Development
Repository anatomy, the Rust and Bun toolchain, just recipes for checking, testing, the wire contract and packaging, plugin authoring against the runtime trait, the desktop app, and how this site is built.
theuth is a single Rust workspace of 65 crates, three Bun projects (the
desktop UI and the packages/apps and packages/documents bundles that t
runs in-process) and this site. This page is the map and the exact commands.
Design rationale lives in the numbered design documents inside the
repository; they are internal working notes and are not published here.
Repository anatomy
| Path | What |
|---|---|
crates/ | every workspace member (members = ["crates/*"], resolver 3, edition 2024) |
docs/ | the plugin authoring guide (plugins.md), the skills format (skills.md), update setup and the internal design documents |
justfile | every build, test, packaging and release recipe |
scripts/ | packaging and release scripts, model fetching (fetch-models.sh), remote builds, smoke drivers (scripts/apps/, scripts/durability-mesh/, scripts/restart-clarity/, scripts/telegram-live-proof/) and scripts/tests/ |
bindings/ | generated, not committed: openrpc.json (the composed wire contract), methods.json, typescript/, surface-catalog.json |
packages/apps, packages/documents | TypeScript sources of the in-process bundles: the OpenUI app check/merge and Mermaid parse bundles (just apps-bundle) and the documents helper (just documents-bundle), both committed under crates/js-runtime/js |
deploy/relay, deploy/share-edge, deploy/computer, deploy/vm, deploy/update | link relay and iroh relay images, compose and Kubernetes manifests; the share edge (image, compose, systemd unit, Kubernetes); an engine in a container; the sandbox VM image; the Linux CLI tarball builder |
vendor/ | patched libsqlite3-sys, pbjson-types, a2a-client, flexaudio-os-macos and ptts; each patch says why in the root Cargo.toml |
site/ | this website: React Router (SPA mode) with the docs under site/content/docs/ |
assets/, .cargo/config.toml, rust-toolchain.toml | images; cmake policy shim and the aarch64-linux linker and flags; channel = "stable" |
There is no CI configuration in the repository; the gates below are run by
hand (just check, just clippy, just test, just durability) and by the
release scripts.
Crates
The binary crate theuth builds t. Plugins implement runtime::Plugin
and are started by t; crates marked library have no actor, config section
or events of their own.
| Crate | Purpose |
|---|---|
theuth | the t binary: load config, start the plugin list, compose the RPC module, t mcp, the Python worker |
runtime (library), wire (library) | the Plugin trait, Runtime handle, bus and config helpers; plugin-owned wire event contracts and the ordered event fanout |
rpc, rpc-core, rpc-core-macros (libraries), rpc-compose | JSON-RPC 2.0 over WebSocket, connection auth and engine discovery; plugin-free RPC contracts; per-method discovery descriptors; cross-plugin composition, the search tool and the ACP server |
tools | tool registry, approval gate, shell and PTY jobs, file tools, the MCP client |
agent | the model loop (genai), sqlite sessions, Fractal context, skills, subagents, the Python runtime |
tui | the terminal UI (iocraft) |
desktop | Tauri 2 shell: macOS menubar app, Windows and Linux desktop, iOS link client; UI under desktop/ui, native companions under desktop/companion* |
secrets, oauth (library) | encrypted vault; PKCE loopback login and token store |
models, markdown, cursor, chat-common (libraries) | bundled models.dev catalog; streaming markdown; Cursor protocol client; helpers the chat adapters share |
web, scrape, search-providers, search (library), routes, firecrawl-native (library) | search_web/read_url, crawler, external engines, shared fuzzy matching, learned site routes, vendored crawler heuristics |
browser, computer, webprofile | embedded headless browser; screen, pointer, accessibility tree and clipboard; the shared, mesh-replicated browser profile |
codeindex, knowledge, document, artifact, app, surface (library) | code symbol index; knowledge bundle; Yjs documents; show files and PDFs; OpenUI apps; Mermaid/json-render catalog |
js-runtime (library), app-parser-stub | the in-process deno_core runtime for the documents and app bundles; the theuth-app-parser-<hash> compatibility stub kept for installed updaters |
schedule, tasks, roster, cells | routines; task board; agents as files; user cells |
decision, double, dreaming, autoresearch, evalcore (library) | local decision oracle; the owner's double; the nightly routine; measured experiment loops; the eval core autoresearch and dreaming share |
link, relay, nodes, mesh, replica, sessionsync, sandbox, a2a, acp | phone/browser uplink and the theuth-relay binary; remote harnesses; iroh engine mesh; replication; transcript sync; ssh/docker/VM engines; A2A and contacts; ACP client |
share, share-edge, share-proto (library) | public sharing client plugin; the theuth-share-edge binary; their wire contract |
mcp-server (library) | theuth as an MCP server (started by t when mcp_server.enabled) |
signal, slack, telegram | the three channel frontends |
voice, voice-mlx (library), talk, meeting | TTS, STT and dictation; Parakeet on MLX (Apple silicon); live spoken conversation; meeting recorder |
update, platform (library) | CLI self-update; OS primitives and the supported-platform matrix |
Toolchain
- Rust:
rust-toolchain.tomlpinschannel = "stable".just setuprunsrustup show active-toolchain || rustup toolchain install stable. Every recipe prepends the active toolchain's bin dir because Homebrew's rustup installs nocargoproxy;export PATH="$(just toolchain):$PATH"does the same in your shell. - Lints: workspace-wide
missing_docs = "warn"andclippy::all = "deny";just clippyruns with-D warnings. - System dependencies:
cmake,clang/libclang,llvm-objcopy/llvm-nm(brew install cmake llvm; on Ubuntuscripts/setup-ubuntu-build.shlists the apt packages and pins Bun 1.4.0). The first build downloads a prebuilt V8 archive;RUSTY_V8_ARCHIVEpoints at a local copy for offline builds. ONNX Runtime 1.32.0 (with the WebGPU plugin execution provider 0.6.0) is the pinned runtime for speech and decision models (scripts/ort-version.env). - Bun is needed only for the UIs, the site and to rebuild the committed
in-process bundles; an installed
tneeds neither Node nor Bun at run time. - Cross-compiling to aarch64-linux uses
scripts/aarch64-linux-lld-cc.shas the linker with+fp16(.cargo/config.toml). target/hygiene: the dev profile keeps line tables only (--profile dev-fullfor a debugger), gates build withCARGO_INCREMENTAL=0unless you set it, andjust sweep [days](needscargo install cargo-sweep) removes artifacts no build used for three days.
Platforms
From crates/platform/src/target.rs:
| Host | Architectures | Floor |
|---|---|---|
| macOS | arm64, x86_64 | macOS 15; shipped packages are arm64 only |
| Windows | x86_64, arm64 | Windows 10 22H2; meetings need Windows 11 |
| Linux | x86_64, arm64 | glibc 2.35 declared; the shipped CLI tarballs are built on Ubuntu 24.04 and need glibc 2.39; systemd user sessions for the service, PipeWire 0.3 or later for meetings; musl unsupported |
| iOS (link client only) | arm64 | iOS 17 |
| Android (link client only) | arm64 | minSdk 26; no build recipe in the repository |
The release pipeline can produce: the macOS app (with the native companion
nested inside) and CLI (arm64), Linux CLI tarballs (x86_64, arm64), Linux
desktop .deb/.rpm/.AppImage (x86_64), a Windows installer and CLI zip
(x86_64). Which of these ship for a given version depends on that release;
Linux and Windows desktop builds are the least exercised.
Everyday recipes
just setup # toolchain
just check # both *-bundle-check recipes, then cargo check --workspace --all-targets
just clippy # cargo clippy --workspace --all-targets -- -D warnings
just fmt # cargo fmt --all
just test # cargo test --workspace
just test -p tools # one crate (ARGS pass through)
cargo test -p tools gate # one crate, tests matching "gate"
just run -- --headless # debug build, runs t
just run -- --data-dir /tmp/theuth-dev # a scratch data dir
just ts # wire contract → bindings/, then TypeScript → bindings/typescript
just ts-desktop # the same plus a copy into crates/desktop/ui/src/rpc/bindings
just wire-schema # bindings/openrpc.json only (cargo test -p theuth --bin t export_bindings)
just wire-schema-accept # copy it over the tracked baseline after review
just apps-bundle # bun → rebuild the in-process app and mermaid bundles in crates/js-runtime/js
just documents-bundle # bun → rebuild the in-process documents bundle in crates/js-runtime/js
just helper # cargo → the theuth-app-parser-<hash> compatibility stub (updaters only)
just install # release t + the app-parser stub into ~/.cargo/bin (or $THEUTH_INSTALL_BIN)
just models # refresh crates/models/data/models.json from models.dev
just models-check # fail when the committed catalog drifted
just fetch-models [--check] # every local model the daemon loads → $THEUTH_DATA_DIR/modelsA headless smoke on a scratch data dir, the way docs/plugins.md describes
it:
THEUTH_RPC__LISTEN=127.0.0.1:7791 ./target/debug/t --headless --data-dir /tmp/theuth-xThe app parser, the Mermaid checker and the documents helper run inside t
on their own deno_core threads (crates/js-runtime); there is no
theuth-documents or app-parser helper process any more. Their bundles are
committed under crates/js-runtime/js; only a TypeScript change in
packages/apps or packages/documents needs just apps-bundle /
just documents-bundle, and just check fails while a bundle is stale.
Release layouts still carry the theuth-app-parser-<hash> stub beside t
for installed updaters.
The wire contract
just wire-schema writes the composed contract the running engine serves
(OpenRPC 1.3.2 with an x-theuth event catalog) to bindings/openrpc.json.
The test wire_schema_snapshot compares it with the tracked baseline
crates/theuth/tests/fixtures/wire/openrpc-v1.json and fails on any change,
additive ones included; review the classified report, then run
just wire-schema-accept. just ts generates the TypeScript client from
the same file (bun run wire:generate in crates/desktop/ui).
Desktop
just desktop # bindings, cargo build -p theuth, bun install, cargo tauri dev
just desktop-check # cd crates/desktop/ui && bun run check && bun run test && bun run build
just web-build # static browser UI → crates/desktop/ui/dist, served by theuth-relay --web
just package-macos # theuth.app + DMG (ad-hoc unless THEUTH_SIGN_IDENTITY or .env.signing)
just install-macos # copy the last package to /Applications
just package-linux # .deb/.rpm/.AppImage with the t sidecar, on a Linux host
just package-windows # NSIS installer + CLI zip, on a Windows host (pwsh 7)
just package-ios # signed IPA (just testflight uploads it)
just companion # the macOS companion (needs Xcode) → target/release/companion/
just companion-windows-test # the Windows companion's portable half and its xUnit suites (.NET 10)The Tauri config (crates/desktop/tauri.conf.json) serves the Vite dev
server on port 1420, builds ui/dist, bundles t as the external binary
(tauri.bundle.conf.json) and reads the updater manifest from the release
bucket. just desktop runs against target/debug/t (or $THEUTH_BIN) and
honours THEUTH_DATA_DIR. The UI tests are vitest (src/**/*.test.ts);
bun run check is tsc -b --noEmit.
Relay, share edge and this site
just relay # cargo run -p relay -- --listen 127.0.0.1:8787
just site-build # cd site && bun install && bun run build → site/dist
theuth-relay --web crates/desktop/ui/dist --site site/dist # serve both; --site-listen defaults to 0.0.0.0:8788
just relay-docker-push [tag] # multi-arch relay image
just iroh-relay-docker-push [tag] # the stock iroh-relay for the mesh, pinned to the workspace iroh
just share-edge-docker-push [tag] # multi-arch theuth-share-edge imageThe site is a React Router project in SPA mode with Fumadocs
(site/package.json: dev, check = tsc -b plus scripts/check-docs.ts,
build = check, react-router build and scripts/finish.ts). Every docs
page is prerendered to static HTML; check-docs.ts validates front matter,
slugs, meta.json entries and every internal /docs link. The version comes
from crates/desktop/tauri.conf.json and the latest release manifest at build
time. The documentation lives as MDX under site/content/docs/ with one
meta.json per section and is served by the relay container
(deploy/relay), which exposes the browser UI on 8787 and the site on 8788.
Release
just bump-version <major|minor|patch|x.y.z> edits Cargo.toml,
tauri.conf.json and Cargo.lock. just release runs the macOS pipeline
(package, notarize, update payloads, publish, tag); Windows and Linux
artifacts are built first with just build-remote <host> windows|linux
(--no-wait and --resume for long builds), the linux-aarch64 CLI tarball
with just stage-linux, and just release-update publishes any platform the
live version is missing. When a model origin or the ONNX Runtime pin changed,
just release-models publishes the model files first. Signing, notarization
and publishing credentials come from a local .env.signing file whose
variable names are listed in .env.signing.example. Sandbox VM images are
built with just vm-image <tag>.
Testing
cargo test --workspaceruns unit tests, doctests and the integration tests undercrates/*/tests/(web SSRF and engine tests, codeindex, replica and session sync, the MCP server catalogue, the share edge, the shared browser profile, the in-process JS bundles' golden files, decision and meeting oracles, sandbox engines, browser live tests, the wire snapshot). No nextest.just durability: the crash-injection suite (every crash point, drain and suspend, journal store, reaper, waits, ACP respawn, jobs and PTY), about a minute on an M-series laptop.just durability-mesh: the two-engine rows in process (about 15 s);just durability-mesh smokeadds the scripted run against two real engines (about 7 min; needs bun and free ports 7931, 7932, 7941, 7942, 7950).just restart-clarity [P1..P6]: one real engine with a realompchild,kill -9and reboot (about 8 min; needs bun, omp and ports 7960 to 7966).- Frontend: vitest in
crates/desktop/ui;bun testinpackages/appsandpackages/documents;just companion-windows-testfor the Windows companion. - Smoke drivers that talk to a running
t --headlessover WebSocket live inscripts/apps/(apps, steering, relay) andscripts/codemap-smoke.ts;scripts/tests/fetch-models-test.shexercises the model fetcher against a fake origin.
Writing a plugin
The contract is small. From crates/runtime/src/lib.rs:
#[async_trait]
pub trait Plugin: Send {
fn name(&self) -> &'static str;
async fn declare_wire(&mut self, _rt: &Runtime) -> anyhow::Result<()> { Ok(()) }
async fn start(self: Box<Self>, rt: &Runtime) -> anyhow::Result<()>;
}Runtime carries the kameo bus, the figment config, data_dir and a
shutdown token. Plugins talk to each other only through typed events on
the bus (rt.publish, rt.subscribe) and commands (ask on an actor
found by name through rt.lookup_when::<A>(name)). There is no shared event
enum, no shared config struct, and no handle threading through main.
declare_wire runs for every plugin before any start, so event contracts
exist before their producers.
The steps, each confirmed against the code:
- Design doc first. A numbered design document with decisions that
name the alternative they beat, the config section with every key and
default, the commands and events exactly as declared, the tools with
their
Risk, the UI surface, what lives on disk, and a runnable check per step. - Crate.
crates/foowith[lints] workspace = true, apub const FOO_ACTOR: &str, aFooConfigthat is#[serde(default)]and read withrt.section::<FooConfig>("foo")(a missing section is an error you turn intoDefault), and wire-visible types that areSerialize + Deserialize + JsonSchema. Events implementwire::WireEventand are registered withrt.register_wire_event::<E>()indeclare_wire. start. Read the config; when disabled or broken, log and returnOk(())so the harness still runs. Spawn the actor and register it underFOO_ACTOR. Do cross-plugin registration in a task afterlookup_when, never by blockingstart.- Tools. Implement
tools::Tool(const NAME,const RISK: Risk,type Args: DeserializeOwned + JsonSchema,description(),call(); optionalDIRECT,RETURNS,CONSUMES_SECRETS), thenreg.ask(tools::RegisterTool(Arc::new(tool)))afterrt.lookup_when::<tools::ToolRegistry>(tools::REGISTRY_ACTOR). A prompt block goes throughtools::RegisterPrompt { plugin, text }. - RPC. The crate owns its methods: a jsonrpsee
#[rpc(server, client)]trait insrc/rpc.rswith#[rpc_core_macros::rpc_descriptors(owner = "foo", ...)], implemented onrpc_core::Server(lookup plus oneask), exported asrpc_module(server) -> rpc_core::DescribedModule. - Integrate. Add the plugin to
engine_plugins()and its module torpc_composition()incrates/theuth/src/main.rs, a commented section toDEFAULT_CONFIGthere, and the TUI command, event and render arms. The testreal_composition_descriptors_match_served_methodsfails when a served method has no descriptor. - Verify.
just check,just clippy,just test,just wire-schemaand, after reviewing the change,just wire-schema-accept; a headless smoke over RPC includingenabled: false, and a Status section in the design doc saying what was exercised.
Nothing reads another plugin's config section or calls into its state directly. Libraries have no actor, config or events and are deliberately not plugins.
Public surfaces to code against
bindings/openrpc.json,bindings/methods.jsonandbindings/typescript/: the RPC methods and event topics a frontend codes against; regenerate withjust ts.bindings/surface-catalog.json: the JSON schema of the json-render blocks a reply may contain.docs/plugins.md: the full plugin guide the steps above summarise.- The bundled
harnessskill is rewritten on every start from the binary; any user-visible change to layout or config needs a matching change there.