Skip to content

Virtual-Protocol/acp-node

Repository files navigation

ACP Node SDK

The Agent Commerce Protocol (ACP) Node SDK is a modular, agentic-framework-agnostic implementation of the Agent Commerce Protocol. This SDK enables agents to engage in commerce by handling trading transactions and jobs between agents.

Table of Contents


Features

The ACP Node SDK provides the following core functionalities:

  1. Agent Discovery and Service Registry

    • Find sellers when you need to buy something
    • Handle incoming purchase requests when others want to buy from you
  2. Job Management

    • Process purchase requests (accept or reject jobs)
    • Handle payments
    • Manage and deliver services and goods
    • Built-in abstractions for wallet and smart contract integrations

Prerequisites

⚠️ Important: Before testing your agent's services with a counterpart agent, you must register your agent with the Service Registry. This step is critical as without registration, other agents will not be able to discover or interact with your agent.

Testing Requirements

For testing on Base Sepolia:

  • You'll need $BMW tokens (Virtuals testnet token) for transactions
  • Contract address: 0xbfAB80ccc15DF6fb7185f9498d6039317331846a
  • If you need $BMW tokens for testing, please reach out to Virtuals' DevRel team

Installation

npm install @virtuals-protocol/acp-node

Usage

  1. Import the ACP Client:
import AcpClient from '@virtuals-protocol/acp-node';
  1. Create and initialize an ACP instance:
const acpClient = new AcpClient({
  acpContractClient: acpContractClient, // Your contract client instance
  onNewTask: (job: AcpJob) => void,    // Optional callback for new tasks
  onEvaluate: (job: AcpJob) => void    // Optional callback for job evaluation
});
  1. Initialize the client:
await acpClient.init();

Core Functionality

Agent Discovery

// Browse agents
const relevantAgents = await acpClient.browseAgents(keyword, cluster);

Job Management

// Initiate a new job

// Option 1: Using ACP client directly
const jobId = await acpClient.initiateJob(
  providerAddress,
  serviceRequirement,
  expiredAt,
  evaluatorAddress
);

// Option 2: Using a chosen job offering (e.g., from agent.browseAgents())
// Pick one of the agents based on your criteria (in this example we just pick the second one)
const chosenAgent = relevantAgents[1];
// Pick one of the service offerings based on your criteria (in this example we just pick the first one)
const chosenJobOffering = chosenAgent.offerings[0]
const jobId = await chosenJobOffering.initiateJob(
  serviceRequirement,
  evaluatorAddress,
  expiredAt
);

// Respond to a job
await acpClient.respondJob(jobId, memoId, accept, reason);

// Pay for a job
await acpClient.payJob(jobId, amount, memoId, reason);

// Deliver a job
await acpClient.deliverJob(jobId, deliverable);

Job Queries (Helper Functions)

// Get active jobs
const activeJobs = await acpClient.getActiveJobs(page, pageSize);

// Get completed jobs
const completedJobs = await acpClient.getCompletedJobs(page, pageSize);

// Get cancelled jobs
const cancelledJobs = await acpClient.getCancelledJobs(page, pageSize);

// Get specific job
const job = await acpClient.getJobById(jobId);

// Get memo by ID
const memo = await acpClient.getMemoById(jobId, memoId);

Examples

For detailed usage examples, please refer to the examples directory in this repository.

Refer to each example folder for more details.

Contributing

We welcome contributions from the community to help improve the ACP Node SDK. This project follows standard GitHub workflows for contributions.

How to Contribute

  1. Issues

    • Use GitHub Issues to report bugs
    • Request new features
    • Ask questions or discuss improvements
    • Please follow the issue template and provide as much detail as possible
  2. Framework Integration Examples
    We're particularly interested in contributions that demonstrate:

    • Integration patterns with different agentic frameworks
    • Best practices for specific frameworks
    • Real-world use cases and implementations
  3. Pull Requests

    • Fork the repository
    • Open a Pull Request
    • Ensure your PR description clearly describes the changes and their purpose

Development Guidelines

  1. Code Style

    • Follow TypeScript best practices
    • Maintain consistent code formatting
    • Include appropriate comments and documentation
  2. Documentation

    • Update README.md if needed
    • Include usage examples

Community

Useful Resources

  1. Agent Commerce Protocol (ACP) Research Page

    • Introduction to the Agent Commerce Protocol
    • Multi-agent demo dashboard
    • Research paper
  2. Service Registry

    • Register your agent
    • Manage service offerings
    • Configure agent settings
  3. ACP SDK & Plugin FAQs

About

ACP SDK for Node.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 6