Skip to main content

gproxy_protocol/wire/openai/responses/
steering.rs

1//! Native Responses WebSocket steering events. Acceptance is not continuation commit.
2use super::input;
3use crate::Rest;
4use serde::{Deserialize, Serialize};
5
6#[derive(
7    Debug,
8    Clone,
9    PartialEq,
10    Eq,
11    Serialize,
12    Deserialize,
13    gproxy_protocol_macros::WireBuilder,
14    gproxy_protocol_macros::DeclaredFields,
15)]
16#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
17#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
18pub struct SteerRequest {
19    pub previous_response_id: String,
20    pub input: SteerInput,
21    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
22    pub rest: Rest,
23}
24
25#[derive(
26    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::DeclaredFields,
27)]
28#[serde(untagged)]
29#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
30#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
31pub enum SteerInput {
32    Text(String),
33    Messages(Vec<SteerMessage>),
34}
35
36#[derive(
37    Debug,
38    Clone,
39    PartialEq,
40    Eq,
41    Serialize,
42    Deserialize,
43    gproxy_protocol_macros::WireBuilder,
44    gproxy_protocol_macros::DeclaredFields,
45)]
46#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
47#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
48pub struct SteerMessage {
49    pub role: SteerRole,
50    pub content: input::MessageContent,
51    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
52    pub type_: Option<input::MessageType>,
53    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
54    pub rest: Rest,
55}
56
57#[derive(
58    Debug,
59    Clone,
60    Copy,
61    PartialEq,
62    Eq,
63    Serialize,
64    Deserialize,
65    gproxy_protocol_macros::DeclaredFields,
66)]
67#[serde(rename_all = "snake_case")]
68#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
69#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
70pub enum SteerRole {
71    User,
72}
73
74#[derive(
75    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::DeclaredFields,
76)]
77#[serde(tag = "type")]
78#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
79#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
80pub enum SteeringEvent {
81    #[serde(rename = "response.steer.accepted")]
82    Accepted(SteerAccepted),
83    #[serde(rename = "response.steer.pending")]
84    Pending(SteerPending),
85    #[serde(rename = "response.steer.failed")]
86    Failed(SteerFailed),
87}
88
89#[derive(
90    Debug,
91    Clone,
92    PartialEq,
93    Eq,
94    Serialize,
95    Deserialize,
96    gproxy_protocol_macros::WireBuilder,
97    gproxy_protocol_macros::DeclaredFields,
98)]
99#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
100#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
101pub struct SteeringReference {
102    pub id: String,
103    pub previous_response_id: String,
104    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
105    pub rest: Rest,
106}
107
108#[derive(
109    Debug,
110    Clone,
111    PartialEq,
112    Eq,
113    Serialize,
114    Deserialize,
115    gproxy_protocol_macros::WireBuilder,
116    gproxy_protocol_macros::DeclaredFields,
117)]
118#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
119#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
120pub struct SteerAccepted {
121    pub sequence_number: i64,
122    pub steer: SteeringReference,
123    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
124    pub rest: Rest,
125}
126
127#[derive(
128    Debug,
129    Clone,
130    PartialEq,
131    Eq,
132    Serialize,
133    Deserialize,
134    gproxy_protocol_macros::WireBuilder,
135    gproxy_protocol_macros::DeclaredFields,
136)]
137#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
138#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
139pub struct SteerPending {
140    pub sequence_number: i64,
141    pub steer: SteeringReference,
142    pub reason: String,
143    pub required_input: Vec<RequiredSteeringInput>,
144    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
145    pub rest: Rest,
146}
147
148#[derive(
149    Debug,
150    Clone,
151    PartialEq,
152    Eq,
153    Serialize,
154    Deserialize,
155    gproxy_protocol_macros::WireBuilder,
156    gproxy_protocol_macros::DeclaredFields,
157)]
158#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
159#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
160pub struct SteerFailed {
161    pub sequence_number: i64,
162    pub steer: FailedSteeringSubmission,
163    pub error: SteerError,
164    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
165    pub rest: Rest,
166}
167
168#[derive(
169    Debug,
170    Clone,
171    PartialEq,
172    Eq,
173    Serialize,
174    Deserialize,
175    gproxy_protocol_macros::WireBuilder,
176    gproxy_protocol_macros::DeclaredFields,
177)]
178#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
179#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
180pub struct FailedSteeringSubmission {
181    pub previous_response_id: String,
182    pub input: SteerInput,
183    #[serde(skip_serializing_if = "Option::is_none")]
184    pub id: Option<String>,
185    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
186    pub rest: Rest,
187}
188
189#[derive(
190    Debug,
191    Clone,
192    PartialEq,
193    Eq,
194    Serialize,
195    Deserialize,
196    gproxy_protocol_macros::WireBuilder,
197    gproxy_protocol_macros::DeclaredFields,
198)]
199#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
200#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
201pub struct SteerError {
202    pub code: String,
203    pub message: String,
204    #[serde(rename = "type")]
205    pub type_: SteerErrorType,
206    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
207    pub rest: Rest,
208}
209
210#[derive(
211    Debug,
212    Clone,
213    Copy,
214    PartialEq,
215    Eq,
216    Serialize,
217    Deserialize,
218    gproxy_protocol_macros::DeclaredFields,
219)]
220#[serde(rename_all = "snake_case")]
221#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
222#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
223pub enum SteerErrorType {
224    InvalidRequestError,
225}
226
227#[derive(
228    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, gproxy_protocol_macros::DeclaredFields,
229)]
230#[serde(tag = "type", rename_all = "snake_case")]
231#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
232#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
233pub enum RequiredSteeringInput {
234    FunctionCallOutput {
235        call_id: String,
236        name: String,
237    },
238    CustomToolCallOutput {
239        call_id: String,
240    },
241    ComputerCallOutput {
242        call_id: String,
243    },
244    ShellCallOutput {
245        call_id: String,
246    },
247    ApplyPatchCallOutput {
248        call_id: String,
249    },
250    ToolSearchOutput {
251        call_id: String,
252        execution: SteeringToolSearchExecution,
253    },
254    McpApprovalResponse {
255        approval_request_id: String,
256    },
257}
258
259#[derive(
260    Debug,
261    Clone,
262    Copy,
263    PartialEq,
264    Eq,
265    Serialize,
266    Deserialize,
267    gproxy_protocol_macros::DeclaredFields,
268)]
269#[serde(rename_all = "snake_case")]
270#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
271#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
272pub enum SteeringToolSearchExecution {
273    Client,
274}