@virtuals-protocol/acp-node 0.2.0-beta.8 → 0.3.0-beta-subscription.1

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