import { type VersionedArvoContract } from 'arvo-core'; import type { AgentInternalTool } from '../AgentTool/types.js'; import type { AgentServiceContract, AnyArvoOrchestratorContract, CreateArvoAgentParam } from './types.js'; /** * Creates a fully-featured AI Agent implemented as an Arvo Resumable Event Handler. * * This factory transforms a Large Language Model into a stateful, event-driven participant * in your Arvo system. The resulting agent operates on a start-stop-resume execution model, * consuming zero resources between event processing cycles while maintaining conversation * state in persistent memory. * * @remark * **Execution Model:** * The agent follows a start-stop-resume pattern. On initialization, it builds context from * the input event, then enters a ReAct (Reason+Act) cognitive loop. When calling Arvo services, * it persists state to memory and suspends, enabling any worker to resume it later. This * eliminates long-running processes and enables horizontal scaling. * * **Tool Ecosystem:** * - **Internal Tools:** Synchronous functions for fast, CPU-bound operations. * - **MCP Tools:** External tools via Model Context Protocol (filesystem, databases, APIs). * - **Arvo Services:** Asynchronous event-driven services that trigger suspension. * * Both Internal and MCP tools execute synchronously within the loop, while Arvo service calls * cause the agent to emit events and suspend until responses arrive. * * **Priority Batch Execution:** * When the LLM requests multiple tools, they are sorted by priority. Only the highest-priority * batch executes; lower-priority calls are dropped. This enforces safety guardrails (e.g., * requiring human approval before destructive actions). * * **Permission Management:** * Tools can be placed under permission policy via `explicitPermissionRequired`. The permission * manager evaluates each tool call as APPROVED (execute), DENIED (block permanently), or * REQUESTABLE (block and emit permission request). Permission state persists across suspensions. * * **Self-Correction:** * If the LLM's outputs fails contract schema validation, the error is fed back and the * agent retries, enabling automatic repair of malformed responses or tools calls. * * @param param - Configuration object defining the agent's contracts, tools, memory backend, * LLM integration, and version-specific behavior handlers. * * @returns An ArvoResumable instance that participates in the event fabric as a standard * event handler, compatible with any Arvo broker implementation. * * @example * ```typescript * export const supportAgent = ({ memory }) => createArvoAgent({ * contracts: { * self: supportAgentContract, * services: { * billing: { * contract: billingServiceContract.version('1.0.0'), * priority: 0 * }, * humanApproval: { * contract: approvalContract.version('1.0.0'), * domains: ['human.interaction'], * priority: 100 // Executes before billing calls * } * } * }, * tools: { * checkTime: createAgentTool({ * name: 'check_time', * description: 'Returns current server time in ISO format', * input: z.object({}), * fn: async () => ({ data: { time: new Date().toISOString() } }) * }) * }, * inferenceConfig: { * llm: openaiLLMIntegration(new OpenAI(), { model: 'gpt-4o' }), * }, * memory: memory, * permissionManager: new SimplePermissionManager(), * handler: { * '1.0.0': { * explicitPermissionRequired: async ({ services }) => [ * services.billing.name // Require permission for billing calls * ], * context: AgentDefaults.CONTEXT_BUILDER(async ({ tools }) => * `You are a support agent with access to billing data via ${tools.services.billing.name}. * You must request approval via ${tools.services.humanApproval.name} before accessing billing.` * ), * output: AgentDefaults.OUTPUT_BUILDER * } * } * }); * ``` */ export declare const createArvoAgent: , TTools extends Record>({ contracts, memory, handler, inferenceConfig, mcp, maxAgentCycles, tools, onStream, permissionManager, defaultEventEmissionDomains, }: CreateArvoAgentParam) => import("arvo-event-handler").ArvoResumable<{ initEventAccessControl: string | null; system: string | null; 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; }[]; agentCycles: { max: number; current: number; }; enabledTools: Record; awaitingToolCalls: Record | null; }>; totalExecutionUnits: number; totalTokenUsage: { prompt: number; completion: number; }; currentSubject?: string | undefined; parentSubject?: string | null | undefined; }, TSelfContract, { [x: string]: VersionedArvoContract | VersionedArvoContract, any>; }>; //# sourceMappingURL=index.d.ts.map