Repository navigation
feat(P1): Redis 通用键浏览(只读)+ AI 只读工具调用 - #549
Merged
Merged
Conversation
P1-1 Redis 通用键空间浏览(只读)
- 新增 app/modules/monitor/cache/browser.py:逻辑库清单(INFO keyspace 解析)、SCAN 分页
(pipeline 批量取 type/ttl)、单键详情(string/hash/list/set/zset/stream,限量 + truncated)
- 安全:只读;键名命中敏感模式(token/session/password/api_key 等)时**值一律脱敏**;
跨库浏览按连接参数新建短生命周期客户端,用完关闭,避免 SELECT 污染共享连接池
- 接口:GET /monitor/cache/redis/{databases,keys,value}(权限 module_monitor:cache:query)
- Web:缓存监控页新增「键空间浏览」tab(库选择 / 模式扫描 / 加载更多 / 行点击查看详情)
- tests/test_redis_browser.py(13 项)
P1-2 AI 只读工具调用
- 新增 app/modules/ai/tools/registry.py:5 个只读工具(server_status / storage_sources /
storage_files / cron_jobs / redis_keys);auth/redis 用闭包捕获,**签名只保留模型可填参数**
(含守卫 _assert_no_injected_params);工具出错返回 {error} 不中断对话
- 明确不移植 FastHub 的 run_host_command / 本机终端类工具(多租户下等于 RCE)
- AgnoFactory.create_agent 支持 tools;ChatService 增加 redis 依赖与 _chat_tools 开关;
WS 与 /ai-chat 均支持 use_tools(默认关闭,零行为变化);新增 GET /ai/chat/tools 能力清单
- Web:聊天输入区新增「启用只读工具」开关,WS 负载带 use_tools
- tests/test_ai_readonly_tools.py(10 项)
验证:后端 pytest **170 passed**、ruff All checks passed、basedpyright 0 errors;
前端 type-check 通过、eslint 无错、prettier 通过、vitest **41 passed**。
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.
按 FastHub 移植清单落地 P1(继续排除:中心/地址源、本地数据库、本地主机/本机文件/本机终端/
run_host_command、桌面壳)。P1-1 Redis 通用键空间浏览(只读)
GET /monitor/cache/redis/databases(解析INFO keyspace)、/redis/keys(SCAN 分页 + pipeline 批量 type/ttl)、/redis/value(按类型限量取值)SELECT污染共享连接池tests/test_redis_browser.py(13 项)P1-2 AI 只读工具调用
app/modules/ai/tools/registry.py:5 个只读工具(服务器状态 / 存储源清单 / 存储文件列表 / 定时任务 / Redis 键名)auth/redis通过闭包捕获,工具签名只保留模型可填参数,并有_assert_no_injected_params守卫;工具出错返回{error}不中断对话AgnoFactory.create_agent(tools=…);WS 与/ai-chat支持use_tools(默认关闭,零行为变化);新增GET /ai/chat/toolsuse_toolstests/test_ai_readonly_tools.py(10 项)验证
pytest170 passed、ruffAll checks passed、basedpyright0 errorsvue-tsc通过、eslint无错、prettier通过、vitest41 passed