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§
- Delegate
Request - What the guest sends to
circlet.delegate. - Delegation
- What a local agent returned, and what it cost.
- Fetch
Request - 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. - Fetch
Response - The response handed back into the circle.
- Guest
Error - A structured error crossing the guest boundary — returned by a guest
through
circlet.fail, or handed back to a caller bycirclet.invoke(InvokeError). - Intent
- The mind a call asks for — a bounded vocabulary, never a model name.
- Invoke
Request - What the guest sends to
circlet.invoke: run another action and give me its output. - Invoke
Response - 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 reservedprice_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.
- Secret
Need - One credential an artifact needs, and who is expected to supply it.
- Seed
- What
circlet.seedhands 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
Intentasks for. - Invoke
Outcome - What
Host::invokereturns when the host itself did not fault: either the sub-action’s output or a structuredInvokeError, each carrying what the sub-action actually spent inpixie. - 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
Intentaims for.
Constants§
- ABI_
VERSION - The Circlet guest ABI version this wire crate defines.
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
i64the ABI returns: pointer in the high 32 bits, length in the low 32. - unpack
- The inverse of
pack.
Type Aliases§
- Invoke
Error - A structured error returned to a guest by
circlet.invoke. - Invoke
Result - The postcard-encoded value
circlet.invokewrites back into guest memory: either the sub-action’s opaque output bytes or a structuredInvokeError.