@bopen-io/clawnet-plugin 0.0.3 → 0.0.4
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/worker.js +54 -12
- package/dist/worker.js.map +2 -2
- package/package.json +1 -1
package/dist/worker.js
CHANGED
|
@@ -6492,15 +6492,15 @@ function registerEventHandlers(ctx) {
|
|
|
6492
6492
|
}
|
|
6493
6493
|
function registerDataHandlers(ctx) {
|
|
6494
6494
|
ctx.data.register(DATA_KEYS.clawnetAgents, async (params) => {
|
|
6495
|
-
const { search, limit } = getListParams(params);
|
|
6496
|
-
|
|
6495
|
+
const { search, page, limit } = getListParams(params);
|
|
6496
|
+
let entities = await ctx.entities.list({
|
|
6497
6497
|
entityType: ENTITY_TYPES.agent,
|
|
6498
6498
|
limit,
|
|
6499
6499
|
offset: 0
|
|
6500
6500
|
});
|
|
6501
6501
|
if (search) {
|
|
6502
6502
|
const term = search.toLowerCase();
|
|
6503
|
-
|
|
6503
|
+
entities = entities.filter((entity) => {
|
|
6504
6504
|
const titleMatch = entity.title?.toLowerCase().includes(term);
|
|
6505
6505
|
const data = entity.data;
|
|
6506
6506
|
const nameMatch = typeof data.name === "string" && data.name.toLowerCase().includes(term);
|
|
@@ -6508,18 +6508,36 @@ function registerDataHandlers(ctx) {
|
|
|
6508
6508
|
return titleMatch || nameMatch || descMatch;
|
|
6509
6509
|
});
|
|
6510
6510
|
}
|
|
6511
|
-
|
|
6511
|
+
const agents = entities.map((entity) => {
|
|
6512
|
+
const d = entity.data;
|
|
6513
|
+
return {
|
|
6514
|
+
id: entity.externalId ?? entity.id,
|
|
6515
|
+
slug: d.slug ?? entity.externalId ?? "",
|
|
6516
|
+
displayName: entity.title ?? d.displayName ?? d.name ?? "",
|
|
6517
|
+
description: d.description ?? null,
|
|
6518
|
+
model: d.model ?? null,
|
|
6519
|
+
color: d.color ?? null,
|
|
6520
|
+
starCount: d.starCount ?? 0,
|
|
6521
|
+
trustScore: null,
|
|
6522
|
+
// Not yet available from ClawNet
|
|
6523
|
+
attestations: [],
|
|
6524
|
+
// Not yet available from ClawNet
|
|
6525
|
+
skills: Array.isArray(d.skills) ? d.skills : [],
|
|
6526
|
+
createdAt: entity.createdAt
|
|
6527
|
+
};
|
|
6528
|
+
});
|
|
6529
|
+
return { agents, total: agents.length, page, limit };
|
|
6512
6530
|
});
|
|
6513
6531
|
ctx.data.register(DATA_KEYS.clawnetSkills, async (params) => {
|
|
6514
6532
|
const { search, limit } = getListParams(params);
|
|
6515
|
-
|
|
6533
|
+
let entities = await ctx.entities.list({
|
|
6516
6534
|
entityType: ENTITY_TYPES.skill,
|
|
6517
6535
|
limit,
|
|
6518
6536
|
offset: 0
|
|
6519
6537
|
});
|
|
6520
6538
|
if (search) {
|
|
6521
6539
|
const term = search.toLowerCase();
|
|
6522
|
-
|
|
6540
|
+
entities = entities.filter((entity) => {
|
|
6523
6541
|
const titleMatch = entity.title?.toLowerCase().includes(term);
|
|
6524
6542
|
const data = entity.data;
|
|
6525
6543
|
const nameMatch = typeof data.name === "string" && data.name.toLowerCase().includes(term);
|
|
@@ -6527,7 +6545,18 @@ function registerDataHandlers(ctx) {
|
|
|
6527
6545
|
return titleMatch || nameMatch || descMatch;
|
|
6528
6546
|
});
|
|
6529
6547
|
}
|
|
6530
|
-
|
|
6548
|
+
const skills = entities.map((entity) => {
|
|
6549
|
+
const d = entity.data;
|
|
6550
|
+
return {
|
|
6551
|
+
id: entity.externalId ?? entity.id,
|
|
6552
|
+
slug: d.slug ?? entity.externalId ?? "",
|
|
6553
|
+
displayName: entity.title ?? d.displayName ?? d.name ?? "",
|
|
6554
|
+
description: d.description ?? null,
|
|
6555
|
+
category: d.category ?? null,
|
|
6556
|
+
starCount: d.starCount ?? 0
|
|
6557
|
+
};
|
|
6558
|
+
});
|
|
6559
|
+
return { skills, total: skills.length };
|
|
6531
6560
|
});
|
|
6532
6561
|
ctx.data.register(DATA_KEYS.syncStatus, async () => {
|
|
6533
6562
|
const cursor = await getSyncCursor(ctx);
|
|
@@ -6559,6 +6588,23 @@ function registerDataHandlers(ctx) {
|
|
|
6559
6588
|
stateKey: STATE_KEYS.clawnetLink
|
|
6560
6589
|
});
|
|
6561
6590
|
const clawnetMatch = linkState ? clawnetEntities.find((e) => e.externalId === linkState.clawnetExternalId) : null;
|
|
6591
|
+
let clawnetTemplate = null;
|
|
6592
|
+
if (clawnetMatch) {
|
|
6593
|
+
const d = clawnetMatch.data;
|
|
6594
|
+
clawnetTemplate = {
|
|
6595
|
+
id: clawnetMatch.externalId ?? clawnetMatch.id,
|
|
6596
|
+
slug: d.slug ?? clawnetMatch.externalId ?? "",
|
|
6597
|
+
displayName: clawnetMatch.title ?? d.displayName ?? d.name ?? "",
|
|
6598
|
+
description: d.description ?? null,
|
|
6599
|
+
model: d.model ?? null,
|
|
6600
|
+
color: d.color ?? null,
|
|
6601
|
+
starCount: d.starCount ?? 0,
|
|
6602
|
+
trustScore: null,
|
|
6603
|
+
attestations: [],
|
|
6604
|
+
skills: Array.isArray(d.skills) ? d.skills : [],
|
|
6605
|
+
createdAt: clawnetMatch.createdAt
|
|
6606
|
+
};
|
|
6607
|
+
}
|
|
6562
6608
|
return {
|
|
6563
6609
|
paperclipAgent: {
|
|
6564
6610
|
id: agent.id,
|
|
@@ -6567,11 +6613,7 @@ function registerDataHandlers(ctx) {
|
|
|
6567
6613
|
role: agent.role
|
|
6568
6614
|
},
|
|
6569
6615
|
clawnetLink: linkState,
|
|
6570
|
-
clawnetTemplate
|
|
6571
|
-
externalId: clawnetMatch.externalId,
|
|
6572
|
-
title: clawnetMatch.title,
|
|
6573
|
-
data: clawnetMatch.data
|
|
6574
|
-
} : null
|
|
6616
|
+
clawnetTemplate
|
|
6575
6617
|
};
|
|
6576
6618
|
})
|
|
6577
6619
|
);
|