agentbnb 8.3.1 → 8.3.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.
@@ -121,7 +121,7 @@ import { execFileSync } from "child_process";
121
121
  import { existsSync, realpathSync } from "fs";
122
122
  import { createRequire } from "module";
123
123
  import { homedir } from "os";
124
- import { basename, isAbsolute, join, resolve } from "path";
124
+ import { basename, dirname, isAbsolute, join, resolve } from "path";
125
125
  function resolveSelfCli() {
126
126
  const require2 = createRequire(import.meta.url);
127
127
  return resolveSelfCliWithDeps({
@@ -130,6 +130,7 @@ function resolveSelfCli() {
130
130
  platform: process.platform,
131
131
  homeDir: homedir(),
132
132
  envPath: process.env["PATH"],
133
+ nodeExecDir: dirname(process.execPath),
133
134
  exists: existsSync,
134
135
  realpath: realpathSync,
135
136
  runWhich: (pathEnv) => execFileSync("which", ["agentbnb"], {
@@ -155,7 +156,7 @@ function resolveSelfCliWithDeps(deps) {
155
156
  };
156
157
  const argvPath = tryCandidate(deps.argv1, "process.argv[1]", true);
157
158
  if (argvPath) return argvPath;
158
- const fullPathEnv = buildFullPathEnv(deps.envPath, deps.homeDir);
159
+ const fullPathEnv = buildFullPathEnv(deps.envPath, deps.homeDir, deps.nodeExecDir);
159
160
  tried.push(`which agentbnb PATH=${fullPathEnv}`);
160
161
  try {
161
162
  const whichPath = tryCandidate(deps.runWhich(fullPathEnv), "which agentbnb");
@@ -173,6 +174,13 @@ function resolveSelfCliWithDeps(deps) {
173
174
  const resolvedPath = tryCandidate(candidate, "pnpm-global");
174
175
  if (resolvedPath) return resolvedPath;
175
176
  }
177
+ if (deps.nodeExecDir) {
178
+ const execDirCandidate = tryCandidate(
179
+ join(deps.nodeExecDir, "agentbnb"),
180
+ "node-execpath-dir"
181
+ );
182
+ if (execDirCandidate) return execDirCandidate;
183
+ }
176
184
  try {
177
185
  const requireResolved = deps.requireResolve("agentbnb/dist/cli/index.js");
178
186
  const resolvedPath = tryCandidate(requireResolved, "require.resolve(agentbnb/dist/cli/index.js)");
@@ -187,7 +195,7 @@ ${tried.map((item) => `- ${item}`).join("\n")}`,
187
195
  "CLI_ENTRY_NOT_FOUND"
188
196
  );
189
197
  }
190
- function buildFullPathEnv(pathEnv, homeDir) {
198
+ function buildFullPathEnv(pathEnv, homeDir, nodeExecDir) {
191
199
  const values = /* @__PURE__ */ new Set();
192
200
  for (const item of (pathEnv ?? "").split(":")) {
193
201
  if (item.trim()) values.add(item.trim());
@@ -205,6 +213,9 @@ function buildFullPathEnv(pathEnv, homeDir) {
205
213
  ]) {
206
214
  values.add(extra);
207
215
  }
216
+ if (nodeExecDir) {
217
+ values.add(nodeExecDir);
218
+ }
208
219
  return [...values].join(":");
209
220
  }
210
221
  function safeRealpath(realpath, path) {
package/dist/cli/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  discoverLocalAgents,
8
8
  getPricingStats,
9
9
  resolveSelfCli
10
- } from "../chunk-O4Q7BRG6.js";
10
+ } from "../chunk-NHVHLUYS.js";
11
11
  import {
12
12
  createLedger,
13
13
  ensureIdentity,
@@ -839,27 +839,30 @@ function generateSkillsYaml(configDir) {
839
839
  }
840
840
  function registerMcpWithClaudeCode() {
841
841
  const claudeDir = join3(homedir(), ".claude");
842
- if (!existsSync3(claudeDir)) {
842
+ const claudeJsonPath = join3(homedir(), ".claude.json");
843
+ const legacySettingsPath = join3(claudeDir, "settings.json");
844
+ const useLegacy = !existsSync3(claudeJsonPath) && existsSync3(legacySettingsPath);
845
+ const targetPath = useLegacy ? legacySettingsPath : claudeJsonPath;
846
+ if (!existsSync3(claudeJsonPath) && !existsSync3(claudeDir)) {
843
847
  return {
844
848
  registered: false,
845
849
  reason: "Claude Code not detected. Add MCP manually: claude mcp add agentbnb -- agentbnb mcp-server"
846
850
  };
847
851
  }
848
- const settingsPath = join3(claudeDir, "settings.json");
849
852
  let agentbnbCommand;
850
853
  try {
851
854
  agentbnbCommand = resolveSelfCli();
852
855
  } catch (err) {
853
856
  const reason = err instanceof Error ? err.message : String(err);
854
- return { registered: false, path: settingsPath, reason: `MCP registration skipped: ${reason}` };
857
+ return { registered: false, path: targetPath, reason: `MCP registration skipped: ${reason}` };
855
858
  }
856
859
  let settings = {};
857
- if (existsSync3(settingsPath)) {
860
+ if (existsSync3(targetPath)) {
858
861
  try {
859
- settings = JSON.parse(readFileSync3(settingsPath, "utf-8"));
862
+ settings = JSON.parse(readFileSync3(targetPath, "utf-8"));
860
863
  } catch {
861
864
  try {
862
- writeFileSync2(`${settingsPath}.bak`, readFileSync3(settingsPath, "utf-8"), "utf-8");
865
+ writeFileSync2(`${targetPath}.bak`, readFileSync3(targetPath, "utf-8"), "utf-8");
863
866
  } catch {
864
867
  }
865
868
  settings = {};
@@ -870,15 +873,17 @@ function registerMcpWithClaudeCode() {
870
873
  const existingCommand = typeof existingEntry?.command === "string" ? existingEntry.command : void 0;
871
874
  const existingArgs = Array.isArray(existingEntry?.args) ? existingEntry.args : void 0;
872
875
  if (existingCommand === agentbnbCommand && existingArgs?.length === 1 && existingArgs[0] === "mcp-server") {
873
- return { registered: false, path: settingsPath, reason: "already registered" };
876
+ return { registered: false, path: targetPath, reason: "already registered" };
874
877
  }
875
878
  mcpServers.agentbnb = {
879
+ type: "stdio",
876
880
  command: agentbnbCommand,
877
- args: ["mcp-server"]
881
+ args: ["mcp-server"],
882
+ env: {}
878
883
  };
879
884
  settings.mcpServers = mcpServers;
880
- writeFileSync2(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
881
- return { registered: true, path: settingsPath };
885
+ writeFileSync2(targetPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
886
+ return { registered: true, path: targetPath };
882
887
  }
883
888
  async function runQuickstart(opts) {
884
889
  const jsonMode = opts.json ?? false;
@@ -920,7 +925,7 @@ Skills: ${skills.skillCount} skill(s) in ${skills.path}`);
920
925
  if (!skipServe) {
921
926
  try {
922
927
  const { ProcessGuard } = await import("../process-guard-TNSUNHSR.js");
923
- const { ServiceCoordinator } = await import("../service-coordinator-SCP2YIFT.js");
928
+ const { ServiceCoordinator } = await import("../service-coordinator-LZJCAQSJ.js");
924
929
  const guard = new ProcessGuard(join3(initResult.configDir, ".pid"));
925
930
  const coordinator = new ServiceCoordinator(initResult.config, guard);
926
931
  const result = await coordinator.ensureRunning({
@@ -982,7 +987,7 @@ Skills: ${skills.skillCount} skill(s) in ${skills.path}`);
982
987
  }
983
988
 
984
989
  // src/cli/index.ts
985
- var VERSION = true ? "8.3.1" : "0.0.0-dev";
990
+ var VERSION = true ? "8.3.2" : "0.0.0-dev";
986
991
  function loadIdentityAuth2(owner) {
987
992
  const configDir = getConfigDir();
988
993
  let keys;
@@ -1717,6 +1722,12 @@ program.command("status").description("Show credit balance and recent transactio
1717
1722
  balance = await statusLedger.getBalance(config.owner);
1718
1723
  transactions = await statusLedger.getHistory(config.owner, 5);
1719
1724
  heldEscrows = creditDb.prepare("SELECT id, amount, card_id, created_at FROM credit_escrow WHERE owner = ? AND status = ?").all(config.owner, "held");
1725
+ } catch (err) {
1726
+ balance = 0;
1727
+ transactions = [];
1728
+ heldEscrows = [];
1729
+ const msg = err instanceof Error ? err.message : String(err);
1730
+ console.warn(`Note: could not fetch balance from registry (${msg}). Run \`agentbnb init\` if this is a new agent.`);
1720
1731
  } finally {
1721
1732
  creditDb.close();
1722
1733
  }
@@ -1759,7 +1770,7 @@ program.command("serve").description("Start the AgentBnB gateway server").option
1759
1770
  process.exit(1);
1760
1771
  }
1761
1772
  const { ProcessGuard } = await import("../process-guard-TNSUNHSR.js");
1762
- const { ServiceCoordinator } = await import("../service-coordinator-SCP2YIFT.js");
1773
+ const { ServiceCoordinator } = await import("../service-coordinator-LZJCAQSJ.js");
1763
1774
  const port = opts.port ? parseInt(opts.port, 10) : config.gateway_port;
1764
1775
  const registryPort = parseInt(opts.registryPort, 10);
1765
1776
  if (!Number.isFinite(port) || !Number.isFinite(registryPort)) {
@@ -2245,7 +2256,7 @@ Feedback for skill: ${opts.skill} (${feedbacks.length} entries)
2245
2256
  });
2246
2257
  program.command("quickstart").alias("qs").description("One-command setup: init + skills.yaml + MCP registration + serve daemon").option("--owner <name>", "Agent owner name").option("--port <port>", "Gateway port", "7700").option("--no-serve", "Skip starting background daemon").option("--no-mcp", "Skip MCP registration with Claude Code").option("--json", "Output as JSON").action(runQuickstart);
2247
2258
  program.command("mcp-server").description("Start an MCP (Model Context Protocol) server for IDE integration").action(async () => {
2248
- const { startMcpServer } = await import("../server-YVLMQ2BO.js");
2259
+ const { startMcpServer } = await import("../server-6I7GU2OZ.js");
2249
2260
  await startMcpServer();
2250
2261
  });
2251
2262
  await program.parseAsync(process.argv);
@@ -248,7 +248,7 @@ function registerPublishTool(server, ctx) {
248
248
  }
249
249
 
250
250
  // src/mcp/server.ts
251
- var VERSION = true ? "8.3.1" : "0.0.0-dev";
251
+ var VERSION = true ? "8.3.2" : "0.0.0-dev";
252
252
  async function startMcpServer() {
253
253
  const config = loadConfig();
254
254
  if (!config) {
@@ -16,7 +16,7 @@ import {
16
16
  getPricingStats,
17
17
  resolveSelfCli,
18
18
  stopAnnouncement
19
- } from "./chunk-O4Q7BRG6.js";
19
+ } from "./chunk-NHVHLUYS.js";
20
20
  import {
21
21
  createLedger,
22
22
  deriveAgentId,
@@ -90,7 +90,7 @@ import {
90
90
  } from "../../chunk-I7KWA7OB.js";
91
91
 
92
92
  // skills/agentbnb/bootstrap.ts
93
- import { join as join7, basename as basename2, dirname as dirname3 } from "path";
93
+ import { join as join7, basename as basename2, dirname as dirname4 } from "path";
94
94
  import { homedir as homedir4 } from "os";
95
95
  import { exec } from "child_process";
96
96
  import { promisify as promisify2 } from "util";
@@ -6289,7 +6289,7 @@ import { execFileSync as execFileSync2 } from "child_process";
6289
6289
  import { existsSync as existsSync5, realpathSync } from "fs";
6290
6290
  import { createRequire } from "module";
6291
6291
  import { homedir as homedir2 } from "os";
6292
- import { basename, isAbsolute, join as join4, resolve } from "path";
6292
+ import { basename, dirname as dirname3, isAbsolute, join as join4, resolve } from "path";
6293
6293
  function resolveSelfCli() {
6294
6294
  const require2 = createRequire(import.meta.url);
6295
6295
  return resolveSelfCliWithDeps({
@@ -6298,6 +6298,7 @@ function resolveSelfCli() {
6298
6298
  platform: process.platform,
6299
6299
  homeDir: homedir2(),
6300
6300
  envPath: process.env["PATH"],
6301
+ nodeExecDir: dirname3(process.execPath),
6301
6302
  exists: existsSync5,
6302
6303
  realpath: realpathSync,
6303
6304
  runWhich: (pathEnv) => execFileSync2("which", ["agentbnb"], {
@@ -6323,7 +6324,7 @@ function resolveSelfCliWithDeps(deps) {
6323
6324
  };
6324
6325
  const argvPath = tryCandidate(deps.argv1, "process.argv[1]", true);
6325
6326
  if (argvPath) return argvPath;
6326
- const fullPathEnv = buildFullPathEnv(deps.envPath, deps.homeDir);
6327
+ const fullPathEnv = buildFullPathEnv(deps.envPath, deps.homeDir, deps.nodeExecDir);
6327
6328
  tried.push(`which agentbnb PATH=${fullPathEnv}`);
6328
6329
  try {
6329
6330
  const whichPath = tryCandidate(deps.runWhich(fullPathEnv), "which agentbnb");
@@ -6341,6 +6342,13 @@ function resolveSelfCliWithDeps(deps) {
6341
6342
  const resolvedPath = tryCandidate(candidate, "pnpm-global");
6342
6343
  if (resolvedPath) return resolvedPath;
6343
6344
  }
6345
+ if (deps.nodeExecDir) {
6346
+ const execDirCandidate = tryCandidate(
6347
+ join4(deps.nodeExecDir, "agentbnb"),
6348
+ "node-execpath-dir"
6349
+ );
6350
+ if (execDirCandidate) return execDirCandidate;
6351
+ }
6344
6352
  try {
6345
6353
  const requireResolved = deps.requireResolve("agentbnb/dist/cli/index.js");
6346
6354
  const resolvedPath = tryCandidate(requireResolved, "require.resolve(agentbnb/dist/cli/index.js)");
@@ -6355,7 +6363,7 @@ ${tried.map((item) => `- ${item}`).join("\n")}`,
6355
6363
  "CLI_ENTRY_NOT_FOUND"
6356
6364
  );
6357
6365
  }
6358
- function buildFullPathEnv(pathEnv, homeDir) {
6366
+ function buildFullPathEnv(pathEnv, homeDir, nodeExecDir) {
6359
6367
  const values = /* @__PURE__ */ new Set();
6360
6368
  for (const item of (pathEnv ?? "").split(":")) {
6361
6369
  if (item.trim()) values.add(item.trim());
@@ -6373,6 +6381,9 @@ function buildFullPathEnv(pathEnv, homeDir) {
6373
6381
  ]) {
6374
6382
  values.add(extra);
6375
6383
  }
6384
+ if (nodeExecDir) {
6385
+ values.add(nodeExecDir);
6386
+ }
6376
6387
  return [...values].join(":");
6377
6388
  }
6378
6389
  function safeRealpath(realpath, path) {
@@ -8141,7 +8152,7 @@ async function runCommand(cmd, env) {
8141
8152
  return execAsync(cmd, { env });
8142
8153
  }
8143
8154
  function deriveAgentName(configDir) {
8144
- const parent = basename2(dirname3(configDir));
8155
+ const parent = basename2(dirname4(configDir));
8145
8156
  if (parent && parent !== "." && parent !== ".agentbnb" && parent !== homedir4().split("/").pop()) {
8146
8157
  return parent;
8147
8158
  }
@@ -8188,31 +8199,26 @@ function quoteShellArg(input) {
8188
8199
  return `'${input.replace(/'/g, `'\\''`)}'`;
8189
8200
  }
8190
8201
  async function activate(config = {}, _onboardDeps) {
8202
+ const debug = process.env["AGENTBNB_DEBUG"] === "1";
8191
8203
  if (config.agentDir) {
8192
8204
  process.env["AGENTBNB_DIR"] = config.agentDir;
8193
- process.stderr.write(
8194
- `[agentbnb] AGENTBNB_DIR set from config.agentDir: ${config.agentDir}
8195
- `
8196
- );
8205
+ if (debug) process.stderr.write(`[agentbnb] AGENTBNB_DIR set from config.agentDir: ${config.agentDir}
8206
+ `);
8197
8207
  } else if (config.workspaceDir) {
8198
8208
  const derived = join7(config.workspaceDir, ".agentbnb");
8199
8209
  process.env["AGENTBNB_DIR"] = derived;
8200
- process.stderr.write(
8201
- `[agentbnb] AGENTBNB_DIR derived from config.workspaceDir: ${derived}
8202
- `
8203
- );
8210
+ if (debug) process.stderr.write(`[agentbnb] AGENTBNB_DIR derived from config.workspaceDir: ${derived}
8211
+ `);
8204
8212
  } else if (!process.env["AGENTBNB_DIR"]) {
8205
8213
  const workspaceDir = resolveWorkspaceDir();
8206
8214
  process.env["AGENTBNB_DIR"] = workspaceDir;
8207
- process.stderr.write(
8208
- `[agentbnb] AGENTBNB_DIR auto-configured to ${workspaceDir} for workspace isolation.
8209
- `
8210
- );
8215
+ if (debug) process.stderr.write(`[agentbnb] AGENTBNB_DIR auto-configured to ${workspaceDir}
8216
+ `);
8211
8217
  }
8212
8218
  const configDir = getConfigDir();
8213
8219
  if (process.env["AGENTBNB_DIR"] !== configDir) {
8214
8220
  process.stderr.write(
8215
- `[agentbnb] WARNING: AGENTBNB_DIR (${process.env["AGENTBNB_DIR"]}) differs from resolved configDir (${configDir}).
8221
+ `[agentbnb] config dir mismatch: env=${process.env["AGENTBNB_DIR"]} resolved=${configDir}
8216
8222
  `
8217
8223
  );
8218
8224
  }
@@ -8220,10 +8226,12 @@ async function activate(config = {}, _onboardDeps) {
8220
8226
  if (!agentConfig) {
8221
8227
  agentConfig = await autoOnboard(configDir, _onboardDeps);
8222
8228
  }
8223
- process.stderr.write(
8224
- `[agentbnb] activate: owner=${agentConfig.owner} config=${configDir}/config.json
8229
+ if (debug) {
8230
+ process.stderr.write(
8231
+ `[agentbnb] activate: owner=${agentConfig.owner} config=${configDir}/config.json
8225
8232
  `
8226
- );
8233
+ );
8234
+ }
8227
8235
  const guard = new ProcessGuard(join7(configDir, ".pid"));
8228
8236
  const coordinator = new ServiceCoordinator(agentConfig, guard);
8229
8237
  const service = new AgentBnBService(coordinator, agentConfig);
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "workspaces": [
4
4
  "packages/*"
5
5
  ],
6
- "version": "8.3.1",
6
+ "version": "8.3.2",
7
7
  "description": "P2P Agent Capability Sharing Protocol — Airbnb for AI agent pipelines",
8
8
  "type": "module",
9
9
  "main": "dist/index.js",
@@ -294,32 +294,29 @@ function quoteShellArg(input: string): string {
294
294
  * registered here to avoid double-handler conflicts. Track in Layer A implementation.
295
295
  */
296
296
  export async function activate(config: BootstrapConfig = {}, _onboardDeps?: OnboardDeps): Promise<BootstrapContext> {
297
+ const debug = process.env['AGENTBNB_DEBUG'] === '1';
298
+
297
299
  // Per-workspace isolation: determine the correct config directory.
298
300
  // Priority: config.agentDir > config.workspaceDir/.agentbnb > AGENTBNB_DIR env > resolveWorkspaceDir()
299
301
  if (config.agentDir) {
300
302
  process.env['AGENTBNB_DIR'] = config.agentDir;
301
- process.stderr.write(
302
- `[agentbnb] AGENTBNB_DIR set from config.agentDir: ${config.agentDir}\n`
303
- );
303
+ if (debug) process.stderr.write(`[agentbnb] AGENTBNB_DIR set from config.agentDir: ${config.agentDir}\n`);
304
304
  } else if (config.workspaceDir) {
305
305
  const derived = join(config.workspaceDir, '.agentbnb');
306
306
  process.env['AGENTBNB_DIR'] = derived;
307
- process.stderr.write(
308
- `[agentbnb] AGENTBNB_DIR derived from config.workspaceDir: ${derived}\n`
309
- );
307
+ if (debug) process.stderr.write(`[agentbnb] AGENTBNB_DIR derived from config.workspaceDir: ${derived}\n`);
310
308
  } else if (!process.env['AGENTBNB_DIR']) {
311
309
  const workspaceDir = resolveWorkspaceDir();
312
310
  process.env['AGENTBNB_DIR'] = workspaceDir;
313
- process.stderr.write(
314
- `[agentbnb] AGENTBNB_DIR auto-configured to ${workspaceDir} for workspace isolation.\n`
315
- );
311
+ if (debug) process.stderr.write(`[agentbnb] AGENTBNB_DIR auto-configured to ${workspaceDir}\n`);
316
312
  }
317
313
 
318
314
  const configDir = getConfigDir();
319
315
 
320
316
  if (process.env['AGENTBNB_DIR'] !== configDir) {
317
+ // Unexpected: env was just set above, so this indicates a resolution conflict.
321
318
  process.stderr.write(
322
- `[agentbnb] WARNING: AGENTBNB_DIR (${process.env['AGENTBNB_DIR']}) differs from resolved configDir (${configDir}).\n`
319
+ `[agentbnb] config dir mismatch: env=${process.env['AGENTBNB_DIR']} resolved=${configDir}\n`
323
320
  );
324
321
  }
325
322
 
@@ -329,10 +326,12 @@ export async function activate(config: BootstrapConfig = {}, _onboardDeps?: Onbo
329
326
  agentConfig = await autoOnboard(configDir, _onboardDeps);
330
327
  }
331
328
 
332
- // Print startup diagnostic so it's always visible in agent logs.
333
- process.stderr.write(
334
- `[agentbnb] activate: owner=${agentConfig.owner} config=${configDir}/config.json\n`
335
- );
329
+ // Startup diagnostic only emit when debug mode is on or first-time setup.
330
+ if (debug) {
331
+ process.stderr.write(
332
+ `[agentbnb] activate: owner=${agentConfig.owner} config=${configDir}/config.json\n`
333
+ );
334
+ }
336
335
 
337
336
  // Use configDir for PID file — previously hardcoded to homedir()/.agentbnb which meant
338
337
  // multiple agents on the same machine would fight over the same PID file.