@clawroom/openclaw 0.4.0 → 0.5.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 +3 -3
- package/package.json +2 -2
- package/src/channel.ts +19 -46
package/README.md
CHANGED
|
@@ -29,11 +29,11 @@ openclaw gateway restart
|
|
|
29
29
|
|
|
30
30
|
## Release
|
|
31
31
|
|
|
32
|
-
The repository includes a GitHub Actions workflow that publishes `@clawroom/protocol`, `@clawroom/sdk`, and `@clawroom/openclaw` to npm when a release tag is pushed.
|
|
32
|
+
The repository includes a GitHub Actions workflow that publishes `@clawroom/protocol`, `@clawroom/sdk`, `@clawroom/bridge`, and `@clawroom/openclaw` to npm when a release tag is pushed.
|
|
33
33
|
|
|
34
34
|
To publish a new version:
|
|
35
35
|
|
|
36
|
-
1. Update the package versions in `protocol/package.json`, `sdk/package.json`, and `plugin/package.json`.
|
|
36
|
+
1. Update the package versions in `protocol/package.json`, `sdk/package.json`, `bridge/package.json`, and `plugin/package.json`.
|
|
37
37
|
2. Commit and push the release commit to GitHub.
|
|
38
38
|
3. Push a release tag, for example `git tag plugin-0.2.3 && git push origin plugin-0.2.3`.
|
|
39
|
-
4. Watch `.github/workflows/release-plugin.yml` until all
|
|
39
|
+
4. Watch `.github/workflows/release-plugin.yml` until all publish jobs succeed.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clawroom/openclaw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "OpenClaw channel plugin for ClawRoom",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@clawroom/sdk"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@clawroom/sdk": "^0.
|
|
25
|
+
"@clawroom/sdk": "^0.5.0"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"openclaw": "*"
|
package/src/channel.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import type { ChannelPlugin } from "openclaw/plugin-sdk/core";
|
|
2
2
|
import type { OpenClawConfig } from "openclaw/plugin-sdk/core";
|
|
3
|
-
import { collectSkills } from "./skill-reporter.js";
|
|
3
|
+
// import { collectSkills } from "./skill-reporter.js";
|
|
4
4
|
import { getClawroomRuntime } from "./runtime.js";
|
|
5
|
-
import {
|
|
5
|
+
import { ClawroomPluginClient } from "./client.js";
|
|
6
6
|
import { setupTaskExecutor } from "./task-executor.js";
|
|
7
7
|
import { setupChatExecutor } from "./chat-executor.js";
|
|
8
8
|
|
|
9
9
|
// ── Config resolution ────────────────────────────────────────────────
|
|
10
10
|
|
|
11
|
-
const DEFAULT_ENDPOINT = "https://clawroom.site9.ai/api/
|
|
11
|
+
const DEFAULT_ENDPOINT = "https://clawroom.site9.ai/api/machines";
|
|
12
12
|
const DEFAULT_ACCOUNT_ID = "default";
|
|
13
13
|
|
|
14
14
|
interface ClawroomAccountConfig {
|
|
15
|
-
|
|
15
|
+
api_key?: string;
|
|
16
|
+
token?: string; // deprecated, fallback
|
|
16
17
|
endpoint?: string;
|
|
17
18
|
skills?: string[];
|
|
18
19
|
enabled?: boolean;
|
|
@@ -23,7 +24,7 @@ interface ResolvedClawroomAccount {
|
|
|
23
24
|
name: string;
|
|
24
25
|
enabled: boolean;
|
|
25
26
|
configured: boolean;
|
|
26
|
-
|
|
27
|
+
apiKey: string;
|
|
27
28
|
endpoint: string;
|
|
28
29
|
skills: string[];
|
|
29
30
|
}
|
|
@@ -39,7 +40,7 @@ function resolveClawroomAccount(opts: {
|
|
|
39
40
|
accountId?: string | null;
|
|
40
41
|
}): ResolvedClawroomAccount {
|
|
41
42
|
const section = readClawroomSection(opts.cfg);
|
|
42
|
-
const
|
|
43
|
+
const apiKey = section.api_key ?? section.token ?? "";
|
|
43
44
|
const endpoint = section.endpoint || DEFAULT_ENDPOINT;
|
|
44
45
|
const skills = Array.isArray(section.skills) ? section.skills : [];
|
|
45
46
|
const enabled = section.enabled !== false;
|
|
@@ -48,8 +49,8 @@ function resolveClawroomAccount(opts: {
|
|
|
48
49
|
accountId: opts.accountId ?? DEFAULT_ACCOUNT_ID,
|
|
49
50
|
name: "ClawRoom",
|
|
50
51
|
enabled,
|
|
51
|
-
configured:
|
|
52
|
-
|
|
52
|
+
configured: apiKey.length > 0,
|
|
53
|
+
apiKey,
|
|
53
54
|
endpoint,
|
|
54
55
|
skills,
|
|
55
56
|
};
|
|
@@ -57,7 +58,7 @@ function resolveClawroomAccount(opts: {
|
|
|
57
58
|
|
|
58
59
|
// ── Persistent client per gateway lifecycle ───────────────────────
|
|
59
60
|
|
|
60
|
-
let activeClient:
|
|
61
|
+
let activeClient: ClawroomPluginClient | null = null;
|
|
61
62
|
|
|
62
63
|
// ── Channel plugin definition ────────────────────────────────────────
|
|
63
64
|
|
|
@@ -104,17 +105,9 @@ export const clawroomPlugin: ChannelPlugin<ResolvedClawroomAccount> = {
|
|
|
104
105
|
deliveryMode: "direct",
|
|
105
106
|
|
|
106
107
|
sendText: async ({ to, text }) => {
|
|
107
|
-
// Outbound
|
|
108
|
-
//
|
|
109
|
-
//
|
|
110
|
-
// to deliver a reply through the channel outbound path.
|
|
111
|
-
if (activeClient) {
|
|
112
|
-
activeClient.send({
|
|
113
|
-
type: "agent.complete",
|
|
114
|
-
taskId: to,
|
|
115
|
-
output: text,
|
|
116
|
-
});
|
|
117
|
-
}
|
|
108
|
+
// Outbound path — task results are sent directly by executors,
|
|
109
|
+
// this is a fallback if openclaw routing triggers outbound delivery.
|
|
110
|
+
// No-op for machine client (executors handle it).
|
|
118
111
|
return { channel: "clawroom", messageId: to, to };
|
|
119
112
|
},
|
|
120
113
|
},
|
|
@@ -125,24 +118,16 @@ export const clawroomPlugin: ChannelPlugin<ResolvedClawroomAccount> = {
|
|
|
125
118
|
|
|
126
119
|
if (!account.configured) {
|
|
127
120
|
throw new Error(
|
|
128
|
-
"ClawRoom is not configured: set channels.clawroom.
|
|
121
|
+
"ClawRoom is not configured: set channels.clawroom.api_key in your OpenClaw config.",
|
|
129
122
|
);
|
|
130
123
|
}
|
|
131
124
|
|
|
132
125
|
const runtime = getClawroomRuntime();
|
|
133
|
-
const skills = collectSkills({
|
|
134
|
-
runtime,
|
|
135
|
-
configuredSkills: account.skills,
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
const deviceId = resolveDeviceId(ctx);
|
|
139
126
|
const log = ctx.log ?? undefined;
|
|
140
127
|
|
|
141
|
-
const client = new
|
|
128
|
+
const client = new ClawroomPluginClient({
|
|
142
129
|
endpoint: account.endpoint,
|
|
143
|
-
|
|
144
|
-
deviceId,
|
|
145
|
-
skills,
|
|
130
|
+
apiKey: account.apiKey,
|
|
146
131
|
log,
|
|
147
132
|
});
|
|
148
133
|
|
|
@@ -170,23 +155,11 @@ export const clawroomPlugin: ChannelPlugin<ResolvedClawroomAccount> = {
|
|
|
170
155
|
});
|
|
171
156
|
};
|
|
172
157
|
|
|
173
|
-
// Wire up
|
|
158
|
+
// Wire up polling events to OpenClaw health status
|
|
174
159
|
client.onWelcome(() => publishConnected());
|
|
175
|
-
client.onTask(() => {
|
|
176
|
-
// Any server task = update lastEventAt so gateway knows we're alive
|
|
177
|
-
ctx.setStatus({
|
|
178
|
-
accountId: account.accountId,
|
|
179
|
-
running: true,
|
|
180
|
-
connected: true,
|
|
181
|
-
lastEventAt: Date.now(),
|
|
182
|
-
lastStartAt: Date.now(),
|
|
183
|
-
lastStopAt: null,
|
|
184
|
-
lastError: null,
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
160
|
client.onDisconnect(() => publishDisconnected());
|
|
188
|
-
client.onFatal((reason
|
|
189
|
-
log?.error?.(`[clawroom] fatal error
|
|
161
|
+
client.onFatal((reason) => {
|
|
162
|
+
log?.error?.(`[clawroom] fatal error: ${reason}`);
|
|
190
163
|
ctx.setStatus({
|
|
191
164
|
accountId: account.accountId,
|
|
192
165
|
running: false,
|