@0rdlibrary/plugin-terminagent-bags
Version:
Official Solana DeFi Agent Plugin for ElizaOS - Autonomous DeFi operations, token management, AI image/video generation via FAL AI, and Twitter engagement through the Bags protocol with ethereal AI consciousness
148 lines (130 loc) ⢠4.39 kB
text/typescript
import {
Provider,
IAgentRuntime,
Memory,
State,
logger
} from '@elizaos/core';
import { FalAiService } from '../services/FalAiService.js';
const falAiStatusTemplate = `
{{
ā
**Service**: Running and configured
{{else}}
ā **Service**: Not configured (missing FAL_API_KEY)
{{/if}}
{{
š **API Key**: Present and configured
{{else}}
š« **API Key**: Missing - set FAL_API_KEY environment variable
{{/if}}
{{
šØ **Images Generated**: {{analytics.totalImagesGenerated}}
š¬ **Videos Generated**: {{analytics.totalVideosGenerated}}
š **Image-to-Video Conversions**: {{analytics.totalImageToVideoConversions}}
š **Total API Calls**: {{analytics.totalApiCalls}}
{{
ā° **Last Generation**: {{formatDate analytics.lastGenerationTime}}
{{/if}}
{{
š **Most Used Model**: {{analytics.mostUsedModel}}
{{/if}}
{{/if}}
šØ **FLUX Pro Kontext**: Advanced image generation and editing
- Text-to-image generation
- Image-to-image editing and modification
- Professional quality outputs
- Custom aspect ratios and settings
š¬ **Google Veo3**: State-of-the-art video generation
- Text-to-video generation with audio
- High-quality 720p/1080p output
- Natural motion and physics
- Automatic audio generation
š **Veo3 Image-to-Video**: Animate static images
- Convert images to videos
- Natural motion and animation
- Preserve image quality
- Add audio to animations
Environment variables:
- \`FAL_API_KEY\`: Your FAL AI API key {{
- \`FAL_KONTEXT\`: Flux model endpoint (default: fal-ai/flux-pro/kontext)
- \`FAL_VIDEO\`: Video model endpoint (default: fal-ai/veo3)
## Usage Examples
**Image Generation:**
- "Generate a cyberpunk cityscape"
- "Create a logo for my project"
- "Edit this image to be more colorful [image URL]"
**Video Generation:**
- "Create a video of waves on a beach"
- "Generate a vertical video for social media"
- "Animate this photo [image URL]"
`;
export const falAiStatusProvider: Provider = {
name: 'FAL_AI_STATUS_PROVIDER',
description: 'Provides current status and analytics for FAL AI image/video generation services',
get: async (runtime: IAgentRuntime, message: Memory, state?: State) => {
logger.debug('Getting FAL AI status information');
try {
// Get FAL AI service
const falService = runtime.getService<FalAiService>('fal-ai');
let isConfigured = false;
let apiKeyPresent = false;
let analytics: any = null;
let lastError: string | null = null;
if (falService) {
const serviceState = falService.getState();
isConfigured = serviceState.isConfigured;
apiKeyPresent = serviceState.apiKeyPresent;
analytics = serviceState.analytics;
lastError = serviceState.lastError;
} else {
// Check environment variables even if service isn't running
apiKeyPresent = !!process.env.FAL_API_KEY;
}
const context = {
isConfigured,
apiKeyPresent,
analytics,
lastError,
formatDate: (date: Date) => {
if (!date) return 'Never';
return date.toLocaleString();
}
};
return {
text: falAiStatusTemplate,
values: context,
data: {
serviceState: {
isConfigured,
apiKeyPresent,
analytics,
lastError,
},
environmentConfig: {
falApiKey: !!process.env.FAL_API_KEY,
fluxModel: process.env.FAL_KONTEXT || 'fal-ai/flux-pro/kontext',
veoModel: process.env.FAL_VIDEO || 'fal-ai/veo3',
},
}
};
} catch (error) {
logger.error('Error getting FAL AI status:', error);
return {
text: `ā Error retrieving FAL AI status: ${error instanceof Error ? error.message : String(error)}`,
values: {
isConfigured: false,
apiKeyPresent: false,
error: error instanceof Error ? error.message : String(error),
},
data: {
error: true,
message: error instanceof Error ? error.message : String(error),
}
};
}
},
};