/** * Ergonomic authoring facade for single-node inline agents. * * `agent(name, { model, instructions, tools, output }).compile()` lowers a * terse definition to the wire-canonical `InlineAgentSpec` and runs the * existing pre-wire validator — a thin convenience layer over the object * literal consumers already write, not a second spec model. The compiled * spec drops straight into `client.tasks.startWithAgent({ agent })`, which * keeps owning transport, optional HTTP preflight, and tool auto-binding. * * `outputSchema(zodSchema)` derives an `output_schema` from a Zod schema * through the *same* `z.toJSONSchema()` path tool `parameters` use (see * {@link zodToJsonSchema}) so a type reused as both a tool arg and an agent * output produces identical JSON Schema. * * Scope is deliberately single-node: multi-agent topologies use the * `InlineGraphSpec` shape directly. The facade first-classes the four * fields most agents set; specs needing `skills`, `use_managed_tools`, * `content_trust`, etc. author the `InlineAgentSpec` literal directly — * that surface stays fully supported. */ import { z } from 'zod'; import type { FunctionToolDef, InlineAgentSpec, Instructions, OutputSchemaSpec } from '../qar/specs.js'; /** Options for {@link outputSchema}. */ export interface OutputSchemaOptions { /** * `output_schema.json_schema.name` — the structured-output schema name * the model provider echoes back. Defaults to `'output'`. */ readonly name?: string; /** * OpenAI strict-mode flag forwarded onto `json_schema.strict`. Omitted * by default (the server picks its default — currently `true`), matching * how `defineFunctionTool` leaves `function.strict` unset. */ readonly strict?: boolean; } /** * Derive an AgentSpec `output_schema` from a Zod schema. * * Uses the shared {@link zodToJsonSchema} derivation, so a Zod type used * for both a tool's `parameters` and an agent's `output` yields the same * JSON Schema body and the same `draft-07` dialect the wire validator and * model provider expect. * * @example * const spec = agent('summarizer', { * model: 'gpt-4o', * instructions: 'Summarize the input.', * output: z.object({ summary: z.string(), wordCount: z.number() }), * }).compile(); */ export declare function outputSchema(schema: z.ZodType, opts?: OutputSchemaOptions): OutputSchemaSpec; /** Terse definition lowered to an {@link InlineAgentSpec} by {@link agent}. */ export interface AgentDefinition { /** Model slug forwarded to `InlineAgentSpec.model`. */ readonly model: string; /** System instructions — a string or a `{ preset, append? }` reference. */ readonly instructions: Instructions; /** * Function tools the agent may call. Pass `defineFunctionTool(...)` * results (handler auto-binds at `startWithAgent`) or hand-authored * `FunctionToolDef` literals. */ readonly tools?: readonly FunctionToolDef[]; /** * Structured-output schema. A Zod schema derives the `output_schema` * (default name `'output'`); pass a pre-built {@link OutputSchemaSpec} * (e.g. from {@link outputSchema} with a custom name/strict) to control * those. */ readonly output?: z.ZodType | OutputSchemaSpec; } /** Builder returned by {@link agent}. */ export interface AgentBuilder { /** * Lower the definition to an {@link InlineAgentSpec} and run the * SDK's pre-wire validator (`assertInlineAgentSpecPreWire`). Throws * `QodoInlineAgentValidationError` on a structural violation. The HTTP * spec preflight stays opt-in on `startWithAgent({ preflight: true })`. */ compile(): InlineAgentSpec; } /** * Begin a single-node inline agent definition. * * @example * import { agent, defineFunctionTool } from '@qodo/sdk'; * import { z } from 'zod'; * * const spec = agent('greeter', { * model: 'gpt-4o', * instructions: 'Greet the user by name.', * tools: [getCurrentTime], * output: z.object({ greeting: z.string() }), * }).compile(); * * const stream = client.tasks.startWithAgent({ agent: spec, input }); */ export declare function agent(name: string, def: AgentDefinition): AgentBuilder; //# sourceMappingURL=agentBuilder.d.ts.map