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>
75 lines
1.8 KiB
PHP
75 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Core\Mod\Agentic\Mcp\Tools\Agent\State;
|
|
|
|
use Core\Mod\Agentic\Models\AgentPlan;
|
|
use Core\Mod\Agentic\Mcp\Tools\Agent\AgentTool;
|
|
|
|
/**
|
|
* Get a workspace state value.
|
|
*/
|
|
class StateGet extends AgentTool
|
|
{
|
|
protected string $category = 'state';
|
|
|
|
protected array $scopes = ['read'];
|
|
|
|
public function name(): string
|
|
{
|
|
return 'state_get';
|
|
}
|
|
|
|
public function description(): string
|
|
{
|
|
return 'Get a workspace state value';
|
|
}
|
|
|
|
public function inputSchema(): array
|
|
{
|
|
return [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'plan_slug' => [
|
|
'type' => 'string',
|
|
'description' => 'Plan slug identifier',
|
|
],
|
|
'key' => [
|
|
'type' => 'string',
|
|
'description' => 'State key',
|
|
],
|
|
],
|
|
'required' => ['plan_slug', 'key'],
|
|
];
|
|
}
|
|
|
|
public function handle(array $args, array $context = []): array
|
|
{
|
|
try {
|
|
$planSlug = $this->require($args, 'plan_slug');
|
|
$key = $this->require($args, 'key');
|
|
} catch (\InvalidArgumentException $e) {
|
|
return $this->error($e->getMessage());
|
|
}
|
|
|
|
$plan = AgentPlan::where('slug', $planSlug)->first();
|
|
|
|
if (! $plan) {
|
|
return $this->error("Plan not found: {$planSlug}");
|
|
}
|
|
|
|
$state = $plan->states()->where('key', $key)->first();
|
|
|
|
if (! $state) {
|
|
return $this->error("State not found: {$key}");
|
|
}
|
|
|
|
return [
|
|
'key' => $state->key,
|
|
'value' => $state->value,
|
|
'category' => $state->category,
|
|
'updated_at' => $state->updated_at->toIso8601String(),
|
|
];
|
|
}
|
|
}
|