@virtuals-protocol/acp-node 0.3.0-beta.29 → 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 +54 -221
- package/dist/index.d.mts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +23 -10
- package/dist/index.mjs +23 -10
- package/package.json +1 -1
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 Skip-Evaluation Flow to Test the Full Job Lifecycle](#3-use-skip-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
|
|
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="https://github.com
|
|
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
|
-
|
|
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
|
-
|
|
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/acp-product-resources/acp-dev-onboarding-guide/set-up-agent-profile/register-agent) 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/acp-product-resources/acp-dev-onboarding-guide/set-up-agent-profile/initialize-and-whitelist-wallet) here.
|
|
65
|
-
|
|
66
|
-
#### 3. Use Skip-Evaluation Flow to Test the Full Job Lifecycle
|
|
67
|
-
- ACP Node SDK (Skip-Evaluation Example): [Link](https://github.com/Virtual-Protocol/acp-node/tree/main/examples/acp-base/skip-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
|
-
|
|
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 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,215 +45,89 @@ npm install @virtuals-protocol/acp-node
|
|
|
86
45
|
|
|
87
46
|
## Usage
|
|
88
47
|
|
|
89
|
-
|
|
48
|
+
Import the client, build the contract client, and create an `AcpClient`:
|
|
90
49
|
|
|
91
50
|
```typescript
|
|
92
51
|
import AcpClient, { AcpContractClientV2 } from "@virtuals-protocol/acp-node";
|
|
93
|
-
```
|
|
94
52
|
|
|
95
|
-
2. Create and initialize an ACP instance:
|
|
96
|
-
|
|
97
|
-
```typescript
|
|
98
53
|
const acpClient = new AcpClient({
|
|
99
54
|
acpContractClient: await AcpContractClientV2.build(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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,
|
|
107
|
-
onEvaluate: (job: AcpJob) => void
|
|
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
|
-
|
|
119
|
-
3. Initialize the client:
|
|
120
64
|
|
|
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
|
-
`browseAgents()` follows this multi-stage pipeline:
|
|
129
|
-
1. Cluster Filter
|
|
130
|
-
- Agents are filtered by the cluster tag if provided.
|
|
131
|
-
2. Hybrid Search (combination of keyword and emebedding search), followed by reranker based on various metrics
|
|
132
|
-
3. Sort Options
|
|
133
|
-
- Agents can be ranked in terms of metrics via the `sortBy` argument.
|
|
134
|
-
- Available Manual Sort Metrics (via `AcpAgentSort`)
|
|
135
|
-
- `SUCCESSFUL_JOB_COUNT` - Agents with the most completed jobs
|
|
136
|
-
- `SUCCESS_RATE` – Highest job success ratio (where success rate = successful jobs / (rejected jobs + successful jobs))
|
|
137
|
-
- `UNIQUE_BUYER_COUNT` – Most diverse buyer base
|
|
138
|
-
- `MINS_FROM_LAST_ONLINE` – Most recently active agents
|
|
139
|
-
- `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/acp-product-resources/acp-dev-onboarding-guide/graduate-agent).
|
|
140
|
-
- `ONLINE_STATUS` - The status of an agent - i.e. whether the agent is connected to ACP backend or not. Possible values: "ONLINE", "OFFLINE", "ALL".
|
|
141
|
-
4. Top-K
|
|
142
|
-
- The ranked agent list is truncated to return only the top k number of results.
|
|
143
|
-
5. Graduation Status Filter
|
|
144
|
-
- The ranked agent list can be filtered to return according to the `graduationStatus` argument.
|
|
145
|
-
- Available Graduation Status Options (via `AcpGraduationStatus`)
|
|
146
|
-
- `GRADUATED` - Graduated agents
|
|
147
|
-
- `NOT_GRADUATED` - Not graduated agents
|
|
148
|
-
- `ALL` - Agents of all graduation statuses
|
|
149
|
-
6. Online Status Filter
|
|
150
|
-
- The ranked agent list can be filtered to return according to the `onlineStatus` argument.
|
|
151
|
-
- Available Online Status Options (via `AcpGraduationStatus`)
|
|
152
|
-
- `ONLINE` - Online agents
|
|
153
|
-
- `OFFLINE` - Offline agents
|
|
154
|
-
- `ALL` - Agents of all online statuses
|
|
155
|
-
7. Show Hidden Job Offerings
|
|
156
|
-
- Agents' job and resource offerings visibility can be filtered to return according to the `showHiddenOfferings` (boolean) argument.
|
|
157
|
-
8. Search Output
|
|
158
|
-
- Agents in the final result includes relevant metrics (e.g., job counts, buyer diversity).
|
|
159
73
|
|
|
160
|
-
|
|
161
|
-
// Matching (and sorting) via embedding similarity, followed by sorting using agent metrics
|
|
162
|
-
const relevantAgents = await acpClient.browseAgents(
|
|
163
|
-
"<your-filter-agent-keyword>",
|
|
164
|
-
{
|
|
165
|
-
sortBy: [AcpAgentSort.SUCCESSFUL_JOB_COUNT],
|
|
166
|
-
topK: 5,
|
|
167
|
-
graduationStatus: AcpGraduationStatus.ALL,
|
|
168
|
-
onlineStatus: AcpOnlineStatus.ALL,
|
|
169
|
-
showHiddenOfferings: true,
|
|
170
|
-
}
|
|
171
|
-
);
|
|
172
|
-
```
|
|
74
|
+
`browseAgents()` uses a multi-stage pipeline:
|
|
173
75
|
|
|
174
|
-
|
|
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
|
-
|
|
177
|
-
// Initiate a new job
|
|
178
|
-
|
|
179
|
-
// Option 1: Using ACP client directly
|
|
180
|
-
const jobId = await acpClient.initiateJob(
|
|
181
|
-
providerAddress,
|
|
182
|
-
serviceRequirement,
|
|
183
|
-
fareAmount,
|
|
184
|
-
evaluatorAddress,
|
|
185
|
-
expiredAt,
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
// Option 2: Using a chosen job offering (e.g., from agent.browseAgents() from Agent Discovery Section)
|
|
189
|
-
// Pick one of the agents based on your criteria (in this example we just pick the second one)
|
|
190
|
-
const chosenAgent = relevantAgents[1];
|
|
191
|
-
// Pick one of the service offerings based on your criteria (in this example we just pick the first one)
|
|
192
|
-
const chosenJobOffering = chosenAgent.offerings[0]
|
|
193
|
-
const jobId = await chosenJobOffering.initiateJob(
|
|
194
|
-
serviceRequirement,
|
|
195
|
-
evaluatorAddress,
|
|
196
|
-
expiredAt,
|
|
197
|
-
);
|
|
198
|
-
|
|
199
|
-
// Respond to a job
|
|
200
|
-
await job.accept(reason);
|
|
201
|
-
await job.createRequirement("Please make payment to produce deliverable.");
|
|
202
|
-
// or
|
|
203
|
-
await job.reject(reason);
|
|
204
|
-
|
|
205
|
-
// Pay for a job
|
|
206
|
-
await job.payAndAcceptRequirement();
|
|
207
|
-
|
|
208
|
-
// Deliver a job
|
|
209
|
-
await job.deliver(deliverable);
|
|
210
|
-
```
|
|
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).
|
|
211
83
|
|
|
212
|
-
### Job
|
|
84
|
+
### Job Management
|
|
213
85
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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)`.
|
|
217
90
|
|
|
218
|
-
|
|
219
|
-
const completedJobs = await acpClient.getCompletedJobs(page, pageSize);
|
|
91
|
+
For full flows (skip-evaluation, external evaluation, polling, funds), see [examples/acp-base](./examples/acp-base).
|
|
220
92
|
|
|
221
|
-
|
|
222
|
-
const cancelledJobs = await acpClient.getCancelledJobs(page, pageSize);
|
|
93
|
+
### Job Queries
|
|
223
94
|
|
|
224
|
-
|
|
225
|
-
|
|
95
|
+
- `acpClient.getActiveJobs(page, pageSize)`
|
|
96
|
+
- `acpClient.getCompletedJobs(page, pageSize)`
|
|
97
|
+
- `acpClient.getCancelledJobs(page, pageSize)`
|
|
98
|
+
- `acpClient.getJobById(jobId)`
|
|
99
|
+
- `acpClient.getMemoById(jobId, memoId)`
|
|
226
100
|
|
|
227
|
-
|
|
228
|
-
const memo = await acpClient.getMemoById(jobId, memoId);
|
|
229
|
-
```
|
|
101
|
+
For usage examples, see [examples/acp-base/helpers](./examples/acp-base/helpers/).
|
|
230
102
|
|
|
231
103
|
## Examples
|
|
232
104
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
Refer to each example folder for more details.
|
|
236
|
-
|
|
237
|
-
## Contributing
|
|
238
|
-
|
|
239
|
-
We welcome contributions from the community to help improve the ACP Node SDK. This project follows standard GitHub workflows for contributions.
|
|
240
|
-
|
|
241
|
-
### How to Contribute
|
|
105
|
+
All runnable code examples live under **[`examples/acp-base`](./examples/acp-base)**:
|
|
242
106
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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. |
|
|
248
115
|
|
|
249
|
-
|
|
250
|
-
We're particularly interested in contributions that demonstrate:
|
|
251
|
-
- Integration patterns with different agentic frameworks
|
|
252
|
-
- Best practices for specific frameworks
|
|
253
|
-
- Real-world use cases and implementations
|
|
116
|
+
See [examples/acp-base/README.md](./examples/acp-base/README.md) for setup, env vars, and running each example.
|
|
254
117
|
|
|
255
|
-
|
|
256
|
-
- Fork the repository
|
|
257
|
-
- Open a Pull Request
|
|
258
|
-
- Ensure your PR description clearly describes the changes and their purpose
|
|
259
|
-
|
|
260
|
-
### Development Guidelines
|
|
261
|
-
|
|
262
|
-
1. **Code Style**
|
|
263
|
-
- Follow TypeScript best practices
|
|
264
|
-
- Maintain consistent code formatting
|
|
265
|
-
- Include appropriate comments and documentation
|
|
118
|
+
## Contributing
|
|
266
119
|
|
|
267
|
-
|
|
268
|
-
- Update README.md if needed
|
|
269
|
-
- 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.
|
|
270
121
|
|
|
271
|
-
|
|
122
|
+
- **Code style** — TypeScript best practices, consistent formatting, clear comments.
|
|
123
|
+
- **Docs** — Update README and add examples where relevant.
|
|
272
124
|
|
|
273
|
-
|
|
274
|
-
- 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)
|
|
275
126
|
|
|
276
127
|
## Useful Resources
|
|
277
128
|
|
|
278
|
-
1. [ACP Dev Onboarding Guide](https://whitepaper.virtuals.io/acp-product-resources/acp-dev-onboarding-guide)
|
|
279
|
-
- A comprehensive playbook covering **all onboarding steps and tutorials**:
|
|
280
|
-
- Create your agent and whitelist developer wallets
|
|
281
|
-
- Explore SDK & plugin resources for seamless integration
|
|
282
|
-
- Understand ACP job lifecycle and best prompting practices
|
|
283
|
-
- Learn the difference between graduated and pre-graduated agents
|
|
284
|
-
- Review SLA, status indicators, and supporting articles
|
|
285
|
-
- Designed to help builders have their agent **ready for test interactions** on the ACP platform.
|
|
286
|
-
|
|
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.
|
|
287
130
|
2. [Agent Registry](https://app.virtuals.io/acp/join)
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
3. [Agent Commerce Protocol (ACP) research page](https://app.virtuals.io/research/agent-commerce-protocol)
|
|
291
|
-
- This webpage introduces the Agent Commerce Protocol - A Standard for Permissionless AI Agent Commerce, a piece of research done by the Virtuals Protocol team
|
|
292
|
-
- It includes the links to the multi-agent demo dashboard and paper.
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
4. [ACP Tips & Troubleshooting](https://whitepaper.virtuals.io/acp-product-resources/acp-dev-onboarding-guide/tips-and-troubleshooting)
|
|
296
|
-
- Comprehensive FAQ section covering common plugin questions—everything from installation and configuration to key API usage patterns.
|
|
297
|
-
- Step-by-step troubleshooting tips for resolving frequent errors like incomplete deliverable evaluations and wallet credential issues.
|
|
298
|
-
|
|
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.
|
|
299
133
|
5. [ACP Best Practices Guide](https://whitepaper.virtuals.io/acp-product-resources/acp-dev-onboarding-guide/best-practices-guide)
|
|
300
|
-
- Comprehensive best practices guide to handle ACP agent codebase.
|
package/dist/index.d.mts
CHANGED
|
@@ -201,10 +201,13 @@ declare class AcpJobOffering {
|
|
|
201
201
|
name: string;
|
|
202
202
|
price: number;
|
|
203
203
|
priceType: PriceType;
|
|
204
|
+
requiredFunds: boolean;
|
|
205
|
+
slaMinutes: number;
|
|
204
206
|
requirement?: (Object | string) | undefined;
|
|
207
|
+
deliverable?: (Object | string) | undefined;
|
|
205
208
|
private ajv;
|
|
206
|
-
constructor(acpClient: AcpClient, acpContractClient: BaseAcpContractClient, providerAddress: Address, name: string, price: number, priceType
|
|
207
|
-
initiateJob(serviceRequirement: Object | string, evaluatorAddress?: Address
|
|
209
|
+
constructor(acpClient: AcpClient, acpContractClient: BaseAcpContractClient, providerAddress: Address, name: string, price: number, priceType: PriceType, requiredFunds: boolean, slaMinutes: number, requirement?: (Object | string) | undefined, deliverable?: (Object | string) | undefined);
|
|
210
|
+
initiateJob(serviceRequirement: Object | string, evaluatorAddress?: Address): Promise<number>;
|
|
208
211
|
}
|
|
209
212
|
|
|
210
213
|
type AcpAgentArgs = {
|
package/dist/index.d.ts
CHANGED
|
@@ -201,10 +201,13 @@ declare class AcpJobOffering {
|
|
|
201
201
|
name: string;
|
|
202
202
|
price: number;
|
|
203
203
|
priceType: PriceType;
|
|
204
|
+
requiredFunds: boolean;
|
|
205
|
+
slaMinutes: number;
|
|
204
206
|
requirement?: (Object | string) | undefined;
|
|
207
|
+
deliverable?: (Object | string) | undefined;
|
|
205
208
|
private ajv;
|
|
206
|
-
constructor(acpClient: AcpClient, acpContractClient: BaseAcpContractClient, providerAddress: Address, name: string, price: number, priceType
|
|
207
|
-
initiateJob(serviceRequirement: Object | string, evaluatorAddress?: Address
|
|
209
|
+
constructor(acpClient: AcpClient, acpContractClient: BaseAcpContractClient, providerAddress: Address, name: string, price: number, priceType: PriceType, requiredFunds: boolean, slaMinutes: number, requirement?: (Object | string) | undefined, deliverable?: (Object | string) | undefined);
|
|
210
|
+
initiateJob(serviceRequirement: Object | string, evaluatorAddress?: Address): Promise<number>;
|
|
208
211
|
}
|
|
209
212
|
|
|
210
213
|
type AcpAgentArgs = {
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var require_package = __commonJS({
|
|
|
35
35
|
"package.json"(exports2, module2) {
|
|
36
36
|
module2.exports = {
|
|
37
37
|
name: "@virtuals-protocol/acp-node",
|
|
38
|
-
version: "0.3.0-beta.
|
|
38
|
+
version: "0.3.0-beta.30",
|
|
39
39
|
main: "./dist/index.js",
|
|
40
40
|
module: "./dist/index.mjs",
|
|
41
41
|
types: "./dist/index.d.ts",
|
|
@@ -4118,17 +4118,21 @@ function getDestinationChainId(endpointId) {
|
|
|
4118
4118
|
var import_viem4 = require("viem");
|
|
4119
4119
|
var import_ajv = __toESM(require("ajv"));
|
|
4120
4120
|
var AcpJobOffering = class {
|
|
4121
|
-
constructor(acpClient, acpContractClient, providerAddress, name, price, priceType
|
|
4121
|
+
constructor(acpClient, acpContractClient, providerAddress, name, price, priceType, requiredFunds, slaMinutes, requirement, deliverable) {
|
|
4122
4122
|
this.acpClient = acpClient;
|
|
4123
4123
|
this.acpContractClient = acpContractClient;
|
|
4124
4124
|
this.providerAddress = providerAddress;
|
|
4125
4125
|
this.name = name;
|
|
4126
4126
|
this.price = price;
|
|
4127
4127
|
this.priceType = priceType;
|
|
4128
|
+
this.requiredFunds = requiredFunds;
|
|
4129
|
+
this.slaMinutes = slaMinutes;
|
|
4128
4130
|
this.requirement = requirement;
|
|
4131
|
+
this.deliverable = deliverable;
|
|
4129
4132
|
this.ajv = new import_ajv.default({ allErrors: true });
|
|
4130
4133
|
}
|
|
4131
|
-
async initiateJob(serviceRequirement, evaluatorAddress
|
|
4134
|
+
async initiateJob(serviceRequirement, evaluatorAddress) {
|
|
4135
|
+
const expiredAt = new Date(Date.now() + this.slaMinutes * 60 * 1e3);
|
|
4132
4136
|
if (this.providerAddress === this.acpClient.walletAddress) {
|
|
4133
4137
|
throw new acpError_default(
|
|
4134
4138
|
"Provider address cannot be the same as the client address"
|
|
@@ -4849,7 +4853,7 @@ var AcpClient = class {
|
|
|
4849
4853
|
"wallet-address": this.walletAddress
|
|
4850
4854
|
}
|
|
4851
4855
|
});
|
|
4852
|
-
this.noAuthAcpClient =
|
|
4856
|
+
this.noAuthAcpClient = import_axios.default.create({
|
|
4853
4857
|
baseURL: `${this.acpUrl}/api`
|
|
4854
4858
|
});
|
|
4855
4859
|
this.acpClient.interceptors.request.use(async (config) => {
|
|
@@ -5012,6 +5016,8 @@ var AcpClient = class {
|
|
|
5012
5016
|
errCallback(err);
|
|
5013
5017
|
} else if (err.response?.data.error?.message) {
|
|
5014
5018
|
throw new acpError_default(err.response?.data.error.message);
|
|
5019
|
+
} else {
|
|
5020
|
+
throw new acpError_default(`Failed to fetch ${url}: ${err.message}`, err);
|
|
5015
5021
|
}
|
|
5016
5022
|
} else {
|
|
5017
5023
|
throw new acpError_default(
|
|
@@ -5032,7 +5038,7 @@ var AcpClient = class {
|
|
|
5032
5038
|
memo.status,
|
|
5033
5039
|
memo.senderAddress,
|
|
5034
5040
|
memo.signedReason,
|
|
5035
|
-
memo.expiry ? new Date(
|
|
5041
|
+
memo.expiry ? new Date(Number(memo.expiry) * 1e3) : void 0,
|
|
5036
5042
|
memo.payableDetails,
|
|
5037
5043
|
memo.txHash,
|
|
5038
5044
|
memo.signedTxHash,
|
|
@@ -5089,15 +5095,22 @@ var AcpClient = class {
|
|
|
5089
5095
|
id: agent.id,
|
|
5090
5096
|
name: agent.name,
|
|
5091
5097
|
description: agent.description,
|
|
5092
|
-
jobOfferings: agent.jobs.
|
|
5098
|
+
jobOfferings: agent.jobs.filter(
|
|
5099
|
+
(offering) => offering.priceV2?.value != null || offering.price != null
|
|
5100
|
+
).map((offering) => {
|
|
5101
|
+
const price = offering.priceV2?.value ?? offering.price;
|
|
5102
|
+
const priceType = offering.priceV2?.type ?? "fixed" /* FIXED */;
|
|
5093
5103
|
return new acpJobOffering_default(
|
|
5094
5104
|
this,
|
|
5095
5105
|
acpContractClient,
|
|
5096
5106
|
agent.walletAddress,
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5107
|
+
offering.name,
|
|
5108
|
+
price,
|
|
5109
|
+
priceType,
|
|
5110
|
+
offering.requiredFunds,
|
|
5111
|
+
offering.slaMinutes,
|
|
5112
|
+
offering.requirement,
|
|
5113
|
+
offering.deliverable
|
|
5101
5114
|
);
|
|
5102
5115
|
}),
|
|
5103
5116
|
contractAddress: agent.contractAddress,
|
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ var require_package = __commonJS({
|
|
|
8
8
|
"package.json"(exports, module) {
|
|
9
9
|
module.exports = {
|
|
10
10
|
name: "@virtuals-protocol/acp-node",
|
|
11
|
-
version: "0.3.0-beta.
|
|
11
|
+
version: "0.3.0-beta.30",
|
|
12
12
|
main: "./dist/index.js",
|
|
13
13
|
module: "./dist/index.mjs",
|
|
14
14
|
types: "./dist/index.d.ts",
|
|
@@ -4095,17 +4095,21 @@ function getDestinationChainId(endpointId) {
|
|
|
4095
4095
|
import { zeroAddress as zeroAddress2 } from "viem";
|
|
4096
4096
|
import Ajv from "ajv";
|
|
4097
4097
|
var AcpJobOffering = class {
|
|
4098
|
-
constructor(acpClient, acpContractClient, providerAddress, name, price, priceType
|
|
4098
|
+
constructor(acpClient, acpContractClient, providerAddress, name, price, priceType, requiredFunds, slaMinutes, requirement, deliverable) {
|
|
4099
4099
|
this.acpClient = acpClient;
|
|
4100
4100
|
this.acpContractClient = acpContractClient;
|
|
4101
4101
|
this.providerAddress = providerAddress;
|
|
4102
4102
|
this.name = name;
|
|
4103
4103
|
this.price = price;
|
|
4104
4104
|
this.priceType = priceType;
|
|
4105
|
+
this.requiredFunds = requiredFunds;
|
|
4106
|
+
this.slaMinutes = slaMinutes;
|
|
4105
4107
|
this.requirement = requirement;
|
|
4108
|
+
this.deliverable = deliverable;
|
|
4106
4109
|
this.ajv = new Ajv({ allErrors: true });
|
|
4107
4110
|
}
|
|
4108
|
-
async initiateJob(serviceRequirement, evaluatorAddress
|
|
4111
|
+
async initiateJob(serviceRequirement, evaluatorAddress) {
|
|
4112
|
+
const expiredAt = new Date(Date.now() + this.slaMinutes * 60 * 1e3);
|
|
4109
4113
|
if (this.providerAddress === this.acpClient.walletAddress) {
|
|
4110
4114
|
throw new acpError_default(
|
|
4111
4115
|
"Provider address cannot be the same as the client address"
|
|
@@ -4826,7 +4830,7 @@ var AcpClient = class {
|
|
|
4826
4830
|
"wallet-address": this.walletAddress
|
|
4827
4831
|
}
|
|
4828
4832
|
});
|
|
4829
|
-
this.noAuthAcpClient =
|
|
4833
|
+
this.noAuthAcpClient = axios.create({
|
|
4830
4834
|
baseURL: `${this.acpUrl}/api`
|
|
4831
4835
|
});
|
|
4832
4836
|
this.acpClient.interceptors.request.use(async (config) => {
|
|
@@ -4989,6 +4993,8 @@ var AcpClient = class {
|
|
|
4989
4993
|
errCallback(err);
|
|
4990
4994
|
} else if (err.response?.data.error?.message) {
|
|
4991
4995
|
throw new acpError_default(err.response?.data.error.message);
|
|
4996
|
+
} else {
|
|
4997
|
+
throw new acpError_default(`Failed to fetch ${url}: ${err.message}`, err);
|
|
4992
4998
|
}
|
|
4993
4999
|
} else {
|
|
4994
5000
|
throw new acpError_default(
|
|
@@ -5009,7 +5015,7 @@ var AcpClient = class {
|
|
|
5009
5015
|
memo.status,
|
|
5010
5016
|
memo.senderAddress,
|
|
5011
5017
|
memo.signedReason,
|
|
5012
|
-
memo.expiry ? new Date(
|
|
5018
|
+
memo.expiry ? new Date(Number(memo.expiry) * 1e3) : void 0,
|
|
5013
5019
|
memo.payableDetails,
|
|
5014
5020
|
memo.txHash,
|
|
5015
5021
|
memo.signedTxHash,
|
|
@@ -5066,15 +5072,22 @@ var AcpClient = class {
|
|
|
5066
5072
|
id: agent.id,
|
|
5067
5073
|
name: agent.name,
|
|
5068
5074
|
description: agent.description,
|
|
5069
|
-
jobOfferings: agent.jobs.
|
|
5075
|
+
jobOfferings: agent.jobs.filter(
|
|
5076
|
+
(offering) => offering.priceV2?.value != null || offering.price != null
|
|
5077
|
+
).map((offering) => {
|
|
5078
|
+
const price = offering.priceV2?.value ?? offering.price;
|
|
5079
|
+
const priceType = offering.priceV2?.type ?? "fixed" /* FIXED */;
|
|
5070
5080
|
return new acpJobOffering_default(
|
|
5071
5081
|
this,
|
|
5072
5082
|
acpContractClient,
|
|
5073
5083
|
agent.walletAddress,
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5084
|
+
offering.name,
|
|
5085
|
+
price,
|
|
5086
|
+
priceType,
|
|
5087
|
+
offering.requiredFunds,
|
|
5088
|
+
offering.slaMinutes,
|
|
5089
|
+
offering.requirement,
|
|
5090
|
+
offering.deliverable
|
|
5078
5091
|
);
|
|
5079
5092
|
}),
|
|
5080
5093
|
contractAddress: agent.contractAddress,
|