comparison 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
comparison
equal deleted inserted replaced
259:667156fcd3e3 260:1f9877b637e9
1 #include "dowa/dowa.h"
2
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
6
7 static const char *Get_String(Dowa_JSON_Entry *object, const char *key)
8 {
9 char *value = Dowa_JSON_Get_String(object, key);
10 return value ? value : "";
11 }
12
13 int main(void)
14 {
15 printf(
16 "{\"type\":\"ready\",\"request_id\":null,"
17 "\"conversation_id\":null,\"status\":\"ok\"}\n");
18 fflush(stdout);
19
20 char *line = NULL;
21 size_t capacity = 0;
22 while (getline(&line, &capacity, stdin) >= 0)
23 {
24 Dowa_Arena *p_arena = Dowa_Arena_Create(64 * 1024);
25 Dowa_JSON_Value parsed = Dowa_JSON_Parse(
26 line, (int32)strlen(line), p_arena);
27 if (parsed.type != DOWA_JSON_OBJECT)
28 {
29 Dowa_Arena_Free(p_arena);
30 continue;
31 }
32 Dowa_JSON_Entry *object = parsed.object_val;
33 const char *command = Get_String(object, "command");
34 const char *request_id = Get_String(object, "request_id");
35 const char *conversation_id = Get_String(object, "conversation_id");
36 if (strcmp(command, "shutdown") == 0)
37 {
38 printf(
39 "{\"type\":\"turn.done\",\"request_id\":\"%s\","
40 "\"conversation_id\":\"\"}\n",
41 request_id);
42 fflush(stdout);
43 Dowa_Arena_Free(p_arena);
44 break;
45 }
46 if (strcmp(command, "turn.start") == 0)
47 {
48 printf(
49 "{\"type\":\"turn.accepted\",\"request_id\":\"%s\","
50 "\"conversation_id\":\"%s\"}\n",
51 request_id,
52 conversation_id);
53 printf(
54 "{\"type\":\"assistant.delta\",\"request_id\":\"%s\","
55 "\"conversation_id\":\"%s\","
56 "\"delta\":\"hello \\\"traveler\\\"\\\\path\"}\n",
57 request_id,
58 conversation_id);
59 printf(
60 "{\"type\":\"assistant.completed\",\"request_id\":\"%s\","
61 "\"conversation_id\":\"%s\","
62 "\"content\":\"hello traveler\"}\n",
63 request_id,
64 conversation_id);
65 printf(
66 "{\"type\":\"assistant.usage\",\"request_id\":\"%s\","
67 "\"conversation_id\":\"%s\","
68 "\"usage\":{\"input_tokens\":7,\"output_tokens\":3}}\n",
69 request_id,
70 conversation_id);
71 printf(
72 "{\"type\":\"turn.done\",\"request_id\":\"%s\","
73 "\"conversation_id\":\"%s\"}\n",
74 request_id,
75 conversation_id);
76 fflush(stdout);
77 }
78 Dowa_Arena_Free(p_arena);
79 }
80 free(line);
81 return 0;
82 }