FileReadBackend
Defined in: tools/builtin/builtin.types.ts:250
The read-only filesystem capability seam — implement this against your host.
Remarks
Backs the two read-only file tools (read and glob). Read-only by nature,
so — like SearchBackend — it is far less dangerous than a mutating or
exec capability, but it still touches a filesystem the core knows nothing
about, hence a seam rather than a shipped implementation.
Backing point: this interface is where you back read and glob, exactly the
way SearchBackend is where you back search (grep). Wire it to e.g.
Node's fs, a virtual filesystem, or a sandbox.
See
- SearchBackend — its read-only sibling; back this the same way.
- FileWriteBackend — the mutating other half of the filesystem.
- readTool and globTool which wrap this seam in model-facing tools.
Methods
glob()
glob(query, ctx): Promise<string[]>;Defined in: tools/builtin/builtin.types.ts:266
List files matching a glob pattern.
Parameters
| Parameter | Type | Description |
|---|---|---|
query | GlobQuery | The glob pattern and optional root directory. |
ctx | ToolContext | Per-call context; ctx.signal may be used to abort the walk. |
Returns
Promise<string[]>
The matching file paths.
read()
read(request, ctx): Promise<FileReadResult>;Defined in: tools/builtin/builtin.types.ts:258
Read a slice of a file's contents.
Parameters
| Parameter | Type | Description |
|---|---|---|
request | FileReadRequest | The file path plus an optional 1-based offset and line limit. |
ctx | ToolContext | Per-call context; ctx.signal may be used to abort the read. |
Returns
Promise<FileReadResult>
The selected lines and the 1-based number of the first line.