Skip to main content

OpenSecretClient

Struct OpenSecretClient 

Source
pub struct OpenSecretClient { /* private fields */ }

Implementations§

Source§

impl OpenSecretClient

Source

pub fn new(base_url: impl Into<String>) -> Result<Self>

Construct a client using the official production PCR0 trust roots.

Source

pub fn new_with_pcr0_environment( base_url: impl Into<String>, pcr0_environment: Pcr0Environment, ) -> Result<Self>

Construct a client using one explicit official PCR0 environment.

Source

pub fn new_with_pcr0_trust_policy( base_url: impl Into<String>, pcr0_trust_policy: Pcr0TrustPolicy, ) -> Result<Self>

Construct a client with an explicit PCR0 trust policy.

Source

pub fn new_with_api_key( base_url: impl Into<String>, api_key: String, ) -> Result<Self>

Construct an API-key client using the official production PCR0 trust roots.

Source

pub fn new_with_api_key_and_pcr0_environment( base_url: impl Into<String>, api_key: String, pcr0_environment: Pcr0Environment, ) -> Result<Self>

Construct an API-key client using one explicit official PCR0 environment.

Source

pub fn new_with_api_key_and_pcr0_trust_policy( base_url: impl Into<String>, api_key: String, pcr0_trust_policy: Pcr0TrustPolicy, ) -> Result<Self>

Construct an API-key client with an explicit PCR0 trust policy.

Source

pub fn set_api_key(&self, api_key: String) -> Result<()>

Source

pub fn clear_api_key(&self) -> Result<()>

Source

pub async fn perform_attestation_handshake(&self) -> Result<()>

Source

pub fn get_session_id(&self) -> Result<Option<Uuid>>

Source

pub async fn test_connection(&self) -> Result<String>

Source

pub async fn send_inference_request( &self, request: InferenceRequest, ) -> Result<InferenceResponse>

Sends a lossless encrypted request to an OpenSecret inference endpoint.

The request URI must be relative and target one of the SDK’s explicitly allowed inference routes. Its method, query string, headers, and body bytes are otherwise caller-owned. The SDK does not parse the request as JSON and never adds or changes inference parameters such as stream.

OpenSecret authentication, attestation sessions, and the encrypted envelope remain SDK-owned. Caller-provided Host, Authorization, x-session-id, Content-Length, Content-Type, Content-Encoding, Accept-Encoding, Content-MD5, Digest, and hop-by-hop headers (including fields named by Connection) are therefore not forwarded. Other headers are preserved.

The returned HTTP response preserves the final OpenSecret status and safe response headers. Its body is decrypted raw bytes. SSE framing is preserved while encrypted data: fields are decrypted without parsing their contents as completion JSON. Individual SSE lines are limited to 16 MiB.

Source

pub async fn login( &self, email: String, password: String, client_id: Uuid, ) -> Result<LoginResponse>

Source

pub async fn login_with_id( &self, id: Uuid, password: String, client_id: Uuid, ) -> Result<LoginResponse>

Source

pub async fn register( &self, email: String, password: String, client_id: Uuid, name: Option<String>, ) -> Result<LoginResponse>

Source

pub async fn register_guest( &self, password: String, client_id: Uuid, ) -> Result<LoginResponse>

Source

pub async fn initiate_github_auth( &self, client_id: Uuid, invite_code: Option<String>, ) -> Result<GithubAuthResponse>

Source

pub async fn handle_github_callback( &self, code: String, state: String, invite_code: String, ) -> Result<LoginResponse>

Source

pub async fn initiate_google_auth( &self, client_id: Uuid, invite_code: Option<String>, ) -> Result<GoogleAuthResponse>

Source

pub async fn handle_google_callback( &self, code: String, state: String, invite_code: String, ) -> Result<LoginResponse>

Source

pub async fn initiate_apple_auth( &self, client_id: Uuid, invite_code: Option<String>, ) -> Result<AppleAuthResponse>

Source

pub async fn handle_apple_callback( &self, code: String, state: String, invite_code: String, ) -> Result<LoginResponse>

Source

pub async fn handle_apple_native_sign_in( &self, user_identifier: String, identity_token: String, client_id: Uuid, email: Option<String>, given_name: Option<String>, family_name: Option<String>, nonce: Option<String>, invite_code: Option<String>, ) -> Result<LoginResponse>

Source

pub async fn refresh_token(&self) -> Result<()>

Source

pub async fn logout(&self) -> Result<()>

Source

pub async fn logout_with_push_device_id( &self, push_device_id: Uuid, ) -> Result<()>

Source

pub fn get_access_token(&self) -> Result<Option<String>>

Source

pub fn get_tokens(&self) -> Result<Option<TokenPair>>

Return one coherent snapshot of the current JWT token pair.

Prefer this over separate access- and refresh-token reads when the pair will be persisted or copied into another client: an automatic refresh can replace both values between two independent lock acquisitions.

Source

pub fn get_refresh_token(&self) -> Result<Option<String>>

Source

pub fn set_tokens( &self, access_token: String, refresh_token: Option<String>, ) -> Result<()>

Source

pub async fn get_user(&self) -> Result<UserResponse>

Source

pub async fn register_push_device( &self, request: RegisterPushDeviceRequest, ) -> Result<PushDevice>

Source

pub async fn list_push_devices(&self) -> Result<PushDeviceListResponse>

Source

pub async fn revoke_push_device( &self, id: Uuid, ) -> Result<DeletedPushDeviceResponse>

Source

pub async fn create_api_key(&self, name: String) -> Result<ApiKeyCreateResponse>

Source

pub async fn list_api_keys(&self) -> Result<Vec<ApiKey>>

Source

pub async fn delete_api_key(&self, name: &str) -> Result<()>

Source

pub async fn kv_get(&self, key: &str) -> Result<String>

Source

pub async fn kv_put(&self, key: &str, value: String) -> Result<String>

Source

pub async fn kv_delete(&self, key: &str) -> Result<()>

Source

pub async fn kv_delete_all(&self) -> Result<()>

Source

pub async fn kv_list(&self) -> Result<Vec<KVListItem>>

Source

pub async fn get_private_key( &self, options: Option<KeyOptions>, ) -> Result<PrivateKeyResponse>

Source

pub async fn get_private_key_bytes( &self, options: Option<KeyOptions>, ) -> Result<PrivateKeyBytesResponse>

Source

pub async fn sign_message( &self, message_bytes: &[u8], algorithm: SigningAlgorithm, key_options: Option<KeyOptions>, ) -> Result<SignMessageResponse>

Source

pub async fn get_public_key( &self, algorithm: SigningAlgorithm, key_options: Option<KeyOptions>, ) -> Result<PublicKeyResponse>

Source

pub async fn generate_third_party_token( &self, audience: Option<String>, ) -> Result<ThirdPartyTokenResponse>

Source

pub async fn encrypt_data( &self, data: String, key_options: Option<KeyOptions>, ) -> Result<EncryptDataResponse>

Source

pub async fn decrypt_data( &self, encrypted_data: String, key_options: Option<KeyOptions>, ) -> Result<String>

Source

pub async fn change_password( &self, current_password: String, new_password: String, ) -> Result<()>

Changes the password for the currently authenticated user

Source

pub async fn request_password_reset( &self, email: String, hashed_secret: String, client_id: Uuid, ) -> Result<()>

Requests a password reset for the given email Note: This does not require authentication but still uses encryption

Source

pub async fn confirm_password_reset( &self, email: String, alphanumeric_code: String, plaintext_secret: String, new_password: String, client_id: Uuid, ) -> Result<()>

Confirms a password reset with the code from email Note: This does not require authentication but still uses encryption

Source

pub async fn verify_email(&self, code: String) -> Result<()>

Verifies an email address with the code from the verification email Note: This does not require authentication but still uses encryption

Source

pub async fn request_new_verification_code(&self) -> Result<()>

Requests a new email verification code

Source

pub async fn request_account_deletion( &self, hashed_secret: String, ) -> Result<()>

Initiates the account deletion process

Source

pub async fn confirm_account_deletion( &self, confirmation_code: String, plaintext_secret: String, ) -> Result<()>

Confirms account deletion with the code from email

Source

pub async fn create_conversation( &self, request: ConversationCreateRequest, ) -> Result<Conversation>

Creates a new conversation.

Source

pub async fn list_conversations( &self, params: Option<ConversationsListParams>, ) -> Result<ConversationsListResponse>

Lists conversations with optional filters and pagination.

Source

pub async fn get_conversation( &self, conversation_id: Uuid, ) -> Result<Conversation>

Fetches a single conversation by UUID.

Source

pub async fn update_conversation( &self, conversation_id: Uuid, request: ConversationUpdateRequest, ) -> Result<Conversation>

Partially updates a conversation.

Source

pub async fn delete_conversation( &self, conversation_id: Uuid, ) -> Result<DeletedObjectResponse>

Deletes a single conversation by UUID.

Source

pub async fn list_conversation_items( &self, conversation_id: Uuid, params: Option<AgentItemsListParams>, ) -> Result<ConversationItemsResponse>

Lists items in a conversation.

Source

pub async fn get_conversation_item( &self, conversation_id: Uuid, item_id: Uuid, ) -> Result<ConversationItem>

Fetches a single item from a conversation.

Source

pub async fn delete_conversations(&self) -> Result<ConversationsDeleteResponse>

Deletes all conversations

Source

pub async fn batch_delete_conversations( &self, ids: Vec<String>, ) -> Result<BatchDeleteConversationsResponse>

Batch deletes multiple conversations by their IDs

Source

pub async fn batch_update_conversation_project( &self, ids: Vec<Uuid>, project_id: Option<Uuid>, ) -> Result<BatchUpdateConversationProjectResponse>

Batch updates conversation project assignments. Use None to clear the project.

Source

pub async fn create_conversation_project( &self, request: ConversationProjectCreateRequest, ) -> Result<ConversationProject>

Creates a new conversation project.

Source

pub async fn list_conversation_projects( &self, params: Option<ConversationProjectListParams>, ) -> Result<ConversationProjectsListResponse>

Lists conversation projects with pagination.

Source

pub async fn get_conversation_project( &self, project_id: Uuid, ) -> Result<ConversationProject>

Fetches a single conversation project by UUID.

Source

pub async fn update_conversation_project( &self, project_id: Uuid, request: ConversationProjectUpdateRequest, ) -> Result<ConversationProject>

Updates a conversation project and/or its project instructions.

Source

pub async fn delete_conversation_project( &self, project_id: Uuid, ) -> Result<DeletedObjectResponse>

Deletes a conversation project by UUID.

Source

pub async fn get_models(&self) -> Result<ModelsResponse>

Fetches available AI models

Source

pub async fn create_embeddings( &self, request: EmbeddingRequest, ) -> Result<EmbeddingResponse>

Creates embeddings for the given input text(s)

§Example
let request = EmbeddingRequest {
    input: "Hello, world!".into(),
    model: "nomic-embed-text".to_string(),
    encoding_format: None,
    dimensions: None,
    user: None,
};
let response = client.create_embeddings(request).await?;
Source

pub async fn create_chat_completion( &self, request: ChatCompletionRequest, ) -> Result<ChatCompletionResponse>

Creates a chat completion (non-streaming)

Source

pub async fn create_chat_completion_stream( &self, request: ChatCompletionRequest, ) -> Result<Pin<Box<dyn Stream<Item = Result<ChatCompletionChunk>> + Send>>>

Creates a streaming chat completion

Searches the public web through OpenSecret’s configured search provider.

Source

pub async fn web_extract( &self, request: WebExtractRequest, ) -> Result<WebExtractResponse>

Extracts sanitized Markdown from public URLs through OpenSecret’s configured provider.

Source

pub async fn get_main_agent(&self) -> Result<MainAgentResponse>

Fetches the current user’s main agent.

Source

pub async fn init_main_agent( &self, request: InitMainAgentRequest, ) -> Result<InitMainAgentResponse>

Explicitly initializes the current user’s main agent.

Source

pub async fn delete_main_agent(&self) -> Result<DeletedObjectResponse>

Deletes the current user’s main agent and resets shared agent state.

Source

pub async fn list_main_agent_items( &self, params: Option<AgentItemsListParams>, ) -> Result<AgentItemsListResponse>

Lists items in the main agent conversation.

Source

pub async fn get_main_agent_item( &self, item_id: Uuid, ) -> Result<ConversationItem>

Fetches a single item from the main agent conversation.

Source

pub async fn set_main_agent_item_reaction( &self, item_id: Uuid, emoji: impl Into<String>, ) -> Result<ConversationItem>

Sets or replaces the current user’s reaction on a main-agent assistant message item.

Source

pub async fn clear_main_agent_item_reaction( &self, item_id: Uuid, ) -> Result<ConversationItem>

Clears the current user’s reaction on a main-agent assistant message item.

Source

pub async fn agent_chat( &self, input: &str, ) -> Result<Pin<Box<dyn Stream<Item = Result<AgentSseEvent>> + Send>>>

Sends a message to the main agent and returns a stream of SSE events.

Source

pub async fn create_subagent( &self, request: CreateSubagentRequest, ) -> Result<SubagentResponse>

Creates a new subagent for the current user.

Source

pub async fn list_subagents( &self, params: Option<ListSubagentsParams>, ) -> Result<SubagentListResponse>

Lists subagents for the current user with pagination and filtering.

Source

pub async fn get_subagent(&self, id: Uuid) -> Result<SubagentResponse>

Fetches a single subagent by UUID.

Source

pub async fn subagent_chat( &self, id: Uuid, input: &str, ) -> Result<Pin<Box<dyn Stream<Item = Result<AgentSseEvent>> + Send>>>

Sends a message to a specific subagent and returns a stream of SSE events.

Source

pub async fn list_subagent_items( &self, id: Uuid, params: Option<AgentItemsListParams>, ) -> Result<AgentItemsListResponse>

Lists items in a subagent conversation.

Source

pub async fn get_subagent_item( &self, id: Uuid, item_id: Uuid, ) -> Result<ConversationItem>

Fetches a single item from a subagent conversation.

Source

pub async fn set_subagent_item_reaction( &self, id: Uuid, item_id: Uuid, emoji: impl Into<String>, ) -> Result<ConversationItem>

Sets or replaces the current user’s reaction on a subagent assistant message item.

Source

pub async fn clear_subagent_item_reaction( &self, id: Uuid, item_id: Uuid, ) -> Result<ConversationItem>

Clears the current user’s reaction on a subagent assistant message item.

Source

pub async fn delete_subagent(&self, id: Uuid) -> Result<DeletedObjectResponse>

Deletes a subagent by UUID.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more