@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
60 lines • 3.25 kB
TypeScript
/**
* The lifecycle supervisor's policy half: which cold-start mode and idle-exit window apply
* (`resolveHostPolicy`, environment over settings.json over the defaults), and the pure decision
* core that turns the current activity snapshot into active / idle / exit (`IdleExitDecider`).
*
* Nothing here touches a socket, a process or the filesystem; `host-lifecycle.ts` owns all of that
* and re-exports these names so every existing importer keeps resolving them at their original home.
*/
export type HostColdStart = "transient" | "persistent";
/** Environment override for the cold-start policy: `transient` or `persistent`. */
export declare const HOST_COLD_START_ENV = "SENPI_RPC_HOST_COLD_START";
/** Environment override for the idle-exit window in milliseconds. */
export declare const HOST_IDLE_EXIT_MS_ENV = "SENPI_RPC_HOST_IDLE_EXIT_MS";
/** Default idle-exit window: 15 minutes of continuous no-connection, no-turn idle. */
export declare const DEFAULT_HOST_IDLE_EXIT_MS: number;
/** Soft handoff deadline: rescan and report, never interrupt turns or in-flight requests. */
export declare const HANDOFF_GRACE_MS_ENV = "SENPI_RPC_HANDOFF_GRACE_MS";
export declare const DEFAULT_HANDOFF_GRACE_MS: number;
/** The policy fields ensureHost() records in rpc-host-daemon/settings.json. */
export interface HostLifecyclePolicyInput {
readonly coldStart?: HostColdStart;
readonly idleExitMs?: number;
}
export interface HostLifecyclePolicy {
readonly coldStart: HostColdStart;
readonly idleExitMs: number;
}
export declare function parseColdStart(value: string | undefined): HostColdStart | undefined;
export declare function parseIdleExitMs(value: string | undefined): number | undefined;
/**
* Resolves the effective host policy. Precedence: environment overrides beat
* settings.json, which beats the documented defaults (transient, 15 minutes).
* Invalid values at either source fall through to the next source.
*/
export declare function resolveHostPolicy(settings: unknown, env: Readonly<Record<string, string | undefined>>): HostLifecyclePolicy;
export interface HostActivity {
readonly connections: number;
readonly activeTurns: number;
}
export type IdleExitDecision = "active" | "idle" | "exit";
/**
* Pure idle-window decision core. `update()` must be called with the CURRENT
* activity state; the window only counts continuously idle time and any
* activity resets it, so a busy host can never cross the threshold.
*
* `firstClientWithinMs` is the launcher's decision budget on a coordinated start (senpi#6001): until the
* first client attaches, or that budget has passed, the window has not begun, so a host whose own startup
* outlasts its idle window cannot exit before the ensure that started it has probed it.
*/
export declare class IdleExitDecider {
private idleSince;
private firstClientBy;
private readonly now;
readonly idleExitMs: number;
constructor(idleExitMs: number, now?: () => number, firstClientWithinMs?: number);
/** A client attached: the window starts over, even while it holds nothing yet (oh-my-openagent#14272). */
restart(): void;
update(activity: HostActivity): IdleExitDecision;
}
//# sourceMappingURL=host-lifecycle-policy.d.ts.map