Skip to Content
@brain-core

Tools

The four fs_* tools brain-core contributes: read, list, search, and write across the URI-native filesystem.

brain-core's tools/ folder holds the four fs_* tools that cover the whole filesystem surface. Each declares its feature gate on its own schema (x-neuralis.requires.features), and the matching HTTP routes carry the same gates independently — the agent path and the direct-HTTP path are both checked, deny-by-default. See package-system tools for the schema-first tool contract.

ToolFeatureWhat it does
fs_readfiles.readBatch read (up to 10 files) by URI or UUID
fs_listfiles.readBounded tree that merges the index with live connector entries
fs_searchfiles.readSemantic, filter, and grep search
fs_writefiles.writeThe write verb — one key per operation

Every file lives at the four-tuple coordinate (uri, connector, os_uri?, container_dir?) described on Connectors. Per-path access is governed by URI policies, and the brain:// memory source is additionally isolated per agent. On a folder that lives on a paired device, fs_read, fs_list and fs_search give the machine path (os_uri) only to that device's owner and to a holder of device.others; everyone else gets the <source>:// address alone.

fs_read — read file contents

Gate: files.read. One call reads up to 10 files. An entry can be a bare reference or {uri, line_start, line_end} carrying its own line window, so a single call can take a slice of one file and all of another; a top-level line_start/line_end applies to the entries that do not bring their own, and read_version: 'baseline' reads the pre-edit snapshot.

{
  "files": [
    { "uri": "data://notes/todo.md", "line_start": 1, "line_end": 200 },
    "brain://insights/q3.md"
  ],
  "include_ids": true
}

Text comes back line-numbered under a lines X-Y / total header, so a follow-up edit can address the lines it just read. A whole-file read that outgrows the snippet cap is trimmed on a line boundary and says how large the file is and which line to continue from; a window you asked for is never trimmed. fs_read preserves original source bytes: images, video, audio, and PDFs are emitted as media content blocks for capable models, each with its source URI so the chat stream can re-read it on conversation reload (a rendered PDF is kept inline). Unknown binary files get a URI and a marker.

A batch answers 200 even when some files failed — one bad URI must not sink the other nine — so failures ride the response as { uri, error, code? }. Branch on code, never on the error text:

codeMeaning
not_foundThe file is genuinely gone. Something confirmed it: storage answered "no such file". Safe to drop it from a cached view.
forbiddenYou may not read it — a path-policy deny or a disabled source. The file still exists; never treat this as absence.
source_unavailableThe folder lives on a paired device that cannot serve right now; reason is its live state (runtime_offline, devices_disabled, broker_outdated, device_not_ready, …). With device_not_ready, not_ready lists what the device's owner fixes there (ceiling_missing_or_empty, socket_isolation_failed, …). The file very likely still exists.
device_refusedThe device answered but refused this read; reason is its fixed refusal code.
vector_store_unavailableThe read needed the index (a brain:// file, an id) and the vector store is not available yet. The file is not gone; retry later.
(absent)Something else went wrong and nothing can be concluded. Retryable.

not_found is deliberately withheld when the underlying storage could not be reached at all, so a temporary outage can never be mistaken for a deletion. Error strings never contain server paths.

fs_list — list files as a tree

Gate: files.read. Renders a compact tree across indexed and live sources. Omit uri (or pass /) for a full root view (all://) with a per-source registry line; recursive: false returns direct children only. sources_only: true answers with the source registry alone — which sources exist and what state they are in, with nothing walked — and limit accepts any size down to a single entry. summary_chars adds inline content previews and include_metadata verbose per-file metadata.

A listing never names what the access rules hide from you. When something is hidden, a scoped listing ends with an Access rules hide entries from you in: line (hidden_in on the route): the folders of that same answer that hold a hidden entry — the listed folder or a folder it shows — never a hidden name and never a count. The root view carries no such line.

{ "uri": "data://agent-core", "recursive": false }

Reads and listings are connector-first: live content and tree structure come from the connector even when the index is cold, then index presence is reconciled per listed file. Presence badges tag only entries that differ from their parent: ● synced (index and connector agree), ○ unindexed (on disk, not yet indexed), ✗ stale (indexed, no longer on the connector); brain:// entries are vector-only.

When a source is a git checkout — or contains checkouts — fs_list also tags each dirty file with its git working-tree status ([M] modified, [A] added, [D] deleted, [R] renamed, [?] untracked), a separate signal from presence (a file can be both indexed and modified). The status is scoped to the folder being listed — never a whole-repo scan — then time-boxed and cached, and it is fail-soft: any problem simply omits the badge. The Files widget's Git Control view builds on the same status.

fs_search — find files across sources

Gate: files.read. Three modes, chosen by search_mode:

  • semantic — meaning-based search over the index, needs query. On Qdrant the query is hybrid: the vector ranking is fused with a BM25 keyword leg over the same content (a fresh install has BM25 ranking from the first file; it needs Qdrant 1.15.2 or later, and an older collection gets it when an owner enables text ranking). A scope that holds at most vectorExactSearchMaxPoints indexed points (20 000 by default) is compared exhaustively, so a small folder finds everything it holds.
  • filter — metadata and keyword queries: category, tags, status, and creation-date ranges, plus query as a tokenized, case-insensitive keyword over indexed content (chunks included, one result per file, ranked by term frequency) and glob as a filename match. No embedding involved.
  • grep — literal text search (ripgrep, git grep, or grep — whichever is available) over live connector content, needs folder_uri + query. The match is a FIXED STRING, never a regular expression; glob narrows the scanned files, path_glob takes a real path glob, case_sensitive honours the query's case and context returns up to five lines around each match. It bypasses the index, so it always reflects the current state of disk.
{ "search_mode": "semantic", "query": "deployment checklist", "limit": 10 }

Results carry URI, snippet, and score (semantic), plus truncated and total_seen in every mode, so a set cut at its limit is never read as proof that the rest does not exist.

In every mode fs_search enforces the per-URI read policy on each result, not just the files.read feature gate — a read:false path (another agent's private memory subtree, for example) is silently absent and a fully-denied folder_uri returns 403. That makes grep the policy-gated counterpart to shell grep: a caller holding files.read plus read on a path can grep it without any execute / shell access. brain:// queries search the calling agent's own memory unless sibling inclusion is explicitly requested, and cross-agent observation requires the matching feature grant.

Metadata and keyword search work without an embedding model. A semantic request reports requested_mode and effective_mode; when embedding is disabled, unavailable or out of budget it falls back to text search — a keyword match that needs every word of the query, so use specific terms — and sets effective_mode: "filter" with embedding_degraded (a safe reason) and a warning. Results carry embedding_status: a vector may be current, stale or missing, and embedding freshness is separate from the current indexed content — a stale vector does not turn an old snapshot into the latest file. Permission, storage, and invalid-request errors remain errors. While the vector store is not available, semantic and filter search answer one error row with code: "vector_store_unavailable" at once (no embedding is spent); grep over a folder keeps working.

fs_write — one tool, one key per operation

Gate: files.write. The key names the operation:

  • Content: create (make a new file), overwrite (replace the whole file), edit (a list of exact-text replacements), insert (add lines at a line number), lines (replace a line range), fields (category, status, pinned, tags, metadata).
  • Structure: move, copy, mkdir, revert, delete.
{
  "uri": "data://notes/todo.md",
  "edit": [{ "old_string": "draft", "new_string": "final" }],
  "fields": { "tags": { "add": ["reviewed"] } }
}

The content keys compose in one call — applied create/overwrite, then edit, insert, lines and fields — and land as a single write with a single undo point. If any one of them cannot be applied, none of them is: the file is left exactly as it was and the answer says which key failed and why. Each structural key stands on its own; a call that mixes two of them is refused with the operation to send first named in the message. The answer carries the node, the keys applied, and the URI the write actually landed at.

create never overwrites. When the name is taken the file lands beside it as name-2.ext and the answer reports the URI actually used, so overwrite is the only way to replace content. Every write snapshots a baseline on the file node, so revert is one-level undo without any external service.

An empty folder has no file node to review, so mkdir always lands committed (and is not supported on brain://, where folders are implicit); an agent's copy lands pending_review like any other agent write, and its destination may be in another source.

Asking is per key. fs_write declares delete as the key that needs confirmation: under the balanced permission mode an edit or a move runs without interrupting, and a delete opens an approval interaction in chat first. Under auto nothing asks — that mode exists so an unattended run can finish, and a prompt it cannot answer would simply stop it. A delete is a revertible tombstone wherever a revert baseline can be taken. On a folder URI a delete removes the tree; over the external MCP surface, where there is nobody to confirm, a recursive folder delete that would leave files with no undo point is refused and the answer says to delete them one at a time instead.

A write to a path the source excludes from indexing is saved and revertible but stays out of search, and the answer says so rather than implying the file is searchable. Writes that go through brain-core update the index inline — the file is searchable as soon as the call returns; a successful write can still report that indexing failed, and that partial outcome must be resolved separately. While the vector store is not available, a new file on a folder source still lands (unindexed until the store is back); an edit, move or delete of an existing file and any brain:// write answer vector_store_unavailable with nothing changed.

On this page