feat(ui/core): срез 6.1 end-to-end — агент показывает смету панелью (show_estimate)
MCP-tool show_estimate пишет _estimate_panel.json → _stream_and_save эмитит событие estimate + сохраняет role='estimate' (восстановление из истории) + удаляет файл (не в кнопки, не повторно). Панель рендерит числа из данных (JS не считает). role='estimate' исключён из контекста LLM (как files). allowedTools + браузер-verified (рендер + restore). APP_VERSION 2026-07-17n.
This commit is contained in:
@@ -374,6 +374,22 @@ def tool_precheck_estimate(*, filename: str) -> dict:
|
||||
return {"error": f"Ошибка pre-check: {type(e).__name__}: {e}"}
|
||||
|
||||
|
||||
def tool_show_estimate(*, estimate: dict) -> dict:
|
||||
"""Показать смету пользователю красивой таблицей-панелью (не текстом).
|
||||
estimate: {title?, positions:[{code,name,unit,qty,unit_cost,total,unresolved?}],
|
||||
totals:{grand_pz,grand_nr,grand_sp,grand_total,vat,total_with_vat}, ok?, warnings?, missing?}.
|
||||
Числа — из расчёта, панель их только отображает."""
|
||||
import json as _json
|
||||
user, tab = _user_tab()
|
||||
work_dir = _work_dir(user, tab)
|
||||
try:
|
||||
(work_dir / "_estimate_panel.json").write_text(
|
||||
_json.dumps(estimate, ensure_ascii=False), encoding="utf-8")
|
||||
return {"shown": True, "positions": len(estimate.get("positions") or [])}
|
||||
except Exception as e:
|
||||
return {"error": f"Не удалось показать смету: {type(e).__name__}: {e}"}
|
||||
|
||||
|
||||
def tool_export_estimate_gge(*, filename: str, estimate: dict) -> dict:
|
||||
"""Экспортировать структурированную смету в .gge XML (формат экспертизы).
|
||||
estimate: {code, name, positions:[{name,code,quantity,unit,price_total_cur,direct}], totals:{}}.
|
||||
@@ -723,6 +739,24 @@ TOOLS: dict[str, dict] = {
|
||||
"required": ["filename"],
|
||||
},
|
||||
},
|
||||
"show_estimate": {
|
||||
"fn": tool_show_estimate,
|
||||
"description": (
|
||||
"Показать рассчитанную смету пользователю КРАСИВОЙ ТАБЛИЦЕЙ-панелью "
|
||||
"(вместо простыни текста). Вызывай ПОСЛЕ того как посчитал смету, чтобы "
|
||||
"человек увидел позиции и итоги наглядно. estimate: {title, positions:"
|
||||
"[{code,name,unit,qty,unit_cost,total,unresolved}], totals:{grand_pz,"
|
||||
"grand_nr,grand_sp,grand_total,vat,total_with_vat}, ok, warnings, missing}. "
|
||||
"Числа — из расчёта; нерассчитанные позиции помечай unresolved=true."
|
||||
),
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"estimate": {"type": "object", "description": "Структура сметы (позиции + итоги)"},
|
||||
},
|
||||
"required": ["estimate"],
|
||||
},
|
||||
},
|
||||
"export_estimate_gge": {
|
||||
"fn": tool_export_estimate_gge,
|
||||
"description": (
|
||||
|
||||
Reference in New Issue
Block a user