/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 98c38f18d407 */ import * as z from "zod/v4"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { smartUnion } from "../../types/smartUnion.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Annotations, Annotations$inboundSchema } from "./annotations.js"; import { BlobResourceContents, BlobResourceContents$inboundSchema, } from "./blobresourcecontents.js"; import { TextResourceContents, TextResourceContents$inboundSchema, } from "./textresourcecontents.js"; export type Resource = TextResourceContents | BlobResourceContents; /** * The contents of a resource, embedded into a prompt or tool call result. * * @remarks * * It is up to the client how best to render embedded resources for the benefit * of the LLM and/or the user. */ export type EmbeddedResource = { type: "resource"; resource: TextResourceContents | BlobResourceContents; annotations?: Annotations | null | undefined; meta?: { [k: string]: any } | null | undefined; [additionalProperties: string]: unknown; }; /** @internal */ export const Resource$inboundSchema: z.ZodType = smartUnion([ TextResourceContents$inboundSchema, BlobResourceContents$inboundSchema, ]); export function resourceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Resource$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Resource' from JSON`, ); } /** @internal */ export const EmbeddedResource$inboundSchema: z.ZodType< EmbeddedResource, unknown > = z.object({ type: z.literal("resource"), resource: smartUnion([ TextResourceContents$inboundSchema, BlobResourceContents$inboundSchema, ]), annotations: z.nullable(Annotations$inboundSchema).optional(), _meta: z.nullable(z.record(z.string(), z.any())).optional(), }).catchall(z.any()).transform((v) => { return remap$(v, { "_meta": "meta", }); }); export function embeddedResourceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EmbeddedResource$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EmbeddedResource' from JSON`, ); }