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

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 { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type AgentHandoffDoneEvent = {
  type: "agent.handoff.done";
  createdAt?: Date | undefined;
  outputIndex: number;
  id: string;
  nextAgentId: string;
  nextAgentName: string;
};

/** @internal */
export const AgentHandoffDoneEvent$inboundSchema: z.ZodType<
  AgentHandoffDoneEvent,
  unknown
> = z.object({
  type: z.literal("agent.handoff.done"),
  created_at: z.iso.datetime({ offset: true }).transform(v => new Date(v))
    .optional(),
  output_index: z.int().default(0),
  id: z.string(),
  next_agent_id: z.string(),
  next_agent_name: z.string(),
}).transform((v) => {
  return remap$(v, {
    "created_at": "createdAt",
    "output_index": "outputIndex",
    "next_agent_id": "nextAgentId",
    "next_agent_name": "nextAgentName",
  });
});

export function agentHandoffDoneEventFromJSON(
  jsonString: string,
): SafeParseResult<AgentHandoffDoneEvent, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => AgentHandoffDoneEvent$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'AgentHandoffDoneEvent' from JSON`,
  );
}
