/**
 * `subscribe_sessions` request parsing and the per-subscription match rule.
 *
 * Parsed once at the wire boundary, so the stream downstream only ever holds a selector that is known to
 * be well formed. Every refusal names the field that was wrong and what to send instead.
 */
import type { RpcCommand } from "./rpc-types.ts";
import type { SessionStatusEntryView, SessionStatusRuntimeView } from "./session-status.ts";
import type { MirrorPending } from "./compact-mirror-pending.ts";
export interface SessionStatusSource {
    readonly sessionIds: () => readonly string[];
    readonly entryView: (sessionId: string) => SessionStatusEntryView | undefined;
    readonly view: (sessionId: string) => {
        readonly entry: SessionStatusEntryView;
        readonly runtime?: SessionStatusRuntimeView;
    } | undefined;
}
export interface SessionStatusDelivery {
    readonly enqueue: (connectionId: string, line: string) => boolean;
    readonly pendingQuestions: (sessionId: string) => number | undefined;
    readonly now?: () => Date;
}
export type StatusSubscription = {
    readonly id: string;
    readonly connectionId: string;
    readonly options: SubscriptionOptions;
    seq: number;
};
export type PendingStatusSubscription = StatusSubscription & {
    readonly lines: string[];
    readonly buffer?: MirrorPending;
};
export declare function matchingMirrors(subscriptions: Iterable<StatusSubscription>, sessionId: string, recordType: string, entryView: () => SessionStatusEntryView | undefined, dialogs?: boolean): StatusSubscription[];
export type SessionSelector = {
    readonly kind: "all";
} | {
    readonly kind: "ids";
    readonly ids: ReadonlySet<string>;
} | {
    readonly kind: "childrenOf";
    readonly parent: string;
};
export type MirrorSelection = {
    readonly kind: "none";
} | {
    readonly kind: "all";
} | {
    readonly kind: "types";
    readonly types: ReadonlySet<string>;
};
export interface SubscriptionOptions {
    /** Internal compact routing identity; set only for the streamed snapshot path. */
    readonly admissionId?: string;
    readonly selector: SessionSelector;
    readonly includeWorkers: boolean;
    readonly includeContext: boolean;
    readonly mirror: MirrorSelection;
    readonly effects: boolean;
    readonly dialogs?: boolean;
}
export interface SubscriptionRefusal {
    readonly reason: string;
    readonly action: string;
}
export declare function parseSubscription(request: Readonly<Pick<Extract<RpcCommand, {
    type: "subscribe_sessions";
}>, "sessions" | "mirror" | "include_workers" | "include_context" | "effects" | "dialogs">>): {
    readonly options: SubscriptionOptions;
} | {
    readonly refusal: SubscriptionRefusal;
};
export declare function subscriptionMatches(options: SubscriptionOptions, sessionId: string, entry: Pick<SessionStatusEntryView, "kind" | "durableSessionId" | "sessionPath" | "context" | "openContext">): boolean;
export declare function matchingStatusConnections(subscriptions: Iterable<StatusSubscription>, sessionId: string, entry: SessionStatusEntryView | undefined): ReadonlyMap<string, boolean>;
//# sourceMappingURL=session-status-subscriptions.d.ts.map