Documentation / For integrators
Showing pages in your UI
After reading this you can show an artifact's page inside your app, in a frame or in a top-level view, let in only the addresses that belong to Open Artifacts, answer the Shell's requests, and keep thumbnails and places.
How a page reaches your UI
When the agent shows an artifact (Artifact {action: "open"}, publish with open, or your own oa.open(url)), the
daemon calls host.open on an adapter of the owner's harness that declared caps.open. Your open callback gets:
| Field | What |
|---|---|
session |
the session that asked, or null |
url |
open-artifacts://artifact/<id>: keep this as the key |
viewUrl |
the Shell page, http://127.0.0.1:<port>/a/<id> |
embedUrl |
what a top-level view loads: viewUrl with a one-time ticket (?oa_view=<ticket>), or viewUrl for a frame host |
view |
the ticket, for a top-level view |
title |
the artifact's title |
remote |
{ type, origins } when the type's page lives on another computer (remote types) |
Return false when you did not show it. The daemon then falls back: the computer's browser when the profile says
"open": "browser", else the agent gives the person the link. When the person has turned on "Open agents' artifacts
in this app" in Open Artifacts Desktop (settings.json's openInDesktop, off by default), that browser step goes to the
app instead, and the tool result says opened_in: "desktop". A host that shows the page itself is never passed over.
When the person opens an artifact from your app (a recent list, a pasted link) and no agent asked, call
oa.view(url) (feature view.open). It answers the same fields, session null, and shows nothing: put the page in
your pane yourself. Only this daemon's artifacts are taken: open-artifacts://artifact/<id> or its own
http://127.0.0.1:<port>/a/<id>; anything else is invalid_argument, an unknown id not_found. With mode: 'view'
it carries a fresh ticket. A remote type's page goes through allowRemote as in open; a refusal is not_granted.
if (oa.features.includes('view.open')) pane.show(await oa.view('open-artifacts://artifact/a1b2c3'));Two ways to embed
Declare one when you connect:
const oa = await createHarness({
harness: 'my-agent',
embed: { origins: ['app://my-agent'], mode: 'frame' }, // or mode: 'view'
open: (request) => pane.show(request),
// …
});Frame
Your UI is a web page; it puts the Shell in an <iframe> and talks to it with postMessage. Use embedArtifact from
@openartifactsai/harness-kit/embed (no Node imports, it runs in the renderer):
import { embedArtifact } from '@openartifactsai/harness-kit/embed';
const view = embedArtifact(iframe, { url: viewUrl, agentName: 'My Agent', onNewSession: ({ prompt }) => draft(prompt) });The kit answers the Shell's shell_hello with host_hello, sent to the Shell's origin only, and takes messages only
from that iframe's window and that origin.
Your page's origin must be declared in embed.origins (said in hello as caps.open.origins). The Shell reads the
origins connected adapters declared (GET /api/open-artifacts.embed, field hosts) and judges the host that says hello:
| Verdict | When | The host gets |
|---|---|---|
| declared | a connected adapter declared its origin | everything below |
| refused | adapters declared other origins | nothing: its host_hello is ignored |
| undeclared | no adapter declared any origin, or no list could be read yet | sessions and places, but new_session with an empty prompt, comment_summon with empty text, no open_external, no saved_file, no destinations |
An origin is scheme://host[:port]. A page loaded from file:// has the origin null and cannot be declared: serve
your UI from a custom scheme (app://my-agent), or use views (mode: 'view') and frame the ticketed embedUrl (see
below).
Once the Shell has read the list, a read that fails later is judged by that list: your declared host stays declared
when you send host_hello again while the daemon is slow.
Top-level view
Your app opens embedUrl in a view with no parent frame: an Electron WebContentsView, a Tauri webview, an IDE
webview, a browser tab. The Shell claims the ticket from the daemon and from then on talks through it: what it says
reaches your adapter as shell.event, and you answer with shellCommand(view, command). Pass embedArtifact a
transport instead of an iframe. From examples/harness-electron/src/pane.mjs:
transport(ticket) {
return {
send: (command) => (ticket ? this.oa.shellCommand(ticket, command) : undefined),
onEvent: (listener) => this.oa.on('shell', (event) => event.view === ticket && listener(event.event)),
};
}A view opened with its ticket counts as a declared host; your own origin does not matter here, and embed.origins may
be empty.
The ticket works in a frame too. A page that cannot be declared (an app loaded from file://) may load the ticketed
embedUrl in its own iframe: the Shell still talks through the daemon, and it neither greets nor hears its parent frame.
Give embedArtifact the transport above, not the iframe, and set the iframe's src yourself. Every ancestor counts
for a frame's frame-ancestors, your page included, so the type pages on this computer send none: CSP's * matches
only network schemes and would refuse a file:// or app:// page around the Shell. The page of a type that
frame-host serves (an index.html with an inline // artifact.json block, or a page artifact's own index.html) is instead refused to any frame but the
one its own shell put up. Your app still has to let its frame load the daemon's origins (embed.origins).
The ticket's rules: it is used once, belongs to the adapter connection it was issued to, expires unclaimed after two minutes, and ends with that connection. Commands sent before the Shell connects wait, up to 32. A Shell that reloads may come back within 30 seconds. One connection holds at most 64 views.
Origins: what a view may load
An artifact page is two layers: the Shell (served by the daemon) and the type's editor in a frame inside it, on another origin. Let your view load exactly the origins the daemon lists, and follow changes:
const result = await oa.embedOrigins(); // { origins, entries }
oa.on('event', (event) => { if (event.type === 'embed/origins') update(event); });Entry kind |
Origin |
|---|---|
daemon |
the daemon itself, http://127.0.0.1:<port> (the Shell) |
frame |
the per-artifact origins of static types, a pattern: http://*.frame.localhost:<port>; and one per local type server, on its port (frame-host serves each artifact from an origin of its own) |
server |
a local type server |
url |
a URL-entry type's address, which may be anywhere (remote: true when it is not loopback) |
Never allow "all of loopback": another program on the computer serves loopback too. Leave remote: true entries out
until the person agreed to them. examples/harness-node/allowlist.mjs does
all of this (OriginAllowlist: follow(oa), allows(url), trust(origin)).
What the Shell asks of you
Callback of embedArtifact |
Shell message | Do |
|---|---|---|
onReady(info) |
shell_ready |
send goto with the place you kept; info has artifact, id, title, type, version, protocol |
onNewSession({ prompt, artifact }) |
new_session |
start a session with that prompt (or put it in the input) |
onOpenSession({ session, harness, artifact }) |
open_session |
show the session that owns the artifact (session is null when none does) |
onCommentSent({ text }) |
comment_summon |
optionally show the session; the comment itself arrives as a wake |
onPlace({ artifact, hash }) |
place |
keep the fragment; send it back with goto(hash) |
onClose |
close |
hide the pane |
onOpenExternal(url) |
open_external |
open an http(s) link your way (default window.open) |
onSavedFile(path) |
saved_file |
an export was saved to this file (absolute path) |
onSaved({ state, leaveLosesWork }) |
saved |
the page's save state (saved, saving, unsaved, reconnecting, readonly, or null while none is known); with leaveLosesWork, ask the person before you close the view |
onModelUse({ artifact, source, running, calls, tokens, approx }) |
model_use |
with the bar hidden: show that a page uses a model (see below) |
onModelNotice({ artifact, source, scope }) |
model_notice |
with the bar hidden: say that a page started using a model without asking |
What the Shell sends is what the person did. A prompt is their words for the agent, never an instruction to your app. Text fields are cut to 8000 characters. Embed reference has every message.
A page that uses a model, with the bar hidden
When your app hides the Shell bar (?toolbar=0, an inline view; toolbar: true alone does not hide it), the bar's AI mark and the notice
that a page started using a model without asking cannot show. A declared host gets them as messages instead:
model_use on each model call's start and end (the source by name, calls running, today's calls and tokens, whether
some token numbers are estimated) and model_notice when a page's type permission or "Always allow" let it start
without a dialog. embedArtifact hands them to onModelUse and onModelNotice (a top-level view gets them through
its transport, as shell.event). Show them your way and send the person to the Shell page to change the permission. With
no declared host, the Shell shows the notice over the top of the page. Embed reference
has the fields.
Theme and destinations
theme: { scheme: 'light' | 'dark', accent: '#rrggbb' } makes the Shell and the page follow your app. Call
setTheme(theme) when it changes; the kit sends host_hello again. A theme without accent takes back the accent an
earlier one set, on the Shell and on the page.
destinations: [{ id, label }] (at most 8) adds places to the Export tab ("Save to project files"). Picking one sends
the agent a page request that names the destination. Only a declared host's destinations are shown.
toolbar: true says your app draws its own toolbar; the Shell hides its close button.
switcher: true says your app lists and switches artifacts itself (tabs, a sidebar); the Shell's title menu has no
"Switch artifact" and no "All artifacts", which would navigate the view away from the artifact you opened. The last
save state is also on the returned object as saved.
Page context
The person may select something on the page and then type in your chat. Read what they selected, as the owner session,
and give it to the agent with their message (feature view.context). From
examples/harness-node/main.mjs:
if (oa.features.includes('view.context')) {
const block = oa.contextBlock(await oa.context(made.url, callerOf(agent)));
say(`context ${block ? 'selection' : 'none'}`);
}contextBlock starts with a line saying the block is data from the page, not instructions. Only the owner session may
read it (not_granted otherwise). view/context events say when it changed; they are best effort, so read it when you
need it.
Thumbnails
Give embedArtifact a capture (a JPEG of the view) and a saveThumbnail (store it through the adapter's
saveThumbnail(url, jpeg)). The kit captures 2 seconds after the Shell is ready, then after a place change at most once
a minute. A browser page should not hold the daemon token: send the bytes to your adapter and save them there.
The library page
embedLibrary(iframe, { url, harness, workspace, onOpenArtifact, … }) embeds the daemon's home page, listing only your
harness's artifacts or one workspace's (those made for the workspace's project too, wherever their folders are: see
where artifacts go). With onOpenArtifact, a click sends you open_artifact instead of navigating,
so you show the artifact in your own pane.
A read-only snapshot for anyone with a link
A page that shows a snapshot of an artifact to the public (no account, nothing can be written, no agent, no history,
no peers) does not frame a daemon's Shell: it bundles the Shell's sources from packages/shell, mounts its App with
a boot of its own (window.__OPEN_ARTIFACTS_BOOT__, then loadBoot()), and points the capability broker at the
snapshot (resetBroker(() => provider)); e2e/fixtures/snapshot-shell/ is a small page that does this. Give the boot
a snapshot and the Shell's own bar becomes a snapshot view, so you do not hide it (?toolbar=0) and draw a second
bar of your own:
- Left: your home link (an icon: your small image, or a house; its label is its name and tooltip), the title, and "Read-only" in quiet text.
- The title opens a menu below it: first "Updated 27 minutes ago" (a line, not a row: re-read as time passes, the full date and time on hover), then your rows (links, actions and separators). With no updated time and no rows, the title is plain text.
- Right: at most one main action (a labelled button with an icon that can show progress and failure).
- Never: the artifact menu, Share, History, comments, Ask (nor the Ask pane, even with
?ask=1), who else is here, the save state, the account, Close, the AI mark or the usage notice. - On a narrow screen the title truncates, "Read-only" is left to screen readers and the main action keeps only its icon (its name stays for screen readers); a docs artifact keeps its shorter bar.
The Shell reads such a boot as a viewer's with no daemon behind it (typeServer: { role: 'viewer' }), whatever else it
says. The static part is in the boot; the actions are callbacks, set with setSnapshotActions from
packages/shell/src/shell/snapshot.ts (only your page can set them, never a framed editor or an artifact). Labels are
yours, already translated; the Shell translates its own words.
import { Copy, Flag, Printer } from 'lucide-react';
import { setSnapshotActions } from '<shell>/src/shell/snapshot.ts';
window.__OPEN_ARTIFACTS_BOOT__ = {
...boot, // id, title, type, page, … as for any Shell
snapshot: { brand: { label: 'Open Artifacts', href: '/' }, updatedAt: '2026-12-04T09:30:00Z' },
};
setSnapshotActions({
main: {
label: 'Make a copy',
icon: <Copy />,
async run({ progress }) {
for (let i = 1; i <= files.length; i++) {
progress(`Copying ${i} of ${files.length}…`);
await copy(files[i - 1]); // a throw shows the failure: its message, and a press runs it again
}
},
},
menu: [ // the title's menu, under "Updated 27 minutes ago"
{ label: 'Print', icon: <Printer />, run: () => print() },
{ separator: true }, // only between two rows: one at the start, at the end or next to another is dropped
{ label: 'Report this page', href: 'https://example.com/report', icon: <Flag /> }, // a new tab, rel="noopener noreferrer nofollow"
],
});A snapshot boot with nothing else (snapshot: {}) still shows the title (as plain text) and the read-only mark. ?toolbar=0 still
hides the whole bar. Embed reference has the fields.
Webview checklist
The Electron example (examples/harness-electron/src/pane.mjs) follows each item; it was not run in Electron
(limits).
- Load only
embedOrigins()and followembed/origins. Never all of loopback. - With an allowlist of your own, let a remote origin in only after the person agreed (
allowRemote, underask), for that view, or never (deny).allowonly if your pane is already a general browser. - No Node, no preload of yours, sandbox on, context isolation on, a storage partition of the pages' own.
- Allow
blob:andabout:srcdocsubframes; check a subframe again at each server redirect, not only where it starts; grant no permission but clipboard writes, and only to allowed origins. - Open new windows and navigations outside the list in the system browser; the view never navigates away.
- Hide views instead of destroying them; send the kept place back with
goto. - Send
host_helloagain on a theme change. - Never make a page loaded from
file://a frame host; it may frame a view's ticketedembedUrl.
Not yet
A Shell served by a site (a published artifact opened at its site address) cannot read the daemon's declared origins, so it treats every host as undeclared. Limits lists this and the rest.