import { Static, TSchema, Type } from "typebox"; //#region src/schemas/protocol.d.ts export declare const DOOM_PROTOCOL_ERROR_CODE: { readonly aborted: 'ABORTED'; readonly invalidMessage: 'INVALID_MESSAGE'; readonly providerError: 'PROVIDER_ERROR'; readonly timeout: 'TIMEOUT'; }; export interface EventBusLike { emit(event: string, data: unknown): void; on(event: string, handler: (data: unknown) => void): () => void; } export declare const ProtocolErrorSchema: Type.TObject<{ code: Type.TString; message: Type.TString; retryable: Type.TOptional; }>; export type ProtocolErrorPayload = Static; export declare class DoomProtocolError extends Error { readonly code: string; readonly retryable: boolean; constructor(payload: ProtocolErrorPayload); } export declare class DoomProtocolValidationError extends DoomProtocolError { constructor(channel: string, details: string); } export interface ProtocolIdentity { source: string; sessionId: string; } export interface NotificationDefinition { channel: string; kind: string; payload: TPayload; } export interface RequestReplyDefinition { requestChannel: string; responseChannel: string; errorChannel: string; requestKind: string; responseKind: string; request: TRequest; response: TResponse; } export interface RequestOptions { signal?: AbortSignal; timeoutMs?: number; /** Ignore correlated replies from any source except this exact provider. */ expectedSource?: string; } export interface ProtocolRuntimeOptions extends ProtocolIdentity { bus: EventBusLike; defaultTimeoutMs?: number; createMessageId?: () => string; duplicateWindow?: number; } export interface ProtocolRuntime { notify(definition: NotificationDefinition, payload: Static): void; onNotification(definition: NotificationDefinition, handler: (payload: Static, identity: ProtocolIdentity) => void | Promise): () => void; request(definition: RequestReplyDefinition, payload: Static, options?: RequestOptions): Promise>; provide(definition: RequestReplyDefinition, handler: (payload: Static, identity: ProtocolIdentity) => Static | Promise>): () => void; } export declare function defineNotification(definition: { channel: `doom:${string}:${string}:v1:${string}`; kind: string; payload: TPayload; }): NotificationDefinition; export declare function defineRequestReply(definition: { channels: { request: `doom:${string}:${string}:v1:${string}`; response: `doom:${string}:${string}:v1:${string}`; error: `doom:${string}:${string}:v1:${string}`; }; kinds: { request: string; response: string; }; request: TRequest; response: TResponse; }): RequestReplyDefinition; export declare const defineJob: typeof defineRequestReply; export declare function createProtocolRuntime(options: ProtocolRuntimeOptions): ProtocolRuntime; //#endregion //# sourceMappingURL=protocol.d.cts.map