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

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

/**
 * Metadata wrapper for MCP tool call responses.
 *
 * @remarks
 *
 * Nests MCP-specific fields under `mcp_meta` to avoid collisions with other
 * metadata keys (e.g. `tool_call_result`) in Harmattan's streaming deltas.
 */
export type ConnectorToolCallMetadata = {
  mcpMeta?: ConnectorToolResultMetadata | null | undefined;
  [additionalProperties: string]: unknown;
};

/** @internal */
export const ConnectorToolCallMetadata$inboundSchema: z.ZodType<
  ConnectorToolCallMetadata,
  unknown
> = z.object({
  mcp_meta: z.nullable(ConnectorToolResultMetadata$inboundSchema).optional(),
}).catchall(z.any()).transform((v) => {
  return remap$(v, {
    "mcp_meta": "mcpMeta",
  });
});

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