import type { AgentTool } from "@earendil-works/pi-agent-core"; import { type Static, Type } from "typebox"; import type { ToolDefinition } from "../extensions/types.ts"; import { type MutationRequesterResolver } from "./file-mutation-coordinator.ts"; import { type HashlineSnapshotStore } from "./hashline.ts"; declare const writeSchema: Type.TObject<{ path: Type.TString; content: Type.TString; }>; export declare const writeToolSystemPromptContribution: Readonly<{ readonly snippet: "Create or overwrite a writable path selector."; readonly guidelines: readonly ["Use write when replacing the full content of a target; use edit for source edits anchored to existing hashline snapshots."]; }>; export type WriteToolInput = Static; export interface WriteToolDetails { resolvedPath?: string; madeExecutable?: boolean; meta?: { sourcePath?: string; diagnostics?: unknown; }; diagnostics?: unknown; } /** Per-call options for {@link WriteOperations.writeFile}. */ export interface WriteFileOptions { /** * Create the file, failing with `EEXIST` if the path is already taken, rather than * truncating whatever is there. Requested only when the tool has just established that the * target was absent, so it closes the window between that check and the write. * * An implementation that cannot express exclusive create may ignore this and overwrite. It * then loses only the race against writers outside Atomic, since the mutation queue already * excludes writers inside it. */ exclusive?: boolean; } /** * 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, options?: WriteFileOptions) => Promise; mkdir: (dir: string) => Promise; /** * Current content of a path, or `undefined` when nothing is there. * * `write` reads before every write, to refuse generated files, to check that this session * has observed what it is replacing, and to decide between creating and overwriting. Those * checks have to see the same filesystem the write lands on, so this belongs here rather * than being read from local disk behind an implementation's back. * * Report absence as `undefined` and **reject** for anything else. A path that exists but * cannot be read is not the same as a free path: returning `undefined` for it would present * an unreadable file as a fresh create and truncate it. */ readFile: (absolutePath: string) => Promise; } export interface WriteToolOptions { /** Custom operations for file writing. Default: local filesystem */ operations?: WriteOperations; hashlineStore?: HashlineSnapshotStore; /** Resolves who is being rejected when a mutation conflicts. Diagnostic only. */ resolveMutationRequester?: MutationRequesterResolver; } export declare function createWriteToolDefinition(cwd: string, options?: WriteToolOptions): ToolDefinition; export declare function createWriteTool(cwd: string, options?: WriteToolOptions): AgentTool; export {}; //# sourceMappingURL=write.d.ts.map