Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

Long-lived protocol-1 WebSocket client.

Implementations§

Source§

impl Client

Source

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

Create a client for url.

Source

pub fn with_config(cfg: ClientConfig) -> Self

Create with explicit config.

Source

pub fn url(&self) -> &str

Daemon URL.

Source

pub fn is_connected(&self) -> bool

Whether the socket is connected.

Source

pub fn is_connection_alive(&self) -> bool

Whether the reader task is alive.

Source

pub fn is_handshake_complete(&self) -> bool

Whether the protocol-1 handshake has completed.

Source

pub async fn readiness_state(&self) -> String

Daemon readiness_state from the last connection_ack (empty before handshake).

Source

pub fn inbound_dropped(&self) -> u64

Count of dropped inbound frames under backpressure.

Source

pub fn set_stream_degraded_callback( &self, cb: Option<Arc<dyn Fn(u64, String) + Send + Sync>>, )

Register a hook invoked on the first inbound overflow drop.

Source

pub fn enable_heartbeat_tracking(&self) -> Arc<HeartbeatTracker>

Enable heartbeat tracking with the default 15s alive threshold.

Source

pub fn enable_heartbeat_tracking_with_threshold( &self, threshold: Duration, ) -> Arc<HeartbeatTracker>

Enable heartbeat tracking with a custom alive threshold.

Source

pub fn disable_heartbeat_tracking(&self)

Disable heartbeat tracking.

Source

pub fn heartbeat_tracker(&self) -> Option<Arc<HeartbeatTracker>>

Current heartbeat tracker, if enabled.

Source

pub fn is_daemon_alive(&self) -> bool

Whether the tracked daemon is considered alive (true if tracking disabled).

Source

pub async fn disconnect_cause(&self) -> Option<DisconnectCause>

Disconnect cause if disconnected.

Source

pub async fn wait_disconnected(&self) -> DisconnectCause

Wait until disconnected.

Source

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

Dial + handshake (connection_init / connection_ack ready).

Source

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

Close the connection.

Source

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

Re-dial and re-handshake after a connection drop.

Does not re-establish loop subscriptions; follow with Self::reattach_and_probe to resume a loop session.

Source

pub async fn send_envelope(&self, env: Envelope) -> Result<()>

Send a raw envelope.

Source

pub async fn notify( &self, method: &str, params: Map<String, Value>, ) -> Result<()>

Fire-and-forget notification.

Source

pub async fn request( &self, method: &str, params: Map<String, Value>, req_timeout: Duration, ) -> Result<Map<String, Value>>

RPC request correlated by id.

Source

pub async fn request_response( &self, payload: Map<String, Value>, fallback_method: &str, req_timeout: Duration, ) -> Result<Map<String, Value>>

Request with a payload map that may include a type field as the method name (Go RequestResponse parity).

Source

pub async fn subscribe( &self, method: &str, params: Map<String, Value>, req_timeout: Duration, ) -> Result<String>

Subscribe; returns subscription id.

Source

pub async fn unsubscribe(&self, id: &str) -> Result<()>

Unsubscribe by id.

Source

pub async fn read_event(&self) -> Result<Option<Value>>

Read next inbound app event (blocks).

Source

pub async fn read_event_with_timeout( &self, dur: Duration, ) -> Result<Option<Value>>

Read with timeout; None on timeout.

Source

pub async fn clear_pending_events(&self)

Clear pending inbound events.

Source

pub async fn peel_stale_pending_control_events(&self) -> Vec<String>

Peel stale pending control frames at turn start.

Source

pub async fn push_pending_event(&self, ev: Value)

Re-queue an event ahead of subsequent Client::read_event calls.

Applies priority-aware drop when the pending buffer is full (Go PushPendingEvent parity).

Source

pub fn set_inbound_max_size(&self, n: usize)

Override the pending-event cap at runtime (Go SetInboundMaxSize parity).

Source

pub fn receive_messages(&self, buffer: usize) -> Receiver<Value>

Spawn a background reader that streams inbound frames on a channel.

The channel closes when the connection ends or the client disconnects. Solicited frames (RPC responses / subscription confirmations) are still routed through the internal mux and are NOT forwarded on this channel; only unsolicited app events are forwarded (Go ReceiveMessages parity).

Heartbeat, ping/pong, and delivery-ack handling are still performed by the internal reader task; this method exposes the already-routed inbound queue as a channel for consumers that prefer pull-style streaming.

Source

pub async fn send_input(&self, text: &str, opts: SendInputOptions) -> Result<()>

Notify loop_input.

Source

pub async fn loop_new( &self, params: Map<String, Value>, ) -> Result<Map<String, Value>>

loop_new RPC.

Source

pub async fn loop_list(&self, limit: u32) -> Result<Map<String, Value>>

loop_list.

Source

pub async fn loop_get(&self, loop_id: &str) -> Result<Map<String, Value>>

loop_get.

Source

pub async fn loop_reattach(&self, loop_id: &str) -> Result<Map<String, Value>>

loop_reattach.

Source

pub async fn loop_subscribe( &self, loop_id: &str, stream_delivery: &str, ) -> Result<String>

Subscribe to loop_events.

Source

pub async fn loop_cards_fetch( &self, loop_id: &str, ) -> Result<Map<String, Value>>

loop_cards_fetch.

Source

pub async fn loop_history_fetch( &self, loop_id: &str, ) -> Result<Map<String, Value>>

loop_history_fetch.

Source

pub async fn loop_messages( &self, loop_id: &str, limit: u32, offset: u32, ) -> Result<Map<String, Value>>

loop_messages.

Source

pub async fn loop_state_get(&self, loop_id: &str) -> Result<Map<String, Value>>

loop_state_get.

Source

pub async fn loop_state_update( &self, loop_id: &str, state: Map<String, Value>, ) -> Result<Map<String, Value>>

loop_state_update.

Source

pub async fn loop_tree( &self, loop_id: &str, format: Option<&str>, ) -> Result<Map<String, Value>>

loop_tree.

Source

pub async fn loop_prune( &self, loop_id: &str, retention_days: Option<i32>, dry_run: bool, ) -> Result<Map<String, Value>>

loop_prune.

Source

pub async fn loop_delete(&self, loop_id: &str) -> Result<Map<String, Value>>

loop_delete.

Source

pub async fn loop_detach(&self, subscription_id: &str) -> Result<()>

Detach from a loop by unsubscribing (subscription_id from loop_subscribe).

Source

pub async fn authenticate( &self, access_key: &str, secret_key: &str, ) -> Result<Map<String, Value>>

Authenticate with access/secret keys.

Source

pub async fn refresh_auth_token( &self, refresh_token: &str, ) -> Result<Map<String, Value>>

Refresh auth token.

Source

pub async fn job_create( &self, goal: &str, workspace: Option<&str>, ) -> Result<Map<String, Value>>

job_create on this long-lived connection.

Source

pub async fn job_status(&self, job_id: &str) -> Result<Map<String, Value>>

job_status.

Source

pub async fn job_pause(&self, job_id: &str) -> Result<Map<String, Value>>

job_pause.

Source

pub async fn job_resume(&self, job_id: &str) -> Result<Map<String, Value>>

job_resume.

Source

pub async fn job_cancel(&self, job_id: &str) -> Result<Map<String, Value>>

job_cancel.

Source

pub async fn job_dag(&self, job_id: &str) -> Result<Map<String, Value>>

job_dag.

Source

pub async fn job_guidance( &self, job_id: &str, content: &str, goal_id: Option<&str>, ) -> Result<Map<String, Value>>

job_guidance.

Source

pub async fn autopilot_status(&self) -> Result<Map<String, Value>>

autopilot_status.

Source

pub async fn autopilot_submit( &self, description: &str, priority: i32, workspace: Option<&str>, ) -> Result<Map<String, Value>>

autopilot_submit.

Source

pub async fn autopilot_list_goals(&self) -> Result<Map<String, Value>>

autopilot_list_goals.

Source

pub async fn autopilot_get_goal( &self, goal_id: &str, ) -> Result<Map<String, Value>>

autopilot_get_goal.

Source

pub async fn autopilot_cancel_goal( &self, goal_id: &str, ) -> Result<Map<String, Value>>

autopilot_cancel_goal.

Source

pub async fn autopilot_cancel_all(&self) -> Result<Map<String, Value>>

autopilot_cancel_all.

Source

pub async fn autopilot_wake(&self) -> Result<Map<String, Value>>

autopilot_wake.

Source

pub async fn autopilot_dream(&self) -> Result<Map<String, Value>>

autopilot_dream.

Source

pub async fn autopilot_resume( &self, goal_id: &str, ) -> Result<Map<String, Value>>

autopilot_resume.

Source

pub async fn autopilot_list_jobs(&self) -> Result<Map<String, Value>>

autopilot_list_jobs.

Source

pub async fn autopilot_get_job( &self, job_id: &str, ) -> Result<Map<String, Value>>

autopilot_get_job.

Source

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

Subscribe to autopilot_events (long-lived worker stream).

Source

pub async fn autopilot_unsubscribe(&self, subscription_id: &str) -> Result<()>

Unsubscribe from an autopilot events subscription.

Source

pub async fn cron_add( &self, text: &str, priority: Option<i32>, ) -> Result<Map<String, Value>>

cron_add.

Source

pub async fn cron_list( &self, status: Option<&str>, ) -> Result<Map<String, Value>>

cron_list.

Source

pub async fn cron_show(&self, job_id: &str) -> Result<Map<String, Value>>

cron_show.

Source

pub async fn cron_cancel(&self, job_id: &str) -> Result<Map<String, Value>>

cron_cancel.

Source

pub async fn memory_stats(&self, mode: &str) -> Result<Map<String, Value>>

memory_stats.

Source

pub async fn list_skills(&self) -> Result<Map<String, Value>>

skills_list.

Source

pub async fn list_models(&self) -> Result<Map<String, Value>>

models_list.

Source

pub async fn mcp_status(&self) -> Result<Map<String, Value>>

mcp_status.

Source

pub async fn fetch_daemon_status(&self) -> Result<Map<String, Value>>

daemon_status.

Source

pub async fn invoke_skill( &self, skill: &str, args: &str, ) -> Result<Map<String, Value>>

invoke_skill on this connection (stream socket for turn enqueue).

Source

pub async fn reattach_and_probe(&self, loop_id: &str) -> Result<()>

Reattach + subscribe + loop_get probe.

Source

pub async fn command_request( &self, command: &str, loop_id: Option<&str>, params: Option<Map<String, Value>>, ) -> Result<Map<String, Value>>

command_request RPC (structured slash command).

Mirrors Go CommandRequest. Default timeout 30s.

Source

pub async fn command_clear(&self, loop_id: &str) -> Result<Map<String, Value>>

/clear — clear loop conversation history.

Source

pub async fn command_exit(&self, loop_id: &str) -> Result<Map<String, Value>>

/exit — stop the loop and mark for exit.

Source

pub async fn command_quit(&self, loop_id: &str) -> Result<Map<String, Value>>

/quit — alias for /exit.

Source

pub async fn command_detach(&self, loop_id: &str) -> Result<Map<String, Value>>

/detach — mark the loop as detached (continues running server-side).

Source

pub async fn command_cancel(&self, loop_id: &str) -> Result<Map<String, Value>>

/cancel — cancel the running query.

Source

pub async fn command_memory(&self, loop_id: &str) -> Result<Map<String, Value>>

/memory — query memory stats.

Source

pub async fn command_policy(&self) -> Result<Map<String, Value>>

/policy — query the active policy profile.

Source

pub async fn command_history(&self, loop_id: &str) -> Result<Map<String, Value>>

/history — query input history.

Source

pub async fn command_config(&self) -> Result<Map<String, Value>>

/config — query daemon configuration.

Source

pub async fn command_review(&self, loop_id: &str) -> Result<Map<String, Value>>

/review — query conversation review.

Source

pub async fn command_plan(&self, loop_id: &str) -> Result<Map<String, Value>>

/plan — query current plan.

Source

pub async fn command_autopilot_dashboard( &self, loop_id: &str, ) -> Result<Map<String, Value>>

/autopilot_dashboard — show autopilot dashboard.

Source

pub async fn wait_for_daemon_ready( &self, timeout: Duration, ) -> Result<Map<String, Value>>

Wait for the protocol-1 connection_ack handshake to report readiness_state == "ready".

Returns immediately when the handshake already completed during Client::connect; otherwise polls inbound frames for an out-of-band connection_ack. Default timeout 10s (Go WaitForDaemonReady parity).

Source§

impl Client

Source

pub async fn send_command(&self, cmd: &str) -> Result<()>

Fire slash_command notification (Go SendCommand parity).

Source

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

Fire disconnect notification (Go SendDetach parity).

Source

pub async fn send_daemon_status(&self, request_id: &[&str]) -> Result<()>

Send daemon_status request envelope (Go SendDaemonStatus parity).

Source

pub async fn send_daemon_shutdown(&self, request_id: &[&str]) -> Result<()>

Send daemon_shutdown request envelope (Go SendDaemonShutdown parity).

Source

pub async fn send_config_get( &self, section: &str, request_id: &[&str], ) -> Result<()>

Send config_get request envelope (Go SendConfigGet parity).

Source

pub async fn send_config_reload(&self, request_id: &[&str]) -> Result<()>

Send config_reload request envelope (Go SendConfigReload parity).

Source

pub async fn send_skills_list(&self, request_id: &[&str]) -> Result<()>

Send skills_list request envelope (Go SendSkillsList parity).

Source

pub async fn send_models_list(&self, request_id: &[&str]) -> Result<()>

Send models_list request envelope (Go SendModelsList parity).

Source

pub async fn send_invoke_skill( &self, skill: &str, args: &str, request_id: &[&str], ) -> Result<()>

Send invoke_skill request envelope (Go SendInvokeSkill parity).

Source

pub async fn send_mcp_status(&self, request_id: &[&str]) -> Result<()>

Send mcp_status request envelope (Go SendMCPStatus parity).

Source

pub async fn send_loop_list( &self, filter: Option<Map<String, Value>>, limit: u32, request_id: &[&str], ) -> Result<()>

Send loop_list request envelope (Go SendLoopList parity).

Source

pub async fn send_loop_get( &self, loop_id: &str, verbose: bool, request_id: &[&str], ) -> Result<()>

Send loop_get request envelope (Go SendLoopGet parity).

Source

pub async fn send_loop_tree( &self, loop_id: &str, format: &str, request_id: &[&str], ) -> Result<()>

Send loop_tree request envelope (Go SendLoopTree parity).

Source

pub async fn send_loop_prune( &self, loop_id: &str, keep_latest: u32, request_id: &[&str], ) -> Result<()>

Send loop_prune request envelope (Go SendLoopPrune parity).

Source

pub async fn send_loop_delete( &self, loop_id: &str, request_id: &[&str], ) -> Result<()>

Send loop_delete request envelope (Go SendLoopDelete parity).

Source

pub async fn send_loop_reattach( &self, loop_id: &str, request_id: &[&str], ) -> Result<()>

Send loop_reattach request envelope (Go SendLoopReattach parity).

Source

pub async fn send_loop_subscribe( &self, loop_id: &str, wire_tier: &str, stream_delivery: &str, request_id: &[&str], ) -> Result<()>

Send loop_events subscribe envelope (Go SendLoopSubscribe parity).

Pass empty wire_tier / stream_delivery to omit those fields.

Source

pub async fn send_loop_detach( &self, loop_id: &str, request_id: &[&str], ) -> Result<()>

Send unsubscribe by subscription id (Go SendLoopDetach parity).

When request_id is empty, loop_id is used as the subscription id.

Source

pub async fn send_loop_new( &self, client_workspace: &str, user_id: &str, client_workspace_id: &str, is_ephemeral: bool, request_id: &[&str], ) -> Result<()>

Send loop_new request envelope (Go SendLoopNew parity).

Source

pub async fn send_loop_input(&self, loop_id: &str, content: &str) -> Result<()>

Send loop_input notification (Go SendLoopInput parity).

Source

pub async fn send_loop_messages( &self, loop_id: &str, limit: u32, offset: u32, include_events: bool, request_id: &[&str], ) -> Result<()>

Send loop_messages request envelope (Go SendLoopMessages parity).

Source

pub async fn send_loop_state_get( &self, loop_id: &str, request_id: &[&str], ) -> Result<()>

Send loop_state_get request envelope (Go SendLoopStateGet parity).

Source

pub async fn send_loop_state_update( &self, loop_id: &str, values: Map<String, Value>, as_node: &str, request_id: &[&str], ) -> Result<()>

Send loop_state_update request envelope (Go SendLoopStateUpdate parity).

Source

pub async fn send_loop_cards_fetch( &self, loop_id: &str, request_id: &[&str], ) -> Result<()>

Send loop_cards_fetch request envelope (Go SendLoopCardsFetch parity).

Source

pub async fn send_loop_history_fetch( &self, loop_id: &str, request_id: &[&str], ) -> Result<()>

Send loop_history_fetch request envelope (Go SendLoopHistoryFetch parity).

Source

pub async fn send_auth( &self, access_key: &str, secret_key: &str, request_id: &[&str], ) -> Result<()>

Send auth request envelope (Go SendAuth parity).

Source

pub async fn send_auth_refresh( &self, refresh_token: &str, request_id: &[&str], ) -> Result<()>

Send auth_refresh request envelope (Go SendAuthRefresh parity).

Source

pub async fn send_cron_add( &self, text: &str, priority: i32, request_id: &[&str], ) -> Result<()>

Send cron_add request envelope (Go SendCronAdd parity).

Source

pub async fn send_cron_list( &self, status: &str, request_id: &[&str], ) -> Result<()>

Send cron_list request envelope (Go SendCronList parity).

Source

pub async fn send_cron_show( &self, job_id: &str, request_id: &[&str], ) -> Result<()>

Send cron_show request envelope (Go SendCronShow parity).

Source

pub async fn send_cron_cancel( &self, job_id: &str, request_id: &[&str], ) -> Result<()>

Send cron_cancel request envelope (Go SendCronCancel parity).

Source

pub async fn send_job_create( &self, goal: &str, workspace: Option<&str>, request_id: &[&str], ) -> Result<()>

Fire-and-forget job_create (Go SendJobCreate parity).

Source

pub async fn send_job_status( &self, job_id: &str, request_id: &[&str], ) -> Result<()>

Fire-and-forget job_status (Go SendJobStatus parity).

Source

pub async fn send_job_pause( &self, job_id: &str, request_id: &[&str], ) -> Result<()>

Fire-and-forget job_pause (Go SendJobPause parity).

Source

pub async fn send_job_resume( &self, job_id: &str, request_id: &[&str], ) -> Result<()>

Fire-and-forget job_resume (Go SendJobResume parity).

Source

pub async fn send_job_cancel( &self, job_id: &str, request_id: &[&str], ) -> Result<()>

Fire-and-forget job_cancel (Go SendJobCancel parity).

Source

pub async fn send_job_dag( &self, job_id: &str, request_id: &[&str], ) -> Result<()>

Fire-and-forget job_dag (Go SendJobDag parity).

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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