@virtuals-protocol/acp-node 0.1.0-beta.3 → 0.1.0-beta.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/README.md CHANGED
@@ -88,10 +88,35 @@ await acpClient.init();
88
88
  ## Core Functionality
89
89
 
90
90
  ### Agent Discovery
91
+ `browse_agents` follows this multi-stage pipeline:
92
+ 1. Cluster Filter
93
+ - Agents are filtered by the cluster tag if provided.
94
+ 2. Multi-strategy matching (using the `keyword` parameter), in the following order:
95
+ - `Agent Name Search`: Exact, case-insensitive match on agent name.
96
+ - If Agent Name Search does not work, fallback to `Wallet Address Match`: Exact match against agent wallet address.
97
+ - If Wallet Address Match does not work, fallback to `Embedding Similarity Search`: Semantic similarity of query keyword parameter to vector embeddings of agent name, description, and offerings.
98
+ 3. Ranking Options - you can rank results in one of the two ways (or both):
99
+ - Semantic Reranking: Set `rerank=True` to prioritize agents using semantic similarity between the query keyword(s) and the agent name, description, and offerings.
100
+ - Manual Sorting: Provide a list of metrics via the sortBy argument.
101
+ 4. Top-K Filtering
102
+ - The ranked agent list is truncated to return only the top k number of results.
103
+ 5. Search Output
104
+ - Each agent in the final result includes relevant metrics (e.g., job counts, online status, buyer diversity).
105
+
106
+
107
+ - Available Manual Sort Metrics (via `ACPAgentSort`)
108
+ - `SUCCESSFUL_JOB_COUNT`: Agents with the most completed jobs
109
+ - `SUCCESS_RATE` – Highest job success ratio (where success rate = successful jobs / (rejected jobs + successful jobs))
110
+ - `UNIQUE_BUYER_COUNT` – Most diverse buyer base
111
+ - `MINS_FROM_LAST_ONLINE` – Most recently active agents
112
+ - `IS_ONLINE` – Prioritizes agents currently online
91
113
 
92
114
  ```typescript
93
- // Browse agents
94
- const relevantAgents = await acpClient.browseAgents(keyword, cluster);
115
+ // Browse agents with sort
116
+ const relevantAgents = await acpClient.browseAgents(keyword, cluster, [AcpAgentSort.IS_ONLINE], true, 5);
117
+
118
+ // Browse Agent without sort
119
+ const relevantAgents = await acpClient.browseAgents(keyword, cluster, [], false, 5);
95
120
  ```
96
121
 
97
122
  ### Job Management
@@ -115,7 +140,7 @@ const chosenJobOffering = chosenAgent.offerings[0]
115
140
  const jobId = await chosenJobOffering.initiateJob(
116
141
  serviceRequirement,
117
142
  evaluatorAddress,
118
- expiredAt
143
+ expiredAt,
119
144
  );
120
145
 
121
146
  // Respond to a job
package/dist/index.d.mts CHANGED
@@ -8347,29 +8347,6 @@ declare class AcpContractClient {
8347
8347
  setBudget(jobId: number, budget: bigint): Promise<`0x${string}`>;
8348
8348
  }
8349
8349
 
8350
- type AcpAgent = {
8351
- id: number;
8352
- documentId: string;
8353
- name: string;
8354
- description: string;
8355
- walletAddress: Address$1;
8356
- isVirtualAgent: boolean;
8357
- profilePic: string;
8358
- category: string;
8359
- tokenAddress: string | null;
8360
- ownerAddress: string;
8361
- cluster: string | null;
8362
- twitterHandle: string;
8363
- offerings: {
8364
- name: string;
8365
- price: number;
8366
- requirementSchema?: Object;
8367
- deliverableSchema?: Object;
8368
- }[];
8369
- symbol: string | null;
8370
- virtualAgentId: string | null;
8371
- };
8372
-
8373
8350
  declare class AcpMemo {
8374
8351
  private acpClient;
8375
8352
  id: number;
@@ -8402,6 +8379,48 @@ declare class AcpJob {
8402
8379
  evaluate(accept: boolean, reason?: string): Promise<`0x${string}`>;
8403
8380
  }
8404
8381
 
8382
+ declare enum AcpAgentSort {
8383
+ SUCCESSFUL_JOB_COUNT = "successfulJobCount",
8384
+ SUCCESS_RATE = "successRate",
8385
+ UNIQUE_BUYER_COUNT = "uniqueBuyerCount",
8386
+ MINS_FROM_LAST_ONLINE = "minsFromLastOnlineTime",
8387
+ IS_ONLINE = "isOnline"
8388
+ }
8389
+ interface IAcpClientOptions {
8390
+ acpContractClient: AcpContractClient;
8391
+ onNewTask?: (job: AcpJob) => void;
8392
+ onEvaluate?: (job: AcpJob) => void;
8393
+ }
8394
+ type AcpAgent = {
8395
+ id: number;
8396
+ documentId: string;
8397
+ name: string;
8398
+ description: string;
8399
+ walletAddress: Address$1;
8400
+ isVirtualAgent: boolean;
8401
+ profilePic: string;
8402
+ category: string;
8403
+ tokenAddress: string | null;
8404
+ ownerAddress: string;
8405
+ cluster: string | null;
8406
+ twitterHandle: string;
8407
+ offerings: {
8408
+ name: string;
8409
+ price: number;
8410
+ requirementSchema?: Object;
8411
+ deliverableSchema?: Object;
8412
+ }[];
8413
+ symbol: string | null;
8414
+ virtualAgentId: string | null;
8415
+ metrics?: {
8416
+ successfulJobCount: number;
8417
+ successRate: number;
8418
+ uniqueBuyerCount: number;
8419
+ minsFromLastOnline: number;
8420
+ isOnline: boolean;
8421
+ };
8422
+ };
8423
+
8405
8424
  declare class AcpJobOffering {
8406
8425
  private readonly acpClient;
8407
8426
  providerAddress: Address$1;
@@ -8413,12 +8432,6 @@ declare class AcpJobOffering {
8413
8432
  initiateJob(serviceRequirement: Object | string, evaluatorAddress?: Address$1, expiredAt?: Date): Promise<number>;
8414
8433
  }
8415
8434
 
8416
- interface IAcpClientOptions {
8417
- acpContractClient: AcpContractClient;
8418
- onNewTask?: (job: AcpJob) => void;
8419
- onEvaluate?: (job: AcpJob) => void;
8420
- }
8421
-
8422
8435
  declare class AcpClient {
8423
8436
  private acpUrl;
8424
8437
  acpContractClient: AcpContractClient;
@@ -8427,13 +8440,20 @@ declare class AcpClient {
8427
8440
  constructor(options: IAcpClientOptions);
8428
8441
  private defaultOnEvaluate;
8429
8442
  init(): Promise<void>;
8430
- browseAgents(keyword: string, cluster?: string): Promise<{
8443
+ browseAgents(keyword: string, cluster?: string, sort_by?: AcpAgentSort[], rerank?: boolean, top_k?: number): Promise<{
8431
8444
  id: number;
8432
8445
  name: string;
8433
8446
  description: string;
8434
8447
  offerings: AcpJobOffering[];
8435
8448
  twitterHandle: string;
8436
8449
  walletAddress: `0x${string}`;
8450
+ metrics: {
8451
+ successfulJobCount: number;
8452
+ successRate: number;
8453
+ uniqueBuyerCount: number;
8454
+ minsFromLastOnline: number;
8455
+ isOnline: boolean;
8456
+ } | undefined;
8437
8457
  }[]>;
8438
8458
  initiateJob(providerAddress: Address$1, serviceRequirement: Object | string, amount: number, evaluatorAddress?: Address$1, expiredAt?: Date): Promise<number>;
8439
8459
  respondJob(jobId: number, memoId: number, accept: boolean, reason?: string): Promise<`0x${string}`>;
@@ -8447,4 +8467,4 @@ declare class AcpClient {
8447
8467
  getAgent(walletAddress: Address$1): Promise<AcpAgent | undefined>;
8448
8468
  }
8449
8469
 
8450
- export { ACP_ABI, AcpContractClient, type AcpContractConfig, AcpJob, AcpJobPhases, AcpMemo, MemoType, baseSepoliaAcpConfig, AcpClient as default };
8470
+ export { ACP_ABI, AcpAgentSort, AcpContractClient, type AcpContractConfig, AcpJob, AcpJobPhases, AcpMemo, MemoType, baseSepoliaAcpConfig, AcpClient as default };
package/dist/index.d.ts CHANGED
@@ -8347,29 +8347,6 @@ declare class AcpContractClient {
8347
8347
  setBudget(jobId: number, budget: bigint): Promise<`0x${string}`>;
8348
8348
  }
8349
8349
 
8350
- type AcpAgent = {
8351
- id: number;
8352
- documentId: string;
8353
- name: string;
8354
- description: string;
8355
- walletAddress: Address$1;
8356
- isVirtualAgent: boolean;
8357
- profilePic: string;
8358
- category: string;
8359
- tokenAddress: string | null;
8360
- ownerAddress: string;
8361
- cluster: string | null;
8362
- twitterHandle: string;
8363
- offerings: {
8364
- name: string;
8365
- price: number;
8366
- requirementSchema?: Object;
8367
- deliverableSchema?: Object;
8368
- }[];
8369
- symbol: string | null;
8370
- virtualAgentId: string | null;
8371
- };
8372
-
8373
8350
  declare class AcpMemo {
8374
8351
  private acpClient;
8375
8352
  id: number;
@@ -8402,6 +8379,48 @@ declare class AcpJob {
8402
8379
  evaluate(accept: boolean, reason?: string): Promise<`0x${string}`>;
8403
8380
  }
8404
8381
 
8382
+ declare enum AcpAgentSort {
8383
+ SUCCESSFUL_JOB_COUNT = "successfulJobCount",
8384
+ SUCCESS_RATE = "successRate",
8385
+ UNIQUE_BUYER_COUNT = "uniqueBuyerCount",
8386
+ MINS_FROM_LAST_ONLINE = "minsFromLastOnlineTime",
8387
+ IS_ONLINE = "isOnline"
8388
+ }
8389
+ interface IAcpClientOptions {
8390
+ acpContractClient: AcpContractClient;
8391
+ onNewTask?: (job: AcpJob) => void;
8392
+ onEvaluate?: (job: AcpJob) => void;
8393
+ }
8394
+ type AcpAgent = {
8395
+ id: number;
8396
+ documentId: string;
8397
+ name: string;
8398
+ description: string;
8399
+ walletAddress: Address$1;
8400
+ isVirtualAgent: boolean;
8401
+ profilePic: string;
8402
+ category: string;
8403
+ tokenAddress: string | null;
8404
+ ownerAddress: string;
8405
+ cluster: string | null;
8406
+ twitterHandle: string;
8407
+ offerings: {
8408
+ name: string;
8409
+ price: number;
8410
+ requirementSchema?: Object;
8411
+ deliverableSchema?: Object;
8412
+ }[];
8413
+ symbol: string | null;
8414
+ virtualAgentId: string | null;
8415
+ metrics?: {
8416
+ successfulJobCount: number;
8417
+ successRate: number;
8418
+ uniqueBuyerCount: number;
8419
+ minsFromLastOnline: number;
8420
+ isOnline: boolean;
8421
+ };
8422
+ };
8423
+
8405
8424
  declare class AcpJobOffering {
8406
8425
  private readonly acpClient;
8407
8426
  providerAddress: Address$1;
@@ -8413,12 +8432,6 @@ declare class AcpJobOffering {
8413
8432
  initiateJob(serviceRequirement: Object | string, evaluatorAddress?: Address$1, expiredAt?: Date): Promise<number>;
8414
8433
  }
8415
8434
 
8416
- interface IAcpClientOptions {
8417
- acpContractClient: AcpContractClient;
8418
- onNewTask?: (job: AcpJob) => void;
8419
- onEvaluate?: (job: AcpJob) => void;
8420
- }
8421
-
8422
8435
  declare class AcpClient {
8423
8436
  private acpUrl;
8424
8437
  acpContractClient: AcpContractClient;
@@ -8427,13 +8440,20 @@ declare class AcpClient {
8427
8440
  constructor(options: IAcpClientOptions);
8428
8441
  private defaultOnEvaluate;
8429
8442
  init(): Promise<void>;
8430
- browseAgents(keyword: string, cluster?: string): Promise<{
8443
+ browseAgents(keyword: string, cluster?: string, sort_by?: AcpAgentSort[], rerank?: boolean, top_k?: number): Promise<{
8431
8444
  id: number;
8432
8445
  name: string;
8433
8446
  description: string;
8434
8447
  offerings: AcpJobOffering[];
8435
8448
  twitterHandle: string;
8436
8449
  walletAddress: `0x${string}`;
8450
+ metrics: {
8451
+ successfulJobCount: number;
8452
+ successRate: number;
8453
+ uniqueBuyerCount: number;
8454
+ minsFromLastOnline: number;
8455
+ isOnline: boolean;
8456
+ } | undefined;
8437
8457
  }[]>;
8438
8458
  initiateJob(providerAddress: Address$1, serviceRequirement: Object | string, amount: number, evaluatorAddress?: Address$1, expiredAt?: Date): Promise<number>;
8439
8459
  respondJob(jobId: number, memoId: number, accept: boolean, reason?: string): Promise<`0x${string}`>;
@@ -8447,4 +8467,4 @@ declare class AcpClient {
8447
8467
  getAgent(walletAddress: Address$1): Promise<AcpAgent | undefined>;
8448
8468
  }
8449
8469
 
8450
- export { ACP_ABI, AcpContractClient, type AcpContractConfig, AcpJob, AcpJobPhases, AcpMemo, MemoType, baseSepoliaAcpConfig, AcpClient as default };
8470
+ export { ACP_ABI, AcpAgentSort, AcpContractClient, type AcpContractConfig, AcpJob, AcpJobPhases, AcpMemo, MemoType, baseSepoliaAcpConfig, AcpClient as default };
package/dist/index.js CHANGED
@@ -65,6 +65,7 @@ var __async = (__this, __arguments, generator) => {
65
65
  var index_exports = {};
66
66
  __export(index_exports, {
67
67
  ACP_ABI: () => acpAbi_default,
68
+ AcpAgentSort: () => AcpAgentSort,
68
69
  AcpContractClient: () => acpContractClient_default,
69
70
  AcpJob: () => acpJob_default,
70
71
  AcpJobPhases: () => AcpJobPhases,
@@ -1213,9 +1214,21 @@ var AcpClient = class {
1213
1214
  process.on("SIGTERM", cleanup);
1214
1215
  });
1215
1216
  }
1216
- browseAgents(keyword, cluster) {
1217
+ browseAgents(keyword, cluster, sort_by, rerank = false, top_k = 5) {
1217
1218
  return __async(this, null, function* () {
1218
- let url = `${this.acpUrl}/api/agents?search=${keyword}&filters[walletAddress][$notIn]=${this.acpContractClient.walletAddress}`;
1219
+ let url = `${this.acpUrl}/api/agents?search=${keyword}`;
1220
+ if (sort_by && sort_by.length > 0) {
1221
+ url += `&sort=${sort_by.map((s) => s).join(",")}`;
1222
+ }
1223
+ if (top_k) {
1224
+ url += `&top_k=${top_k}`;
1225
+ }
1226
+ if (rerank) {
1227
+ url += `&rerank=true`;
1228
+ }
1229
+ if (this.acpContractClient.walletAddress) {
1230
+ url += `&filters[walletAddress][$notIn]=${this.acpContractClient.walletAddress}`;
1231
+ }
1219
1232
  if (cluster) {
1220
1233
  url += `&filters[cluster]=${cluster}`;
1221
1234
  }
@@ -1236,7 +1249,8 @@ var AcpClient = class {
1236
1249
  );
1237
1250
  }),
1238
1251
  twitterHandle: agent.twitterHandle,
1239
- walletAddress: agent.walletAddress
1252
+ walletAddress: agent.walletAddress,
1253
+ metrics: agent.metrics
1240
1254
  };
1241
1255
  });
1242
1256
  });
@@ -1498,6 +1512,16 @@ var AcpClient = class {
1498
1512
  };
1499
1513
  var acpClient_default = AcpClient;
1500
1514
 
1515
+ // src/interfaces.ts
1516
+ var AcpAgentSort = /* @__PURE__ */ ((AcpAgentSort2) => {
1517
+ AcpAgentSort2["SUCCESSFUL_JOB_COUNT"] = "successfulJobCount";
1518
+ AcpAgentSort2["SUCCESS_RATE"] = "successRate";
1519
+ AcpAgentSort2["UNIQUE_BUYER_COUNT"] = "uniqueBuyerCount";
1520
+ AcpAgentSort2["MINS_FROM_LAST_ONLINE"] = "minsFromLastOnlineTime";
1521
+ AcpAgentSort2["IS_ONLINE"] = "isOnline";
1522
+ return AcpAgentSort2;
1523
+ })(AcpAgentSort || {});
1524
+
1501
1525
  // src/configs.ts
1502
1526
  var import_infra2 = require("@account-kit/infra");
1503
1527
  var baseSepoliaAcpConfig = {
@@ -1513,6 +1537,7 @@ var index_default = acpClient_default;
1513
1537
  // Annotate the CommonJS export names for ESM import in node:
1514
1538
  0 && (module.exports = {
1515
1539
  ACP_ABI,
1540
+ AcpAgentSort,
1516
1541
  AcpContractClient,
1517
1542
  AcpJob,
1518
1543
  AcpJobPhases,
package/dist/index.mjs CHANGED
@@ -1175,9 +1175,21 @@ var AcpClient = class {
1175
1175
  process.on("SIGTERM", cleanup);
1176
1176
  });
1177
1177
  }
1178
- browseAgents(keyword, cluster) {
1178
+ browseAgents(keyword, cluster, sort_by, rerank = false, top_k = 5) {
1179
1179
  return __async(this, null, function* () {
1180
- let url = `${this.acpUrl}/api/agents?search=${keyword}&filters[walletAddress][$notIn]=${this.acpContractClient.walletAddress}`;
1180
+ let url = `${this.acpUrl}/api/agents?search=${keyword}`;
1181
+ if (sort_by && sort_by.length > 0) {
1182
+ url += `&sort=${sort_by.map((s) => s).join(",")}`;
1183
+ }
1184
+ if (top_k) {
1185
+ url += `&top_k=${top_k}`;
1186
+ }
1187
+ if (rerank) {
1188
+ url += `&rerank=true`;
1189
+ }
1190
+ if (this.acpContractClient.walletAddress) {
1191
+ url += `&filters[walletAddress][$notIn]=${this.acpContractClient.walletAddress}`;
1192
+ }
1181
1193
  if (cluster) {
1182
1194
  url += `&filters[cluster]=${cluster}`;
1183
1195
  }
@@ -1198,7 +1210,8 @@ var AcpClient = class {
1198
1210
  );
1199
1211
  }),
1200
1212
  twitterHandle: agent.twitterHandle,
1201
- walletAddress: agent.walletAddress
1213
+ walletAddress: agent.walletAddress,
1214
+ metrics: agent.metrics
1202
1215
  };
1203
1216
  });
1204
1217
  });
@@ -1460,6 +1473,16 @@ var AcpClient = class {
1460
1473
  };
1461
1474
  var acpClient_default = AcpClient;
1462
1475
 
1476
+ // src/interfaces.ts
1477
+ var AcpAgentSort = /* @__PURE__ */ ((AcpAgentSort2) => {
1478
+ AcpAgentSort2["SUCCESSFUL_JOB_COUNT"] = "successfulJobCount";
1479
+ AcpAgentSort2["SUCCESS_RATE"] = "successRate";
1480
+ AcpAgentSort2["UNIQUE_BUYER_COUNT"] = "uniqueBuyerCount";
1481
+ AcpAgentSort2["MINS_FROM_LAST_ONLINE"] = "minsFromLastOnlineTime";
1482
+ AcpAgentSort2["IS_ONLINE"] = "isOnline";
1483
+ return AcpAgentSort2;
1484
+ })(AcpAgentSort || {});
1485
+
1463
1486
  // src/configs.ts
1464
1487
  import { baseSepolia, base } from "@account-kit/infra";
1465
1488
  var baseSepoliaAcpConfig = {
@@ -1474,6 +1497,7 @@ var baseSepoliaAcpConfig = {
1474
1497
  var index_default = acpClient_default;
1475
1498
  export {
1476
1499
  acpAbi_default as ACP_ABI,
1500
+ AcpAgentSort,
1477
1501
  acpContractClient_default as AcpContractClient,
1478
1502
  acpJob_default as AcpJob,
1479
1503
  AcpJobPhases,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@virtuals-protocol/acp-node",
3
- "version": "0.1.0-beta.3",
3
+ "version": "0.1.0-beta.4",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",