@helpai/elements 0.24.0 → 0.26.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/schema.mjs CHANGED
@@ -129,7 +129,7 @@ var behaviorSchema = z4.object({
129
129
  "Show tool/function calls the model makes (e.g. search) as inline chips in the transcript. `false` (default) hides them."
130
130
  ),
131
131
  popOutUrl: z4.string().min(1).max(2048).optional().describe(
132
- "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 `/start-conversation.widget.behavior.popOutUrl`."
132
+ "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`."
133
133
  )
134
134
  }).loose().describe("Lifecycle + streaming behaviour. Doesn't affect visual presentation.").meta({
135
135
  examples: [
@@ -517,7 +517,7 @@ var moduleSchema = z14.object({
517
517
  "UI layout that renders this tab: `chat` (the conversation), `home`, `help`, or `news`."
518
518
  ),
519
519
  contentTags: z14.array(z14.string().max(60)).max(20).optional().describe(
520
- "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."
520
+ "Content tags this tab scopes to \u2014 the `tags` filter on `GET /content` (matches content tagged with ANY of them). Omit for the `chat` layout."
521
521
  ),
522
522
  id: z14.string().max(60).optional().describe(
523
523
  "Stable id for navigation + last-tab persistence. Defaults to the first `contentTags` entry, else `layout`."
@@ -570,10 +570,12 @@ var modulesSchema = z14.array(moduleSchema).max(4).describe(
570
570
  import { z as z15 } from "zod";
571
571
  var trackingSchema = z15.object({
572
572
  enabled: z15.boolean().optional().describe("Master switch. Default `false` \u2014 no hits are sent until the deployment turns tracking on."),
573
- endpoint: z15.url().max(2048).optional().describe("Pixel collector URL. Default: `https://t.<brand domain>/api/ai-elements/px.gif`. Must be a full URL."),
573
+ endpoint: z15.url().max(2048).optional().describe(
574
+ "Pixel collector URL. Default: `${dataBaseUrl}/elements/px.gif` (e.g. `https://help.ai/api/data/elements/px.gif`). Must be a full URL."
575
+ ),
574
576
  sampleRate: z15.number().min(0).max(1).optional().describe("Per-visitor sampling 0..1 (decided once per page load, keeping funnels intact). Default `1`."),
575
577
  token: z15.string().max(512).optional().describe(
576
- "Anti-forgery token, echoed as `tk=` on every hit. Server-issued in the `/start-conversation` response \u2014 never set by hand (see `docs/api/tracking-collector.md`)."
578
+ "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`)."
577
579
  )
578
580
  }).loose().describe(
579
581
  "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."
@@ -583,14 +585,16 @@ var trackingSchema = z15.object({
583
585
 
584
586
  // src/schema/widget.ts
585
587
  var endpointsSchema = z16.object({
586
- upload: z16.string().min(1).max(2048).default("/ai/agent/upload-file"),
587
- transcribe: z16.string().min(1).max(2048).default("/ai/agent/transcribe-audio"),
588
- submitForm: z16.string().min(1).max(2048).default("/ai/agent/submit-form").describe(
588
+ upload: z16.string().min(1).max(2048).default("/ai-agent/upload-file"),
589
+ transcribe: z16.string().min(1).max(2048).default("/ai-agent/transcribe-audio"),
590
+ submitForm: z16.string().min(1).max(2048).default("/submit-form").describe(
589
591
  "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."
590
592
  )
591
- }).loose().describe("HTTP endpoint overrides. Paths are appended to baseUrl; absolute URLs are accepted too.").meta({
593
+ }).loose().describe(
594
+ "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."
595
+ ).meta({
592
596
  examples: [
593
- { upload: "/ai/agent/upload-file", transcribe: "/ai/agent/transcribe-audio" },
597
+ { upload: "/ai-agent/upload-file", transcribe: "/ai-agent/transcribe-audio" },
594
598
  { upload: "https://help.ai/uploads/presign" },
595
599
  { submitForm: "https://crm.acme.com/leads" }
596
600
  ]
@@ -637,7 +641,13 @@ var connectionConfigSchema = z16.object({
637
641
  "Deployment UUID from the dashboard. Picks which agent / settings bundle answers this mount. Sent as `x-ai-agent-deployment-id`."
638
642
  ),
639
643
  baseUrl: z16.string().min(1).max(2048).optional().describe(
640
- "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."
644
+ "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."
645
+ ),
646
+ agentBaseUrl: z16.string().min(1).max(2048).optional().describe(
647
+ "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: `/ai-agent/handshake`). Precedence: this option > derived from the main origin (`${baseUrl}/api/agent`). Not server-pushable."
648
+ ),
649
+ dataBaseUrl: z16.string().min(1).max(2048).optional().describe(
650
+ "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`)."
641
651
  ),
642
652
  userContext: userContextSchema.optional(),
643
653
  pageContext: pageContextSchema.optional(),
@@ -677,7 +687,7 @@ var widgetSettingsSchema = z16.object({
677
687
  modules: modulesSchema.optional(),
678
688
  tracking: trackingSchema.optional()
679
689
  }).loose().describe(
680
- "Portal-configurable widget settings \u2014 fourteen sections, one per dashboard tab. The backend pushes this same shape on `/ai/agent/start-conversation` under `config`."
690
+ "Portal-configurable widget settings \u2014 fourteen sections, one per dashboard tab. The backend pushes this same shape on `/ai-agent/handshake` under `config`."
681
691
  ).meta({
682
692
  examples: [
683
693
  { presentation: { mode: "floating", position: "bottom-right" }, theme: "auto" },
@@ -695,10 +705,8 @@ var widgetSettingsSchema = z16.object({
695
705
  });
696
706
  var widgetConfigSchema = connectionConfigSchema.extend({
697
707
  ...widgetSettingsSchema.shape,
698
- site: z16.unknown().optional().describe(
699
- 'Site config \u2014 applies in `mode: "page"`. Comes from the start-conversation response, not user-edited.'
700
- ),
701
- blocks: z16.unknown().optional().describe('Blocks (nav + link cards) \u2014 applies in `mode: "page"`. Comes from the start-conversation response.')
708
+ site: z16.unknown().optional().describe('Site config \u2014 applies in `mode: "page"`. Comes from the handshake response, not user-edited.'),
709
+ blocks: z16.unknown().optional().describe('Blocks (nav + link cards) \u2014 applies in `mode: "page"`. Comes from the handshake response.')
702
710
  }).describe(
703
711
  "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."
704
712
  ).meta({
@@ -722,7 +730,9 @@ var connectionConfigPartialSchema = connectionConfigSchema.partial();
722
730
 
723
731
  // src/schema/deployment.ts
724
732
  import { z as z17 } from "zod";
725
- var serverConfigSchema = widgetSettingsSchema.partial();
733
+ var serverConfigSchema = widgetSettingsSchema.partial().omit({ forms: true }).extend({
734
+ dataBaseUrl: z17.string().min(1).max(2048).optional()
735
+ });
726
736
  var siteConfigSchema = z17.object({
727
737
  title: z17.string().min(1).max(120).optional().describe("Brand / site name. Used as the logo's alt-text fallback."),
728
738
  logo: assetSchema.optional().describe("Brand logo shown at the top of the page-mode sidebar."),
@@ -745,7 +755,7 @@ var handshakeWelcomeSuggestionSchema = z17.object({
745
755
  text: z17.string().optional()
746
756
  }).loose();
747
757
  var rebindReasonSchema = z17.enum(["conflict", "expired", "invalid"]);
748
- var startConversationResponseSchema = z17.object({
758
+ var handshakeResponseSchema = z17.object({
749
759
  deployment: z17.object({
750
760
  id: z17.string(),
751
761
  name: z17.string(),
@@ -779,22 +789,6 @@ var startConversationResponseSchema = z17.object({
779
789
  }).loose().optional(),
780
790
  visitorId: z17.string(),
781
791
  conversationId: z17.string(),
782
- canContinue: z17.boolean(),
783
- messages: z17.array(z17.unknown()),
784
- /**
785
- * Form submissions recorded for this conversation — echoed like
786
- * `messages` so the widget reconstructs the collapsed "form submitted"
787
- * timeline markers on resume. `createdAt` is ISO-8601 (a serialized
788
- * Mongo ISODate — same format as message `createdAt`).
789
- */
790
- formSubmissions: z17.array(
791
- z17.object({
792
- formId: z17.string(),
793
- trigger: z17.string(),
794
- skipped: z17.boolean().optional(),
795
- createdAt: z17.iso.datetime().optional()
796
- }).loose()
797
- ).optional(),
798
792
  /**
799
793
  * Per-visitor preferences (locale picker, theme picker, sound
800
794
  * mute, dragged panel size). Distinct from `config` — this is
@@ -850,7 +844,7 @@ function emitJsonSchema() {
850
844
  description: "Canonical config schemas for the embeddable AI agent elements widget.",
851
845
  definitions: {
852
846
  WidgetConfig: z19.toJSONSchema(widgetConfigSchema),
853
- StartConversationResponse: z19.toJSONSchema(startConversationResponseSchema)
847
+ HandshakeResponse: z19.toJSONSchema(handshakeResponseSchema)
854
848
  }
855
849
  };
856
850
  }
@@ -883,6 +877,7 @@ export {
883
877
  formFieldSchema,
884
878
  formTriggerSchema,
885
879
  formsSchema,
880
+ handshakeResponseSchema,
886
881
  hapticsOptionsSchema,
887
882
  headerActionsSchema,
888
883
  headerSchema,
@@ -912,7 +907,6 @@ export {
912
907
  siteConfigSchema,
913
908
  sizeOptionsSchema,
914
909
  soundOptionsSchema,
915
- startConversationResponseSchema,
916
910
  stringsOverrideSchema,
917
911
  themeFieldSchema,
918
912
  themeOverridesSchema,
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Mode resolution: the tag itself doesn't pin a default mode. When no
10
10
  * `mode=…` attribute is set, the resolver default (`"floating"`) seeds
11
- * the very first frame — which the App's start-conversation gate keeps blank
11
+ * the very first frame — which the App's handshake gate keeps blank
12
12
  * — then the server's pushed `widget.presentation.mode` wins via
13
13
  * `mergeServerConfig` (subscribed in `boot()` below). Drop a bare
14
14
  * `<web-ai-chat public-key="…" ai-agent-deployment-id="…">` on the