



























@@ -23,21 +23,28 @@ import type { ResolvedSessionMaintenanceConfig } from "./store-maintenance.js";
2323import {
2424getSessionEntry,
2525cleanupSessionLifecycleArtifacts as cleanupFileSessionLifecycleArtifacts,
26+deleteSessionEntryLifecycle as deleteFileSessionEntryLifecycle,
2627listSessionEntries as listFileSessionEntries,
2728loadSessionStore,
2829applySessionEntryPatchProjection as applyFileSessionEntryPatchProjection,
2930patchSessionEntry as patchFileSessionEntry,
3031readSessionUpdatedAt as readFileSessionUpdatedAt,
3132resolveSessionStoreEntry,
33+resetSessionEntryLifecycle as resetFileSessionEntryLifecycle,
3234updateSessionStore,
3335updateSessionStoreEntry as updateFileSessionStoreEntry,
36+type DeleteSessionEntryLifecycleResult,
37+type ResetSessionEntryLifecycleMutation,
38+type ResetSessionEntryLifecycleResult,
3439type SessionEntryPatchProjectionContext,
3540type SessionEntryPatchProjectionFailure,
3641type SessionEntryPatchProjectionResult,
3742type SessionEntryPatchProjectionSnapshot,
3843type SessionEntryPatchProjectionTarget,
44+type SessionLifecycleArchivedTranscript,
3945type SessionLifecycleArtifactCleanupParams,
4046type SessionLifecycleArtifactCleanupResult,
47+type SessionLifecycleStoreTarget,
4148} from "./store.js";
4249import { parseSessionThreadInfo } from "./thread-info.js";
4350import {
@@ -280,7 +287,41 @@ export type SessionPatchProjectionResult<TFailure extends SessionPatchProjection
280287export type SessionPatchProjectionSnapshot = SessionEntryPatchProjectionSnapshot;
281288export type SessionPatchProjectionTarget = SessionEntryPatchProjectionTarget;
282289283-export type { SessionLifecycleArtifactCleanupParams, SessionLifecycleArtifactCleanupResult };
290+export type {
291+DeleteSessionEntryLifecycleResult,
292+ResetSessionEntryLifecycleResult,
293+SessionLifecycleArchivedTranscript,
294+SessionLifecycleArtifactCleanupParams,
295+SessionLifecycleArtifactCleanupResult,
296+SessionLifecycleStoreTarget,
297+};
298+299+export type ResetSessionEntryLifecycleParams = {
300+/** Runs after the persisted entry rotates and before transcript artifacts move. */
301+afterEntryMutation?: (mutation: ResetSessionEntryLifecycleMutation) => Promise<void> | void;
302+/** Agent owner used to resolve backend transcript artifacts. */
303+agentId?: string;
304+/** Builds the persisted replacement entry from the current backend row. */
305+buildNextEntry: (context: {
306+currentEntry?: SessionEntry;
307+primaryKey: string;
308+}) => Promise<SessionEntry> | SessionEntry;
309+/** Explicit store target for file-backed stores and SQLite migration adapters. */
310+storePath: string;
311+/** Canonical key plus aliases that identify the logical entry. */
312+target: SessionLifecycleStoreTarget;
313+};
314+315+export type DeleteSessionEntryLifecycleParams = {
316+/** Agent owner used to resolve backend transcript artifacts. */
317+agentId?: string;
318+/** Whether transcript artifacts should be archived/deleted with the entry. */
319+archiveTranscript: boolean;
320+/** Explicit store target for file-backed stores and SQLite migration adapters. */
321+storePath: string;
322+/** Canonical key plus aliases that identify the logical entry. */
323+target: SessionLifecycleStoreTarget;
324+};
284325285326/** Returns the entry for a canonical or alias session key, if one exists. */
286327export function loadSessionEntry(scope: SessionAccessScope): SessionEntry | undefined {
@@ -521,6 +562,20 @@ export async function cleanupSessionLifecycleArtifacts(
521562return await cleanupFileSessionLifecycleArtifacts(params);
522563}
523564565+/** Resets one persisted session entry and transitions its transcript state. */
566+export async function resetSessionEntryLifecycle(
567+params: ResetSessionEntryLifecycleParams,
568+): Promise<ResetSessionEntryLifecycleResult> {
569+return await resetFileSessionEntryLifecycle(params);
570+}
571+572+/** Deletes one persisted session entry and transitions its transcript state. */
573+export async function deleteSessionEntryLifecycle(
574+params: DeleteSessionEntryLifecycleParams,
575+): Promise<DeleteSessionEntryLifecycleResult> {
576+return await deleteFileSessionEntryLifecycle(params);
577+}
578+524579/** Reads parsed transcript records from an explicit or derived transcript target. */
525580export async function loadTranscriptEvents(
526581scope: SessionTranscriptReadScope,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。