agentbnb 8.2.0 → 8.2.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.
Files changed (40) hide show
  1. package/dist/{chunk-TBJ3FZKZ.js → chunk-4IPJJRTP.js} +1 -1
  2. package/dist/chunk-CKOOVZOI.js +158 -0
  3. package/dist/chunk-CQFBNTGT.js +145 -0
  4. package/dist/{chunk-P4LOYSLA.js → chunk-DYQOFGGI.js} +331 -416
  5. package/dist/{chunk-ALX4WS3A.js → chunk-EG6RS4JC.js} +70 -46
  6. package/dist/{chunk-CUONY5TO.js → chunk-EJKW57ZV.js} +19 -1
  7. package/dist/{chunk-5AAFG2V2.js → chunk-LKLKYXLV.js} +239 -24
  8. package/dist/{chunk-7EF3HYVZ.js → chunk-MCED4GDW.js} +499 -86
  9. package/dist/{chunk-YHY7OG6S.js → chunk-MWOXW7JQ.js} +7 -7
  10. package/dist/{chunk-E2OKP5CY.js → chunk-QCGIG7WW.js} +182 -86
  11. package/dist/{chunk-5GME4KJZ.js → chunk-QHZGOG3O.js} +148 -46
  12. package/dist/{chunk-D6RKW2XG.js → chunk-RYISHSHB.js} +302 -4
  13. package/dist/{chunk-O2OYBAVR.js → chunk-S3V6R3EN.js} +75 -39
  14. package/dist/{chunk-X32NE6V4.js → chunk-WNXXLCV5.js} +1 -1
  15. package/dist/{chunk-C537SFHV.js → chunk-XBGVQMQJ.js} +72 -48
  16. package/dist/{chunk-FTZTEHYG.js → chunk-Z2GEFFDO.js} +135 -8
  17. package/dist/cli/index.js +42 -67
  18. package/dist/{client-HKV3QWZ3.js → client-XOLP5IUZ.js} +4 -2
  19. package/dist/{conduct-W6XF6DJW.js → conduct-AZFLNUX3.js} +10 -11
  20. package/dist/{conduct-YB64OHI6.js → conduct-VPUYTNEA.js} +10 -11
  21. package/dist/{conductor-mode-AKREGDIU.js → conductor-mode-PLTB6MS3.js} +7 -8
  22. package/dist/{conductor-mode-TFCVCQHU.js → conductor-mode-WKB42PYM.js} +6 -3
  23. package/dist/{execute-EPE6MZLT.js → execute-NNDCXTN4.js} +3 -2
  24. package/dist/{execute-AYQWORVH.js → execute-RIRHTIBU.js} +6 -5
  25. package/dist/index.d.ts +8 -8
  26. package/dist/index.js +637 -693
  27. package/dist/{publish-capability-AH2HDW54.js → publish-capability-QDR2QIZ2.js} +2 -2
  28. package/dist/{request-HCCXSKAY.js → request-NX7GSPIG.js} +31 -36
  29. package/dist/{serve-skill-SZAQT5T5.js → serve-skill-E6EJQYAK.js} +10 -9
  30. package/dist/{server-LMY2A3GT.js → server-VBCT32FC.js} +12 -18
  31. package/dist/{service-coordinator-WGH6B2VT.js → service-coordinator-KMSA6BST.js} +137 -69
  32. package/dist/skills/agentbnb/bootstrap.js +561 -247
  33. package/package.json +13 -17
  34. package/skills/agentbnb/bootstrap.test.ts +8 -6
  35. package/skills/agentbnb/bootstrap.ts +21 -13
  36. package/skills/agentbnb/install.sh +0 -0
  37. package/dist/chunk-64AK4FJM.js +0 -84
  38. package/dist/chunk-KF3TZHA5.js +0 -91
  39. package/dist/chunk-LJM7FHPM.js +0 -138
  40. package/dist/chunk-OH7BP5NP.js +0 -96
@@ -2,8 +2,8 @@ import {
2
2
  parseSoulMd,
3
3
  publishFromSoul,
4
4
  skillConfigToSkill
5
- } from "./chunk-TBJ3FZKZ.js";
6
- import "./chunk-O2OYBAVR.js";
5
+ } from "./chunk-4IPJJRTP.js";
6
+ import "./chunk-S3V6R3EN.js";
7
7
  import "./chunk-WVY2W7AA.js";
8
8
  export {
9
9
  parseSoulMd,
@@ -1,35 +1,31 @@
1
- import {
2
- RelayClient
3
- } from "./chunk-Z4MCGKTL.js";
4
- import "./chunk-SSK653A6.js";
5
- import {
6
- createLedger
7
- } from "./chunk-5AAFG2V2.js";
8
1
  import {
9
2
  AutoRequestor,
10
3
  BudgetManager,
11
4
  DEFAULT_BUDGET_CONFIG
12
- } from "./chunk-5GME4KJZ.js";
13
- import "./chunk-KF3TZHA5.js";
5
+ } from "./chunk-QHZGOG3O.js";
14
6
  import {
15
7
  DEFAULT_AUTONOMY_CONFIG
16
8
  } from "./chunk-GKVTD4EZ.js";
17
- import "./chunk-LJM7FHPM.js";
9
+ import "./chunk-CQFBNTGT.js";
18
10
  import {
19
11
  openCreditDb
20
- } from "./chunk-D6RKW2XG.js";
12
+ } from "./chunk-RYISHSHB.js";
21
13
  import "./chunk-NWIQJ2CL.js";
22
14
  import {
23
15
  requestCapability
24
- } from "./chunk-64AK4FJM.js";
16
+ } from "./chunk-CKOOVZOI.js";
25
17
  import {
26
18
  loadKeyPair
27
- } from "./chunk-CUONY5TO.js";
19
+ } from "./chunk-EJKW57ZV.js";
28
20
  import "./chunk-5AH3CMOX.js";
29
21
  import "./chunk-75OC6E4F.js";
22
+ import {
23
+ RelayClient
24
+ } from "./chunk-Z4MCGKTL.js";
25
+ import "./chunk-SSK653A6.js";
30
26
  import {
31
27
  openDatabase
32
- } from "./chunk-O2OYBAVR.js";
28
+ } from "./chunk-S3V6R3EN.js";
33
29
  import "./chunk-WVY2W7AA.js";
34
30
 
35
31
  // src/mcp/tools/request.ts
@@ -88,12 +84,23 @@ async function handleRequest(args, ctx) {
88
84
  } finally {
89
85
  db.close();
90
86
  }
87
+ let identityAuth;
88
+ try {
89
+ const keys = loadKeyPair(ctx.configDir);
90
+ identityAuth = {
91
+ agentId: ctx.identity.agent_id,
92
+ publicKey: ctx.identity.public_key,
93
+ privateKey: keys.privateKey
94
+ };
95
+ } catch {
96
+ }
91
97
  if (localCard && localCard.owner === ctx.config.owner) {
92
98
  const result = await requestCapability({
93
99
  gatewayUrl: ctx.config.gateway_url,
94
100
  token: ctx.config.token,
95
101
  cardId,
96
- params: { ...args.params ?? {}, ...args.skill_id ? { skill_id: args.skill_id } : {}, requester: ctx.config.owner }
102
+ params: { ...args.params ?? {}, ...args.skill_id ? { skill_id: args.skill_id } : {}, requester: ctx.config.owner },
103
+ identity: identityAuth
97
104
  });
98
105
  return {
99
106
  content: [{ type: "text", text: JSON.stringify({ success: true, result }, null, 2) }]
@@ -123,28 +130,16 @@ async function handleRequest(args, ctx) {
123
130
  const targetOwner = remoteCard["owner"] ?? remoteCard["agent_name"];
124
131
  const gatewayUrl = remoteCard["gateway_url"];
125
132
  if (gatewayUrl) {
126
- const keys = loadKeyPair(ctx.configDir);
127
- const ledger = createLedger({
128
- registryUrl: ctx.config.registry,
129
- ownerPublicKey: ctx.identity.public_key,
130
- privateKey: keys.privateKey
133
+ const result = await requestCapability({
134
+ gatewayUrl,
135
+ token: "",
136
+ cardId,
137
+ params: { ...args.params ?? {}, ...args.skill_id ? { skill_id: args.skill_id } : {}, requester: ctx.config.owner },
138
+ identity: identityAuth
131
139
  });
132
- const { escrowId } = await ledger.hold(ctx.config.owner, maxCost, cardId);
133
- try {
134
- const result = await requestCapability({
135
- gatewayUrl,
136
- token: "",
137
- cardId,
138
- params: { ...args.params ?? {}, ...args.skill_id ? { skill_id: args.skill_id } : {}, requester: ctx.config.owner }
139
- });
140
- await ledger.settle(escrowId, targetOwner ?? "unknown");
141
- return {
142
- content: [{ type: "text", text: JSON.stringify({ success: true, result, credits_spent: maxCost }, null, 2) }]
143
- };
144
- } catch (err) {
145
- await ledger.release(escrowId);
146
- throw err;
147
- }
140
+ return {
141
+ content: [{ type: "text", text: JSON.stringify({ success: true, result }, null, 2) }]
142
+ };
148
143
  }
149
144
  if (targetOwner) {
150
145
  const relay = new RelayClient({
@@ -1,21 +1,22 @@
1
1
  import {
2
2
  executeCapabilityRequest
3
- } from "./chunk-C537SFHV.js";
4
- import {
5
- RelayClient
6
- } from "./chunk-Z4MCGKTL.js";
7
- import "./chunk-SSK653A6.js";
8
- import "./chunk-X32NE6V4.js";
3
+ } from "./chunk-XBGVQMQJ.js";
4
+ import "./chunk-WNXXLCV5.js";
5
+ import "./chunk-CQFBNTGT.js";
9
6
  import {
10
7
  openCreditDb
11
- } from "./chunk-D6RKW2XG.js";
8
+ } from "./chunk-RYISHSHB.js";
12
9
  import "./chunk-NWIQJ2CL.js";
13
- import "./chunk-CUONY5TO.js";
10
+ import "./chunk-EJKW57ZV.js";
14
11
  import "./chunk-75OC6E4F.js";
12
+ import {
13
+ RelayClient
14
+ } from "./chunk-Z4MCGKTL.js";
15
+ import "./chunk-SSK653A6.js";
15
16
  import {
16
17
  listCards,
17
18
  openDatabase
18
- } from "./chunk-O2OYBAVR.js";
19
+ } from "./chunk-S3V6R3EN.js";
19
20
  import "./chunk-WVY2W7AA.js";
20
21
 
21
22
  // src/mcp/tools/serve-skill.ts
@@ -1,24 +1,18 @@
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-LKLKYXLV.js";
7
5
  import {
8
6
  fetchRemoteCards,
9
- mergeResults
10
- } from "./chunk-KF3TZHA5.js";
11
- import {
12
- searchCards
13
- } from "./chunk-LJM7FHPM.js";
14
- import {
15
7
  getBalance,
16
- openCreditDb
17
- } from "./chunk-D6RKW2XG.js";
8
+ mergeResults,
9
+ openCreditDb,
10
+ searchCards
11
+ } from "./chunk-RYISHSHB.js";
18
12
  import "./chunk-NWIQJ2CL.js";
19
13
  import {
20
14
  loadKeyPair
21
- } from "./chunk-CUONY5TO.js";
15
+ } from "./chunk-EJKW57ZV.js";
22
16
  import {
23
17
  getConfigDir,
24
18
  loadConfig
@@ -26,7 +20,7 @@ import {
26
20
  import {
27
21
  insertCard,
28
22
  openDatabase
29
- } from "./chunk-O2OYBAVR.js";
23
+ } from "./chunk-S3V6R3EN.js";
30
24
  import {
31
25
  AnyCardSchema
32
26
  } from "./chunk-WVY2W7AA.js";
@@ -253,7 +247,7 @@ function registerPublishTool(server, ctx) {
253
247
  }
254
248
 
255
249
  // src/mcp/server.ts
256
- var VERSION = "8.2.0";
250
+ var VERSION = "8.2.2";
257
251
  async function startMcpServer() {
258
252
  const config = loadConfig();
259
253
  if (!config) {
@@ -274,9 +268,9 @@ async function startMcpServer() {
274
268
  registerDiscoverTool(server, ctx);
275
269
  registerStatusTool(server, ctx);
276
270
  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");
271
+ const { registerRequestTool } = await import("./request-NX7GSPIG.js");
272
+ const { registerConductTool } = await import("./conduct-AZFLNUX3.js");
273
+ const { registerServeSkillTool } = await import("./serve-skill-E6EJQYAK.js");
280
274
  registerRequestTool(server, ctx);
281
275
  registerConductTool(server, ctx);
282
276
  registerServeSkillTool(server, ctx);
@@ -1,36 +1,28 @@
1
1
  import {
2
2
  executeCapabilityBatch,
3
3
  executeCapabilityRequest
4
- } from "./chunk-C537SFHV.js";
4
+ } from "./chunk-XBGVQMQJ.js";
5
5
  import {
6
6
  StructuredFeedbackSchema
7
7
  } from "./chunk-AUBHR7HH.js";
8
8
  import {
9
- RelayMessageSchema
10
- } from "./chunk-SSK653A6.js";
9
+ interpolateObject
10
+ } from "./chunk-3MJT4PZG.js";
11
11
  import {
12
12
  KNOWN_API_KEYS,
13
13
  announceGateway,
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-Z2GEFFDO.js";
23
20
  import {
24
21
  createLedger,
22
+ deriveAgentId,
25
23
  identityAuthPlugin
26
- } from "./chunk-5AAFG2V2.js";
27
- import {
28
- ApiSkillConfigSchema,
29
- parseSkillsFile
30
- } from "./chunk-OCSU2S6W.js";
31
- import {
32
- interpolateObject
33
- } from "./chunk-3MJT4PZG.js";
24
+ } from "./chunk-LKLKYXLV.js";
25
+ import "./chunk-WNXXLCV5.js";
34
26
  import {
35
27
  DEFAULT_AUTONOMY_CONFIG,
36
28
  getAutonomyTier,
@@ -38,30 +30,32 @@ import {
38
30
  listPendingRequests,
39
31
  resolvePendingRequest
40
32
  } from "./chunk-GKVTD4EZ.js";
33
+ import "./chunk-CQFBNTGT.js";
41
34
  import {
35
+ bootstrapAgent,
42
36
  buildReputationMap,
43
37
  computeReputation,
44
38
  filterCards,
45
- searchCards
46
- } from "./chunk-LJM7FHPM.js";
47
- import {
48
- bootstrapAgent,
49
39
  getBalance,
50
40
  getTransactions,
51
41
  holdEscrow,
52
42
  migrateOwner,
53
43
  openCreditDb,
54
44
  releaseEscrow,
45
+ searchCards,
55
46
  settleEscrow
56
- } from "./chunk-D6RKW2XG.js";
47
+ } from "./chunk-RYISHSHB.js";
57
48
  import "./chunk-NWIQJ2CL.js";
58
49
  import {
59
50
  generateKeyPair,
60
51
  verifyEscrowReceipt
61
- } from "./chunk-CUONY5TO.js";
52
+ } from "./chunk-EJKW57ZV.js";
62
53
  import {
63
54
  getConfigDir
64
55
  } from "./chunk-75OC6E4F.js";
56
+ import {
57
+ RelayMessageSchema
58
+ } from "./chunk-SSK653A6.js";
65
59
  import {
66
60
  getActivityFeed,
67
61
  getCard,
@@ -81,11 +75,15 @@ import {
81
75
  updateCard,
82
76
  updateSkillAvailability,
83
77
  updateSkillIdleRate
84
- } from "./chunk-O2OYBAVR.js";
78
+ } from "./chunk-S3V6R3EN.js";
85
79
  import {
86
80
  AgentBnBError,
87
81
  AnyCardSchema
88
82
  } from "./chunk-WVY2W7AA.js";
83
+ import {
84
+ ApiSkillConfigSchema,
85
+ parseSkillsFile
86
+ } from "./chunk-OCSU2S6W.js";
89
87
 
90
88
  // src/runtime/agent-runtime.ts
91
89
  import { readFileSync, existsSync } from "fs";
@@ -256,7 +254,7 @@ function applyInputMapping(params, mapping) {
256
254
  return { body, query, pathParams, headers };
257
255
  }
258
256
  function sleep(ms) {
259
- return new Promise((resolve2) => setTimeout(resolve2, ms));
257
+ return new Promise((resolve) => setTimeout(resolve, ms));
260
258
  }
261
259
  var RETRYABLE_STATUSES = /* @__PURE__ */ new Set([429, 500, 503]);
262
260
  var ApiExecutor = class {
@@ -632,7 +630,7 @@ function safeInterpolateCommand2(template, context) {
632
630
  });
633
631
  }
634
632
  function spawnWithKill(command, options, registry) {
635
- return new Promise((resolve2, reject) => {
633
+ return new Promise((resolve, reject) => {
636
634
  const child = spawn("/bin/sh", ["-c", `${command} < /dev/null`], {
637
635
  cwd: options.cwd,
638
636
  env: options.env,
@@ -689,7 +687,7 @@ function spawnWithKill(command, options, registry) {
689
687
  Object.assign(err, { stderr: stderr.trim() });
690
688
  reject(err);
691
689
  } else {
692
- resolve2({ stdout, stderr });
690
+ resolve({ stdout, stderr });
693
691
  }
694
692
  });
695
693
  child.on("error", (err) => {
@@ -946,7 +944,7 @@ var AgentRuntime = class {
946
944
  }
947
945
  const modes = /* @__PURE__ */ new Map();
948
946
  if (this.conductorEnabled) {
949
- const { ConductorMode } = await import("./conductor-mode-AKREGDIU.js");
947
+ const { ConductorMode } = await import("./conductor-mode-PLTB6MS3.js");
950
948
  const { registerConductorCard, CONDUCTOR_OWNER } = await import("./card-EX2EYGCZ.js");
951
949
  const { loadPeers } = await import("./peers-K7FSHPN3.js");
952
950
  registerConductorCard(this.registryDb);
@@ -1110,7 +1108,54 @@ function createGatewayServer(opts) {
1110
1108
  return { status: "ok", version: VERSION, uptime: process.uptime() };
1111
1109
  });
1112
1110
  fastify.post("/rpc", async (request, reply) => {
1113
- const body = request.body;
1111
+ const rawBody = request.body;
1112
+ if (Array.isArray(rawBody)) {
1113
+ const responses = await Promise.all(
1114
+ rawBody.map(async (single) => {
1115
+ if (single.jsonrpc !== "2.0" || !single.method) {
1116
+ return { jsonrpc: "2.0", id: single.id ?? null, error: { code: -32600, message: "Invalid Request" } };
1117
+ }
1118
+ if (single.method !== "capability.execute") {
1119
+ return { jsonrpc: "2.0", id: single.id ?? null, error: { code: -32601, message: "Method not found" } };
1120
+ }
1121
+ const params2 = single.params ?? {};
1122
+ const cardId2 = params2.card_id;
1123
+ if (!cardId2) {
1124
+ return { jsonrpc: "2.0", id: single.id ?? null, error: { code: -32602, message: "Invalid params: card_id required" } };
1125
+ }
1126
+ const requester2 = params2.requester ?? "unknown";
1127
+ const receipt2 = params2.escrow_receipt;
1128
+ const batchSkillId = params2.skill_id;
1129
+ const trackKey2 = batchSkillId ?? cardId2;
1130
+ inFlight.set(trackKey2, (inFlight.get(trackKey2) ?? 0) + 1);
1131
+ try {
1132
+ const result2 = await executeCapabilityRequest({
1133
+ registryDb,
1134
+ creditDb,
1135
+ cardId: cardId2,
1136
+ skillId: batchSkillId,
1137
+ params: params2,
1138
+ requester: requester2,
1139
+ escrowReceipt: receipt2,
1140
+ skillExecutor,
1141
+ handlerUrl,
1142
+ timeoutMs
1143
+ });
1144
+ if (result2.success) {
1145
+ return { jsonrpc: "2.0", id: single.id ?? null, result: result2.result };
1146
+ } else {
1147
+ return { jsonrpc: "2.0", id: single.id ?? null, error: result2.error };
1148
+ }
1149
+ } finally {
1150
+ const next = (inFlight.get(trackKey2) ?? 1) - 1;
1151
+ if (next <= 0) inFlight.delete(trackKey2);
1152
+ else inFlight.set(trackKey2, next);
1153
+ }
1154
+ })
1155
+ );
1156
+ return reply.send(responses);
1157
+ }
1158
+ const body = rawBody;
1114
1159
  if (body.jsonrpc !== "2.0" || !body.method) {
1115
1160
  return reply.status(400).send({
1116
1161
  jsonrpc: "2.0",
@@ -1212,6 +1257,7 @@ import swaggerUi from "@fastify/swagger-ui";
1212
1257
  import fastifyStatic from "@fastify/static";
1213
1258
  import fastifyWebsocket from "@fastify/websocket";
1214
1259
  import { join, dirname } from "path";
1260
+ import { randomUUID as randomUUID6 } from "crypto";
1215
1261
  import { fileURLToPath } from "url";
1216
1262
  import { existsSync as existsSync2 } from "fs";
1217
1263
  import { z as z4 } from "zod";
@@ -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;
@@ -4394,15 +4440,60 @@ function createRegistryServer(opts) {
4394
4440
  });
4395
4441
  }
4396
4442
  const { requests, strategy, total_budget } = parseResult.data;
4397
- const batchResult = await executeCapabilityBatch({
4398
- requests,
4399
- strategy,
4400
- total_budget,
4401
- registryDb: db,
4402
- creditDb: opts.creditDb,
4403
- owner
4404
- });
4405
- return reply.send(batchResult);
4443
+ const host = request.headers.host ?? request.hostname;
4444
+ const relayRegistryUrl = `${request.protocol}://${host}`;
4445
+ const relayRequesterOwner = `${owner}:batch:${Date.now()}`;
4446
+ let relayClient;
4447
+ try {
4448
+ const batchResult = await executeCapabilityBatch({
4449
+ requests,
4450
+ strategy,
4451
+ total_budget,
4452
+ registryDb: db,
4453
+ creditDb: opts.creditDb,
4454
+ owner,
4455
+ registryUrl: relayRegistryUrl,
4456
+ dispatchRequest: async ({ target, params, requester }) => {
4457
+ if (!target.via_relay) {
4458
+ return { card_id: target.cardId, skill_id: target.skillId };
4459
+ }
4460
+ if (!relayClient) {
4461
+ const { RelayClient } = await import("./websocket-client-QOVARTRN.js");
4462
+ relayClient = new RelayClient({
4463
+ registryUrl: relayRegistryUrl,
4464
+ owner: relayRequesterOwner,
4465
+ token: "batch-token",
4466
+ card: {
4467
+ spec_version: "1.0",
4468
+ id: randomUUID6(),
4469
+ owner: relayRequesterOwner,
4470
+ name: relayRequesterOwner,
4471
+ description: "Batch requester",
4472
+ level: 1,
4473
+ inputs: [],
4474
+ outputs: [],
4475
+ pricing: { credits_per_call: 1 },
4476
+ availability: { online: false }
4477
+ },
4478
+ onRequest: async () => ({ error: { code: -32601, message: "Batch requester does not serve capabilities" } }),
4479
+ silent: true
4480
+ });
4481
+ await relayClient.connect();
4482
+ }
4483
+ const { requestViaRelay } = await import("./client-XOLP5IUZ.js");
4484
+ return requestViaRelay(relayClient, {
4485
+ targetOwner: target.owner,
4486
+ cardId: target.cardId,
4487
+ skillId: target.skillId,
4488
+ params: { ...params, requester },
4489
+ requester
4490
+ });
4491
+ }
4492
+ });
4493
+ return reply.send(batchResult);
4494
+ } finally {
4495
+ relayClient?.disconnect();
4496
+ }
4406
4497
  });
4407
4498
  if (opts.ownerApiKey && opts.ownerName) {
4408
4499
  const ownerApiKey = opts.ownerApiKey;
@@ -4822,11 +4913,9 @@ var IdleMonitor = class {
4822
4913
 
4823
4914
  // src/runtime/service-coordinator.ts
4824
4915
  import { spawn as spawn2 } from "child_process";
4825
- import { createRequire } from "module";
4826
4916
  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";
4829
- import { randomUUID as randomUUID6 } from "crypto";
4917
+ import { join as join2 } from "path";
4918
+ import { randomUUID as randomUUID7 } from "crypto";
4830
4919
  var ServiceCoordinator = class {
4831
4920
  config;
4832
4921
  guard;
@@ -5029,10 +5118,10 @@ var ServiceCoordinator = class {
5029
5118
  }
5030
5119
  if (opts.registryUrl && opts.relay) {
5031
5120
  const { RelayClient } = await import("./websocket-client-QOVARTRN.js");
5032
- const { executeCapabilityRequest: executeCapabilityRequest2 } = await import("./execute-AYQWORVH.js");
5121
+ const { executeCapabilityRequest: executeCapabilityRequest2 } = await import("./execute-RIRHTIBU.js");
5033
5122
  const cards = listCards(this.runtime.registryDb, this.config.owner);
5034
5123
  const card = cards[0] ?? {
5035
- id: randomUUID6(),
5124
+ id: randomUUID7(),
5036
5125
  owner: this.config.owner,
5037
5126
  name: this.config.owner,
5038
5127
  description: "Agent registered via CLI",
@@ -5136,7 +5225,8 @@ var ServiceCoordinator = class {
5136
5225
  spawnManagedProcess(opts) {
5137
5226
  const runtime = loadPersistedRuntime(getConfigDir());
5138
5227
  const nodeExec = resolveNodeExecutable(runtime);
5139
- const cliArgs = resolveCliLaunchArgs(this.buildServeArgs(opts));
5228
+ const cliPath = resolveSelfCli();
5229
+ const cliArgs = [cliPath, "serve", ...this.buildServeArgs(opts)];
5140
5230
  const child = spawn2(nodeExec, cliArgs, {
5141
5231
  detached: true,
5142
5232
  stdio: "ignore",
@@ -5322,28 +5412,6 @@ function resolveNodeExecutable(runtime) {
5322
5412
  }
5323
5413
  return process.execPath;
5324
5414
  }
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
5415
  function isPidAlive(pid) {
5348
5416
  if (!Number.isInteger(pid) || pid <= 0) return false;
5349
5417
  try {