Skip to main content

Crate troupekit_tools

Crate troupekit_tools 

Source
Expand description

Tools for Troupekit agents: one Tool trait, a registry that checks arguments against each tool’s JSON Schema, typed tools from serde structs, an SSRF-guarded HTTP client, web fetch, web search and declarative HTTP tools. Third-party text is always fenced as untrusted.

Re-exports§

pub use declarative::http_toolkit_from_toml;
pub use fetch::web_fetch;
pub use http::is_public_ip;
pub use http::receive;
pub use http::HttpLimits;
pub use http::Received;
pub use http::GuardedHttp;
pub use registry::compile_schema;
pub use registry::schema_errors;
pub use registry::valid_tool_name;
pub use registry::ToolRegistry;
pub use registry::Toolkit;
pub use search::BraveSearch;
pub use search::SearchHit;
pub use search::SearchProvider;
pub use search::SearchToolkit;
pub use search::SearxngSearch;
pub use secrets::EnvSecrets;
pub use secrets::SecretSource;
pub use text::cap_chars;
pub use text::fence_capped;
pub use text::fence_untrusted;
pub use text::html_to_text;
pub use text::response_text;
pub use text::MAX_TEXT_CHARS;
pub use tool::hosted;
pub use tool::Tool;
pub use tool::ToolContext;
pub use tool::ToolError;
pub use tool::ToolOutput;
pub use typed::typed_tool;
pub use typed::TypedTool;

Modules§

declarative
fetch
http
registry
search
secrets
text
tool
typed

Structs§

HttpError
A failed transport call: its kind and a message without secrets. Converts into ProviderError here and into tool errors in the tools crate, keeping the message. Displays as the message.
HttpRequest
One outgoing HTTP request for any transport. accept lists the media types a 2xx answer may have (empty accepts any; guarded transports enforce it). Debug prints header names only, so a request holding an API key can be logged safely.
HttpResponse
An HTTP reply: status, final URL after redirects, headers, a body still to be read, and truncated when the transport cut the body at its own size limit. Header names keep the case the transport saw.
ToolSpec
A tool as a model sees it: its name, what it does and a JSON Schema for its arguments. hosted marks a tool a vendor may run server-side; wires without that send it as a plain tool and the local one runs.

Enums§

HostedTool
A server-side tool a vendor can run itself instead of the local tool of the same name. max_uses caps calls per agent run; fetch also caps the page tokens it reads. Serializes with a kind tag in snake case.
HttpErrorKind
Kind of a failed transport call. Invalid is a malformed request, Blocked a refused address or scheme, Rejected a reply that broke a request rule, Timeout a time limit.
Method
HTTP method of a request. Deserializes from upper-case names such as GET and POST; as_str gives the same upper-case name for the wire.

Traits§

Transport
Sends HTTP requests. HTTP clients, guarded clients, proxies and test fakes implement it, so models and tools never own an HTTP stack. Returns Ok for any status the server sent and Err when the request was refused, failed in transport or broke a limit.