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>
78 lines
2.4 KiB
PHP
78 lines
2.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Core\Mod\Agentic\Mcp\Tools\Agent\Session;
|
|
|
|
use Core\Mod\Agentic\Services\AgentSessionService;
|
|
use Core\Mod\Agentic\Mcp\Tools\Agent\AgentTool;
|
|
|
|
/**
|
|
* Continue from a previous session (multi-agent handoff).
|
|
*/
|
|
class SessionContinue extends AgentTool
|
|
{
|
|
protected string $category = 'session';
|
|
|
|
protected array $scopes = ['write'];
|
|
|
|
public function name(): string
|
|
{
|
|
return 'session_continue';
|
|
}
|
|
|
|
public function description(): string
|
|
{
|
|
return 'Continue from a previous session (multi-agent handoff)';
|
|
}
|
|
|
|
public function inputSchema(): array
|
|
{
|
|
return [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'previous_session_id' => [
|
|
'type' => 'string',
|
|
'description' => 'Session ID to continue from',
|
|
],
|
|
'agent_type' => [
|
|
'type' => 'string',
|
|
'description' => 'New agent type taking over',
|
|
],
|
|
],
|
|
'required' => ['previous_session_id', 'agent_type'],
|
|
];
|
|
}
|
|
|
|
public function handle(array $args, array $context = []): array
|
|
{
|
|
try {
|
|
$previousSessionId = $this->require($args, 'previous_session_id');
|
|
$agentType = $this->require($args, 'agent_type');
|
|
} catch (\InvalidArgumentException $e) {
|
|
return $this->error($e->getMessage());
|
|
}
|
|
|
|
$sessionService = app(AgentSessionService::class);
|
|
$session = $sessionService->continueFrom($previousSessionId, $agentType);
|
|
|
|
if (! $session) {
|
|
return $this->error("Previous session not found: {$previousSessionId}");
|
|
}
|
|
|
|
$inheritedContext = $session->context_summary ?? [];
|
|
|
|
return $this->success([
|
|
'session' => [
|
|
'session_id' => $session->session_id,
|
|
'agent_type' => $session->agent_type,
|
|
'status' => $session->status,
|
|
'plan' => $session->plan?->slug,
|
|
],
|
|
'continued_from' => $inheritedContext['continued_from'] ?? null,
|
|
'previous_agent' => $inheritedContext['previous_agent'] ?? null,
|
|
'handoff_notes' => $inheritedContext['handoff_notes'] ?? null,
|
|
'inherited_context' => $inheritedContext['inherited_context'] ?? null,
|
|
]);
|
|
}
|
|
}
|