Skip to main content

Crate troupekit_kit

Crate troupekit_kit 

Source

Re-exports§

pub use knowledge::Knowledge;

Modules§

knowledge
Ingest a folder into a named vector index in the store file. Unchanged files are skipped by content hash, changed files are replaced whole, a file that fails is recorded and the walk goes on, and the sources of files gone from the folder are removed.
prelude
The names most programs need, for use troupekit::prelude::*;. Builder, built agent, outcome, storage, laws, errors and tools. AsTool, IntoToolOutput and Input stay at the crate root.

Structs§

Agent
Builds one agent from a name to an answer: model, instructions, tools, evals, limits, storage and laws. Setters never fail; build checks everything, reports the first problem and makes no model call. run and run_with build and run in one call.
AgentMemory
Long-term memory for one user and one session: facts about the user and a session summary, kept in a SQLite file. The agent gets the five memory tools, bound to this user and session, and by default the facts and summary are prepended to every run’s input.
BuiltAgent
An agent that passed every build check, ready to run many times. Cheap to clone and safe to share across tasks; each run gets its own state, and in-memory checkpoints are dropped after the run.
BuiltGraph
A graph that passed every build check, ready to run many times. Cheap to clone and safe to share across tasks; in-memory checkpoints are dropped after each run.
Graph
Builds a pipeline of agents and tool fns that run one after another. Each node reads the output of the node before it, the first reads the input; the last node’s output is the answer. Fan-out, routers and human nodes stay in workflow TOML.
GraphReport
The result of one finished graph run: the last node’s output, the whole state, usage, steps and the run id. Read it through the getters.
Input
What an agent runs on: one user text, or a prepared conversation. Built from &str, String, one Message or a Vec<Message>. An empty conversation fails when the run starts.
Json
Wraps any Serialize value so a tool can return it as JSON text. A serialize failure becomes an error output naming the failure. Use it for structs: Json(Point { x, y }).
Laws
The laws attached to an agent or graph, checked at build. 0.2 stores and validates them; no run proves them yet. auto asks the verifier to also derive laws from the code, and defaults to true.
RunOutcome
The result of one finished run: the answer and how it was reached. text is the answer as text; output is the raw final value. Read it through the getters.
Storage
Where an agent or graph keeps run checkpoints. memory() (the default) uses a fresh in-memory store per run, so nothing grows; sqlite(path) and custom(store) keep runs for resume.
ToolContext
Per-call context handed to every tool. Cheap to clone, so typed tool closures can own a copy across awaits. run_id names the run that made the call; idempotency_key is the same for a replayed call and new for every other, for tools that dedupe.
ToolOutput
What a tool returns to the model. is_error marks content that describes a failure the model may react to, such as an HTTP error status from a remote API.

Enums§

KitError
Every failure of the kit: builder settings, catalog and key problems, and the wrapped engine errors, plus run outcomes that are not an answer. Messages name the agent and the fix; they never hold an API key.
LocalChoice
Where an on-device model comes from: a row id of the built-in local catalog (&str), a GGUF file (PathBuf), or a loaded model (Arc<dyn LocalModel>). Converts with From; read at build.

Traits§

AsTool
Anything an agent or graph accepts as a tool: every Tool + 'static. A #[tool] fn and the tool(..) function form both qualify; an Arc<dyn Tool> goes through .tool_arc(..) instead.
IntoToolOutput
Converts a tool fn’s return value into what the model sees. Text, numbers, bool, (), JSON values, Json<T>, Option<T> and Result<T, E: Display> convert; an Err becomes an error output so the model can react to the failure instead of the run stopping.
Tool
A capability an agent can call: a spec the model sees and an async call. Object safe, so registries hold Arc<dyn Tool>. Arguments arrive as JSON already checked against spec().schema when called through a registry.

Functions§

tool
Builds a tool from argument type A and async fn f, without a macro. f takes the parsed arguments and returns any IntoToolOutput value; name and description are what the model sees. The schema is the same one typed_tool derives from A.

Attribute Macros§

agent
Turns fn calc() {} into a fn returning a configured Agent: the doc comment becomes the instructions and the fn name, _ read as -, the agent name. Keys such as model, tools = [add] and evals map to the builder methods of the same name.
tool
Turns a fn into a tool value: #[tool] async fn add(a: i64, b: i64) makes add a unit struct implementing Tool; the doc comment is the description, the arguments the schema, and the body stays callable as add::invoke(..). An imported add turns a let add binding into a unit-struct pattern: rename the binding or use the tool by path. Keys: name, description, crate.