UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

54 lines • 3.09 kB
/** * The Windows containment handle for one tool child generation (senpi#3566, plan todo 4): a Job Object the server * creates and keeps, so the child's process tree can be terminated even after the child itself is gone. * * The job is created with `KILL_ON_JOB_CLOSE | BREAKAWAY_OK`: closing the server's handle ends every member, and a * launch that explicitly asked to be detached can leave the job with `CREATE_BREAKAWAY_FROM_JOB`. Membership evidence * is creation-time (`command_started`); the process-id listing here only confirms, never refutes. kernel32 is reached * through `bun:ffi`, the same boundary `core/process-footprint.ts` uses; a host without it refuses `child` at startup. */ export declare const JOB_OBJECT_LIMIT_BREAKAWAY_OK = 2048; export declare const JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE = 8192; export declare const JOB_OBJECT_EXTENDED_LIMIT_INFORMATION_CLASS = 9; export declare const JOB_OBJECT_BASIC_PROCESS_ID_LIST_CLASS = 3; /** `JOBOBJECT_EXTENDED_LIMIT_INFORMATION` on a 64-bit Windows: 64-byte basic limits, 48-byte IO counters, 4 sizes. */ export declare const EXTENDED_LIMIT_INFORMATION_BYTES = 144; /** `BasicLimitInformation.LimitFlags`: after two LARGE_INTEGER time limits. */ export declare const LIMIT_FLAGS_OFFSET = 16; export interface Kernel32Job { CreateJobObjectW(attributes: null, name: null): unknown; SetInformationJobObject(job: unknown, infoClass: number, info: Uint8Array, length: number): number; QueryInformationJobObject(job: unknown, infoClass: number, info: Uint8Array, length: number, returned: null): number; OpenProcess(access: number, inherit: number, pid: number): unknown; AssignProcessToJobObject(job: unknown, process: unknown): number; IsProcessInJob(process: unknown, job: unknown, result: Uint8Array): number; TerminateJobObject(job: unknown, exitCode: number): number; CloseHandle(handle: unknown): number; GetLastError(): number; GetCurrentProcess(): unknown; } export declare class WindowsJobError extends Error { readonly code = "tool_child_job_assign_failed"; readonly win32Error: number; constructor(step: string, win32Error: number); } export declare function extendedLimitInformation(): Uint8Array; export declare class WindowsJob { private closed; private readonly kernel; private readonly handle; private constructor(); static create(kernel: Kernel32Job): WindowsJob; assign(pid: number): void; /** Confirmation only: a running pid listed here is a member; absence never proves a creation-time member left. */ memberPids(): number[]; terminate(exitCode?: number): void; close(): void; } export declare function loadKernel32Job(): Kernel32Job | undefined; /** * Whether this process runs inside any Job Object (`IsProcessInJob(GetCurrentProcess(), NULL)`). Off Windows, or * without bun:ffi, it is false: there is no job to be in. The answer for this host's own kernel is computed once. */ export declare function currentProcessInJob(kernel?: Kernel32Job): boolean; //# sourceMappingURL=windows-job.d.ts.map