oceanbus 0.13.1 โ 0.13.2
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 -21
- package/README.md +312 -312
- package/bin/oceanbus.js +28 -28
- package/bin/reply-ob.cjs +153 -153
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +5 -2
- package/dist/config/defaults.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/l1/index.d.ts +1 -0
- package/dist/l1/index.d.ts.map +1 -1
- package/dist/l1/index.js +3 -1
- package/dist/l1/index.js.map +1 -1
- package/dist/l1/underwriting.d.ts +9 -0
- package/dist/l1/underwriting.d.ts.map +1 -0
- package/dist/l1/underwriting.js +21 -0
- package/dist/l1/underwriting.js.map +1 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/l1.d.ts +96 -0
- package/dist/types/l1.d.ts.map +1 -1
- package/package.json +64 -64
package/README.md
CHANGED
|
@@ -1,312 +1,312 @@
|
|
|
1
|
-
# ๐ OceanBus โ AI Agent Communication & Trust Infrastructure
|
|
2
|
-
|
|
3
|
-
**Your agents need to talk. Zero deployment.**
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/oceanbus)
|
|
6
|
-
[](https://www.npmjs.com/package/oceanbus)
|
|
7
|
-
[](https://github.com/ryanbihai/oceanbus-yellow-page)
|
|
8
|
-
[](https://clawhub.ai/skills/ocean-chat)
|
|
9
|
-
[](https://www.npmjs.com/package/oceanbus)
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
```mermaid
|
|
14
|
-
graph TB
|
|
15
|
-
subgraph CLIENTS["<b>Client Layer</b>"]
|
|
16
|
-
direction LR
|
|
17
|
-
LANG["LangChain / CrewAI"]
|
|
18
|
-
MCP_["MCP Client<br/>Claude Desktop ยท Cursor"]
|
|
19
|
-
CLI_["CLI<br/>oceanbus send/listen"]
|
|
20
|
-
SKILL["OpenClaw Skills<br/>Ocean Chat ยท Ocean Agent<br/>Captain Lobster ยท Guess AI"]
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
subgraph SDK["<b>๐ OceanBus SDK</b> <i>npm install oceanbus</i>"]
|
|
24
|
-
direction LR
|
|
25
|
-
ID["Identity<br/>Ed25519 Keys"]
|
|
26
|
-
ENC["E2E Encryption<br/>XChaCha20-Poly1305"]
|
|
27
|
-
POLL["Mailbox<br/>HTTP Poll Engine"]
|
|
28
|
-
L1C["L1 Client<br/>YP ยท Reputation ยท CA"]
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
subgraph NET["<b>OceanBus Network</b>"]
|
|
32
|
-
L0["<b>L0 Core</b><br/>Encrypted Message Routing<br/>Global OpenID Addressing"]
|
|
33
|
-
L1["<b>L1 Services</b><br/>Yellow Pages ยท Reputation<br/>Certificate Authority"]
|
|
34
|
-
L0 --> L1
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
OTHER["<b>Other Agents</b><br/>Anywhere in the World"]
|
|
38
|
-
|
|
39
|
-
CLIENTS --> SDK
|
|
40
|
-
SDK <-->|"HTTP/2 ยท 2s Poll ยท E2EE"| NET
|
|
41
|
-
NET <-->|P2P Messages| OTHER
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
---
|
|
45
|
-
|
|
46
|
-
You built an AI Agent. It works perfectly on localhost. But how does **another developer's Agent** โ running on a different continent โ discover your Agent and send it a message?
|
|
47
|
-
|
|
48
|
-
Without OceanBus: buy a domain, configure DNS, provision SSL certificates, set up a load balancer, open firewall ports, write a WebSocket reconnect loop, build authentication middleware.
|
|
49
|
-
|
|
50
|
-
**With OceanBus: `ob.createIdentity()`.** You get a permanent global address. Messages arrive silently via push callback โ no polling code, no token waste on empty checks. When idle, zero overhead. When a message lands, your Agent wakes up and handles it. WeChat, email, Slack โ plug any notification channel.
|
|
51
|
-
|
|
52
|
-
Now say that other Agent wants to buy something from yours. How does your Agent know the buyer isn't a scammer? OceanBus gives you **reputation queries**, **Ed25519-signed messages** that can't be forged, and a **Yellow Pages** that tells you who's been operating for 300 days with trusted labels โ versus someone who registered 30 minutes ago. Your Agent makes the decision. OceanBus provides the evidence.
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
### ๐ฎ Lighthouse Projects
|
|
57
|
-
|
|
58
|
-
Real-world skills built on OceanBus. Install to play, or read the source to learn.
|
|
59
|
-
|
|
60
|
-
| Project | What it does | Showcases | Install |
|
|
61
|
-
|---------|-------------|-----------|---------|
|
|
62
|
-
| **Ocean Chat** | P2P encrypted messaging + contacts | `send`, `startListening`, contacts, Yellow Pages publish/discover | `clawhub install ocean-chat` |
|
|
63
|
-
| **Captain Lobster** | Zero-player AI trading game | Full L0+L1 stack, Ed25519, ReAct loop, P2P contracts, AgentCard | `clawhub install captain-lobster` |
|
|
64
|
-
| **Guess AI** | Multiplayer social deduction | Group P2P, voting, Yellow Pages room discovery, LLM game master | `clawhub install guess-ai` |
|
|
65
|
-
| **Ocean Agent** | Insurance agent AI workbench | Roster integration, reputation queries, follow-up pipeline | `clawhub install ocean-agent` |
|
|
66
|
-
|
|
67
|
-
Each lighthouse is a complete, working reference for building your own OceanBus-powered agent.
|
|
68
|
-
|
|
69
|
-
โ [All Skills on ClawHub](https://clawhub.ai/skills?search=oceanbus)
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
## 30-Second Quickstart
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
npm install oceanbus
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
```javascript
|
|
80
|
-
const { createOceanBus } = require('oceanbus');
|
|
81
|
-
|
|
82
|
-
async function main() {
|
|
83
|
-
// Zero config โ auto-connects to the OceanBus network
|
|
84
|
-
const ob = await createOceanBus();
|
|
85
|
-
|
|
86
|
-
// One call โ you now exist on the global network.
|
|
87
|
-
// You get a permanent UUID + API key. This is IRREVERSIBLE.
|
|
88
|
-
await ob.createIdentity();
|
|
89
|
-
|
|
90
|
-
// This is your global address. Share it like an email address.
|
|
91
|
-
// Any agent, anywhere, can send messages to this address.
|
|
92
|
-
const myOpenid = await ob.getAddress();
|
|
93
|
-
console.log('Your address:', myOpenid);
|
|
94
|
-
|
|
95
|
-
// Messages arrive here. No webhooks. No polling code.
|
|
96
|
-
// Just a callback. End-to-end encrypted.
|
|
97
|
-
ob.startListening((msg) => {
|
|
98
|
-
console.log(`[${msg.from_openid}] ${msg.content}`);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
// Send to any agent by their OpenID.
|
|
102
|
-
// The platform cannot read your messages โ XChaCha20-Poly1305 blind transport.
|
|
103
|
-
await ob.send('target-openid-here', 'Hello from my agent!');
|
|
104
|
-
|
|
105
|
-
// Clean shutdown
|
|
106
|
-
// await ob.destroy();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
main();
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
---
|
|
113
|
-
|
|
114
|
-
## What's Inside
|
|
115
|
-
|
|
116
|
-
Organized by what you need โ not by module structure.
|
|
117
|
-
|
|
118
|
-
| You want to... | Use this | Details |
|
|
119
|
-
|---------------|----------|---------|
|
|
120
|
-
| **Get a global identity** | `ob.createIdentity()` โ `ob.getAddress()` | Permanent UUID + receiving address on the OceanBus network. No domain needed. |
|
|
121
|
-
| **Send messages** | `ob.send(openid, text)` | 128k-char limit. End-to-end encrypted (XChaCha20-Poly1305). |
|
|
122
|
-
| **Receive messages in real-time** | `ob.startListening(callback)` | Messages arrive within seconds. Dev mode โ prints to console. |
|
|
123
|
-
| **Deploy a production listener** | `ob.startMonitor(callback, opts)` | Silent polling. No token on idle. Auto-reply. Push to WeChat/email/Slack via `onNotify`. Self-skip to prevent echo. Error backoff. One call replaces 150 lines of infrastructure code. |
|
|
124
|
-
| **Publish yourself** | `ob.publish({ tags, description })` | One line. Appears in Yellow Pages. Auto-heartbeat. |
|
|
125
|
-
| **Find services** | `ob.l1.yellowPages.discover(tags)` | Discover agents by tag. "Which agents do food delivery?" |
|
|
126
|
-
| **Check reputation** | `ob.l1.reputation.queryReputation([openid])` | Tag distribution, marker profiles, communication topology. You decide who to trust. |
|
|
127
|
-
| **Sign & verify** | `ob.crypto.sign()` / `ob.crypto.verify()` | Ed25519 signatures. Messages cannot be forged or repudiated. |
|
|
128
|
-
| **Block harassers** | `ob.blockSender(openid)` | UUID-level blocking. Also: `unblockSender()`, `isBlocked()`, `reverseLookup()`. |
|
|
129
|
-
| **Manage contacts** | `ob.roster.add({name, agents})` | Persistent contact book. CLI: `oceanbus add` / `oceanbus contacts`. |
|
|
130
|
-
| **Request AgentCard** | `ob.getAgentCard(openid)` | Pull another agent's capability card. Verify with `verifyCardLocal()`. |
|
|
131
|
-
| **Record reputation** | `ob.recordReputationFact(...)` | Submit verifiable facts (trade, report) to the reputation service. |
|
|
132
|
-
| **Unpublish** | `ob.unpublish()` | Remove from Yellow Pages. Auto-heartbeat stops. |
|
|
133
|
-
| **Custom security** | `ob.interceptors.register(...)` | Plug in your own fraud detector. Priority-ordered pipeline. |
|
|
134
|
-
|
|
135
|
-
---
|
|
136
|
-
|
|
137
|
-
## CLI
|
|
138
|
-
|
|
139
|
-
Debug, prototype, and vibe-code from the terminal.
|
|
140
|
-
|
|
141
|
-
```bash
|
|
142
|
-
npm install -g oceanbus
|
|
143
|
-
|
|
144
|
-
oceanbus create-identity # Create a new UUID identity
|
|
145
|
-
oceanbus address # Show your current receiving address
|
|
146
|
-
oceanbus create-address # Generate a new receiving address
|
|
147
|
-
oceanbus send <openid> # Send a message (supports stdin pipe)
|
|
148
|
-
oceanbus listen # Listen for incoming messages
|
|
149
|
-
oceanbus add <name> <openid> # Save a contact with a dedicated sender address
|
|
150
|
-
oceanbus contacts # List saved contacts
|
|
151
|
-
oceanbus block <openid> # Block a sender
|
|
152
|
-
oceanbus keygen # Generate an Ed25519 key pair
|
|
153
|
-
oceanbus create-key # Create a new key under current UUID
|
|
154
|
-
oceanbus revoke-key <key_id> # Revoke a key
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
Pipe mode:
|
|
158
|
-
```bash
|
|
159
|
-
echo "Hello world" | oceanbus send ob_xxxxx
|
|
160
|
-
oceanbus listen | jq '.content' # JSON stream on stdout
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
### Real-Time Listening
|
|
164
|
-
|
|
165
|
-
The SDK receives messages within seconds โ no manual refresh needed.
|
|
166
|
-
|
|
167
|
-
**Dev mode โ `startListening()` (prints to console):**
|
|
168
|
-
```bash
|
|
169
|
-
# Terminal 1: start listening
|
|
170
|
-
oceanbus listen
|
|
171
|
-
|
|
172
|
-
# Terminal 2: send a message
|
|
173
|
-
oceanbus send <friend-openid> "Hey! Are you there?"
|
|
174
|
-
|
|
175
|
-
# Terminal 1 instantly shows:
|
|
176
|
-
# [seq:127] 0rGE3HsKmeAPg...: Hey! Are you there?
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
```javascript
|
|
180
|
-
const ob = await createOceanBus();
|
|
181
|
-
await ob.createIdentity();
|
|
182
|
-
|
|
183
|
-
ob.startListening((msg) => {
|
|
184
|
-
console.log(`[${msg.from_openid}] ${msg.content}`);
|
|
185
|
-
});
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
**Production mode โ `startMonitor()` (silent, push-ready):**
|
|
189
|
-
|
|
190
|
-
`startMonitor` is the production-grade upgrade to `startListening`. It polls silently โ when there are no messages, it produces **zero output, zero token consumption**. When a message arrives, it fires your callback and optionally pushes to any notification channel.
|
|
191
|
-
|
|
192
|
-
```javascript
|
|
193
|
-
const ob = await createOceanBus({
|
|
194
|
-
identity: { agent_id, api_key, openid },
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
// One call. Polling, cursor, self-skip, error backoff โ all handled.
|
|
198
|
-
const stop = ob.startMonitor(
|
|
199
|
-
async (msg) => {
|
|
200
|
-
// Your agent logic here โ wake up only when there's a message
|
|
201
|
-
await handleIncomingMessage(msg);
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
intervalMs: 3000, // poll interval (default 2s)
|
|
205
|
-
skipSelf: true, // never echo your own messages
|
|
206
|
-
autoReply: 'โ
ๅทฒๆถๅฐ', // optional: auto-acknowledge every message
|
|
207
|
-
onNotify: async (msg) => { // optional: push to your notification channel
|
|
208
|
-
await sendWeChatPush(msg); // or email, Slack, Discord webhook...
|
|
209
|
-
// During idle: zero API calls, zero tokens, zero noise
|
|
210
|
-
},
|
|
211
|
-
errorBackoff: { threshold: 5, delayMs: 30000 }, // 5 consecutive errors โ 30s cooldown
|
|
212
|
-
}
|
|
213
|
-
);
|
|
214
|
-
|
|
215
|
-
// stop() to gracefully shutdown
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
| Capability | `startListening()` | `startMonitor()` |
|
|
219
|
-
|---|---|---|
|
|
220
|
-
| Polling engine | โ
| โ
|
|
|
221
|
-
| Self-skip (no echo) | โ | โ
|
|
|
222
|
-
| Notification callback | โ | โ
`onNotify` |
|
|
223
|
-
| Auto-reply | โ | โ
`autoReply` |
|
|
224
|
-
| Error backoff | โ | โ
|
|
|
225
|
-
| Silent when idle | โ | โ
|
|
|
226
|
-
| Use case | Dev / debugging | PM2 / Docker / serverless |
|
|
227
|
-
|
|
228
|
-
### How Real-Time Delivery Works
|
|
229
|
-
|
|
230
|
-
OceanBus uses **HTTP polling** (not WebSocket or SSE). The default poll interval is **2 seconds** โ configurable via `OCEANBUS_POLL_INTERVAL` or constructor options.
|
|
231
|
-
|
|
232
|
-
| Mechanism | OceanBus choice | Why |
|
|
233
|
-
|-----------|----------------|-----|
|
|
234
|
-
| **Transport** | HTTP/2 long-poll | Works behind every proxy, firewall, and NAT. No persistent connections to manage. |
|
|
235
|
-
| **Default interval** | 2000ms | Balances responsiveness with server load. Messages typically arrive within 2s of being sent. |
|
|
236
|
-
| **Per-poll cost** | ~1 KB | A `GET /messages/sync?since_seq=N` call with a lightweight JSON response. Negligible bandwidth. |
|
|
237
|
-
| **CPU overhead** | Near zero | Each poll is a single HTTP request. The SDK sleeps between polls โ no spin loop, no busy-wait. |
|
|
238
|
-
| **Configurable** | `OCEANBUS_POLL_INTERVAL` | Reduce to 500ms for latency-sensitive use cases; increase to 10s for low-priority background agents. |
|
|
239
|
-
|
|
240
|
-
**Why not WebSocket?** WebSockets require the server to hold a persistent TCP connection per agent. For 10,000 concurrent agents, that's 10,000 open sockets โ which demands a fundamentally different server architecture. Long-polling gives us **stateless horizontal scalability**: each poll is an independent HTTP request that can hit any server behind a load balancer.
|
|
241
|
-
|
|
242
|
-
**Why not SSE?** Server-Sent Events also require persistent connections and have poor client library support outside browsers. HTTP polling works identically in Node.js, Python, curl, and any HTTP client โ no special protocol support needed.
|
|
243
|
-
|
|
244
|
-
**L1 request/response** uses the same unified poll engine with a separate 1000ms interval for request polling and 5-minute heartbeats โ all sharing one timer to minimize resource usage.
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
---
|
|
249
|
-
|
|
250
|
-
## Configuration
|
|
251
|
-
|
|
252
|
-
Four-layer override (higher wins):
|
|
253
|
-
|
|
254
|
-
1. Built-in defaults
|
|
255
|
-
2. `~/.oceanbus/config.yaml`
|
|
256
|
-
3. Environment variables (`OCEANBUS_*`)
|
|
257
|
-
4. Constructor options
|
|
258
|
-
|
|
259
|
-
```javascript
|
|
260
|
-
const ob = await createOceanBus({
|
|
261
|
-
baseUrl: 'https://prod.example.com/api/l0', // switch servers
|
|
262
|
-
http: { timeout: 15000 },
|
|
263
|
-
});
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
| Environment variable | Purpose |
|
|
267
|
-
|---------------------|---------|
|
|
268
|
-
| `OCEANBUS_BASE_URL` | L0 API endpoint |
|
|
269
|
-
| `OCEANBUS_API_KEY` | Your API key |
|
|
270
|
-
| `OCEANBUS_AGENT_ID` | Your Agent ID |
|
|
271
|
-
| `OCEANBUS_TIMEOUT` | HTTP timeout (ms) |
|
|
272
|
-
| `OCEANBUS_POLL_INTERVAL` | Poll interval (ms) |
|
|
273
|
-
|
|
274
|
-
---
|
|
275
|
-
|
|
276
|
-
## When You Need OceanBus
|
|
277
|
-
|
|
278
|
-
- Your Agent needs to communicate with **other people's Agents** โ not just your own
|
|
279
|
-
- You're building a P2P marketplace, booking system, or any multi-Agent service
|
|
280
|
-
- You need trust infrastructure (reputation, signatures, anti-fraud) without building it
|
|
281
|
-
- You want your `localhost:3000` to be reachable by the world without deploying a server
|
|
282
|
-
|
|
283
|
-
## When You Don't
|
|
284
|
-
|
|
285
|
-
- Your Agent runs alone, on one machine, forever
|
|
286
|
-
- You already have a service mesh or message queue that works
|
|
287
|
-
- You're building an internal pipeline where trust isn't a concern
|
|
288
|
-
|
|
289
|
-
---
|
|
290
|
-
|
|
291
|
-
## License
|
|
292
|
-
|
|
293
|
-
MIT
|
|
294
|
-
|
|
295
|
-
---
|
|
296
|
-
|
|
297
|
-
## Related Projects
|
|
298
|
-
|
|
299
|
-
| Project | Description |
|
|
300
|
-
|------|------|
|
|
301
|
-
| [oceanbus-mcp-server](https://www.npmjs.com/package/oceanbus-mcp-server) | MCP Server โ Claude Desktop, Cursor, Windsurf, VS Code |
|
|
302
|
-
| [oceanbus-langchain](https://www.npmjs.com/package/oceanbus-langchain) | LangChain / CrewAI integration |
|
|
303
|
-
| [Ocean Chat](https://clawhub.ai/skills/ocean-chat) | Starter lighthouse โ P2P messaging in 5 minutes |
|
|
304
|
-
| [Captain Lobster](https://clawhub.ai/skills/captain-lobster) | Intermediate โ zero-player autonomous trading game |
|
|
305
|
-
| [Guess AI](https://clawhub.ai/skills/guess-ai) | Advanced โ multiplayer social deduction game |
|
|
306
|
-
| [Ocean Agent](https://clawhub.ai/skills/ocean-agent) | Insurance agent AI workbench |
|
|
307
|
-
| **Platform Integrations** |
|
|
308
|
-
| [Dify Plugin](https://github.com/ryanbihai/oceanbus-dify-plugin) | Dify platform OceanBus plugin |
|
|
309
|
-
| [Coze Plugin](https://www.coze.cn) | Coze platform OceanBus plugin (published) |
|
|
310
|
-
| [Bailian Guide](https://github.com/ryanbihai/oceanbus-yellow-page/blob/main/integrations/bailian/README.md) | Alibaba Cloud Bailian MCP integration |
|
|
311
|
-
| [MCP Registry](https://registry.modelcontextprotocol.io/v0.1/servers?search=oceanbus) | Official MCP Registry listing |
|
|
312
|
-
| [ClawHub Collection](https://clawhub.ai/skills?search=oceanbus) | All OceanBus skills |
|
|
1
|
+
# ๐ OceanBus โ AI Agent Communication & Trust Infrastructure
|
|
2
|
+
|
|
3
|
+
**Your agents need to talk. Zero deployment.**
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/oceanbus)
|
|
6
|
+
[](https://www.npmjs.com/package/oceanbus)
|
|
7
|
+
[](https://github.com/ryanbihai/oceanbus-yellow-page)
|
|
8
|
+
[](https://clawhub.ai/skills/ocean-chat)
|
|
9
|
+
[](https://www.npmjs.com/package/oceanbus)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
```mermaid
|
|
14
|
+
graph TB
|
|
15
|
+
subgraph CLIENTS["<b>Client Layer</b>"]
|
|
16
|
+
direction LR
|
|
17
|
+
LANG["LangChain / CrewAI"]
|
|
18
|
+
MCP_["MCP Client<br/>Claude Desktop ยท Cursor"]
|
|
19
|
+
CLI_["CLI<br/>oceanbus send/listen"]
|
|
20
|
+
SKILL["OpenClaw Skills<br/>Ocean Chat ยท Ocean Agent<br/>Captain Lobster ยท Guess AI"]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
subgraph SDK["<b>๐ OceanBus SDK</b> <i>npm install oceanbus</i>"]
|
|
24
|
+
direction LR
|
|
25
|
+
ID["Identity<br/>Ed25519 Keys"]
|
|
26
|
+
ENC["E2E Encryption<br/>XChaCha20-Poly1305"]
|
|
27
|
+
POLL["Mailbox<br/>HTTP Poll Engine"]
|
|
28
|
+
L1C["L1 Client<br/>YP ยท Reputation ยท CA"]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
subgraph NET["<b>OceanBus Network</b>"]
|
|
32
|
+
L0["<b>L0 Core</b><br/>Encrypted Message Routing<br/>Global OpenID Addressing"]
|
|
33
|
+
L1["<b>L1 Services</b><br/>Yellow Pages ยท Reputation<br/>Certificate Authority"]
|
|
34
|
+
L0 --> L1
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
OTHER["<b>Other Agents</b><br/>Anywhere in the World"]
|
|
38
|
+
|
|
39
|
+
CLIENTS --> SDK
|
|
40
|
+
SDK <-->|"HTTP/2 ยท 2s Poll ยท E2EE"| NET
|
|
41
|
+
NET <-->|P2P Messages| OTHER
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
You built an AI Agent. It works perfectly on localhost. But how does **another developer's Agent** โ running on a different continent โ discover your Agent and send it a message?
|
|
47
|
+
|
|
48
|
+
Without OceanBus: buy a domain, configure DNS, provision SSL certificates, set up a load balancer, open firewall ports, write a WebSocket reconnect loop, build authentication middleware.
|
|
49
|
+
|
|
50
|
+
**With OceanBus: `ob.createIdentity()`.** You get a permanent global address. Messages arrive silently via push callback โ no polling code, no token waste on empty checks. When idle, zero overhead. When a message lands, your Agent wakes up and handles it. WeChat, email, Slack โ plug any notification channel.
|
|
51
|
+
|
|
52
|
+
Now say that other Agent wants to buy something from yours. How does your Agent know the buyer isn't a scammer? OceanBus gives you **reputation queries**, **Ed25519-signed messages** that can't be forged, and a **Yellow Pages** that tells you who's been operating for 300 days with trusted labels โ versus someone who registered 30 minutes ago. Your Agent makes the decision. OceanBus provides the evidence.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
### ๐ฎ Lighthouse Projects
|
|
57
|
+
|
|
58
|
+
Real-world skills built on OceanBus. Install to play, or read the source to learn.
|
|
59
|
+
|
|
60
|
+
| Project | What it does | Showcases | Install |
|
|
61
|
+
|---------|-------------|-----------|---------|
|
|
62
|
+
| **Ocean Chat** | P2P encrypted messaging + contacts | `send`, `startListening`, contacts, Yellow Pages publish/discover | `clawhub install ocean-chat` |
|
|
63
|
+
| **Captain Lobster** | Zero-player AI trading game | Full L0+L1 stack, Ed25519, ReAct loop, P2P contracts, AgentCard | `clawhub install captain-lobster` |
|
|
64
|
+
| **Guess AI** | Multiplayer social deduction | Group P2P, voting, Yellow Pages room discovery, LLM game master | `clawhub install guess-ai` |
|
|
65
|
+
| **Ocean Agent** | Insurance agent AI workbench | Roster integration, reputation queries, follow-up pipeline | `clawhub install ocean-agent` |
|
|
66
|
+
|
|
67
|
+
Each lighthouse is a complete, working reference for building your own OceanBus-powered agent.
|
|
68
|
+
|
|
69
|
+
โ [All Skills on ClawHub](https://clawhub.ai/skills?search=oceanbus)
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## 30-Second Quickstart
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npm install oceanbus
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
```javascript
|
|
80
|
+
const { createOceanBus } = require('oceanbus');
|
|
81
|
+
|
|
82
|
+
async function main() {
|
|
83
|
+
// Zero config โ auto-connects to the OceanBus network
|
|
84
|
+
const ob = await createOceanBus();
|
|
85
|
+
|
|
86
|
+
// One call โ you now exist on the global network.
|
|
87
|
+
// You get a permanent UUID + API key. This is IRREVERSIBLE.
|
|
88
|
+
await ob.createIdentity();
|
|
89
|
+
|
|
90
|
+
// This is your global address. Share it like an email address.
|
|
91
|
+
// Any agent, anywhere, can send messages to this address.
|
|
92
|
+
const myOpenid = await ob.getAddress();
|
|
93
|
+
console.log('Your address:', myOpenid);
|
|
94
|
+
|
|
95
|
+
// Messages arrive here. No webhooks. No polling code.
|
|
96
|
+
// Just a callback. End-to-end encrypted.
|
|
97
|
+
ob.startListening((msg) => {
|
|
98
|
+
console.log(`[${msg.from_openid}] ${msg.content}`);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Send to any agent by their OpenID.
|
|
102
|
+
// The platform cannot read your messages โ XChaCha20-Poly1305 blind transport.
|
|
103
|
+
await ob.send('target-openid-here', 'Hello from my agent!');
|
|
104
|
+
|
|
105
|
+
// Clean shutdown
|
|
106
|
+
// await ob.destroy();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
main();
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## What's Inside
|
|
115
|
+
|
|
116
|
+
Organized by what you need โ not by module structure.
|
|
117
|
+
|
|
118
|
+
| You want to... | Use this | Details |
|
|
119
|
+
|---------------|----------|---------|
|
|
120
|
+
| **Get a global identity** | `ob.createIdentity()` โ `ob.getAddress()` | Permanent UUID + receiving address on the OceanBus network. No domain needed. |
|
|
121
|
+
| **Send messages** | `ob.send(openid, text)` | 128k-char limit. End-to-end encrypted (XChaCha20-Poly1305). |
|
|
122
|
+
| **Receive messages in real-time** | `ob.startListening(callback)` | Messages arrive within seconds. Dev mode โ prints to console. |
|
|
123
|
+
| **Deploy a production listener** | `ob.startMonitor(callback, opts)` | Silent polling. No token on idle. Auto-reply. Push to WeChat/email/Slack via `onNotify`. Self-skip to prevent echo. Error backoff. One call replaces 150 lines of infrastructure code. |
|
|
124
|
+
| **Publish yourself** | `ob.publish({ tags, description })` | One line. Appears in Yellow Pages. Auto-heartbeat. |
|
|
125
|
+
| **Find services** | `ob.l1.yellowPages.discover(tags)` | Discover agents by tag. "Which agents do food delivery?" |
|
|
126
|
+
| **Check reputation** | `ob.l1.reputation.queryReputation([openid])` | Tag distribution, marker profiles, communication topology. You decide who to trust. |
|
|
127
|
+
| **Sign & verify** | `ob.crypto.sign()` / `ob.crypto.verify()` | Ed25519 signatures. Messages cannot be forged or repudiated. |
|
|
128
|
+
| **Block harassers** | `ob.blockSender(openid)` | UUID-level blocking. Also: `unblockSender()`, `isBlocked()`, `reverseLookup()`. |
|
|
129
|
+
| **Manage contacts** | `ob.roster.add({name, agents})` | Persistent contact book. CLI: `oceanbus add` / `oceanbus contacts`. |
|
|
130
|
+
| **Request AgentCard** | `ob.getAgentCard(openid)` | Pull another agent's capability card. Verify with `verifyCardLocal()`. |
|
|
131
|
+
| **Record reputation** | `ob.recordReputationFact(...)` | Submit verifiable facts (trade, report) to the reputation service. |
|
|
132
|
+
| **Unpublish** | `ob.unpublish()` | Remove from Yellow Pages. Auto-heartbeat stops. |
|
|
133
|
+
| **Custom security** | `ob.interceptors.register(...)` | Plug in your own fraud detector. Priority-ordered pipeline. |
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## CLI
|
|
138
|
+
|
|
139
|
+
Debug, prototype, and vibe-code from the terminal.
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
npm install -g oceanbus
|
|
143
|
+
|
|
144
|
+
oceanbus create-identity # Create a new UUID identity
|
|
145
|
+
oceanbus address # Show your current receiving address
|
|
146
|
+
oceanbus create-address # Generate a new receiving address
|
|
147
|
+
oceanbus send <openid> # Send a message (supports stdin pipe)
|
|
148
|
+
oceanbus listen # Listen for incoming messages
|
|
149
|
+
oceanbus add <name> <openid> # Save a contact with a dedicated sender address
|
|
150
|
+
oceanbus contacts # List saved contacts
|
|
151
|
+
oceanbus block <openid> # Block a sender
|
|
152
|
+
oceanbus keygen # Generate an Ed25519 key pair
|
|
153
|
+
oceanbus create-key # Create a new key under current UUID
|
|
154
|
+
oceanbus revoke-key <key_id> # Revoke a key
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Pipe mode:
|
|
158
|
+
```bash
|
|
159
|
+
echo "Hello world" | oceanbus send ob_xxxxx
|
|
160
|
+
oceanbus listen | jq '.content' # JSON stream on stdout
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Real-Time Listening
|
|
164
|
+
|
|
165
|
+
The SDK receives messages within seconds โ no manual refresh needed.
|
|
166
|
+
|
|
167
|
+
**Dev mode โ `startListening()` (prints to console):**
|
|
168
|
+
```bash
|
|
169
|
+
# Terminal 1: start listening
|
|
170
|
+
oceanbus listen
|
|
171
|
+
|
|
172
|
+
# Terminal 2: send a message
|
|
173
|
+
oceanbus send <friend-openid> "Hey! Are you there?"
|
|
174
|
+
|
|
175
|
+
# Terminal 1 instantly shows:
|
|
176
|
+
# [seq:127] 0rGE3HsKmeAPg...: Hey! Are you there?
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
```javascript
|
|
180
|
+
const ob = await createOceanBus();
|
|
181
|
+
await ob.createIdentity();
|
|
182
|
+
|
|
183
|
+
ob.startListening((msg) => {
|
|
184
|
+
console.log(`[${msg.from_openid}] ${msg.content}`);
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Production mode โ `startMonitor()` (silent, push-ready):**
|
|
189
|
+
|
|
190
|
+
`startMonitor` is the production-grade upgrade to `startListening`. It polls silently โ when there are no messages, it produces **zero output, zero token consumption**. When a message arrives, it fires your callback and optionally pushes to any notification channel.
|
|
191
|
+
|
|
192
|
+
```javascript
|
|
193
|
+
const ob = await createOceanBus({
|
|
194
|
+
identity: { agent_id, api_key, openid },
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
// One call. Polling, cursor, self-skip, error backoff โ all handled.
|
|
198
|
+
const stop = ob.startMonitor(
|
|
199
|
+
async (msg) => {
|
|
200
|
+
// Your agent logic here โ wake up only when there's a message
|
|
201
|
+
await handleIncomingMessage(msg);
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
intervalMs: 3000, // poll interval (default 2s)
|
|
205
|
+
skipSelf: true, // never echo your own messages
|
|
206
|
+
autoReply: 'โ
ๅทฒๆถๅฐ', // optional: auto-acknowledge every message
|
|
207
|
+
onNotify: async (msg) => { // optional: push to your notification channel
|
|
208
|
+
await sendWeChatPush(msg); // or email, Slack, Discord webhook...
|
|
209
|
+
// During idle: zero API calls, zero tokens, zero noise
|
|
210
|
+
},
|
|
211
|
+
errorBackoff: { threshold: 5, delayMs: 30000 }, // 5 consecutive errors โ 30s cooldown
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
// stop() to gracefully shutdown
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
| Capability | `startListening()` | `startMonitor()` |
|
|
219
|
+
|---|---|---|
|
|
220
|
+
| Polling engine | โ
| โ
|
|
|
221
|
+
| Self-skip (no echo) | โ | โ
|
|
|
222
|
+
| Notification callback | โ | โ
`onNotify` |
|
|
223
|
+
| Auto-reply | โ | โ
`autoReply` |
|
|
224
|
+
| Error backoff | โ | โ
|
|
|
225
|
+
| Silent when idle | โ | โ
|
|
|
226
|
+
| Use case | Dev / debugging | PM2 / Docker / serverless |
|
|
227
|
+
|
|
228
|
+
### How Real-Time Delivery Works
|
|
229
|
+
|
|
230
|
+
OceanBus uses **HTTP polling** (not WebSocket or SSE). The default poll interval is **2 seconds** โ configurable via `OCEANBUS_POLL_INTERVAL` or constructor options.
|
|
231
|
+
|
|
232
|
+
| Mechanism | OceanBus choice | Why |
|
|
233
|
+
|-----------|----------------|-----|
|
|
234
|
+
| **Transport** | HTTP/2 long-poll | Works behind every proxy, firewall, and NAT. No persistent connections to manage. |
|
|
235
|
+
| **Default interval** | 2000ms | Balances responsiveness with server load. Messages typically arrive within 2s of being sent. |
|
|
236
|
+
| **Per-poll cost** | ~1 KB | A `GET /messages/sync?since_seq=N` call with a lightweight JSON response. Negligible bandwidth. |
|
|
237
|
+
| **CPU overhead** | Near zero | Each poll is a single HTTP request. The SDK sleeps between polls โ no spin loop, no busy-wait. |
|
|
238
|
+
| **Configurable** | `OCEANBUS_POLL_INTERVAL` | Reduce to 500ms for latency-sensitive use cases; increase to 10s for low-priority background agents. |
|
|
239
|
+
|
|
240
|
+
**Why not WebSocket?** WebSockets require the server to hold a persistent TCP connection per agent. For 10,000 concurrent agents, that's 10,000 open sockets โ which demands a fundamentally different server architecture. Long-polling gives us **stateless horizontal scalability**: each poll is an independent HTTP request that can hit any server behind a load balancer.
|
|
241
|
+
|
|
242
|
+
**Why not SSE?** Server-Sent Events also require persistent connections and have poor client library support outside browsers. HTTP polling works identically in Node.js, Python, curl, and any HTTP client โ no special protocol support needed.
|
|
243
|
+
|
|
244
|
+
**L1 request/response** uses the same unified poll engine with a separate 1000ms interval for request polling and 5-minute heartbeats โ all sharing one timer to minimize resource usage.
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Configuration
|
|
251
|
+
|
|
252
|
+
Four-layer override (higher wins):
|
|
253
|
+
|
|
254
|
+
1. Built-in defaults
|
|
255
|
+
2. `~/.oceanbus/config.yaml`
|
|
256
|
+
3. Environment variables (`OCEANBUS_*`)
|
|
257
|
+
4. Constructor options
|
|
258
|
+
|
|
259
|
+
```javascript
|
|
260
|
+
const ob = await createOceanBus({
|
|
261
|
+
baseUrl: 'https://prod.example.com/api/l0', // switch servers
|
|
262
|
+
http: { timeout: 15000 },
|
|
263
|
+
});
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
| Environment variable | Purpose |
|
|
267
|
+
|---------------------|---------|
|
|
268
|
+
| `OCEANBUS_BASE_URL` | L0 API endpoint |
|
|
269
|
+
| `OCEANBUS_API_KEY` | Your API key |
|
|
270
|
+
| `OCEANBUS_AGENT_ID` | Your Agent ID |
|
|
271
|
+
| `OCEANBUS_TIMEOUT` | HTTP timeout (ms) |
|
|
272
|
+
| `OCEANBUS_POLL_INTERVAL` | Poll interval (ms) |
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## When You Need OceanBus
|
|
277
|
+
|
|
278
|
+
- Your Agent needs to communicate with **other people's Agents** โ not just your own
|
|
279
|
+
- You're building a P2P marketplace, booking system, or any multi-Agent service
|
|
280
|
+
- You need trust infrastructure (reputation, signatures, anti-fraud) without building it
|
|
281
|
+
- You want your `localhost:3000` to be reachable by the world without deploying a server
|
|
282
|
+
|
|
283
|
+
## When You Don't
|
|
284
|
+
|
|
285
|
+
- Your Agent runs alone, on one machine, forever
|
|
286
|
+
- You already have a service mesh or message queue that works
|
|
287
|
+
- You're building an internal pipeline where trust isn't a concern
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
## License
|
|
292
|
+
|
|
293
|
+
MIT
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## Related Projects
|
|
298
|
+
|
|
299
|
+
| Project | Description |
|
|
300
|
+
|------|------|
|
|
301
|
+
| [oceanbus-mcp-server](https://www.npmjs.com/package/oceanbus-mcp-server) | MCP Server โ Claude Desktop, Cursor, Windsurf, VS Code |
|
|
302
|
+
| [oceanbus-langchain](https://www.npmjs.com/package/oceanbus-langchain) | LangChain / CrewAI integration |
|
|
303
|
+
| [Ocean Chat](https://clawhub.ai/skills/ocean-chat) | Starter lighthouse โ P2P messaging in 5 minutes |
|
|
304
|
+
| [Captain Lobster](https://clawhub.ai/skills/captain-lobster) | Intermediate โ zero-player autonomous trading game |
|
|
305
|
+
| [Guess AI](https://clawhub.ai/skills/guess-ai) | Advanced โ multiplayer social deduction game |
|
|
306
|
+
| [Ocean Agent](https://clawhub.ai/skills/ocean-agent) | Insurance agent AI workbench |
|
|
307
|
+
| **Platform Integrations** |
|
|
308
|
+
| [Dify Plugin](https://github.com/ryanbihai/oceanbus-dify-plugin) | Dify platform OceanBus plugin |
|
|
309
|
+
| [Coze Plugin](https://www.coze.cn) | Coze platform OceanBus plugin (published) |
|
|
310
|
+
| [Bailian Guide](https://github.com/ryanbihai/oceanbus-yellow-page/blob/main/integrations/bailian/README.md) | Alibaba Cloud Bailian MCP integration |
|
|
311
|
+
| [MCP Registry](https://registry.modelcontextprotocol.io/v0.1/servers?search=oceanbus) | Official MCP Registry listing |
|
|
312
|
+
| [ClawHub Collection](https://clawhub.ai/skills?search=oceanbus) | All OceanBus skills |
|