@heroui/agent 0.2.0-beta.6 → 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/dist/contracts.js CHANGED
@@ -2061,12 +2061,13 @@ function renderAgentUICatalogPrompt() {
2061
2061
  // src/contracts/client-tools.ts
2062
2062
  import { z as z2 } from "zod";
2063
2063
  var RESERVED_AGENT_TOOL_NAMES = [
2064
+ "callMcpTool",
2064
2065
  "composeUI",
2065
2066
  "executeSandbox",
2066
2067
  "getComponentSchema",
2067
- "loadUIRenderers",
2068
2068
  "renderComponent",
2069
2069
  "searchKnowledge",
2070
+ "searchMcpTools",
2070
2071
  "searchWeb"
2071
2072
  ];
2072
2073
  var RESERVED_AGENT_TOOL_PREFIX = "mcp_";
@@ -2095,11 +2096,124 @@ var clientToolsSchema = z2.array(clientToolManifestEntrySchema).max(MAX_CLIENT_T
2095
2096
  });
2096
2097
 
2097
2098
  // src/contracts/identity.ts
2098
- import { z as z4 } from "zod";
2099
-
2100
- // src/contracts/models.schema.ts
2101
2099
  import { z as z3 } from "zod";
2102
2100
 
2101
+ // src/contracts/version.ts
2102
+ var HEROUI_AGENT_PROTOCOL_VERSION = 6;
2103
+ var HEROUI_AGENT_SDK_VERSION = "0.2.0-beta.8";
2104
+
2105
+ // src/contracts/identity.ts
2106
+ var agentThemeSchema = z3.enum(["light", "dark", "system"]);
2107
+ var agentSurfaceVariantSchema = z3.enum([
2108
+ "outline",
2109
+ "plain",
2110
+ "surface",
2111
+ "surface-secondary"
2112
+ ]);
2113
+ var RESERVED_IDENTITY_IDS = /* @__PURE__ */ new Set([
2114
+ "[object object]",
2115
+ "0",
2116
+ "anonymous",
2117
+ "distinct_id",
2118
+ "distinctid",
2119
+ "email",
2120
+ "false",
2121
+ "guest",
2122
+ "id",
2123
+ "nan",
2124
+ "none",
2125
+ "not_authenticated",
2126
+ "null",
2127
+ "true",
2128
+ "undefined"
2129
+ ]);
2130
+ var agentIdentityIdSchema = z3.string().trim().min(1).max(200).refine((value) => !RESERVED_IDENTITY_IDS.has(value.toLowerCase()), {
2131
+ message: "Identity id is reserved"
2132
+ });
2133
+ var agentAuthIdentitySchema = z3.discriminatedUnion("type", [
2134
+ z3.object({
2135
+ id: agentIdentityIdSchema,
2136
+ type: z3.literal("anonymous")
2137
+ }),
2138
+ z3.object({
2139
+ id: agentIdentityIdSchema,
2140
+ type: z3.literal("user")
2141
+ })
2142
+ ]);
2143
+ var agentAuthProfileSchema = z3.object({
2144
+ avatarUrl: z3.string().trim().pipe(z3.url()).optional(),
2145
+ email: z3.string().trim().max(320).pipe(z3.email()).optional(),
2146
+ name: z3.string().trim().max(120).optional()
2147
+ });
2148
+ var createAgentAuthTokenRequestSchema = z3.object({
2149
+ /**
2150
+ * Browser-scoped id the SDK passed to the host callback. Sending it together
2151
+ * with an identified `identity` merges that anonymous person's conversations
2152
+ * into the identified user, so history survives login.
2153
+ */
2154
+ anonymousId: agentIdentityIdSchema.optional(),
2155
+ identity: agentAuthIdentitySchema,
2156
+ profile: agentAuthProfileSchema.optional()
2157
+ });
2158
+ var agentAuthTokenSchema = z3.object({
2159
+ expiresAt: z3.number().int().positive(),
2160
+ token: z3.string().trim().min(1)
2161
+ });
2162
+ var agentTokenClaimsSchema = z3.object({
2163
+ agentId: z3.string().trim().min(1).max(100),
2164
+ apiKeyId: z3.string().trim().min(1).max(100),
2165
+ aud: z3.literal("heroui-agent"),
2166
+ exp: z3.number().int().positive(),
2167
+ iat: z3.number().int().positive(),
2168
+ iss: z3.literal("https://api.heroui.com"),
2169
+ jti: z3.uuid(),
2170
+ protocolVersion: z3.literal(HEROUI_AGENT_PROTOCOL_VERSION),
2171
+ sub: z3.string().trim().min(1).max(200)
2172
+ });
2173
+ var AGENT_CONVERSATION_SOURCE = {
2174
+ embed: "embed",
2175
+ preview: "preview"
2176
+ };
2177
+ var agentProjectConfigSchema = z3.object({
2178
+ agentId: z3.string(),
2179
+ minimumProtocolVersion: z3.literal(HEROUI_AGENT_PROTOCOL_VERSION),
2180
+ name: z3.string().trim().min(1).max(120),
2181
+ protocolVersion: z3.literal(HEROUI_AGENT_PROTOCOL_VERSION),
2182
+ sdkVersion: z3.string().default(HEROUI_AGENT_SDK_VERSION),
2183
+ suggestedPrompts: z3.array(z3.string().trim().min(1).max(160)).max(5),
2184
+ surfaceVariant: agentSurfaceVariantSchema.default("plain"),
2185
+ theme: agentThemeSchema
2186
+ });
2187
+
2188
+ // src/contracts/messages.ts
2189
+ import { z as z4 } from "zod";
2190
+ var agentSourceBaseSchema = z4.object({
2191
+ excerpt: z4.string().trim().min(1).max(2e3).optional(),
2192
+ locator: z4.string().trim().min(1).max(160).optional(),
2193
+ sourceId: z4.string().trim().min(1).max(120)
2194
+ });
2195
+ var safeSourceUrlSchema = z4.string().trim().max(2048).refine((value) => {
2196
+ try {
2197
+ return ["http:", "https:"].includes(new URL(value).protocol);
2198
+ } catch {
2199
+ return false;
2200
+ }
2201
+ });
2202
+ var agentSourceSchema = z4.union([
2203
+ agentSourceBaseSchema.extend({
2204
+ sourceType: z4.literal("document"),
2205
+ title: z4.string().trim().min(1).max(200)
2206
+ }),
2207
+ agentSourceBaseSchema.extend({
2208
+ sourceType: z4.literal("url").optional(),
2209
+ title: z4.string().trim().min(1).max(200).optional(),
2210
+ url: safeSourceUrlSchema
2211
+ })
2212
+ ]);
2213
+ var agentSourcesSchema = z4.object({
2214
+ items: z4.array(agentSourceSchema).min(1).max(16)
2215
+ });
2216
+
2103
2217
  // src/contracts/models.ts
2104
2218
  var AGENT_MODEL_IDS = [
2105
2219
  "moonshotai/Kimi-K3",
@@ -2178,228 +2292,17 @@ function getAgentModelTier(modelId) {
2178
2292
  }
2179
2293
 
2180
2294
  // src/contracts/models.schema.ts
2181
- var agentModelIdSchema = z3.preprocess(
2295
+ import { z as z5 } from "zod";
2296
+ var agentModelIdSchema = z5.preprocess(
2182
2297
  (value) => typeof value === "string" ? resolveAgentModelId(value) : value,
2183
- z3.enum(AGENT_MODEL_IDS)
2298
+ z5.enum(AGENT_MODEL_IDS)
2184
2299
  );
2185
2300
 
2186
- // src/contracts/version.ts
2187
- var HEROUI_AGENT_PROTOCOL_VERSION = 5;
2188
- var HEROUI_AGENT_SDK_VERSION = "0.2.0-beta.6";
2189
- var HEROUI_AGENT_TASK_ID = "heroui-agents-runtime";
2190
- var TRUSTED_AGENT_CLIENT_DATA_KEY = "__heroUiAgentApi";
2191
-
2192
- // src/contracts/identity.ts
2193
- var agentThemeSchema = z4.enum(["light", "dark", "system"]);
2194
- var agentSurfaceVariantSchema = z4.enum([
2195
- "outline",
2196
- "plain",
2197
- "surface",
2198
- "surface-secondary"
2199
- ]);
2200
- var pageContextSchema = z4.record(z4.string().max(100), z4.unknown());
2201
- var RESERVED_IDENTITY_IDS = /* @__PURE__ */ new Set([
2202
- "[object object]",
2203
- "0",
2204
- "anonymous",
2205
- "distinct_id",
2206
- "distinctid",
2207
- "email",
2208
- "false",
2209
- "guest",
2210
- "id",
2211
- "nan",
2212
- "none",
2213
- "not_authenticated",
2214
- "null",
2215
- "true",
2216
- "undefined"
2217
- ]);
2218
- var agentIdentityIdSchema = z4.string().trim().min(1).max(200).refine((value) => !RESERVED_IDENTITY_IDS.has(value.toLowerCase()), {
2219
- message: "Identity id is reserved"
2220
- });
2221
- var agentAuthIdentitySchema = z4.discriminatedUnion("type", [
2222
- z4.object({
2223
- id: agentIdentityIdSchema,
2224
- type: z4.literal("anonymous")
2225
- }),
2226
- z4.object({
2227
- id: agentIdentityIdSchema,
2228
- type: z4.literal("user")
2229
- })
2230
- ]);
2231
- var agentAuthProfileSchema = z4.object({
2232
- avatarUrl: z4.string().trim().pipe(z4.url()).optional(),
2233
- email: z4.string().trim().max(320).pipe(z4.email()).optional(),
2234
- name: z4.string().trim().max(120).optional()
2235
- });
2236
- var createAgentAuthTokenRequestSchema = z4.object({
2237
- /**
2238
- * Browser-scoped id the SDK passed to the host callback. Sending it together
2239
- * with an identified `identity` merges that anonymous person's conversations
2240
- * into the identified user, so history survives login.
2241
- */
2242
- anonymousId: agentIdentityIdSchema.optional(),
2243
- identity: agentAuthIdentitySchema,
2244
- profile: agentAuthProfileSchema.optional()
2245
- });
2246
- var agentAuthTokenSchema = z4.object({
2247
- expiresAt: z4.number().int().positive(),
2248
- token: z4.string().trim().min(1)
2249
- });
2250
- var agentTokenClaimsSchema = z4.object({
2251
- agentId: z4.string().trim().min(1).max(100),
2252
- apiKeyId: z4.string().trim().min(1).max(100),
2253
- aud: z4.literal("heroui-agent"),
2254
- exp: z4.number().int().positive(),
2255
- iat: z4.number().int().positive(),
2256
- iss: z4.literal("https://api.heroui.com"),
2257
- jti: z4.uuid(),
2258
- protocolVersion: z4.literal(HEROUI_AGENT_PROTOCOL_VERSION),
2259
- sub: z4.string().trim().min(1).max(200)
2260
- });
2261
- var trustedAgentClientDataSchema = z4.object({
2262
- agentId: z4.string(),
2263
- billingLicenseId: z4.string().nullable(),
2264
- billingOwnerUserId: z4.string(),
2265
- /**
2266
- * Browser-declared client tools the embed can execute for this turn. The
2267
- * runtime registers them as model-visible tools without an execute function.
2268
- */
2269
- clientTools: clientToolsSchema.default([]),
2270
- conversationId: z4.uuid(),
2271
- /**
2272
- * Pseudonymous identity used by persisted conversations. This is signed by
2273
- * the API so the runtime can link telemetry without handling a raw identity.
2274
- */
2275
- endUserKey: z4.string().trim().min(1).max(200).optional(),
2276
- /**
2277
- * When web search is enabled, allow image results via `includeImages`.
2278
- * Defaults to true at the host when omitted; optional here so signed
2279
- * payloads without the field stay valid and keep image search on.
2280
- */
2281
- imageSearch: z4.boolean().optional(),
2282
- /**
2283
- * Optional browser-selected OpenRouter model. The API accepts only the
2284
- * fixed agent allowlist and signs the value before the runtime sees it.
2285
- */
2286
- modelId: agentModelIdSchema.optional(),
2287
- /**
2288
- * When web search is enabled, allow recent news results via `includeNews`.
2289
- * Optional and disabled when omitted so older signed payloads remain valid.
2290
- */
2291
- newsSearch: z4.boolean().optional(),
2292
- pageContext: pageContextSchema.default({}),
2293
- /**
2294
- * Set by the API when the session was authorized by a dashboard preview
2295
- * credential rather than a host API key, so operator traffic can be separated
2296
- * from real visitors. Optional (not defaulted) to keep older signed payloads
2297
- * valid.
2298
- */
2299
- preview: z4.boolean().optional(),
2300
- protocolVersion: z4.literal(HEROUI_AGENT_PROTOCOL_VERSION),
2301
- requestId: z4.uuid(),
2302
- sdkVersion: z4.string().trim().min(1).max(80),
2303
- signedAt: z4.number(),
2304
- subject: z4.string(),
2305
- /**
2306
- * Host-enabled public web search. When true the runtime registers the
2307
- * `searchWeb` tool (if the search backend is configured) so the agent can
2308
- * look up public information, images, and optionally news. Optional (not defaulted) so schema
2309
- * parsing never injects a field into an already-signed payload.
2310
- */
2311
- webSearch: z4.boolean().optional()
2312
- });
2313
- var signedTrustedAgentClientDataSchema = trustedAgentClientDataSchema.extend({
2314
- sig: z4.string().min(1)
2315
- });
2316
- var AGENT_CONVERSATION_SOURCE = {
2317
- embed: "embed",
2318
- preview: "preview"
2319
- };
2320
- var agentProjectConfigSchema = z4.object({
2321
- agentId: z4.string(),
2322
- minimumProtocolVersion: z4.literal(HEROUI_AGENT_PROTOCOL_VERSION),
2323
- name: z4.string().trim().min(1).max(120),
2324
- /**
2325
- * InstantDB app used for ephemeral live-conversation presence. Optional so
2326
- * newer SDKs remain compatible with older Agent API deployments.
2327
- */
2328
- presence: z4.object({ appId: z4.uuid() }).optional(),
2329
- protocolVersion: z4.literal(HEROUI_AGENT_PROTOCOL_VERSION),
2330
- sdkVersion: z4.string().default(HEROUI_AGENT_SDK_VERSION),
2331
- suggestedPrompts: z4.array(z4.string().trim().min(1).max(160)).max(5),
2332
- surfaceVariant: agentSurfaceVariantSchema.default("plain"),
2333
- theme: agentThemeSchema
2334
- });
2335
-
2336
- // src/contracts/messages.ts
2337
- import { z as z5 } from "zod";
2338
- var agentSourceBaseSchema = z5.object({
2339
- excerpt: z5.string().trim().min(1).max(2e3).optional(),
2340
- locator: z5.string().trim().min(1).max(160).optional(),
2341
- sourceId: z5.string().trim().min(1).max(120)
2342
- });
2343
- var safeSourceUrlSchema = z5.string().trim().max(2048).refine((value) => {
2344
- try {
2345
- return ["http:", "https:"].includes(new URL(value).protocol);
2346
- } catch {
2347
- return false;
2348
- }
2349
- });
2350
- var agentSourceSchema = z5.union([
2351
- agentSourceBaseSchema.extend({
2352
- sourceType: z5.literal("document"),
2353
- title: z5.string().trim().min(1).max(200)
2354
- }),
2355
- agentSourceBaseSchema.extend({
2356
- sourceType: z5.literal("url").optional(),
2357
- title: z5.string().trim().min(1).max(200).optional(),
2358
- url: safeSourceUrlSchema
2359
- })
2360
- ]);
2361
- var agentSourcesSchema = z5.object({
2362
- items: z5.array(agentSourceSchema).min(1).max(16)
2363
- });
2364
-
2365
- // src/contracts/trusted.ts
2366
- function canonicalize(value) {
2367
- if (value === null || typeof value !== "object") return JSON.stringify(value);
2368
- if (Array.isArray(value)) return `[${value.map(canonicalize).join(",")}]`;
2369
- const entries = Object.entries(value).filter(([, entryValue]) => entryValue !== void 0).sort(([a], [b]) => a.localeCompare(b)).map(([key2, entryValue]) => `${JSON.stringify(key2)}:${canonicalize(entryValue)}`);
2370
- return `{${entries.join(",")}}`;
2371
- }
2372
- function timingSafeEqual(a, b) {
2373
- if (a.length !== b.length) return false;
2374
- let mismatch = 0;
2375
- for (let index = 0; index < a.length; index += 1) {
2376
- mismatch |= a.charCodeAt(index) ^ b.charCodeAt(index);
2377
- }
2378
- return mismatch === 0;
2379
- }
2380
- async function hmacHex(secret, input) {
2381
- const key2 = await crypto.subtle.importKey(
2382
- "raw",
2383
- new TextEncoder().encode(secret),
2384
- { hash: "SHA-256", name: "HMAC" },
2385
- false,
2386
- ["sign"]
2387
- );
2388
- const signature = await crypto.subtle.sign("HMAC", key2, new TextEncoder().encode(input));
2389
- return Array.from(new Uint8Array(signature), (byte) => byte.toString(16).padStart(2, "0")).join(
2390
- ""
2391
- );
2392
- }
2393
- async function signTrustedAgentClientData(secret, data) {
2394
- return { ...data, sig: await hmacHex(secret, canonicalize(data)) };
2395
- }
2396
- async function verifyTrustedAgentClientData(secret, value) {
2397
- if (!value || typeof value !== "object") return null;
2398
- const { sig, ...data } = value;
2399
- if (typeof sig !== "string" || !sig) return null;
2400
- const expected = await hmacHex(secret, canonicalize(data));
2401
- return timingSafeEqual(sig, expected) ? data : null;
2402
- }
2301
+ // src/contracts/runtime.ts
2302
+ var HEROUI_AGENT_RUNTIME_TIMING_EVENT = "heroui-agent:runtime-timing";
2303
+ var HEROUI_AGENT_TURN_ADMITTED_FRAME_TYPE = "heroui_agent_turn_admitted";
2304
+ var HEROUI_AGENT_TURN_ADMISSION_STATUS_METHOD = "getTurnAdmissionStatuses";
2305
+ var HEROUI_AGENT_TURN_ADMISSION_STATUS_MAX_IDS = 50;
2403
2306
  export {
2404
2307
  AGENT_CONVERSATION_SOURCE,
2405
2308
  AGENT_MODEL_IDS,
@@ -2420,15 +2323,17 @@ export {
2420
2323
  HEROUI_AGENT_MAX_ATTACHMENTS,
2421
2324
  HEROUI_AGENT_PROTOCOL_VERSION,
2422
2325
  HEROUI_AGENT_REMOTE_CONFIG_VERSION,
2326
+ HEROUI_AGENT_RUNTIME_TIMING_EVENT,
2423
2327
  HEROUI_AGENT_SDK_VERSION,
2424
- HEROUI_AGENT_TASK_ID,
2425
2328
  HEROUI_AGENT_TEXT_ATTACHMENT_CONTENT_TYPES,
2329
+ HEROUI_AGENT_TURN_ADMISSION_STATUS_MAX_IDS,
2330
+ HEROUI_AGENT_TURN_ADMISSION_STATUS_METHOD,
2331
+ HEROUI_AGENT_TURN_ADMITTED_FRAME_TYPE,
2426
2332
  LEGACY_AGENT_MODEL_IDS,
2427
2333
  MAX_CLIENT_TOOLS,
2428
2334
  MAX_CLIENT_TOOLS_BYTES,
2429
2335
  RESERVED_AGENT_TOOL_NAMES,
2430
2336
  RESERVED_AGENT_TOOL_PREFIX,
2431
- TRUSTED_AGENT_CLIENT_DATA_KEY,
2432
2337
  accordionComponentSchema,
2433
2338
  actionGroupComponentSchema,
2434
2339
  agentAuthIdentitySchema,
@@ -2503,7 +2408,6 @@ export {
2503
2408
  meterListComponentSchema,
2504
2409
  metricGridComponentSchema,
2505
2410
  numberFormatSchema,
2506
- pageContextSchema,
2507
2411
  parseAgentRemoteConfig,
2508
2412
  pieChartComponentSchema,
2509
2413
  playerCardComponentSchema,
@@ -2525,8 +2429,6 @@ export {
2525
2429
  rowComponentSchema,
2526
2430
  sankeyChartComponentSchema,
2527
2431
  scatterChartComponentSchema,
2528
- signTrustedAgentClientData,
2529
- signedTrustedAgentClientDataSchema,
2530
2432
  spacerComponentSchema,
2531
2433
  stepsComponentSchema,
2532
2434
  sunburstChartComponentSchema,
@@ -2535,8 +2437,6 @@ export {
2535
2437
  tagListComponentSchema,
2536
2438
  textComponentSchema,
2537
2439
  toggleGroupComponentSchema,
2538
- trustedAgentClientDataSchema,
2539
- verifyTrustedAgentClientData,
2540
2440
  viewEventComponentSchema,
2541
2441
  weatherConditionSchema,
2542
2442
  weatherConditions,