@bastani/atomic 0.9.78 → 0.9.79-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 +50 -0
- package/dist/builtin/intercom/CHANGELOG.md +12 -0
- package/dist/builtin/intercom/broker/broker.ts +198 -72
- package/dist/builtin/intercom/broker/client-message-validation.ts +38 -0
- package/dist/builtin/intercom/broker/client.ts +150 -11
- package/dist/builtin/intercom/broker/delivery-failure-reason.ts +1 -0
- package/dist/builtin/intercom/broker/departed-children.ts +23 -0
- package/dist/builtin/intercom/broker/hosted-session-errors.ts +188 -0
- package/dist/builtin/intercom/broker/hosted-sessions.ts +113 -0
- package/dist/builtin/intercom/broker/multinode-router.ts +7 -2
- package/dist/builtin/intercom/broker/presence-handler.ts +2 -1
- package/dist/builtin/intercom/broker/protocol-version.ts +6 -1
- package/dist/builtin/intercom/broker/recipient-gone-errors.ts +46 -5
- package/dist/builtin/intercom/broker/released-reply-errors.ts +1 -1
- package/dist/builtin/intercom/broker/send-handler.ts +19 -3
- package/dist/builtin/intercom/broker/socket-writes.ts +20 -1
- package/dist/builtin/intercom/hosted-session-timeout-error.ts +59 -0
- package/dist/builtin/intercom/index.bundle.mjs +634 -125
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/types.ts +41 -3
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +8 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +90 -34
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +9 -0
- package/dist/builtin/workflows/builtin/{chunk-89we7r4p.js → chunk-5hrzxynt.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-8yfssw01.js → chunk-m56qhe4b.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-wh2p4qjg.js → chunk-x8m4t2jy.js} +182 -33
- package/dist/builtin/workflows/builtin/goal.js +2 -2
- package/dist/builtin/workflows/builtin/index.js +3 -3
- package/dist/builtin/workflows/builtin/ralph.js +2 -2
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +1243 -230
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +854 -170
- package/dist/builtin/workflows/src/index.js +854 -170
- package/dist/builtin/workflows/src/local-worker-entry.mjs +854 -170
- package/dist/cli/startup-progress.d.ts +30 -0
- package/dist/cli/startup-progress.d.ts.map +1 -0
- package/dist/cli/startup-progress.js +78 -0
- package/dist/cli/startup-progress.js.map +1 -0
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +3 -0
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +2 -0
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +2 -0
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-state.d.ts +12 -4
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +82 -15
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session.d.ts +3 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +3 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/builtin-resource-loader.d.ts.map +1 -1
- package/dist/core/builtin-resource-loader.js +3 -0
- package/dist/core/builtin-resource-loader.js.map +1 -1
- package/dist/core/debug.d.ts +4 -2
- package/dist/core/debug.d.ts.map +1 -1
- package/dist/core/debug.js +15 -1
- package/dist/core/debug.js.map +1 -1
- package/dist/core/export-html/ansi-to-html.d.ts +5 -0
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
- package/dist/core/export-html/ansi-to-html.js +57 -20
- package/dist/core/export-html/ansi-to-html.js.map +1 -1
- package/dist/core/export-html/template.js +1 -1
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js +2 -3
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extensions/workflow-activity-hub.d.ts +7 -0
- package/dist/core/extensions/workflow-activity-hub.d.ts.map +1 -1
- package/dist/core/extensions/workflow-activity-hub.js +104 -6
- package/dist/core/extensions/workflow-activity-hub.js.map +1 -1
- package/dist/core/keybindings.d.ts +0 -8
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +0 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/mandatory-resource-loader.d.ts.map +1 -1
- package/dist/core/mandatory-resource-loader.js +3 -0
- package/dist/core/mandatory-resource-loader.js.map +1 -1
- package/dist/core/resume/session-resume.d.ts +7 -1
- package/dist/core/resume/session-resume.d.ts.map +1 -1
- package/dist/core/resume/session-resume.js +136 -16
- package/dist/core/resume/session-resume.js.map +1 -1
- package/dist/core/session-history-index.d.ts +31 -0
- package/dist/core/session-history-index.d.ts.map +1 -0
- package/dist/core/session-history-index.js +82 -0
- package/dist/core/session-history-index.js.map +1 -0
- package/dist/core/session-manager-core.d.ts +3 -0
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +22 -17
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-history.d.ts +3 -3
- package/dist/core/session-manager-history.d.ts.map +1 -1
- package/dist/core/session-manager-history.js +6 -5
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/storage/session/history-load-observer.d.ts +11 -0
- package/dist/core/storage/session/history-load-observer.d.ts.map +1 -0
- package/dist/core/storage/session/history-load-observer.js +25 -0
- package/dist/core/storage/session/history-load-observer.js.map +1 -0
- package/dist/core/storage/session/sql-session-store.d.ts.map +1 -1
- package/dist/core/storage/session/sql-session-store.js +6 -0
- package/dist/core/storage/session/sql-session-store.js.map +1 -1
- package/dist/core/tool-deactivation.d.ts +11 -0
- package/dist/core/tool-deactivation.d.ts.map +1 -0
- package/dist/core/tool-deactivation.js +13 -0
- package/dist/core/tool-deactivation.js.map +1 -0
- package/dist/core/tool-status.d.ts +6 -1
- package/dist/core/tool-status.d.ts.map +1 -1
- package/dist/core/tool-status.js +11 -3
- package/dist/core/tool-status.js.map +1 -1
- package/dist/extensions/llama/errors.js +1 -1
- package/dist/extensions/llama/errors.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts +1 -1
- package/dist/extensions/llama/provider.js +1 -1
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/main-session.d.ts +14 -2
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +42 -9
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +4 -2
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +6 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +13 -4
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.js +3 -4
- package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
- package/dist/modes/interactive/components/task-detail.d.ts +1 -1
- package/dist/modes/interactive/components/task-detail.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-detail.js +1 -3
- package/dist/modes/interactive/components/task-detail.js.map +1 -1
- package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-inspector.js +1 -7
- package/dist/modes/interactive/components/task-inspector.js.map +1 -1
- package/dist/modes/interactive/components/task-navigation.d.ts +0 -1
- package/dist/modes/interactive/components/task-navigation.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-navigation.js +1 -3
- package/dist/modes/interactive/components/task-navigation.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +5 -9
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.js +8 -5
- package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js +16 -10
- package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +2 -0
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-unavailable-tools.d.ts +20 -0
- package/dist/modes/interactive/interactive-unavailable-tools.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-unavailable-tools.js +40 -0
- package/dist/modes/interactive/interactive-unavailable-tools.js.map +1 -0
- package/dist/modes/interactive-engine/engine-diagnostic-view.d.ts +3 -2
- package/dist/modes/interactive-engine/engine-diagnostic-view.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-diagnostic-view.js +5 -3
- package/dist/modes/interactive-engine/engine-diagnostic-view.js.map +1 -1
- package/dist/modes/interactive-engine/remote-component.js +1 -1
- package/dist/modes/interactive-engine/remote-component.js.map +1 -1
- package/docs/background-tasks.md +1 -1
- package/docs/compaction/reference.md +1 -1
- package/docs/compaction.md +3 -3
- package/docs/extensions/api-reference.md +1 -1
- package/docs/extensions/events.md +2 -0
- package/docs/extensions.md +1 -1
- package/docs/intercom/operations.md +2 -2
- package/docs/intercom/reference.md +12 -1
- package/docs/keybindings.md +2 -3
- package/docs/llama-cpp.md +9 -10
- package/docs/models/reference.md +1 -1
- package/docs/models-configuration.md +1 -1
- package/docs/sessions.md +6 -2
- package/docs/subagents.md +3 -1
- package/docs/usage.md +1 -1
- package/docs/workflows/operations.md +2 -2
- package/docs/worktree-snapshots.md +3 -1
- package/npm-shrinkwrap.json +32 -32
- package/package.json +4 -4
- package/schemas/keybindings.schema.json +0 -4
- package/schemas/models.schema.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-manager-core.js","sourceRoot":"","sources":["../../src/core/session-manager-core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGpG,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AAC/G,OAAO,EACN,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,wBAAwB,EACxB,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EACzB,8BAA8B,EAC9B,2BAA2B,EAC3B,uBAAuB,EACvB,oBAAoB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACN,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,aAAa,GACb,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAmBtE,OAAO,EACN,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,0BAA0B,GAC1B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EACN,sBAAs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AC,CAAC,mBAAmB;oBACrB,CAAC,CAAC,OAAO,gBAAgB,KAAK,UAAU;wBACvC,CAAC,CAAC,gBAAgB;wBAClB,CAAC,CAAC,SAAS,CACb,CAAC;YACH,CAAC;oBAAS,CAAC;gBACV,IAAI,CAAC,QAAQ;oBAAE,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;YACpC,CAAC;QACF,CAAC;QACD,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC,2BAA2B,CAAC,CAAC;QACtE,OAAO,eAAe,CACrB,mBAAmB,EACnB,OAAO,gBAAgB,KAAK,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS,EACrE,OAAO,KAAK,SAAS,IAAI,iBAAiB,IAAI,OAAO,IAAI,OAAO,CAAC,eAAe,KAAK,IAAI,EACzF,OAAO,IAAI,SAAS,IAAI,OAAO;YAC9B,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC,OAAO,gBAAgB,KAAK,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAC7F,CAAC;IACH,CAAC;CACD","sourcesContent":["import { writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { getCurrentSystemMessage } from \"@bastani/pi-ai\";\nimport type { ImageContent, Message, TextContent, Usage } from \"@bastani/pi-ai/compat\";\nimport { getAgentDir } from \"../config.js\";\nimport { createSessionCwdMatcher, normalizePath, pathsEqual, resolvePath } from \"../utils/paths.ts\";\nimport type { VerbatimCompactionDetails } from \"./compaction/compaction-types.js\";\nimport type { BashExecutionMessage, CustomMessage } from \"./messages.ts\";\nimport { createBranchedSessionState } from \"./session-manager-archive.ts\";\nimport { classifiedWorkflowMetadata, validSessionWorkflowMetadata } from \"./session-manager-classification.ts\";\nimport {\n\tcreateBranchSummaryEntry,\n\tcreateCompactionEntry,\n\tcreateContextEditEntry,\n\tcreateCustomEntry,\n\tcreateCustomMessageEntry,\n\tcreateLabelEntry,\n\tcreateMessageEntry,\n\tcreateModelChangeEntry,\n\tcreateSessionFilePath,\n\tcreateSessionHeader,\n\tcreateSessionInfoEntry,\n\tcreateSessionSummaryEntry,\n\tcreateThinkingLevelChangeEntry,\n\tcreateWorktreeSnapshotEntry,\n\tgetEntriesWithoutHeader,\n\tgetLatestSessionName,\n} from \"./session-manager-entries.ts\";\nimport { SessionEntryError } from \"./session-manager-errors.js\";\nimport {\n\tbuildContextEntries,\n\tbuildSessionIndex,\n\tbuildSessionProjection,\n\tbuildSessionTree,\n\tgetBranchPath,\n} from \"./session-manager-history.ts\";\nimport { listProjectSessions } from \"./session-manager-list.ts\";\nimport { getDefaultSessionDirPath } from \"./session-manager-paths.ts\";\nimport type {\n\tBranchSummaryEntry,\n\tContextEditEntry,\n\tFileEntry,\n\tModelFallbackRecord,\n\tNewSessionOptions,\n\tSessionContext,\n\tSessionEntry,\n\tSessionHeader,\n\tSessionInfo,\n\tSessionListProgress,\n\tSessionNameState,\n\tSessionProjection,\n\tSessionTreeNode,\n\tSessionWorkflowMetadata,\n\tUsageEntry,\n\tWorktreeRestoreHostWarning,\n} from \"./session-manager-types.ts\";\nimport {\n\tassertValidSessionId,\n\tcreateSessionId,\n\tgenerateId,\n\tvalidateSessionFileEntries,\n} from \"./session-manager-validation.ts\";\nimport { listSessionStore } from \"./session-store-list.js\";\nimport {\n\tassertSessionBlobStore,\n\tcopySessionBlobs,\n\tsessionBlobHashes,\n\tstoreSessionBlobs,\n\tTOOL_OUTPUT_ENTRY_TYPE,\n\ttype ToolOutputReference,\n\ttakeInlineToolOutput,\n} from \"./session-tool-output.ts\";\nimport { adoptInlineSnapshotBlobs } from \"./session-worktree-snapshots.ts\";\nimport { SessionBlobError, type StorageFailureCause, StorageRollbackError } from \"./storage/errors.js\";\nimport {\n\tSessionFormatVersionError,\n\tSessionIdMismatchError,\n\ttype SessionJsonValue,\n\tSessionNotFoundError,\n\tStorageUnavailableError,\n} from \"./storage/session/errors.js\";\nimport { JsonlSessionStore } from \"./storage/session/jsonl-session-store.js\";\nimport { MemorySessionStore, markPrivateMemorySessionStore } from \"./storage/session/memory-session-store.js\";\nimport type { SessionBlob, SessionRecordHeader, SessionSnapshot, SessionStore } from \"./storage/session/types.js\";\nimport { WorkspaceConfigError } from \"./worktree-snapshot/errors.ts\";\nimport type { WorktreeRootMapping, WorktreeSnapshot } from \"./worktree-snapshot/types.ts\";\n\nasync function resolveSessionStore(cwd: string): Promise<SessionStore> {\n\t// Selection loads settings and tools, which depend on the completed session module.\n\treturn (await import(\"./session-storage.js\")).resolveSessionStore(cwd);\n}\n\n/** An in-memory session tree whose mutations await the backing store. */\nexport class SessionManager {\n\tprivate sessionId = \"\";\n\tprivate sessionFile: string | undefined;\n\tprivate sessionDir: string;\n\tprivate cwd: string;\n\tprivate store: SessionStore;\n\tprivate lastSeq = 0;\n\tprivate mutation: Promise<void> = Promise.resolve();\n\tprivate fileEntries: FileEntry[] = [];\n\tprivate byId: Map<string, SessionEntry> = new Map();\n\tprivate labelsById: Map<string, string> = new Map();\n\tprivate labelTimestampsById: Map<string, string> = new Map();\n\tprivate leafId: string | null = null;\n\n\tprivate constructor(store: SessionStore, cwd: string, sessionDir: string, options?: NewSessionOptions) {\n\t\tthis.store = store;\n\t\tthis.cwd = resolvePath(cwd);\n\t\tthis.sessionDir = normalizePath(sessionDir);\n\t\tthis.start(options);\n\t}\n\n\tprivate runMutation<T>(operation: () => Promise<T>): Promise<T> {\n\t\tconst result = this.mutation.then(operation);\n\t\tthis.mutation = result.then(\n\t\t\t() => {},\n\t\t\t() => {},\n\t\t);\n\t\treturn result;\n\t}\n\n\tprivate recordHeader(header = this.getHeader()!): SessionRecordHeader {\n\t\tconst { type: _type, ...record } = header;\n\t\treturn record;\n\t}\n\n\tprivate restore(snapshot: SessionSnapshot, location?: string): void {\n\t\tconst header = snapshot.header;\n\t\tthis.fileEntries = [{ type: \"session\", ...header }, ...snapshot.entries];\n\t\tthis.sessionId = header.id;\n\t\tthis.lastSeq = snapshot.lastSeq;\n\t\tthis.sessionFile =\n\t\t\tlocation ?? (this.store instanceof JsonlSessionStore ? this.store.locationFor(header) : undefined);\n\t\tthis._buildIndex();\n\t}\n\n\tprivate start(options?: NewSessionOptions): string | undefined {\n\t\tif (options?.id !== undefined) assertValidSessionId(options.id);\n\t\tthis.sessionId = options?.id ?? createSessionId();\n\t\tthis.fileEntries = [\n\t\t\tcreateSessionHeader(\n\t\t\t\tthis.sessionId,\n\t\t\t\tthis.cwd,\n\t\t\t\tnew Date().toISOString(),\n\t\t\t\toptions?.parentSession,\n\t\t\t\toptions?.internal,\n\t\t\t\toptions?.workflow,\n\t\t\t),\n\t\t];\n\t\tthis.lastSeq = 0;\n\t\tthis._buildIndex();\n\t\tthis.sessionFile =\n\t\t\tthis.store instanceof JsonlSessionStore\n\t\t\t\t? this.sessionDir\n\t\t\t\t\t? createSessionFilePath(this.sessionDir, this.getHeader()!.createdAt, this.sessionId)\n\t\t\t\t\t: this.store.locationFor(this.recordHeader())\n\t\t\t\t: undefined;\n\t\treturn this.sessionFile;\n\t}\n\n\tsetSessionFile(sessionFile: string): Promise<void> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst opened = await SessionManager.open(sessionFile, this.sessionDir, this.cwd);\n\t\t\tthis.store = opened.store;\n\t\t\tthis.restore(\n\t\t\t\t{ header: opened.recordHeader(), entries: opened.getEntries(), lastSeq: opened.lastSeq },\n\t\t\t\topened.sessionFile,\n\t\t\t);\n\t\t});\n\t}\n\n\tprivate async initialize(): Promise<void> {\n\t\tthis.lastSeq = (\n\t\t\tawait (this.store instanceof JsonlSessionStore\n\t\t\t\t? this.store.create(this.recordHeader(), this.getEntries(), this.sessionFile)\n\t\t\t\t: this.store.create(this.recordHeader(), this.getEntries()))\n\t\t).lastSeq;\n\t}\n\n\tprivate async storeForNewSession(): Promise<SessionStore> {\n\t\tif (\n\t\t\tthis.store instanceof JsonlSessionStore &&\n\t\t\tthis.sessionDir &&\n\t\t\tthis.store.descriptor.location !== resolvePath(this.sessionDir)\n\t\t) {\n\t\t\treturn JsonlSessionStore.open(this.sessionDir, { exactDirectory: true, scanExisting: false });\n\t\t}\n\t\treturn this.store;\n\t}\n\n\tnewSession(options?: NewSessionOptions): Promise<string | undefined> {\n\t\treturn this.runMutation(async () => {\n\t\t\tif (options?.id !== undefined) assertValidSessionId(options.id);\n\t\t\tconst header = createSessionHeader(\n\t\t\t\toptions?.id ?? createSessionId(),\n\t\t\t\tthis.cwd,\n\t\t\t\tnew Date().toISOString(),\n\t\t\t\toptions?.parentSession,\n\t\t\t\toptions?.internal,\n\t\t\t\toptions?.workflow,\n\t\t\t);\n\t\t\tconst record = this.recordHeader(header);\n\t\t\tconst store = await this.storeForNewSession();\n\t\t\tconst location =\n\t\t\t\tstore instanceof JsonlSessionStore\n\t\t\t\t\t? this.sessionDir\n\t\t\t\t\t\t? createSessionFilePath(this.sessionDir, record.createdAt, record.id)\n\t\t\t\t\t\t: store.locationFor(record)\n\t\t\t\t\t: undefined;\n\t\t\tconst result = await (store instanceof JsonlSessionStore\n\t\t\t\t? store.create(record, [], location)\n\t\t\t\t: store.create(record, []));\n\t\t\tthis.store = store;\n\t\t\tthis.byId.clear();\n\t\t\tthis.labelsById.clear();\n\t\t\tthis.labelTimestampsById.clear();\n\t\t\tthis.restore({ header: record, entries: [], lastSeq: result.lastSeq }, location);\n\t\t\treturn this.sessionFile;\n\t\t});\n\t}\n\n\tmarkSessionInternal(workflow?: SessionWorkflowMetadata): Promise<void> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst previous = this.getHeader()!;\n\t\t\tif (classifiedWorkflowMetadata(previous)) return;\n\t\t\tconst validWorkflow = validSessionWorkflowMetadata(workflow);\n\t\t\tif (!validWorkflow) return;\n\t\t\tconst header: SessionHeader = { ...previous, internal: true, workflow: validWorkflow };\n\t\t\tconst result = await this.store.replace(this.sessionId, this.recordHeader(header), this.getEntries(), {\n\t\t\t\texpectSeq: this.lastSeq,\n\t\t\t});\n\t\t\tthis.lastSeq = result.lastSeq;\n\t\t\tthis.fileEntries[0] = header;\n\t\t});\n\t}\n\n\tprivate _buildIndex(): void {\n\t\tvalidateSessionFileEntries(this.fileEntries, this.sessionFile ?? \"in-memory session\");\n\t\tconst index = buildSessionIndex(this.fileEntries);\n\t\tthis.byId = index.byId;\n\t\tthis.labelsById = index.labelsById;\n\t\tthis.labelTimestampsById = index.labelTimestampsById;\n\t\tthis.leafId = index.leafId;\n\t}\n\n\tisPersisted(): boolean {\n\t\treturn !(this.store instanceof MemorySessionStore);\n\t}\n\n\tgetCwd(): string {\n\t\treturn this.cwd;\n\t}\n\n\tgetSessionDir(): string {\n\t\treturn this.sessionDir;\n\t}\n\n\tusesDefaultSessionDir(): boolean {\n\t\treturn pathsEqual(this.sessionDir, getDefaultSessionDirPath(this.cwd));\n\t}\n\n\tgetSessionId(): string {\n\t\treturn this.sessionId;\n\t}\n\n\tgetSessionFile(): string | undefined {\n\t\treturn this.sessionFile;\n\t}\n\n\tgetSessionStore(): SessionStore {\n\t\treturn this.store;\n\t}\n\n\tasync deleteSession(sessionId: string): Promise<void> {\n\t\tassertValidSessionId(sessionId);\n\t\tif (sessionId === this.sessionId) {\n\t\t\tthrow new Error(`Cannot delete the session that is currently open: ${sessionId}`);\n\t\t}\n\t\ttry {\n\t\t\tawait this.store.delete(sessionId);\n\t\t} catch (error) {\n\t\t\tif (!(error instanceof SessionNotFoundError)) throw error;\n\t\t}\n\t}\n\n\t/** @internal Finalize provisional startup storage after project trust resolves. */\n\trebindStore(store: SessionStore, removeProvisionalRecord: boolean): Promise<void> {\n\t\treturn this.runMutation(async () => {\n\t\t\tif (store === this.store) return;\n\t\t\tconst header = this.recordHeader();\n\t\t\tconst entries = this.getEntries();\n\t\t\tconst hashes = sessionBlobHashes(this.store, entries);\n\t\t\tassertSessionBlobStore(store, this.sessionId, hashes.length);\n\t\t\tconst result = await store.create(header, entries);\n\t\t\tawait copySessionBlobs(this.store, this.sessionId, store, this.sessionId, hashes);\n\t\t\tif (removeProvisionalRecord) await this.store.delete(this.sessionId);\n\t\t\tthis.store = store;\n\t\t\tthis.sessionDir = store instanceof JsonlSessionStore ? store.descriptor.location : \"\";\n\t\t\tthis.restore({ header, entries, lastSeq: result.lastSeq });\n\t\t});\n\t}\n\n\tasync openSessionById(sessionId: string, cwdOverride?: string, sessionDirectory?: string): Promise<SessionManager> {\n\t\tlet store =\n\t\t\tsessionDirectory === undefined\n\t\t\t\t? this.store\n\t\t\t\t: await JsonlSessionStore.open(sessionDirectory, { exactDirectory: true, scanExisting: false });\n\t\tlet snapshot: SessionSnapshot;\n\t\ttry {\n\t\t\tsnapshot = await store.load(sessionId);\n\t\t} catch (error) {\n\t\t\tif (\n\t\t\t\t!(error instanceof SessionNotFoundError) ||\n\t\t\t\tsessionDirectory !== undefined ||\n\t\t\t\t!this.usesDefaultSessionDir()\n\t\t\t)\n\t\t\t\tthrow error;\n\t\t\tstore = await JsonlSessionStore.open(join(getAgentDir(), \"sessions\"), { scanExisting: false });\n\t\t\tsnapshot = await store.load(sessionId);\n\t\t}\n\t\tconst location = store instanceof JsonlSessionStore ? await store.findFile(sessionId) : undefined;\n\t\tif (location !== undefined) {\n\t\t\tstore = await JsonlSessionStore.open(dirname(location), { exactDirectory: true, scanExisting: false });\n\t\t\tsnapshot = await store.load(sessionId);\n\t\t}\n\t\tif (snapshot.header.id !== sessionId) throw new SessionIdMismatchError(sessionId, snapshot.header.id);\n\t\tconst manager = new SessionManager(store, cwdOverride ?? snapshot.header.cwd, this.sessionDir);\n\t\tmanager.restore(snapshot, location);\n\t\tif (location !== undefined) manager.sessionDir = dirname(location);\n\t\treturn manager;\n\t}\n\n\tasync importFromJsonl(inputPath: string, cwdOverride?: string): Promise<SessionManager> {\n\t\tconst source = await JsonlSessionStore.open(dirname(resolvePath(inputPath)), {\n\t\t\texactDirectory: true,\n\t\t\tscanExisting: false,\n\t\t});\n\t\ttry {\n\t\t\tconst loaded = await source.loadFile(inputPath);\n\t\t\tconst { entries, blobs } = takeInlineToolOutput(loaded.entries, loaded.header.id);\n\t\t\tassertSessionBlobStore(this.store, loaded.header.id, blobs.length);\n\t\t\tconst snapshot = {\n\t\t\t\t...loaded,\n\t\t\t\tentries: await adoptInlineSnapshotBlobs(entries, this.store.snapshotBlobs),\n\t\t\t};\n\t\t\tconst manager = new SessionManager(this.store, cwdOverride ?? snapshot.header.cwd, this.sessionDir);\n\t\t\tmanager.restore(snapshot);\n\t\t\tawait manager.initialize();\n\t\t\tawait storeSessionBlobs(this.store, snapshot.header.id, blobs);\n\t\t\treturn manager;\n\t\t} finally {\n\t\t\tawait source.close();\n\t\t}\n\t}\n\n\tprivate _appendEntry(entry: SessionEntry): Promise<void> {\n\t\treturn this._appendEntries([entry]);\n\t}\n\n\tprivate async _appendEntries(entries: readonly SessionEntry[]): Promise<void> {\n\t\tconst result = await this.store.append(this.sessionId, entries, { expectSeq: this.lastSeq });\n\t\tthis.lastSeq = result.lastSeq;\n\t\tfor (const entry of entries) {\n\t\t\tthis.fileEntries.push(entry);\n\t\t\tthis.byId.set(entry.id, entry);\n\t\t\tthis.leafId = entry.id;\n\t\t}\n\t}\n\n\t/**\n\t * @internal Record the model and thinking level a new session starts on with one store write, as a model change\n\t * followed by a thinking level change.\n\t */\n\tappendStartState(\n\t\tmodel: { readonly provider: string; readonly modelId: string } | undefined,\n\t\tthinkingLevel: string,\n\t): Promise<void> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst modelEntry =\n\t\t\t\tmodel === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: createModelChangeEntry(model.provider, model.modelId, this.byId, this.leafId);\n\t\t\tconst thinkingEntry = createThinkingLevelChangeEntry(\n\t\t\t\tthinkingLevel,\n\t\t\t\t{ has: (id) => id === modelEntry?.id || this.byId.has(id) },\n\t\t\t\tmodelEntry?.id ?? this.leafId,\n\t\t\t);\n\t\t\tawait this._appendEntries(modelEntry === undefined ? [thinkingEntry] : [modelEntry, thinkingEntry]);\n\t\t});\n\t}\n\n\t/** Append a message as child of current leaf, then advance leaf. Returns entry id. */\n\tappendMessage(message: Message | CustomMessage | BashExecutionMessage): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst entry = createMessageEntry(message, this.byId, this.leafId);\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\n\t/** Append a thinking level change as child of current leaf, then advance leaf. Returns entry id. */\n\tappendThinkingLevelChange(thinkingLevel: string): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst entry = createThinkingLevelChangeEntry(thinkingLevel, this.byId, this.leafId);\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\n\t/** Record auxiliary model usage without adding it to the LLM context. */\n\tappendUsage(kind: string, provider: string, model: string, usage: Usage, note?: string): Promise<UsageEntry> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst entry: UsageEntry = {\n\t\t\t\ttype: \"usage\",\n\t\t\t\tid: generateId(this.byId),\n\t\t\t\tparentId: this.leafId,\n\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\tkind,\n\t\t\t\tprovider,\n\t\t\t\tmodel,\n\t\t\t\tusage,\n\t\t\t\t...(note === undefined ? {} : { note }),\n\t\t\t};\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry;\n\t\t});\n\t}\n\n\t/**\n\t * Append a model change as child of current leaf, then advance leaf. Returns entry id. `fallback` records why a model\n\t * fallback made the change.\n\t */\n\tappendModelChange(provider: string, modelId: string, fallback?: ModelFallbackRecord): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst entry = createModelChangeEntry(provider, modelId, this.byId, this.leafId, fallback);\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\tappendCompaction(\n\t\tcompactedText: string,\n\t\tfirstKeptEntryId: string | null,\n\t\ttokensBefore: number,\n\t\tdetails: VerbatimCompactionDetails,\n\t\tusage?: Usage,\n\t\tcoveredThroughEntryId?: string,\n\t\tprecondition?: () => void,\n\t): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tprecondition?.();\n\t\t\tif (firstKeptEntryId !== null && !this.byId.has(firstKeptEntryId))\n\t\t\t\tthrow new SessionEntryError(firstKeptEntryId, \"missing\");\n\t\t\tif (coveredThroughEntryId !== undefined && !this.byId.has(coveredThroughEntryId))\n\t\t\t\tthrow new SessionEntryError(coveredThroughEntryId, \"missing\");\n\t\t\tconst entry = createCompactionEntry(\n\t\t\t\tcompactedText,\n\t\t\t\tfirstKeptEntryId,\n\t\t\t\ttokensBefore,\n\t\t\t\tdetails,\n\t\t\t\tusage,\n\t\t\t\tthis.byId,\n\t\t\t\tthis.leafId,\n\t\t\t\tcoveredThroughEntryId,\n\t\t\t);\n\t\t\tconst systemMessage = getCurrentSystemMessage(this.buildSessionProjection().messages);\n\t\t\tif (systemMessage) entry.systemMessage = { ...systemMessage, timestamp: new Date(entry.timestamp).getTime() };\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\n\t/** Save a JSONL backup; database-backed sessions have no file snapshot. */\n\twriteBackupSnapshot(label = \"compact\"): Promise<string | undefined> {\n\t\treturn this.runMutation(async () => {\n\t\t\tif (!(this.store instanceof JsonlSessionStore) || !this.sessionFile) return undefined;\n\t\t\tconst path = `${this.sessionFile}.${new Date().toISOString().replace(/[:.]/g, \"-\")}.${label.replace(/[^a-z0-9_-]/gi, \"-\") || \"backup\"}.bak`;\n\t\t\ttry {\n\t\t\t\tawait writeFile(\n\t\t\t\t\tpath,\n\t\t\t\t\t`${[JSON.stringify({ type: \"session\", ...this.recordHeader() }), ...this.getEntries().map((entry) => JSON.stringify(entry))].join(\"\\n\")}\\n`,\n\t\t\t\t);\n\t\t\t} catch (cause) {\n\t\t\t\tthrow new StorageUnavailableError(this.store.descriptor, cause as Error);\n\t\t\t}\n\t\t\treturn path;\n\t\t});\n\t}\n\n\t/** Append a branch-local edit to an earlier model-visible entry. */\n\tappendContextEdit(targetId: string, replacement: ContextEditEntry[\"replacement\"]): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tif (\n\t\t\t\treplacement !== null &&\n\t\t\t\t(typeof replacement !== \"object\" ||\n\t\t\t\t\t!(\"content\" in replacement) ||\n\t\t\t\t\t(typeof replacement.content !== \"string\" && !Array.isArray(replacement.content)))\n\t\t\t) {\n\t\t\t\tthrow new SessionEntryError(targetId, \"invalid-replacement\");\n\t\t\t}\n\t\t\tconst target = this.byId.get(targetId);\n\t\t\tif (!target) throw new SessionEntryError(targetId, \"missing\");\n\t\t\tif (!this.getBranch().some((entry) => entry.id === targetId)) {\n\t\t\t\tthrow new SessionEntryError(targetId, \"inactive\");\n\t\t\t}\n\t\t\tconst editable =\n\t\t\t\ttarget.type === \"custom_message\" ||\n\t\t\t\t(target.type === \"message\" &&\n\t\t\t\t\t(target.message.role === \"user\" ||\n\t\t\t\t\t\ttarget.message.role === \"assistant\" ||\n\t\t\t\t\t\ttarget.message.role === \"toolResult\"));\n\t\t\tif (!editable) throw new SessionEntryError(targetId, \"not-editable\");\n\t\t\tconst targetRole = target.type === \"message\" ? target.message.role : \"custom\";\n\t\t\tconst normalizedReplacement =\n\t\t\t\treplacement !== null &&\n\t\t\t\t(targetRole === \"assistant\" || targetRole === \"toolResult\") &&\n\t\t\t\ttypeof replacement.content === \"string\"\n\t\t\t\t\t? { content: [{ type: \"text\" as const, text: replacement.content }] }\n\t\t\t\t\t: replacement;\n\t\t\tconst entry = createContextEditEntry(targetId, normalizedReplacement, this.byId, this.leafId);\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\n\t/** Append a custom entry (for extensions) as child of current leaf, then advance leaf. Returns entry id. */\n\tappendCustomEntry<T = SessionJsonValue>(customType: string, data?: T): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst entry = createCustomEntry(customType, data, this.byId, this.leafId);\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\n\t/**\n\t * @internal Stores `data` as a blob of the current session and appends the entry that references it, as one\n\t * mutation, so a session change cannot come between the two. The blob goes first: a process that stops in between\n\t * leaves only a blob of this session. Rejects with `blobs-unsupported` when the store holds no blobs.\n\t */\n\tappendToolOutputBlob(toolCallId: string, data: Uint8Array): Promise<SessionBlob> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst { putBlob } = this.store;\n\t\t\tif (putBlob === undefined) {\n\t\t\t\tthrow new SessionBlobError(\"blobs-unsupported\", {\n\t\t\t\t\tsessionId: this.sessionId,\n\t\t\t\t\tadapter: this.store.descriptor.adapter,\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst blob = await putBlob.call(this.store, this.sessionId, data);\n\t\t\tconst reference: ToolOutputReference = { toolCallId, hash: blob.hash, bytes: blob.bytes };\n\t\t\tawait this._appendEntry(createCustomEntry(TOOL_OUTPUT_ENTRY_TYPE, reference, this.byId, this.leafId));\n\t\t\treturn blob;\n\t\t});\n\t}\n\n\t/**\n\t * Record a checkout's snapshot at the current leaf. Pass the snapshot when it is new; omit it to refer to an earlier\n\t * entry's snapshot with the same id (an unchanged capture). `restore` records that the snapshot was restored on\n\t * this host into `root`, and `restoreWarnings` what that restore reported beyond its snapshot record.\n\t */\n\tappendWorktreeSnapshot(\n\t\troot: string,\n\t\tsnapshotId: string,\n\t\tsnapshot?: WorktreeSnapshot,\n\t\trestore?: WorktreeRootMapping,\n\t\trestoreWarnings: readonly WorktreeRestoreHostWarning[] = [],\n\t): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tif (snapshot !== undefined && snapshot.id !== snapshotId) {\n\t\t\t\tthrow new WorkspaceConfigError(\"sdk\", \"snapshot\", \"a snapshot whose id is snapshotId\");\n\t\t\t}\n\t\t\tif (snapshot === undefined && !this.getWorktreeSnapshotRecords().has(snapshotId)) {\n\t\t\t\tthrow new WorkspaceConfigError(\"sdk\", \"snapshotId\", \"the id of a snapshot recorded in this session\");\n\t\t\t}\n\t\t\tif (restore !== undefined && (restore.to !== root || restore.snapshotId !== snapshotId)) {\n\t\t\t\tthrow new WorkspaceConfigError(\"sdk\", \"restore\", \"a mapping to root for snapshotId\");\n\t\t\t}\n\t\t\tif (restore === undefined && restoreWarnings.length > 0) {\n\t\t\t\tthrow new WorkspaceConfigError(\"sdk\", \"restoreWarnings\", \"warnings recorded together with their restore\");\n\t\t\t}\n\t\t\tconst entry = createWorktreeSnapshotEntry(\n\t\t\t\troot,\n\t\t\t\tsnapshotId,\n\t\t\t\tsnapshot,\n\t\t\t\trestore,\n\t\t\t\trestoreWarnings,\n\t\t\t\tthis.byId,\n\t\t\t\tthis.leafId,\n\t\t\t);\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\n\t/** Restores recorded on the active branch, oldest first: work recorded under `from` continues under `to`. */\n\tgetWorktreeRootMappings(): WorktreeRootMapping[] {\n\t\treturn this.getBranch().flatMap((entry) =>\n\t\t\tentry.type === \"worktree_snapshot\" && entry.restore ? [entry.restore] : [],\n\t\t);\n\t}\n\n\t/** Every snapshot record in the session, by id. */\n\tgetWorktreeSnapshotRecords(): Map<string, WorktreeSnapshot> {\n\t\tconst records = new Map<string, WorktreeSnapshot>();\n\t\tfor (const entry of this.fileEntries) {\n\t\t\tif (entry.type === \"worktree_snapshot\" && entry.snapshot) records.set(entry.snapshotId, entry.snapshot);\n\t\t}\n\t\treturn records;\n\t}\n\n\t/** The latest snapshot of each checkout root on the active branch, keyed by the root it was last recorded under. */\n\tgetLatestWorktreeSnapshots(): Map<string, WorktreeSnapshot> {\n\t\tconst records = this.getWorktreeSnapshotRecords();\n\t\tconst latest = new Map<string, WorktreeSnapshot>();\n\t\tfor (const entry of this.getBranch()) {\n\t\t\tif (entry.type !== \"worktree_snapshot\") continue;\n\t\t\tconst snapshot = records.get(entry.snapshotId);\n\t\t\tif (snapshot) latest.set(entry.root, snapshot);\n\t\t}\n\t\treturn latest;\n\t}\n\n\t/** Append a session info entry (e.g., display name). Returns entry id. */\n\tappendSessionInfo(name: string): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst entry = createSessionInfoEntry(name, this.byId, this.leafId);\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\n\t/** Append a generated resume summary anchored to the message it describes. Returns entry id. */\n\tappendSessionSummary(summary: string, summarizedThroughId: string, usage?: Usage): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tif (!this.byId.has(summarizedThroughId)) throw new SessionEntryError(summarizedThroughId, \"missing\");\n\t\t\tconst entry = createSessionSummaryEntry(summary, summarizedThroughId, usage, this.byId, this.leafId);\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\n\t/** Get the current session name from the latest session_info entry, if any. */\n\tgetSessionName(): string | undefined {\n\t\treturn this.getSessionNameState().name;\n\t}\n\n\t/**\n\t * Get the session name state. `hasName` is true for a session that was named and\n\t * then cleared even though `name` is undefined; a never-named session reports\n\t * `hasName: false`. Read-side only: the JSONL already records the distinction.\n\t */\n\tgetSessionNameState(): SessionNameState {\n\t\treturn getLatestSessionName(this.fileEntries);\n\t}\n\n\t/** Append a custom message entry (for extensions) that participates in LLM context unless excluded. */\n\tappendCustomMessageEntry<T = SessionJsonValue>(\n\t\tcustomType: string,\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\tdisplay: boolean,\n\t\tdetails?: T,\n\t\texcludeFromContext?: boolean,\n\t\tprotectedReconciliation?: { delivery: \"steer\" | \"followUp\" },\n\t\tstageAdmissionKey?: string,\n\t): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst entry = createCustomMessageEntry(\n\t\t\t\tcustomType,\n\t\t\t\tcontent,\n\t\t\t\tdisplay,\n\t\t\t\tdetails,\n\t\t\t\texcludeFromContext,\n\t\t\t\tprotectedReconciliation,\n\t\t\t\tthis.byId,\n\t\t\t\tthis.leafId,\n\t\t\t\tstageAdmissionKey,\n\t\t\t);\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\n\tgetLeafId(): string | null {\n\t\treturn this.leafId;\n\t}\n\n\tgetLeafEntry(): SessionEntry | undefined {\n\t\treturn this.leafId ? this.byId.get(this.leafId) : undefined;\n\t}\n\n\tgetEntry(id: string): SessionEntry | undefined {\n\t\treturn this.byId.get(id);\n\t}\n\n\t/** Get all direct children of an entry. */\n\tgetChildren(parentId: string): SessionEntry[] {\n\t\tconst children: SessionEntry[] = [];\n\t\tfor (const entry of this.byId.values()) {\n\t\t\tif (entry.parentId === parentId) {\n\t\t\t\tchildren.push(entry);\n\t\t\t}\n\t\t}\n\t\treturn children;\n\t}\n\n\t/** Get the label for an entry, if any. */\n\tgetLabel(id: string): string | undefined {\n\t\treturn this.labelsById.get(id);\n\t}\n\n\t/** Set or clear a label on an entry. */\n\tappendLabelChange(targetId: string, label: string | undefined): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tif (!this.byId.has(targetId)) {\n\t\t\t\tthrow new SessionEntryError(targetId, \"missing\");\n\t\t\t}\n\t\t\tconst entry = createLabelEntry(targetId, label, this.byId, this.leafId);\n\t\t\tawait this._appendEntry(entry);\n\t\t\tif (label) {\n\t\t\t\tthis.labelsById.set(targetId, label);\n\t\t\t\tthis.labelTimestampsById.set(targetId, entry.timestamp);\n\t\t\t} else {\n\t\t\t\tthis.labelsById.delete(targetId);\n\t\t\t\tthis.labelTimestampsById.delete(targetId);\n\t\t\t}\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\n\t/** Walk from entry to root, returning all entries in path order. */\n\tgetBranch(fromId?: string): SessionEntry[] {\n\t\treturn getBranchPath(fromId ?? this.leafId, this.byId);\n\t}\n\n\t/** Return the active branch entries after applying the latest compaction boundary. */\n\tbuildContextEntries(): SessionEntry[] {\n\t\treturn buildContextEntries(this.getEntries(), this.leafId, this.byId);\n\t}\n\n\t/** Build provenance-preserving, compaction-aware model context from the current leaf. */\n\tbuildSessionProjection(): SessionProjection {\n\t\treturn buildSessionProjection(this.getEntries(), this.leafId, this.byId, this.sessionId);\n\t}\n\n\t/** Build the session context (what gets sent to the LLM). */\n\tbuildSessionContext(): SessionContext {\n\t\tconst { messages, thinkingLevel, model } = this.buildSessionProjection();\n\t\treturn { messages, thinkingLevel, model };\n\t}\n\n\t/** Get session header. */\n\tgetHeader(): SessionHeader | null {\n\t\tconst header = this.fileEntries.find((entry) => entry.type === \"session\");\n\t\treturn header ? (header as SessionHeader) : null;\n\t}\n\n\t/** Number of entries without copying the session history. */\n\tgetEntryCount(): number {\n\t\treturn this.byId.size;\n\t}\n\n\t/** Get all session entries (excludes header). Returns a shallow copy. */\n\tgetEntries(): SessionEntry[] {\n\t\treturn getEntriesWithoutHeader(this.fileEntries);\n\t}\n\n\t/** Get the session as a tree structure. Returns a shallow defensive copy of all entries. */\n\tgetTree(): SessionTreeNode[] {\n\t\treturn buildSessionTree(this.getEntries(), this.labelsById, this.labelTimestampsById);\n\t}\n\n\t/** Start a new branch from an earlier entry. */\n\tbranch(branchFromId: string): Promise<void> {\n\t\treturn this.runMutation(async () => {\n\t\t\tif (!this.byId.has(branchFromId)) {\n\t\t\t\tthrow new SessionEntryError(branchFromId, \"missing\");\n\t\t\t}\n\t\t\tthis.leafId = branchFromId;\n\t\t});\n\t}\n\n\t/** Reset the leaf pointer to null (before any entries). */\n\tresetLeaf(): Promise<void> {\n\t\treturn this.runMutation(async () => {\n\t\t\tthis.leafId = null;\n\t\t});\n\t}\n\n\t/** Start a new branch with a summary of the abandoned path. */\n\tbranchWithSummary<T = SessionJsonValue>(\n\t\tbranchFromId: string | null,\n\t\tsummary: string,\n\t\tdetails?: T,\n\t\tfromHook?: boolean,\n\t\tusage?: import(\"@bastani/pi-ai/compat\").Usage,\n\t\tfromId?: string,\n\t): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tif (branchFromId !== null && !this.byId.has(branchFromId)) {\n\t\t\t\tthrow new SessionEntryError(branchFromId, \"missing\");\n\t\t\t}\n\t\t\tconst entry: BranchSummaryEntry = createBranchSummaryEntry(\n\t\t\t\tbranchFromId,\n\t\t\t\tfromId ?? this.leafId ?? \"root\",\n\t\t\t\tsummary,\n\t\t\t\tdetails,\n\t\t\t\tusage,\n\t\t\t\tfromHook,\n\t\t\t\tthis.byId,\n\t\t\t);\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\n\tcreateBranchedSession(leafId: string): Promise<string | undefined> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst result = createBranchedSessionState({\n\t\t\t\tleafId,\n\t\t\t\tcwd: this.cwd,\n\t\t\t\tparentSessionId: this.sessionId,\n\t\t\t\tworkflow: classifiedWorkflowMetadata(this.getHeader()),\n\t\t\t\tpath: this.getBranch(leafId),\n\t\t\t\tlabelsById: this.labelsById,\n\t\t\t\tlabelTimestampsById: this.labelTimestampsById,\n\t\t\t});\n\t\t\tconst header = result.fileEntries[0] as SessionHeader;\n\t\t\tconst entries = getEntriesWithoutHeader(result.fileEntries);\n\t\t\tconst record = this.recordHeader(header);\n\t\t\tconst hashes = sessionBlobHashes(this.store, entries);\n\t\t\tconst store = await this.storeForNewSession();\n\t\t\tconst location =\n\t\t\t\tstore instanceof JsonlSessionStore\n\t\t\t\t\t? this.sessionDir\n\t\t\t\t\t\t? createSessionFilePath(this.sessionDir, record.createdAt, record.id)\n\t\t\t\t\t\t: store.locationFor(record)\n\t\t\t\t\t: undefined;\n\t\t\tconst lastSeq = (\n\t\t\t\tawait (store instanceof JsonlSessionStore\n\t\t\t\t\t? store.create(record, entries, location)\n\t\t\t\t\t: store.create(record, entries))\n\t\t\t).lastSeq;\n\t\t\tawait copySessionBlobs(this.store, this.sessionId, store, record.id, hashes);\n\t\t\tthis.store = store;\n\t\t\tthis.fileEntries = result.fileEntries;\n\t\t\tthis.sessionId = header.id;\n\t\t\tthis.lastSeq = lastSeq;\n\t\t\tthis.sessionFile = location;\n\t\t\tthis._buildIndex();\n\t\t\treturn this.sessionFile;\n\t\t});\n\t}\n\n\tasync forkTo(cwd: string, sessionDir?: string | SessionStore, options?: NewSessionOptions): Promise<SessionManager> {\n\t\tconst store =\n\t\t\ttypeof sessionDir === \"string\"\n\t\t\t\t? await JsonlSessionStore.open(sessionDir, { exactDirectory: true, scanExisting: false })\n\t\t\t\t: (sessionDir ?? (await resolveSessionStore(cwd)));\n\t\tconst directory = store instanceof JsonlSessionStore ? store.descriptor.location : \"\";\n\t\treturn SessionManager.constructWithStore(store, store !== sessionDir, async () => {\n\t\t\tconst source = { store: this.store, sessionId: this.sessionId, entries: this.getEntries() };\n\t\t\tconst manager = new SessionManager(store, cwd, directory, { ...options, parentSession: source.sessionId });\n\t\t\tconst hashes = sessionBlobHashes(source.store, source.entries);\n\t\t\tassertSessionBlobStore(store, manager.sessionId, hashes.length);\n\t\t\tmanager.fileEntries.push(...source.entries);\n\t\t\tawait manager.initialize();\n\t\t\tawait copySessionBlobs(source.store, source.sessionId, store, manager.sessionId, hashes);\n\t\t\tmanager._buildIndex();\n\t\t\treturn manager;\n\t\t});\n\t}\n\n\tstatic async importFromJsonl(\n\t\tinputPath: string,\n\t\tcwd: string,\n\t\tsessionDir?: string | SessionStore,\n\t): Promise<SessionManager> {\n\t\tconst store =\n\t\t\ttypeof sessionDir === \"string\"\n\t\t\t\t? await JsonlSessionStore.open(sessionDir, { exactDirectory: true, scanExisting: false })\n\t\t\t\t: (sessionDir ?? (await resolveSessionStore(cwd)));\n\t\treturn SessionManager.constructWithStore(store, store !== sessionDir, () =>\n\t\t\tnew SessionManager(\n\t\t\t\tstore,\n\t\t\t\tcwd,\n\t\t\t\tstore instanceof JsonlSessionStore ? store.descriptor.location : \"\",\n\t\t\t).importFromJsonl(inputPath),\n\t\t);\n\t}\n\tprivate static async constructWithStore(\n\t\tstore: SessionStore,\n\t\towned: boolean,\n\t\tconstruct: () => Promise<SessionManager>,\n\t): Promise<SessionManager> {\n\t\ttry {\n\t\t\treturn await construct();\n\t\t} catch (error) {\n\t\t\tif (owned) {\n\t\t\t\ttry {\n\t\t\t\t\tawait store.close();\n\t\t\t\t} catch (cause) {\n\t\t\t\t\tthrow new StorageRollbackError(error as StorageFailureCause, cause as StorageFailureCause);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tstatic async create(cwd: string, sessionDir?: string, options?: NewSessionOptions): Promise<SessionManager>;\n\tstatic async create(store: SessionStore, cwd: string, options?: NewSessionOptions): Promise<SessionManager>;\n\tstatic async create(\n\t\tcwdOrStore: string | SessionStore,\n\t\tdirectoryOrCwd?: string,\n\t\toptions?: NewSessionOptions,\n\t): Promise<SessionManager> {\n\t\tconst cwd = typeof cwdOrStore === \"string\" ? cwdOrStore : (directoryOrCwd ?? process.cwd());\n\t\tif (typeof cwdOrStore === \"string\" && directoryOrCwd === undefined) {\n\t\t\tconst store = await resolveSessionStore(cwd);\n\t\t\treturn SessionManager.constructWithStore(store, true, () => SessionManager.create(store, cwd, options));\n\t\t}\n\t\tconst directory =\n\t\t\ttypeof cwdOrStore === \"string\"\n\t\t\t\t? directoryOrCwd\n\t\t\t\t\t? normalizePath(directoryOrCwd)\n\t\t\t\t\t: getDefaultSessionDirPath(cwd)\n\t\t\t\t: cwdOrStore instanceof JsonlSessionStore\n\t\t\t\t\t? cwdOrStore.descriptor.location\n\t\t\t\t\t: \"\";\n\t\tconst store =\n\t\t\ttypeof cwdOrStore === \"string\"\n\t\t\t\t? await JsonlSessionStore.open(directory, { exactDirectory: true, scanExisting: false })\n\t\t\t\t: cwdOrStore;\n\t\treturn SessionManager.constructWithStore(store, store !== cwdOrStore, async () => {\n\t\t\tconst manager = new SessionManager(store, cwd, directory, options);\n\t\t\tif (typeof cwdOrStore !== \"string\" && store instanceof JsonlSessionStore) {\n\t\t\t\tmanager.sessionFile = store.locationFor(manager.recordHeader());\n\t\t\t\tmanager.sessionDir = dirname(manager.sessionFile);\n\t\t\t}\n\t\t\tawait manager.initialize();\n\t\t\treturn manager;\n\t\t});\n\t}\n\n\tstatic async open(path: string, sessionDir?: string, cwdOverride?: string): Promise<SessionManager>;\n\tstatic async open(store: SessionStore, sessionId: string, cwdOverride?: string): Promise<SessionManager>;\n\tstatic async open(\n\t\tpathOrStore: string | SessionStore,\n\t\tdirectoryOrId?: string,\n\t\tcwdOverride?: string,\n\t): Promise<SessionManager> {\n\t\tif (typeof pathOrStore !== \"string\") {\n\t\t\tconst snapshot = await pathOrStore.load(directoryOrId!);\n\t\t\tif (snapshot.header.id !== directoryOrId) throw new SessionIdMismatchError(directoryOrId!, snapshot.header.id);\n\t\t\tconst manager = new SessionManager(\n\t\t\t\tpathOrStore,\n\t\t\t\tcwdOverride ?? snapshot.header.cwd,\n\t\t\t\tpathOrStore instanceof JsonlSessionStore ? pathOrStore.descriptor.location : \"\",\n\t\t\t);\n\t\t\tmanager.restore(\n\t\t\t\tsnapshot,\n\t\t\t\tpathOrStore instanceof JsonlSessionStore ? await pathOrStore.findFile(directoryOrId!) : undefined,\n\t\t\t);\n\t\t\tif (manager.sessionFile) manager.sessionDir = dirname(manager.sessionFile);\n\t\t\treturn manager;\n\t\t}\n\t\tconst path = resolvePath(pathOrStore);\n\t\tconst directory = directoryOrId ?? dirname(path);\n\t\tconst store = await JsonlSessionStore.open(dirname(path), { exactDirectory: true, scanExisting: false });\n\t\tlet snapshot: SessionSnapshot;\n\t\ttry {\n\t\t\tsnapshot = await store.loadFile(path);\n\t\t} catch (error) {\n\t\t\tif (!(error instanceof StorageUnavailableError) || (error.cause as NodeJS.ErrnoException).code !== \"ENOENT\")\n\t\t\t\tthrow error;\n\t\t\tconst manager = new SessionManager(store, cwdOverride ?? process.cwd(), directory);\n\t\t\tmanager.lastSeq = (await store.create(manager.recordHeader(), [], path)).lastSeq;\n\t\t\tmanager.sessionFile = path;\n\t\t\treturn manager;\n\t\t}\n\t\tconst manager = new SessionManager(store, cwdOverride ?? snapshot.header.cwd, directory);\n\t\tmanager.restore(snapshot, path);\n\t\treturn manager;\n\t}\n\n\tstatic async continueRecent(\n\t\tcwd: string,\n\t\tsessionDir?: string,\n\t\toptions?: { includeInternal?: boolean },\n\t): Promise<SessionManager>;\n\tstatic async continueRecent(\n\t\tstore: SessionStore,\n\t\tcwd: string,\n\t\toptions?: { includeInternal?: boolean },\n\t): Promise<SessionManager>;\n\tstatic async continueRecent(\n\t\tcwdOrStore: string | SessionStore,\n\t\tdirectoryOrCwd?: string,\n\t\toptions?: { includeInternal?: boolean },\n\t): Promise<SessionManager> {\n\t\tconst cwd = typeof cwdOrStore === \"string\" ? cwdOrStore : directoryOrCwd!;\n\t\tif (typeof cwdOrStore === \"string\" && directoryOrCwd === undefined) {\n\t\t\tconst store = await resolveSessionStore(cwd);\n\t\t\treturn SessionManager.constructWithStore(store, true, () =>\n\t\t\t\tSessionManager.continueRecent(store, cwd, options),\n\t\t\t);\n\t\t}\n\t\tconst directory = typeof cwdOrStore === \"string\" ? (directoryOrCwd ?? getDefaultSessionDirPath(cwd)) : \"\";\n\t\tconst store =\n\t\t\ttypeof cwdOrStore === \"string\"\n\t\t\t\t? await JsonlSessionStore.open(directory, { exactDirectory: true, scanExisting: false })\n\t\t\t\t: cwdOrStore;\n\t\treturn SessionManager.constructWithStore(store, store !== cwdOrStore, async () => {\n\t\t\tconst recent = await store.findMostRecent({\n\t\t\t\tcwd: resolvePath(cwd),\n\t\t\t\tincludeInternal: options?.includeInternal,\n\t\t\t});\n\t\t\tconst manager = new SessionManager(store, cwd, directory);\n\t\t\tif (recent) manager.restore(await store.load(recent.id), recent.location);\n\t\t\telse await manager.initialize();\n\t\t\treturn manager;\n\t\t});\n\t}\n\n\tstatic inMemory(cwd: string = process.cwd(), options?: NewSessionOptions, entries?: FileEntry[]): SessionManager {\n\t\tconst manager = new SessionManager(\n\t\t\tmarkPrivateMemorySessionStore(new MemorySessionStore(createSessionCwdMatcher)),\n\t\t\tcwd,\n\t\t\t\"\",\n\t\t\toptions,\n\t\t);\n\t\tif (entries?.length) {\n\t\t\tmanager.fileEntries = entries[0].type === \"session\" ? entries : [...manager.fileEntries, ...entries];\n\t\t\tmanager.sessionId = manager.getHeader()!.id;\n\t\t\tmanager._buildIndex();\n\t\t}\n\t\tmanager.mutation = manager.initialize();\n\t\treturn manager;\n\t}\n\n\tstatic async forkFrom(\n\t\tsourcePath: string,\n\t\ttargetCwd: string,\n\t\tsessionDir?: string | SessionStore,\n\t\toptions?: NewSessionOptions,\n\t): Promise<SessionManager> {\n\t\tconst sourceStore = await JsonlSessionStore.open(dirname(resolvePath(sourcePath)), {\n\t\t\texactDirectory: true,\n\t\t\tscanExisting: false,\n\t\t});\n\t\tlet source: SessionSnapshot;\n\t\ttry {\n\t\t\tsource = await sourceStore.loadFile(resolvePath(sourcePath));\n\t\t} finally {\n\t\t\tawait sourceStore.close();\n\t\t}\n\t\tconst { entries, blobs } = takeInlineToolOutput(source.entries, source.header.id);\n\t\tconst store =\n\t\t\ttypeof sessionDir === \"string\"\n\t\t\t\t? await JsonlSessionStore.open(sessionDir, { exactDirectory: true, scanExisting: false })\n\t\t\t\t: (sessionDir ?? (await resolveSessionStore(targetCwd)));\n\t\tconst directory =\n\t\t\ttypeof sessionDir === \"string\"\n\t\t\t\t? sessionDir\n\t\t\t\t: sessionDir instanceof JsonlSessionStore\n\t\t\t\t\t? sessionDir.descriptor.location\n\t\t\t\t\t: \"\";\n\t\treturn SessionManager.constructWithStore(store, store !== sessionDir, async () => {\n\t\t\tconst manager = new SessionManager(store, targetCwd, directory, {\n\t\t\t\t...options,\n\t\t\t\tparentSession: source.header.id,\n\t\t\t});\n\t\t\tassertSessionBlobStore(store, manager.sessionId, blobs.length);\n\t\t\tmanager.fileEntries.push(...entries);\n\t\t\tawait manager.initialize();\n\t\t\tawait storeSessionBlobs(store, manager.sessionId, blobs);\n\t\t\tmanager._buildIndex();\n\t\t\treturn manager;\n\t\t});\n\t}\n\n\tstatic async findById(cwd: string, id: string, sessionDir?: string): Promise<string | undefined> {\n\t\tconst store =\n\t\t\tsessionDir === undefined\n\t\t\t\t? await resolveSessionStore(cwd)\n\t\t\t\t: await JsonlSessionStore.open(sessionDir, { exactDirectory: true, scanExisting: false });\n\t\ttry {\n\t\t\tconst header = await store.readHeader(id);\n\t\t\tif (\n\t\t\t\t!header ||\n\t\t\t\tclassifiedWorkflowMetadata(header) ||\n\t\t\t\t!createSessionCwdMatcher(resolvePath(cwd))(resolvePath(header.cwd))\n\t\t\t)\n\t\t\t\treturn undefined;\n\t\t\treturn store instanceof JsonlSessionStore ? await store.findFile(id) : id;\n\t\t} catch (error) {\n\t\t\tif (error instanceof SessionFormatVersionError) return undefined;\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tawait store.close();\n\t\t}\n\t}\n\n\tstatic async list(\n\t\tcwd: string,\n\t\tsessionDir?: string | SessionStore,\n\t\tonProgress?: SessionListProgress,\n\t\toptions?: { includeInternal?: boolean; signal?: AbortSignal } | AbortSignal,\n\t): Promise<SessionInfo[]> {\n\t\tconst signal = options && \"aborted\" in options ? options : options?.signal;\n\t\tif (typeof sessionDir !== \"string\") {\n\t\t\tconst store = sessionDir ?? (await resolveSessionStore(cwd));\n\t\t\ttry {\n\t\t\t\treturn await listSessionStore(\n\t\t\t\t\tstore,\n\t\t\t\t\t{\n\t\t\t\t\t\tcwd: resolvePath(cwd),\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\tincludeInternal:\n\t\t\t\t\t\t\toptions !== undefined && \"includeInternal\" in options && options.includeInternal === true,\n\t\t\t\t\t},\n\t\t\t\t\tonProgress,\n\t\t\t\t);\n\t\t\t} finally {\n\t\t\t\tif (sessionDir === undefined) await store.close();\n\t\t\t}\n\t\t}\n\t\treturn listProjectSessions(\n\t\t\tcwd,\n\t\t\tsessionDir,\n\t\t\tonProgress,\n\t\t\toptions !== undefined && \"includeInternal\" in options && options.includeInternal === true,\n\t\t\tsignal,\n\t\t);\n\t}\n\n\tstatic async listAll(onProgress?: SessionListProgress, signal?: AbortSignal): Promise<SessionInfo[]>;\n\tstatic async listAll(\n\t\tsessionDir?: string | SessionStore,\n\t\tonProgress?: SessionListProgress,\n\t\toptions?: { includeInternal?: boolean; signal?: AbortSignal } | AbortSignal,\n\t): Promise<SessionInfo[]>;\n\tstatic async listAll(\n\t\tdirectoryOrProgress?: string | SessionStore | SessionListProgress,\n\t\tprogressOrSignal?: SessionListProgress | AbortSignal,\n\t\toptions?: { includeInternal?: boolean; signal?: AbortSignal } | AbortSignal,\n\t): Promise<SessionInfo[]> {\n\t\tif (typeof directoryOrProgress !== \"string\") {\n\t\t\tconst supplied = typeof directoryOrProgress === \"object\" ? directoryOrProgress : undefined;\n\t\t\tconst store = supplied ?? (await resolveSessionStore(process.cwd()));\n\t\t\ttry {\n\t\t\t\treturn await listSessionStore(\n\t\t\t\t\tstore,\n\t\t\t\t\t{\n\t\t\t\t\t\tincludeInternal:\n\t\t\t\t\t\t\toptions !== undefined && \"includeInternal\" in options && options.includeInternal === true,\n\t\t\t\t\t\tsignal:\n\t\t\t\t\t\t\toptions && \"aborted\" in options\n\t\t\t\t\t\t\t\t? options\n\t\t\t\t\t\t\t\t: (options?.signal ?? (typeof progressOrSignal === \"object\" ? progressOrSignal : undefined)),\n\t\t\t\t\t},\n\t\t\t\t\ttypeof directoryOrProgress === \"function\"\n\t\t\t\t\t\t? directoryOrProgress\n\t\t\t\t\t\t: typeof progressOrSignal === \"function\"\n\t\t\t\t\t\t\t? progressOrSignal\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t);\n\t\t\t} finally {\n\t\t\t\tif (!supplied) await store.close();\n\t\t\t}\n\t\t}\n\t\tconst { listAllSessions } = await import(\"./session-manager-list.ts\");\n\t\treturn listAllSessions(\n\t\t\tdirectoryOrProgress,\n\t\t\ttypeof progressOrSignal === \"function\" ? progressOrSignal : undefined,\n\t\t\toptions !== undefined && \"includeInternal\" in options && options.includeInternal === true,\n\t\t\toptions && \"aborted\" in options\n\t\t\t\t? options\n\t\t\t\t: (options?.signal ?? (typeof progressOrSignal === \"object\" ? progressOrSignal : undefined)),\n\t\t);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"session-manager-core.js","sourceRoot":"","sources":["../../src/core/session-manager-core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGpG,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AAC/G,OAAO,EACN,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,wBAAwB,EACxB,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EACzB,8BAA8B,EAC9B,2BAA2B,EAC3B,uBAAuB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACN,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,aAAa,GACb,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAmBtE,OAAO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7F,CAAC;IACH,CAAC;CACD","sourcesContent":["import { writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { getCurrentSystemMessage } from \"@bastani/pi-ai\";\nimport type { ImageContent, Message, TextContent, Usage } from \"@bastani/pi-ai/compat\";\nimport { getAgentDir } from \"../config.js\";\nimport { createSessionCwdMatcher, normalizePath, pathsEqual, resolvePath } from \"../utils/paths.ts\";\nimport type { VerbatimCompactionDetails } from \"./compaction/compaction-types.js\";\nimport type { BashExecutionMessage, CustomMessage } from \"./messages.ts\";\nimport { SessionHistoryIndex } from \"./session-history-index.ts\";\nimport { createBranchedSessionState } from \"./session-manager-archive.ts\";\nimport { classifiedWorkflowMetadata, validSessionWorkflowMetadata } from \"./session-manager-classification.ts\";\nimport {\n\tcreateBranchSummaryEntry,\n\tcreateCompactionEntry,\n\tcreateContextEditEntry,\n\tcreateCustomEntry,\n\tcreateCustomMessageEntry,\n\tcreateLabelEntry,\n\tcreateMessageEntry,\n\tcreateModelChangeEntry,\n\tcreateSessionFilePath,\n\tcreateSessionHeader,\n\tcreateSessionInfoEntry,\n\tcreateSessionSummaryEntry,\n\tcreateThinkingLevelChangeEntry,\n\tcreateWorktreeSnapshotEntry,\n\tgetEntriesWithoutHeader,\n} from \"./session-manager-entries.ts\";\nimport { SessionEntryError } from \"./session-manager-errors.js\";\nimport {\n\tbuildContextEntries,\n\tbuildSessionIndex,\n\tbuildSessionProjection,\n\tbuildSessionTree,\n\tgetBranchPath,\n} from \"./session-manager-history.ts\";\nimport { listProjectSessions } from \"./session-manager-list.ts\";\nimport { getDefaultSessionDirPath } from \"./session-manager-paths.ts\";\nimport type {\n\tBranchSummaryEntry,\n\tContextEditEntry,\n\tFileEntry,\n\tModelFallbackRecord,\n\tNewSessionOptions,\n\tSessionContext,\n\tSessionEntry,\n\tSessionHeader,\n\tSessionInfo,\n\tSessionListProgress,\n\tSessionNameState,\n\tSessionProjection,\n\tSessionTreeNode,\n\tSessionWorkflowMetadata,\n\tUsageEntry,\n\tWorktreeRestoreHostWarning,\n} from \"./session-manager-types.ts\";\nimport {\n\tassertValidSessionId,\n\tcreateSessionId,\n\tgenerateId,\n\tvalidateSessionFileEntries,\n} from \"./session-manager-validation.ts\";\nimport { listSessionStore } from \"./session-store-list.js\";\nimport {\n\tassertSessionBlobStore,\n\tcopySessionBlobs,\n\tsessionBlobHashes,\n\tstoreSessionBlobs,\n\tTOOL_OUTPUT_ENTRY_TYPE,\n\ttype ToolOutputReference,\n\ttakeInlineToolOutput,\n} from \"./session-tool-output.ts\";\nimport { adoptInlineSnapshotBlobs } from \"./session-worktree-snapshots.ts\";\nimport { SessionBlobError, type StorageFailureCause, StorageRollbackError } from \"./storage/errors.js\";\nimport {\n\tSessionFormatVersionError,\n\tSessionIdMismatchError,\n\ttype SessionJsonValue,\n\tSessionNotFoundError,\n\tStorageUnavailableError,\n} from \"./storage/session/errors.js\";\nimport { JsonlSessionStore } from \"./storage/session/jsonl-session-store.js\";\nimport { MemorySessionStore, markPrivateMemorySessionStore } from \"./storage/session/memory-session-store.js\";\nimport type { SessionBlob, SessionRecordHeader, SessionSnapshot, SessionStore } from \"./storage/session/types.js\";\nimport { WorkspaceConfigError } from \"./worktree-snapshot/errors.ts\";\nimport type { WorktreeRootMapping, WorktreeSnapshot } from \"./worktree-snapshot/types.ts\";\n\nasync function resolveSessionStore(cwd: string): Promise<SessionStore> {\n\t// Selection loads settings and tools, which depend on the completed session module.\n\treturn (await import(\"./session-storage.js\")).resolveSessionStore(cwd);\n}\n\n/** An in-memory session tree whose mutations await the backing store. */\nexport class SessionManager {\n\tprivate sessionId = \"\";\n\tprivate sessionFile: string | undefined;\n\tprivate sessionDir: string;\n\tprivate cwd: string;\n\tprivate store: SessionStore;\n\tprivate lastSeq = 0;\n\tprivate mutation: Promise<void> = Promise.resolve();\n\tprivate fileEntries: FileEntry[] = [];\n\tprivate byId: Map<string, SessionEntry> = new Map();\n\tprivate labelsById: Map<string, string> = new Map();\n\tprivate labelTimestampsById: Map<string, string> = new Map();\n\tprivate leafId: string | null = null;\n\tprivate readonly historyIndex = new SessionHistoryIndex();\n\n\tprivate constructor(store: SessionStore, cwd: string, sessionDir: string, options?: NewSessionOptions) {\n\t\tthis.store = store;\n\t\tthis.cwd = resolvePath(cwd);\n\t\tthis.sessionDir = normalizePath(sessionDir);\n\t\tthis.start(options);\n\t}\n\n\tprivate runMutation<T>(operation: () => Promise<T>): Promise<T> {\n\t\tconst result = this.mutation.then(operation);\n\t\tthis.mutation = result.then(\n\t\t\t() => {},\n\t\t\t() => {},\n\t\t);\n\t\treturn result;\n\t}\n\n\tprivate recordHeader(header = this.getHeader()!): SessionRecordHeader {\n\t\tconst { type: _type, ...record } = header;\n\t\treturn record;\n\t}\n\n\tprivate restore(snapshot: SessionSnapshot, location?: string): void {\n\t\tconst header = snapshot.header;\n\t\tthis.fileEntries = [{ type: \"session\", ...header }, ...snapshot.entries];\n\t\tthis.sessionId = header.id;\n\t\tthis.lastSeq = snapshot.lastSeq;\n\t\tthis.sessionFile =\n\t\t\tlocation ?? (this.store instanceof JsonlSessionStore ? this.store.locationFor(header) : undefined);\n\t\tthis._buildIndex();\n\t}\n\n\tprivate start(options?: NewSessionOptions): string | undefined {\n\t\tif (options?.id !== undefined) assertValidSessionId(options.id);\n\t\tthis.sessionId = options?.id ?? createSessionId();\n\t\tthis.fileEntries = [\n\t\t\tcreateSessionHeader(\n\t\t\t\tthis.sessionId,\n\t\t\t\tthis.cwd,\n\t\t\t\tnew Date().toISOString(),\n\t\t\t\toptions?.parentSession,\n\t\t\t\toptions?.internal,\n\t\t\t\toptions?.workflow,\n\t\t\t),\n\t\t];\n\t\tthis.lastSeq = 0;\n\t\tthis._buildIndex();\n\t\tthis.sessionFile =\n\t\t\tthis.store instanceof JsonlSessionStore\n\t\t\t\t? this.sessionDir\n\t\t\t\t\t? createSessionFilePath(this.sessionDir, this.getHeader()!.createdAt, this.sessionId)\n\t\t\t\t\t: this.store.locationFor(this.recordHeader())\n\t\t\t\t: undefined;\n\t\treturn this.sessionFile;\n\t}\n\n\tsetSessionFile(sessionFile: string): Promise<void> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst opened = await SessionManager.open(sessionFile, this.sessionDir, this.cwd);\n\t\t\tthis.store = opened.store;\n\t\t\tthis.restore(\n\t\t\t\t{ header: opened.recordHeader(), entries: opened.getEntries(), lastSeq: opened.lastSeq },\n\t\t\t\topened.sessionFile,\n\t\t\t);\n\t\t});\n\t}\n\n\tprivate async initialize(): Promise<void> {\n\t\tthis.lastSeq = (\n\t\t\tawait (this.store instanceof JsonlSessionStore\n\t\t\t\t? this.store.create(this.recordHeader(), this.getEntries(), this.sessionFile)\n\t\t\t\t: this.store.create(this.recordHeader(), this.getEntries()))\n\t\t).lastSeq;\n\t}\n\n\tprivate async storeForNewSession(): Promise<SessionStore> {\n\t\tif (\n\t\t\tthis.store instanceof JsonlSessionStore &&\n\t\t\tthis.sessionDir &&\n\t\t\tthis.store.descriptor.location !== resolvePath(this.sessionDir)\n\t\t) {\n\t\t\treturn JsonlSessionStore.open(this.sessionDir, { exactDirectory: true, scanExisting: false });\n\t\t}\n\t\treturn this.store;\n\t}\n\n\tnewSession(options?: NewSessionOptions): Promise<string | undefined> {\n\t\treturn this.runMutation(async () => {\n\t\t\tif (options?.id !== undefined) assertValidSessionId(options.id);\n\t\t\tconst header = createSessionHeader(\n\t\t\t\toptions?.id ?? createSessionId(),\n\t\t\t\tthis.cwd,\n\t\t\t\tnew Date().toISOString(),\n\t\t\t\toptions?.parentSession,\n\t\t\t\toptions?.internal,\n\t\t\t\toptions?.workflow,\n\t\t\t);\n\t\t\tconst record = this.recordHeader(header);\n\t\t\tconst store = await this.storeForNewSession();\n\t\t\tconst location =\n\t\t\t\tstore instanceof JsonlSessionStore\n\t\t\t\t\t? this.sessionDir\n\t\t\t\t\t\t? createSessionFilePath(this.sessionDir, record.createdAt, record.id)\n\t\t\t\t\t\t: store.locationFor(record)\n\t\t\t\t\t: undefined;\n\t\t\tconst result = await (store instanceof JsonlSessionStore\n\t\t\t\t? store.create(record, [], location)\n\t\t\t\t: store.create(record, []));\n\t\t\tthis.store = store;\n\t\t\tthis.byId.clear();\n\t\t\tthis.labelsById.clear();\n\t\t\tthis.labelTimestampsById.clear();\n\t\t\tthis.restore({ header: record, entries: [], lastSeq: result.lastSeq }, location);\n\t\t\treturn this.sessionFile;\n\t\t});\n\t}\n\n\tmarkSessionInternal(workflow?: SessionWorkflowMetadata): Promise<void> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst previous = this.getHeader()!;\n\t\t\tif (classifiedWorkflowMetadata(previous)) return;\n\t\t\tconst validWorkflow = validSessionWorkflowMetadata(workflow);\n\t\t\tif (!validWorkflow) return;\n\t\t\tconst header: SessionHeader = { ...previous, internal: true, workflow: validWorkflow };\n\t\t\tconst result = await this.store.replace(this.sessionId, this.recordHeader(header), this.getEntries(), {\n\t\t\t\texpectSeq: this.lastSeq,\n\t\t\t});\n\t\t\tthis.lastSeq = result.lastSeq;\n\t\t\tthis.fileEntries[0] = header;\n\t\t});\n\t}\n\n\tprivate _buildIndex(): void {\n\t\tvalidateSessionFileEntries(this.fileEntries, this.sessionFile ?? \"in-memory session\");\n\t\tconst index = buildSessionIndex(this.fileEntries);\n\t\tthis.byId = index.byId;\n\t\tthis.labelsById = index.labelsById;\n\t\tthis.labelTimestampsById = index.labelTimestampsById;\n\t\tthis.leafId = index.leafId;\n\t}\n\n\tisPersisted(): boolean {\n\t\treturn !(this.store instanceof MemorySessionStore);\n\t}\n\n\tgetCwd(): string {\n\t\treturn this.cwd;\n\t}\n\n\tgetSessionDir(): string {\n\t\treturn this.sessionDir;\n\t}\n\n\tusesDefaultSessionDir(): boolean {\n\t\treturn pathsEqual(this.sessionDir, getDefaultSessionDirPath(this.cwd));\n\t}\n\n\tgetSessionId(): string {\n\t\treturn this.sessionId;\n\t}\n\n\tgetSessionFile(): string | undefined {\n\t\treturn this.sessionFile;\n\t}\n\n\tgetSessionStore(): SessionStore {\n\t\treturn this.store;\n\t}\n\n\tasync deleteSession(sessionId: string): Promise<void> {\n\t\tassertValidSessionId(sessionId);\n\t\tif (sessionId === this.sessionId) {\n\t\t\tthrow new Error(`Cannot delete the session that is currently open: ${sessionId}`);\n\t\t}\n\t\ttry {\n\t\t\tawait this.store.delete(sessionId);\n\t\t} catch (error) {\n\t\t\tif (!(error instanceof SessionNotFoundError)) throw error;\n\t\t}\n\t}\n\n\t/** @internal Finalize provisional startup storage after project trust resolves. */\n\trebindStore(store: SessionStore, removeProvisionalRecord: boolean): Promise<void> {\n\t\treturn this.runMutation(async () => {\n\t\t\tif (store === this.store) return;\n\t\t\tconst header = this.recordHeader();\n\t\t\tconst entries = this.getEntries();\n\t\t\tconst hashes = sessionBlobHashes(this.store, entries);\n\t\t\tassertSessionBlobStore(store, this.sessionId, hashes.length);\n\t\t\tconst result = await store.create(header, entries);\n\t\t\tawait copySessionBlobs(this.store, this.sessionId, store, this.sessionId, hashes);\n\t\t\tif (removeProvisionalRecord) await this.store.delete(this.sessionId);\n\t\t\tthis.store = store;\n\t\t\tthis.sessionDir = store instanceof JsonlSessionStore ? store.descriptor.location : \"\";\n\t\t\tthis.restore({ header, entries, lastSeq: result.lastSeq });\n\t\t});\n\t}\n\n\tasync openSessionById(sessionId: string, cwdOverride?: string, sessionDirectory?: string): Promise<SessionManager> {\n\t\tlet store =\n\t\t\tsessionDirectory === undefined\n\t\t\t\t? this.store\n\t\t\t\t: await JsonlSessionStore.open(sessionDirectory, { exactDirectory: true, scanExisting: false });\n\t\tlet snapshot: SessionSnapshot;\n\t\ttry {\n\t\t\tsnapshot = await store.load(sessionId);\n\t\t} catch (error) {\n\t\t\tif (\n\t\t\t\t!(error instanceof SessionNotFoundError) ||\n\t\t\t\tsessionDirectory !== undefined ||\n\t\t\t\t!this.usesDefaultSessionDir()\n\t\t\t)\n\t\t\t\tthrow error;\n\t\t\tstore = await JsonlSessionStore.open(join(getAgentDir(), \"sessions\"), { scanExisting: false });\n\t\t\tsnapshot = await store.load(sessionId);\n\t\t}\n\t\tconst location = store instanceof JsonlSessionStore ? await store.findFile(sessionId) : undefined;\n\t\tif (location !== undefined) {\n\t\t\tstore = await JsonlSessionStore.open(dirname(location), { exactDirectory: true, scanExisting: false });\n\t\t\tsnapshot = await store.load(sessionId);\n\t\t}\n\t\tif (snapshot.header.id !== sessionId) throw new SessionIdMismatchError(sessionId, snapshot.header.id);\n\t\tconst manager = new SessionManager(store, cwdOverride ?? snapshot.header.cwd, this.sessionDir);\n\t\tmanager.restore(snapshot, location);\n\t\tif (location !== undefined) manager.sessionDir = dirname(location);\n\t\treturn manager;\n\t}\n\n\tasync importFromJsonl(inputPath: string, cwdOverride?: string): Promise<SessionManager> {\n\t\tconst source = await JsonlSessionStore.open(dirname(resolvePath(inputPath)), {\n\t\t\texactDirectory: true,\n\t\t\tscanExisting: false,\n\t\t});\n\t\ttry {\n\t\t\tconst loaded = await source.loadFile(inputPath);\n\t\t\tconst { entries, blobs } = takeInlineToolOutput(loaded.entries, loaded.header.id);\n\t\t\tassertSessionBlobStore(this.store, loaded.header.id, blobs.length);\n\t\t\tconst snapshot = {\n\t\t\t\t...loaded,\n\t\t\t\tentries: await adoptInlineSnapshotBlobs(entries, this.store.snapshotBlobs),\n\t\t\t};\n\t\t\tconst manager = new SessionManager(this.store, cwdOverride ?? snapshot.header.cwd, this.sessionDir);\n\t\t\tmanager.restore(snapshot);\n\t\t\tawait manager.initialize();\n\t\t\tawait storeSessionBlobs(this.store, snapshot.header.id, blobs);\n\t\t\treturn manager;\n\t\t} finally {\n\t\t\tawait source.close();\n\t\t}\n\t}\n\n\tprivate _appendEntry(entry: SessionEntry): Promise<void> {\n\t\treturn this._appendEntries([entry]);\n\t}\n\n\tprivate async _appendEntries(entries: readonly SessionEntry[]): Promise<void> {\n\t\tconst result = await this.store.append(this.sessionId, entries, { expectSeq: this.lastSeq });\n\t\tthis.lastSeq = result.lastSeq;\n\t\tfor (const entry of entries) {\n\t\t\tthis.fileEntries.push(entry);\n\t\t\tthis.byId.set(entry.id, entry);\n\t\t\tthis.historyIndex.appended(entry, this.byId);\n\t\t\tthis.leafId = entry.id;\n\t\t}\n\t}\n\n\t/**\n\t * @internal Record the model and thinking level a new session starts on with one store write, as a model change\n\t * followed by a thinking level change.\n\t */\n\tappendStartState(\n\t\tmodel: { readonly provider: string; readonly modelId: string } | undefined,\n\t\tthinkingLevel: string,\n\t): Promise<void> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst modelEntry =\n\t\t\t\tmodel === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: createModelChangeEntry(model.provider, model.modelId, this.byId, this.leafId);\n\t\t\tconst thinkingEntry = createThinkingLevelChangeEntry(\n\t\t\t\tthinkingLevel,\n\t\t\t\t{ has: (id) => id === modelEntry?.id || this.byId.has(id) },\n\t\t\t\tmodelEntry?.id ?? this.leafId,\n\t\t\t);\n\t\t\tawait this._appendEntries(modelEntry === undefined ? [thinkingEntry] : [modelEntry, thinkingEntry]);\n\t\t});\n\t}\n\n\t/** Append a message as child of current leaf, then advance leaf. Returns entry id. */\n\tappendMessage(message: Message | CustomMessage | BashExecutionMessage): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst entry = createMessageEntry(message, this.byId, this.leafId);\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\n\t/** Append a thinking level change as child of current leaf, then advance leaf. Returns entry id. */\n\tappendThinkingLevelChange(thinkingLevel: string): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst entry = createThinkingLevelChangeEntry(thinkingLevel, this.byId, this.leafId);\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\n\t/** Record auxiliary model usage without adding it to the LLM context. */\n\tappendUsage(kind: string, provider: string, model: string, usage: Usage, note?: string): Promise<UsageEntry> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst entry: UsageEntry = {\n\t\t\t\ttype: \"usage\",\n\t\t\t\tid: generateId(this.byId),\n\t\t\t\tparentId: this.leafId,\n\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\tkind,\n\t\t\t\tprovider,\n\t\t\t\tmodel,\n\t\t\t\tusage,\n\t\t\t\t...(note === undefined ? {} : { note }),\n\t\t\t};\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry;\n\t\t});\n\t}\n\n\t/**\n\t * Append a model change as child of current leaf, then advance leaf. Returns entry id. `fallback` records why a model\n\t * fallback made the change.\n\t */\n\tappendModelChange(provider: string, modelId: string, fallback?: ModelFallbackRecord): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst entry = createModelChangeEntry(provider, modelId, this.byId, this.leafId, fallback);\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\tappendCompaction(\n\t\tcompactedText: string,\n\t\tfirstKeptEntryId: string | null,\n\t\ttokensBefore: number,\n\t\tdetails: VerbatimCompactionDetails,\n\t\tusage?: Usage,\n\t\tcoveredThroughEntryId?: string,\n\t\tprecondition?: () => void,\n\t): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tprecondition?.();\n\t\t\tif (firstKeptEntryId !== null && !this.byId.has(firstKeptEntryId))\n\t\t\t\tthrow new SessionEntryError(firstKeptEntryId, \"missing\");\n\t\t\tif (coveredThroughEntryId !== undefined && !this.byId.has(coveredThroughEntryId))\n\t\t\t\tthrow new SessionEntryError(coveredThroughEntryId, \"missing\");\n\t\t\tconst entry = createCompactionEntry(\n\t\t\t\tcompactedText,\n\t\t\t\tfirstKeptEntryId,\n\t\t\t\ttokensBefore,\n\t\t\t\tdetails,\n\t\t\t\tusage,\n\t\t\t\tthis.byId,\n\t\t\t\tthis.leafId,\n\t\t\t\tcoveredThroughEntryId,\n\t\t\t);\n\t\t\tconst systemMessage = getCurrentSystemMessage(this.buildSessionProjection().messages);\n\t\t\tif (systemMessage) entry.systemMessage = { ...systemMessage, timestamp: new Date(entry.timestamp).getTime() };\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\n\t/** Save a JSONL backup; database-backed sessions have no file snapshot. */\n\twriteBackupSnapshot(label = \"compact\"): Promise<string | undefined> {\n\t\treturn this.runMutation(async () => {\n\t\t\tif (!(this.store instanceof JsonlSessionStore) || !this.sessionFile) return undefined;\n\t\t\tconst path = `${this.sessionFile}.${new Date().toISOString().replace(/[:.]/g, \"-\")}.${label.replace(/[^a-z0-9_-]/gi, \"-\") || \"backup\"}.bak`;\n\t\t\ttry {\n\t\t\t\tawait writeFile(\n\t\t\t\t\tpath,\n\t\t\t\t\t`${[JSON.stringify({ type: \"session\", ...this.recordHeader() }), ...this.getEntries().map((entry) => JSON.stringify(entry))].join(\"\\n\")}\\n`,\n\t\t\t\t);\n\t\t\t} catch (cause) {\n\t\t\t\tthrow new StorageUnavailableError(this.store.descriptor, cause as Error);\n\t\t\t}\n\t\t\treturn path;\n\t\t});\n\t}\n\n\t/** Append a branch-local edit to an earlier model-visible entry. */\n\tappendContextEdit(targetId: string, replacement: ContextEditEntry[\"replacement\"]): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tif (\n\t\t\t\treplacement !== null &&\n\t\t\t\t(typeof replacement !== \"object\" ||\n\t\t\t\t\t!(\"content\" in replacement) ||\n\t\t\t\t\t(typeof replacement.content !== \"string\" && !Array.isArray(replacement.content)))\n\t\t\t) {\n\t\t\t\tthrow new SessionEntryError(targetId, \"invalid-replacement\");\n\t\t\t}\n\t\t\tconst target = this.byId.get(targetId);\n\t\t\tif (!target) throw new SessionEntryError(targetId, \"missing\");\n\t\t\tif (!this.getBranch().some((entry) => entry.id === targetId)) {\n\t\t\t\tthrow new SessionEntryError(targetId, \"inactive\");\n\t\t\t}\n\t\t\tconst editable =\n\t\t\t\ttarget.type === \"custom_message\" ||\n\t\t\t\t(target.type === \"message\" &&\n\t\t\t\t\t(target.message.role === \"user\" ||\n\t\t\t\t\t\ttarget.message.role === \"assistant\" ||\n\t\t\t\t\t\ttarget.message.role === \"toolResult\"));\n\t\t\tif (!editable) throw new SessionEntryError(targetId, \"not-editable\");\n\t\t\tconst targetRole = target.type === \"message\" ? target.message.role : \"custom\";\n\t\t\tconst normalizedReplacement =\n\t\t\t\treplacement !== null &&\n\t\t\t\t(targetRole === \"assistant\" || targetRole === \"toolResult\") &&\n\t\t\t\ttypeof replacement.content === \"string\"\n\t\t\t\t\t? { content: [{ type: \"text\" as const, text: replacement.content }] }\n\t\t\t\t\t: replacement;\n\t\t\tconst entry = createContextEditEntry(targetId, normalizedReplacement, this.byId, this.leafId);\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\n\t/** Append a custom entry (for extensions) as child of current leaf, then advance leaf. Returns entry id. */\n\tappendCustomEntry<T = SessionJsonValue>(customType: string, data?: T): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst entry = createCustomEntry(customType, data, this.byId, this.leafId);\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\n\t/**\n\t * @internal Stores `data` as a blob of the current session and appends the entry that references it, as one\n\t * mutation, so a session change cannot come between the two. The blob goes first: a process that stops in between\n\t * leaves only a blob of this session. Rejects with `blobs-unsupported` when the store holds no blobs.\n\t */\n\tappendToolOutputBlob(toolCallId: string, data: Uint8Array): Promise<SessionBlob> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst { putBlob } = this.store;\n\t\t\tif (putBlob === undefined) {\n\t\t\t\tthrow new SessionBlobError(\"blobs-unsupported\", {\n\t\t\t\t\tsessionId: this.sessionId,\n\t\t\t\t\tadapter: this.store.descriptor.adapter,\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst blob = await putBlob.call(this.store, this.sessionId, data);\n\t\t\tconst reference: ToolOutputReference = { toolCallId, hash: blob.hash, bytes: blob.bytes };\n\t\t\tawait this._appendEntry(createCustomEntry(TOOL_OUTPUT_ENTRY_TYPE, reference, this.byId, this.leafId));\n\t\t\treturn blob;\n\t\t});\n\t}\n\n\t/**\n\t * Record a checkout's snapshot at the current leaf. Pass the snapshot when it is new; omit it to refer to an earlier\n\t * entry's snapshot with the same id (an unchanged capture). `restore` records that the snapshot was restored on\n\t * this host into `root`, and `restoreWarnings` what that restore reported beyond its snapshot record.\n\t */\n\tappendWorktreeSnapshot(\n\t\troot: string,\n\t\tsnapshotId: string,\n\t\tsnapshot?: WorktreeSnapshot,\n\t\trestore?: WorktreeRootMapping,\n\t\trestoreWarnings: readonly WorktreeRestoreHostWarning[] = [],\n\t): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tif (snapshot !== undefined && snapshot.id !== snapshotId) {\n\t\t\t\tthrow new WorkspaceConfigError(\"sdk\", \"snapshot\", \"a snapshot whose id is snapshotId\");\n\t\t\t}\n\t\t\tif (snapshot === undefined && !this.getWorktreeSnapshotRecords().has(snapshotId)) {\n\t\t\t\tthrow new WorkspaceConfigError(\"sdk\", \"snapshotId\", \"the id of a snapshot recorded in this session\");\n\t\t\t}\n\t\t\tif (restore !== undefined && (restore.to !== root || restore.snapshotId !== snapshotId)) {\n\t\t\t\tthrow new WorkspaceConfigError(\"sdk\", \"restore\", \"a mapping to root for snapshotId\");\n\t\t\t}\n\t\t\tif (restore === undefined && restoreWarnings.length > 0) {\n\t\t\t\tthrow new WorkspaceConfigError(\"sdk\", \"restoreWarnings\", \"warnings recorded together with their restore\");\n\t\t\t}\n\t\t\tconst entry = createWorktreeSnapshotEntry(\n\t\t\t\troot,\n\t\t\t\tsnapshotId,\n\t\t\t\tsnapshot,\n\t\t\t\trestore,\n\t\t\t\trestoreWarnings,\n\t\t\t\tthis.byId,\n\t\t\t\tthis.leafId,\n\t\t\t);\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\n\t/** Restores recorded on the active branch, oldest first: work recorded under `from` continues under `to`. */\n\tgetWorktreeRootMappings(): WorktreeRootMapping[] {\n\t\treturn this.historyIndex.worktreeRootMappings(this.leafId, this.byId);\n\t}\n\n\t/** Every snapshot record in the session, by id. */\n\tgetWorktreeSnapshotRecords(): Map<string, WorktreeSnapshot> {\n\t\treturn this.historyIndex.worktreeSnapshotRecords(this.fileEntries);\n\t}\n\n\t/** The latest snapshot of each checkout root on the active branch, keyed by the root it was last recorded under. */\n\tgetLatestWorktreeSnapshots(): Map<string, WorktreeSnapshot> {\n\t\tconst records = this.getWorktreeSnapshotRecords();\n\t\tconst latest = new Map<string, WorktreeSnapshot>();\n\t\tfor (const { root, snapshotId } of this.historyIndex.worktreeSnapshots(this.leafId, this.byId)) {\n\t\t\tconst snapshot = records.get(snapshotId);\n\t\t\tif (snapshot) latest.set(root, snapshot);\n\t\t}\n\t\treturn latest;\n\t}\n\n\t/** Append a session info entry (e.g., display name). Returns entry id. */\n\tappendSessionInfo(name: string): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst entry = createSessionInfoEntry(name, this.byId, this.leafId);\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\n\t/** Append a generated resume summary anchored to the message it describes. Returns entry id. */\n\tappendSessionSummary(summary: string, summarizedThroughId: string, usage?: Usage): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tif (!this.byId.has(summarizedThroughId)) throw new SessionEntryError(summarizedThroughId, \"missing\");\n\t\t\tconst entry = createSessionSummaryEntry(summary, summarizedThroughId, usage, this.byId, this.leafId);\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\n\t/** Get the current session name from the latest session_info entry, if any. */\n\tgetSessionName(): string | undefined {\n\t\treturn this.getSessionNameState().name;\n\t}\n\n\t/**\n\t * Get the session name state. `hasName` is true for a session that was named and\n\t * then cleared even though `name` is undefined; a never-named session reports\n\t * `hasName: false`. Read-side only: the JSONL already records the distinction.\n\t */\n\tgetSessionNameState(): SessionNameState {\n\t\treturn this.historyIndex.sessionName(this.fileEntries);\n\t}\n\n\t/** Append a custom message entry (for extensions) that participates in LLM context unless excluded. */\n\tappendCustomMessageEntry<T = SessionJsonValue>(\n\t\tcustomType: string,\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\tdisplay: boolean,\n\t\tdetails?: T,\n\t\texcludeFromContext?: boolean,\n\t\tprotectedReconciliation?: { delivery: \"steer\" | \"followUp\" },\n\t\tstageAdmissionKey?: string,\n\t): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst entry = createCustomMessageEntry(\n\t\t\t\tcustomType,\n\t\t\t\tcontent,\n\t\t\t\tdisplay,\n\t\t\t\tdetails,\n\t\t\t\texcludeFromContext,\n\t\t\t\tprotectedReconciliation,\n\t\t\t\tthis.byId,\n\t\t\t\tthis.leafId,\n\t\t\t\tstageAdmissionKey,\n\t\t\t);\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\n\tgetLeafId(): string | null {\n\t\treturn this.leafId;\n\t}\n\n\tgetLeafEntry(): SessionEntry | undefined {\n\t\treturn this.leafId ? this.byId.get(this.leafId) : undefined;\n\t}\n\n\tgetEntry(id: string): SessionEntry | undefined {\n\t\treturn this.byId.get(id);\n\t}\n\n\t/** Get all direct children of an entry. */\n\tgetChildren(parentId: string): SessionEntry[] {\n\t\tconst children: SessionEntry[] = [];\n\t\tfor (const entry of this.byId.values()) {\n\t\t\tif (entry.parentId === parentId) {\n\t\t\t\tchildren.push(entry);\n\t\t\t}\n\t\t}\n\t\treturn children;\n\t}\n\n\t/** Get the label for an entry, if any. */\n\tgetLabel(id: string): string | undefined {\n\t\treturn this.labelsById.get(id);\n\t}\n\n\t/** Set or clear a label on an entry. */\n\tappendLabelChange(targetId: string, label: string | undefined): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tif (!this.byId.has(targetId)) {\n\t\t\t\tthrow new SessionEntryError(targetId, \"missing\");\n\t\t\t}\n\t\t\tconst entry = createLabelEntry(targetId, label, this.byId, this.leafId);\n\t\t\tawait this._appendEntry(entry);\n\t\t\tif (label) {\n\t\t\t\tthis.labelsById.set(targetId, label);\n\t\t\t\tthis.labelTimestampsById.set(targetId, entry.timestamp);\n\t\t\t} else {\n\t\t\t\tthis.labelsById.delete(targetId);\n\t\t\t\tthis.labelTimestampsById.delete(targetId);\n\t\t\t}\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\n\t/** Walk from entry to root, returning all entries in path order. */\n\tgetBranch(fromId?: string): SessionEntry[] {\n\t\tconst leafId = fromId ?? this.leafId;\n\t\treturn leafId === this.leafId\n\t\t\t? this.historyIndex.branch(leafId, this.byId).slice()\n\t\t\t: getBranchPath(leafId, this.byId);\n\t}\n\n\t/** Return the active branch entries after applying the latest compaction boundary. */\n\tbuildContextEntries(): SessionEntry[] {\n\t\treturn buildContextEntries(this.getEntries(), this.leafId, this.byId, this.activeBranch());\n\t}\n\n\t/** Build provenance-preserving, compaction-aware model context from the current leaf. */\n\tbuildSessionProjection(): SessionProjection {\n\t\treturn buildSessionProjection(this.getEntries(), this.leafId, this.byId, this.sessionId, this.activeBranch());\n\t}\n\n\t/** The active branch when the leaf is an entry of this session; undefined lets a stale leaf fall back as before. */\n\tprivate activeBranch(): readonly SessionEntry[] | undefined {\n\t\treturn this.leafId !== null && this.byId.has(this.leafId)\n\t\t\t? this.historyIndex.branch(this.leafId, this.byId)\n\t\t\t: undefined;\n\t}\n\n\t/** Build the session context (what gets sent to the LLM). */\n\tbuildSessionContext(): SessionContext {\n\t\tconst { messages, thinkingLevel, model } = this.buildSessionProjection();\n\t\treturn { messages, thinkingLevel, model };\n\t}\n\n\t/** Get session header. */\n\tgetHeader(): SessionHeader | null {\n\t\tconst header = this.fileEntries.find((entry) => entry.type === \"session\");\n\t\treturn header ? (header as SessionHeader) : null;\n\t}\n\n\t/** Number of entries without copying the session history. */\n\tgetEntryCount(): number {\n\t\treturn this.byId.size;\n\t}\n\n\t/** Get all session entries (excludes header). Returns a shallow copy. */\n\tgetEntries(): SessionEntry[] {\n\t\treturn getEntriesWithoutHeader(this.fileEntries);\n\t}\n\n\t/** Get the session as a tree structure. Returns a shallow defensive copy of all entries. */\n\tgetTree(): SessionTreeNode[] {\n\t\treturn buildSessionTree(this.getEntries(), this.labelsById, this.labelTimestampsById);\n\t}\n\n\t/** Start a new branch from an earlier entry. */\n\tbranch(branchFromId: string): Promise<void> {\n\t\treturn this.runMutation(async () => {\n\t\t\tif (!this.byId.has(branchFromId)) {\n\t\t\t\tthrow new SessionEntryError(branchFromId, \"missing\");\n\t\t\t}\n\t\t\tthis.leafId = branchFromId;\n\t\t});\n\t}\n\n\t/** Reset the leaf pointer to null (before any entries). */\n\tresetLeaf(): Promise<void> {\n\t\treturn this.runMutation(async () => {\n\t\t\tthis.leafId = null;\n\t\t});\n\t}\n\n\t/** Start a new branch with a summary of the abandoned path. */\n\tbranchWithSummary<T = SessionJsonValue>(\n\t\tbranchFromId: string | null,\n\t\tsummary: string,\n\t\tdetails?: T,\n\t\tfromHook?: boolean,\n\t\tusage?: import(\"@bastani/pi-ai/compat\").Usage,\n\t\tfromId?: string,\n\t): Promise<string> {\n\t\treturn this.runMutation(async () => {\n\t\t\tif (branchFromId !== null && !this.byId.has(branchFromId)) {\n\t\t\t\tthrow new SessionEntryError(branchFromId, \"missing\");\n\t\t\t}\n\t\t\tconst entry: BranchSummaryEntry = createBranchSummaryEntry(\n\t\t\t\tbranchFromId,\n\t\t\t\tfromId ?? this.leafId ?? \"root\",\n\t\t\t\tsummary,\n\t\t\t\tdetails,\n\t\t\t\tusage,\n\t\t\t\tfromHook,\n\t\t\t\tthis.byId,\n\t\t\t);\n\t\t\tawait this._appendEntry(entry);\n\t\t\treturn entry.id;\n\t\t});\n\t}\n\n\tcreateBranchedSession(leafId: string): Promise<string | undefined> {\n\t\treturn this.runMutation(async () => {\n\t\t\tconst result = createBranchedSessionState({\n\t\t\t\tleafId,\n\t\t\t\tcwd: this.cwd,\n\t\t\t\tparentSessionId: this.sessionId,\n\t\t\t\tworkflow: classifiedWorkflowMetadata(this.getHeader()),\n\t\t\t\tpath: this.getBranch(leafId),\n\t\t\t\tlabelsById: this.labelsById,\n\t\t\t\tlabelTimestampsById: this.labelTimestampsById,\n\t\t\t});\n\t\t\tconst header = result.fileEntries[0] as SessionHeader;\n\t\t\tconst entries = getEntriesWithoutHeader(result.fileEntries);\n\t\t\tconst record = this.recordHeader(header);\n\t\t\tconst hashes = sessionBlobHashes(this.store, entries);\n\t\t\tconst store = await this.storeForNewSession();\n\t\t\tconst location =\n\t\t\t\tstore instanceof JsonlSessionStore\n\t\t\t\t\t? this.sessionDir\n\t\t\t\t\t\t? createSessionFilePath(this.sessionDir, record.createdAt, record.id)\n\t\t\t\t\t\t: store.locationFor(record)\n\t\t\t\t\t: undefined;\n\t\t\tconst lastSeq = (\n\t\t\t\tawait (store instanceof JsonlSessionStore\n\t\t\t\t\t? store.create(record, entries, location)\n\t\t\t\t\t: store.create(record, entries))\n\t\t\t).lastSeq;\n\t\t\tawait copySessionBlobs(this.store, this.sessionId, store, record.id, hashes);\n\t\t\tthis.store = store;\n\t\t\tthis.fileEntries = result.fileEntries;\n\t\t\tthis.sessionId = header.id;\n\t\t\tthis.lastSeq = lastSeq;\n\t\t\tthis.sessionFile = location;\n\t\t\tthis._buildIndex();\n\t\t\treturn this.sessionFile;\n\t\t});\n\t}\n\n\tasync forkTo(cwd: string, sessionDir?: string | SessionStore, options?: NewSessionOptions): Promise<SessionManager> {\n\t\tconst store =\n\t\t\ttypeof sessionDir === \"string\"\n\t\t\t\t? await JsonlSessionStore.open(sessionDir, { exactDirectory: true, scanExisting: false })\n\t\t\t\t: (sessionDir ?? (await resolveSessionStore(cwd)));\n\t\tconst directory = store instanceof JsonlSessionStore ? store.descriptor.location : \"\";\n\t\treturn SessionManager.constructWithStore(store, store !== sessionDir, async () => {\n\t\t\tconst source = { store: this.store, sessionId: this.sessionId, entries: this.getEntries() };\n\t\t\tconst manager = new SessionManager(store, cwd, directory, { ...options, parentSession: source.sessionId });\n\t\t\tconst hashes = sessionBlobHashes(source.store, source.entries);\n\t\t\tassertSessionBlobStore(store, manager.sessionId, hashes.length);\n\t\t\tmanager.fileEntries.push(...source.entries);\n\t\t\tawait manager.initialize();\n\t\t\tawait copySessionBlobs(source.store, source.sessionId, store, manager.sessionId, hashes);\n\t\t\tmanager._buildIndex();\n\t\t\treturn manager;\n\t\t});\n\t}\n\n\tstatic async importFromJsonl(\n\t\tinputPath: string,\n\t\tcwd: string,\n\t\tsessionDir?: string | SessionStore,\n\t): Promise<SessionManager> {\n\t\tconst store =\n\t\t\ttypeof sessionDir === \"string\"\n\t\t\t\t? await JsonlSessionStore.open(sessionDir, { exactDirectory: true, scanExisting: false })\n\t\t\t\t: (sessionDir ?? (await resolveSessionStore(cwd)));\n\t\treturn SessionManager.constructWithStore(store, store !== sessionDir, () =>\n\t\t\tnew SessionManager(\n\t\t\t\tstore,\n\t\t\t\tcwd,\n\t\t\t\tstore instanceof JsonlSessionStore ? store.descriptor.location : \"\",\n\t\t\t).importFromJsonl(inputPath),\n\t\t);\n\t}\n\tprivate static async constructWithStore(\n\t\tstore: SessionStore,\n\t\towned: boolean,\n\t\tconstruct: () => Promise<SessionManager>,\n\t): Promise<SessionManager> {\n\t\ttry {\n\t\t\treturn await construct();\n\t\t} catch (error) {\n\t\t\tif (owned) {\n\t\t\t\ttry {\n\t\t\t\t\tawait store.close();\n\t\t\t\t} catch (cause) {\n\t\t\t\t\tthrow new StorageRollbackError(error as StorageFailureCause, cause as StorageFailureCause);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tstatic async create(cwd: string, sessionDir?: string, options?: NewSessionOptions): Promise<SessionManager>;\n\tstatic async create(store: SessionStore, cwd: string, options?: NewSessionOptions): Promise<SessionManager>;\n\tstatic async create(\n\t\tcwdOrStore: string | SessionStore,\n\t\tdirectoryOrCwd?: string,\n\t\toptions?: NewSessionOptions,\n\t): Promise<SessionManager> {\n\t\tconst cwd = typeof cwdOrStore === \"string\" ? cwdOrStore : (directoryOrCwd ?? process.cwd());\n\t\tif (typeof cwdOrStore === \"string\" && directoryOrCwd === undefined) {\n\t\t\tconst store = await resolveSessionStore(cwd);\n\t\t\treturn SessionManager.constructWithStore(store, true, () => SessionManager.create(store, cwd, options));\n\t\t}\n\t\tconst directory =\n\t\t\ttypeof cwdOrStore === \"string\"\n\t\t\t\t? directoryOrCwd\n\t\t\t\t\t? normalizePath(directoryOrCwd)\n\t\t\t\t\t: getDefaultSessionDirPath(cwd)\n\t\t\t\t: cwdOrStore instanceof JsonlSessionStore\n\t\t\t\t\t? cwdOrStore.descriptor.location\n\t\t\t\t\t: \"\";\n\t\tconst store =\n\t\t\ttypeof cwdOrStore === \"string\"\n\t\t\t\t? await JsonlSessionStore.open(directory, { exactDirectory: true, scanExisting: false })\n\t\t\t\t: cwdOrStore;\n\t\treturn SessionManager.constructWithStore(store, store !== cwdOrStore, async () => {\n\t\t\tconst manager = new SessionManager(store, cwd, directory, options);\n\t\t\tif (typeof cwdOrStore !== \"string\" && store instanceof JsonlSessionStore) {\n\t\t\t\tmanager.sessionFile = store.locationFor(manager.recordHeader());\n\t\t\t\tmanager.sessionDir = dirname(manager.sessionFile);\n\t\t\t}\n\t\t\tawait manager.initialize();\n\t\t\treturn manager;\n\t\t});\n\t}\n\n\tstatic async open(path: string, sessionDir?: string, cwdOverride?: string): Promise<SessionManager>;\n\tstatic async open(store: SessionStore, sessionId: string, cwdOverride?: string): Promise<SessionManager>;\n\tstatic async open(\n\t\tpathOrStore: string | SessionStore,\n\t\tdirectoryOrId?: string,\n\t\tcwdOverride?: string,\n\t): Promise<SessionManager> {\n\t\tif (typeof pathOrStore !== \"string\") {\n\t\t\tconst snapshot = await pathOrStore.load(directoryOrId!);\n\t\t\tif (snapshot.header.id !== directoryOrId) throw new SessionIdMismatchError(directoryOrId!, snapshot.header.id);\n\t\t\tconst manager = new SessionManager(\n\t\t\t\tpathOrStore,\n\t\t\t\tcwdOverride ?? snapshot.header.cwd,\n\t\t\t\tpathOrStore instanceof JsonlSessionStore ? pathOrStore.descriptor.location : \"\",\n\t\t\t);\n\t\t\tmanager.restore(\n\t\t\t\tsnapshot,\n\t\t\t\tpathOrStore instanceof JsonlSessionStore ? await pathOrStore.findFile(directoryOrId!) : undefined,\n\t\t\t);\n\t\t\tif (manager.sessionFile) manager.sessionDir = dirname(manager.sessionFile);\n\t\t\treturn manager;\n\t\t}\n\t\tconst path = resolvePath(pathOrStore);\n\t\tconst directory = directoryOrId ?? dirname(path);\n\t\tconst store = await JsonlSessionStore.open(dirname(path), { exactDirectory: true, scanExisting: false });\n\t\tlet snapshot: SessionSnapshot;\n\t\ttry {\n\t\t\tsnapshot = await store.loadFile(path);\n\t\t} catch (error) {\n\t\t\tif (!(error instanceof StorageUnavailableError) || (error.cause as NodeJS.ErrnoException).code !== \"ENOENT\")\n\t\t\t\tthrow error;\n\t\t\tconst manager = new SessionManager(store, cwdOverride ?? process.cwd(), directory);\n\t\t\tmanager.lastSeq = (await store.create(manager.recordHeader(), [], path)).lastSeq;\n\t\t\tmanager.sessionFile = path;\n\t\t\treturn manager;\n\t\t}\n\t\tconst manager = new SessionManager(store, cwdOverride ?? snapshot.header.cwd, directory);\n\t\tmanager.restore(snapshot, path);\n\t\treturn manager;\n\t}\n\n\tstatic async continueRecent(\n\t\tcwd: string,\n\t\tsessionDir?: string,\n\t\toptions?: { includeInternal?: boolean },\n\t): Promise<SessionManager>;\n\tstatic async continueRecent(\n\t\tstore: SessionStore,\n\t\tcwd: string,\n\t\toptions?: { includeInternal?: boolean },\n\t): Promise<SessionManager>;\n\tstatic async continueRecent(\n\t\tcwdOrStore: string | SessionStore,\n\t\tdirectoryOrCwd?: string,\n\t\toptions?: { includeInternal?: boolean },\n\t): Promise<SessionManager> {\n\t\tconst cwd = typeof cwdOrStore === \"string\" ? cwdOrStore : directoryOrCwd!;\n\t\tif (typeof cwdOrStore === \"string\" && directoryOrCwd === undefined) {\n\t\t\tconst store = await resolveSessionStore(cwd);\n\t\t\treturn SessionManager.constructWithStore(store, true, () =>\n\t\t\t\tSessionManager.continueRecent(store, cwd, options),\n\t\t\t);\n\t\t}\n\t\tconst directory = typeof cwdOrStore === \"string\" ? (directoryOrCwd ?? getDefaultSessionDirPath(cwd)) : \"\";\n\t\tconst store =\n\t\t\ttypeof cwdOrStore === \"string\"\n\t\t\t\t? await JsonlSessionStore.open(directory, { exactDirectory: true, scanExisting: false })\n\t\t\t\t: cwdOrStore;\n\t\treturn SessionManager.constructWithStore(store, store !== cwdOrStore, async () => {\n\t\t\tconst recent = await store.findMostRecent({\n\t\t\t\tcwd: resolvePath(cwd),\n\t\t\t\tincludeInternal: options?.includeInternal,\n\t\t\t});\n\t\t\tconst manager = new SessionManager(store, cwd, directory);\n\t\t\tif (recent) manager.restore(await store.load(recent.id), recent.location);\n\t\t\telse await manager.initialize();\n\t\t\treturn manager;\n\t\t});\n\t}\n\n\tstatic inMemory(cwd: string = process.cwd(), options?: NewSessionOptions, entries?: FileEntry[]): SessionManager {\n\t\tconst manager = new SessionManager(\n\t\t\tmarkPrivateMemorySessionStore(new MemorySessionStore(createSessionCwdMatcher)),\n\t\t\tcwd,\n\t\t\t\"\",\n\t\t\toptions,\n\t\t);\n\t\tif (entries?.length) {\n\t\t\tmanager.fileEntries = entries[0].type === \"session\" ? entries : [...manager.fileEntries, ...entries];\n\t\t\tmanager.sessionId = manager.getHeader()!.id;\n\t\t\tmanager._buildIndex();\n\t\t}\n\t\tmanager.mutation = manager.initialize();\n\t\treturn manager;\n\t}\n\n\tstatic async forkFrom(\n\t\tsourcePath: string,\n\t\ttargetCwd: string,\n\t\tsessionDir?: string | SessionStore,\n\t\toptions?: NewSessionOptions,\n\t): Promise<SessionManager> {\n\t\tconst sourceStore = await JsonlSessionStore.open(dirname(resolvePath(sourcePath)), {\n\t\t\texactDirectory: true,\n\t\t\tscanExisting: false,\n\t\t});\n\t\tlet source: SessionSnapshot;\n\t\ttry {\n\t\t\tsource = await sourceStore.loadFile(resolvePath(sourcePath));\n\t\t} finally {\n\t\t\tawait sourceStore.close();\n\t\t}\n\t\tconst { entries, blobs } = takeInlineToolOutput(source.entries, source.header.id);\n\t\tconst store =\n\t\t\ttypeof sessionDir === \"string\"\n\t\t\t\t? await JsonlSessionStore.open(sessionDir, { exactDirectory: true, scanExisting: false })\n\t\t\t\t: (sessionDir ?? (await resolveSessionStore(targetCwd)));\n\t\tconst directory =\n\t\t\ttypeof sessionDir === \"string\"\n\t\t\t\t? sessionDir\n\t\t\t\t: sessionDir instanceof JsonlSessionStore\n\t\t\t\t\t? sessionDir.descriptor.location\n\t\t\t\t\t: \"\";\n\t\treturn SessionManager.constructWithStore(store, store !== sessionDir, async () => {\n\t\t\tconst manager = new SessionManager(store, targetCwd, directory, {\n\t\t\t\t...options,\n\t\t\t\tparentSession: source.header.id,\n\t\t\t});\n\t\t\tassertSessionBlobStore(store, manager.sessionId, blobs.length);\n\t\t\tmanager.fileEntries.push(...entries);\n\t\t\tawait manager.initialize();\n\t\t\tawait storeSessionBlobs(store, manager.sessionId, blobs);\n\t\t\tmanager._buildIndex();\n\t\t\treturn manager;\n\t\t});\n\t}\n\n\tstatic async findById(cwd: string, id: string, sessionDir?: string): Promise<string | undefined> {\n\t\tconst store =\n\t\t\tsessionDir === undefined\n\t\t\t\t? await resolveSessionStore(cwd)\n\t\t\t\t: await JsonlSessionStore.open(sessionDir, { exactDirectory: true, scanExisting: false });\n\t\ttry {\n\t\t\tconst header = await store.readHeader(id);\n\t\t\tif (\n\t\t\t\t!header ||\n\t\t\t\tclassifiedWorkflowMetadata(header) ||\n\t\t\t\t!createSessionCwdMatcher(resolvePath(cwd))(resolvePath(header.cwd))\n\t\t\t)\n\t\t\t\treturn undefined;\n\t\t\treturn store instanceof JsonlSessionStore ? await store.findFile(id) : id;\n\t\t} catch (error) {\n\t\t\tif (error instanceof SessionFormatVersionError) return undefined;\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tawait store.close();\n\t\t}\n\t}\n\n\tstatic async list(\n\t\tcwd: string,\n\t\tsessionDir?: string | SessionStore,\n\t\tonProgress?: SessionListProgress,\n\t\toptions?: { includeInternal?: boolean; signal?: AbortSignal } | AbortSignal,\n\t): Promise<SessionInfo[]> {\n\t\tconst signal = options && \"aborted\" in options ? options : options?.signal;\n\t\tif (typeof sessionDir !== \"string\") {\n\t\t\tconst store = sessionDir ?? (await resolveSessionStore(cwd));\n\t\t\ttry {\n\t\t\t\treturn await listSessionStore(\n\t\t\t\t\tstore,\n\t\t\t\t\t{\n\t\t\t\t\t\tcwd: resolvePath(cwd),\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\tincludeInternal:\n\t\t\t\t\t\t\toptions !== undefined && \"includeInternal\" in options && options.includeInternal === true,\n\t\t\t\t\t},\n\t\t\t\t\tonProgress,\n\t\t\t\t);\n\t\t\t} finally {\n\t\t\t\tif (sessionDir === undefined) await store.close();\n\t\t\t}\n\t\t}\n\t\treturn listProjectSessions(\n\t\t\tcwd,\n\t\t\tsessionDir,\n\t\t\tonProgress,\n\t\t\toptions !== undefined && \"includeInternal\" in options && options.includeInternal === true,\n\t\t\tsignal,\n\t\t);\n\t}\n\n\tstatic async listAll(onProgress?: SessionListProgress, signal?: AbortSignal): Promise<SessionInfo[]>;\n\tstatic async listAll(\n\t\tsessionDir?: string | SessionStore,\n\t\tonProgress?: SessionListProgress,\n\t\toptions?: { includeInternal?: boolean; signal?: AbortSignal } | AbortSignal,\n\t): Promise<SessionInfo[]>;\n\tstatic async listAll(\n\t\tdirectoryOrProgress?: string | SessionStore | SessionListProgress,\n\t\tprogressOrSignal?: SessionListProgress | AbortSignal,\n\t\toptions?: { includeInternal?: boolean; signal?: AbortSignal } | AbortSignal,\n\t): Promise<SessionInfo[]> {\n\t\tif (typeof directoryOrProgress !== \"string\") {\n\t\t\tconst supplied = typeof directoryOrProgress === \"object\" ? directoryOrProgress : undefined;\n\t\t\tconst store = supplied ?? (await resolveSessionStore(process.cwd()));\n\t\t\ttry {\n\t\t\t\treturn await listSessionStore(\n\t\t\t\t\tstore,\n\t\t\t\t\t{\n\t\t\t\t\t\tincludeInternal:\n\t\t\t\t\t\t\toptions !== undefined && \"includeInternal\" in options && options.includeInternal === true,\n\t\t\t\t\t\tsignal:\n\t\t\t\t\t\t\toptions && \"aborted\" in options\n\t\t\t\t\t\t\t\t? options\n\t\t\t\t\t\t\t\t: (options?.signal ?? (typeof progressOrSignal === \"object\" ? progressOrSignal : undefined)),\n\t\t\t\t\t},\n\t\t\t\t\ttypeof directoryOrProgress === \"function\"\n\t\t\t\t\t\t? directoryOrProgress\n\t\t\t\t\t\t: typeof progressOrSignal === \"function\"\n\t\t\t\t\t\t\t? progressOrSignal\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t);\n\t\t\t} finally {\n\t\t\t\tif (!supplied) await store.close();\n\t\t\t}\n\t\t}\n\t\tconst { listAllSessions } = await import(\"./session-manager-list.ts\");\n\t\treturn listAllSessions(\n\t\t\tdirectoryOrProgress,\n\t\t\ttypeof progressOrSignal === \"function\" ? progressOrSignal : undefined,\n\t\t\toptions !== undefined && \"includeInternal\" in options && options.includeInternal === true,\n\t\t\toptions && \"aborted\" in options\n\t\t\t\t? options\n\t\t\t\t: (options?.signal ?? (typeof progressOrSignal === \"object\" ? progressOrSignal : undefined)),\n\t\t);\n\t}\n}\n"]}
|
|
@@ -9,7 +9,7 @@ export declare function getLatestCompactionBoundaryEntry(entries: SessionEntry[]
|
|
|
9
9
|
/** Convert one durable session entry into the messages it contributes to model context. */
|
|
10
10
|
export declare function sessionEntryToContextMessages(entry: SessionEntry): AgentMessage[];
|
|
11
11
|
/** Return the active branch entries after applying the latest compaction boundary. */
|
|
12
|
-
export declare function buildContextEntries(entries: SessionEntry[], leafId?: string | null, byId?: Map<string, SessionEntry
|
|
12
|
+
export declare function buildContextEntries(entries: SessionEntry[], leafId?: string | null, byId?: Map<string, SessionEntry>, branch?: readonly SessionEntry[]): SessionEntry[];
|
|
13
13
|
/**
|
|
14
14
|
* Build provenance-preserving, compaction-aware model context.
|
|
15
15
|
*
|
|
@@ -22,7 +22,7 @@ export declare function buildContextEntries(entries: SessionEntry[], leafId?: st
|
|
|
22
22
|
* (after its `coveredThroughEntryId`) replay unchanged, and older boundaries among them
|
|
23
23
|
* contribute nothing.
|
|
24
24
|
*/
|
|
25
|
-
export declare function buildSessionProjection(entries: SessionEntry[], leafId?: string | null, byId?: Map<string, SessionEntry>, sessionId?: string): SessionProjection;
|
|
25
|
+
export declare function buildSessionProjection(entries: SessionEntry[], leafId?: string | null, byId?: Map<string, SessionEntry>, sessionId?: string, branch?: readonly SessionEntry[]): SessionProjection;
|
|
26
26
|
/**
|
|
27
27
|
* Build the session context from entries using tree traversal.
|
|
28
28
|
* If leafId is provided, walks from that entry to root.
|
|
@@ -38,6 +38,6 @@ export interface SessionIndex {
|
|
|
38
38
|
leafId: string | null;
|
|
39
39
|
}
|
|
40
40
|
export declare function buildSessionIndex(fileEntries: FileEntry[]): SessionIndex;
|
|
41
|
-
export declare function getBranchPath(fromId: string | null | undefined, byId:
|
|
41
|
+
export declare function getBranchPath(fromId: string | null | undefined, byId: ReadonlyMap<string, SessionEntry>): SessionEntry[];
|
|
42
42
|
export declare function buildSessionTree(entries: SessionEntry[], labelsById: ReadonlyMap<string, string>, labelTimestampsById: ReadonlyMap<string, string>): SessionTreeNode[];
|
|
43
43
|
//# sourceMappingURL=session-manager-history.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-manager-history.d.ts","sourceRoot":"","sources":["../../src/core/session-manager-history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAUlF,OAAO,KAAK,EACX,eAAe,EACf,gBAAgB,EAChB,SAAS,EAET,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,M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EAAE,YAAY,CAAC,GACrC,YAAY,EAAE,CAShB;AAED,wBAAgB,gBAAgB,CAC/B,OAAO,EAAE,YAAY,EAAE,EACvB,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EACvC,mBAAmB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9C,eAAe,EAAE,CAqCnB"}
|
|
@@ -134,13 +134,13 @@ function boundaryCoveredIndex(path, boundary, boundaryIndex) {
|
|
|
134
134
|
return covered >= 0 ? covered : boundaryIndex - 1;
|
|
135
135
|
}
|
|
136
136
|
/** Return the active branch entries after applying the latest compaction boundary. */
|
|
137
|
-
export function buildContextEntries(entries, leafId, byId = new Map(entries.map((entry) => [entry.id, entry]))) {
|
|
137
|
+
export function buildContextEntries(entries, leafId, byId = new Map(entries.map((entry) => [entry.id, entry])), branch) {
|
|
138
138
|
if (leafId === null)
|
|
139
139
|
return [];
|
|
140
140
|
const leaf = leafId ? byId.get(leafId) : entries[entries.length - 1];
|
|
141
141
|
if (!leaf)
|
|
142
142
|
return [];
|
|
143
|
-
const path = normalizeDerivedSessionEntries(getBranchPath(leaf.id, byId));
|
|
143
|
+
const path = normalizeDerivedSessionEntries(branch ?? getBranchPath(leaf.id, byId));
|
|
144
144
|
const boundary = getLatestCompactionBoundaryEntry(path);
|
|
145
145
|
if (!boundary)
|
|
146
146
|
return path;
|
|
@@ -161,7 +161,7 @@ export function buildContextEntries(entries, leafId, byId = new Map(entries.map(
|
|
|
161
161
|
* (after its `coveredThroughEntryId`) replay unchanged, and older boundaries among them
|
|
162
162
|
* contribute nothing.
|
|
163
163
|
*/
|
|
164
|
-
export function buildSessionProjection(entries, leafId, byId, sessionId) {
|
|
164
|
+
export function buildSessionProjection(entries, leafId, byId, sessionId, branch) {
|
|
165
165
|
// Build uuid index if not available
|
|
166
166
|
if (!byId) {
|
|
167
167
|
byId = new Map();
|
|
@@ -186,9 +186,10 @@ export function buildSessionProjection(entries, leafId, byId, sessionId) {
|
|
|
186
186
|
return { entries: [], messages: [], thinkingLevel: "off", model: null };
|
|
187
187
|
}
|
|
188
188
|
// Walk from leaf to root, collecting path
|
|
189
|
-
const
|
|
189
|
+
const walked = branch ?? getBranchPath(leaf.id, byId);
|
|
190
|
+
const path = normalizeDerivedSessionEntries(walked);
|
|
190
191
|
const { thinkingLevel, model } = getSessionContextSettings(path);
|
|
191
|
-
const contextEntries = buildContextEntries(entries, leaf.id, byId);
|
|
192
|
+
const contextEntries = buildContextEntries(entries, leaf.id, byId, walked);
|
|
192
193
|
const edits = collectContextEdits(contextEntries);
|
|
193
194
|
const boundary = getLatestCompactionBoundaryEntry(path);
|
|
194
195
|
if (!boundary || boundary.details?.backend === "summary") {
|