@bastani/atomic 0.10.19 → 0.10.20-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +72 -0
- package/dist/_shared/adapter-open-DXXV6ATH.js +22 -0
- package/dist/_shared/adapter-open-DXXV6ATH.js.map +1 -0
- 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-JXBZ3H27.js +484 -229
- package/dist/_shared/mode-interactive-sdk-JXBZ3H27.js.map +1 -1
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +63 -16
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js.map +1 -1
- package/dist/_shared/mode-shared-2QJSCUM6.js +61 -16
- package/dist/_shared/mode-shared-2QJSCUM6.js.map +1 -1
- package/dist/_shared/p0-cli-BB45ZQY6.js +2 -2
- package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
- package/dist/_shared/p1b-elig-BY2G5BUE.js +6 -3
- package/dist/_shared/p1b-elig-BY2G5BUE.js.map +1 -1
- package/dist/_shared/runtime-O4KCSG4C.js +5 -5
- package/dist/_shared/{sdk-BHX35EPK.js → sdk-5ZFNDXUJ.js} +319 -86
- package/dist/_shared/sdk-5ZFNDXUJ.js.map +1 -0
- package/dist/_shared/session-data-AHTU7IS6.js +15 -7
- package/dist/_shared/session-data-AHTU7IS6.js.map +1 -1
- package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
- package/dist/_shared/settings-startup-HXQLSUWM.js +2 -2
- package/dist/_shared/settings-startup-HXQLSUWM.js.map +1 -1
- package/dist/_shared/{startup-0-0-4EDVBK5P.js → startup-0-0-OWBJIX35.js} +162 -44
- package/dist/_shared/startup-0-0-OWBJIX35.js.map +1 -0
- package/dist/_shared/{startup-0-1-H5IXVRXQ.js → startup-0-1-DZYE4E5Z.js} +462 -37
- package/dist/_shared/startup-0-1-DZYE4E5Z.js.map +1 -0
- package/dist/_shared/{startup-0-2-YZZOC22D.js → startup-0-2-WFLTE4SC.js} +147 -6
- package/dist/_shared/startup-0-2-WFLTE4SC.js.map +1 -0
- package/dist/_shared/startup-0-3-DE2NCS6A.js +59 -50
- package/dist/_shared/startup-0-3-DE2NCS6A.js.map +1 -1
- package/dist/_shared/{startup-0-4-ZMJV547D.js → startup-0-4-6XXL4JMZ.js} +115 -25
- package/dist/_shared/startup-0-4-6XXL4JMZ.js.map +1 -0
- package/dist/_shared/{startup-0-5-HZX3ZPTP.js → startup-0-5-DNS6FYS7.js} +229 -156
- package/dist/_shared/startup-0-5-DNS6FYS7.js.map +1 -0
- package/dist/_shared/{startup-10-0-TDQNBDDL.js → startup-10-0-O6DAT7U4.js} +131 -162
- package/dist/_shared/startup-10-0-O6DAT7U4.js.map +1 -0
- package/dist/_shared/startup-12-0-55AAXBJZ.js +3 -3
- package/dist/_shared/startup-14-0-MLX36RBG.js +9 -6
- package/dist/_shared/startup-14-0-MLX36RBG.js.map +1 -1
- package/dist/_shared/{startup-15-0-YUKGAC63.js → startup-15-0-E7RYG5YF.js} +9 -9
- package/dist/_shared/{startup-15-0-YUKGAC63.js.map → startup-15-0-E7RYG5YF.js.map} +1 -1
- package/dist/_shared/startup-15-1-WQZBOTMZ.js +340 -128
- package/dist/_shared/startup-15-1-WQZBOTMZ.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +279 -151
- package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
- package/dist/_shared/{startup-8-1-QZMXUGHI.js → startup-8-1-VXBL37AI.js} +352 -27
- package/dist/_shared/startup-8-1-VXBL37AI.js.map +1 -0
- package/dist/_shared/storage-command-7MGXLJGZ.js +15 -273
- package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
- package/dist/_shared/{storage-status-K7PX2RXA.js → storage-status-T6FUXRIM.js} +8 -24
- package/dist/_shared/{storage-status-K7PX2RXA.js.map → storage-status-T6FUXRIM.js.map} +1 -1
- package/dist/_shared/task-reference-stream-JWMUZSJX.js +1 -1
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/team-DOQKICG2.js +4 -3
- package/dist/_shared/team-DOQKICG2.js.map +1 -1
- package/dist/_shared/tree-outline-MUEPK5B7.js +9 -2
- package/dist/_shared/tree-outline-MUEPK5B7.js.map +1 -1
- package/dist/binary-self-update.js +3 -3
- package/dist/builtin/intercom/broker/broker.bundle.mjs +46 -8
- package/dist/builtin/intercom/broker/broker.ts +1 -0
- package/dist/builtin/intercom/broker/client.ts +5 -1
- package/dist/builtin/intercom/broker/departed-children.ts +12 -6
- package/dist/builtin/intercom/broker/ended-child-wakes.ts +2 -0
- package/dist/builtin/intercom/index.bundle.mjs +130 -264
- package/dist/builtin/intercom/message-display.ts +42 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/types.ts +1 -0
- package/dist/builtin/mcp/index.bundle.mjs +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +99 -20
- package/dist/builtin/web-access/index.bundle.mjs +15 -9
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/cli/args.js +2 -2
- package/dist/cli/auth-cli.code.js +6 -6
- package/dist/cli/auth-cli.impl.js +3 -3
- package/dist/cli/auth-cli.js +3 -3
- package/dist/cli/blueprint-command.code.js +4 -4
- 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.impl.js +3 -3
- package/dist/cli/intercom-command.js +3 -3
- package/dist/cli/list-models.code.js +3 -3
- package/dist/cli/list-models.impl.js +3 -3
- package/dist/cli/list-models.js +3 -3
- package/dist/cli/session-picker.code.js +2 -2
- package/dist/cli/session-picker.impl.js +3 -3
- package/dist/cli/session-picker.js +3 -3
- package/dist/cli/startup-ui.code.js +2 -2
- 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 +3 -3
- package/dist/cli/team-command.impl.js +3 -3
- package/dist/cli/team-command.js +3 -3
- package/dist/cli.js +2 -2
- package/dist/core/agent-session-runtime.d.ts +16 -4
- package/dist/core/agent-session-types.d.ts +5 -1
- package/dist/core/debug.impl.js +3 -3
- package/dist/core/debug.js +3 -3
- package/dist/core/export-html/card-projection.code.js +74 -72
- package/dist/core/export-html/card-projection.code.js.map +1 -1
- 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 +52 -41
- 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.code.js +1 -1
- 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/template.js +27 -39
- package/dist/core/export-html/tool-renderer.code.js +1 -1
- 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/context-types.d.ts +3 -0
- package/dist/core/extensions/context-types.js.map +1 -1
- 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 +2 -2
- package/dist/core/extensions/runner-context.d.ts +1 -0
- package/dist/core/extensions/runner-context.js +18 -2
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runtime-types.d.ts +1 -0
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/intercom-broker-control-host.code.js +1 -1
- 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/model-registry.js +2 -2
- package/dist/core/model-runtime-streaming.d.ts +3 -1
- package/dist/core/model-runtime.d.ts +2 -0
- 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/resume/failure.d.ts +1 -1
- package/dist/core/sdk.code.js +4 -4
- package/dist/core/sdk.impl.js +3 -3
- package/dist/core/sdk.js +3 -3
- package/dist/core/session-claims.d.ts +13 -2
- package/dist/core/session-load-events.d.ts +42 -0
- package/dist/core/session-manager-core.d.ts +17 -2
- package/dist/core/session-manager-core.js +234 -93
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-errors.d.ts +2 -2
- package/dist/core/session-manager-history.d.ts +1 -1
- 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 +2 -2
- 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-manager.js +2 -2
- package/dist/core/storage/adapter-open.js +3 -0
- package/dist/core/storage/adapter-open.js.map +1 -0
- package/dist/core/storage/index.js +2 -2
- package/dist/core/storage/node-sqlite-thread.js +2 -2
- package/dist/core/storage/node-sqlite.js +2 -2
- 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.js +1 -0
- package/dist/core/storage/prefix.js.map +1 -1
- package/dist/core/storage/provider.js +2 -2
- package/dist/core/storage/schema-catalog.d.ts +2 -1
- package/dist/core/storage/schema-catalog.js +25 -6
- package/dist/core/storage/schema-catalog.js.map +1 -1
- package/dist/core/storage/selection.js +2 -2
- package/dist/core/storage/session/branch-fork-source.code.js +17 -4
- package/dist/core/storage/session/branch-fork-source.code.js.map +1 -1
- 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 +7 -7
- package/dist/core/storage/session/child-reader.code.js.map +1 -1
- package/dist/core/storage/session/child-reader.d.ts +1 -0
- 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.code.js +1 -1
- 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 +3 -3
- 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-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 +9 -5
- 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-window.code.js +29 -13
- package/dist/core/storage/session/fork-window.code.js.map +1 -1
- 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-store.d.ts +8 -4
- 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.d.ts +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/parent-links.d.ts +122 -0
- 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 +3 -3
- 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/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 +5 -6
- package/dist/core/storage/session/snapshot-history.code.js.map +1 -1
- 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 +7 -20
- 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.code.js +1 -1
- 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/session/types.d.ts +11 -3
- package/dist/core/storage/session/usage-observations.d.ts +27 -0
- package/dist/core/storage/session/usage-observations.js +3 -0
- package/dist/core/storage/session/usage-observations.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.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/subscription-usage-identity.d.ts +9 -0
- package/dist/core/subscription-usage-observations.d.ts +15 -0
- package/dist/core/subscription-usage-storage.js +3 -0
- package/dist/core/subscription-usage-storage.js.map +1 -0
- package/dist/core/subscription-usage.d.ts +20 -3
- package/dist/core/tasks/task-completion-entry.code.js +1 -1
- 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 +5 -5
- package/dist/core/tasks/task-reference-archive.js +3 -3
- package/dist/core/tasks/task-reference-identity.code.js +1 -1
- 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/read-url.code.js +3 -3
- 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.js +2 -2
- package/dist/core/worktree-snapshot/errors.code.js +3 -3
- package/dist/core/worktree-snapshot/errors.impl.js +3 -3
- package/dist/core/worktree-snapshot/errors.js +3 -3
- 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 +2 -2
- package/dist/extensions/codemode/execute.impl.js +3 -3
- package/dist/extensions/codemode/execute.js +3 -3
- package/dist/extensions/codemode/renderer.code.js +12 -7
- package/dist/extensions/codemode/renderer.code.js.map +1 -1
- 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 +6 -3
- package/dist/index.js +10 -10
- package/dist/main-first-time-setup.code.js +2 -2
- 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/index.d.ts +1 -1
- package/dist/modes/interactive/components/intercom-wake-notice.d.ts +4 -0
- package/dist/modes/interactive/components/notice-line.d.ts +1 -1
- package/dist/modes/interactive/components/stored-tree-view.code.js +6 -5
- package/dist/modes/interactive/components/stored-tree-view.code.js.map +1 -1
- 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/tool-block.d.ts +5 -1
- package/dist/modes/interactive/components/user-message-selector-archive.code.js +1 -1
- 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-engine/isolated-runtime.d.ts +4 -3
- package/dist/modes/print-mode.js +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +5 -0
- package/dist/modes/rpc/rpc-client.d.ts +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +26 -3
- package/dist/package-manager-cli.code.js +7 -7
- 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/12.js +1 -1
- package/dist/startup-stages/13.js +2 -1
- package/dist/startup-stages/14.js +1 -0
- package/dist/startup-stages/4.js +1 -1
- package/dist/startup-stages/6.js +1 -1
- package/dist/startup-stages/7.js +1 -1
- package/dist/startup-stages/8.js +1 -1
- package/dist/startup-stages/stages.json +1 -1
- package/dist/utils/startup-database-spare.code.js +3 -3
- 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/docs/.agents/context/DESIGN.md +30 -0
- package/docs/changelog.mdx +46 -0
- package/docs/docs.json +1 -1
- package/docs/extensions/api-reference.md +6 -0
- package/docs/guides/subscription-usage.md +28 -82
- package/docs/intercom.md +3 -1
- package/docs/json.md +3 -3
- package/docs/providers.md +2 -0
- package/docs/reference/cli.md +3 -1
- package/docs/rpc/protocol.md +31 -3
- package/docs/sdk/reference.md +26 -1
- package/docs/sdk.md +2 -0
- package/docs/sessions.md +38 -1
- package/docs/slash-commands.md +1 -1
- package/docs/subagents.md +2 -0
- package/docs/usage.md +1 -1
- package/package.json +8 -8
- package/dist/_shared/sdk-BHX35EPK.js.map +0 -1
- package/dist/_shared/startup-0-0-4EDVBK5P.js.map +0 -1
- package/dist/_shared/startup-0-1-H5IXVRXQ.js.map +0 -1
- package/dist/_shared/startup-0-2-YZZOC22D.js.map +0 -1
- package/dist/_shared/startup-0-4-ZMJV547D.js.map +0 -1
- package/dist/_shared/startup-0-5-HZX3ZPTP.js.map +0 -1
- package/dist/_shared/startup-10-0-TDQNBDDL.js.map +0 -1
- package/dist/_shared/startup-8-1-QZMXUGHI.js.map +0 -1
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { __name } from "./rolldown-runtime-BGM3D5V3.js";
|
|
2
2
|
import { APP_NAME, CONFIG_DIR_NAME, createChildProcessEnvironment, findHelperExecutable, getAgentDir, helperLaunch, helperLaunchAsync, missingHelperOptions, startedWithHangupIgnored, stripBom } from "./p0-cli-BB45ZQY6.js";
|
|
3
|
-
import { CONTINUE_AFTER_FAILURE, DynamicBorder, EventSourceError, ForkSourceIncompleteError, FramedSelector, LATEST_PROTOCOL_VERSION, SubscriptionClosedError, SubscriptionConfigError, SubscriptionSetupError, SubscriptionTimeoutError, abortFailure, announceHistoryLoad, applySessionSummaryEntries, assertForkSegments, bindChatEpoch, blueprintBuildsSettled, boundedChatRecord, canonicalEventBusFor, collectDeclaredDisplaySecrets, decodeChatOrder, decodeChatRecord, dropStoredNotes, encodeChatOrder, extractHeaderSecrets, firstChatOrders, flushRawStdout, forkRunSegments, forkStoreRelation, formatAppendRecoveryNotice, hasHistoryLoadObserver, isBetterMostRecentCandidate, isObject, isSensitiveKeyNameForMasking, locateForkSeq, markPreferResumableSupported, materializeSessionSummaryMetadata, nativeForkReader, noteSnapshotGeneration, onBlueprintBuildFinished, onBlueprintBuildWaiting, prefixForkSegments, raceWithAbortSignal, redactAuthorizationUrlForDisplay, redactCredentials, redactOAuthErrorText, redactUrlForDisplay, redactUrlForTransportDisplay, registerArchiveLoad, registerForkScope, registerHistorySnapshot, resolveDecisionDeadlineMs, scrubFetchError, segmentLength, sha256Hex, sharedHistorySwitchHost, sharedWakeDispatcher, sliceHead, storedEntryNotes, storedRows, stripUrlUserinfoAndHash, whenAborted, withinDecisionDeadline, writeRawStdout, yieldTurn } from "./startup-0-0-
|
|
4
|
-
import { CommandDeliveries, SqlSessionSearchIndex, WorkspacePublicationError, collectCommandDeliveries, normalizeModelFailureSignal, reportDiagnostics, requireTimerMs } from "./startup-0-1-
|
|
3
|
+
import { CONTINUE_AFTER_FAILURE, DynamicBorder, EventSourceError, ForkSourceIncompleteError, FramedSelector, LATEST_PROTOCOL_VERSION, SubscriptionClosedError, SubscriptionConfigError, SubscriptionSetupError, SubscriptionTimeoutError, abortFailure, announceHistoryLoad, applySessionSummaryEntries, assertForkSegments, bindChatEpoch, blueprintBuildsSettled, boundedChatRecord, canonicalEventBusFor, collectDeclaredDisplaySecrets, decodeChatOrder, decodeChatRecord, dropStoredNotes, encodeChatOrder, extractHeaderSecrets, firstChatOrders, flushRawStdout, forkRunSegments, forkStoreRelation, formatAppendRecoveryNotice, hasHistoryLoadObserver, isBetterMostRecentCandidate, isObject, isSensitiveKeyNameForMasking, locateForkSeq, markPreferResumableSupported, materializeSessionSummaryMetadata, nativeForkReader, noteSnapshotGeneration, onBlueprintBuildFinished, onBlueprintBuildWaiting, prefixForkSegments, raceWithAbortSignal, redactAuthorizationUrlForDisplay, redactCredentials, redactOAuthErrorText, redactUrlForDisplay, redactUrlForTransportDisplay, registerArchiveLoad, registerForkScope, registerHistorySnapshot, resolveDecisionDeadlineMs, scrubFetchError, segmentLength, sha256Hex, sharedHistorySwitchHost, sharedWakeDispatcher, sliceHead, storedEntryNotes, storedRows, stripUrlUserinfoAndHash, whenAborted, withinDecisionDeadline, writeRawStdout, yieldTurn } from "./startup-0-0-OWBJIX35.js";
|
|
4
|
+
import { CommandDeliveries, LaterSessionParents, SessionDuplicateEntryError, SessionInvalidParentError, SessionParentIndex, SessionParentRepairer, SqlSessionSearchIndex, UsageObservationStore, WorkspacePublicationError, collectCommandDeliveries, normalizeModelFailureSignal, pairedForkEntry, repairAppendedSessionParents, repairSessionParentWrites, repairedWriteResult, reportDiagnostics, requireTimerMs, setUsageObservationStore, usageObservationStore, validateSessionParentWrites } from "./startup-0-1-DZYE4E5Z.js";
|
|
5
5
|
import { getAvailableThemes, keyHint } from "./p2-shell-main-B2WIALFD.js";
|
|
6
6
|
import { releaseLock, reportDebugAsync, waitForLock } from "./p1b-elig-BY2G5BUE.js";
|
|
7
|
-
import { FileAuthStorageBackend, ResumePreconditionError, STRUCTURED_OUTPUT_TOOL_NAME, asyncAuthStorageReads, classifyRepository, detachForkChildren, detachForkWithin, isTombstoned, killTrackedDetachedChildren, lockedReferrers, markNativeMcpToolDefinition, matchesMcpDirectToolSelection, noteForkCopyRefusal, providerRetryHint, removeStoredRows, resumeForkDetaches } from "./startup-0-2-
|
|
7
|
+
import { FileAuthStorageBackend, ResumePreconditionError, STRUCTURED_OUTPUT_TOOL_NAME, asyncAuthStorageReads, classifyRepository, detachForkChildren, detachForkWithin, isSessionLoadEvent, isTombstoned, killTrackedDetachedChildren, lockedReferrers, markNativeMcpToolDefinition, matchesMcpDirectToolSelection, noteForkCopyRefusal, providerRetryHint, removeStoredRows, resumeForkDetaches, subscribeToLiveSessionLoads } from "./startup-0-2-WFLTE4SC.js";
|
|
8
8
|
import { CODEMODE_TOOL_NAME, assistantRetryAttempt, runWorkspaceProcess } from "./startup-0-3-DE2NCS6A.js";
|
|
9
9
|
import { DecisionConfigError, DecisionModelUnavailableError, DecisionOutputError, DecisionProviderError, DecisionRequestError, SESSION_HISTORY_CHUNK_BYTES, SESSION_HISTORY_PAGE_BYTES, entrySizeLimit, isDecisionError, isDecisionProviderError } from "./settings-startup-HXQLSUWM.js";
|
|
10
10
|
import { RESUME_UPGRADE_SOURCES, branchRanges, childCatalogCut, foldSessionResume, foreignResumeIds, isSessionResumeIndex, isUpgradableSessionResumeIndex, latestCompactionOf, readEarlierCompletionIntents, selectedPagePlan, sessionResumeFrom, sessionResumePlan, sessionResumeUpgrade, sessionTailFrom, snapshotCutOf, stateSeqsBefore, transcriptBranchSpan, validateSessionEntries, validateSessionHeader, validateSessionText } from "./startup-8-0-34CBHPZH.js";
|
|
11
|
-
import { LIST_MCP_RESOURCES_TOOL, LIST_MCP_RESOURCE_TEMPLATES_TOOL, READ_MCP_RESOURCE_TOOL, TOOL_SEARCH_TOOL_NAME, createMcpResourceToolDefinitions, createMcpToolDefinition, createMcpToolName, createMcpToolRenderers, defaultResumePreflightIo, enablePrintModelSelection, gitUnavailableProblem, hasPrintModelSelection, openWorkspaceRepository, ranOnModelLine, removeRestoredWorktree } from "./startup-0-5-
|
|
12
|
-
import { assertWorkspaceGitAvailable, formatModelLabel, gitOutput, runWorkspaceGit } from "./startup-0-4-
|
|
13
|
-
import { SettingsManager, checkoutsNeedingRebuild, inheritedRemotes, isInside, pathExists, resumeStoreDir, savedProjectTrustAsync, setUpResumedBlueprints, settingsFileTarget, settingsFileTargetAsync, writeSettingsFile, writeSettingsFileAsync } from "./startup-8-1-
|
|
14
|
-
import "./startup-15-0-
|
|
15
|
-
import "./startup-10-0-
|
|
11
|
+
import { LIST_MCP_RESOURCES_TOOL, LIST_MCP_RESOURCE_TEMPLATES_TOOL, READ_MCP_RESOURCE_TOOL, TOOL_SEARCH_TOOL_NAME, createMcpResourceToolDefinitions, createMcpToolDefinition, createMcpToolName, createMcpToolRenderers, defaultResumePreflightIo, enablePrintModelSelection, gitUnavailableProblem, hasPrintModelSelection, openWorkspaceRepository, ranOnModelLine, removeRestoredWorktree } from "./startup-0-5-DNS6FYS7.js";
|
|
12
|
+
import { assertWorkspaceGitAvailable, formatModelLabel, gitOutput, runWorkspaceGit } from "./startup-0-4-6XXL4JMZ.js";
|
|
13
|
+
import { SettingsManager, checkoutsNeedingRebuild, inheritedRemotes, isInside, pathExists, resumeStoreDir, savedProjectTrustAsync, selectSessionStorageWithSettingsAsync, setUpResumedBlueprints, settingsFileTarget, settingsFileTargetAsync, writeSettingsFile, writeSettingsFileAsync } from "./startup-8-1-VXBL37AI.js";
|
|
14
|
+
import "./startup-15-0-E7RYG5YF.js";
|
|
15
|
+
import "./startup-10-0-O6DAT7U4.js";
|
|
16
16
|
import "./p1a-prewarm-XIU57JHF.js";
|
|
17
17
|
import "./startup-14-0-MLX36RBG.js";
|
|
18
18
|
import "./startup-15-1-WQZBOTMZ.js";
|
|
@@ -38,6 +38,7 @@ import { once } from "node:events";
|
|
|
38
38
|
import { SessionConflictError, SessionConflictError as SessionConflictError$1, SessionExistsError, SessionExistsError as SessionExistsError$1, SessionFormatVersionError, SessionIdMismatchError, SessionIdMismatchError as SessionIdMismatchError$1, SessionInvalidTextError, SessionInvalidTimestampError, SessionNotFoundError, SessionNotFoundError as SessionNotFoundError$1, StorageUnavailableError as StorageUnavailableError$1, StoreClosedError as StoreClosedError$1 } from "../core/storage/session/errors.js";
|
|
39
39
|
import * as blobStore from "../core/worktree-snapshot/blob-store.js";
|
|
40
40
|
import { MemorySnapshotBlobStore, SNAPSHOT_COLLECTION_BATCH, SqlSnapshotBlobStore, SqlSnapshotBlobStore as SqlSnapshotBlobStore$1, snapshotBlobHashes, snapshotIndexTables, snapshotIndexTables as snapshotIndexTables$1 } from "../core/worktree-snapshot/blob-store.js";
|
|
41
|
+
import { withProviderTimeout } from "@bastani/atomic-ai/utils/provider-waits/timeout";
|
|
41
42
|
import { publishExtensionContextEffect, registerExtensionContextRetirementEffect } from "../core/extensions/runner-context.js";
|
|
42
43
|
import { Type as Type$1 } from "@bastani/atomic-ai/utils/typebox/index";
|
|
43
44
|
import { ModelRegistry } from "../core/model-registry.js";
|
|
@@ -2478,6 +2479,8 @@ async function entryByteLengthOf(database) {
|
|
|
2478
2479
|
const STATEMENT_BATCH_BYTES = 1048576;
|
|
2479
2480
|
/** The most sessions whose last written row a store remembers for appends through the append function. */
|
|
2480
2481
|
const WRITTEN_ROWS = 64;
|
|
2482
|
+
/** Larger sessions use the existing database indexes rather than retaining their IDs in the writer. */
|
|
2483
|
+
const WRITTEN_PARENT_POSITIONS = 16384;
|
|
2481
2484
|
/** About how many bytes `statement` carries: its text and its parameters. */
|
|
2482
2485
|
function statementBytes(statement) {
|
|
2483
2486
|
let bytes = statement.sql.length;
|
|
@@ -2687,6 +2690,7 @@ var SqlSessionStore = class SqlSessionStore {
|
|
|
2687
2690
|
this.entryByteLength = entryByteLength;
|
|
2688
2691
|
this.tables = tables;
|
|
2689
2692
|
this.prefix = prefix ?? "";
|
|
2693
|
+
setUsageObservationStore(this, new UsageObservationStore(database, prefix));
|
|
2690
2694
|
registerForkScope(this, () => {
|
|
2691
2695
|
const identity = this.database.databaseIdentity?.();
|
|
2692
2696
|
return {
|
|
@@ -2986,7 +2990,7 @@ var SqlSessionStore = class SqlSessionStore {
|
|
|
2986
2990
|
searchUnavailable = true;
|
|
2987
2991
|
});
|
|
2988
2992
|
await Promise.allSettled([entryByteLengthPromise]);
|
|
2989
|
-
await flushStorageSchemaSetups(database, ledger);
|
|
2993
|
+
await flushStorageSchemaSetups(database, ledger, "intercom-");
|
|
2990
2994
|
searchIndex = searchUnavailable ? void 0 : openedSearch;
|
|
2991
2995
|
shared = createdShared;
|
|
2992
2996
|
if (!shared && database.readOnly !== true) {
|
|
@@ -3011,7 +3015,7 @@ var SqlSessionStore = class SqlSessionStore {
|
|
|
3011
3015
|
searchUnavailable = true;
|
|
3012
3016
|
})]);
|
|
3013
3017
|
await Promise.allSettled([entryByteLengthPromise]);
|
|
3014
|
-
await flushStorageSchemaSetups(database, ledger);
|
|
3018
|
+
await flushStorageSchemaSetups(database, ledger, "intercom-");
|
|
3015
3019
|
blobs = openedBlobs;
|
|
3016
3020
|
searchIndex = searchUnavailable ? void 0 : openedSearch;
|
|
3017
3021
|
if (shared) await ensureForkInheritedBlobGuard(database, snapshotIndexTables$1(options.prefix), forkTables.forkSegments, ledger);
|
|
@@ -3432,10 +3436,12 @@ var SqlSessionStore = class SqlSessionStore {
|
|
|
3432
3436
|
async create(header, entries) {
|
|
3433
3437
|
return this.writing(header.id, this.writeCreate(header, entries));
|
|
3434
3438
|
}
|
|
3435
|
-
async writeCreate(header,
|
|
3439
|
+
async writeCreate(header, input) {
|
|
3436
3440
|
this.assertOpen();
|
|
3437
3441
|
validateSessionHeader(header);
|
|
3438
|
-
validateSessionEntries(
|
|
3442
|
+
validateSessionEntries(input);
|
|
3443
|
+
const prepared = repairSessionParentWrites(header.id, input);
|
|
3444
|
+
const entries = prepared.entries;
|
|
3439
3445
|
const existing = this.newSessionRead(header.id);
|
|
3440
3446
|
let written = [];
|
|
3441
3447
|
let writtenRow;
|
|
@@ -3458,8 +3464,15 @@ var SqlSessionStore = class SqlSessionStore {
|
|
|
3458
3464
|
};
|
|
3459
3465
|
}, this.sessionWrite(header.id, existing));
|
|
3460
3466
|
this.noteWritten(header.id, created.epoch, written);
|
|
3467
|
+
if (this.appendFunction !== void 0 && writtenRow !== void 0 && entries.length <= WRITTEN_PARENT_POSITIONS) writtenRow = {
|
|
3468
|
+
...writtenRow,
|
|
3469
|
+
parents: new SessionParentIndex(entries)
|
|
3470
|
+
};
|
|
3461
3471
|
this.rememberWritten(header.id, writtenRow);
|
|
3462
|
-
return
|
|
3472
|
+
return {
|
|
3473
|
+
...created,
|
|
3474
|
+
...repairedWriteResult(prepared)
|
|
3475
|
+
};
|
|
3463
3476
|
}
|
|
3464
3477
|
/**
|
|
3465
3478
|
* The read that begins a transaction writing a new session `id`, by `create` or by a fork: whether it exists and, where
|
|
@@ -3511,6 +3524,22 @@ var SqlSessionStore = class SqlSessionStore {
|
|
|
3511
3524
|
}
|
|
3512
3525
|
async writeCreateFork(header, entries, source) {
|
|
3513
3526
|
if (this.create !== SqlSessionStore.prototype.create) return void 0;
|
|
3527
|
+
if (!("read" in entries)) {
|
|
3528
|
+
validateSessionEntries(entries);
|
|
3529
|
+
const prepared = repairSessionParentWrites(header.id, entries);
|
|
3530
|
+
if (prepared.repaired.length > 0) {
|
|
3531
|
+
const repaired = { async *read() {
|
|
3532
|
+
for (const [index, entry] of entries.entries()) yield pairedForkEntry({
|
|
3533
|
+
entry,
|
|
3534
|
+
reference: source.receipts.get(entry.id)
|
|
3535
|
+
}, prepared.entries[index]);
|
|
3536
|
+
} };
|
|
3537
|
+
return {
|
|
3538
|
+
...this.sharesTablesWith(source.store) ? await this.createStreamedFork(header, repaired, source) : await this.createStagedFork(header, repaired, source),
|
|
3539
|
+
...repairedWriteResult(prepared)
|
|
3540
|
+
};
|
|
3541
|
+
}
|
|
3542
|
+
}
|
|
3514
3543
|
if (!this.sharesTablesWith(source.store)) {
|
|
3515
3544
|
if ("read" in entries) return entries.kind === "complete-session" ? this.createStagedFork(header, entries, source) : void 0;
|
|
3516
3545
|
if (source.receipts.size < 2) return void 0;
|
|
@@ -3524,7 +3553,6 @@ var SqlSessionStore = class SqlSessionStore {
|
|
|
3524
3553
|
if ("read" in entries) return this.createStreamedFork(header, entries, source);
|
|
3525
3554
|
this.assertOpen();
|
|
3526
3555
|
validateSessionHeader(header);
|
|
3527
|
-
validateSessionEntries(entries);
|
|
3528
3556
|
if (source.receipts.size === 0 && source.hashes.length === 0 && (!this.sharedHistorySeen || source.epoch === void 0)) return void 0;
|
|
3529
3557
|
for (let attempt = 0, ordered = false;; attempt++) {
|
|
3530
3558
|
const reads = this.sharedHistorySeen ? this.sharedForkReads(header.id, source.sessionId, false, ordered) : void 0;
|
|
@@ -3889,7 +3917,7 @@ var SqlSessionStore = class SqlSessionStore {
|
|
|
3889
3917
|
header,
|
|
3890
3918
|
entries: [],
|
|
3891
3919
|
lastSeq
|
|
3892
|
-
}, summary, index),
|
|
3920
|
+
}, summary, index, lastSeq),
|
|
3893
3921
|
create: (header, entries) => this.create(header, entries),
|
|
3894
3922
|
newSessionRead: (id) => this.newSessionRead(id),
|
|
3895
3923
|
startNewSession: async (tx, id, found) => {
|
|
@@ -4028,7 +4056,7 @@ var SqlSessionStore = class SqlSessionStore {
|
|
|
4028
4056
|
const captured = !atHead && cached?.sessionId === source.sessionId && cached.index.seq === prefix.through && cached.index.epoch === shared.epoch ? cached : void 0;
|
|
4029
4057
|
const state = atHead ? shared.state : captured === void 0 ? void 0 : JSON.parse(captured.state);
|
|
4030
4058
|
const index = captured?.index ?? (state === void 0 ? void 0 : windowIndex(state, prefix.through));
|
|
4031
|
-
if (state !== void 0 && index !== void 0) return this.writeSharedPrefixFork(tx, header, source.sessionId, shared, state, index);
|
|
4059
|
+
if (state !== void 0 && index !== void 0 && (state.parentLinksCheckedThrough ?? -1) >= prefix.through) return this.writeSharedPrefixFork(tx, header, source.sessionId, shared, state, index);
|
|
4032
4060
|
}
|
|
4033
4061
|
const { encodedForkRow } = await import("../core/storage/session/fork-row-bytes.code.js").catch((error) => __atomicOnDemandFailed(error, "session storage"));
|
|
4034
4062
|
const { foldForkRow } = await import("../core/storage/session/fork-row-index.code.js").catch((error) => __atomicOnDemandFailed(error, "session storage"));
|
|
@@ -4062,6 +4090,7 @@ var SqlSessionStore = class SqlSessionStore {
|
|
|
4062
4090
|
let summary = applySessionSummaryEntries(void 0, []).state;
|
|
4063
4091
|
let index = foldSessionResume(void 0, []);
|
|
4064
4092
|
let seq = 0;
|
|
4093
|
+
const repairer = new SessionParentRepairer(header.id);
|
|
4065
4094
|
const hashes = /* @__PURE__ */ new Set();
|
|
4066
4095
|
const inlineSnapshot = async (ref) => {
|
|
4067
4096
|
const text = (key) => this.dialect.jsonText("entry_json", key);
|
|
@@ -4088,9 +4117,10 @@ var SqlSessionStore = class SqlSessionStore {
|
|
|
4088
4117
|
let copiedRows = false;
|
|
4089
4118
|
const ownSeqs = [];
|
|
4090
4119
|
const remainingBlobs = await writes.around(async () => {
|
|
4091
|
-
for await (const
|
|
4120
|
+
for await (const original of stream.read(reader, async (id) => await lookup(id) !== void 0, inlineSnapshot)) {
|
|
4121
|
+
const entry = repairer.repair(original.entry, seq + 1, original.parentRecordedLater);
|
|
4122
|
+
const row = pairedForkEntry(original, entry);
|
|
4092
4123
|
index = await foldForkRow(index, row, lookup);
|
|
4093
|
-
const entry = row.entry;
|
|
4094
4124
|
const listed = applySessionSummaryEntries(summary, [entry]);
|
|
4095
4125
|
summary = listed.state;
|
|
4096
4126
|
const unchanged = row.stored?.sessionId === source.sessionId && row.edits === void 0;
|
|
@@ -4158,7 +4188,7 @@ var SqlSessionStore = class SqlSessionStore {
|
|
|
4158
4188
|
header,
|
|
4159
4189
|
entries: [],
|
|
4160
4190
|
lastSeq: seq
|
|
4161
|
-
}, summary, index);
|
|
4191
|
+
}, summary, index, seq);
|
|
4162
4192
|
last.push(statement.statement);
|
|
4163
4193
|
if (!copiedRows && hashes.size === 0) {
|
|
4164
4194
|
last.push(this.forkVersionStep(header.id));
|
|
@@ -4181,7 +4211,8 @@ var SqlSessionStore = class SqlSessionStore {
|
|
|
4181
4211
|
return {
|
|
4182
4212
|
lastSeq: seq,
|
|
4183
4213
|
epoch: remainingBlobs.epoch,
|
|
4184
|
-
remainingBlobs: remainingBlobs.remaining
|
|
4214
|
+
remainingBlobs: remainingBlobs.remaining,
|
|
4215
|
+
...repairer.repaired.length > 0 ? { repaired: repairer.repaired } : {}
|
|
4185
4216
|
};
|
|
4186
4217
|
}
|
|
4187
4218
|
/**
|
|
@@ -4317,7 +4348,7 @@ var SqlSessionStore = class SqlSessionStore {
|
|
|
4317
4348
|
}, {
|
|
4318
4349
|
...index,
|
|
4319
4350
|
epoch
|
|
4320
|
-
});
|
|
4351
|
+
}, through);
|
|
4321
4352
|
const lineage = this.lineageTables();
|
|
4322
4353
|
assertForkSegments(header.id, segments, through);
|
|
4323
4354
|
const statements = [
|
|
@@ -4378,17 +4409,32 @@ var SqlSessionStore = class SqlSessionStore {
|
|
|
4378
4409
|
async append(sessionId, entries, options) {
|
|
4379
4410
|
return this.writing(sessionId, this.writeAppend(sessionId, entries, options));
|
|
4380
4411
|
}
|
|
4381
|
-
async writeAppend(sessionId,
|
|
4412
|
+
async writeAppend(sessionId, input, options) {
|
|
4382
4413
|
this.assertOpen();
|
|
4383
4414
|
validateSessionText("sessionId", sessionId);
|
|
4384
|
-
const fast = await this.appendThroughFunction(sessionId,
|
|
4415
|
+
const fast = await this.appendThroughFunction(sessionId, input, options);
|
|
4385
4416
|
if (fast !== void 0) return fast;
|
|
4417
|
+
validateSessionEntries(input);
|
|
4418
|
+
const wanted = /* @__PURE__ */ new Set();
|
|
4419
|
+
for (const { id, parentId } of input) {
|
|
4420
|
+
wanted.add(id);
|
|
4421
|
+
if (parentId !== null) wanted.add(parentId);
|
|
4422
|
+
}
|
|
4423
|
+
const candidates = [...wanted];
|
|
4424
|
+
const leading = this.headRead(sessionId, options, true, true, this.parentFacts(sessionId, candidates));
|
|
4386
4425
|
let written = [];
|
|
4387
4426
|
let writtenRow;
|
|
4388
4427
|
const appended = await this.transactionCheckedAlongside(async (tx, checked) => {
|
|
4389
4428
|
writtenRow = void 0;
|
|
4390
|
-
const { row: previous, state: summaryState } = await this.forWrite(tx, sessionId, options, true, true);
|
|
4391
|
-
|
|
4429
|
+
const { row: previous, state: summaryState } = await this.forWrite(tx, sessionId, options, true, true, leading);
|
|
4430
|
+
const forked = previous.forked !== void 0 ? Number(previous.forked) === 1 : await this.sharedHistoryForks(tx) && await this.hasForkSegments(tx, sessionId);
|
|
4431
|
+
let facts = previous.parent_facts;
|
|
4432
|
+
if (forked && candidates.length > 0) {
|
|
4433
|
+
const statement = this.parentFacts(sessionId, candidates, await this.viewTables(tx, sessionId));
|
|
4434
|
+
facts = (await tx.get(statement.sql, ...statement.params))?.parent_facts;
|
|
4435
|
+
}
|
|
4436
|
+
const prepared = await this.repairAppendParents(tx, sessionId, input, previous.last_seq, facts);
|
|
4437
|
+
const entries = prepared.entries;
|
|
4392
4438
|
await this.blobTable.assertStored(tx, entries.flatMap((entry) => entry.type === "worktree_snapshot" && entry.snapshot !== void 0 ? [entry.snapshot] : []));
|
|
4393
4439
|
const lastSeq = previous.last_seq + entries.length;
|
|
4394
4440
|
const summary = this.summaryWrite(sessionId, {
|
|
@@ -4399,18 +4445,19 @@ var SqlSessionStore = class SqlSessionStore {
|
|
|
4399
4445
|
written = [];
|
|
4400
4446
|
const statements = this.entryWrites(sessionId, entries, previous.last_seq, summary.texts, true, written);
|
|
4401
4447
|
await checked;
|
|
4402
|
-
const forked = previous.forked !== void 0 ? Number(previous.forked) === 1 : await this.sharedHistoryForks(tx) && await this.hasForkSegments(tx, sessionId);
|
|
4403
4448
|
writtenRow = forked ? void 0 : summary.row;
|
|
4404
4449
|
const links = forked ? entries.map((_, index) => this.forkLinks().entry(sessionId, previous.last_seq + index + 1)) : [];
|
|
4405
4450
|
await this.writeEntries(tx, summary.statement, links.length === 0 ? statements : thenAll(statements, links));
|
|
4406
4451
|
return {
|
|
4407
4452
|
lastSeq,
|
|
4408
|
-
epoch: summary.epoch
|
|
4453
|
+
epoch: summary.epoch,
|
|
4454
|
+
...repairedWriteResult(prepared)
|
|
4409
4455
|
};
|
|
4410
|
-
}, this.sessionWrite(sessionId,
|
|
4456
|
+
}, this.sessionWrite(sessionId, leading));
|
|
4411
4457
|
this.noteWritten(sessionId, appended.epoch, written);
|
|
4412
4458
|
this.rememberWritten(sessionId, writtenRow);
|
|
4413
|
-
|
|
4459
|
+
const { epoch: _epoch, ...result } = appended;
|
|
4460
|
+
return result;
|
|
4414
4461
|
}
|
|
4415
4462
|
/**
|
|
4416
4463
|
* Remembers `row`, the session's row a committed write of this store left, for the next append to plan from, where
|
|
@@ -4441,13 +4488,15 @@ var SqlSessionStore = class SqlSessionStore {
|
|
|
4441
4488
|
if (previous.last_seq !== options.expectSeq) return void 0;
|
|
4442
4489
|
const state = JSON.parse(previous.summary_state);
|
|
4443
4490
|
if (options.epoch !== void 0 && state.epoch !== options.epoch) return void 0;
|
|
4491
|
+
const window = windowIndex(state, previous.last_seq);
|
|
4492
|
+
if (isSessionResumeIndex(window, previous.last_seq) && foreignResumeIds(window, entries).length > 0) return void 0;
|
|
4493
|
+
const parents = previous.parents;
|
|
4444
4494
|
try {
|
|
4445
4495
|
validateSessionEntries(entries);
|
|
4496
|
+
validateSessionParentWrites(entries, previous.last_seq, (id) => parents?.positions.get(id) ?? (id === previous.lastEntryId ? previous.last_seq : void 0), parents?.detached);
|
|
4446
4497
|
} catch {
|
|
4447
4498
|
return;
|
|
4448
4499
|
}
|
|
4449
|
-
const window = windowIndex(state, previous.last_seq);
|
|
4450
|
-
if (isSessionResumeIndex(window, previous.last_seq) && foreignResumeIds(window, entries).length > 0) return void 0;
|
|
4451
4500
|
const lastSeq = previous.last_seq + entries.length;
|
|
4452
4501
|
const summary = this.summaryWrite(sessionId, {
|
|
4453
4502
|
header: JSON.parse(previous.header_json),
|
|
@@ -4472,13 +4521,17 @@ var SqlSessionStore = class SqlSessionStore {
|
|
|
4472
4521
|
const texts = summary.texts.map(({ index, text }) => [previous.last_seq + index + 1, this.encode(text)]);
|
|
4473
4522
|
const blobs = this.blobTable.storedHashes(entries.flatMap((entry) => entry.type === "worktree_snapshot" && entry.snapshot !== void 0 ? [entry.snapshot] : []));
|
|
4474
4523
|
const { concurrency = { kind: "serial" } } = sessionWriteTransaction(this.tables.sessions, sessionId);
|
|
4524
|
+
const facts = parents === void 0 ? this.parentFacts(sessionId, entries.map(({ id }) => id)) : void 0;
|
|
4525
|
+
const rest = Array.from({ length: 20 }, () => "?").join(", ");
|
|
4475
4526
|
const [answer] = await autocommit({
|
|
4476
|
-
sql: `SELECT outcome, detail FROM ${fn}(${
|
|
4527
|
+
sql: facts === void 0 ? `SELECT outcome, detail FROM ${fn}(?, ?, ?, ?, ${rest})` : `WITH ready AS MATERIALIZED (SELECT CAST(? AS text) AS session_id WHERE (${facts.sql}) = '[]')
|
|
4528
|
+
SELECT outcome, detail FROM ready CROSS JOIN LATERAL ${fn}(?, ?, ?, ready.session_id, ${rest})`,
|
|
4477
4529
|
params: [
|
|
4530
|
+
...facts === void 0 ? [] : [sessionId, ...facts.params],
|
|
4478
4531
|
concurrency.kind === "serial" ? concurrency.domain ?? "" : "",
|
|
4479
4532
|
SESSION_SCHEMA_VERSION_UNCHUNKED,
|
|
4480
4533
|
3,
|
|
4481
|
-
sessionId,
|
|
4534
|
+
...facts === void 0 ? [sessionId] : [],
|
|
4482
4535
|
previous.last_seq,
|
|
4483
4536
|
previous.revision,
|
|
4484
4537
|
await sha256Hex(new TextEncoder().encode(`${previous.header_json}\n${previous.summary_state}`)),
|
|
@@ -4491,7 +4544,13 @@ var SqlSessionStore = class SqlSessionStore {
|
|
|
4491
4544
|
switch (answer?.outcome) {
|
|
4492
4545
|
case "appended":
|
|
4493
4546
|
this.noteWritten(sessionId, summary.epoch, written);
|
|
4494
|
-
|
|
4547
|
+
if (parents !== void 0 && lastSeq <= WRITTEN_PARENT_POSITIONS) {
|
|
4548
|
+
for (const { entry, seq } of written) parents.note(entry, seq);
|
|
4549
|
+
this.rememberWritten(sessionId, {
|
|
4550
|
+
...summary.row,
|
|
4551
|
+
parents
|
|
4552
|
+
});
|
|
4553
|
+
} else this.rememberWritten(sessionId, summary.row);
|
|
4495
4554
|
return { lastSeq };
|
|
4496
4555
|
case "version":
|
|
4497
4556
|
assertStorageSchemaVersion("sessions", answer.detail === null ? null : Number(answer.detail), 3, SESSION_SCHEMA_VERSION_UNCHUNKED);
|
|
@@ -4639,6 +4698,7 @@ $grant$`);
|
|
|
4639
4698
|
await checked;
|
|
4640
4699
|
validateSessionHeader(header);
|
|
4641
4700
|
validateSessionEntries(entries);
|
|
4701
|
+
const prepared = repairSessionParentWrites(sessionId, entries);
|
|
4642
4702
|
if (header.id !== sessionId) throw new SessionIdMismatchError$1(sessionId, header.id);
|
|
4643
4703
|
if (pins !== void 0) released = await replaceForkedSessionWithin(this.forkHost(), tx, sessionId, pins, lockLate).catch((error) => {
|
|
4644
4704
|
noteForkCopyRefusal(error, "replace");
|
|
@@ -4647,13 +4707,14 @@ $grant$`);
|
|
|
4647
4707
|
await this.searchIndex?.forgetWithin(tx, sessionId);
|
|
4648
4708
|
const summary = this.summaryWrite(sessionId, {
|
|
4649
4709
|
header,
|
|
4650
|
-
entries,
|
|
4710
|
+
entries: prepared.entries,
|
|
4651
4711
|
lastSeq: entries.length
|
|
4652
4712
|
});
|
|
4653
|
-
await this.writeEntries(tx, summary.statement, withRest(this.sessionRowDeletes(sessionId), this.entryWrites(sessionId, entries, 0, summary.texts, true, entriesWritten)));
|
|
4713
|
+
await this.writeEntries(tx, summary.statement, withRest(this.sessionRowDeletes(sessionId), this.entryWrites(sessionId, prepared.entries, 0, summary.texts, true, entriesWritten)));
|
|
4654
4714
|
return {
|
|
4655
4715
|
lastSeq: entries.length,
|
|
4656
|
-
epoch: summary.epoch
|
|
4716
|
+
epoch: summary.epoch,
|
|
4717
|
+
...repairedWriteResult(prepared)
|
|
4657
4718
|
};
|
|
4658
4719
|
}, this.sessionWrite(sessionId, ...searchLock === void 0 ? [] : [searchLock], ...pinReads === void 0 ? [] : [this.headRead(sessionId, options, false), ...pinReads]));
|
|
4659
4720
|
let written;
|
|
@@ -4699,10 +4760,6 @@ $grant$`);
|
|
|
4699
4760
|
async load(sessionId) {
|
|
4700
4761
|
this.assertOpen();
|
|
4701
4762
|
validateSessionText("sessionId", sessionId);
|
|
4702
|
-
if (hasHistoryLoadObserver()) {
|
|
4703
|
-
const row = await this.database.get(`SELECT last_seq FROM ${this.tables.sessions} WHERE id = ?`, sessionId);
|
|
4704
|
-
if (row) announceHistoryLoad(row.last_seq);
|
|
4705
|
-
}
|
|
4706
4763
|
let generation = this.generation(sessionId);
|
|
4707
4764
|
let guessedPlain = false;
|
|
4708
4765
|
return this.readTransaction(sessionId, (tx) => this.read(tx, sessionId, generation, guessedPlain), () => {
|
|
@@ -5126,6 +5183,7 @@ $grant$`);
|
|
|
5126
5183
|
this.scopes.clear();
|
|
5127
5184
|
this.summaries.clear();
|
|
5128
5185
|
dropStoredNotes(this);
|
|
5186
|
+
await usageObservationStore(this)?.drain();
|
|
5129
5187
|
const reader = this.reader;
|
|
5130
5188
|
this.reader = void 0;
|
|
5131
5189
|
if (reader !== void 0) await (await reader.catch(() => void 0))?.close();
|
|
@@ -5493,7 +5551,10 @@ $grant$`);
|
|
|
5493
5551
|
...shared,
|
|
5494
5552
|
segments: void 0
|
|
5495
5553
|
} : shared;
|
|
5496
|
-
const epoch = head.then((found) =>
|
|
5554
|
+
const epoch = head.then((found) => {
|
|
5555
|
+
if (found && hasHistoryLoadObserver()) announceHistoryLoad(Number(found.last_seq));
|
|
5556
|
+
return guess.segments === void 0 && shared.segments !== void 0 && Number(found?.forked) === 1 ? void 0 : found?.epoch;
|
|
5557
|
+
});
|
|
5497
5558
|
let [row, rows] = await Promise.all([head, this.readRows(tx, sessionId, void 0, void 0, epoch, guess)]);
|
|
5498
5559
|
if (!row) throw new SessionNotFoundError$1(sessionId);
|
|
5499
5560
|
this.noteForked(tx, sessionId, row.forked);
|
|
@@ -5785,6 +5846,7 @@ $grant$`);
|
|
|
5785
5846
|
"taskId",
|
|
5786
5847
|
"terminalStatus"
|
|
5787
5848
|
];
|
|
5849
|
+
const toolOutputHash = `CASE WHEN ${j("customType")} = 'atomic.tool-output' AND ${jsonType("data", "hash")} = '${sqlite ? "text" : "string"}' THEN ${j("data", "hash")} END`;
|
|
5788
5850
|
const op = `CASE WHEN ${jsonType("data", "op")} = '${sqlite ? "text" : "string"}' THEN ${j("data", "op")} END`;
|
|
5789
5851
|
const deliveryOp = `chunks > 0 AND ${j("type")} = 'custom' AND ${j("customType")} = 'atomic-pooled-delivery-op'`;
|
|
5790
5852
|
const dataExpr = this.dialect.jsonObject([
|
|
@@ -5793,6 +5855,7 @@ $grant$`);
|
|
|
5793
5855
|
"index",
|
|
5794
5856
|
"timestamp"
|
|
5795
5857
|
].includes(key) ? `CASE WHEN ${jsonType("data", key)} IN ('integer','real','number') THEN CAST(${j("data", key)} AS ${this.dialect.types.real}) END` : key === "runId" ? `CASE WHEN ${j("customType")} NOT IN ('workflow.run.start','workflow.run.end') OR ${jsonType("data", key)} = '${sqlite ? "text" : "string"}' THEN ${j("data", key)} END` : j("data", key)]),
|
|
5858
|
+
["hash", toolOutputHash],
|
|
5796
5859
|
["name", `CASE WHEN ${jsonType("data", "name")} = '${sqlite ? "text" : "string"}' THEN '' END`],
|
|
5797
5860
|
["ts", `CASE WHEN ${jsonType("data", "ts")} IN ('integer','real','number') THEN 0 END`],
|
|
5798
5861
|
["message", this.dialect.jsonObject([
|
|
@@ -5900,6 +5963,7 @@ $grant$`);
|
|
|
5900
5963
|
const stubPage = `${page}, payloads AS (SELECT seq,entry_id,-chunks AS chunks,entry_json FROM page) ${projection}`;
|
|
5901
5964
|
let topology = currentIndex && requested !== void 0 ? branchRanges(currentIndex, requested) : void 0;
|
|
5902
5965
|
for (let pass = topology === void 0 ? 0 : 1; pass < 2; pass++) {
|
|
5966
|
+
const unresolvedParents = new LaterSessionParents();
|
|
5903
5967
|
for (let after = 0; after < limit;) {
|
|
5904
5968
|
const view = this.entriesView(tables, sessionId, after, Math.min(limit, after + SESSION_RESUME_REBUILD.pageEntries));
|
|
5905
5969
|
const args = [
|
|
@@ -6003,10 +6067,10 @@ $grant$`);
|
|
|
6003
6067
|
const old = index ?? foldSessionResume(void 0, []);
|
|
6004
6068
|
const seqs = /* @__PURE__ */ new Map();
|
|
6005
6069
|
for (const id of foreignResumeIds(old, batch)) {
|
|
6006
|
-
const seq = await this.seqOfEntry(this.database, void 0, sessionId, id);
|
|
6070
|
+
const seq = await this.seqOfEntry(this.database, void 0, sessionId, id, old.seq);
|
|
6007
6071
|
if (seq !== void 0) seqs.set(id, seq);
|
|
6008
6072
|
}
|
|
6009
|
-
index = foldSessionResume(index, batch, (id) => seqs.get(id), (seq) => topology === void 0 || topology.some(([a, b]) => seq >= a && seq <= b));
|
|
6073
|
+
index = foldSessionResume(index, batch, (id) => seqs.get(id), (seq) => topology === void 0 || topology.some(([a, b]) => seq >= a && seq <= b), unresolvedParents);
|
|
6010
6074
|
if (toolCalls > 0) index = {
|
|
6011
6075
|
...index,
|
|
6012
6076
|
totals: {
|
|
@@ -6194,6 +6258,7 @@ $grant$`);
|
|
|
6194
6258
|
CASE WHEN ${role}='assistant' AND COALESCE(${j("message", "stopReason")},'') IN ('','toolUse','stop') AND CASE WHEN ${ctype}='array' THEN NOT ${hasText} WHEN ${ctype}='${sqlite ? "text" : "string"}' THEN length(${trim}(${content},?))=0 ELSE TRUE END THEN 1 ELSE 0 END hidden,
|
|
6195
6259
|
CASE WHEN ${j("type")}='custom' AND ${j("customType")}='atomic.leaf' THEN 1 ELSE 0 END leaf_move,
|
|
6196
6260
|
CASE WHEN ${j("type")}='custom' AND ${j("customType")}='subagent-child' THEN 1 ELSE 0 END child_record,
|
|
6261
|
+
CASE WHEN ${j("type")}='custom' AND ${j("customType")}='atomic.tool-output' AND ${this.dialect.jsonHasType("text", "entry_json", "data", "hash")} THEN ${j("data", "hash")} END tool_output_hash,
|
|
6197
6262
|
CASE WHEN ${j("type")}='label' THEN ${j("targetId")} END target,CASE WHEN ${j("type")}='label' THEN substr(${j("label")},1,128) END label
|
|
6198
6263
|
FROM ${view.name} WHERE session_id=? AND seq BETWEEN ? AND ? ORDER BY seq LIMIT ?`), ...view.params, whites, whites, sessionId, fromSeq, toSeq, 64)).map((row) => Number(row.chunks) > 0 ? {
|
|
6199
6264
|
seq: Number(row.seq),
|
|
@@ -6209,6 +6274,7 @@ $grant$`);
|
|
|
6209
6274
|
...typeof row.calls === "string" && row.calls !== "[]" ? { callIds: JSON.parse(row.calls) } : {},
|
|
6210
6275
|
...Number(row.leaf_move) === 1 ? { leafMove: true } : {},
|
|
6211
6276
|
...Number(row.child_record) === 1 ? { childRecord: true } : {},
|
|
6277
|
+
...typeof row.tool_output_hash === "string" && /^[0-9a-f]{64}$/.test(row.tool_output_hash) ? { toolOutputHash: row.tool_output_hash } : {},
|
|
6212
6278
|
...typeof row.target === "string" ? {
|
|
6213
6279
|
labelTarget: row.target,
|
|
6214
6280
|
label: typeof row.label === "string" ? row.label : void 0
|
|
@@ -6216,38 +6282,79 @@ $grant$`);
|
|
|
6216
6282
|
});
|
|
6217
6283
|
});
|
|
6218
6284
|
}
|
|
6219
|
-
/** Sparse
|
|
6285
|
+
/** Sparse, byte-bounded archive page: one statement reads its fence, sizes, and only the bodies that fit. */
|
|
6220
6286
|
async readSelectedPage(sessionId, seqs, epoch, options = {}) {
|
|
6221
6287
|
this.assertOpen();
|
|
6222
6288
|
const limit = entrySizeLimit(options.limit);
|
|
6223
6289
|
const wanted = options.backward ? seqs.slice(-limit) : seqs.slice(0, limit);
|
|
6224
6290
|
if (!wanted.length) return { items: [] };
|
|
6225
|
-
|
|
6291
|
+
const unfinished = this.unfinishedWrites.get(sessionId);
|
|
6292
|
+
if (unfinished !== void 0) await Promise.all(unfinished);
|
|
6293
|
+
const database = await this.readerDatabase();
|
|
6294
|
+
const generation = this.generation(sessionId);
|
|
6295
|
+
const shared = this.sharedHistorySeen;
|
|
6296
|
+
const plain = shared && this.forkedSessions.get(sessionId) === false;
|
|
6297
|
+
const valid = wanted.filter((seq) => Number.isSafeInteger(seq) && seq > 0);
|
|
6298
|
+
const view = this.entriesView({
|
|
6299
|
+
segments: shared && !plain ? this.forkTables.forkSegments : void 0,
|
|
6300
|
+
dialect: this.dialect
|
|
6301
|
+
}, sessionId, valid.length ? Math.min(...valid) - 1 : 0, valid.length ? Math.max(...valid) : 0);
|
|
6302
|
+
const forked = this.outsideForkedColumn("id");
|
|
6303
|
+
const tail = `(SELECT length(data) FROM ${this.tables.entryChunks} c WHERE c.session_id=e.src_id AND c.seq=e.src_seq AND c.idx=e.chunks-1)`;
|
|
6304
|
+
const rows = await database.all(withForkViews([view], `WITH sized AS MATERIALIZED (
|
|
6305
|
+
SELECT e.seq,e.chunks,e.src_id,e.src_seq,CASE WHEN e.chunks=0 THEN ${this.entryByteLength("e.entry_json")}
|
|
6306
|
+
ELSE (e.chunks-1)*?+${tail} END AS bytes
|
|
6307
|
+
FROM ${view.name} e WHERE ${inJsonList(this.dialect, "e.seq", true)}
|
|
6308
|
+
), packet AS (
|
|
6309
|
+
SELECT *,sum(bytes) OVER (ORDER BY seq ${options.backward ? "DESC" : "ASC"}) AS total FROM sized
|
|
6310
|
+
)
|
|
6311
|
+
SELECT 0 AS seq,NULL AS bytes,NULL AS body,last_seq,revision,${generation.sql} AS epoch,
|
|
6312
|
+
(SELECT schema_version FROM ${this.tables.meta} LIMIT 1) AS schema_version${forked}
|
|
6313
|
+
FROM ${this.tables.sessions} WHERE id = ?
|
|
6314
|
+
UNION ALL
|
|
6315
|
+
SELECT p.seq,p.bytes,CASE WHEN p.chunks=0 AND p.total<=? THEN
|
|
6316
|
+
(SELECT e.entry_json FROM ${this.tables.entries} e WHERE e.session_id=p.src_id AND e.seq=p.src_seq) END,
|
|
6317
|
+
NULL,NULL,NULL,NULL${forked === "" ? "" : ",NULL"}
|
|
6318
|
+
FROM packet p ORDER BY seq`), ...view.params, SESSION_ENTRY_CHUNK_BYTES, JSON.stringify(valid), ...generation.params, sessionId, SESSION_HISTORY_PAGE_BYTES);
|
|
6319
|
+
const head = rows[0];
|
|
6320
|
+
if (!head || Number(head.seq) !== 0) throw new SessionNotFoundError$1(sessionId);
|
|
6321
|
+
assertStorageSchemaVersion("sessions", head.schema_version, 3, SESSION_SCHEMA_VERSION_UNCHUNKED);
|
|
6322
|
+
this.noteSchemaVersion(head.schema_version);
|
|
6323
|
+
this.noteForked(void 0, sessionId, head.forked);
|
|
6324
|
+
if (this.sharedHistorySeen !== shared || plain && Number(head.forked) === 1) return this.readSelectedPage(sessionId, seqs, epoch, options);
|
|
6325
|
+
const lastSeq = Number(head.last_seq);
|
|
6326
|
+
this.noteGeneration(sessionId, head.revision, lastSeq, head.epoch);
|
|
6327
|
+
if (head.epoch !== epoch) throw new SessionConflictError$1(sessionId, wanted.at(-1), lastSeq);
|
|
6328
|
+
const bySeq = new Map(rows.slice(1).map((row) => [Number(row.seq), row]));
|
|
6329
|
+
const plan = selectedPagePlan(sessionId, wanted, lastSeq, (seq) => {
|
|
6330
|
+
const bytes = bySeq.get(seq)?.bytes;
|
|
6331
|
+
if (bytes == null) throw new SessionConflictError$1(sessionId, wanted.at(-1), lastSeq);
|
|
6332
|
+
return Number(bytes);
|
|
6333
|
+
}, options.backward);
|
|
6334
|
+
if ("oversized" in plan) return {
|
|
6335
|
+
lastSeq,
|
|
6336
|
+
items: [{
|
|
6337
|
+
kind: "oversized",
|
|
6338
|
+
sessionId,
|
|
6339
|
+
epoch,
|
|
6340
|
+
...plan.oversized
|
|
6341
|
+
}]
|
|
6342
|
+
};
|
|
6343
|
+
if (plan.seqs.some((seq) => bySeq.get(seq)?.body == null)) return this.readTransaction(sessionId, async (tx) => {
|
|
6226
6344
|
const head = await this.historyHead(tx, sessionId, true);
|
|
6227
|
-
if (head.epoch !== epoch || head.lastSeq <
|
|
6228
|
-
const tail = `(SELECT length(data) FROM ${this.tables.entryChunks} c WHERE c.session_id=e.src_id AND c.seq=e.src_seq AND c.idx=e.chunks-1)`;
|
|
6229
|
-
const view = this.entriesView(await this.viewTables(tx, sessionId), sessionId, Math.min(...wanted) - 1, Math.max(...wanted));
|
|
6230
|
-
const rows = await tx.all(withForkViews([view], `SELECT seq,CASE WHEN chunks=0 THEN ${this.entryByteLength("entry_json")} ELSE (chunks-1)*?+${tail} END bytes FROM ${view.name} e WHERE session_id=? AND ${inJsonList(this.dialect, "seq", true)} ORDER BY seq`), ...view.params, SESSION_ENTRY_CHUNK_BYTES, sessionId, JSON.stringify(wanted));
|
|
6231
|
-
const sizes = new Map(rows.map((row) => [Number(row.seq), row.bytes == null ? void 0 : Number(row.bytes)]));
|
|
6232
|
-
const plan = selectedPagePlan(sessionId, wanted, head.lastSeq, (seq) => {
|
|
6233
|
-
const bytes = sizes.get(seq);
|
|
6234
|
-
if (bytes === void 0) throw new SessionConflictError$1(sessionId, wanted.at(-1), head.lastSeq);
|
|
6235
|
-
return bytes;
|
|
6236
|
-
}, options.backward);
|
|
6237
|
-
if ("oversized" in plan) return {
|
|
6238
|
-
lastSeq: head.lastSeq,
|
|
6239
|
-
items: [{
|
|
6240
|
-
kind: "oversized",
|
|
6241
|
-
sessionId,
|
|
6242
|
-
epoch,
|
|
6243
|
-
...plan.oversized
|
|
6244
|
-
}]
|
|
6245
|
-
};
|
|
6345
|
+
if (head.epoch !== epoch || head.lastSeq < lastSeq) throw new SessionConflictError$1(sessionId, lastSeq, head.lastSeq);
|
|
6246
6346
|
return {
|
|
6247
6347
|
lastSeq: head.lastSeq,
|
|
6248
6348
|
items: await this.readSeqs(tx, sessionId, plan.seqs)
|
|
6249
6349
|
};
|
|
6250
6350
|
});
|
|
6351
|
+
return {
|
|
6352
|
+
lastSeq,
|
|
6353
|
+
items: plan.seqs.map((seq) => ({
|
|
6354
|
+
seq,
|
|
6355
|
+
entry: JSON.parse(bySeq.get(seq).body)
|
|
6356
|
+
}))
|
|
6357
|
+
};
|
|
6251
6358
|
}
|
|
6252
6359
|
/** Compare finished subagents' captures without opening or reading their conversations. */
|
|
6253
6360
|
async readBranchSnapshotMetadata(sessionIds) {
|
|
@@ -6894,7 +7001,11 @@ $grant$`);
|
|
|
6894
7001
|
column: "entry_json",
|
|
6895
7002
|
element: "parsed"
|
|
6896
7003
|
} : { column: "entry_json" }, "data", "completionId")} THEN ${key("data", "completionId")} END`,
|
|
6897
|
-
key("message", "role")
|
|
7004
|
+
key("message", "role"),
|
|
7005
|
+
`CASE WHEN ${key("customType")} = 'atomic.tool-output' AND ${this.dialect.jsonAtIsText(pg ? {
|
|
7006
|
+
column: "entry_json",
|
|
7007
|
+
element: "parsed"
|
|
7008
|
+
} : { column: "entry_json" }, "data", "hash")} THEN ${key("data", "hash")} END`
|
|
6898
7009
|
]);
|
|
6899
7010
|
const view = this.entriesView(tables, sessionId, seqs[0] - 1, seqs.at(-1));
|
|
6900
7011
|
const parsed = (await tx.all(withForkViews([view], `WITH projected AS MATERIALIZED (SELECT seq,chunks,CAST(${projection} AS TEXT) AS link FROM ${view.name} ${pg ? `CROSS JOIN LATERAL (SELECT ${postgresJsonb("entry_json")} AS value OFFSET 0) AS parsed` : ""} WHERE session_id=? AND seq BETWEEN ? AND ?) SELECT seq,chunks,CASE WHEN ${this.dialect.textByteLength("link")}<=512 THEN link END AS link FROM projected ORDER BY seq`), ...view.params, sessionId, seqs[0], seqs.at(-1))).map((r) => ({
|
|
@@ -6918,13 +7029,14 @@ $grant$`);
|
|
|
6918
7029
|
const role = chunked ? roles.get(seq) : link?.[8];
|
|
6919
7030
|
if (!link || chunked && (link[2] === "custom" || link[2] === "compaction" || link[2] === "message" && role === void 0)) page.push(...await metadata([seq]));
|
|
6920
7031
|
else {
|
|
6921
|
-
const [id, parentId, type, customType, first, covered, strategy, completionId] = link;
|
|
7032
|
+
const [id, parentId, type, customType, first, covered, strategy, completionId, , hash] = link;
|
|
6922
7033
|
page.push({
|
|
6923
7034
|
seq,
|
|
6924
7035
|
id,
|
|
6925
7036
|
parentId,
|
|
6926
7037
|
type,
|
|
6927
7038
|
customType: customType ?? void 0,
|
|
7039
|
+
hash: hash ?? void 0,
|
|
6928
7040
|
completionId: completionId ?? void 0,
|
|
6929
7041
|
...type === "message" && role === "system" ? { system: true } : {},
|
|
6930
7042
|
...type === "compaction" && strategy === "verbatim-lines" ? { boundary: {
|
|
@@ -6935,7 +7047,7 @@ $grant$`);
|
|
|
6935
7047
|
}
|
|
6936
7048
|
}
|
|
6937
7049
|
return page;
|
|
6938
|
-
}, true, SESSION_READ_FETCH.max);
|
|
7050
|
+
}, (id, through) => this.seqOfEntry(tx, tables, sessionId, id, through), true, SESSION_READ_FETCH.max);
|
|
6939
7051
|
const labelBody = `CASE WHEN chunks=0 AND ${this.dialect.textByteLength("entry_json")}<=512 THEN entry_json END`;
|
|
6940
7052
|
return indexedForkWindow(header, selected.index, selected.leaf, (lo, hi) => this.readRows(tx, sessionId, {
|
|
6941
7053
|
from: lo,
|
|
@@ -7015,7 +7127,7 @@ $grant$`);
|
|
|
7015
7127
|
async resumeIn(tx, sessionId, header, index, options) {
|
|
7016
7128
|
const { leafSeq } = index;
|
|
7017
7129
|
const plan = sessionResumePlan(index, index.leafSeq, options?.deferChildRecords);
|
|
7018
|
-
announceHistoryLoad(plan.state.length + plan.branch.reduce((sum, [a, b]) => sum + b - a + 1, 0));
|
|
7130
|
+
if (hasHistoryLoadObserver()) announceHistoryLoad(plan.state.length + plan.branch.reduce((sum, [a, b]) => sum + b - a + 1, 0));
|
|
7019
7131
|
const [ranges, state, leaf] = await Promise.all([
|
|
7020
7132
|
Promise.all(plan.branch.map(([start, end]) => this.readRows(tx, sessionId, {
|
|
7021
7133
|
from: start,
|
|
@@ -7116,8 +7228,8 @@ $grant$`);
|
|
|
7116
7228
|
if (row === void 0) return [];
|
|
7117
7229
|
return [typeof row.data === "string" ? new TextEncoder().encode(row.data) : row.data];
|
|
7118
7230
|
}
|
|
7119
|
-
async forWrite(tx, sessionId, options, includeSummaryState = false, forked = false) {
|
|
7120
|
-
const read = this.headRead(sessionId, options, includeSummaryState, forked);
|
|
7231
|
+
async forWrite(tx, sessionId, options, includeSummaryState = false, forked = false, leading) {
|
|
7232
|
+
const read = leading ?? this.headRead(sessionId, options, includeSummaryState, forked);
|
|
7121
7233
|
const row = await tx.get(read.sql, ...read.params);
|
|
7122
7234
|
if (!row) throw new SessionNotFoundError$1(sessionId);
|
|
7123
7235
|
const state = row.summary_state === void 0 ? void 0 : JSON.parse(String(row.summary_state));
|
|
@@ -7131,13 +7243,89 @@ $grant$`);
|
|
|
7131
7243
|
* The read of the session's row that `forWrite` checks a write against; with `forked`, once this store has seen
|
|
7132
7244
|
* shared history, it also reads whether the session has fork segments (#6560).
|
|
7133
7245
|
*/
|
|
7134
|
-
headRead(sessionId, options, includeSummaryState, forked = false) {
|
|
7246
|
+
headRead(sessionId, options, includeSummaryState, forked = false, facts) {
|
|
7135
7247
|
return {
|
|
7136
|
-
sql: `SELECT header_json, last_seq${includeSummaryState || options.epoch !== void 0 ? ", summary_state" : ""}${forked ? this.outsideForkedColumn("id") : ""}
|
|
7248
|
+
sql: `SELECT header_json, last_seq${includeSummaryState || options.epoch !== void 0 ? ", summary_state" : ""}${forked ? this.outsideForkedColumn("id") : ""}${facts === void 0 ? "" : `, (${facts.sql}) AS parent_facts`}
|
|
7137
7249
|
FROM ${this.tables.sessions} WHERE id = ?`,
|
|
7138
|
-
params: [sessionId]
|
|
7250
|
+
params: [...facts?.params ?? [], sessionId]
|
|
7251
|
+
};
|
|
7252
|
+
}
|
|
7253
|
+
/** Indexed ID lookups and links that might become forward links if a new ID is published. */
|
|
7254
|
+
parentFacts(sessionId, candidates, logical) {
|
|
7255
|
+
if (candidates.length === 0) return void 0;
|
|
7256
|
+
const index = snapshotIndexTables$1(this.prefix);
|
|
7257
|
+
const { dialect } = this;
|
|
7258
|
+
const json = `CAST(${dialect.jsonGroupArray(dialect.jsonArray([
|
|
7259
|
+
"entry_id",
|
|
7260
|
+
"seq",
|
|
7261
|
+
"parent_id"
|
|
7262
|
+
]))} AS ${dialect.types.text})`;
|
|
7263
|
+
const parentId = `CASE WHEN ${dialect.jsonHasType("text", "entry_json", "parentId")} THEN ${dialect.jsonText("entry_json", "parentId")} END`;
|
|
7264
|
+
const keys = "(SELECT value FROM candidates)";
|
|
7265
|
+
const wanted = `WITH candidates AS MATERIALIZED (SELECT value FROM ${dialect.jsonValues("?")})`;
|
|
7266
|
+
if (logical) {
|
|
7267
|
+
const view = this.entriesView(logical, sessionId, 0, FORK_VIEW_END);
|
|
7268
|
+
return {
|
|
7269
|
+
sql: withForkViews([view], `${wanted} SELECT ${json} AS parent_facts FROM (
|
|
7270
|
+
SELECT entry_id, seq, ${parentId} AS parent_id FROM ${view.name}
|
|
7271
|
+
) AS links WHERE entry_id IN ${keys} OR parent_id IN ${keys}`),
|
|
7272
|
+
params: [...view.params, JSON.stringify(candidates)]
|
|
7273
|
+
};
|
|
7274
|
+
}
|
|
7275
|
+
return {
|
|
7276
|
+
sql: `${wanted}, indexed AS MATERIALIZED (
|
|
7277
|
+
SELECT EXISTS (SELECT 1 FROM ${index.sources} WHERE source = 'session-entries' AND backfilled_through >= watermark) AS ready
|
|
7278
|
+
) SELECT ${json} AS parent_facts FROM (
|
|
7279
|
+
SELECT entry_id, seq, NULL AS parent_id FROM ${index.sessionLinks}
|
|
7280
|
+
WHERE (SELECT ready FROM indexed) AND session_id = ? AND entry_id IN ${keys}
|
|
7281
|
+
UNION ALL
|
|
7282
|
+
SELECT entry_id, NULL AS seq, parent_id FROM ${index.sessionLinks}
|
|
7283
|
+
WHERE (SELECT ready FROM indexed) AND session_id = ? AND broken = 1 AND parent_id IN ${keys}
|
|
7284
|
+
UNION ALL
|
|
7285
|
+
SELECT entry_id, seq, parent_id FROM (
|
|
7286
|
+
SELECT entry_id, seq, ${parentId} AS parent_id FROM ${this.tables.entries}
|
|
7287
|
+
WHERE NOT (SELECT ready FROM indexed) AND session_id = ?
|
|
7288
|
+
) AS raw WHERE entry_id IN ${keys} OR parent_id IN ${keys}
|
|
7289
|
+
) AS facts`,
|
|
7290
|
+
params: [
|
|
7291
|
+
JSON.stringify(candidates),
|
|
7292
|
+
sessionId,
|
|
7293
|
+
sessionId,
|
|
7294
|
+
sessionId
|
|
7295
|
+
]
|
|
7139
7296
|
};
|
|
7140
7297
|
}
|
|
7298
|
+
async repairAppendParents(tx, sessionId, entries, after, facts) {
|
|
7299
|
+
const positions = /* @__PURE__ */ new Map();
|
|
7300
|
+
const detached = /* @__PURE__ */ new Map();
|
|
7301
|
+
for (const [id, seq, parent] of JSON.parse(facts ?? "[]")) {
|
|
7302
|
+
if (seq !== null) positions.set(id, Math.max(positions.get(id) ?? 0, seq));
|
|
7303
|
+
if (parent !== null) detached.set(parent, id);
|
|
7304
|
+
}
|
|
7305
|
+
try {
|
|
7306
|
+
validateSessionParentWrites(entries, after, (id) => positions.get(id), detached);
|
|
7307
|
+
return {
|
|
7308
|
+
entries,
|
|
7309
|
+
repaired: []
|
|
7310
|
+
};
|
|
7311
|
+
} catch (error) {
|
|
7312
|
+
if (!(error instanceof SessionInvalidParentError || error instanceof SessionDuplicateEntryError)) throw error;
|
|
7313
|
+
}
|
|
7314
|
+
const view = this.entriesView(await this.viewTables(tx, sessionId), sessionId, 0, after);
|
|
7315
|
+
const parent = this.dialect.jsonText("entry_json", "parentId");
|
|
7316
|
+
const rows = await tx.all(withForkViews([view], `SELECT seq, entry_id, ${parent} AS parent_id FROM ${view.name} ORDER BY seq`), ...view.params);
|
|
7317
|
+
const recorded = new SessionParentIndex();
|
|
7318
|
+
for (const row of rows) recorded.note({
|
|
7319
|
+
id: row.entry_id,
|
|
7320
|
+
parentId: row.parent_id
|
|
7321
|
+
}, Number(row.seq));
|
|
7322
|
+
return repairAppendedSessionParents(sessionId, entries, {
|
|
7323
|
+
lastSeq: after,
|
|
7324
|
+
lastEntryId: rows.at(-1)?.entry_id ?? null,
|
|
7325
|
+
seqOf: (id) => recorded.positions.get(id),
|
|
7326
|
+
detachedParents: recorded.detached
|
|
7327
|
+
});
|
|
7328
|
+
}
|
|
7141
7329
|
/** Whether session `sessionId` has fork segments, read in `tx`, whose database has shared history (#6560). */
|
|
7142
7330
|
async hasForkSegments(tx, sessionId) {
|
|
7143
7331
|
return await tx.get(`SELECT 1 AS found FROM ${this.forkTables.forkSegments} WHERE session_id = ? LIMIT 1`, sessionId) !== void 0;
|
|
@@ -7165,7 +7353,7 @@ $grant$`);
|
|
|
7165
7353
|
columns: ["entry_id"],
|
|
7166
7354
|
sessionId,
|
|
7167
7355
|
after: 0,
|
|
7168
|
-
through: FORK_VIEW_END,
|
|
7356
|
+
through: options.through ?? FORK_VIEW_END,
|
|
7169
7357
|
match: {
|
|
7170
7358
|
column: "entry_id",
|
|
7171
7359
|
value: entryId
|
|
@@ -7177,7 +7365,7 @@ $grant$`);
|
|
|
7177
7365
|
columns: ["entry_id"],
|
|
7178
7366
|
sessionId,
|
|
7179
7367
|
after: 0,
|
|
7180
|
-
through: FORK_VIEW_END,
|
|
7368
|
+
through: options.through ?? FORK_VIEW_END,
|
|
7181
7369
|
match: {
|
|
7182
7370
|
column: "entry_id",
|
|
7183
7371
|
value: entryId
|
|
@@ -7199,23 +7387,29 @@ $grant$`);
|
|
|
7199
7387
|
* `executor` with `tables`, or, with `tables` undefined, outside a transaction through `outsideTransaction`. A fork's
|
|
7200
7388
|
* inherited entries are linked under the sessions that store them, at their seqs there, which the view renumbers.
|
|
7201
7389
|
*/
|
|
7202
|
-
async seqOfEntry(executor, tables, sessionId, entryId) {
|
|
7390
|
+
async seqOfEntry(executor, tables, sessionId, entryId, through = FORK_VIEW_END) {
|
|
7391
|
+
if (through === 0) return void 0;
|
|
7203
7392
|
const read = (viewTables, forked = "") => {
|
|
7204
|
-
const statement = this.entrySeqStatement(viewTables, sessionId, entryId, {
|
|
7393
|
+
const statement = this.entrySeqStatement(viewTables, sessionId, entryId, {
|
|
7394
|
+
forked,
|
|
7395
|
+
through
|
|
7396
|
+
});
|
|
7205
7397
|
return executor.get(statement.sql, ...statement.params);
|
|
7206
7398
|
};
|
|
7207
7399
|
const row = tables === void 0 ? await this.outsideSessionRead(sessionId, (viewTables) => read(viewTables, this.outsideForkedColumn("?")), (found) => found?.seq != null, (found) => found?.forked) : await read(tables);
|
|
7208
7400
|
return row?.seq == null ? void 0 : Number(row.seq);
|
|
7209
7401
|
}
|
|
7210
7402
|
/** The statement that saves the session's row, with the search texts of `snapshot`'s entries and its generation. */
|
|
7211
|
-
summaryWrite(sessionId, snapshot, previous, appendedResume) {
|
|
7403
|
+
summaryWrite(sessionId, snapshot, previous, appendedResume, parentLinksCheckedThrough) {
|
|
7212
7404
|
const { header, lastSeq } = snapshot;
|
|
7213
7405
|
const { state: listed, texts } = applySessionSummaryEntries(previous, snapshot.entries);
|
|
7214
7406
|
const resume = previous === void 0 ? foldSessionResume(void 0, snapshot.entries) : appendedResume;
|
|
7215
7407
|
const epoch = resume?.epoch ?? previous?.epoch ?? newRevision();
|
|
7408
|
+
const checked = parentLinksCheckedThrough ?? (previous === void 0 || previous.parentLinksCheckedThrough === lastSeq - snapshot.entries.length ? lastSeq : void 0);
|
|
7216
7409
|
const state = {
|
|
7217
7410
|
...listed,
|
|
7218
7411
|
...windowFields(previous, resume, lastSeq, epoch),
|
|
7412
|
+
...checked === void 0 ? {} : { parentLinksCheckedThrough: checked },
|
|
7219
7413
|
epoch
|
|
7220
7414
|
};
|
|
7221
7415
|
const summary = materializeSessionSummaryMetadata(header, state);
|
|
@@ -7223,7 +7417,8 @@ $grant$`);
|
|
|
7223
7417
|
header_json: this.encode(header),
|
|
7224
7418
|
summary_state: this.encode(state),
|
|
7225
7419
|
revision: newRevision(),
|
|
7226
|
-
last_seq: lastSeq
|
|
7420
|
+
last_seq: lastSeq,
|
|
7421
|
+
lastEntryId: snapshot.entries.at(-1)?.id ?? resume?.lastId ?? void 0
|
|
7227
7422
|
};
|
|
7228
7423
|
return {
|
|
7229
7424
|
statement: {
|
|
@@ -13784,6 +13979,7 @@ async function runPrintMode(runtimeHost, options) {
|
|
|
13784
13979
|
let repliedThisRun = false;
|
|
13785
13980
|
let session = runtimeHost.session;
|
|
13786
13981
|
let unsubscribe;
|
|
13982
|
+
const stopSessionLoads = mode === "json" ? subscribeToLiveSessionLoads(runtimeHost, (event) => writeRawStdout(`${JSON.stringify(event)}\n`)) : void 0;
|
|
13787
13983
|
const terminatingStructuredOutputCallIds = /* @__PURE__ */ new Set();
|
|
13788
13984
|
let disposing;
|
|
13789
13985
|
let signalCount = 0;
|
|
@@ -13791,7 +13987,7 @@ async function runPrintMode(runtimeHost, options) {
|
|
|
13791
13987
|
const disposeRuntime = () => {
|
|
13792
13988
|
disposing ??= (async () => {
|
|
13793
13989
|
unsubscribe?.();
|
|
13794
|
-
await runtimeHost.dispose();
|
|
13990
|
+
await runtimeHost.dispose().finally(() => stopSessionLoads?.());
|
|
13795
13991
|
})();
|
|
13796
13992
|
return disposing;
|
|
13797
13993
|
};
|
|
@@ -13890,6 +14086,7 @@ async function runPrintMode(runtimeHost, options) {
|
|
|
13890
14086
|
enablePrintModelSelection(session);
|
|
13891
14087
|
unsubscribe?.();
|
|
13892
14088
|
unsubscribe = session.subscribe((event) => {
|
|
14089
|
+
if (isSessionLoadEvent(event)) return;
|
|
13893
14090
|
if (isTerminatingStructuredOutputEvent(event, (name) => session.getToolDefinition(name))) terminatingStructuredOutputCallIds.add(event.toolCallId);
|
|
13894
14091
|
if (event.type === "message_end" && event.message.role === "assistant") repliedThisRun = true;
|
|
13895
14092
|
if (event.type === "session_storage_reconnect") reportDiagnostics([{
|
|
@@ -14041,6 +14238,39 @@ var ThemeSelectorComponent = class extends FramedSelector {
|
|
|
14041
14238
|
});
|
|
14042
14239
|
}
|
|
14043
14240
|
};
|
|
14241
|
+
// dist/core/subscription-usage-storage.js
|
|
14242
|
+
const STORAGE_OPEN_MS = 1e3;
|
|
14243
|
+
/** Standalone reports use the selected database without opening or creating a chat session. */
|
|
14244
|
+
async function withSelectedUsageStore(cwd, agentDir, settings, signal, run) {
|
|
14245
|
+
let owned;
|
|
14246
|
+
const store = await withProviderTimeout(STORAGE_OPEN_MS, signal, async (opening) => {
|
|
14247
|
+
const selection = await selectSessionStorageWithSettingsAsync(cwd, {
|
|
14248
|
+
agentDir,
|
|
14249
|
+
settings
|
|
14250
|
+
});
|
|
14251
|
+
opening.throwIfAborted();
|
|
14252
|
+
if ("load" in selection) return usageObservationStore(selection);
|
|
14253
|
+
if (selection.kind === "database") return new UsageObservationStore(selection.database, selection.prefix);
|
|
14254
|
+
if (selection.kind !== "adapter" && selection.kind !== "sqlite") return void 0;
|
|
14255
|
+
const database = selection.kind === "sqlite" ? await (await import("../core/storage/node-sqlite.js").catch((error) => __atomicOnDemandFailed(error, "session storage"))).openNodeSqliteDatabase(selection.path) : await (await import("../core/storage/adapter-open.js").catch((error) => __atomicOnDemandFailed(error, "session storage"))).openAdapterSelectionDatabase(selection, {
|
|
14256
|
+
agentDir,
|
|
14257
|
+
domain: "sessions",
|
|
14258
|
+
signal: opening
|
|
14259
|
+
});
|
|
14260
|
+
if (opening.aborted) {
|
|
14261
|
+
await database.close().catch(() => {});
|
|
14262
|
+
return;
|
|
14263
|
+
}
|
|
14264
|
+
owned = database;
|
|
14265
|
+
return new UsageObservationStore(database, selection.prefix);
|
|
14266
|
+
}, "Usage storage").catch(() => void 0);
|
|
14267
|
+
try {
|
|
14268
|
+
signal?.throwIfAborted();
|
|
14269
|
+
return await run(store);
|
|
14270
|
+
} finally {
|
|
14271
|
+
if (owned) await withProviderTimeout(STORAGE_OPEN_MS, void 0, () => owned.close(), "Usage storage close").catch(() => {});
|
|
14272
|
+
}
|
|
14273
|
+
}
|
|
14044
14274
|
// dist/subscription-usage-sdk.js
|
|
14045
14275
|
/** Read subscription quotas without returning credentials or spending credits. */
|
|
14046
14276
|
async function getSubscriptionUsage(options = {}) {
|
|
@@ -14050,7 +14280,10 @@ async function getSubscriptionUsage(options = {}) {
|
|
|
14050
14280
|
if (modelRuntime) return await loadSubscriptionUsage(modelRuntime, void 0, options);
|
|
14051
14281
|
const services = usageServices();
|
|
14052
14282
|
const runtime = signal ? await raceWithAbortSignal(services, signal) : await services;
|
|
14053
|
-
return await loadSubscriptionUsage(runtime.modelRuntime, runtime.settingsManager.getDefaultProvider(),
|
|
14283
|
+
return await withSelectedUsageStore(runtime.cwd, runtime.agentDir, runtime.settingsManager.getSettings(), signal, (store) => loadSubscriptionUsage(runtime.modelRuntime, runtime.settingsManager.getDefaultProvider(), {
|
|
14284
|
+
...options,
|
|
14285
|
+
store
|
|
14286
|
+
}));
|
|
14054
14287
|
} catch {
|
|
14055
14288
|
signal?.throwIfAborted();
|
|
14056
14289
|
throw new Error("Could not read subscription accounts.");
|
|
@@ -14100,16 +14333,16 @@ const COMPACTOR_LINE_WIDTH = 2e3;
|
|
|
14100
14333
|
function compactedOutputTokenCap(triggerTokens, maxOutputTokens = COMPACTED_OUTPUT_MAX_TOKENS) {
|
|
14101
14334
|
return Math.max(0, Math.min(Number.isFinite(maxOutputTokens) && maxOutputTokens > 0 ? maxOutputTokens : COMPACTED_OUTPUT_MAX_TOKENS, Math.floor(triggerTokens * COMPACTED_OUTPUT_MAX_TRIGGER_SHARE)));
|
|
14102
14335
|
}
|
|
14103
|
-
export { CLOUDFLARE_GATEWAY_BINDING_AUTH_SENTINEL, COMPACTED_OUTPUT_MAX_TOKENS, COMPACTED_OUTPUT_MAX_TRIGGER_SHARE, COMPACTOR_COMPRESSION_RATIO, COMPACTOR_LINE_WIDTH, ClassifierDecisionError, GITHUB_COPILOT_ERROR_DIAGNOSTIC, GitHubCopilotAuthenticationError, GitHubCopilotContentFilterError, GitHubCopilotEmptyResponseError, GitHubCopilotError, GitHubCopilotInvalidRequestError, GitHubCopilotModelUnavailableError, GitHubCopilotPromptTooLargeError, GitHubCopilotQuotaExhaustedError, GitHubCopilotRateLimitError, GitHubCopilotServiceUnavailableError, GitHubCopilotStreamEndedEarlyError, GitHubCopilotUnrecognizedResponseError, IntercomBrokerError, IntercomBrokerProtocolError, IntercomBrokerStopTimeoutError, IntercomBrokerSuccessorTimeoutError, IntercomBrokerUpgradeError, IntercomRoutingChangedError, IntercomRoutingError, IntercomRoutingMismatchError, IntercomRoutingTimeoutError, IntercomRoutingUnavailableError, LISTING_FETCH_BATCH, MAX_SESSION_START_TIMEOUT_MS, McpOAuthAuthorizationRequiredError, McpOAuthCredentialStore, McpSignInCancelledError, MemorySnapshotBlobStore, ModelRegistry, OAuthRefreshRejectedError, OAuthTemporarilyUnavailableError, OutputRepairExhaustedError, ProjectGroupError, ProviderRequestFailure, RUNTIME_INTERCOM_GROUP_ENV, SESSION_APPEND_FUNCTION_DOMAIN, SESSION_BLOB_CHUNK_BYTES, SESSION_DOMAIN, SESSION_ENTRY_CHUNK_BYTES, SESSION_FILLFACTOR_DOMAIN, SESSION_PRESENCE_DOMAIN, SESSION_PRESENCE_TABLES, SESSION_READ_FETCH, SESSION_READ_PAGE_CHARS, SESSION_RESUME_REBUILD, SESSION_SCHEMA_VERSION, SESSION_SCHEMA_VERSION_CHUNKED, SESSION_SCHEMA_VERSION_SHARED_HISTORY, SESSION_TABLES, SNAPSHOT_COLLECTION_BATCH, SessionConflictError, SessionExistsError, SessionFormatVersionError, SessionIdMismatchError, SessionInvalidTextError, SessionInvalidTimestampError, SessionNotFoundError, SessionStartConfigError, SessionStartError, SessionStartTimeoutError, ShowImagesSelectorComponent, SqlSessionStore, SqlSnapshotBlobStore, TEAM_JOIN_COMMAND, TerminalDecisionError, ThemeSelectorComponent, addMcpServerConfigAsync, announceBlueprintBuildWaits, clampThinkingLevel, classifyGitHubCopilotFailure, compactedOutputTokenCap, configuredSecretRedactor, createGatewayBindingFetch, createMcpAuthProvider, createMcpExtension, createTranscript, decide, decisionFailure, describeGitHubCopilotModel, deserializeGitHubCopilotError, findGitHubCopilotError, findSessionStartError, generateStructuredOutput, getGitHubCopilotError, getMcpToolExposure, getSubscriptionUsage, getSupportedThinkingLevels, githubChecks, githubReviews, interval, isGitHubCopilotAuthenticationError, isGitHubCopilotContentFilterError, isGitHubCopilotEmptyResponseError, isGitHubCopilotError, isGitHubCopilotInvalidRequestError, isGitHubCopilotModelUnavailableError, isGitHubCopilotPromptTooLargeError, isGitHubCopilotQuotaExhaustedError, isGitHubCopilotRateLimitError, isGitHubCopilotServiceUnavailableError, isGitHubCopilotStreamEndedEarlyError, isGitHubCopilotUnrecognizedResponseError, isIntercomBrokerError, isIntercomBrokerProtocolError, isIntercomBrokerStopTimeoutError, isIntercomBrokerSuccessorTimeoutError, isIntercomBrokerUpgradeError, isIntercomRoutingChangedError, isIntercomRoutingError, isIntercomRoutingMismatchError, isIntercomRoutingTimeoutError, isIntercomRoutingUnavailableError, isOAuthRefreshRejectedError, isProjectGroupError, isRetryableGitHubCopilotError, isRetryableIntercomBrokerError, isRetryableIntercomRoutingError, isRetryableSessionStartError, isSessionStartConfigError, isSessionStartError, isSessionStartTimeoutError, loadMcpConfigAsync, logTail, mcpNamespace, mcpRequestTimeoutMs, parseFlattenedKeyPath, parseSessionStartTimeoutMs, publishExtensionContextEffect, publishPullRequest, readRuntimeIntercomGroup, reconstructFlattenedKeys, registerExtensionContextRetirementEffect, rehydrateIntercomBrokerError, rehydrateSessionStartError, removeMcpServerConfigAsync, resolveAutoModel, resolveDecisionModel, resolveMcpServerUrl, restoreRunWorktree, runDecision, runPrintMode, runRestorePreconditionError, runtimeIntercomGroupEnvKey, serializeGitHubCopilotError, serializeIntercomBrokerError, serializeSessionStartError, sessionScopedExtensionState, sessionStartStepText, setUpRestoredRunWorktrees, setUpResumedRunWorktrees, signInMcpServer, snapshotBlobHashes, snapshotIndexTables, unflattenArgumentsWithSchema, updateMcpServerConfig, updateMcpServerConfigAsync, validateMcpServerConfig, webhook, workspaceChangeSet, writeBlueprintBuildEvent };
|
|
14336
|
+
export { CLOUDFLARE_GATEWAY_BINDING_AUTH_SENTINEL, COMPACTED_OUTPUT_MAX_TOKENS, COMPACTED_OUTPUT_MAX_TRIGGER_SHARE, COMPACTOR_COMPRESSION_RATIO, COMPACTOR_LINE_WIDTH, ClassifierDecisionError, GITHUB_COPILOT_ERROR_DIAGNOSTIC, GitHubCopilotAuthenticationError, GitHubCopilotContentFilterError, GitHubCopilotEmptyResponseError, GitHubCopilotError, GitHubCopilotInvalidRequestError, GitHubCopilotModelUnavailableError, GitHubCopilotPromptTooLargeError, GitHubCopilotQuotaExhaustedError, GitHubCopilotRateLimitError, GitHubCopilotServiceUnavailableError, GitHubCopilotStreamEndedEarlyError, GitHubCopilotUnrecognizedResponseError, IntercomBrokerError, IntercomBrokerProtocolError, IntercomBrokerStopTimeoutError, IntercomBrokerSuccessorTimeoutError, IntercomBrokerUpgradeError, IntercomRoutingChangedError, IntercomRoutingError, IntercomRoutingMismatchError, IntercomRoutingTimeoutError, IntercomRoutingUnavailableError, LISTING_FETCH_BATCH, MAX_SESSION_START_TIMEOUT_MS, McpOAuthAuthorizationRequiredError, McpOAuthCredentialStore, McpSignInCancelledError, MemorySnapshotBlobStore, ModelRegistry, OAuthRefreshRejectedError, OAuthTemporarilyUnavailableError, OutputRepairExhaustedError, ProjectGroupError, ProviderRequestFailure, RUNTIME_INTERCOM_GROUP_ENV, SESSION_APPEND_FUNCTION_DOMAIN, SESSION_BLOB_CHUNK_BYTES, SESSION_DOMAIN, SESSION_ENTRY_CHUNK_BYTES, SESSION_FILLFACTOR_DOMAIN, SESSION_PRESENCE_DOMAIN, SESSION_PRESENCE_TABLES, SESSION_READ_FETCH, SESSION_READ_PAGE_CHARS, SESSION_RESUME_REBUILD, SESSION_SCHEMA_VERSION, SESSION_SCHEMA_VERSION_CHUNKED, SESSION_SCHEMA_VERSION_SHARED_HISTORY, SESSION_TABLES, SNAPSHOT_COLLECTION_BATCH, SessionConflictError, SessionExistsError, SessionFormatVersionError, SessionIdMismatchError, SessionInvalidTextError, SessionInvalidTimestampError, SessionNotFoundError, SessionStartConfigError, SessionStartError, SessionStartTimeoutError, ShowImagesSelectorComponent, SqlSessionStore, SqlSnapshotBlobStore, TEAM_JOIN_COMMAND, TerminalDecisionError, ThemeSelectorComponent, addMcpServerConfigAsync, announceBlueprintBuildWaits, clampThinkingLevel, classifyGitHubCopilotFailure, compactedOutputTokenCap, configuredSecretRedactor, createGatewayBindingFetch, createMcpAuthProvider, createMcpExtension, createTranscript, decide, decisionFailure, describeGitHubCopilotModel, deserializeGitHubCopilotError, findGitHubCopilotError, findSessionStartError, generateStructuredOutput, getGitHubCopilotError, getMcpToolExposure, getSubscriptionUsage, getSupportedThinkingLevels, githubChecks, githubReviews, interval, isGitHubCopilotAuthenticationError, isGitHubCopilotContentFilterError, isGitHubCopilotEmptyResponseError, isGitHubCopilotError, isGitHubCopilotInvalidRequestError, isGitHubCopilotModelUnavailableError, isGitHubCopilotPromptTooLargeError, isGitHubCopilotQuotaExhaustedError, isGitHubCopilotRateLimitError, isGitHubCopilotServiceUnavailableError, isGitHubCopilotStreamEndedEarlyError, isGitHubCopilotUnrecognizedResponseError, isIntercomBrokerError, isIntercomBrokerProtocolError, isIntercomBrokerStopTimeoutError, isIntercomBrokerSuccessorTimeoutError, isIntercomBrokerUpgradeError, isIntercomRoutingChangedError, isIntercomRoutingError, isIntercomRoutingMismatchError, isIntercomRoutingTimeoutError, isIntercomRoutingUnavailableError, isOAuthRefreshRejectedError, isProjectGroupError, isRetryableGitHubCopilotError, isRetryableIntercomBrokerError, isRetryableIntercomRoutingError, isRetryableSessionStartError, isSessionStartConfigError, isSessionStartError, isSessionStartTimeoutError, loadMcpConfigAsync, logTail, mcpNamespace, mcpRequestTimeoutMs, parseFlattenedKeyPath, parseSessionStartTimeoutMs, publishExtensionContextEffect, publishPullRequest, readRuntimeIntercomGroup, reconstructFlattenedKeys, registerExtensionContextRetirementEffect, rehydrateIntercomBrokerError, rehydrateSessionStartError, removeMcpServerConfigAsync, resolveAutoModel, resolveDecisionModel, resolveMcpServerUrl, restoreRunWorktree, runDecision, runPrintMode, runRestorePreconditionError, runtimeIntercomGroupEnvKey, serializeGitHubCopilotError, serializeIntercomBrokerError, serializeSessionStartError, sessionScopedExtensionState, sessionStartStepText, setUpRestoredRunWorktrees, setUpResumedRunWorktrees, signInMcpServer, snapshotBlobHashes, snapshotIndexTables, unflattenArgumentsWithSchema, updateMcpServerConfig, updateMcpServerConfigAsync, validateMcpServerConfig, webhook, withSelectedUsageStore, workspaceChangeSet, writeBlueprintBuildEvent };
|
|
14104
14337
|
|
|
14105
|
-
//# sourceMappingURL=sdk-
|
|
14338
|
+
//# sourceMappingURL=sdk-5ZFNDXUJ.js.map
|
|
14106
14339
|
// __atomicOnDemandFailed: written by the build (scripts/in-place-update-gate.mjs). An import of this release's code on
|
|
14107
14340
|
// demand that fails in a process an in-place update left running says to restart.
|
|
14108
14341
|
function __atomicOnDemandFailed(error, feature) {
|
|
14109
14342
|
return (async () => {
|
|
14110
14343
|
const root = new URL("../", import.meta.url);
|
|
14111
14344
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
14112
|
-
const key = `${root.href}#0.10.
|
|
14345
|
+
const key = `${root.href}#0.10.20-alpha.2`;
|
|
14113
14346
|
let release = releases.get(key);
|
|
14114
14347
|
if (release === undefined) {
|
|
14115
14348
|
const current = (async () => {
|
|
@@ -14137,7 +14370,7 @@ function __atomicOnDemandFailed(error, feature) {
|
|
|
14137
14370
|
} catch {
|
|
14138
14371
|
// No installation to read, as in a bundle of the package: the release the process runs decides.
|
|
14139
14372
|
}
|
|
14140
|
-
const updatedTo = typeof installed === "string" && installed !== "0.10.
|
|
14373
|
+
const updatedTo = typeof installed === "string" && installed !== "0.10.20-alpha.2" ? installed : running !== undefined && running.version !== "0.10.20-alpha.2" ? "0.10.20-alpha.2" : undefined;
|
|
14141
14374
|
if (updatedTo === undefined) throw error;
|
|
14142
14375
|
const application = typeof running?.name === "string" ? running.name : "atomic";
|
|
14143
14376
|
const restart = new Error(`${application} was updated to ${updatedTo} while this session was running; restart it to keep using ${feature}.`, {
|