AI Enrichment

The AI layer is provider-agnostic behind a two-method interface. Features depend on that interface rather than on a concrete client, which keeps where the tokens come from a resolution-time decision.

You bring your own key: OpenAI, Anthropic, Gemini, Ollama, or any OpenAI-compatible endpoint. Keys are never stored in Mochi’s config. The config file holds only a pointer to a vault entry, and the secret itself lives in the Flow vault. Each provider gets its own slot, so you can hold an OpenAI key and an Anthropic key at once and flip between them without re-entering anything.

Reaching the vault involved a small piece of trickery I’m fond of. Mochi’s AI package can’t import Flow’s vault resolution, since it’s internal to Flow and off-limits the same way it is to the Rust layer. Instead it shells out to its own binary’s inherited secret command, exactly as the desktop does. Vault access always goes through Flow’s real implementation rather than a reimplementation of it.

The agent loop is bounded rather than trusted to stop on its own: a round budget and a wall-clock timeout, sized for analyzing a whole workspace while still stopping well short of a runaway. Tools come from Mochi’s own MCP server behind a three-tier permission policy, and every call is recorded as an audit entry. Confirmation is designed to cross a process boundary. If no confirmation handler is set, the loop returns a pending request rather than blocking, so the desktop can ask the user and resume.

Usage is logged locally as one JSON line per generation, with age and size retention, so you can see what your own key is being spent on.