Download codex-rs/protocol/src/request_user_input.rs from SaylorTwift/codex: direct link, hf CLI and curl.
- Browser
- Download file 3.52 kB
-
https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/protocol/src/request_user_input.rs
- Command line
-
hf download hf://SaylorTwift/codex/codex-rs/protocol/src/request_user_input.rs
-
curl -L -o request_user_input.rs https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/protocol/src/request_user_input.rs
3.52 kB
| use std::collections::HashMap; | |
| use schemars::JsonSchema; | |
| use serde::Deserialize; | |
| use serde::Serialize; | |
| use ts_rs::TS; | |
| pub struct RequestUserInputQuestionOption { | |
| pub label: String, | |
| pub description: String, | |
| } | |
| pub struct RequestUserInputQuestion { | |
| pub id: String, | |
| pub header: String, | |
| pub question: String, | |
| pub is_other: bool, | |
| pub is_secret: bool, | |
| pub options: Option<Vec<RequestUserInputQuestionOption>>, | |
| } | |
| pub struct RequestUserInputArgs { | |
| pub questions: Vec<RequestUserInputQuestion>, | |
| pub is_blocking: bool, | |
| /// @deprecated Use `isBlocking` to decide whether the request should block. | |
| pub auto_resolution_ms: Option<u64>, | |
| } | |
| pub struct RequestUserInputAnswer { | |
| pub answers: Vec<String>, | |
| } | |
| pub struct RequestUserInputResponse { | |
| pub answers: HashMap<String, RequestUserInputAnswer>, | |
| } | |
| pub struct RequestUserInputEvent { | |
| /// Responses API call id for the associated tool call, if available. | |
| pub call_id: String, | |
| /// Turn ID that this request belongs to. | |
| /// Uses `#[serde(default)]` for backwards compatibility. | |
| pub turn_id: String, | |
| pub questions: Vec<RequestUserInputQuestion>, | |
| pub is_blocking: bool, | |
| /// @deprecated Use `isBlocking` to decide whether the request should block. | |
| pub auto_resolution_ms: Option<u64>, | |
| } | |
| impl<'de> Deserialize<'de> for RequestUserInputEvent { | |
| fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> | |
| where | |
| D: serde::Deserializer<'de>, | |
| { | |
| struct WireRequestUserInputEvent { | |
| call_id: String, | |
| turn_id: String, | |
| questions: Vec<RequestUserInputQuestion>, | |
| is_blocking: Option<bool>, | |
| auto_resolution_ms: Option<u64>, | |
| } | |
| let wire = WireRequestUserInputEvent::deserialize(deserializer)?; | |
| Ok(Self { | |
| call_id: wire.call_id, | |
| turn_id: wire.turn_id, | |
| questions: wire.questions, | |
| is_blocking: wire.is_blocking.unwrap_or(true), | |
| auto_resolution_ms: wire.auto_resolution_ms, | |
| }) | |
| } | |
| } | |
| mod tests; | |