pub struct OpenSecretClient { /* private fields */ }Implementations§
Source§impl OpenSecretClient
impl OpenSecretClient
Sourcepub fn new(base_url: impl Into<String>) -> Result<Self>
pub fn new(base_url: impl Into<String>) -> Result<Self>
Construct a client using the official production PCR0 trust roots.
Sourcepub fn new_with_pcr0_environment(
base_url: impl Into<String>,
pcr0_environment: Pcr0Environment,
) -> Result<Self>
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.
Sourcepub fn new_with_pcr0_trust_policy(
base_url: impl Into<String>,
pcr0_trust_policy: Pcr0TrustPolicy,
) -> Result<Self>
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.
Sourcepub fn new_with_api_key(
base_url: impl Into<String>,
api_key: String,
) -> Result<Self>
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.
Sourcepub fn new_with_api_key_and_pcr0_environment(
base_url: impl Into<String>,
api_key: String,
pcr0_environment: Pcr0Environment,
) -> Result<Self>
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.
Sourcepub fn new_with_api_key_and_pcr0_trust_policy(
base_url: impl Into<String>,
api_key: String,
pcr0_trust_policy: Pcr0TrustPolicy,
) -> Result<Self>
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.
Sourcepub fn with_cache_namespace_root(
self,
root: TransportV2CacheNamespaceRoot,
) -> Self
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.
pub fn set_api_key(&self, api_key: String) -> Result<()>
pub fn clear_api_key(&self) -> Result<()>
pub async fn perform_attestation_handshake(&self) -> Result<()>
Sourcepub async fn prepare_native_oauth_handoff(
&self,
) -> Result<PreparedNativeOAuthHandoff>
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.
Sourcepub async fn redeem_native_oauth_handoff(
&self,
prepared: PreparedNativeOAuthHandoff,
grant: NativeOAuthHandoffGrant,
) -> Result<LoginResponse>
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.
pub fn get_session_id(&self) -> Result<Option<Uuid>>
pub async fn test_connection(&self) -> Result<String>
Sourcepub async fn send_inference_request(
&self,
request: InferenceRequest,
) -> Result<InferenceResponse>
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.
Sourcepub async fn send_inference_request_with_budget(
&self,
request: InferenceRequest,
send_budget: InferenceSendBudget,
) -> Result<InferenceResponse>
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.
Sourcepub async fn send_inference_request_with_api_key(
&self,
request: InferenceRequest,
api_key: String,
) -> Result<InferenceResponse>
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.
pub async fn login( &self, email: String, password: String, client_id: Uuid, ) -> Result<LoginResponse>
pub async fn login_with_id( &self, id: Uuid, password: String, client_id: Uuid, ) -> Result<LoginResponse>
pub async fn register( &self, email: String, password: String, client_id: Uuid, name: Option<String>, ) -> Result<LoginResponse>
pub async fn register_guest( &self, password: String, client_id: Uuid, ) -> Result<LoginResponse>
pub async fn initiate_github_auth( &self, client_id: Uuid, invite_code: Option<String>, ) -> Result<GithubAuthResponse>
pub async fn handle_github_callback( &self, code: String, state: String, invite_code: String, ) -> Result<LoginResponse>
pub async fn initiate_google_auth( &self, client_id: Uuid, invite_code: Option<String>, ) -> Result<GoogleAuthResponse>
pub async fn handle_google_callback( &self, code: String, state: String, invite_code: String, ) -> Result<LoginResponse>
pub async fn initiate_apple_auth( &self, client_id: Uuid, invite_code: Option<String>, ) -> Result<AppleAuthResponse>
pub async fn handle_apple_callback( &self, code: String, state: String, invite_code: String, ) -> Result<LoginResponse>
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>
pub async fn refresh_token(&self) -> Result<()>
pub async fn logout(&self) -> Result<()>
pub async fn logout_with_push_device_id( &self, push_device_id: Uuid, ) -> Result<()>
pub fn get_access_token(&self) -> Result<Option<String>>
Sourcepub fn get_tokens(&self) -> Result<Option<TokenPair>>
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.
pub fn get_refresh_token(&self) -> Result<Option<String>>
pub fn set_tokens( &self, access_token: String, refresh_token: Option<String>, ) -> Result<()>
pub async fn get_user(&self) -> Result<UserResponse>
pub async fn register_push_device( &self, request: RegisterPushDeviceRequest, ) -> Result<PushDevice>
pub async fn list_push_devices(&self) -> Result<PushDeviceListResponse>
pub async fn revoke_push_device( &self, id: Uuid, ) -> Result<DeletedPushDeviceResponse>
pub async fn create_api_key(&self, name: String) -> Result<ApiKeyCreateResponse>
pub async fn list_api_keys(&self) -> Result<Vec<ApiKey>>
pub async fn delete_api_key(&self, name: &str) -> Result<()>
pub async fn get_private_key( &self, options: Option<KeyOptions>, ) -> Result<PrivateKeyResponse>
pub async fn get_private_key_bytes( &self, options: Option<KeyOptions>, ) -> Result<PrivateKeyBytesResponse>
pub async fn sign_message( &self, message_bytes: &[u8], algorithm: SigningAlgorithm, key_options: Option<KeyOptions>, ) -> Result<SignMessageResponse>
pub async fn get_public_key( &self, algorithm: SigningAlgorithm, key_options: Option<KeyOptions>, ) -> Result<PublicKeyResponse>
pub async fn generate_third_party_token( &self, audience: Option<String>, ) -> Result<ThirdPartyTokenResponse>
pub async fn encrypt_data( &self, data: String, key_options: Option<KeyOptions>, ) -> Result<EncryptDataResponse>
pub async fn decrypt_data( &self, encrypted_data: String, key_options: Option<KeyOptions>, ) -> Result<String>
Sourcepub async fn change_password(
&self,
current_password: String,
new_password: String,
) -> Result<()>
pub async fn change_password( &self, current_password: String, new_password: String, ) -> Result<()>
Changes the password for the currently authenticated user
Sourcepub async fn request_password_reset(
&self,
email: String,
hashed_secret: String,
client_id: Uuid,
) -> Result<()>
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
Sourcepub async fn confirm_password_reset(
&self,
email: String,
alphanumeric_code: String,
plaintext_secret: String,
new_password: String,
client_id: Uuid,
) -> Result<()>
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
Sourcepub async fn verify_email(&self, code: String) -> Result<()>
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
Sourcepub async fn request_new_verification_code(&self) -> Result<()>
pub async fn request_new_verification_code(&self) -> Result<()>
Requests a new email verification code
Sourcepub async fn request_account_deletion(
&self,
hashed_secret: String,
) -> Result<()>
pub async fn request_account_deletion( &self, hashed_secret: String, ) -> Result<()>
Initiates the account deletion process
Sourcepub async fn confirm_account_deletion(
&self,
confirmation_code: String,
plaintext_secret: String,
) -> Result<()>
pub async fn confirm_account_deletion( &self, confirmation_code: String, plaintext_secret: String, ) -> Result<()>
Confirms account deletion with the code from email
Sourcepub async fn create_conversation(
&self,
request: ConversationCreateRequest,
) -> Result<Conversation>
pub async fn create_conversation( &self, request: ConversationCreateRequest, ) -> Result<Conversation>
Creates a new conversation.
Sourcepub async fn list_conversations(
&self,
params: Option<ConversationsListParams>,
) -> Result<ConversationsListResponse>
pub async fn list_conversations( &self, params: Option<ConversationsListParams>, ) -> Result<ConversationsListResponse>
Lists conversations with optional filters and pagination.
Sourcepub async fn get_conversation(
&self,
conversation_id: Uuid,
) -> Result<Conversation>
pub async fn get_conversation( &self, conversation_id: Uuid, ) -> Result<Conversation>
Fetches a single conversation by UUID.
Sourcepub async fn update_conversation(
&self,
conversation_id: Uuid,
request: ConversationUpdateRequest,
) -> Result<Conversation>
pub async fn update_conversation( &self, conversation_id: Uuid, request: ConversationUpdateRequest, ) -> Result<Conversation>
Partially updates a conversation.
Sourcepub async fn delete_conversation(
&self,
conversation_id: Uuid,
) -> Result<DeletedObjectResponse>
pub async fn delete_conversation( &self, conversation_id: Uuid, ) -> Result<DeletedObjectResponse>
Deletes a single conversation by UUID.
Sourcepub async fn list_conversation_items(
&self,
conversation_id: Uuid,
params: Option<AgentItemsListParams>,
) -> Result<ConversationItemsResponse>
pub async fn list_conversation_items( &self, conversation_id: Uuid, params: Option<AgentItemsListParams>, ) -> Result<ConversationItemsResponse>
Lists items in a conversation.
Sourcepub async fn get_conversation_item(
&self,
conversation_id: Uuid,
item_id: Uuid,
) -> Result<ConversationItem>
pub async fn get_conversation_item( &self, conversation_id: Uuid, item_id: Uuid, ) -> Result<ConversationItem>
Fetches a single item from a conversation.
Sourcepub async fn delete_conversations(&self) -> Result<ConversationsDeleteResponse>
pub async fn delete_conversations(&self) -> Result<ConversationsDeleteResponse>
Deletes all conversations
Sourcepub async fn batch_delete_conversations(
&self,
ids: Vec<String>,
) -> Result<BatchDeleteConversationsResponse>
pub async fn batch_delete_conversations( &self, ids: Vec<String>, ) -> Result<BatchDeleteConversationsResponse>
Batch deletes multiple conversations by their IDs
Sourcepub async fn batch_update_conversation_project(
&self,
ids: Vec<Uuid>,
project_id: Option<Uuid>,
) -> Result<BatchUpdateConversationProjectResponse>
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.
Sourcepub async fn create_conversation_project(
&self,
request: ConversationProjectCreateRequest,
) -> Result<ConversationProject>
pub async fn create_conversation_project( &self, request: ConversationProjectCreateRequest, ) -> Result<ConversationProject>
Creates a new conversation project.
Sourcepub async fn list_conversation_projects(
&self,
params: Option<ConversationProjectListParams>,
) -> Result<ConversationProjectsListResponse>
pub async fn list_conversation_projects( &self, params: Option<ConversationProjectListParams>, ) -> Result<ConversationProjectsListResponse>
Lists conversation projects with pagination.
Sourcepub async fn get_conversation_project(
&self,
project_id: Uuid,
) -> Result<ConversationProject>
pub async fn get_conversation_project( &self, project_id: Uuid, ) -> Result<ConversationProject>
Fetches a single conversation project by UUID.
Sourcepub async fn update_conversation_project(
&self,
project_id: Uuid,
request: ConversationProjectUpdateRequest,
) -> Result<ConversationProject>
pub async fn update_conversation_project( &self, project_id: Uuid, request: ConversationProjectUpdateRequest, ) -> Result<ConversationProject>
Updates a conversation project and/or its project instructions.
Sourcepub async fn delete_conversation_project(
&self,
project_id: Uuid,
) -> Result<DeletedObjectResponse>
pub async fn delete_conversation_project( &self, project_id: Uuid, ) -> Result<DeletedObjectResponse>
Deletes a conversation project by UUID.
Sourcepub async fn get_models(&self) -> Result<ModelsResponse>
pub async fn get_models(&self) -> Result<ModelsResponse>
Fetches available AI models
Sourcepub async fn get_model_catalog(&self) -> Result<ModelCatalogResponse>
pub async fn get_model_catalog(&self) -> Result<ModelCatalogResponse>
Fetches the full model catalog with context windows and capabilities.
Sourcepub async fn create_embeddings(
&self,
request: EmbeddingRequest,
) -> Result<EmbeddingResponse>
pub async fn create_embeddings( &self, request: EmbeddingRequest, ) -> Result<EmbeddingResponse>
Sourcepub async fn system_one(
&self,
request: SystemOneRequest,
) -> Result<SystemOneResponse>
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.
Sourcepub async fn system_one_with_api_key(
&self,
request: SystemOneRequest,
api_key: String,
) -> Result<SystemOneResponse>
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.
Sourcepub async fn create_chat_completion(
&self,
request: ChatCompletionRequest,
) -> Result<ChatCompletionResponse>
pub async fn create_chat_completion( &self, request: ChatCompletionRequest, ) -> Result<ChatCompletionResponse>
Creates a chat completion (non-streaming)
Sourcepub async fn create_chat_completion_stream(
&self,
request: ChatCompletionRequest,
) -> Result<Pin<Box<dyn Stream<Item = Result<ChatCompletionChunk>> + Send>>>
pub async fn create_chat_completion_stream( &self, request: ChatCompletionRequest, ) -> Result<Pin<Box<dyn Stream<Item = Result<ChatCompletionChunk>> + Send>>>
Creates a streaming chat completion
Sourcepub async fn web_search(
&self,
request: WebSearchRequest,
) -> Result<WebSearchResponse>
pub async fn web_search( &self, request: WebSearchRequest, ) -> Result<WebSearchResponse>
Searches the public web through OpenSecret’s configured search provider.
Sourcepub async fn web_extract(
&self,
request: WebExtractRequest,
) -> Result<WebExtractResponse>
pub async fn web_extract( &self, request: WebExtractRequest, ) -> Result<WebExtractResponse>
Extracts sanitized Markdown from public URLs through OpenSecret’s configured provider.
Sourcepub async fn get_main_agent(&self) -> Result<MainAgentResponse>
pub async fn get_main_agent(&self) -> Result<MainAgentResponse>
Fetches the current user’s main agent.
Sourcepub async fn init_main_agent(
&self,
request: InitMainAgentRequest,
) -> Result<InitMainAgentResponse>
pub async fn init_main_agent( &self, request: InitMainAgentRequest, ) -> Result<InitMainAgentResponse>
Explicitly initializes the current user’s main agent.
Sourcepub async fn delete_main_agent(&self) -> Result<DeletedObjectResponse>
pub async fn delete_main_agent(&self) -> Result<DeletedObjectResponse>
Deletes the current user’s main agent and resets shared agent state.
Sourcepub async fn list_main_agent_items(
&self,
params: Option<AgentItemsListParams>,
) -> Result<AgentItemsListResponse>
pub async fn list_main_agent_items( &self, params: Option<AgentItemsListParams>, ) -> Result<AgentItemsListResponse>
Lists items in the main agent conversation.
Sourcepub async fn get_main_agent_item(
&self,
item_id: Uuid,
) -> Result<ConversationItem>
pub async fn get_main_agent_item( &self, item_id: Uuid, ) -> Result<ConversationItem>
Fetches a single item from the main agent conversation.
Sourcepub async fn set_main_agent_item_reaction(
&self,
item_id: Uuid,
emoji: impl Into<String>,
) -> Result<ConversationItem>
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.
Sourcepub async fn clear_main_agent_item_reaction(
&self,
item_id: Uuid,
) -> Result<ConversationItem>
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.
Sourcepub async fn agent_chat(
&self,
input: &str,
) -> Result<Pin<Box<dyn Stream<Item = Result<AgentSseEvent>> + Send>>>
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.
Sourcepub async fn create_subagent(
&self,
request: CreateSubagentRequest,
) -> Result<SubagentResponse>
pub async fn create_subagent( &self, request: CreateSubagentRequest, ) -> Result<SubagentResponse>
Creates a new subagent for the current user.
Sourcepub async fn list_subagents(
&self,
params: Option<ListSubagentsParams>,
) -> Result<SubagentListResponse>
pub async fn list_subagents( &self, params: Option<ListSubagentsParams>, ) -> Result<SubagentListResponse>
Lists subagents for the current user with pagination and filtering.
Sourcepub async fn get_subagent(&self, id: Uuid) -> Result<SubagentResponse>
pub async fn get_subagent(&self, id: Uuid) -> Result<SubagentResponse>
Fetches a single subagent by UUID.
Sourcepub async fn subagent_chat(
&self,
id: Uuid,
input: &str,
) -> Result<Pin<Box<dyn Stream<Item = Result<AgentSseEvent>> + Send>>>
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.
Sourcepub async fn list_subagent_items(
&self,
id: Uuid,
params: Option<AgentItemsListParams>,
) -> Result<AgentItemsListResponse>
pub async fn list_subagent_items( &self, id: Uuid, params: Option<AgentItemsListParams>, ) -> Result<AgentItemsListResponse>
Lists items in a subagent conversation.
Sourcepub async fn get_subagent_item(
&self,
id: Uuid,
item_id: Uuid,
) -> Result<ConversationItem>
pub async fn get_subagent_item( &self, id: Uuid, item_id: Uuid, ) -> Result<ConversationItem>
Fetches a single item from a subagent conversation.
Sourcepub async fn set_subagent_item_reaction(
&self,
id: Uuid,
item_id: Uuid,
emoji: impl Into<String>,
) -> Result<ConversationItem>
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.
Sourcepub async fn clear_subagent_item_reaction(
&self,
id: Uuid,
item_id: Uuid,
) -> Result<ConversationItem>
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.
Sourcepub async fn delete_subagent(&self, id: Uuid) -> Result<DeletedObjectResponse>
pub async fn delete_subagent(&self, id: Uuid) -> Result<DeletedObjectResponse>
Deletes a subagent by UUID.