FileWriteBackend
Defined in: tools/builtin/builtin.types.ts:348
The mutating filesystem capability seam — implement this against your host.
Remarks
Backs the two mutating file tools (write and edit). Like
ShellBackend (bash), this is a dangerous, host-binding capability — it
changes files on whatever host you wire up — so the core ships no
implementation.
SECURITY: this overwrites and rewrites files with no sandbox of its own — that
is the backend's responsibility. Route the resulting tools through the
permission gate (../../permissions) before granting them to a model you do
not fully trust, the same advice as for ShellBackend.
Backing point: this interface is where you back write and edit, exactly the
way ShellBackend is where you back shell (bash). Wire it to e.g.
Node's fs, a container, or a remote sandbox.
See
- ShellBackend — the other dangerous, host-binding seam; back this the same way.
- FileReadBackend — the read-only other half of the filesystem.
- writeTool and editTool which wrap this seam in model-facing tools.
Methods
edit()
edit(request, ctx): Promise<FileEditResult>;Defined in: tools/builtin/builtin.types.ts:364
Replace the first occurrence of a string in a file.
Parameters
| Parameter | Type | Description |
|---|---|---|
request | FileEditRequest | The path plus the exact string to find and its replacement. |
ctx | ToolContext | Per-call context; ctx.signal may be used to abort the edit. |
Returns
Promise<FileEditResult>
The path edited and whether the target string was found.
write()
write(request, ctx): Promise<FileWriteResult>;Defined in: tools/builtin/builtin.types.ts:356
Write a file's full contents, creating parent directories as needed.
Parameters
| Parameter | Type | Description |
|---|---|---|
request | FileWriteRequest | The path and the full content to write. |
ctx | ToolContext | Per-call context; ctx.signal may be used to abort the write. |
Returns
Promise<FileWriteResult>
The path written and the number of bytes written.