@clawhive/openclaw-plugin 0.2.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 +217 -0
- package/dist/api.d.ts +6 -0
- package/dist/api.js +6 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +324 -0
- package/dist/runtime-api.d.ts +1 -0
- package/dist/runtime-api.js +1 -0
- package/dist/setup-entry.d.ts +4 -0
- package/dist/setup-entry.js +3 -0
- package/dist/src/agency-install/claimLoop.d.ts +41 -0
- package/dist/src/agency-install/claimLoop.js +188 -0
- package/dist/src/agent-panel/claimLoop.d.ts +32 -0
- package/dist/src/agent-panel/claimLoop.js +118 -0
- package/dist/src/agent-panel/executor.d.ts +8 -0
- package/dist/src/agent-panel/executor.js +368 -0
- package/dist/src/agent-panel/plan.d.ts +20 -0
- package/dist/src/agent-panel/plan.js +111 -0
- package/dist/src/agent-panel/prompts.d.ts +38 -0
- package/dist/src/agent-panel/prompts.js +87 -0
- package/dist/src/agent-panel/types.d.ts +45 -0
- package/dist/src/agent-panel/types.js +1 -0
- package/dist/src/agents.d.ts +44 -0
- package/dist/src/agents.js +195 -0
- package/dist/src/authorization.d.ts +34 -0
- package/dist/src/authorization.js +183 -0
- package/dist/src/channel.d.ts +5 -0
- package/dist/src/channel.js +93 -0
- package/dist/src/claimPolling.d.ts +9 -0
- package/dist/src/claimPolling.js +13 -0
- package/dist/src/client.d.ts +386 -0
- package/dist/src/client.js +595 -0
- package/dist/src/config.d.ts +28 -0
- package/dist/src/config.js +94 -0
- package/dist/src/defaults.d.ts +40 -0
- package/dist/src/defaults.js +52 -0
- package/dist/src/deviceCode.d.ts +16 -0
- package/dist/src/deviceCode.js +65 -0
- package/dist/src/heartbeat.d.ts +25 -0
- package/dist/src/heartbeat.js +65 -0
- package/dist/src/imageAttachments.d.ts +14 -0
- package/dist/src/imageAttachments.js +81 -0
- package/dist/src/inbound.d.ts +10 -0
- package/dist/src/inbound.js +140 -0
- package/dist/src/installMutex.d.ts +4 -0
- package/dist/src/installMutex.js +18 -0
- package/dist/src/market-install/claimLoop.d.ts +41 -0
- package/dist/src/market-install/claimLoop.js +183 -0
- package/dist/src/market-install/downloader.d.ts +36 -0
- package/dist/src/market-install/downloader.js +133 -0
- package/dist/src/market-install/executor.d.ts +28 -0
- package/dist/src/market-install/executor.js +352 -0
- package/dist/src/market-install/types.d.ts +62 -0
- package/dist/src/market-install/types.js +1 -0
- package/dist/src/market-install/verifier.d.ts +32 -0
- package/dist/src/market-install/verifier.js +60 -0
- package/dist/src/market-publish/packager.d.ts +34 -0
- package/dist/src/market-publish/packager.js +168 -0
- package/dist/src/market-publish/publishFlow.d.ts +70 -0
- package/dist/src/market-publish/publishFlow.js +107 -0
- package/dist/src/market-publish/uploader.d.ts +73 -0
- package/dist/src/market-publish/uploader.js +132 -0
- package/dist/src/openclawVersion.d.ts +4 -0
- package/dist/src/openclawVersion.js +13 -0
- package/dist/src/outbound.d.ts +13 -0
- package/dist/src/outbound.js +41 -0
- package/dist/src/pairing.d.ts +32 -0
- package/dist/src/pairing.js +64 -0
- package/dist/src/runtime.d.ts +52 -0
- package/dist/src/runtime.js +26 -0
- package/dist/src/telemetry.d.ts +34 -0
- package/dist/src/telemetry.js +89 -0
- package/dist/src/transport/realtime.d.ts +49 -0
- package/dist/src/transport/realtime.js +273 -0
- package/dist/src/transport.d.ts +38 -0
- package/dist/src/transport.js +15 -0
- package/dist/src/wake.d.ts +31 -0
- package/dist/src/wake.js +101 -0
- package/openclaw.config.example.yaml +10 -0
- package/openclaw.plugin.json +122 -0
- package/package.json +84 -0
package/dist/src/wake.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
const VALID_TASK_TYPES = new Set([
|
|
2
|
+
"agent_panel_turn",
|
|
3
|
+
"market_install",
|
|
4
|
+
"agency_install",
|
|
5
|
+
]);
|
|
6
|
+
export class PluginWakeSubscription {
|
|
7
|
+
options;
|
|
8
|
+
channel = null;
|
|
9
|
+
startResolve = null;
|
|
10
|
+
startPromise = null;
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this.options = options;
|
|
13
|
+
}
|
|
14
|
+
async start() {
|
|
15
|
+
if (this.startPromise) {
|
|
16
|
+
return this.startPromise;
|
|
17
|
+
}
|
|
18
|
+
const channel = this.options.client
|
|
19
|
+
.channel(`plugin-wake:${this.options.pluginNodeId}`)
|
|
20
|
+
.on("postgres_changes", {
|
|
21
|
+
event: "INSERT",
|
|
22
|
+
schema: "public",
|
|
23
|
+
table: "plugin_wake_events",
|
|
24
|
+
filter: `plugin_node_id=eq.${this.options.pluginNodeId}`,
|
|
25
|
+
}, (payload) => {
|
|
26
|
+
this.handleWakeRow(payload.new);
|
|
27
|
+
});
|
|
28
|
+
this.channel = channel;
|
|
29
|
+
this.startPromise = new Promise((resolve) => {
|
|
30
|
+
this.startResolve = resolve;
|
|
31
|
+
channel.subscribe((status) => {
|
|
32
|
+
if (channel !== this.channel) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (status === "SUBSCRIBED") {
|
|
36
|
+
this.startResolve = null;
|
|
37
|
+
this.options.logger?.info(`ClawHive wake subscribed plugin_node=${this.options.pluginNodeId}`);
|
|
38
|
+
resolve();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (isTerminalStatus(status)) {
|
|
42
|
+
this.startResolve = null;
|
|
43
|
+
this.options.logger?.warn(`ClawHive wake subscription status=${status} plugin_node=${this.options.pluginNodeId}`);
|
|
44
|
+
resolve();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
return this.startPromise;
|
|
49
|
+
}
|
|
50
|
+
async stop() {
|
|
51
|
+
const channel = this.channel;
|
|
52
|
+
this.channel = null;
|
|
53
|
+
const resolveStart = this.startResolve;
|
|
54
|
+
this.startResolve = null;
|
|
55
|
+
if (!channel) {
|
|
56
|
+
this.startPromise = null;
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
resolveStart?.();
|
|
60
|
+
await this.options.client.removeChannel(channel);
|
|
61
|
+
this.startPromise = null;
|
|
62
|
+
}
|
|
63
|
+
handleWakeRow(row) {
|
|
64
|
+
if (!isRecord(row)) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const taskType = row.task_type;
|
|
68
|
+
if (typeof taskType !== "string" || !VALID_TASK_TYPES.has(taskType)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const taskId = row.task_id;
|
|
72
|
+
const pluginNodeId = row.plugin_node_id;
|
|
73
|
+
const userId = row.user_id;
|
|
74
|
+
if (!isNonEmptyString(taskId) || !isNonEmptyString(pluginNodeId) || !isNonEmptyString(userId)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (pluginNodeId !== this.options.pluginNodeId || userId !== this.options.userId) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
this.options.onWake({
|
|
81
|
+
id: typeof row.id === "string" ? row.id : String(row.id ?? ""),
|
|
82
|
+
payload: isPlainObject(row.payload) ? row.payload : {},
|
|
83
|
+
pluginNodeId,
|
|
84
|
+
taskId,
|
|
85
|
+
taskType: taskType,
|
|
86
|
+
userId,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function isTerminalStatus(status) {
|
|
91
|
+
return status === "CHANNEL_ERROR" || status === "TIMED_OUT" || status === "CLOSED";
|
|
92
|
+
}
|
|
93
|
+
function isRecord(value) {
|
|
94
|
+
return typeof value === "object" && value !== null;
|
|
95
|
+
}
|
|
96
|
+
function isPlainObject(value) {
|
|
97
|
+
return isRecord(value) && !Array.isArray(value);
|
|
98
|
+
}
|
|
99
|
+
function isNonEmptyString(value) {
|
|
100
|
+
return typeof value === "string" && value.length > 0;
|
|
101
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "clawhive",
|
|
3
|
+
"name": "ClawHive",
|
|
4
|
+
"description": "ClawHive cloud pairing channel for OpenClaw",
|
|
5
|
+
"channels": ["clawhive"],
|
|
6
|
+
"channelEnvVars": {
|
|
7
|
+
"clawhive": [
|
|
8
|
+
"CLAWHIVE_SUPABASE_MODE",
|
|
9
|
+
"CLAWHIVE_PROJECT_URL",
|
|
10
|
+
"CLAWHIVE_PLUGIN_TOKEN",
|
|
11
|
+
"CLAWHIVE_USER_ID",
|
|
12
|
+
"CLAWHIVE_SUPABASE_ANON_KEY"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
"configSchema": {
|
|
16
|
+
"type": "object",
|
|
17
|
+
"additionalProperties": false,
|
|
18
|
+
"properties": {
|
|
19
|
+
"projectUrl": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"minLength": 1,
|
|
22
|
+
"title": "ClawHive Project URL",
|
|
23
|
+
"description": "Optional Supabase project base URL. In local mode, this should be the local project base URL without /rest/v1."
|
|
24
|
+
},
|
|
25
|
+
"anonKey": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"minLength": 1,
|
|
28
|
+
"title": "ClawHive Anon Key",
|
|
29
|
+
"description": "Optional Supabase anon key. In local mode, this falls back to CLAWHIVE_SUPABASE_ANON_KEY from the current shell."
|
|
30
|
+
},
|
|
31
|
+
"pluginToken": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"minLength": 1,
|
|
34
|
+
"title": "Plugin Token",
|
|
35
|
+
"description": "Optional bootstrap token. If omitted, the plugin bootstraps and persists one automatically on first gateway run."
|
|
36
|
+
},
|
|
37
|
+
"userId": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"minLength": 1,
|
|
40
|
+
"title": "Supabase User ID",
|
|
41
|
+
"description": "Owner user id used when registering the plugin node."
|
|
42
|
+
},
|
|
43
|
+
"pluginNodeId": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"title": "Plugin Node ID",
|
|
46
|
+
"description": "Optional previously assigned plugin node id."
|
|
47
|
+
},
|
|
48
|
+
"nodeName": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"title": "Node Name",
|
|
51
|
+
"description": "Display name used for this desktop plugin node."
|
|
52
|
+
},
|
|
53
|
+
"pluginVersion": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"title": "Plugin Version",
|
|
56
|
+
"description": "ClawHive plugin runtime version."
|
|
57
|
+
},
|
|
58
|
+
"publishSourceRef": {
|
|
59
|
+
"type": "string",
|
|
60
|
+
"title": "Publish Source Ref",
|
|
61
|
+
"description": "Optional stable source reference used when preparing a marketplace release."
|
|
62
|
+
},
|
|
63
|
+
"publishFingerprint": {
|
|
64
|
+
"type": "string",
|
|
65
|
+
"title": "Publish Fingerprint",
|
|
66
|
+
"description": "Optional immutable checksum or fingerprint for a marketplace release artifact."
|
|
67
|
+
},
|
|
68
|
+
"minPluginVersion": {
|
|
69
|
+
"type": "string",
|
|
70
|
+
"title": "Minimum Plugin Version",
|
|
71
|
+
"description": "Optional minimum compatible ClawHive plugin runtime version for a published release."
|
|
72
|
+
},
|
|
73
|
+
"minOpenClawVersion": {
|
|
74
|
+
"type": "string",
|
|
75
|
+
"title": "Minimum OpenClaw Version",
|
|
76
|
+
"description": "Optional minimum compatible OpenClaw host version for a published release."
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"uiHints": {
|
|
81
|
+
"projectUrl": {
|
|
82
|
+
"label": "Project URL",
|
|
83
|
+
"placeholder": "https://your-project.supabase.co"
|
|
84
|
+
},
|
|
85
|
+
"anonKey": {
|
|
86
|
+
"label": "Anon Key",
|
|
87
|
+
"placeholder": "eyJ..."
|
|
88
|
+
},
|
|
89
|
+
"pluginToken": {
|
|
90
|
+
"label": "Plugin Token",
|
|
91
|
+
"placeholder": "Auto-generated on first run",
|
|
92
|
+
"sensitive": true
|
|
93
|
+
},
|
|
94
|
+
"userId": {
|
|
95
|
+
"label": "User ID"
|
|
96
|
+
},
|
|
97
|
+
"pluginNodeId": {
|
|
98
|
+
"label": "Plugin Node ID"
|
|
99
|
+
},
|
|
100
|
+
"nodeName": {
|
|
101
|
+
"label": "Node Name",
|
|
102
|
+
"placeholder": "OpenClaw Desktop"
|
|
103
|
+
},
|
|
104
|
+
"pluginVersion": {
|
|
105
|
+
"label": "Plugin Version"
|
|
106
|
+
},
|
|
107
|
+
"publishSourceRef": {
|
|
108
|
+
"label": "Publish Source Ref",
|
|
109
|
+
"placeholder": "git:main#<commit>"
|
|
110
|
+
},
|
|
111
|
+
"publishFingerprint": {
|
|
112
|
+
"label": "Publish Fingerprint",
|
|
113
|
+
"placeholder": "sha256:..."
|
|
114
|
+
},
|
|
115
|
+
"minPluginVersion": {
|
|
116
|
+
"label": "Minimum Plugin Version"
|
|
117
|
+
},
|
|
118
|
+
"minOpenClawVersion": {
|
|
119
|
+
"label": "Minimum OpenClaw Version"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@clawhive/openclaw-plugin",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "ClawHive channel plugin for OpenClaw",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"homepage": "https://github.com/optimalAIs/clawhive#readme",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+ssh://git@github.com/optimalAIs/clawhive.git",
|
|
10
|
+
"directory": "openclaw-plugin"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/optimalAIs/clawhive/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"clawhive",
|
|
17
|
+
"openclaw",
|
|
18
|
+
"plugin",
|
|
19
|
+
"channel"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=22.14.0"
|
|
23
|
+
},
|
|
24
|
+
"type": "module",
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./setup-entry": {
|
|
33
|
+
"types": "./dist/setup-entry.d.ts",
|
|
34
|
+
"import": "./dist/setup-entry.js"
|
|
35
|
+
},
|
|
36
|
+
"./api": {
|
|
37
|
+
"types": "./dist/api.d.ts",
|
|
38
|
+
"import": "./dist/api.js"
|
|
39
|
+
},
|
|
40
|
+
"./runtime-api": {
|
|
41
|
+
"types": "./dist/runtime-api.d.ts",
|
|
42
|
+
"import": "./dist/runtime-api.js"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"dist",
|
|
47
|
+
"openclaw.plugin.json",
|
|
48
|
+
"README.md",
|
|
49
|
+
"openclaw.config.example.yaml"
|
|
50
|
+
],
|
|
51
|
+
"scripts": {
|
|
52
|
+
"check": "tsc --noEmit",
|
|
53
|
+
"build": "tsc -p tsconfig.json",
|
|
54
|
+
"prepack": "npm run build",
|
|
55
|
+
"prepublishOnly": "npm run check && npm run build && npm pack --dry-run"
|
|
56
|
+
},
|
|
57
|
+
"openclaw": {
|
|
58
|
+
"extensions": [
|
|
59
|
+
"./dist/index.js"
|
|
60
|
+
],
|
|
61
|
+
"channel": {
|
|
62
|
+
"id": "clawhive",
|
|
63
|
+
"name": "ClawHive"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"publishConfig": {
|
|
67
|
+
"access": "public"
|
|
68
|
+
},
|
|
69
|
+
"dependencies": {
|
|
70
|
+
"@sentry/node": "^9.16.0",
|
|
71
|
+
"@sinclair/typebox": "^0.34.41",
|
|
72
|
+
"@supabase/supabase-js": "^2.103.2",
|
|
73
|
+
"openclaw": "^2026.4.14",
|
|
74
|
+
"qrcode-terminal": "^0.12.0",
|
|
75
|
+
"tar": "^7.4.3",
|
|
76
|
+
"ws": "^8.20.0"
|
|
77
|
+
},
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"@types/node": "^24.6.0",
|
|
80
|
+
"@types/qrcode-terminal": "^0.12.2",
|
|
81
|
+
"tsx": "^4.21.0",
|
|
82
|
+
"typescript": "^5.9.3"
|
|
83
|
+
}
|
|
84
|
+
}
|