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

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

/**
 * Capability for server tasks operations.
 */
export type ServerTasksCapability = {
  list?: { [k: string]: any } | null | undefined;
  cancel?: { [k: string]: any } | null | undefined;
  requests?: ServerTasksRequestsCapability | null | undefined;
  [additionalProperties: string]: unknown;
};

/** @internal */
export const ServerTasksCapability$inboundSchema: z.ZodType<
  ServerTasksCapability,
  unknown
> = z.object({
  list: z.nullable(z.record(z.string(), z.any())).optional(),
  cancel: z.nullable(z.record(z.string(), z.any())).optional(),
  requests: z.nullable(ServerTasksRequestsCapability$inboundSchema).optional(),
}).catchall(z.any());

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