@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
30 lines • 1.75 kB
TypeScript
import type { MachineOps, OpContext, OpName, PolicyHooks } from "../../../vendor/senpi-machine-ops/index.js";
/**
* The hooks the tool path honours: only `beforeOp`, once per tool call. The tools run the extension filesystem policy
* themselves and sub-operations carry no hooks, so `filesystem` and `afterOp` are rejected at compile time instead of
* being silently ignored.
*/
export type ToolPathPolicy = Pick<PolicyHooks, "beforeOp"> & {
readonly filesystem?: never;
readonly afterOp?: never;
};
/** One MachineOps bound to the tool path: principal `local-session`, no scope root (the tools resolve paths). */
export interface ToolMachine {
readonly ops: MachineOps;
/**
* Runs `PolicyHooks.beforeOp` once for one tool call; a denial rejects with `Error(reason)` before any effect.
* Without a `beforeOp` it returns undefined synchronously, so a tool that awaits only a returned promise keeps
* its exact pre-layer timing (bash emits its first partial update before any await).
*/
begin(op: OpName, args: unknown, signal: AbortSignal | undefined): Promise<void> | undefined;
/** Context for a sub-operation inside a call `begin` already admitted. */
context(signal: AbortSignal | undefined, pathLock?: "caller"): OpContext;
}
/** Binds the tool path to the MachineOps `resolveOps` returns, read on every use. */
export declare function bindToolMachine(resolveOps: () => MachineOps, policy?: ToolPathPolicy): ToolMachine;
/** A ToolMachine over a host-supplied MachineOps (a remote device, a sandbox): the tools' only effect channel. */
export declare function createToolMachine(options: {
ops: MachineOps;
policy?: ToolPathPolicy;
}): ToolMachine;
//# sourceMappingURL=tool-machine.d.ts.map