@zmeel/adapter-openclaw-gateway 0.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/LICENSE +21 -0
- package/README.md +72 -0
- package/dist/cli/format-event.d.ts +2 -0
- package/dist/cli/format-event.d.ts.map +1 -0
- package/dist/cli/format-event.js +20 -0
- package/dist/cli/format-event.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/server/execute.d.ts +3 -0
- package/dist/server/execute.d.ts.map +1 -0
- package/dist/server/execute.js +1146 -0
- package/dist/server/execute.js.map +1 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +3 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/test.d.ts +3 -0
- package/dist/server/test.d.ts.map +1 -0
- package/dist/server/test.js +290 -0
- package/dist/server/test.js.map +1 -0
- package/dist/shared/stream.d.ts +5 -0
- package/dist/shared/stream.d.ts.map +1 -0
- package/dist/shared/stream.js +13 -0
- package/dist/shared/stream.js.map +1 -0
- package/dist/ui/build-config.d.ts +3 -0
- package/dist/ui/build-config.d.ts.map +1 -0
- package/dist/ui/build-config.js +33 -0
- package/dist/ui/build-config.js.map +1 -0
- package/dist/ui/index.d.ts +3 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +3 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/parse-stdout.d.ts +3 -0
- package/dist/ui/parse-stdout.d.ts.map +1 -0
- package/dist/ui/parse-stdout.js +64 -0
- package/dist/ui/parse-stdout.js.map +1 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Paperclip AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# OpenClaw Gateway Adapter
|
|
2
|
+
|
|
3
|
+
This document describes how `@zmeel/adapter-openclaw-gateway` invokes OpenClaw over the Gateway protocol.
|
|
4
|
+
|
|
5
|
+
## Transport
|
|
6
|
+
|
|
7
|
+
This adapter always uses WebSocket gateway transport.
|
|
8
|
+
|
|
9
|
+
- URL must be `ws://` or `wss://`
|
|
10
|
+
- Connect flow follows gateway protocol:
|
|
11
|
+
1. receive `connect.challenge`
|
|
12
|
+
2. send `req connect` (protocol/client/auth/device payload)
|
|
13
|
+
3. send `req agent`
|
|
14
|
+
4. wait for completion via `req agent.wait`
|
|
15
|
+
5. stream `event agent` frames into zmeel logs/transcript parsing
|
|
16
|
+
|
|
17
|
+
## Auth Modes
|
|
18
|
+
|
|
19
|
+
Gateway credentials can be provided in any of these ways:
|
|
20
|
+
|
|
21
|
+
- `authToken` / `token` in adapter config
|
|
22
|
+
- `headers.x-openclaw-token`
|
|
23
|
+
- `headers.x-openclaw-auth` (legacy)
|
|
24
|
+
- `password` (shared password mode)
|
|
25
|
+
|
|
26
|
+
When a token is present and `authorization` header is missing, the adapter derives `Authorization: Bearer <token>`.
|
|
27
|
+
|
|
28
|
+
## Device Auth
|
|
29
|
+
|
|
30
|
+
By default the adapter sends a signed `device` payload in `connect` params.
|
|
31
|
+
|
|
32
|
+
- set `disableDeviceAuth=true` to omit device signing
|
|
33
|
+
- set `devicePrivateKeyPem` to pin a stable signing key
|
|
34
|
+
- without `devicePrivateKeyPem`, the adapter generates an ephemeral Ed25519 keypair per run
|
|
35
|
+
- when `autoPairOnFirstConnect` is enabled (default), the adapter handles one initial `pairing required` by calling `device.pair.list` + `device.pair.approve` over shared auth, then retries once.
|
|
36
|
+
|
|
37
|
+
## Session Strategy
|
|
38
|
+
|
|
39
|
+
The adapter supports the same session routing model as HTTP OpenClaw mode:
|
|
40
|
+
|
|
41
|
+
- `sessionKeyStrategy=issue|fixed|run`
|
|
42
|
+
- `sessionKey` is used when strategy is `fixed`
|
|
43
|
+
|
|
44
|
+
Resolved session key is sent as `agent.sessionKey`.
|
|
45
|
+
|
|
46
|
+
## Payload Mapping
|
|
47
|
+
|
|
48
|
+
The agent request is built as:
|
|
49
|
+
|
|
50
|
+
- required fields:
|
|
51
|
+
- `message` (wake text plus optional `payloadTemplate.message`/`payloadTemplate.text` prefix)
|
|
52
|
+
- `idempotencyKey` (zmeel `runId`)
|
|
53
|
+
- `sessionKey` (resolved strategy)
|
|
54
|
+
- optional additions:
|
|
55
|
+
- all `payloadTemplate` fields merged in
|
|
56
|
+
- `agentId` from config if set and not already in template
|
|
57
|
+
|
|
58
|
+
## Timeouts
|
|
59
|
+
|
|
60
|
+
- `timeoutSec` controls adapter-level request budget
|
|
61
|
+
- `waitTimeoutMs` controls `agent.wait.timeoutMs`
|
|
62
|
+
|
|
63
|
+
If `agent.wait` returns `timeout`, adapter returns `openclaw_gateway_wait_timeout`.
|
|
64
|
+
|
|
65
|
+
## Log Format
|
|
66
|
+
|
|
67
|
+
Structured gateway event logs use:
|
|
68
|
+
|
|
69
|
+
- `[openclaw-gateway] ...` for lifecycle/system logs
|
|
70
|
+
- `[openclaw-gateway:event] run=<id> stream=<stream> data=<json>` for `event agent` frames
|
|
71
|
+
|
|
72
|
+
UI/CLI parsers consume these lines to render transcript updates.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-event.d.ts","sourceRoot":"","sources":["../../src/cli/format-event.ts"],"names":[],"mappings":"AAEA,wBAAgB,+BAA+B,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAoBjF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import pc from "picocolors";
|
|
2
|
+
export function printOpenClawGatewayStreamEvent(raw, debug) {
|
|
3
|
+
const line = raw.trim();
|
|
4
|
+
if (!line)
|
|
5
|
+
return;
|
|
6
|
+
if (!debug) {
|
|
7
|
+
console.log(line);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (line.startsWith("[openclaw-gateway:event]")) {
|
|
11
|
+
console.log(pc.cyan(line));
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (line.startsWith("[openclaw-gateway]")) {
|
|
15
|
+
console.log(pc.blue(line));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
console.log(pc.gray(line));
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=format-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-event.js","sourceRoot":"","sources":["../../src/cli/format-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,MAAM,UAAU,+BAA+B,CAAC,GAAW,EAAE,KAAc;IACzE,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IACxB,IAAI,CAAC,IAAI;QAAE,OAAO;IAElB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClB,OAAO;IACT,CAAC;IAED,IAAI,IAAI,CAAC,UAAU,CAAC,0BAA0B,CAAC,EAAE,CAAC;QAChD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3B,OAAO;IACT,CAAC;IAED,IAAI,IAAI,CAAC,UAAU,CAAC,oBAAoB,CAAC,EAAE,CAAC;QAC1C,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3B,OAAO;IACT,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const type = "openclaw_gateway";
|
|
2
|
+
export declare const label = "OpenClaw Gateway";
|
|
3
|
+
export declare const models: {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
}[];
|
|
7
|
+
export declare const agentConfigurationDoc = "# openclaw_gateway agent configuration\n\nAdapter: openclaw_gateway\n\nUse when:\n- You want zmeel to invoke OpenClaw over the Gateway WebSocket protocol.\n- You want native gateway auth/connect semantics instead of HTTP /v1/responses or /hooks/*.\n\nDon't use when:\n- You only expose OpenClaw HTTP endpoints.\n- Your deployment does not permit outbound WebSocket access from the zmeel server.\n\nCore fields:\n- url (string, required): OpenClaw gateway WebSocket URL (ws:// or wss://)\n- headers (object, optional): handshake headers; supports x-openclaw-token / x-openclaw-auth\n- authToken (string, optional): shared gateway token override\n- password (string, optional): gateway shared password, if configured\n\nGateway connect identity fields:\n- clientId (string, optional): gateway client id (default gateway-client)\n- clientMode (string, optional): gateway client mode (default backend)\n- clientVersion (string, optional): client version string\n- role (string, optional): gateway role (default operator)\n- scopes (string[] | comma string, optional): gateway scopes (default [\"operator.admin\"])\n- disableDeviceAuth (boolean, optional): disable signed device payload in connect params (default false)\n\nRequest behavior fields:\n- payloadTemplate (object, optional): additional fields merged into gateway agent params\n- workspaceRuntime (object, optional): reserved workspace runtime metadata; workspace runtime services are manually controlled from the workspace UI and are not auto-started by heartbeats\n- timeoutSec (number, optional): adapter timeout in seconds (default 120)\n- waitTimeoutMs (number, optional): agent.wait timeout override (default timeoutSec * 1000)\n- autoPairOnFirstConnect (boolean, optional): on first \"pairing required\", attempt device.pair.list/device.pair.approve via shared auth, then retry once (default true)\n- zmeelApiUrl (string, optional): absolute zmeel base URL advertised in wake text\n\nSession routing fields:\n- sessionKeyStrategy (string, optional): issue (default), fixed, or run\n- sessionKey (string, optional): fixed session key when strategy=fixed (default zmeel)\n\nStandard outbound payload additions:\n- zmeel (object): standardized zmeel context added to every gateway agent request\n- zmeel.workspace (object, optional): resolved execution workspace for this run\n- zmeel.workspaces (array, optional): additional workspace hints zmeel exposed to the run\n- zmeel.workspaceRuntime (object, optional): reserved workspace runtime metadata when explicitly supplied outside normal heartbeat execution\n\nStandard result metadata supported:\n- meta.runtimeServices (array, optional): normalized adapter-managed runtime service reports\n- meta.previewUrl (string, optional): shorthand single preview URL\n- meta.previewUrls (string[], optional): shorthand multiple preview URLs\n";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,qBAAqB,CAAC;AACvC,eAAO,MAAM,KAAK,qBAAqB,CAAC;AAExC,eAAO,MAAM,MAAM,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAO,CAAC;AAE1D,eAAO,MAAM,qBAAqB,myFAgDjC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export const type = "openclaw_gateway";
|
|
2
|
+
export const label = "OpenClaw Gateway";
|
|
3
|
+
export const models = [];
|
|
4
|
+
export const agentConfigurationDoc = `# openclaw_gateway agent configuration
|
|
5
|
+
|
|
6
|
+
Adapter: openclaw_gateway
|
|
7
|
+
|
|
8
|
+
Use when:
|
|
9
|
+
- You want zmeel to invoke OpenClaw over the Gateway WebSocket protocol.
|
|
10
|
+
- You want native gateway auth/connect semantics instead of HTTP /v1/responses or /hooks/*.
|
|
11
|
+
|
|
12
|
+
Don't use when:
|
|
13
|
+
- You only expose OpenClaw HTTP endpoints.
|
|
14
|
+
- Your deployment does not permit outbound WebSocket access from the zmeel server.
|
|
15
|
+
|
|
16
|
+
Core fields:
|
|
17
|
+
- url (string, required): OpenClaw gateway WebSocket URL (ws:// or wss://)
|
|
18
|
+
- headers (object, optional): handshake headers; supports x-openclaw-token / x-openclaw-auth
|
|
19
|
+
- authToken (string, optional): shared gateway token override
|
|
20
|
+
- password (string, optional): gateway shared password, if configured
|
|
21
|
+
|
|
22
|
+
Gateway connect identity fields:
|
|
23
|
+
- clientId (string, optional): gateway client id (default gateway-client)
|
|
24
|
+
- clientMode (string, optional): gateway client mode (default backend)
|
|
25
|
+
- clientVersion (string, optional): client version string
|
|
26
|
+
- role (string, optional): gateway role (default operator)
|
|
27
|
+
- scopes (string[] | comma string, optional): gateway scopes (default ["operator.admin"])
|
|
28
|
+
- disableDeviceAuth (boolean, optional): disable signed device payload in connect params (default false)
|
|
29
|
+
|
|
30
|
+
Request behavior fields:
|
|
31
|
+
- payloadTemplate (object, optional): additional fields merged into gateway agent params
|
|
32
|
+
- workspaceRuntime (object, optional): reserved workspace runtime metadata; workspace runtime services are manually controlled from the workspace UI and are not auto-started by heartbeats
|
|
33
|
+
- timeoutSec (number, optional): adapter timeout in seconds (default 120)
|
|
34
|
+
- waitTimeoutMs (number, optional): agent.wait timeout override (default timeoutSec * 1000)
|
|
35
|
+
- autoPairOnFirstConnect (boolean, optional): on first "pairing required", attempt device.pair.list/device.pair.approve via shared auth, then retry once (default true)
|
|
36
|
+
- zmeelApiUrl (string, optional): absolute zmeel base URL advertised in wake text
|
|
37
|
+
|
|
38
|
+
Session routing fields:
|
|
39
|
+
- sessionKeyStrategy (string, optional): issue (default), fixed, or run
|
|
40
|
+
- sessionKey (string, optional): fixed session key when strategy=fixed (default zmeel)
|
|
41
|
+
|
|
42
|
+
Standard outbound payload additions:
|
|
43
|
+
- zmeel (object): standardized zmeel context added to every gateway agent request
|
|
44
|
+
- zmeel.workspace (object, optional): resolved execution workspace for this run
|
|
45
|
+
- zmeel.workspaces (array, optional): additional workspace hints zmeel exposed to the run
|
|
46
|
+
- zmeel.workspaceRuntime (object, optional): reserved workspace runtime metadata when explicitly supplied outside normal heartbeat execution
|
|
47
|
+
|
|
48
|
+
Standard result metadata supported:
|
|
49
|
+
- meta.runtimeServices (array, optional): normalized adapter-managed runtime service reports
|
|
50
|
+
- meta.previewUrl (string, optional): shorthand single preview URL
|
|
51
|
+
- meta.previewUrls (string[], optional): shorthand multiple preview URLs
|
|
52
|
+
`;
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,IAAI,GAAG,kBAAkB,CAAC;AACvC,MAAM,CAAC,MAAM,KAAK,GAAG,kBAAkB,CAAC;AAExC,MAAM,CAAC,MAAM,MAAM,GAAoC,EAAE,CAAC;AAE1D,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/server/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,sBAAsB,EAEvB,MAAM,sBAAsB,CAAC;AA+9B9B,wBAAsB,OAAO,CAAC,GAAG,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAsb3F"}
|