agentbnb 4.0.2 → 5.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.
- package/README.md +31 -2
- package/dist/chunk-AUBHR7HH.js +25 -0
- package/dist/chunk-B5FTAGFN.js +393 -0
- package/dist/{chunk-GGYC5U2Z.js → chunk-BTTL24TZ.js} +29 -91
- package/dist/chunk-C6KPAFCC.js +387 -0
- package/dist/chunk-CRFCWD6V.js +366 -0
- package/dist/chunk-CSATDXZC.js +89 -0
- package/dist/{chunk-T7NS2J2B.js → chunk-DFBX3BBD.js} +84 -1
- package/dist/{chunk-DNWT5FZQ.js → chunk-EANI2N2V.js} +98 -1
- package/dist/{chunk-HH24WMFN.js → chunk-FLY3WIQR.js} +1 -1
- package/dist/chunk-HLUEOLSZ.js +62 -0
- package/dist/chunk-IVOYM3WG.js +25 -0
- package/dist/chunk-LCAIAAG2.js +916 -0
- package/dist/chunk-MLS6IGGG.js +294 -0
- package/dist/{chunk-4P3EMGL4.js → chunk-MNO4COST.js} +5 -3
- package/dist/chunk-NH2FIERR.js +138 -0
- package/dist/chunk-UKT6H7YT.js +29 -0
- package/dist/{chunk-BH6WGYFB.js → chunk-VE3E4AMH.js} +8 -8
- package/dist/{chunk-7NA43XCG.js → chunk-W5BZMKMF.js} +163 -29
- package/dist/{chunk-FF226TIV.js → chunk-ZX5623ER.js} +0 -57
- package/dist/cli/index.js +362 -4631
- package/dist/{conduct-N52JX7RT.js → conduct-KM6ZNJGE.js} +10 -8
- package/dist/{conduct-GZQNFTRP.js → conduct-WGTMQND5.js} +10 -8
- package/dist/{conductor-mode-XUWGR4ZE.js → conductor-mode-OL2FNOYY.js} +6 -4
- package/dist/conductor-mode-VRO7TYW2.js +592 -0
- package/dist/execute-CPFSOOO3.js +13 -0
- package/dist/execute-IP2QHALV.js +10 -0
- package/dist/index.d.ts +19 -8
- package/dist/index.js +190 -37
- package/dist/peers-CJ7T4RJO.js +13 -0
- package/dist/process-guard-CC7CNRQJ.js +176 -0
- package/dist/{request-4GQSSM4B.js → request-YOWPXVLQ.js} +13 -10
- package/dist/schema-7BSSLZ4S.js +8 -0
- package/dist/{serve-skill-TPHZH6BS.js → serve-skill-JHFNR7BW.js} +8 -7
- package/dist/{server-365V3GYD.js → server-HKJJWFRG.js} +10 -8
- package/dist/service-coordinator-5R4LQW6L.js +4917 -0
- package/dist/skills/agentbnb/bootstrap.js +6181 -0
- package/dist/websocket-client-WRN3HO73.js +6 -0
- package/openclaw.plugin.json +54 -0
- package/package.json +11 -2
- package/skills/agentbnb/SKILL.md +87 -70
- package/skills/agentbnb/bootstrap.test.ts +142 -242
- package/skills/agentbnb/bootstrap.ts +88 -95
- package/skills/agentbnb/install.sh +97 -27
- package/dist/execute-PNGQOMYO.js +0 -10
package/dist/index.d.ts
CHANGED
|
@@ -777,6 +777,12 @@ interface SearchFilters {
|
|
|
777
777
|
online?: boolean;
|
|
778
778
|
/** Filter cards that use all of the specified APIs. */
|
|
779
779
|
apis_used?: string[];
|
|
780
|
+
/**
|
|
781
|
+
* Minimum reputation score (0.0 - 1.0) for the card owner.
|
|
782
|
+
* Cards whose owner has a reputation score below this value are excluded.
|
|
783
|
+
* Owners with no feedback default to 0.5 (cold-start score).
|
|
784
|
+
*/
|
|
785
|
+
min_reputation?: number;
|
|
780
786
|
}
|
|
781
787
|
/**
|
|
782
788
|
* Searches CapabilityCards using FTS5 full-text search with optional filters.
|
|
@@ -785,7 +791,7 @@ interface SearchFilters {
|
|
|
785
791
|
*
|
|
786
792
|
* @param db - Open database instance.
|
|
787
793
|
* @param query - Full-text search query string.
|
|
788
|
-
* @param filters - Optional filters for level, online status, and
|
|
794
|
+
* @param filters - Optional filters for level, online status, apis_used, and min_reputation.
|
|
789
795
|
* @returns Array of matching CapabilityCard objects sorted by relevance.
|
|
790
796
|
*/
|
|
791
797
|
declare function searchCards(db: Database.Database, query: string, filters?: SearchFilters): CapabilityCard[];
|
|
@@ -939,8 +945,8 @@ declare const PipelineSkillConfigSchema: z.ZodObject<{
|
|
|
939
945
|
skill_id: z.ZodString;
|
|
940
946
|
input_mapping: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
941
947
|
}, "strip", z.ZodTypeAny, {
|
|
942
|
-
input_mapping: Record<string, string>;
|
|
943
948
|
skill_id: string;
|
|
949
|
+
input_mapping: Record<string, string>;
|
|
944
950
|
}, {
|
|
945
951
|
skill_id: string;
|
|
946
952
|
input_mapping?: Record<string, string> | undefined;
|
|
@@ -978,8 +984,8 @@ declare const PipelineSkillConfigSchema: z.ZodObject<{
|
|
|
978
984
|
free_tier?: number | undefined;
|
|
979
985
|
};
|
|
980
986
|
steps: ({
|
|
981
|
-
input_mapping: Record<string, string>;
|
|
982
987
|
skill_id: string;
|
|
988
|
+
input_mapping: Record<string, string>;
|
|
983
989
|
} | {
|
|
984
990
|
input_mapping: Record<string, string>;
|
|
985
991
|
command: string;
|
|
@@ -1279,8 +1285,8 @@ declare const SkillConfigSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
|
1279
1285
|
skill_id: z.ZodString;
|
|
1280
1286
|
input_mapping: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
1281
1287
|
}, "strip", z.ZodTypeAny, {
|
|
1282
|
-
input_mapping: Record<string, string>;
|
|
1283
1288
|
skill_id: string;
|
|
1289
|
+
input_mapping: Record<string, string>;
|
|
1284
1290
|
}, {
|
|
1285
1291
|
skill_id: string;
|
|
1286
1292
|
input_mapping?: Record<string, string> | undefined;
|
|
@@ -1318,8 +1324,8 @@ declare const SkillConfigSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
|
1318
1324
|
free_tier?: number | undefined;
|
|
1319
1325
|
};
|
|
1320
1326
|
steps: ({
|
|
1321
|
-
input_mapping: Record<string, string>;
|
|
1322
1327
|
skill_id: string;
|
|
1328
|
+
input_mapping: Record<string, string>;
|
|
1323
1329
|
} | {
|
|
1324
1330
|
input_mapping: Record<string, string>;
|
|
1325
1331
|
command: string;
|
|
@@ -1605,8 +1611,8 @@ declare const SkillsFileSchema: z.ZodObject<{
|
|
|
1605
1611
|
skill_id: z.ZodString;
|
|
1606
1612
|
input_mapping: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
1607
1613
|
}, "strip", z.ZodTypeAny, {
|
|
1608
|
-
input_mapping: Record<string, string>;
|
|
1609
1614
|
skill_id: string;
|
|
1615
|
+
input_mapping: Record<string, string>;
|
|
1610
1616
|
}, {
|
|
1611
1617
|
skill_id: string;
|
|
1612
1618
|
input_mapping?: Record<string, string> | undefined;
|
|
@@ -1644,8 +1650,8 @@ declare const SkillsFileSchema: z.ZodObject<{
|
|
|
1644
1650
|
free_tier?: number | undefined;
|
|
1645
1651
|
};
|
|
1646
1652
|
steps: ({
|
|
1647
|
-
input_mapping: Record<string, string>;
|
|
1648
1653
|
skill_id: string;
|
|
1654
|
+
input_mapping: Record<string, string>;
|
|
1649
1655
|
} | {
|
|
1650
1656
|
input_mapping: Record<string, string>;
|
|
1651
1657
|
command: string;
|
|
@@ -1843,8 +1849,8 @@ declare const SkillsFileSchema: z.ZodObject<{
|
|
|
1843
1849
|
free_tier?: number | undefined;
|
|
1844
1850
|
};
|
|
1845
1851
|
steps: ({
|
|
1846
|
-
input_mapping: Record<string, string>;
|
|
1847
1852
|
skill_id: string;
|
|
1853
|
+
input_mapping: Record<string, string>;
|
|
1848
1854
|
} | {
|
|
1849
1855
|
input_mapping: Record<string, string>;
|
|
1850
1856
|
command: string;
|
|
@@ -3851,6 +3857,11 @@ interface ExecuteRequestOptions {
|
|
|
3851
3857
|
timeoutMs?: number;
|
|
3852
3858
|
/** Optional progress callback forwarded to SkillExecutor during execution. */
|
|
3853
3859
|
onProgress?: ProgressCallback;
|
|
3860
|
+
/**
|
|
3861
|
+
* When true, skip local credit check and escrow management.
|
|
3862
|
+
* Used for relay-routed requests where the Hub relay has already held credits.
|
|
3863
|
+
*/
|
|
3864
|
+
relayAuthorized?: boolean;
|
|
3854
3865
|
}
|
|
3855
3866
|
/**
|
|
3856
3867
|
* Result of a capability execution.
|
package/dist/index.js
CHANGED
|
@@ -212,6 +212,85 @@ function insertRequestLog(db, entry) {
|
|
|
212
212
|
);
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
+
// src/feedback/store.ts
|
|
216
|
+
import { randomUUID } from "crypto";
|
|
217
|
+
function initFeedbackTable(db) {
|
|
218
|
+
db.exec(`
|
|
219
|
+
CREATE TABLE IF NOT EXISTS feedback (
|
|
220
|
+
id TEXT PRIMARY KEY,
|
|
221
|
+
transaction_id TEXT NOT NULL,
|
|
222
|
+
provider_agent TEXT NOT NULL,
|
|
223
|
+
skill_id TEXT NOT NULL,
|
|
224
|
+
requester_agent TEXT NOT NULL,
|
|
225
|
+
rating INTEGER NOT NULL,
|
|
226
|
+
latency_ms INTEGER NOT NULL,
|
|
227
|
+
result_quality TEXT NOT NULL,
|
|
228
|
+
quality_details TEXT,
|
|
229
|
+
would_reuse INTEGER NOT NULL,
|
|
230
|
+
cost_value_ratio TEXT NOT NULL,
|
|
231
|
+
timestamp TEXT NOT NULL,
|
|
232
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
CREATE INDEX IF NOT EXISTS feedback_provider_idx ON feedback(provider_agent);
|
|
236
|
+
CREATE INDEX IF NOT EXISTS feedback_skill_idx ON feedback(skill_id);
|
|
237
|
+
`);
|
|
238
|
+
}
|
|
239
|
+
function getFeedbackForProvider(db, providerAgent, sinceDays) {
|
|
240
|
+
let rows;
|
|
241
|
+
if (sinceDays !== void 0) {
|
|
242
|
+
rows = db.prepare(`
|
|
243
|
+
SELECT * FROM feedback
|
|
244
|
+
WHERE provider_agent = ?
|
|
245
|
+
AND timestamp >= datetime('now', ? || ' days')
|
|
246
|
+
ORDER BY timestamp DESC
|
|
247
|
+
`).all(providerAgent, `-${sinceDays}`);
|
|
248
|
+
} else {
|
|
249
|
+
rows = db.prepare(`
|
|
250
|
+
SELECT * FROM feedback
|
|
251
|
+
WHERE provider_agent = ?
|
|
252
|
+
ORDER BY timestamp DESC
|
|
253
|
+
`).all(providerAgent);
|
|
254
|
+
}
|
|
255
|
+
return rows.map(rowToFeedback);
|
|
256
|
+
}
|
|
257
|
+
function rowToFeedback(row) {
|
|
258
|
+
return {
|
|
259
|
+
transaction_id: row["transaction_id"],
|
|
260
|
+
provider_agent: row["provider_agent"],
|
|
261
|
+
skill_id: row["skill_id"],
|
|
262
|
+
requester_agent: row["requester_agent"],
|
|
263
|
+
rating: row["rating"],
|
|
264
|
+
latency_ms: row["latency_ms"],
|
|
265
|
+
result_quality: row["result_quality"],
|
|
266
|
+
quality_details: row["quality_details"] ?? void 0,
|
|
267
|
+
would_reuse: row["would_reuse"] === 1,
|
|
268
|
+
cost_value_ratio: row["cost_value_ratio"],
|
|
269
|
+
timestamp: row["timestamp"]
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// src/evolution/store.ts
|
|
274
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
275
|
+
function initEvolutionTable(db) {
|
|
276
|
+
db.exec(`
|
|
277
|
+
CREATE TABLE IF NOT EXISTS evolution_versions (
|
|
278
|
+
id TEXT PRIMARY KEY,
|
|
279
|
+
template_name TEXT NOT NULL,
|
|
280
|
+
template_version TEXT NOT NULL,
|
|
281
|
+
publisher_agent TEXT NOT NULL,
|
|
282
|
+
changelog TEXT NOT NULL,
|
|
283
|
+
core_memory_snapshot TEXT NOT NULL,
|
|
284
|
+
fitness_improvement REAL NOT NULL,
|
|
285
|
+
timestamp TEXT NOT NULL,
|
|
286
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
CREATE INDEX IF NOT EXISTS evolution_template_idx
|
|
290
|
+
ON evolution_versions(template_name, created_at DESC);
|
|
291
|
+
`);
|
|
292
|
+
}
|
|
293
|
+
|
|
215
294
|
// src/registry/store.ts
|
|
216
295
|
var V2_FTS_TRIGGERS = `
|
|
217
296
|
DROP TRIGGER IF EXISTS cards_ai;
|
|
@@ -366,6 +445,8 @@ function openDatabase(path = ":memory:") {
|
|
|
366
445
|
);
|
|
367
446
|
`);
|
|
368
447
|
createRequestLogTable(db);
|
|
448
|
+
initFeedbackTable(db);
|
|
449
|
+
initEvolutionTable(db);
|
|
369
450
|
runMigrations(db);
|
|
370
451
|
return db;
|
|
371
452
|
}
|
|
@@ -509,6 +590,52 @@ function listCards(db, owner) {
|
|
|
509
590
|
return rows.map((row) => JSON.parse(row.data));
|
|
510
591
|
}
|
|
511
592
|
|
|
593
|
+
// src/feedback/reputation.ts
|
|
594
|
+
var QUALITY_SCORES = {
|
|
595
|
+
excellent: 1,
|
|
596
|
+
good: 0.8,
|
|
597
|
+
acceptable: 0.6,
|
|
598
|
+
poor: 0.3,
|
|
599
|
+
failed: 0
|
|
600
|
+
};
|
|
601
|
+
var COST_VALUE_SCORES = {
|
|
602
|
+
great: 1,
|
|
603
|
+
fair: 0.6,
|
|
604
|
+
overpriced: 0.2
|
|
605
|
+
};
|
|
606
|
+
var DECAY_DAYS = 30;
|
|
607
|
+
var WEIGHTS = {
|
|
608
|
+
rating: 0.4,
|
|
609
|
+
quality: 0.3,
|
|
610
|
+
would_reuse: 0.2,
|
|
611
|
+
cost_value: 0.1
|
|
612
|
+
};
|
|
613
|
+
function computeReputation(feedbacks) {
|
|
614
|
+
if (feedbacks.length === 0) return 0.5;
|
|
615
|
+
const now = Date.now();
|
|
616
|
+
let weightedSum = 0;
|
|
617
|
+
let totalWeight = 0;
|
|
618
|
+
for (const fb of feedbacks) {
|
|
619
|
+
const feedbackDate = new Date(fb.timestamp).getTime();
|
|
620
|
+
const ageDays = Math.max(0, (now - feedbackDate) / (1e3 * 60 * 60 * 24));
|
|
621
|
+
const recencyWeight = Math.exp(-ageDays / DECAY_DAYS);
|
|
622
|
+
const ratingScore = (fb.rating - 1) / 4;
|
|
623
|
+
const qualityScore = QUALITY_SCORES[fb.result_quality];
|
|
624
|
+
const reuseScore = fb.would_reuse ? 1 : 0;
|
|
625
|
+
const costScore = COST_VALUE_SCORES[fb.cost_value_ratio];
|
|
626
|
+
const componentScore = WEIGHTS.rating * ratingScore + WEIGHTS.quality * qualityScore + WEIGHTS.would_reuse * reuseScore + WEIGHTS.cost_value * costScore;
|
|
627
|
+
weightedSum += recencyWeight * componentScore;
|
|
628
|
+
totalWeight += recencyWeight;
|
|
629
|
+
}
|
|
630
|
+
if (totalWeight === 0) return 0.5;
|
|
631
|
+
const raw = weightedSum / totalWeight;
|
|
632
|
+
return Math.max(0, Math.min(1, raw));
|
|
633
|
+
}
|
|
634
|
+
function getReputationScore(db, agentId) {
|
|
635
|
+
const feedbacks = getFeedbackForProvider(db, agentId);
|
|
636
|
+
return computeReputation(feedbacks);
|
|
637
|
+
}
|
|
638
|
+
|
|
512
639
|
// src/registry/matcher.ts
|
|
513
640
|
function searchCards(db, query, filters = {}) {
|
|
514
641
|
const words = query.trim().split(/\s+/).map((w) => w.replace(/["*^{}():]/g, "")).filter((w) => w.length > 0);
|
|
@@ -537,19 +664,34 @@ function searchCards(db, query, filters = {}) {
|
|
|
537
664
|
const stmt = db.prepare(sql);
|
|
538
665
|
const rows = stmt.all(...params);
|
|
539
666
|
const results = rows.map((row) => JSON.parse(row.data));
|
|
667
|
+
let filtered = results;
|
|
540
668
|
if (filters.apis_used && filters.apis_used.length > 0) {
|
|
541
669
|
const requiredApis = filters.apis_used;
|
|
542
|
-
|
|
670
|
+
filtered = filtered.filter((card) => {
|
|
543
671
|
const cardApis = card.metadata?.apis_used ?? [];
|
|
544
672
|
return requiredApis.every((api) => cardApis.includes(api));
|
|
545
673
|
});
|
|
546
674
|
}
|
|
547
|
-
|
|
675
|
+
if (filters.min_reputation !== void 0 && filters.min_reputation > 0) {
|
|
676
|
+
filtered = applyReputationFilter(db, filtered, filters.min_reputation);
|
|
677
|
+
}
|
|
678
|
+
return filtered;
|
|
679
|
+
}
|
|
680
|
+
function applyReputationFilter(db, cards, minReputation) {
|
|
681
|
+
const owners = [...new Set(cards.map((c) => c.owner))];
|
|
682
|
+
const reputationMap = /* @__PURE__ */ new Map();
|
|
683
|
+
for (const owner of owners) {
|
|
684
|
+
reputationMap.set(owner, getReputationScore(db, owner));
|
|
685
|
+
}
|
|
686
|
+
return cards.filter((card) => {
|
|
687
|
+
const score = reputationMap.get(card.owner) ?? 0.5;
|
|
688
|
+
return score >= minReputation;
|
|
689
|
+
});
|
|
548
690
|
}
|
|
549
691
|
|
|
550
692
|
// src/credit/ledger.ts
|
|
551
693
|
import Database2 from "better-sqlite3";
|
|
552
|
-
import { randomUUID } from "crypto";
|
|
694
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
553
695
|
var CREDIT_SCHEMA = `
|
|
554
696
|
CREATE TABLE IF NOT EXISTS credit_balances (
|
|
555
697
|
owner TEXT PRIMARY KEY,
|
|
@@ -605,7 +747,7 @@ function recordEarning(db, owner, amount, _cardId, receiptNonce) {
|
|
|
605
747
|
).run(amount, now, owner);
|
|
606
748
|
db.prepare(
|
|
607
749
|
"INSERT INTO credit_transactions (id, owner, amount, reason, reference_id, created_at) VALUES (?, ?, ?, ?, ?, ?)"
|
|
608
|
-
).run(
|
|
750
|
+
).run(randomUUID3(), owner, amount, "remote_earning", receiptNonce, now);
|
|
609
751
|
})();
|
|
610
752
|
}
|
|
611
753
|
|
|
@@ -613,12 +755,12 @@ function recordEarning(db, owner, amount, _cardId, receiptNonce) {
|
|
|
613
755
|
import Fastify from "fastify";
|
|
614
756
|
|
|
615
757
|
// src/gateway/execute.ts
|
|
616
|
-
import { randomUUID as
|
|
758
|
+
import { randomUUID as randomUUID5 } from "crypto";
|
|
617
759
|
|
|
618
760
|
// src/credit/escrow.ts
|
|
619
|
-
import { randomUUID as
|
|
761
|
+
import { randomUUID as randomUUID4 } from "crypto";
|
|
620
762
|
function holdEscrow(db, owner, amount, cardId) {
|
|
621
|
-
const escrowId =
|
|
763
|
+
const escrowId = randomUUID4();
|
|
622
764
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
623
765
|
const hold = db.transaction(() => {
|
|
624
766
|
const row = db.prepare("SELECT balance FROM credit_balances WHERE owner = ?").get(owner);
|
|
@@ -633,7 +775,7 @@ function holdEscrow(db, owner, amount, cardId) {
|
|
|
633
775
|
).run(escrowId, owner, amount, cardId, "held", now);
|
|
634
776
|
db.prepare(
|
|
635
777
|
"INSERT INTO credit_transactions (id, owner, amount, reason, reference_id, created_at) VALUES (?, ?, ?, ?, ?, ?)"
|
|
636
|
-
).run(
|
|
778
|
+
).run(randomUUID4(), owner, -amount, "escrow_hold", escrowId, now);
|
|
637
779
|
});
|
|
638
780
|
hold();
|
|
639
781
|
return escrowId;
|
|
@@ -662,7 +804,7 @@ function settleEscrow(db, escrowId, recipientOwner) {
|
|
|
662
804
|
).run("settled", now, escrowId);
|
|
663
805
|
db.prepare(
|
|
664
806
|
"INSERT INTO credit_transactions (id, owner, amount, reason, reference_id, created_at) VALUES (?, ?, ?, ?, ?, ?)"
|
|
665
|
-
).run(
|
|
807
|
+
).run(randomUUID4(), recipientOwner, escrow.amount, "settlement", escrowId, now);
|
|
666
808
|
});
|
|
667
809
|
settle();
|
|
668
810
|
}
|
|
@@ -687,7 +829,7 @@ function releaseEscrow(db, escrowId) {
|
|
|
687
829
|
).run("released", now, escrowId);
|
|
688
830
|
db.prepare(
|
|
689
831
|
"INSERT INTO credit_transactions (id, owner, amount, reason, reference_id, created_at) VALUES (?, ?, ?, ?, ?, ?)"
|
|
690
|
-
).run(
|
|
832
|
+
).run(randomUUID4(), escrow.owner, escrow.amount, "refund", escrowId, now);
|
|
691
833
|
});
|
|
692
834
|
release();
|
|
693
835
|
}
|
|
@@ -709,7 +851,7 @@ function confirmEscrowDebit(db, escrowId) {
|
|
|
709
851
|
).run("settled", now, escrowId);
|
|
710
852
|
db.prepare(
|
|
711
853
|
"INSERT INTO credit_transactions (id, owner, amount, reason, reference_id, created_at) VALUES (?, ?, ?, ?, ?, ?)"
|
|
712
|
-
).run(
|
|
854
|
+
).run(randomUUID4(), escrow.owner, 0, "remote_settlement_confirmed", escrowId, now);
|
|
713
855
|
});
|
|
714
856
|
confirm();
|
|
715
857
|
}
|
|
@@ -797,7 +939,8 @@ async function executeCapabilityRequest(opts) {
|
|
|
797
939
|
skillExecutor,
|
|
798
940
|
handlerUrl,
|
|
799
941
|
timeoutMs = 3e5,
|
|
800
|
-
onProgress
|
|
942
|
+
onProgress,
|
|
943
|
+
relayAuthorized = false
|
|
801
944
|
} = opts;
|
|
802
945
|
const card = getCard(registryDb, cardId);
|
|
803
946
|
if (!card) {
|
|
@@ -822,7 +965,8 @@ async function executeCapabilityRequest(opts) {
|
|
|
822
965
|
}
|
|
823
966
|
let escrowId = null;
|
|
824
967
|
let isRemoteEscrow = false;
|
|
825
|
-
if (
|
|
968
|
+
if (relayAuthorized) {
|
|
969
|
+
} else if (receipt) {
|
|
826
970
|
const { signature, ...receiptData2 } = receipt;
|
|
827
971
|
const publicKeyBuf = Buffer.from(receipt.requester_public_key, "hex");
|
|
828
972
|
const valid = verifyEscrowReceipt(receiptData2, signature, publicKeyBuf);
|
|
@@ -856,7 +1000,7 @@ async function executeCapabilityRequest(opts) {
|
|
|
856
1000
|
updateReputation(registryDb, cardId, false, latencyMs);
|
|
857
1001
|
try {
|
|
858
1002
|
insertRequestLog(registryDb, {
|
|
859
|
-
id:
|
|
1003
|
+
id: randomUUID5(),
|
|
860
1004
|
card_id: cardId,
|
|
861
1005
|
card_name: cardName,
|
|
862
1006
|
skill_id: resolvedSkillId,
|
|
@@ -882,7 +1026,7 @@ async function executeCapabilityRequest(opts) {
|
|
|
882
1026
|
updateReputation(registryDb, cardId, true, latencyMs);
|
|
883
1027
|
try {
|
|
884
1028
|
insertRequestLog(registryDb, {
|
|
885
|
-
id:
|
|
1029
|
+
id: randomUUID5(),
|
|
886
1030
|
card_id: cardId,
|
|
887
1031
|
card_name: cardName,
|
|
888
1032
|
skill_id: resolvedSkillId,
|
|
@@ -1840,7 +1984,7 @@ var CommandExecutor = class {
|
|
|
1840
1984
|
};
|
|
1841
1985
|
|
|
1842
1986
|
// src/conductor/task-decomposer.ts
|
|
1843
|
-
import { randomUUID as
|
|
1987
|
+
import { randomUUID as randomUUID6 } from "crypto";
|
|
1844
1988
|
var TEMPLATES = {
|
|
1845
1989
|
"video-production": {
|
|
1846
1990
|
keywords: ["video", "demo", "clip", "animation"],
|
|
@@ -1935,7 +2079,7 @@ function decompose(task, _availableCapabilities) {
|
|
|
1935
2079
|
for (const template of Object.values(TEMPLATES)) {
|
|
1936
2080
|
const matched = template.keywords.some((kw) => lower.includes(kw));
|
|
1937
2081
|
if (!matched) continue;
|
|
1938
|
-
const ids = template.steps.map(() =>
|
|
2082
|
+
const ids = template.steps.map(() => randomUUID6());
|
|
1939
2083
|
return template.steps.map((step, i) => ({
|
|
1940
2084
|
id: ids[i],
|
|
1941
2085
|
description: step.description,
|
|
@@ -1949,10 +2093,10 @@ function decompose(task, _availableCapabilities) {
|
|
|
1949
2093
|
}
|
|
1950
2094
|
|
|
1951
2095
|
// src/gateway/client.ts
|
|
1952
|
-
import { randomUUID as
|
|
2096
|
+
import { randomUUID as randomUUID7 } from "crypto";
|
|
1953
2097
|
async function requestCapability(opts) {
|
|
1954
2098
|
const { gatewayUrl, token, cardId, params = {}, timeoutMs = 3e5, escrowReceipt, identity } = opts;
|
|
1955
|
-
const id =
|
|
2099
|
+
const id = randomUUID7();
|
|
1956
2100
|
const payload = {
|
|
1957
2101
|
jsonrpc: "2.0",
|
|
1958
2102
|
id,
|
|
@@ -2022,10 +2166,10 @@ async function requestViaRelay(relay, opts) {
|
|
|
2022
2166
|
}
|
|
2023
2167
|
|
|
2024
2168
|
// src/autonomy/tiers.ts
|
|
2025
|
-
import { randomUUID as
|
|
2169
|
+
import { randomUUID as randomUUID8 } from "crypto";
|
|
2026
2170
|
|
|
2027
2171
|
// src/autonomy/pending-requests.ts
|
|
2028
|
-
import { randomUUID as
|
|
2172
|
+
import { randomUUID as randomUUID9 } from "crypto";
|
|
2029
2173
|
|
|
2030
2174
|
// src/cli/peers.ts
|
|
2031
2175
|
import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, existsSync as existsSync3, mkdirSync as mkdirSync2 } from "fs";
|
|
@@ -2133,11 +2277,20 @@ function minMaxNormalize(values) {
|
|
|
2133
2277
|
function scorePeers(candidates, selfOwner) {
|
|
2134
2278
|
const eligible = candidates.filter((c) => c.card.owner !== selfOwner);
|
|
2135
2279
|
if (eligible.length === 0) return [];
|
|
2136
|
-
const successRates = eligible.map((c) =>
|
|
2280
|
+
const successRates = eligible.map((c) => {
|
|
2281
|
+
if (c.skillMetadata?.success_rate !== void 0) {
|
|
2282
|
+
return c.skillMetadata.success_rate;
|
|
2283
|
+
}
|
|
2284
|
+
return c.card.metadata?.success_rate ?? 0.5;
|
|
2285
|
+
});
|
|
2137
2286
|
const costEfficiencies = eligible.map((c) => c.cost === 0 ? 1 : 1 / c.cost);
|
|
2138
2287
|
const idleRates = eligible.map((c) => {
|
|
2288
|
+
if (c.skillInternal !== void 0) {
|
|
2289
|
+
const skillIdleRate = c.skillInternal["idle_rate"];
|
|
2290
|
+
if (typeof skillIdleRate === "number") return skillIdleRate;
|
|
2291
|
+
}
|
|
2139
2292
|
const internal = c.card._internal;
|
|
2140
|
-
const idleRate = internal?.idle_rate;
|
|
2293
|
+
const idleRate = internal?.["idle_rate"];
|
|
2141
2294
|
return typeof idleRate === "number" ? idleRate : 1;
|
|
2142
2295
|
});
|
|
2143
2296
|
const normSuccess = minMaxNormalize(successRates);
|
|
@@ -2660,7 +2813,7 @@ var ConductorMode = class {
|
|
|
2660
2813
|
|
|
2661
2814
|
// src/credit/escrow-receipt.ts
|
|
2662
2815
|
import { z as z3 } from "zod";
|
|
2663
|
-
import { randomUUID as
|
|
2816
|
+
import { randomUUID as randomUUID10 } from "crypto";
|
|
2664
2817
|
var EscrowReceiptSchema = z3.object({
|
|
2665
2818
|
requester_owner: z3.string().min(1),
|
|
2666
2819
|
requester_public_key: z3.string().min(1),
|
|
@@ -2680,7 +2833,7 @@ function createSignedEscrowReceipt(db, privateKey, publicKey, opts) {
|
|
|
2680
2833
|
card_id: opts.cardId,
|
|
2681
2834
|
...opts.skillId ? { skill_id: opts.skillId } : {},
|
|
2682
2835
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2683
|
-
nonce:
|
|
2836
|
+
nonce: randomUUID10()
|
|
2684
2837
|
};
|
|
2685
2838
|
const signature = signEscrowReceipt(receiptData, privateKey);
|
|
2686
2839
|
const receipt = {
|
|
@@ -3051,7 +3204,7 @@ var AgentBnBProvider = class {
|
|
|
3051
3204
|
|
|
3052
3205
|
// src/identity/guarantor.ts
|
|
3053
3206
|
import { z as z5 } from "zod";
|
|
3054
|
-
import { randomUUID as
|
|
3207
|
+
import { randomUUID as randomUUID11 } from "crypto";
|
|
3055
3208
|
var MAX_AGENTS_PER_GUARANTOR = 10;
|
|
3056
3209
|
var GUARANTOR_CREDIT_POOL = 50;
|
|
3057
3210
|
var GuarantorRecordSchema = z5.object({
|
|
@@ -3090,7 +3243,7 @@ function registerGuarantor(db, githubLogin) {
|
|
|
3090
3243
|
);
|
|
3091
3244
|
}
|
|
3092
3245
|
const record = {
|
|
3093
|
-
id:
|
|
3246
|
+
id: randomUUID11(),
|
|
3094
3247
|
github_login: githubLogin,
|
|
3095
3248
|
agent_count: 0,
|
|
3096
3249
|
credit_pool: GUARANTOR_CREDIT_POOL,
|
|
@@ -3164,7 +3317,7 @@ function getAgentGuarantor(db, agentId) {
|
|
|
3164
3317
|
function initiateGithubAuth() {
|
|
3165
3318
|
return {
|
|
3166
3319
|
auth_url: "https://github.com/login/oauth/authorize?client_id=PLACEHOLDER&scope=read:user",
|
|
3167
|
-
state:
|
|
3320
|
+
state: randomUUID11()
|
|
3168
3321
|
};
|
|
3169
3322
|
}
|
|
3170
3323
|
|
|
@@ -3248,7 +3401,7 @@ var RelayMessageSchema = z6.discriminatedUnion("type", [
|
|
|
3248
3401
|
]);
|
|
3249
3402
|
|
|
3250
3403
|
// src/relay/websocket-relay.ts
|
|
3251
|
-
import { randomUUID as
|
|
3404
|
+
import { randomUUID as randomUUID14 } from "crypto";
|
|
3252
3405
|
|
|
3253
3406
|
// src/relay/relay-credit.ts
|
|
3254
3407
|
function lookupCardPrice(registryDb, cardId, skillId) {
|
|
@@ -3306,10 +3459,10 @@ function releaseForRelay(creditDb, escrowId) {
|
|
|
3306
3459
|
}
|
|
3307
3460
|
|
|
3308
3461
|
// src/hub-agent/relay-bridge.ts
|
|
3309
|
-
import { randomUUID as
|
|
3462
|
+
import { randomUUID as randomUUID13 } from "crypto";
|
|
3310
3463
|
|
|
3311
3464
|
// src/hub-agent/job-queue.ts
|
|
3312
|
-
import { randomUUID as
|
|
3465
|
+
import { randomUUID as randomUUID12 } from "crypto";
|
|
3313
3466
|
function updateJobStatus(db, jobId, status, result) {
|
|
3314
3467
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3315
3468
|
if (result !== void 0) {
|
|
@@ -3430,7 +3583,7 @@ function registerWebSocketRelay(server, db, creditDb) {
|
|
|
3430
3583
|
function logAgentJoined(owner, cardName, cardId) {
|
|
3431
3584
|
try {
|
|
3432
3585
|
insertRequestLog(db, {
|
|
3433
|
-
id:
|
|
3586
|
+
id: randomUUID14(),
|
|
3434
3587
|
card_id: cardId,
|
|
3435
3588
|
card_name: cardName,
|
|
3436
3589
|
requester: owner,
|
|
@@ -3772,7 +3925,7 @@ function registerWebSocketRelay(server, db, creditDb) {
|
|
|
3772
3925
|
|
|
3773
3926
|
// src/relay/websocket-client.ts
|
|
3774
3927
|
import WebSocket from "ws";
|
|
3775
|
-
import { randomUUID as
|
|
3928
|
+
import { randomUUID as randomUUID15 } from "crypto";
|
|
3776
3929
|
var RelayClient = class {
|
|
3777
3930
|
ws = null;
|
|
3778
3931
|
opts;
|
|
@@ -3869,7 +4022,7 @@ var RelayClient = class {
|
|
|
3869
4022
|
if (!this.ws || this.ws.readyState !== WebSocket.OPEN || !this.registered) {
|
|
3870
4023
|
throw new Error("Not connected to registry relay");
|
|
3871
4024
|
}
|
|
3872
|
-
const id =
|
|
4025
|
+
const id = randomUUID15();
|
|
3873
4026
|
const timeoutMs = opts.timeoutMs ?? 3e5;
|
|
3874
4027
|
return new Promise((resolve, reject) => {
|
|
3875
4028
|
const timeout = setTimeout(() => {
|
|
@@ -4073,12 +4226,12 @@ var RelayClient = class {
|
|
|
4073
4226
|
};
|
|
4074
4227
|
|
|
4075
4228
|
// src/onboarding/index.ts
|
|
4076
|
-
import { randomUUID as
|
|
4229
|
+
import { randomUUID as randomUUID17 } from "crypto";
|
|
4077
4230
|
import { existsSync as existsSync5, readFileSync as readFileSync5 } from "fs";
|
|
4078
4231
|
import { join as join5 } from "path";
|
|
4079
4232
|
|
|
4080
4233
|
// src/cli/onboarding.ts
|
|
4081
|
-
import { randomUUID as
|
|
4234
|
+
import { randomUUID as randomUUID16 } from "crypto";
|
|
4082
4235
|
import { createConnection } from "net";
|
|
4083
4236
|
var KNOWN_API_KEYS = [
|
|
4084
4237
|
"OPENAI_API_KEY",
|
|
@@ -4220,7 +4373,7 @@ function capabilitiesToV2Card(capabilities, owner, agentName) {
|
|
|
4220
4373
|
}));
|
|
4221
4374
|
const card = {
|
|
4222
4375
|
spec_version: "2.0",
|
|
4223
|
-
id:
|
|
4376
|
+
id: randomUUID17(),
|
|
4224
4377
|
owner,
|
|
4225
4378
|
agent_name: agentName ?? owner,
|
|
4226
4379
|
skills,
|