@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
67 lines • 3.35 kB
TypeScript
import type { LegacyViewCursor } from "./legacy-view-cursor.ts";
import { type ResyncSnapshot, type ShedMode } from "./socket-peer-shed.ts";
export { SocketEventQueueOverflowError, SocketEventQueueStallError } from "./socket-event-queue-errors.ts";
export type { ResyncSnapshot, ShedMode } from "./socket-peer-shed.ts";
type SocketSink = {
writeRaw(chunk: string): void;
waitForBackpressure(): Promise<void>;
};
export declare const DEFAULT_STALL_MS = 30000;
/** Independent FIFO actor for one socket. It never shares a drain promise with another sink. */
export declare class SocketEventSinkActor {
private readonly queue;
private draining?;
private closed;
private failure?;
private recovery?;
private recoveryEnabled;
private snapshot?;
private readonly shed;
private attempt?;
/** The attach frame in flight, charged against the budget until the sink accepted it. */
private frameBytes;
private readonly stopped;
private readonly sink;
private readonly onFailure;
private readonly maxQueueBytes;
private readonly stallPeer;
constructor(sink: SocketSink, onFailure: (cause: unknown) => void, maxQueueBytes?: number, stallMs?: number, shedMode?: ShedMode);
enableRecovery(snapshot: ResyncSnapshot): void;
disableRecovery(): void;
/**
* A newly attached session's baseline, frozen by the caller: it takes this FIFO position, so every record
* enqueued after it follows it, and a stale attempt (`live` false) writes nothing. Never holds credit. A view
* with no frame installs nothing, so the next record goes in flight exactly as before the attach; while a
* recovery drops records the view is dropped too, covered by the cut read at the delivery.
*/
installBaseline(cursor: LegacyViewCursor, live: () => boolean): void;
/** `held`, for a record that reaches this peer because it holds a session: whether it still does. */
enqueue(line: string, key?: string, onWritten?: (written: boolean) => void, demotedLine?: string, reply?: boolean, held?: () => boolean, current?: () => boolean): void;
flush(): Promise<void>;
/**
* Resolve once every record enqueued so far has been ACCEPTED into this queue.
*
* `enqueue` admits a record synchronously, or fails closed on byte overflow, so
* acceptance is already settled by the time a caller asks - and it never waits for
* the peer to drain. This is the session worker's credit point (#1774); use
* `flush()` where the queue must actually reach the transport (close, shutdown).
*/
waitForAcceptance(): Promise<void>;
close(): void;
private fits;
private admitReply;
/** A plain peer's overflow: the notice, then fail closed so the client resyncs. */
private failOverflow;
/** Ends every queued baseline and the one in flight, then empties the queue. */
private dropQueue;
/** The stall deadline's shed: one cut per pending recovery, never a re-cut while the peer stays idle. */
private cutOnce;
private cut;
private write;
/** An attach frame is charged like the replay line it replaces: one that does not fit sheds, or overflows a plain peer. */
private writeFrame;
private deliver;
private stream;
private drain;
}
//# sourceMappingURL=socket-event-fanout.d.ts.map