Package Exports
- @agentdao/core
- @agentdao/core/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@agentdao/core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@agentdao/core
Core functionality and skills for AgentDAO - Web3 subscriptions, content generation, social media, help support, and live chat.
Installation
npm install @agentdao/core
# or
yarn add @agentdao/core
# or
pnpm add @agentdao/coreCore Features
- Type-safe agent creation and execution
- Input and output validation
- Error handling with standardized error types
- Metadata tracking
- Extensible architecture
Skills Overview
This package includes powerful, composable skills that can be integrated into any application:
- Web3SubscriptionSkill - ADAO token-based subscription management on Base chain
- ContentGeneratorSkill - AI-powered content generation and optimization
- SocialMediaSkill - Multi-platform social media management and analytics
- HelpSupportSkill - AI customer support with knowledge base and ticket management
- LiveChatSkill - Real-time chat with moderation and file sharing
Web3SubscriptionSkill
Manage subscriptions using ADAO tokens on Base chain with flexible billing periods.
Web3SubscriptionSkill Setup
import { Web3SubscriptionSkill } from '@agentdao/core';Web3SubscriptionSkill Configuration
const subscriptionConfig = {
  agentId: 'my-agent-123',
  agentName: 'My Agent',
  domain: 'myagent.agentdao.com',
  
  // ADAO Token Configuration (Base chain)
  adaoToken: {
    address: '0x...', // ADAO contract address on Base
    decimals: 18,
    network: 'base',
    logo: 'https://example.com/adao-logo.png'
  },
  
  // Subscription Plans
  plans: {
    basic: {
      name: 'Basic Plan',
      description: 'Essential features',
      features: ['chat', 'basic_analytics'],
      pricing: {
        monthly: { adao: 100 },
        quarterly: { adao: 270 }, // 10% discount
        annually: { adao: 960 }   // 20% discount
      }
    },
    pro: {
      name: 'Pro Plan',
      description: 'Advanced features',
      features: ['chat', 'analytics', 'priority_support'],
      pricing: {
        monthly: { adao: 250 },
        quarterly: { adao: 675 },
        annually: { adao: 2400 }
      }
    }
  },
  
  // Provider Configuration
  provider: {
    rpcUrl: 'https://mainnet.base.org',
    chainId: 8453
  }
};Web3SubscriptionSkill Usage
const subscriptionSkill = new Web3SubscriptionSkill(subscriptionConfig);
// Create a subscription
const subscription = await subscriptionSkill.createSubscription(
  '0x1234...', // user address
  'pro',       // plan ID
  'monthly'    // billing period
);
// Check subscription status
const status = await subscriptionSkill.getSubscriptionStatus(
  '0x1234...'  // user address
);
// Get revenue analytics
const analytics = await subscriptionSkill.getRevenueAnalytics();Web3SubscriptionSkill Key Features
- ✅ ADAO token payments on Base chain
- ✅ Monthly, quarterly, and annual billing
- ✅ Automatic subscription management
- ✅ Revenue tracking and analytics
- ✅ Plan upgrades and downgrades
- ✅ Subscription cancellation
ContentGeneratorSkill
Generate AI-powered content for blogs, social media, emails, and more with SEO optimization.
ContentGeneratorSkill Setup
import { ContentGeneratorSkill } from '@agentdao/core';ContentGeneratorSkill Configuration
const contentConfig = {
  brand: {
    name: 'My Company',
    voice: 'professional',
    tone: 'friendly',
    keywords: ['technology', 'innovation', 'solutions']
  },
  
  ai: {
    provider: 'openai',
    model: 'gpt-4',
    apiKey: process.env.OPENAI_API_KEY,
    maxTokens: 2000,
    temperature: 0.7
  },
  
  seo: {
    keywords: ['seo', 'marketing', 'digital'],
    targetLength: 1500
  },
  
  integration: {
    autoSave: true,
    storage: 'database' // or 'file'
  },
  
  templates: {
    blog_post: {
      prompt: 'Write a blog post about {topic}',
      variables: ['topic'],
      maxLength: 2000
    },
    social_post: {
      prompt: 'Create a {platform} post about {topic}',
      variables: ['platform', 'topic'],
      maxLength: 280
    }
  }
};ContentGeneratorSkill Usage
const contentSkill = new ContentGeneratorSkill(contentConfig);
// Generate blog post
const blogPost = await contentSkill.generateBlogPost(
  'AI in Healthcare',
  ['artificial intelligence', 'healthcare', 'innovation']
);
// Generate social media post
const socialPost = await contentSkill.generateSocialPost(
  'twitter',
  'New product launch'
);
// Optimize content for SEO
const optimized = await contentSkill.optimizeForSEO(
  'Your content here...',
  ['keyword1', 'keyword2']
);
// Generate meta tags
const metaTags = await contentSkill.generateMetaTags(
  'Page Title',
  'Page description'
);ContentGeneratorSkill Key Features
- ✅ AI-powered content generation
- ✅ Multi-platform social media posts
- ✅ SEO optimization and scoring
- ✅ Content templates and variables
- ✅ Brand voice customization
- ✅ Meta tag generation
SocialMediaSkill
Manage social media presence across multiple platforms with scheduling and analytics.
SocialMediaSkill Setup
import { SocialMediaSkill } from '@agentdao/core';SocialMediaSkill Configuration
const socialConfig = {
  platforms: {
    twitter: {
      enabled: true,
      accessToken: process.env.TWITTER_ACCESS_TOKEN,
      username: '@mycompany'
    },
    linkedin: {
      enabled: true,
      accessToken: process.env.LINKEDIN_ACCESS_TOKEN,
      companyId: '123456'
    },
    facebook: {
      enabled: true,
      accessToken: process.env.FACEBOOK_ACCESS_TOKEN,
      pageId: '987654321'
    },
    instagram: {
      enabled: true,
      accessToken: process.env.INSTAGRAM_ACCESS_TOKEN,
      accountId: 'insta123'
    }
  },
  
  scheduling: {
    enabled: true,
    timezone: 'UTC',
    defaultTime: '09:00'
  },
  
  analytics: {
    enabled: true,
    trackEngagement: true,
    trackReach: true
  }
};SocialMediaSkill Usage
const socialSkill = new SocialMediaSkill(socialConfig);
// Post to all platforms
const results = await socialSkill.postToAll(
  'Exciting news! We just launched our new feature.',
  [{ type: 'image', url: 'https://example.com/image.jpg' }]
);
// Post to specific platform
const result = await socialSkill.postToPlatform(
  'twitter',
  'Check out our latest blog post!',
  []
);
// Schedule a post
const scheduled = await socialSkill.schedulePost(
  'twitter',
  'Scheduled post content',
  new Date('2024-01-15T10:00:00Z')
);
// Get analytics
const analytics = await socialSkill.getPostAnalytics('post_id_123');SocialMediaSkill Key Features
- ✅ Multi-platform posting (Twitter, LinkedIn, Facebook, Instagram)
- ✅ Post scheduling and drafts
- ✅ Analytics and engagement tracking
- ✅ Comment management
- ✅ Mention monitoring
- ✅ File/media uploads
HelpSupportSkill
Provide AI-powered customer support with knowledge base and ticket management.
HelpSupportSkill Setup
import { HelpSupportSkill } from '@agentdao/core';HelpSupportSkill Configuration
const supportConfig = {
  agentName: 'Customer Support Bot',
  
  ai: {
    provider: 'openai',
    model: 'gpt-4',
    apiKey: process.env.OPENAI_API_KEY,
    maxTokens: 1000,
    temperature: 0.7
  },
  
  escalationThreshold: 5, // messages before human escalation
  
  humanSupport: {
    enabled: true,
    email: 'support@company.com',
    phone: '+1-555-0123',
    responseTime: '2 hours'
  },
  
  knowledgeBase: {
    sources: [
      'https://docs.company.com',
      'https://help.company.com'
    ],
    autoUpdate: true
  }
};HelpSupportSkill Usage
const supportSkill = new HelpSupportSkill(supportConfig);
// Handle customer message
const response = await supportSkill.handleMessage(
  'How do I reset my password?',
  {
    userId: 'user123',
    subscription: 'pro',
    previousTickets: 2
  }
);
// Start conversation
const conversationId = await supportSkill.startConversation('user123');
// Search knowledge base
const results = await supportSkill.searchKnowledgeBase('password reset');
// Create support ticket
const ticket = await supportSkill.createTicket(
  'user123',
  'Payment processing error',
  'high'
);
// Get support analytics
const analytics = await supportSkill.getSupportAnalytics();HelpSupportSkill Key Features
- ✅ AI-powered responses with confidence scoring
- ✅ Automatic escalation to human support
- ✅ Knowledge base integration
- ✅ Support ticket management
- ✅ Conversation history tracking
- ✅ Analytics and common issue detection
LiveChatSkill
Real-time chat functionality with moderation, file sharing, and user management.
LiveChatSkill Setup
import { LiveChatSkill } from '@agentdao/core';LiveChatSkill Configuration
const chatConfig = {
  maxParticipants: 50,
  messageHistoryLimit: 100,
  
  moderation: {
    enabled: true,
    profanityFilter: true,
    spamDetection: true,
    autoBlock: false,
    filters: ['spam', 'inappropriate']
  },
  
  fileSharing: {
    enabled: true,
    maxFileSize: 10 * 1024 * 1024, // 10MB
    allowedTypes: ['image/*', 'application/pdf']
  },
  
  notifications: {
    enabled: true,
    sound: true,
    desktop: true
  }
};LiveChatSkill Usage
const chatSkill = new LiveChatSkill(chatConfig);
// Start a chat
const chatId = await chatSkill.startChat('user123', {
  userAgent: 'Mozilla/5.0...',
  referrer: 'https://example.com'
});
// Send a message
const message = await chatSkill.sendMessage(
  chatId,
  'Hello everyone!',
  'user123'
);
// Join/leave chat
await chatSkill.joinChat(chatId, 'user456');
await chatSkill.leaveChat(chatId, 'user456');
// Upload file
const fileMessage = await chatSkill.uploadFile(
  chatId,
  fileObject,
  'user123'
);
// Get online users
const onlineUsers = await chatSkill.getOnlineUsers(chatId);
// Moderate message
const moderation = await chatSkill.moderateMessage('inappropriate content');
// Get chat analytics
const analytics = await chatSkill.getChatAnalytics(chatId);LiveChatSkill Key Features
- ✅ Real-time messaging
- ✅ File upload and sharing
- ✅ Message moderation and filtering
- ✅ User presence tracking
- ✅ Chat analytics
- ✅ Multi-user conversations
Core Agent Usage
import { Agent } from '@agentdao/core';
// Create a new agent
const agent = new Agent({
  name: 'my-agent',
  description: 'A custom agent',
  version: '1.0.0',
  handler: async (input) => {
    // Process the input
    return { result: 'success' };
  },
});
// Execute the agent
try {
  const result = await agent.execute({ query: 'test' });
  console.log(result);
} catch (error) {
  console.error('Agent execution failed:', error);
}API Reference
Agent
The main class for creating and executing agents.
Constructor
new Agent(config: AgentConfig)Configuration
interface AgentConfig {
  name: string;
  handler: (input: AgentInput) => Promise<AgentOutput>;
  description?: string;
  version?: string;
  validateInput?: (input: AgentInput) => boolean;
  validateOutput?: (output: AgentOutput) => boolean;
}Methods
- execute(input: AgentInput): Promise<AgentOutput>
- getName(): string
- getDescription(): string | undefined
- getVersion(): string | undefined
- getMetadata(): AgentMetadata
Types
- AgentInput: The input type for agent execution
- AgentOutput: The output type for agent execution
- AgentError: Standardized error type
- AgentMetadata: Agent metadata including creation and update timestamps
Development
# Install dependencies
pnpm install
# Run tests
pnpm test
# Build the package
pnpm build
# Run linting
pnpm lint
# Format code
pnpm formatLicense
MIT
API Key Requirement
You must provide your AgentDAO API key to use the AgentBridgeClient and access the AgentDAO API.
Example Usage
import { AgentBridgeClient } from '@agentdao/core';
const client = new AgentBridgeClient(
  process.env.NEXT_PUBLIC_API_URL!,
  process.env.AGENTDAO_API_KEY // Your AgentDAO API key
);- Set NEXT_PUBLIC_API_URLandAGENTDAO_API_KEYin your environment variables or.envfile.
FundAgent
Autonomously creates Gnosis Safe wallets for projects or domains when funded with ADAO tokens. Useful for reward pools, DAOs, and agent-managed funds.
FundAgent Setup
import { FundAgent } from '@agentdao/core';
const fundAgent = new FundAgent({
  network: 'base',
  safeFactoryAddress: '0xSAFEFACTORY...',
  adaoTokenAddress: '0x1ef7Be0aBff7d1490e952eC1C7476443A66d6b72',
  minDeposit: 100,
  onWalletCreated: async (safeAddress, owner) => {
    // Notify user or update DB
  }
});FundAgent Usage
// Listen for deposits and create wallets
fundAgent.listenForDeposits();
// Or create directly
const safeAddress = await fundAgent.createSafeWallet('0xUserWallet...', 100);
// Get wallet status
const status = await fundAgent.getWalletStatus(safeAddress);
// Add a new owner
await fundAgent.addOwner(safeAddress, '0xNewOwner...');FundAgent Key Features
- ✅ Autonomous Safe wallet creation
- ✅ Multi-owner (multi-sig) support
- ✅ ADAO token funding and gating
- ✅ API for wallet status and management
- ✅ Integrates with other agents (e.g., GamificationAgent)