@agent-native/core 0.55.0 → 0.56.1
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.
- package/README.md +7 -7
- package/dist/action-ui.d.ts +17 -0
- package/dist/action-ui.d.ts.map +1 -0
- package/dist/action-ui.js +23 -0
- package/dist/action-ui.js.map +1 -0
- package/dist/action.d.ts +8 -1
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js +3 -0
- package/dist/action.js.map +1 -1
- package/dist/agent/production-agent.d.ts +2 -0
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +7 -1
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/thread-data-builder.d.ts +4 -0
- package/dist/agent/thread-data-builder.d.ts.map +1 -1
- package/dist/agent/thread-data-builder.js +4 -0
- package/dist/agent/thread-data-builder.js.map +1 -1
- package/dist/agent/types.d.ts +2 -0
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +6 -4
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/chat/index.d.ts +5 -3
- package/dist/client/chat/index.d.ts.map +1 -1
- package/dist/client/chat/index.js +4 -3
- package/dist/client/chat/index.js.map +1 -1
- package/dist/client/chat/run-recovery.d.ts.map +1 -1
- package/dist/client/chat/run-recovery.js +9 -5
- package/dist/client/chat/run-recovery.js.map +1 -1
- package/dist/client/chat/runtime.d.ts +354 -0
- package/dist/client/chat/runtime.d.ts.map +1 -0
- package/dist/client/chat/runtime.js +2 -0
- package/dist/client/chat/runtime.js.map +1 -0
- package/dist/client/chat/tool-call-display.d.ts +4 -1
- package/dist/client/chat/tool-call-display.d.ts.map +1 -1
- package/dist/client/chat/tool-call-display.js +6 -5
- package/dist/client/chat/tool-call-display.js.map +1 -1
- package/dist/client/chat/tool-render-registry.d.ts +11 -0
- package/dist/client/chat/tool-render-registry.d.ts.map +1 -1
- package/dist/client/chat/tool-render-registry.js +47 -1
- package/dist/client/chat/tool-render-registry.js.map +1 -1
- package/dist/client/chat/widgets/builtin-tool-renderers.js +73 -18
- package/dist/client/chat/widgets/builtin-tool-renderers.js.map +1 -1
- package/dist/client/chat/widgets/data-widget-types.d.ts +1 -51
- package/dist/client/chat/widgets/data-widget-types.d.ts.map +1 -1
- package/dist/client/chat/widgets/data-widget-types.js +1 -92
- package/dist/client/chat/widgets/data-widget-types.js.map +1 -1
- package/dist/client/chat-view-transition.d.ts +12 -0
- package/dist/client/chat-view-transition.d.ts.map +1 -1
- package/dist/client/chat-view-transition.js +16 -0
- package/dist/client/chat-view-transition.js.map +1 -1
- package/dist/client/index.d.ts +5 -3
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +4 -3
- package/dist/client/index.js.map +1 -1
- package/dist/client/route-state.d.ts.map +1 -1
- package/dist/client/route-state.js +2 -15
- package/dist/client/route-state.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts +3 -0
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +2 -0
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/data-widgets/index.d.ts +326 -0
- package/dist/data-widgets/index.d.ts.map +1 -0
- package/dist/data-widgets/index.js +232 -0
- package/dist/data-widgets/index.js.map +1 -0
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +14 -0
- package/dist/deploy/build.js.map +1 -1
- package/dist/index.browser.d.ts +2 -0
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js +2 -0
- package/dist/index.browser.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/provider-api/corpus-jobs.d.ts +160 -0
- package/dist/provider-api/corpus-jobs.d.ts.map +1 -1
- package/dist/provider-api/corpus-jobs.js +44 -0
- package/dist/provider-api/corpus-jobs.js.map +1 -1
- package/dist/provider-api/index.d.ts +39 -0
- package/dist/provider-api/index.d.ts.map +1 -1
- package/dist/provider-api/index.js +53 -0
- package/dist/provider-api/index.js.map +1 -1
- package/dist/server/action-discovery.d.ts.map +1 -1
- package/dist/server/action-discovery.js +5 -0
- package/dist/server/action-discovery.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +5 -0
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/styles/agent-native.css +9 -2
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +1 -0
- package/dist/vite/client.js.map +1 -1
- package/docs/content/actions.md +52 -0
- package/docs/content/components.md +24 -1
- package/docs/content/drop-in-agent.md +9 -2
- package/docs/content/faq.md +5 -4
- package/docs/content/getting-started.md +39 -88
- package/docs/content/key-concepts.md +22 -22
- package/docs/content/mcp-apps.md +1 -1
- package/docs/content/native-chat-ui.md +210 -0
- package/docs/content/what-is-agent-native.md +2 -2
- package/package.json +5 -2
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Native Chat UI"
|
|
3
|
+
description: "Action-declared native chat renderers, reusable DataTable/DataChart outputs, and how BYO agent runtimes should connect to Agent-Native chat."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Native Chat UI
|
|
7
|
+
|
|
8
|
+
Native chat UI is the in-app rendering path for first-party agent output. An
|
|
9
|
+
action returns structured JSON, the chat runtime recognizes an explicit widget
|
|
10
|
+
discriminant, and `<AssistantChat>` renders a real React component in the
|
|
11
|
+
conversation. You do not build an iframe or a one-off HTML artifact for the
|
|
12
|
+
normal app chat.
|
|
13
|
+
|
|
14
|
+
Use native chat UI when the user should inspect output where the agent is
|
|
15
|
+
already speaking: query results, response insights, setup summaries,
|
|
16
|
+
approval/denial controls, or links into app views. Use [MCP Apps](/docs/mcp-apps)
|
|
17
|
+
when an external host such as Claude, ChatGPT, Copilot, or Cursor should render
|
|
18
|
+
an inline route from your app.
|
|
19
|
+
|
|
20
|
+
## Action-declared widgets {#action-declared-widgets}
|
|
21
|
+
|
|
22
|
+
The native path has two explicit parts:
|
|
23
|
+
|
|
24
|
+
- `outputSchema` validates the action's response shape.
|
|
25
|
+
- `chatUI.renderer` selects the native React renderer for the validated result.
|
|
26
|
+
|
|
27
|
+
The built-in data renderers use a plain JSON result with `widget` plus the
|
|
28
|
+
matching payload:
|
|
29
|
+
|
|
30
|
+
| Widget | Required payload | Renders as |
|
|
31
|
+
| ----------------- | ---------------------------- | ----------------------------------------------- |
|
|
32
|
+
| `"data-table"` | `table` | A native, reusable data table |
|
|
33
|
+
| `"data-chart"` | `chartSeries` | A native bar, line, or area chart |
|
|
34
|
+
| `"data-insights"` | `table` and/or `chartSeries` | A combined insight card with chart/table output |
|
|
35
|
+
|
|
36
|
+
Server actions should import the server-safe helpers and schemas from
|
|
37
|
+
`@agent-native/core/data-widgets`; client code can import the same types from
|
|
38
|
+
`@agent-native/core/client/chat` or `@agent-native/core/client`.
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import {
|
|
42
|
+
ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER,
|
|
43
|
+
dataInsightsWidgetResultSchema,
|
|
44
|
+
defineAction,
|
|
45
|
+
} from "@agent-native/core";
|
|
46
|
+
import { createDataInsightsWidgetResult } from "@agent-native/core/data-widgets";
|
|
47
|
+
|
|
48
|
+
export default defineAction({
|
|
49
|
+
description: "Analyze form responses.",
|
|
50
|
+
readOnly: true,
|
|
51
|
+
outputSchema: dataInsightsWidgetResultSchema,
|
|
52
|
+
chatUI: {
|
|
53
|
+
renderer: ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER,
|
|
54
|
+
title: "Response insights",
|
|
55
|
+
},
|
|
56
|
+
run: async () =>
|
|
57
|
+
createDataInsightsWidgetResult({
|
|
58
|
+
title: "Response insights",
|
|
59
|
+
display: {
|
|
60
|
+
title: "42 responses",
|
|
61
|
+
description: "Completion rate rose this week.",
|
|
62
|
+
primaryAction: {
|
|
63
|
+
label: "Open response insights",
|
|
64
|
+
href: "/response-insights",
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
chartSeries: {
|
|
68
|
+
type: "bar",
|
|
69
|
+
title: "Responses by day",
|
|
70
|
+
xKey: "day",
|
|
71
|
+
series: [{ key: "responses", label: "Responses" }],
|
|
72
|
+
data: [
|
|
73
|
+
{ day: "Mon", responses: 8 },
|
|
74
|
+
{ day: "Tue", responses: 13 },
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
table: {
|
|
78
|
+
title: "Top answers",
|
|
79
|
+
columns: [
|
|
80
|
+
{ key: "answer", label: "Answer" },
|
|
81
|
+
{ key: "count", label: "Count", align: "right" },
|
|
82
|
+
],
|
|
83
|
+
rows: [
|
|
84
|
+
{ answer: "Yes", count: 31 },
|
|
85
|
+
{ answer: "No", count: 11 },
|
|
86
|
+
],
|
|
87
|
+
totalRows: 2,
|
|
88
|
+
},
|
|
89
|
+
}),
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The renderer only takes over when the action declares `chatUI` or the result has
|
|
94
|
+
an explicit known `widget` discriminant. It never shape-infers arbitrary objects
|
|
95
|
+
and it never executes HTML or JavaScript from tool results.
|
|
96
|
+
|
|
97
|
+
## DataTable output {#data-table}
|
|
98
|
+
|
|
99
|
+
`table` is intentionally simple so list, SQL, analytics, and setup actions can
|
|
100
|
+
reuse it:
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
{
|
|
104
|
+
title?: string;
|
|
105
|
+
columns: Array<{ key: string; label: string; align?: "left" | "right" }>;
|
|
106
|
+
rows: Array<Record<string, unknown>>;
|
|
107
|
+
totalRows?: number;
|
|
108
|
+
sampledRows?: number;
|
|
109
|
+
truncated?: boolean;
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Prefer stable column keys and JSON-safe row values. Use `totalRows`,
|
|
114
|
+
`sampledRows`, and `truncated` when the action is showing a slice of a larger
|
|
115
|
+
result set.
|
|
116
|
+
|
|
117
|
+
## DataChart output {#data-chart}
|
|
118
|
+
|
|
119
|
+
`chartSeries` supports the common chart shapes used in agent answers without
|
|
120
|
+
requiring each template to ship its own chat renderer:
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
{
|
|
124
|
+
type: "bar" | "line" | "area";
|
|
125
|
+
title?: string;
|
|
126
|
+
xKey: string;
|
|
127
|
+
series: Array<{ key: string; label: string; color?: string }>;
|
|
128
|
+
data: Array<Record<string, unknown>>;
|
|
129
|
+
sampled?: boolean;
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Keep chart data compact. For large datasets, aggregate in the action and link
|
|
134
|
+
to the full app view with `display.primaryAction` or action `link` metadata.
|
|
135
|
+
|
|
136
|
+
## Native widgets vs MCP Apps {#native-vs-mcp-apps}
|
|
137
|
+
|
|
138
|
+
Native chat widgets and MCP Apps are complementary:
|
|
139
|
+
|
|
140
|
+
- **Native widgets** are for the app's own chat runtime. The action result is
|
|
141
|
+
JSON, and the framework renders the built-in React widget.
|
|
142
|
+
- **MCP Apps** are for external hosts. The action declares `mcpApp` and usually
|
|
143
|
+
`link`, and the host renders a real app route inline when supported.
|
|
144
|
+
- **Deep links** remain the universal fallback. Use action `link` or
|
|
145
|
+
`display.primaryAction` so CLI clients, older MCP hosts, and plain transcript
|
|
146
|
+
readers can open the full app view.
|
|
147
|
+
|
|
148
|
+
When both a native widget payload and MCP Apps metadata are present, the in-app
|
|
149
|
+
chat prefers the native widget. External hosts use the MCP Apps resource or the
|
|
150
|
+
deep link fallback.
|
|
151
|
+
|
|
152
|
+
## Custom native renderers {#custom-native-renderers}
|
|
153
|
+
|
|
154
|
+
Register product-specific components by exact renderer id, then declare that id
|
|
155
|
+
on the action:
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
import { registerActionChatRenderer } from "@agent-native/core/client/chat";
|
|
159
|
+
|
|
160
|
+
registerActionChatRenderer({
|
|
161
|
+
id: "crm.deal-card",
|
|
162
|
+
renderer: "crm.deal-card",
|
|
163
|
+
Component: ({ context }) => <DealCard result={context.resultJson} />,
|
|
164
|
+
});
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
export default defineAction({
|
|
169
|
+
description: "Show a deal card.",
|
|
170
|
+
outputSchema: dealCardSchema,
|
|
171
|
+
chatUI: { renderer: "crm.deal-card" },
|
|
172
|
+
run: async () => ({ dealId: "deal_123", amount: 42000 }),
|
|
173
|
+
});
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Use this for first-party app UI. Keep cross-host iframe UI in `mcpApp`, and keep
|
|
177
|
+
arbitrary query execution behind typed read actions rather than raw SQL in chat.
|
|
178
|
+
|
|
179
|
+
## BYO agent runtimes {#byo-agent-runtimes}
|
|
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.
|
|
203
|
+
|
|
204
|
+
## Related docs {#related-docs}
|
|
205
|
+
|
|
206
|
+
- [Actions](/docs/actions) — define the operations that return native widget data.
|
|
207
|
+
- [Drop-in Agent](/docs/drop-in-agent) — mount the standard chat runtime.
|
|
208
|
+
- [Component API](/docs/components) — custom chat layers and tool renderers.
|
|
209
|
+
- [MCP Apps](/docs/mcp-apps) — inline UI for external MCP hosts.
|
|
210
|
+
- [Key Concepts](/docs/key-concepts#protocols) — protocol status and positioning.
|
|
@@ -66,7 +66,7 @@ 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.
|
|
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).
|
|
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
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.
|
|
@@ -181,7 +181,7 @@ import { AgentSidebar } from "@agent-native/core/client";
|
|
|
181
181
|
<AgentSidebar />;
|
|
182
182
|
```
|
|
183
183
|
|
|
184
|
-
One action, many surfaces: the agent calls it as a tool, the UI calls it as a typesafe mutation, native chat can render explicit widget results, external agents reach it over [A2A](/docs/a2a-protocol), and MCP hosts call it through the app's [MCP server](/docs/mcp-protocol), optionally with MCP Apps UI resources and standard remote MCP OAuth handled by the framework. See [Actions](/docs/actions) for the full reference.
|
|
184
|
+
One action, many surfaces: the agent calls it as a tool, the UI calls it as a typesafe mutation, [native chat](/docs/native-chat-ui) can render explicit widget results, external agents reach it over [A2A](/docs/a2a-protocol), and MCP hosts call it through the app's [MCP server](/docs/mcp-protocol), optionally with MCP Apps UI resources and standard remote MCP OAuth handled by the framework. See [Actions](/docs/actions) for the full reference.
|
|
185
185
|
|
|
186
186
|
## What's next {#whats-next}
|
|
187
187
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22"
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"./server/design-token-utils": "./dist/server/design-token-utils.js",
|
|
38
38
|
"./brand-kit": "./dist/brand-kit/index.js",
|
|
39
39
|
"./brand-kit/fig": "./dist/brand-kit/fig/index.js",
|
|
40
|
+
"./data-widgets": "./dist/data-widgets/index.js",
|
|
40
41
|
"./agent-web": "./dist/agent-web/index.js",
|
|
41
42
|
"./db": "./dist/db/index.js",
|
|
42
43
|
"./db/schema": "./dist/db/schema.js",
|
|
@@ -140,7 +141,9 @@
|
|
|
140
141
|
"./tsconfig.base.json": "./tsconfig.base.json"
|
|
141
142
|
},
|
|
142
143
|
"sideEffects": [
|
|
143
|
-
"*.css"
|
|
144
|
+
"*.css",
|
|
145
|
+
"dist/client/chat/widgets/builtin-tool-renderers.js",
|
|
146
|
+
"dist/client/dev-overlay/builtins.js"
|
|
144
147
|
],
|
|
145
148
|
"files": [
|
|
146
149
|
"bin",
|