@laceletho/plugin-openclaw 0.2.0 → 1.1.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.
- package/README.md +20 -69
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,6 +11,8 @@ OpenCode plugin for session callback support with OpenClaw. Subscribes to OpenCo
|
|
|
11
11
|
|
|
12
12
|
## Architecture
|
|
13
13
|
|
|
14
|
+
This plugin runs inside **OpenCode** and provides an HTTP server for callback registration:
|
|
15
|
+
|
|
14
16
|
```
|
|
15
17
|
┌─────────────────┐ POST /register ┌─────────────────────┐
|
|
16
18
|
│ CLI/Tool │ ──────────────────────> │ OpenclawPlugin │
|
|
@@ -24,7 +26,7 @@ OpenCode plugin for session callback support with OpenClaw. Subscribes to OpenCo
|
|
|
24
26
|
┌─────────────────────┐
|
|
25
27
|
│ Subscribe to │
|
|
26
28
|
│ session.updated │
|
|
27
|
-
│
|
|
29
|
+
│ message.part.* │
|
|
28
30
|
└──────────┬──────────┘
|
|
29
31
|
│
|
|
30
32
|
│ session completes
|
|
@@ -43,17 +45,13 @@ npm install @laceletho/plugin-openclaw
|
|
|
43
45
|
|
|
44
46
|
## Configuration
|
|
45
47
|
|
|
46
|
-
###
|
|
48
|
+
### Enable Plugin
|
|
47
49
|
|
|
48
50
|
Add to your `opencode.json`:
|
|
49
51
|
|
|
50
52
|
```json
|
|
51
53
|
{
|
|
52
54
|
"plugins": ["@laceletho/plugin-openclaw"],
|
|
53
|
-
"openclaw": {
|
|
54
|
-
"port": 9090,
|
|
55
|
-
"openclawApiKey": "your-openclaw-hooks-token"
|
|
56
|
-
}
|
|
57
55
|
}
|
|
58
56
|
```
|
|
59
57
|
|
|
@@ -66,13 +64,15 @@ Add to your `opencode.json`:
|
|
|
66
64
|
|
|
67
65
|
## How It Works
|
|
68
66
|
|
|
69
|
-
1. **Registration**:
|
|
67
|
+
1. **Registration**: A CLI/tool creates an OpenCode session and sends a POST request to the plugin's `/register` endpoint with the session ID and callback configuration.
|
|
70
68
|
|
|
71
|
-
2. **Event Subscription**: The plugin subscribes to OpenCode's `session.updated` and `session.deleted` events.
|
|
69
|
+
2. **Event Subscription**: The plugin subscribes to OpenCode's `session.updated`, `message.part.*`, and `session.deleted` events.
|
|
72
70
|
|
|
73
|
-
3. **
|
|
71
|
+
3. **Content Accumulation**: The plugin accumulates text content and tool outputs from `message.part.updated` and `message.part.delta` events.
|
|
74
72
|
|
|
75
|
-
4. **
|
|
73
|
+
4. **Callback Trigger**: When a registered session's status changes to `completed` or `failed`, the plugin sends a webhook to the configured OpenClaw endpoint with the accumulated content.
|
|
74
|
+
|
|
75
|
+
5. **Cleanup**: After sending the callback (or when a session is deleted), the plugin removes the registration from memory.
|
|
76
76
|
|
|
77
77
|
## API Endpoints
|
|
78
78
|
|
|
@@ -118,41 +118,19 @@ Health check endpoint.
|
|
|
118
118
|
|
|
119
119
|
The plugin subscribes to the following OpenCode events:
|
|
120
120
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
### `session.updated`
|
|
130
|
-
|
|
131
|
-
Triggered when session metadata is updated. The plugin monitors the session status and sends the callback when the status becomes `completed` or `failed`.
|
|
132
|
-
|
|
133
|
-
### `session.error`
|
|
134
|
-
|
|
135
|
-
Triggered when a session encounters an error. The plugin marks the session as failed and includes error information in the callback.
|
|
136
|
-
|
|
137
|
-
### `session.deleted`
|
|
138
|
-
|
|
139
|
-
Triggered when a session is deleted. The plugin removes the session from the callback registry.
|
|
140
|
-
|
|
141
|
-
### Important: Event Data Limitations
|
|
142
|
-
|
|
143
|
-
**`session.updated` events do NOT contain message content**. They only include session metadata (id, status, timestamps, etc.). The actual content is delivered through separate `message.part.*` events.
|
|
144
|
-
|
|
145
|
-
The plugin automatically handles this by:
|
|
146
|
-
1. Listening to `message.part.updated` and `message.part.delta` events
|
|
147
|
-
2. Accumulating text and tool outputs in memory
|
|
148
|
-
3. Including the accumulated content when sending the callback on `session.updated`
|
|
121
|
+
| Event | Purpose |
|
|
122
|
+
|-------|---------|
|
|
123
|
+
| `message.part.updated` | Accumulate text content and tool outputs |
|
|
124
|
+
| `message.part.delta` | Append streaming text deltas |
|
|
125
|
+
| `session.updated` | Monitor session status for completion |
|
|
126
|
+
| `session.error` | Track session errors |
|
|
127
|
+
| `session.deleted` | Clean up registry on session deletion |
|
|
149
128
|
|
|
150
129
|
## Callback to OpenClaw
|
|
151
130
|
|
|
152
131
|
When a registered session completes, the plugin sends a POST request to the configured URL:
|
|
153
132
|
|
|
154
|
-
|
|
155
|
-
|
|
133
|
+
**Payload:**
|
|
156
134
|
```json
|
|
157
135
|
{
|
|
158
136
|
"message": "Task completed: sess_abc123\n\nResult:\nHere's the code...",
|
|
@@ -172,36 +150,9 @@ Content-Type: application/json
|
|
|
172
150
|
|
|
173
151
|
## Usage with CLI
|
|
174
152
|
|
|
175
|
-
This plugin is designed to work with
|
|
176
|
-
|
|
177
|
-
```bash
|
|
178
|
-
# 1. Start OpenCode with the plugin
|
|
179
|
-
opencode serve
|
|
180
|
-
|
|
181
|
-
# 2. From another terminal, dispatch a task with CLI
|
|
182
|
-
export OPENCODE_URL=http://localhost:4096
|
|
183
|
-
export OPENCODE_PASSWORD=your-password
|
|
184
|
-
export OPENCLAW_CALLBACK_URL=http://localhost:18789/hooks/agent
|
|
185
|
-
|
|
186
|
-
openclaw-opencode task "Write a Python function"
|
|
187
|
-
|
|
188
|
-
# 3. Plugin automatically sends callback when session completes
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
## OpenClaw Configuration
|
|
192
|
-
|
|
193
|
-
To receive webhook callbacks, OpenClaw must have its **hooks system enabled**. Add this to your OpenClaw configuration:
|
|
153
|
+
This plugin is designed to work with `@laceletho/openclaw-opencode-cli`.
|
|
194
154
|
|
|
195
|
-
|
|
196
|
-
{
|
|
197
|
-
"hooks": {
|
|
198
|
-
"enabled": true,
|
|
199
|
-
"token": "your-openclaw-hooks-token",
|
|
200
|
-
"path": "/hooks",
|
|
201
|
-
"allowedAgentIds": ["main", "hooks"]
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
```
|
|
155
|
+
**See the [CLI documentation](https://github.com/LaceLetho/openclaw-opencode-cli) for usage instructions.**
|
|
205
156
|
|
|
206
157
|
## Testing
|
|
207
158
|
|