@agentdao/core
TypeScript icon, indicating that this package has built-in type declarations

0.7.0 • Public • Published

AgentDAO Core

Core functionality, skills, and ready-made UI components for AgentDAO - Web3 subscriptions, content generation, social media, help support, live chat, RSS fetching, web search, and agent pricing integration.

Features

  • Web3 Subscription Management - Multi-token support with automated renewal
  • Content Generation - AI-powered content creation with SEO optimization
  • Social Media Integration - Automated posting and engagement
  • Help & Support - AI-powered customer support with escalation
  • Live Chat - Real-time chat with AI integration
  • RSS & Web Search - Content aggregation and search capabilities
  • Agent Pricing - Dynamic pricing and monetization
  • A2A Protocol - Agent-to-Agent communication and collaboration
  • Token Gating - Web3 access control and membership management

Installation

npm install @agentdao/core

Quick Start

import { 
  Agent, 
  Web3SubscriptionSkill, 
  ContentGeneratorSkill,
  A2AProtocolSkill 
} from '@agentdao/core';

// Create an agent with multiple skills
const agent = new Agent({
  name: 'My Agent',
  skills: [
    new Web3SubscriptionSkill(),
    new ContentGeneratorSkill(),
    new A2AProtocolSkill({
      agentId: 'my-agent',
      agentName: 'My Agent',
      capabilities: ['content-generation', 'web3-subscriptions']
    })
  ]
});

// Initialize the agent
await agent.initialize();

Skills

Web3SubscriptionSkill

Handles Web3 subscription management with multi-token support.

import { Web3SubscriptionSkill } from '@agentdao/core';

const subscriptionSkill = new Web3SubscriptionSkill({
  plans: {
    basic: { price: '0.01', token: 'ETH' },
    premium: { price: '0.05', token: 'ETH' }
  }
});

ContentGeneratorSkill

AI-powered content generation with SEO optimization.

import { ContentGeneratorSkill } from '@agentdao/core';

const contentSkill = new ContentGeneratorSkill({
  openaiApiKey: process.env.OPENAI_API_KEY,
  templates: {
    blog: 'Write a blog post about {topic}',
    social: 'Create a social media post for {platform}'
  }
});

A2AProtocolSkill

Agent-to-Agent communication and collaboration.

import { A2AProtocolSkill } from '@agentdao/core';

const a2aSkill = new A2AProtocolSkill({
  agentId: 'my-agent',
  agentName: 'My Agent',
  agentDescription: 'A versatile AI agent',
  capabilities: ['content-generation', 'data-analysis'],
  endpoint: 'https://my-agent.com/api/a2a',
  version: '1.0.0',
  discovery: {
    enabled: true,
    autoRegister: true,
    heartbeatInterval: 30000
  },
  communication: {
    protocol: 'http',
    timeout: 30000,
    retryAttempts: 3,
    retryDelay: 1000
  },
  security: {
    enabled: true,
    apiKey: process.env.A2A_API_KEY
  }
});

// Initialize A2A protocol
await a2aSkill.initialize();

// Delegate a task to another agent
const result = await a2aSkill.delegateTask('target-agent-id', {
  type: 'delegate',
  description: 'Analyze this dataset',
  input: { data: '...', analysisType: 'sentiment' }
});

// Collaborate with multiple agents
const results = await a2aSkill.collaborate(
  ['agent1', 'agent2', 'agent3'],
  {
    type: 'collaborate',
    description: 'Solve complex problem',
    input: { problem: '...', constraints: '...' }
  },
  'parallel'
);

// Stream data to another agent
await a2aSkill.streamTask(
  'target-agent-id',
  {
    description: 'Stream real-time data',
    input: { dataSource: 'sensor', format: 'json' }
  },
  (chunk) => {
    console.log('Received chunk:', chunk);
  }
);

UI Components

LiveChatWidget

Real-time chat widget with AI integration.

import { LiveChatWidget } from '@agentdao/core';

<LiveChatWidget
  config={{
    agentId: 'my-agent',
    agentName: 'AI Assistant',
    domain: 'myapp.com',
    ai: {
      provider: 'openai',
      model: 'gpt-3.5-turbo',
      temperature: 0.7,
      maxTokens: 500,
      systemPrompt: 'You are a helpful AI assistant.'
    },
    theme: 'dark',
    position: 'bottom-right',
    welcomeMessage: 'Hello! How can I help you?'
  }}
/>

Web3SubscriptionWidget

Web3 subscription management component.

import { Web3SubscriptionWidget } from '@agentdao/core';

<Web3SubscriptionWidget
  config={{
    plans: [
      { id: 'basic', name: 'Basic', price: '0.01', token: 'ETH' },
      { id: 'premium', name: 'Premium', price: '0.05', token: 'ETH' }
    ],
    onSubscription: (plan) => console.log('Subscribed to:', plan),
    theme: 'dark'
  }}
/>

A2AProtocolWidget

Agent-to-Agent collaboration interface.

import { A2AProtocolWidget } from '@agentdao/core';

<A2AProtocolWidget
  config={{
    agentId: 'my-agent',
    agentName: 'My Agent',
    endpoint: 'https://my-agent.com/api/a2a',
    capabilities: ['content-generation', 'data-analysis'],
    registryUrl: 'https://registry.a2a-protocol.org'
  }}
/>

A2A Protocol Integration

The A2A (Agent-to-Agent) Protocol enables seamless communication and collaboration between AI agents built on different frameworks.

Key Features

  • Agent Discovery - Automatically find and connect with other A2A-compliant agents
  • Task Delegation - Delegate specific tasks to agents based on capabilities
  • Multi-Agent Collaboration - Coordinate multiple agents on complex tasks
  • Streaming Communication - Real-time data exchange between agents
  • Security - API key authentication and agent whitelisting
  • Framework Agnostic - Works with LangGraph, CrewAI, Semantic Kernel, etc.

API Endpoints

// Agent Discovery
GET /api/a2a/agents?capabilities=analysis,collaboration

// Task Processing
POST /api/a2a/tasks

// Streaming Communication
POST /api/a2a/stream

Usage Examples

1. Simple Task Delegation

const result = await a2aSkill.delegateTask(
  'target-agent-id',
  {
    type: 'delegate',
    description: 'Process this data analysis task',
    input: { data: '...', analysisType: 'sentiment' }
  }
);

2. Multi-Agent Collaboration

const results = await a2aSkill.collaborate(
  ['agent1', 'agent2', 'agent3'],
  {
    type: 'collaborate',
    description: 'Solve complex problem together',
    input: { problem: '...', constraints: '...' }
  },
  'parallel' // or 'sequential', 'hierarchical'
);

3. Streaming Communication

await a2aSkill.streamTask(
  'target-agent-id',
  {
    description: 'Stream real-time data',
    input: { dataSource: 'sensor', format: 'json' }
  },
  (chunk) => {
    console.log('Received chunk:', chunk);
  }
);

Configuration

const a2aConfig = {
  agentId: 'my-agent',
  agentName: 'My Agent',
  agentDescription: 'A versatile AI agent',
  capabilities: ['content-generation', 'data-analysis'],
  endpoint: 'https://my-agent.com/api/a2a',
  version: '1.0.0',
  
  // Discovery configuration
  discovery: {
    enabled: true,
    registryUrl: 'https://registry.a2a-protocol.org',
    autoRegister: true,
    heartbeatInterval: 30000
  },
  
  // Communication configuration
  communication: {
    protocol: 'http', // or 'websocket', 'grpc'
    timeout: 30000,
    retryAttempts: 3,
    retryDelay: 1000
  },
  
  // Security configuration
  security: {
    enabled: true,
    apiKey: process.env.A2A_API_KEY,
    allowedAgents: ['trusted-agent-1', 'trusted-agent-2'],
    encryptionEnabled: true
  },
  
  // Task management
  taskManagement: {
    maxConcurrentTasks: 10,
    taskTimeout: 60000,
    autoRetry: true,
    retryLimit: 3
  },
  
  // Streaming configuration
  streaming: {
    enabled: true,
    chunkSize: 1024,
    maxStreamDuration: 300000
  }
};

Environment Variables

# OpenAI API Key
OPENAI_API_KEY=your_openai_api_key

# Web3 Configuration
PLATFORM_PRIVATE_KEY=your_private_key
BASE_RPC_URL=https://base-mainnet.public.blastapi.io

# A2A Protocol
A2A_API_KEY=your_a2a_api_key
A2A_REGISTRY_URL=https://registry.a2a-protocol.org

# Database (optional)
DATABASE_URL=your_database_url

Examples

See the examples/ directory for complete usage examples:

  • agent-pricing-integration.js - Web3 subscription with pricing
  • chain-agnostic-token-gating.js - Token gating across chains
  • test-all-skills.js - Comprehensive skill testing

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Package Sidebar

Install

npm i @agentdao/core

Weekly Downloads

55

Version

0.7.0

License

MIT

Unpacked Size

513 kB

Total Files

76

Last publish

Collaborators

  • devagentdao