bluefly / ai_agent_crewai
Integrates CrewAI as an AI agent system with multi-agent orchestration and analytics
Requires
- php: >=8.1
- drupal/ai: ^1.2
- drupal/core: ^10.3 || ^11
- drupal/key: ^1.20
This package is auto-updated.
Last update: 2025-07-09 18:31:06 UTC
README
Integrates CrewAI as an AI agent system with multi-agent orchestration and analytics for Drupal.
Overview
The CrewAI Agent module provides a comprehensive integration of CrewAI's multi-agent framework into Drupal, enabling the creation and management of AI agent crews that can work together on complex tasks through role-based coordination.
Features
- Multi-Agent Orchestration: Create crews of specialized AI agents with distinct roles and goals
- Role-Based Agent System: Define agents with specific capabilities and responsibilities
- Task Delegation: Automatic distribution of tasks among crew members
- Python Bridge Integration: Seamless integration with CrewAI's Python library
- Workflow Builder: Visual interface for composing and managing agent crews
- ECA Integration: Event-Condition-Action workflow support for automated agent triggers
- Performance Monitoring: Track agent performance and task completion metrics
- Key Management: Secure API key storage and management
Requirements
- Drupal 10.3 or higher / Drupal 11
- PHP 8.1 or higher
- Python 3.8+ (for CrewAI bridge)
- Node.js 16+ (for async communication server)
- AI module (
drupal/ai
) ^1.2 - Key module (
drupal/key
) ^1.20
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.