import { k as SessionMaintenanceMode } from "./types.base-BDLtjuuz.js"; import { i as MsgContext } from "./templating-DOk3rz_v.js"; import { i as OpenClawConfig } from "./types.openclaw-DH5a2ppk.js"; import { o as SessionEntry, r as GroupKeyResolution } from "./types-Dv0vM7Zp.js"; import { t as DeliveryContext } from "./delivery-context.types-DyNhFIjW.js"; //#region src/config/sessions/disk-budget.d.ts type SessionDiskBudgetSweepResult = { totalBytesBefore: number; totalBytesAfter: number; removedFiles: number; removedEntries: number; freedBytes: number; maxBytes: number; highWaterBytes: number; overBudget: boolean; }; //#endregion //#region src/config/sessions/store-maintenance.d.ts type SessionMaintenanceWarning = { activeSessionKey: string; activeUpdatedAt?: number; totalEntries: number; pruneAfterMs: number; maxEntries: number; wouldPrune: boolean; wouldCap: boolean; }; type ResolvedSessionMaintenanceConfig = { mode: SessionMaintenanceMode; pruneAfterMs: number; maxEntries: number; modelRunPruneAfterMs: number; resetArchiveRetentionMs: number | null; maxDiskBytes: number | null; highWaterBytes: number | null; }; type ResolvedSessionMaintenanceConfigInput = Omit & Partial>; //#endregion //#region src/config/sessions/store-maintenance-operations.d.ts type SessionMaintenanceApplyReport = { mode: ResolvedSessionMaintenanceConfig["mode"]; beforeCount: number; afterCount: number; modelRunPruned: number; pruned: number; capped: number; diskBudget: SessionDiskBudgetSweepResult | null; }; //#endregion //#region src/config/sessions/store-writer-state.d.ts /** Clears session store writer queues and cache for tests. */ declare function clearSessionStoreCacheForTest(): void; //#endregion //#region src/config/sessions/store-load.d.ts type LoadSessionStoreOptions = { skipCache?: boolean; maintenanceConfig?: ResolvedSessionMaintenanceConfig; runMaintenance?: boolean; clone?: boolean; hydrateSkillPromptRefs?: boolean; }; declare function loadSessionStore(storePath: string, opts?: LoadSessionStoreOptions): Record; //#endregion //#region src/config/sessions/store-entry.d.ts declare function resolveSessionStoreEntry(params: { store: Record; sessionKey: string; }): { normalizedKey: string; existing: SessionEntry | undefined; legacyKeys: string[]; }; //#endregion //#region src/config/sessions/store.d.ts type SaveSessionStoreOptions = { /** Skip pruning, capping, and rotation (e.g. during one-time migrations). */skipMaintenance?: boolean; /** Caller already proved the store serialization is unchanged unless maintenance mutates it. */ skipSerializeForUnchangedStore?: boolean; /** Internal hot paths can hand writer-owned stores to the cache after persistence. */ takeCacheOwnership?: boolean; /** Active session key for warn-only maintenance. */ activeSessionKey?: string; /** Optional callback for warn-only maintenance. */ onWarn?: (warning: SessionMaintenanceWarning) => void | Promise; /** Optional callback with maintenance stats after a save. */ onMaintenanceApplied?: (report: SessionMaintenanceApplyReport) => void | Promise; /** Optional overrides used by maintenance commands. */ maintenanceOverride?: Partial; /** Fully resolved maintenance settings when the caller already has config loaded. */ maintenanceConfig?: ResolvedSessionMaintenanceConfig; /** Changed top-level entry when a hot path only updated one existing session. */ singleEntryPersistence?: SingleEntryPersistencePatch; /** Throw when best-effort store recovery cannot confirm the requested write. */ requireWriteSuccess?: boolean; }; type UpdateSessionStoreOptions = SaveSessionStoreOptions & { /** Allow a nested mutation only when the caller already owns this store writer lane. */reentrant?: boolean; /** * Specialized callers can prove their mutator made no changes through its result. * When true, the writer-owned object cache is restored and sessions.json is untouched. */ skipSaveWhenResult?: (result: T) => boolean; resolveSingleEntryPersistence?: (result: T) => SingleEntryPersistencePatch | null | undefined; }; type SingleEntryPersistencePatch = { sessionKey: string; entry: SessionEntry; }; declare function saveSessionStore(storePath: string, store: Record, opts?: SaveSessionStoreOptions): Promise; declare function updateSessionStore(storePath: string, mutator: (store: Record) => Promise | T, opts?: UpdateSessionStoreOptions): Promise; //#endregion //#region src/sessions/transcript-events.d.ts /** Storage-neutral identity for the session transcript that changed. */ type SessionTranscriptUpdateTarget = { agentId: string; sessionId: string; sessionKey: string; }; type SessionTranscriptUpdateFields = { sessionFile?: string; target?: SessionTranscriptUpdateTarget; sessionKey?: string; agentId?: string; /** @deprecated Pre-SQLite compatibility mirror. Prefer `target.sessionId`. */ sessionId?: string; message?: unknown; messageId?: string; messageSeq?: number; }; /** Normalized transcript update emitted after a session transcript changes. */ type SessionTranscriptUpdate = SessionTranscriptUpdateFields & { /** @deprecated File-backed compatibility hint. Prefer `target` for identity. */sessionFile: string; }; type SessionTranscriptListener = (update: SessionTranscriptUpdate) => void; /** Registers a listener for normalized session transcript updates. */ declare function onSessionTranscriptUpdate(listener: SessionTranscriptListener): () => void; /** Emits a normalized transcript update to all registered listeners. */ declare function emitSessionTranscriptUpdate(update: string | SessionTranscriptUpdate): void; //#endregion //#region src/config/sessions/session-accessor.d.ts type TranscriptMessageAppendOptions = { /** Runtime config used for message redaction and transcript header metadata. */config?: OpenClawConfig; /** Working directory recorded in a newly created transcript header. */ cwd?: string; /** How duplicate message idempotency keys are detected before append. */ idempotencyLookup?: "scan" | "caller-checked"; /** Provider/channel message payload to persist. */ message: TMessage; /** Testable timestamp override for the generated transcript entry. */ now?: number; /** Optional finalizer that runs after duplicate detection but before persistence. */ prepareMessageAfterIdempotencyCheck?: (message: TMessage) => TMessage | undefined; /** Allow append without parent-link migration for large legacy linear transcripts. */ useRawWhenLinear?: boolean; }; type TranscriptMessageAppendResult = { /** False when idempotency lookup found an existing transcript message. */appended: boolean; /** Redacted message payload as persisted or replayed from the transcript. */ message: TMessage; /** Existing or newly generated transcript message id. */ messageId: string; }; /** Transcript update fields supplied by callers; sessionFile is resolved here. */ type TranscriptUpdatePayload = Omit; type RecordInboundSessionMetaParams = { /** Set false to only patch existing entries; missing sessions stay absent. */createIfMissing?: boolean; /** Inbound message context whose stable metadata is derived and persisted. */ ctx: MsgContext; /** Group routing resolution for group-owned session keys. */ groupResolution?: GroupKeyResolution | null; /** Canonical or alias session key for the inbound conversation. */ sessionKey: string; /** Explicit store target for file-backed stores and SQLite migration adapters. */ storePath: string; }; type UpdateSessionLastRouteParams = { /** Account owning the delivery route when the channel is multi-account. */accountId?: string; /** Delivery channel id persisted as the last route channel. */ channel?: SessionEntry["lastChannel"]; /** Set false to only patch existing entries; missing sessions stay absent. */ createIfMissing?: boolean; /** Optional inbound context whose session metadata is derived alongside the route. */ ctx?: MsgContext; /** Explicit delivery context merged over the persisted session fallback. */ deliveryContext?: DeliveryContext; /** Group routing resolution for group-owned session keys. */ groupResolution?: GroupKeyResolution | null; /** Canonical channel route persisted as the session route slot. */ route?: SessionEntry["route"]; /** Canonical or alias session key for the routed conversation. */ sessionKey: string; /** Explicit store target for file-backed stores and SQLite migration adapters. */ storePath: string; /** Thread/topic id for the delivery route, when the transport has one. */ threadId?: string | number; /** Delivery target persisted as the last route recipient. */ to?: string; }; /** * Records stable conversation metadata derived from one inbound message as a * single storage-sized upsert (createIfMissing by default). Inbound metadata * must not refresh activity timestamps — idle reset relies on updatedAt from * real session turns — so existing rows merge with preserve-activity * semantics while legacy alias keys collapse onto the canonical row. */ declare function recordInboundSessionMeta(params: RecordInboundSessionMetaParams): Promise; /** * Persists the last known delivery route for one session as a single * storage-sized patch. Route updates preserve activity timestamps (#49515) * and merge explicit route/delivery input over the persisted session * fallback before normalizing the derived last* fields. */ declare function updateSessionLastRoute(params: UpdateSessionLastRouteParams): Promise; //#endregion //#region src/config/sessions/transcript.d.ts type SessionTranscriptAppendResult = { ok: true; sessionFile: string; messageId: string; } | { ok: false; reason: string; code?: "blocked" | "session-rebound"; }; type SessionTranscriptUpdateMode = "inline" | "file-only" | "none"; type SessionTranscriptDeliveryMirror = { kind: "channel-final"; sourceMessageId?: string; } | { kind: "channel-final-suppressed"; reason: "stale-foreground"; sourceMessageId?: string; }; type AssistantTranscriptText = { id?: string; text: string; timestamp?: number; }; type SessionRecentConversationText = { id?: string; role: "user" | "assistant"; text: string; timestamp?: number; sourceChannel?: string; }; type ReadRecentSessionConversationTextOptions = { beforeTimestampMs?: number; limit?: number; minTimestampMs?: number; }; type ReadRecentSessionConversationTextParams = ReadRecentSessionConversationTextOptions & { agentId?: string; sessionKey: string; storePath?: string; }; type LatestAssistantTranscriptText = AssistantTranscriptText; declare function readRecentUserAssistantTextForSession(params: ReadRecentSessionConversationTextParams): Promise; declare function readLatestAssistantTextFromSessionTranscript(sessionFile: string | undefined): Promise; //#endregion export { resolveSessionStoreEntry as _, SessionTranscriptUpdateMode as a, ResolvedSessionMaintenanceConfig as b, TranscriptMessageAppendOptions as c, recordInboundSessionMeta as d, updateSessionLastRoute as f, updateSessionStore as g, saveSessionStore as h, SessionTranscriptDeliveryMirror as i, TranscriptMessageAppendResult as l, onSessionTranscriptUpdate as m, SessionRecentConversationText as n, readLatestAssistantTextFromSessionTranscript as o, emitSessionTranscriptUpdate as p, SessionTranscriptAppendResult as r, readRecentUserAssistantTextForSession as s, LatestAssistantTranscriptText as t, TranscriptUpdatePayload as u, loadSessionStore as v, ResolvedSessionMaintenanceConfigInput as x, clearSessionStoreCacheForTest as y };