agentbnb 9.1.1 → 9.2.0

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 (41) hide show
  1. package/dist/{card-UF465O7O.js → card-VVXNKHDX.js} +2 -2
  2. package/dist/{chunk-RVOZHVM7.js → chunk-53Q2HHHH.js} +6 -6
  3. package/dist/{chunk-5CC6O6SO.js → chunk-AA25Z6FW.js} +1 -1
  4. package/dist/{chunk-Y7CO3VLF.js → chunk-B6AKTLXB.js} +2 -2
  5. package/dist/{chunk-2HH2F3DM.js → chunk-CMGJ52SX.js} +54 -1
  6. package/dist/{chunk-I4E5ERDN.js → chunk-EC6DIVE5.js} +1 -1
  7. package/dist/{chunk-O44N3KR7.js → chunk-FK54LVDR.js} +2 -2
  8. package/dist/{chunk-AMABG5SI.js → chunk-GGRH5PCD.js} +7 -7
  9. package/dist/{chunk-W6LOCBWQ.js → chunk-IWAK4WHK.js} +1 -1
  10. package/dist/{chunk-ZYOMPJGG.js → chunk-KKFP5Y2Z.js} +2 -2
  11. package/dist/{chunk-F2CIPAN2.js → chunk-MQIT2F5V.js} +1 -1
  12. package/dist/{chunk-AW4VSROG.js → chunk-RNALIVRR.js} +1 -1
  13. package/dist/{chunk-G4TF4LB4.js → chunk-UPWAXWY2.js} +1 -1
  14. package/dist/{chunk-WARYO57F.js → chunk-V5TJXK3F.js} +3 -3
  15. package/dist/{chunk-TCA63C42.js → chunk-WEZ7PSOE.js} +9 -9
  16. package/dist/{chunk-LENX5NUW.js → chunk-Z7XWQ63B.js} +55 -2
  17. package/dist/cli/index.js +45 -45
  18. package/dist/{client-XOSXFC7Q.js → client-KL67WZVJ.js} +2 -2
  19. package/dist/{conduct-MALC6HEK.js → conduct-JRLLA4PB.js} +10 -10
  20. package/dist/{conduct-UT6ZYSJD.js → conduct-QLWXU2ZU.js} +10 -10
  21. package/dist/{conductor-mode-UJKMO2GW.js → conductor-mode-66IITI4I.js} +3 -3
  22. package/dist/{conductor-mode-3WLLERB4.js → conductor-mode-PFO2VLH6.js} +9 -9
  23. package/dist/{credits-action-KOUJNR36.js → credits-action-XERUEDF3.js} +4 -4
  24. package/dist/{did-action-UHUYMA4Y.js → did-action-ODWTBVXL.js} +2 -2
  25. package/dist/{execute-UFMGTXET.js → execute-NOQVN7ZG.js} +9 -9
  26. package/dist/{execute-3RADNI74.js → execute-YBNCDAOX.js} +2 -2
  27. package/dist/{openclaw-setup-HEWZZOY7.js → openclaw-setup-4RIZRMXA.js} +11 -11
  28. package/dist/{openclaw-skills-5XLQFRWT.js → openclaw-skills-TQ2JVBRM.js} +2 -2
  29. package/dist/{publish-capability-LM4RSQXX.js → publish-capability-2FMD3K6Z.js} +3 -3
  30. package/dist/{request-LID2N42Y.js → request-EYN4CVXC.js} +8 -8
  31. package/dist/{serve-skill-CDNSHTEE.js → serve-skill-NWERGVH5.js} +9 -9
  32. package/dist/{server-QIAO3YSK.js → server-UPOPLZ24.js} +10 -10
  33. package/dist/{service-coordinator-FB44QL7L.js → service-coordinator-ZOZTW2U6.js} +233 -35
  34. package/dist/{session-action-GYITLYOE.js → session-action-OSBZB4TX.js} +2 -2
  35. package/dist/signing-AQTKYJDB.js +16 -0
  36. package/dist/skills/agentbnb/bootstrap.js +221 -23
  37. package/dist/{store-C4DLIXYM.js → store-74EWU77V.js} +2 -2
  38. package/dist/{vc-action-BWGNQ77Y.js → vc-action-A6VBKERF.js} +2 -2
  39. package/package.json +1 -1
  40. package/dist/{chunk-YNBZLXYS.js → chunk-65GNX2KC.js} +0 -0
  41. package/dist/{chunk-7VZ4M4CT.js → chunk-C56X7EFJ.js} +3 -3
@@ -1,3 +1,8 @@
1
+ import {
2
+ executeCapabilityBatch,
3
+ executeCapabilityRequest,
4
+ notifyProviderEvent
5
+ } from "./chunk-53Q2HHHH.js";
1
6
  import {
2
7
  StructuredFeedbackSchema
3
8
  } from "./chunk-AUBHR7HH.js";
@@ -12,15 +17,13 @@ import {
12
17
  import {
13
18
  interpolateObject
14
19
  } from "./chunk-3MJT4PZG.js";
15
- import {
16
- executeCapabilityBatch,
17
- executeCapabilityRequest,
18
- notifyProviderEvent
19
- } from "./chunk-RVOZHVM7.js";
20
20
  import {
21
21
  announceGateway,
22
22
  stopAnnouncement
23
23
  } from "./chunk-TA73FIZU.js";
24
+ import {
25
+ syncCreditsFromRegistry
26
+ } from "./chunk-KKFP5Y2Z.js";
24
27
  import {
25
28
  resolveSelfCli
26
29
  } from "./chunk-7S4ZLFVI.js";
@@ -29,34 +32,32 @@ import {
29
32
  buildDraftCard,
30
33
  detectApiKeys,
31
34
  getPricingStats
32
- } from "./chunk-G4TF4LB4.js";
35
+ } from "./chunk-UPWAXWY2.js";
36
+ import {
37
+ createLedger,
38
+ identityAuthPlugin,
39
+ tryVerifyIdentity
40
+ } from "./chunk-Z7XWQ63B.js";
41
+ import {
42
+ deriveAgentId
43
+ } from "./chunk-AA25Z6FW.js";
33
44
  import {
34
45
  listPendingRequests,
35
46
  resolvePendingRequest
36
47
  } from "./chunk-5PV5YCSN.js";
48
+ import "./chunk-FK54LVDR.js";
49
+ import "./chunk-ELFGYC22.js";
37
50
  import {
38
51
  DEFAULT_AUTONOMY_CONFIG,
39
52
  getAutonomyTier,
40
53
  insertAuditEvent
41
54
  } from "./chunk-G5WKW3ED.js";
42
- import {
43
- syncCreditsFromRegistry
44
- } from "./chunk-ZYOMPJGG.js";
45
- import {
46
- createLedger,
47
- identityAuthPlugin
48
- } from "./chunk-LENX5NUW.js";
49
- import {
50
- deriveAgentId
51
- } from "./chunk-5CC6O6SO.js";
52
- import "./chunk-O44N3KR7.js";
53
- import "./chunk-ELFGYC22.js";
54
55
  import {
55
56
  buildReputationMap,
56
57
  computeReputation,
57
58
  filterCards,
58
59
  searchCards
59
- } from "./chunk-I4E5ERDN.js";
60
+ } from "./chunk-EC6DIVE5.js";
60
61
  import {
61
62
  NETWORK_FEE_RATE,
62
63
  bootstrapAgent,
@@ -87,7 +88,10 @@ import {
87
88
  updateCard,
88
89
  updateSkillAvailability,
89
90
  updateSkillIdleRate
90
- } from "./chunk-7VZ4M4CT.js";
91
+ } from "./chunk-C56X7EFJ.js";
92
+ import {
93
+ emitProviderEvent
94
+ } from "./chunk-GZUTU6IZ.js";
91
95
  import {
92
96
  RelayMessageSchema,
93
97
  SESSION_MESSAGE_TYPES,
@@ -102,7 +106,7 @@ import {
102
106
  import {
103
107
  generateKeyPair,
104
108
  verifyEscrowReceipt
105
- } from "./chunk-YNBZLXYS.js";
109
+ } from "./chunk-65GNX2KC.js";
106
110
  import "./chunk-YDGXKH2T.js";
107
111
  import "./chunk-J4RFJVXI.js";
108
112
  import {
@@ -118,9 +122,6 @@ import {
118
122
  getSkillRequestCount,
119
123
  insertRequestLog
120
124
  } from "./chunk-4XTYT4JW.js";
121
- import {
122
- emitProviderEvent
123
- } from "./chunk-GZUTU6IZ.js";
124
125
  import "./chunk-3RG5ZIWI.js";
125
126
 
126
127
  // src/runtime/agent-runtime.ts
@@ -1179,8 +1180,8 @@ var AgentRuntime = class {
1179
1180
  }
1180
1181
  const modes = /* @__PURE__ */ new Map();
1181
1182
  if (this.conductorEnabled) {
1182
- const { ConductorMode } = await import("./conductor-mode-3WLLERB4.js");
1183
- const { registerConductorCard, CONDUCTOR_OWNER } = await import("./card-UF465O7O.js");
1183
+ const { ConductorMode } = await import("./conductor-mode-PFO2VLH6.js");
1184
+ const { registerConductorCard, CONDUCTOR_OWNER } = await import("./card-VVXNKHDX.js");
1184
1185
  const { loadPeers } = await import("./peers-7BMU2775.js");
1185
1186
  registerConductorCard(this.registryDb);
1186
1187
  const resolveAgentUrl = (owner) => {
@@ -3265,6 +3266,75 @@ function initiateGithubAuth() {
3265
3266
  };
3266
3267
  }
3267
3268
 
3269
+ // src/registry/hub-identities.ts
3270
+ import { randomBytes as randomBytes2, createHash } from "crypto";
3271
+ var HUB_IDENTITIES_SCHEMA = `
3272
+ CREATE TABLE IF NOT EXISTS hub_identities (
3273
+ email TEXT PRIMARY KEY,
3274
+ agent_id TEXT NOT NULL UNIQUE,
3275
+ public_key TEXT NOT NULL,
3276
+ encrypted_private_key TEXT NOT NULL,
3277
+ kdf_salt TEXT NOT NULL,
3278
+ display_name TEXT NOT NULL,
3279
+ created_at TEXT NOT NULL
3280
+ );
3281
+
3282
+ CREATE INDEX IF NOT EXISTS idx_hub_identities_agent_id
3283
+ ON hub_identities(agent_id);
3284
+ `;
3285
+ var CHALLENGES_SCHEMA = `
3286
+ CREATE TABLE IF NOT EXISTS hub_challenges (
3287
+ challenge TEXT PRIMARY KEY,
3288
+ expires_at TEXT NOT NULL,
3289
+ consumed_at TEXT
3290
+ );
3291
+ `;
3292
+ function ensureHubIdentitiesTables(db) {
3293
+ db.exec(HUB_IDENTITIES_SCHEMA);
3294
+ db.exec(CHALLENGES_SCHEMA);
3295
+ }
3296
+ function deriveAgentId2(publicKeyHex) {
3297
+ const hash = createHash("sha256").update(publicKeyHex, "hex").digest("hex");
3298
+ return `agent-${hash.slice(0, 16)}`;
3299
+ }
3300
+ var CHALLENGE_TTL_MS = 10 * 60 * 1e3;
3301
+ function createChallenge(db) {
3302
+ const challenge = randomBytes2(32).toString("hex");
3303
+ const expires_at = new Date(Date.now() + CHALLENGE_TTL_MS).toISOString();
3304
+ db.prepare("INSERT INTO hub_challenges (challenge, expires_at) VALUES (?, ?)").run(challenge, expires_at);
3305
+ return { challenge, expires_at };
3306
+ }
3307
+ function consumeChallenge(db, challenge) {
3308
+ const row = db.prepare("SELECT expires_at, consumed_at FROM hub_challenges WHERE challenge = ?").get(challenge);
3309
+ if (!row) return false;
3310
+ if (row.consumed_at) return false;
3311
+ if (new Date(row.expires_at).getTime() < Date.now()) return false;
3312
+ const consumed_at = (/* @__PURE__ */ new Date()).toISOString();
3313
+ db.prepare("UPDATE hub_challenges SET consumed_at = ? WHERE challenge = ?").run(consumed_at, challenge);
3314
+ return true;
3315
+ }
3316
+ function pruneChallenges(db) {
3317
+ const cutoff = new Date(Date.now() - 24 * 60 * 60 * 1e3).toISOString();
3318
+ db.prepare("DELETE FROM hub_challenges WHERE expires_at < ? OR consumed_at IS NOT NULL").run(cutoff);
3319
+ }
3320
+ function registerHubIdentity(db, input) {
3321
+ const agent_id = deriveAgentId2(input.public_key);
3322
+ const created_at = (/* @__PURE__ */ new Date()).toISOString();
3323
+ db.prepare(`
3324
+ INSERT INTO hub_identities (email, agent_id, public_key, encrypted_private_key, kdf_salt, display_name, created_at)
3325
+ VALUES (?, ?, ?, ?, ?, ?, ?)
3326
+ `).run(input.email, agent_id, input.public_key, input.encrypted_private_key, input.kdf_salt, input.display_name, created_at);
3327
+ return { ...input, agent_id, created_at };
3328
+ }
3329
+ function getHubIdentityByEmail(db, email) {
3330
+ const row = db.prepare("SELECT * FROM hub_identities WHERE email = ?").get(email);
3331
+ return row ?? null;
3332
+ }
3333
+ function getHubIdentityByAgentId(db, agent_id) {
3334
+ const row = db.prepare("SELECT * FROM hub_identities WHERE agent_id = ?").get(agent_id);
3335
+ return row ?? null;
3336
+ }
3337
+
3268
3338
  // src/registry/free-tier.ts
3269
3339
  function initFreeTierTable(db) {
3270
3340
  db.exec(`
@@ -5273,6 +5343,121 @@ function createRegistryServer(opts) {
5273
5343
  throw err;
5274
5344
  }
5275
5345
  });
5346
+ ensureHubIdentitiesTables(db);
5347
+ try {
5348
+ pruneChallenges(db);
5349
+ } catch {
5350
+ }
5351
+ api.get("/api/agents/challenge", {
5352
+ schema: {
5353
+ tags: ["hub-auth"],
5354
+ summary: "Get a registration challenge",
5355
+ response: {
5356
+ 200: {
5357
+ type: "object",
5358
+ properties: {
5359
+ challenge: { type: "string" },
5360
+ expires_at: { type: "string" }
5361
+ }
5362
+ }
5363
+ }
5364
+ }
5365
+ }, async (_request, reply) => {
5366
+ const { challenge, expires_at } = createChallenge(db);
5367
+ return reply.send({ challenge, expires_at });
5368
+ });
5369
+ api.post("/api/agents/register", {
5370
+ schema: {
5371
+ tags: ["hub-auth"],
5372
+ summary: "Register a new Hub-managed agent identity",
5373
+ body: {
5374
+ type: "object",
5375
+ required: ["email", "public_key", "encrypted_private_key", "kdf_salt", "display_name", "challenge", "signature"],
5376
+ properties: {
5377
+ email: { type: "string", format: "email" },
5378
+ public_key: { type: "string" },
5379
+ encrypted_private_key: { type: "string" },
5380
+ kdf_salt: { type: "string" },
5381
+ display_name: { type: "string" },
5382
+ challenge: { type: "string" },
5383
+ signature: { type: "string" }
5384
+ }
5385
+ },
5386
+ response: {
5387
+ 201: { type: "object", additionalProperties: true },
5388
+ 400: { type: "object", properties: { error: { type: "string" } } },
5389
+ 409: { type: "object", properties: { error: { type: "string" } } }
5390
+ }
5391
+ }
5392
+ }, async (request, reply) => {
5393
+ const body = request.body;
5394
+ if (!consumeChallenge(db, body.challenge)) {
5395
+ return reply.code(400).send({ error: "Invalid or expired challenge" });
5396
+ }
5397
+ if (!/^[0-9a-fA-F]+$/.test(body.public_key) || body.public_key.length % 2 !== 0) {
5398
+ return reply.code(400).send({ error: "Invalid public_key format" });
5399
+ }
5400
+ try {
5401
+ const { verifyEscrowReceipt: verifyEscrowReceipt2 } = await import("./signing-AQTKYJDB.js");
5402
+ const publicKeyBuffer = Buffer.from(body.public_key, "hex");
5403
+ const valid = verifyEscrowReceipt2({ challenge: body.challenge }, body.signature, publicKeyBuffer);
5404
+ if (!valid) {
5405
+ return reply.code(400).send({ error: "Invalid signature" });
5406
+ }
5407
+ } catch (err) {
5408
+ const msg = err instanceof Error ? err.message : String(err);
5409
+ return reply.code(400).send({ error: `Signature verification failed: ${msg}` });
5410
+ }
5411
+ const existing = getHubIdentityByEmail(db, body.email.toLowerCase());
5412
+ if (existing) {
5413
+ return reply.code(409).send({ error: "Email already registered" });
5414
+ }
5415
+ const agent_id = deriveAgentId2(body.public_key);
5416
+ const existingByAgentId = getHubIdentityByAgentId(db, agent_id);
5417
+ if (existingByAgentId) {
5418
+ return reply.code(409).send({ error: "Agent already registered" });
5419
+ }
5420
+ const identity = registerHubIdentity(db, {
5421
+ email: body.email.toLowerCase(),
5422
+ public_key: body.public_key,
5423
+ encrypted_private_key: body.encrypted_private_key,
5424
+ kdf_salt: body.kdf_salt,
5425
+ display_name: body.display_name
5426
+ });
5427
+ return reply.code(201).send({
5428
+ agent_id: identity.agent_id,
5429
+ did: `did:agentbnb:${identity.agent_id}`,
5430
+ created_at: identity.created_at
5431
+ });
5432
+ });
5433
+ api.post("/api/agents/login", {
5434
+ schema: {
5435
+ tags: ["hub-auth"],
5436
+ summary: "Fetch encrypted identity blob for login",
5437
+ body: {
5438
+ type: "object",
5439
+ required: ["email"],
5440
+ properties: { email: { type: "string", format: "email" } }
5441
+ },
5442
+ response: {
5443
+ 200: { type: "object", additionalProperties: true },
5444
+ 404: { type: "object", properties: { error: { type: "string" } } }
5445
+ }
5446
+ }
5447
+ }, async (request, reply) => {
5448
+ const body = request.body;
5449
+ const identity = getHubIdentityByEmail(db, body.email.toLowerCase());
5450
+ if (!identity) {
5451
+ return reply.code(404).send({ error: "Identity not found" });
5452
+ }
5453
+ return reply.send({
5454
+ agent_id: identity.agent_id,
5455
+ public_key: identity.public_key,
5456
+ encrypted_private_key: identity.encrypted_private_key,
5457
+ kdf_salt: identity.kdf_salt,
5458
+ display_name: identity.display_name
5459
+ });
5460
+ });
5276
5461
  api.post("/api/identity/link", {
5277
5462
  schema: {
5278
5463
  tags: ["identity"],
@@ -5572,7 +5757,7 @@ function createRegistryServer(opts) {
5572
5757
  });
5573
5758
  await relayClient.connect();
5574
5759
  }
5575
- const { requestViaRelay } = await import("./client-XOSXFC7Q.js");
5760
+ const { requestViaRelay } = await import("./client-KL67WZVJ.js");
5576
5761
  return requestViaRelay(relayClient, {
5577
5762
  targetOwner: target.owner,
5578
5763
  cardId: target.cardId,
@@ -5591,12 +5776,24 @@ function createRegistryServer(opts) {
5591
5776
  const ownerApiKey = opts.ownerApiKey;
5592
5777
  const ownerName = opts.ownerName;
5593
5778
  void api.register(async (ownerRoutes) => {
5594
- ownerRoutes.addHook("onRequest", async (request, reply) => {
5779
+ ownerRoutes.addHook("preHandler", async (request, reply) => {
5595
5780
  const auth = request.headers.authorization;
5596
5781
  const token = auth?.startsWith("Bearer ") ? auth.slice(7).trim() : null;
5597
- if (!token || token !== ownerApiKey) {
5598
- return reply.status(401).send({ error: "Unauthorized" });
5782
+ if (token === ownerApiKey) {
5783
+ request.agentId = ownerName;
5784
+ return;
5785
+ }
5786
+ const didResult = await tryVerifyIdentity(request, {});
5787
+ if (didResult.valid) {
5788
+ const hubIdentity = getHubIdentityByAgentId(db, didResult.agentId);
5789
+ if (!hubIdentity) {
5790
+ return reply.status(401).send({ error: "Agent not registered on this Hub" });
5791
+ }
5792
+ request.agentId = didResult.agentId;
5793
+ request.agentPublicKey = didResult.publicKey;
5794
+ return;
5599
5795
  }
5796
+ return reply.status(401).send({ error: "Unauthorized" });
5600
5797
  });
5601
5798
  ownerRoutes.get("/me", {
5602
5799
  schema: {
@@ -5607,13 +5804,14 @@ function createRegistryServer(opts) {
5607
5804
  200: { type: "object", properties: { owner: { type: "string" }, balance: { type: "number" } } }
5608
5805
  }
5609
5806
  }
5610
- }, async (_request, reply) => {
5807
+ }, async (request, reply) => {
5808
+ const identity = request.agentId ?? ownerName;
5611
5809
  let balance = 0;
5612
5810
  if (opts.creditDb) {
5613
5811
  const ledger = createLedger({ db: opts.creditDb });
5614
- balance = await ledger.getBalance(ownerName);
5812
+ balance = await ledger.getBalance(identity);
5615
5813
  }
5616
- return reply.send({ owner: ownerName, balance });
5814
+ return reply.send({ owner: identity, balance });
5617
5815
  });
5618
5816
  ownerRoutes.get("/requests", {
5619
5817
  schema: {
@@ -6235,7 +6433,7 @@ var ServiceCoordinator = class {
6235
6433
  console.log("Conductor mode enabled \u2014 orchestrate/plan skills available via gateway");
6236
6434
  }
6237
6435
  if (opts.conductorEnabled && this.config.conductor?.public) {
6238
- const { buildConductorCard } = await import("./card-UF465O7O.js");
6436
+ const { buildConductorCard } = await import("./card-VVXNKHDX.js");
6239
6437
  const conductorCard = attachCanonicalAgentId(
6240
6438
  this.runtime.registryDb,
6241
6439
  buildConductorCard(this.config.owner)
@@ -6312,7 +6510,7 @@ var ServiceCoordinator = class {
6312
6510
  }
6313
6511
  if (opts.registryUrl && opts.relay) {
6314
6512
  const { RelayClient } = await import("./websocket-client-FCPZOE4S.js");
6315
- const { executeCapabilityRequest: executeCapabilityRequest2 } = await import("./execute-UFMGTXET.js");
6513
+ const { executeCapabilityRequest: executeCapabilityRequest2 } = await import("./execute-NOQVN7ZG.js");
6316
6514
  const localCards = listCards(this.runtime.registryDb, this.config.owner);
6317
6515
  const { primaryCard, additionalCards } = buildRelayRegistrationCards(this.config.owner, localCards);
6318
6516
  if (this.config.conductor?.public) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ensureIdentity
3
- } from "./chunk-5CC6O6SO.js";
4
- import "./chunk-YNBZLXYS.js";
3
+ } from "./chunk-AA25Z6FW.js";
4
+ import "./chunk-65GNX2KC.js";
5
5
  import "./chunk-UVCNMRPS.js";
6
6
  import {
7
7
  getConfigDir,
@@ -0,0 +1,16 @@
1
+ import {
2
+ generateKeyPair,
3
+ loadKeyPair,
4
+ saveKeyPair,
5
+ signEscrowReceipt,
6
+ verifyEscrowReceipt
7
+ } from "./chunk-65GNX2KC.js";
8
+ import "./chunk-UVCNMRPS.js";
9
+ import "./chunk-3RG5ZIWI.js";
10
+ export {
11
+ generateKeyPair,
12
+ loadKeyPair,
13
+ saveKeyPair,
14
+ signEscrowReceipt,
15
+ verifyEscrowReceipt
16
+ };