/** * daemon/image-context.ts — Per-session image context for conversational refinement. * * Tracks prompt history and the last generated image per routing context. * The composite key (source:recipient:sessionId) ensures complete isolation * between users, adapters, and sessions. */ export interface ImageContext { /** Each refinement step as a standalone phrase, oldest first. */ promptHistory: string[]; /** The most recently generated image buffer (for native img2img). */ lastImage?: Buffer; /** MIME type of lastImage ("image/webp" | "image/png"). */ lastImageMime: string; /** Unix ms timestamp — used for TTL eviction. */ updatedAt: number; } /** * Build the composite routing key for image context lookup. * Format: "{source}:{recipient}:{sessionId}" */ export declare function buildImageContextKey(source: string, recipient: string | undefined, sessionId: string | undefined): string; export declare function getImageContext(key: string): ImageContext | undefined; export declare function setImageContext(key: string, ctx: ImageContext): void; export declare function clearImageContext(key: string): void; /** * Remove image contexts that haven't been updated within the TTL window. * Returns the number of evicted entries. */ export declare function pruneStaleContexts(ttlMs?: number): number; /** * Classify an incoming text message as a new image request, a refinement * of the current image context, or unrelated to image generation. * * Only returns "refine" when there is an actual signal — a pronoun * referencing the image, a modification verb, or a style keyword. * Messages that don't contain any image-related signal fall through * as "unrelated" so they reach normal routing (Claude, slash commands, etc.). */ export declare function classifyImageRequest(text: string, context: ImageContext | undefined): { type: "new" | "refine" | "unrelated"; prompt: string; }; /** * Build a combined prompt from the full prompt history using prompt chaining. * * The first entry is the base description; subsequent entries are refinement * phrases appended with ", ". Cap at MAX_HISTORY entries. */ export declare function buildChainedPrompt(history: string[]): string; /** * Append a new prompt phrase to the context's history, enforcing the cap. * Returns an updated context object (does NOT mutate the original). */ export declare function appendPromptToContext(existing: ImageContext | undefined, prompt: string, imageBuffer?: Buffer, imageMime?: string): ImageContext; //# sourceMappingURL=image-context.d.ts.map