agentbnb 5.1.4 → 5.1.6

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.
@@ -601,6 +601,15 @@ async function executeCapabilityRequest(opts) {
601
601
  if (!card) {
602
602
  return { success: false, error: { code: -32602, message: `Card not found: ${cardId}` } };
603
603
  }
604
+ if (requester === card.owner && !relayAuthorized) {
605
+ return {
606
+ success: false,
607
+ error: {
608
+ code: -32603,
609
+ message: `Self-request blocked: requester (${requester}) is the card owner. Set AGENTBNB_DIR to your agent's config directory before calling agentbnb request.`
610
+ }
611
+ };
612
+ }
604
613
  let creditsNeeded;
605
614
  let cardName;
606
615
  let resolvedSkillId;
@@ -40,6 +40,15 @@ async function executeCapabilityRequest(opts) {
40
40
  if (!card) {
41
41
  return { success: false, error: { code: -32602, message: `Card not found: ${cardId}` } };
42
42
  }
43
+ if (requester === card.owner && !relayAuthorized) {
44
+ return {
45
+ success: false,
46
+ error: {
47
+ code: -32603,
48
+ message: `Self-request blocked: requester (${requester}) is the card owner. Set AGENTBNB_DIR to your agent's config directory before calling agentbnb request.`
49
+ }
50
+ };
51
+ }
43
52
  let creditsNeeded;
44
53
  let cardName;
45
54
  let resolvedSkillId;
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`);
@@ -1560,7 +1559,7 @@ program.command("serve").description("Start the AgentBnB gateway server").option
1560
1559
  process.exit(1);
1561
1560
  }
1562
1561
  const { ProcessGuard } = await import("../process-guard-CC7CNRQJ.js");
1563
- const { ServiceCoordinator } = await import("../service-coordinator-UTKI4FRI.js");
1562
+ const { ServiceCoordinator } = await import("../service-coordinator-JB6VM6SF.js");
1564
1563
  const port = opts.port ? parseInt(opts.port, 10) : config.gateway_port;
1565
1564
  const registryPort = parseInt(opts.registryPort, 10);
1566
1565
  if (!Number.isFinite(port) || !Number.isFinite(registryPort)) {
@@ -1929,7 +1928,7 @@ Feedback for skill: ${opts.skill} (${feedbacks.length} entries)
1929
1928
  }
1930
1929
  });
1931
1930
  program.command("mcp-server").description("Start an MCP (Model Context Protocol) server for IDE integration").action(async () => {
1932
- const { startMcpServer } = await import("../server-HKJJWFRG.js");
1931
+ const { startMcpServer } = await import("../server-RKVZ4HXC.js");
1933
1932
  await startMcpServer();
1934
1933
  });
1935
1934
  await program.parseAsync(process.argv);
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  executeCapabilityBatch,
3
3
  executeCapabilityRequest
4
- } from "./chunk-LCAIAAG2.js";
4
+ } from "./chunk-DC5AC6UA.js";
5
5
  import "./chunk-CRFCWD6V.js";
6
6
  import "./chunk-WGZ5AGOX.js";
7
7
  export {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  executeCapabilityBatch,
3
3
  executeCapabilityRequest
4
- } from "./chunk-W5BZMKMF.js";
4
+ } from "./chunk-ZZVFYYUA.js";
5
5
  import "./chunk-UKT6H7YT.js";
6
6
  import "./chunk-DFBX3BBD.js";
7
7
  import "./chunk-EANI2N2V.js";
package/dist/index.js CHANGED
@@ -946,6 +946,15 @@ async function executeCapabilityRequest(opts) {
946
946
  if (!card) {
947
947
  return { success: false, error: { code: -32602, message: `Card not found: ${cardId}` } };
948
948
  }
949
+ if (requester === card.owner && !relayAuthorized) {
950
+ return {
951
+ success: false,
952
+ error: {
953
+ code: -32603,
954
+ message: `Self-request blocked: requester (${requester}) is the card owner. Set AGENTBNB_DIR to your agent's config directory before calling agentbnb request.`
955
+ }
956
+ };
957
+ }
949
958
  let creditsNeeded;
950
959
  let cardName;
951
960
  let resolvedSkillId;
@@ -4,7 +4,7 @@ import {
4
4
  import "./chunk-QT7TEVNV.js";
5
5
  import {
6
6
  executeCapabilityRequest
7
- } from "./chunk-W5BZMKMF.js";
7
+ } from "./chunk-ZZVFYYUA.js";
8
8
  import "./chunk-UKT6H7YT.js";
9
9
  import {
10
10
  listCards,
@@ -277,7 +277,7 @@ async function startMcpServer() {
277
277
  registerPublishTool(server, ctx);
278
278
  const { registerRequestTool } = await import("./request-YOWPXVLQ.js");
279
279
  const { registerConductTool } = await import("./conduct-KM6ZNJGE.js");
280
- const { registerServeSkillTool } = await import("./serve-skill-JHFNR7BW.js");
280
+ const { registerServeSkillTool } = await import("./serve-skill-EZSFLMAM.js");
281
281
  registerRequestTool(server, ctx);
282
282
  registerConductTool(server, ctx);
283
283
  registerServeSkillTool(server, ctx);
@@ -41,7 +41,7 @@ import {
41
41
  import {
42
42
  executeCapabilityBatch,
43
43
  executeCapabilityRequest
44
- } from "./chunk-W5BZMKMF.js";
44
+ } from "./chunk-ZZVFYYUA.js";
45
45
  import "./chunk-UKT6H7YT.js";
46
46
  import {
47
47
  getActivityFeed,
@@ -4593,7 +4593,7 @@ var ServiceCoordinator = class {
4593
4593
  }
4594
4594
  if (opts.registryUrl && opts.relay) {
4595
4595
  const { RelayClient } = await import("./websocket-client-6IIDGXKB.js");
4596
- const { executeCapabilityRequest: executeCapabilityRequest2 } = await import("./execute-CPFSOOO3.js");
4596
+ const { executeCapabilityRequest: executeCapabilityRequest2 } = await import("./execute-RKBWFIDK.js");
4597
4597
  const cards = listCards(this.runtime.registryDb, this.config.owner);
4598
4598
  const card = cards[0] ?? {
4599
4599
  id: randomUUID5(),
@@ -36,7 +36,7 @@ import {
36
36
  updateCard,
37
37
  updateSkillAvailability,
38
38
  updateSkillIdleRate
39
- } from "../../chunk-LCAIAAG2.js";
39
+ } from "../../chunk-DC5AC6UA.js";
40
40
  import {
41
41
  bootstrapAgent,
42
42
  generateKeyPair,
@@ -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
@@ -5432,7 +5431,7 @@ var ServiceCoordinator = class {
5432
5431
  }
5433
5432
  if (opts.registryUrl && opts.relay) {
5434
5433
  const { RelayClient: RelayClient2 } = await import("../../websocket-client-WRN3HO73.js");
5435
- const { executeCapabilityRequest: executeCapabilityRequest2 } = await import("../../execute-IP2QHALV.js");
5434
+ const { executeCapabilityRequest: executeCapabilityRequest2 } = await import("../../execute-BH7A37T4.js");
5436
5435
  const cards = listCards(this.runtime.registryDb, this.config.owner);
5437
5436
  const card = cards[0] ?? {
5438
5437
  id: randomUUID6(),
@@ -6137,6 +6136,19 @@ 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.env["AGENTBNB_DIR"] = configDir;
6142
+ process.stderr.write(
6143
+ `[agentbnb] AGENTBNB_DIR not set \u2014 auto-configured to ${configDir} for child process isolation.
6144
+ `
6145
+ );
6146
+ } else if (process.env["AGENTBNB_DIR"] !== configDir) {
6147
+ process.stderr.write(
6148
+ `[agentbnb] WARNING: AGENTBNB_DIR (${process.env["AGENTBNB_DIR"]}) differs from resolved configDir (${configDir}).
6149
+ `
6150
+ );
6151
+ }
6140
6152
  let agentConfig = loadConfig();
6141
6153
  if (!agentConfig) {
6142
6154
  const result = spawnSync("agentbnb", ["init", "--yes", "--no-detect"], {
@@ -6153,7 +6165,11 @@ async function activate(config = {}) {
6153
6165
  throw new AgentBnBError("AgentBnB config still not found after auto-init", "CONFIG_NOT_FOUND");
6154
6166
  }
6155
6167
  }
6156
- const guard = new ProcessGuard(join5(homedir3(), ".agentbnb", ".pid"));
6168
+ process.stderr.write(
6169
+ `[agentbnb] activate: owner=${agentConfig.owner} config=${configDir}/config.json
6170
+ `
6171
+ );
6172
+ const guard = new ProcessGuard(join5(configDir, ".pid"));
6157
6173
  const coordinator = new ServiceCoordinator(agentConfig, guard);
6158
6174
  const service = new AgentBnBService(coordinator, agentConfig);
6159
6175
  const opts = {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "workspaces": [
4
4
  "packages/*"
5
5
  ],
6
- "version": "5.1.4",
6
+ "version": "5.1.6",
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.4"
8
+ version: "5.1.6"
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,22 @@ 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: each agent must have its own data directory.
60
+ // If AGENTBNB_DIR is not set, auto-set it from configDir so all child processes
61
+ // spawned by this OpenClaw session (e.g. `agentbnb request` CLI calls) inherit it.
62
+ if (!process.env['AGENTBNB_DIR']) {
63
+ process.env['AGENTBNB_DIR'] = configDir;
64
+ process.stderr.write(
65
+ `[agentbnb] AGENTBNB_DIR not set — auto-configured to ${configDir} for child process isolation.\n`
66
+ );
67
+ } else if (process.env['AGENTBNB_DIR'] !== configDir) {
68
+ process.stderr.write(
69
+ `[agentbnb] WARNING: AGENTBNB_DIR (${process.env['AGENTBNB_DIR']}) differs from resolved configDir (${configDir}).\n`
70
+ );
71
+ }
72
+
58
73
  let agentConfig = loadConfig();
59
74
  if (!agentConfig) {
60
75
  // Auto-init for first-time OpenClaw plugin activation
@@ -73,7 +88,14 @@ export async function activate(config: BootstrapConfig = {}): Promise<BootstrapC
73
88
  }
74
89
  }
75
90
 
76
- const guard = new ProcessGuard(join(homedir(), '.agentbnb', '.pid'));
91
+ // Print startup diagnostic so it's always visible in agent logs.
92
+ process.stderr.write(
93
+ `[agentbnb] activate: owner=${agentConfig.owner} config=${configDir}/config.json\n`
94
+ );
95
+
96
+ // Use configDir for PID file — previously hardcoded to homedir()/.agentbnb which meant
97
+ // multiple agents on the same machine would fight over the same PID file.
98
+ const guard = new ProcessGuard(join(configDir, '.pid'));
77
99
  const coordinator = new ServiceCoordinator(agentConfig, guard);
78
100
  const service = new AgentBnBService(coordinator, agentConfig);
79
101