Output Artifact Reference
Reference tables for final output viewers, Markdown breyta-resource embeds,
table queries, aggregates, charts, downloads, media, and structured output.
For the authoring model and examples in context, start with
Output Artifacts.
Complete Report Pattern
Use this as the reference pattern when you need to combine the full output
authoring surface in one report:
| Report section | What it demonstrates |
|---|---|
| Daily retail operations brief | Single canonical Markdown output envelope. |
| Open orders needing follow-up | Embedded table resource with selected columns, filters, sorting, formatting, and bounded snapshot page. |
| Fulfillment status mix | Aggregate query and bar chart from the same table resource. |
| Order value trend | Line chart from table rows using :type :line. |
| Visual context | Inline SVG image and video resource embeds. |
| Supporting resources | Resource-ref table cells and direct Markdown res:// links that drill into the Breyta resource viewer. |
| Embedded details | Nested Markdown, text, and JSON resources rendered inline. |
| Attachments | The same resources rendered as compact :view :download affordances at the bottom of the report. |
Minimal authoring shape:
(let [orders-table (flow/step :function :persist-orders
{:persist {:type :table
:rows-path [:rows]}})
nested-report (flow/step :function :persist-nested-report
{:persist {:type :blob
:content-type "text/markdown"}})
image (flow/step :function :persist-image
{:persist {:type :blob
:content-type "image/svg+xml"}})
video (flow/step :function :persist-video
{:persist {:type :blob
:content-type "video/mp4"}})
table-uri (:uri orders-table)
report (str "# Daily retail operations brief\n\n"
"```breyta-resource\n"
(pr-str {:resource table-uri
:view :table
:mode :snapshot
:title "Filtered open orders"
:table {:query {:select [:order-id :customer :amount]
:where [[:status := "open"]]
:sort [[:created-at :desc]]
:page {:mode :offset :limit 25}}
:row-transform "(fn [row]\n (assoc row :customer (str (:customer row) \" - review\")))"
:columns {"amount" {:label "Amount"
:format {:display "currency"
:currency "USD"}}}}})
"\n```\n\n"
"```breyta-resource\n"
(pr-str {:resource table-uri
:view :table
:mode :snapshot
:title "Orders by status"
:table {:aggregate {:group-by ["status"]
:metrics [{:op :count :as "orders"}]}
:chart {:x "status"
:series [{:field "orders"
:type :bar}]}}})
"\n```\n\n"
"```breyta-resource\n"
(pr-str {:resource table-uri
:view :table
:mode :snapshot
:title "Order value trend"
:table {:query {:select [:created-at :amount]
:sort [[:created-at :asc]]
:page {:mode :offset :limit 25}}
:columns {"created-at" {:label "Created"
:format {:display "timestamp"}}
"amount" {:label "Order value"
:format {:display "currency"
:currency "USD"}}}
:chart {:x "created-at"
:series [{:field "amount"
:label "Order value"
:type :line}]}}})
"\n```\n\n"
"See [Analyst note](" (:uri nested-report) ").\n\n"
"```breyta-resource\n"
(pr-str {:resource (:uri image)
:view :image
:alt "Fulfillment lane dashboard snapshot"})
"\n```\n\n"
"## Attachments\n\n"
"```breyta-resource\n"
(pr-str {:resource table-uri
:view :download
:title "Orders source CSV"
:format :csv})
"\n```\n\n"
"```breyta-resource\n"
(pr-str {:resource (:uri video)
:view :download
:title "Packing station clip video"})
"\n```")]
{:breyta.viewer/kind :markdown
:breyta.viewer/options {:title "Markdown resource output"}
:breyta.viewer/value report})
The complete pattern can include one example of every current embed adapter:
:table, table :aggregate, bar and line table :chart, :download, :markdown,
:text, :json, :image, and :video.
Viewer Envelope
Return a viewer envelope when you want predictable rendering:
{:breyta.viewer/kind :markdown
:breyta.viewer/options {:title "Summary"}
:breyta.viewer/value "# Summary\n\nDone."}
| Key | Required | Meaning |
|---|---|---|
:breyta.viewer/kind | Yes | Viewer type. |
:breyta.viewer/value | Yes | Payload rendered by the viewer. |
:breyta.viewer/options | No | Viewer metadata such as title, alt text, and output metadata. |
:breyta.viewer/items | For :group | Ordered child viewer envelopes. |
:breyta.viewer/options {:title ...} provides viewer metadata and can label
grouped child artifacts. It does not rename the canonical flow-output resource
or the single final output page/panel chrome. Recent-run row titles are
configured separately on the run form with :title.
Viewer Kinds
| Kind | Use when | Value shape |
|---|---|---|
:markdown | Human-readable report or narrative output. | Markdown string. |
:raw | Structured map/vector/scalar is the intended product output. | Any EDN/JSON-compatible value. |
:text | Plain text should preserve line breaks. | String. |
:table | A persisted Breyta table resource is the primary artifact. | Resource ref from :persist {:type :table ...}. |
:image | Dedicated image viewer is best. | URL, signed URL, or persisted blob result. |
:audio | Dedicated audio viewer is best. | URL, signed URL, or persisted blob result. |
:video | Dedicated video viewer is best. | URL, signed URL, or persisted blob result. |
:download | Compact file/table download affordance. | Map with :download-url and optional metadata. |
:group | Multiple top-level artifacts are needed. | :breyta.viewer/items vector. |
Markdown Resource Directive
Inside a Markdown viewer, embed resources with a fenced block:
```breyta-resource
{:resource "res://v1/ws/ws-123/result/table/tbl_orders"
:view :table
:mode :snapshot
:title "Open orders"
:table {:query {:select ["order-id" "customer" "amount"]
:where [["status" := "open"]]
:page {:mode :offset :limit 25}}}}
```
| Field | Required | Applies to | Meaning |
|---|---|---|---|
:resource | Yes | All embeds | Absolute res://... URI in the current workspace. |
:view | No | All embeds | :auto, :table, :markdown, :text, :json, :image, :audio, :video, or :download. Defaults to :auto. |
:mode | No | All embeds | :snapshot in v1. Snapshot is the default. :live is reserved and not supported. |
:title | No | All embeds | Display title/caption where the adapter renders one. For embedded tables, use Markdown headings for visible titles. |
:label, :name | No | All embeds | Alternate display-name fields when :title is absent. |
:alt | No | Image embeds | Image alt text. |
:format | No | Download embeds | Download/export format, for example :csv. |
:partition-key | No | Table/download embeds | Single table-family partition key. |
:partition-keys | No | Table/download embeds | Multiple table-family partition keys when supported. |
:partitions | No | Table/download embeds | Explicit partition target shape when supported by the table service. |
:table | No | Table embeds | Query, aggregate, chart, columns, and partition options. |
:row-transform | No | Table embeds | Snapshot-time sandboxed Clojure function that maps each resolved row to a display row. |
Embed Pattern Matrix
| Pattern | Directive shape | Notes |
|---|---|---|
| Auto | {:resource uri :view :auto} | Uses content type and resource metadata. Prefer explicit views for public outputs. |
| Table query | {:resource uri :view :table :table {:query query}} | Bounded row snapshot. |
| Table aggregate | {:resource uri :view :table :table {:aggregate aggregate}} | Grouped metric snapshot. |
| Table chart | {:resource uri :view :table :table {:query query :chart chart}} | Chart uses the same query/aggregate rows as the table. |
| Download | {:resource uri :view :download} | Table resources default to CSV. |
| Markdown | {:resource uri :view :markdown} | Renders persisted Markdown inline. |
| Text | {:resource uri :view :text} | Renders plain text. |
| JSON | {:resource uri :view :json} | Renders persisted JSON as formatted raw output. |
| Image | {:resource uri :view :image :alt "..."} | Uses signed resource content URLs. |
| Audio | {:resource uri :view :audio} | Uses signed resource content URLs. |
| Video | {:resource uri :view :video} | Uses signed resource content URLs. |
Snapshot And Live Mode
Markdown resource embeds are resolved as snapshots. The resource is read or
queried by the output resolver, converted into viewer metadata, and rendered
from that snapshot in document order.
| Mode | Supported | Behavior |
|---|---|---|
:snapshot | Yes | Default. Resolve the resource into a stable viewer snapshot for the run output. |
omitted :mode | Yes | Same as :snapshot. |
:live | No | Reserved for a future contract. Current renderer returns an inline unsupported-mode fallback. |
V1 does not support live resource-backed pagination, arbitrary re-querying from
the browser, or client-side resource fetches from Markdown embeds. Use bounded
query/aggregate options in the directive so the report output is stable.
Directive blocks are intentionally bounded authoring data. Keep each
breyta-resource block small, use the documented enum-like values for fields
such as :view, :mode, and :format, and put large row shaping logic in flow
functions before persisting the resource. The renderer rejects oversized
directives and unsupported values with an inline fallback.
Table Query Options
Static Markdown tables and Breyta table resource embeds are separate output
patterns. Use normal Markdown table syntax for fixed explanatory rows inside a
report. Use :view :table when the output should render a persisted table
resource with bounded query, aggregate, chart, download, or drilldown behavior.
{:query {:select [:order-id :customer :amount :created-at]
:where [[:status := "open"]]
:sort [[:created-at :desc]]
:page {:mode :offset :limit 25}}}
Field names in :select, :where, :sort, :group-by, :order-by, and
metric :field / :as values may be strings or keywords.
| Field | Required | Meaning |
|---|---|---|
:select | No | Ordered fields to show. Omit only when the table default preview is intended. |
:where | No | Filter clauses, for example [["status" := "open"]]. |
:sort | No | Sort clauses, for example [["created-at" :desc]]. |
:page | Yes for stable public output | Bounded page options. Use {:mode :offset :limit N} in v1 Markdown embeds. |
| Predicate op | Meaning |
|---|---|
:= | Equal. |
:!= | Not equal. |
:> | Greater than. |
:>= | Greater than or equal. |
:< | Less than. |
:<= | Less than or equal. |
:contains | Contains text/value where supported. |
| Sort direction | Meaning |
|---|---|
:asc | Ascending. |
:desc | Descending. |
Table Aggregate Options
{:aggregate {:where [["created-at" :>= "2026-05-01T00:00:00Z"]]
:group-by ["status"]
:metrics [{:op :count :as "orders"}
{:op :sum :field "amount" :as "total-amount"}]
:having [["orders" :>= 1]]
:order-by [["status" :asc]]
:limit 10}}
| Field | Required | Meaning |
|---|---|---|
:where | No | Filters applied before grouping. |
:group-by | Yes | Fields to group rows by. |
:metrics | Yes | Metric maps with :op, optional :field, and :as. |
:having | No | Filters applied after grouping; can reference group keys and metric aliases. |
:order-by | No | Sort clauses for aggregate result rows. |
:limit | No | Bounded aggregate result size. Defaults to 25 rows and is capped at 100 rows. |
Metric :op | Requires :field | Meaning |
|---|---|---|
:count | No | Count rows in the group. |
:sum | Yes | Sum numeric field values. |
:avg | Yes | Average numeric field values. |
:min | Yes | Minimum field value. |
:max | Yes | Maximum field value. |
:count-distinct | Yes | Count distinct field values. |
:arg-max | Yes | Return :field from the row with the largest :order-field. |
:arg-min | Yes | Return :field from the row with the smallest :order-field. |
:collect-set | Yes | Return a bounded deterministic set of distinct field values; include :limit. |
:percentile | Yes | Numeric percentile; include :p in 0.0..1.0. |
:median | Yes | Median numeric field value. |
Metric-local filters are supported:
{:op :count
:where [["status" := "open"]]
:as "open-orders"}
Argument metric example:
{:op :arg-max
:field "order-id"
:order-field "amount"
:as "largest-order-id"}
Bucketed group-by examples:
{:group-by [{:field "created-at"
:bucket {:op :date-trunc :unit :month}
:as "created-month"}]
:metrics [{:op :count :as "orders"}]
:limit 12}
{:group-by [{:field "amount"
:bucket {:op :numeric-bin :size 10}
:as "amount-bin"}]
:metrics [{:op :count :as "orders"}
{:op :percentile :field "amount" :p 0.95 :as "p95-amount"}]
:limit 20}
Table Column Presentation
{:columns {"amount" {:label "Amount"
:format {:display "currency" :currency "USD"}}
"created-at" {:label "Created"
:format {:display "timestamp"}}}}
| Field | Meaning |
|---|---|
:label | Human column heading. |
:format | Display format metadata. |
:semantic-type | Optional semantic hint. |
:type-hint | Optional type hint. |
| Format | Example |
|---|---|
| Currency | {:display "currency" :currency "USD"} |
| Timestamp | {:display "timestamp"} |
| Relative time | {:display "relative-time"} |
{:display "email"} | |
| URL/link | {:display "url"} |
Table Row Transform
Use :row-transform when column labels and built-in formats are not enough for
the final display row. The transform runs once while the Markdown resource
snapshot is produced, after query/aggregate/selection and before the output is
stored. It is not re-run on every page read.
{:resource "res://v1/ws/ws-123/result/table/tbl_orders"
:view :table
:mode :snapshot
:table {:query {:select [:order-id :customer :amount]
:where [[:status := "open"]]
:page {:mode :offset :limit 25}}
:row-transform "(fn [row]\n (assoc row :customer\n (str (:customer row) \" - \"\n (if (< (:amount row) 10)\n \"batch pickup\"\n \"monitor cutoff\"))))"}}
| Rule | Meaning |
|---|---|
| Input | Each function call receives one row map from the bounded snapshot. |
| Output | Return one row map. The renderer preserves row count and order. |
| Timing | Runs at snapshot creation time, not in the browser. |
| Sandbox | Uses the same bounded Clojure sandbox used for flow data transforms. See the :function sandbox helper reference for available breyta.sandbox/*, json/*, string, regex, collection, and limited Java time helpers. |
| Scope | Presentation-only. Use flow steps for durable data normalization. |
| Size | Keep transform source small. Oversized transform forms are rejected before sandbox evaluation. |
Table Chart Options
{:chart {:title "Order count by status"
:x "status"
:series [{:field "orders"
:label "Orders"
:type :bar}]
:height 220}}
Line chart:
{:chart {:title "Order value trend"
:x "created-at"
:series [{:field "amount"
:label "Order value"
:type :line}]
:height 220}}
| Field | Required | Meaning |
|---|---|---|
:title | No | Chart title metadata. Markdown embeds do not render this as extra card chrome. |
:x | No | Category/label field. Defaults to the first visible field. |
:series | Yes | Series maps with :field, optional :label, and optional :type. |
:height | No | Chart height in pixels. Defaults to 220 and is clamped to 120-480. |
:y-min, :y-max | No | Optional y-domain overrides. Defaults include zero. |
| Series field | Meaning |
|---|---|
:field | Numeric field to plot. |
:label | Legend/display label. |
:type | :bar or :line. |
Chart x-axis and hover labels reuse the table column display formatting for the
:x field. For timestamp/date period fields, set the column :format so the
chart shows compact labels instead of raw ISO strings:
{:query {:select [:created-at :amount]
:page {:mode :offset :limit 25}}
:columns {"created-at" {:label "Created"
:format {:display "timestamp"}}}
:chart {:x "created-at"
:series [{:field "amount" :type :line}]}}
Charts include zero in the y-domain by default. Use explicit :y-min and
:y-max chart options when a custom y-domain is required.
Table Family Partitions
| Field | Use when |
|---|---|
:partition-key | Rendering one explicit partition. |
:partition-keys | Rendering several explicit partitions where supported. |
:partitions | Passing the table service's explicit partition target shape. |
Pin partitioned table families for stable snapshots:
{:resource "res://v1/ws/ws-123/result/table/tbl_orders_by_year"
:view :table
:table {:partition-key "2026"
:query {:select ["order-id" "amount"]
:page {:mode :offset :limit 25}}}}
Download Options
| Field | Applies to | Meaning |
|---|---|---|
:format :csv | Table resources | Export/download table snapshot as CSV. |
:partition-key | Table families | Export one partition. |
:title | All downloads | User-facing download card title. |
{:resource "res://v1/ws/ws-123/result/table/tbl_orders"
:view :download
:title "Orders source CSV"
:format :csv}
In the rendered Breyta UI this becomes a compact source/download affordance.
When a user copies the whole Markdown output, the same embed becomes a normal
Markdown link with an absolute Breyta app deep link to the resource viewer:
[Orders source CSV](https://flows.breyta.ai/ws-123/resources/panel?uri=...)
Use this when a report should show a table snapshot inline but also expose the
underlying source/export as a portable link.
Resource Links In Tables
Table cells can point at other resources by storing canonical resource refs in
row data:
{:resource "Analyst note"
:type "Markdown"
:open {:type :resource-ref
:uri "res://v1/ws/ws-123/file/blob/.../analyst-note.md"
:label "Analyst note"}}
The web table renderer displays these cells as clickable resource links. In a
run Output panel, clicking the link opens the target resource in the same panel
and shows a compact Output return link. CLI/API table reads and CSV export
keep the canonical raw resource-ref value. Copied Markdown table output uses the
rendered label for the cell.
Structured Map Output
Do not paste maps into Markdown paragraphs. Use one of these:
| Need | Shape |
|---|---|
| Structured value is the product output | {:breyta.viewer/kind :raw :breyta.viewer/value data} |
| Persisted JSON inside a report | {:resource uri :view :json} inside a breyta-resource fence |
| Supporting detail in a report | Fenced clojure, edn, or json code block |
| Human summary | Convert the data to prose, bullets, or a Markdown table |
Copy Markdown Export
The floating copy action on a Markdown output exports portable Markdown where
resolved resource embeds are converted when possible.
| Resolved embed | Copied Markdown output |
|---|---|
| Table query/aggregate snapshot | Markdown table. |
| Markdown resource | Markdown content. |
| Text resource | Fenced text code block. |
| JSON/raw resource | Fenced clojure code block, pretty-printed when the value is EDN/JSON-like. |
| Image resource | Markdown image link using an absolute Breyta content URL, wrapped in an absolute Breyta resource-viewer link when the resource URI is known. |
| Audio/video/download resource | Markdown link to the absolute Breyta resource viewer when the resource URI is known; otherwise the direct content/download URL. |
| Unsupported conversion | Original breyta-resource fence is preserved. |
Absolute links are built from the current Breyta request host. Resource-backed
links prefer Breyta app deep links so clicking them opens the resource output in
Breyta. Normal Breyta access controls still apply when the linked resource is
opened.