rendering
Typst Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Typst KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.typst.*.
Use lua_read_doc("integrations.typst") 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
Typst workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.typst.render({markup = "example_markup", title = "example_title"}))' --json kosmo integrations:lua --eval 'print(docs.read("typst"))' --json
kosmo integrations:lua --eval 'print(docs.read("typst.render"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local typst = app.integrations.typst
local result = typst.render({markup = "example_markup", title = "example_title"})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.typst, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.typst.default.* or app.integrations.typst.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Typst, 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.
Typst — Lua API Reference
render_typst
Render a Typst document to PDF. Pass valid Typst markup and get back a downloadable PDF link. Use this tool to generate formatted documents: reports, invoices, proposals, summaries, letters, tables, and more.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
markup | string | yes | Typst markup content to compile into a PDF document. |
title | string | no | Document title used as link text (default: "Document"). |
Key Typst Syntax
= Headingfor headings (==for h2,===for h3)*bold*for bold,_italic_for italic#table(columns: ..., [...], [...])for tables#set page(margin: 2cm)for page settings#set text(size: 12pt, font: "...")for text settings- itemfor bullet lists,+ itemfor numbered lists#line(length: 100%)for horizontal rules#align(center)[...]for alignment#v(1em)for vertical spacing
Example
local result = app.integrations.typst.render_typst({
markup = [[
#set page(margin: 2cm)
#set text(size: 11pt)
= Quarterly Report
== Summary
Revenue increased by *15%* compared to last quarter.
#table(
columns: (1fr, 1fr, 1fr),
[*Metric*], [*Q1*], [*Q2*],
[Revenue], [$1.2M], [$1.38M],
[Users], [12,000], [15,400],
)
]],
title = "Quarterly Report"
})
print(result)Raw agent markdown
# Typst — Lua API Reference
## render_typst
Render a Typst document to PDF. Pass valid Typst markup and get back a downloadable PDF link. Use this tool to generate formatted documents: reports, invoices, proposals, summaries, letters, tables, and more.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `markup` | string | yes | Typst markup content to compile into a PDF document. |
| `title` | string | no | Document title used as link text (default: `"Document"`). |
### Key Typst Syntax
- `= Heading` for headings (`==` for h2, `===` for h3)
- `*bold*` for bold, `_italic_` for italic
- `#table(columns: ..., [...], [...])` for tables
- `#set page(margin: 2cm)` for page settings
- `#set text(size: 12pt, font: "...")` for text settings
- `- item` for bullet lists, `+ item` for numbered lists
- `#line(length: 100%)` for horizontal rules
- `#align(center)[...]` for alignment
- `#v(1em)` for vertical spacing
### Example
```lua
local result = app.integrations.typst.render_typst({
markup = [[
#set page(margin: 2cm)
#set text(size: 11pt)
= Quarterly Report
== Summary
Revenue increased by *15%* compared to last quarter.
#table(
columns: (1fr, 1fr, 1fr),
[*Metric*], [*Q1*], [*Q2*],
[Revenue], [$1.2M], [$1.38M],
[Users], [12,000], [15,400],
)
]],
title = "Quarterly Report"
})
print(result)
``` local result = app.integrations.typst.render({markup = "example_markup", title = "example_title"})
print(result) Functions
render Write
Render a Typst document to PDF. Pass valid Typst markup and get back a downloadable PDF link. Use this tool to generate formatted documents: reports, invoices, proposals, summaries, letters, tables, and more. Example markup: ``` #set page(margin: 2cm) #set text(size: 11pt) = Quarterly Report == Summary Revenue increased by *15%* compared to last quarter. #table( columns: (1fr, 1fr, 1fr), [*Metric*], [*Q1*], [*Q2*], [Revenue], [$1.2M], [$1.38M], [Users], [12,000], [15,400], ) ``` Key Typst syntax: - `= Heading` for headings (`==` for h2, `===` for h3) - `*bold*` for bold, `_italic_` for italic - `#table(columns: ..., [...], [...])` for tables - `#set page(margin: 2cm)` for page settings - `#set text(size: 12pt, font: "...")` for text settings - `- item` for bullet lists, `+ item` for numbered lists - `#line(length: 100%)` for horizontal rules - `#align(center)[...]` for alignment - `#v(1em)` for vertical spacing
- Lua path
app.integrations.typst.render- Full name
typst.render_typst
| Parameter | Type | Required | Description |
|---|---|---|---|
markup | string | yes | Typst markup content to compile into a PDF document. |
title | string | no | Document title used as link text (default: "Document"). |