UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

58 lines • 2.84 kB
import type { BaselineBarrier } from "./socket-baseline-barrier.ts"; import type { ResyncReason } from "./socket-peer-recovery.ts"; export type QueueEntry = { line: string; bytes: number; key?: string; /** * The record with its cumulative snapshot fields blanked (delta kept). When a * later record with the same key supersedes this one, the entry is rewritten to * this line instead of being replaced, so a stalled reader never loses a delta. */ demotedLine?: string; /** Runs once with `true` when `line` reached the peer, with `false` when the actor dropped or replaced it unwritten. */ onWritten?: (written: boolean) => void; reply: boolean; /** Set on a record captured behind a pending cut: it reaches the peer only while the peer still holds its session. */ held?: () => boolean; /** A targeted reply's destination check, repeated immediately before its write (#4728). */ current?: () => boolean; }; /** A late peer's attach baseline in its FIFO position. */ export type AttachEntry = { readonly kind: "attach"; readonly barrier: BaselineBarrier; }; /** A shed's recovery in its FIFO position: the gap, then the cut's frames. A stale one reads a fresh cut when delivered. */ export type RecoveryEntry = { readonly kind: "recovery"; readonly reason: ResyncReason; readonly sessions: readonly string[]; barrier: BaselineBarrier; stale: boolean; }; export type QueueItem = QueueEntry | AttachEntry | RecoveryEntry; export declare const isBarrier: (item: QueueItem) => item is AttachEntry | RecoveryEntry; /** One socket's FIFO: records charged by their bytes, barriers weighing nothing. */ export declare class SocketEventQueue { private items; private charged; get bytes(): number; get length(): number; push(item: QueueItem): void; shift(): QueueItem | undefined; /** A record takes its place ahead of `before` while that is still queued, else the tail. */ insertBefore(before: QueueItem, entry: QueueEntry): void; /** * Lossless supersession of the queued record with `key`. The old behaviour replaced the queued line * outright, which threw away every delta a stalled reader had not yet received (a desktop client * assembles text from deltas). Keep the superseded record - demoted to its delta-only form when the * producer supplied one - and let only the newest record carry the snapshot. */ supersede(key: string): void; /** Keeps the items `keep` accepts; every other record is released (`onWritten(false)`) and every other barrier ended. */ retain(keep: (item: QueueItem) => boolean): void; /** Ends every barrier and empties the queue; the dropped records' callbacks never run. */ clear(): void; } //# sourceMappingURL=socket-event-queue.d.ts.map