@heroui/agent 0.2.0-beta.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/CHANGELOG.md ADDED
@@ -0,0 +1,64 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0-beta.1
4
+
5
+ - Add the `kpi-grid` component: up to four headline KPIs, each pairing its value and change with a
6
+ sparkline of its own history. `renderComponent` can build one straight from a multi-period dataset,
7
+ taking each numeric column as one KPI. `metric-grid` stays for figures with no history to plot, and
8
+ the agent is instructed never to fabricate a trend to reach for the richer card.
9
+ - Fold `renderUI` into `composeUI`, which now accepts either a single component or a layout tree as
10
+ its root. The component union is no longer declared to the model as a tool schema: it reads a
11
+ compact kind catalog and fetches the props it needs with `getComponentSchema`, which cut ~300 KB
12
+ (~76K tokens) of JSON Schema off every rendering request. `renderUI` and the `loadUIRenderers`
13
+ deferral it needed are gone; only `loadUIRenderers` stays reserved for stored-conversation safety.
14
+ - Promote fourteen polished Storybook response compositions to validated Agent UI kinds, including
15
+ current weather, forecasts, flights, events, rides, playlists, commerce, messages, player stats,
16
+ notifications, and product-signal tabs.
17
+ - Bump the Agent protocol to version 4 so older embeds receive an explicit upgrade response instead
18
+ of silently dropping the new component kinds.
19
+ - Require a `getAuthToken` callback alongside `agentId` for React, Next.js, and
20
+ CDN integrations.
21
+ - Exchange the project API key only from a server when minting a short-lived browser token.
22
+ Protocol version 3 includes its API key id in the JWT so revoking a key immediately invalidates
23
+ its sessions.
24
+ - Add dashboard-managed projects, versioned playground configuration, and deterministic
25
+ server-authenticated setup code generation.
26
+ - Identify signed-in end users: `createAuthToken` accepts the browser's `anonymousId` alongside an
27
+ identified `identity`, moving conversations started before login onto that person. Identified
28
+ users now see their history on any device they sign in from.
29
+ - Add `useAgent().refreshAuth()` to mint a credential for the person who just signed in.
30
+ `shutdown()` now also drops the cached credential and the browser's anonymous id, so a shared
31
+ device does not attribute the next visitor to the previous user.
32
+ - Reject placeholder identity values such as `anonymous`, `undefined`, and `null`, which would
33
+ otherwise collapse unrelated visitors into one person.
34
+
35
+ ## 0.1.0-beta.0
36
+
37
+ - Initial public beta of the React provider, vanilla loader, server token client, approval-gated
38
+ actions, generated calculation sandbox, durable streaming transport, and validated generative UI
39
+ components.
40
+ - Generative UI renders through three runtime tools — `renderComponent` (dataset charts, tables,
41
+ metrics, comparisons), `renderUI` (record cards, timelines, forms, follow-ups, dashboards), and
42
+ `composeUI` (bounded layout composition) — all constrained to one validated component union.
43
+ - Semantic card hierarchy plus details/compact/media record layouts, meter lists, task progress
44
+ states, typed number/date-range/time/boolean form fields, prompt-aware actions, and
45
+ runtime-attested source links for web-backed responses.
46
+ - Per-browser conversation history with an in-embed conversation picker and a resizable sidebar
47
+ view mode.
48
+ - Embed styles ship through the `@heroui/agent/css` package export and must be imported by React
49
+ applications; the CDN loader adds the same compiled stylesheet automatically.
50
+ - Grouped configuration props: `appearance` (view mode plus a small theme surface with color
51
+ scheme, radius, seven color tokens, and typography), `composer`, `startScreen` (greeting and
52
+ prompts), `capabilities`, `permissions`, `componentExports`, `responseActions`, and
53
+ `showLauncher` — with `agentId`, `tools`, and `context` at the root. Permission modes can ask
54
+ before every client tool, respect per-tool `needsApproval` flags, or run declared tools without
55
+ prompting; the end-user picker is host opt-in.
56
+
57
+ ### Known limitations
58
+
59
+ - Invite-only manual provisioning, English-only UI, a fixed validated component union, and
60
+ per-browser conversation history (no cross-device identity).
61
+ - No background mutations, MCP/OpenAPI import, custom component registration, self-hosting, or
62
+ public pricing during the beta.
63
+ - Exact compatibility is guaranteed only for protocol version 4 and this prerelease; review this
64
+ changelog before upgrading to another beta.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 HeroUI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,205 @@
1
+ ![hero](https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/npm-packages/agents/heroui-agents@2x.jpg)
2
+
3
+ # HeroUI Agents SDK
4
+
5
+ Embed a hosted generative-UI agent in your React app with [`@heroui/agent`](https://www.heroui.com/agents). Declare typed client tools that read your data — the hosted runtime plans the answer, runs calculations in a sandbox, and streams back charts, tables, and metrics.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @heroui/agent@beta
11
+ ```
12
+
13
+ Import the stylesheet once:
14
+
15
+ ```css
16
+ @import "@heroui/agent/css";
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```tsx
22
+ import {HeroUIAgent} from "@heroui/agent/next";
23
+
24
+ export function AppAgent() {
25
+ return (
26
+ <HeroUIAgent
27
+ agentId="proj_..."
28
+ getAuthToken={async (context) => {
29
+ const response = await fetch("/api/heroui-agent/auth-token", {
30
+ method: "POST",
31
+ headers: {"Content-Type": "application/json"},
32
+ body: JSON.stringify(context),
33
+ });
34
+
35
+ if (!response.ok) throw new Error("Agent authentication failed");
36
+
37
+ return response.json();
38
+ }}
39
+ />
40
+ );
41
+ }
42
+ ```
43
+
44
+ Mint the short-lived browser credential on your server — never expose the project API key to the client:
45
+
46
+ ```ts
47
+ import {createAuthToken} from "@heroui/agent/server";
48
+
49
+ export async function POST(request: Request) {
50
+ const {anonymousId, agentId} = await request.json();
51
+
52
+ return Response.json(
53
+ await createAuthToken({
54
+ apiKey: process.env.HEROUI_AGENT_API_KEY!,
55
+ identity: {id: anonymousId, type: "anonymous"},
56
+ agentId,
57
+ }),
58
+ );
59
+ }
60
+ ```
61
+
62
+ ## Overview
63
+
64
+ `@heroui/agent` provides a unified SDK for embedding HeroUI Agents into web applications.
65
+
66
+ ### Entrypoints
67
+
68
+ | Entrypoint | Description | Links |
69
+ | -------------------------------------------- | -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
70
+ | [`@heroui/agent`](#herouiagent) | React embed, hooks, and client tools | [npm](https://www.npmjs.com/package/@heroui/agent) • [Docs](https://heroui.pro/docs/agent/getting-started/installation) |
71
+ | [`@heroui/agent/next`](#herouiagentnext) | Next.js App Router entry | [Docs](https://heroui.pro/docs/agent/getting-started/installation) |
72
+ | [`@heroui/agent/server`](#herouiagentserver) | Server helpers for minting auth tokens | [Docs](https://heroui.pro/docs/agent/getting-started/identifying-users) |
73
+ | [`@heroui/agent/css`](#styles) | Agent stylesheet | — |
74
+ | [`@heroui/agent/contracts`](#contracts) | Shared protocol types and schemas | — |
75
+
76
+ ## Package Details
77
+
78
+ ### @heroui/agent
79
+
80
+ The core React SDK for embedding a hosted agent.
81
+
82
+ #### Features
83
+
84
+ - **Generative UI** — Charts, tables, metrics, and forms streamed from a validated component union
85
+ - **Client tools** — Typed browser functions that run with the signed-in user's session
86
+ - **Dashboard-driven appearance** — Theme, launcher, greeting, and composer without a redeploy
87
+ - **Anonymous → identified** — Merge guest history when the user signs in
88
+ - **Edge-safe contracts** — Protocol types with no Node built-ins
89
+
90
+ #### Installation
91
+
92
+ ```bash
93
+ npm install @heroui/agent@beta
94
+ ```
95
+
96
+ ### @heroui/agent/next
97
+
98
+ Next.js App Router entry that mirrors the root export.
99
+
100
+ ```tsx
101
+ import {HeroUIAgent} from "@heroui/agent/next";
102
+ ```
103
+
104
+ ### @heroui/agent/server
105
+
106
+ Server-only helpers for exchanging a project API key for a short-lived browser credential.
107
+
108
+ ```ts
109
+ import {createAuthToken} from "@heroui/agent/server";
110
+ ```
111
+
112
+ ### Styles
113
+
114
+ ```css
115
+ @import "@heroui/agent/css";
116
+ ```
117
+
118
+ Optional Pro theme variants (`brutalism`, `glass`, `mouve`) ship from [`@heroui-pro/react`](https://heroui.pro/docs):
119
+
120
+ ```tsx
121
+ import "@heroui/agent/css";
122
+ import "@heroui-pro/react/agent-themes/glass";
123
+ ```
124
+
125
+ ### Contracts
126
+
127
+ Shared protocol version, message types, and schemas used by the SDK and hosted API.
128
+
129
+ ```ts
130
+ import {HEROUI_AGENT_PROTOCOL_VERSION} from "@heroui/agent/contracts";
131
+ ```
132
+
133
+ ## Client Tools
134
+
135
+ Client tools let the agent call into your application — fetch data, change filters, create records:
136
+
137
+ ```tsx
138
+ import {HeroUIAgent, createToolHelper} from "@heroui/agent";
139
+ import {z} from "zod";
140
+
141
+ const tool = createToolHelper<{apiClient: ApiClient}>();
142
+
143
+ const tools = [
144
+ tool({
145
+ name: "search_users",
146
+ description: "Search for users by name or email",
147
+ parameters: z.object({query: z.string()}),
148
+ execute: ({query}, context) => context.apiClient.searchUsers(query),
149
+ }),
150
+ ];
151
+
152
+ <HeroUIAgent agentId="proj_..." getAuthToken={getAuthToken} context={{apiClient}} tools={tools} />;
153
+ ```
154
+
155
+ Only tool names, descriptions, and JSON schemas reach the hosted agent. Implementations and `context` never leave the browser.
156
+
157
+ [Learn more](https://heroui.pro/docs/agent/api-reference/client-tools)
158
+
159
+ ## Documentation
160
+
161
+ - [Installation](https://heroui.pro/docs/agent/getting-started/installation)
162
+ - [Identifying users](https://heroui.pro/docs/agent/getting-started/identifying-users)
163
+ - [Configuration](https://heroui.pro/docs/agent/api-reference/configuration)
164
+ - [Client tools](https://heroui.pro/docs/agent/api-reference/client-tools)
165
+ - [Appearance](https://heroui.pro/docs/agent/configure/appearance)
166
+ - [Configure](https://heroui.pro/docs/agent/configure)
167
+
168
+ Projects and API keys are managed in the [Agents dashboard](https://heroui.pro/dashboard/agents).
169
+
170
+ ## What runs where
171
+
172
+ The browser sends every message through the HeroUI API, which owns the model,
173
+ the durable run, the conversation store, and server-side tools. Answers stream
174
+ back over a direct read-only realtime connection so tokens and client-tool
175
+ calls arrive without an API proxy hop.
176
+
177
+ | In the browser | Behind the HeroUI API |
178
+ | -------------------------------------------- | -------------------------------------------- |
179
+ | Panel, theme, composer, generated UI | Model orchestration and the durable run |
180
+ | Client tools, running as the signed-in user | Server tools, MCP servers, knowledge search |
181
+ | A short-lived, read-only answer stream token | Runtime credentials and conversation storage |
182
+
183
+ ## Compatibility
184
+
185
+ - React 19+
186
+ - Next.js 15+ for `@heroui/agent/next`
187
+ - Chrome/Edge 120+, Firefox 121+, Safari 17.2+
188
+ - ESM only
189
+
190
+ This SDK speaks protocol version `5`. The hosted API returns `426 Upgrade Required` when a beta SDK is no longer compatible.
191
+
192
+ ## Support
193
+
194
+ - [Documentation](https://heroui.pro/docs/agent)
195
+ - [Agents product](https://www.heroui.com/agents)
196
+ - [Issues](https://github.com/heroui-inc/heroui-platform/issues)
197
+ - [Discord](https://discord.gg/9b6yyZKmH4)
198
+
199
+ ## License
200
+
201
+ MIT — see [LICENSE](LICENSE).
202
+
203
+ ---
204
+
205
+ Built by [HeroUI](https://www.heroui.com)