Watch
1
0
Fork
You've already forked arc
0
forked from hesabix/arc
arc/hesabixAPI/app/services/ai/ai_function_extensions_phase6.py
Babak Alizadeh 36b5aa9185 Add remaining tenant-bound MCP tools so authorized members can match UI workflows.
Pin the business from the credential, omit extra_info, and require confirmation on destructive writes while leaving binaries and connector secrets out of band.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-29 13:59:43 +03:30

57 lines
2.1 KiB
Python

"""
فاز ۶ AI — کاتالوگ گزارش‌ها و list_available_reports.
"""
from __future__ import annotations
from typing import Any, Dict, TYPE_CHECKING
from app.services.ai.function_registry import AIRole, AIFunction
if TYPE_CHECKING:
from app.services.ai.function_registry import AIFunctionRegistry
def register_phase6_business_functions(registry: "AIFunctionRegistry") -> None:
def list_available_reports_handler(args: Dict[str, Any], context: Dict[str, Any]) -> Any:
from app.services.ai.ai_reports_service import list_available_reports
ctx = context["user_context"]
business_id = int(args.get("business_id") or context.get("business_id"))
return list_available_reports(
ctx,
business_id=business_id,
category=args.get("category"),
db=context.get("db"),
)
registry.register(
AIFunction(
name="list_available_reports",
description=(
"لیست گزارش‌هایی که کاربر مجاز به دریافت آن‌هاست؛ گزارش افزونه فقط با افزونهٔ فعال می‌آید. "
"category اختیاری: financial, sales, warehouse, accounting, integration, system. "
"سپس از get_report با report_type استفاده کنید."
),
parameters_schema={
"type": "object",
"properties": {
"category": {
"type": "string",
"enum": [
"financial",
"sales",
"warehouse",
"accounting",
"integration",
"system",
],
},
},
},
handler=list_available_reports_handler,
allowed_roles={AIRole.USER, AIRole.BUSINESS_OWNER, AIRole.OPERATOR, AIRole.ADMIN},
required_permissions=["reports.read"],
category="reports",
is_readonly=True,
)
)