diff mrjunejune/test/inference_bridge_fake_sidecar.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
children b401627fc49e
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mrjunejune/test/inference_bridge_fake_sidecar.c	Wed Aug 05 09:19:41 2026 -0700
@@ -0,0 +1,82 @@
+#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\":\"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;
+}