/** * Run-epoch coordination for the agent loop. * * Each call to `runAgentLoop` bumps its sessionKey's epoch and closes over the * new value. Any stream.push captured by an earlier run of the same sessionKey * discovers its epoch is stale and silently drops — the "later run wins" * preemption pattern. * * The default `runEpochBySessionKey` is a MODULE-LEVEL Map, i.e. a * process-wide singleton. This is intentional for the single-agent CLI case * (only one MossAgent instance per process) but INCORRECT when a host embeds * multiple MossAgent instances that may collide on the same sessionKey — they * would stomp each other's epochs and cancel each other's live streams. * * MossAgent instances therefore pass their OWN Map via * `AgentLoopExtensions.runEpochStore`; both `bumpAgentLoopRunEpoch` and * `guardMiniAgentStreamPush` accept it as an optional argument. * When omitted, they fall back to the singleton for backwards compatibility. */ import type { EventStream } from '../../provider/pi-ai-types.js'; import type { MiniAgentEvent, MiniAgentResult } from '../subagent/agent-events.js'; /** Exposed for tests/hosts that want the singleton store explicitly. */ export declare function getDefaultRunEpochStore(): Map; export declare function bumpAgentLoopRunEpoch(sessionKey: string, store?: Map): number; export declare function guardMiniAgentStreamPush(stream: EventStream, sessionKey: string, runEpoch: number, store?: Map): void; //# sourceMappingURL=agent-loop-push-guard.d.ts.map