// This file is @generated by prost-build.
#![allow(clippy::trivially_copy_pass_by_ref)]

#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Empty {}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ThreadIdRequest {
    #[prost(string, tag = "1")]
    pub thread_id: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct CreateThreadRequest {
    #[prost(string, tag = "1")]
    pub thread_id: ::prost::alloc::string::String,
    #[prost(string, optional, tag = "2")]
    pub forked_from_id: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(message, optional, tag = "3")]
    pub source: ::core::option::Option<SessionSource>,
    #[prost(string, tag = "4")]
    pub base_instructions_json: ::prost::alloc::string::String,
    #[prost(string, repeated, tag = "5")]
    pub dynamic_tools_json: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    #[prost(enumeration = "ThreadEventPersistenceMode", tag = "6")]
    pub event_persistence_mode: i32,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ResumeThreadRequest {
    #[prost(string, tag = "1")]
    pub thread_id: ::prost::alloc::string::String,
    #[prost(string, optional, tag = "2")]
    pub rollout_path: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(string, repeated, tag = "3")]
    pub history_json: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    #[prost(bool, tag = "4")]
    pub has_history: bool,
    #[prost(bool, tag = "5")]
    pub include_archived: bool,
    #[prost(enumeration = "ThreadEventPersistenceMode", tag = "6")]
    pub event_persistence_mode: i32,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct AppendThreadItemsRequest {
    #[prost(string, tag = "1")]
    pub thread_id: ::prost::alloc::string::String,
    #[prost(string, repeated, tag = "2")]
    pub items_json: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct LoadThreadHistoryRequest {
    #[prost(string, tag = "1")]
    pub thread_id: ::prost::alloc::string::String,
    #[prost(bool, tag = "2")]
    pub include_archived: bool,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ReadThreadRequest {
    #[prost(string, tag = "1")]
    pub thread_id: ::prost::alloc::string::String,
    #[prost(bool, tag = "2")]
    pub include_archived: bool,
    #[prost(bool, tag = "3")]
    pub include_history: bool,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListThreadsRequest {
    #[prost(uint32, tag = "1")]
    pub page_size: u32,
    #[prost(string, optional, tag = "2")]
    pub cursor: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(enumeration = "ThreadSortKey", tag = "3")]
    pub sort_key: i32,
    #[prost(message, repeated, tag = "4")]
    pub allowed_sources: ::prost::alloc::vec::Vec<SessionSource>,
    #[prost(message, optional, tag = "5")]
    pub model_provider_filter: ::core::option::Option<ModelProviderFilter>,
    #[prost(bool, tag = "6")]
    pub archived: bool,
    #[prost(string, optional, tag = "7")]
    pub search_term: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(message, optional, tag = "8")]
    pub cwd_filter: ::core::option::Option<CwdFilter>,
    #[prost(bool, tag = "9")]
    pub use_state_db_only: bool,
    #[prost(enumeration = "SortDirection", tag = "10")]
    pub sort_direction: i32,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ModelProviderFilter {
    #[prost(string, repeated, tag = "1")]
    pub values: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct CwdFilter {
    #[prost(string, repeated, tag = "1")]
    pub values: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListThreadsResponse {
    #[prost(message, repeated, tag = "1")]
    pub threads: ::prost::alloc::vec::Vec<StoredThread>,
    #[prost(string, optional, tag = "2")]
    pub next_cursor: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StoredThreadResponse {
    #[prost(message, optional, tag = "1")]
    pub thread: ::core::option::Option<StoredThread>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct StoredThreadHistory {
    #[prost(string, tag = "1")]
    pub thread_id: ::prost::alloc::string::String,
    #[prost(string, repeated, tag = "2")]
    pub items_json: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct StoredThread {
    /// Mirrors Rust's StoredThread. Domain types that are not protobuf-native,
    /// such as ThreadId, DateTime<Utc>, and PathBuf, are represented as their
    /// stable scalar forms on the wire.
    #[prost(string, tag = "1")]
    pub thread_id: ::prost::alloc::string::String,
    #[prost(string, optional, tag = "2")]
    pub forked_from_id: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(string, tag = "3")]
    pub preview: ::prost::alloc::string::String,
    #[prost(string, optional, tag = "4")]
    pub name: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(string, tag = "5")]
    pub model_provider: ::prost::alloc::string::String,
    #[prost(string, optional, tag = "6")]
    pub model: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(int64, tag = "7")]
    pub created_at: i64,
    #[prost(int64, tag = "8")]
    pub updated_at: i64,
    #[prost(int64, optional, tag = "9")]
    pub archived_at: ::core::option::Option<i64>,
    #[prost(string, tag = "10")]
    pub cwd: ::prost::alloc::string::String,
    #[prost(string, tag = "11")]
    pub cli_version: ::prost::alloc::string::String,
    #[prost(message, optional, tag = "12")]
    pub source: ::core::option::Option<SessionSource>,
    #[prost(message, optional, tag = "13")]
    pub git_info: ::core::option::Option<GitInfo>,
    #[prost(string, optional, tag = "14")]
    pub agent_nickname: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(string, optional, tag = "15")]
    pub agent_role: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(string, optional, tag = "16")]
    pub agent_path: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(string, optional, tag = "17")]
    pub reasoning_effort: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(string, optional, tag = "18")]
    pub first_user_message: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(string, optional, tag = "19")]
    pub rollout_path: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(string, optional, tag = "20")]
    pub approval_mode_json: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(string, optional, tag = "21")]
    pub sandbox_policy_json: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(string, optional, tag = "22")]
    pub token_usage_json: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(message, optional, tag = "23")]
    pub history: ::core::option::Option<StoredThreadHistory>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SessionSource {
    #[prost(enumeration = "SessionSourceKind", tag = "1")]
    pub kind: i32,
    #[prost(string, optional, tag = "2")]
    pub custom: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(string, optional, tag = "3")]
    pub sub_agent_parent_thread_id: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(int32, optional, tag = "4")]
    pub sub_agent_depth: ::core::option::Option<i32>,
    #[prost(string, optional, tag = "5")]
    pub sub_agent_other: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(string, optional, tag = "6")]
    pub sub_agent_path: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(string, optional, tag = "7")]
    pub sub_agent_nickname: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(string, optional, tag = "8")]
    pub sub_agent_role: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GitInfo {
    #[prost(string, optional, tag = "1")]
    pub sha: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(string, optional, tag = "2")]
    pub branch: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(string, optional, tag = "3")]
    pub origin_url: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct UpdateThreadMetadataRequest {
    #[prost(string, tag = "1")]
    pub thread_id: ::prost::alloc::string::String,
    #[prost(message, optional, tag = "2")]
    pub patch: ::core::option::Option<ThreadMetadataPatch>,
    #[prost(bool, tag = "3")]
    pub include_archived: bool,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ThreadMetadataPatch {
    #[prost(string, optional, tag = "1")]
    pub name: ::core::option::Option<::prost::alloc::string::String>,
    #[prost(enumeration = "ThreadMemoryMode", optional, tag = "2")]
    pub memory_mode: ::core::option::Option<i32>,
    #[prost(message, optional, tag = "3")]
    pub git_info: ::core::option::Option<GitInfoPatch>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GitInfoPatch {
    #[prost(message, optional, tag = "1")]
    pub sha: ::core::option::Option<OptionalStringPatch>,
    #[prost(message, optional, tag = "2")]
    pub branch: ::core::option::Option<OptionalStringPatch>,
    #[prost(message, optional, tag = "3")]
    pub origin_url: ::core::option::Option<OptionalStringPatch>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct OptionalStringPatch {
    #[prost(enumeration = "OptionalStringPatchKind", tag = "1")]
    pub kind: i32,
    #[prost(string, optional, tag = "2")]
    pub value: ::core::option::Option<::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ArchiveThreadRequest {
    #[prost(string, tag = "1")]
    pub thread_id: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ThreadSortKey {
    CreatedAt = 0,
    UpdatedAt = 1,
}
impl ThreadSortKey {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::CreatedAt => "THREAD_SORT_KEY_CREATED_AT",
            Self::UpdatedAt => "THREAD_SORT_KEY_UPDATED_AT",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "THREAD_SORT_KEY_CREATED_AT" => Some(Self::CreatedAt),
            "THREAD_SORT_KEY_UPDATED_AT" => Some(Self::UpdatedAt),
            _ => None,
        }
    }
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SortDirection {
    Asc = 0,
    Desc = 1,
}
impl SortDirection {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Asc => "SORT_DIRECTION_ASC",
            Self::Desc => "SORT_DIRECTION_DESC",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "SORT_DIRECTION_ASC" => Some(Self::Asc),
            "SORT_DIRECTION_DESC" => Some(Self::Desc),
            _ => None,
        }
    }
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SessionSourceKind {
    Unknown = 0,
    Cli = 1,
    Vscode = 2,
    Exec = 3,
    AppServer = 4,
    Custom = 5,
    SubAgentReview = 6,
    SubAgentCompact = 7,
    SubAgentThreadSpawn = 8,
    SubAgentMemoryConsolidation = 9,
    SubAgentOther = 10,
}
impl SessionSourceKind {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Unknown => "SESSION_SOURCE_KIND_UNKNOWN",
            Self::Cli => "SESSION_SOURCE_KIND_CLI",
            Self::Vscode => "SESSION_SOURCE_KIND_VSCODE",
            Self::Exec => "SESSION_SOURCE_KIND_EXEC",
            Self::AppServer => "SESSION_SOURCE_KIND_APP_SERVER",
            Self::Custom => "SESSION_SOURCE_KIND_CUSTOM",
            Self::SubAgentReview => "SESSION_SOURCE_KIND_SUB_AGENT_REVIEW",
            Self::SubAgentCompact => "SESSION_SOURCE_KIND_SUB_AGENT_COMPACT",
            Self::SubAgentThreadSpawn => "SESSION_SOURCE_KIND_SUB_AGENT_THREAD_SPAWN",
            Self::SubAgentMemoryConsolidation => {
                "SESSION_SOURCE_KIND_SUB_AGENT_MEMORY_CONSOLIDATION"
            }
            Self::SubAgentOther => "SESSION_SOURCE_KIND_SUB_AGENT_OTHER",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "SESSION_SOURCE_KIND_UNKNOWN" => Some(Self::Unknown),
            "SESSION_SOURCE_KIND_CLI" => Some(Self::Cli),
            "SESSION_SOURCE_KIND_VSCODE" => Some(Self::Vscode),
            "SESSION_SOURCE_KIND_EXEC" => Some(Self::Exec),
            "SESSION_SOURCE_KIND_APP_SERVER" => Some(Self::AppServer),
            "SESSION_SOURCE_KIND_CUSTOM" => Some(Self::Custom),
            "SESSION_SOURCE_KIND_SUB_AGENT_REVIEW" => Some(Self::SubAgentReview),
            "SESSION_SOURCE_KIND_SUB_AGENT_COMPACT" => Some(Self::SubAgentCompact),
            "SESSION_SOURCE_KIND_SUB_AGENT_THREAD_SPAWN" => Some(Self::SubAgentThreadSpawn),
            "SESSION_SOURCE_KIND_SUB_AGENT_MEMORY_CONSOLIDATION" => {
                Some(Self::SubAgentMemoryConsolidation)
            }
            "SESSION_SOURCE_KIND_SUB_AGENT_OTHER" => Some(Self::SubAgentOther),
            _ => None,
        }
    }
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ThreadMemoryMode {
    Enabled = 0,
    Disabled = 1,
}
impl ThreadMemoryMode {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Enabled => "THREAD_MEMORY_MODE_ENABLED",
            Self::Disabled => "THREAD_MEMORY_MODE_DISABLED",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "THREAD_MEMORY_MODE_ENABLED" => Some(Self::Enabled),
            "THREAD_MEMORY_MODE_DISABLED" => Some(Self::Disabled),
            _ => None,
        }
    }
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum OptionalStringPatchKind {
    Unset = 0,
    Clear = 1,
    Set = 2,
}
impl OptionalStringPatchKind {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Unset => "OPTIONAL_STRING_PATCH_KIND_UNSET",
            Self::Clear => "OPTIONAL_STRING_PATCH_KIND_CLEAR",
            Self::Set => "OPTIONAL_STRING_PATCH_KIND_SET",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "OPTIONAL_STRING_PATCH_KIND_UNSET" => Some(Self::Unset),
            "OPTIONAL_STRING_PATCH_KIND_CLEAR" => Some(Self::Clear),
            "OPTIONAL_STRING_PATCH_KIND_SET" => Some(Self::Set),
            _ => None,
        }
    }
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ThreadEventPersistenceMode {
    Limited = 0,
    Extended = 1,
}
impl ThreadEventPersistenceMode {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Limited => "THREAD_EVENT_PERSISTENCE_MODE_LIMITED",
            Self::Extended => "THREAD_EVENT_PERSISTENCE_MODE_EXTENDED",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "THREAD_EVENT_PERSISTENCE_MODE_LIMITED" => Some(Self::Limited),
            "THREAD_EVENT_PERSISTENCE_MODE_EXTENDED" => Some(Self::Extended),
            _ => None,
        }
    }
}
/// Generated client implementations.
pub mod thread_store_client {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value
    )]
    use tonic::codegen::http::Uri;
    use tonic::codegen::*;
    #[derive(Debug, Clone)]
    pub struct ThreadStoreClient<T> {
        inner: tonic::client::Grpc<T>,
    }
    impl ThreadStoreClient<tonic::transport::Channel> {
        /// Attempt to create a new client by connecting to a given endpoint.
        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
        where
            D: TryInto<tonic::transport::Endpoint>,
            D::Error: Into<StdError>,
        {
            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
            Ok(Self::new(conn))
        }
    }
    impl<T> ThreadStoreClient<T>
    where
        T: tonic::client::GrpcService<tonic::body::Body>,
        T::Error: Into<StdError>,
        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
    {
        pub fn new(inner: T) -> Self {
            let inner = tonic::client::Grpc::new(inner);
            Self { inner }
        }
        pub fn with_origin(inner: T, origin: Uri) -> Self {
            let inner = tonic::client::Grpc::with_origin(inner, origin);
            Self { inner }
        }
        pub fn with_interceptor<F>(
            inner: T,
            interceptor: F,
        ) -> ThreadStoreClient<InterceptedService<T, F>>
        where
            F: tonic::service::Interceptor,
            T::ResponseBody: Default,
            T: tonic::codegen::Service<
                    http::Request<tonic::body::Body>,
                    Response = http::Response<
                        <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
                    >,
                >,
            <T as tonic::codegen::Service<http::Request<tonic::body::Body>>>::Error:
                Into<StdError> + std::marker::Send + std::marker::Sync,
        {
            ThreadStoreClient::new(InterceptedService::new(inner, interceptor))
        }
        /// Compress requests with the given encoding.
        ///
        /// This requires the server to support it otherwise it might respond with an
        /// error.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.send_compressed(encoding);
            self
        }
        /// Enable decompressing responses.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.accept_compressed(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_decoding_message_size(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_encoding_message_size(limit);
            self
        }
        pub async fn create_thread(
            &mut self,
            request: impl tonic::IntoRequest<super::CreateThreadRequest>,
        ) -> std::result::Result<tonic::Response<super::Empty>, tonic::Status> {
            self.inner.ready().await.map_err(|e| {
                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
            })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/codex.thread_store.v1.ThreadStore/CreateThread",
            );
            let mut req = request.into_request();
            req.extensions_mut().insert(GrpcMethod::new(
                "codex.thread_store.v1.ThreadStore",
                "CreateThread",
            ));
            self.inner.unary(req, path, codec).await
        }
        pub async fn resume_thread(
            &mut self,
            request: impl tonic::IntoRequest<super::ResumeThreadRequest>,
        ) -> std::result::Result<tonic::Response<super::Empty>, tonic::Status> {
            self.inner.ready().await.map_err(|e| {
                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
            })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/codex.thread_store.v1.ThreadStore/ResumeThread",
            );
            let mut req = request.into_request();
            req.extensions_mut().insert(GrpcMethod::new(
                "codex.thread_store.v1.ThreadStore",
                "ResumeThread",
            ));
            self.inner.unary(req, path, codec).await
        }
        pub async fn append_items(
            &mut self,
            request: impl tonic::IntoRequest<super::AppendThreadItemsRequest>,
        ) -> std::result::Result<tonic::Response<super::Empty>, tonic::Status> {
            self.inner.ready().await.map_err(|e| {
                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
            })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/codex.thread_store.v1.ThreadStore/AppendItems",
            );
            let mut req = request.into_request();
            req.extensions_mut().insert(GrpcMethod::new(
                "codex.thread_store.v1.ThreadStore",
                "AppendItems",
            ));
            self.inner.unary(req, path, codec).await
        }
        pub async fn persist_thread(
            &mut self,
            request: impl tonic::IntoRequest<super::ThreadIdRequest>,
        ) -> std::result::Result<tonic::Response<super::Empty>, tonic::Status> {
            self.inner.ready().await.map_err(|e| {
                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
            })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/codex.thread_store.v1.ThreadStore/PersistThread",
            );
            let mut req = request.into_request();
            req.extensions_mut().insert(GrpcMethod::new(
                "codex.thread_store.v1.ThreadStore",
                "PersistThread",
            ));
            self.inner.unary(req, path, codec).await
        }
        pub async fn flush_thread(
            &mut self,
            request: impl tonic::IntoRequest<super::ThreadIdRequest>,
        ) -> std::result::Result<tonic::Response<super::Empty>, tonic::Status> {
            self.inner.ready().await.map_err(|e| {
                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
            })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/codex.thread_store.v1.ThreadStore/FlushThread",
            );
            let mut req = request.into_request();
            req.extensions_mut().insert(GrpcMethod::new(
                "codex.thread_store.v1.ThreadStore",
                "FlushThread",
            ));
            self.inner.unary(req, path, codec).await
        }
        pub async fn shutdown_thread(
            &mut self,
            request: impl tonic::IntoRequest<super::ThreadIdRequest>,
        ) -> std::result::Result<tonic::Response<super::Empty>, tonic::Status> {
            self.inner.ready().await.map_err(|e| {
                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
            })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/codex.thread_store.v1.ThreadStore/ShutdownThread",
            );
            let mut req = request.into_request();
            req.extensions_mut().insert(GrpcMethod::new(
                "codex.thread_store.v1.ThreadStore",
                "ShutdownThread",
            ));
            self.inner.unary(req, path, codec).await
        }
        pub async fn discard_thread(
            &mut self,
            request: impl tonic::IntoRequest<super::ThreadIdRequest>,
        ) -> std::result::Result<tonic::Response<super::Empty>, tonic::Status> {
            self.inner.ready().await.map_err(|e| {
                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
            })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/codex.thread_store.v1.ThreadStore/DiscardThread",
            );
            let mut req = request.into_request();
            req.extensions_mut().insert(GrpcMethod::new(
                "codex.thread_store.v1.ThreadStore",
                "DiscardThread",
            ));
            self.inner.unary(req, path, codec).await
        }
        pub async fn load_history(
            &mut self,
            request: impl tonic::IntoRequest<super::LoadThreadHistoryRequest>,
        ) -> std::result::Result<tonic::Response<super::StoredThreadHistory>, tonic::Status>
        {
            self.inner.ready().await.map_err(|e| {
                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
            })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/codex.thread_store.v1.ThreadStore/LoadHistory",
            );
            let mut req = request.into_request();
            req.extensions_mut().insert(GrpcMethod::new(
                "codex.thread_store.v1.ThreadStore",
                "LoadHistory",
            ));
            self.inner.unary(req, path, codec).await
        }
        pub async fn read_thread(
            &mut self,
            request: impl tonic::IntoRequest<super::ReadThreadRequest>,
        ) -> std::result::Result<tonic::Response<super::StoredThreadResponse>, tonic::Status>
        {
            self.inner.ready().await.map_err(|e| {
                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
            })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/codex.thread_store.v1.ThreadStore/ReadThread",
            );
            let mut req = request.into_request();
            req.extensions_mut().insert(GrpcMethod::new(
                "codex.thread_store.v1.ThreadStore",
                "ReadThread",
            ));
            self.inner.unary(req, path, codec).await
        }
        pub async fn list_threads(
            &mut self,
            request: impl tonic::IntoRequest<super::ListThreadsRequest>,
        ) -> std::result::Result<tonic::Response<super::ListThreadsResponse>, tonic::Status>
        {
            self.inner.ready().await.map_err(|e| {
                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
            })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/codex.thread_store.v1.ThreadStore/ListThreads",
            );
            let mut req = request.into_request();
            req.extensions_mut().insert(GrpcMethod::new(
                "codex.thread_store.v1.ThreadStore",
                "ListThreads",
            ));
            self.inner.unary(req, path, codec).await
        }
        pub async fn update_thread_metadata(
            &mut self,
            request: impl tonic::IntoRequest<super::UpdateThreadMetadataRequest>,
        ) -> std::result::Result<tonic::Response<super::StoredThreadResponse>, tonic::Status>
        {
            self.inner.ready().await.map_err(|e| {
                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
            })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/codex.thread_store.v1.ThreadStore/UpdateThreadMetadata",
            );
            let mut req = request.into_request();
            req.extensions_mut().insert(GrpcMethod::new(
                "codex.thread_store.v1.ThreadStore",
                "UpdateThreadMetadata",
            ));
            self.inner.unary(req, path, codec).await
        }
        pub async fn archive_thread(
            &mut self,
            request: impl tonic::IntoRequest<super::ArchiveThreadRequest>,
        ) -> std::result::Result<tonic::Response<super::Empty>, tonic::Status> {
            self.inner.ready().await.map_err(|e| {
                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
            })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/codex.thread_store.v1.ThreadStore/ArchiveThread",
            );
            let mut req = request.into_request();
            req.extensions_mut().insert(GrpcMethod::new(
                "codex.thread_store.v1.ThreadStore",
                "ArchiveThread",
            ));
            self.inner.unary(req, path, codec).await
        }
        pub async fn unarchive_thread(
            &mut self,
            request: impl tonic::IntoRequest<super::ArchiveThreadRequest>,
        ) -> std::result::Result<tonic::Response<super::StoredThreadResponse>, tonic::Status>
        {
            self.inner.ready().await.map_err(|e| {
                tonic::Status::unknown(format!("Service was not ready: {}", e.into()))
            })?;
            let codec = tonic_prost::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/codex.thread_store.v1.ThreadStore/UnarchiveThread",
            );
            let mut req = request.into_request();
            req.extensions_mut().insert(GrpcMethod::new(
                "codex.thread_store.v1.ThreadStore",
                "UnarchiveThread",
            ));
            self.inner.unary(req, path, codec).await
        }
    }
}
/// Generated server implementations.
pub mod thread_store_server {
    #![allow(
        unused_variables,
        dead_code,
        missing_docs,
        clippy::wildcard_imports,
        clippy::let_unit_value
    )]
    use tonic::codegen::*;
    /// Generated trait containing gRPC methods that should be implemented for use with ThreadStoreServer.
    #[async_trait]
    pub trait ThreadStore: std::marker::Send + std::marker::Sync + 'static {
        async fn create_thread(
            &self,
            request: tonic::Request<super::CreateThreadRequest>,
        ) -> std::result::Result<tonic::Response<super::Empty>, tonic::Status> {
            let _ = request;
            Err(tonic::Status::unimplemented("not implemented"))
        }
        async fn resume_thread(
            &self,
            request: tonic::Request<super::ResumeThreadRequest>,
        ) -> std::result::Result<tonic::Response<super::Empty>, tonic::Status> {
            let _ = request;
            Err(tonic::Status::unimplemented("not implemented"))
        }
        async fn append_items(
            &self,
            request: tonic::Request<super::AppendThreadItemsRequest>,
        ) -> std::result::Result<tonic::Response<super::Empty>, tonic::Status> {
            let _ = request;
            Err(tonic::Status::unimplemented("not implemented"))
        }
        async fn persist_thread(
            &self,
            request: tonic::Request<super::ThreadIdRequest>,
        ) -> std::result::Result<tonic::Response<super::Empty>, tonic::Status> {
            let _ = request;
            Err(tonic::Status::unimplemented("not implemented"))
        }
        async fn flush_thread(
            &self,
            request: tonic::Request<super::ThreadIdRequest>,
        ) -> std::result::Result<tonic::Response<super::Empty>, tonic::Status> {
            let _ = request;
            Err(tonic::Status::unimplemented("not implemented"))
        }
        async fn shutdown_thread(
            &self,
            request: tonic::Request<super::ThreadIdRequest>,
        ) -> std::result::Result<tonic::Response<super::Empty>, tonic::Status> {
            let _ = request;
            Err(tonic::Status::unimplemented("not implemented"))
        }
        async fn discard_thread(
            &self,
            request: tonic::Request<super::ThreadIdRequest>,
        ) -> std::result::Result<tonic::Response<super::Empty>, tonic::Status> {
            let _ = request;
            Err(tonic::Status::unimplemented("not implemented"))
        }
        async fn load_history(
            &self,
            request: tonic::Request<super::LoadThreadHistoryRequest>,
        ) -> std::result::Result<tonic::Response<super::StoredThreadHistory>, tonic::Status>
        {
            let _ = request;
            Err(tonic::Status::unimplemented("not implemented"))
        }
        async fn read_thread(
            &self,
            request: tonic::Request<super::ReadThreadRequest>,
        ) -> std::result::Result<tonic::Response<super::StoredThreadResponse>, tonic::Status>
        {
            let _ = request;
            Err(tonic::Status::unimplemented("not implemented"))
        }
        async fn list_threads(
            &self,
            request: tonic::Request<super::ListThreadsRequest>,
        ) -> std::result::Result<tonic::Response<super::ListThreadsResponse>, tonic::Status>;
        async fn update_thread_metadata(
            &self,
            request: tonic::Request<super::UpdateThreadMetadataRequest>,
        ) -> std::result::Result<tonic::Response<super::StoredThreadResponse>, tonic::Status>
        {
            let _ = request;
            Err(tonic::Status::unimplemented("not implemented"))
        }
        async fn archive_thread(
            &self,
            request: tonic::Request<super::ArchiveThreadRequest>,
        ) -> std::result::Result<tonic::Response<super::Empty>, tonic::Status> {
            let _ = request;
            Err(tonic::Status::unimplemented("not implemented"))
        }
        async fn unarchive_thread(
            &self,
            request: tonic::Request<super::ArchiveThreadRequest>,
        ) -> std::result::Result<tonic::Response<super::StoredThreadResponse>, tonic::Status>
        {
            let _ = request;
            Err(tonic::Status::unimplemented("not implemented"))
        }
    }
    #[derive(Debug)]
    pub struct ThreadStoreServer<T> {
        inner: Arc<T>,
        accept_compression_encodings: EnabledCompressionEncodings,
        send_compression_encodings: EnabledCompressionEncodings,
        max_decoding_message_size: Option<usize>,
        max_encoding_message_size: Option<usize>,
    }
    impl<T> ThreadStoreServer<T> {
        pub fn new(inner: T) -> Self {
            Self::from_arc(Arc::new(inner))
        }
        pub fn from_arc(inner: Arc<T>) -> Self {
            Self {
                inner,
                accept_compression_encodings: Default::default(),
                send_compression_encodings: Default::default(),
                max_decoding_message_size: None,
                max_encoding_message_size: None,
            }
        }
        pub fn with_interceptor<F>(inner: T, interceptor: F) -> InterceptedService<Self, F>
        where
            F: tonic::service::Interceptor,
        {
            InterceptedService::new(Self::new(inner), interceptor)
        }
        /// Enable decompressing requests with the given encoding.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.accept_compression_encodings.enable(encoding);
            self
        }
        /// Compress responses with the given encoding, if the client supports it.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.send_compression_encodings.enable(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.max_decoding_message_size = Some(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.max_encoding_message_size = Some(limit);
            self
        }
    }
    impl<T, B> tonic::codegen::Service<http::Request<B>> for ThreadStoreServer<T>
    where
        T: ThreadStore,
        B: Body + std::marker::Send + 'static,
        B::Error: Into<StdError> + std::marker::Send + 'static,
    {
        type Response = http::Response<tonic::body::Body>;
        type Error = std::convert::Infallible;
        type Future = BoxFuture<Self::Response, Self::Error>;
        fn poll_ready(
            &mut self,
            _cx: &mut Context<'_>,
        ) -> Poll<std::result::Result<(), Self::Error>> {
            Poll::Ready(Ok(()))
        }
        fn call(&mut self, req: http::Request<B>) -> Self::Future {
            macro_rules! unary_service {
                ($svc:ident, $request:ty, $response:ty, $method:ident) => {{
                    #[allow(non_camel_case_types)]
                    struct $svc<T: ThreadStore>(pub Arc<T>);
                    impl<T: ThreadStore> tonic::server::UnaryService<$request> for $svc<T> {
                        type Response = $response;
                        type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
                        fn call(&mut self, request: tonic::Request<$request>) -> Self::Future {
                            let inner = Arc::clone(&self.0);
                            let fut =
                                async move { <T as ThreadStore>::$method(&inner, request).await };
                            Box::pin(fut)
                        }
                    }
                    let accept_compression_encodings = self.accept_compression_encodings;
                    let send_compression_encodings = self.send_compression_encodings;
                    let max_decoding_message_size = self.max_decoding_message_size;
                    let max_encoding_message_size = self.max_encoding_message_size;
                    let inner = self.inner.clone();
                    let fut = async move {
                        let method = $svc(inner);
                        let codec = tonic_prost::ProstCodec::default();
                        let mut grpc = tonic::server::Grpc::new(codec)
                            .apply_compression_config(
                                accept_compression_encodings,
                                send_compression_encodings,
                            )
                            .apply_max_message_size_config(
                                max_decoding_message_size,
                                max_encoding_message_size,
                            );
                        let res = grpc.unary(method, req).await;
                        Ok(res)
                    };
                    Box::pin(fut)
                }};
            }
            match req.uri().path() {
                "/codex.thread_store.v1.ThreadStore/CreateThread" => unary_service!(
                    CreateThreadSvc,
                    super::CreateThreadRequest,
                    super::Empty,
                    create_thread
                ),
                "/codex.thread_store.v1.ThreadStore/ResumeThread" => unary_service!(
                    ResumeThreadSvc,
                    super::ResumeThreadRequest,
                    super::Empty,
                    resume_thread
                ),
                "/codex.thread_store.v1.ThreadStore/AppendItems" => unary_service!(
                    AppendItemsSvc,
                    super::AppendThreadItemsRequest,
                    super::Empty,
                    append_items
                ),
                "/codex.thread_store.v1.ThreadStore/PersistThread" => unary_service!(
                    PersistThreadSvc,
                    super::ThreadIdRequest,
                    super::Empty,
                    persist_thread
                ),
                "/codex.thread_store.v1.ThreadStore/FlushThread" => unary_service!(
                    FlushThreadSvc,
                    super::ThreadIdRequest,
                    super::Empty,
                    flush_thread
                ),
                "/codex.thread_store.v1.ThreadStore/ShutdownThread" => unary_service!(
                    ShutdownThreadSvc,
                    super::ThreadIdRequest,
                    super::Empty,
                    shutdown_thread
                ),
                "/codex.thread_store.v1.ThreadStore/DiscardThread" => unary_service!(
                    DiscardThreadSvc,
                    super::ThreadIdRequest,
                    super::Empty,
                    discard_thread
                ),
                "/codex.thread_store.v1.ThreadStore/LoadHistory" => unary_service!(
                    LoadHistorySvc,
                    super::LoadThreadHistoryRequest,
                    super::StoredThreadHistory,
                    load_history
                ),
                "/codex.thread_store.v1.ThreadStore/ReadThread" => unary_service!(
                    ReadThreadSvc,
                    super::ReadThreadRequest,
                    super::StoredThreadResponse,
                    read_thread
                ),
                "/codex.thread_store.v1.ThreadStore/ListThreads" => {
                    #[allow(non_camel_case_types)]
                    struct ListThreadsSvc<T: ThreadStore>(pub Arc<T>);
                    impl<T: ThreadStore> tonic::server::UnaryService<super::ListThreadsRequest> for ListThreadsSvc<T> {
                        type Response = super::ListThreadsResponse;
                        type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
                        fn call(
                            &mut self,
                            request: tonic::Request<super::ListThreadsRequest>,
                        ) -> Self::Future {
                            let inner = Arc::clone(&self.0);
                            let fut = async move {
                                <T as ThreadStore>::list_threads(&inner, request).await
                            };
                            Box::pin(fut)
                        }
                    }
                    let accept_compression_encodings = self.accept_compression_encodings;
                    let send_compression_encodings = self.send_compression_encodings;
                    let max_decoding_message_size = self.max_decoding_message_size;
                    let max_encoding_message_size = self.max_encoding_message_size;
                    let inner = self.inner.clone();
                    let fut = async move {
                        let method = ListThreadsSvc(inner);
                        let codec = tonic_prost::ProstCodec::default();
                        let mut grpc = tonic::server::Grpc::new(codec)
                            .apply_compression_config(
                                accept_compression_encodings,
                                send_compression_encodings,
                            )
                            .apply_max_message_size_config(
                                max_decoding_message_size,
                                max_encoding_message_size,
                            );
                        let res = grpc.unary(method, req).await;
                        Ok(res)
                    };
                    Box::pin(fut)
                }
                "/codex.thread_store.v1.ThreadStore/UpdateThreadMetadata" => unary_service!(
                    UpdateThreadMetadataSvc,
                    super::UpdateThreadMetadataRequest,
                    super::StoredThreadResponse,
                    update_thread_metadata
                ),
                "/codex.thread_store.v1.ThreadStore/ArchiveThread" => unary_service!(
                    ArchiveThreadSvc,
                    super::ArchiveThreadRequest,
                    super::Empty,
                    archive_thread
                ),
                "/codex.thread_store.v1.ThreadStore/UnarchiveThread" => unary_service!(
                    UnarchiveThreadSvc,
                    super::ArchiveThreadRequest,
                    super::StoredThreadResponse,
                    unarchive_thread
                ),
                _ => Box::pin(async move {
                    let mut response = http::Response::new(tonic::body::Body::default());
                    let headers = response.headers_mut();
                    headers.insert(
                        tonic::Status::GRPC_STATUS,
                        (tonic::Code::Unimplemented as i32).into(),
                    );
                    headers.insert(
                        http::header::CONTENT_TYPE,
                        tonic::metadata::GRPC_CONTENT_TYPE,
                    );
                    Ok(response)
                }),
            }
        }
    }
    impl<T> Clone for ThreadStoreServer<T> {
        fn clone(&self) -> Self {
            let inner = self.inner.clone();
            Self {
                inner,
                accept_compression_encodings: self.accept_compression_encodings,
                send_compression_encodings: self.send_compression_encodings,
                max_decoding_message_size: self.max_decoding_message_size,
                max_encoding_message_size: self.max_encoding_message_size,
            }
        }
    }
    /// Generated gRPC service name
    pub const SERVICE_NAME: &str = "codex.thread_store.v1.ThreadStore";
    impl<T> tonic::server::NamedService for ThreadStoreServer<T> {
        const NAME: &'static str = SERVICE_NAME;
    }
}
