KosmoKrator

rendering

Mermaid Lua API for KosmoKrator Agents

Agent-facing Lua documentation and function reference for the Mermaid KosmoKrator integration.

1 functions 0 read 1 write No credentials auth

Lua Namespace

Agents call this integration through app.integrations.mermaid.*. Use lua_read_doc("integrations.mermaid") inside KosmoKrator to discover the same reference at runtime.

Agent-Facing Lua Docs

This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.

Mermaid — Lua API Reference

render_mermaid

Render Mermaid diagram syntax (flowcharts, sequence, ER, class, state, Gantt, and more) to a PNG image.

Parameters

NameTypeRequiredDescription
syntaxstringyesMermaid diagram syntax. Must be valid Mermaid markup (e.g., starting with graph TD, sequenceDiagram, erDiagram, etc.).
titlestringnoDiagram title used as alt text (default: "Diagram").
widthintegernoOutput width in pixels (default: 1400, range: 100–4000).
themestringnoMermaid theme (default: "default"). One of: "default", "dark", "forest", "neutral".

Examples

Render a flowchart

local result = app.integrations.mermaid.render_mermaid({
  syntax = "graph TD\n  A[Start] --> B{Decision}\n  B -->|Yes| C[Action]\n  B -->|No| D[End]",
  title = "Simple Flowchart",
  theme = "default"
})

Render a sequence diagram with dark theme

local result = app.integrations.mermaid.render_mermaid({
  syntax = "sequenceDiagram\n  participant Client\n  participant Server\n  Client->>Server: Request\n  Server-->>Client: Response",
  title = "Client-Server Sequence",
  theme = "dark"
})

Render an ER diagram

local result = app.integrations.mermaid.render_mermaid({
  syntax = "erDiagram\n  CUSTOMER ||--o{ ORDER : places\n  ORDER ||--|{ LINE-ITEM : contains",
  title = "Entity Relationship",
  width = 1200
})
Raw agent markdown
# Mermaid — Lua API Reference

## render_mermaid

Render Mermaid diagram syntax (flowcharts, sequence, ER, class, state, Gantt, and more) to a PNG image.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `syntax` | string | yes | Mermaid diagram syntax. Must be valid Mermaid markup (e.g., starting with `graph TD`, `sequenceDiagram`, `erDiagram`, etc.). |
| `title` | string | no | Diagram title used as alt text (default: `"Diagram"`). |
| `width` | integer | no | Output width in pixels (default: 1400, range: 100–4000). |
| `theme` | string | no | Mermaid theme (default: `"default"`). One of: `"default"`, `"dark"`, `"forest"`, `"neutral"`. |

### Examples

#### Render a flowchart

```lua
local result = app.integrations.mermaid.render_mermaid({
  syntax = "graph TD\n  A[Start] --> B{Decision}\n  B -->|Yes| C[Action]\n  B -->|No| D[End]",
  title = "Simple Flowchart",
  theme = "default"
})
```

#### Render a sequence diagram with dark theme

```lua
local result = app.integrations.mermaid.render_mermaid({
  syntax = "sequenceDiagram\n  participant Client\n  participant Server\n  Client->>Server: Request\n  Server-->>Client: Response",
  title = "Client-Server Sequence",
  theme = "dark"
})
```

#### Render an ER diagram

```lua
local result = app.integrations.mermaid.render_mermaid({
  syntax = "erDiagram\n  CUSTOMER ||--o{ ORDER : places\n  ORDER ||--|{ LINE-ITEM : contains",
  title = "Entity Relationship",
  width = 1200
})
```

Metadata-Derived Lua Example

local result = app.integrations.mermaid.render_mermaid({
  syntax = "example_syntax",
  title = "example_title",
  width = 1,
  theme = "example_theme"
})
print(result)

Functions

render_mermaid

Render a Mermaid diagram to a PNG image. Pass valid Mermaid syntax and get back a markdown image embed. Supported diagram types: flowchart, sequence, class, state, ER, Gantt, pie, quadrant, requirement, git graph, C4, mindmap, timeline, sankey, XY chart, block. Example syntax: ``` graph TD A[Start] --> B{Decision} B -->|Yes| C[Action] B -->|No| D[End] ``` Tips: - Use `graph TD` for top-down flowcharts, `graph LR` for left-to-right - Use `sequenceDiagram` for sequence diagrams - Use `erDiagram` for entity-relationship diagrams - Use `classDiagram` for class diagrams - Use `stateDiagram-v2` for state diagrams - Use `gantt` for Gantt charts - Use `pie` for pie charts - Use `gitgraph` for git graphs - Use `mindmap` for mind maps

Operation
Write write
Full name
mermaid.render_mermaid
ParameterTypeRequiredDescription
syntax string yes Mermaid diagram syntax. Must be valid Mermaid markup (e.g., starting with graph TD, sequenceDiagram, erDiagram, etc.).
title string no Diagram title used as alt text (default: "Diagram").
width integer no Output width in pixels (default: 1400, range: 100-4000).
theme string no Mermaid theme (default: 'default').