Documentation / For integrators

Integrating Open Artifacts into an agent product

This guide is for engineers who ship an agent product: a desktop app (Electron, Tauri), an IDE extension, a command-line agent, or a web app with a local helper, in JavaScript or not. After reading it you can make three things work:

  1. your agent makes artifacts (decks, designs, docs, sheets, dashboards, boards, films) with Open Artifacts' tools;
  2. the artifacts' pages show inside your UI;
  3. what people write on those pages (comments, Ask, page requests) comes back into the right agent session.

You can stop at any level below and have something that works. Each level says what to write, what the person sees, and how to check it.

The parts

 your app ─────────── your adapter ──────── harness kit ─── WebSocket /__harness ───▶ daemon (one per computer)
 (chat, sessions,     (the code you write:   (@openartifactsai/       JSON-RPC 2.0          │  tools, library, wake,
  tool registry, UI)   sessions, tools,       harness-kit, or the                        │  type servers
                       wakes, pages)          stdio bridge)                              ▼
                                                                               Shell page  /a/<id>
 your UI ◀── iframe or top-level view ──────────────────────────────────────── (title bar, comments, share,
                                                                                export, "Ask") around the page
  • The daemon (open-artifacts daemon) runs once per computer and per Open Artifacts home (~/.agents/open-artifacts, or $OPEN_ARTIFACTS_HOME). It owns the artifact library, the three agent tools, the type servers and the inbox of messages for agent sessions. Every agent app on the computer shares it.
  • The Shell is the daemon's page at http://127.0.0.1:<port>/a/<id>. It frames the artifact's editor and draws the title bar, comments, share and export. It talks to whoever embeds it.
  • Your adapter is the code you write. It connects to the daemon as your harness (a name such as my-agent), tells it which sessions exist, gives your agent the tools, takes wakes, and shows pages.
  • The kit (@openartifactsai/harness-kit, Node 22.18+ or Electron's Node) does the connection for a JavaScript adapter: it finds or starts the daemon, reconnects (not after the person stopped the daemon from your app: restart and stop), attaches sessions again, and wraps every call. A program in another language runs open-artifacts harness --stdio instead (non-node).

Pick a level

Level You write The person sees Comments come back
0. Skill + command line Copy the skill; the agent runs open-artifacts … in a shell A link to the page in the chat In the result of the agent's next call, or while it runs open-artifacts wait
1. MCP An MCP server entry (and hooks, if your app has them) A link, or your app's browser In the next tool result; with hooks, at session start, with the next message, at the end of a turn
2. The kit An adapter: sessions, native tools, a wake callback A link Right away, into the session that owns the artifact
3. Pages in your UI An open callback and an embedding The page beside the chat As above, plus Ask starts or opens your sessions
4. The library Cards or a list from artifact events Cards under messages, or your own artifact list As above

The shipped integrations sit at these levels: Claude Code, Codex, Cursor, Copilot, Antigravity, Grok Build, ZCode and Devin are level 1 with hooks; DeepSeek Harness (plugins/dsh), Pi (plugins/pi) and OMP (plugins/omp) are full adapters on the kit; Hermes Agent (plugins/hermes) is a full adapter in Python over open-artifacts harness --stdio. plugins/README.md lists them.

Level 0: the skill and the command line

Any agent that can read a skill file and run a command can use Open Artifacts. Write the skill into your app's skill folder, under the command you want the person to type:

open-artifacts skill install --command open-artifacts --dir ~/.my-agent/skills

This writes ~/.my-agent/skills/open-artifacts/SKILL.md, rendered for your harness when you add --harness my-agent (its agent name, command, rules). It writes again only when the text changed (an etag in the file), and it leaves alone a SKILL.md there that Open Artifacts did not write, unless you pass --force. open-artifacts skill render prints the same text without writing it.

The agent then calls the tools from the command line, one JSON argument each:

open-artifacts artifact '{"action":"quickstart"}'
open-artifacts comments '{"action":"wait"}'

open-artifacts is the @openartifactsai/cli package, or node <plugin>/skills/open-artifacts/scripts/open-artifacts.mjs inside a plugin. It starts the daemon when none runs.

  • What the person sees: the agent replies with the artifact's view_url; they open it in a browser.
  • How comments come back: in the messages of the agent's next tool result, or while it runs open-artifacts wait.
  • Check: open-artifacts doctor says the home, the daemon, the runtime and the installed types are fine.

Level 1: MCP

If your agent takes MCP servers, add one that runs the bridge over stdio:

node <plugin>/skills/open-artifacts/scripts/open-artifacts.mjs mcp --harness my-agent

--harness names your harness, so calls from it are tied to your profile (its agent name, its sessions). The agent gets Artifact, ArtifactData and ArtifactComments, and ShowArtifact when the client shows MCP Apps.

The session id comes from your profile's sessionEnv. When your app's variable is set in every terminal it opens, the person's own commands included (Orca's ORCA_PANE_KEY), it cannot be a sessionEnv, which marks a command as an agent's; name it on the command line instead: mcp --harness my-agent --session-env MY_PANE_ID.

Comments reach an MCP-only agent in the messages of its next tool result. If your app has hooks, run open-artifacts hook <event> --harness my-agent from them and comments arrive at session start, with the person's next message, and at the end of a turn. The hook reads your app's hook input on stdin and answers in your app's format; the profile's hookDialect says which (claude-code, cursor, copilot, antigravity, grok, or a mapping of your own, profile reference).

Tell the daemon about your harness with a profile. Ship it inside your plugin and have the person (or your installer, from the person's own terminal) add it:

open-artifacts harness add my-agent.json
open-artifacts harness list
  • What the person sees: a link, or your app's built-in browser if the agent opens the view_url there. A profile with "open": "browser" has the daemon open the computer's browser when the agent asks it to show a page (or, when the person turned on "Open agents' artifacts in this app", hand it to Open Artifacts Desktop: opened_in: "desktop").
  • Check: open-artifacts doctor --harness my-agent reports the profile, and once your app runs, its connection.

Level 2: the kit — native tools, sessions, wake

At this level your app holds a live connection. Pages still open by link, but comments reach the session that owns the artifact the moment they are sent. The code below is from examples/harness-node, which the repository's test suite runs against a real daemon.

Connect

From examples/harness-node/harness.mjs:

export function connectHarness({ name = 'example-node', agentName = 'Example', wake, runtime = hostRuntime(), ...options } = {}) {
  return createHarness({
    harness: name,
    agentName,
    ...(runtime ? { runtime } : {}),
    commands: ['open-artifacts'],
    caps: { wake: { resume: true }, tools: 'native', library: 'own' },
    wake,
    ...options,
  });
}
export function callerOf(session) {
  return { session: session.id, workspace: session.workspace };
}

createHarness finds the running daemon through daemon.json in the Open Artifacts home, or starts one. To start one it needs a runtime: pass runtime: { dir, version } (the @openartifactsai/cli folder your app carries), or set OPEN_ARTIFACTS_DAEMON_BIN. Without either, and with no runtime registered on the computer, it fails with no_daemon (runtime).

The example tells the kit which runtime it ships with hostRuntime(), from the same file:

export function hostRuntime(folders = runtimeFolders()) {
  for (const dir of folders) {
    const version = runtimeInfo(dir)?.version;
    if (version) return { dir, version };
  }
  if (process.env.OPEN_ARTIFACTS_DAEMON_BIN) return undefined;
  throw new Error('No Open Artifacts runtime: install @openartifactsai/cli (npm install @openartifactsai/cli), or in this repository build it (npm run build, then node scripts/build-plugins.mjs).');
}

runtimeFolders() lists the installed @openartifactsai/cli package and, in this repository, the built skills/open-artifacts; runtimeInfo (from the kit) reads a folder's version. Your app returns the folder inside its own bundle.

caps tells the daemon what your adapter does. The kit adds wake only when you pass a wake callback and open only when you pass an open callback, so you cannot claim what you do not handle.

Attach sessions

A session is one conversation of your agent. Attach it when it starts, set its status when a turn starts and ends, and detach it when it closes. From examples/harness-node/main.mjs:

await oa.attach({ ...callerOf(agent), title: agent.title, status: 'running' });
// …
await oa.status(callerOf(agent), 'idle');

session is your id for it and workspace the project folder it works in. While a session is running, the pages of the artifacts its turn works on (it called a tool on one, made, opened or wrote it, or took a wake for it) say its agent is working, the Shell's top bar included, from that moment on (an empty canvas says so instead of asking for content); its other artifacts' pages stay as they are. Set it back to idle when the turn ends. The kit attaches every session again after a reconnect. What waited in a session's inbox while it was away goes to your wake callback on attach.

Register the tools

Register the daemon's tools in your agent's own tool registry, each call going back with the session as caller. From examples/harness-node/tools.mjs:

export async function registerTools(oa, agent) {
  const definitions = await oa.tools();
  for (const tool of definitions) {
    agent.register(tool.name, {
      description: tool.description,
      inputSchema: tool.inputSchema,
      run: (args) => oa.call(tool.name, args, callerOf(agent)),
    });
  }
  return definitions.map((tool) => tool.name);
}
export function reportWrites(oa, agent, paths) {
  return oa.wrote(paths, callerOf(agent));
}

The caller is what makes the session the artifact's owner, so comments come back to it. When your agent writes files into an artifact's folder with its own file tools, report them with wrote (agent.wrote): the daemon records that the agent wrote them, so they are not reported back as the person's changes. Tools covers action kinds, what leaves the computer, and session permissions.

Take wakes

When the person sends comments or uses Ask on a page, the daemon calls wake.deliver on the adapter of the session that owns the artifact. From examples/harness-node/wakes.mjs:

export function routeOf(params) {
  return params.source?.from?.kind === 'owner' ? 'turn' : 'notice';
}
export function wakeHandler(sessions, { onWake = () => undefined } = {}) {
  return (params) => {
    const agent = params.session ? sessions.get(params.session) : null;
    if (!agent) return 'failed';
    const route = routeOf(params);
    agent.add(route === 'turn' ? 'user' : 'notice', params.text);
    onWake(params, route, agent);
    return 'delivered';
  };
}

Only the owner's words become a user turn. A comment from someone the artifact was shared with, or a finished background task, is a notice the agent sees with the next turn. Answer failed when you could not take it: the daemon keeps the message in the inbox. Wake explains every answer and why the routing matters.

An artifact the person made on the home page has no session to wake. Pass startSession and its page offers "New session" in your app, also while none of your sessions is attached: the kit declares caps.sessions.start, and your callback starts a session whose first message is text (starting a new session):

startSession: async ({ text, artifact }) => {
  const session = await myApp.newSession({ title: artifact.title, firstMessage: text });
  return { session: session.id }; // the daemon makes it the artifact's owner
},

Pass sessionModels as well and the person picks the model and its reasoning effort first; they reach startSession as model and effort (letting the person pick the model).

Check it

node examples/harness-node/main.mjs --workspace /tmp/demo --once

It prints connected, tools, skill, published, opened and ready <url>. Open the page (open-artifacts open <url> prints its address), comment and press Send to agent: the line wake turn comment from owner on "…" appears. In a second terminal, open-artifacts doctor --harness example-node shows the adapter connected (run it while main.mjs runs without --once).

Level 3: show pages in your UI

Pass an open callback and say how you embed. The daemon then calls host.open instead of handing the agent a link, and your app shows the Shell page.

Way What you load How messages travel Use it when
Frame viewUrl in an <iframe> of your page postMessage between your page and the Shell your UI is a web page served from an origin of your own
Top-level view embedUrl (with a one-time view ticket) in a webview, tab or window through the daemon: shell.event to your adapter, shellCommand back Electron, Tauri, an IDE webview, or any view without a parent frame

The view way, from examples/harness-electron/src/pane.mjs (this example was not run in Electron, see limits):

const embed = embedArtifact(this.transport(request.view), {
  url: request.embedUrl,
  harness: 'electron-example',
  agentName: this.agentName,
  toolbar: false,
  theme: themeOf(),
  // …
  capture: async () => (await view.webContents.capturePage()).toJPEG(70),
  saveThumbnail: (jpeg, artifact) => this.oa.saveThumbnail(artifact, jpeg),
});

Three rules decide whether this works safely:

  • Load only the daemon's origins. embedOrigins() lists them, and embed/origins events change them. Never let in "all of loopback". examples/harness-node/allowlist.mjs does this.
  • Declare your own origin for a frame. embed: { origins: ['https://app.example.com'], mode: 'frame' }. The Shell gives an undeclared host no prompt text, no comment text, no links out, no saved files and no destinations. A page loaded from file:// has origin null and can never be declared: serve your UI from a custom scheme or use a top-level view.
  • A remote type's page asks first. A type whose page lives on another computer arrives with remote; the kit asks your allowRemote before showing it (embed.remote: 'ask', the default), or never shows it (deny). allow is only for a host whose pane is already a general browser (remote types).

The page tells you where the person is (onPlace), what they selected (context(), feature view.context), and asks you to start or open sessions (onNewSession, onOpenSession). It also says its save state (onSaved), so your app can ask before closing a view that would lose work; switcher: true hides the Shell's own artifact switcher when your app has tabs. To show an artifact the person picked in your app, with no agent asking, call oa.view(url) (feature view.open). Embedding has the whole list and a webview checklist; embed reference has every message.

  • What the person sees: the page opens beside the chat; Ask goes to your session; thumbnails appear in the library.
  • Check: main.mjs prints opened in-host when your open callback took the page; your view loads only origins in the allowlist.

Level 4: the library

Your app can show the person's artifacts its own way. Three choices, said as caps.library:

  • home: embed the daemon's home page with embedLibrary, filtered to your harness or workspace.
  • cards: a card under the message that made or changed an artifact.
  • own: your own list, kept from artifact events.

The value is a declaration: the daemon records it and shows it (its log, GET /api/open-artifacts.harnesses, doctor --session), and nothing it or the Shell does depends on it. Leave library out when your app has no place that lists artifacts; there is no value for that, and artifact events and the home page work the same either way.

From examples/harness-node/artifacts.mjs, a card per artifact and session, keyed by the open-artifacts:// link:

export function cardOf(report) {
  if (report.change === 'removed') return null;
  const { artifact } = report;
  return { url: artifact.url, title: artifact.title, type: artifact.type, thumbnail: artifact.thumbnail, updatedAt: artifact.updatedAt };
}

on('artifact') reports each artifact that is created, updated or removed in the library, with who changed it and which files. session and workspace are set when one of your harness's sessions owns it; a removed report carries no session, so find the card by its link: followArtifacts in the same file drops it from every session. Keep the open-artifacts://artifact/<id> link as the key: the page address can change when the daemon restarts on another port, and viewUrl(url) gives the current one.

Optional: answer pages' model calls

A page can ask a model for text, and the person picks who answers. Pass sample to createHarness and your app is one of the choices: it answers each round with its own model and quota, while the daemon keeps consent, limits, the cache and the tool rounds.

const oa = await createHarness({
  harness: 'my-agent',
  wake,
  sample: {
    caps: { stream: true },
    run: async (round, { onText, signal }) => myModel.answer(round, { onText, signal }),   // → { text, stop, model?, usage? }
  },
});

The round is not a turn of the session that owns the artifact: no history, no session tools, and session only for reference. Sampling covers the round, streaming, cancelling, refusing and testing it.

Optional: lend your app's MCP servers to pages

A page can call tools of MCP servers. Besides the computer's connectors (connectors.json), it can name one of your app's servers as host:<name>. Pass mcp to createHarness to lend them: you list the servers and their tools and run each call, while the daemon keeps the page's declaration, the person's permission, the confirmation of calls that may change something, and the counts.

const oa = await createHarness({
  harness: 'my-agent',
  wake,
  mcp: {
    listTools: async ({ server }) => ({ servers: await myApp.mcpServers(server) }),   // [{ server, tools, authStatus? }]
    callTool: async ({ server, tool, arguments: args }, { signal }) => myApp.mcpClient(server).callTool({ name: tool, arguments: args }, { signal }),
  },
});

Connectors covers the order of checks, refusals, cancelling and testing.

Commands and the skill

The person types a command to ask for an artifact. The default is /open-artifacts <type> <what to make>; your app may use its own name, given in commands (createHarness({ commands: ['artifact'] })) or the profile.

  • installSkill({ dir, agentName, tools, opens }) writes the skill rendered for your harness, as skill install does, and writes it again after a runtime update changes it. See examples/harness-node/skill.mjs.

  • opens says how the page reaches the person, and so how the skill's "show it" step reads. Pass it to installSkill, renderSkill, localSkill and keepSkillInstalled:

    opens The skill tells the agent Use it when
    host your app shows the page by itself after the first write; with open: "never", call Artifact open and the app shows it you pass an open callback (caps.open)
    agent-browser open view_url in its own browser panel or tab your agent has a browser tool and you show no pages yourself
    system the page opens in the computer's browser after the first write; otherwise Artifact open opens it there the computer's browser is where the person looks
    link nothing opens by itself; give the person view_url as a link neither of the above

    Left out, the daemon's rendering (skill.get) uses host when your caps have open (from hello or your profile), else a general step: the agent's built-in browser if it has one, otherwise Artifact open in the computer's browser. Harness.installSkill does the same for the kit's own rendering (used when the daemon is not connected or lacks skill.get): it passes opens: 'host' when you gave createHarness an open callback. An opens you pass always wins. The standalone helpers (installSkill(client, …), renderSkill, localSkill) know nothing of your callbacks: pass opens to them yourself.

  • commands() (commands.list) gives one entry per installed type for your command menu: the text to insert (/artifact slides ), a title, a description and starting prompts.

  • The skill and quickstart read the same options: your command, agent name, how the agent calls tools, how pages open, your rules, and the action kinds you confirm with the person.

Your harness's rules come in two kinds. rules is text (at most 4000 characters) that the daemon puts first in the skill, saying it wins over the instructions after it; it changes no permission. policy is data the daemon acts on: offer (make artifacts only when asked, or offer them), reuse (where quickstart looks for one to reuse), artifacts (where new artifacts go by default: home, the person's Open Artifacts folder, or workspace; say workspace when your app does not let its agent write outside the working folder, see Settings), roles (what each kind of session may do) and confirm (action kinds the person approves each time). Per-session permissions go in attach({ may, role }) and are enforced when the daemon lists session.may (tools).

The profile

The daemon knows each harness by a profile: its title, agent name, level, how it reaches the daemon, its markers and session variable, its hook format, and more. Profiles come from three places:

Source Where Who writes it Wins over
user <home>/harnesses/<name>.json the person, with open-artifacts harness add everything
adapter the same file, "source": "adapter" your adapter, in hello (profile) the shipped one, field by field
shipped packages/daemon/harnesses/<name>.json in the runtime Open Artifacts' release the defaults

Your adapter may report almost everything about itself. It may never set nudge, start, mcp, skillsDir, sessionWorkspace, source or name: nudge, start and sessionWorkspace make the daemon run a program or read files, so only a file on disk that ships with Open Artifacts or that the person added may say them. A reported profile never overwrites the person's own file. Profile reference lists every field.

An app with no adapter can still be offered as "New session" for an artifact no session owns: its profile's start names the command line the daemon runs to start one (profile reference).

Give your app's display name as the profile title; with the kit, createHarness({ profile: { title: 'My App' } }) reports it in hello. The Shell uses it wherever it names the harness to a person: the Ask pane ("Messages go to the My App session…"), the open-session button and menu item, and the owner badge on the home page. Without a title the Shell shows your harness name as it is.

Names from before the rename

Up to 0.22 the product was Open Artifact: @open-artifact/harness-kit, the subprotocol open-artifact-harness, /api/open-artifact.* routes, X-Open-Artifact-* headers, open-artifact:// links and messages keyed openArtifact. Write the new names. An adapter, host page or type server built on 0.22 keeps working with a newer daemon: the daemon and the Shell still take the older names, and send them to a peer that speaks only those. What each side keeps is in names from before the rename and the embed reference.

Before you ship

  • Your harness name matches ^[a-z0-9][a-z0-9._-]{0,40}$ and is the same in hello, the profile and --harness.
  • Every tool call carries the session as caller; files your agent writes itself are reported with wrote.
  • The wake callback routes by source.from.kind: only owner becomes a user turn.
  • wake answers failed when it could not take a message, so the daemon keeps it.
  • Sessions are attached with their workspace, set running/idle, and detached when they close.
  • Your views load only embedOrigins(), follow embed/origins, and keep pages away from your app's privileges.
  • A frame host's origin is declared in embed.origins; nothing is loaded from file://.
  • Remote type pages go through allowRemote, or embed.remote is deny.
  • You test for features by name (harness.features.includes('view.context')), not by version.
  • Publishing to a site, changing remotes, adding profiles and updating the runtime are left to the person.
  • Your tests run the adapter against the fake daemon, and open-artifacts doctor --harness <name> --session <id> passes against your running app (testing).
  • You read security and limits.

Further reading

Topic Page
The three tools, action kinds, session permissions, ownership integrating/tools.md
Wake routing, answers, resume, starting a new session, nudges integrating/wake.md
Frames, top-level views, origins, thumbnails, theming integrating/embedding.md
Types whose pages live on another computer integrating/remote-types.md
Which runtime runs, updates, pins integrating/runtime.md
Answering pages' model calls with your app's model integrating/sampling.md
Lending your app's MCP servers to pages integrating/connectors.md
Adapters not written in JavaScript integrating/non-node.md
Trust boundaries in one place integrating/security.md
The fake daemon, doctor, CI integrating/testing.md
What does not work yet integrating/limits.md
Every Harness API method, event and error spec/harness-api.md
Every host ↔ Shell message spec/embed.md
Every profile field spec/profile.md
Runnable examples examples/README.md
A full adapter of a terminal agent, on the kit (Pi, OMP) plugins/pi, plugins/omp
A full adapter in Python, over harness --stdio (Hermes Agent) plugins/hermes