/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Status, Status$inboundSchema, Status$outboundSchema, } from "./status.js"; /** * Function call item: A call to a function tool, including function name and JSON-string arguments. */ export type FunctionToolCallWithId = { type: "function_call"; arguments: string; callId: string; name: string; /** * The unique ID of the message. */ id: string; /** * The processing status of an individual item. 'in_progress' means currently processing, 'completed' means finished successfully, 'incomplete' means processing stopped before completion. */ status?: Status | undefined; /** * The ID of the response that created this item, if any. */ responseId?: string | null | undefined; /** * Metadata from the response that created this item, if any. */ metadata?: { [k: string]: string } | null | undefined; }; /** @internal */ export const FunctionToolCallWithId$inboundSchema: z.ZodType< FunctionToolCallWithId, z.ZodTypeDef, unknown > = z.object({ type: z.literal("function_call"), arguments: z.string(), call_id: z.string(), name: z.string(), id: z.string(), status: Status$inboundSchema.optional(), response_id: z.nullable(z.string()).optional(), metadata: z.nullable(z.record(z.string())).optional(), }).transform((v) => { return remap$(v, { "call_id": "callId", "response_id": "responseId", }); }); /** @internal */ export type FunctionToolCallWithId$Outbound = { type: "function_call"; arguments: string; call_id: string; name: string; id: string; status?: string | undefined; response_id?: string | null | undefined; metadata?: { [k: string]: string } | null | undefined; }; /** @internal */ export const FunctionToolCallWithId$outboundSchema: z.ZodType< FunctionToolCallWithId$Outbound, z.ZodTypeDef, FunctionToolCallWithId > = z.object({ type: z.literal("function_call"), arguments: z.string(), callId: z.string(), name: z.string(), id: z.string(), status: Status$outboundSchema.optional(), responseId: z.nullable(z.string()).optional(), metadata: z.nullable(z.record(z.string())).optional(), }).transform((v) => { return remap$(v, { callId: "call_id", responseId: "response_id", }); }); export function functionToolCallWithIdToJSON( functionToolCallWithId: FunctionToolCallWithId, ): string { return JSON.stringify( FunctionToolCallWithId$outboundSchema.parse(functionToolCallWithId), ); } export function functionToolCallWithIdFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FunctionToolCallWithId$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FunctionToolCallWithId' from JSON`, ); }