Sentinels is a cutting-edge, agent-based task execution framework for Laravel that combines power and flexibility with simplicity and ease of use. It empowers developers to create, manage, and execute single-purpose agents in a highly efficient pipeline architecture.
- Invokable Agents: Create powerful, single-purpose agents with a clean, invokable interface.
- Flexible Pipeline Architecture: Chain multiple agents together for complex task execution.
- Dynamic Agent Routing: Route tasks to specific agents based on custom conditions.
- Easy Integration: Seamlessly integrates with Laravel projects.
- Extensible Design: Easily extend and customize to fit your specific needs.
- Performance Optimized: Designed for efficient execution of complex task chains.
Install Sentinels via Composer:
composer require vampires/sentinels
Here's a simple example to get you started with Sentinels:
use Vampires\Sentinels\Agents\AgentManager;
use Vampires\Sentinels\Agents\BaseAgent;
// Define a simple agent
class UppercaseAgent extends BaseAgent
{
public function __invoke($input = null)
{
return strtoupper($input);
}
}
// Use the agent in a pipeline
$manager = new AgentManager();
$result = $manager
->addAgent(new UppercaseAgent())
->pipeline("hello world");
echo $result; // Outputs: HELLO WORLD
Agents are the building blocks of Sentinels. Create a new agent by extending the BaseAgent
class:
use Vampires\Sentinels\Agents\BaseAgent;
class MyCustomAgent extends BaseAgent
{
public function __invoke($input = null)
{
// Your agent logic here
return $input;
}
}
The AgentManager
allows you to create powerful pipelines by chaining multiple agents:
use Vampires\Sentinels\Agents\AgentManager;
$manager = new AgentManager();
$result = $manager
->addAgent(new DataFetchAgent())
->addAgent(new DataTransformAgent())
->addAgent(new DataValidationAgent())
->executeAll($initialData);
Use the AgentRouter
to dynamically route tasks to specific agents:
use Vampires\Sentinels\Agents\AgentRouter;
$router = new AgentRouter();
$router
->addRoute("email", new EmailAgent())
->addRoute("sms", new SmsAgent());
$agent = $router->route("email task");
$result = $agent("Send this email");
Sentinels comes with a comprehensive test suite. Run the tests with:
composer test
We welcome contributions! Please see CONTRIBUTING.md for details on how to contribute to Sentinels.
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
Sentinels is open-sourced software licensed under the MIT license.