@heroui/agent 0.2.0-beta.1 → 0.2.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.
- package/CHANGELOG.md +73 -2
- package/README.md +23 -13
- package/dist/chart-content-BBHQVMP4.js +1 -0
- package/dist/chunk-2XBFFSW2.js +1 -0
- package/dist/chunk-5XUOZ2ZC.js +2 -0
- package/dist/chunk-64RI74L5.js +1 -0
- package/dist/chunk-6ZJJN322.js +1 -0
- package/dist/chunk-7KCGPNEN.js +1 -0
- package/dist/chunk-A53R5SMW.js +2 -0
- package/dist/chunk-BBB5EHDN.js +5 -0
- package/dist/chunk-CR3H7AVI.js +1 -0
- package/dist/chunk-HCLXS4HQ.js +1 -0
- package/dist/chunk-MXLGM4WV.js +1 -0
- package/dist/chunk-OA3TG5CS.js +1 -0
- package/dist/chunk-PZJ4NC3J.js +1 -0
- package/dist/chunk-RNNGE7KM.js +1 -0
- package/dist/chunk-S6OIAJSC.js +1 -0
- package/dist/component-renderer-GG6JVRUG.js +1 -0
- package/dist/composer-draft-NSKK65F3.js +1 -0
- package/dist/composer-image-draft-KAGTNQR7.js +1 -0
- package/dist/contracts.d.ts +374 -20
- package/dist/contracts.js +2 -2325
- package/dist/css/index.css +1 -1
- package/dist/embed-runtime-ZZKIK7WA.js +5 -0
- package/dist/identity-3P8-17km.d.ts +95 -0
- package/dist/index.d.ts +67 -13
- package/dist/index.js +1 -28
- package/dist/interactive-map-surface-WC2LPCR7.js +1 -0
- package/dist/internal/client-tools.js +1 -0
- package/dist/internal/models.js +1 -0
- package/dist/internal/runtime.js +1 -0
- package/dist/internal/theme.js +1 -0
- package/dist/next.d.ts +2 -1
- package/dist/next.js +1 -22
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -256
- package/package.json +26 -27
- package/dist/chart-content-VZ66GD22.js +0 -1391
- package/dist/chunk-3FG5NRTX.js +0 -9
- package/dist/chunk-CU6MPKAJ.js +0 -359
- package/dist/chunk-DW4AQRM5.js +0 -297
- package/dist/chunk-GDDNN2XY.js +0 -954
- package/dist/chunk-RQCTC4JB.js +0 -1084
- package/dist/chunk-TOOT6SZ2.js +0 -74
- package/dist/chunk-VJA52U5P.js +0 -137
- package/dist/component-renderer-IBJDNXSO.js +0 -9780
- package/dist/embed-runtime-XOPQY7Z5.js +0 -7254
- package/dist/identity-NYCXY1mT.d.ts +0 -164
- 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: "
|
|
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" */
|
|
@@ -345,6 +372,12 @@ type AgentCapabilities = {
|
|
|
345
372
|
* @default true
|
|
346
373
|
*/
|
|
347
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;
|
|
348
381
|
/**
|
|
349
382
|
* Allow the hosted agent to search the public web for current information
|
|
350
383
|
* and images. Results are untrusted external content; keep this off when the
|
|
@@ -461,7 +494,6 @@ type AgentStartScreenOptions = {
|
|
|
461
494
|
/** Internal — for HeroUI platform development only. */
|
|
462
495
|
type AgentApiOverrides = {
|
|
463
496
|
baseUrl?: string;
|
|
464
|
-
realtimeUrl?: string;
|
|
465
497
|
};
|
|
466
498
|
/**
|
|
467
499
|
* Short-lived browser credential returned by the customer's server.
|
|
@@ -506,14 +538,20 @@ type HeroUIAgentProps = {
|
|
|
506
538
|
* include structured reasons and an optional comment from the feedback popover.
|
|
507
539
|
*/
|
|
508
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;
|
|
509
547
|
/** Client-tool approval defaults and optional end-user picker. */
|
|
510
548
|
permissions?: AgentPermissionOptions;
|
|
511
549
|
/**
|
|
512
|
-
* Warm the agent
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
* 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.
|
|
517
555
|
*
|
|
518
556
|
* Set to `false` to request nothing until the panel is opened. Worth doing
|
|
519
557
|
* when most visitors never open the agent, or on pages where you want to
|
|
@@ -523,6 +561,19 @@ type HeroUIAgentProps = {
|
|
|
523
561
|
*/
|
|
524
562
|
preload?: boolean;
|
|
525
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;
|
|
526
577
|
/**
|
|
527
578
|
* Apply the appearance saved for this project in the HeroUI dashboard —
|
|
528
579
|
* launcher icon, colors, typography, greeting, and suggested prompts —
|
|
@@ -556,7 +607,8 @@ type HeroUIAgentProps = {
|
|
|
556
607
|
};
|
|
557
608
|
type AgentController = {
|
|
558
609
|
hide: () => void;
|
|
559
|
-
|
|
610
|
+
/** Start a fresh conversation, optionally submitting its first prompt immediately. */
|
|
611
|
+
newConversation: (prompt?: string) => void;
|
|
560
612
|
/**
|
|
561
613
|
* Warm the agent now, without opening it — the same work the `preload` prop
|
|
562
614
|
* does on its own. Pair it with `preload={false}` to pick the moment from
|
|
@@ -564,6 +616,8 @@ type AgentController = {
|
|
|
564
616
|
* struggling with. Cheap to call repeatedly; the work happens once.
|
|
565
617
|
*/
|
|
566
618
|
preload: () => void;
|
|
619
|
+
/** Whether project configuration and the complete composer are ready to open. */
|
|
620
|
+
ready: boolean;
|
|
567
621
|
refreshAuth: () => void;
|
|
568
622
|
show: () => void;
|
|
569
623
|
shutdown: () => void;
|
|
@@ -571,7 +625,7 @@ type AgentController = {
|
|
|
571
625
|
};
|
|
572
626
|
|
|
573
627
|
/**
|
|
574
|
-
* Imperative controls for the
|
|
628
|
+
* Imperative controls for the agent embed. Safe to call before
|
|
575
629
|
* `<HeroUIAgent />` mounts (calls are ignored with a console warning). Pass a
|
|
576
630
|
* `agentId` when rendering more than one agent on the same page.
|
|
577
631
|
*/
|
|
@@ -582,13 +636,13 @@ declare function useAgent(agentId?: string): AgentController;
|
|
|
582
636
|
* ```tsx
|
|
583
637
|
* <body>
|
|
584
638
|
* {children}
|
|
585
|
-
* <HeroUIAgent getAuthToken={getAuthToken} agentId=
|
|
639
|
+
* <HeroUIAgent getAuthToken={getAuthToken} agentId={process.env.NEXT_PUBLIC_HEROUI_AGENT_ID!} />
|
|
586
640
|
* </body>
|
|
587
641
|
* ```
|
|
588
642
|
*
|
|
589
643
|
* Renders nothing in the tree; the launcher and chat panel mount into an
|
|
590
644
|
* independent React root on `document.body`.
|
|
591
645
|
*/
|
|
592
|
-
declare function HeroUIAgent(props: HeroUIAgentProps):
|
|
646
|
+
declare function HeroUIAgent(props: HeroUIAgentProps): react_jsx_runtime.JSX.Element;
|
|
593
647
|
|
|
594
|
-
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-GDDNN2XY.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-RQCTC4JB.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-5XUOZ2ZC.js";import"./chunk-A53R5SMW.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-GDDNN2XY.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-RQCTC4JB.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-5XUOZ2ZC.js";import"./chunk-A53R5SMW.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
package/dist/server.js
CHANGED
|
@@ -1,256 +1 @@
|
|
|
1
|
-
|
|
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.1";
|
|
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
|
-
pageContext: pageContextSchema.default({}),
|
|
167
|
-
/**
|
|
168
|
-
* Set by the API when the session was authorized by a dashboard preview
|
|
169
|
-
* credential rather than a host API key, so operator traffic can be separated
|
|
170
|
-
* from real visitors. Optional (not defaulted) to keep older signed payloads
|
|
171
|
-
* valid.
|
|
172
|
-
*/
|
|
173
|
-
preview: z3.boolean().optional(),
|
|
174
|
-
protocolVersion: z3.literal(HEROUI_AGENT_PROTOCOL_VERSION),
|
|
175
|
-
requestId: z3.uuid(),
|
|
176
|
-
sdkVersion: z3.string().trim().min(1).max(80),
|
|
177
|
-
signedAt: z3.number(),
|
|
178
|
-
subject: z3.string(),
|
|
179
|
-
/**
|
|
180
|
-
* Host-enabled public web search. When true the runtime registers the
|
|
181
|
-
* `searchWeb` tool (if the search backend is configured) so the agent can
|
|
182
|
-
* look up public information and images. Optional (not defaulted) so schema
|
|
183
|
-
* parsing never injects a field into an already-signed payload.
|
|
184
|
-
*/
|
|
185
|
-
webSearch: z3.boolean().optional()
|
|
186
|
-
});
|
|
187
|
-
var signedTrustedAgentClientDataSchema = trustedAgentClientDataSchema.extend({
|
|
188
|
-
sig: z3.string().min(1)
|
|
189
|
-
});
|
|
190
|
-
var agentProjectConfigSchema = z3.object({
|
|
191
|
-
agentId: z3.string(),
|
|
192
|
-
minimumProtocolVersion: z3.literal(HEROUI_AGENT_PROTOCOL_VERSION),
|
|
193
|
-
name: z3.string().trim().min(1).max(120),
|
|
194
|
-
protocolVersion: z3.literal(HEROUI_AGENT_PROTOCOL_VERSION),
|
|
195
|
-
/**
|
|
196
|
-
* Internal streaming infrastructure endpoint, resolved server-side so
|
|
197
|
-
* customers never configure it. Optional for compatibility with older API
|
|
198
|
-
* deployments; the SDK falls back to Trigger.dev's public endpoint.
|
|
199
|
-
*/
|
|
200
|
-
realtime: z3.object({ url: z3.url() }).optional(),
|
|
201
|
-
sdkVersion: z3.string().default(HEROUI_AGENT_SDK_VERSION),
|
|
202
|
-
suggestedPrompts: z3.array(z3.string().trim().min(1).max(160)).max(5),
|
|
203
|
-
surfaceVariant: agentSurfaceVariantSchema.default("plain"),
|
|
204
|
-
theme: agentThemeSchema
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
// src/server/index.ts
|
|
208
|
-
var DEFAULT_API_BASE_URL = "https://api.heroui.com";
|
|
209
|
-
var HeroUIAgentAuthError = class extends Error {
|
|
210
|
-
status;
|
|
211
|
-
constructor(message, status, options) {
|
|
212
|
-
super(message, options);
|
|
213
|
-
this.name = "HeroUIAgentAuthError";
|
|
214
|
-
this.status = status;
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
async function createAuthToken(options) {
|
|
218
|
-
const apiKey = options.apiKey.trim();
|
|
219
|
-
const agentId = options.agentId.trim();
|
|
220
|
-
const request = createAgentAuthTokenRequestSchema.safeParse({
|
|
221
|
-
anonymousId: options.anonymousId,
|
|
222
|
-
identity: options.identity,
|
|
223
|
-
profile: options.profile
|
|
224
|
-
});
|
|
225
|
-
if (!apiKey || !agentId || !request.success) {
|
|
226
|
-
throw new HeroUIAgentAuthError("Invalid HeroUI Agent auth token request", 400);
|
|
227
|
-
}
|
|
228
|
-
const apiBaseUrl = (options.apiBaseUrl?.trim() || DEFAULT_API_BASE_URL).replace(/\/$/, "");
|
|
229
|
-
let response;
|
|
230
|
-
try {
|
|
231
|
-
response = await fetch(`${apiBaseUrl}/v1/agents/${encodeURIComponent(agentId)}/auth-tokens`, {
|
|
232
|
-
body: JSON.stringify(request.data),
|
|
233
|
-
cache: "no-store",
|
|
234
|
-
headers: {
|
|
235
|
-
Accept: "application/json",
|
|
236
|
-
"Content-Type": "application/json",
|
|
237
|
-
"X-HeroUI-Agent-Key": apiKey
|
|
238
|
-
},
|
|
239
|
-
method: "POST"
|
|
240
|
-
});
|
|
241
|
-
} catch (cause) {
|
|
242
|
-
throw new HeroUIAgentAuthError("HeroUI Agent authentication is unavailable", 503, { cause });
|
|
243
|
-
}
|
|
244
|
-
if (!response.ok) {
|
|
245
|
-
throw new HeroUIAgentAuthError("HeroUI Agent authentication failed", response.status);
|
|
246
|
-
}
|
|
247
|
-
const parsed = agentAuthTokenSchema.safeParse(await response.json().catch(() => null));
|
|
248
|
-
if (!parsed.success) {
|
|
249
|
-
throw new HeroUIAgentAuthError("HeroUI Agent authentication returned invalid data", 502);
|
|
250
|
-
}
|
|
251
|
-
return parsed.data;
|
|
252
|
-
}
|
|
253
|
-
export {
|
|
254
|
-
HeroUIAgentAuthError,
|
|
255
|
-
createAuthToken
|
|
256
|
-
};
|
|
1
|
+
import{z as e}from"zod";var m="0.2.0-beta.10";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,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heroui/agent",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.10",
|
|
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": {
|
|
7
|
-
"url": "https://github.com/heroui-inc/heroui-
|
|
7
|
+
"url": "https://github.com/heroui-inc/heroui-pro/issues"
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/heroui-inc/heroui-
|
|
11
|
+
"url": "git+https://github.com/heroui-inc/heroui-pro.git",
|
|
12
12
|
"directory": "packages/agent"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
@@ -64,31 +64,15 @@
|
|
|
64
64
|
"engines": {
|
|
65
65
|
"node": ">=20"
|
|
66
66
|
},
|
|
67
|
-
"scripts": {
|
|
68
|
-
"build": "rm -rf dist && tsup && pnpm build:styles",
|
|
69
|
-
"build:contracts": "rm -rf dist && tsup --config tsup.contracts.config.ts",
|
|
70
|
-
"build:styles": "node scripts/build-styles.mjs",
|
|
71
|
-
"check:bundle": "node scripts/check-bundle-size.mjs",
|
|
72
|
-
"check:package": "publint && attw --pack . --profile esm-only --exclude-entrypoints css css/index.css",
|
|
73
|
-
"check:styles": "node scripts/build-styles.mjs --check",
|
|
74
|
-
"clean": "rm -rf dist node_modules .turbo",
|
|
75
|
-
"lint": "eslint src/",
|
|
76
|
-
"lint:fix": "eslint src/ --fix",
|
|
77
|
-
"prepublishOnly": "export npm_config_dry_run=false && pnpm --dir ../.. exec turbo run build --filter=@heroui/agent && pnpm lint && pnpm typecheck && pnpm test && pnpm check:package && pnpm check:bundle && pnpm verify:pack",
|
|
78
|
-
"release": "pnpm prepublishOnly && pnpm version:bump",
|
|
79
|
-
"test": "NODE_OPTIONS=\"${NODE_OPTIONS:+$NODE_OPTIONS }--no-experimental-webstorage\" vitest run",
|
|
80
|
-
"typecheck": "tsc --noEmit",
|
|
81
|
-
"version:bump": "bumpp package.json src/contracts/version.ts ../../apps/frontend/src/app/dashboard/agents/_preview/contracts/version.ts --commit \"chore(agent): release heroui-agent-v%s\" --tag \"heroui-agent-v%s\"",
|
|
82
|
-
"verify:pack": "node scripts/verify-packed-package.mjs"
|
|
83
|
-
},
|
|
84
67
|
"dependencies": {
|
|
85
68
|
"@ai-sdk/react": "4.0.12",
|
|
69
|
+
"@cloudflare/ai-chat": "0.10.1",
|
|
86
70
|
"@gravity-ui/icons": "2.18.0",
|
|
87
71
|
"@heroui/react": "3.2.2",
|
|
88
72
|
"@internationalized/date": "3.12.2",
|
|
89
73
|
"@react-aria/utils": "3.34.1",
|
|
90
74
|
"@react-stately/utils": "3.12.1",
|
|
91
|
-
"
|
|
75
|
+
"agents": "0.20.1",
|
|
92
76
|
"ai": "7.0.11",
|
|
93
77
|
"maplibre-gl": "5.24.0",
|
|
94
78
|
"motion": "12.38.0",
|
|
@@ -110,10 +94,6 @@
|
|
|
110
94
|
],
|
|
111
95
|
"devDependencies": {
|
|
112
96
|
"@arethetypeswrong/cli": "0.18.5",
|
|
113
|
-
"@heroui-pro/config": "workspace:*",
|
|
114
|
-
"@heroui-pro/react": "workspace:*",
|
|
115
|
-
"@heroui/agent-client": "workspace:*",
|
|
116
|
-
"@heroui/agent-ui": "workspace:*",
|
|
117
97
|
"@heroui/styles": "3.2.2",
|
|
118
98
|
"@tailwindcss/cli": "4.2.2",
|
|
119
99
|
"@types/react": "19.2.14",
|
|
@@ -128,6 +108,25 @@
|
|
|
128
108
|
"tailwindcss": "4.2.2",
|
|
129
109
|
"tsup": "8.5.0",
|
|
130
110
|
"typescript": "5.9.3",
|
|
131
|
-
"vitest": "4.1.0"
|
|
111
|
+
"vitest": "4.1.0",
|
|
112
|
+
"@heroui-pro/config": "0.0.0",
|
|
113
|
+
"@heroui-pro/react": "1.0.0-beta.8",
|
|
114
|
+
"@heroui/agent-client": "0.0.0",
|
|
115
|
+
"@heroui/agent-ui": "0.0.0"
|
|
116
|
+
},
|
|
117
|
+
"scripts": {
|
|
118
|
+
"build": "rm -rf dist && tsup && pnpm build:styles",
|
|
119
|
+
"build:contracts": "rm -rf dist && tsup --config tsup.contracts.config.ts",
|
|
120
|
+
"build:styles": "node scripts/build-styles.mjs",
|
|
121
|
+
"check:bundle": "node scripts/check-bundle-size.mjs",
|
|
122
|
+
"check:package": "publint && attw --pack . --profile esm-only --exclude-entrypoints css css/index.css",
|
|
123
|
+
"check:styles": "node scripts/build-styles.mjs --check",
|
|
124
|
+
"clean": "rm -rf dist node_modules .turbo",
|
|
125
|
+
"lint": "eslint src/",
|
|
126
|
+
"lint:fix": "eslint src/ --fix",
|
|
127
|
+
"release": "pnpm prepublishOnly && bumpp package.json src/contracts/version.ts ../../apps/frontend/src/app/dashboard/agents/_preview/contracts/version.ts --commit \"chore(agent): release heroui-agent-v%s\" --tag \"heroui-agent-v%s\"",
|
|
128
|
+
"test": "NODE_OPTIONS=\"${NODE_OPTIONS:+$NODE_OPTIONS }--no-experimental-webstorage\" vitest run",
|
|
129
|
+
"typecheck": "tsc --noEmit",
|
|
130
|
+
"verify:pack": "node scripts/verify-packed-package.mjs"
|
|
132
131
|
}
|
|
133
|
-
}
|
|
132
|
+
}
|