import type { SummaryRecord } from "../storage/types.js"; import type { BuildContextPacketInput, ContextPacket, ContextPacketStore, RoomContextCompactionResult, RoomContextResetResult, RoomContextUsage } from "./types.js"; export interface RoomSummaryMessage { seq: number; eventId: string; actorId: string; actorDisplayName: string; occurredAt: string; content: string; } export interface RoomCompactionRequest { roomId: string; previousSummary?: SummaryRecord; messages: readonly RoomSummaryMessage[]; fromSeq: number; throughSeq: number; maxOutputChars: number; signal: AbortSignal; } export type RoomCompactionProgress = { phase: "started"; roomId: string; operationId: string; attempt: number; maxAttempts: number; fromSeq: number; throughSeq: number; messageCount: number; } | { phase: "retrying"; roomId: string; operationId: string; attempt: number; maxAttempts: number; fromSeq: number; throughSeq: number; messageCount: number; nextDelayMs: number; errorCode: string; } | { phase: "completed"; roomId: string; operationId: string; attempt: number; maxAttempts: number; fromSeq: number; throughSeq: number; messageCount: number; generatorActorId: string; summaryChars: number; } | { phase: "failed"; roomId: string; operationId: string; attempt: number; maxAttempts: number; fromSeq: number; throughSeq: number; messageCount: number; errorCode: string; }; export interface RoomCompactionResult { content: string; generatorActorId: string; } export interface RoomContextSummarizer { compact(input: RoomCompactionRequest): Promise; } export interface RoomContextEngineOptions { store: ContextPacketStore & { replaceActiveSummary(input: { summaryId?: string; roomId: string; fromSeq: number; throughSeq: number; content: string; generatorActorId: string; expectedPreviousSummaryId?: string; createdAt?: string; }): SummaryRecord; recordContextReset(input: { roomId: string; throughSeq: number; resetNativeSessions?: boolean; createdAt?: string; }): import("../storage/types.js").ContextResetRecord; }; summarizer: RoomContextSummarizer; maxChars: number; /** Soft packet target. The configured maxChars remains the hard ceiling. */ compactionTriggerChars?: number; maxPasses?: number; maxCompactionInputChars?: number; maxSummaryChars?: number; /** Total attempts for one compactable chunk, including the first attempt. */ compactionAttempts?: number; compactionRetryBaseMs?: number; /** Recent message.created records left verbatim after an explicit compaction. */ manualRetainMessages?: number; /** Best-effort semantic archive hook before older raw messages leave the packet. */ beforeCompaction?: (input: { roomId: string; throughSeq: number; signal: AbortSignal; }) => void | Promise; onProgress?: (progress: RoomCompactionProgress) => void | Promise; } /** * Builds bounded room context and rolls old transcript into a durable checkpoint * only when the packet would otherwise omit unread messages. */ export declare class RoomContextEngine { #private; constructor(options: RoomContextEngineOptions); prepare(input: Omit): Promise; /** * Conservative room-level estimate: active checkpoint plus every * message.created record after it. Target-specific identity/memory and native * instructions are deliberately not presented as model-token usage. */ inspectUsage(roomId: string): RoomContextUsage; resetNow(roomId: string, resetNativeSessions?: boolean): RoomContextResetResult; /** Explicitly rolls old message.created records into the same durable summary * used by automatic compaction while retaining a recent verbatim tail. */ compactNow(roomId: string): Promise; close(): void; } //# sourceMappingURL=context-engine.d.ts.map