CodeArts Agent 内部架构与连通方案
已发现的关键信息
| 组件 | 路径/地址 | 说明 |
|---|---|---|
| AgentKernel | localhost:52366 | 本地 HTTP 服务器,处理所有请求 |
| 配置文件 | .codeartsdoer/CodeArts_Agent/Vscode_*/server_config.properties | 含 pid、port、version |
| 会话数据库 | .codeartsdoer/codearts-data/opencode.db | SQLite,存储所有会话/消息/偏好 |
| 云端API | https://snap-access.cn-north-4.myhuaweicloud.com/api/v2/chat/completions | 实际推理后端 |
| 认证方式 | 华为云 AK/SK + HMAC-SHA256 签名 | 通过 getUserAkSk() 获取 |
| VS Code 插件 | C:\Program Files\CodeArts Agent\resources\app\extensions\vscode-codebot\ | 桥接 IDE 和 AgentKernel |
可行的 3 种连通路径
路径1:直接读取 opencode.db(最简单,只读监控)
- 无需认证,直接用 SQLite 读取会话、消息、偏好
- 适合:监控对话内容、统计使用量
路径2:通过 AgentKernel API(需破解认证)
- 本地 HTTP 服务在 52366 端口,但需要 AK/SK 签名
- AK/SK 由 VS Code 插件通过
getUserAkSk()从华为云 IAM 获取 - 理论上可以从插件内存/请求中截获,但涉及安全风险
路径3:通过华为云 CodeArts 控制台 API(官方路径)
- 企业版提供控制台 API,可管理成员、查看用量
- 这是官方推荐的监控方式
立即可用的方案:读取 opencode.db
codearts_monitor.py
+193
Run CodeArts monitor
自动
python C:\codeartswork\together\codearts_monitor.py
check_schema.py
+16
Check DB schema
自动
python C:\codeartswork\together\check_schema.py
codearts_monitor.py
+6
-6
codearts_monitor.py
+2
-2
codearts_monitor.py
+1
-1
codearts_monitor.py
+1
-1
codearts_monitor.py
+5
-1
Run fixed CodeArts monitor
自动
python C:\codeartswork\together\codearts_monitor.py
监控器成功运行了!可以看到会话、消息和用户偏好。让我修复 kernel 状态检测和消息预览:
codearts_monitor.py
+8
-5
Run monitor with fixed kernel status
自动
python C:\codeartswork\together\codearts_monitor.py
Debug config path
自动
python -c "
import glob
configs = glob.glob(r'C:\Users\PCbeta Tester\.codeartsdoer\CodeArts_Agent\*\server_config.properties')
print('Found configs:', configs)
if configs:
with open(configs[0]) as f:
print(f.read())
"
codearts_monitor.py
+1
-1
Run monitor with encoding fix
自动
python C:\codeartswork\together\codearts_monitor.py
AgentKernel 状态已正常显示。消息预览为空是因为 data 中的 content 字段在 part 表而非 message 表。让我看看消息的实际数据结构:
check_msg.py
+25
Check message data structure
自动
python C:\codeartswork\together\check_msg.py
check_msg2.py
+24
Find text parts and user messages
自动
python C:\codeartswork\together\check_msg2.py
完美!现在数据结构清楚了。part 表中 type=text 的才是实际对话内容。让我更新监控器并给你最终总结:
codearts_monitor.py
+13
-3
Run final monitor
自动
python C:\codeartswork\together\codearts_monitor.py
监控器完全工作了!可以看到模型是 inferhub-provider/GLM-5.1,消息内容也能正确读取。
总结:CodeArts 的连通方案
已验证可用的路径
| 方案 | 可行性 | 说明 |
|---|---|---|
| 读取 opencode.db | ✅ 已验证 | SQLite 数据库,含全部会话/消息/偏好,无需认证 |
| AgentKernel 本地 API | ✅ 存在但需认证 | localhost:52366,华为云 AK/SK 签名认证 |
| 日志监控 | ✅ 已验证 | codearts-data/log/ 下有完整的请求/响应日志 |
| CodeArts CLI/TUI | ✅ 官方支持 | 官网明确提到 CLI/TUI 模式 |
关键发现
-
opencode.db 是最直接的监控入口,存储了:
session- 所有会话(标题、目录、时间)message- 消息元数据(角色、模型、token消耗)part- 消息内容(文本、工具调用、步骤)preference- 用户偏好
-
AgentKernel 在
localhost:52366运行,API 路由包括:/global/health- 健康检查/v1/config- 配置/v1/init- 初始化/cag/codebase/v1/*- 代码库索引/session/*/todo- 任务列表/event- 事件流/log- 日志
-
云端推理 走
snap-access.cn-north-4.myhuaweicloud.com,用华为云 AK/SK 签名
已生成的监控工具在 C:\codeartswork\together\codearts_monitor.py,可以直接 python codearts_monitor.py 运行。

2228

被折叠的 条评论
为什么被折叠?



