Mercurial
diff mrjunejune/main.c @ 260:1f9877b637e9
Add Copilot-powered cyberpunk JRPG chat
Integrate the production JRPG chat with Seobeo streaming, Deita persistence, and a Bazel-managed Copilot SDK and LiteLLM inference stack.
Co-authored-by: Copilot <[email protected]>
| author | MrJuneJune <mrjunejune@users.noreply.github.com> |
|---|---|
| date | Wed, 05 Aug 2026 09:19:41 -0700 |
| parents | 667156fcd3e3 |
| children | ee04e4e69fed |
line wrap: on
line diff
--- a/mrjunejune/main.c Wed Aug 05 09:19:41 2026 -0700 +++ b/mrjunejune/main.c Wed Aug 05 09:19:41 2026 -0700 @@ -3,6 +3,7 @@ #include "s3/s3_uploader.h" #include "deita/deita.h" #include "mrjunejune/latex_renderer.h" +#include "mrjunejune/conversation_api.h" #include <time.h> #include <sys/stat.h> #include <stdarg.h> @@ -191,8 +192,9 @@ void handle_sigint(int sig) { - printf("Failed\n"); + (void)sig; stop_server = 1; + Seobeo_Web_Server_Stop(); } void Seobeo_Render_Html( @@ -831,7 +833,6 @@ return resp; } -#if defined(MRJUNEJUNE_ENABLE_DEV_PAGES) Seobeo_Request_Entry *GetJrpg(Seobeo_Request_Entry *req, Dowa_Arena *arena) { Seobeo_Request_Entry *resp = NULL; @@ -840,7 +841,6 @@ Dowa_HashMap_Push_Arena(resp, "body", final_body, arena); return resp; } -#endif Seobeo_Request_Entry *GetNotesLogin(Seobeo_Request_Entry *req, Dowa_Arena *arena) { @@ -878,9 +878,7 @@ CREATE_REDIRECT_HANDLER(HlsPlayer, "/tools/hls_player") CREATE_REDIRECT_HANDLER(LatexEditor, "/tools/latex_editor") CREATE_REDIRECT_HANDLER(Talk, "/talk") -#if defined(MRJUNEJUNE_ENABLE_DEV_PAGES) CREATE_REDIRECT_HANDLER(Jrpg, "/jrpg") -#endif CREATE_REDIRECT_HANDLER(Editor, "/editor") // S3 Upload URL API @@ -1959,8 +1957,16 @@ int main(void) { + signal(SIGINT, handle_sigint); + signal(SIGTERM, handle_sigint); + // Load server config load_config("mrjunejune/.config"); + const char *database_override = getenv("MRJUNEJUNE_DB_PATH"); + if (database_override && database_override[0] != '\0') + { + snprintf(g_db_path, sizeof(g_db_path), "%s", database_override); + } // Load S3 credentials from .env FILE *env_file = fopen(".env", "r"); @@ -2011,6 +2017,21 @@ // Initialize database init_database(); + if (!Conversation_API_Init(g_db_path)) + Seobeo_Log(SEOBEO_ERROR, "[CONVERSATION] Store unavailable\n"); + const char *sidecar_path = getenv("MRJUNEJUNE_INFERENCE_SIDECAR_PATH"); + const char *copilot_cli_path = getenv("MRJUNEJUNE_COPILOT_CLI_PATH"); + if (sidecar_path && copilot_cli_path) + { + if (!Conversation_API_Enable_Inference(sidecar_path, copilot_cli_path)) + Seobeo_Log(SEOBEO_ERROR, "[INFERENCE] Sidecar unavailable\n"); + } + else + { + Seobeo_Log( + SEOBEO_WARNING, + "[INFERENCE] Runtime paths not configured; turns return 503\n"); + } g_media_worker_pool = Seobeo_Worker_Pool_Create(2, 16); if (!g_media_worker_pool) @@ -2021,6 +2042,7 @@ } Seobeo_Router_Init(); + Conversation_API_Register_Routes(); Seobeo_Router_Register("GET", "/", GetHomePage); Seobeo_Router_Register("GET", "/index.html", GetRedirectHomePage); @@ -2067,11 +2089,9 @@ Seobeo_Router_Register("GET", "/talk", GetTalk); Seobeo_Router_Register("GET", "/talk/index.html", GetRedirectTalk); -#if defined(MRJUNEJUNE_ENABLE_DEV_PAGES) - // -- Development pages --/ + // -- JRPG agent chat --/ Seobeo_Router_Register("GET", "/jrpg", GetJrpg); Seobeo_Router_Register("GET", "/jrpg/index.html", GetRedirectJrpg); -#endif // -- Notes --/ Seobeo_Router_Register("GET", "/notes", GetNotes); @@ -2091,4 +2111,5 @@ Seobeo_Web_Server_Start("mrjunejune/src", server_port, SEOBEO_MODE_EDGE, 4); Seobeo_Worker_Pool_Destroy(g_media_worker_pool); g_media_worker_pool = NULL; + Conversation_API_Destroy(); }