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

import * as z from "zod/v3";
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 AgentHandoffStartedEvent = {
  type?: "agent.handoff.started" | undefined;
  createdAt?: Date | undefined;
  outputIndex: number | undefined;
  id: string;
  previousAgentId: string;
  previousAgentName: string;
};

/** @internal */
export const AgentHandoffStartedEvent$inboundSchema: z.ZodType<
  AgentHandoffStartedEvent,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: z.literal("agent.handoff.started").default("agent.handoff.started"),
  created_at: z.string().datetime({ offset: true }).transform(v => new Date(v))
    .optional(),
  output_index: z.number().int().default(0),
  id: z.string(),
  previous_agent_id: z.string(),
  previous_agent_name: z.string(),
}).transform((v) => {
  return remap$(v, {
    "created_at": "createdAt",
    "output_index": "outputIndex",
    "previous_agent_id": "previousAgentId",
    "previous_agent_name": "previousAgentName",
  });
});

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