/* * 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"; export const AgentRunObject = { AgentRun: "agent.run", } as const; export type AgentRunObject = ClosedEnum; export const AgentRunStatus = { Queued: "queued", Submitting: "submitting", Completed: "completed", Failed: "failed", } as const; export type AgentRunStatus = ClosedEnum; export type AgentRun = { object: AgentRunObject; id: string; agentId: string; /** * The agent configuration version this run executed against. Null for runs created before versioning. */ agentVersion: number | null; status: AgentRunStatus; /** * Arbitrary JSON value. */ input?: any | undefined; conversation?: any | null | undefined; previousResponseId: string | null; metadata: { [k: string]: string } | null; gatewayResponseId: string | null; gatewayResponse?: any | null | undefined; error?: any | null | undefined; createdAt: Date; completedAt: Date | null; }; /** @internal */ export const AgentRunObject$inboundSchema: z.ZodNativeEnum< typeof AgentRunObject > = z.nativeEnum(AgentRunObject); /** @internal */ export const AgentRunObject$outboundSchema: z.ZodNativeEnum< typeof AgentRunObject > = AgentRunObject$inboundSchema; /** @internal */ export const AgentRunStatus$inboundSchema: z.ZodNativeEnum< typeof AgentRunStatus > = z.nativeEnum(AgentRunStatus); /** @internal */ export const AgentRunStatus$outboundSchema: z.ZodNativeEnum< typeof AgentRunStatus > = AgentRunStatus$inboundSchema; /** @internal */ export const AgentRun$inboundSchema: z.ZodType< AgentRun, z.ZodTypeDef, unknown > = z.object({ object: AgentRunObject$inboundSchema, id: z.string(), agent_id: z.string(), agent_version: z.nullable(z.number().int()), status: AgentRunStatus$inboundSchema, input: z.any().optional(), conversation: z.nullable(z.any()).optional(), previous_response_id: z.nullable(z.string()), metadata: z.nullable(z.record(z.string())), gateway_response_id: z.nullable(z.string()), gateway_response: z.nullable(z.any()).optional(), error: z.nullable(z.any()).optional(), created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), completed_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ), }).transform((v) => { return remap$(v, { "agent_id": "agentId", "agent_version": "agentVersion", "previous_response_id": "previousResponseId", "gateway_response_id": "gatewayResponseId", "gateway_response": "gatewayResponse", "created_at": "createdAt", "completed_at": "completedAt", }); }); /** @internal */ export type AgentRun$Outbound = { object: string; id: string; agent_id: string; agent_version: number | null; status: string; input?: any | undefined; conversation?: any | null | undefined; previous_response_id: string | null; metadata: { [k: string]: string } | null; gateway_response_id: string | null; gateway_response?: any | null | undefined; error?: any | null | undefined; created_at: string; completed_at: string | null; }; /** @internal */ export const AgentRun$outboundSchema: z.ZodType< AgentRun$Outbound, z.ZodTypeDef, AgentRun > = z.object({ object: AgentRunObject$outboundSchema, id: z.string(), agentId: z.string(), agentVersion: z.nullable(z.number().int()), status: AgentRunStatus$outboundSchema, input: z.any().optional(), conversation: z.nullable(z.any()).optional(), previousResponseId: z.nullable(z.string()), metadata: z.nullable(z.record(z.string())), gatewayResponseId: z.nullable(z.string()), gatewayResponse: z.nullable(z.any()).optional(), error: z.nullable(z.any()).optional(), createdAt: z.date().transform(v => v.toISOString()), completedAt: z.nullable(z.date().transform(v => v.toISOString())), }).transform((v) => { return remap$(v, { agentId: "agent_id", agentVersion: "agent_version", previousResponseId: "previous_response_id", gatewayResponseId: "gateway_response_id", gatewayResponse: "gateway_response", createdAt: "created_at", completedAt: "completed_at", }); }); export function agentRunToJSON(agentRun: AgentRun): string { return JSON.stringify(AgentRun$outboundSchema.parse(agentRun)); } export function agentRunFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AgentRun$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AgentRun' from JSON`, ); }