gproxy_protocol/transform/generate/gemini_responses/stream/mod.rs
1//! Direct, bounded Gemini GenerateContent ↔ Responses incremental conversion.
2//! Native source/target collectors validate lifecycle and final canonical parity.
3//!
4//! Constructors accept an explicit target policy before allocating any IDs.
5//! Gemini response IDs may arrive late: the already emitted Responses ID stays
6//! fixed while its actual source association is attached. A Responses header
7//! requires an observed or explicit actual model and factual creation time;
8//! the client request's routing alias is never used as a model observation.
9//!
10//! Gemini parts become distinct Responses items, including repeated text and
11//! same-name functions. Text, thinking and actual complete function arguments
12//! are emitted immediately. Item status and required usage are finalized only
13//! after native termination and EOF. Gemini usage must be observed at or after
14//! the last content; earlier thinking/candidate components remain lower bounds
15//! until current totals/components or an explicit final thinking fact resolve
16//! the final split. Missing counters are not fabricated as zero.
17//!
18//! Responses message parts retain source order because Gemini has no indexed
19//! text deltas. Later parts/items wait boundedly for earlier content to close;
20//! a complete function argument object may be emitted before output_item.done.
21//! Declared reasoning content takes precedence over summaries. Otherwise summary
22//! deltas stream immediately; once a visible summary is emitted, that item's
23//! representation stays summary-only even if raw content arrives later.
24//! Final canonical comparison uses that selected view and coalesces only adjacent plain
25//! text fragments with the same thought flag; signatures/media/functions stay
26//! exact. Unsigned empty reasoning is omitted like the buffered pair.
27//!
28//! A Responses upstream's reasoning ciphertext cannot become a Gemini
29//! signature, so reasoning replays as unsigned thought text. This pure
30//! converter itself performs no state writes or upstream calls.
31//!
32//! Every failed push poisons the stream. Input/output events and bytes, pending
33//! payloads, items, parts and tools are bounded. Provider errors, premature EOF,
34//! unsupported execution/media and conflicting factual metadata cannot produce
35//! a successful target terminal. Annotations/logprobs/usage retain actual final
36//! native facts rather than replaying previously emitted text.
37
38mod common;
39mod context;
40mod gemini_parts;
41mod gemini_to_responses;
42mod identity;
43mod response_events;
44mod response_items;
45mod response_projection;
46mod responses_to_gemini;
47mod usage;
48pub use common::{StreamEnd, StreamLimits};
49pub use context::{GeminiToResponsesContext, ResponsesToGeminiContext};
50pub use gemini_to_responses::GeminiToResponsesStream;
51pub use responses_to_gemini::ResponsesToGeminiStream;