feat: Generic CRM API tool - AI can control entire system

- Create call_crm_api tool: single tool that can call ANY CRM API endpoint
- Inject OpenAPI spec into system prompt so AI knows all available endpoints
- Always include call_crm_api in agent tools (not just via tool_ids)
- Extend get_current_user to support internal header-based auth (X-Internal-Call,
  X-Tenant-Id, X-User-Id) for AI tool API access
- No more manual tool-per-endpoint registration needed
This commit is contained in:
Agent Zero
2026-07-25 02:31:33 +02:00
parent 6a622665a2
commit e2cd435861
4 changed files with 245 additions and 3 deletions
+10 -1
View File
@@ -63,9 +63,18 @@ class AIAssistantPlugin(BasePlugin):
await seed_defaults(db)
async def on_activate(self, db, service_container, event_bus) -> None:
"""Activate plugin: register context tools and participant handler."""
"""Activate plugin: register CRM API tool and participant handler."""
await super().on_activate(db, service_container, event_bus)
# Register the generic CRM API tool — gives AI full system access
try:
from app.plugins.builtins.ai_assistant.crm_api_tool import register_crm_api_tool
from app.plugins.builtins.ai_assistant.tool_registry import get_tool_registry
register_crm_api_tool(get_tool_registry())
logger.info("CRM API tool registered — AI has full system access")
except Exception:
logger.exception("Failed to register CRM API tool")
# Register as participant in the kommunikation system
try:
from app.plugins.builtins.ai_assistant.participant_handler import (