/**
 * Envelope codecs — a *table* of per-type wire schemas, not an `if`/`switch`
 * ladder.
 *
 * Everything that flows through a {@link import("./channel").Channel} is an
 * {@link Envelope}: a small, self-describing record carrying a `type` tag and a
 * `type`-specific `payload`. The four traffic classes the swarm exchanges are:
 *
 *   - `task`    — a unit of work handed from one teammate to another.
 *   - `result`  — the outcome of a previously dispatched task.
 *   - `note`    — free-form chatter / status with no contractual shape.
 *   - `control` — a lifecycle signal (pause, resume, drain, …) addressed at a
 *     reader rather than at the work itself.
 *
 * Rather than branch on `type` everywhere a message is read or written, each
 * class registers a zod schema for its `payload` in a single {@link
 * CODEC_TABLE}. {@link encode} and {@link decode} dispatch *through the table*
 * by looking the tag up — adding a fifth class is one table row, not a new
 * `case` scattered across the codebase. Validation is the schema's job; there
 * are no hand-rolled `is*` guards anywhere in this module.
 */
import { z, type ZodType } from "zod";
/** The closed set of message classes the postbox understands. */
export declare const ENVELOPE_TYPES: readonly ["task", "result", "note", "control"];
/** A single message class tag — the table key and the envelope discriminant. */
export type EnvelopeType = (typeof ENVELOPE_TYPES)[number];
/**
 * The codec table: message-class tag → its codec row. This is the single source
 * of truth {@link encode}/{@link decode} dispatch through. Declared `satisfies`
 * a `Record<EnvelopeType, …>` so dropping a class — or adding one without a
 * row — is a compile error, keeping the table exhaustive over
 * {@link EnvelopeType}.
 */
declare const CODEC_TABLE: {
    readonly task: {
        readonly payload: z.ZodObject<{
            title: z.ZodString;
            brief: z.ZodString;
            ticketId: z.ZodOptional<z.ZodString>;
            priority: z.ZodDefault<z.ZodEnum<{
                low: "low";
                high: "high";
                normal: "normal";
            }>>;
        }, z.core.$strip>;
    };
    readonly result: {
        readonly payload: z.ZodObject<{
            taskId: z.ZodString;
            status: z.ZodEnum<{
                error: "error";
                ok: "ok";
                skipped: "skipped";
            }>;
            summary: z.ZodString;
            artifacts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
        }, z.core.$strip>;
    };
    readonly note: {
        readonly payload: z.ZodObject<{
            text: z.ZodString;
        }, z.core.$strip>;
    };
    readonly control: {
        readonly payload: z.ZodObject<{
            signal: z.ZodEnum<{
                pause: "pause";
                resume: "resume";
                drain: "drain";
                shutdown: "shutdown";
            }>;
            reason: z.ZodOptional<z.ZodString>;
        }, z.core.$strip>;
    };
};
/** The decoded payload type for a given message class, inferred from its row. */
export type PayloadOf<K extends EnvelopeType> = z.infer<(typeof CODEC_TABLE)[K]["payload"]>;
/**
 * The full wire envelope schema, as a discriminated union over `type`.
 *
 * Each branch is built *from the table*, reusing the row's `payload` schema
 * rather than re-declaring it, so the table stays the single source of truth
 * for what each class may carry. The branch tuple is written out explicitly so
 * zod keeps full per-class inference (narrowing on `type` narrows `payload`);
 * it is checked exhaustive against {@link ENVELOPE_TYPES} just below.
 */
declare const envelopeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
    type: z.ZodLiteral<"task">;
    payload: z.ZodObject<{
        title: z.ZodString;
        brief: z.ZodString;
        ticketId: z.ZodOptional<z.ZodString>;
        priority: z.ZodDefault<z.ZodEnum<{
            low: "low";
            high: "high";
            normal: "normal";
        }>>;
    }, z.core.$strip> | z.ZodObject<{
        taskId: z.ZodString;
        status: z.ZodEnum<{
            error: "error";
            ok: "ok";
            skipped: "skipped";
        }>;
        summary: z.ZodString;
        artifacts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
    }, z.core.$strip> | z.ZodObject<{
        text: z.ZodString;
    }, z.core.$strip> | z.ZodObject<{
        signal: z.ZodEnum<{
            pause: "pause";
            resume: "resume";
            drain: "drain";
            shutdown: "shutdown";
        }>;
        reason: z.ZodOptional<z.ZodString>;
    }, z.core.$strip>;
    id: z.ZodString;
    from: z.ZodString;
    to: z.ZodString;
    ts: z.ZodNumber;
}, z.core.$strip>, z.ZodObject<{
    type: z.ZodLiteral<"result">;
    payload: z.ZodObject<{
        title: z.ZodString;
        brief: z.ZodString;
        ticketId: z.ZodOptional<z.ZodString>;
        priority: z.ZodDefault<z.ZodEnum<{
            low: "low";
            high: "high";
            normal: "normal";
        }>>;
    }, z.core.$strip> | z.ZodObject<{
        taskId: z.ZodString;
        status: z.ZodEnum<{
            error: "error";
            ok: "ok";
            skipped: "skipped";
        }>;
        summary: z.ZodString;
        artifacts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
    }, z.core.$strip> | z.ZodObject<{
        text: z.ZodString;
    }, z.core.$strip> | z.ZodObject<{
        signal: z.ZodEnum<{
            pause: "pause";
            resume: "resume";
            drain: "drain";
            shutdown: "shutdown";
        }>;
        reason: z.ZodOptional<z.ZodString>;
    }, z.core.$strip>;
    id: z.ZodString;
    from: z.ZodString;
    to: z.ZodString;
    ts: z.ZodNumber;
}, z.core.$strip>, z.ZodObject<{
    type: z.ZodLiteral<"note">;
    payload: z.ZodObject<{
        title: z.ZodString;
        brief: z.ZodString;
        ticketId: z.ZodOptional<z.ZodString>;
        priority: z.ZodDefault<z.ZodEnum<{
            low: "low";
            high: "high";
            normal: "normal";
        }>>;
    }, z.core.$strip> | z.ZodObject<{
        taskId: z.ZodString;
        status: z.ZodEnum<{
            error: "error";
            ok: "ok";
            skipped: "skipped";
        }>;
        summary: z.ZodString;
        artifacts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
    }, z.core.$strip> | z.ZodObject<{
        text: z.ZodString;
    }, z.core.$strip> | z.ZodObject<{
        signal: z.ZodEnum<{
            pause: "pause";
            resume: "resume";
            drain: "drain";
            shutdown: "shutdown";
        }>;
        reason: z.ZodOptional<z.ZodString>;
    }, z.core.$strip>;
    id: z.ZodString;
    from: z.ZodString;
    to: z.ZodString;
    ts: z.ZodNumber;
}, z.core.$strip>, z.ZodObject<{
    type: z.ZodLiteral<"control">;
    payload: z.ZodObject<{
        title: z.ZodString;
        brief: z.ZodString;
        ticketId: z.ZodOptional<z.ZodString>;
        priority: z.ZodDefault<z.ZodEnum<{
            low: "low";
            high: "high";
            normal: "normal";
        }>>;
    }, z.core.$strip> | z.ZodObject<{
        taskId: z.ZodString;
        status: z.ZodEnum<{
            error: "error";
            ok: "ok";
            skipped: "skipped";
        }>;
        summary: z.ZodString;
        artifacts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
    }, z.core.$strip> | z.ZodObject<{
        text: z.ZodString;
    }, z.core.$strip> | z.ZodObject<{
        signal: z.ZodEnum<{
            pause: "pause";
            resume: "resume";
            drain: "drain";
            shutdown: "shutdown";
        }>;
        reason: z.ZodOptional<z.ZodString>;
    }, z.core.$strip>;
    id: z.ZodString;
    from: z.ZodString;
    to: z.ZodString;
    ts: z.ZodNumber;
}, z.core.$strip>], "type">;
/**
 * A message as it travels through a channel. The `type` discriminant ties
 * `payload` to exactly one row of the {@link CODEC_TABLE}; narrowing on `type`
 * narrows `payload` to that class's shape.
 */
export type Envelope = z.infer<typeof envelopeSchema>;
/** The zod schema for a fully-formed {@link Envelope}. Reused by the channel. */
export declare const ENVELOPE_SCHEMA: ZodType<Envelope>;
/**
 * Validate and serialize an envelope to its one-line wire form.
 *
 * Dispatch is table-driven: validation runs the discriminated-union schema,
 * which selects the branch — and thus the payload row — by the envelope's own
 * `type`. A malformed envelope raises a `validation` fault rather than emitting
 * a bad line. Returns compact JSON (no trailing newline; the log adds framing).
 */
export declare function encode(env: Envelope): string;
/**
 * Parse and validate one wire line back into a typed {@link Envelope}.
 *
 * The same table dispatch runs in reverse: JSON is parsed, then the
 * discriminated union routes by `type` to the right payload row for validation.
 * Unparseable text or a row mismatch raises a `validation` fault.
 */
export declare function decode(line: string): Envelope;
export {};
