@bastani/atomic 0.10.20-alpha.1 → 0.10.20-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/dist/_shared/dist-KOELCESV.js +2 -2
- package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
- package/dist/_shared/lib-4PES5P4V.js +2 -2
- package/dist/_shared/mode-interactive-sdk-JXBZ3H27.js +72 -39
- package/dist/_shared/mode-interactive-sdk-JXBZ3H27.js.map +1 -1
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +57 -18
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js.map +1 -1
- package/dist/_shared/mode-shared-2QJSCUM6.js +59 -14
- package/dist/_shared/mode-shared-2QJSCUM6.js.map +1 -1
- package/dist/_shared/p0-cli-BB45ZQY6.js +2 -2
- package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
- package/dist/_shared/p1b-elig-BY2G5BUE.js +6 -3
- package/dist/_shared/p1b-elig-BY2G5BUE.js.map +1 -1
- package/dist/_shared/runtime-O4KCSG4C.js +4 -4
- package/dist/_shared/sdk-5ZFNDXUJ.js +208 -54
- package/dist/_shared/sdk-5ZFNDXUJ.js.map +1 -1
- package/dist/_shared/session-data-AHTU7IS6.js +14 -7
- package/dist/_shared/session-data-AHTU7IS6.js.map +1 -1
- package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
- package/dist/_shared/settings-startup-HXQLSUWM.js +2 -2
- package/dist/_shared/settings-startup-HXQLSUWM.js.map +1 -1
- package/dist/_shared/{startup-0-0-FPPQF42L.js → startup-0-0-OWBJIX35.js} +161 -86
- package/dist/_shared/startup-0-0-OWBJIX35.js.map +1 -0
- package/dist/_shared/{startup-0-1-Q7GBLBEL.js → startup-0-1-DZYE4E5Z.js} +321 -17
- package/dist/_shared/startup-0-1-DZYE4E5Z.js.map +1 -0
- package/dist/_shared/{startup-0-2-JNYN24UI.js → startup-0-2-WFLTE4SC.js} +113 -6
- package/dist/_shared/startup-0-2-WFLTE4SC.js.map +1 -0
- package/dist/_shared/startup-0-3-DE2NCS6A.js +47 -23
- package/dist/_shared/startup-0-3-DE2NCS6A.js.map +1 -1
- package/dist/_shared/{startup-0-4-ZZXFKE55.js → startup-0-4-6XXL4JMZ.js} +37 -13
- package/dist/_shared/startup-0-4-6XXL4JMZ.js.map +1 -0
- package/dist/_shared/{startup-0-5-WN2IYA25.js → startup-0-5-DNS6FYS7.js} +126 -150
- package/dist/_shared/startup-0-5-DNS6FYS7.js.map +1 -0
- package/dist/_shared/startup-10-0-O6DAT7U4.js +93 -72
- package/dist/_shared/startup-10-0-O6DAT7U4.js.map +1 -1
- package/dist/_shared/startup-12-0-55AAXBJZ.js +3 -3
- package/dist/_shared/startup-14-0-MLX36RBG.js +5 -5
- package/dist/_shared/startup-15-0-E7RYG5YF.js +6 -6
- package/dist/_shared/startup-15-1-WQZBOTMZ.js +289 -122
- package/dist/_shared/startup-15-1-WQZBOTMZ.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +263 -145
- package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
- package/dist/_shared/{startup-8-1-QZMXUGHI.js → startup-8-1-VXBL37AI.js} +325 -10
- package/dist/_shared/startup-8-1-VXBL37AI.js.map +1 -0
- package/dist/_shared/storage-command-7MGXLJGZ.js +11 -273
- package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
- package/dist/_shared/storage-status-T6FUXRIM.js +4 -4
- package/dist/_shared/task-reference-stream-JWMUZSJX.js +1 -1
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/team-DOQKICG2.js +2 -2
- package/dist/_shared/tree-outline-MUEPK5B7.js +9 -2
- package/dist/_shared/tree-outline-MUEPK5B7.js.map +1 -1
- package/dist/binary-self-update.js +3 -3
- package/dist/builtin/intercom/broker/broker.bundle.mjs +46 -8
- package/dist/builtin/intercom/broker/broker.ts +1 -0
- package/dist/builtin/intercom/broker/client.ts +5 -1
- package/dist/builtin/intercom/broker/departed-children.ts +12 -6
- package/dist/builtin/intercom/broker/ended-child-wakes.ts +2 -0
- package/dist/builtin/intercom/index.bundle.mjs +130 -264
- package/dist/builtin/intercom/message-display.ts +42 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/types.ts +1 -0
- package/dist/builtin/mcp/index.bundle.mjs +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +99 -20
- package/dist/builtin/web-access/index.bundle.mjs +15 -9
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/cli/args.js +2 -2
- package/dist/cli/auth-cli.code.js +6 -6
- package/dist/cli/auth-cli.impl.js +3 -3
- package/dist/cli/auth-cli.js +3 -3
- package/dist/cli/blueprint-command.code.js +4 -4
- package/dist/cli/blueprint-command.impl.js +3 -3
- package/dist/cli/blueprint-command.js +3 -3
- package/dist/cli/intercom-command.code.js +3 -3
- package/dist/cli/intercom-command.impl.js +3 -3
- package/dist/cli/intercom-command.js +3 -3
- package/dist/cli/list-models.code.js +3 -3
- package/dist/cli/list-models.impl.js +3 -3
- package/dist/cli/list-models.js +3 -3
- package/dist/cli/session-picker.code.js +2 -2
- package/dist/cli/session-picker.impl.js +3 -3
- package/dist/cli/session-picker.js +3 -3
- package/dist/cli/startup-ui.code.js +2 -2
- package/dist/cli/startup-ui.impl.js +3 -3
- package/dist/cli/startup-ui.js +3 -3
- package/dist/cli/storage-command.impl.js +3 -3
- package/dist/cli/storage-command.js +3 -3
- package/dist/cli/storage-search-session.code.js +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-runtime.d.ts +14 -3
- package/dist/core/agent-session-types.d.ts +5 -1
- package/dist/core/debug.impl.js +3 -3
- package/dist/core/debug.js +3 -3
- package/dist/core/export-html/card-projection.code.js +74 -72
- package/dist/core/export-html/card-projection.code.js.map +1 -1
- package/dist/core/export-html/card-projection.impl.js +3 -3
- package/dist/core/export-html/card-projection.js +3 -3
- package/dist/core/export-html/index.code.js +12 -4
- package/dist/core/export-html/index.code.js.map +1 -1
- package/dist/core/export-html/index.impl.js +3 -3
- package/dist/core/export-html/index.js +3 -3
- package/dist/core/export-html/json-spans.impl.js +3 -3
- package/dist/core/export-html/json-spans.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.code.js +1 -1
- package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.js +3 -3
- package/dist/core/export-html/template.js +24 -23
- 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/jiti-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-loader.js +3 -3
- package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-static-loader.js +3 -3
- package/dist/core/extensions/loader-host-modules.code.js +1 -1
- package/dist/core/extensions/loader-host-modules.impl.js +3 -3
- package/dist/core/extensions/loader-host-modules.js +3 -3
- package/dist/core/extensions/loader-virtual-modules.js +2 -2
- package/dist/core/extensions/runner-context.js +2 -2
- package/dist/core/intercom-broker-control-host.impl.js +3 -3
- package/dist/core/intercom-broker-control-host.js +3 -3
- package/dist/core/intercom-broker-control.code.js +3 -3
- package/dist/core/intercom-broker-control.impl.js +3 -3
- package/dist/core/intercom-broker-control.js +3 -3
- package/dist/core/model-registry.js +2 -2
- package/dist/core/package-manager-storage-adapters.code.js +1 -1
- package/dist/core/package-manager-storage-adapters.impl.js +3 -3
- package/dist/core/package-manager-storage-adapters.js +3 -3
- package/dist/core/resume/failure.d.ts +1 -1
- package/dist/core/sdk.code.js +4 -4
- package/dist/core/sdk.impl.js +3 -3
- package/dist/core/sdk.js +3 -3
- package/dist/core/session-claims.d.ts +13 -2
- package/dist/core/session-load-events.d.ts +42 -0
- package/dist/core/session-manager-core.d.ts +13 -2
- package/dist/core/session-manager-core.js +211 -98
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-errors.d.ts +2 -2
- package/dist/core/session-manager-list.impl.js +3 -3
- package/dist/core/session-manager-list.js +3 -3
- package/dist/core/session-manager.code.js +1 -1
- package/dist/core/session-manager.impl.js +3 -3
- package/dist/core/session-manager.js +3 -3
- package/dist/core/session-storage.code.js +1 -1
- package/dist/core/session-storage.impl.js +3 -3
- package/dist/core/session-storage.js +3 -3
- package/dist/core/settings-manager.js +2 -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/schema-catalog.d.ts +2 -1
- package/dist/core/storage/schema-catalog.js +25 -6
- package/dist/core/storage/schema-catalog.js.map +1 -1
- package/dist/core/storage/selection.js +2 -2
- package/dist/core/storage/session/branch-fork-source.code.js +17 -4
- package/dist/core/storage/session/branch-fork-source.code.js.map +1 -1
- package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
- package/dist/core/storage/session/branch-fork-source.js +3 -3
- package/dist/core/storage/session/card-view.impl.js +3 -3
- package/dist/core/storage/session/card-view.js +3 -3
- package/dist/core/storage/session/child-reader.code.js +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.code.js +1 -1
- package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.js +3 -3
- package/dist/core/storage/session/expanded-child-details.code.js +3 -3
- package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
- package/dist/core/storage/session/expanded-child-details.js +3 -3
- package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
- package/dist/core/storage/session/fork-row-bytes.js +3 -3
- package/dist/core/storage/session/fork-row-index.impl.js +3 -3
- package/dist/core/storage/session/fork-row-index.js +3 -3
- package/dist/core/storage/session/fork-staging.code.js +8 -4
- package/dist/core/storage/session/fork-staging.code.js.map +1 -1
- package/dist/core/storage/session/fork-staging.impl.js +3 -3
- package/dist/core/storage/session/fork-staging.js +3 -3
- package/dist/core/storage/session/fork-window.code.js +29 -14
- package/dist/core/storage/session/fork-window.code.js.map +1 -1
- package/dist/core/storage/session/fork-window.impl.js +3 -3
- package/dist/core/storage/session/fork-window.js +3 -3
- package/dist/core/storage/session/history-pages.impl.js +3 -3
- package/dist/core/storage/session/history-pages.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.d.ts +8 -4
- package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.js +3 -3
- package/dist/core/storage/session/memory-session-store.d.ts +3 -3
- package/dist/core/storage/session/memory-session-store.impl.js +3 -3
- package/dist/core/storage/session/memory-session-store.js +3 -3
- package/dist/core/storage/session/parent-links.d.ts +122 -0
- package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.js +3 -3
- package/dist/core/storage/session/released-history-files.code.js +3 -3
- package/dist/core/storage/session/released-history-files.impl.js +3 -3
- package/dist/core/storage/session/released-history-files.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.js +3 -3
- package/dist/core/storage/session/session-resume.impl.js +3 -3
- package/dist/core/storage/session/session-resume.js +3 -3
- package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
- package/dist/core/storage/session/snapshot-cut.js +3 -3
- package/dist/core/storage/session/snapshot-history.code.js +5 -6
- package/dist/core/storage/session/snapshot-history.code.js.map +1 -1
- package/dist/core/storage/session/snapshot-history.impl.js +3 -3
- package/dist/core/storage/session/snapshot-history.js +3 -3
- package/dist/core/storage/session/sql-session-store.d.ts +4 -3
- package/dist/core/storage/session/sql-session-store.impl.js +3 -3
- package/dist/core/storage/session/sql-session-store.js +3 -3
- package/dist/core/storage/session/tree-outline.impl.js +3 -3
- package/dist/core/storage/session/tree-outline.js +3 -3
- package/dist/core/storage/session/tree-presentation.code.js +1 -1
- package/dist/core/storage/session/tree-presentation.impl.js +3 -3
- package/dist/core/storage/session/tree-presentation.js +3 -3
- package/dist/core/storage/session/types.d.ts +9 -3
- package/dist/core/storage/session/usage-observations.js +1 -1
- package/dist/core/storage/storage-status.impl.js +3 -3
- package/dist/core/storage/storage-status.js +3 -3
- package/dist/core/storage/team.impl.js +3 -3
- package/dist/core/storage/team.js +3 -3
- package/dist/core/structured-output/index.impl.js +3 -3
- package/dist/core/structured-output/index.js +3 -3
- package/dist/core/tasks/task-completion-entry.code.js +1 -1
- package/dist/core/tasks/task-completion-entry.impl.js +3 -3
- package/dist/core/tasks/task-completion-entry.js +3 -3
- package/dist/core/tasks/task-file-history.code.js +3 -3
- package/dist/core/tasks/task-file-history.impl.js +3 -3
- package/dist/core/tasks/task-file-history.js +3 -3
- package/dist/core/tasks/task-reference-archive.code.js +5 -5
- package/dist/core/tasks/task-reference-archive.js +3 -3
- package/dist/core/tasks/task-reference-identity.code.js +1 -1
- package/dist/core/tasks/task-reference-identity.js +3 -3
- package/dist/core/tasks/task-reference-stream.impl.js +3 -3
- package/dist/core/tasks/task-reference-stream.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.js +3 -3
- package/dist/core/tasks/task-view-source.code.js +1 -1
- package/dist/core/tasks/task-view-source.impl.js +3 -3
- package/dist/core/tasks/task-view-source.js +3 -3
- package/dist/core/tools/read-url.code.js +3 -3
- package/dist/core/tools/read-url.impl.js +3 -3
- package/dist/core/tools/read-url.js +3 -3
- package/dist/core/worktree-snapshot/blob-store.js +2 -2
- package/dist/core/worktree-snapshot/errors.code.js +3 -3
- package/dist/core/worktree-snapshot/errors.impl.js +3 -3
- package/dist/core/worktree-snapshot/errors.js +3 -3
- package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
- package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
- package/dist/extensions/codemode/execute.code.js +2 -2
- package/dist/extensions/codemode/execute.impl.js +3 -3
- package/dist/extensions/codemode/execute.js +3 -3
- package/dist/extensions/codemode/renderer.code.js +12 -7
- package/dist/extensions/codemode/renderer.code.js.map +1 -1
- package/dist/extensions/codemode/renderer.impl.js +3 -3
- package/dist/extensions/codemode/renderer.js +3 -3
- package/dist/extensions/mcp/cli.code.js +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.impl.js +3 -3
- package/dist/extensions/mcp/runtime.js +3 -3
- package/dist/index.d.ts +5 -2
- 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/main.js +1 -1
- package/dist/modes/index.d.ts +1 -1
- package/dist/modes/interactive/components/intercom-wake-notice.d.ts +4 -0
- package/dist/modes/interactive/components/notice-line.d.ts +1 -1
- package/dist/modes/interactive/components/stored-tree-view.code.js +6 -5
- package/dist/modes/interactive/components/stored-tree-view.code.js.map +1 -1
- package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
- package/dist/modes/interactive/components/stored-tree-view.js +3 -3
- package/dist/modes/interactive/components/tool-block.d.ts +5 -1
- package/dist/modes/interactive/components/user-message-selector-archive.code.js +1 -1
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +3 -3
- package/dist/modes/interactive-engine/protocol.d.ts +0 -4
- package/dist/modes/rpc/rpc-client-api.d.ts +5 -0
- package/dist/modes/rpc/rpc-types.d.ts +23 -5
- package/dist/package-manager-cli.code.js +7 -7
- package/dist/package-manager-cli.impl.js +3 -3
- package/dist/package-manager-cli.js +3 -3
- package/dist/rpc-entry.js +1 -1
- package/dist/startup-files.json +1 -1
- package/dist/startup-stages/10.js +1 -1
- package/dist/startup-stages/12.js +1 -1
- package/dist/startup-stages/13.js +2 -1
- package/dist/startup-stages/14.js +1 -0
- package/dist/startup-stages/4.js +1 -1
- package/dist/startup-stages/6.js +1 -1
- package/dist/startup-stages/7.js +1 -1
- package/dist/startup-stages/8.js +1 -1
- package/dist/startup-stages/stages.json +1 -1
- package/dist/utils/startup-database-spare.code.js +3 -3
- package/dist/utils/startup-database-spare.impl.js +3 -3
- package/dist/utils/startup-database-spare.js +3 -3
- package/dist/utils/tools-manager.code.js +1 -1
- package/dist/utils/tools-manager.impl.js +3 -3
- package/dist/utils/tools-manager.js +3 -3
- package/docs/.agents/context/DESIGN.md +30 -0
- package/docs/changelog.mdx +23 -0
- package/docs/docs.json +1 -1
- package/docs/guides/subscription-usage.md +3 -3
- package/docs/intercom.md +3 -1
- package/docs/json.md +3 -3
- package/docs/providers.md +2 -0
- package/docs/rpc/protocol.md +1 -1
- package/docs/sdk.md +2 -0
- package/docs/sessions.md +36 -1
- package/docs/subagents.md +2 -0
- package/package.json +8 -8
- package/dist/_shared/startup-0-0-FPPQF42L.js.map +0 -1
- package/dist/_shared/startup-0-1-Q7GBLBEL.js.map +0 -1
- package/dist/_shared/startup-0-2-JNYN24UI.js.map +0 -1
- package/dist/_shared/startup-0-4-ZZXFKE55.js.map +0 -1
- package/dist/_shared/startup-0-5-WN2IYA25.js.map +0 -1
- package/dist/_shared/startup-8-1-QZMXUGHI.js.map +0 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import "./rolldown-runtime-BGM3D5V3.js";
|
|
2
2
|
import { APP_NAME, ENV_DEBUG, ENV_OFFLINE, ENV_SESSION_DIR, ENV_SKIP_VERSION_CHECK, ENV_STARTUP_BENCHMARK, VERSION, canonicalizePathAsync as canonicalizePathAsync$1, getAgentDir, getEnvValue, getPackageDir, inheritsDebugSetting, markLifecycleTiming, onDebugSettingChange, readInteractiveEngineBootstrap, resolvePath, setDebugSetting, setEnvValue, takeInteractiveEngineBootstrapArg } from "./p0-cli-BB45ZQY6.js";
|
|
3
|
-
import { CompactionCancelledError, CompactionStateError, CompactorFailure, EngineSessionStats, ExtensionStartupError, HostListenerFailures, INTERACTIVE_MODEL_REFRESH_TIMEOUT_MS, InteractiveEngineResourceReadinessError, MissingSessionCwdError, NativeModuleUnavailableError, QueuedDeliveryView, STALE_EXTENSION_CONTEXT_MESSAGE, SessionIntercomPolicy, TOOL_RESULTS_SUBDIR, VERBATIM_COMPACTION_STRATEGY, allToolNames, applyBashSessionEnvironment, assertSessionCwdExists, assignMissingToolCallIds, asyncScope, bindChatReceipt, blueprintBuildPending, blueprintBuildSettled, blueprintBuildsRunning, buildBoundaryText, buildBoundaryTextWithLocation, captureHerdrEnvironment, carryDroppedQueuedMessages, chatRecordSavesSettled, cleanupWindowsSelfUpdateQuarantine, completeStartup, createSyntheticSourceInfo, customMessageExcludesContext, deduplicateDiagnostics, deferDeprecationWarnings, endQueuedMessageDelivery, findMissingSessionCwdIssue, findMissingSessionCwdIssueAsync, formatCodexProviderError, formatNoModelSelectedMessage, formatNoModelsAvailableMessage, getBuiltinPackageLocations, getBuiltinPackagePaths, getDefaultCacheRetention, getToolListError, handlePackageCommandParseOutcome, heldInputView, holdToolsUntilOwnerBuilt, hostInputError, hostNoticeForEvent, interactiveQuitOf, isExtensionLoadError, isMandatoryRuntimeTool, isSingleGenericAbortTextContent, isToolModifier, isTrustedMandatoryRuntimeTool, isUnknownModel, loadShownDeprecationNotices, mergeSessionTrustDecisions, modelCallUsage, nativeModuleProblem, nativeModuleUnavailable, noteQueueUpdateDeliveries, noteQueuedMessagesDropped, noteUserMessageOrigin, notifySessionProviderRequestDispatched, observeToolExecutionTiming, parsePackageCommand, pendingProjectResourcesTrusted, projectTrustedBeforeExtensions, recordStartupThinkingLevel, refreshConfig, registerStartupRollback, releaseToolAbortGraceTimers, releaseUnownedPaneRegistration, replacementAbortContent, restoreStdout, retryStatusUpdate, rollbackStartup, sanitizeOpenAIResponsesPayload, saveChatRecord, savedConversationThinkingLevel, scrubPreCompactionAssistantUsage, serializeConversationForCompaction, serializeSessionMutation, sessionIntercomFacade, shareBlueprintBuild, shouldRunFirstTimeSetup, sleep, snapshotBashSessionEnvironment, startEventLoopMonitor, startupCleanupFailureMessage, startupProjectTrust, stopBlueprintBuilds, takeOverStdout, trackChatRecordSave, uniquifyToolCallIds, validateIntercomSessionOptions, waitForEventLoopMonitorReady, warnDeprecation, watchFirstProjectTrustHandler, writeRawStdout } from "./startup-0-0-
|
|
4
|
-
import { AgentRehydrateError, CacheWarmer, EngineHealthController, RemoteModelCatalog, RemoteQueuePause, TRANSPILE_CACHE_WRITE_WAIT_MS, ToolExecutionScheduler, acceptsForkReplay, assertSettingsWrites, captureForkReplayPair, claimInteractiveBind, collectSettingsDiagnostics, convertToLlm, convertToLlmWithForkBoundaries, currentResourceAdmission, deferMessagesInterleavedWithToolBatch, drainProcessStdio, drainWindowsDirectorySecurityReads, forkReplayFilter, getClientIdentity, isForkHeader, isLocalOnlySessionStorage, isTruthyEnvFlag, isVerbatimCompactionMessage, lifecycleScopeForOwner, migrateCompactionModelSettings, normalizeMessageContent, normalizeModelFailureSignal, noteCommandTurnMessage, ownedSettingsManagers, parseArgs, prewarmModelApi, printHelp, readPipedStdin, recordClosedStart, recordResumeTimings, repairOrphanToolResults, reportDiagnostics, resolveCompactionModel, serializeWorkspaceError, sessionLifecycleCreation, sessionLifecycleScopes, setUsageObservationStore, transpileCacheWritesSettled, unreadableTrustSettingsDiagnostics, usageObservationStore,
|
|
3
|
+
import { CompactionCancelledError, CompactionStateError, CompactorFailure, EngineSessionStats, ExtensionStartupError, HostListenerFailures, INTERACTIVE_MODEL_REFRESH_TIMEOUT_MS, InteractiveEngineResourceReadinessError, MissingSessionCwdError, NativeModuleUnavailableError, QueuedDeliveryView, STALE_EXTENSION_CONTEXT_MESSAGE, SessionIntercomPolicy, TOOL_RESULTS_SUBDIR, VERBATIM_COMPACTION_STRATEGY, acquireLiveSessionClaim, allToolNames, applyBashSessionEnvironment, assertSessionCwdExists, assignMissingToolCallIds, asyncScope, bindChatReceipt, blueprintBuildPending, blueprintBuildSettled, blueprintBuildsRunning, buildBoundaryText, buildBoundaryTextWithLocation, captureHerdrEnvironment, carryDroppedQueuedMessages, chatRecordSavesSettled, cleanupWindowsSelfUpdateQuarantine, completeStartup, createSyntheticSourceInfo, customMessageExcludesContext, deduplicateDiagnostics, deferDeprecationWarnings, endQueuedMessageDelivery, findMissingSessionCwdIssue, findMissingSessionCwdIssueAsync, flushRawStdout, formatCodexProviderError, formatNoModelSelectedMessage, formatNoModelsAvailableMessage, getBuiltinPackageLocations, getBuiltinPackagePaths, getDefaultCacheRetention, getToolListError, handlePackageCommandParseOutcome, heldInputView, holdToolsUntilOwnerBuilt, hostInputError, hostNoticeForEvent, interactiveQuitOf, isExtensionLoadError, isMandatoryRuntimeTool, isSingleGenericAbortTextContent, isToolModifier, isTrustedMandatoryRuntimeTool, isUnknownModel, loadShownDeprecationNotices, mergeSessionTrustDecisions, modelCallUsage, nativeModuleProblem, nativeModuleUnavailable, noteQueueUpdateDeliveries, noteQueuedMessagesDropped, noteUserMessageOrigin, notifySessionProviderRequestDispatched, observeToolExecutionTiming, parsePackageCommand, pendingProjectResourcesTrusted, projectTrustedBeforeExtensions, recordStartupThinkingLevel, refreshConfig, registerStartupRollback, releaseToolAbortGraceTimers, releaseUnownedPaneRegistration, replacementAbortContent, restoreStdout, retryStatusUpdate, rollbackStartup, sanitizeOpenAIResponsesPayload, saveChatRecord, savedConversationThinkingLevel, scrubPreCompactionAssistantUsage, serializeConversationForCompaction, serializeSessionMutation, sessionIntercomFacade, shareBlueprintBuild, shouldRunFirstTimeSetup, sleep, snapshotBashSessionEnvironment, startEventLoopMonitor, startupCleanupFailureMessage, startupProjectTrust, stopBlueprintBuilds, takeOverStdout, trackChatRecordSave, uniquifyToolCallIds, validateIntercomSessionOptions, waitForEventLoopMonitorReady, warnDeprecation, watchFirstProjectTrustHandler, writeRawStdout } from "./startup-0-0-OWBJIX35.js";
|
|
4
|
+
import { AgentRehydrateError, CacheWarmer, EngineHealthController, RemoteModelCatalog, RemoteQueuePause, TRANSPILE_CACHE_WRITE_WAIT_MS, ToolExecutionScheduler, acceptsForkReplay, assertSettingsWrites, captureForkReplayPair, claimInteractiveBind, collectSettingsDiagnostics, convertToLlm, convertToLlmWithForkBoundaries, currentResourceAdmission, deferMessagesInterleavedWithToolBatch, drainProcessStdio, drainWindowsDirectorySecurityReads, forkReplayFilter, getClientIdentity, isForkHeader, isLocalOnlySessionStorage, isTruthyEnvFlag, isVerbatimCompactionMessage, lifecycleScopeForOwner, migrateCompactionModelSettings, normalizeMessageContent, normalizeModelFailureSignal, noteCommandTurnMessage, ownedSettingsManagers, parseArgs, prewarmModelApi, printHelp, readPipedStdin, recordClosedStart, recordResumeTimings, repairOrphanToolResults, reportDiagnostics, resolveCompactionModel, serializeWorkspaceError, sessionLifecycleCreation, sessionLifecycleScopes, setUsageObservationStore, transpileCacheWritesSettled, unreadableTrustSettingsDiagnostics, usageObservationStore, withImagesBlocked, withWindowsDirectorySecurityOwner } from "./startup-0-1-DZYE4E5Z.js";
|
|
5
5
|
import { endTimingSpan, initTheme, printTimings, resetTimings, startEarlyInputCapture, startTimingSpan, stopThemeWatcher, time } from "./p2-shell-main-B2WIALFD.js";
|
|
6
6
|
import { ProjectTrustStore, hasErrorIdentity, hasProjectTrustInputs, hasProjectTrustInputsAsync, redactCredentialShapes, rehydrateErrorCause, reportDebugAsync, serializeErrorCause } from "./p1b-elig-BY2G5BUE.js";
|
|
7
7
|
import { shouldUseFullscreenTui } from "./p1-elig-shell-WWRO3L2R.js";
|
|
8
|
-
import { MessageAdmissionBoundary, abortSessionWork, acquireProtectedPaths, armSessionQuitStops, assertSessionOpen, buildCompactorMessages, calculateContextTokens, clearNestedToolCalls, drainSessionReload, drainSessionWork, drainSessionWorkWithin, estimateContextTokens, estimateProjectedContextTokens, estimateTextTokens, estimateTokens, executeNestedToolCall, getCallableTools, getShellEnvAsync, hasCallingSessionWork, hasProcessStorageSelection, hasSessionReload, isPowerShellAvailable, isPowerShellAvailableAsync, isSelectedNativeMcpTool, limitQuitShutdownHandlers, ownedSessionManagerStores, ownedSessionPermits, ownedSessionStores, processSharedStorageSelection, recordNestedToolCalls, registerSessionRetirement, registerSessionWorkOwner, renewSessionWork, requestCompactorOutput, resolveSessionTempDirPath, restoreAnthropicReplayThinkingBlocks, retireSessionReloadGeneration, selectProcessStorage, sessionGenerationClosing, sessionLifetime, setActiveSessionTempId, setCliStorageSelection, shouldCompact, shutdownDeadline, trackSessionReload, trackSessionWork, untilShutdownHandlerDeadline, validateProcessStorageAsync } from "./startup-0-2-
|
|
8
|
+
import { MessageAdmissionBoundary, abortSessionWork, acquireProtectedPaths, armSessionQuitStops, assertSessionOpen, buildCompactorMessages, calculateContextTokens, clearNestedToolCalls, drainSessionReload, drainSessionWork, drainSessionWorkWithin, estimateContextTokens, estimateProjectedContextTokens, estimateTextTokens, estimateTokens, executeNestedToolCall, getCallableTools, getShellEnvAsync, hasCallingSessionWork, hasProcessStorageSelection, hasSessionReload, isPowerShellAvailable, isPowerShellAvailableAsync, isSelectedNativeMcpTool, isSessionLoadEvent, limitQuitShutdownHandlers, observeSessionLoadHistory, ownedSessionManagerStores, ownedSessionPermits, ownedSessionStores, processSharedStorageSelection, recordNestedToolCalls, registerSessionRetirement, registerSessionWorkOwner, renewSessionWork, replaySessionOpen, requestCompactorOutput, resolveSessionTempDirPath, restoreAnthropicReplayThinkingBlocks, retireSessionReloadGeneration, selectProcessStorage, sessionGenerationClosing, sessionLifetime, setActiveSessionTempId, setCliStorageSelection, shouldCompact, shutdownDeadline, startSessionLoad, trackSessionReload, trackSessionWork, untilShutdownHandlerDeadline, validateProcessStorageAsync, withInitialSessionLoad, withSessionLoadEvents, withSessionLoadPhase } from "./startup-0-2-WFLTE4SC.js";
|
|
9
9
|
import { ChildTaskWaits, RESUME_CATALOG_TIMEOUT_MS, buildSessionProjection, createChildCommandTaskOwner, createProjectTrustContext, getLatestCompactionBoundaryEntry, ignoredProjectSettingsWarning, prepareSessionOpenMarkers, providerAdmissionTimeout, resolveModelScopeWithDiagnostics, resolveWorktreeSnapshotSettings, resumeFailureMessage, resumeLookupError, scheduleSessionTempCleanup, startInteractiveEngineLiveness, withResumeLookupDeadline } from "./startup-0-3-DE2NCS6A.js";
|
|
10
10
|
import { SESSION_HISTORY_SCAN_ENTRIES, SessionAlreadyOpenError, SessionEntryError, isRpcRequestAcceptedFailure, isRpcTransportFailure, markRpcTransportFailure, rpcTransportError } from "./settings-startup-HXQLSUWM.js";
|
|
11
|
-
import { JsonlSessionStore, agentSessionPersistenceFailureMethods, agentSessionReleaseMethods, clearPersistenceFailure, enableReleaseWhenIdle, getLatestSessionSummary, notReopenable, noteMessageSaved, onSessionClose, parseReleaseWhenIdle, recordPersistenceFailure, repeatsShownUnsavedInput, rethrowUnlessReportedPersistenceFailure, sessionClosing } from "./startup-8-0-34CBHPZH.js";
|
|
12
|
-
import { ModelRuntime, WORKSPACE_WRITE_TOOL_NAMES, activatesOnRegistration, agentSessionModelsMethods, agentSessionRetryMethods, assertSessionManagerInWorktreeAsync, bindSessionWorkspace, buildSessionOptions, buildSystemPrompt, computeDeferExtensions, computeInteractiveEngineResourceDeferral, computeStartupInputCaptureEnabled, computeStartupTrustPromptPossible, createToolNameMatcher, deferFirstPromptModel, engineExtensionsCanDecide, ensureRetryPromise, extensionsCanDecideProjectTrust, findInitialModel, formatScopedModelList, getModelFastRoute, getSkillCatalog, isRegisteredToolAllowed, isToolActivatable, isToolDeclarationHidden, loginIsolatedApiKeyProvider, loginIsolatedOAuthProvider, loginRuntimeOAuthProvider, markRuntimeStreamFunction, mergeHeaders, pendingTaskCompletionIntents, rateLimitGuidance, recordSessionWorkspace, resolveDeferredStartupModel, resolveRestoredModelReference, retryIsCurrent, sessionAccountCheckpoint, startupErrorHandlerTokens, streamWithFastRoute, uncachedCopilotModelHint, unresolvedFallbackModelDiagnostics, withFastRouteStreamOptions, workspaceSessionCwdAsync } from "./startup-0-5-
|
|
13
|
-
import { autoDetectCompactionQuery, executeBashWithOperations, formatModelLabel, prepareCompactionBoundary } from "./startup-0-4-
|
|
14
|
-
import { ENGINE_SHUTDOWN_GRACE_MS, RpcClient, SessionWorktreeSnapshotRecorder, SettingsManager, agentSessionSummaryMethods, agentSessionTreeMethods, applyToolModifiers, buildInteractiveEngineArgs, canIsolateSessionStore, cancelSessionSubscriptions, continueSessionWhereItWorked, createLocalBashOperations, createLocalPowerShellOperations, currentWorktreeRestoreNotices, currentWorktreeRootMappings, defaultToolSelectionFor, findUnansweredToolCall, hasSubagentCaptures, inheritChildSessionOptionsWithDefaults, isPlainRuntimeMetadataCommand, notifyAgentPanelSourceHubRebound, parentHistoryNotices, pathExists, prepareInitialMessage, prepareSessionResume, projectSettingsChooseSessionStorage, registerHostStoragePackages, releaseSessionWorktrees, removeSavedModelRoutingSettings, removeSavedModelRoutingSettingsAsync, resolveAppMode, resolveCliPaths, resolveExcludedToolsForAppMode, resolveSessionStore, resumeStoreDir, runMigrations, runMigrationsAsync, savedProjectTrustAsync, sessionResumeOptions, shellCommandPrefixFor, shouldStartRpcCatalogRefresh, showDeprecationWarnings, subscribeSession, takeEngineSessionStorageArg, toPrintOutputMode } from "./startup-8-1-
|
|
11
|
+
import { JsonlSessionStore, MemorySessionStore, agentSessionPersistenceFailureMethods, agentSessionReleaseMethods, clearPersistenceFailure, createSessionId, enableReleaseWhenIdle, getLatestSessionSummary, notReopenable, noteMessageSaved, onSessionClose, parseReleaseWhenIdle, recordPersistenceFailure, repeatsShownUnsavedInput, rethrowUnlessReportedPersistenceFailure, sessionClosing } from "./startup-8-0-34CBHPZH.js";
|
|
12
|
+
import { ModelRuntime, WORKSPACE_WRITE_TOOL_NAMES, activatesOnRegistration, agentSessionModelsMethods, agentSessionRetryMethods, assertSessionManagerInWorktreeAsync, bindSessionWorkspace, buildSessionOptions, buildSystemPrompt, computeDeferExtensions, computeInteractiveEngineResourceDeferral, computeStartupInputCaptureEnabled, computeStartupTrustPromptPossible, createToolNameMatcher, deferFirstPromptModel, engineExtensionsCanDecide, ensureRetryPromise, extensionsCanDecideProjectTrust, findInitialModel, formatScopedModelList, getModelFastRoute, getSkillCatalog, isRegisteredToolAllowed, isToolActivatable, isToolDeclarationHidden, loginIsolatedApiKeyProvider, loginIsolatedOAuthProvider, loginRuntimeOAuthProvider, markRuntimeStreamFunction, mergeHeaders, pendingTaskCompletionIntents, rateLimitGuidance, recordSessionWorkspace, resolveDeferredStartupModel, resolveRestoredModelReference, retryIsCurrent, sessionAccountCheckpoint, startupErrorHandlerTokens, streamWithFastRoute, uncachedCopilotModelHint, unresolvedFallbackModelDiagnostics, withFastRouteStreamOptions, workspaceSessionCwdAsync } from "./startup-0-5-DNS6FYS7.js";
|
|
13
|
+
import { autoDetectCompactionQuery, executeBashWithOperations, formatModelLabel, prepareCompactionBoundary } from "./startup-0-4-6XXL4JMZ.js";
|
|
14
|
+
import { ENGINE_SHUTDOWN_GRACE_MS, RpcClient, SessionWorktreeSnapshotRecorder, SettingsManager, agentSessionSummaryMethods, agentSessionTreeMethods, applyToolModifiers, buildInteractiveEngineArgs, canIsolateSessionStore, cancelSessionSubscriptions, continueSessionWhereItWorked, createLocalBashOperations, createLocalPowerShellOperations, currentWorktreeRestoreNotices, currentWorktreeRootMappings, defaultToolSelectionFor, findUnansweredToolCall, hasSubagentCaptures, inheritChildSessionOptionsWithDefaults, isPlainRuntimeMetadataCommand, notifyAgentPanelSourceHubRebound, parentHistoryNotices, pathExists, prepareInitialMessage, prepareSessionResume, projectSettingsChooseSessionStorage, registerHostStoragePackages, releaseSessionWorktrees, removeSavedModelRoutingSettings, removeSavedModelRoutingSettingsAsync, resolveAppMode, resolveCliPaths, resolveExcludedToolsForAppMode, resolveSessionStore, resumeStoreDir, runMigrations, runMigrationsAsync, savedProjectTrustAsync, sessionResumeOptions, shellCommandPrefixFor, shouldStartRpcCatalogRefresh, showDeprecationWarnings, subscribeSession, takeEngineSessionStorageArg, toPrintOutputMode } from "./startup-8-1-VXBL37AI.js";
|
|
15
15
|
import { abortCurrentGeneration, activatesAfterRecordedLoadout, agentSessionCustomMessageCommitMethods, agentSessionDetachedToolMethods, agentSessionMessageQueueMethods, agentSessionPromptMethods, agentSessionStateMethods, agentSessionTaskMethods, agentSessionToolHooksMethods, agentSessionToolRegistryMethods, awaitedToolTurnEntryId, bindChildTaskNotices, blueprintSubject, childCommandTaskHost, dismissProtectedStreamingCustomMessage, forgetQueuedMessageReceipt, holdsTurnsForDetachedResults, installQueuedMessageTaking, isDetachedToolCall, isProtectedStreamingCustomMessage, isSubagentChildSession, markProtectedStreamingCustomMessageConsumed, markProtectedStreamingCustomMessagePersistenceFailed, normalizeQueuedMessageImages, openChildCommandTaskHost, pauseQueuedMessages, pendingProtectedStreamingCustomMessages, pendingResumeUpdate, persistProtectedStreamingCustomMessage, prepareProtectedStreamingCustomMessagesForDisposal, preservesInitialToolLoadout, queueRunStarted, queuedMessageReceiptId, recordExplicitToolDeactivations, recordedToolLoadout, recoverProtectedStreamingCustomMessages, releaseDetachedCallHolds, replaceSessionTaskOwner, requeueQueuedMessagesNotStarted, retryConsumedProtectedStreamingCustomMessages, startQueuedMessage, withoutDetachedPlaceholders } from "./startup-15-0-E7RYG5YF.js";
|
|
16
16
|
import { SessionManager, SessionSelectorConflictError, agentSessionExportMethods, createResumeProgress, openCliSession, openSessionInCurrentCwdOrExit, promptForDirtyCheckout, promptForMissingSessionCwd, recordPromptOrder, refreshSessionStorage, sessionStorageWouldMove, startupResumeDiagnostics, validateForkFlags, validateImportFlags, validateSessionIdFlags } from "./startup-10-0-O6DAT7U4.js";
|
|
17
17
|
import { captureInteractiveEngineStartupEnv, discardPrewarmedEngine, interactiveEngineClientOptions, interactiveEngineStartupEnv, isInteractiveEngineChild } from "./p1a-prewarm-XIU57JHF.js";
|
|
@@ -159,6 +159,12 @@ const agentSessionBashMethods = {
|
|
|
159
159
|
};
|
|
160
160
|
// dist/core/agent-session-events.js
|
|
161
161
|
function _emit(event) {
|
|
162
|
+
if (isSessionLoadEvent(event)) {
|
|
163
|
+
for (const listener of this._eventListeners) try {
|
|
164
|
+
listener(event);
|
|
165
|
+
} catch {}
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
162
168
|
if (event.type === "agent_start") {
|
|
163
169
|
if (this._retryStatus === void 0 || this._turnStartedAt === void 0) this._turnStartedAt = Date.now();
|
|
164
170
|
event = {
|
|
@@ -634,6 +640,14 @@ function subscribe(listenerOrSource, handler, options) {
|
|
|
634
640
|
if (typeof listenerOrSource !== "function") return subscribeSession(this, listenerOrSource, handler, options);
|
|
635
641
|
const listener = listenerOrSource;
|
|
636
642
|
this._eventListeners = [...this._eventListeners, listener];
|
|
643
|
+
replaySessionOpen(this, listener);
|
|
644
|
+
const warning = this.sessionManager.getHistoryWarning();
|
|
645
|
+
if (warning !== void 0) listener(warning);
|
|
646
|
+
const repaired = this.sessionManager.getImportRepairs();
|
|
647
|
+
if (repaired.length > 0) listener({
|
|
648
|
+
type: "session_history_repaired",
|
|
649
|
+
repaired
|
|
650
|
+
});
|
|
637
651
|
return () => {
|
|
638
652
|
const index = this._eventListeners.indexOf(listener);
|
|
639
653
|
if (index !== -1) this._eventListeners = this._eventListeners.filter((_, position) => position !== index);
|
|
@@ -3223,9 +3237,16 @@ function _bindExtensionCore(runner, publication, startupToolNames, startupLoadou
|
|
|
3223
3237
|
});
|
|
3224
3238
|
}
|
|
3225
3239
|
async function reload(options) {
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3240
|
+
const run = async () => {
|
|
3241
|
+
if (this._disposed || sessionGenerationClosing.has(this) || hasSessionReload(this)) throw hostInputError("SessionClosed");
|
|
3242
|
+
sessionGenerationClosing.add(this);
|
|
3243
|
+
return trackSessionReload(this, () => reloadAdmitted.call(this, options));
|
|
3244
|
+
};
|
|
3245
|
+
if (options?.reason === "startup") return run();
|
|
3246
|
+
return withSessionLoadEvents(this.sessionId, (event) => this._emit(event), (phase) => {
|
|
3247
|
+
phase("Reloading session");
|
|
3248
|
+
return run();
|
|
3249
|
+
});
|
|
3229
3250
|
}
|
|
3230
3251
|
async function reloadAdmitted(options) {
|
|
3231
3252
|
const retiringRunner = this._extensionRunner;
|
|
@@ -4127,6 +4148,10 @@ var AgentSessionBase = class {
|
|
|
4127
4148
|
...notice
|
|
4128
4149
|
})
|
|
4129
4150
|
});
|
|
4151
|
+
this.sessionManager.bindHistoryRepairs((repaired) => this._emit({
|
|
4152
|
+
type: "session_history_repaired",
|
|
4153
|
+
repaired
|
|
4154
|
+
}));
|
|
4130
4155
|
this.settingsManager = config.settingsManager;
|
|
4131
4156
|
this._scopedModels = config.scopedModels ?? [];
|
|
4132
4157
|
this._configuredFallbackModels = config.fallbackModels;
|
|
@@ -4375,8 +4400,14 @@ function closeFailure(session, failure) {
|
|
|
4375
4400
|
* just before the switch.
|
|
4376
4401
|
*/
|
|
4377
4402
|
const HOST_STARTED_SESSION = Symbol("host-started-session");
|
|
4403
|
+
function interactiveEngineClaimHostPid() {
|
|
4404
|
+
const env = interactiveEngineStartupEnv();
|
|
4405
|
+
return env.child === "1" && env.hostPid !== void 0 ? Number(env.hostPid) : void 0;
|
|
4406
|
+
}
|
|
4378
4407
|
var AgentSessionRuntime = class {
|
|
4379
4408
|
rebindSession;
|
|
4409
|
+
listeners = /* @__PURE__ */ new Set();
|
|
4410
|
+
unsubscribeSessionEvents;
|
|
4380
4411
|
beforeSessionInvalidate;
|
|
4381
4412
|
projectTrustContextFactory;
|
|
4382
4413
|
closed = false;
|
|
@@ -4419,16 +4450,34 @@ var AgentSessionRuntime = class {
|
|
|
4419
4450
|
}
|
|
4420
4451
|
await finalize();
|
|
4421
4452
|
}
|
|
4422
|
-
|
|
4453
|
+
/** The isolated host views sessions already opened by its writer, the engine. */
|
|
4454
|
+
sessionClaimMirror = false;
|
|
4455
|
+
claimSessionTarget(sessionId, borrowHost = false) {
|
|
4456
|
+
return acquireLiveSessionClaim(sessionId, {
|
|
4457
|
+
agentDir: this.services.agentDir,
|
|
4458
|
+
mirror: this.sessionClaimMirror,
|
|
4459
|
+
hostPid: borrowHost ? interactiveEngineClaimHostPid() : void 0
|
|
4460
|
+
});
|
|
4461
|
+
}
|
|
4462
|
+
replace(target, operation) {
|
|
4463
|
+
return withSessionLoadEvents(target, (event) => this.emitEvent(event), (phase) => this.replaceOperation((claim) => operation(phase, claim)), ({ cancelled }) => cancelled);
|
|
4464
|
+
}
|
|
4465
|
+
replaceOperation(operation) {
|
|
4423
4466
|
registerSessionRetirement(this.session);
|
|
4424
4467
|
return this.admit(async () => {
|
|
4425
4468
|
this.replacements++;
|
|
4426
4469
|
let outcome;
|
|
4470
|
+
let releaseClaim;
|
|
4427
4471
|
try {
|
|
4428
|
-
outcome = { value: await operation() }
|
|
4472
|
+
outcome = { value: await operation(async (id, { borrowHost, persisted = this.session.sessionManager.isPersisted() } = {}) => {
|
|
4473
|
+
if (persisted) releaseClaim = await this.claimSessionTarget(id, borrowHost);
|
|
4474
|
+
this.assertOpen();
|
|
4475
|
+
}) };
|
|
4429
4476
|
} catch (error) {
|
|
4430
4477
|
outcome = { error };
|
|
4431
4478
|
this.retainCleanupFailures(error);
|
|
4479
|
+
} finally {
|
|
4480
|
+
await releaseClaim?.();
|
|
4432
4481
|
}
|
|
4433
4482
|
this.replacements--;
|
|
4434
4483
|
if (this.replacements === 0 && this.session._disposed) try {
|
|
@@ -4452,6 +4501,26 @@ var AgentSessionRuntime = class {
|
|
|
4452
4501
|
}
|
|
4453
4502
|
return trackSessionWork(this, operation);
|
|
4454
4503
|
}
|
|
4504
|
+
/** Subscribe to the active session's events across replacements. Replays this runtime's initial open. */
|
|
4505
|
+
subscribe(listener) {
|
|
4506
|
+
const subscription = (event) => listener(event);
|
|
4507
|
+
this.listeners.add(subscription);
|
|
4508
|
+
if (this.listeners.size === 1) this.bindSessionEvents();
|
|
4509
|
+
replaySessionOpen(this, subscription);
|
|
4510
|
+
return () => {
|
|
4511
|
+
this.listeners.delete(subscription);
|
|
4512
|
+
if (this.listeners.size === 0) this.bindSessionEvents();
|
|
4513
|
+
};
|
|
4514
|
+
}
|
|
4515
|
+
bindSessionEvents() {
|
|
4516
|
+
this.unsubscribeSessionEvents?.();
|
|
4517
|
+
this.unsubscribeSessionEvents = this.listeners.size > 0 ? this._session.subscribe((event) => this.emitEvent(event)) : void 0;
|
|
4518
|
+
}
|
|
4519
|
+
emitEvent(event) {
|
|
4520
|
+
for (const listener of [...this.listeners]) try {
|
|
4521
|
+
listener(event);
|
|
4522
|
+
} catch {}
|
|
4523
|
+
}
|
|
4455
4524
|
/** Bind a process-local trust UI; closures never cross the engine RPC boundary. */
|
|
4456
4525
|
setProjectTrustContextFactory(factory) {
|
|
4457
4526
|
this.projectTrustContextFactory = factory;
|
|
@@ -4740,6 +4809,7 @@ var AgentSessionRuntime = class {
|
|
|
4740
4809
|
this._diagnostics = result.diagnostics;
|
|
4741
4810
|
this._modelFallbackMessage = result.modelFallbackMessage;
|
|
4742
4811
|
this._modelFallbackReason = result.modelFallbackReason;
|
|
4812
|
+
this.bindSessionEvents();
|
|
4743
4813
|
if (setup) {
|
|
4744
4814
|
await setup(result.session.sessionManager);
|
|
4745
4815
|
this.assertOpen();
|
|
@@ -4832,18 +4902,26 @@ var AgentSessionRuntime = class {
|
|
|
4832
4902
|
};
|
|
4833
4903
|
}
|
|
4834
4904
|
async switchSession(sessionId, options) {
|
|
4835
|
-
return this.replace(async () => {
|
|
4905
|
+
return this.replace(sessionId, async (phase, claim) => {
|
|
4836
4906
|
const beforeResult = await this.emitBeforeSwitch("resume", sessionId);
|
|
4837
4907
|
this.assertOpen();
|
|
4838
4908
|
if (beforeResult.cancelled) return beforeResult;
|
|
4839
4909
|
const previousSessionId = this.session.sessionId;
|
|
4910
|
+
await claim(sessionId, {
|
|
4911
|
+
borrowHost: sessionId === previousSessionId || options?.startedSession === HOST_STARTED_SESSION,
|
|
4912
|
+
persisted: options?.sessionDirectory !== void 0 || this.session.sessionManager.isPersisted()
|
|
4913
|
+
});
|
|
4840
4914
|
const onProgress = options?.onProgress;
|
|
4915
|
+
const report = onProgress ? (message, entries) => {
|
|
4916
|
+
onProgress(message);
|
|
4917
|
+
phase(message, entries);
|
|
4918
|
+
} : phase;
|
|
4841
4919
|
const openHistory = () => this.boundedSessionLookup(this.session.sessionManager.openSessionById(sessionId, options?.cwdOverride, options?.sessionDirectory, { history: options?.history }), sessionId);
|
|
4842
|
-
|
|
4843
|
-
const opened = await (
|
|
4920
|
+
report("Reading session history");
|
|
4921
|
+
const opened = await observeSessionLoadHistory(report, openHistory);
|
|
4844
4922
|
if (options?.startedSession === HOST_STARTED_SESSION) opened.markSessionStarted();
|
|
4845
4923
|
else if (options?.startedSession instanceof SessionManager) await options.startedSession.handOverStartedSession(opened);
|
|
4846
|
-
const { sessionManager, unrecorded } = await this.resumeWorktree(opened, options?.sessionDirectory, "switch-session",
|
|
4924
|
+
const { sessionManager, unrecorded } = await this.resumeWorktree(opened, options?.sessionDirectory, "switch-session", report);
|
|
4847
4925
|
const missingCwd = await findMissingSessionCwdIssueAsync(sessionManager, this.cwd);
|
|
4848
4926
|
if (missingCwd !== void 0) throw new MissingSessionCwdError(missingCwd);
|
|
4849
4927
|
const runtimeOptions = {
|
|
@@ -4857,7 +4935,7 @@ var AgentSessionRuntime = class {
|
|
|
4857
4935
|
},
|
|
4858
4936
|
projectTrustContext: (options?.projectTrustContextFactory ?? this.projectTrustContextFactory)?.(sessionManager.getCwd())
|
|
4859
4937
|
};
|
|
4860
|
-
|
|
4938
|
+
report("Preparing session");
|
|
4861
4939
|
await this.settleActiveResponseBeforeTeardown();
|
|
4862
4940
|
this.assertOpen();
|
|
4863
4941
|
const complete = await this.createRuntime.prepareResume?.(runtimeOptions);
|
|
@@ -4869,12 +4947,18 @@ var AgentSessionRuntime = class {
|
|
|
4869
4947
|
});
|
|
4870
4948
|
}
|
|
4871
4949
|
async newSession(options) {
|
|
4872
|
-
return this.replace(async () => {
|
|
4950
|
+
return this.replace(this.cwd, async (phase, claim) => {
|
|
4873
4951
|
const beforeResult = await this.emitBeforeSwitch("new");
|
|
4874
4952
|
this.assertOpen();
|
|
4875
4953
|
if (beforeResult.cancelled) return beforeResult;
|
|
4954
|
+
phase("Starting session");
|
|
4876
4955
|
const previousSessionId = this.session.sessionId;
|
|
4877
|
-
const
|
|
4956
|
+
const id = createSessionId();
|
|
4957
|
+
await claim(id);
|
|
4958
|
+
const sessionManager = await SessionManager.create(this.session.sessionManager.getSessionStore(), this.cwd, {
|
|
4959
|
+
id,
|
|
4960
|
+
parentSession: options?.parentSession
|
|
4961
|
+
});
|
|
4878
4962
|
await this.teardownCurrent("new", sessionManager.getSessionId());
|
|
4879
4963
|
await this.apply(await this.createRuntime({
|
|
4880
4964
|
cwd: this.cwd,
|
|
@@ -4890,11 +4974,12 @@ var AgentSessionRuntime = class {
|
|
|
4890
4974
|
});
|
|
4891
4975
|
}
|
|
4892
4976
|
async fork(entryId, options) {
|
|
4893
|
-
return this.replace(async () => {
|
|
4977
|
+
return this.replace(this.session.sessionId, async (phase, claim) => {
|
|
4894
4978
|
const position = options?.position ?? "before";
|
|
4895
4979
|
const beforeResult = await this.emitBeforeFork(entryId, { position });
|
|
4896
4980
|
this.assertOpen();
|
|
4897
4981
|
if (beforeResult.cancelled) return { cancelled: true };
|
|
4982
|
+
phase(position === "at" ? "Cloning session" : "Forking session");
|
|
4898
4983
|
let targetLeafId;
|
|
4899
4984
|
let selectedText;
|
|
4900
4985
|
const selectedEntry = await this.session.sessionManager.readEntry(entryId);
|
|
@@ -4907,9 +4992,15 @@ var AgentSessionRuntime = class {
|
|
|
4907
4992
|
}
|
|
4908
4993
|
this.assertOpen();
|
|
4909
4994
|
const previousSessionId = this.session.sessionId;
|
|
4910
|
-
const
|
|
4911
|
-
|
|
4912
|
-
|
|
4995
|
+
const openHistory = () => this.session.sessionManager.openSessionById(previousSessionId, this.session.sessionManager.getCwd());
|
|
4996
|
+
const sessionManager = await observeSessionLoadHistory(phase, openHistory);
|
|
4997
|
+
const id = createSessionId();
|
|
4998
|
+
await claim(id);
|
|
4999
|
+
if (!targetLeafId) await sessionManager.newSession({
|
|
5000
|
+
id,
|
|
5001
|
+
parentSession: previousSessionId
|
|
5002
|
+
});
|
|
5003
|
+
else await sessionManager.createBranchedSession(targetLeafId, { id });
|
|
4913
5004
|
await this.teardownCurrent("fork", sessionManager.getSessionId());
|
|
4914
5005
|
await this.apply(await this.createRuntime({
|
|
4915
5006
|
cwd: sessionManager.getCwd(),
|
|
@@ -4929,13 +5020,14 @@ var AgentSessionRuntime = class {
|
|
|
4929
5020
|
}
|
|
4930
5021
|
/** Import a format-4 JSONL export into the active session store. */
|
|
4931
5022
|
async importFromJsonl(inputPath, cwdOverride) {
|
|
4932
|
-
return this.replace(async () => {
|
|
5023
|
+
return this.replace(inputPath, async (phase, claim) => {
|
|
5024
|
+
phase("Importing session");
|
|
4933
5025
|
const resolvedPath = resolvePath(inputPath);
|
|
4934
5026
|
if (!await pathExists(resolvedPath)) throw new SessionImportFileNotFoundError(resolvedPath);
|
|
4935
5027
|
const source = await JsonlSessionStore.open(dirname(resolvedPath), { scanExisting: false });
|
|
4936
5028
|
let targetSessionId;
|
|
4937
5029
|
try {
|
|
4938
|
-
targetSessionId = (await source.loadFile(resolvedPath)).header.id;
|
|
5030
|
+
targetSessionId = (await source.loadFile(resolvedPath, { persistUpgrade: false })).header.id;
|
|
4939
5031
|
} finally {
|
|
4940
5032
|
await source.close();
|
|
4941
5033
|
}
|
|
@@ -4943,7 +5035,10 @@ var AgentSessionRuntime = class {
|
|
|
4943
5035
|
this.assertOpen();
|
|
4944
5036
|
if (beforeResult.cancelled) return beforeResult;
|
|
4945
5037
|
const previousSessionId = this.session.sessionId;
|
|
4946
|
-
const
|
|
5038
|
+
const importHistory = () => this.session.sessionManager.importFromJsonl(resolvedPath, cwdOverride, claim);
|
|
5039
|
+
const imported = await observeSessionLoadHistory(phase, importHistory);
|
|
5040
|
+
const repaired = imported.getImportRepairs();
|
|
5041
|
+
const { sessionManager, unrecorded } = await this.resumeWorktree(imported, void 0, "switch-session", phase);
|
|
4947
5042
|
const missingCwd = await findMissingSessionCwdIssueAsync(sessionManager, this.cwd);
|
|
4948
5043
|
if (missingCwd !== void 0) {
|
|
4949
5044
|
const failure = new MissingSessionCwdError(missingCwd);
|
|
@@ -4962,7 +5057,10 @@ var AgentSessionRuntime = class {
|
|
|
4962
5057
|
}
|
|
4963
5058
|
}));
|
|
4964
5059
|
this.resumeNoticeQueue.push(...unrecorded);
|
|
4965
|
-
return {
|
|
5060
|
+
return {
|
|
5061
|
+
cancelled: false,
|
|
5062
|
+
...repaired.length === 0 ? {} : { repaired }
|
|
5063
|
+
};
|
|
4966
5064
|
});
|
|
4967
5065
|
}
|
|
4968
5066
|
/**
|
|
@@ -4987,6 +5085,9 @@ var AgentSessionRuntime = class {
|
|
|
4987
5085
|
* they were restored. Lookups in shared storage are bounded as `/resume`'s are.
|
|
4988
5086
|
*/
|
|
4989
5087
|
rehydrate(sessionId, options) {
|
|
5088
|
+
return withSessionLoadEvents(sessionId, (event) => this.emitEvent(event), (phase) => this.rehydrateSession(sessionId, options?.history, phase));
|
|
5089
|
+
}
|
|
5090
|
+
rehydrateSession(sessionId, history, phase) {
|
|
4990
5091
|
return this.admit(async () => {
|
|
4991
5092
|
const current = this.session;
|
|
4992
5093
|
if (this.session.sessionId === sessionId && !current._disposed) return this.session;
|
|
@@ -4994,7 +5095,7 @@ var AgentSessionRuntime = class {
|
|
|
4994
5095
|
if (live !== void 0 && !live._disposed) return live;
|
|
4995
5096
|
const pending = this.rehydrating.get(sessionId);
|
|
4996
5097
|
if (pending !== void 0) return pending;
|
|
4997
|
-
const rehydration = this.rehydrateFromStore(sessionId,
|
|
5098
|
+
const rehydration = this.rehydrateFromStore(sessionId, history, phase);
|
|
4998
5099
|
this.rehydrating.set(sessionId, rehydration);
|
|
4999
5100
|
try {
|
|
5000
5101
|
return await rehydration;
|
|
@@ -5004,14 +5105,16 @@ var AgentSessionRuntime = class {
|
|
|
5004
5105
|
});
|
|
5005
5106
|
}
|
|
5006
5107
|
/** Where a rehydrated session continues, decided checkout by checkout; see {@link continueSessionWhereItWorked}. */
|
|
5007
|
-
continueWhereItWorked(opened, history) {
|
|
5108
|
+
continueWhereItWorked(opened, history, onProgress) {
|
|
5008
5109
|
const options = {
|
|
5009
5110
|
...this.resumeOptions("rehydrate"),
|
|
5111
|
+
onProgress,
|
|
5010
5112
|
onNotices: (notices) => this.queueResumeNotices(notices)
|
|
5011
5113
|
};
|
|
5012
5114
|
return continueSessionWhereItWorked(opened, options, (cwd) => this.boundedSessionLookup(opened.openSessionById(opened.getSessionId(), cwd, void 0, { history }), opened.getSessionId()));
|
|
5013
5115
|
}
|
|
5014
|
-
async rehydrateFromStore(sessionId, history) {
|
|
5116
|
+
async rehydrateFromStore(sessionId, history, phase) {
|
|
5117
|
+
phase?.("Reading session history");
|
|
5015
5118
|
const store = this.session.sessionManager.getSessionStore();
|
|
5016
5119
|
if (await this.boundedSessionLookup(store.readHeader(sessionId), sessionId) === void 0) {
|
|
5017
5120
|
const storage = store.descriptor.adapter;
|
|
@@ -5021,29 +5124,37 @@ var AgentSessionRuntime = class {
|
|
|
5021
5124
|
localOnly: isLocalOnlySessionStorage(storage)
|
|
5022
5125
|
});
|
|
5023
5126
|
}
|
|
5024
|
-
const
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
sessionManager
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5127
|
+
const releaseClaim = this.session.sessionManager.isPersisted() ? await this.claimSessionTarget(sessionId) : void 0;
|
|
5128
|
+
try {
|
|
5129
|
+
const openHistory = () => this.boundedSessionLookup(this.session.sessionManager.openSessionById(sessionId, void 0, void 0, { history }), sessionId);
|
|
5130
|
+
const opened = await (phase ? observeSessionLoadHistory(phase, openHistory) : openHistory());
|
|
5131
|
+
const sessionManager = await this.continueWhereItWorked(opened, history, phase);
|
|
5132
|
+
phase?.("Preparing session");
|
|
5133
|
+
const cwd = sessionManager.getCwd();
|
|
5134
|
+
const create = () => sessionLifecycleCreation.run({ scope: {} }, () => this.sessionFactory({
|
|
5135
|
+
cwd,
|
|
5136
|
+
agentDir: this.services.agentDir,
|
|
5137
|
+
sessionManager,
|
|
5138
|
+
sessionStartEvent: {
|
|
5139
|
+
type: "session_start",
|
|
5140
|
+
reason: "resume"
|
|
5141
|
+
},
|
|
5142
|
+
...cwd === this.services.cwd ? { services: this.services } : {}
|
|
5143
|
+
}));
|
|
5144
|
+
const session = (await (phase ? withSessionLoadPhase(phase, create) : create())).session;
|
|
5145
|
+
this.rehydrated.set(sessionId, session);
|
|
5146
|
+
onSessionClose(session, () => this.rehydrated.delete(sessionId));
|
|
5147
|
+
if (this.closed) {
|
|
5148
|
+
const cleanupCause = await session.dispose().then(() => void 0, (failure) => closeFailure(session, failure));
|
|
5149
|
+
throw Object.assign(/* @__PURE__ */ new Error("Session is closed"), {
|
|
5150
|
+
code: "SessionClosed",
|
|
5151
|
+
...cleanupCause === void 0 ? {} : { cleanupCause }
|
|
5152
|
+
});
|
|
5153
|
+
}
|
|
5154
|
+
return session;
|
|
5155
|
+
} finally {
|
|
5156
|
+
await releaseClaim?.();
|
|
5045
5157
|
}
|
|
5046
|
-
return session;
|
|
5047
5158
|
}
|
|
5048
5159
|
/** Number of live sessions this runtime rehydrated; counted by tests. */
|
|
5049
5160
|
get rehydratedSessionCount() {
|
|
@@ -5118,20 +5229,30 @@ var AgentSessionRuntime = class {
|
|
|
5118
5229
|
* later /new, /resume, /fork, and import flows.
|
|
5119
5230
|
*/
|
|
5120
5231
|
async function createAgentSessionRuntime(createRuntime, options) {
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
return new AgentSessionRuntime(result.session, result.services, createRuntime, result.diagnostics, result.modelFallbackMessage, result.modelFallbackReason, options.interactive);
|
|
5125
|
-
} catch (error) {
|
|
5126
|
-
const store = ownedSessionManagerStores.get(options.sessionManager);
|
|
5127
|
-
ownedSessionManagerStores.delete(options.sessionManager);
|
|
5232
|
+
return withInitialSessionLoad(options.sessionManager.getSessionId(), async (phase) => {
|
|
5233
|
+
phase("Preparing session");
|
|
5234
|
+
let releaseClaim;
|
|
5128
5235
|
try {
|
|
5129
|
-
await
|
|
5130
|
-
|
|
5131
|
-
|
|
5236
|
+
if (options.sessionManager.isPersisted()) releaseClaim = await acquireLiveSessionClaim(options.sessionManager.getSessionId(), {
|
|
5237
|
+
agentDir: options.agentDir,
|
|
5238
|
+
hostPid: interactiveEngineClaimHostPid()
|
|
5239
|
+
});
|
|
5240
|
+
await assertSessionCwdExists(options.sessionManager, options.cwd);
|
|
5241
|
+
const result = await observeSessionLoadHistory(phase, () => sessionLifecycleCreation.run({ scope: {} }, () => createRuntime(options)));
|
|
5242
|
+
return new AgentSessionRuntime(result.session, result.services, createRuntime, result.diagnostics, result.modelFallbackMessage, result.modelFallbackReason, options.interactive);
|
|
5243
|
+
} catch (error) {
|
|
5244
|
+
const store = ownedSessionManagerStores.get(options.sessionManager);
|
|
5245
|
+
ownedSessionManagerStores.delete(options.sessionManager);
|
|
5246
|
+
try {
|
|
5247
|
+
await store?.close();
|
|
5248
|
+
} catch (cause) {
|
|
5249
|
+
throw new StorageRollbackError(error, cause);
|
|
5250
|
+
}
|
|
5251
|
+
throw error;
|
|
5252
|
+
} finally {
|
|
5253
|
+
await releaseClaim?.();
|
|
5132
5254
|
}
|
|
5133
|
-
|
|
5134
|
-
}
|
|
5255
|
+
}, (runtime) => runtime);
|
|
5135
5256
|
}
|
|
5136
5257
|
// dist/core/sdk.js
|
|
5137
5258
|
setDefaultStreamFn(streamSimple);
|
|
@@ -5194,13 +5315,18 @@ function sessionIntercomPolicyFor(options) {
|
|
|
5194
5315
|
return options.intercom === void 0 ? void 0 : SessionIntercomPolicy.fromOptions(options.intercom);
|
|
5195
5316
|
}
|
|
5196
5317
|
async function createAgentSession(options = {}) {
|
|
5197
|
-
return createScopedSession(options, false);
|
|
5318
|
+
if (sessionLifecycleCreation.getStore()?.replacement) return createScopedSession(options, false);
|
|
5319
|
+
const target = options.sessionManager?.getSessionId() ?? options.cwd ?? process.cwd();
|
|
5320
|
+
return withInitialSessionLoad(target, (phase) => {
|
|
5321
|
+
phase("Preparing session");
|
|
5322
|
+
return observeSessionLoadHistory(phase, () => createScopedSession(options, false, true, true, phase));
|
|
5323
|
+
}, (result) => result.session);
|
|
5198
5324
|
}
|
|
5199
5325
|
/** Internal CLI assembly seam. Not exported from the package entrypoint. */
|
|
5200
5326
|
function createUnstartedAgentSession(options, persistInitialState = true, recoverMissingModel = false) {
|
|
5201
5327
|
return createScopedSession(options, true, persistInitialState, recoverMissingModel);
|
|
5202
5328
|
}
|
|
5203
|
-
function createScopedSession(options, deferStart, persistInitialState = true, recoverMissingModel = !deferStart) {
|
|
5329
|
+
function createScopedSession(options, deferStart, persistInitialState = true, recoverMissingModel = !deferStart, phase) {
|
|
5204
5330
|
let releaseWhenIdle;
|
|
5205
5331
|
try {
|
|
5206
5332
|
const nativeProblem = nativeModuleProblem();
|
|
@@ -5234,7 +5360,7 @@ function createScopedSession(options, deferStart, persistInitialState = true, re
|
|
|
5234
5360
|
extensionBindings: options.extensionBindings ?? context.bindings,
|
|
5235
5361
|
resourceAdmission: admission
|
|
5236
5362
|
};
|
|
5237
|
-
return await constructAgentSession(scopedOptions, deferStart, persistInitialState, acquisition, recoverMissingModel && (Object.hasOwn(scopedOptions, "model") ? !scopedOptions.model : !("model" in scopedOptions)));
|
|
5363
|
+
return await constructAgentSession(scopedOptions, deferStart, persistInitialState, acquisition, recoverMissingModel && (Object.hasOwn(scopedOptions, "model") ? !scopedOptions.model : !("model" in scopedOptions)), phase);
|
|
5238
5364
|
} catch (error) {
|
|
5239
5365
|
if (acquisition.resumed) await releaseSessionWorktrees(acquisition.resumed);
|
|
5240
5366
|
const failures = await rollbackFactoryAcquisitions();
|
|
@@ -5245,6 +5371,8 @@ function createScopedSession(options, deferStart, persistInitialState = true, re
|
|
|
5245
5371
|
}
|
|
5246
5372
|
if (!failures.length) await acquisition.release?.();
|
|
5247
5373
|
throw factoryRollbackError(error, failures);
|
|
5374
|
+
} finally {
|
|
5375
|
+
await acquisition.releaseClaim?.();
|
|
5248
5376
|
}
|
|
5249
5377
|
});
|
|
5250
5378
|
sessionLifecycleScopes.set(result.session, context.scope);
|
|
@@ -5269,23 +5397,25 @@ async function acquireSessionPermit(admission, options) {
|
|
|
5269
5397
|
* unless `resume.waitForBlueprint` is `"prompt"`. The checkout is compared under the `snapshots` the session itself records with. A session
|
|
5270
5398
|
* without snapshots is returned unchanged, so creating it costs no Git call.
|
|
5271
5399
|
*/
|
|
5272
|
-
async function sessionResumedOnThisNode(sessionManager, agentDir, settingsManager, snapshots) {
|
|
5400
|
+
async function sessionResumedOnThisNode(sessionManager, agentDir, settingsManager, snapshots, onProgress) {
|
|
5273
5401
|
if (sessionManager === void 0 || !sessionManager.isPersisted()) return sessionManager;
|
|
5274
5402
|
if (sessionManager.getLatestWorktreeSnapshots().size === 0 && !hasSubagentCaptures(sessionManager)) return sessionManager;
|
|
5275
5403
|
const settings = settingsManager ?? await SettingsManager.createAsync(process.cwd(), agentDir);
|
|
5276
5404
|
const prepared = await prepareSessionResume(sessionManager, {
|
|
5277
5405
|
...sessionResumeOptions("create-agent-session", process.cwd(), agentDir, settings, savedProjectTrustAsync(agentDir, settings), false),
|
|
5278
|
-
settings: resolveWorktreeSnapshotSettings(snapshots, "sdk", "snapshots", settings.getWorktreeSnapshotSettings())
|
|
5406
|
+
settings: resolveWorktreeSnapshotSettings(snapshots, "sdk", "snapshots", settings.getWorktreeSnapshotSettings()),
|
|
5407
|
+
onProgress
|
|
5279
5408
|
});
|
|
5280
5409
|
return prepared.status === "ready" ? prepared.sessionManager : sessionManager;
|
|
5281
5410
|
}
|
|
5282
|
-
async function constructAgentSession(options, deferStart, persistInitialState, acquisition, recoverMissingModel) {
|
|
5411
|
+
async function constructAgentSession(options, deferStart, persistInitialState, acquisition, recoverMissingModel, phase) {
|
|
5283
5412
|
resolveWorktreeSnapshotSettings(options.snapshots, "sdk", "snapshots");
|
|
5284
5413
|
const workspace = options.workspace === void 0 ? void 0 : await bindSessionWorkspace(options.workspace, options.sessionManager, options.resourceAdmissionSignal);
|
|
5285
5414
|
if (workspace !== void 0) await assertSessionManagerInWorktreeAsync(workspace, options.sessionManager);
|
|
5286
5415
|
const agentDir = options.agentDir ? resolvePath(options.agentDir) : getDefaultAgentDir();
|
|
5287
5416
|
await validateProcessStorageAsync(agentDir);
|
|
5288
|
-
|
|
5417
|
+
if (!deferStart && options.sessionManager?.isPersisted()) acquisition.releaseClaim = await acquireLiveSessionClaim(options.sessionManager.getSessionId(), { agentDir });
|
|
5418
|
+
const suppliedSession = options.cwd === void 0 && workspace === void 0 ? await sessionResumedOnThisNode(options.sessionManager, agentDir, options.settingsManager, options.snapshots, phase) : options.sessionManager;
|
|
5289
5419
|
acquisition.resumed = suppliedSession;
|
|
5290
5420
|
const cwd = workspace === void 0 ? resolvePath(options.cwd ?? suppliedSession?.getCwd() ?? process.cwd()) : await workspaceSessionCwdAsync(workspace, options.cwd);
|
|
5291
5421
|
let resourceLoader = options.resourceLoader;
|
|
@@ -5329,7 +5459,9 @@ async function constructAgentSession(options, deferStart, persistInitialState, a
|
|
|
5329
5459
|
sessionStore
|
|
5330
5460
|
});
|
|
5331
5461
|
if (store !== options.sessionStore) acquisition.store = store;
|
|
5332
|
-
|
|
5462
|
+
const id = createSessionId();
|
|
5463
|
+
if (!(store instanceof MemorySessionStore)) acquisition.releaseClaim = await acquireLiveSessionClaim(id, { agentDir });
|
|
5464
|
+
sessionManager = await SessionManager.create(store, cwd, { id });
|
|
5333
5465
|
}
|
|
5334
5466
|
setUsageObservationStore(modelRuntime, usageObservationStore(sessionManager.getSessionStore()));
|
|
5335
5467
|
if (workspace !== void 0 && persistInitialState) await recordSessionWorkspace(sessionManager, workspace);
|
|
@@ -6159,6 +6291,7 @@ var IsolatedInteractiveRuntime = class extends AgentSessionRuntime {
|
|
|
6159
6291
|
compactionHoldReported = false;
|
|
6160
6292
|
/** The engine prepares every resume of this session and builds its blueprints; this mirror only restores the same state. */
|
|
6161
6293
|
resumeBlueprints = "skip";
|
|
6294
|
+
sessionClaimMirror = true;
|
|
6162
6295
|
patchedSessions = /* @__PURE__ */ new WeakSet();
|
|
6163
6296
|
/** Only committed bytes, independent of host-local mutations. Never shared across engine session generations. */
|
|
6164
6297
|
privateMirror;
|
|
@@ -7145,8 +7278,8 @@ var IsolatedInteractiveRuntime = class extends AgentSessionRuntime {
|
|
|
7145
7278
|
const settledBefore = this.settledEngineSession;
|
|
7146
7279
|
const onProgress = options?.onProgress;
|
|
7147
7280
|
let requestId;
|
|
7148
|
-
const stopProgress = onProgress && this.client.
|
|
7149
|
-
if (event.type === "
|
|
7281
|
+
const stopProgress = onProgress && this.client.onEvent((event) => {
|
|
7282
|
+
if (requestId !== void 0 && event.type === "session_load_progress" && event.id === requestId) onProgress(event.message);
|
|
7150
7283
|
});
|
|
7151
7284
|
this.hostSwitchInFlight += 1;
|
|
7152
7285
|
try {
|
|
@@ -7156,8 +7289,7 @@ var IsolatedInteractiveRuntime = class extends AgentSessionRuntime {
|
|
|
7156
7289
|
sessionId,
|
|
7157
7290
|
cwdOverride: options?.cwdOverride,
|
|
7158
7291
|
sessionDirectory: options?.sessionDirectory,
|
|
7159
|
-
startedSession: started || void 0
|
|
7160
|
-
reportLoadProgress: onProgress ? true : void 0
|
|
7292
|
+
startedSession: started || void 0
|
|
7161
7293
|
}, (id) => {
|
|
7162
7294
|
requestId = id;
|
|
7163
7295
|
}) : await this.client.switchSession(sessionId, options?.cwdOverride, options?.sessionDirectory);
|
|
@@ -7244,7 +7376,10 @@ var IsolatedInteractiveRuntime = class extends AgentSessionRuntime {
|
|
|
7244
7376
|
this.advanceHostMirrorOrder(applied.generation, applied.seq);
|
|
7245
7377
|
} else if (settled) this.advanceHostMirrorOrder(settled.generation, settled.seq);
|
|
7246
7378
|
await this.initializeFromEngine();
|
|
7247
|
-
return {
|
|
7379
|
+
return {
|
|
7380
|
+
cancelled: false,
|
|
7381
|
+
...result.repaired === void 0 ? {} : { repaired: result.repaired }
|
|
7382
|
+
};
|
|
7248
7383
|
} finally {
|
|
7249
7384
|
this.hostSwitchInFlight -= 1;
|
|
7250
7385
|
if (!this.disposed && this.hostSwitchInFlight === 0 && this.hasPendingMirrorSync()) this.scheduleMirrorSync();
|
|
@@ -7698,6 +7833,7 @@ var IsolatedInteractiveRuntime = class extends AgentSessionRuntime {
|
|
|
7698
7833
|
if (!this.hostEventsSubscribed) {
|
|
7699
7834
|
this.hostEventsSubscribed = true;
|
|
7700
7835
|
this.client.onEvent((event) => {
|
|
7836
|
+
if (isSessionLoadEvent(event)) return;
|
|
7701
7837
|
if (this.releasingHostEvents) this.releasingHostEvents.push({
|
|
7702
7838
|
event,
|
|
7703
7839
|
audience: this.lastHostListener
|
|
@@ -8103,6 +8239,7 @@ var IsolatedInteractiveRuntime = class extends AgentSessionRuntime {
|
|
|
8103
8239
|
return JSON.parse(json + decoder.decode());
|
|
8104
8240
|
}
|
|
8105
8241
|
observeEvent(event) {
|
|
8242
|
+
if (isSessionLoadEvent(event)) return;
|
|
8106
8243
|
const session = super.session;
|
|
8107
8244
|
const record = event;
|
|
8108
8245
|
if (isEngineExtensionError(record)) {
|
|
@@ -9198,10 +9335,22 @@ async function main(argv, options) {
|
|
|
9198
9335
|
return false;
|
|
9199
9336
|
};
|
|
9200
9337
|
let sessionManager;
|
|
9338
|
+
let startupClaim;
|
|
9201
9339
|
let worktreeRestoreDiagnostics = [];
|
|
9202
9340
|
const createSessionStartupProgress = () => createResumeProgress(appMode, engineEnv.child === "1", process.stderr, startupSettingsManager.getThemeSetting());
|
|
9203
|
-
const startupProgress = createSessionStartupProgress();
|
|
9204
9341
|
const stopAnnouncingWaits = appMode !== "interactive" && engineEnv.child !== "1" ? (await import("../modes/print-mode.js").catch((error) => __atomicOnDemandFailed(error, "this feature"))).announceBlueprintBuildWaits(appMode !== "print") : void 0;
|
|
9342
|
+
const jsonSessionLoad = appMode === "json" || appMode === "rpc" ? startSessionLoad(parsed.session ?? parsed.sessionId ?? parsed.fork ?? parsed.import ?? cwd, (event) => writeRawStdout(`${JSON.stringify(event)}\n`)) : void 0;
|
|
9343
|
+
const jsonStartupProgress = jsonSessionLoad && {
|
|
9344
|
+
phase: jsonSessionLoad.phase,
|
|
9345
|
+
done() {},
|
|
9346
|
+
pause() {},
|
|
9347
|
+
async beforeExit(failure) {
|
|
9348
|
+
if (failure === void 0) jsonSessionLoad.finish(true);
|
|
9349
|
+
else jsonSessionLoad.fail(failure);
|
|
9350
|
+
await flushRawStdout();
|
|
9351
|
+
}
|
|
9352
|
+
};
|
|
9353
|
+
const startupProgress = jsonStartupProgress ?? createSessionStartupProgress();
|
|
9205
9354
|
try {
|
|
9206
9355
|
const opened = await openCliSession(parsed, cwd, startupSettingsManager, {
|
|
9207
9356
|
agentDir,
|
|
@@ -9213,12 +9362,16 @@ async function main(argv, options) {
|
|
|
9213
9362
|
},
|
|
9214
9363
|
blueprints: engineEnv.child === "1" ? "skip" : "build",
|
|
9215
9364
|
interactive: appMode === "interactive" || engineEnv.child === "1",
|
|
9216
|
-
|
|
9365
|
+
hostClaimPid: engineEnv.child === "1" && engineEnv.hostPid !== void 0 ? Number(engineEnv.hostPid) : void 0,
|
|
9217
9366
|
progress: startupProgress,
|
|
9218
9367
|
chooseDirtyCheckout: appMode === "interactive" ? (prompt) => promptForDirtyCheckout(prompt, startupSettingsManager) : void 0
|
|
9219
9368
|
});
|
|
9220
9369
|
stopAnnouncingWaits?.();
|
|
9221
|
-
if (opened === "cancelled")
|
|
9370
|
+
if (opened === "cancelled") {
|
|
9371
|
+
if (jsonStartupProgress) await jsonStartupProgress.beforeExit();
|
|
9372
|
+
process.exit(0);
|
|
9373
|
+
}
|
|
9374
|
+
startupClaim = opened;
|
|
9222
9375
|
sessionManager = opened.sessionManager;
|
|
9223
9376
|
if (engineEnv.startedSessionId !== void 0 && sessionManager.getSessionId() === engineEnv.startedSessionId) sessionManager.markSessionStarted();
|
|
9224
9377
|
worktreeRestoreDiagnostics = opened.notices;
|
|
@@ -9227,57 +9380,71 @@ async function main(argv, options) {
|
|
|
9227
9380
|
holdToolsUntilOwnerBuilt(resumeStoreDir(agentDir), Number(engineEnv.hostPid), resumed.getSessionId(), (timings) => recordResumeTimings(resumed, timings));
|
|
9228
9381
|
}
|
|
9229
9382
|
} catch (error) {
|
|
9383
|
+
await startupClaim?.releaseClaim();
|
|
9230
9384
|
const held = error instanceof SessionAlreadyOpenError;
|
|
9231
9385
|
const message = held || error instanceof StorageConfigError ? error.message : resumeFailureMessage(error);
|
|
9386
|
+
if (jsonStartupProgress) await jsonStartupProgress.beforeExit(message ?? "Could not open session");
|
|
9232
9387
|
if (message === void 0) throw error;
|
|
9233
9388
|
startupEarlyInputCapture?.consume();
|
|
9234
9389
|
console.error(chalk.red(`Error: ${message}`));
|
|
9235
9390
|
process.exit(held ? 75 : 1);
|
|
9236
9391
|
}
|
|
9237
|
-
|
|
9238
|
-
|
|
9239
|
-
|
|
9240
|
-
|
|
9241
|
-
|
|
9242
|
-
|
|
9243
|
-
|
|
9244
|
-
|
|
9245
|
-
|
|
9246
|
-
progress?.
|
|
9392
|
+
let sessionCwd;
|
|
9393
|
+
let autoTrustOnReloadCwd;
|
|
9394
|
+
let runtime;
|
|
9395
|
+
try {
|
|
9396
|
+
const missingSessionCwdIssue = findMissingSessionCwdIssue(sessionManager, cwd);
|
|
9397
|
+
if (missingSessionCwdIssue) {
|
|
9398
|
+
if (appMode === "interactive") {
|
|
9399
|
+
const choice = await promptForMissingSessionCwd(missingSessionCwdIssue, startupSettingsManager);
|
|
9400
|
+
const progress = createSessionStartupProgress();
|
|
9401
|
+
if (choice !== void 0) progress?.phase(choice === "fork" ? "Forking saved session" : "Reading session history");
|
|
9402
|
+
try {
|
|
9403
|
+
sessionManager = await openSessionInCurrentCwdOrExit(sessionManager, missingSessionCwdIssue, choice, progress, startupClaim?.reserveClaim);
|
|
9404
|
+
} finally {
|
|
9405
|
+
progress?.done();
|
|
9406
|
+
}
|
|
9407
|
+
} else if (engineEnv.child === "1" && engineEnv.sessionCwdOverride !== void 0) sessionManager = await sessionManager.openSessionById(sessionManager.getSessionId(), engineEnv.sessionCwdOverride, void 0, { history: "tail" });
|
|
9408
|
+
else {
|
|
9409
|
+
const message = new MissingSessionCwdError(missingSessionCwdIssue).message;
|
|
9410
|
+
if (jsonStartupProgress) await jsonStartupProgress.beforeExit(message);
|
|
9411
|
+
console.error(chalk.red(message));
|
|
9412
|
+
process.exit(1);
|
|
9247
9413
|
}
|
|
9248
|
-
} else if (engineEnv.child === "1" && engineEnv.sessionCwdOverride !== void 0) sessionManager = await sessionManager.openSessionById(sessionManager.getSessionId(), engineEnv.sessionCwdOverride, void 0, { history: "tail" });
|
|
9249
|
-
else {
|
|
9250
|
-
console.error(chalk.red(new MissingSessionCwdError(missingSessionCwdIssue).message));
|
|
9251
|
-
process.exit(1);
|
|
9252
9414
|
}
|
|
9253
|
-
|
|
9254
|
-
|
|
9255
|
-
|
|
9256
|
-
|
|
9257
|
-
|
|
9258
|
-
|
|
9415
|
+
if (parsed.name !== void 0) {
|
|
9416
|
+
if (!parsed.name.trim()) {
|
|
9417
|
+
const message = "--name requires a non-empty value";
|
|
9418
|
+
if (jsonStartupProgress) await jsonStartupProgress.beforeExit(message);
|
|
9419
|
+
console.error(chalk.red(`Error: ${message}`));
|
|
9420
|
+
startupEarlyInputCapture?.consume();
|
|
9421
|
+
process.exit(1);
|
|
9422
|
+
}
|
|
9259
9423
|
}
|
|
9424
|
+
jsonSessionLoad?.finish();
|
|
9425
|
+
time("createSessionManager");
|
|
9426
|
+
markLifecycleTiming("session-opened");
|
|
9427
|
+
isolateInteractiveHost &&= canIsolateSessionStore(sessionManager.getSessionStore());
|
|
9428
|
+
sessionCwd = sessionManager.getCwd();
|
|
9429
|
+
const selectedProjectTrusted = parsed.projectTrustOverride ?? (hasProjectTrustInputs(sessionCwd) ? projectTrustStore.get(sessionCwd) : true) ?? startupDefaultProjectTrust === "always";
|
|
9430
|
+
isolateInteractiveHost &&= storagePinned || selectedProjectTrusted;
|
|
9431
|
+
startupEarlyInputCapture ??= beginStartupInputCapture(sessionCwd, true, deprecationWarnings.length);
|
|
9432
|
+
autoTrustOnReloadCwd = parsed.projectTrustOverride === void 0 && !hasProjectTrustInputs(sessionCwd) ? sessionCwd : void 0;
|
|
9433
|
+
if (isolateInteractiveHost) await shareBlueprintBuild(resumeStoreDir(agentDir), sessionManager.getSessionId());
|
|
9434
|
+
const runtimeCreationSpan = startTimingSpan("createAgentSessionRuntime");
|
|
9435
|
+
runtime = await createRuntimeForMode(createRuntime, sessionManager.getCwd(), agentDir, sessionManager, isolateInteractiveHost, (options?.extensionFactories?.length ?? 0) > 0, parsed, {
|
|
9436
|
+
extensions: resolvedExtensionPaths,
|
|
9437
|
+
skills: resolvedSkillPaths,
|
|
9438
|
+
promptTemplates: resolvedPromptTemplatePaths,
|
|
9439
|
+
themes: resolvedThemePaths
|
|
9440
|
+
}, appMode === "interactive" || engineEnv.child === "1", async () => extensionsCanDecideTrust && {
|
|
9441
|
+
cwd: sessionManager.getCwd(),
|
|
9442
|
+
extensionsCanDecide: await extensionsCanDecideTrust
|
|
9443
|
+
}, engineInputsFinal);
|
|
9444
|
+
endTimingSpan(runtimeCreationSpan);
|
|
9445
|
+
} finally {
|
|
9446
|
+
await startupClaim?.releaseClaim();
|
|
9260
9447
|
}
|
|
9261
|
-
time("createSessionManager");
|
|
9262
|
-
markLifecycleTiming("session-opened");
|
|
9263
|
-
isolateInteractiveHost &&= canIsolateSessionStore(sessionManager.getSessionStore());
|
|
9264
|
-
const sessionCwd = sessionManager.getCwd();
|
|
9265
|
-
const selectedProjectTrusted = parsed.projectTrustOverride ?? (hasProjectTrustInputs(sessionCwd) ? projectTrustStore.get(sessionCwd) : true) ?? startupDefaultProjectTrust === "always";
|
|
9266
|
-
isolateInteractiveHost &&= storagePinned || selectedProjectTrusted;
|
|
9267
|
-
startupEarlyInputCapture ??= beginStartupInputCapture(sessionCwd, true, deprecationWarnings.length);
|
|
9268
|
-
const autoTrustOnReloadCwd = parsed.projectTrustOverride === void 0 && !hasProjectTrustInputs(sessionCwd) ? sessionCwd : void 0;
|
|
9269
|
-
if (isolateInteractiveHost) await shareBlueprintBuild(resumeStoreDir(agentDir), sessionManager.getSessionId());
|
|
9270
|
-
const runtimeCreationSpan = startTimingSpan("createAgentSessionRuntime");
|
|
9271
|
-
const runtime = await createRuntimeForMode(createRuntime, sessionManager.getCwd(), agentDir, sessionManager, isolateInteractiveHost, (options?.extensionFactories?.length ?? 0) > 0, parsed, {
|
|
9272
|
-
extensions: resolvedExtensionPaths,
|
|
9273
|
-
skills: resolvedSkillPaths,
|
|
9274
|
-
promptTemplates: resolvedPromptTemplatePaths,
|
|
9275
|
-
themes: resolvedThemePaths
|
|
9276
|
-
}, appMode === "interactive" || engineEnv.child === "1", async () => extensionsCanDecideTrust && {
|
|
9277
|
-
cwd: sessionManager.getCwd(),
|
|
9278
|
-
extensionsCanDecide: await extensionsCanDecideTrust
|
|
9279
|
-
}, engineInputsFinal);
|
|
9280
|
-
endTimingSpan(runtimeCreationSpan);
|
|
9281
9448
|
markLifecycleTiming("runtime-created");
|
|
9282
9449
|
ThreadConnection.releaseSpare();
|
|
9283
9450
|
startupRuntime = runtime;
|
|
@@ -9433,7 +9600,7 @@ function __atomicOnDemandFailed(error, feature) {
|
|
|
9433
9600
|
return (async () => {
|
|
9434
9601
|
const root = new URL("../", import.meta.url);
|
|
9435
9602
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
9436
|
-
const key = `${root.href}#0.10.20-alpha.
|
|
9603
|
+
const key = `${root.href}#0.10.20-alpha.2`;
|
|
9437
9604
|
let release = releases.get(key);
|
|
9438
9605
|
if (release === undefined) {
|
|
9439
9606
|
const current = (async () => {
|
|
@@ -9461,7 +9628,7 @@ function __atomicOnDemandFailed(error, feature) {
|
|
|
9461
9628
|
} catch {
|
|
9462
9629
|
// No installation to read, as in a bundle of the package: the release the process runs decides.
|
|
9463
9630
|
}
|
|
9464
|
-
const updatedTo = typeof installed === "string" && installed !== "0.10.20-alpha.
|
|
9631
|
+
const updatedTo = typeof installed === "string" && installed !== "0.10.20-alpha.2" ? installed : running !== undefined && running.version !== "0.10.20-alpha.2" ? "0.10.20-alpha.2" : undefined;
|
|
9465
9632
|
if (updatedTo === undefined) throw error;
|
|
9466
9633
|
const application = typeof running?.name === "string" ? running.name : "atomic";
|
|
9467
9634
|
const restart = new Error(`${application} was updated to ${updatedTo} while this session was running; restart it to keep using ${feature}.`, {
|