/* * 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 { collectExtraKeys as collectExtraKeys$, safeParse, } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AgentCompactionContextManagement, AgentCompactionContextManagement$inboundSchema, AgentCompactionContextManagement$Outbound, AgentCompactionContextManagement$outboundSchema, } from "./agentcompactioncontextmanagement.js"; export type CreateAgentRunRequestInput2 = { type?: string | undefined; additionalProperties?: { [k: string]: any } | undefined; }; export type CreateAgentRunRequestInput = | string | Array; export type CreateAgentRunRequest = { input: string | Array; /** * Arbitrary JSON value. */ conversation?: any | undefined; previousResponseId?: string | undefined; /** * Context management strategies to apply during agent-run response generation. Supports compaction, which summarizes older conversation history when the context exceeds a token threshold. */ contextManagement?: Array | undefined; metadata?: { [k: string]: string } | undefined; }; /** @internal */ export const CreateAgentRunRequestInput2$inboundSchema: z.ZodType< CreateAgentRunRequestInput2, z.ZodTypeDef, unknown > = collectExtraKeys$( z.object({ type: z.string().optional(), }).catchall(z.any()), "additionalProperties", true, ); /** @internal */ export type CreateAgentRunRequestInput2$Outbound = { type?: string | undefined; [additionalProperties: string]: unknown; }; /** @internal */ export const CreateAgentRunRequestInput2$outboundSchema: z.ZodType< CreateAgentRunRequestInput2$Outbound, z.ZodTypeDef, CreateAgentRunRequestInput2 > = z.object({ type: z.string().optional(), additionalProperties: z.record(z.any()).optional(), }).transform((v) => { return { ...v.additionalProperties, ...remap$(v, { additionalProperties: null, }), }; }); export function createAgentRunRequestInput2ToJSON( createAgentRunRequestInput2: CreateAgentRunRequestInput2, ): string { return JSON.stringify( CreateAgentRunRequestInput2$outboundSchema.parse( createAgentRunRequestInput2, ), ); } export function createAgentRunRequestInput2FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateAgentRunRequestInput2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateAgentRunRequestInput2' from JSON`, ); } /** @internal */ export const CreateAgentRunRequestInput$inboundSchema: z.ZodType< CreateAgentRunRequestInput, z.ZodTypeDef, unknown > = z.union([ z.string(), z.array(z.lazy(() => CreateAgentRunRequestInput2$inboundSchema)), ]); /** @internal */ export type CreateAgentRunRequestInput$Outbound = | string | Array; /** @internal */ export const CreateAgentRunRequestInput$outboundSchema: z.ZodType< CreateAgentRunRequestInput$Outbound, z.ZodTypeDef, CreateAgentRunRequestInput > = z.union([ z.string(), z.array(z.lazy(() => CreateAgentRunRequestInput2$outboundSchema)), ]); export function createAgentRunRequestInputToJSON( createAgentRunRequestInput: CreateAgentRunRequestInput, ): string { return JSON.stringify( CreateAgentRunRequestInput$outboundSchema.parse(createAgentRunRequestInput), ); } export function createAgentRunRequestInputFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateAgentRunRequestInput$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateAgentRunRequestInput' from JSON`, ); } /** @internal */ export const CreateAgentRunRequest$inboundSchema: z.ZodType< CreateAgentRunRequest, z.ZodTypeDef, unknown > = z.object({ input: z.union([ z.string(), z.array(z.lazy(() => CreateAgentRunRequestInput2$inboundSchema)), ]), conversation: z.any().optional(), previous_response_id: z.string().optional(), context_management: z.array(AgentCompactionContextManagement$inboundSchema) .optional(), metadata: z.record(z.string()).optional(), }).transform((v) => { return remap$(v, { "previous_response_id": "previousResponseId", "context_management": "contextManagement", }); }); /** @internal */ export type CreateAgentRunRequest$Outbound = { input: string | Array; conversation?: any | undefined; previous_response_id?: string | undefined; context_management?: | Array | undefined; metadata?: { [k: string]: string } | undefined; }; /** @internal */ export const CreateAgentRunRequest$outboundSchema: z.ZodType< CreateAgentRunRequest$Outbound, z.ZodTypeDef, CreateAgentRunRequest > = z.object({ input: z.union([ z.string(), z.array(z.lazy(() => CreateAgentRunRequestInput2$outboundSchema)), ]), conversation: z.any().optional(), previousResponseId: z.string().optional(), contextManagement: z.array(AgentCompactionContextManagement$outboundSchema) .optional(), metadata: z.record(z.string()).optional(), }).transform((v) => { return remap$(v, { previousResponseId: "previous_response_id", contextManagement: "context_management", }); }); export function createAgentRunRequestToJSON( createAgentRunRequest: CreateAgentRunRequest, ): string { return JSON.stringify( CreateAgentRunRequest$outboundSchema.parse(createAgentRunRequest), ); } export function createAgentRunRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateAgentRunRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateAgentRunRequest' from JSON`, ); }