Skip to main content

Overview

Code artifacts render syntax-highlighted code with live preview and execution.

Supported Languages

Code Previews

Code Runtime

HTML

Renders in a sandboxed iframe. External CDNs allowed (Tailwind, etc.).

React / JSX

Available: React hooks, Tailwind CSS, Lucide icons, Recharts.

Vue

JavaScript

Console output (log, warn, error) is captured and displayed.

Python

Runs via Pyodide. Available: numpy, pandas, scipy, scikit-learn, matplotlib.

JSON

Features: tree view, collapse/expand, search, JSONPath.

SVG

CSV / TSV

Renders in an interactive spreadsheet. Auto-detects delimiter (comma, tab, pipe, semicolon). Cells are editable — changes are saved back to the artifact automatically. Use tsv for tab-separated data:

Smart Diff

Use smartdiff for structured diffs with language-aware syntax highlighting:
Each line is highlighted using the actual language grammar (e.g., JavaScript keywords, strings) with red/green backgrounds for deleted/inserted lines. The diff panel shows side-by-side or unified view.

Plain Text

Files with unknown extensions automatically fall back to plain text rendering in the code panel:
Supported via the txt panel type. This means any file type can be opened — if no specific panel exists for the language, it renders as plain text with the code viewer.

Programmatic API

Open code artifacts directly without processing AI message content.

openFile

Auto-detects language from the file extension:

openCode

Specify the language explicitly:

updateFile

Updates an existing artifact’s code and refreshes the panel without creating a duplicate tab:

Options

Both methods accept an options object:

clearArtifacts

Remove all artifacts and close the panel:

Edit Tab

The edit tab provides an in-panel code editor powered by CodeMirror 6. It’s optional — you must provide CodeMirror modules via config to enable it.

Setup

Install the required CodeMirror packages plus any language packages you need:

Supported Language Packages

Pass the modules in your SDK config:

Using the Edit Tab

Once configured, include 'edit' in the tabs array:

Handling Saves

When the user clicks the Save button in the edit tab, an edit:save event fires:

Console Output

HTML artifacts capture console.log, console.warn, console.error, console.info, and uncaught exceptions from user code. A collapsible console footer appears in the panel when entries exist, auto-expanding on errors. The console header includes filter toggles for each log type (error, warn, info, log). Click a filter to hide/show entries of that type. Filters only appear when entries of that type exist. Listen for console events to send errors back to your AI agent:
Set consolePanel: false in config or per-artifact options to hide the footer UI while still receiving events.

Editor Theme

The editor theme is independent of the SDK theme and controlled via editor.theme:
Without the editor config, the edit tab button won’t appear — the feature degrades gracefully. Language modules (e.g. langJavascript, langPython, langHtml) and lezerHighlight are optional but recommended for syntax highlighting. Only include the language packages you need — languages without a matching module fall back to plain text editing.