monoloop
Product façade for Monoloop: Connector + Interpreter + transaction-composing Loop.
Hosts should depend on this crate for plug-and-play assembly (cargo add monoloop).
Profile connectors (Grok, Cursor, …) are optional Cargo features.
License: AGPL-3.0-or-later. Commercial: https://frogfish.io
| Resource | URL |
|---|---|
| docs.rs | https://docs.rs/monoloop |
Repository / normative doc/ |
https://github.com/frogfishio/monoloop |
| Homepage | https://frogfish.io |
What this crate is / is not
| Is | Is not |
|---|---|
| Re-exports of the three product components + contracts | A fourth runtime component |
Thin CLI (monoloop --version / --copyright) |
A chat UI or agent framework |
| Assembly entry for hosts | Test kit (see monoloop-testkit) |
Host integration (product hosts)
1. Smoke assembly (FakeConnector, no network)
Shape: ChannelBinding → ChannelRegistry → RuntimeBootstrap → submit.
2. Grok Build wiring (no testkit)
Public binding signature (also on docs.rs / monoloop-connector-grok):
Façade imports with --features grok:
monoloop::connector_grok::{grok_channel_binding, SecretResolver, SecretRef, …}monoloop::loop_runtime::AcpPromptEncodermonoloop::interpreter::DefaultInterpreterFactory
Live Driver/Console qualification stays in monoloop-testkit (live_grok_*).
Product hosts must not depend on testkit.
3. Multi-turn history (host-built)
user_text_input("…") is a one-line helper. For chat journals, build
CanonicalInput yourself:
use ;
let limits = default;
let input = try_new?;
Monoloop does not own durable history. The host maps journal →
CanonicalMessage::{System,User,Assistant,Tool} and submits one transaction at a time.
Resume Grok with explicit session_id: Some(SessionId::from_external(&ExternalSessionId::try_new(grok_session_id)?))
(never ambient “last session”).
4. Live text path = complete canonical units only
There is no token / delta stream API. UI should render from push events:
TransactionEventPayload::CanonicalUnit(CanonicalUnitEvent) — complete sentences /
structures / tool lifecycle units. InterpretationEnd / EOF alone ≠ turn success;
wait for the completion callback / Ended payload.
5. Tokio Handle in Tauri / desktop hosts
RuntimeBootstrap.executor is a tokio::runtime::Handle. Supported pattern:
- At app startup, build a dedicated multi-thread Tokio runtime and keep it for process life.
- Pass
runtime.handle().clone()(orHandle::current()inside that runtime) intoRuntimeBootstrap. - Drive
submit/ async work on that runtime.
#[tokio::main] is fine for CLI samples; embedded hosts (Tauri) should own the runtime explicitly.
Set RuntimeConfig { enable_mcp_listener: false, ..Default::default() } unless you want the MCP shell (Default enables it).
Hard rules
- Do not depend on
monoloop-testkitfrom product crates. - Do not invent ambient “current session”.
- Empty tools (
HostToolRegistry::empty(),tools: vec![]) →tool_unavailable, zero effects. - Canonical completeness ≠ authorization.
Agent assembly recipe (copy this shape)
1. ChannelBinding { connector_factory, encoder, interpreter, capabilities, … }
2. ChannelRegistry::build(vec![binding])
3. DefaultTransactionRuntime::start(RuntimeBootstrap {
config: RuntimeConfig { enable_mcp_listener: false, ..Default::default() },
channels, tools: HostToolRegistry::empty(), executor
})
4. TransactionRuntime::submit(TransactionRequest { … push events + completion … })
5. Await the one completion callback
Module map
| Use | From |
|---|---|
monoloop::contracts::* |
identities, ports, CanonicalInput, sinks |
monoloop::connector::* |
FakeConnector / abstract Connector |
monoloop::interpreter::* |
DefaultInterpreterFactory |
monoloop::loop_runtime::* |
runtime, registry, encoders |
monoloop::connector_grok::* |
Grok profile (features = ["grok"]) |
TestTextEncoder (smoke only)
Loop-owned deterministic encoder for FakeConnector + test_raw. Not a production
Channel encoder. Live hosts use profile *_channel_binding.
Optional Channel profiles
= { = "0.1", = ["grok"] }
# also: cursor, codex, agy, zai, claude
Version / license helpers
use ;
println!;
println!;
Normative specs (public repo): doc/README.md, doc/MONOLOOP.md,
doc/TRANSACTION_RUNTIME_IMPLEMENTATION.md, doc/GROK_BUILD_CONNECTOR.md.