@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
49 lines • 3.14 kB
TypeScript
export { KILL_GUARD_SHIM_MARKER, renderKillGuardShims } from "./shim-script.ts";
export interface KillGuardRuntime {
readonly dir: string;
readonly bashEnv: string;
/** The executable the shims run the judge with: the compiled binary, or the JS runtime for `entry`. */
readonly exec: string;
/** The judge entry script for an npm or source install; absent for the compiled binary's hidden subcommand. */
readonly entry: string | undefined;
readonly agentPid: number;
readonly protectedPids: readonly number[];
}
/**
* Writes the shim directory for `version` under `root` when it is missing or stale: staged in a temp directory and
* renamed into place, so a reader sees either no directory or a complete one. Returns the directory.
*/
export declare function installKillGuardShims(root: string, version: string, options?: {
readonly deadlineSeconds?: number;
}): string;
/**
* The variables that carry `runtime` into a process started with `base`: the shim directory first on PATH (once),
* BASH_ENV on the wrapper with the user's own BASH_ENV kept in `SENPI_KILL_GUARD_USER_BASH_ENV` (also when `base`
* already carries a kill-guard BASH_ENV from an outer agent), PROMPT_COMMAND on the hook that carries the same `kill`
* wrapper into interactive bash with the user's own PROMPT_COMMAND kept the same way in
* `SENPI_KILL_GUARD_USER_PROMPT_COMMAND` (an outer agent's hook is never captured as the user's: it would eval itself
* forever), the judge exports, and `SHLVL=1` when `base` has no usable level, so bash reads BASH_ENV whatever its
* stdin is.
*/
export declare function killGuardEnvironment(base: NodeJS.ProcessEnv, runtime: KillGuardRuntime): Record<string, string>;
export interface ActivateKillGuardRuntimeOptions {
/** Whoever keeps the runtime active (one per session); the runtime stays active until every holder releases. */
readonly holder: object;
readonly agentDir: string;
/** Read once per process: the protected set does not change while the agent runs. */
readonly protectedPids: () => readonly number[];
readonly platform?: NodeJS.Platform;
/** Told when the shared record for this agent dir is unreadable and this copy's own record is used instead. */
readonly warn?: (message: string) => void;
}
/** Installs (once per agent dir) and activates the runtime layer for this process; `undefined` on Windows. */
export declare function activateKillGuardRuntime(options: ActivateKillGuardRuntimeOptions): KillGuardRuntime | undefined;
/**
* Drops one holder (its session ended, or its user switched the guard off); the other holders keep theirs, and the
* runtime layer stops reaching new processes once none is left.
*/
export declare function releaseKillGuardRuntime(holder: object): void;
export declare function withKillGuardRuntime(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
/** The runtime layer's variables for a kernel session environment built on `base`; empty when none is active. */
export declare function activeKillGuardEnvironment(base: NodeJS.ProcessEnv): Record<string, string>;
//# sourceMappingURL=runtime.d.ts.map