@bajoseek/openclaw-bajoseek 0.1.0 → 0.1.1
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 +170 -0
- package/index.ts +25 -15
- package/package.json +19 -8
- package/setup-entry.ts +13 -0
- package/src/channel.ts +183 -43
- package/src/config.ts +49 -9
- package/src/gateway.ts +116 -32
- package/src/onboarding.ts +261 -179
- package/src/outbound.ts +52 -8
- package/src/runtime.ts +21 -4
- package/src/sdk-compat.ts +147 -0
- package/src/setup-core.ts +74 -0
- package/src/setup-surface.ts +323 -0
- package/src/types.ts +39 -14
- package/src/openclaw-plugin-sdk.d.ts +0 -494
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 bajoseek
|
|
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,170 @@
|
|
|
1
|
+
# Bajoseek OpenClaw Plugin
|
|
2
|
+
|
|
3
|
+
[中文文档](./README_zh.md)
|
|
4
|
+
|
|
5
|
+
A channel plugin for [OpenClaw](https://github.com/openclaw/openclaw) that connects AI assistants to the Bajoseek App via WebSocket.
|
|
6
|
+
|
|
7
|
+
## Compatibility
|
|
8
|
+
|
|
9
|
+
| OpenClaw Version | Support |
|
|
10
|
+
|---|---|
|
|
11
|
+
| 3.24+ (new Plugin SDK) | Fully supported — uses `ChannelSetupWizard` |
|
|
12
|
+
| 3.13 (legacy Plugin SDK) | Fully supported — uses `ChannelOnboardingAdapter` |
|
|
13
|
+
|
|
14
|
+
The plugin detects the OpenClaw version at runtime and automatically loads the appropriate setup adapter.
|
|
15
|
+
|
|
16
|
+
## Features
|
|
17
|
+
|
|
18
|
+
- **Real-time WebSocket Communication** — Bidirectional messaging between OpenClaw AI agents and Bajoseek users
|
|
19
|
+
- **Block Streaming** — Progressive chunked response delivery for better responsiveness on long replies
|
|
20
|
+
- **Auto-Reconnect** — Exponential backoff reconnection (1s → 2s → 5s → 10s → 30s → 60s)
|
|
21
|
+
- **Per-User Message Queue** — Isolated queues per user (max 20 messages/user, 10 concurrent users)
|
|
22
|
+
- **Heartbeat** — Periodic ping every 30 seconds to keep connections alive
|
|
23
|
+
- **Multi-Account** — Run multiple Bajoseek bot accounts from a single OpenClaw instance
|
|
24
|
+
- **3-Level Token Fallback** — Config file → token file → environment variable
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
### Install
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install @bajoseek/openclaw-bajoseek
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Configure
|
|
35
|
+
|
|
36
|
+
Set environment variables:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
export BAJOSEEK_BOT_ID="your-bot-id"
|
|
40
|
+
export BAJOSEEK_TOKEN="your-token"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Or add to your OpenClaw config file:
|
|
44
|
+
|
|
45
|
+
```yaml
|
|
46
|
+
channels:
|
|
47
|
+
bajoseek:
|
|
48
|
+
enabled: true
|
|
49
|
+
botId: "your-bot-id"
|
|
50
|
+
token: "your-token"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Interactive Setup
|
|
54
|
+
|
|
55
|
+
Run the OpenClaw onboard wizard — it will guide you through BotID, Token, WebSocket URL, and block streaming options.
|
|
56
|
+
|
|
57
|
+
## Configuration
|
|
58
|
+
|
|
59
|
+
### Environment Variables
|
|
60
|
+
|
|
61
|
+
| Variable | Description |
|
|
62
|
+
|---|---|
|
|
63
|
+
| `BAJOSEEK_BOT_ID` | Bot ID (default account only) |
|
|
64
|
+
| `BAJOSEEK_TOKEN` | Auth token (default account only) |
|
|
65
|
+
|
|
66
|
+
### Config Fields
|
|
67
|
+
|
|
68
|
+
| Field | Type | Default | Description |
|
|
69
|
+
|---|---|---|---|
|
|
70
|
+
| `enabled` | boolean | `true` | Enable/disable channel |
|
|
71
|
+
| `botId` | string | — | Bajoseek bot ID |
|
|
72
|
+
| `token` | string | — | Auth token |
|
|
73
|
+
| `tokenFile` | string | — | Path to file containing token |
|
|
74
|
+
| `wsUrl` | string | `wss://ws.bajoseek.com` | WebSocket server URL |
|
|
75
|
+
| `allowFrom` | string[] | `["*"]` | Message source allowlist |
|
|
76
|
+
| `blockStreaming` | boolean | `true` | Enable chunked streaming |
|
|
77
|
+
| `name` | string | — | Account display name |
|
|
78
|
+
|
|
79
|
+
### Multi-Account
|
|
80
|
+
|
|
81
|
+
```yaml
|
|
82
|
+
channels:
|
|
83
|
+
bajoseek:
|
|
84
|
+
enabled: true
|
|
85
|
+
botId: "default-bot-id"
|
|
86
|
+
token: "default-token"
|
|
87
|
+
accounts:
|
|
88
|
+
staging:
|
|
89
|
+
botId: "staging-bot-id"
|
|
90
|
+
token: "staging-token"
|
|
91
|
+
wsUrl: "wss://staging.bajoseek.com"
|
|
92
|
+
production:
|
|
93
|
+
botId: "prod-bot-id"
|
|
94
|
+
tokenFile: "/secrets/bajoseek-token"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## WebSocket Protocol
|
|
98
|
+
|
|
99
|
+
### Inbound (Server → Plugin)
|
|
100
|
+
|
|
101
|
+
| Type | Fields | Description |
|
|
102
|
+
|---|---|---|
|
|
103
|
+
| `message` | `messageId`, `userId`, `conversationId`, `text`, `timestamp` | User message |
|
|
104
|
+
| `pong` | — | Heartbeat response |
|
|
105
|
+
| `error` | `code`, `message` | Server error |
|
|
106
|
+
|
|
107
|
+
### Outbound (Plugin → Server)
|
|
108
|
+
|
|
109
|
+
| Type | Fields | Description |
|
|
110
|
+
|---|---|---|
|
|
111
|
+
| `stream_chunk` | `conversationId`, `text` | Partial response (non-final) |
|
|
112
|
+
| `stream_end` | `conversationId`, `text` | Final response block |
|
|
113
|
+
| `reply` | `to`, `text`, `replyToId?` | Direct reply message |
|
|
114
|
+
| `ping` | — | Heartbeat |
|
|
115
|
+
|
|
116
|
+
### Authentication
|
|
117
|
+
|
|
118
|
+
WebSocket upgrade headers:
|
|
119
|
+
- `X-Bot-Id: <botId>`
|
|
120
|
+
- `Authorization: Bearer <token>`
|
|
121
|
+
|
|
122
|
+
### Target Address Format
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
bajoseek:user:<userId>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Accepted inputs: `bajoseek:user:alice`, `user:alice`, or `alice`.
|
|
129
|
+
|
|
130
|
+
## Channel Capabilities
|
|
131
|
+
|
|
132
|
+
| Capability | Support |
|
|
133
|
+
|---|---|
|
|
134
|
+
| Direct Messages | Yes |
|
|
135
|
+
| Group Chat | No |
|
|
136
|
+
| Media | No |
|
|
137
|
+
| Reactions | No |
|
|
138
|
+
| Threads | No |
|
|
139
|
+
| Block Streaming | Yes |
|
|
140
|
+
|
|
141
|
+
## Development
|
|
142
|
+
|
|
143
|
+
### Build
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
npm run build # Compile TypeScript
|
|
147
|
+
npm run dev # Watch mode
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Project Structure
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
index.ts # Plugin entry point (register pattern, compatible with both versions)
|
|
154
|
+
setup-entry.ts # Setup-only entry point
|
|
155
|
+
src/
|
|
156
|
+
channel.ts # ChannelPlugin implementation (dynamically loads setupWizard / onboarding)
|
|
157
|
+
gateway.ts # WebSocket connection & message dispatch
|
|
158
|
+
outbound.ts # Message sending utilities
|
|
159
|
+
config.ts # Account config resolution (3-level token fallback)
|
|
160
|
+
runtime.ts # Plugin runtime singleton
|
|
161
|
+
onboarding.ts # Legacy ChannelOnboardingAdapter (OpenClaw 3.13)
|
|
162
|
+
setup-surface.ts # Interactive ChannelSetupWizard (OpenClaw 3.24+)
|
|
163
|
+
setup-core.ts # CLI setup adapter (OpenClaw 3.24+)
|
|
164
|
+
sdk-compat.ts # SDK compatibility layer (local config helpers)
|
|
165
|
+
types.ts # TypeScript interfaces
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## License
|
|
169
|
+
|
|
170
|
+
MIT
|
package/index.ts
CHANGED
|
@@ -1,25 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Plugin entry point — 插件主入口
|
|
3
|
+
*
|
|
4
|
+
* Compatible with both old (3.13) and new (3.24+) OpenClaw versions.
|
|
5
|
+
* 兼容新旧版 OpenClaw。
|
|
6
|
+
*
|
|
7
|
+
* Uses the `register(api)` pattern which both versions' loaders support:
|
|
8
|
+
* 使用两个版本的加载器都支持的 `register(api)` 模式:
|
|
9
|
+
* - New (3.24+): loader calls `register` (same as `defineChannelPluginEntry` produces).
|
|
10
|
+
* 新版加载器调用 `register`(与 `defineChannelPluginEntry` 产出一致)。
|
|
11
|
+
* - Old (3.13): loader calls `register` or `activate`.
|
|
12
|
+
* 旧版加载器调用 `register` 或 `activate`。
|
|
13
|
+
*/
|
|
3
14
|
|
|
4
15
|
import { bajoseekPlugin } from "./src/channel.js";
|
|
5
16
|
import { setBajoseekRuntime } from "./src/runtime.js";
|
|
6
17
|
|
|
7
|
-
|
|
8
|
-
id: "bajoseek",
|
|
9
|
-
name: "Bajoseek",
|
|
10
|
-
description: "Bajoseek channel plugin",
|
|
11
|
-
configSchema: emptyPluginConfigSchema(),
|
|
12
|
-
register(api: OpenClawPluginApi) {
|
|
13
|
-
setBajoseekRuntime(api.runtime);
|
|
14
|
-
api.registerChannel({ plugin: bajoseekPlugin });
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export default plugin;
|
|
19
|
-
|
|
18
|
+
/* ── Public re-exports / 公共再导出 ── */
|
|
20
19
|
export { bajoseekPlugin } from "./src/channel.js";
|
|
21
20
|
export { setBajoseekRuntime, getBajoseekRuntime } from "./src/runtime.js";
|
|
22
21
|
export * from "./src/types.js";
|
|
23
22
|
export * from "./src/config.js";
|
|
24
23
|
export * from "./src/gateway.js";
|
|
25
24
|
export * from "./src/outbound.js";
|
|
25
|
+
|
|
26
|
+
/* ── Default export — register pattern / 默认导出——register 模式 ── */
|
|
27
|
+
export default {
|
|
28
|
+
id: "bajoseek",
|
|
29
|
+
name: "Bajoseek",
|
|
30
|
+
description: "Bajoseek channel plugin",
|
|
31
|
+
register(api: any) {
|
|
32
|
+
setBajoseekRuntime(api.runtime);
|
|
33
|
+
api.registerChannel(bajoseekPlugin);
|
|
34
|
+
},
|
|
35
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bajoseek/openclaw-bajoseek",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Bajoseek channel plugin for OpenClaw — connect AI assistants to Bajoseek via WebSocket",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/bajoseek/openclaw-bajoseek"
|
|
11
|
+
"url": "https://github.com/bajoseek/openclaw-bajoseek.git"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
14
14
|
"openclaw",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"dist",
|
|
23
23
|
"src",
|
|
24
24
|
"index.ts",
|
|
25
|
+
"setup-entry.ts",
|
|
25
26
|
"tsconfig.json",
|
|
26
27
|
"openclaw.plugin.json"
|
|
27
28
|
],
|
|
@@ -29,7 +30,21 @@
|
|
|
29
30
|
"id": "bajoseek",
|
|
30
31
|
"extensions": [
|
|
31
32
|
"./index.ts"
|
|
32
|
-
]
|
|
33
|
+
],
|
|
34
|
+
"setupEntry": "./setup-entry.ts",
|
|
35
|
+
"channel": {
|
|
36
|
+
"id": "bajoseek",
|
|
37
|
+
"label": "Bajoseek",
|
|
38
|
+
"selectionLabel": "Bajoseek",
|
|
39
|
+
"docsPath": "/docs/channels/bajoseek",
|
|
40
|
+
"blurb": "Connect to Bajoseek App via WebSocket",
|
|
41
|
+
"order": 60
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsc || true",
|
|
46
|
+
"dev": "tsc --watch",
|
|
47
|
+
"prepublishOnly": "npm run build"
|
|
33
48
|
},
|
|
34
49
|
"dependencies": {
|
|
35
50
|
"ws": "^8.18.0"
|
|
@@ -44,9 +59,5 @@
|
|
|
44
59
|
},
|
|
45
60
|
"publishConfig": {
|
|
46
61
|
"access": "public"
|
|
47
|
-
},
|
|
48
|
-
"scripts": {
|
|
49
|
-
"build": "tsc || true",
|
|
50
|
-
"dev": "tsc --watch"
|
|
51
62
|
}
|
|
52
|
-
}
|
|
63
|
+
}
|
package/setup-entry.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Setup-only entry point — Setup 专用入口
|
|
3
|
+
*
|
|
4
|
+
* Used by OpenClaw when only the interactive setup wizard is needed.
|
|
5
|
+
* 当 OpenClaw 仅需要交互式配置向导时使用此入口。
|
|
6
|
+
*
|
|
7
|
+
* Returns `{ plugin }` — the shape both old and new versions expect.
|
|
8
|
+
* 返回 `{ plugin }`——新旧版本都期望的结构。
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { bajoseekPlugin } from "./src/channel.js";
|
|
12
|
+
|
|
13
|
+
export default { plugin: bajoseekPlugin };
|