agentbnb 8.2.1 → 8.2.3
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.
- package/dist/{chunk-7Q2XUXSA.js → chunk-4IPJJRTP.js} +1 -1
- package/dist/{chunk-EZVOG7QS.js → chunk-CKOOVZOI.js} +15 -18
- package/dist/chunk-CQFBNTGT.js +145 -0
- package/dist/{chunk-WKWJWKX7.js → chunk-DYQOFGGI.js} +155 -445
- package/dist/{chunk-NP55V7RQ.js → chunk-EG6RS4JC.js} +70 -46
- package/dist/{chunk-KBQNTUTN.js → chunk-LKLKYXLV.js} +1 -1
- package/dist/{chunk-STJLWMXH.js → chunk-MCED4GDW.js} +467 -98
- package/dist/{chunk-GWMMYVLL.js → chunk-MWOXW7JQ.js} +7 -7
- package/dist/{chunk-GJETGML6.js → chunk-QCGIG7WW.js} +4 -6
- package/dist/{chunk-UYCD3JBZ.js → chunk-QHZGOG3O.js} +148 -46
- package/dist/{chunk-JLNHMNES.js → chunk-RYISHSHB.js} +286 -1
- package/dist/{chunk-SRBVKO2V.js → chunk-S3V6R3EN.js} +66 -39
- package/dist/chunk-TUCEDQGM.js +44 -0
- package/dist/{chunk-RBXTWWUH.js → chunk-WNXXLCV5.js} +1 -1
- package/dist/{chunk-LOUEJI6X.js → chunk-XBGVQMQJ.js} +71 -47
- package/dist/{chunk-DEWY7OQK.js → chunk-Z2GEFFDO.js} +1 -1
- package/dist/cli/index.js +38 -74
- package/dist/{client-66TFS7RS.js → client-XOLP5IUZ.js} +1 -1
- package/dist/{conduct-A6COHLHY.js → conduct-AZFLNUX3.js} +9 -10
- package/dist/{conduct-IUVAXUAV.js → conduct-VPUYTNEA.js} +9 -10
- package/dist/{conductor-mode-L2MB44BW.js → conductor-mode-PLTB6MS3.js} +6 -7
- package/dist/{conductor-mode-D5TFQW5L.js → conductor-mode-WKB42PYM.js} +6 -3
- package/dist/{execute-WOS457HW.js → execute-NNDCXTN4.js} +3 -2
- package/dist/{execute-5AWLARB5.js → execute-RIRHTIBU.js} +5 -4
- package/dist/index.d.ts +5069 -0
- package/dist/index.js +208 -610
- package/dist/{publish-capability-JJCBBMSX.js → publish-capability-QDR2QIZ2.js} +2 -2
- package/dist/{request-6YQLA7K3.js → request-OERS5BE7.js} +71 -33
- package/dist/{serve-skill-X7TZSILV.js → serve-skill-E6EJQYAK.js} +9 -8
- package/dist/{server-5TSP4DBX.js → server-46VEG2W7.js} +10 -14
- package/dist/{service-coordinator-WTUSMPY6.js → service-coordinator-KMSA6BST.js} +77 -32
- package/dist/skills/agentbnb/bootstrap.js +150 -62
- package/package.json +18 -12
- package/skills/agentbnb/install.sh +0 -0
- package/dist/chunk-BZOJ7HBT.js +0 -170
- package/dist/chunk-KF3TZHA5.js +0 -91
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RelayClient,
|
|
3
|
+
RelayMessageSchema
|
|
4
|
+
} from "../../chunk-3LWBH7P3.js";
|
|
1
5
|
import {
|
|
2
6
|
AutoRequestor,
|
|
3
7
|
BudgetController,
|
|
@@ -5,23 +9,19 @@ import {
|
|
|
5
9
|
DEFAULT_AUTONOMY_CONFIG,
|
|
6
10
|
DEFAULT_BUDGET_CONFIG,
|
|
7
11
|
ORCHESTRATION_FEE,
|
|
8
|
-
buildReputationMap,
|
|
9
|
-
computeReputation,
|
|
10
12
|
decompose,
|
|
11
|
-
fetchRemoteCards,
|
|
12
|
-
filterCards,
|
|
13
13
|
getAutonomyTier,
|
|
14
14
|
insertAuditEvent,
|
|
15
15
|
interpolateObject,
|
|
16
16
|
listPendingRequests,
|
|
17
17
|
matchSubTasks,
|
|
18
|
-
mergeResults,
|
|
19
18
|
orchestrate,
|
|
19
|
+
resolvePendingRequest
|
|
20
|
+
} from "../../chunk-DYQOFGGI.js";
|
|
21
|
+
import {
|
|
20
22
|
requestCapability,
|
|
21
|
-
requestViaRelay
|
|
22
|
-
|
|
23
|
-
searchCards
|
|
24
|
-
} from "../../chunk-WKWJWKX7.js";
|
|
23
|
+
requestViaRelay
|
|
24
|
+
} from "../../chunk-CKOOVZOI.js";
|
|
25
25
|
import {
|
|
26
26
|
loadPeers
|
|
27
27
|
} from "../../chunk-HLUEOLSZ.js";
|
|
@@ -30,10 +30,14 @@ import {
|
|
|
30
30
|
executeCapabilityRequest,
|
|
31
31
|
releaseRequesterEscrow,
|
|
32
32
|
settleRequesterEscrow
|
|
33
|
-
} from "../../chunk-
|
|
33
|
+
} from "../../chunk-EG6RS4JC.js";
|
|
34
34
|
import {
|
|
35
35
|
bootstrapAgent,
|
|
36
|
-
|
|
36
|
+
buildReputationMap,
|
|
37
|
+
computeReputation,
|
|
38
|
+
confirmEscrowDebit,
|
|
39
|
+
fetchRemoteCards,
|
|
40
|
+
filterCards,
|
|
37
41
|
getActivityFeed,
|
|
38
42
|
getBalance,
|
|
39
43
|
getCard,
|
|
@@ -51,21 +55,26 @@ import {
|
|
|
51
55
|
insertFeedback,
|
|
52
56
|
insertRequestLog,
|
|
53
57
|
listCards,
|
|
54
|
-
loadKeyPair,
|
|
55
58
|
lookupAgent,
|
|
59
|
+
mergeResults,
|
|
56
60
|
migrateOwner,
|
|
57
61
|
openCreditDb,
|
|
58
62
|
openDatabase,
|
|
59
63
|
releaseEscrow,
|
|
60
|
-
|
|
64
|
+
searchCards,
|
|
61
65
|
settleEscrow,
|
|
62
|
-
signEscrowReceipt,
|
|
63
66
|
updateCard,
|
|
64
67
|
updateSkillAvailability,
|
|
65
|
-
updateSkillIdleRate
|
|
66
|
-
|
|
67
|
-
} from "../../chunk-STJLWMXH.js";
|
|
68
|
+
updateSkillIdleRate
|
|
69
|
+
} from "../../chunk-MCED4GDW.js";
|
|
68
70
|
import "../../chunk-NWIQJ2CL.js";
|
|
71
|
+
import {
|
|
72
|
+
generateKeyPair,
|
|
73
|
+
loadKeyPair,
|
|
74
|
+
saveKeyPair,
|
|
75
|
+
signEscrowReceipt,
|
|
76
|
+
verifyEscrowReceipt
|
|
77
|
+
} from "../../chunk-EJKW57ZV.js";
|
|
69
78
|
import {
|
|
70
79
|
getConfigDir,
|
|
71
80
|
loadConfig
|
|
@@ -74,17 +83,13 @@ import {
|
|
|
74
83
|
AgentBnBError,
|
|
75
84
|
AnyCardSchema
|
|
76
85
|
} from "../../chunk-WVY2W7AA.js";
|
|
77
|
-
import {
|
|
78
|
-
RelayClient,
|
|
79
|
-
RelayMessageSchema
|
|
80
|
-
} from "../../chunk-3LWBH7P3.js";
|
|
81
86
|
|
|
82
87
|
// skills/agentbnb/bootstrap.ts
|
|
83
88
|
import { join as join7, basename as basename2, dirname as dirname3 } from "path";
|
|
84
89
|
import { homedir as homedir4 } from "os";
|
|
85
90
|
import { exec } from "child_process";
|
|
86
91
|
import { promisify as promisify2 } from "util";
|
|
87
|
-
import { randomUUID as
|
|
92
|
+
import { randomUUID as randomUUID11 } from "crypto";
|
|
88
93
|
|
|
89
94
|
// src/runtime/process-guard.ts
|
|
90
95
|
import { dirname, join } from "path";
|
|
@@ -1272,7 +1277,7 @@ var AgentRuntime = class {
|
|
|
1272
1277
|
}
|
|
1273
1278
|
const modes = /* @__PURE__ */ new Map();
|
|
1274
1279
|
if (this.conductorEnabled) {
|
|
1275
|
-
const { ConductorMode } = await import("../../conductor-mode-
|
|
1280
|
+
const { ConductorMode } = await import("../../conductor-mode-WKB42PYM.js");
|
|
1276
1281
|
const { registerConductorCard, CONDUCTOR_OWNER } = await import("../../card-EX2EYGCZ.js");
|
|
1277
1282
|
const { loadPeers: loadPeers2 } = await import("../../peers-CJ7T4RJO.js");
|
|
1278
1283
|
registerConductorCard(this.registryDb);
|
|
@@ -1585,6 +1590,7 @@ import swaggerUi from "@fastify/swagger-ui";
|
|
|
1585
1590
|
import fastifyStatic from "@fastify/static";
|
|
1586
1591
|
import fastifyWebsocket from "@fastify/websocket";
|
|
1587
1592
|
import { join as join3, dirname as dirname2 } from "path";
|
|
1593
|
+
import { randomUUID as randomUUID7 } from "crypto";
|
|
1588
1594
|
import { fileURLToPath } from "url";
|
|
1589
1595
|
import { existsSync as existsSync4 } from "fs";
|
|
1590
1596
|
import { z as z7 } from "zod";
|
|
@@ -5533,15 +5539,60 @@ function createRegistryServer(opts) {
|
|
|
5533
5539
|
});
|
|
5534
5540
|
}
|
|
5535
5541
|
const { requests, strategy, total_budget } = parseResult.data;
|
|
5536
|
-
const
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5542
|
+
const host = request.headers.host ?? request.hostname;
|
|
5543
|
+
const relayRegistryUrl = `${request.protocol}://${host}`;
|
|
5544
|
+
const relayRequesterOwner = `${owner}:batch:${Date.now()}`;
|
|
5545
|
+
let relayClient;
|
|
5546
|
+
try {
|
|
5547
|
+
const batchResult = await executeCapabilityBatch({
|
|
5548
|
+
requests,
|
|
5549
|
+
strategy,
|
|
5550
|
+
total_budget,
|
|
5551
|
+
registryDb: db,
|
|
5552
|
+
creditDb: opts.creditDb,
|
|
5553
|
+
owner,
|
|
5554
|
+
registryUrl: relayRegistryUrl,
|
|
5555
|
+
dispatchRequest: async ({ target, params, requester }) => {
|
|
5556
|
+
if (!target.via_relay) {
|
|
5557
|
+
return { card_id: target.cardId, skill_id: target.skillId };
|
|
5558
|
+
}
|
|
5559
|
+
if (!relayClient) {
|
|
5560
|
+
const { RelayClient: RelayClient2 } = await import("../../websocket-client-4Z5P54RU.js");
|
|
5561
|
+
relayClient = new RelayClient2({
|
|
5562
|
+
registryUrl: relayRegistryUrl,
|
|
5563
|
+
owner: relayRequesterOwner,
|
|
5564
|
+
token: "batch-token",
|
|
5565
|
+
card: {
|
|
5566
|
+
spec_version: "1.0",
|
|
5567
|
+
id: randomUUID7(),
|
|
5568
|
+
owner: relayRequesterOwner,
|
|
5569
|
+
name: relayRequesterOwner,
|
|
5570
|
+
description: "Batch requester",
|
|
5571
|
+
level: 1,
|
|
5572
|
+
inputs: [],
|
|
5573
|
+
outputs: [],
|
|
5574
|
+
pricing: { credits_per_call: 1 },
|
|
5575
|
+
availability: { online: false }
|
|
5576
|
+
},
|
|
5577
|
+
onRequest: async () => ({ error: { code: -32601, message: "Batch requester does not serve capabilities" } }),
|
|
5578
|
+
silent: true
|
|
5579
|
+
});
|
|
5580
|
+
await relayClient.connect();
|
|
5581
|
+
}
|
|
5582
|
+
const { requestViaRelay: requestViaRelay2 } = await import("../../client-XOLP5IUZ.js");
|
|
5583
|
+
return requestViaRelay2(relayClient, {
|
|
5584
|
+
targetOwner: target.owner,
|
|
5585
|
+
cardId: target.cardId,
|
|
5586
|
+
skillId: target.skillId,
|
|
5587
|
+
params: { ...params, requester },
|
|
5588
|
+
requester
|
|
5589
|
+
});
|
|
5590
|
+
}
|
|
5591
|
+
});
|
|
5592
|
+
return reply.send(batchResult);
|
|
5593
|
+
} finally {
|
|
5594
|
+
relayClient?.disconnect();
|
|
5595
|
+
}
|
|
5545
5596
|
});
|
|
5546
5597
|
if (opts.ownerApiKey && opts.ownerName) {
|
|
5547
5598
|
const ownerApiKey = opts.ownerApiKey;
|
|
@@ -6123,7 +6174,7 @@ function extractErrorMessage(err) {
|
|
|
6123
6174
|
import { spawn as spawn2 } from "child_process";
|
|
6124
6175
|
import { existsSync as existsSync6, readFileSync as readFileSync4 } from "fs";
|
|
6125
6176
|
import { join as join5 } from "path";
|
|
6126
|
-
import { randomUUID as
|
|
6177
|
+
import { randomUUID as randomUUID8 } from "crypto";
|
|
6127
6178
|
var ServiceCoordinator = class {
|
|
6128
6179
|
config;
|
|
6129
6180
|
guard;
|
|
@@ -6326,10 +6377,10 @@ var ServiceCoordinator = class {
|
|
|
6326
6377
|
}
|
|
6327
6378
|
if (opts.registryUrl && opts.relay) {
|
|
6328
6379
|
const { RelayClient: RelayClient2 } = await import("../../websocket-client-4Z5P54RU.js");
|
|
6329
|
-
const { executeCapabilityRequest: executeCapabilityRequest2 } = await import("../../execute-
|
|
6380
|
+
const { executeCapabilityRequest: executeCapabilityRequest2 } = await import("../../execute-NNDCXTN4.js");
|
|
6330
6381
|
const cards = listCards(this.runtime.registryDb, this.config.owner);
|
|
6331
6382
|
const card = cards[0] ?? {
|
|
6332
|
-
id:
|
|
6383
|
+
id: randomUUID8(),
|
|
6333
6384
|
owner: this.config.owner,
|
|
6334
6385
|
name: this.config.owner,
|
|
6335
6386
|
description: "Agent registered via CLI",
|
|
@@ -6635,11 +6686,11 @@ function sleep2(ms) {
|
|
|
6635
6686
|
}
|
|
6636
6687
|
|
|
6637
6688
|
// src/app/agentbnb-service.ts
|
|
6638
|
-
import { randomUUID as
|
|
6689
|
+
import { randomUUID as randomUUID10 } from "crypto";
|
|
6639
6690
|
|
|
6640
6691
|
// src/credit/escrow-receipt.ts
|
|
6641
6692
|
import { z as z8 } from "zod";
|
|
6642
|
-
import { randomUUID as
|
|
6693
|
+
import { randomUUID as randomUUID9 } from "crypto";
|
|
6643
6694
|
var EscrowReceiptSchema = z8.object({
|
|
6644
6695
|
requester_owner: z8.string().min(1),
|
|
6645
6696
|
requester_agent_id: z8.string().optional(),
|
|
@@ -6661,7 +6712,7 @@ function createSignedEscrowReceipt(db, privateKey, publicKey, opts) {
|
|
|
6661
6712
|
card_id: opts.cardId,
|
|
6662
6713
|
...opts.skillId ? { skill_id: opts.skillId } : {},
|
|
6663
6714
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6664
|
-
nonce:
|
|
6715
|
+
nonce: randomUUID9()
|
|
6665
6716
|
};
|
|
6666
6717
|
const signature = signEscrowReceipt(receiptData, privateKey);
|
|
6667
6718
|
const receipt = {
|
|
@@ -6903,13 +6954,13 @@ var AgentBnBService = class {
|
|
|
6903
6954
|
if (!this.config.registry) {
|
|
6904
6955
|
throw new AgentBnBError("Registry is required for relay fallback.", "RELAY_NOT_AVAILABLE");
|
|
6905
6956
|
}
|
|
6906
|
-
const requesterId = `${this.config.owner}:req:${
|
|
6957
|
+
const requesterId = `${this.config.owner}:req:${randomUUID10()}`;
|
|
6907
6958
|
const tempRelay = new RelayClient({
|
|
6908
6959
|
registryUrl: this.config.registry,
|
|
6909
6960
|
owner: requesterId,
|
|
6910
6961
|
token: this.config.token,
|
|
6911
6962
|
card: {
|
|
6912
|
-
id:
|
|
6963
|
+
id: randomUUID10(),
|
|
6913
6964
|
owner: requesterId,
|
|
6914
6965
|
name: requesterId,
|
|
6915
6966
|
description: "Requester",
|
|
@@ -7129,12 +7180,23 @@ async function handleRequest(args, ctx) {
|
|
|
7129
7180
|
} finally {
|
|
7130
7181
|
db.close();
|
|
7131
7182
|
}
|
|
7183
|
+
let identityAuth;
|
|
7184
|
+
try {
|
|
7185
|
+
const keys = loadKeyPair(ctx.configDir);
|
|
7186
|
+
identityAuth = {
|
|
7187
|
+
agentId: ctx.identity.agent_id,
|
|
7188
|
+
publicKey: ctx.identity.public_key,
|
|
7189
|
+
privateKey: keys.privateKey
|
|
7190
|
+
};
|
|
7191
|
+
} catch {
|
|
7192
|
+
}
|
|
7132
7193
|
if (localCard && localCard.owner === ctx.config.owner) {
|
|
7133
7194
|
const result = await requestCapability({
|
|
7134
7195
|
gatewayUrl: ctx.config.gateway_url,
|
|
7135
7196
|
token: ctx.config.token,
|
|
7136
7197
|
cardId,
|
|
7137
|
-
params: { ...args.params ?? {}, ...args.skill_id ? { skill_id: args.skill_id } : {}, requester: ctx.config.owner }
|
|
7198
|
+
params: { ...args.params ?? {}, ...args.skill_id ? { skill_id: args.skill_id } : {}, requester: ctx.config.owner },
|
|
7199
|
+
identity: identityAuth
|
|
7138
7200
|
});
|
|
7139
7201
|
return {
|
|
7140
7202
|
content: [{ type: "text", text: JSON.stringify({ success: true, result }, null, 2) }]
|
|
@@ -7164,32 +7226,58 @@ async function handleRequest(args, ctx) {
|
|
|
7164
7226
|
const targetOwner = remoteCard["owner"] ?? remoteCard["agent_name"];
|
|
7165
7227
|
const gatewayUrl = remoteCard["gateway_url"];
|
|
7166
7228
|
if (gatewayUrl) {
|
|
7167
|
-
|
|
7168
|
-
const
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
|
|
7172
|
-
}
|
|
7173
|
-
|
|
7174
|
-
|
|
7229
|
+
let remoteCost = 0;
|
|
7230
|
+
const remoteSkills = remoteCard["skills"];
|
|
7231
|
+
if (Array.isArray(remoteSkills)) {
|
|
7232
|
+
const matchedSkill = args.skill_id ? remoteSkills.find((s) => s.id === args.skill_id) : remoteSkills[0];
|
|
7233
|
+
remoteCost = matchedSkill?.pricing?.credits_per_call ?? 0;
|
|
7234
|
+
} else {
|
|
7235
|
+
const remotePricing = remoteCard["pricing"];
|
|
7236
|
+
remoteCost = remotePricing?.credits_per_call ?? 0;
|
|
7237
|
+
}
|
|
7238
|
+
if (remoteCost > 0) {
|
|
7239
|
+
const creditDb = openCreditDb(ctx.config.credit_db_path);
|
|
7240
|
+
creditDb.pragma("busy_timeout = 5000");
|
|
7241
|
+
try {
|
|
7242
|
+
const keys = loadKeyPair(ctx.configDir);
|
|
7243
|
+
const { escrowId, receipt } = createSignedEscrowReceipt(creditDb, keys.privateKey, keys.publicKey, {
|
|
7244
|
+
owner: ctx.config.owner,
|
|
7245
|
+
agent_id: ctx.identity.agent_id,
|
|
7246
|
+
amount: remoteCost,
|
|
7247
|
+
cardId,
|
|
7248
|
+
skillId: args.skill_id
|
|
7249
|
+
});
|
|
7250
|
+
try {
|
|
7251
|
+
const result = await requestCapability({
|
|
7252
|
+
gatewayUrl,
|
|
7253
|
+
token: ctx.config.token ?? "",
|
|
7254
|
+
cardId,
|
|
7255
|
+
params: { ...args.params ?? {}, ...args.skill_id ? { skill_id: args.skill_id } : {}, requester: ctx.config.owner },
|
|
7256
|
+
identity: identityAuth,
|
|
7257
|
+
escrowReceipt: receipt
|
|
7258
|
+
});
|
|
7259
|
+
confirmEscrowDebit(creditDb, escrowId);
|
|
7260
|
+
return {
|
|
7261
|
+
content: [{ type: "text", text: JSON.stringify({ success: true, result }, null, 2) }]
|
|
7262
|
+
};
|
|
7263
|
+
} catch (execErr) {
|
|
7264
|
+
releaseEscrow(creditDb, escrowId);
|
|
7265
|
+
throw execErr;
|
|
7266
|
+
}
|
|
7267
|
+
} finally {
|
|
7268
|
+
creditDb.close();
|
|
7269
|
+
}
|
|
7270
|
+
} else {
|
|
7175
7271
|
const result = await requestCapability({
|
|
7176
7272
|
gatewayUrl,
|
|
7177
|
-
token: "",
|
|
7273
|
+
token: ctx.config.token ?? "",
|
|
7178
7274
|
cardId,
|
|
7179
7275
|
params: { ...args.params ?? {}, ...args.skill_id ? { skill_id: args.skill_id } : {}, requester: ctx.config.owner },
|
|
7180
|
-
identity:
|
|
7181
|
-
agentId: ctx.identity.agent_id,
|
|
7182
|
-
publicKey: ctx.identity.public_key,
|
|
7183
|
-
privateKey: keys.privateKey
|
|
7184
|
-
}
|
|
7276
|
+
identity: identityAuth
|
|
7185
7277
|
});
|
|
7186
|
-
await ledger.settle(escrowId, targetOwner ?? "unknown");
|
|
7187
7278
|
return {
|
|
7188
|
-
content: [{ type: "text", text: JSON.stringify({ success: true, result
|
|
7279
|
+
content: [{ type: "text", text: JSON.stringify({ success: true, result }, null, 2) }]
|
|
7189
7280
|
};
|
|
7190
|
-
} catch (err) {
|
|
7191
|
-
await ledger.release(escrowId);
|
|
7192
|
-
throw err;
|
|
7193
7281
|
}
|
|
7194
7282
|
}
|
|
7195
7283
|
if (targetOwner) {
|
|
@@ -7714,7 +7802,7 @@ function registerDecomposerCard(configDir, owner) {
|
|
|
7714
7802
|
"SELECT id FROM capability_cards WHERE owner = ? AND json_extract(data, '$.capability_type') = ?"
|
|
7715
7803
|
).get(owner, "task_decomposition");
|
|
7716
7804
|
if (existing) return;
|
|
7717
|
-
const cardId =
|
|
7805
|
+
const cardId = randomUUID11();
|
|
7718
7806
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
7719
7807
|
const card = {
|
|
7720
7808
|
spec_version: "2.0",
|
|
@@ -7781,7 +7869,7 @@ function deriveAgentName(configDir) {
|
|
|
7781
7869
|
if (parent && parent !== "." && parent !== ".agentbnb" && parent !== homedir4().split("/").pop()) {
|
|
7782
7870
|
return parent;
|
|
7783
7871
|
}
|
|
7784
|
-
return `agent-${
|
|
7872
|
+
return `agent-${randomUUID11().slice(0, 8)}`;
|
|
7785
7873
|
}
|
|
7786
7874
|
var defaultDeps = { resolveSelfCli, runCommand };
|
|
7787
7875
|
async function autoOnboard(configDir, deps = defaultDeps) {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"workspaces": [
|
|
4
4
|
"packages/*"
|
|
5
5
|
],
|
|
6
|
-
"version": "8.2.
|
|
6
|
+
"version": "8.2.3",
|
|
7
7
|
"description": "P2P Agent Capability Sharing Protocol — Airbnb for AI agent pipelines",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "dist/index.js",
|
|
@@ -32,6 +32,18 @@
|
|
|
32
32
|
"import": "./dist/identity/index.js"
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsup",
|
|
37
|
+
"build:hub": "cd hub && pnpm install && pnpm build",
|
|
38
|
+
"build:all": "pnpm build && pnpm build:hub",
|
|
39
|
+
"dev": "tsx watch src/cli/index.ts",
|
|
40
|
+
"test": "vitest run",
|
|
41
|
+
"test:run": "vitest run",
|
|
42
|
+
"test:watch": "vitest",
|
|
43
|
+
"lint": "eslint src/",
|
|
44
|
+
"typecheck": "tsc --noEmit",
|
|
45
|
+
"prepublishOnly": "pnpm run build && pnpm run typecheck && pnpm run test:run"
|
|
46
|
+
},
|
|
35
47
|
"keywords": [
|
|
36
48
|
"ai",
|
|
37
49
|
"agent",
|
|
@@ -82,15 +94,9 @@
|
|
|
82
94
|
"engines": {
|
|
83
95
|
"node": ">=20.0.0"
|
|
84
96
|
},
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
"dev": "tsx watch src/cli/index.ts",
|
|
90
|
-
"test": "vitest run",
|
|
91
|
-
"test:run": "vitest run",
|
|
92
|
-
"test:watch": "vitest",
|
|
93
|
-
"lint": "eslint src/",
|
|
94
|
-
"typecheck": "tsc --noEmit"
|
|
97
|
+
"pnpm": {
|
|
98
|
+
"onlyBuiltDependencies": [
|
|
99
|
+
"better-sqlite3"
|
|
100
|
+
]
|
|
95
101
|
}
|
|
96
|
-
}
|
|
102
|
+
}
|
|
File without changes
|
package/dist/chunk-BZOJ7HBT.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getFeedbackForProvider
|
|
3
|
-
} from "./chunk-SRBVKO2V.js";
|
|
4
|
-
|
|
5
|
-
// src/feedback/reputation.ts
|
|
6
|
-
var QUALITY_SCORES = {
|
|
7
|
-
excellent: 1,
|
|
8
|
-
good: 0.8,
|
|
9
|
-
acceptable: 0.6,
|
|
10
|
-
poor: 0.3,
|
|
11
|
-
failed: 0
|
|
12
|
-
};
|
|
13
|
-
var COST_VALUE_SCORES = {
|
|
14
|
-
great: 1,
|
|
15
|
-
fair: 0.6,
|
|
16
|
-
overpriced: 0.2
|
|
17
|
-
};
|
|
18
|
-
var DECAY_DAYS = 30;
|
|
19
|
-
var WEIGHTS = {
|
|
20
|
-
rating: 0.4,
|
|
21
|
-
quality: 0.3,
|
|
22
|
-
would_reuse: 0.2,
|
|
23
|
-
cost_value: 0.1
|
|
24
|
-
};
|
|
25
|
-
function computeReputation(feedbacks) {
|
|
26
|
-
if (feedbacks.length === 0) return 0.5;
|
|
27
|
-
const now = Date.now();
|
|
28
|
-
let weightedSum = 0;
|
|
29
|
-
let totalWeight = 0;
|
|
30
|
-
for (const fb of feedbacks) {
|
|
31
|
-
const feedbackDate = new Date(fb.timestamp).getTime();
|
|
32
|
-
const ageDays = Math.max(0, (now - feedbackDate) / (1e3 * 60 * 60 * 24));
|
|
33
|
-
const recencyWeight = Math.exp(-ageDays / DECAY_DAYS);
|
|
34
|
-
const ratingScore = (fb.rating - 1) / 4;
|
|
35
|
-
const qualityScore = QUALITY_SCORES[fb.result_quality];
|
|
36
|
-
const reuseScore = fb.would_reuse ? 1 : 0;
|
|
37
|
-
const costScore = COST_VALUE_SCORES[fb.cost_value_ratio];
|
|
38
|
-
const componentScore = WEIGHTS.rating * ratingScore + WEIGHTS.quality * qualityScore + WEIGHTS.would_reuse * reuseScore + WEIGHTS.cost_value * costScore;
|
|
39
|
-
weightedSum += recencyWeight * componentScore;
|
|
40
|
-
totalWeight += recencyWeight;
|
|
41
|
-
}
|
|
42
|
-
if (totalWeight === 0) return 0.5;
|
|
43
|
-
const raw = weightedSum / totalWeight;
|
|
44
|
-
return Math.max(0, Math.min(1, raw));
|
|
45
|
-
}
|
|
46
|
-
function getReputationScore(db, agentId) {
|
|
47
|
-
const feedbacks = getFeedbackForProvider(db, agentId);
|
|
48
|
-
return computeReputation(feedbacks);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// src/registry/matcher.ts
|
|
52
|
-
var CACHE_MAX_ENTRIES = 100;
|
|
53
|
-
var CACHE_TTL_MS = 3e4;
|
|
54
|
-
var dbCaches = /* @__PURE__ */ new WeakMap();
|
|
55
|
-
function getDbCache(db) {
|
|
56
|
-
let cache = dbCaches.get(db);
|
|
57
|
-
if (!cache) {
|
|
58
|
-
cache = /* @__PURE__ */ new Map();
|
|
59
|
-
dbCaches.set(db, cache);
|
|
60
|
-
}
|
|
61
|
-
return cache;
|
|
62
|
-
}
|
|
63
|
-
function cacheKey(query, filters) {
|
|
64
|
-
return `${query}|${filters.level ?? ""}|${filters.online ?? ""}|${(filters.apis_used ?? []).join(",")}|${filters.min_reputation ?? ""}`;
|
|
65
|
-
}
|
|
66
|
-
function evictCache(cache) {
|
|
67
|
-
const now = Date.now();
|
|
68
|
-
for (const [key, entry] of cache) {
|
|
69
|
-
if (entry.expiresAt <= now) cache.delete(key);
|
|
70
|
-
}
|
|
71
|
-
while (cache.size > CACHE_MAX_ENTRIES) {
|
|
72
|
-
const firstKey = cache.keys().next().value;
|
|
73
|
-
cache.delete(firstKey);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
function searchCards(db, query, filters = {}) {
|
|
77
|
-
const cache = getDbCache(db);
|
|
78
|
-
const key = cacheKey(query, filters);
|
|
79
|
-
const cached = cache.get(key);
|
|
80
|
-
if (cached && cached.expiresAt > Date.now()) {
|
|
81
|
-
return cached.results;
|
|
82
|
-
}
|
|
83
|
-
const words = query.trim().split(/\s+/).map((w) => w.replace(/["*^{}():]/g, "")).filter((w) => w.length > 0);
|
|
84
|
-
if (words.length === 0) return [];
|
|
85
|
-
const ftsQuery = words.map((w) => `"${w}"`).join(" OR ");
|
|
86
|
-
const conditions = [];
|
|
87
|
-
const params = [ftsQuery];
|
|
88
|
-
if (filters.level !== void 0) {
|
|
89
|
-
conditions.push(`json_extract(cc.data, '$.level') = ?`);
|
|
90
|
-
params.push(filters.level);
|
|
91
|
-
}
|
|
92
|
-
if (filters.online !== void 0) {
|
|
93
|
-
conditions.push(`json_extract(cc.data, '$.availability.online') = ?`);
|
|
94
|
-
params.push(filters.online ? 1 : 0);
|
|
95
|
-
}
|
|
96
|
-
const whereClause = conditions.length > 0 ? `AND ${conditions.join(" AND ")}` : "";
|
|
97
|
-
const sql = `
|
|
98
|
-
SELECT cc.data
|
|
99
|
-
FROM capability_cards cc
|
|
100
|
-
JOIN cards_fts ON cc.rowid = cards_fts.rowid
|
|
101
|
-
WHERE cards_fts MATCH ?
|
|
102
|
-
${whereClause}
|
|
103
|
-
ORDER BY bm25(cards_fts)
|
|
104
|
-
LIMIT 50
|
|
105
|
-
`;
|
|
106
|
-
const stmt = db.prepare(sql);
|
|
107
|
-
const rows = stmt.all(...params);
|
|
108
|
-
const results = rows.map((row) => JSON.parse(row.data));
|
|
109
|
-
let filtered = results;
|
|
110
|
-
if (filters.apis_used && filters.apis_used.length > 0) {
|
|
111
|
-
const requiredApis = filters.apis_used;
|
|
112
|
-
filtered = filtered.filter((card) => {
|
|
113
|
-
const cardApis = card.metadata?.apis_used ?? [];
|
|
114
|
-
return requiredApis.every((api) => cardApis.includes(api));
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
if (filters.min_reputation !== void 0 && filters.min_reputation > 0) {
|
|
118
|
-
filtered = applyReputationFilter(db, filtered, filters.min_reputation);
|
|
119
|
-
}
|
|
120
|
-
evictCache(cache);
|
|
121
|
-
cache.set(key, { results: filtered, expiresAt: Date.now() + CACHE_TTL_MS });
|
|
122
|
-
return filtered;
|
|
123
|
-
}
|
|
124
|
-
function filterCards(db, filters) {
|
|
125
|
-
const conditions = [];
|
|
126
|
-
const params = [];
|
|
127
|
-
if (filters.level !== void 0) {
|
|
128
|
-
conditions.push(`json_extract(data, '$.level') = ?`);
|
|
129
|
-
params.push(filters.level);
|
|
130
|
-
}
|
|
131
|
-
if (filters.online !== void 0) {
|
|
132
|
-
conditions.push(`json_extract(data, '$.availability.online') = ?`);
|
|
133
|
-
params.push(filters.online ? 1 : 0);
|
|
134
|
-
}
|
|
135
|
-
const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
136
|
-
const sql = `SELECT data FROM capability_cards ${whereClause}`;
|
|
137
|
-
const stmt = db.prepare(sql);
|
|
138
|
-
const rows = stmt.all(...params);
|
|
139
|
-
let cards = rows.map((row) => JSON.parse(row.data));
|
|
140
|
-
if (filters.min_reputation !== void 0 && filters.min_reputation > 0) {
|
|
141
|
-
cards = applyReputationFilter(db, cards, filters.min_reputation);
|
|
142
|
-
}
|
|
143
|
-
return cards;
|
|
144
|
-
}
|
|
145
|
-
function applyReputationFilter(db, cards, minReputation) {
|
|
146
|
-
const owners = [...new Set(cards.map((c) => c.owner))];
|
|
147
|
-
const reputationMap = /* @__PURE__ */ new Map();
|
|
148
|
-
for (const owner of owners) {
|
|
149
|
-
reputationMap.set(owner, getReputationScore(db, owner));
|
|
150
|
-
}
|
|
151
|
-
return cards.filter((card) => {
|
|
152
|
-
const score = reputationMap.get(card.owner) ?? 0.5;
|
|
153
|
-
return score >= minReputation;
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
function buildReputationMap(db, owners) {
|
|
157
|
-
const unique = [...new Set(owners)];
|
|
158
|
-
const map = /* @__PURE__ */ new Map();
|
|
159
|
-
for (const owner of unique) {
|
|
160
|
-
map.set(owner, getReputationScore(db, owner));
|
|
161
|
-
}
|
|
162
|
-
return map;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export {
|
|
166
|
-
computeReputation,
|
|
167
|
-
searchCards,
|
|
168
|
-
filterCards,
|
|
169
|
-
buildReputationMap
|
|
170
|
-
};
|
package/dist/chunk-KF3TZHA5.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AgentBnBError
|
|
3
|
-
} from "./chunk-WVY2W7AA.js";
|
|
4
|
-
|
|
5
|
-
// src/cli/remote-registry.ts
|
|
6
|
-
var RegistryTimeoutError = class extends AgentBnBError {
|
|
7
|
-
constructor(url) {
|
|
8
|
-
super(
|
|
9
|
-
`Registry at ${url} did not respond within 5s. Showing local results only.`,
|
|
10
|
-
"REGISTRY_TIMEOUT"
|
|
11
|
-
);
|
|
12
|
-
this.name = "RegistryTimeoutError";
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
var RegistryConnectionError = class extends AgentBnBError {
|
|
16
|
-
constructor(url) {
|
|
17
|
-
super(
|
|
18
|
-
`Cannot reach ${url}. Is the registry running? Showing local results only.`,
|
|
19
|
-
"REGISTRY_CONNECTION"
|
|
20
|
-
);
|
|
21
|
-
this.name = "RegistryConnectionError";
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
var RegistryAuthError = class extends AgentBnBError {
|
|
25
|
-
constructor(url) {
|
|
26
|
-
super(
|
|
27
|
-
`Authentication failed for ${url}. Run \`agentbnb config set token <your-token>\`.`,
|
|
28
|
-
"REGISTRY_AUTH"
|
|
29
|
-
);
|
|
30
|
-
this.name = "RegistryAuthError";
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
async function fetchRemoteCards(registryUrl, params, timeoutMs = 5e3) {
|
|
34
|
-
let cardsUrl;
|
|
35
|
-
try {
|
|
36
|
-
cardsUrl = new URL("/cards", registryUrl);
|
|
37
|
-
} catch {
|
|
38
|
-
throw new AgentBnBError(`Invalid registry URL: ${registryUrl}`, "INVALID_REGISTRY_URL");
|
|
39
|
-
}
|
|
40
|
-
const searchParams = new URLSearchParams();
|
|
41
|
-
if (params.q !== void 0) searchParams.set("q", params.q);
|
|
42
|
-
if (params.level !== void 0) searchParams.set("level", String(params.level));
|
|
43
|
-
if (params.online !== void 0) searchParams.set("online", String(params.online));
|
|
44
|
-
if (params.tag !== void 0) searchParams.set("tag", params.tag);
|
|
45
|
-
searchParams.set("limit", "100");
|
|
46
|
-
cardsUrl.search = searchParams.toString();
|
|
47
|
-
const controller = new AbortController();
|
|
48
|
-
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
49
|
-
let response;
|
|
50
|
-
try {
|
|
51
|
-
response = await fetch(cardsUrl.toString(), { signal: controller.signal });
|
|
52
|
-
} catch (err) {
|
|
53
|
-
clearTimeout(timer);
|
|
54
|
-
const isTimeout = err instanceof Error && err.name === "AbortError";
|
|
55
|
-
if (isTimeout) {
|
|
56
|
-
throw new RegistryTimeoutError(registryUrl);
|
|
57
|
-
}
|
|
58
|
-
throw new RegistryConnectionError(registryUrl);
|
|
59
|
-
} finally {
|
|
60
|
-
clearTimeout(timer);
|
|
61
|
-
}
|
|
62
|
-
if (response.status === 401 || response.status === 403) {
|
|
63
|
-
throw new RegistryAuthError(registryUrl);
|
|
64
|
-
}
|
|
65
|
-
if (!response.ok) {
|
|
66
|
-
throw new RegistryConnectionError(registryUrl);
|
|
67
|
-
}
|
|
68
|
-
const body = await response.json();
|
|
69
|
-
return body.items;
|
|
70
|
-
}
|
|
71
|
-
function mergeResults(localCards, remoteCards, hasQuery) {
|
|
72
|
-
const taggedLocal = localCards.map((c) => ({ ...c, source: "local" }));
|
|
73
|
-
const taggedRemote = remoteCards.map((c) => ({ ...c, source: "remote" }));
|
|
74
|
-
const localIds = new Set(localCards.map((c) => c.id));
|
|
75
|
-
const dedupedRemote = taggedRemote.filter((c) => !localIds.has(c.id));
|
|
76
|
-
if (!hasQuery) {
|
|
77
|
-
return [...taggedLocal, ...dedupedRemote];
|
|
78
|
-
}
|
|
79
|
-
const result = [];
|
|
80
|
-
const maxLen = Math.max(taggedLocal.length, dedupedRemote.length);
|
|
81
|
-
for (let i = 0; i < maxLen; i++) {
|
|
82
|
-
if (i < taggedLocal.length) result.push(taggedLocal[i]);
|
|
83
|
-
if (i < dedupedRemote.length) result.push(dedupedRemote[i]);
|
|
84
|
-
}
|
|
85
|
-
return result;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export {
|
|
89
|
-
fetchRemoteCards,
|
|
90
|
-
mergeResults
|
|
91
|
-
};
|