Models: - ab.ai.bot: service URL, webhook secret, privacy mode, ping/dispatch - ab.ai.directive: full directive lifecycle log with status tracking - ab.ai.log: activity log with level/agent/record linkage - ab.ai.agent.registry: agent list synced from agent service Controllers: - webhook.py: /ai/webhook/callback handles directive_completed, escalation, sweep_findings - health_proxy.py: /ai/health proxies agent service detailed health - approval.py: /ai/chat dispatch, /ai/approval/pending, /ai/approval/respond Security: - group_ai_user (chat) + group_ai_manager (configure, approve, logs) - ir.model.access.csv for all 4 models Views: list/form for bot, directives, logs, registry; main menu with AI brain icon OWL2 frontend: - systray_button.js: brain icon in top bar, status dot, pending approval badge - ai_panel.js: slide-in chat panel, approval workflow, 30s poll for pending items - CSS: slide-in animation, message bubbles, loading dots, approval section Data: 4 cron jobs (ping, registry sync, directive/log cleanup) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
import logging
|
|
import requests
|
|
|
|
from odoo import http
|
|
from odoo.http import request
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
class AiHealthProxyController(http.Controller):
|
|
|
|
@http.route('/ai/health', type='http', auth='user', methods=['GET'])
|
|
def ai_health(self):
|
|
bot = request.env['ab.ai.bot'].sudo().search([('active', '=', True)], limit=1)
|
|
if not bot:
|
|
return request.make_response(
|
|
'{"status":"no_bot_configured"}',
|
|
headers=[('Content-Type', 'application/json')],
|
|
status=503,
|
|
)
|
|
url = bot._get_service_url() + '/health/detailed'
|
|
try:
|
|
resp = requests.get(url, headers=bot._build_headers(), timeout=5)
|
|
return request.make_response(
|
|
resp.text,
|
|
headers=[('Content-Type', 'application/json')],
|
|
status=resp.status_code,
|
|
)
|
|
except Exception as exc:
|
|
_logger.warning('health proxy failed: %s', exc)
|
|
import json
|
|
body = json.dumps({'status': 'unreachable', 'error': str(exc)})
|
|
return request.make_response(
|
|
body,
|
|
headers=[('Content-Type', 'application/json')],
|
|
status=503,
|
|
)
|