/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; import { safeParse } from "../lib/schemas.js"; import * as openEnums from "../types/enums.js"; import { OpenEnum } from "../types/enums.js"; import { Result as SafeParseResult } from "../types/fp.js"; import * as types from "../types/primitives.js"; import { SDKValidationError } from "./errors/sdk-validation-error.js"; export const Role = { User: "user", Assistant: "assistant", System: "system", Tool: "tool", } as const; export type Role = OpenEnum; export type ToolCall = { name: string; args: { [k: string]: any }; }; export type AgentMemoryTurnMessage = { role: Role; content: string; timestamp?: number | undefined; toolCalls?: Array | undefined; }; /** @internal */ export const Role$inboundSchema: z.ZodMiniType = openEnums .inboundSchema(Role); /** @internal */ export const Role$outboundSchema: z.ZodMiniType = openEnums .outboundSchema(Role); /** @internal */ export const ToolCall$inboundSchema: z.ZodMiniType = z .object({ name: types.string(), args: z.record(z.string(), z.any()), }); /** @internal */ export type ToolCall$Outbound = { name: string; args: { [k: string]: any }; }; /** @internal */ export const ToolCall$outboundSchema: z.ZodMiniType< ToolCall$Outbound, ToolCall > = z.object({ name: z.string(), args: z.record(z.string(), z.any()), }); export function toolCallToJSON(toolCall: ToolCall): string { return JSON.stringify(ToolCall$outboundSchema.parse(toolCall)); } export function toolCallFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ToolCall$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ToolCall' from JSON`, ); } /** @internal */ export const AgentMemoryTurnMessage$inboundSchema: z.ZodMiniType< AgentMemoryTurnMessage, unknown > = z.object({ role: Role$inboundSchema, content: types.string(), timestamp: types.optional(types.number()), toolCalls: types.optional(z.array(z.lazy(() => ToolCall$inboundSchema))), }); /** @internal */ export type AgentMemoryTurnMessage$Outbound = { role: string; content: string; timestamp?: number | undefined; toolCalls?: Array | undefined; }; /** @internal */ export const AgentMemoryTurnMessage$outboundSchema: z.ZodMiniType< AgentMemoryTurnMessage$Outbound, AgentMemoryTurnMessage > = z.object({ role: Role$outboundSchema, content: z.string(), timestamp: z.optional(z.int()), toolCalls: z.optional(z.array(z.lazy(() => ToolCall$outboundSchema))), }); export function agentMemoryTurnMessageToJSON( agentMemoryTurnMessage: AgentMemoryTurnMessage, ): string { return JSON.stringify( AgentMemoryTurnMessage$outboundSchema.parse(agentMemoryTurnMessage), ); } export function agentMemoryTurnMessageFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AgentMemoryTurnMessage$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AgentMemoryTurnMessage' from JSON`, ); }