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

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 {
  JSONPayloadResponse,
  JSONPayloadResponse$inboundSchema,
} from "./jsonpayloadresponse.js";

/**
 * Attributes for custom task completed events.
 */
export type CustomTaskCompletedAttributesResponse = {
  /**
   * 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;
  /**
   * A payload containing arbitrary JSON data.
   *
   * @remarks
   *
   * Used for complete state snapshots or final results.
   * When encrypted, the value field contains base64-encoded encrypted data
   * and encoding_options indicates the type of encryption applied.
   */
  payload: JSONPayloadResponse;
};

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

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