import type { AfterToolCallContext, AgentTurnContext, BeforeToolCallContext, BeforeToolCallResult } from '@earendil-works/pi-agent-core'; export interface AgentTurnPolicy { reset(): void; beforeToolCall(context: BeforeToolCallContext, signal?: AbortSignal): Promise; afterToolCall(context: AfterToolCallContext): Promise; shouldStopAfterTurn(context: AgentTurnContext): boolean; /** One bounded continuation requested by a policy, e.g. a budget handoff. */ takeContinuationMessage?(): string | undefined; /** Recheck limits at dispatch, including requests made by recovery paths. */ beforeModelRequest?(signal?: AbortSignal): string | undefined; stopReason?(): 'completed' | 'limit'; } export interface AgentTurnPolicyOptions { maxTurns?: number; maxToolFailures?: number; resolveToolLimit?: (toolName: string, args: unknown) => { id: string; maxCalls: number; } | undefined; authorizeToolCall?: (context: BeforeToolCallContext, signal?: AbortSignal) => Promise; } /** One user-visible run policy. A fresh instance is created for every embedded run. */ export declare function createAgentTurnPolicy(options: AgentTurnPolicyOptions): AgentTurnPolicy;