openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
309 lines • 13.4 kB
TypeScript
import "./types.openclaw-BdCLfP4c.js";
import { E as SessionResetConfig, w as SessionConfig } from "./types.base-D2CyC728.js";
import "./index-DrZymUhy.js";
import { c as SessionEntry, t as AmbientTranscriptWatermark } from "./types-DeuBjaEd.js";
import "./templating-CpgmHvb9.js";
import { l as ResolvedSessionMaintenanceConfigInput } from "./transcript-CIHZ7YGz.js";
import "./delivery-context.shared-BmQEDHxo.js";
import "./sessions-50ndZyDQ.js";
import "./send-policy-KrTiVLHN.js";
//#region src/config/sessions/reset-policy.d.ts
type SessionResetMode = "none" | "daily" | "idle";
type SessionStaleReason = Exclude<SessionResetMode, "none">;
type SessionResetType = "direct" | "group" | "thread";
type SessionResetPolicy = {
mode: SessionResetMode;
atHour: number;
idleMinutes?: number;
configured?: boolean;
};
type SessionFreshness = {
fresh: boolean;
dailyResetAt?: number;
idleExpiresAt?: number;
staleReason?: SessionStaleReason;
};
/** Resolves the effective reset policy for direct, group, or thread sessions. */
declare function resolveSessionResetPolicy(params: {
sessionCfg?: SessionConfig;
resetType: SessionResetType;
resetOverride?: SessionResetConfig;
}): SessionResetPolicy;
/** Evaluates whether a persisted session is still fresh under the resolved reset policy. */
declare function evaluateSessionFreshness(params: {
updatedAt: number;
sessionStartedAt?: number;
lastInteractionAt?: number;
now: number;
policy: SessionResetPolicy;
}): SessionFreshness;
//#endregion
//#region src/config/sessions/reset.d.ts
declare function resolveSessionResetType(params: {
sessionKey?: string | null;
isGroup?: boolean;
isThread?: boolean;
}): SessionResetType;
declare function resolveThreadFlag(params: {
sessionKey?: string | null;
messageThreadId?: string | number | null;
threadLabel?: string | null;
threadStarterBody?: string | null;
parentSessionKey?: string | null;
}): boolean;
declare function resolveChannelResetConfig(params: {
sessionCfg?: SessionConfig;
channel?: string | null;
}): SessionResetConfig | undefined;
//#endregion
//#region src/config/sessions/ambient-transcript-watermark.d.ts
type AmbientTranscriptWatermarkScope = {
channel: string;
accountId?: string;
conversationId: string;
threadId?: string | number;
};
declare function resolveAmbientTranscriptWatermarkKey(scope: AmbientTranscriptWatermarkScope): string;
declare function updateAmbientTranscriptWatermark(params: {
storePath: string;
sessionKey: string;
key: string;
messageId: string;
timestampMs?: number;
expectedSessionId?: string;
}): Promise<SessionEntry | null>;
//#endregion
//#region src/plugin-sdk/session-store-runtime-internal.d.ts
type SessionStoreReadParams = {
agentId?: string;
env?: NodeJS.ProcessEnv;
hydrateSkillPromptRefs?: boolean;
readConsistency?: "latest";
sessionKey: string;
storePath?: string;
};
//#endregion
//#region src/plugin-sdk/session-transcript-runtime.d.ts
type SessionTranscriptEvent = unknown;
//#endregion
//#region src/config/sessions/legacy-sqlite-marker.d.ts
type SqliteSessionFileMarker = {
agentId: string;
sessionId: string;
storePath: string;
};
declare function formatSqliteSessionFileMarker(marker: SqliteSessionFileMarker): string;
declare function parseSqliteSessionFileMarker(sessionFile: string | undefined): SqliteSessionFileMarker | undefined;
declare function sqliteSessionFileMarkerMatchesSession(sessionFile: string | undefined, sessionId: string): boolean;
//#endregion
//#region src/config/sessions/store-writer-state.d.ts
/** Clears session writer queues and prompt-blob caches for tests. */
declare function clearSessionStoreCacheForTest(): void;
//#endregion
//#region src/sessions/agent-harness-session-key.d.ts
type AgentHarnessSessionStoreEntry = {
agentHarnessId?: unknown;
modelSelectionLocked?: unknown;
pluginOwnerId?: unknown;
sessionId?: unknown;
};
/** True for any valid durable harness lock, including supported ordinary-key rows. */
declare function isValidAgentHarnessSessionStoreEntry(sessionKey: string, entry: AgentHarnessSessionStoreEntry): boolean;
//#endregion
//#region src/plugin-sdk/session-store-runtime.d.ts
type SessionStoreListParams = Partial<Omit<SessionStoreReadParams, "sessionKey">>;
type SessionStoreEntrySummary = {
sessionKey: string;
entry: SessionEntry;
};
type LoadSessionStoreOptions = {
skipCache?: boolean;
hydrateSkillPromptRefs?: boolean;
};
type UpdateSessionStoreOptions<T> = {
activeSessionKey?: string;
skipMaintenance?: boolean;
skipSaveWhenResult?: (result: T) => boolean;
};
type SessionStoreTranscriptEvent = SessionTranscriptEvent;
type SessionStoreEntryUpdate = (entry: SessionEntry) => Promise<Partial<SessionEntry> | null> | Partial<SessionEntry> | null;
type SessionStoreEntryPatch = (entry: SessionEntry, context: {
existingEntry?: SessionEntry;
}) => Promise<Partial<SessionEntry> | null> | Partial<SessionEntry> | null;
type PatchSessionEntryParams = SessionStoreReadParams & {
/** Synchronous final ownership check executed inside the commit transaction. */
assertCommitAllowed?: () => void;
fallbackEntry?: SessionEntry;
maintenanceConfig?: ResolvedSessionMaintenanceConfigInput;
preserveActivity?: boolean;
requireWriteSuccess?: boolean;
replaceEntry?: boolean;
skipMaintenance?: boolean;
update: SessionStoreEntryPatch;
};
type UpdateSessionStoreEntryParams = {
storePath: string;
sessionKey: string;
update: SessionStoreEntryUpdate;
skipMaintenance?: boolean;
takeCacheOwnership?: boolean;
requireWriteSuccess?: boolean;
};
type UpsertSessionEntryParams = SessionStoreReadParams & {
entry: SessionEntry;
};
type ReadAmbientTranscriptWatermarkParams = SessionStoreReadParams & {
key: string;
};
type DeleteSessionEntryParams = SessionStoreReadParams & {
archiveTranscript?: boolean;
expectedSessionId?: string | null;
expectedUpdatedAt?: number;
};
type SessionLifecycleArtifactsCleanupParams = {
agentId?: string;
archiveRemovedEntryTranscripts?: boolean;
env?: NodeJS.ProcessEnv;
orphanTranscriptMinAgeMs: number;
pluginOwnerId?: string;
sessionStore?: string;
sessionKeySegmentPrefix: string;
storePath?: string;
transcriptContentMarker: string;
nowMs?: number;
};
type SessionLifecycleArtifactsCleanupResult = {
archivedTranscriptArtifacts: number;
removedEntries: number;
};
/**
* @deprecated Use getSessionEntry or listSessionEntries.
*
* Official plugins released with v2026.7.1-beta.5 import this symbol. Keep the
* compatibility projection through 2026-10-12, then remove it only after the
* minimum supported plugin version excludes that release.
*/
declare function loadSessionStore(storePath: string, options?: LoadSessionStoreOptions): Record<string, SessionEntry>;
/**
* @deprecated Use patchSessionEntry, upsertSessionEntry, or deleteSessionEntry.
*
* Official plugins released with v2026.7.1-beta.5 import this symbol. Keep the
* compatibility bridge through 2026-10-12. The callback mutates a detached
* projection; the resulting row diff commits through the SQLite accessor.
* Beta.5 memory-core already uses cleanupSessionLifecycleArtifacts; this
* whole-store callback remains only for Feishu doctor's explicit repair flow.
*/
declare function updateSessionStore<T>(storePath: string, mutator: (store: Record<string, SessionEntry>) => Promise<T> | T, options?: UpdateSessionStoreOptions<T>): Promise<T>;
/**
* @deprecated Resolve transcript identities with loadTranscriptEventsSync.
*
* Beta.5 Feishu doctor still inspects JSONL paths synchronously. SQLite
* markers therefore materialize a bounded export at the canonical legacy path
* rather than making the old doctor classify every healthy transcript as
* missing. These files are durable because beta.5 renames repaired transcripts
* to recovery archives; remove this bridge only after beta.5 is unsupported.
*/
declare function resolveSessionFilePath(sessionId: string, entry?: {
sessionFile?: string;
}, options?: {
agentId?: string;
sessionsDir?: string;
}): string;
/**
* Resolves the configured session store path.
*
* Beta.5 resolves a configured path with an agent id, then passes only the
* path to loadSessionStore/updateSessionStore. Its shipped callers either
* consume the selection synchronously or dedupe by path, so retaining the
* latest selection preserves that bounded compatibility contract.
*/
declare function resolveStorePath(store?: string, options?: {
agentId?: string;
env?: NodeJS.ProcessEnv;
}): string;
/**
* @deprecated Use getSessionEntry with a storage-neutral session identity.
*
* Official plugins released with v2026.7.1-beta.5 import this whole-store
* lookup helper. Keep it through 2026-10-12 with the other beta.5 bridge.
*/
declare function resolveSessionStoreEntry(params: {
store: Record<string, SessionEntry>;
sessionKey: string;
}): {
normalizedKey: string;
existing: SessionEntry | undefined;
legacyKeys: string[];
};
/** Loads one session entry by agent/session identity. */
declare function getSessionEntry(params: SessionStoreReadParams): SessionEntry | undefined;
/** Reads the current session binding of one canonical transport address. */
declare function getConversationSession(params: {
agentId: string;
env?: NodeJS.ProcessEnv;
storePath?: string;
channel: string;
accountId: string;
kind: "channel" | "direct" | "group";
peerId: string;
threadId?: string;
}): {
sessionKey: string;
sessionId: string;
} | undefined;
/**
* Lists session entries for one agent. `readOnly` reads without joining the
* agent database writable lifecycle (no create/register/migrate) — required
* for detection/introspection paths that may run across the whole fleet.
* One flagged entry instead of a second export keeps the SDK surface budget flat.
*/
declare function listSessionEntries(params?: SessionStoreListParams & {
readOnly?: boolean;
}): SessionStoreEntrySummary[];
/** Reads transcript events for a live SQLite-backed session identity. */
declare function loadTranscriptEventsSync(params: {
agentId?: string;
env?: NodeJS.ProcessEnv;
sessionId: string;
sessionKey?: string;
storePath?: string;
}): SessionStoreTranscriptEvent[];
/** Reads transcript freshness and byte size without materializing event rows. */
declare function readTranscriptStatsSync(params: {
agentId?: string;
env?: NodeJS.ProcessEnv;
sessionId: string;
sessionKey?: string;
storePath?: string;
}): {
eventCount: number;
maxSeq: number;
sizeBytes: number;
};
/** Resolves the persisted session key for one SQLite transcript identity. */
declare function resolveTranscriptSessionKeyBySessionId(params: {
agentId?: string;
env?: NodeJS.ProcessEnv;
sessionId: string;
storePath?: string;
}): string | undefined;
/** Patches one session entry by agent/session identity. */
declare function patchSessionEntry(params: PatchSessionEntryParams): Promise<SessionEntry | null>;
/** Reads the last activity timestamp for one session entry. */
declare function readSessionUpdatedAt(params: SessionStoreReadParams): number | undefined;
declare function readAmbientTranscriptWatermark(params: ReadAmbientTranscriptWatermarkParams): AmbientTranscriptWatermark | undefined;
/** Updates an existing session entry by store path and session key. */
declare function updateSessionStoreEntry(params: UpdateSessionStoreEntryParams): Promise<SessionEntry | null>;
/** Replaces or creates one session entry by agent/session identity. */
declare function upsertSessionEntry(params: UpsertSessionEntryParams): Promise<void>;
/** Deletes one session entry by agent/session identity. */
declare function deleteSessionEntry(params: DeleteSessionEntryParams): Promise<boolean>;
/** Resolves the file artifacts that should be backed up before mutating a session store. */
declare function resolveSessionStoreBackupPaths(params: {
agentId?: string;
storePath: string;
}): string[];
/** Cleans stale lifecycle-owned session entries and orphan transcripts for one agent store. */
declare function cleanupSessionLifecycleArtifacts(params: SessionLifecycleArtifactsCleanupParams): Promise<SessionLifecycleArtifactsCleanupResult>;
//#endregion
export { resolveAmbientTranscriptWatermarkKey as A, isValidAgentHarnessSessionStoreEntry as C, parseSqliteSessionFileMarker as D, formatSqliteSessionFileMarker as E, SessionResetMode as F, evaluateSessionFreshness as I, resolveSessionResetPolicy as L, resolveChannelResetConfig as M, resolveSessionResetType as N, sqliteSessionFileMarkerMatchesSession as O, resolveThreadFlag as P, upsertSessionEntry as S, SqliteSessionFileMarker as T, resolveSessionStoreEntry as _, deleteSessionEntry as a, updateSessionStore as b, listSessionEntries as c, patchSessionEntry as d, readAmbientTranscriptWatermark as f, resolveSessionStoreBackupPaths as g, resolveSessionFilePath as h, cleanupSessionLifecycleArtifacts as i, updateAmbientTranscriptWatermark as j, AmbientTranscriptWatermarkScope as k, loadSessionStore as l, readTranscriptStatsSync as m, SessionStoreTranscriptEvent as n, getConversationSession as o, readSessionUpdatedAt as p, UpdateSessionStoreOptions as r, getSessionEntry as s, LoadSessionStoreOptions as t, loadTranscriptEventsSync as u, resolveStorePath as v, clearSessionStoreCacheForTest as w, updateSessionStoreEntry as x, resolveTranscriptSessionKeyBySessionId as y };