Internals
Extending Meridian
Recipes for adding a framework, a model provider, an agent tool, a card type or an API endpoint.
Add a framework
Drop a JSON file into content/frameworks/ and restart. No code needed. See Frameworks, policies & training.
Add a model provider
- In
backend/llm, implementChatModel:rust#[async_trait] impl ChatModel for MyProvider { fn info(&self) -> ModelInfo { /* provider, model, base_url */ } async fn stream(&self, req: ChatRequest) -> Result<EventStream> { // yield Event::Text, Event::ToolUse { id, name, input }, then Event::Stop { reason, native } } } - Add a variant to
Providerinconfig.rs(its name, default model, base URL and key variables) and build it inLlmConfig::build. - Add a unit test that maps a request body, like the ones in
openai.rsandanthropic.rs.
If the provider speaks the OpenAI Chat Completions API, you don't need code: use MERIDIAN_LLM_PROVIDER=compatible.
Add an agent tool
- Describe it in
backend/agent/src/tools.rs: name, description, JSON schema, and a human label inlabel(). - Implement it in
backend/server/src/host.rs::dispatch. ReturnToolOutcome::ok(content, summary), attach cards with.with_card(…), and call.waiting()if the user must answer. - Put consequential writes behind a
confirmcard, and run them inrun_actionwhen the card is approved. - Add a case to the journey test if it changes user-visible behaviour.
Add a card type
- Build the card JSON in
host.rs(it needs anid,kindandstatusif it can be answered). - If it takes an answer, handle it in
answer_card. - Add its type to
frontend/lib/types.tsand render it incomponents/agent/cards.tsx. - Document it in the API reference and on Cards.
Add an API endpoint
- Write the handler in the matching
backend/server/src/routes/*.rs. Keep it thin: parse input, check the role, calldomain. - Register it in
routes/mod.rs. - Add it to
frontend/lib/api.ts, plus the CLI if useful. - Document it in
docs/api.md.
