Extract business logic from MCP tool handlers into 15 Action classes (Plan 5, Session 5, Phase 3, Task 2) following the Brain pattern. MCP tools become thin wrappers calling Action::run(). Add framework-level REST controllers and routes as sensible defaults for consumers. Co-Authored-By: Virgil <virgil@lethean.io>
49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Core PHP Framework
|
|
*
|
|
* Licensed under the European Union Public Licence (EUPL) v1.2.
|
|
* See LICENSE file for details.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Core\Mod\Agentic\Actions\Session;
|
|
|
|
use Core\Actions\Action;
|
|
use Core\Mod\Agentic\Models\AgentSession;
|
|
|
|
/**
|
|
* Get detailed information about a specific session.
|
|
*
|
|
* Returns the session with plan context, scoped to workspace.
|
|
*
|
|
* Usage:
|
|
* $session = GetSession::run('ses_abc123', 1);
|
|
*/
|
|
class GetSession
|
|
{
|
|
use Action;
|
|
|
|
/**
|
|
* @throws \InvalidArgumentException
|
|
*/
|
|
public function handle(string $sessionId, int $workspaceId): AgentSession
|
|
{
|
|
if ($sessionId === '') {
|
|
throw new \InvalidArgumentException('session_id is required');
|
|
}
|
|
|
|
$session = AgentSession::with('plan')
|
|
->where('session_id', $sessionId)
|
|
->where('workspace_id', $workspaceId)
|
|
->first();
|
|
|
|
if (! $session) {
|
|
throw new \InvalidArgumentException("Session not found: {$sessionId}");
|
|
}
|
|
|
|
return $session;
|
|
}
|
|
}
|