trusty-common
Shared utility surface for the trusty-* family of CLI tools and daemons (trusty-memory, trusty-search, etc.).
Centralizes port auto-detection, data-directory resolution, tracing/CLI init, NO_COLOR handling, and a minimal OpenRouter chat-completions client so each tool doesn't reinvent (and subtly diverge on) the basics.
Installation
To pull in the optional axum HTTP-server middleware helpers:
Quick Example
use ;
async
Feature Flags
axum-server(optional) — enables theservermodule: standard axum middleware stack (CORS, tracing, gzip with SSE carve-out) plus a fast-failreqwest::Clientconfigured for daemon-to-daemon calls.
By default the crate is dependency-light: only tokio, serde, reqwest,
tracing, etc. Axum is pulled in only when the axum-server feature is on.
What's Included
- Port binding —
bind_with_auto_portwalks forward through ports when the requested one is busy, so restarts don't fail noisily. - Data directory —
data_dir(app_name)resolves an OS-appropriate per-application directory and creates it if missing. - Tracing/CLI init — opinionated
tracing_subscribersetup withRUST_LOGandNO_COLORrespected out of the box. - OpenRouter client — a small typed wrapper over OpenRouter's chat-completions API for LLM-backed tooling.
- Server middleware (feature-gated) — shared axum middleware stack so
every
trusty-*daemon gets identical CORS/trace/gzip behavior.
License
Licensed under the Elastic License 2.0.