0dc26f3b15
- Add create_call tool: records phone calls as Call entity (not Meeting) - Add AssistantRule entity: persistent behavioral rules the AI follows - Add save_rule tool: AI can save new rules when user requests them - Add systemInstructions to webhook: call vs meeting guidance, open question tracking - Add recentCalls to case context for AI awareness - Add AssistantRuleContextProvider: injects active rules per mode into context Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
42 lines
1012 B
PHP
42 lines
1012 B
PHP
<?php
|
|
|
|
namespace Espo\Modules\SmartAssistant\Services;
|
|
|
|
use Espo\ORM\EntityManager;
|
|
use Espo\Core\Utils\Log;
|
|
|
|
class AssistantRuleContextProvider
|
|
{
|
|
private EntityManager $entityManager;
|
|
private Log $log;
|
|
|
|
public function __construct(EntityManager $entityManager, Log $log)
|
|
{
|
|
$this->entityManager = $entityManager;
|
|
$this->log = $log;
|
|
}
|
|
|
|
public function getRulesForMode(string $mode): array
|
|
{
|
|
$entries = $this->entityManager->getRDBRepository('AssistantRule')
|
|
->where([
|
|
'isActive' => true,
|
|
'deleted' => false,
|
|
'scope' => ['global', $mode],
|
|
])
|
|
->order('createdAt', 'ASC')
|
|
->find();
|
|
|
|
$rules = [];
|
|
foreach ($entries as $entry) {
|
|
$rules[] = [
|
|
'name' => $entry->get('name'),
|
|
'rule' => $entry->get('rule'),
|
|
'scope' => $entry->get('scope'),
|
|
];
|
|
}
|
|
|
|
return $rules;
|
|
}
|
|
}
|