UNPKG

@code-yeongyu/senpi

Version:

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

33 lines • 2.47 kB
/** * Process-wide replacement of `node:child_process` for extension code (senpi#3566, plan todo 4). * * The Bun extension importer resolves `node:child_process` / `child_process` - in an extension and in every module of * its graph, transitive dependencies included - to the virtual id below, which serves whatever module this process * installed. The server installs nothing, so extensions there get the real module, exactly as before. A tool child * installs the gated module before any extension loads, so a named import there passes the execution barrier too. * Bun forbids overriding the builtin's own name, which is why the redirect goes to a separate id. */ import realChildProcess from "node:child_process"; export declare const GATED_CHILD_PROCESS_ID = "senpi-tool-child:child_process"; export declare const CHILD_PROCESS_REDIRECTS: Readonly<Record<string, string>>; export declare function installChildProcessModule(module: typeof realChildProcess): void; /** The launch functions the gated module replaces; every other export is the builtin's own, untouched. */ export declare const CHILD_PROCESS_LAUNCH_FUNCTIONS: readonly ["spawn", "spawnSync", "exec", "execSync", "execFile", "execFileSync", "fork"]; /** * The module object the virtual id serves. Bun snapshots an object module's named exports when it is first loaded, so * each launch function forwards to the module installed at call time - and so does its `util.promisify.custom`, which * `promisify(exec)` relies on for `{ stdout, stderr }`. Every other export (`ChildProcess` and the rest) is the * builtin's own object, so the export key set, classes and identities are those of `node:child_process`. */ export declare function childProcessVirtualModule(): Readonly<Record<string, unknown>>; export declare const GATED_WORKER_THREADS_ID = "senpi-tool-child:worker_threads"; export declare const WORKER_THREADS_REDIRECTS: Readonly<Record<string, string>>; export declare class NestedWorkerRefusedError extends Error { readonly code = "tool_child_nested_worker_refused"; constructor(); } /** The Worker a job worker sees: constructing it throws, so no thread outside the barrier ever starts. */ export declare function RefusedWorker(): never; /** `node:worker_threads` for a job worker's module graph: the builtin's exports with `Worker` refused. */ export declare function workerThreadsVirtualModule(): Readonly<Record<string, unknown>>; //# sourceMappingURL=gated-modules.d.ts.map