Open Agent Loops
API Reference

FileWriteBackend

@open-agent-loops/core


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

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

ParameterTypeDescription
requestFileEditRequestThe path plus the exact string to find and its replacement.
ctxToolContextPer-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

ParameterTypeDescription
requestFileWriteRequestThe path and the full content to write.
ctxToolContextPer-call context; ctx.signal may be used to abort the write.

Returns

Promise<FileWriteResult>

The path written and the number of bytes written.

On this page