#23566: Gateway:expose memory/*.md in agents.files RPC
gateway
size: S
Cluster:
Memory Management Enhancements
## Summary
Expose daily memory markdown files under memory/ via gateway RPC:
- agents.files.list now includes memory/*.md
- agents.files.get/set now accept safe memory/<name>.md paths
## Why
Settings UIs can currently edit top-level workspace files but not daily memory files. This enables first-class memory folder editing.
## Safety
Path remains constrained:
- strict allow pattern for memory/<safe>.md
- normalization checks prevent traversal
## Tests
- Added coverage in src/gateway/server-methods/agents-mutate.test.ts for listing memory markdown files
- Ran: pnpm test src/gateway/server-methods/agents-mutate.test.ts
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR exposes daily memory markdown files (`memory/*.md`) through the gateway RPC by:
- Adding `listMemoryFiles()` function to discover `.md` files in the `memory/` directory
- Updating `listAgentFiles()` to include memory files in `agents.files.list` results
- Extending `isAllowedMemoryRelativePath()` validation to accept `memory/<name>.md` paths in `agents.files.get` and `agents.files.set`
The security implementation uses a strict regex pattern (`/^memory\/[A-Za-z0-9._-]+\.md$/`) combined with `path.posix.normalize()` checks to prevent path traversal attacks. The test coverage validates that markdown files are correctly listed while non-markdown files and subdirectories are filtered out.
**Issue found**: The `agents.files.set` endpoint doesn't create the `memory/` subdirectory before writing files, which will cause `ENOENT` errors when trying to write to `memory/*.md` paths for the first time.
<h3>Confidence Score: 3/5</h3>
- This PR has solid security measures but contains a critical bug that will prevent the new feature from working
- The path traversal protection is well-implemented and tested. However, the `agents.files.set` endpoint is missing the necessary `mkdir` call to create the `memory/` subdirectory before writing files, which means the feature will fail at runtime when users try to create memory files. This is a straightforward fix but prevents the feature from working as intended.
- src/gateway/server-methods/agents.ts requires a fix to create the memory/ subdirectory before writing files
<sub>Last reviewed commit: 7404408</sub>
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#11761: fix(gateway): expose memory/ directory files in agents.files RPC
by advaitpaliwal · 2026-02-08
90.2%
#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
77.5%
#2884: fix: Create memory directory and symlink identity files during work...
by webdevtodayjason · 2026-01-27
75.8%
#14576: Fix/memory loss bugs
by ENCHIGO · 2026-02-12
74.9%
#10591: feat(hooks): add session-start-memory bundled hook
by morningstar-daemon · 2026-02-06
74.9%
#9678: Cross-agent memory read allowlist
by Helmi · 2026-02-05
74.5%
#19341: Mind Memory Fork
by juliopx · 2026-02-17
74.4%
#11457: feat: Add hybrid memory mode with auto-created daily log templates
by Undertone0809 · 2026-02-07
73.5%
#6362: fix(memory): add ignore patterns to chokidar file watcher
by Glucksberg · 2026-02-01
73.4%