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

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";
import { Failure, Failure$inboundSchema } from "./failure.js";

/**
 * Attributes for custom task failed events.
 */
export type CustomTaskFailedAttributes = {
  /**
   * Unique identifier for the custom task within the workflow.
   */
  customTaskId: string;
  /**
   * The type/category of the custom task (e.g., 'llm_call', 'api_request').
   */
  customTaskType: string;
  /**
   * Represents an error or exception that occurred during execution.
   */
  failure: Failure;
};

/** @internal */
export const CustomTaskFailedAttributes$inboundSchema: z.ZodType<
  CustomTaskFailedAttributes,
  unknown
> = z.object({
  custom_task_id: z.string(),
  custom_task_type: z.string(),
  failure: Failure$inboundSchema,
}).transform((v) => {
  return remap$(v, {
    "custom_task_id": "customTaskId",
    "custom_task_type": "customTaskType",
  });
});

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