@heroui/agent 0.2.0-beta.8 → 0.2.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/dist/chart-content-BBHQVMP4.js +1 -0
- package/dist/chunk-2XBFFSW2.js +1 -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-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/chunk-SUDHJNTJ.js +2 -0
- package/dist/chunk-WUAFMD7Z.js +2 -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 +1 -1
- package/dist/contracts.js +2 -2445
- package/dist/embed-runtime-GYXK7V6N.js +5 -0
- package/dist/index.js +1 -31
- 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.js +1 -25
- package/dist/server.js +1 -136
- package/package.json +4 -4
- package/dist/chart-content-E4NPTUPR.js +0 -2696
- package/dist/chunk-3FG5NRTX.js +0 -9
- package/dist/chunk-CMZDZGUZ.js +0 -1132
- package/dist/chunk-DS4X5K2R.js +0 -56
- package/dist/chunk-FNGGMHVR.js +0 -625
- package/dist/chunk-G6GFNSG4.js +0 -284
- package/dist/chunk-Q7LGTVBL.js +0 -43
- package/dist/chunk-TOOT6SZ2.js +0 -74
- package/dist/chunk-UUPU3MYB.js +0 -42
- package/dist/chunk-VJA52U5P.js +0 -137
- package/dist/chunk-W7SCMB3O.js +0 -1285
- package/dist/component-renderer-MDDQMQTU.js +0 -10629
- package/dist/composer-draft-DTQAEO5K.js +0 -20
- package/dist/composer-image-draft-IVJ352E6.js +0 -174
- package/dist/embed-runtime-VVAGDPYY.js +0 -9422
- package/dist/interactive-map-surface-67KHT3VB.js +0 -362
package/dist/server.js
CHANGED
|
@@ -1,136 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
// src/contracts/version.ts
|
|
5
|
-
var HEROUI_AGENT_PROTOCOL_VERSION = 6;
|
|
6
|
-
var HEROUI_AGENT_SDK_VERSION = "0.2.0-beta.8";
|
|
7
|
-
|
|
8
|
-
// src/contracts/identity.ts
|
|
9
|
-
var agentThemeSchema = z.enum(["light", "dark", "system"]);
|
|
10
|
-
var agentSurfaceVariantSchema = z.enum([
|
|
11
|
-
"outline",
|
|
12
|
-
"plain",
|
|
13
|
-
"surface",
|
|
14
|
-
"surface-secondary"
|
|
15
|
-
]);
|
|
16
|
-
var RESERVED_IDENTITY_IDS = /* @__PURE__ */ new Set([
|
|
17
|
-
"[object object]",
|
|
18
|
-
"0",
|
|
19
|
-
"anonymous",
|
|
20
|
-
"distinct_id",
|
|
21
|
-
"distinctid",
|
|
22
|
-
"email",
|
|
23
|
-
"false",
|
|
24
|
-
"guest",
|
|
25
|
-
"id",
|
|
26
|
-
"nan",
|
|
27
|
-
"none",
|
|
28
|
-
"not_authenticated",
|
|
29
|
-
"null",
|
|
30
|
-
"true",
|
|
31
|
-
"undefined"
|
|
32
|
-
]);
|
|
33
|
-
var agentIdentityIdSchema = z.string().trim().min(1).max(200).refine((value) => !RESERVED_IDENTITY_IDS.has(value.toLowerCase()), {
|
|
34
|
-
message: "Identity id is reserved"
|
|
35
|
-
});
|
|
36
|
-
var agentAuthIdentitySchema = z.discriminatedUnion("type", [
|
|
37
|
-
z.object({
|
|
38
|
-
id: agentIdentityIdSchema,
|
|
39
|
-
type: z.literal("anonymous")
|
|
40
|
-
}),
|
|
41
|
-
z.object({
|
|
42
|
-
id: agentIdentityIdSchema,
|
|
43
|
-
type: z.literal("user")
|
|
44
|
-
})
|
|
45
|
-
]);
|
|
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()
|
|
50
|
-
});
|
|
51
|
-
var createAgentAuthTokenRequestSchema = z.object({
|
|
52
|
-
/**
|
|
53
|
-
* Browser-scoped id the SDK passed to the host callback. Sending it together
|
|
54
|
-
* with an identified `identity` merges that anonymous person's conversations
|
|
55
|
-
* into the identified user, so history survives login.
|
|
56
|
-
*/
|
|
57
|
-
anonymousId: agentIdentityIdSchema.optional(),
|
|
58
|
-
identity: agentAuthIdentitySchema,
|
|
59
|
-
profile: agentAuthProfileSchema.optional()
|
|
60
|
-
});
|
|
61
|
-
var agentAuthTokenSchema = z.object({
|
|
62
|
-
expiresAt: z.number().int().positive(),
|
|
63
|
-
token: z.string().trim().min(1)
|
|
64
|
-
});
|
|
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)
|
|
75
|
-
});
|
|
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),
|
|
83
|
-
surfaceVariant: agentSurfaceVariantSchema.default("plain"),
|
|
84
|
-
theme: agentThemeSchema
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
// src/server/index.ts
|
|
88
|
-
var DEFAULT_API_BASE_URL = "https://api.heroui.com";
|
|
89
|
-
var HeroUIAgentAuthError = class extends Error {
|
|
90
|
-
status;
|
|
91
|
-
constructor(message, status, options) {
|
|
92
|
-
super(message, options);
|
|
93
|
-
this.name = "HeroUIAgentAuthError";
|
|
94
|
-
this.status = status;
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
async function createAuthToken(options) {
|
|
98
|
-
const apiKey = options.apiKey.trim();
|
|
99
|
-
const agentId = options.agentId.trim();
|
|
100
|
-
const request = createAgentAuthTokenRequestSchema.safeParse({
|
|
101
|
-
anonymousId: options.anonymousId,
|
|
102
|
-
identity: options.identity,
|
|
103
|
-
profile: options.profile
|
|
104
|
-
});
|
|
105
|
-
if (!apiKey || !agentId || !request.success) {
|
|
106
|
-
throw new HeroUIAgentAuthError("Invalid HeroUI Agent auth token request", 400);
|
|
107
|
-
}
|
|
108
|
-
const apiBaseUrl = (options.apiBaseUrl?.trim() || DEFAULT_API_BASE_URL).replace(/\/$/, "");
|
|
109
|
-
let response;
|
|
110
|
-
try {
|
|
111
|
-
response = await fetch(`${apiBaseUrl}/v1/agents/${encodeURIComponent(agentId)}/auth-tokens`, {
|
|
112
|
-
body: JSON.stringify(request.data),
|
|
113
|
-
cache: "no-store",
|
|
114
|
-
headers: {
|
|
115
|
-
Accept: "application/json",
|
|
116
|
-
"Content-Type": "application/json",
|
|
117
|
-
"X-HeroUI-Agent-Key": apiKey
|
|
118
|
-
},
|
|
119
|
-
method: "POST"
|
|
120
|
-
});
|
|
121
|
-
} catch (cause) {
|
|
122
|
-
throw new HeroUIAgentAuthError("HeroUI Agent authentication is unavailable", 503, { cause });
|
|
123
|
-
}
|
|
124
|
-
if (!response.ok) {
|
|
125
|
-
throw new HeroUIAgentAuthError("HeroUI Agent authentication failed", response.status);
|
|
126
|
-
}
|
|
127
|
-
const parsed = agentAuthTokenSchema.safeParse(await response.json().catch(() => null));
|
|
128
|
-
if (!parsed.success) {
|
|
129
|
-
throw new HeroUIAgentAuthError("HeroUI Agent authentication returned invalid data", 502);
|
|
130
|
-
}
|
|
131
|
-
return parsed.data;
|
|
132
|
-
}
|
|
133
|
-
export {
|
|
134
|
-
HeroUIAgentAuthError,
|
|
135
|
-
createAuthToken
|
|
136
|
-
};
|
|
1
|
+
import{z as e}from"zod";var m="0.2.0-beta.9";var d=e.enum(["light","dark","system"]),A=e.enum(["outline","plain","surface","surface-secondary"]),y=new Set(["[object object]","0","anonymous","distinct_id","distinctid","email","false","guest","id","nan","none","not_authenticated","null","true","undefined"]),c=e.string().trim().min(1).max(200).refine(t=>!y.has(t.toLowerCase()),{message:"Identity id is reserved"}),f=e.discriminatedUnion("type",[e.object({id:c,type:e.literal("anonymous")}),e.object({id:c,type:e.literal("user")})]),S=e.object({avatarUrl:e.string().trim().pipe(e.url()).optional(),email:e.string().trim().max(320).pipe(e.email()).optional(),name:e.string().trim().max(120).optional()}),u=e.object({anonymousId:c.optional(),identity:f,profile:S.optional()}),g=e.object({expiresAt:e.number().int().positive(),token:e.string().trim().min(1)}),O=e.object({agentId:e.string().trim().min(1).max(100),apiKeyId:e.string().trim().min(1).max(100),aud:e.literal("heroui-agent"),exp:e.number().int().positive(),iat:e.number().int().positive(),iss:e.literal("https://api.heroui.com"),jti:e.uuid(),protocolVersion:e.literal(6),sub:e.string().trim().min(1).max(200)});var R=e.object({agentId:e.string(),minimumProtocolVersion:e.literal(6),name:e.string().trim().min(1).max(120),protocolVersion:e.literal(6),sdkVersion:e.string().default(m),suggestedPrompts:e.array(e.string().trim().min(1).max(160)).max(5),surfaceVariant:A.default("plain"),theme:d});var I="https://api.heroui.com",n=class extends Error{status;constructor(o,i,a){super(o,a),this.name="HeroUIAgentAuthError",this.status=i}};async function C(t){let o=t.apiKey.trim(),i=t.agentId.trim(),a=u.safeParse({anonymousId:t.anonymousId,identity:t.identity,profile:t.profile});if(!o||!i||!a.success)throw new n("Invalid HeroUI Agent auth token request",400);let h=(t.apiBaseUrl?.trim()||I).replace(/\/$/,""),r;try{r=await fetch(`${h}/v1/agents/${encodeURIComponent(i)}/auth-tokens`,{body:JSON.stringify(a.data),cache:"no-store",headers:{Accept:"application/json","Content-Type":"application/json","X-HeroUI-Agent-Key":o},method:"POST"})}catch(l){throw new n("HeroUI Agent authentication is unavailable",503,{cause:l})}if(!r.ok)throw new n("HeroUI Agent authentication failed",r.status);let p=g.safeParse(await r.json().catch(()=>null));if(!p.success)throw new n("HeroUI Agent authentication returned invalid data",502);return p.data}export{n as HeroUIAgentAuthError,C as createAuthToken};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heroui/agent",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.9",
|
|
4
4
|
"description": "Embed a hosted HeroUI Agent that turns application data into interactive UI.",
|
|
5
5
|
"homepage": "https://www.heroui.com/agents",
|
|
6
6
|
"bugs": {
|
|
@@ -109,10 +109,10 @@
|
|
|
109
109
|
"tsup": "8.5.0",
|
|
110
110
|
"typescript": "5.9.3",
|
|
111
111
|
"vitest": "4.1.0",
|
|
112
|
-
"@heroui-pro/config": "0.0.0",
|
|
113
|
-
"@heroui-pro/react": "1.0.0-beta.8",
|
|
114
112
|
"@heroui/agent-client": "0.0.0",
|
|
115
|
-
"@heroui/
|
|
113
|
+
"@heroui-pro/react": "1.0.0-beta.8",
|
|
114
|
+
"@heroui/agent-ui": "0.0.0",
|
|
115
|
+
"@heroui-pro/config": "0.0.0"
|
|
116
116
|
},
|
|
117
117
|
"scripts": {
|
|
118
118
|
"build": "rm -rf dist && tsup && pnpm build:styles",
|