@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
78 lines (77 loc) • 2.62 kB
TypeScript
import type { RollingWorkerSupervisorOptions, RollingWorkerSupervisorSnapshot, TransferableProxySocket } from "../types/index.js";
/**
* Owns worker generations while the caller owns the public listening socket.
* Sockets are transferred once to the active worker, so response bytes never
* traverse a supervisor-side proxy hop.
*/
export declare class RollingWorkerSupervisor {
private readonly options;
private generation;
private active;
private candidate;
private readonly draining;
private readonly queuedSockets;
private flushingSockets;
private consecutiveOfferTimeouts;
private lastStallReplacementAt;
private transferStateTimer;
private replacement;
private rejectedSockets;
private failedTransfers;
private readonly recentEvents;
private lastFailure;
private closed;
private shutdownPromise;
private readonly shutdownWaiters;
constructor(options: RollingWorkerSupervisorOptions);
snapshot(): RollingWorkerSupervisorSnapshot;
start(expectedVersion: string): Promise<RollingWorkerSupervisorSnapshot>;
replace(expectedVersion: string): Promise<RollingWorkerSupervisorSnapshot>;
/**
* Admit a paused socket to the active generation or the bounded
* readiness queue.
*/
acceptSocket(socket: TransferableProxySocket): void;
/**
* Retain a socket only within the queue capacity and deadline, recording
* classified rejection.
*/
private queueSocket;
close(): Promise<void>;
private closeWorkers;
private requestWorkerShutdown;
private forceTerminateWorkers;
private notifyShutdownWaiters;
/**
* Validate candidate readiness and activation while preserving an
* independent listener for actual exit.
*/
private spawnCandidate;
private flushQueuedSockets;
private transferSocket;
private maybeDrainWorker;
/**
* Cancel the affected handoff and request bounded replacement without
* killing unrelated streams.
*/
private handleTransferFailure;
/**
* Record a classified admission rejection before releasing the
* parent-owned socket.
*/
private rejectSocket;
private describeTransferError;
private extractLifecycleFailureDetails;
/**
* Retain the latest failure and its observed process evidence in the
* incident journal.
*/
private recordFailure;
/**
* Publish an independent incident record and retain only a bounded
* recent summary.
*/
private recordEvent;
private scheduleTransferState;
private publishState;
}