gproxy_protocol/adapt/generate/state.rs
1//! What a conversion needs to know about where it runs. No generation identity
2//! is stored: a tool call ID is forwarded unchanged or aliased reversibly
3//! (`transform::identity::tool_alias`), and an upstream's signature travels to
4//! the client in its own protocol's field (`transform::generate::signature`),
5//! so a later turn recovers both from what the client sends back. The store
6//! and scope serve the Responses history a `previous_response_id` continues.
7
8use crate::{capability::StateStore, transform::identity::IdentityTarget};
9use std::{collections::BTreeMap, time::SystemTime};
10
11pub struct GenerationStateAccess<'a, S: StateStore> {
12 pub store: &'a S,
13 pub scope: &'a S::Scope,
14 pub target: IdentityTarget,
15 pub conversation_key: String,
16 pub expires_at: SystemTime,
17 pub now: SystemTime,
18}
19
20/// Identity/name facts for replaying tool calls and results, all taken from
21/// the client's history. Keys remain the exact client IDs.
22#[derive(Debug, Default)]
23pub struct GenerationToolReplay {
24 pub names: BTreeMap<String, String>,
25 pub kinds: BTreeMap<String, super::ToolCallKind>,
26 /// Native Chat forms of aliased calls replayed to a Chat upstream, keyed
27 /// by the client alias.
28 pub chat_forms: BTreeMap<String, ChatCallForm>,
29 /// The upstream ID each alias names.
30 pub original_call_ids: BTreeMap<String, String>,
31}
32
33mod chat_form;
34pub use chat_form::ChatCallForm;