← Back to PRs

#23566: Gateway:expose memory/*.md in agents.files RPC

by SepehrShapouri open 2026-02-22 12:56 View on GitHub →
gateway size: S
## 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