comparison mrjunejune/inference_bridge.c @ 280:49e9e591c9bb

Add persistent dictation, prewarmed WebRTC speech input, Copilot SDK routing, animated conversation lifecycle controls, parking, and architecture coverage.
author MrJuneJune <me@mrjunejune.com>
date Tue, 18 Aug 2026 19:14:53 -0700
parents 056790c4fb0d
children
comparison
equal deleted inserted replaced
279:b3b547563ec7 280:49e9e591c9bb
196 return "public_visitor"; 196 return "public_visitor";
197 case INFERENCE_PROMPT_PROFILE_INVITED_FRIEND: 197 case INFERENCE_PROMPT_PROFILE_INVITED_FRIEND:
198 return "invited_friend"; 198 return "invited_friend";
199 case INFERENCE_PROMPT_PROFILE_JUNE_ADMIN: 199 case INFERENCE_PROMPT_PROFILE_JUNE_ADMIN:
200 return "june_admin"; 200 return "june_admin";
201 case INFERENCE_PROMPT_PROFILE_CANVAS_ORCHESTRATOR:
202 return "canvas_orchestrator";
201 } 203 }
202 return NULL; 204 return NULL;
203 } 205 }
204 206
205 static boolean Inference_Bridge_Command( 207 static boolean Inference_Bridge_Command(
208 const char *request_id, 210 const char *request_id,
209 const char *conversation_id, 211 const char *conversation_id,
210 const char *prompt, 212 const char *prompt,
211 const char *prompt_profile, 213 const char *prompt_profile,
212 uint32 prompt_version, 214 uint32 prompt_version,
213 uint32 knowledge_version) 215 uint32 knowledge_version,
216 boolean include_resume_existing,
217 boolean resume_existing)
214 { 218 {
215 if (!command || !request_id) 219 if (!command || !request_id)
216 return FALSE; 220 return FALSE;
217 size_t input_length = 221 size_t input_length =
218 strlen(command) + strlen(request_id) + 222 strlen(command) + strlen(request_id) +
267 escaped_prompt, 271 escaped_prompt,
268 escaped_profile, 272 escaped_profile,
269 prompt_version, 273 prompt_version,
270 knowledge_version); 274 knowledge_version);
271 } 275 }
276 else if (escaped_profile)
277 {
278 snprintf(
279 payload,
280 capacity,
281 "{\"command\":\"%s\",\"request_id\":\"%s\","
282 "\"conversation_id\":\"%s\","
283 "\"prompt_profile\":\"%s\",\"prompt_version\":%u,"
284 "\"knowledge_version\":%u%s}",
285 escaped_command,
286 escaped_request,
287 escaped_conversation,
288 escaped_profile,
289 prompt_version,
290 knowledge_version,
291 include_resume_existing
292 ? (resume_existing
293 ? ",\"resume_existing\":true"
294 : ",\"resume_existing\":false")
295 : "");
296 }
272 else 297 else
273 { 298 {
274 snprintf( 299 snprintf(
275 payload, 300 payload,
276 capacity, 301 capacity,
331 { 356 {
332 if (!p_bridge) 357 if (!p_bridge)
333 return; 358 return;
334 if (atomic_load(&p_bridge->running) && p_bridge->p_commands) 359 if (atomic_load(&p_bridge->running) && p_bridge->p_commands)
335 Inference_Bridge_Command( 360 Inference_Bridge_Command(
336 p_bridge, "shutdown", "server-shutdown", "", NULL, NULL, 0, 0); 361 p_bridge, "shutdown", "server-shutdown", "", NULL, NULL, 0, 0,
362 FALSE, FALSE);
337 if (p_bridge->p_commands) 363 if (p_bridge->p_commands)
338 { 364 {
339 fclose(p_bridge->p_commands); 365 fclose(p_bridge->p_commands);
340 p_bridge->p_commands = NULL; 366 p_bridge->p_commands = NULL;
341 } 367 }
640 boolean success = Inference_Bridge_Write(p_bridge, payload); 666 boolean success = Inference_Bridge_Write(p_bridge, payload);
641 Dowa_Arena_Free(p_arena); 667 Dowa_Arena_Free(p_arena);
642 return success; 668 return success;
643 } 669 }
644 670
671 boolean Inference_Bridge_Warm_Conversation(
672 Inference_Bridge *p_bridge,
673 const char *request_id,
674 const char *conversation_id,
675 Inference_Prompt_Profile prompt_profile,
676 uint32 prompt_version,
677 uint32 knowledge_version,
678 boolean resume_existing)
679 {
680 const char *profile = Inference_Bridge_Profile_Name(prompt_profile);
681 if (!p_bridge || !request_id || !request_id[0] ||
682 !conversation_id || !conversation_id[0] || !profile)
683 return FALSE;
684 return Inference_Bridge_Command(
685 p_bridge,
686 "conversation.warm",
687 request_id,
688 conversation_id,
689 NULL,
690 profile,
691 prompt_version,
692 knowledge_version,
693 TRUE,
694 resume_existing);
695 }
696
645 boolean Inference_Bridge_Abort_Turn( 697 boolean Inference_Bridge_Abort_Turn(
646 Inference_Bridge *p_bridge, 698 Inference_Bridge *p_bridge,
647 const char *request_id, 699 const char *request_id,
648 const char *conversation_id) 700 const char *conversation_id)
649 { 701 {
650 return Inference_Bridge_Command( 702 return Inference_Bridge_Command(
651 p_bridge, "turn.abort", request_id, conversation_id, NULL, NULL, 0, 0); 703 p_bridge, "turn.abort", request_id, conversation_id, NULL, NULL, 0, 0,
704 FALSE, FALSE);
652 } 705 }
653 706
654 boolean Inference_Bridge_Delete_Conversation( 707 boolean Inference_Bridge_Delete_Conversation(
655 Inference_Bridge *p_bridge, 708 Inference_Bridge *p_bridge,
656 const char *request_id, 709 const char *request_id,
662 request_id, 715 request_id,
663 conversation_id, 716 conversation_id,
664 NULL, 717 NULL,
665 NULL, 718 NULL,
666 0, 719 0,
667 0); 720 0,
721 FALSE,
722 FALSE);
668 } 723 }
669 724
670 void Inference_Bridge_Destroy(Inference_Bridge *p_bridge) 725 void Inference_Bridge_Destroy(Inference_Bridge *p_bridge)
671 { 726 {
672 if (!p_bridge) 727 if (!p_bridge)