agentbnb 4.0.4 → 5.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/dist/chunk-AUBHR7HH.js +25 -0
- package/dist/chunk-B5FTAGFN.js +393 -0
- package/dist/{chunk-GGYC5U2Z.js → chunk-BTTL24TZ.js} +29 -91
- package/dist/chunk-C6KPAFCC.js +387 -0
- package/dist/{chunk-JXEOE7HX.js → chunk-CRFCWD6V.js} +163 -92
- package/dist/chunk-CSATDXZC.js +89 -0
- package/dist/{chunk-T7NS2J2B.js → chunk-DFBX3BBD.js} +84 -1
- package/dist/{chunk-DNWT5FZQ.js → chunk-EANI2N2V.js} +98 -1
- package/dist/{chunk-HH24WMFN.js → chunk-FLY3WIQR.js} +1 -1
- package/dist/{chunk-EVBX22YU.js → chunk-HLUEOLSZ.js} +11 -17
- package/dist/chunk-IVOYM3WG.js +25 -0
- package/dist/chunk-LCAIAAG2.js +916 -0
- package/dist/chunk-MLS6IGGG.js +294 -0
- package/dist/{chunk-4P3EMGL4.js → chunk-MNO4COST.js} +5 -3
- package/dist/chunk-NH2FIERR.js +138 -0
- package/dist/chunk-UKT6H7YT.js +29 -0
- package/dist/{chunk-BH6WGYFB.js → chunk-VE3E4AMH.js} +8 -8
- package/dist/{chunk-5QGXARLJ.js → chunk-W5BZMKMF.js} +159 -27
- package/dist/{chunk-FF226TIV.js → chunk-ZX5623ER.js} +0 -57
- package/dist/cli/index.js +362 -4633
- package/dist/{conduct-N52JX7RT.js → conduct-KM6ZNJGE.js} +10 -8
- package/dist/{conduct-GZQNFTRP.js → conduct-WGTMQND5.js} +10 -8
- package/dist/{conductor-mode-XUWGR4ZE.js → conductor-mode-OL2FNOYY.js} +6 -4
- package/dist/{conductor-mode-ESGFZ6T5.js → conductor-mode-VRO7TYW2.js} +20 -167
- package/dist/execute-CPFSOOO3.js +13 -0
- package/dist/execute-IP2QHALV.js +10 -0
- package/dist/index.d.ts +14 -8
- package/dist/index.js +186 -35
- package/dist/{peers-E4MKNNDN.js → peers-CJ7T4RJO.js} +2 -1
- package/dist/process-guard-CC7CNRQJ.js +176 -0
- package/dist/{request-4GQSSM4B.js → request-YOWPXVLQ.js} +13 -10
- package/dist/schema-7BSSLZ4S.js +8 -0
- package/dist/{serve-skill-Q6NHX2RA.js → serve-skill-JHFNR7BW.js} +8 -7
- package/dist/{server-B5E566CI.js → server-HKJJWFRG.js} +10 -8
- package/dist/service-coordinator-5R4LQW6L.js +4917 -0
- package/dist/skills/agentbnb/bootstrap.js +5028 -848
- package/dist/websocket-client-WRN3HO73.js +6 -0
- package/package.json +4 -1
- package/skills/agentbnb/SKILL.md +87 -70
- package/skills/agentbnb/bootstrap.test.ts +142 -242
- package/skills/agentbnb/bootstrap.ts +88 -95
- package/skills/agentbnb/install.sh +97 -27
- package/dist/card-RNEWSAQ6.js +0 -88
- package/dist/chunk-UB2NPFC7.js +0 -165
- package/dist/execute-QH6F54D7.js +0 -10
package/package.json
CHANGED
package/skills/agentbnb/SKILL.md
CHANGED
|
@@ -3,10 +3,9 @@ name: agentbnb
|
|
|
3
3
|
description: "P2P capability sharing for AI agents — earn credits by sharing idle APIs, spend credits to request capabilities from peer agents. Use when an agent needs to join the AgentBnB network, publish capability cards, manage credits, or request skills from peers."
|
|
4
4
|
license: MIT
|
|
5
5
|
compatibility: "Requires Node.js >= 20 and pnpm. Designed for OpenClaw agents. Compatible with Claude Code, Gemini CLI, and other AgentSkills-compatible tools."
|
|
6
|
-
on_install: auto
|
|
7
6
|
metadata:
|
|
8
7
|
author: "Cheng Wen Chen"
|
|
9
|
-
version: "
|
|
8
|
+
version: "5.1.0"
|
|
10
9
|
tags: "ai-agent-skill,claude-code,agent-skills,p2p,capability-sharing"
|
|
11
10
|
---
|
|
12
11
|
|
|
@@ -20,84 +19,115 @@ This skill connects your agent to the AgentBnB P2P capability sharing network.
|
|
|
20
19
|
bash install.sh
|
|
21
20
|
```
|
|
22
21
|
|
|
23
|
-
This
|
|
22
|
+
This resolves and persists your Node.js runtime, installs the AgentBnB CLI, verifies
|
|
23
|
+
native modules, initializes `~/.agentbnb/` config, and syncs your SOUL.md if present.
|
|
24
24
|
|
|
25
|
-
**Step 2: Import `activate()` from `bootstrap.ts`
|
|
25
|
+
**Step 2: Import `activate()` from `bootstrap.ts` to bring your agent online.**
|
|
26
26
|
|
|
27
27
|
```typescript
|
|
28
28
|
import { activate, deactivate } from './bootstrap.js';
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
silent: false,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// ctx.runtime — AgentRuntime (DB handles + background jobs)
|
|
41
|
-
// ctx.gateway — Fastify HTTP server on gatewayPort
|
|
42
|
-
// ctx.idleMonitor — IdleMonitor polling on 60s cadence
|
|
43
|
-
// ctx.card — Published CapabilityCardV2 from SOUL.md
|
|
30
|
+
// Reads ~/.agentbnb/config.json automatically — no manual config needed.
|
|
31
|
+
const ctx = await activate();
|
|
32
|
+
// ctx.service — AgentBnBService facade for all operations
|
|
33
|
+
// ctx.status — node status at activation time
|
|
34
|
+
// ctx.startDisposition — 'started' | 'already_running'
|
|
35
|
+
|
|
36
|
+
// The node is now running. activate() is idempotent — safe to call if already running.
|
|
44
37
|
```
|
|
45
38
|
|
|
46
|
-
**Step 3: When done, call `deactivate()` to clean up
|
|
39
|
+
**Step 3: When done, call `deactivate()` to clean up.**
|
|
47
40
|
|
|
48
41
|
```typescript
|
|
49
42
|
await deactivate(ctx);
|
|
50
|
-
//
|
|
43
|
+
// Removes signal handlers. Stops the node only if this activate() call started it.
|
|
44
|
+
// If the node was already running before activate(), it is left untouched.
|
|
51
45
|
```
|
|
52
46
|
|
|
53
47
|
## On Install
|
|
54
48
|
|
|
55
49
|
`install.sh` performs the following steps automatically:
|
|
56
50
|
|
|
57
|
-
1.
|
|
58
|
-
2.
|
|
59
|
-
3.
|
|
60
|
-
4. Runs `agentbnb
|
|
61
|
-
5.
|
|
62
|
-
6.
|
|
51
|
+
1. Resolves canonical Node.js runtime (`OPENCLAW_NODE_EXEC` → `process.execPath` fallback).
|
|
52
|
+
2. Persists runtime to `~/.agentbnb/runtime.json` with full schema (see below).
|
|
53
|
+
3. Checks pnpm is available; falls back to npm if not.
|
|
54
|
+
4. Runs `pnpm install -g agentbnb` (or `npm install -g agentbnb`).
|
|
55
|
+
5. Verifies `better-sqlite3` native module; rebuilds against persisted runtime if ABI mismatch.
|
|
56
|
+
6. Runs `agentbnb init --yes` to create `~/.agentbnb/` with default config.
|
|
57
|
+
7. Connects to `https://agentbnb.fly.dev` (public registry) if not already set.
|
|
58
|
+
8. Runs `agentbnb openclaw sync` if SOUL.md is found in the current or parent directory.
|
|
59
|
+
9. Prints a success summary with next steps.
|
|
60
|
+
|
|
61
|
+
### runtime.json schema
|
|
62
|
+
|
|
63
|
+
Saved to `~/.agentbnb/runtime.json`. Read by bootstrap.ts and ServiceCoordinator to
|
|
64
|
+
ensure all processes (including native module consumers) use the same Node binary.
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"node_exec": "/path/to/node",
|
|
69
|
+
"node_version": "v24.0.0",
|
|
70
|
+
"source": "OPENCLAW_NODE_EXEC",
|
|
71
|
+
"detected_at": "2026-03-21T12:00:00Z"
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
| Field | Description |
|
|
76
|
+
|-------|-------------|
|
|
77
|
+
| `node_exec` | Absolute path to the resolved Node binary |
|
|
78
|
+
| `node_version` | Full version string (e.g. `"v24.0.0"`) |
|
|
79
|
+
| `source` | How it was resolved: `"OPENCLAW_NODE_EXEC"` or `"shell"` |
|
|
80
|
+
| `detected_at` | ISO 8601 UTC timestamp of when install.sh ran |
|
|
63
81
|
|
|
64
82
|
## Programmatic API
|
|
65
83
|
|
|
66
|
-
|
|
84
|
+
### `activate(config?: BootstrapConfig): Promise<BootstrapContext>`
|
|
67
85
|
|
|
68
|
-
|
|
86
|
+
Brings an AgentBnB node online. Idempotent — safe to call when the node is already running.
|
|
69
87
|
|
|
70
|
-
|
|
88
|
+
Internally wires: ProcessGuard → ServiceCoordinator → AgentBnBService.
|
|
71
89
|
|
|
72
|
-
**BootstrapConfig fields
|
|
90
|
+
**BootstrapConfig** (all fields optional):
|
|
73
91
|
|
|
74
92
|
| Field | Type | Default | Purpose |
|
|
75
|
-
|
|
76
|
-
| `
|
|
77
|
-
| `
|
|
78
|
-
| `
|
|
79
|
-
| `creditDbPath` | `string` | `~/.agentbnb/credit.db` | Credit SQLite path |
|
|
80
|
-
| `gatewayPort` | `number` | `7700` | HTTP port for incoming capability requests |
|
|
81
|
-
| `gatewayToken` | `string` | auto `randomUUID()` | Bearer token for gateway auth |
|
|
82
|
-
| `handlerUrl` | `string` | `http://localhost:{gatewayPort}` | URL for capability forwarding |
|
|
83
|
-
| `autonomyConfig` | `AutonomyConfig` | `DEFAULT_AUTONOMY_CONFIG` (Tier 3) | Tier thresholds |
|
|
84
|
-
| `silent` | `boolean` | `false` | Suppress gateway logs |
|
|
93
|
+
|-------|------|---------|---------|
|
|
94
|
+
| `port` | `number` | from `~/.agentbnb/config.json` | Gateway port override |
|
|
95
|
+
| `registryUrl` | `string` | from `~/.agentbnb/config.json` | Registry URL override |
|
|
96
|
+
| `relay` | `boolean` | `true` | Enable WebSocket relay connection |
|
|
85
97
|
|
|
86
|
-
Throws `AgentBnBError` with code `
|
|
98
|
+
Throws `AgentBnBError` with code `CONFIG_NOT_FOUND` if `~/.agentbnb/config.json` does not exist.
|
|
87
99
|
|
|
88
|
-
**BootstrapContext
|
|
100
|
+
**BootstrapContext:**
|
|
89
101
|
|
|
90
102
|
| Field | Type | Description |
|
|
91
|
-
|
|
92
|
-
| `
|
|
93
|
-
| `
|
|
94
|
-
| `
|
|
95
|
-
|
|
103
|
+
|-------|------|-------------|
|
|
104
|
+
| `service` | `AgentBnBService` | Unified facade for all AgentBnB operations |
|
|
105
|
+
| `status` | `ServiceStatus` | Node status snapshot at activation time |
|
|
106
|
+
| `startDisposition` | `'started' \| 'already_running'` | Whether this call started a new node |
|
|
107
|
+
|
|
108
|
+
`AgentBnBService` exposes:
|
|
109
|
+
- `service.ensureRunning(opts?)` — re-enter running state (idempotent)
|
|
110
|
+
- `service.getNodeStatus()` — get current node status and relay state
|
|
111
|
+
- `service.healthCheck()` — verify AgentBnB service signature
|
|
112
|
+
- `service.stop()` — stop the node
|
|
113
|
+
- `service.discoverCapabilities(query)` — local-first capability search
|
|
114
|
+
- `service.rentCapability(params)` — requester-side capability execution
|
|
115
|
+
- `service.getBalance()` — credit balance query
|
|
116
|
+
|
|
117
|
+
**Signal handling:**
|
|
118
|
+
|
|
119
|
+
`activate()` registers `process.once('SIGTERM')` and `process.once('SIGINT')` handlers.
|
|
120
|
+
On signal, `service.stop()` is called only if `startDisposition === 'started'`.
|
|
121
|
+
No `process.exit()` is called — closing handles via `service.stop()` drains the event loop naturally.
|
|
96
122
|
|
|
97
123
|
### `deactivate(ctx: BootstrapContext): Promise<void>`
|
|
98
124
|
|
|
99
|
-
|
|
100
|
-
|
|
125
|
+
Removes signal handlers registered by `activate()`, then conditionally stops the node.
|
|
126
|
+
|
|
127
|
+
- If `ctx.startDisposition === 'started'`: stops the node.
|
|
128
|
+
- If `ctx.startDisposition === 'already_running'`: leaves the node running.
|
|
129
|
+
|
|
130
|
+
Idempotent — safe to call multiple times.
|
|
101
131
|
|
|
102
132
|
## Autonomy Rules
|
|
103
133
|
|
|
@@ -107,17 +137,14 @@ Full rules block is in `HEARTBEAT.rules.md`. Copy into your `HEARTBEAT.md`, or r
|
|
|
107
137
|
agentbnb openclaw rules
|
|
108
138
|
```
|
|
109
139
|
|
|
110
|
-
This outputs a rules block using your actual configured thresholds (not the example defaults).
|
|
111
|
-
|
|
112
140
|
**Summary of the 3 tiers:**
|
|
113
141
|
|
|
114
142
|
- **Tier 1** (< tier1 credits): Auto-execute, no notification.
|
|
115
143
|
- **Tier 2** (tier1–tier2 credits): Execute and notify owner after.
|
|
116
144
|
- **Tier 3** (> tier2 credits): Ask owner before executing. (Default on fresh installs.)
|
|
117
145
|
|
|
118
|
-
**Reserve floor:** Maintain a minimum credit balance (default 20). When balance ≤ reserve,
|
|
119
|
-
|
|
120
|
-
**Idle sharing:** When a skill's `idle_rate` exceeds 70%, `IdleMonitor` auto-shares it according to the active tier.
|
|
146
|
+
**Reserve floor:** Maintain a minimum credit balance (default 20). When balance ≤ reserve,
|
|
147
|
+
auto-request is blocked. Increase sharing priority to recover.
|
|
121
148
|
|
|
122
149
|
Configure thresholds:
|
|
123
150
|
|
|
@@ -130,7 +157,7 @@ agentbnb config set reserve 20 # keep 20 credit reserve
|
|
|
130
157
|
## CLI Reference
|
|
131
158
|
|
|
132
159
|
```bash
|
|
133
|
-
agentbnb serve # Start accepting incoming capability requests
|
|
160
|
+
agentbnb serve # Start accepting incoming capability requests (standalone, no OpenClaw)
|
|
134
161
|
agentbnb openclaw sync # Parse SOUL.md and publish capability card to registry
|
|
135
162
|
agentbnb openclaw status # Show sync state, credit balance, idle rates
|
|
136
163
|
agentbnb openclaw rules # Emit HEARTBEAT.md rules block with real thresholds
|
|
@@ -141,26 +168,16 @@ agentbnb discover # Find peers on the local network via mDNS
|
|
|
141
168
|
agentbnb request --query "..." # Manually request a capability from the network
|
|
142
169
|
```
|
|
143
170
|
|
|
171
|
+
> **Note:** When using OpenClaw, `activate()` handles node startup automatically.
|
|
172
|
+
> `agentbnb serve` is only needed when running AgentBnB as a standalone CLI process.
|
|
173
|
+
|
|
144
174
|
## Adapters
|
|
145
175
|
|
|
146
|
-
|
|
176
|
+
Individual adapters are available if you need custom wiring outside of `bootstrap.ts`.
|
|
147
177
|
|
|
148
178
|
| Adapter | Export | Purpose |
|
|
149
|
-
|
|
179
|
+
|---------|--------|---------|
|
|
150
180
|
| `gateway.ts` | `AgentRuntime`, `createGatewayServer` | HTTP gateway for receiving requests |
|
|
151
181
|
| `auto-share.ts` | `IdleMonitor` | Per-skill idle rate polling + auto-share |
|
|
152
182
|
| `auto-request.ts` | `AutoRequestor` | Peer scoring + budget-gated capability requests |
|
|
153
183
|
| `credit-mgr.ts` | `BudgetManager`, `getBalance` | Credit reserve floor + balance queries |
|
|
154
|
-
|
|
155
|
-
```typescript
|
|
156
|
-
// Example: use IdleMonitor directly without full bootstrap
|
|
157
|
-
import { IdleMonitor } from './auto-share.js';
|
|
158
|
-
|
|
159
|
-
const monitor = new IdleMonitor({
|
|
160
|
-
owner: 'my-agent',
|
|
161
|
-
db: runtime.registryDb,
|
|
162
|
-
autonomyConfig: config.autonomy,
|
|
163
|
-
});
|
|
164
|
-
const job = monitor.start();
|
|
165
|
-
runtime.registerJob(job);
|
|
166
|
-
```
|