chore: auto-commit (4 archivos)

- data.h
- data_http.cpp
- main.cpp
- views.cpp

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-14 02:06:46 +02:00
parent 5c53cfcb68
commit 00ee6a93e3
4 changed files with 315 additions and 17 deletions
+31 -3
View File
@@ -612,12 +612,38 @@ bool load_claude_usage_http(const std::string& api_url, RegistryData& out,
const std::string sql_viol = "SELECT COUNT(*) FROM violations" + wf_viol;
out.claude.total_violations = extract_int(call_monitor_query(cli, sql_viol.c_str()));
}
// MCP / fn run / heredoc — herramientas registry-aware. Cubre las
// variantes vistas en produccion: mcp, mcp_fn_search, mcp_fn_run,
// fn_cli_run, fn_run_cli, heredoc, heredoc_py.
static const char* kRegistryAwareToolCond =
"(tool_used LIKE 'mcp%' OR tool_used LIKE 'heredoc%' "
"OR tool_used IN ('fn_cli_run','fn_run_cli'))";
{
const std::string wf_and = wf_calls.empty()
? std::string(" WHERE ") + kRegistryAwareToolCond
: std::string(wf_calls + " AND " + kRegistryAwareToolCond);
const std::string sql = "SELECT COUNT(*) FROM calls" + wf_and;
out.claude.total_mcp = extract_int(call_monitor_query(cli, sql.c_str()));
}
// % calls que llamaron a una funcion del registry (function_id no vacio).
{
const std::string wf_and = wf_calls.empty()
? std::string(" WHERE function_id != '' ")
: std::string(wf_calls + " AND function_id != '' ");
const std::string sql = "SELECT COUNT(*) FROM calls" + wf_and;
int reg_hits = extract_int(call_monitor_query(cli, sql.c_str()));
out.claude.registry_pct = (out.claude.total_calls > 0)
? 100.0 * static_cast<double>(reg_hits) / static_cast<double>(out.claude.total_calls)
: 0.0;
}
out.claude.total_copies = extract_int(call_monitor_query(cli, "SELECT COUNT(*) FROM copied_code"));
out.claude.total_versions = extract_int(call_monitor_query(cli, "SELECT COUNT(*) FROM function_versions"));
// Recent executions (calls table) ordenada por ts DESC
{
std::string sql = "SELECT id, ts, function_id, tool_used, duration_ms, success, error_class, session_id "
std::string sql = "SELECT id, ts, function_id, tool_used, duration_ms, success, error_class, session_id, "
"COALESCE(command_snippet,'') AS command_snippet, "
"COALESCE(error_snippet,'') AS error_snippet "
"FROM calls" + wf_calls + " ORDER BY ts DESC LIMIT 100";
json rx = call_monitor_query(cli, sql.c_str());
if (rx.is_object() && rx.contains("rows")) {
@@ -630,8 +656,10 @@ bool load_claude_usage_http(const std::string& api_url, RegistryData& out,
row.tool_used = extract_str(r, 3);
row.duration_ms = extract_row_int(r, 4);
row.success = extract_row_int(r, 5) != 0;
row.error_class = extract_str(r, 6);
row.session_id = extract_str(r, 7);
row.error_class = extract_str(r, 6);
row.session_id = extract_str(r, 7);
row.command_snippet = extract_str(r, 8);
row.error_snippet = extract_str(r, 9);
if (row.id > mx) mx = row.id;
out.claude.recent_executions.push_back(row);
}