@bastani/atomic 0.10.7 → 0.10.8

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 (262) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/_shared/dist-KOELCESV.js +2 -2
  3. package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
  4. package/dist/_shared/lib-4PES5P4V.js +2 -2
  5. package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +5 -5
  6. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +5 -5
  7. package/dist/_shared/mode-shared-2QJSCUM6.js +5 -5
  8. package/dist/_shared/p1a-prewarm-UQY3X2UK.js +3 -3
  9. package/dist/_shared/runtime-O4KCSG4C.js +2 -2
  10. package/dist/_shared/{sdk-WQIOHVKO.js → sdk-OSBEPR3Q.js} +2875 -12
  11. package/dist/_shared/sdk-OSBEPR3Q.js.map +1 -0
  12. package/dist/_shared/session-data-AHTU7IS6.js +3 -3
  13. package/dist/_shared/startup-0-0-TYUFUOJZ.js +2 -2
  14. package/dist/_shared/startup-0-1-W2G2UY7R.js +163 -163
  15. package/dist/_shared/startup-0-1-W2G2UY7R.js.map +1 -1
  16. package/dist/_shared/{startup-0-2-SZGQIWHI.js → startup-0-2-UXBUEOXW.js} +4 -4
  17. package/dist/_shared/{startup-0-2-SZGQIWHI.js.map → startup-0-2-UXBUEOXW.js.map} +1 -1
  18. package/dist/_shared/startup-0-3-T4DVFYWX.js +3 -3
  19. package/dist/_shared/startup-0-4-HN5EB4K7.js +3 -3
  20. package/dist/_shared/{startup-0-5-OHJNE6JH.js → startup-0-5-FD2P735I.js} +5 -5
  21. package/dist/_shared/{startup-0-5-OHJNE6JH.js.map → startup-0-5-FD2P735I.js.map} +1 -1
  22. package/dist/_shared/startup-10-0-TDQNBDDL.js +5 -5
  23. package/dist/_shared/startup-12-0-55AAXBJZ.js +2 -2
  24. package/dist/_shared/startup-14-0-MLX36RBG.js +17 -4
  25. package/dist/_shared/startup-14-0-MLX36RBG.js.map +1 -1
  26. package/dist/_shared/startup-15-0-YUKGAC63.js +3 -3
  27. package/dist/_shared/startup-15-1-4S7FLMNG.js +5 -5
  28. package/dist/_shared/startup-8-0-34CBHPZH.js +3 -3
  29. package/dist/_shared/{startup-8-1-SJW2GMAM.js → startup-8-1-4KANEHRA.js} +6 -6
  30. package/dist/_shared/{startup-8-1-SJW2GMAM.js.map → startup-8-1-4KANEHRA.js.map} +1 -1
  31. package/dist/_shared/storage-command-7MGXLJGZ.js +3 -3
  32. package/dist/_shared/task-reference-stream-JWMUZSJX.js +1 -1
  33. package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
  34. package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
  35. package/dist/builtin/intercom/index.bundle.mjs +1 -1
  36. package/dist/builtin/intercom/package.json +1 -1
  37. package/dist/builtin/mcp/index.bundle.mjs +1 -1
  38. package/dist/builtin/mcp/package.json +1 -1
  39. package/dist/builtin/subagents/package.json +1 -1
  40. package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -1
  41. package/dist/builtin/web-access/index.bundle.mjs +1 -1
  42. package/dist/builtin/web-access/package.json +1 -1
  43. package/dist/cli/auth-cli.code.js +3 -3
  44. package/dist/cli/auth-cli.impl.js +3 -3
  45. package/dist/cli/auth-cli.js +3 -3
  46. package/dist/cli/blueprint-command.code.js +2 -2
  47. package/dist/cli/blueprint-command.impl.js +3 -3
  48. package/dist/cli/blueprint-command.js +3 -3
  49. package/dist/cli/intercom-command.code.js +3 -3
  50. package/dist/cli/intercom-command.impl.js +3 -3
  51. package/dist/cli/intercom-command.js +3 -3
  52. package/dist/cli/list-models.impl.js +3 -3
  53. package/dist/cli/list-models.js +3 -3
  54. package/dist/cli/session-picker.code.js +1 -1
  55. package/dist/cli/session-picker.impl.js +3 -3
  56. package/dist/cli/session-picker.js +3 -3
  57. package/dist/cli/startup-ui.code.js +1 -1
  58. package/dist/cli/startup-ui.impl.js +3 -3
  59. package/dist/cli/startup-ui.js +3 -3
  60. package/dist/cli/storage-command.impl.js +3 -3
  61. package/dist/cli/storage-command.js +3 -3
  62. package/dist/cli/storage-search-session.code.js +2 -2
  63. package/dist/cli/storage-search-session.impl.js +3 -3
  64. package/dist/cli/storage-search-session.js +3 -3
  65. package/dist/cli/team-command.code.js +2 -2
  66. package/dist/cli/team-command.impl.js +3 -3
  67. package/dist/cli/team-command.js +3 -3
  68. package/dist/cli.js +2 -2
  69. package/dist/core/debug.impl.js +3 -3
  70. package/dist/core/debug.js +3 -3
  71. package/dist/core/export-html/card-projection.code.js +1 -1
  72. package/dist/core/export-html/card-projection.impl.js +3 -3
  73. package/dist/core/export-html/card-projection.js +3 -3
  74. package/dist/core/export-html/index.code.js +2 -2
  75. package/dist/core/export-html/index.impl.js +3 -3
  76. package/dist/core/export-html/index.js +3 -3
  77. package/dist/core/export-html/json-spans.impl.js +3 -3
  78. package/dist/core/export-html/json-spans.js +3 -3
  79. package/dist/core/export-html/oversized-render-inputs.code.js +1 -1
  80. package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
  81. package/dist/core/export-html/oversized-render-inputs.js +3 -3
  82. package/dist/core/export-html/tool-renderer.impl.js +3 -3
  83. package/dist/core/export-html/tool-renderer.js +3 -3
  84. package/dist/core/extensions/jiti-loader.impl.js +3 -3
  85. package/dist/core/extensions/jiti-loader.js +3 -3
  86. package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
  87. package/dist/core/extensions/jiti-static-loader.js +3 -3
  88. package/dist/core/extensions/loader-host-modules.impl.js +3 -3
  89. package/dist/core/extensions/loader-host-modules.js +3 -3
  90. package/dist/core/extensions/loader-virtual-modules.js +1 -1
  91. package/dist/core/extensions/runner-context.js +1 -1
  92. package/dist/core/intercom-broker-control-host.code.js +1 -1
  93. package/dist/core/intercom-broker-control-host.impl.js +3 -3
  94. package/dist/core/intercom-broker-control-host.js +3 -3
  95. package/dist/core/intercom-broker-control.code.js +2 -2
  96. package/dist/core/intercom-broker-control.impl.js +3 -3
  97. package/dist/core/intercom-broker-control.js +3 -3
  98. package/dist/core/model-registry.js +1 -1
  99. package/dist/core/package-manager-storage-adapters.code.js +1 -1
  100. package/dist/core/package-manager-storage-adapters.impl.js +3 -3
  101. package/dist/core/package-manager-storage-adapters.js +3 -3
  102. package/dist/core/sdk.code.js +3 -3
  103. package/dist/core/sdk.impl.js +3 -3
  104. package/dist/core/sdk.js +3 -3
  105. package/dist/core/session-claims.d.ts +30 -0
  106. package/dist/core/session-lifecycle-work.d.ts +74 -0
  107. package/dist/core/session-manager-core.js +4 -4
  108. package/dist/core/session-manager-list.impl.js +3 -3
  109. package/dist/core/session-manager-list.js +3 -3
  110. package/dist/core/session-manager.impl.js +3 -3
  111. package/dist/core/session-manager.js +3 -3
  112. package/dist/core/session-storage.code.js +1 -1
  113. package/dist/core/session-storage.impl.js +3 -3
  114. package/dist/core/session-storage.js +3 -3
  115. package/dist/core/storage/index.js +2 -2
  116. package/dist/core/storage/node-sqlite-thread.js +2 -2
  117. package/dist/core/storage/node-sqlite.js +2 -2
  118. package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
  119. package/dist/core/storage/offline-snapshot-file.js +3 -3
  120. package/dist/core/storage/provider.js +2 -2
  121. package/dist/core/storage/selection.js +2 -2
  122. package/dist/core/storage/session/branch-fork-source.code.js +2 -2
  123. package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
  124. package/dist/core/storage/session/branch-fork-source.js +3 -3
  125. package/dist/core/storage/session/card-view.impl.js +3 -3
  126. package/dist/core/storage/session/card-view.js +3 -3
  127. package/dist/core/storage/session/child-reader.code.js +2 -2
  128. package/dist/core/storage/session/child-reader.impl.js +3 -3
  129. package/dist/core/storage/session/child-reader.js +3 -3
  130. package/dist/core/storage/session/chunked-resume-projection.code.js +1 -1
  131. package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
  132. package/dist/core/storage/session/chunked-resume-projection.js +3 -3
  133. package/dist/core/storage/session/expanded-child-details.code.js +3 -3
  134. package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
  135. package/dist/core/storage/session/expanded-child-details.js +3 -3
  136. package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
  137. package/dist/core/storage/session/fork-row-bytes.js +3 -3
  138. package/dist/core/storage/session/fork-row-index.impl.js +3 -3
  139. package/dist/core/storage/session/fork-row-index.js +3 -3
  140. package/dist/core/storage/session/fork-staging.code.js +1 -1
  141. package/dist/core/storage/session/fork-staging.impl.js +3 -3
  142. package/dist/core/storage/session/fork-staging.js +3 -3
  143. package/dist/core/storage/session/fork-window.code.js +2 -2
  144. package/dist/core/storage/session/fork-window.impl.js +3 -3
  145. package/dist/core/storage/session/fork-window.js +3 -3
  146. package/dist/core/storage/session/history-pages.impl.js +3 -3
  147. package/dist/core/storage/session/history-pages.js +3 -3
  148. package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
  149. package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
  150. package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
  151. package/dist/core/storage/session/jsonl-session-store.js +3 -3
  152. package/dist/core/storage/session/memory-session-store.impl.js +3 -3
  153. package/dist/core/storage/session/memory-session-store.js +3 -3
  154. package/dist/core/storage/session/pinned-branch-resume.code.js +2 -2
  155. package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
  156. package/dist/core/storage/session/pinned-branch-resume.js +3 -3
  157. package/dist/core/storage/session/released-history-files.code.js +1 -1
  158. package/dist/core/storage/session/released-history-files.impl.js +3 -3
  159. package/dist/core/storage/session/released-history-files.js +3 -3
  160. package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
  161. package/dist/core/storage/session/resident-fork-rows.js +3 -3
  162. package/dist/core/storage/session/session-resume.impl.js +3 -3
  163. package/dist/core/storage/session/session-resume.js +3 -3
  164. package/dist/core/storage/session/session-search-index.d.ts +39 -0
  165. package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
  166. package/dist/core/storage/session/snapshot-cut.js +3 -3
  167. package/dist/core/storage/session/snapshot-history.code.js +2 -2
  168. package/dist/core/storage/session/snapshot-history.impl.js +3 -3
  169. package/dist/core/storage/session/snapshot-history.js +3 -3
  170. package/dist/core/storage/session/sql-session-store.code.js +1 -1
  171. package/dist/core/storage/session/sql-session-store.d.ts +400 -0
  172. package/dist/core/storage/session/sql-session-store.impl.js +3 -3
  173. package/dist/core/storage/session/sql-session-store.js +3 -3
  174. package/dist/core/storage/session/tree-outline.impl.js +3 -3
  175. package/dist/core/storage/session/tree-outline.js +3 -3
  176. package/dist/core/storage/session/tree-presentation.code.js +1 -1
  177. package/dist/core/storage/session/tree-presentation.impl.js +3 -3
  178. package/dist/core/storage/session/tree-presentation.js +3 -3
  179. package/dist/core/storage/session/yield-turn.d.ts +3 -0
  180. package/dist/core/storage/storage-status.code.js +1 -1
  181. package/dist/core/storage/storage-status.impl.js +3 -3
  182. package/dist/core/storage/storage-status.js +3 -3
  183. package/dist/core/storage/team.code.js +1 -1
  184. package/dist/core/storage/team.impl.js +3 -3
  185. package/dist/core/storage/team.js +3 -3
  186. package/dist/core/storage/transfer-files.d.ts +74 -0
  187. package/dist/core/structured-output/index.code.js +1 -1
  188. package/dist/core/structured-output/index.impl.js +3 -3
  189. package/dist/core/structured-output/index.js +3 -3
  190. package/dist/core/tasks/task-completion-entry.code.js +1 -1
  191. package/dist/core/tasks/task-completion-entry.impl.js +3 -3
  192. package/dist/core/tasks/task-completion-entry.js +3 -3
  193. package/dist/core/tasks/task-file-history.code.js +2 -2
  194. package/dist/core/tasks/task-file-history.impl.js +3 -3
  195. package/dist/core/tasks/task-file-history.js +3 -3
  196. package/dist/core/tasks/task-reference-archive.code.js +3 -3
  197. package/dist/core/tasks/task-reference-archive.js +3 -3
  198. package/dist/core/tasks/task-reference-identity.js +3 -3
  199. package/dist/core/tasks/task-reference-stream.impl.js +3 -3
  200. package/dist/core/tasks/task-reference-stream.js +3 -3
  201. package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
  202. package/dist/core/tasks/task-unsaved-answer.js +3 -3
  203. package/dist/core/tasks/task-view-source.code.js +1 -1
  204. package/dist/core/tasks/task-view-source.impl.js +3 -3
  205. package/dist/core/tasks/task-view-source.js +3 -3
  206. package/dist/core/tools/read-url.code.js +1 -1
  207. package/dist/core/tools/read-url.impl.js +3 -3
  208. package/dist/core/tools/read-url.js +3 -3
  209. package/dist/core/worktree-snapshot/blob-store.js +2 -2
  210. package/dist/core/worktree-snapshot/errors.code.js +1 -1
  211. package/dist/core/worktree-snapshot/errors.impl.js +3 -3
  212. package/dist/core/worktree-snapshot/errors.js +3 -3
  213. package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
  214. package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
  215. package/dist/extensions/codemode/execute.code.js +1 -1
  216. package/dist/extensions/codemode/execute.impl.js +3 -3
  217. package/dist/extensions/codemode/execute.js +3 -3
  218. package/dist/extensions/codemode/renderer.code.js +1 -1
  219. package/dist/extensions/codemode/renderer.impl.js +3 -3
  220. package/dist/extensions/codemode/renderer.js +3 -3
  221. package/dist/extensions/mcp/cli.code.js +2 -2
  222. package/dist/extensions/mcp/cli.impl.js +3 -3
  223. package/dist/extensions/mcp/cli.js +3 -3
  224. package/dist/extensions/mcp/cli.lazy.code.js +2 -2
  225. package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
  226. package/dist/extensions/mcp/cli.lazy.js +3 -3
  227. package/dist/extensions/mcp/runtime.code.js +1 -1
  228. package/dist/extensions/mcp/runtime.impl.js +3 -3
  229. package/dist/extensions/mcp/runtime.js +3 -3
  230. package/dist/index.d.ts +13 -3
  231. package/dist/index.js +11 -11
  232. package/dist/main-first-time-setup.code.js +1 -1
  233. package/dist/main-first-time-setup.impl.js +3 -3
  234. package/dist/main-first-time-setup.js +3 -3
  235. package/dist/main.js +1 -1
  236. package/dist/modes/interactive/components/stored-tree-view.code.js +2 -2
  237. package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
  238. package/dist/modes/interactive/components/stored-tree-view.js +3 -3
  239. package/dist/modes/interactive/components/user-message-selector-archive.code.js +1 -1
  240. package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
  241. package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
  242. package/dist/modes/print-mode.js +1 -1
  243. package/dist/package-manager-cli.code.js +4 -4
  244. package/dist/package-manager-cli.impl.js +3 -3
  245. package/dist/package-manager-cli.js +3 -3
  246. package/dist/startup-files.json +1 -1
  247. package/dist/startup-stages/10.js +1 -1
  248. package/dist/startup-stages/12.js +1 -1
  249. package/dist/startup-stages/8.js +1 -1
  250. package/dist/utils/startup-database-spare.code.js +1 -1
  251. package/dist/utils/startup-database-spare.impl.js +3 -3
  252. package/dist/utils/startup-database-spare.js +3 -3
  253. package/dist/utils/tools-manager.impl.js +3 -3
  254. package/dist/utils/tools-manager.js +3 -3
  255. package/docs/sdk/reference.md +85 -0
  256. package/docs/sdk.md +23 -1
  257. package/package.json +8 -8
  258. package/dist/_shared/fork-staging-maintenance-AIIUXOZQ.js +0 -19
  259. package/dist/_shared/fork-staging-maintenance-AIIUXOZQ.js.map +0 -1
  260. package/dist/_shared/sdk-WQIOHVKO.js.map +0 -1
  261. package/dist/_shared/sql-session-store-5FD3WBMZ.js +0 -2903
  262. package/dist/_shared/sql-session-store-5FD3WBMZ.js.map +0 -1
@@ -19250,7 +19250,7 @@ function __atomicOnDemandFailed(error, feature) {
19250
19250
  return (async () => {
19251
19251
  const root = new URL("../", import.meta.url);
19252
19252
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
19253
- const key = `${root.href}#0.10.7`;
19253
+ const key = `${root.href}#0.10.8`;
19254
19254
  let release = releases.get(key);
19255
19255
  if (release === undefined) {
19256
19256
  const current = (async () => {
@@ -19278,7 +19278,7 @@ function __atomicOnDemandFailed(error, feature) {
19278
19278
  } catch {
19279
19279
  // No installation to read, as in a bundle of the package: the release the process runs decides.
19280
19280
  }
19281
- const updatedTo = typeof installed === "string" && installed !== "0.10.7" ? installed : running !== undefined && running.version !== "0.10.7" ? "0.10.7" : undefined;
19281
+ const updatedTo = typeof installed === "string" && installed !== "0.10.8" ? installed : running !== undefined && running.version !== "0.10.8" ? "0.10.8" : undefined;
19282
19282
  if (updatedTo === undefined) throw error;
19283
19283
  const application = typeof running?.name === "string" ? running.name : "atomic";
19284
19284
  const restart = new Error(`${application} was updated to ${updatedTo} while this session was running; restart it to keep using ${feature}.`, {
@@ -18953,6 +18953,167 @@ function isAgentViewReceipts(value) {
18953
18953
  if (value.sessionFile !== void 0 && typeof value.sessionFile !== "string") return false;
18954
18954
  return value.taken.every((receipt) => receipt === null || isJsonObject(receipt) && typeof receipt.id === "string" && typeof receipt.after === "number" && Number.isSafeInteger(receipt.after) && receipt.after >= 0 && (receipt.epoch === void 0 || typeof receipt.epoch === "string") && (receipt.typed === void 0 || typeof receipt.typed === "string") && (receipt.local === void 0 || receipt.local === true));
18955
18955
  }
18956
+ // dist/core/storage/transfer-files.js
18957
+ /**
18958
+ * The files `atomic storage export` writes and `atomic storage import` reads (#4716, #4720): one JSONL file per session,
18959
+ * in the `sessions` subdirectory of the export directory. Each file is written whole through a temporary file, and one
18960
+ * that already holds the same bytes is left untouched.
18961
+ */
18962
+ /** The file name extension of an exported session; import reads every file with it and ignores the rest. */
18963
+ const TRANSFER_FILE_EXTENSION = ".jsonl";
18964
+ /** The subdirectory of an export directory that holds sessions. */
18965
+ const SESSIONS_TRANSFER_DIRECTORY = "sessions";
18966
+ /** An export or import that could not be done; an import that fails this way wrote nothing. */
18967
+ var StorageTransferError = class extends StorageError {
18968
+ name = "StorageTransferError";
18969
+ path;
18970
+ line;
18971
+ id;
18972
+ reason;
18973
+ constructor(init) {
18974
+ super(`${init.path}${init.line === void 0 ? "" : `:${init.line}`}: ${init.reason}`, { cause: init.cause });
18975
+ this.path = init.path;
18976
+ this.line = init.line;
18977
+ this.id = init.id;
18978
+ this.reason = init.reason;
18979
+ }
18980
+ };
18981
+ /**
18982
+ * An import that failed after it wrote some sessions: `written` names exactly what it wrote, and `notWritten` what it
18983
+ * did not. Importing the same files again writes only what is missing.
18984
+ */
18985
+ var StorageImportIncompleteError = class extends StorageError {
18986
+ name = "StorageImportIncompleteError";
18987
+ written;
18988
+ notWritten;
18989
+ constructor(cause, outcome) {
18990
+ super(cause.message, { cause });
18991
+ this.written = outcome.written;
18992
+ this.notWritten = outcome.notWritten;
18993
+ }
18994
+ };
18995
+ function isStorageImportIncompleteError(value) {
18996
+ if (value instanceof StorageImportIncompleteError) return true;
18997
+ return typeof value === "object" && value !== null && value.name === "StorageImportIncompleteError";
18998
+ }
18999
+ function isStorageTransferError(value) {
19000
+ if (value instanceof StorageTransferError) return true;
19001
+ return typeof value === "object" && value !== null && value.name === "StorageTransferError";
19002
+ }
19003
+ /** The file a session with `id` is exported to in `directory`. */
19004
+ function transferFile(directory, id) {
19005
+ return join$1(directory, `${encodeURIComponent(id)}${TRANSFER_FILE_EXTENSION}`);
19006
+ }
19007
+ async function sameBytes(left, right) {
19008
+ const [a, b] = await Promise.all([open(left, "r"), open(right, "r").catch(() => void 0)]);
19009
+ if (b === void 0) {
19010
+ await a.close();
19011
+ return false;
19012
+ }
19013
+ return withCleanup(async () => {
19014
+ const [sizeA, sizeB] = await Promise.all([a.stat(), b.stat()]);
19015
+ if (sizeA.size !== sizeB.size) return false;
19016
+ const chunkA = Buffer.alloc(65536);
19017
+ const chunkB = Buffer.alloc(65536);
19018
+ for (let offset = 0; offset < sizeA.size;) {
19019
+ const [readA, readB] = await Promise.all([a.read(chunkA, 0, chunkA.length, offset), b.read(chunkB, 0, chunkB.length, offset)]);
19020
+ if (readA.bytesRead === 0 || readA.bytesRead !== readB.bytesRead) return false;
19021
+ if (!chunkA.subarray(0, readA.bytesRead).equals(chunkB.subarray(0, readB.bytesRead))) return false;
19022
+ offset += readA.bytesRead;
19023
+ }
19024
+ return true;
19025
+ }, async () => {
19026
+ await Promise.allSettled([a.close(), b.close()]);
19027
+ });
19028
+ }
19029
+ /**
19030
+ * Writes `lines`, each followed by a newline, to `file` through an owner-only temporary file in the same directory
19031
+ * that is flushed and then renamed over it, so `file` holds either its earlier content or all of the new content. The
19032
+ * lines are written as they come, so a large session is never held as one string. A file that already holds exactly
19033
+ * these bytes is left alone.
19034
+ */
19035
+ async function writeLinesAtomically(file, lines) {
19036
+ async function* contents() {
19037
+ for await (const line of lines) yield `${line}\n`;
19038
+ }
19039
+ return writeChunksAtomically(file, contents());
19040
+ }
19041
+ /** Publish a complete file even when a single JSONL record spans many byte chunks. */
19042
+ async function writeChunksAtomically(file, chunks) {
19043
+ const temporary = join$1(file, "..", `.${randomUUID()}.tmp`);
19044
+ try {
19045
+ const handle = await open(temporary, "wx", 384);
19046
+ await withCleanup(async () => {
19047
+ for await (const chunk of chunks) await handle.writeFile(chunk);
19048
+ await handle.sync();
19049
+ }, () => handle.close());
19050
+ if (await sameBytes(temporary, file)) {
19051
+ await rm(temporary, { force: true });
19052
+ return "unchanged";
19053
+ }
19054
+ await rename(temporary, file);
19055
+ } catch (error) {
19056
+ await rm(temporary, { force: true }).catch(() => void 0);
19057
+ if (isStorageTransferError(error)) throw error;
19058
+ throw new StorageTransferError({
19059
+ path: file,
19060
+ reason: `cannot write the export file: ${error.message}`,
19061
+ cause: error
19062
+ });
19063
+ }
19064
+ return "written";
19065
+ }
19066
+ /**
19067
+ * The `*.jsonl` files of `directory`, in name order, each decoded as UTF-8 and split into lines; a final newline does
19068
+ * not start another line. A directory that does not exist holds no files. Throws `StorageTransferError` naming the
19069
+ * file when one cannot be read or is not UTF-8.
19070
+ */
19071
+ async function readTransferDirectory(directory) {
19072
+ let names;
19073
+ try {
19074
+ names = await readdir(directory);
19075
+ } catch (error) {
19076
+ if (error.code === "ENOENT") return [];
19077
+ throw new StorageTransferError({
19078
+ path: directory,
19079
+ reason: `cannot read the directory: ${error.message}`,
19080
+ cause: error
19081
+ });
19082
+ }
19083
+ const files = [];
19084
+ for (const name of names.filter((entry) => entry.endsWith(TRANSFER_FILE_EXTENSION)).sort()) {
19085
+ const file = join$1(directory, name);
19086
+ let bytes;
19087
+ try {
19088
+ bytes = await readFile(file);
19089
+ } catch (error) {
19090
+ throw new StorageTransferError({
19091
+ path: file,
19092
+ reason: `cannot read the file: ${error.message}`,
19093
+ cause: error
19094
+ });
19095
+ }
19096
+ let text;
19097
+ try {
19098
+ text = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
19099
+ } catch {
19100
+ throw new StorageTransferError({
19101
+ path: file,
19102
+ reason: "is not valid UTF-8 text"
19103
+ });
19104
+ }
19105
+ const lines = text.split("\n");
19106
+ if (lines.at(-1) === "") lines.pop();
19107
+ files.push({
19108
+ file,
19109
+ lines: lines.map((line, index) => ({
19110
+ line: index + 1,
19111
+ text: line
19112
+ }))
19113
+ });
19114
+ }
19115
+ return files;
19116
+ }
18956
19117
  // dist/core/storage/session/child-catalog.js
18957
19118
  const obj = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : {};
18958
19119
  const keyOf = (owner, child) => JSON.stringify([owner, child]);
@@ -19260,167 +19421,6 @@ var ChildCatalog = class ChildCatalog {
19260
19421
  return c ? [.../* @__PURE__ */ new Set([c.first, ...c.fields.values()])].sort((a, b) => a - b) : void 0;
19261
19422
  }
19262
19423
  };
19263
- // dist/core/storage/transfer-files.js
19264
- /**
19265
- * The files `atomic storage export` writes and `atomic storage import` reads (#4716, #4720): one JSONL file per session,
19266
- * in the `sessions` subdirectory of the export directory. Each file is written whole through a temporary file, and one
19267
- * that already holds the same bytes is left untouched.
19268
- */
19269
- /** The file name extension of an exported session; import reads every file with it and ignores the rest. */
19270
- const TRANSFER_FILE_EXTENSION = ".jsonl";
19271
- /** The subdirectory of an export directory that holds sessions. */
19272
- const SESSIONS_TRANSFER_DIRECTORY = "sessions";
19273
- /** An export or import that could not be done; an import that fails this way wrote nothing. */
19274
- var StorageTransferError = class extends StorageError {
19275
- name = "StorageTransferError";
19276
- path;
19277
- line;
19278
- id;
19279
- reason;
19280
- constructor(init) {
19281
- super(`${init.path}${init.line === void 0 ? "" : `:${init.line}`}: ${init.reason}`, { cause: init.cause });
19282
- this.path = init.path;
19283
- this.line = init.line;
19284
- this.id = init.id;
19285
- this.reason = init.reason;
19286
- }
19287
- };
19288
- /**
19289
- * An import that failed after it wrote some sessions: `written` names exactly what it wrote, and `notWritten` what it
19290
- * did not. Importing the same files again writes only what is missing.
19291
- */
19292
- var StorageImportIncompleteError = class extends StorageError {
19293
- name = "StorageImportIncompleteError";
19294
- written;
19295
- notWritten;
19296
- constructor(cause, outcome) {
19297
- super(cause.message, { cause });
19298
- this.written = outcome.written;
19299
- this.notWritten = outcome.notWritten;
19300
- }
19301
- };
19302
- function isStorageImportIncompleteError(value) {
19303
- if (value instanceof StorageImportIncompleteError) return true;
19304
- return typeof value === "object" && value !== null && value.name === "StorageImportIncompleteError";
19305
- }
19306
- function isStorageTransferError(value) {
19307
- if (value instanceof StorageTransferError) return true;
19308
- return typeof value === "object" && value !== null && value.name === "StorageTransferError";
19309
- }
19310
- /** The file a session with `id` is exported to in `directory`. */
19311
- function transferFile(directory, id) {
19312
- return join$1(directory, `${encodeURIComponent(id)}${TRANSFER_FILE_EXTENSION}`);
19313
- }
19314
- async function sameBytes(left, right) {
19315
- const [a, b] = await Promise.all([open(left, "r"), open(right, "r").catch(() => void 0)]);
19316
- if (b === void 0) {
19317
- await a.close();
19318
- return false;
19319
- }
19320
- return withCleanup(async () => {
19321
- const [sizeA, sizeB] = await Promise.all([a.stat(), b.stat()]);
19322
- if (sizeA.size !== sizeB.size) return false;
19323
- const chunkA = Buffer.alloc(65536);
19324
- const chunkB = Buffer.alloc(65536);
19325
- for (let offset = 0; offset < sizeA.size;) {
19326
- const [readA, readB] = await Promise.all([a.read(chunkA, 0, chunkA.length, offset), b.read(chunkB, 0, chunkB.length, offset)]);
19327
- if (readA.bytesRead === 0 || readA.bytesRead !== readB.bytesRead) return false;
19328
- if (!chunkA.subarray(0, readA.bytesRead).equals(chunkB.subarray(0, readB.bytesRead))) return false;
19329
- offset += readA.bytesRead;
19330
- }
19331
- return true;
19332
- }, async () => {
19333
- await Promise.allSettled([a.close(), b.close()]);
19334
- });
19335
- }
19336
- /**
19337
- * Writes `lines`, each followed by a newline, to `file` through an owner-only temporary file in the same directory
19338
- * that is flushed and then renamed over it, so `file` holds either its earlier content or all of the new content. The
19339
- * lines are written as they come, so a large session is never held as one string. A file that already holds exactly
19340
- * these bytes is left alone.
19341
- */
19342
- async function writeLinesAtomically(file, lines) {
19343
- async function* contents() {
19344
- for await (const line of lines) yield `${line}\n`;
19345
- }
19346
- return writeChunksAtomically(file, contents());
19347
- }
19348
- /** Publish a complete file even when a single JSONL record spans many byte chunks. */
19349
- async function writeChunksAtomically(file, chunks) {
19350
- const temporary = join$1(file, "..", `.${randomUUID()}.tmp`);
19351
- try {
19352
- const handle = await open(temporary, "wx", 384);
19353
- await withCleanup(async () => {
19354
- for await (const chunk of chunks) await handle.writeFile(chunk);
19355
- await handle.sync();
19356
- }, () => handle.close());
19357
- if (await sameBytes(temporary, file)) {
19358
- await rm(temporary, { force: true });
19359
- return "unchanged";
19360
- }
19361
- await rename(temporary, file);
19362
- } catch (error) {
19363
- await rm(temporary, { force: true }).catch(() => void 0);
19364
- if (isStorageTransferError(error)) throw error;
19365
- throw new StorageTransferError({
19366
- path: file,
19367
- reason: `cannot write the export file: ${error.message}`,
19368
- cause: error
19369
- });
19370
- }
19371
- return "written";
19372
- }
19373
- /**
19374
- * The `*.jsonl` files of `directory`, in name order, each decoded as UTF-8 and split into lines; a final newline does
19375
- * not start another line. A directory that does not exist holds no files. Throws `StorageTransferError` naming the
19376
- * file when one cannot be read or is not UTF-8.
19377
- */
19378
- async function readTransferDirectory(directory) {
19379
- let names;
19380
- try {
19381
- names = await readdir(directory);
19382
- } catch (error) {
19383
- if (error.code === "ENOENT") return [];
19384
- throw new StorageTransferError({
19385
- path: directory,
19386
- reason: `cannot read the directory: ${error.message}`,
19387
- cause: error
19388
- });
19389
- }
19390
- const files = [];
19391
- for (const name of names.filter((entry) => entry.endsWith(TRANSFER_FILE_EXTENSION)).sort()) {
19392
- const file = join$1(directory, name);
19393
- let bytes;
19394
- try {
19395
- bytes = await readFile(file);
19396
- } catch (error) {
19397
- throw new StorageTransferError({
19398
- path: file,
19399
- reason: `cannot read the file: ${error.message}`,
19400
- cause: error
19401
- });
19402
- }
19403
- let text;
19404
- try {
19405
- text = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
19406
- } catch {
19407
- throw new StorageTransferError({
19408
- path: file,
19409
- reason: "is not valid UTF-8 text"
19410
- });
19411
- }
19412
- const lines = text.split("\n");
19413
- if (lines.at(-1) === "") lines.pop();
19414
- files.push({
19415
- file,
19416
- lines: lines.map((line, index) => ({
19417
- line: index + 1,
19418
- text: line
19419
- }))
19420
- });
19421
- }
19422
- return files;
19423
- }
19424
19424
  // dist/core/storage/session/scratch-directory.js
19425
19425
  function sessionScratchDir(agentDir, cwd, _sessionId) {
19426
19426
  return getDefaultSessionDirPath(cwd, agentDir);
@@ -19434,7 +19434,7 @@ function __atomicOnDemandFailed(error, feature) {
19434
19434
  return (async () => {
19435
19435
  const root = new URL("../", import.meta.url);
19436
19436
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
19437
- const key = `${root.href}#0.10.7`;
19437
+ const key = `${root.href}#0.10.8`;
19438
19438
  let release = releases.get(key);
19439
19439
  if (release === undefined) {
19440
19440
  const current = (async () => {
@@ -19462,7 +19462,7 @@ function __atomicOnDemandFailed(error, feature) {
19462
19462
  } catch {
19463
19463
  // No installation to read, as in a bundle of the package: the release the process runs decides.
19464
19464
  }
19465
- const updatedTo = typeof installed === "string" && installed !== "0.10.7" ? installed : running !== undefined && running.version !== "0.10.7" ? "0.10.7" : undefined;
19465
+ const updatedTo = typeof installed === "string" && installed !== "0.10.8" ? installed : running !== undefined && running.version !== "0.10.8" ? "0.10.8" : undefined;
19466
19466
  if (updatedTo === undefined) throw error;
19467
19467
  const application = typeof running?.name === "string" ? running.name : "atomic";
19468
19468
  const restart = new Error(`${application} was updated to ${updatedTo} while this session was running; restart it to keep using ${feature}.`, {