/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AgentReasoningConfiguration, AgentReasoningConfiguration$inboundSchema, AgentReasoningConfiguration$Outbound, AgentReasoningConfiguration$outboundSchema, } from "./agentreasoningconfiguration.js"; import { AgentTextConfiguration, AgentTextConfiguration$inboundSchema, AgentTextConfiguration$Outbound, AgentTextConfiguration$outboundSchema, } from "./agenttextconfiguration.js"; import { ToolDefinition, ToolDefinition$inboundSchema, ToolDefinition$Outbound, ToolDefinition$outboundSchema, } from "./tooldefinition.js"; export const AgentObject = { Agent: "agent", } as const; export type AgentObject = ClosedEnum; export type Agent = { object: AgentObject; id: string; name: string; description: string | null; model: string; instructions: string | null; tools: Array; /** * Arbitrary JSON value. */ toolChoice?: any | undefined; parallelToolCalls: boolean; maxToolCalls: number | null; text: AgentTextConfiguration | null; reasoning: AgentReasoningConfiguration | null; metadata: { [k: string]: string }; /** * Current configuration version. Incremented on every update or rollback. */ version: number; createdAt: Date; updatedAt: Date; deletedAt: Date | null; }; /** @internal */ export const AgentObject$inboundSchema: z.ZodNativeEnum = z .nativeEnum(AgentObject); /** @internal */ export const AgentObject$outboundSchema: z.ZodNativeEnum = AgentObject$inboundSchema; /** @internal */ export const Agent$inboundSchema: z.ZodType = z .object({ object: AgentObject$inboundSchema, id: z.string(), name: z.string(), description: z.nullable(z.string()), model: z.string(), instructions: z.nullable(z.string()), tools: z.array(ToolDefinition$inboundSchema), tool_choice: z.any().optional(), parallel_tool_calls: z.boolean(), max_tool_calls: z.nullable(z.number().int()), text: z.nullable(AgentTextConfiguration$inboundSchema), reasoning: z.nullable(AgentReasoningConfiguration$inboundSchema), metadata: z.record(z.string()), version: z.number().int(), created_at: z.string().datetime({ offset: true }).transform(v => new Date(v) ), updated_at: z.string().datetime({ offset: true }).transform(v => new Date(v) ), deleted_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ), }).transform((v) => { return remap$(v, { "tool_choice": "toolChoice", "parallel_tool_calls": "parallelToolCalls", "max_tool_calls": "maxToolCalls", "created_at": "createdAt", "updated_at": "updatedAt", "deleted_at": "deletedAt", }); }); /** @internal */ export type Agent$Outbound = { object: string; id: string; name: string; description: string | null; model: string; instructions: string | null; tools: Array; tool_choice?: any | undefined; parallel_tool_calls: boolean; max_tool_calls: number | null; text: AgentTextConfiguration$Outbound | null; reasoning: AgentReasoningConfiguration$Outbound | null; metadata: { [k: string]: string }; version: number; created_at: string; updated_at: string; deleted_at: string | null; }; /** @internal */ export const Agent$outboundSchema: z.ZodType< Agent$Outbound, z.ZodTypeDef, Agent > = z.object({ object: AgentObject$outboundSchema, id: z.string(), name: z.string(), description: z.nullable(z.string()), model: z.string(), instructions: z.nullable(z.string()), tools: z.array(ToolDefinition$outboundSchema), toolChoice: z.any().optional(), parallelToolCalls: z.boolean(), maxToolCalls: z.nullable(z.number().int()), text: z.nullable(AgentTextConfiguration$outboundSchema), reasoning: z.nullable(AgentReasoningConfiguration$outboundSchema), metadata: z.record(z.string()), version: z.number().int(), createdAt: z.date().transform(v => v.toISOString()), updatedAt: z.date().transform(v => v.toISOString()), deletedAt: z.nullable(z.date().transform(v => v.toISOString())), }).transform((v) => { return remap$(v, { toolChoice: "tool_choice", parallelToolCalls: "parallel_tool_calls", maxToolCalls: "max_tool_calls", createdAt: "created_at", updatedAt: "updated_at", deletedAt: "deleted_at", }); }); export function agentToJSON(agent: Agent): string { return JSON.stringify(Agent$outboundSchema.parse(agent)); } export function agentFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Agent$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Agent' from JSON`, ); }