API Reference mead v#0.1.1

Copy Markdown View Source

Modules

Public API of the mead runtime: isolated, supervised conversation sessions.

The deck's view of one session: one process per session that owns the event sequence, the event log, the prompt queue and the turn that runs.

Starts and stops the Mead.Deck.Channel of each session. A channel is :temporary: when it stops, a reconnecting deck asks for a new one through ensure/2, and the event log it keeps on disk carries the sequence over.

Reads and validates config :mead, :deck.

The append-only log of the sequenced events of one deck session, one file <id>.events per session beside the session history, on the same Mead.Session.Record framing (length and checksum per record, a torn last record cut on open).

The wire vocabulary of the deck protocol: building the envelope of a server event and validating a client message.

The Mead.Router.Interaction of a deck turn: every question and every progress report is a call into the Mead.Deck.Channel of the session, which owns the policy, the event log and the clock.

The HTTP side of the deck: the two routes under /deck.

One WebSocket connection of the deck: a translator between frames and calls on the session's Mead.Deck.Channel, which holds all the state, so a deck that reconnects finds it intact.

Single-use tickets that turn an authenticated POST /deck/ticket into one WebSocket upgrade.

The single plug behind the shared Bandit listener: it hands a request to the MCP plug or to the deck plug by the first segment of its path.

Ledger of what the router sends to providers, kept in memory and journaled to disk.

The pure model of the ledger journal: the counter rows, the ring of the last 100 turns and the dropped count that a sequence of journal events adds up to.

The file side of the ledger journal: ledger.journal in the storage directory, a sequence of Mead.Session.Record records, each one Mead.Ledger.Journal event.

The tools the connected MCP servers offer, plus the normalized server configuration, in an ETS table any process can read.

Validates and normalizes the MCP servers configured under config :mead, :mcp, servers: [...].

One process per configured MCP server. It owns a transport, performs the MCP handshake, keeps the server's tools published in Mead.MCP.Catalog, and carries tool calls.

The client side of MCP for the runtime: a supervisor that keeps one Mead.MCP.Connection per configured server, and the two functions the router uses, tools_for/2 and call_tool/4.

Decides which tools the model sees and whether a named call may run. Pure: it reads no process and asks no server.

Pure JSON-RPC 2.0 codec for the slice of MCP that mead speaks as a client: initialize, notifications/initialized, tools/list, and tools/call.

The server side of MCP: an HTTP listener that lets a client with the configured token drive sessions as tools (see Mead.MCP.Server.Tools). The last child of the root supervisor.

Reads and validates config :mead, :mcp_server.

Turns one decoded JSON-RPC message into the server's answer. Pure apart from the tools it calls: no HTTP, no process of its own, so every protocol rule is testable without a network.

The HTTP side of the MCP server: POST /mcp, one JSON-RPC message per request.

The nine tools the MCP server offers: start_session, submit_turn, history, stop_session, resume_session, delete_session, list_sessions, compact_session, and usage. They are the only code of the server that touches the runtime, and they do it only through the public Mead API.

Behaviour for the pipe between a Mead.MCP.Connection and one MCP server.

The Streamable HTTP transport of MCP: every message is a POST, and the answer is either one JSON body or an event stream that ends with the answer.

Runs an MCP server as a child process and talks to it over its standard input and output, one JSON message per line.

The Origin rule of every HTTP surface of the runtime: protection against DNS rebinding and cross-site WebSocket hijacking.

Behaviour for a model backend that completes a conversation.

Mead.Provider backed by the Anthropic Messages API.

Mead.Provider backed by the Ollama chat API, meant for the local slot of Mead.Router.

An incremental parser for text/event-stream bodies.

Turn handler that sends each turn to a local or a cloud model.

The built-in ask_user tool: lets the model put a short multiple-choice question to the person and use the answer.

Decides whether a turn is routine enough for the local model or needs the cloud.

What the router asks of a person (or of a policy standing in for one) around each tool call.

Registry helpers shared by the processes that make up one conversation.

Provisional default handler that answers every turn with its own input.

Keeps the turns of one conversation, and writes them through Mead.Session.Store when the session has a storage directory.

Dynamically starts and stops the per-conversation supervisors.

The record framing shared by the session files and the ledger journal, and the few file operations both need.

Orchestrates the turns of one conversation.

Keeps the turns of each conversation in one append-only file per session.

Supervises the two processes of one conversation.

One exchange in a conversation: the input, the output once known, and how it ended.

Behaviour for the code that produces the output of a turn.

Generates random (version 4) UUID strings without any dependency.