@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
61 lines • 3.19 kB
TypeScript
import type { CliRuntimeConfiguration } from "../../main.ts";
import type { SessionPathReservations as DaemonPathReservations } from "./host-reservations.ts";
import { type OpenRpcSession, type RpcSessionEntry, type RpcSessionLaunchProfile, type RpcSessionOpenOptions, type RpcSessionRow } from "./session-registry.ts";
import { SessionWorkerClient } from "./session-worker-client.ts";
import type { WorkerCapacity } from "./worker-capacity.ts";
type SessionWorkerCallbacks = ConstructorParameters<typeof SessionWorkerClient>[0];
export interface WorkerSessionRegistryOptions {
readonly configuration: CliRuntimeConfiguration;
readonly closeGraceMs: number;
readonly now: () => number;
/** Production builds the real worker; a caller may supply one to drive a lifecycle path deterministically. */
readonly createWorker?: (callbacks: SessionWorkerCallbacks) => SessionWorkerClient;
readonly pathReservations?: DaemonPathReservations;
/** A worker budget shared with the process's other worker pools; absent means this registry's own count (senpi#5413). */
readonly capacity?: WorkerCapacity;
}
/** Transport-side lifecycle owner. Caller paths are never inspected on this event loop. */
export declare class WorkerSessionRegistry {
readonly supportsCompact: () => boolean;
private readonly entries;
private readonly reservations;
private readonly claims;
private serial;
readonly closeGraceMs: number;
private readonly now;
private readonly options;
private readonly createWorker;
constructor(options: WorkerSessionRegistryOptions);
get size(): number;
reserveHandle(): string;
holderPids(observedStarts?: ReadonlyMap<number, number | undefined>): Promise<readonly number[]>;
openSession(profile: RpcSessionLaunchProfile, options?: RpcSessionOpenOptions): Promise<OpenRpcSession>;
peek(handle: string): RpcSessionEntry | undefined;
attachSession(handle: string): RpcSessionEntry;
getForCommand(handle: string, command: string): RpcSessionEntry;
beginClose(handle: string, onRole?: (finalizer: boolean) => void, options?: {
detach?: boolean;
}): RpcSessionEntry;
close(handle: string): Promise<void>;
closeMarked(handle: string): Promise<void>;
list(): RpcSessionRow[];
/** Only compare spellings already tied to a granted identity; do not inspect caller paths here. */
private knownReservationKey;
private attach;
/** Granted paths currently held by a handle; the per-worker budget is bounded by it. */
reservationCount(handle: string): number;
private reserve;
/**
* Releases the grants a worker's latest snapshot no longer claims.
*
* Only a fully open entry reports live writers. An entry still opening, closing or
* quarantined keeps every grant until its real exit, because a worker stuck in a
* syscall can still be writing a path it can no longer report.
*/
private reconcile;
/** The live view a full budget is reconciled against; absent while the entry cannot report one. */
private liveWorkerPaths;
private openResult;
}
export {};
//# sourceMappingURL=worker-session-registry.d.ts.map