@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
50 lines • 3.03 kB
TypeScript
import type { ExecShell } from "../../../vendor/senpi-machine-ops/index.js";
import type { AgentTool } from "@earendil-works/pi-agent-core";
import type { ShellTrust } from "../../engine-trust/shell-trust.ts";
import type { ToolDefinition } from "../extensions/types.ts";
import { type BashSpawnHook, type BashToolDetails, bashSchema, type ShellToolConfig } from "./bash-schema.ts";
import { type OutputSpillFactory } from "./output-accumulator-core.ts";
import { type BashOperations } from "./shell-operations.ts";
import type { ToolMachine } from "./tool-machine.ts";
/** Annotates a failed command's result with the engine trust status; undefined leaves the result as is. */
export type ShellTrustAnnotator = (result: {
exitCode: number;
output: string;
}) => {
text: string | undefined;
trust: ShellTrust;
} | undefined;
export interface ShellToolCoreOptions {
/** Runs the policy gate once per call. */
machine: ToolMachine;
/** Where the command runs. */
operations: BashOperations;
/** Where output past the display limits is kept; the path appears in the model's truncation notice. */
outputSpill: OutputSpillFactory;
/** The base environment before the session's `PI_*` values. Default: empty. */
shellEnv?: () => NodeJS.ProcessEnv;
/** Default: no annotation. */
annotateTrust?: ShellTrustAnnotator;
/** Redact credential-shaped output before streaming or spilling. Default: false. */
redactSecretsInOutput?: boolean;
/** Command prefix prepended to every command (for example shell setup commands) */
commandPrefix?: string;
/** Expose current Pi session metadata as PI_* environment variables. Default: true */
exposeSessionEnvironment?: boolean;
/** Hook to adjust command, cwd, or env before execution */
spawnHook?: BashSpawnHook;
}
/** A shell tool's model-facing definition and execution, without renderers: the shared core of bash and powershell. */
export declare function createShellToolCore(cwd: string, config: ShellToolConfig, options: ShellToolCoreOptions): ToolDefinition<typeof bashSchema, BashToolDetails | undefined>;
export interface CoreBashToolOptions extends Omit<ShellToolCoreOptions, "operations" | "outputSpill" | "annotateTrust" | "shellEnv"> {
/** Where the command runs. Default: `process.exec` on `machine`, in `shell`. */
operations?: BashOperations;
/** The shell for the default operations. Default: the machine's own (`/bin/sh -c` on POSIX). */
shell?: ExecShell;
/** Default: a file under `/tmp` on `machine` (see `createMachineOutputSpill`). */
outputSpill?: OutputSpillFactory;
}
/** The bash tool for a host whose only effect channel is `machine`. */
export declare function createCoreBashToolDefinition(cwd: string, options: CoreBashToolOptions): ToolDefinition<typeof bashSchema, BashToolDetails | undefined>;
export declare function createCoreBashTool(cwd: string, options: CoreBashToolOptions): AgentTool<typeof bashSchema>;
//# sourceMappingURL=bash-core.d.ts.map