view mrjunejune/inference_bridge.h @ 279:b3b547563ec7

Add Google connector service and agent wiki Implement the C/Seobeo Google Drive and Gmail connector with encrypted OAuth storage, Zenbu authentication, browser testing, AI tool discovery, chunked HTTP decoding, and Bazel coverage. Consolidate repository guidance into progressive wiki documentation and enforce arena-first allocation for new first-party C code. Co-authored-by: Copilot <[email protected]> Copilot-Session: 84c338fd-0939-4bb3-b7f3-1062eb213e5d
author MrJuneJune <me@mrjunejune.com>
date Mon, 17 Aug 2026 22:22:36 -0700
parents 056790c4fb0d
children 49e9e591c9bb
line wrap: on
line source

#ifndef MRJUNEJUNE_INFERENCE_BRIDGE_H
#define MRJUNEJUNE_INFERENCE_BRIDGE_H

#include "dowa/dowa.h"

typedef struct Inference_Bridge Inference_Bridge;

#define INFERENCE_BRIDGE_HISTORY_MAX 20

/* A single prior-turn entry for transcript rehydration. */
typedef struct {
  const char *role;    /* must be "user" or "assistant"; never NULL */
  const char *content; /* non-NULL; may be empty string             */
} Inference_Bridge_History_Message;

typedef enum {
  INFERENCE_PROMPT_PROFILE_PUBLIC_VISITOR = 0,
  INFERENCE_PROMPT_PROFILE_INVITED_FRIEND = 1,
  INFERENCE_PROMPT_PROFILE_JUNE_ADMIN = 2,
} Inference_Prompt_Profile;

typedef struct {
  const char *type;
  const char *request_id;
  const char *conversation_id;
  const char *delta;
  const char *content;
  const char *error_code;
  const char *error_message;
  const char *raw_json;
  size_t raw_json_length;
  int64 input_tokens;
  int64 output_tokens;
  boolean failed;
  boolean aborted;
} Inference_Event;

typedef void (*Inference_Event_Handler)(
    const Inference_Event *p_event,
    void *p_user_data);

Inference_Bridge *Inference_Bridge_Create(
    const char *sidecar_path,
    const char *copilot_cli_path,
    Inference_Event_Handler handler,
    void *p_user_data);

boolean Inference_Bridge_Start(Inference_Bridge *p_bridge);
boolean Inference_Bridge_Is_Ready(const Inference_Bridge *p_bridge);

/*
 * Start an inference turn.
 *
 * p_history / history_count: optional bounded history for transcript
 * rehydration.  Pass NULL / 0 if no prior context is available.
 * history_count must not exceed INFERENCE_BRIDGE_HISTORY_MAX (20).
 * Every entry must have role "user" or "assistant" and a non-NULL content.
 * Returns FALSE and writes nothing if any validation constraint is violated.
 */
boolean Inference_Bridge_Start_Turn(
    Inference_Bridge *p_bridge,
    const char *request_id,
    const char *conversation_id,
    const char *prompt,
    Inference_Prompt_Profile prompt_profile,
    uint32 prompt_version,
    uint32 knowledge_version,
    const Inference_Bridge_History_Message *p_history,
    uint32 history_count);

boolean Inference_Bridge_Abort_Turn(
    Inference_Bridge *p_bridge,
    const char *request_id,
    const char *conversation_id);

boolean Inference_Bridge_Delete_Conversation(
    Inference_Bridge *p_bridge,
    const char *request_id,
    const char *conversation_id);

void Inference_Bridge_Destroy(Inference_Bridge *p_bridge);

#endif