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 with_cache_namespace_root( self, root: TransportV2CacheNamespaceRoot, ) -> Self

Replace the random per-client provider-cache namespace root.

The root must be generated independently from account identifiers and credentials. Persist it when cache continuity across restarts matters.

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 async fn prepare_native_oauth_handoff( &self, ) -> Result<PreparedNativeOAuthHandoff>

Reserve one exact anonymous request for a hosted native OAuth handoff.

The returned IDs may be sent to the hosted browser so the enclave can bind its signed grant to this request. The handle itself must remain in the native process and is consumed exactly once by redemption.

Source

pub async fn redeem_native_oauth_handoff( &self, prepared: PreparedNativeOAuthHandoff, grant: NativeOAuthHandoffGrant, ) -> Result<LoginResponse>

Redeem a hosted handoff grant through the exact request prepared above.

No credential or cache namespace root is attached. This method sends at most once and never allocates a replacement request ID.

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 request to an allowed OpenSecret inference endpoint.

The complete logical request, including its selected credential, is authenticated inside one Transport V2 envelope. No outer credential is emitted. One marked outer session-recovery error may re-establish the attested session and resend the captured request with a fresh request ID. No other failure triggers replay, and there is no V1 downgrade.

Source

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

Sends an inference request while sharing a caller-owned send budget.

Only inference HTTP sends consume this request-local budget. Attestation and proactive token refresh do not consume it, and callers can share it across their own retry layers.

Source

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

Sends one inference request with an explicit per-request API key.

This is intended for multiplexing callers such as maple-proxy. The key is placed only inside the encrypted request and is not retained by the client or installed as its default credential.

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 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 get_model_catalog(&self) -> Result<ModelCatalogResponse>

Fetches the full model catalog with context windows and capabilities.

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 system_one( &self, request: SystemOneRequest, ) -> Result<SystemOneResponse>

Answers typed System One questions about a state with calibrated probabilities (POST /v1/systemone); see crate::system_one.

Uses the client’s configured credential: an API key when one is set, otherwise the signed-in session. A rejected request is Error::Api with the backend’s status (422 for schema problems, 413 for size limits, chat’s statuses for quota and capacity) and body; Error::api_error_code reads its system_one_* code.

Source

pub async fn system_one_with_api_key( &self, request: SystemOneRequest, api_key: String, ) -> Result<SystemOneResponse>

Self::system_one with an explicit per-request API key, encrypted inside this one request and not retained by the client.

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 = !

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

fn try_from(value: U) -> Result<T, !>

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