import type { HubClientRecord, HubCommandEnvelope, HubEventEnvelope, HubReplyEnvelope, SessionRecord as HubSessionRecord, ITelemetryService, JsonValue, SessionParticipant } from "@cline/shared"; import type { PendingPromptsRuntimeService, RuntimeHost, SessionConnectionRuntimeService, SessionUsageRuntimeService } from "../../../runtime/host/runtime-host"; import { type CoreSessionSnapshot } from "../../../session/session-snapshot"; import { type HubSessionState } from "../hub-session-records"; export type PendingApproval = { sessionId: string; resolve: (result: { approved: boolean; reason?: string; }) => void; }; export type PendingCapabilityRequest = { sessionId: string; targetClientId: string; capabilityName: string; onProgress?: (payload: Record) => void; resolve: (result: { ok: boolean; payload?: Record; error?: string; }) => void; }; /** * Shared mutable state and helpers passed to every command-handler module. * The transport class owns the maps; handlers get a stable read/write surface. */ export interface HubTransportContext { readonly clients: Map; readonly sessionState: Map; readonly pendingApprovals: Map; readonly pendingCapabilityRequests: Map; readonly suppressNextTerminalEventBySession: Map; readonly telemetry?: ITelemetryService; readonly sessionHost: RuntimeHost & Partial; publish(event: HubEventEnvelope): void; buildEvent(event: HubEventEnvelope["event"], payload?: Record, sessionId?: string): HubEventEnvelope; requestCapability(sessionId: string, capabilityName: string, payload: Record, targetClientId: string, onProgress?: (payload: Record) => void): Promise | undefined>; } type EnvelopeRef = Pick; export declare function okReply(envelope: EnvelopeRef, payload?: HubReplyEnvelope["payload"]): HubReplyEnvelope; export declare function errorReply(envelope: EnvelopeRef, code: string, message: string): HubReplyEnvelope; /** Returns the value when it's a plain object, or undefined otherwise. */ export declare function asPlainRecord(value: unknown): Record | undefined; /** * Pulls the session id from the envelope. Handlers accept either * `payload.sessionId` (top-level command argument) or `envelope.sessionId` * (envelope-level addressing). Returns "" when neither is present so handlers * can branch on truthiness. */ export declare function extractSessionId(envelope: HubCommandEnvelope): string; export declare function buildHubEvent(event: HubEventEnvelope["event"], payload?: Record, sessionId?: string): HubEventEnvelope; export declare function readHubSessionRecord(ctx: HubTransportContext, sessionId: string): Promise; export declare function readCoreSessionSnapshot(ctx: HubTransportContext, sessionId: string): Promise; export declare function ensureSessionState(ctx: HubTransportContext, sessionId: string, clientId: string, role: SessionParticipant["role"], options?: { interactive?: boolean; }): HubSessionState; export declare function ensureSessionParticipant(ctx: HubTransportContext, sessionId: string, clientId: string, role: SessionParticipant["role"], options?: { interactive?: boolean; }): HubSessionState; export {};