@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
28 lines • 1.69 kB
TypeScript
import type { RpcSessionRegistry } from "./session-registry.ts";
export interface SweepVerdicts {
/** Open sessions idle past the window: a retained one parks, any other closes as `idle_evicted`. */
readonly idle: readonly string[];
/**
* Sessions no client holds whose transcript directory is gone. Nothing can reopen them by path
* and they can never persist again, so they close as `session_dir_removed` (senpi#2206).
*/
readonly orphaned: readonly string[];
}
/**
* How long a session must stand detached before the early-retirement branch may
* park it: a disconnect that overlaps a sweep is a client about to come back,
* and re-opening its runtime cold is the expensive path.
*/
export declare const DETACHED_RETIREMENT_GRACE_MS = 5000;
/**
* One occupancy sweep's decisions. "Idle" is the COMPLETE session-owned activity contract
* (`AgentSession.isSessionBusy`: agent run, bash, background terminal jobs and other published
* wake sources, compaction, barrier-held session work): a busy session restarts its idle clock
* instead, so work that outlives a turn is never killed. A quiet detached in-process worker
* with flushed history can reopen by path and need not keep its runtime for the idle window -
* once it has been detached for at least `DETACHED_RETIREMENT_GRACE_MS`, so a transient
* reconnect keeps the runtime it already owns.
* A non-finite window evicts nothing idle.
*/
export declare function selectSweepEvictions(registry: Pick<RpcSessionRegistry, "list" | "peek">, now: number, idleEvictionMs: number, hasPendingRequest?: (sessionId: string) => boolean): SweepVerdicts;
//# sourceMappingURL=session-sweep.d.ts.map