@egoai/platform 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 +111 -0
- package/openclaw.plugin.json +39 -0
- package/package.json +56 -0
- package/src/brain.ts +584 -0
- package/src/channel.ts +54 -0
- package/src/chat.ts +373 -0
- package/src/config.ts +79 -0
- package/src/index.ts +117 -0
- package/src/monitor.ts +591 -0
- package/src/types.ts +118 -0
- package/src/workspace.ts +324 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ego AI and contributors
|
|
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,111 @@
|
|
|
1
|
+
# @egoai/platform
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@egoai/platform)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
An OpenClaw channel plugin that connects an OpenClaw agent to SideClaw for real-time AI voice conversations.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
### From npm
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
openclaw plugins install @egoai/platform
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### From source
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
git clone https://github.com/egotv/sideclaw-plugin.git
|
|
20
|
+
cd character-platform-plugin
|
|
21
|
+
npm install
|
|
22
|
+
openclaw plugins install .
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Configuration
|
|
26
|
+
|
|
27
|
+
Add the following to your `openclaw.json` under `channels.sideclaw`:
|
|
28
|
+
|
|
29
|
+
```jsonc
|
|
30
|
+
{
|
|
31
|
+
"channels": {
|
|
32
|
+
"sideclaw": {
|
|
33
|
+
"enabled": true,
|
|
34
|
+
"platformUrl": "ws://sideclaw-host:19999",
|
|
35
|
+
"platformKey": "sk_pair_YOUR_TOKEN_HERE"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Or use the CLI:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
openclaw config set channels.sideclaw.enabled true
|
|
45
|
+
openclaw config set channels.sideclaw.platformUrl "ws://sideclaw-host:19999"
|
|
46
|
+
openclaw config set channels.sideclaw.platformKey "sk_pair_YOUR_TOKEN_HERE"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Config fields
|
|
50
|
+
|
|
51
|
+
| Field | Type | Required | Description |
|
|
52
|
+
|-------|------|----------|-------------|
|
|
53
|
+
| `enabled` | boolean | Yes | Enable or disable the channel |
|
|
54
|
+
| `platformUrl` | string | Yes | WebSocket URL of the SideClaw server (ws:// or wss://) |
|
|
55
|
+
| `platformKey` | string | Yes | Pairing token generated from the SideClaw onboarding UI |
|
|
56
|
+
|
|
57
|
+
### Environment variables
|
|
58
|
+
|
|
59
|
+
| Variable | Description |
|
|
60
|
+
|----------|-------------|
|
|
61
|
+
| `OPENCLAW_GATEWAY_TOKEN` | Gateway authentication token. Takes priority over any value stored in config. |
|
|
62
|
+
|
|
63
|
+
## Commands
|
|
64
|
+
|
|
65
|
+
| Command | Description |
|
|
66
|
+
|---------|-------------|
|
|
67
|
+
| `/sideclaw-pair` | Show step-by-step pairing instructions (register on SideClaw, add OpenClaw, get pairing token) |
|
|
68
|
+
| `/sideclaw-status` | Show current connection state and configured values (`platformUrl`, `platformKey` presence, `enabled`) |
|
|
69
|
+
| `/sideclaw-reconnect` | Skip the pending retry delay and reconnect immediately (no-op if already connected) |
|
|
70
|
+
|
|
71
|
+
## How It Works
|
|
72
|
+
|
|
73
|
+
OpenClaw gateways typically run on a user's local machine behind NAT, so SideClaw cannot reach the gateway directly. This plugin uses a reverse connection pattern: it dials out from the gateway to SideClaw rather than waiting to be dialed. On startup, the plugin connects to the local gateway WebSocket first and buffers the `connect.challenge` message before opening a second connection to SideClaw. The buffered challenge is forwarded to SideClaw immediately after the connection opens, which prevents the gateway from timing out while waiting for a handshake response. Once both sides complete the handshake, the plugin becomes a bidirectional frame relay for the lifetime of the session. If either side disconnects, the gateway's ChannelManager restarts `startAccount()` with backoff.
|
|
74
|
+
|
|
75
|
+
### Workspace file reading
|
|
76
|
+
|
|
77
|
+
The relay intercepts `workspace.read` RPC requests from the SideClaw server. Instead of forwarding these to the gateway (which can't serve files back over NAT), the relay reads files directly from the local filesystem using the workspace path from the gateway config (`agents.defaults.workspace`). A fast string pre-check avoids JSON parsing overhead on non-matching frames.
|
|
78
|
+
|
|
79
|
+
## Security
|
|
80
|
+
|
|
81
|
+
- **URL validation**: Only `ws://` and `wss://` URLs are accepted for `platformUrl`. Any other scheme is rejected to prevent SSRF.
|
|
82
|
+
- **Plaintext token warning**: If `platformKey` is transmitted over an unencrypted `ws://` connection, the plugin logs a security warning. Use `wss://` in production.
|
|
83
|
+
- **Secret priority**: `OPENCLAW_GATEWAY_TOKEN` in the environment always takes precedence over the value in `openclaw.json`. Prefer environment variables for secrets rather than storing them in config files.
|
|
84
|
+
|
|
85
|
+
## Development
|
|
86
|
+
|
|
87
|
+
After cloning and installing (see "From source" above):
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npm run type-check # TypeScript check
|
|
91
|
+
npm test # Run tests (vitest)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The package ships raw TypeScript with no runtime dependencies. TypeScript and vitest are the only dev-time requirements.
|
|
95
|
+
|
|
96
|
+
### File structure
|
|
97
|
+
|
|
98
|
+
| File | Purpose |
|
|
99
|
+
|------|---------|
|
|
100
|
+
| `src/index.ts` | Plugin entry — `register(api)` |
|
|
101
|
+
| `src/channel.ts` | ChannelPlugin shape — id, meta, capabilities, config |
|
|
102
|
+
| `src/monitor.ts` | `startAccount()` — buffered handshake + relay with `workspace.read` interception |
|
|
103
|
+
| `src/config.ts` | `SideClawAccount` type, `resolveGatewayToken/Url` |
|
|
104
|
+
| `src/types.ts` | RPC frame types (`RpcRequest`, `RpcResponse`, `WorkspaceReadParams`, `FileEntry`) |
|
|
105
|
+
| `src/workspace.ts` | Local workspace file reading — `handleWorkspaceRead()`, `resolveWorkspace()`, `collectFiles()` |
|
|
106
|
+
| `tests/workspace.test.ts` | Workspace module tests (file reading, path traversal, resolution) |
|
|
107
|
+
| `tests/intercept.test.ts` | RPC interception flow tests |
|
|
108
|
+
|
|
109
|
+
## License
|
|
110
|
+
|
|
111
|
+
MIT
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "platform",
|
|
3
|
+
"kind": "channel",
|
|
4
|
+
"channels": ["platform"],
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"description": "Connect OpenClaw to platform for real-time AI voice conversations with embodied agents.",
|
|
7
|
+
"name": "platform",
|
|
8
|
+
"configSchema": {
|
|
9
|
+
"type": "object",
|
|
10
|
+
"additionalProperties": false,
|
|
11
|
+
"properties": {
|
|
12
|
+
"platform": {
|
|
13
|
+
"type": "object",
|
|
14
|
+
"properties": {
|
|
15
|
+
"enabled": { "type": "boolean", "default": false },
|
|
16
|
+
"platformUrl": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "WebSocket URL of the platform server, e.g. ws://platform-host:19999"
|
|
19
|
+
},
|
|
20
|
+
"platformKey": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "Pairing token from platform onboarding UI"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"uiHints": {
|
|
29
|
+
"platformUrl": {
|
|
30
|
+
"label": "platform URL",
|
|
31
|
+
"placeholder": "ws://platform-host:19999"
|
|
32
|
+
},
|
|
33
|
+
"platformKey": {
|
|
34
|
+
"label": "Platform Key",
|
|
35
|
+
"placeholder": "Key from platform onboarding",
|
|
36
|
+
"sensitive": true
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@egoai/platform",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "OpenClaw channel plugin character platform",
|
|
6
|
+
"main": "./src/index.ts",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "Ego AI <dev@ego.live>",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/egotv/character-platform-plugin.git"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/egotv/character-platform-plugin",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/egotv/character-platform-plugin/issues"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"openclaw",
|
|
19
|
+
"openclaw-plugin",
|
|
20
|
+
"character-platform",
|
|
21
|
+
"voice",
|
|
22
|
+
"webrtc",
|
|
23
|
+
"channel"
|
|
24
|
+
],
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">= 20"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"src/",
|
|
30
|
+
"openclaw.plugin.json"
|
|
31
|
+
],
|
|
32
|
+
"openclaw": {
|
|
33
|
+
"extensions": [
|
|
34
|
+
"./src/index.ts"
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"openclaw": ">= 2026.3"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public",
|
|
42
|
+
"registry": "https://registry.npmjs.org/"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"type-check": "tsc --noEmit",
|
|
46
|
+
"test": "vitest run"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/ws": "^8.18.1",
|
|
50
|
+
"openclaw": "^2026.3.24",
|
|
51
|
+
"typescript": "^5.7.0",
|
|
52
|
+
"undici": "^8.0.2",
|
|
53
|
+
"vitest": "^4.1.1",
|
|
54
|
+
"ws": "^8.20.0"
|
|
55
|
+
}
|
|
56
|
+
}
|