@bastani/atomic 0.10.11-alpha.1 → 0.10.11-alpha.3

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 (457) hide show
  1. package/CHANGELOG.md +155 -0
  2. package/README.md +5 -8
  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 +9 -9
  7. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +8 -8
  8. package/dist/_shared/mode-shared-2QJSCUM6.js +9 -9
  9. package/dist/_shared/p0-cli-BB45ZQY6.js +46 -67
  10. package/dist/_shared/p0-cli-BB45ZQY6.js.map +1 -1
  11. package/dist/_shared/p1a-prewarm-XIU57JHF.js +7 -8
  12. package/dist/_shared/p1a-prewarm-XIU57JHF.js.map +1 -1
  13. package/dist/_shared/{p1b-elig-ENCUPKKJ.js → p1b-elig-TVB5CBLL.js} +14 -2
  14. package/dist/_shared/{p1b-elig-ENCUPKKJ.js.map → p1b-elig-TVB5CBLL.js.map} +1 -1
  15. package/dist/_shared/runtime-O4KCSG4C.js +5 -5
  16. package/dist/_shared/{sdk-AVFII7NK.js → sdk-B5LEWGGI.js} +2633 -488
  17. package/dist/_shared/sdk-B5LEWGGI.js.map +1 -0
  18. package/dist/_shared/session-data-AHTU7IS6.js +3 -3
  19. package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
  20. package/dist/_shared/settings-startup-8-DNZ2RIHM.js +1 -1
  21. package/dist/_shared/{settings-startup-4QCVCI53.js → settings-startup-HXQLSUWM.js} +8 -2
  22. package/dist/_shared/settings-startup-HXQLSUWM.js.map +1 -0
  23. package/dist/_shared/{startup-0-0-57KF6LZH.js → startup-0-0-EZUKEP4Q.js} +436 -51
  24. package/dist/_shared/startup-0-0-EZUKEP4Q.js.map +1 -0
  25. package/dist/_shared/{startup-0-1-GIY75K46.js → startup-0-1-RTOHJFDJ.js} +240 -279
  26. package/dist/_shared/startup-0-1-RTOHJFDJ.js.map +1 -0
  27. package/dist/_shared/{startup-0-2-27OWFHV6.js → startup-0-2-5QHPCEON.js} +254 -46
  28. package/dist/_shared/startup-0-2-5QHPCEON.js.map +1 -0
  29. package/dist/_shared/{startup-0-3-T4DVFYWX.js → startup-0-3-4ZYBYQNM.js} +273 -14
  30. package/dist/_shared/startup-0-3-4ZYBYQNM.js.map +1 -0
  31. package/dist/_shared/startup-0-4-ZMJV547D.js +14 -9
  32. package/dist/_shared/startup-0-4-ZMJV547D.js.map +1 -1
  33. package/dist/_shared/startup-0-5-YDW47QX6.js +10 -10
  34. package/dist/_shared/startup-0-5-YDW47QX6.js.map +1 -1
  35. package/dist/_shared/startup-10-0-TDQNBDDL.js +9 -9
  36. package/dist/_shared/startup-12-0-55AAXBJZ.js +3 -3
  37. package/dist/_shared/startup-14-0-MLX36RBG.js +6 -7
  38. package/dist/_shared/startup-14-0-MLX36RBG.js.map +1 -1
  39. package/dist/_shared/startup-15-0-YUKGAC63.js +7 -7
  40. package/dist/_shared/startup-15-1-4S7FLMNG.js +22 -30
  41. package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
  42. package/dist/_shared/startup-8-0-34CBHPZH.js +455 -102
  43. package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
  44. package/dist/_shared/{startup-8-1-X32CYSXB.js → startup-8-1-LZFXSD3Z.js} +162 -1184
  45. package/dist/_shared/startup-8-1-LZFXSD3Z.js.map +1 -0
  46. package/dist/_shared/storage-command-7MGXLJGZ.js +189 -36
  47. package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
  48. package/dist/_shared/storage-status-K7PX2RXA.js +557 -0
  49. package/dist/_shared/storage-status-K7PX2RXA.js.map +1 -0
  50. package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
  51. package/dist/_shared/team-DOQKICG2.js +376 -0
  52. package/dist/_shared/team-DOQKICG2.js.map +1 -0
  53. package/dist/_shared/tree-outline-MUEPK5B7.js +3 -3
  54. package/dist/builtin/intercom/CHANGELOG.md +34 -0
  55. package/dist/builtin/intercom/README.md +2 -2
  56. package/dist/builtin/intercom/broker/broker.bundle.mjs +1091 -344
  57. package/dist/builtin/intercom/broker/database-wake-up-bus.ts +243 -64
  58. package/dist/builtin/intercom/broker/multinode-router.ts +154 -22
  59. package/dist/builtin/intercom/broker/multinode-state-store.ts +30 -3
  60. package/dist/builtin/intercom/broker/open-broker-state.ts +14 -0
  61. package/dist/builtin/intercom/broker/sql-add-column.ts +29 -5
  62. package/dist/builtin/intercom/broker/sql-ended-child-queue-store.ts +3 -2
  63. package/dist/builtin/intercom/broker/sql-held-send-store.ts +2 -2
  64. package/dist/builtin/intercom/broker/sql-known-session-store.ts +43 -19
  65. package/dist/builtin/intercom/broker/sql-lease-store.ts +208 -101
  66. package/dist/builtin/intercom/broker/sql-outbox-store.ts +516 -102
  67. package/dist/builtin/intercom/broker/sql-pending-ask-store.ts +8 -5
  68. package/dist/builtin/intercom/broker/sql-released-ask-store.ts +12 -5
  69. package/dist/builtin/intercom/broker/sql-restoring-reservation-store.ts +24 -7
  70. package/dist/builtin/intercom/broker/sql-retention.ts +141 -0
  71. package/dist/builtin/intercom/broker/sql-schema.ts +199 -27
  72. package/dist/builtin/intercom/broker/sql-sent-message-authority.ts +74 -19
  73. package/dist/builtin/intercom/broker/wake-up-bus.ts +6 -0
  74. package/dist/builtin/intercom/index.bundle.mjs +2 -3
  75. package/dist/builtin/intercom/package.json +1 -1
  76. package/dist/builtin/mcp/index.bundle.mjs +1 -1
  77. package/dist/builtin/mcp/package.json +1 -1
  78. package/dist/builtin/subagents/CHANGELOG.md +6 -0
  79. package/dist/builtin/subagents/package.json +1 -1
  80. package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -1
  81. package/dist/builtin/web-access/index.bundle.mjs +2 -10
  82. package/dist/builtin/web-access/package.json +1 -1
  83. package/dist/bun/bundled-sqlite.js +41 -0
  84. package/dist/bun/bundled-sqlite.js.map +1 -0
  85. package/dist/cli/args.js +2 -2
  86. package/dist/cli/auth-cli.code.js +6 -6
  87. package/dist/cli/auth-cli.impl.js +3 -3
  88. package/dist/cli/auth-cli.js +3 -3
  89. package/dist/cli/blueprint-command.code.js +4 -4
  90. package/dist/cli/blueprint-command.impl.js +3 -3
  91. package/dist/cli/blueprint-command.js +3 -3
  92. package/dist/cli/intercom-command.code.js +4 -4
  93. package/dist/cli/intercom-command.code.js.map +1 -1
  94. package/dist/cli/intercom-command.impl.js +3 -3
  95. package/dist/cli/intercom-command.js +3 -3
  96. package/dist/cli/list-models.code.js +2 -2
  97. package/dist/cli/list-models.impl.js +3 -3
  98. package/dist/cli/list-models.js +3 -3
  99. package/dist/cli/session-picker.code.js +2 -2
  100. package/dist/cli/session-picker.impl.js +3 -3
  101. package/dist/cli/session-picker.js +3 -3
  102. package/dist/cli/startup-ui.code.js +2 -2
  103. package/dist/cli/startup-ui.impl.js +3 -3
  104. package/dist/cli/startup-ui.js +3 -3
  105. package/dist/cli/storage-command.impl.js +3 -3
  106. package/dist/cli/storage-command.js +3 -3
  107. package/dist/cli/storage-search-session.code.js +3 -3
  108. package/dist/cli/storage-search-session.impl.js +3 -3
  109. package/dist/cli/storage-search-session.js +3 -3
  110. package/dist/cli/team-command.code.js +20 -114
  111. package/dist/cli/team-command.code.js.map +1 -1
  112. package/dist/cli/team-command.impl.js +3 -3
  113. package/dist/cli/team-command.js +3 -3
  114. package/dist/cli.js +5 -18
  115. package/dist/cli.js.map +1 -1
  116. package/dist/core/agent-rehydrate-errors.d.ts +4 -9
  117. package/dist/core/compaction/compactor.d.ts +3 -3
  118. package/dist/core/debug.code.js +1 -1
  119. package/dist/core/debug.impl.js +3 -3
  120. package/dist/core/debug.js +3 -3
  121. package/dist/core/export-html/card-projection.impl.js +3 -3
  122. package/dist/core/export-html/card-projection.js +3 -3
  123. package/dist/core/export-html/index.code.js +2 -2
  124. package/dist/core/export-html/index.impl.js +3 -3
  125. package/dist/core/export-html/index.js +3 -3
  126. package/dist/core/export-html/json-spans.impl.js +3 -3
  127. package/dist/core/export-html/json-spans.js +3 -3
  128. package/dist/core/export-html/oversized-render-inputs.code.js +1 -1
  129. package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
  130. package/dist/core/export-html/oversized-render-inputs.js +3 -3
  131. package/dist/core/export-html/tool-renderer.impl.js +3 -3
  132. package/dist/core/export-html/tool-renderer.js +3 -3
  133. package/dist/core/extensions/jiti-loader.impl.js +3 -3
  134. package/dist/core/extensions/jiti-loader.js +3 -3
  135. package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
  136. package/dist/core/extensions/jiti-static-loader.js +3 -3
  137. package/dist/core/extensions/loader-host-modules.code.js +1 -1
  138. package/dist/core/extensions/loader-host-modules.impl.js +3 -3
  139. package/dist/core/extensions/loader-host-modules.js +3 -3
  140. package/dist/core/extensions/loader-virtual-modules.js +1 -1
  141. package/dist/core/extensions/runner-context.js +3 -3
  142. package/dist/core/intercom-broker-control-host.code.js +2 -2
  143. package/dist/core/intercom-broker-control-host.impl.js +3 -3
  144. package/dist/core/intercom-broker-control-host.js +3 -3
  145. package/dist/core/intercom-broker-control.code.js +3 -3
  146. package/dist/core/intercom-broker-control.impl.js +3 -3
  147. package/dist/core/intercom-broker-control.js +3 -3
  148. package/dist/core/package-manager-storage-adapters.code.js +1 -1
  149. package/dist/core/package-manager-storage-adapters.impl.js +3 -3
  150. package/dist/core/package-manager-storage-adapters.js +3 -3
  151. package/dist/core/process-start-token.d.ts +8 -0
  152. package/dist/core/process-tree-containment.d.ts +16 -0
  153. package/dist/core/sdk-types.d.ts +1 -2
  154. package/dist/core/sdk-types.js.map +1 -1
  155. package/dist/core/sdk.code.js +4 -4
  156. package/dist/core/sdk.impl.js +3 -3
  157. package/dist/core/sdk.js +3 -3
  158. package/dist/core/session-manager-core.js +27 -15
  159. package/dist/core/session-manager-core.js.map +1 -1
  160. package/dist/core/session-manager-list.impl.js +3 -3
  161. package/dist/core/session-manager-list.js +3 -3
  162. package/dist/core/session-manager.code.js +3 -3
  163. package/dist/core/session-manager.impl.js +3 -3
  164. package/dist/core/session-manager.js +3 -3
  165. package/dist/core/session-open-markers.js +3 -0
  166. package/dist/core/session-open-markers.js.map +1 -0
  167. package/dist/core/session-storage.code.js +1 -1
  168. package/dist/core/session-storage.impl.js +3 -3
  169. package/dist/core/session-storage.js +3 -3
  170. package/dist/core/settings-schema.d.ts +0 -3
  171. package/dist/core/storage/added-exports-0-10-11.js +19 -0
  172. package/dist/core/storage/added-exports-0-10-11.js.map +1 -0
  173. package/dist/core/storage/added-exports.js +3 -0
  174. package/dist/core/storage/added-exports.js.map +1 -1
  175. package/dist/core/storage/creation-time.js +105 -0
  176. package/dist/core/storage/creation-time.js.map +1 -0
  177. package/dist/core/storage/database.d.ts +56 -5
  178. package/dist/core/storage/database.js.map +1 -1
  179. package/dist/core/storage/dialect.d.ts +1 -1
  180. package/dist/core/storage/dialect.js +1 -1
  181. package/dist/core/storage/dialect.js.map +1 -1
  182. package/dist/core/storage/errors.d.ts +13 -13
  183. package/dist/core/storage/errors.js +10 -16
  184. package/dist/core/storage/errors.js.map +1 -1
  185. package/dist/core/storage/fenced-paths.d.ts +11 -0
  186. package/dist/core/storage/fenced-paths.js +11 -0
  187. package/dist/core/storage/fenced-paths.js.map +1 -1
  188. package/dist/core/storage/file-identity.d.ts +2 -0
  189. package/dist/core/storage/file-identity.js +24 -8
  190. package/dist/core/storage/file-identity.js.map +1 -1
  191. package/dist/core/storage/index.d.ts +4 -3
  192. package/dist/core/storage/index.js +5 -3
  193. package/dist/core/storage/index.js.map +1 -1
  194. package/dist/core/storage/libsql-removed.d.ts +71 -0
  195. package/dist/core/storage/libsql-removed.js +123 -0
  196. package/dist/core/storage/libsql-removed.js.map +1 -0
  197. package/dist/core/storage/migrations.d.ts +81 -8
  198. package/dist/core/storage/migrations.js +386 -47
  199. package/dist/core/storage/migrations.js.map +1 -1
  200. package/dist/core/storage/node-sqlite-file-gate.js +0 -15
  201. package/dist/core/storage/node-sqlite-file-gate.js.map +1 -1
  202. package/dist/core/storage/node-sqlite-thread.js +36 -12
  203. package/dist/core/storage/node-sqlite-thread.js.map +1 -1
  204. package/dist/core/storage/node-sqlite.js +135 -3
  205. package/dist/core/storage/node-sqlite.js.map +1 -1
  206. package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
  207. package/dist/core/storage/offline-snapshot-file.js +3 -3
  208. package/dist/core/storage/prefix.d.ts +1 -1
  209. package/dist/core/storage/prefix.js +14 -2
  210. package/dist/core/storage/prefix.js.map +1 -1
  211. package/dist/core/storage/process-selection.d.ts +5 -5
  212. package/dist/core/storage/provider.js +2 -2
  213. package/dist/core/storage/schema-catalog.d.ts +82 -5
  214. package/dist/core/storage/schema-catalog.js +244 -34
  215. package/dist/core/storage/schema-catalog.js.map +1 -1
  216. package/dist/core/storage/selection.d.ts +7 -82
  217. package/dist/core/storage/selection.js +20 -235
  218. package/dist/core/storage/selection.js.map +1 -1
  219. package/dist/core/storage/session/branch-fork-source.code.js +9 -8
  220. package/dist/core/storage/session/branch-fork-source.code.js.map +1 -1
  221. package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
  222. package/dist/core/storage/session/branch-fork-source.js +3 -3
  223. package/dist/core/storage/session/card-view.impl.js +3 -3
  224. package/dist/core/storage/session/card-view.js +3 -3
  225. package/dist/core/storage/session/child-reader.code.js +4 -4
  226. package/dist/core/storage/session/child-reader.impl.js +3 -3
  227. package/dist/core/storage/session/child-reader.js +3 -3
  228. package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
  229. package/dist/core/storage/session/chunked-resume-projection.js +3 -3
  230. package/dist/core/storage/session/errors.js +1 -1
  231. package/dist/core/storage/session/expanded-child-details.code.js +3 -3
  232. package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
  233. package/dist/core/storage/session/expanded-child-details.js +3 -3
  234. package/dist/core/storage/session/fork-detach.d.ts +118 -0
  235. package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
  236. package/dist/core/storage/session/fork-row-bytes.js +3 -3
  237. package/dist/core/storage/session/fork-row-index.impl.js +3 -3
  238. package/dist/core/storage/session/fork-row-index.js +3 -3
  239. package/dist/core/storage/session/fork-schema.js +53 -0
  240. package/dist/core/storage/session/fork-schema.js.map +1 -0
  241. package/dist/core/storage/session/fork-segments.d.ts +58 -0
  242. package/dist/core/storage/session/fork-staging.code.js +5 -8
  243. package/dist/core/storage/session/fork-staging.code.js.map +1 -1
  244. package/dist/core/storage/session/fork-staging.impl.js +3 -3
  245. package/dist/core/storage/session/fork-staging.js +3 -3
  246. package/dist/core/storage/session/fork-sweep.js +61 -0
  247. package/dist/core/storage/session/fork-sweep.js.map +1 -0
  248. package/dist/core/storage/session/fork-window.code.js +4 -4
  249. package/dist/core/storage/session/fork-window.impl.js +3 -3
  250. package/dist/core/storage/session/fork-window.js +3 -3
  251. package/dist/core/storage/session/history-pages.impl.js +3 -3
  252. package/dist/core/storage/session/history-pages.js +3 -3
  253. package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
  254. package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
  255. package/dist/core/storage/session/jsonl-session-store.d.ts +42 -2
  256. package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
  257. package/dist/core/storage/session/jsonl-session-store.js +3 -3
  258. package/dist/core/storage/session/memory-session-store.impl.js +3 -3
  259. package/dist/core/storage/session/memory-session-store.js +3 -3
  260. package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
  261. package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
  262. package/dist/core/storage/session/pinned-branch-resume.js +3 -3
  263. package/dist/core/storage/session/released-history-files.code.js +4 -4
  264. package/dist/core/storage/session/released-history-files.impl.js +3 -3
  265. package/dist/core/storage/session/released-history-files.js +3 -3
  266. package/dist/core/storage/session/resident-fork-rows.code.js +1 -1
  267. package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
  268. package/dist/core/storage/session/resident-fork-rows.js +3 -3
  269. package/dist/core/storage/session/session-resume.impl.js +3 -3
  270. package/dist/core/storage/session/session-resume.js +3 -3
  271. package/dist/core/storage/session/session-search-index.d.ts +43 -4
  272. package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
  273. package/dist/core/storage/session/snapshot-cut.js +3 -3
  274. package/dist/core/storage/session/snapshot-history.code.js +4 -4
  275. package/dist/core/storage/session/snapshot-history.impl.js +3 -3
  276. package/dist/core/storage/session/snapshot-history.js +3 -3
  277. package/dist/core/storage/session/sql-session-store.code.js +1 -1
  278. package/dist/core/storage/session/sql-session-store.d.ts +394 -20
  279. package/dist/core/storage/session/sql-session-store.impl.js +4 -4
  280. package/dist/core/storage/session/sql-session-store.js +4 -4
  281. package/dist/core/storage/session/tree-outline.impl.js +3 -3
  282. package/dist/core/storage/session/tree-outline.js +3 -3
  283. package/dist/core/storage/session/tree-presentation.impl.js +3 -3
  284. package/dist/core/storage/session/tree-presentation.js +3 -3
  285. package/dist/core/storage/session/types.d.ts +22 -0
  286. package/dist/core/storage/sqlite-facade.d.ts +23 -2
  287. package/dist/core/storage/sqlite-facade.js +34 -0
  288. package/dist/core/storage/sqlite-facade.js.map +1 -1
  289. package/dist/core/storage/storage-status.code.js +1 -1
  290. package/dist/core/storage/storage-status.impl.js +3 -3
  291. package/dist/core/storage/storage-status.js +3 -3
  292. package/dist/core/storage/team.code.js +1 -1
  293. package/dist/core/storage/team.d.ts +26 -115
  294. package/dist/core/storage/team.impl.js +3 -3
  295. package/dist/core/storage/team.js +3 -3
  296. package/dist/core/structured-output/index.code.js +1 -1
  297. package/dist/core/structured-output/index.impl.js +3 -3
  298. package/dist/core/structured-output/index.js +3 -3
  299. package/dist/core/tasks/task-completion-entry.impl.js +3 -3
  300. package/dist/core/tasks/task-completion-entry.js +3 -3
  301. package/dist/core/tasks/task-file-history.code.js +4 -4
  302. package/dist/core/tasks/task-file-history.impl.js +3 -3
  303. package/dist/core/tasks/task-file-history.js +3 -3
  304. package/dist/core/tasks/task-reference-archive.code.js +5 -5
  305. package/dist/core/tasks/task-reference-archive.js +3 -3
  306. package/dist/core/tasks/task-reference-identity.js +3 -3
  307. package/dist/core/tasks/task-reference-stream.impl.js +3 -3
  308. package/dist/core/tasks/task-reference-stream.js +3 -3
  309. package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
  310. package/dist/core/tasks/task-unsaved-answer.js +3 -3
  311. package/dist/core/tasks/task-view-source.code.js +1 -1
  312. package/dist/core/tasks/task-view-source.impl.js +3 -3
  313. package/dist/core/tasks/task-view-source.js +3 -3
  314. package/dist/core/tools/history-session.d.ts +2 -0
  315. package/dist/core/tools/history-tasks.d.ts +3 -2
  316. package/dist/core/tools/read-url.code.js +4 -4
  317. package/dist/core/tools/read-url.impl.js +3 -3
  318. package/dist/core/tools/read-url.js +3 -3
  319. package/dist/core/worktree-snapshot/blob-store.d.ts +71 -3
  320. package/dist/core/worktree-snapshot/blob-store.js +575 -67
  321. package/dist/core/worktree-snapshot/blob-store.js.map +1 -1
  322. package/dist/core/worktree-snapshot/errors.code.js +3 -3
  323. package/dist/core/worktree-snapshot/errors.impl.js +3 -3
  324. package/dist/core/worktree-snapshot/errors.js +3 -3
  325. package/dist/core/worktree-snapshot/fork-blob-guard.js +81 -0
  326. package/dist/core/worktree-snapshot/fork-blob-guard.js.map +1 -0
  327. package/dist/core/worktree-snapshot/fork-snapshot-index.js +162 -0
  328. package/dist/core/worktree-snapshot/fork-snapshot-index.js.map +1 -0
  329. package/dist/core/worktree-snapshot/session-index-reset.code.js +4 -0
  330. package/dist/core/worktree-snapshot/session-index-reset.code.js.map +1 -1
  331. package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
  332. package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
  333. package/dist/extensions/codemode/execute.code.js +2 -2
  334. package/dist/extensions/codemode/execute.impl.js +3 -3
  335. package/dist/extensions/codemode/execute.js +3 -3
  336. package/dist/extensions/codemode/renderer.code.js +2 -2
  337. package/dist/extensions/codemode/renderer.impl.js +3 -3
  338. package/dist/extensions/codemode/renderer.js +3 -3
  339. package/dist/extensions/mcp/cli.code.js +3 -3
  340. package/dist/extensions/mcp/cli.impl.js +3 -3
  341. package/dist/extensions/mcp/cli.js +3 -3
  342. package/dist/extensions/mcp/cli.lazy.code.js +2 -2
  343. package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
  344. package/dist/extensions/mcp/cli.lazy.js +3 -3
  345. package/dist/extensions/mcp/runtime.code.js +1 -1
  346. package/dist/extensions/mcp/runtime.impl.js +3 -3
  347. package/dist/extensions/mcp/runtime.js +3 -3
  348. package/dist/index.d.ts +3 -1
  349. package/dist/index.js +8 -8
  350. package/dist/main-first-time-setup.code.js +2 -2
  351. package/dist/main-first-time-setup.impl.js +3 -3
  352. package/dist/main-first-time-setup.js +3 -3
  353. package/dist/main.js +1 -1
  354. package/dist/modes/interactive/components/stored-tree-view.code.js +3 -3
  355. package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
  356. package/dist/modes/interactive/components/stored-tree-view.js +3 -3
  357. package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
  358. package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
  359. package/dist/modes/interactive/startup-shell-eligibility.js +1 -1
  360. package/dist/modes/interactive-engine/engine-prewarm.d.ts +1 -1
  361. package/dist/modes/print-mode.js +1 -1
  362. package/dist/package-manager-cli.code.js +7 -7
  363. package/dist/package-manager-cli.impl.js +3 -3
  364. package/dist/package-manager-cli.js +3 -3
  365. package/dist/rpc-entry.js +1 -1
  366. package/dist/startup-files.json +1 -1
  367. package/dist/startup-stages/10.js +1 -1
  368. package/dist/startup-stages/11.js +1 -1
  369. package/dist/startup-stages/12.js +1 -1
  370. package/dist/startup-stages/2.js +2 -3
  371. package/dist/startup-stages/3.js +1 -3
  372. package/dist/startup-stages/4.js +1 -2
  373. package/dist/startup-stages/5.js +1 -1
  374. package/dist/startup-stages/6.js +5 -7
  375. package/dist/startup-stages/7.js +3 -6
  376. package/dist/startup-stages/8.js +7 -2
  377. package/dist/startup-stages/9.js +1 -7
  378. package/dist/startup-stages/stages.json +1 -1
  379. package/dist/utils/compile-cache-deferral.js +8 -13
  380. package/dist/utils/compile-cache-deferral.js.map +1 -1
  381. package/dist/utils/compile-cache-warmup-host.js +3 -4
  382. package/dist/utils/compile-cache-warmup-host.js.map +1 -1
  383. package/dist/utils/compile-cache.js +12 -100
  384. package/dist/utils/compile-cache.js.map +1 -1
  385. package/dist/utils/startup-database-spare.code.js +3 -3
  386. package/dist/utils/startup-database-spare.impl.js +3 -3
  387. package/dist/utils/startup-database-spare.js +3 -3
  388. package/dist/utils/tools-manager.code.js +1 -1
  389. package/dist/utils/tools-manager.impl.js +3 -3
  390. package/dist/utils/tools-manager.js +3 -3
  391. package/dist/utils/worker-threads.js +2 -15
  392. package/dist/utils/worker-threads.js.map +1 -1
  393. package/docs/build.md +3 -3
  394. package/docs/changelog.mdx +1421 -69
  395. package/docs/compaction/reference.md +5 -5
  396. package/docs/compaction.md +7 -9
  397. package/docs/containerization.md +2 -2
  398. package/docs/custom-provider/api-reference.md +1 -1
  399. package/docs/docs.json +37 -10
  400. package/docs/environment-variables.md +0 -2
  401. package/docs/extensions/api-reference.md +4 -4
  402. package/docs/getting-started/installation.md +3 -0
  403. package/docs/guides/configuration.md +1 -1
  404. package/docs/guides/non-interactive.md +1 -1
  405. package/docs/guides/resume-on-any-machine.md +14 -22
  406. package/docs/guides/team-setup.md +56 -83
  407. package/docs/guides.md +2 -4
  408. package/docs/herdr.md +1 -1
  409. package/docs/index.md +1 -1
  410. package/docs/intercom/operations.md +26 -21
  411. package/docs/intercom/reference.md +2 -2
  412. package/docs/intercom.md +1 -1
  413. package/docs/libraries/storage-postgres.md +9 -9
  414. package/docs/libraries.md +2 -3
  415. package/docs/models-configuration.md +2 -2
  416. package/docs/models.md +2 -3
  417. package/docs/packages/authoring.md +7 -7
  418. package/docs/packages.md +1 -1
  419. package/docs/programmatic.md +2 -2
  420. package/docs/quickstart.md +1 -1
  421. package/docs/reference/cli.md +6 -11
  422. package/docs/reference.md +2 -2
  423. package/docs/rpc/extension-ui.md +2 -2
  424. package/docs/sdk/reference.md +5 -4
  425. package/docs/sdk/storage.md +8 -92
  426. package/docs/sdk/structured-decisions.md +1 -1
  427. package/docs/sdk/web-server.md +3 -3
  428. package/docs/sdk.md +14 -4
  429. package/docs/security.md +1 -1
  430. package/docs/session-format.md +5 -5
  431. package/docs/sessions.md +31 -42
  432. package/docs/settings.md +7 -8
  433. package/docs/storage/custom-adapters.md +255 -0
  434. package/docs/storage/jsonl.md +117 -0
  435. package/docs/{guides/postgres-pgbouncer.md → storage/postgres/pgbouncer.md} +73 -68
  436. package/docs/storage/postgres/tuning.md +337 -0
  437. package/docs/storage/postgres.md +556 -0
  438. package/docs/storage/sqlite.md +99 -0
  439. package/docs/storage.md +333 -956
  440. package/docs/subagents/authoring.md +1 -1
  441. package/docs/subagents.md +2 -2
  442. package/docs/tools.md +1 -1
  443. package/docs/worktree-snapshots.md +2 -2
  444. package/package.json +9 -9
  445. package/schemas/models.schema.json +2 -2
  446. package/schemas/settings.schema.json +0 -14
  447. package/dist/_shared/sdk-AVFII7NK.js.map +0 -1
  448. package/dist/_shared/settings-startup-4QCVCI53.js.map +0 -1
  449. package/dist/_shared/startup-0-0-57KF6LZH.js.map +0 -1
  450. package/dist/_shared/startup-0-1-GIY75K46.js.map +0 -1
  451. package/dist/_shared/startup-0-2-27OWFHV6.js.map +0 -1
  452. package/dist/_shared/startup-0-3-T4DVFYWX.js.map +0 -1
  453. package/dist/_shared/startup-8-1-X32CYSXB.js.map +0 -1
  454. package/dist/core/intercom-broker-control.d.ts +0 -129
  455. package/dist/startup-stages/13.js +0 -1
  456. package/docs/guides/postgres-tuning.md +0 -311
  457. package/docs/libraries/storage-libsql.md +0 -97
@@ -1,29 +1,29 @@
1
1
  import { __commonJSMin, __name, __require, __toESM } from "./rolldown-runtime-BGM3D5V3.js";
2
2
  import { APP_NAME, BUILTIN_PACKAGE_DIR_NAMES, CONFIG_DIR_NAME, ENV_AGENT_DIR, ENV_DEBUG, ENV_OFFLINE, ENV_PACKAGE_DIR, ENV_SELF_UPDATE_COMMAND, ENV_SESSION_DIR, ENV_SHARE_VIEWER_URL, ENV_STDIN_TIMEOUT_MS, ENV_TELEMETRY, INSTALLED_EXTENSION_ENTRIES, SOURCE_EXTENSION_ENTRIES, VERSION, createChildProcessEnvironment, createModuleRequire, findHelperExecutableAsync, getAgentDir, getAgentDirs, getBinDir, getEnvValue, getPackageDir, helperLaunchAsync, isBunBinary, isBundledBuild, isChildProcessExitStatusUnknownError, missingHelperOptions, resolvePath, stripBom, waitForChildProcess } from "./p0-cli-BB45ZQY6.js";
3
- import { BUILTIN_HELP_TOOL_NAMES, BUILTIN_PATH_PREFIX, CountdownTimer, Diff, DynamicBorder, EventSourceError, FORKED_PACKAGE_NAMES, FileToolAbortedError, FramedSelector, GIT_MINIMUM_VERSION, GitProvisionConfigError, GitProvisionTimeoutError, GitUnavailableError, JSON_RPC_ERROR_CODES, LlamaServerRequestError, LlamaServerUnreachableError, MAX_POSITION_LENGTH, MAX_TOOL_DETACHMENT_AFTER_MS, ManagedToolDownloadError, ManagedToolTimeoutError, McpAbortError, McpConnectionClosedError, McpError, McpTimeoutError, ROW_INTENT_META, STALE_EXTENSION_CONTEXT_MESSAGE, SUPPORTED_PROTOCOL_VERSIONS, Stop, SubscriptionClosedError, SubscriptionConfigError, SubscriptionEventError, SubscriptionHandlerError, SubscriptionRecordError, TASK_MARKS, TaskCleanupError, TaskEvictedError, ToolDetachmentError, VALID_THINKING_LEVELS, abortSymbol, applyExifOrientation, applySessionSummaryEntries, asyncScope, attachCleanupCause as attachCleanupCause$1, attachGitCleanupFailure, attachSessionClaim, cancelReasonText, canonicalEventBusFor, captureHerdrEnvironment, combineUsage, compactTemplate, compactUrl, createGitEnvironment, createOwnedAbortController, decodeChatOrder, decodeChatRecord, defaultToolNamesFor, deserializeToolDetachmentError, encodeChatOrder, fetchWithRetry, fieldTone, firstChatOrders, flushable, formatSize, formatTodoId, formatTokenCount, getBuiltinPackageLocations, getDefaultCacheRetention, getDefaultSessionDirPath, getFinalValue, getFunctionList, getManyValues, getPiUserAgent, getProviderLoginHelp, getResourcePathKeyAsync, getTodoStatus, getTodoTitle, getToolListError, holdProcessDescendants, isEventSourceError, isExtensionStartupFailure, isFinalValue, isFlushable, isFunctionList, isGitProvisionError, isGitUnavailableError, isInstallTelemetryEnabled, isJsonRpcId, isJsonRpcNotification, isJsonRpcRequest, isJsonRpcResponse, isManagedToolError, isMandatoryRuntimeTool, isMany, isObject, isPathInside, isStop, isSyntheticPath, isTodoClosed, isTrustedMandatoryRuntimeTool, isValidThinkingLevel, leadingAndTrailingWs, leadingWs, longestCommonPrefix, longestCommonSuffix, materializeSessionSummaryMetadata, maximumOverlap, mergeReadRanges, none, normalizeDisplayText, normalizeTodoId, parseTranscriptFrameLayout, registerCanonicalEventBus, removePrefix, removeSuffix, renderToolPath, replacePrefix, replaceSuffix, replaceTabs, reportContained, require_constants, require_debug, require_identity, require_ignore, require_parse_url, require_sha256, require_stringifyNumber, require_util_contains_newline, rowTone, segment, sessionWriteTransaction, setFunctionList, sharedClockNow, sharedWakeDispatcher, sleep as sleep$1, spanElapsedMs, spawnHostProcess, splitTodosByAssignment, stop, str as str$1, stripFenceMarkers, styleFieldTone, summarizeSession, toError, trailingWs, uniquifyToolCallIds, validQuestionnaire, withCleanup, withLegacyPackageNames, yieldToEventLoop, yieldTurn } from "./startup-0-0-57KF6LZH.js";
3
+ import { BUILTIN_HELP_TOOL_NAMES, BUILTIN_PATH_PREFIX, CountdownTimer, Diff, DynamicBorder, EventSourceError, FORKED_PACKAGE_NAMES, FileToolAbortedError, FramedSelector, GIT_MINIMUM_VERSION, GitProvisionConfigError, GitProvisionTimeoutError, GitUnavailableError, JSON_RPC_ERROR_CODES, LlamaServerRequestError, LlamaServerUnreachableError, MAX_POSITION_LENGTH, MAX_TOOL_DETACHMENT_AFTER_MS, ManagedToolDownloadError, ManagedToolTimeoutError, McpAbortError, McpConnectionClosedError, McpError, McpTimeoutError, ROW_INTENT_META, STALE_EXTENSION_CONTEXT_MESSAGE, SUPPORTED_PROTOCOL_VERSIONS, Stop, SubscriptionClosedError, SubscriptionConfigError, SubscriptionEventError, SubscriptionHandlerError, SubscriptionRecordError, TASK_MARKS, TaskCleanupError, TaskEvictedError, ToolDetachmentError, VALID_THINKING_LEVELS, abortSymbol, applyExifOrientation, applySessionSummaryEntries, asyncScope, attachCleanupCause as attachCleanupCause$1, attachGitCleanupFailure, canWatchProcessUntilHostDies, cancelReasonText, canonicalEventBusFor, captureHerdrEnvironment, combineUsage, compactTemplate, compactUrl, createGitEnvironment, createOwnedAbortController, decodeChatOrder, decodeChatRecord, defaultToolNamesFor, deserializeToolDetachmentError, encodeChatOrder, fetchWithRetry, fieldTone, firstChatOrders, flushable, formatSize, formatTodoId, formatTokenCount, getBuiltinPackageLocations, getDefaultCacheRetention, getDefaultSessionDirPath, getFinalValue, getFunctionList, getManyValues, getPiUserAgent, getProviderLoginHelp, getResourcePathKeyAsync, getTodoStatus, getTodoTitle, getToolListError, holdProcessDescendants, isEventSourceError, isExtensionStartupFailure, isFinalValue, isFlushable, isFunctionList, isGitProvisionError, isGitUnavailableError, isInstallTelemetryEnabled, isJsonRpcId, isJsonRpcNotification, isJsonRpcRequest, isJsonRpcResponse, isManagedToolError, isMandatoryRuntimeTool, isMany, isObject, isPathInside, isStop, isSyntheticPath, isTodoClosed, isTrustedMandatoryRuntimeTool, isValidThinkingLevel, joinForkSegments, leadingAndTrailingWs, leadingWs, longestCommonPrefix, longestCommonSuffix, materializeSessionSummaryMetadata, maximumOverlap, mergeReadRanges, none, normalizeDisplayText, normalizeTodoId, parseTranscriptFrameLayout, registerCanonicalEventBus, removePrefix, removeSuffix, renderToolPath, replacePrefix, replaceSuffix, replaceTabs, reportContained, require_constants, require_debug, require_identity, require_ignore, require_parse_url, require_sha256, require_stringifyNumber, require_util_contains_newline, rowTone, segment, segmentLength, setFunctionList, sharedWakeDispatcher, sleep as sleep$1, spanElapsedMs, spawnHostProcess, splitTodosByAssignment, stop, str as str$1, stripFenceMarkers, styleFieldTone, summarizeSession, toError, trailingWs, uniquifyToolCallIds, validQuestionnaire, watchProcessUntilHostDies, withCleanup, withLegacyPackageNames, yieldToEventLoop, yieldTurn } from "./startup-0-0-EZUKEP4Q.js";
4
4
  import { CodeHighlighter, OVERLAY_ACTIVE_ROW_MARKER, getLanguageFromPath, graphemeAt, highlightCode, keyHint, loadPhoton, navActionText, navFirstKeyText, parenthesizedKeyHint, rawKeyHint, renderNavHintLine, singleLineDisplayText, terminalDisplayCursor, terminalDisplayText, theme } from "./p2-shell-main-B2WIALFD.js";
5
- import { failureDebugFields, findInCauseChain, hasErrorIdentity, ownProcessStartToken, readProcessStartToken, reportDebugAsync, serializeErrorCause } from "./p1b-elig-ENCUPKKJ.js";
5
+ import { failureDebugFields, findInCauseChain, hasErrorIdentity, reportDebugAsync, serializeErrorCause } from "./p1b-elig-TVB5CBLL.js";
6
6
  import { windowsPowerShellEnvironment } from "./p1-elig-shell-WWRO3L2R.js";
7
- import { SessionOpenElsewhereError, parseSerializedDecisionError } from "./settings-startup-4QCVCI53.js";
7
+ import { parseSerializedDecisionError } from "./settings-startup-HXQLSUWM.js";
8
8
  import { SETTINGS_DEFAULTS } from "./p2-common-YLSYXMDQ.js";
9
9
  import { interactiveEngineStartupEnv } from "./p1a-prewarm-XIU57JHF.js";
10
- import { access, lstat, mkdir, open, readFile, readdir, rename, rm, rmdir, stat, unlink, writeFile } from "node:fs/promises";
10
+ import { access, lstat, open, readFile, readdir, rename, rm, stat, unlink } from "node:fs/promises";
11
11
  import { existsSync, readFileSync, readdirSync, statSync } from "fs";
12
12
  import { basename, delimiter, dirname, isAbsolute, join, relative, resolve, sep } from "path";
13
- import { constants as constants$1, hostname } from "node:os";
13
+ import { constants as constants$1 } from "node:os";
14
14
  import { basename as basename$1, dirname as dirname$1, extname, isAbsolute as isAbsolute$1, join as join$1, relative as relative$1, resolve as resolve$1, sep as sep$1 } from "node:path";
15
15
  import { execFile, spawn, spawnSync } from "node:child_process";
16
16
  import { execFile as execFile$1, spawnSync as spawnSync$1 } from "child_process";
17
17
  import { arch, hostname as hostname$1, platform } from "os";
18
18
  import { pathExists } from "../utils/path-exists.js";
19
- import { constants as constants$2, readFileSync as readFileSync$1, readdirSync as readdirSync$1, rmSync as rmSync$1, rmdirSync as rmdirSync$1, statSync as statSync$1 } from "node:fs";
19
+ import { constants as constants$2, readFileSync as readFileSync$1, readdirSync as readdirSync$1, statSync as statSync$1 } from "node:fs";
20
20
  import { CACHE_WARMING_MAX_AGE_MS, CACHE_WARMING_MAX_IDLE_AGE_MS, GitHubCopilotStreamEndedEarlyError, OAuthRefreshRejectedError, Type, evaluateCacheWarming, findGitHubCopilotError, findTlsCertificateRefusal, getCacheWarmingDelayMs, getCacheWarmingRequestOptions, getCurrentTools, getPromptCacheTtlMs as getPromptCacheTtlMs$1, getTlsCertificateRefusal, isCacheWarmingReplayable, isModelType, isOAuthRefreshRejectedError, isPermanentRefreshRejection, lazyStream, normalizeProviderId, parseOAuthErrorBody, validateToolArguments } from "@bastani/atomic-ai";
21
21
  import { Container, Input, Key, Markdown, Spacer, Text, fuzzyFilter, getCapabilities, getKeybindings, getSelectPageIndex, matchesKey, setImageTranscoder, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@bastani/atomic-tui";
22
22
  import chalk from "chalk";
23
23
  import { SessionBlobError, StorageConfigError, StorageError, isStorageError, rehydrateStorageError, serializeStorageError } from "../core/storage/errors.js";
24
24
  import { renderStorageIdentifiers, storageMigrationTable, validateStoragePrefix } from "../core/storage/prefix.js";
25
25
  import { chmod as chmod$1, lstat as lstat$1, mkdir as mkdir$1, mkdtemp as mkdtemp$1, open as open$1, readFile as readFile$1, readdir as readdir$1, readlink as readlink$1, rename as rename$1, rm as rm$1, stat as stat$2, utimes as utimes$1, writeFile as writeFile$1 } from "fs/promises";
26
- import { createHash, randomBytes, randomUUID } from "node:crypto";
26
+ import { createHash, randomUUID } from "node:crypto";
27
27
  import lockfile from "proper-lockfile";
28
28
  import { StringEnum as StringEnum$1, clampThinkingLevel, getApiProvider } from "@bastani/atomic-ai/compat";
29
29
  import { createHash as createHash$1, randomUUID as randomUUID$1 } from "crypto";
@@ -36,8 +36,10 @@ import { Buffer as Buffer$1, constants as constants$3 } from "node:buffer";
36
36
  import { StringDecoder } from "node:string_decoder";
37
37
  import { isProxy } from "node:util/types";
38
38
  import { Type as Type$1 } from "@bastani/atomic-ai/utils/typebox/index";
39
+ import { storageSchemaCurrent } from "../core/storage/added-exports.js";
39
40
  import { dialectOf } from "../core/storage/dialect.js";
40
- import { applyStorageMigrations, withShortSchemaLockWaits } from "../core/storage/migrations.js";
41
+ import * as migrations from "../core/storage/migrations.js";
42
+ import { applyStorageMigrations, ensureStorageSchema, withShortSchemaLockWaits } from "../core/storage/migrations.js";
41
43
  import { schemaCatalogOf } from "../core/storage/schema-catalog.js";
42
44
  import { sequenceRunner } from "../core/storage/statement-sequence.js";
43
45
  import { TextDecoder as TextDecoder$1 } from "util";
@@ -276,7 +278,7 @@ ${chalk.bold("Commands:")}
276
278
  ${APP_NAME} auth <command> Log in or out, print credentials, or check provider readiness
277
279
  ${APP_NAME} mcp <command> Configure MCP servers, check connections, and sign in
278
280
  ${APP_NAME} storage <command> Show storage selections and connectivity, or join a shared database
279
- ${APP_NAME} team <command> Join or leave a team database (shared Intercom, private sessions)
281
+ ${APP_NAME} team <command> Show the storage layout in effect (individual, team, ci or custom)
280
282
  ${APP_NAME} intercom <command> Show or restart this machine's Intercom broker
281
283
  ${APP_NAME} blueprint cache-key Print cache keys and paths for a runner's cache action (actions/cache)
282
284
  ${APP_NAME} blueprint prebuild Prebuild a repository into an idle worktree for later resume
@@ -464,11 +466,6 @@ ${chalk.bold("Environment Variables:")}
464
466
  PI_* aliases are also supported for app-specific variables above.
465
467
  ATOMIC_STORAGE - Shared storage selection JSON for sessions and Intercom (overridden by --storage)
466
468
  ATOMIC_SESSIONS_STORAGE - Session-only storage selection JSON (cannot be combined with ${ENV_SESSION_DIR})
467
- ATOMIC_PROFILE - ci: use the team database for sessions and Intercom without settings
468
- ATOMIC_TEAM_URL - Team database URL for ATOMIC_PROFILE=ci
469
- ATOMIC_TEAM_TOKEN - Team database token for ATOMIC_PROFILE=ci (or ATOMIC_TEAM_TOKEN_FILE)
470
- ATOMIC_TEAM_TOKEN_FILE - File holding the team database token for ATOMIC_PROFILE=ci
471
- ATOMIC_TEAM_PREFIX - Team table prefix for ATOMIC_PROFILE=ci
472
469
 
473
470
  ${chalk.bold("Built-in Tool Names:")}
474
471
  ${formatBuiltinToolHelpLines()}
@@ -2858,247 +2855,55 @@ function formatResumeTimings(timings) {
2858
2855
  if (timings.firstPromptReadyMs !== null) lines.push(`ready after ${seconds(timings.firstPromptReadyMs)} s`);
2859
2856
  return lines;
2860
2857
  }
2861
- // dist/core/session-open-markers.js
2858
+ // dist/core/storage/session/fork-detach-map.js
2862
2859
  /**
2863
- * Which sessions are running (#4971): a process that runs a session keeps a marker for it, refreshed on a heartbeat and
2864
- * removed when the session closes or the process exits. A store that keeps markers (`SessionStore.openMarkers`, a table
2865
- * in a SQL store) holds them, so every host and agent directory sharing the store sees them; for any other store they
2866
- * are files under the agent directory, `open-sessions/<session id>/<token>.json`. Deleting a session that has a fresh
2867
- * marker, from another process or from another session of the same process, is refused. A marker of a process on
2868
- * this host counts while that process runs, however long it was suspended; one of another host counts while its
2869
- * heartbeat is fresh, judged on the clock that stamps the marker (#5058): the store's, or the shared file system's.
2860
+ * Segment arithmetic for detaching lazy forks (detach_ancestor): which rows a detach page copies, and when a sibling's
2861
+ * segments can be re-pointed at a detached child. See fork-segments.ts for what a segment is.
2870
2862
  */
2871
- /** How often a held marker's heartbeat is refreshed. */
2872
- const HEARTBEAT_MS = 15e3;
2873
- /** How old the heartbeat of another host's marker may be before the marker no longer counts. */
2874
- const STALE_MS = 4 * HEARTBEAT_MS;
2875
2863
  /**
2876
- * How long a marker of this host that does not say when its holder started counts while a process with its pid runs: a
2877
- * later process may have been given the pid (#5058).
2864
+ * The first `rows` rows of `segment`, which a detach page copies into the child, and what remains of the segment
2865
+ * after them; `rest` is undefined when the page takes the whole segment. Copying `page` and replacing `segment` with
2866
+ * `rest` in one transaction leaves the child's view unchanged: no seq is covered both by a segment and by a row of its own.
2878
2867
  */
2879
- const UNSTARTED_MARKER_LIMIT_MS = 864e5;
2880
- const PROCESS_NONCE = randomBytes(8).toString("hex");
2881
- let processToken;
2882
- /**
2883
- * This process's markers: its pid, a nonce that tells it from an earlier process given the same pid, and when it
2884
- * started, where that can be read, which tells it from a later one (#5058). Fixed once first used.
2885
- */
2886
- function ownToken() {
2887
- if (processToken === void 0) {
2888
- const started = ownProcessStartToken();
2889
- processToken = `${process.pid}-${PROCESS_NONCE}${started === void 0 ? "" : `-${started}`}`;
2890
- }
2891
- return processToken;
2892
- }
2893
- async function prepareSessionOpenMarkers() {
2894
- await readProcessStartToken(process.pid);
2895
- }
2896
- /** A marker token that names when its holder started. */
2897
- const STARTED_TOKEN = /^\d+-[0-9a-f]{16}-([0-9a-f]{12})$/;
2898
- /** The session ids a marker directory can be named after, as `assertValidSessionId` accepts them. */
2899
- const VALID_SESSION_ID = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
2900
- /** Marker files under an agent directory, for stores that keep no markers. */
2901
- var FileOpenMarkers = class {
2902
- agentDir;
2903
- pending = /* @__PURE__ */ new Map();
2904
- constructor(agentDir) {
2905
- this.agentDir = agentDir;
2906
- }
2907
- directory(sessionId) {
2908
- return join$1(this.agentDir, "open-sessions", sessionId);
2909
- }
2910
- inOrder(path, operation) {
2911
- const result = (this.pending.get(path) ?? Promise.resolve()).then(operation);
2912
- const settled = result.catch(() => {});
2913
- this.pending.set(path, settled);
2914
- settled.then(() => {
2915
- if (this.pending.get(path) === settled) this.pending.delete(path);
2916
- });
2917
- return result;
2918
- }
2919
- put(sessionId, marker) {
2920
- const path = join$1(this.directory(sessionId), `${marker.token}.json`);
2921
- return this.inOrder(path, async () => {
2922
- await mkdir(dirname$1(path), { recursive: true });
2923
- await writeFile(path, JSON.stringify({
2924
- pid: marker.pid,
2925
- host: marker.host
2926
- }));
2927
- });
2928
- }
2929
- remove(sessionId, token) {
2930
- const directory = this.directory(sessionId);
2931
- const path = join$1(directory, `${token}.json`);
2932
- return this.inOrder(path, async () => {
2933
- try {
2934
- await rm(path);
2935
- await rmdir(directory);
2936
- } catch {}
2937
- });
2938
- }
2939
- removeSync(sessionId, token) {
2940
- const directory = this.directory(sessionId);
2941
- try {
2942
- rmSync$1(join$1(directory, `${token}.json`));
2943
- rmdirSync$1(directory);
2944
- } catch {}
2945
- }
2946
- async list(sessionId) {
2947
- const directory = this.directory(sessionId);
2948
- await Promise.all([...this.pending].flatMap(([path, settled]) => dirname$1(path) === directory ? [settled] : []));
2949
- let names;
2950
- try {
2951
- names = await readdir(directory);
2952
- } catch {
2953
- return [];
2954
- }
2955
- if (names.length === 0) return [];
2956
- const now = await sharedClockNow(dirname$1(directory));
2957
- const markers = [];
2958
- for (const name of names) {
2959
- const path = join$1(directory, name);
2960
- try {
2961
- const parsed = JSON.parse(await readFile(path, "utf8"));
2962
- if (typeof parsed.pid !== "number" || typeof parsed.host !== "string") continue;
2963
- const token = name.replace(/\.json$/, "");
2964
- const ageMs = Math.max(0, now - (await stat(path)).mtimeMs);
2965
- markers.push({
2966
- token,
2967
- pid: parsed.pid,
2968
- host: parsed.host,
2969
- ageMs
2970
- });
2971
- } catch {}
2972
- }
2973
- return markers;
2974
- }
2975
- };
2976
- const fileMarkers = /* @__PURE__ */ new Map();
2977
- function fileMarkersIn(agentDir) {
2978
- let markers = fileMarkers.get(agentDir);
2979
- if (markers === void 0) {
2980
- markers = new FileOpenMarkers(agentDir);
2981
- fileMarkers.set(agentDir, markers);
2982
- }
2983
- return markers;
2984
- }
2985
- /** Where `store`'s sessions are marked open: in the store when it keeps markers, else under `agentDir`. */
2986
- function markersFor(store, agentDir) {
2987
- return store?.openMarkers ?? fileMarkersIn(agentDir);
2988
- }
2989
- /** Markers this process holds, by store and then session id. */
2990
- const held = /* @__PURE__ */ new Map();
2991
- let heldCount = 0;
2992
- let heartbeat;
2993
- function ownMarker() {
2994
- return {
2995
- token: ownToken(),
2996
- pid: process.pid,
2997
- host: hostname()
2868
+ function splitSegment(segment, rows) {
2869
+ if (rows >= segmentLength(segment)) return {
2870
+ page: segment,
2871
+ rest: void 0
2998
2872
  };
2999
- }
3000
- function refreshMarkers() {
3001
- for (const sessions of held.values()) for (const marker of sessions.values()) marker.markers.put(marker.sessionId, ownMarker()).catch(() => {});
3002
- }
3003
- process.on("exit", () => {
3004
- for (const sessions of held.values()) for (const marker of sessions.values()) if (marker.markers instanceof FileOpenMarkers) marker.markers.removeSync(marker.sessionId, ownToken());
3005
- });
3006
- /**
3007
- * Records that this process has `sessionId` of `store` open, until the returned function is called, once; holds by
3008
- * one process for one session share a marker. Never throws, and neither does the release: a marker that cannot be
3009
- * written leaves the session unprotected.
3010
- */
3011
- function holdSessionOpenMarker(sessionId, options = {}) {
3012
- if (!VALID_SESSION_ID.test(sessionId)) return async () => {};
3013
- const markers = markersFor(options.store, options.agentDir ?? getAgentDir());
3014
- let sessions = held.get(markers);
3015
- if (sessions === void 0) {
3016
- sessions = /* @__PURE__ */ new Map();
3017
- held.set(markers, sessions);
3018
- }
3019
- let marker = sessions.get(sessionId);
3020
- if (marker === void 0) {
3021
- marker = {
3022
- markers,
3023
- sessionId,
3024
- holds: 0,
3025
- releaseClaim: attachSessionClaim(sessionId)
3026
- };
3027
- sessions.set(sessionId, marker);
3028
- heldCount++;
3029
- markers.put(sessionId, ownMarker()).catch(() => {});
3030
- if (heartbeat === void 0) {
3031
- heartbeat = setInterval(refreshMarkers, HEARTBEAT_MS);
3032
- heartbeat.unref();
3033
- }
3034
- }
3035
- const holding = marker;
3036
- const owner = sessions;
3037
- holding.holds++;
3038
- let released = false;
3039
- return async () => {
3040
- if (released) return;
3041
- released = true;
3042
- if (--holding.holds > 0) return;
3043
- owner.delete(sessionId);
3044
- if (owner.size === 0) held.delete(markers);
3045
- const releasingClaim = holding.releaseClaim?.();
3046
- if (--heldCount === 0 && heartbeat !== void 0) {
3047
- clearInterval(heartbeat);
3048
- heartbeat = void 0;
3049
- }
3050
- await releasingClaim;
3051
- if (held.get(markers)?.has(sessionId)) return;
3052
- await markers.remove(sessionId, ownToken()).catch(() => {});
2873
+ const toSeq = segment.fromSeq + rows - 1;
2874
+ return {
2875
+ page: {
2876
+ ...segment,
2877
+ toSeq
2878
+ },
2879
+ rest: {
2880
+ sourceId: segment.sourceId,
2881
+ fromSeq: toSeq + 1,
2882
+ toSeq: segment.toSeq,
2883
+ baseSeq: segment.baseSeq + rows
2884
+ }
3053
2885
  };
3054
2886
  }
3055
- /** Whether `pid` is a live process on this host; one this process may not signal (EPERM) still exists. */
3056
- function processAlive(pid) {
3057
- try {
3058
- process.kill(pid, 0);
3059
- return true;
3060
- } catch (error) {
3061
- return error.code === "EPERM";
3062
- }
3063
- }
3064
- /**
3065
- * Whether the holder of `marker`, a marker of this host, still runs (#5058): a process with its pid that started when
3066
- * the marker says, or, for a marker that does not say, any process with its pid for a day after its last heartbeat. A
3067
- * marker whose start cannot be read right now is its holder's while a process with its pid runs (#5141).
3068
- */
3069
- async function holderRuns(marker) {
3070
- if (marker.pid === process.pid) {
3071
- await prepareSessionOpenMarkers();
3072
- return marker.token === ownToken();
3073
- }
3074
- const started = STARTED_TOKEN.exec(marker.token)?.[1];
3075
- const current = started === void 0 ? void 0 : await readProcessStartToken(marker.pid);
3076
- if (current !== void 0) return current === started;
3077
- return (started !== void 0 || marker.ageMs <= UNSTARTED_MARKER_LIMIT_MS) && processAlive(marker.pid);
3078
- }
3079
2887
  /**
3080
- * A running session, in another process or in this one, that has `sessionId` of `store` open, or undefined when none
3081
- * does. Stale markers are removed.
2888
+ * `sibling`'s segments re-pointed from `parentId` at the detached child `childId`, or undefined when the sibling must
2889
+ * keep reading the parent. `childOnParent` are the child's segments on the parent as they were before the detach. A
2890
+ * sibling is re-pointed only when each of its segments on the parent lies within one of those that maps the parent's
2891
+ * seq `j` to the child's own seq `j`, the prefix the child forked: the sibling then reads the same seqs of the child
2892
+ * that it read of the parent, and those rows of the child are copies of exactly those rows of the parent, so its view
2893
+ * does not change. A sibling that reads parent rows past the child's cut-off would read the child's own later rows
2894
+ * there instead, and one that reads rows a branch fork skipped would read other rows; both are left on the parent, to
2895
+ * be detached on their own.
3082
2896
  */
3083
- async function findSessionOpenHolder(sessionId, options = {}) {
3084
- if (!VALID_SESSION_ID.test(sessionId)) return void 0;
3085
- const markers = markersFor(options.store, options.agentDir ?? getAgentDir());
3086
- const host = hostname();
3087
- for (const marker of await markers.list(sessionId)) {
3088
- if (marker.host === host ? !await holderRuns(marker) : marker.ageMs > STALE_MS) {
3089
- await markers.remove(sessionId, marker.token).catch(() => {});
3090
- continue;
3091
- }
3092
- return {
3093
- pid: marker.pid,
3094
- host: marker.host
3095
- };
3096
- }
3097
- }
3098
- /** Rejects with a {@link SessionOpenElsewhereError} when a running session has `sessionId` of `store` open (#4971). */
3099
- async function assertSessionNotOpenElsewhere(sessionId, options = {}) {
3100
- const holder = await findSessionOpenHolder(sessionId, options);
3101
- if (holder !== void 0) throw new SessionOpenElsewhereError(sessionId, holder);
2897
+ function reparentedSegments(sibling, parentId, childId, childOnParent) {
2898
+ const prefix = childOnParent.filter((cover) => cover.baseSeq + 1 === cover.fromSeq);
2899
+ const onParent = sibling.filter((segment) => segment.sourceId === parentId);
2900
+ if (onParent.length === 0) return void 0;
2901
+ const held = (segment) => prefix.some((cover) => cover.fromSeq <= segment.fromSeq && segment.toSeq <= cover.toSeq);
2902
+ if (!onParent.every(held)) return void 0;
2903
+ return joinForkSegments(sibling.map((segment) => segment.sourceId === parentId ? {
2904
+ ...segment,
2905
+ sourceId: childId
2906
+ } : segment));
3102
2907
  }
3103
2908
  // dist/core/tasks/reopened-completion.js
3104
2909
  function readable(value, isProxy) {
@@ -4675,15 +4480,10 @@ const LOCAL_ONLY_STORAGE = /* @__PURE__ */ new Set([
4675
4480
  function isLocalOnlySessionStorage(adapter) {
4676
4481
  return LOCAL_ONLY_STORAGE.has(adapter);
4677
4482
  }
4678
- /** The command that joins this node to shared storage, named in hints when a lookup misses on local-only storage. */
4679
- const TEAM_JOIN_COMMAND = "atomic team join <url> --token-file <path>";
4680
4483
  /** The command that points this node's storage at a shared database, keeping the rest of its layout. */
4681
- const STORAGE_JOIN_COMMAND = "atomic storage join <url> --token-file <path>";
4682
- /**
4683
- * How a node puts its sessions in shared storage, named in hints when a session lookup misses on local-only storage.
4684
- * `atomic team join` keeps sessions on each machine, so a machine joined that way leaves the team first.
4685
- */
4686
- const SESSION_STORAGE_JOIN = `\`${STORAGE_JOIN_COMMAND}\` (after \`atomic team leave\` on a machine joined with \`atomic team join\`, which keeps sessions on each machine)`;
4484
+ const STORAGE_JOIN_COMMAND = "atomic storage join <postgres-url> --password-file <path>";
4485
+ /** How a node puts its sessions in shared storage, named in hints when a session lookup misses on local-only storage. */
4486
+ const SESSION_STORAGE_JOIN = `\`${STORAGE_JOIN_COMMAND}\``;
4687
4487
  /** How deep cause chains are serialized and walked. */
4688
4488
  const MAX_CAUSE_DEPTH$1 = 8;
4689
4489
  const AGENT_REHYDRATE_ERROR_NAME = "AgentRehydrateError";
@@ -8433,6 +8233,8 @@ async function execCommand(command, args, cwd, options, onQuit) {
8433
8233
  truncated: false
8434
8234
  };
8435
8235
  }
8236
+ const endsWithHost = onQuit !== void 0;
8237
+ const guardianEndsIt = endsWithHost && canWatchProcessUntilHostDies();
8436
8238
  const proc = spawnHostProcess(launch.file, argv, {
8437
8239
  cwd,
8438
8240
  env,
@@ -8441,9 +8243,11 @@ async function execCommand(command, args, cwd, options, onQuit) {
8441
8243
  "pipe",
8442
8244
  "pipe"
8443
8245
  ],
8444
- endWithParent: onQuit !== void 0,
8246
+ endWithParent: endsWithHost && !guardianEndsIt,
8445
8247
  ...missingHelperOptions(launch)
8446
8248
  });
8249
+ const hostDeathWatch = guardianEndsIt && proc.pid !== void 0 ? watchProcessUntilHostDies(proc.pid) : void 0;
8250
+ if (hostDeathWatch !== void 0) proc.once("exit", () => hostDeathWatch.release());
8447
8251
  if (onQuit !== void 0 && proc.pid !== void 0) quitStoppableCommands.add(proc);
8448
8252
  let stdout = "";
8449
8253
  let stderr = "";
@@ -8552,6 +8356,7 @@ async function execCommand(command, args, cwd, options, onQuit) {
8552
8356
  if (!killed && isChildProcessExitStatusUnknownError(error)) stderr = stderr ? `${stderr}\n${error.message}` : error.message;
8553
8357
  else if (!stderr) stderr = error.message;
8554
8358
  } finally {
8359
+ hostDeathWatch?.release();
8555
8360
  clearTimeout(timeoutId);
8556
8361
  options?.signal?.removeEventListener("abort", abort);
8557
8362
  stopOnQuit?.();
@@ -9750,9 +9555,24 @@ async function create(path, header) {
9750
9555
  throw e;
9751
9556
  }
9752
9557
  }
9753
- /** Device, a known inode, a recorded creation time and the header: an unknown inode or creation time proves no owner. */
9558
+ /**
9559
+ * Device, a known inode, a recorded creation time and the header: an unknown inode or creation time proves no owner.
9560
+ * Where creation times move (APFS and HFS+, which never reuse an inode number) the epoch has none; see
9561
+ * `creation-time.ts`.
9562
+ */
9754
9563
  function hasStableFileOwner(epoch) {
9755
- return /^\d+:[1-9]\d*:[1-9]\d*:[\da-f]{16}$/.test(epoch);
9564
+ return /^\d+:[1-9]\d*:(?:[1-9]\d*:)?[\da-f]{16}$/.test(epoch);
9565
+ }
9566
+ /**
9567
+ * The epoch an older build gave the owner's file on macOS, with its creation time in it, which the diagnostics it
9568
+ * saved are kept under: only while the file is still the one `owner.epoch` names, and has a creation time.
9569
+ */
9570
+ async function olderEpoch(owner) {
9571
+ const current = /^(\d+:[1-9]\d*):([\da-f]{16})$/.exec(owner.epoch);
9572
+ if (!current || !owner.file) return void 0;
9573
+ const stats = await stat(owner.file, { bigint: true }).catch(() => void 0);
9574
+ if (!stats || stats.birthtimeNs <= 0n || `${stats.dev}:${stats.ino}` !== current[1]) return void 0;
9575
+ return `${current[1]}:${stats.birthtimeNs}:${current[2]}`;
9756
9576
  }
9757
9577
  async function discoverChatFile(file, id) {
9758
9578
  const { path } = files({
@@ -9809,8 +9629,13 @@ async function readSlot(owner, slot) {
9809
9629
  }
9810
9630
  async function readFileChatRecords(owner, anchors) {
9811
9631
  if (!hasStableFileOwner(owner.epoch)) return [];
9632
+ const older = await olderEpoch(owner);
9633
+ const owners = older === void 0 ? [owner] : [{
9634
+ ...owner,
9635
+ epoch: older
9636
+ }, owner];
9812
9637
  const result = [];
9813
- for (const anchor of anchors) for (const line of await readSlot(owner, slotFor(owner, anchor))) {
9638
+ for (const anchor of anchors) for (const each of owners) for (const line of await readSlot(each, slotFor(each, anchor))) {
9814
9639
  const record = decodeChatRecord(line);
9815
9640
  if (record) result.push({
9816
9641
  anchor,
@@ -9821,7 +9646,16 @@ async function readFileChatRecords(owner, anchors) {
9821
9646
  }
9822
9647
  async function readFileChatOrders(owner, promptIds) {
9823
9648
  if (!promptIds.length || !owner.file || !hasStableFileOwner(owner.epoch)) return [];
9824
- const orders = (await readSlot(owner, orderSlot(owner))).flatMap((line) => decodeChatOrder(line) ?? []);
9649
+ const older = await olderEpoch(owner);
9650
+ const owners = older === void 0 ? [owner] : [{
9651
+ ...owner,
9652
+ epoch: older
9653
+ }, owner];
9654
+ const orders = [];
9655
+ for (const each of owners) for (const line of await readSlot(each, orderSlot(each))) {
9656
+ const order = decodeChatOrder(line);
9657
+ if (order) orders.push(order);
9658
+ }
9825
9659
  return firstChatOrders(orders, promptIds);
9826
9660
  }
9827
9661
  async function deleteFileChatRecords(owner) {
@@ -12529,6 +12363,11 @@ var HistorySearchPositions = class {
12529
12363
  }
12530
12364
  };
12531
12365
  // dist/core/storage/session/session-search-index.js
12366
+ /**
12367
+ * `ensureStorageSchemaOnce` of `migrations.ts`, which the copies earlier releases loaded lack: taken from the module
12368
+ * namespace, so this module links against them too. Without it the tuning runs in a transaction of its own, as before.
12369
+ */
12370
+ const setupOnce = migrations;
12532
12371
  const SESSION_SEARCH_DOMAIN = "session-search";
12533
12372
  const SESSION_SEARCH_TABLES = Object.freeze({
12534
12373
  state: "search_state",
@@ -12537,6 +12376,19 @@ const SESSION_SEARCH_TABLES = Object.freeze({
12537
12376
  trigrams: "search_trgm",
12538
12377
  entriesForget: "entries_search_forget"
12539
12378
  });
12379
+ /**
12380
+ * The ledger step, `schema:session-search-tuning`, that gives an existing PostgreSQL trigram index the pending-list
12381
+ * limit below and its entries table the autovacuum settings below.
12382
+ */
12383
+ const SESSION_SEARCH_TUNING_DOMAIN = "session-search-tuning";
12384
+ const SESSION_SEARCH_TUNING_REVISION = 1;
12385
+ /**
12386
+ * The PostgreSQL trigram index's `gin_pending_list_limit`, in kB: 64 MB rather than the server's default 4 MB. An insert
12387
+ * that finds the pending list over this limit merges the whole list into the index itself, inside its transaction and
12388
+ * the session's lock; the background merge (`SEARCH_PENDING_MERGE_CHARS`) and autovacuum keep the list far below it.
12389
+ */
12390
+ const SEARCH_PENDING_LIST_LIMIT_KB = 65536;
12391
+ const SEARCH_ENTRIES_AUTOVACUUM = `autovacuum_vacuum_insert_threshold = 1000, autovacuum_vacuum_insert_scale_factor = 0`;
12540
12392
  const SEARCH_PART_CHARS = 4096;
12541
12393
  const MAX_INDEXED_ENTRY_CHARS = 8388608;
12542
12394
  const PART_BITS = 14;
@@ -12789,12 +12641,18 @@ const sqliteFts = {
12789
12641
  return seqs;
12790
12642
  }
12791
12643
  };
12644
+ /**
12645
+ * The search indexes this process found it does not own, by database (`databaseIdentity`, which names the role and
12646
+ * schema too), ledger and index: their tuning is left to `atomic storage migrate`, so later opens do not read the
12647
+ * catalog for it again.
12648
+ */
12649
+ const unownedSearchIndexes = /* @__PURE__ */ new Set();
12792
12650
  async function createTrigramIndex(tx, dialect, tables) {
12793
12651
  await tx.exec("SAVEPOINT atomic_session_search_trgm");
12794
12652
  try {
12795
12653
  await tx.exec("CREATE EXTENSION IF NOT EXISTS pg_trgm");
12796
12654
  const found = await tx.get("SELECT n.nspname AS schema FROM pg_catalog.pg_extension e JOIN pg_catalog.pg_namespace n ON n.oid = e.extnamespace WHERE e.extname = 'pg_trgm'");
12797
- await tx.exec(`CREATE INDEX IF NOT EXISTS ${tables.trigrams} ON ${tables.entries} USING gin (body ${dialect.identifier(String(found?.schema))}.gin_trgm_ops)`);
12655
+ await tx.exec(`CREATE INDEX IF NOT EXISTS ${tables.trigrams} ON ${tables.entries} USING gin (body ${dialect.identifier(String(found?.schema))}.gin_trgm_ops) WITH (gin_pending_list_limit = ${SEARCH_PENDING_LIST_LIMIT_KB})`);
12798
12656
  await tx.exec("RELEASE SAVEPOINT atomic_session_search_trgm");
12799
12657
  } catch {
12800
12658
  await tx.exec("ROLLBACK TO SAVEPOINT atomic_session_search_trgm");
@@ -12807,7 +12665,7 @@ async function trigramIndexExists(database, dialect, tables) {
12807
12665
  const postgresTrigrams = {
12808
12666
  async create(tx, dialect, tables, sessionTables) {
12809
12667
  const { int, text } = dialect.types;
12810
- await tx.exec(`CREATE TABLE IF NOT EXISTS ${tables.entries} (sid ${int} NOT NULL, seq ${int} NOT NULL, part ${int} NOT NULL, body ${text} NOT NULL, PRIMARY KEY (sid, seq, part))`);
12668
+ await tx.exec(`CREATE TABLE IF NOT EXISTS ${tables.entries} (sid ${int} NOT NULL, seq ${int} NOT NULL, part ${int} NOT NULL, body ${text} NOT NULL, PRIMARY KEY (sid, seq, part)) WITH (${SEARCH_ENTRIES_AUTOVACUUM})`);
12811
12669
  await tx.exec(dialect.renderTrigger(forgetTrigger(tables, sessionTables, postgresTrigrams)));
12812
12670
  await createTrigramIndex(tx, dialect, tables);
12813
12671
  },
@@ -12831,6 +12689,60 @@ const postgresTrigrams = {
12831
12689
  async merge() {
12832
12690
  return false;
12833
12691
  },
12692
+ async tune(database, dialect, tables, ledger) {
12693
+ if (database.readOnly === true) return;
12694
+ const schema = {
12695
+ ledger,
12696
+ domain: SESSION_SEARCH_TUNING_DOMAIN,
12697
+ revision: SESSION_SEARCH_TUNING_REVISION
12698
+ };
12699
+ if (await storageSchemaCurrent(database, schema)) return;
12700
+ const identity = database.databaseIdentity?.();
12701
+ const key = identity === void 0 ? void 0 : JSON.stringify([
12702
+ identity,
12703
+ ledger,
12704
+ tables.trigrams
12705
+ ]);
12706
+ if (key !== void 0 && unownedSearchIndexes.has(key)) return;
12707
+ const found = await database.get(`SELECT pg_catalog.pg_has_role(current_user, i.relowner, 'USAGE')
12708
+ AND pg_catalog.pg_has_role(current_user, t.relowner, 'USAGE') AS owned
12709
+ FROM pg_catalog.pg_class i
12710
+ JOIN pg_catalog.pg_index x ON x.indexrelid = i.oid
12711
+ JOIN pg_catalog.pg_class t ON t.oid = x.indrelid
12712
+ WHERE i.relnamespace = current_schema()::regnamespace AND i.relname = ?`, dialect.identifier(tables.trigrams));
12713
+ if (found === void 0) return;
12714
+ if (found.owned !== true && Number(found.owned) !== 1) {
12715
+ if (key !== void 0) unownedSearchIndexes.add(key);
12716
+ return;
12717
+ }
12718
+ const setup = async (tx) => {
12719
+ await tx.exec(`ALTER INDEX ${tables.trigrams} SET (gin_pending_list_limit = ${SEARCH_PENDING_LIST_LIMIT_KB})`);
12720
+ await tx.exec(`ALTER TABLE ${tables.entries} SET (${SEARCH_ENTRIES_AUTOVACUUM})`);
12721
+ };
12722
+ const once = setupOnce.ensureStorageSchemaOnce;
12723
+ if (once !== void 0) await once(database, schema, setup);
12724
+ else await database.transaction((tx) => ensureStorageSchema(tx, dialect, schema, () => setup(tx)), {
12725
+ retryTransientFailures: true,
12726
+ concurrency: {
12727
+ kind: "serial",
12728
+ domain: ledger
12729
+ }
12730
+ });
12731
+ },
12732
+ async mergePending(database, dialect, tables) {
12733
+ const owned = (await database.autocommit?.({
12734
+ sql: `SELECT CASE WHEN pg_catalog.pg_has_role(current_user, c.relowner, 'USAGE')
12735
+ AND pg_catalog.pg_try_advisory_xact_lock(pg_catalog.hashtextextended(current_schema() || '.' || c.relname || ':pending', 0))
12736
+ THEN pg_catalog.gin_clean_pending_list(c.oid) END AS pages,
12737
+ pg_catalog.pg_has_role(current_user, c.relowner, 'USAGE') AS owned
12738
+ FROM pg_catalog.pg_class c WHERE c.relnamespace = current_schema()::regnamespace AND c.relname = ?`,
12739
+ params: [dialect.identifier(tables.trigrams)]
12740
+ }, {
12741
+ kind: "serial",
12742
+ domain: `${tables.trigrams}:pending`
12743
+ }) ?? [])[0]?.owned;
12744
+ return owned === true || Number(owned) === 1;
12745
+ },
12834
12746
  async insert(tx, tables, sid, docs, signal) {
12835
12747
  for (let start = 0; start < docs.length; start += INSERT_ROWS_PER_STATEMENT) {
12836
12748
  signal?.throwIfAborted();
@@ -12905,6 +12817,12 @@ var SqlSessionSearchIndex = class SqlSessionSearchIndex {
12905
12817
  tables;
12906
12818
  engine;
12907
12819
  writesPrepared = false;
12820
+ /** Characters of search text written since the last background merge of the pending list began. */
12821
+ pendingChars = 0;
12822
+ /** The background merge of the pending list in flight, if any. */
12823
+ merging;
12824
+ /** False once a merge found that this role may not merge the pending list, which autovacuum then merges. */
12825
+ mayMerge = true;
12908
12826
  constructor(database, sessionTables, tables) {
12909
12827
  this.database = database;
12910
12828
  this.dialect = dialectOf(database);
@@ -12915,20 +12833,25 @@ var SqlSessionSearchIndex = class SqlSessionSearchIndex {
12915
12833
  static async open(database, sessionTables, prefix) {
12916
12834
  const tables = renderStorageIdentifiers("sessions", SESSION_SEARCH_TABLES, prefix);
12917
12835
  const engine = engineFor(dialectOf(database));
12836
+ const ledger = storageMigrationTable(prefix);
12837
+ let created = false;
12918
12838
  try {
12919
12839
  if (await SqlSessionSearchIndex.tablesExist(database, tables)) return new SqlSessionSearchIndex(database, sessionTables, tables);
12920
12840
  await applyStorageMigrations(database, SESSION_SEARCH_DOMAIN, [{
12921
12841
  version: 1,
12922
12842
  up: async (tx, dialect) => {
12923
12843
  const { int, text, rowKey } = dialect.types;
12924
- await tx.exec(`CREATE TABLE IF NOT EXISTS ${tables.state} (sid ${rowKey}, session_id ${text} NOT NULL UNIQUE, format ${int} NOT NULL, indexed_seq ${int} NOT NULL, revision ${text} NOT NULL, entry_id ${text} NOT NULL)${dialect.tableOptions}`);
12844
+ const tuned = engine.tune === void 0 ? "" : `; INSERT INTO ${ledger} (domain, version, applied_at) VALUES ('schema:${SESSION_SEARCH_TUNING_DOMAIN}', ${SESSION_SEARCH_TUNING_REVISION}, ${dialect.nowMs}) ON CONFLICT DO NOTHING`;
12845
+ await tx.exec(`CREATE TABLE IF NOT EXISTS ${tables.state} (sid ${rowKey}, session_id ${text} NOT NULL UNIQUE, format ${int} NOT NULL, indexed_seq ${int} NOT NULL, revision ${text} NOT NULL, entry_id ${text} NOT NULL)${dialect.tableOptions}${tuned}`);
12925
12846
  await engine.create(tx, dialect, tables, sessionTables);
12847
+ created = true;
12926
12848
  }
12927
12849
  }], {
12928
- table: storageMigrationTable(prefix),
12850
+ table: ledger,
12929
12851
  acceptNewer: true
12930
12852
  });
12931
12853
  if (!await engine.ready(database, dialectOf(database), tables)) return void 0;
12854
+ if (!created) await engine.tune?.(database, dialectOf(database), tables, ledger).catch(() => void 0);
12932
12855
  } catch {
12933
12856
  return;
12934
12857
  }
@@ -12972,7 +12895,7 @@ var SqlSessionSearchIndex = class SqlSessionSearchIndex {
12972
12895
  indexedSeq,
12973
12896
  lastSeq
12974
12897
  }, generation, row.session_revision);
12975
- await this.database.transaction((tx) => this.forget(tx, sessionId), this.sessionWrite(sessionId));
12898
+ await this.database.transaction((tx) => this.forget(tx, sessionId), this.searchWrite(sessionId));
12976
12899
  return withCoverageMeta({
12977
12900
  indexedSeq: 0,
12978
12901
  lastSeq
@@ -12981,9 +12904,10 @@ var SqlSessionSearchIndex = class SqlSessionSearchIndex {
12981
12904
  async extend(sessionId, format, afterSeq, throughSeq, texts, options) {
12982
12905
  if (throughSeq >= SEQ_SPACE || throughSeq < afterSeq) return false;
12983
12906
  options?.signal?.throwIfAborted();
12984
- const txOptions = this.sessionWrite(sessionId);
12907
+ const txOptions = this.searchWrite(sessionId);
12985
12908
  const { docs, oversizedSeqs } = prepareDocs(texts);
12986
- if (docs.reduce((sum, doc) => sum + doc.text.length, 0) <= BATCH_CHARS) {
12909
+ const totalChars = docs.reduce((sum, doc) => sum + doc.text.length, 0);
12910
+ if (totalChars <= BATCH_CHARS) {
12987
12911
  let backlog = false;
12988
12912
  const extended = await this.writeTransaction(sessionId, async (tx) => {
12989
12913
  options?.signal?.throwIfAborted();
@@ -13017,6 +12941,7 @@ var SqlSessionSearchIndex = class SqlSessionSearchIndex {
13017
12941
  const nextWhole = mergeWholeSeqs(row.whole_seqs, oversizedSeqs);
13018
12942
  return (await tx.run(`UPDATE ${this.tables.state} SET indexed_seq = ?, entry_id = ? WHERE sid = ? AND session_id = ? AND format = ? AND indexed_seq = ? AND revision = ?`, throughSeq, nextWhole, sid, sessionId, format, afterSeq, activeGen)).changes === 1;
13019
12943
  });
12944
+ this.notePendingChars(totalChars);
13020
12945
  if (extended && backlog) await this.mergeBacklog(options?.signal);
13021
12946
  return extended;
13022
12947
  }
@@ -13068,6 +12993,7 @@ var SqlSessionSearchIndex = class SqlSessionSearchIndex {
13068
12993
  }
13069
12994
  return true;
13070
12995
  }, txOptions)) return false;
12996
+ this.notePendingChars(batch.reduce((sum, doc) => sum + doc.text.length, 0));
13071
12997
  if (backlog) await this.mergeBacklog(options?.signal);
13072
12998
  start = end;
13073
12999
  await yieldTurn();
@@ -13081,6 +13007,22 @@ var SqlSessionSearchIndex = class SqlSessionSearchIndex {
13081
13007
  return (await tx.run(`UPDATE ${this.tables.state} SET indexed_seq = ?, entry_id = ? WHERE sid = ? AND session_id = ? AND format = ? AND indexed_seq = ? AND revision = ?`, throughSeq, nextWhole, sid, sessionId, format, afterSeq, activeGen)).changes === 1;
13082
13008
  }, txOptions);
13083
13009
  }
13010
+ /**
13011
+ * Counts `chars` of search text a committed write added, and once `SEARCH_PENDING_MERGE_CHARS` of them have, starts a
13012
+ * background merge of the pending list, which this write and the writes after it do not wait for. So no write merges
13013
+ * the list inside its transaction, which holds the session's lock (PostgreSQL only).
13014
+ */
13015
+ notePendingChars(chars) {
13016
+ if (this.engine.mergePending === void 0 || !this.mayMerge || this.database.readOnly === true) return;
13017
+ this.pendingChars += chars;
13018
+ if (this.pendingChars < 131072 || this.merging !== void 0) return;
13019
+ this.pendingChars = 0;
13020
+ this.merging = this.engine.mergePending(this.database, this.dialect, this.tables).then((merged) => {
13021
+ if (!merged) this.mayMerge = false;
13022
+ }, () => void 0).finally(() => {
13023
+ this.merging = void 0;
13024
+ });
13025
+ }
13084
13026
  async mergeBacklog(signal) {
13085
13027
  for (let write = 0; write < MAX_MERGE_BACKLOG_WRITES; write++) {
13086
13028
  await yieldTurn();
@@ -13088,11 +13030,34 @@ var SqlSessionSearchIndex = class SqlSessionSearchIndex {
13088
13030
  }
13089
13031
  }
13090
13032
  /**
13091
- * A write of the session `sessionId`'s index rows: the session's own domain, which the session store's writers take,
13092
- * since `replace` and `delete` forget a session's index in their own transactions.
13033
+ * A write of the session `sessionId`'s index rows, in the domain of that session's index rather than the session's
13034
+ * own: saves to the session, which take the session's domain, run beside it. A rewrite of the session, which forgets
13035
+ * its index, takes this domain too ({@link writeLock}), so an index write commits wholly before the rewrite reads
13036
+ * the index or starts after it commits, and its checks then see the rewrite. `delete` holds the whole database.
13093
13037
  */
13094
- sessionWrite(sessionId) {
13095
- return sessionWriteTransaction(this.sessionTables.sessions, sessionId);
13038
+ searchWrite(sessionId) {
13039
+ return {
13040
+ retryTransientFailures: true,
13041
+ concurrency: {
13042
+ kind: "serial",
13043
+ domain: this.searchDomain(sessionId)
13044
+ }
13045
+ };
13046
+ }
13047
+ searchDomain(sessionId) {
13048
+ return `${this.tables.state}:${sessionId}`;
13049
+ }
13050
+ /**
13051
+ * On PostgreSQL, the statement that takes, inside a transaction of the session's own domain, the advisory lock index
13052
+ * writes of the session `sessionId` hold ({@link searchWrite}), keyed as the driver keys a domain's lock. A rewrite
13053
+ * runs it before it touches the index. Undefined where transactions do not run beside each other.
13054
+ */
13055
+ writeLock(sessionId) {
13056
+ if (this.dialect.name !== "postgres") return void 0;
13057
+ return {
13058
+ sql: "SELECT pg_catalog.pg_advisory_xact_lock(pg_catalog.hashtextextended(CASE WHEN current_schema() = 'public' THEN '' ELSE current_schema() || ':' END || ?, 0)) IS NULL AS locked",
13059
+ params: [this.searchDomain(sessionId)]
13060
+ };
13096
13061
  }
13097
13062
  async writeTransaction(sessionId, body) {
13098
13063
  let prepared = this.writesPrepared;
@@ -13102,7 +13067,7 @@ var SqlSessionSearchIndex = class SqlSessionSearchIndex {
13102
13067
  prepared = true;
13103
13068
  }
13104
13069
  return body(tx);
13105
- }, this.sessionWrite(sessionId));
13070
+ }, this.searchWrite(sessionId));
13106
13071
  if (prepared) this.writesPrepared = true;
13107
13072
  return result;
13108
13073
  }
@@ -16884,10 +16849,6 @@ const SettingsSchema = Type$1.Object({
16884
16849
  $schema: Type$1.Optional(Type$1.String({ description: "JSON Schema reference." })),
16885
16850
  storage: Type$1.Optional(StorageSelectionSchema),
16886
16851
  sessions: Type$1.Optional(Type$1.Object({ storage: Type$1.Optional(SessionStorageSelectionSchema) })),
16887
- teamJoin: Type$1.Optional(Type$1.Object({ storage: Type$1.String({
16888
- pattern: "^sha256:[0-9a-f]{64}$",
16889
- description: "Fingerprint of the `storage` selection that `atomic team join` wrote."
16890
- }) }, { description: "Managed team join record; leave unchanged." })),
16891
16852
  lastChangelogVersion: Type$1.Optional(Type$1.String()),
16892
16853
  firstRunOnboardingStartedVersion: Type$1.Optional(Type$1.String({ description: "Managed onboarding state; leave unchanged." })),
16893
16854
  onboardedVersion: Type$1.Optional(Type$1.String({ description: "Managed onboarding completion state; leave unchanged." })),
@@ -19494,16 +19455,16 @@ var ChildCatalog = class ChildCatalog {
19494
19455
  function sessionScratchDir(agentDir, cwd, _sessionId) {
19495
19456
  return getDefaultSessionDirPath(cwd, agentDir);
19496
19457
  }
19497
- export { AgentRehydrateError, AgentReleaseConfigError, CacheWarmer, ChildCatalog, CommandDeliveries, DEFAULT_MAX_MESSAGE_BYTES, DEFAULT_SUBSCRIPTION_MAX_CONCURRENT, EMPTY_OUTPUT_TEXT, EngineHealthController, ExtensionInputComponent, ExtensionSelectorComponent, FirstTimeSetupComponent, GIT_RELEASE, HistorySearchPositions, IMAGE_RESIZE_WORKER_RESPONSE_TYPE, LEGACY_AZURE_PROVIDER, LlamaClient, MAX_INDEXED_ENTRY_CHARS, MULTI_SUBMIT_LABEL, MarkdownContentCache, McpClient, MultiSelectView, NestedGitignore, NestedToolCallRunner, NoUsableModelError, QuestionParamsSchema, RESERVED_LABELS, RESUME_TIMINGS_TYPE, RemoteModelCatalog, RemoteQueuePause, ReopenedCompletionHeaders, ResumeTimingsRecorder, SEARCH_PART_CHARS, SESSIONS_TRANSFER_DIRECTORY, SESSION_STORAGE_JOIN, STORAGE_JOIN_COMMAND, SUMMARY_COMPACTION_PREFIX, SessionKeyDigests, SessionStorageSelectionSchema, SettingsSchema, SqlSessionSearchIndex, StorageImportIncompleteError, StorageSelectionSchema, StorageTransferError, StringEnum, TEAM_JOIN_COMMAND, TOOL_OUTPUT_ENTRY_TYPE, TRANSPILE_CACHE_WRITE_WAIT_MS, TaskElapsedClocks, TaskToolError, ToolExecutionScheduler, TransportEvents, UNORDERED_ADMISSION, VERBATIM_COMPACTION_PREFIX, VERIFICATION_PENDING_REASON, WorkspaceBindingError, WorkspaceCollectionError, WorkspaceConfigError, WorkspaceDriftError, WorkspaceError, WorkspaceGitError, WorkspacePublicationError, WorkspaceRestoreError, WorkspaceSandboxError, WorkspaceSnapshotError, WorkspaceTimeoutError, WrappingSelect, acceptsForkReplay, addResource, adoptCommandSession, appendFileChatRecord, assertSessionBlobStore, assertSessionNotOpenElsewhere, assertSettingsWrites, attachCleanupCause, bindRegistrationCallbacks, bindTaskClock, bindTaskClockSource, bodyWidths, buildDirectoryTree, buildDirectoryTreeFromOperations, buildToolStatusReport, cancelInitialBinding, cancelPausedOwnerTasks, cancelReceiptSentence, cancelReceiptStatus, captureForkReplayPair, captureRegistrationInvocation, carriedTransformedPrompt, carryCompletionEvidence, chatAnswerIntent, chatNumberingFor, childPresentationInput, claimInteractiveBind, classifyCompactionModel, cleanupFailureSummary, collectAgentTasks, collectCommandDeliveries, collectExtensionPackageWarnings, collectFlags, collectMarkdownTransformers, collectPackageInstallWarnings, collectRegisteredTools, collectSettingsDiagnostics, columnWidths, compareCreated, compareFrozen, computeFocusedOptionHasPreview, conflictEntries, convertImageBytesToPng, convertToLlm, convertToLlmWithForkBoundaries, convertToPng, copyRegistrations, copySessionBlobs, createAccumulator, createBranchSummaryMessage, createCustomMessage, createInvocationBindings, createLazyBuiltinFactory, createManagedTaskClocks, createProviderAlias, createSessionHistoryToolDefinition, createSkillRouter, createVerbatimCompactionMessage, crossTabLeftWidthWithDonation, currentResourceAdmission, decideLayout, deferCommandTurn, deferMessagesInterleavedWithToolBatch, deferRestorePhase, deleteFileChatRecords, describeToolSelection, detectLinuxLibc, diffLines, diffWords, discoverChatFile, drainProcessStdio, drainWindowsDirectorySecurityReads, dropDeferredCommandTurn, ensurePngTranscoder, ensureTool, errorMessage$1 as errorMessage, execCommand, extensionRefreshRejection, extensionSource, filterSupersededHerdrIntegrationPaths, findEntryRenderer, findMessageRenderer, findSessionOpenHolder, findToolDefinition, findWorkspaceError, fixUtf8Stream, flush, forkReplayFilter, forkToolDeclarations, formatAnswerScalar, formatBytes, formatNoUsableModelMessage, formatPackageInstallWarning, formatResumeTimings, formatTokenSegment, formatToolStatus, genBridge, getBuiltinExtensionEntryLabel, getClientIdentity, getCommandEnv, getGitDistributionTarget, getGitInstallDir, getGitReleaseMarker, getGitShellEnvironment, getGitShellEnvironmentAsync, getGitStatus, getGitStatusAsync, getLatestVersion, getLazyBuiltinSpec, getLoaderAgentDirs, getPromptCacheTtlMs, getStorageAdapterHostModules, getToolEnv, getToolPath, getVirtualModules, gitInstallCommand, gitignoreMatcher, hasExtensionHandlers, hasFileChatRecords, hasLazyBuiltinSpec, hasQuitStoppableCommands, hasRecordedTransformedPrompt, hasTaskPromptHost, hasTransformedPrompt, heldPromptInput, heldPrompts, holdSessionOpenMarker, initialBindScope, inlineToolOutput, insertForcedOptionsBeforeTerminator, invocationExtension, invocationRuntime, isAgentRehydrateError, isAgentReleaseConfigError, isBashToolResult, isContentFilterRefusal, isEditToolResult, isFindToolResult, isForkHeader, isHeldPromptInput, isInsideInputHook, isJsonValue, isLocalOnlySessionStorage, isLsToolResult, isNativeBuiltinExtensionPath, isOfflineModeEnabled, isPowerShellToolResult, isPresentationHostInput, isProviderCredentialRejection, isReadToolResult, isRetryableAgentRehydrateError, isRetryableModelFailure, isRetryableSameModelFailure, isRetryableWorkspaceError, isSafetyRefusalFailure, isSourceBuiltinExtensionPath, isStorageImportIncompleteError, isStorageTransferError, isTaskToolError, isToolCallEventType, isTruthyEnvFlag, isUnrecognizedModelFailure, isVerbatimCompactionMessage, isWorkspaceBindingError, isWorkspaceCollectionError, isWorkspaceConfigError, isWorkspaceDriftError, isWorkspaceError, isWorkspaceGitError, isWorkspacePublicationError, isWorkspaceRestoreError, isWorkspaceSandboxError, isWorkspaceSnapshotError, isWorkspaceTimeoutError, isWriteToolResult, joinCommandSend, joinCommandTurn, killQuitStoppableCommandsNow, latestLegacyMessageTime, latestResumeTimings, legacyCompletionTarget, lifecycleScopeForOwner, llamaInferenceUrl, loadVirtualModules, loaderHostModulesTestHooks, mergeExtensionWarnings, mergeResourcePaths, messageIsLlmVisible, messageStartsLlmUserTurn, migrateCompactionModelSettings, modelFailureMessage, next, nextTransformedPromptRecord, normalizeAzureSettings, normalizeLlamaServerUrl, normalizeMessageContent, normalizeModelFailureSignal, normalizeModelProvider, normalizeModelReference, normalizeProviderKeys, noteCommandAnswer, noteCommandTurnMessage, noteRestoreFetch, openEventSubscription, originalRegistrationCallback, ownedSettingsManagers, parseArgs, parseConflictBytes, parseEngineExplicitQuitCommand, parseGitVersion, parseInteractiveEngineCommand, parseInteractiveEngineMessage, parseSkillUri, partitionByCredentials, plainStatMtimeMs, powershellCandidates, prepareRegistrationCallbacks, prepareSessionOpenMarkers, presentTaskError, presentationHostInput, prewarmModelApi, printHelp, projectTransformedPrompt, providerOfModelReference, publishEvent, readConflictUrl, readFileChatOrders, readFileChatRecords, readHostInputFormRequest, readInlineCaret, readInlineDraft, readLocalFileChunks, readPipedStdin, readTransferDirectory, reconcileRegistration, recordBlueprintStep, recordClosedStart, recordResumeTimings, recordSettingsWrite, refreshConflictFile, registerConflictBlocks, registerFactoryStartupHandler, registerInitialBindings, registerLazyBuiltin, registrationFields, rehydrateAgentRehydrateError, rehydrateTaskToolError, rehydrateWorkspaceError, rejectMalformedToolArguments, rememberEarlierCompletion, renderTodoCall, renderTodoResult, reopenedCompletionName, repairOrphanToolResults, reportDiagnostics, requestedThinkingLevelForModelSwitch, requireTimerMs, require_from_url, require_int, require_int$1, require_log, require_re, require_timestamp, require_toJS, require_trim_comparator_whitespace, require_util_flow_indent_check, require_util_map_includes, require_visit, reserveQueuedInputAdmission, resetGitProvisionStateForTest, resizeImageInProcess, resolveCompactionModel, resolveGit, resolveGitSync, resolveInlineDraftValue, resolveInstalledGit, resolveInvocationRuntime, resolveRegisteredCommands, resolveResourcePath, resolveToolConcurrency, resolvesCompletionHeader, routeKey, routeNamesPrompt, runCallback, runCommandHandler, runInputHook, runSynchronousCallback, runWithProgress, scheduleToolExecution, selectActivePreviewPaneIndex, selectActiveTabItems, selectConfirmedIndicator, selectReadLinesFromChunks, selectReadLinesFromList, serializeAgentRehydrateError, serializeInteractiveEngineFrame, serializeInteractiveEngineMessage, serializeTodoForAgent, serializeTodoListForAgent, serializeWorkspaceError, sessionBlobHashes, sessionBlobOutput, sessionLifecycleCreation, sessionLifecycleScopes, sessionPosition, sessionScratchDir, setCallbackActivityReporter, settingsWriteOwner, shareCompletionEvidence, showLlamaUi, shownSpanMs, skillUri, splitSearchTextParts, startedAsFork, startupRegistrationTokens, startupSourceId, stopIndex, storeInlineToolOutputs, storeSessionBlobs, streamCutDurationMs, stripVerbatimCompactionPrefix, subagentsLazyBuiltinSpec, summarizeLegacySession, takeInlineToolOutput, takeInlineToolOutputEntry, taskClockOf, taskClockRunning, taskClocksFor, taskElapsedMs, taskPromptHost, thinkingLevelForModelSwitch, timeCheckoutRestore, timeRestorePhase, toResolvedPaths, tokenize, toolChangeSupport, toolOutputUrl, toolOutputUrlHash, trackAdmittedAgentTask, trackTranspileCacheWrite, trackWindowsDirectorySecurityWork, transferFile, transformedPromptOwner, transpileCacheWritesSettled, unpackIds, unreadablePathError, unreadableTrustSettingsDiagnostics, unwritablePathError, userLikeContentBlockIsLlmVisible, validateEventSource, validateSubscriptionAdmission, verbatimRecallHint, verifyWindowsDirectorySecurity, verifyWindowsDirectorySecurityAsync, waitResultTail, waitStatus, watchHeldPromptAttention, withGitProvisionSettingsForTest, withImagesBlocked, withInlineDraft, withOwnResourceAdmission, withResourceAdmission, withTranspileCacheWriteOwner, withWindowsDirectorySecurityOwner, withoutCarriedToolOutput, withoutSearchPosition, writeChunksAtomically, writeLinesAtomically, writeRenderers };
19458
+ export { AgentRehydrateError, AgentReleaseConfigError, CacheWarmer, ChildCatalog, CommandDeliveries, DEFAULT_MAX_MESSAGE_BYTES, DEFAULT_SUBSCRIPTION_MAX_CONCURRENT, EMPTY_OUTPUT_TEXT, EngineHealthController, ExtensionInputComponent, ExtensionSelectorComponent, FirstTimeSetupComponent, GIT_RELEASE, HistorySearchPositions, IMAGE_RESIZE_WORKER_RESPONSE_TYPE, LEGACY_AZURE_PROVIDER, LlamaClient, MAX_INDEXED_ENTRY_CHARS, MULTI_SUBMIT_LABEL, MarkdownContentCache, McpClient, MultiSelectView, NestedGitignore, NestedToolCallRunner, NoUsableModelError, QuestionParamsSchema, RESERVED_LABELS, RESUME_TIMINGS_TYPE, RemoteModelCatalog, RemoteQueuePause, ReopenedCompletionHeaders, ResumeTimingsRecorder, SEARCH_PART_CHARS, SESSIONS_TRANSFER_DIRECTORY, SESSION_STORAGE_JOIN, STORAGE_JOIN_COMMAND, SUMMARY_COMPACTION_PREFIX, SessionKeyDigests, SessionStorageSelectionSchema, SettingsSchema, SqlSessionSearchIndex, StorageImportIncompleteError, StorageSelectionSchema, StorageTransferError, StringEnum, TOOL_OUTPUT_ENTRY_TYPE, TRANSPILE_CACHE_WRITE_WAIT_MS, TaskElapsedClocks, TaskToolError, ToolExecutionScheduler, TransportEvents, UNORDERED_ADMISSION, VERBATIM_COMPACTION_PREFIX, VERIFICATION_PENDING_REASON, WorkspaceBindingError, WorkspaceCollectionError, WorkspaceConfigError, WorkspaceDriftError, WorkspaceError, WorkspaceGitError, WorkspacePublicationError, WorkspaceRestoreError, WorkspaceSandboxError, WorkspaceSnapshotError, WorkspaceTimeoutError, WrappingSelect, acceptsForkReplay, addResource, adoptCommandSession, appendFileChatRecord, assertSessionBlobStore, assertSettingsWrites, attachCleanupCause, bindRegistrationCallbacks, bindTaskClock, bindTaskClockSource, bodyWidths, buildDirectoryTree, buildDirectoryTreeFromOperations, buildToolStatusReport, cancelInitialBinding, cancelPausedOwnerTasks, cancelReceiptSentence, cancelReceiptStatus, captureForkReplayPair, captureRegistrationInvocation, carriedTransformedPrompt, carryCompletionEvidence, chatAnswerIntent, chatNumberingFor, childPresentationInput, claimInteractiveBind, classifyCompactionModel, cleanupFailureSummary, collectAgentTasks, collectCommandDeliveries, collectExtensionPackageWarnings, collectFlags, collectMarkdownTransformers, collectPackageInstallWarnings, collectRegisteredTools, collectSettingsDiagnostics, columnWidths, compareCreated, compareFrozen, computeFocusedOptionHasPreview, conflictEntries, convertImageBytesToPng, convertToLlm, convertToLlmWithForkBoundaries, convertToPng, copyRegistrations, copySessionBlobs, createAccumulator, createBranchSummaryMessage, createCustomMessage, createInvocationBindings, createLazyBuiltinFactory, createManagedTaskClocks, createProviderAlias, createSessionHistoryToolDefinition, createSkillRouter, createVerbatimCompactionMessage, crossTabLeftWidthWithDonation, currentResourceAdmission, decideLayout, deferCommandTurn, deferMessagesInterleavedWithToolBatch, deferRestorePhase, deleteFileChatRecords, describeToolSelection, detectLinuxLibc, diffLines, diffWords, discoverChatFile, drainProcessStdio, drainWindowsDirectorySecurityReads, dropDeferredCommandTurn, ensurePngTranscoder, ensureTool, errorMessage$1 as errorMessage, execCommand, extensionRefreshRejection, extensionSource, filterSupersededHerdrIntegrationPaths, findEntryRenderer, findMessageRenderer, findToolDefinition, findWorkspaceError, fixUtf8Stream, flush, forkReplayFilter, forkToolDeclarations, formatAnswerScalar, formatBytes, formatNoUsableModelMessage, formatPackageInstallWarning, formatResumeTimings, formatTokenSegment, formatToolStatus, genBridge, getBuiltinExtensionEntryLabel, getClientIdentity, getCommandEnv, getGitDistributionTarget, getGitInstallDir, getGitReleaseMarker, getGitShellEnvironment, getGitShellEnvironmentAsync, getGitStatus, getGitStatusAsync, getLatestVersion, getLazyBuiltinSpec, getLoaderAgentDirs, getPromptCacheTtlMs, getStorageAdapterHostModules, getToolEnv, getToolPath, getVirtualModules, gitInstallCommand, gitignoreMatcher, hasExtensionHandlers, hasFileChatRecords, hasLazyBuiltinSpec, hasQuitStoppableCommands, hasRecordedTransformedPrompt, hasTaskPromptHost, hasTransformedPrompt, heldPromptInput, heldPrompts, initialBindScope, inlineToolOutput, insertForcedOptionsBeforeTerminator, invocationExtension, invocationRuntime, isAgentRehydrateError, isAgentReleaseConfigError, isBashToolResult, isContentFilterRefusal, isEditToolResult, isFindToolResult, isForkHeader, isHeldPromptInput, isInsideInputHook, isJsonValue, isLocalOnlySessionStorage, isLsToolResult, isNativeBuiltinExtensionPath, isOfflineModeEnabled, isPowerShellToolResult, isPresentationHostInput, isProviderCredentialRejection, isReadToolResult, isRetryableAgentRehydrateError, isRetryableModelFailure, isRetryableSameModelFailure, isRetryableWorkspaceError, isSafetyRefusalFailure, isSourceBuiltinExtensionPath, isStorageImportIncompleteError, isStorageTransferError, isTaskToolError, isToolCallEventType, isTruthyEnvFlag, isUnrecognizedModelFailure, isVerbatimCompactionMessage, isWorkspaceBindingError, isWorkspaceCollectionError, isWorkspaceConfigError, isWorkspaceDriftError, isWorkspaceError, isWorkspaceGitError, isWorkspacePublicationError, isWorkspaceRestoreError, isWorkspaceSandboxError, isWorkspaceSnapshotError, isWorkspaceTimeoutError, isWriteToolResult, joinCommandSend, joinCommandTurn, killQuitStoppableCommandsNow, latestLegacyMessageTime, latestResumeTimings, legacyCompletionTarget, lifecycleScopeForOwner, llamaInferenceUrl, loadVirtualModules, loaderHostModulesTestHooks, mergeExtensionWarnings, mergeResourcePaths, messageIsLlmVisible, messageStartsLlmUserTurn, migrateCompactionModelSettings, modelFailureMessage, next, nextTransformedPromptRecord, normalizeAzureSettings, normalizeLlamaServerUrl, normalizeMessageContent, normalizeModelFailureSignal, normalizeModelProvider, normalizeModelReference, normalizeProviderKeys, noteCommandAnswer, noteCommandTurnMessage, noteRestoreFetch, openEventSubscription, originalRegistrationCallback, ownedSettingsManagers, parseArgs, parseConflictBytes, parseEngineExplicitQuitCommand, parseGitVersion, parseInteractiveEngineCommand, parseInteractiveEngineMessage, parseSkillUri, partitionByCredentials, plainStatMtimeMs, powershellCandidates, prepareRegistrationCallbacks, presentTaskError, presentationHostInput, prewarmModelApi, printHelp, projectTransformedPrompt, providerOfModelReference, publishEvent, readConflictUrl, readFileChatOrders, readFileChatRecords, readHostInputFormRequest, readInlineCaret, readInlineDraft, readLocalFileChunks, readPipedStdin, readTransferDirectory, reconcileRegistration, recordBlueprintStep, recordClosedStart, recordResumeTimings, recordSettingsWrite, refreshConflictFile, registerConflictBlocks, registerFactoryStartupHandler, registerInitialBindings, registerLazyBuiltin, registrationFields, rehydrateAgentRehydrateError, rehydrateTaskToolError, rehydrateWorkspaceError, rejectMalformedToolArguments, rememberEarlierCompletion, renderTodoCall, renderTodoResult, reopenedCompletionName, repairOrphanToolResults, reparentedSegments, reportDiagnostics, requestedThinkingLevelForModelSwitch, requireTimerMs, require_from_url, require_int, require_int$1, require_log, require_re, require_timestamp, require_toJS, require_trim_comparator_whitespace, require_util_flow_indent_check, require_util_map_includes, require_visit, reserveQueuedInputAdmission, resetGitProvisionStateForTest, resizeImageInProcess, resolveCompactionModel, resolveGit, resolveGitSync, resolveInlineDraftValue, resolveInstalledGit, resolveInvocationRuntime, resolveRegisteredCommands, resolveResourcePath, resolveToolConcurrency, resolvesCompletionHeader, routeKey, routeNamesPrompt, runCallback, runCommandHandler, runInputHook, runSynchronousCallback, runWithProgress, scheduleToolExecution, selectActivePreviewPaneIndex, selectActiveTabItems, selectConfirmedIndicator, selectReadLinesFromChunks, selectReadLinesFromList, serializeAgentRehydrateError, serializeInteractiveEngineFrame, serializeInteractiveEngineMessage, serializeTodoForAgent, serializeTodoListForAgent, serializeWorkspaceError, sessionBlobHashes, sessionBlobOutput, sessionLifecycleCreation, sessionLifecycleScopes, sessionPosition, sessionScratchDir, setCallbackActivityReporter, settingsWriteOwner, shareCompletionEvidence, showLlamaUi, shownSpanMs, skillUri, splitSearchTextParts, splitSegment, startedAsFork, startupRegistrationTokens, startupSourceId, stopIndex, storeInlineToolOutputs, storeSessionBlobs, streamCutDurationMs, stripVerbatimCompactionPrefix, subagentsLazyBuiltinSpec, summarizeLegacySession, takeInlineToolOutput, takeInlineToolOutputEntry, taskClockOf, taskClockRunning, taskClocksFor, taskElapsedMs, taskPromptHost, thinkingLevelForModelSwitch, timeCheckoutRestore, timeRestorePhase, toResolvedPaths, tokenize, toolChangeSupport, toolOutputUrl, toolOutputUrlHash, trackAdmittedAgentTask, trackTranspileCacheWrite, trackWindowsDirectorySecurityWork, transferFile, transformedPromptOwner, transpileCacheWritesSettled, unpackIds, unreadablePathError, unreadableTrustSettingsDiagnostics, unwritablePathError, userLikeContentBlockIsLlmVisible, validateEventSource, validateSubscriptionAdmission, verbatimRecallHint, verifyWindowsDirectorySecurity, verifyWindowsDirectorySecurityAsync, waitResultTail, waitStatus, watchHeldPromptAttention, withGitProvisionSettingsForTest, withImagesBlocked, withInlineDraft, withOwnResourceAdmission, withResourceAdmission, withTranspileCacheWriteOwner, withWindowsDirectorySecurityOwner, withoutCarriedToolOutput, withoutSearchPosition, writeChunksAtomically, writeLinesAtomically, writeRenderers };
19498
19459
 
19499
- //# sourceMappingURL=startup-0-1-GIY75K46.js.map
19460
+ //# sourceMappingURL=startup-0-1-RTOHJFDJ.js.map
19500
19461
  // __atomicOnDemandFailed: written by the build (scripts/in-place-update-gate.mjs). An import of this release's code on
19501
19462
  // demand that fails in a process an in-place update left running says to restart.
19502
19463
  function __atomicOnDemandFailed(error, feature) {
19503
19464
  return (async () => {
19504
19465
  const root = new URL("../", import.meta.url);
19505
19466
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
19506
- const key = `${root.href}#0.10.11-alpha.1`;
19467
+ const key = `${root.href}#0.10.11-alpha.3`;
19507
19468
  let release = releases.get(key);
19508
19469
  if (release === undefined) {
19509
19470
  const current = (async () => {
@@ -19531,7 +19492,7 @@ function __atomicOnDemandFailed(error, feature) {
19531
19492
  } catch {
19532
19493
  // No installation to read, as in a bundle of the package: the release the process runs decides.
19533
19494
  }
19534
- const updatedTo = typeof installed === "string" && installed !== "0.10.11-alpha.1" ? installed : running !== undefined && running.version !== "0.10.11-alpha.1" ? "0.10.11-alpha.1" : undefined;
19495
+ const updatedTo = typeof installed === "string" && installed !== "0.10.11-alpha.3" ? installed : running !== undefined && running.version !== "0.10.11-alpha.3" ? "0.10.11-alpha.3" : undefined;
19535
19496
  if (updatedTo === undefined) throw error;
19536
19497
  const application = typeof running?.name === "string" ? running.name : "atomic";
19537
19498
  const restart = new Error(`${application} was updated to ${updatedTo} while this session was running; restart it to keep using ${feature}.`, {