Add Asterisk configuration and diagnostics support

- Updated .env.example to include Asterisk templates path.
- Modified docker-compose.yml to mount the templates directory.
- Enhanced backend Dockerfile to copy templates into the container.
- Introduced Asterisk diagnostics functionality in asterisk_profiles.py, allowing for baseline checks and diagnostics reporting.
- Integrated Asterisk diagnostics into the device diagnostics workflow in graph.py.
- Added formatting for Asterisk baseline drift reports in diagnostic_format.py.
- Updated SKILL.md to document new config baseline drift feature for Asterisk.

This commit enhances the system's capabilities for managing Asterisk configurations and diagnostics, improving overall troubleshooting processes.
This commit is contained in:
2026-06-15 07:49:10 +03:00
parent 0375b20bb4
commit 9fc35e86fe
13 changed files with 773 additions and 4 deletions

View File

@@ -273,8 +273,41 @@ def _qm_config_text_block(text: str) -> str:
return "\n".join(lines) if len(lines) > 2 else f"```\n{_clip(text, 8000)}\n```"
def _baseline_drift_table(payload: dict) -> str:
lines = [
f"**Profile:** `{payload.get('profile', '?')}` — {payload.get('summary', '')}",
"",
"| File | Check | Expected | Status |",
"|---|---|---|---|",
]
for file_entry in payload.get("files") or []:
path = file_entry.get("path") or "?"
if file_entry.get("missing"):
lines.append(f"| `{path}` | file | present | **MISSING** |")
continue
checks = file_entry.get("checks") or []
if not checks:
lines.append(f"| `{path}` | — | — | ok |")
continue
for i, check in enumerate(checks):
path_col = f"`{path}`" if i == 0 else ""
kind = check.get("kind") or "check"
expected = _cell(check.get("expected") or "")
status = "ok" if check.get("ok") else "**DRIFT**"
lines.append(f"| {path_col} | {kind} | {expected} | {status} |")
vars_used = payload.get("variables") or {}
if vars_used:
lines.append("")
lines.append("Variables: " + ", ".join(f"`{k}={v}`" for k, v in vars_used.items()))
return "\n".join(lines)
def format_tool_output_markdown(tool: str, output: str) -> str:
"""Turn raw MCP JSON/text into readable markdown when possible."""
if tool == "asterisk_config_baseline":
parsed = _parse_json_payload(output)
if isinstance(parsed, dict):
return _baseline_drift_table(parsed)
parsed = _parse_json_payload(output)
if tool == "proxmox_list_qemu":
if isinstance(parsed, (dict, list)):
@@ -325,7 +358,7 @@ def prepare_report_diagnostics(diagnostics: list[dict]) -> list[dict]:
formatted = ""
tool = d.get("tool")
if text:
if tool in _TABLE_TOOLS:
if tool in _TABLE_TOOLS or tool == "asterisk_config_baseline":
formatted = format_tool_output_markdown(tool, text)
elif tool == "ssh_run":
if re.search(r"^\s*\d+\s+\S+\s+(running|stopped)", text, re.MULTILINE):