@virtuals-protocol/acp-node 0.1.0-beta.2 → 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 +30 -5
- package/dist/index.d.mts +52 -32
- package/dist/index.d.ts +52 -32
- package/dist/index.js +31 -6
- package/dist/index.mjs +30 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ For testing on Base Sepolia:
|
|
|
58
58
|
## Installation
|
|
59
59
|
|
|
60
60
|
```bash
|
|
61
|
-
npm install acp-node
|
|
61
|
+
npm install @virtuals-protocol/acp-node
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
## Usage
|
|
@@ -66,7 +66,7 @@ npm install acp-node
|
|
|
66
66
|
1. Import the ACP Client:
|
|
67
67
|
|
|
68
68
|
```typescript
|
|
69
|
-
import AcpClient from 'acp-node';
|
|
69
|
+
import AcpClient from '@virtuals-protocol/acp-node';
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
2. Create and initialize an ACP instance:
|
|
@@ -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;
|
|
@@ -8410,13 +8429,7 @@ declare class AcpJobOffering {
|
|
|
8410
8429
|
requirementSchema?: Object | undefined;
|
|
8411
8430
|
private ajv;
|
|
8412
8431
|
constructor(acpClient: AcpClient, providerAddress: Address$1, type: string, price: number, requirementSchema?: Object | undefined);
|
|
8413
|
-
initiateJob(serviceRequirement: Object | string,
|
|
8414
|
-
}
|
|
8415
|
-
|
|
8416
|
-
interface IAcpClientOptions {
|
|
8417
|
-
acpContractClient: AcpContractClient;
|
|
8418
|
-
onNewTask?: (job: AcpJob) => void;
|
|
8419
|
-
onEvaluate?: (job: AcpJob) => void;
|
|
8432
|
+
initiateJob(serviceRequirement: Object | string, evaluatorAddress?: Address$1, expiredAt?: Date): Promise<number>;
|
|
8420
8433
|
}
|
|
8421
8434
|
|
|
8422
8435
|
declare class AcpClient {
|
|
@@ -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;
|
|
@@ -8410,13 +8429,7 @@ declare class AcpJobOffering {
|
|
|
8410
8429
|
requirementSchema?: Object | undefined;
|
|
8411
8430
|
private ajv;
|
|
8412
8431
|
constructor(acpClient: AcpClient, providerAddress: Address$1, type: string, price: number, requirementSchema?: Object | undefined);
|
|
8413
|
-
initiateJob(serviceRequirement: Object | string,
|
|
8414
|
-
}
|
|
8415
|
-
|
|
8416
|
-
interface IAcpClientOptions {
|
|
8417
|
-
acpContractClient: AcpContractClient;
|
|
8418
|
-
onNewTask?: (job: AcpJob) => void;
|
|
8419
|
-
onEvaluate?: (job: AcpJob) => void;
|
|
8432
|
+
initiateJob(serviceRequirement: Object | string, evaluatorAddress?: Address$1, expiredAt?: Date): Promise<number>;
|
|
8420
8433
|
}
|
|
8421
8434
|
|
|
8422
8435
|
declare class AcpClient {
|
|
@@ -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,
|
|
@@ -1101,8 +1102,8 @@ var AcpJobOffering = class {
|
|
|
1101
1102
|
this.requirementSchema = requirementSchema;
|
|
1102
1103
|
this.ajv = new import_ajv.default({ allErrors: true });
|
|
1103
1104
|
}
|
|
1104
|
-
initiateJob(_0, _1
|
|
1105
|
-
return __async(this, arguments, function* (serviceRequirement,
|
|
1105
|
+
initiateJob(_0, _1) {
|
|
1106
|
+
return __async(this, arguments, function* (serviceRequirement, evaluatorAddress, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
1106
1107
|
if (this.requirementSchema) {
|
|
1107
1108
|
const validator = this.ajv.compile(this.requirementSchema);
|
|
1108
1109
|
const valid = validator(serviceRequirement);
|
|
@@ -1113,7 +1114,7 @@ var AcpJobOffering = class {
|
|
|
1113
1114
|
return yield this.acpClient.initiateJob(
|
|
1114
1115
|
this.providerAddress,
|
|
1115
1116
|
serviceRequirement,
|
|
1116
|
-
|
|
1117
|
+
this.price,
|
|
1117
1118
|
evaluatorAddress,
|
|
1118
1119
|
expiredAt
|
|
1119
1120
|
);
|
|
@@ -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}
|
|
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
|
@@ -1063,8 +1063,8 @@ var AcpJobOffering = class {
|
|
|
1063
1063
|
this.requirementSchema = requirementSchema;
|
|
1064
1064
|
this.ajv = new Ajv({ allErrors: true });
|
|
1065
1065
|
}
|
|
1066
|
-
initiateJob(_0, _1
|
|
1067
|
-
return __async(this, arguments, function* (serviceRequirement,
|
|
1066
|
+
initiateJob(_0, _1) {
|
|
1067
|
+
return __async(this, arguments, function* (serviceRequirement, evaluatorAddress, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
1068
1068
|
if (this.requirementSchema) {
|
|
1069
1069
|
const validator = this.ajv.compile(this.requirementSchema);
|
|
1070
1070
|
const valid = validator(serviceRequirement);
|
|
@@ -1075,7 +1075,7 @@ var AcpJobOffering = class {
|
|
|
1075
1075
|
return yield this.acpClient.initiateJob(
|
|
1076
1076
|
this.providerAddress,
|
|
1077
1077
|
serviceRequirement,
|
|
1078
|
-
|
|
1078
|
+
this.price,
|
|
1079
1079
|
evaluatorAddress,
|
|
1080
1080
|
expiredAt
|
|
1081
1081
|
);
|
|
@@ -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}
|
|
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,
|