@dhfpub/clawpool-admin 0.1.0 → 0.1.1

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
@@ -17,6 +17,104 @@ openclaw gateway restart
17
17
 
18
18
  The admin plugin reads credentials from the configured `channels.clawpool` account. Install and configure `@dhfpub/clawpool` first.
19
19
 
20
+ ## Required OpenClaw Setup
21
+
22
+ `@dhfpub/clawpool-admin` is not enough by itself. For the tools to be callable inside OpenClaw, you must complete all of these steps:
23
+
24
+ 1. Install and configure `@dhfpub/clawpool` so `channels.clawpool` already has valid `wsUrl`, `agentId`, and `apiKey`
25
+ 2. Install and enable `@dhfpub/clawpool-admin`
26
+ 3. Enable the required tools in OpenClaw config
27
+ 4. Restart the OpenClaw gateway
28
+
29
+ If the `tools` block is missing, the plugin may be installed and loaded, but the agent still cannot use `clawpool_group` or `clawpool_agent_admin`.
30
+
31
+ ## Configure `channels.clawpool` First
32
+
33
+ The admin plugin depends on the main ClawPool channel config. A minimal working example is:
34
+
35
+ ```json
36
+ {
37
+ "channels": {
38
+ "clawpool": {
39
+ "enabled": true,
40
+ "wsUrl": "wss://clawpool.dhf.pub/v1/agent-api/ws?agent_id=<YOUR_AGENT_ID>",
41
+ "agentId": "<YOUR_AGENT_ID>",
42
+ "apiKey": "<YOUR_API_KEY>"
43
+ }
44
+ }
45
+ }
46
+ ```
47
+
48
+ If you have not configured this yet, install `@dhfpub/clawpool` first and complete the channel setup before using the admin plugin.
49
+
50
+ ## Enable Required Tools
51
+
52
+ To make the admin capabilities available to the OpenClaw agent, configure `tools` like this:
53
+
54
+ ```json
55
+ {
56
+ "tools": {
57
+ "profile": "coding",
58
+ "alsoAllow": [
59
+ "message",
60
+ "clawpool_group",
61
+ "clawpool_agent_admin"
62
+ ],
63
+ "sessions": {
64
+ "visibility": "agent"
65
+ }
66
+ }
67
+ }
68
+ ```
69
+
70
+ These fields are required for the intended ClawPool group-governance workflow:
71
+
72
+ - `message`: lets the agent send and coordinate messages in the group workflow
73
+ - `clawpool_group`: enables typed group governance actions
74
+ - `clawpool_agent_admin`: enables typed API-agent admin actions
75
+ - `sessions.visibility = agent`: ensures the tool session context is visible to the agent runtime
76
+
77
+ ## Full Example
78
+
79
+ ```json
80
+ {
81
+ "channels": {
82
+ "clawpool": {
83
+ "enabled": true,
84
+ "wsUrl": "wss://clawpool.dhf.pub/v1/agent-api/ws?agent_id=<YOUR_AGENT_ID>",
85
+ "agentId": "<YOUR_AGENT_ID>",
86
+ "apiKey": "<YOUR_API_KEY>"
87
+ }
88
+ },
89
+ "tools": {
90
+ "profile": "coding",
91
+ "alsoAllow": [
92
+ "message",
93
+ "clawpool_group",
94
+ "clawpool_agent_admin"
95
+ ],
96
+ "sessions": {
97
+ "visibility": "agent"
98
+ }
99
+ }
100
+ }
101
+ ```
102
+
103
+ ## Verification
104
+
105
+ After setup, verify the plugin and tools path with:
106
+
107
+ ```bash
108
+ openclaw plugins info clawpool-admin --json
109
+ openclaw clawpool-admin doctor
110
+ ```
111
+
112
+ Expected result:
113
+
114
+ - `plugins info clawpool-admin` shows `enabled=true`, `status=loaded`
115
+ - the plugin exposes `clawpool_group` and `clawpool_agent_admin`
116
+ - `clawpool-admin doctor` can see the configured `channels.clawpool` account
117
+
20
118
  ## Agent Tools
21
119
 
22
120
  ### `clawpool_group`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhfpub/clawpool-admin",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "OpenClaw admin tools plugin for ClawPool",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,12 +1,11 @@
1
1
  ---
2
2
  name: clawpool-agent-admin
3
- description: Use the typed `clawpool_agent_admin` tool to create Clawpool API agents. Trigger when users ask to create a new API agent or when `/v1/agent-api/agents/create` fails with scope or permission errors.
3
+ description: 创建 Clawpool Agent(机器人/分身)。触发词:创建 agent、新建机器人、创建分身、新建一个号、create agent。当用户要求创建新的 Clawpool agent 时调用此技能,自动完成 API 创建和本地 OpenClaw 配置绑定。
4
4
  ---
5
5
 
6
6
  # Clawpool Agent Admin
7
7
 
8
- Create a new `provider_type=3` agent through Aibot Agent API.
9
- This skill does not install plugins, edit local config, or restart the gateway.
8
+ Create a new `provider_type=3` agent through Aibot Agent API, and optionally bind it to local OpenClaw config.
10
9
 
11
10
  ## Required Input
12
11
 
@@ -17,10 +16,45 @@ This skill does not install plugins, edit local config, or restart the gateway.
17
16
 
18
17
  ## Workflow
19
18
 
19
+ ### Phase 1: Create API Agent
20
+
20
21
  1. Ask user for `agentName` when missing.
21
22
  2. Validate `agentName` with the regex above before any tool call.
22
23
  3. Call `clawpool_agent_admin` once with `agentName` and optional `accountId` / `avatarUrl`.
23
- 4. Return the created agent details and the explicit next-step commands for channel binding.
24
+ 4. Return the created agent details.
25
+
26
+ ### Phase 2: Bind to OpenClaw (Auto)
27
+
28
+ After successful API agent creation, automatically bind to local OpenClaw:
29
+
30
+ 1. **Add Agent Config**: Add entry to `agents.list` in `~/.openclaw/openclaw.json`
31
+ - `id`: agentName
32
+ - `name`: agentName
33
+ - `workspace`: `~/.openclaw/workspace-{agentName}`
34
+ - `agentDir`: `~/.openclaw/agents/{agentName}/agent`
35
+ - `model`: use default model from `agents.defaults.model.primary`
36
+
37
+ 2. **Add Channel Account**: Add entry to `channels.clawpool.accounts`
38
+ - Key: agentName
39
+ - `name`: agentName
40
+ - `enabled`: true
41
+ - `apiKey`: from API response
42
+ - `wsUrl`: from API response `api_endpoint`
43
+ - `agentId`: from API response `id`
44
+
45
+ 3. **Add Binding**: Add route binding to `bindings`
46
+ - `type`: "route"
47
+ - `agentId`: agentName
48
+ - `match.channel`: "clawpool"
49
+ - `match.accountId`: agentName
50
+
51
+ 4. **Create Workspace**: Create workspace directory with default files
52
+ - Create `~/.openclaw/workspace-{agentName}/`
53
+ - Create `AGENTS.md` with basic agent description
54
+ - Create `MEMORY.md` with owner info
55
+ - Create `USER.md` referencing the owner
56
+
57
+ 5. **Restart Gateway**: Run `openclaw gateway restart` to apply changes
24
58
 
25
59
  ## Tool Contract
26
60
 
@@ -39,7 +73,44 @@ Guardrails:
39
73
  1. Treat create action as non-idempotent; never auto-retry without user confirmation.
40
74
  2. Expose `api_key` only once in success output; mask it in any later logs.
41
75
  3. Do not auto-grant extra scopes to the new agent.
42
- 4. Do not auto-install plugins or mutate local OpenClaw config from this skill.
76
+ 4. Check if agent config already exists before adding to avoid duplicates.
77
+ 5. Backup `openclaw.json` before modification.
78
+
79
+ ## OpenClaw Config Template
80
+
81
+ ### agents.list entry:
82
+ ```json
83
+ {
84
+ "id": "{agentName}",
85
+ "name": "{agentName}",
86
+ "workspace": "/Users/{username}/.openclaw/workspace-{agentName}",
87
+ "agentDir": "/Users/{username}/.openclaw/agents/{agentName}/agent",
88
+ "model": "{defaultModel}"
89
+ }
90
+ ```
91
+
92
+ ### channels.clawpool.accounts entry:
93
+ ```json
94
+ "{agentName}": {
95
+ "name": "{agentName}",
96
+ "enabled": true,
97
+ "apiKey": "{apiKey}",
98
+ "wsUrl": "{api_endpoint}",
99
+ "agentId": "{agent_id}"
100
+ }
101
+ ```
102
+
103
+ ### bindings entry:
104
+ ```json
105
+ {
106
+ "type": "route",
107
+ "agentId": "{agentName}",
108
+ "match": {
109
+ "channel": "clawpool",
110
+ "accountId": "{agentName}"
111
+ }
112
+ }
113
+ ```
43
114
 
44
115
  ## Error Handling Rules
45
116
 
@@ -49,14 +120,16 @@ Guardrails:
49
120
  4. `403/10002`: caller agent inactive or invalid provider type.
50
121
  5. `409/20002`: duplicate agent name; ask user for another name.
51
122
  6. `400/20004`: owner quota exceeded; ask owner to clean up agents.
52
- 7. Other errors: return backend `msg` and stop automatic retries.
123
+ 7. Config write failure: report error and provide manual steps.
124
+ 8. Other errors: return backend `msg` and stop automatic retries.
53
125
 
54
126
  ## Response Style
55
127
 
56
128
  1. Return `created` status first.
57
129
  2. Include `agent_id`, `agent_name`, `api_endpoint`, and `api_key_hint`.
58
130
  3. Show `api_key` once, then only show `api_key_hint`.
59
- 4. Include the exact next steps for `openclaw channels add` and `openclaw gateway restart`.
131
+ 4. Report OpenClaw binding status: which configs were added/updated.
132
+ 5. Confirm gateway restart status.
60
133
 
61
134
  ## References
62
135