@dhf-openclaw/grix 0.4.9 → 0.4.11

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.
@@ -0,0 +1,170 @@
1
+ ---
2
+ name: grix-egg
3
+ description: 在虾塘触发的安装私聊中处理 egg 安装。适用于主 OpenClaw agent 收到包含 install_id、egg、install、main_agent 的安装上下文时,负责与用户多轮确认、执行 persona.zip 到 OpenClaw agent 或 skill.zip 到 Claude agent 的正规安装流程,并在当前私聊里持续回报进度、失败原因和最终结果。
4
+ ---
5
+
6
+ # Egg Install
7
+
8
+ 仅在"虾塘发起的安装私聊"里使用这个技能。
9
+
10
+ 这类会话通常会先收到一条系统代发的安装请求,正文里会带一个 JSON 上下文块,至少包含:
11
+
12
+ - `install_id` — 安装单唯一 ID,所有状态指令必须使用原值
13
+ - `egg` — egg 包标识,格式为 `<name>@<version>` 或带完整下载 URL 的对象
14
+ - `install` — 安装模式,枚举值:`create_new`(新建目标 agent)或 `existing_agent`(安装到已有 agent)
15
+ - `main_agent` — 发起安装的主 OpenClaw agent ID,安装完成后如需通知或回调,使用该 ID
16
+
17
+ 你的职责不是返回隐藏协议结果,而是直接在当前私聊里把安装流程做完。
18
+
19
+ ## 工作方式
20
+
21
+ 1. 先读完整个 JSON 上下文,确认 egg、版本、安装模式和目标类型。
22
+ 2. 在真正动手前,先在当前私聊里和用户确认关键目标。
23
+ 3. `create_new` 时,先确认新 agent 的命名和用途,再继续创建。
24
+ 4. `existing_agent` 时,只能操作上下文里指定的目标 agent,不要私自换目标。
25
+ 5. 安装过程中,每完成一个关键动作就用自然语言回报一次进度。
26
+ 6. 在"包下载完成"和"安装内容落位完成待校验"两个节点,各额外发送一条 `status=running` 的**独立安装状态指令消息**。
27
+ 7. 最终成功或失败时,必须发送一条 `status=success` 或 `status=failed` 的**独立安装状态指令消息**。
28
+ 8. 出错时,直接说明失败点、影响和下一步建议,不要模糊带过。
29
+ 9. 最终明确告诉用户:装到了哪个 agent、结果成功还是失败、后续是否还要继续操作。
30
+
31
+ ## 绝对规则
32
+
33
+ - 只在当前私聊里沟通,不要切换到隐藏协议,不要输出机器专用 JSON。
34
+ - 必须按 OpenClaw / Claude 的正规步骤安装,不要直接改后端数据库。
35
+ - 需要创建远端 API agent 时,使用 `grix_agent_admin`。
36
+ - 所有远端 API 通讯都必须走统一工具入口:`grix_query` / `grix_group` / `grix_agent_admin`,禁止在对话里自行发 HTTP 请求。
37
+ - 禁止使用 `curl`、`fetch`、`axios` 或临时脚本直连 `/v1/agent-api`。
38
+ - 单个业务动作只调用一次对应工具,失败后先说明原因,不要静默重试。
39
+ - `persona.zip` 只能面向 OpenClaw 目标。
40
+ - `skill.zip` 只能面向 Claude 目标。
41
+ - 不要自动新建 Claude 目标 agent。
42
+ - 没完成校验前,绝不能宣称安装成功。
43
+ - 如果新建目标后又失败了,能安全回滚就先回滚;不能回滚就如实告诉用户当前残留状态。
44
+ - 最终成功或失败时,必须发送一条独立的 `egg-install-status` 指令消息。
45
+ - 状态指令消息必须单独发送,不要和自然语言解释混在同一条里。
46
+ - 用户拒绝确认或主动取消时,必须发送 `status=failed`、`error_code=user_cancelled` 的状态指令后再结束。
47
+
48
+ ## 安装状态指令
49
+
50
+ server 不会猜自然语言。要让安装单进入"进行中 / 成功 / 失败",你必须发送这类单行消息:
51
+
52
+ ```text
53
+ [[egg-install-status|install_id=<INSTALL_ID>|status=<running|success|failed>|step=<STEP>|summary=<URI_ENCODED_SUMMARY>]]
54
+ ```
55
+
56
+ 常用可选字段:
57
+
58
+ - `target_agent_id=<AGENT_ID>`:成功时尽量带上,尤其是 `create_new`。
59
+ - `detail_text=<URI_ENCODED_DETAIL>`:补充更长说明。
60
+ - `error_code=<ERROR_CODE>`:失败时建议带上。
61
+ - `error_msg=<URI_ENCODED_ERROR_MSG>`:失败时建议带上。
62
+
63
+ 规则:
64
+
65
+ 1. `install_id` 必须使用上下文里的原值。
66
+ 2. `status` 只能是 `running`、`success`、`failed`。
67
+ 3. `summary`、`detail_text`、`error_msg` 如果有空格、中文或特殊字符,按 URI component 编码。
68
+ 4. 这条指令只负责状态收口;如果要跟用户解释原因,另发一条正常文字消息。
69
+ 5. `create_new` 成功时,必须尽量带 `target_agent_id`,否则 server 可能无法通过最终校验。
70
+
71
+ ## 统一 API 请求机制
72
+
73
+ 当安装流程需要访问 Grix 远端能力时,统一按下面路由,不要绕过:
74
+
75
+ 1. 查联系人 / 会话 / 消息:调用 `grix_query`
76
+ 2. 群治理动作(建群、加人、移人、禁言、解散):调用 `grix_group`
77
+ 3. 创建远端 API agent:调用 `grix_agent_admin`
78
+
79
+ 规则:
80
+
81
+ 1. 不直接拼接 `Authorization` 或手工构造 `/v1/agent-api/*` 请求。
82
+ 2. 不写临时通讯脚本,不走隐藏协议。
83
+ 3. 优先复用 `accountId`;若上下文有歧义,先确认后再调用工具。
84
+
85
+ ## 推荐流程
86
+
87
+ ### `persona.zip` -> OpenClaw
88
+
89
+ 1. 读取上下文,确认是 `create_new` 还是 `existing_agent`。
90
+ 2. 和用户确认目标 agent 或新 agent 命名;**用户拒绝则发 `failed/user_cancelled` 指令后结束**。
91
+ 3. 如果需要新建远端 API agent,用 `grix_agent_admin` 创建。
92
+ 4. 用 OpenClaw 正规步骤准备本地目标目录和配置。
93
+ 5. 下载 egg 包,并校验 hash / manifest(如果上下文提供)。
94
+ 6. 发送 `status=running`、`step=downloaded` 状态指令。
95
+ 7. 安装 persona 内容。
96
+ 8. 发送 `status=running`、`step=installed` 状态指令。
97
+ 9. 按需刷新或重启本地运行时。
98
+ 10. 校验目标 agent 仍然可用。
99
+ - 校验失败 → 尝试回滚(含步骤3新建的远端 agent),无法回滚则如实告知残留状态 → 发 `failed` 指令后结束。
100
+ 11. 发送 `status=success` 状态指令(带 `target_agent_id`),再向用户汇报完成。
101
+
102
+ ### `skill.zip` -> Claude
103
+
104
+ 1. 确认上下文指定的 Claude 目标 agent 存在;**不存在则发 `failed/target_not_found` 指令后结束**。
105
+ 2. 和用户确认目标 agent;**用户拒绝则发 `failed/user_cancelled` 指令后结束**。
106
+ 3. 下载 skill 包,并校验 hash / manifest(如果上下文提供)。
107
+ 4. 发送 `status=running`、`step=downloaded` 状态指令。
108
+ 5. 用 Claude 正规步骤安装 skill 包。
109
+ 6. 发送 `status=running`、`step=installed` 状态指令。
110
+ 7. 按需刷新配置或重载运行时。
111
+ 8. 校验目标 agent 仍然可用。
112
+ - 校验失败 → 如实告知用户 → 发 `failed` 指令后结束。
113
+ 9. 发送 `status=success` 状态指令(带 `target_agent_id`),再向用户汇报完成。
114
+
115
+ ## 每次安装至少校验这些点
116
+
117
+ - 目标 agent 选对了
118
+ - 包已成功下载
119
+ - hash / manifest 校验通过(如果提供)
120
+ - 安装内容已经落到目标位置
121
+ - 目标 agent 安装后仍然可用
122
+
123
+ ## 指令示例
124
+
125
+ 进行中(下载完成):
126
+
127
+ ```text
128
+ [[egg-install-status|install_id=eggins_20370001|status=running|step=downloaded|summary=%E5%B7%B2%E4%B8%8B%E8%BD%BD%E5%B9%B6%E9%AA%8C%E8%AF%81%E5%AE%89%E8%A3%85%E5%8C%85]]
129
+ ```
130
+
131
+ 进行中(安装落位完成):
132
+
133
+ ```text
134
+ [[egg-install-status|install_id=eggins_20370001|status=running|step=installed|summary=%E5%AE%89%E8%A3%85%E5%86%85%E5%AE%B9%E5%B7%B2%E8%90%BD%E4%BD%8D%EF%BC%8C%E6%A0%A1%E9%AA%8C%E4%B8%AD]]
135
+ ```
136
+
137
+ 成功:
138
+
139
+ ```text
140
+ [[egg-install-status|install_id=eggins_20370001|status=success|step=completed|target_agent_id=2035123456789012345|summary=%E5%B7%B2%E5%AE%8C%E6%88%90%E5%AE%89%E8%A3%85]]
141
+ ```
142
+
143
+ 失败(用户取消):
144
+
145
+ ```text
146
+ [[egg-install-status|install_id=eggins_20370001|status=failed|step=user_cancelled|error_code=user_cancelled|summary=%E7%94%A8%E6%88%B7%E5%8F%96%E6%B6%88%E5%AE%89%E8%A3%85]]
147
+ ```
148
+
149
+ 失败(目标不存在):
150
+
151
+ ```text
152
+ [[egg-install-status|install_id=eggins_20370001|status=failed|step=target_not_found|error_code=target_not_found|error_msg=%E6%8C%87%E5%AE%9A%E7%9A%84%20Claude%20agent%20%E4%B8%8D%E5%AD%98%E5%9C%A8|summary=%E5%AE%89%E8%A3%85%E5%A4%B1%E8%B4%A5]]
153
+ ```
154
+
155
+ 失败(下载失败):
156
+
157
+ ```text
158
+ [[egg-install-status|install_id=eggins_20370001|status=failed|step=download_failed|error_code=download_failed|error_msg=%E4%B8%8B%E8%BD%BD%E5%AE%89%E8%A3%85%E5%8C%85%E5%A4%B1%E8%B4%A5|summary=%E5%AE%89%E8%A3%85%E5%A4%B1%E8%B4%A5]]
159
+ ```
160
+
161
+ ## 回复风格
162
+
163
+ - 用正常对话回复用户
164
+ - 进度回报要短、明确、可执行
165
+ - 失败说明要具体
166
+ - 最终总结必须包含目标 agent 和安装结果
167
+
168
+ ## References
169
+
170
+ 1. Load [references/api-contract.md](references/api-contract.md).
@@ -0,0 +1,38 @@
1
+ # API Contract
2
+
3
+ ## Purpose
4
+
5
+ Unify remote API communication in `egg-install` with the same typed tool pathway used by other grix-admin skills.
6
+
7
+ ## Base Rules
8
+
9
+ 1. Base path is `/v1/agent-api`.
10
+ 2. Auth is `Authorization: Bearer <agent_api_key>`.
11
+ 3. Caller must be `provider_type=3` and `status=active`.
12
+ 4. `egg-install` must not send direct HTTP requests to Grix by itself.
13
+
14
+ ## Unified Tool Path
15
+
16
+ Use only these entry points for remote communication:
17
+
18
+ | Install intent | Tool | Notes |
19
+ |---|---|---|
20
+ | Contact/session/message lookup | `grix_query` | Read-only queries |
21
+ | Group lifecycle and membership ops | `grix_group` | Governance operations |
22
+ | Create remote API agent | `grix_agent_admin` | Returns `id`, `agent_name`, `api_endpoint`, `api_key`, `api_key_hint` |
23
+
24
+ Local binding remains a local operation via bundled script:
25
+
26
+ - `scripts/grix_agent_bind.py configure-local-openclaw ... --apply`
27
+
28
+ ## Prohibited Paths
29
+
30
+ 1. Do not use `curl`, `fetch`, `axios`, or custom temporary scripts to call `/v1/agent-api/*`.
31
+ 2. Do not bypass typed tools with hidden protocol payloads.
32
+ 3. Do not auto-retry non-idempotent create actions without explicit confirmation.
33
+
34
+ ## Retry Policy
35
+
36
+ 1. Scope/auth/parameter errors: no automatic retry.
37
+ 2. Transient network failure: at most one retry, and only after explicit confirmation.
38
+ 3. Installation status directives (`egg-install-status`) must still be emitted on terminal success/failure.
@@ -0,0 +1,144 @@
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, 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`, `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`, `add_members`, `remove_members`, `update_member_role`, `update_all_members_muted`, `update_member_speaking`, `dissolve`
27
+ 3. `accountId`: optional; include it when the configured account is ambiguous
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
+ ### remove_members
71
+
72
+ Required input:
73
+
74
+ 1. `sessionId`
75
+ 2. `memberIds`
76
+
77
+ ### update_member_role
78
+
79
+ Required input:
80
+
81
+ 1. `sessionId`
82
+ 2. `memberId`
83
+ 3. `role`
84
+
85
+ Guardrails:
86
+
87
+ 1. Only use `memberType=1` for role updates.
88
+ 2. Never guess a role value; confirm when unclear.
89
+
90
+ ### update_all_members_muted
91
+
92
+ Required input:
93
+
94
+ 1. `sessionId`
95
+ 2. `allMembersMuted`
96
+
97
+ Guardrails:
98
+
99
+ 1. Only use this for group-wide mute state changes.
100
+ 2. Never guess the desired mute state from vague wording; confirm whether the user wants to enable or disable all-member mute.
101
+
102
+ ### update_member_speaking
103
+
104
+ Required input:
105
+
106
+ 1. `sessionId`
107
+ 2. `memberId`
108
+ 3. At least one of `isSpeakMuted` or `canSpeakWhenAllMuted`
109
+
110
+ Guardrails:
111
+
112
+ 1. Only use `memberType=1` or `memberType=2`.
113
+ 2. Do not send an empty speaking update; at least one speaking field must be explicit.
114
+ 3. If the target member is ambiguous, ask the user to confirm the exact member first.
115
+
116
+ ### detail / dissolve
117
+
118
+ Required input:
119
+
120
+ 1. `sessionId`
121
+
122
+ ## Error Handling Rules
123
+
124
+ 1. `403/20011`:
125
+ report missing scope and ask owner to grant the scope in Aibot Agent permission page.
126
+ 2. `401/10001`:
127
+ report invalid key/auth and suggest checking agent config or rotating API key.
128
+ 3. `403/10002`:
129
+ report agent is not active or invalid provider type.
130
+ 4. `400/10003`:
131
+ report invalid/missing parameters and ask user for corrected values.
132
+ 5. Other errors:
133
+ return backend `msg` and stop automatic retries.
134
+
135
+ ## Response Style
136
+
137
+ 1. State action result first.
138
+ 2. Include key identifiers (`session_id`, member count, mute state) when successful.
139
+ 3. Include exact remediation when failed.
140
+ 4. Never hide scope or auth errors behind generic wording.
141
+
142
+ ## References
143
+
144
+ 1. Load [references/api-contract.md](references/api-contract.md) when you need exact tool mapping, payload examples, and scope matrix.
@@ -0,0 +1,73 @@
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_create` | `POST` | `/sessions/create_group` | `group.create` |
19
+ | `group_member_add` | `POST` | `/sessions/members/add` | `group.member.add` |
20
+
21
+ ## OpenClaw Tool Mapping
22
+
23
+ Use the native `grix_group` tool with typed fields:
24
+
25
+ | Tool action | HTTP action | Required fields |
26
+ |---|---|---|
27
+ | `create` | `group_create` | `name` |
28
+ | `detail` | `group_detail_read` | `sessionId` |
29
+ | `add_members` | `group_member_add` | `sessionId`, `memberIds` |
30
+ | `remove_members` | `group_member_remove` | `sessionId`, `memberIds` |
31
+ | `update_member_role` | `group_member_role_update` | `sessionId`, `memberId`, `role` |
32
+ | `update_all_members_muted` | `group_all_members_muted_update` | `sessionId`, `allMembersMuted` |
33
+ | `update_member_speaking` | `group_member_speaking_update` | `sessionId`, `memberId`, `isSpeakMuted` or `canSpeakWhenAllMuted` |
34
+ | `dissolve` | `group_dissolve` | `sessionId` |
35
+
36
+ ## Payload Templates
37
+
38
+ ### create
39
+
40
+ ```json
41
+ {
42
+ "action": "create",
43
+ "name": "项目协作群",
44
+ "memberIds": ["1002", "9991"],
45
+ "memberTypes": [1, 2]
46
+ }
47
+ ```
48
+
49
+ ### add_members
50
+
51
+ ```json
52
+ {
53
+ "action": "add_members",
54
+ "sessionId": "task_room_9083",
55
+ "memberIds": ["1003"],
56
+ "memberTypes": [1]
57
+ }
58
+ ```
59
+
60
+ ## Error Matrix
61
+
62
+ | HTTP/BizCode | Meaning | Skill Response |
63
+ |---|---|---|
64
+ | `403/20011` | agent scope forbidden | Tell owner to grant corresponding scope |
65
+ | `400/10003` | invalid request payload | Ask for missing or corrected parameters |
66
+ | `401/10001` | invalid or missing auth | Check api_key and account config |
67
+ | `403/10002` | agent not active / invalid provider | Ask owner to activate the agent |
68
+
69
+ ## Retry Policy
70
+
71
+ 1. Never auto-retry `group_create` unless user confirms.
72
+ 2. Allow one retry for transient network failure only.
73
+ 3. Do not retry auth/scope/parameter failures automatically.
@@ -0,0 +1,151 @@
1
+ ---
2
+ name: grix-query
3
+ description: Use the typed `grix_query` tool for Grix contact search, session search, and session message history lookup. Trigger when users ask to find contacts, locate a conversation, 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 message history.
10
+
11
+ ## Workflow
12
+
13
+ 1. Parse the user request into one action:
14
+ `contact_search`, `session_search`, or `message_history`.
15
+ 2. Validate required fields before any tool call.
16
+ 3. Call `grix_query` exactly once per business action.
17
+ 4. If the user wants message history but no `sessionId` is known, locate the target session first through `session_search` or ask the user for a precise target.
18
+ 5. Return exact remediation for scope, auth, and parameter failures.
19
+
20
+ ## Tool Contract
21
+
22
+ For Grix query actions, always call:
23
+
24
+ 1. Tool: `grix_query`
25
+ 2. `action`: one of `contact_search`, `session_search`, or `message_history`
26
+ 3. `accountId`: optional; include it when the configured account is ambiguous
27
+
28
+ Rules:
29
+
30
+ 1. Pass query parameters with their exact typed field names.
31
+ 2. Use `id` for `contact_search` and `session_search`.
32
+ 3. Use `sessionId`, `beforeId`, and `limit` explicitly for message history.
33
+ 4. Never invent a `sessionId`. Resolve it from context, from a previous tool result, or ask the user.
34
+ 5. Keep one tool call per action for audit clarity.
35
+
36
+ ## Single Lookup Usage
37
+
38
+ When the user already provides one exact ID, do not do fuzzy search.
39
+ Call the corresponding search action once and return the backend result as-is in the normal search-result shape.
40
+
41
+ 1. Single contact lookup:
42
+ use `action: "contact_search"` and pass `id`
43
+ 2. Single session lookup:
44
+ use `action: "session_search"` and pass `id`
45
+
46
+ ID meaning:
47
+
48
+ 1. `contact_search.id`:
49
+ contact or Agent numeric ID, for example `1002` or `9992`
50
+ 2. `session_search.id`:
51
+ exact session ID string, for example `task_room_9083`
52
+
53
+ Examples:
54
+
55
+ ```json
56
+ {
57
+ "action": "contact_search",
58
+ "id": "1002"
59
+ }
60
+ ```
61
+
62
+ ```json
63
+ {
64
+ "action": "session_search",
65
+ "id": "task_room_9083"
66
+ }
67
+ ```
68
+
69
+ ## Action Contracts
70
+
71
+ ### contact_search
72
+
73
+ Purpose: search the owner's Grix contact directory.
74
+ When `id` is provided, return the exact matching contact record in the same search-result shape.
75
+
76
+ Required input:
77
+
78
+ 1. `id` (contact ID, numeric string)
79
+
80
+ Optional input:
81
+
82
+ 1. `limit`
83
+ 2. `offset`
84
+
85
+ Guardrails:
86
+
87
+ 1. Use this when the target contact ID is already known and you need the exact contact entry.
88
+ 2. Do not jump directly to session history from a vague contact hint; resolve the contact or session first.
89
+ 3. `id` must be the current contact's numeric ID, not username, nickname, remark name, or session ID.
90
+
91
+ ### session_search
92
+
93
+ Purpose: search the owner's visible sessions by final display title.
94
+ When `id` is provided, return the exact matching session in the same search-result shape.
95
+
96
+ Required input:
97
+
98
+ 1. `id` (session ID)
99
+
100
+ Optional input:
101
+
102
+ 1. `limit`
103
+ 2. `offset`
104
+
105
+ Guardrails:
106
+
107
+ 1. Use this when the target session ID is already known and you need the exact session entry.
108
+ 2. If multiple sessions match, present the candidates and let the user choose before reading history.
109
+ 3. `id` must be the exact current `session_id`, not group name, title text, or contact ID.
110
+
111
+ ### message_history
112
+
113
+ Purpose: read recent message history from a known session.
114
+
115
+ Required input:
116
+
117
+ 1. `sessionId`
118
+
119
+ Optional input:
120
+
121
+ 1. `beforeId`
122
+ 2. `limit`
123
+
124
+ Guardrails:
125
+
126
+ 1. Only call this after the target session is unambiguous.
127
+ 2. Use `beforeId` only for older-page pagination.
128
+ 3. Do not claim to have full history if only one page was fetched.
129
+
130
+ ## Error Handling Rules
131
+
132
+ 1. `403/20011`:
133
+ report missing scope and ask the owner to grant the required scope in the Aibot Agent permission page.
134
+ 2. `401/10001`:
135
+ report invalid key/auth and suggest checking agent config or rotating the API key.
136
+ 3. `403/10002`:
137
+ report the agent is not active or has an invalid provider type.
138
+ 4. `400/10003`:
139
+ report invalid or missing parameters and ask the user for corrected values.
140
+ 5. `404/4004`:
141
+ report the target session does not exist or is not visible.
142
+ 6. Other errors:
143
+ return the backend `msg` and stop automatic retries.
144
+
145
+ ## Response Style
146
+
147
+ 1. State the query result first.
148
+ 2. Include key identifiers from successful lookups:
149
+ `peer_id` / `peer_type` for contacts, `session_id` for sessions, and message identifiers for history.
150
+ 3. If history results may be partial, state that clearly.
151
+ 4. Never hide scope or auth errors behind generic wording.
@@ -0,0 +1,80 @@
1
+ ---
2
+ name: grix-register
3
+ description: 仅用于初次安装阶段,完成 grix.dhf.pub 账号注册/登录并拿到第一个 provider_type=3 Agent 的参数;本技能不做任何本地 OpenClaw 配置。
4
+ ---
5
+
6
+ # Grix Register
7
+
8
+ 这个技能只负责“初次安装”的云端准备:账号注册/登录 + 生成首个 `provider_type=3` Agent 参数。
9
+ 你(AI)在终端里全自动操作,**不需要用户打开浏览器**。拿到参数后,必须移交给 `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
+ scripts/grix_auth.py send-email-code --email "<用户的email>" --scene "register"
25
+ ```
26
+ 3. 等待命令执行成功后,提示用户去邮箱查收验证码,并询问该验证码。
27
+
28
+ ### 2. 执行自动注册(获取 Token)
29
+
30
+ 1. 用户提供验证码后,你需要为用户生成一个复杂度高且随机安全的密码(建议生成一个12位的强密码,包含大小写、数字和特殊字符)。
31
+ 2. 使用收集到的信息,执行注册命令:
32
+ ```bash
33
+ scripts/grix_auth.py register --email "<邮箱>" --password "<生成的随机密码>" --email-code "<验证码>"
34
+ ```
35
+ 3. 这个命令成功后会返回用户的 `access_token`。请在回复中安全地**将生成的密码告知用户**,建议他们妥善保存。
36
+
37
+ 注:如果注册提示邮箱已注册,可切换 `scripts/grix_auth.py login` 路径继续获取 `access_token`。
38
+
39
+ ### 3. 创建首个云端 Agent 参数
40
+
41
+ 拿到 `access_token` 后,询问 Agent 名称(如果上下文已有就直接用),执行:
42
+
43
+ ```bash
44
+ scripts/grix_auth.py create-api-agent --access-token "<token>" --agent-name "<agent名称>"
45
+ ```
46
+
47
+ 若同名 `provider_type=3` Agent 已存在,脚本会自动轮换 API Key 后复用。
48
+
49
+ ### 4. 强制移交给 grix-admin
50
+
51
+ 第三步执行成功后,脚本会返回一些关键设定:
52
+ - `agent_id`
53
+ - `agent_name`
54
+ - `api_endpoint`
55
+ - `api_key`
56
+
57
+ 然后立刻交给 `grix-admin`,并传递如下 payload:
58
+
59
+ ```json
60
+ {
61
+ "mode": "bind-local",
62
+ "agent_name": "<agent_name>",
63
+ "agent_id": "<agent_id>",
64
+ "api_endpoint": "<api_endpoint>",
65
+ "api_key": "<api_key>"
66
+ }
67
+ ```
68
+
69
+ ## Guardrails
70
+
71
+ 1. 不要求用户去网页注册或手动点页面。
72
+ 2. 不修改任何本地 OpenClaw 配置。
73
+ 3. 不安装插件、不改工具权限、不重启 gateway。
74
+ 4. 创建或复用出参数后,必须交接给 `grix-admin`。
75
+
76
+ ## References
77
+
78
+ 1. [references/api-contract.md](references/api-contract.md)
79
+ 2. [references/handoff-contract.md](references/handoff-contract.md)
80
+ 3. [scripts/grix_auth.py](scripts/grix_auth.py)