← Back to PRs

#11761: fix(gateway): expose memory/ directory files in agents.files RPC

by advaitpaliwal open 2026-02-08 08:25 View on GitHub →
gateway stale
## 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