@agentdao/core
Version:
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
641 lines (640 loc) • 15.3 kB
TypeScript
export interface AgentInput {
[key: string]: unknown;
}
export interface AgentOutput {
[key: string]: unknown;
}
export interface AgentError extends Error {
code?: string;
details?: unknown;
}
export interface AgentConfig {
name: string;
description?: string;
version?: string;
handler: (input: AgentInput) => Promise<AgentOutput>;
validateInput?: (input: AgentInput) => boolean;
validateOutput?: (output: AgentOutput) => boolean;
}
export interface AgentMetadata {
name: string;
description?: string;
version?: string;
createdAt: Date;
updatedAt: Date;
}
export type BillingPeriod = 'monthly' | 'quarterly' | 'annually';
export interface Web3SubscriptionConfig {
agentId: string;
agentName: string;
domain: string;
adaoToken: {
address: string;
decimals: number;
network: 'base';
logo?: string;
};
plans: {
[planId: string]: {
name: string;
description: string;
features: string[];
maxUsers?: number;
customFeatures?: any;
pricing: {
monthly: {
price: number;
discount: number;
};
quarterly: {
price: number;
discount: number;
};
annually: {
price: number;
discount: number;
};
};
billing: {
defaultPeriod: BillingPeriod;
allowPeriodChange: boolean;
prorationEnabled: boolean;
};
};
};
provider: {
rpcUrl: string;
chainId: number;
gasLimit?: number;
gasPrice?: string;
explorer: string;
};
payment: {
autoApprove: boolean;
requireConfirmation: boolean;
refundPolicy: {
enabled: boolean;
gracePeriod: number;
};
billing: {
allowTrial: boolean;
trialDays: number;
gracePeriodDays: number;
};
};
integration: {
webhookUrl?: string;
redirectUrl?: string;
successMessage?: string;
errorMessage?: string;
};
analytics: {
trackRevenue: boolean;
trackUsage: boolean;
exportData: boolean;
};
database?: {
endpoint: string;
apiKey?: string;
};
}
export interface Subscription {
id: string;
userAddress: string;
planId: string;
planName: string;
billingPeriod: BillingPeriod;
price: number;
monthlyPrice: number;
startDate: Date;
endDate: Date;
nextBillingDate: Date;
status: 'active' | 'expired' | 'cancelled' | 'trial';
features: string[];
discountApplied: number;
}
export interface SubscriptionStatus {
hasActiveSubscription: boolean;
planId?: string;
planName?: string;
billingPeriod?: BillingPeriod;
daysLeft?: number;
nextBillingDate?: Date;
features?: string[];
isTrial?: boolean;
trialDaysLeft?: number;
}
export interface PlanPricing {
planId: string;
planName: string;
monthly: {
price: number;
discount: number;
};
quarterly: {
price: number;
discount: number;
};
annually: {
price: number;
discount: number;
};
features: string[];
}
export interface Plan {
id: string;
name: string;
description: string;
pricing: PlanPricing;
features: string[];
maxUsers?: number;
}
export interface RevenueStats {
totalRevenue: number;
monthlyRevenue: number;
activeSubscriptions: number;
topPlans: Array<{
planId: string;
count: number;
revenue: number;
}>;
}
export interface ContentGeneratorConfig {
agentId: string;
agentName: string;
domain: string;
ai: {
provider: 'openai' | 'anthropic' | 'google' | 'cohere';
apiKey: string;
model: string;
temperature: number;
maxTokens: number;
retryAttempts: number;
};
templates: {
[templateId: string]: {
name: string;
type: 'blog' | 'social' | 'email' | 'ad' | 'product' | 'newsletter';
prompt: string;
maxLength: number;
format: 'text' | 'html' | 'markdown' | 'json';
variables: string[];
examples: string[];
};
};
brand: {
name: string;
voice: string;
tone: string;
keywords: string[];
styleGuide: string;
logo?: string;
colors?: string[];
};
seo: {
enabled: boolean;
keywords: string[];
metaDescriptionLength: number;
titleMaxLength: number;
autoOptimize: boolean;
};
categories: {
[categoryId: string]: {
name: string;
description: string;
keywords: string[];
templates: string[];
};
};
integration: {
autoSave: boolean;
saveLocation: 'database' | 'file' | 'api';
publishAutomatically: boolean;
reviewRequired: boolean;
};
}
export interface GeneratedContent {
id: string;
templateId: string;
content: string;
metadata: {
title?: string;
description?: string;
keywords?: string[];
seoScore?: number;
};
createdAt: Date;
status: 'draft' | 'published' | 'archived';
}
export interface BlogPost {
title: string;
content: string;
summary: string;
keywords: string[];
seoOptimized: boolean;
wordCount: number;
}
export interface SocialPost {
content: string;
platform: string;
hashtags: string[];
characterCount: number;
mediaAttachments?: string[];
}
export interface Email {
subject: string;
body: string;
recipient: string;
sender: string;
template: string;
}
export interface OptimizedContent {
original: string;
optimized: string;
seoScore: number;
suggestions: string[];
}
export interface MetaTags {
title: string;
description: string;
keywords: string[];
ogTitle?: string;
ogDescription?: string;
ogImage?: string;
}
export interface SocialMediaConfig {
agentId: string;
agentName: string;
domain: string;
platforms: {
twitter?: {
enabled: boolean;
apiKey: string;
apiSecret: string;
accessToken: string;
accessTokenSecret: string;
username: string;
autoReply: boolean;
};
linkedin?: {
enabled: boolean;
clientId: string;
clientSecret: string;
accessToken: string;
companyId?: string;
autoReply: boolean;
};
facebook?: {
enabled: boolean;
appId: string;
appSecret: string;
accessToken: string;
pageId?: string;
autoReply: boolean;
};
instagram?: {
enabled: boolean;
accessToken: string;
businessAccountId?: string;
autoReply: boolean;
};
};
strategy: {
postingSchedule: {
enabled: boolean;
timezone: string;
schedule: {
[day: string]: string[];
};
};
contentMix: {
promotional: number;
educational: number;
entertaining: number;
userGenerated: number;
};
hashtagStrategy: {
maxHashtags: number;
trendingHashtags: boolean;
brandedHashtags: string[];
};
};
engagement: {
autoRespond: boolean;
responseTemplates: {
[platform: string]: string[];
};
mentionMonitoring: {
enabled: boolean;
keywords: string[];
autoRespond: boolean;
};
};
analytics: {
trackPerformance: boolean;
reportFrequency: 'daily' | 'weekly' | 'monthly';
exportData: boolean;
goals: {
followers: number;
engagement: number;
reach: number;
};
};
database?: {
endpoint: string;
apiKey?: string;
};
}
export interface PostResult {
platform: string;
postId: string;
url: string;
success: boolean;
error?: string;
timestamp: Date;
}
export interface ScheduledPost {
id: string;
platform: string;
content: string;
scheduledTime: Date;
status: 'scheduled' | 'posted' | 'failed';
mediaAttachments?: string[];
}
export interface DraftPost {
id: string;
content: string;
platforms: string[];
createdAt: Date;
updatedAt: Date;
}
export interface PostAnalytics {
postId: string;
platform: string;
impressions: number;
engagement: number;
clicks: number;
shares: number;
comments: number;
likes: number;
}
export interface AccountAnalytics {
platform: string;
followers: number;
following: number;
posts: number;
engagementRate: number;
reach: number;
impressions: number;
}
export interface CommentResponse {
commentId: string;
response: string;
platform: string;
}
export interface Mention {
id: string;
platform: string;
username: string;
content: string;
timestamp: Date;
url: string;
}
export interface Media {
type: 'image' | 'video' | 'gif';
url: string;
altText?: string;
}
export interface HelpSupportConfig {
agentId: string;
agentName: string;
domain: string;
ai: {
provider: 'openai' | 'anthropic';
apiKey: string;
model: string;
temperature: number;
maxTokens: number;
};
knowledgeBase: {
type: 'url' | 'files' | 'database';
sources: string[];
autoUpdate: boolean;
};
autoResponse: boolean;
escalationThreshold: number;
humanSupport: {
enabled: boolean;
email: string;
phone: string;
responseTime: string;
};
database?: {
endpoint: string;
apiKey?: string;
};
}
export interface UserContext {
userId: string;
subscription?: string;
previousInteractions?: number;
userAgent?: string;
location?: string;
}
export interface SupportResponse {
response: string;
confidence: number;
sources?: string[];
suggestedActions?: string[];
escalateToHuman: boolean;
conversationId: string;
}
export interface ConversationSummary {
conversationId: string;
userId: string;
startTime: Date;
endTime: Date;
messageCount: number;
resolution: 'resolved' | 'escalated' | 'abandoned';
satisfaction?: number;
}
export interface KnowledgeResult {
id: string;
title: string;
content: string;
relevance: number;
source: string;
lastUpdated: Date;
}
export interface Ticket {
id: string;
userId: string;
issue: string;
priority: 'low' | 'medium' | 'high';
status: 'open' | 'in_progress' | 'resolved' | 'closed';
assignedTo?: string;
createdAt: Date;
updatedAt: Date;
notes: string[];
}
export type TicketStatus = 'open' | 'in_progress' | 'resolved' | 'closed';
export interface SupportAnalytics {
totalTickets: number;
averageResolutionTime: number;
satisfactionScore: number;
commonIssues: CommonIssue[];
responseTime: number;
}
export interface CommonIssue {
issue: string;
frequency: number;
averageResolutionTime: number;
category: string;
}
export interface LiveChatConfig {
agentId: string;
agentName: string;
domain: string;
ai: {
provider: 'openai' | 'anthropic';
apiKey: string;
model: string;
temperature: number;
};
chatHistory: {
storage: 'database' | 'redis' | 'memory';
retentionDays: number;
maxMessages: number;
};
features: {
typingIndicator: boolean;
readReceipts: boolean;
fileSharing: boolean;
voiceMessages: boolean;
emojiReactions: boolean;
};
moderation: {
enabled: boolean;
filters: string[];
autoBlock: boolean;
profanityFilter: boolean;
spamDetection: boolean;
};
storage?: {
endpoint: string;
apiKey?: string;
bucket?: string;
region?: string;
};
}
export interface ChatContext {
chatId: string;
userId: string;
userAgent: string;
location?: string;
subscription?: string;
}
export interface ChatMessage {
id: string;
chatId: string;
sender: string;
content: string;
messageType: 'text' | 'file' | 'voice' | 'image';
timestamp: Date;
read: boolean;
metadata?: {
fileUrl?: string;
fileSize?: number;
fileName?: string;
emojiReactions?: string[];
};
}
export interface ChatSummary {
chatId: string;
userId: string;
startTime: Date;
endTime: Date;
messageCount: number;
participants: string[];
duration: number;
}
export interface FileMessage {
id: string;
chatId: string;
fileName: string;
fileUrl: string;
fileSize: number;
fileType: string;
uploadedBy: string;
timestamp: Date;
}
export interface ModerationResult {
isAppropriate: boolean;
confidence: number;
flaggedWords?: string[];
reason?: string;
action: 'allow' | 'flag' | 'block';
}
export interface ChatAnalytics {
chatId: string;
totalMessages: number;
participants: number;
averageResponseTime: number;
duration: number;
satisfaction?: number;
}
export interface User {
id: string;
username: string;
avatar?: string;
online: boolean;
lastSeen: Date;
}
export interface AgentPricingConfig {
agent: {
id: number;
name: string;
description: string;
developer_name: string;
developer_avatar?: string;
};
pricing: {
is_available_for_hire: boolean;
platform_commission_rate: number;
payment_wallet_address?: string;
pricing_plans: Record<string, any>;
accepted_tokens: Record<string, any>;
usage_limits: Record<string, any>;
rate_limits: Record<string, any>;
};
integration: {
api_documentation?: string;
integration_guide?: string;
webhook_url?: string;
api_base_url?: string;
requires_api_key: boolean;
requires_webhook: boolean;
custom_headers: Record<string, any>;
};
features: {
features_enabled: string[];
tags: string[];
categories: string[];
supported_languages: string[];
};
}
export interface PricingPlan {
name: string;
description?: string;
price: number;
features?: string[];
requests_per_month?: number;
concurrent_requests?: number;
discount?: number;
}
export interface AcceptedToken {
address: string;
decimals: number;
symbol: string;
network?: string;
}