@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
47 lines • 2.58 kB
TypeScript
import type { AgentTool } from "@earendil-works/pi-agent-core";
import { type Static, Type } from "typebox";
import type { FilesystemPolicyChecker, ToolDefinition } from "../extensions/types.ts";
import { type FileMutationQueue, type ToolPathCanonicalizer, type ToolPathResolver } from "./file-tool-host.ts";
import type { ToolMachine } from "./tool-machine.ts";
import { type WriteBaseline, type WriteToolDetails } from "./write-result.ts";
export declare const writeSchema: Type.TObject<{
path: Type.TString;
content: Type.TString;
}>;
export declare const writeToolSystemPromptContribution: {
readonly snippet: "Create or overwrite files";
readonly guidelines: readonly ["write only for new files or full rewrites."];
readonly fullGuidelines: readonly ["Use write only for new files or complete rewrites."];
};
export type WriteToolInput = Static<typeof writeSchema>;
/**
* Pluggable operations for the write tool.
* Override these to delegate file writing to remote systems (for example SSH).
*/
export interface WriteOperations {
/** Write content to a file */
writeFile: (absolutePath: string, content: string) => Promise<void>;
/** Create directory recursively */
mkdir: (dir: string) => Promise<void>;
}
export interface CoreWriteToolOptions {
/** Operation layer and policy gate. */
machine: ToolMachine;
/** Custom operations for file writing. Default: writes through `machine` */
operations?: WriteOperations;
/** Extension-registered filesystem policy checker. */
filesystemPolicy?: FilesystemPolicyChecker;
/** Default: POSIX resolution against the cwd. */
resolvePath?: ToolPathResolver;
/** The directory handed to `operations.mkdir`. Default: POSIX dirname. */
dirname?: (absolutePath: string) => string;
/** Default: one queue per path string in this isolate, shared with the core edit tool. */
withMutationQueue?: FileMutationQueue;
/** The path `filesystemPolicy` judges. Default: the resolved path as is. */
canonicalizePath?: ToolPathCanonicalizer;
/** The content before the write, for the result's patch. Default: read on `machine`; none with custom operations. */
readBaseline?: (absolutePath: string) => Promise<WriteBaseline>;
}
export declare function createCoreWriteToolDefinition(cwd: string, options: CoreWriteToolOptions): ToolDefinition<typeof writeSchema, WriteToolDetails | undefined>;
export declare function createCoreWriteTool(cwd: string, options: CoreWriteToolOptions): AgentTool<typeof writeSchema>;
//# sourceMappingURL=write-core.d.ts.map