@bastani/atomic 0.10.9 → 0.10.10-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 +83 -0
- package/README.md +226 -163
- 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 +27 -12
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js.map +1 -1
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +47 -7
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js.map +1 -1
- package/dist/_shared/mode-shared-2QJSCUM6.js +48 -19
- package/dist/_shared/mode-shared-2QJSCUM6.js.map +1 -1
- package/dist/_shared/{p1a-prewarm-UQY3X2UK.js → p1a-prewarm-XIU57JHF.js} +5 -5
- package/dist/_shared/{p1a-prewarm-UQY3X2UK.js.map → p1a-prewarm-XIU57JHF.js.map} +1 -1
- package/dist/_shared/p2-shell-main-B2WIALFD.js +30 -25
- package/dist/_shared/p2-shell-main-B2WIALFD.js.map +1 -1
- package/dist/_shared/runtime-O4KCSG4C.js +5 -5
- package/dist/_shared/{sdk-OSBEPR3Q.js → sdk-RRLVN7ER.js} +15 -9
- package/dist/_shared/sdk-RRLVN7ER.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/settings-startup-8-DNZ2RIHM.js +4 -1
- package/dist/_shared/settings-startup-8-DNZ2RIHM.js.map +1 -1
- package/dist/_shared/{startup-0-0-TYUFUOJZ.js → startup-0-0-4VG2G44V.js} +427 -33
- package/dist/_shared/startup-0-0-4VG2G44V.js.map +1 -0
- package/dist/_shared/{startup-0-1-W2G2UY7R.js → startup-0-1-XTIL65D4.js} +18 -11
- package/dist/_shared/startup-0-1-XTIL65D4.js.map +1 -0
- package/dist/_shared/{startup-0-2-UXBUEOXW.js → startup-0-2-27OWFHV6.js} +150 -62
- package/dist/_shared/startup-0-2-27OWFHV6.js.map +1 -0
- package/dist/_shared/startup-0-3-T4DVFYWX.js +15 -25
- package/dist/_shared/startup-0-3-T4DVFYWX.js.map +1 -1
- package/dist/_shared/{startup-0-4-HN5EB4K7.js → startup-0-4-ZMJV547D.js} +81 -12
- package/dist/_shared/startup-0-4-ZMJV547D.js.map +1 -0
- package/dist/_shared/startup-0-5-FD2P735I.js +90 -50
- package/dist/_shared/startup-0-5-FD2P735I.js.map +1 -1
- package/dist/_shared/startup-10-0-TDQNBDDL.js +5 -5
- package/dist/_shared/startup-12-0-55AAXBJZ.js +13 -7
- package/dist/_shared/startup-12-0-55AAXBJZ.js.map +1 -1
- package/dist/_shared/startup-14-0-MLX36RBG.js +4 -4
- package/dist/_shared/startup-15-0-YUKGAC63.js +4 -4
- package/dist/_shared/startup-15-1-4S7FLMNG.js +88 -28
- package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +5 -5
- package/dist/_shared/startup-8-1-4KANEHRA.js +61 -17
- package/dist/_shared/startup-8-1-4KANEHRA.js.map +1 -1
- package/dist/_shared/storage-command-7MGXLJGZ.js +4 -4
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/README.md +87 -116
- package/dist/builtin/intercom/broker/broker.bundle.mjs +3 -3
- package/dist/builtin/intercom/broker/presence-handler.ts +1 -1
- package/dist/builtin/intercom/group.ts +7 -3
- package/dist/builtin/intercom/index.bundle.mjs +1 -1
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/README.md +61 -27
- package/dist/builtin/mcp/index.bundle.mjs +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +8 -0
- package/dist/builtin/subagents/README.md +74 -141
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +213 -74
- package/dist/builtin/web-access/CHANGELOG.md +9 -0
- package/dist/builtin/web-access/README.md +61 -88
- package/dist/builtin/web-access/index.bundle.mjs +387 -351
- package/dist/builtin/web-access/package.json +1 -1
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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-methods.d.ts +4 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session.d.ts +3 -0
- package/dist/core/compaction/compactor.d.ts +20 -14
- package/dist/core/compaction/errors.d.ts +120 -0
- package/dist/core/compaction/index.d.ts +1 -0
- package/dist/core/compaction/model-resolver.d.ts +2 -2
- 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 +2 -2
- 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.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/api-types.d.ts +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +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 +1 -1
- package/dist/core/extensions/provider-types.d.ts +18 -6
- package/dist/core/extensions/provider-types.js.map +1 -1
- package/dist/core/extensions/runner-context.js +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-config.d.ts +40 -0
- package/dist/core/model-registry.js +1 -1
- package/dist/core/model-resolver-scope.d.ts +4 -4
- package/dist/core/model-runtime.d.ts +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/provider-composer-internal.d.ts +11 -2
- 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.impl.js +3 -3
- package/dist/core/session-storage.js +3 -3
- package/dist/core/settings-manager-basic-accessors.d.ts +6 -2
- 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/provider.js +2 -2
- package/dist/core/storage/selection.js +2 -2
- 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-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 +2 -2
- 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 +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-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 +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 +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.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/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/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.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.impl.js +3 -3
- package/dist/core/tasks/task-view-source.js +3 -3
- package/dist/core/tools/read-url.code.js +2 -2
- 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 +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 +2 -2
- 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-extensions.d.ts +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +7 -7
- 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/modes/interactive/components/settings-selector-types.d.ts +1 -0
- package/dist/modes/interactive/components/settings-selector-types.js.map +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/theme/color-utils.d.ts +5 -5
- package/dist/modes/interactive/theme/theme-loading.d.ts +1 -0
- package/dist/modes/interactive-engine/engine-prewarm.js +1 -1
- package/dist/modes/interactive-engine/remote-model-catalog.d.ts +1 -0
- package/dist/modes/print-mode.js +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +6 -0
- package/dist/modes/rpc/rpc-types.d.ts +29 -2
- package/dist/package-manager-cli.code.js +5 -5
- 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/5.js +1 -1
- package/dist/startup-stages/7.js +1 -1
- package/dist/startup-stages/8.js +1 -2
- package/dist/startup-stages/9.js +2 -1
- package/dist/utils/native-module.d.ts +44 -0
- 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/background-tasks.md +238 -243
- package/docs/build.md +21 -15
- package/docs/changelog.mdx +1 -1
- package/docs/codemode.md +68 -51
- package/docs/compaction/reference.md +65 -26
- package/docs/compaction.md +118 -66
- package/docs/computer-use.md +179 -146
- package/docs/containerization.md +87 -33
- package/docs/custom-provider/api-reference.md +152 -13
- package/docs/custom-provider/oauth.md +45 -28
- package/docs/custom-provider/override.md +14 -7
- package/docs/custom-provider/registration.md +77 -67
- package/docs/custom-provider/streaming.md +42 -19
- package/docs/custom-provider.md +26 -62
- package/docs/development.md +81 -42
- package/docs/docs.json +54 -38
- package/docs/environment-variables.md +92 -64
- package/docs/extensions/api-reference.md +326 -735
- package/docs/extensions/authoring.md +186 -269
- package/docs/extensions/events.md +308 -375
- package/docs/extensions/examples.md +122 -74
- package/docs/extensions/ui.md +217 -197
- package/docs/extensions.md +189 -259
- package/docs/getting-started/authentication.md +27 -14
- package/docs/getting-started/first-session.md +25 -26
- package/docs/getting-started/installation.md +62 -84
- package/docs/getting-started/project-instructions.md +39 -14
- package/docs/guides/configuration.md +62 -20
- package/docs/guides/intercom.md +20 -12
- package/docs/guides/non-interactive.md +31 -16
- package/docs/guides/orchestration.md +17 -9
- package/docs/guides/resume-on-any-machine.md +63 -52
- package/docs/guides/subagents.md +26 -14
- package/docs/guides/team-setup.md +49 -27
- package/docs/guides.md +30 -23
- package/docs/herdr.md +22 -17
- package/docs/index.md +24 -17
- package/docs/intercom/operations.md +90 -66
- package/docs/intercom/reference.md +219 -192
- package/docs/intercom.md +111 -92
- package/docs/json.md +73 -71
- package/docs/keybindings.md +74 -48
- package/docs/libraries/agent-core.md +52 -9
- package/docs/libraries/ai.md +90 -63
- package/docs/libraries/codemode.md +31 -8
- package/docs/libraries/schema.md +12 -9
- package/docs/libraries/storage-libsql.md +92 -0
- package/docs/libraries/storage-postgres.md +119 -0
- package/docs/libraries/telemetry.md +42 -9
- package/docs/libraries/tui.md +74 -94
- package/docs/libraries.md +25 -8
- package/docs/llama-cpp.md +38 -33
- package/docs/mcp-servers.md +140 -88
- package/docs/models/reference.md +53 -36
- package/docs/models-configuration.md +19 -13
- package/docs/models.md +102 -87
- package/docs/orchestration/migrating-workflows.md +22 -20
- package/docs/orchestration/patterns.md +36 -21
- package/docs/orchestration.md +24 -21
- package/docs/packages/authoring.md +29 -18
- package/docs/packages/reference.md +77 -16
- package/docs/packages.md +34 -34
- package/docs/programmatic.md +28 -21
- package/docs/prompt-templates.md +65 -41
- package/docs/providers/reference.md +36 -20
- package/docs/providers.md +78 -76
- package/docs/quickstart.md +42 -54
- package/docs/reference/cli.md +256 -254
- package/docs/reference.md +30 -23
- package/docs/rpc/examples.md +121 -17
- package/docs/rpc/extension-ui.md +86 -63
- package/docs/rpc/protocol.md +817 -358
- package/docs/rpc.md +78 -152
- package/docs/sdk/reference.md +309 -73
- package/docs/sdk/storage.md +614 -0
- package/docs/sdk/structured-decisions.md +168 -65
- package/docs/sdk/web-server.md +80 -46
- package/docs/sdk.md +168 -215
- package/docs/security.md +117 -44
- package/docs/session-format.md +127 -76
- package/docs/sessions.md +155 -113
- package/docs/settings.md +293 -205
- package/docs/shell-aliases.md +15 -6
- package/docs/skills/authoring.md +17 -9
- package/docs/skills/reference.md +23 -21
- package/docs/skills.md +148 -97
- package/docs/storage.md +172 -260
- package/docs/subagents/authoring.md +148 -15
- package/docs/subagents/reference.md +105 -29
- package/docs/subagents.md +247 -250
- package/docs/terminal-setup.md +97 -69
- package/docs/termux.md +51 -85
- package/docs/themes/reference.md +51 -37
- package/docs/themes.md +52 -55
- package/docs/tmux.md +38 -21
- package/docs/tools.md +209 -147
- package/docs/tui/reference.md +64 -32
- package/docs/tui.md +38 -66
- package/docs/usage.md +94 -86
- package/docs/verification.md +25 -25
- package/docs/web-access.md +106 -54
- package/docs/windows.md +55 -57
- package/docs/worktree-snapshots.md +82 -74
- package/examples/sdk/11-sessions.ts +4 -4
- package/package.json +8 -8
- package/schemas/models.schema.json +58 -7
- package/dist/_shared/sdk-OSBEPR3Q.js.map +0 -1
- package/dist/_shared/startup-0-0-TYUFUOJZ.js.map +0 -1
- package/dist/_shared/startup-0-1-W2G2UY7R.js.map +0 -1
- package/dist/_shared/startup-0-2-UXBUEOXW.js.map +0 -1
- package/dist/_shared/startup-0-4-HN5EB4K7.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-methods.js","sourceRoot":"","sources":["../../src/core/agent-session-methods.ts"],"names":[],"mappings":"","sourcesContent":["import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, ThinkingLevel } from \"@bastani/atomic-agent-core\";\nimport type { ProviderHeaders } from \"@bastani/atomic-ai\";\nimport type {\n\tApi,\n\tAssistantMessage,\n\tImageContent,\n\tMessage,\n\tModel,\n\tTextContent,\n\tToolResultMessage,\n} from \"@bastani/atomic-ai/compat\";\nimport type { DetachedToolCall, DetachedToolResult, ToolDetachmentPolicy } from \"./agent-session-detached-tools.ts\";\nimport type { PersistenceFailure, UnsavedInput } from \"./agent-session-persistence-failures.ts\";\nimport type { PendingPostToolCompactionGuard } from \"./agent-session-post-tool-compaction.ts\";\nimport type { RecordedToolLoadout } from \"./agent-session-state.ts\";\nimport type {\n\tAgentSessionEvent,\n\tAgentSessionEventListener,\n\tAgentSessionReloadOptions,\n\tClearedQueue,\n\tClearQueueOptions,\n\tDrainedAgentQueues,\n\tExtensionBindings,\n\tInterruptQueueHold,\n\tModelCycleResult,\n\tModelMutationOptions,\n\tPromptDisposition,\n\tPromptOptions,\n\tQueuedInputDisposition,\n\tSessionAbortOptions,\n\tSessionRecoveryReport,\n\tSessionStats,\n\tToolDefinitionEntry,\n} from \"./agent-session-types.js\";\nimport type { BashResult } from \"./bash-executor.ts\";\nimport type { VerbatimCompactionResult } from \"./compaction/index.ts\";\nimport type {\n\tAgentActivityOutcome,\n\tBoundaryContextPreview,\n\tContextUsage,\n\tExtensionCommandContextActions,\n\tExtensionErrorListener,\n\tExtensionMode,\n\tExtensionRunner,\n\tExtensionUIContext,\n\tReplacedSessionContext,\n\tSendMessageOptions,\n\tSendMessagesOptions,\n\tSessionBoundaryDraft,\n\tSessionRecoveryReason,\n\tSessionStartEvent,\n\tToolDefinition,\n\tToolInfo,\n} from \"./extensions/index.js\";\nimport type { BashExecutionMessage, CustomMessage } from \"./messages.ts\";\nimport type { ExtensionProviderTransaction, ModelRuntime } from \"./model-runtime.js\";\nimport type { PathMetadata } from \"./package-manager.ts\";\nimport type { PromptTemplate } from \"./prompt-templates.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { BranchSummaryEntry, SessionEntry, SessionManager, SessionSummaryEntry } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { NormalizedBuildSystemPromptOptions } from \"./system-prompt.ts\";\nimport type { ToolStatusReport } from \"./tool-status.js\";\nimport type { BashOperations } from \"./tools/bash.js\";\nimport type { ToolExecutionScheduler } from \"./tools/tool-concurrency.ts\";\nimport type { SystemMessageWithTransformedPrompt } from \"./transformed-system-prompt.ts\";\nimport type { WorktreeRootMapping } from \"./worktree-snapshot/types.ts\";\n\nexport interface SessionCompactOptions {\n\t/** Instructions for this compaction: what to recover first, and the compactor's query. */\n\tquery?: string;\n\t/**\n\t * `auto` or an exact compactor model `provider/model` for this run only; overrides the `compactionModel` setting\n\t * without saving it. Any other value clears the context with a notice.\n\t */\n\tcompactionModel?: string;\n}\n\nexport interface VerbatimCompactionApplyOptions {\n\tabortController: AbortController;\n\tbackupLabel: string;\n\tquery?: string;\n\tcompactionModel?: string;\n\treason: \"manual\" | \"threshold\" | \"overflow\";\n\t/** Reports when a session_before_compact override becomes the active compaction source. */\n\tonCompactionSource?: (fromExtension: boolean) => void;\n\t/** Last entry the boundary covers; the entries after it stay in the context as they are. Default: all of them. */\n\tcoveredThroughEntryId?: string;\n}\n\n/**\n * How much an automatic compaction is load-bearing: `load_bearing` when the turn cannot continue without it (a provider\n * overflow), `recoverable` otherwise. Only a load-bearing failure marks the overflow unresolved.\n */\nexport type AutoCompactionUrgency = \"recoverable\" | \"load_bearing\";\n\n/** Outcome of an automatic compaction admission and persistence attempt. */\nexport type AutoCompactionRunOutcome = \"compacted\" | \"not_compactable\" | \"deferred\" | \"failed\";\n\nexport interface ExtensionResourcePathEntry {\n\tpath: string;\n\textensionPath: string;\n}\n\nexport interface ExtensionResourcePathResult {\n\tpath: string;\n\tmetadata: PathMetadata;\n}\n\nexport interface RuntimeBuildOptions {\n\tactiveToolNames?: string[];\n\tflagValues?: Map<string, boolean | string>;\n\tincludeAllExtensionTools?: boolean;\n\tpreserveRunner?: boolean;\n\tpowerShellAvailable: boolean;\n}\n\n/** The settlement of the run a `pauseTurn` ended. Spelled out, as published declarations may predate `PromiseWithResolvers`. */\nexport interface TurnPause {\n\treadonly promise: Promise<void>;\n\tresolve(): void;\n}\n\nexport interface AgentSessionQueuePauseControl {\n\treadonly queuedMessagesPaused: boolean;\n\t/** Whether Esc in the session's chat paused it (`pauseTurn`): its queue is held until the user continues it. */\n\treadonly turnPaused: boolean;\n\tpauseQueuedMessages(): void;\n\t/** Release the hold without starting a turn; true means raw queued work was released. */\n\tresumeQueuedMessages(beforeRelease?: () => void): Promise<boolean>;\n}\n\nexport interface AgentSessionMethodSurface extends AgentSessionQueuePauseControl {\n\treadonly modelRuntime: ModelRuntime;\n\treadonly state: AgentState;\n\treadonly model: Model<Api> | undefined;\n\treadonly thinkingLevel: ThinkingLevel;\n\treadonly isStreaming: boolean;\n\treadonly systemPrompt: string;\n\treadonly retryAttempt: number;\n\treadonly retryStatus?: import(\"./session-retry-status.js\").SessionRetryStatus;\n\t/** Time of the current turn's first request, including waits and later attempts; absent between turns. */\n\treadonly turnStartedAt?: number;\n\treadonly isCompacting: boolean;\n\treadonly compactionReason?: import(\"./agent-session-types.js\").CompactionReason;\n\treadonly compactionStartedAt?: number;\n\treadonly messages: AgentMessage[];\n\t/** The settled chat rows, including admitted messages whose save is still in flight. */\n\treadonly transcriptMessages: AgentMessage[];\n\treadonly steeringMode: \"all\" | \"one-at-a-time\";\n\treadonly followUpMode: \"all\" | \"one-at-a-time\";\n\treadonly sessionFile: string | undefined;\n\treadonly sessionId: string;\n\treadonly sessionName: string | undefined;\n\treadonly sessionSummary: SessionSummaryEntry | undefined;\n\treadonly scopedModels: ReadonlyArray<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\treadonly promptTemplates: ReadonlyArray<PromptTemplate>;\n\treadonly pendingMessageCount: number;\n\treadonly resourceLoader: ResourceLoader;\n\treadonly autoCompactionEnabled: boolean;\n\treadonly isRetrying: boolean;\n\t/**\n\t * The session waits out a retry's backoff before its next attempt. A session with fallback models keeps its run\n\t * open through the wait, so it also reads as streaming then.\n\t */\n\treadonly isWaitingToRetry: boolean;\n\treadonly autoRetryEnabled: boolean;\n\treadonly isBashRunning: boolean;\n\treadonly hasPendingBashMessages: boolean;\n\treadonly extensionRunner: ExtensionRunner;\n\n\t_handleAgentEvent(event: AgentEvent): Promise<void> | void;\n\t_getRequiredRequestAuth(\n\t\tmodel: Model<Api>,\n\t\tsignal?: AbortSignal,\n\t): Promise<{ apiKey?: string; headers?: ProviderHeaders; baseUrl?: string }>;\n\t_installAgentToolHooks(): void;\n\t_installAgentNextTurnRefresh(): void;\n\t_installAgentRequestProjection(): void;\n\t_installAgentBoundaryHooks(): void;\n\t_refreshFinalizedContext(): void;\n\t_projectFinalizedMessages(): AgentMessage[];\n\trefreshContext(): void;\n\t_dispatchTurnEndBoundary(\n\t\tmessage: AssistantMessage,\n\t\ttoolResults: ToolResultMessage[],\n\t\tawaitPersistence?: boolean,\n\t): Promise<boolean>;\n\t_applyBoundaryDrafts(manager: SessionManager, drafts: SessionBoundaryDraft[]): Promise<SessionEntry[]>;\n\t_createBoundaryPreviewManager(drafts: SessionBoundaryDraft[]): Promise<SessionManager>;\n\t_getPendingBoundaryMessages(): AgentMessage[];\n\t_buildBoundaryContext(\n\t\tdrafts: SessionBoundaryDraft[],\n\t\tboundary: \"turn_end\" | \"agent_before_settle\",\n\t): Promise<BoundaryContextPreview>;\n\t_commitBoundaryDrafts(drafts: SessionBoundaryDraft[]): Promise<void>;\n\t_reportInvalidBoundaryContinuation(event: \"turn_end\" | \"agent_before_settle\"): void;\n\t_findPersistedMessageEntryId(message: AgentMessage): string | undefined;\n\t_omitRecoveryAttempt(message: AssistantMessage, toolResults?: AgentMessage[]): Promise<void>;\n\t_omitTrailingAssistantAttempt(accept?: (message: AssistantMessage) => boolean): Promise<boolean>;\n\t_runBeforeSettleBoundary(): Promise<boolean>;\n\t_emit(event: AgentSessionEvent): void;\n\t_emitQueueUpdate(): void;\n\t_createRetryPromiseForAgentEnd(event: AgentEvent): void;\n\t_findLastAssistantInMessages(messages: AgentMessage[]): AssistantMessage | undefined;\n\t_processAgentEvent(event: AgentEvent, retryGeneration?: number): Promise<void>;\n\t_applyInterruptAbortMessage(event: AgentEvent): void;\n\t_applyProviderErrorGuidance(event: AgentEvent): void;\n\t_resolveRetry(): void;\n\t_getUserMessageText(message: Message): string;\n\t_findLastAssistantMessage(): AssistantMessage | undefined;\n\t_replaceMessageInPlace(target: AgentMessage, replacement: AgentMessage): void;\n\t_emitExtensionEvent(event: AgentEvent): Promise<void>;\n\tsubscribe(\n\t\tsource: import(\"./event-subscriptions/types.js\").EventSource,\n\t\thandler: import(\"./event-subscriptions/session-subscription.js\").SessionEventHandler,\n\t\toptions?: import(\"./event-subscriptions/session-subscription.js\").SessionSubscribeOptions,\n\t): import(\"./event-subscriptions/types.js\").Subscription;\n\tsubscribe(listener: AgentSessionEventListener): () => void;\n\t_disconnectFromAgent(): void;\n\tdispose(): Promise<void>;\n\tgetAgentTaskHost(): import(\"./tasks/agent-adapter.js\").AgentTaskHost;\n\t_getCommandTaskOwner(): import(\"./tools/bash-pty-native.js\").SupervisedCommandOwner | undefined;\n\tcloseSessionTasks(): Promise<void>;\n\t/** Cancel owned execution without closing message admission. */\n\tpauseTasks(): Promise<void>;\n\tresumeTasks(): void;\n\n\tgetActiveToolNames(): string[];\n\tgetCallableToolNames(): string[];\n\tgetAllTools(): ToolInfo[];\n\tgetToolDefinition(name: string): ToolDefinition | undefined;\n\t/** Explain which tools are active, which are not (and why), and which selected names nothing registered. */\n\tgetToolStatus(): ToolStatusReport;\n\tgetToolStatusAsync(): Promise<ToolStatusReport>;\n\t/** The tool status without its Git section, so without running git. */\n\t_getToolStatusWithoutGit(): ToolStatusReport;\n\tsetActiveToolsByName(toolNames: string[]): void;\n\t_setActiveTools(toolNames: string[]): void;\n\tsetScopedModels(scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>): void;\n\t_normalizePromptSnippet(text: string | undefined): string | undefined;\n\t_normalizePromptGuidelines(guidelines: string[] | undefined): string[];\n\t_rebuildSystemPrompt(toolNames: string[]): void;\n\t_preparePromptAndToolLoadout(\n\t\toptions: NormalizedBuildSystemPromptOptions,\n\t\tmessages?: AgentMessage[],\n\t): SystemMessageWithTransformedPrompt | undefined;\n\t_restoreToolsFromTranscript(options?: { startup?: boolean }): void;\n\t_refreshBaseSystemPromptFromActiveTools(): void;\n\t_currentRunSystemPromptOptions(): NormalizedBuildSystemPromptOptions;\n\t_recordSystemPromptForModelSwitch(): Promise<void>;\n\t_recordTransformedPromptHead(): Promise<void> | undefined;\n\n\tprompt(text: string, options?: PromptOptions): Promise<void>;\n\t_runAgentPrompt(\n\t\tmessages: AgentMessage | AgentMessage[],\n\t\tpromptStarted?: () => void,\n\t\treportDispatch?: (disposition: PromptDisposition) => void,\n\t\tprepared?: boolean,\n\t\tcustomStarter?: CustomMessage,\n\t\tfallbackGeneration?: number,\n\t): Promise<void>;\n\t_runAgentContinue(): Promise<void>;\n\t_runAgentContinuation(beforeContinue: () => Promise<void>, mode?: \"continue\" | \"recovery\" | \"settle\"): Promise<void>;\n\t_continueQueuedAgentMessages(): Promise<void>;\n\t_tryExecuteExtensionCommand(text: string): Promise<boolean>;\n\t_expandSkillCommand(text: string): Promise<string>;\n\tsteer(\n\t\ttext: string,\n\t\timages?: ImageContent[],\n\t\toptions?: Pick<PromptOptions, \"source\" | \"expandPromptTemplates\">,\n\t): Promise<QueuedInputDisposition>;\n\tfollowUp(\n\t\ttext: string,\n\t\timages?: ImageContent[],\n\t\toptions?: Pick<PromptOptions, \"source\" | \"expandPromptTemplates\">,\n\t): Promise<QueuedInputDisposition>;\n\tsendUserMessage(\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\toptions?: { deliverAs?: \"steer\" | \"followUp\"; expandPromptTemplates?: boolean },\n\t): Promise<void>;\n\n\t_queueSteer(\n\t\ttext: string,\n\t\timages?: ImageContent[],\n\t\ttyped?: string,\n\t\trawText?: string,\n\t\treceiptId?: string,\n\t\toriginSendId?: string,\n\t): Promise<void>;\n\t_queueFollowUp(\n\t\ttext: string,\n\t\timages?: ImageContent[],\n\t\ttyped?: string,\n\t\trawText?: string,\n\t\treceiptId?: string,\n\t\toriginSendId?: string,\n\t): Promise<void>;\n\t_throwIfExtensionCommand(text: string): void;\n\tsendCustomMessage<T = unknown>(\n\t\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\t\toptions?: SendMessageOptions,\n\t): Promise<void>;\n\tsendCustomMessages<T = unknown>(\n\t\tmessages: Array<Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">>,\n\t\toptions?: SendMessagesOptions,\n\t): Promise<void>;\n\t_commitAdmittedCustomMessage<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_commitAdmittedCustomMessages<T>(messages: CustomMessage<T>[], options?: SendMessagesOptions): Promise<void>;\n\t_appendCustomMessage<T>(message: CustomMessage<T>): Promise<void>;\n\t_flushPendingCustomMessages(withinRun?: boolean): Promise<void>;\n\t_enqueueInterruptCustomMessage<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_sendInterruptCustomMessageNow<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_ensureActiveInterruptQueueHold(): InterruptQueueHold;\n\t_restoreAndClearActiveInterruptQueueHold(): void;\n\t_queueAgentMessage(message: AgentMessage, delivery: \"steer\" | \"followUp\" | \"interrupt\"): void;\n\t_drainQueuedAgentMessages(): DrainedAgentQueues;\n\t_restoreQueuedAgentMessages(queues: DrainedAgentQueues): void;\n\tclearQueue(options?: ClearQueueOptions): ClearedQueue;\n\tgetSteeringMessages(): readonly string[];\n\tgetFollowUpMessages(): readonly string[];\n\tabort(options?: SessionAbortOptions): Promise<void>;\n\t/** Ends the current turn without closing the session to further messages, as Esc does in a subagent's chat. */\n\tinterruptTurn(): Promise<void>;\n\t/**\n\t * Pauses the current turn as Esc does in a subagent's chat: returns the typed messages still queued, ends the turn,\n\t * and holds the rest of the queue until the next message continues the session.\n\t */\n\tpauseTurn(): Promise<ClearedQueue>;\n\t/** Continues a session `pauseTurn` paused: its hold is released, so the user's message sent next starts the turn. */\n\tresumeTurn(): Promise<void>;\n\t_sealMessageAdmissionIfDrained(): boolean;\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\"): void;\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\"): void;\n\n\t_emitModelChanged(\n\t\tnextModel: Model<Api>,\n\t\tpreviousModel: Model<Api> | undefined,\n\t\tsource: \"set\" | \"cycle\" | \"restore\" | \"fallback\",\n\t): void;\n\t_emitModelSelect(\n\t\tnextModel: Model<Api>,\n\t\tpreviousModel: Model<Api> | undefined,\n\t\tsource: \"set\" | \"cycle\" | \"restore\" | \"fallback\",\n\t): Promise<void>;\n\tsetModel(model: Model<Api>, options?: ModelMutationOptions & { thinkingLevel?: ThinkingLevel }): Promise<void>;\n\tcycleModel(\n\t\tdirection?: \"forward\" | \"backward\",\n\t\toptions?: ModelMutationOptions,\n\t): Promise<ModelCycleResult | undefined>;\n\t_cycleScopedModel(\n\t\tdirection: \"forward\" | \"backward\",\n\t\toptions: ModelMutationOptions,\n\t): Promise<ModelCycleResult | undefined>;\n\t_cycleAvailableModel(\n\t\tdirection: \"forward\" | \"backward\",\n\t\toptions: ModelMutationOptions,\n\t): Promise<ModelCycleResult | undefined>;\n\tsetThinkingLevel(level: ThinkingLevel, options?: ModelMutationOptions): Promise<void>;\n\tcycleThinkingLevel(options?: ModelMutationOptions): Promise<ThinkingLevel | undefined>;\n\tgetAvailableThinkingLevels(): ThinkingLevel[];\n\tsupportsThinking(): boolean;\n\t_getThinkingLevelForModelSwitch(targetModel?: Model<Api>, explicitLevel?: ThinkingLevel): ThinkingLevel;\n\t_clampThinkingLevel(level: ThinkingLevel, availableLevels: ThinkingLevel[]): ThinkingLevel;\n\t_recordThinkingLevel(): Promise<string> | undefined;\n\n\t_applyVerbatimCompaction(options: VerbatimCompactionApplyOptions): Promise<VerbatimCompactionResult | undefined>;\n\tcompact(options?: SessionCompactOptions): Promise<VerbatimCompactionResult>;\n\tabortCompaction(): void;\n\tabortBranchSummary(): void;\n\tabortSessionSummary(): void;\n\t_maybeGenerateSessionSummary(): Promise<void>;\n\t_checkCompaction(assistantMessage: AssistantMessage, skipAbortedCheck?: boolean): Promise<void>;\n\t_compactBeforeContinuation(input?: readonly AgentMessage[]): Promise<boolean>;\n\t_compactBeforeResumedPrompt(\n\t\tupdate: AgentMessage | undefined,\n\t\tinput: readonly AgentMessage[],\n\t\tsendsPrompt?: boolean,\n\t): Promise<boolean>;\n\t_continueAgentAfterCompactionCheck(): Promise<void>;\n\t_dropTrailingAutoCompactionRetryAssistantIfPresent(): Promise<void>;\n\t_schedulePostAutoCompactionContinuationProbe(reason: \"overflow\" | \"threshold\", willRetry: boolean): void;\n\t_awaitPendingPostCompactionContinuation(): Promise<void>;\n\t_resumeAfterAutoCompaction(): Promise<void>;\n\t_resumeAfterLengthTruncation(): Promise<void>;\n\t_runAutoCompaction(\n\t\treason: \"overflow\" | \"threshold\",\n\t\twillRetry: boolean,\n\t\turgency?: AutoCompactionUrgency,\n\t\tcoveredThroughEntryId?: string,\n\t): Promise<AutoCompactionRunOutcome>;\n\t_preflightPostToolContext(messages: AgentMessage[], signal?: AbortSignal): Promise<AgentMessage[]>;\n\t_finishPostToolCompactionPreflight(messages: AgentMessage[]): AgentMessage[];\n\tsetAutoCompactionEnabled(enabled: boolean): void;\n\t/** Give an agent without `read` or `search` the read-only `session_history` tool after a compaction boundary. */\n\t_enableSessionHistoryTool(): void;\n\n\tbindExtensions(bindings: ExtensionBindings): Promise<void>;\n\tstartPendingRecovery(reason?: SessionRecoveryReason): Promise<SessionRecoveryReport>;\n\tstartPendingRecoveryRestore(reason?: SessionRecoveryReason): Promise<SessionRecoveryReport>;\n\t/** Keep only the stored history and let go of everything live; rehydrate with `AgentSessionRuntime.rehydrate`. */\n\trelease(): Promise<import(\"./agent-session-release.ts\").ReleasedAgentSession>;\n\t/** Let calls of `detachable` tools that run longer than `policy.afterMs` go on without the run; `undefined` runs them inline. */\n\tsetToolDetachment(policy: ToolDetachmentPolicy | undefined): void;\n\t/** The calls the session's runs detached and the host has not taken yet; taking them clears the list. */\n\ttakeDetachedToolCalls(): DetachedToolCall[];\n\t/** Whether the transcript ends on a turn that issued a detachable call and has no answer from the model yet. */\n\thasPendingDetachedTurn(): boolean;\n\t/** Whether the transcript still waits on the result of a call of a detachable tool: nothing may start a turn. */\n\tisWaitingOnDetachedResults(): boolean;\n\t/** Start again the detachable calls the transcript ends on without a result, with their original ids and arguments. */\n\tredispatchDetachedToolCalls(): DetachedToolCall[];\n\t/** Record detached calls' results; the turn that issued them continues once each of its detachable calls has one. */\n\tresumeDetachedTurn(\n\t\tresults: readonly DetachedToolResult[],\n\t\tonRecorded?: (toolCallIds: readonly string[]) => void,\n\t): Promise<void>;\n\t_waitForExtensionStart(): Promise<void>;\n\textendResourcesFromExtensions(reason: \"startup\" | \"reload\"): Promise<void>;\n\tbuildExtensionResourcePaths(entries: ExtensionResourcePathEntry[]): ExtensionResourcePathResult[];\n\tgetExtensionSourceLabel(extensionPath: string): string;\n\t_applyExtensionBindings(runner: ExtensionRunner): void;\n\t_refreshCurrentModelFromRegistry(): Promise<void>;\n\trefreshCurrentModelFromRegistry(): Promise<void>;\n\t_bindExtensionCore(\n\t\trunner: ExtensionRunner,\n\t\tpublication?: {\n\t\t\tresourceLoader: ResourceLoader;\n\t\t\tproviderTransaction: ExtensionProviderTransaction;\n\t\t\tproviderIds: Set<string>;\n\t\t\tdefer(effect: () => void | Promise<void>): void;\n\t\t},\n\t\tstartupToolNames?: readonly string[],\n\t\tstartupLoadout?: RecordedToolLoadout,\n\t): void;\n\t_refreshToolRegistry(options?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean }): void;\n\t_buildRuntime(options: RuntimeBuildOptions): void;\n\treload(options?: AgentSessionReloadOptions): Promise<void>;\n\tcompleteStartupResources(resourceLoader: ResourceLoader): Promise<void>;\n\n\t_isRetryableError(message: AssistantMessage): boolean;\n\t_isFallbackableError(message: AssistantMessage): boolean;\n\t_isEmptyCompletion(message: AssistantMessage): boolean;\n\t_isSafetyRefusal(message: AssistantMessage): boolean;\n\t_handleRetryableError(message: AssistantMessage): Promise<boolean>;\n\t_trySwitchToFallbackModel(message: AssistantMessage): Promise<boolean>;\n\t_selectModelWithCredentials(): Promise<void>;\n\t_beginFallbackModelScope(): void;\n\t_clearFallbackModelScope(): void;\n\t_settleFallbackModelScope(): Promise<boolean>;\n\tabortRetry(): void;\n\twaitForRetry(): Promise<void>;\n\tsetAutoRetryEnabled(enabled: boolean): void;\n\n\texecuteBash(\n\t\tcommand: string,\n\t\tonChunk?: (chunk: string, channel: \"stdout\" | \"stderr\") => void,\n\t\toptions?: {\n\t\t\texcludeFromContext?: boolean;\n\t\t\tid?: string;\n\t\t\toperations?: BashOperations;\n\t\t\tpty?: boolean;\n\t\t\temitEvent?: boolean;\n\t\t\trecordResult?: boolean;\n\t\t},\n\t): Promise<BashResult>;\n\trecordBashResult(\n\t\tcommand: string,\n\t\tresult: BashResult,\n\t\toptions?: { excludeFromContext?: boolean; persist?: boolean; defer?: boolean },\n\t): Promise<void>;\n\tabortBash(id?: string): void;\n\t_flushPendingBashMessages(): Promise<void>;\n\n\tsetSessionName(name: string): Promise<void>;\n\tnavigateTree(\n\t\ttargetId: string,\n\t\toptions?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string },\n\t): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>;\n\tgetUserMessagesForForking(): Array<{ entryId: string; text: string }>;\n\t_extractUserMessageText(content: string | Array<{ type: string; text?: string }>): string;\n\n\tgetSessionStats(): SessionStats;\n\tgetContextUsage(): ContextUsage | undefined;\n\texportToHtml(outputPath?: string, options?: { themeName?: string }): Promise<string>;\n\t/**\n\t * `snapshotContent: false` leaves worktree snapshot patch and bundle content out of the file, and\n\t * `toolOutputContent: false` the tool outputs kept as session blobs.\n\t */\n\texportToJsonl(\n\t\toutputPath?: string,\n\t\toptions?: { includeShareContext?: boolean; snapshotContent?: boolean; toolOutputContent?: boolean },\n\t): Promise<string>;\n\tgetLastAssistantText(): string | undefined;\n\tcreateReplacedSessionContext(): ReplacedSessionContext;\n\thasExtensionHandlers(eventType: string): boolean;\n\tgetPersistenceFailure(): PersistenceFailure | undefined;\n\tgetUnsavedInput(): UnsavedInput | undefined;\n\tdiscardUnsavedInput(): void;\n}\n\nexport interface AgentSessionPublicSurface\n\textends Pick<\n\t\tAgentSessionMethodSurface,\n\t\t| \"getAgentTaskHost\"\n\t\t| \"closeSessionTasks\"\n\t\t| \"modelRuntime\"\n\t\t| \"state\"\n\t\t| \"model\"\n\t\t| \"thinkingLevel\"\n\t\t| \"isStreaming\"\n\t\t| \"systemPrompt\"\n\t\t| \"retryAttempt\"\n\t\t| \"retryStatus\"\n\t\t| \"turnStartedAt\"\n\t\t| \"isCompacting\"\n\t\t| \"compactionReason\"\n\t\t| \"compactionStartedAt\"\n\t\t| \"messages\"\n\t\t| \"transcriptMessages\"\n\t\t| \"steeringMode\"\n\t\t| \"followUpMode\"\n\t\t| \"sessionFile\"\n\t\t| \"sessionId\"\n\t\t| \"sessionName\"\n\t\t| \"sessionSummary\"\n\t\t| \"scopedModels\"\n\t\t| \"promptTemplates\"\n\t\t| \"pendingMessageCount\"\n\t\t| \"resourceLoader\"\n\t\t| \"autoCompactionEnabled\"\n\t\t| \"isRetrying\"\n\t\t| \"isWaitingToRetry\"\n\t\t| \"autoRetryEnabled\"\n\t\t| \"abortSessionSummary\"\n\t\t| \"isBashRunning\"\n\t\t| \"hasPendingBashMessages\"\n\t\t| \"extensionRunner\"\n\t\t| \"queuedMessagesPaused\"\n\t\t| \"pauseQueuedMessages\"\n\t\t| \"resumeQueuedMessages\"\n\t\t| \"subscribe\"\n\t\t| \"dispose\"\n\t\t| \"getActiveToolNames\"\n\t\t| \"getCallableToolNames\"\n\t\t| \"getAllTools\"\n\t\t| \"getToolDefinition\"\n\t\t| \"getToolStatus\"\n\t\t| \"getToolStatusAsync\"\n\t\t| \"setActiveToolsByName\"\n\t\t| \"setScopedModels\"\n\t\t| \"prompt\"\n\t\t| \"steer\"\n\t\t| \"followUp\"\n\t\t| \"sendCustomMessage\"\n\t\t| \"sendCustomMessages\"\n\t\t| \"sendUserMessage\"\n\t\t| \"clearQueue\"\n\t\t| \"getSteeringMessages\"\n\t\t| \"getFollowUpMessages\"\n\t\t| \"abort\"\n\t\t| \"interruptTurn\"\n\t\t| \"pauseTurn\"\n\t\t| \"resumeTurn\"\n\t\t| \"turnPaused\"\n\t\t| \"setModel\"\n\t\t| \"cycleModel\"\n\t\t| \"setThinkingLevel\"\n\t\t| \"cycleThinkingLevel\"\n\t\t| \"getAvailableThinkingLevels\"\n\t\t| \"supportsThinking\"\n\t\t| \"setSteeringMode\"\n\t\t| \"setFollowUpMode\"\n\t\t| \"compact\"\n\t\t| \"abortCompaction\"\n\t\t| \"abortBranchSummary\"\n\t\t| \"setAutoCompactionEnabled\"\n\t\t| \"bindExtensions\"\n\t\t| \"startPendingRecovery\"\n\t\t| \"startPendingRecoveryRestore\"\n\t\t| \"release\"\n\t\t| \"setToolDetachment\"\n\t\t| \"takeDetachedToolCalls\"\n\t\t| \"hasPendingDetachedTurn\"\n\t\t| \"isWaitingOnDetachedResults\"\n\t\t| \"redispatchDetachedToolCalls\"\n\t\t| \"resumeDetachedTurn\"\n\t\t| \"refreshCurrentModelFromRegistry\"\n\t\t| \"reload\"\n\t\t| \"completeStartupResources\"\n\t\t| \"abortRetry\"\n\t\t| \"setAutoRetryEnabled\"\n\t\t| \"executeBash\"\n\t\t| \"recordBashResult\"\n\t\t| \"abortBash\"\n\t\t| \"setSessionName\"\n\t\t| \"navigateTree\"\n\t\t| \"getUserMessagesForForking\"\n\t\t| \"getSessionStats\"\n\t\t| \"getContextUsage\"\n\t\t| \"refreshContext\"\n\t\t| \"exportToHtml\"\n\t\t| \"exportToJsonl\"\n\t\t| \"getLastAssistantText\"\n\t\t| \"createReplacedSessionContext\"\n\t\t| \"hasExtensionHandlers\"\n\t\t| \"getPersistenceFailure\"\n\t\t| \"getUnsavedInput\"\n\t\t| \"discardUnsavedInput\"\n\t> {\n\treadonly agent: Agent;\n\treadonly sessionManager: SessionManager;\n\treadonly settingsManager: SettingsManager;\n}\n\nexport interface AgentSessionInternalSurface extends AgentSessionMethodSurface, AgentSessionPublicSurface {\n\t_scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\t_fallbackModels: string[];\n\t_isFallbackModelAllowed?: (model: Model<Api>, effort: string | undefined) => boolean;\n\t_fallbackAttemptedKeys: Set<string>;\n\t_fallbackBlockedModels: Array<Model<Api>>;\n\t_fallbackBlockedProviders: Set<string>;\n\t_fallbackOriginModel: Model<Api> | undefined;\n\t_fallbackOriginThinkingLevel: ThinkingLevel | undefined;\n\t_fallbackScopeGeneration: number;\n\t_fallbackOriginGeneration: number | undefined;\n\t_fallbackRestoreError: string | undefined;\n\n\t_unsubscribeAgent?: () => void;\n\t_eventListeners: AgentSessionEventListener[];\n\t_agentEventQueue: Promise<void>;\n\t_steeringMessages: string[];\n\t_followUpMessages: string[];\n\t_interruptDeliveryQueue: Promise<void>;\n\t_pendingPostCompactionContinuation: Promise<void> | undefined;\n\t_postCompactionContinuationToken: number;\n\t_lengthContinuationAttempts: number;\n\t_outputBudgetErrorContinuationAttempts: number;\n\t_postToolCompactionPreflightError: string | undefined;\n\t_pendingPostToolCompactionGuard: PendingPostToolCompactionGuard | undefined;\n\t/** Set once a compaction boundary gave this restricted agent the `session_history` tool. */\n\t_sessionHistoryToolEnabled: boolean;\n\t_terminatingToolCallIds: Set<string>;\n\t_stopAfterTurnBlockedContinuation: boolean;\n\t/** The current turn was ended by {@link interruptTurn}: a child's message admission stays open after it. */\n\t_turnInterruptedByUser: boolean;\n\t_abortPreparedRunAtStart: boolean;\n\t_startAbortedForInterrupt: boolean;\n\t_awaitingStartAfterInterrupt: boolean;\n\t_undeliveredAgentStarts: number;\n\t/** A child whose turn the user interrupted waits here: the next message it receives starts its next turn. */\n\t_awaitingMessageAfterInterrupt: boolean;\n\t/** A `pauseTurn` holds the queue: settles once its run did, and the user's continue releases the hold. */\n\t_turnPause: TurnPause | undefined;\n\t/** The release of a `pauseTurn` hold under way, which every next message waits for. */\n\t_turnPauseRelease: Promise<void> | undefined;\n\t_pendingInterruptDeliveries: number;\n\t_priorityInterruptPending: boolean;\n\t_activePromptCount: number;\n\t_isPreparingRun: false | \"user\" | \"custom\";\n\t_promptPreflightCount: number;\n\t_agentRunAbortRequested: boolean;\n\t_cacheWarmer?: import(\"./cache-warmer.ts\").CacheWarmer;\n\t_activeInterruptQueueHold: InterruptQueueHold | undefined;\n\t_queuedMessagesPaused: boolean;\n\t_queuedMessagesPauseAbortBoundary: Promise<void> | undefined;\n\t_admittedQueuedMessageAwaitingReply: string | undefined;\n\t_admittedRecoveryTurn: Promise<void> | undefined;\n\t_activeInterruptAbortMessage: string | undefined;\n\t_pendingNextTurnMessages: CustomMessage[];\n\t_pendingCustomMessages: CustomMessage[];\n\t_protectedStreamingCustomMessages: Array<{\n\t\tmessage: CustomMessage;\n\t\tdelivery: \"steer\" | \"followUp\";\n\t\tphase: \"queued\" | \"consumed-unpersisted\" | \"persistence-failed\";\n\t}>;\n\t_compactionAbortController: AbortController | undefined;\n\t_manualCompactionPromise: Promise<VerbatimCompactionResult> | undefined;\n\t_autoCompactionAbortController: AbortController | undefined;\n\t/** Stops the compactor request of the running compaction, which then clears the context instead. */\n\t_compactorAbortController: AbortController | undefined;\n\t_autoCompactionCompletion: Promise<void> | undefined;\n\t_compactionReason: import(\"./agent-session-types.js\").CompactionReason | undefined;\n\t_compactionStartedAt: number | undefined;\n\t_overflowRecoveryAttempted: boolean;\n\t_recoverableLengthRecoveryAttempted: boolean;\n\t_contextOverflowUnresolved: boolean;\n\t_branchSummaryAbortController: AbortController | undefined;\n\t_branchSummaryCompletion: Promise<void> | undefined;\n\t_retryAbortController: AbortController | undefined;\n\t_retryAttempt: number;\n\t_retryStatus?: import(\"./session-retry-status.js\").SessionRetryStatus;\n\t_turnStartedAt?: number;\n\t_longStreamCutRetries: number;\n\t_retryPromise: Promise<void> | undefined;\n\t_retryResolve: (() => void) | undefined;\n\t_retryGeneration: number;\n\t_agentRunRetryGeneration: number;\n\t_bashAbortControllers: Map<string | symbol, Set<AbortController>>;\n\t_pendingBashMessages: BashExecutionMessage[];\n\t_runOnlyBashMessages?: WeakSet<object>;\n\t_extensionRunner: ExtensionRunner;\n\t_turnIndex: number;\n\treadonly _entryIdsByMessage: WeakMap<object, string>;\n\treadonly _boundaryDispatchedMessages: WeakSet<object>;\n\treadonly _messagesAwaitingPersistence: WeakMap<object, Promise<void>>;\n\t_transcriptAppend: { message: AgentMessage; previousLeaf: string | null; owner?: object } | undefined;\n\treadonly _messagesWithFailedPersistence: WeakSet<object>;\n\t_persistenceFailure: string | undefined;\n\t_turnStopReason: string | undefined;\n\t_worktreeSnapshots: import(\"./session-worktree-snapshots.ts\").SessionWorktreeSnapshotRecorder;\n\treadonly _reissuedToolCallIds: Set<string>;\n\t_lastAssistantToolResults: AgentMessage[];\n\t_lastActivityOutcome: AgentActivityOutcome;\n\t_isBeforeSettle: boolean;\n\t_abortDuringBeforeSettle: boolean;\n\t_isEmittingAgentSettled: boolean;\n\treadonly _deferredSettledActions: Array<() => Promise<void>>;\n\t_callerReplacedNextRequestContext: boolean;\n\t_resourceLoader: ResourceLoader;\n\t_customTools: ToolDefinition[];\n\t_baseToolDefinitions: Map<string, ToolDefinition>;\n\t_cwd: string;\n\t_extensionRunnerRef?: { current?: ExtensionRunner };\n\t_initialActiveToolNames?: string[];\n\t_pendingToolNames: Set<string>;\n\t_restoredToolNames: Set<string>;\n\t_explicitToolDeactivations: Set<string>;\n\t_usesDefaultTools: boolean;\n\t_defaultToolModifiers: string[];\n\t_appliedDefaultTools: Set<string>;\n\t_allowedToolNames?: Set<string>;\n\t_excludedToolNames?: Set<string>;\n\t_allowedTools?: (name: string) => boolean;\n\t_excludedTools?: (name: string) => boolean;\n\t_childSessionOptions?: import(\"./child-session-options.ts\").ChildSessionOptionsResolver;\n\t_storageAgentDir?: string;\n\t_baseToolsOverride?: Record<string, AgentTool>;\n\t_sessionStartEvent: SessionStartEvent;\n\t_workspace?: import(\"./workspace/resolve.ts\").BoundWorkspace;\n\t_subagentPolicy?: import(\"./extensions/index.js\").SubagentChildPolicy;\n\t_intercomPolicy?: import(\"./intercom-policy.ts\").SessionIntercomPolicy;\n\t_subagentMessageAdmission?: import(\"./message-admission.js\").MessageAdmissionBoundary;\n\t_extensionUIContext?: ExtensionUIContext;\n\t_extensionHumanInput?: import(\"./extensions/host-input.js\").HostInput | null;\n\t_extensionDiagnosticListener?: (diagnostic: import(\"./extensions/host-input.js\").HostDiagnostic) => void;\n\t_extensionMode: ExtensionMode;\n\t_disposed: boolean;\n\t_close(event: import(\"./extensions/types.ts\").SessionShutdownEvent, beforeInvalidate?: () => void): Promise<void>;\n\t_sessionSummaryAbortController: AbortController | undefined;\n\t_sessionSummaryToken: number;\n\t_sessionSummaryRun: import(\"./agent-session-summary.ts\").SessionSummaryRun | undefined;\n\t_lastSummarizedMessageId: string | undefined;\n\t_extensionCommandContextActions?: ExtensionCommandContextActions;\n\t_extensionShutdownHandler?: () => void;\n\t_extensionErrorListener?: ExtensionErrorListener;\n\t_extensionErrorUnsubscriber?: () => void;\n\t_modelRuntime: ModelRuntime;\n\t_extensionProviderIds: Set<string>;\n\t_toolRegistry: Map<string, AgentTool>;\n\t_toolExecutionScheduler: ToolExecutionScheduler;\n\t_outerWorktreeRootMappings: readonly WorktreeRootMapping[];\n\t_worktreeRestoreNotices: readonly string[];\n\t_toolDefinitions: Map<string, ToolDefinitionEntry>;\n\t_toolPromptSnippets: Map<string, string>;\n\t_toolPromptGuidelines: Map<string, string[]>;\n\t_baseSystemPromptOptions: NormalizedBuildSystemPromptOptions;\n\t_systemPromptTransform?: (prompt: string) => string;\n\t_systemPromptSections?: import(\"./sdk-types.ts\").SystemPromptSectionsTransform;\n\t_transformedPromptHead?: import(\"./transformed-system-prompt.ts\").TransformedPrompt;\n\t_contextProjectionTransform?: (messages: AgentMessage[]) => AgentMessage[];\n\t_requestContextProjectionTransform?: (messages: AgentMessage[]) => AgentMessage[];\n\t/** The restored history's last message until the first request after a resume; see `_compactBeforeResumedPrompt`. */\n\t_resumeBudgetCheckpoint?: AgentMessage;\n\t/**\n\t * What the check of `_resumeBudgetCheckpoint` for a run that sends the session's prompt as it is now (a prompt, or a\n\t * run an extension starts) found that prompt to need: its update, or null when the prompt was current. Undefined\n\t * until such a run is checked. A conversation request retires the checkpoint once the transcript it sends holds that\n\t * update, at once when it is null; see `_compactBeforeResumedPrompt`.\n\t */\n\t_resumePromptUpdate?: AgentMessage | null;\n\t/**\n\t * The prompt update a resume needs, as the first check of a run that does not send the session's prompt (an\n\t * interrupt, queued input) found it while one was pending. Until the checkpoint retires, a later turn of such a run\n\t * leaves out what it changes or adds; see `withoutResumeUpdate`.\n\t */\n\t_resumeHeldUpdate?: SystemMessageWithTransformedPrompt;\n\t_runSystemPromptOptions?: NormalizedBuildSystemPromptOptions;\n\t/**\n\t * The prompt sections that the latest sent prompt's `before_agent_start` handlers set, replaced or removed relative\n\t * to the base options, such as the MCP servers' section, for the extensions of `runner` (held weakly, so a reload's\n\t * retired extensions can be collected). A run that starts without a prompt (an interrupt, queued input) keeps them\n\t * as the conversation last had them; see `_currentRunSystemPromptOptions`.\n\t */\n\t_promptSectionNames?: { runner: WeakRef<ExtensionRunner>; names: ReadonlySet<string> };\n\t_lastAssistantMessage: AssistantMessage | undefined;\n\t_tempStorageLease: import(\"./tools/session-temp-dir.ts\").ProtectedPathLease | undefined;\n\t_sessionOpenMarker: (() => Promise<void>) | undefined;\n\t_agentTaskHost: import(\"./tasks/agent-adapter.js\").AgentTaskHost | undefined;\n\t_parentCommandTaskOwner: import(\"./tasks/child-command-owner.js\").ChildCommandTaskOwner | undefined;\n\t_inheritedHistory: import(\"./tools/history-protocol.ts\").ProjectHistory | undefined;\n\t_resourceAdmission: import(\"./sdk-types.ts\").ResourceAdmission | undefined;\n\t_childTaskWaits: import(\"./tasks/child-command-owner.js\").ChildTaskWaits;\n\t_taskCompletionOutbox: import(\"./tasks/completion.js\").TaskCompletionOutbox | undefined;\n\t_taskAdmission: import(\"./message-admission.js\").MessageAdmissionBoundary | undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"agent-session-methods.js","sourceRoot":"","sources":["../../src/core/agent-session-methods.ts"],"names":[],"mappings":"","sourcesContent":["import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, ThinkingLevel } from \"@bastani/atomic-agent-core\";\nimport type { ProviderHeaders } from \"@bastani/atomic-ai\";\nimport type {\n\tApi,\n\tAssistantMessage,\n\tImageContent,\n\tMessage,\n\tModel,\n\tTextContent,\n\tToolResultMessage,\n} from \"@bastani/atomic-ai/compat\";\nimport type { DetachedToolCall, DetachedToolResult, ToolDetachmentPolicy } from \"./agent-session-detached-tools.ts\";\nimport type { PersistenceFailure, UnsavedInput } from \"./agent-session-persistence-failures.ts\";\nimport type { PendingPostToolCompactionGuard } from \"./agent-session-post-tool-compaction.ts\";\nimport type { RecordedToolLoadout } from \"./agent-session-state.ts\";\nimport type {\n\tAgentSessionEvent,\n\tAgentSessionEventListener,\n\tAgentSessionReloadOptions,\n\tClearedQueue,\n\tClearQueueOptions,\n\tDrainedAgentQueues,\n\tExtensionBindings,\n\tInterruptQueueHold,\n\tModelCycleResult,\n\tModelMutationOptions,\n\tPromptDisposition,\n\tPromptOptions,\n\tQueuedInputDisposition,\n\tSessionAbortOptions,\n\tSessionRecoveryReport,\n\tSessionStats,\n\tToolDefinitionEntry,\n} from \"./agent-session-types.js\";\nimport type { BashResult } from \"./bash-executor.ts\";\nimport type { VerbatimCompactionResult } from \"./compaction/index.ts\";\nimport type {\n\tAgentActivityOutcome,\n\tBoundaryContextPreview,\n\tContextUsage,\n\tExtensionCommandContextActions,\n\tExtensionErrorListener,\n\tExtensionMode,\n\tExtensionRunner,\n\tExtensionUIContext,\n\tReplacedSessionContext,\n\tSendMessageOptions,\n\tSendMessagesOptions,\n\tSessionBoundaryDraft,\n\tSessionRecoveryReason,\n\tSessionStartEvent,\n\tToolDefinition,\n\tToolInfo,\n} from \"./extensions/index.js\";\nimport type { BashExecutionMessage, CustomMessage } from \"./messages.ts\";\nimport type { ExtensionProviderTransaction, ModelRuntime } from \"./model-runtime.js\";\nimport type { PathMetadata } from \"./package-manager.ts\";\nimport type { PromptTemplate } from \"./prompt-templates.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { BranchSummaryEntry, SessionEntry, SessionManager, SessionSummaryEntry } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { NormalizedBuildSystemPromptOptions } from \"./system-prompt.ts\";\nimport type { ToolStatusReport } from \"./tool-status.js\";\nimport type { BashOperations } from \"./tools/bash.js\";\nimport type { ToolExecutionScheduler } from \"./tools/tool-concurrency.ts\";\nimport type { SystemMessageWithTransformedPrompt } from \"./transformed-system-prompt.ts\";\nimport type { WorktreeRootMapping } from \"./worktree-snapshot/types.ts\";\n\nexport interface SessionCompactOptions {\n\t/** Instructions for this compaction: what to recover first, and the compactor's query. */\n\tquery?: string;\n\t/**\n\t * `auto` or an exact compactor model `provider/model` for this run only; overrides the `compactionModel` setting\n\t * without saving it. Any other value clears the context with a notice.\n\t */\n\tcompactionModel?: string;\n}\n\nexport interface VerbatimCompactionApplyOptions {\n\tabortController: AbortController;\n\tbackupLabel: string;\n\tquery?: string;\n\tcompactionModel?: string;\n\treason: \"manual\" | \"threshold\" | \"overflow\";\n\t/** Reports when a session_before_compact override becomes the active compaction source. */\n\tonCompactionSource?: (fromExtension: boolean) => void;\n\t/** Last entry the boundary covers; the entries after it stay in the context as they are. Default: all of them. */\n\tcoveredThroughEntryId?: string;\n}\n\n/**\n * How much an automatic compaction is load-bearing: `load_bearing` when the turn cannot continue without it (a provider\n * overflow), `recoverable` otherwise. Only a load-bearing failure marks the overflow unresolved.\n */\nexport type AutoCompactionUrgency = \"recoverable\" | \"load_bearing\";\n\n/** Outcome of an automatic compaction admission and persistence attempt. */\nexport type AutoCompactionRunOutcome = \"compacted\" | \"not_compactable\" | \"deferred\" | \"failed\";\n\nexport interface ExtensionResourcePathEntry {\n\tpath: string;\n\textensionPath: string;\n}\n\nexport interface ExtensionResourcePathResult {\n\tpath: string;\n\tmetadata: PathMetadata;\n}\n\nexport interface RuntimeBuildOptions {\n\tactiveToolNames?: string[];\n\tflagValues?: Map<string, boolean | string>;\n\tincludeAllExtensionTools?: boolean;\n\tpreserveRunner?: boolean;\n\tpowerShellAvailable: boolean;\n}\n\n/** The settlement of the run a `pauseTurn` ended. Spelled out, as published declarations may predate `PromiseWithResolvers`. */\nexport interface TurnPause {\n\treadonly promise: Promise<void>;\n\tresolve(): void;\n}\n\nexport interface AgentSessionQueuePauseControl {\n\treadonly queuedMessagesPaused: boolean;\n\t/** Whether Esc in the session's chat paused it (`pauseTurn`): its queue is held until the user continues it. */\n\treadonly turnPaused: boolean;\n\tpauseQueuedMessages(): void;\n\t/** Release the hold without starting a turn; true means raw queued work was released. */\n\tresumeQueuedMessages(beforeRelease?: () => void): Promise<boolean>;\n}\n\nexport interface AgentSessionMethodSurface extends AgentSessionQueuePauseControl {\n\treadonly modelRuntime: ModelRuntime;\n\treadonly state: AgentState;\n\treadonly model: Model<Api> | undefined;\n\treadonly thinkingLevel: ThinkingLevel;\n\treadonly isStreaming: boolean;\n\treadonly systemPrompt: string;\n\treadonly retryAttempt: number;\n\treadonly retryStatus?: import(\"./session-retry-status.js\").SessionRetryStatus;\n\t/** Time of the current turn's first request, including waits and later attempts; absent between turns. */\n\treadonly turnStartedAt?: number;\n\treadonly isCompacting: boolean;\n\treadonly compactionReason?: import(\"./agent-session-types.js\").CompactionReason;\n\treadonly compactionStartedAt?: number;\n\treadonly messages: AgentMessage[];\n\t/** The settled chat rows, including admitted messages whose save is still in flight. */\n\treadonly transcriptMessages: AgentMessage[];\n\treadonly steeringMode: \"all\" | \"one-at-a-time\";\n\treadonly followUpMode: \"all\" | \"one-at-a-time\";\n\treadonly sessionFile: string | undefined;\n\treadonly sessionId: string;\n\treadonly sessionName: string | undefined;\n\treadonly sessionSummary: SessionSummaryEntry | undefined;\n\treadonly scopedModels: ReadonlyArray<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\treadonly promptTemplates: ReadonlyArray<PromptTemplate>;\n\treadonly pendingMessageCount: number;\n\treadonly resourceLoader: ResourceLoader;\n\treadonly autoCompactionEnabled: boolean;\n\treadonly isRetrying: boolean;\n\t/**\n\t * The session waits out a retry's backoff before its next attempt. A session with fallback models keeps its run\n\t * open through the wait, so it also reads as streaming then.\n\t */\n\treadonly isWaitingToRetry: boolean;\n\treadonly autoRetryEnabled: boolean;\n\treadonly isBashRunning: boolean;\n\treadonly hasPendingBashMessages: boolean;\n\treadonly extensionRunner: ExtensionRunner;\n\n\t_handleAgentEvent(event: AgentEvent): Promise<void> | void;\n\t_getRequiredRequestAuth(\n\t\tmodel: Model<Api>,\n\t\tsignal?: AbortSignal,\n\t): Promise<{ apiKey?: string; headers?: ProviderHeaders; baseUrl?: string }>;\n\t_installAgentToolHooks(): void;\n\t_installAgentNextTurnRefresh(): void;\n\t_installAgentRequestProjection(): void;\n\t_installAgentBoundaryHooks(): void;\n\t_refreshFinalizedContext(): void;\n\t_projectFinalizedMessages(): AgentMessage[];\n\trefreshContext(): void;\n\t_dispatchTurnEndBoundary(\n\t\tmessage: AssistantMessage,\n\t\ttoolResults: ToolResultMessage[],\n\t\tawaitPersistence?: boolean,\n\t): Promise<boolean>;\n\t_applyBoundaryDrafts(manager: SessionManager, drafts: SessionBoundaryDraft[]): Promise<SessionEntry[]>;\n\t_createBoundaryPreviewManager(drafts: SessionBoundaryDraft[]): Promise<SessionManager>;\n\t_getPendingBoundaryMessages(): AgentMessage[];\n\t_buildBoundaryContext(\n\t\tdrafts: SessionBoundaryDraft[],\n\t\tboundary: \"turn_end\" | \"agent_before_settle\",\n\t): Promise<BoundaryContextPreview>;\n\t_commitBoundaryDrafts(drafts: SessionBoundaryDraft[]): Promise<void>;\n\t_reportInvalidBoundaryContinuation(event: \"turn_end\" | \"agent_before_settle\"): void;\n\t_findPersistedMessageEntryId(message: AgentMessage): string | undefined;\n\t_omitRecoveryAttempt(message: AssistantMessage, toolResults?: AgentMessage[]): Promise<void>;\n\t_omitTrailingAssistantAttempt(accept?: (message: AssistantMessage) => boolean): Promise<boolean>;\n\t_runBeforeSettleBoundary(): Promise<boolean>;\n\t_emit(event: AgentSessionEvent): void;\n\t_emitQueueUpdate(): void;\n\t_createRetryPromiseForAgentEnd(event: AgentEvent): void;\n\t_findLastAssistantInMessages(messages: AgentMessage[]): AssistantMessage | undefined;\n\t_processAgentEvent(event: AgentEvent, retryGeneration?: number): Promise<void>;\n\t_applyInterruptAbortMessage(event: AgentEvent): void;\n\t_applyProviderErrorGuidance(event: AgentEvent): void;\n\t_resolveRetry(): void;\n\t_getUserMessageText(message: Message): string;\n\t_findLastAssistantMessage(): AssistantMessage | undefined;\n\t_replaceMessageInPlace(target: AgentMessage, replacement: AgentMessage): void;\n\t_emitExtensionEvent(event: AgentEvent): Promise<void>;\n\tsubscribe(\n\t\tsource: import(\"./event-subscriptions/types.js\").EventSource,\n\t\thandler: import(\"./event-subscriptions/session-subscription.js\").SessionEventHandler,\n\t\toptions?: import(\"./event-subscriptions/session-subscription.js\").SessionSubscribeOptions,\n\t): import(\"./event-subscriptions/types.js\").Subscription;\n\tsubscribe(listener: AgentSessionEventListener): () => void;\n\t_disconnectFromAgent(): void;\n\tdispose(): Promise<void>;\n\tgetAgentTaskHost(): import(\"./tasks/agent-adapter.js\").AgentTaskHost;\n\t_getCommandTaskOwner(): import(\"./tools/bash-pty-native.js\").SupervisedCommandOwner | undefined;\n\tcloseSessionTasks(): Promise<void>;\n\t/** Cancel owned execution without closing message admission. */\n\tpauseTasks(): Promise<void>;\n\tresumeTasks(): void;\n\n\tgetActiveToolNames(): string[];\n\tgetCallableToolNames(): string[];\n\tgetAllTools(): ToolInfo[];\n\tgetToolDefinition(name: string): ToolDefinition | undefined;\n\t/** Explain which tools are active, which are not (and why), and which selected names nothing registered. */\n\tgetToolStatus(): ToolStatusReport;\n\tgetToolStatusAsync(): Promise<ToolStatusReport>;\n\t/** The tool status without its Git section, so without running git. */\n\t_getToolStatusWithoutGit(): ToolStatusReport;\n\tsetActiveToolsByName(toolNames: string[]): void;\n\t_setActiveTools(toolNames: string[]): void;\n\tsetScopedModels(scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>): void;\n\t_normalizePromptSnippet(text: string | undefined): string | undefined;\n\t_normalizePromptGuidelines(guidelines: string[] | undefined): string[];\n\t_rebuildSystemPrompt(toolNames: string[]): void;\n\t_preparePromptAndToolLoadout(\n\t\toptions: NormalizedBuildSystemPromptOptions,\n\t\tmessages?: AgentMessage[],\n\t): SystemMessageWithTransformedPrompt | undefined;\n\t_restoreToolsFromTranscript(options?: { startup?: boolean }): void;\n\t_refreshBaseSystemPromptFromActiveTools(): void;\n\t_currentRunSystemPromptOptions(): NormalizedBuildSystemPromptOptions;\n\t_recordSystemPromptForModelSwitch(): Promise<void>;\n\t_recordTransformedPromptHead(): Promise<void> | undefined;\n\n\tprompt(text: string, options?: PromptOptions): Promise<void>;\n\t_runAgentPrompt(\n\t\tmessages: AgentMessage | AgentMessage[],\n\t\tpromptStarted?: () => void,\n\t\treportDispatch?: (disposition: PromptDisposition) => void,\n\t\tprepared?: boolean,\n\t\tcustomStarter?: CustomMessage,\n\t\tfallbackGeneration?: number,\n\t): Promise<void>;\n\t_runAgentContinue(): Promise<void>;\n\t_runAgentContinuation(beforeContinue: () => Promise<void>, mode?: \"continue\" | \"recovery\" | \"settle\"): Promise<void>;\n\t_continueQueuedAgentMessages(): Promise<void>;\n\t_tryExecuteExtensionCommand(text: string): Promise<boolean>;\n\t_expandSkillCommand(text: string): Promise<string>;\n\tsteer(\n\t\ttext: string,\n\t\timages?: ImageContent[],\n\t\toptions?: Pick<PromptOptions, \"source\" | \"expandPromptTemplates\">,\n\t): Promise<QueuedInputDisposition>;\n\tfollowUp(\n\t\ttext: string,\n\t\timages?: ImageContent[],\n\t\toptions?: Pick<PromptOptions, \"source\" | \"expandPromptTemplates\">,\n\t): Promise<QueuedInputDisposition>;\n\tsendUserMessage(\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\toptions?: { deliverAs?: \"steer\" | \"followUp\"; expandPromptTemplates?: boolean },\n\t): Promise<void>;\n\n\t_queueSteer(\n\t\ttext: string,\n\t\timages?: ImageContent[],\n\t\ttyped?: string,\n\t\trawText?: string,\n\t\treceiptId?: string,\n\t\toriginSendId?: string,\n\t): Promise<void>;\n\t_queueFollowUp(\n\t\ttext: string,\n\t\timages?: ImageContent[],\n\t\ttyped?: string,\n\t\trawText?: string,\n\t\treceiptId?: string,\n\t\toriginSendId?: string,\n\t): Promise<void>;\n\t_throwIfExtensionCommand(text: string): void;\n\tsendCustomMessage<T = unknown>(\n\t\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\t\toptions?: SendMessageOptions,\n\t): Promise<void>;\n\tsendCustomMessages<T = unknown>(\n\t\tmessages: Array<Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">>,\n\t\toptions?: SendMessagesOptions,\n\t): Promise<void>;\n\t_commitAdmittedCustomMessage<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_commitAdmittedCustomMessages<T>(messages: CustomMessage<T>[], options?: SendMessagesOptions): Promise<void>;\n\t_appendCustomMessage<T>(message: CustomMessage<T>): Promise<void>;\n\t_flushPendingCustomMessages(withinRun?: boolean): Promise<void>;\n\t_enqueueInterruptCustomMessage<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_sendInterruptCustomMessageNow<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_ensureActiveInterruptQueueHold(): InterruptQueueHold;\n\t_restoreAndClearActiveInterruptQueueHold(): void;\n\t_queueAgentMessage(message: AgentMessage, delivery: \"steer\" | \"followUp\" | \"interrupt\"): void;\n\t_drainQueuedAgentMessages(): DrainedAgentQueues;\n\t_restoreQueuedAgentMessages(queues: DrainedAgentQueues): void;\n\tclearQueue(options?: ClearQueueOptions): ClearedQueue;\n\tgetSteeringMessages(): readonly string[];\n\tgetFollowUpMessages(): readonly string[];\n\tabort(options?: SessionAbortOptions): Promise<void>;\n\t/** Ends the current turn without closing the session to further messages, as Esc does in a subagent's chat. */\n\tinterruptTurn(): Promise<void>;\n\t/**\n\t * Pauses the current turn as Esc does in a subagent's chat: returns the typed messages still queued, ends the turn,\n\t * and holds the rest of the queue until the next message continues the session.\n\t */\n\tpauseTurn(): Promise<ClearedQueue>;\n\t/** Continues a session `pauseTurn` paused: its hold is released, so the user's message sent next starts the turn. */\n\tresumeTurn(): Promise<void>;\n\t_sealMessageAdmissionIfDrained(): boolean;\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\"): void;\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\"): void;\n\n\t_emitModelChanged(\n\t\tnextModel: Model<Api>,\n\t\tpreviousModel: Model<Api> | undefined,\n\t\tsource: \"set\" | \"cycle\" | \"restore\" | \"fallback\",\n\t): void;\n\t_emitModelSelect(\n\t\tnextModel: Model<Api>,\n\t\tpreviousModel: Model<Api> | undefined,\n\t\tsource: \"set\" | \"cycle\" | \"restore\" | \"fallback\",\n\t): Promise<void>;\n\tsetModel(model: Model<Api>, options?: ModelMutationOptions & { thinkingLevel?: ThinkingLevel }): Promise<void>;\n\tcycleModel(\n\t\tdirection?: \"forward\" | \"backward\",\n\t\toptions?: ModelMutationOptions,\n\t): Promise<ModelCycleResult | undefined>;\n\t_cycleScopedModel(\n\t\tdirection: \"forward\" | \"backward\",\n\t\toptions: ModelMutationOptions,\n\t): Promise<ModelCycleResult | undefined>;\n\t_cycleAvailableModel(\n\t\tdirection: \"forward\" | \"backward\",\n\t\toptions: ModelMutationOptions,\n\t): Promise<ModelCycleResult | undefined>;\n\tsetThinkingLevel(level: ThinkingLevel, options?: ModelMutationOptions): Promise<void>;\n\tcycleThinkingLevel(options?: ModelMutationOptions): Promise<ThinkingLevel | undefined>;\n\tgetAvailableThinkingLevels(): ThinkingLevel[];\n\tsupportsThinking(): boolean;\n\t_getThinkingLevelForModelSwitch(targetModel?: Model<Api>, explicitLevel?: ThinkingLevel): ThinkingLevel;\n\t_clampThinkingLevel(level: ThinkingLevel, availableLevels: ThinkingLevel[]): ThinkingLevel;\n\t_recordThinkingLevel(): Promise<string> | undefined;\n\n\t_applyVerbatimCompaction(options: VerbatimCompactionApplyOptions): Promise<VerbatimCompactionResult | undefined>;\n\tcompact(options?: SessionCompactOptions): Promise<VerbatimCompactionResult>;\n\tabortCompaction(): void;\n\tabortBranchSummary(): void;\n\tabortSessionSummary(): void;\n\t_maybeGenerateSessionSummary(): Promise<void>;\n\t_checkCompaction(assistantMessage: AssistantMessage, skipAbortedCheck?: boolean): Promise<void>;\n\t_compactBeforeContinuation(input?: readonly AgentMessage[]): Promise<boolean>;\n\t_compactBeforeResumedPrompt(\n\t\tupdate: AgentMessage | undefined,\n\t\tinput: readonly AgentMessage[],\n\t\tsendsPrompt?: boolean,\n\t): Promise<boolean>;\n\t_continueAgentAfterCompactionCheck(): Promise<void>;\n\t_dropTrailingAutoCompactionRetryAssistantIfPresent(): Promise<void>;\n\t_schedulePostAutoCompactionContinuationProbe(reason: \"overflow\" | \"threshold\", willRetry: boolean): void;\n\t_awaitPendingPostCompactionContinuation(): Promise<void>;\n\t_resumeAfterAutoCompaction(): Promise<void>;\n\t_resumeAfterLengthTruncation(): Promise<void>;\n\t_runAutoCompaction(\n\t\treason: \"overflow\" | \"threshold\",\n\t\twillRetry: boolean,\n\t\turgency?: AutoCompactionUrgency,\n\t\tcoveredThroughEntryId?: string,\n\t): Promise<AutoCompactionRunOutcome>;\n\t_preflightPostToolContext(messages: AgentMessage[], signal?: AbortSignal): Promise<AgentMessage[]>;\n\t_finishPostToolCompactionPreflight(messages: AgentMessage[]): AgentMessage[];\n\tsetAutoCompactionEnabled(enabled: boolean): void;\n\tsetCompactionModel(model: string, scope?: \"global\" | \"project\", options?: { persist?: boolean }): void;\n\t/** Give an agent without `read` or `search` the read-only `session_history` tool after a compaction boundary. */\n\t_enableSessionHistoryTool(): void;\n\n\tbindExtensions(bindings: ExtensionBindings): Promise<void>;\n\tstartPendingRecovery(reason?: SessionRecoveryReason): Promise<SessionRecoveryReport>;\n\tstartPendingRecoveryRestore(reason?: SessionRecoveryReason): Promise<SessionRecoveryReport>;\n\t/** Keep only the stored history and let go of everything live; rehydrate with `AgentSessionRuntime.rehydrate`. */\n\trelease(): Promise<import(\"./agent-session-release.ts\").ReleasedAgentSession>;\n\t/** Let calls of `detachable` tools that run longer than `policy.afterMs` go on without the run; `undefined` runs them inline. */\n\tsetToolDetachment(policy: ToolDetachmentPolicy | undefined): void;\n\t/** The calls the session's runs detached and the host has not taken yet; taking them clears the list. */\n\ttakeDetachedToolCalls(): DetachedToolCall[];\n\t/** Whether the transcript ends on a turn that issued a detachable call and has no answer from the model yet. */\n\thasPendingDetachedTurn(): boolean;\n\t/** Whether the transcript still waits on the result of a call of a detachable tool: nothing may start a turn. */\n\tisWaitingOnDetachedResults(): boolean;\n\t/** Start again the detachable calls the transcript ends on without a result, with their original ids and arguments. */\n\tredispatchDetachedToolCalls(): DetachedToolCall[];\n\t/** Record detached calls' results; the turn that issued them continues once each of its detachable calls has one. */\n\tresumeDetachedTurn(\n\t\tresults: readonly DetachedToolResult[],\n\t\tonRecorded?: (toolCallIds: readonly string[]) => void,\n\t): Promise<void>;\n\t_waitForExtensionStart(): Promise<void>;\n\textendResourcesFromExtensions(reason: \"startup\" | \"reload\"): Promise<void>;\n\tbuildExtensionResourcePaths(entries: ExtensionResourcePathEntry[]): ExtensionResourcePathResult[];\n\tgetExtensionSourceLabel(extensionPath: string): string;\n\t_applyExtensionBindings(runner: ExtensionRunner): void;\n\t_refreshCurrentModelFromRegistry(): Promise<void>;\n\trefreshCurrentModelFromRegistry(): Promise<void>;\n\t_bindExtensionCore(\n\t\trunner: ExtensionRunner,\n\t\tpublication?: {\n\t\t\tresourceLoader: ResourceLoader;\n\t\t\tproviderTransaction: ExtensionProviderTransaction;\n\t\t\tproviderIds: Set<string>;\n\t\t\tdefer(effect: () => void | Promise<void>): void;\n\t\t},\n\t\tstartupToolNames?: readonly string[],\n\t\tstartupLoadout?: RecordedToolLoadout,\n\t): void;\n\t_refreshToolRegistry(options?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean }): void;\n\t_buildRuntime(options: RuntimeBuildOptions): void;\n\treload(options?: AgentSessionReloadOptions): Promise<void>;\n\tcompleteStartupResources(resourceLoader: ResourceLoader): Promise<void>;\n\n\t_isRetryableError(message: AssistantMessage): boolean;\n\t_isFallbackableError(message: AssistantMessage): boolean;\n\t_isEmptyCompletion(message: AssistantMessage): boolean;\n\t_isSafetyRefusal(message: AssistantMessage): boolean;\n\t_handleRetryableError(message: AssistantMessage): Promise<boolean>;\n\t_trySwitchToFallbackModel(message: AssistantMessage): Promise<boolean>;\n\t_selectModelWithCredentials(): Promise<void>;\n\t_beginFallbackModelScope(): void;\n\t_clearFallbackModelScope(): void;\n\t_settleFallbackModelScope(): Promise<boolean>;\n\tabortRetry(): void;\n\twaitForRetry(): Promise<void>;\n\tsetAutoRetryEnabled(enabled: boolean): void;\n\n\texecuteBash(\n\t\tcommand: string,\n\t\tonChunk?: (chunk: string, channel: \"stdout\" | \"stderr\") => void,\n\t\toptions?: {\n\t\t\texcludeFromContext?: boolean;\n\t\t\tid?: string;\n\t\t\toperations?: BashOperations;\n\t\t\tpty?: boolean;\n\t\t\temitEvent?: boolean;\n\t\t\trecordResult?: boolean;\n\t\t},\n\t): Promise<BashResult>;\n\trecordBashResult(\n\t\tcommand: string,\n\t\tresult: BashResult,\n\t\toptions?: { excludeFromContext?: boolean; persist?: boolean; defer?: boolean },\n\t): Promise<void>;\n\tabortBash(id?: string): void;\n\t_flushPendingBashMessages(): Promise<void>;\n\n\tsetSessionName(name: string): Promise<void>;\n\tnavigateTree(\n\t\ttargetId: string,\n\t\toptions?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string },\n\t): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>;\n\tgetUserMessagesForForking(): Array<{ entryId: string; text: string }>;\n\t_extractUserMessageText(content: string | Array<{ type: string; text?: string }>): string;\n\n\tgetSessionStats(): SessionStats;\n\tgetContextUsage(): ContextUsage | undefined;\n\texportToHtml(outputPath?: string, options?: { themeName?: string }): Promise<string>;\n\t/**\n\t * `snapshotContent: false` leaves worktree snapshot patch and bundle content out of the file, and\n\t * `toolOutputContent: false` the tool outputs kept as session blobs.\n\t */\n\texportToJsonl(\n\t\toutputPath?: string,\n\t\toptions?: { includeShareContext?: boolean; snapshotContent?: boolean; toolOutputContent?: boolean },\n\t): Promise<string>;\n\tgetLastAssistantText(): string | undefined;\n\tcreateReplacedSessionContext(): ReplacedSessionContext;\n\thasExtensionHandlers(eventType: string): boolean;\n\tgetPersistenceFailure(): PersistenceFailure | undefined;\n\tgetUnsavedInput(): UnsavedInput | undefined;\n\tdiscardUnsavedInput(): void;\n}\n\nexport interface AgentSessionPublicSurface\n\textends Pick<\n\t\tAgentSessionMethodSurface,\n\t\t| \"getAgentTaskHost\"\n\t\t| \"closeSessionTasks\"\n\t\t| \"modelRuntime\"\n\t\t| \"state\"\n\t\t| \"model\"\n\t\t| \"thinkingLevel\"\n\t\t| \"isStreaming\"\n\t\t| \"systemPrompt\"\n\t\t| \"retryAttempt\"\n\t\t| \"retryStatus\"\n\t\t| \"turnStartedAt\"\n\t\t| \"isCompacting\"\n\t\t| \"compactionReason\"\n\t\t| \"compactionStartedAt\"\n\t\t| \"messages\"\n\t\t| \"transcriptMessages\"\n\t\t| \"steeringMode\"\n\t\t| \"followUpMode\"\n\t\t| \"sessionFile\"\n\t\t| \"sessionId\"\n\t\t| \"sessionName\"\n\t\t| \"sessionSummary\"\n\t\t| \"scopedModels\"\n\t\t| \"promptTemplates\"\n\t\t| \"pendingMessageCount\"\n\t\t| \"resourceLoader\"\n\t\t| \"autoCompactionEnabled\"\n\t\t| \"isRetrying\"\n\t\t| \"isWaitingToRetry\"\n\t\t| \"autoRetryEnabled\"\n\t\t| \"abortSessionSummary\"\n\t\t| \"isBashRunning\"\n\t\t| \"hasPendingBashMessages\"\n\t\t| \"extensionRunner\"\n\t\t| \"queuedMessagesPaused\"\n\t\t| \"pauseQueuedMessages\"\n\t\t| \"resumeQueuedMessages\"\n\t\t| \"subscribe\"\n\t\t| \"dispose\"\n\t\t| \"getActiveToolNames\"\n\t\t| \"getCallableToolNames\"\n\t\t| \"getAllTools\"\n\t\t| \"getToolDefinition\"\n\t\t| \"getToolStatus\"\n\t\t| \"getToolStatusAsync\"\n\t\t| \"setActiveToolsByName\"\n\t\t| \"setScopedModels\"\n\t\t| \"prompt\"\n\t\t| \"steer\"\n\t\t| \"followUp\"\n\t\t| \"sendCustomMessage\"\n\t\t| \"sendCustomMessages\"\n\t\t| \"sendUserMessage\"\n\t\t| \"clearQueue\"\n\t\t| \"getSteeringMessages\"\n\t\t| \"getFollowUpMessages\"\n\t\t| \"abort\"\n\t\t| \"interruptTurn\"\n\t\t| \"pauseTurn\"\n\t\t| \"resumeTurn\"\n\t\t| \"turnPaused\"\n\t\t| \"setModel\"\n\t\t| \"cycleModel\"\n\t\t| \"setThinkingLevel\"\n\t\t| \"cycleThinkingLevel\"\n\t\t| \"getAvailableThinkingLevels\"\n\t\t| \"supportsThinking\"\n\t\t| \"setSteeringMode\"\n\t\t| \"setFollowUpMode\"\n\t\t| \"compact\"\n\t\t| \"abortCompaction\"\n\t\t| \"abortBranchSummary\"\n\t\t| \"setAutoCompactionEnabled\"\n\t\t| \"setCompactionModel\"\n\t\t| \"bindExtensions\"\n\t\t| \"startPendingRecovery\"\n\t\t| \"startPendingRecoveryRestore\"\n\t\t| \"release\"\n\t\t| \"setToolDetachment\"\n\t\t| \"takeDetachedToolCalls\"\n\t\t| \"hasPendingDetachedTurn\"\n\t\t| \"isWaitingOnDetachedResults\"\n\t\t| \"redispatchDetachedToolCalls\"\n\t\t| \"resumeDetachedTurn\"\n\t\t| \"refreshCurrentModelFromRegistry\"\n\t\t| \"reload\"\n\t\t| \"completeStartupResources\"\n\t\t| \"abortRetry\"\n\t\t| \"setAutoRetryEnabled\"\n\t\t| \"executeBash\"\n\t\t| \"recordBashResult\"\n\t\t| \"abortBash\"\n\t\t| \"setSessionName\"\n\t\t| \"navigateTree\"\n\t\t| \"getUserMessagesForForking\"\n\t\t| \"getSessionStats\"\n\t\t| \"getContextUsage\"\n\t\t| \"refreshContext\"\n\t\t| \"exportToHtml\"\n\t\t| \"exportToJsonl\"\n\t\t| \"getLastAssistantText\"\n\t\t| \"createReplacedSessionContext\"\n\t\t| \"hasExtensionHandlers\"\n\t\t| \"getPersistenceFailure\"\n\t\t| \"getUnsavedInput\"\n\t\t| \"discardUnsavedInput\"\n\t> {\n\treadonly agent: Agent;\n\treadonly sessionManager: SessionManager;\n\treadonly settingsManager: SettingsManager;\n}\n\nexport interface AgentSessionInternalSurface extends AgentSessionMethodSurface, AgentSessionPublicSurface {\n\t_scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\t_fallbackModels: string[];\n\t_isFallbackModelAllowed?: (model: Model<Api>, effort: string | undefined) => boolean;\n\t_fallbackAttemptedKeys: Set<string>;\n\t_fallbackBlockedModels: Array<Model<Api>>;\n\t_fallbackBlockedProviders: Set<string>;\n\t_fallbackOriginModel: Model<Api> | undefined;\n\t_fallbackOriginThinkingLevel: ThinkingLevel | undefined;\n\t_fallbackScopeGeneration: number;\n\t_fallbackOriginGeneration: number | undefined;\n\t_fallbackRestoreError: string | undefined;\n\n\t_unsubscribeAgent?: () => void;\n\t_eventListeners: AgentSessionEventListener[];\n\t_agentEventQueue: Promise<void>;\n\t_steeringMessages: string[];\n\t_followUpMessages: string[];\n\t_interruptDeliveryQueue: Promise<void>;\n\t_pendingPostCompactionContinuation: Promise<void> | undefined;\n\t_postCompactionContinuationToken: number;\n\t_lengthContinuationAttempts: number;\n\t_outputBudgetErrorContinuationAttempts: number;\n\t_postToolCompactionPreflightError: string | undefined;\n\t_pendingPostToolCompactionGuard: PendingPostToolCompactionGuard | undefined;\n\t/** Set once a compaction boundary gave this restricted agent the `session_history` tool. */\n\t_sessionHistoryToolEnabled: boolean;\n\t_terminatingToolCallIds: Set<string>;\n\t_stopAfterTurnBlockedContinuation: boolean;\n\t/** The current turn was ended by {@link interruptTurn}: a child's message admission stays open after it. */\n\t_turnInterruptedByUser: boolean;\n\t_abortPreparedRunAtStart: boolean;\n\t_startAbortedForInterrupt: boolean;\n\t_awaitingStartAfterInterrupt: boolean;\n\t_undeliveredAgentStarts: number;\n\t/** A child whose turn the user interrupted waits here: the next message it receives starts its next turn. */\n\t_awaitingMessageAfterInterrupt: boolean;\n\t/** A `pauseTurn` holds the queue: settles once its run did, and the user's continue releases the hold. */\n\t_turnPause: TurnPause | undefined;\n\t/** The release of a `pauseTurn` hold under way, which every next message waits for. */\n\t_turnPauseRelease: Promise<void> | undefined;\n\t_pendingInterruptDeliveries: number;\n\t_priorityInterruptPending: boolean;\n\t_activePromptCount: number;\n\t_isPreparingRun: false | \"user\" | \"custom\";\n\t_promptPreflightCount: number;\n\t_agentRunAbortRequested: boolean;\n\t_cacheWarmer?: import(\"./cache-warmer.ts\").CacheWarmer;\n\t_activeInterruptQueueHold: InterruptQueueHold | undefined;\n\t_queuedMessagesPaused: boolean;\n\t_queuedMessagesPauseAbortBoundary: Promise<void> | undefined;\n\t_admittedQueuedMessageAwaitingReply: string | undefined;\n\t_admittedRecoveryTurn: Promise<void> | undefined;\n\t_activeInterruptAbortMessage: string | undefined;\n\t_pendingNextTurnMessages: CustomMessage[];\n\t_pendingCustomMessages: CustomMessage[];\n\t_protectedStreamingCustomMessages: Array<{\n\t\tmessage: CustomMessage;\n\t\tdelivery: \"steer\" | \"followUp\";\n\t\tphase: \"queued\" | \"consumed-unpersisted\" | \"persistence-failed\";\n\t}>;\n\t_compactionAbortController: AbortController | undefined;\n\t_manualCompactionPromise: Promise<VerbatimCompactionResult> | undefined;\n\t_autoCompactionAbortController: AbortController | undefined;\n\t/** Stops the compactor request of the running compaction, which then clears the context instead. */\n\t_compactorAbortController: AbortController | undefined;\n\t_autoCompactionCompletion: Promise<void> | undefined;\n\t_compactionReason: import(\"./agent-session-types.js\").CompactionReason | undefined;\n\t_compactionStartedAt: number | undefined;\n\t_overflowRecoveryAttempted: boolean;\n\t_recoverableLengthRecoveryAttempted: boolean;\n\t_contextOverflowUnresolved: boolean;\n\t_branchSummaryAbortController: AbortController | undefined;\n\t_branchSummaryCompletion: Promise<void> | undefined;\n\t_retryAbortController: AbortController | undefined;\n\t_retryAttempt: number;\n\t_retryStatus?: import(\"./session-retry-status.js\").SessionRetryStatus;\n\t_turnStartedAt?: number;\n\t_longStreamCutRetries: number;\n\t_retryPromise: Promise<void> | undefined;\n\t_retryResolve: (() => void) | undefined;\n\t_retryGeneration: number;\n\t_agentRunRetryGeneration: number;\n\t_bashAbortControllers: Map<string | symbol, Set<AbortController>>;\n\t_pendingBashMessages: BashExecutionMessage[];\n\t_runOnlyBashMessages?: WeakSet<object>;\n\t_extensionRunner: ExtensionRunner;\n\t_turnIndex: number;\n\treadonly _entryIdsByMessage: WeakMap<object, string>;\n\treadonly _boundaryDispatchedMessages: WeakSet<object>;\n\treadonly _messagesAwaitingPersistence: WeakMap<object, Promise<void>>;\n\t_transcriptAppend: { message: AgentMessage; previousLeaf: string | null; owner?: object } | undefined;\n\treadonly _messagesWithFailedPersistence: WeakSet<object>;\n\t_persistenceFailure: string | undefined;\n\t_turnStopReason: string | undefined;\n\t_worktreeSnapshots: import(\"./session-worktree-snapshots.ts\").SessionWorktreeSnapshotRecorder;\n\treadonly _reissuedToolCallIds: Set<string>;\n\t_lastAssistantToolResults: AgentMessage[];\n\t_lastActivityOutcome: AgentActivityOutcome;\n\t_isBeforeSettle: boolean;\n\t_abortDuringBeforeSettle: boolean;\n\t_isEmittingAgentSettled: boolean;\n\treadonly _deferredSettledActions: Array<() => Promise<void>>;\n\t_callerReplacedNextRequestContext: boolean;\n\t_resourceLoader: ResourceLoader;\n\t_customTools: ToolDefinition[];\n\t_baseToolDefinitions: Map<string, ToolDefinition>;\n\t_cwd: string;\n\t_extensionRunnerRef?: { current?: ExtensionRunner };\n\t_initialActiveToolNames?: string[];\n\t_pendingToolNames: Set<string>;\n\t_restoredToolNames: Set<string>;\n\t_explicitToolDeactivations: Set<string>;\n\t_usesDefaultTools: boolean;\n\t_defaultToolModifiers: string[];\n\t_appliedDefaultTools: Set<string>;\n\t_allowedToolNames?: Set<string>;\n\t_excludedToolNames?: Set<string>;\n\t_allowedTools?: (name: string) => boolean;\n\t_excludedTools?: (name: string) => boolean;\n\t_childSessionOptions?: import(\"./child-session-options.ts\").ChildSessionOptionsResolver;\n\t_storageAgentDir?: string;\n\t_baseToolsOverride?: Record<string, AgentTool>;\n\t_sessionStartEvent: SessionStartEvent;\n\t_workspace?: import(\"./workspace/resolve.ts\").BoundWorkspace;\n\t_subagentPolicy?: import(\"./extensions/index.js\").SubagentChildPolicy;\n\t_intercomPolicy?: import(\"./intercom-policy.ts\").SessionIntercomPolicy;\n\t_subagentMessageAdmission?: import(\"./message-admission.js\").MessageAdmissionBoundary;\n\t_extensionUIContext?: ExtensionUIContext;\n\t_extensionHumanInput?: import(\"./extensions/host-input.js\").HostInput | null;\n\t_extensionDiagnosticListener?: (diagnostic: import(\"./extensions/host-input.js\").HostDiagnostic) => void;\n\t_extensionMode: ExtensionMode;\n\t_disposed: boolean;\n\t_close(event: import(\"./extensions/types.ts\").SessionShutdownEvent, beforeInvalidate?: () => void): Promise<void>;\n\t_sessionSummaryAbortController: AbortController | undefined;\n\t_sessionSummaryToken: number;\n\t_sessionSummaryRun: import(\"./agent-session-summary.ts\").SessionSummaryRun | undefined;\n\t_lastSummarizedMessageId: string | undefined;\n\t_extensionCommandContextActions?: ExtensionCommandContextActions;\n\t_extensionShutdownHandler?: () => void;\n\t_extensionErrorListener?: ExtensionErrorListener;\n\t_extensionErrorUnsubscriber?: () => void;\n\t_modelRuntime: ModelRuntime;\n\t_extensionProviderIds: Set<string>;\n\t_toolRegistry: Map<string, AgentTool>;\n\t_toolExecutionScheduler: ToolExecutionScheduler;\n\t_outerWorktreeRootMappings: readonly WorktreeRootMapping[];\n\t_worktreeRestoreNotices: readonly string[];\n\t_toolDefinitions: Map<string, ToolDefinitionEntry>;\n\t_toolPromptSnippets: Map<string, string>;\n\t_toolPromptGuidelines: Map<string, string[]>;\n\t_baseSystemPromptOptions: NormalizedBuildSystemPromptOptions;\n\t_systemPromptTransform?: (prompt: string) => string;\n\t_systemPromptSections?: import(\"./sdk-types.ts\").SystemPromptSectionsTransform;\n\t_transformedPromptHead?: import(\"./transformed-system-prompt.ts\").TransformedPrompt;\n\t_contextProjectionTransform?: (messages: AgentMessage[]) => AgentMessage[];\n\t_requestContextProjectionTransform?: (messages: AgentMessage[]) => AgentMessage[];\n\t/** The restored history's last message until the first request after a resume; see `_compactBeforeResumedPrompt`. */\n\t_resumeBudgetCheckpoint?: AgentMessage;\n\t/**\n\t * What the check of `_resumeBudgetCheckpoint` for a run that sends the session's prompt as it is now (a prompt, or a\n\t * run an extension starts) found that prompt to need: its update, or null when the prompt was current. Undefined\n\t * until such a run is checked. A conversation request retires the checkpoint once the transcript it sends holds that\n\t * update, at once when it is null; see `_compactBeforeResumedPrompt`.\n\t */\n\t_resumePromptUpdate?: AgentMessage | null;\n\t/**\n\t * The prompt update a resume needs, as the first check of a run that does not send the session's prompt (an\n\t * interrupt, queued input) found it while one was pending. Until the checkpoint retires, a later turn of such a run\n\t * leaves out what it changes or adds; see `withoutResumeUpdate`.\n\t */\n\t_resumeHeldUpdate?: SystemMessageWithTransformedPrompt;\n\t_runSystemPromptOptions?: NormalizedBuildSystemPromptOptions;\n\t/**\n\t * The prompt sections that the latest sent prompt's `before_agent_start` handlers set, replaced or removed relative\n\t * to the base options, such as the MCP servers' section, for the extensions of `runner` (held weakly, so a reload's\n\t * retired extensions can be collected). A run that starts without a prompt (an interrupt, queued input) keeps them\n\t * as the conversation last had them; see `_currentRunSystemPromptOptions`.\n\t */\n\t_promptSectionNames?: { runner: WeakRef<ExtensionRunner>; names: ReadonlySet<string> };\n\t_lastAssistantMessage: AssistantMessage | undefined;\n\t_tempStorageLease: import(\"./tools/session-temp-dir.ts\").ProtectedPathLease | undefined;\n\t_sessionOpenMarker: (() => Promise<void>) | undefined;\n\t_agentTaskHost: import(\"./tasks/agent-adapter.js\").AgentTaskHost | undefined;\n\t_parentCommandTaskOwner: import(\"./tasks/child-command-owner.js\").ChildCommandTaskOwner | undefined;\n\t_inheritedHistory: import(\"./tools/history-protocol.ts\").ProjectHistory | undefined;\n\t_resourceAdmission: import(\"./sdk-types.ts\").ResourceAdmission | undefined;\n\t_childTaskWaits: import(\"./tasks/child-command-owner.js\").ChildTaskWaits;\n\t_taskCompletionOutbox: import(\"./tasks/completion.js\").TaskCompletionOutbox | undefined;\n\t_taskAdmission: import(\"./message-admission.js\").MessageAdmissionBoundary | undefined;\n}\n"]}
|
|
@@ -264,6 +264,9 @@ declare class AgentSessionBase {
|
|
|
264
264
|
*/
|
|
265
265
|
stopTurns(reason: string | undefined): void;
|
|
266
266
|
setCacheWarmingMode(mode: import("./settings-manager.ts").CacheWarmingMode): void;
|
|
267
|
+
setDecisionModel(model: string, scope?: "global" | "project", options?: {
|
|
268
|
+
persist?: boolean;
|
|
269
|
+
}): void;
|
|
267
270
|
/**
|
|
268
271
|
* The save receipt of a message this session emitted: the sequence its entry was stored at, read while the entry is
|
|
269
272
|
* in the session's memory, as at its `message_end`. Undefined for a message that was not saved.
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { AgentMessage } from "@bastani/atomic-agent-core";
|
|
2
|
+
import type { CompactorApi } from "@bastani/atomic-ai";
|
|
2
3
|
import type { Usage } from "@bastani/atomic-ai/compat";
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
/**
|
|
4
|
+
import { CompactorFailure } from "./errors.js";
|
|
5
|
+
export { CompactorFailure };
|
|
6
|
+
/** Default wall-clock bound on one compactor request unless overridden by model `timeoutMs`; past it the context is cleared instead. */
|
|
6
7
|
export declare const COMPACTOR_REQUEST_TIMEOUT_MS = 120000;
|
|
7
8
|
/** Lines longer than this are wrapped before they are sent, so the compactor can keep or drop parts of them. */
|
|
8
9
|
export declare const COMPACTOR_LINE_WIDTH = 2000;
|
|
9
|
-
/**
|
|
10
|
+
/** Default upper bound on compacted text, in estimated tokens, unless overridden by model `maxTokens`. Longer output is a failure and the context is cleared. */
|
|
10
11
|
export declare const COMPACTED_OUTPUT_MAX_TOKENS = 32000;
|
|
11
12
|
/** Compacted text never fills more than this share of the context the automatic trigger allows. */
|
|
12
13
|
export declare const COMPACTED_OUTPUT_MAX_TRIGGER_SHARE = 0.5;
|
|
@@ -14,10 +15,6 @@ export interface CompactorMessage {
|
|
|
14
15
|
role: "user" | "assistant";
|
|
15
16
|
content: string;
|
|
16
17
|
}
|
|
17
|
-
/** Why a compactor request produced no usable text. The context is cleared instead. */
|
|
18
|
-
export declare class CompactorFailure extends Error {
|
|
19
|
-
constructor(message: string);
|
|
20
|
-
}
|
|
21
18
|
/** Splits every line longer than `width` characters into parts of at most `width` characters. */
|
|
22
19
|
export declare function wrapLongLines(text: string, width?: number): string;
|
|
23
20
|
/** Whether a message is a compaction boundary's text rather than conversation. */
|
|
@@ -29,15 +26,23 @@ export type IsBoundaryMessage = (message: AgentMessage) => boolean;
|
|
|
29
26
|
*/
|
|
30
27
|
export declare function buildCompactorMessages(messages: readonly AgentMessage[], isBoundary: IsBoundaryMessage): CompactorMessage[];
|
|
31
28
|
/** Largest compacted text, in estimated tokens, for a model whose automatic trigger fires above `triggerTokens`. */
|
|
32
|
-
export declare function compactedOutputTokenCap(triggerTokens: number): number;
|
|
29
|
+
export declare function compactedOutputTokenCap(triggerTokens: number, maxOutputTokens?: number): number;
|
|
33
30
|
/** A conservative token estimate for text: four characters per token, one per character outside ASCII. */
|
|
34
31
|
export declare function estimateTextTokens(text: string): number;
|
|
35
32
|
export interface CompactorRequest {
|
|
36
33
|
readonly apiKey: string | undefined;
|
|
34
|
+
/** Compactor API identifier. */
|
|
35
|
+
readonly api?: CompactorApi;
|
|
37
36
|
/** The compactor model's id, sent as `model`. */
|
|
38
37
|
readonly modelId: string;
|
|
39
|
-
/** The compactor model's base URL; the request goes to `<baseUrl
|
|
40
|
-
readonly baseUrl
|
|
38
|
+
/** The compactor model's base URL; the request goes to `<baseUrl><endpointPath>`. */
|
|
39
|
+
readonly baseUrl: string;
|
|
40
|
+
/** Path appended to `baseUrl` (default `"/compact"`). Pass `""` to POST directly to `baseUrl`. */
|
|
41
|
+
readonly endpointPath?: string;
|
|
42
|
+
/** Additional or overridden API-specific request body parameters. */
|
|
43
|
+
readonly params?: Record<string, unknown>;
|
|
44
|
+
/** Optional resolved headers merged into the request (supporting custom auth headers or metadata). */
|
|
45
|
+
readonly headers?: Record<string, string>;
|
|
41
46
|
readonly messages: readonly CompactorMessage[];
|
|
42
47
|
readonly query: string;
|
|
43
48
|
/** Aborts when the compaction itself is cancelled; that is a cancel, not a failure. */
|
|
@@ -48,9 +53,10 @@ export interface CompactorRequest {
|
|
|
48
53
|
readonly fetchFn?: typeof fetch;
|
|
49
54
|
}
|
|
50
55
|
/**
|
|
51
|
-
* Send the framed conversation to a compactor endpoint and return its text. Throws
|
|
52
|
-
* reason for every failure (no credentials, HTTP error, malformed
|
|
53
|
-
* when `signal` aborts.
|
|
56
|
+
* Send the framed conversation to a compactor endpoint and return its text. Throws {@link CompactorFailure} (a
|
|
57
|
+
* {@link CompactionError}) naming the reason for every failure (missing baseUrl, no credentials, HTTP error, malformed
|
|
58
|
+
* or empty output, timeout), and {@link CompactionCancelledError} when `signal` aborts. Credentials never appear in a
|
|
59
|
+
* thrown message.
|
|
54
60
|
*/
|
|
55
61
|
export declare function requestCompactorOutput(request: CompactorRequest): Promise<{
|
|
56
62
|
text: string;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The {@link CompactionError} family: every typed failure of compaction settings, session compaction state,
|
|
3
|
+
* cancellation, and remote compactor requests. Catch the family or a concrete subclass and branch on `code`.
|
|
4
|
+
*/
|
|
5
|
+
export type CompactionConfigErrorCode = "invalid-setting";
|
|
6
|
+
export type CompactionStateErrorCode = "nothing-to-compact" | "pending-tool-call" | "no-model-selected" | "snapshot-failed" | "boundary-not-built";
|
|
7
|
+
export type CompactorFailureCode = "missing-base-url" | "missing-credentials" | "request-aborted" | "timeout" | "http-error" | "network-error" | "malformed-response" | "empty-output" | "compactor-failed";
|
|
8
|
+
export type CompactionErrorCode = CompactionConfigErrorCode | "cancelled" | CompactionStateErrorCode | CompactorFailureCode;
|
|
9
|
+
export type CompactionConfigSource = "settings" | "sdk" | "rpc";
|
|
10
|
+
export type CompactionSettingsScope = "global" | "project";
|
|
11
|
+
export type CompactionCancelReason = "aborted" | "extension";
|
|
12
|
+
export type CompactionErrorFieldValue = string | number | boolean;
|
|
13
|
+
/** The family of compaction errors. Not retryable unless a subclass says so. */
|
|
14
|
+
export declare class CompactionError extends Error {
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly code: CompactionErrorCode;
|
|
17
|
+
readonly hint: string;
|
|
18
|
+
readonly retryable: boolean;
|
|
19
|
+
private readonly extraFields;
|
|
20
|
+
constructor(code: CompactionErrorCode, message: string, hint: string, options?: ErrorOptions & {
|
|
21
|
+
readonly retryable?: boolean;
|
|
22
|
+
readonly fields?: Readonly<Record<string, CompactionErrorFieldValue>>;
|
|
23
|
+
});
|
|
24
|
+
fields(): Readonly<Record<string, CompactionErrorFieldValue>>;
|
|
25
|
+
}
|
|
26
|
+
export interface CompactionConfigErrorFields {
|
|
27
|
+
readonly source: CompactionConfigSource;
|
|
28
|
+
readonly field: string;
|
|
29
|
+
readonly scope?: CompactionSettingsScope;
|
|
30
|
+
}
|
|
31
|
+
/** A compaction setting or RPC parameter is invalid. Not retryable: fix the value. */
|
|
32
|
+
export declare class CompactionConfigError extends CompactionError {
|
|
33
|
+
readonly name: "CompactionConfigError";
|
|
34
|
+
readonly code: CompactionConfigErrorCode;
|
|
35
|
+
readonly retryable: false;
|
|
36
|
+
readonly source: CompactionConfigSource;
|
|
37
|
+
readonly field: string;
|
|
38
|
+
readonly scope: CompactionSettingsScope | undefined;
|
|
39
|
+
constructor(fields: CompactionConfigErrorFields, options?: ErrorOptions);
|
|
40
|
+
fields(): Readonly<Record<string, CompactionErrorFieldValue>>;
|
|
41
|
+
}
|
|
42
|
+
export interface CompactionCancelledErrorFields {
|
|
43
|
+
readonly reason?: CompactionCancelReason;
|
|
44
|
+
}
|
|
45
|
+
/** Compaction was cancelled before committing a boundary. Not retryable automatically. */
|
|
46
|
+
export declare class CompactionCancelledError extends CompactionError {
|
|
47
|
+
readonly name: "CompactionCancelledError";
|
|
48
|
+
readonly code: "cancelled";
|
|
49
|
+
readonly retryable: false;
|
|
50
|
+
readonly reason: CompactionCancelReason | undefined;
|
|
51
|
+
constructor(fields?: CompactionCancelledErrorFields, options?: ErrorOptions);
|
|
52
|
+
fields(): Readonly<Record<string, CompactionErrorFieldValue>>;
|
|
53
|
+
}
|
|
54
|
+
export interface CompactionStateErrorFields {
|
|
55
|
+
readonly code: CompactionStateErrorCode;
|
|
56
|
+
readonly message?: string;
|
|
57
|
+
readonly detail?: string;
|
|
58
|
+
}
|
|
59
|
+
/** Compaction could not start or commit in the session's current state. */
|
|
60
|
+
export declare class CompactionStateError extends CompactionError {
|
|
61
|
+
readonly name: "CompactionStateError";
|
|
62
|
+
readonly code: CompactionStateErrorCode;
|
|
63
|
+
readonly retryable: false;
|
|
64
|
+
readonly detail: string | undefined;
|
|
65
|
+
constructor(fields: CompactionStateErrorFields, options?: ErrorOptions);
|
|
66
|
+
fields(): Readonly<Record<string, CompactionErrorFieldValue>>;
|
|
67
|
+
}
|
|
68
|
+
export interface CompactorFailureOptions extends ErrorOptions {
|
|
69
|
+
readonly code?: CompactorFailureCode;
|
|
70
|
+
readonly hint?: string;
|
|
71
|
+
readonly retryable?: boolean;
|
|
72
|
+
readonly status?: number;
|
|
73
|
+
readonly timeoutMs?: number;
|
|
74
|
+
readonly model?: string;
|
|
75
|
+
}
|
|
76
|
+
/** Why a compactor request produced no usable text. Session compaction falls back to clearing the context instead. */
|
|
77
|
+
export declare class CompactorFailure extends CompactionError {
|
|
78
|
+
readonly name: "CompactorFailure";
|
|
79
|
+
readonly code: CompactorFailureCode;
|
|
80
|
+
readonly retryable: boolean;
|
|
81
|
+
readonly status: number | undefined;
|
|
82
|
+
readonly timeoutMs: number | undefined;
|
|
83
|
+
readonly model: string | undefined;
|
|
84
|
+
constructor(message: string, options?: CompactorFailureOptions);
|
|
85
|
+
fields(): Readonly<Record<string, CompactionErrorFieldValue>>;
|
|
86
|
+
}
|
|
87
|
+
/** Whether `value` is a {@link CompactionError}, including one that crossed a process boundary. */
|
|
88
|
+
export declare function isCompactionError(value: unknown): value is CompactionError;
|
|
89
|
+
/** Whether `value` is a {@link CompactionConfigError}, including one that crossed a process boundary. */
|
|
90
|
+
export declare function isCompactionConfigError(value: unknown): value is CompactionConfigError;
|
|
91
|
+
/** Whether `value` is a {@link CompactionCancelledError}, including one that crossed a process boundary. */
|
|
92
|
+
export declare function isCompactionCancelledError(value: unknown): value is CompactionCancelledError;
|
|
93
|
+
/** Whether `value` is a {@link CompactionStateError}, including one that crossed a process boundary. */
|
|
94
|
+
export declare function isCompactionStateError(value: unknown): value is CompactionStateError;
|
|
95
|
+
/** Whether `value` is a {@link CompactorFailure}, including one that crossed a process boundary. */
|
|
96
|
+
export declare function isCompactorFailure(value: unknown): value is CompactorFailure;
|
|
97
|
+
/** The first {@link CompactionError} in `error`'s cause chain, looking at most eight errors deep. */
|
|
98
|
+
export declare function findCompactionError(error: unknown): CompactionError | undefined;
|
|
99
|
+
/** Whether a compaction error in `error`'s cause chain says the caller may retry. */
|
|
100
|
+
export declare function isRetryableCompactionError(error: unknown): boolean;
|
|
101
|
+
/** A compaction error as it crosses a worker, RPC, or process boundary. */
|
|
102
|
+
export interface SerializedCompactionError {
|
|
103
|
+
readonly name: string;
|
|
104
|
+
readonly code: string;
|
|
105
|
+
readonly message: string;
|
|
106
|
+
readonly hint: string;
|
|
107
|
+
readonly retryable: boolean;
|
|
108
|
+
readonly fields: Readonly<Record<string, CompactionErrorFieldValue>>;
|
|
109
|
+
readonly cause?: SerializedCompactionError | {
|
|
110
|
+
readonly name: string;
|
|
111
|
+
readonly message: string;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/** Serialize `error` and up to seven causes into JSON-safe data that {@link rehydrateCompactionError} restores. */
|
|
115
|
+
export declare function serializeCompactionError(error: CompactionError, depth?: number): SerializedCompactionError;
|
|
116
|
+
/** Validate untrusted data received across a process boundary as a {@link SerializedCompactionError}. */
|
|
117
|
+
export declare function parseSerializedCompactionError(value: unknown): SerializedCompactionError | undefined;
|
|
118
|
+
/** Restore a serialized compaction error as the same class, with its fields and cause chain; unknown names become the family base. */
|
|
119
|
+
export declare function rehydrateCompactionError(serialized: SerializedCompactionError): CompactionError;
|
|
120
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -7,6 +7,7 @@ export * from "./compaction-boundary.js";
|
|
|
7
7
|
export * from "./compaction-types.js";
|
|
8
8
|
export * from "./compactor.js";
|
|
9
9
|
export * from "./context-clear.js";
|
|
10
|
+
export * from "./errors.js";
|
|
10
11
|
export * from "./model-resolver.js";
|
|
11
12
|
export * from "./session-summarization.ts";
|
|
12
13
|
export * from "./transcript-serialization.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AnyModel } from "@bastani/atomic-ai";
|
|
1
|
+
import { type AnyModel, type CompactorModel } from "@bastani/atomic-ai";
|
|
2
2
|
/**
|
|
3
3
|
* What a `compactionModel` value selects. `auto` (also an empty value) clears the context and lets the agent recover
|
|
4
4
|
* from session history; `compactor` sends the conversation to that compactor model's endpoint. A value naming a chat
|
|
@@ -13,7 +13,7 @@ export type CompactionModelSelection = {
|
|
|
13
13
|
} | {
|
|
14
14
|
kind: "compactor";
|
|
15
15
|
fullId: string;
|
|
16
|
-
model:
|
|
16
|
+
model: CompactorModel;
|
|
17
17
|
};
|
|
18
18
|
/** What kind of registered model a `compactionModel` value names. */
|
|
19
19
|
export type CompactionModelKind = "auto" | "compactor" | "chat" | "classifier" | "unknown";
|
package/dist/core/debug.impl.js
CHANGED
|
@@ -6,7 +6,7 @@ try {
|
|
|
6
6
|
} catch (error) {
|
|
7
7
|
const root = new URL("../", import.meta.url);
|
|
8
8
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
9
|
-
const key = `${root.href}#0.10.
|
|
9
|
+
const key = `${root.href}#0.10.10-alpha.2`;
|
|
10
10
|
let release = releases.get(key);
|
|
11
11
|
if (release === undefined) {
|
|
12
12
|
const current = (async () => {
|
|
@@ -27,8 +27,8 @@ try {
|
|
|
27
27
|
release = current;
|
|
28
28
|
}
|
|
29
29
|
const running = await release;
|
|
30
|
-
if (running === undefined || running.version === "0.10.
|
|
31
|
-
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.
|
|
30
|
+
if (running === undefined || running.version === "0.10.10-alpha.2") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.10-alpha.2 while this session was running; restart it to keep using this feature.", {
|
|
32
32
|
cause: error,
|
|
33
33
|
});
|
|
34
34
|
}
|
package/dist/core/debug.js
CHANGED
|
@@ -6,7 +6,7 @@ try {
|
|
|
6
6
|
} catch (error) {
|
|
7
7
|
const root = new URL("../", import.meta.url);
|
|
8
8
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
9
|
-
const key = `${root.href}#0.10.
|
|
9
|
+
const key = `${root.href}#0.10.10-alpha.2`;
|
|
10
10
|
let release = releases.get(key);
|
|
11
11
|
if (release === undefined) {
|
|
12
12
|
const current = (async () => {
|
|
@@ -27,8 +27,8 @@ try {
|
|
|
27
27
|
release = current;
|
|
28
28
|
}
|
|
29
29
|
const running = await release;
|
|
30
|
-
if (running === undefined || running.version === "0.10.
|
|
31
|
-
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.
|
|
30
|
+
if (running === undefined || running.version === "0.10.10-alpha.2") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.10-alpha.2 while this session was running; restart it to keep using this feature.", {
|
|
32
32
|
cause: error,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -6,7 +6,7 @@ try {
|
|
|
6
6
|
} catch (error) {
|
|
7
7
|
const root = new URL("../../", import.meta.url);
|
|
8
8
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
9
|
-
const key = `${root.href}#0.10.
|
|
9
|
+
const key = `${root.href}#0.10.10-alpha.2`;
|
|
10
10
|
let release = releases.get(key);
|
|
11
11
|
if (release === undefined) {
|
|
12
12
|
const current = (async () => {
|
|
@@ -27,8 +27,8 @@ try {
|
|
|
27
27
|
release = current;
|
|
28
28
|
}
|
|
29
29
|
const running = await release;
|
|
30
|
-
if (running === undefined || running.version === "0.10.
|
|
31
|
-
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.
|
|
30
|
+
if (running === undefined || running.version === "0.10.10-alpha.2") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.10-alpha.2 while this session was running; restart it to keep using session export.", {
|
|
32
32
|
cause: error,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -6,7 +6,7 @@ try {
|
|
|
6
6
|
} catch (error) {
|
|
7
7
|
const root = new URL("../../", import.meta.url);
|
|
8
8
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
9
|
-
const key = `${root.href}#0.10.
|
|
9
|
+
const key = `${root.href}#0.10.10-alpha.2`;
|
|
10
10
|
let release = releases.get(key);
|
|
11
11
|
if (release === undefined) {
|
|
12
12
|
const current = (async () => {
|
|
@@ -27,8 +27,8 @@ try {
|
|
|
27
27
|
release = current;
|
|
28
28
|
}
|
|
29
29
|
const running = await release;
|
|
30
|
-
if (running === undefined || running.version === "0.10.
|
|
31
|
-
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.
|
|
30
|
+
if (running === undefined || running.version === "0.10.10-alpha.2") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.10-alpha.2 while this session was running; restart it to keep using session export.", {
|
|
32
32
|
cause: error,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -614,7 +614,7 @@ function __atomicOnDemandFailed(error, feature) {
|
|
|
614
614
|
return (async () => {
|
|
615
615
|
const root = new URL("../../", import.meta.url);
|
|
616
616
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
617
|
-
const key = `${root.href}#0.10.
|
|
617
|
+
const key = `${root.href}#0.10.10-alpha.2`;
|
|
618
618
|
let release = releases.get(key);
|
|
619
619
|
if (release === undefined) {
|
|
620
620
|
const current = (async () => {
|
|
@@ -642,7 +642,7 @@ function __atomicOnDemandFailed(error, feature) {
|
|
|
642
642
|
} catch {
|
|
643
643
|
// No installation to read, as in a bundle of the package: the release the process runs decides.
|
|
644
644
|
}
|
|
645
|
-
const updatedTo = typeof installed === "string" && installed !== "0.10.
|
|
645
|
+
const updatedTo = typeof installed === "string" && installed !== "0.10.10-alpha.2" ? installed : running !== undefined && running.version !== "0.10.10-alpha.2" ? "0.10.10-alpha.2" : undefined;
|
|
646
646
|
if (updatedTo === undefined) throw error;
|
|
647
647
|
const application = typeof running?.name === "string" ? running.name : "atomic";
|
|
648
648
|
const restart = new Error(`${application} was updated to ${updatedTo} while this session was running; restart it to keep using ${feature}.`, {
|
|
@@ -6,7 +6,7 @@ try {
|
|
|
6
6
|
} catch (error) {
|
|
7
7
|
const root = new URL("../../", import.meta.url);
|
|
8
8
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
9
|
-
const key = `${root.href}#0.10.
|
|
9
|
+
const key = `${root.href}#0.10.10-alpha.2`;
|
|
10
10
|
let release = releases.get(key);
|
|
11
11
|
if (release === undefined) {
|
|
12
12
|
const current = (async () => {
|
|
@@ -27,8 +27,8 @@ try {
|
|
|
27
27
|
release = current;
|
|
28
28
|
}
|
|
29
29
|
const running = await release;
|
|
30
|
-
if (running === undefined || running.version === "0.10.
|
|
31
|
-
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.
|
|
30
|
+
if (running === undefined || running.version === "0.10.10-alpha.2") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.10-alpha.2 while this session was running; restart it to keep using session export.", {
|
|
32
32
|
cause: error,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -6,7 +6,7 @@ try {
|
|
|
6
6
|
} catch (error) {
|
|
7
7
|
const root = new URL("../../", import.meta.url);
|
|
8
8
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
9
|
-
const key = `${root.href}#0.10.
|
|
9
|
+
const key = `${root.href}#0.10.10-alpha.2`;
|
|
10
10
|
let release = releases.get(key);
|
|
11
11
|
if (release === undefined) {
|
|
12
12
|
const current = (async () => {
|
|
@@ -27,8 +27,8 @@ try {
|
|
|
27
27
|
release = current;
|
|
28
28
|
}
|
|
29
29
|
const running = await release;
|
|
30
|
-
if (running === undefined || running.version === "0.10.
|
|
31
|
-
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.
|
|
30
|
+
if (running === undefined || running.version === "0.10.10-alpha.2") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.10-alpha.2 while this session was running; restart it to keep using session export.", {
|
|
32
32
|
cause: error,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -6,7 +6,7 @@ try {
|
|
|
6
6
|
} catch (error) {
|
|
7
7
|
const root = new URL("../../", import.meta.url);
|
|
8
8
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
9
|
-
const key = `${root.href}#0.10.
|
|
9
|
+
const key = `${root.href}#0.10.10-alpha.2`;
|
|
10
10
|
let release = releases.get(key);
|
|
11
11
|
if (release === undefined) {
|
|
12
12
|
const current = (async () => {
|
|
@@ -27,8 +27,8 @@ try {
|
|
|
27
27
|
release = current;
|
|
28
28
|
}
|
|
29
29
|
const running = await release;
|
|
30
|
-
if (running === undefined || running.version === "0.10.
|
|
31
|
-
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.
|
|
30
|
+
if (running === undefined || running.version === "0.10.10-alpha.2") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.10-alpha.2 while this session was running; restart it to keep using session export.", {
|
|
32
32
|
cause: error,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -6,7 +6,7 @@ try {
|
|
|
6
6
|
} catch (error) {
|
|
7
7
|
const root = new URL("../../", import.meta.url);
|
|
8
8
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
9
|
-
const key = `${root.href}#0.10.
|
|
9
|
+
const key = `${root.href}#0.10.10-alpha.2`;
|
|
10
10
|
let release = releases.get(key);
|
|
11
11
|
if (release === undefined) {
|
|
12
12
|
const current = (async () => {
|
|
@@ -27,8 +27,8 @@ try {
|
|
|
27
27
|
release = current;
|
|
28
28
|
}
|
|
29
29
|
const running = await release;
|
|
30
|
-
if (running === undefined || running.version === "0.10.
|
|
31
|
-
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.
|
|
30
|
+
if (running === undefined || running.version === "0.10.10-alpha.2") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.10-alpha.2 while this session was running; restart it to keep using session export.", {
|
|
32
32
|
cause: error,
|
|
33
33
|
});
|
|
34
34
|
}
|