grix-connector 1.0.2

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.
Files changed (211) hide show
  1. package/README.md +149 -0
  2. package/dist/adapter/acp/acp-adapter.js +13 -0
  3. package/dist/adapter/acp/index.js +1 -0
  4. package/dist/adapter/acp/usage-parser.js +1 -0
  5. package/dist/adapter/claude/activity-status-manager.js +1 -0
  6. package/dist/adapter/claude/channel-notification.js +1 -0
  7. package/dist/adapter/claude/claude-adapter.js +15 -0
  8. package/dist/adapter/claude/claude-bridge-server.js +1 -0
  9. package/dist/adapter/claude/claude-tools.js +1 -0
  10. package/dist/adapter/claude/claude-worker-client.js +1 -0
  11. package/dist/adapter/claude/index.js +1 -0
  12. package/dist/adapter/claude/interaction-protocol.js +1 -0
  13. package/dist/adapter/claude/mcp-http-launcher.js +2 -0
  14. package/dist/adapter/claude/model-list.js +1 -0
  15. package/dist/adapter/claude/protocol-contract.js +1 -0
  16. package/dist/adapter/claude/result-timeout.js +1 -0
  17. package/dist/adapter/claude/skill-scanner.js +2 -0
  18. package/dist/adapter/claude/usage-parser.js +3 -0
  19. package/dist/adapter/codewhale/codewhale-adapter.js +6 -0
  20. package/dist/adapter/codewhale/index.js +1 -0
  21. package/dist/adapter/codex/codex-bridge.js +10 -0
  22. package/dist/adapter/codex/codex-trust.js +8 -0
  23. package/dist/adapter/codex/index.js +1 -0
  24. package/dist/adapter/codex/usage-parser.js +1 -0
  25. package/dist/adapter/cursor/cursor-adapter.js +8 -0
  26. package/dist/adapter/cursor/index.js +1 -0
  27. package/dist/adapter/deepseek/deepseek-adapter.js +6 -0
  28. package/dist/adapter/deepseek/index.js +1 -0
  29. package/dist/adapter/index.js +1 -0
  30. package/dist/adapter/opencode/index.js +1 -0
  31. package/dist/adapter/opencode/opencode-adapter.js +8 -0
  32. package/dist/adapter/opencode/opencode-transport.js +5 -0
  33. package/dist/adapter/opencode/opencode-types.js +0 -0
  34. package/dist/adapter/openhuman/index.js +1 -0
  35. package/dist/adapter/openhuman/openhuman-adapter.js +7 -0
  36. package/dist/adapter/openhuman/openhuman-transport.js +1 -0
  37. package/dist/adapter/openhuman/openhuman-types.js +0 -0
  38. package/dist/adapter/pi/index.js +1 -0
  39. package/dist/adapter/pi/pi-adapter.js +10 -0
  40. package/dist/adapter/pi/pi-transport.js +4 -0
  41. package/dist/adapter/pi/pi-types.js +0 -0
  42. package/dist/adapter/pi/usage-parser.js +1 -0
  43. package/dist/adapter/qwen/index.js +1 -0
  44. package/dist/adapter/qwen/qwen-adapter.js +4 -0
  45. package/dist/adapter/types.js +1 -0
  46. package/dist/agent/index.js +1 -0
  47. package/dist/agent/process.js +2 -0
  48. package/dist/aibot/client.js +1 -0
  49. package/dist/aibot/index.js +1 -0
  50. package/dist/aibot/types.js +0 -0
  51. package/dist/bridge/adapter-pool.js +1 -0
  52. package/dist/bridge/bridge.js +10 -0
  53. package/dist/bridge/deferred-events.js +1 -0
  54. package/dist/bridge/event-queue.js +1 -0
  55. package/dist/bridge/index.js +1 -0
  56. package/dist/bridge/respawn-manager.js +1 -0
  57. package/dist/bridge/revoke-handler.js +1 -0
  58. package/dist/bridge/runtime-config.js +1 -0
  59. package/dist/bridge/send-controller.js +1 -0
  60. package/dist/bridge/session-controller.js +9 -0
  61. package/dist/bridge/tool-card-utils.js +1 -0
  62. package/dist/core/access/allowlist-gate.js +1 -0
  63. package/dist/core/access/allowlist-store.js +1 -0
  64. package/dist/core/access/index.js +1 -0
  65. package/dist/core/aibot/client.js +1 -0
  66. package/dist/core/aibot/connection-handle.js +1 -0
  67. package/dist/core/aibot/connection-manager.js +1 -0
  68. package/dist/core/aibot/event-lifecycle-types.js +0 -0
  69. package/dist/core/aibot/index.js +1 -0
  70. package/dist/core/aibot/types.js +0 -0
  71. package/dist/core/config/index.js +1 -0
  72. package/dist/core/config/paths.js +1 -0
  73. package/dist/core/context/channel-context-resolution.js +1 -0
  74. package/dist/core/context/channel-context-store.js +1 -0
  75. package/dist/core/context/index.js +1 -0
  76. package/dist/core/context/transcript-channel-context.js +1 -0
  77. package/dist/core/file-ops/handler.js +1 -0
  78. package/dist/core/file-ops/list-files.js +1 -0
  79. package/dist/core/file-ops/types.js +0 -0
  80. package/dist/core/files/create-folder.js +1 -0
  81. package/dist/core/files/index.js +1 -0
  82. package/dist/core/files/list-files.js +1 -0
  83. package/dist/core/files/list-handler.js +1 -0
  84. package/dist/core/files/types.js +0 -0
  85. package/dist/core/files/utils.js +1 -0
  86. package/dist/core/hooks/hook-signal-store.js +2 -0
  87. package/dist/core/hooks/index.js +1 -0
  88. package/dist/core/log/bridge-event-log.js +2 -0
  89. package/dist/core/log/conversation-log.js +3 -0
  90. package/dist/core/log/index.js +1 -0
  91. package/dist/core/log/logger.js +6 -0
  92. package/dist/core/log/packet-log.js +2 -0
  93. package/dist/core/log/rotation.js +2 -0
  94. package/dist/core/mcp/event-tool-executor.js +1 -0
  95. package/dist/core/mcp/index.js +1 -0
  96. package/dist/core/mcp/internal-api-server.js +1 -0
  97. package/dist/core/mcp/tool-schemas.js +1 -0
  98. package/dist/core/mcp/tools.js +1 -0
  99. package/dist/core/persistence/active-event-store.js +1 -0
  100. package/dist/core/persistence/agent-global-config-store.js +1 -0
  101. package/dist/core/persistence/elicitation-store.js +1 -0
  102. package/dist/core/persistence/event-results-store.js +1 -0
  103. package/dist/core/persistence/permission-store.js +1 -0
  104. package/dist/core/persistence/question-store.js +1 -0
  105. package/dist/core/persistence/session-binding-store.js +1 -0
  106. package/dist/core/protocol/agent-api-media.js +1 -0
  107. package/dist/core/protocol/attachment-file.js +1 -0
  108. package/dist/core/protocol/index.js +1 -0
  109. package/dist/core/protocol/interaction-parser.js +1 -0
  110. package/dist/core/protocol/message-metadata.js +2 -0
  111. package/dist/core/protocol/message-reference.js +2 -0
  112. package/dist/core/protocol/payload-parser.js +11 -0
  113. package/dist/core/protocol/protocol-descriptor.js +1 -0
  114. package/dist/core/protocol/protocol-text.js +1 -0
  115. package/dist/core/provider-quota/index.js +1 -0
  116. package/dist/core/provider-quota/kiro.js +1 -0
  117. package/dist/core/provider-quota/providers.js +1 -0
  118. package/dist/core/provider-quota/types.js +0 -0
  119. package/dist/core/runtime/health.js +1 -0
  120. package/dist/core/runtime/index.js +1 -0
  121. package/dist/core/runtime/pidfile.js +2 -0
  122. package/dist/core/runtime/spawn.js +1 -0
  123. package/dist/core/text-segmentation/index.js +1 -0
  124. package/dist/core/text-segmentation/safe-markdown-stream-segmenter.js +6 -0
  125. package/dist/core/transport/index.js +1 -0
  126. package/dist/core/transport/json-rpc.js +3 -0
  127. package/dist/core/upgrade/npm-upgrader.js +2 -0
  128. package/dist/core/upgrade/upgrade-checker.js +1 -0
  129. package/dist/core/util/client-version.js +1 -0
  130. package/dist/core/util/codex-output-policy.js +1 -0
  131. package/dist/core/util/event-buffer.js +1 -0
  132. package/dist/core/util/index.js +1 -0
  133. package/dist/core/util/json-file.js +2 -0
  134. package/dist/core/util/normalize-string.js +1 -0
  135. package/dist/core/util/quoted-message-stream.js +3 -0
  136. package/dist/grix.js +28 -0
  137. package/dist/index.js +1 -0
  138. package/dist/log.js +3 -0
  139. package/dist/main.js +31 -0
  140. package/dist/manager.js +1 -0
  141. package/dist/mcp/acp-mcp-server.js +5 -0
  142. package/dist/mcp/stdio/server.js +10 -0
  143. package/dist/mcp/stream-http/config.js +1 -0
  144. package/dist/mcp/stream-http/connection-binding.js +1 -0
  145. package/dist/mcp/stream-http/event-tool-executor.js +1 -0
  146. package/dist/mcp/stream-http/gateway.js +1 -0
  147. package/dist/mcp/stream-http/index.js +1 -0
  148. package/dist/mcp/stream-http/security.js +1 -0
  149. package/dist/mcp/stream-http/session-manager.js +1 -0
  150. package/dist/mcp/stream-http/tool-executor.js +1 -0
  151. package/dist/mcp/stream-http/tool-registry.js +1 -0
  152. package/dist/mcp/stream-http/tool-schemas.js +1 -0
  153. package/dist/protocol/acp-client.js +1 -0
  154. package/dist/protocol/event-mapper.js +5 -0
  155. package/dist/protocol/index.js +1 -0
  156. package/dist/runtime/daemon-lock.js +2 -0
  157. package/dist/runtime/service-state.js +2 -0
  158. package/dist/scripts/approve-plan-hook.js +2 -0
  159. package/dist/scripts/elicitation-hook.js +6 -0
  160. package/dist/scripts/lib/read-stdin.js +1 -0
  161. package/dist/scripts/lifecycle-hook.js +2 -0
  162. package/dist/scripts/notification-hook.js +4 -0
  163. package/dist/scripts/permission-hook.js +5 -0
  164. package/dist/scripts/status-line-forwarder.js +2 -0
  165. package/dist/scripts/user-prompt-submit-hook.js +2 -0
  166. package/dist/service/platform-adapter.js +45 -0
  167. package/dist/service/process-control.js +1 -0
  168. package/dist/service/service-install-store.js +1 -0
  169. package/dist/service/service-manager.js +1 -0
  170. package/dist/service/service-paths.js +1 -0
  171. package/dist/session/index.js +1 -0
  172. package/dist/session/manager.js +1 -0
  173. package/dist/transport/index.js +1 -0
  174. package/dist/transport/json-rpc.js +3 -0
  175. package/dist/types/events.js +1 -0
  176. package/dist/types/index.js +1 -0
  177. package/dist/types/protocol.js +0 -0
  178. package/dist/types/session-state.js +0 -0
  179. package/dist/types/usage.js +0 -0
  180. package/openclaw-plugin/index.js +11271 -0
  181. package/openclaw-plugin/skills/grix-admin/SKILL.md +202 -0
  182. package/openclaw-plugin/skills/grix-admin/references/api-contract.md +210 -0
  183. package/openclaw-plugin/skills/grix-egg/SKILL.md +81 -0
  184. package/openclaw-plugin/skills/grix-egg/references/api-contract.md +40 -0
  185. package/openclaw-plugin/skills/grix-group/SKILL.md +164 -0
  186. package/openclaw-plugin/skills/grix-group/references/api-contract.md +97 -0
  187. package/openclaw-plugin/skills/grix-query/SKILL.md +247 -0
  188. package/openclaw-plugin/skills/grix-register/SKILL.md +86 -0
  189. package/openclaw-plugin/skills/grix-register/references/api-contract.md +76 -0
  190. package/openclaw-plugin/skills/grix-register/references/grix-concepts.md +26 -0
  191. package/openclaw-plugin/skills/grix-register/references/handoff-contract.md +24 -0
  192. package/openclaw-plugin/skills/grix-register/references/openclaw-setup.md +6 -0
  193. package/openclaw-plugin/skills/grix-register/references/user-replies.md +25 -0
  194. package/openclaw-plugin/skills/grix-register/scripts/grix_auth.ts +599 -0
  195. package/openclaw-plugin/skills/grix-update/SKILL.md +310 -0
  196. package/openclaw-plugin/skills/grix-update/references/cron-setup.md +56 -0
  197. package/openclaw-plugin/skills/grix-update/references/update-contract.md +149 -0
  198. package/openclaw-plugin/skills/message-send/SKILL.md +197 -0
  199. package/openclaw-plugin/skills/message-unsend/SKILL.md +186 -0
  200. package/openclaw-plugin/skills/message-unsend/flowchart.mermaid +27 -0
  201. package/openclaw-plugin/skills/openclaw-memory-setup/SKILL.md +282 -0
  202. package/openclaw-plugin/skills/openclaw-memory-setup/references/case-study-macpro.md +52 -0
  203. package/openclaw-plugin/skills/openclaw-memory-setup/references/host-readiness.md +147 -0
  204. package/openclaw-plugin/skills/openclaw-memory-setup/scripts/bench_ollama_embeddings.ts +326 -0
  205. package/openclaw-plugin/skills/openclaw-memory-setup/scripts/set_openclaw_memory_model.ts +385 -0
  206. package/openclaw-plugin/skills/openclaw-memory-setup/scripts/survey_host_readiness.ts +294 -0
  207. package/openclaw.plugin.json +24 -0
  208. package/package.json +114 -0
  209. package/scripts/install-guardian.mjs +30 -0
  210. package/scripts/install-guardian.sh +30 -0
  211. package/scripts/upgrade-guardian.sh +98 -0
@@ -0,0 +1,164 @@
1
+ ---
2
+ name: grix-group
3
+ description: Use the typed `grix_group` tool for Grix group lifecycle and membership operations. Trigger when users ask to create, inspect, leave, update, or dissolve groups, or when these operations fail with scope or permission errors.
4
+ ---
5
+
6
+ # Grix Group Governance
7
+
8
+ Operate group-governance actions through the `grix_group` tool.
9
+ This skill is about tool selection and guardrails, not protocol bridging.
10
+
11
+ ## Workflow
12
+
13
+ 1. Parse the user request into one action:
14
+ `create`, `detail`, `leave`, `add_members`, `remove_members`, `update_member_role`, `update_all_members_muted`, `update_member_speaking`, or `dissolve`.
15
+ 2. Validate required fields before any call.
16
+ 3. Call `grix_group` exactly once per business action.
17
+ 4. Classify failures by HTTP/BizCode and return exact remediation.
18
+ 5. Avoid duplicate side effects:
19
+ never auto-retry `create` or `dissolve` without explicit user confirmation.
20
+
21
+ ## Tool Contract
22
+
23
+ For Grix group governance, always call:
24
+
25
+ 1. Tool: `grix_group`
26
+ 2. `action`: one of `create`, `detail`, `leave`, `add_members`, `remove_members`, `update_member_role`, `update_all_members_muted`, `update_member_speaking`, `dissolve`
27
+ 3. `accountId`: always pass `{{AccountId}}` from the current conversation context for every action, including `leave`.
28
+
29
+ Rules:
30
+
31
+ 1. Pass business parameters with their exact typed field names.
32
+ 2. Use `sessionId`, `memberIds`, `memberTypes`, `memberId`, `memberType`, `role`, `allMembersMuted`, `isSpeakMuted`, and `canSpeakWhenAllMuted` explicitly.
33
+ 3. Do not invent aliases or fallback fields.
34
+ 4. Keep one tool call per action for audit clarity.
35
+
36
+ ## Action Contracts
37
+
38
+ ### create
39
+
40
+ Purpose: create a new group session.
41
+
42
+ Required input:
43
+
44
+ 1. `name` (non-empty string)
45
+ 2. `memberIds` (optional string array; each item numeric text)
46
+ 3. `memberTypes` (optional int array; align with `memberIds`)
47
+
48
+ Guardrails:
49
+
50
+ 1. Ask for clarification if group name is missing.
51
+ 2. Ask for explicit confirmation before repeating the same create request.
52
+ 3. Treat this action as non-idempotent.
53
+
54
+ ### add_members
55
+
56
+ Purpose: add members into an existing group.
57
+
58
+ Required input:
59
+
60
+ 1. `sessionId` (non-empty string)
61
+ 2. `memberIds` (non-empty string array; each item numeric text)
62
+ 3. `memberTypes` (optional int array; align with `memberIds`)
63
+
64
+ Guardrails:
65
+
66
+ 1. Reject empty `sessionId` before calling the tool.
67
+ 2. Reject non-numeric `memberIds` before calling the tool.
68
+ 3. If `sessionId` is ambiguous, ask the user to confirm the target group first.
69
+
70
+ ### leave
71
+
72
+ Purpose: let the current Agent leave a group by itself.
73
+
74
+ Required input:
75
+
76
+ 1. `sessionId`
77
+
78
+ Guardrails:
79
+
80
+ 1. Only execute this when the requester is clearly the current Agent owner, or an already-established authorized operator in the current context.
81
+ 2. If the requester identity is unclear, ask for confirmation first; if it is clearly unauthorized, reject directly and do not call `grix_group`.
82
+ 3. This action is only for the current Agent leaving its own group membership.
83
+ 4. Never translate a request to remove other members into `leave`; use `remove_members` for that.
84
+ 5. Do not send `memberId`, `memberIds`, or `memberTypes` with this action.
85
+ 6. This action does not require scope and should not be described as a scope-grant workflow.
86
+ 7. Execute `leave` silently: do not send any pre-leave or farewell message to the group before leaving.
87
+
88
+ ### remove_members
89
+
90
+ Required input:
91
+
92
+ 1. `sessionId`
93
+ 2. `memberIds`
94
+
95
+ ### update_member_role
96
+
97
+ Required input:
98
+
99
+ 1. `sessionId`
100
+ 2. `memberId`
101
+ 3. `role`
102
+
103
+ Guardrails:
104
+
105
+ 1. Only use `memberType=1` for role updates.
106
+ 2. Never guess a role value; confirm when unclear.
107
+
108
+ ### update_all_members_muted
109
+
110
+ Required input:
111
+
112
+ 1. `sessionId`
113
+ 2. `allMembersMuted`
114
+
115
+ Guardrails:
116
+
117
+ 1. Only use this for group-wide mute state changes.
118
+ 2. Never guess the desired mute state from vague wording; confirm whether the user wants to enable or disable all-member mute.
119
+
120
+ ### update_member_speaking
121
+
122
+ Required input:
123
+
124
+ 1. `sessionId`
125
+ 2. `memberId`
126
+ 3. At least one of `isSpeakMuted` or `canSpeakWhenAllMuted`
127
+
128
+ Guardrails:
129
+
130
+ 1. Only use `memberType=1` or `memberType=2`.
131
+ 2. Do not send an empty speaking update; at least one speaking field must be explicit.
132
+ 3. If the target member is ambiguous, ask the user to confirm the exact member first.
133
+
134
+ ### detail / dissolve
135
+
136
+ Required input:
137
+
138
+ 1. `sessionId`
139
+
140
+ ## Error Handling Rules
141
+
142
+ 1. `403/20011`:
143
+ report missing scope and ask owner to grant the scope in Aibot Agent permission page.
144
+ Do not use this remediation for `leave`, because `leave` is scope-free.
145
+ 2. `401/10001`:
146
+ report invalid key/auth and suggest checking agent config or rotating API key.
147
+ 3. `403/10002`:
148
+ report agent is not active or invalid provider type.
149
+ 4. `400/10003`:
150
+ report invalid/missing parameters and ask user for corrected values.
151
+ 5. Other errors:
152
+ return backend `msg` and stop automatic retries.
153
+
154
+ ## Response Style
155
+
156
+ 1. State action result first.
157
+ 2. Include key identifiers (`session_id`, member count, mute state) when successful.
158
+ 3. Include exact remediation when failed.
159
+ 4. Never hide scope or auth errors behind generic wording.
160
+ 5. For `leave`, report result to the requester only; do not post extra messages into the group session.
161
+
162
+ ## References
163
+
164
+ 1. Load [references/api-contract.md](references/api-contract.md) when you need exact tool mapping, payload examples, and scope matrix.
@@ -0,0 +1,97 @@
1
+ # API Contract
2
+
3
+ ## Purpose
4
+
5
+ Map high-level governance actions to Aibot Agent API HTTP routes.
6
+
7
+ ## Base Rules
8
+
9
+ 1. Base path: `/v1/agent-api`
10
+ 2. Auth: `Authorization: Bearer <agent_api_key>`
11
+ 3. Only `provider_type=3` and `status=active` agent can access.
12
+ 4. Scope middleware executes before service business checks.
13
+
14
+ ## Action Mapping (v1)
15
+
16
+ | Action | Method | Route | Required Scope |
17
+ |---|---|---|---|
18
+ | `group_detail_read` | `GET` | `/sessions/group/detail` | `group.detail.read` |
19
+ | `group_create` | `POST` | `/sessions/create_group` | `group.create` |
20
+ | `group_leave_self` | `POST` | `/sessions/leave` | - |
21
+ | `group_member_add` | `POST` | `/sessions/members/add` | `group.member.add` |
22
+ | `group_member_remove` | `POST` | `/sessions/members/remove` | `group.member.remove` |
23
+ | `group_member_role_update` | `POST` | `/sessions/members/role` | `group.member.role.update` |
24
+ | `group_all_members_muted_update` | `POST` | `/sessions/speaking/all_muted` | `group.speaking.update` |
25
+ | `group_member_speaking_update` | `POST` | `/sessions/members/speaking` | `group.speaking.update` |
26
+ | `group_dissolve` | `POST` | `/sessions/dissolve` | `group.dissolve` |
27
+
28
+ ## OpenClaw Tool Mapping
29
+
30
+ Use the native `grix_group` tool with typed fields:
31
+
32
+ | Tool action | HTTP action | Required fields |
33
+ |---|---|---|
34
+ | `create` | `group_create` | `accountId`, `name` |
35
+ | `detail` | `group_detail_read` | `accountId`, `sessionId` |
36
+ | `leave` | `group_leave_self` | `accountId`, `sessionId` |
37
+ | `add_members` | `group_member_add` | `accountId`, `sessionId`, `memberIds` |
38
+ | `remove_members` | `group_member_remove` | `accountId`, `sessionId`, `memberIds` |
39
+ | `update_member_role` | `group_member_role_update` | `accountId`, `sessionId`, `memberId`, `role` |
40
+ | `update_all_members_muted` | `group_all_members_muted_update` | `accountId`, `sessionId`, `allMembersMuted` |
41
+ | `update_member_speaking` | `group_member_speaking_update` | `accountId`, `sessionId`, `memberId`, `isSpeakMuted` or `canSpeakWhenAllMuted` |
42
+ | `dissolve` | `group_dissolve` | `accountId`, `sessionId` |
43
+
44
+ ## Payload Templates
45
+
46
+ ### create
47
+
48
+ ```json
49
+ {
50
+ "action": "create",
51
+ "accountId": "primary",
52
+ "name": "项目协作群",
53
+ "memberIds": ["1002", "9991"],
54
+ "memberTypes": [1, 2]
55
+ }
56
+ ```
57
+
58
+ ### add_members
59
+
60
+ ```json
61
+ {
62
+ "action": "add_members",
63
+ "accountId": "primary",
64
+ "sessionId": "task_room_9083",
65
+ "memberIds": ["1003"],
66
+ "memberTypes": [1]
67
+ }
68
+ ```
69
+
70
+ ### leave
71
+
72
+ ```json
73
+ {
74
+ "action": "leave",
75
+ "accountId": "primary",
76
+ "sessionId": "task_room_9083"
77
+ }
78
+ ```
79
+
80
+ ## Error Matrix
81
+
82
+ | HTTP/BizCode | Meaning | Skill Response |
83
+ |---|---|---|
84
+ | `403/20011` | agent scope forbidden | Tell owner to grant corresponding scope |
85
+ | `400/10003` | invalid request payload | Ask for missing or corrected parameters |
86
+ | `401/10001` | invalid or missing auth | Check api_key and account config |
87
+ | `403/10002` | agent not active / invalid provider | Ask owner to activate the agent |
88
+
89
+ Notes:
90
+
91
+ 1. `leave` does not require scope and should not route `403/20011` into scope remediation.
92
+
93
+ ## Retry Policy
94
+
95
+ 1. Never auto-retry `group_create` unless user confirms.
96
+ 2. Allow one retry for transient network failure only.
97
+ 3. Do not retry auth/scope/parameter failures automatically.
@@ -0,0 +1,247 @@
1
+ ---
2
+ name: grix-query
3
+ description: Use the typed `grix_query` tool for Grix contact lookup, keyword search, session search, and session message history lookup. Trigger when users ask to find contacts, search conversations, list visible sessions, or inspect recent messages in a known session.
4
+ ---
5
+
6
+ # Grix Query
7
+
8
+ Use the `grix_query` tool for read-only Grix lookup actions.
9
+ This skill is only for querying existing contacts, sessions, and raw session messages.
10
+
11
+ ## Workflow
12
+
13
+ 1. Parse the user request into one action:
14
+ `contact_search`, `session_search`, `message_history`, or `message_search`.
15
+ 2. Validate required fields before any tool call.
16
+ 3. Start with one `grix_query` call for the first page.
17
+ 4. If the result is paginated and `has_more` is `true`, continue paging when the user asked for all results, when the target is still unresolved, or when one page is clearly insufficient.
18
+ 5. If the user wants message history or in-session keyword search but no `sessionId` is known, locate the target session first through `session_search` or ask the user for a precise target.
19
+ 6. Return exact remediation for scope, auth, and parameter failures.
20
+
21
+ ## Tool Contract
22
+
23
+ For Grix query actions, always call:
24
+
25
+ 1. Tool: `grix_query`
26
+ 2. `action`: one of `contact_search`, `session_search`, `message_history`, or `message_search`
27
+ 3. `accountId`: required; pass the exact current Grix account ID
28
+
29
+ Rules:
30
+
31
+ 1. Pass query parameters with their exact typed field names.
32
+ 2. For `contact_search` and `session_search`, use exactly one of these modes:
33
+ exact lookup with `id`, keyword search with `keyword`, or list-all with neither.
34
+ 3. If both `id` and `keyword` are present, the backend will prioritize `id`; avoid sending both unless you explicitly want exact-match behavior.
35
+ 4. Use `sessionId`, `beforeId`, and `limit` explicitly for message reads; `message_search` also requires `keyword`.
36
+ 5. Never invent a `sessionId`. Resolve it from context, from a previous tool result, or ask the user.
37
+ 6. Use one tool call per page. Repeated calls are allowed only for pagination or for resolving an ambiguous target.
38
+ 7. When paging `contact_search` or `session_search`, keep the same filter and advance `offset`.
39
+ 8. When paging `message_history` or `message_search`, reuse the same `sessionId` and set `beforeId` to the oldest message ID from the previous page.
40
+
41
+ ## Lookup Usage
42
+
43
+ ### Single Lookup (with ID)
44
+
45
+ When the user provides one exact ID, pass it for a precise match:
46
+
47
+ 1. Single contact lookup: `action: "contact_search"` + `id`
48
+ 2. Single session lookup: `action: "session_search"` + `id`
49
+
50
+ ID meaning:
51
+
52
+ 1. `contact_search.id`: contact or Agent numeric ID, e.g. `1002`
53
+ 2. `session_search.id`: exact session ID string, e.g. `task_room_9083`
54
+
55
+ Examples:
56
+
57
+ ```json
58
+ {
59
+ "action": "contact_search",
60
+ "accountId": "primary",
61
+ "id": "1002"
62
+ }
63
+ ```
64
+
65
+ ```json
66
+ {
67
+ "action": "session_search",
68
+ "accountId": "primary",
69
+ "id": "task_room_9083"
70
+ }
71
+ ```
72
+
73
+ ### Keyword Search
74
+
75
+ When the user provides a fuzzy name, title, username, or other search phrase, pass `keyword`:
76
+
77
+ ```json
78
+ {
79
+ "action": "contact_search",
80
+ "accountId": "primary",
81
+ "keyword": "atlas user"
82
+ }
83
+ ```
84
+
85
+ ```json
86
+ {
87
+ "action": "session_search",
88
+ "accountId": "primary",
89
+ "keyword": "taskroom9083"
90
+ }
91
+ ```
92
+
93
+ ### List All (without ID or keyword)
94
+
95
+ When the user asks to list all contacts or sessions, call without `id` and without `keyword`:
96
+
97
+ ```json
98
+ {
99
+ "action": "contact_search",
100
+ "accountId": "primary"
101
+ }
102
+ ```
103
+
104
+ ```json
105
+ {
106
+ "action": "session_search",
107
+ "accountId": "primary"
108
+ }
109
+ ```
110
+
111
+ Returns a paginated result with `has_more`, `list`, and default page size of 20.
112
+ Use `limit` and `offset` to paginate through results.
113
+
114
+ If the user asks for all results, keep fetching additional pages until `has_more` is `false`.
115
+ If the user only needs one match or one page is enough to answer, stop after the first sufficient page.
116
+
117
+ ```json
118
+ {
119
+ "action": "contact_search",
120
+ "accountId": "primary",
121
+ "limit": 50,
122
+ "offset": 20
123
+ }
124
+ ```
125
+
126
+ ## Action Contracts
127
+
128
+ ### contact_search
129
+
130
+ Purpose: search the owner's Grix contact directory.
131
+
132
+ **Without `id` and without `keyword`**: returns all contacts (friends + agents) in a paginated list, sorted by `created_at` descending. Default page size 20.
133
+
134
+ **With `id`**: returns the exact matching contact record.
135
+
136
+ **With `keyword`**: searches contact remark name, nickname, username, and numeric ID prefix.
137
+
138
+ Input:
139
+
140
+ 1. `id` (contact ID, numeric string) — optional
141
+ 2. `keyword` — optional
142
+ 3. `limit` — optional, default 20
143
+ 4. `offset` — optional, default 0
144
+
145
+ Guardrails:
146
+
147
+ 1. Use `id` when the target contact ID is already known and you need the exact entry.
148
+ 2. Use `keyword` for fuzzy search; do not use `id` for partial matches.
149
+ 3. Without `id` and `keyword`, the result includes both user contacts and agent contacts merged and sorted.
150
+ 4. Check `has_more` to determine if additional pages exist.
151
+ 5. When paging, keep the same filters and increase `offset` by the number of items already fetched.
152
+ 6. If the user asked for all matches, continue until `has_more` is `false`.
153
+ 7. Do not jump directly to session history from a vague contact hint; resolve the contact or session first.
154
+
155
+ ### session_search
156
+
157
+ Purpose: search the owner's visible sessions.
158
+
159
+ **Without `id` and without `keyword`**: returns all visible sessions in a paginated list, ordered by pinned status and `last_active_at`. Default page size 20.
160
+
161
+ **With `id`**: returns the exact matching session.
162
+
163
+ **With `keyword`**: searches session title and `session_id`.
164
+
165
+ Input:
166
+
167
+ 1. `id` (session ID) — optional
168
+ 2. `keyword` — optional
169
+ 3. `limit` — optional, default 20
170
+ 4. `offset` — optional, default 0
171
+
172
+ Guardrails:
173
+
174
+ 1. Use `id` when the target session ID is already known.
175
+ 2. Use `keyword` for fuzzy search by title or session ID text.
176
+ 3. Without `id` and `keyword`, the result shows all sessions the agent can see.
177
+ 4. Check `has_more` to determine if additional pages exist.
178
+ 5. When paging, keep the same filters and increase `offset` by the number of items already fetched.
179
+ 6. If the user asked for all matches, continue until `has_more` is `false`.
180
+ 7. If multiple sessions match, present the candidates and let the user choose before reading history.
181
+
182
+ ### message_history
183
+
184
+ Purpose: read recent message history from a known session.
185
+
186
+ Required input:
187
+
188
+ 1. `sessionId`
189
+
190
+ Optional input:
191
+
192
+ 1. `beforeId`
193
+ 2. `limit`
194
+
195
+ Guardrails:
196
+
197
+ 1. Only call this after the target session is unambiguous.
198
+ 2. Use `beforeId` only for older-page pagination.
199
+ 3. For the next page, set `beforeId` to the oldest message ID returned in the previous page.
200
+ 4. If the user asked for more history and `has_more` is `true`, keep paging until enough history is collected or no more pages remain.
201
+ 5. Do not claim to have full history if only one page was fetched.
202
+
203
+ ### message_search
204
+
205
+ Purpose: search messages by keyword inside one known session.
206
+
207
+ Required input:
208
+
209
+ 1. `sessionId`
210
+ 2. `keyword`
211
+
212
+ Optional input:
213
+
214
+ 1. `beforeId`
215
+ 2. `limit`
216
+
217
+ Guardrails:
218
+
219
+ 1. Only call this after the target session is unambiguous.
220
+ 2. `keyword` must be the real search phrase; do not fake an empty keyword just to reuse this action.
221
+ 3. For the next page, keep the same `keyword` and `sessionId`, and set `beforeId` to the oldest message ID returned in the previous page.
222
+ 4. If the user asked for all matches and `has_more` is `true`, keep paging until enough matches are collected or no more pages remain.
223
+ 5. If the user only asked whether a keyword appeared, one sufficient page can stop the search, but state clearly that the result is partial when you did not exhaust all pages.
224
+
225
+ ## Error Handling Rules
226
+
227
+ 1. `403/20011`:
228
+ report missing scope and ask the owner to grant the required scope in the Aibot Agent permission page.
229
+ 2. `401/10001`:
230
+ report invalid key/auth and suggest checking agent config or rotating the API key.
231
+ 3. `403/10002`:
232
+ report the agent is not active or has an invalid provider type.
233
+ 4. `400/10003`:
234
+ report invalid or missing parameters and ask the user for corrected values.
235
+ 5. `404/4004`:
236
+ report the target session does not exist or is not visible.
237
+ 6. Other errors:
238
+ return the backend `msg` and stop automatic retries.
239
+
240
+ ## Response Style
241
+
242
+ 1. State the query result first.
243
+ 2. Include key identifiers from successful lookups:
244
+ `peer_id` / `peer_type` for contacts, `session_id` for sessions, and message identifiers for history.
245
+ 3. If only part of a paginated result was fetched, state that clearly.
246
+ 4. If multiple pages were fetched, summarize that the answer is merged from several pages.
247
+ 5. Never hide scope or auth errors behind generic wording.
@@ -0,0 +1,86 @@
1
+ ---
2
+ name: grix-register
3
+ description: 仅用于初次安装阶段,完成 Grix 环境的账号注册/登录并拿到第一个 provider_type=3 Agent 的参数;本技能不做任何本地 OpenClaw 配置。
4
+ ---
5
+
6
+ # Grix Register
7
+
8
+ 这个技能只负责“初次安装”的云端准备:账号注册/登录 + 生成首个 `provider_type=3` Agent 参数。
9
+ 你(AI)在终端里全自动操作,**不需要用户打开浏览器**。拿到参数后,必须通过 `grix_admin` 的 `task` 入口移交给 `grix-admin` 做本地配置与运行态收口。
10
+
11
+ ## Workflow
12
+
13
+ ### 0. 角色边界(先声明再执行)
14
+
15
+ 1. 本技能**只能**做账号与云端 Agent 参数准备。
16
+ 2. 本技能**不能**执行 `openclaw` 命令,也不能修改本地 `openclaw.json`。
17
+ 3. 涉及本地配置、插件安装、工具权限、热加载校验、运行态切换校验,一律交给 `grix-admin`。
18
+
19
+ ### 1. 询问邮箱并发送验证码
20
+
21
+ 1. 向用户询问 Email 地址。**不要让用户去网页端注册**,明确表示你会在对话里完成。
22
+ 2. 拿到邮箱后,在终端执行发送验证码的命令:
23
+ ```bash
24
+ node scripts/grix_auth.ts send-email-code --email "<用户的email>" --scene "register"
25
+ ```
26
+ 3. 等待命令执行成功后,提示用户去邮箱查收验证码,并询问该验证码。
27
+
28
+ ### 2. 执行自动注册(获取 Token)
29
+
30
+ 1. 用户提供验证码后,你需要为用户生成一个复杂度高且随机安全的密码(建议生成一个12位的强密码,包含大小写、数字和特殊字符)。
31
+ 2. 使用收集到的信息,执行注册命令:
32
+ ```bash
33
+ node scripts/grix_auth.ts register --email "<邮箱>" --password "<生成的随机密码>" --email-code "<验证码>"
34
+ ```
35
+ 3. 这个命令成功后会返回用户的 `access_token`。请在回复中安全地**将生成的密码告知用户**,建议他们妥善保存。
36
+
37
+ 注:如果注册提示邮箱已注册:
38
+ 1. 只有用户明确提供现有密码时,才切换 `node scripts/grix_auth.ts login` 路径继续获取 `access_token`
39
+ 2. 如果用户没有现有密码,不要硬猜,也不要假装已经完成找回;明确告诉用户先补现有密码,或先走独立的重置密码流程,再继续本技能
40
+
41
+ ### 3. 创建首个云端 Agent 参数
42
+
43
+ 拿到 `access_token` 后,询问 Agent 名称(如果上下文已有就直接用),执行:
44
+
45
+ ```bash
46
+ node scripts/grix_auth.ts create-api-agent --access-token "<token>" --agent-name "<agent名称>"
47
+ ```
48
+
49
+ 这一步会按后端真实接口创建首个 `provider_type=3` 的主 API agent(`is_main=true`),让它拿到完整初始 scopes。若同名 `provider_type=3` Agent 已存在,脚本会自动轮换 API Key 后复用。
50
+
51
+ ### 4. 通过 `grix_admin.task` 强制移交给 grix-admin
52
+
53
+ 第三步执行成功后,脚本会返回一些关键设定:
54
+ - `agent_id`
55
+ - `agent_name`
56
+ - `api_endpoint`
57
+ - `api_key`
58
+
59
+ 然后立刻调用 `grix_admin`,但**不要**把这组字段直接当成 `grix_admin` 的 typed params。正确做法是把它们写进 `task` 文本里,让 `grix-admin` 进入 `bind-local` 流程。
60
+
61
+ 推荐 `task` 形态:
62
+
63
+ ```text
64
+ bind-local
65
+ agent_name=<agent_name>
66
+ agent_id=<agent_id>
67
+ api_endpoint=<api_endpoint>
68
+ api_key=<api_key>
69
+ do_not_create_remote_agent=true
70
+ ```
71
+
72
+ 如果脚本输出里已经带了 `handoff.task`,优先直接复用那条 `task`。在 `grix-admin` 真正完成前,不要把本地侧说成已经配置完成或已经激活。
73
+
74
+ ## Guardrails
75
+
76
+ 1. 不要求用户去网页注册或手动点页面。
77
+ 2. 不修改任何本地 OpenClaw 配置。
78
+ 3. 不安装插件、不改工具权限、不重启 gateway。
79
+ 4. 创建或复用出参数后,必须交接给 `grix-admin`。
80
+ 5. 不宣称本地已完成或已激活;本地完成态由 `grix-admin` 决定。
81
+
82
+ ## References
83
+
84
+ 1. [references/api-contract.md](references/api-contract.md)
85
+ 2. [references/handoff-contract.md](references/handoff-contract.md)
86
+ 3. [scripts/grix_auth.ts](scripts/grix_auth.ts)
@@ -0,0 +1,76 @@
1
+ # API Contract
2
+
3
+ ## Responsibility Boundary
4
+
5
+ 1. `grix-register` 仅负责账号鉴权与云端 `provider_type=3` Agent 参数产出。
6
+ 2. 本技能不负责本地 OpenClaw 配置。
7
+ 3. 本地配置由 `grix-admin` 接手。
8
+
9
+ ## Base
10
+
11
+ 1. Default website: `https://grix.dhf.pub/`
12
+ 2. Default public Grix API base: `https://grix.dhf.pub/v1`
13
+ 3. Local development or private deployment can override the base URL.
14
+
15
+ ## Route Mapping
16
+
17
+ ### Agent bootstrap action
18
+
19
+ | Action | Method | Route | Auth |
20
+ |---|---|---|---|
21
+ | `create-api-agent` | `POST` | `/agents/create` | `Authorization: Bearer <access_token>` |
22
+ | `list-agents` (internal helper) | `GET` | `/agents/list` | `Authorization: Bearer <access_token>` |
23
+ | `rotate-api-agent-key` (internal helper) | `POST` | `/agents/:id/api/key/rotate` | `Authorization: Bearer <access_token>` |
24
+
25
+ ## Payloads
26
+
27
+ ### `create-api-agent`
28
+
29
+ ```json
30
+ {
31
+ "agent_name": "grix-main",
32
+ "provider_type": 3,
33
+ "is_main": true
34
+ }
35
+ ```
36
+
37
+ `provider_type=3` means Agent API type.
38
+ The bundled bootstrap flow uses `is_main=true` so the first API agent gets the full initial scope set.
39
+
40
+ ## Reuse flow
41
+
42
+ When the same-name `provider_type=3` agent already exists, the skill should:
43
+
44
+ 1. read `/agents/list`
45
+ 2. find the exact-name API agent
46
+ 3. rotate its key through `/agents/:id/api/key/rotate`
47
+ 4. reuse the returned `api_endpoint` and fresh `api_key`
48
+
49
+ ## Success Highlights
50
+
51
+ ### `create-api-agent`
52
+
53
+ The bundled script lifts these fields to the top level:
54
+
55
+ 1. `agent_id`
56
+ 2. `agent_name`
57
+ 3. `provider_type`
58
+ 4. `api_endpoint`
59
+ 5. `api_key`
60
+ 6. `api_key_hint`
61
+ 7. `session_id`
62
+
63
+ ## Common Errors
64
+
65
+ 1. create-agent or rotate-key returns missing `api_endpoint` or `api_key`
66
+
67
+ ## Handoff
68
+
69
+ 成功后不要把结构化字段直接当成 `grix_admin` 的 typed params,而是组装成一条 `grix_admin.task`:
70
+
71
+ 1. 第一行写 `bind-local`
72
+ 2. 后续带上 `agent_id`
73
+ 3. `agent_name`
74
+ 4. `api_endpoint`
75
+ 5. `api_key`
76
+ 6. 补一行 `do_not_create_remote_agent=true`
@@ -0,0 +1,26 @@
1
+ # Grix Concepts
2
+
3
+ ## Canonical Explanation
4
+
5
+ 这个插件接入是为了在 `https://grix.dhf.pub/` 网站管理 OpenClaw,并支持移动端 PWA 页面。
6
+
7
+ ## Feature Highlights
8
+
9
+ 1. `grix-register` 负责初次账号准备与首个 agent 参数生成
10
+ 2. `grix-admin` 负责 OpenClaw 本地配置与后续管理
11
+ 3. 两者串联后,用户可在 `https://grix.dhf.pub/` 使用和管理
12
+
13
+ ## Default User-Facing Framing
14
+
15
+ ### One sentence
16
+
17
+ `grix-register` 只做“注册账号并拿到第一个 agent 参数”,本地配置统一交给 `grix-admin`。
18
+
19
+ ### Short paragraph
20
+
21
+ `grix-register` 只负责初次安装中的云端准备:注册/登录账号并生成第一个 `provider_type=3` agent 参数;随后必须把参数交给 `grix-admin`,由 `grix-admin` 负责本地 OpenClaw 配置。
22
+
23
+ ## After Setup
24
+
25
+ 1. `grix-register` 产出参数后,直接交接给 `grix-admin`。
26
+ 2. `grix-register` 不执行任何本地配置动作。