Skip to main content

Module google_gemini

Module google_gemini 

Source
Expand description

Google Gemini (Code Assist) runtime — broker-proxied only.

Experimental. See docs/specs/google-gemini-oauth-spec.md.

Modules§

runtime
Runtime dispatch for WireProtocol::GoogleGeminiCodeAssist.
setup
Google Gemini Code Assist project setup: bounded loadCodeAssist and onboardUser/operations polling via the broker proxy.
stream
Broker-proxied streaming call to Code Assist’s v1internal:streamGenerateContent. Composes:
translate
Translation between the runtime’s generic chat/tool shape and the Gemini Code Assist streamGenerateContent wire format (Vertex-style contents + function calls). Also decodes the SSE line format used by cloudcode-pa.googleapis.com when called with ?alt=sse.

Structs§

GeminiFunctionCall
IneligibleTier
LoadCodeAssistResponse
OnboardUserRequest
TierMetadata
ToolSpec
UserData

Enums§

ChatTurn
Minimal, generic input shape callers assemble before calling the translator. Kept intentionally small: text / tool-call / tool-response only. Media payloads are unsupported in this experimental slice.
GeminiPart
GeminiStreamEvent
A decoded, runtime-facing event from the Gemini stream. Text fragments and tool calls are surfaced separately so the runtime can route them without re-parsing the vendor shape.
SetupError
StreamError
Runtime-facing outcome of a single streamed model turn.

Constants§

MAX_INBOUND_LINE_BYTES
Maximum bytes we will buffer for a single SSE line before failing closed. Google’s Code Assist emits reasonably small JSON chunks; refusing anything bigger prevents a hostile upstream from ballooning memory.
ONBOARDING_MAX_ATTEMPTS
Bounded onboarding polling budget. The reference client polls every 5s indefinitely; we cap the total wait so tests and production never spin.
ONBOARDING_POLL_INTERVAL

Functions§

from_stream_line
Decode one inbound SSE data: line into runtime events. Empty/comment lines yield an empty vec; data: [DONE] yields Finish { reason: None }. Malformed JSON is surfaced as an Err so the caller can decide whether to terminate the stream (spec: fail closed on structurally invalid frames).
setup_user
Resolve the user’s Code Assist project id and tier through the broker.
setup_user_with_sleeper
Same as setup_user, but the caller injects a sleeper (test seam). The polling loop is bounded by ONBOARDING_MAX_ATTEMPTS regardless.
stream_gemini
Start a broker-proxied streaming turn against Code Assist and yield decoded events as they arrive. The returned stream is Send + 'static so it can be forwarded through the runtime’s event bus.
translate_generate_content_request
Translate a normalized conversation + tool set into a GeminiGenerateRequest ready for /v1internal:streamGenerateContent.
translate_tool_schemas
Translate tool schemas (Anthropic-shaped: {name, description, input_schema}) into Gemini ToolSpecs. Internal-only tool names are dropped.