@agent-native/core 0.56.0 → 0.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +9 -7
  2. package/dist/cli/plan-local.d.ts.map +1 -1
  3. package/dist/cli/plan-local.js +66 -10
  4. package/dist/cli/plan-local.js.map +1 -1
  5. package/dist/cli/skills.d.ts +2 -2
  6. package/dist/cli/skills.d.ts.map +1 -1
  7. package/dist/cli/skills.js +13 -5
  8. package/dist/cli/skills.js.map +1 -1
  9. package/dist/client/AssistantChat.d.ts +8 -0
  10. package/dist/client/AssistantChat.d.ts.map +1 -1
  11. package/dist/client/AssistantChat.js +24 -4
  12. package/dist/client/AssistantChat.js.map +1 -1
  13. package/dist/client/agent-chat-adapter.d.ts.map +1 -1
  14. package/dist/client/agent-chat-adapter.js +39 -4
  15. package/dist/client/agent-chat-adapter.js.map +1 -1
  16. package/dist/client/chat/index.d.ts +1 -1
  17. package/dist/client/chat/index.d.ts.map +1 -1
  18. package/dist/client/chat/index.js +1 -0
  19. package/dist/client/chat/index.js.map +1 -1
  20. package/dist/client/chat/runtime.d.ts +93 -0
  21. package/dist/client/chat/runtime.d.ts.map +1 -1
  22. package/dist/client/chat/runtime.js +934 -1
  23. package/dist/client/chat/runtime.js.map +1 -1
  24. package/dist/client/index.d.ts +1 -1
  25. package/dist/client/index.d.ts.map +1 -1
  26. package/dist/client/index.js +1 -0
  27. package/dist/client/index.js.map +1 -1
  28. package/dist/deploy/build.d.ts.map +1 -1
  29. package/dist/deploy/build.js +14 -0
  30. package/dist/deploy/build.js.map +1 -1
  31. package/dist/mcp/build-server.d.ts.map +1 -1
  32. package/dist/mcp/build-server.js +48 -3
  33. package/dist/mcp/build-server.js.map +1 -1
  34. package/docs/content/actions.md +5 -1
  35. package/docs/content/agent-surfaces.md +258 -0
  36. package/docs/content/components.md +38 -17
  37. package/docs/content/drop-in-agent.md +10 -5
  38. package/docs/content/embedding-sdk.md +4 -0
  39. package/docs/content/external-agents.md +1 -0
  40. package/docs/content/getting-started.md +2 -0
  41. package/docs/content/key-concepts.md +3 -2
  42. package/docs/content/mcp-apps.md +1 -1
  43. package/docs/content/native-chat-ui.md +69 -22
  44. package/docs/content/plan-plugin.md +27 -1
  45. package/docs/content/pure-agent-apps.md +2 -1
  46. package/docs/content/using-your-agent.md +1 -0
  47. package/docs/content/what-is-agent-native.md +3 -2
  48. package/package.json +4 -2
@@ -0,0 +1,258 @@
1
+ ---
2
+ title: "Agent Surfaces"
3
+ description: "Use Agent-Native headlessly, as rich chat, inside an existing app, or as a full agent-native application."
4
+ search: "headless agent rich chat full app BYO agent runtime AgentChatRuntime embed actions MCP A2A HTTP CLI"
5
+ ---
6
+
7
+ # Agent Surfaces
8
+
9
+ Agent-Native is deliberately composable. You can use the agent without much UI,
10
+ use the UI without the built-in agent runtime, or use both together as a full
11
+ application.
12
+
13
+ The useful way to choose is not by protocol first. Choose the product surface
14
+ you want, then use the matching primitive.
15
+
16
+ | Surface | Use it when | Start with |
17
+ | ----------------------------- | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
18
+ | **Headless agent/actions** | Code, jobs, scripts, another app, or another agent should call the work directly. | `defineAction`, HTTP, CLI, MCP, A2A |
19
+ | **Rich chat on Agent-Native** | You want a standalone or embedded chat backed by the built-in agent loop. | `<AgentChatSurface>`, `<AssistantChat>`, `createAgentChatPlugin()` |
20
+ | **Rich chat on your agent** | You built the agent elsewhere and want Agent-Native's composer, transcript, tool cards, and native widgets. | `AgentChatRuntime`, `<AssistantChat runtime={runtime}>` |
21
+ | **Embedded sidecar** | You already have a SaaS app and want an agent beside it with page context and host commands. | `createAgentNativeEmbeddedPlugin()`, `AgentNativeEmbedded` |
22
+ | **Full application** | Humans and agents should share durable screens, data, navigation, and collaboration. | Templates, actions, SQL state, context awareness |
23
+
24
+ Those are stages, not separate products. A workflow can start as a headless
25
+ action, appear in chat as a table or chart, and later become a full screen in an
26
+ app without changing the operation the agent calls.
27
+
28
+ ## Headless agent/actions {#headless}
29
+
30
+ Use the headless path when no one needs to stare at a custom app screen while
31
+ the work runs: scheduled jobs, integrations, backend workflows, CLI loops,
32
+ another agent, or an existing product calling into Agent-Native.
33
+
34
+ Most headless integrations should start with actions:
35
+
36
+ ```ts
37
+ // actions/summarize-week.ts
38
+ import { defineAction } from "@agent-native/core";
39
+ import { z } from "zod";
40
+
41
+ export default defineAction({
42
+ description: "Summarize this week's submissions.",
43
+ readOnly: true,
44
+ schema: z.object({ formId: z.string() }),
45
+ run: async ({ formId }) => {
46
+ return { formId, summary: "34 submissions, up 18% from last week." };
47
+ },
48
+ });
49
+ ```
50
+
51
+ One action is then callable as:
52
+
53
+ - **HTTP** — `POST /_agent-native/actions/summarize-week`
54
+ - **CLI** — `pnpm action summarize-week --formId form_123`
55
+ - **MCP** — from Claude, ChatGPT, Codex, Cursor, OpenCode, Copilot, and other MCP hosts
56
+ - **A2A** — from another agent-native app or agent peer
57
+ - **UI** — through `useActionQuery`, `useActionMutation`, or `callAction`
58
+ - **Agent tool** — from the built-in chat loop
59
+
60
+ If you need the whole agent loop headlessly, use the server API from a worker,
61
+ job, integration webhook, or custom host. This is lower-level than actions: you
62
+ provide the engine, model, messages, actions, and event sink yourself.
63
+
64
+ ```ts
65
+ import {
66
+ actionsToEngineTools,
67
+ resolveEngine,
68
+ runAgentLoop,
69
+ } from "@agent-native/core/server";
70
+
71
+ const engine = await resolveEngine({ engineOption: undefined });
72
+ const model = engine.defaultModel;
73
+ const controller = new AbortController();
74
+
75
+ await runAgentLoop({
76
+ engine,
77
+ model,
78
+ systemPrompt: "You are the reporting agent for this workspace.",
79
+ actions,
80
+ tools: actionsToEngineTools(actions),
81
+ messages: [
82
+ {
83
+ role: "user",
84
+ content: [{ type: "text", text: "Summarize this week's forms." }],
85
+ },
86
+ ],
87
+ send: (event) => {
88
+ // Persist, log, stream, or translate AgentChatEvent objects.
89
+ },
90
+ signal: controller.signal,
91
+ ownerEmail: user.email,
92
+ orgId: user.orgId,
93
+ });
94
+ ```
95
+
96
+ For most apps, scheduled prompts and integration webhooks already call this loop
97
+ for you. Reach for direct `runAgentLoop()` when you are building a custom
98
+ headless host, eval runner, or server-side orchestration surface.
99
+
100
+ ## Rich chat on Agent-Native {#rich-chat}
101
+
102
+ Use the built-in chat when the user should talk to the agent, see tool calls,
103
+ approve work, inspect native results, and keep a durable thread history.
104
+
105
+ The simplest full-page chat:
106
+
107
+ ```tsx
108
+ import { AgentChatSurface } from "@agent-native/core/client/chat";
109
+
110
+ export default function ChatRoute() {
111
+ return <AgentChatSurface mode="page" className="h-screen" />;
112
+ }
113
+ ```
114
+
115
+ The simplest embedded chat with your own chrome:
116
+
117
+ ```tsx
118
+ import { AssistantChat } from "@agent-native/core/client/chat";
119
+
120
+ export function ProjectChat({ threadId }: { threadId: string }) {
121
+ return <AssistantChat threadId={threadId} />;
122
+ }
123
+ ```
124
+
125
+ Actions can return explicit native widget results so chat output is not just
126
+ text. Tables, charts, and typed product cards render as first-party React
127
+ components in the chat, without iframes. See [Native Chat UI](/docs/native-chat-ui).
128
+
129
+ ## Rich chat on your agent {#byo-agent}
130
+
131
+ Use this path when your agent is already built with another framework or
132
+ runtime and you want Agent-Native's chat UI around it.
133
+
134
+ `AgentChatRuntime` is the boundary. Your runtime streams normalized events;
135
+ Agent-Native renders the composer, transcript, tool calls, approvals, native
136
+ widgets, and app layout.
137
+
138
+ ```tsx
139
+ import {
140
+ AssistantChat,
141
+ createHttpAgentChatRuntime,
142
+ } from "@agent-native/core/client/chat";
143
+
144
+ const runtime = createHttpAgentChatRuntime({
145
+ id: "external:support-agent",
146
+ label: "Support agent",
147
+ endpoint: "/api/support-agent/chat",
148
+ headers: async () => ({ Authorization: `Bearer ${await getToken()}` }),
149
+ });
150
+
151
+ export function SupportAgentChat() {
152
+ return <AssistantChat runtime={runtime} threadId="support" />;
153
+ }
154
+ ```
155
+
156
+ The endpoint can stream SSE or NDJSON events:
157
+
158
+ ```txt
159
+ data: {"type":"message-delta","messageId":"m1","delta":{"type":"text","text":"I found 34 submissions."}}
160
+ data: {"type":"tool-start","toolCall":{"id":"t1","name":"query","input":{"formId":"form_123"}}}
161
+ data: {"type":"tool-done","toolCallId":"t1","toolName":"query","status":"completed","resultText":"34 rows"}
162
+ data: {"type":"done","reason":"complete"}
163
+ ```
164
+
165
+ For a trivial integration, returning `{ "text": "..." }` also works. For richer
166
+ integrations, stream `message-*`, `tool-*`, `approval-request`, `status`,
167
+ `artifact`, `file`, `usage`, `error`, and `done` events. Tool results can carry
168
+ `chatUI` metadata so the same native table/chart/card renderers work with your
169
+ agent too.
170
+
171
+ This is the right place to adapt Mastra, Flue, Eve, LangGraph, a custom service,
172
+ or an AG-UI-compatible event stream. Do not use ACP as the default end-user app
173
+ chat protocol; ACP is better framed as coding-agent/editor interoperability.
174
+ Agent-Native does not currently claim A2UI support.
175
+
176
+ ## Embedded sidecar {#embedded-sidecar}
177
+
178
+ Use the embedded sidecar when the main product already exists and you want an
179
+ agent beside it.
180
+
181
+ The server plugin mounts Agent-Native routes into your host app and resolves
182
+ host identity server-side:
183
+
184
+ ```ts
185
+ import { createAgentNativeEmbeddedPlugin } from "@agent-native/core/server";
186
+
187
+ export default createAgentNativeEmbeddedPlugin({
188
+ databaseUrl: process.env.AGENT_NATIVE_DATABASE_URL,
189
+ auth: getHostSession,
190
+ actions: hostActions,
191
+ });
192
+ ```
193
+
194
+ The React sidecar passes page context and host commands:
195
+
196
+ ```tsx
197
+ import { AgentNativeEmbedded } from "@agent-native/core/client";
198
+
199
+ export function AppShell({ children }) {
200
+ return (
201
+ <AgentNativeEmbedded
202
+ getContext={() => ({
203
+ route: { pathname: window.location.pathname },
204
+ selection: { text: window.getSelection()?.toString() || undefined },
205
+ })}
206
+ onNavigate={(payload) =>
207
+ router.navigate((payload as { path: string }).path)
208
+ }
209
+ onRefresh={() => queryClient.invalidateQueries()}
210
+ >
211
+ {children}
212
+ </AgentNativeEmbedded>
213
+ );
214
+ }
215
+ ```
216
+
217
+ See [Embedding SDK](/docs/embedding-sdk) for host auth, database isolation,
218
+ iframe/picker mode, and lower-level bridge APIs.
219
+
220
+ ## Full application {#full-application}
221
+
222
+ Use the full app path when users need durable objects and workflows: forms,
223
+ dashboards, calendars, inboxes, editors, documents, assets, or reports.
224
+
225
+ Full apps add product UI around the same action and agent contract:
226
+
227
+ - **SQL state** — app data, navigation, settings, and chat history are durable.
228
+ - **Context awareness** — the agent knows the current route, selection, and focused object.
229
+ - **Live sync** — agent changes update the UI, and UI changes update the agent's context.
230
+ - **Deep links** — action results can open the right app view.
231
+ - **Native chat widgets** — tables, charts, cards, approvals, and typed results appear inline.
232
+
233
+ Start from a [template](/docs/cloneable-saas) when you want a complete app, or
234
+ from [Starter](/docs/template-starter) when you want only the framework wiring.
235
+
236
+ ## How to choose {#how-to-choose}
237
+
238
+ | If you are thinking... | Choose |
239
+ | --------------------------------------------------------------- | ------------------------- |
240
+ | "I just need a callable tool or workflow." | Headless action |
241
+ | "I want the framework's agent, but chat should be the main UI." | Rich chat on Agent-Native |
242
+ | "I already have an agent; I need a polished chat UI for it." | Rich chat on your agent |
243
+ | "I already have a SaaS app; add an agent beside it." | Embedded sidecar |
244
+ | "The agent and UI should evolve together as the product." | Full application |
245
+
246
+ Keep the contract small: define durable operations as actions, return explicit
247
+ widget results when chat needs rich UI, and add full screens only when users
248
+ need to browse, compare, configure, or collaborate over persistent objects.
249
+
250
+ ## Related docs {#related-docs}
251
+
252
+ - [Actions](/docs/actions) — define the headless operation once.
253
+ - [Native Chat UI](/docs/native-chat-ui) — render typed action results in chat.
254
+ - [Drop-in Agent](/docs/drop-in-agent) — mount chat, sidebar, or panel surfaces.
255
+ - [Component API](/docs/components) — lower-level React chat/composer pieces.
256
+ - [Embedding SDK](/docs/embedding-sdk) — add Agent-Native to an existing app.
257
+ - [External Agents](/docs/external-agents) — connect MCP-compatible hosts to an app.
258
+ - [A2A Protocol](/docs/a2a-protocol) — call agents from other agents.
@@ -27,23 +27,26 @@ so bundlers choose the browser-safe entry.
27
27
 
28
28
  ## Agent And Chat UI {#agent-chat-ui}
29
29
 
30
- | API | Import path | Use when |
31
- | -------------------------- | --------------------------------------------- | ------------------------------------------------------------------------------------------------ |
32
- | `<AgentSidebar>` | `@agent-native/core/client` or `/client/chat` | You want the complete sidebar around your app. |
33
- | `<AgentToggleButton>` | `@agent-native/core/client` or `/client/chat` | You render your own header button for the sidebar. |
34
- | `<AgentPanel>` | `@agent-native/core/client` or `/client/chat` | You want the full panel in your own layout, route, dialog, or side column. |
35
- | `<AgentChatSurface>` | `@agent-native/core/client` or `/client/chat` | You want chat in panel or page mode without the sidebar wrapper. |
36
- | `<AssistantChat>` | `@agent-native/core/client` or `/client/chat` | You want to own surrounding chrome while keeping the standard conversation and composer runtime. |
37
- | `<MultiTabAssistantChat>` | `@agent-native/core/client` or `/client/chat` | You want the framework's thread tabs without `AgentPanel` chrome. |
38
- | `createAgentChatAdapter()` | `@agent-native/core/client` or `/client/chat` | You are adapting a BYO assistant-ui transport into the Agent-Native chat runtime. |
39
- | `useChatThreads()` | `@agent-native/core/client` or `/client/chat` | You need a custom thread list, history picker, or scoped chat UI. |
40
- | `sendToAgentChat()` | `@agent-native/core/client` or `/client/chat` | A product action should hand work to the agent chat. |
41
-
42
- In docs, `AgentChatRuntime` means this standard runtime posture: assistant-ui
43
- thread state, Agent-Native streaming, run recovery, attachments, model
44
- selection, approvals, native tool widgets, and SQL-backed sync. It is not a
45
- separate protocol replacement. BYO agents should adapt into this runtime with
46
- `createAgentChatAdapter()` when they want the normal app chat experience.
30
+ | API | Import path | Use when |
31
+ | --------------------------------- | --------------------------------------------- | ------------------------------------------------------------------------------------------------ |
32
+ | `<AgentSidebar>` | `@agent-native/core/client` or `/client/chat` | You want the complete sidebar around your app. |
33
+ | `<AgentToggleButton>` | `@agent-native/core/client` or `/client/chat` | You render your own header button for the sidebar. |
34
+ | `<AgentPanel>` | `@agent-native/core/client` or `/client/chat` | You want the full panel in your own layout, route, dialog, or side column. |
35
+ | `<AgentChatSurface>` | `@agent-native/core/client` or `/client/chat` | You want chat in panel or page mode without the sidebar wrapper. |
36
+ | `<AssistantChat>` | `@agent-native/core/client` or `/client/chat` | You want to own surrounding chrome while keeping the standard conversation and composer runtime. |
37
+ | `<MultiTabAssistantChat>` | `@agent-native/core/client` or `/client/chat` | You want the framework's thread tabs without `AgentPanel` chrome. |
38
+ | `createHttpAgentChatRuntime()` | `@agent-native/core/client` or `/client/chat` | You have a BYO agent endpoint that streams normalized chat events. |
39
+ | `createAgentChatRuntimeAdapter()` | `@agent-native/core/client` or `/client/chat` | You need to adapt an `AgentChatRuntime` into assistant-ui yourself. |
40
+ | `createAgentChatAdapter()` | `@agent-native/core/client` or `/client/chat` | You need the built-in Agent-Native SSE transport as a low-level assistant-ui adapter. |
41
+ | `useChatThreads()` | `@agent-native/core/client` or `/client/chat` | You need a custom thread list, history picker, or scoped chat UI. |
42
+ | `sendToAgentChat()` | `@agent-native/core/client` or `/client/chat` | A product action should hand work to the agent chat. |
43
+
44
+ `AgentChatRuntime` is the BYO-agent contract for the standard chat shell. Pass
45
+ `runtime` to `<AssistantChat>` when an external agent should power the
46
+ conversation while Agent-Native keeps the composer, transcript, tool cards, and
47
+ native widget rendering. If you are choosing between headless actions, rich
48
+ chat, embedded sidecar, and full app shapes, see
49
+ [Agent Surfaces](/docs/agent-surfaces).
47
50
 
48
51
  The shortest custom route is still a pre-wired surface:
49
52
 
@@ -77,6 +80,24 @@ function CustomChat({ projectSlug }: { projectSlug: string }) {
77
80
  }
78
81
  ```
79
82
 
83
+ For a bring-your-own agent endpoint:
84
+
85
+ ```tsx
86
+ import {
87
+ AssistantChat,
88
+ createHttpAgentChatRuntime,
89
+ } from "@agent-native/core/client/chat";
90
+
91
+ const runtime = createHttpAgentChatRuntime({
92
+ endpoint: "/api/my-agent/chat",
93
+ label: "My agent",
94
+ });
95
+
96
+ export function MyAgentChat() {
97
+ return <AssistantChat runtime={runtime} />;
98
+ }
99
+ ```
100
+
80
101
  ## Chat Field And Composer {#composer}
81
102
 
82
103
  Use `@agent-native/core/client/composer` when you need to place the same chat
@@ -184,20 +184,25 @@ framework own the agent runtime:
184
184
  - **`@agent-native/core/client/conversation`** — use this for transcript
185
185
  rendering without the full chat runtime.
186
186
  - **`createAgentChatAdapter()`** — use this only when building a custom
187
- assistant-ui transport for the standard Agent-Native chat runtime. It
187
+ assistant-ui transport for the built-in Agent-Native chat endpoint. It
188
188
  connects to the same `/_agent-native/agent-chat` stream and preserves
189
189
  run-manager recovery, attachments, model selection, native widgets, and
190
190
  thread metadata.
191
+ - **`createHttpAgentChatRuntime()`** — use this when a BYO agent exposes a
192
+ POST endpoint that streams `AgentChatRuntime` events. Pass the runtime to
193
+ `<AssistantChat runtime={runtime} />`.
191
194
 
192
195
  Avoid posting directly to `/_agent-native/agent-chat` from product UI. If a
193
196
  lower-level helper is missing for a real custom surface, add that named helper
194
197
  first so client code does not learn a second, ad hoc transport.
195
198
 
196
199
  For BYO agent runtimes, keep actions and SQL-backed app state as the contract.
197
- Adapt the runtime into `<AssistantChat createAdapter={...} />` when you want
198
- Agent-Native chat behavior, or use `PromptComposer` by itself only when the
199
- external runtime owns the transcript and loop. See
200
- [Native Chat UI](/docs/native-chat-ui#byo-agent-runtimes).
200
+ Adapt the runtime into `<AssistantChat runtime={...} />` when you want
201
+ Agent-Native chat behavior. Use `<AssistantChat createAdapter={...} />` only
202
+ for lower-level assistant-ui transports, or `PromptComposer` by itself only
203
+ when the external runtime owns the transcript and loop. See
204
+ [Native Chat UI](/docs/native-chat-ui#byo-agent-runtimes) and
205
+ [Agent Surfaces](/docs/agent-surfaces#byo-agent).
201
206
 
202
207
  ### Build your own sidebar from pieces {#build-your-own-sidebar}
203
208
 
@@ -29,6 +29,10 @@ pnpm add @agent-native/core
29
29
 
30
30
  ## Choosing a mode {#choosing-a-mode}
31
31
 
32
+ This page is for embedding Agent-Native into an existing product. If you are
33
+ still deciding between headless actions, rich chat, an embedded sidecar, or a
34
+ full app, start with [Agent Surfaces](/docs/agent-surfaces).
35
+
32
36
  | Mode | Use it when | Package |
33
37
  | ------------------------------------ | --------------------------------------------------------------------------------------------------- | -------------------------------------------------------- |
34
38
  | **EmbeddedApp picker** | Launching a full Agent-Native app as a focused iframe (asset picker, form builder, approval panel). | `@agent-native/embedding` |
@@ -13,6 +13,7 @@ The external-agent bridge closes the loop. First you connect your own agent to a
13
13
  ## Which agent path do you need? {#which-agent-path}
14
14
 
15
15
  - **External MCP host:** use this page when Claude, ChatGPT, Codex, Cursor, OpenCode, GitHub Copilot / VS Code, or another MCP-compatible host should call your hosted agent-native app.
16
+ - **Your own runtime behind Agent-Native chat:** see [Agent Surfaces](/docs/agent-surfaces#byo-agent) and [Native Chat UI](/docs/native-chat-ui#byo-agent-runtimes) when an agent built with another framework should power `<AssistantChat runtime={...}>`.
16
17
  - **Your app consuming MCP tools:** see [MCP Clients](/docs/mcp-clients) when an agent-native app needs to call tools exposed by another MCP server.
17
18
  - **Another app or agent via A2A:** use [Agent Mentions](/docs/agent-mentions) and [A2A](/docs/a2a-protocol) when agent-native apps should discover and delegate to each other.
18
19
  - **Local custom sub-agents:** use [Workspace](/docs/workspace) when you want custom agent profiles inside the agent-native workspace itself.
@@ -13,6 +13,7 @@ Start with the path that matches what you want to do next:
13
13
 
14
14
  - **Use a starter app.** Browse the [template gallery](/templates). Hosted apps already include sign-in, data, and the agent sidebar. No install required.
15
15
  - **Build or customize your own app.** Continue with [Create a local app](#create-your-app). You'll scaffold a template, run it locally, then change the code, brand, data model, and integrations.
16
+ - **Choose headless, chat, embedded, or full app.** Use [Agent Surfaces](/docs/agent-surfaces) when you know the workflow but not how much UI belongs around it.
16
17
  - **Add agent-native skills to a code tool.** Jump to [Try it with a skill](#try-with-a-skill) to add Plans or PR Recaps to Claude Code, Codex, or Cursor without scaffolding an app.
17
18
  - **Connect an external agent to an app.** Use [External Agents](/docs/external-agents) to connect Claude, ChatGPT, Codex, Cursor, OpenCode, GitHub Copilot / VS Code, or another MCP host to an existing app.
18
19
 
@@ -122,6 +123,7 @@ Once your app is running, the usual next step is small and concrete:
122
123
  Useful follow-up docs:
123
124
 
124
125
  - [Key Concepts](/docs/key-concepts) for the architecture: SQL, actions, polling sync, and context awareness
126
+ - [Agent Surfaces](/docs/agent-surfaces) for choosing headless, rich chat, embedded sidecar, or full app
125
127
  - [Workspace](/docs/workspace) for instructions, skills, memory, and per-user MCP connections
126
128
  - [Messaging](/docs/messaging) for Slack, email, Telegram, and other ways to reach the agent
127
129
  - [FAQ](/docs/faq) for setup and product questions
@@ -194,7 +194,7 @@ Agent-native supports a lot of agent-facing protocols because different hosts st
194
194
  | ----------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- |
195
195
  | Agent tool calling | Shipping | The in-app agent sees actions as function tools with zod-derived JSON Schema. | `defineAction()` |
196
196
  | UI actions | Shipping | React calls the same action through `useActionMutation()` / `useActionQuery()`. | The same action |
197
- | Native chat widgets | Shipping | Tool results with explicit widget discriminants can render native tables, charts, approvals, and setup cards in chat. | Structured action results |
197
+ | Native chat widgets | Shipping | Tool results with explicit widget discriminants can render native tables, charts, and typed app results in chat. | Structured action results |
198
198
  | HTTP and CLI | Shipping | Actions auto-mount at `/_agent-native/actions/:name` and run via `pnpm action <name>`. | The same action |
199
199
  | MCP server | Shipping | External MCP hosts get Streamable HTTP tools, the `ask-agent` meta-tool, and optional MCP Apps resources. | The same action, plus optional `mcpApp` |
200
200
  | MCP OAuth | Shipping | Standard remote MCP OAuth, PKCE, dynamic client registration, refresh tokens, and `mcp:read` / `mcp:write` / `mcp:apps` scopes. | Nothing per action |
@@ -222,7 +222,7 @@ Those protocol adapters let the same app grow across three product shapes:
222
222
  | **Rich chat agent** | A standalone or embedded chat can guide setup, call tools, request approvals, and render native tables/charts/results. | Agent-first workflows that still need inspectable output |
223
223
  | **Whole application** | Chat starts central when helpful, then becomes a sidebar next to forms, dashboards, editors, calendars, or documents. | Durable products where humans and agents share state over time |
224
224
 
225
- You should be able to start with the headless contract, add rich chat, and then grow a full app around the same actions and SQL state instead of rebuilding.
225
+ You should be able to start with the headless contract, add rich chat, and then grow a full app around the same actions and SQL state instead of rebuilding. See [Agent Surfaces](/docs/agent-surfaces) for the concrete choice guide and APIs.
226
226
 
227
227
  ## Agent modifies code {#agent-modifies-code}
228
228
 
@@ -320,5 +320,6 @@ For detailed guidance on specific patterns:
320
320
  - [Context Awareness](/docs/context-awareness) — navigation state, view-screen, navigate commands
321
321
  - [Skills Guide](/docs/skills-guide) — framework skills, domain skills, creating custom skills
322
322
  - [Native Chat UI](/docs/native-chat-ui) — action-declared tables, charts, and BYO runtime posture
323
+ - [Agent Surfaces](/docs/agent-surfaces) — headless, rich chat, embedded sidecar, and full-app paths
323
324
  - [A2A Protocol](/docs/a2a-protocol) — agent-to-agent communication
324
325
  - [Multi-App Workspace](/docs/multi-app-workspace) — host many apps in one monorepo with shared auth, skills, components, and credentials
@@ -9,7 +9,7 @@ MCP Apps are the official `io.modelcontextprotocol/ui` extension that lets compa
9
9
 
10
10
  For connecting external agents and the broader MCP server setup, see [External Agents](/docs/external-agents) and [MCP Protocol](/docs/mcp-protocol). This page covers authoring MCP App resources and the embed bridge that powers them.
11
11
 
12
- Inside an Agent-Native app's own chat, prefer [native chat renderers](/docs/native-chat-ui) for first-party widgets such as tables, charts, setup cards, and approvals. Use MCP Apps for external/cross-host inline UI in Claude, ChatGPT, Copilot, Cursor, and other compatible hosts, with the action `link` as the universal deep-link fallback.
12
+ Inside an Agent-Native app's own chat, prefer [native chat renderers](/docs/native-chat-ui) for first-party widgets such as tables, charts, typed results, and approval affordances. Use MCP Apps for external/cross-host inline UI in Claude, ChatGPT, Copilot, Cursor, and other compatible hosts, with the action `link` as the universal deep-link fallback.
13
13
 
14
14
  ## Authoring: optional MCP Apps UI {#mcp-apps}
15
15
 
@@ -178,32 +178,79 @@ arbitrary query execution behind typed read actions rather than raw SQL in chat.
178
178
 
179
179
  ## BYO agent runtimes {#byo-agent-runtimes}
180
180
 
181
- Agent-Native ships the chat/runtime stack: thread persistence, streaming,
182
- attachments, tool calls, run recovery, approvals, suggestions, native widgets,
183
- and SQL-backed app state. In docs, `AgentChatRuntime` refers to that standard
184
- runtime posture, not a separate package you need to replace.
185
-
186
- For bring-your-own agent work, keep the action surface and app state as the
187
- contract:
188
-
189
- - Use `createAgentChatAdapter()` or the `<AssistantChat createAdapter={...} />`
190
- prop when you need a custom assistant-ui transport while keeping the standard
191
- chat runtime.
192
- - Use `PromptComposer` only when your product owns the full external runtime
193
- and wants the Agent-Native composer field without the standard transcript.
194
- - Treat AG-UI as the likely adapter shape for external event-stream runtimes.
195
- It should adapt into Agent-Native actions, context, and native renderers
196
- rather than creating a second app API.
197
- - Treat ACP as coding-agent/editor interoperability. It is useful for IDE
198
- agents, but it is not the general BYO chat runtime contract for app users.
199
-
200
- The goal is one operation model: actions, SQL state, context awareness, native
201
- widgets, MCP Apps, A2A, and MCP all wrap the same app capabilities instead of
202
- forking behavior per agent surface.
181
+ `AgentChatRuntime` is the bring-your-own-agent contract for the chat shell. It
182
+ lets an agent you built elsewhere stream normalized events into Agent-Native's
183
+ conversation UI while keeping the shared composer, transcript rendering, tool
184
+ cards, approvals, native widgets, and surrounding app layout. For how this fits
185
+ with headless actions, embedded sidecars, and full applications, see
186
+ [Agent Surfaces](/docs/agent-surfaces).
187
+
188
+ Use the generic HTTP runtime when your agent can expose a POST endpoint that
189
+ returns SSE or NDJSON runtime events:
190
+
191
+ ```tsx
192
+ import {
193
+ AssistantChat,
194
+ createHttpAgentChatRuntime,
195
+ } from "@agent-native/core/client/chat";
196
+
197
+ const runtime = createHttpAgentChatRuntime({
198
+ id: "external:mastra",
199
+ label: "Mastra",
200
+ endpoint: "/api/mastra/chat",
201
+ headers: async () => ({
202
+ Authorization: `Bearer ${await getAgentToken()}`,
203
+ }),
204
+ });
205
+
206
+ export function SupportChat() {
207
+ return <AssistantChat runtime={runtime} threadId="support" />;
208
+ }
209
+ ```
210
+
211
+ The endpoint may stream the normalized event shape directly:
212
+
213
+ ```txt
214
+ data: {"type":"message-start","message":{"id":"m1","role":"assistant","content":[]}}
215
+ data: {"type":"message-delta","messageId":"m1","delta":{"type":"text","text":"Hello"}}
216
+ data: {"type":"tool-start","toolCall":{"id":"t1","name":"query","input":{"q":"forms"}}}
217
+ data: {"type":"tool-done","toolCallId":"t1","toolName":"query","status":"completed","resultText":"34 rows"}
218
+ data: {"type":"done","reason":"complete"}
219
+ ```
220
+
221
+ For very simple agents, a JSON response `{ "text": "..." }` is accepted and
222
+ converted into a single assistant message. For richer agents, stream
223
+ `message-*`, `tool-*`, `approval-request`, `status`, `artifact`, `file`,
224
+ `usage`, `error`, and `done` events. Tool results can carry `mcpApp` or
225
+ `chatUI` metadata, so action-declared native widgets still render without
226
+ iframes.
227
+
228
+ When you want the built-in Agent-Native transport as a runtime object, use:
229
+
230
+ ```ts
231
+ import { createAgentNativeChatRuntime } from "@agent-native/core/client/chat";
232
+
233
+ const runtime = createAgentNativeChatRuntime({
234
+ threadId: "forms-chat",
235
+ mode: "act",
236
+ });
237
+ ```
238
+
239
+ Use `<AssistantChat createAdapter={...} />` only when you need full
240
+ assistant-ui adapter control. Use `PromptComposer` by itself when your product
241
+ owns the entire external transcript and only wants Agent-Native's composer
242
+ field.
243
+
244
+ AG-UI is still an adapter target: it can be mapped into `AgentChatRuntime`
245
+ events, actions, context, and native renderers over time. ACP remains
246
+ coding-agent/editor interoperability, not the general app-chat runtime for end
247
+ users. A2UI is not claimed as supported here; if it matures, it should adapt
248
+ into this same explicit runtime/widget contract.
203
249
 
204
250
  ## Related docs {#related-docs}
205
251
 
206
252
  - [Actions](/docs/actions) — define the operations that return native widget data.
253
+ - [Agent Surfaces](/docs/agent-surfaces) — decide whether you need headless, chat, sidecar, or full app.
207
254
  - [Drop-in Agent](/docs/drop-in-agent) — mount the standard chat runtime.
208
255
  - [Component API](/docs/components) — custom chat layers and tool renderers.
209
256
  - [MCP Apps](/docs/mcp-apps) — inline UI for external MCP hosts.
@@ -37,9 +37,35 @@ the Plan MCP connector. They write `plans/<slug>/plan.mdx` plus optional
37
37
  `canvas.mdx`, `prototype.mdx`, and `.plan-state.json`, then preview locally with:
38
38
 
39
39
  ```bash
40
- npx @agent-native/core@latest plan local preview --dir plans/<slug> --kind plan --open
40
+ npx @agent-native/core@latest plan local serve --dir plans/<slug> --kind plan --open
41
41
  ```
42
42
 
43
+ This starts a tiny localhost bridge and opens the Plan UI against the local
44
+ folder. (`plan local preview` runs a local Plan dev-server route instead, and
45
+ `plan local preview --out preview.html` is a legacy escape hatch that writes a
46
+ standalone static HTML file. `plan serve` is accepted as a short alias for
47
+ `plan local serve`.)
48
+
49
+ A few local-files-mode gotchas worth knowing:
50
+
51
+ - **Use a Chromium browser.** Safari blocks the hosted HTTPS Plan page from
52
+ reading the `http://127.0.0.1` localhost bridge (mixed-content / private
53
+ network), so the page hangs on "Loading plan." On macOS `--open` already
54
+ prefers Chrome/Chromium/Edge/Brave; if Safari opens anyway, reopen the printed
55
+ URL in a Chromium browser.
56
+ - **The served URL is written to `plans/<slug>/.plan-url`** (override with
57
+ `--url-file`). A backgrounded or headless agent can read that file instead of
58
+ scraping the long-running `serve` stdout. Treat it as a local token file and
59
+ do not commit it.
60
+ - **Verify headlessly** when no browser is available:
61
+ `npx @agent-native/core@latest plan local verify --dir plans/<slug>` starts the
62
+ bridge, checks the private-network preflight and JSON payload, prints
63
+ diagnostics, and exits non-zero on failure — no human eyes required.
64
+ - **Run `plan local check` first.** It validates the MDX against the Plan
65
+ renderer's block schema (including required fields like `checklist` item
66
+ `id`/`label` and `question-form` question `id`/`title`/`mode`), so authoring
67
+ mistakes surface before the browser handoff instead of as a stuck loader.
68
+
43
69
  For folders in the current repo, the direct local route includes `?path=...` so
44
70
  the local Plan app can keep browser edits saving to the repo folder. The Plan
45
71
  app uses `apps.plan.roots[0].path` in `agent-native.json` as the default place
@@ -5,7 +5,7 @@ description: "Apps where the agent is the whole product — open it, ask for wha
5
5
 
6
6
  # Pure-Agent Apps
7
7
 
8
- This is the minimal end of agent-native — for the full-UI end, start from a [template](/docs/cloneable-saas).
8
+ This is the minimal end of agent-native — for the full-UI end, start from a [template](/docs/cloneable-saas). If you are choosing between headless, chat-first, embedded, and full-app shapes, start with [Agent Surfaces](/docs/agent-surfaces).
9
9
 
10
10
  Imagine opening an app and seeing… just a chat. No dashboard. No sidebar full of menus. No forms. You ask for what you want — "summarize my unread emails," "post the daily metrics to Slack," "find the candidates who replied last week" — and the agent goes off and does it. The output shows up in chat, in Slack, in your inbox, wherever it belongs.
11
11
 
@@ -90,6 +90,7 @@ Most pure-agent apps eventually want a little custom UI — not a dashboard, but
90
90
  ## What's next
91
91
 
92
92
  - [**Getting Started**](/docs/getting-started) — clone the Starter template
93
+ - [**Agent Surfaces**](/docs/agent-surfaces) — choose headless, rich chat, embedded sidecar, or full app
93
94
  - [**Messaging the agent**](/docs/messaging) — how users talk to the agent across web, Slack, Telegram, email
94
95
  - [**Recurring Jobs**](/docs/recurring-jobs) — scheduled prompts the agent runs on its own
95
96
  - [**Dispatch**](/docs/template-dispatch) — the workspace template that's a great starting point for pure-agent apps
@@ -39,6 +39,7 @@ _For developers building the app._
39
39
  The agent isn't a separate app you tab over to. It ships as a handful of React components — a sidebar, a raw panel, and a `sendToAgentChat()` call — that you drop into any app. Render `<AgentSidebar>` to give every screen a toggleable agent, or wire a button to hand a specific task off to the chat instead of running a one-shot LLM call.
40
40
 
41
41
  → [**Drop-in Agent**](/docs/drop-in-agent) — mount `<AgentPanel>`, `<AgentSidebar>`, and `sendToAgentChat()` into any React app. _(For developers building the app.)_
42
+ → [**Agent Surfaces**](/docs/agent-surfaces) — choose whether the workflow should be headless, chat-first, embedded, or a full app. _(For developers designing the product shape.)_
42
43
 
43
44
  ## You can go UI-light {#ui-light}
44
45
 
@@ -66,10 +66,10 @@ At minimum, "a UI for the agent" is an observability and management dashboard. A
66
66
  There are three useful shapes:
67
67
 
68
68
  - **Headless** — call the agent and actions from code, HTTP, CLI, MCP, or A2A.
69
- - **Rich chat** — give the agent a first-class chat UI with native tool widgets such as tables, charts, approvals, setup cards, and links into app views. See [Native Chat UI](/docs/native-chat-ui).
69
+ - **Rich chat** — give the agent a first-class chat UI with native tool widgets such as tables, charts, typed results, approvals, and links into app views. See [Native Chat UI](/docs/native-chat-ui).
70
70
  - **Whole app** — put a full application around the agent, with SQL state, context awareness, deep links, and live sync so humans and agents stay in the same workspace.
71
71
 
72
- Agent-native is designed so those are stages, not rewrites. You can start headless, add rich chat, and grow into a full app around the same action surface.
72
+ Agent-native is designed so those are stages, not rewrites. You can start headless, add rich chat, and grow into a full app around the same action surface. See [Agent Surfaces](/docs/agent-surfaces) for the concrete APIs behind each shape.
73
73
 
74
74
  ## Why every app benefits from an agent {#why-every-app-benefits-from-an-agent}
75
75
 
@@ -186,6 +186,7 @@ One action, many surfaces: the agent calls it as a tool, the UI calls it as a ty
186
186
  ## What's next {#whats-next}
187
187
 
188
188
  - [**Getting Started**](/docs) — pick a template and run it
189
+ - [**Agent Surfaces**](/docs/agent-surfaces) — choose headless, rich chat, embedded sidecar, or full app
189
190
  - [**Key Concepts**](/docs/key-concepts) — the architecture: SQL, actions, polling sync, context awareness, portability
190
191
  - [**Templates**](/docs/cloneable-saas) — templates as complete products you own
191
192
  - [**Workspace**](/docs/workspace) — the per-user customization layer (skills, memory, instructions, MCP) backed by SQL, not files