import { type JsonValue } from "../state/json.js"; import { type ClientEvent, type ClientHello, type ClientOperation, type ClientResponse } from "./protocol.js"; import type { ResolvedResourceManagerInitialization, ResolvedSettingsChange, ResolvedWorkflowLaunch } from "./resolver.js"; import type { WorkflowRunView } from "./view.js"; /** Bounded reason code and safe message for one failed subscription. */ export type SubscriptionFailure = { reasonCode: "connection_lost" | "reconnect_exhausted" | "projection_failed"; message: string; }; export declare class WorkflowClientVersionError extends Error { constructor(message: string); } export type WorkflowClientOptions = { clientId?: string; databasePath?: string; serverEntryPath?: string; env?: Record; }; export declare class WorkflowClient { readonly clientId: string; readonly databasePath: string; readonly endpoint: string; private readonly serverEntryPath; private readonly env; private socket; private connectTask; private hello; private closed; private reconnectTimer; private reconnectAttempts; /** Set only after a connection holds every subscription it asked to restore. */ private subscriptionsRestored; private readonly pending; private readonly subscriptions; constructor(options?: WorkflowClientOptions); get connectionId(): string | undefined; get packageVersion(): string | undefined; connect(): Promise; request(options: { operation: ClientOperation; requestId?: string; idempotencyKey?: string; runId?: string; expectedRevision?: number; payload?: JsonValue; signal?: AbortSignal; }): Promise; requestDurable(options: { operation: ClientOperation; requestId?: string; idempotencyKey: string; runId?: string; expectedRevision?: number; payload?: JsonValue; signal?: AbortSignal; }): Promise; getRun(runId: string): Promise; watchRuns(listener: (event: ClientEvent) => void, options?: { subscriptionId?: string; limit?: number; }): Promise<() => Promise>; watchRun(runId: string, listener: (event: ClientEvent) => void, options?: { subscriptionId?: string; revision?: number; }): Promise<() => Promise>; watchSession(sessionId: string, listener: (event: ClientEvent) => void, options?: { subscriptionId?: string; coordinator?: boolean; nodeCursor?: number; }): Promise<() => Promise>; /** * Move the node window of the active session subscription. `null` returns to * the window that follows the node the widget shows as working. The stored * subscription keeps the window, so a reconnect restores it. */ setSessionNodeWindow(sessionId: string, nodeCursor: number | null): Promise; ensureAvailable(): Promise; ensureRunning(): Promise; readContent(runId: string, contentPath: string): Promise<{ mediaType: string; content: Buffer; }>; hydrateContent(runId: string, value: JsonValue): Promise; private hydrateContentValue; resolveWorkflow(options: { cwd: string; workflowRef: string; timeoutMs?: number; }): Promise; resolveResourceManagerInitialization(options: { cwd: string; resourceManagerName: string; spec: JsonValue; timeoutMs?: number; }): Promise; resolveSettingsChange(options: { cwd: string; workflowRef: string; definitionDigest: string; mountPath: string; current: JsonValue; patch: JsonValue; actorId: string; timeoutMs?: number; }): Promise; close(): Promise; private subscribe; private requestConnected; private send; private openConnection; private deliverSubscriptionEvent; private restoreSubscriptions; private resetConnection; /** * Report one bounded failure to every subscriber. The extension keeps its last * view for display and loses command authority until a fresh snapshot arrives. */ private reportSubscriptionFailure; private scheduleReconnect; private runResolver; private startDetached; }