/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: e5810d7dbeb9
 */
import * as z from "zod/v4";
import { safeParse } from "../../lib/schemas.js";
import { discriminatedUnion } from "../../types/discriminatedUnion.js";
import { AgentHandoffDoneEvent$inboundSchema, } from "./agenthandoffdoneevent.js";
import { AgentHandoffStartedEvent$inboundSchema, } from "./agenthandoffstartedevent.js";
import { FunctionCallEvent$inboundSchema, } from "./functioncallevent.js";
import { MessageOutputEvent$inboundSchema, } from "./messageoutputevent.js";
import { ResponseDoneEvent$inboundSchema, } from "./responsedoneevent.js";
import { ResponseErrorEvent$inboundSchema, } from "./responseerrorevent.js";
import { ResponseStartedEvent$inboundSchema, } from "./responsestartedevent.js";
import { SSETypes$inboundSchema } from "./ssetypes.js";
import { ToolExecutionDeltaEvent$inboundSchema, } from "./toolexecutiondeltaevent.js";
import { ToolExecutionDoneEvent$inboundSchema, } from "./toolexecutiondoneevent.js";
import { ToolExecutionStartedEvent$inboundSchema, } from "./toolexecutionstartedevent.js";
/** @internal */
export const ConversationEventsData$inboundSchema = discriminatedUnion("type", {
    ["agent.handoff.done"]: AgentHandoffDoneEvent$inboundSchema,
    ["agent.handoff.started"]: AgentHandoffStartedEvent$inboundSchema,
    ["conversation.response.done"]: ResponseDoneEvent$inboundSchema,
    ["conversation.response.error"]: ResponseErrorEvent$inboundSchema,
    ["conversation.response.started"]: ResponseStartedEvent$inboundSchema,
    ["function.call.delta"]: FunctionCallEvent$inboundSchema,
    ["message.output.delta"]: MessageOutputEvent$inboundSchema,
    ["tool.execution.delta"]: ToolExecutionDeltaEvent$inboundSchema,
    ["tool.execution.done"]: ToolExecutionDoneEvent$inboundSchema,
    ["tool.execution.started"]: ToolExecutionStartedEvent$inboundSchema,
});
export function conversationEventsDataFromJSON(jsonString) {
    return safeParse(jsonString, (x) => ConversationEventsData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ConversationEventsData' from JSON`);
}
/** @internal */
export const ConversationEvents$inboundSchema = z.object({
    event: SSETypes$inboundSchema,
    data: z.string().transform((v, ctx) => {
        try {
            return JSON.parse(v);
        }
        catch (err) {
            ctx.addIssue({
                input: v,
                code: "custom",
                message: `malformed json: ${err}`,
            });
            return z.NEVER;
        }
    }).pipe(discriminatedUnion("type", {
        ["agent.handoff.done"]: AgentHandoffDoneEvent$inboundSchema,
        ["agent.handoff.started"]: AgentHandoffStartedEvent$inboundSchema,
        ["conversation.response.done"]: ResponseDoneEvent$inboundSchema,
        ["conversation.response.error"]: ResponseErrorEvent$inboundSchema,
        ["conversation.response.started"]: ResponseStartedEvent$inboundSchema,
        ["function.call.delta"]: FunctionCallEvent$inboundSchema,
        ["message.output.delta"]: MessageOutputEvent$inboundSchema,
        ["tool.execution.delta"]: ToolExecutionDeltaEvent$inboundSchema,
        ["tool.execution.done"]: ToolExecutionDoneEvent$inboundSchema,
        ["tool.execution.started"]: ToolExecutionStartedEvent$inboundSchema,
    })),
});
export function conversationEventsFromJSON(jsonString) {
    return safeParse(jsonString, (x) => ConversationEvents$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ConversationEvents' from JSON`);
}
//# sourceMappingURL=conversationevents.js.map