@bastani/atomic 0.9.84 → 0.9.85-alpha.1
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 +32 -0
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/broker/broker.ts +25 -7
- package/dist/builtin/intercom/broker/spawn.ts +83 -17
- package/dist/builtin/intercom/index.bundle.mjs +89 -26
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +6 -0
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/authoring.d.ts +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +48 -9
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +48 -9
- package/dist/builtin/workflows/src/index.js +48 -9
- package/dist/builtin/workflows/src/local-worker-entry.mjs +48 -9
- package/dist/config.d.ts +3 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -3
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-export.d.ts +2 -2
- package/dist/core/agent-session-export.d.ts.map +1 -1
- package/dist/core/agent-session-export.js +4 -5
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-services.js +1 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-summary.d.ts.map +1 -1
- package/dist/core/agent-session-summary.js +8 -1
- package/dist/core/agent-session-summary.js.map +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-tree.js +3 -6
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/builtin-resource-loader.d.ts.map +1 -1
- package/dist/core/builtin-resource-loader.js +1 -1
- package/dist/core/builtin-resource-loader.js.map +1 -1
- package/dist/core/extensions/loader-core.d.ts +6 -2
- package/dist/core/extensions/loader-core.d.ts.map +1 -1
- package/dist/core/extensions/loader-core.js +13 -9
- package/dist/core/extensions/loader-core.js.map +1 -1
- package/dist/core/extensions/loader-discovery.js +1 -1
- package/dist/core/extensions/loader-discovery.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts +20 -14
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +133 -78
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/ts-source-specifiers.d.ts +1 -0
- package/dist/core/extensions/ts-source-specifiers.d.ts.map +1 -1
- package/dist/core/extensions/ts-source-specifiers.js +18 -2
- package/dist/core/extensions/ts-source-specifiers.js.map +1 -1
- package/dist/core/mandatory-resource-loader.d.ts +5 -2
- package/dist/core/mandatory-resource-loader.d.ts.map +1 -1
- package/dist/core/mandatory-resource-loader.js +17 -12
- package/dist/core/mandatory-resource-loader.js.map +1 -1
- package/dist/core/model-fallback-failures.d.ts.map +1 -1
- package/dist/core/model-fallback-failures.js +10 -3
- package/dist/core/model-fallback-failures.js.map +1 -1
- package/dist/core/resource-loader-extensions.d.ts.map +1 -1
- package/dist/core/resource-loader-extensions.js +1 -1
- package/dist/core/resource-loader-extensions.js.map +1 -1
- package/dist/core/resource-loader-reload.js +1 -1
- package/dist/core/resource-loader-reload.js.map +1 -1
- package/dist/core/resume/blueprint/resume.d.ts +4 -4
- package/dist/core/resume/blueprint/resume.js +4 -4
- package/dist/core/resume/blueprint/resume.js.map +1 -1
- package/dist/core/resume/session-resume.d.ts +6 -3
- package/dist/core/resume/session-resume.d.ts.map +1 -1
- package/dist/core/resume/session-resume.js +159 -37
- package/dist/core/resume/session-resume.js.map +1 -1
- package/dist/core/sdk.js +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +10 -4
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +23 -6
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +2 -2
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js +2 -1
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/session-manager-history.d.ts +13 -1
- package/dist/core/session-manager-history.d.ts.map +1 -1
- package/dist/core/session-manager-history.js +21 -1
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +3 -1
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/core/session-manager.d.ts +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +1 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-worktree-snapshots.d.ts +61 -4
- package/dist/core/session-worktree-snapshots.d.ts.map +1 -1
- package/dist/core/session-worktree-snapshots.js +261 -28
- package/dist/core/session-worktree-snapshots.js.map +1 -1
- package/dist/core/storage/session/entry-structure.js +31 -1
- package/dist/core/storage/session/entry-structure.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/build-questionnaire.js +2 -1
- package/dist/core/tools/ask-user-question/state/build-questionnaire.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.js +2 -0
- package/dist/core/tools/ask-user-question/state/questionnaire-session.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/field-tone.d.ts +26 -0
- package/dist/core/tools/ask-user-question/state/selectors/field-tone.d.ts.map +1 -0
- package/dist/core/tools/ask-user-question/state/selectors/field-tone.js +27 -0
- package/dist/core/tools/ask-user-question/state/selectors/field-tone.js.map +1 -0
- package/dist/core/tools/ask-user-question/state/selectors/projections.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/selectors/projections.js +1 -0
- package/dist/core/tools/ask-user-question/state/selectors/projections.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/state-reducer.js +1 -1
- package/dist/core/tools/ask-user-question/state/state-reducer.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.js +6 -6
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts +5 -3
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js +14 -4
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts +2 -0
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js +3 -3
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts +16 -6
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.js +42 -24
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.js +12 -3
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.js.map +1 -1
- package/dist/core/tools/read.d.ts +1 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +13 -14
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/worktree-snapshot/index.d.ts +2 -2
- package/dist/core/worktree-snapshot/index.d.ts.map +1 -1
- package/dist/core/worktree-snapshot/index.js +1 -1
- package/dist/core/worktree-snapshot/index.js.map +1 -1
- package/dist/core/worktree-snapshot/records.d.ts +6 -0
- package/dist/core/worktree-snapshot/records.d.ts.map +1 -1
- package/dist/core/worktree-snapshot/records.js +18 -4
- package/dist/core/worktree-snapshot/records.js.map +1 -1
- package/dist/core/worktree-snapshot/restore.d.ts +24 -1
- package/dist/core/worktree-snapshot/restore.d.ts.map +1 -1
- package/dist/core/worktree-snapshot/restore.js +443 -72
- package/dist/core/worktree-snapshot/restore.js.map +1 -1
- package/dist/core/worktree-snapshot/types.d.ts +44 -0
- package/dist/core/worktree-snapshot/types.d.ts.map +1 -1
- package/dist/core/worktree-snapshot/types.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +2 -1
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +4 -1
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +8 -0
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +11 -2
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-command-timeouts.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-timeouts.js +1 -0
- package/dist/modes/rpc/rpc-command-timeouts.js.map +1 -1
- package/dist/modes/rpc/rpc-input-scheduler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-input-scheduler.js +1 -0
- package/dist/modes/rpc/rpc-input-scheduler.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +11 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/docs/environment-variables.md +1 -1
- package/docs/guides/resume-on-any-machine.md +6 -4
- package/docs/intercom/operations.md +4 -0
- package/docs/rpc/protocol.md +2 -2
- package/docs/sdk/reference.md +3 -0
- package/docs/sdk.md +2 -2
- package/docs/session-format.md +11 -2
- package/docs/sessions.md +4 -2
- package/docs/settings.md +1 -1
- package/docs/workflows/api-reference.md +2 -2
- package/docs/worktree-snapshots.md +13 -5
- package/npm-shrinkwrap.json +32 -32
- package/package.json +3 -3
|
@@ -233,6 +233,15 @@ export function buildSessionContext(entries, leafId, byId) {
|
|
|
233
233
|
const { messages, thinkingLevel, model } = buildSessionProjection(entries, leafId, byId);
|
|
234
234
|
return { messages, thinkingLevel, model };
|
|
235
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* `customType` of the entry that records a leaf move made without a new entry, such as `/tree` without a summary. It is
|
|
238
|
+
* a child of the new leaf and never a leaf itself, so it adds nothing to the context and a reader that takes the last
|
|
239
|
+
* entry as the leaf still follows the selected branch (#3325).
|
|
240
|
+
*/
|
|
241
|
+
export const LEAF_MOVE_ENTRY_TYPE = "atomic.leaf";
|
|
242
|
+
export function isLeafMoveEntry(entry) {
|
|
243
|
+
return entry.type === "custom" && entry.customType === LEAF_MOVE_ENTRY_TYPE;
|
|
244
|
+
}
|
|
236
245
|
export function buildSessionIndex(fileEntries) {
|
|
237
246
|
const byId = new Map();
|
|
238
247
|
const labelsById = new Map();
|
|
@@ -254,8 +263,18 @@ export function buildSessionIndex(fileEntries) {
|
|
|
254
263
|
}
|
|
255
264
|
}
|
|
256
265
|
}
|
|
266
|
+
const last = leafId === null ? undefined : byId.get(leafId);
|
|
267
|
+
if (last && isLeafMoveEntry(last))
|
|
268
|
+
leafId = last.parentId;
|
|
257
269
|
return { byId, labelsById, labelTimestampsById, leafId };
|
|
258
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* The entry a session continues from when it is opened: its last entry, or the entry a recorded leaf move selected
|
|
273
|
+
* (#3325). `null` when the session continues from before its first entry.
|
|
274
|
+
*/
|
|
275
|
+
export function getSessionLeafId(entries) {
|
|
276
|
+
return buildSessionIndex(entries).leafId;
|
|
277
|
+
}
|
|
259
278
|
export function getBranchPath(fromId, byId) {
|
|
260
279
|
const path = [];
|
|
261
280
|
let current = fromId ? byId.get(fromId) : undefined;
|
|
@@ -269,7 +288,8 @@ export function getBranchPath(fromId, byId) {
|
|
|
269
288
|
export function buildSessionTree(entries, labelsById, labelTimestampsById) {
|
|
270
289
|
const nodeMap = new Map();
|
|
271
290
|
const roots = [];
|
|
272
|
-
// Create nodes with resolved labels
|
|
291
|
+
// Create nodes with resolved labels. A recorded leaf move is bookkeeping, not a node of the tree.
|
|
292
|
+
entries = entries.filter((entry) => !isLeafMoveEntry(entry));
|
|
273
293
|
for (const entry of entries) {
|
|
274
294
|
const label = labelsById.get(entry.id);
|
|
275
295
|
const labelTimestamp = labelTimestampsById.get(entry.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-manager-history.js","sourceRoot":"","sources":["../../src/core/session-manager-history.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAwB,MAAM,0CAA0C,CAAC;AAC7G,OAAO,EACN,YAAY,EACZ,0BAA0B,EAC1B,mBAAmB,EACnB,+BAA+B,EAC/B,uBAAuB,GACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAYlF,4EAA4E;AAC5E,SAAS,uBAAuB,CAAC,KAAmB;IACnD,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,uBAAuB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC5E,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;QACrC,OAAO,mBAAmB,CACzB,KAAK,CAAC,UAAU,EAChB,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,SAAS,EACf,KAAK,CAAC,kBAAkB,EACxB,KAAK,CAAC,iBAAiB,CACvB,CAAC;IACH,CAAC;IACD,IAAI,KAAK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C,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5G,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["import type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { VerbatimCompactionDetails } from \"./compaction/compaction-types.js\";\nimport { serializeRetainedTranscript, type TranscriptChunk } from \"./compaction/transcript-serialization.js\";\nimport {\n\tconvertToLlm,\n\tcreateBranchSummaryMessage,\n\tcreateCustomMessage,\n\tcreateVerbatimCompactionMessage,\n\tnormalizeMessageContent,\n} from \"./messages.ts\";\nimport { normalizeDerivedSessionEntries } from \"./session-entry-normalization.ts\";\nimport type {\n\tCompactionEntry,\n\tContextEditEntry,\n\tFileEntry,\n\tProjectedSessionEntry,\n\tSessionContext,\n\tSessionEntry,\n\tSessionProjection,\n\tSessionTreeNode,\n} from \"./session-manager-types.ts\";\n\n/** Build the single context message a durable entry contributes, if any. */\nfunction contextMessageFromEntry(entry: SessionEntry): AgentMessage | undefined {\n\tif (entry.type === \"message\") return normalizeMessageContent(entry.message);\n\tif (entry.type === \"custom_message\") {\n\t\treturn createCustomMessage(\n\t\t\tentry.customType,\n\t\t\tentry.content,\n\t\t\tentry.display,\n\t\t\tentry.details,\n\t\t\tentry.timestamp,\n\t\t\tentry.excludeFromContext,\n\t\t\tentry.stageAdmissionKey,\n\t\t);\n\t}\n\tif (entry.type === \"branch_summary\" && typeof entry.summary === \"string\" && entry.summary.length > 0) {\n\t\treturn createBranchSummaryMessage(entry.summary, entry.fromId, entry.timestamp);\n\t}\n\treturn undefined;\n}\n\n/**\n * Serialize the kept tail into the compaction boundary's transcript grammar.\n *\n * The tail is concatenated onto the end of the boundary string instead of being\n * replayed as structured messages. A tail that starts mid-turn (a tool result whose\n * tool call was compacted away, or a trailing unanswered tool call) would otherwise\n * emit ill-ordered provider blocks and fail the request. Payloads are kept whole:\n * tool results keep their full text and images stay as image blocks, because the tail\n * is exactly the span `preserve_recent` promised to keep. Thinking is omitted, as in\n * the compacted region; the durable entries keep it, and messages after the boundary\n * replay with their thinking blocks.\n */\nfunction serializeKeptTail(entries: SessionEntry[], edits?: Map<string, ContextEditEntry>): TranscriptChunk[] {\n\tconst messages: AgentMessage[] = [];\n\tfor (const entry of entries) {\n\t\tconst message = contextMessageFromEntry(entry);\n\t\tif (!message) continue;\n\t\tconst edit = edits?.get(entry.id);\n\t\tif (edit) messages.push(...applyContextEdit([message], edit));\n\t\telse messages.push(message);\n\t}\n\tif (messages.length === 0) return [];\n\treturn serializeRetainedTranscript(convertToLlm(messages));\n}\n\n/** Index the latest context edit per target among the given entries. */\nexport function collectContextEdits(entries: readonly SessionEntry[]): Map<string, ContextEditEntry> {\n\tconst edits = new Map<string, ContextEditEntry>();\n\tfor (const entry of entries) {\n\t\tif (entry.type === \"context_edit\") edits.set(entry.targetId, entry);\n\t}\n\treturn edits;\n}\n\n/** Apply one append-only context edit to the messages an entry contributes. */\nexport function applyContextEdit(messages: AgentMessage[], edit: ContextEditEntry): AgentMessage[] {\n\tconst replacement = edit.replacement;\n\tif (replacement === null) return [];\n\n\treturn messages.map((message) => {\n\t\tif (\n\t\t\tmessage.role !== \"user\" &&\n\t\t\tmessage.role !== \"assistant\" &&\n\t\t\tmessage.role !== \"toolResult\" &&\n\t\t\tmessage.role !== \"custom\"\n\t\t) {\n\t\t\treturn message;\n\t\t}\n\t\tconst content =\n\t\t\t(message.role === \"assistant\" || message.role === \"toolResult\") && typeof replacement.content === \"string\"\n\t\t\t\t? [{ type: \"text\" as const, text: replacement.content }]\n\t\t\t\t: replacement.content;\n\t\treturn { ...message, content } as AgentMessage;\n\t});\n}\n\nfunction projectContextEntry(entry: SessionEntry, edit: ContextEditEntry | undefined): AgentMessage[] {\n\tconst messages = sessionEntryToContextMessages(entry);\n\tif (!edit) return messages;\n\treturn applyContextEdit(messages, edit);\n}\n\n/** Extract the settings (thinking level and model) recorded along a branch path. */\nfunction getSessionContextSettings(path: SessionEntry[]): {\n\tthinkingLevel: string;\n\tmodel: { provider: string; modelId: string } | null;\n} {\n\tlet thinkingLevel = \"off\";\n\tlet model: { provider: string; modelId: string } | null = null;\n\tfor (const entry of path) {\n\t\tif (entry.type === \"thinking_level_change\") {\n\t\t\tthinkingLevel = entry.thinkingLevel;\n\t\t} else if (entry.type === \"model_change\") {\n\t\t\tmodel = { provider: entry.provider, modelId: entry.modelId };\n\t\t} else if (entry.type === \"message\" && entry.message.role === \"assistant\") {\n\t\t\tmodel = { provider: entry.message.provider, modelId: entry.message.model };\n\t\t}\n\t}\n\treturn { thinkingLevel, model };\n}\n\nexport function getLatestCompactionBoundaryEntry(\n\tentries: SessionEntry[],\n): CompactionEntry<VerbatimCompactionDetails> | null {\n\tfor (let i = entries.length - 1; i >= 0; i--) {\n\t\tconst entry = entries[i];\n\t\tif (entry.type !== \"compaction\") continue;\n\t\tconst details = (entry as CompactionEntry<{ strategy?: string }>).details;\n\t\tif (details?.strategy === \"verbatim-lines\") return entry as CompactionEntry<VerbatimCompactionDetails>;\n\t}\n\treturn null;\n}\n\n/** Convert one durable session entry into the messages it contributes to model context. */\nexport function sessionEntryToContextMessages(entry: SessionEntry): AgentMessage[] {\n\tif (entry.type === \"message\") return [normalizeMessageContent(entry.message)];\n\tif (entry.type === \"custom_message\") {\n\t\treturn [\n\t\t\tcreateCustomMessage(\n\t\t\t\tentry.customType,\n\t\t\t\tentry.content,\n\t\t\t\tentry.display,\n\t\t\t\tentry.details,\n\t\t\t\tentry.timestamp,\n\t\t\t\tentry.excludeFromContext,\n\t\t\t\tentry.stageAdmissionKey,\n\t\t\t),\n\t\t];\n\t}\n\tif (entry.type === \"branch_summary\" && entry.summary.length > 0) {\n\t\treturn [createBranchSummaryMessage(entry.summary, entry.fromId, entry.timestamp)];\n\t}\n\tif (entry.type === \"compaction\") {\n\t\tconst details = (entry as CompactionEntry<{ strategy?: string }>).details;\n\t\tif (details?.strategy === \"verbatim-lines\") {\n\t\t\treturn [\n\t\t\t\t...(entry.systemMessage ? [entry.systemMessage] : []),\n\t\t\t\tcreateVerbatimCompactionMessage(\n\t\t\t\t\tentry.summary,\n\t\t\t\t\tentry.tokensBefore,\n\t\t\t\t\tentry.timestamp,\n\t\t\t\t\tentry.details as VerbatimCompactionDetails,\n\t\t\t\t),\n\t\t\t];\n\t\t}\n\t}\n\treturn [];\n}\n\n/**\n * Path index of the last entry `boundary` covers: its `coveredThroughEntryId` when that entry precedes\n * it on the path, otherwise every entry before the boundary.\n */\nfunction boundaryCoveredIndex(path: SessionEntry[], boundary: CompactionEntry, boundaryIndex: number): number {\n\tconst covered = path.findIndex(\n\t\t(entry, index) => index < boundaryIndex && entry.id === boundary.coveredThroughEntryId,\n\t);\n\treturn covered >= 0 ? covered : boundaryIndex - 1;\n}\n\n/** Return the active branch entries after applying the latest compaction boundary. */\nexport function buildContextEntries(\n\tentries: SessionEntry[],\n\tleafId?: string | null,\n\tbyId = new Map(entries.map((entry) => [entry.id, entry])),\n\tbranch?: readonly SessionEntry[],\n): SessionEntry[] {\n\tif (leafId === null) return [];\n\tconst leaf = leafId ? byId.get(leafId) : entries[entries.length - 1];\n\tif (!leaf) return [];\n\tconst path = normalizeDerivedSessionEntries(branch ?? getBranchPath(leaf.id, byId));\n\tconst boundary = getLatestCompactionBoundaryEntry(path);\n\tif (!boundary) return path;\n\tconst boundaryIndex = path.findIndex((entry) => entry.id === boundary.id);\n\tconst firstKeptIndex = path.findIndex(\n\t\t(entry, index) => index < boundaryIndex && entry.id === boundary.firstKeptEntryId,\n\t);\n\tconst retainedStart = firstKeptIndex >= 0 ? firstKeptIndex : boundaryCoveredIndex(path, boundary, boundaryIndex) + 1;\n\treturn [boundary, ...path.slice(retainedStart, boundaryIndex), ...path.slice(boundaryIndex + 1)];\n}\n\n/**\n * Build provenance-preserving, compaction-aware model context.\n *\n * Every entry on the active branch after the latest compaction boundary is projected\n * to the messages it contributes after context edits. The latest verbatim compaction\n * boundary is emitted as one custom-role text message: the compacted string with the\n * kept tail (edits applied) serialized and appended to its end, rather than the tail\n * being replayed as separate structured messages. Kept-tail entries therefore project\n * to no standalone messages of their own. Entries a background boundary does not cover\n * (after its `coveredThroughEntryId`) replay unchanged, and older boundaries among them\n * contribute nothing.\n */\nexport function buildSessionProjection(\n\tentries: SessionEntry[],\n\tleafId?: string | null,\n\tbyId?: Map<string, SessionEntry>,\n\tsessionId?: string,\n\tbranch?: readonly SessionEntry[],\n): SessionProjection {\n\t// Build uuid index if not available\n\tif (!byId) {\n\t\tbyId = new Map<string, SessionEntry>();\n\t\tfor (const entry of entries) {\n\t\t\tbyId.set(entry.id, entry);\n\t\t}\n\t}\n\n\t// Find leaf\n\tlet leaf: SessionEntry | undefined;\n\tif (leafId === null) {\n\t\t// Explicitly null - return no messages (navigated to before first entry)\n\t\treturn { entries: [], messages: [], thinkingLevel: \"off\", model: null };\n\t}\n\tif (leafId) {\n\t\tleaf = byId.get(leafId);\n\t}\n\tif (!leaf) {\n\t\t// Fallback to last entry (when leafId is undefined)\n\t\tleaf = entries[entries.length - 1];\n\t}\n\n\tif (!leaf) {\n\t\treturn { entries: [], messages: [], thinkingLevel: \"off\", model: null };\n\t}\n\n\t// Walk from leaf to root, collecting path\n\tconst walked = branch ?? getBranchPath(leaf.id, byId);\n\tconst path = normalizeDerivedSessionEntries(walked);\n\tconst { thinkingLevel, model } = getSessionContextSettings(path);\n\tconst contextEntries = buildContextEntries(entries, leaf.id, byId, walked);\n\tconst edits = collectContextEdits(contextEntries);\n\n\tconst boundary = getLatestCompactionBoundaryEntry(path);\n\tif (!boundary || boundary.details?.backend === \"summary\") {\n\t\tconst projected = contextEntries.map(\n\t\t\t(sourceEntry): ProjectedSessionEntry => ({\n\t\t\t\tsourceEntry,\n\t\t\t\tmessages:\n\t\t\t\t\tboundary && sourceEntry.type === \"compaction\" && sourceEntry.id !== boundary.id\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: projectContextEntry(sourceEntry, edits.get(sourceEntry.id)),\n\t\t\t}),\n\t\t);\n\t\treturn { entries: projected, messages: projected.flatMap((entry) => entry.messages), thinkingLevel, model };\n\t}\n\n\tconst boundaryIndex = path.findIndex((entry) => entry.id === boundary.id);\n\tconst firstKeptIndex = path.findIndex(\n\t\t(entry, index) => index < boundaryIndex && entry.id === boundary.firstKeptEntryId,\n\t);\n\tconst coveredIndex = boundaryCoveredIndex(path, boundary, boundaryIndex);\n\tconst keptTailEntries = firstKeptIndex >= 0 ? path.slice(firstKeptIndex, coveredIndex + 1) : [];\n\tconst keptTailIds = new Set(keptTailEntries.map((entry) => entry.id));\n\tconst keptTail = serializeKeptTail(keptTailEntries, edits);\n\tconst separator: TranscriptChunk[] =\n\t\tkeptTail.length > 0 && boundary.summary.length > 0 ? [{ type: \"text\", text: \"\\n\\n\" }] : [];\n\tconst boundaryMessages: AgentMessage[] = [\n\t\t...(boundary.systemMessage ? [boundary.systemMessage] : []),\n\t\tcreateVerbatimCompactionMessage(\n\t\t\tboundary.summary,\n\t\t\tboundary.tokensBefore,\n\t\t\tboundary.timestamp,\n\t\t\tboundary.details,\n\t\t\t[...separator, ...keptTail],\n\t\t\tsessionId,\n\t\t),\n\t];\n\tconst projected = contextEntries.map(\n\t\t(sourceEntry): ProjectedSessionEntry => ({\n\t\t\tsourceEntry,\n\t\t\tmessages:\n\t\t\t\tsourceEntry.id === boundary.id\n\t\t\t\t\t? boundaryMessages\n\t\t\t\t\t: keptTailIds.has(sourceEntry.id) || sourceEntry.type === \"compaction\"\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: projectContextEntry(sourceEntry, edits.get(sourceEntry.id)),\n\t\t}),\n\t);\n\treturn { entries: projected, messages: projected.flatMap((entry) => entry.messages), thinkingLevel, model };\n}\n\n/**\n * Build the session context from entries using tree traversal.\n * If leafId is provided, walks from that entry to root.\n * Emits the latest verbatim compaction boundary as one custom-role text message: the\n * compacted string with the kept tail serialized and appended to its end, rather than\n * the tail being replayed as separate structured messages.\n */\nexport function buildSessionContext(\n\tentries: SessionEntry[],\n\tleafId?: string | null,\n\tbyId?: Map<string, SessionEntry>,\n): SessionContext {\n\tconst { messages, thinkingLevel, model } = buildSessionProjection(entries, leafId, byId);\n\treturn { messages, thinkingLevel, model };\n}\n\nexport interface SessionIndex {\n\tbyId: Map<string, SessionEntry>;\n\tlabelsById: Map<string, string>;\n\tlabelTimestampsById: Map<string, string>;\n\tleafId: string | null;\n}\n\nexport function buildSessionIndex(fileEntries: FileEntry[]): SessionIndex {\n\tconst byId = new Map<string, SessionEntry>();\n\tconst labelsById = new Map<string, string>();\n\tconst labelTimestampsById = new Map<string, string>();\n\tlet leafId: string | null = null;\n\n\tfor (const entry of fileEntries) {\n\t\tif (entry.type === \"session\") continue;\n\t\tbyId.set(entry.id, entry);\n\t\tleafId = entry.id;\n\t\tif (entry.type === \"label\") {\n\t\t\tif (entry.label) {\n\t\t\t\tlabelsById.set(entry.targetId, entry.label);\n\t\t\t\tlabelTimestampsById.set(entry.targetId, entry.timestamp);\n\t\t\t} else {\n\t\t\t\tlabelsById.delete(entry.targetId);\n\t\t\t\tlabelTimestampsById.delete(entry.targetId);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { byId, labelsById, labelTimestampsById, leafId };\n}\n\nexport function getBranchPath(\n\tfromId: string | null | undefined,\n\tbyId: ReadonlyMap<string, SessionEntry>,\n): SessionEntry[] {\n\tconst path: SessionEntry[] = [];\n\tlet current = fromId ? byId.get(fromId) : undefined;\n\twhile (current) {\n\t\tpath.push(current);\n\t\tcurrent = current.parentId ? byId.get(current.parentId) : undefined;\n\t}\n\tpath.reverse();\n\treturn path;\n}\n\nexport function buildSessionTree(\n\tentries: SessionEntry[],\n\tlabelsById: ReadonlyMap<string, string>,\n\tlabelTimestampsById: ReadonlyMap<string, string>,\n): SessionTreeNode[] {\n\tconst nodeMap = new Map<string, SessionTreeNode>();\n\tconst roots: SessionTreeNode[] = [];\n\n\t// Create nodes with resolved labels\n\tfor (const entry of entries) {\n\t\tconst label = labelsById.get(entry.id);\n\t\tconst labelTimestamp = labelTimestampsById.get(entry.id);\n\t\tnodeMap.set(entry.id, { entry, children: [], label, labelTimestamp });\n\t}\n\n\t// Build tree\n\tfor (const entry of entries) {\n\t\tconst node = nodeMap.get(entry.id)!;\n\t\tif (entry.parentId === null || entry.parentId === entry.id) {\n\t\t\troots.push(node);\n\t\t} else {\n\t\t\tconst parent = nodeMap.get(entry.parentId);\n\t\t\tif (parent) {\n\t\t\t\tparent.children.push(node);\n\t\t\t} else {\n\t\t\t\t// Orphan - treat as root\n\t\t\t\troots.push(node);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Sort children by timestamp (oldest first, newest at bottom)\n\t// Use iterative approach to avoid stack overflow on deep trees\n\tconst stack: SessionTreeNode[] = [...roots];\n\twhile (stack.length > 0) {\n\t\tconst node = stack.pop()!;\n\t\tnode.children.sort((a, b) => new Date(a.entry.timestamp).getTime() - new Date(b.entry.timestamp).getTime());\n\t\tstack.push(...node.children);\n\t}\n\n\treturn roots;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"session-manager-history.js","sourceRoot":"","sources":["../../src/core/session-manager-history.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAwB,MAAM,0CAA0C,CAAC;AAC7G,OAAO,EACN,YAAY,EACZ,0BAA0B,EAC1B,mBAAmB,EACnB,+BAA+B,EAC/B,uBAAuB,GACvB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAYlF,4EAA4E;AAC5E,SAAS,uBAAuB,CAAC,KAAmB;IACnD,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,uBAAuB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC5E,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;QACrC,OAAO,mBA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AG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAE,CAAC;QACpC,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,IAAI,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,EAAE,EAAE,CAAC;YAC5D,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC;aAAM,CAAC;YACP,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YAC3C,IAAI,MAAM,EAAE,CAAC;gBACZ,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;iBAAM,CAAC;gBACP,yBAAyB;gBACzB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClB,CAAC;QACF,CAAC;IACF,CAAC;IAED,8DAA8D;IAC9D,+DAA+D;IAC/D,MAAM,KAAK,GAAsB,CAAC,GAAG,KAAK,CAAC,CAAC;IAC5C,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,EAAG,CAAC;QAC1B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5G,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["import type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { VerbatimCompactionDetails } from \"./compaction/compaction-types.js\";\nimport { serializeRetainedTranscript, type TranscriptChunk } from \"./compaction/transcript-serialization.js\";\nimport {\n\tconvertToLlm,\n\tcreateBranchSummaryMessage,\n\tcreateCustomMessage,\n\tcreateVerbatimCompactionMessage,\n\tnormalizeMessageContent,\n} from \"./messages.ts\";\nimport { normalizeDerivedSessionEntries } from \"./session-entry-normalization.ts\";\nimport type {\n\tCompactionEntry,\n\tContextEditEntry,\n\tFileEntry,\n\tProjectedSessionEntry,\n\tSessionContext,\n\tSessionEntry,\n\tSessionProjection,\n\tSessionTreeNode,\n} from \"./session-manager-types.ts\";\n\n/** Build the single context message a durable entry contributes, if any. */\nfunction contextMessageFromEntry(entry: SessionEntry): AgentMessage | undefined {\n\tif (entry.type === \"message\") return normalizeMessageContent(entry.message);\n\tif (entry.type === \"custom_message\") {\n\t\treturn createCustomMessage(\n\t\t\tentry.customType,\n\t\t\tentry.content,\n\t\t\tentry.display,\n\t\t\tentry.details,\n\t\t\tentry.timestamp,\n\t\t\tentry.excludeFromContext,\n\t\t\tentry.stageAdmissionKey,\n\t\t);\n\t}\n\tif (entry.type === \"branch_summary\" && typeof entry.summary === \"string\" && entry.summary.length > 0) {\n\t\treturn createBranchSummaryMessage(entry.summary, entry.fromId, entry.timestamp);\n\t}\n\treturn undefined;\n}\n\n/**\n * Serialize the kept tail into the compaction boundary's transcript grammar.\n *\n * The tail is concatenated onto the end of the boundary string instead of being\n * replayed as structured messages. A tail that starts mid-turn (a tool result whose\n * tool call was compacted away, or a trailing unanswered tool call) would otherwise\n * emit ill-ordered provider blocks and fail the request. Payloads are kept whole:\n * tool results keep their full text and images stay as image blocks, because the tail\n * is exactly the span `preserve_recent` promised to keep. Thinking is omitted, as in\n * the compacted region; the durable entries keep it, and messages after the boundary\n * replay with their thinking blocks.\n */\nfunction serializeKeptTail(entries: SessionEntry[], edits?: Map<string, ContextEditEntry>): TranscriptChunk[] {\n\tconst messages: AgentMessage[] = [];\n\tfor (const entry of entries) {\n\t\tconst message = contextMessageFromEntry(entry);\n\t\tif (!message) continue;\n\t\tconst edit = edits?.get(entry.id);\n\t\tif (edit) messages.push(...applyContextEdit([message], edit));\n\t\telse messages.push(message);\n\t}\n\tif (messages.length === 0) return [];\n\treturn serializeRetainedTranscript(convertToLlm(messages));\n}\n\n/** Index the latest context edit per target among the given entries. */\nexport function collectContextEdits(entries: readonly SessionEntry[]): Map<string, ContextEditEntry> {\n\tconst edits = new Map<string, ContextEditEntry>();\n\tfor (const entry of entries) {\n\t\tif (entry.type === \"context_edit\") edits.set(entry.targetId, entry);\n\t}\n\treturn edits;\n}\n\n/** Apply one append-only context edit to the messages an entry contributes. */\nexport function applyContextEdit(messages: AgentMessage[], edit: ContextEditEntry): AgentMessage[] {\n\tconst replacement = edit.replacement;\n\tif (replacement === null) return [];\n\n\treturn messages.map((message) => {\n\t\tif (\n\t\t\tmessage.role !== \"user\" &&\n\t\t\tmessage.role !== \"assistant\" &&\n\t\t\tmessage.role !== \"toolResult\" &&\n\t\t\tmessage.role !== \"custom\"\n\t\t) {\n\t\t\treturn message;\n\t\t}\n\t\tconst content =\n\t\t\t(message.role === \"assistant\" || message.role === \"toolResult\") && typeof replacement.content === \"string\"\n\t\t\t\t? [{ type: \"text\" as const, text: replacement.content }]\n\t\t\t\t: replacement.content;\n\t\treturn { ...message, content } as AgentMessage;\n\t});\n}\n\nfunction projectContextEntry(entry: SessionEntry, edit: ContextEditEntry | undefined): AgentMessage[] {\n\tconst messages = sessionEntryToContextMessages(entry);\n\tif (!edit) return messages;\n\treturn applyContextEdit(messages, edit);\n}\n\n/** Extract the settings (thinking level and model) recorded along a branch path. */\nfunction getSessionContextSettings(path: SessionEntry[]): {\n\tthinkingLevel: string;\n\tmodel: { provider: string; modelId: string } | null;\n} {\n\tlet thinkingLevel = \"off\";\n\tlet model: { provider: string; modelId: string } | null = null;\n\tfor (const entry of path) {\n\t\tif (entry.type === \"thinking_level_change\") {\n\t\t\tthinkingLevel = entry.thinkingLevel;\n\t\t} else if (entry.type === \"model_change\") {\n\t\t\tmodel = { provider: entry.provider, modelId: entry.modelId };\n\t\t} else if (entry.type === \"message\" && entry.message.role === \"assistant\") {\n\t\t\tmodel = { provider: entry.message.provider, modelId: entry.message.model };\n\t\t}\n\t}\n\treturn { thinkingLevel, model };\n}\n\nexport function getLatestCompactionBoundaryEntry(\n\tentries: SessionEntry[],\n): CompactionEntry<VerbatimCompactionDetails> | null {\n\tfor (let i = entries.length - 1; i >= 0; i--) {\n\t\tconst entry = entries[i];\n\t\tif (entry.type !== \"compaction\") continue;\n\t\tconst details = (entry as CompactionEntry<{ strategy?: string }>).details;\n\t\tif (details?.strategy === \"verbatim-lines\") return entry as CompactionEntry<VerbatimCompactionDetails>;\n\t}\n\treturn null;\n}\n\n/** Convert one durable session entry into the messages it contributes to model context. */\nexport function sessionEntryToContextMessages(entry: SessionEntry): AgentMessage[] {\n\tif (entry.type === \"message\") return [normalizeMessageContent(entry.message)];\n\tif (entry.type === \"custom_message\") {\n\t\treturn [\n\t\t\tcreateCustomMessage(\n\t\t\t\tentry.customType,\n\t\t\t\tentry.content,\n\t\t\t\tentry.display,\n\t\t\t\tentry.details,\n\t\t\t\tentry.timestamp,\n\t\t\t\tentry.excludeFromContext,\n\t\t\t\tentry.stageAdmissionKey,\n\t\t\t),\n\t\t];\n\t}\n\tif (entry.type === \"branch_summary\" && entry.summary.length > 0) {\n\t\treturn [createBranchSummaryMessage(entry.summary, entry.fromId, entry.timestamp)];\n\t}\n\tif (entry.type === \"compaction\") {\n\t\tconst details = (entry as CompactionEntry<{ strategy?: string }>).details;\n\t\tif (details?.strategy === \"verbatim-lines\") {\n\t\t\treturn [\n\t\t\t\t...(entry.systemMessage ? [entry.systemMessage] : []),\n\t\t\t\tcreateVerbatimCompactionMessage(\n\t\t\t\t\tentry.summary,\n\t\t\t\t\tentry.tokensBefore,\n\t\t\t\t\tentry.timestamp,\n\t\t\t\t\tentry.details as VerbatimCompactionDetails,\n\t\t\t\t),\n\t\t\t];\n\t\t}\n\t}\n\treturn [];\n}\n\n/**\n * Path index of the last entry `boundary` covers: its `coveredThroughEntryId` when that entry precedes\n * it on the path, otherwise every entry before the boundary.\n */\nfunction boundaryCoveredIndex(path: SessionEntry[], boundary: CompactionEntry, boundaryIndex: number): number {\n\tconst covered = path.findIndex(\n\t\t(entry, index) => index < boundaryIndex && entry.id === boundary.coveredThroughEntryId,\n\t);\n\treturn covered >= 0 ? covered : boundaryIndex - 1;\n}\n\n/** Return the active branch entries after applying the latest compaction boundary. */\nexport function buildContextEntries(\n\tentries: SessionEntry[],\n\tleafId?: string | null,\n\tbyId = new Map(entries.map((entry) => [entry.id, entry])),\n\tbranch?: readonly SessionEntry[],\n): SessionEntry[] {\n\tif (leafId === null) return [];\n\tconst leaf = leafId ? byId.get(leafId) : entries[entries.length - 1];\n\tif (!leaf) return [];\n\tconst path = normalizeDerivedSessionEntries(branch ?? getBranchPath(leaf.id, byId));\n\tconst boundary = getLatestCompactionBoundaryEntry(path);\n\tif (!boundary) return path;\n\tconst boundaryIndex = path.findIndex((entry) => entry.id === boundary.id);\n\tconst firstKeptIndex = path.findIndex(\n\t\t(entry, index) => index < boundaryIndex && entry.id === boundary.firstKeptEntryId,\n\t);\n\tconst retainedStart = firstKeptIndex >= 0 ? firstKeptIndex : boundaryCoveredIndex(path, boundary, boundaryIndex) + 1;\n\treturn [boundary, ...path.slice(retainedStart, boundaryIndex), ...path.slice(boundaryIndex + 1)];\n}\n\n/**\n * Build provenance-preserving, compaction-aware model context.\n *\n * Every entry on the active branch after the latest compaction boundary is projected\n * to the messages it contributes after context edits. The latest verbatim compaction\n * boundary is emitted as one custom-role text message: the compacted string with the\n * kept tail (edits applied) serialized and appended to its end, rather than the tail\n * being replayed as separate structured messages. Kept-tail entries therefore project\n * to no standalone messages of their own. Entries a background boundary does not cover\n * (after its `coveredThroughEntryId`) replay unchanged, and older boundaries among them\n * contribute nothing.\n */\nexport function buildSessionProjection(\n\tentries: SessionEntry[],\n\tleafId?: string | null,\n\tbyId?: Map<string, SessionEntry>,\n\tsessionId?: string,\n\tbranch?: readonly SessionEntry[],\n): SessionProjection {\n\t// Build uuid index if not available\n\tif (!byId) {\n\t\tbyId = new Map<string, SessionEntry>();\n\t\tfor (const entry of entries) {\n\t\t\tbyId.set(entry.id, entry);\n\t\t}\n\t}\n\n\t// Find leaf\n\tlet leaf: SessionEntry | undefined;\n\tif (leafId === null) {\n\t\t// Explicitly null - return no messages (navigated to before first entry)\n\t\treturn { entries: [], messages: [], thinkingLevel: \"off\", model: null };\n\t}\n\tif (leafId) {\n\t\tleaf = byId.get(leafId);\n\t}\n\tif (!leaf) {\n\t\t// Fallback to last entry (when leafId is undefined)\n\t\tleaf = entries[entries.length - 1];\n\t}\n\n\tif (!leaf) {\n\t\treturn { entries: [], messages: [], thinkingLevel: \"off\", model: null };\n\t}\n\n\t// Walk from leaf to root, collecting path\n\tconst walked = branch ?? getBranchPath(leaf.id, byId);\n\tconst path = normalizeDerivedSessionEntries(walked);\n\tconst { thinkingLevel, model } = getSessionContextSettings(path);\n\tconst contextEntries = buildContextEntries(entries, leaf.id, byId, walked);\n\tconst edits = collectContextEdits(contextEntries);\n\n\tconst boundary = getLatestCompactionBoundaryEntry(path);\n\tif (!boundary || boundary.details?.backend === \"summary\") {\n\t\tconst projected = contextEntries.map(\n\t\t\t(sourceEntry): ProjectedSessionEntry => ({\n\t\t\t\tsourceEntry,\n\t\t\t\tmessages:\n\t\t\t\t\tboundary && sourceEntry.type === \"compaction\" && sourceEntry.id !== boundary.id\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: projectContextEntry(sourceEntry, edits.get(sourceEntry.id)),\n\t\t\t}),\n\t\t);\n\t\treturn { entries: projected, messages: projected.flatMap((entry) => entry.messages), thinkingLevel, model };\n\t}\n\n\tconst boundaryIndex = path.findIndex((entry) => entry.id === boundary.id);\n\tconst firstKeptIndex = path.findIndex(\n\t\t(entry, index) => index < boundaryIndex && entry.id === boundary.firstKeptEntryId,\n\t);\n\tconst coveredIndex = boundaryCoveredIndex(path, boundary, boundaryIndex);\n\tconst keptTailEntries = firstKeptIndex >= 0 ? path.slice(firstKeptIndex, coveredIndex + 1) : [];\n\tconst keptTailIds = new Set(keptTailEntries.map((entry) => entry.id));\n\tconst keptTail = serializeKeptTail(keptTailEntries, edits);\n\tconst separator: TranscriptChunk[] =\n\t\tkeptTail.length > 0 && boundary.summary.length > 0 ? [{ type: \"text\", text: \"\\n\\n\" }] : [];\n\tconst boundaryMessages: AgentMessage[] = [\n\t\t...(boundary.systemMessage ? [boundary.systemMessage] : []),\n\t\tcreateVerbatimCompactionMessage(\n\t\t\tboundary.summary,\n\t\t\tboundary.tokensBefore,\n\t\t\tboundary.timestamp,\n\t\t\tboundary.details,\n\t\t\t[...separator, ...keptTail],\n\t\t\tsessionId,\n\t\t),\n\t];\n\tconst projected = contextEntries.map(\n\t\t(sourceEntry): ProjectedSessionEntry => ({\n\t\t\tsourceEntry,\n\t\t\tmessages:\n\t\t\t\tsourceEntry.id === boundary.id\n\t\t\t\t\t? boundaryMessages\n\t\t\t\t\t: keptTailIds.has(sourceEntry.id) || sourceEntry.type === \"compaction\"\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: projectContextEntry(sourceEntry, edits.get(sourceEntry.id)),\n\t\t}),\n\t);\n\treturn { entries: projected, messages: projected.flatMap((entry) => entry.messages), thinkingLevel, model };\n}\n\n/**\n * Build the session context from entries using tree traversal.\n * If leafId is provided, walks from that entry to root.\n * Emits the latest verbatim compaction boundary as one custom-role text message: the\n * compacted string with the kept tail serialized and appended to its end, rather than\n * the tail being replayed as separate structured messages.\n */\nexport function buildSessionContext(\n\tentries: SessionEntry[],\n\tleafId?: string | null,\n\tbyId?: Map<string, SessionEntry>,\n): SessionContext {\n\tconst { messages, thinkingLevel, model } = buildSessionProjection(entries, leafId, byId);\n\treturn { messages, thinkingLevel, model };\n}\n\n/**\n * `customType` of the entry that records a leaf move made without a new entry, such as `/tree` without a summary. It is\n * a child of the new leaf and never a leaf itself, so it adds nothing to the context and a reader that takes the last\n * entry as the leaf still follows the selected branch (#3325).\n */\nexport const LEAF_MOVE_ENTRY_TYPE = \"atomic.leaf\";\n\nexport function isLeafMoveEntry(entry: SessionEntry): boolean {\n\treturn entry.type === \"custom\" && entry.customType === LEAF_MOVE_ENTRY_TYPE;\n}\n\nexport interface SessionIndex {\n\tbyId: Map<string, SessionEntry>;\n\tlabelsById: Map<string, string>;\n\tlabelTimestampsById: Map<string, string>;\n\tleafId: string | null;\n}\n\nexport function buildSessionIndex(fileEntries: readonly FileEntry[]): SessionIndex {\n\tconst byId = new Map<string, SessionEntry>();\n\tconst labelsById = new Map<string, string>();\n\tconst labelTimestampsById = new Map<string, string>();\n\tlet leafId: string | null = null;\n\n\tfor (const entry of fileEntries) {\n\t\tif (entry.type === \"session\") continue;\n\t\tbyId.set(entry.id, entry);\n\t\tleafId = entry.id;\n\t\tif (entry.type === \"label\") {\n\t\t\tif (entry.label) {\n\t\t\t\tlabelsById.set(entry.targetId, entry.label);\n\t\t\t\tlabelTimestampsById.set(entry.targetId, entry.timestamp);\n\t\t\t} else {\n\t\t\t\tlabelsById.delete(entry.targetId);\n\t\t\t\tlabelTimestampsById.delete(entry.targetId);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst last = leafId === null ? undefined : byId.get(leafId);\n\tif (last && isLeafMoveEntry(last)) leafId = last.parentId;\n\treturn { byId, labelsById, labelTimestampsById, leafId };\n}\n\n/**\n * The entry a session continues from when it is opened: its last entry, or the entry a recorded leaf move selected\n * (#3325). `null` when the session continues from before its first entry.\n */\nexport function getSessionLeafId(entries: readonly SessionEntry[]): string | null {\n\treturn buildSessionIndex(entries).leafId;\n}\n\nexport function getBranchPath(\n\tfromId: string | null | undefined,\n\tbyId: ReadonlyMap<string, SessionEntry>,\n): SessionEntry[] {\n\tconst path: SessionEntry[] = [];\n\tlet current = fromId ? byId.get(fromId) : undefined;\n\twhile (current) {\n\t\tpath.push(current);\n\t\tcurrent = current.parentId ? byId.get(current.parentId) : undefined;\n\t}\n\tpath.reverse();\n\treturn path;\n}\n\nexport function buildSessionTree(\n\tentries: SessionEntry[],\n\tlabelsById: ReadonlyMap<string, string>,\n\tlabelTimestampsById: ReadonlyMap<string, string>,\n): SessionTreeNode[] {\n\tconst nodeMap = new Map<string, SessionTreeNode>();\n\tconst roots: SessionTreeNode[] = [];\n\n\t// Create nodes with resolved labels. A recorded leaf move is bookkeeping, not a node of the tree.\n\tentries = entries.filter((entry) => !isLeafMoveEntry(entry));\n\tfor (const entry of entries) {\n\t\tconst label = labelsById.get(entry.id);\n\t\tconst labelTimestamp = labelTimestampsById.get(entry.id);\n\t\tnodeMap.set(entry.id, { entry, children: [], label, labelTimestamp });\n\t}\n\n\t// Build tree\n\tfor (const entry of entries) {\n\t\tconst node = nodeMap.get(entry.id)!;\n\t\tif (entry.parentId === null || entry.parentId === entry.id) {\n\t\t\troots.push(node);\n\t\t} else {\n\t\t\tconst parent = nodeMap.get(entry.parentId);\n\t\t\tif (parent) {\n\t\t\t\tparent.children.push(node);\n\t\t\t} else {\n\t\t\t\t// Orphan - treat as root\n\t\t\t\troots.push(node);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Sort children by timestamp (oldest first, newest at bottom)\n\t// Use iterative approach to avoid stack overflow on deep trees\n\tconst stack: SessionTreeNode[] = [...roots];\n\twhile (stack.length > 0) {\n\t\tconst node = stack.pop()!;\n\t\tnode.children.sort((a, b) => new Date(a.entry.timestamp).getTime() - new Date(b.entry.timestamp).getTime());\n\t\tstack.push(...node.children);\n\t}\n\n\treturn roots;\n}\n"]}
|
|
@@ -3,7 +3,7 @@ import type { AgentMessage } from "@earendil-works/pi-agent-core";
|
|
|
3
3
|
import type { CustomMessage } from "./messages.ts";
|
|
4
4
|
import type { SessionManager } from "./session-manager-core.ts";
|
|
5
5
|
import { type SessionRecordHeader } from "./storage/session/types.js";
|
|
6
|
-
import type { WorktreeRestoreWarning, WorktreeRootMapping, WorktreeSnapshot } from "./worktree-snapshot/types.ts";
|
|
6
|
+
import type { WorktreeRestoreWarning, WorktreeRootMapping, WorktreeSnapshot, WorktreeUnrestored } from "./worktree-snapshot/types.ts";
|
|
7
7
|
/** A restore warning that depends on the host and the moment of the restore rather than on the snapshot. */
|
|
8
8
|
export type WorktreeRestoreHostWarning = Extract<WorktreeRestoreWarning, {
|
|
9
9
|
readonly code: "lfs-objects-unavailable" | "stale-restore-retained";
|
|
@@ -228,6 +228,8 @@ export interface WorktreeSnapshotEntry extends SessionEntryBase {
|
|
|
228
228
|
restore?: WorktreeRootMapping;
|
|
229
229
|
/** What the restore in `restore` reported that its snapshot record cannot reproduce: LFS objects it could not fetch, and leftovers of interrupted restores on this host. */
|
|
230
230
|
restoreWarnings?: WorktreeRestoreHostWarning[];
|
|
231
|
+
/** Present on the entry written when a resume continued without restoring this checkout (#4733). */
|
|
232
|
+
unrestored?: WorktreeUnrestored;
|
|
231
233
|
/**
|
|
232
234
|
* Base64 patch and bundle content by SHA-256, carried by exported session files so a moved file is complete.
|
|
233
235
|
* Import verifies each hash and moves the content into the store's blob table.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-manager-types.d.ts","sourceRoot":"","sources":["../../src/core/session-manager-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,KAAK,EACL,WAAW,EACX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAA0B,KAAK,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAC9F,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"session-manager-types.d.ts","sourceRoot":"","sources":["../../src/core/session-manager-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,gBAAgB,EAChB,YAAY,EACZ,aAAa,E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C3D,YAAY,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;CAC1D;AAED,MAAM,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,SAAS,WAAW,EAAE,KAAK,IAAI,CAAC;AAEpH,MAAM,MAAM,sBAAsB,GAAG,IAAI,CACxC,cAAc,EACZ,QAAQ,GACR,eAAe,GACf,uBAAuB,GACvB,cAAc,GACd,iBAAiB,GACjB,gBAAgB,GAChB,WAAW,GACX,cAAc,GACd,UAAU,GACV,UAAU,GACV,WAAW,GACX,qBAAqB,GACrB,wBAAwB,GACxB,WAAW,GACX,YAAY,GACZ,SAAS,GACT,gBAAgB,GAChB,qBAAqB,GACrB,yBAAyB,CAC3B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-manager-types.js","sourceRoot":"","sources":["../../src/core/session-manager-types.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,sBAAsB,EAA4B,MAAM,4BAA4B,CAAC;AAS9F,MAAM,CAAC,MAAM,uBAAuB,GAAG,sBAAsB,CAAC","sourcesContent":["import type {\n\tAssistantMessage,\n\tImageContent,\n\tSystemMessage,\n\tTextContent,\n\tToolResultMessage,\n\tUsage,\n\tUserMessage,\n} from \"@bastani/pi-ai/compat\";\nimport type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { CustomMessage } from \"./messages.ts\";\nimport type { SessionManager } from \"./session-manager-core.ts\";\nimport { SESSION_FORMAT_VERSION, type SessionRecordHeader } from \"./storage/session/types.js\";\nimport type { WorktreeRestoreWarning, WorktreeRootMapping, WorktreeSnapshot } from \"./worktree-snapshot/types.ts\";\n\n/** A restore warning that depends on the host and the moment of the restore rather than on the snapshot. */\nexport type WorktreeRestoreHostWarning = Extract<\n\tWorktreeRestoreWarning,\n\t{ readonly code: \"lfs-objects-unavailable\" | \"stale-restore-retained\" }\n>;\n\nexport const CURRENT_SESSION_VERSION = SESSION_FORMAT_VERSION;\n\n/**\n * Workflow linkage persisted on internal (workflow-created) session headers.\n * Used to exclude workflow stage sessions from the standard `/resume` history\n * while keeping them resumable through the workflow-specific resume path.\n */\nexport interface SessionWorkflowMetadata {\n\trunId: string;\n\tstageId: string;\n\tstageName: string;\n}\n\nexport interface SessionHeader extends SessionRecordHeader {\n\ttype: \"session\";\n}\n\nexport interface NewSessionOptions {\n\tid?: string;\n\tparentSession?: string;\n\t/** Mark the new session as internal (e.g. a workflow stage session). */\n\tinternal?: boolean;\n\t/** Workflow run/stage linkage for internal workflow sessions. */\n\tworkflow?: SessionWorkflowMetadata;\n}\n\nexport interface SessionEntryBase {\n\ttype: string;\n\tid: string;\n\tparentId: string | null;\n\ttimestamp: string;\n}\n\nexport interface SessionMessageEntry extends SessionEntryBase {\n\ttype: \"message\";\n\tmessage: AgentMessage;\n}\n\nexport interface ThinkingLevelChangeEntry extends SessionEntryBase {\n\ttype: \"thinking_level_change\";\n\tthinkingLevel: string;\n}\n\n/** Why a model fallback moved a session off the model its turn asked for. */\nexport interface ModelFallbackRecord {\n\t/** The model the turn was asked to run on, as `provider/model`. */\n\trequested: string;\n\t/** The model that failed, as `provider/model`. */\n\tfrom: string;\n\t/** The failure that moved the session on. */\n\treason: string;\n}\n\nexport interface ModelChangeEntry extends SessionEntryBase {\n\ttype: \"model_change\";\n\tprovider: string;\n\tmodelId: string;\n\t/** Present when a model fallback made this change. */\n\tfallback?: ModelFallbackRecord;\n}\n\nexport interface UsageEntry extends SessionEntryBase {\n\ttype: \"usage\";\n\tkind: string;\n\tprovider: string;\n\tmodel: string;\n\tusage: Usage;\n\tnote?: string;\n}\n\n/** Durable compaction boundary. Active entries carry `details.strategy === \"verbatim-lines\"`. */\nexport interface CompactionEntry<T = unknown> extends SessionEntryBase {\n\ttype: \"compaction\";\n\tsummary: string;\n\t/** First context-visible tail entry, or null when the durable summary replaces the entire pre-boundary transcript. */\n\tfirstKeptEntryId: string | null;\n\ttokensBefore: number;\n\t/**\n\t * Last entry the boundary covers, when a background compaction committed it after more entries were\n\t * appended. Entries after it and before the boundary replay unchanged. Absent: the boundary covers\n\t * every entry before it.\n\t */\n\tcoveredThroughEntryId?: string;\n\tdetails?: T;\n\t/** Aggregate usage from model calls that produced this boundary. */\n\tusage?: Usage;\n\t/** True when the compacted text was supplied by an extension hook. */\n\tfromHook?: boolean;\n\t/** Replayed system instructions and tool state at this boundary. */\n\tsystemMessage?: SystemMessage;\n}\n\n/** @deprecated Legacy archival statistics; never produced or applied. */\nexport interface ContextCompactionStats {\n\tobjectsBefore: number;\n\tobjectsAfter: number;\n\tobjectsDeleted: number;\n\ttokensBefore: number;\n\ttokensAfter: number;\n\tpercentReduction: number;\n}\n\n/** @deprecated Legacy archival record; never produced or applied. */\nexport interface ContextCompactionEntry extends SessionEntryBase {\n\ttype: \"context_compaction\";\n\tpromptVersion: 1;\n\tdeletedTargets: Array<\n\t\t{ kind: \"entry\"; entryId: string } | { kind: \"content_block\"; entryId: string; blockIndex: number }\n\t>;\n\tprotectedEntryIds: string[];\n\tstats: ContextCompactionStats;\n\tbackupPath?: string;\n}\n\nexport interface BranchSummaryEntry<T = unknown> extends SessionEntryBase {\n\ttype: \"branch_summary\";\n\tfromId: string;\n\tsummary: string;\n\t/** Extension-specific data (not sent to LLM) */\n\tdetails?: T;\n\t/** Usage from the model call that generated this summary. */\n\tusage?: Usage;\n\t/** True if generated by an extension, false if generated by Atomic. */\n\tfromHook?: boolean;\n}\n\n/**\n * Custom entry for extensions to store extension-specific data in the session.\n * Use customType to identify your extension's entries.\n *\n * Purpose: Persist extension state across session reloads. On reload, extensions can\n * scan entries for their customType and reconstruct internal state.\n *\n * Does NOT participate in LLM context (ignored by buildSessionContext).\n * For injecting content into context, see CustomMessageEntry.\n */\nexport interface CustomEntry<T = unknown> extends SessionEntryBase {\n\ttype: \"custom\";\n\tcustomType: string;\n\tdata?: T;\n}\n\n/** Label entry for user-defined bookmarks/markers on entries. */\nexport interface LabelEntry extends SessionEntryBase {\n\ttype: \"label\";\n\ttargetId: string;\n\tlabel: string | undefined;\n}\n\n/** Session metadata entry (e.g., user-defined display name). */\nexport interface SessionInfoEntry extends SessionEntryBase {\n\ttype: \"session_info\";\n\tname?: string;\n}\n\n/**\n * Session name read state, mirroring pi's has_session_name / session_name pair\n * (upstream 7bdb16c2): the fact that a session was ever named is separate from the\n * name it currently holds. The distinction is already durable in the JSONL — a clear\n * appends a `session_info` entry with an empty name, a never-named session has none —\n * so this is a read-side shape, not a storage change.\n *\n * - `{ hasName: false }` — no `session_info` entry exists; the session was never named.\n * - `{ hasName: true }` — the latest `session_info` entry has an empty name; the session\n * was named and then cleared.\n * - `{ hasName: true, name: \"…\" }` — the session currently holds this name.\n */\nexport interface SessionNameState {\n\t/** True when a `session_info` entry exists, even if its latest name is empty (cleared). */\n\thasName: boolean;\n\t/** Current name. Undefined for both a cleared and a never-named session. */\n\tname?: string;\n}\n\n/** Session summary metadata entry. */\nexport interface SessionSummaryEntry extends SessionEntryBase {\n\ttype: \"session_summary\";\n\tsummary: string;\n\tsummarizedThroughId: string;\n\tusage?: Usage;\n}\n\n/**\n * Custom message entry for extensions to inject messages into LLM context.\n * Use customType to identify your extension's entries.\n *\n * Unlike CustomEntry, this usually participates in LLM context.\n * The content is converted to a user message in buildSessionContext() unless\n * excludeFromContext is true. Use details for extension-specific metadata (not sent to LLM).\n *\n * display controls TUI rendering:\n * - false: hidden entirely\n * - true: rendered with distinct styling (different from user messages)\n */\nexport interface ProtectedReconciliationMarker {\n\tdelivery: \"steer\" | \"followUp\";\n}\n\nexport interface CustomMessageEntry<T = unknown> extends SessionEntryBase {\n\ttype: \"custom_message\";\n\tcustomType: string;\n\tcontent: string | (TextContent | ImageContent)[];\n\tdetails?: T;\n\tdisplay: boolean;\n\texcludeFromContext?: boolean;\n\t/** Stable producer identity used by workflow stages to de-nominate admitted external turns. */\n\tstageAdmissionKey?: string;\n\t/** Runtime provenance used to distinguish stage continuation from an externally triggered response. */\n\t/** Internal crash-recovery marker for a model-facing protected turn. */\n\tprotectedReconciliation?: ProtectedReconciliationMarker;\n}\n\n/** Content that an append-only context edit may replace without changing message metadata. */\nexport type ContextEditableContent =\n\t| UserMessage[\"content\"]\n\t| AssistantMessage[\"content\"]\n\t| ToolResultMessage[\"content\"]\n\t| CustomMessage[\"content\"];\n\n/** Append-only change to one earlier entry's contribution to model context. */\nexport interface ContextEditEntry extends SessionEntryBase {\n\ttype: \"context_edit\";\n\ttargetId: string;\n\t/** Null omits the target from model context. A value replaces only its content. */\n\treplacement: { content: ContextEditableContent } | null;\n}\n\n/**\n * The repository state of one checkout at the end of a turn that ran a file-writing tool. `snapshot` is present when\n * the state changed; an entry without it refers to the earlier entry whose snapshot has the same `snapshotId`.\n * `restore` marks the entry written when that snapshot was restored on this host into `root`.\n */\nexport interface WorktreeSnapshotEntry extends SessionEntryBase {\n\ttype: \"worktree_snapshot\";\n\troot: string;\n\tsnapshotId: string;\n\tsnapshot?: WorktreeSnapshot;\n\trestore?: WorktreeRootMapping;\n\t/** What the restore in `restore` reported that its snapshot record cannot reproduce: LFS objects it could not fetch, and leftovers of interrupted restores on this host. */\n\trestoreWarnings?: WorktreeRestoreHostWarning[];\n\t/**\n\t * Base64 patch and bundle content by SHA-256, carried by exported session files so a moved file is complete.\n\t * Import verifies each hash and moves the content into the store's blob table.\n\t */\n\tblobs?: Record<string, string>;\n}\n\n/** Session entry - has id/parentId for tree structure (returned by \"read\" methods in SessionManager) */\nexport type SessionEntry =\n\t| SessionMessageEntry\n\t| ThinkingLevelChangeEntry\n\t| ModelChangeEntry\n\t| UsageEntry\n\t| CompactionEntry\n\t| ContextCompactionEntry\n\t| BranchSummaryEntry\n\t| CustomEntry\n\t| CustomMessageEntry\n\t| ContextEditEntry\n\t| LabelEntry\n\t| SessionInfoEntry\n\t| SessionSummaryEntry\n\t| WorktreeSnapshotEntry;\n\n/** Raw file entry (includes header) */\nexport type FileEntry = SessionHeader | SessionEntry;\n\n/** Tree node for getTree() - defensive copy of session structure */\nexport interface SessionTreeNode {\n\tentry: SessionEntry;\n\tchildren: SessionTreeNode[];\n\t/** Resolved label for this entry, if any */\n\tlabel?: string;\n\t/** Timestamp of the latest label change for this entry, if any */\n\tlabelTimestamp?: string;\n}\n\nexport interface ProjectedSessionEntry {\n\t/** Raw append-only entry that owns this projected contribution. */\n\tsourceEntry: SessionEntry;\n\t/** Model-visible messages after context edits. Empty for state-only entries and omissions. */\n\tmessages: AgentMessage[];\n}\n\nexport interface SessionProjection {\n\tentries: ProjectedSessionEntry[];\n\tmessages: AgentMessage[];\n\tthinkingLevel: string;\n\tmodel: { provider: string; modelId: string } | null;\n}\n\nexport interface SessionContext {\n\tmessages: AgentMessage[];\n\tthinkingLevel: string;\n\tmodel: { provider: string; modelId: string } | null;\n}\n\nexport interface SessionInfo {\n\tpath: string;\n\tid: string;\n\t/** Working directory where the session was started. Empty string for old sessions. */\n\tcwd: string;\n\t/**\n\t * User-defined display name from session_info entries. Undefined both for a\n\t * never-named session and for one whose name was cleared; `hasName` separates them.\n\t */\n\tname?: string;\n\t/** True when a session_info entry exists, even if the name was later cleared. */\n\thasName?: boolean;\n\t/** Path to the parent session (if this session was forked). */\n\tparentSessionPath?: string;\n\t/** True when this session was created by automated machinery (e.g. a workflow stage). */\n\tinternal?: boolean;\n\t/** Workflow run/stage linkage when the session is an internal workflow session. */\n\tworkflow?: SessionWorkflowMetadata;\n\tcreated: Date;\n\tmodified: Date;\n\tmessageCount: number;\n\tfirstMessage: string;\n\t/** Latest stored generated resume summary. */\n\tsummary?: string;\n\tsummarizedThroughId?: string;\n\tallMessagesText: string;\n\t/** Optional semantic color for synthetic selector rows. */\n\tmessageColor?: \"success\" | \"warning\" | \"accent\" | \"error\";\n}\n\nexport type SessionListProgress = (loaded: number, total: number, partialSessions?: readonly SessionInfo[]) => void;\n\nexport type ReadonlySessionManager = Pick<\n\tSessionManager,\n\t| \"getCwd\"\n\t| \"getSessionDir\"\n\t| \"usesDefaultSessionDir\"\n\t| \"getSessionId\"\n\t| \"getSessionStore\"\n\t| \"getSessionFile\"\n\t| \"getLeafId\"\n\t| \"getLeafEntry\"\n\t| \"getEntry\"\n\t| \"getLabel\"\n\t| \"getBranch\"\n\t| \"buildContextEntries\"\n\t| \"buildSessionProjection\"\n\t| \"getHeader\"\n\t| \"getEntries\"\n\t| \"getTree\"\n\t| \"getSessionName\"\n\t| \"getSessionNameState\"\n\t| \"getWorktreeRootMappings\"\n>;\n"]}
|
|
1
|
+
{"version":3,"file":"session-manager-types.js","sourceRoot":"","sources":["../../src/core/session-manager-types.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,sBAAsB,EAA4B,MAAM,4BAA4B,CAAC;AAc9F,MAAM,CAAC,MAAM,uBAAuB,GAAG,sBAAsB,CAAC","sourcesContent":["import type {\n\tAssistantMessage,\n\tImageContent,\n\tSystemMessage,\n\tTextContent,\n\tToolResultMessage,\n\tUsage,\n\tUserMessage,\n} from \"@bastani/pi-ai/compat\";\nimport type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { CustomMessage } from \"./messages.ts\";\nimport type { SessionManager } from \"./session-manager-core.ts\";\nimport { SESSION_FORMAT_VERSION, type SessionRecordHeader } from \"./storage/session/types.js\";\nimport type {\n\tWorktreeRestoreWarning,\n\tWorktreeRootMapping,\n\tWorktreeSnapshot,\n\tWorktreeUnrestored,\n} from \"./worktree-snapshot/types.ts\";\n\n/** A restore warning that depends on the host and the moment of the restore rather than on the snapshot. */\nexport type WorktreeRestoreHostWarning = Extract<\n\tWorktreeRestoreWarning,\n\t{ readonly code: \"lfs-objects-unavailable\" | \"stale-restore-retained\" }\n>;\n\nexport const CURRENT_SESSION_VERSION = SESSION_FORMAT_VERSION;\n\n/**\n * Workflow linkage persisted on internal (workflow-created) session headers.\n * Used to exclude workflow stage sessions from the standard `/resume` history\n * while keeping them resumable through the workflow-specific resume path.\n */\nexport interface SessionWorkflowMetadata {\n\trunId: string;\n\tstageId: string;\n\tstageName: string;\n}\n\nexport interface SessionHeader extends SessionRecordHeader {\n\ttype: \"session\";\n}\n\nexport interface NewSessionOptions {\n\tid?: string;\n\tparentSession?: string;\n\t/** Mark the new session as internal (e.g. a workflow stage session). */\n\tinternal?: boolean;\n\t/** Workflow run/stage linkage for internal workflow sessions. */\n\tworkflow?: SessionWorkflowMetadata;\n}\n\nexport interface SessionEntryBase {\n\ttype: string;\n\tid: string;\n\tparentId: string | null;\n\ttimestamp: string;\n}\n\nexport interface SessionMessageEntry extends SessionEntryBase {\n\ttype: \"message\";\n\tmessage: AgentMessage;\n}\n\nexport interface ThinkingLevelChangeEntry extends SessionEntryBase {\n\ttype: \"thinking_level_change\";\n\tthinkingLevel: string;\n}\n\n/** Why a model fallback moved a session off the model its turn asked for. */\nexport interface ModelFallbackRecord {\n\t/** The model the turn was asked to run on, as `provider/model`. */\n\trequested: string;\n\t/** The model that failed, as `provider/model`. */\n\tfrom: string;\n\t/** The failure that moved the session on. */\n\treason: string;\n}\n\nexport interface ModelChangeEntry extends SessionEntryBase {\n\ttype: \"model_change\";\n\tprovider: string;\n\tmodelId: string;\n\t/** Present when a model fallback made this change. */\n\tfallback?: ModelFallbackRecord;\n}\n\nexport interface UsageEntry extends SessionEntryBase {\n\ttype: \"usage\";\n\tkind: string;\n\tprovider: string;\n\tmodel: string;\n\tusage: Usage;\n\tnote?: string;\n}\n\n/** Durable compaction boundary. Active entries carry `details.strategy === \"verbatim-lines\"`. */\nexport interface CompactionEntry<T = unknown> extends SessionEntryBase {\n\ttype: \"compaction\";\n\tsummary: string;\n\t/** First context-visible tail entry, or null when the durable summary replaces the entire pre-boundary transcript. */\n\tfirstKeptEntryId: string | null;\n\ttokensBefore: number;\n\t/**\n\t * Last entry the boundary covers, when a background compaction committed it after more entries were\n\t * appended. Entries after it and before the boundary replay unchanged. Absent: the boundary covers\n\t * every entry before it.\n\t */\n\tcoveredThroughEntryId?: string;\n\tdetails?: T;\n\t/** Aggregate usage from model calls that produced this boundary. */\n\tusage?: Usage;\n\t/** True when the compacted text was supplied by an extension hook. */\n\tfromHook?: boolean;\n\t/** Replayed system instructions and tool state at this boundary. */\n\tsystemMessage?: SystemMessage;\n}\n\n/** @deprecated Legacy archival statistics; never produced or applied. */\nexport interface ContextCompactionStats {\n\tobjectsBefore: number;\n\tobjectsAfter: number;\n\tobjectsDeleted: number;\n\ttokensBefore: number;\n\ttokensAfter: number;\n\tpercentReduction: number;\n}\n\n/** @deprecated Legacy archival record; never produced or applied. */\nexport interface ContextCompactionEntry extends SessionEntryBase {\n\ttype: \"context_compaction\";\n\tpromptVersion: 1;\n\tdeletedTargets: Array<\n\t\t{ kind: \"entry\"; entryId: string } | { kind: \"content_block\"; entryId: string; blockIndex: number }\n\t>;\n\tprotectedEntryIds: string[];\n\tstats: ContextCompactionStats;\n\tbackupPath?: string;\n}\n\nexport interface BranchSummaryEntry<T = unknown> extends SessionEntryBase {\n\ttype: \"branch_summary\";\n\tfromId: string;\n\tsummary: string;\n\t/** Extension-specific data (not sent to LLM) */\n\tdetails?: T;\n\t/** Usage from the model call that generated this summary. */\n\tusage?: Usage;\n\t/** True if generated by an extension, false if generated by Atomic. */\n\tfromHook?: boolean;\n}\n\n/**\n * Custom entry for extensions to store extension-specific data in the session.\n * Use customType to identify your extension's entries.\n *\n * Purpose: Persist extension state across session reloads. On reload, extensions can\n * scan entries for their customType and reconstruct internal state.\n *\n * Does NOT participate in LLM context (ignored by buildSessionContext).\n * For injecting content into context, see CustomMessageEntry.\n */\nexport interface CustomEntry<T = unknown> extends SessionEntryBase {\n\ttype: \"custom\";\n\tcustomType: string;\n\tdata?: T;\n}\n\n/** Label entry for user-defined bookmarks/markers on entries. */\nexport interface LabelEntry extends SessionEntryBase {\n\ttype: \"label\";\n\ttargetId: string;\n\tlabel: string | undefined;\n}\n\n/** Session metadata entry (e.g., user-defined display name). */\nexport interface SessionInfoEntry extends SessionEntryBase {\n\ttype: \"session_info\";\n\tname?: string;\n}\n\n/**\n * Session name read state, mirroring pi's has_session_name / session_name pair\n * (upstream 7bdb16c2): the fact that a session was ever named is separate from the\n * name it currently holds. The distinction is already durable in the JSONL — a clear\n * appends a `session_info` entry with an empty name, a never-named session has none —\n * so this is a read-side shape, not a storage change.\n *\n * - `{ hasName: false }` — no `session_info` entry exists; the session was never named.\n * - `{ hasName: true }` — the latest `session_info` entry has an empty name; the session\n * was named and then cleared.\n * - `{ hasName: true, name: \"…\" }` — the session currently holds this name.\n */\nexport interface SessionNameState {\n\t/** True when a `session_info` entry exists, even if its latest name is empty (cleared). */\n\thasName: boolean;\n\t/** Current name. Undefined for both a cleared and a never-named session. */\n\tname?: string;\n}\n\n/** Session summary metadata entry. */\nexport interface SessionSummaryEntry extends SessionEntryBase {\n\ttype: \"session_summary\";\n\tsummary: string;\n\tsummarizedThroughId: string;\n\tusage?: Usage;\n}\n\n/**\n * Custom message entry for extensions to inject messages into LLM context.\n * Use customType to identify your extension's entries.\n *\n * Unlike CustomEntry, this usually participates in LLM context.\n * The content is converted to a user message in buildSessionContext() unless\n * excludeFromContext is true. Use details for extension-specific metadata (not sent to LLM).\n *\n * display controls TUI rendering:\n * - false: hidden entirely\n * - true: rendered with distinct styling (different from user messages)\n */\nexport interface ProtectedReconciliationMarker {\n\tdelivery: \"steer\" | \"followUp\";\n}\n\nexport interface CustomMessageEntry<T = unknown> extends SessionEntryBase {\n\ttype: \"custom_message\";\n\tcustomType: string;\n\tcontent: string | (TextContent | ImageContent)[];\n\tdetails?: T;\n\tdisplay: boolean;\n\texcludeFromContext?: boolean;\n\t/** Stable producer identity used by workflow stages to de-nominate admitted external turns. */\n\tstageAdmissionKey?: string;\n\t/** Runtime provenance used to distinguish stage continuation from an externally triggered response. */\n\t/** Internal crash-recovery marker for a model-facing protected turn. */\n\tprotectedReconciliation?: ProtectedReconciliationMarker;\n}\n\n/** Content that an append-only context edit may replace without changing message metadata. */\nexport type ContextEditableContent =\n\t| UserMessage[\"content\"]\n\t| AssistantMessage[\"content\"]\n\t| ToolResultMessage[\"content\"]\n\t| CustomMessage[\"content\"];\n\n/** Append-only change to one earlier entry's contribution to model context. */\nexport interface ContextEditEntry extends SessionEntryBase {\n\ttype: \"context_edit\";\n\ttargetId: string;\n\t/** Null omits the target from model context. A value replaces only its content. */\n\treplacement: { content: ContextEditableContent } | null;\n}\n\n/**\n * The repository state of one checkout at the end of a turn that ran a file-writing tool. `snapshot` is present when\n * the state changed; an entry without it refers to the earlier entry whose snapshot has the same `snapshotId`.\n * `restore` marks the entry written when that snapshot was restored on this host into `root`.\n */\nexport interface WorktreeSnapshotEntry extends SessionEntryBase {\n\ttype: \"worktree_snapshot\";\n\troot: string;\n\tsnapshotId: string;\n\tsnapshot?: WorktreeSnapshot;\n\trestore?: WorktreeRootMapping;\n\t/** What the restore in `restore` reported that its snapshot record cannot reproduce: LFS objects it could not fetch, and leftovers of interrupted restores on this host. */\n\trestoreWarnings?: WorktreeRestoreHostWarning[];\n\t/** Present on the entry written when a resume continued without restoring this checkout (#4733). */\n\tunrestored?: WorktreeUnrestored;\n\t/**\n\t * Base64 patch and bundle content by SHA-256, carried by exported session files so a moved file is complete.\n\t * Import verifies each hash and moves the content into the store's blob table.\n\t */\n\tblobs?: Record<string, string>;\n}\n\n/** Session entry - has id/parentId for tree structure (returned by \"read\" methods in SessionManager) */\nexport type SessionEntry =\n\t| SessionMessageEntry\n\t| ThinkingLevelChangeEntry\n\t| ModelChangeEntry\n\t| UsageEntry\n\t| CompactionEntry\n\t| ContextCompactionEntry\n\t| BranchSummaryEntry\n\t| CustomEntry\n\t| CustomMessageEntry\n\t| ContextEditEntry\n\t| LabelEntry\n\t| SessionInfoEntry\n\t| SessionSummaryEntry\n\t| WorktreeSnapshotEntry;\n\n/** Raw file entry (includes header) */\nexport type FileEntry = SessionHeader | SessionEntry;\n\n/** Tree node for getTree() - defensive copy of session structure */\nexport interface SessionTreeNode {\n\tentry: SessionEntry;\n\tchildren: SessionTreeNode[];\n\t/** Resolved label for this entry, if any */\n\tlabel?: string;\n\t/** Timestamp of the latest label change for this entry, if any */\n\tlabelTimestamp?: string;\n}\n\nexport interface ProjectedSessionEntry {\n\t/** Raw append-only entry that owns this projected contribution. */\n\tsourceEntry: SessionEntry;\n\t/** Model-visible messages after context edits. Empty for state-only entries and omissions. */\n\tmessages: AgentMessage[];\n}\n\nexport interface SessionProjection {\n\tentries: ProjectedSessionEntry[];\n\tmessages: AgentMessage[];\n\tthinkingLevel: string;\n\tmodel: { provider: string; modelId: string } | null;\n}\n\nexport interface SessionContext {\n\tmessages: AgentMessage[];\n\tthinkingLevel: string;\n\tmodel: { provider: string; modelId: string } | null;\n}\n\nexport interface SessionInfo {\n\tpath: string;\n\tid: string;\n\t/** Working directory where the session was started. Empty string for old sessions. */\n\tcwd: string;\n\t/**\n\t * User-defined display name from session_info entries. Undefined both for a\n\t * never-named session and for one whose name was cleared; `hasName` separates them.\n\t */\n\tname?: string;\n\t/** True when a session_info entry exists, even if the name was later cleared. */\n\thasName?: boolean;\n\t/** Path to the parent session (if this session was forked). */\n\tparentSessionPath?: string;\n\t/** True when this session was created by automated machinery (e.g. a workflow stage). */\n\tinternal?: boolean;\n\t/** Workflow run/stage linkage when the session is an internal workflow session. */\n\tworkflow?: SessionWorkflowMetadata;\n\tcreated: Date;\n\tmodified: Date;\n\tmessageCount: number;\n\tfirstMessage: string;\n\t/** Latest stored generated resume summary. */\n\tsummary?: string;\n\tsummarizedThroughId?: string;\n\tallMessagesText: string;\n\t/** Optional semantic color for synthetic selector rows. */\n\tmessageColor?: \"success\" | \"warning\" | \"accent\" | \"error\";\n}\n\nexport type SessionListProgress = (loaded: number, total: number, partialSessions?: readonly SessionInfo[]) => void;\n\nexport type ReadonlySessionManager = Pick<\n\tSessionManager,\n\t| \"getCwd\"\n\t| \"getSessionDir\"\n\t| \"usesDefaultSessionDir\"\n\t| \"getSessionId\"\n\t| \"getSessionStore\"\n\t| \"getSessionFile\"\n\t| \"getLeafId\"\n\t| \"getLeafEntry\"\n\t| \"getEntry\"\n\t| \"getLabel\"\n\t| \"getBranch\"\n\t| \"buildContextEntries\"\n\t| \"buildSessionProjection\"\n\t| \"getHeader\"\n\t| \"getEntries\"\n\t| \"getTree\"\n\t| \"getSessionName\"\n\t| \"getSessionNameState\"\n\t| \"getWorktreeRootMappings\"\n>;\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type { VerbatimCompactionDetails } from "./compaction/compaction-types.js";
|
|
2
2
|
export { SessionManager } from "./session-manager-core.ts";
|
|
3
3
|
export { SessionEntryError, SessionIdError } from "./session-manager-errors.js";
|
|
4
|
-
export { buildContextEntries, buildSessionContext, buildSessionProjection, getLatestCompactionBoundaryEntry, sessionEntryToContextMessages, } from "./session-manager-history.ts";
|
|
4
|
+
export { buildContextEntries, buildSessionContext, buildSessionProjection, getLatestCompactionBoundaryEntry, getSessionLeafId, sessionEntryToContextMessages, } from "./session-manager-history.ts";
|
|
5
5
|
export { getDefaultSessionDir, getDefaultSessionDirPath } from "./session-manager-paths.ts";
|
|
6
6
|
export { findMostRecentSession, isInternalHeader, loadEntriesFromFile, parseSessionEntries, } from "./session-manager-storage.ts";
|
|
7
7
|
export type { BranchSummaryEntry, CompactionEntry, ContextCompactionEntry, ContextCompactionStats, ContextEditableContent, ContextEditEntry, CustomEntry, CustomMessageEntry, FileEntry, LabelEntry, ModelChangeEntry, ModelFallbackRecord, NewSessionOptions, ProjectedSessionEntry, ReadonlySessionManager, SessionContext, SessionEntry, SessionEntryBase, SessionHeader, SessionInfo, SessionInfoEntry, SessionListProgress, SessionMessageEntry, SessionNameState, SessionProjection, SessionSummaryEntry, SessionTreeNode, SessionWorkflowMetadata, ThinkingLevelChangeEntry, UsageEntry, WorktreeRestoreHostWarning, WorktreeSnapshotEntry, } from "./session-manager-types.ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-manager.d.ts","sourceRoot":"","sources":["../../src/core/session-manager.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,gCAAgC,EAChC,6BAA6B,GAC7B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC5F,OAAO,EACN,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,GACnB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACX,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,uBAAuB,EACvB,wBAAwB,EACxB,UAAU,EACV,0BAA0B,EAC1B,qBAAqB,GACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC"}
|
|
1
|
+
{"version":3,"file":"session-manager.d.ts","sourceRoot":"","sources":["../../src/core/session-manager.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,gCAAgC,EAChC,gBAAgB,EAChB,6BAA6B,GAC7B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC5F,OAAO,EACN,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,GACnB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACX,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,uBAAuB,EACvB,wBAAwB,EACxB,UAAU,EACV,0BAA0B,EAC1B,qBAAqB,GACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { SessionManager } from "./session-manager-core.js";
|
|
2
2
|
export { SessionEntryError, SessionIdError } from "./session-manager-errors.js";
|
|
3
|
-
export { buildContextEntries, buildSessionContext, buildSessionProjection, getLatestCompactionBoundaryEntry, sessionEntryToContextMessages, } from "./session-manager-history.js";
|
|
3
|
+
export { buildContextEntries, buildSessionContext, buildSessionProjection, getLatestCompactionBoundaryEntry, getSessionLeafId, sessionEntryToContextMessages, } from "./session-manager-history.js";
|
|
4
4
|
export { getDefaultSessionDir, getDefaultSessionDirPath } from "./session-manager-paths.js";
|
|
5
5
|
export { findMostRecentSession, isInternalHeader, loadEntriesFromFile, parseSessionEntries, } from "./session-manager-storage.js";
|
|
6
6
|
export { CURRENT_SESSION_VERSION } from "./session-manager-types.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-manager.js","sourceRoot":"","sources":["../../src/core/session-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,gCAAgC,EAChC,6BAA6B,GAC7B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC5F,OAAO,EACN,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,GACnB,MAAM,8BAA8B,CAAC;AAmCtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC","sourcesContent":["export type { VerbatimCompactionDetails } from \"./compaction/compaction-types.js\";\nexport { SessionManager } from \"./session-manager-core.ts\";\nexport { SessionEntryError, SessionIdError } from \"./session-manager-errors.js\";\nexport {\n\tbuildContextEntries,\n\tbuildSessionContext,\n\tbuildSessionProjection,\n\tgetLatestCompactionBoundaryEntry,\n\tsessionEntryToContextMessages,\n} from \"./session-manager-history.ts\";\nexport { getDefaultSessionDir, getDefaultSessionDirPath } from \"./session-manager-paths.ts\";\nexport {\n\tfindMostRecentSession,\n\tisInternalHeader,\n\tloadEntriesFromFile,\n\tparseSessionEntries,\n} from \"./session-manager-storage.ts\";\nexport type {\n\tBranchSummaryEntry,\n\tCompactionEntry,\n\tContextCompactionEntry,\n\tContextCompactionStats,\n\tContextEditableContent,\n\tContextEditEntry,\n\tCustomEntry,\n\tCustomMessageEntry,\n\tFileEntry,\n\tLabelEntry,\n\tModelChangeEntry,\n\tModelFallbackRecord,\n\tNewSessionOptions,\n\tProjectedSessionEntry,\n\tReadonlySessionManager,\n\tSessionContext,\n\tSessionEntry,\n\tSessionEntryBase,\n\tSessionHeader,\n\tSessionInfo,\n\tSessionInfoEntry,\n\tSessionListProgress,\n\tSessionMessageEntry,\n\tSessionNameState,\n\tSessionProjection,\n\tSessionSummaryEntry,\n\tSessionTreeNode,\n\tSessionWorkflowMetadata,\n\tThinkingLevelChangeEntry,\n\tUsageEntry,\n\tWorktreeRestoreHostWarning,\n\tWorktreeSnapshotEntry,\n} from \"./session-manager-types.ts\";\nexport { CURRENT_SESSION_VERSION } from \"./session-manager-types.ts\";\nexport { assertValidSessionId } from \"./session-manager-validation.ts\";\n"]}
|
|
1
|
+
{"version":3,"file":"session-manager.js","sourceRoot":"","sources":["../../src/core/session-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,gCAAgC,EAChC,gBAAgB,EAChB,6BAA6B,GAC7B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC5F,OAAO,EACN,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,GACnB,MAAM,8BAA8B,CAAC;AAmCtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC","sourcesContent":["export type { VerbatimCompactionDetails } from \"./compaction/compaction-types.js\";\nexport { SessionManager } from \"./session-manager-core.ts\";\nexport { SessionEntryError, SessionIdError } from \"./session-manager-errors.js\";\nexport {\n\tbuildContextEntries,\n\tbuildSessionContext,\n\tbuildSessionProjection,\n\tgetLatestCompactionBoundaryEntry,\n\tgetSessionLeafId,\n\tsessionEntryToContextMessages,\n} from \"./session-manager-history.ts\";\nexport { getDefaultSessionDir, getDefaultSessionDirPath } from \"./session-manager-paths.ts\";\nexport {\n\tfindMostRecentSession,\n\tisInternalHeader,\n\tloadEntriesFromFile,\n\tparseSessionEntries,\n} from \"./session-manager-storage.ts\";\nexport type {\n\tBranchSummaryEntry,\n\tCompactionEntry,\n\tContextCompactionEntry,\n\tContextCompactionStats,\n\tContextEditableContent,\n\tContextEditEntry,\n\tCustomEntry,\n\tCustomMessageEntry,\n\tFileEntry,\n\tLabelEntry,\n\tModelChangeEntry,\n\tModelFallbackRecord,\n\tNewSessionOptions,\n\tProjectedSessionEntry,\n\tReadonlySessionManager,\n\tSessionContext,\n\tSessionEntry,\n\tSessionEntryBase,\n\tSessionHeader,\n\tSessionInfo,\n\tSessionInfoEntry,\n\tSessionListProgress,\n\tSessionMessageEntry,\n\tSessionNameState,\n\tSessionProjection,\n\tSessionSummaryEntry,\n\tSessionTreeNode,\n\tSessionWorkflowMetadata,\n\tThinkingLevelChangeEntry,\n\tUsageEntry,\n\tWorktreeRestoreHostWarning,\n\tWorktreeSnapshotEntry,\n} from \"./session-manager-types.ts\";\nexport { CURRENT_SESSION_VERSION } from \"./session-manager-types.ts\";\nexport { assertValidSessionId } from \"./session-manager-validation.ts\";\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { AssistantMessage } from "@bastani/pi-ai/compat";
|
|
2
2
|
import type { SessionManager } from "./session-manager.ts";
|
|
3
|
-
import type { SessionEntry } from "./session-manager-types.ts";
|
|
3
|
+
import type { SessionEntry, WorktreeRestoreHostWarning } from "./session-manager-types.ts";
|
|
4
4
|
import type { SessionStore } from "./storage/session/types.js";
|
|
5
5
|
import { type WorktreeSnapshotUnavailableReason } from "./worktree-snapshot/capture.ts";
|
|
6
6
|
import { type GitUnavailableError, type WorkspaceError } from "./worktree-snapshot/errors.ts";
|
|
7
|
-
import type { SnapshotBlobStore, WorktreeRestoreWarning, WorktreeRootMapping, WorktreeSnapshot, WorktreeSnapshotSettings } from "./worktree-snapshot/types.ts";
|
|
7
|
+
import type { SnapshotBlobStore, WorktreeRestoreWarning, WorktreeRootMapping, WorktreeSnapshot, WorktreeSnapshotSettings, WorktreeUnrestored } from "./worktree-snapshot/types.ts";
|
|
8
8
|
/** Why a turn's snapshot could not be recorded: Git is unavailable, or a typed workspace failure. */
|
|
9
9
|
export type WorktreeSnapshotUnavailable = WorkspaceError | GitUnavailableError;
|
|
10
10
|
/** Built-in tools that can change files: a turn that called one records a snapshot. */
|
|
@@ -41,23 +41,44 @@ export declare class SessionWorktreeSnapshotRecorder {
|
|
|
41
41
|
}
|
|
42
42
|
/** `path` rewritten through each restore in order: a path under `from` moves to the same place under `to`. */
|
|
43
43
|
export declare function mapRestoredPath(path: string, mappings: readonly WorktreeRootMapping[]): string;
|
|
44
|
+
/** The checkouts on the active branch whose latest snapshot the session holds no record of, where they are now (#4733). */
|
|
45
|
+
export declare function missingSnapshotRecords(sessionManager: Pick<SessionManager, "getBranch" | "getWorktreeRootMappings" | "getWorktreeSnapshotRecords">): MissingSnapshotRecord[];
|
|
44
46
|
/**
|
|
45
47
|
* The latest snapshot of each checkout on the active branch, keyed by where that checkout is now: a checkout restored
|
|
46
48
|
* elsewhere appears once, under its newest location. A snapshot whose record is missing is left out.
|
|
47
49
|
*/
|
|
48
50
|
export declare function currentWorktreeSnapshots(sessionManager: Pick<SessionManager, "getBranch" | "getWorktreeRootMappings" | "getWorktreeSnapshotRecords">): Map<string, WorktreeSnapshot>;
|
|
51
|
+
/** A checkout a resume continued without, because nothing of its snapshot could be restored here (#4733). */
|
|
52
|
+
export interface UnrestoredWorktree {
|
|
53
|
+
readonly root: string;
|
|
54
|
+
readonly snapshot: WorktreeSnapshot;
|
|
55
|
+
/** Why: the restore error, or Git being unavailable. */
|
|
56
|
+
readonly reason: Error;
|
|
57
|
+
/** The record the resume wrote for it in the session. */
|
|
58
|
+
readonly record: WorktreeUnrestored;
|
|
59
|
+
}
|
|
60
|
+
/** A checkout whose latest snapshot the session refers to without holding its record (#4733). */
|
|
61
|
+
export interface MissingSnapshotRecord {
|
|
62
|
+
readonly root: string;
|
|
63
|
+
readonly snapshotId: string;
|
|
64
|
+
}
|
|
49
65
|
export type SessionWorktreeResume = {
|
|
50
66
|
readonly status: "none";
|
|
67
|
+
readonly missingRecords?: readonly MissingSnapshotRecord[];
|
|
51
68
|
} | {
|
|
52
69
|
readonly status: "verified";
|
|
53
70
|
readonly snapshot: WorktreeSnapshot;
|
|
54
71
|
readonly cwd: string;
|
|
72
|
+
readonly unrestored: readonly UnrestoredWorktree[];
|
|
73
|
+
readonly missingRecords?: readonly MissingSnapshotRecord[];
|
|
55
74
|
} | {
|
|
56
75
|
readonly status: "restored";
|
|
57
76
|
readonly snapshot: WorktreeSnapshot;
|
|
58
77
|
readonly mappings: readonly WorktreeRootMapping[];
|
|
59
78
|
readonly cwd: string;
|
|
60
79
|
readonly warnings: readonly WorktreeRestoreWarning[];
|
|
80
|
+
readonly unrestored: readonly UnrestoredWorktree[];
|
|
81
|
+
readonly missingRecords?: readonly MissingSnapshotRecord[];
|
|
61
82
|
};
|
|
62
83
|
export interface ResumeSessionWorktreeOptions {
|
|
63
84
|
readonly settings: WorktreeSnapshotSettings;
|
|
@@ -77,7 +98,28 @@ export interface ResumeSessionWorktreeOptions {
|
|
|
77
98
|
readonly pendingMappings?: readonly WorktreeRootMapping[];
|
|
78
99
|
/** Checkouts, by the root the session's restores put them at, to continue in as they are without verifying them. */
|
|
79
100
|
readonly keepInPlace?: ReadonlySet<string>;
|
|
101
|
+
/**
|
|
102
|
+
* Checkouts, by the same roots, that cannot be restored on this host, with the reason, such as Git being
|
|
103
|
+
* unavailable: the resume continues without them, as for a restore that gives nothing (#4733).
|
|
104
|
+
*/
|
|
105
|
+
readonly cannotRestore?: ReadonlyMap<string, Error>;
|
|
106
|
+
/**
|
|
107
|
+
* Where the session continues when the checkout it works in is not restored and its working directory is not on
|
|
108
|
+
* this host: the directory the resume started from. Default: the recorded working directory.
|
|
109
|
+
*/
|
|
110
|
+
readonly fallbackCwd?: string;
|
|
111
|
+
/**
|
|
112
|
+
* Continue without a checkout whose latest snapshot the session holds no record of, listing it in `missingRecords`,
|
|
113
|
+
* instead of failing with `snapshot-not-found` before anything is restored (#4733).
|
|
114
|
+
*/
|
|
115
|
+
readonly skipMissingRecords?: boolean;
|
|
80
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Whether a failed restore of one checkout leaves the resume able to continue without the exact state (#4733): any
|
|
119
|
+
* typed workspace or Git failure, except a snapshot record that fails the security checks (`invalid-snapshot`) and a
|
|
120
|
+
* target that holds other files (`unsafe-target`), which refuse the resume.
|
|
121
|
+
*/
|
|
122
|
+
export declare function isRecoverableRestoreFailure(error: unknown): error is Error;
|
|
81
123
|
/**
|
|
82
124
|
* Checks the latest recorded snapshot of each checkout on the active session branch. Drifted or missing checkouts are
|
|
83
125
|
* restored into fresh worktrees, and each old→new mapping is recorded only after all checkouts have been restored.
|
|
@@ -88,9 +130,19 @@ export declare function resumeSessionWorktree(sessionManager: SessionManager, op
|
|
|
88
130
|
export declare function formatWorktreeRestoreNotice(mapping: WorktreeRootMapping): string;
|
|
89
131
|
/** One line per restore warning, for the notices shown after a restore. */
|
|
90
132
|
export declare function formatWorktreeRestoreWarning(warning: WorktreeRestoreWarning): string;
|
|
133
|
+
/**
|
|
134
|
+
* The one notice for a worktree restored with less than its snapshot (#4733): what it holds, what is missing and what
|
|
135
|
+
* to do to get the rest.
|
|
136
|
+
*/
|
|
137
|
+
export declare function formatDegradedRestoreNotice(mapping: WorktreeRootMapping, snapshot: WorktreeSnapshot | undefined, warnings?: readonly WorktreeRestoreHostWarning[]): string;
|
|
138
|
+
/** The notice for a checkout whose snapshot the session holds no record of, which a resume continued without. */
|
|
139
|
+
export declare function formatMissingRecordNotice(missing: MissingSnapshotRecord): string;
|
|
140
|
+
/** The one notice for a checkout a resume continued without (#4733). */
|
|
141
|
+
export declare function formatUnrestoredNotice(root: string, unrestored: WorktreeUnrestored): string;
|
|
91
142
|
/**
|
|
92
143
|
* One informational line per worktree restored since `since`, each followed by its snapshot's warnings and what the
|
|
93
|
-
* restore itself reported
|
|
144
|
+
* restore itself reported; one notice per worktree restored with less than its snapshot, and per checkout a resume
|
|
145
|
+
* continued without, since `since` (#4733).
|
|
94
146
|
*/
|
|
95
147
|
export declare function worktreeRestoreNotices(sessionManager: Pick<SessionManager, "getBranch" | "getWorktreeSnapshotRecords">, since: string): {
|
|
96
148
|
readonly type: "info" | "warning";
|
|
@@ -130,6 +182,11 @@ export type WorktreeSnapshotComparison = {
|
|
|
130
182
|
};
|
|
131
183
|
/** Compares the checkout at `dir` with `snapshot`, for `/session snapshot`. */
|
|
132
184
|
export declare function compareWorktreeSnapshot(snapshot: WorktreeSnapshot, dir: string, settings: WorktreeSnapshotSettings): Promise<WorktreeSnapshotComparison>;
|
|
185
|
+
/**
|
|
186
|
+
* What the last resume did about the checkout now at `root`, for `/session snapshot`, when it restored less than the
|
|
187
|
+
* snapshot or nothing of it (#4733): the notice that resume showed. Undefined after a complete restore, or none.
|
|
188
|
+
*/
|
|
189
|
+
export declare function describeWorktreeRestoreStatus(sessionManager: Pick<SessionManager, "getBranch" | "getWorktreeSnapshotRecords">, root: string): string | undefined;
|
|
133
190
|
/** Lines describing `snapshot` for `/session snapshot`. */
|
|
134
191
|
export declare function describeWorktreeSnapshot(root: string, snapshot: WorktreeSnapshot): string[];
|
|
135
192
|
/**
|
|
@@ -149,7 +206,7 @@ export declare function openSessionInWorktree(sessionManager: SessionManager, op
|
|
|
149
206
|
* Opens `sessionManager`'s session in `cwd`, where resuming it left its working directory, and returns the notices to
|
|
150
207
|
* show for the worktrees that resuming `restored` it into.
|
|
151
208
|
*/
|
|
152
|
-
export declare function openResumedSession(sessionManager: SessionManager, cwd: string, restored: readonly WorktreeRootMapping[], sessionDirectory?: string): Promise<{
|
|
209
|
+
export declare function openResumedSession(sessionManager: SessionManager, cwd: string, restored: readonly WorktreeRootMapping[], sessionDirectory?: string, unrestored?: readonly WorktreeUnrestored[]): Promise<{
|
|
153
210
|
readonly sessionManager: SessionManager;
|
|
154
211
|
readonly notices: {
|
|
155
212
|
readonly type: "info" | "warning";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-worktree-snapshots.d.ts","sourceRoot":"","sources":["../../src/core/session-worktree-snapshots.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session-worktree-snapshots.d.ts","sourceRoot":"","sources":["../../src/core/session-worktree-snapshots.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,KAAK,EAAE,YAAY,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EAGN,KAAK,iCAAiC,EAGtC,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAEN,KAAK,mBAAmB,EAQxB,KAAK,cAAc,EAGnB,MAAM,+BAA+B,CAAC;AAcvC,OAAO,KAAK,EAEX,iBAAiB,EAEjB,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,wBAAwB,EACxB,kBAAkB,EAClB,MAAM,8BAA8B,CAAC;AAEtC,qGAAqG;AACrG,MAAM,MAAM,2BAA2B,GAAG,cAAc,GAAG,mBAAmB,CAAC;AAE/E,uFAAuF;AACvF,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAAoD,CAAC;AAGxG,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;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