Skip to main content

Crate wabot_feature_mindset

Crate wabot_feature_mindset 

Source
Expand description

§wabot-feature-mindset

Rust port of wabot-ts/src/feature/mindset. Provides:

  • The Mindset trait — what user code implements to describe a bot’s personality and preferred LLM models. Mirrors IMindset.
  • The MindsetOperator — the boring runtime that turns a Mindset + a set of tools into a system prompt and a function dispatcher. Mirrors MindsetOperator.
  • MindsetCache — opt-in reuse of a mindset’s description across chats and messages.

Tools themselves live in wabot_feature_tool, shared with the agent feature; the #[tools] / #[tool] macros in wabot-macros generate the per-impl-block plumbing that feeds it.

§The shape of a mindset

Mindset::describe returns the whole persona in one call, which is what makes MindsetCache possible — one await to memoize rather than five independent ones that could each see different state:

ⓘ
#[async_trait]
impl Mindset for ElisaMindset {
    async fn describe(&self) -> MindsetDescription {
        MindsetDescription::new(MindsetIdentity::new("Elisa", "spanish"))
            .with_context(self.store.summary().await)
            .with_skills("Answer questions about orders.")
    }
    async fn models(&self) -> MindsetModels {
        MindsetModels::new().with(ModelKind::Llm, vec![MindsetModelRef::new("claude-opus-5")])
    }
}

Re-exports§

pub use agents::mindset_agent_tools_provider;
pub use agents::register_mindset_agent_tools_provider;
pub use agents::DynMindsetAgentToolsProvider;
pub use agents::MindsetAgentBinding;
pub use agents::MindsetAgentTools;
pub use agents::MindsetAgentToolsProvider;
pub use cache::LoadedMindset;
pub use cache::MindsetCache;
pub use cache::MindsetCacheConfig;

Modules§

agents
The seam between mindsets and agents. Port of wabot-ts/src/feature/mindset/IMindsetAgentToolsProvider.ts.
cache
Process-global cache of loaded mindset descriptions. Port of wabot-ts/src/feature/mindset/MindsetCache.ts.

Structs§

MindsetDescription
Everything a mindset says about itself. Mirrors IMindsetDescription.
MindsetIdentity
Per-bot identity. Mirrors IMindsetIdentity in TS.
MindsetModelRef
Lightweight model identifier — same fields as IMindsetModelRef.
MindsetModels
Models grouped by kind. Default returns an empty set.
MindsetOperator
The mindset-driven runtime that ChatBot consumes.
ToolDefinition
A tool the model can call: its schema plus a type-erased async body. #[tools] emits one of these per method.
ToolGate
Which tools are reachable in a given context.
ToolInvoker
Turns tool definitions into an LLM schema and dispatches calls.
ToolParameter
One parameter of a tool, as the model sees it.
ToolSchema
Provider-neutral tool description shipped to the LLM. Shared by mindsets and agents; the chat adapters know this type.

Enums§

ModelKind
Modality of an LLM the mindset can request. Mirrors IMindsetModelKind. The operator falls back to Llm for VisionLlm/AudioLlm when the mindset hasn’t supplied a more specific model — matches the TS MODEL_KIND_FALLBACK table.
ToolError
What a tool invocation can go wrong with.

Traits§

Mindset
What user mindsets implement. Mirrors IMindset: a persona (Mindset::describe) and the models to run it on (Mindset::models).

Functions§

normalize_optional_arguments
Drop optional arguments the model declined to fill in.
parse_tool_arguments
Parse a tool’s JSON arguments into its args struct: normalize the optional ones, deserialize, then validate.

Type Aliases§

MindsetError
Alias of ToolError.
MindsetTool
The tool schema an adapter ships to the model. Alias of ToolSchema, which mindsets and agents share — same relationship IMindsetTool has to IToolSchema in TS.
MindsetToolDefinition
Alias of ToolDefinition, what #[tools] emits per method.
MindsetToolParameter
Alias of ToolParameter.
ToolInvokeFn
Deserialize + validate + dispatch + stringify, all inside the closure the macro emits.