agentbnb 8.2.3 → 8.3.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 (62) hide show
  1. package/dist/{card-EX2EYGCZ.js → card-BN643ZOY.js} +6 -2
  2. package/dist/card-T2XJZA5A.js +92 -0
  3. package/dist/{chunk-3LWBH7P3.js → chunk-4NFJ3VYZ.js} +20 -1
  4. package/dist/chunk-5AIYALBX.js +857 -0
  5. package/dist/chunk-6QMDJVMS.js +238 -0
  6. package/dist/{chunk-LKLKYXLV.js → chunk-74LZDEDT.js} +6 -4
  7. package/dist/{chunk-GKVTD4EZ.js → chunk-77KGEDH4.js} +1 -1
  8. package/dist/{chunk-QCGIG7WW.js → chunk-7IQE34QK.js} +14 -7
  9. package/dist/{chunk-QHZGOG3O.js → chunk-D242QZCR.js} +168 -41
  10. package/dist/chunk-EE3V3DXK.js +60 -0
  11. package/dist/{chunk-RYISHSHB.js → chunk-F3KIEVJ2.js} +207 -265
  12. package/dist/{chunk-XBGVQMQJ.js → chunk-FELGHDCA.js} +16 -39
  13. package/dist/{chunk-EJKW57ZV.js → chunk-GIEJVKZZ.js} +1 -1
  14. package/dist/{chunk-WVY2W7AA.js → chunk-I7KWA7OB.js} +20 -0
  15. package/dist/{chunk-4IPJJRTP.js → chunk-IGQNP3ZO.js} +5 -2
  16. package/dist/chunk-NQANA6WH.js +797 -0
  17. package/dist/{chunk-Z4MCGKTL.js → chunk-NX27AFPA.js} +15 -2
  18. package/dist/{chunk-Z2GEFFDO.js → chunk-O4Q7BRG6.js} +2 -2
  19. package/dist/{chunk-SSK653A6.js → chunk-PQIP7EXY.js} +6 -0
  20. package/dist/{chunk-EG6RS4JC.js → chunk-QFPXZITP.js} +20 -65
  21. package/dist/chunk-R4F4XII4.js +264 -0
  22. package/dist/{chunk-DYQOFGGI.js → chunk-RVBW2QXU.js} +178 -49
  23. package/dist/{chunk-CQFBNTGT.js → chunk-S7DZHKCG.js} +25 -12
  24. package/dist/chunk-U6LP4KWN.js +238 -0
  25. package/dist/{chunk-MWOXW7JQ.js → chunk-VJ7XBEY6.js} +24 -16
  26. package/dist/chunk-WTHMHNKC.js +129 -0
  27. package/dist/{chunk-OCSU2S6W.js → chunk-WX3GZVFG.js} +2 -1
  28. package/dist/{chunk-CKOOVZOI.js → chunk-YKMBFQC2.js} +37 -5
  29. package/dist/{chunk-S3V6R3EN.js → chunk-ZU2TP7CN.js} +70 -27
  30. package/dist/cli/index.js +203 -237
  31. package/dist/client-OKJJ3UP2.js +19 -0
  32. package/dist/client-UQBGCIPA.js +20 -0
  33. package/dist/conduct-4JDMWBQD.js +22 -0
  34. package/dist/{conduct-AZFLNUX3.js → conduct-VYYBCPHA.js} +14 -13
  35. package/dist/{conductor-mode-WKB42PYM.js → conductor-mode-OPGQJFLA.js} +12 -8
  36. package/dist/{conductor-mode-PLTB6MS3.js → conductor-mode-SBDCRIX6.js} +16 -11
  37. package/dist/execute-FZLQGIXB.js +14 -0
  38. package/dist/execute-TEZPQ5WP.js +15 -0
  39. package/dist/index.d.ts +172 -11
  40. package/dist/index.js +1529 -433
  41. package/dist/{process-guard-GH5LRNWO.js → process-guard-TNSUNHSR.js} +1 -1
  42. package/dist/{publish-capability-QDR2QIZ2.js → publish-capability-HVYILTPR.js} +4 -3
  43. package/dist/{reliability-metrics-QG7WC5QK.js → reliability-metrics-G7LPUYJD.js} +3 -1
  44. package/dist/reliability-metrics-RRUKJ4ME.js +20 -0
  45. package/dist/{request-OERS5BE7.js → request-KJNKR27T.js} +76 -71
  46. package/dist/{serve-skill-E6EJQYAK.js → serve-skill-GC6NIQ5T.js} +10 -11
  47. package/dist/{server-46VEG2W7.js → server-YV3XPTX5.js} +11 -10
  48. package/dist/{service-coordinator-KMSA6BST.js → service-coordinator-RY5AKUZS.js} +420 -171
  49. package/dist/{skill-config-FETXPNVP.js → skill-config-5O2VR546.js} +1 -1
  50. package/dist/skills/agentbnb/bootstrap.js +528 -253
  51. package/dist/websocket-client-3U27WJUU.js +7 -0
  52. package/dist/{websocket-client-4Z5P54RU.js → websocket-client-SNDF3B6N.js} +1 -1
  53. package/package.json +1 -1
  54. package/dist/chunk-MCED4GDW.js +0 -1572
  55. package/dist/chunk-NWIQJ2CL.js +0 -108
  56. package/dist/chunk-TUCEDQGM.js +0 -44
  57. package/dist/chunk-WNXXLCV5.js +0 -32
  58. package/dist/client-XOLP5IUZ.js +0 -12
  59. package/dist/conduct-VPUYTNEA.js +0 -21
  60. package/dist/execute-NNDCXTN4.js +0 -13
  61. package/dist/execute-RIRHTIBU.js +0 -16
  62. package/dist/websocket-client-QOVARTRN.js +0 -7
package/dist/cli/index.js CHANGED
@@ -7,51 +7,44 @@ import {
7
7
  discoverLocalAgents,
8
8
  getPricingStats,
9
9
  resolveSelfCli
10
- } from "../chunk-Z2GEFFDO.js";
10
+ } from "../chunk-O4Q7BRG6.js";
11
11
  import {
12
12
  createLedger,
13
13
  ensureIdentity,
14
14
  loadOrRepairIdentity
15
- } from "../chunk-LKLKYXLV.js";
16
- import {
17
- releaseRequesterEscrow,
18
- settleRequesterEscrow
19
- } from "../chunk-WNXXLCV5.js";
20
- import {
21
- createSignedEscrowReceipt
22
- } from "../chunk-TUCEDQGM.js";
15
+ } from "../chunk-74LZDEDT.js";
23
16
  import {
24
17
  AutoRequestor,
25
18
  BudgetManager,
26
- DEFAULT_BUDGET_CONFIG
27
- } from "../chunk-QHZGOG3O.js";
19
+ DEFAULT_BUDGET_CONFIG,
20
+ requestViaTemporaryRelay
21
+ } from "../chunk-D242QZCR.js";
28
22
  import {
29
23
  DEFAULT_AUTONOMY_CONFIG
30
- } from "../chunk-GKVTD4EZ.js";
31
- import "../chunk-CQFBNTGT.js";
24
+ } from "../chunk-77KGEDH4.js";
25
+ import "../chunk-S7DZHKCG.js";
32
26
  import {
33
27
  bootstrapAgent,
34
- createAgentRecord,
35
28
  fetchRemoteCards,
36
29
  filterCards,
37
30
  getBalance,
38
31
  getTransactions,
39
- lookupAgent,
40
- lookupAgentByOwner,
41
32
  mergeResults,
42
33
  migrateOwner,
43
34
  openCreditDb,
44
35
  searchCards
45
- } from "../chunk-RYISHSHB.js";
46
- import "../chunk-NWIQJ2CL.js";
36
+ } from "../chunk-F3KIEVJ2.js";
37
+ import "../chunk-NX27AFPA.js";
38
+ import "../chunk-PQIP7EXY.js";
47
39
  import {
48
40
  requestCapability
49
- } from "../chunk-CKOOVZOI.js";
41
+ } from "../chunk-YKMBFQC2.js";
50
42
  import {
51
43
  generateKeyPair,
52
44
  loadKeyPair,
53
45
  saveKeyPair
54
- } from "../chunk-EJKW57ZV.js";
46
+ } from "../chunk-GIEJVKZZ.js";
47
+ import "../chunk-U6LP4KWN.js";
55
48
  import {
56
49
  findPeer,
57
50
  loadPeers,
@@ -65,19 +58,26 @@ import {
65
58
  } from "../chunk-75OC6E4F.js";
66
59
  import {
67
60
  parseSoulMd
68
- } from "../chunk-4IPJJRTP.js";
61
+ } from "../chunk-IGQNP3ZO.js";
69
62
  import {
63
+ attachCanonicalAgentId,
70
64
  deleteCard,
71
65
  getCard,
72
66
  insertCard,
73
67
  listCards,
74
68
  openDatabase
75
- } from "../chunk-S3V6R3EN.js";
69
+ } from "../chunk-5AIYALBX.js";
70
+ import {
71
+ createAgentRecord,
72
+ lookupAgent,
73
+ lookupAgentByOwner,
74
+ updateAgentRecord
75
+ } from "../chunk-WTHMHNKC.js";
76
76
  import {
77
77
  AgentBnBError,
78
78
  AnyCardSchema,
79
79
  CapabilityCardV2Schema
80
- } from "../chunk-WVY2W7AA.js";
80
+ } from "../chunk-I7KWA7OB.js";
81
81
 
82
82
  // src/cli/index.ts
83
83
  import { Command } from "commander";
@@ -188,17 +188,18 @@ function publishFromSoulV2(db, soulContent, owner, sharedSkills) {
188
188
  created_at: existingV2?.created_at ?? now,
189
189
  updated_at: now
190
190
  };
191
- CapabilityCardV2Schema.parse(card);
191
+ const storedCard = attachCanonicalAgentId(db, card);
192
+ CapabilityCardV2Schema.parse(storedCard);
192
193
  if (existingV2) {
193
194
  db.prepare(
194
195
  "UPDATE capability_cards SET data = ?, updated_at = ? WHERE id = ?"
195
- ).run(JSON.stringify(card), now, cardId);
196
+ ).run(JSON.stringify(storedCard), now, cardId);
196
197
  } else {
197
198
  db.prepare(
198
199
  "INSERT INTO capability_cards (id, owner, data, created_at, updated_at) VALUES (?, ?, ?, ?, ?)"
199
- ).run(cardId, owner, JSON.stringify(card), now, now);
200
+ ).run(cardId, storedCard.owner, JSON.stringify(storedCard), now, now);
200
201
  }
201
- return card;
202
+ return storedCard;
202
203
  }
203
204
 
204
205
  // src/openclaw/heartbeat-writer.ts
@@ -499,6 +500,28 @@ function loadIdentityAuth(owner) {
499
500
  privateKey: keys.privateKey
500
501
  };
501
502
  }
503
+ function syncAgentRecord(db, identity, owner, displayName) {
504
+ const existingAgent = lookupAgent(db, identity.agent_id) ?? lookupAgentByOwner(db, owner);
505
+ if (!existingAgent) {
506
+ createAgentRecord(db, {
507
+ agent_id: identity.agent_id,
508
+ display_name: displayName,
509
+ public_key: identity.public_key,
510
+ legacy_owner: owner
511
+ });
512
+ return;
513
+ }
514
+ const updates = {};
515
+ if (existingAgent.display_name !== displayName) {
516
+ updates.display_name = displayName;
517
+ }
518
+ if (existingAgent.legacy_owner !== owner) {
519
+ updates.legacy_owner = owner;
520
+ }
521
+ if (Object.keys(updates).length > 0) {
522
+ updateAgentRecord(db, existingAgent.agent_id, updates);
523
+ }
524
+ }
502
525
  async function performInit(opts) {
503
526
  const configDir = getConfigDir();
504
527
  const dbPath = join2(configDir, "registry.db");
@@ -524,24 +547,25 @@ async function performInit(opts) {
524
547
  const identity = identityMaterial.identity;
525
548
  const keypairStatus = identityMaterial.status === "generated" ? "generated" : "existing";
526
549
  const creditDb = openCreditDb(creditDbPath);
550
+ const registryDb = openDatabase(dbPath);
551
+ syncAgentRecord(creditDb, identity, owner, config.display_name ?? owner);
552
+ syncAgentRecord(registryDb, identity, owner, config.display_name ?? owner);
527
553
  if (existingConfig?.owner && existingConfig.owner !== owner) {
528
554
  migrateOwner(creditDb, existingConfig.owner, owner);
529
- const regDb = openDatabase(dbPath);
530
- try {
531
- const rows = regDb.prepare("SELECT id, owner, data FROM capability_cards WHERE owner != ?").all(owner);
532
- for (const row of rows) {
533
- try {
534
- const card = JSON.parse(row.data);
535
- card.owner = owner;
536
- regDb.prepare("UPDATE capability_cards SET owner = ?, data = ? WHERE id = ?").run(owner, JSON.stringify(card), row.id);
537
- } catch {
538
- }
539
- }
540
- if (!opts.json && rows.length > 0) {
541
- console.log(`Migrated ${rows.length} card(s) \u2192 ${owner}`);
555
+ const rows = registryDb.prepare("SELECT id, owner, data FROM capability_cards WHERE owner = ?").all(existingConfig.owner);
556
+ for (const row of rows) {
557
+ try {
558
+ const card = JSON.parse(row.data);
559
+ const updatedCard = attachCanonicalAgentId(registryDb, {
560
+ ...card,
561
+ owner
562
+ });
563
+ registryDb.prepare("UPDATE capability_cards SET owner = ?, data = ? WHERE id = ?").run(owner, JSON.stringify(updatedCard), row.id);
564
+ } catch {
542
565
  }
543
- } finally {
544
- regDb.close();
566
+ }
567
+ if (!opts.json && rows.length > 0) {
568
+ console.log(`Migrated ${rows.length} card(s) \u2192 ${owner}`);
545
569
  }
546
570
  const allOwners = creditDb.prepare("SELECT owner FROM credit_balances WHERE owner != ?").all(owner);
547
571
  for (const { owner: oldOwner } of allOwners) {
@@ -569,23 +593,12 @@ async function performInit(opts) {
569
593
  console.log(`Migrated local credits: ${existingConfig.owner} \u2192 ${owner}`);
570
594
  }
571
595
  }
572
- const existingAgent = lookupAgent(creditDb, identity.agent_id) ?? lookupAgentByOwner(creditDb, owner);
573
- if (!existingAgent) {
574
- try {
575
- createAgentRecord(creditDb, {
576
- agent_id: identity.agent_id,
577
- display_name: config.display_name ?? owner,
578
- public_key: identity.public_key,
579
- legacy_owner: owner
580
- });
581
- } catch {
582
- }
583
- }
584
596
  if (!config.agent_id || config.agent_id !== identity.agent_id) {
585
597
  config.agent_id = identity.agent_id;
586
598
  saveConfig(config);
587
599
  }
588
- bootstrapAgent(creditDb, owner, 100);
600
+ bootstrapAgent(creditDb, identity.agent_id, 100);
601
+ registryDb.close();
589
602
  creditDb.close();
590
603
  let registryBalance;
591
604
  if (config.registry) {
@@ -636,13 +649,20 @@ async function performInit(opts) {
636
649
  if (yesMode) {
637
650
  const db = openDatabase(dbPath);
638
651
  try {
652
+ const storedCard = attachCanonicalAgentId(db, card);
639
653
  db.prepare(
640
654
  `INSERT OR REPLACE INTO capability_cards (id, owner, data, created_at, updated_at)
641
655
  VALUES (?, ?, ?, ?, ?)`
642
- ).run(card.id, card.owner, JSON.stringify(card), card.created_at, card.updated_at);
643
- publishedCards.push({ id: card.id, name: card.agent_name });
656
+ ).run(
657
+ storedCard.id,
658
+ storedCard.owner,
659
+ JSON.stringify(storedCard),
660
+ storedCard.created_at,
661
+ storedCard.updated_at
662
+ );
663
+ publishedCards.push({ id: storedCard.id, name: storedCard.agent_name });
644
664
  if (!opts.json) {
645
- console.log(` Published v2.0 card: ${card.agent_name} (${card.skills.length} skills)`);
665
+ console.log(` Published v2.0 card: ${storedCard.agent_name} (${storedCard.skills.length} skills)`);
646
666
  }
647
667
  } finally {
648
668
  db.close();
@@ -653,12 +673,19 @@ Publish these ${card.skills.length} capabilities? [y/N] `);
653
673
  if (yes) {
654
674
  const db = openDatabase(dbPath);
655
675
  try {
676
+ const storedCard = attachCanonicalAgentId(db, card);
656
677
  db.prepare(
657
678
  `INSERT OR REPLACE INTO capability_cards (id, owner, data, created_at, updated_at)
658
679
  VALUES (?, ?, ?, ?, ?)`
659
- ).run(card.id, card.owner, JSON.stringify(card), card.created_at, card.updated_at);
660
- publishedCards.push({ id: card.id, name: card.agent_name });
661
- console.log(` Published v2.0 card: ${card.agent_name} (${card.skills.length} skills)`);
680
+ ).run(
681
+ storedCard.id,
682
+ storedCard.owner,
683
+ JSON.stringify(storedCard),
684
+ storedCard.created_at,
685
+ storedCard.updated_at
686
+ );
687
+ publishedCards.push({ id: storedCard.id, name: storedCard.agent_name });
688
+ console.log(` Published v2.0 card: ${storedCard.agent_name} (${storedCard.skills.length} skills)`);
662
689
  } finally {
663
690
  db.close();
664
691
  }
@@ -721,13 +748,20 @@ Publish these ${card.skills.length} capabilities? [y/N] `);
721
748
  const card = capabilitiesToV2Card(selected, owner);
722
749
  const db = openDatabase(dbPath);
723
750
  try {
751
+ const storedCard = attachCanonicalAgentId(db, card);
724
752
  db.prepare(
725
753
  `INSERT OR REPLACE INTO capability_cards (id, owner, data, created_at, updated_at)
726
754
  VALUES (?, ?, ?, ?, ?)`
727
- ).run(card.id, card.owner, JSON.stringify(card), card.created_at, card.updated_at);
728
- publishedCards.push({ id: card.id, name: card.agent_name });
755
+ ).run(
756
+ storedCard.id,
757
+ storedCard.owner,
758
+ JSON.stringify(storedCard),
759
+ storedCard.created_at,
760
+ storedCard.updated_at
761
+ );
762
+ publishedCards.push({ id: storedCard.id, name: storedCard.agent_name });
729
763
  console.log(`
730
- Published v2.0 card: ${card.agent_name} (${card.skills.length} skills)`);
764
+ Published v2.0 card: ${storedCard.agent_name} (${storedCard.skills.length} skills)`);
731
765
  } finally {
732
766
  db.close();
733
767
  }
@@ -885,8 +919,8 @@ Skills: ${skills.skillCount} skill(s) in ${skills.path}`);
885
919
  let daemonStatus = { running: false, reason: "skipped" };
886
920
  if (!skipServe) {
887
921
  try {
888
- const { ProcessGuard } = await import("../process-guard-GH5LRNWO.js");
889
- const { ServiceCoordinator } = await import("../service-coordinator-KMSA6BST.js");
922
+ const { ProcessGuard } = await import("../process-guard-TNSUNHSR.js");
923
+ const { ServiceCoordinator } = await import("../service-coordinator-RY5AKUZS.js");
890
924
  const guard = new ProcessGuard(join3(initResult.configDir, ".pid"));
891
925
  const coordinator = new ServiceCoordinator(initResult.config, guard);
892
926
  const result = await coordinator.ensureRunning({
@@ -948,7 +982,7 @@ Skills: ${skills.skillCount} skill(s) in ${skills.path}`);
948
982
  }
949
983
 
950
984
  // src/cli/index.ts
951
- var VERSION = "8.2.3";
985
+ var VERSION = true ? "8.3.0" : "0.0.0-dev";
952
986
  function loadIdentityAuth2(owner) {
953
987
  const configDir = getConfigDir();
954
988
  let keys;
@@ -965,6 +999,32 @@ function loadIdentityAuth2(owner) {
965
999
  privateKey: keys.privateKey
966
1000
  };
967
1001
  }
1002
+ function parsePositiveNumber(value) {
1003
+ return typeof value === "number" && value > 0 ? value : void 0;
1004
+ }
1005
+ function buildTimeoutHintFromCard(card, skillId) {
1006
+ const cardHint = {
1007
+ expected_duration_ms: parsePositiveNumber(card["expected_duration_ms"]),
1008
+ hard_timeout_ms: parsePositiveNumber(card["hard_timeout_ms"])
1009
+ };
1010
+ const skills = card["skills"];
1011
+ if (!Array.isArray(skills)) {
1012
+ return cardHint.expected_duration_ms !== void 0 || cardHint.hard_timeout_ms !== void 0 ? cardHint : void 0;
1013
+ }
1014
+ const selected = skillId ? skills.find((candidate) => {
1015
+ if (!candidate || typeof candidate !== "object") return false;
1016
+ return candidate["id"] === skillId;
1017
+ }) : skills[0];
1018
+ if (!selected || typeof selected !== "object") {
1019
+ return cardHint.expected_duration_ms !== void 0 || cardHint.hard_timeout_ms !== void 0 ? cardHint : void 0;
1020
+ }
1021
+ const selectedRecord = selected;
1022
+ const hint = {
1023
+ expected_duration_ms: parsePositiveNumber(selectedRecord["expected_duration_ms"]) ?? cardHint.expected_duration_ms,
1024
+ hard_timeout_ms: parsePositiveNumber(selectedRecord["hard_timeout_ms"]) ?? cardHint.hard_timeout_ms
1025
+ };
1026
+ return hint.expected_duration_ms !== void 0 || hint.hard_timeout_ms !== void 0 ? hint : void 0;
1027
+ }
968
1028
  function getLanIp2() {
969
1029
  const nets = networkInterfaces2();
970
1030
  for (const ifaces of Object.values(nets)) {
@@ -1072,15 +1132,22 @@ program.command("publish <card.json>").description("Publish a Capability Card to
1072
1132
  }
1073
1133
  }
1074
1134
  const db = openDatabase(config.db_path);
1135
+ let localCard = card;
1075
1136
  try {
1076
1137
  if (card.spec_version === "2.0") {
1077
1138
  const now = (/* @__PURE__ */ new Date()).toISOString();
1078
- const cardWithTimestamps = { ...card, created_at: card.created_at ?? now, updated_at: now };
1139
+ const cardWithTimestamps = attachCanonicalAgentId(db, {
1140
+ ...card,
1141
+ created_at: card.created_at ?? now,
1142
+ updated_at: now
1143
+ });
1079
1144
  db.prepare(
1080
1145
  "INSERT OR REPLACE INTO capability_cards (id, owner, data, created_at, updated_at) VALUES (?, ?, ?, ?, ?)"
1081
1146
  ).run(cardWithTimestamps.id, cardWithTimestamps.owner, JSON.stringify(cardWithTimestamps), cardWithTimestamps.created_at, cardWithTimestamps.updated_at);
1147
+ localCard = cardWithTimestamps;
1082
1148
  } else {
1083
1149
  insertCard(db, card);
1150
+ localCard = attachCanonicalAgentId(db, card);
1084
1151
  }
1085
1152
  } finally {
1086
1153
  db.close();
@@ -1092,7 +1159,7 @@ program.command("publish <card.json>").description("Publish a Capability Card to
1092
1159
  let remoteSuccess = false;
1093
1160
  if (registryUrl) {
1094
1161
  const url = `${registryUrl.replace(/\/$/, "")}/cards`;
1095
- const remoteCard = { ...card, gateway_url: config.gateway_url };
1162
+ const remoteCard = config.agent_id && localCard.owner === config.owner && localCard.agent_id !== config.agent_id ? { ...localCard, agent_id: config.agent_id, gateway_url: config.gateway_url } : { ...localCard, gateway_url: config.gateway_url };
1096
1163
  try {
1097
1164
  const response = await fetch(url, {
1098
1165
  method: "POST",
@@ -1128,8 +1195,8 @@ program.command("publish-skills").description("Publish capabilities from skills.
1128
1195
  console.error("Error: not initialized. Run `agentbnb init` first.");
1129
1196
  process.exit(1);
1130
1197
  }
1131
- const { parseSkillsFile } = await import("../skill-config-FETXPNVP.js");
1132
- const { skillConfigToSkill } = await import("../publish-capability-QDR2QIZ2.js");
1198
+ const { parseSkillsFile } = await import("../skill-config-5O2VR546.js");
1199
+ const { skillConfigToSkill } = await import("../publish-capability-HVYILTPR.js");
1133
1200
  const skillsPath = typeof opts.fromSkills === "string" ? opts.fromSkills : "./skills.yaml";
1134
1201
  let yamlContent;
1135
1202
  try {
@@ -1159,6 +1226,7 @@ program.command("publish-skills").description("Publish capabilities from skills.
1159
1226
  spec_version: "2.0",
1160
1227
  id: randomUUID3(),
1161
1228
  owner: config.owner,
1229
+ agent_id: config.agent_id,
1162
1230
  agent_name: config.owner,
1163
1231
  skills,
1164
1232
  availability: { online: true },
@@ -1167,9 +1235,10 @@ program.command("publish-skills").description("Publish capabilities from skills.
1167
1235
  };
1168
1236
  const db = openDatabase(config.db_path);
1169
1237
  try {
1238
+ const storedCard = attachCanonicalAgentId(db, card);
1170
1239
  db.prepare(
1171
1240
  "INSERT OR REPLACE INTO capability_cards (id, owner, data, created_at, updated_at) VALUES (?, ?, ?, ?, ?)"
1172
- ).run(card.id, card.owner, JSON.stringify(card), now, now);
1241
+ ).run(storedCard.id, storedCard.owner, JSON.stringify(storedCard), now, now);
1173
1242
  } finally {
1174
1243
  db.close();
1175
1244
  }
@@ -1366,7 +1435,7 @@ ${discovered.length} agent(s) found on local network`);
1366
1435
  console.log(`
1367
1436
  ${outputCards.length} result(s)`);
1368
1437
  });
1369
- program.command("request [card-id]").description("Request a capability from another agent \u2014 direct (card-id) or auto (--query)").option("--params <json>", "Input parameters as JSON string", "{}").option("--peer <name>", "Peer name to send request to (resolves URL+token from peer registry)").option("--skill <id>", "Skill ID within a v2.0 card").option("--cost <credits>", "Credits to commit (required for cross-machine peer requests)").option("--query <text>", "Search query for capability gap (triggers auto-request flow)").option("--max-cost <credits>", "Maximum credits to spend on auto-request (default: 50)").option("--no-receipt", "Skip signed escrow receipt (local-only mode)").option("--batch <file>", "Path to JSON file with batch request payload { requests, strategy, total_budget }").option("--json", "Output as JSON").action(async (cardId, opts) => {
1438
+ program.command("request [card-id]").description("Request a capability from another agent \u2014 direct (card-id) or auto (--query)").option("--params <json>", "Input parameters as JSON string", "{}").option("--peer <name>", "Peer name to send request to (resolves URL+token from peer registry)").option("--skill <id>", "Skill ID within a v2.0 card").option("--cost <credits>", "Credits to commit (required for cross-machine peer requests)").option("--query <text>", "Search query for capability gap (triggers auto-request flow)").option("--max-cost <credits>", "Maximum credits to spend on auto-request (default: 50)").option("--timeout <ms>", "Request timeout override in milliseconds").option("--no-receipt", "Skip signed escrow receipt (local-only mode)").option("--batch <file>", "Path to JSON file with batch request payload { requests, strategy, total_budget }").option("--json", "Output as JSON").action(async (cardId, opts) => {
1370
1439
  const config = loadConfig();
1371
1440
  if (!config) {
1372
1441
  console.error("Error: not initialized. Run `agentbnb init` first.");
@@ -1478,10 +1547,20 @@ Batch Results (${res.results.length} items):`);
1478
1547
  console.error("Error: --params must be valid JSON.");
1479
1548
  process.exit(1);
1480
1549
  }
1550
+ let timeoutOverrideMs;
1551
+ if (opts.timeout !== void 0) {
1552
+ timeoutOverrideMs = Number(opts.timeout);
1553
+ if (!Number.isFinite(timeoutOverrideMs) || timeoutOverrideMs <= 0) {
1554
+ console.error("Error: --timeout <ms> must be a positive number.");
1555
+ process.exit(1);
1556
+ }
1557
+ }
1481
1558
  let gatewayUrl;
1482
1559
  let token;
1483
1560
  let isRemoteRequest = false;
1484
1561
  let targetOwner;
1562
+ let targetAgentId;
1563
+ let timeoutHint;
1485
1564
  const identityAuth = loadIdentityAuth2(config.owner);
1486
1565
  if (opts.peer) {
1487
1566
  const peer = findPeer(opts.peer);
@@ -1504,6 +1583,7 @@ Batch Results (${res.results.length} items):`);
1504
1583
  if (localCard && localCard.owner === config.owner) {
1505
1584
  gatewayUrl = config.gateway_url;
1506
1585
  token = config.token;
1586
+ timeoutHint = buildTimeoutHintFromCard(localCard, opts.skill);
1507
1587
  } else {
1508
1588
  const registryUrl = config.registry;
1509
1589
  if (!registryUrl) {
@@ -1525,6 +1605,8 @@ Batch Results (${res.results.length} items):`);
1525
1605
  process.exit(1);
1526
1606
  }
1527
1607
  targetOwner = remoteCard.owner ?? remoteCard.agent_name;
1608
+ targetAgentId = typeof remoteCard.agent_id === "string" ? remoteCard.agent_id : void 0;
1609
+ timeoutHint = buildTimeoutHintFromCard(remoteCard, opts.skill);
1528
1610
  if (remoteCard.gateway_url && typeof remoteCard.gateway_url === "string") {
1529
1611
  gatewayUrl = remoteCard.gateway_url;
1530
1612
  } else if (targetOwner && config.registry) {
@@ -1545,110 +1627,6 @@ Batch Results (${res.results.length} items):`);
1545
1627
  }
1546
1628
  }
1547
1629
  }
1548
- const useReceipt = isRemoteRequest && opts.receipt !== false;
1549
- const isRelayOnly = isRemoteRequest && !gatewayUrl;
1550
- const useRegistryLedger = false;
1551
- if (useReceipt && !opts.cost && !isRelayOnly) {
1552
- console.error("Error: --cost <credits> is required for remote requests. Specify the credits to commit.");
1553
- process.exit(1);
1554
- }
1555
- let escrowId;
1556
- let escrowReceipt;
1557
- let requestLedger;
1558
- if (useReceipt) {
1559
- const amount = Number(opts.cost);
1560
- if (isNaN(amount) || amount <= 0) {
1561
- console.error("Error: --cost must be a positive number.");
1562
- process.exit(1);
1563
- }
1564
- if (useRegistryLedger) {
1565
- const reqIdentityAuth = loadIdentityAuth2(config.owner);
1566
- requestLedger = createLedger({
1567
- registryUrl: config.registry,
1568
- ownerPublicKey: reqIdentityAuth.publicKey,
1569
- privateKey: reqIdentityAuth.privateKey
1570
- });
1571
- try {
1572
- const { escrowId: heldId } = await requestLedger.hold(config.owner, amount, cardId);
1573
- escrowId = heldId;
1574
- if (!opts.json) {
1575
- console.log(`Escrow: ${amount} credits held via Registry (ID: ${escrowId.slice(0, 8)}...)`);
1576
- }
1577
- } catch (err) {
1578
- const msg = err instanceof Error ? err.message : String(err);
1579
- if (opts.json) {
1580
- console.log(JSON.stringify({ success: false, error: msg }, null, 2));
1581
- } else {
1582
- console.error(`Error creating escrow via Registry: ${msg}`);
1583
- }
1584
- process.exit(1);
1585
- }
1586
- } else if (gatewayUrl) {
1587
- const configDir = getConfigDir();
1588
- const creditDb = openCreditDb(join4(configDir, "credit.db"));
1589
- creditDb.pragma("busy_timeout = 5000");
1590
- try {
1591
- const keys = loadKeyPair(configDir);
1592
- const receiptResult = createSignedEscrowReceipt(creditDb, keys.privateKey, keys.publicKey, {
1593
- owner: config.owner,
1594
- amount,
1595
- cardId,
1596
- skillId: opts.skill
1597
- });
1598
- escrowId = receiptResult.escrowId;
1599
- escrowReceipt = receiptResult.receipt;
1600
- if (!opts.json) {
1601
- console.log(`Escrow: ${amount} credits held (ID: ${escrowId.slice(0, 8)}...)`);
1602
- }
1603
- } catch (err) {
1604
- creditDb.close();
1605
- const msg = err instanceof Error ? err.message : String(err);
1606
- if (opts.json) {
1607
- console.log(JSON.stringify({ success: false, error: msg }, null, 2));
1608
- } else {
1609
- console.error(`Error creating escrow receipt: ${msg}`);
1610
- }
1611
- process.exit(1);
1612
- }
1613
- creditDb.close();
1614
- }
1615
- }
1616
- const settleEscrow = async () => {
1617
- if (useReceipt && escrowId) {
1618
- if (requestLedger) {
1619
- await requestLedger.settle(escrowId, targetOwner ?? config.owner);
1620
- if (!opts.json) console.log(`Escrow settled: ${opts.cost} credits deducted.`);
1621
- } else if (escrowReceipt) {
1622
- const configDir = getConfigDir();
1623
- const creditDb = openCreditDb(join4(configDir, "credit.db"));
1624
- creditDb.pragma("busy_timeout = 5000");
1625
- try {
1626
- settleRequesterEscrow(creditDb, escrowId);
1627
- if (!opts.json) console.log(`Escrow settled: ${opts.cost} credits deducted.`);
1628
- } finally {
1629
- creditDb.close();
1630
- }
1631
- }
1632
- }
1633
- };
1634
- const releaseEscrow = async () => {
1635
- if (useReceipt && escrowId) {
1636
- if (requestLedger) {
1637
- await requestLedger.release(escrowId);
1638
- if (!opts.json) console.log("Escrow released: credits refunded.");
1639
- } else if (escrowReceipt) {
1640
- const configDir = getConfigDir();
1641
- const creditDb = openCreditDb(join4(configDir, "credit.db"));
1642
- creditDb.pragma("busy_timeout = 5000");
1643
- try {
1644
- releaseRequesterEscrow(creditDb, escrowId);
1645
- if (!opts.json) console.log("Escrow released: credits refunded.");
1646
- } finally {
1647
- creditDb.close();
1648
- }
1649
- }
1650
- }
1651
- };
1652
1630
  const printResult = (result) => {
1653
1631
  if (opts.json) {
1654
1632
  console.log(JSON.stringify({ success: true, result }, null, 2));
@@ -1657,70 +1635,58 @@ Batch Results (${res.results.length} items):`);
1657
1635
  console.log(typeof result === "string" ? result : JSON.stringify(result, null, 2));
1658
1636
  }
1659
1637
  };
1660
- const isNetworkError = (err) => {
1661
- const msg = err instanceof Error ? err.message : String(err);
1662
- return msg.includes("NETWORK_ERROR") || msg.includes("ECONNREFUSED") || msg.includes("fetch failed") || msg.includes("Network error");
1663
- };
1664
- const tryViaRelay = async () => {
1665
- const { RelayClient } = await import("../websocket-client-QOVARTRN.js");
1666
- const { requestViaRelay } = await import("../client-XOLP5IUZ.js");
1667
- const requesterId = `${config.owner}:req:${randomUUID3()}`;
1668
- const tempRelay = new RelayClient({
1669
- registryUrl: config.registry,
1670
- owner: requesterId,
1671
- token: config.token,
1672
- card: { id: randomUUID3(), owner: requesterId, name: requesterId, description: "Requester", level: 1, spec_version: "1.0", inputs: [], outputs: [], pricing: { credits_per_call: 1 }, availability: { online: false } },
1673
- onRequest: async () => ({ error: { code: -32601, message: "Not serving" } }),
1674
- silent: true
1675
- });
1676
- try {
1677
- await tempRelay.connect();
1678
- const result = await requestViaRelay(tempRelay, {
1638
+ try {
1639
+ let result;
1640
+ if (!isRemoteRequest) {
1641
+ result = await requestCapability({
1642
+ gatewayUrl,
1643
+ token,
1644
+ cardId,
1645
+ params: {
1646
+ ...params,
1647
+ ...opts.skill ? { skill_id: opts.skill } : {},
1648
+ requester: config.owner
1649
+ },
1650
+ timeoutMs: timeoutOverrideMs,
1651
+ timeoutHint,
1652
+ identity: identityAuth
1653
+ });
1654
+ } else if (isRemoteRequest && config.registry && targetOwner) {
1655
+ if (!opts.json) console.log("Requesting via relay...");
1656
+ result = await requestViaTemporaryRelay({
1657
+ registryUrl: config.registry,
1658
+ owner: config.owner,
1659
+ token: config.token,
1679
1660
  targetOwner,
1661
+ targetAgentId,
1680
1662
  cardId,
1681
1663
  skillId: opts.skill,
1682
- params: { ...params, ...opts.skill ? { skill_id: opts.skill } : {} },
1683
- requester: config.owner,
1684
- // actual owner for credit tracking on relay server
1685
- escrowReceipt
1664
+ params: {
1665
+ ...params,
1666
+ ...opts.skill ? { skill_id: opts.skill } : {},
1667
+ requester: config.owner
1668
+ },
1669
+ timeoutMs: timeoutOverrideMs
1670
+ });
1671
+ } else if (gatewayUrl) {
1672
+ result = await requestCapability({
1673
+ gatewayUrl,
1674
+ token,
1675
+ cardId,
1676
+ params: {
1677
+ ...params,
1678
+ ...opts.skill ? { skill_id: opts.skill } : {},
1679
+ requester: config.owner
1680
+ },
1681
+ timeoutMs: timeoutOverrideMs,
1682
+ timeoutHint,
1683
+ identity: identityAuth
1686
1684
  });
1687
- return result;
1688
- } finally {
1689
- tempRelay.disconnect();
1690
- }
1691
- };
1692
- try {
1693
- let result;
1694
- if (!gatewayUrl && isRemoteRequest && config.registry && targetOwner) {
1695
- if (!opts.json) console.log("No gateway URL, requesting via relay...");
1696
- result = await tryViaRelay();
1697
1685
  } else {
1698
- try {
1699
- result = await requestCapability({
1700
- gatewayUrl,
1701
- token,
1702
- cardId,
1703
- params: {
1704
- ...params,
1705
- ...opts.skill ? { skill_id: opts.skill } : {},
1706
- requester: config.owner
1707
- },
1708
- escrowReceipt,
1709
- identity: identityAuth
1710
- });
1711
- } catch (directErr) {
1712
- if (isNetworkError(directErr) && isRemoteRequest && config.registry && targetOwner) {
1713
- if (!opts.json) console.log("Direct connection failed, trying relay...");
1714
- result = await tryViaRelay();
1715
- } else {
1716
- throw directErr;
1717
- }
1718
- }
1686
+ throw new Error("Remote request requires a registry URL and target owner. Configure registry with: agentbnb config set registry <url>");
1719
1687
  }
1720
- await settleEscrow();
1721
1688
  printResult(result);
1722
1689
  } catch (err) {
1723
- await releaseEscrow();
1724
1690
  const msg = err instanceof Error ? err.message : String(err);
1725
1691
  if (opts.json) {
1726
1692
  console.log(JSON.stringify({ success: false, error: msg }, null, 2));
@@ -1792,8 +1758,8 @@ program.command("serve").description("Start the AgentBnB gateway server").option
1792
1758
  console.error("Error: not initialized. Run `agentbnb init` first.");
1793
1759
  process.exit(1);
1794
1760
  }
1795
- const { ProcessGuard } = await import("../process-guard-GH5LRNWO.js");
1796
- const { ServiceCoordinator } = await import("../service-coordinator-KMSA6BST.js");
1761
+ const { ProcessGuard } = await import("../process-guard-TNSUNHSR.js");
1762
+ const { ServiceCoordinator } = await import("../service-coordinator-RY5AKUZS.js");
1797
1763
  const port = opts.port ? parseInt(opts.port, 10) : config.gateway_port;
1798
1764
  const registryPort = parseInt(opts.registryPort, 10);
1799
1765
  if (!Number.isFinite(port) || !Number.isFinite(registryPort)) {
@@ -2167,7 +2133,7 @@ openclaw.command("rules").description("Print HEARTBEAT.md rules block (or inject
2167
2133
  }
2168
2134
  });
2169
2135
  program.command("conduct <task>").description("Orchestrate a complex task across the AgentBnB network").option("--plan-only", "Show execution plan without executing").option("--max-budget <credits>", "Maximum credits to spend", "100").option("--json", "Output as JSON").action(async (task, opts) => {
2170
- const { conductAction } = await import("../conduct-VPUYTNEA.js");
2136
+ const { conductAction } = await import("../conduct-4JDMWBQD.js");
2171
2137
  const result = await conductAction(task, opts);
2172
2138
  if (opts.json) {
2173
2139
  console.log(JSON.stringify(result, null, 2));
@@ -2279,7 +2245,7 @@ Feedback for skill: ${opts.skill} (${feedbacks.length} entries)
2279
2245
  });
2280
2246
  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);
2281
2247
  program.command("mcp-server").description("Start an MCP (Model Context Protocol) server for IDE integration").action(async () => {
2282
- const { startMcpServer } = await import("../server-46VEG2W7.js");
2248
+ const { startMcpServer } = await import("../server-YV3XPTX5.js");
2283
2249
  await startMcpServer();
2284
2250
  });
2285
2251
  await program.parseAsync(process.argv);