你现在主要精力就是解决CodeArts的。 现在咱们本身就在CodeArts里面,你找找有什么连通的方法!

CodeArts Agent 内部架构与连通方案

已发现的关键信息

组件路径/地址说明
AgentKernellocalhost:52366本地 HTTP 服务器,处理所有请求
配置文件.codeartsdoer/CodeArts_Agent/Vscode_*/server_config.properties含 pid、port、version
会话数据库.codeartsdoer/codearts-data/opencode.dbSQLite,存储所有会话/消息/偏好
云端APIhttps://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 模式

关键发现

  1. opencode.db 是最直接的监控入口,存储了:

    • session - 所有会话(标题、目录、时间)
    • message - 消息元数据(角色、模型、token消耗)
    • part - 消息内容(文本、工具调用、步骤)
    • preference - 用户偏好
  2. AgentKernel 在 localhost:52366 运行,API 路由包括:

    • /global/health - 健康检查
    • /v1/config - 配置
    • /v1/init - 初始化
    • /cag/codebase/v1/* - 代码库索引
    • /session/*/todo - 任务列表
    • /event - 事件流
    • /log - 日志
  3. 云端推理 走 snap-access.cn-north-4.myhuaweicloud.com,用华为云 AK/SK 签名

已生成的监控工具在 C:\codeartswork\together\codearts_monitor.py,可以直接 python codearts_monitor.py 运行。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值