agentbnb 9.0.3 → 9.1.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 (72) hide show
  1. package/dist/{card-NKQFB3HD.js → card-NQHAGTQQ.js} +3 -1
  2. package/dist/{card-6KL6L4GF.js → card-VVT3XBOI.js} +3 -1
  3. package/dist/chunk-3RG5ZIWI.js +10 -0
  4. package/dist/{chunk-76YORWFJ.js → chunk-3Y76PHEY.js} +62 -5
  5. package/dist/{chunk-QEDVPJKP.js → chunk-4DBSSFHG.js} +20 -16
  6. package/dist/chunk-4HLGFR72.js +155 -0
  7. package/dist/{chunk-ERT77HKY.js → chunk-4M6IAIVK.js} +2 -2
  8. package/dist/{chunk-FUGWPKXN.js → chunk-4UIUIHST.js} +1 -1
  9. package/dist/chunk-4XTYT4JW.js +147 -0
  10. package/dist/{chunk-2SOHHB2O.js → chunk-AR7Z3EQB.js} +34 -11
  11. package/dist/{chunk-Z4IDXMSP.js → chunk-D7NH6YLM.js} +6 -1
  12. package/dist/{chunk-SLZBE2I5.js → chunk-DBO2335D.js} +17 -12
  13. package/dist/{chunk-N3TXLBGK.js → chunk-GAZCZCAZ.js} +1 -1
  14. package/dist/{chunk-UQCQ2JCG.js → chunk-JJHQAZWE.js} +4 -4
  15. package/dist/{chunk-NLQCHO7N.js → chunk-JKD6QRUD.js} +3 -134
  16. package/dist/{chunk-74OZGLIT.js → chunk-LENX5NUW.js} +1 -1
  17. package/dist/{chunk-I3RRMAAD.js → chunk-PIO2FMX4.js} +5 -5
  18. package/dist/{chunk-77HAL2ZL.js → chunk-PYZGF5QH.js} +60 -3
  19. package/dist/chunk-Q5OFZ2JR.js +292 -0
  20. package/dist/{chunk-YJ3RGKPU.js → chunk-QG2LLVXP.js} +6 -2
  21. package/dist/chunk-QXRNW4OJ.js +35 -0
  22. package/dist/{chunk-UR3MISL2.js → chunk-UPNREF4L.js} +1 -1
  23. package/dist/{chunk-SMQDT7CT.js → chunk-UXL7DV7P.js} +7 -3
  24. package/dist/{chunk-PG3CLSAH.js → chunk-VJ2Q33AP.js} +3 -134
  25. package/dist/{chunk-DYJ7YGBM.js → chunk-WOVESOQ7.js} +237 -124
  26. package/dist/{chunk-BNS76U6K.js → chunk-XL5XD3IG.js} +23 -17
  27. package/dist/{chunk-FMKBCO2Q.js → chunk-ZYOMPJGG.js} +2 -2
  28. package/dist/cli/index.js +117 -48
  29. package/dist/{client-YB3IYO3S.js → client-XOSXFC7Q.js} +1 -0
  30. package/dist/{conduct-URYWMA5T.js → conduct-6C6JWZKZ.js} +13 -10
  31. package/dist/conduct-VSSHJHVH.js +29 -0
  32. package/dist/{conductor-mode-NRSVP2AU.js → conductor-mode-KKPSNN7V.js} +9 -6
  33. package/dist/{conductor-mode-2UFN6BUL.js → conductor-mode-NKHIZG4N.js} +17 -14
  34. package/dist/{config-IRWLG6IW.js → config-ZFWBAGDU.js} +1 -0
  35. package/dist/{credits-action-24EPLUHG.js → credits-action-N3WB4WSI.js} +5 -3
  36. package/dist/{daemon-A7DXZIQW.js → daemon-OM2K3U7J.js} +1 -0
  37. package/dist/{did-action-MQLDT4RF.js → did-action-3PNFYLX2.js} +1 -0
  38. package/dist/{execute-DNRNU3HM.js → execute-IEQ3RV7I.js} +6 -3
  39. package/dist/{execute-2Z3XIUHR.js → execute-QHP4KUV2.js} +10 -7
  40. package/dist/index.d.ts +412 -275
  41. package/dist/index.js +886 -282
  42. package/dist/{openclaw-setup-WA625DZA.js → openclaw-setup-PKGFB4IH.js} +19 -16
  43. package/dist/{openclaw-skills-76ZWXHFM.js → openclaw-skills-5VJDA6SX.js} +7 -6
  44. package/dist/{peers-F2EWUMVQ.js → peers-7BMU2775.js} +1 -0
  45. package/dist/{peers-CJ7T4RJO.js → peers-IOVCBWAI.js} +1 -0
  46. package/dist/{process-guard-QDBIOLY4.js → process-guard-6324CZDC.js} +1 -0
  47. package/dist/{publish-capability-FOCHYNYE.js → publish-capability-CHMPZ6W3.js} +4 -2
  48. package/dist/{reliability-metrics-JSOY3PNW.js → reliability-metrics-22JTZGB4.js} +1 -0
  49. package/dist/{reliability-metrics-KKUFFVB6.js → reliability-metrics-MIJ3TJWL.js} +1 -0
  50. package/dist/{request-KPKWBL5W.js → request-6TBVP3GR.js} +12 -9
  51. package/dist/request-log-2D253WML.js +17 -0
  52. package/dist/request-log-SIGTGOFA.js +16 -0
  53. package/dist/{scanner-GP4AOCW6.js → scanner-EFU6NBEJ.js} +1 -0
  54. package/dist/{schema-7BSSLZ4S.js → schema-FABVZKSI.js} +1 -0
  55. package/dist/{serve-skill-QSUIK3ZF.js → serve-skill-BRUHUDRA.js} +12 -9
  56. package/dist/{server-OCCAVVDF.js → server-N4BJW4TS.js} +15 -8
  57. package/dist/{service-coordinator-4JAUUNUL.js → service-coordinator-M2CBDEUQ.js} +539 -50
  58. package/dist/session-5AIRM7YF.js +144 -0
  59. package/dist/session-action-67J57636.js +131 -0
  60. package/dist/{skill-config-5O2VR546.js → skill-config-VYNF7BCY.js} +1 -0
  61. package/dist/{skill-wrap-YLCJMFEJ.js → skill-wrap-IAZHOYM4.js} +1 -0
  62. package/dist/skills/agentbnb/bootstrap.js +564 -75
  63. package/dist/{store-S22F3I7G.js → store-A4YPEHDV.js} +3 -1
  64. package/dist/{vc-action-SUD7TMN2.js → vc-action-TSAIABUM.js} +1 -0
  65. package/dist/websocket-client-FCPZOE4S.js +9 -0
  66. package/dist/websocket-client-RT4KLJL4.js +8 -0
  67. package/dist/{writer-4QJ3U3WE.js → writer-V7JBWKKZ.js} +1 -0
  68. package/package.json +1 -1
  69. package/dist/chunk-3466S65P.js +0 -179
  70. package/dist/conduct-UAEEMVFD.js +0 -26
  71. package/dist/websocket-client-5CRE36Z5.js +0 -7
  72. package/dist/websocket-client-WHEHIYIZ.js +0 -6
@@ -1,3 +1,13 @@
1
+ import {
2
+ createLedger,
3
+ deriveAgentId,
4
+ ensureIdentity,
5
+ executeCapabilityBatch,
6
+ executeCapabilityRequest,
7
+ identityAuthPlugin,
8
+ loadOrRepairIdentity,
9
+ syncCreditsFromRegistry
10
+ } from "../../chunk-PYZGF5QH.js";
1
11
  import {
2
12
  AutoRequestor,
3
13
  BudgetController,
@@ -16,29 +26,9 @@ import {
16
26
  requestViaTemporaryRelay,
17
27
  resolvePendingRequest,
18
28
  verifyUCAN
19
- } from "../../chunk-SLZBE2I5.js";
20
- import {
21
- requestCapability,
22
- requestViaRelay
23
- } from "../../chunk-W6LOCBWQ.js";
24
- import {
25
- RelayClient,
26
- RelayMessageSchema
27
- } from "../../chunk-DYJ7YGBM.js";
28
- import {
29
- loadPeers
30
- } from "../../chunk-HLUEOLSZ.js";
31
- import {
32
- createLedger,
33
- deriveAgentId,
34
- ensureIdentity,
35
- executeCapabilityBatch,
36
- executeCapabilityRequest,
37
- identityAuthPlugin,
38
- loadOrRepairIdentity,
39
- syncCreditsFromRegistry
40
- } from "../../chunk-77HAL2ZL.js";
29
+ } from "../../chunk-DBO2335D.js";
41
30
  import {
31
+ NETWORK_FEE_RATE,
42
32
  bootstrapAgent,
43
33
  buildReputationMap,
44
34
  computeReputation,
@@ -57,44 +47,66 @@ import {
57
47
  releaseEscrow,
58
48
  searchCards,
59
49
  settleEscrow
60
- } from "../../chunk-BNS76U6K.js";
50
+ } from "../../chunk-XL5XD3IG.js";
61
51
  import "../../chunk-6QMDJVMS.js";
52
+ import {
53
+ requestCapability,
54
+ requestViaRelay
55
+ } from "../../chunk-W6LOCBWQ.js";
62
56
  import {
63
57
  generateKeyPair,
64
58
  loadKeyPair,
65
59
  signEscrowReceipt,
66
60
  verifyEscrowReceipt
67
61
  } from "../../chunk-YNBZLXYS.js";
62
+ import {
63
+ RelayClient,
64
+ RelayMessageSchema,
65
+ SESSION_MESSAGE_TYPES,
66
+ SessionEndMessageSchema,
67
+ SessionMessageMessageSchema,
68
+ SessionOpenMessageSchema,
69
+ loadSessionConfig
70
+ } from "../../chunk-WOVESOQ7.js";
71
+ import {
72
+ loadCoreConfig
73
+ } from "../../chunk-QXRNW4OJ.js";
74
+ import {
75
+ loadPeers
76
+ } from "../../chunk-HLUEOLSZ.js";
68
77
  import {
69
78
  getConfigDir,
70
79
  loadConfig
71
80
  } from "../../chunk-IVOYM3WG.js";
72
81
  import {
73
82
  attachCanonicalAgentId,
74
- getActivityFeed,
75
83
  getCard,
76
84
  getCardsBySkillCapability,
77
85
  getEvolutionHistory,
78
86
  getFeedbackForProvider,
79
87
  getFeedbackForSkill,
80
88
  getLatestEvolution,
81
- getRequestLog,
82
- getSkillRequestCount,
83
89
  insertCard,
84
90
  insertEvolution,
85
91
  insertFeedback,
86
- insertRequestLog,
87
92
  listCards,
88
93
  openDatabase,
89
94
  updateCard,
90
95
  updateSkillAvailability,
91
96
  updateSkillIdleRate
92
- } from "../../chunk-PG3CLSAH.js";
97
+ } from "../../chunk-VJ2Q33AP.js";
98
+ import {
99
+ getActivityFeed,
100
+ getRequestLog,
101
+ getSkillRequestCount,
102
+ insertRequestLog
103
+ } from "../../chunk-4XTYT4JW.js";
93
104
  import "../../chunk-EE3V3DXK.js";
94
105
  import {
95
106
  AgentBnBError,
96
107
  AnyCardSchema
97
108
  } from "../../chunk-UVCNMRPS.js";
109
+ import "../../chunk-3RG5ZIWI.js";
98
110
 
99
111
  // skills/agentbnb/bootstrap.ts
100
112
  import { join as join6, basename as basename2, dirname as dirname4 } from "path";
@@ -102,7 +114,7 @@ import { existsSync as existsSync7, writeFileSync as writeFileSync2 } from "fs";
102
114
  import { homedir as homedir4 } from "os";
103
115
  import { exec } from "child_process";
104
116
  import { promisify as promisify2 } from "util";
105
- import { randomUUID as randomUUID11 } from "crypto";
117
+ import { randomUUID as randomUUID12 } from "crypto";
106
118
 
107
119
  // src/runtime/process-guard.ts
108
120
  import { dirname, join } from "path";
@@ -879,9 +891,42 @@ var PipelineExecutor = class {
879
891
  };
880
892
 
881
893
  // src/skills/openclaw-bridge.ts
882
- import { execFileSync } from "child_process";
894
+ import { spawnSync } from "child_process";
883
895
  var DEFAULT_BASE_URL = "http://localhost:3000";
884
896
  var DEFAULT_TIMEOUT_MS = 6e4;
897
+ function isOpenClawJsonResponse(value) {
898
+ return typeof value === "object" && value !== null && "payloads" in value && Array.isArray(value.payloads) && "meta" in value;
899
+ }
900
+ function parseOpenClawResponse(raw) {
901
+ if (!isOpenClawJsonResponse(raw)) {
902
+ return raw;
903
+ }
904
+ const { payloads, meta } = raw;
905
+ const texts = payloads.map((p) => p.text).filter((t) => typeof t === "string" && t.length > 0);
906
+ const mediaUrls = payloads.map((p) => p.mediaUrl).filter((u) => typeof u === "string" && u.length > 0);
907
+ const openclawMeta = {
908
+ duration_ms: meta.durationMs,
909
+ model: meta.agentMeta?.model,
910
+ provider: meta.agentMeta?.provider
911
+ };
912
+ if (texts.length === 0) {
913
+ return { text: "", media_urls: mediaUrls, _openclaw_meta: openclawMeta };
914
+ }
915
+ const lastText = texts[texts.length - 1];
916
+ try {
917
+ const structured = JSON.parse(lastText);
918
+ if (typeof structured === "object" && structured !== null) {
919
+ return { ...structured, _openclaw_meta: openclawMeta };
920
+ }
921
+ return { result: structured, _openclaw_meta: openclawMeta };
922
+ } catch {
923
+ return {
924
+ text: texts.join("\n\n"),
925
+ media_urls: mediaUrls.length > 0 ? mediaUrls : void 0,
926
+ _openclaw_meta: openclawMeta
927
+ };
928
+ }
929
+ }
885
930
  function buildPayload(config, params) {
886
931
  return {
887
932
  task: config.name,
@@ -948,7 +993,7 @@ Do NOT include explanations, markdown formatting, or code blocks.
948
993
  The JSON should contain the output fields specified in your SKILL.md.
949
994
  If you cannot complete the task, return: {"error": "reason"}`;
950
995
  try {
951
- const stdout = execFileSync("openclaw", [
996
+ const proc = spawnSync("openclaw", [
952
997
  "agent",
953
998
  "--agent",
954
999
  config.agent_name,
@@ -957,21 +1002,37 @@ If you cannot complete the task, return: {"error": "reason"}`;
957
1002
  "--json",
958
1003
  "--local"
959
1004
  ], {
960
- timeout: timeoutMs
1005
+ timeout: timeoutMs,
1006
+ maxBuffer: 10 * 1024 * 1024
1007
+ // 10 MB
961
1008
  });
962
- const text = stdout.toString().trim();
1009
+ if (proc.error) {
1010
+ return { success: false, error: proc.error.message };
1011
+ }
1012
+ const stderrText = proc.stderr?.toString() ?? "";
1013
+ const stdoutText = proc.stdout?.toString() ?? "";
1014
+ const text = (stderrText || stdoutText).trim();
1015
+ if (!text) {
1016
+ return {
1017
+ success: false,
1018
+ error: `OpenClaw process channel returned empty output (exit code ${proc.status})`
1019
+ };
1020
+ }
1021
+ const jsonStart = text.lastIndexOf("\n{");
1022
+ const jsonText = jsonStart >= 0 ? text.slice(jsonStart + 1) : text;
963
1023
  try {
964
- const parsed = JSON.parse(text);
965
- return { success: true, result: parsed };
1024
+ const parsed = JSON.parse(jsonText);
1025
+ const result = parseOpenClawResponse(parsed);
1026
+ return { success: true, result };
966
1027
  } catch {
967
1028
  return {
968
1029
  success: false,
969
- error: `OpenClaw process channel returned invalid JSON: ${text}`
1030
+ error: `OpenClaw process channel returned invalid JSON: ${jsonText.slice(0, 500)}`
970
1031
  };
971
1032
  }
972
1033
  } catch (err) {
973
- const message2 = err instanceof Error ? err.message : String(err);
974
- return { success: false, error: message2 };
1034
+ const errMsg = err instanceof Error ? err.message : String(err);
1035
+ return { success: false, error: errMsg };
975
1036
  }
976
1037
  }
977
1038
  async function executeTelegram(config, payload) {
@@ -1390,9 +1451,9 @@ var AgentRuntime = class {
1390
1451
  }
1391
1452
  const modes = /* @__PURE__ */ new Map();
1392
1453
  if (this.conductorEnabled) {
1393
- const { ConductorMode } = await import("../../conductor-mode-NRSVP2AU.js");
1394
- const { registerConductorCard, CONDUCTOR_OWNER } = await import("../../card-6KL6L4GF.js");
1395
- const { loadPeers: loadPeers2 } = await import("../../peers-CJ7T4RJO.js");
1454
+ const { ConductorMode } = await import("../../conductor-mode-KKPSNN7V.js");
1455
+ const { registerConductorCard, CONDUCTOR_OWNER } = await import("../../card-VVT3XBOI.js");
1456
+ const { loadPeers: loadPeers2 } = await import("../../peers-IOVCBWAI.js");
1396
1457
  registerConductorCard(this.registryDb);
1397
1458
  const resolveAgentUrl = (owner) => {
1398
1459
  const peers = loadPeers2();
@@ -1726,7 +1787,7 @@ import swaggerUi from "@fastify/swagger-ui";
1726
1787
  import fastifyStatic from "@fastify/static";
1727
1788
  import fastifyWebsocket from "@fastify/websocket";
1728
1789
  import { join as join2, dirname as dirname2 } from "path";
1729
- import { randomUUID as randomUUID7 } from "crypto";
1790
+ import { randomUUID as randomUUID8 } from "crypto";
1730
1791
  import { fileURLToPath } from "url";
1731
1792
  import { existsSync as existsSync3 } from "fs";
1732
1793
  import { z as z6 } from "zod";
@@ -1918,9 +1979,10 @@ function buildDraftCard(apiKey, owner) {
1918
1979
  }
1919
1980
 
1920
1981
  // src/relay/websocket-relay.ts
1921
- import { randomUUID as randomUUID5 } from "crypto";
1982
+ import { randomUUID as randomUUID6 } from "crypto";
1922
1983
 
1923
1984
  // src/relay/relay-credit.ts
1985
+ var coreConductorFee = loadCoreConfig("economics");
1924
1986
  function lookupCardPrice(registryDb, cardId, skillId) {
1925
1987
  const row = registryDb.prepare("SELECT data FROM capability_cards WHERE id = ?").get(cardId);
1926
1988
  if (!row) return null;
@@ -1967,8 +2029,11 @@ function settleForRelay(creditDb, escrowId, recipientOwner) {
1967
2029
  }
1968
2030
  function calculateConductorFee(totalSubTaskCost) {
1969
2031
  if (totalSubTaskCost <= 0) return 0;
1970
- const fee = Math.ceil(totalSubTaskCost * 0.1);
1971
- return Math.max(1, Math.min(20, fee));
2032
+ const rate = coreConductorFee?.conductor?.sub_task_fee_rate ?? 0.1;
2033
+ const min = coreConductorFee?.conductor?.sub_task_fee_min ?? 1;
2034
+ const max = coreConductorFee?.conductor?.sub_task_fee_max ?? 20;
2035
+ const fee = Math.ceil(totalSubTaskCost * rate);
2036
+ return Math.max(min, Math.min(max, fee));
1972
2037
  }
1973
2038
  function releaseForRelay(creditDb, escrowId) {
1974
2039
  if (escrowId === void 0) return;
@@ -2022,10 +2087,9 @@ function processEscrowSettle(creditDb, escrowId, success, providerAgentId, signa
2022
2087
  if (!escrowRow) {
2023
2088
  throw new Error(`Escrow not found or already settled: ${escrowId}`);
2024
2089
  }
2025
- const NETWORK_FEE_RATE2 = 0.05;
2026
2090
  if (success) {
2027
2091
  settleEscrow(creditDb, escrowId, providerAgentId);
2028
- const networkFee = Math.floor(escrowRow.amount * NETWORK_FEE_RATE2);
2092
+ const networkFee = Math.floor(escrowRow.amount * NETWORK_FEE_RATE);
2029
2093
  const providerAmount = escrowRow.amount - networkFee;
2030
2094
  return {
2031
2095
  escrow_id: escrowId,
@@ -2346,12 +2410,413 @@ function handleJobRelayResponse(opts) {
2346
2410
  }
2347
2411
  }
2348
2412
 
2413
+ // src/session/session-manager.ts
2414
+ import { randomUUID as randomUUID5 } from "crypto";
2415
+
2416
+ // src/session/session-escrow.ts
2417
+ var SessionEscrow = class {
2418
+ constructor(creditDb) {
2419
+ this.creditDb = creditDb;
2420
+ }
2421
+ /** escrowId → { budget, spent } */
2422
+ tracking = /* @__PURE__ */ new Map();
2423
+ /**
2424
+ * Hold the full session budget in escrow.
2425
+ * @returns The escrow ID for tracking.
2426
+ */
2427
+ holdBudget(owner, budget, cardId) {
2428
+ const escrowId = holdEscrow(this.creditDb, owner, budget, cardId);
2429
+ this.tracking.set(escrowId, { budget, spent: 0 });
2430
+ return escrowId;
2431
+ }
2432
+ /**
2433
+ * Record a per-message deduction against the session budget.
2434
+ * Does not touch the DB — tracking is in-memory until settle.
2435
+ */
2436
+ deductMessage(escrowId, rate) {
2437
+ return this.deduct(escrowId, rate);
2438
+ }
2439
+ /**
2440
+ * Record a per-minute deduction against the session budget.
2441
+ */
2442
+ deductMinute(escrowId, rate) {
2443
+ return this.deduct(escrowId, rate);
2444
+ }
2445
+ /**
2446
+ * Settle the session escrow. Pays the provider the actual cost and
2447
+ * refunds the remainder to the requester.
2448
+ */
2449
+ settle(escrowId, providerOwner) {
2450
+ const t = this.tracking.get(escrowId);
2451
+ if (!t) {
2452
+ settleEscrow(this.creditDb, escrowId, providerOwner);
2453
+ return;
2454
+ }
2455
+ if (t.spent <= 0) {
2456
+ releaseEscrow(this.creditDb, escrowId);
2457
+ } else {
2458
+ settleEscrow(this.creditDb, escrowId, providerOwner);
2459
+ }
2460
+ this.tracking.delete(escrowId);
2461
+ }
2462
+ /**
2463
+ * Release the escrow entirely — full refund to requester.
2464
+ */
2465
+ refund(escrowId) {
2466
+ releaseEscrow(this.creditDb, escrowId);
2467
+ this.tracking.delete(escrowId);
2468
+ }
2469
+ /**
2470
+ * Get remaining budget for a session escrow.
2471
+ */
2472
+ getRemainingBudget(escrowId) {
2473
+ const t = this.tracking.get(escrowId);
2474
+ if (!t) return 0;
2475
+ return t.budget - t.spent;
2476
+ }
2477
+ /**
2478
+ * Get total spent for a session escrow.
2479
+ */
2480
+ getSpent(escrowId) {
2481
+ return this.tracking.get(escrowId)?.spent ?? 0;
2482
+ }
2483
+ /**
2484
+ * Check if the budget is exhausted.
2485
+ */
2486
+ isBudgetExhausted(escrowId) {
2487
+ return this.getRemainingBudget(escrowId) <= 0;
2488
+ }
2489
+ /**
2490
+ * Calculate the cost for a single interaction based on pricing model.
2491
+ */
2492
+ calculateCost(pricingModel, rate, durationMinutes) {
2493
+ switch (pricingModel) {
2494
+ case "per_message":
2495
+ return rate;
2496
+ case "per_minute":
2497
+ return Math.ceil(durationMinutes ?? 1) * rate;
2498
+ case "per_session":
2499
+ return rate;
2500
+ }
2501
+ }
2502
+ deduct(escrowId, amount) {
2503
+ const t = this.tracking.get(escrowId);
2504
+ if (!t) {
2505
+ throw new Error(`No session escrow tracking for ${escrowId}`);
2506
+ }
2507
+ t.spent += amount;
2508
+ return { spent: t.spent, remaining: t.budget - t.spent };
2509
+ }
2510
+ };
2511
+
2512
+ // src/session/session-manager.ts
2513
+ var SessionManager = class {
2514
+ sessions = /* @__PURE__ */ new Map();
2515
+ idleTimers = /* @__PURE__ */ new Map();
2516
+ durationTimers = /* @__PURE__ */ new Map();
2517
+ escrow;
2518
+ config;
2519
+ sendToAgent;
2520
+ /** Maps agent connection key → set of session IDs they participate in. */
2521
+ agentSessions = /* @__PURE__ */ new Map();
2522
+ constructor(opts) {
2523
+ this.escrow = new SessionEscrow(opts.creditDb);
2524
+ this.config = opts.config ?? loadSessionConfig();
2525
+ this.sendToAgent = opts.sendToAgent;
2526
+ }
2527
+ /**
2528
+ * Open a new session between requester and provider.
2529
+ */
2530
+ openSession(msg, requesterKey) {
2531
+ const requesterSessions = this.agentSessions.get(requesterKey);
2532
+ if (requesterSessions && requesterSessions.size >= this.config.abuse.max_concurrent_sessions_per_agent) {
2533
+ this.sendToAgent(requesterKey, {
2534
+ type: "session_error",
2535
+ session_id: msg.session_id,
2536
+ code: "MAX_CONCURRENT_SESSIONS",
2537
+ message: `Maximum concurrent sessions (${this.config.abuse.max_concurrent_sessions_per_agent}) reached`
2538
+ });
2539
+ throw new Error("Max concurrent sessions reached");
2540
+ }
2541
+ const escrowId = this.escrow.holdBudget(msg.requester_id, msg.budget, msg.card_id);
2542
+ const now = (/* @__PURE__ */ new Date()).toISOString();
2543
+ const session = {
2544
+ id: msg.session_id,
2545
+ requester_id: msg.requester_id,
2546
+ provider_id: msg.provider_id,
2547
+ skill_id: msg.skill_id,
2548
+ card_id: msg.card_id,
2549
+ status: "open",
2550
+ escrow_id: escrowId,
2551
+ budget: msg.budget,
2552
+ spent: 0,
2553
+ pricing_model: msg.pricing_model,
2554
+ messages: [],
2555
+ created_at: now,
2556
+ updated_at: now
2557
+ };
2558
+ this.sessions.set(session.id, session);
2559
+ this.trackAgentSession(requesterKey, session.id);
2560
+ this.trackAgentSession(msg.provider_id, session.id);
2561
+ this.sendToAgent(requesterKey, {
2562
+ type: "session_ack",
2563
+ session_id: session.id,
2564
+ escrow_id: escrowId,
2565
+ status: "open"
2566
+ });
2567
+ const initialMsg = this.createMessage(session.id, "requester", msg.initial_message);
2568
+ session.messages.push(initialMsg);
2569
+ session.status = "active";
2570
+ session.updated_at = (/* @__PURE__ */ new Date()).toISOString();
2571
+ this.sendToAgent(msg.provider_id, {
2572
+ type: "session_message",
2573
+ session_id: session.id,
2574
+ sender: "requester",
2575
+ content: msg.initial_message
2576
+ });
2577
+ if (session.pricing_model === "per_session") {
2578
+ const cost = this.config.pricing.per_session_flat_rate;
2579
+ this.escrow.deductMessage(escrowId, cost);
2580
+ session.spent = cost;
2581
+ }
2582
+ this.resetIdleTimer(session.id);
2583
+ this.startDurationTimer(session.id);
2584
+ return session;
2585
+ }
2586
+ /**
2587
+ * Route a message within an active session.
2588
+ */
2589
+ routeMessage(msg, senderKey) {
2590
+ const session = this.sessions.get(msg.session_id);
2591
+ if (!session) {
2592
+ this.sendToAgent(senderKey, {
2593
+ type: "session_error",
2594
+ session_id: msg.session_id,
2595
+ code: "SESSION_NOT_FOUND",
2596
+ message: "Session not found"
2597
+ });
2598
+ return;
2599
+ }
2600
+ if (session.status !== "active") {
2601
+ this.sendToAgent(senderKey, {
2602
+ type: "session_error",
2603
+ session_id: msg.session_id,
2604
+ code: "SESSION_NOT_ACTIVE",
2605
+ message: `Session is ${session.status}, not active`
2606
+ });
2607
+ return;
2608
+ }
2609
+ if (session.messages.length >= this.config.pricing.max_messages_per_session) {
2610
+ this.endSessionInternal(session, "budget_exhausted");
2611
+ return;
2612
+ }
2613
+ if (session.pricing_model === "per_message" && msg.sender === "provider") {
2614
+ const rate = this.config.pricing.per_message_base_rate;
2615
+ const { remaining } = this.escrow.deductMessage(session.escrow_id, rate);
2616
+ session.spent += rate;
2617
+ if (remaining <= 0) {
2618
+ const record2 = this.createMessage(session.id, msg.sender, msg.content, msg.metadata);
2619
+ session.messages.push(record2);
2620
+ session.updated_at = (/* @__PURE__ */ new Date()).toISOString();
2621
+ const targetKey2 = this.getCounterpartyKey(session, msg.sender);
2622
+ this.sendToAgent(targetKey2, {
2623
+ type: "session_message",
2624
+ session_id: session.id,
2625
+ sender: msg.sender,
2626
+ content: msg.content,
2627
+ metadata: msg.metadata
2628
+ });
2629
+ this.endSessionInternal(session, "budget_exhausted");
2630
+ return;
2631
+ }
2632
+ }
2633
+ const record = this.createMessage(session.id, msg.sender, msg.content, msg.metadata);
2634
+ session.messages.push(record);
2635
+ session.updated_at = (/* @__PURE__ */ new Date()).toISOString();
2636
+ const targetKey = this.getCounterpartyKey(session, msg.sender);
2637
+ this.sendToAgent(targetKey, {
2638
+ type: "session_message",
2639
+ session_id: session.id,
2640
+ sender: msg.sender,
2641
+ content: msg.content,
2642
+ metadata: msg.metadata
2643
+ });
2644
+ this.resetIdleTimer(session.id);
2645
+ }
2646
+ /**
2647
+ * End a session at the request of either party.
2648
+ */
2649
+ endSession(msg, _senderKey) {
2650
+ const session = this.sessions.get(msg.session_id);
2651
+ if (!session) return;
2652
+ if (session.status === "settled" || session.status === "closed") return;
2653
+ this.endSessionInternal(session, msg.reason);
2654
+ }
2655
+ /**
2656
+ * Handle agent disconnection — end all their active sessions.
2657
+ */
2658
+ handleDisconnect(agentKey) {
2659
+ const sessionIds = this.agentSessions.get(agentKey);
2660
+ if (!sessionIds) return;
2661
+ for (const sessionId of sessionIds) {
2662
+ const session = this.sessions.get(sessionId);
2663
+ if (session && session.status !== "settled" && session.status !== "closed") {
2664
+ this.endSessionInternal(session, "error");
2665
+ }
2666
+ }
2667
+ }
2668
+ /** Get a session by ID. */
2669
+ getSession(sessionId) {
2670
+ return this.sessions.get(sessionId);
2671
+ }
2672
+ /** List sessions, optionally filtered by agent. */
2673
+ listSessions(agentId) {
2674
+ if (!agentId) return Array.from(this.sessions.values());
2675
+ return Array.from(this.sessions.values()).filter(
2676
+ (s) => s.requester_id === agentId || s.provider_id === agentId
2677
+ );
2678
+ }
2679
+ /** Clean up all timers (for graceful shutdown). */
2680
+ shutdown() {
2681
+ for (const timer of this.idleTimers.values()) clearTimeout(timer);
2682
+ for (const timer of this.durationTimers.values()) clearTimeout(timer);
2683
+ this.idleTimers.clear();
2684
+ this.durationTimers.clear();
2685
+ }
2686
+ // -------------------------------------------------------------------------
2687
+ // Internal helpers
2688
+ // -------------------------------------------------------------------------
2689
+ endSessionInternal(session, reason) {
2690
+ session.status = "closing";
2691
+ session.end_reason = reason;
2692
+ session.ended_at = (/* @__PURE__ */ new Date()).toISOString();
2693
+ this.clearTimers(session.id);
2694
+ if (session.spent > 0) {
2695
+ this.escrow.settle(session.escrow_id, session.provider_id);
2696
+ } else {
2697
+ this.escrow.refund(session.escrow_id);
2698
+ }
2699
+ const durationMs = Date.now() - new Date(session.created_at).getTime();
2700
+ const settledMsg = {
2701
+ type: "session_settled",
2702
+ session_id: session.id,
2703
+ total_cost: session.spent,
2704
+ messages_count: session.messages.length,
2705
+ duration_seconds: Math.round(durationMs / 1e3),
2706
+ refunded: session.budget - session.spent
2707
+ };
2708
+ session.status = "settled";
2709
+ session.updated_at = (/* @__PURE__ */ new Date()).toISOString();
2710
+ this.sendToAgent(session.requester_id, settledMsg);
2711
+ this.sendToAgent(session.provider_id, settledMsg);
2712
+ session.status = "closed";
2713
+ this.untrackAgentSession(session.requester_id, session.id);
2714
+ this.untrackAgentSession(session.provider_id, session.id);
2715
+ }
2716
+ resetIdleTimer(sessionId) {
2717
+ const existing = this.idleTimers.get(sessionId);
2718
+ if (existing) clearTimeout(existing);
2719
+ const timer = setTimeout(() => {
2720
+ const session = this.sessions.get(sessionId);
2721
+ if (session && session.status === "active") {
2722
+ this.endSessionInternal(session, "timeout");
2723
+ }
2724
+ }, this.config.timeouts.idle_timeout_ms);
2725
+ this.idleTimers.set(sessionId, timer);
2726
+ }
2727
+ startDurationTimer(sessionId) {
2728
+ const timer = setTimeout(() => {
2729
+ const session = this.sessions.get(sessionId);
2730
+ if (session && session.status !== "settled" && session.status !== "closed") {
2731
+ this.endSessionInternal(session, "timeout");
2732
+ }
2733
+ }, this.config.timeouts.max_session_duration_ms);
2734
+ this.durationTimers.set(sessionId, timer);
2735
+ }
2736
+ clearTimers(sessionId) {
2737
+ const idle = this.idleTimers.get(sessionId);
2738
+ if (idle) {
2739
+ clearTimeout(idle);
2740
+ this.idleTimers.delete(sessionId);
2741
+ }
2742
+ const dur = this.durationTimers.get(sessionId);
2743
+ if (dur) {
2744
+ clearTimeout(dur);
2745
+ this.durationTimers.delete(sessionId);
2746
+ }
2747
+ }
2748
+ createMessage(sessionId, sender, content, metadata) {
2749
+ return {
2750
+ id: randomUUID5(),
2751
+ session_id: sessionId,
2752
+ sender,
2753
+ content,
2754
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2755
+ metadata
2756
+ };
2757
+ }
2758
+ getCounterpartyKey(session, sender) {
2759
+ return sender === "requester" ? session.provider_id : session.requester_id;
2760
+ }
2761
+ trackAgentSession(agentKey, sessionId) {
2762
+ let set = this.agentSessions.get(agentKey);
2763
+ if (!set) {
2764
+ set = /* @__PURE__ */ new Set();
2765
+ this.agentSessions.set(agentKey, set);
2766
+ }
2767
+ set.add(sessionId);
2768
+ }
2769
+ untrackAgentSession(agentKey, sessionId) {
2770
+ const set = this.agentSessions.get(agentKey);
2771
+ if (set) {
2772
+ set.delete(sessionId);
2773
+ if (set.size === 0) this.agentSessions.delete(agentKey);
2774
+ }
2775
+ }
2776
+ };
2777
+
2778
+ // src/session/session-relay.ts
2779
+ function attachSessionHandler(opts) {
2780
+ const { sessionManager } = opts;
2781
+ return {
2782
+ handleSessionMessage(msg, senderKey) {
2783
+ if (!SESSION_MESSAGE_TYPES.has(msg.type)) return false;
2784
+ switch (msg.type) {
2785
+ case "session_open": {
2786
+ const parsed = SessionOpenMessageSchema.parse(msg);
2787
+ sessionManager.openSession(parsed, senderKey);
2788
+ return true;
2789
+ }
2790
+ case "session_message": {
2791
+ const parsed = SessionMessageMessageSchema.parse(msg);
2792
+ sessionManager.routeMessage(parsed, senderKey);
2793
+ return true;
2794
+ }
2795
+ case "session_end": {
2796
+ const parsed = SessionEndMessageSchema.parse(msg);
2797
+ sessionManager.endSession(parsed, senderKey);
2798
+ return true;
2799
+ }
2800
+ // session_ack, session_settled, session_error are relay→agent only
2801
+ // They should not arrive from agents, but we silently absorb them
2802
+ case "session_ack":
2803
+ case "session_settled":
2804
+ case "session_error":
2805
+ return true;
2806
+ default:
2807
+ return false;
2808
+ }
2809
+ }
2810
+ };
2811
+ }
2812
+
2349
2813
  // src/relay/websocket-relay.ts
2350
- var RATE_LIMIT_MAX = 60;
2351
- var RATE_LIMIT_WINDOW_MS = 6e4;
2352
- var RELAY_IDLE_TIMEOUT_MS = 3e4;
2353
- var RELAY_HARD_TIMEOUT_MS = 3e5;
2354
- var RELAY_DISCONNECT_GRACE_MS = RELAY_HARD_TIMEOUT_MS + 3e4;
2814
+ var coreRelay = loadCoreConfig("relay");
2815
+ var RATE_LIMIT_MAX = coreRelay?.rate_limit_max ?? 60;
2816
+ var RATE_LIMIT_WINDOW_MS = coreRelay?.rate_limit_window_ms ?? 6e4;
2817
+ var RELAY_IDLE_TIMEOUT_MS = coreRelay?.relay_idle_timeout_ms ?? 3e4;
2818
+ var RELAY_HARD_TIMEOUT_MS = coreRelay?.relay_hard_timeout_ms ?? 3e5;
2819
+ var RELAY_DISCONNECT_GRACE_MS = coreRelay?.relay_disconnect_grace_ms ?? RELAY_HARD_TIMEOUT_MS + 3e4;
2355
2820
  function readTimeoutOverride(envKey, fallbackMs) {
2356
2821
  const raw = process.env[envKey];
2357
2822
  if (!raw) return fallbackMs;
@@ -2582,7 +3047,7 @@ function registerWebSocketRelay(server, db, creditDb) {
2582
3047
  function logAgentJoined(owner, cardName, cardId) {
2583
3048
  try {
2584
3049
  insertRequestLog(db, {
2585
- id: randomUUID5(),
3050
+ id: randomUUID6(),
2586
3051
  card_id: cardId,
2587
3052
  card_name: cardName,
2588
3053
  requester: owner,
@@ -2600,6 +3065,19 @@ function registerWebSocketRelay(server, db, creditDb) {
2600
3065
  ws.send(JSON.stringify(msg));
2601
3066
  }
2602
3067
  }
3068
+ function sendToAgentByKey(agentKey, msg) {
3069
+ const connKey = resolveConnectionKey(agentKey);
3070
+ const ws = connKey ? connections.get(connKey) : void 0;
3071
+ if (ws && ws.readyState === 1) {
3072
+ ws.send(JSON.stringify(msg));
3073
+ }
3074
+ }
3075
+ const sessionManager = creditDb ? new SessionManager({
3076
+ creditDb,
3077
+ sendToAgent: sendToAgentByKey,
3078
+ isAgentOnline: (key) => !!resolveConnectionKey(key)
3079
+ }) : void 0;
3080
+ const sessionHandler = sessionManager ? attachSessionHandler({ sessionManager }) : void 0;
2603
3081
  function handleRegister(ws, msg) {
2604
3082
  const { owner, card } = msg;
2605
3083
  const existing = connections.get(owner);
@@ -2819,6 +3297,9 @@ function registerWebSocketRelay(server, db, creditDb) {
2819
3297
  }
2820
3298
  }
2821
3299
  markOwnerOffline(owner);
3300
+ if (sessionManager) {
3301
+ sessionManager.handleDisconnect(owner);
3302
+ }
2822
3303
  for (const [reqId, pending] of pendingRequests) {
2823
3304
  if (pending.targetOwner === owner) {
2824
3305
  clearPendingTimers(pending);
@@ -3013,6 +3494,13 @@ function registerWebSocketRelay(server, db, creditDb) {
3013
3494
  handleBalanceSync(socket, msg);
3014
3495
  break;
3015
3496
  default:
3497
+ if (sessionHandler && registeredOwner) {
3498
+ const handled = sessionHandler.handleSessionMessage(
3499
+ msg,
3500
+ registeredOwner
3501
+ );
3502
+ if (handled) break;
3503
+ }
3016
3504
  break;
3017
3505
  }
3018
3506
  })();
@@ -3047,6 +3535,7 @@ function registerWebSocketRelay(server, db, creditDb) {
3047
3535
  pendingRequests.clear();
3048
3536
  rateLimits.clear();
3049
3537
  agentCapacities.clear();
3538
+ if (sessionManager) sessionManager.shutdown();
3050
3539
  },
3051
3540
  setOnAgentOnline: (cb) => {
3052
3541
  onAgentOnlineCallback = cb;
@@ -3063,7 +3552,7 @@ function registerWebSocketRelay(server, db, creditDb) {
3063
3552
 
3064
3553
  // src/identity/guarantor.ts
3065
3554
  import { z as z2 } from "zod";
3066
- import { randomUUID as randomUUID6 } from "crypto";
3555
+ import { randomUUID as randomUUID7 } from "crypto";
3067
3556
  var MAX_AGENTS_PER_GUARANTOR = 10;
3068
3557
  var GUARANTOR_CREDIT_POOL = 50;
3069
3558
  var GuarantorRecordSchema = z2.object({
@@ -3102,7 +3591,7 @@ function registerGuarantor(db, githubLogin) {
3102
3591
  );
3103
3592
  }
3104
3593
  const record = {
3105
- id: randomUUID6(),
3594
+ id: randomUUID7(),
3106
3595
  github_login: githubLogin,
3107
3596
  agent_count: 0,
3108
3597
  credit_pool: GUARANTOR_CREDIT_POOL,
@@ -3176,7 +3665,7 @@ function getAgentGuarantor(db, agentId) {
3176
3665
  function initiateGithubAuth() {
3177
3666
  return {
3178
3667
  auth_url: "https://github.com/login/oauth/authorize?client_id=PLACEHOLDER&scope=read:user",
3179
- state: randomUUID6()
3668
+ state: randomUUID7()
3180
3669
  };
3181
3670
  }
3182
3671
 
@@ -5486,14 +5975,14 @@ function createRegistryServer(opts) {
5486
5975
  return { card_id: target.cardId, skill_id: target.skillId };
5487
5976
  }
5488
5977
  if (!relayClient) {
5489
- const { RelayClient: RelayClient2 } = await import("../../websocket-client-WHEHIYIZ.js");
5978
+ const { RelayClient: RelayClient2 } = await import("../../websocket-client-RT4KLJL4.js");
5490
5979
  relayClient = new RelayClient2({
5491
5980
  registryUrl: relayRegistryUrl,
5492
5981
  owner: relayRequesterOwner,
5493
5982
  token: "batch-token",
5494
5983
  card: {
5495
5984
  spec_version: "1.0",
5496
- id: randomUUID7(),
5985
+ id: randomUUID8(),
5497
5986
  owner: relayRequesterOwner,
5498
5987
  name: relayRequesterOwner,
5499
5988
  description: "Batch requester",
@@ -5508,7 +5997,7 @@ function createRegistryServer(opts) {
5508
5997
  });
5509
5998
  await relayClient.connect();
5510
5999
  }
5511
- const { requestViaRelay: requestViaRelay2 } = await import("../../client-YB3IYO3S.js");
6000
+ const { requestViaRelay: requestViaRelay2 } = await import("../../client-XOSXFC7Q.js");
5512
6001
  return requestViaRelay2(relayClient, {
5513
6002
  targetOwner: target.owner,
5514
6003
  cardId: target.cardId,
@@ -5764,7 +6253,7 @@ function createRegistryServer(opts) {
5764
6253
  if (!opts.creditDb) {
5765
6254
  return reply.code(404).send({ error: "Credit system not enabled" });
5766
6255
  }
5767
- const { getReliabilityMetrics } = await import("../../reliability-metrics-JSOY3PNW.js");
6256
+ const { getReliabilityMetrics } = await import("../../reliability-metrics-22JTZGB4.js");
5768
6257
  const metrics = getReliabilityMetrics(opts.creditDb, owner);
5769
6258
  if (!metrics) {
5770
6259
  return reply.code(404).send({ error: "No reliability data for this provider" });
@@ -5820,7 +6309,7 @@ function createRegistryServer(opts) {
5820
6309
  }
5821
6310
  let reliability = null;
5822
6311
  if (opts.creditDb) {
5823
- const { getReliabilityMetrics } = await import("../../reliability-metrics-JSOY3PNW.js");
6312
+ const { getReliabilityMetrics } = await import("../../reliability-metrics-22JTZGB4.js");
5824
6313
  reliability = getReliabilityMetrics(opts.creditDb, providerIdentity);
5825
6314
  }
5826
6315
  agents.push({
@@ -5976,7 +6465,7 @@ async function stopAnnouncement() {
5976
6465
  }
5977
6466
 
5978
6467
  // src/runtime/resolve-self-cli.ts
5979
- import { execFileSync as execFileSync2 } from "child_process";
6468
+ import { execFileSync } from "child_process";
5980
6469
  import { existsSync as existsSync4, realpathSync } from "fs";
5981
6470
  import { createRequire } from "module";
5982
6471
  import { homedir as homedir2 } from "os";
@@ -5992,7 +6481,7 @@ function resolveSelfCli() {
5992
6481
  nodeExecDir: dirname3(process.execPath),
5993
6482
  exists: existsSync4,
5994
6483
  realpath: realpathSync,
5995
- runWhich: (pathEnv) => execFileSync2("which", ["agentbnb"], {
6484
+ runWhich: (pathEnv) => execFileSync("which", ["agentbnb"], {
5996
6485
  encoding: "utf8",
5997
6486
  env: { ...process.env, PATH: pathEnv }
5998
6487
  }).trim(),
@@ -6113,11 +6602,11 @@ function extractErrorMessage(err) {
6113
6602
  import { spawn as spawn2 } from "child_process";
6114
6603
  import { existsSync as existsSync5, readFileSync as readFileSync3 } from "fs";
6115
6604
  import { join as join4 } from "path";
6116
- import { randomUUID as randomUUID8 } from "crypto";
6605
+ import { randomUUID as randomUUID9 } from "crypto";
6117
6606
  import { Cron as Cron2 } from "croner";
6118
6607
  function buildFallbackRelayCard(owner) {
6119
6608
  return {
6120
- id: randomUUID8(),
6609
+ id: randomUUID9(),
6121
6610
  owner,
6122
6611
  name: owner,
6123
6612
  description: "Agent registered via CLI",
@@ -6286,7 +6775,7 @@ var ServiceCoordinator = class {
6286
6775
  console.log("Conductor mode enabled \u2014 orchestrate/plan skills available via gateway");
6287
6776
  }
6288
6777
  if (opts.conductorEnabled && this.config.conductor?.public) {
6289
- const { buildConductorCard } = await import("../../card-6KL6L4GF.js");
6778
+ const { buildConductorCard } = await import("../../card-VVT3XBOI.js");
6290
6779
  const conductorCard = attachCanonicalAgentId(
6291
6780
  this.runtime.registryDb,
6292
6781
  buildConductorCard(this.config.owner)
@@ -6362,8 +6851,8 @@ var ServiceCoordinator = class {
6362
6851
  }
6363
6852
  }
6364
6853
  if (opts.registryUrl && opts.relay) {
6365
- const { RelayClient: RelayClient2 } = await import("../../websocket-client-WHEHIYIZ.js");
6366
- const { executeCapabilityRequest: executeCapabilityRequest2 } = await import("../../execute-DNRNU3HM.js");
6854
+ const { RelayClient: RelayClient2 } = await import("../../websocket-client-RT4KLJL4.js");
6855
+ const { executeCapabilityRequest: executeCapabilityRequest2 } = await import("../../execute-IEQ3RV7I.js");
6367
6856
  const localCards = listCards(this.runtime.registryDb, this.config.owner);
6368
6857
  const { primaryCard, additionalCards } = buildRelayRegistrationCards(this.config.owner, localCards);
6369
6858
  if (this.config.conductor?.public) {
@@ -6661,11 +7150,11 @@ function sleep2(ms) {
6661
7150
  }
6662
7151
 
6663
7152
  // src/app/agentbnb-service.ts
6664
- import { randomUUID as randomUUID10 } from "crypto";
7153
+ import { randomUUID as randomUUID11 } from "crypto";
6665
7154
 
6666
7155
  // src/credit/escrow-receipt.ts
6667
7156
  import { z as z7 } from "zod";
6668
- import { randomUUID as randomUUID9 } from "crypto";
7157
+ import { randomUUID as randomUUID10 } from "crypto";
6669
7158
  var EscrowReceiptSchema = z7.object({
6670
7159
  requester_owner: z7.string().min(1),
6671
7160
  requester_agent_id: z7.string().optional(),
@@ -6687,7 +7176,7 @@ function createSignedEscrowReceipt(db, privateKey, publicKey, opts) {
6687
7176
  card_id: opts.cardId,
6688
7177
  ...opts.skillId ? { skill_id: opts.skillId } : {},
6689
7178
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
6690
- nonce: randomUUID9()
7179
+ nonce: randomUUID10()
6691
7180
  };
6692
7181
  const signature = signEscrowReceipt(receiptData, privateKey);
6693
7182
  const receipt = {
@@ -6937,13 +7426,13 @@ var AgentBnBService = class {
6937
7426
  if (!this.config.registry) {
6938
7427
  throw new AgentBnBError("Registry is required for relay fallback.", "RELAY_NOT_AVAILABLE");
6939
7428
  }
6940
- const requesterId = `${this.config.owner}:req:${randomUUID10()}`;
7429
+ const requesterId = `${this.config.owner}:req:${randomUUID11()}`;
6941
7430
  const tempRelay = new RelayClient({
6942
7431
  registryUrl: this.config.registry,
6943
7432
  owner: requesterId,
6944
7433
  token: this.config.token,
6945
7434
  card: {
6946
- id: randomUUID10(),
7435
+ id: randomUUID11(),
6947
7436
  owner: requesterId,
6948
7437
  name: requesterId,
6949
7438
  description: "Requester",
@@ -7806,7 +8295,7 @@ function registerDecomposerCard(configDir, owner) {
7806
8295
  "SELECT id FROM capability_cards WHERE owner = ? AND json_extract(data, '$.capability_type') = ?"
7807
8296
  ).get(owner, "task_decomposition");
7808
8297
  if (existing) return;
7809
- const cardId = randomUUID11();
8298
+ const cardId = randomUUID12();
7810
8299
  const now = (/* @__PURE__ */ new Date()).toISOString();
7811
8300
  const card = {
7812
8301
  spec_version: "2.0",
@@ -7873,7 +8362,7 @@ function deriveAgentName(configDir) {
7873
8362
  if (parent && parent !== "." && parent !== ".agentbnb" && parent !== homedir4().split("/").pop()) {
7874
8363
  return parent;
7875
8364
  }
7876
- return `agent-${randomUUID11().slice(0, 8)}`;
8365
+ return `agent-${randomUUID12().slice(0, 8)}`;
7877
8366
  }
7878
8367
  var defaultDeps = { resolveSelfCli, runCommand };
7879
8368
  async function autoOnboard(configDir, deps = defaultDeps) {