Skip to content

QUSD-ai/nanda-skill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@qusd/nanda-skill

A2A protocol skill for AI agents. Discover, message, and pay other agents.

What is this?

A TypeScript SDK implementing the A2A (Agent-to-Agent) protocol. It lets AI agents:

  • Discover other agents via Agent Cards
  • Communicate using JSON-RPC messages
  • Verify identity via did:key identifiers
  • Pay for services via X402 (coming soon)

Installation

bun add @qusd/nanda-skill
# or
npm install @qusd/nanda-skill

Quick Start

Create an Agent

import { createAgent } from '@qusd/nanda-skill';

const agent = await createAgent({
  name: 'my-agent',
  description: 'A helpful agent that answers questions',
  capabilities: [
    { name: 'chat', description: 'General conversation' },
    { name: 'search', description: 'Search the web' }
  ],
  port: 3000,
  onMessage: async (message) => {
    return `You said: ${message}`;
  }
});

// Agent is now discoverable at:
// http://localhost:3000/.well-known/agent.json

Discover Another Agent

import { discoverAgent, sendMessage } from '@qusd/nanda-skill';

// Find an agent
const card = await discoverAgent('http://localhost:3001');
console.log(`Found: ${card.name}`);
console.log(`DID: ${card.did}`);
console.log(`Capabilities: ${card.capabilities.map(c => c.name).join(', ')}`);

// Send a message
const response = await sendMessage('http://localhost:3001', 'Hello!');
console.log(`Response: ${response.result}`);

Using the Client Class

import { A2AClient } from '@qusd/nanda-skill';

const client = new A2AClient('http://localhost:3001');

// Discover the agent
const card = await client.discover();

// Check capabilities
if (client.hasCapability('search')) {
  const result = await client.sendMessage('Search for AI news');
  console.log(result);
}

Agent Card

Every agent exposes an Agent Card at /.well-known/agent.json:

{
  "name": "my-agent",
  "description": "A helpful agent",
  "url": "http://localhost:3000",
  "did": "did:key:z6Mk...",
  "capabilities": [
    { "name": "chat", "description": "General conversation" }
  ],
  "version": "1.0.0"
}

Identity (did:key)

Each agent gets a cryptographic identity using the did:key method:

import { generateIdentity } from '@qusd/nanda-skill';

const identity = await generateIdentity();
console.log(identity.did); // did:key:z6Mk...

This DID can be:

  • Verified cryptographically (no central authority)
  • Registered on-chain for reputation tracking
  • Used to sign messages and prove authorship

JSON-RPC Methods

Method Description
message/send Send a message to the agent
tasks/get Get task status by ID
tasks/list List all tasks

Example: Multi-Agent System

import { createAgent, A2AClient } from '@qusd/nanda-skill';

// Create Vision agent
const vision = await createAgent({
  name: 'vision-agent',
  description: 'Processes images and detects objects',
  capabilities: [{ name: 'detect-objects' }],
  port: 3001,
  onMessage: async (msg) => {
    return JSON.stringify({ objects: ['person', 'car', 'tree'] });
  }
});

// Create Navigation agent that uses Vision
const nav = await createAgent({
  name: 'nav-agent', 
  description: 'Plans routes and avoids obstacles',
  capabilities: [{ name: 'plan-route' }],
  port: 3002,
  onMessage: async (msg) => {
    // Query vision agent
    const visionClient = new A2AClient('http://localhost:3001');
    await visionClient.discover();
    const obstacles = await visionClient.sendMessage('detect obstacles');
    
    return `Route planned avoiding: ${obstacles.result}`;
  }
});

Roadmap

  • X402 payment integration
  • On-chain agent registry
  • Reputation scoring
  • Streaming responses
  • MCP bridge

License

MIT

Links

About

A2A protocol skill for AI agents. Discover, message, and pay other agents.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors