@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
44 lines • 2.11 kB
TypeScript
/**
* Environment variable every exec/spawn child of an instance with a scope registry (a `stateDir`) carries; the sweep
* finds members by it. An instance without a registry (senpi's own tool path) adds no variable.
*/
export declare const SCOPE_ENV = "SENPI_MACHINE_SCOPE";
/** Set on the runtime's own processes, which a sweep never signals. */
export declare const RUNTIME_ENV = "OMO_MACHINE_RUNTIME";
/** HUP, then TERM, then KILL, each followed by its wait (herdr sweep ladder). */
export declare const SWEEP_LADDER: readonly {
readonly signal: NodeJS.Signals;
readonly waitMs: number;
}[];
export declare function newScopeToken(): string;
/**
* Scope tokens: the token file is written under `<stateDir>/machine/scopes/` before the child spawns, so a crash
* between spawn and bookkeeping still leaves a record; `sweep` ends every member of a token.
*/
export declare class ScopeRegistry {
private readonly dir;
/** token -> process-group leader -> the leader's start time read when it was attached. */
private readonly groups;
private readonly killTree;
private readonly startTimeOf;
constructor(stateDir: string, killTree: (pid: number) => void, options?: {
readonly startTimeOf?: (pid: number) => Promise<string | undefined>;
});
tokenPath(token: string): string;
record(token: string, meta: {
principal: string;
command: string;
}): Promise<void>;
attach(token: string, pid: number): void;
/** Drop the token file once its exec settled; the group stays sweepable by token. */
release(token: string): Promise<void>;
/**
* Whether the live group `pid` is still the one this registry started. A live process with the leader's pid must
* have the start time recorded at attach. A gone leader with a live group is ours: POSIX does not reuse a process
* group ID while the group exists, so the pid cannot have been handed to a new group leader meanwhile.
*/
private sameGroup;
private targets;
sweep(tokenList: readonly string[]): Promise<void>;
}
//# sourceMappingURL=scopes.d.ts.map