@bastani/atomic 0.10.11-alpha.2 → 0.10.11-alpha.4
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.
- package/CHANGELOG.md +150 -0
- package/README.md +5 -8
- package/dist/_shared/dist-KOELCESV.js +2 -2
- package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
- package/dist/_shared/lib-4PES5P4V.js +2 -2
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +6 -6
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +5 -5
- package/dist/_shared/mode-shared-2QJSCUM6.js +6 -6
- package/dist/_shared/p0-cli-BB45ZQY6.js +46 -67
- package/dist/_shared/p0-cli-BB45ZQY6.js.map +1 -1
- package/dist/_shared/p1a-prewarm-XIU57JHF.js +7 -8
- package/dist/_shared/p1a-prewarm-XIU57JHF.js.map +1 -1
- package/dist/_shared/{p1b-elig-ENCUPKKJ.js → p1b-elig-TVB5CBLL.js} +36 -8
- package/dist/_shared/p1b-elig-TVB5CBLL.js.map +1 -0
- package/dist/_shared/p2-shell-main-B2WIALFD.js +6 -3
- package/dist/_shared/p2-shell-main-B2WIALFD.js.map +1 -1
- package/dist/_shared/runtime-O4KCSG4C.js +3 -3
- package/dist/_shared/{sdk-IQMULKFU.js → sdk-B5LEWGGI.js} +1218 -657
- package/dist/_shared/sdk-B5LEWGGI.js.map +1 -0
- package/dist/_shared/session-data-AHTU7IS6.js +2 -2
- package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
- package/dist/_shared/{startup-0-0-3IXNMFM2.js → startup-0-0-XJJDOIEC.js} +50 -48
- package/dist/_shared/startup-0-0-XJJDOIEC.js.map +1 -0
- package/dist/_shared/{startup-0-1-7T2IAE7J.js → startup-0-1-M6OWAYHH.js} +540 -136
- package/dist/_shared/startup-0-1-M6OWAYHH.js.map +1 -0
- package/dist/_shared/startup-0-2-5QHPCEON.js +47 -48
- package/dist/_shared/startup-0-2-5QHPCEON.js.map +1 -1
- package/dist/_shared/startup-0-3-4ZYBYQNM.js +5 -5
- package/dist/_shared/startup-0-4-ZMJV547D.js +12 -7
- package/dist/_shared/startup-0-4-ZMJV547D.js.map +1 -1
- package/dist/_shared/startup-0-5-YDW47QX6.js +7 -7
- package/dist/_shared/startup-0-5-YDW47QX6.js.map +1 -1
- package/dist/_shared/startup-10-0-TDQNBDDL.js +6 -6
- package/dist/_shared/startup-12-0-55AAXBJZ.js +2 -2
- package/dist/_shared/startup-14-0-MLX36RBG.js +4 -5
- package/dist/_shared/startup-14-0-MLX36RBG.js.map +1 -1
- package/dist/_shared/startup-15-0-YUKGAC63.js +4 -4
- package/dist/_shared/startup-15-1-4S7FLMNG.js +19 -27
- package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +2144 -249
- package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
- package/dist/_shared/{startup-8-1-X32CYSXB.js → startup-8-1-LZFXSD3Z.js} +98 -1184
- package/dist/_shared/startup-8-1-LZFXSD3Z.js.map +1 -0
- package/dist/_shared/storage-command-7MGXLJGZ.js +188 -37
- package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
- package/dist/_shared/storage-status-K7PX2RXA.js +557 -0
- package/dist/_shared/storage-status-K7PX2RXA.js.map +1 -0
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/team-DOQKICG2.js +376 -0
- package/dist/_shared/team-DOQKICG2.js.map +1 -0
- package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
- package/dist/builtin/intercom/CHANGELOG.md +42 -0
- package/dist/builtin/intercom/README.md +2 -2
- package/dist/builtin/intercom/broker/broker.bundle.mjs +1917 -381
- package/dist/builtin/intercom/broker/client.ts +8 -0
- package/dist/builtin/intercom/broker/database-wake-up-bus.ts +324 -68
- package/dist/builtin/intercom/broker/multinode-router.ts +256 -39
- package/dist/builtin/intercom/broker/multinode-state-store.ts +71 -5
- package/dist/builtin/intercom/broker/open-broker-state.ts +14 -0
- package/dist/builtin/intercom/broker/send-order-gate.ts +5 -2
- package/dist/builtin/intercom/broker/sql-add-column.ts +50 -5
- package/dist/builtin/intercom/broker/sql-ended-child-queue-store.ts +3 -2
- package/dist/builtin/intercom/broker/sql-held-send-store.ts +2 -2
- package/dist/builtin/intercom/broker/sql-known-session-store.ts +43 -19
- package/dist/builtin/intercom/broker/sql-lease-store.ts +473 -121
- package/dist/builtin/intercom/broker/sql-outbox-store.ts +821 -79
- package/dist/builtin/intercom/broker/sql-pending-ask-store.ts +8 -5
- package/dist/builtin/intercom/broker/sql-released-ask-store.ts +12 -5
- package/dist/builtin/intercom/broker/sql-restoring-reservation-store.ts +256 -8
- package/dist/builtin/intercom/broker/sql-retention.ts +150 -0
- package/dist/builtin/intercom/broker/sql-schema.ts +175 -24
- package/dist/builtin/intercom/broker/sql-sent-message-authority.ts +74 -19
- package/dist/builtin/intercom/broker/wake-up-bus.ts +6 -0
- package/dist/builtin/intercom/index.bundle.mjs +14 -4
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/index.bundle.mjs +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +6 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/skill-creator/eval-viewer/generate_review.py +8 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -1
- package/dist/builtin/web-access/index.bundle.mjs +2 -10
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/bun/bundled-sqlite.js +41 -0
- package/dist/bun/bundled-sqlite.js.map +1 -0
- package/dist/cli/args.js +2 -2
- package/dist/cli/auth-cli.code.js +4 -4
- package/dist/cli/auth-cli.impl.js +3 -3
- package/dist/cli/auth-cli.js +3 -3
- package/dist/cli/blueprint-command.code.js +3 -3
- package/dist/cli/blueprint-command.impl.js +3 -3
- package/dist/cli/blueprint-command.js +3 -3
- package/dist/cli/intercom-command.code.js +3 -3
- package/dist/cli/intercom-command.code.js.map +1 -1
- package/dist/cli/intercom-command.impl.js +3 -3
- package/dist/cli/intercom-command.js +3 -3
- package/dist/cli/list-models.code.js +2 -2
- package/dist/cli/list-models.impl.js +3 -3
- package/dist/cli/list-models.js +3 -3
- package/dist/cli/session-picker.code.js +1 -1
- package/dist/cli/session-picker.impl.js +3 -3
- package/dist/cli/session-picker.js +3 -3
- package/dist/cli/startup-ui.code.js +1 -1
- package/dist/cli/startup-ui.impl.js +3 -3
- package/dist/cli/startup-ui.js +3 -3
- package/dist/cli/storage-command.impl.js +3 -3
- package/dist/cli/storage-command.js +3 -3
- package/dist/cli/storage-search-session.code.js +3 -3
- package/dist/cli/storage-search-session.impl.js +3 -3
- package/dist/cli/storage-search-session.js +3 -3
- package/dist/cli/team-command.code.js +19 -113
- package/dist/cli/team-command.code.js.map +1 -1
- package/dist/cli/team-command.impl.js +3 -3
- package/dist/cli/team-command.js +3 -3
- package/dist/cli.js +5 -18
- package/dist/cli.js.map +1 -1
- package/dist/core/agent-rehydrate-errors.d.ts +4 -9
- package/dist/core/compaction/compactor.d.ts +3 -3
- package/dist/core/debug.code.js +1 -1
- package/dist/core/debug.impl.js +3 -3
- package/dist/core/debug.js +3 -3
- package/dist/core/export-html/card-projection.impl.js +3 -3
- package/dist/core/export-html/card-projection.js +3 -3
- package/dist/core/export-html/index.code.js +4 -4
- package/dist/core/export-html/index.code.js.map +1 -1
- package/dist/core/export-html/index.impl.js +3 -3
- package/dist/core/export-html/index.js +3 -3
- package/dist/core/export-html/json-spans.impl.js +3 -3
- package/dist/core/export-html/json-spans.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.js +3 -3
- package/dist/core/export-html/tool-renderer.impl.js +3 -3
- package/dist/core/export-html/tool-renderer.js +3 -3
- package/dist/core/extensions/jiti-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-loader.js +3 -3
- package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-static-loader.js +3 -3
- package/dist/core/extensions/loader-host-modules.code.js +1 -1
- package/dist/core/extensions/loader-host-modules.impl.js +3 -3
- package/dist/core/extensions/loader-host-modules.js +3 -3
- package/dist/core/extensions/loader-virtual-modules.js +1 -1
- package/dist/core/extensions/runner-context.js +2 -2
- package/dist/core/intercom-broker-control-host.code.js +2 -2
- package/dist/core/intercom-broker-control-host.impl.js +3 -3
- package/dist/core/intercom-broker-control-host.js +3 -3
- package/dist/core/intercom-broker-control.code.js +3 -3
- package/dist/core/intercom-broker-control.impl.js +3 -3
- package/dist/core/intercom-broker-control.js +3 -3
- package/dist/core/package-manager-storage-adapters.code.js +1 -1
- package/dist/core/package-manager-storage-adapters.impl.js +3 -3
- package/dist/core/package-manager-storage-adapters.js +3 -3
- package/dist/core/process-start-token.d.ts +12 -3
- package/dist/core/process-tree-containment.d.ts +16 -0
- package/dist/core/sdk-types.d.ts +1 -2
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.code.js +3 -3
- package/dist/core/sdk.impl.js +3 -3
- package/dist/core/sdk.js +3 -3
- package/dist/core/session-manager-core.js +5 -5
- package/dist/core/session-manager-list.impl.js +3 -3
- package/dist/core/session-manager-list.js +3 -3
- package/dist/core/session-manager.code.js +1 -1
- package/dist/core/session-manager.impl.js +3 -3
- package/dist/core/session-manager.js +3 -3
- package/dist/core/session-storage.code.js +1 -1
- package/dist/core/session-storage.impl.js +3 -3
- package/dist/core/session-storage.js +3 -3
- package/dist/core/settings-schema.d.ts +0 -3
- package/dist/core/storage/added-exports-0-10-11.js +19 -0
- package/dist/core/storage/added-exports-0-10-11.js.map +1 -0
- package/dist/core/storage/creation-time.js +105 -0
- package/dist/core/storage/creation-time.js.map +1 -0
- package/dist/core/storage/database.d.ts +25 -5
- package/dist/core/storage/database.js.map +1 -1
- package/dist/core/storage/dialect.d.ts +1 -1
- package/dist/core/storage/dialect.js +1 -1
- package/dist/core/storage/dialect.js.map +1 -1
- package/dist/core/storage/errors.d.ts +13 -13
- package/dist/core/storage/errors.js +10 -16
- package/dist/core/storage/errors.js.map +1 -1
- package/dist/core/storage/fenced-paths.d.ts +18 -6
- package/dist/core/storage/fenced-paths.js +18 -6
- package/dist/core/storage/fenced-paths.js.map +1 -1
- package/dist/core/storage/file-identity.d.ts +2 -0
- package/dist/core/storage/file-identity.js +24 -8
- package/dist/core/storage/file-identity.js.map +1 -1
- package/dist/core/storage/index.d.ts +3 -2
- package/dist/core/storage/index.js +5 -3
- package/dist/core/storage/index.js.map +1 -1
- package/dist/core/storage/libsql-removed.d.ts +71 -0
- package/dist/core/storage/libsql-removed.js +123 -0
- package/dist/core/storage/libsql-removed.js.map +1 -0
- package/dist/core/storage/migrations.d.ts +78 -14
- package/dist/core/storage/migrations.js +375 -49
- package/dist/core/storage/migrations.js.map +1 -1
- package/dist/core/storage/node-sqlite-file-gate.js +0 -15
- package/dist/core/storage/node-sqlite-file-gate.js.map +1 -1
- package/dist/core/storage/node-sqlite-thread.js +215 -30
- package/dist/core/storage/node-sqlite-thread.js.map +1 -1
- package/dist/core/storage/node-sqlite.js +484 -72
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
- package/dist/core/storage/offline-snapshot-file.js +3 -3
- package/dist/core/storage/prefix.d.ts +1 -1
- package/dist/core/storage/prefix.js +9 -2
- package/dist/core/storage/prefix.js.map +1 -1
- package/dist/core/storage/process-selection.d.ts +5 -5
- package/dist/core/storage/provider.js +2 -2
- package/dist/core/storage/schema-catalog.d.ts +76 -15
- package/dist/core/storage/schema-catalog.js +359 -68
- package/dist/core/storage/schema-catalog.js.map +1 -1
- package/dist/core/storage/selection.d.ts +7 -82
- package/dist/core/storage/selection.js +20 -235
- package/dist/core/storage/selection.js.map +1 -1
- package/dist/core/storage/session/branch-fork-source.code.js +2 -2
- package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
- package/dist/core/storage/session/branch-fork-source.js +3 -3
- package/dist/core/storage/session/card-view.impl.js +3 -3
- package/dist/core/storage/session/card-view.js +3 -3
- package/dist/core/storage/session/child-reader.code.js +3 -3
- package/dist/core/storage/session/child-reader.impl.js +3 -3
- package/dist/core/storage/session/child-reader.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.js +3 -3
- package/dist/core/storage/session/expanded-child-details.code.js +2 -2
- package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
- package/dist/core/storage/session/expanded-child-details.js +3 -3
- package/dist/core/storage/session/fork-detach.d.ts +11 -1
- package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
- package/dist/core/storage/session/fork-row-bytes.js +3 -3
- package/dist/core/storage/session/fork-row-index.impl.js +3 -3
- package/dist/core/storage/session/fork-row-index.js +3 -3
- package/dist/core/storage/session/fork-staging.code.js +4 -7
- package/dist/core/storage/session/fork-staging.code.js.map +1 -1
- package/dist/core/storage/session/fork-staging.impl.js +3 -3
- package/dist/core/storage/session/fork-staging.js +3 -3
- package/dist/core/storage/session/fork-sweep.js +31 -7
- package/dist/core/storage/session/fork-sweep.js.map +1 -1
- package/dist/core/storage/session/fork-window.code.js +3 -3
- package/dist/core/storage/session/fork-window.impl.js +3 -3
- package/dist/core/storage/session/fork-window.js +3 -3
- package/dist/core/storage/session/history-pages.impl.js +3 -3
- package/dist/core/storage/session/history-pages.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
- package/dist/core/storage/session/jsonl-session-lock.d.ts +100 -0
- package/dist/core/storage/session/jsonl-session-store.d.ts +46 -24
- package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.js +3 -3
- package/dist/core/storage/session/memory-session-store.impl.js +3 -3
- package/dist/core/storage/session/memory-session-store.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.js +3 -3
- package/dist/core/storage/session/released-history-files.code.js +9 -9
- package/dist/core/storage/session/released-history-files.code.js.map +1 -1
- package/dist/core/storage/session/released-history-files.impl.js +3 -3
- package/dist/core/storage/session/released-history-files.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.js +3 -3
- package/dist/core/storage/session/session-resume.impl.js +3 -3
- package/dist/core/storage/session/session-resume.js +3 -3
- package/dist/core/storage/session/session-search-index.d.ts +52 -5
- package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
- package/dist/core/storage/session/snapshot-cut.js +3 -3
- package/dist/core/storage/session/snapshot-history.code.js +3 -3
- package/dist/core/storage/session/snapshot-history.impl.js +3 -3
- package/dist/core/storage/session/snapshot-history.js +3 -3
- package/dist/core/storage/session/sql-session-store.code.js +1 -1
- package/dist/core/storage/session/sql-session-store.d.ts +99 -18
- package/dist/core/storage/session/sql-session-store.impl.js +3 -3
- package/dist/core/storage/session/sql-session-store.js +3 -3
- package/dist/core/storage/session/tree-outline.impl.js +3 -3
- package/dist/core/storage/session/tree-outline.js +3 -3
- package/dist/core/storage/session/tree-presentation.impl.js +3 -3
- package/dist/core/storage/session/tree-presentation.js +3 -3
- package/dist/core/storage/sqlite-facade.d.ts +12 -1
- package/dist/core/storage/sqlite-facade.js +310 -33
- package/dist/core/storage/sqlite-facade.js.map +1 -1
- package/dist/core/storage/sqlite-open-batch.js +10 -0
- package/dist/core/storage/sqlite-open-batch.js.map +1 -0
- package/dist/core/storage/storage-status.code.js +1 -1
- package/dist/core/storage/storage-status.impl.js +3 -3
- package/dist/core/storage/storage-status.js +3 -3
- package/dist/core/storage/team.code.js +1 -1
- package/dist/core/storage/team.d.ts +26 -115
- package/dist/core/storage/team.impl.js +3 -3
- package/dist/core/storage/team.js +3 -3
- package/dist/core/structured-output/index.code.js +1 -1
- package/dist/core/structured-output/index.impl.js +3 -3
- package/dist/core/structured-output/index.js +3 -3
- package/dist/core/tasks/task-completion-entry.impl.js +3 -3
- package/dist/core/tasks/task-completion-entry.js +3 -3
- package/dist/core/tasks/task-file-history.code.js +3 -3
- package/dist/core/tasks/task-file-history.impl.js +3 -3
- package/dist/core/tasks/task-file-history.js +3 -3
- package/dist/core/tasks/task-reference-archive.code.js +4 -4
- package/dist/core/tasks/task-reference-archive.js +3 -3
- package/dist/core/tasks/task-reference-identity.js +3 -3
- package/dist/core/tasks/task-reference-stream.impl.js +3 -3
- package/dist/core/tasks/task-reference-stream.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.js +3 -3
- package/dist/core/tasks/task-view-source.code.js +1 -1
- package/dist/core/tasks/task-view-source.impl.js +3 -3
- package/dist/core/tasks/task-view-source.js +3 -3
- package/dist/core/tools/history-tasks.d.ts +3 -2
- package/dist/core/tools/read-url.code.js +4 -4
- package/dist/core/tools/read-url.impl.js +3 -3
- package/dist/core/tools/read-url.js +3 -3
- package/dist/core/worktree-snapshot/blob-store.d.ts +44 -5
- package/dist/core/worktree-snapshot/blob-store.js +553 -30
- package/dist/core/worktree-snapshot/blob-store.js.map +1 -1
- package/dist/core/worktree-snapshot/errors.code.js +2 -2
- package/dist/core/worktree-snapshot/errors.impl.js +3 -3
- package/dist/core/worktree-snapshot/errors.js +3 -3
- package/dist/core/worktree-snapshot/fork-blob-guard.js +81 -0
- package/dist/core/worktree-snapshot/fork-blob-guard.js.map +1 -0
- package/dist/core/worktree-snapshot/fork-snapshot-index.js +208 -50
- package/dist/core/worktree-snapshot/fork-snapshot-index.js.map +1 -1
- package/dist/core/worktree-snapshot/session-index-reset.code.js +4 -0
- package/dist/core/worktree-snapshot/session-index-reset.code.js.map +1 -1
- package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
- package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
- package/dist/extensions/codemode/execute.code.js +1 -1
- package/dist/extensions/codemode/execute.impl.js +3 -3
- package/dist/extensions/codemode/execute.js +3 -3
- package/dist/extensions/codemode/renderer.code.js +2 -2
- package/dist/extensions/codemode/renderer.impl.js +3 -3
- package/dist/extensions/codemode/renderer.js +3 -3
- package/dist/extensions/mcp/cli.code.js +3 -3
- package/dist/extensions/mcp/cli.impl.js +3 -3
- package/dist/extensions/mcp/cli.js +3 -3
- package/dist/extensions/mcp/cli.lazy.code.js +2 -2
- package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
- package/dist/extensions/mcp/cli.lazy.js +3 -3
- package/dist/extensions/mcp/runtime.code.js +1 -1
- package/dist/extensions/mcp/runtime.impl.js +3 -3
- package/dist/extensions/mcp/runtime.js +3 -3
- package/dist/index.d.ts +3 -1
- package/dist/index.js +5 -5
- package/dist/main-first-time-setup.code.js +1 -1
- package/dist/main-first-time-setup.impl.js +3 -3
- package/dist/main-first-time-setup.js +3 -3
- package/dist/main.js +1 -1
- package/dist/modes/interactive/components/stored-tree-view.code.js +2 -2
- package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
- package/dist/modes/interactive/components/stored-tree-view.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
- package/dist/modes/interactive/startup-shell-eligibility.js +1 -1
- package/dist/modes/interactive-engine/engine-prewarm.d.ts +1 -1
- package/dist/modes/print-mode.js +1 -1
- package/dist/package-manager-cli.code.js +6 -6
- package/dist/package-manager-cli.impl.js +3 -3
- package/dist/package-manager-cli.js +3 -3
- package/dist/rpc-entry.js +1 -1
- package/dist/startup-files.json +1 -1
- package/dist/startup-stages/10.js +1 -1
- package/dist/startup-stages/11.js +1 -1
- package/dist/startup-stages/12.js +1 -1
- package/dist/startup-stages/2.js +2 -4
- package/dist/startup-stages/3.js +1 -3
- package/dist/startup-stages/4.js +1 -2
- package/dist/startup-stages/5.js +1 -1
- package/dist/startup-stages/6.js +5 -7
- package/dist/startup-stages/7.js +3 -10
- package/dist/startup-stages/8.js +7 -2
- package/dist/startup-stages/9.js +1 -7
- package/dist/startup-stages/stages.json +1 -1
- package/dist/utils/compile-cache-deferral.js +8 -13
- package/dist/utils/compile-cache-deferral.js.map +1 -1
- package/dist/utils/compile-cache-warmup-host.js +3 -4
- package/dist/utils/compile-cache-warmup-host.js.map +1 -1
- package/dist/utils/compile-cache.js +12 -100
- package/dist/utils/compile-cache.js.map +1 -1
- package/dist/utils/startup-database-spare.code.js +2 -2
- package/dist/utils/startup-database-spare.impl.js +3 -3
- package/dist/utils/startup-database-spare.js +3 -3
- package/dist/utils/tools-manager.code.js +1 -1
- package/dist/utils/tools-manager.impl.js +3 -3
- package/dist/utils/tools-manager.js +3 -3
- package/dist/utils/worker-threads.js +2 -15
- package/dist/utils/worker-threads.js.map +1 -1
- package/docs/build.md +3 -3
- package/docs/changelog.mdx +1470 -69
- package/docs/compaction/reference.md +5 -5
- package/docs/compaction.md +7 -9
- package/docs/containerization.md +2 -2
- package/docs/custom-provider/api-reference.md +1 -1
- package/docs/docs.json +37 -10
- package/docs/environment-variables.md +0 -2
- package/docs/extensions/api-reference.md +4 -4
- package/docs/getting-started/installation.md +3 -0
- package/docs/guides/configuration.md +1 -1
- package/docs/guides/non-interactive.md +1 -1
- package/docs/guides/resume-on-any-machine.md +14 -22
- package/docs/guides/team-setup.md +56 -83
- package/docs/guides.md +2 -4
- package/docs/herdr.md +1 -1
- package/docs/index.md +1 -1
- package/docs/intercom/operations.md +26 -21
- package/docs/intercom/reference.md +2 -2
- package/docs/intercom.md +1 -1
- package/docs/libraries/storage-postgres.md +9 -9
- package/docs/libraries.md +2 -3
- package/docs/models-configuration.md +2 -2
- package/docs/models.md +2 -3
- package/docs/packages/authoring.md +7 -7
- package/docs/packages.md +1 -1
- package/docs/programmatic.md +2 -2
- package/docs/quickstart.md +1 -1
- package/docs/reference/cli.md +6 -11
- package/docs/reference.md +2 -2
- package/docs/rpc/extension-ui.md +2 -2
- package/docs/sdk/reference.md +5 -4
- package/docs/sdk/storage.md +8 -92
- package/docs/sdk/structured-decisions.md +1 -1
- package/docs/sdk/web-server.md +3 -3
- package/docs/sdk.md +14 -4
- package/docs/security.md +1 -1
- package/docs/session-format.md +5 -5
- package/docs/sessions.md +29 -49
- package/docs/settings.md +7 -8
- package/docs/storage/custom-adapters.md +255 -0
- package/docs/storage/jsonl.md +117 -0
- package/docs/{guides/postgres-pgbouncer.md → storage/postgres/pgbouncer.md} +66 -68
- package/docs/storage/postgres/tuning.md +337 -0
- package/docs/storage/postgres.md +556 -0
- package/docs/storage/sqlite.md +99 -0
- package/docs/storage.md +326 -990
- package/docs/subagents/authoring.md +1 -1
- package/docs/subagents.md +2 -2
- package/docs/tools.md +1 -1
- package/docs/worktree-snapshots.md +2 -2
- package/package.json +9 -9
- package/schemas/models.schema.json +2 -2
- package/schemas/settings.schema.json +0 -14
- package/dist/_shared/p1b-elig-ENCUPKKJ.js.map +0 -1
- package/dist/_shared/sdk-IQMULKFU.js.map +0 -1
- package/dist/_shared/startup-0-0-3IXNMFM2.js.map +0 -1
- package/dist/_shared/startup-0-1-7T2IAE7J.js.map +0 -1
- package/dist/_shared/startup-8-1-X32CYSXB.js.map +0 -1
- package/dist/core/intercom-broker-control.d.ts +0 -129
- package/dist/startup-stages/13.js +0 -1
- package/docs/guides/postgres-tuning.md +0 -311
- package/docs/libraries/storage-libsql.md +0 -97
|
@@ -1,8 +1,8 @@
|
|
|
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, 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,
|
|
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-XJJDOIEC.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, reportDebugAsync, serializeErrorCause } from "./p1b-elig-
|
|
5
|
+
import { failureDebugFields, findInCauseChain, hasErrorIdentity, reportDebugAsync, serializeErrorCause } from "./p1b-elig-TVB5CBLL.js";
|
|
6
6
|
import { windowsPowerShellEnvironment } from "./p1-elig-shell-WWRO3L2R.js";
|
|
7
7
|
import { parseSerializedDecisionError } from "./settings-startup-HXQLSUWM.js";
|
|
8
8
|
import { SETTINGS_DEFAULTS } from "./p2-common-YLSYXMDQ.js";
|
|
@@ -22,7 +22,7 @@ import { Container, Input, Key, Markdown, Spacer, Text, fuzzyFilter, getCapabili
|
|
|
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
|
-
import { chmod as chmod$1, lstat as lstat$1, mkdir as mkdir$
|
|
25
|
+
import { chmod as chmod$1, lstat as lstat$1, mkdir as mkdir$2, mkdtemp as mkdtemp$1, open as open$2, 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$2, writeFile as writeFile$1 } from "fs/promises";
|
|
26
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";
|
|
@@ -36,9 +36,12 @@ 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, transactionFinisher } from "../core/storage/added-exports.js";
|
|
39
40
|
import { dialectOf } from "../core/storage/dialect.js";
|
|
40
|
-
import
|
|
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";
|
|
44
|
+
import { queueSqliteSchemaSetup } from "../core/storage/sqlite-open-batch.js";
|
|
42
45
|
import { sequenceRunner } from "../core/storage/statement-sequence.js";
|
|
43
46
|
import { TextDecoder as TextDecoder$1 } from "util";
|
|
44
47
|
import { ModelThinkingLevelSchema } from "@bastani/atomic-ai/providers/model-schema";
|
|
@@ -276,7 +279,7 @@ ${chalk.bold("Commands:")}
|
|
|
276
279
|
${APP_NAME} auth <command> Log in or out, print credentials, or check provider readiness
|
|
277
280
|
${APP_NAME} mcp <command> Configure MCP servers, check connections, and sign in
|
|
278
281
|
${APP_NAME} storage <command> Show storage selections and connectivity, or join a shared database
|
|
279
|
-
${APP_NAME} team <command>
|
|
282
|
+
${APP_NAME} team <command> Show the storage layout in effect (individual, team, ci or custom)
|
|
280
283
|
${APP_NAME} intercom <command> Show or restart this machine's Intercom broker
|
|
281
284
|
${APP_NAME} blueprint cache-key Print cache keys and paths for a runner's cache action (actions/cache)
|
|
282
285
|
${APP_NAME} blueprint prebuild Prebuild a repository into an idle worktree for later resume
|
|
@@ -464,11 +467,6 @@ ${chalk.bold("Environment Variables:")}
|
|
|
464
467
|
PI_* aliases are also supported for app-specific variables above.
|
|
465
468
|
ATOMIC_STORAGE - Shared storage selection JSON for sessions and Intercom (overridden by --storage)
|
|
466
469
|
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
470
|
|
|
473
471
|
${chalk.bold("Built-in Tool Names:")}
|
|
474
472
|
${formatBuiltinToolHelpLines()}
|
|
@@ -1014,14 +1012,14 @@ async function downloadTool(tool) {
|
|
|
1014
1012
|
if (!target) throw new Error(`Unsupported platform: ${plat}/${architecture}`);
|
|
1015
1013
|
const version = tool === "fd" && plat === "darwin" && architecture === "x64" ? "10.3.0" : await getLatestVersion(tool);
|
|
1016
1014
|
const assetName = config.getAssetName(version, target);
|
|
1017
|
-
await mkdir$
|
|
1015
|
+
await mkdir$2(TOOLS_DIR, { recursive: true });
|
|
1018
1016
|
const downloadUrl = `https://github.com/${config.repo}/releases/download/${config.tagPrefix}${version}/${assetName}`;
|
|
1019
1017
|
const archivePath = join(TOOLS_DIR, assetName);
|
|
1020
1018
|
const binaryExt = plat === "win32" ? ".exe" : "";
|
|
1021
1019
|
const binaryPath = join(TOOLS_DIR, config.binaryName + binaryExt);
|
|
1022
1020
|
await downloadFile(tool, downloadUrl, archivePath);
|
|
1023
1021
|
const extractDir = join(TOOLS_DIR, `extract_tmp_${config.binaryName}_${process.pid}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`);
|
|
1024
|
-
await mkdir$
|
|
1022
|
+
await mkdir$2(extractDir, { recursive: true });
|
|
1025
1023
|
try {
|
|
1026
1024
|
if (assetName.endsWith(".tar.gz")) await extractTarGzArchive(archivePath, extractDir, assetName);
|
|
1027
1025
|
else if (assetName.endsWith(".zip")) await extractZipArchive(archivePath, extractDir, assetName);
|
|
@@ -2231,8 +2229,8 @@ async function takeOverStaleLock(lockPath, stale) {
|
|
|
2231
2229
|
if (!await moveLock(lockPath, trash)) return;
|
|
2232
2230
|
const moved = await lockIdentity(trash);
|
|
2233
2231
|
if (moved !== void 0 && moved.id !== stale) try {
|
|
2234
|
-
await mkdir$
|
|
2235
|
-
await retryTransient(() => utimes$
|
|
2232
|
+
await mkdir$2(lockPath);
|
|
2233
|
+
await retryTransient(() => utimes$2(lockPath, moved.mtime, moved.mtime));
|
|
2236
2234
|
} catch (error) {
|
|
2237
2235
|
if (errnoCode(error) !== "EEXIST" && errnoCode(error) !== "ENOENT" && !isTransientLockError(error)) throw error;
|
|
2238
2236
|
}
|
|
@@ -2530,7 +2528,7 @@ async function publishGitDistribution(stagedRoot, target, layout) {
|
|
|
2530
2528
|
const name = randomUUID$1();
|
|
2531
2529
|
const release = currentGitLayout(join(gitReleasesDir(), name));
|
|
2532
2530
|
try {
|
|
2533
|
-
await mkdir$
|
|
2531
|
+
await mkdir$2(gitReleasesDir(), { recursive: true });
|
|
2534
2532
|
await rename$1(stagedRoot, release.root);
|
|
2535
2533
|
} catch (error) {
|
|
2536
2534
|
throw await installFailedAsync("promote", target, layout, error);
|
|
@@ -2546,7 +2544,7 @@ async function installGitDistribution(target, system, signal, emit) {
|
|
|
2546
2544
|
const layout = currentGitLayout();
|
|
2547
2545
|
const binDir = dirname(layout.root);
|
|
2548
2546
|
try {
|
|
2549
|
-
await mkdir$
|
|
2547
|
+
await mkdir$2(binDir, { recursive: true });
|
|
2550
2548
|
} catch (error) {
|
|
2551
2549
|
throw await installFailedAsync("stage", target, layout, error);
|
|
2552
2550
|
}
|
|
@@ -2624,7 +2622,7 @@ async function installUnderLock(target, layout, system, signal, emit) {
|
|
|
2624
2622
|
const stagedRoot = join(staging, "git");
|
|
2625
2623
|
try {
|
|
2626
2624
|
await writeFile$1(archivePath, archive);
|
|
2627
|
-
await mkdir$
|
|
2625
|
+
await mkdir$2(stagedRoot);
|
|
2628
2626
|
} catch (error) {
|
|
2629
2627
|
throw await installFailedAsync("stage", target, layout, error);
|
|
2630
2628
|
}
|
|
@@ -4483,15 +4481,10 @@ const LOCAL_ONLY_STORAGE = /* @__PURE__ */ new Set([
|
|
|
4483
4481
|
function isLocalOnlySessionStorage(adapter) {
|
|
4484
4482
|
return LOCAL_ONLY_STORAGE.has(adapter);
|
|
4485
4483
|
}
|
|
4486
|
-
/** The command that joins this node to shared storage, named in hints when a lookup misses on local-only storage. */
|
|
4487
|
-
const TEAM_JOIN_COMMAND = "atomic team join <url> --token-file <path>";
|
|
4488
4484
|
/** The command that points this node's storage at a shared database, keeping the rest of its layout. */
|
|
4489
|
-
const STORAGE_JOIN_COMMAND = "atomic storage join <url> --
|
|
4490
|
-
/**
|
|
4491
|
-
|
|
4492
|
-
* `atomic team join` keeps sessions on each machine, so a machine joined that way leaves the team first.
|
|
4493
|
-
*/
|
|
4494
|
-
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)`;
|
|
4485
|
+
const STORAGE_JOIN_COMMAND = "atomic storage join <postgres-url> --password-file <path>";
|
|
4486
|
+
/** How a node puts its sessions in shared storage, named in hints when a session lookup misses on local-only storage. */
|
|
4487
|
+
const SESSION_STORAGE_JOIN = `\`${STORAGE_JOIN_COMMAND}\``;
|
|
4495
4488
|
/** How deep cause chains are serialized and walked. */
|
|
4496
4489
|
const MAX_CAUSE_DEPTH$1 = 8;
|
|
4497
4490
|
const AGENT_REHYDRATE_ERROR_NAME = "AgentRehydrateError";
|
|
@@ -8241,6 +8234,8 @@ async function execCommand(command, args, cwd, options, onQuit) {
|
|
|
8241
8234
|
truncated: false
|
|
8242
8235
|
};
|
|
8243
8236
|
}
|
|
8237
|
+
const endsWithHost = onQuit !== void 0;
|
|
8238
|
+
const guardianEndsIt = endsWithHost && canWatchProcessUntilHostDies();
|
|
8244
8239
|
const proc = spawnHostProcess(launch.file, argv, {
|
|
8245
8240
|
cwd,
|
|
8246
8241
|
env,
|
|
@@ -8249,9 +8244,11 @@ async function execCommand(command, args, cwd, options, onQuit) {
|
|
|
8249
8244
|
"pipe",
|
|
8250
8245
|
"pipe"
|
|
8251
8246
|
],
|
|
8252
|
-
endWithParent:
|
|
8247
|
+
endWithParent: endsWithHost && !guardianEndsIt,
|
|
8253
8248
|
...missingHelperOptions(launch)
|
|
8254
8249
|
});
|
|
8250
|
+
const hostDeathWatch = guardianEndsIt && proc.pid !== void 0 ? watchProcessUntilHostDies(proc.pid) : void 0;
|
|
8251
|
+
if (hostDeathWatch !== void 0) proc.once("exit", () => hostDeathWatch.release());
|
|
8255
8252
|
if (onQuit !== void 0 && proc.pid !== void 0) quitStoppableCommands.add(proc);
|
|
8256
8253
|
let stdout = "";
|
|
8257
8254
|
let stderr = "";
|
|
@@ -8360,6 +8357,7 @@ async function execCommand(command, args, cwd, options, onQuit) {
|
|
|
8360
8357
|
if (!killed && isChildProcessExitStatusUnknownError(error)) stderr = stderr ? `${stderr}\n${error.message}` : error.message;
|
|
8361
8358
|
else if (!stderr) stderr = error.message;
|
|
8362
8359
|
} finally {
|
|
8360
|
+
hostDeathWatch?.release();
|
|
8363
8361
|
clearTimeout(timeoutId);
|
|
8364
8362
|
options?.signal?.removeEventListener("abort", abort);
|
|
8365
8363
|
stopOnQuit?.();
|
|
@@ -9558,9 +9556,24 @@ async function create(path, header) {
|
|
|
9558
9556
|
throw e;
|
|
9559
9557
|
}
|
|
9560
9558
|
}
|
|
9561
|
-
/**
|
|
9559
|
+
/**
|
|
9560
|
+
* Device, a known inode, a recorded creation time and the header: an unknown inode or creation time proves no owner.
|
|
9561
|
+
* Where creation times move (APFS and HFS+, which never reuse an inode number) the epoch has none; see
|
|
9562
|
+
* `creation-time.ts`.
|
|
9563
|
+
*/
|
|
9562
9564
|
function hasStableFileOwner(epoch) {
|
|
9563
|
-
return /^\d+:[1-9]\d*:[1-9]\d*:[\da-f]{16}$/.test(epoch);
|
|
9565
|
+
return /^\d+:[1-9]\d*:(?:[1-9]\d*:)?[\da-f]{16}$/.test(epoch);
|
|
9566
|
+
}
|
|
9567
|
+
/**
|
|
9568
|
+
* The epoch an older build gave the owner's file on macOS, with its creation time in it, which the diagnostics it
|
|
9569
|
+
* saved are kept under: only while the file is still the one `owner.epoch` names, and has a creation time.
|
|
9570
|
+
*/
|
|
9571
|
+
async function olderEpoch(owner) {
|
|
9572
|
+
const current = /^(\d+:[1-9]\d*):([\da-f]{16})$/.exec(owner.epoch);
|
|
9573
|
+
if (!current || !owner.file) return void 0;
|
|
9574
|
+
const stats = await stat(owner.file, { bigint: true }).catch(() => void 0);
|
|
9575
|
+
if (!stats || stats.birthtimeNs <= 0n || `${stats.dev}:${stats.ino}` !== current[1]) return void 0;
|
|
9576
|
+
return `${current[1]}:${stats.birthtimeNs}:${current[2]}`;
|
|
9564
9577
|
}
|
|
9565
9578
|
async function discoverChatFile(file, id) {
|
|
9566
9579
|
const { path } = files({
|
|
@@ -9573,35 +9586,81 @@ async function discoverChatFile(file, id) {
|
|
|
9573
9586
|
async function hasFileChatRecords(owner) {
|
|
9574
9587
|
return !!owner.file && hasStableFileOwner(owner.epoch) && discoverChatFile(owner.file, owner.id);
|
|
9575
9588
|
}
|
|
9576
|
-
|
|
9577
|
-
|
|
9578
|
-
|
|
9579
|
-
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
9585
|
-
|
|
9589
|
+
const CHAT_OPEN_BATCH = 32;
|
|
9590
|
+
async function appendFileChatRecords(owner, entries) {
|
|
9591
|
+
if (!entries.length || !hasStableFileOwner(owner.epoch)) return;
|
|
9592
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
9593
|
+
const add = (slot, line) => {
|
|
9594
|
+
let lines = grouped.get(slot);
|
|
9595
|
+
if (!lines) {
|
|
9596
|
+
lines = [];
|
|
9597
|
+
grouped.set(slot, lines);
|
|
9598
|
+
}
|
|
9599
|
+
lines.push(line);
|
|
9600
|
+
};
|
|
9601
|
+
for (const { anchor, record } of entries) {
|
|
9602
|
+
add(slotFor(owner, anchor), JSON.stringify({
|
|
9603
|
+
v: 1,
|
|
9604
|
+
...record
|
|
9605
|
+
}));
|
|
9606
|
+
if (record.kind === "promptBefore") add(orderSlot(owner), encodeChatOrder({
|
|
9607
|
+
anchor,
|
|
9608
|
+
promptId: record.promptId
|
|
9609
|
+
}));
|
|
9610
|
+
}
|
|
9611
|
+
await appendSlots(owner, grouped);
|
|
9586
9612
|
}
|
|
9587
|
-
async function
|
|
9613
|
+
async function appendSlots(owner, grouped) {
|
|
9588
9614
|
const { path, header } = files(owner);
|
|
9589
|
-
const
|
|
9615
|
+
const headerPrefix = header.trimEnd();
|
|
9616
|
+
const slots = [...grouped.keys()];
|
|
9617
|
+
let index;
|
|
9590
9618
|
try {
|
|
9591
|
-
|
|
9592
|
-
|
|
9593
|
-
|
|
9594
|
-
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
|
|
9619
|
+
for (let at = 0; at < slots.length; at += CHAT_OPEN_BATCH) {
|
|
9620
|
+
const batch = slots.slice(at, at + CHAT_OPEN_BATCH);
|
|
9621
|
+
const handles = /* @__PURE__ */ new Map();
|
|
9622
|
+
try {
|
|
9623
|
+
const openIndex = index === void 0;
|
|
9624
|
+
const results = await Promise.allSettled([...openIndex ? [owned(path, header, true)] : [], ...batch.map((slot) => owned(`${path}.${slot}`, `${headerPrefix} ${slot}\n`, true))]);
|
|
9625
|
+
let firstError;
|
|
9626
|
+
let hasError = false;
|
|
9627
|
+
const slotResults = openIndex ? results.slice(1) : results;
|
|
9628
|
+
if (openIndex) {
|
|
9629
|
+
const indexResult = results[0];
|
|
9630
|
+
if (indexResult.status === "fulfilled") index = indexResult.value;
|
|
9631
|
+
else {
|
|
9632
|
+
firstError = indexResult.reason;
|
|
9633
|
+
hasError = true;
|
|
9634
|
+
}
|
|
9635
|
+
}
|
|
9636
|
+
for (const [i, result] of slotResults.entries()) if (result.status === "fulfilled") {
|
|
9637
|
+
if (result.value) handles.set(batch[i], result.value);
|
|
9638
|
+
} else if (!hasError) {
|
|
9639
|
+
firstError = result.reason;
|
|
9640
|
+
hasError = true;
|
|
9641
|
+
}
|
|
9642
|
+
if (hasError) throw firstError;
|
|
9643
|
+
index ??= await create(path, header);
|
|
9644
|
+
const missing = batch.filter((slot) => !handles.has(slot));
|
|
9645
|
+
if (missing.length > 0) {
|
|
9646
|
+
await index.appendFile(`\n${missing.join("\n")}\n`);
|
|
9647
|
+
const created = await Promise.allSettled(missing.map((slot) => create(`${path}.${slot}`, `${headerPrefix} ${slot}\n`)));
|
|
9648
|
+
let createError;
|
|
9649
|
+
let hasCreateError = false;
|
|
9650
|
+
for (const [i, result] of created.entries()) if (result.status === "fulfilled") handles.set(missing[i], result.value);
|
|
9651
|
+
else if (!hasCreateError) {
|
|
9652
|
+
createError = result.reason;
|
|
9653
|
+
hasCreateError = true;
|
|
9654
|
+
}
|
|
9655
|
+
if (hasCreateError) throw createError;
|
|
9656
|
+
}
|
|
9657
|
+
await Promise.all(batch.map((slot) => handles.get(slot).appendFile(`\n${grouped.get(slot).join("\n")}\n`)));
|
|
9658
|
+
} finally {
|
|
9659
|
+
await Promise.all([...handles.values()].map((handle) => handle.close().catch(() => void 0)));
|
|
9660
|
+
}
|
|
9602
9661
|
}
|
|
9603
9662
|
} finally {
|
|
9604
|
-
await index
|
|
9663
|
+
await index?.close().catch(() => void 0);
|
|
9605
9664
|
}
|
|
9606
9665
|
}
|
|
9607
9666
|
async function readSlot(owner, slot) {
|
|
@@ -9616,20 +9675,48 @@ async function readSlot(owner, slot) {
|
|
|
9616
9675
|
}
|
|
9617
9676
|
}
|
|
9618
9677
|
async function readFileChatRecords(owner, anchors) {
|
|
9619
|
-
if (!hasStableFileOwner(owner.epoch)) return [];
|
|
9678
|
+
if (!anchors.length || !hasStableFileOwner(owner.epoch)) return [];
|
|
9679
|
+
const older = await olderEpoch(owner);
|
|
9680
|
+
const owners = older === void 0 ? [owner] : [{
|
|
9681
|
+
...owner,
|
|
9682
|
+
epoch: older
|
|
9683
|
+
}, owner];
|
|
9684
|
+
const tasks = [];
|
|
9685
|
+
for (const anchor of anchors) for (const each of owners) tasks.push({
|
|
9686
|
+
anchor,
|
|
9687
|
+
owner: each,
|
|
9688
|
+
slot: slotFor(each, anchor)
|
|
9689
|
+
});
|
|
9620
9690
|
const result = [];
|
|
9621
|
-
for (
|
|
9622
|
-
const
|
|
9623
|
-
|
|
9624
|
-
|
|
9625
|
-
|
|
9626
|
-
|
|
9691
|
+
for (let at = 0; at < tasks.length; at += CHAT_OPEN_BATCH) {
|
|
9692
|
+
const batch = tasks.slice(at, at + CHAT_OPEN_BATCH);
|
|
9693
|
+
const read = await Promise.all(batch.map((task) => readSlot(task.owner, task.slot)));
|
|
9694
|
+
for (const [i, lines] of read.entries()) {
|
|
9695
|
+
const anchor = batch[i].anchor;
|
|
9696
|
+
for (const line of lines) {
|
|
9697
|
+
const record = decodeChatRecord(line);
|
|
9698
|
+
if (record) result.push({
|
|
9699
|
+
anchor,
|
|
9700
|
+
record
|
|
9701
|
+
});
|
|
9702
|
+
}
|
|
9703
|
+
}
|
|
9627
9704
|
}
|
|
9628
9705
|
return result;
|
|
9629
9706
|
}
|
|
9630
9707
|
async function readFileChatOrders(owner, promptIds) {
|
|
9631
9708
|
if (!promptIds.length || !owner.file || !hasStableFileOwner(owner.epoch)) return [];
|
|
9632
|
-
const
|
|
9709
|
+
const older = await olderEpoch(owner);
|
|
9710
|
+
const owners = older === void 0 ? [owner] : [{
|
|
9711
|
+
...owner,
|
|
9712
|
+
epoch: older
|
|
9713
|
+
}, owner];
|
|
9714
|
+
const read = await Promise.all(owners.map((each) => readSlot(each, orderSlot(each))));
|
|
9715
|
+
const orders = [];
|
|
9716
|
+
for (const lines of read) for (const line of lines) {
|
|
9717
|
+
const order = decodeChatOrder(line);
|
|
9718
|
+
if (order) orders.push(order);
|
|
9719
|
+
}
|
|
9633
9720
|
return firstChatOrders(orders, promptIds);
|
|
9634
9721
|
}
|
|
9635
9722
|
async function deleteFileChatRecords(owner) {
|
|
@@ -9642,13 +9729,17 @@ async function deleteFileChatRecords(owner) {
|
|
|
9642
9729
|
} finally {
|
|
9643
9730
|
await index.close();
|
|
9644
9731
|
}
|
|
9645
|
-
|
|
9646
|
-
|
|
9647
|
-
|
|
9648
|
-
const
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9732
|
+
const unique = [...new Set(slots)].filter((slot) => /^[0-9a-f]{64}$/.test(slot));
|
|
9733
|
+
const headerPrefix = header.trimEnd();
|
|
9734
|
+
for (let at = 0; at < unique.length; at += CHAT_OPEN_BATCH) {
|
|
9735
|
+
const batch = unique.slice(at, at + CHAT_OPEN_BATCH);
|
|
9736
|
+
await Promise.all(batch.map(async (slot) => {
|
|
9737
|
+
const name = `${path}.${slot}`;
|
|
9738
|
+
const data = await owned(name, `${headerPrefix} ${slot}\n`);
|
|
9739
|
+
if (!data) return;
|
|
9740
|
+
await data.close();
|
|
9741
|
+
await unlink(name);
|
|
9742
|
+
}));
|
|
9652
9743
|
}
|
|
9653
9744
|
await unlink(path);
|
|
9654
9745
|
}
|
|
@@ -12337,6 +12428,11 @@ var HistorySearchPositions = class {
|
|
|
12337
12428
|
}
|
|
12338
12429
|
};
|
|
12339
12430
|
// dist/core/storage/session/session-search-index.js
|
|
12431
|
+
/**
|
|
12432
|
+
* `ensureStorageSchemaOnce` of `migrations.ts`, which the copies earlier releases loaded lack: taken from the module
|
|
12433
|
+
* namespace, so this module links against them too. Without it the tuning runs in a transaction of its own, as before.
|
|
12434
|
+
*/
|
|
12435
|
+
const setupOnce = migrations;
|
|
12340
12436
|
const SESSION_SEARCH_DOMAIN = "session-search";
|
|
12341
12437
|
const SESSION_SEARCH_TABLES = Object.freeze({
|
|
12342
12438
|
state: "search_state",
|
|
@@ -12345,6 +12441,19 @@ const SESSION_SEARCH_TABLES = Object.freeze({
|
|
|
12345
12441
|
trigrams: "search_trgm",
|
|
12346
12442
|
entriesForget: "entries_search_forget"
|
|
12347
12443
|
});
|
|
12444
|
+
/**
|
|
12445
|
+
* The ledger step, `schema:session-search-tuning`, that gives an existing PostgreSQL trigram index the pending-list
|
|
12446
|
+
* limit below and its entries table the autovacuum settings below.
|
|
12447
|
+
*/
|
|
12448
|
+
const SESSION_SEARCH_TUNING_DOMAIN = "session-search-tuning";
|
|
12449
|
+
const SESSION_SEARCH_TUNING_REVISION = 1;
|
|
12450
|
+
/**
|
|
12451
|
+
* The PostgreSQL trigram index's `gin_pending_list_limit`, in kB: 64 MB rather than the server's default 4 MB. An insert
|
|
12452
|
+
* that finds the pending list over this limit merges the whole list into the index itself, inside its transaction and
|
|
12453
|
+
* the session's lock; the background merge (`SEARCH_PENDING_MERGE_CHARS`) and autovacuum keep the list far below it.
|
|
12454
|
+
*/
|
|
12455
|
+
const SEARCH_PENDING_LIST_LIMIT_KB = 65536;
|
|
12456
|
+
const SEARCH_ENTRIES_AUTOVACUUM = `autovacuum_vacuum_insert_threshold = 1000, autovacuum_vacuum_insert_scale_factor = 0`;
|
|
12348
12457
|
const SEARCH_PART_CHARS = 4096;
|
|
12349
12458
|
const MAX_INDEXED_ENTRY_CHARS = 8388608;
|
|
12350
12459
|
const PART_BITS = 14;
|
|
@@ -12552,32 +12661,69 @@ const sqliteFts = {
|
|
|
12552
12661
|
signal?.throwIfAborted();
|
|
12553
12662
|
return repeated === MERGE_STEPS_PER_WRITE;
|
|
12554
12663
|
},
|
|
12555
|
-
|
|
12556
|
-
|
|
12664
|
+
forgetStatement(tables, sessionId) {
|
|
12665
|
+
return {
|
|
12666
|
+
sql: `DELETE FROM ${tables.fts} WHERE rowid BETWEEN (SELECT sid << 40 FROM ${tables.state} WHERE session_id = ?) AND (SELECT (sid << 40) + 1099511627775 FROM ${tables.state} WHERE session_id = ?)`,
|
|
12667
|
+
params: [sessionId, sessionId]
|
|
12668
|
+
};
|
|
12557
12669
|
},
|
|
12558
|
-
|
|
12670
|
+
firstCandidatesWindow(tables, sessionId, sets, fromSeq, cappedTo, limit) {
|
|
12671
|
+
if (sets.every((all) => all.length === 1)) {
|
|
12672
|
+
const query = sets.map((all) => `(${ftsLiteral(all[0])})`).join(" OR ");
|
|
12673
|
+
return {
|
|
12674
|
+
sql: `SELECT (rowid >> ${PART_BITS}) & ${SEQ_MASK} AS seq FROM ${tables.fts} WHERE ${tables.fts} MATCH ? AND rowid BETWEEN (SELECT (sid << 40) + (? << ${PART_BITS}) FROM ${tables.state} WHERE session_id = ?) AND (SELECT (sid << 40) + (min(?, indexed_seq) << ${PART_BITS}) + ${PART_MASK} FROM ${tables.state} WHERE session_id = ?) ORDER BY rowid LIMIT ?`,
|
|
12675
|
+
params: [
|
|
12676
|
+
query,
|
|
12677
|
+
fromSeq,
|
|
12678
|
+
sessionId,
|
|
12679
|
+
cappedTo,
|
|
12680
|
+
sessionId,
|
|
12681
|
+
CANDIDATE_ROWS
|
|
12682
|
+
]
|
|
12683
|
+
};
|
|
12684
|
+
}
|
|
12685
|
+
const firstWinCap = Math.min(cappedTo, fromSeq + SEQ_WINDOW - 1);
|
|
12686
|
+
const arms = [];
|
|
12687
|
+
const params = [];
|
|
12688
|
+
for (const [setIndex, all] of sets.entries()) for (const [litIndex, literal] of all.entries()) {
|
|
12689
|
+
arms.push(`SELECT (rowid >> ${PART_BITS}) & ${SEQ_MASK} AS seq, ${setIndex} AS set_id, ${litIndex} AS lit_id, ${all.length} AS need FROM ${tables.fts} WHERE ${tables.fts} MATCH ? AND rowid BETWEEN (SELECT (sid << 40) + (? << ${PART_BITS}) FROM ${tables.state} WHERE session_id = ?) AND (SELECT (sid << 40) + (min(?, indexed_seq) << ${PART_BITS}) + ${PART_MASK} FROM ${tables.state} WHERE session_id = ?)`);
|
|
12690
|
+
params.push(ftsLiteral(literal), fromSeq, sessionId, firstWinCap, sessionId);
|
|
12691
|
+
}
|
|
12692
|
+
return {
|
|
12693
|
+
sql: `SELECT DISTINCT seq FROM (
|
|
12694
|
+
SELECT seq, set_id FROM (${arms.join(" UNION ALL ")})
|
|
12695
|
+
GROUP BY seq, set_id HAVING count(DISTINCT lit_id) = max(need)
|
|
12696
|
+
) ORDER BY seq LIMIT ?`,
|
|
12697
|
+
params: [...params, limit]
|
|
12698
|
+
};
|
|
12699
|
+
},
|
|
12700
|
+
async candidatesFromFirstWindow(database, tables, sid, sets, fromSeq, through, limit, firstRows, signal) {
|
|
12559
12701
|
signal?.throwIfAborted();
|
|
12560
|
-
const sets = normalizeSets(anyOf);
|
|
12561
|
-
if (sets.length === 0) return [];
|
|
12562
12702
|
const seqs = [];
|
|
12703
|
+
for (const row of firstRows) {
|
|
12704
|
+
const seq = Number(row.seq);
|
|
12705
|
+
if (seqs.at(-1) !== seq && seqs.length < limit) seqs.push(seq);
|
|
12706
|
+
}
|
|
12563
12707
|
if (sets.every((all) => all.length === 1)) {
|
|
12708
|
+
if (firstRows.length < CANDIDATE_ROWS || seqs.length >= limit) return seqs;
|
|
12564
12709
|
const query = sets.map((all) => `(${ftsLiteral(all[0])})`).join(" OR ");
|
|
12565
|
-
for (let from =
|
|
12710
|
+
for (let from = Number(firstRows.at(-1).seq) + 1; from <= through && seqs.length < limit;) {
|
|
12711
|
+
await yieldTurn();
|
|
12566
12712
|
signal?.throwIfAborted();
|
|
12567
|
-
const rows = await database.all(`SELECT (rowid >> ${PART_BITS}) & ${SEQ_MASK} AS seq FROM ${tables.fts} WHERE ${tables.fts} MATCH ? AND rowid BETWEEN (? << 40) + (? << ${PART_BITS}) AND (? << 40) + (? << ${PART_BITS}) + ${PART_MASK} ORDER BY rowid LIMIT ?`, query, sid, from, sid,
|
|
12713
|
+
const rows = await database.all(`SELECT (rowid >> ${PART_BITS}) & ${SEQ_MASK} AS seq FROM ${tables.fts} WHERE ${tables.fts} MATCH ? AND rowid BETWEEN (? << 40) + (? << ${PART_BITS}) AND (? << 40) + (? << ${PART_BITS}) + ${PART_MASK} ORDER BY rowid LIMIT ?`, query, sid, from, sid, through, CANDIDATE_ROWS);
|
|
12568
12714
|
for (const row of rows) {
|
|
12569
12715
|
const seq = Number(row.seq);
|
|
12570
12716
|
if (seqs.at(-1) !== seq && seqs.length < limit) seqs.push(seq);
|
|
12571
12717
|
}
|
|
12572
12718
|
if (rows.length < CANDIDATE_ROWS) break;
|
|
12573
12719
|
from = Number(rows.at(-1).seq) + 1;
|
|
12574
|
-
await yieldTurn();
|
|
12575
12720
|
}
|
|
12576
12721
|
return seqs;
|
|
12577
12722
|
}
|
|
12578
|
-
for (let from = fromSeq; from <=
|
|
12723
|
+
for (let from = fromSeq + SEQ_WINDOW; from <= through && seqs.length < limit; from += SEQ_WINDOW) {
|
|
12724
|
+
await yieldTurn();
|
|
12579
12725
|
signal?.throwIfAborted();
|
|
12580
|
-
const winTo = Math.min(
|
|
12726
|
+
const winTo = Math.min(through, from + SEQ_WINDOW - 1);
|
|
12581
12727
|
const arms = [];
|
|
12582
12728
|
const params = [];
|
|
12583
12729
|
for (const [setIndex, all] of sets.entries()) for (const [litIndex, literal] of all.entries()) {
|
|
@@ -12592,17 +12738,22 @@ const sqliteFts = {
|
|
|
12592
12738
|
const seq = Number(row.seq);
|
|
12593
12739
|
if (seqs.at(-1) !== seq && seqs.length < limit) seqs.push(seq);
|
|
12594
12740
|
}
|
|
12595
|
-
if (winTo < toSeq && seqs.length < limit) await yieldTurn();
|
|
12596
12741
|
}
|
|
12597
12742
|
return seqs;
|
|
12598
12743
|
}
|
|
12599
12744
|
};
|
|
12745
|
+
/**
|
|
12746
|
+
* The search indexes this process found it does not own, by database (`databaseIdentity`, which names the role and
|
|
12747
|
+
* schema too), ledger and index: their tuning is left to `atomic storage migrate`, so later opens do not read the
|
|
12748
|
+
* catalog for it again.
|
|
12749
|
+
*/
|
|
12750
|
+
const unownedSearchIndexes = /* @__PURE__ */ new Set();
|
|
12600
12751
|
async function createTrigramIndex(tx, dialect, tables) {
|
|
12601
12752
|
await tx.exec("SAVEPOINT atomic_session_search_trgm");
|
|
12602
12753
|
try {
|
|
12603
12754
|
await tx.exec("CREATE EXTENSION IF NOT EXISTS pg_trgm");
|
|
12604
12755
|
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'");
|
|
12605
|
-
await tx.exec(`CREATE INDEX IF NOT EXISTS ${tables.trigrams} ON ${tables.entries} USING gin (body ${dialect.identifier(String(found?.schema))}.gin_trgm_ops)`);
|
|
12756
|
+
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})`);
|
|
12606
12757
|
await tx.exec("RELEASE SAVEPOINT atomic_session_search_trgm");
|
|
12607
12758
|
} catch {
|
|
12608
12759
|
await tx.exec("ROLLBACK TO SAVEPOINT atomic_session_search_trgm");
|
|
@@ -12615,7 +12766,7 @@ async function trigramIndexExists(database, dialect, tables) {
|
|
|
12615
12766
|
const postgresTrigrams = {
|
|
12616
12767
|
async create(tx, dialect, tables, sessionTables) {
|
|
12617
12768
|
const { int, text } = dialect.types;
|
|
12618
|
-
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))`);
|
|
12769
|
+
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})`);
|
|
12619
12770
|
await tx.exec(dialect.renderTrigger(forgetTrigger(tables, sessionTables, postgresTrigrams)));
|
|
12620
12771
|
await createTrigramIndex(tx, dialect, tables);
|
|
12621
12772
|
},
|
|
@@ -12639,6 +12790,60 @@ const postgresTrigrams = {
|
|
|
12639
12790
|
async merge() {
|
|
12640
12791
|
return false;
|
|
12641
12792
|
},
|
|
12793
|
+
async tune(database, dialect, tables, ledger) {
|
|
12794
|
+
if (database.readOnly === true) return;
|
|
12795
|
+
const schema = {
|
|
12796
|
+
ledger,
|
|
12797
|
+
domain: SESSION_SEARCH_TUNING_DOMAIN,
|
|
12798
|
+
revision: SESSION_SEARCH_TUNING_REVISION
|
|
12799
|
+
};
|
|
12800
|
+
if (await storageSchemaCurrent(database, schema)) return;
|
|
12801
|
+
const identity = database.databaseIdentity?.();
|
|
12802
|
+
const key = identity === void 0 ? void 0 : JSON.stringify([
|
|
12803
|
+
identity,
|
|
12804
|
+
ledger,
|
|
12805
|
+
tables.trigrams
|
|
12806
|
+
]);
|
|
12807
|
+
if (key !== void 0 && unownedSearchIndexes.has(key)) return;
|
|
12808
|
+
const found = await database.get(`SELECT pg_catalog.pg_has_role(current_user, i.relowner, 'USAGE')
|
|
12809
|
+
AND pg_catalog.pg_has_role(current_user, t.relowner, 'USAGE') AS owned
|
|
12810
|
+
FROM pg_catalog.pg_class i
|
|
12811
|
+
JOIN pg_catalog.pg_index x ON x.indexrelid = i.oid
|
|
12812
|
+
JOIN pg_catalog.pg_class t ON t.oid = x.indrelid
|
|
12813
|
+
WHERE i.relnamespace = current_schema()::regnamespace AND i.relname = ?`, dialect.identifier(tables.trigrams));
|
|
12814
|
+
if (found === void 0) return;
|
|
12815
|
+
if (found.owned !== true && Number(found.owned) !== 1) {
|
|
12816
|
+
if (key !== void 0) unownedSearchIndexes.add(key);
|
|
12817
|
+
return;
|
|
12818
|
+
}
|
|
12819
|
+
const setup = async (tx) => {
|
|
12820
|
+
await tx.exec(`ALTER INDEX ${tables.trigrams} SET (gin_pending_list_limit = ${SEARCH_PENDING_LIST_LIMIT_KB})`);
|
|
12821
|
+
await tx.exec(`ALTER TABLE ${tables.entries} SET (${SEARCH_ENTRIES_AUTOVACUUM})`);
|
|
12822
|
+
};
|
|
12823
|
+
const once = setupOnce.ensureStorageSchemaOnce;
|
|
12824
|
+
if (once !== void 0) await once(database, schema, setup);
|
|
12825
|
+
else await database.transaction((tx) => ensureStorageSchema(tx, dialect, schema, () => setup(tx)), {
|
|
12826
|
+
retryTransientFailures: true,
|
|
12827
|
+
concurrency: {
|
|
12828
|
+
kind: "serial",
|
|
12829
|
+
domain: ledger
|
|
12830
|
+
}
|
|
12831
|
+
});
|
|
12832
|
+
},
|
|
12833
|
+
async mergePending(database, dialect, tables) {
|
|
12834
|
+
const owned = (await database.autocommit?.({
|
|
12835
|
+
sql: `SELECT CASE WHEN pg_catalog.pg_has_role(current_user, c.relowner, 'USAGE')
|
|
12836
|
+
AND pg_catalog.pg_try_advisory_xact_lock(pg_catalog.hashtextextended(current_schema() || '.' || c.relname || ':pending', 0))
|
|
12837
|
+
THEN pg_catalog.gin_clean_pending_list(c.oid) END AS pages,
|
|
12838
|
+
pg_catalog.pg_has_role(current_user, c.relowner, 'USAGE') AS owned
|
|
12839
|
+
FROM pg_catalog.pg_class c WHERE c.relnamespace = current_schema()::regnamespace AND c.relname = ?`,
|
|
12840
|
+
params: [dialect.identifier(tables.trigrams)]
|
|
12841
|
+
}, {
|
|
12842
|
+
kind: "serial",
|
|
12843
|
+
domain: `${tables.trigrams}:pending`
|
|
12844
|
+
}) ?? [])[0]?.owned;
|
|
12845
|
+
return owned === true || Number(owned) === 1;
|
|
12846
|
+
},
|
|
12642
12847
|
async insert(tx, tables, sid, docs, signal) {
|
|
12643
12848
|
for (let start = 0; start < docs.length; start += INSERT_ROWS_PER_STATEMENT) {
|
|
12644
12849
|
signal?.throwIfAborted();
|
|
@@ -12652,34 +12857,75 @@ const postgresTrigrams = {
|
|
|
12652
12857
|
if (start + INSERT_ROWS_PER_STATEMENT < docs.length) await yieldTurn();
|
|
12653
12858
|
}
|
|
12654
12859
|
},
|
|
12655
|
-
|
|
12656
|
-
|
|
12657
|
-
|
|
12860
|
+
forgetStatement(tables, sessionId) {
|
|
12861
|
+
return {
|
|
12862
|
+
sql: `DELETE FROM ${tables.entries} WHERE sid IN (SELECT sid FROM ${tables.state} WHERE session_id = ?)`,
|
|
12863
|
+
params: [sessionId]
|
|
12864
|
+
};
|
|
12658
12865
|
},
|
|
12659
|
-
|
|
12866
|
+
firstCandidatesWindow(tables, sessionId, sets, fromSeq, cappedTo, limit) {
|
|
12867
|
+
const firstWinCap = Math.min(cappedTo, fromSeq + SEQ_WINDOW - 1);
|
|
12868
|
+
if (sets.every((all) => all.length === 1)) {
|
|
12869
|
+
const params = [];
|
|
12870
|
+
const where = sets.map((all) => {
|
|
12871
|
+
const literal = all[0];
|
|
12872
|
+
params.push(likePattern(literal));
|
|
12873
|
+
return `${likeColumn(literal)} LIKE ? ESCAPE '\\'`;
|
|
12874
|
+
}).join(" OR ");
|
|
12875
|
+
return {
|
|
12876
|
+
sql: `SELECT DISTINCT seq FROM ${tables.entries} WHERE sid = (SELECT sid FROM ${tables.state} WHERE session_id = ?) AND seq >= ? AND seq <= (SELECT LEAST(?, indexed_seq) FROM ${tables.state} WHERE session_id = ?) AND (${where}) ORDER BY seq LIMIT ?`,
|
|
12877
|
+
params: [
|
|
12878
|
+
sessionId,
|
|
12879
|
+
fromSeq,
|
|
12880
|
+
firstWinCap,
|
|
12881
|
+
sessionId,
|
|
12882
|
+
...params,
|
|
12883
|
+
limit
|
|
12884
|
+
]
|
|
12885
|
+
};
|
|
12886
|
+
}
|
|
12887
|
+
const arms = [];
|
|
12888
|
+
const params = [];
|
|
12889
|
+
for (const [setIndex, all] of sets.entries()) for (const [litIndex, literal] of all.entries()) {
|
|
12890
|
+
arms.push(`SELECT seq, ${setIndex} AS set_id, ${litIndex} AS lit_id, ${all.length} AS need FROM ${tables.entries} WHERE sid = (SELECT sid FROM ${tables.state} WHERE session_id = ?) AND seq >= ? AND seq <= (SELECT LEAST(?, indexed_seq) FROM ${tables.state} WHERE session_id = ?) AND ${likeColumn(literal)} LIKE ? ESCAPE '\\'`);
|
|
12891
|
+
params.push(sessionId, fromSeq, firstWinCap, sessionId, likePattern(literal));
|
|
12892
|
+
}
|
|
12893
|
+
return {
|
|
12894
|
+
sql: `SELECT DISTINCT seq FROM (
|
|
12895
|
+
SELECT seq, set_id FROM (${arms.join(" UNION ALL ")}) AS hits
|
|
12896
|
+
GROUP BY seq, set_id HAVING count(DISTINCT lit_id) = max(need)
|
|
12897
|
+
) AS matched ORDER BY seq LIMIT ?`,
|
|
12898
|
+
params: [...params, limit]
|
|
12899
|
+
};
|
|
12900
|
+
},
|
|
12901
|
+
async candidatesFromFirstWindow(database, tables, sid, sets, fromSeq, through, limit, firstRows, signal) {
|
|
12660
12902
|
signal?.throwIfAborted();
|
|
12661
|
-
const sets = normalizeSets(anyOf);
|
|
12662
|
-
if (sets.length === 0) return [];
|
|
12663
12903
|
const seqs = [];
|
|
12904
|
+
for (const row of firstRows) {
|
|
12905
|
+
const seq = Number(row.seq);
|
|
12906
|
+
if (seqs.at(-1) !== seq && seqs.length < limit) seqs.push(seq);
|
|
12907
|
+
}
|
|
12664
12908
|
if (sets.every((all) => all.length === 1)) {
|
|
12909
|
+
if (fromSeq + SEQ_WINDOW > through || seqs.length >= limit) return seqs;
|
|
12665
12910
|
const params = [];
|
|
12666
12911
|
const where = sets.map((all) => {
|
|
12667
12912
|
const literal = all[0];
|
|
12668
12913
|
params.push(likePattern(literal));
|
|
12669
12914
|
return `${likeColumn(literal)} LIKE ? ESCAPE '\\'`;
|
|
12670
12915
|
}).join(" OR ");
|
|
12671
|
-
for (let from = fromSeq; from <=
|
|
12916
|
+
for (let from = fromSeq + SEQ_WINDOW; from <= through && seqs.length < limit; from += SEQ_WINDOW) {
|
|
12917
|
+
await yieldTurn();
|
|
12672
12918
|
signal?.throwIfAborted();
|
|
12673
|
-
const winTo = Math.min(
|
|
12919
|
+
const winTo = Math.min(through, from + SEQ_WINDOW - 1);
|
|
12674
12920
|
const rows = await database.all(`SELECT DISTINCT seq FROM ${tables.entries} WHERE sid = ? AND seq >= ? AND seq <= ? AND (${where}) ORDER BY seq LIMIT ?`, sid, from, winTo, ...params, limit - seqs.length);
|
|
12675
12921
|
for (const row of rows) seqs.push(Number(row.seq));
|
|
12676
|
-
if (winTo < toSeq && seqs.length < limit) await yieldTurn();
|
|
12677
12922
|
}
|
|
12678
12923
|
return seqs;
|
|
12679
12924
|
}
|
|
12680
|
-
for (let from = fromSeq; from <=
|
|
12925
|
+
for (let from = fromSeq + SEQ_WINDOW; from <= through && seqs.length < limit; from += SEQ_WINDOW) {
|
|
12926
|
+
await yieldTurn();
|
|
12681
12927
|
signal?.throwIfAborted();
|
|
12682
|
-
const winTo = Math.min(
|
|
12928
|
+
const winTo = Math.min(through, from + SEQ_WINDOW - 1);
|
|
12683
12929
|
const arms = [];
|
|
12684
12930
|
const params = [];
|
|
12685
12931
|
for (const [setIndex, all] of sets.entries()) for (const [litIndex, literal] of all.entries()) {
|
|
@@ -12694,7 +12940,6 @@ const postgresTrigrams = {
|
|
|
12694
12940
|
const seq = Number(row.seq);
|
|
12695
12941
|
if (seqs.at(-1) !== seq && seqs.length < limit) seqs.push(seq);
|
|
12696
12942
|
}
|
|
12697
|
-
if (winTo < toSeq && seqs.length < limit) await yieldTurn();
|
|
12698
12943
|
}
|
|
12699
12944
|
return seqs;
|
|
12700
12945
|
}
|
|
@@ -12713,6 +12958,12 @@ var SqlSessionSearchIndex = class SqlSessionSearchIndex {
|
|
|
12713
12958
|
tables;
|
|
12714
12959
|
engine;
|
|
12715
12960
|
writesPrepared = false;
|
|
12961
|
+
/** Characters of search text written since the last background merge of the pending list began. */
|
|
12962
|
+
pendingChars = 0;
|
|
12963
|
+
/** The background merge of the pending list in flight, if any. */
|
|
12964
|
+
merging;
|
|
12965
|
+
/** False once a merge found that this role may not merge the pending list, which autovacuum then merges. */
|
|
12966
|
+
mayMerge = true;
|
|
12716
12967
|
constructor(database, sessionTables, tables) {
|
|
12717
12968
|
this.database = database;
|
|
12718
12969
|
this.dialect = dialectOf(database);
|
|
@@ -12720,23 +12971,49 @@ var SqlSessionSearchIndex = class SqlSessionSearchIndex {
|
|
|
12720
12971
|
this.tables = tables;
|
|
12721
12972
|
this.engine = engineFor(this.dialect);
|
|
12722
12973
|
}
|
|
12723
|
-
static async open(database, sessionTables, prefix) {
|
|
12974
|
+
static async open(database, sessionTables, prefix, onUnavailable) {
|
|
12724
12975
|
const tables = renderStorageIdentifiers("sessions", SESSION_SEARCH_TABLES, prefix);
|
|
12725
|
-
const
|
|
12976
|
+
const dialect = dialectOf(database);
|
|
12977
|
+
const engine = engineFor(dialect);
|
|
12978
|
+
const ledger = storageMigrationTable(prefix);
|
|
12979
|
+
let created = false;
|
|
12726
12980
|
try {
|
|
12727
12981
|
if (await SqlSessionSearchIndex.tablesExist(database, tables)) return new SqlSessionSearchIndex(database, sessionTables, tables);
|
|
12982
|
+
if (!dialect.versionedMigrations) {
|
|
12983
|
+
const { int, text, rowKey } = dialect.types;
|
|
12984
|
+
const stateSql = `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}`;
|
|
12985
|
+
const ftsSql = `CREATE VIRTUAL TABLE IF NOT EXISTS ${tables.fts} USING fts5(body, content='', contentless_delete=1, tokenize='trigram', detail='none')`;
|
|
12986
|
+
if (queueSqliteSchemaSetup(database, ledger, {
|
|
12987
|
+
optional: true,
|
|
12988
|
+
verify: (catalog) => catalog.hasTable(tables.state) && catalog.hasTable(tables.fts),
|
|
12989
|
+
onFailure: onUnavailable,
|
|
12990
|
+
run(ctx) {
|
|
12991
|
+
if (!ctx.tableExisted(tables.state)) {
|
|
12992
|
+
ctx.enqueue(stateSql);
|
|
12993
|
+
ctx.noteTableCreated(tables.state);
|
|
12994
|
+
}
|
|
12995
|
+
if (!ctx.tableExisted(tables.fts)) {
|
|
12996
|
+
ctx.enqueue(ftsSql);
|
|
12997
|
+
ctx.noteTableCreated(tables.fts);
|
|
12998
|
+
}
|
|
12999
|
+
}
|
|
13000
|
+
})) return new SqlSessionSearchIndex(database, sessionTables, tables);
|
|
13001
|
+
}
|
|
12728
13002
|
await applyStorageMigrations(database, SESSION_SEARCH_DOMAIN, [{
|
|
12729
13003
|
version: 1,
|
|
12730
13004
|
up: async (tx, dialect) => {
|
|
12731
13005
|
const { int, text, rowKey } = dialect.types;
|
|
12732
|
-
|
|
13006
|
+
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`;
|
|
13007
|
+
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}`);
|
|
12733
13008
|
await engine.create(tx, dialect, tables, sessionTables);
|
|
13009
|
+
created = true;
|
|
12734
13010
|
}
|
|
12735
13011
|
}], {
|
|
12736
|
-
table:
|
|
13012
|
+
table: ledger,
|
|
12737
13013
|
acceptNewer: true
|
|
12738
13014
|
});
|
|
12739
|
-
if (!await engine.ready(database,
|
|
13015
|
+
if (!await engine.ready(database, dialect, tables)) return void 0;
|
|
13016
|
+
if (!created) await engine.tune?.(database, dialect, tables, ledger).catch(() => void 0);
|
|
12740
13017
|
} catch {
|
|
12741
13018
|
return;
|
|
12742
13019
|
}
|
|
@@ -12746,21 +13023,50 @@ var SqlSessionSearchIndex = class SqlSessionSearchIndex {
|
|
|
12746
13023
|
const dialect = dialectOf(database);
|
|
12747
13024
|
if (dialect.versionedMigrations) return false;
|
|
12748
13025
|
const catalog = await schemaCatalogOf(database);
|
|
12749
|
-
if (catalog
|
|
13026
|
+
if (catalog !== void 0) return catalog.hasTable(tables.state) && catalog.hasTable(tables.fts);
|
|
12750
13027
|
const probes = [tables.state, tables.fts].map((table) => dialect.tableExists(table));
|
|
12751
13028
|
return (await Promise.all(probes.map((probe) => database.get(probe.sql, ...probe.params)))).every((row) => row !== void 0);
|
|
12752
13029
|
}
|
|
13030
|
+
/** The statements that forget session `sessionId`, in order: its indexed text, then its state row. */
|
|
13031
|
+
forgetStatements(sessionId) {
|
|
13032
|
+
return [this.engine.forgetStatement(this.tables, sessionId), {
|
|
13033
|
+
sql: `DELETE FROM ${this.tables.state} WHERE session_id = ?`,
|
|
13034
|
+
params: [sessionId]
|
|
13035
|
+
}];
|
|
13036
|
+
}
|
|
12753
13037
|
async forget(tx, sessionId) {
|
|
12754
|
-
|
|
12755
|
-
await tx.run(`DELETE FROM ${this.tables.state} WHERE session_id = ?`, sessionId);
|
|
13038
|
+
for (const { sql, params } of this.forgetStatements(sessionId)) await tx.run(sql, ...params);
|
|
12756
13039
|
}
|
|
13040
|
+
/**
|
|
13041
|
+
* Forgets session `sessionId` inside transaction `tx` under a savepoint, so an index that cannot be forgotten leaves
|
|
13042
|
+
* the transaction going. Where `tx` is pipelined on PostgreSQL, the savepoint, the forget and the release go out in
|
|
13043
|
+
* one round trip: a statement that fails aborts the transaction, so nothing after it runs, and the release with it;
|
|
13044
|
+
* the transaction then goes back to the savepoint, which still stands, and drops it.
|
|
13045
|
+
*/
|
|
12757
13046
|
async forgetWithin(tx, sessionId) {
|
|
12758
|
-
|
|
12759
|
-
|
|
12760
|
-
|
|
12761
|
-
|
|
12762
|
-
|
|
13047
|
+
if (transactionFinisher(tx) === void 0 || this.dialect.name !== "postgres") {
|
|
13048
|
+
await tx.exec("SAVEPOINT atomic_session_search_forget");
|
|
13049
|
+
try {
|
|
13050
|
+
await this.forget(tx, sessionId);
|
|
13051
|
+
} catch {
|
|
13052
|
+
await tx.exec("ROLLBACK TO SAVEPOINT atomic_session_search_forget");
|
|
13053
|
+
}
|
|
13054
|
+
await tx.exec("RELEASE SAVEPOINT atomic_session_search_forget");
|
|
13055
|
+
return;
|
|
12763
13056
|
}
|
|
13057
|
+
const [savepoint, ...rest] = await Promise.allSettled([
|
|
13058
|
+
tx.exec("SAVEPOINT atomic_session_search_forget"),
|
|
13059
|
+
...this.forgetStatements(sessionId).map(({ sql, params }) => tx.run(sql, ...params)),
|
|
13060
|
+
tx.exec("RELEASE SAVEPOINT atomic_session_search_forget")
|
|
13061
|
+
]);
|
|
13062
|
+
if (savepoint.status === "rejected") throw savepoint.reason;
|
|
13063
|
+
const forgets = rest.slice(0, -1);
|
|
13064
|
+
const release = rest.at(-1);
|
|
13065
|
+
if (forgets.every((forgot) => forgot.status === "fulfilled")) {
|
|
13066
|
+
if (release.status === "rejected") throw release.reason;
|
|
13067
|
+
return;
|
|
13068
|
+
}
|
|
13069
|
+
await tx.exec("ROLLBACK TO SAVEPOINT atomic_session_search_forget");
|
|
12764
13070
|
await tx.exec("RELEASE SAVEPOINT atomic_session_search_forget");
|
|
12765
13071
|
}
|
|
12766
13072
|
async coverage(sessionId, format) {
|
|
@@ -12780,7 +13086,7 @@ var SqlSessionSearchIndex = class SqlSessionSearchIndex {
|
|
|
12780
13086
|
indexedSeq,
|
|
12781
13087
|
lastSeq
|
|
12782
13088
|
}, generation, row.session_revision);
|
|
12783
|
-
await this.database.transaction((tx) => this.forget(tx, sessionId), this.
|
|
13089
|
+
await this.database.transaction((tx) => this.forget(tx, sessionId), this.searchWrite(sessionId));
|
|
12784
13090
|
return withCoverageMeta({
|
|
12785
13091
|
indexedSeq: 0,
|
|
12786
13092
|
lastSeq
|
|
@@ -12789,9 +13095,10 @@ var SqlSessionSearchIndex = class SqlSessionSearchIndex {
|
|
|
12789
13095
|
async extend(sessionId, format, afterSeq, throughSeq, texts, options) {
|
|
12790
13096
|
if (throughSeq >= SEQ_SPACE || throughSeq < afterSeq) return false;
|
|
12791
13097
|
options?.signal?.throwIfAborted();
|
|
12792
|
-
const txOptions = this.
|
|
13098
|
+
const txOptions = this.searchWrite(sessionId);
|
|
12793
13099
|
const { docs, oversizedSeqs } = prepareDocs(texts);
|
|
12794
|
-
|
|
13100
|
+
const totalChars = docs.reduce((sum, doc) => sum + doc.text.length, 0);
|
|
13101
|
+
if (totalChars <= BATCH_CHARS) {
|
|
12795
13102
|
let backlog = false;
|
|
12796
13103
|
const extended = await this.writeTransaction(sessionId, async (tx) => {
|
|
12797
13104
|
options?.signal?.throwIfAborted();
|
|
@@ -12825,6 +13132,7 @@ var SqlSessionSearchIndex = class SqlSessionSearchIndex {
|
|
|
12825
13132
|
const nextWhole = mergeWholeSeqs(row.whole_seqs, oversizedSeqs);
|
|
12826
13133
|
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;
|
|
12827
13134
|
});
|
|
13135
|
+
this.notePendingChars(totalChars);
|
|
12828
13136
|
if (extended && backlog) await this.mergeBacklog(options?.signal);
|
|
12829
13137
|
return extended;
|
|
12830
13138
|
}
|
|
@@ -12876,6 +13184,7 @@ var SqlSessionSearchIndex = class SqlSessionSearchIndex {
|
|
|
12876
13184
|
}
|
|
12877
13185
|
return true;
|
|
12878
13186
|
}, txOptions)) return false;
|
|
13187
|
+
this.notePendingChars(batch.reduce((sum, doc) => sum + doc.text.length, 0));
|
|
12879
13188
|
if (backlog) await this.mergeBacklog(options?.signal);
|
|
12880
13189
|
start = end;
|
|
12881
13190
|
await yieldTurn();
|
|
@@ -12889,6 +13198,22 @@ var SqlSessionSearchIndex = class SqlSessionSearchIndex {
|
|
|
12889
13198
|
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;
|
|
12890
13199
|
}, txOptions);
|
|
12891
13200
|
}
|
|
13201
|
+
/**
|
|
13202
|
+
* Counts `chars` of search text a committed write added, and once `SEARCH_PENDING_MERGE_CHARS` of them have, starts a
|
|
13203
|
+
* background merge of the pending list, which this write and the writes after it do not wait for. So no write merges
|
|
13204
|
+
* the list inside its transaction, which holds the session's lock (PostgreSQL only).
|
|
13205
|
+
*/
|
|
13206
|
+
notePendingChars(chars) {
|
|
13207
|
+
if (this.engine.mergePending === void 0 || !this.mayMerge || this.database.readOnly === true) return;
|
|
13208
|
+
this.pendingChars += chars;
|
|
13209
|
+
if (this.pendingChars < 131072 || this.merging !== void 0) return;
|
|
13210
|
+
this.pendingChars = 0;
|
|
13211
|
+
this.merging = this.engine.mergePending(this.database, this.dialect, this.tables).then((merged) => {
|
|
13212
|
+
if (!merged) this.mayMerge = false;
|
|
13213
|
+
}, () => void 0).finally(() => {
|
|
13214
|
+
this.merging = void 0;
|
|
13215
|
+
});
|
|
13216
|
+
}
|
|
12892
13217
|
async mergeBacklog(signal) {
|
|
12893
13218
|
for (let write = 0; write < MAX_MERGE_BACKLOG_WRITES; write++) {
|
|
12894
13219
|
await yieldTurn();
|
|
@@ -12896,11 +13221,34 @@ var SqlSessionSearchIndex = class SqlSessionSearchIndex {
|
|
|
12896
13221
|
}
|
|
12897
13222
|
}
|
|
12898
13223
|
/**
|
|
12899
|
-
* A write of the session `sessionId`'s index rows
|
|
12900
|
-
*
|
|
13224
|
+
* A write of the session `sessionId`'s index rows, in the domain of that session's index rather than the session's
|
|
13225
|
+
* own: saves to the session, which take the session's domain, run beside it. A rewrite of the session, which forgets
|
|
13226
|
+
* its index, takes this domain too ({@link writeLock}), so an index write commits wholly before the rewrite reads
|
|
13227
|
+
* the index or starts after it commits, and its checks then see the rewrite. `delete` holds the whole database.
|
|
12901
13228
|
*/
|
|
12902
|
-
|
|
12903
|
-
return
|
|
13229
|
+
searchWrite(sessionId) {
|
|
13230
|
+
return {
|
|
13231
|
+
retryTransientFailures: true,
|
|
13232
|
+
concurrency: {
|
|
13233
|
+
kind: "serial",
|
|
13234
|
+
domain: this.searchDomain(sessionId)
|
|
13235
|
+
}
|
|
13236
|
+
};
|
|
13237
|
+
}
|
|
13238
|
+
searchDomain(sessionId) {
|
|
13239
|
+
return `${this.tables.state}:${sessionId}`;
|
|
13240
|
+
}
|
|
13241
|
+
/**
|
|
13242
|
+
* On PostgreSQL, the statement that takes, inside a transaction of the session's own domain, the advisory lock index
|
|
13243
|
+
* writes of the session `sessionId` hold ({@link searchWrite}), keyed as the driver keys a domain's lock. A rewrite
|
|
13244
|
+
* runs it before it touches the index. Undefined where transactions do not run beside each other.
|
|
13245
|
+
*/
|
|
13246
|
+
writeLock(sessionId) {
|
|
13247
|
+
if (this.dialect.name !== "postgres") return void 0;
|
|
13248
|
+
return {
|
|
13249
|
+
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",
|
|
13250
|
+
params: [this.searchDomain(sessionId)]
|
|
13251
|
+
};
|
|
12904
13252
|
}
|
|
12905
13253
|
async writeTransaction(sessionId, body) {
|
|
12906
13254
|
let prepared = this.writesPrepared;
|
|
@@ -12910,21 +13258,64 @@ var SqlSessionSearchIndex = class SqlSessionSearchIndex {
|
|
|
12910
13258
|
prepared = true;
|
|
12911
13259
|
}
|
|
12912
13260
|
return body(tx);
|
|
12913
|
-
}, this.
|
|
13261
|
+
}, this.searchWrite(sessionId));
|
|
12914
13262
|
if (prepared) this.writesPrepared = true;
|
|
12915
13263
|
return result;
|
|
12916
13264
|
}
|
|
12917
13265
|
async candidates(sessionId, anyOf, fromSeq, toSeq, limit, generation, signal) {
|
|
12918
13266
|
signal?.throwIfAborted();
|
|
12919
13267
|
if (anyOf.length === 0 || fromSeq > toSeq) return [];
|
|
12920
|
-
const
|
|
13268
|
+
const stateStatement = {
|
|
13269
|
+
sql: `SELECT sid, indexed_seq, revision AS generation, entry_id AS whole_seqs FROM ${this.tables.state} WHERE session_id = ?`,
|
|
13270
|
+
params: [sessionId]
|
|
13271
|
+
};
|
|
13272
|
+
const sets = normalizeSets(anyOf);
|
|
13273
|
+
const cappedTo = Math.min(toSeq, 67108863);
|
|
13274
|
+
const sqlFrom = Math.max(0, fromSeq);
|
|
13275
|
+
if (sets.length === 0 || limit <= 0 || sqlFrom > cappedTo) {
|
|
13276
|
+
const state = await this.database.get(stateStatement.sql, ...stateStatement.params);
|
|
13277
|
+
signal?.throwIfAborted();
|
|
13278
|
+
if (!state) return generation !== void 0 ? void 0 : [];
|
|
13279
|
+
const indexedSeq = Number(state.indexed_seq);
|
|
13280
|
+
if (generation !== void 0 && (state.generation !== generation || indexedSeq < toSeq)) return;
|
|
13281
|
+
const through = Math.min(cappedTo, indexedSeq);
|
|
13282
|
+
if (fromSeq > through) return [];
|
|
13283
|
+
return mergeCandidateSeqs([], parseWholeSeqs(state.whole_seqs).filter((seq) => seq >= fromSeq && seq <= through), limit);
|
|
13284
|
+
}
|
|
13285
|
+
const firstWindow = this.engine.firstCandidatesWindow(this.tables, sessionId, sets, sqlFrom, cappedTo, limit);
|
|
13286
|
+
const initial = await this.database.transaction(async (tx) => {
|
|
13287
|
+
const state = await tx.get(stateStatement.sql, ...stateStatement.params);
|
|
13288
|
+
if (!state) return {
|
|
13289
|
+
state,
|
|
13290
|
+
rows: []
|
|
13291
|
+
};
|
|
13292
|
+
const indexedSeq = Number(state.indexed_seq);
|
|
13293
|
+
if (generation !== void 0 && (state.generation !== generation || indexedSeq < toSeq)) return {
|
|
13294
|
+
state,
|
|
13295
|
+
rows: []
|
|
13296
|
+
};
|
|
13297
|
+
if (fromSeq > Math.min(cappedTo, indexedSeq)) return {
|
|
13298
|
+
state,
|
|
13299
|
+
rows: []
|
|
13300
|
+
};
|
|
13301
|
+
return {
|
|
13302
|
+
state,
|
|
13303
|
+
rows: await tx.all(firstWindow.sql, ...firstWindow.params)
|
|
13304
|
+
};
|
|
13305
|
+
}, {
|
|
13306
|
+
readOnly: true,
|
|
13307
|
+
retryTransientFailures: true,
|
|
13308
|
+
leading: [stateStatement, firstWindow],
|
|
13309
|
+
leadingOnly: true
|
|
13310
|
+
});
|
|
12921
13311
|
signal?.throwIfAborted();
|
|
13312
|
+
const { state } = initial;
|
|
12922
13313
|
if (!state) return generation !== void 0 ? void 0 : [];
|
|
12923
13314
|
const indexedSeq = Number(state.indexed_seq);
|
|
12924
13315
|
if (generation !== void 0 && (state.generation !== generation || indexedSeq < toSeq)) return;
|
|
12925
|
-
const through = Math.min(
|
|
13316
|
+
const through = Math.min(cappedTo, indexedSeq);
|
|
12926
13317
|
if (fromSeq > through) return [];
|
|
12927
|
-
const engineSeqs = await this.engine.
|
|
13318
|
+
const engineSeqs = await this.engine.candidatesFromFirstWindow(this.database, this.tables, Number(state.sid), sets, sqlFrom, through, limit, initial.rows, signal);
|
|
12928
13319
|
signal?.throwIfAborted();
|
|
12929
13320
|
return mergeCandidateSeqs(engineSeqs, parseWholeSeqs(state.whole_seqs).filter((seq) => seq >= fromSeq && seq <= through), limit);
|
|
12930
13321
|
}
|
|
@@ -13214,7 +13605,7 @@ function keepCleanupFailure(primary, cleanupCause) {
|
|
|
13214
13605
|
* and other file types until EOF. If closing the file fails after another failure, the first failure is thrown
|
|
13215
13606
|
* with the close failure as its `cleanupCause`.
|
|
13216
13607
|
*/
|
|
13217
|
-
async function* readLocalFileChunks(path, { signal }, open = open$
|
|
13608
|
+
async function* readLocalFileChunks(path, { signal }, open = open$2) {
|
|
13218
13609
|
const handle = await open(path, "r");
|
|
13219
13610
|
let closed = false;
|
|
13220
13611
|
try {
|
|
@@ -14374,17 +14765,19 @@ const HEAD_SCAN_LIMIT_BYTES = 262144;
|
|
|
14374
14765
|
const HEAD_CHUNK_BYTES = 16384;
|
|
14375
14766
|
const NEWLINE = 10;
|
|
14376
14767
|
function applyLine(scan, line, unterminated = false) {
|
|
14377
|
-
if (
|
|
14768
|
+
if (line.includes("\0")) return false;
|
|
14769
|
+
if (!line.trim()) return true;
|
|
14378
14770
|
let entry;
|
|
14379
14771
|
try {
|
|
14380
14772
|
entry = JSON.parse(line);
|
|
14381
14773
|
} catch (cause) {
|
|
14382
|
-
if (unterminated) return;
|
|
14774
|
+
if (unterminated) return false;
|
|
14383
14775
|
throw cause;
|
|
14384
14776
|
}
|
|
14385
14777
|
const { state, texts } = applySessionSummaryEntries(scan.state, [entry]);
|
|
14386
14778
|
scan.state = state;
|
|
14387
14779
|
for (const { text } of texts) scan.texts.push(text);
|
|
14780
|
+
return true;
|
|
14388
14781
|
}
|
|
14389
14782
|
/** Reads entries up to the first user message; returns the offset after the last line consumed. */
|
|
14390
14783
|
async function scanHead(handle, scan) {
|
|
@@ -14396,10 +14789,15 @@ async function scanHead(handle, scan) {
|
|
|
14396
14789
|
while (offset < HEAD_SCAN_LIMIT_BYTES) {
|
|
14397
14790
|
const { bytesRead } = await handle.read(chunk, 0, chunk.length, offset);
|
|
14398
14791
|
if (bytesRead === 0) {
|
|
14399
|
-
if (pending.length > 0
|
|
14792
|
+
if (pending.length > 0 && !applyLine(scan, pending.toString("utf8"), true)) return {
|
|
14793
|
+
end,
|
|
14794
|
+
complete: true,
|
|
14795
|
+
torn: true
|
|
14796
|
+
};
|
|
14400
14797
|
return {
|
|
14401
14798
|
end: end + pending.length,
|
|
14402
|
-
complete: true
|
|
14799
|
+
complete: true,
|
|
14800
|
+
torn: false
|
|
14403
14801
|
};
|
|
14404
14802
|
}
|
|
14405
14803
|
offset += bytesRead;
|
|
@@ -14407,18 +14805,28 @@ async function scanHead(handle, scan) {
|
|
|
14407
14805
|
for (let newline = pending.indexOf(NEWLINE); newline !== -1; newline = pending.indexOf(NEWLINE)) {
|
|
14408
14806
|
const line = pending.subarray(0, newline).toString("utf8");
|
|
14409
14807
|
pending = pending.subarray(newline + 1);
|
|
14808
|
+
if (header) {
|
|
14809
|
+
header = false;
|
|
14810
|
+
end += newline + 1;
|
|
14811
|
+
continue;
|
|
14812
|
+
}
|
|
14813
|
+
if (!applyLine(scan, line)) return {
|
|
14814
|
+
end,
|
|
14815
|
+
complete: true,
|
|
14816
|
+
torn: true
|
|
14817
|
+
};
|
|
14410
14818
|
end += newline + 1;
|
|
14411
|
-
if (header) header = false;
|
|
14412
|
-
else applyLine(scan, line);
|
|
14413
14819
|
if (scan.state.firstMessage) return {
|
|
14414
14820
|
end,
|
|
14415
|
-
complete: true
|
|
14821
|
+
complete: true,
|
|
14822
|
+
torn: false
|
|
14416
14823
|
};
|
|
14417
14824
|
}
|
|
14418
14825
|
}
|
|
14419
14826
|
return {
|
|
14420
14827
|
end,
|
|
14421
|
-
complete: false
|
|
14828
|
+
complete: false,
|
|
14829
|
+
torn: false
|
|
14422
14830
|
};
|
|
14423
14831
|
}
|
|
14424
14832
|
/**
|
|
@@ -14448,7 +14856,7 @@ async function scanTail(handle, size, headEnd, scan, windowBytes = SUMMARY_WINDO
|
|
|
14448
14856
|
latestMessageTime: null
|
|
14449
14857
|
};
|
|
14450
14858
|
const lines = bytes.subarray(from, filled).toString("utf8").split("\n");
|
|
14451
|
-
for (const [index, line] of lines.entries()) applyLine(scan, line, index === lines.length - 1);
|
|
14859
|
+
for (const [index, line] of lines.entries()) if (!applyLine(scan, line, index === lines.length - 1)) break;
|
|
14452
14860
|
return !skipsMiddle || scan.state.latestMessageTime !== null;
|
|
14453
14861
|
}
|
|
14454
14862
|
/**
|
|
@@ -14470,8 +14878,8 @@ async function summarizeLegacySession(file, size, modifiedMs, options) {
|
|
|
14470
14878
|
try {
|
|
14471
14879
|
const head = await scanHead(handle, scan);
|
|
14472
14880
|
if (!head.complete && allowWhole) return summarizeSession(await file.read());
|
|
14473
|
-
if (!await scanTail(handle, size, head.end, scan) && allowWhole) return summarizeSession(await file.read());
|
|
14474
|
-
estimated = Math.max(size - SUMMARY_WINDOW_BYTES, head.end) > head.end;
|
|
14881
|
+
if (!head.torn && !await scanTail(handle, size, head.end, scan) && allowWhole) return summarizeSession(await file.read());
|
|
14882
|
+
estimated = !head.torn && Math.max(size - SUMMARY_WINDOW_BYTES, head.end) > head.end;
|
|
14475
14883
|
} finally {
|
|
14476
14884
|
await handle.close();
|
|
14477
14885
|
}
|
|
@@ -16692,10 +17100,6 @@ const SettingsSchema = Type$1.Object({
|
|
|
16692
17100
|
$schema: Type$1.Optional(Type$1.String({ description: "JSON Schema reference." })),
|
|
16693
17101
|
storage: Type$1.Optional(StorageSelectionSchema),
|
|
16694
17102
|
sessions: Type$1.Optional(Type$1.Object({ storage: Type$1.Optional(SessionStorageSelectionSchema) })),
|
|
16695
|
-
teamJoin: Type$1.Optional(Type$1.Object({ storage: Type$1.String({
|
|
16696
|
-
pattern: "^sha256:[0-9a-f]{64}$",
|
|
16697
|
-
description: "Fingerprint of the `storage` selection that `atomic team join` wrote."
|
|
16698
|
-
}) }, { description: "Managed team join record; leave unchanged." })),
|
|
16699
17103
|
lastChangelogVersion: Type$1.Optional(Type$1.String()),
|
|
16700
17104
|
firstRunOnboardingStartedVersion: Type$1.Optional(Type$1.String({ description: "Managed onboarding state; leave unchanged." })),
|
|
16701
17105
|
onboardedVersion: Type$1.Optional(Type$1.String({ description: "Managed onboarding completion state; leave unchanged." })),
|
|
@@ -19302,16 +19706,16 @@ var ChildCatalog = class ChildCatalog {
|
|
|
19302
19706
|
function sessionScratchDir(agentDir, cwd, _sessionId) {
|
|
19303
19707
|
return getDefaultSessionDirPath(cwd, agentDir);
|
|
19304
19708
|
}
|
|
19305
|
-
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,
|
|
19709
|
+
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, appendFileChatRecords, 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 };
|
|
19306
19710
|
|
|
19307
|
-
//# sourceMappingURL=startup-0-1-
|
|
19711
|
+
//# sourceMappingURL=startup-0-1-M6OWAYHH.js.map
|
|
19308
19712
|
// __atomicOnDemandFailed: written by the build (scripts/in-place-update-gate.mjs). An import of this release's code on
|
|
19309
19713
|
// demand that fails in a process an in-place update left running says to restart.
|
|
19310
19714
|
function __atomicOnDemandFailed(error, feature) {
|
|
19311
19715
|
return (async () => {
|
|
19312
19716
|
const root = new URL("../", import.meta.url);
|
|
19313
19717
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
19314
|
-
const key = `${root.href}#0.10.11-alpha.
|
|
19718
|
+
const key = `${root.href}#0.10.11-alpha.4`;
|
|
19315
19719
|
let release = releases.get(key);
|
|
19316
19720
|
if (release === undefined) {
|
|
19317
19721
|
const current = (async () => {
|
|
@@ -19339,7 +19743,7 @@ function __atomicOnDemandFailed(error, feature) {
|
|
|
19339
19743
|
} catch {
|
|
19340
19744
|
// No installation to read, as in a bundle of the package: the release the process runs decides.
|
|
19341
19745
|
}
|
|
19342
|
-
const updatedTo = typeof installed === "string" && installed !== "0.10.11-alpha.
|
|
19746
|
+
const updatedTo = typeof installed === "string" && installed !== "0.10.11-alpha.4" ? installed : running !== undefined && running.version !== "0.10.11-alpha.4" ? "0.10.11-alpha.4" : undefined;
|
|
19343
19747
|
if (updatedTo === undefined) throw error;
|
|
19344
19748
|
const application = typeof running?.name === "string" ? running.name : "atomic";
|
|
19345
19749
|
const restart = new Error(`${application} was updated to ${updatedTo} while this session was running; restart it to keep using ${feature}.`, {
|