Xerg
Use xerg if it is already installed. If not, use npx @xerg/cli with the same arguments.
Xerg audits OpenClaw and Hermes workflows in dollars, not tokens. It reads gateway logs and session transcripts, surfaces confirmed waste plus savings opportunities, and helps you measure fixes with --compare.
Local audits need no account. Hosted sync and hosted MCP are optional paid workspace features. No data leaves your machine unless you explicitly push results to Xerg Cloud.
Quick Start
CODEBLOCK0
Use direct commands when you need explicit control, non-interactive behavior, JSON output, or CI gates:
CODEBLOCK1
Inputs
Xerg needs one of these source inputs:
- - Local OpenClaw data at the default paths:
-
/tmp/openclaw/openclaw-*.log
-
~/.openclaw/agents/*/sessions/*.jsonl
- - Local Hermes data at the default paths:
-
~/.hermes/logs/agent.log* with
gateway.log* fallback
-
~/.hermes/sessions/
- - Explicit paths via
--log-file and/or INLINECODE9 - An SSH target via INLINECODE10
- A Railway target via INLINECODE11
- A multi-source config via INLINECODE12
Additional requirements:
- -
--compare needs at least one previously stored compatible local snapshot - Pushing needs auth via
XERG_API_KEY, ~/.xerg/config.json, or browser credentials from INLINECODE16 - SSH audits require
ssh and rsync on your local PATH and are OpenClaw-only in this phase - Railway audits require the
railway CLI on your local PATH and are OpenClaw-only in this phase
Default Flow
- 1. Start with the default first-run path when you want the fastest local result:
CODEBLOCK2
- -
init detects local OpenClaw or Hermes data - it runs a first audit with local snapshot persistence enabled
- it offers optional hosted follow-up after the audit completes
- if no local data is found, it prints explicit local-path commands plus remote OpenClaw-only guidance
- 2. Detect sources directly when paths or connectivity are uncertain:
CODEBLOCK3
- -
xerg doctor --verbose shows progress on stderr while Xerg checks local paths or remote transports - If local defaults are empty, prefer
xerg doctor --remote ... or xerg doctor --railway instead of guessing paths
- 3. Run a baseline audit explicitly when you want direct control:
CODEBLOCK4
- 4. Choose the right output mode for the task:
CODEBLOCK5
- - Plain
xerg audit is best for a human-readable summary - INLINECODE27 is best for automation and agents
- INLINECODE28 is best for a shareable report
- 5. After a workflow or model change, measure the delta:
CODEBLOCK6
- 6. Export, push, or hosted-setup only when needed:
CODEBLOCK7
- -
connect is the guided hosted path: it reuses existing auth, prompts before browser login when needed, and offers to push the latest audit - INLINECODE30 prints or writes hosted MCP config for Cursor, Claude Code, or another client
- local audits and compare remain available if you skip hosted setup
Source Selection
Local defaults:
CODEBLOCK8
If both OpenClaw and Hermes are present locally, pass --runtime openclaw or --runtime hermes explicitly.
Explicit local paths:
CODEBLOCK9
SSH remote:
CODEBLOCK10
Railway:
CODEBLOCK11
Multiple remote sources:
CODEBLOCK12
Remote config files use this shape:
CODEBLOCK13
CI And Automation
For CI gates, prefer a single command so the audit can still be pushed before threshold failure:
CODEBLOCK14
Common variants:
CODEBLOCK15
Documented exit codes:
- -
0 success - INLINECODE34 runtime error
- INLINECODE35 no supported local runtime data found
- INLINECODE36 threshold exceeded
Automation can branch on those codes instead of scraping terminal output.
Recommendations
When using --json, expect a recommendations array alongside the audit summary. Recommendation items include:
- -
id, findingId, kind, title, INLINECODE43 - INLINECODE44 ,
confidence, INLINECODE46 - optional INLINECODE47
Current recommendation kinds fall into two buckets:
- - Confirmed waste:
retry-waste, INLINECODE49 - Savings opportunities or directional findings:
context-outlier, idle-spend, INLINECODE52
Prefer reversible or high-confidence fixes first. Treat model downgrades and context reductions as A/B-test candidates, not guaranteed savings.
Checks
Before finalizing work that used Xerg:
- - Say whether the audit was local, SSH, Railway, or multi-source
- Say whether the output was plain terminal text, JSON, or Markdown
- If
--compare was used, confirm that it compared against a compatible stored snapshot - If no data was found, run
xerg doctor or use explicit source flags rather than guessing - Say whether results were pushed to the Xerg API
- Distinguish confirmed waste (
retry-waste, loop-waste) from directional opportunities (context-outlier, idle-spend, candidate-downgrade)
Notes
- -
--compare and --no-db cannot be used together - Xerg is local-first: it stores economic metadata and audit snapshots locally, not prompt or response content
- INLINECODE62 is recommended for CI and non-interactive automation
- If browser auth is needed without the hosted setup flow, use
xerg login; remove stored credentials with INLINECODE64 - Pilot: xerg.ai/pilot
- Support: INLINECODE65
Xerg
如果已安装 xerg,请直接使用。否则,使用 npx @xerg/cli 并传入相同参数。
Xerg 以美元而非代币为单位审计 OpenClaw 和 Hermes 工作流。它读取网关日志和会话记录,发现已确认的浪费及节省机会,并通过 --compare 帮助您衡量修复效果。
本地审计无需账户。托管同步和托管 MCP 是可选的付费工作区功能。除非您明确将结果推送到 Xerg Cloud,否则不会有数据离开您的机器。
快速开始
bash
xerg init
xerg audit --compare
当您需要显式控制、非交互式行为、JSON 输出或 CI 门控时,请使用直接命令:
bash
xerg doctor
xerg audit
xerg audit --json
xerg audit --fail-above-waste-rate 0.30
输入
Xerg 需要以下源输入之一:
- /tmp/openclaw/openclaw-*.log
- ~/.openclaw/agents/
/sessions/.jsonl
- ~/.hermes/logs/agent.log
,回退至 gateway.log
- ~/.hermes/sessions/
- - 通过 --log-file 和/或 --sessions-dir 指定的显式路径
- 通过 --remote 指定的 SSH 目标
- 通过 --railway 指定的 Railway 目标
- 通过 --remote-config 指定的多源配置
额外要求:
- - --compare 需要至少一个先前存储的兼容本地快照
- 推送需要通过 XERGAPIKEY、~/.xerg/config.json 或 xerg login 的浏览器凭据进行身份验证
- SSH 审计需要在本地 PATH 中包含 ssh 和 rsync,此阶段仅支持 OpenClaw
- Railway 审计需要在本地 PATH 中包含 railway CLI,此阶段仅支持 OpenClaw
默认流程
- 1. 当您想要最快的本地结果时,从默认的首次运行路径开始:
bash
xerg init
- - init 检测本地 OpenClaw 或 Hermes 数据
- 它运行首次审计并启用本地快照持久化
- 审计完成后,它会提供可选的托管后续操作
- 如果未找到本地数据,它会打印显式的本地路径命令以及远程 OpenClaw 专属指导
- 2. 当路径或连接性不确定时,直接检测源:
bash
xerg doctor
xerg doctor --verbose
xerg doctor --remote user@host
xerg doctor --railway
- - xerg doctor --verbose 在 Xerg 检查本地路径或远程传输时,在 stderr 上显示进度
- 如果本地默认值为空,优先使用 xerg doctor --remote ... 或 xerg doctor --railway,而不是猜测路径
- 3. 当您想要直接控制时,显式运行基线审计:
bash
xerg audit
xerg audit --runtime openclaw
xerg audit --runtime hermes
- 4. 为任务选择正确的输出模式:
bash
xerg audit
xerg audit --json
xerg audit --markdown
- - 纯 xerg audit 最适合人类可读的摘要
- xerg audit --json 最适合自动化和代理
- xerg audit --markdown 最适合可共享的报告
- 5. 在工作流或模型更改后,衡量差异:
bash
xerg audit --compare
xerg audit --compare --json
- 6. 仅在需要时导出、推送或设置托管:
bash
xerg audit --markdown > xerg-audit.md
xerg connect
xerg mcp-setup
xerg audit --push
xerg push
- - connect 是引导式托管路径:它重用现有身份验证,必要时在浏览器登录前提示,并提供推送最新审计的选项
- mcp-setup 为 Cursor、Claude Code 或其他客户端打印或写入托管 MCP 配置
- 如果跳过托管设置,本地审计和比较仍然可用
源选择
本地默认值:
bash
xerg audit
如果本地同时存在 OpenClaw 和 Hermes,请显式传递 --runtime openclaw 或 --runtime hermes。
显式本地路径:
bash
xerg audit --runtime openclaw --log-file /path/to/openclaw.log
xerg audit --runtime openclaw --sessions-dir /path/to/sessions
xerg audit --runtime hermes --log-file ~/.hermes/logs/agent.log
xerg audit --runtime hermes --sessions-dir ~/.hermes/sessions
SSH 远程:
bash
xerg audit --remote user@vps.example.com
xerg audit --remote user@vps.example.com \
--remote-log-file /opt/openclaw/logs/openclaw.log \
--remote-sessions-dir /opt/openclaw/sessions
Railway:
bash
xerg audit --railway
xerg audit --railway --project --environment --service
多个远程源:
bash
xerg audit --remote-config ~/.xerg/remotes.json
远程配置文件使用以下格式:
json
{
remotes: [
{
name: prod,
transport: ssh,
host: deploy@prod.example.com
},
{
name: railway-prod,
transport: railway,
railway: {
projectId: ...,
environmentId: ...,
serviceId: ...
}
}
]
}
CI 和自动化
对于 CI 门控,建议使用单个命令,以便在阈值失败前仍可推送审计:
bash
xerg audit --push --fail-above-waste-rate 0.25 --fail-above-waste-usd 100
常见变体:
bash
xerg audit --fail-above-waste-rate 0.30
xerg audit --fail-above-waste-usd 50
xerg audit --since 24h --fail-above-waste-rate 0.30
已记录的退出代码:
- - 0 成功
- 1 运行时错误
- 2 未找到支持的本地运行时数据
- 3 超过阈值
自动化可以根据这些代码进行分支,而不是解析终端输出。
建议
使用 --json 时,期望在审计摘要旁边看到一个 recommendations 数组。建议项包括:
- - id、findingId、kind、title、description
- estimatedSavingsUsd、confidence、actionType
- 可选的 suggestedChange
当前的建议类型分为两类:
- - 已确认的浪费:retry-waste、loop-waste
- 节省机会或方向性发现:context-outlier、idle-spend、candidate-downgrade
优先选择可逆或高置信度的修复。将模型降级和上下文缩减视为 A/B 测试候选方案,而非保证的节省。
检查
在完成使用 Xerg 的工作之前:
- - 说明审计是本地、SSH、Railway 还是多源
- 说明输出是纯终端文本、JSON 还是 Markdown
- 如果使用了 --compare,确认它是否与兼容的存储快照进行了比较
- 如果未找到数据,运行 xerg doctor 或使用显式源标志,而不是猜测
- 说明结果是否已推送到 Xerg API
- 区分已确认的浪费(retry-waste、loop-waste)和方向性机会(context-outlier、idle-spend、candidate-downgrade)
备注
- - --compare 和 --no-db 不能同时使用
- Xerg 以本地优先:它在本地存储经济元数据和审计快照,而不是提示或响应内容
- 建议在 CI 和非交互式自动化中使用 XERGAPIKEY
- 如果需要在没有托管设置流程的情况下进行浏览器身份验证,请使用 xerg login;使用 xerg logout 删除存储的凭据
- 试点:xerg.ai/pilot
- 支持:query@xerg.ai