diff --git a/files/custom/Espo/Modules/SmartAssistant/Controllers/SmartAssistant.php b/files/custom/Espo/Modules/SmartAssistant/Controllers/SmartAssistant.php index 65840c6..4071cfd 100644 --- a/files/custom/Espo/Modules/SmartAssistant/Controllers/SmartAssistant.php +++ b/files/custom/Espo/Modules/SmartAssistant/Controllers/SmartAssistant.php @@ -9,18 +9,22 @@ use Espo\Core\Exceptions\Forbidden; use Espo\Core\InjectableFactory; use Espo\Core\Acl; use Espo\Modules\SmartAssistant\Services\SmartAssistantService; +use Espo\Modules\SmartAssistant\Services\ActionExecutor; use Espo\Modules\SmartAssistant\Services\CaseMemoryService; use Espo\Modules\SmartAssistant\Services\DocumentAnalyzer; +use Espo\Entities\User; class SmartAssistant { private InjectableFactory $injectableFactory; private Acl $acl; + private User $user; - public function __construct(InjectableFactory $injectableFactory, Acl $acl) + public function __construct(InjectableFactory $injectableFactory, Acl $acl, User $user) { $this->injectableFactory = $injectableFactory; $this->acl = $acl; + $this->user = $user; } private function getService(): SmartAssistantService @@ -171,6 +175,24 @@ class SmartAssistant ]; } + public function postActionExecuteTool(Request $request, Response $response): array + { + $this->checkAccess(); + $data = $request->getParsedBody(); + + if (empty($data->tool)) { + throw new BadRequest('tool is required.'); + } + + $tool = $data->tool; + $params = (array) ($data->params ?? []); + $caseId = $data->caseId ?? null; + + $executor = $this->injectableFactory->create(ActionExecutor::class); + + return $executor->execute($tool, $params, $caseId, $this->user->getId()); + } + public function postActionReadDocument(Request $request, Response $response): array { $this->checkAccess(); diff --git a/files/custom/Espo/Modules/SmartAssistant/Resources/routes.json b/files/custom/Espo/Modules/SmartAssistant/Resources/routes.json index 126b561..3611edf 100644 --- a/files/custom/Espo/Modules/SmartAssistant/Resources/routes.json +++ b/files/custom/Espo/Modules/SmartAssistant/Resources/routes.json @@ -86,5 +86,13 @@ "controller": "SmartAssistant", "action": "saveMemory" } + }, + { + "route": "/SmartAssistant/action/executeTool", + "method": "post", + "params": { + "controller": "SmartAssistant", + "action": "executeTool" + } } ] diff --git a/manifest.json b/manifest.json index d137a18..9837202 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "module": "SmartAssistant", "description": "Unified AI Assistant for Legal CRM — floating chat with case memory, office alerts, and AI Gateway integration", "author": "klear", - "version": "2.6.0", + "version": "2.6.1", "acceptableVersions": [ ">=8.0.0" ],