feat(plugin): local scene-memory reader (tdai_read_local) + guarded read_cos - #774
Open
YOMXXX wants to merge 2 commits into
Open
feat(plugin): local scene-memory reader (tdai_read_local) + guarded read_cos#774YOMXXX wants to merge 2 commits into
YOMXXX wants to merge 2 commits into
Conversation
New tool for COS-less deployments: reads scene-memory files (persona.md, scene_blocks/*.md) from a configured local directory by relative path. Security checks reject absolute paths (POSIX + Windows drive-letter/UNC) and any ".." traversal, with a resolve+relative containment check as defense-in-depth. Part of TencentCloud#762 Signed-off-by: 李冠辰 <liguanchen@xiaomi.com>
The scene-detail read tool is now registered based on deployment: - storage.localDir set -> register tdai_read_local (local mode) - otherwise -> register tdai_read_cos (default COS mode) This stops registering a read tool that is guaranteed to fail, and the memory-tools guide + Scene Navigation hint in the injected prompt now reflect the tool that actually exists. - openclaw.plugin.json: new storage.localDir config field - format.ts / recall.ts: dynamic tools guide by ReadTool - README (CN/EN): document storage.localDir - vitest added for the plugin; 13 tests cover path safety + dynamic guide Closes TencentCloud#762 Signed-off-by: 李冠辰 <liguanchen@xiaomi.com>
Collaborator
|
Thanks for your attention! We will schedule an internal review as soon as possible. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #762.
Problem
For COS-less local deployments the scene-detail read tool
tdai_read_cosis the only way to open scene-memory files, but it always fails without COS:format.tsinjects only the scene path index, and the guide advertisestdai_read_cosindex.tsregisterstdai_read_cosunconditionally — a tool that is guaranteed to fail, wasting AI call budgetResult: the AI "knows a scene exists but can't recall the details".
Change
Commit 1 —
feat(plugin): add tdai_read_local tool with path-safety checkssrc/tools/read-local.ts: reads a local file by relative path from a configured root..traversal, plus aresolve+relativecontainment check (defense-in-depth)Commit 2 —
feat(plugin): guard scene-detail tools by storage.localDiropenclaw.plugin.json: newstorage.localDirconfig fieldindex.ts: registers exactly one read tool —tdai_read_localwhenstorage.localDiris set (local mode), otherwisetdai_read_cos(default COS mode). No longer registers a tool that is guaranteed to fail.format.ts/recall.ts: the memory-tools guide and Scene Navigation hint are now dynamic, guiding the tool that is actually registered (tdai_read_cos/tdai_read_local, or neither)storage.localDirTests
vitest added to
openclaw-plugin(first tests for this package):src/tools/read-local.test.ts— 9 tests: path-safety (traversal, absolute, drive-letter, UNC, blank) + local reads (nested block, missing file, rejected paths)src/format.test.ts— 4 tests: guide/hint reflectreadTool(local/ defaultcos/none)npm test: 2 files, 13 tests, all passing.npm run build(tsc) passes.Behavior summary
storage.localDirtdai_read_costdai_read_costdai_read_localtdai_read_local