@heroui/agent 0.2.0-beta.7 → 0.2.0-beta.8
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 +15 -2
- package/README.md +15 -10
- package/dist/{chunk-V5S5FRGV.js → chunk-CMZDZGUZ.js} +354 -206
- package/dist/chunk-DS4X5K2R.js +56 -0
- package/dist/{chunk-6O3SFXJK.js → chunk-G6GFNSG4.js} +13 -54
- package/dist/chunk-Q7LGTVBL.js +43 -0
- package/dist/chunk-UUPU3MYB.js +42 -0
- package/dist/{chunk-OQGXZY5L.js → chunk-W7SCMB3O.js} +552 -358
- package/dist/{component-renderer-46EJDPTB.js → component-renderer-MDDQMQTU.js} +4 -2
- package/dist/composer-draft-DTQAEO5K.js +20 -0
- package/dist/composer-image-draft-IVJ352E6.js +174 -0
- package/dist/contracts.d.ts +50 -19
- package/dist/contracts.js +130 -230
- package/dist/css/index.css +1 -1
- package/dist/{embed-runtime-UF7XJIFA.js → embed-runtime-VVAGDPYY.js} +3415 -1643
- package/dist/identity-3P8-17km.d.ts +95 -0
- package/dist/index.d.ts +46 -10
- package/dist/index.js +5 -2
- package/dist/next.d.ts +2 -1
- package/dist/next.js +5 -2
- package/dist/server.d.ts +1 -1
- package/dist/server.js +35 -159
- package/package.json +3 -3
- package/dist/identity-Z6i6pL0F.d.ts +0 -166
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const agentThemeSchema: z.ZodEnum<{
|
|
4
|
+
dark: "dark";
|
|
5
|
+
light: "light";
|
|
6
|
+
system: "system";
|
|
7
|
+
}>;
|
|
8
|
+
declare const agentSurfaceVariantSchema: z.ZodEnum<{
|
|
9
|
+
surface: "surface";
|
|
10
|
+
outline: "outline";
|
|
11
|
+
plain: "plain";
|
|
12
|
+
"surface-secondary": "surface-secondary";
|
|
13
|
+
}>;
|
|
14
|
+
declare const agentIdentityIdSchema: z.ZodString;
|
|
15
|
+
declare const agentAuthIdentitySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
16
|
+
id: z.ZodString;
|
|
17
|
+
type: z.ZodLiteral<"anonymous">;
|
|
18
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
19
|
+
id: z.ZodString;
|
|
20
|
+
type: z.ZodLiteral<"user">;
|
|
21
|
+
}, z.core.$strip>], "type">;
|
|
22
|
+
declare const agentAuthProfileSchema: z.ZodObject<{
|
|
23
|
+
avatarUrl: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodURL>>;
|
|
24
|
+
email: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodEmail>>;
|
|
25
|
+
name: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
/** Server-to-server request for a short-lived browser credential. */
|
|
28
|
+
declare const createAgentAuthTokenRequestSchema: z.ZodObject<{
|
|
29
|
+
anonymousId: z.ZodOptional<z.ZodString>;
|
|
30
|
+
identity: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
31
|
+
id: z.ZodString;
|
|
32
|
+
type: z.ZodLiteral<"anonymous">;
|
|
33
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
34
|
+
id: z.ZodString;
|
|
35
|
+
type: z.ZodLiteral<"user">;
|
|
36
|
+
}, z.core.$strip>], "type">;
|
|
37
|
+
profile: z.ZodOptional<z.ZodObject<{
|
|
38
|
+
avatarUrl: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodURL>>;
|
|
39
|
+
email: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodEmail>>;
|
|
40
|
+
name: z.ZodOptional<z.ZodString>;
|
|
41
|
+
}, z.core.$strip>>;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
declare const agentAuthTokenSchema: z.ZodObject<{
|
|
44
|
+
expiresAt: z.ZodNumber;
|
|
45
|
+
token: z.ZodString;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
declare const agentTokenClaimsSchema: z.ZodObject<{
|
|
48
|
+
agentId: z.ZodString;
|
|
49
|
+
apiKeyId: z.ZodString;
|
|
50
|
+
aud: z.ZodLiteral<"heroui-agent">;
|
|
51
|
+
exp: z.ZodNumber;
|
|
52
|
+
iat: z.ZodNumber;
|
|
53
|
+
iss: z.ZodLiteral<"https://api.heroui.com">;
|
|
54
|
+
jti: z.ZodUUID;
|
|
55
|
+
protocolVersion: z.ZodLiteral<6>;
|
|
56
|
+
sub: z.ZodString;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
/**
|
|
59
|
+
* How a persisted conversation was started. Rows written before this existed
|
|
60
|
+
* carry no source and are treated as `embed`.
|
|
61
|
+
*/
|
|
62
|
+
declare const AGENT_CONVERSATION_SOURCE: {
|
|
63
|
+
readonly embed: "embed";
|
|
64
|
+
readonly preview: "preview";
|
|
65
|
+
};
|
|
66
|
+
type AgentConversationSource = (typeof AGENT_CONVERSATION_SOURCE)[keyof typeof AGENT_CONVERSATION_SOURCE];
|
|
67
|
+
declare const agentProjectConfigSchema: z.ZodObject<{
|
|
68
|
+
agentId: z.ZodString;
|
|
69
|
+
minimumProtocolVersion: z.ZodLiteral<6>;
|
|
70
|
+
name: z.ZodString;
|
|
71
|
+
protocolVersion: z.ZodLiteral<6>;
|
|
72
|
+
sdkVersion: z.ZodDefault<z.ZodString>;
|
|
73
|
+
suggestedPrompts: z.ZodArray<z.ZodString>;
|
|
74
|
+
surfaceVariant: z.ZodDefault<z.ZodEnum<{
|
|
75
|
+
surface: "surface";
|
|
76
|
+
outline: "outline";
|
|
77
|
+
plain: "plain";
|
|
78
|
+
"surface-secondary": "surface-secondary";
|
|
79
|
+
}>>;
|
|
80
|
+
theme: z.ZodEnum<{
|
|
81
|
+
dark: "dark";
|
|
82
|
+
light: "light";
|
|
83
|
+
system: "system";
|
|
84
|
+
}>;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
type AgentAuthIdentity = z.infer<typeof agentAuthIdentitySchema>;
|
|
87
|
+
type AgentAuthProfile = z.infer<typeof agentAuthProfileSchema>;
|
|
88
|
+
type AgentAuthToken = z.infer<typeof agentAuthTokenSchema>;
|
|
89
|
+
type CreateAgentAuthTokenRequest = z.infer<typeof createAgentAuthTokenRequestSchema>;
|
|
90
|
+
type AgentTokenClaims = z.infer<typeof agentTokenClaimsSchema>;
|
|
91
|
+
type AgentTheme = z.infer<typeof agentThemeSchema>;
|
|
92
|
+
type AgentSurfaceVariant = z.infer<typeof agentSurfaceVariantSchema>;
|
|
93
|
+
type AgentProjectConfig = z.infer<typeof agentProjectConfigSchema>;
|
|
94
|
+
|
|
95
|
+
export { AGENT_CONVERSATION_SOURCE as A, type CreateAgentAuthTokenRequest as C, type AgentAuthIdentity as a, type AgentAuthProfile as b, type AgentAuthToken as c, type AgentConversationSource as d, type AgentProjectConfig as e, type AgentSurfaceVariant as f, type AgentTheme as g, type AgentTokenClaims as h, agentAuthIdentitySchema as i, agentAuthProfileSchema as j, agentAuthTokenSchema as k, agentIdentityIdSchema as l, agentProjectConfigSchema as m, agentSurfaceVariantSchema as n, agentThemeSchema as o, agentTokenClaimsSchema as p, createAgentAuthTokenRequestSchema as q };
|
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" */
|
|
@@ -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
|
|
518
|
-
*
|
|
519
|
-
*
|
|
520
|
-
*
|
|
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
|
-
|
|
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):
|
|
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,23 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HeroUIAgent,
|
|
3
3
|
useAgent
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-CMZDZGUZ.js";
|
|
5
5
|
import {
|
|
6
6
|
AGENT_DESIGN_THEMES,
|
|
7
7
|
AGENT_MODEL_IDS,
|
|
8
8
|
AGENT_MODEL_OPTIONS,
|
|
9
9
|
DEFAULT_AGENT_PICKER_MODEL_ID,
|
|
10
|
+
HEROUI_AGENT_RUNTIME_TIMING_EVENT,
|
|
10
11
|
LEGACY_AGENT_MODEL_IDS,
|
|
11
12
|
createToolHelper,
|
|
12
13
|
getAgentModelTier,
|
|
13
14
|
isAgentModelId,
|
|
14
15
|
resolveAgentModelId
|
|
15
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-W7SCMB3O.js";
|
|
17
|
+
import "./chunk-Q7LGTVBL.js";
|
|
16
18
|
export {
|
|
17
19
|
AGENT_DESIGN_THEMES,
|
|
18
20
|
AGENT_MODEL_IDS,
|
|
19
21
|
AGENT_MODEL_OPTIONS,
|
|
20
22
|
DEFAULT_AGENT_PICKER_MODEL_ID,
|
|
23
|
+
HEROUI_AGENT_RUNTIME_TIMING_EVENT,
|
|
21
24
|
HeroUIAgent,
|
|
22
25
|
LEGACY_AGENT_MODEL_IDS,
|
|
23
26
|
createToolHelper,
|
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,19 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HeroUIAgent,
|
|
3
3
|
useAgent
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-CMZDZGUZ.js";
|
|
5
5
|
import {
|
|
6
6
|
AGENT_MODEL_IDS,
|
|
7
7
|
AGENT_MODEL_OPTIONS,
|
|
8
8
|
DEFAULT_AGENT_PICKER_MODEL_ID,
|
|
9
|
+
HEROUI_AGENT_RUNTIME_TIMING_EVENT,
|
|
9
10
|
createToolHelper,
|
|
10
11
|
getAgentModelTier,
|
|
11
12
|
isAgentModelId
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-W7SCMB3O.js";
|
|
14
|
+
import "./chunk-Q7LGTVBL.js";
|
|
13
15
|
export {
|
|
14
16
|
AGENT_MODEL_IDS,
|
|
15
17
|
AGENT_MODEL_OPTIONS,
|
|
16
18
|
DEFAULT_AGENT_PICKER_MODEL_ID,
|
|
19
|
+
HEROUI_AGENT_RUNTIME_TIMING_EVENT,
|
|
17
20
|
HeroUIAgent,
|
|
18
21
|
createToolHelper,
|
|
19
22
|
getAgentModelTier,
|
package/dist/server.d.ts
CHANGED
package/dist/server.js
CHANGED
|
@@ -1,82 +1,18 @@
|
|
|
1
1
|
// src/contracts/identity.ts
|
|
2
|
-
import { z as z3 } from "zod";
|
|
3
|
-
|
|
4
|
-
// src/contracts/client-tools.ts
|
|
5
2
|
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
3
|
|
|
67
4
|
// src/contracts/version.ts
|
|
68
|
-
var HEROUI_AGENT_PROTOCOL_VERSION =
|
|
69
|
-
var HEROUI_AGENT_SDK_VERSION = "0.2.0-beta.
|
|
5
|
+
var HEROUI_AGENT_PROTOCOL_VERSION = 6;
|
|
6
|
+
var HEROUI_AGENT_SDK_VERSION = "0.2.0-beta.8";
|
|
70
7
|
|
|
71
8
|
// src/contracts/identity.ts
|
|
72
|
-
var agentThemeSchema =
|
|
73
|
-
var agentSurfaceVariantSchema =
|
|
9
|
+
var agentThemeSchema = z.enum(["light", "dark", "system"]);
|
|
10
|
+
var agentSurfaceVariantSchema = z.enum([
|
|
74
11
|
"outline",
|
|
75
12
|
"plain",
|
|
76
13
|
"surface",
|
|
77
14
|
"surface-secondary"
|
|
78
15
|
]);
|
|
79
|
-
var pageContextSchema = z3.record(z3.string().max(100), z3.unknown());
|
|
80
16
|
var RESERVED_IDENTITY_IDS = /* @__PURE__ */ new Set([
|
|
81
17
|
"[object object]",
|
|
82
18
|
"0",
|
|
@@ -94,25 +30,25 @@ var RESERVED_IDENTITY_IDS = /* @__PURE__ */ new Set([
|
|
|
94
30
|
"true",
|
|
95
31
|
"undefined"
|
|
96
32
|
]);
|
|
97
|
-
var agentIdentityIdSchema =
|
|
33
|
+
var agentIdentityIdSchema = z.string().trim().min(1).max(200).refine((value) => !RESERVED_IDENTITY_IDS.has(value.toLowerCase()), {
|
|
98
34
|
message: "Identity id is reserved"
|
|
99
35
|
});
|
|
100
|
-
var agentAuthIdentitySchema =
|
|
101
|
-
|
|
36
|
+
var agentAuthIdentitySchema = z.discriminatedUnion("type", [
|
|
37
|
+
z.object({
|
|
102
38
|
id: agentIdentityIdSchema,
|
|
103
|
-
type:
|
|
39
|
+
type: z.literal("anonymous")
|
|
104
40
|
}),
|
|
105
|
-
|
|
41
|
+
z.object({
|
|
106
42
|
id: agentIdentityIdSchema,
|
|
107
|
-
type:
|
|
43
|
+
type: z.literal("user")
|
|
108
44
|
})
|
|
109
45
|
]);
|
|
110
|
-
var agentAuthProfileSchema =
|
|
111
|
-
avatarUrl:
|
|
112
|
-
email:
|
|
113
|
-
name:
|
|
46
|
+
var agentAuthProfileSchema = z.object({
|
|
47
|
+
avatarUrl: z.string().trim().pipe(z.url()).optional(),
|
|
48
|
+
email: z.string().trim().max(320).pipe(z.email()).optional(),
|
|
49
|
+
name: z.string().trim().max(120).optional()
|
|
114
50
|
});
|
|
115
|
-
var createAgentAuthTokenRequestSchema =
|
|
51
|
+
var createAgentAuthTokenRequestSchema = z.object({
|
|
116
52
|
/**
|
|
117
53
|
* Browser-scoped id the SDK passed to the host callback. Sending it together
|
|
118
54
|
* with an identified `identity` merges that anonymous person's conversations
|
|
@@ -122,88 +58,28 @@ var createAgentAuthTokenRequestSchema = z3.object({
|
|
|
122
58
|
identity: agentAuthIdentitySchema,
|
|
123
59
|
profile: agentAuthProfileSchema.optional()
|
|
124
60
|
});
|
|
125
|
-
var agentAuthTokenSchema =
|
|
126
|
-
expiresAt:
|
|
127
|
-
token:
|
|
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()
|
|
61
|
+
var agentAuthTokenSchema = z.object({
|
|
62
|
+
expiresAt: z.number().int().positive(),
|
|
63
|
+
token: z.string().trim().min(1)
|
|
191
64
|
});
|
|
192
|
-
var
|
|
193
|
-
|
|
65
|
+
var agentTokenClaimsSchema = z.object({
|
|
66
|
+
agentId: z.string().trim().min(1).max(100),
|
|
67
|
+
apiKeyId: z.string().trim().min(1).max(100),
|
|
68
|
+
aud: z.literal("heroui-agent"),
|
|
69
|
+
exp: z.number().int().positive(),
|
|
70
|
+
iat: z.number().int().positive(),
|
|
71
|
+
iss: z.literal("https://api.heroui.com"),
|
|
72
|
+
jti: z.uuid(),
|
|
73
|
+
protocolVersion: z.literal(HEROUI_AGENT_PROTOCOL_VERSION),
|
|
74
|
+
sub: z.string().trim().min(1).max(200)
|
|
194
75
|
});
|
|
195
|
-
var agentProjectConfigSchema =
|
|
196
|
-
agentId:
|
|
197
|
-
minimumProtocolVersion:
|
|
198
|
-
name:
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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),
|
|
76
|
+
var agentProjectConfigSchema = z.object({
|
|
77
|
+
agentId: z.string(),
|
|
78
|
+
minimumProtocolVersion: z.literal(HEROUI_AGENT_PROTOCOL_VERSION),
|
|
79
|
+
name: z.string().trim().min(1).max(120),
|
|
80
|
+
protocolVersion: z.literal(HEROUI_AGENT_PROTOCOL_VERSION),
|
|
81
|
+
sdkVersion: z.string().default(HEROUI_AGENT_SDK_VERSION),
|
|
82
|
+
suggestedPrompts: z.array(z.string().trim().min(1).max(160)).max(5),
|
|
207
83
|
surfaceVariant: agentSurfaceVariantSchema.default("plain"),
|
|
208
84
|
theme: agentThemeSchema
|
|
209
85
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heroui/agent",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.8",
|
|
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
|
-
"
|
|
75
|
+
"agents": "0.20.1",
|
|
76
76
|
"ai": "7.0.11",
|
|
77
77
|
"maplibre-gl": "5.24.0",
|
|
78
78
|
"motion": "12.38.0",
|