/**
 * `gateway/rpc` v1.0 — FROZEN NDJSON message contract (Zod schemas).
 *
 * The CLI-RPC transport carries gateway dispatch traffic over a long-lived
 * unix-domain socket. The wire format is newline-delimited JSON (NDJSON): one
 * {@link GatewayRpcFrame} per line — exactly the framing discipline used by the
 * FROZEN `supervisor-ipc` v1.0 contract, REUSED here (not edited): a versioned,
 * correlation-id'd envelope discriminated by `direction`.
 *
 * The difference from supervisor-ipc is the PAYLOAD: this contract wraps the
 * frozen gateway shapes ({@link dispatchRequestSchema} /
 * {@link dispatchResponseSchema} from `@cleocode/contracts/gateway`) rather
 * than supervisor process-control messages. So:
 *
 * ```jsonc
 * // request frame (client → server)
 * { "protocol_version": "1.0.0", "id": "abc", "direction": "request",
 *   "request": { "gateway": "query", "domain": "tasks", "operation": "show",
 *                "params": { "id": "T1" }, "source": "rpc",
 *                "requestId": "abc" } }
 * // response frame (server → client)
 * { "protocol_version": "1.0.0", "id": "abc", "direction": "response",
 *   "response": { "success": true, "data": {…}, "meta": {…} } }
 * // error frame (server → client) — protocol-level (bad version / parse / unknown)
 * { "protocol_version": "1.0.0", "id": "abc", "direction": "error",
 *   "error": { "code": "E_RPC_BAD_VERSION", "message": "…" } }
 * ```
 *
 * FROZEN v1.0: the {@link GATEWAY_RPC_DIRECTIONS} set is pinned by the drift
 * guard (`__tests__/freeze.test.ts`). Do not add/rename/remove directions in
 * place — bump to a new versioned directory instead. The request/response
 * PAYLOADS are owned by the gateway contract (R3-T2 · T11446) and re-validated
 * here so an untrusted RPC boundary cannot inject a malformed dispatch request.
 *
 * @task T11449
 * @epic T11254
 * @saga T11243
 * @packageDocumentation
 */
import { z } from 'zod';
import { GATEWAY_RPC_PROTOCOL_VERSION } from './version.js';
/**
 * A protocol-level (transport) error returned when a frame cannot even reach
 * the gateway: malformed JSON, a wrong `protocol_version`, or a frame the
 * server cannot route. Distinct from a {@link dispatchResponseSchema} `error`
 * field, which is a DOMAIN error produced by the handler itself.
 */
export declare const GatewayRpcErrorSchema: z.ZodObject<{
    code: z.ZodString;
    message: z.ZodString;
}, z.core.$strict>;
/** Protocol-level RPC error payload (inferred from {@link GatewayRpcErrorSchema}). */
export type GatewayRpcError = z.infer<typeof GatewayRpcErrorSchema>;
/**
 * A client → server request frame: a versioned, correlated wrapper around a
 * single frozen {@link dispatchRequestSchema}. The `direction` discriminator +
 * flattened `request` payload mirror the supervisor-ipc envelope shape.
 */
export declare const GatewayRpcRequestFrameSchema: z.ZodObject<{
    protocol_version: z.ZodString;
    id: z.ZodString;
    direction: z.ZodLiteral<"request">;
    request: z.ZodObject<{
        gateway: z.ZodCustom<import("../../gateway.js").Gateway, import("../../gateway.js").Gateway>;
        domain: z.ZodString;
        operation: z.ZodString;
        params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
        source: z.ZodEnum<{
            http: "http";
            cli: "cli";
            mcp: "mcp";
            rpc: "rpc";
        }>;
        requestId: z.ZodString;
        sessionId: z.ZodOptional<z.ZodString>;
        originSessionId: z.ZodOptional<z.ZodString>;
        executionSessionId: z.ZodOptional<z.ZodString>;
        _fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
        _mvi: z.ZodOptional<z.ZodCustom<import("@cleocode/lafs").MVILevel, import("@cleocode/lafs").MVILevel>>;
    }, z.core.$strip>;
}, z.core.$strict>;
/** Request frame (inferred from {@link GatewayRpcRequestFrameSchema}). */
export type GatewayRpcRequestFrame = z.infer<typeof GatewayRpcRequestFrameSchema>;
/**
 * A server → client response frame: a versioned, correlated wrapper around a
 * single frozen {@link dispatchResponseSchema} (the LAFS envelope the handler
 * produced).
 */
export declare const GatewayRpcResponseFrameSchema: z.ZodObject<{
    protocol_version: z.ZodString;
    id: z.ZodString;
    direction: z.ZodLiteral<"response">;
    response: z.ZodObject<{
        meta: z.ZodObject<{
            gateway: z.ZodCustom<import("../../gateway.js").Gateway, import("../../gateway.js").Gateway>;
            domain: z.ZodString;
            operation: z.ZodString;
            timestamp: z.ZodString;
            duration_ms: z.ZodNumber;
            source: z.ZodEnum<{
                http: "http";
                cli: "cli";
                mcp: "mcp";
                rpc: "rpc";
            }>;
            requestId: z.ZodString;
            rateLimit: z.ZodOptional<z.ZodObject<{
                limit: z.ZodNumber;
                remaining: z.ZodNumber;
                resetMs: z.ZodNumber;
                category: z.ZodString;
            }, z.core.$strip>>;
            sessionId: z.ZodOptional<z.ZodString>;
            originSessionId: z.ZodOptional<z.ZodString>;
            executionSessionId: z.ZodOptional<z.ZodString>;
            version: z.ZodOptional<z.ZodString>;
        }, z.core.$catchall<z.ZodUnknown>>;
        success: z.ZodBoolean;
        data: z.ZodOptional<z.ZodUnknown>;
        page: z.ZodOptional<z.ZodCustom<import("@cleocode/lafs").LAFSPage, import("@cleocode/lafs").LAFSPage>>;
        partial: z.ZodOptional<z.ZodBoolean>;
        error: z.ZodOptional<z.ZodObject<{
            code: z.ZodString;
            exitCode: z.ZodOptional<z.ZodNumber>;
            message: z.ZodString;
            details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
            fix: z.ZodOptional<z.ZodString>;
            alternatives: z.ZodOptional<z.ZodArray<z.ZodObject<{
                action: z.ZodString;
                command: z.ZodString;
            }, z.core.$strip>>>;
            problemDetails: z.ZodOptional<z.ZodCustom<import("../../engine-result.js").ProblemDetails, import("../../engine-result.js").ProblemDetails>>;
        }, z.core.$strip>>;
    }, z.core.$strip>;
}, z.core.$strict>;
/** Response frame (inferred from {@link GatewayRpcResponseFrameSchema}). */
export type GatewayRpcResponseFrame = z.infer<typeof GatewayRpcResponseFrameSchema>;
/**
 * A server → client protocol-level error frame, emitted when a request frame
 * cannot be decoded or routed. Correlation `id` is best-effort (`'0'` when the
 * frame was so malformed the id could not be recovered).
 */
export declare const GatewayRpcErrorFrameSchema: z.ZodObject<{
    protocol_version: z.ZodString;
    id: z.ZodString;
    direction: z.ZodLiteral<"error">;
    error: z.ZodObject<{
        code: z.ZodString;
        message: z.ZodString;
    }, z.core.$strict>;
}, z.core.$strict>;
/** Error frame (inferred from {@link GatewayRpcErrorFrameSchema}). */
export type GatewayRpcErrorFrame = z.infer<typeof GatewayRpcErrorFrameSchema>;
/**
 * The top-level RPC frame: a versioned, correlated wrapper that is a request,
 * a response, or a protocol-level error, discriminated by `direction`. One
 * frame per NDJSON line.
 */
export declare const GatewayRpcFrameSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
    protocol_version: z.ZodString;
    id: z.ZodString;
    direction: z.ZodLiteral<"request">;
    request: z.ZodObject<{
        gateway: z.ZodCustom<import("../../gateway.js").Gateway, import("../../gateway.js").Gateway>;
        domain: z.ZodString;
        operation: z.ZodString;
        params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
        source: z.ZodEnum<{
            http: "http";
            cli: "cli";
            mcp: "mcp";
            rpc: "rpc";
        }>;
        requestId: z.ZodString;
        sessionId: z.ZodOptional<z.ZodString>;
        originSessionId: z.ZodOptional<z.ZodString>;
        executionSessionId: z.ZodOptional<z.ZodString>;
        _fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
        _mvi: z.ZodOptional<z.ZodCustom<import("@cleocode/lafs").MVILevel, import("@cleocode/lafs").MVILevel>>;
    }, z.core.$strip>;
}, z.core.$strict>, z.ZodObject<{
    protocol_version: z.ZodString;
    id: z.ZodString;
    direction: z.ZodLiteral<"response">;
    response: z.ZodObject<{
        meta: z.ZodObject<{
            gateway: z.ZodCustom<import("../../gateway.js").Gateway, import("../../gateway.js").Gateway>;
            domain: z.ZodString;
            operation: z.ZodString;
            timestamp: z.ZodString;
            duration_ms: z.ZodNumber;
            source: z.ZodEnum<{
                http: "http";
                cli: "cli";
                mcp: "mcp";
                rpc: "rpc";
            }>;
            requestId: z.ZodString;
            rateLimit: z.ZodOptional<z.ZodObject<{
                limit: z.ZodNumber;
                remaining: z.ZodNumber;
                resetMs: z.ZodNumber;
                category: z.ZodString;
            }, z.core.$strip>>;
            sessionId: z.ZodOptional<z.ZodString>;
            originSessionId: z.ZodOptional<z.ZodString>;
            executionSessionId: z.ZodOptional<z.ZodString>;
            version: z.ZodOptional<z.ZodString>;
        }, z.core.$catchall<z.ZodUnknown>>;
        success: z.ZodBoolean;
        data: z.ZodOptional<z.ZodUnknown>;
        page: z.ZodOptional<z.ZodCustom<import("@cleocode/lafs").LAFSPage, import("@cleocode/lafs").LAFSPage>>;
        partial: z.ZodOptional<z.ZodBoolean>;
        error: z.ZodOptional<z.ZodObject<{
            code: z.ZodString;
            exitCode: z.ZodOptional<z.ZodNumber>;
            message: z.ZodString;
            details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
            fix: z.ZodOptional<z.ZodString>;
            alternatives: z.ZodOptional<z.ZodArray<z.ZodObject<{
                action: z.ZodString;
                command: z.ZodString;
            }, z.core.$strip>>>;
            problemDetails: z.ZodOptional<z.ZodCustom<import("../../engine-result.js").ProblemDetails, import("../../engine-result.js").ProblemDetails>>;
        }, z.core.$strip>>;
    }, z.core.$strip>;
}, z.core.$strict>, z.ZodObject<{
    protocol_version: z.ZodString;
    id: z.ZodString;
    direction: z.ZodLiteral<"error">;
    error: z.ZodObject<{
        code: z.ZodString;
        message: z.ZodString;
    }, z.core.$strict>;
}, z.core.$strict>], "direction">;
/** Any RPC frame (inferred from {@link GatewayRpcFrameSchema}). */
export type GatewayRpcFrame = z.infer<typeof GatewayRpcFrameSchema>;
/**
 * The FROZEN v1.0 `direction` discriminator values. The drift guard
 * (`__tests__/freeze.test.ts`) pins this tuple; any addition/removal is a
 * contract-breaking change requiring a new versioned directory.
 */
export declare const GATEWAY_RPC_DIRECTIONS: readonly ["request", "response", "error"];
/** A single frozen RPC frame direction. */
export type GatewayRpcDirection = (typeof GATEWAY_RPC_DIRECTIONS)[number];
/**
 * The FROZEN v1.0 protocol-level transport error codes the adapter emits in an
 * {@link GatewayRpcErrorFrameSchema}. Pinned by the drift guard.
 */
export declare const GATEWAY_RPC_ERROR_CODES: readonly ["E_RPC_PARSE", "E_RPC_BAD_VERSION", "E_RPC_BAD_FRAME", "E_RPC_INTERNAL"];
/** A single frozen RPC protocol-level error code. */
export type GatewayRpcErrorCode = (typeof GATEWAY_RPC_ERROR_CODES)[number];
/**
 * Type guard: is `v` the frozen RPC protocol version this contract pins?
 *
 * Used by the adapter's version-negotiation step to reject mismatched frames
 * with an `E_RPC_BAD_VERSION` error frame before any gateway routing.
 *
 * @param v - The candidate `protocol_version` string from an inbound frame.
 * @returns `true` iff `v` equals {@link GATEWAY_RPC_PROTOCOL_VERSION}.
 */
export declare function isFrozenGatewayRpcVersion(v: string): v is typeof GATEWAY_RPC_PROTOCOL_VERSION;
//# sourceMappingURL=messages.d.ts.map