pub struct WpsClient {
inner: Arc<Client>,
endpoint: String,
auth_key: String,
}Expand description
Per-launch sidecar config + reusable HTTP client. Cheap to clone
(the inner reqwest::Client uses Arc internally).
Fields§
§inner: Arc<Client>§endpoint: String§auth_key: StringImplementations§
Source§impl WpsClient
impl WpsClient
Sourcepub fn from_env() -> Option<Self>
pub fn from_env() -> Option<Self>
Build a client from the env. Returns None when the required
env vars are missing — the caller surfaces a system chunk
rather than crashing.
Sourcepub async fn publish_chunk(
&self,
block_id: Option<&str>,
payload: &ToolChunk,
) -> Result<()>
pub async fn publish_chunk( &self, block_id: Option<&str>, payload: &ToolChunk, ) -> Result<()>
Publish a tool_chunk event. The tool_use_id lives in the
payload (not on this method’s signature) so a single per-block
subscription receives chunks for every tool in that block.
Persists with TOOL_CHUNK_PERSIST so late subscribers (the
frontend, which learns about the tool_use only after Claude
buffers the stream) get the full history on subscribe.
Sourcepub async fn publish_compaction_started(
&self,
block_id: Option<&str>,
payload: &CompactionStarted,
) -> Result<()>
pub async fn publish_compaction_started( &self, block_id: Option<&str>, payload: &CompactionStarted, ) -> Result<()>
Publish a compaction_started event — the PreCompact-hook
signal that fires the instant Claude Code begins compacting.
persist = 0: live subscribers only, never replayed — see
COMPACTION_STARTED_PERSIST’s doc comment. Uses
COMPACTION_STARTED_TIMEOUT (much shorter than the client-wide
default) since this call sits on a synchronous hook Claude Code
blocks compaction on — see that constant’s doc comment.
Sourcepub async fn post_json(
&self,
path: &str,
agent_token: Option<&str>,
body: &impl Serialize,
timeout: Duration,
) -> Result<Value>
pub async fn post_json( &self, path: &str, agent_token: Option<&str>, body: &impl Serialize, timeout: Duration, ) -> Result<Value>
POST body as JSON to path on the sidecar and return its JSON
reply. agent_token goes out as X-Agent-Token, so the sidecar
knows which agent is asking (an agent’s own env carries it as
AGENTMUX_AGENT_TOKEN). timeout replaces the client-wide default:
callers on a synchronous hook must not wait long.
Sourceasync fn publish(
&self,
event: &str,
persist: usize,
block_id: Option<&str>,
payload: &impl Serialize,
timeout_override: Option<Duration>,
) -> Result<()>
async fn publish( &self, event: &str, persist: usize, block_id: Option<&str>, payload: &impl Serialize, timeout_override: Option<Duration>, ) -> Result<()>
Shared publish path for every MPS event this crate emits.
event/persist vary per call site; the scoping (block:<id>)
and auth/error-handling are identical across all of them.
timeout_override replaces the client-wide default
(reqwest::RequestBuilder::timeout overrides per-request) when
Some — used by call sites sitting on a synchronous caller that
must not inherit from_env’s more generous streaming timeout.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for WpsClient
impl !UnwindSafe for WpsClient
impl Freeze for WpsClient
impl Send for WpsClient
impl Sync for WpsClient
impl Unpin for WpsClient
impl UnsafeUnpin for WpsClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more