@heroui/agent 0.2.0-beta.7 → 0.2.0-beta.9

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 (49) hide show
  1. package/CHANGELOG.md +20 -2
  2. package/README.md +15 -10
  3. package/dist/chart-content-BBHQVMP4.js +1 -0
  4. package/dist/chunk-2XBFFSW2.js +1 -0
  5. package/dist/chunk-64RI74L5.js +1 -0
  6. package/dist/chunk-6ZJJN322.js +1 -0
  7. package/dist/chunk-7KCGPNEN.js +1 -0
  8. package/dist/chunk-BBB5EHDN.js +5 -0
  9. package/dist/chunk-CR3H7AVI.js +1 -0
  10. package/dist/chunk-HCLXS4HQ.js +1 -0
  11. package/dist/chunk-MXLGM4WV.js +1 -0
  12. package/dist/chunk-OA3TG5CS.js +1 -0
  13. package/dist/chunk-PZJ4NC3J.js +1 -0
  14. package/dist/chunk-RNNGE7KM.js +1 -0
  15. package/dist/chunk-S6OIAJSC.js +1 -0
  16. package/dist/chunk-SUDHJNTJ.js +2 -0
  17. package/dist/chunk-WUAFMD7Z.js +2 -0
  18. package/dist/component-renderer-GG6JVRUG.js +1 -0
  19. package/dist/composer-draft-NSKK65F3.js +1 -0
  20. package/dist/composer-image-draft-KAGTNQR7.js +1 -0
  21. package/dist/contracts.d.ts +50 -19
  22. package/dist/contracts.js +2 -2545
  23. package/dist/css/index.css +1 -1
  24. package/dist/embed-runtime-GYXK7V6N.js +5 -0
  25. package/dist/identity-3P8-17km.d.ts +95 -0
  26. package/dist/index.d.ts +46 -10
  27. package/dist/index.js +1 -28
  28. package/dist/interactive-map-surface-WC2LPCR7.js +1 -0
  29. package/dist/internal/client-tools.js +1 -0
  30. package/dist/internal/models.js +1 -0
  31. package/dist/internal/runtime.js +1 -0
  32. package/dist/internal/theme.js +1 -0
  33. package/dist/next.d.ts +2 -1
  34. package/dist/next.js +1 -22
  35. package/dist/server.d.ts +1 -1
  36. package/dist/server.js +1 -260
  37. package/package.json +6 -6
  38. package/dist/chart-content-E4NPTUPR.js +0 -2696
  39. package/dist/chunk-3FG5NRTX.js +0 -9
  40. package/dist/chunk-6O3SFXJK.js +0 -325
  41. package/dist/chunk-FNGGMHVR.js +0 -625
  42. package/dist/chunk-OQGXZY5L.js +0 -1091
  43. package/dist/chunk-TOOT6SZ2.js +0 -74
  44. package/dist/chunk-V5S5FRGV.js +0 -984
  45. package/dist/chunk-VJA52U5P.js +0 -137
  46. package/dist/component-renderer-46EJDPTB.js +0 -10627
  47. package/dist/embed-runtime-UF7XJIFA.js +0 -7650
  48. package/dist/identity-Z6i6pL0F.d.ts +0 -166
  49. package/dist/interactive-map-surface-67KHT3VB.js +0 -362
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ComponentType, ReactNode, CSSProperties } from 'react';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
3
  import { z } from 'zod';
3
4
  import { AnimateOptions, CustomRenderer, CustomRendererProps } from 'streamdown';
4
5
 
@@ -30,6 +31,16 @@ type ClientToolSchema<TArgs> = {
30
31
  parse: (input: unknown) => TArgs;
31
32
  safeParse: (input: unknown) => unknown;
32
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
+ }>;
33
44
  /**
34
45
  * A tool the agent can call in the user's browser. Execution and rendering
35
46
  * never leave the page — only the name, description, schema, and approval
@@ -39,7 +50,7 @@ type ClientTool<TArgs = any, TContext = any> = {
39
50
  description: string;
40
51
  /** Human-readable name shown in the default tool card. Defaults to `name`. */
41
52
  displayName?: string;
42
- execute: (args: TArgs, context: TContext) => Promise<unknown> | unknown;
53
+ execute: (args: TArgs, context: TContext, execution: ClientToolExecutionContext) => Promise<unknown> | unknown;
43
54
  /** Icon component for the default tool card ({size, color, stroke} props). */
44
55
  icon?: ComponentType<ClientToolIconProps>;
45
56
  iconColor?: string;
@@ -98,6 +109,22 @@ declare const agentThemeSchema: z.ZodEnum<{
98
109
  }>;
99
110
  type AgentTheme = z.infer<typeof agentThemeSchema>;
100
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
+
101
128
  /**
102
129
  * Deliberately Zod-free: the model catalogue is re-exported from the package
103
130
  * root, so importing Zod here would pull the whole validation library into the
@@ -296,7 +323,7 @@ type AgentMarkdownPlugins = {
296
323
  type AgentMarkdownOptions = {
297
324
  /**
298
325
  * Animate newly streamed content. Pass `false` to disable text animation.
299
- * @default {animation: "blurIn", duration: 160, easing: "ease-out", sep: "word", stagger: 18}
326
+ * @default {animation: "fadeIn", duration: 160, easing: "ease-out", sep: "word", stagger: 18}
300
327
  */
301
328
  animated?: AgentMarkdownAnimation;
302
329
  /** Streaming caret style. Pass `false` to hide it. @default "block" */
@@ -511,14 +538,20 @@ type HeroUIAgentProps = {
511
538
  * include structured reasons and an optional comment from the feedback popover.
512
539
  */
513
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;
514
547
  /** Client-tool approval defaults and optional end-user picker. */
515
548
  permissions?: AgentPermissionOptions;
516
549
  /**
517
- * Warm the agent up before the visitor touches it: fetch the chat engine,
518
- * bootstrap the conversation, and boot the agent run all while the panel is
519
- * still closed, at the browser's idle priority so it never competes with your
520
- * page's own loading. The first open is then immediate instead of showing a
521
- * loading state.
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.
522
555
  *
523
556
  * Set to `false` to request nothing until the panel is opened. Worth doing
524
557
  * when most visitors never open the agent, or on pages where you want to
@@ -574,7 +607,8 @@ type HeroUIAgentProps = {
574
607
  };
575
608
  type AgentController = {
576
609
  hide: () => void;
577
- newConversation: () => void;
610
+ /** Start a fresh conversation, optionally submitting its first prompt immediately. */
611
+ newConversation: (prompt?: string) => void;
578
612
  /**
579
613
  * Warm the agent now, without opening it — the same work the `preload` prop
580
614
  * does on its own. Pair it with `preload={false}` to pick the moment from
@@ -582,6 +616,8 @@ type AgentController = {
582
616
  * struggling with. Cheap to call repeatedly; the work happens once.
583
617
  */
584
618
  preload: () => void;
619
+ /** Whether project configuration and the complete composer are ready to open. */
620
+ ready: boolean;
585
621
  refreshAuth: () => void;
586
622
  show: () => void;
587
623
  shutdown: () => void;
@@ -607,6 +643,6 @@ declare function useAgent(agentId?: string): AgentController;
607
643
  * Renders nothing in the tree; the launcher and chat panel mount into an
608
644
  * independent React root on `document.body`.
609
645
  */
610
- declare function HeroUIAgent(props: HeroUIAgentProps): null;
646
+ declare function HeroUIAgent(props: HeroUIAgentProps): react_jsx_runtime.JSX.Element;
611
647
 
612
- export { AGENT_DESIGN_THEMES, AGENT_MODEL_IDS, AGENT_MODEL_OPTIONS, 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 AgentSharedContext, type AgentStartScreenOptions, type AgentThemeColor, type AgentThemeColors, type AgentThemeOptions, type AgentTypography, type AgentViewMode, type ClientTool, type ClientToolIconProps, type ClientToolRenderProps, type ClientToolStatus, DEFAULT_AGENT_PICKER_MODEL_ID, type GetAuthToken, type GetAuthTokenContext, HeroUIAgent, type HeroUIAgentProps, LEGACY_AGENT_MODEL_IDS, createToolHelper, getAgentModelTier, isAgentModelId, resolveAgentModelId, useAgent };
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 };
package/dist/index.js CHANGED
@@ -1,28 +1 @@
1
- import {
2
- HeroUIAgent,
3
- useAgent
4
- } from "./chunk-V5S5FRGV.js";
5
- import {
6
- AGENT_DESIGN_THEMES,
7
- AGENT_MODEL_IDS,
8
- AGENT_MODEL_OPTIONS,
9
- DEFAULT_AGENT_PICKER_MODEL_ID,
10
- LEGACY_AGENT_MODEL_IDS,
11
- createToolHelper,
12
- getAgentModelTier,
13
- isAgentModelId,
14
- resolveAgentModelId
15
- } from "./chunk-OQGXZY5L.js";
16
- export {
17
- AGENT_DESIGN_THEMES,
18
- AGENT_MODEL_IDS,
19
- AGENT_MODEL_OPTIONS,
20
- DEFAULT_AGENT_PICKER_MODEL_ID,
21
- HeroUIAgent,
22
- LEGACY_AGENT_MODEL_IDS,
23
- createToolHelper,
24
- getAgentModelTier,
25
- isAgentModelId,
26
- resolveAgentModelId,
27
- useAgent
28
- };
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};
@@ -0,0 +1 @@
1
+ "use client";import{a as V,b as x}from"./chunk-HCLXS4HQ.js";import{a as G}from"./chunk-CR3H7AVI.js";import{StarFill as ee}from"@gravity-ui/icons";import Z from"maplibre-gl";import{createContext as D,useCallback as H,useContext as $,useEffect as h,useRef as g,useState as k}from"react";import{createPortal as A}from"react-dom";import{jsx as n,jsxs as y}from"react/jsx-runtime";var _=D(null);function O(){if(!(typeof document>"u")){if(document.documentElement.classList.contains("dark")||document.documentElement.dataset.theme==="dark")return"dark";if(document.documentElement.classList.contains("light")||document.documentElement.dataset.theme==="light")return"light"}}function j(e){let a=e?.closest("[data-theme]")?.dataset.theme;return a==="dark"||a==="light"?a:void 0}function B(){return typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Q(e){let[r,a]=k(()=>O()??B());return h(()=>{let s=e.current?.closest("[data-theme]"),c=()=>a(j(e.current)??O()??B()),t=new MutationObserver(c),m=window.matchMedia("(prefers-color-scheme: dark)");return c(),t.observe(document.documentElement,{attributeFilter:["class","data-theme"],attributes:!0}),s&&s!==document.documentElement&&t.observe(s,{attributeFilter:["data-theme"],attributes:!0}),m.addEventListener("change",c),()=>{t.disconnect(),m.removeEventListener("change",c)}},[e]),r}function X({center:e,children:r,className:a,padding:s,styles:c,zoom:t,...m}){let[o,u]=e,p=g(null),W=g({...m,center:[o,u],zoom:t}),[i,R]=k(null),[L,M]=k("loading"),z=Q(p),b=c[z],w=g(b),I=g(s),P=g(t);return h(()=>{let d=p.current;if(!d)return;let l=new Z.Map({attributionControl:!1,container:d,renderWorldCopies:!1,style:w.current,...W.current}),f=window.setTimeout(()=>M("error"),12e3),E=()=>{window.clearTimeout(f),M("loaded")},N=new ResizeObserver(()=>l.resize());return l.touchZoomRotate.disableRotation(),I.current&&l.setPadding(I.current),l.on("load",E),N.observe(d),R(l),()=>{window.clearTimeout(f),N.disconnect(),l.off("load",E),l.remove(),R(null)}},[]),h(()=>{if(!i||w.current===b)return;let d=window.setTimeout(()=>M("error"),12e3),l=()=>{window.clearTimeout(d),M("loaded")},f=()=>M("loading");return w.current=b,i.once("styledataloading",f),i.setStyle(b,{diff:!1}),i.once("style.load",l),()=>{window.clearTimeout(d),i.off("style.load",l),i.off("styledataloading",f)}},[b,i]),h(()=>{if(!i)return;let d=i.getCenter(),l=d.lng!==o||d.lat!==u,f=P.current!==t;P.current=t,!(!l&&!f)&&i.easeTo({center:[o,u],duration:window.matchMedia("(prefers-reduced-motion: reduce)").matches?0:350,...f?{zoom:t}:{}})},[u,o,i,t]),n(_,{value:i,children:y("div",{ref:p,className:G("aui-interactive-map",a),"data-load-state":L,"data-slot":"agent-ui-interactive-map",children:[L==="loading"?n("div",{"aria-label":"Loading map",className:"aui-interactive-map__loader",role:"status",children:n("span",{})}):null,L==="error"?y("div",{className:"aui-interactive-map__error",role:"status",children:[n("strong",{children:"Map unavailable"}),n("span",{children:"Location results remain available."})]}):null,i?r:null]})})}function q({children:e,latitude:r,longitude:a}){let s=$(_),c=g({latitude:r,longitude:a}),[t,m]=k(null);return h(()=>{let o=document.createElement("div"),u=c.current,p=new Z.Marker({element:o}).setLngLat([u.longitude,u.latitude]);return o.className="aui-interactive-map__marker-host",m(p),()=>{p.remove()}},[]),h(()=>{if(!s||!t)return;t.addTo(s);let o=t.getElement();return o.removeAttribute("aria-label"),o.removeAttribute("role"),o.removeAttribute("tabindex"),()=>{t.remove()}},[s,t]),h(()=>{t?.setLngLat([a,r])},[r,a,t]),t?A(n("div",{className:"aui-interactive-map__marker-content",children:e}),t.getElement()):null}function T({children:e,label:r,...a}){return n("button",{"aria-label":r,className:"aui-interactive-map__control-button",type:"button",...a,children:e})}function J(e){return n("svg",{"aria-hidden":"true",fill:"none",viewBox:"0 0 16 16",...e,children:n("path",{d:"M8 3v10M3 8h10",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"1.5"})})}function K(e){return n("svg",{"aria-hidden":"true",fill:"none",viewBox:"0 0 16 16",...e,children:n("path",{d:"M3 8h10",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"1.5"})})}function U(e){return y("svg",{"aria-hidden":"true",fill:"none",viewBox:"0 0 24 24",...e,children:[n("path",{d:"M12 2 16 12h-4V2Z","data-needle":"north-right"}),n("path",{d:"m12 2-4 10h4V2Z","data-needle":"north-left"}),n("path",{d:"m12 22 4-10h-4v10Z","data-needle":"south-right"}),n("path",{d:"m12 22-4-10h4v10Z","data-needle":"south-left"})]})}function Y(){let e=$(_),r=g(null),a=H(()=>{!e||!r.current||(r.current.style.transform=`rotateX(${e.getPitch()}deg) rotateZ(${-e.getBearing()}deg)`)},[e]);return h(()=>{if(e)return e.on("pitch",a),e.on("rotate",a),a(),()=>{e.off("pitch",a),e.off("rotate",a)}},[e,a]),y("div",{className:"aui-interactive-map__controls","data-slot":"agent-ui-map-controls",children:[y("div",{className:"aui-interactive-map__control-group",children:[n(T,{label:"Zoom in",onClick:()=>e?.zoomTo(e.getZoom()+1,{duration:250}),children:n(J,{})}),n(T,{label:"Zoom out",onClick:()=>e?.zoomTo(e.getZoom()-1,{duration:250}),children:n(K,{})})]}),n("div",{className:"aui-interactive-map__control-group",children:n(T,{label:"Reset bearing to north",onClick:()=>e?.resetNorthPitch({duration:250}),children:n(U,{ref:r,className:"aui-interactive-map__compass"})})})]})}var C=Object.assign(X,{Controls:Y,Marker:q});import{jsx as v,jsxs as S}from"react/jsx-runtime";var te={dark:"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",light:"https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json"},ae={bottom:132,left:0,right:0,top:0},F=new Intl.NumberFormat(void 0,{maximumFractionDigits:1,minimumFractionDigits:1});function me({component:e,onSelect:r,selectedLocationId:a}){let s=x(e),c=V(e.locations,a,s.center);return S("div",{"aria-label":`${e.title} map with ${e.locations.length} locations`,className:"aui-map__surface","data-renderer":"interactive","data-slot":"agent-ui-map-surface",role:"region",children:[S(C,{center:[c.longitude,c.latitude],className:"aui-map__interactive-map",dragRotate:!1,padding:ae,pitchWithRotate:!1,styles:te,zoom:s.zoom,children:[e.locations.map((t,m)=>{let o=t.id===a,u=t.rating!==void 0?F.format(t.rating):t.relevance!==void 0?`${Math.round(t.relevance*100)}%`:String(m+1),p=`Select ${t.title} on map${t.rating===void 0?"":`, rated ${F.format(t.rating)} out of 5`}`;return v(C.Marker,{latitude:t.latitude,longitude:t.longitude,children:S("button",{"aria-label":p,"aria-pressed":o,className:"aui-map__marker","data-renderer":"interactive","data-selected":o,"data-slot":"agent-ui-map-marker",title:t.title,type:"button",onClick:()=>r(t),children:[v(ee,{"aria-hidden":"true"}),v("span",{children:u})]})},t.id)}),v(C.Controls,{})]}),S("span",{className:"aui-map__attribution","data-slot":"agent-ui-map-attribution",children:[v("a",{href:"https://www.openstreetmap.org/copyright",rel:"noreferrer",target:"_blank",children:"\xA9 OpenStreetMap"}),v("span",{"aria-hidden":"true",children:" \xB7 "}),v("a",{href:"https://carto.com/attributions",rel:"noreferrer",target:"_blank",children:"\xA9 CARTO"})]})]})}export{me as InteractiveMapSurface};
@@ -0,0 +1 @@
1
+ import{a,b,c,d}from"../chunk-64RI74L5.js";export{a as createToolHelper,b as isZodSchema,c as parseClientToolArgs,d as resolveDirectToolAction};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g}from"../chunk-OA3TG5CS.js";export{a as AGENT_MODEL_IDS,e as AGENT_MODEL_OPTIONS,d as DEFAULT_AGENT_PICKER_MODEL_ID,b as LEGACY_AGENT_MODEL_IDS,g as getAgentModelTier,f as isAgentModelId,c as resolveAgentModelId};
@@ -0,0 +1 @@
1
+ import{a,b,c,d}from"../chunk-7KCGPNEN.js";export{a as HEROUI_AGENT_RUNTIME_TIMING_EVENT,d as HEROUI_AGENT_TURN_ADMISSION_STATUS_MAX_IDS,c as HEROUI_AGENT_TURN_ADMISSION_STATUS_METHOD,b as HEROUI_AGENT_TURN_ADMITTED_FRAME_TYPE};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f}from"../chunk-2XBFFSW2.js";export{c as ACCENT_FOREGROUND_CSS,a as AGENT_DESIGN_THEMES,d as LAUNCHER_FOREGROUND_CSS,e as buildLauncherStyle,f as buildThemeStyle,b as resolveAgentDesignTheme};
package/dist/next.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- export { AGENT_MODEL_IDS, AGENT_MODEL_OPTIONS, AgentAttachmentContentType, AgentAuthToken, AgentComposerOptions, AgentContext, AgentController, AgentFeedbackReason, AgentMarkdownAnimation, AgentMarkdownCaret, AgentMarkdownOptions, AgentMarkdownPlugins, AgentMarkdownRenderer, AgentMarkdownRendererProps, AgentModelId, AgentModelOption, AgentModelTier, AgentPermissionMode, AgentPermissionOptions, AgentResponseFeedback, AgentSharedContext, ClientTool, ClientToolIconProps, ClientToolRenderProps, ClientToolStatus, DEFAULT_AGENT_PICKER_MODEL_ID, GetAuthToken, GetAuthTokenContext, HeroUIAgent, HeroUIAgentProps, createToolHelper, getAgentModelTier, isAgentModelId, useAgent } from './index.js';
1
+ export { AGENT_MODEL_IDS, AGENT_MODEL_OPTIONS, AgentActivityPhase, AgentAttachmentContentType, AgentAuthToken, AgentComposerOptions, AgentContext, AgentController, AgentFeedbackReason, AgentMarkdownAnimation, AgentMarkdownCaret, AgentMarkdownOptions, AgentMarkdownPlugins, AgentMarkdownRenderer, AgentMarkdownRendererProps, AgentModelId, AgentModelOption, AgentModelTier, AgentPermissionMode, AgentPermissionOptions, AgentResponseFeedback, AgentRuntimeTiming, AgentRuntimeTimingEventDetail, AgentSharedContext, ClientTool, ClientToolExecutionContext, ClientToolIconProps, ClientToolRenderProps, ClientToolStatus, DEFAULT_AGENT_PICKER_MODEL_ID, GetAuthToken, GetAuthTokenContext, HEROUI_AGENT_RUNTIME_TIMING_EVENT, HeroUIAgent, HeroUIAgentProps, createToolHelper, getAgentModelTier, isAgentModelId, useAgent } from './index.js';
2
2
  import 'react';
3
+ import 'react/jsx-runtime';
3
4
  import 'zod';
4
5
  import 'streamdown';
package/dist/next.js CHANGED
@@ -1,22 +1 @@
1
- import {
2
- HeroUIAgent,
3
- useAgent
4
- } from "./chunk-V5S5FRGV.js";
5
- import {
6
- AGENT_MODEL_IDS,
7
- AGENT_MODEL_OPTIONS,
8
- DEFAULT_AGENT_PICKER_MODEL_ID,
9
- createToolHelper,
10
- getAgentModelTier,
11
- isAgentModelId
12
- } from "./chunk-OQGXZY5L.js";
13
- export {
14
- AGENT_MODEL_IDS,
15
- AGENT_MODEL_OPTIONS,
16
- DEFAULT_AGENT_PICKER_MODEL_ID,
17
- HeroUIAgent,
18
- createToolHelper,
19
- getAgentModelTier,
20
- isAgentModelId,
21
- useAgent
22
- };
1
+ import{a as i,b as p}from"./chunk-SUDHJNTJ.js";import"./chunk-WUAFMD7Z.js";import"./chunk-6ZJJN322.js";import{a as e}from"./chunk-64RI74L5.js";import{a as t,d as n,e as o,f as r,g as A}from"./chunk-OA3TG5CS.js";import{a as g}from"./chunk-7KCGPNEN.js";import"./chunk-2XBFFSW2.js";export{t as AGENT_MODEL_IDS,o as AGENT_MODEL_OPTIONS,n as DEFAULT_AGENT_PICKER_MODEL_ID,g as HEROUI_AGENT_RUNTIME_TIMING_EVENT,p as HeroUIAgent,e as createToolHelper,A as getAgentModelTier,r as isAgentModelId,i as useAgent};
package/dist/server.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as AgentAuthIdentity, b as AgentAuthProfile, c as AgentAuthToken } from './identity-Z6i6pL0F.js';
1
+ import { a as AgentAuthIdentity, b as AgentAuthProfile, c as AgentAuthToken } from './identity-3P8-17km.js';
2
2
  import 'zod';
3
3
 
4
4
  type CreateAuthTokenOptions = {
package/dist/server.js CHANGED
@@ -1,260 +1 @@
1
- // src/contracts/identity.ts
2
- import { z as z3 } from "zod";
3
-
4
- // src/contracts/client-tools.ts
5
- import { z } from "zod";
6
- var RESERVED_AGENT_TOOL_NAMES = [
7
- "composeUI",
8
- "executeSandbox",
9
- "getComponentSchema",
10
- "loadUIRenderers",
11
- "renderComponent",
12
- "searchKnowledge",
13
- "searchWeb"
14
- ];
15
- var RESERVED_AGENT_TOOL_PREFIX = "mcp_";
16
- var MAX_CLIENT_TOOLS = 20;
17
- var MAX_CLIENT_TOOLS_BYTES = 16 * 1024;
18
- var clientToolManifestEntrySchema = z.object({
19
- description: z.string().trim().min(1).max(1e3),
20
- inputSchema: z.record(z.string(), z.unknown()),
21
- name: z.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/).refine(
22
- (name) => !RESERVED_AGENT_TOOL_NAMES.includes(name) && !name.toLowerCase().startsWith(RESERVED_AGENT_TOOL_PREFIX),
23
- "Client tool name is reserved by the HeroUI Agent runtime"
24
- ),
25
- needsApproval: z.boolean().optional()
26
- });
27
- var clientToolsSchema = z.array(clientToolManifestEntrySchema).max(MAX_CLIENT_TOOLS).superRefine((tools, context) => {
28
- const names = /* @__PURE__ */ new Set();
29
- for (const entry of tools) {
30
- if (names.has(entry.name)) {
31
- context.addIssue({ code: "custom", message: `Duplicate client tool name: ${entry.name}` });
32
- }
33
- names.add(entry.name);
34
- }
35
- if (new TextEncoder().encode(JSON.stringify(tools)).byteLength > MAX_CLIENT_TOOLS_BYTES) {
36
- context.addIssue({ code: "custom", message: "Client tool manifest exceeds 16KB" });
37
- }
38
- });
39
-
40
- // src/contracts/models.schema.ts
41
- import { z as z2 } from "zod";
42
-
43
- // src/contracts/models.ts
44
- var AGENT_MODEL_IDS = [
45
- "moonshotai/Kimi-K3",
46
- "openai/gpt-5.6-luna",
47
- "openai/gpt-5.6-terra",
48
- "openai/gpt-5.6-sol",
49
- "google/gemini-3.6-flash",
50
- "anthropic/claude-sonnet-5",
51
- "anthropic/claude-opus-4.8"
52
- ];
53
- var LEGACY_AGENT_MODEL_IDS = {
54
- "google/gemini-3.5-flash": "google/gemini-3.6-flash"
55
- };
56
- function resolveAgentModelId(value) {
57
- return LEGACY_AGENT_MODEL_IDS[value] ?? value;
58
- }
59
- var AGENT_MODEL_ID_SET = new Set(AGENT_MODEL_IDS);
60
-
61
- // src/contracts/models.schema.ts
62
- var agentModelIdSchema = z2.preprocess(
63
- (value) => typeof value === "string" ? resolveAgentModelId(value) : value,
64
- z2.enum(AGENT_MODEL_IDS)
65
- );
66
-
67
- // src/contracts/version.ts
68
- var HEROUI_AGENT_PROTOCOL_VERSION = 5;
69
- var HEROUI_AGENT_SDK_VERSION = "0.2.0-beta.7";
70
-
71
- // src/contracts/identity.ts
72
- var agentThemeSchema = z3.enum(["light", "dark", "system"]);
73
- var agentSurfaceVariantSchema = z3.enum([
74
- "outline",
75
- "plain",
76
- "surface",
77
- "surface-secondary"
78
- ]);
79
- var pageContextSchema = z3.record(z3.string().max(100), z3.unknown());
80
- var RESERVED_IDENTITY_IDS = /* @__PURE__ */ new Set([
81
- "[object object]",
82
- "0",
83
- "anonymous",
84
- "distinct_id",
85
- "distinctid",
86
- "email",
87
- "false",
88
- "guest",
89
- "id",
90
- "nan",
91
- "none",
92
- "not_authenticated",
93
- "null",
94
- "true",
95
- "undefined"
96
- ]);
97
- var agentIdentityIdSchema = z3.string().trim().min(1).max(200).refine((value) => !RESERVED_IDENTITY_IDS.has(value.toLowerCase()), {
98
- message: "Identity id is reserved"
99
- });
100
- var agentAuthIdentitySchema = z3.discriminatedUnion("type", [
101
- z3.object({
102
- id: agentIdentityIdSchema,
103
- type: z3.literal("anonymous")
104
- }),
105
- z3.object({
106
- id: agentIdentityIdSchema,
107
- type: z3.literal("user")
108
- })
109
- ]);
110
- var agentAuthProfileSchema = z3.object({
111
- avatarUrl: z3.string().trim().pipe(z3.url()).optional(),
112
- email: z3.string().trim().max(320).pipe(z3.email()).optional(),
113
- name: z3.string().trim().max(120).optional()
114
- });
115
- var createAgentAuthTokenRequestSchema = z3.object({
116
- /**
117
- * Browser-scoped id the SDK passed to the host callback. Sending it together
118
- * with an identified `identity` merges that anonymous person's conversations
119
- * into the identified user, so history survives login.
120
- */
121
- anonymousId: agentIdentityIdSchema.optional(),
122
- identity: agentAuthIdentitySchema,
123
- profile: agentAuthProfileSchema.optional()
124
- });
125
- var agentAuthTokenSchema = z3.object({
126
- expiresAt: z3.number().int().positive(),
127
- token: z3.string().trim().min(1)
128
- });
129
- var agentTokenClaimsSchema = z3.object({
130
- agentId: z3.string().trim().min(1).max(100),
131
- apiKeyId: z3.string().trim().min(1).max(100),
132
- aud: z3.literal("heroui-agent"),
133
- exp: z3.number().int().positive(),
134
- iat: z3.number().int().positive(),
135
- iss: z3.literal("https://api.heroui.com"),
136
- jti: z3.uuid(),
137
- protocolVersion: z3.literal(HEROUI_AGENT_PROTOCOL_VERSION),
138
- sub: z3.string().trim().min(1).max(200)
139
- });
140
- var trustedAgentClientDataSchema = z3.object({
141
- agentId: z3.string(),
142
- billingLicenseId: z3.string().nullable(),
143
- billingOwnerUserId: z3.string(),
144
- /**
145
- * Browser-declared client tools the embed can execute for this turn. The
146
- * runtime registers them as model-visible tools without an execute function.
147
- */
148
- clientTools: clientToolsSchema.default([]),
149
- conversationId: z3.uuid(),
150
- /**
151
- * Pseudonymous identity used by persisted conversations. This is signed by
152
- * the API so the runtime can link telemetry without handling a raw identity.
153
- */
154
- endUserKey: z3.string().trim().min(1).max(200).optional(),
155
- /**
156
- * When web search is enabled, allow image results via `includeImages`.
157
- * Defaults to true at the host when omitted; optional here so signed
158
- * payloads without the field stay valid and keep image search on.
159
- */
160
- imageSearch: z3.boolean().optional(),
161
- /**
162
- * Optional browser-selected OpenRouter model. The API accepts only the
163
- * fixed agent allowlist and signs the value before the runtime sees it.
164
- */
165
- modelId: agentModelIdSchema.optional(),
166
- /**
167
- * When web search is enabled, allow recent news results via `includeNews`.
168
- * Optional and disabled when omitted so older signed payloads remain valid.
169
- */
170
- newsSearch: z3.boolean().optional(),
171
- pageContext: pageContextSchema.default({}),
172
- /**
173
- * Set by the API when the session was authorized by a dashboard preview
174
- * credential rather than a host API key, so operator traffic can be separated
175
- * from real visitors. Optional (not defaulted) to keep older signed payloads
176
- * valid.
177
- */
178
- preview: z3.boolean().optional(),
179
- protocolVersion: z3.literal(HEROUI_AGENT_PROTOCOL_VERSION),
180
- requestId: z3.uuid(),
181
- sdkVersion: z3.string().trim().min(1).max(80),
182
- signedAt: z3.number(),
183
- subject: z3.string(),
184
- /**
185
- * Host-enabled public web search. When true the runtime registers the
186
- * `searchWeb` tool (if the search backend is configured) so the agent can
187
- * look up public information, images, and optionally news. Optional (not defaulted) so schema
188
- * parsing never injects a field into an already-signed payload.
189
- */
190
- webSearch: z3.boolean().optional()
191
- });
192
- var signedTrustedAgentClientDataSchema = trustedAgentClientDataSchema.extend({
193
- sig: z3.string().min(1)
194
- });
195
- var agentProjectConfigSchema = z3.object({
196
- agentId: z3.string(),
197
- minimumProtocolVersion: z3.literal(HEROUI_AGENT_PROTOCOL_VERSION),
198
- name: z3.string().trim().min(1).max(120),
199
- /**
200
- * InstantDB app used for ephemeral live-conversation presence. Optional so
201
- * newer SDKs remain compatible with older Agent API deployments.
202
- */
203
- presence: z3.object({ appId: z3.uuid() }).optional(),
204
- protocolVersion: z3.literal(HEROUI_AGENT_PROTOCOL_VERSION),
205
- sdkVersion: z3.string().default(HEROUI_AGENT_SDK_VERSION),
206
- suggestedPrompts: z3.array(z3.string().trim().min(1).max(160)).max(5),
207
- surfaceVariant: agentSurfaceVariantSchema.default("plain"),
208
- theme: agentThemeSchema
209
- });
210
-
211
- // src/server/index.ts
212
- var DEFAULT_API_BASE_URL = "https://api.heroui.com";
213
- var HeroUIAgentAuthError = class extends Error {
214
- status;
215
- constructor(message, status, options) {
216
- super(message, options);
217
- this.name = "HeroUIAgentAuthError";
218
- this.status = status;
219
- }
220
- };
221
- async function createAuthToken(options) {
222
- const apiKey = options.apiKey.trim();
223
- const agentId = options.agentId.trim();
224
- const request = createAgentAuthTokenRequestSchema.safeParse({
225
- anonymousId: options.anonymousId,
226
- identity: options.identity,
227
- profile: options.profile
228
- });
229
- if (!apiKey || !agentId || !request.success) {
230
- throw new HeroUIAgentAuthError("Invalid HeroUI Agent auth token request", 400);
231
- }
232
- const apiBaseUrl = (options.apiBaseUrl?.trim() || DEFAULT_API_BASE_URL).replace(/\/$/, "");
233
- let response;
234
- try {
235
- response = await fetch(`${apiBaseUrl}/v1/agents/${encodeURIComponent(agentId)}/auth-tokens`, {
236
- body: JSON.stringify(request.data),
237
- cache: "no-store",
238
- headers: {
239
- Accept: "application/json",
240
- "Content-Type": "application/json",
241
- "X-HeroUI-Agent-Key": apiKey
242
- },
243
- method: "POST"
244
- });
245
- } catch (cause) {
246
- throw new HeroUIAgentAuthError("HeroUI Agent authentication is unavailable", 503, { cause });
247
- }
248
- if (!response.ok) {
249
- throw new HeroUIAgentAuthError("HeroUI Agent authentication failed", response.status);
250
- }
251
- const parsed = agentAuthTokenSchema.safeParse(await response.json().catch(() => null));
252
- if (!parsed.success) {
253
- throw new HeroUIAgentAuthError("HeroUI Agent authentication returned invalid data", 502);
254
- }
255
- return parsed.data;
256
- }
257
- export {
258
- HeroUIAgentAuthError,
259
- createAuthToken
260
- };
1
+ import{z as e}from"zod";var m="0.2.0-beta.9";var d=e.enum(["light","dark","system"]),A=e.enum(["outline","plain","surface","surface-secondary"]),y=new Set(["[object object]","0","anonymous","distinct_id","distinctid","email","false","guest","id","nan","none","not_authenticated","null","true","undefined"]),c=e.string().trim().min(1).max(200).refine(t=>!y.has(t.toLowerCase()),{message:"Identity id is reserved"}),f=e.discriminatedUnion("type",[e.object({id:c,type:e.literal("anonymous")}),e.object({id:c,type:e.literal("user")})]),S=e.object({avatarUrl:e.string().trim().pipe(e.url()).optional(),email:e.string().trim().max(320).pipe(e.email()).optional(),name:e.string().trim().max(120).optional()}),u=e.object({anonymousId:c.optional(),identity:f,profile:S.optional()}),g=e.object({expiresAt:e.number().int().positive(),token:e.string().trim().min(1)}),O=e.object({agentId:e.string().trim().min(1).max(100),apiKeyId:e.string().trim().min(1).max(100),aud:e.literal("heroui-agent"),exp:e.number().int().positive(),iat:e.number().int().positive(),iss:e.literal("https://api.heroui.com"),jti:e.uuid(),protocolVersion:e.literal(6),sub:e.string().trim().min(1).max(200)});var R=e.object({agentId:e.string(),minimumProtocolVersion:e.literal(6),name:e.string().trim().min(1).max(120),protocolVersion:e.literal(6),sdkVersion:e.string().default(m),suggestedPrompts:e.array(e.string().trim().min(1).max(160)).max(5),surfaceVariant:A.default("plain"),theme:d});var I="https://api.heroui.com",n=class extends Error{status;constructor(o,i,a){super(o,a),this.name="HeroUIAgentAuthError",this.status=i}};async function C(t){let o=t.apiKey.trim(),i=t.agentId.trim(),a=u.safeParse({anonymousId:t.anonymousId,identity:t.identity,profile:t.profile});if(!o||!i||!a.success)throw new n("Invalid HeroUI Agent auth token request",400);let h=(t.apiBaseUrl?.trim()||I).replace(/\/$/,""),r;try{r=await fetch(`${h}/v1/agents/${encodeURIComponent(i)}/auth-tokens`,{body:JSON.stringify(a.data),cache:"no-store",headers:{Accept:"application/json","Content-Type":"application/json","X-HeroUI-Agent-Key":o},method:"POST"})}catch(l){throw new n("HeroUI Agent authentication is unavailable",503,{cause:l})}if(!r.ok)throw new n("HeroUI Agent authentication failed",r.status);let p=g.safeParse(await r.json().catch(()=>null));if(!p.success)throw new n("HeroUI Agent authentication returned invalid data",502);return p.data}export{n as HeroUIAgentAuthError,C as createAuthToken};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heroui/agent",
3
- "version": "0.2.0-beta.7",
3
+ "version": "0.2.0-beta.9",
4
4
  "description": "Embed a hosted HeroUI Agent that turns application data into interactive UI.",
5
5
  "homepage": "https://www.heroui.com/agents",
6
6
  "bugs": {
@@ -66,13 +66,13 @@
66
66
  },
67
67
  "dependencies": {
68
68
  "@ai-sdk/react": "4.0.12",
69
+ "@cloudflare/ai-chat": "0.10.1",
69
70
  "@gravity-ui/icons": "2.18.0",
70
71
  "@heroui/react": "3.2.2",
71
- "@instantdb/core": "1.0.49",
72
72
  "@internationalized/date": "3.12.2",
73
73
  "@react-aria/utils": "3.34.1",
74
74
  "@react-stately/utils": "3.12.1",
75
- "@trigger.dev/sdk": "4.5.7",
75
+ "agents": "0.20.1",
76
76
  "ai": "7.0.11",
77
77
  "maplibre-gl": "5.24.0",
78
78
  "motion": "12.38.0",
@@ -109,10 +109,10 @@
109
109
  "tsup": "8.5.0",
110
110
  "typescript": "5.9.3",
111
111
  "vitest": "4.1.0",
112
- "@heroui-pro/config": "0.0.0",
113
- "@heroui-pro/react": "1.0.0-beta.8",
114
112
  "@heroui/agent-client": "0.0.0",
115
- "@heroui/agent-ui": "0.0.0"
113
+ "@heroui-pro/react": "1.0.0-beta.8",
114
+ "@heroui/agent-ui": "0.0.0",
115
+ "@heroui-pro/config": "0.0.0"
116
116
  },
117
117
  "scripts": {
118
118
  "build": "rm -rf dist && tsup && pnpm build:styles",