import type z from 'zod'; import type { AgentLLMIntegrationParam } from '../Integrations/types.js'; import type { IMCPClient } from '../interfaces.mcp.js'; import type { IPermissionManager, PermissionManagerContext } from '../interfaces.permission.manager.js'; import type { OtelInfoType } from '../types.js'; import type { AgentEventStreamer } from './stream/types.js'; import type { AgentMessage, AgentOutputBuilder, AgentToolDefinition, CreateArvoAgentParam } from './types.js'; /** * The Core Cognitive Loop of the Arvo Agent. * * This function implements the **ReAct (Reason + Act)** pattern, orchestrating the interactive * session between the Large Language Model (LLM) and the available Tool ecosystem. * * @remarks * **Hybrid Execution Strategy:** * The loop handles two types of tool executions differently: * 1. **Synchronous Tools (Internal & MCP):** These are executed **immediately** within the loop. * The results are added to the history, and the LLM is called again in the same tick. * 2. **Asynchronous Tools (Arvo Services):** These interrupt the loop. The function returns * the tool call definition, signaling the parent `ArvoResumable` to **emit an event and suspend**. * * **Self-Correction:** * If the LLM's final output fails the Contract's Output Schema validation (via `outputBuilder`), * the loop catches the error and feeds it back to the LLM for auto-correction. * * @param param.currentSubject - The Arvo orchestration subject of the currently executing agent instance. * Passed through to every internal tool invocation so tools can identify which agent is calling them. * @param param.parentSubject - The Arvo orchestration subject of the parent orchestrator that invoked * this agent. `null` when this agent is the root of the orchestration tree. Also forwarded to * every internal tool invocation. */ export declare const agentLoop: (param: { currentSubject: string; parentSubject: string | null; initLifecycle: AgentLLMIntegrationParam["lifecycle"]; system: string | null; messages: AgentMessage[]; tools: AgentToolDefinition[]; outputFormat: z.ZodTypeAny; outputBuilder: AgentOutputBuilder; llmResponseType: NonNullable["responseType"]>; llm: NonNullable["llm"]>; preInferenceHook: NonNullable["hooks"]>["preInference"]> | null; postInferenceHook: NonNullable["hooks"]>["postInference"]> | null; mcp: IMCPClient | null; agentCycles: { current: number; max: number; }; currentTotalExecutionUnits: number; currentTotalUsageTokens: { prompt: number; completion: number; }; onStream: AgentEventStreamer; permissionPolicy: string[]; permissionManager: IPermissionManager | null; permissionManagerContext: PermissionManagerContext; }, config: { otelInfo: OtelInfoType; }) => Promise<{ messages: { content: { type: "tool_result"; toolUseId: string; content: string; } | { type: "text"; content: string; } | { type: "media"; content: string; contentType: { type: "image"; name: string; mediatype: string; format: "base64"; } | { type: "file"; name: string; mediatype: string; format: "base64"; }; } | { type: "tool_use"; toolUseId: string; name: string; input: Record; }; role: "user" | "assistant"; seenCount: number; }[]; toolCalls: { type: "tool_use"; toolUseId: string; name: string; input: Record; }[]; agentCycles: { current: number; max: number; }; executionUnits: number; tokenUsage: { prompt: number; completion: number; }; output?: undefined; } | { messages: { content: { type: "tool_result"; toolUseId: string; content: string; } | { type: "text"; content: string; } | { type: "media"; content: string; contentType: { type: "image"; name: string; mediatype: string; format: "base64"; } | { type: "file"; name: string; mediatype: string; format: "base64"; }; } | { type: "tool_use"; toolUseId: string; name: string; input: Record; }; role: "user" | "assistant"; seenCount: number; }[]; output: { [x: string]: any; } & { __id?: import("arvo-core").CreateArvoEvent, string>["id"]; __executionunits?: import("arvo-core").CreateArvoEvent, string>["executionunits"]; }; agentCycles: { current: number; max: number; }; executionUnits: number; tokenUsage: { prompt: number; completion: number; }; toolCalls?: undefined; }>; //# sourceMappingURL=agentLoop.d.ts.map