grix-connector 3.29.2 → 3.30.0

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.
@@ -1,28 +1,21 @@
1
- # API Contract
1
+ # API Contract for OpenClaw
2
2
 
3
3
  ## Purpose
4
4
 
5
- `grix-admin` is responsible for local binding and runtime convergence, and when the current agent has the corresponding scope, supports completing the following through `grix_admin` via WS:
6
-
7
- 1. Create new remote API agents
8
- 2. Query agent categories under the current account
9
- 3. Create categories
10
- 4. Modify categories
11
- 5. Assign or clear categories for specified agents
5
+ This contract covers remote Agent and category administration through `grix_admin`, followed by local OpenClaw binding when required.
12
6
 
13
7
  ## Base Rules
14
8
 
15
- 1. Do not ask users to provide website account/password for this flow.
16
- 2. All remote creation and category actions must go through `grix_admin` via the current account's authenticated WS channel.
17
- 3. If `agent_name` / `agent_id` / `api_endpoint` / `api_key` are incomplete, and the current account cannot create remotely, stop first and require backend admin to complete them.
18
- 4. The current agent must first have the corresponding scope enabled on the frontend permissions page; without scope, WS will fail directly.
19
- 5. For `bind-local` / `create-and-bind` / `connector-bind-local` / `create-and-connector-bind`, "config written successfully" does not equal completion; if this invocation already has real routing verification conditions, real verification passing must also be counted as part of the success criteria; otherwise explicitly hand the subsequent verification responsibility back to the upper-level flow.
20
- 6. Before remote creation, require a concrete Agent name and a professional introduction based on the user's stated purpose, responsibilities, intended users or scenarios, operating expectations, and boundaries. If those details are missing, ask the user before calling the API.
21
- 7. Always send the finalized behavioral description in the actual `introduction` field of `action=create_agent`; never substitute a chat summary, `soulContent`, or local persona file for this API field.
9
+ 1. Do not ask users for a website account or password.
10
+ 2. Perform remote creation and category actions through `grix_admin` on the current account's authenticated WS channel.
11
+ 3. Require a concrete `agentName` and professional `introduction` before remote creation.
12
+ 4. If agent parameters are incomplete and the current account cannot create remotely, require backend admin creation first.
13
+ 5. Report the exact missing scope when the service returns `code=4003`.
14
+ 6. Static config writing alone is not full convergence when real routing verification is available.
22
15
 
23
- ## Direct `grix_admin` Contract
16
+ ## Direct Actions
24
17
 
25
- ### 1. Create Remote Agent
18
+ ### Create Agent
26
19
 
27
20
  ```json
28
21
  {
@@ -36,33 +29,14 @@
36
29
  }
37
30
  ```
38
31
 
39
- Key fields to read from the return:
40
-
41
- 1. `createdAgent.id`
42
- 2. `createdAgent.agent_name`
43
- 3. `createdAgent.api_endpoint`
44
- 4. `createdAgent.api_key`
45
-
46
- Required scope:
47
-
48
- 1. `agent.api.create`
49
- 2. If `categoryName` is included, may additionally need `agent.category.list`, `agent.category.create`, `agent.category.assign`
50
- 3. If `categoryId` is included, additionally needs `agent.category.assign`
32
+ Read `createdAgent.id`, `createdAgent.agent_name`, `createdAgent.api_endpoint`, and `createdAgent.api_key` from the result. Required scope is `agent.api.create`, plus category scopes when category fields are supplied.
51
33
 
52
- ### 2. List Categories
34
+ ### Category Actions
53
35
 
54
36
  ```json
55
- {
56
- "action": "list_categories"
57
- }
37
+ { "action": "list_categories" }
58
38
  ```
59
39
 
60
- Required scope:
61
-
62
- 1. `agent.category.list`
63
-
64
- ### 3. Create Category
65
-
66
40
  ```json
67
41
  {
68
42
  "action": "create_category",
@@ -72,12 +46,6 @@ Required scope:
72
46
  }
73
47
  ```
74
48
 
75
- Required scope:
76
-
77
- 1. `agent.category.create`
78
-
79
- ### 4. Update Category
80
-
81
49
  ```json
82
50
  {
83
51
  "action": "update_category",
@@ -88,12 +56,6 @@ Required scope:
88
56
  }
89
57
  ```
90
58
 
91
- Required scope:
92
-
93
- 1. `agent.category.update`
94
-
95
- ### 5. Assign or Clear Category
96
-
97
59
  ```json
98
60
  {
99
61
  "action": "assign_category",
@@ -102,89 +64,26 @@ Required scope:
102
64
  }
103
65
  ```
104
66
 
105
- Clear category:
67
+ Use `categoryId: "0"` to clear an assignment. Required scopes are `agent.category.list`, `agent.category.create`, `agent.category.update`, and `agent.category.assign` respectively.
106
68
 
107
- ```json
108
- {
109
- "action": "assign_category",
110
- "agentId": "10001",
111
- "categoryId": "0"
112
- }
113
- ```
114
-
115
- Required scope:
116
-
117
- 1. `agent.category.assign`
118
-
119
- ## Local Bind Steps
120
-
121
- After remote agent parameters are complete, continue with local binding. The target environment determines which path to follow.
122
-
123
- ### Path A: OpenClaw
69
+ ## Local Binding
124
70
 
125
71
  Use official OpenClaw CLI commands:
126
72
 
127
- 1. Prepare local directories:
128
- - `workspace=~/.openclaw/workspace-<agent_name>`
129
- - `agentDir=~/.openclaw/agents/<agent_name>/agent`
130
- - Add minimal `IDENTITY.md`, `SOUL.md`, `AGENTS.md` when required persona files are missing
131
- 2. Resolve `model` in this order:
132
- - The existing `model` from that local agent's entry
133
- - `agents.defaults.model.primary`
134
- - If still unavailable, clearly report error and stop
135
- 3. Read current config and merge:
136
- - `channels.grix.accounts`
137
- - `agents.list`
138
- - `tools.profile`
139
- - `tools.alsoAllow`
140
- - `tools.sessions.visibility`
141
- 4. Write back using official CLI:
142
- - `channels.grix.accounts.<agent_name>`
143
- - `agents.list`
144
- - `openclaw agents bind --agent <agent_name> --bind grix:<agent_name>`
145
- - `tools.profile`
146
- - `tools.alsoAllow`
147
- - `tools.sessions.visibility`
148
- - If needed, restore `channels.grix.enabled=true`
149
- 5. After writing, perform static validation first:
73
+ 1. Prepare `~/.openclaw/workspace-<agent_name>` and `~/.openclaw/agents/<agent_name>/agent`.
74
+ 2. Keep persona files in the workspace root and create minimal required files if missing.
75
+ 3. Resolve the model from the existing agent entry, then `agents.defaults.model.primary`; stop if neither exists.
76
+ 4. Merge the Grix account and agent entries, bind the agent to `grix:<agent_name>`, configure the coding profile and required Grix tools, and restore `channels.grix.enabled=true` only when explicitly disabled.
77
+ 5. Do not overwrite `openclaw.json` directly.
78
+ 6. Validate with:
150
79
  - `openclaw config validate`
151
80
  - `openclaw config get --json channels.grix.accounts.<agent_name>`
152
81
  - `openclaw config get --json agents.list`
153
82
  - `openclaw agents bindings --agent <agent_name> --json`
154
- 6. If this invocation already has real verification conditions, must immediately perform a real routing verification; reuse the current install/acceptance context, do not invent additional probes. Reply falling to the main agent, default assistant, old persona, or old config are all considered failures.
155
- 7. Only when step 5 static validation passes and this invocation itself handles step 6 real verification but verification fails, is one `openclaw gateway restart` allowed; after restart, must redo the same round of real routing verification.
156
- 8. If this invocation cannot perform real verification, can only state "config has been written, runtime not yet tested, needs subsequent flow to continue verification"; do not write it as "already fully taken effect".
157
-
158
- ### Path B: grix-connector
159
-
160
- Directly manage `~/.grix/config/agents.json` and hot-reload the daemon:
161
-
162
- 1. Target file: `~/.grix/config/agents.json`. Initialize as `{ "agents": [] }` if missing.
163
- 2. Read the existing `agents` array. Match by `name === agent_name`:
164
- - If found, update the existing entry in place.
165
- - If not found, append a new entry.
166
- 3. Write the entry with these fields:
167
- - `name`: `agent_name`
168
- - `ws_url`: `api_endpoint`
169
- - `agent_id`: `agent_id`
170
- - `api_key`: `api_key`
171
- - `client_type`: `client_type` (default `pi`)
172
- 4. Preserve valid JSON, set file permissions to `0o600`, and create a timestamped backup (also `0o600`) before writing.
173
- 5. Trigger reload through the synchronous Admin API:
174
- - Default endpoint: `POST http://127.0.0.1:19580/api/reload`
175
- - The endpoint waits for `manager.reload()` to complete and returns `{ ok: true, result }` or an error. Use this instead of the CLI `grix-connector reload` to avoid races and to surface reload failures.
176
- - If the admin port was customized via `GRIX_ADMIN_PORT` or `--admin-port`, read the actual port from `~/.grix/data/admin-port`.
177
- 6. Verify via Admin API `GET http://127.0.0.1:<admin-port>/api/agents`:
178
- - Find entry where `name === agent_name`.
179
- - Confirm the entry exists and reports `alive === true`.
180
- - **Caveat**: `alive=true` only means the daemon started the instance. It does **not** prove the Agent successfully authenticated with the Grix platform.
181
- 7. Perform secondary platform-connection verification:
182
- - Inspect daemon logs for WebSocket connection success / authentication failure messages for this Agent.
183
- - Or ask the owner to send a test message to the Agent and confirm it responds.
184
- 8. If verification fails, report the observed status and stop; do not claim success.
185
- 9. If this invocation cannot perform real verification, can only state "config has been written, reload completed, runtime not yet tested"; do not write it as "already fully taken effect".
83
+ 7. When real routing verification is available, verify the target identity, persona, and binding.
84
+ 8. Only when static validation passes but real verification fails may one `openclaw gateway restart` be used, followed by one retest.
186
85
 
187
- ## `bind-local` Input Contract
86
+ ## `bind-local`
188
87
 
189
88
  ```json
190
89
  {
@@ -192,37 +91,9 @@ Directly manage `~/.grix/config/agents.json` and hot-reload the daemon:
192
91
  }
193
92
  ```
194
93
 
195
- This mode prioritizes local binding; if this invocation has real verification conditions, must also complete real routing verification before it counts as full convergence; otherwise only complete static binding and explicitly hand subsequent verification responsibility to the upper-level flow.
94
+ This mode performs local binding only. If real routing verification is unavailable, report static completion and hand verification responsibility back to the upper-level flow.
196
95
 
197
- ## `connector-bind-local` Input Contract
198
-
199
- ```json
200
- {
201
- "task": "connector-bind-local\nagent_name=programmer-pi\nagent_id=2079349263263338496\napi_endpoint=wss://grix.dhf.pub/v1/agent-api/ws?agent_id=2079349263263338496\napi_key=ak_xxx\nclient_type=pi"
202
- }
203
- ```
204
-
205
- Field mapping to `~/.grix/config/agents.json`:
206
-
207
- | Input field | JSON field | Notes |
208
- | -------------- | ------------ | ------------------------------------------ |
209
- | `agent_name` | `name` | Also used as the matching key |
210
- | `api_endpoint` | `ws_url` | The WebSocket URL for the agent API |
211
- | `agent_id` | `agent_id` | Platform agent ID |
212
- | `api_key` | `api_key` | Agent API key |
213
- | `client_type` | `client_type`| Optional, default `pi` |
214
-
215
- Convergence rules:
216
-
217
- 1. Backup `~/.grix/config/agents.json` before writing; set backup permissions to `0o600`.
218
- 2. Preserve valid JSON and set file permissions to `0o600`.
219
- 3. Trigger reload via synchronous Admin API `POST http://127.0.0.1:19580/api/reload` (or the port stored in `~/.grix/data/admin-port` if customized).
220
- 4. Verify via `GET http://127.0.0.1:<admin-port>/api/agents` that the entry exists and has `alive=true`.
221
- 5. Perform secondary platform-connection verification by checking daemon logs or sending a test message; do not treat `alive=true` as proof of successful platform authentication.
222
-
223
- ## `create-and-bind` Input Contract
224
-
225
- When the main agent already has an available account and `agent.api.create` scope, can enter the creation flow through `grix_admin.task`:
96
+ ## `create-and-bind`
226
97
 
227
98
  ```json
228
99
  {
@@ -230,52 +101,16 @@ When the main agent already has an available account and `agent.api.create` scop
230
101
  }
231
102
  ```
232
103
 
233
- This mode requires steps in order:
234
-
235
- 1. Confirm `agentName` and a professionally organized `introduction` are both present; otherwise ask the user about the Agent's purpose, core responsibilities, intended users, and boundaries before continuing
236
- 2. First make one direct call with `action=create_agent`, passing `agentName`, `introduction`, and optional `categoryId` / `categoryName` / `parentCategoryId` / `categorySortOrder` together
237
- 3. If the return already includes the category assignment result, continue directly
238
- 4. If the caller used a legacy path, or the return does not include the category assignment result, supplement with:
239
- - `categoryId` -> `action=assign_category`
240
- - `categoryName` -> `action=list_categories`
241
- - Not found -> `action=create_category`
242
- - After obtaining category ID -> `action=assign_category`
243
- 5. Finally follow the same local binding and runtime convergence flow as `bind-local`
244
-
245
- Notes:
246
-
247
- 1. `categoryId` and `categoryName` cannot be provided simultaneously
248
- 2. When matching `categoryName`, must also consider `parentCategoryId`
249
- 3. If the remote return indicates missing `agent.api.create` or any `agent.category.*` scope, clearly state which specific scope is missing
250
-
251
- ## `create-and-connector-bind` Input Contract
252
-
253
- When the main agent already has an available account and `agent.api.create` scope, and the target runtime is grix-connector:
254
-
255
- ```json
256
- {
257
- "task": "create-and-connector-bind\nagentName=程序员 pi\nintroduction=专业软件工程 Agent,负责分析需求、设计实现、编写并验证代码;涉及破坏性操作或需求边界不明确时先请求确认。\nisMain=false\nclientType=pi\ncategoryName=Developers\nparentCategoryId=0\ncategorySortOrder=10"
258
- }
259
- ```
260
-
261
- This mode requires steps in order:
262
-
263
- 1. Confirm `agentName` and a professionally organized `introduction` are both present; otherwise ask the user about the Agent's purpose, core responsibilities, intended users, and boundaries before continuing.
264
- 2. Make one direct call with `action=create_agent`, passing `agentName`, `introduction`, and optional `categoryId` / `categoryName` / `parentCategoryId` / `categorySortOrder` together.
265
- 3. If the return already includes the category assignment result, continue directly; otherwise supplement with the same category resolution logic as `create-and-bind`.
266
- 4. Read `createdAgent.id`, `createdAgent.agent_name`, `createdAgent.api_endpoint`, `createdAgent.api_key` from the result.
267
- 5. Follow the `connector-bind-local` local binding and runtime convergence flow, using `clientType` (default `pi`) for the `client_type` field.
268
- 6. Trigger reload via the synchronous Admin API `POST /api/reload`, verify the Agent entry exists and `alive=true` via `GET /api/agents`, and perform secondary platform-connection verification (log inspection or test message).
269
-
270
- Notes:
271
-
272
- 1. `categoryId` and `categoryName` cannot be provided simultaneously.
273
- 2. `clientType` defaults to `pi` when omitted.
274
- 3. If the remote return indicates missing `agent.api.create` or any `agent.category.*` scope, clearly state which specific scope is missing.
104
+ Execution order:
275
105
 
276
- ## `category-manage` Input Contract
106
+ 1. Validate `agentName`, `introduction`, and category-field exclusivity.
107
+ 2. Call `action=create_agent` once with all supplied creation and category fields.
108
+ 3. Supplement category resolution only if the response did not complete it.
109
+ 4. Read the returned agent parameters.
110
+ 5. Continue with `bind-local`.
111
+ 6. Complete static validation and any available real routing verification before claiming full convergence.
277
112
 
278
- When only doing subsequent category management, enter through `grix_admin.task`:
113
+ ## `category-manage`
279
114
 
280
115
  ```json
281
116
  {
@@ -283,15 +118,4 @@ When only doing subsequent category management, enter through `grix_admin.task`:
283
118
  }
284
119
  ```
285
120
 
286
- Mapping:
287
-
288
- 1. `operation=list` -> `action=list_categories`
289
- 2. `operation=create` -> `action=create_category`
290
- 3. `operation=update` -> `action=update_category`
291
- 4. `operation=assign` -> `action=assign_category`
292
-
293
- Notes:
294
-
295
- 1. For `operation=assign`, `categoryId=0` means clear the category
296
- 2. No step can be executed cross-account
297
- 3. Do not hand-write HTTP or fall back to legacy scripts
121
+ Map `list`, `create`, `update`, and `assign` to their corresponding direct actions. Never execute across accounts or fall back to handwritten HTTP.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grix-connector",
3
- "version": "3.29.2",
3
+ "version": "3.30.0",
4
4
  "description": "Connect local AI coding agents (Claude, Codex, Gemini, Qwen, DeepSeek, Cursor, OpenCode, Pi, OpenHuman, Reasonix) to the Grix scheduling platform. Also serves as an OpenClaw plugin for Grix channel transport.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",