/** * ContextRecorder — observes footprintjs subflow + scope events, emits * grouped `context.*` domain events via the EventDispatcher. * * Pattern: Observer (GoF) + Pipes & Filters (Hohpe & Woolf, 2003). * Role: Core semantic grouping layer for the 3-slot model. Watches * slot subflows (sf-system-prompt / sf-messages / sf-tools) and * translates raw writes into context.injected / evicted / * slot_composed / budget_pressure events. * Emits: agentfootprint.context.injected * agentfootprint.context.evicted * agentfootprint.context.slot_composed * agentfootprint.context.budget_pressure */ import type { CombinedRecorder, FlowSubflowEvent, WriteEvent } from 'footprintjs'; import type { EventDispatcher } from '../../events/dispatcher.js'; import { type RunContext } from '../../bridge/eventMeta.js'; /** * Supplies the recorder with run-level context. Passed at construction * time (static fields) OR updated via `updateRunContext` between runs * when reusing one recorder across multiple executor runs. */ export interface ContextRecorderOptions { readonly dispatcher: EventDispatcher; readonly id?: string; readonly getRunContext: () => RunContext; } export declare class ContextRecorder implements CombinedRecorder { readonly id: string; private readonly dispatcher; private readonly getRunContext; private readonly seenInjections; constructor(options: ContextRecorderOptions); onSubflowEntry(event: FlowSubflowEvent): void; onSubflowExit(event: FlowSubflowEvent): void; onWrite(event: WriteEvent): void; private handleInjectionsWrite; private handleSlotComposedWrite; private handleEvictionsWrite; private handleBudgetPressureWrite; private emitInjected; private dispatch; private asInjectionArray; private asSlotComposition; private asEvictionArray; private asPressureArray; }