agentbnb 5.1.11 → 7.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +245 -39
  2. package/dist/{card-RSGDCHCV.js → card-REW7BSWW.js} +1 -1
  3. package/dist/{chunk-FLY3WIQR.js → chunk-2HSUPCBT.js} +3 -3
  4. package/dist/{chunk-WGZ5AGOX.js → chunk-3CIMVISQ.js} +24 -1
  5. package/dist/{chunk-NH2FIERR.js → chunk-574W3HHE.js} +1 -1
  6. package/dist/{chunk-WTXRY7R2.js → chunk-APEG4QIN.js} +157 -9
  7. package/dist/chunk-BP3L2TET.js +148 -0
  8. package/dist/{chunk-NLAWT4DT.js → chunk-CWYPTQRQ.js} +7 -7
  9. package/dist/{chunk-UKT6H7YT.js → chunk-DUW6RX6I.js} +5 -2
  10. package/dist/chunk-EAD4A4KG.js +430 -0
  11. package/dist/{chunk-QT7TEVNV.js → chunk-EHSHB7TY.js} +23 -1
  12. package/dist/{chunk-B5FTAGFN.js → chunk-ETGOKDFR.js} +75 -75
  13. package/dist/{chunk-5KFI5X7B.js → chunk-F53QQIM2.js} +1 -1
  14. package/dist/{chunk-MLS6IGGG.js → chunk-FK2MDNTB.js} +117 -117
  15. package/dist/{chunk-EGUOAHCW.js → chunk-GO4FVRVN.js} +15 -13
  16. package/dist/{chunk-CRFCWD6V.js → chunk-J2K5S5MX.js} +136 -173
  17. package/dist/chunk-K5FO42YF.js +1136 -0
  18. package/dist/{chunk-DFBX3BBD.js → chunk-KA2VIEGM.js} +211 -16
  19. package/dist/chunk-NWIQJ2CL.js +108 -0
  20. package/dist/chunk-OCSU2S6W.js +168 -0
  21. package/dist/{chunk-QQFBFV4V.js → chunk-PGDBUUGR.js} +60 -19
  22. package/dist/{chunk-QITOPASZ.js → chunk-PSQHUZ7X.js} +1 -1
  23. package/dist/{chunk-C6KPAFCC.js → chunk-PU7LXOQ3.js} +23 -1
  24. package/dist/{chunk-JOY533UH.js → chunk-TW65F5EU.js} +1 -1
  25. package/dist/{chunk-ZX5623ER.js → chunk-VMH2YS2I.js} +1 -1
  26. package/dist/{chunk-XND2DWTZ.js → chunk-VPQ44XKE.js} +2 -2
  27. package/dist/{chunk-CSATDXZC.js → chunk-Y7T6IMM3.js} +1 -1
  28. package/dist/cli/index.js +755 -379
  29. package/dist/{client-T5MTY3CS.js → client-HRYRJKSA.js} +3 -3
  30. package/dist/{conduct-WU3VEXB6.js → conduct-JNYJCDHQ.js} +14 -13
  31. package/dist/conduct-KJUD2RTB.js +22 -0
  32. package/dist/{conductor-mode-ZMTFZGJP.js → conductor-mode-2VVFMKVE.js} +313 -14
  33. package/dist/conductor-mode-VGUU54QI.js +276 -0
  34. package/dist/execute-I4PKSNJM.js +12 -0
  35. package/dist/execute-MOXSSA3Q.js +15 -0
  36. package/dist/index.d.ts +795 -2
  37. package/dist/index.js +861 -111
  38. package/dist/{process-guard-CC7CNRQJ.js → process-guard-QCCBGILS.js} +1 -1
  39. package/dist/publish-capability-TS6CNR5G.js +12 -0
  40. package/dist/reliability-metrics-QG7WC5QK.js +18 -0
  41. package/dist/{request-VOXBFUOG.js → request-E7TA7COA.js} +19 -18
  42. package/dist/{serve-skill-IH7UAJNR.js → serve-skill-HIOWYKRU.js} +13 -11
  43. package/dist/{server-JVQW2TID.js → server-I63CXFX3.js} +17 -16
  44. package/dist/{service-coordinator-EYRDTHL5.js → service-coordinator-XBNT3SMU.js} +369 -260
  45. package/dist/skill-config-FETXPNVP.js +22 -0
  46. package/dist/skills/agentbnb/bootstrap.js +430 -84
  47. package/dist/websocket-client-5MH6QRJK.js +7 -0
  48. package/dist/{websocket-client-WRN3HO73.js → websocket-client-PFGVTXNE.js} +1 -1
  49. package/openclaw.plugin.json +2 -2
  50. package/package.json +2 -1
  51. package/skills/agentbnb/SKILL.md +35 -0
  52. package/skills/agentbnb/bootstrap.ts +126 -8
  53. package/skills/agentbnb/install.sh +49 -9
  54. package/dist/chunk-EANI2N2V.js +0 -309
  55. package/dist/chunk-EPIWHNB2.js +0 -946
  56. package/dist/conduct-6LKIJJKQ.js +0 -21
  57. package/dist/conductor-mode-Q4IIDY5E.js +0 -123
  58. package/dist/execute-4D4ITQCL.js +0 -10
  59. package/dist/execute-T7Y6RKSW.js +0 -13
  60. package/dist/websocket-client-6IIDGXKB.js +0 -7
@@ -1,10 +1,83 @@
1
1
  import {
2
2
  getFeedbackForProvider,
3
3
  signEscrowReceipt
4
- } from "./chunk-CRFCWD6V.js";
4
+ } from "./chunk-K5FO42YF.js";
5
5
  import {
6
6
  AgentBnBError
7
- } from "./chunk-WGZ5AGOX.js";
7
+ } from "./chunk-3CIMVISQ.js";
8
+
9
+ // src/gateway/client.ts
10
+ import { randomUUID } from "crypto";
11
+ async function requestCapability(opts) {
12
+ const { gatewayUrl, token, cardId, params = {}, timeoutMs = 3e5, escrowReceipt, identity } = opts;
13
+ const id = randomUUID();
14
+ const payload = {
15
+ jsonrpc: "2.0",
16
+ id,
17
+ method: "capability.execute",
18
+ params: {
19
+ card_id: cardId,
20
+ ...params,
21
+ ...escrowReceipt ? { escrow_receipt: escrowReceipt } : {}
22
+ }
23
+ };
24
+ const headers = { "Content-Type": "application/json" };
25
+ if (identity) {
26
+ const signature = signEscrowReceipt(payload, identity.privateKey);
27
+ headers["X-Agent-Id"] = identity.agentId;
28
+ headers["X-Agent-Public-Key"] = identity.publicKey;
29
+ headers["X-Agent-Signature"] = signature;
30
+ } else if (token) {
31
+ headers["Authorization"] = `Bearer ${token}`;
32
+ }
33
+ const controller = new AbortController();
34
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
35
+ let response;
36
+ try {
37
+ response = await fetch(`${gatewayUrl}/rpc`, {
38
+ method: "POST",
39
+ headers,
40
+ body: JSON.stringify(payload),
41
+ signal: controller.signal
42
+ });
43
+ } catch (err) {
44
+ clearTimeout(timer);
45
+ const isTimeout = err instanceof Error && err.name === "AbortError";
46
+ throw new AgentBnBError(
47
+ isTimeout ? "Request timed out" : `Network error: ${String(err)}`,
48
+ isTimeout ? "TIMEOUT" : "NETWORK_ERROR"
49
+ );
50
+ } finally {
51
+ clearTimeout(timer);
52
+ }
53
+ const body = await response.json();
54
+ if (body.error) {
55
+ throw new AgentBnBError(body.error.message, `RPC_ERROR_${body.error.code}`);
56
+ }
57
+ return body.result;
58
+ }
59
+ async function requestViaRelay(relay, opts) {
60
+ try {
61
+ return await relay.request({
62
+ targetOwner: opts.targetOwner,
63
+ cardId: opts.cardId,
64
+ skillId: opts.skillId,
65
+ params: opts.params ?? {},
66
+ requester: opts.requester,
67
+ escrowReceipt: opts.escrowReceipt,
68
+ timeoutMs: opts.timeoutMs
69
+ });
70
+ } catch (err) {
71
+ const message = err instanceof Error ? err.message : String(err);
72
+ if (message.includes("timeout")) {
73
+ throw new AgentBnBError(message, "TIMEOUT");
74
+ }
75
+ if (message.includes("offline")) {
76
+ throw new AgentBnBError(message, "AGENT_OFFLINE");
77
+ }
78
+ throw new AgentBnBError(message, "RELAY_ERROR");
79
+ }
80
+ }
8
81
 
9
82
  // src/utils/interpolation.ts
10
83
  function resolvePath(obj, path) {
@@ -181,79 +254,6 @@ function buildReputationMap(db, owners) {
181
254
  return map;
182
255
  }
183
256
 
184
- // src/gateway/client.ts
185
- import { randomUUID } from "crypto";
186
- async function requestCapability(opts) {
187
- const { gatewayUrl, token, cardId, params = {}, timeoutMs = 3e5, escrowReceipt, identity } = opts;
188
- const id = randomUUID();
189
- const payload = {
190
- jsonrpc: "2.0",
191
- id,
192
- method: "capability.execute",
193
- params: {
194
- card_id: cardId,
195
- ...params,
196
- ...escrowReceipt ? { escrow_receipt: escrowReceipt } : {}
197
- }
198
- };
199
- const headers = { "Content-Type": "application/json" };
200
- if (identity) {
201
- const signature = signEscrowReceipt(payload, identity.privateKey);
202
- headers["X-Agent-Id"] = identity.agentId;
203
- headers["X-Agent-Public-Key"] = identity.publicKey;
204
- headers["X-Agent-Signature"] = signature;
205
- } else if (token) {
206
- headers["Authorization"] = `Bearer ${token}`;
207
- }
208
- const controller = new AbortController();
209
- const timer = setTimeout(() => controller.abort(), timeoutMs);
210
- let response;
211
- try {
212
- response = await fetch(`${gatewayUrl}/rpc`, {
213
- method: "POST",
214
- headers,
215
- body: JSON.stringify(payload),
216
- signal: controller.signal
217
- });
218
- } catch (err) {
219
- clearTimeout(timer);
220
- const isTimeout = err instanceof Error && err.name === "AbortError";
221
- throw new AgentBnBError(
222
- isTimeout ? "Request timed out" : `Network error: ${String(err)}`,
223
- isTimeout ? "TIMEOUT" : "NETWORK_ERROR"
224
- );
225
- } finally {
226
- clearTimeout(timer);
227
- }
228
- const body = await response.json();
229
- if (body.error) {
230
- throw new AgentBnBError(body.error.message, `RPC_ERROR_${body.error.code}`);
231
- }
232
- return body.result;
233
- }
234
- async function requestViaRelay(relay, opts) {
235
- try {
236
- return await relay.request({
237
- targetOwner: opts.targetOwner,
238
- cardId: opts.cardId,
239
- skillId: opts.skillId,
240
- params: opts.params ?? {},
241
- requester: opts.requester,
242
- escrowReceipt: opts.escrowReceipt,
243
- timeoutMs: opts.timeoutMs
244
- });
245
- } catch (err) {
246
- const message = err instanceof Error ? err.message : String(err);
247
- if (message.includes("timeout")) {
248
- throw new AgentBnBError(message, "TIMEOUT");
249
- }
250
- if (message.includes("offline")) {
251
- throw new AgentBnBError(message, "AGENT_OFFLINE");
252
- }
253
- throw new AgentBnBError(message, "RELAY_ERROR");
254
- }
255
- }
256
-
257
257
  // src/autonomy/tiers.ts
258
258
  import { randomUUID as randomUUID2 } from "crypto";
259
259
  var DEFAULT_AUTONOMY_CONFIG = {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AgentBnBError
3
- } from "./chunk-WGZ5AGOX.js";
3
+ } from "./chunk-3CIMVISQ.js";
4
4
 
5
5
  // src/credit/signing.ts
6
6
  import { generateKeyPairSync, sign, verify, createPublicKey, createPrivateKey } from "crypto";
@@ -1,6 +1,117 @@
1
1
  import {
2
2
  searchCards
3
- } from "./chunk-NH2FIERR.js";
3
+ } from "./chunk-574W3HHE.js";
4
+
5
+ // src/registry/pricing.ts
6
+ function getPricingStats(db, query) {
7
+ const cards = searchCards(db, query);
8
+ const prices = [];
9
+ const queryLower = query.toLowerCase();
10
+ const queryWords = queryLower.split(/\s+/).filter((w) => w.length > 0);
11
+ for (const card of cards) {
12
+ const v2 = card;
13
+ if (v2.skills && v2.skills.length > 0) {
14
+ for (const skill of v2.skills) {
15
+ const nameMatch = skillMatchesQuery(skill, queryWords);
16
+ if (nameMatch) {
17
+ prices.push(skill.pricing.credits_per_call);
18
+ }
19
+ }
20
+ } else {
21
+ prices.push(card.pricing.credits_per_call);
22
+ }
23
+ }
24
+ if (prices.length === 0) {
25
+ return { min: 0, max: 0, median: 0, mean: 0, count: 0 };
26
+ }
27
+ prices.sort((a, b) => a - b);
28
+ const min = prices[0];
29
+ const max = prices[prices.length - 1];
30
+ const mean = prices.reduce((sum, p) => sum + p, 0) / prices.length;
31
+ const median = computeMedian(prices);
32
+ return { min, max, median, mean, count: prices.length };
33
+ }
34
+ function skillMatchesQuery(skill, queryWords) {
35
+ const text = `${skill.name} ${skill.description}`.toLowerCase();
36
+ return queryWords.some((word) => text.includes(word));
37
+ }
38
+ function computeMedian(sorted) {
39
+ const mid = Math.floor(sorted.length / 2);
40
+ if (sorted.length % 2 === 1) {
41
+ return sorted[mid];
42
+ }
43
+ return (sorted[mid - 1] + sorted[mid]) / 2;
44
+ }
45
+
46
+ // src/discovery/mdns.ts
47
+ import { Bonjour } from "bonjour-service";
48
+ var bonjourInstance = null;
49
+ function getBonjour() {
50
+ if (bonjourInstance === null) {
51
+ bonjourInstance = new Bonjour();
52
+ }
53
+ return bonjourInstance;
54
+ }
55
+ function announceGateway(owner, port, metadata) {
56
+ const bonjour = getBonjour();
57
+ const txt = {
58
+ owner,
59
+ version: "1.0",
60
+ ...metadata
61
+ };
62
+ bonjour.publish({
63
+ name: owner,
64
+ type: "agentbnb",
65
+ port,
66
+ txt
67
+ });
68
+ }
69
+ function discoverLocalAgents(onFound, onDown) {
70
+ const bonjour = getBonjour();
71
+ const browser = bonjour.find({ type: "agentbnb" });
72
+ browser.on("up", (service) => {
73
+ const addresses = service.addresses ?? [];
74
+ const ipv4Addresses = addresses.filter((addr) => !addr.includes(":"));
75
+ const host = ipv4Addresses.length > 0 ? ipv4Addresses[0] : service.host;
76
+ const url = `http://${host}:${service.port}`;
77
+ const owner = service.txt?.owner ?? service.name;
78
+ onFound({
79
+ name: service.name,
80
+ url,
81
+ owner
82
+ });
83
+ });
84
+ if (onDown) {
85
+ browser.on("down", (service) => {
86
+ const addresses = service.addresses ?? [];
87
+ const ipv4Addresses = addresses.filter((addr) => !addr.includes(":"));
88
+ const host = ipv4Addresses.length > 0 ? ipv4Addresses[0] : service.host;
89
+ const url = `http://${host}:${service.port}`;
90
+ const owner = service.txt?.owner ?? service.name;
91
+ onDown({
92
+ name: service.name,
93
+ url,
94
+ owner
95
+ });
96
+ });
97
+ }
98
+ return {
99
+ stop: () => browser.stop()
100
+ };
101
+ }
102
+ async function stopAnnouncement() {
103
+ if (bonjourInstance === null) {
104
+ return;
105
+ }
106
+ const instance = bonjourInstance;
107
+ bonjourInstance = null;
108
+ await new Promise((resolve) => {
109
+ instance.unpublishAll(() => {
110
+ instance.destroy();
111
+ resolve();
112
+ });
113
+ });
114
+ }
4
115
 
5
116
  // src/cli/onboarding.ts
6
117
  import { randomUUID } from "crypto";
@@ -171,124 +282,13 @@ function buildDraftCard(apiKey, owner) {
171
282
  };
172
283
  }
173
284
 
174
- // src/registry/pricing.ts
175
- function getPricingStats(db, query) {
176
- const cards = searchCards(db, query);
177
- const prices = [];
178
- const queryLower = query.toLowerCase();
179
- const queryWords = queryLower.split(/\s+/).filter((w) => w.length > 0);
180
- for (const card of cards) {
181
- const v2 = card;
182
- if (v2.skills && v2.skills.length > 0) {
183
- for (const skill of v2.skills) {
184
- const nameMatch = skillMatchesQuery(skill, queryWords);
185
- if (nameMatch) {
186
- prices.push(skill.pricing.credits_per_call);
187
- }
188
- }
189
- } else {
190
- prices.push(card.pricing.credits_per_call);
191
- }
192
- }
193
- if (prices.length === 0) {
194
- return { min: 0, max: 0, median: 0, mean: 0, count: 0 };
195
- }
196
- prices.sort((a, b) => a - b);
197
- const min = prices[0];
198
- const max = prices[prices.length - 1];
199
- const mean = prices.reduce((sum, p) => sum + p, 0) / prices.length;
200
- const median = computeMedian(prices);
201
- return { min, max, median, mean, count: prices.length };
202
- }
203
- function skillMatchesQuery(skill, queryWords) {
204
- const text = `${skill.name} ${skill.description}`.toLowerCase();
205
- return queryWords.some((word) => text.includes(word));
206
- }
207
- function computeMedian(sorted) {
208
- const mid = Math.floor(sorted.length / 2);
209
- if (sorted.length % 2 === 1) {
210
- return sorted[mid];
211
- }
212
- return (sorted[mid - 1] + sorted[mid]) / 2;
213
- }
214
-
215
- // src/discovery/mdns.ts
216
- import { Bonjour } from "bonjour-service";
217
- var bonjourInstance = null;
218
- function getBonjour() {
219
- if (bonjourInstance === null) {
220
- bonjourInstance = new Bonjour();
221
- }
222
- return bonjourInstance;
223
- }
224
- function announceGateway(owner, port, metadata) {
225
- const bonjour = getBonjour();
226
- const txt = {
227
- owner,
228
- version: "1.0",
229
- ...metadata
230
- };
231
- bonjour.publish({
232
- name: owner,
233
- type: "agentbnb",
234
- port,
235
- txt
236
- });
237
- }
238
- function discoverLocalAgents(onFound, onDown) {
239
- const bonjour = getBonjour();
240
- const browser = bonjour.find({ type: "agentbnb" });
241
- browser.on("up", (service) => {
242
- const addresses = service.addresses ?? [];
243
- const ipv4Addresses = addresses.filter((addr) => !addr.includes(":"));
244
- const host = ipv4Addresses.length > 0 ? ipv4Addresses[0] : service.host;
245
- const url = `http://${host}:${service.port}`;
246
- const owner = service.txt?.owner ?? service.name;
247
- onFound({
248
- name: service.name,
249
- url,
250
- owner
251
- });
252
- });
253
- if (onDown) {
254
- browser.on("down", (service) => {
255
- const addresses = service.addresses ?? [];
256
- const ipv4Addresses = addresses.filter((addr) => !addr.includes(":"));
257
- const host = ipv4Addresses.length > 0 ? ipv4Addresses[0] : service.host;
258
- const url = `http://${host}:${service.port}`;
259
- const owner = service.txt?.owner ?? service.name;
260
- onDown({
261
- name: service.name,
262
- url,
263
- owner
264
- });
265
- });
266
- }
267
- return {
268
- stop: () => browser.stop()
269
- };
270
- }
271
- async function stopAnnouncement() {
272
- if (bonjourInstance === null) {
273
- return;
274
- }
275
- const instance = bonjourInstance;
276
- bonjourInstance = null;
277
- await new Promise((resolve) => {
278
- instance.unpublishAll(() => {
279
- instance.destroy();
280
- resolve();
281
- });
282
- });
283
- }
284
-
285
285
  export {
286
- KNOWN_API_KEYS,
287
- detectApiKeys,
288
- detectOpenPorts,
289
- buildDraftCard,
290
286
  getPricingStats,
291
287
  announceGateway,
292
288
  discoverLocalAgents,
293
- stopAnnouncement
289
+ stopAnnouncement,
290
+ KNOWN_API_KEYS,
291
+ detectApiKeys,
292
+ detectOpenPorts,
293
+ buildDraftCard
294
294
  };
@@ -1,26 +1,26 @@
1
+ import {
2
+ fetchRemoteCards
3
+ } from "./chunk-VMH2YS2I.js";
1
4
  import {
2
5
  createPendingRequest,
3
6
  getAutonomyTier,
4
7
  insertAuditEvent
5
- } from "./chunk-CSATDXZC.js";
6
- import {
7
- fetchRemoteCards
8
- } from "./chunk-ZX5623ER.js";
8
+ } from "./chunk-Y7T6IMM3.js";
9
9
  import {
10
10
  searchCards
11
- } from "./chunk-NH2FIERR.js";
12
- import {
13
- requestCapability
14
- } from "./chunk-XND2DWTZ.js";
15
- import {
16
- findPeer
17
- } from "./chunk-5AH3CMOX.js";
11
+ } from "./chunk-574W3HHE.js";
18
12
  import {
19
13
  getBalance,
20
14
  holdEscrow,
21
15
  releaseEscrow,
22
16
  settleEscrow
23
- } from "./chunk-EANI2N2V.js";
17
+ } from "./chunk-J2K5S5MX.js";
18
+ import {
19
+ requestCapability
20
+ } from "./chunk-VPQ44XKE.js";
21
+ import {
22
+ findPeer
23
+ } from "./chunk-5AH3CMOX.js";
24
24
 
25
25
  // src/credit/budget.ts
26
26
  var DEFAULT_BUDGET_CONFIG = {
@@ -97,12 +97,14 @@ function scorePeers(candidates, selfOwner) {
97
97
  const idleRate = internal?.["idle_rate"];
98
98
  return typeof idleRate === "number" ? idleRate : 1;
99
99
  });
100
+ const loadFactors = eligible.map((c) => c.loadFactor ?? 1);
100
101
  const normSuccess = minMaxNormalize(successRates);
101
102
  const normCost = minMaxNormalize(costEfficiencies);
102
103
  const normIdle = minMaxNormalize(idleRates);
104
+ const normLoad = minMaxNormalize(loadFactors);
103
105
  const scored = eligible.map((c, i) => ({
104
106
  ...c,
105
- rawScore: (normSuccess[i] ?? 0) * (normCost[i] ?? 0) * (normIdle[i] ?? 0)
107
+ rawScore: (normSuccess[i] ?? 0) * (normCost[i] ?? 0) * (normIdle[i] ?? 0) * (normLoad[i] ?? 0)
106
108
  }));
107
109
  scored.sort((a, b) => b.rawScore - a.rawScore);
108
110
  return scored;