php-agentic/Mcp/Tools/Agent/Plan/PlanGet.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

94 lines
2.9 KiB
PHP

<?php
declare(strict_types=1);
namespace Core\Mod\Agentic\Mcp\Tools\Agent\Plan;
use Core\Mod\Agentic\Models\AgentPlan;
use Core\Mod\Agentic\Mcp\Tools\Agent\AgentTool;
/**
* Get detailed information about a specific plan.
*/
class PlanGet extends AgentTool
{
protected string $category = 'plan';
protected array $scopes = ['read'];
public function name(): string
{
return 'plan_get';
}
public function description(): string
{
return 'Get detailed information about a specific plan';
}
public function inputSchema(): array
{
return [
'type' => 'object',
'properties' => [
'slug' => [
'type' => 'string',
'description' => 'Plan slug identifier',
],
'format' => [
'type' => 'string',
'description' => 'Output format: json or markdown',
'enum' => ['json', 'markdown'],
],
],
'required' => ['slug'],
];
}
public function handle(array $args, array $context = []): array
{
try {
$slug = $this->require($args, 'slug');
} catch (\InvalidArgumentException $e) {
return $this->error($e->getMessage());
}
$format = $this->optional($args, 'format', 'json');
// Use circuit breaker for Agentic module database calls
return $this->withCircuitBreaker('agentic', function () use ($slug, $format) {
$plan = AgentPlan::with('agentPhases')
->where('slug', $slug)
->first();
if (! $plan) {
return $this->error("Plan not found: {$slug}");
}
if ($format === 'markdown') {
return ['markdown' => $plan->toMarkdown()];
}
return [
'plan' => [
'slug' => $plan->slug,
'title' => $plan->title,
'description' => $plan->description,
'status' => $plan->status,
'context' => $plan->context,
'progress' => $plan->getProgress(),
'phases' => $plan->agentPhases->map(fn ($phase) => [
'order' => $phase->order,
'name' => $phase->name,
'description' => $phase->description,
'status' => $phase->status,
'tasks' => $phase->tasks,
'checkpoints' => $phase->checkpoints,
])->all(),
'created_at' => $plan->created_at->toIso8601String(),
'updated_at' => $plan->updated_at->toIso8601String(),
],
];
}, fn () => $this->error('Agentic service temporarily unavailable', 'service_unavailable'));
}
}