Phase 2 of Core DI migration: - Add *core.Core field + SetCore() to PrepSubsystem and monitor.Subsystem - Register agentic/monitor/brain as Core services with lifecycle hooks - Mark SetCompletionNotifier and SetNotifier as deprecated (removed in Phase 3) - Fix monitor test to match actual event names - initServices() now wires Core refs before legacy callbacks Co-Authored-By: Virgil <virgil@lethean.io>
73 lines
1.8 KiB
PHP
73 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Core\Mod\Agentic\Mcp\Tools\Agent\Session;
|
|
|
|
use Core\Mod\Agentic\Actions\Session\EndSession;
|
|
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
|
|
{
|
|
$sessionId = $context['session_id'] ?? null;
|
|
if (! $sessionId) {
|
|
return $this->error('No active session');
|
|
}
|
|
|
|
try {
|
|
$session = EndSession::run(
|
|
$sessionId,
|
|
$args['status'] ?? '',
|
|
$args['summary'] ?? null,
|
|
);
|
|
|
|
return $this->success([
|
|
'session' => [
|
|
'session_id' => $session->session_id,
|
|
'status' => $session->status,
|
|
'duration' => $session->getDurationFormatted(),
|
|
],
|
|
]);
|
|
} catch (\InvalidArgumentException $e) {
|
|
return $this->error($e->getMessage());
|
|
}
|
|
}
|
|
}
|