Short polling requests keep the sequential HTTP transport available for * graph/MCP requests. SQLite is persistence, never a streaming connection. */
| 678 | /* Short polling requests keep the sequential HTTP transport available for |
| 679 | * graph/MCP requests. SQLite is persistence, never a streaming connection. */ |
| 680 | static void handle_agent_events(cbm_http_conn_t *c, const cbm_http_req_t *req, bool post) { |
| 681 | cbm_ui_log_init(); |
| 682 | char *json = NULL; |
| 683 | int status = 200; |
| 684 | cbm_mutex_lock(&g_log_mutex); |
| 685 | sqlite3 *db = activity_db_locked(); |
| 686 | if (post) { |
| 687 | status = cbm_activity_ingest(db, req->body, &json); |
| 688 | } else { |
| 689 | char project[256] = {0}, cursor[32] = {0}, limit[16] = {0}; |
| 690 | cbm_http_query_param(req->query, "project", project, sizeof(project)); |
| 691 | cbm_http_query_param(req->query, "after", cursor, sizeof(cursor)); |
| 692 | cbm_http_query_param(req->query, "limit", limit, sizeof(limit)); |
| 693 | json = cbm_activity_agents(db, project, strtoll(cursor, NULL, 10), atoi(limit)); |
| 694 | if (!json) |
| 695 | status = 503; |
| 696 | } |
| 697 | cbm_mutex_unlock(&g_log_mutex); |
| 698 | cbm_http_replyf(c, status, g_cors_json, "%s", |
| 699 | json ? json |
| 700 | : status == 400 ? "{\"error\":\"invalid event batch\"}" |
| 701 | : "{\"error\":\"activity storage unavailable\"}"); |
| 702 | cbm_free(CBM_MEM_CLASS_OTHER, json); |
| 703 | } |
| 704 | |
| 705 | /* ── Frontend log file ────────────────────────────────────────── */ |
| 706 |
no test coverage detected