@accurix/centrinfo-widget 4.0.0 → 5.1.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.
@@ -1,7 +1,362 @@
1
- import "preact";
1
+ import * as preact0 from "preact";
2
2
 
3
- //#region src/i18n.d.ts
3
+ //#region ../centrinfo-results/src/analytics-explanation.d.ts
4
4
 
5
+ /**
6
+ * Framework-agnostic analytics explanation core.
7
+ *
8
+ * Every surface (Liveboard SDK vanilla DOM, the Preact widget and full-page
9
+ * chat app, and the React dashboard) renders an explanation from the SAME
10
+ * display model built here, so wording, order and value-status rules never
11
+ * drift between surfaces. Renderers only map this model onto their own markup
12
+ * and theme tokens.
13
+ *
14
+ * Step-by-step order (fixed):
15
+ * 1. lead plain business answer (headline + summary)
16
+ * 2. comparison each compared period with its value + status chip
17
+ * 3. conclusions what the data supports
18
+ * 4. limits in-progress / unconfirmed zero / missing period / caveats
19
+ * 5. checked "Times in <tz> · Checked <time>"
20
+ * 6. investigate causes, recommendations, outlook, follow-ups (optional
21
+ * disclosure, collapsed by default)
22
+ *
23
+ * Zero is only "confirmed" when the source says so. An empty bucket or an
24
+ * unconfirmed zero reads as "no records yet" and never produces a % change.
25
+ *
26
+ * Pure TypeScript, no DOM or framework imports: safe for every SDK bundle.
27
+ */
28
+ type AnalyticsExplanationValueStatus = 'observed' | 'confirmed_zero' | 'empty_bucket' | 'unconfirmed_zero' | 'missing';
29
+ interface AnalyticsExplanationPeriodRangeInput {
30
+ label: string;
31
+ start?: string;
32
+ end?: string;
33
+ timezone?: string;
34
+ }
35
+ interface AnalyticsExplanationEvidenceItemInput {
36
+ id: string;
37
+ text: string;
38
+ kind?: string;
39
+ metric?: string;
40
+ period?: AnalyticsExplanationPeriodRangeInput;
41
+ filters?: string[];
42
+ value?: number;
43
+ valueStatus?: AnalyticsExplanationValueStatus | string;
44
+ statusReason?: string;
45
+ source?: {
46
+ kind?: 'card' | 'supporting_query' | string;
47
+ insightId?: string;
48
+ queryRunId?: string;
49
+ liveboardTileId?: string;
50
+ };
51
+ checkedAt?: string;
52
+ }
53
+ interface AnalyticsExplanationPeriodInput {
54
+ evidenceId?: string;
55
+ label: string;
56
+ start?: string;
57
+ end?: string;
58
+ timezone?: string;
59
+ current?: boolean;
60
+ inProgress?: boolean;
61
+ value?: number;
62
+ valueText?: string;
63
+ valueStatus?: AnalyticsExplanationValueStatus | string;
64
+ statusReason?: string;
65
+ source?: string;
66
+ }
67
+ interface AnalyticsExplanationMissingInput {
68
+ evidenceId?: string;
69
+ label: string;
70
+ period?: AnalyticsExplanationPeriodRangeInput;
71
+ reason: string;
72
+ }
73
+ interface AnalyticsExplanationFreshnessInput {
74
+ status?: string;
75
+ dataAsOf?: string;
76
+ expectedThrough?: string;
77
+ lagDays?: number;
78
+ checkedAt?: string;
79
+ timezone?: string;
80
+ }
81
+ /** Structural explanation shape every surface's DTO satisfies. */
82
+ interface AnalyticsExplanationInput {
83
+ explanationId?: string;
84
+ conversationalPreface?: string;
85
+ headline?: string;
86
+ summary?: string;
87
+ evidence?: string[];
88
+ headlineEvidenceIds?: string[];
89
+ summaryEvidenceIds?: string[];
90
+ businessMeaningEvidenceIds?: string[];
91
+ evidenceStatements?: Array<{
92
+ text: string;
93
+ evidenceIds?: string[];
94
+ }>;
95
+ evidenceItems?: AnalyticsExplanationEvidenceItemInput[];
96
+ periods?: AnalyticsExplanationPeriodInput[];
97
+ missing?: AnalyticsExplanationMissingInput[];
98
+ timezone?: string;
99
+ checkedAt?: string;
100
+ currentPeriodInProgress?: boolean;
101
+ cached?: boolean;
102
+ dataFreshness?: AnalyticsExplanationFreshnessInput;
103
+ businessMeaning?: string;
104
+ possibleDrivers?: Array<{
105
+ hypothesis: string;
106
+ howToCheck: string;
107
+ evidenceIds?: string[];
108
+ }>;
109
+ recommendations?: Array<{
110
+ action: string;
111
+ why: string;
112
+ successMetric?: string;
113
+ evidenceIds?: string[];
114
+ }>;
115
+ forecast?: {
116
+ text: string;
117
+ qualityStatus?: string;
118
+ limitations?: string;
119
+ horizon?: string;
120
+ };
121
+ limitations?: string[];
122
+ followUps?: string[];
123
+ source?: string;
124
+ /** "basic" = the free explanation built from the facts; "detailed" = checked AI wording. */
125
+ level?: 'basic' | 'detailed' | string;
126
+ /** The detailed AI explanation that loads separately (poll by explanationId). */
127
+ aiExplanation?: AnalyticsAIExplanationInput | null;
128
+ }
129
+ /** State of the detailed AI explanation, as returned by every surface. */
130
+ type AnalyticsAIExplanationStatus = 'pending' | 'ready' | 'failed' | 'not_requested';
131
+ interface AnalyticsAIExplanationInput {
132
+ status: AnalyticsAIExplanationStatus | string;
133
+ explanationId?: string;
134
+ retryAvailable?: boolean;
135
+ }
136
+ declare const ANALYTICS_EXPLANATION_COPY: {
137
+ readonly eyebrow: "Answer from your data";
138
+ readonly provenanceAI: "AI-assisted · evidence checked";
139
+ readonly provenanceGoverned: "Based on current values";
140
+ readonly comparison: "Comparison";
141
+ readonly conclusions: "What we can conclude";
142
+ readonly whyItMatters: "Why it matters";
143
+ readonly limits: "Important limits";
144
+ readonly investigate: "Investigate further";
145
+ readonly evidenceList: "Evidence checked";
146
+ readonly causes: "Possible causes";
147
+ readonly causesHint: "Not proven causes";
148
+ readonly howToCheck: "How to check:";
149
+ readonly recommendations: "Recommended next steps";
150
+ readonly watch: "Watch:";
151
+ readonly outlook: "Outlook";
152
+ readonly followUps: "Ask a follow-up";
153
+ readonly sourceNoteAI: "AI-assisted wording, checked against the live values shown here.";
154
+ readonly sourceNoteGoverned: "Based only on the live values shown here.";
155
+ readonly evidence: "Evidence";
156
+ readonly evidenceMetric: "Metric";
157
+ readonly evidencePeriod: "Period";
158
+ readonly evidenceTimezone: "Timezone";
159
+ readonly evidenceFilters: "Filters";
160
+ readonly evidenceValue: "Value";
161
+ readonly evidenceStatus: "Status";
162
+ readonly evidenceSource: "Source";
163
+ readonly evidenceChecked: "Checked";
164
+ readonly openSource: "Open source";
165
+ readonly closeEvidence: "Close evidence details";
166
+ readonly citationLabel: "Show evidence";
167
+ readonly sourceCard: "This card";
168
+ readonly sourceSupportingQuery: "Supporting query";
169
+ readonly feedbackPrompt: "Was this explanation helpful?";
170
+ readonly feedbackHelpful: "Helpful explanation";
171
+ readonly feedbackNotHelpful: "Unhelpful explanation";
172
+ readonly feedbackReasonsPrompt: "What went wrong? (optional)";
173
+ readonly feedbackCommentPlaceholder: "Anything else? (optional)";
174
+ readonly feedbackSubmit: "Send feedback";
175
+ readonly feedbackThanks: "Thanks for the feedback.";
176
+ readonly feedbackUndo: "Undo";
177
+ readonly feedbackError: "Feedback could not be saved. Try again.";
178
+ readonly notComparable: "Not comparable yet";
179
+ readonly basicExplanation: "Basic explanation";
180
+ readonly preparingDetailed: "Preparing a detailed explanation…";
181
+ readonly detailedReady: "Detailed explanation ready.";
182
+ readonly detailedUnavailable: "A detailed explanation is not available right now.";
183
+ readonly detailedRetry: "Try again";
184
+ readonly region: "Explanation";
185
+ readonly inProgress: "in progress";
186
+ readonly expand: "Expand explanation";
187
+ readonly collapse: "Collapse explanation";
188
+ readonly reasonWrongNumbers: "Wrong numbers";
189
+ readonly reasonMissingComparison: "Missing comparison";
190
+ readonly reasonUnclear: "Unclear";
191
+ readonly reasonTooLong: "Too long";
192
+ };
193
+ /** The explanation panel's copy with a host's overrides on top. */
194
+ type AnalyticsExplanationCopyOverrides = Partial<{ -readonly [K in keyof typeof ANALYTICS_EXPLANATION_COPY]: string }>;
195
+ type AnalyticsComparisonBasis = 'complete' | 'like_for_like' | 'current_in_progress_no_time' | 'not_comparable';
196
+ interface AnalyticsComparisonPeriod {
197
+ label: string;
198
+ start?: string;
199
+ end?: string;
200
+ fullEnd?: string;
201
+ inProgress?: boolean;
202
+ toDate?: boolean;
203
+ }
204
+ /** Backend `periodComparison` (reader-safe projection). */
205
+ interface AnalyticsPeriodComparison {
206
+ comparisonBasis: AnalyticsComparisonBasis | string;
207
+ reason?: string;
208
+ grain?: string;
209
+ measureField?: string;
210
+ seriesField?: string;
211
+ currentPeriod?: AnalyticsComparisonPeriod;
212
+ previousPeriod?: AnalyticsComparisonPeriod;
213
+ currentValue?: number;
214
+ previousToDateValue?: number;
215
+ previousFullValue?: number;
216
+ cutoffAt?: string;
217
+ cutoffSource?: 'now' | 'data_as_of' | string;
218
+ timezone?: string;
219
+ series?: Array<{
220
+ key: string;
221
+ currentValue?: number;
222
+ previousToDateValue?: number;
223
+ previousFullValue?: number;
224
+ }>;
225
+ }
226
+ interface AnalyticsComparisonDisplay {
227
+ basis: AnalyticsComparisonBasis | string;
228
+ kind: 'change' | 'neutral';
229
+ /** Set only for like-for-like (or complete) changes: red/green allowed. */
230
+ percent?: number;
231
+ tone: 'positive' | 'negative' | 'neutral';
232
+ /** Badge text: "↑ 50.0%", "Up from 0", "Today so far: 6 · Yesterday: 26 (full day)". */
233
+ label: string;
234
+ /** "vs yesterday at this time" / "vs same point last week". */
235
+ copy: string;
236
+ /** "Yesterday full day: 26". */
237
+ secondary?: string;
238
+ /** Compact one-line form for KPI cards: "Full day: 26". */
239
+ compactSecondary?: string;
240
+ /** Hover text with the cutoff time. */
241
+ title?: string;
242
+ reason?: string;
243
+ }
244
+ interface AnalyticsGroupComparisonPoint {
245
+ side: 'current' | 'previous';
246
+ basis: string;
247
+ /** Value to plot: previous-to-date on a like-for-like previous bucket. */
248
+ plotValue?: number;
249
+ /** Previous bucket: the full previous value (tooltip). */
250
+ fullValue?: number;
251
+ /** Previous bucket plotted at the same point (label "Yesterday at this time"). */
252
+ toDate: boolean;
253
+ /** Current bucket: this group's change, following the KPI basis rules. */
254
+ display?: AnalyticsComparisonDisplay;
255
+ }
256
+ /**
257
+ * Poll response for a detailed AI explanation. `explanation` is set only when
258
+ * `status` is "ready" and is the CHECKED explanation (never raw model text).
259
+ */
260
+ interface AnalyticsAIExplanationJob<E extends AnalyticsExplanationInput> {
261
+ status: AnalyticsAIExplanationStatus | string;
262
+ explanationId?: string;
263
+ retryAvailable?: boolean;
264
+ explanation?: E | null;
265
+ /**
266
+ * The free basic explanation as updated by the background job (it gains the
267
+ * baseline sentence, e.g. "within the recent range of 22–28"). Present while
268
+ * the AI explanation is pending or after it failed.
269
+ */
270
+ basic?: E | null;
271
+ }
272
+ interface AnalyticsAIExplanationTransport<E extends AnalyticsExplanationInput> {
273
+ /** GET the job by id with the surface's own credentials. */
274
+ poll: (explanationId: string, signal?: AbortSignal) => Promise<AnalyticsAIExplanationJob<E>>;
275
+ /** "Try again": re-request with the retry flag. Omit when retry is impossible. */
276
+ retry?: (explanationId: string, signal?: AbortSignal) => Promise<AnalyticsAIExplanationJob<E>>;
277
+ /** The job reached a final status: let the surface remember it (status only, not the payload). */
278
+ settled?: (explanationId: string, status: 'ready' | 'failed' | 'not_requested') => void;
279
+ }
280
+ //#endregion
281
+ //#region ../centrinfo-results/src/labels.d.ts
282
+ type AnalyticsExplanationCopy = Required<AnalyticsExplanationCopyOverrides>;
283
+ /** Every string the shared result renderer shows. Hosts override any subset. */
284
+ interface ResultLabels {
285
+ resultDetails: string;
286
+ liveMetric: string;
287
+ currentValue: string;
288
+ noMatchTitle: string;
289
+ noMatchBody: string;
290
+ chartType: string;
291
+ chooseChartType: string;
292
+ aggregate: string;
293
+ aggregateTitle: string;
294
+ aggregateCharge: string;
295
+ chartFallback: string;
296
+ chartLine: string;
297
+ chartBar: string;
298
+ chartStackedBar: string;
299
+ chartLineHint: string;
300
+ chartBarHint: string;
301
+ chartStackedBarHint: string;
302
+ aggregationSum: string;
303
+ aggregationAvg: string;
304
+ aggregationMin: string;
305
+ aggregationMax: string;
306
+ aggregationCount: string;
307
+ aggregationCountDistinct: string;
308
+ download: string;
309
+ downloadData: string;
310
+ expandTable: string;
311
+ expandChart: string;
312
+ restoreView: string;
313
+ aboutResult: string;
314
+ aboutPeriod: string;
315
+ aboutResults: string;
316
+ aboutChecked: string;
317
+ aboutTimezone: string;
318
+ aboutSourceData: string;
319
+ aboutFilters: string;
320
+ /** `{count}` placeholder. */
321
+ rowOne: string;
322
+ rowMany: string;
323
+ filtersOne: string;
324
+ filtersMany: string;
325
+ filtersApplied: string;
326
+ notSet: string;
327
+ noValue: string;
328
+ yes: string;
329
+ no: string;
330
+ chartValues: string;
331
+ /** `{measure}`, `{dimension}`. */
332
+ chartTitle: string;
333
+ seriesLimited: string;
334
+ summaryLatest: string;
335
+ summaryNoTrend: string;
336
+ summaryHighest: string;
337
+ summaryNoComparison: string;
338
+ zoomControls: string;
339
+ zoomIn: string;
340
+ zoomOut: string;
341
+ zoomReset: string;
342
+ zoomResetShort: string;
343
+ zoomNone: string;
344
+ zoomAllOne: string;
345
+ zoomAllMany: string;
346
+ zoomRange: string;
347
+ inProgress: string;
348
+ newContent: string;
349
+ updatedAt: string;
350
+ liveData: string;
351
+ viewData: string;
352
+ hideData: string;
353
+ inProgressLegend: string;
354
+ /** Overrides for the explanation panel copy. */
355
+ explanation?: Partial<AnalyticsExplanationCopy>;
356
+ governedResult: string;
357
+ }
358
+ //#endregion
359
+ //#region src/i18n.d.ts
5
360
  /**
6
361
  * Every user-visible chrome string in one place. The widget ships English
7
362
  * defaults; a host localises by passing `labels` to `Centrinfo.init()` —
@@ -11,6 +366,12 @@ import "preact";
11
366
  * never produces.
12
367
  */
13
368
  interface WidgetStrings {
369
+ /**
370
+ * Labels for analytics answers (KPI, chart, table, details, explanation).
371
+ * Any subset overrides the English defaults; `explanation` holds the
372
+ * explanation panel's wording.
373
+ */
374
+ analytics?: Partial<ResultLabels>;
14
375
  /** Optional full-page labels. Older integrations use the core labels as fallbacks. */
15
376
  fullPageNewConversation?: string;
16
377
  fullPageHistory?: string;
@@ -36,6 +397,10 @@ interface WidgetStrings {
36
397
  /** Header presence line when bootstrap was loaded with `offline`. */
37
398
  statusOffline: string;
38
399
  liveSupport: string;
400
+ /** Button on the "teammate left, the AI is back" notice. */
401
+ reconnectSupport: string;
402
+ /** Message that opens the live-support form again after reconnecting. */
403
+ reconnectPrompt: string;
39
404
  waitingForTeam: string;
40
405
  assistantName: string;
41
406
  chatName: string;
@@ -59,6 +424,8 @@ interface WidgetStrings {
59
424
  reopenVoiceChat: string;
60
425
  voiceConnecting: string;
61
426
  voiceListening: string;
427
+ voiceHearing: string;
428
+ voiceUnavailable: string;
62
429
  voiceProcessing: string;
63
430
  voiceSpeaking: string;
64
431
  voiceNoise: string;
@@ -95,6 +462,7 @@ interface WidgetStrings {
95
462
  /** Per-message 👍/👎 feedback. */
96
463
  feedbackHelpful: string;
97
464
  feedbackNotHelpful: string;
465
+ feedbackAnswerPrompt: string;
98
466
  feedbackThanks: string;
99
467
  /** End-of-chat CSAT prompt. */
100
468
  csatPrompt: string;
@@ -110,10 +478,23 @@ interface WidgetStrings {
110
478
  emptyReply: string;
111
479
  errorGeneric: string;
112
480
  errorRateLimit: string;
481
+ /** Shown in place of an analytics result that is not kept in local storage. */
482
+ resultExpired: string;
113
483
  attaching: string;
114
484
  attachTooLarge: string;
115
485
  attachFailed: string;
486
+ attachPreviewTitle: string;
487
+ attachOpen: string;
488
+ attachDownload: string;
489
+ attachPreviewClose: string;
490
+ attachPreviewLoading: string;
491
+ attachPreviewFailed: string;
492
+ attachPreviewUnsupported: string;
493
+ attachAnalysisFailed: string;
116
494
  removeAttachment: string;
495
+ attachLimit: string;
496
+ attachedFiles: string;
497
+ removeAttachmentNamed: string;
117
498
  dropFileHere: string;
118
499
  clearDeviceData: string;
119
500
  clearDeviceDataBody: string;
@@ -129,6 +510,8 @@ interface WidgetStrings {
129
510
  /** Generic action-form success fallback + error. */
130
511
  formThanks: string;
131
512
  formError: string;
513
+ /** Case number appended to a confirmation. `{reference}` is the case number. */
514
+ caseReference: string;
132
515
  /** Public action drawer chrome. Action-specific copy remains descriptor data. */
133
516
  actionContactOptions: string;
134
517
  actionGetInTouch: string;
@@ -146,6 +529,7 @@ interface WidgetStrings {
146
529
  bookingPickDay: string;
147
530
  bookingPickTimeLabel: string;
148
531
  bookingDuration: string;
532
+ bookingCallbackDuration: string;
149
533
  bookingTimezone: string;
150
534
  bookingSchedulerFallback: string;
151
535
  bookingCheckingAvailability: string;
@@ -157,6 +541,11 @@ interface WidgetStrings {
157
541
  bookingNotOffered: string;
158
542
  /** Confirmation after requesting a demo. `{when}` = the chosen slot. */
159
543
  bookingRequested: string;
544
+ /** The request was retained but the calendar provider did not confirm it. */
545
+ bookingVerificationPending: string;
546
+ /** Confirmation after requesting a callback. `{when}` = the chosen slot. */
547
+ bookingCallbackRequested: string;
548
+ bookingCallbackConfirmed: string;
160
549
  /** Confirmation when a real calendar event was created. `{when}` = slot. */
161
550
  bookingConfirmed: string;
162
551
  /** Shown when the chosen slot was just taken by someone else. */
@@ -166,12 +555,22 @@ interface WidgetStrings {
166
555
  bookingViaProvider: string;
167
556
  bookingOpenScheduler: string;
168
557
  bookingLinkOpened: string;
558
+ bookingScheduled: string;
559
+ bookingBackToChat: string;
560
+ bookingOpenNewTab: string;
561
+ bookingCloseScheduler: string;
562
+ bookingLoadingScheduler: string;
169
563
  bookingMeetingLink: string;
564
+ bookingManageLink: string;
565
+ bookingCheckingDetails: string;
566
+ bookingDetailsUnavailable: string;
567
+ bookingRetryDetails: string;
170
568
  /** Preview mode (data-preview): canned reply, action note, top banner. */
171
569
  previewReply: string;
172
570
  previewActionNote: string;
173
571
  previewBanner: string;
174
572
  }
573
+ declare const StringsProvider: preact0.Provider<WidgetStrings>;
175
574
  //#endregion
176
575
  //#region src/api/types.d.ts
177
576
  /** The result metadata that arrives with (or after) an answer. */
@@ -208,6 +607,9 @@ interface PublicChatAction {
208
607
  submitLabel: string;
209
608
  fields: PublicChatActionField[];
210
609
  delivery: string;
610
+ /** True when submitting brings a teammate into this chat; false for a
611
+ * follow-up by email or phone. Several actions share an endpoint. */
612
+ liveHandoff?: boolean;
211
613
  prompt: string;
212
614
  shortLabel: string;
213
615
  enabled: boolean;
@@ -217,7 +619,17 @@ interface PublicChatAction {
217
619
  /** Client-only compatibility marker. Never emitted by the production catalogue. */
218
620
  legacyFallback?: boolean;
219
621
  }
622
+ interface LiveAudioSegment {
623
+ seq: number;
624
+ /** Empty when the server could not voice the piece; speak `text` instead. */
625
+ audioBase64: string;
626
+ mimeType?: string;
627
+ /** The piece as spoken (no links or markdown). */
628
+ text?: string;
629
+ }
220
630
  interface TurnResult {
631
+ /** True when the reply was spoken in live pieces (onAudioSegment). */
632
+ liveAudio?: boolean;
221
633
  answer: string;
222
634
  sources: Source[];
223
635
  suggestedReplies: string[];
@@ -248,6 +660,7 @@ interface AnalyticsVisualizationColumn {
248
660
  dataType: 'text' | 'number' | 'currency' | 'percent' | 'boolean' | 'date' | 'datetime';
249
661
  semanticRole: 'identifier' | 'dimension' | 'measure' | 'date' | 'geography' | 'boolean';
250
662
  aggregation?: 'none' | 'sum' | 'avg' | 'count' | 'count_distinct' | 'min' | 'max';
663
+ allowedAggregations?: Array<'none' | 'sum' | 'avg' | 'count' | 'count_distinct' | 'min' | 'max'>;
251
664
  formatPattern?: string;
252
665
  currencyCode?: string;
253
666
  description?: string;
@@ -265,21 +678,101 @@ interface AnalyticsVisualizationRecommendation {
265
678
  reason?: string;
266
679
  confidence?: number;
267
680
  }
681
+ type AnalyticsValueStatus = 'observed' | 'confirmed_zero' | 'empty_bucket' | 'unconfirmed_zero' | 'missing';
682
+ interface AnalyticsEvidencePeriod {
683
+ label: string;
684
+ start?: string;
685
+ end?: string;
686
+ timezone?: string;
687
+ }
688
+ interface AnalyticsExplanationEvidenceItem {
689
+ id: string;
690
+ text: string;
691
+ kind?: string;
692
+ metric?: string;
693
+ period?: AnalyticsEvidencePeriod;
694
+ filters?: string[];
695
+ value?: number;
696
+ valueStatus: AnalyticsValueStatus | string;
697
+ statusReason?: string;
698
+ source: {
699
+ kind: 'card' | 'supporting_query' | string;
700
+ insightId?: string;
701
+ queryRunId?: string;
702
+ liveboardTileId?: string;
703
+ };
704
+ checkedAt?: string;
705
+ }
706
+ interface AnalyticsExplanationPeriod {
707
+ evidenceId?: string;
708
+ label: string;
709
+ start?: string;
710
+ end?: string;
711
+ timezone?: string;
712
+ current?: boolean;
713
+ inProgress?: boolean;
714
+ value?: number;
715
+ valueText?: string;
716
+ valueStatus: AnalyticsValueStatus | string;
717
+ statusReason?: string;
718
+ source?: 'card' | 'supporting_query' | string;
719
+ }
720
+ interface AnalyticsExplanationMissing {
721
+ evidenceId?: string;
722
+ label: string;
723
+ period?: AnalyticsEvidencePeriod;
724
+ reason: string;
725
+ }
726
+ interface AnalyticsExplanationDataFreshness {
727
+ status: string;
728
+ dataAsOf?: string;
729
+ expectedThrough?: string;
730
+ lagDays?: number;
731
+ checkedAt?: string;
732
+ timezone?: string;
733
+ }
734
+ interface AnalyticsValueProvenance {
735
+ rowIndex: number;
736
+ field: string;
737
+ period?: string;
738
+ filled: 'empty_bucket' | string;
739
+ status: 'empty_bucket' | 'confirmed_zero' | 'unconfirmed_zero' | string;
740
+ reason?: string;
741
+ }
268
742
  interface AnalyticsVisualizationExplanation {
743
+ /** Stable opaque id; used only for "Was this helpful?" feedback. */
744
+ explanationId?: string;
269
745
  conversationalPreface?: string;
270
746
  metricReference?: string;
271
747
  headline: string;
272
748
  summary: string;
273
749
  evidence?: string[];
750
+ headlineEvidenceIds?: string[];
751
+ summaryEvidenceIds?: string[];
752
+ businessMeaningEvidenceIds?: string[];
753
+ evidenceStatements?: Array<{
754
+ text: string;
755
+ evidenceIds?: string[];
756
+ }>;
757
+ evidenceItems?: AnalyticsExplanationEvidenceItem[];
758
+ periods?: AnalyticsExplanationPeriod[];
759
+ missing?: AnalyticsExplanationMissing[];
760
+ timezone?: string;
761
+ checkedAt?: string;
762
+ currentPeriodInProgress?: boolean;
763
+ cached?: boolean;
764
+ dataFreshness?: AnalyticsExplanationDataFreshness;
274
765
  businessMeaning?: string;
275
766
  possibleDrivers?: Array<{
276
767
  hypothesis: string;
277
768
  howToCheck: string;
769
+ evidenceIds?: string[];
278
770
  }>;
279
771
  recommendations?: Array<{
280
772
  action: string;
281
773
  why: string;
282
774
  successMetric?: string;
775
+ evidenceIds?: string[];
283
776
  }>;
284
777
  forecast?: {
285
778
  text: string;
@@ -290,6 +783,12 @@ interface AnalyticsVisualizationExplanation {
290
783
  limitations?: string[];
291
784
  followUps?: string[];
292
785
  source: 'governed_result' | 'ai_grounded' | 'rag_deterministic_analysis' | 'analysis_contract' | string;
786
+ /** The detailed AI explanation that loads separately (poll by explanationId). */
787
+ aiExplanation?: {
788
+ status: string;
789
+ explanationId?: string;
790
+ retryAvailable?: boolean;
791
+ } | null;
293
792
  }
294
793
  interface AnalyticsVisualizationAnalysis {
295
794
  summary: string;
@@ -419,6 +918,7 @@ interface AnalyticsVisualization {
419
918
  tableAvailable?: boolean;
420
919
  downloadAvailable?: boolean;
421
920
  explanation?: AnalyticsVisualizationExplanation;
921
+ valueProvenance?: AnalyticsValueProvenance[];
422
922
  }
423
923
  interface SpeechResult {
424
924
  providerReady: boolean;
@@ -433,6 +933,9 @@ interface LiveEvent {
433
933
  content: string;
434
934
  authorName?: string;
435
935
  createdAt: string;
936
+ /** On an ai_handback notice: the visitor had asked for a person, so offer
937
+ * to bring one back. */
938
+ reconnectOffered?: boolean;
436
939
  }
437
940
  interface LiveEventsResult {
438
941
  mode: 'ai' | 'queued' | 'human';
@@ -448,6 +951,8 @@ interface AuthenticatedHistoryMessage {
448
951
  content: string;
449
952
  authorName?: string;
450
953
  messageType?: string;
954
+ /** On an ai_handback notice: the visitor had asked for a person. */
955
+ reconnectOffered?: boolean;
451
956
  sources?: Array<{
452
957
  title?: string;
453
958
  url?: string;
@@ -470,9 +975,22 @@ interface AuthenticatedHistoryResult {
470
975
  interface StreamCallbacks {
471
976
  /** Called with each incremental text chunk. */
472
977
  onChunk: (text: string) => void;
978
+ /** The answer text and metadata have arrived; optional reply audio may follow. */
979
+ onTextReady?: () => void;
980
+ /** Live answers: what was streamed so far is replaced by a newer answer. */
981
+ onReset?: () => void;
982
+ /** Live answers: one spoken piece of the reply, in order, while it is still
983
+ * being written. Older backends send a single whole-reply clip instead. */
984
+ onAudioSegment?: (segment: LiveAudioSegment) => void;
473
985
  signal?: AbortSignal;
474
986
  /** True only for turns sent from the active Speak-with-AI call. */
475
987
  voicePlaybackRequested?: boolean;
988
+ /** Stable id of the visitor's message. A retry sends the same id, so the
989
+ * backend answers and bills the turn once. */
990
+ clientMessageId?: string;
991
+ attachmentId?: string;
992
+ /** Every stored file sent with this message. */
993
+ attachmentIds?: string[];
476
994
  }
477
995
  interface ActionResult {
478
996
  ok: boolean;
@@ -481,15 +999,33 @@ interface ActionResult {
481
999
  * a real calendar event was created (event mode) or a Calendly link was
482
1000
  * resolved (link mode). Absent when it fell back to a staff-follow-up request. */
483
1001
  booking?: DemoBooking;
1002
+ /** Case number for a request staff will follow up on (support, demo, callback). */
1003
+ caseReference?: string;
1004
+ /** Inquiry receiving this booking receipt; used to confirm hosted Calendly completion. */
1005
+ inquiryId?: string;
484
1006
  }
485
1007
  /** Outcome of a live book-a-demo (mirrors backend services.PublicDemoBooking). */
486
1008
  interface DemoBooking {
487
1009
  mode: 'event' | 'link';
488
1010
  provider: string;
489
1011
  confirmed?: boolean;
1012
+ /** The request and slot were retained, but the provider outcome could not be verified. */
1013
+ verificationPending?: boolean;
490
1014
  eventLink?: string;
491
1015
  meetingUrl?: string;
492
1016
  schedulingLink?: string;
1017
+ cancelUrl?: string;
1018
+ rescheduleUrl?: string;
1019
+ startAt?: string;
1020
+ endAt?: string;
1021
+ timezone?: string;
1022
+ title?: string;
1023
+ }
1024
+ interface HostedBookingConfirmation {
1025
+ sessionId: string;
1026
+ inquiryId: string;
1027
+ eventUri: string;
1028
+ inviteeUri: string;
493
1029
  }
494
1030
  /** A 👍/👎 a visitor left on one assistant reply (POST /public-chat/feedback). */
495
1031
  interface FeedbackInput {
@@ -503,6 +1039,31 @@ interface FeedbackInput {
503
1039
  question?: string;
504
1040
  answer?: string;
505
1041
  }
1042
+ /** "Was this helpful?" vote on one analytics explanation
1043
+ * (POST /public-chat/explanation-feedback). One vote per visitor session per
1044
+ * explanation; `clear` removes it. Never billed. */
1045
+ interface ExplanationFeedbackInput {
1046
+ sessionId: string;
1047
+ explanationId: string;
1048
+ rating: 'up' | 'down' | 'clear';
1049
+ reasons?: Array<'wrong_numbers' | 'missing_comparison' | 'unclear' | 'too_long'>;
1050
+ comment?: string;
1051
+ modelId?: string;
1052
+ modelVersion?: number;
1053
+ /** Which public surface showed the explanation. */
1054
+ surface?: 'widget' | 'chat_app';
1055
+ }
1056
+ /** Detailed AI explanation job for an analytics answer
1057
+ * (GET /public-chat/analytics-explanations/:id). `explanation` is set only
1058
+ * when ready and is the checked, public-safe explanation. */
1059
+ interface ExplanationJob {
1060
+ status: 'pending' | 'ready' | 'failed' | 'not_requested' | string;
1061
+ explanationId?: string;
1062
+ retryAvailable?: boolean;
1063
+ explanation?: Record<string, unknown> | null;
1064
+ /** The free basic explanation as updated by the job (gains the baseline sentence). */
1065
+ basic?: Record<string, unknown> | null;
1066
+ }
506
1067
  /** A [start, end) window the org's calendar is busy. */
507
1068
  interface BusyRange {
508
1069
  start: string;
@@ -541,21 +1102,24 @@ interface Transport {
541
1102
  stream(question: string, sessionId: string, cb: StreamCallbacks): Promise<TurnResult>;
542
1103
  /** Poll for staff/system events after a timestamp during live handoff. */
543
1104
  liveEvents(sessionId: string, after: string): Promise<LiveEventsResult>;
1105
+ /** Short-lived signal that this chat is open in a visible browser tab. */
1106
+ presence(sessionId: string): Promise<void>;
544
1107
  /** Soft visitor typing hint for the staff console. */
545
1108
  typing(sessionId: string, isTyping: boolean): Promise<void>;
546
1109
  action(type: string, payload: Record<string, unknown>, endpointOverride?: string): Promise<ActionResult>;
1110
+ confirmHostedBooking?(input: HostedBookingConfirmation): Promise<DemoBooking>;
547
1111
  /** Synthesize short widget UI prompts through the token's configured TTS voice. */
548
1112
  speak(text: string): Promise<SpeechResult>;
549
1113
  transcribe(audioBase64: string, mimeType: string, languageHint?: string, durationSeconds?: number): Promise<string>;
550
1114
  /** Preferred binary voice upload. Optional for backward-compatible custom transports. */
1115
+ /** A file the visitor attached to this conversation, for preview. */
1116
+ fetchAttachment?(attachmentId: string, sessionId: string): Promise<Blob>;
551
1117
  transcribeAudio?(audio: Blob, mimeType: string, languageHint?: string, durationSeconds?: number): Promise<string>;
552
- /**
553
- * Extract text from a visitor-attached image / PDF via the backend's
554
- * multimodal endpoint (`POST /public-chat/extract`). The returned text is
555
- * prepended to the visitor's next message so the AI can answer about it.
556
- * Resolves to '' when extraction is unavailable / fails.
557
- */
558
- extract(fileBase64: string, mimeType: string, filename?: string): Promise<string>;
1118
+ uploadAttachment?(fileBase64: string, mimeType: string, filename: string, sessionId: string, analyze: boolean): Promise<{
1119
+ id: string;
1120
+ text: string;
1121
+ analysisFailed: boolean;
1122
+ }>;
559
1123
  /** Search GIFs (Tenor). Returns [] when no key is configured. */
560
1124
  searchGifs(query: string): Promise<GifResult[]>;
561
1125
  /**
@@ -577,6 +1141,13 @@ interface Transport {
577
1141
  /** Record a 👍/👎 on an assistant reply (`POST /public-chat/feedback`).
578
1142
  * Best-effort — a failed rating never disrupts the chat. */
579
1143
  sendFeedback(input: FeedbackInput): Promise<void>;
1144
+ /** Record a vote on an analytics explanation. Rejects on failure so the UI
1145
+ * can offer a retry (unlike `sendFeedback`). Optional for custom transports. */
1146
+ sendExplanationFeedback?(input: ExplanationFeedbackInput): Promise<void>;
1147
+ /** Poll the detailed AI explanation of an analytics answer. Optional. */
1148
+ fetchExplanation?(explanationId: string, sessionId: string, surface?: 'widget' | 'chat_app', signal?: AbortSignal): Promise<ExplanationJob>;
1149
+ /** "Try again" on a failed detailed AI explanation. Optional. */
1150
+ retryExplanation?(explanationId: string, sessionId: string, surface?: 'widget' | 'chat_app'): Promise<ExplanationJob>;
580
1151
  }
581
1152
  //#endregion
582
1153
  //#region src/types.d.ts
@@ -649,6 +1220,11 @@ interface WidgetConfig {
649
1220
  labels?: Partial<WidgetStrings>;
650
1221
  /** Locale used to select a translation bundle. Defaults to browser locale. */
651
1222
  locale?: string;
1223
+ /**
1224
+ * Text direction. `auto` (default) follows the locale: Arabic, Hebrew,
1225
+ * Persian, Urdu and similar scripts render right-to-left.
1226
+ */
1227
+ dir?: 'ltr' | 'rtl' | 'auto';
652
1228
  /**
653
1229
  * Translation data keyed by locale (`fr`, `fr-CA`, `yo`, ...). Exact locale
654
1230
  * wins, then its base language. Explicit `labels` still wins over the pack.
@@ -748,6 +1324,14 @@ interface WidgetConfig {
748
1324
  role: 'user' | 'assistant';
749
1325
  content: string;
750
1326
  }) => void;
1327
+ /** Called only for a server-cited source in a signed analytics answer.
1328
+ * The host should open it through its authorized analytics client. */
1329
+ onOpenAnalyticsSource?: (source: {
1330
+ kind: 'liveboard_tile' | 'insight';
1331
+ id: string;
1332
+ /** Result filters for a host to validate against the destination board. */
1333
+ appliedFilters?: AnalyticsVisualization['appliedFilters'];
1334
+ }) => void;
751
1335
  onAction?: (action: string) => void;
752
1336
  onHandoff?: () => void;
753
1337
  }
@@ -848,7 +1432,7 @@ interface WidgetHandle {
848
1432
  }
849
1433
  /** A rendered chat message. */
850
1434
  interface ChatArtifact {
851
- type: 'image' | 'resource_link' | 'visualization';
1435
+ type: 'image' | 'video' | 'resource_link' | 'visualization';
852
1436
  name?: string;
853
1437
  title?: string;
854
1438
  caption?: string;
@@ -860,6 +1444,12 @@ interface ChatArtifact {
860
1444
  /** Local compatibility bridge for the existing governed analytics result. */
861
1445
  visualization?: AnalyticsVisualization;
862
1446
  }
1447
+ /** A file sent with a visitor message. */
1448
+ interface MessageAttachment {
1449
+ /** The stored attachment, when it was uploaded. */
1450
+ id?: string;
1451
+ name: string;
1452
+ }
863
1453
  interface ChatMessage {
864
1454
  id: string;
865
1455
  role: 'user' | 'assistant' | 'system';
@@ -868,12 +1458,21 @@ interface ChatMessage {
868
1458
  authorName?: string;
869
1459
  /** Live handoff event type from the backend, e.g. agent_joined. */
870
1460
  liveEventType?: string;
1461
+ /** An ai_handback notice that may offer "Reconnect to support". */
1462
+ offerReconnect?: boolean;
1463
+ /** Local assistant message opened by "Reconnect to support". */
1464
+ reconnectOffer?: boolean;
871
1465
  /** ISO timestamp for server-originated live events. */
872
1466
  createdAt?: string;
873
1467
  /** Inline image (e.g. a GIF the visitor sent). Rendered in the bubble. */
874
1468
  imageUrl?: string;
875
1469
  /** Name of a file the visitor attached (rendered as a chip on their bubble). */
876
1470
  attachmentName?: string;
1471
+ /** The stored attachment behind attachmentName, for preview. */
1472
+ attachmentId?: string;
1473
+ /** Every file sent with this message (newer messages; older ones use
1474
+ * attachmentName / attachmentId). */
1475
+ attachments?: MessageAttachment[];
877
1476
  sources?: Source[];
878
1477
  suggestedReplies?: string[];
879
1478
  availableActions?: string[];
@@ -896,6 +1495,10 @@ interface ChatMessage {
896
1495
  feedback?: 'up' | 'down';
897
1496
  visualization?: AnalyticsVisualization;
898
1497
  artifacts?: ChatArtifact[];
1498
+ /** Set on a restored message whose analytics result was not kept in local storage. */
1499
+ resultExpired?: {
1500
+ title?: string;
1501
+ };
899
1502
  }
900
1503
  interface Source {
901
1504
  title?: string;
@@ -959,7 +1562,7 @@ interface BootstrapInfo {
959
1562
  offline?: boolean;
960
1563
  /** Book-a-demo scheduler status (present only when book-a-demo is enabled).
961
1564
  * Drives the demo UX: event-mode → in-widget slot picker that creates a real
962
- * calendar event; link-mode → a "Book on Calendly" link; absent/!connected →
1565
+ * calendar event or Calendly invitee; link-mode → a hosted scheduler; absent/!connected →
963
1566
  * slot picker that just files a request for staff to confirm. */
964
1567
  scheduler?: SchedulerInfo;
965
1568
  }
@@ -984,4 +1587,4 @@ interface SchedulerInfo {
984
1587
  };
985
1588
  }
986
1589
  //#endregion
987
- export { PublicChatActionField as _, Source as a, WidgetConfig as c, WidgetUser as d, ActionResult as f, PublicChatAction as g, GifResult as h, FeaturedLink as i, WidgetHandle as l, DemoSlotsResult as m, ChatArtifact as n, Visitor as o, AnalyticsVisualization as p, ChatMessage as r, WidgetActionTranslation as s, BootstrapInfo as t, WidgetThemeTokens as u, Transport as v, WidgetStrings as y };
1590
+ export { StringsProvider as C, AnalyticsExplanationInput as D, AnalyticsAIExplanationTransport as E, AnalyticsGroupComparisonPoint as O, Transport as S, ResultLabels as T, DemoSlotsResult as _, MessageAttachment as a, PublicChatAction as b, Visitor as c, WidgetHandle as d, WidgetThemeTokens as f, DemoBooking as g, AnalyticsVisualization as h, FeaturedLink as i, AnalyticsPeriodComparison as k, WidgetActionTranslation as l, ActionResult as m, ChatArtifact as n, SchedulerInfo as o, WidgetUser as p, ChatMessage as r, Source as s, BootstrapInfo as t, WidgetConfig as u, ExplanationFeedbackInput as v, WidgetStrings as w, PublicChatActionField as x, GifResult as y };