/** * BackgroundReviewCoordinator — owns the per-session counters that decide when * to nudge the model into running a quiet user-understanding review * after a normal user turn finishes. * * The nudge state and review scheduling are kept out of the per-session agent * instance so: * - `AgentInstance` no longer carries an inline counter object. * - Future changes to the review cadence only touch this file. */ import type { Agent } from '@earendil-works/pi-agent-core'; import type { Config } from '../../config/schema.js'; export interface BackgroundReviewCoordinatorOptions { /** Effective config snapshot used to look up review-cadence settings. */ getConfig: () => Config | undefined; } export interface ScheduleReviewContext { conversationId: string; agent: Agent; /** Last assistant text — review is skipped when empty. */ lastAssistantText: string | null; workspaceId: string; } export declare class BackgroundReviewCoordinator { private readonly opts; private readonly states; constructor(opts: BackgroundReviewCoordinatorOptions); /** * Called before the main `agent.prompt` for a user turn — bumps the review * counter and arms a review when the cadence interval is hit. */ beginUserTurn(conversationId: string): void; /** Reserve a due review and return the work without starting it. */ createReviewTaskAfterUserTurn(ctx: ScheduleReviewContext): (() => Promise) | undefined; /** Tear down state for a session (called by `AgentManager.removeAgent`). */ forgetSession(conversationId: string): void; /** Clear every counter (`AgentManager.dispose` / hot reload). */ clear(): void; private ensureState; }