agentbnb 8.2.0 → 8.2.1

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.
Files changed (38) hide show
  1. package/dist/{chunk-TBJ3FZKZ.js → chunk-7Q2XUXSA.js} +1 -1
  2. package/dist/{chunk-LJM7FHPM.js → chunk-BZOJ7HBT.js} +33 -1
  3. package/dist/{chunk-FTZTEHYG.js → chunk-DEWY7OQK.js} +135 -8
  4. package/dist/{chunk-CUONY5TO.js → chunk-EJKW57ZV.js} +19 -1
  5. package/dist/chunk-EZVOG7QS.js +161 -0
  6. package/dist/{chunk-E2OKP5CY.js → chunk-GJETGML6.js} +181 -83
  7. package/dist/{chunk-YHY7OG6S.js → chunk-GWMMYVLL.js} +4 -4
  8. package/dist/{chunk-D6RKW2XG.js → chunk-JLNHMNES.js} +16 -3
  9. package/dist/{chunk-5AAFG2V2.js → chunk-KBQNTUTN.js} +239 -24
  10. package/dist/{chunk-C537SFHV.js → chunk-LOUEJI6X.js} +4 -4
  11. package/dist/{chunk-ALX4WS3A.js → chunk-NP55V7RQ.js} +1 -1
  12. package/dist/{chunk-X32NE6V4.js → chunk-RBXTWWUH.js} +1 -1
  13. package/dist/{chunk-O2OYBAVR.js → chunk-SRBVKO2V.js} +9 -0
  14. package/dist/{chunk-7EF3HYVZ.js → chunk-STJLWMXH.js} +48 -4
  15. package/dist/{chunk-5GME4KJZ.js → chunk-UYCD3JBZ.js} +3 -3
  16. package/dist/{chunk-P4LOYSLA.js → chunk-WKWJWKX7.js} +286 -81
  17. package/dist/cli/index.js +35 -57
  18. package/dist/{client-HKV3QWZ3.js → client-66TFS7RS.js} +4 -2
  19. package/dist/{conduct-W6XF6DJW.js → conduct-A6COHLHY.js} +8 -8
  20. package/dist/{conduct-YB64OHI6.js → conduct-IUVAXUAV.js} +8 -8
  21. package/dist/{conductor-mode-TFCVCQHU.js → conductor-mode-D5TFQW5L.js} +2 -2
  22. package/dist/{conductor-mode-AKREGDIU.js → conductor-mode-L2MB44BW.js} +7 -7
  23. package/dist/{execute-AYQWORVH.js → execute-5AWLARB5.js} +5 -5
  24. package/dist/{execute-EPE6MZLT.js → execute-WOS457HW.js} +2 -2
  25. package/dist/index.js +438 -92
  26. package/dist/{publish-capability-AH2HDW54.js → publish-capability-JJCBBMSX.js} +2 -2
  27. package/dist/{request-HCCXSKAY.js → request-6YQLA7K3.js} +13 -8
  28. package/dist/{serve-skill-SZAQT5T5.js → serve-skill-X7TZSILV.js} +5 -5
  29. package/dist/{server-LMY2A3GT.js → server-5TSP4DBX.js} +10 -12
  30. package/dist/{service-coordinator-WGH6B2VT.js → service-coordinator-WTUSMPY6.js} +69 -46
  31. package/dist/skills/agentbnb/bootstrap.js +459 -189
  32. package/package.json +13 -17
  33. package/skills/agentbnb/bootstrap.test.ts +8 -6
  34. package/skills/agentbnb/bootstrap.ts +21 -13
  35. package/skills/agentbnb/install.sh +0 -0
  36. package/dist/chunk-64AK4FJM.js +0 -84
  37. package/dist/chunk-OH7BP5NP.js +0 -96
  38. package/dist/index.d.ts +0 -5069
@@ -4,32 +4,32 @@ import {
4
4
  import "./chunk-SSK653A6.js";
5
5
  import {
6
6
  createLedger
7
- } from "./chunk-5AAFG2V2.js";
7
+ } from "./chunk-KBQNTUTN.js";
8
8
  import {
9
9
  AutoRequestor,
10
10
  BudgetManager,
11
11
  DEFAULT_BUDGET_CONFIG
12
- } from "./chunk-5GME4KJZ.js";
12
+ } from "./chunk-UYCD3JBZ.js";
13
13
  import "./chunk-KF3TZHA5.js";
14
14
  import {
15
15
  DEFAULT_AUTONOMY_CONFIG
16
16
  } from "./chunk-GKVTD4EZ.js";
17
- import "./chunk-LJM7FHPM.js";
17
+ import "./chunk-BZOJ7HBT.js";
18
18
  import {
19
19
  openCreditDb
20
- } from "./chunk-D6RKW2XG.js";
20
+ } from "./chunk-JLNHMNES.js";
21
21
  import "./chunk-NWIQJ2CL.js";
22
22
  import {
23
23
  requestCapability
24
- } from "./chunk-64AK4FJM.js";
24
+ } from "./chunk-EZVOG7QS.js";
25
25
  import {
26
26
  loadKeyPair
27
- } from "./chunk-CUONY5TO.js";
27
+ } from "./chunk-EJKW57ZV.js";
28
28
  import "./chunk-5AH3CMOX.js";
29
29
  import "./chunk-75OC6E4F.js";
30
30
  import {
31
31
  openDatabase
32
- } from "./chunk-O2OYBAVR.js";
32
+ } from "./chunk-SRBVKO2V.js";
33
33
  import "./chunk-WVY2W7AA.js";
34
34
 
35
35
  // src/mcp/tools/request.ts
@@ -135,7 +135,12 @@ async function handleRequest(args, ctx) {
135
135
  gatewayUrl,
136
136
  token: "",
137
137
  cardId,
138
- params: { ...args.params ?? {}, ...args.skill_id ? { skill_id: args.skill_id } : {}, requester: ctx.config.owner }
138
+ params: { ...args.params ?? {}, ...args.skill_id ? { skill_id: args.skill_id } : {}, requester: ctx.config.owner },
139
+ identity: {
140
+ agentId: ctx.identity.agent_id,
141
+ publicKey: ctx.identity.public_key,
142
+ privateKey: keys.privateKey
143
+ }
139
144
  });
140
145
  await ledger.settle(escrowId, targetOwner ?? "unknown");
141
146
  return {
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  executeCapabilityRequest
3
- } from "./chunk-C537SFHV.js";
3
+ } from "./chunk-LOUEJI6X.js";
4
4
  import {
5
5
  RelayClient
6
6
  } from "./chunk-Z4MCGKTL.js";
7
7
  import "./chunk-SSK653A6.js";
8
- import "./chunk-X32NE6V4.js";
8
+ import "./chunk-RBXTWWUH.js";
9
9
  import {
10
10
  openCreditDb
11
- } from "./chunk-D6RKW2XG.js";
11
+ } from "./chunk-JLNHMNES.js";
12
12
  import "./chunk-NWIQJ2CL.js";
13
- import "./chunk-CUONY5TO.js";
13
+ import "./chunk-EJKW57ZV.js";
14
14
  import "./chunk-75OC6E4F.js";
15
15
  import {
16
16
  listCards,
17
17
  openDatabase
18
- } from "./chunk-O2OYBAVR.js";
18
+ } from "./chunk-SRBVKO2V.js";
19
19
  import "./chunk-WVY2W7AA.js";
20
20
 
21
21
  // src/mcp/tools/serve-skill.ts
@@ -1,24 +1,22 @@
1
1
  import {
2
+ createLedger,
2
3
  ensureIdentity
3
- } from "./chunk-OH7BP5NP.js";
4
- import {
5
- createLedger
6
- } from "./chunk-5AAFG2V2.js";
4
+ } from "./chunk-KBQNTUTN.js";
7
5
  import {
8
6
  fetchRemoteCards,
9
7
  mergeResults
10
8
  } from "./chunk-KF3TZHA5.js";
11
9
  import {
12
10
  searchCards
13
- } from "./chunk-LJM7FHPM.js";
11
+ } from "./chunk-BZOJ7HBT.js";
14
12
  import {
15
13
  getBalance,
16
14
  openCreditDb
17
- } from "./chunk-D6RKW2XG.js";
15
+ } from "./chunk-JLNHMNES.js";
18
16
  import "./chunk-NWIQJ2CL.js";
19
17
  import {
20
18
  loadKeyPair
21
- } from "./chunk-CUONY5TO.js";
19
+ } from "./chunk-EJKW57ZV.js";
22
20
  import {
23
21
  getConfigDir,
24
22
  loadConfig
@@ -26,7 +24,7 @@ import {
26
24
  import {
27
25
  insertCard,
28
26
  openDatabase
29
- } from "./chunk-O2OYBAVR.js";
27
+ } from "./chunk-SRBVKO2V.js";
30
28
  import {
31
29
  AnyCardSchema
32
30
  } from "./chunk-WVY2W7AA.js";
@@ -253,7 +251,7 @@ function registerPublishTool(server, ctx) {
253
251
  }
254
252
 
255
253
  // src/mcp/server.ts
256
- var VERSION = "8.2.0";
254
+ var VERSION = "8.2.1";
257
255
  async function startMcpServer() {
258
256
  const config = loadConfig();
259
257
  if (!config) {
@@ -274,9 +272,9 @@ async function startMcpServer() {
274
272
  registerDiscoverTool(server, ctx);
275
273
  registerStatusTool(server, ctx);
276
274
  registerPublishTool(server, ctx);
277
- const { registerRequestTool } = await import("./request-HCCXSKAY.js");
278
- const { registerConductTool } = await import("./conduct-W6XF6DJW.js");
279
- const { registerServeSkillTool } = await import("./serve-skill-SZAQT5T5.js");
275
+ const { registerRequestTool } = await import("./request-6YQLA7K3.js");
276
+ const { registerConductTool } = await import("./conduct-A6COHLHY.js");
277
+ const { registerServeSkillTool } = await import("./serve-skill-X7TZSILV.js");
280
278
  registerRequestTool(server, ctx);
281
279
  registerConductTool(server, ctx);
282
280
  registerServeSkillTool(server, ctx);
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  executeCapabilityBatch,
3
3
  executeCapabilityRequest
4
- } from "./chunk-C537SFHV.js";
4
+ } from "./chunk-LOUEJI6X.js";
5
5
  import {
6
6
  StructuredFeedbackSchema
7
7
  } from "./chunk-AUBHR7HH.js";
@@ -14,16 +14,15 @@ import {
14
14
  buildDraftCard,
15
15
  detectApiKeys,
16
16
  getPricingStats,
17
+ resolveSelfCli,
17
18
  stopAnnouncement
18
- } from "./chunk-FTZTEHYG.js";
19
- import {
20
- deriveAgentId
21
- } from "./chunk-OH7BP5NP.js";
22
- import "./chunk-X32NE6V4.js";
19
+ } from "./chunk-DEWY7OQK.js";
20
+ import "./chunk-RBXTWWUH.js";
23
21
  import {
24
22
  createLedger,
23
+ deriveAgentId,
25
24
  identityAuthPlugin
26
- } from "./chunk-5AAFG2V2.js";
25
+ } from "./chunk-KBQNTUTN.js";
27
26
  import {
28
27
  ApiSkillConfigSchema,
29
28
  parseSkillsFile
@@ -43,7 +42,7 @@ import {
43
42
  computeReputation,
44
43
  filterCards,
45
44
  searchCards
46
- } from "./chunk-LJM7FHPM.js";
45
+ } from "./chunk-BZOJ7HBT.js";
47
46
  import {
48
47
  bootstrapAgent,
49
48
  getBalance,
@@ -53,12 +52,12 @@ import {
53
52
  openCreditDb,
54
53
  releaseEscrow,
55
54
  settleEscrow
56
- } from "./chunk-D6RKW2XG.js";
55
+ } from "./chunk-JLNHMNES.js";
57
56
  import "./chunk-NWIQJ2CL.js";
58
57
  import {
59
58
  generateKeyPair,
60
59
  verifyEscrowReceipt
61
- } from "./chunk-CUONY5TO.js";
60
+ } from "./chunk-EJKW57ZV.js";
62
61
  import {
63
62
  getConfigDir
64
63
  } from "./chunk-75OC6E4F.js";
@@ -81,7 +80,7 @@ import {
81
80
  updateCard,
82
81
  updateSkillAvailability,
83
82
  updateSkillIdleRate
84
- } from "./chunk-O2OYBAVR.js";
83
+ } from "./chunk-SRBVKO2V.js";
85
84
  import {
86
85
  AgentBnBError,
87
86
  AnyCardSchema
@@ -256,7 +255,7 @@ function applyInputMapping(params, mapping) {
256
255
  return { body, query, pathParams, headers };
257
256
  }
258
257
  function sleep(ms) {
259
- return new Promise((resolve2) => setTimeout(resolve2, ms));
258
+ return new Promise((resolve) => setTimeout(resolve, ms));
260
259
  }
261
260
  var RETRYABLE_STATUSES = /* @__PURE__ */ new Set([429, 500, 503]);
262
261
  var ApiExecutor = class {
@@ -632,7 +631,7 @@ function safeInterpolateCommand2(template, context) {
632
631
  });
633
632
  }
634
633
  function spawnWithKill(command, options, registry) {
635
- return new Promise((resolve2, reject) => {
634
+ return new Promise((resolve, reject) => {
636
635
  const child = spawn("/bin/sh", ["-c", `${command} < /dev/null`], {
637
636
  cwd: options.cwd,
638
637
  env: options.env,
@@ -689,7 +688,7 @@ function spawnWithKill(command, options, registry) {
689
688
  Object.assign(err, { stderr: stderr.trim() });
690
689
  reject(err);
691
690
  } else {
692
- resolve2({ stdout, stderr });
691
+ resolve({ stdout, stderr });
693
692
  }
694
693
  });
695
694
  child.on("error", (err) => {
@@ -946,7 +945,7 @@ var AgentRuntime = class {
946
945
  }
947
946
  const modes = /* @__PURE__ */ new Map();
948
947
  if (this.conductorEnabled) {
949
- const { ConductorMode } = await import("./conductor-mode-AKREGDIU.js");
948
+ const { ConductorMode } = await import("./conductor-mode-L2MB44BW.js");
950
949
  const { registerConductorCard, CONDUCTOR_OWNER } = await import("./card-EX2EYGCZ.js");
951
950
  const { loadPeers } = await import("./peers-K7FSHPN3.js");
952
951
  registerConductorCard(this.registryDb);
@@ -1110,7 +1109,54 @@ function createGatewayServer(opts) {
1110
1109
  return { status: "ok", version: VERSION, uptime: process.uptime() };
1111
1110
  });
1112
1111
  fastify.post("/rpc", async (request, reply) => {
1113
- const body = request.body;
1112
+ const rawBody = request.body;
1113
+ if (Array.isArray(rawBody)) {
1114
+ const responses = await Promise.all(
1115
+ rawBody.map(async (single) => {
1116
+ if (single.jsonrpc !== "2.0" || !single.method) {
1117
+ return { jsonrpc: "2.0", id: single.id ?? null, error: { code: -32600, message: "Invalid Request" } };
1118
+ }
1119
+ if (single.method !== "capability.execute") {
1120
+ return { jsonrpc: "2.0", id: single.id ?? null, error: { code: -32601, message: "Method not found" } };
1121
+ }
1122
+ const params2 = single.params ?? {};
1123
+ const cardId2 = params2.card_id;
1124
+ if (!cardId2) {
1125
+ return { jsonrpc: "2.0", id: single.id ?? null, error: { code: -32602, message: "Invalid params: card_id required" } };
1126
+ }
1127
+ const requester2 = params2.requester ?? "unknown";
1128
+ const receipt2 = params2.escrow_receipt;
1129
+ const batchSkillId = params2.skill_id;
1130
+ const trackKey2 = batchSkillId ?? cardId2;
1131
+ inFlight.set(trackKey2, (inFlight.get(trackKey2) ?? 0) + 1);
1132
+ try {
1133
+ const result2 = await executeCapabilityRequest({
1134
+ registryDb,
1135
+ creditDb,
1136
+ cardId: cardId2,
1137
+ skillId: batchSkillId,
1138
+ params: params2,
1139
+ requester: requester2,
1140
+ escrowReceipt: receipt2,
1141
+ skillExecutor,
1142
+ handlerUrl,
1143
+ timeoutMs
1144
+ });
1145
+ if (result2.success) {
1146
+ return { jsonrpc: "2.0", id: single.id ?? null, result: result2.result };
1147
+ } else {
1148
+ return { jsonrpc: "2.0", id: single.id ?? null, error: result2.error };
1149
+ }
1150
+ } finally {
1151
+ const next = (inFlight.get(trackKey2) ?? 1) - 1;
1152
+ if (next <= 0) inFlight.delete(trackKey2);
1153
+ else inFlight.set(trackKey2, next);
1154
+ }
1155
+ })
1156
+ );
1157
+ return reply.send(responses);
1158
+ }
1159
+ const body = rawBody;
1114
1160
  if (body.jsonrpc !== "2.0" || !body.method) {
1115
1161
  return reply.status(400).send({
1116
1162
  jsonrpc: "2.0",
@@ -2365,7 +2411,7 @@ async function creditRoutesPlugin(fastify, options) {
2365
2411
  }
2366
2412
  initFreeTierTable(creditDb);
2367
2413
  await fastify.register(async (scope) => {
2368
- identityAuthPlugin(scope);
2414
+ identityAuthPlugin(scope, { agentDb: creditDb });
2369
2415
  scope.post("/api/credits/hold", {
2370
2416
  schema: {
2371
2417
  tags: ["credits"],
@@ -3504,7 +3550,7 @@ function createRegistryServer(opts) {
3504
3550
  type: "apiKey",
3505
3551
  in: "header",
3506
3552
  name: "X-Agent-PublicKey",
3507
- description: "Ed25519 public key (hex). Also requires X-Agent-Signature and X-Agent-Timestamp headers."
3553
+ description: "Ed25519 public key (hex). Also requires X-Agent-Id, X-Agent-Signature, and X-Agent-Timestamp headers."
3508
3554
  }
3509
3555
  }
3510
3556
  }
@@ -3517,7 +3563,7 @@ function createRegistryServer(opts) {
3517
3563
  void server.register(cors, {
3518
3564
  origin: true,
3519
3565
  methods: ["GET", "POST", "PATCH", "DELETE", "OPTIONS"],
3520
- allowedHeaders: ["Content-Type", "Authorization", "X-Agent-PublicKey", "X-Agent-Signature", "X-Agent-Timestamp"]
3566
+ allowedHeaders: ["Content-Type", "Authorization", "X-Agent-Id", "X-Agent-PublicKey", "X-Agent-Signature", "X-Agent-Timestamp"]
3521
3567
  });
3522
3568
  void server.register(fastifyWebsocket);
3523
3569
  let relayState = null;
@@ -4822,10 +4868,8 @@ var IdleMonitor = class {
4822
4868
 
4823
4869
  // src/runtime/service-coordinator.ts
4824
4870
  import { spawn as spawn2 } from "child_process";
4825
- import { createRequire } from "module";
4826
4871
  import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
4827
- import { fileURLToPath as fileURLToPath2 } from "url";
4828
- import { dirname as dirname2, join as join2, resolve } from "path";
4872
+ import { join as join2 } from "path";
4829
4873
  import { randomUUID as randomUUID6 } from "crypto";
4830
4874
  var ServiceCoordinator = class {
4831
4875
  config;
@@ -5029,7 +5073,7 @@ var ServiceCoordinator = class {
5029
5073
  }
5030
5074
  if (opts.registryUrl && opts.relay) {
5031
5075
  const { RelayClient } = await import("./websocket-client-QOVARTRN.js");
5032
- const { executeCapabilityRequest: executeCapabilityRequest2 } = await import("./execute-AYQWORVH.js");
5076
+ const { executeCapabilityRequest: executeCapabilityRequest2 } = await import("./execute-5AWLARB5.js");
5033
5077
  const cards = listCards(this.runtime.registryDb, this.config.owner);
5034
5078
  const card = cards[0] ?? {
5035
5079
  id: randomUUID6(),
@@ -5136,7 +5180,8 @@ var ServiceCoordinator = class {
5136
5180
  spawnManagedProcess(opts) {
5137
5181
  const runtime = loadPersistedRuntime(getConfigDir());
5138
5182
  const nodeExec = resolveNodeExecutable(runtime);
5139
- const cliArgs = resolveCliLaunchArgs(this.buildServeArgs(opts));
5183
+ const cliPath = resolveSelfCli();
5184
+ const cliArgs = [cliPath, "serve", ...this.buildServeArgs(opts)];
5140
5185
  const child = spawn2(nodeExec, cliArgs, {
5141
5186
  detached: true,
5142
5187
  stdio: "ignore",
@@ -5322,28 +5367,6 @@ function resolveNodeExecutable(runtime) {
5322
5367
  }
5323
5368
  return process.execPath;
5324
5369
  }
5325
- function resolveCliLaunchArgs(serveArgs) {
5326
- const require2 = createRequire(import.meta.url);
5327
- try {
5328
- const distCli2 = require2.resolve("agentbnb/dist/cli/index.js");
5329
- return [distCli2, "serve", ...serveArgs];
5330
- } catch {
5331
- }
5332
- const projectRoot = resolve(dirname2(fileURLToPath2(import.meta.url)), "..", "..");
5333
- const distCli = join2(projectRoot, "dist", "cli", "index.js");
5334
- if (existsSync3(distCli)) {
5335
- return [distCli, "serve", ...serveArgs];
5336
- }
5337
- const srcCli = join2(projectRoot, "src", "cli", "index.ts");
5338
- if (existsSync3(srcCli)) {
5339
- const tsxCli = require2.resolve("tsx/dist/cli.mjs");
5340
- return [tsxCli, srcCli, "serve", ...serveArgs];
5341
- }
5342
- throw new AgentBnBError(
5343
- "Unable to locate AgentBnB CLI entry (dist/cli/index.js or src/cli/index.ts)",
5344
- "CLI_ENTRY_NOT_FOUND"
5345
- );
5346
- }
5347
5370
  function isPidAlive(pid) {
5348
5371
  if (!Number.isInteger(pid) || pid <= 0) return false;
5349
5372
  try {