@heroui/agent 1.0.0-beta.1 → 1.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -0
- package/README.md +195 -72
- package/dist/chunk-23EBJXRA.js +1 -0
- package/dist/chunk-5CSSZ76R.js +1 -0
- package/dist/chunk-AR424OVX.js +1 -0
- package/dist/chunk-FZXNXBTZ.js +1 -0
- package/dist/chunk-KFWXAD55.js +1 -0
- package/dist/chunk-MB3T5S5N.js +1 -0
- package/dist/client-tools-manifest-PCUOVUXR.js +1 -0
- package/dist/css/index.css +1 -2
- package/dist/index.d.ts +9 -669
- package/dist/index.js +1 -1
- package/dist/internal/host.d.ts +188 -0
- package/dist/internal/host.js +1 -0
- package/dist/internal/shared.d.ts +67 -0
- package/dist/internal/shared.js +1 -0
- package/dist/next.d.ts +3 -4
- package/dist/next.js +1 -1
- package/dist/persistence-YI6JSYCT.js +1 -0
- package/dist/server.d.ts +23 -2
- package/dist/server.js +1 -1
- package/dist/types-C3g7R0hr.d.ts +592 -0
- package/dist/version-LiwSi-9e.d.ts +5 -0
- package/dist/zod.d.ts +1 -0
- package/dist/zod.js +5 -0
- package/package.json +25 -37
- package/dist/chart-content-BBHQVMP4.js +0 -1
- package/dist/chunk-4JEZZR5J.js +0 -1
- package/dist/chunk-5RHO3S5E.js +0 -2
- package/dist/chunk-64RI74L5.js +0 -1
- package/dist/chunk-6ZJJN322.js +0 -1
- package/dist/chunk-7KCGPNEN.js +0 -1
- package/dist/chunk-BBB5EHDN.js +0 -5
- package/dist/chunk-CLHBM3HQ.js +0 -1
- package/dist/chunk-CR3H7AVI.js +0 -1
- package/dist/chunk-HCLXS4HQ.js +0 -1
- package/dist/chunk-PZJ4NC3J.js +0 -1
- package/dist/chunk-RNNGE7KM.js +0 -1
- package/dist/chunk-S6OIAJSC.js +0 -1
- package/dist/chunk-UHHKMESI.js +0 -1
- package/dist/chunk-USFF5UMB.js +0 -2
- package/dist/component-renderer-XOCP6UFF.js +0 -1
- package/dist/composer-draft-NSKK65F3.js +0 -1
- package/dist/composer-image-draft-KAGTNQR7.js +0 -1
- package/dist/contracts.d.ts +0 -1651
- package/dist/contracts.js +0 -2
- package/dist/embed-runtime-FP77ORXA.js +0 -5
- package/dist/identity-3P8-17km.d.ts +0 -95
- package/dist/interactive-map-surface-WC2LPCR7.js +0 -1
- package/dist/internal/client-tools.js +0 -1
- package/dist/internal/models.js +0 -1
- package/dist/internal/runtime.js +0 -1
- package/dist/internal/theme.js +0 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as d,b as e}from"./chunk-MB3T5S5N.js";import"./chunk-5CSSZ76R.js";import{a as f}from"./chunk-AR424OVX.js";import{a as b,b as c}from"./chunk-23EBJXRA.js";import{a}from"./chunk-FZXNXBTZ.js";export{f as DEFAULT_MARKDOWN_ANIMATION,c as HEROUI_AGENT_API_BASE_URL,b as HEROUI_AGENT_SDK_VERSION,e as HeroUIAgent,a as createToolHelper,d as useAgent};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { L as AgentViewMode, O as ClientToolIcon, m as AgentError, V as UploadAgentDataSourceInput, B as AgentResponseFeedback, F as AgentStatus, i as AgentController, U as HeroUIAgentProps, M as ClientTool, S as GetAuthToken } from '../types-C3g7R0hr.js';
|
|
2
|
+
export { X as parseClientToolArgs, Y as resolveDirectToolAction } from '../types-C3g7R0hr.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
|
|
5
|
+
type HostedFrameBounds = {
|
|
6
|
+
bottom: number;
|
|
7
|
+
left: number;
|
|
8
|
+
right: number;
|
|
9
|
+
top: number;
|
|
10
|
+
};
|
|
11
|
+
type HostedFrameState = {
|
|
12
|
+
bounds: HostedFrameBounds | null;
|
|
13
|
+
closing: boolean;
|
|
14
|
+
dragging: boolean;
|
|
15
|
+
expanded: boolean;
|
|
16
|
+
mounted: boolean;
|
|
17
|
+
open: boolean;
|
|
18
|
+
overlayOpen: boolean;
|
|
19
|
+
ready: boolean;
|
|
20
|
+
resizing: boolean;
|
|
21
|
+
sidebarWidth: number | null;
|
|
22
|
+
viewMode: AgentViewMode;
|
|
23
|
+
};
|
|
24
|
+
type HostPageLayout = {
|
|
25
|
+
active: boolean;
|
|
26
|
+
body: HTMLElement;
|
|
27
|
+
original: {
|
|
28
|
+
bodyLeft: string;
|
|
29
|
+
bodyOverflow: string;
|
|
30
|
+
bodyPosition: string;
|
|
31
|
+
bodyRight: string;
|
|
32
|
+
bodyTop: string;
|
|
33
|
+
bodyWidth: string;
|
|
34
|
+
rootMarginRight: string;
|
|
35
|
+
rootOverflow: string;
|
|
36
|
+
rootTransition: string;
|
|
37
|
+
};
|
|
38
|
+
root: HTMLElement;
|
|
39
|
+
scrollLock: {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
} | null;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
declare const HEROUI_AGENT_HOSTED_ORIGIN: "https://agent.heroui.pro";
|
|
46
|
+
declare const HEROUI_AGENT_HOSTED_STAGING_ORIGIN: "https://staging-agent.heroui.pro";
|
|
47
|
+
declare const HEROUI_AGENT_BRIDGE_MAX_MESSAGE_BYTES: number;
|
|
48
|
+
declare const HEROUI_AGENT_BRIDGE_MAX_PERSISTENCE_BYTES: number;
|
|
49
|
+
type AgentBridgeJsonValue = boolean | null | number | string | AgentBridgeJsonValue[] | {
|
|
50
|
+
[key: string]: AgentBridgeJsonValue;
|
|
51
|
+
};
|
|
52
|
+
type HostedAgentToolManifest = {
|
|
53
|
+
description: string;
|
|
54
|
+
displayName?: string;
|
|
55
|
+
icon?: ClientToolIcon;
|
|
56
|
+
iconColor?: string;
|
|
57
|
+
inputSchema: Record<string, unknown>;
|
|
58
|
+
name: string;
|
|
59
|
+
needsApproval?: boolean;
|
|
60
|
+
};
|
|
61
|
+
type HostedAgentInit = {
|
|
62
|
+
restoreSession?: boolean;
|
|
63
|
+
localStorage: Record<string, string>;
|
|
64
|
+
sessionStorage: Record<string, string>;
|
|
65
|
+
props: Record<string, unknown>;
|
|
66
|
+
tools: HostedAgentToolManifest[];
|
|
67
|
+
};
|
|
68
|
+
type AgentPersistenceRequest = {
|
|
69
|
+
store: "composer-image-drafts" | "message-outboxes";
|
|
70
|
+
operation: "get" | "put" | "delete" | "deletePrefix";
|
|
71
|
+
key?: string;
|
|
72
|
+
prefix?: string;
|
|
73
|
+
value?: unknown;
|
|
74
|
+
};
|
|
75
|
+
type AgentBridgePayloads = {
|
|
76
|
+
"host.command": {
|
|
77
|
+
name: string;
|
|
78
|
+
payload?: unknown;
|
|
79
|
+
};
|
|
80
|
+
"host.init": HostedAgentInit;
|
|
81
|
+
"host.init-error": AgentError;
|
|
82
|
+
"host.update": HostedAgentInit;
|
|
83
|
+
"host.rpc-result": {
|
|
84
|
+
value: unknown;
|
|
85
|
+
};
|
|
86
|
+
"host.rpc-error": {
|
|
87
|
+
error: string;
|
|
88
|
+
code?: string;
|
|
89
|
+
};
|
|
90
|
+
"host.upload-data-source": {
|
|
91
|
+
toolCallId: string;
|
|
92
|
+
upload: UploadAgentDataSourceInput;
|
|
93
|
+
};
|
|
94
|
+
"iframe.ready": undefined;
|
|
95
|
+
"iframe.reload": undefined;
|
|
96
|
+
"iframe.auth-request": undefined;
|
|
97
|
+
"iframe.context-request": undefined;
|
|
98
|
+
"iframe.feedback": AgentResponseFeedback;
|
|
99
|
+
"iframe.persistence": AgentPersistenceRequest;
|
|
100
|
+
"iframe.state": HostedFrameState;
|
|
101
|
+
"iframe.storage": {
|
|
102
|
+
operation: "set" | "remove" | "clear";
|
|
103
|
+
storage: "local" | "session";
|
|
104
|
+
key?: string;
|
|
105
|
+
value?: string;
|
|
106
|
+
};
|
|
107
|
+
"iframe.rpc-result": {
|
|
108
|
+
value: unknown;
|
|
109
|
+
};
|
|
110
|
+
"iframe.rpc-error": {
|
|
111
|
+
error: string;
|
|
112
|
+
};
|
|
113
|
+
"iframe.error": AgentError;
|
|
114
|
+
"iframe.status": AgentStatus;
|
|
115
|
+
"iframe.tool-cancel": {
|
|
116
|
+
idempotencyKey: string;
|
|
117
|
+
};
|
|
118
|
+
"iframe.tool-execute": {
|
|
119
|
+
args: unknown;
|
|
120
|
+
conversationId: string;
|
|
121
|
+
idempotencyKey: string;
|
|
122
|
+
name: string;
|
|
123
|
+
toolCallId: string;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
type AgentBridgeMessageType = keyof AgentBridgePayloads;
|
|
127
|
+
type AgentBridgeEnvelope<T extends AgentBridgeMessageType = AgentBridgeMessageType> = T extends AgentBridgeMessageType ? {
|
|
128
|
+
nonce: string;
|
|
129
|
+
payload?: AgentBridgePayloads[T];
|
|
130
|
+
requestId: string;
|
|
131
|
+
sessionId: string;
|
|
132
|
+
type: T;
|
|
133
|
+
} : never;
|
|
134
|
+
declare function createAgentBridgeEnvelope<T extends AgentBridgeMessageType>(sessionId: string, nonce: string, type: T, payload?: AgentBridgePayloads[T], requestId?: string): AgentBridgeEnvelope<T>;
|
|
135
|
+
declare function parseAgentBridgeEnvelope(value: unknown): AgentBridgeEnvelope | null;
|
|
136
|
+
declare function isAgentBridgeJsonValue(value: unknown, seen?: Set<object>): value is AgentBridgeJsonValue;
|
|
137
|
+
declare function estimateAgentBridgeMessageBytes(value: unknown): number;
|
|
138
|
+
|
|
139
|
+
/** Bounds even callbacks that do not cooperate with cancellation. */
|
|
140
|
+
declare function abortable<T>(signal: AbortSignal, work: () => Promise<T>): Promise<T>;
|
|
141
|
+
declare function withDeadline<T>(milliseconds: number, work: (signal: AbortSignal) => Promise<T>, parent?: AbortSignal): Promise<T>;
|
|
142
|
+
|
|
143
|
+
declare function createAgentError(cause: unknown, phase?: AgentStatus): AgentError;
|
|
144
|
+
|
|
145
|
+
type AgentHostController = AgentController & {
|
|
146
|
+
destroy: () => void;
|
|
147
|
+
subscribe: (listener: () => void) => () => void;
|
|
148
|
+
update: (options: HeroUIAgentProps) => void;
|
|
149
|
+
};
|
|
150
|
+
type ClientToolManifestSerializer = (tools: ClientTool[]) => HostedAgentToolManifest[] | Promise<HostedAgentToolManifest[]>;
|
|
151
|
+
declare function mountAgent(initialOptions: HeroUIAgentProps, serializeTools: ClientToolManifestSerializer): AgentHostController;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Requests a short-lived HeroUI Agent credential through the host
|
|
155
|
+
* application's server callback. Refresh and request de-duplication are
|
|
156
|
+
* handled here while the project API key remains server-only.
|
|
157
|
+
*/
|
|
158
|
+
declare class EmbedSessionManager {
|
|
159
|
+
private readonly agentId;
|
|
160
|
+
private readonly getAuthToken;
|
|
161
|
+
private cached;
|
|
162
|
+
private failure;
|
|
163
|
+
private generation;
|
|
164
|
+
private pending;
|
|
165
|
+
private controller;
|
|
166
|
+
constructor(agentId: string, getAuthToken: GetAuthToken);
|
|
167
|
+
clear(): void;
|
|
168
|
+
/**
|
|
169
|
+
* Forgets both the cached credential and the browser's anonymous id, so the
|
|
170
|
+
* next request represents a brand-new person. Used on logout to stop a
|
|
171
|
+
* shared device from attributing the next visitor to the previous user.
|
|
172
|
+
*/
|
|
173
|
+
reset(): void;
|
|
174
|
+
get(): Promise<string>;
|
|
175
|
+
subjectHash(): Promise<string>;
|
|
176
|
+
private anonymousId;
|
|
177
|
+
private expiresAt;
|
|
178
|
+
private refresh;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
declare class ClientToolResultError extends Error {
|
|
182
|
+
readonly code: "CLIENT_TOOL_RESULT_TOO_LARGE" | "CLIENT_TOOL_RESULT_NOT_SERIALIZABLE";
|
|
183
|
+
constructor(code: "CLIENT_TOOL_RESULT_TOO_LARGE" | "CLIENT_TOOL_RESULT_NOT_SERIALIZABLE", message: string);
|
|
184
|
+
}
|
|
185
|
+
/** Validate before crossing the bridge or persisting a replayable receipt. */
|
|
186
|
+
declare function serializeClientToolResult(value: unknown): unknown;
|
|
187
|
+
|
|
188
|
+
export { type AgentBridgeEnvelope, type AgentBridgeJsonValue, type AgentBridgeMessageType, type AgentBridgePayloads, type AgentHostController, type AgentPersistenceRequest, type ClientToolManifestSerializer, ClientToolResultError, EmbedSessionManager, HEROUI_AGENT_BRIDGE_MAX_MESSAGE_BYTES, HEROUI_AGENT_BRIDGE_MAX_PERSISTENCE_BYTES, HEROUI_AGENT_HOSTED_ORIGIN, HEROUI_AGENT_HOSTED_STAGING_ORIGIN, type HostPageLayout, type HostedAgentInit, type HostedAgentToolManifest, type HostedFrameState, abortable, createAgentBridgeEnvelope, createAgentError, estimateAgentBridgeMessageBytes, isAgentBridgeJsonValue, mountAgent, parseAgentBridgeEnvelope, serializeClientToolResult, withDeadline };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as r,b as t,c as l,d as a,e as i,f as n,g as s}from"../chunk-5CSSZ76R.js";import"../chunk-23EBJXRA.js";import{c as o,d as e,i as m,j as p,k as f,l as x,m as g,n as u,o as A,p as C}from"../chunk-FZXNXBTZ.js";export{i as ClientToolResultError,a as EmbedSessionManager,f as HEROUI_AGENT_BRIDGE_MAX_MESSAGE_BYTES,x as HEROUI_AGENT_BRIDGE_MAX_PERSISTENCE_BYTES,m as HEROUI_AGENT_HOSTED_ORIGIN,p as HEROUI_AGENT_HOSTED_STAGING_ORIGIN,r as abortable,g as createAgentBridgeEnvelope,l as createAgentError,C as estimateAgentBridgeMessageBytes,A as isAgentBridgeJsonValue,s as mountAgent,u as parseAgentBridgeEnvelope,o as parseClientToolArgs,e as resolveDirectToolAction,n as serializeClientToolResult,t as withDeadline};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export { H as HEROUI_AGENT_API_BASE_URL, a as HEROUI_AGENT_SDK_VERSION } from '../version-LiwSi-9e.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { M as ClientTool } from '../types-C3g7R0hr.js';
|
|
4
|
+
export { R as DEFAULT_MARKDOWN_ANIMATION } from '../types-C3g7R0hr.js';
|
|
5
|
+
import 'react';
|
|
6
|
+
|
|
7
|
+
declare const agentIdentityIdSchema: z.ZodString;
|
|
8
|
+
declare const agentAuthIdentitySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
9
|
+
id: z.ZodString;
|
|
10
|
+
type: z.ZodLiteral<"anonymous">;
|
|
11
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
12
|
+
id: z.ZodString;
|
|
13
|
+
type: z.ZodLiteral<"user">;
|
|
14
|
+
}, z.core.$strip>], "type">;
|
|
15
|
+
declare const agentAuthProfileSchema: z.ZodObject<{
|
|
16
|
+
avatarUrl: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodURL>>;
|
|
17
|
+
email: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodEmail>>;
|
|
18
|
+
name: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
/** Descriptive server-assigned labels, never authorization or prompt context. */
|
|
21
|
+
declare const agentAuthMetadataSchema: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
22
|
+
declare const createAgentAuthTokenRequestSchema: z.ZodObject<{
|
|
23
|
+
anonymousId: z.ZodOptional<z.ZodString>;
|
|
24
|
+
identity: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
25
|
+
id: z.ZodString;
|
|
26
|
+
type: z.ZodLiteral<"anonymous">;
|
|
27
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
28
|
+
id: z.ZodString;
|
|
29
|
+
type: z.ZodLiteral<"user">;
|
|
30
|
+
}, z.core.$strip>], "type">;
|
|
31
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
32
|
+
profile: z.ZodOptional<z.ZodObject<{
|
|
33
|
+
avatarUrl: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodURL>>;
|
|
34
|
+
email: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodEmail>>;
|
|
35
|
+
name: z.ZodOptional<z.ZodString>;
|
|
36
|
+
}, z.core.$strip>>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
declare const agentAuthTokenSchema: z.ZodObject<{
|
|
39
|
+
expiresAt: z.ZodNumber;
|
|
40
|
+
token: z.ZodString;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
type AgentAuthIdentity = z.infer<typeof agentAuthIdentitySchema>;
|
|
43
|
+
type AgentAuthProfile = z.infer<typeof agentAuthProfileSchema>;
|
|
44
|
+
type AgentAuthToken = z.infer<typeof agentAuthTokenSchema>;
|
|
45
|
+
type CreateAgentAuthTokenRequest = z.infer<typeof createAgentAuthTokenRequestSchema>;
|
|
46
|
+
|
|
47
|
+
declare const RESERVED_AGENT_TOOL_NAMES: readonly ["readConversationHistory", "callMcpTool", "composeUI", "executeSandbox", "generateFile", "getUIComponents", "readSkill", "renderComponent", "renderDocument", "searchKnowledge", "searchMcpTools", "searchWeb"];
|
|
48
|
+
declare const RESERVED_AGENT_TOOL_PREFIX = "mcp_";
|
|
49
|
+
|
|
50
|
+
declare const MAX_CLIENT_TOOLS = 20;
|
|
51
|
+
declare const MAX_CLIENT_TOOLS_BYTES: number;
|
|
52
|
+
declare const clientToolManifestEntrySchema: z.ZodObject<{
|
|
53
|
+
description: z.ZodString;
|
|
54
|
+
inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
55
|
+
name: z.ZodString;
|
|
56
|
+
needsApproval: z.ZodOptional<z.ZodBoolean>;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
declare const clientToolsSchema: z.ZodArray<z.ZodObject<{
|
|
59
|
+
description: z.ZodString;
|
|
60
|
+
inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
61
|
+
name: z.ZodString;
|
|
62
|
+
needsApproval: z.ZodOptional<z.ZodBoolean>;
|
|
63
|
+
}, z.core.$strip>>;
|
|
64
|
+
type ClientToolManifestEntry = z.infer<typeof clientToolManifestEntrySchema>;
|
|
65
|
+
declare function serializeClientTools(tools: ClientTool[]): ClientToolManifestEntry[];
|
|
66
|
+
|
|
67
|
+
export { type AgentAuthIdentity, type AgentAuthProfile, type AgentAuthToken, type ClientToolManifestEntry, type CreateAgentAuthTokenRequest, MAX_CLIENT_TOOLS, MAX_CLIENT_TOOLS_BYTES, RESERVED_AGENT_TOOL_NAMES, RESERVED_AGENT_TOOL_PREFIX, agentAuthIdentitySchema, agentAuthMetadataSchema, agentAuthProfileSchema, agentAuthTokenSchema, agentIdentityIdSchema, clientToolManifestEntrySchema, clientToolsSchema, createAgentAuthTokenRequestSchema, serializeClientTools };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as l}from"../chunk-AR424OVX.js";import{a as s,b as A}from"../chunk-23EBJXRA.js";import{a as c,b as h,c as p,d as u,e as g}from"../chunk-KFWXAD55.js";import{e as r,f as m}from"../chunk-FZXNXBTZ.js";import{z as e}from"zod";var d=new Set(["[object object]","0","anonymous","distinct_id","distinctid","email","false","guest","id","nan","none","not_authenticated","null","true","undefined"]),t=e.string().trim().min(1).max(200).refine(n=>!d.has(n.toLowerCase()),{message:"Identity id is reserved"}),o=e.discriminatedUnion("type",[e.object({id:t,type:e.literal("anonymous")}),e.object({id:t,type:e.literal("user")})]),i=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()}),a=e.record(e.string(),e.string()).refine(n=>new TextEncoder().encode(JSON.stringify(n)).byteLength<=4096,{message:"Metadata must not exceed 4 KiB"}),S=e.object({anonymousId:t.optional(),identity:o,metadata:a.optional(),profile:i.optional()}),T=e.object({expiresAt:e.number().int().positive(),token:e.string().trim().min(1)});export{l as DEFAULT_MARKDOWN_ANIMATION,A as HEROUI_AGENT_API_BASE_URL,s as HEROUI_AGENT_SDK_VERSION,c as MAX_CLIENT_TOOLS,h as MAX_CLIENT_TOOLS_BYTES,r as RESERVED_AGENT_TOOL_NAMES,m as RESERVED_AGENT_TOOL_PREFIX,o as agentAuthIdentitySchema,a as agentAuthMetadataSchema,i as agentAuthProfileSchema,T as agentAuthTokenSchema,t as agentIdentityIdSchema,p as clientToolManifestEntrySchema,u as clientToolsSchema,S as createAgentAuthTokenRequestSchema,g as serializeClientTools};
|
package/dist/next.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { A as AgentApiOverrides, a as AgentAppearance, b as AgentAttachmentContentType, c as AgentAuthToken, d as AgentCapabilities, e as AgentColorScheme, f as AgentComponentExportFormat, g as AgentComposerOptions, h as AgentContext, i as AgentController, j as AgentDataSource, k as AgentDataSourceFormat, l as AgentDesignTheme, m as AgentError, n as AgentFeedbackReason, o as AgentLauncherOptions, p as AgentLauncherPosition, q as AgentMarkdownAnimation, r as AgentMarkdownAnimationOptions, s as AgentMarkdownCaret, t as AgentMarkdownOptions, u as AgentMessageAction, v as AgentModelId, w as AgentPanelOptions, x as AgentPermissionMode, y as AgentPermissionOptions, z as AgentRadius, B as AgentResponseFeedback, C as AgentSharedContext, D as AgentShouldCloseOnInteractOutside, E as AgentStartScreenOptions, F as AgentStatus, G as AgentSurfaceVariant, H as AgentThemeColor, I as AgentThemeColors, J as AgentThemeOptions, K as AgentTypography, L as AgentViewMode, M as ClientTool, N as ClientToolExecutionContext, O as ClientToolIcon, P as ClientToolStatus, Q as ClientToolVisualResult, R as DEFAULT_MARKDOWN_ANIMATION, S as GetAuthToken, T as GetAuthTokenContext, U as HeroUIAgentProps, V as UploadAgentDataSourceInput, W as createToolHelper } from './types-C3g7R0hr.js';
|
|
2
|
+
export { HeroUIAgent, useAgent } from './index.js';
|
|
3
|
+
export { H as HEROUI_AGENT_API_BASE_URL, a as HEROUI_AGENT_SDK_VERSION } from './version-LiwSi-9e.js';
|
|
2
4
|
import 'react';
|
|
3
|
-
import 'react/jsx-runtime';
|
|
4
|
-
import 'zod';
|
|
5
|
-
import 'streamdown';
|
package/dist/next.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as f,b as m}from"./chunk-MB3T5S5N.js";import"./chunk-5CSSZ76R.js";import{a as p}from"./chunk-AR424OVX.js";import{a as r,b as e}from"./chunk-23EBJXRA.js";import{a as o}from"./chunk-FZXNXBTZ.js";export{p as DEFAULT_MARKDOWN_ANIMATION,e as HEROUI_AGENT_API_BASE_URL,r as HEROUI_AGENT_SDK_VERSION,m as HeroUIAgent,o as createToolHelper,f as useAgent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var d="heroui-agent-host-storage";var s="records";async function k(r,t){let e=f(t),o=await w();if(!o){if(e.operation==="get")return null;throw new Error("Durable HeroUI Agent storage is unavailable")}try{if(e.operation==="deletePrefix")return await g(o,l(r,e.store,e.prefix)),null;let n=l(r,e.store,e.key),i=o.transaction(s,e.operation==="get"?"readonly":"readwrite"),a=i.objectStore(s);if(e.operation==="get"){let p=await P(a.get(n));return await u(i),p?.value??null}return e.operation==="put"?a.put({id:n,value:e.value}):a.delete(n),await u(i),null}finally{o.close()}}function f(r){if(!r||typeof r!="object")throw new Error("Invalid persistence request");let t=r,e=t.store;if(e!=="composer-image-drafts"&&e!=="message-outboxes")throw new Error("Invalid persistence store");if(t.operation==="deletePrefix"){if(!c(t.prefix))throw new Error("Invalid persistence prefix");return{operation:"deletePrefix",prefix:t.prefix,store:e}}if(t.operation!=="delete"&&t.operation!=="get"&&t.operation!=="put"||!c(t.key))throw new Error("Invalid persistence request");return t.operation==="put"?{key:t.key,operation:"put",store:e,value:t.value}:{key:t.key,operation:t.operation,store:e}}function c(r){return typeof r=="string"&&r.length>0&&r.length<=2048}function l(r,t,e){return`${r}:${t}:${e}`}function w(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((r,t)=>{let e=indexedDB.open(d,1);e.onerror=()=>t(e.error??new Error("Unable to open Agent storage")),e.onupgradeneeded=()=>{e.result.objectStoreNames.contains(s)||e.result.createObjectStore(s,{keyPath:"id"})},e.onsuccess=()=>r(e.result)})}function g(r,t){let e=r.transaction(s,"readwrite"),o=e.objectStore(s).openCursor();return o.onsuccess=()=>{let n=o.result;n&&(typeof n.key=="string"&&n.key.startsWith(t)&&n.delete(),n.continue())},u(e)}function P(r){return new Promise((t,e)=>{r.onerror=()=>e(r.error??new Error("Agent storage request failed")),r.onsuccess=()=>t(r.result)})}function u(r){return new Promise((t,e)=>{r.onabort=()=>e(r.error??new Error("Agent storage write aborted")),r.onerror=()=>e(r.error??new Error("Agent storage transaction failed")),r.oncomplete=()=>t()})}export{k as executeAgentHostPersistence};
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const agentAuthIdentitySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
type: z.ZodLiteral<"anonymous">;
|
|
6
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
7
|
+
id: z.ZodString;
|
|
8
|
+
type: z.ZodLiteral<"user">;
|
|
9
|
+
}, z.core.$strip>], "type">;
|
|
10
|
+
declare const agentAuthProfileSchema: z.ZodObject<{
|
|
11
|
+
avatarUrl: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodURL>>;
|
|
12
|
+
email: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodEmail>>;
|
|
13
|
+
name: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
declare const agentAuthTokenSchema: z.ZodObject<{
|
|
16
|
+
expiresAt: z.ZodNumber;
|
|
17
|
+
token: z.ZodString;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
type AgentAuthIdentity = z.infer<typeof agentAuthIdentitySchema>;
|
|
20
|
+
type AgentAuthProfile = z.infer<typeof agentAuthProfileSchema>;
|
|
21
|
+
type AgentAuthToken = z.infer<typeof agentAuthTokenSchema>;
|
|
3
22
|
|
|
4
23
|
type CreateAuthTokenOptions = {
|
|
5
24
|
/**
|
|
@@ -15,6 +34,8 @@ type CreateAuthTokenOptions = {
|
|
|
15
34
|
identity: AgentAuthIdentity;
|
|
16
35
|
/** Optional end-user profile metadata shown in Agent monitoring. */
|
|
17
36
|
profile?: AgentAuthProfile;
|
|
37
|
+
/** Descriptive run labels shown in Monitor. Maximum 4 KiB; never grants access. */
|
|
38
|
+
metadata?: Record<string, string>;
|
|
18
39
|
agentId: string;
|
|
19
40
|
};
|
|
20
41
|
declare class HeroUIAgentAuthError extends Error {
|
package/dist/server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as
|
|
1
|
+
import{z as t}from"zod";var g=new Set(["[object object]","0","anonymous","distinct_id","distinctid","email","false","guest","id","nan","none","not_authenticated","null","true","undefined"]),s=t.string().trim().min(1).max(200).refine(e=>!g.has(e.toLowerCase()),{message:"Identity id is reserved"}),A=t.discriminatedUnion("type",[t.object({id:s,type:t.literal("anonymous")}),t.object({id:s,type:t.literal("user")})]),l=t.object({avatarUrl:t.string().trim().pipe(t.url()).optional(),email:t.string().trim().max(320).pipe(t.email()).optional(),name:t.string().trim().max(120).optional()}),y=t.record(t.string(),t.string()).refine(e=>new TextEncoder().encode(JSON.stringify(e)).byteLength<=4096,{message:"Metadata must not exceed 4 KiB"}),u=t.object({anonymousId:s.optional(),identity:A,metadata:y.optional(),profile:l.optional()}),p=t.object({expiresAt:t.number().int().positive(),token:t.string().trim().min(1)});var h="https://api.heroui.pro";var n=class extends Error{status;constructor(a,o,i){super(a,i),this.name="HeroUIAgentAuthError",this.status=o}};async function k(e){let a=e.apiKey.trim(),o=e.agentId.trim(),i=u.safeParse({anonymousId:e.anonymousId,identity:e.identity,metadata:e.metadata,profile:e.profile});if(!a||!o||!i.success)throw new n("Invalid HeroUI Agent auth token request",400);let d=(e.apiBaseUrl?.trim()||h).replace(/\/$/,""),r;try{r=await fetch(`${d}/v1/agents/${encodeURIComponent(o)}/auth-tokens`,{body:JSON.stringify(i.data),cache:"no-store",headers:{Accept:"application/json","Content-Type":"application/json","X-HeroUI-Agent-Key":a},method:"POST"})}catch(m){throw new n("HeroUI Agent authentication is unavailable",503,{cause:m})}if(!r.ok)throw new n("HeroUI Agent authentication failed",r.status);let c=p.safeParse(await r.json().catch(()=>null));if(!c.success)throw new n("HeroUI Agent authentication returned invalid data",502);return c.data}export{n as HeroUIAgentAuthError,k as createAuthToken};
|