Skip to main content

NoxyAgentClient

Struct NoxyAgentClient 

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

Implementations§

Source§

impl NoxyAgentClient

Source

pub async fn send_decision<T>( &self, identity_address: NoxyIdentityAddress, actionable_decision: &T, ) -> Result<Vec<NoxyDeliveryOutcome>, Box<dyn Error + Send + Sync>>
where T: Serialize,

Route an actionable decision to all devices registered for the identity. Uses one client-generated decision_id (UUID) for the whole batch so every device shares the same logical decision.

Source

pub async fn get_decision_outcome( &self, decision_id: &str, identity_id: &str, ) -> Result<NoxyGetDecisionOutcomeResponse, Status>

Single poll for human-in-the-loop resolution.

Source

pub async fn wait_for_decision_outcome( &self, options: WaitForDecisionOutcomeOptions, ) -> Result<NoxyGetDecisionOutcomeResponse, Box<dyn Error + Send + Sync>>

Poll GetDecisionOutcome with exponential backoff until terminal outcome or pending == false.

Source

pub async fn send_decision_and_wait_for_outcome<T>( &self, identity_address: NoxyIdentityAddress, actionable_decision: &T, options: Option<SendDecisionAndWaitOptions>, ) -> Result<NoxyGetDecisionOutcomeResponse, Box<dyn Error + Send + Sync>>
where T: Serialize,

[send_decision] then [wait_for_decision_outcome] using the first delivery with a non-empty decision_id.

Examples found in repository?
examples/basic.rs (line 38)
10async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
11    let auth_token = std::env::var("NOXY_APP_TOKEN").expect("NOXY_APP_TOKEN must be set");
12    let target_address = std::env::var("NOXY_TARGET_ADDRESS").expect("NOXY_TARGET_ADDRESS must be set");
13
14    let config = NoxyConfig {
15        endpoint: NOXY_ENDPOINT.to_string(),
16        auth_token,
17        decision_ttl_seconds: 3600,
18    };
19
20    let client = init_noxy_agent_client(config).await?;
21
22    let quota = client.get_quota().await?;
23    println!(
24        "Quota: {} / {} remaining (status: {:?})",
25        quota.quota_remaining, quota.quota_total, quota.status
26    );
27
28    let actionable = serde_json::json!({
29        "kind": "propose_tool_call",
30        "tool": "transfer_funds",
31        "args": { "to": "0x000000000000000000000000000000000000dEaD", "amountWei": "1" },
32        "title": "[RUST] Transfer 1 wei to the burn address",
33        "summary": "[RUST] The agent is requesting approval to send 1 wei to the burn address.",
34    });
35
36    println!("Routing decision to {}...", target_address);
37    let resolution = client
38        .send_decision_and_wait_for_outcome(target_address, &actionable, None)
39        .await?;
40
41    println!(
42        "Outcome: {:?}, pending: {}",
43        resolution.outcome, resolution.pending
44    );
45    if resolution.outcome == NoxyHumanDecisionOutcome::Approved {
46        println!("User approved — continue agent loop.");
47    }
48
49    Ok(())
50}
Source

pub async fn get_quota(&self) -> Result<NoxyGetQuotaResponse, Status>

Examples found in repository?
examples/basic.rs (line 22)
10async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
11    let auth_token = std::env::var("NOXY_APP_TOKEN").expect("NOXY_APP_TOKEN must be set");
12    let target_address = std::env::var("NOXY_TARGET_ADDRESS").expect("NOXY_TARGET_ADDRESS must be set");
13
14    let config = NoxyConfig {
15        endpoint: NOXY_ENDPOINT.to_string(),
16        auth_token,
17        decision_ttl_seconds: 3600,
18    };
19
20    let client = init_noxy_agent_client(config).await?;
21
22    let quota = client.get_quota().await?;
23    println!(
24        "Quota: {} / {} remaining (status: {:?})",
25        quota.quota_remaining, quota.quota_total, quota.status
26    );
27
28    let actionable = serde_json::json!({
29        "kind": "propose_tool_call",
30        "tool": "transfer_funds",
31        "args": { "to": "0x000000000000000000000000000000000000dEaD", "amountWei": "1" },
32        "title": "[RUST] Transfer 1 wei to the burn address",
33        "summary": "[RUST] The agent is requesting approval to send 1 wei to the burn address.",
34    });
35
36    println!("Routing decision to {}...", target_address);
37    let resolution = client
38        .send_decision_and_wait_for_outcome(target_address, &actionable, None)
39        .await?;
40
41    println!(
42        "Outcome: {:?}, pending: {}",
43        resolution.outcome, resolution.pending
44    );
45    if resolution.outcome == NoxyHumanDecisionOutcome::Approved {
46        println!("User approved — continue agent loop.");
47    }
48
49    Ok(())
50}

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<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<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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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