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

import * as z from "zod/v4";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  ClientTasksCapability,
  ClientTasksCapability$inboundSchema,
} from "./clienttaskscapability.js";
import {
  ElicitationCapability,
  ElicitationCapability$inboundSchema,
} from "./elicitationcapability.js";
import {
  RootsCapability,
  RootsCapability$inboundSchema,
} from "./rootscapability.js";
import {
  SamplingCapability,
  SamplingCapability$inboundSchema,
} from "./samplingcapability.js";

/**
 * Capabilities a client may support.
 */
export type ClientCapabilities = {
  experimental?: { [k: string]: { [k: string]: any } } | null | undefined;
  sampling?: SamplingCapability | null | undefined;
  elicitation?: ElicitationCapability | null | undefined;
  roots?: RootsCapability | null | undefined;
  tasks?: ClientTasksCapability | null | undefined;
  [additionalProperties: string]: unknown;
};

/** @internal */
export const ClientCapabilities$inboundSchema: z.ZodType<
  ClientCapabilities,
  unknown
> = z.object({
  experimental: z.nullable(z.record(z.string(), z.record(z.string(), z.any())))
    .optional(),
  sampling: z.nullable(SamplingCapability$inboundSchema).optional(),
  elicitation: z.nullable(ElicitationCapability$inboundSchema).optional(),
  roots: z.nullable(RootsCapability$inboundSchema).optional(),
  tasks: z.nullable(ClientTasksCapability$inboundSchema).optional(),
}).catchall(z.any());

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