agentbnb 5.1.1 → 5.1.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/dist/cli/index.js CHANGED
@@ -590,7 +590,10 @@ program.command("init").description("Initialize AgentBnB config and create agent
590
590
  credit_db_path: creditDbPath,
591
591
  token: existingConfig?.token ?? token,
592
592
  // Preserve existing token
593
- api_key: existingConfig?.api_key ?? randomBytes(32).toString("hex")
593
+ api_key: existingConfig?.api_key ?? randomBytes(32).toString("hex"),
594
+ // Default registry for fresh installs: auto-set in --yes (automated) mode only.
595
+ // Interactive init leaves registry unset so users can configure it explicitly.
596
+ ...existingConfig?.registry ? { registry: existingConfig.registry } : opts.yes ? { registry: "https://agentbnb.fly.dev" } : {}
594
597
  };
595
598
  saveConfig(config);
596
599
  let keypairStatus = "existing";
@@ -651,11 +654,11 @@ program.command("init").description("Initialize AgentBnB config and create agent
651
654
  bootstrapAgent(creditDb, owner, 100);
652
655
  creditDb.close();
653
656
  let registryBalance;
654
- if (existingConfig?.registry) {
657
+ if (config.registry) {
655
658
  try {
656
659
  const identityAuth = loadIdentityAuth(owner);
657
660
  const ledger = createLedger({
658
- registryUrl: existingConfig.registry,
661
+ registryUrl: config.registry,
659
662
  ownerPublicKey: identityAuth.publicKey,
660
663
  privateKey: identityAuth.privateKey
661
664
  });
@@ -1310,8 +1313,9 @@ Batch Results (${res.results.length} items):`);
1310
1313
  }
1311
1314
  }
1312
1315
  const useReceipt = isRemoteRequest && opts.receipt !== false;
1316
+ const isRelayOnly = isRemoteRequest && !gatewayUrl;
1313
1317
  const useRegistryLedger = isRemoteRequest && !!config.registry && !!gatewayUrl;
1314
- if (useReceipt && !opts.cost) {
1318
+ if (useReceipt && !opts.cost && !isRelayOnly) {
1315
1319
  console.error("Error: --cost <credits> is required for remote requests. Specify the credits to commit.");
1316
1320
  process.exit(1);
1317
1321
  }
@@ -67,6 +67,7 @@ import {
67
67
  // skills/agentbnb/bootstrap.ts
68
68
  import { join as join5 } from "path";
69
69
  import { homedir as homedir3 } from "os";
70
+ import { spawnSync } from "child_process";
70
71
 
71
72
  // src/runtime/process-guard.ts
72
73
  import { dirname, join } from "path";
@@ -6136,12 +6137,21 @@ function isNetworkError(err) {
6136
6137
 
6137
6138
  // skills/agentbnb/bootstrap.ts
6138
6139
  async function activate(config = {}) {
6139
- const agentConfig = loadConfig();
6140
+ let agentConfig = loadConfig();
6140
6141
  if (!agentConfig) {
6141
- throw new AgentBnBError(
6142
- "AgentBnB config not found. Run: agentbnb init",
6143
- "CONFIG_NOT_FOUND"
6144
- );
6142
+ const result = spawnSync("agentbnb", ["init", "--yes", "--no-detect"], {
6143
+ stdio: "pipe",
6144
+ env: { ...process.env },
6145
+ encoding: "utf-8"
6146
+ });
6147
+ if (result.error || result.status !== 0) {
6148
+ const msg = result.error?.message ?? result.stderr?.trim() ?? "agentbnb init failed";
6149
+ throw new AgentBnBError(`Auto-init failed: ${msg}`, "INIT_FAILED");
6150
+ }
6151
+ agentConfig = loadConfig();
6152
+ if (!agentConfig) {
6153
+ throw new AgentBnBError("AgentBnB config still not found after auto-init", "CONFIG_NOT_FOUND");
6154
+ }
6145
6155
  }
6146
6156
  const guard = new ProcessGuard(join5(homedir3(), ".agentbnb", ".pid"));
6147
6157
  const coordinator = new ServiceCoordinator(agentConfig, guard);
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "workspaces": [
4
4
  "packages/*"
5
5
  ],
6
- "version": "5.1.1",
6
+ "version": "5.1.2",
7
7
  "description": "P2P Agent Capability Sharing Protocol — Airbnb for AI agent pipelines",
8
8
  "type": "module",
9
9
  "main": "dist/index.js",
@@ -5,7 +5,7 @@ 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
6
  metadata:
7
7
  author: "Cheng Wen Chen"
8
- version: "5.1.0"
8
+ version: "5.1.2"
9
9
  tags: "ai-agent-skill,claude-code,agent-skills,p2p,capability-sharing"
10
10
  ---
11
11
 
@@ -165,12 +165,20 @@ agentbnb config set tier1 <N> # Set Tier 1 credit threshold
165
165
  agentbnb config set tier2 <N> # Set Tier 2 credit threshold
166
166
  agentbnb config set reserve <N> # Set minimum credit reserve floor
167
167
  agentbnb discover # Find peers on the local network via mDNS
168
- agentbnb request --query "..." # Manually request a capability from the network
168
+ agentbnb discover --registry # Search remote registry for capability cards
169
+ agentbnb request <cardId> --skill <skillId> --params '{"key":"val"}' --json
170
+ # Request a capability (relay-only: no --cost needed)
171
+ agentbnb request <cardId> --skill <skillId> --params '{"key":"val"}' --cost 5 --json
172
+ # Request a capability with direct HTTP escrow payment
169
173
  ```
170
174
 
171
175
  > **Note:** When using OpenClaw, `activate()` handles node startup automatically.
172
176
  > `agentbnb serve` is only needed when running AgentBnB as a standalone CLI process.
173
177
 
178
+ > **Multi-agent tip:** If multiple agents share the same machine, each agent should use its own
179
+ > config directory. Set `AGENTBNB_DIR=<path>` before any `agentbnb` CLI call, or pass it in
180
+ > the shell environment. Example: `AGENTBNB_DIR=~/.openclaw/agents/mybot/.agentbnb agentbnb status`
181
+
174
182
  ## Adapters
175
183
 
176
184
  Individual adapters are available if you need custom wiring outside of `bootstrap.ts`.
@@ -10,6 +10,7 @@
10
10
 
11
11
  import { join } from 'node:path';
12
12
  import { homedir } from 'node:os';
13
+ import { spawnSync } from 'node:child_process';
13
14
 
14
15
  import { loadConfig } from '../../src/cli/config.js';
15
16
  import { AgentBnBError } from '../../src/types/index.js';
@@ -48,18 +49,28 @@ export interface BootstrapContext {
48
49
  * Brings an AgentBnB node online (idempotent — safe to call when already running).
49
50
  * Registers SIGTERM/SIGINT handlers that conditionally stop the node on process exit.
50
51
  *
51
- * @throws {AgentBnBError} CONFIG_NOT_FOUND if ~/.agentbnb/config.json does not exist.
52
+ * @throws {AgentBnBError} INIT_FAILED if auto-init fails when no config exists.
52
53
  *
53
54
  * TODO: Once ServiceCoordinator gains its own signal handling, remove the handlers
54
55
  * registered here to avoid double-handler conflicts. Track in Layer A implementation.
55
56
  */
56
57
  export async function activate(config: BootstrapConfig = {}): Promise<BootstrapContext> {
57
- const agentConfig = loadConfig();
58
+ let agentConfig = loadConfig();
58
59
  if (!agentConfig) {
59
- throw new AgentBnBError(
60
- 'AgentBnB config not found. Run: agentbnb init',
61
- 'CONFIG_NOT_FOUND',
62
- );
60
+ // Auto-init for first-time OpenClaw plugin activation
61
+ const result = spawnSync('agentbnb', ['init', '--yes', '--no-detect'], {
62
+ stdio: 'pipe',
63
+ env: { ...process.env },
64
+ encoding: 'utf-8',
65
+ });
66
+ if (result.error || result.status !== 0) {
67
+ const msg = result.error?.message ?? (result.stderr as string | null)?.trim() ?? 'agentbnb init failed';
68
+ throw new AgentBnBError(`Auto-init failed: ${msg}`, 'INIT_FAILED');
69
+ }
70
+ agentConfig = loadConfig();
71
+ if (!agentConfig) {
72
+ throw new AgentBnBError('AgentBnB config still not found after auto-init', 'CONFIG_NOT_FOUND');
73
+ }
63
74
  }
64
75
 
65
76
  const guard = new ProcessGuard(join(homedir(), '.agentbnb', '.pid'));