bluefly / ai_agent_crewai
Drupal AI agent module for CrewAI multi-agent orchestration
0.1.0
2025-07-27 03:59 UTC
Requires
- php: >=8.1
- bluefly/llm: ^0.1
- drupal/advancedqueue: ^1.0
- drupal/ai: ^1.0
- drupal/ai_agents: ^1.1
- drupal/core: ^10.3 || ^11
- drupal/eck: ^2.0
- drupal/key: ^1.0
- drupal/memcache: ^2.0
- drupal/queue_ui: ^3.0
- drupal/redis: ^1.0
Requires (Dev)
- drupal/coder: ^8.3
- drupal/core-dev: ^10.3 || ^11
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.0
- squizlabs/php_codesniffer: ^3.7
Suggests
- drupal/queue_ui: Queue management interface for agent processing
- drupal/redis: High-performance Redis caching for agent orchestration
- drupal/token: Token replacement system for dynamic values
This package is auto-updated.
Last update: 2025-07-30 03:17:08 UTC
README
Drupal integration for CrewAI multi-agent AI framework. Create teams of AI agents that work together on complex tasks.
What Works
- Agent and crew configuration entities
- Basic Python bridge communication
- REST API endpoints for crew management
- ECA integration for workflow automation
- Task management system
- Agent performance tracking
Features
- Multi-agent crew coordination
- Role-based agent definitions
- Task delegation system
- Python bridge for CrewAI library
- ECA workflow integration
- Performance monitoring
- Secure key management
Requirements
- Drupal: 10.4+ or 11.0+
- PHP: 8.1+ (8.2+ recommended for Drupal 11)
- Python: 3.8+ (for CrewAI bridge)
- Node.js: 16+ (for async communication server)
- Core Dependencies:
- AI module (
drupal/ai
) ^1.2 - Key module (
drupal/key
) ^1.20 - Views module (
drupal/views
) for admin interfaces - REST module (
drupal/rest
) for API endpoints
- AI module (
Installation
Install via Composer:
composer require bluefly/ai_agent_crewai
Enable the module:
drush en ai_agent_crewai
Set up the Python environment:
cd web/modules/custom/ai_agent_crewai ./setup.sh
Start the Node.js bridge server:
node nodejs/server.js
Configuration
- Navigate to Configuration > AI > CrewAI Settings (
/admin/config/ai/crewai
) - Configure your API keys (OpenAI, Anthropic, etc.)
- Set up agent templates and default crews
- Configure task execution parameters
Usage
Creating a Crew Programmatically
$orchestrator = \Drupal::service('ai_agent_crewai.orchestrator');
// Define agents
$agents = [
[
'role' => 'researcher',
'goal' => 'Find accurate and relevant information',
'backstory' => 'Expert at analyzing data and finding insights'
],
[
'role' => 'writer',
'goal' => 'Create engaging and informative content',
'backstory' => 'Skilled content creator with attention to detail'
],
[
'role' => 'editor',
'goal' => 'Ensure quality and accuracy',
'backstory' => 'Meticulous editor with high standards'
]
];
// Define tasks
$tasks = [
'Research Drupal 11 features and improvements',
'Write a comprehensive blog post about the findings',
'Edit and polish the content for publication'
];
// Create and execute crew
$crew = $orchestrator->createCrew([
'agents' => $agents,
'tasks' => $tasks
]);
$result = $orchestrator->executeCrew($crew);
Using the Workflow Builder
- Navigate to Structure > CrewAI Workflows (
/admin/structure/crewai/workflows
) - Click "Add Workflow" to create a new agent crew
- Define agents with roles, goals, and backstories
- Create tasks and assign them to agents
- Save and execute the workflow
Drush Commands
# Execute a predefined crew
drush crewai:execute-crew content_creation
# List available crews
drush crewai:list-crews
# Monitor crew execution
drush crewai:monitor [crew-id]
ECA Integration
The module provides several ECA plugins for workflow automation:
Actions
- Orchestrate Crew: Execute a CrewAI crew
- Intelligent Crew Execution: Smart task routing with agent selection
- AI Content Enhancement: Enhance content using agent crews
- Dynamic Agent Discovery: Discover and utilize available agents
Events
- Agent Performance Threshold: Triggered when agent performance metrics cross thresholds
Conditions
- Agent Capability Match: Check if agents match required capabilities
API Endpoints
The module exposes REST endpoints for crew management:
GET /api/crewai/crews
- List all crewsPOST /api/crewai/crews
- Create a new crewGET /api/crewai/crews/{id}
- Get crew detailsPOST /api/crewai/crews/{id}/execute
- Execute a crewGET /api/crewai/crews/{id}/status
- Get execution status
Development
Running Tests
# PHP Unit tests
./vendor/bin/phpunit web/modules/custom/ai_agent_crewai
# Python tests
cd web/modules/custom/ai_agent_crewai
python -m pytest tests/
Debugging
Enable debug mode in settings:
$settings['ai_agent_crewai.debug'] = TRUE;
Check logs at:
- Drupal:
/admin/reports/dblog
- Python bridge:
python/logs/crewai_bridge.log
- Node.js server:
nodejs/logs/server.log
Troubleshooting
Common Issues
Python Bridge Connection Failed
- Ensure Python environment is activated
- Check
python/requirements.txt
dependencies - Verify Python path in module settings
Node.js Server Not Responding
- Check if port 3000 is available
- Review Node.js server logs
- Ensure all npm dependencies are installed
Agent Execution Timeouts
- Increase timeout in crew settings
- Check API rate limits
- Monitor agent performance metrics
Support
- Issue Queue: https://github.com/bluefly/ai_agent_crewai/issues
- Documentation: https://docs.bluefly.dev/ai-agent-crewai
- Packagist: https://packagist.org/packages/bluefly/ai_agent_crewai
License
This project is licensed under the GPL-2.0-or-later license.