npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dudko.dev/agent-web-react

v0.0.55

Published

React bindings for @dudko.dev/agent-web: a headless useAgent hook, an AgentProvider context, and optional pre-styled components (chat panel, plan/step view, BYOK key form, WebLLM load bar) that connect the in-browser LLM agent to any React site. UI you ca

Downloads

7,350

Readme

@dudko.dev/agent-web-react

npm downloads license last commit release

agent.dudko.dev · docs · live demo · source

React bindings for @dudko.dev/agent-web — the headless, universal in-browser LLM agent. Drop the agent into any React app with a single hook and (optionally) a set of pre-styled components:

  • 🪝 useAgent — build the agent from a config, stream its typed events into a ready-to-render state (plan, steps, tool calls, streamed answer, token usage, model-load progress, chat transcript), and get run / stop / reset / reload.
  • 🌐 useRemoteAgent — the same chat for an agent that runs on a SERVER (the swarm's gateway): no model or key in the page, the turns streamed in, approvals answered through the gateway - a support widget on a public site (below).
  • 💬 <AgentChat> — a drop-in chat: every tool call with its cost, tokens by kind per answer and in total, thoughts, subagents, consent prompts; a composer with "+" / Ctrl+V / drag & drop attachments (images, PDFs, files), "/" commands, run timer, agents, model + thinking chip, the "⚡ Auto" consent chip and speech to text; saved chats in IndexedDB and a workspace (virtual file system) panel. Everything is a prop: show/hide, labels (i18n), render props, slots, swappable components, theme — see docs/chat.md; its look: Styling the chat.
  • 🕸️ Pipeline editor — draw a graph of agents on a canvas (our own: no canvas or graph library), connect them with conditions and loops, run it with live statuses, copy it as code: <PipelineEditor> and usePipeline, behind @dudko.dev/agent-web-react/pipeline — see docs/pipeline.md.
  • 🗣️ Steering and learning — type to the agent while it works (send, stopSubagent; queued / delivered notes under the step that got them), and watch it keep a notebook: lessons it wrote down as skills (learned, <LearnedSkills>, forgetSkill) and the pages it fetched — see docs/chat.md.
  • 🧩 Building blocks — <AgentComposer>, <MessageList>, <StepList>, <ToolApprovalPrompt>, <ElicitationPrompt>, <ApprovalModeSwitch>, <ChatHistoryList>, <FilesPanel>, <LearnedSkills>, <MemoryCard>, <ContextMeter>, <PlanView>, <ModelLoadBar>, <UsageBadge>, <ApiKeyForm>; hooks useChatHistory, useVirtualFiles, useSpeechToText, useFollowScroll (a transcript that follows the answer and leaves a reader where they are); MCP hooks useMcp / useMcpServers live in @dudko.dev/agent-web-react/mcp.
  • 📏 A limit on the message box — longText: { maxInputChars: 4000 } (composer; off by default): typing stops at it with a quiet counter near it; any longer text that would go over it (a paste, a drop, a keyboard's clipboard chip, an IME's commit, a dictation) becomes the whole text as a pasted-<date-time>.txt attachment - never cut, and no maxLength, which cuts. Opt-in excerptChars (for an agent with createFileTools over the same files): a long text attachment reaches the model as its beginning and its workspace path - see docs/chat.md.
  • 🎙️ Voice — dictation through your own model (speech.createRecognizer + createRecordingRecognizer: record, then transcribe; the words land in the box), voice messages (voiceMessage: record and attach the audio, for a core that transcribes it) and a Listen button on each answer (readAloud: the device's voices with createBrowserSpeaker, or a provider's with createAudioSpeaker; Markdown read as words, code not spelled out, each answer in its own language - languageOfText). The microphone is asked for on a tap and let go when the recording ends — see docs/chat.md.
  • 🔑 useCredentials — store BYOK API keys encrypted at rest (WebCrypto + IndexedDB).
  • 🖥️ useWebLLMModel / useLocalModel — load an on-device model (WebLLM, the browser's built-in model, transformers.js, or your own runtime) with download progress, switching and unloading.
  • 🎛️ Headless-first — the event→UI logic is a pure, exported reducer (agentStateReducer); the components are optional sugar on top.
  • 🧱 No React on your site? — @dudko.dev/agent-web-element is this chat as a web component, <dd-agent-chat>, for Vue, Angular, Svelte, Solid, Astro or plain HTML (React inside it) - see its docs.

▶︎ Live demo — three agents: one edits a sticky-notes board, one drives any number of MCP servers (plus a 185-tool mock catalogue to show tool search), and one plays chess against you — your move triggers it, analyst subagents run in Web Workers. Cloud BYOK or local WebGPU, all in your browser. Settings turn on tool consent, thinking, token and step limits, compaction, skills - the agent's own notebook (it writes down what it figured out, in the workspace, across reloads) and web access limited to hosts you list. Type to the agent while it works. Source in apps/demo.

The family

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 | Its chat with no framework: the state, a controller, labels in 33 languages, Markdown | | @dudko.dev/agent-web-react (this package) | 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 |

Install

npm install @dudko.dev/agent-web-react @dudko.dev/agent-web react react-dom

Then add only the model providers you use (optional peers of the core, dynamically imported):

# cloud, pick what you need
npm install @ai-sdk/openai        # or @ai-sdk/anthropic, @ai-sdk/google, @ai-sdk/xai, @ai-sdk/deepseek, @ai-sdk/openai-compatible
# local WebGPU models
npm install @browser-ai/web-llm @mlc-ai/web-llm

Import the optional stylesheet once (skip it if you style the components yourself):

import '@dudko.dev/agent-web-react/styles.css'

Quick start — a drop-in chat panel

<AgentProvider> builds one agent and shares it; <AgentChat> renders it.

import { useMemo } from 'react'
import {
  AgentProvider,
  AgentChat,
  useCredentials,
  defineTool,
} from '@dudko.dev/agent-web-react'
import { z } from 'zod'
import '@dudko.dev/agent-web-react/styles.css'

export function Assistant() {
  const credentials = useCredentials() // encrypted vault (WebCrypto + IndexedDB)

  // Your app's actions, as tools. Keep the object referentially stable.
  const tools = useMemo(
    () => ({
      add_text: defineTool({
        description: 'Add a text block to the page.',
        inputSchema: z.object({ text: z.string() }),
        execute: async ({ text }) => addTextBlock(text), // your code
      }),
    }),
    [],
  )

  return (
    <AgentProvider
      config={{
        model: { providerType: 'google', model: 'gemini-3.5-flash', credentialRef: 'google' },
        credentials: credentials.store,
        tools,
        describeState: () => serializeMyState(), // optional grounding
      }}
    >
      <AgentChat title="Assistant" style={{ height: 520 }} />
    </AgentProvider>
  )
}

Using a bundler (Vite, Next, CRA)? A provider spec like the one above asks the core to import('@ai-sdk/google') at runtime — but browser bundlers can't resolve that bare, @vite-ignored import, so it fails with “Provider package … is not installed” (and WebLLM fails with “webLLM is not a function”). Build the model yourself and pass it directly instead — see Models in a bundler. It's a few extra lines and works in every bundler.

Store the user's key once (encrypted at rest), e.g. from a settings form:

const credentials = useCredentials()
await credentials.setKey('google', userProvidedKey)
// or drop in <ApiKeyForm credentials={credentials} credentialRef="google" />

The useAgent hook (headless)

useAgent is the whole library in one hook — use it directly if you want your own UI:

import { useAgent } from '@dudko.dev/agent-web-react'

function Custom() {
  const agent = useAgent({
    // In a bundler, pass a model you built (see “Models in a bundler”); a
    // provider spec like this one only resolves where dynamic imports do.
    model: { providerType: 'openai', model: 'gpt-5.4-mini', credentialRef: 'openai' },
    credentials,
    tools,
  })

  return (
    <>
      <button disabled={!agent.isReady} onClick={() => agent.run('Add a totals row')}>
        Run
      </button>
      {agent.isRunning && <button onClick={agent.stop}>Stop</button>}

      {/* Everything below is live, derived from the event stream: */}
      {agent.plan && <p>{agent.plan.thought}</p>}
      {agent.steps.map((s) => (
        <div key={s.id}>
          {s.index}/{s.total} · {s.step.description} · {s.status}
          {s.toolCalls.map((c, i) => (
            <code key={i}>{c.name}</code>
          ))}
        </div>
      ))}
      <p>{agent.finalText}</p>
      <small>{agent.usage.totalTokens} tokens</small>
    </>
  )
}

useAgent is @dudko.dev/agent-web-ui/controller's createAgentController and React: the hook makes a controller when the component mounts, hands it the latest config and options after every render, tells it to rebuild when deps change, reads its snapshot through useSyncExternalStore and disposes it on unmount (StrictMode's second mount gets a new one). A front end of another framework wraps the same controller (see that package's README).

Option pageContext (every collector OFF unless switched on): what the person is looking at - the address, the title, the focused field, the selection, the location, … - read when a message is sent and passed to the core as run(goal, { context }); untrusted data in the user prompt, never a policy input. <AgentChat pageContext showPageContext> and <AgentComposer> take the same (the chip "Sharing: …" opens to exactly what goes, with "Don't share with this message"). See docs/chat.md.

useAgent(config, options) returns the full AgentUiState plus:

| Field | Description | | --- | --- | | run(goal, { images, files, attachments, label, context }) | Start a run (with attachments; context: a page context you collected, false for none - absent, it is read now from the pageContext option); resolves with the RunResult. When the conversation is running in another tab it waits for that run (sessionBusy), then goes with that turn in its memory | | stop() | Abort this tab's in-flight run (going, or waiting for the session). Never another tab's: that is stopRemote() | | stopRemote(), sendRemote(text) | Stop / write to the conversation's run in another tab (remote?.running). A text waits in queued (sentTo: 'another-tab', "waiting for the other tab to pick it up") until that tab answers - with no time limit: a tab the browser froze answers when it wakes. Taken, that run's own entry takes its place; refused, or that run ended without it, it comes back as undelivered. <AgentComposer> uses them while it follows such a run | | agent | the core Agent itself (or undefined until built): agent.usage / agent.sessionUsage() (tokens spent, counted live; core ≥ 0.0.32), agent.listLearnedSkills(), agent.capabilities | | forgetSkill(name) | delete one of the agent's own lessons from its notebook | | previewPageContext(), pageContextCollector() | What the next message would share (the pageContext option, read without asking anything), and the collector behind it - see Page context | | sendUndelivered() / discardUndelivered() | send, or drop, what a stopped run never showed the agent | | send(text, { context? }), stopSubagent(id) | Say something to the running agent (shown to the model at its next boundary; the replanner re-checks the plan; with the page context of that moment) / stop one subagent. queued, notes and undelivered show where a message is — see docs/chat.md. send is this tab's run only; another tab's is sendRemote | | remote, sessionBusy | several tabs: remote ({ running, runId?, ended? }) - the run in view is another tab's, followed live (its steps, answer and usage fill the rest of the state; isRunning is true meanwhile; its consent requests are shown, never answered here); sessionBusy ({ heldBy, goal? }) - this tab's run waits for the conversation's other run (its goal shown as queued; a stop of the wait gives it back to the composer). See docs/chat.md | | reset() | Clear the whole conversation (and the agent's memory of it) | | reload() | Rebuild the agent (e.g. after storing a new key) | | status | idle | initializing | ready | running | error | | isReady / isRunning | convenience booleans | | messages | transcript; each assistant message keeps its steps, tool calls, thoughts, approvals, subagents, usage and duration | | plan / steps | the live plan and per-step tool calls (with timing) | | finalText / finalReasoning | the streamed answer and its thoughts | | usage / totalUsage | tokens of this run / of the conversation, by kind - plus mediaCalls and decisionCalls (calls, not tokens) when the run made some | | pendingApprovals, approve(id, { remember }), deny(id) | tool consent (a request made by a helper the model started carries subagent: { id, depth, name?, role? }). A request the core stops waiting for - no decision within toolApproval.timeoutMs (default five minutes), the run stopped - is settled by the core and leaves the list; a late approve does nothing | | pendingQuestions, answerQuestion(id, answer) | the model's questions to the person (the core's ask_user, with askUser on in the config - see Questions from the agent): the ones waiting in THIS tab, oldest first (PendingQuestion: the core's request - id, question, options, multiple, allowOther, step?, subagent? - plus expiresAt). answerQuestion takes { choice: [label] }, { other: text } or { declined: true } and returns false when the question is no longer waiting. How each ended is questions (QuestionView[]; never what was typed) | | approvalMode / setApprovalMode(mode) | the autopilot switch, live | | approveAppToolCall(call, signal) / sampleForApp(request, approve, signal) | for MCP Apps: an app's tool call (AppToolCall: the core's request plus frame, the asking frame's id, put on the request's app) through the agent's consent gate (its mode and rules, as for the model - autopilot asks nothing with core 0.0.53 or later, an older core still asks before an app's write; a 'deny' rule and Read-only decided before "Always allow", which is kept per app and connection for the page's life, appToolGrants); an app's sampling/createMessage answered by the agent's model (the core's Agent.sampleForApp: checked, rate-limited, put to approve, no tools, none of the chat; its tokens count in totalUsage only, the answer goes to the caller only) - <AgentChat> wires both | | compact() | summarise the stored transcript now | | sessionId / loadChat(chat) | the memory session; switch conversations | | subagents, skills, discoveredTools, compactions, budget | the rest of the run, folded. subagents is a tree: static subagents and the helpers the model started (subagents.dynamic), each node with parentId / depth, status, model, tokens, tool calls and time; subagentTree(subagents) nests it - see docs/chat.md | | media, transcripts, decisions | absent until there is one: the files the run generated (MediaView[]: a path in the workspace, never bytes; references - the paths of the reference pictures a picture was made with, and whether they were used), the audio it transcribed (TranscriptView[]), and the decision model's answers that came before any step (DecisionView[]; later ones are on their step) | | learned, learnedNow, fetches | the agent's notebook (LessonView[], survives reset), what it wrote this run, and the web_fetch requests this run made (FetchView[]) | | queued, notes, undelivered, replan | steering: messages waiting, shown (and where), left over; the last replan decision (byUser when a message caused it; failed + error when the replanner call itself failed and the run went on with its plan) | | steps[i].tier, .model, .tierReason, .escalations, .replanFailed | with the core's executorTiers: the tier and model a step is on, why it started there, and its escalations (StepEscalationView[]); a tool call of an escalated attempt has attempt, a write that was not run twice replayed. replanFailed: the replanner failed after this step (a warning). All absent when tiers are off — see docs/chat.md | | error, errorCode, stopped, events, seq | the run's error text (a replanner failure is not one: see replan.failed); the core's code for an error a host may say in its own words - 'no-plan' (the planner returned nothing readable) or 'no-answer' (the model wrote no answer); whether it was stopped, the raw event log and its counter | | modelLoad | WebLLM download progress, when loading |

Options: deps (rebuild the agent when these change — e.g. on a model switch), onEvent (tap the raw event stream), autoStart, maxEvents, approvals (route consent requests into the hook; default true), questions (answer the model's ask_user questions in the hook when askUser is on without an onQuestion of the host's; default true), followUp (a message that came too late for the run, while the answer was being written, is sent as the next message when it ends; default true), appToolGrants (where "Always allow" given to an MCP App's tool is kept: default one set for the page's life, so a rebuilt agent or a remounted chat keeps it and a reload forgets it; kept per app and per connection of its server, so a server added again or another one under the same name starts with none, and a 'deny' rule or Read-only still refuses), watch (follow the conversation's run in another tab of the site - default true; needs a memory the tabs share, IndexedDBStore). The queue behind approve / deny is exported for a host that builds the core's agent itself: createApprovalQueue() gives handler (pass it as toolApproval.onRequest; a request whose signal aborts leaves the queue), approve(id, { remember }), deny(id, reason), settleAll(decision) and pending().

Keep tools and describeState referentially stable (useMemo / useCallback); pass a changed deps array to rebuild the agent on a model/provider switch.

An agent on a server — useRemoteAgent

The chat can talk to an agent that runs on a SERVER - the swarm's gateway (examples/swarm: Temporal + Postgres, Cloudflare, Google Cloud or AWS, one HTTP API) - instead of building one in the page. No model, key or tool in the browser: a support widget on a public site.

import { AgentChat, useRemoteAgent } from '@dudko.dev/agent-web-react'

function SupportChat() {
  const agent = useRemoteAgent({
    baseUrl: 'https://support.example.com/agent',
    headers: async () => ({ authorization: `Bearer ${await visitorToken()}` }), // or credentials: 'include'
    sessionId: sessionStorage.getItem('support-chat') ?? undefined,
    onSessionId: (id) =>
      id ? sessionStorage.setItem('support-chat', id) : sessionStorage.removeItem('support-chat'),
  })
  return <AgentChat controller={agent} textOnly showApprovalMode={false} allowRemember={false} />
}

It returns what useAgent returns - the same snapshot and methods, so <AgentChat> draws it unchanged - from @dudko.dev/agent-web-ui/controller's createRemoteAgentController: messages go to POST /sessions / /sessions/:id/messages, the turn streams in from GET /sessions/:id/events (SSE, resumed with Last-Event-ID after a drop), a parked approval is answered through POST /sessions/:id/answers/:requestId, Stop is POST /sessions/:id/stop. <RemoteAgentProvider> shares it with a subtree. Options (baseUrl, sessionId, headers, credentials, onSessionId, onEvent, maxEvents, reconnect, fetch), what each method does there and what is not available: docs/chat.md.

What is loaded. <AgentChat>, useRemoteAgent and <RemoteAgentProvider> import no value of the core: what the chat needs of it is the ui package's copies, and the core itself is loaded by the ui package with a dynamic import() only when useAgent builds an agent in the page. So a page whose chat is on a server gets nothing of the in-browser agent from your bundler - no AI SDK, no zod - as long as it does not use the core's names itself (this package re-exports some, e.g. createAgent: a bundler drops them unless they are used; the package has no side effects but its CSS). @dudko.dev/agent-web stays a peer to install. The support chat of agent.dudko.dev (the web component, React inside) is 182 KiB gzip on its first open this way - @dudko.dev/agent-web-ui has the details.

Local WebGPU model (no key, offline)

import { useAgent, useWebLLMModel, ModelLoadBar } from '@dudko.dev/agent-web-react'
import { webLLM } from '@browser-ai/web-llm' // your app's optional peer

// Build WebLLM in your own code so the bundler includes it (see note below).
const createLocalModel = (id: string, opts?: object) => Promise.resolve(webLLM(id, opts as never))

function LocalAgent() {
  const local = useWebLLMModel('Qwen2.5-1.5B-Instruct-q4f16_1-MLC', { create: createLocalModel })
  const agent = useAgent(
    { model: local.model!, tools },
    { deps: [local.model] }, // build once the model is loaded
  )

  if (!local.ready) {
    return local.loading ? (
      <ModelLoadBar load={{ progress: local.progress, text: local.text }} />
    ) : (
      <button disabled={!local.supported} onClick={local.load}>
        Load local model
      </button>
    )
  }
  return <AgentChat controller={agent} />
}

load() eagerly downloads the weights (so the progress bar fills during load, not silently on the first message) and ready flips only once the model can actually answer. The create option is what makes it work under a bundler — see below.

Change the modelId and everything the hook reports — model, ready, loading, progress, error — is about the new one, which is not loaded yet. The previous model stays in memory (loadedModelId; switching back is instant) until the new one is loaded — that frees it first, so two models never share the GPU — or until unload().

Context window. WebLLM loads its models with a 4096-token window, far below what Qwen3 or Llama 3.x were trained on. Pass contextWindowTokens to load with more (it costs KV-cache VRAM, not a new download); your create factory receives it and applies it with the core's withWebLLMContextWindow (see the demo's providers.ts). local.contextWindow is the window the model was loaded with, and the agent fits its runs into it on its own — compaction, tool lists and tool results are sized from it.

Vision. Phi-3.5-vision-instruct-q4f16_1-MLC takes images (paste, drop or attach them) — a multimodal model that never sends them anywhere.

Any on-device runtime — useLocalModel

useWebLLMModel is useLocalModel with the WebLLM engine. Describe another runtime as an engine — create, and optionally warmUp (download now, with progress), unload, supported, contextWindowOf — and the hook gives the same load / unload / progress / switching:

import { useLocalModel, createWebLLMEngine, type LocalModelEngine } from '@dudko.dev/agent-web-react'

const builtIn: LocalModelEngine = {
  create: async () => (await import('@browser-ai/core')).browserAI('text', {
    expectedInputs: [{ type: 'text' }, { type: 'image' }],
  }),
  warmUp: async (m, { onProgress }) => {
    await m.createSessionWithProgress((p) => onProgress({ progress: p, text: 'Downloading' }))
  },
  supported: () => 'LanguageModel' in globalThis, // Chrome's Prompt API
  contextWindowOf: (m) => m.getContextWindow(),
}
const webllm = createWebLLMEngine({ create: createLocalModel })

// One hook, any runtime: switching frees the previous model with its own engine.
const local = useLocalModel(option.model, option.builtIn ? builtIn : webllm, {
  contextWindowTokens: option.contextWindow,
})

The demo runs WebLLM, Chrome's Gemini Nano and transformers.js this way — see apps/demo/src/local-engines.ts.

Models in a bundler (Vite, Next, CRA)

The core builds cloud providers with import('@ai-sdk/<provider>') and WebLLM with import('@browser-ai/web-llm'). Those are bare, @vite-ignored dynamic imports — great for Node/SSR/import-map setups, but a browser bundler either leaves them unresolvable at runtime (cloud → “Provider package … is not installed”) or stubs them to an empty module (WebLLM → “webLLM is not a function”).

The fix is the same for both: build the model in your own code (a static import your bundler can see) and hand the agent a direct LanguageModel.

Cloud — construct the provider from the vault-stored key:

import { useEffect, useState } from 'react'
import { createGoogleGenerativeAI } from '@ai-sdk/google'
import type { LanguageModel } from 'ai'
import { useAgent, useCredentials } from '@dudko.dev/agent-web-react'

function CloudAgent() {
  const credentials = useCredentials()
  const [model, setModel] = useState<LanguageModel>()

  useEffect(() => {
    credentials.store.getApiKey('google').then((key) => {
      setModel(key ? createGoogleGenerativeAI({ apiKey: key })('gemini-3.5-flash') : undefined)
    })
  }, [credentials.store, credentials.version])

  const agent = useAgent({ model: model!, credentials: credentials.store, tools }, { deps: [model] })
  // …render <AgentChat controller={agent} /> once model is set
}

Anthropic needs headers: { 'anthropic-dangerous-direct-browser-access': 'true' } passed to createAnthropic({ … }) for direct browser calls.

Local — pass a statically-imported webLLM factory via useWebLLMModel's create option (see the WebLLM example above).

The apps/demo app does exactly this — see apps/demo/src/providers.ts.

MCP hooks live in their own subpath

import { useMcp, useMcpServers } from '@dudko.dev/agent-web-react/mcp'

The MCP hooks are not exported from @dudko.dev/agent-web-react. They load the core's @dudko.dev/agent-web/mcp, which imports the MCP SDK (@modelcontextprotocol/client) — an optional peer, so npm does not install it for you. A bundler cannot honour "optional": it resolves even a dynamic import() at build time, so a host that merely imported useAgent from the main entry used to fail webpack/CRA with Module not found for the SDK while never touching MCP. Behind a subpath the decision is yours:

  • Don't use MCP → import only from the main entry. Nothing in your build mentions the SDK; install nothing extra.
  • Use MCP → import from …/mcp and npm install @modelcontextprotocol/client next to the core (it is bundled into an async chunk, loaded when you connect).

The MCP SDK is the core's peer, and it was renamed. A core on the 2.x MCP SDK (@dudko.dev/[email protected] and later) imports @modelcontextprotocol/client (^2.4.0); cores up to 0.0.39 import @modelcontextprotocol/sdk 1.x. Install the one your core asks for — when you upgrade the core: npm uninstall @modelcontextprotocol/sdk && npm install @modelcontextprotocol/client. This package imports neither, and its hooks work with both. Nothing changes in the hooks' API: ConnectedMcp, BrowserOAuthProviderOptions, McpServerResult and the other types exported from …/mcp are structural types of this package, not the SDK's. The one difference you can observe: isUnauthorizedError(err) now also recognises the error by its name (the 2.x class sets it) and across two copies of the SDK. A tool call refused with 403 insufficient_scope fails with the SDK's InsufficientScopeError, which is not an authorization failure for isUnauthorizedError — the status stays connected. See the core's upgrade notes.

Migrating from ≤ 0.0.18. useMcp, useMcpServers and their helpers (readCallbackParams, claimOAuthCallback, stripOAuthParams, describeMcpResult, isUnauthorizedError) and types (McpStatus, McpAuthMode, McpServerView, …) moved: change the import path, nothing else.

Markdown answers live in their own subpath

import { markdownContent, markdownFileContent } from '@dudko.dev/agent-web-react/markdown'

<AgentChat renderContent={markdownContent} renderFileContent={markdownFileContent} />

<AgentChat> draws answers as plain text unless you pass renderContent. …/markdown has the package's renderer: <Markdown text streaming? className?> (React elements, never HTML; streamed answers drawn without jumps; tables, lists, code, quotes, links), markdownContent (the assistant's answers through it, the person's text and errors as text) and markdownFileContent (a .md file's preview); markdownContentWith({ linkAllowed }) keeps only the links a policy allows (linkPolicyOf(hosts)), the rest drawn as text. Links only to http(s) / mailto, raw HTML as text, no picture loaded, a link to a workspace file opened in the page, linear on any text. The main entry carries none of it. The parser itself is @dudko.dev/agent-web-ui/markdown (re-exported here), for a renderer of another front end. See docs/chat.md.

Pipelines: an editor on a canvas

import { PipelineEditor, usePipeline } from '@dudko.dev/agent-web-react/pipeline'
import '@dudko.dev/agent-web-react/pipeline.css'

const pipeline = usePipeline(definition, { base: { model, credentials }, tools: { files } })
return <PipelineEditor value={definition} onChange={setDefinition} controller={pipeline} />

The editor for the core's pipelines (a graph of agents in plain JSON) lives in its own entry, like MCP and for a similar reason: a chat host should not carry a canvas, an inspector and a code generator, nor need a core new enough to have createPipeline. Nothing in the main entry references it. Its stylesheet, pipeline.css, is separate too and stands on its own. It adds no dependency: the canvas is this package's own code.

| Export | What it is | | --- | --- | | usePipeline(definition, options) | Builds the pipeline with the core (resolveNode, or the registries of nodeResolver: base, models, skills, tools, mcpServers), and returns run(input, { start? }) (start at a node: run again from it), stop(), reset(), pause() / resume(note?) / paused / held (hold the run before its next step, then go on - with a note for that step), send(text, nodeId?) (a message to the steps at work), isRunning, validation, result plus the state below. | | pipelineStateReducer, createInitialPipelineState, pipelineNodeView | The pure event → state reducer: per-node status and visits, which edges fired, what each node's agent is doing, outputs, usage, stoppedBy, the error - and each visit's inputs, route and why, tool calls, files, tokens and times (PIPELINE_VIEW_LIMITS). | | <PipelineEditor> | The editor: canvas, node cards, inspector, toolbar, validation, run bar, results - every visit opens to what it got, did, chose and why (onOpenFile, renderVisitExtra, slots.resultsFinal); allowFullscreen adds a Full screen button. Controlled (value, onChange). | | <PipelineNodeCard>, <PipelineInspector>, <PipelineResults>, <PipelineIssues>, <PipelineCodeDialog> | Its parts, to compose your own. | | <Canvas>, <CanvasPort> and the canvas maths | The generic node-and-edge canvas underneath: pan, zoom, drag, connect, keyboard, screen readers. | | addNode, removeNode, renameNode, addEdge, updateEdge, removeEdge, setEntry, autoLayout, parsePipelineJson, ... | Editing a definition, as pure functions. | | pipelineToCode(definition, { target }) | "Copy as code": a snippet for the browser package or for the Node one. | | PipelineLabelsProvider, defaultPipelineLabels, usePipelineLabels | Every string of the editor (its own labels object, not AgentLabels). |

The full guide, with every prop, state field and label: docs/pipeline.md. Live, in Pipeline Studio: https://agent.dudko.dev/studio/.

The useMcp hook — connect a remote MCP server

Let the user name their own MCP server at runtime and hand its tools to the agent. Auth is either a static header or the full OAuth 2.1 flow with dynamic client registration — no client ID to configure, and the access token is refreshed for you when it expires mid-run.

import { useMcp } from '@dudko.dev/agent-web-react/mcp'

const mcp = useMcp({ clientName: 'my-app' })

await mcp.connect({ url, oauth: true })       // or { url, headers: { Authorization } }

// The server wants a sign-in: send the user off from a real click.
{mcp.status === 'needs-authorization' && <button onClick={mcp.authorize}>Authorize</button>}

// Then just merge the tools into any agent config.
const config = { model, tools: { ...myTools, ...mcp.tools } }

useMcp returns { status, tools, catalog, instructions, protocol, error, authorizationUrl, oauthRegistration, oauthSupported, completingAuthorization, pendingElicitations, answerElicitation, connect, disconnect, authorize, forgetAuthorization, checkOAuthSupport, apps }. oauthRegistration says how the server's OAuth client was registered ('cimd' or 'dcr') once it is connected with OAuth; apps is the server's MCP Apps (with useMcp({ apps: true })) - pass it to <AgentChat mcpApps>. status is idle | connecting | connected | needs-authorization | error. protocol is the revision negotiated with the connected server ({ server, version, era }, e.g. 2025-11-25 / legacy or 2026-07-28 / modern; absent until connected, and on a core that does not report it). pendingElicitations / answerElicitation are the server's questions to the user - see MCP elicitation.

instructions is what the connected server told the agent in its handshake (MCP instructions), when it sent any. The core puts that text into the system prompt of an agent that uses the server's tools, and it is third-party text: with bring-your-own servers, show it to the user, labelled as the server's words (useMcpServers().servers[i].instructions is the same per server; mcpInstructionsOf(connection, name) reads it from a ConnectedMcp).

The OAuth round-trip navigates away from your app, so the hook persists what it needs and, on the way back, finishes the code exchange (passing iss to the core, which refuses a response from another authorization server - RFC 9207), strips ?code=… from the address bar and reconnects before rendering — completingAuthorization covers that window.

Options:

| | | | --- | --- | | useMcp({ clientName }) | the MCP client name, and the client_name of a dynamic registration | | useMcp({ clientMetadataUrl }) | the URL of a client ID metadata document (CIMD) your app hosts, for every OAuth server - see below | | useMcp({ onLog }) | connector log lines | | useMcp({ apps }) | MCP Apps: declare the extension and read the tools' apps (default false); the hook then returns apps, and a tool meant for its app only is not in tools | | useMcp({ elicitation }) | let a server ask the user something in the middle of a tool call: true, or the core's settings { url, timeoutMs, maxPerToolCall, maxPerRun, subagents }. Off by default - see MCP elicitation | | connect({ url, name, headers }) | the endpoint, the tool prefix ("<name>__<tool>", default mcp), static headers | | connect({ oauth }) | true, or { redirectUrl, scope, clientName, clientMetadataUrl, registration } (McpOAuthOptions) - each overrides the hook-level value for this server; registration is below | | connect({ protocol }) | the MCP protocol revisions this connection may use: 'legacy' (the 2025 revisions), 'auto' (2026-07-28 when the server offers it, the 2025 ones otherwise) or 'modern' (2026-07-28 only). Left out, nothing is passed and the core speaks the 2025 revisions, exactly as before. Kept across the OAuth redirect. See the protocol revision | | connect({ skills }) | experimental: load the skills the server serves (the MCP Skills extension) into the agent's skills catalog, as <server>/<skill>. They come with tools - nothing else to wire. Needs protocol: 'auto' or 'modern'. true, or { consent: 'once-per-skill' \| 'ask' \| 'never', dynamic?: boolean } (consent: when a person is asked before one of its skills enters the agent's context; dynamic: true: its generated skills too, no checksums - see MCP skills; McpSkillsSetting, mcpSkillsSettingOf). Off (left out) by default. Kept across the OAuth redirect. See MCP skills |

clientMetadataUrl (CIMD). Instead of registering itself with every authorization server, an app can publish one JSON document that describes it and use that document's URL as its client_id:

const mcp = useMcp({
  clientName: 'my-app',
  clientMetadataUrl: 'https://my-app.example/oauth/client.json',
})
await mcp.connect({ url, oauth: true })
// or for one server only: connect({ url, oauth: { clientMetadataUrl: '…' } })

The hooks pass the URL to the core's OAuth provider unchanged. An authorization server that advertises client_id_metadata_document_supported takes it as the client_id and no registration request is made; any other server gets dynamic registration as before, and a registration already stored for the server wins over both (forgetAuthorization drops it). The URL must be https with a path of its own, and the document served there must list the redirectUrl (by default this page, without query or hash) in its redirect_uris - the core refuses any other URL before a request is made, and the server ends in status: 'error' with the reason. The URL is public and is remembered with the rest of the server's OAuth details across the redirect and reloads. The core's README and security notes say what the document must contain.

oauth.registration: CIMD, DCR, or whichever the server supports. Per server, 'auto' (the default - the document where the server supports it, dynamic registration elsewhere), 'cimd' (the document only) or 'dcr' (dynamic registration only, even with a clientMetadataUrl), handed to the core's provider of the same name:

await mcp.connect({ url, oauth: { registration: 'cimd' } }) // with useMcp({ clientMetadataUrl })
mcp.oauthRegistration // 'cimd' | 'dcr', once connected: which way was taken

Under 'cimd' a server whose authorization server does not support documents ends in status: 'error' with the core's reason - … does not support client ID metadata documents (CIMD), which this connection requires (registration: 'cimd') - nothing was sent to its registration endpoint - and is never offered for authorization; 'cimd' with no clientMetadataUrl fails the same way before any request. A client stored for the server under the other kind is not reused: the core forgets it and its tokens, and the user signs in again. The setting is kept across the redirect (and, in useMcpServers, with the server list); oauthRegistration (useMcp) / servers[i].oauthRegistration (useMcpServers) is 'cimd' or 'dcr' while the server is connected with OAuth, read from the core's registrationKind(). A core older than the option would ignore it and register the old way, so the hooks refuse 'cimd' / 'dcr' there (status: 'error'); 'auto' and no value work with any core. The helpers the hooks use are exported from ./mcp: newMcpOAuthProvider, mcpOAuthRecordOf / mcpOAuthOptionsOfRecord (what the redirect record keeps) and mcpOAuthRegistrationOf.

Two notes:

  • The connector lives in the core's optional @dudko.dev/agent-web/mcp subpath and is loaded with a dynamic import, so the SDK stays out of your initial bundle until connect runs. Install @modelcontextprotocol/client alongside the core (@modelcontextprotocol/sdk for a core up to 0.0.39) — importing these hooks is what puts it in your build.
  • oauthSupported is false on cores older than @dudko.dev/[email protected], which introduced BrowserOAuthProvider; header auth still works there. The peer floor is >=0.0.60 — the first core with createPipelineControl (steering a pipeline run: usePipeline's pause / resume / send), after askUser (the model's questions: ask_user, user.question-*), after several tabs (onStorageChange, watchSession, the session lock), MCP Apps (approveAppToolCall, sampleForApp), MCP skills with consent, file.written, elicitation and the OAuth registration choice this package's chat and hooks use, on top of model tiers, dynamic subagents, media and decision models, pipelines, the learning notebook, the virtual file system, attachments, consent, tool search, subagents, steering and context editing. skills: { dynamic: true } needs a core 0.0.42 or later: an older one declines those skills.

Several MCP servers — useMcpServers

import { useMcpServers } from '@dudko.dev/agent-web-react/mcp'

const mcp = useMcpServers({ clientName: 'my-app' }) // the list persists; reconnects on load
await mcp.add({ name: 'docs', url, auth: 'oauth' }) // 'none' | 'bearer' (+ token) | 'oauth'
mcp.servers  // [{ name, url, status, catalog, instructions, error, … }]
const config = { model, tools: { ...myTools, ...mcp.tools } } // "<name>__<tool>"

useMcpServers takes the options of useMcp (clientName, clientMetadataUrl, onLog, elicitation) plus persist, storageKey, autoConnect and connectTimeoutMs, and returns { servers, tools, catalog, protocols, connectedCount, pendingElicitations, answerElicitation, … }. A server may be added with its own protocol (add({ name, url, protocol: 'auto' })), skills: true or { consent, dynamic } (MCP skills; servers[i].skills) and apps: false (that server's MCP Apps off while the others' are shown; servers[i].apps), all remembered with the list; servers[i].protocolMode is what it was added with and servers[i].protocol ({ version, era }) what was negotiated while it is connected - protocols lists them for every connected server. A server added with auth: 'oauth' may carry its own oauth: { redirectUrl, scope, clientName, clientMetadataUrl, registration }, which wins over the hook-level values and is remembered with the list; servers[i].oauthRegistration says which way its client was registered once it is connected:

const mcp = useMcpServers({ clientMetadataUrl: 'https://my-app.example/oauth/client.json' })
await mcp.add({ name: 'docs', url, auth: 'oauth' }) // CIMD where the server supports it, DCR elsewhere
await mcp.add({ name: 'crm', url: crmUrl, auth: 'oauth', oauth: { registration: 'cimd' } }) // CIMD or nothing
mcp.servers[0].oauthRegistration // 'cimd' | 'dcr'

Servers connect in parallel, each with its own deadline; paginated tool lists are read to the end; tools a server marks read-only skip the "ask before changes" prompt. With hundreds of tools the core switches to tool search (a compact catalogue + find_tools) above toolSearchThreshold — see the core's capabilities doc.

MCP skills (experimental)

await mcp.add({ name: 'docs', url, protocol: 'auto', skills: true })
// the agent's catalog now has docs/<skill> entries; mcp.servers[0].skills === true
// a server you vetted: its skills load without asking
await mcp.add({ name: 'ours', url: ourUrl, protocol: 'auto', skills: { consent: 'never' } })
// a server you trust with its GENERATED skills (no checksums): each is read whole, and the
// person approves that copy
await mcp.add({ name: 'gen', url: genUrl, protocol: 'auto', skills: { dynamic: true } })

A server may serve skills (the io.modelcontextprotocol/skills extension, Beta): instruction files the agent can load. With skills: true (on connect, or per server on add, remembered with the list) the core declares the extension and puts the server's skills into the agent's catalog next to your own skills and the agent's lessons, named <server>/<skill> - so a server can never take the name of one of yours, nor of another server's skill. Nothing else is wired: the skills come with the server's tools, like its instructions. The run's skills (message.skills, the skill.activated event, which carries server for these) show that name, so a UI says whose skill it is. The text is third-party: the core loads it on demand, verified against the server's digests, under a preamble that says it is knowledge only - it cannot approve a call, change the approval mode, open the web or run code (while the agent acts on one, a tool that runs code is always asked). Needs the 2026-07-28 revision. The core's README ("MCP skills") has the rules.

A person sees a server's skill before the agent does. The first time a skill would enter the agent's context, the core asks through the same consent gate as a tool call - useAgent()'s pendingApprovals gets a request whose skill (SkillConsentView) holds the server, the skill, its description, size and files, and the very text the model would read (skill.body, while the request is open: the reducer drops it once it is decided, so a saved chat does not keep it). <AgentChat> / <ToolApprovalPrompt> render it as its own card - "The server “docs” offers the skill “pdf-processing”", the description, a collapsed preview of the text (plain text) and Allow once / Always for this server / Deny; approve(id) / approve(id, { remember: true }) / deny(id) answer it. Asked whatever the approval mode - autopilot too. skills: { consent } (per server, remembered) or the agent's mcpSkills: { consent } (core config) choose when: 'once-per-skill' (default: once per skill in the agent's life, again when the server changes it), 'ask' (every task that loads it) or 'never' (a server you vetted: today's behaviour). A skill inside another one (nested) is asked about on its own. The agent may also load a skill a server names by its address (skill://…/SKILL.md, in its instructions or a skill), from that server only - the card says so (skill.byUri).

Generated skills ("resources": "dynamic": the server publishes no checksums) are declined unless the server was added with skills: { dynamic: true } (remembered with the list; there is no switch for every server). Then, before the person is asked, the core reads the whole skill - its SKILL.md and, if the server can list directories, every file in them, within the specification's limits (512 files, 16 MiB) - computes the digests itself and keeps that copy in memory: the card shows its size and files, says so in one line (skill.dynamic; skillConsentDynamic: "This server publishes no checksums for this skill: you approve the copy the agent just read, and only that copy is used."), and the agent is given that copy only, never a later read. A server that cannot list its files gives SKILL.md alone (skill.noFileListing, skillConsentNoFileListing). Nothing of the copy is stored.

The protocol revision

await mcp.add({ name: 'docs', url, protocol: 'auto' })
mcp.servers[0].protocol // { version: '2026-07-28', era: 'modern' } - or 2025-11-25 / legacy
  • 'legacy' (and no protocol at all) is the 2025 handshake: the requests and the CORS request headers are exactly what they were before the option existed.
  • 'auto' asks the server first (server/discover, one extra request at connect) and speaks 2026-07-28 to a server that offers it. From a page, that revision sends two more request headers, Mcp-Method and Mcp-Name: a server whose Access-Control-Allow-Headers does not list them blocks the probe in the browser, and the core falls back to the 2025 revisions with a warning (onLog) that names the missing headers.
  • 'modern' is 2026-07-28 only: a server that does not offer it, or whose CORS blocks the headers, fails the connect with the reason.

The revision is decided once, at connect. The core's README has the details (CORS, tool-list changes on 2026-07-28).

MCP elicitation — a server asks the user

A server may ask the user for input in the middle of a tool call: a form to fill in (a name, a date, a choice), or - with url: true - a page to open (a payment, a sign-in on the server's own site). Turn it on in the hook and show the questions:

import { useMcpServers } from '@dudko.dev/agent-web-react/mcp'
import { AgentChat, useAgent } from '@dudko.dev/agent-web-react'

const mcp = useMcpServers({ elicitation: { url: true } }) // or `true`: forms only
const agent = useAgent({ model, tools: mcp.tools }, { deps: [mcp.tools] })

<AgentChat
  controller={agent}
  elicitations={mcp.pendingElicitations}
  onElicitationAnswer={mcp.answerElicitation}
/>
// or anywhere: <ElicitationPrompt elicitations={…} onAnswer={…} outcomes={agent.elicitations} />
  • Off by default. Without elicitation the hooks pass nothing to the core: no capability is declared in the handshake, a server cannot ask, and the wire is what it was. true turns it on with the core's defaults; an object is the core's settings - url (also offer URL mode; default false), timeoutMs (how long a question waits; default 300 000), maxPerToolCall (5), maxPerRun (20), subagents (let a helper's call ask too; default false). The option is read when a server connects: changing it takes a reconnect. A core without elicitation ignores it.
  • pendingElicitations are the questions waiting, oldest first (PendingElicitation: the core's McpElicitationRequest - id, server, tool, mode, message, requestedSchema or url, subagent? - plus expiresAt when the question has a time limit). answerElicitation(id, result) answers one: { action: 'accept', content } (a form's values; nothing for a link), { action: 'decline' } or { action: 'cancel' }; it returns false when the question is no longer waiting. A question also leaves the list, answered cancel, when the core stops waiting (its time ran out, the run stopped), when its server is disconnected or removed, and when the component that holds the hook unmounts.
  • Time. A question waits timeoutMs (default 300 000: five minutes; 0 or Infinity = until the run is stopped). The step it belongs to does not cut it short: the core stops the step's clock (chatTimeoutMs) while a person is asked, and the step goes on with the time it had left once the question is settled. A question nobody answered in time is cancelled by the core and its tool call fails; the prompt then says it was answered automatically, and why.
  • <ElicitationPrompt> (main entry; it imports neither the SDK nor the core's ./mcp) draws the question where the consent cards are, one at a time with a count: the host's own header (which server asks, during which tool), the server's message under a caption that says it is the server's, then the form - text (plain, email, URL, date, date and time, with length limits), numbers and whole numbers (with bounds), a tick box, a select (plain, titled, enumNames), a multi-select - with required marks, titles, descriptions and defaults, and Submit / Decline / Cancel. Submit is checked first by the core's own rules (elicitationFormAnswer) and a refused field says what is wrong with it, by name. A link shows its host large, the whole address as text, and an Open in a new tab button; "I have finished there" (the accept) appears once the user opened it.
  • On the 2025 revisions the core sends the calls to a server that may ask one at a time (its question does not say which call it belongs to); on 2026-07-28 a question is part of the call's own answer. Both work the same from here.

A host that calls the core's connectMcpHttp itself can use the same queue the hooks use (createElicitationQueue from …/mcp) or pass its own onElicitation, and render <ElicitationPrompt> with what it was given.

Security. The question is the SERVER's text, and the prompt treats it so. Its message, the field titles and descriptions and the option names are shown as plain text (never as markup) inside a box captioned "From the server “server”"; the header above it is the app's own. A link is never followed by itself: there is no <a>, nothing opens it before the user's click on Open, which calls window.open(url, '_blank', 'noopener,noreferrer'), and there is no Open at all for anything but https (or http on a loopback host) without credentials - checked again here, although the core already refuses such links. What the user types stays in the prompt's own component state until Submit hands it to answerElicitation, which passes it to the core and keeps nothing: it is not in the agent's state (state.elicitations holds field NAMES only), its events, the transcript, a saved chat or a log. The core sends it to the server that asked and nowhere else - never to the model.

Questions from the agent — ask_user

With the core's askUser on, the model may ask the person ONE closed question with 2-6 options instead of guessing (the core's built-in ask_user tool; off by default - see the core's docs). useAgent answers it when the config turns it on without a handler of its own:

const agent = useAgent({ model, tools, askUser: true }) // or { timeoutMs, maxPerRun }
<AgentChat controller={agent} /> // the question card appears where the consent cards are
// or anywhere: <QuestionPrompt questions={agent.pendingQuestions}
//   onAnswer={agent.answerQuestion} outcomes={agent.questions} />
  • Who answers. askUser: true (or an object without onQuestion) makes the hook supply onQuestion - its queue (createQuestionQueue, exported for a host that builds the agent itself) - and the questions land in pendingQuestions. A host's own askUser.onQuestion wins (then nothing reaches pendingQuestions); askUser off stays off, and the core mounts no tool. useAgent(config, { questions: false }) keeps the hook out of it.
  • <QuestionPrompt> draws one question at a time, with a count: the host's own line ("The agent asks you", or which helper asks), the model's question, one button per option with its description under it, and Skip. A single choice is answered by its button; with multiple the options are toggles and Send sends them; with allowOther an Other… button opens a field for the person's own words. Keys 1-6 pick an option while the card has the focus (Tab reaches every button, Enter presses it, Esc closes the field), the card is a role="group" named by the question, every target is at least 40 px tall, and nothing scrolls sideways at 320 px. Under it: the time left ("If you do not answer, the agent decides by itself in 4:59").
  • Without an answer. A question waits the core's askUser.timeoutMs (default five minutes; the step's own limit stops meanwhile); then the core tells the model the person did not answer, and the card says the agent went on without the answer, and why - as it does for a handler that failed. Stop ends the wait at once (and the card goes, without a note). A run ending takes every question still open down.
  • Several tabs. A question is answered only in the tab that runs the agent: a tab following that run shows the question without its buttons ("Answered in the other tab…"), and "It waits for an answer in the other tab." above the composer.

Security. The question and every option are the MODEL's text (the core cleans them of control and bidirectional characters): the card shows them as text nodes, never as markup. What the person types in Other… stays in the card's own state until Send hands it to answerQuestion, which passes it to the core and keeps nothing. The core gives it to the model as the tool's result; the reducer takes it out of everything it keeps (withoutOwnWords: an ask_user result that is not known to hold labels only loses its output in the steps, the transcript, a saved chat and the event log), and the core's user.question-answered event never carries it. A host tapping onEvent sees the core's raw step.tool-result, words included.

MCP Apps — a server's interface in the chat

apps: true (on useMcp or useMcpServers) declares the MCP Apps extension: a tool whose server ships an HTML app for its result comes with that app, and <AgentChat mcpApps> draws it under the answer in a sandboxed frame. Whatever the app asks the host to do - call a tool of its server, open a link, put a message in the chat - is put to the user in the chat's consent area, labelled as the app's.

const mcp = useMcpServers({ apps: true })
const agent = useAgent({ model, tools: mcp.tools }, { deps: [mcp.tools] })
<AgentChat controller={agent} mcpApps={mcp.apps} appPanel="auto" />

Off by default (the hooks declare nothing and every tool is mounted as before). Needs a core with MCP Apps. See docs/chat.md.

One server's apps off. useMcpServers({ apps: true }) with add({ name, url, apps: false }): that server is not told of apps, none of its apps is read or drawn, a tool it marks for its app only is mounted for nobody, and its other tools are plain tools.

What an app may ask for besides - each off by default, each put to the user:

<AgentChat
  controller={agent}
  mcpApps={mcp.apps}
  appFullscreen // ui/request-display-mode: full screen over the chat, after a click in the app; Esc / Exit back
  appDownloads // ui/download-file: name, type, size shown; saved by your page; programs, scripts, pages refused
  appSampling // sampling/createMessage: the agent's model answers the app; no tools; the answer never in the chat
/>

hostCapabilities names only what is on (downloadFile, sampling - never sampling.tools); hostContext.availableDisplayModes is ['inline', 'fullscreen'] with appFullscreen (no picture-in-picture). The rules: docs/chat.md.

An origin of its own (opt-in). By default an app runs in an opaque frame: no storage or cookies of its own, requests with Origin: null. Serve the sandbox page of @dudko.dev/agent-web-react/mcp-app-sandbox on ANOTHER origin and pass its URL, and apps run on that origin instead - the specification's sandbox proxy:

<AgentChat controller={agent} mcpApps={mcp.apps} appSandbox={{ url: 'https://apps.example.com/sandbox/v1' }} />
// or one origin per server (needs a wildcard certificate): 'https://{server}.apps.example.com/sandbox/v1'
// A Cloudflare Worker on apps.example.com (or Node / Deno / Bun: Request in, Response out)
import { mcpAppSandboxResponse } from '@dudko.dev/agent-web-react/mcp-app-sandbox'
export default {
  fetch: (request: Request) =>
    mcpAppSandboxResponse(request, { path: '/sandbox/v1', hosts: 'https://chat.example.com' }),
}

A URL on your page's own origin, or not https:// (http:// only on localhost / 127.0.0.1), is refused; a sandbox page that does not answer in timeoutMs (5 s) is given up for the page's life. Either way the app runs in the opaque frame - the stricter of the two - and its header says "sandboxed" instead of "sandboxed on its own origin". The headers, the hosts setting and the trade-offs: docs/chat.md.

In your language

The chat's labels come in 33 languages from @dudko.dev/agent-web-ui/locales (this package's dependency; with pnpm, add @dudko.dev/agent-web-ui to your own dependencies to import it). Each language is a chunk of its own, loaded on demand; give the labels to <AgentLabelsProvider> or to a component's labels prop:

import { loadAgentLabels } from '@dudko.dev/agent-web-ui/locales'
import { AgentChat, AgentLabelsProvider } from '@dudko.dev/agent-web-react'

const labels = await loadAgentLabels(navigator.language) // 'ru', 'pt-BR', 'sr-Latn-RS' → sr-Latn, …

createRoot(root).render(
  <AgentLabelsProvider labels={{ ...labels, emptyState: 'Чем помочь?' }}>
    <AgentChat />
  </AgentLabelsProvider>,
)

What a language does not cover stays English (defaultLabels); emptyState is yours to word. The tags, the fallback, the plurals and which translations are machine-made: @dudko.dev/agent-web-ui's README and [docs/chat.md](docs/chat.md#in-your-languag