import { type RawData, WebSocket } from "ws"; import type { EndpointBackgroundExchangeMode, EndpointExecutionSurface, RuntimeConversationRef, RuntimeEndpointCapability, RuntimeSessionConversationHistoryResponse, SessionNamingBlock, WorkspaceMetadata } from "../runtime-endpoint-client.js"; import type { BrokerLogger } from "./logger.js"; import type { NetworkPresence } from "./network-presence.js"; import type { RuntimeProcessingState, RuntimeWorkTargetRef } from "./runtime-processing-state-event-types.js"; import { type IpcCapabilities } from "./version-handshake.js"; export interface IPCServerHandlers { registerEndpoint(body: RegisterEndpointBody, ipcWs: WebSocket): Promise; heartbeatEndpoint(endpoint_id: string): Promise; unregisterEndpoint(endpoint_id: string): Promise; send(body: SendBody): Promise; sendRuntimeAssignmentReply(body: RuntimeAssignmentReplyBody): Promise; claimRuntimeAssignment(body: RuntimeAssignmentClaimBody): Promise; readRuntimeSessionConversationHistory(body: RuntimeSessionConversationHistoryBody): Promise; reportProcessingState(body: ProcessingStateBody): Promise; reattachEndpoint(endpoint_id: string, plugin_pid: number, ipcWs: WebSocket): Promise; listUndispatched(plugin_pid: number, endpoint_id?: string): Promise; readUndispatchedPresence(endpoint_id: string): Promise; dispatch(undispatched_id: string, target_endpoint_id: string): Promise; setTaskHint(body: TaskHintBody): Promise; selfSettleUndispatched(body: SelfSettleUndispatchedBody): Promise; awaitStagedDelivery(body: AwaitStagedDeliveryBody): Promise; } export interface SelfSettleUndispatchedBody { endpoint_id: string; plugin_pid: number; undispatched_id: string; } export interface SelfSettleUndispatchedResponse { settled: true; remove_reason: "handled_no_reply"; } export interface AwaitStagedDeliveryBody { endpoint_id: string; plugin_pid: number; timeout_ms: number; mark_attempt?: boolean; } export interface StagedDeliveryItem { endpoint_id: string; undispatched_id: string; assignment_id: string; source_message_id: string; message: { from: string; content: string; contentType: string; sourceMessageId: string; }; staged_at: string; } export interface AwaitStagedDeliveryResponse { items: StagedDeliveryItem[]; } export interface ReattachResponse { restored: true; reconnecting_buffer_count: number; } export type UndispatchedListResponse = import("./undispatched-inbox.js").UndispatchedMessage[]; export interface UndispatchedPresenceResponse { bound_continuation_count: number; } export interface RegisterEndpointBody { agent_id: string; plugin_pid: number; kind: string; client_kind?: string; client_version?: string; started_at?: string; workspace?: string | WorkspaceMetadata; tracking_ref?: string; session_name?: string; task_hint?: string; runtime_session_id?: string; runtime_capabilities?: RuntimeEndpointCapability[]; execution_surface?: EndpointExecutionSurface; background_exchange_mode?: EndpointBackgroundExchangeMode; spawn_token?: string; } export interface TaskHintBody { endpoint_id: string; plugin_pid: number; task_hint: string; } export interface RegisterEndpointResponse { endpoint_id: string; endpoint_owner_token?: string; session_naming?: SessionNamingBlock; } export interface SendBody { endpoint_id: string; to: string; content: string; contentType?: string; metadata?: Record; require_live?: boolean; } export interface SendResponse { messageId: string; status: string; } export interface RuntimeAssignmentReplyBody { endpoint_id: string; plugin_pid: number; endpoint_owner_token?: string; source_message_id: string; assignment_id: string; reply_request_id: string; content: string; contentType?: string; metadata?: Record; } export interface RuntimeAssignmentClaimBody { endpoint_id: string; plugin_pid: number; endpoint_owner_token?: string; undispatched_id: string; recover_existing?: boolean; assignment_mode?: "staged"; } export interface RuntimeSessionConversationHistoryBody { endpoint_id: string; plugin_pid: number; endpoint_owner_token?: string; conversation_ref: RuntimeConversationRef; limit?: number; before?: string; after?: string; } export interface RuntimeAssignmentClaimResponse { assignment: RuntimeAssignmentContext; message: { from: string; content: string; contentType: string; metadata: Record; sourceMessageId?: string; }; } export interface ProcessingStateBody { endpoint_id: string; plugin_pid: number; endpoint_owner_token?: string; source_message_id: string; assignment_id: string; state_event_id: string; state_sequence: number; state: RuntimeProcessingState; occurred_at?: number; undispatched_id?: string; retryable?: boolean; reason_code?: string; detail?: string; reply_request_id?: string; outbound_message_id?: string; } export interface RuntimeAssignmentContext { undispatchedId: string; sourceMessageId: string; assignmentId: string; targetRef: RuntimeWorkTargetRef; deliveryIntent: "external_handoff"; replyCorrelationId?: string; originalTraceId?: string; } export type BrokerHttpErrorExtra = Record; export declare class BrokerHttpError extends Error { readonly status: number; readonly code: string; readonly extra?: BrokerHttpErrorExtra; constructor(status: number, code: string, message: string, extra?: BrokerHttpErrorExtra); } export interface IPCServerOptions { bearerToken: string; handlers: IPCServerHandlers; logger: BrokerLogger; onChannelOpened?: (plugin_pid: number, ws: WebSocket, clientCapabilities: IpcCapabilities) => void; onChannelClosed?: (plugin_pid: number, ws: WebSocket) => void; onPushAck?: (plugin_pid: number, ws: WebSocket, push_id: string) => void; getNetworkPresence: () => NetworkPresence; } export interface RunningIPCServer { ipcUrl: string; port: number; close(): Promise; } export declare function startIPCServer(opts: IPCServerOptions): Promise; export declare function pushToPlugin(ws: WebSocket, event: PushEvent): boolean; export type PushEvent = { event: "message_received"; push_id?: string; from: string; content: string; contentType: string; metadata?: Record; sourceMessageId?: string; runtimeAssignment?: RuntimeAssignmentContext; } | { event: "ping"; push_id?: string; ts: string; } | { event: "presence_changed"; push_id?: string; presence: NetworkPresence; reason?: string; }; export declare function parsePluginFrame(data: RawData): unknown; //# sourceMappingURL=ipc-server.d.ts.map