/* * 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 AgentVersionObject = { AgentVersion: "agent.version", } as const; export type AgentVersionObject = ClosedEnum; export type AgentVersion = { object: AgentVersionObject; id: string; agentId: string; version: number; /** * True when this version matches the agent's current configuration. */ isCurrent: boolean; /** * When this version was produced by a rollback, the version it was restored from. */ restoredFromVersion: number | null; 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 }; createdAt: Date; }; /** @internal */ export const AgentVersionObject$inboundSchema: z.ZodNativeEnum< typeof AgentVersionObject > = z.nativeEnum(AgentVersionObject); /** @internal */ export const AgentVersionObject$outboundSchema: z.ZodNativeEnum< typeof AgentVersionObject > = AgentVersionObject$inboundSchema; /** @internal */ export const AgentVersion$inboundSchema: z.ZodType< AgentVersion, z.ZodTypeDef, unknown > = z.object({ object: AgentVersionObject$inboundSchema, id: z.string(), agent_id: z.string(), version: z.number().int(), is_current: z.boolean(), restored_from_version: z.nullable(z.number().int()), 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()), created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), }).transform((v) => { return remap$(v, { "agent_id": "agentId", "is_current": "isCurrent", "restored_from_version": "restoredFromVersion", "tool_choice": "toolChoice", "parallel_tool_calls": "parallelToolCalls", "max_tool_calls": "maxToolCalls", "created_at": "createdAt", }); }); /** @internal */ export type AgentVersion$Outbound = { object: string; id: string; agent_id: string; version: number; is_current: boolean; restored_from_version: number | null; 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 }; created_at: string; }; /** @internal */ export const AgentVersion$outboundSchema: z.ZodType< AgentVersion$Outbound, z.ZodTypeDef, AgentVersion > = z.object({ object: AgentVersionObject$outboundSchema, id: z.string(), agentId: z.string(), version: z.number().int(), isCurrent: z.boolean(), restoredFromVersion: z.nullable(z.number().int()), 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()), createdAt: z.date().transform(v => v.toISOString()), }).transform((v) => { return remap$(v, { agentId: "agent_id", isCurrent: "is_current", restoredFromVersion: "restored_from_version", toolChoice: "tool_choice", parallelToolCalls: "parallel_tool_calls", maxToolCalls: "max_tool_calls", createdAt: "created_at", }); }); export function agentVersionToJSON(agentVersion: AgentVersion): string { return JSON.stringify(AgentVersion$outboundSchema.parse(agentVersion)); } export function agentVersionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AgentVersion$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AgentVersion' from JSON`, ); }