Builds one agent in code or from a persona TOML, as the kit builder does.
Wraps the neutral AgentBuilder; every setter returns a new builder and
forwards unchanged. build validates everything.
A built agent: runs, starts, resumes and streams, as the kit’s BuiltAgent.
Wraps the neutral AgentHandle; every method forwards unchanged.
Safe to share between threads and to run concurrently.
Builds a graph of agents and tool steps, as the kit’s Graph does.
Wraps the neutral GraphBuilder; every setter returns a new builder and
forwards unchanged. build validates the graph.
A built graph: runs, starts, resumes and streams, as the kit’s BuiltGraph.
Wraps the neutral GraphHandle; every method forwards unchanged.
Safe to share between threads.
One HTTP header, mirrored from HostHeader.
Used in both directions: request headers out, reply headers back.
sensitive marks a credential; every text form shows it as [redacted].
An HTTP request for a host transport, mirrored from HostHttpRequest.
The neutral layer has already checked the URL against the vendor.
Input to the foreign HostTransport::send; its text forms redact the key.
One message of a host model request, mirrored from HostMessage.
Tool calls and the tool call id are JSON and text the Rust side rendered.
Input to the foreign HostModel::generate.
What a host model can do, mirrored from HostModelCaps.
Returned by the foreign HostModel::capabilities and read by Rust.
context_tokens is the model’s context window.
A host model’s whole reply, mirrored from HostReply.
Rust parses and validates text and tool_calls_json (native tool
calls, for a model whose caps set tools); token counts feed usage.
A request to a host model, mirrored from HostRequest.
Rust renders every field; the host passes them to its model as given.
Input to the foreign HostModel::generate.
Where a host transport pushes the reply, wrapping the neutral sink.
Input: the head once, then body chunks. Output: chunk returns false
once Rust stops reading (closed, cancelled or over the cap), and the
host must then stop reading and cancel the request.
Created by Rust and handed to HostTransport::send.
Knowledge settings for an agent, mirrored from KnowledgeConfig.
dir is the folder to ingest; index and store are optional paths.
Input to AgentBuilder::knowledge.
The events of one run, pulled with next or pushed to a listener.
Wraps the neutral RunStream; every method forwards unchanged.
Created by AgentHandle::stream and GraphHandle::stream.
Process-wide settings for initialize, mirrored from RuntimeSettings.
The neutral layer checks the bounds of plan section 8 (S1 to S3).
Input: worker threads, max caller string bytes, event buffer size.
Where a host model pushes its text deltas, wrapping the neutral sink.
Input: text pieces in order. Output: none; Rust caps the total bytes.
Created by Rust and handed to HostModel::generate.
Token counts and cost of a step or a run, mirrored from FfiUsage.
Output only: built from the neutral value, never read back.
Cost is in millionths of a US dollar.
Stable numeric code of every failure, mirrored from the neutral ErrorCode.
Swift and Kotlin compare TroupekitError.code against these numbers.
The numbers are fixed forever and checked by error_code_survives_conversion.
What happened in one run event, mirrored from FfiEventKind.
Lifecycle kinds are never dropped; TextDelta may be when the buffer
is full (RunStream::dropped_deltas). Output only.
Error a Swift or Kotlin host callback returns; the neutral layer turns it
into a tool error output, a model failure or a transport failure.
Input: the foreign text as detail, named so for the same Kotlin clash.
Output: the neutral HostError with that text.
The one error Swift and Kotlin see: the neutral FfiError with its code
as a number, so a code added later still reaches the app unchanged.
Input: a neutral error. Output: Failure { code, detail, run_id }; the
text is detail because a Kotlin exception field named message clashes
with Throwable.message in the generated code.
Receives every event of a run, implemented in Swift or Kotlin.
Called on a Rust worker thread, never on the caller’s thread.
Input: one event. Output: none.
An embedder implemented in Swift or Kotlin, used for knowledge.
embed returns one vector of dims floats per text, in order.
Rust checks the shape and the batch size.
A model implemented in Swift or Kotlin, such as an on-device model.
generate pushes text deltas into sink and returns the whole reply;
Rust renders the request and parses the reply.
A tool implemented in Swift or Kotlin and called by the agent.
schema_json is a JSON Schema object; call gets the arguments as JSON
and returns the output text, or a HostError the model sees.
An HTTP stack implemented in Swift or Kotlin, used for model calls only.
send calls sink.head once, then sink.chunk per body chunk, then
returns; Rust has already checked the URL against the vendor.
Receives every trace record of a traced build or run, implemented in
Swift or Kotlin: the callback form of trace_jsonl. Called on the
thread that writes the record; keys are scrubbed before the call.
Input: one JSON object on one line, no newline. Output: none.
Sets the process-wide runtime once, before the first agent is built.
Exported as initialize (freeze open question Q2). Input: the settings.
Output: the neutral layer’s result, its error converted.