Skip to content

Commit e79556f

Browse files
authored
docs: sync with goclaw source changes c083622f..76385f2f (EN+VI+ZH) (#50)
- channels/telegram: add group-to-supergroup auto-migration section - providers/openrouter: add identification headers (HTTP-Referer, X-Title) - core-concepts/tools-overview: add deterministic ordering for prompt caching, hardened exec exemption matching (all-or-nothing, path traversal block, quote strip)
1 parent 376f1db commit e79556f

9 files changed

Lines changed: 114 additions & 9 deletions

File tree

channels/telegram.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,16 @@ Each Telegram instance maintains an isolated HTTP transport — no shared connec
291291
}
292292
```
293293

294+
## Group-to-Supergroup Migration
295+
296+
When a Telegram group is upgraded to a supergroup, the chat ID changes. GoClaw handles this automatically:
297+
298+
- **Inbound detection** — When a `MigrateToChatID` message arrives, GoClaw updates all DB references (paired_devices, sessions, channel_contacts) atomically and invalidates in-memory caches
299+
- **Send-path retry** — If a send fails because the group was migrated, GoClaw detects the new chat ID from the Telegram API error, updates DB, and retries the send automatically
300+
- **Idempotent** — Safe to trigger multiple times; duplicate migrations are no-ops
301+
302+
No configuration needed. Check logs for `telegram: migrating group chat` entries if troubleshooting.
303+
294304
## Troubleshooting
295305

296306
| Issue | Solution |
@@ -308,4 +318,4 @@ Each Telegram instance maintains an isolated HTTP transport — no shared connec
308318
- [Browser Pairing](/channel-browser-pairing) — Pairing flow
309319
- [Sessions & History](/sessions-and-history) — Conversation history
310320

311-
<!-- goclaw-source: c5bfbc96 | updated: 2026-04-02 -->
321+
<!-- goclaw-source: 76385f2f | updated: 2026-04-07 -->

core-concepts/tools-overview.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ GoClaw registers aliases so agents can reference tools by alternative names. Thi
9595

9696
Aliases appear as one-line descriptions in the system prompt. They are not separate tools — calling an alias invokes the underlying tool.
9797

98+
### Deterministic Ordering
99+
100+
All tool names, aliases, and MCP tool descriptions are sorted lexicographically before being included in the system prompt. This ensures identical prompt prefixes across requests, maximizing LLM prompt cache hit rates (Anthropic and OpenAI cache by exact prefix match).
101+
98102
## Policy Engine
99103

100104
Beyond profiles, a 7-step policy engine gives fine-grained control:
@@ -184,6 +188,16 @@ Admins can disable specific groups per agent:
184188
}
185189
```
186190

191+
### Hardened Exemption Matching
192+
193+
When a shell command matches a deny pattern, GoClaw checks path exemptions (e.g., `.goclaw/skills-store/`). The exemption logic is strict:
194+
195+
- **All-or-nothing** — Every field in the command that triggers the deny pattern must be individually covered by an exemption. A single unexempted field blocks the entire command
196+
- **Path traversal blocked** — Fields containing `..` are never exempt, preventing exemption escape via `../../etc/passwd`
197+
- **Quote stripping** — Surrounding quotes (`"`, `'`) are stripped before matching, since LLMs often quote paths
198+
199+
This prevents pipe/comment bypass attacks like `cat /app/data/skills-store/tool.py | cat /app/data/secret` — the second field matches deny but has no exemption, so the entire command is blocked.
200+
187201
The `tools.exec_approval` setting adds an additional approval layer (`full`, `light`, or `none`).
188202

189203
## spawn — Subagent Orchestration
@@ -255,4 +269,4 @@ All parameters are optional — defaults apply when not configured.
255269
- [Multi-Tenancy](/multi-tenancy) — Per-user tool access and isolation
256270
- [Custom Tools](/custom-tools) — Build your own tools
257271

258-
<!-- goclaw-source: c083622f | updated: 2026-04-05 -->
272+
<!-- goclaw-source: 76385f2f | updated: 2026-04-07 -->

providers/openrouter.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ To set a default model for OpenRouter in your agent config:
6262
}
6363
```
6464

65+
## Identification Headers
66+
67+
GoClaw automatically sends identification headers with every OpenRouter API request:
68+
69+
| Header | Value | Purpose |
70+
|---|---|---|
71+
| `HTTP-Referer` | `https://goclaw.sh` | Site identification for OpenRouter rankings |
72+
| `X-Title` | `GoClaw` | App name shown in OpenRouter analytics |
73+
74+
These headers are sent for both config-file and dashboard-registered OpenRouter providers. No configuration needed — they are applied automatically.
75+
6576
## Supported Features
6677

6778
OpenRouter passes through most features to the underlying model provider. Availability depends on the model:
@@ -90,4 +101,4 @@ OpenRouter passes through most features to the underlying model provider. Availa
90101
- [OpenAI](/provider-openai) — direct OpenAI integration
91102
- [Overview](/providers-overview) — provider architecture and retry logic
92103

93-
<!-- goclaw-source: 57754a5 | updated: 2026-03-18 -->
104+
<!-- goclaw-source: 76385f2f | updated: 2026-04-07 -->

vi/channels/telegram.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,16 @@ Mỗi Telegram instance duy trì HTTP transport riêng biệt — không share c
295295
}
296296
```
297297

298+
## Chuyển đổi Group sang Supergroup
299+
300+
Khi một Telegram group được nâng cấp thành supergroup, chat ID sẽ thay đổi. GoClaw xử lý tự động:
301+
302+
- **Phát hiện tin nhắn đến** — Khi nhận được message `MigrateToChatID`, GoClaw cập nhật tất cả tham chiếu DB (paired_devices, sessions, channel_contacts) atomically và xóa cache trong bộ nhớ
303+
- **Retry khi gửi** — Nếu gửi tin thất bại do group đã migrate, GoClaw phát hiện chat ID mới từ Telegram API error, cập nhật DB và tự động gửi lại
304+
- **Idempotent** — An toàn khi kích hoạt nhiều lần; các migration trùng lặp là no-op
305+
306+
Không cần cấu hình. Kiểm tra log với `telegram: migrating group chat` nếu cần troubleshoot.
307+
298308
## Xử lý sự cố
299309

300310
| Vấn đề | Giải pháp |
@@ -312,4 +322,4 @@ Mỗi Telegram instance duy trì HTTP transport riêng biệt — không share c
312322
- [Browser Pairing](/channel-browser-pairing) — Luồng pairing
313323
- [Sessions & History](/sessions-and-history) — Lịch sử cuộc trò chuyện
314324

315-
<!-- goclaw-source: c5bfbc96 | cập nhật: 2026-04-02 -->
325+
<!-- goclaw-source: 76385f2f | cập nhật: 2026-04-07 -->

vi/core-concepts/tools-overview.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ GoClaw đăng ký alias để agent có thể tham chiếu tool bằng tên khá
9797

9898
Alias xuất hiện dưới dạng mô tả một dòng trong system prompt. Chúng không phải tool riêng biệt — gọi alias sẽ kích hoạt tool gốc.
9999

100+
### Sắp xếp xác định (Deterministic Ordering)
101+
102+
Tất cả tên tool, alias và mô tả MCP tool được sắp xếp theo thứ tự chữ cái trước khi đưa vào system prompt. Điều này đảm bảo prompt prefix giống hệt nhau giữa các request, tối đa hóa tỷ lệ cache hit của LLM prompt (Anthropic và OpenAI cache theo exact prefix match).
103+
100104
## Policy Engine
101105

102106
Ngoài profile, policy engine 7 bước cho phép kiểm soát chi tiết:
@@ -186,6 +190,16 @@ Admin có thể tắt nhóm cụ thể theo từng agent:
186190
}
187191
```
188192

193+
### Kiểm tra Exemption nghiêm ngặt
194+
195+
Khi lệnh shell khớp deny pattern, GoClaw kiểm tra path exemption (ví dụ: `.goclaw/skills-store/`). Logic exemption rất chặt chẽ:
196+
197+
- **Tất cả hoặc không** — Mọi field trong lệnh khớp deny pattern đều phải được exemption riêng lẻ. Một field không được exempt sẽ chặn toàn bộ lệnh
198+
- **Chặn path traversal** — Field chứa `..` không bao giờ được exempt, ngăn chặn escape qua `../../etc/passwd`
199+
- **Loại bỏ dấu ngoặc** — Dấu ngoặc bao quanh (`"`, `'`) được loại trước khi so khớp, vì LLM thường đặt path trong ngoặc
200+
201+
Điều này ngăn chặn tấn công bypass qua pipe/comment như `cat /app/data/skills-store/tool.py | cat /app/data/secret` — field thứ hai khớp deny nhưng không có exemption, nên toàn bộ lệnh bị chặn.
202+
189203
Cài đặt `tools.exec_approval` thêm một lớp phê duyệt bổ sung (`full`, `light`, hoặc `none`).
190204

191205
## spawn — Điều phối Subagent
@@ -257,4 +271,4 @@ Tất cả tham số đều tùy chọn — giá trị mặc định áp dụng
257271
- [Multi-Tenancy](/multi-tenancy) — Truy cập tool per-user và cách ly
258272
- [Custom Tools](/custom-tools) — Xây dựng tool của riêng bạn
259273

260-
<!-- goclaw-source: c083622f | cập nhật: 2026-04-05 -->
274+
<!-- goclaw-source: 76385f2f | cập nhật: 2026-04-07 -->

vi/providers/openrouter.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ Logic `resolveModel()` của GoClaw áp dụng riêng cho OpenRouter:
6464
}
6565
```
6666

67+
## Header nhận dạng
68+
69+
GoClaw tự động gửi header nhận dạng với mọi request đến OpenRouter API:
70+
71+
| Header | Giá trị | Mục đích |
72+
|---|---|---|
73+
| `HTTP-Referer` | `https://goclaw.sh` | Nhận dạng site cho bảng xếp hạng OpenRouter |
74+
| `X-Title` | `GoClaw` | Tên app hiển thị trong OpenRouter analytics |
75+
76+
Các header này được gửi cho cả provider cấu hình qua config-file và dashboard. Không cần cấu hình — tự động áp dụng.
77+
6778
## Tính năng được hỗ trợ
6879

6980
OpenRouter chuyển tiếp hầu hết tính năng đến provider model bên dưới. Tính khả dụng phụ thuộc vào model:
@@ -92,4 +103,4 @@ OpenRouter chuyển tiếp hầu hết tính năng đến provider model bên d
92103
- [OpenAI](/provider-openai) — tích hợp trực tiếp OpenAI
93104
- [Tổng quan](/providers-overview) — kiến trúc provider và retry logic
94105

95-
<!-- goclaw-source: 57754a5 | cập nhật: 2026-03-18 -->
106+
<!-- goclaw-source: 76385f2f | cập nhật: 2026-04-07 -->

zh/channels/telegram.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,16 @@ Writer 是允许执行敏感命令(`/reset`、文件写入)的群组成员
295295
}
296296
```
297297

298+
## Group 升级为 Supergroup
299+
300+
当 Telegram group 升级为 supergroup 时,chat ID 会改变。GoClaw 自动处理此过程:
301+
302+
- **入站检测** — 收到 `MigrateToChatID` 消息时,GoClaw 原子性更新所有 DB 引用(paired_devices、sessions、channel_contacts)并清除内存缓存
303+
- **发送重试** — 若发送失败(因 group 已迁移),GoClaw 从 Telegram API 错误中检测新 chat ID,更新 DB 并自动重试
304+
- **幂等** — 多次触发安全;重复迁移为无操作
305+
306+
无需配置。排查时查看日志中的 `telegram: migrating group chat` 条目。
307+
298308
## 故障排查
299309

300310
| 问题 | 解决方案 |
@@ -312,4 +322,4 @@ Writer 是允许执行敏感命令(`/reset`、文件写入)的群组成员
312322
- [Browser Pairing](/channel-browser-pairing) — 配对流程
313323
- [Sessions & History](/sessions-and-history) — 会话历史
314324

315-
<!-- goclaw-source: c5bfbc96 | 更新: 2026-04-02 -->
325+
<!-- goclaw-source: 76385f2f | 更新: 2026-04-07 -->

zh/core-concepts/tools-overview.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ GoClaw 注册别名,让 agent 可以用替代名称引用工具。这实现了
9797

9898
别名在系统提示词中显示为单行描述。它们不是独立工具——调用别名会调用底层工具。
9999

100+
### 确定性排序
101+
102+
所有工具名称、别名和 MCP 工具描述在包含到系统提示词之前按字典序排序。这确保了跨请求的相同提示词前缀,最大化 LLM 提示词缓存命中率(Anthropic 和 OpenAI 按精确前缀匹配缓存)。
103+
100104
## 策略引擎
101105

102106
除了 profile,7 步策略引擎提供精细控制:
@@ -186,6 +190,16 @@ GoClaw 注册别名,让 agent 可以用替代名称引用工具。这实现了
186190
}
187191
```
188192

193+
### 强化豁免匹配
194+
195+
当 shell 命令匹配拒绝模式时,GoClaw 会检查路径豁免(如 `.goclaw/skills-store/`)。豁免逻辑非常严格:
196+
197+
- **全部或无** — 命令中触发拒绝模式的每个字段都必须单独被豁免覆盖。一个未豁免的字段将阻止整个命令
198+
- **阻止路径遍历** — 包含 `..` 的字段永远不会被豁免,防止通过 `../../etc/passwd` 绕过
199+
- **去除引号** — 匹配前去除包围的引号(`"``'`),因为 LLM 经常给路径加引号
200+
201+
这可防止 pipe/注释绕过攻击,如 `cat /app/data/skills-store/tool.py | cat /app/data/secret` — 第二个字段匹配拒绝模式但没有豁免,因此整个命令被阻止。
202+
189203
`tools.exec_approval` 设置添加额外的审批层(`full``light``none`)。
190204

191205
## spawn — 子 Agent 编排
@@ -253,4 +267,4 @@ GoClaw 追踪每个 session 中每个工具的执行时间。如果工具调用
253267
- [多租户](/multi-tenancy) — 每用户工具访问和隔离
254268
- [自定义工具](/custom-tools) — 构建你自己的工具
255269

256-
<!-- goclaw-source: c083622f | 更新: 2026-04-05 -->
270+
<!-- goclaw-source: 76385f2f | 更新: 2026-04-07 -->

zh/providers/openrouter.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ GoClaw 的 `resolveModel()` 逻辑专门针对 OpenRouter:
6464
}
6565
```
6666

67+
## 标识 Header
68+
69+
GoClaw 自动在每个 OpenRouter API 请求中发送标识 header:
70+
71+
| Header || 用途 |
72+
|---|---|---|
73+
| `HTTP-Referer` | `https://goclaw.sh` | OpenRouter 排名的站点标识 |
74+
| `X-Title` | `GoClaw` | OpenRouter analytics 中显示的应用名称 |
75+
76+
这些 header 同时适用于通过 config 文件和控制台注册的 OpenRouter provider。无需配置——自动应用。
77+
6778
## 支持的功能
6879

6980
OpenRouter 将大多数功能透传给底层模型 provider,可用性取决于模型:
@@ -92,4 +103,4 @@ OpenRouter 将大多数功能透传给底层模型 provider,可用性取决于
92103
- [OpenAI](/provider-openai) — 直接 OpenAI 集成
93104
- [概览](/providers-overview) — provider 架构和重试逻辑
94105

95-
<!-- goclaw-source: 57754a5 | 更新: 2026-03-18 -->
106+
<!-- goclaw-source: 76385f2f | 更新: 2026-04-07 -->

0 commit comments

Comments
 (0)