import {z} from 'zod' export type GetApiApiV1AgentsIdArgs = {id: string}; export type GetApiApiV1AgentsIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const agentDefinition = z.object({name: z.string(), type: z.enum(["llm-call", "connector-call"]), llm: z.object({provider: z.string().optional(), model: z.string().optional()}).optional(), connector: z.object({name: z.string().optional(), operation: z.string().optional()}).optional()}); export const routingRule = z.object({pattern: z.string(), agent: z.string(), priority: z.number().int().optional()}); export const agentConfigSpec = z.object({execution: z.object({default_mode: z.enum(["auto", "parallel", "sequential"]).optional(), max_parallel_tasks: z.number().int().optional(), timeout_seconds: z.number().int().optional()}).optional(), agents: z.array(agentDefinition).optional(), routing: z.array(routingRule).optional()}); export const agentResource = z.object({id: z.string().optional(), name: z.string().optional(), domain: z.string().optional(), description: z.string().optional(), version: z.number().int().optional(), is_active: z.boolean().optional(), config: agentConfigSpec.optional(), created_at: z.string().optional(), updated_at: z.string().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Get agent by ID (Enterprise) * * GET /api/v1/agents/{id} */ export const getApiApiV1AgentsId = async (args: GetApiApiV1AgentsIdArgs, options?: GetApiApiV1AgentsIdOptions) => { const {baseUrl = "https://orchestrator.getaxonflow.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/agents/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(agentResource, await res.json()) };