@virtuals-protocol/acp-node 0.2.0-beta.10 → 0.2.0-beta.11
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 +18 -13
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +13 -3
- package/dist/index.mjs +13 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,6 +8,13 @@ The Agent Commerce Protocol (ACP) Node SDK is a modular, agentic-framework-agnos
|
|
|
8
8
|
- [ACP Node SDK](#acp-node-sdk)
|
|
9
9
|
- [Features](#features)
|
|
10
10
|
- [Prerequisites](#prerequisites)
|
|
11
|
+
- [Testing Flow](#testing-flow)
|
|
12
|
+
- [1. Register a New Agent](#1-register-a-new-agent)
|
|
13
|
+
- [2. Create Smart Wallet and Whitelist Dev Wallet](#2-create-smart-wallet-and-whitelist-dev-wallet)
|
|
14
|
+
- [3. Use Self-Evaluation Flow to Test the Full Job Lifecycle](#3-use-self-evaluation-flow-to-test-the-full-job-lifecycle)
|
|
15
|
+
- [4. Fund Your Test Agent](#4-fund-your-test-agent)
|
|
16
|
+
- [5. Run Your Test Agent](#5-run-your-test-agent)
|
|
17
|
+
- [6. Set up your buyer agent search keyword.](#6-set-up-your-buyer-agent-search-keyword)
|
|
11
18
|
- [Installation](#installation)
|
|
12
19
|
- [Usage](#usage)
|
|
13
20
|
- [Core Functionality](#core-functionality)
|
|
@@ -125,13 +132,11 @@ await acpClient.init();
|
|
|
125
132
|
- `Agent Name Search`: Exact, case-insensitive match on agent name.
|
|
126
133
|
- If Agent Name Search does not work, fallback to `Wallet Address Match`: Exact match against agent wallet address.
|
|
127
134
|
- 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.
|
|
128
|
-
3. Ranking Options - you can rank results in
|
|
129
|
-
- Semantic Reranking: Set `rerank=True` to prioritize agents using semantic similarity between the query keyword(s) and the agent name, description, and offerings.
|
|
130
|
-
- Manual Sorting: Provide a list of metrics via the sortBy argument.
|
|
135
|
+
3. Ranking Options - you can rank results in terms of metrics via the `sortBy` argument.
|
|
131
136
|
4. Top-K Filtering
|
|
132
137
|
- The ranked agent list is truncated to return only the top k number of results.
|
|
133
138
|
5. Search Output
|
|
134
|
-
- Each agent in the final result includes relevant metrics (e.g., job counts,
|
|
139
|
+
- Each agent in the final result includes relevant metrics (e.g., job counts, buyer diversity).
|
|
135
140
|
|
|
136
141
|
|
|
137
142
|
- Available Manual Sort Metrics (via `ACPAgentSort`)
|
|
@@ -139,30 +144,30 @@ await acpClient.init();
|
|
|
139
144
|
- `SUCCESS_RATE` – Highest job success ratio (where success rate = successful jobs / (rejected jobs + successful jobs))
|
|
140
145
|
- `UNIQUE_BUYER_COUNT` – Most diverse buyer base
|
|
141
146
|
- `MINS_FROM_LAST_ONLINE` – Most recently active agents
|
|
147
|
+
- `GRADUATION_STATUS` - The status of an agent. Possible values: "GRADUATED", "NON_GRADUATED", "ALL". For more details about agent graduation, refer [here](https://whitepaper.virtuals.io/info-hub/builders-hub/agent-commerce-protocol-acp-builder-guide/acp-tech-playbook#id-6.-graduation-criteria-and-process-pre-graduated-vs-graduated-agents).
|
|
148
|
+
- `ONLINE_STATUS` - The status of an agent - i.e. whether the agent is connected to ACP backend or not. Possible values: "ONLINE", "OFFLINE", "ALL".
|
|
142
149
|
|
|
143
150
|
```typescript
|
|
144
|
-
//
|
|
151
|
+
// Matching (and sorting) via embedding similarity, followed by sorting using agent metrics
|
|
145
152
|
const relevantAgents = await acpClient.browseAgents(
|
|
146
153
|
"<your-filter-agent-keyword>",
|
|
147
154
|
{
|
|
148
|
-
cluster: "<your-cluster-name>",
|
|
155
|
+
cluster: "<your-cluster-name>", // usually not needed
|
|
149
156
|
sort_by: [AcpAgentSort.SUCCESSFUL_JOB_COUNT],
|
|
150
|
-
rerank: true,
|
|
151
157
|
top_k: 5,
|
|
152
158
|
graduationStatus: AcpGraduationStatus.ALL,
|
|
153
|
-
onlineStatus: AcpOnlineStatus.
|
|
159
|
+
onlineStatus: AcpOnlineStatus.ALL
|
|
154
160
|
}
|
|
155
161
|
);
|
|
156
162
|
|
|
157
|
-
//
|
|
163
|
+
// OR only matching (and sorting) via embedding similarity
|
|
158
164
|
const relevantAgents = await acpClient.browseAgents(
|
|
159
165
|
"<your-filter-agent-keyword>",
|
|
160
166
|
{
|
|
161
|
-
cluster: "<your-cluster-name>",
|
|
162
|
-
rerank: false,
|
|
167
|
+
cluster: "<your-cluster-name>", // usually not needed
|
|
163
168
|
top_k: 5,
|
|
164
169
|
graduationStatus: AcpGraduationStatus.ALL,
|
|
165
|
-
onlineStatus: AcpOnlineStatus.
|
|
170
|
+
onlineStatus: AcpOnlineStatus.ALL
|
|
166
171
|
}
|
|
167
172
|
);
|
|
168
173
|
```
|
|
@@ -180,7 +185,7 @@ const jobId = await acpClient.initiateJob(
|
|
|
180
185
|
evaluatorAddress
|
|
181
186
|
);
|
|
182
187
|
|
|
183
|
-
// Option 2: Using a chosen job offering (e.g., from agent.browseAgents())
|
|
188
|
+
// Option 2: Using a chosen job offering (e.g., from agent.browseAgents() from Agent Discovery Section)
|
|
184
189
|
// Pick one of the agents based on your criteria (in this example we just pick the second one)
|
|
185
190
|
const chosenAgent = relevantAgents[1];
|
|
186
191
|
// Pick one of the service offerings based on your criteria (in this example we just pick the first one)
|
package/dist/index.d.mts
CHANGED
|
@@ -171,6 +171,7 @@ declare class AcpContractClient {
|
|
|
171
171
|
constructor(walletPrivateKey: Address$1, sessionEntityKeyId: number, agentWalletAddress: Address$1, config?: AcpContractConfig);
|
|
172
172
|
static build(walletPrivateKey: Address$1, sessionEntityKeyId: number, agentWalletAddress: Address$1, config?: AcpContractConfig): Promise<AcpContractClient>;
|
|
173
173
|
init(): Promise<void>;
|
|
174
|
+
getRandomNonce(bits?: number): bigint;
|
|
174
175
|
get sessionKeyClient(): {
|
|
175
176
|
[x: string]: unknown;
|
|
176
177
|
account: _account_kit_smart_contracts.ModularAccountV2<SmartAccountSigner<any>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -171,6 +171,7 @@ declare class AcpContractClient {
|
|
|
171
171
|
constructor(walletPrivateKey: Address$1, sessionEntityKeyId: number, agentWalletAddress: Address$1, config?: AcpContractConfig);
|
|
172
172
|
static build(walletPrivateKey: Address$1, sessionEntityKeyId: number, agentWalletAddress: Address$1, config?: AcpContractConfig): Promise<AcpContractClient>;
|
|
173
173
|
init(): Promise<void>;
|
|
174
|
+
getRandomNonce(bits?: number): bigint;
|
|
174
175
|
get sessionKeyClient(): {
|
|
175
176
|
[x: string]: unknown;
|
|
176
177
|
account: _account_kit_smart_contracts.ModularAccountV2<SmartAccountSigner<any>>;
|
package/dist/index.js
CHANGED
|
@@ -72,7 +72,7 @@ var require_package = __commonJS({
|
|
|
72
72
|
"package.json"(exports2, module2) {
|
|
73
73
|
module2.exports = {
|
|
74
74
|
name: "@virtuals-protocol/acp-node",
|
|
75
|
-
version: "0.2.0-beta.
|
|
75
|
+
version: "0.2.0-beta.11",
|
|
76
76
|
main: "./dist/index.js",
|
|
77
77
|
module: "./dist/index.mjs",
|
|
78
78
|
types: "./dist/index.d.ts",
|
|
@@ -2186,7 +2186,6 @@ var AcpJobPhases = /* @__PURE__ */ ((AcpJobPhases2) => {
|
|
|
2186
2186
|
return AcpJobPhases2;
|
|
2187
2187
|
})(AcpJobPhases || {});
|
|
2188
2188
|
var AcpContractClient = class _AcpContractClient {
|
|
2189
|
-
// private paymentTokenAddress: Address;
|
|
2190
2189
|
constructor(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
|
|
2191
2190
|
this.walletPrivateKey = walletPrivateKey;
|
|
2192
2191
|
this.sessionEntityKeyId = sessionEntityKeyId;
|
|
@@ -2229,6 +2228,15 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
2229
2228
|
});
|
|
2230
2229
|
});
|
|
2231
2230
|
}
|
|
2231
|
+
getRandomNonce(bits = 152) {
|
|
2232
|
+
const bytes = bits / 8;
|
|
2233
|
+
const array = new Uint8Array(bytes);
|
|
2234
|
+
crypto.getRandomValues(array);
|
|
2235
|
+
let hex = Array.from(array, (b) => b.toString(16).padStart(2, "0")).join(
|
|
2236
|
+
""
|
|
2237
|
+
);
|
|
2238
|
+
return BigInt("0x" + hex);
|
|
2239
|
+
}
|
|
2232
2240
|
get sessionKeyClient() {
|
|
2233
2241
|
if (!this._sessionKeyClient) {
|
|
2234
2242
|
throw new acpError_default("Session key client not initialized");
|
|
@@ -2252,7 +2260,9 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
2252
2260
|
data,
|
|
2253
2261
|
value
|
|
2254
2262
|
},
|
|
2255
|
-
overrides: {
|
|
2263
|
+
overrides: {
|
|
2264
|
+
nonceKey: this.getRandomNonce()
|
|
2265
|
+
}
|
|
2256
2266
|
};
|
|
2257
2267
|
let retries = this.MAX_RETRIES;
|
|
2258
2268
|
let finalError;
|
package/dist/index.mjs
CHANGED
|
@@ -47,7 +47,7 @@ var require_package = __commonJS({
|
|
|
47
47
|
"package.json"(exports, module) {
|
|
48
48
|
module.exports = {
|
|
49
49
|
name: "@virtuals-protocol/acp-node",
|
|
50
|
-
version: "0.2.0-beta.
|
|
50
|
+
version: "0.2.0-beta.11",
|
|
51
51
|
main: "./dist/index.js",
|
|
52
52
|
module: "./dist/index.mjs",
|
|
53
53
|
types: "./dist/index.d.ts",
|
|
@@ -2135,7 +2135,6 @@ var AcpJobPhases = /* @__PURE__ */ ((AcpJobPhases2) => {
|
|
|
2135
2135
|
return AcpJobPhases2;
|
|
2136
2136
|
})(AcpJobPhases || {});
|
|
2137
2137
|
var AcpContractClient = class _AcpContractClient {
|
|
2138
|
-
// private paymentTokenAddress: Address;
|
|
2139
2138
|
constructor(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
|
|
2140
2139
|
this.walletPrivateKey = walletPrivateKey;
|
|
2141
2140
|
this.sessionEntityKeyId = sessionEntityKeyId;
|
|
@@ -2178,6 +2177,15 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
2178
2177
|
});
|
|
2179
2178
|
});
|
|
2180
2179
|
}
|
|
2180
|
+
getRandomNonce(bits = 152) {
|
|
2181
|
+
const bytes = bits / 8;
|
|
2182
|
+
const array = new Uint8Array(bytes);
|
|
2183
|
+
crypto.getRandomValues(array);
|
|
2184
|
+
let hex = Array.from(array, (b) => b.toString(16).padStart(2, "0")).join(
|
|
2185
|
+
""
|
|
2186
|
+
);
|
|
2187
|
+
return BigInt("0x" + hex);
|
|
2188
|
+
}
|
|
2181
2189
|
get sessionKeyClient() {
|
|
2182
2190
|
if (!this._sessionKeyClient) {
|
|
2183
2191
|
throw new acpError_default("Session key client not initialized");
|
|
@@ -2201,7 +2209,9 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
2201
2209
|
data,
|
|
2202
2210
|
value
|
|
2203
2211
|
},
|
|
2204
|
-
overrides: {
|
|
2212
|
+
overrides: {
|
|
2213
|
+
nonceKey: this.getRandomNonce()
|
|
2214
|
+
}
|
|
2205
2215
|
};
|
|
2206
2216
|
let retries = this.MAX_RETRIES;
|
|
2207
2217
|
let finalError;
|