Mercurial
view mrjunejune/test/inference_bridge_fake_sidecar.c @ 264:04fee26ecce0
add authenticated JRPG conversation platform
Add reusable auth/session storage, owned conversation recovery, guest quotas, admin workflows, URL-routed conversation UI, mobile frame support, and parallel browser acceptance.
Co-authored-by: Copilot <[email protected]>
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Fri, 07 Aug 2026 07:34:12 -0700 |
| parents | b401627fc49e |
| children | 056790c4fb0d |
line wrap: on
line source
#include "dowa/dowa.h" #include <stdio.h> #include <stdlib.h> #include <string.h> static const char *Get_String(Dowa_JSON_Entry *object, const char *key) { char *value = Dowa_JSON_Get_String(object, key); return value ? value : ""; } int main(void) { printf( "{\"type\":\"ready\",\"request_id\":null," "\"conversation_id\":null,\"status\":\"ok\"}\n"); fflush(stdout); char *line = NULL; size_t capacity = 0; while (getline(&line, &capacity, stdin) >= 0) { Dowa_Arena *p_arena = Dowa_Arena_Create(64 * 1024); Dowa_JSON_Value parsed = Dowa_JSON_Parse( line, (int32)strlen(line), p_arena); if (parsed.type != DOWA_JSON_OBJECT) { Dowa_Arena_Free(p_arena); continue; } Dowa_JSON_Entry *object = parsed.object_val; const char *command = Get_String(object, "command"); const char *request_id = Get_String(object, "request_id"); const char *conversation_id = Get_String(object, "conversation_id"); if (strcmp(command, "shutdown") == 0) { printf( "{\"type\":\"turn.done\",\"request_id\":\"%s\"," "\"conversation_id\":\"\"}\n", request_id); fflush(stdout); Dowa_Arena_Free(p_arena); break; } if (strcmp(command, "turn.start") == 0) { printf( "{\"type\":\"turn.accepted\",\"request_id\":\"%s\"," "\"conversation_id\":\"%s\"}\n", request_id, conversation_id); printf( "{\"type\":\"tool.started\",\"request_id\":\"%s\"," "\"conversation_id\":\"%s\"," "\"tool\":{\"name\":\"mock-search\"}}\n", request_id, conversation_id); printf( "{\"type\":\"assistant.delta\",\"request_id\":\"%s\"," "\"conversation_id\":\"%s\"," "\"delta\":\"hello \\\"traveler\\\"\\\\path\"}\n", request_id, conversation_id); printf( "{\"type\":\"assistant.completed\",\"request_id\":\"%s\"," "\"conversation_id\":\"%s\"," "\"content\":\"hello traveler\"}\n", request_id, conversation_id); printf( "{\"type\":\"assistant.usage\",\"request_id\":\"%s\"," "\"conversation_id\":\"%s\"," "\"usage\":{\"input_tokens\":7,\"output_tokens\":3}}\n", request_id, conversation_id); printf( "{\"type\":\"turn.done\",\"request_id\":\"%s\"," "\"conversation_id\":\"%s\"}\n", request_id, conversation_id); fflush(stdout); } Dowa_Arena_Free(p_arena); } free(line); return 0; }