import { AgentContract } from "../contracts/agent/agent.contract.mjs"; import { JudgeConfig } from "./judge-config.type.mjs"; import { AgentConfig } from "./agent-config.type.mjs"; //#region ../ai/src/agent/agent.d.ts /** * Creates an executable AI agent from the given configuration. * * The agent runs a bounded trip loop: each trip calls the model, dispatches * any requested tool calls, then loops until the model stops or `maxTrips` * is reached. Each `execute()` / `stream()` call spawns a fresh internal * `Execution` instance — the factory itself holds no state across calls. * * `execute()` never throws — any error is attached to the returned result * under `result.error`. `stream()` surfaces errors both on the terminal * `error` stream event and via the `stream.result` promise. * * @example * const myAgent = agent({ * model: openai.model({ name: "gpt-4o" }), * systemPrompt: "You are a helpful assistant.", * tools: [searchTool], * }); * * const result = await myAgent.execute("What is the capital of Egypt?"); * * @example * const stream = myAgent.stream("Write a haiku about Cairo."); * * for await (const event of stream) { * if (event.type === "streaming") process.stdout.write(event.delta); * } * * const result = await stream.result; */ declare function agent(config: AgentConfig): AgentContract; declare namespace agent { var judge: typeof judgeAgent; } /** * Config for the `ai.agent.judge(...)` helper — every `AgentConfig` field * except `judge` itself (the helper sets it). Callers tune resilience by * passing a {@link JudgeConfig} as the second argument instead. */ type JudgeAgentConfig = Omit, "judge">; /** * Build a judge-safe agent — sugar for `agent({ ...config, judge })`. * * Use this for LLM-as-judge graders and verdict classifiers running on * models that may emit corrupted structured output (e.g. the Amazon Nova * family). The returned agent parses verdicts leniently (tolerates fenced * ` ```json ` blocks + surrounding prose), auto-enables a couple of repair * re-asks, and never throws on a parse miss — surfacing `result.error` with * `result.data` left undefined so a flaky judge degrades gracefully. * * See {@link AgentConfig.judge} for the full behavior + the resilience-over- * strictness trade-off. * * @param config - Any agent config (model, system prompt, output schema, …). * @param judge - Optional fine-tuning ({@link JudgeConfig}); defaults to `true`. * * @example * const grader = ai.agent.judge({ * model: nova.model({ name: "amazon.nova-pro-v1:0" }), * systemPrompt: "Grade the answer. Respond with JSON only.", * output: verdictSchema, * }); * * const result = await grader.execute(prompt); * if (result.error) { * // graceful default — the judge couldn't produce a clean verdict * } */ declare function judgeAgent(config: JudgeAgentConfig, judge?: JudgeConfig | boolean): AgentContract; //#endregion export { JudgeAgentConfig, agent }; //# sourceMappingURL=agent.d.mts.map