@helpai/elements 0.12.3 → 0.13.0
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/configurator.mjs +171 -87
- package/elements-web-component.esm.js +27 -27
- package/elements-web-component.esm.js.map +4 -4
- package/elements.cjs.js +27 -27
- package/elements.cjs.js.map +4 -4
- package/elements.esm.js +27 -27
- package/elements.esm.js.map +4 -4
- package/elements.js +28 -28
- package/elements.js.map +4 -4
- package/index.d.ts +143 -2
- package/index.mjs +1470 -502
- package/package.json +1 -1
- package/schema.d.ts +127 -2
- package/schema.json +476 -3
- package/schema.mjs +178 -89
- package/style.css +1 -1
- package/web-component.mjs +1487 -523
package/schema.mjs
CHANGED
|
@@ -17,7 +17,7 @@ var localeSchema = z.string().min(1).max(35).describe("BCP-47 locale tag (e.g. `
|
|
|
17
17
|
var uuid7Schema = z.uuidv7().describe("UUID v7 (RFC 9562) \u2014 the single id format for visitor / session / message / file / content ids.");
|
|
18
18
|
|
|
19
19
|
// src/schema/widget.ts
|
|
20
|
-
import { z as
|
|
20
|
+
import { z as z16 } from "zod";
|
|
21
21
|
|
|
22
22
|
// src/schema/widget/presentation.ts
|
|
23
23
|
import { z as z3 } from "zod";
|
|
@@ -225,6 +225,9 @@ var featureFlagsSchema = z7.object({
|
|
|
225
225
|
),
|
|
226
226
|
tools: z7.array(toolRefSchema).max(200).optional().describe(
|
|
227
227
|
"Backend tools the assistant may invoke. Bare codes (`'tool:send-money'`) or rich refs (`{ code, config }`)."
|
|
228
|
+
),
|
|
229
|
+
humanInLoop: z7.boolean().default(true).describe(
|
|
230
|
+
"Render human-in-the-loop tool UI \u2014 the inline ask-input form + approve/reject controls for gated tools. `true` (default) shows them; `false` suppresses the UI (the wire still carries the signals)."
|
|
228
231
|
)
|
|
229
232
|
}).loose().describe("Capability flags \u2014 file upload, voice mode, and the tools the assistant may invoke.").meta({
|
|
230
233
|
examples: [
|
|
@@ -398,45 +401,121 @@ var i18nSchema = z13.object({
|
|
|
398
401
|
]
|
|
399
402
|
});
|
|
400
403
|
|
|
401
|
-
// src/schema/widget/
|
|
404
|
+
// src/schema/widget/intake.ts
|
|
402
405
|
import { z as z14 } from "zod";
|
|
403
|
-
var
|
|
404
|
-
|
|
405
|
-
|
|
406
|
+
var fieldTypeSchema = z14.enum([
|
|
407
|
+
"text",
|
|
408
|
+
"email",
|
|
409
|
+
"tel",
|
|
410
|
+
"url",
|
|
411
|
+
"number",
|
|
412
|
+
"textarea",
|
|
413
|
+
"select",
|
|
414
|
+
"radio",
|
|
415
|
+
"checkbox",
|
|
416
|
+
"multiselect"
|
|
417
|
+
]);
|
|
418
|
+
var fieldOptionSchema = z14.object({
|
|
419
|
+
value: z14.string().min(1).max(200).describe("The value recorded when this choice is picked."),
|
|
420
|
+
label: z14.string().min(1).max(200).optional().describe("Display text; falls back to `value`."),
|
|
421
|
+
description: z14.string().max(280).optional().describe("Optional sub-label under the choice.")
|
|
422
|
+
}).loose();
|
|
423
|
+
var fieldValidationSchema = z14.object({
|
|
424
|
+
pattern: z14.string().max(500).optional().describe("Regex source string \u2014 text-like fields (e.g. `^\\d{5}$`)."),
|
|
425
|
+
minLength: z14.number().int().min(0).max(1e4).optional(),
|
|
426
|
+
maxLength: z14.number().int().min(1).max(1e4).optional(),
|
|
427
|
+
min: z14.number().optional().describe("Minimum \u2014 `number` fields."),
|
|
428
|
+
max: z14.number().optional().describe("Maximum \u2014 `number` fields."),
|
|
429
|
+
minSelections: z14.number().int().min(0).max(50).optional().describe("Minimum picks \u2014 `multiselect`."),
|
|
430
|
+
maxSelections: z14.number().int().min(1).max(50).optional().describe("Maximum picks \u2014 `multiselect`.")
|
|
431
|
+
}).loose();
|
|
432
|
+
var formFieldSchema = z14.object({
|
|
433
|
+
name: z14.string().min(1).max(80).describe("Stable key the answer is recorded under (e.g. `email`). Sent to the agent as captured context."),
|
|
434
|
+
label: z14.string().min(1).max(200).describe("Visible field label."),
|
|
435
|
+
type: fieldTypeSchema.describe("Field renderer + built-in validation (`email`/`tel`/`url`/`number` are checked)."),
|
|
436
|
+
placeholder: z14.string().max(200).optional(),
|
|
437
|
+
required: z14.boolean().optional().default(true).describe("Must be answered to submit. Set `false` to allow skipping."),
|
|
438
|
+
defaultValue: z14.string().max(2e3).optional().describe("Pre-filled value (comma-join for `multiselect`)."),
|
|
439
|
+
options: z14.array(fieldOptionSchema).max(50).optional().describe("Choices for `select` / `radio` / `multiselect`."),
|
|
440
|
+
validation: fieldValidationSchema.optional(),
|
|
441
|
+
allowOther: z14.boolean().optional().describe("`select`/`radio`/`multiselect` \u2014 allow a free-text 'Other' answer."),
|
|
442
|
+
validationHint: z14.string().max(280).optional().describe("Small helper line under the field.")
|
|
443
|
+
}).loose();
|
|
444
|
+
var intakeSchema = z14.object({
|
|
445
|
+
enabled: z14.boolean().default(false).describe("Turn the pre-chat intake gate on. Off by default."),
|
|
446
|
+
title: z14.string().max(120).optional().describe("Form heading (e.g. 'Before we start')."),
|
|
447
|
+
description: z14.string().max(500).optional().describe("Sub-heading under the title."),
|
|
448
|
+
fields: z14.array(formFieldSchema).max(20).default([]).describe("The questions to ask, in order. The gate is only active when there is \u22651 field."),
|
|
449
|
+
submitLabel: z14.string().max(60).optional().describe("Submit button label (default 'Start chat')."),
|
|
450
|
+
skippable: z14.boolean().default(false).describe("Show a Skip control to dismiss the whole form.")
|
|
451
|
+
}).loose().describe(
|
|
452
|
+
"Pre-chat intake form \u2014 a blocking lead/sales-capture gate of typed, validated fields. The same field shape powers the AI ask-input tool. Off by default."
|
|
453
|
+
).meta({
|
|
454
|
+
examples: [
|
|
455
|
+
{ enabled: false },
|
|
456
|
+
{
|
|
457
|
+
enabled: true,
|
|
458
|
+
title: "Before we start",
|
|
459
|
+
description: "Tell us who you are so we can help faster.",
|
|
460
|
+
submitLabel: "Start chat",
|
|
461
|
+
fields: [
|
|
462
|
+
{ name: "name", label: "Your name", type: "text", required: true },
|
|
463
|
+
{ name: "email", label: "Work email", type: "email", required: true },
|
|
464
|
+
{ name: "phone", label: "Phone", type: "tel", required: false },
|
|
465
|
+
{
|
|
466
|
+
name: "topic",
|
|
467
|
+
label: "What can we help with?",
|
|
468
|
+
type: "select",
|
|
469
|
+
required: true,
|
|
470
|
+
options: [
|
|
471
|
+
{ value: "sales", label: "Talk to sales" },
|
|
472
|
+
{ value: "support", label: "Get support" }
|
|
473
|
+
]
|
|
474
|
+
}
|
|
475
|
+
]
|
|
476
|
+
}
|
|
477
|
+
]
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
// src/schema/widget/modules.ts
|
|
481
|
+
import { z as z15 } from "zod";
|
|
482
|
+
var moduleLayoutSchema = z15.enum(["chat", "home", "help", "news"]);
|
|
483
|
+
var moduleSchema = z15.object({
|
|
484
|
+
label: z15.string().min(1).max(40).describe(
|
|
406
485
|
"Tab label \u2014 an i18n key (resolved against the i18n strings, e.g. `tabHome`) or a literal. Translations ride `i18n.strings`."
|
|
407
486
|
),
|
|
408
487
|
layout: moduleLayoutSchema.describe(
|
|
409
488
|
"UI layout that renders this tab: `chat` (the conversation), `home`, `help`, or `news`."
|
|
410
489
|
),
|
|
411
|
-
contentTags:
|
|
490
|
+
contentTags: z15.array(z15.string().max(60)).max(20).optional().describe(
|
|
412
491
|
"Content tags this tab scopes to \u2014 the `tags` filter on `GET /ai/agent/content` (matches content tagged with ANY of them). Omit for the `chat` layout."
|
|
413
492
|
),
|
|
414
|
-
id:
|
|
493
|
+
id: z15.string().max(60).optional().describe(
|
|
415
494
|
"Stable id for navigation + last-tab persistence. Defaults to the first `contentTags` entry, else `layout`."
|
|
416
495
|
),
|
|
417
496
|
// ── `home` layout config (flat feature flags — no block authoring) ──────
|
|
418
|
-
brandName:
|
|
419
|
-
showGreeting:
|
|
420
|
-
greetingText:
|
|
421
|
-
userAvatars:
|
|
422
|
-
|
|
423
|
-
name:
|
|
424
|
-
avatar:
|
|
425
|
-
role:
|
|
497
|
+
brandName: z15.string().max(80).optional().describe("`home` \u2014 hero wordmark (e.g. your company name)."),
|
|
498
|
+
showGreeting: z15.boolean().optional().describe("`home` \u2014 show the greeting hero (default true)."),
|
|
499
|
+
greetingText: z15.string().max(280).optional().describe("`home` \u2014 override the greeting headline (default 'How can we help?'); supports a `{name}` token."),
|
|
500
|
+
userAvatars: z15.array(
|
|
501
|
+
z15.object({
|
|
502
|
+
name: z15.string().min(1).max(80),
|
|
503
|
+
avatar: z15.string().max(2048).optional().describe("Image URL; falls back to initials of `name`."),
|
|
504
|
+
role: z15.string().max(80).optional()
|
|
426
505
|
}).loose()
|
|
427
506
|
).max(10).optional().describe("`home` \u2014 team/agent avatars shown in the hero."),
|
|
428
|
-
showSearchBar:
|
|
429
|
-
showRecentMessages:
|
|
430
|
-
status:
|
|
431
|
-
text:
|
|
432
|
-
level:
|
|
507
|
+
showSearchBar: z15.boolean().optional().describe("`home` \u2014 show the 'Search for help' bar (default true)."),
|
|
508
|
+
showRecentMessages: z15.boolean().optional().describe("`home` \u2014 show the visitor's most recent conversation card (default true)."),
|
|
509
|
+
status: z15.object({
|
|
510
|
+
text: z15.string().min(1).max(120),
|
|
511
|
+
level: z15.string().max(40).optional().describe(
|
|
433
512
|
"`home` \u2014 status severity, drives the status icon colour. Free text; `operational` (green, default), `degraded` (amber), and `down` (red) are styled, any other value falls back to the operational style."
|
|
434
513
|
).meta({ examples: ["operational", "degraded", "down"] }),
|
|
435
|
-
url:
|
|
514
|
+
url: z15.string().max(2048).optional().describe("Opens in an in-widget iframe when tapped.")
|
|
436
515
|
}).optional().describe("`home` \u2014 system-status card. Omit to hide."),
|
|
437
|
-
contentBlockTitle:
|
|
516
|
+
contentBlockTitle: z15.string().max(80).optional().describe("`home` \u2014 heading for the content list built from `contentTags` (default 'Popular articles').")
|
|
438
517
|
}).loose();
|
|
439
|
-
var modulesSchema =
|
|
518
|
+
var modulesSchema = z15.array(moduleSchema).max(4).describe(
|
|
440
519
|
"Messenger tabs \u2014 an ordered list of up to 4 tabs, each picking a `layout` + optional content `contentTags` (the content scope) + a translatable `label`. One tab \u2192 no tab bar (just that content); zero \u2192 an empty state. Floating / drawer / modal only."
|
|
441
520
|
).meta({
|
|
442
521
|
examples: [
|
|
@@ -459,23 +538,27 @@ var modulesSchema = z14.array(moduleSchema).max(4).describe(
|
|
|
459
538
|
});
|
|
460
539
|
|
|
461
540
|
// src/schema/widget.ts
|
|
462
|
-
var endpointsSchema =
|
|
463
|
-
upload:
|
|
464
|
-
transcribe:
|
|
541
|
+
var endpointsSchema = z16.object({
|
|
542
|
+
upload: z16.string().min(1).max(2048).default("/ai/agent/upload-file"),
|
|
543
|
+
transcribe: z16.string().min(1).max(2048).default("/ai/agent/transcribe-audio"),
|
|
544
|
+
intake: z16.string().min(1).max(2048).default("/ai/agent/intake").describe(
|
|
545
|
+
"Pre-chat intake submission endpoint. The widget POSTs the captured lead values here on completion (fire-and-forget), keyed by the same visitorId + sessionId as the conversation. Optional \u2014 a 404 is ignored."
|
|
546
|
+
)
|
|
465
547
|
}).loose().describe("HTTP endpoint overrides. Paths are appended to baseUrl; absolute URLs are accepted too.").meta({
|
|
466
548
|
examples: [
|
|
467
549
|
{ upload: "/ai/agent/upload-file", transcribe: "/ai/agent/transcribe-audio" },
|
|
468
|
-
{ upload: "https://help.ai/uploads/presign" }
|
|
550
|
+
{ upload: "https://help.ai/uploads/presign" },
|
|
551
|
+
{ intake: "https://crm.acme.com/leads/intake" }
|
|
469
552
|
]
|
|
470
553
|
});
|
|
471
|
-
var userContextSchema =
|
|
472
|
-
id:
|
|
473
|
-
email:
|
|
474
|
-
name:
|
|
475
|
-
plan:
|
|
476
|
-
role:
|
|
477
|
-
phone:
|
|
478
|
-
}).catchall(
|
|
554
|
+
var userContextSchema = z16.object({
|
|
555
|
+
id: z16.string().min(1).max(200).optional().describe("Host's stable id for the user \u2014 informational context the agent/backend can key on (not auth)."),
|
|
556
|
+
email: z16.string().min(1).max(320).optional().describe("User email \u2014 surfaced to the agent for context (optional)."),
|
|
557
|
+
name: z16.string().min(1).max(200).optional().describe("Display name \u2014 shown in the Home greeting (`{name}`) and conversation transcripts (optional)."),
|
|
558
|
+
plan: z16.string().min(1).max(120).optional().describe("Subscription / pricing tier, e.g. `pro` (optional)."),
|
|
559
|
+
role: z16.string().min(1).max(120).optional().describe("The user's role on the host site, e.g. `admin` (optional)."),
|
|
560
|
+
phone: z16.string().min(1).max(40).optional().describe("Phone number (optional).")
|
|
561
|
+
}).catchall(z16.union([z16.string(), z16.number(), z16.boolean()])).describe(
|
|
479
562
|
"Host-asserted end-user context (informational, untrusted \u2014 not authentication). Recognised `id` / `email` / `name` / `plan` / `role` / `phone` plus any extra custom scalar fields forwarded to the agent."
|
|
480
563
|
).meta({
|
|
481
564
|
examples: [{ id: "u_123" }, { id: "u_123", email: "alex@acme.com", name: "Alex Lee", plan: "pro" }]
|
|
@@ -491,31 +574,31 @@ var PAGE_AREA_SUGGESTIONS = [
|
|
|
491
574
|
"account",
|
|
492
575
|
"blog"
|
|
493
576
|
];
|
|
494
|
-
var pageContextSchema =
|
|
495
|
-
area:
|
|
496
|
-
url:
|
|
497
|
-
path:
|
|
498
|
-
title:
|
|
499
|
-
}).catchall(
|
|
577
|
+
var pageContextSchema = z16.object({
|
|
578
|
+
area: z16.string().min(1).max(64).optional().describe(`Host-defined surface the visitor is on. Free-form; suggested: ${PAGE_AREA_SUGGESTIONS.join(" | ")}.`),
|
|
579
|
+
url: z16.string().min(1).max(2048).optional().describe("Full page URL. Auto-filled from the host page when omitted."),
|
|
580
|
+
path: z16.string().min(1).max(2048).optional().describe("Page path, e.g. `/pricing/enterprise`."),
|
|
581
|
+
title: z16.string().min(1).max(300).optional().describe("Human-readable page title.")
|
|
582
|
+
}).catchall(z16.union([z16.string(), z16.number(), z16.boolean()])).describe(
|
|
500
583
|
"Host-asserted page/visit context (informational, untrusted). Where the visitor is + the surface (`area`) they're using, plus any custom scalar fields, forwarded to the agent."
|
|
501
584
|
).meta({ examples: [{ area: "pricing", path: "/pricing" }, { area: "help-desk" }] });
|
|
502
|
-
var connectionConfigSchema =
|
|
503
|
-
widgetId:
|
|
585
|
+
var connectionConfigSchema = z16.object({
|
|
586
|
+
widgetId: z16.string().min(1).max(80).default("default").describe(
|
|
504
587
|
"Stable per-instance id used to namespace localStorage keys. Set this when mounting more than one widget on the same page so their conversation state doesn't collide."
|
|
505
588
|
),
|
|
506
|
-
publicKey:
|
|
589
|
+
publicKey: z16.string().min(1).max(200).optional().describe(
|
|
507
590
|
"Workspace-scoped public key (`agent_pk_\u2026`) issued from the dashboard. Sent on every API call as the `x-public-key` header."
|
|
508
591
|
),
|
|
509
|
-
aiAgentDeploymentId:
|
|
592
|
+
aiAgentDeploymentId: z16.string().min(1).max(200).optional().describe(
|
|
510
593
|
"Deployment UUID from the dashboard. Picks which agent / settings bundle answers this mount. Sent as `x-ai-agent-deployment-id`."
|
|
511
594
|
),
|
|
512
|
-
baseUrl:
|
|
595
|
+
baseUrl: z16.string().min(1).max(2048).optional().describe(
|
|
513
596
|
"Full backend origin (e.g. `https://help.ai/api`). Set this to point at your staging / self-hosted / custom backend. Default: the brand's `defaultBaseUrl` baked at build time."
|
|
514
597
|
),
|
|
515
598
|
userContext: userContextSchema.optional(),
|
|
516
599
|
pageContext: pageContextSchema.optional(),
|
|
517
600
|
endpoints: endpointsSchema.optional(),
|
|
518
|
-
debug:
|
|
601
|
+
debug: z16.union([z16.boolean(), z16.enum(["off", "error", "warn", "info", "debug", "trace"])]).optional().describe(
|
|
519
602
|
'Console log verbosity. `false` / `"off"` silences everything (default in production). `true` \u2192 `"debug"`. Levels `error` / `warn` / `info` / `debug` / `trace` gate output additively. Use `"trace"` to capture per-chunk SSE frames + every state transition. Also toggleable at runtime via `chat.setDebug(level)` or `?<brand>-debug=trace` in the page URL \u2014 the URL beats this option, this option beats the persisted `localStorage` value.'
|
|
520
603
|
)
|
|
521
604
|
}).loose().describe(
|
|
@@ -535,7 +618,7 @@ var connectionConfigSchema = z15.object({
|
|
|
535
618
|
}
|
|
536
619
|
]
|
|
537
620
|
});
|
|
538
|
-
var widgetSettingsSchema =
|
|
621
|
+
var widgetSettingsSchema = z16.object({
|
|
539
622
|
presentation: presentationSchema.optional(),
|
|
540
623
|
behavior: behaviorSchema.optional(),
|
|
541
624
|
theme: themeFieldSchema.default("auto").describe("Theme preference (`auto` follows OS) or a tokens override object (`accent`, `radius`, `fontFamily`)."),
|
|
@@ -547,9 +630,10 @@ var widgetSettingsSchema = z15.object({
|
|
|
547
630
|
i18n: i18nSchema.optional(),
|
|
548
631
|
footer: footerSchema.optional(),
|
|
549
632
|
features: featureFlagsSchema.optional(),
|
|
633
|
+
intake: intakeSchema.optional(),
|
|
550
634
|
modules: modulesSchema.optional()
|
|
551
635
|
}).loose().describe(
|
|
552
|
-
"Portal-configurable widget settings \u2014
|
|
636
|
+
"Portal-configurable widget settings \u2014 thirteen sections, one per dashboard tab. The backend pushes this same shape on `/ai/agent/start-session` under `config`."
|
|
553
637
|
).meta({
|
|
554
638
|
examples: [
|
|
555
639
|
{ presentation: { mode: "floating", position: "bottom-right" }, theme: "auto" },
|
|
@@ -567,8 +651,8 @@ var widgetSettingsSchema = z15.object({
|
|
|
567
651
|
});
|
|
568
652
|
var widgetConfigSchema = connectionConfigSchema.extend({
|
|
569
653
|
...widgetSettingsSchema.shape,
|
|
570
|
-
site:
|
|
571
|
-
blocks:
|
|
654
|
+
site: z16.unknown().optional().describe('Site config \u2014 applies in `mode: "page"`. Comes from the start-session response, not user-edited.'),
|
|
655
|
+
blocks: z16.unknown().optional().describe('Blocks (nav + link cards) \u2014 applies in `mode: "page"`. Comes from the start-session response.')
|
|
572
656
|
}).describe(
|
|
573
657
|
"Full client widget config \u2014 connection (where + auth) + widget settings (look + behaviour) + page-mode extras. This is what the runtime parses on `mount()` / `init()`. Mode-specific constraints (e.g. `position` only meaningful in `floating`) are NOT enforced here \u2014 the runtime silently ignores irrelevant fields rather than rejecting them so the same object can flow across mode changes."
|
|
574
658
|
).meta({
|
|
@@ -591,49 +675,49 @@ var widgetSettingsPartialSchema = widgetSettingsSchema.partial();
|
|
|
591
675
|
var connectionConfigPartialSchema = connectionConfigSchema.partial();
|
|
592
676
|
|
|
593
677
|
// src/schema/deployment.ts
|
|
594
|
-
import { z as
|
|
678
|
+
import { z as z17 } from "zod";
|
|
595
679
|
var serverConfigSchema = widgetSettingsSchema.partial();
|
|
596
|
-
var siteConfigSchema =
|
|
597
|
-
title:
|
|
680
|
+
var siteConfigSchema = z17.object({
|
|
681
|
+
title: z17.string().min(1).max(120).optional().describe("Brand / site name. Used as the logo's alt-text fallback."),
|
|
598
682
|
logo: assetSchema.optional().describe("Brand logo shown at the top of the page-mode sidebar."),
|
|
599
683
|
logoDark: assetSchema.optional().describe(
|
|
600
684
|
"Optional dark-theme logo variant. Falls back to `logo` when the active theme is light or `logoDark` is unset."
|
|
601
685
|
)
|
|
602
686
|
}).loose();
|
|
603
|
-
var blocksConfigSchema =
|
|
604
|
-
navigation:
|
|
605
|
-
linkCards:
|
|
687
|
+
var blocksConfigSchema = z17.object({
|
|
688
|
+
navigation: z17.array(linkSchema).max(100).optional().describe("Sidebar navigation links (vertical list, primary nav)."),
|
|
689
|
+
linkCards: z17.array(linkSchema).max(100).optional().describe("Sidebar link cards (richer entries with optional `description`).")
|
|
606
690
|
}).loose();
|
|
607
|
-
var handshakeWelcomeMessageSchema =
|
|
608
|
-
id:
|
|
609
|
-
role:
|
|
610
|
-
text:
|
|
691
|
+
var handshakeWelcomeMessageSchema = z17.object({
|
|
692
|
+
id: z17.string(),
|
|
693
|
+
role: z17.enum(["assistant", "system"]),
|
|
694
|
+
text: z17.string()
|
|
611
695
|
}).loose();
|
|
612
|
-
var handshakeWelcomeSuggestionSchema =
|
|
613
|
-
id:
|
|
614
|
-
label:
|
|
615
|
-
text:
|
|
696
|
+
var handshakeWelcomeSuggestionSchema = z17.object({
|
|
697
|
+
id: z17.string(),
|
|
698
|
+
label: z17.string(),
|
|
699
|
+
text: z17.string().optional()
|
|
616
700
|
}).loose();
|
|
617
|
-
var rebindReasonSchema =
|
|
618
|
-
var startSessionResponseSchema =
|
|
619
|
-
deployment:
|
|
620
|
-
id:
|
|
621
|
-
name:
|
|
701
|
+
var rebindReasonSchema = z17.enum(["conflict", "expired", "invalid"]);
|
|
702
|
+
var startSessionResponseSchema = z17.object({
|
|
703
|
+
deployment: z17.object({
|
|
704
|
+
id: z17.string(),
|
|
705
|
+
name: z17.string(),
|
|
622
706
|
// Page URL identifier — present on every deployment; unique per host.
|
|
623
707
|
// Used to mount page deployments via `?slug=…`.
|
|
624
|
-
slug:
|
|
625
|
-
publicKey:
|
|
708
|
+
slug: z17.string().optional(),
|
|
709
|
+
publicKey: z17.string().optional()
|
|
626
710
|
// Deliberately no `type` / `channel` here. Deployment-level
|
|
627
711
|
// taxonomy is a backend categorization concern — the widget's
|
|
628
712
|
// rendering choice flows from `widget.presentation.mode`, not
|
|
629
713
|
// the deployment record's category. `.loose()` lets any such
|
|
630
714
|
// backend field pass through without typing.
|
|
631
715
|
}).loose(),
|
|
632
|
-
agent:
|
|
633
|
-
id:
|
|
634
|
-
name:
|
|
635
|
-
title:
|
|
636
|
-
status:
|
|
716
|
+
agent: z17.object({
|
|
717
|
+
id: z17.string(),
|
|
718
|
+
name: z17.string(),
|
|
719
|
+
title: z17.string().optional(),
|
|
720
|
+
status: z17.enum(["online", "away", "offline"]).optional()
|
|
637
721
|
}).loose(),
|
|
638
722
|
/**
|
|
639
723
|
* Deployment-wide widget configuration the dashboard admin saved
|
|
@@ -643,25 +727,25 @@ var startSessionResponseSchema = z16.object({
|
|
|
643
727
|
config: serverConfigSchema.optional(),
|
|
644
728
|
site: siteConfigSchema.optional(),
|
|
645
729
|
blocks: blocksConfigSchema.optional(),
|
|
646
|
-
welcome:
|
|
647
|
-
messages:
|
|
648
|
-
suggestions:
|
|
730
|
+
welcome: z17.object({
|
|
731
|
+
messages: z17.array(handshakeWelcomeMessageSchema).optional(),
|
|
732
|
+
suggestions: z17.array(handshakeWelcomeSuggestionSchema).optional()
|
|
649
733
|
}).loose().optional(),
|
|
650
|
-
visitorId:
|
|
651
|
-
sessionId:
|
|
652
|
-
canContinue:
|
|
653
|
-
messages:
|
|
734
|
+
visitorId: z17.string(),
|
|
735
|
+
sessionId: z17.string(),
|
|
736
|
+
canContinue: z17.boolean(),
|
|
737
|
+
messages: z17.array(z17.unknown()),
|
|
654
738
|
/**
|
|
655
739
|
* Per-visitor preferences (locale picker, theme picker, sound
|
|
656
740
|
* mute, dragged panel size). Distinct from `config` — this is
|
|
657
741
|
* what THIS visitor toggled inside the widget, not the
|
|
658
742
|
* deployment's admin-set defaults.
|
|
659
743
|
*/
|
|
660
|
-
userPrefs:
|
|
744
|
+
userPrefs: z17.record(z17.string(), z17.unknown()).optional(),
|
|
661
745
|
// Present only when the server rotated the request `visitorId` /
|
|
662
746
|
// `sessionId`. Purely advisory — client must adopt the response ids
|
|
663
747
|
// verbatim regardless of whether this block is present.
|
|
664
|
-
rebind:
|
|
748
|
+
rebind: z17.object({
|
|
665
749
|
visitorId: rebindReasonSchema.optional(),
|
|
666
750
|
sessionId: rebindReasonSchema.optional()
|
|
667
751
|
}).loose().optional()
|
|
@@ -698,15 +782,15 @@ function widgetSettingsSchemaForMode(mode) {
|
|
|
698
782
|
var ALL_MODES = ["floating", "inline", "standalone", "page", "modal", "drawer"];
|
|
699
783
|
|
|
700
784
|
// src/schema/json-schema.ts
|
|
701
|
-
import { z as
|
|
785
|
+
import { z as z19 } from "zod";
|
|
702
786
|
function emitJsonSchema() {
|
|
703
787
|
return {
|
|
704
788
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
705
789
|
title: "@helpai/elements config",
|
|
706
790
|
description: "Canonical config schemas for the embeddable AI agent elements widget.",
|
|
707
791
|
definitions: {
|
|
708
|
-
WidgetConfig:
|
|
709
|
-
StartSessionResponse:
|
|
792
|
+
WidgetConfig: z19.toJSONSchema(widgetConfigSchema),
|
|
793
|
+
StartSessionResponse: z19.toJSONSchema(startSessionResponseSchema)
|
|
710
794
|
}
|
|
711
795
|
};
|
|
712
796
|
}
|
|
@@ -730,12 +814,17 @@ export {
|
|
|
730
814
|
featureFlagsSchema,
|
|
731
815
|
feedbackEventSchema,
|
|
732
816
|
feedbackSchema,
|
|
817
|
+
fieldOptionSchema,
|
|
818
|
+
fieldTypeSchema,
|
|
819
|
+
fieldValidationSchema,
|
|
733
820
|
footerSchema,
|
|
821
|
+
formFieldSchema,
|
|
734
822
|
hapticsOptionsSchema,
|
|
735
823
|
headerActionsSchema,
|
|
736
824
|
headerSchema,
|
|
737
825
|
i18nSchema,
|
|
738
826
|
initialSizeSchema,
|
|
827
|
+
intakeSchema,
|
|
739
828
|
launcherCalloutSchema,
|
|
740
829
|
launcherOptionsSchema,
|
|
741
830
|
launcherSizeSchema,
|