rendering
Vega-Lite Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Vega-Lite KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.vegalite.*.
Use lua_read_doc("integrations.vegalite") inside KosmoKrator to discover the same reference at runtime.
Call Lua from the Headless CLI
Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic
Vega-Lite workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.vegalite.render({spec = "example_spec", title = "example_title", width = 1}))' --json kosmo integrations:lua --eval 'print(docs.read("vegalite"))' --json
kosmo integrations:lua --eval 'print(docs.read("vegalite.render"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local vegalite = app.integrations.vegalite
local result = vegalite.render({spec = "example_spec", title = "example_title", width = 1})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.vegalite, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.vegalite.default.* or app.integrations.vegalite.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Vega-Lite, use the narrower mcp:lua command.
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json Agent-Facing Lua Docs
This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.
Vega-Lite — Lua API Reference
render_vegalite
Render a Vega-Lite visualization to a PNG image. Pass a complete Vega-Lite JSON specification and get back a markdown image embed. Always use inline data with "data": {"values": [...]}. Never use "data": {"url": "..."}.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
spec | string | yes | Complete Vega-Lite JSON specification. Must include "data" with inline "values", "mark" type, and "encoding". Always use {"data": {"values": [...]}} for data. |
title | string | no | Chart title used as alt text (default: "Chart"). |
width | integer | no | Output width in pixels (default: 800, range: 200–4000). |
Supported Mark Types
bar, line, point, area, rect, circle, square, arc, text, tick, rule, trail, boxplot
Always include "type" in encoding channels: "quantitative", "nominal", "ordinal", or "temporal".
Example
local result = app.integrations.vegalite.render_vegalite({
spec = [[{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"values": [
{"category": "A", "value": 28},
{"category": "B", "value": 55},
{"category": "C", "value": 43}
]
},
"mark": "bar",
"encoding": {
"x": {"field": "category", "type": "nominal"},
"y": {"field": "value", "type": "quantitative"}
}
}]],
title = "Sample Bar Chart",
width = 600
})
print(result)Raw agent markdown
# Vega-Lite — Lua API Reference
## render_vegalite
Render a Vega-Lite visualization to a PNG image. Pass a complete Vega-Lite JSON specification and get back a markdown image embed. Always use inline data with `"data": {"values": [...]}`. Never use `"data": {"url": "..."}`.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `spec` | string | yes | Complete Vega-Lite JSON specification. Must include `"data"` with inline `"values"`, `"mark"` type, and `"encoding"`. Always use `{"data": {"values": [...]}}` for data. |
| `title` | string | no | Chart title used as alt text (default: `"Chart"`). |
| `width` | integer | no | Output width in pixels (default: 800, range: 200–4000). |
### Supported Mark Types
`bar`, `line`, `point`, `area`, `rect`, `circle`, `square`, `arc`, `text`, `tick`, `rule`, `trail`, `boxplot`
Always include `"type"` in encoding channels: `"quantitative"`, `"nominal"`, `"ordinal"`, or `"temporal"`.
### Example
```lua
local result = app.integrations.vegalite.render_vegalite({
spec = [[{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"values": [
{"category": "A", "value": 28},
{"category": "B", "value": 55},
{"category": "C", "value": 43}
]
},
"mark": "bar",
"encoding": {
"x": {"field": "category", "type": "nominal"},
"y": {"field": "value", "type": "quantitative"}
}
}]],
title = "Sample Bar Chart",
width = 600
})
print(result)
``` local result = app.integrations.vegalite.render({spec = "example_spec", title = "example_title", width = 1})
print(result) Functions
render Write
Render a Vega-Lite visualization to a PNG image. Pass a complete Vega-Lite JSON specification and get back a markdown image embed. IMPORTANT: Always use inline data with "data": {"values": [...]}. Never use "data": {"url": "..."}. Example spec: { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "data": {"values": [ {"category": "A", "value": 28}, {"category": "B", "value": 55}, {"category": "C", "value": 43} ]}, "mark": "bar", "encoding": { "x": {"field": "category", "type": "nominal"}, "y": {"field": "value", "type": "quantitative"} } } Supported mark types: bar, line, point, area, rect, circle, square, arc, text, tick, rule, trail, boxplot. Always include "type" in encoding channels: "quantitative", "nominal", "ordinal", or "temporal".
- Lua path
app.integrations.vegalite.render- Full name
vegalite.render_vegalite
| Parameter | Type | Required | Description |
|---|---|---|---|
spec | string | yes | Complete Vega-Lite JSON specification. Must include "data" with inline "values", "mark" type, and "encoding". Always use {"data": {"values": [...]}} for data. |
title | string | no | Chart title used as alt text (default: "Chart"). |
width | integer | no | Output width in pixels (default: 800, range: 200–4000). |