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

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 {
  PromptsCapability,
  PromptsCapability$inboundSchema,
} from "./promptscapability.js";
import {
  ResourcesCapability,
  ResourcesCapability$inboundSchema,
} from "./resourcescapability.js";
import {
  ServerTasksCapability,
  ServerTasksCapability$inboundSchema,
} from "./servertaskscapability.js";
import {
  ToolsCapability,
  ToolsCapability$inboundSchema,
} from "./toolscapability.js";

/**
 * Capabilities that a server may support.
 */
export type ServerCapabilities = {
  experimental?: { [k: string]: { [k: string]: any } } | null | undefined;
  logging?: { [k: string]: any } | null | undefined;
  prompts?: PromptsCapability | null | undefined;
  resources?: ResourcesCapability | null | undefined;
  tools?: ToolsCapability | null | undefined;
  completions?: { [k: string]: any } | null | undefined;
  tasks?: ServerTasksCapability | null | undefined;
  [additionalProperties: string]: unknown;
};

/** @internal */
export const ServerCapabilities$inboundSchema: z.ZodType<
  ServerCapabilities,
  unknown
> = z.object({
  experimental: z.nullable(z.record(z.string(), z.record(z.string(), z.any())))
    .optional(),
  logging: z.nullable(z.record(z.string(), z.any())).optional(),
  prompts: z.nullable(PromptsCapability$inboundSchema).optional(),
  resources: z.nullable(ResourcesCapability$inboundSchema).optional(),
  tools: z.nullable(ToolsCapability$inboundSchema).optional(),
  completions: z.nullable(z.record(z.string(), z.any())).optional(),
  tasks: z.nullable(ServerTasksCapability$inboundSchema).optional(),
}).catchall(z.any());

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