MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / handle_agent_events

Function handle_agent_events

src/ui/http_server.c:680–703  ·  view source on GitHub ↗

Short polling requests keep the sequential HTTP transport available for * graph/MCP requests. SQLite is persistence, never a streaming connection. */

Source from the content-addressed store, hash-verified

678/* Short polling requests keep the sequential HTTP transport available for
679 * graph/MCP requests. SQLite is persistence, never a streaming connection. */
680static 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

Callers 1

dispatch_requestFunction · 0.85

Calls 9

cbm_ui_log_initFunction · 0.85
cbm_mutex_lockFunction · 0.85
activity_db_lockedFunction · 0.85
cbm_activity_ingestFunction · 0.85
cbm_http_query_paramFunction · 0.85
cbm_activity_agentsFunction · 0.85
cbm_mutex_unlockFunction · 0.85
cbm_http_replyfFunction · 0.85
cbm_freeFunction · 0.85

Tested by

no test coverage detected