// This file is auto-generated by @hey-api/openapi-ts
import { defaultOnError, excludeKnownTags, preserveCustomPayload, requiredDefaultOnError, vecSkipError, } from "../../schema-deserialize.js";
import * as z from "zod/v4";
/**
 * JSON RPC Request Id
 *
 * An identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null \[1\] and Numbers SHOULD NOT contain fractional parts \[2\]
 *
 * The Server MUST reply with the same value in the Response object if included. This member is used to correlate the context between the two objects.
 *
 * \[1\] The use of Null as a value for the id member in a Request object is discouraged, because this specification uses a value of Null for Responses with an unknown id. Also, because JSON-RPC 1.0 uses an id value of Null for Notifications this could cause confusion in handling.
 *
 * \[2\] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions.
 */
export const zRequestId = z.union([z.number(), z.string()]).nullable();
/**
 * A unique identifier for a conversation session between a client and agent.
 *
 * Sessions maintain their own context, conversation history, and state,
 * allowing multiple independent interactions with the same agent.
 *
 * See protocol docs: [Session ID](https://agentclientprotocol.com/protocol/v2/draft/session-setup#session-id)
 */
export const zSessionId = z.string();
/**
 * Unique identifier for a tool call within a session.
 */
export const zToolCallId = z.string();
/**
 * Categories of tools that can be invoked.
 *
 * Tool kinds help clients choose appropriate icons and optimize how they
 * display tool execution progress.
 *
 * See protocol docs: [Creating](https://agentclientprotocol.com/protocol/v2/draft/tool-calls#creating)
 */
export const zToolKind = z.union([
    z.literal("read"),
    z.literal("edit"),
    z.literal("delete"),
    z.literal("move"),
    z.literal("search"),
    z.literal("execute"),
    z.literal("think"),
    z.literal("fetch"),
    z.literal("switch_mode"),
    z.literal("other"),
    z.string(),
]);
/**
 * Execution status of a tool call.
 *
 * Tool calls progress through different statuses during their lifecycle.
 *
 * See protocol docs: [Status](https://agentclientprotocol.com/protocol/v2/draft/tool-calls#status)
 */
export const zToolCallStatus = z.union([
    z.literal("pending"),
    z.literal("in_progress"),
    z.literal("completed"),
    z.literal("failed"),
    z.literal("cancelled"),
    z.string(),
]);
/**
 * The sender or recipient of messages and data in a conversation.
 */
export const zRole = z.union([
    z.literal("assistant"),
    z.literal("user"),
    z.string(),
]);
/**
 * Optional annotations for the client. The client can use annotations to inform how objects are used or displayed
 */
export const zAnnotations = z.object({
    audience: defaultOnError(vecSkipError(zRole).nullish(), () => undefined),
    lastModified: defaultOnError(z.iso.datetime({ offset: true }).nullish(), () => undefined),
    priority: defaultOnError(z.number().gte(0).lte(1).nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Text provided to or from an LLM.
 */
export const zTextContent = z.object({
    text: z.string(),
    annotations: defaultOnError(zAnnotations.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * An Internet media type identifying the format of protocol content.
 */
export const zMediaType = z.string();
/**
 * An image provided to or from an LLM.
 */
export const zImageContent = z.object({
    data: z.string(),
    mimeType: zMediaType,
    uri: defaultOnError(z.url().nullish(), () => undefined),
    annotations: defaultOnError(zAnnotations.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Audio provided to or from an LLM.
 */
export const zAudioContent = z.object({
    data: z.string(),
    mimeType: zMediaType,
    annotations: defaultOnError(zAnnotations.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Theme an icon is designed for.
 */
export const zIconTheme = z.union([
    z.literal("light"),
    z.literal("dark"),
    z.string(),
]);
/**
 * An optionally-sized icon that can be displayed in a user interface.
 */
export const zIcon = z.object({
    src: z.url(),
    mimeType: defaultOnError(zMediaType.nullish(), () => undefined),
    sizes: defaultOnError(vecSkipError(z.string()).nullish(), () => undefined),
    theme: defaultOnError(zIconTheme.nullish(), () => undefined),
});
/**
 * A resource that the server is capable of reading, included in a prompt or tool call result.
 */
export const zResourceLink = z.object({
    name: z.string(),
    uri: z.url(),
    title: defaultOnError(z.string().nullish(), () => undefined),
    description: defaultOnError(z.string().nullish(), () => undefined),
    icons: defaultOnError(vecSkipError(zIcon).nullish(), () => undefined),
    mimeType: defaultOnError(zMediaType.nullish(), () => undefined),
    size: defaultOnError(z.number().nullish(), () => undefined),
    annotations: defaultOnError(zAnnotations.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Text-based resource contents.
 */
export const zTextResourceContents = z.object({
    text: z.string(),
    uri: z.url(),
    mimeType: defaultOnError(zMediaType.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Binary resource contents.
 */
export const zBlobResourceContents = z.object({
    blob: z.string(),
    uri: z.url(),
    mimeType: defaultOnError(zMediaType.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Resource content that can be embedded in a message.
 */
export const zEmbeddedResourceResource = z.union([
    zTextResourceContents,
    zBlobResourceContents,
]);
/**
 * The contents of a resource, embedded into a prompt or tool call result.
 */
export const zEmbeddedResource = z.object({
    resource: zEmbeddedResourceResource,
    annotations: defaultOnError(zAnnotations.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Content blocks represent displayable information in the Agent Client Protocol.
 *
 * They provide a structured way to handle various types of user-facing content—whether
 * it's text from language models, images for analysis, or embedded resources for context.
 *
 * Content blocks appear in:
 * - User prompts sent via `session/prompt`
 * - Language model output reported through `session/update` notifications as
 * message updates or streamed chunks
 * - Progress updates and results from tool calls
 *
 * This structure is compatible with the Model Context Protocol (MCP), enabling
 * agents to seamlessly forward content from MCP tool outputs without transformation.
 *
 * See protocol docs: [Content](https://agentclientprotocol.com/protocol/v2/draft/content)
 *
 * Custom variants (unknown `type` values) keep their extra
 * properties exactly as received; unlike known variants, those keys
 * bypass lenient-field salvage and arrive unvalidated.
 */
export const zContentBlock = preserveCustomPayload(z.union([
    zTextContent.and(z.object({
        type: z.literal("text"),
    })),
    zImageContent.and(z.object({
        type: z.literal("image"),
    })),
    zAudioContent.and(z.object({
        type: z.literal("audio"),
    })),
    zResourceLink.and(z.object({
        type: z.literal("resource_link"),
    })),
    zEmbeddedResource.and(z.object({
        type: z.literal("resource"),
    })),
    excludeKnownTags(z.object({
        type: z.string(),
    }), "type", ["audio", "image", "resource", "resource_link", "text"]),
]), "type", ["audio", "image", "resource", "resource_link", "text"]);
/**
 * Standard content block (text, images, resources).
 */
export const zContent = z.object({
    content: zContentBlock,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Kind of file content represented by a diff change.
 */
export const zDiffFileType = z.union([
    z.literal("text"),
    z.literal("binary"),
    z.literal("directory"),
    z.literal("symlink"),
    z.string(),
]);
/**
 * An absolute filesystem path used by the protocol.
 */
export const zAbsolutePath = z.string();
/**
 * Operation metadata for add, delete, and modify changes.
 */
export const zDiffPathChange = z.object({
    path: zAbsolutePath,
});
/**
 * Operation metadata for move and copy changes.
 */
export const zDiffPathPairChange = z.object({
    oldPath: zAbsolutePath,
    path: zAbsolutePath,
});
/**
 * One file-level change described by a [`Diff`].
 *
 * Structured change metadata lets clients identify affected files and
 * operations without parsing the text patch.
 *
 * Custom variants (unknown `operation` values) keep their extra
 * properties exactly as received; unlike known variants, those keys
 * bypass lenient-field salvage and arrive unvalidated.
 */
export const zDiffChange = preserveCustomPayload(z.intersection(z.union([
    zDiffPathChange.and(z.object({
        operation: z.literal("add"),
    })),
    zDiffPathChange.and(z.object({
        operation: z.literal("delete"),
    })),
    zDiffPathChange.and(z.object({
        operation: z.literal("modify"),
    })),
    zDiffPathPairChange.and(z.object({
        operation: z.literal("move"),
    })),
    zDiffPathPairChange.and(z.object({
        operation: z.literal("copy"),
    })),
    excludeKnownTags(z.object({
        operation: z.string(),
    }), "operation", ["add", "copy", "delete", "modify", "move"]),
]), z.object({
    fileType: defaultOnError(zDiffFileType.nullish(), () => undefined),
    mimeType: defaultOnError(zMediaType.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
})), "operation", ["add", "copy", "delete", "modify", "move"]);
/**
 * Text patch format used by [`DiffPatch`].
 */
export const zDiffPatchFormat = z.union([z.literal("git_patch"), z.string()]);
/**
 * Renderable patch text and its format.
 */
export const zDiffPatch = z.object({
    format: zDiffPatchFormat,
    text: z.string(),
});
/**
 * File changes produced by a tool call.
 *
 * `changes` is authoritative for affected absolute paths and operations.
 * `patch` optionally carries renderable text for some or all of those changes
 * and MUST be consistent with `changes`. Agents SHOULD provide `patch` whenever
 * feasible. Clients MUST handle diffs where `patch` is omitted or `null`.
 *
 * See protocol docs: [Content](https://agentclientprotocol.com/protocol/v2/draft/tool-calls#content)
 */
export const zDiff = z.object({
    changes: vecSkipError(zDiffChange),
    patch: defaultOnError(zDiffPatch.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Unique identifier for an agent-owned terminal within a session.
 */
export const zTerminalId = z.string();
/**
 * A display-only reference to an agent-owned terminal.
 *
 * Terminal state and output are delivered separately through
 * [`TerminalUpdate`] and [`TerminalOutputChunk`].
 */
export const zTerminal = z.object({
    terminalId: zTerminalId,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Content produced by a tool call.
 *
 * Tool calls can produce different types of content including standard
 * content blocks (text, images), file diffs, or display-only terminals.
 *
 * See protocol docs: [Content](https://agentclientprotocol.com/protocol/v2/draft/tool-calls#content)
 *
 * Custom variants (unknown `type` values) keep their extra
 * properties exactly as received; unlike known variants, those keys
 * bypass lenient-field salvage and arrive unvalidated.
 */
export const zToolCallContent = preserveCustomPayload(z.union([
    zContent.and(z.object({
        type: z.literal("content"),
    })),
    zDiff.and(z.object({
        type: z.literal("diff"),
    })),
    zTerminal.and(z.object({
        type: z.literal("terminal"),
    })),
    excludeKnownTags(z.object({
        type: z.string(),
    }), "type", ["content", "diff", "terminal"]),
]), "type", ["content", "diff", "terminal"]);
/**
 * A file location being accessed or modified by a tool.
 *
 * Enables clients to implement "follow-along" features that track
 * which files the agent is working with in real-time.
 *
 * See protocol docs: [Following the Agent](https://agentclientprotocol.com/protocol/v2/draft/tool-calls#following-the-agent)
 */
export const zToolCallLocation = z.object({
    path: zAbsolutePath,
    line: defaultOnError(z
        .int()
        .gte(0)
        .max(4294967295, {
        error: "Invalid value: Expected uint32 to be <= 4294967295",
    })
        .nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Represents an upsert for a tool call that the language model has requested.
 *
 * Tool calls are actions that the agent executes on behalf of the language model,
 * such as reading files, executing code, or fetching data from external sources.
 *
 * Only [`ToolCallUpdate::tool_call_id`] is required. Other fields have patch semantics:
 * omitted fields leave the existing tool call value unchanged, `null` clears or
 * unsets the value, and concrete values replace the previous value. For
 * collection fields, concrete arrays replace the previous collection, and both
 * `null` and `[]` clear the collection. When a client receives a tool call ID it
 * has not seen before, omitted fields use client defaults.
 *
 * See protocol docs: [Tool Calls](https://agentclientprotocol.com/protocol/v2/draft/tool-calls)
 */
export const zToolCallUpdate = z.object({
    toolCallId: zToolCallId,
    name: defaultOnError(z.string().nullish(), () => undefined),
    title: defaultOnError(z.string().nullish(), () => undefined),
    kind: defaultOnError(zToolKind.nullish(), () => undefined),
    status: defaultOnError(zToolCallStatus.nullish(), () => undefined),
    content: defaultOnError(vecSkipError(zToolCallContent).nullish(), () => undefined),
    locations: defaultOnError(vecSkipError(zToolCallLocation).nullish(), () => undefined),
    rawInput: defaultOnError(z.unknown().optional(), () => undefined),
    rawOutput: defaultOnError(z.unknown().optional(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Permission request details for a tool call.
 */
export const zToolCallPermissionSubject = z.object({
    toolCall: zToolCallUpdate,
});
/**
 * Permission request details for a command.
 */
export const zCommandPermissionSubject = z.object({
    command: z.string(),
    cwd: zAbsolutePath,
    toolCallId: defaultOnError(zToolCallId.nullish(), () => undefined),
    terminalId: defaultOnError(zTerminalId.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * The operation requiring permission.
 *
 * Custom variants (unknown `type` values) keep their extra
 * properties exactly as received; unlike known variants, those keys
 * bypass lenient-field salvage and arrive unvalidated.
 */
export const zRequestPermissionSubject = preserveCustomPayload(z.union([
    zToolCallPermissionSubject.and(z.object({
        type: z.literal("tool_call"),
    })),
    zCommandPermissionSubject.and(z.object({
        type: z.literal("command"),
    })),
    excludeKnownTags(z.object({
        type: z.string(),
    }), "type", ["command", "tool_call"]),
]), "type", ["command", "tool_call"]);
/**
 * Unique identifier for a permission option.
 */
export const zPermissionOptionId = z.string();
/**
 * The type of permission option being presented to the user.
 *
 * Helps clients choose appropriate icons and UI treatment.
 */
export const zPermissionOptionKind = z.union([
    z.literal("allow_once"),
    z.literal("allow_always"),
    z.literal("reject_once"),
    z.literal("reject_always"),
    z.string(),
]);
/**
 * An option presented to the user when requesting permission.
 */
export const zPermissionOption = z.object({
    optionId: zPermissionOptionId,
    name: z.string(),
    kind: zPermissionOptionKind,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Request for user permission to proceed with an operation.
 *
 * Sent when the agent needs authorization before performing a sensitive operation.
 *
 * See protocol docs: [Requesting Permission](https://agentclientprotocol.com/protocol/v2/draft/tool-calls#requesting-permission)
 */
export const zRequestPermissionRequest = z.object({
    sessionId: zSessionId,
    title: z.string(),
    description: defaultOnError(z.string().nullish(), () => undefined),
    subject: zRequestPermissionSubject.nullish(),
    options: z.array(zPermissionOption).min(1),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Session-scoped elicitation, optionally tied to a specific tool call.
 *
 * When `tool_call_id` is set, the elicitation is tied to a specific tool call.
 * This is useful when an agent receives an elicitation from an MCP server
 * during a tool call and needs to redirect it to the user.
 */
export const zElicitationSessionScope = z.object({
    sessionId: zSessionId,
    toolCallId: defaultOnError(zToolCallId.nullish(), () => undefined),
});
/**
 * Request-scoped elicitation, tied to a specific JSON-RPC request outside of a session
 * (e.g., during auth/configuration phases before any session is started).
 */
export const zElicitationRequestScope = z.object({
    requestId: zRequestId,
});
/**
 * Object schema type.
 */
export const zElicitationSchemaType = z.literal("object");
/**
 * String format types for string properties in elicitation schemas.
 */
export const zStringFormat = z.union([
    z.literal("email"),
    z.literal("uri"),
    z.literal("date"),
    z.literal("date-time"),
    z.string(),
]);
/**
 * A titled enum option with a const value, human-readable title, and optional description.
 */
export const zEnumOption = z.object({
    const: z.string(),
    title: z.string(),
    description: defaultOnError(z.string().nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Schema for string properties in an elicitation form.
 *
 * When `enum` or `oneOf` is set, this represents a single-select enum
 * with `"type": "string"`.
 */
export const zStringPropertySchema = z.object({
    title: defaultOnError(z.string().nullish(), () => undefined),
    description: defaultOnError(z.string().nullish(), () => undefined),
    minLength: z
        .int()
        .gte(0)
        .max(4294967295, {
        error: "Invalid value: Expected uint32 to be <= 4294967295",
    })
        .nullish(),
    maxLength: z
        .int()
        .gte(0)
        .max(4294967295, {
        error: "Invalid value: Expected uint32 to be <= 4294967295",
    })
        .nullish(),
    pattern: z.string().nullish(),
    format: zStringFormat.nullish(),
    default: defaultOnError(z.string().nullish(), () => undefined),
    enum: z.array(z.string()).min(1).nullish(),
    oneOf: z.array(zEnumOption).min(1).nullish(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Schema for number (floating-point) properties in an elicitation form.
 */
export const zNumberPropertySchema = z.object({
    title: defaultOnError(z.string().nullish(), () => undefined),
    description: defaultOnError(z.string().nullish(), () => undefined),
    minimum: z.number().nullish(),
    maximum: z.number().nullish(),
    default: defaultOnError(z.number().nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Schema for integer properties in an elicitation form.
 */
export const zIntegerPropertySchema = z.object({
    title: defaultOnError(z.string().nullish(), () => undefined),
    description: defaultOnError(z.string().nullish(), () => undefined),
    minimum: z.number().nullish(),
    maximum: z.number().nullish(),
    default: defaultOnError(z.number().nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Schema for boolean properties in an elicitation form.
 */
export const zBooleanPropertySchema = z.object({
    title: defaultOnError(z.string().nullish(), () => undefined),
    description: defaultOnError(z.string().nullish(), () => undefined),
    default: defaultOnError(z.boolean().nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * String item schema for multi-select enum properties.
 */
export const zStringMultiSelectItems = z.object({
    enum: z.array(z.string()).min(1),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Items definition for titled multi-select enum properties.
 */
export const zTitledMultiSelectItems = z.object({
    anyOf: z.array(zEnumOption).min(1),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Items for a multi-select (array) property schema.
 *
 * Custom variants (unknown `type` values) keep their extra
 * properties exactly as received; unlike known variants, those keys
 * bypass lenient-field salvage and arrive unvalidated.
 */
export const zMultiSelectItems = preserveCustomPayload(z.union([
    zStringMultiSelectItems.and(z.object({
        type: z.literal("string"),
    })),
    excludeKnownTags(z.object({
        type: z.string(),
    }), "type", ["string"]),
    zTitledMultiSelectItems,
]), "type", ["string"]);
/**
 * Schema for multi-select (array) properties in an elicitation form.
 */
export const zMultiSelectPropertySchema = z.object({
    title: defaultOnError(z.string().nullish(), () => undefined),
    description: defaultOnError(z.string().nullish(), () => undefined),
    minItems: z.number().nullish(),
    maxItems: z.number().nullish(),
    items: zMultiSelectItems,
    default: defaultOnError(vecSkipError(z.string()).nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Property schema for elicitation form fields.
 *
 * Each variant corresponds to a JSON Schema `"type"` value.
 * Single-select enums use the `String` variant with `enum` or `oneOf` set.
 * Multi-select enums use the `Array` variant.
 *
 * Custom variants (unknown `type` values) keep their extra
 * properties exactly as received; unlike known variants, those keys
 * bypass lenient-field salvage and arrive unvalidated.
 */
export const zElicitationPropertySchema = preserveCustomPayload(z.union([
    zStringPropertySchema.and(z.object({
        type: z.literal("string"),
    })),
    zNumberPropertySchema.and(z.object({
        type: z.literal("number"),
    })),
    zIntegerPropertySchema.and(z.object({
        type: z.literal("integer"),
    })),
    zBooleanPropertySchema.and(z.object({
        type: z.literal("boolean"),
    })),
    zMultiSelectPropertySchema.and(z.object({
        type: z.literal("array"),
    })),
    excludeKnownTags(z.object({
        type: z.string(),
    }), "type", ["array", "boolean", "integer", "number", "string"]),
]), "type", ["array", "boolean", "integer", "number", "string"]);
/**
 * Type-safe elicitation schema for requesting structured user input.
 *
 * This represents a JSON Schema object with primitive-typed properties,
 * as required by the elicitation specification.
 */
export const zElicitationSchema = z.object({
    type: defaultOnError(zElicitationSchemaType.optional().default("object"), () => "object"),
    title: defaultOnError(z.string().nullish(), () => undefined),
    properties: z
        .record(z.string(), zElicitationPropertySchema)
        .optional()
        .default({}),
    required: z.array(z.string()).nullish(),
    description: defaultOnError(z.string().nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Form-based elicitation mode where the client renders a form from the provided schema.
 */
export const zElicitationFormMode = z.intersection(z.union([zElicitationSessionScope, zElicitationRequestScope]), z.object({
    requestedSchema: zElicitationSchema,
}));
/**
 * Unique identifier for an elicitation.
 */
export const zElicitationId = z.string();
/**
 * URL-based elicitation mode where the client directs the user to a URL.
 */
export const zElicitationUrlMode = z.intersection(z.union([zElicitationSessionScope, zElicitationRequestScope]), z.object({
    elicitationId: zElicitationId,
    url: z.url(),
}));
/**
 * Request from the agent to elicit structured user input.
 *
 * The agent sends this to the client to request information from the user,
 * either via a form or by directing them to a URL.
 * Elicitations are tied to a session (optionally a tool call) or a request.
 *
 * Custom variants (unknown `mode` values) keep their extra
 * properties exactly as received; unlike known variants, those keys
 * bypass lenient-field salvage and arrive unvalidated.
 */
export const zCreateElicitationRequest = preserveCustomPayload(z.intersection(z.union([
    zElicitationFormMode.and(z.object({
        mode: z.literal("form"),
    })),
    zElicitationUrlMode.and(z.object({
        mode: z.literal("url"),
    })),
    excludeKnownTags(z.intersection(z.union([zElicitationSessionScope, zElicitationRequestScope]), z.object({
        mode: z.string(),
    })), "mode", ["form", "url"]),
]), z.object({
    message: z.string(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
})), "mode", ["form", "url"]);
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Unique identifier for an MCP server using the ACP transport.
 *
 * The value is opaque and generated by the ACP component providing the MCP server. It is
 * used by `mcp/connect` to route connection requests back to the component that declared the
 * server.
 *
 * @experimental
 */
export const zMcpServerAcpId = z.string();
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Request parameters for `mcp/connect`.
 *
 * @experimental
 */
export const zConnectMcpRequest = z.object({
    serverId: zMcpServerAcpId,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * A unique identifier for an active MCP-over-ACP connection.
 *
 * @experimental
 */
export const zMcpConnectionId = z.string();
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Request parameters for `mcp/message`.
 *
 * @experimental
 */
export const zMessageMcpRequest = z.object({
    connectionId: zMcpConnectionId,
    method: z.string(),
    params: z.record(z.string(), z.unknown()).nullish(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Request parameters for `mcp/disconnect`.
 *
 * @experimental
 */
export const zDisconnectMcpRequest = z.object({
    connectionId: zMcpConnectionId,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Allows for sending an arbitrary request that is not part of the ACP spec.
 * Extension methods provide a way to add custom functionality while maintaining
 * protocol compatibility.
 *
 * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/draft/extensibility)
 */
export const zExtRequest = z.unknown();
/**
 * A JSON-RPC request object.
 */
export const zAgentRequest = z.object({
    id: zRequestId,
    method: z.string(),
    params: z
        .union([
        zRequestPermissionRequest,
        zCreateElicitationRequest,
        zConnectMcpRequest,
        zMessageMcpRequest,
        zDisconnectMcpRequest,
        zExtRequest,
    ])
        .nullish(),
});
/**
 * Protocol version identifier.
 *
 * This version is only bumped for breaking changes.
 * Non-breaking changes should be introduced via capabilities.
 */
export const zProtocolVersion = z.int().gte(0).lte(65535);
/**
 * Metadata about the implementation of the client or agent.
 * Describes the name and version of an ACP implementation, with an optional
 * title for UI representation.
 */
export const zImplementation = z.object({
    name: z.string(),
    title: defaultOnError(z.string().nullish(), () => undefined),
    version: z.string(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Capabilities for image content in prompt requests.
 *
 * Supplying `{}` means the agent supports image content in prompts.
 */
export const zPromptImageCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Capabilities for audio content in prompt requests.
 *
 * Supplying `{}` means the agent supports audio content in prompts.
 */
export const zPromptAudioCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Capabilities for embedded context in prompt requests.
 *
 * Supplying `{}` means the agent supports embedded context in prompts.
 */
export const zPromptEmbeddedContextCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Prompt capabilities supported by the agent in `session/prompt` requests.
 *
 * Baseline agent functionality requires support for [`ContentBlock::Text`]
 * and [`ContentBlock::ResourceLink`] in prompt requests.
 *
 * Other variants must be explicitly opted in to.
 * Capabilities for different types of content in prompt requests.
 *
 * Indicates which content types beyond the baseline (text and resource links)
 * the agent can process.
 *
 * See protocol docs: [Prompt Capabilities](https://agentclientprotocol.com/protocol/v2/draft/initialization#prompt-capabilities)
 */
export const zPromptCapabilities = z.object({
    image: defaultOnError(zPromptImageCapabilities.nullish(), () => undefined),
    audio: defaultOnError(zPromptAudioCapabilities.nullish(), () => undefined),
    embeddedContext: defaultOnError(zPromptEmbeddedContextCapabilities.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Capabilities for stdio MCP server transports.
 *
 * Supplying `{}` means the agent supports stdio MCP server transports.
 */
export const zMcpStdioCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Capabilities for HTTP MCP server transports.
 *
 * Supplying `{}` means the agent supports HTTP MCP server transports.
 */
export const zMcpHttpCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Capabilities for ACP MCP server transports.
 *
 * Supplying `{}` means the agent supports ACP MCP server transports.
 *
 * @experimental
 */
export const zMcpAcpCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * MCP capabilities supported by the agent for session lifecycle requests.
 */
export const zMcpCapabilities = z.object({
    stdio: defaultOnError(zMcpStdioCapabilities.nullish(), () => undefined),
    http: defaultOnError(zMcpHttpCapabilities.nullish(), () => undefined),
    acp: defaultOnError(zMcpAcpCapabilities.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Capabilities for the `session/delete` method.
 *
 * Supplying `{}` means the agent supports deleting sessions from `session/list`.
 */
export const zSessionDeleteCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Capabilities for additional session directories support.
 *
 * Supplying `{}` means the agent supports the `additionalDirectories` field on
 * supported session lifecycle requests. Agents that also support
 * `session/list` may return `SessionInfo.additionalDirectories` to report the
 * complete ordered additional-root list associated with a listed session.
 */
export const zSessionAdditionalDirectoriesCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Capabilities for the `session/fork` method.
 *
 * Supplying `{}` means the agent supports forking sessions.
 *
 * @experimental
 */
export const zSessionForkCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Session capabilities supported by the agent.
 *
 * Supplying `{}` means the agent supports the baseline session methods:
 * `session/new`, `session/list`, `session/resume`, `session/close`,
 * `session/prompt`, `session/cancel`, and `session/update`.
 *
 * Agents that support sessions **MAY** support additional session methods,
 * prompt content types, and MCP transports by specifying additional
 * capabilities.
 *
 * See protocol docs: [Session Capabilities](https://agentclientprotocol.com/protocol/v2/draft/initialization#session-capabilities)
 */
export const zSessionCapabilities = z.object({
    prompt: defaultOnError(zPromptCapabilities.nullish(), () => undefined),
    mcp: defaultOnError(zMcpCapabilities.nullish(), () => undefined),
    delete: defaultOnError(zSessionDeleteCapabilities.nullish(), () => undefined),
    additionalDirectories: defaultOnError(zSessionAdditionalDirectoriesCapabilities.nullish(), () => undefined),
    fork: defaultOnError(zSessionForkCapabilities.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Authentication-related extension capabilities supported by the agent.
 *
 * This object does not advertise support for `auth/login` or `auth/logout`.
 * Those methods are advertised by a non-empty `authMethods` list in the
 * `initialize` response.
 */
export const zAgentAuthCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Provider configuration capabilities supported by the agent.
 *
 * Supplying `{}` means the agent supports provider configuration methods.
 *
 * @experimental
 */
export const zProvidersCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Marker for `document/didOpen` capability support.
 */
export const zNesDocumentDidOpenCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * How the agent wants document changes delivered.
 */
export const zTextDocumentSyncKind = z.union([
    z.literal("full"),
    z.literal("incremental"),
]);
/**
 * Capabilities for `document/didChange` events.
 */
export const zNesDocumentDidChangeCapabilities = z.object({
    syncKind: zTextDocumentSyncKind,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Marker for `document/didClose` capability support.
 */
export const zNesDocumentDidCloseCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Marker for `document/didSave` capability support.
 */
export const zNesDocumentDidSaveCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Marker for `document/didFocus` capability support.
 */
export const zNesDocumentDidFocusCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Document event capabilities the agent wants to receive.
 */
export const zNesDocumentEventCapabilities = z.object({
    didOpen: defaultOnError(zNesDocumentDidOpenCapabilities.nullish(), () => undefined),
    didChange: defaultOnError(zNesDocumentDidChangeCapabilities.nullish(), () => undefined),
    didClose: defaultOnError(zNesDocumentDidCloseCapabilities.nullish(), () => undefined),
    didSave: defaultOnError(zNesDocumentDidSaveCapabilities.nullish(), () => undefined),
    didFocus: defaultOnError(zNesDocumentDidFocusCapabilities.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Event capabilities the agent can consume.
 */
export const zNesEventCapabilities = z.object({
    document: defaultOnError(zNesDocumentEventCapabilities.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Capabilities for recent files context.
 */
export const zNesRecentFilesCapabilities = z.object({
    maxCount: defaultOnError(z
        .int()
        .gte(0)
        .max(4294967295, {
        error: "Invalid value: Expected uint32 to be <= 4294967295",
    })
        .nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Capabilities for related snippets context.
 */
export const zNesRelatedSnippetsCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Capabilities for edit history context.
 */
export const zNesEditHistoryCapabilities = z.object({
    maxCount: defaultOnError(z
        .int()
        .gte(0)
        .max(4294967295, {
        error: "Invalid value: Expected uint32 to be <= 4294967295",
    })
        .nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Capabilities for user actions context.
 */
export const zNesUserActionsCapabilities = z.object({
    maxCount: defaultOnError(z
        .int()
        .gte(0)
        .max(4294967295, {
        error: "Invalid value: Expected uint32 to be <= 4294967295",
    })
        .nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Capabilities for open files context.
 */
export const zNesOpenFilesCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Capabilities for diagnostics context.
 */
export const zNesDiagnosticsCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Context capabilities the agent wants attached to each suggestion request.
 */
export const zNesContextCapabilities = z.object({
    recentFiles: defaultOnError(zNesRecentFilesCapabilities.nullish(), () => undefined),
    relatedSnippets: defaultOnError(zNesRelatedSnippetsCapabilities.nullish(), () => undefined),
    editHistory: defaultOnError(zNesEditHistoryCapabilities.nullish(), () => undefined),
    userActions: defaultOnError(zNesUserActionsCapabilities.nullish(), () => undefined),
    openFiles: defaultOnError(zNesOpenFilesCapabilities.nullish(), () => undefined),
    diagnostics: defaultOnError(zNesDiagnosticsCapabilities.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * NES capabilities advertised by the agent during initialization.
 *
 * Supplying `{}` means the agent supports the NES method surface. Omitted or
 * `null` both mean the agent does not advertise support for `nes*` methods.
 */
export const zNesCapabilities = z.object({
    events: defaultOnError(zNesEventCapabilities.nullish(), () => undefined),
    context: defaultOnError(zNesContextCapabilities.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * The encoding used for character offsets in positions.
 *
 * Follows the same conventions as LSP 3.17. The default is UTF-16.
 */
export const zPositionEncodingKind = z.union([
    z.literal("utf-16"),
    z.literal("utf-32"),
    z.literal("utf-8"),
]);
/**
 * Capabilities supported by the agent.
 *
 * Advertised during initialization to inform the client about
 * available features and content types.
 *
 * See protocol docs: [Agent Capabilities](https://agentclientprotocol.com/protocol/v2/draft/initialization#agent-capabilities)
 */
export const zAgentCapabilities = z.object({
    session: defaultOnError(zSessionCapabilities.nullish(), () => undefined),
    auth: defaultOnError(zAgentAuthCapabilities.nullish(), () => undefined),
    providers: defaultOnError(zProvidersCapabilities.nullish(), () => undefined),
    nes: defaultOnError(zNesCapabilities.nullish(), () => undefined),
    positionEncoding: defaultOnError(zPositionEncodingKind.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Typed identifier used for auth method values on the wire.
 */
export const zAuthMethodId = z.string();
/**
 * An environment variable to set when launching a process.
 */
export const zEnvVariable = z.object({
    name: z.string(),
    value: z.string(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Terminal-based authentication method.
 *
 * The client runs the configured agent program as a separate interactive
 * process for the user to authenticate via a TUI. Agents MUST advertise this
 * method only when the client enabled its terminal authentication capability.
 * A zero exit status signals success; any other termination signals failure.
 * The client MUST NOT pass this method to `auth/login`.
 */
export const zAuthMethodTerminal = z.object({
    methodId: zAuthMethodId,
    name: z.string(),
    description: defaultOnError(z.string().nullish(), () => undefined),
    args: defaultOnError(vecSkipError(z.string()).optional(), () => []),
    env: defaultOnError(vecSkipError(zEnvVariable).optional(), () => []),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Agent handles authentication itself through `auth/login`.
 *
 * The `type` discriminator value is `agent`.
 */
export const zAuthMethodAgent = z.object({
    methodId: zAuthMethodId,
    name: z.string(),
    description: defaultOnError(z.string().nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Describes an available authentication method.
 *
 * The `type` field acts as the discriminator in the serialized JSON form.
 *
 * Custom variants (unknown `type` values) keep their extra
 * properties exactly as received; unlike known variants, those keys
 * bypass lenient-field salvage and arrive unvalidated.
 */
export const zAuthMethod = preserveCustomPayload(z.union([
    zAuthMethodTerminal.and(z.object({
        type: z.literal("terminal"),
    })),
    zAuthMethodAgent.and(z.object({
        type: z.literal("agent"),
    })),
    excludeKnownTags(z.object({
        type: z.string(),
        methodId: zAuthMethodId,
        name: z.string(),
        description: defaultOnError(z.string().nullish(), () => undefined),
        _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
    }), "type", ["agent", "terminal"]),
]), "type", ["agent", "terminal"]);
/**
 * Response to the `initialize` method.
 *
 * Contains the negotiated protocol version and agent capabilities.
 *
 * See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/v2/draft/initialization)
 */
export const zInitializeResponse = z.object({
    protocolVersion: zProtocolVersion,
    info: zImplementation,
    capabilities: defaultOnError(zAgentCapabilities.optional().default({}), () => ({})),
    authMethods: defaultOnError(vecSkipError(zAuthMethod).optional(), () => []),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Response to the `auth/login` method.
 */
export const zLoginAuthResponse = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Unique identifier for a configurable LLM provider.
 *
 * @experimental
 */
export const zProviderId = z.string();
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Well-known API protocol identifiers for LLM providers.
 *
 * Agents and clients MUST handle unknown protocol identifiers gracefully.
 *
 * Protocol names beginning with `_` are free for custom use, like other ACP extension methods.
 * Protocol names that do not begin with `_` are reserved for the ACP spec.
 *
 * @experimental
 */
export const zLlmProtocol = z.union([
    z.literal("anthropic"),
    z.literal("openai"),
    z.literal("azure"),
    z.literal("vertex"),
    z.literal("bedrock"),
    z.string(),
]);
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Current effective non-secret routing configuration for a provider.
 *
 * @experimental
 */
export const zProviderCurrentConfig = z.object({
    apiType: zLlmProtocol,
    baseUrl: z.url(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Information about a configurable LLM provider.
 *
 * @experimental
 */
export const zProviderInfo = z.object({
    providerId: zProviderId,
    supported: requiredDefaultOnError(vecSkipError(zLlmProtocol), () => []),
    required: z.boolean(),
    current: zProviderCurrentConfig.nullish(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Response to `providers/list`.
 *
 * @experimental
 */
export const zListProvidersResponse = z.object({
    providers: z.array(zProviderInfo),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Response to `providers/set`.
 *
 * @experimental
 */
export const zSetProviderResponse = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Response to `providers/disable`.
 *
 * @experimental
 */
export const zDisableProviderResponse = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Response to the `auth/logout` method.
 */
export const zLogoutAuthResponse = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Unique identifier for a session configuration option.
 */
export const zSessionConfigId = z.string();
/**
 * Semantic category for a session configuration option.
 *
 * This is intended to help Clients distinguish broadly common selectors (e.g. model selector vs
 * session mode selector vs thought/reasoning level) for UX purposes (keyboard shortcuts, icons,
 * placement). It MUST NOT be required for correctness. Clients MUST handle missing or unknown
 * categories gracefully.
 *
 * Category names beginning with `_` are free for custom use, like other ACP extension methods.
 * Category names that do not begin with `_` are reserved for the ACP spec.
 */
export const zSessionConfigOptionCategory = z.union([
    z.literal("mode"),
    z.literal("model"),
    z.literal("model_config"),
    z.literal("thought_level"),
    z.string(),
]);
/**
 * Unique identifier for a session configuration option value.
 */
export const zSessionConfigValueId = z.string();
/**
 * A possible value for a session configuration option.
 */
export const zSessionConfigSelectOption = z.object({
    value: zSessionConfigValueId,
    name: z.string(),
    description: defaultOnError(z.string().nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Unique identifier for a session configuration option value group.
 */
export const zSessionConfigGroupId = z.string();
/**
 * A group of possible values for a session configuration option.
 */
export const zSessionConfigSelectGroup = z.object({
    groupId: zSessionConfigGroupId,
    name: z.string(),
    options: requiredDefaultOnError(vecSkipError(zSessionConfigSelectOption), () => []),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Possible values for a session configuration option.
 */
export const zSessionConfigSelectOptions = z.union([
    z.array(zSessionConfigSelectOption),
    z.array(zSessionConfigSelectGroup),
]);
/**
 * A single-value selector (dropdown) session configuration option payload.
 */
export const zSessionConfigSelect = z.object({
    currentValue: zSessionConfigValueId,
    options: zSessionConfigSelectOptions,
});
/**
 * A boolean on/off toggle session configuration option payload.
 */
export const zSessionConfigBoolean = z.object({
    currentValue: z.boolean(),
});
/**
 * A session configuration option selector and its current state.
 *
 * Custom variants (unknown `type` values) keep their extra
 * properties exactly as received; unlike known variants, those keys
 * bypass lenient-field salvage and arrive unvalidated.
 */
export const zSessionConfigOption = preserveCustomPayload(z.intersection(z.union([
    zSessionConfigSelect.and(z.object({
        type: z.literal("select"),
    })),
    zSessionConfigBoolean.and(z.object({
        type: z.literal("boolean"),
    })),
    excludeKnownTags(z.object({
        type: z.string(),
    }), "type", ["boolean", "select"]),
]), z.object({
    configId: zSessionConfigId,
    name: z.string(),
    description: defaultOnError(z.string().nullish(), () => undefined),
    category: defaultOnError(zSessionConfigOptionCategory.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
})), "type", ["boolean", "select"]);
/**
 * Response from creating a new session.
 *
 * See protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol/v2/draft/session-setup#creating-a-session)
 */
export const zNewSessionResponse = z.object({
    sessionId: zSessionId,
    configOptions: defaultOnError(vecSkipError(zSessionConfigOption).optional(), () => []),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Information about a session returned by session/list
 */
export const zSessionInfo = z.object({
    sessionId: zSessionId,
    cwd: zAbsolutePath,
    additionalDirectories: defaultOnError(vecSkipError(zAbsolutePath).optional(), () => []),
    title: defaultOnError(z.string().nullish(), () => undefined),
    updatedAt: defaultOnError(z.iso.datetime({ offset: true }).nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * An opaque cursor used to paginate `session/list` results.
 */
export const zSessionListCursor = z.string();
/**
 * Response from listing sessions.
 */
export const zListSessionsResponse = z.object({
    sessions: requiredDefaultOnError(vecSkipError(zSessionInfo), () => []),
    nextCursor: defaultOnError(zSessionListCursor.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Response from deleting a session.
 */
export const zDeleteSessionResponse = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Response from forking an existing session.
 *
 * @experimental
 */
export const zForkSessionResponse = z.object({
    sessionId: zSessionId,
    configOptions: defaultOnError(vecSkipError(zSessionConfigOption).optional(), () => []),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Response from resuming an existing session.
 */
export const zResumeSessionResponse = z.object({
    configOptions: defaultOnError(vecSkipError(zSessionConfigOption).optional(), () => []),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Response from closing a session.
 */
export const zCloseSessionResponse = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Response to `session/set_config_option` method.
 */
export const zSetSessionConfigOptionResponse = z.object({
    configOptions: requiredDefaultOnError(vecSkipError(zSessionConfigOption), () => []),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Response acknowledging that a user prompt was accepted.
 *
 * This response does not indicate that the agent has finished processing.
 * Processing and completion are reported through `state_update` session updates.
 *
 * See protocol docs: [Prompt Accepted](https://agentclientprotocol.com/protocol/v2/draft/prompt-lifecycle#2-prompt-accepted)
 */
export const zPromptResponse = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Response to `nes/start`.
 */
export const zStartNesResponse = z.object({
    sessionId: zSessionId,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Unique identifier for an NES suggestion.
 *
 * @experimental
 */
export const zNesSuggestionId = z.string();
/**
 * A zero-based position in a text document.
 *
 * The meaning of `character` depends on the negotiated position encoding.
 */
export const zPosition = z.object({
    line: z.int().gte(0).max(4294967295, {
        error: "Invalid value: Expected uint32 to be <= 4294967295",
    }),
    character: z.int().gte(0).max(4294967295, {
        error: "Invalid value: Expected uint32 to be <= 4294967295",
    }),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * A range in a text document, expressed as start and end positions.
 */
export const zRange = z.object({
    start: zPosition,
    end: zPosition,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * A text edit within a suggestion.
 */
export const zNesTextEdit = z.object({
    range: zRange,
    newText: z.string(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * A text edit suggestion.
 */
export const zNesEditSuggestion = z.object({
    suggestionId: zNesSuggestionId,
    uri: z.url(),
    edits: z.array(zNesTextEdit).min(1),
    cursorPosition: defaultOnError(zPosition.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * A jump-to-location suggestion.
 */
export const zNesJumpSuggestion = z.object({
    suggestionId: zNesSuggestionId,
    uri: z.url(),
    position: zPosition,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * A rename symbol suggestion.
 */
export const zNesRenameSuggestion = z.object({
    suggestionId: zNesSuggestionId,
    uri: z.url(),
    position: zPosition,
    newName: z.string(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * A search-and-replace suggestion.
 */
export const zNesSearchAndReplaceSuggestion = z.object({
    suggestionId: zNesSuggestionId,
    uri: z.url(),
    search: z.string(),
    replace: z.string(),
    isRegex: z.boolean().nullish(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * A suggestion returned by the agent.
 *
 * Custom variants (unknown `kind` values) keep their extra
 * properties exactly as received; unlike known variants, those keys
 * bypass lenient-field salvage and arrive unvalidated.
 */
export const zNesSuggestion = preserveCustomPayload(z.union([
    zNesEditSuggestion.and(z.object({
        kind: z.literal("edit"),
    })),
    zNesJumpSuggestion.and(z.object({
        kind: z.literal("jump"),
    })),
    zNesRenameSuggestion.and(z.object({
        kind: z.literal("rename"),
    })),
    zNesSearchAndReplaceSuggestion.and(z.object({
        kind: z.literal("searchAndReplace"),
    })),
    excludeKnownTags(z.object({
        kind: z.string(),
        suggestionId: zNesSuggestionId,
    }), "kind", ["edit", "jump", "rename", "searchAndReplace"]),
]), "kind", ["edit", "jump", "rename", "searchAndReplace"]);
/**
 * Response to `nes/suggest`.
 */
export const zSuggestNesResponse = z.object({
    suggestions: z.array(zNesSuggestion),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Response from closing an NES session.
 */
export const zCloseNesResponse = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Allows for sending an arbitrary response to an [`ExtRequest`] that is not part of the ACP spec.
 * Extension methods provide a way to add custom functionality while maintaining
 * protocol compatibility.
 *
 * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/draft/extensibility)
 */
export const zExtResponse = z.unknown();
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Response to `mcp/message`.
 *
 * This is the inner MCP response result payload. Any JSON value is valid.
 *
 * @experimental
 */
export const zMessageMcpResponse = z.unknown();
/**
 * Predefined error codes for common JSON-RPC and ACP-specific errors.
 *
 * These codes follow the JSON-RPC 2.0 specification for standard errors
 * and use the reserved range (-32000 to -32099) for protocol-specific errors.
 */
export const zErrorCode = z.union([
    z.literal(-32700),
    z.literal(-32600),
    z.literal(-32601),
    z.literal(-32602),
    z.literal(-32603),
    z.literal(-32800),
    z.literal(-32000),
    z.literal(-32002),
    z
        .int()
        .min(-2147483648, {
        error: "Invalid value: Expected int32 to be >= -2147483648",
    })
        .max(2147483647, {
        error: "Invalid value: Expected int32 to be <= 2147483647",
    }),
]);
/**
 * JSON-RPC error object.
 *
 * Represents an error that occurred during method execution, following the
 * JSON-RPC 2.0 error object specification with optional additional data.
 *
 * See protocol docs: [JSON-RPC Error Object](https://www.jsonrpc.org/specification#error_object)
 */
export const zError = z.object({
    code: zErrorCode,
    message: z.string(),
    data: defaultOnError(z.unknown().optional(), () => undefined),
});
/**
 * A JSON-RPC response object.
 */
export const zAgentResponse = z.union([
    z.object({
        id: zRequestId,
        result: z.union([
            zInitializeResponse,
            zLoginAuthResponse,
            zListProvidersResponse,
            zSetProviderResponse,
            zDisableProviderResponse,
            zLogoutAuthResponse,
            zNewSessionResponse,
            zListSessionsResponse,
            zDeleteSessionResponse,
            zForkSessionResponse,
            zResumeSessionResponse,
            zCloseSessionResponse,
            zSetSessionConfigOptionResponse,
            zPromptResponse,
            zStartNesResponse,
            zSuggestNesResponse,
            zCloseNesResponse,
            zExtResponse,
            zMessageMcpResponse,
        ]),
    }),
    z.object({
        id: zRequestId,
        error: zError,
    }),
]);
/**
 * Unique identifier for a message within a session.
 */
export const zMessageId = z.string();
/**
 * A streamed item of message content.
 */
export const zContentChunk = z.object({
    messageId: zMessageId,
    content: zContentBlock,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * A user message upsert.
 *
 * Only [`UserMessage::message_id`] is required. `content` has patch semantics:
 * an omitted field leaves existing message content unchanged, `null` clears the
 * value, and a concrete array replaces the previous value. For a new
 * `messageId`, omitted fields use client defaults. `content` is replaced as a
 * whole array; send `[]` or `null` to clear it.
 *
 * Message updates and chunks are applied in the order they are received. When
 * a `user_message` update includes `content`, that array replaces any content
 * previously accumulated for the message, including content from earlier
 * chunks. Later chunks with the same `messageId` append to the current
 * content.
 */
export const zUserMessage = z.object({
    messageId: zMessageId,
    content: defaultOnError(vecSkipError(zContentBlock).nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * An agent message upsert.
 *
 * Only [`AgentMessage::message_id`] is required. `content` has patch semantics:
 * an omitted field leaves existing message content unchanged, `null` clears the
 * value, and a concrete array replaces the previous value. For a new
 * `messageId`, omitted fields use client defaults. `content` is replaced as a
 * whole array; send `[]` or `null` to clear it.
 *
 * Message updates and chunks are applied in the order they are received. When
 * an `agent_message` update includes `content`, that array replaces any
 * content previously accumulated for the message, including content from
 * earlier chunks. Later chunks with the same `messageId` append to the current
 * content.
 */
export const zAgentMessage = z.object({
    messageId: zMessageId,
    content: defaultOnError(vecSkipError(zContentBlock).nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * An agent thought or reasoning message upsert.
 *
 * Only [`AgentThought::message_id`] is required. `content` has patch semantics:
 * an omitted field leaves existing thought content unchanged, `null` clears the
 * value, and a concrete array replaces the previous value. For a new
 * `messageId`, omitted fields use client defaults. `content` is replaced as a
 * whole array; send `[]` or `null` to clear it.
 *
 * Message updates and chunks are applied in the order they are received. When
 * an `agent_thought` update includes `content`, that array replaces any
 * content previously accumulated for the thought, including content from
 * earlier chunks. Later chunks with the same `messageId` append to the current
 * content.
 */
export const zAgentThought = z.object({
    messageId: zMessageId,
    content: defaultOnError(vecSkipError(zContentBlock).nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Foreground work is in progress.
 */
export const zRunningStateUpdate = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Reasons why an agent stops active session work.
 *
 * See protocol docs: [Stop Reasons](https://agentclientprotocol.com/protocol/v2/draft/prompt-lifecycle#stop-reasons)
 */
export const zStopReason = z.union([
    z.literal("end_turn"),
    z.literal("max_tokens"),
    z.literal("max_turn_requests"),
    z.literal("refusal"),
    z.literal("cancelled"),
    z.string(),
]);
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Token usage information for completed session work.
 *
 * @experimental
 */
export const zUsage = z.object({
    totalTokens: z.number(),
    inputTokens: z.number(),
    outputTokens: z.number(),
    thoughtTokens: defaultOnError(z.number().nullish(), () => undefined),
    cachedReadTokens: defaultOnError(z.number().nullish(), () => undefined),
    cachedWriteTokens: defaultOnError(z.number().nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * The agent is ready to process a new prompt.
 */
export const zIdleStateUpdate = z.object({
    stopReason: defaultOnError(zStopReason.nullish(), () => undefined),
    usage: defaultOnError(zUsage.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Foreground work is blocked on user action.
 */
export const zRequiresActionStateUpdate = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * The state of the agent's foreground work has changed.
 *
 * Background activity can continue and emit other `session/update` notifications
 * while `idle`. Those notifications do not change this state.
 *
 * Custom variants (unknown `state` values) keep their extra
 * properties exactly as received; unlike known variants, those keys
 * bypass lenient-field salvage and arrive unvalidated.
 */
export const zStateUpdate = preserveCustomPayload(z.union([
    zRunningStateUpdate.and(z.object({
        state: z.literal("running"),
    })),
    zIdleStateUpdate.and(z.object({
        state: z.literal("idle"),
    })),
    zRequiresActionStateUpdate.and(z.object({
        state: z.literal("requires_action"),
    })),
    excludeKnownTags(z.object({
        state: z.string(),
    }), "state", ["idle", "requires_action", "running"]),
]), "state", ["idle", "requires_action", "running"]);
/**
 * A streamed item of tool-call content.
 *
 * Tool-call content chunks append one [`ToolCallContent`] item to the current
 * content for the matching [`ToolCallId`]. Agents can use
 * [`ToolCallUpdate::content`] when they need to replace the whole content
 * collection instead.
 */
export const zToolCallContentChunk = z.object({
    toolCallId: zToolCallId,
    content: zToolCallContent,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * An authoritative replacement snapshot of terminal output bytes.
 */
export const zTerminalOutput = z.object({
    data: z.string(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Exit information for an agent-owned terminal.
 *
 * The presence of this object marks the terminal as exited, even when neither
 * an exit code nor a signal is known.
 */
export const zTerminalExitStatus = z.object({
    exitCode: defaultOnError(z
        .int()
        .gte(0)
        .max(4294967295, {
        error: "Invalid value: Expected uint32 to be <= 4294967295",
    })
        .nullish(), () => undefined),
    signal: defaultOnError(z.string().nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * An upsert for the stored state of an agent-owned terminal.
 *
 * Only [`TerminalUpdate::terminal_id`] is required. Other fields have patch
 * semantics: omitted fields leave the stored value unchanged, `null` clears
 * it, and concrete values replace it. When the terminal ID is new, omitted
 * fields start unknown.
 */
export const zTerminalUpdate = z.object({
    terminalId: zTerminalId,
    command: defaultOnError(z.string().nullish(), () => undefined),
    cwd: defaultOnError(zAbsolutePath.nullish(), () => undefined),
    output: defaultOnError(zTerminalOutput.nullish(), () => undefined),
    exitStatus: defaultOnError(zTerminalExitStatus.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * A chunk of bytes appended to an agent-owned terminal's output.
 */
export const zTerminalOutputChunk = z.object({
    terminalId: zTerminalId,
    data: z.string(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Unique identifier for a plan within a session.
 */
export const zPlanId = z.string();
/**
 * Priority levels for plan entries.
 *
 * Used to indicate the relative importance or urgency of different
 * tasks in the execution plan.
 * See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/v2/draft/agent-plan#plan-entries)
 */
export const zPlanEntryPriority = z.union([
    z.literal("high"),
    z.literal("medium"),
    z.literal("low"),
    z.string(),
]);
/**
 * Status of a plan entry in the execution flow.
 *
 * Tracks the lifecycle of each task from planning through completion.
 * See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/v2/draft/agent-plan#plan-entries)
 */
export const zPlanEntryStatus = z.union([
    z.literal("pending"),
    z.literal("in_progress"),
    z.literal("completed"),
    z.literal("cancelled"),
    z.string(),
]);
/**
 * A single entry in the execution plan.
 *
 * Represents a task or goal that the assistant intends to accomplish
 * as part of fulfilling the user's request.
 * See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/v2/draft/agent-plan#plan-entries)
 */
export const zPlanEntry = z.object({
    content: z.string(),
    priority: zPlanEntryPriority,
    status: zPlanEntryStatus,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * A plan represented as structured entries.
 */
export const zPlanItems = z.object({
    planId: zPlanId,
    entries: requiredDefaultOnError(vecSkipError(zPlanEntry), () => []),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * A plan represented by a file URI.
 *
 * @experimental
 */
export const zPlanFile = z.object({
    planId: zPlanId,
    uri: z.url(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * A plan represented as raw markdown content.
 *
 * @experimental
 */
export const zPlanMarkdown = z.object({
    planId: zPlanId,
    content: z.string(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Updated content for a plan.
 *
 * Custom variants (unknown `type` values) keep their extra
 * properties exactly as received; unlike known variants, those keys
 * bypass lenient-field salvage and arrive unvalidated.
 */
export const zPlanUpdateContent = preserveCustomPayload(z.union([
    zPlanItems.and(z.object({
        type: z.literal("items"),
    })),
    zPlanFile.and(z.object({
        type: z.literal("file"),
    })),
    zPlanMarkdown.and(z.object({
        type: z.literal("markdown"),
    })),
    excludeKnownTags(z.object({
        type: z.string(),
        planId: zPlanId,
    }), "type", ["file", "items", "markdown"]),
]), "type", ["file", "items", "markdown"]);
/**
 * A content update for a plan identified by ID.
 */
export const zPlanUpdate = z.object({
    plan: zPlanUpdateContent,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Removal notice for a plan identified by ID.
 *
 * @experimental
 */
export const zPlanRemoved = z.object({
    planId: zPlanId,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * All text that was typed after the command name is provided as input.
 */
export const zTextCommandInput = z.object({
    hint: z.string(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * The input specification for a command.
 *
 * Custom variants (unknown `type` values) keep their extra
 * properties exactly as received; unlike known variants, those keys
 * bypass lenient-field salvage and arrive unvalidated.
 */
export const zAvailableCommandInput = preserveCustomPayload(z.union([
    zTextCommandInput.and(z.object({
        type: z.literal("text"),
    })),
    excludeKnownTags(z.object({
        type: z.string(),
    }), "type", ["text"]),
]), "type", ["text"]);
/**
 * Information about a command.
 */
export const zAvailableCommand = z.object({
    name: z.string(),
    description: z.string(),
    input: defaultOnError(zAvailableCommandInput.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Available commands are ready or have changed
 */
export const zAvailableCommandsUpdate = z.object({
    availableCommands: requiredDefaultOnError(vecSkipError(zAvailableCommand), () => []),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Session configuration options have been updated.
 */
export const zConfigOptionUpdate = z.object({
    configOptions: requiredDefaultOnError(vecSkipError(zSessionConfigOption), () => []),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Update to session metadata. All fields are optional to support partial updates.
 *
 * Agents send this notification to update session information like title or custom metadata.
 * This allows clients to display dynamic session names and track session state changes.
 *
 * Omitted fields leave the existing session info unchanged. `null` clears the
 * corresponding value.
 */
export const zSessionInfoUpdate = z.object({
    title: defaultOnError(z.string().nullish(), () => undefined),
    updatedAt: defaultOnError(z.iso.datetime({ offset: true }).nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Cost information for a session.
 */
export const zCost = z.object({
    amount: z.number(),
    currency: z.string().regex(/^[A-Z]{3}$/),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Context window and cost update for a session.
 */
export const zUsageUpdate = z.object({
    used: z.number(),
    size: z.number(),
    cost: defaultOnError(zCost.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Unique identifier for a context compaction within a session.
 *
 * @experimental
 */
export const zCompactionId = z.string();
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Lifecycle state of a context compaction.
 *
 * @experimental
 */
export const zCompactionStatus = z.union([
    z.literal("in_progress"),
    z.literal("completed"),
    z.literal("failed"),
    z.literal("cancelled"),
    z.string(),
]);
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * A context compaction upsert. The first update fixes the compaction's
 * timeline position. Later updates with the same ID patch that entity in place.
 *
 * `summary`, `error`, and `_meta` have patch semantics: omission leaves the
 * stored value unchanged, `null` clears it, and a concrete value replaces it.
 * `summary: []` also clears the retained summary. A non-empty summary is only
 * valid with `completed`; `error` is only valid with `failed`.
 *
 * @experimental
 */
export const zCompactionUpdate = z.object({
    compactionId: zCompactionId,
    status: zCompactionStatus,
    summary: defaultOnError(vecSkipError(zContentBlock).nullish(), () => undefined),
    error: defaultOnError(z.string().nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * A content block appended to the retained summary of an in-progress
 * compaction. Agents send chunks only after an `in_progress` update and before
 * the terminal update for the same ID.
 *
 * @experimental
 */
export const zCompactionSummaryChunk = z.object({
    compactionId: zCompactionId,
    content: zContentBlock,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Different types of updates that can be sent while a session exists.
 *
 * These updates report messages, progress, and other session activity.
 *
 * See protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/v2/draft/prompt-lifecycle#3-agent-reports-output)
 *
 * Custom variants (unknown `sessionUpdate` values) keep their extra
 * properties exactly as received; unlike known variants, those keys
 * bypass lenient-field salvage and arrive unvalidated.
 */
export const zSessionUpdate = preserveCustomPayload(z.union([
    zContentChunk.and(z.object({
        sessionUpdate: z.literal("user_message_chunk"),
    })),
    zUserMessage.and(z.object({
        sessionUpdate: z.literal("user_message"),
    })),
    zContentChunk.and(z.object({
        sessionUpdate: z.literal("agent_message_chunk"),
    })),
    zAgentMessage.and(z.object({
        sessionUpdate: z.literal("agent_message"),
    })),
    zContentChunk.and(z.object({
        sessionUpdate: z.literal("agent_thought_chunk"),
    })),
    zAgentThought.and(z.object({
        sessionUpdate: z.literal("agent_thought"),
    })),
    zStateUpdate.and(z.object({
        sessionUpdate: z.literal("state_update"),
    })),
    zToolCallContentChunk.and(z.object({
        sessionUpdate: z.literal("tool_call_content_chunk"),
    })),
    zToolCallUpdate.and(z.object({
        sessionUpdate: z.literal("tool_call_update"),
    })),
    zTerminalUpdate.and(z.object({
        sessionUpdate: z.literal("terminal_update"),
    })),
    zTerminalOutputChunk.and(z.object({
        sessionUpdate: z.literal("terminal_output_chunk"),
    })),
    zPlanUpdate.and(z.object({
        sessionUpdate: z.literal("plan_update"),
    })),
    zPlanRemoved.and(z.object({
        sessionUpdate: z.literal("plan_removed"),
    })),
    zAvailableCommandsUpdate.and(z.object({
        sessionUpdate: z.literal("available_commands_update"),
    })),
    zConfigOptionUpdate.and(z.object({
        sessionUpdate: z.literal("config_option_update"),
    })),
    zSessionInfoUpdate.and(z.object({
        sessionUpdate: z.literal("session_info_update"),
    })),
    zUsageUpdate.and(z.object({
        sessionUpdate: z.literal("usage_update"),
    })),
    zCompactionUpdate.and(z.object({
        sessionUpdate: z.literal("compaction_update"),
    })),
    zCompactionSummaryChunk.and(z.object({
        sessionUpdate: z.literal("compaction_summary_chunk"),
    })),
    excludeKnownTags(z.object({
        sessionUpdate: z.string(),
    }), "sessionUpdate", [
        "agent_message",
        "agent_message_chunk",
        "agent_thought",
        "agent_thought_chunk",
        "available_commands_update",
        "compaction_summary_chunk",
        "compaction_update",
        "config_option_update",
        "plan_removed",
        "plan_update",
        "session_info_update",
        "state_update",
        "terminal_output_chunk",
        "terminal_update",
        "tool_call_content_chunk",
        "tool_call_update",
        "usage_update",
        "user_message",
        "user_message_chunk",
    ]),
]), "sessionUpdate", [
    "agent_message",
    "agent_message_chunk",
    "agent_thought",
    "agent_thought_chunk",
    "available_commands_update",
    "compaction_summary_chunk",
    "compaction_update",
    "config_option_update",
    "plan_removed",
    "plan_update",
    "session_info_update",
    "state_update",
    "terminal_output_chunk",
    "terminal_update",
    "tool_call_content_chunk",
    "tool_call_update",
    "usage_update",
    "user_message",
    "user_message_chunk",
]);
/**
 * Notification containing a session update from the agent.
 *
 * Agents can send session updates at any point while the session exists.
 *
 * See protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/v2/draft/prompt-lifecycle#3-agent-reports-output)
 */
export const zUpdateSessionNotification = z.object({
    sessionId: zSessionId,
    update: zSessionUpdate,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Notification sent by the agent when a URL-based elicitation is complete.
 */
export const zCompleteElicitationNotification = z.object({
    elicitationId: zElicitationId,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Notification parameters for `mcp/message`.
 *
 * This is used when the wrapped MCP message is a notification and the outer JSON-RPC
 * envelope has no `id`.
 *
 * @experimental
 */
export const zMessageMcpNotification = z.object({
    connectionId: zMcpConnectionId,
    method: z.string(),
    params: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Allows the Agent to send an arbitrary notification that is not part of the ACP spec.
 * Extension notifications provide a way to send one-way messages for custom functionality
 * while maintaining protocol compatibility.
 *
 * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/draft/extensibility)
 */
export const zExtNotification = z.unknown();
/**
 * A JSON-RPC notification object.
 */
export const zAgentNotification = z.object({
    method: z.string(),
    params: z
        .union([
        zUpdateSessionNotification,
        zCompleteElicitationNotification,
        zMessageMcpNotification,
        zExtNotification,
    ])
        .nullish(),
});
/**
 * Capabilities for terminal authentication methods.
 *
 * Supplying `{}` means the client can reproduce the configured agent
 * invocation in an interactive terminal and supports terminal authentication
 * methods.
 */
export const zTerminalAuthCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Authentication capabilities supported by the client.
 *
 * Advertised during initialization to inform the agent which authentication
 * method types the client can handle. This governs opt-in types that require
 * additional client-side support.
 */
export const zAuthCapabilities = z.object({
    terminal: defaultOnError(zTerminalAuthCapabilities.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Form-based elicitation capabilities.
 *
 * Supplying `{}` means the client supports form-based elicitation.
 */
export const zElicitationFormCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * URL-based elicitation capabilities.
 *
 * Supplying `{}` means the client supports URL-based elicitation.
 */
export const zElicitationUrlCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Elicitation capabilities supported by the client.
 */
export const zElicitationCapabilities = z.object({
    form: defaultOnError(zElicitationFormCapabilities.nullish(), () => undefined),
    url: defaultOnError(zElicitationUrlCapabilities.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Marker for jump suggestion support.
 */
export const zNesJumpCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Marker for rename suggestion support.
 */
export const zNesRenameCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Marker for search and replace suggestion support.
 */
export const zNesSearchAndReplaceCapabilities = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * NES capabilities advertised by the client during initialization.
 */
export const zClientNesCapabilities = z.object({
    jump: defaultOnError(zNesJumpCapabilities.nullish(), () => undefined),
    rename: defaultOnError(zNesRenameCapabilities.nullish(), () => undefined),
    searchAndReplace: defaultOnError(zNesSearchAndReplaceCapabilities.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Capabilities supported by the client.
 *
 * Advertised during initialization to inform the agent about
 * available features and methods.
 *
 * See protocol docs: [Client Capabilities](https://agentclientprotocol.com/protocol/v2/draft/initialization#client-capabilities)
 */
export const zClientCapabilities = z.object({
    auth: defaultOnError(zAuthCapabilities.nullish(), () => undefined),
    elicitation: defaultOnError(zElicitationCapabilities.nullish(), () => undefined),
    nes: defaultOnError(zClientNesCapabilities.nullish(), () => undefined),
    positionEncodings: defaultOnError(vecSkipError(zPositionEncodingKind).optional(), () => []),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Request parameters for the initialize method.
 *
 * Sent by the client to establish connection and negotiate capabilities.
 *
 * See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/v2/draft/initialization)
 */
export const zInitializeRequest = z.object({
    protocolVersion: zProtocolVersion,
    info: zImplementation,
    capabilities: defaultOnError(zClientCapabilities.optional().default({}), () => ({})),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Request parameters for the `auth/login` method.
 *
 * Specifies which authentication method to use.
 *
 * Agents MUST support this method when their `initialize` response advertised
 * at least one valid authentication method. Clients MUST NOT call this method
 * when `authMethods` was omitted or empty.
 */
export const zLoginAuthRequest = z.object({
    methodId: zAuthMethodId,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Request parameters for `providers/list`.
 *
 * @experimental
 */
export const zListProvidersRequest = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Request parameters for `providers/set`.
 *
 * Replaces the full configuration for one provider ID.
 *
 * @experimental
 */
export const zSetProviderRequest = z.object({
    providerId: zProviderId,
    apiType: zLlmProtocol,
    baseUrl: z.url(),
    headers: z.record(z.string(), z.string()).optional(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Request parameters for `providers/disable`.
 *
 * @experimental
 */
export const zDisableProviderRequest = z.object({
    providerId: zProviderId,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Request parameters for the `auth/logout` method.
 *
 * Terminates the current authenticated session.
 *
 * Agents MUST support this method when their `initialize` response advertised
 * at least one valid authentication method. Clients MUST NOT call this method
 * when `authMethods` was omitted or empty.
 */
export const zLogoutAuthRequest = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * An HTTP header to set when making requests to the MCP server.
 */
export const zHttpHeader = z.object({
    name: z.string(),
    value: z.string(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * HTTP transport configuration for MCP.
 */
export const zMcpServerHttp = z.object({
    name: z.string(),
    url: z.url(),
    headers: z.array(zHttpHeader).optional(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * ACP transport configuration for MCP.
 *
 * The MCP server is provided by an ACP component and communicates over the ACP channel
 * using `mcp/connect`, `mcp/message`, and `mcp/disconnect`.
 *
 * @experimental
 */
export const zMcpServerAcp = z.object({
    name: z.string(),
    serverId: zMcpServerAcpId,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Stdio transport configuration for MCP.
 */
export const zMcpServerStdio = z.object({
    name: z.string(),
    command: zAbsolutePath,
    args: z.array(z.string()).optional(),
    env: z.array(zEnvVariable).optional(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Configuration for connecting to an MCP (Model Context Protocol) server.
 *
 * MCP servers provide tools and context that the agent can use when
 * processing prompts.
 *
 * See protocol docs: [MCP Servers](https://agentclientprotocol.com/protocol/v2/draft/session-setup#mcp-servers)
 *
 * Custom variants (unknown `type` values) keep their extra
 * properties exactly as received; unlike known variants, those keys
 * bypass lenient-field salvage and arrive unvalidated.
 */
export const zMcpServer = preserveCustomPayload(z.union([
    zMcpServerHttp.and(z.object({
        type: z.literal("http"),
    })),
    zMcpServerAcp.and(z.object({
        type: z.literal("acp"),
    })),
    zMcpServerStdio.and(z.object({
        type: z.literal("stdio"),
    })),
    excludeKnownTags(z.object({
        type: z.string(),
    }), "type", ["acp", "http", "stdio"]),
]), "type", ["acp", "http", "stdio"]);
/**
 * Request parameters for creating a new session.
 *
 * See protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol/v2/draft/session-setup#creating-a-session)
 */
export const zNewSessionRequest = z.object({
    cwd: zAbsolutePath,
    additionalDirectories: defaultOnError(vecSkipError(zAbsolutePath).optional(), () => []),
    mcpServers: defaultOnError(vecSkipError(zMcpServer).optional(), () => []),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Request parameters for listing existing sessions.
 */
export const zListSessionsRequest = z.object({
    cwd: zAbsolutePath.nullish(),
    cursor: zSessionListCursor.nullish(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Request parameters for deleting an existing session from `session/list`.
 *
 * Only available if the Agent supports the `session.delete` capability.
 */
export const zDeleteSessionRequest = z.object({
    sessionId: zSessionId,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Request parameters for forking an existing session.
 *
 * Creates a new session based on the context of an existing one, allowing
 * operations like generating summaries without affecting the original session's history.
 *
 * Only available if the Agent supports the `session.fork` capability.
 *
 * @experimental
 */
export const zForkSessionRequest = z.object({
    sessionId: zSessionId,
    cwd: zAbsolutePath,
    additionalDirectories: defaultOnError(vecSkipError(zAbsolutePath).optional(), () => []),
    mcpServers: defaultOnError(vecSkipError(zMcpServer).optional(), () => []),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Inclusive replay cursor requesting replay from the start of the conversation.
 */
export const zReplayFromStart = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Inclusive cursor describing where replayed session history should begin.
 *
 * Replay includes the position identified by the cursor.
 *
 * Custom variants (unknown `type` values) keep their extra
 * properties exactly as received; unlike known variants, those keys
 * bypass lenient-field salvage and arrive unvalidated.
 */
export const zReplayFrom = preserveCustomPayload(z.union([
    zReplayFromStart.and(z.object({
        type: z.literal("start"),
    })),
    excludeKnownTags(z.object({
        type: z.string(),
        _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
    }), "type", ["start"]),
]), "type", ["start"]);
/**
 * Request parameters for resuming an existing session.
 *
 * Resumes an existing session and optionally replays prior conversation
 * history according to `replayFrom`.
 */
export const zResumeSessionRequest = z.object({
    sessionId: zSessionId,
    cwd: zAbsolutePath,
    additionalDirectories: defaultOnError(vecSkipError(zAbsolutePath).optional(), () => []),
    mcpServers: defaultOnError(vecSkipError(zMcpServer).optional(), () => []),
    replayFrom: defaultOnError(zReplayFrom.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Request parameters for closing an active session.
 *
 * The agent **must** cancel any ongoing work related to the session (treat it
 * as if `session/cancel` was called) and then free up any resources associated
 * with the session.
 */
export const zCloseSessionRequest = z.object({
    sessionId: zSessionId,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Request parameters for setting a session configuration option.
 *
 * Custom variants (unknown `type` values) keep their extra
 * properties exactly as received; unlike known variants, those keys
 * bypass lenient-field salvage and arrive unvalidated.
 */
export const zSetSessionConfigOptionRequest = preserveCustomPayload(z.intersection(z.union([
    z.object({
        value: zSessionConfigValueId,
        type: z.literal("id"),
    }),
    z.object({
        value: z.boolean(),
        type: z.literal("boolean"),
    }),
    excludeKnownTags(z.object({
        type: z.string(),
        value: z.unknown(),
    }), "type", ["boolean", "id"]),
]), z.object({
    sessionId: zSessionId,
    configId: zSessionConfigId,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
})), "type", ["boolean", "id"]);
/**
 * Request parameters for sending a user prompt to the agent.
 *
 * Contains the user's message and any additional context.
 *
 * See protocol docs: [User Message](https://agentclientprotocol.com/protocol/v2/draft/prompt-lifecycle#1-user-message)
 */
export const zPromptRequest = z.object({
    sessionId: zSessionId,
    prompt: z.array(zContentBlock),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * A workspace folder.
 */
export const zWorkspaceFolder = z.object({
    uri: z.url(),
    name: z.string(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Repository metadata for an NES session.
 */
export const zNesRepository = z.object({
    name: z.string(),
    owner: z.string(),
    remoteUrl: z.string(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Request to start an NES session.
 */
export const zStartNesRequest = z.object({
    workspaceUri: defaultOnError(z.url().nullish(), () => undefined),
    workspaceFolders: z.array(zWorkspaceFolder).nullish(),
    repository: defaultOnError(zNesRepository.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * What triggered the suggestion request.
 */
export const zNesTriggerKind = z.union([
    z.literal("automatic"),
    z.literal("diagnostic"),
    z.literal("manual"),
    z.string(),
]);
/**
 * A recently accessed file.
 */
export const zNesRecentFile = z.object({
    uri: z.url(),
    languageId: z.string(),
    text: z.string(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * A code excerpt from a file.
 */
export const zNesExcerpt = z.object({
    startLine: z.int().gte(0).max(4294967295, {
        error: "Invalid value: Expected uint32 to be <= 4294967295",
    }),
    endLine: z.int().gte(0).max(4294967295, {
        error: "Invalid value: Expected uint32 to be <= 4294967295",
    }),
    text: z.string(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * A related code snippet from a file.
 */
export const zNesRelatedSnippet = z.object({
    uri: z.url(),
    excerpts: z.array(zNesExcerpt),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * An entry in the edit history.
 */
export const zNesEditHistoryEntry = z.object({
    uri: z.url(),
    diff: z.string(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * A user action (typing, cursor movement, etc.).
 */
export const zNesUserAction = z.object({
    action: z.string(),
    uri: z.url(),
    position: zPosition,
    timestampMs: z.number(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * An open file in the editor.
 */
export const zNesOpenFile = z.object({
    uri: z.url(),
    languageId: z.string(),
    visibleRange: defaultOnError(zRange.nullish(), () => undefined),
    lastFocusedMs: defaultOnError(z.number().nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Severity of a diagnostic.
 */
export const zNesDiagnosticSeverity = z.union([
    z.literal("error"),
    z.literal("warning"),
    z.literal("information"),
    z.literal("hint"),
    z.string(),
]);
/**
 * A diagnostic (error, warning, etc.).
 */
export const zNesDiagnostic = z.object({
    uri: z.url(),
    range: zRange,
    severity: zNesDiagnosticSeverity,
    message: z.string(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Context attached to a suggestion request.
 */
export const zNesSuggestContext = z.object({
    recentFiles: z.array(zNesRecentFile).nullish(),
    relatedSnippets: z.array(zNesRelatedSnippet).nullish(),
    editHistory: z.array(zNesEditHistoryEntry).nullish(),
    userActions: z.array(zNesUserAction).nullish(),
    openFiles: z.array(zNesOpenFile).nullish(),
    diagnostics: z.array(zNesDiagnostic).nullish(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Request for a code suggestion.
 */
export const zSuggestNesRequest = z.object({
    sessionId: zSessionId,
    uri: z.url(),
    version: z.number(),
    position: zPosition,
    selection: zRange.nullish(),
    triggerKind: zNesTriggerKind,
    context: zNesSuggestContext.nullish(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Request to close an NES session.
 *
 * The agent **must** cancel any ongoing work related to the NES session
 * and then free up any resources associated with the session.
 */
export const zCloseNesRequest = z.object({
    sessionId: zSessionId,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * A JSON-RPC request object.
 */
export const zClientRequest = z.object({
    id: zRequestId,
    method: z.string(),
    params: z
        .union([
        zInitializeRequest,
        zLoginAuthRequest,
        zListProvidersRequest,
        zSetProviderRequest,
        zDisableProviderRequest,
        zLogoutAuthRequest,
        zNewSessionRequest,
        zListSessionsRequest,
        zDeleteSessionRequest,
        zForkSessionRequest,
        zResumeSessionRequest,
        zCloseSessionRequest,
        zSetSessionConfigOptionRequest,
        zPromptRequest,
        zStartNesRequest,
        zSuggestNesRequest,
        zCloseNesRequest,
        zMessageMcpRequest,
        zExtRequest,
    ])
        .nullish(),
});
/**
 * The user selected one of the provided options.
 */
export const zSelectedPermissionOutcome = z.object({
    optionId: zPermissionOptionId,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * The outcome of a permission request.
 *
 * Custom variants (unknown `outcome` values) keep their extra
 * properties exactly as received; unlike known variants, those keys
 * bypass lenient-field salvage and arrive unvalidated.
 */
export const zRequestPermissionOutcome = preserveCustomPayload(z.union([
    z.object({
        outcome: z.literal("cancelled"),
    }),
    zSelectedPermissionOutcome.and(z.object({
        outcome: z.literal("selected"),
    })),
    excludeKnownTags(z.object({
        outcome: z.string(),
    }), "outcome", ["cancelled", "selected"]),
]), "outcome", ["cancelled", "selected"]);
/**
 * Response to a permission request.
 */
export const zRequestPermissionResponse = z.object({
    outcome: zRequestPermissionOutcome,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Allowed wire representations for [`ElicitationContentValue`].
 */
export const zElicitationContentValue = z.union([
    z.string(),
    z.number(),
    z.number(),
    z.boolean(),
    z.array(z.string()),
]);
/**
 * The user accepted the elicitation and provided content.
 */
export const zElicitationAcceptAction = z.object({
    content: z.record(z.string(), zElicitationContentValue).nullish(),
});
/**
 * Response from the client to an elicitation request.
 *
 * Custom variants (unknown `action` values) keep their extra
 * properties exactly as received; unlike known variants, those keys
 * bypass lenient-field salvage and arrive unvalidated.
 */
export const zCreateElicitationResponse = preserveCustomPayload(z.intersection(z.union([
    zElicitationAcceptAction.and(z.object({
        action: z.literal("accept"),
    })),
    z.object({
        action: z.literal("decline"),
    }),
    z.object({
        action: z.literal("cancel"),
    }),
    excludeKnownTags(z.object({
        action: z.string(),
    }), "action", ["accept", "cancel", "decline"]),
]), z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
})), "action", ["accept", "cancel", "decline"]);
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Response to `mcp/connect`.
 *
 * @experimental
 */
export const zConnectMcpResponse = z.object({
    connectionId: zMcpConnectionId,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * **UNSTABLE**
 *
 * This capability is not part of the spec yet, and may be removed or changed at any point.
 *
 * Response to `mcp/disconnect`.
 *
 * @experimental
 */
export const zDisconnectMcpResponse = z.object({
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * A JSON-RPC response object.
 */
export const zClientResponse = z.union([
    z.object({
        id: zRequestId,
        result: z.union([
            zRequestPermissionResponse,
            zCreateElicitationResponse,
            zConnectMcpResponse,
            zDisconnectMcpResponse,
            zMessageMcpResponse,
            zExtResponse,
        ]),
    }),
    z.object({
        id: zRequestId,
        error: zError,
    }),
]);
/**
 * Notification to cancel ongoing operations for a session.
 *
 * See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/v2/draft/prompt-lifecycle#cancellation)
 */
export const zCancelSessionNotification = z.object({
    sessionId: zSessionId,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Notification sent when a file is opened in the editor.
 */
export const zDidOpenDocumentNotification = z.object({
    sessionId: zSessionId,
    uri: z.url(),
    languageId: z.string(),
    version: z.number(),
    text: z.string(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * A content change event for a document.
 *
 * When `range` is `None`, `text` is the full content of the document.
 * When `range` is `Some`, `text` replaces the given range.
 */
export const zTextDocumentContentChangeEvent = z.object({
    range: zRange.nullish(),
    text: z.string(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Notification sent when a file is edited.
 */
export const zDidChangeDocumentNotification = z.object({
    sessionId: zSessionId,
    uri: z.url(),
    version: z.number(),
    contentChanges: requiredDefaultOnError(vecSkipError(zTextDocumentContentChangeEvent), () => []),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Notification sent when a file is closed.
 */
export const zDidCloseDocumentNotification = z.object({
    sessionId: zSessionId,
    uri: z.url(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Notification sent when a file is saved.
 */
export const zDidSaveDocumentNotification = z.object({
    sessionId: zSessionId,
    uri: z.url(),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Notification sent when a file becomes the active editor tab.
 */
export const zDidFocusDocumentNotification = z.object({
    sessionId: zSessionId,
    uri: z.url(),
    version: z.number(),
    position: zPosition,
    visibleRange: zRange,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * Notification sent when a suggestion is accepted.
 */
export const zAcceptNesNotification = z.object({
    sessionId: zSessionId,
    suggestionId: zNesSuggestionId,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * The reason a suggestion was rejected.
 */
export const zNesRejectReason = z.union([
    z.literal("rejected"),
    z.literal("ignored"),
    z.literal("replaced"),
    z.literal("cancelled"),
    z.string(),
]);
/**
 * Notification sent when a suggestion is rejected.
 */
export const zRejectNesNotification = z.object({
    sessionId: zSessionId,
    suggestionId: zNesSuggestionId,
    reason: defaultOnError(zNesRejectReason.nullish(), () => undefined),
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * A JSON-RPC notification object.
 */
export const zClientNotification = z.object({
    method: z.string(),
    params: z
        .union([
        zCancelSessionNotification,
        zDidOpenDocumentNotification,
        zDidChangeDocumentNotification,
        zDidCloseDocumentNotification,
        zDidSaveDocumentNotification,
        zDidFocusDocumentNotification,
        zAcceptNesNotification,
        zRejectNesNotification,
        zMessageMcpNotification,
        zExtNotification,
    ])
        .nullish(),
});
/**
 * Notification to cancel an ongoing request.
 *
 * See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/v2/draft/cancellation)
 */
export const zCancelRequestNotification = z.object({
    requestId: zRequestId,
    _meta: defaultOnError(z.record(z.string(), z.unknown()).nullish(), () => undefined),
});
/**
 * A JSON-RPC notification object.
 */
export const zProtocolLevelNotification = z.object({
    method: z.string(),
    params: zCancelRequestNotification.nullish(),
});
//# sourceMappingURL=zod.gen.js.map