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

import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import * as openEnums from "../../types/enums.js";
import { OpenEnum } from "../../types/enums.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export const FunctionCallEventConfirmationStatus = {
  Pending: "pending",
  Allowed: "allowed",
  Denied: "denied",
} as const;
export type FunctionCallEventConfirmationStatus = OpenEnum<
  typeof FunctionCallEventConfirmationStatus
>;

export type FunctionCallEvent = {
  type: "function.call.delta";
  createdAt?: Date | undefined;
  outputIndex: number;
  id: string;
  model?: string | null | undefined;
  agentId?: string | null | undefined;
  name: string;
  toolCallId: string;
  arguments: string;
  confirmationStatus?: FunctionCallEventConfirmationStatus | null | undefined;
};

/** @internal */
export const FunctionCallEventConfirmationStatus$inboundSchema: z.ZodType<
  FunctionCallEventConfirmationStatus,
  unknown
> = openEnums.inboundSchema(FunctionCallEventConfirmationStatus);

/** @internal */
export const FunctionCallEvent$inboundSchema: z.ZodType<
  FunctionCallEvent,
  unknown
> = z.object({
  type: z.literal("function.call.delta"),
  created_at: z.iso.datetime({ offset: true }).transform(v => new Date(v))
    .optional(),
  output_index: z.int().default(0),
  id: z.string(),
  model: z.nullable(z.string()).optional(),
  agent_id: z.nullable(z.string()).optional(),
  name: z.string(),
  tool_call_id: z.string(),
  arguments: z.string(),
  confirmation_status: z.nullable(
    FunctionCallEventConfirmationStatus$inboundSchema,
  ).optional(),
}).transform((v) => {
  return remap$(v, {
    "created_at": "createdAt",
    "output_index": "outputIndex",
    "agent_id": "agentId",
    "tool_call_id": "toolCallId",
    "confirmation_status": "confirmationStatus",
  });
});

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