/**
 * Collab live-session wire protocol.
 *
 * Hub topology: the host is authoritative, guests never peer. All session
 * payloads (`CollabFrame`) travel AES-256-GCM sealed; the relay only sees the
 * plaintext envelope (`[4B uint32 BE peerId][sealed payload]`) plus TEXT JSON
 * control messages that carry no session data.
 */
import type { ImageContent, Model } from "@pk-nerdsaver-ai/pi-ai";
import type { BusChannel, GuestFrame, ParsedCollabLink, Participant, SessionState, AgentSnapshot as WireAgentSnapshot } from "@pk-nerdsaver-ai/pi-wire";
import { DEFAULT_RELAY_URL, ENVELOPE_HEADER_LENGTH, ROOM_ID_BYTES } from "@pk-nerdsaver-ai/pi-wire";
import type { ContextUsage } from "../extensibility/extensions/types";
import type { AgentSessionEvent } from "../session/agent-session";
import type { SessionEntry, SessionHeader } from "../session/session-entries";
export type { CollabPromptDetails, ParsedCollabLink, RelayControlMessage, RelayControlToGuest, RelayControlToHost, } from "@pk-nerdsaver-ai/pi-wire";
export { COLLAB_PROMPT_MESSAGE_TYPE, COLLAB_PROTO } from "@pk-nerdsaver-ai/pi-wire";
export { DEFAULT_RELAY_URL, ENVELOPE_HEADER_LENGTH, ROOM_ID_BYTES };
export type CollabParticipant = Participant;
export type AgentSnapshot = WireAgentSnapshot;
/** Debounced footer snapshot broadcast by the host. */
export type CollabSessionState = SessionState & {
    /**
     * Host model (full catalog object). Guests apply it to their replica
     * agent state so model display and context-window math are native.
     */
    model?: Model;
    /** Host status-line context numbers (guest system prompt/tools differ, so local estimates drift). */
    contextUsage?: ContextUsage;
};
/**
 * Encrypted payload frames (inside AES-GCM, JSON). The wire package pins the
 * JSON skeleton (`WireFrame`); host-side frames carry the rich session types
 * that serialize into those shapes.
 */
export type CollabFrame = Exclude<GuestFrame, {
    t: "prompt";
}> | {
    t: "prompt";
    text: string;
    images?: ImageContent[];
} | {
    t: "welcome";
    proto: number;
    header: SessionHeader;
    entries: SessionEntry[];
    state: CollabSessionState;
    agents: AgentSnapshot[];
    /** True when this peer joined through a read-only (view) link. */
    readOnly?: boolean;
} | {
    t: "entry";
    entry: SessionEntry;
} | {
    t: "event";
    event: AgentSessionEvent;
} | {
    t: "state";
    state: CollabSessionState;
}
/** Mirrored EventBus traffic (task subagent lifecycle/progress channels only). */
 | {
    t: "bus";
    channel: BusChannel;
    data: unknown;
}
/** Full agent-registry snapshot (debounced on registry change). */
 | {
    t: "agents";
    agents: AgentSnapshot[];
}
/** Targeted reply to fetch-transcript; `text` is decoded JSONL from `fromByte`, `newSize` the next offset base. */
 | {
    t: "transcript";
    reqId: number;
    text: string;
    newSize: number;
    error?: string;
} | {
    t: "bye";
    reason: string;
} | {
    t: "error";
    message: string;
};
export declare function packEnvelope(peerId: number, sealed: Uint8Array): Uint8Array;
export declare function unpackEnvelope(data: Uint8Array): {
    peerId: number;
    payload: Uint8Array;
} | null;
/** Rewrite the peerId in place without copying the payload. */
export declare function rewriteEnvelopePeer(data: Uint8Array, peerId: number): void;
export declare function generateRoomId(): string;
/**
 * Render the shareable link. Compact forms: the default relay collapses to
 * `<roomId>.<key>`, other wss relays drop the scheme (`host[:port]/r/…`);
 * only localhost ws:// links keep their full URL so parsing cannot
 * mis-infer wss.
 *
 * The room secret is dot-joined (`<roomId>.<key>`) rather than `#`-joined:
 * RFC 3986 forbids a raw `#` inside a fragment, so strict URL stacks (macOS
 * Foundation behind terminal click-to-open) percent-encode a second `#` to
 * `%23` and break the link. Parsers still accept the legacy `#` form and the
 * mangled `%23` form.
 *
 * Full links append the write token to the key
 * (`base64url(key ∥ writeToken)`); read-only (view) links carry the bare
 * 32-byte key, which is also the pre-token link format.
 */
export declare function formatCollabLink(relayUrl: string, roomId: string, key: Uint8Array, writeToken?: Uint8Array): string;
/**
 * Render the browser deep link: `http(s)://<relay-host>/#<collab-link>`. The
 * relay serves the web client at `/`, and the whole collab link (including the
 * room key) rides in the fragment, so it never appears in any HTTP request.
 * Terminals auto-link the https form, making it click-to-join.
 */
export declare function formatCollabWebLink(relayUrl: string, roomId: string, key: Uint8Array, writeToken?: Uint8Array): string;
export declare function parseCollabLink(link: string): ParsedCollabLink | {
    error: string;
};
