@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
52 lines • 2.52 kB
TypeScript
/**
* The session activity contract every occupancy decision shares.
*
* "Busy" means work the session OWNS that must outlive an idle-eviction
* decision - not merely a streaming turn. There are exactly two registration
* points for a new activity source:
*
* - in-session work reports a field on `SessionActivitySnapshot` (agent run,
* bash, compaction, the session-work barrier);
* - work owned by an extension publishes a `wake_source_state` event with a
* non-zero `activeCount` (background terminal jobs, terminal monitors,
* loop-guard holds), which `WakeSourceTracker` folds into the same predicate.
*
* Callers (the shared RPC host's occupancy sweep, and anything else deciding
* whether a session may be torn down) MUST consult `isSessionBusySnapshot()` /
* `AgentSession.isSessionBusy` instead of testing individual flags, so a source
* added later cannot be silently missed by one call site.
*/
/** Live counts of extension-published wake sources, keyed by source name. */
export declare class WakeSourceTracker {
private readonly counts;
/**
* Folds one `wake_source_state` payload in. Unknown shapes are ignored: a
* malformed publisher must never flip a session to "idle" by accident.
*/
observe(data: unknown): void;
/** Whether any published source currently reports live work. */
get hasActive(): boolean;
/** Sources reporting live work, for diagnostics. */
get activeSources(): readonly string[];
/** Live obligation counts; publishers without a kind remain background work. */
get activeCounts(): {
readonly children: number;
readonly background: number;
};
}
/** In-session activity signals. Every field means "work that must not be evicted". */
export interface SessionActivitySnapshot {
/** An agent run or post-run continuation is active. */
readonly isStreaming: boolean;
/** A bash command owned by this session is running. */
readonly isBashRunning: boolean;
/** Compaction or branch summarization is running. */
readonly isCompacting: boolean;
/** The session-work barrier holds deferred work (queued continuations, rebinds). */
readonly hasSessionWork: boolean;
/** An extension-published wake source reports live work. */
readonly hasActiveWakeSource: boolean;
}
/** The complete session-owned activity predicate. */
export declare function isSessionBusySnapshot(snapshot: SessionActivitySnapshot): boolean;
//# sourceMappingURL=session-activity.d.ts.map