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
1.9 KiB
PHP
78 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Core\Mod\Agentic\Mcp\Tools\Agent\Session;
|
|
|
|
use Core\Mod\Agentic\Models\AgentSession;
|
|
use Core\Mod\Agentic\Mcp\Tools\Agent\AgentTool;
|
|
|
|
/**
|
|
* End the current session.
|
|
*/
|
|
class SessionEnd extends AgentTool
|
|
{
|
|
protected string $category = 'session';
|
|
|
|
protected array $scopes = ['write'];
|
|
|
|
public function name(): string
|
|
{
|
|
return 'session_end';
|
|
}
|
|
|
|
public function description(): string
|
|
{
|
|
return 'End the current session';
|
|
}
|
|
|
|
public function inputSchema(): array
|
|
{
|
|
return [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'status' => [
|
|
'type' => 'string',
|
|
'description' => 'Final session status',
|
|
'enum' => ['completed', 'handed_off', 'paused', 'failed'],
|
|
],
|
|
'summary' => [
|
|
'type' => 'string',
|
|
'description' => 'Final summary',
|
|
],
|
|
],
|
|
'required' => ['status'],
|
|
];
|
|
}
|
|
|
|
public function handle(array $args, array $context = []): array
|
|
{
|
|
try {
|
|
$status = $this->require($args, 'status');
|
|
} catch (\InvalidArgumentException $e) {
|
|
return $this->error($e->getMessage());
|
|
}
|
|
|
|
$sessionId = $context['session_id'] ?? null;
|
|
|
|
if (! $sessionId) {
|
|
return $this->error('No active session');
|
|
}
|
|
|
|
$session = AgentSession::where('session_id', $sessionId)->first();
|
|
|
|
if (! $session) {
|
|
return $this->error('Session not found');
|
|
}
|
|
|
|
$session->end($status, $this->optional($args, 'summary'));
|
|
|
|
return $this->success([
|
|
'session' => [
|
|
'session_id' => $session->session_id,
|
|
'status' => $session->status,
|
|
'duration' => $session->getDurationFormatted(),
|
|
],
|
|
]);
|
|
}
|
|
}
|