@rudderhq/agent-runtime-openclaw-gateway 0.1.0-canary.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.
Files changed (43) hide show
  1. package/LICENSE +14 -0
  2. package/README.md +72 -0
  3. package/dist/cli/format-event.d.ts +2 -0
  4. package/dist/cli/format-event.d.ts.map +1 -0
  5. package/dist/cli/format-event.js +20 -0
  6. package/dist/cli/format-event.js.map +1 -0
  7. package/dist/cli/index.d.ts +2 -0
  8. package/dist/cli/index.d.ts.map +1 -0
  9. package/dist/cli/index.js +2 -0
  10. package/dist/cli/index.js.map +1 -0
  11. package/dist/index.d.ts +8 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +53 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/server/execute.d.ts +3 -0
  16. package/dist/server/execute.d.ts.map +1 -0
  17. package/dist/server/execute.js +1150 -0
  18. package/dist/server/execute.js.map +1 -0
  19. package/dist/server/index.d.ts +3 -0
  20. package/dist/server/index.d.ts.map +1 -0
  21. package/dist/server/index.js +3 -0
  22. package/dist/server/index.js.map +1 -0
  23. package/dist/server/test.d.ts +3 -0
  24. package/dist/server/test.d.ts.map +1 -0
  25. package/dist/server/test.js +290 -0
  26. package/dist/server/test.js.map +1 -0
  27. package/dist/shared/stream.d.ts +5 -0
  28. package/dist/shared/stream.d.ts.map +1 -0
  29. package/dist/shared/stream.js +13 -0
  30. package/dist/shared/stream.js.map +1 -0
  31. package/dist/ui/build-config.d.ts +3 -0
  32. package/dist/ui/build-config.d.ts.map +1 -0
  33. package/dist/ui/build-config.js +33 -0
  34. package/dist/ui/build-config.js.map +1 -0
  35. package/dist/ui/index.d.ts +3 -0
  36. package/dist/ui/index.d.ts.map +1 -0
  37. package/dist/ui/index.js +3 -0
  38. package/dist/ui/index.js.map +1 -0
  39. package/dist/ui/parse-stdout.d.ts +3 -0
  40. package/dist/ui/parse-stdout.d.ts.map +1 -0
  41. package/dist/ui/parse-stdout.js +64 -0
  42. package/dist/ui/parse-stdout.js.map +1 -0
  43. package/package.json +62 -0
package/LICENSE ADDED
@@ -0,0 +1,14 @@
1
+ This package is part of the Rudder project.
2
+
3
+ Rudder began as a fork of an early version of Paperclip.
4
+
5
+ Licensing for this package follows the repository-level transition:
6
+ - new Rudder contributions are made under the Apache License, Version 2.0
7
+ - upstream-derived Paperclip portions preserve the original MIT notice where applicable
8
+
9
+ Canonical project-level license and attribution texts live in the source repository:
10
+ - `LICENSE`
11
+ - `NOTICE`
12
+ - `LICENSES/MIT-PAPERCLIP`
13
+
14
+ Source repository: https://github.com/Undertone0809/rudder
package/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # OpenClaw Gateway Adapter
2
+
3
+ This document describes how `@rudderhq/agent-runtime-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 Rudder 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` (Rudder `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,2 @@
1
+ export declare function printOpenClawGatewayStreamEvent(raw: string, debug: boolean): void;
2
+ //# sourceMappingURL=format-event.d.ts.map
@@ -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,2 @@
1
+ export { printOpenClawGatewayStreamEvent } from "./format-event.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -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,2 @@
1
+ export { printOpenClawGatewayStreamEvent } from "./format-event.js";
2
+ //# sourceMappingURL=index.js.map
@@ -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"}
@@ -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 Rudder 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 Rudder 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): desired runtime service intents; Rudder forwards these in a standardized rudder.workspaceRuntime block for remote execution environments\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- rudderApiUrl (string, optional): absolute Rudder 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 rudder)\n\nStandard outbound payload additions:\n- rudder (object): standardized Rudder context added to every gateway agent request\n- rudder.workspace (object, optional): resolved execution workspace for this run\n- rudder.workspaces (array, optional): additional workspace hints Rudder exposed to the run\n- rudder.workspaceRuntime (object, optional): normalized runtime service intent config for the workspace\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,6vFAgDjC,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 Rudder 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 Rudder 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): desired runtime service intents; Rudder forwards these in a standardized rudder.workspaceRuntime block for remote execution environments
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
+ - rudderApiUrl (string, optional): absolute Rudder 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 rudder)
41
+
42
+ Standard outbound payload additions:
43
+ - rudder (object): standardized Rudder context added to every gateway agent request
44
+ - rudder.workspace (object, optional): resolved execution workspace for this run
45
+ - rudder.workspaces (array, optional): additional workspace hints Rudder exposed to the run
46
+ - rudder.workspaceRuntime (object, optional): normalized runtime service intent config for the workspace
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,3 @@
1
+ import type { AgentRuntimeExecutionContext, AgentRuntimeExecutionResult } from "@rudderhq/agent-runtime-utils";
2
+ export declare function execute(ctx: AgentRuntimeExecutionContext): Promise<AgentRuntimeExecutionResult>;
3
+ //# sourceMappingURL=execute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/server/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,2BAA2B,EAE5B,MAAM,+BAA+B,CAAC;AAm+BvC,wBAAsB,OAAO,CAAC,GAAG,EAAE,4BAA4B,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAsbrG"}