@dhf-openclaw/grix 0.4.10 → 0.4.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,75 +1,46 @@
1
- # OpenClaw Grix Unified Plugin
1
+ # OpenClaw Grix 插件
2
2
 
3
- This plugin connects OpenClaw to [https://grix.dhf.pub/](https://grix.dhf.pub/) and provides a single, unified integration for:
3
+ OpenClaw 接到 Grix 服务的统一插件,默认支持正式环境,也支持本地开发地址,包含:
4
4
 
5
- - Grix channel transport (WebSocket Agent API)
6
- - native message actions (`unsend` / `delete`)
7
- - typed Grix admin tools
8
- - operator CLI commands
9
- - bundled Grix workflow skills
5
+ - Grix Channel(收发消息、流式回复、`unsend`、`delete`)
6
+ - 管理工具:`grix_query`、`grix_group`、`grix_agent_admin`
7
+ - 运维命令:`openclaw grix doctor`、`openclaw grix create-agent`
8
+ - 内置技能包(`skills/`)
10
9
 
11
- Compatibility:
10
+ ## 兼容性
12
11
 
13
- - Requires `OpenClaw >= 2026.3.13`
12
+ - `OpenClaw >= 2026.3.23-1`
14
13
 
15
- ## Included Capability
14
+ ## 5 分钟安装(推荐)
16
15
 
17
- After installation, one plugin covers all major Grix workflows:
18
-
19
- - Channel runtime:
20
- - inbound message receive
21
- - outbound reply / media / streaming chunk send
22
- - native channel actions (`unsend`, `delete`)
23
- - Typed admin tools:
24
- - `grix_query`
25
- - `grix_group`
26
- - `grix_agent_admin`
27
- - Operator CLI:
28
- - `openclaw grix doctor`
29
- - `openclaw grix create-agent ...`
30
- - Bundled skills:
31
- - `message-send`
32
- - `message-unsend`
33
- - `egg-install`
34
- - `grix-query`
35
- - `grix-group-governance`
36
- - `grix-agent-admin`
37
-
38
- ## Install
16
+ ### 1) 安装并启用插件
39
17
 
40
18
  ```bash
41
19
  openclaw plugins install @dhf-openclaw/grix
42
20
  openclaw plugins enable grix
43
- openclaw gateway restart
44
21
  ```
45
22
 
46
- ### Local Source Checkout
23
+ ### 2) 绑定 Grix Channel
47
24
 
48
- If you load from a local checkout:
25
+ 用你已有的 Grix API agent 信息执行:
49
26
 
50
27
  ```bash
51
- npm install
52
- openclaw plugins install ./grix.ts
28
+ openclaw channels add \
29
+ --channel grix \
30
+ --name grix-main \
31
+ --http-url "wss://<YOUR_GRIX_HOST>/v1/agent-api/ws?agent_id={agent_id}" \
32
+ --user-id "<YOUR_AGENT_ID>" \
33
+ --token "<YOUR_API_KEY>"
53
34
  ```
54
35
 
55
- ## Required OpenClaw Config
36
+ 说明:
56
37
 
57
- ### Channel Config (`channels.grix`)
38
+ - `--http-url` 可以带 `agent_id`,也可以不带。不带时会自动按 `--user-id` 补上。
39
+ - `--name` 是本地账户名,可自定义(如 `ops`、`prod`)。
58
40
 
59
- ```json
60
- {
61
- "channels": {
62
- "grix": {
63
- "enabled": true,
64
- "wsUrl": "wss://grix.dhf.pub/v1/agent-api/ws?agent_id=<YOUR_AGENT_ID>",
65
- "agentId": "<YOUR_AGENT_ID>",
66
- "apiKey": "<YOUR_API_KEY>"
67
- }
68
- }
69
- }
70
- ```
41
+ ### 3) 开放工具权限
71
42
 
72
- ### Tool Exposure Config
43
+ OpenClaw 配置里确保有:
73
44
 
74
45
  ```json
75
46
  {
@@ -88,77 +59,182 @@ openclaw plugins install ./grix.ts
88
59
  }
89
60
  ```
90
61
 
91
- Full example:
62
+ ### 4) 重启网关
63
+
64
+ ```bash
65
+ openclaw gateway restart
66
+ ```
67
+
68
+ ### 5) 验证安装结果
69
+
70
+ ```bash
71
+ openclaw plugins info grix --json
72
+ openclaw grix doctor
73
+ openclaw skills list
74
+ ```
75
+
76
+ 预期:
77
+
78
+ - `grix` 插件已启用
79
+ - `doctor` 能看到可用账户
80
+ - `skills list` 能看到本插件内置技能
81
+
82
+ ## 配置参数说明(完整)
83
+
84
+ `channels.grix` 支持“单账户”或“多账户(accounts)”两种写法。
85
+
86
+ ### 最小可用配置(单账户)
87
+
88
+ 线上发布示例:
92
89
 
93
90
  ```json
94
91
  {
95
92
  "channels": {
96
93
  "grix": {
97
94
  "enabled": true,
98
- "wsUrl": "wss://grix.dhf.pub/v1/agent-api/ws?agent_id=<YOUR_AGENT_ID>",
95
+ "wsUrl": "wss://<YOUR_GRIX_HOST>/v1/agent-api/ws?agent_id=<YOUR_AGENT_ID>",
96
+ "apiBaseUrl": "https://<YOUR_GRIX_HOST>/v1/agent-api",
99
97
  "agentId": "<YOUR_AGENT_ID>",
100
98
  "apiKey": "<YOUR_API_KEY>"
101
99
  }
102
- },
103
- "tools": {
104
- "profile": "coding",
105
- "alsoAllow": [
106
- "message",
107
- "grix_query",
108
- "grix_group",
109
- "grix_agent_admin"
110
- ],
111
- "sessions": {
112
- "visibility": "agent"
113
- }
114
100
  }
115
101
  }
116
102
  ```
117
103
 
118
- After any config change:
104
+ 本地开发示例:
119
105
 
120
- ```bash
121
- openclaw gateway restart
106
+ ```json
107
+ {
108
+ "channels": {
109
+ "grix": {
110
+ "enabled": true,
111
+ "wsUrl": "ws://127.0.0.1:27189/v1/agent-api/ws?agent_id=<YOUR_AGENT_ID>",
112
+ "apiBaseUrl": "http://127.0.0.1:27180/v1/agent-api",
113
+ "agentId": "<YOUR_AGENT_ID>",
114
+ "apiKey": "<YOUR_API_KEY>"
115
+ }
116
+ }
117
+ }
122
118
  ```
123
119
 
124
- ## Typed Tools
120
+ ### 多账户配置示例
125
121
 
126
- ### `grix_query`
127
-
128
- Supported actions:
122
+ ```json
123
+ {
124
+ "channels": {
125
+ "grix": {
126
+ "enabled": true,
127
+ "defaultAccount": "ops",
128
+ "accounts": {
129
+ "ops": {
130
+ "enabled": true,
131
+ "name": "Ops",
132
+ "wsUrl": "ws://127.0.0.1:27189/v1/agent-api/ws?agent_id=<OPS_AGENT_ID>",
133
+ "apiBaseUrl": "http://127.0.0.1:27180/v1/agent-api",
134
+ "agentId": "<OPS_AGENT_ID>",
135
+ "apiKey": "<OPS_API_KEY>"
136
+ },
137
+ "prod": {
138
+ "enabled": true,
139
+ "wsUrl": "wss://<YOUR_GRIX_HOST>/v1/agent-api/ws?agent_id=<PROD_AGENT_ID>",
140
+ "apiBaseUrl": "https://<YOUR_GRIX_HOST>/v1/agent-api",
141
+ "agentId": "<PROD_AGENT_ID>",
142
+ "apiKey": "<PROD_API_KEY>"
143
+ }
144
+ }
145
+ }
146
+ }
147
+ }
148
+ ```
129
149
 
130
- - `contact_search`
131
- - `session_search`
132
- - `message_history`
150
+ ### 字段说明
151
+
152
+ | 字段 | 必填 | 默认值 | 说明 |
153
+ | --- | --- | --- | --- |
154
+ | `enabled` | 否 | `true` | 全局开关。设为 `false` 后该通道停用。 |
155
+ | `defaultAccount` | 否 | 自动选择 | 多账户时默认账户 ID。 |
156
+ | `accounts.<id>` | 否 | - | 多账户配置项,`<id>` 自定义(如 `ops`)。 |
157
+ | `name` | 否 | - | 账户显示名。 |
158
+ | `wsUrl` | 是(可用环境变量兜底) | `ws://127.0.0.1:27189/...`(当有 `agentId` 且未填时) | Grix WebSocket 地址。 |
159
+ | `apiBaseUrl` | 否(可用环境变量兜底) | 优先使用显式配置;否则按同一账号的 `wsUrl` 推导;本地 `ws://127.0.0.1:27189/...` 会默认映射成 `http://127.0.0.1:27180/v1/agent-api`;只有账号自己既没配 `apiBaseUrl` 也没配 `wsUrl` 时,才回退环境变量 | Grix HTTP API 地址。开发时可单独指向本地后端。 |
160
+ | `agentId` | 是(可用环境变量兜底) | - | Grix agent ID。 |
161
+ | `apiKey` | 是(可用环境变量兜底) | - | Grix API Key。 |
162
+ | `reconnectMs` | 否 | `2000` | 重连基础延迟(毫秒)。 |
163
+ | `reconnectMaxMs` | 否 | `max(30000, reconnectMs*8)` | 重连最大延迟(毫秒)。 |
164
+ | `reconnectStableMs` | 否 | `30000` | 连接保持多久算“稳定”(毫秒)。 |
165
+ | `connectTimeoutMs` | 否 | `10000` | 建连超时(毫秒)。 |
166
+ | `keepalivePingMs` | 否 | 自动计算 | 心跳发送间隔(毫秒)。 |
167
+ | `keepaliveTimeoutMs` | 否 | 自动计算 | 心跳超时阈值(毫秒)。 |
168
+ | `upstreamRetryMaxAttempts` | 否 | `3` | 上游发送失败重试次数(1-5)。 |
169
+ | `upstreamRetryBaseDelayMs` | 否 | `300` | 上游重试基础延迟(毫秒)。 |
170
+ | `upstreamRetryMaxDelayMs` | 否 | `2000` | 上游重试最大延迟(毫秒)。 |
171
+ | `maxChunkChars` | 否 | `1200` | 普通回复分片长度上限(最大 2000)。 |
172
+ | `streamChunkChars` | 否 | `48` | 流式回复分片长度上限(最大 2000)。 |
173
+ | `streamChunkDelayMs` | 否 | `0` | 流式分片发送间隔(毫秒)。 |
174
+ | `dmPolicy` | 否 | `open` | 私聊策略:`open` / `pairing` / `allowlist` / `disabled`。 |
175
+ | `allowFrom` | 否 | `[]` | 白名单发送者列表(配合 `dmPolicy=allowlist`)。 |
176
+ | `defaultTo` | 否 | - | 默认发送目标会话。 |
177
+ | `execApprovals.enabled` | 否 | `false` | 是否启用聊天内执行审批。 |
178
+ | `execApprovals.approvers` | 条件必填 | `[]` | 审批人 sender ID 列表。启用审批时需填写。 |
179
+
180
+ ### 环境变量兜底
181
+
182
+ 如果配置文件没填,插件会按下列环境变量读取:
183
+
184
+ - `GRIX_WS_URL`
185
+ - `GRIX_AGENT_API_BASE`
186
+ - `GRIX_WEB_BASE_URL`
187
+ - `GRIX_AGENT_ID`
188
+ - `GRIX_API_KEY`
189
+
190
+ 注册脚本默认使用正式环境地址;如果要切到本地或其他部署,可额外设置:
191
+
192
+ - `GRIX_WEB_BASE_URL`
193
+
194
+ 说明:
195
+
196
+ - `grix_query`、`grix_group`、`grix_agent_admin` 这些 HTTP 请求会优先使用当前账号自己的 `apiBaseUrl`。
197
+ - 如果当前账号没配 `apiBaseUrl`,会先按当前账号自己的 `wsUrl` 自动推导。
198
+ - 只有当前账号自己既没配 `apiBaseUrl`,也没提供可用的 `wsUrl` 时,才会回退到 `GRIX_AGENT_API_BASE` 或 `GRIX_WEB_BASE_URL`。
199
+ - `skills/grix-register/scripts/grix_auth.py` 会优先读取 `GRIX_WEB_BASE_URL`,再回落到正式环境地址;插件运行时也会把它当作 HTTP 基地址兜底。
200
+ - 多账号混用不同环境时,不建议设置全局 `GRIX_AGENT_API_BASE` / `GRIX_WEB_BASE_URL`,否则容易把一个账号的 HTTP 请求导到另一个环境。
201
+ - 本地开发最稳妥的写法是同时配置:
133
202
 
134
- ### `grix_group`
203
+ ```json
204
+ {
205
+ "channels": {
206
+ "grix": {
207
+ "wsUrl": "ws://127.0.0.1:27189/v1/agent-api/ws?agent_id=<YOUR_AGENT_ID>",
208
+ "apiBaseUrl": "http://127.0.0.1:27180/v1/agent-api",
209
+ "agentId": "<YOUR_AGENT_ID>",
210
+ "apiKey": "<YOUR_API_KEY>"
211
+ }
212
+ }
213
+ }
214
+ ```
135
215
 
136
- Supported actions:
216
+ ## 工具与命令
137
217
 
138
- - `create`
139
- - `detail`
140
- - `add_members`
141
- - `remove_members`
142
- - `update_member_role`
143
- - `update_all_members_muted`
144
- - `update_member_speaking`
145
- - `dissolve`
218
+ ### Agent 可调用工具
146
219
 
147
- ### `grix_agent_admin`
220
+ - `grix_query`:`contact_search`、`session_search`、`message_history`
221
+ - `grix_group`:`create`、`detail`、`leave`、`add_members`、`remove_members`、`update_member_role`、`update_all_members_muted`、`update_member_speaking`、`dissolve`
222
+ - `grix_agent_admin`:创建 `provider_type=3` 的 Grix API agent(只创建远端 agent,不会直接改本地 `channels.grix`)
148
223
 
149
- Creates `provider_type=3` API agents with typed parameters.
224
+ 工具调用约束:
150
225
 
151
- This tool creates the remote Grix API agent only. It does not directly mutate local OpenClaw channel config.
226
+ - 以上三个工具都必须显式传入 `accountId`。
227
+ - 如果工具调用上下文存在当前连接账号,则 `accountId` 必须与上下文账号一致;不一致会直接拒绝执行。
152
228
 
153
- ## Operator CLI
229
+ ### 运维命令
154
230
 
155
- ### Inspect Grix accounts
231
+ 查看账户:
156
232
 
157
233
  ```bash
158
234
  openclaw grix doctor
159
235
  ```
160
236
 
161
- ### Create API agent
237
+ 创建 API agent
162
238
 
163
239
  ```bash
164
240
  openclaw grix create-agent \
@@ -166,19 +242,18 @@ openclaw grix create-agent \
166
242
  --describe-message-tool '{"actions":["unsend","delete"]}'
167
243
  ```
168
244
 
169
- `create-agent` prints:
170
-
171
- - created agent payload
172
- - one-time API key in result payload
173
- - safe next-step channel binding command template
245
+ 参数说明:
174
246
 
175
- `--describe-message-tool` is required and must follow OpenClaw `describeMessageTool` discovery structure.
247
+ - `--agent-name`:必填,小写字母开头,只允许小写字母、数字、`-`,长度 3-32。
248
+ - `--describe-message-tool`:必填,JSON 对象,至少包含 `actions` 数组。
249
+ - `--account-id`:可选,指定用哪个本地 Grix 账户发起创建。
250
+ - `--avatar-url`:可选,给新 agent 设置头像地址。
176
251
 
177
- ## Exec Approvals
252
+ 命令输出里会给出一次性 `api_key` 和下一步绑定命令模板。
178
253
 
179
- Grix can approve OpenClaw host `exec` requests in chat.
254
+ ## 聊天内 Exec 审批(可选)
180
255
 
181
- ### 1. Configure Grix approvers
256
+ 先在 Grix 账户里配置审批人:
182
257
 
183
258
  ```json
184
259
  {
@@ -193,26 +268,7 @@ Grix can approve OpenClaw host `exec` requests in chat.
193
268
  }
194
269
  ```
195
270
 
196
- If using named accounts:
197
-
198
- ```json
199
- {
200
- "channels": {
201
- "grix": {
202
- "accounts": {
203
- "ops": {
204
- "execApprovals": {
205
- "enabled": true,
206
- "approvers": ["<GRIX_SENDER_ID>"]
207
- }
208
- }
209
- }
210
- }
211
- }
212
- }
213
- ```
214
-
215
- ### 2. Enable OpenClaw exec approvals
271
+ 再开启 OpenClaw exec 审批:
216
272
 
217
273
  ```json
218
274
  {
@@ -228,58 +284,18 @@ If using named accounts:
228
284
  "enabled": true,
229
285
  "mode": "session"
230
286
  }
231
- },
232
- "channels": {
233
- "grix": {
234
- "execApprovals": {
235
- "enabled": true,
236
- "approvers": ["<GRIX_SENDER_ID>"]
237
- }
238
- }
239
287
  }
240
288
  }
241
289
  ```
242
290
 
243
- Mode choices:
291
+ `mode` 说明:
244
292
 
245
- - `session`: send approval prompt to current Grix chat
246
- - `targets`: send approval prompt to configured `approvals.exec.targets`
247
- - `both`: send to both
293
+ - `session`:发到当前会话
294
+ - `targets`:发到 `approvals.exec.targets`
295
+ - `both`:两边都发
248
296
 
249
- ### 3. Restart
297
+ 配置改完后重启:
250
298
 
251
299
  ```bash
252
300
  openclaw gateway restart
253
301
  ```
254
-
255
- ### 4. Approve in chat
256
-
257
- Flow:
258
-
259
- 1. Ask OpenClaw to run an `exec` command that needs approval.
260
- 2. OpenClaw sends approval prompt to Grix.
261
- 3. An allowed approver can:
262
- - click `Allow Once`, `Allow Always`, or `Deny`
263
- - or send `/approve <id> allow-once|allow-always|deny`
264
- 4. OpenClaw continues or denies execution.
265
-
266
- Notes:
267
-
268
- - approvers must be Grix sender IDs, not OpenClaw agent IDs
269
- - configure approvers under the serving account
270
- - approval requests and results are posted in chat
271
-
272
- ## Verification
273
-
274
- ```bash
275
- openclaw plugins info grix --json
276
- openclaw skills list
277
- openclaw grix doctor
278
- ```
279
-
280
- Expected:
281
-
282
- - plugin `grix` is enabled and loaded
283
- - typed tools are callable when `tools.alsoAllow` is configured
284
- - bundled skills are visible in skills list
285
- - `openclaw grix doctor` can read configured `channels.grix` accounts