@virtuals-protocol/acp-node 0.1.0-beta.3 → 0.1.0-beta.5

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
@@ -75,6 +75,7 @@ type AcpContractConfig = {
75
75
  alchemyRpcUrl: string;
76
76
  };
77
77
  declare const baseSepoliaAcpConfig: AcpContractConfig;
78
+ declare const baseAcpConfig: AcpContractConfig;
78
79
 
79
80
  declare enum MemoType {
80
81
  MESSAGE = 0,
@@ -101,8 +102,8 @@ declare class AcpContractClient {
101
102
  private chain;
102
103
  private contractAddress;
103
104
  private virtualsTokenAddress;
104
- constructor(walletPrivateKey: Address, sessionEntityKeyId: number, agentWalletAddress: Address, config: AcpContractConfig);
105
- static build(walletPrivateKey: Address, sessionEntityKeyId: number, agentWalletAddress: Address, config: AcpContractConfig): Promise<AcpContractClient>;
105
+ constructor(walletPrivateKey: Address, sessionEntityKeyId: number, agentWalletAddress: Address, config?: AcpContractConfig);
106
+ static build(walletPrivateKey: Address, sessionEntityKeyId: number, agentWalletAddress: Address, config?: AcpContractConfig): Promise<AcpContractClient>;
106
107
  init(): Promise<void>;
107
108
  get sessionKeyClient(): {
108
109
  [x: string]: unknown;
@@ -8347,29 +8348,6 @@ declare class AcpContractClient {
8347
8348
  setBudget(jobId: number, budget: bigint): Promise<`0x${string}`>;
8348
8349
  }
8349
8350
 
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
8351
  declare class AcpMemo {
8374
8352
  private acpClient;
8375
8353
  id: number;
@@ -8390,7 +8368,8 @@ declare class AcpJob {
8390
8368
  price: number;
8391
8369
  memos: AcpMemo[];
8392
8370
  phase: AcpJobPhases;
8393
- constructor(acpClient: AcpClient, id: number, clientAddress: Address$1, providerAddress: Address$1, evaluatorAddress: Address$1, price: number, memos: AcpMemo[], phase: AcpJobPhases);
8371
+ context: Record<string, any>;
8372
+ constructor(acpClient: AcpClient, id: number, clientAddress: Address$1, providerAddress: Address$1, evaluatorAddress: Address$1, price: number, memos: AcpMemo[], phase: AcpJobPhases, context: Record<string, any>);
8394
8373
  get serviceRequirement(): string | undefined;
8395
8374
  get deliverable(): string | undefined;
8396
8375
  get providerAgent(): Promise<AcpAgent | undefined>;
@@ -8402,6 +8381,48 @@ declare class AcpJob {
8402
8381
  evaluate(accept: boolean, reason?: string): Promise<`0x${string}`>;
8403
8382
  }
8404
8383
 
8384
+ declare enum AcpAgentSort {
8385
+ SUCCESSFUL_JOB_COUNT = "successfulJobCount",
8386
+ SUCCESS_RATE = "successRate",
8387
+ UNIQUE_BUYER_COUNT = "uniqueBuyerCount",
8388
+ MINS_FROM_LAST_ONLINE = "minsFromLastOnlineTime",
8389
+ IS_ONLINE = "isOnline"
8390
+ }
8391
+ interface IAcpClientOptions {
8392
+ acpContractClient: AcpContractClient;
8393
+ onNewTask?: (job: AcpJob) => void;
8394
+ onEvaluate?: (job: AcpJob) => void;
8395
+ }
8396
+ type AcpAgent = {
8397
+ id: number;
8398
+ documentId: string;
8399
+ name: string;
8400
+ description: string;
8401
+ walletAddress: Address$1;
8402
+ isVirtualAgent: boolean;
8403
+ profilePic: string;
8404
+ category: string;
8405
+ tokenAddress: string | null;
8406
+ ownerAddress: string;
8407
+ cluster: string | null;
8408
+ twitterHandle: string;
8409
+ offerings: {
8410
+ name: string;
8411
+ price: number;
8412
+ requirementSchema?: Object;
8413
+ deliverableSchema?: Object;
8414
+ }[];
8415
+ symbol: string | null;
8416
+ virtualAgentId: string | null;
8417
+ metrics?: {
8418
+ successfulJobCount: number;
8419
+ successRate: number;
8420
+ uniqueBuyerCount: number;
8421
+ minsFromLastOnline: number;
8422
+ isOnline: boolean;
8423
+ };
8424
+ };
8425
+
8405
8426
  declare class AcpJobOffering {
8406
8427
  private readonly acpClient;
8407
8428
  providerAddress: Address$1;
@@ -8413,12 +8434,6 @@ declare class AcpJobOffering {
8413
8434
  initiateJob(serviceRequirement: Object | string, evaluatorAddress?: Address$1, expiredAt?: Date): Promise<number>;
8414
8435
  }
8415
8436
 
8416
- interface IAcpClientOptions {
8417
- acpContractClient: AcpContractClient;
8418
- onNewTask?: (job: AcpJob) => void;
8419
- onEvaluate?: (job: AcpJob) => void;
8420
- }
8421
-
8422
8437
  declare class AcpClient {
8423
8438
  private acpUrl;
8424
8439
  acpContractClient: AcpContractClient;
@@ -8427,13 +8442,20 @@ declare class AcpClient {
8427
8442
  constructor(options: IAcpClientOptions);
8428
8443
  private defaultOnEvaluate;
8429
8444
  init(): Promise<void>;
8430
- browseAgents(keyword: string, cluster?: string): Promise<{
8445
+ browseAgents(keyword: string, cluster?: string, sort_by?: AcpAgentSort[], rerank?: boolean, top_k?: number): Promise<{
8431
8446
  id: number;
8432
8447
  name: string;
8433
8448
  description: string;
8434
8449
  offerings: AcpJobOffering[];
8435
8450
  twitterHandle: string;
8436
8451
  walletAddress: `0x${string}`;
8452
+ metrics: {
8453
+ successfulJobCount: number;
8454
+ successRate: number;
8455
+ uniqueBuyerCount: number;
8456
+ minsFromLastOnline: number;
8457
+ isOnline: boolean;
8458
+ } | undefined;
8437
8459
  }[]>;
8438
8460
  initiateJob(providerAddress: Address$1, serviceRequirement: Object | string, amount: number, evaluatorAddress?: Address$1, expiredAt?: Date): Promise<number>;
8439
8461
  respondJob(jobId: number, memoId: number, accept: boolean, reason?: string): Promise<`0x${string}`>;
@@ -8447,4 +8469,4 @@ declare class AcpClient {
8447
8469
  getAgent(walletAddress: Address$1): Promise<AcpAgent | undefined>;
8448
8470
  }
8449
8471
 
8450
- export { ACP_ABI, AcpContractClient, type AcpContractConfig, AcpJob, AcpJobPhases, AcpMemo, MemoType, baseSepoliaAcpConfig, AcpClient as default };
8472
+ export { ACP_ABI, AcpAgentSort, AcpContractClient, type AcpContractConfig, AcpJob, AcpJobPhases, AcpMemo, MemoType, baseAcpConfig, baseSepoliaAcpConfig, AcpClient as default };
package/dist/index.d.ts CHANGED
@@ -75,6 +75,7 @@ type AcpContractConfig = {
75
75
  alchemyRpcUrl: string;
76
76
  };
77
77
  declare const baseSepoliaAcpConfig: AcpContractConfig;
78
+ declare const baseAcpConfig: AcpContractConfig;
78
79
 
79
80
  declare enum MemoType {
80
81
  MESSAGE = 0,
@@ -101,8 +102,8 @@ declare class AcpContractClient {
101
102
  private chain;
102
103
  private contractAddress;
103
104
  private virtualsTokenAddress;
104
- constructor(walletPrivateKey: Address, sessionEntityKeyId: number, agentWalletAddress: Address, config: AcpContractConfig);
105
- static build(walletPrivateKey: Address, sessionEntityKeyId: number, agentWalletAddress: Address, config: AcpContractConfig): Promise<AcpContractClient>;
105
+ constructor(walletPrivateKey: Address, sessionEntityKeyId: number, agentWalletAddress: Address, config?: AcpContractConfig);
106
+ static build(walletPrivateKey: Address, sessionEntityKeyId: number, agentWalletAddress: Address, config?: AcpContractConfig): Promise<AcpContractClient>;
106
107
  init(): Promise<void>;
107
108
  get sessionKeyClient(): {
108
109
  [x: string]: unknown;
@@ -8347,29 +8348,6 @@ declare class AcpContractClient {
8347
8348
  setBudget(jobId: number, budget: bigint): Promise<`0x${string}`>;
8348
8349
  }
8349
8350
 
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
8351
  declare class AcpMemo {
8374
8352
  private acpClient;
8375
8353
  id: number;
@@ -8390,7 +8368,8 @@ declare class AcpJob {
8390
8368
  price: number;
8391
8369
  memos: AcpMemo[];
8392
8370
  phase: AcpJobPhases;
8393
- constructor(acpClient: AcpClient, id: number, clientAddress: Address$1, providerAddress: Address$1, evaluatorAddress: Address$1, price: number, memos: AcpMemo[], phase: AcpJobPhases);
8371
+ context: Record<string, any>;
8372
+ constructor(acpClient: AcpClient, id: number, clientAddress: Address$1, providerAddress: Address$1, evaluatorAddress: Address$1, price: number, memos: AcpMemo[], phase: AcpJobPhases, context: Record<string, any>);
8394
8373
  get serviceRequirement(): string | undefined;
8395
8374
  get deliverable(): string | undefined;
8396
8375
  get providerAgent(): Promise<AcpAgent | undefined>;
@@ -8402,6 +8381,48 @@ declare class AcpJob {
8402
8381
  evaluate(accept: boolean, reason?: string): Promise<`0x${string}`>;
8403
8382
  }
8404
8383
 
8384
+ declare enum AcpAgentSort {
8385
+ SUCCESSFUL_JOB_COUNT = "successfulJobCount",
8386
+ SUCCESS_RATE = "successRate",
8387
+ UNIQUE_BUYER_COUNT = "uniqueBuyerCount",
8388
+ MINS_FROM_LAST_ONLINE = "minsFromLastOnlineTime",
8389
+ IS_ONLINE = "isOnline"
8390
+ }
8391
+ interface IAcpClientOptions {
8392
+ acpContractClient: AcpContractClient;
8393
+ onNewTask?: (job: AcpJob) => void;
8394
+ onEvaluate?: (job: AcpJob) => void;
8395
+ }
8396
+ type AcpAgent = {
8397
+ id: number;
8398
+ documentId: string;
8399
+ name: string;
8400
+ description: string;
8401
+ walletAddress: Address$1;
8402
+ isVirtualAgent: boolean;
8403
+ profilePic: string;
8404
+ category: string;
8405
+ tokenAddress: string | null;
8406
+ ownerAddress: string;
8407
+ cluster: string | null;
8408
+ twitterHandle: string;
8409
+ offerings: {
8410
+ name: string;
8411
+ price: number;
8412
+ requirementSchema?: Object;
8413
+ deliverableSchema?: Object;
8414
+ }[];
8415
+ symbol: string | null;
8416
+ virtualAgentId: string | null;
8417
+ metrics?: {
8418
+ successfulJobCount: number;
8419
+ successRate: number;
8420
+ uniqueBuyerCount: number;
8421
+ minsFromLastOnline: number;
8422
+ isOnline: boolean;
8423
+ };
8424
+ };
8425
+
8405
8426
  declare class AcpJobOffering {
8406
8427
  private readonly acpClient;
8407
8428
  providerAddress: Address$1;
@@ -8413,12 +8434,6 @@ declare class AcpJobOffering {
8413
8434
  initiateJob(serviceRequirement: Object | string, evaluatorAddress?: Address$1, expiredAt?: Date): Promise<number>;
8414
8435
  }
8415
8436
 
8416
- interface IAcpClientOptions {
8417
- acpContractClient: AcpContractClient;
8418
- onNewTask?: (job: AcpJob) => void;
8419
- onEvaluate?: (job: AcpJob) => void;
8420
- }
8421
-
8422
8437
  declare class AcpClient {
8423
8438
  private acpUrl;
8424
8439
  acpContractClient: AcpContractClient;
@@ -8427,13 +8442,20 @@ declare class AcpClient {
8427
8442
  constructor(options: IAcpClientOptions);
8428
8443
  private defaultOnEvaluate;
8429
8444
  init(): Promise<void>;
8430
- browseAgents(keyword: string, cluster?: string): Promise<{
8445
+ browseAgents(keyword: string, cluster?: string, sort_by?: AcpAgentSort[], rerank?: boolean, top_k?: number): Promise<{
8431
8446
  id: number;
8432
8447
  name: string;
8433
8448
  description: string;
8434
8449
  offerings: AcpJobOffering[];
8435
8450
  twitterHandle: string;
8436
8451
  walletAddress: `0x${string}`;
8452
+ metrics: {
8453
+ successfulJobCount: number;
8454
+ successRate: number;
8455
+ uniqueBuyerCount: number;
8456
+ minsFromLastOnline: number;
8457
+ isOnline: boolean;
8458
+ } | undefined;
8437
8459
  }[]>;
8438
8460
  initiateJob(providerAddress: Address$1, serviceRequirement: Object | string, amount: number, evaluatorAddress?: Address$1, expiredAt?: Date): Promise<number>;
8439
8461
  respondJob(jobId: number, memoId: number, accept: boolean, reason?: string): Promise<`0x${string}`>;
@@ -8447,4 +8469,4 @@ declare class AcpClient {
8447
8469
  getAgent(walletAddress: Address$1): Promise<AcpAgent | undefined>;
8448
8470
  }
8449
8471
 
8450
- export { ACP_ABI, AcpContractClient, type AcpContractConfig, AcpJob, AcpJobPhases, AcpMemo, MemoType, baseSepoliaAcpConfig, AcpClient as default };
8472
+ export { ACP_ABI, AcpAgentSort, AcpContractClient, type AcpContractConfig, AcpJob, AcpJobPhases, AcpMemo, MemoType, baseAcpConfig, baseSepoliaAcpConfig, AcpClient as default };
package/dist/index.js CHANGED
@@ -65,11 +65,13 @@ 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,
71
72
  AcpMemo: () => acpMemo_default,
72
73
  MemoType: () => MemoType,
74
+ baseAcpConfig: () => baseAcpConfig,
73
75
  baseSepoliaAcpConfig: () => baseSepoliaAcpConfig,
74
76
  default: () => index_default
75
77
  });
@@ -762,8 +764,27 @@ var import_socket = require("socket.io-client");
762
764
 
763
765
  // src/acpContractClient.ts
764
766
  var import_core = require("@aa-sdk/core");
765
- var import_infra = require("@account-kit/infra");
767
+ var import_infra2 = require("@account-kit/infra");
766
768
  var import_smart_contracts = require("@account-kit/smart-contracts");
769
+
770
+ // src/configs.ts
771
+ var import_infra = require("@account-kit/infra");
772
+ var baseSepoliaAcpConfig = {
773
+ chain: import_infra.baseSepolia,
774
+ contractAddress: "0x2422c1c43451Eb69Ff49dfD39c4Dc8C5230fA1e6",
775
+ virtualsTokenAddress: "0xbfAB80ccc15DF6fb7185f9498d6039317331846a",
776
+ alchemyRpcUrl: "https://alchemy-proxy.virtuals.io/api/proxy/rpc",
777
+ acpUrl: "https://acpx-staging.virtuals.io"
778
+ };
779
+ var baseAcpConfig = {
780
+ chain: import_infra.base,
781
+ contractAddress: "0x2422c1c43451Eb69Ff49dfD39c4Dc8C5230fA1e6",
782
+ virtualsTokenAddress: "0xbfAB80ccc15DF6fb7185f9498d6039317331846a",
783
+ alchemyRpcUrl: "https://alchemy-proxy-prod.virtuals.io/api/proxy/rpc",
784
+ acpUrl: "https://acpx.virtuals.io"
785
+ };
786
+
787
+ // src/acpContractClient.ts
767
788
  var import_viem = require("viem");
768
789
  var MemoType = /* @__PURE__ */ ((MemoType2) => {
769
790
  MemoType2[MemoType2["MESSAGE"] = 0] = "MESSAGE";
@@ -784,7 +805,7 @@ var AcpJobPhases = /* @__PURE__ */ ((AcpJobPhases2) => {
784
805
  return AcpJobPhases2;
785
806
  })(AcpJobPhases || {});
786
807
  var AcpContractClient = class _AcpContractClient {
787
- constructor(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config) {
808
+ constructor(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
788
809
  this.walletPrivateKey = walletPrivateKey;
789
810
  this.sessionEntityKeyId = sessionEntityKeyId;
790
811
  this.agentWalletAddress = agentWalletAddress;
@@ -793,8 +814,8 @@ var AcpContractClient = class _AcpContractClient {
793
814
  this.contractAddress = config.contractAddress;
794
815
  this.virtualsTokenAddress = config.virtualsTokenAddress;
795
816
  }
796
- static build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config) {
797
- return __async(this, null, function* () {
817
+ static build(_0, _1, _2) {
818
+ return __async(this, arguments, function* (walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
798
819
  const acpContractClient = new _AcpContractClient(
799
820
  walletPrivateKey,
800
821
  sessionEntityKeyId,
@@ -810,7 +831,7 @@ var AcpContractClient = class _AcpContractClient {
810
831
  const sessionKeySigner = import_core.LocalAccountSigner.privateKeyToAccountSigner(this.walletPrivateKey);
811
832
  this._sessionKeyClient = yield (0, import_smart_contracts.createModularAccountV2Client)({
812
833
  chain: this.chain,
813
- transport: (0, import_infra.alchemy)({
834
+ transport: (0, import_infra2.alchemy)({
814
835
  rpcUrl: this.config.alchemyRpcUrl
815
836
  }),
816
837
  signer: sessionKeySigner,
@@ -982,7 +1003,7 @@ var acpContractClient_default = AcpContractClient;
982
1003
 
983
1004
  // src/acpJob.ts
984
1005
  var AcpJob = class {
985
- constructor(acpClient, id, clientAddress, providerAddress, evaluatorAddress, price, memos, phase) {
1006
+ constructor(acpClient, id, clientAddress, providerAddress, evaluatorAddress, price, memos, phase, context) {
986
1007
  this.acpClient = acpClient;
987
1008
  this.id = id;
988
1009
  this.clientAddress = clientAddress;
@@ -991,6 +1012,7 @@ var AcpJob = class {
991
1012
  this.price = price;
992
1013
  this.memos = memos;
993
1014
  this.phase = phase;
1015
+ this.context = context;
994
1016
  }
995
1017
  get serviceRequirement() {
996
1018
  var _a;
@@ -1170,7 +1192,8 @@ var AcpClient = class {
1170
1192
  memo.nextPhase
1171
1193
  );
1172
1194
  }),
1173
- data.phase
1195
+ data.phase,
1196
+ data.context
1174
1197
  );
1175
1198
  this.onEvaluate(job);
1176
1199
  }
@@ -1197,7 +1220,8 @@ var AcpClient = class {
1197
1220
  memo.nextPhase
1198
1221
  );
1199
1222
  }),
1200
- data.phase
1223
+ data.phase,
1224
+ data.context
1201
1225
  );
1202
1226
  this.onNewTask(job);
1203
1227
  }
@@ -1213,9 +1237,21 @@ var AcpClient = class {
1213
1237
  process.on("SIGTERM", cleanup);
1214
1238
  });
1215
1239
  }
1216
- browseAgents(keyword, cluster) {
1240
+ browseAgents(keyword, cluster, sort_by, rerank = false, top_k = 5) {
1217
1241
  return __async(this, null, function* () {
1218
- let url = `${this.acpUrl}/api/agents?search=${keyword}&filters[walletAddress][$notIn]=${this.acpContractClient.walletAddress}`;
1242
+ let url = `${this.acpUrl}/api/agents?search=${keyword}`;
1243
+ if (sort_by && sort_by.length > 0) {
1244
+ url += `&sort=${sort_by.map((s) => s).join(",")}`;
1245
+ }
1246
+ if (top_k) {
1247
+ url += `&top_k=${top_k}`;
1248
+ }
1249
+ if (rerank) {
1250
+ url += `&rerank=true`;
1251
+ }
1252
+ if (this.acpContractClient.walletAddress) {
1253
+ url += `&filters[walletAddress][$notIn]=${this.acpContractClient.walletAddress}`;
1254
+ }
1219
1255
  if (cluster) {
1220
1256
  url += `&filters[cluster]=${cluster}`;
1221
1257
  }
@@ -1236,7 +1272,8 @@ var AcpClient = class {
1236
1272
  );
1237
1273
  }),
1238
1274
  twitterHandle: agent.twitterHandle,
1239
- walletAddress: agent.walletAddress
1275
+ walletAddress: agent.walletAddress,
1276
+ metrics: agent.metrics
1240
1277
  };
1241
1278
  });
1242
1279
  });
@@ -1330,7 +1367,8 @@ var AcpClient = class {
1330
1367
  memo.nextPhase
1331
1368
  );
1332
1369
  }),
1333
- job.phase
1370
+ job.phase,
1371
+ job.context
1334
1372
  );
1335
1373
  });
1336
1374
  } catch (error) {
@@ -1368,7 +1406,8 @@ var AcpClient = class {
1368
1406
  memo.nextPhase
1369
1407
  );
1370
1408
  }),
1371
- job.phase
1409
+ job.phase,
1410
+ job.context
1372
1411
  );
1373
1412
  });
1374
1413
  } catch (error) {
@@ -1406,7 +1445,8 @@ var AcpClient = class {
1406
1445
  memo.nextPhase
1407
1446
  );
1408
1447
  }),
1409
- job.phase
1448
+ job.phase,
1449
+ job.context
1410
1450
  );
1411
1451
  });
1412
1452
  } catch (error) {
@@ -1447,7 +1487,8 @@ var AcpClient = class {
1447
1487
  memo.nextPhase
1448
1488
  );
1449
1489
  }),
1450
- job.phase
1490
+ job.phase,
1491
+ job.context
1451
1492
  );
1452
1493
  } catch (error) {
1453
1494
  throw error;
@@ -1498,25 +1539,27 @@ var AcpClient = class {
1498
1539
  };
1499
1540
  var acpClient_default = AcpClient;
1500
1541
 
1501
- // src/configs.ts
1502
- var import_infra2 = require("@account-kit/infra");
1503
- var baseSepoliaAcpConfig = {
1504
- chain: import_infra2.baseSepolia,
1505
- contractAddress: "0x2422c1c43451Eb69Ff49dfD39c4Dc8C5230fA1e6",
1506
- virtualsTokenAddress: "0xbfAB80ccc15DF6fb7185f9498d6039317331846a",
1507
- alchemyRpcUrl: "https://alchemy-proxy.virtuals.io/api/proxy/rpc",
1508
- acpUrl: "https://acpx-staging.virtuals.io"
1509
- };
1542
+ // src/interfaces.ts
1543
+ var AcpAgentSort = /* @__PURE__ */ ((AcpAgentSort2) => {
1544
+ AcpAgentSort2["SUCCESSFUL_JOB_COUNT"] = "successfulJobCount";
1545
+ AcpAgentSort2["SUCCESS_RATE"] = "successRate";
1546
+ AcpAgentSort2["UNIQUE_BUYER_COUNT"] = "uniqueBuyerCount";
1547
+ AcpAgentSort2["MINS_FROM_LAST_ONLINE"] = "minsFromLastOnlineTime";
1548
+ AcpAgentSort2["IS_ONLINE"] = "isOnline";
1549
+ return AcpAgentSort2;
1550
+ })(AcpAgentSort || {});
1510
1551
 
1511
1552
  // src/index.ts
1512
1553
  var index_default = acpClient_default;
1513
1554
  // Annotate the CommonJS export names for ESM import in node:
1514
1555
  0 && (module.exports = {
1515
1556
  ACP_ABI,
1557
+ AcpAgentSort,
1516
1558
  AcpContractClient,
1517
1559
  AcpJob,
1518
1560
  AcpJobPhases,
1519
1561
  AcpMemo,
1520
1562
  MemoType,
1563
+ baseAcpConfig,
1521
1564
  baseSepoliaAcpConfig
1522
1565
  });
package/dist/index.mjs CHANGED
@@ -726,6 +726,25 @@ import { alchemy } from "@account-kit/infra";
726
726
  import {
727
727
  createModularAccountV2Client
728
728
  } from "@account-kit/smart-contracts";
729
+
730
+ // src/configs.ts
731
+ import { baseSepolia, base } from "@account-kit/infra";
732
+ var baseSepoliaAcpConfig = {
733
+ chain: baseSepolia,
734
+ contractAddress: "0x2422c1c43451Eb69Ff49dfD39c4Dc8C5230fA1e6",
735
+ virtualsTokenAddress: "0xbfAB80ccc15DF6fb7185f9498d6039317331846a",
736
+ alchemyRpcUrl: "https://alchemy-proxy.virtuals.io/api/proxy/rpc",
737
+ acpUrl: "https://acpx-staging.virtuals.io"
738
+ };
739
+ var baseAcpConfig = {
740
+ chain: base,
741
+ contractAddress: "0x2422c1c43451Eb69Ff49dfD39c4Dc8C5230fA1e6",
742
+ virtualsTokenAddress: "0xbfAB80ccc15DF6fb7185f9498d6039317331846a",
743
+ alchemyRpcUrl: "https://alchemy-proxy-prod.virtuals.io/api/proxy/rpc",
744
+ acpUrl: "https://acpx.virtuals.io"
745
+ };
746
+
747
+ // src/acpContractClient.ts
729
748
  import { encodeFunctionData, erc20Abi, fromHex } from "viem";
730
749
  var MemoType = /* @__PURE__ */ ((MemoType2) => {
731
750
  MemoType2[MemoType2["MESSAGE"] = 0] = "MESSAGE";
@@ -746,7 +765,7 @@ var AcpJobPhases = /* @__PURE__ */ ((AcpJobPhases2) => {
746
765
  return AcpJobPhases2;
747
766
  })(AcpJobPhases || {});
748
767
  var AcpContractClient = class _AcpContractClient {
749
- constructor(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config) {
768
+ constructor(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
750
769
  this.walletPrivateKey = walletPrivateKey;
751
770
  this.sessionEntityKeyId = sessionEntityKeyId;
752
771
  this.agentWalletAddress = agentWalletAddress;
@@ -755,8 +774,8 @@ var AcpContractClient = class _AcpContractClient {
755
774
  this.contractAddress = config.contractAddress;
756
775
  this.virtualsTokenAddress = config.virtualsTokenAddress;
757
776
  }
758
- static build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config) {
759
- return __async(this, null, function* () {
777
+ static build(_0, _1, _2) {
778
+ return __async(this, arguments, function* (walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
760
779
  const acpContractClient = new _AcpContractClient(
761
780
  walletPrivateKey,
762
781
  sessionEntityKeyId,
@@ -944,7 +963,7 @@ var acpContractClient_default = AcpContractClient;
944
963
 
945
964
  // src/acpJob.ts
946
965
  var AcpJob = class {
947
- constructor(acpClient, id, clientAddress, providerAddress, evaluatorAddress, price, memos, phase) {
966
+ constructor(acpClient, id, clientAddress, providerAddress, evaluatorAddress, price, memos, phase, context) {
948
967
  this.acpClient = acpClient;
949
968
  this.id = id;
950
969
  this.clientAddress = clientAddress;
@@ -953,6 +972,7 @@ var AcpJob = class {
953
972
  this.price = price;
954
973
  this.memos = memos;
955
974
  this.phase = phase;
975
+ this.context = context;
956
976
  }
957
977
  get serviceRequirement() {
958
978
  var _a;
@@ -1132,7 +1152,8 @@ var AcpClient = class {
1132
1152
  memo.nextPhase
1133
1153
  );
1134
1154
  }),
1135
- data.phase
1155
+ data.phase,
1156
+ data.context
1136
1157
  );
1137
1158
  this.onEvaluate(job);
1138
1159
  }
@@ -1159,7 +1180,8 @@ var AcpClient = class {
1159
1180
  memo.nextPhase
1160
1181
  );
1161
1182
  }),
1162
- data.phase
1183
+ data.phase,
1184
+ data.context
1163
1185
  );
1164
1186
  this.onNewTask(job);
1165
1187
  }
@@ -1175,9 +1197,21 @@ var AcpClient = class {
1175
1197
  process.on("SIGTERM", cleanup);
1176
1198
  });
1177
1199
  }
1178
- browseAgents(keyword, cluster) {
1200
+ browseAgents(keyword, cluster, sort_by, rerank = false, top_k = 5) {
1179
1201
  return __async(this, null, function* () {
1180
- let url = `${this.acpUrl}/api/agents?search=${keyword}&filters[walletAddress][$notIn]=${this.acpContractClient.walletAddress}`;
1202
+ let url = `${this.acpUrl}/api/agents?search=${keyword}`;
1203
+ if (sort_by && sort_by.length > 0) {
1204
+ url += `&sort=${sort_by.map((s) => s).join(",")}`;
1205
+ }
1206
+ if (top_k) {
1207
+ url += `&top_k=${top_k}`;
1208
+ }
1209
+ if (rerank) {
1210
+ url += `&rerank=true`;
1211
+ }
1212
+ if (this.acpContractClient.walletAddress) {
1213
+ url += `&filters[walletAddress][$notIn]=${this.acpContractClient.walletAddress}`;
1214
+ }
1181
1215
  if (cluster) {
1182
1216
  url += `&filters[cluster]=${cluster}`;
1183
1217
  }
@@ -1198,7 +1232,8 @@ var AcpClient = class {
1198
1232
  );
1199
1233
  }),
1200
1234
  twitterHandle: agent.twitterHandle,
1201
- walletAddress: agent.walletAddress
1235
+ walletAddress: agent.walletAddress,
1236
+ metrics: agent.metrics
1202
1237
  };
1203
1238
  });
1204
1239
  });
@@ -1292,7 +1327,8 @@ var AcpClient = class {
1292
1327
  memo.nextPhase
1293
1328
  );
1294
1329
  }),
1295
- job.phase
1330
+ job.phase,
1331
+ job.context
1296
1332
  );
1297
1333
  });
1298
1334
  } catch (error) {
@@ -1330,7 +1366,8 @@ var AcpClient = class {
1330
1366
  memo.nextPhase
1331
1367
  );
1332
1368
  }),
1333
- job.phase
1369
+ job.phase,
1370
+ job.context
1334
1371
  );
1335
1372
  });
1336
1373
  } catch (error) {
@@ -1368,7 +1405,8 @@ var AcpClient = class {
1368
1405
  memo.nextPhase
1369
1406
  );
1370
1407
  }),
1371
- job.phase
1408
+ job.phase,
1409
+ job.context
1372
1410
  );
1373
1411
  });
1374
1412
  } catch (error) {
@@ -1409,7 +1447,8 @@ var AcpClient = class {
1409
1447
  memo.nextPhase
1410
1448
  );
1411
1449
  }),
1412
- job.phase
1450
+ job.phase,
1451
+ job.context
1413
1452
  );
1414
1453
  } catch (error) {
1415
1454
  throw error;
@@ -1460,25 +1499,27 @@ var AcpClient = class {
1460
1499
  };
1461
1500
  var acpClient_default = AcpClient;
1462
1501
 
1463
- // src/configs.ts
1464
- import { baseSepolia, base } from "@account-kit/infra";
1465
- var baseSepoliaAcpConfig = {
1466
- chain: baseSepolia,
1467
- contractAddress: "0x2422c1c43451Eb69Ff49dfD39c4Dc8C5230fA1e6",
1468
- virtualsTokenAddress: "0xbfAB80ccc15DF6fb7185f9498d6039317331846a",
1469
- alchemyRpcUrl: "https://alchemy-proxy.virtuals.io/api/proxy/rpc",
1470
- acpUrl: "https://acpx-staging.virtuals.io"
1471
- };
1502
+ // src/interfaces.ts
1503
+ var AcpAgentSort = /* @__PURE__ */ ((AcpAgentSort2) => {
1504
+ AcpAgentSort2["SUCCESSFUL_JOB_COUNT"] = "successfulJobCount";
1505
+ AcpAgentSort2["SUCCESS_RATE"] = "successRate";
1506
+ AcpAgentSort2["UNIQUE_BUYER_COUNT"] = "uniqueBuyerCount";
1507
+ AcpAgentSort2["MINS_FROM_LAST_ONLINE"] = "minsFromLastOnlineTime";
1508
+ AcpAgentSort2["IS_ONLINE"] = "isOnline";
1509
+ return AcpAgentSort2;
1510
+ })(AcpAgentSort || {});
1472
1511
 
1473
1512
  // src/index.ts
1474
1513
  var index_default = acpClient_default;
1475
1514
  export {
1476
1515
  acpAbi_default as ACP_ABI,
1516
+ AcpAgentSort,
1477
1517
  acpContractClient_default as AcpContractClient,
1478
1518
  acpJob_default as AcpJob,
1479
1519
  AcpJobPhases,
1480
1520
  acpMemo_default as AcpMemo,
1481
1521
  MemoType,
1522
+ baseAcpConfig,
1482
1523
  baseSepoliaAcpConfig,
1483
1524
  index_default as default
1484
1525
  };
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.5",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",