@virtuals-protocol/acp-node 0.1.0-beta.1 → 0.1.0-beta.2

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.
Files changed (36) hide show
  1. package/dist/index.d.mts +8450 -0
  2. package/dist/index.d.ts +8450 -0
  3. package/dist/index.js +1522 -0
  4. package/dist/index.mjs +1484 -0
  5. package/package.json +5 -2
  6. package/buyer.ts +0 -47
  7. package/docs/imgs/acp-banner.jpeg +0 -0
  8. package/examples/acp_base/README.md +0 -94
  9. package/examples/acp_base/docs/imgs/agent-wallet-page.png +0 -0
  10. package/examples/acp_base/docs/imgs/session-entity-id-location.png +0 -0
  11. package/examples/acp_base/docs/imgs/whitelist-wallet-info.png +0 -0
  12. package/examples/acp_base/docs/imgs/whitelist-wallet.png +0 -0
  13. package/examples/acp_base/external_evaluation/.env.example +0 -5
  14. package/examples/acp_base/external_evaluation/buyer.ts +0 -52
  15. package/examples/acp_base/external_evaluation/env.ts +0 -22
  16. package/examples/acp_base/external_evaluation/evaluator.ts +0 -29
  17. package/examples/acp_base/external_evaluation/seller.ts +0 -46
  18. package/examples/acp_base/self_evaluation/.env.example +0 -4
  19. package/examples/acp_base/self_evaluation/buyer.ts +0 -54
  20. package/examples/acp_base/self_evaluation/env.ts +0 -21
  21. package/examples/acp_base/self_evaluation/seller.ts +0 -46
  22. package/helpers/.env.example +0 -3
  23. package/helpers/acpHelperFunctions.ts +0 -69
  24. package/interfaces.ts +0 -24
  25. package/seller.ts +0 -46
  26. package/src/acpAbi.ts +0 -680
  27. package/src/acpClient.ts +0 -458
  28. package/src/acpContractClient.ts +0 -269
  29. package/src/acpJob.ts +0 -91
  30. package/src/acpJobOffering.ts +0 -43
  31. package/src/acpMemo.ts +0 -32
  32. package/src/configs.ts +0 -28
  33. package/src/index.ts +0 -18
  34. package/src/interfaces.ts +0 -55
  35. package/test.ts +0 -26
  36. package/tsconfig.json +0 -113
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@virtuals-protocol/acp-node",
3
- "version": "0.1.0-beta.1",
3
+ "version": "0.1.0-beta.2",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -22,5 +22,8 @@
22
22
  "socket.io-client": "^4.8.1",
23
23
  "tsup": "^8.5.0",
24
24
  "viem": "^2.28.2"
25
- }
25
+ },
26
+ "files": [
27
+ "dist"
28
+ ]
26
29
  }
package/buyer.ts DELETED
@@ -1,47 +0,0 @@
1
- import AcpClient, {
2
- AcpContractClient,
3
- AcpJob,
4
- AcpJobPhases,
5
- baseSepoliaAcpConfig,
6
- } from "./dist/index.mjs";
7
-
8
- async function buyer() {
9
- const config = baseSepoliaAcpConfig;
10
- config.acpUrl = "https://acpx.virtuals.gg";
11
-
12
- const acpClient = new AcpClient({
13
- acpContractClient: await AcpContractClient.build(
14
- "0x28d641a2851134ace8673ae320ffed9f77826a52fadc813c55dd22c2870acf3b",
15
- 1,
16
- "0xc027328E8202910F496232358567Ed1DA982c728",
17
- config
18
- ),
19
- onNewTask: async (job: AcpJob) => {
20
- if (
21
- job.phase === AcpJobPhases.NEGOTIATION &&
22
- job.memos.find((m) => m.nextPhase === AcpJobPhases.TRANSACTION)
23
- ) {
24
- console.log("Paying job", job);
25
- await job.pay(1);
26
- console.log(`Job ${job.id} paid`);
27
- } else if (job.phase === AcpJobPhases.COMPLETED) {
28
- console.log(`Job ${job.id} completed`);
29
- }
30
- },
31
- onEvaluate: async (job: AcpJob) => {
32
- console.log("Evaluation function called", job);
33
- await job.evaluate(true, "Self-evaluated and approved");
34
- console.log(`Job ${job.id} evaluated`);
35
- },
36
- });
37
-
38
- const job = await acpClient.initiateJob(
39
- "0x88Be2314fd1d9f3BFE07Af252fbf96aF636FD68E",
40
- "meme generation",
41
- 1
42
- );
43
-
44
- console.log(job);
45
- }
46
-
47
- buyer();
Binary file
@@ -1,94 +0,0 @@
1
- # ACP Node SDK Examples (without framework)
2
-
3
- This directory contains raw examples demonstrating direct usage of the ACP Node SDK without any agentic framework integration.
4
-
5
- ## Directory Structure
6
-
7
- - [`external_evaluation/`](./external_evaluation) - Examples demonstrating external evaluation pattern
8
- - [`self_evaluation/`](./self_evaluation) - Examples demonstrating self evaluation pattern
9
-
10
- ## Environment Setup
11
-
12
- Before running the examples, you need to set up your environment variables. Create a `.env` file in the example directory with the following variables:
13
-
14
- ```bash
15
- # Required for all examples
16
- WHITELISTED_WALLET_PRIVATE_KEY=0x... # Your whitelisted wallet private key
17
- WHITELISTED_WALLET_ENTITY_ID=... # Your session entity key ID
18
- BUYER_AGENT_WALLET_ADDRESS=0x... # Buyer's wallet address
19
- SELLER_AGENT_WALLET_ADDRESS=0x... # Seller's wallet address
20
-
21
- # Required for external evaluation examples
22
- EVALUATOR_AGENT_WALLET_ADDRESS=0x... # Evaluator's wallet address
23
- ```
24
-
25
- ### Getting the Required Values
26
-
27
- 1. **Whitelist Your Wallet**
28
- - Go to [Service Registry](https://acp-staging.virtuals.io/)
29
- - Navigate to the Agent Wallet page
30
- ![Agent Wallet Page](docs/imgs/agent-wallet-page.png)
31
- - Whitelist your wallet:
32
- ![Whitelist Wallet](docs/imgs/whitelist-wallet.png)
33
- ![Whitelist Wallet Info](docs/imgs/whitelist-wallet-info.png)
34
-
35
- 2. **Get Session Entity Key ID**
36
- - Find your session entity key ID in the Service Registry:
37
- ![Session Entity ID](docs/imgs/session-entity-id-location.png)
38
-
39
- 3. **Wallet Addresses**
40
- - `BUYER_AGENT_WALLET_ADDRESS`: The wallet address of the agent initiating the job
41
- - `SELLER_AGENT_WALLET_ADDRESS`: The wallet address of the agent providing the service
42
- - `EVALUATOR_AGENT_WALLET_ADDRESS`: (For external evaluation) The wallet address of the third-party evaluator
43
-
44
- > **Note:** Make sure your wallet has sufficient $BMW tokens for testing on Base Sepolia. If you need tokens, please reach out to Virtuals' DevRel team.
45
-
46
- ## Evaluation Patterns
47
-
48
- ### Self Evaluation
49
-
50
- Self evaluation occurs when the buyer evaluates their own job deliverables. This pattern is useful when:
51
- - The buyer has specific criteria for quality control
52
- - The evaluation logic is simple and can be automated
53
- - The buyer wants to maintain control over the evaluation process
54
-
55
- Example implementation:
56
- ```typescript
57
- const onEvaluate = (job: AcpJob) => {
58
- // Implement your evaluation logic here
59
- await job.evaluate(true, "Self-evaluated and approved");
60
- };
61
- ```
62
-
63
- For a complete implementation, see the [`self_evaluation`](./self_evaluation) directory.
64
-
65
- ### External Evaluation
66
-
67
- External evaluation involves a third-party evaluator reviewing job deliverables. This pattern is useful when:
68
- - You need unbiased evaluation
69
- - The evaluation requires domain expertise
70
- - You want to implement reputation systems
71
-
72
- Example implementation:
73
- ```typescript
74
- const onEvaluate = (job: AcpJob) => {
75
- // Implement external evaluation logic here
76
- // This could involve calling external APIs or services
77
- await job.evaluate(true, "Externally evaluated and approved");
78
- };
79
- ```
80
-
81
- For a complete implementation, see the [`external_evaluation`](./external_evaluation) directory.
82
-
83
- ## Usage
84
-
85
- To use these examples:
86
-
87
- 1. Navigate to the specific example directory:
88
- - [`self_evaluation/`](./self_evaluation) for self-evaluation pattern
89
- - [`external_evaluation/`](./external_evaluation) for external evaluation pattern
90
- 2. Review the implementation details
91
- 3. Copy the relevant code patterns to your implementation
92
- 4. Customize the evaluation logic according to your needs
93
-
94
- For more detailed examples and implementations, please refer to the specific example directories.
@@ -1,5 +0,0 @@
1
- WHITELISTED_WALLET_PRIVATE_KEY=0x-<whitelisted-wallet-private-key>
2
- WHITELISTED_WALLET_ENTITY_ID=<whitelisted-wallet-entity-id>
3
- BUYER_AGENT_WALLET_ADDRESS=<buyer-agent-wallet-address>
4
- SELLER_AGENT_WALLET_ADDRESS=<seller-agent-wallet-address>
5
- EVALUATOR_AGENT_WALLET_ADDRESS=<evaluator-agent-wallet-address>
@@ -1,52 +0,0 @@
1
- // TODO: Point the imports to acp-node after publishing
2
-
3
- import AcpClient from "../../../src/acpClient";
4
- import AcpContractClient, { AcpJobPhases } from "../../../src/acpContractClient";
5
- import AcpJob from "../../../src/acpJob";
6
- import { baseSepoliaAcpConfig } from "../../../src";
7
- import {
8
- BUYER_AGENT_WALLET_ADDRESS,
9
- EVALUATOR_AGENT_WALLET_ADDRESS,
10
- WHITELISTED_WALLET_ENTITY_ID,
11
- WHITELISTED_WALLET_PRIVATE_KEY
12
- } from "./env";
13
-
14
- async function buyer() {
15
- const acpClient = new AcpClient({
16
- acpContractClient: await AcpContractClient.build(
17
- WHITELISTED_WALLET_PRIVATE_KEY,
18
- WHITELISTED_WALLET_ENTITY_ID,
19
- BUYER_AGENT_WALLET_ADDRESS,
20
- baseSepoliaAcpConfig
21
- ),
22
- onNewTask: async (job: AcpJob) => {
23
- if (
24
- job.phase === AcpJobPhases.NEGOTIATION &&
25
- job.memos.find((m) => m.nextPhase === AcpJobPhases.TRANSACTION)
26
- ) {
27
- console.log("Paying job", job);
28
- await job.pay(1);
29
- console.log(`Job ${job.id} paid`);
30
- } else if (job.phase === AcpJobPhases.COMPLETED) {
31
- console.log(`Job ${job.id} completed`);
32
- }
33
- },
34
- });
35
-
36
- const relevantAgents = await acpClient.browseAgents("meme", "999");
37
- console.log("Relevant seller agents: ", relevantAgents);
38
- // Pick one of the agents based on your criteria (in this example we just pick the second one)
39
- const chosenAgent = relevantAgents[1];
40
- // Pick one of the service offerings based on your criteria (in this example we just pick the first one)
41
- const chosenJobOffering = chosenAgent.offerings[0]
42
-
43
- const jobId = await chosenJobOffering.initiateJob(
44
- chosenJobOffering.requirementSchema || {},
45
- new Date(Date.now() + 1000 * 60 * 60 * 24),
46
- EVALUATOR_AGENT_WALLET_ADDRESS,
47
- );
48
-
49
- console.log(`Job ${jobId} initiated`);
50
- }
51
-
52
- buyer();
@@ -1,22 +0,0 @@
1
- import dotenv from "dotenv";
2
- import { Address } from "viem";
3
-
4
- dotenv.config({ path: __dirname + '/.env' });
5
-
6
- function getEnvVar<T extends string = string>(key: string, required = true): T {
7
- const value = process.env[key];
8
- if (required && (value === undefined || value === '')) {
9
- throw new Error(`${key} is not defined or is empty in the .env file`);
10
- }
11
- return value as T;
12
- }
13
-
14
- export const WHITELISTED_WALLET_PRIVATE_KEY = getEnvVar<Address>('WHITELISTED_WALLET_PRIVATE_KEY');
15
- export const WHITELISTED_WALLET_ENTITY_ID = parseInt(getEnvVar('WHITELISTED_WALLET_ENTITY_ID'), 10);
16
- export const BUYER_AGENT_WALLET_ADDRESS = getEnvVar<Address>('BUYER_AGENT_WALLET_ADDRESS');
17
- export const SELLER_AGENT_WALLET_ADDRESS = getEnvVar<Address>('SELLER_AGENT_WALLET_ADDRESS');
18
- export const EVALUATOR_AGENT_WALLET_ADDRESS = getEnvVar<Address>('EVALUATOR_AGENT_WALLET_ADDRESS');
19
-
20
- if (isNaN(WHITELISTED_WALLET_ENTITY_ID)) {
21
- throw new Error('WHITELISTED_WALLET_ENTITY_ID must be a valid number in the .env file');
22
- }
@@ -1,29 +0,0 @@
1
- // TODO: Point the imports to acp-node after publishing
2
-
3
- import AcpClient from "../../../src/acpClient";
4
- import AcpContractClient from "../../../src/acpContractClient";
5
- import AcpJob from "../../../src/acpJob";
6
- import { baseSepoliaAcpConfig } from "../../../src";
7
- import {
8
- EVALUATOR_AGENT_WALLET_ADDRESS,
9
- WHITELISTED_WALLET_ENTITY_ID,
10
- WHITELISTED_WALLET_PRIVATE_KEY
11
- } from "./env";
12
-
13
- async function evaluator() {
14
- new AcpClient({
15
- acpContractClient: await AcpContractClient.build(
16
- WHITELISTED_WALLET_PRIVATE_KEY,
17
- WHITELISTED_WALLET_ENTITY_ID,
18
- EVALUATOR_AGENT_WALLET_ADDRESS,
19
- baseSepoliaAcpConfig
20
- ),
21
- onEvaluate: async (job: AcpJob) => {
22
- console.log("Evaluation function called", job);
23
- await job.evaluate(true, "Externally evaluated and approved");
24
- console.log(`Job ${job.id} evaluated`);
25
- },
26
- });
27
- }
28
-
29
- evaluator();
@@ -1,46 +0,0 @@
1
- // TODO: Point the imports to acp-node after publishing
2
-
3
- import AcpClient from "../../../src/acpClient";
4
- import AcpContractClient, { AcpJobPhases } from "../../../src/acpContractClient";
5
- import AcpJob from "../../../src/acpJob";
6
- import { baseSepoliaAcpConfig } from "../../../src";
7
- import {
8
- SELLER_AGENT_WALLET_ADDRESS,
9
- WHITELISTED_WALLET_ENTITY_ID,
10
- WHITELISTED_WALLET_PRIVATE_KEY
11
- } from "./env";
12
-
13
- async function seller() {
14
- new AcpClient({
15
- acpContractClient: await AcpContractClient.build(
16
- WHITELISTED_WALLET_PRIVATE_KEY,
17
- WHITELISTED_WALLET_ENTITY_ID,
18
- SELLER_AGENT_WALLET_ADDRESS,
19
- baseSepoliaAcpConfig
20
- ),
21
- onNewTask: async (job: AcpJob) => {
22
- if (
23
- job.phase === AcpJobPhases.REQUEST &&
24
- job.memos.find((m) => m.nextPhase === AcpJobPhases.NEGOTIATION)
25
- ) {
26
- console.log("Responding to job", job);
27
- await job.respond(true);
28
- console.log(`Job ${job.id} responded`);
29
- } else if (
30
- job.phase === AcpJobPhases.TRANSACTION &&
31
- job.memos.find((m) => m.nextPhase === AcpJobPhases.EVALUATION)
32
- ) {
33
- console.log("Delivering job", job);
34
- await job.deliver(
35
- JSON.stringify({
36
- type: "url",
37
- value: "https://example.com",
38
- })
39
- );
40
- console.log(`Job ${job.id} delivered`);
41
- }
42
- },
43
- });
44
- }
45
-
46
- seller();
@@ -1,4 +0,0 @@
1
- WHITELISTED_WALLET_PRIVATE_KEY=0x-<whitelisted-wallet-private-key>
2
- WHITELISTED_WALLET_ENTITY_ID=<whitelisted-wallet-entity-id>
3
- BUYER_AGENT_WALLET_ADDRESS=<buyer-agent-wallet-address>
4
- SELLER_AGENT_WALLET_ADDRESS=<seller-agent-wallet-address>
@@ -1,54 +0,0 @@
1
- // TODO: Point the imports to acp-node after publishing
2
-
3
- import AcpClient from "../../../src/acpClient";
4
- import AcpContractClient, { AcpJobPhases } from "../../../src/acpContractClient";
5
- import AcpJob from "../../../src/acpJob";
6
- import { baseSepoliaAcpConfig } from "../../../src";
7
- import {
8
- BUYER_AGENT_WALLET_ADDRESS,
9
- WHITELISTED_WALLET_ENTITY_ID,
10
- WHITELISTED_WALLET_PRIVATE_KEY
11
- } from "./env";
12
-
13
- async function buyer() {
14
- const acpClient = new AcpClient({
15
- acpContractClient: await AcpContractClient.build(
16
- WHITELISTED_WALLET_PRIVATE_KEY,
17
- WHITELISTED_WALLET_ENTITY_ID,
18
- BUYER_AGENT_WALLET_ADDRESS,
19
- baseSepoliaAcpConfig
20
- ),
21
- onNewTask: async (job: AcpJob) => {
22
- if (
23
- job.phase === AcpJobPhases.NEGOTIATION &&
24
- job.memos.find((m) => m.nextPhase === AcpJobPhases.TRANSACTION)
25
- ) {
26
- console.log("Paying job", job);
27
- await job.pay(1);
28
- console.log(`Job ${job.id} paid`);
29
- } else if (job.phase === AcpJobPhases.COMPLETED) {
30
- console.log(`Job ${job.id} completed`);
31
- }
32
- },
33
- onEvaluate: async (job: AcpJob) => {
34
- console.log("Evaluation function called", job);
35
- await job.evaluate(true, "Self-evaluated and approved");
36
- console.log(`Job ${job.id} evaluated`);
37
- },
38
- });
39
-
40
- const relevantAgents = await acpClient.browseAgents("meme", "999");
41
- // Pick one of the agents based on your criteria (in this example we just pick the first one)
42
- const chosenAgent = relevantAgents[0];
43
- // Pick one of the service offerings based on your criteria (in this example we just pick the first one)
44
- const chosenJobOffering = chosenAgent.offerings[0]
45
-
46
- const jobId = await chosenJobOffering.initiateJob(
47
- chosenJobOffering.requirementSchema || {},
48
- new Date(Date.now() + 1000 * 60 * 60 * 24),
49
- );
50
-
51
- console.log(`Job ${jobId} initiated`);
52
- }
53
-
54
- buyer();
@@ -1,21 +0,0 @@
1
- import dotenv from "dotenv";
2
- import { Address } from "viem";
3
-
4
- dotenv.config({ path: __dirname + '/.env' });
5
-
6
- function getEnvVar<T extends string = string>(key: string, required = true): T {
7
- const value = process.env[key];
8
- if (required && (value === undefined || value === '')) {
9
- throw new Error(`${key} is not defined or is empty in the .env file`);
10
- }
11
- return value as T;
12
- }
13
-
14
- export const WHITELISTED_WALLET_PRIVATE_KEY = getEnvVar<Address>('WHITELISTED_WALLET_PRIVATE_KEY');
15
- export const WHITELISTED_WALLET_ENTITY_ID = parseInt(getEnvVar('WHITELISTED_WALLET_ENTITY_ID'), 10);
16
- export const BUYER_AGENT_WALLET_ADDRESS = getEnvVar<Address>('BUYER_AGENT_WALLET_ADDRESS');
17
- export const SELLER_AGENT_WALLET_ADDRESS = getEnvVar<Address>('SELLER_AGENT_WALLET_ADDRESS');
18
-
19
- if (isNaN(WHITELISTED_WALLET_ENTITY_ID)) {
20
- throw new Error('WHITELISTED_WALLET_ENTITY_ID must be a valid number in the .env file');
21
- }
@@ -1,46 +0,0 @@
1
- // TODO: Point the imports to acp-node after publishing
2
-
3
- import AcpClient from "../../../src/acpClient";
4
- import AcpContractClient, { AcpJobPhases } from "../../../src/acpContractClient";
5
- import AcpJob from "../../../src/acpJob";
6
- import { baseSepoliaAcpConfig } from "../../../src";
7
- import {
8
- SELLER_AGENT_WALLET_ADDRESS,
9
- WHITELISTED_WALLET_ENTITY_ID,
10
- WHITELISTED_WALLET_PRIVATE_KEY
11
- } from "./env";
12
-
13
- async function seller() {
14
- new AcpClient({
15
- acpContractClient: await AcpContractClient.build(
16
- WHITELISTED_WALLET_PRIVATE_KEY,
17
- WHITELISTED_WALLET_ENTITY_ID,
18
- SELLER_AGENT_WALLET_ADDRESS,
19
- baseSepoliaAcpConfig
20
- ),
21
- onNewTask: async (job: AcpJob) => {
22
- if (
23
- job.phase === AcpJobPhases.REQUEST &&
24
- job.memos.find((m) => m.nextPhase === AcpJobPhases.NEGOTIATION)
25
- ) {
26
- console.log("Responding to job", job);
27
- await job.respond(true);
28
- console.log(`Job ${job.id} responded`);
29
- } else if (
30
- job.phase === AcpJobPhases.TRANSACTION &&
31
- job.memos.find((m) => m.nextPhase === AcpJobPhases.EVALUATION)
32
- ) {
33
- console.log("Delivering job", job);
34
- await job.deliver(
35
- JSON.stringify({
36
- type: "url",
37
- value: "https://example.com",
38
- })
39
- );
40
- console.log(`Job ${job.id} delivered`);
41
- }
42
- },
43
- });
44
- }
45
-
46
- seller();
@@ -1,3 +0,0 @@
1
- WHITELISTED_WALLET_PRIVATE_KEY=0x-<whitelisted-wallet-private-key>
2
- WHITELISTED_WALLET_ENTITY_ID=<whitelisted-wallet-entity-id>
3
- BUYER_AGENT_WALLET_ADDRESS=<buyer-agent-wallet-address>
@@ -1,69 +0,0 @@
1
- import AcpClient from "../src/acpClient";
2
- import AcpContractClient from "../src/acpContractClient";
3
- import { baseSepoliaAcpConfig } from "../src/configs";
4
- import * as dotenv from "dotenv";
5
- import { Address } from "viem";
6
-
7
- // Load environment variables
8
- dotenv.config({ override: true });
9
-
10
- async function testHelperFunctions() {
11
- console.log("Testing ACP helper functions...");
12
-
13
- // Initialize AcpClient
14
- const acpClient = new AcpClient({
15
- acpContractClient: await AcpContractClient.build(
16
- process.env.WHITELISTED_WALLET_PRIVATE_KEY as `0x${string}`,
17
- Number(process.env.WHITELISTED_WALLET_ENTITY_ID),
18
- process.env.BUYER_AGENT_WALLET_ADDRESS as Address,
19
- baseSepoliaAcpConfig
20
- )
21
- });
22
-
23
- // Get active jobs
24
- const activeJobs = await acpClient.getActiveJobs(1, 10);
25
- console.log("\n🔵 Active Jobs:");
26
- console.log(activeJobs.length > 0 ? activeJobs : "No active jobs found.");
27
-
28
- // Get completed jobs
29
- const completedJobs = await acpClient.getCompletedJobs(1, 10);
30
- console.log("\n✅ Completed Jobs:");
31
- console.log(completedJobs.length > 0 ? completedJobs : "No completed jobs found.");
32
-
33
- // Get cancelled jobs
34
- const cancelledJobs = await acpClient.getCancelledJobs(1, 10);
35
- console.log("\n❌ Cancelled Jobs:");
36
- console.log(cancelledJobs.length > 0 ? cancelledJobs : "No cancelled jobs found.");
37
-
38
- if (completedJobs.length > 0) {
39
- const onChainJobId = completedJobs[0].id;
40
- if (onChainJobId) {
41
- const job = await acpClient.getJobById(onChainJobId);
42
- console.log(`\n📄 Job Details (Job ID: ${onChainJobId}):`);
43
- console.log(job);
44
-
45
- const memos = completedJobs[0].memos;
46
- if (memos && memos.length > 0) {
47
- const memoId = memos[0].id;
48
- const memo = await acpClient.getMemoById(onChainJobId, memoId);
49
- console.log(`\n📝 Memo Details (Job ID: ${onChainJobId}, Memo ID: ${memoId}):`);
50
- console.log(memo);
51
- } else {
52
- console.log("\n⚠️ No memos found for the completed job.");
53
- }
54
- }
55
- } else {
56
- console.log("\n⚠️ No completed jobs available for detailed inspection.");
57
- }
58
- }
59
-
60
- // Run the test
61
- testHelperFunctions()
62
- .then(() => {
63
- console.log("\n✨ Test completed successfully");
64
- process.exit(0);
65
- })
66
- .catch(error => {
67
- console.error("Error in helper functions test:", error);
68
- process.exit(1);
69
- });
package/interfaces.ts DELETED
@@ -1,24 +0,0 @@
1
- import { Address } from "viem";
2
-
3
- export type AcpAgent = {
4
- id: number;
5
- documentId: string;
6
- name: string;
7
- description: string;
8
- walletAddress: Address;
9
- isVirtualAgent: boolean;
10
- profilePic: string;
11
- category: string;
12
- tokenAddress: string | null;
13
- ownerAddress: string;
14
- cluster: string | null;
15
- twitterHandle: string;
16
- offerings: {
17
- name: string;
18
- price: number;
19
- requirementSchema?: Object;
20
- deliverableSchema?: Object;
21
- }[];
22
- symbol: string | null;
23
- virtualAgentId: string | null;
24
- };
package/seller.ts DELETED
@@ -1,46 +0,0 @@
1
- import AcpClient, {
2
- AcpContractClient,
3
- AcpJob,
4
- AcpJobPhases,
5
- baseSepoliaAcpConfig,
6
- } from "./dist/index.mjs";
7
-
8
- async function seller() {
9
- const config = baseSepoliaAcpConfig;
10
- config.acpUrl = "https://acpx.virtuals.gg";
11
-
12
- new AcpClient({
13
- acpContractClient: await AcpContractClient.build(
14
- "0x28d641a2851134ace8673ae320ffed9f77826a52fadc813c55dd22c2870acf3b",
15
- 1,
16
- "0x88Be2314fd1d9f3BFE07Af252fbf96aF636FD68E",
17
- config
18
- ),
19
- onNewTask: async (job: AcpJob) => {
20
- console.log(job);
21
-
22
- if (
23
- job.phase === AcpJobPhases.REQUEST &&
24
- job.memos.find((m) => m.nextPhase === AcpJobPhases.NEGOTIATION)
25
- ) {
26
- console.log("Responding to job", job);
27
- await job.respond(true);
28
- console.log(`Job ${job.id} responded`);
29
- } else if (
30
- job.phase === AcpJobPhases.TRANSACTION &&
31
- job.memos.find((m) => m.nextPhase === AcpJobPhases.EVALUATION)
32
- ) {
33
- console.log("Delivering job", job);
34
- await job.deliver(
35
- JSON.stringify({
36
- type: "url",
37
- value: "https://example.com",
38
- })
39
- );
40
- console.log(`Job ${job.id} delivered`);
41
- }
42
- },
43
- });
44
- }
45
-
46
- seller();