Official

visuals

HTML pages (html_preview, html_render) and native inline charts, positioned diagrams and sortable tables in agent replies.

The app opens the listing; nothing installs until an agent in your Plugins workspace has read the files and you enable the plugin. In a terminal: dvg install convergence/visuals@0.2.0

Visuals — official plugin

convergence/visuals provides publish_visual for interactive, native visual replies. It ships enabled on a fresh install; an existing install keeps the choice it has, and users can turn it off or on in Settings → Plugins. It starts only when a reply first contains one of its fences and loads Pele only on the first Mermaid fence, so a chat without fences pays nothing. Its only requested permission is tools.provide.

HTML pages (T3 Code's html_preview and html_render)

html.ts holds T3's contract (pingdotgg/t3code b24f0fbb): the tool names, descriptions, limits (HTML 1–512000 UTF-16 units, title 1–200, preview width 240–1600 with 728 by default, frame height 80–2000), the result shapes and messages, the frame-height rule, and the theme bootstrap with Divergence's colours. Both tools are direct, so in code mode they stay tools of their own and the preview's PNG reaches the agent as an MCP image part.

  • html_preview sends the themed page to host/web.preview. With a confined renderer it answers T3's metadata as text and structured content plus the PNG. Without one it is an error, HtmlBackendUnavailable: <raw reason>, with no image: nothing renders unconfined and no screenshot is made up.
  • html_render saves the agent's page unchanged as a html v1 transcript artifact (the host stamps the owner) and answers T3's htmlRender reference and message. Measured heights are not supplied.
  • Inline (html-view.ts) the page is live (ui.webDocument): borderless in the reply, as wide as the column and as tall as the page up to the agent's height, with one small glass Open in panel control. The panel is a detail-pane tab (the convergence/tabs service): the page live again, its Source, Copy and Save (kernel/copy_text, kernel/save_text, both after a click).

The renderer is the host's: Debian's Chromium in a disposable container of the local Docker engine, admitted through chrome://sandbox (crates/host/src/web). Differences from T3 and from a system web view: pages are offline (remote URLs and local image paths never load; missingImages lists the paths a page names), fonts and text metrics are Linux's (DejaVu, Liberation, Noto Color Emoji), there is no GPU, and native browser menus, pickers, IME composition, accessibility, clipboard and drag from the page are not available. Without Docker or the built renderer image the page says why and its source, copy and save still work.

Version 2 supports responsive multi-panel compositions: bar (grouped/stacked/ percent; horizontal/vertical), line, area, scatter/bubble, pie/donut, heatmap, histogram, range/timeline, waterfall and boxplot, plus metrics, text, typed tables and positioned diagrams. document.ts defines the strict, bounded JSON schema; rules.md is the agent-facing reference. Version 1 documents still replay.

Rendering and interaction

Rust/GPUI draws every shape, label, control and floating tooltip. A pinned, DOM-free D3 math subset computes scales, numeric/UTC ticks and paths inside QuickJS; there is no browser, JavaScript UI execution, graph auto-layout, network, file, process or plugin-storage access. math.LICENSES.txt includes provenance and licenses; scripts/bundle-visuals-math.mjs reproduces the readable bundle.

Charts use the native canvas's onResize({width,height}) logical-pixel measurement, not a scaled viewBox. Text remains readable as panels grow or wrap. Compact legends keep original domains, colors and percentage denominators when hidden. Null breaks paths and stays explicitly missing in shared bar inspection.

Hover opens a clamped floating tooltip; click pins/unpins. Arrow keys, Home/End traverse observations, Enter/Space pin, Escape clears inspection. In the expanded overlay Escape unpins first, then closes. Tables retain stable raw row identity, sort nulls last in either direction, paginate and expose full selected values. Diagram node details remain accessible through a native picker.

State and cached geometry belong to each artifact's ctx.state, with separate panels and inline/expanded inspection. Hover does not recompute paths. Native resize reports are change-only and coalesced off-paint. No JavaScript frame loop or render-time notification runs.

Persistence and compatibility

The host owns immutable transcript artifacts. ctx.artifacts.publish persists the complete document independently of the surrounding tool result, including discarded acknowledgements and later code-mode errors. The plugin registers removable visual renderers for versions 1 and 2; Source retains original input and Data retains all raw values, including hidden series and nulls.

This plugin requires the updated native host and canvas resize API. Older hosts without artifact support fail with an explicit update message. Invalid persisted documents keep their readable summary and expose a validation error.

Verification

node --import ./plugins/testing/register.mjs --test plugins/visuals/*.test.ts
pnpm -C plugins typecheck
pnpm -C plugins exec prettier --check 'visuals/**/*.{ts,json,md}'

Geometry tests use asymmetric data and independent numeric expectations; view tests exercise real native element factories and handlers. Native desktop checks and app-owned Metal captures supplement these tests; they do not use a browser.

Permissions in 0.2.0

  • Provide agent tools tools.provideMediumGives tools to agents.Let agents preview and publish HTML pages and bounded visual replies into the current chat

Files

document.test.ts10.3 KB
// Boundary coverage for the bounded agent JSON format and all relational validation.
import assert from "node:assert/strict";
import { test } from "node:test";
import * as z from "zod";
import {
  chartSchema,
  diagramSchema,
  tableSchema,
  visualDocumentSchema,
  richVisualDocumentSchema,
  richChartSchema,
  numberFormatSchema,
  LIMITS,
} from "./document.ts";
import { chartDocument, diagramDocument, tableDocument } from "./testing.ts";

test("strict versioned documents reject executable/resource/UI-shaped extras at every level", () => {
  for (const document of [chartDocument, diagramDocument, tableDocument])
    assert.deepEqual(visualDocumentSchema.parse(document), document);
  for (const extra of ["html", "svg", "ui", "onClick", "path", "url", "source"])
    assert.equal(visualDocumentSchema.safeParse({ ...chartDocument, [extra]: "unsafe" }).success, false);
  assert.equal(visualDocumentSchema.safeParse({ ...chartDocument, version: 2 }).success, false);
  assert.equal(
    visualDocumentSchema.safeParse({ ...chartDocument, body: { ...chartDocument.body, onClick: "run()" } }).success,
    false,
  );
  // Plain strings are not interpreted as HTML: a text cell may safely describe markup.
  assert.equal(
    tableSchema.safeParse({
      kind: "table",
      columns: [{ key: "text", label: "Text", type: "text" }],
      rows: [["<b>inert text</b>"]],
    }).success,
    true,
  );
  assert.doesNotThrow(() => z.toJSONSchema(visualDocumentSchema));
});

test("title/summary/label bounds and meaningful summary are required", () => {
  for (const summary of [undefined, "", "   \n", "---", "x".repeat(2001)])
    assert.equal(visualDocumentSchema.safeParse({ ...chartDocument, summary }).success, false);
  assert.equal(visualDocumentSchema.safeParse({ ...chartDocument, title: "x".repeat(161) }).success, false);
  assert.equal(
    visualDocumentSchema.safeParse({ ...chartDocument, title: "x".repeat(160), summary: "x".repeat(2000) }).success,
    true,
  );
  assert.equal(
    chartSchema.safeParse({
      kind: "chart",
      chart: "line",
      categories: ["x".repeat(121)],
      series: [{ name: "Score", values: [1] }],
    }).success,
    false,
  );
});

test("charts enforce finite bounded values, matching lengths, series and aggregate value budgets", () => {
  const chart = { kind: "chart", chart: "line", categories: ["A"], series: [{ name: "Score", values: [0] }] };
  for (const value of [NaN, Infinity, -Infinity, LIMITS.magnitude + 1, -LIMITS.magnitude - 1, "1"])
    assert.equal(chartSchema.safeParse({ ...chart, series: [{ name: "Score", values: [value] }] }).success, false);
  for (const value of [null, LIMITS.magnitude, -LIMITS.magnitude])
    assert.equal(chartSchema.safeParse({ ...chart, series: [{ name: "Score", values: [value] }] }).success, true);
  assert.equal(chartSchema.safeParse({ ...chart, series: [{ name: "Score", values: [1, 2] }] }).success, false);
  assert.equal(
    chartSchema.safeParse({ ...chart, series: Array.from({ length: 9 }, () => chart.series[0]) }).success,
    false,
  );
  const categories = Array.from({ length: 1000 }, (_, i) => String(i));
  assert.equal(
    chartSchema.safeParse({ ...chart, categories, series: [{ name: "Score", values: categories.map(() => null) }] })
      .success,
    true,
  );
  assert.equal(
    chartSchema.safeParse({
      ...chart,
      categories,
      series: ["A", "B"].map((name) => ({ name, values: categories.map(() => 0) })),
    }).success,
    false,
  );
});

test("diagrams enforce unique ids, valid edge references, finite positions and whole-node bounds", () => {
  const body = diagramSchema.parse(diagramDocument.body);
  assert.equal(diagramSchema.safeParse({ ...body, nodes: [body.nodes[0], body.nodes[0]] }).success, false);
  assert.equal(diagramSchema.safeParse({ ...body, edges: [{ from: "client", to: "unknown" }] }).success, false);
  assert.equal(diagramSchema.safeParse({ ...body, edges: [{ from: "client", to: "client" }] }).success, true);
  for (const patch of [{ x: -1 }, { y: Infinity }, { width: 0 }, { x: 399 }, { height: 201 }, { onClick: "click" }])
    assert.equal(
      diagramSchema.safeParse({ ...body, nodes: [{ ...body.nodes[0], ...patch }, body.nodes[1]] }).success,
      false,
    );
  assert.equal(diagramSchema.safeParse({ ...body, width: 10001 }).success, false);
  assert.equal(
    diagramSchema.safeParse({
      ...body,
      nodes: Array.from({ length: 101 }, (_, i) => ({ ...body.nodes[0], id: `node-${i}` })),
    }).success,
    false,
  );
  assert.equal(
    diagramSchema.safeParse({ ...body, edges: Array.from({ length: 201 }, () => body.edges[0]) }).success,
    false,
  );
});

test("tables enforce unique keys, exact row width, cell types and row/column/text budgets", () => {
  const body = tableSchema.parse(tableDocument.body);
  for (const rows of [
    [["A", "2", true]],
    [["A", 2, 1]],
    [[2, 2, true]],
    [["A", 2]],
    [["A", 2, true, null]],
    [["x".repeat(121), 2, true]],
  ])
    assert.equal(tableSchema.safeParse({ ...body, rows }).success, false);
  assert.equal(tableSchema.safeParse({ ...body, rows: [[null, null, null]] }).success, true);
  assert.equal(
    tableSchema.safeParse({ ...body, columns: [body.columns[0], body.columns[0]], rows: [] }).success,
    false,
  );
  const columns = Array.from({ length: 20 }, (_, i) => ({ key: `c-${i}`, label: `Column ${i}`, type: "number" }));
  const rows = Array.from({ length: 200 }, () => columns.map(() => 0));
  assert.equal(tableSchema.safeParse({ kind: "table", columns, rows }).success, true);
  assert.equal(tableSchema.safeParse({ kind: "table", columns, rows: [...rows, rows[0]] }).success, false);
  assert.equal(
    tableSchema.safeParse({
      kind: "table",
      columns: [...columns, { key: "extra", label: "Extra", type: "text" }],
      rows: [],
    }).success,
    false,
  );
});

test("v2 validates analytical relations instead of accepting merely well-shaped charts", () => {
  const line = {
    kind: "chart",
    chart: "line",
    x: { type: "number", values: [1, 8, 10] },
    series: [{ name: "A", values: [2, null, 9] }],
  };
  assert.equal(richChartSchema.safeParse(line).success, true);
  for (const values of [
    [1, 1, 10],
    [10, 8, 1],
  ])
    assert.equal(richChartSchema.safeParse({ ...line, x: { type: "number", values } }).success, false);
  assert.equal(richChartSchema.safeParse({ ...line, series: [{ name: "A", values: [2, 9] }] }).success, false);
  assert.equal(richChartSchema.safeParse({ ...line, bands: [{ from: 9, to: 2, label: "Bad" }] }).success, false);
  for (const count of [-1, NaN])
    assert.equal(
      richChartSchema.safeParse({ kind: "chart", chart: "histogram", bins: [{ from: 0, to: 2, count }] }).success,
      false,
    );
  assert.equal(
    richChartSchema.safeParse({
      kind: "chart",
      chart: "histogram",
      bins: [
        { from: 0, to: 3, count: 1 },
        { from: 2, to: 4, count: 2 },
      ],
    }).success,
    false,
  );
  assert.equal(
    richChartSchema.safeParse({
      kind: "chart",
      chart: "heatmap",
      x: ["X"],
      y: ["Y"],
      cells: [
        { x: 0, y: 0, value: 1 },
        { x: 0, y: 0, value: 2 },
      ],
    }).success,
    false,
  );
  assert.equal(
    richChartSchema.safeParse({
      kind: "chart",
      chart: "box",
      items: [{ label: "A", min: 1, q1: 4, median: 3, q3: 8, max: 10 }],
    }).success,
    false,
  );
  const range = { kind: "chart", chart: "range", items: [{ label: "A", start: 0.2, end: 0.8 }] };
  assert.equal(richChartSchema.safeParse(range).success, true);
  assert.equal(richChartSchema.safeParse({ ...range, axis: "time" }).success, false);
});

test("percent stacks, parts and formatting reject misleading interpretation", () => {
  const bar = {
    kind: "chart",
    chart: "bar",
    stack: "percent",
    x: { type: "category", values: ["A"] },
    series: [{ name: "A", values: [0] }],
  };
  assert.equal(richChartSchema.safeParse(bar).success, true, "zero total is an explicit rendered state");
  assert.equal(richChartSchema.safeParse({ ...bar, series: [{ name: "A", values: [-1] }] }).success, false);
  assert.equal(richChartSchema.safeParse({ ...bar, references: [{ label: "Raw", value: 10 }] }).success, false);
  assert.equal(
    richChartSchema.safeParse({
      kind: "chart",
      chart: "pie",
      parts: [
        { label: "A", value: 1 },
        { label: "A", value: 3 },
      ],
    }).success,
    false,
  );
  assert.equal(numberFormatSchema.safeParse({ style: "currency" }).success, false);
  assert.equal(numberFormatSchema.safeParse({ style: "number", currency: "USD" }).success, false);
  assert.equal(numberFormatSchema.safeParse({ style: "currency", currency: "USD", precision: 2 }).success, true);
});

test("composition enforces aggregate resource budgets, unique ids and no executable extras", () => {
  const panel = {
    id: "p",
    body: {
      kind: "table",
      columns: Array.from({ length: 20 }, (_, i) => ({ key: `c${i}`, label: `C${i}`, type: "number" })),
      rows: Array.from({ length: 200 }, () => Array(20).fill(1)),
    },
  };
  const document = {
    version: 2,
    title: "Budget",
    summary: "All panels share the same resource budget.",
    panels: [panel, { ...panel, id: "q" }],
  };
  assert.equal(richVisualDocumentSchema.safeParse(document).success, true, "8000 cells are accepted");
  assert.equal(
    richVisualDocumentSchema.safeParse({
      ...document,
      panels: [...document.panels, { ...panel, id: "r", body: { ...panel.body, rows: [panel.body.rows[0]] } }],
    }).success,
    false,
  );
  assert.equal(richVisualDocumentSchema.safeParse({ ...document, panels: [panel, panel] }).success, false);
  for (const extra of ["html", "onClick", "ui", "url"])
    assert.equal(
      richVisualDocumentSchema.safeParse({ ...document, panels: [{ ...panel, [extra]: "run" }] }).success,
      false,
    );
  const sparse = {
    id: "s",
    body: {
      kind: "chart",
      chart: "scatter",
      series: [{ name: "A", points: Array.from({ length: 1000 }, (_, i) => ({ x: i, y: i % 3 })) }],
    },
  };
  assert.equal(
    richVisualDocumentSchema.safeParse({ ...document, panels: [sparse, { ...sparse, id: "t" }] }).success,
    true,
  );
  assert.equal(
    richVisualDocumentSchema.safeParse({
      ...document,
      panels: [sparse, ...["t", "u", "v"].map((id) => ({ ...sparse, id }))],
    }).success,
    false,
    "composition cannot multiply command/path budgets",
  );
  assert.doesNotThrow(() => z.toJSONSchema(visualDocumentSchema));
});

Versions

VersionPublishedPlugin APISizePermissionsStatus
0.2.2latestNov 21, 2026>=2 <4349.5 KB1 permissionListed
0.2.1Oct 25, 2026>=2 <4349.2 KB1 permissionListed
0.2.0Oct 23, 2026>=2 <4349.3 KB1 permissionListed

Reviews and comments

0 threads · 0 reviews

No comments yet.