import { type z } from 'zod'; import { type Msg } from '../index.js'; export type CtxVal = Record; export type Agent = { name: string; model?: string; functions: SwarmFunc[]; instructions: string | ((args: CtxVal) => string); toolChoice?: string; parallelToolCalls?: boolean; }; export type SwarmFuncResult = { value: string; agent?: Agent; ctx?: CtxVal; }; export interface SwarmFunc = z.ZodObject> { /** The implementation of the function, with arg parsing and validation. */ (input: string | Msg): Promise; /** The Zod schema for the arguments string. */ argsSchema: Schema; /** Parse the function arguments from a message. */ parseArgs(input: string | Msg): z.infer; /** The function spec for the OpenAI API `functions` property. */ spec: { name: string; description?: string; parameters: Record; }; } export type SwarmResponse = { messages: Msg[]; agent: Agent; ctx: CtxVal; };