----- THIS SKILL IS DEPRECATED - DON'T RUN -----
----- KILOCODE GATEWAY IS NOW BUILT-IN IN OPENCLAW -----
Kilocode Model Sync
Workspace: ~/.openclaw/workspace-steve/
Scripts: ~/.openclaw/workspace/skills/kilocode-model-sync/scripts/
Snapshots/diffs/patches: ~/.openclaw/workspace/kilocode-models/
Telegram delivery: Use the message tool with channel=telegram, target Guillaume's chat.
Step 1 — Run the sync script
CODEBLOCK0
Parse the JSON result from stdout. It contains:
| Field | Meaning |
|---|
| INLINECODE5 | INLINECODE6 \ | INLINECODE7 \ | INLINECODE8 |
| INLINECODE9 |
Total models fetched from API |
|
diff.added | New models not in previous snapshot |
|
diff.removed | Models that disappeared |
|
diff.updated | Models with changed fields |
|
snapshot_path | Where today's snapshot was saved |
|
patch_path | Path to the
.patch.json file (only if changed) |
|
diff_path | Path to the
.diff.json file (only if changed) |
Step 2 — If status == "no_change"
Write a brief memory note and stop. No notification needed.
CODEBLOCK1
Step 3 — If status == "changed", notify Guillaume via Telegram
Use the message tool to send to Guillaume's Telegram:
CODEBLOCK2
Format costs as $0.001/1k (multiply the raw per-token value × 1000).
Use free for models with 0 cost on both input and output.
Step 4 — Wait for approval signal from Grog
Grog will relay a sessions_send message to your session containing either:
- -
approve — proceed to apply - INLINECODE25 — log and stop
Step 5 — If approved, apply the patch
CODEBLOCK3
The script:
- 1. Backs up
openclaw.json with a timestamp - Replaces
models.providers.kilocode.models with the new list - Runs INLINECODE28
- Polls
openclaw gateway status until RPC probe: ok (up to 30s)
Result fields:
- -
status: "ok" | INLINECODE33 - INLINECODE34 : where the backup was saved
- INLINECODE35 : true/false
- INLINECODE36 : error message if failed
Step 6 — Write mission control entry
Append to ~/.openclaw/workspace/memory/YYYY-MM-DD.md:
CODEBLOCK4
Step 7 — Send Telegram confirmation
CODEBLOCK5
If gateway restart failed:
⚠️ *Kilocode Model Sync — Patch Applied, Gateway Restart Failed*
Models were written to openclaw.json but the gateway did not restart cleanly.
Error: {error}
Please restart manually: `openclaw gateway restart`
Step 8 — Report summary to Grog (sessions_send to main session)
After completion, send a concise summary to the main agent session so Grog can relay it
to Guillaume if needed. Use sessions_send with label=main or sessionKey=agent:main:main.
Error handling
- - If
sync_models.py exits with status "error": notify Guillaume via Telegram with the error, stop. - If
apply_patch.py fails to write config: the script auto-restores from backup; report failure. - If gateway doesn't come back: report in Telegram, tell Guillaume to restart manually.
- Always write a memory note even on failure.
----- 此技能已弃用 - 请勿运行 -----
----- KILOCODE 网关现已内置于 OPENCLAW 中 -----
Kilocode 模型同步
工作空间: ~/.openclaw/workspace-steve/
脚本: ~/.openclaw/workspace/skills/kilocode-model-sync/scripts/
快照/差异/补丁: ~/.openclaw/workspace/kilocode-models/
Telegram 投递: 使用 message 工具,设置 channel=telegram,目标为 Guillaume 的聊天。
步骤 1 — 运行同步脚本
bash
source ~/.openclaw/.env && python3 ~/.openclaw/workspace/skills/kilocode-model-sync/scripts/sync_models.py
解析 stdout 中的 JSON 结果。它包含:
| 字段 | 含义 |
|---|
| status | changed \ | nochange \ | error |
| totalmodels |
从 API 获取的模型总数 |
| diff.added | 上一快照中不存在的新模型 |
| diff.removed | 已消失的模型 |
| diff.updated | 字段发生变化的模型 |
| snapshot_path | 今日快照的保存路径 |
| patch_path | .patch.json 文件的路径(仅在发生变化时存在) |
| diff_path | .diff.json 文件的路径(仅在发生变化时存在) |
步骤 2 — 如果 status == no_change
写入一条简短的内存记录并停止。无需通知。
memory/YYYY-MM-DD.md 条目:
Kilocode 模型同步 — YYYY-MM-DD
步骤 3 — 如果 status == changed,通过 Telegram 通知 Guillaume
使用 message 工具发送到 Guillaume 的 Telegram:
🤖 Kilocode 模型同步 — {日期}
在 Kilocode 模型列表中发现变化:
✅ 新增:{N} 个模型
❌ 移除:{N} 个模型
🔄 更新:{N} 个模型
新模型:
{对于每个新增:• id — 名称(上下文:Xk tokens,成本:输入 $Y/输出 $Z 每 1k)}
移除的模型:
{对于每个移除:• id — 名称}
回复 Grog:@steve approve 以应用,或 @steve skip 以忽略。
成本格式化为 $0.001/1k(将原始每 token 值 × 1000)。
对于输入和输出成本均为 0 的模型,使用 free。
步骤 4 — 等待 Grog 的批准信号
Grog 将向您的会话转发一条 sessions_send 消息,其中包含:
- - approve — 继续应用
- skip — 记录并停止
步骤 5 — 如果批准,应用补丁
bash
python3 ~/.openclaw/workspace/skills/kilocode-model-sync/scripts/applypatch.py path>
该脚本:
- 1. 使用时间戳备份 openclaw.json
- 将 models.providers.kilocode.models 替换为新列表
- 运行 openclaw gateway restart
- 轮询 openclaw gateway status 直到 RPC probe: ok(最长 30 秒)
结果字段:
- - status:ok \| appliedrestartfailed
- backup_path:备份的保存路径
- gateway.ok:true/false
- gateway.error:失败时的错误消息
步骤 6 — 写入任务控制条目
追加到 ~/.openclaw/workspace/memory/YYYY-MM-DD.md:
markdown
Kilocode 模型同步 — YYYY-MM-DD
- - 状态: 已应用 ✅
- 新增: N 个模型 — 列出 ID
- 移除: N 个模型 — 列出 ID
- 更新: N 个模型 — 列出 ID
- 备份: backup_path
- 网关重启: 成功 / 失败(错误消息)
- 批准人: Guillaume(通过 Telegram)
步骤 7 — 发送 Telegram 确认
✅ Kilocode 模型同步 — 已应用
{N} 个新模型已添加到 openclaw.json。
{N} 个模型已移除。
网关重启成功。 ✅
备份保存于:{backup_path}
如果网关重启失败:
⚠️ Kilocode 模型同步 — 补丁已应用,网关重启失败
模型已写入 openclaw.json,但网关未干净重启。
错误:{error}
请手动重启:openclaw gateway restart
步骤 8 — 向 Grog 报告摘要(sessions_send 到主会话)
完成后,向主代理会话发送一份简洁摘要,以便 Grog 在需要时转发给 Guillaume。
使用 sessions_send,设置 label=main 或 sessionKey=agent:main:main。
错误处理
- - 如果 syncmodels.py 退出状态为 error:通过 Telegram 通知 Guillaume 错误信息,停止。
- 如果 applypatch.py 无法写入配置:脚本会自动从备份恢复;报告失败。
- 如果网关未恢复:在 Telegram 中报告,告知 Guillaume 手动重启。
- 即使失败,也始终写入内存记录。