/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: e3e5ab88e018
 */

import * as z from "zod/v4";
import { smartUnion } from "../../types/smartUnion.js";
import {
  BuiltInConnectors,
  BuiltInConnectors$outboundSchema,
} from "./builtinconnectors.js";

export type ToolUnion = BuiltInConnectors | string;

export type ToolReferenceChunk = {
  type?: "tool_reference" | undefined;
  tool: BuiltInConnectors | string;
  title: string;
  url?: string | null | undefined;
  favicon?: string | null | undefined;
  description?: string | null | undefined;
};

/** @internal */
export type ToolUnion$Outbound = string | string;

/** @internal */
export const ToolUnion$outboundSchema: z.ZodType<
  ToolUnion$Outbound,
  ToolUnion
> = smartUnion([BuiltInConnectors$outboundSchema, z.string()]);

export function toolUnionToJSON(toolUnion: ToolUnion): string {
  return JSON.stringify(ToolUnion$outboundSchema.parse(toolUnion));
}

/** @internal */
export type ToolReferenceChunk$Outbound = {
  type: "tool_reference";
  tool: string | string;
  title: string;
  url?: string | null | undefined;
  favicon?: string | null | undefined;
  description?: string | null | undefined;
};

/** @internal */
export const ToolReferenceChunk$outboundSchema: z.ZodType<
  ToolReferenceChunk$Outbound,
  ToolReferenceChunk
> = z.object({
  type: z.literal("tool_reference").default("tool_reference" as const),
  tool: smartUnion([BuiltInConnectors$outboundSchema, z.string()]),
  title: z.string(),
  url: z.nullable(z.string()).optional(),
  favicon: z.nullable(z.string()).optional(),
  description: z.nullable(z.string()).optional(),
});

export function toolReferenceChunkToJSON(
  toolReferenceChunk: ToolReferenceChunk,
): string {
  return JSON.stringify(
    ToolReferenceChunk$outboundSchema.parse(toolReferenceChunk),
  );
}
