/**
 * Main-thread runtime client — sits opposite the worker, forwards
 * `AgentCommand`s, fields host tool requests + model-stream requests from the
 * worker, and exposes a small imperative API to the host. Owns the abort
 * generation that detaches late client/model-stream results after a cancel.
 */
import { type AgentConfiguration, type AgentEventListener, type AgentSubmitOptions } from '../../contracts/agent-api.js';
import { type AgentSnapshot } from '../../contracts/agent-snapshot.js';
import { type HostToolExecutor, type ToolRegistry } from '../../contracts/host-tool-api.js';
import { type ShortcutXLModelStreamEvent } from '../../contracts/model-stream.js';
import { type ShortcutXLAiModelStreamRequest, type WorkerMessage } from '../../contracts/wire.js';
/** Main-thread side of the structured-clone-safe message channel. */
export interface ShortcutXLWorkerPort {
    postMessage(message: WorkerMessage): void;
    addEventListener(type: 'message', listener: (event: {
        data: unknown;
    }) => void): void;
    removeEventListener(type: 'message', listener: (event: {
        data: unknown;
    }) => void): void;
    start?(): void;
}
/** Imperative API the host calls to drive the runtime running inside the worker. */
export interface EmbeddedAgentPortClient {
    abort(): Promise<void>;
    configure(configuration: AgentConfiguration): Promise<void>;
    dispose(): void;
    getModelStreamBridgeMetrics(): ShortcutXLModelStreamBridgeMetrics;
    getSnapshot(): AgentSnapshot | null;
    submit(prompt: string, submitOptions?: AgentSubmitOptions, options?: {
        awaitAck?: boolean;
    }): Promise<void>;
    subscribe(listener: AgentEventListener): () => void;
}
/** Host-side handler for model-stream requests forwarded from the worker. */
export interface ShortcutXLModelStreamRequestHandler {
    handleRequest(request: ShortcutXLAiModelStreamRequest, emitEvent: (event: ShortcutXLModelStreamEvent) => void, signal: AbortSignal): Promise<void>;
}
/** Trace-event tags used by `onModelStreamTrace`. */
export declare const ShortcutXLModelStreamTraceKind: {
    readonly HostToolRequestReceived: "hostToolRequestReceived";
    readonly HostToolResultPosted: "hostToolResultPosted";
    readonly HostToolResultSuppressed: "hostToolResultSuppressed";
    readonly CancelReceived: "cancelReceived";
    readonly EventSent: "eventSent";
    readonly HandlerCompleted: "handlerCompleted";
    readonly HandlerFailed: "handlerFailed";
    readonly RequestReceived: "requestReceived";
};
export type ShortcutXLModelStreamTraceKind = (typeof ShortcutXLModelStreamTraceKind)[keyof typeof ShortcutXLModelStreamTraceKind];
/** One observability entry emitted while bridging requests across the port. */
export interface ShortcutXLModelStreamTraceEntry {
    readonly eventKind?: ShortcutXLModelStreamEvent['kind'];
    readonly kind: ShortcutXLModelStreamTraceKind;
    readonly message?: string;
    readonly requestId: string;
    readonly timestamp: number;
}
/** Aggregate counters for host/worker model stream pressure and coalescing. */
export interface ShortcutXLModelStreamBridgeMetrics {
    readonly activeModelStreams: number;
    readonly coalescedModelStreamDeltaCount: number;
    readonly coalescingWindowMs: number;
    readonly forwardedModelStreamDeltaCount: number;
    readonly forwardedModelStreamEventCount: number;
    readonly generatedModelStreamErrorCount: number;
    readonly maxActiveModelStreams: number;
    readonly modelStreamCancelCount: number;
    readonly modelStreamDeltaFlushCount: number;
    readonly modelStreamRequestCount: number;
    readonly rawModelStreamDeltaCount: number;
    readonly rawModelStreamEventCount: number;
}
/** Wiring for `createEmbeddedAgentPortClient`. */
export interface CreateEmbeddedAgentPortClientOptions {
    hostToolExecutor: HostToolExecutor;
    modelStreamRequestHandler?: ShortcutXLModelStreamRequestHandler;
    onModelStreamTrace?: (entry: ShortcutXLModelStreamTraceEntry) => void;
    registry: ToolRegistry;
}
/** Build a main-thread client bound to one worker port. */
export declare function createEmbeddedAgentPortClient(port: ShortcutXLWorkerPort, options: CreateEmbeddedAgentPortClientOptions): EmbeddedAgentPortClient;
//# sourceMappingURL=host-client.d.ts.map