Skip to main content

Crate brainos_intent

Crate brainos_intent 

Source
Expand description

§Brain Intent — Standardized Intent Token (SIT) schema

Provides the universal envelope (IntentToken) that classifiers emit and routers resolve into concrete tool invocations. The schema is wire-stable: the SCHEMA constant identifies the version of the envelope shape.

This crate is intentionally dependency-light — it defines data types and trait signatures only. Concrete classifier, router, registry and index implementations live in higher-level crates that compose this schema.

Modules§

sanitization
Treat MCP tool descriptions and tool outputs (and any other attacker-controllable text that flows into an LLM prompt) as untrusted input.
verbs
Canonical verb vocabulary for Brain’s capability kernel.

Structs§

BackendId
Opaque identifier for a native action backend (memory, web_search, …). Kept as a newtype to keep ToolRoute self-describing without forcing the schema crate to know about every backend in the workspace.
DefaultIntentRouter
Default IntentRouter that scores registered tools against a token and returns the highest-ranked candidate’s route. Pure-data routing — no embeddings (the semantic CapabilityIndex lands in a separate slice); this router relies on verb match plus capability overlap.
InMemoryToolRegistry
In-memory ToolRegistry backed by a RwLock<HashMap>. The default registry the MCP host and native backends register into on mount; the router queries this when resolving an IntentToken.
IntentToken
The universal envelope that flows from a classifier through a router into an executor. verb + object describe what the caller wants; required_capabilities and constraints describe under what conditions the action may run; provenance records who asked.
Object
ScoredTool
ToolAnnotations
ToolDescriptor
ToolUsage
Reasoner-facing usage guidance for a capability. This is what lets a planner or the chat reasoner choose the right tool instead of guessing from a one-line description: when it applies, when it does not, what must be true first, roughly what it costs, and the safety tier the action carries (awareness ≠ permission — execution is still gated by the consent/audit path; this string is purely descriptive).
Verb

Enums§

Constraint
IntentError
Provenance
ToolRoute
ToolSource

Constants§

SCHEMA
Wire identifier for the current SIT envelope. Bumped on any breaking change to IntentToken.

Traits§

BreakerCheck
Per-tool circuit-breaker snapshot. The router calls this for every candidate during IntentRouter::resolve; tools whose breaker is Open are excluded from scoring so a recently-failing tool can’t be chosen until the cooldown elapses. The concrete breaker lives in brainos-resilience; the trait keeps the schema crate independent of the resilience layer.
CapabilityIndex
Semantic top-k search over the registered tools. The default scoring strategy combines verb match, capability overlap, and embedding similarity against the token’s surface form.
IntentRouter
Resolves a token into a concrete invocation target. Implementations score candidates from a CapabilityIndex and return the best route.
ToolRegistry
Authoritative catalog of every tool the host can dispatch to. The MCP host and native backends register here on mount; the router queries here when resolving a token.