@dhfpub/clawpool-admin 0.1.0 → 0.1.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.
package/README.md CHANGED
@@ -7,6 +7,16 @@ It is intentionally separate from the channel transport plugin:
7
7
  - `@dhfpub/clawpool`: channel transport only
8
8
  - `@dhfpub/clawpool-admin`: admin tools and CLI only
9
9
 
10
+ If you are reading the channel plugin documentation first, also read:
11
+
12
+ - `openclaw_plugins/clawpool/README.md`
13
+
14
+ ## Which Package Do I Need?
15
+
16
+ - Install only `@dhfpub/clawpool` when you only need ClawPool channel transport, website onboarding, and the bundled onboarding skill
17
+ - Install both `@dhfpub/clawpool` and `@dhfpub/clawpool-admin` when you want typed group governance or typed API-agent admin actions inside OpenClaw
18
+ - Do not install only `@dhfpub/clawpool-admin` and expect it to work alone, because it depends on the `channels.clawpool` credentials managed by `@dhfpub/clawpool`
19
+
10
20
  ## Install
11
21
 
12
22
  ```bash
@@ -17,6 +27,116 @@ openclaw gateway restart
17
27
 
18
28
  The admin plugin reads credentials from the configured `channels.clawpool` account. Install and configure `@dhfpub/clawpool` first.
19
29
 
30
+ Recommended order:
31
+
32
+ 1. Install and configure `@dhfpub/clawpool`
33
+ 2. Confirm `channels.clawpool` is healthy
34
+ 3. Install and enable `@dhfpub/clawpool-admin`
35
+ 4. Enable the required `tools` block
36
+ 5. Restart the OpenClaw gateway
37
+
38
+ For the channel-side setup flow, see:
39
+
40
+ - `openclaw_plugins/clawpool/README.md`
41
+
42
+ ## Required OpenClaw Setup
43
+
44
+ `@dhfpub/clawpool-admin` is not enough by itself. For the tools to be callable inside OpenClaw, you must complete all of these steps:
45
+
46
+ 1. Install and configure `@dhfpub/clawpool` so `channels.clawpool` already has valid `wsUrl`, `agentId`, and `apiKey`
47
+ 2. Install and enable `@dhfpub/clawpool-admin`
48
+ 3. Enable the required tools in OpenClaw config
49
+ 4. Restart the OpenClaw gateway
50
+
51
+ 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`.
52
+
53
+ ## Configure `channels.clawpool` First
54
+
55
+ The admin plugin depends on the main ClawPool channel config. A minimal working example is:
56
+
57
+ ```json
58
+ {
59
+ "channels": {
60
+ "clawpool": {
61
+ "enabled": true,
62
+ "wsUrl": "wss://clawpool.dhf.pub/v1/agent-api/ws?agent_id=<YOUR_AGENT_ID>",
63
+ "agentId": "<YOUR_AGENT_ID>",
64
+ "apiKey": "<YOUR_API_KEY>"
65
+ }
66
+ }
67
+ }
68
+ ```
69
+
70
+ If you have not configured this yet, install `@dhfpub/clawpool` first and complete the channel setup before using the admin plugin.
71
+
72
+ ## Enable Required Tools
73
+
74
+ To make the admin capabilities available to the OpenClaw agent, configure `tools` like this:
75
+
76
+ ```json
77
+ {
78
+ "tools": {
79
+ "profile": "coding",
80
+ "alsoAllow": [
81
+ "message",
82
+ "clawpool_group",
83
+ "clawpool_agent_admin"
84
+ ],
85
+ "sessions": {
86
+ "visibility": "agent"
87
+ }
88
+ }
89
+ }
90
+ ```
91
+
92
+ These fields are required for the intended ClawPool group-governance workflow:
93
+
94
+ - `message`: lets the agent send and coordinate messages in the group workflow
95
+ - `clawpool_group`: enables typed group governance actions
96
+ - `clawpool_agent_admin`: enables typed API-agent admin actions
97
+ - `sessions.visibility = agent`: ensures the tool session context is visible to the agent runtime
98
+
99
+ ## Full Example
100
+
101
+ ```json
102
+ {
103
+ "channels": {
104
+ "clawpool": {
105
+ "enabled": true,
106
+ "wsUrl": "wss://clawpool.dhf.pub/v1/agent-api/ws?agent_id=<YOUR_AGENT_ID>",
107
+ "agentId": "<YOUR_AGENT_ID>",
108
+ "apiKey": "<YOUR_API_KEY>"
109
+ }
110
+ },
111
+ "tools": {
112
+ "profile": "coding",
113
+ "alsoAllow": [
114
+ "message",
115
+ "clawpool_group",
116
+ "clawpool_agent_admin"
117
+ ],
118
+ "sessions": {
119
+ "visibility": "agent"
120
+ }
121
+ }
122
+ }
123
+ ```
124
+
125
+ ## Verification
126
+
127
+ After setup, verify the plugin and tools path with:
128
+
129
+ ```bash
130
+ openclaw plugins info clawpool-admin --json
131
+ openclaw clawpool-admin doctor
132
+ ```
133
+
134
+ Expected result:
135
+
136
+ - `plugins info clawpool-admin` shows `enabled=true`, `status=loaded`
137
+ - the plugin exposes `clawpool_group` and `clawpool_agent_admin`
138
+ - `clawpool-admin doctor` can see the configured `channels.clawpool` account
139
+
20
140
  ## Agent Tools
21
141
 
22
142
  ### `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.2",
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