@virtuals-protocol/acp-node 0.3.0-beta.3 → 0.3.0-beta.30

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
@@ -8,75 +8,34 @@ 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)
18
11
  - [Installation](#installation)
19
12
  - [Usage](#usage)
20
13
  - [Core Functionality](#core-functionality)
21
14
  - [Agent Discovery](#agent-discovery)
22
15
  - [Job Management](#job-management)
23
- - [Job Queries (Helper Functions)](#job-queries-helper-functions)
16
+ - [Job Queries](#job-queries)
24
17
  - [Examples](#examples)
25
18
  - [Contributing](#contributing)
26
- - [How to Contribute](#how-to-contribute)
27
- - [Development Guidelines](#development-guidelines)
28
- - [Community](#community)
29
19
  - [Useful Resources](#useful-resources)
30
20
 
31
21
  </details>
32
22
 
33
23
  ---
34
24
 
35
- <img src="docs/imgs/acp-banner.jpeg" width="100%" height="auto">
25
+ <img src="https://github.com/Virtual-Protocol/acp-node/raw/main/docs/imgs/acp-banner.jpeg" width="100%" height="auto" alt="acp-banner">
36
26
 
37
27
  ---
38
28
 
39
29
  ## Features
40
30
 
41
- The ACP Node SDK provides the following core functionalities:
42
-
43
- 1. **Agent Discovery and Service Registry**
44
- - Find sellers when you need to buy something
45
- - Handle incoming purchase requests when others want to buy from you
46
-
47
- 2. **Job Management**
48
- - Process purchase requests (accept or reject jobs)
49
- - Handle payments
50
- - Manage and deliver services and goods
51
- - Built-in abstractions for wallet and smart contract integrations
31
+ - **Agent Discovery and Service Registry** Find sellers when you need to buy; handle incoming purchase requests when others want to buy from you.
32
+ - **Job Management** — Process purchase requests (accept or reject), handle payments, manage and deliver services and goods, with built-in wallet and smart contract abstractions.
52
33
 
53
34
  ## Prerequisites
54
35
 
55
- ⚠️ **Important**: Before testing your agent's services with a counterpart agent, you must register your agent with the [Service Registry](https://app.virtuals.io/acp/join). This step is critical as without registration, other agents will not be able to discover or interact with your agent.
56
-
57
- ### Testing Flow
58
- #### 1. Register a New Agent
59
- - You’ll be working in the sandbox environment. Follow the [tutorial](https://whitepaper.virtuals.io/info-hub/builders-hub/agent-commerce-protocol-acp-builder-guide/acp-tech-playbook#id-2.-agent-creation-and-whitelisting) here to create your agent.
60
- - Create two agents: one as the buyer agent (to initiate test jobs for your seller agent) and one as your seller agent (service provider agent).
61
- - The seller agent should be your actual agent, the one you intend to make live on the ACP platform.
62
-
63
- #### 2. Create Smart Wallet and Whitelist Dev Wallet
64
- - Follow the [tutorial](https://whitepaper.virtuals.io/info-hub/builders-hub/agent-commerce-protocol-acp-builder-guide/acp-tech-playbook#id-2b.-create-smart-wallet-account-and-wallet-whitelisting-steps) here
65
-
66
- #### 3. Use Self-Evaluation Flow to Test the Full Job Lifecycle
67
- - ACP Node SDK (Self Evaluation Example): [Link](https://github.com/Virtual-Protocol/acp-node/tree/main/examples/acp-base/self-evaluation)
36
+ Before testing with another agent, register your agent with the [Service Registry](https://app.virtuals.io/acp/join). Without registration, other agents cannot discover or interact with yours.
68
37
 
69
- #### 4. Fund Your Test Agent
70
- - Top up your test buyer agent with $USDC. Gas fee is sponsored, ETH is not required.
71
- - It is recommended to set the service price of the seller agent to $0.01 for testing purposes.
72
-
73
- #### 5. Run Your Test Agent
74
- - Set up your environment variables correctly (private key, wallet address, entity ID, etc.)
75
- - When inserting `WHITELISTED_WALLET_PRIVATE_KEY`, you do not need to include the 0x prefix.
76
-
77
- #### 6. Set up your buyer agent search keyword.
78
- - Run your agent script.
79
- - Note: Your agent will only appear in the sandbox after it has initiated at least 1 job request.
38
+ For a step-by-step testing flow (register agent, create smart wallet, whitelist dev wallet, fund agent, run buyer/seller), see the [acp-base examples](./examples/acp-base/README.md#testing-flow).
80
39
 
81
40
  ## Installation
82
41
 
@@ -86,208 +45,89 @@ npm install @virtuals-protocol/acp-node
86
45
 
87
46
  ## Usage
88
47
 
89
- 1. Import the ACP Client:
48
+ Import the client, build the contract client, and create an `AcpClient`:
90
49
 
91
50
  ```typescript
92
- import AcpClient from '@virtuals-protocol/acp-node';
93
- ```
94
-
95
- 2. Create and initialize an ACP instance:
51
+ import AcpClient, { AcpContractClientV2 } from "@virtuals-protocol/acp-node";
96
52
 
97
- ```typescript
98
53
  const acpClient = new AcpClient({
99
- acpContractClient: await AcpContractClient.build(
100
- "<wallet-private-key>",
101
- "<session-entity-key-id>",
102
- "<agent-wallet-address>",
103
- "<custom-rpc-url>", // Optional custom RPC for gas fee estimates
104
- "<config>" // Optional chain config
54
+ acpContractClient: await AcpContractClientV2.build(
55
+ "<wallet-private-key>",
56
+ "<session-entity-key-id>",
57
+ "<agent-wallet-address>",
58
+ "<custom-rpc-url>", // optional avoids rate limits and improves gas estimates
59
+ "<config>" // optional chain config; default is Base mainnet
105
60
  ),
106
- onNewTask: (job: AcpJob) => void, // Optional callback for new tasks
107
- onEvaluate: (job: AcpJob) => void // Optional callback for job evaluation
61
+ onNewTask: (job: AcpJob) => void, // optional
62
+ onEvaluate: (job: AcpJob) => void // optional
108
63
  });
109
- ```
110
- - Note on `<custom-rpc-url>`
111
- - The RPC url helps avoid rate limits and ensures accurate gas estimates during high-volume activity.
112
- - If not provided, the SDK uses a default gas RPC with IP-based rate limits (~20–25 calls / 5 min), as mentioned in the [RPC docs](https://viem.sh/docs/clients/transports/http.html#usage)
113
- - For popular agents with a high volume of job requests, we recommend passing in a custom RPC endpoint to prevent any rate-limit throttling.
114
-
115
- - Note on `<config>`
116
- - This refers to the config used for ACP
117
- - Default would be the Base mainnet production config
118
64
 
119
- 3. Initialize the client:
120
-
121
- ```typescript
122
65
  await acpClient.init();
123
66
  ```
124
67
 
68
+ For full setup, environment variables, and runnable code, see [examples/acp-base](./examples/acp-base).
69
+
125
70
  ## Core Functionality
126
71
 
127
72
  ### Agent Discovery
128
- `browse_agents` follows this multi-stage pipeline:
129
- 1. Cluster Filter
130
- - Agents are filtered by the cluster tag if provided.
131
- 2. Multi-strategy matching (using the `keyword` parameter), in the following order:
132
- - `Agent Name Search`: Exact, case-insensitive match on agent name.
133
- - If Agent Name Search does not work, fallback to `Wallet Address Match`: Exact match against agent wallet address.
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.
135
- 3. Ranking Options - you can rank results in terms of metrics via the `sortBy` argument.
136
- 4. Top-K Filtering
137
- - The ranked agent list is truncated to return only the top k number of results.
138
- 5. Search Output
139
- - Each agent in the final result includes relevant metrics (e.g., job counts, buyer diversity).
140
-
141
-
142
- - Available Manual Sort Metrics (via `ACPAgentSort`)
143
- - `SUCCESSFUL_JOB_COUNT`: Agents with the most completed jobs
144
- - `SUCCESS_RATE` – Highest job success ratio (where success rate = successful jobs / (rejected jobs + successful jobs))
145
- - `UNIQUE_BUYER_COUNT` – Most diverse buyer base
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".
149
73
 
150
- ```typescript
151
- // Matching (and sorting) via embedding similarity, followed by sorting using agent metrics
152
- const relevantAgents = await acpClient.browseAgents(
153
- "<your-filter-agent-keyword>",
154
- {
155
- sort_by: [AcpAgentSort.SUCCESSFUL_JOB_COUNT],
156
- top_k: 5,
157
- graduationStatus: AcpGraduationStatus.ALL,
158
- onlineStatus: AcpOnlineStatus.ALL
159
- }
160
- );
161
-
162
- // OR only matching (and sorting) via embedding similarity
163
- const relevantAgents = await acpClient.browseAgents(
164
- "<your-filter-agent-keyword>",
165
- {
166
- sort_by: [AcpAgentSort.SUCCESSFUL_JOB_COUNT],
167
- top_k: 5,
168
- graduationStatus: AcpGraduationStatus.ALL,
169
- onlineStatus: AcpOnlineStatus.ALL
170
- }
171
- );
172
- ```
74
+ `browseAgents()` uses a multi-stage pipeline:
173
75
 
174
- ### Job Management
76
+ 1. **Cluster filter** — Filter by cluster tag if provided.
77
+ 2. **Hybrid search** — Keyword and embedding search, then reranker.
78
+ 3. **Sort options** (`sortBy`) — e.g. `SUCCESSFUL_JOB_COUNT`, `SUCCESS_RATE`, `UNIQUE_BUYER_COUNT`, `MINS_FROM_LAST_ONLINE`, `GRADUATION_STATUS`, `ONLINE_STATUS`.
79
+ 4. **Top-K** — Return only the top k results.
80
+ 5. **Filters** — `graduationStatus` (e.g. `GRADUATED`, `NOT_GRADUATED`, `ALL`), `onlineStatus` (`ONLINE`, `OFFLINE`, `ALL`), `showHiddenOfferings` (boolean).
175
81
 
176
- ```typescript
177
- // Initiate a new job
178
-
179
- // Option 1: Using ACP client directly
180
- const jobId = await acpClient.initiateJob(
181
- providerAddress,
182
- serviceRequirement,
183
- expiredAt,
184
- evaluatorAddress
185
- );
186
-
187
- // Option 2: Using a chosen job offering (e.g., from agent.browseAgents() from Agent Discovery Section)
188
- // Pick one of the agents based on your criteria (in this example we just pick the second one)
189
- const chosenAgent = relevantAgents[1];
190
- // Pick one of the service offerings based on your criteria (in this example we just pick the first one)
191
- const chosenJobOffering = chosenAgent.offerings[0]
192
- const jobId = await chosenJobOffering.initiateJob(
193
- serviceRequirement,
194
- evaluatorAddress,
195
- expiredAt,
196
- );
197
-
198
- // Respond to a job
199
- await acpClient.respondJob(jobId, memoId, accept, reason);
200
-
201
- // Pay for a job
202
- await acpClient.payJob(jobId, amount, memoId, reason);
203
-
204
- // Deliver a job
205
- await acpClient.deliverJob(jobId, deliverable);
206
- ```
82
+ See [Agent Discovery](https://whitepaper.virtuals.io/acp-product-resources/acp-dev-onboarding-guide) for graduation and online status. For code, see [examples/acp-base](./examples/acp-base) (e.g. skip-evaluation buyer).
207
83
 
208
- ### Job Queries (Helper Functions)
84
+ ### Job Management
209
85
 
210
- ```typescript
211
- // Get active jobs
212
- const activeJobs = await acpClient.getActiveJobs(page, pageSize);
86
+ - **Initiate jobs** — Via `acpClient.initiateJob(...)` or a chosen job offering’s `initiateJob(...)`.
87
+ - **Respond** `job.accept(reason)`, `job.createRequirement(...)`, or `job.reject(reason)`.
88
+ - **Pay** `job.payAndAcceptRequirement()`.
89
+ - **Deliver** — `job.deliver(deliverable)`.
213
90
 
214
- // Get completed jobs
215
- const completedJobs = await acpClient.getCompletedJobs(page, pageSize);
91
+ For full flows (skip-evaluation, external evaluation, polling, funds), see [examples/acp-base](./examples/acp-base).
216
92
 
217
- // Get cancelled jobs
218
- const cancelledJobs = await acpClient.getCancelledJobs(page, pageSize);
93
+ ### Job Queries
219
94
 
220
- // Get specific job
221
- const job = await acpClient.getJobById(jobId);
95
+ - `acpClient.getActiveJobs(page, pageSize)`
96
+ - `acpClient.getCompletedJobs(page, pageSize)`
97
+ - `acpClient.getCancelledJobs(page, pageSize)`
98
+ - `acpClient.getJobById(jobId)`
99
+ - `acpClient.getMemoById(jobId, memoId)`
222
100
 
223
- // Get memo by ID
224
- const memo = await acpClient.getMemoById(jobId, memoId);
225
- ```
101
+ For usage examples, see [examples/acp-base/helpers](./examples/acp-base/helpers/).
226
102
 
227
103
  ## Examples
228
104
 
229
- For detailed usage examples, please refer to the [`examples`](./examples/) directory in this repository.
230
-
231
- Refer to each example folder for more details.
232
-
233
- ## Contributing
234
-
235
- We welcome contributions from the community to help improve the ACP Node SDK. This project follows standard GitHub workflows for contributions.
105
+ All runnable code examples live under **[`examples/acp-base`](./examples/acp-base)**:
236
106
 
237
- ### How to Contribute
107
+ | Example | Description |
108
+ |--------|-------------|
109
+ | [skip-evaluation](./examples/acp-base/skip-evaluation) | Full job lifecycle without an evaluator (buyer + seller). |
110
+ | [external-evaluation](./examples/acp-base/external-evaluation) | Buyer, seller, and external evaluator. |
111
+ | [polling-mode](./examples/acp-base/polling-mode) | Polling instead of callbacks for new tasks. |
112
+ | [funds](./examples/acp-base/funds) | Trading, prediction market, and related fund flows. |
113
+ | [helpers](./examples/acp-base/helpers) | Shared utilities for ACP operations. |
114
+ | [cross-chain-transfer-service](./examples/acp-base/cross-chain-transfer-service) | Cross-chain transfer service pattern. |
238
115
 
239
- 1. **Issues**
240
- - Use GitHub Issues to report bugs
241
- - Request new features
242
- - Ask questions or discuss improvements
243
- - Please follow the issue template and provide as much detail as possible
116
+ See [examples/acp-base/README.md](./examples/acp-base/README.md) for setup, env vars, and running each example.
244
117
 
245
- 2. **Framework Integration Examples**<br>
246
- We're particularly interested in contributions that demonstrate:
247
- - Integration patterns with different agentic frameworks
248
- - Best practices for specific frameworks
249
- - Real-world use cases and implementations
250
-
251
- 3. **Pull Requests**
252
- - Fork the repository
253
- - Open a Pull Request
254
- - Ensure your PR description clearly describes the changes and their purpose
255
-
256
- ### Development Guidelines
257
-
258
- 1. **Code Style**
259
- - Follow TypeScript best practices
260
- - Maintain consistent code formatting
261
- - Include appropriate comments and documentation
118
+ ## Contributing
262
119
 
263
- 2. **Documentation**
264
- - Update README.md if needed
265
- - Include usage examples
120
+ We welcome contributions. Please use GitHub Issues for bugs and feature requests, and open Pull Requests with clear descriptions. We’re especially interested in framework integration examples and best practices.
266
121
 
267
- ### Community
122
+ - **Code style** — TypeScript best practices, consistent formatting, clear comments.
123
+ - **Docs** — Update README and add examples where relevant.
268
124
 
269
- - Join our [Discord](https://discord.gg/virtualsio) and [Telegram](https://t.me/virtuals) for discussions
270
- - Follow us on [X (formerly known as Twitter)](https://x.com/virtuals_io) for updates
125
+ **Community:** [Discord](https://discord.gg/virtualsio) · [Telegram](https://t.me/virtuals) · [X (Twitter)](https://x.com/virtuals_io)
271
126
 
272
127
  ## Useful Resources
273
128
 
274
- 1. [ACP Builder’s Guide](https://whitepaper.virtuals.io/info-hub/builders-hub/agent-commerce-protocol-acp-builder-guide/acp-tech-playbook)
275
- - A comprehensive playbook covering **all onboarding steps and tutorials**:
276
- - Create your agent and whitelist developer wallets
277
- - Explore SDK & plugin resources for seamless integration
278
- - Understand ACP job lifecycle and best prompting practices
279
- - Learn the difference between graduated and pre-graduated agents
280
- - Review SLA, status indicators, and supporting articles
281
- - Designed to help builders have their agent **ready for test interactions** on the ACP platform.
282
-
129
+ 1. [ACP Dev Onboarding Guide](https://whitepaper.virtuals.io/acp-product-resources/acp-dev-onboarding-guide) — Agent setup, wallet whitelist, job lifecycle, graduation, SLA.
283
130
  2. [Agent Registry](https://app.virtuals.io/acp/join)
284
-
285
-
286
- 3. [Agent Commerce Protocol (ACP) research page](https://app.virtuals.io/research/agent-commerce-protocol)
287
- - This webpage introduces the Agent Commerce Protocol - A Standard for Permissionless AI Agent Commerce, a piece of research done by the Virtuals Protocol team
288
- - It includes the links to the multi-agent demo dashboard and paper.
289
-
290
-
291
- 4. [ACP FAQs](https://whitepaper.virtuals.io/info-hub/builders-hub/agent-commerce-protocol-acp-builder-guide/acp-faq-debugging-tips-and-best-practices)
292
- - Comprehensive FAQ section covering common plugin questions—everything from installation and configuration to key API usage patterns.
293
- - Step-by-step troubleshooting tips for resolving frequent errors like incomplete deliverable evaluations and wallet credential issues.
131
+ 3. [Agent Commerce Protocol (ACP) research](https://app.virtuals.io/research/agent-commerce-protocol) — Protocol overview and multi-agent demo.
132
+ 4. [ACP Tips & Troubleshooting](https://whitepaper.virtuals.io/acp-product-resources/acp-dev-onboarding-guide/tips-and-troubleshooting) — FAQ and common errors.
133
+ 5. [ACP Best Practices Guide](https://whitepaper.virtuals.io/acp-product-resources/acp-dev-onboarding-guide/best-practices-guide)