UNPKG

@code-yeongyu/senpi

Version:

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

31 lines • 1.59 kB
import { createLocalMachineOps } from "../../../vendor/senpi-machine-ops/index.js"; import { createInProcessHolderLink } from "../../../vendor/senpi-machine-ops/process/in-process-holder.js"; import { killProcessTree } from "../../utils/shell.js"; import { ensureTool } from "../../utils/tools-manager.js"; import { bindToolMachine } from "./tool-machine.js"; let processMachineOps; /** * The process-wide local MachineOps the built-in tools use when no caller supplies one. It has no `stateDir`, so it * records no scope tokens and writes nothing to disk: abort and timeout still kill the command's process group. */ function defaultLocalMachineOps() { processMachineOps ??= createLocalMachineOps({ holder: createInProcessHolderLink(), // A call, not the bare reference: the session-path audit (no-sync-in-session-path) follows calls only, and the // Windows kill path behind it (`taskkill` via spawnSync) must stay visible to its ledger. killProcessTree: (pid) => killProcessTree(pid), resolveFd: () => ensureTool("fd"), }); return processMachineOps; } /** A ToolMachine over `ops`, or over the process-wide local machine when the caller supplies none. */ export function createToolMachine(options) { return bindToolMachine(() => options?.ops ?? defaultLocalMachineOps(), options?.policy); } let defaultMachine; /** The ToolMachine a tool factory uses when its options carry none. */ export function defaultToolMachine() { defaultMachine ??= createToolMachine(); return defaultMachine; } //# sourceMappingURL=machine.js.map