agentbnb 5.1.3 → 5.1.5

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
@@ -572,14 +572,13 @@ function getLanIp() {
572
572
  var program = new Command();
573
573
  program.name("agentbnb").description("P2P Agent Capability Sharing Protocol \u2014 Airbnb for AI agent pipelines").version(pkg.version);
574
574
  program.command("init").description("Initialize AgentBnB config and create agent identity").option("--owner <name>", "Agent owner name").option("--port <port>", "Gateway port", "7700").option("--host <ip>", "Override gateway host IP (default: auto-detected LAN IP)").option("--yes", "Auto-confirm all draft cards (non-interactive)").option("--no-detect", "Skip API key detection").option("--from <file>", "Parse a specific file for capability detection").option("--json", "Output as JSON").action(async (opts) => {
575
- const owner = opts.owner ?? `agent-${randomBytes(4).toString("hex")}`;
576
- const token = randomBytes(32).toString("hex");
577
575
  const configDir = getConfigDir();
578
576
  const dbPath = join2(configDir, "registry.db");
579
577
  const creditDbPath = join2(configDir, "credit.db");
580
578
  const port = parseInt(opts.port, 10);
581
579
  const ip = opts.host ?? getLanIp();
582
580
  const existingConfig = loadConfig();
581
+ const owner = opts.owner ?? existingConfig?.owner ?? `agent-${randomBytes(4).toString("hex")}`;
583
582
  const config = {
584
583
  ...existingConfig,
585
584
  // Preserve all existing keys (registry, autonomy, budget, etc.)
@@ -588,7 +587,7 @@ program.command("init").description("Initialize AgentBnB config and create agent
588
587
  gateway_port: port,
589
588
  db_path: dbPath,
590
589
  credit_db_path: creditDbPath,
591
- token: existingConfig?.token ?? token,
590
+ token: existingConfig?.token ?? randomBytes(32).toString("hex"),
592
591
  // Preserve existing token
593
592
  api_key: existingConfig?.api_key ?? randomBytes(32).toString("hex"),
594
593
  // Default registry for fresh installs: auto-set in --yes (automated) mode only.
@@ -808,7 +807,7 @@ Publish these ${card.skills.length} capabilities? [y/N] `);
808
807
  success: true,
809
808
  owner,
810
809
  config_dir: configDir,
811
- token,
810
+ token: config.token,
812
811
  gateway_url: config.gateway_url,
813
812
  keypair: keypairStatus,
814
813
  agent_id: identity.agent_id
@@ -824,7 +823,7 @@ Publish these ${card.skills.length} capabilities? [y/N] `);
824
823
  } else {
825
824
  console.log(`AgentBnB initialized.`);
826
825
  console.log(` Owner: ${owner}`);
827
- console.log(` Token: ${token}`);
826
+ console.log(` Token: ${config.token}`);
828
827
  console.log(` Config: ${configDir}/config.json`);
829
828
  if (registryBalance !== void 0) {
830
829
  console.log(` Registry balance: ${registryBalance} credits`);
@@ -1470,7 +1469,7 @@ Batch Results (${res.results.length} items):`);
1470
1469
  params: {
1471
1470
  ...params,
1472
1471
  ...opts.skill ? { skill_id: opts.skill } : {},
1473
- ...isRemoteRequest ? { requester: config.owner } : {}
1472
+ requester: config.owner
1474
1473
  },
1475
1474
  escrowReceipt,
1476
1475
  identity: identityAuth
@@ -66,7 +66,6 @@ import {
66
66
 
67
67
  // skills/agentbnb/bootstrap.ts
68
68
  import { join as join5 } from "path";
69
- import { homedir as homedir3 } from "os";
70
69
  import { spawnSync } from "child_process";
71
70
 
72
71
  // src/runtime/process-guard.ts
@@ -6137,6 +6136,12 @@ function isNetworkError(err) {
6137
6136
 
6138
6137
  // skills/agentbnb/bootstrap.ts
6139
6138
  async function activate(config = {}) {
6139
+ const configDir = getConfigDir();
6140
+ if (!process.env["AGENTBNB_DIR"]) {
6141
+ process.stderr.write(
6142
+ "[agentbnb] WARNING: AGENTBNB_DIR is not set. Using shared ~/.agentbnb \u2014 multiple agents on the same machine will overwrite each other's owner and credits. Set AGENTBNB_DIR=~/.agentbnb/<agent-name> for per-agent isolation.\n"
6143
+ );
6144
+ }
6140
6145
  let agentConfig = loadConfig();
6141
6146
  if (!agentConfig) {
6142
6147
  const result = spawnSync("agentbnb", ["init", "--yes", "--no-detect"], {
@@ -6153,7 +6158,11 @@ async function activate(config = {}) {
6153
6158
  throw new AgentBnBError("AgentBnB config still not found after auto-init", "CONFIG_NOT_FOUND");
6154
6159
  }
6155
6160
  }
6156
- const guard = new ProcessGuard(join5(homedir3(), ".agentbnb", ".pid"));
6161
+ process.stderr.write(
6162
+ `[agentbnb] activate: owner=${agentConfig.owner} config=${configDir}/config.json
6163
+ `
6164
+ );
6165
+ const guard = new ProcessGuard(join5(configDir, ".pid"));
6157
6166
  const coordinator = new ServiceCoordinator(agentConfig, guard);
6158
6167
  const service = new AgentBnBService(coordinator, agentConfig);
6159
6168
  const opts = {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "workspaces": [
4
4
  "packages/*"
5
5
  ],
6
- "version": "5.1.3",
6
+ "version": "5.1.5",
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.3"
8
+ version: "5.1.5"
9
9
  tags: "ai-agent-skill,claude-code,agent-skills,p2p,capability-sharing"
10
10
  ---
11
11
 
@@ -9,10 +9,9 @@
9
9
  */
10
10
 
11
11
  import { join } from 'node:path';
12
- import { homedir } from 'node:os';
13
12
  import { spawnSync } from 'node:child_process';
14
13
 
15
- import { loadConfig } from '../../src/cli/config.js';
14
+ import { getConfigDir, loadConfig } from '../../src/cli/config.js';
16
15
  import { AgentBnBError } from '../../src/types/index.js';
17
16
  import { ProcessGuard } from '../../src/runtime/process-guard.js';
18
17
  import { ServiceCoordinator } from '../../src/runtime/service-coordinator.js';
@@ -55,6 +54,19 @@ export interface BootstrapContext {
55
54
  * registered here to avoid double-handler conflicts. Track in Layer A implementation.
56
55
  */
57
56
  export async function activate(config: BootstrapConfig = {}): Promise<BootstrapContext> {
57
+ const configDir = getConfigDir();
58
+
59
+ // Isolation warning: each agent should have its own data directory.
60
+ // Without AGENTBNB_DIR, multiple agents share ~/.agentbnb and pollute each other's
61
+ // owner / identity / registry / credit state.
62
+ if (!process.env['AGENTBNB_DIR']) {
63
+ process.stderr.write(
64
+ '[agentbnb] WARNING: AGENTBNB_DIR is not set. Using shared ~/.agentbnb — ' +
65
+ 'multiple agents on the same machine will overwrite each other\'s owner and credits. ' +
66
+ 'Set AGENTBNB_DIR=~/.agentbnb/<agent-name> for per-agent isolation.\n'
67
+ );
68
+ }
69
+
58
70
  let agentConfig = loadConfig();
59
71
  if (!agentConfig) {
60
72
  // Auto-init for first-time OpenClaw plugin activation
@@ -73,7 +85,14 @@ export async function activate(config: BootstrapConfig = {}): Promise<BootstrapC
73
85
  }
74
86
  }
75
87
 
76
- const guard = new ProcessGuard(join(homedir(), '.agentbnb', '.pid'));
88
+ // Print startup diagnostic so it's always visible in agent logs.
89
+ process.stderr.write(
90
+ `[agentbnb] activate: owner=${agentConfig.owner} config=${configDir}/config.json\n`
91
+ );
92
+
93
+ // Use configDir for PID file — previously hardcoded to homedir()/.agentbnb which meant
94
+ // multiple agents on the same machine would fight over the same PID file.
95
+ const guard = new ProcessGuard(join(configDir, '.pid'));
77
96
  const coordinator = new ServiceCoordinator(agentConfig, guard);
78
97
  const service = new AgentBnBService(coordinator, agentConfig);
79
98