import {z} from 'zod' export type AgentDefinition = {name: string, type: 'llm-call' | 'connector-call', llm?: ({provider?: string | undefined, model?: string | undefined}) | undefined, connector?: ({name?: string | undefined, operation?: string | undefined}) | undefined}; export type RoutingRule = {pattern: string, agent: string, priority?: number | undefined}; export type AgentConfigSpec = {execution?: ({default_mode?: ('auto' | 'parallel' | 'sequential') | undefined, max_parallel_tasks?: number | undefined, timeout_seconds?: number | undefined}) | undefined, agents?: Array | undefined, routing?: Array | undefined}; export type ValidateAgentRequest = {name?: string | undefined, domain?: string | undefined, config: AgentConfigSpec}; export type CreateApiApiV1AgentsValidateArgs = {body: ValidateAgentRequest}; export type CreateApiApiV1AgentsValidateOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const validationResponse = z.object({valid: z.boolean().optional(), errors: z.array(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 }; /** * Validate agent configuration (Enterprise) * * POST /api/v1/agents/validate */ export const createApiApiV1AgentsValidate = async (args: CreateApiApiV1AgentsValidateArgs, options?: CreateApiApiV1AgentsValidateOptions) => { const {baseUrl = "https://orchestrator.getaxonflow.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/agents/validate${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(validationResponse, await res.json()) };