@heroui/agent 0.2.0-beta.9 → 1.0.0-beta.10

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 (53) hide show
  1. package/CHANGELOG.md +125 -0
  2. package/README.md +196 -73
  3. package/dist/chunk-23EBJXRA.js +1 -0
  4. package/dist/chunk-5CSSZ76R.js +1 -0
  5. package/dist/chunk-AR424OVX.js +1 -0
  6. package/dist/chunk-FZXNXBTZ.js +1 -0
  7. package/dist/chunk-KFWXAD55.js +1 -0
  8. package/dist/chunk-MB3T5S5N.js +1 -0
  9. package/dist/client-tools-manifest-PCUOVUXR.js +1 -0
  10. package/dist/css/index.css +1 -2
  11. package/dist/index.d.ts +9 -643
  12. package/dist/index.js +1 -1
  13. package/dist/internal/host.d.ts +188 -0
  14. package/dist/internal/host.js +1 -0
  15. package/dist/internal/shared.d.ts +67 -0
  16. package/dist/internal/shared.js +1 -0
  17. package/dist/next.d.ts +3 -4
  18. package/dist/next.js +1 -1
  19. package/dist/persistence-YI6JSYCT.js +1 -0
  20. package/dist/server.d.ts +23 -2
  21. package/dist/server.js +1 -1
  22. package/dist/types-C3g7R0hr.d.ts +592 -0
  23. package/dist/version-LiwSi-9e.d.ts +5 -0
  24. package/dist/zod.d.ts +1 -0
  25. package/dist/zod.js +5 -0
  26. package/package.json +25 -36
  27. package/dist/chart-content-BBHQVMP4.js +0 -1
  28. package/dist/chunk-2XBFFSW2.js +0 -1
  29. package/dist/chunk-64RI74L5.js +0 -1
  30. package/dist/chunk-6ZJJN322.js +0 -1
  31. package/dist/chunk-7KCGPNEN.js +0 -1
  32. package/dist/chunk-BBB5EHDN.js +0 -5
  33. package/dist/chunk-CR3H7AVI.js +0 -1
  34. package/dist/chunk-HCLXS4HQ.js +0 -1
  35. package/dist/chunk-MXLGM4WV.js +0 -1
  36. package/dist/chunk-OA3TG5CS.js +0 -1
  37. package/dist/chunk-PZJ4NC3J.js +0 -1
  38. package/dist/chunk-RNNGE7KM.js +0 -1
  39. package/dist/chunk-S6OIAJSC.js +0 -1
  40. package/dist/chunk-SUDHJNTJ.js +0 -2
  41. package/dist/chunk-WUAFMD7Z.js +0 -2
  42. package/dist/component-renderer-GG6JVRUG.js +0 -1
  43. package/dist/composer-draft-NSKK65F3.js +0 -1
  44. package/dist/composer-image-draft-KAGTNQR7.js +0 -1
  45. package/dist/contracts.d.ts +0 -1384
  46. package/dist/contracts.js +0 -2
  47. package/dist/embed-runtime-GYXK7V6N.js +0 -5
  48. package/dist/identity-3P8-17km.d.ts +0 -95
  49. package/dist/interactive-map-surface-WC2LPCR7.js +0 -1
  50. package/dist/internal/client-tools.js +0 -1
  51. package/dist/internal/models.js +0 -1
  52. package/dist/internal/runtime.js +0 -1
  53. package/dist/internal/theme.js +0 -1
package/dist/index.d.ts CHANGED
@@ -1,648 +1,14 @@
1
- import { ComponentType, ReactNode, CSSProperties } from 'react';
2
- import * as react_jsx_runtime from 'react/jsx-runtime';
3
- import { z } from 'zod';
4
- import { AnimateOptions, CustomRenderer, CustomRendererProps } from 'streamdown';
1
+ import { U as HeroUIAgentProps, i as AgentController } from './types-C3g7R0hr.js';
2
+ export { A as AgentApiOverrides, a as AgentAppearance, b as AgentAttachmentContentType, c as AgentAuthToken, d as AgentCapabilities, e as AgentColorScheme, f as AgentComponentExportFormat, g as AgentComposerOptions, h as AgentContext, j as AgentDataSource, k as AgentDataSourceFormat, l as AgentDesignTheme, m as AgentError, n as AgentFeedbackReason, o as AgentLauncherOptions, p as AgentLauncherPosition, q as AgentMarkdownAnimation, r as AgentMarkdownAnimationOptions, s as AgentMarkdownCaret, t as AgentMarkdownOptions, u as AgentMessageAction, v as AgentModelId, w as AgentPanelOptions, x as AgentPermissionMode, y as AgentPermissionOptions, z as AgentRadius, B as AgentResponseFeedback, C as AgentSharedContext, D as AgentShouldCloseOnInteractOutside, E as AgentStartScreenOptions, F as AgentStatus, G as AgentSurfaceVariant, H as AgentThemeColor, I as AgentThemeColors, J as AgentThemeOptions, K as AgentTypography, L as AgentViewMode, M as ClientTool, N as ClientToolExecutionContext, O as ClientToolIcon, P as ClientToolStatus, Q as ClientToolVisualResult, R as DEFAULT_MARKDOWN_ANIMATION, S as GetAuthToken, T as GetAuthTokenContext, V as UploadAgentDataSourceInput, W as createToolHelper } from './types-C3g7R0hr.js';
3
+ export { H as HEROUI_AGENT_API_BASE_URL, a as HEROUI_AGENT_SDK_VERSION } from './version-LiwSi-9e.js';
4
+ import 'react';
5
5
 
6
- /**
7
- * Deliberately Zod-free: `createToolHelper` and these types are re-exported from
8
- * the package root, which the panel shell is served from. The manifest
9
- * serializer that does need Zod lives in `./client-tools-manifest`.
10
- */
11
- type ClientToolStatus = "input-streaming" | "approval-requested" | "executing" | "completed" | "rejected" | "error";
12
- type ClientToolIconProps = {
13
- color?: string;
14
- size?: number | string;
15
- stroke?: number | string;
16
- };
17
- type ClientToolRenderProps<TArgs = unknown> = {
18
- /** Arguments the agent passed to the tool (typed when using Zod). */
19
- args: TArgs;
20
- /** Error message, present when `status === "error"`. */
21
- error?: string;
22
- /** Approve the call. Present when `status === "approval-requested"`. */
23
- onApprove?: () => void;
24
- /** Reject the call. Present when `status === "approval-requested"`. */
25
- onReject?: () => void;
26
- /** Return value of `execute`, present when `status === "completed"`. */
27
- result?: unknown;
28
- status: ClientToolStatus;
29
- };
30
- type ClientToolSchema<TArgs> = {
31
- parse: (input: unknown) => TArgs;
32
- safeParse: (input: unknown) => unknown;
33
- };
34
- /**
35
- * Stable identity for one agent-initiated browser tool effect. Pass
36
- * `idempotencyKey` through to mutation APIs so an ambiguous network retry can
37
- * return the original result instead of applying the side effect twice.
38
- */
39
- type ClientToolExecutionContext = Readonly<{
40
- conversationId: string;
41
- idempotencyKey: string;
42
- toolCallId: string;
43
- }>;
44
- /**
45
- * A tool the agent can call in the user's browser. Execution and rendering
46
- * never leave the page — only the name, description, schema, and approval
47
- * flag are shared with the hosted agent.
48
- */
49
- type ClientTool<TArgs = any, TContext = any> = {
50
- description: string;
51
- /** Human-readable name shown in the default tool card. Defaults to `name`. */
52
- displayName?: string;
53
- execute: (args: TArgs, context: TContext, execution: ClientToolExecutionContext) => Promise<unknown> | unknown;
54
- /** Icon component for the default tool card ({size, color, stroke} props). */
55
- icon?: ComponentType<ClientToolIconProps>;
56
- iconColor?: string;
57
- name: string;
58
- /** When true, the user must approve the call before `execute` runs. */
59
- needsApproval?: boolean;
60
- /** Zod schema (typed) or raw JSON Schema object for the tool parameters. */
61
- parameters: ClientToolSchema<TArgs> | Record<string, unknown>;
62
- /**
63
- * Replace the default tool card. Return `null` for any status to fall back
64
- * to the default card for that state.
65
- */
66
- render?: (props: ClientToolRenderProps<TArgs>) => ReactNode;
67
- };
68
- /**
69
- * Returns a type-safe tool factory bound to your shared context type:
70
- *
71
- * ```ts
72
- * type AppContext = {apiClient: ApiClient};
73
- * const tool = createToolHelper<AppContext>();
74
- * const tools = [tool({name: "search_users", parameters: z.object({...}), execute: (args, ctx) => ...})];
75
- * ```
76
- */
77
- declare function createToolHelper<TContext>(): <TArgs>(definition: ClientTool<TArgs, TContext>) => ClientTool<TArgs, TContext>;
78
-
79
- type MessageActionKind = "copy" | "feedback" | "retry";
80
- type MessageFeedbackReason = "did_not_follow_instructions" | "incomplete" | "incorrect" | "not_relevant" | "other" | "unclear";
81
-
82
- /** How browser client-tool calls are approved before they execute. */
83
- type AgentPermissionMode$1 = "ask" | "auto" | "full";
84
-
85
- /**
86
- * File types that the hosted model pipeline can process consistently.
87
- *
88
- * SVG and office/archive formats are intentionally excluded: SVG can carry
89
- * active content, while provider support for zipped document formats varies.
90
- */
91
- declare const HEROUI_AGENT_ATTACHMENT_EXTENSION_BY_CONTENT_TYPE: {
92
- readonly "application/json": "json";
93
- readonly "application/pdf": "pdf";
94
- readonly "image/gif": "gif";
95
- readonly "image/jpeg": "jpg";
96
- readonly "image/png": "png";
97
- readonly "image/webp": "webp";
98
- readonly "text/csv": "csv";
99
- readonly "text/markdown": "md";
100
- readonly "text/plain": "txt";
101
- readonly "text/tab-separated-values": "tsv";
102
- };
103
- type HeroUIAgentAttachmentContentType = keyof typeof HEROUI_AGENT_ATTACHMENT_EXTENSION_BY_CONTENT_TYPE;
104
-
105
- declare const agentThemeSchema: z.ZodEnum<{
106
- dark: "dark";
107
- light: "light";
108
- system: "system";
109
- }>;
110
- type AgentTheme = z.infer<typeof agentThemeSchema>;
111
-
112
- /** Browser event emitted when protocol-v6 runtime latency checkpoints arrive. */
113
- declare const HEROUI_AGENT_RUNTIME_TIMING_EVENT: "heroui-agent:runtime-timing";
114
- type AgentActivityPhase = "accepted" | "preparing" | "generating" | "waiting-client-tool" | "running-server-tool" | "recovering";
115
- type AgentRuntimeTiming = {
116
- completedAt?: number;
117
- firstSemanticTextAt?: number;
118
- providerFirstEventAt?: number;
119
- providerRequestedAt?: number;
120
- runtimeAdmittedAt?: number;
121
- turnId?: string;
122
- };
123
- type AgentRuntimeTimingEventDetail = AgentRuntimeTiming & {
124
- agentId: string;
125
- conversationId: string;
126
- };
127
-
128
- /**
129
- * Deliberately Zod-free: the model catalogue is re-exported from the package
130
- * root, so importing Zod here would pull the whole validation library into the
131
- * panel shell's first-paint graph. The matching schema lives in
132
- * `./models.schema`, which only server and contract consumers need.
133
- */
134
- /** Model ids the hosted agent accepts from the browser picker. */
135
- declare const AGENT_MODEL_IDS: readonly ["moonshotai/Kimi-K3", "openai/gpt-5.6-luna", "openai/gpt-5.6-terra", "openai/gpt-5.6-sol", "google/gemini-3.6-flash", "anthropic/claude-sonnet-5", "anthropic/claude-opus-4.8"];
136
- type AgentModelId = (typeof AGENT_MODEL_IDS)[number];
137
- /**
138
- * Retired ids mapped to their replacement. Model ids are a public part of the
139
- * embed API — a customer pins one in their own code and projects store one as
140
- * their default — so a retired id keeps resolving instead of failing the
141
- * session with an "Invalid agent model" error.
142
- */
143
- declare const LEGACY_AGENT_MODEL_IDS: Record<string, AgentModelId>;
144
- /** Resolves a possibly-retired model id to the id the runtime should use. */
145
- declare function resolveAgentModelId(value: string): string;
146
- type AgentModelTier = "codegen" | "complex" | "light";
147
- type AgentModelOption = {
148
- description: string;
149
- id: AgentModelId;
150
- label: string;
151
- provider: "Anthropic" | "Google" | "Moonshot AI" | "OpenAI";
152
- tier: AgentModelTier;
153
- };
154
- /**
155
- * Recommended default selected when the optional picker first opens. Luna
156
- * matches the hosted runtime's baked-in default (`DEFAULT_CHAT_MODEL_IDS.herouiAgent`),
157
- * so what users see in the picker is what actually runs by default.
158
- */
159
- declare const DEFAULT_AGENT_PICKER_MODEL_ID = "openai/gpt-5.6-luna";
160
- /**
161
- * Small, tool-capable model catalog for HeroUI Agent. These ids are the
162
- * server-side allowlist as well as the browser picker source of truth.
163
- */
164
- declare const AGENT_MODEL_OPTIONS: readonly [{
165
- readonly description: "Flagship model for coding, reasoning, and knowledge work";
166
- readonly id: "moonshotai/Kimi-K3";
167
- readonly label: "Kimi K3";
168
- readonly provider: "Moonshot AI";
169
- readonly tier: "light";
170
- }, {
171
- readonly description: "Fast answers and lightweight agent workflows";
172
- readonly id: "openai/gpt-5.6-luna";
173
- readonly label: "GPT-5.6 Luna";
174
- readonly provider: "OpenAI";
175
- readonly tier: "light";
176
- }, {
177
- readonly description: "Balanced reasoning for everyday agent tasks";
178
- readonly id: "openai/gpt-5.6-terra";
179
- readonly label: "GPT-5.6 Terra";
180
- readonly provider: "OpenAI";
181
- readonly tier: "codegen";
182
- }, {
183
- readonly description: "Deep reasoning for complex, multi-step analysis";
184
- readonly id: "openai/gpt-5.6-sol";
185
- readonly label: "GPT-5.6 Sol";
186
- readonly provider: "OpenAI";
187
- readonly tier: "complex";
188
- }, {
189
- readonly description: "Fast multimodal analysis with a large context window";
190
- readonly id: "google/gemini-3.6-flash";
191
- readonly label: "Gemini 3.6 Flash";
192
- readonly provider: "Google";
193
- readonly tier: "light";
194
- }, {
195
- readonly description: "Strong agentic reasoning and polished UI decisions";
196
- readonly id: "anthropic/claude-sonnet-5";
197
- readonly label: "Claude Sonnet 5";
198
- readonly provider: "Anthropic";
199
- readonly tier: "codegen";
200
- }, {
201
- readonly description: "Highest-capability Claude for difficult research and analysis";
202
- readonly id: "anthropic/claude-opus-4.8";
203
- readonly label: "Claude Opus 4.8";
204
- readonly provider: "Anthropic";
205
- readonly tier: "complex";
206
- }];
207
- declare function isAgentModelId(value: unknown): value is AgentModelId;
208
- /** Unknown/env-overridden models keep the hosted agent's historical light tier. */
209
- declare function getAgentModelTier(modelId?: string): AgentModelTier;
210
-
211
- /**
212
- * Light/dark color scheme selection for the embed. `"system"` follows the
213
- * OS preference and updates live when it changes.
214
- */
215
- type AgentColorScheme = AgentTheme;
216
- /**
217
- * A theme color value: one CSS color applied to both schemes, or separate
218
- * values per scheme. Tokens left unset fall back to the built-in defaults of
219
- * each scheme, so overriding a light color never degrades dark mode.
220
- */
221
- type AgentThemeColor = string | {
222
- dark?: string;
223
- light?: string;
224
- };
225
- /** Corner rounding preset applied across the embed surface and fields. */
226
- type AgentRadius = "pill" | "round" | "sharp" | "soft";
227
- /**
228
- * The seven high-impact color tokens. Everything else in the embed
229
- * (borders, shadows, chart palettes) derives from these and from the
230
- * built-in scheme defaults.
231
- */
232
- type AgentThemeColors = {
233
- /** Primary action and highlight color. Chart palettes derive from it. */
234
- accent?: AgentThemeColor;
235
- /** Chat panel background. */
236
- background?: AgentThemeColor;
237
- /** Primary text color. */
238
- foreground?: AgentThemeColor;
239
- /** Dropdown and popover surface color. */
240
- overlay?: AgentThemeColor;
241
- /** Card surface color. */
242
- surface?: AgentThemeColor;
243
- /** Secondary surface color (chips, muted fills). */
244
- surfaceSecondary?: AgentThemeColor;
245
- /** Tooltip surface color. Text contrast is derived automatically. */
246
- tooltip?: AgentThemeColor;
247
- };
248
- type AgentTypography = {
249
- /**
250
- * Base font size in pixels (clamped to 12–18).
251
- * @default 14
252
- */
253
- baseSize?: number;
254
- /** CSS font family stack, e.g. `"Geist, sans-serif"`. */
255
- fontFamily?: string;
256
- };
257
- /**
258
- * HeroUI Pro theme variant applied to the agent surface.
259
- *
260
- * Anything other than `"base"` also needs its stylesheet loaded once, from the
261
- * licensed Pro package: `import "@heroui-pro/react/agent-themes/glass"`.
262
- */
263
- type AgentDesignTheme = "base" | "brutalism" | "glass" | "mouve";
264
- declare const AGENT_DESIGN_THEMES: readonly AgentDesignTheme[];
265
- /**
266
- * Intentionally small theme surface: one color scheme, one Pro variant, four
267
- * radius presets, seven color tokens, and basic typography. No named themes,
268
- * extend chains, or per-component tokens.
269
- */
270
- type AgentThemeOptions = {
271
- /** @default "system" */
272
- colorScheme?: AgentColorScheme;
273
- colors?: AgentThemeColors;
274
- /**
275
- * HeroUI Pro theme variant. Requires the matching stylesheet import.
276
- * @default "base"
277
- */
278
- designTheme?: AgentDesignTheme;
279
- /** @default "round" */
280
- radius?: AgentRadius;
281
- typography?: AgentTypography;
282
- };
283
-
284
- type AgentComponentExportFormat = "csv" | "png" | "svg";
285
- type AgentPermissionMode = AgentPermissionMode$1;
286
- /** MIME type accepted by the hosted HeroUI Agent attachment pipeline. */
287
- type AgentAttachmentContentType = HeroUIAgentAttachmentContentType;
288
- type AgentMessageAction = MessageActionKind;
289
- type AgentFeedbackReason = MessageFeedbackReason;
290
- type AgentResponseFeedback = {
291
- /** Optional free-form context supplied by the end user. */
292
- comment?: string;
293
- conversationId: string;
294
- messageId: string;
295
- rating: "negative" | "positive";
296
- /** Structured reasons selected for negative feedback. Empty for positive feedback. */
297
- reasons: AgentFeedbackReason[];
298
- };
299
- type AgentContext = Record<string, unknown>;
300
- /**
301
- * The single shared context object. It is passed as the second argument to
302
- * every client tool's `execute` — API clients, user info, state setters.
303
- * Anything goes; it never leaves the browser.
304
- *
305
- * One key is reserved: `page`. When present, the SDK calls it on every turn
306
- * and sends its JSON-serializable return value (route, filters, selection —
307
- * max 16KB) to the agent as page context. Nothing else in the context object
308
- * ever crosses the wire.
309
- */
310
- type AgentSharedContext = {
311
- page?: () => AgentContext | Promise<AgentContext>;
312
- } & Record<string, unknown>;
313
- type AgentViewMode = "floating" | "sidebar";
314
- type AgentMarkdownAnimation = boolean | AnimateOptions;
315
- type AgentMarkdownCaret = "block" | "circle";
316
- type AgentMarkdownRenderer = CustomRenderer;
317
- type AgentMarkdownRendererProps = CustomRendererProps;
318
- type AgentMarkdownPlugins = {
319
- /** Custom renderers selected by fenced-code language. */
320
- renderers?: AgentMarkdownRenderer[];
321
- };
322
- /** Streaming Markdown presentation and custom fenced-code renderers. */
323
- type AgentMarkdownOptions = {
324
- /**
325
- * Animate newly streamed content. Pass `false` to disable text animation.
326
- * @default {animation: "fadeIn", duration: 160, easing: "ease-out", sep: "word", stagger: 18}
327
- */
328
- animated?: AgentMarkdownAnimation;
329
- /** Streaming caret style. Pass `false` to hide it. @default "block" */
330
- caret?: AgentMarkdownCaret | false;
331
- /** Custom fenced-code renderers. */
332
- plugins?: AgentMarkdownPlugins;
333
- };
334
- /** Corner that anchors the launcher button and the floating panel. */
335
- type AgentLauncherPosition = "bottom-left" | "bottom-right";
336
- /** Placement of the floating launcher button (visibility is `showLauncher`). */
337
- type AgentLauncherOptions = {
338
- /**
339
- * Fill of the launcher button. Defaults to the accent color; set it when a
340
- * custom {@link icon} needs a different backdrop. The mark inside gets a
341
- * contrasting foreground automatically.
342
- */
343
- background?: AgentThemeColor;
344
- /**
345
- * Image rendered inside the launcher button instead of the built-in spark
346
- * mark. Use a square asset (70x70 or larger); it is scaled to fit.
347
- */
348
- icon?: string;
349
- /**
350
- * Pixel offsets from the anchored corner: `x` from the side edge, `y` from
351
- * the bottom. Defaults to 24 (16 on small screens).
352
- */
353
- offset?: {
354
- x?: number;
355
- y?: number;
356
- };
357
- /** @default "bottom-right" */
358
- position?: AgentLauncherPosition;
359
- /**
360
- * Escape hatch for launcher styling the options above do not cover, applied
361
- * as inline styles on the button (so it wins over the stylesheet). Prefer the
362
- * dedicated options where they exist; this is not covered by the embed's
363
- * visual defaults and can break the button's layout.
364
- */
365
- style?: CSSProperties;
366
- };
367
- /** Optional hosted-agent capabilities, all off by default. */
368
- type AgentCapabilities = {
369
- /**
370
- * Allow the hosted agent to search for images via web search. Only applies
371
- * when {@link webSearch} is enabled; defaults to true in that case.
372
- * @default true
373
- */
374
- imageSearch?: boolean;
375
- /**
376
- * Allow the hosted agent to include recent news results in web searches.
377
- * Only applies when {@link webSearch} is enabled and is off by default.
378
- * @default false
379
- */
380
- newsSearch?: boolean;
381
- /**
382
- * Allow the hosted agent to search the public web for current information
383
- * and images. Results are untrusted external content; keep this off when the
384
- * assistant should only ever answer from your declared client tools.
385
- * @default false
386
- */
387
- webSearch?: boolean;
388
- };
389
- /** Browser client-tool approval policy. */
390
- type AgentPermissionOptions = {
391
- /**
392
- * Permission mode used before an end user chooses another mode.
393
- * `"ask"` gates every client tool, `"auto"` gates only tools marked
394
- * `needsApproval`, and `"full"` runs client tools without prompting.
395
- * @default "auto"
396
- */
397
- defaultMode?: AgentPermissionMode;
398
- /**
399
- * Show the permission picker in the composer, letting the end user switch
400
- * modes for themselves.
401
- *
402
- * This is a privilege boundary, not just a control: it permits the end user
403
- * to select `"full"` and run every client tool without approval, overriding
404
- * {@link defaultMode}. Their choice persists for the conversation.
405
- *
406
- * The picker only renders when {@link HeroUIAgentProps.tools} is non-empty,
407
- * since there is nothing to approve otherwise.
408
- * @default false
409
- */
410
- showPicker?: boolean;
411
- };
412
- /**
413
- * Size and expansion of the chat panel. In `floating` mode expansion grows the
414
- * card; in `sidebar` mode it temporarily fills the viewport. Initial dimensions
415
- * are ignored in `sidebar` mode and below the mobile breakpoint.
416
- */
417
- type AgentPanelOptions = {
418
- /**
419
- * Open the panel expanded. End users can still collapse it unless
420
- * {@link expandable} is off.
421
- * @default false
422
- */
423
- expanded?: boolean;
424
- /**
425
- * Offer the expand control in the panel header. In sidebar mode the expanded
426
- * panel fills the viewport. Turn it off to pin the panel to one size.
427
- * @default true
428
- */
429
- expandable?: boolean;
430
- /**
431
- * Panel height before expanding — a number in pixels or any CSS length.
432
- * Capped to the viewport.
433
- * @default "max(420px, 56dvh)"
434
- */
435
- initialHeight?: number | string;
436
- /**
437
- * Panel width before expanding — a number in pixels or any CSS length.
438
- * Expanding widens the panel from here. Capped to the viewport.
439
- * @default 440
440
- */
441
- initialWidth?: number | string;
442
- };
443
- /** Visual presentation: view mode, theme, panel size, and launcher placement. */
444
- type AgentAppearance = {
445
- /** Where the launcher button (and the floating panel) is anchored. */
446
- launcher?: AgentLauncherOptions;
447
- /** Size and expansion of the floating panel. */
448
- panel?: AgentPanelOptions;
449
- theme?: AgentThemeOptions;
450
- /**
451
- * How the chat opens: `"floating"` (default) is a floating rounded panel in
452
- * the corner; `"sidebar"` docks full-height to the right edge of the page.
453
- */
454
- viewMode?: AgentViewMode;
455
- };
456
- /** Message composer settings. */
457
- type AgentComposerOptions = {
458
- /**
459
- * File types end users can attach. Omit to allow every supported type, pass
460
- * a subset to narrow the picker, or pass `false` to remove attachments.
461
- * @default all supported attachment types
462
- */
463
- attachments?: AgentAttachmentContentType[] | false;
464
- /**
465
- * Model used for new turns before an end user chooses another model.
466
- * When the picker is disabled, this pins every turn to the configured model.
467
- */
468
- defaultModel?: AgentModelId;
469
- /** Show microphone recording and voice transcription controls. @default true */
470
- dictation?: boolean;
471
- /**
472
- * Small verification notice shown below the composer and above the HeroUI
473
- * attribution. Supports `[label](example.com)` and HTTPS links; bare domains
474
- * are normalized to HTTPS. Limited to 240 characters. Pass `false` or omit it
475
- * to hide the notice.
476
- * @default false
477
- * @example "Agent may make mistakes. [View terms](https://example.com/terms)"
478
- */
479
- disclaimer?: string | false;
480
- /** Let the end user choose from the hosted agent's allowlisted models. @default false */
481
- modelPicker?: boolean;
482
- /** Placeholder shown in the message composer. @default "Ask anything…" */
483
- placeholder?: string;
484
- };
485
- /** The empty-conversation view shown before the first message. */
486
- type AgentStartScreenOptions = {
487
- /** Heading shown above the composer. @default "Ask about your data" */
488
- greeting?: string;
489
- /** Show and enable `Ctrl+1`…`Ctrl+5` shortcuts for the visible prompts. @default false */
490
- promptShortcuts?: boolean;
491
- /** Up to five suggested prompts (each max 160 characters). */
492
- prompts?: string[];
493
- };
494
- /** Internal — for HeroUI platform development only. */
495
- type AgentApiOverrides = {
496
- baseUrl?: string;
497
- };
498
- /**
499
- * Short-lived browser credential returned by the customer's server.
500
- *
501
- * Declared here rather than re-exported from `@heroui/agent-client`: that
502
- * package is bundled into this one, so a re-export would leave a dangling
503
- * reference in the published typings. The two declarations are structurally
504
- * identical, which is what lets the session manager accept this callback.
505
- */
506
- type AgentAuthToken = {
507
- expiresAt: number;
508
- token: string;
509
- };
510
- /** Context supplied whenever the SDK needs a fresh browser credential. */
511
- type GetAuthTokenContext = {
512
- anonymousId: string;
513
- agentId: string;
514
- };
515
- type GetAuthToken = (context: GetAuthTokenContext) => Promise<AgentAuthToken>;
516
- type HeroUIAgentProps = {
517
- /** Internal — for HeroUI platform development only. */
518
- _api?: AgentApiOverrides;
519
- appearance?: AgentAppearance;
520
- capabilities?: AgentCapabilities;
521
- /** Component export formats to show. Pass `false` to hide export and copy controls. */
522
- componentExports?: AgentComponentExportFormat[] | false;
523
- composer?: AgentComposerOptions;
524
- /**
525
- * Shared context for client tools; its reserved `page` key supplies the
526
- * page context sent to the agent. See {@link AgentSharedContext}.
527
- */
528
- context?: AgentSharedContext;
529
- /**
530
- * Fetches a short-lived browser credential from the host application's
531
- * server. Never expose a HeroUI Agent API key in browser code.
532
- */
533
- getAuthToken: GetAuthToken;
534
- /** Streaming Markdown animation, caret, and custom fenced-code renderers. */
535
- markdown?: AgentMarkdownOptions;
536
- /**
537
- * Receives end-user ratings for assistant responses. Negative ratings can
538
- * include structured reasons and an optional comment from the feedback popover.
539
- */
540
- onFeedback?: (feedback: AgentResponseFeedback) => Promise<void> | void;
541
- /**
542
- * Fires whenever project configuration and the complete composer are ready
543
- * for the current conversation. Use `useAgent().ready` when a custom launcher
544
- * also needs the status reactively.
545
- */
546
- onReady?: () => void;
547
- /** Client-tool approval defaults and optional end-user picker. */
548
- permissions?: AgentPermissionOptions;
549
- /**
550
- * Warm the agent before the visitor touches it: fetch the chat engine,
551
- * configuration, and credentials, then bootstrap and preconnect the runtime
552
- * while the panel is still closed. Work starts immediately and in parallel
553
- * so readiness follows the launcher as quickly as possible. Opening before
554
- * then shows the Agent shell with a loading state.
555
- *
556
- * Set to `false` to request nothing until the panel is opened. Worth doing
557
- * when most visitors never open the agent, or on pages where you want to
558
- * choose the moment yourself — `useAgent().preload()` runs the same warm-up
559
- * on your signal.
560
- * @default true
561
- */
562
- preload?: boolean;
563
- agentId: string;
564
- /**
565
- * Reopen the panel after a page refresh when it was open before the refresh.
566
- * The restored panel always starts a new chat instead of resuming the
567
- * previously active conversation.
568
- * @default false
569
- */
570
- reopenOnRefresh?: boolean;
571
- /**
572
- * Open the panel on the start screen instead of restoring the most recently
573
- * active conversation. Conversation history remains available in the picker.
574
- * @default false
575
- */
576
- startNewConversationOnOpen?: boolean;
577
- /**
578
- * Apply the appearance saved for this project in the HeroUI dashboard —
579
- * launcher icon, colors, typography, greeting, and suggested prompts —
580
- * without redeploying.
581
- *
582
- * Anything passed in code wins, field by field, so this only fills in what
583
- * you left unset. Pass `false` to ignore the dashboard entirely and
584
- * configure the embed exclusively from props.
585
- * @default true
586
- */
587
- remoteConfig?: boolean;
588
- /**
589
- * Per-message actions shown under assistant responses: `"copy"` copies the
590
- * response text, `"feedback"` shows thumbs up/down, `"retry"` regenerates
591
- * the last response. Pass `false` to hide all actions.
592
- * @default ["copy", "feedback", "retry"]
593
- */
594
- responseActions?: AgentMessageAction[] | false;
595
- /**
596
- * Show the floating launcher button when the panel is closed. Set to
597
- * `false` when opening the agent exclusively through `useAgent()`.
598
- * @default true
599
- */
600
- showLauncher?: boolean;
601
- startScreen?: AgentStartScreenOptions;
602
- /**
603
- * Client tools the agent can call in the user's browser. Define with
604
- * `createToolHelper<Context>()` for typed args and context.
605
- */
606
- tools?: ClientTool[];
607
- };
608
- type AgentController = {
609
- hide: () => void;
610
- /** Start a fresh conversation, optionally submitting its first prompt immediately. */
611
- newConversation: (prompt?: string) => void;
612
- /**
613
- * Warm the agent now, without opening it — the same work the `preload` prop
614
- * does on its own. Pair it with `preload={false}` to pick the moment from
615
- * your own signal: a pricing page, a scroll depth, a form the visitor is
616
- * struggling with. Cheap to call repeatedly; the work happens once.
617
- */
618
- preload: () => void;
619
- /** Whether project configuration and the complete composer are ready to open. */
620
- ready: boolean;
621
- refreshAuth: () => void;
622
- show: () => void;
623
- shutdown: () => void;
624
- toggle: () => void;
625
- };
626
-
627
- /**
628
- * Imperative controls for the agent embed. Safe to call before
629
- * `<HeroUIAgent />` mounts (calls are ignored with a console warning). Pass a
630
- * `agentId` when rendering more than one agent on the same page.
631
- */
6
+ /** Imperative controls for the hosted iframe Agent. */
632
7
  declare function useAgent(agentId?: string): AgentController;
633
8
  /**
634
- * One-line agent embed:
635
- *
636
- * ```tsx
637
- * <body>
638
- * {children}
639
- * <HeroUIAgent getAuthToken={getAuthToken} agentId={process.env.NEXT_PUBLIC_HEROUI_AGENT_ID!} />
640
- * </body>
641
- * ```
642
- *
643
- * Renders nothing in the tree; the launcher and chat panel mount into an
644
- * independent React root on `document.body`.
9
+ * Mounts the lightweight customer-page bridge. All visible Agent UI is owned
10
+ * by the cross-origin hosted iframe.
645
11
  */
646
- declare function HeroUIAgent(props: HeroUIAgentProps): react_jsx_runtime.JSX.Element;
12
+ declare function HeroUIAgent<TContext extends object = Record<string, unknown>>(props: HeroUIAgentProps<TContext>): null;
647
13
 
648
- export { AGENT_DESIGN_THEMES, AGENT_MODEL_IDS, AGENT_MODEL_OPTIONS, type AgentActivityPhase, type AgentApiOverrides, type AgentAppearance, type AgentAttachmentContentType, type AgentAuthToken, type AgentCapabilities, type AgentColorScheme, type AgentComponentExportFormat, type AgentComposerOptions, type AgentContext, type AgentController, type AgentDesignTheme, type AgentFeedbackReason, type AgentLauncherOptions, type AgentLauncherPosition, type AgentMarkdownAnimation, type AgentMarkdownCaret, type AgentMarkdownOptions, type AgentMarkdownPlugins, type AgentMarkdownRenderer, type AgentMarkdownRendererProps, type AgentMessageAction, type AgentModelId, type AgentModelOption, type AgentModelTier, type AgentPanelOptions, type AgentPermissionMode, type AgentPermissionOptions, type AgentRadius, type AgentResponseFeedback, type AgentRuntimeTiming, type AgentRuntimeTimingEventDetail, type AgentSharedContext, type AgentStartScreenOptions, type AgentThemeColor, type AgentThemeColors, type AgentThemeOptions, type AgentTypography, type AgentViewMode, type ClientTool, type ClientToolExecutionContext, type ClientToolIconProps, type ClientToolRenderProps, type ClientToolStatus, DEFAULT_AGENT_PICKER_MODEL_ID, type GetAuthToken, type GetAuthTokenContext, HEROUI_AGENT_RUNTIME_TIMING_EVENT, HeroUIAgent, type HeroUIAgentProps, LEGACY_AGENT_MODEL_IDS, createToolHelper, getAgentModelTier, isAgentModelId, resolveAgentModelId, useAgent };
14
+ export { AgentController, HeroUIAgent, HeroUIAgentProps, useAgent };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as m,b as a}from"./chunk-SUDHJNTJ.js";import"./chunk-WUAFMD7Z.js";import"./chunk-6ZJJN322.js";import{a as e}from"./chunk-64RI74L5.js";import{a as t,b as n,c as o,d as r,e as A,f as g,g as i}from"./chunk-OA3TG5CS.js";import{a as s}from"./chunk-7KCGPNEN.js";import{a as p}from"./chunk-2XBFFSW2.js";export{p as AGENT_DESIGN_THEMES,t as AGENT_MODEL_IDS,A as AGENT_MODEL_OPTIONS,r as DEFAULT_AGENT_PICKER_MODEL_ID,s as HEROUI_AGENT_RUNTIME_TIMING_EVENT,a as HeroUIAgent,n as LEGACY_AGENT_MODEL_IDS,e as createToolHelper,i as getAgentModelTier,g as isAgentModelId,o as resolveAgentModelId,m as useAgent};
1
+ import{a as d,b as e}from"./chunk-MB3T5S5N.js";import"./chunk-5CSSZ76R.js";import{a as f}from"./chunk-AR424OVX.js";import{a as b,b as c}from"./chunk-23EBJXRA.js";import{a}from"./chunk-FZXNXBTZ.js";export{f as DEFAULT_MARKDOWN_ANIMATION,c as HEROUI_AGENT_API_BASE_URL,b as HEROUI_AGENT_SDK_VERSION,e as HeroUIAgent,a as createToolHelper,d as useAgent};