Neutral rendering helpers for agent replies.

Concrete transports can render Reply into HTML, mrkdwn, plain text, JSON cards, or another surface-specific format.

Functions

text-reply

fn (text: Str): Reply

Build a plain text Reply.

Example

reply ::ai::agent::render/text-reply("Done.")
reply.text  // "Done."
reply.format  // "plain"

truncate-text

fn (text: Str, max-chars: Int, suffix: Str): Str

Truncate text to max-chars, appending suffix when truncation occurs.

Example

::render ::ai::agent::render

::render/truncate-text("Hello world", 5, " [more]")  // "Hello [more]"
::render/truncate-text("Hello", 5, " [more]")  // "Hello"

with-sources

fn (reply: Reply, sources: Vec): Reply

Attach source records to a Reply.

Example

::render ::ai::agent::render

reply ::render/with-sources(::render/text-reply("See the runbook."), [{title: "Runbook"}])
reply.sources  // [{title: "Runbook"}]

Types

Reply

Reply type {
    text: Str,
    format: Str?,
    sources: Vec?,
    metadata: Map?
}

Neutral reply record before transport-specific rendering.