import type { AgentStepExecutor, AgentStepRequest, AgentStepSubmission, ConversationRange } from "../workflows/types.js"; export type SubmissionResult = { accepted: true; message: string; } | { accepted: false; message: string; }; export type PromptDelivery = { prompt: string; /** True when the agent is known to be mid-run, so delivery must be queued. */ streaming: boolean; }; /** * Bracketing hooks for conversation linkage: a mark is taken when the step * prompt is first delivered, and the recorded entry range since that mark is * attached to the accepted submission. */ export type ConversationHooks = { beginAttempt?: (contract: AgentStepRequest["contract"]) => void; mark: () => number; rangeSince: (mark: number) => ConversationRange | undefined; }; export type ConversationStepExecutorOptions = { /** Deliver a prompt into the pi conversation. */ sendPrompt: (delivery: PromptDelivery) => void; /** Reminders sent when the agent settles without submitting. Default 2. */ maxNudges?: number; /** Conversation linkage hooks, wired to the session recorder. */ conversation?: ConversationHooks; }; /** * AgentStepExecutor that runs steps inside the current pi conversation. The * engine hands it a prompt; it delivers the prompt as a user message and * resolves once the model submits an accepted output through the `workflow` * tool. If the agent settles without submitting, it nudges the model a * bounded number of times before failing the step. */ export declare class ConversationStepExecutor implements AgentStepExecutor { private readonly sendPrompt; private readonly maxNudges; private readonly conversation; private pending; private streaming; private heldByUser; constructor(options: ConversationStepExecutorOptions); /** Track agent streaming state (wire to agent_start / agent_settled). */ setStreaming(streaming: boolean): void; get pendingStepId(): string | null; /** * Hold the pending step for the user: no nudges are sent while held, so an * escape-interrupted conversation stays quiet until the user resumes. */ hold(): void; get held(): boolean; /** * Release a user hold. When a step is still pending, its prompt is * re-delivered so the model picks the step back up. */ release(): void; runAgentStep(request: AgentStepRequest, signal: AbortSignal): Promise; /** Called by the `workflow` tool when the model submits a step output. */ submit(stepId: string, attemptId: string, output: unknown): Promise; /** * Called when the agent settles. Returns true when a nudge was sent, false * when there was nothing to do. Fails the pending step once the nudge * budget is exhausted. */ handleAgentSettled(): boolean; private clearPending; }