import { n as MsgContext } from "./templating-Cqqe1hGs.js"; import { O as SessionMaintenanceMode } from "./types.base-CrXPFJf5.js"; import { a as SessionEntry, n as GroupKeyResolution, o as SessionScope } from "./types-CCX1gTNG.js"; import { t as DeliveryContext } from "./delivery-context.types-DyNhFIjW.js"; //#region src/config/sessions/paths.d.ts declare function resolveSessionTranscriptsDirForAgent(agentId?: string, env?: NodeJS.ProcessEnv, homedir?: () => string): string; type SessionFilePathOptions = { agentId?: string; sessionsDir?: string; }; declare function resolveSessionTranscriptPathInDir(sessionId: string, sessionsDir: string, topicId?: string | number): string; declare function resolveSessionFilePath(sessionId: string, entry?: { sessionFile?: string; }, opts?: SessionFilePathOptions): string; declare function resolveStorePath(store?: string, opts?: { agentId?: string; env?: NodeJS.ProcessEnv; }): string; //#endregion //#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; resetArchiveRetentionMs: number | null; maxDiskBytes: number | null; highWaterBytes: number | 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 declare function readSessionUpdatedAt(params: { storePath: string; sessionKey: string; }): number | undefined; type SessionMaintenanceApplyReport = { mode: ResolvedSessionMaintenanceConfig["mode"]; beforeCount: number; afterCount: number; pruned: number; capped: number; diskBudget: SessionDiskBudgetSweepResult | null; }; 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; }; type UpdateSessionStoreOptions = SaveSessionStoreOptions & { /** * 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; }; type SessionEntryWorkflowOptions = { agentId?: string; env?: NodeJS.ProcessEnv; hydrateSkillPromptRefs?: boolean; storePath?: string; }; declare function getSessionEntry(options: SessionEntryWorkflowOptions & { sessionKey: string; }): SessionEntry | undefined; declare function listSessionEntries(options?: SessionEntryWorkflowOptions): Array<{ 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; declare function updateSessionStoreEntry(params: { storePath: string; sessionKey: string; update: (entry: SessionEntry) => Promise | null> | Partial | null; skipMaintenance?: boolean; takeCacheOwnership?: boolean; }): Promise; declare function patchSessionEntry(params: SessionEntryWorkflowOptions & { sessionKey: string; fallbackEntry?: SessionEntry; preserveActivity?: boolean; replaceEntry?: boolean; update: (entry: SessionEntry) => Promise | null> | Partial | null; }): Promise; declare function upsertSessionEntry(params: SessionEntryWorkflowOptions & { sessionKey: string; entry: SessionEntry; }): Promise; declare function recordSessionMetaFromInbound(params: { storePath: string; sessionKey: string; ctx: MsgContext; groupResolution?: GroupKeyResolution | null; createIfMissing?: boolean; }): Promise; declare function updateLastRoute(params: { storePath: string; sessionKey: string; channel?: SessionEntry["lastChannel"]; to?: string; accountId?: string; threadId?: string | number; route?: SessionEntry["route"]; deliveryContext?: DeliveryContext; ctx?: MsgContext; groupResolution?: GroupKeyResolution | null; createIfMissing?: boolean; }): Promise; //#endregion //#region src/config/sessions/group.d.ts /** * Resolves channel/group chat context into the persisted group session key. * * Provider-prefixed ids use channel-owned normalization, while legacy plugin resolvers remain a * fallback for older channel surfaces that cannot yet express the generic route shape. */ declare function resolveGroupSessionKey(ctx: MsgContext): GroupKeyResolution | null; //#endregion //#region src/config/sessions/artifacts.d.ts /** Returns true for archived session artifacts and legacy store backup names. */ declare function isSessionArchiveArtifactName(fileName: string): boolean; /** Returns true for transcript files counted in usage, including reset/deleted archives. */ declare function isUsageCountedSessionTranscriptFileName(fileName: string): boolean; /** Extracts the session id from a usage-counted transcript filename. */ declare function parseUsageCountedSessionIdFromFileName(fileName: string): string | null; //#endregion //#region src/config/sessions/main-session.d.ts /** Canonicalizes main-session aliases to the current scoped session key. */ declare function canonicalizeMainSessionAlias(params: { cfg?: { session?: { scope?: SessionScope; mainKey?: string; }; }; agentId: string; sessionKey: string; }): string; //#endregion //#region src/config/sessions/session-key.d.ts /** * Resolves the persisted session-store key for an inbound message. * * Explicit session keys pass through the compatibility normalizer, direct chats collapse to the * agent's canonical main bucket, and group/channel sessions stay isolated under the same agent. */ declare function resolveSessionKey(scope: SessionScope, ctx: MsgContext, mainKey?: string, agentId?: string): string; //#endregion //#region src/config/sessions/transcript.d.ts type AssistantTranscriptText = { id?: string; text: string; timestamp?: number; }; type LatestAssistantTranscriptText = AssistantTranscriptText; declare function readLatestAssistantTextFromSessionTranscript(sessionFile: string | undefined): Promise; //#endregion //#region src/config/sessions/session-file.d.ts /** Resolves a transcript file path and persists it into the session store when needed. */ declare function resolveAndPersistSessionFile(params: { sessionId: string; sessionKey: string; sessionStore: Record; storePath: string; sessionEntry?: SessionEntry; agentId?: string; sessionsDir?: string; fallbackSessionFile?: string; activeSessionKey?: string; maintenanceConfig?: ResolvedSessionMaintenanceConfig; }): Promise<{ sessionFile: string; sessionEntry: SessionEntry; }>; //#endregion export { resolveSessionTranscriptPathInDir as C, resolveSessionFilePath as S, resolveStorePath as T, updateSessionStoreEntry as _, isSessionArchiveArtifactName as a, loadSessionStore as b, resolveGroupSessionKey as c, patchSessionEntry as d, readSessionUpdatedAt as f, updateSessionStore as g, updateLastRoute as h, canonicalizeMainSessionAlias as i, getSessionEntry as l, saveSessionStore as m, readLatestAssistantTextFromSessionTranscript as n, isUsageCountedSessionTranscriptFileName as o, recordSessionMetaFromInbound as p, resolveSessionKey as r, parseUsageCountedSessionIdFromFileName as s, resolveAndPersistSessionFile as t, listSessionEntries as u, upsertSessionEntry as v, resolveSessionTranscriptsDirForAgent as w, clearSessionStoreCacheForTest as x, resolveSessionStoreEntry as y };