MeridianDocsSign in
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

  1. In backend/llm, implement ChatModel:
    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 }
        }
    }
  2. Add a variant to Provider in config.rs (its name, default model, base URL and key variables) and build it in LlmConfig::build.
  3. Add a unit test that maps a request body, like the ones in openai.rs and anthropic.rs.

If the provider speaks the OpenAI Chat Completions API, you don't need code: use MERIDIAN_LLM_PROVIDER=compatible.

Add an agent tool

  1. Describe it in backend/agent/src/tools.rs: name, description, JSON schema, and a human label in label().
  2. Implement it in backend/server/src/host.rs::dispatch. Return ToolOutcome::ok(content, summary), attach cards with .with_card(…), and call .waiting() if the user must answer.
  3. Put consequential writes behind a confirm card, and run them in run_action when the card is approved.
  4. Add a case to the journey test if it changes user-visible behaviour.

Add a card type

  1. Build the card JSON in host.rs (it needs an id, kind and status if it can be answered).
  2. If it takes an answer, handle it in answer_card.
  3. Add its type to frontend/lib/types.ts and render it in components/agent/cards.tsx.
  4. Document it in the API reference and on Cards.

Add an API endpoint

  1. Write the handler in the matching backend/server/src/routes/*.rs. Keep it thin: parse input, check the role, call domain.
  2. Register it in routes/mod.rs.
  3. Add it to frontend/lib/api.ts, plus the CLI if useful.
  4. Document it in docs/api.md.