Skip to main content

Crate circlet_wire

Crate circlet_wire 

Source
Expand description

The Circlet wire contract — the one definition both sides compile.

Everything that crosses the guest boundary is described here: the envelope for each host import, the codec that carries it, and the packed (pointer, length) layout results ride home in. The host crate (circlet) re-exports these types; the guest SDK (circlet-guest) consumes them. Neither side declares its own copy, so the contract cannot drift — and the encoded bytes are pinned by test in this crate, where a change has to announce itself.

§One encoding

Envelopes are postcard: compact, no intermediate string, no field names on the wire, byte slices carried as bytes rather than arrays of decimal numbers. There is exactly one encoding and nothing to negotiate — an option whose weaker arm nobody should pick is not an option, it is a liability, and a codec chosen per artifact is a second wire to keep in step forever.

Two things that are deliberately NOT this codec:

  • Cast input and output. Opaque bytes to Circlet, whatever the embedder puts there.
  • Documents. Receipts and recorded transcripts are JSON: they are read by people and by other systems, long after the run, at a standards edge. A live wire and a stored document want opposite things.

This crate depends on serde and postcard alone: it compiles for wasm32-unknown-unknown inside every guest, so it assumes nothing beyond an allocator.

Structs§

DelegateRequest
What the guest sends to circlet.delegate.
Delegation
What a local agent returned, and what it cost.
FetchRequest
An outbound HTTP request as the guest describes it. Circlet validates the host, substitutes secrets, and hands the finished request to the embedder’s Host.
FetchResponse
The response handed back into the circle.
Intent
The mind a call asks for — a bounded vocabulary, never a model name.
InvokeRequest
What the guest sends to circlet.invoke: run another action and give me its output.
InvokeResponse
What the embedder hands back: the sub-action’s output and what it cost.
LlmChunk
One chunk of a model stream, and what it cost.
LlmRequest
What the guest sends to circlet.llm_open.
Price
What the guest sends to circlet.price: what its most recent developer-priced fetch was actually worth, once the response has shown (per result returned, per byte delivered — the author’s own pricing logic). Must be at or under the reserved price_max; the difference returns to the payer’s grant. Above the max is a typed trap, never a bill.
Requirements
What an artifact requires to run, declared by the code that requires it.
SecretNeed
One credential an artifact needs, and who is expected to supply it.
Seed
What circlet.seed hands the guest: the host-stamped wall clock and a random seed — the ONLY nondeterminism a guest can ever see, delivered as a recorded input rather than an ambient power. One pair per cast: every call inside one cast returns the same values (a reflex is conceptually instantaneous), the transcript records them once, and replay serves the recording — so “what time is it” stops being the reason a guest author reaches outside the circle, and determinism survives.

Enums§

Effort
How much deliberation an Intent asks for.
Owner
Who supplies a secret. A bounded vocabulary, like every other one that crosses a boundary: an unknown word is refused rather than guessed at.
Tier
The quality/latency corner an Intent aims for.

Functions§

decode
Decode an envelope from the boundary.
encode
Encode an envelope for the boundary.
pack
Pack a guest (pointer, length) pair into the one i64 the ABI returns: pointer in the high 32 bits, length in the low 32.
unpack
The inverse of pack.