php-agentic/Mcp/Tools/Agent/Content/ContentBatchGenerate.php
Snider ad83825f93 refactor: rename namespace Core\Agentic to Core\Mod\Agentic
Updates all classes to use the new modular namespace convention.
Adds Service/ layer with Core\Service\Agentic for service definition.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 16:12:58 +00:00

85 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
namespace Core\Mod\Agentic\Mcp\Tools\Agent\Content;
use Mod\Content\Jobs\GenerateContentJob;
use Mod\Content\Models\ContentBrief;
use Core\Mod\Agentic\Mcp\Tools\Agent\AgentTool;
/**
* Queue multiple briefs for batch content generation.
*
* Processes briefs that are ready (queued status with past or no scheduled time).
*/
class ContentBatchGenerate extends AgentTool
{
protected string $category = 'content';
protected array $scopes = ['write'];
public function name(): string
{
return 'content_batch_generate';
}
public function description(): string
{
return 'Queue multiple briefs for batch content generation';
}
public function inputSchema(): array
{
return [
'type' => 'object',
'properties' => [
'limit' => [
'type' => 'integer',
'description' => 'Maximum briefs to process (default: 5)',
],
'mode' => [
'type' => 'string',
'description' => 'Generation mode',
'enum' => ['draft', 'refine', 'full'],
],
],
];
}
public function handle(array $args, array $context = []): array
{
try {
$limit = $this->optionalInt($args, 'limit', 5, 1, 50);
$mode = $this->optionalEnum($args, 'mode', ['draft', 'refine', 'full'], 'full');
} catch (\InvalidArgumentException $e) {
return $this->error($e->getMessage());
}
$query = ContentBrief::readyToProcess();
// Scope to workspace if provided
if (! empty($context['workspace_id'])) {
$query->where('workspace_id', $context['workspace_id']);
}
$briefs = $query->limit($limit)->get();
if ($briefs->isEmpty()) {
return $this->success([
'message' => 'No briefs ready for processing',
'queued' => 0,
]);
}
foreach ($briefs as $brief) {
GenerateContentJob::dispatch($brief, $mode);
}
return $this->success([
'queued' => $briefs->count(),
'mode' => $mode,
'brief_ids' => $briefs->pluck('id')->all(),
]);
}
}