#11761: fix(gateway): expose memory/ directory files in agents.files RPC
gateway
stale
Cluster:
Memory Management Enhancements
## Summary
The `agents.files.list` RPC only returned hardcoded bootstrap files (AGENTS.md, SOUL.md, etc.) and MEMORY.md. Daily memory files under `memory/` (e.g. `memory/2026-02-08.md`) were never listed, and `agents.files.get`/`agents.files.set` rejected them via the `ALLOWED_FILE_NAMES` whitelist — so any UI consuming the file list would show "No memories yet" even when memory files exist on disk.
**Changes:**
- Add `isAllowedFileName()` helper that accepts `memory/*.md` paths (with path traversal protection)
- Walk the `memory/` subdirectory in `listAgentFiles()`
- Ensure parent directory is created on `agents.files.set` for subdirectory files
## AI-Assisted
- [x] AI-assisted (Claude)
- [x] Fully tested — `pnpm build && pnpm check && pnpm test` all pass (251/251 tests)
- [x] I understand what the code does
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates the gateway `agents.files.*` RPCs to properly surface per-day memory files stored under `memory/` inside an agent workspace.
- Introduces `isAllowedFileName()` to extend the existing whitelist so `memory/*.md` (single-level) paths are accepted, while still blocking basic traversal patterns.
- Extends `listAgentFiles()` to read the `memory/` directory and include any `.md` files found there.
- Updates `agents.files.set` to create the parent directory when writing a file in a subdirectory (e.g. `memory/2026-02-08.md`).
Overall, the change fits naturally into the existing gateway file RPC design: file names remain constrained to a small allowlist plus a narrowly-scoped `memory/*.md` extension, and listing/writing is still anchored under the resolved agent workspace directory.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- Changes are localized to the gateway agent file RPC handlers and primarily extend an existing allowlist to include `memory/*.md` plus add directory creation when writing those files. The new constraints (`memory/` prefix, `.md` suffix, single path segment) keep the surface area small, and the listing logic is read-only and best-effort.
- No files require special attention
<!-- greptile_other_comments_section -->
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#23566: Gateway:expose memory/*.md in agents.files RPC
by SepehrShapouri · 2026-02-22
90.2%
#9678: Cross-agent memory read allowlist
by Helmi · 2026-02-05
80.5%
#2884: fix: Create memory directory and symlink identity files during work...
by webdevtodayjason · 2026-01-27
79.0%
#21217: fix: memory prune command to prevent unbounded MEMORY.md growth
by theognis1002 · 2026-02-19
78.5%
#8713: feat: gateway memory monitor, install linger, docs and failover
by quratus · 2026-02-04
78.3%
#19341: Mind Memory Fork
by juliopx · 2026-02-17
76.5%
#7896: docs: enforce immediate memory persistence in AGENTS.md
by FelixFoster · 2026-02-03
76.2%
#11743: fix: remove redundant file reads from AGENTS.md template
by shogunsea · 2026-02-08
76.1%
#9726: feat: add identityDir config for separate identity file location
by rickburn · 2026-02-05
75.4%
#15852: fix: pass agentId when resolving IRC session paths
by MisterGuy420 · 2026-02-14
75.0%