import type { ProviderId } from "@earendil-works/pi-ai";
import type { HandSessionAdvertisement, HookModelRequest, HookModelRequestReply } from "../egress/wire.ts";
import type { Extension } from "../extensions/types.ts";
export type HookProviders = readonly ProviderId[] | "*";
export interface HandHookAccess {
    readonly requestHooks: HookProviders;
    readonly streamHooks: HookProviders;
}
/** The request and stream hooks of the extensions `only` accepts (the ones that run on this hand). */
export declare function handHookAccess(extensions: readonly Extension[], only: (extensionPath: string) => boolean): HandHookAccess;
export interface AdvertHashParts {
    readonly extensionSetHash: string;
    readonly cwd: string;
    /** The project-local hook set, as hook identities; its order does not matter. */
    readonly projectHooks: readonly string[];
}
/** `H(extension set hash, cwd, project-local hook set)` (4.9): `sha256:` + hex SHA-256 of their canonical JSON. */
export declare function computeAdvertHash(parts: AdvertHashParts): string;
/** A bound session's advertisement, before a connection stamps it. */
export type HandHookSession = Omit<HandSessionAdvertisement, "t" | "connectionId">;
/** A hook request for a session not advertised on the connection it names; nothing ran. */
export declare class HookNotAdvertisedError extends Error {
    readonly name = "HookNotAdvertisedError";
}
export interface HandHookLinkOptions {
    send(message: HandSessionAdvertisement | HookModelRequestReply): Promise<void>;
    serve(request: HookModelRequest): Promise<HookModelRequestReply>;
}
export interface HandHookLink {
    /** A new connection: every bound session's advertisement goes out first, in order, under `connectionId`. */
    connect(connectionId: string, sessions: readonly HandHookSession[]): Promise<void>;
    /** A session bound (or re-hashed) mid-connection: its advertisement goes out before anything else for it. */
    advertise(session: HandHookSession): Promise<void>;
    /**
     * One `hook.model_request` received on `connectionId`; its reply follows that session's advertisement. Its hooks run
     * outside the outgoing order, so a slow hook holds back no other request's reply and no advertisement.
     */
    receive(connectionId: string, request: HookModelRequest): Promise<void>;
}
export declare function createHandHookLink(options: HandHookLinkOptions): HandHookLink;
//# sourceMappingURL=hook-advertise.d.ts.map