From f304ada4d3947965b0e90900d0719e8ade4266db Mon Sep 17 00:00:00 2001 From: Myron Blair Date: Wed, 17 Jun 2026 12:33:09 +0000 Subject: [PATCH] Fix chat URL routing and agent.php fact_type column error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - sendMessage() was fetching /api.php?action=chat which bypasses the /api/* rewrite rule; api.php parsed endpoint as "api.php" → 404. Fixed to /api/chat so the rewrite routes it correctly to chat.php. - agent.php HA entity map INSERT used non-existent fact_type column, causing PDOException on every agent heartbeat. Fixed to use the correct (category, fact_key, fact_value) columns. Co-Authored-By: Claude Sonnet 4.6 --- api/endpoints/agent.php | 2 +- public_html/assets/js/jarvis-app.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/endpoints/agent.php b/api/endpoints/agent.php index 288b8da..f7ee21b 100644 --- a/api/endpoints/agent.php +++ b/api/endpoints/agent.php @@ -184,7 +184,7 @@ switch ($agentAction) { ]; } JarvisDB::query( - 'INSERT INTO kb_facts (fact_key, fact_value, fact_type) VALUES ("ha/entity_map", ?, "json") + 'INSERT INTO kb_facts (category, fact_key, fact_value) VALUES ("ha_entities", "ha/entity_map", ?) ON DUPLICATE KEY UPDATE fact_value=VALUES(fact_value), updated_at=NOW()', [json_encode($entityMap)] ); diff --git a/public_html/assets/js/jarvis-app.js b/public_html/assets/js/jarvis-app.js index 78aeba1..04725a5 100644 --- a/public_html/assets/js/jarvis-app.js +++ b/public_html/assets/js/jarvis-app.js @@ -1180,7 +1180,7 @@ async function sendMessage() { const payload = {message:text, session_id:sessionId, stream:true}; if (selectedContext) { payload.context = selectedContext; clearContext(); } - const resp = await fetch('/api.php?action=chat', { + const resp = await fetch('/api/chat', { method: 'POST', headers: {'Content-Type':'application/json','X-Session-Token':sessionToken}, body: JSON.stringify(payload),