Skip to content

Framework-free UI logic

The UI logic of @dudko.dev/agent-web, the in-browser LLM agent, with no framework. It is the part of @dudko.dev/agent-web-react that never needed React: what the chat shows, worked out as plain functions and data. Build a front end for any framework on it - a web component, Vue, Angular, Svelte, plain DOM - or use it on a server.

  • The headless reducer - agentStateReducer folds the core’s AgentEvents into an AgentUiState: the plan, the steps and their tool calls, the streamed answer, the transcript, usage, consent requests, a server’s questions, the model’s questions, subagents, files written, MCP Apps. Pure: no clock, no randomness, no DOM.
  • Every UI string - AgentLabels / defaultLabels / mergeLabels (and the pipeline editor’s PipelineLabels): one object to translate or reword.
  • The pure helpers behind the chat: the message box (slash commands, attachments and their refusals, the long-text rule), the files an answer names, the scroll that follows an answer, the consent queue, the question queues, image downscaling, file kinds, formatting.
  • Voice - recording over getUserMedia + MediaRecorder (every track stopped when it ends), a recording as a speech recognizer, reading aloud with the device’s voices or a provider’s.
  • Saved chats - ChatHistoryStore (IndexedDB, memory fallback) and the merge of two tabs’ saves of one chat.
  • The security cores, as strings and plain objects: the sandboxed frame for untrusted HTML, the MCP Apps frame (its policy, its shell, the extension’s JSON-RPC bridge) and the MCP Apps sandbox page a server serves on an origin of its own.
  • The stylesheets - styles.css (the chat) and pipeline.css (the pipeline editor): plain CSS, awr- classes and --awr-* custom properties, light and dark.

It ships no agent logic (the core does that) and draws nothing: a front end draws, this package says what to draw. @dudko.dev/agent-web-react is built on it and re-exports everything it used to export, so a React app keeps importing from the React package.

One planning loop: two agents, and the layers that put its chat on a page. Every package has its page at agent.dudko.dev/docs. The live demo and the app are built on them.

Package What it is
@dudko.dev/agent The agent in Node: stdio and HTTP MCP servers, OAuth 2.1, a REPL CLI, persistence and resume
@dudko.dev/agent-web The same agent in a browser tab, with no backend: your own key or a local WebGPU model
@dudko.dev/agent-web-ui (this package) Its chat with no framework: the state, a controller, labels in 33 languages, Markdown
@dudko.dev/agent-web-react React: the useAgent hook and a ready chat panel
@dudko.dev/agent-web-element <dd-agent-chat>: the whole chat as a web component, for a page on any stack
@dudko.dev/agent-web-vue Vue 3: the useAgent() composable
@dudko.dev/agent-web-angular Angular: injectAgent(), the chat state as signals
@dudko.dev/agent-web-svelte Svelte 4 and 5: createAgent(), the chat state as a store
Terminal window
npm i @dudko.dev/agent-web-ui @dudko.dev/agent-web

@dudko.dev/agent-web is a peer dependency (one core per page; the type imports come from it, and the core itself is imported only when something needs it - see The core, loaded when needed). There is no other dependency. A React app does not install this package itself: @dudko.dev/agent-web-react depends on it.

Import What Imports
@dudko.dev/agent-web-ui the reducer and its types, the labels, the pure helpers, voice, saved chats, the sandboxed frame the core, dynamically (saved chats, other tabs)
@dudko.dev/agent-web-ui/mcp-app MCP Apps on the page’s side: the frame’s policy and shell, the bridge, the link to a sandbox page, an app’s requests nothing
@dudko.dev/agent-web-ui/mcp-app-sandbox the MCP Apps sandbox page for a SERVER (a Worker, Node, Deno, Bun): the page, its headers, a Request → Response handler nothing
@dudko.dev/agent-web-ui/pipeline the pipeline editor’s logic: the reducer of a pipeline run, the editing helpers, the code generator, the editor’s strings the core
@dudko.dev/agent-web-ui/pipeline-format the pipeline DEFINITION format an editor writes and an executor reads: its types, the validator (refuses secret values), references by name, the JSON Schema, the converters to and from the engine’s definition (see The pipeline definition format) nothing
@dudko.dev/agent-web-ui/canvas the generic canvas’s maths (viewport, curves, hit tests, layout order) and its strings nothing
@dudko.dev/agent-web-ui/controller the agent as a store any front end wraps: createAgentController, and createRemoteAgentController for an agent on a server (see Controller) the core, dynamically, when an agent is built in the page
@dudko.dev/agent-web-ui/markdown the answers’ Markdown as a tree any front end draws: the parser, the parser of an answer still being written, safeHref, the link allowlist, the renderer’s helpers (see Markdown) nothing
@dudko.dev/agent-web-ui/locales the chat’s labels in your language, loaded on demand: loadAgentLabels(tag), the list of tags, labelsFromCatalog nothing
@dudko.dev/agent-web-ui/locales/<tag> one language’s labels (labels) and its catalog (catalog) nothing
@dudko.dev/agent-web-ui/styles.css the chat’s stylesheet -
@dudko.dev/agent-web-ui/pipeline.css the pipeline editor’s stylesheet (stands on its own) -

The main entry also carries the DOM-root helpers a front end needs when its chat may live in a shadow root (a web component): rootOf, activeElementOf, deepActiveElement, nothingFocused, isEventInside, eventTargetOf, deepElementFromPoint, composedContains, shadowRootsAround, listenScrollAround, portalHostOf. From the document, everything inside a shadow root is its host (the focus, a click’s target, the element under a point); these ask the component’s own root, and in the light DOM answer exactly what the document call does.

Every entry is ESM and CommonJS with types. The main entry never mentions the core’s ./mcp subpath, the MCP SDK, the pipeline code, the Markdown parser, the controller (the core’s createAgent) or the MCP Apps frame - not in itself and not in a chunk it loads - so a host that uses none of them carries none of them (tests/entries.test.ts reads the built files).

No entry but ./pipeline imports the core statically. A bundler that keeps one export of the core keeps all of its top-level code - the AI SDK, zod, the providers -, so the few values the chat needs of it (which media types are pictures, which text, the mark of a replayed write, the check of an MCP App’s origins; fileKindOf and mediaFamilyOf answer with them) are copies here, held to the core’s own by the tests. The rest goes through loadAgentCore() - a dynamic import('@dudko.dev/agent-web'), the same module every time: the controller when it builds an agent (createAgent, the run’s control, another tab’s run), the chat history when it announces a write, followOtherTabs / listenToOtherTabs when there is a database to follow (pass loadAgentCore instead of the core’s module: the follow starts once it resolves). agentCoreIfLoaded() answers without importing; AgentCoreModule is the module’s type.

So a chat whose agent is on a server (createRemoteAgentController, the element’s backend) never loads the core: the support chat of agent.dudko.dev went from 1.35 MB (399 KB gzip) to 0.62 MB (182 KB gzip) on its first open - React and the chat. A page that builds an agent imports the core itself anyway (its model, its stores); your bundler puts the core in a chunk of its own.

Everything a chat shows is a function of the events the agent emitted. Keep a state, fold every event into it, draw the state:

import { createAgent } from '@dudko.dev/agent-web'
import { agentStateReducer, createInitialAgentState, defaultLabels } from '@dudko.dev/agent-web-ui'
let state = createInitialAgentState()
const render = () => {
// your framework here: state.status, state.steps, state.messages, state.approvals, …
document.querySelector('#status')!.textContent = defaultLabels.status[state.status]
}
const agent = await createAgent(config)
await agent.run(goal, {
onEvent: (event) => {
state = agentStateReducer(state, { type: 'event', event, at: Date.now() })
render()
},
})

The reducer never mutates the state it is given: each action gives a new state object, which suits any framework’s change detection. The actions besides event are what the host did (AgentAction): a status, a reset, a saved chat loaded, the notebook, messages that never reached the model, a text sent to a run in another tab. The run’s own start, steps and end are events (run.start, …). at is the only clock: the reducer reads none of its own. The state is made of plain, exported view types (StepView, ToolCallView, ApprovalView, ElicitationView, QuestionView, SubagentView, ChatMessage, AppView, …): see the React package’s docs/chat.md for what each field means - the React components draw exactly these.

What the reducer guarantees, for a UI of your own too: a person’s own words given to the model’s ask_user never stay in the steps or a saved chat (withoutOwnWords), a server’s form and an MCP skill’s text are never mirrored onto a saved message, and a consent request of an MCP App outlives the run that showed it.

@dudko.dev/agent-web-ui/controller is everything useAgent of the React package does that is not React, as a store: it builds the agent, folds its events into the state above, runs, stops and steers it, keeps the consent and question queues, follows a run of the conversation in another tab, and keeps the usage. React’s useAgent is this controller and useSyncExternalStore; a web component, Vue, Angular or Svelte wraps the same controller and re-implements none of it.

The contract:

  • createAgentController(config, options?) builds the agent at once (unless autoStart: false, or the config has no model yet) and starts following other tabs. Make one when the view appears.
  • getSnapshot() is everything the view draws: the AgentUiState, status, isReady, isRunning, pendingApprovals, pendingQuestions, approvalMode, sessionId. It is frozen, the same object while nothing changes and a new one after every change.
  • subscribe(listener) calls listener after every change - never at once - and returns the unsubscribe (React’s useSyncExternalStore contract).
  • The methods: run, stop, send, stopSubagent, sendRemote, stopRemote, sendUndelivered, discardUndelivered, reset, reload, loadChat, approve, deny, answerQuestion, setApprovalMode, approveAppToolCall, sampleForApp, compact, forgetSkill, and the agent getter (the built agent, once ready). They are what useAgent returns, with the same meaning: see the React package’s README.
  • update(config, { options?, rebuild? }) takes a new config: by default it builds a new agent (a deps change of useAgent), the transcript kept; rebuild: false only takes the latest config and options and applies what is live (a new toolApproval.mode, another store to follow other tabs through).
  • dispose() tears it all down: the run aborted, its consent requests denied and its questions declined (“the view was closed”), an MCP App’s waiting request denied, a build in progress dropped, the other-tab channels closed, pending timers cleared, every listener let go. The snapshot stays as it was and every method is then a no-op. Call it when the view goes away.

Options (AgentControllerOptions): onEvent, autoStart, maxEvents, appToolGrants, approvals, questions, followUp, watch - the options of useAgent without deps. createInitialAgentSnapshot(config) is the snapshot before any controller exists (a first render that must not make one, a server render).

A custom UI in plain JS:

import { createAgentController } from '@dudko.dev/agent-web-ui/controller'
const chat = createAgentController({ model, credentials, toolApproval: { mode: 'ask-writes' } })
const render = () => {
const s = chat.getSnapshot()
status.textContent = s.status
log.textContent = s.messages.map((m) => `${m.role}: ${m.content}`).join('\n')
allow.hidden = s.pendingApprovals.length === 0
}
const off = chat.subscribe(render)
render()
send.onclick = () => (chat.getSnapshot().isRunning ? chat.send(input.value) : chat.run(input.value))
stop.onclick = () => chat.stop()
allow.onclick = () => chat.approve(chat.getSnapshot().pendingApprovals[0].id)
// when the view goes away: off(); chat.dispose()

createRemoteAgentController(options) is the same store for an agent that runs on a SERVER - the swarm’s gateway (examples/swarm* in the repository: Temporal + Postgres, Cloudflare, Google Cloud, AWS - one HTTP API). The same snapshot and the same methods, so any view of the controller draws it unchanged; nothing of the agent is in the page (no model, no key, no tool).

import { createRemoteAgentController } from '@dudko.dev/agent-web-ui/controller'
const chat = createRemoteAgentController({
baseUrl: 'https://support.example.com/agent',
headers: async () => ({ authorization: `Bearer ${await visitorToken()}` }), // or credentials: 'include'
sessionId: sessionStorage.getItem('chat') ?? undefined,
onSessionId: (id) => (id ? sessionStorage.setItem('chat', id) : sessionStorage.removeItem('chat')),
})

The options (RemoteAgentOptions):

Option What
baseUrl The gateway’s base URL (required)
sessionId A session to continue (below)
headers Headers for every request: an object, or a function called before each one, async allowed (RemoteAgentHeaders) - a visitor token, a captcha token while there is no session yet
credentials fetch’s credentials (default 'same-origin'; 'include' sends a cookie cross-site - the gateway’s anonymous visitor cookie)
fetch The fetch to use (default the global one)
onSessionId Told every change of the session (started, forgotten, reset())
onEvent Every event folded, the swarm’s turn.started / turn.ended markers as they came (a tool.approval-resolved that only says the turn parked is not told)
maxEvents The raw event log kept in the snapshot (default 200; 0 = unbounded)
reconnect { minMs, maxMs }: the stream’s reconnect backoff (default 1 s, doubled up to 30 s)
  • run(text) - the first message POST /sessions, the next ones POST /sessions/:id/messages (each with an id: a retried POST is harmless); shown at once, its turn takes its place. Resolves with the turn’s result, undefined when it failed (the error said, the words back in undelivered). Text only: images or files are refused in words.
  • The turn streams in from GET /sessions/:id/events (SSE read through fetch, so headers can carry a token), folded by the same reducer - the server’s agent emits the core’s events, the swarm’s turn.started / turn.ended frame each turn. A dropped stream is opened again with Last-Event-ID after reconnect.minMs (default 1 s, or the gateway’s retry:), doubled up to reconnect.maxMs (30 s); a frame resets it. A later attempt’s copy of a step, the answer or the plan replaces the earlier one (remoteEventScope): delivery is at-least-once.
  • sessionId - a session to continue: its stream is replayed, the transcript comes back. 404: forgotten; 409 session_ended: the next message starts a new one. onSessionId is told every change.
  • pendingApprovals - a call the server’s policy asks about parks the turn; approve(id) / deny(id, reason) post { approved } to POST /sessions/:id/answers/:requestId (no remember: every call is decided on its own on a server). stop() is POST /sessions/:id/stop. send(text) while a turn runs posts a message that waits in queued for its own turn.
  • Not available, answered as before an agent exists: agent (undefined), answerQuestion, stopSubagent, sendRemote, forgetSkill (false), compact (undefined), approveAppToolCall / sampleForApp (throw), setApprovalMode, stopRemote, update (do nothing). reset() forgets the session; loadChat({ sessionId }) opens another; reload() opens the stream again now. dispose() closes the stream and clears the reconnect timer.
  • onEvent(event, { live, id }) - every event as the reducer took it. live is true only for a turn that a message sent through THIS controller started, as it happens: never for the replay of a session’s log (a reload, loadChat, a sessionId given) nor for a turn another tab or client started on the same session - so a host can act on what its own message caused (open a page the agent named, say) without acting again on every reload. id is the event’s cursor on the stream (<turn>:<attempt>:<seq>); the controller’s own events (a request that failed) are live, without an id.
  • createInitialRemoteSnapshot({ sessionId }) is its snapshot before one exists. createSseParser (SSE text, fed chunk by chunk, to RemoteFrames - id, data - and retry:), parseRemoteCursor (<turn>:<attempt>:<seq>), remoteEventScope and remoteEventOf (a Node core event to the shape the reducer folds) are its pure parts.
  • Nothing of the core is loaded for it: the ./controller entry takes the core only through loadAgentCore(), which this controller never calls - see The core, loaded when needed.

The React package’s useRemoteAgent / <RemoteAgentProvider> and the element’s backend attribute are this controller.

@dudko.dev/agent-web-ui/pipeline-format is the JSON a pipeline is STORED and SHARED as: what an editor saves and an executor (a server that runs pipelines, such as examples/pipelines) reads. It wraps the engine’s definition - the PipelineDefinition of both cores, which stays the source of truth for execution, and what the React package’s PipelineEditor edits - with what a stored document needs: a format and a schema version, a stable name, required edge ids, and the names of the secrets a node may use. It imports nothing, so the same module runs in a page, a Worker and Node.

import {
validatePipelineDocument,
documentToDefinition,
definitionToDocument,
unresolvedReferences,
pipelineDocumentJsonSchema,
} from '@dudko.dev/agent-web-ui/pipeline-format'
const v = validatePipelineDocument(json) // every issue at once: { path: '/nodes/0/id', code, message }
if (v.ok) {
const definition = documentToDefinition(v.document) // what the engine runs / the editor edits
const missing = unresolvedReferences(v.document, { tools: ['word_count'], models: () => true })
}
const doc = definitionToDocument(editedDefinition, { base: loadedDocument }) // an editor's save
  • format: "agent-pipeline", schemaVersion: 1 - a newer version is refused, never guessed at.
  • Conditions are data (always, contains, matches, route, otherwise), as the engine’s.
  • References by name only: model, tools, mcpServers, skills, secrets per node, and { "$secret": "NAME" } anywhere in a node’s settings. pipelineReferences lists them with their paths; unresolvedReferences(doc, resolvers) says which an executor cannot resolve (a kind the resolvers do not mention resolves nothing).
  • No secret values: a string that looks like a key or a token (secretKindOf: provider key shapes, private keys, JWTs, bearer and basic credentials, password=..., long random runs) and any value under a secret-sounding settings key (apiKey, token, password, …) is an issue (secret_value) - which names the kind, never the value. The scan is linear and bounded.
  • pipelineDocumentJsonSchema (draft 2020-12, $id urn:dudko-dev:agent-pipeline:1) describes the shape for other tools; the validator is the full check. The engine’s own rules (the otherwise rule, a pattern’s size, …) are the core’s validatePipeline, run on documentToDefinition(doc).
  • definitionToDocument(def, { base }) keeps from the loaded document what the engine has no field for (the name, the description, each node’s secrets); documentToDefinition copies only what the engine reads. A document round-trips through both unchanged.
  • pipelineDocumentsEqual(a, b) is an editor’s “unsaved changes” check: the same pipeline whatever the order of keys, a title equal to the name or an edge’s default id (canonicalPipelineDocument(doc) is the document as an editor would save it back). Compare with it, not with JSON.stringify - a version stored by hand or by another tool would always look changed.

defaultLabels is every string the chat shows; counted phrases are functions so that languages with several plural forms can say them. mergeLabels(defaultLabels, overrides) merges the nested groups key by key. The React package’s <AgentLabelsProvider> / useLabels are this object in a React context; a web component or a Vue plugin can do the same with its own mechanism.

./markdown turns a model’s Markdown into a small tree - blocks (p, h, code, quote, hr, list, table) of inline runs (text, br, code, strong, em, del, link, file) - that a renderer of any front end draws as elements, never as HTML. The React package’s <Markdown> (@dudko.dev/agent-web-react/markdown) is one; a web component or a Vue / Svelte component draws the same tree the same way.

import {
parseMarkdownCached, // a finished text (cached by its text)
parseMarkdownStreaming, // a text still being written, given the parse of what it was before
emptyMarkdownStream,
markdownCellIsLong,
type MarkdownBlock,
} from '@dudko.dev/agent-web-ui/markdown'
let stream = emptyMarkdownStream()
const blocksOf = (text: string, pending: boolean): MarkdownBlock[] =>
pending ? (stream = parseMarkdownStreaming(stream, text)).blocks : parseMarkdownCached(text)

What it reads: paragraphs with their line breaks, headings, lists (nested, at most 9 levels), fenced code (at any indentation), quotes, rules, GFM tables, **bold**, *italic*, ~~struck~~, `code`, links and bare http(s) URLs. While an answer is written (parseMarkdownStreaming) nothing already drawn changes its kind or gets shorter: the last line waits while it is only markers, emphasis open at the end is drawn closed, a link is its words until its address is whole, and the finished blocks are kept as the same objects.

It is a security boundary for a host - the text is the model’s:

  • Raw HTML is text: <script>, <img onerror>, entities - the characters as written. There is no node that is markup or carries an attribute.
  • A link only to http(s) or mailto (safeHref): anything else - javascript:, data:, vbscript:, file:, //host, a relative address, and their obfuscated forms (entities, which are never decoded, percent-encoding, blanks inside, case) - stays text.
  • A link to a workspace file is { t: 'file', path } only when its destination, percent-decoded first, is a workspace path by workspacePathOf (absolute, no .. / . / empty segment, no //host, no backslash or control character) - %2e%2e, %2F%2Fhost, %5C are refused; a whole code span that is one carries path. A renderer draws it as a control that opens the file in the page, never as <a href>. A link’s words hold no link of their own.
  • No picture is loaded from an answer: ![a](https://raw.githubusercontent.com/dudko-dev/agents/main/packages/agent-web-ui/…) is its ! and a link (or a file link).
  • A link allowlist, for a chat that should link only to its own sites (opt-in, a renderer’s linkAllowed): linkHostAllowed(href, hosts) / linkPolicyOf(hosts) - each entry host or host/path; http(s) only, the host exactly (no subdomain, no look-alike), no user, password or port, a path entry a prefix by whole segments after the URL parser’s normalisation. parseLinkHosts(attribute) reads a list separated by blanks or commas; a malformed entry empties it (no link kept - never every link).
  • Linear on any text: one pass for code spans, lookups for brackets and destinations, one opener stack per kind of emphasis, list nesting bounded - long runs of *, _, [, backticks, >, | or ever-deeper lists cost what plain text does (tests/markdown.test.ts times them).

The chat’s labels come translated into 33 languages - the same 33 as the app at https://agent.dudko.dev/app/, whose translations they are:

en, ru, uk, be, pl, cs, sk, hr, sr, sr-Latn, bg, ro, hu, de, fr, it, es, pt, nl, da, sv, nb, fi, el, sq, ca, tr, es-419, pt-BR, fr-CA, ht, qu, gn.

import { loadAgentLabels } from '@dudko.dev/agent-web-ui/locales'
import { defaultLabels, mergeLabels } from '@dudko.dev/agent-web-ui'
const labels = mergeLabels(defaultLabels, await loadAgentLabels(navigator.language))
  • One language, one file. Each language is an entry of its own (@dudko.dev/agent-web-ui/locales/<tag>), and loadAgentLabels loads it with a literal import(), so a bundler makes a chunk of each: a page in Russian downloads Russian only (about 27 KB, 7 KB gzipped), plus the builder every language shares (5 KB gzipped). The variants carry their base too: es-419 is Spanish with the words of the Americas, fr-CA French with Québec’s punctuation, sr-Latn the Cyrillic catalog transliterated letter for letter. To have one language in your main bundle instead, import it: import { labels } from '@dudko.dev/agent-web-ui/locales/de'.
  • Which language. loadAgentLabels(tag) takes any BCP 47 tag: the exact tag (pt-BR), then its language and script (sr-Latn-RS → sr-Latn), then its language (de-AT → de, es-MX → es, no → nb), then English - also for a tag that is not one. agentLabelLocaleOf(tag) tells which it picks; AGENT_LABEL_LOCALES is the list. Choosing es-419 for es-MX is the host’s call: pass the tag you mean.
  • What is not translated stays English. The labels are an AgentLabelsOverride: the chat’s strings the app shows. What they do not cover yet (a few parts of AgentLabels the app does not mount, and emptyState, which is the host’s own words) falls back to defaultLabels once merged.
  • Plurals and numbers are the language’s own: a counted phrase picks its form with Intl.PluralRules(tag) (Russian: 1 шаг, 2 шага, 5 шагов, 21 шаг) and writes its number with Intl.NumberFormat(tag) (1 234 in Russian, 1.234 in German); sizes and token counts are Intl.NumberFormat’s units and compact form. No library.
  • Your own wording or language. labelsFromCatalog(tag, catalog) builds the labels from a catalog of the same keys (AgentLabelCatalog; plural entries as { one, few, many, other } - the categories of the language - with {count}): take a language’s catalog, change what you like, or translate English’s.
  • Machine-made, not reviewed: ht (Kreyòl ayisyen), qu (Runa Simi) and gn (Avañe’ẽ) were written with care but have not been read by a native speaker yet - the app marks them the same way. Corrections are welcome. The other 30 are reviewed.

Four parts of this package are security boundaries. Each guard has a guard … test here (tests/files.test.ts, tests/apps*.test.ts, tests/app-prompts.test.ts, tests/markdown.test.ts), the React package’s browser tests run hostile pages and a hostile MCP App against them, and a change needs a mutation check.

  • The sandboxed frame (buildSandboxedDocument, sandboxedCsp, sandboxTokens): untrusted HTML goes into <iframe sandbox> WITHOUT allow-same-origin, under a policy with no network source, framed by a document of ours whose frame-src 'none' is what stops it navigating itself. Never render a workspace file by blob: / data: URL or as markup.
  • The MCP Apps frame (./mcp-app): the app’s policy from its resource’s declared origins ONLY (frames, workers and <base> never granted; 'wasm-unsafe-eval' always, 'unsafe-eval' never), one inner sandbox="allow-scripts" frame, and McpAppBridge - an allow-list of methods, their parameters checked, nothing but ping before ui/initialize.
  • The sandbox page (./mcp-app-sandbox, for a server): an app on an origin of its own. It binds to the first ancestor on an allowed host that sends sandbox-resource-ready, once, relays to exact origins only, and ignores a sandbox, csp or permissions the host sends: the header is the policy, and frame-ancestors names the hosts.
  • The Markdown parser (./markdown): raw HTML is text, links only to http(s) / mailto, a file link only to a workspace path (decoded first), no picture, linear on any text - see Markdown.
// A Cloudflare Worker serving the sandbox page
import { mcpAppSandboxResponse } from '@dudko.dev/agent-web-ui/mcp-app-sandbox'
export default {
fetch: (request: Request, env: { HOSTS?: string }) =>
mcpAppSandboxResponse(request, { path: '/sandbox/v1', hosts: env.HOSTS }),
}

How an app runs and what the two modes trade: the React package’s docs/chat.md.

  • @dudko.dev/agent-web-react - the hook, the context and the components; it imports this package (one copy on a page) and re-exports its names, and ships its stylesheets at @dudko.dev/agent-web-react/styles.css and /pipeline.css, copied from here.
  • apps/app and apps/demo draw their answers’ Markdown with ./markdown, through the React package’s <Markdown>.
  • apps/app-sandbox - the demo’s and the app’s MCP Apps sandbox page on Cloudflare, ./mcp-app-sandbox and nothing else.
  • @dudko.dev/agent-web-element: the React chat as a web component, with React bundled inside, for a page that has none.
  • @dudko.dev/agent-web-vue, -angular and -svelte: thin bindings of ./controller, no React.

MIT © Siarhei Dudko