import type { Pool } from "mysql2/promise"; import type { Pool as PgPool } from "pg"; /** * Audit view of a session = its **current context** (the live messages + the last compaction's * summary), i.e. the floor-bounded window — never the full raw transcript. This matches the * deployment decision that audit/回溯 needs "current + summary" ([ref]); the full `session_event` * log remains available as a separate cold-forensic query if ever needed. */ export interface SessionAudit { sessionId: string; createdAt: string; /** The bounded-window floor (last compaction's firstKeptEntryId), or null if never compacted. */ floorEntryId: string | null; thinkingLevel: string; model: { provider: string; modelId: string; } | null; /** Current model context: prior messages with older history collapsed into a summary message. */ messages: unknown[]; /** [ref]① web 观测切片 B: the session's prompt-epoch pin, core contract verbatim (core 1.304 * `session.getPromptEpoch()` — first-class `prompt_epoch` entry, compaction restatement, [ref] anchor * all inside core). Additive; a pre-epoch session omits the key entirely (undefined). */ promptEpoch?: { epoch: number; artifactDigest: string; packId: string; assemblyApi: number; activatedBy: "session_start" | "compaction" | "legacy_migration"; }; } /** Build the audit view from the durable log. Returns undefined if the session does not exist. */ export declare function buildSessionAudit(pool: Pool, sessionId: string): Promise; /** The PG twin — same view over PgSessionStorage.wake. Until this, the * audit face was TiDB-only and a PG/local deployment 404'd the whole web session area. local = follow-on * (its storage seam has no wake-equivalent yet — may turn out to be a core gap). */ export declare function buildSessionAuditPg(pool: PgPool, sessionId: string): Promise; /** The LOCAL (File) leg — web session area on DB_BACKEND=local. * 实现姿势:`FileSessionRepo.exportEntries`(纯读、torn-tail 恢复、missing→not_found)→ * `boundedTail`(纯函数切 floor)→ InMemorySessionStorage → 同一 auditFromStorage 内核。零写面、 * 零新 seam;createdAt 从 repo.list() 的 metadata 取(File 形态 meta 与 entries 分储)。 */ export declare function buildSessionAuditLocal(root: string, sessionId: string): Promise; /** Window `messages` — `tail=N` (last N) or `before=&limit=N` ([max(0,before-N), before)). * Returns the window + its {offset,total} so the web can page upward. */ export declare function windowMessages(messages: unknown[], opts: { tail?: number; before?: number; limit?: number; }): { messages: unknown[]; window: { offset: number; total: number; }; }; /** Cap oversized STRING bodies inside a message (top-level `content` string, or `text`/`content` * string fields of content parts — the shapes core emits; anything else passes through untouched). A capped * message gains `truncated: true` (message level — the web renders an expand affordance and refetches that * one message at full size). Pure/copy-on-write: uncapped messages keep their original reference. * [ref]①:超预算时引擎注入块(INJECTED_BLOCK_RE 闭集)优先整段让位,用户正文最后截。 */ export declare function truncateMessageBlobs(messages: unknown[], capBytes: number): unknown[]; //# sourceMappingURL=audit.d.ts.map