@helpai/elements 0.25.0 → 0.27.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/README.md +2 -2
- package/configurator.mjs +18 -17
- package/elements-web-component.esm.js +19 -19
- package/elements-web-component.esm.js.map +4 -4
- package/elements.cjs.js +22 -22
- package/elements.cjs.js.map +4 -4
- package/elements.esm.js +22 -22
- package/elements.esm.js.map +4 -4
- package/elements.js +19 -19
- package/elements.js.map +4 -4
- package/index.d.ts +42 -87
- package/index.mjs +190 -181
- package/package.json +1 -1
- package/schema.d.ts +50 -50
- package/schema.json +24 -27
- package/schema.mjs +20 -19
- package/web-component.d.ts +1 -1
- package/web-component.mjs +190 -181
package/README.md
CHANGED
|
@@ -85,7 +85,7 @@ re-resolves at runtime.
|
|
|
85
85
|
| `index.mjs` / `web-component.mjs` | ESM | Bundlers (Vite, webpack, esbuild) — bare imports kept |
|
|
86
86
|
| `elements.cjs.js` | CJS | `require()` from Node / legacy tooling |
|
|
87
87
|
| `style.css` | CSS | `<link rel="stylesheet">` |
|
|
88
|
-
| `schema.json` | JSON Schema | Dashboard config UIs, backend
|
|
88
|
+
| `schema.json` | JSON Schema | Dashboard config UIs, backend handshake validation, 3rd-party tooling |
|
|
89
89
|
| `schema.mjs` | ESM | Zod runtime schemas: `import { widgetConfigSchema } from "@helpai/elements/schema"` |
|
|
90
90
|
|
|
91
91
|
Every bundle exposes the same surface (`mount`, `init`, `hook`, types).
|
|
@@ -323,7 +323,7 @@ attribute. See [https://help.ai/docs/elements/modes](https://help.ai/docs/elemen
|
|
|
323
323
|
## Configuration
|
|
324
324
|
|
|
325
325
|
The element reads its per-deployment configuration from your
|
|
326
|
-
Help AI workspace at
|
|
326
|
+
Help AI workspace at handshake time — colors, launcher
|
|
327
327
|
chrome, strings, action layout, model defaults, history visibility
|
|
328
328
|
all flow through `StartConversationResponse.settings`. You don't recompile
|
|
329
329
|
per-customer.
|
package/configurator.mjs
CHANGED
|
@@ -132,7 +132,7 @@ var behaviorSchema = z4.object({
|
|
|
132
132
|
"Show tool/function calls the model makes (e.g. search) as inline chips in the transcript. `false` (default) hides them."
|
|
133
133
|
),
|
|
134
134
|
popOutUrl: z4.string().min(1).max(2048).optional().describe(
|
|
135
|
-
"URL the `popOut` action opens in a new tab (carries `?conversation=<id>&widgetId=<id>` query params). Falls back to the brand's build-time default. Set this to point at your own dedicated chat page (e.g. `https://app.acme.com/chat`). Server-pushable on `/
|
|
135
|
+
"URL the `popOut` action opens in a new tab (carries `?conversation=<id>&widgetId=<id>` query params). Falls back to the brand's build-time default. Set this to point at your own dedicated chat page (e.g. `https://app.acme.com/chat`). Server-pushable on `/handshake.widget.behavior.popOutUrl`."
|
|
136
136
|
)
|
|
137
137
|
}).loose().describe("Lifecycle + streaming behaviour. Doesn't affect visual presentation.").meta({
|
|
138
138
|
examples: [
|
|
@@ -572,13 +572,15 @@ var modulesSchema = z14.array(moduleSchema).max(4).describe(
|
|
|
572
572
|
// src/schema/widget/tracking.ts
|
|
573
573
|
import { z as z15 } from "zod";
|
|
574
574
|
var trackingSchema = z15.object({
|
|
575
|
-
enabled: z15.boolean().optional().describe(
|
|
575
|
+
enabled: z15.boolean().optional().describe(
|
|
576
|
+
"Master switch. Default `true` \u2014 the widget always fires; the data module gates ingestion per deployment server-side. Set `false` to silence the client entirely."
|
|
577
|
+
),
|
|
576
578
|
endpoint: z15.url().max(2048).optional().describe(
|
|
577
|
-
"Pixel collector URL. Default: `${dataBaseUrl}/elements
|
|
579
|
+
"Pixel collector URL. Default: `${dataBaseUrl}/pai/elements-px.gif` (e.g. `https://help.ai/api/data/pai/elements-px.gif`). Must be a full URL."
|
|
578
580
|
),
|
|
579
581
|
sampleRate: z15.number().min(0).max(1).optional().describe("Per-visitor sampling 0..1 (decided once per page load, keeping funnels intact). Default `1`."),
|
|
580
582
|
token: z15.string().max(512).optional().describe(
|
|
581
|
-
"Anti-forgery token, echoed as `tk=` on every hit. Server-issued in the `/
|
|
583
|
+
"Anti-forgery token, echoed as `tk=` on every hit. Server-issued in the `/handshake` response \u2014 never set by hand (see `docs/api/tracking-collector.md`)."
|
|
582
584
|
)
|
|
583
585
|
}).loose().describe(
|
|
584
586
|
"Anonymous usage tracking for the widget owner \u2014 GA-style pixel events (open, send, form submit, \u2026) with page / device / locale dimensions. Never includes message content; visitors are identified only by the widget's anonymous visitorId."
|
|
@@ -588,16 +590,16 @@ var trackingSchema = z15.object({
|
|
|
588
590
|
|
|
589
591
|
// src/schema/widget.ts
|
|
590
592
|
var endpointsSchema = z16.object({
|
|
591
|
-
upload: z16.string().min(1).max(2048).default("/
|
|
592
|
-
transcribe: z16.string().min(1).max(2048).default("/
|
|
593
|
-
submitForm: z16.string().min(1).max(2048).default("/submit-form").describe(
|
|
593
|
+
upload: z16.string().min(1).max(2048).default("/pai/upload-file"),
|
|
594
|
+
transcribe: z16.string().min(1).max(2048).default("/pai/transcribe-audio"),
|
|
595
|
+
submitForm: z16.string().min(1).max(2048).default("/pai/submit-form").describe(
|
|
594
596
|
"Form submission endpoint. The widget POSTs each completed form's values here (fire-and-forget), keyed by the same visitorId + conversationId as the conversation; the payload carries `formId` + `trigger` so the backend can route. Optional \u2014 a 404 is ignored."
|
|
595
597
|
)
|
|
596
598
|
}).loose().describe(
|
|
597
599
|
"HTTP endpoint overrides. `upload` / `transcribe` paths are appended to the agent base (`${baseUrl}/api/agent`), `submitForm` to the data base (`dataBaseUrl`); absolute URLs are accepted too."
|
|
598
600
|
).meta({
|
|
599
601
|
examples: [
|
|
600
|
-
{ upload: "/
|
|
602
|
+
{ upload: "/pai/upload-file", transcribe: "/pai/transcribe-audio" },
|
|
601
603
|
{ upload: "https://help.ai/uploads/presign" },
|
|
602
604
|
{ submitForm: "https://crm.acme.com/leads" }
|
|
603
605
|
]
|
|
@@ -646,8 +648,11 @@ var connectionConfigSchema = z16.object({
|
|
|
646
648
|
baseUrl: z16.string().min(1).max(2048).optional().describe(
|
|
647
649
|
"MAIN site origin (e.g. `https://help.ai`) \u2014 the API modules derive from it: agent API at `${baseUrl}/api/agent`, data API at `${baseUrl}/api/data`. Set this to point at your staging / self-hosted / custom backend. Default: the brand's `defaultBaseUrl` baked at build time."
|
|
648
650
|
),
|
|
651
|
+
agentBaseUrl: z16.string().min(1).max(2048).optional().describe(
|
|
652
|
+
"Full agent-API base \u2014 set it to reach a STANDALONE `module-help-ai-agent-api` directly (local module on its own port, e.g. `http://localhost:3087`; routes attach as-is: `/pai/handshake`). Precedence: this option > derived from the main origin (`${baseUrl}/api/agent`). Not server-pushable."
|
|
653
|
+
),
|
|
649
654
|
dataBaseUrl: z16.string().min(1).max(2048).optional().describe(
|
|
650
|
-
"Full data-API base (e.g. `https://help.ai/api/data`) \u2014 the service serving content, form definitions (`GET /forms`), and form submissions at root-level paths. Precedence: this option > server-pushed `config.dataBaseUrl` > derived from the main origin (`${baseUrl}/api/data`)."
|
|
655
|
+
"Full data-API base (e.g. `https://help.ai/api/data`, or a standalone local module like `http://localhost:3106`) \u2014 the service serving content, form definitions (`GET /forms`), and form submissions at root-level paths. Precedence: this option > server-pushed `config.dataBaseUrl` > derived from the main origin (`${baseUrl}/api/data`)."
|
|
651
656
|
),
|
|
652
657
|
userContext: userContextSchema.optional(),
|
|
653
658
|
pageContext: pageContextSchema.optional(),
|
|
@@ -687,7 +692,7 @@ var widgetSettingsSchema = z16.object({
|
|
|
687
692
|
modules: modulesSchema.optional(),
|
|
688
693
|
tracking: trackingSchema.optional()
|
|
689
694
|
}).loose().describe(
|
|
690
|
-
"Portal-configurable widget settings \u2014 fourteen sections, one per dashboard tab. The backend pushes this same shape on `/
|
|
695
|
+
"Portal-configurable widget settings \u2014 fourteen sections, one per dashboard tab. The backend pushes this same shape on `/pai/handshake` under `config`."
|
|
691
696
|
).meta({
|
|
692
697
|
examples: [
|
|
693
698
|
{ presentation: { mode: "floating", position: "bottom-right" }, theme: "auto" },
|
|
@@ -705,10 +710,8 @@ var widgetSettingsSchema = z16.object({
|
|
|
705
710
|
});
|
|
706
711
|
var widgetConfigSchema = connectionConfigSchema.extend({
|
|
707
712
|
...widgetSettingsSchema.shape,
|
|
708
|
-
site: z16.unknown().optional().describe(
|
|
709
|
-
|
|
710
|
-
),
|
|
711
|
-
blocks: z16.unknown().optional().describe('Blocks (nav + link cards) \u2014 applies in `mode: "page"`. Comes from the start-conversation response.')
|
|
713
|
+
site: z16.unknown().optional().describe('Site config \u2014 applies in `mode: "page"`. Comes from the handshake response, not user-edited.'),
|
|
714
|
+
blocks: z16.unknown().optional().describe('Blocks (nav + link cards) \u2014 applies in `mode: "page"`. Comes from the handshake response.')
|
|
712
715
|
}).describe(
|
|
713
716
|
"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."
|
|
714
717
|
).meta({
|
|
@@ -757,7 +760,7 @@ var handshakeWelcomeSuggestionSchema = z17.object({
|
|
|
757
760
|
text: z17.string().optional()
|
|
758
761
|
}).loose();
|
|
759
762
|
var rebindReasonSchema = z17.enum(["conflict", "expired", "invalid"]);
|
|
760
|
-
var
|
|
763
|
+
var handshakeResponseSchema = z17.object({
|
|
761
764
|
deployment: z17.object({
|
|
762
765
|
id: z17.string(),
|
|
763
766
|
name: z17.string(),
|
|
@@ -791,8 +794,6 @@ var startConversationResponseSchema = z17.object({
|
|
|
791
794
|
}).loose().optional(),
|
|
792
795
|
visitorId: z17.string(),
|
|
793
796
|
conversationId: z17.string(),
|
|
794
|
-
canContinue: z17.boolean(),
|
|
795
|
-
messages: z17.array(z17.unknown()),
|
|
796
797
|
/**
|
|
797
798
|
* Per-visitor preferences (locale picker, theme picker, sound
|
|
798
799
|
* mute, dragged panel size). Distinct from `config` — this is
|