grix-connector 3.10.2 → 3.11.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.
@@ -16,7 +16,7 @@
16
16
  2. All remote creation and category actions must go through `grix_admin` via the current account's authenticated WS channel.
17
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
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`, "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.
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
20
 
21
21
  ## Direct `grix_admin` Contract
22
22
 
@@ -116,7 +116,11 @@ Required scope:
116
116
 
117
117
  ## Local Bind Steps
118
118
 
119
- After remote agent parameters are complete, continue with local binding through the official OpenClaw CLI:
119
+ After remote agent parameters are complete, continue with local binding. The target environment determines which path to follow.
120
+
121
+ ### Path A: OpenClaw
122
+
123
+ Use official OpenClaw CLI commands:
120
124
 
121
125
  1. Prepare local directories:
122
126
  - `workspace=~/.openclaw/workspace-<agent_name>`
@@ -149,6 +153,35 @@ After remote agent parameters are complete, continue with local binding through
149
153
  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.
150
154
  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".
151
155
 
156
+ ### Path B: grix-connector
157
+
158
+ Directly manage `~/.grix/config/agents.json` and hot-reload the daemon:
159
+
160
+ 1. Target file: `~/.grix/config/agents.json`. Initialize as `{ "agents": [] }` if missing.
161
+ 2. Read the existing `agents` array. Match by `name === agent_name`:
162
+ - If found, update the existing entry in place.
163
+ - If not found, append a new entry.
164
+ 3. Write the entry with these fields:
165
+ - `name`: `agent_name`
166
+ - `ws_url`: `api_endpoint`
167
+ - `agent_id`: `agent_id`
168
+ - `api_key`: `api_key`
169
+ - `client_type`: `client_type` (default `pi`)
170
+ 4. Preserve valid JSON, set file permissions to `0o600`, and create a timestamped backup (also `0o600`) before writing.
171
+ 5. Trigger reload through the synchronous Admin API:
172
+ - Default endpoint: `POST http://127.0.0.1:19580/api/reload`
173
+ - 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.
174
+ - If the admin port was customized via `GRIX_ADMIN_PORT` or `--admin-port`, read the actual port from `~/.grix/data/admin-port`.
175
+ 6. Verify via Admin API `GET http://127.0.0.1:<admin-port>/api/agents`:
176
+ - Find entry where `name === agent_name`.
177
+ - Confirm the entry exists and reports `alive === true`.
178
+ - **Caveat**: `alive=true` only means the daemon started the instance. It does **not** prove the Agent successfully authenticated with the Grix platform.
179
+ 7. Perform secondary platform-connection verification:
180
+ - Inspect daemon logs for WebSocket connection success / authentication failure messages for this Agent.
181
+ - Or ask the owner to send a test message to the Agent and confirm it responds.
182
+ 8. If verification fails, report the observed status and stop; do not claim success.
183
+ 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".
184
+
152
185
  ## `bind-local` Input Contract
153
186
 
154
187
  ```json
@@ -159,6 +192,32 @@ After remote agent parameters are complete, continue with local binding through
159
192
 
160
193
  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.
161
194
 
195
+ ## `connector-bind-local` Input Contract
196
+
197
+ ```json
198
+ {
199
+ "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"
200
+ }
201
+ ```
202
+
203
+ Field mapping to `~/.grix/config/agents.json`:
204
+
205
+ | Input field | JSON field | Notes |
206
+ | -------------- | ------------ | ------------------------------------------ |
207
+ | `agent_name` | `name` | Also used as the matching key |
208
+ | `api_endpoint` | `ws_url` | The WebSocket URL for the agent API |
209
+ | `agent_id` | `agent_id` | Platform agent ID |
210
+ | `api_key` | `api_key` | Agent API key |
211
+ | `client_type` | `client_type`| Optional, default `pi` |
212
+
213
+ Convergence rules:
214
+
215
+ 1. Backup `~/.grix/config/agents.json` before writing; set backup permissions to `0o600`.
216
+ 2. Preserve valid JSON and set file permissions to `0o600`.
217
+ 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).
218
+ 4. Verify via `GET http://127.0.0.1:<admin-port>/api/agents` that the entry exists and has `alive=true`.
219
+ 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.
220
+
162
221
  ## `create-and-bind` Input Contract
163
222
 
164
223
  When the main agent already has an available account and `agent.api.create` scope, can enter the creation flow through `grix_admin.task`:
@@ -186,6 +245,30 @@ Notes:
186
245
  2. When matching `categoryName`, must also consider `parentCategoryId`
187
246
  3. If the remote return indicates missing `agent.api.create` or any `agent.category.*` scope, clearly state which specific scope is missing
188
247
 
248
+ ## `create-and-connector-bind` Input Contract
249
+
250
+ When the main agent already has an available account and `agent.api.create` scope, and the target runtime is grix-connector:
251
+
252
+ ```json
253
+ {
254
+ "task": "create-and-connector-bind\nagentName=程序员 pi\nintroduction=A coding assistant\nisMain=false\nclientType=pi\ncategoryName=Developers\nparentCategoryId=0\ncategorySortOrder=10"
255
+ }
256
+ ```
257
+
258
+ This mode requires steps in order:
259
+
260
+ 1. Make one direct call with `action=create_agent`, passing optional `categoryId` / `categoryName` / `parentCategoryId` / `categorySortOrder` together.
261
+ 2. If the return already includes the category assignment result, continue directly; otherwise supplement with the same category resolution logic as `create-and-bind`.
262
+ 3. Read `createdAgent.id`, `createdAgent.agent_name`, `createdAgent.api_endpoint`, `createdAgent.api_key` from the result.
263
+ 4. Follow the `connector-bind-local` local binding and runtime convergence flow, using `clientType` (default `pi`) for the `client_type` field.
264
+ 5. 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).
265
+
266
+ Notes:
267
+
268
+ 1. `categoryId` and `categoryName` cannot be provided simultaneously.
269
+ 2. `clientType` defaults to `pi` when omitted.
270
+ 3. If the remote return indicates missing `agent.api.create` or any `agent.category.*` scope, clearly state which specific scope is missing.
271
+
189
272
  ## `category-manage` Input Contract
190
273
 
191
274
  When only doing subsequent category management, enter through `grix_admin.task`:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grix-connector",
3
- "version": "3.10.2",
3
+ "version": "3.11.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",