Skip to main content

Client

Struct Client 

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

A thin async client for the kindling daemon.

Cheap to clone-by-config; construct once and share a reference. Each call opens a fresh connection (no pooling), so the client itself holds no live socket and is Send + Sync.

Implementations§

Source§

impl Client

Source

pub fn new() -> Result<Client, ClientError>

Build a client from the default ClientConfig: socket at ~/.kindling/kindling.sock, project root from the current directory, the compiled schema version, a 1s connect budget, and the real binary spawner.

Source

pub fn with_config(config: ClientConfig) -> Client

Build a client from an explicit ClientConfig.

Source

pub fn config(&self) -> &ClientConfig

The configuration this client was built with.

Source

pub async fn health(&self) -> Result<Health, ClientError>

GET /v1/health — version, schema version, and touched project ids.

Verifies the daemon’s schemaVersion matches ClientConfig::expected_schema_version; returns ClientError::SchemaMismatch if not (fail loud).

Source

pub async fn open_capsule( &self, kind: CapsuleType, intent: impl Into<String>, scope_ids: ScopeIds, id: Option<String>, ) -> Result<Capsule, ClientError>

POST /v1/capsules — open a capsule.

Source

pub async fn get_open_capsule( &self, session_id: &str, ) -> Result<Option<Capsule>, ClientError>

GET /v1/capsules/open?sessionId=… — the open session capsule for session_id, or None when none is open.

Each Claude Code hook is a fresh process holding only the session id, so the Stop hook resolves the capsule it must close through this endpoint rather than tracking it in-process.

Source

pub async fn close_capsule( &self, capsule_id: &str, body: CloseCapsuleBody, ) -> Result<Capsule, ClientError>

PATCH /v1/capsules/:id/close — close a capsule.

Source

pub async fn append_observation( &self, input: ObservationInput, capsule_id: Option<String>, validate: Option<bool>, ) -> Result<AppendResult, ClientError>

POST /v1/observations — append an observation, optionally attaching it to capsule_id and toggling service-side validate (default true).

Returns an AppendResult carrying the stored observation and the daemon’s deduplicated flag. A duplicate id is not an error: the daemon ignores the write and returns the pre-existing row with deduplicated: true, so replaying an already-delivered observation is a no-op.

Source

pub async fn retrieve( &self, options: RetrieveOptions, ) -> Result<RetrieveResult, ClientError>

POST /v1/retrieve — deterministic ranked retrieval.

Source

pub async fn list_observations( &self, request: ListObservationsRequest, ) -> Result<ListObservationsResult, ClientError>

POST /v1/observations/list — exhaustive, deterministically-paginated observation list (FTS-independent; kind / scope / half-open time-range filters with a keyset cursor). Returns one page; pass back ListObservationsResult::next_cursor as ListObservationsRequest::cursor until it is None.

Source

pub async fn pin(&self, body: CreatePinBody) -> Result<Pin, ClientError>

POST /v1/pins — create a pin.

Source

pub async fn unpin(&self, pin_id: &str) -> Result<(), ClientError>

DELETE /v1/pins/:id — remove a pin.

Source

pub async fn forget(&self, observation_id: &str) -> Result<(), ClientError>

POST /v1/observations/:id/forget — redact an observation (content replaced with [redacted], redacted flag set). Succeeds on 204.

A missing id surfaces as ClientError::Api with status 404 (the daemon maps the store’s ObservationNotFound). The observation_id must be exact — prefix resolution is a higher-layer concern.

Source

pub async fn session_start_context( &self, max_results: Option<u32>, ) -> Result<Option<String>, ClientError>

POST /v1/context/session-start — the assembled + formatted SessionStart injection markdown, or None when there is nothing to inject.

The daemon owns the formatting (recency-ordered observations, pin previews, and the toLocaleString-parity dates). max_results caps the recent-observation count (default 10 when None). The project scope is derived from this client’s project root, reproducing the Node hook’s { repoId: <project root> } filter within the project database.

Source

pub async fn pre_compact_context(&self) -> Result<Option<String>, ClientError>

POST /v1/context/pre-compact — the assembled + formatted PreCompact injection markdown (pinned items + latest session summary), or None when there is nothing to inject.

As with Self::session_start_context, the project scope is derived from this client’s project root.

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
Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. 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<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> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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