@accurix/centrinfo-widget 1.1.0 → 4.0.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.
@@ -11,14 +11,59 @@ import "preact";
11
11
  * never produces.
12
12
  */
13
13
  interface WidgetStrings {
14
+ /** Optional full-page labels. Older integrations use the core labels as fallbacks. */
15
+ fullPageNewConversation?: string;
16
+ fullPageHistory?: string;
17
+ fullPageShare?: string;
18
+ fullPageExport?: string;
19
+ fullPageSupportQueued?: string;
20
+ fullPageSources?: string;
21
+ fullPageActions?: string;
22
+ fullPageDownloadTranscript?: string;
23
+ fullPageLiveAgent?: string;
24
+ fullPageAttachmentTooLarge?: string;
25
+ fullPageAttachmentUnsupported?: string;
26
+ fullPageAttachmentFailed?: string;
14
27
  openChat: string;
15
28
  closeChat: string;
29
+ closeHistory: string;
30
+ unreadMessage: string;
31
+ unreadMessages: string;
16
32
  muteSounds: string;
17
33
  unmuteSounds: string;
18
34
  /** Header presence line when the org is reachable. */
19
35
  statusOnline: string;
20
36
  /** Header presence line when bootstrap was loaded with `offline`. */
21
37
  statusOffline: string;
38
+ liveSupport: string;
39
+ waitingForTeam: string;
40
+ assistantName: string;
41
+ chatName: string;
42
+ welcomeLabel: string;
43
+ welcomeEyebrow: string;
44
+ welcomePrompt: string;
45
+ agentTyping: string;
46
+ expandedAnalyticsResult: string;
47
+ privacyAndData: string;
48
+ muteMicrophone: string;
49
+ unmuteMicrophone: string;
50
+ chooseMicrophone: string;
51
+ defaultMicrophone: string;
52
+ microphone: string;
53
+ talkNow: string;
54
+ expandView: string;
55
+ exitExpandedView: string;
56
+ minimizeVoiceChat: string;
57
+ endVoiceChat: string;
58
+ restoreVoiceChat: string;
59
+ reopenVoiceChat: string;
60
+ voiceConnecting: string;
61
+ voiceListening: string;
62
+ voiceProcessing: string;
63
+ voiceSpeaking: string;
64
+ voiceNoise: string;
65
+ voiceMisunderstood: string;
66
+ voiceDenied: string;
22
67
  composerPlaceholder: string;
23
68
  send: string;
24
69
  emoji: string;
@@ -26,6 +71,7 @@ interface WidgetStrings {
26
71
  attachFile: string;
27
72
  recordVoice: string;
28
73
  stopRecording: string;
74
+ actionTestMode: string;
29
75
  stop: string;
30
76
  copy: string;
31
77
  copied: string;
@@ -67,6 +113,11 @@ interface WidgetStrings {
67
113
  attaching: string;
68
114
  attachTooLarge: string;
69
115
  attachFailed: string;
116
+ removeAttachment: string;
117
+ dropFileHere: string;
118
+ clearDeviceData: string;
119
+ clearDeviceDataBody: string;
120
+ clearDeviceDataCta: string;
70
121
  /** Handoff card (manual follow-up request). */
71
122
  handoffTitle: string;
72
123
  handoffName: string;
@@ -78,9 +129,32 @@ interface WidgetStrings {
78
129
  /** Generic action-form success fallback + error. */
79
130
  formThanks: string;
80
131
  formError: string;
132
+ /** Public action drawer chrome. Action-specific copy remains descriptor data. */
133
+ actionContactOptions: string;
134
+ actionGetInTouch: string;
135
+ actionMore: string;
136
+ actionNeedHelp: string;
137
+ actionChoose: string;
138
+ actionFooter: string;
139
+ actionCategorySupport: string;
140
+ actionCategorySales: string;
141
+ actionCategoryMarketing: string;
142
+ actionClose: string;
143
+ actionAs: string;
81
144
  /** Demo-booking picker. */
82
145
  bookingPickTime: string;
146
+ bookingPickDay: string;
147
+ bookingPickTimeLabel: string;
83
148
  bookingDuration: string;
149
+ bookingTimezone: string;
150
+ bookingSchedulerFallback: string;
151
+ bookingCheckingAvailability: string;
152
+ bookingNoSlots: string;
153
+ bookingAvailabilityUnavailable: string;
154
+ bookingEarlierToday: string;
155
+ bookingCalendarBusy: string;
156
+ bookingAlreadyBooked: string;
157
+ bookingNotOffered: string;
84
158
  /** Confirmation after requesting a demo. `{when}` = the chosen slot. */
85
159
  bookingRequested: string;
86
160
  /** Confirmation when a real calendar event was created. `{when}` = slot. */
@@ -101,11 +175,58 @@ interface WidgetStrings {
101
175
  //#endregion
102
176
  //#region src/api/types.d.ts
103
177
  /** The result metadata that arrives with (or after) an answer. */
178
+ /**
179
+ * One visitor action, described entirely by the backend.
180
+ *
181
+ * Production actions arrive from the backend. A visibly marked test-mode shim
182
+ * remains only for installations running an older backend response contract.
183
+ *
184
+ * `id` is the stable identifier (e.g. `public_book_demo`); it is never shown
185
+ * to a visitor. Everything a visitor reads is display text the backend may
186
+ * translate.
187
+ */
188
+ interface PublicChatActionField {
189
+ key: string;
190
+ label: string;
191
+ kind: 'text' | 'email' | 'tel' | 'textarea';
192
+ required?: boolean;
193
+ identity?: 'name' | 'email' | 'phone';
194
+ placeholder?: string;
195
+ }
196
+ type PublicChatActionReadiness = 'available' | 'degraded' | 'unavailable';
197
+ interface PublicChatAction {
198
+ id: string;
199
+ /** POST /public-chat/<endpoint> */
200
+ endpoint: string;
201
+ /** Generic renderer selected by the backend contract. Defaults to form. */
202
+ presentation?: 'form' | 'booking';
203
+ label: string;
204
+ description: string;
205
+ category: 'support' | 'sales' | 'marketing';
206
+ icon: string;
207
+ formTitle: string;
208
+ submitLabel: string;
209
+ fields: PublicChatActionField[];
210
+ delivery: string;
211
+ prompt: string;
212
+ shortLabel: string;
213
+ enabled: boolean;
214
+ readiness: PublicChatActionReadiness;
215
+ /** Visitor-safe explanation shown when readiness is `degraded`. */
216
+ readinessNote?: string;
217
+ /** Client-only compatibility marker. Never emitted by the production catalogue. */
218
+ legacyFallback?: boolean;
219
+ }
104
220
  interface TurnResult {
105
221
  answer: string;
106
222
  sources: Source[];
107
223
  suggestedReplies: string[];
224
+ /** Legacy: raw tool ids. Prefer `actions`. */
108
225
  availableActions: string[];
226
+ /** Structured action descriptors. Empty on older backends. */
227
+ actions?: PublicChatAction[];
228
+ /** Action the backend resolved for this turn — open its form directly. */
229
+ selectedAction?: string;
109
230
  handoffOffered: boolean;
110
231
  /** Contact fields the backend wants inline before handoff, e.g. ["email"]. */
111
232
  requestedContactFields?: string[];
@@ -119,6 +240,7 @@ interface TurnResult {
119
240
  audioBase64?: string;
120
241
  mimeType?: string;
121
242
  visualization?: AnalyticsVisualization;
243
+ artifacts?: ChatArtifact[];
122
244
  }
123
245
  interface AnalyticsVisualizationColumn {
124
246
  key: string;
@@ -135,7 +257,7 @@ interface AnalyticsVisualizationColumn {
135
257
  groupable?: boolean;
136
258
  }
137
259
  interface AnalyticsVisualizationRecommendation {
138
- type: 'kpi' | 'table' | 'line' | 'area' | 'bar' | 'stacked_bar' | 'pie' | 'scatter' | 'funnel';
260
+ type: 'kpi' | 'table' | 'line' | 'area' | 'bar' | 'stacked_bar' | 'pie' | 'scatter' | 'funnel' | 'heatmap' | 'radar';
139
261
  mode: string;
140
262
  categoryField?: string;
141
263
  valueFields?: string[];
@@ -144,6 +266,8 @@ interface AnalyticsVisualizationRecommendation {
144
266
  confidence?: number;
145
267
  }
146
268
  interface AnalyticsVisualizationExplanation {
269
+ conversationalPreface?: string;
270
+ metricReference?: string;
147
271
  headline: string;
148
272
  summary: string;
149
273
  evidence?: string[];
@@ -165,12 +289,85 @@ interface AnalyticsVisualizationExplanation {
165
289
  };
166
290
  limitations?: string[];
167
291
  followUps?: string[];
168
- source: 'governed_result' | 'ai_grounded';
292
+ source: 'governed_result' | 'ai_grounded' | 'rag_deterministic_analysis' | 'analysis_contract' | string;
293
+ }
294
+ interface AnalyticsVisualizationAnalysis {
295
+ summary: string;
296
+ highlights?: Array<{
297
+ kind: 'value' | 'result' | 'leader' | 'lowest' | 'share' | 'trend' | string;
298
+ title: string;
299
+ description: string;
300
+ field?: string;
301
+ value?: number;
302
+ changePercent?: number;
303
+ }>;
304
+ suggestedQuestions?: string[];
305
+ limitations?: string[];
306
+ method?: 'governed_result' | 'ai_grounded' | 'ai_enhanced' | string;
307
+ }
308
+ interface AnalyticsVisualizationAnalysisIntent {
309
+ method: string;
310
+ metric?: string;
311
+ metricOperation?: 'direct' | 'ratio' | 'rate' | 'share' | string;
312
+ numeratorMetric?: string;
313
+ denominatorMetric?: string;
314
+ timeField?: string;
315
+ breakdowns?: string[];
316
+ comparison?: string;
317
+ requestedAspects?: string[];
318
+ requestedOutputs?: string[];
319
+ requestedEntities?: string[];
320
+ requiredEvidence?: string[];
321
+ status: 'planned' | 'completed' | 'incomplete' | 'failed' | string;
322
+ message?: string;
323
+ }
324
+ interface AnalyticsVisualizationAnalysisCoverage {
325
+ complete: boolean;
326
+ coveredAspects?: string[];
327
+ missingAspects?: string[];
328
+ evidenceKeys?: string[];
329
+ }
330
+ interface AnalyticsVisualizationBusinessAnalysis {
331
+ type: 'analysis_result';
332
+ method: string;
333
+ question: string;
334
+ answer: string;
335
+ evidence: Array<{
336
+ id: string;
337
+ statement: string;
338
+ values?: Record<string, unknown>;
339
+ }>;
340
+ tables?: Array<{
341
+ title: string;
342
+ columns: string[];
343
+ rows: Array<Record<string, unknown>>;
344
+ }>;
345
+ charts?: Array<{
346
+ type: 'bar' | 'line' | 'scatter' | string;
347
+ title: string;
348
+ x: string;
349
+ y: string;
350
+ rows: Array<Record<string, unknown>>;
351
+ }>;
352
+ confidence: 'low' | 'medium' | 'high';
353
+ limitations?: string[];
354
+ recommendedActions?: string[];
355
+ sources?: Array<{
356
+ name: string;
357
+ type: string;
358
+ entity: string;
359
+ rowCount: number;
360
+ }>;
361
+ quality?: Record<string, unknown>;
362
+ provenance?: Record<string, unknown>;
363
+ explanation?: AnalyticsVisualizationExplanation;
364
+ intent?: AnalyticsVisualizationAnalysisIntent;
365
+ coverage?: AnalyticsVisualizationAnalysisCoverage;
169
366
  }
170
367
  interface AnalyticsVisualization {
171
368
  version?: number;
172
369
  presentation?: 'kpi' | 'chart' | 'table';
173
- type: 'kpi' | 'table' | 'bar' | 'line' | 'area' | 'stacked_bar' | 'pie' | 'scatter' | 'funnel';
370
+ type: 'kpi' | 'table' | 'bar' | 'line' | 'area' | 'stacked_bar' | 'pie' | 'scatter' | 'funnel' | 'heatmap' | 'radar';
174
371
  title?: string;
175
372
  label?: string;
176
373
  value?: string;
@@ -214,6 +411,10 @@ interface AnalyticsVisualization {
214
411
  isMixed: boolean;
215
412
  };
216
413
  chartRecommendation?: AnalyticsVisualizationRecommendation;
414
+ analysis?: AnalyticsVisualizationAnalysis;
415
+ businessAnalysis?: AnalyticsVisualizationBusinessAnalysis;
416
+ analysisIntent?: AnalyticsVisualizationAnalysisIntent;
417
+ analysisCoverage?: AnalyticsVisualizationAnalysisCoverage;
217
418
  expandable?: boolean;
218
419
  tableAvailable?: boolean;
219
420
  downloadAvailable?: boolean;
@@ -252,6 +453,7 @@ interface AuthenticatedHistoryMessage {
252
453
  url?: string;
253
454
  }>;
254
455
  visualization?: AnalyticsVisualization;
456
+ artifacts?: ChatArtifact[];
255
457
  createdAt: string;
256
458
  }
257
459
  interface AuthenticatedHistoryConversation {
@@ -272,7 +474,6 @@ interface StreamCallbacks {
272
474
  /** True only for turns sent from the active Speak-with-AI call. */
273
475
  voicePlaybackRequested?: boolean;
274
476
  }
275
- type ActionType = 'contact' | 'inquiry' | 'book-demo' | 'request-callback' | 'subscribe-newsletter';
276
477
  interface ActionResult {
277
478
  ok: boolean;
278
479
  note?: string;
@@ -309,6 +510,12 @@ interface BusyRange {
309
510
  }
310
511
  /** Booking availability for the picker. */
311
512
  interface DemoSlotsResult {
513
+ status?: 'available' | 'request_only' | 'delegated' | 'unavailable';
514
+ reason?: string;
515
+ timezone?: string;
516
+ slotDurationMinutes?: number;
517
+ /** Exact provider-checked slot instants the visitor may choose. */
518
+ available?: string[];
312
519
  /** Exact slot instants (UTC ISO) already booked via the widget. */
313
520
  taken: string[];
314
521
  /** Busy ranges from the connected calendar (Google / Outlook). */
@@ -336,10 +543,12 @@ interface Transport {
336
543
  liveEvents(sessionId: string, after: string): Promise<LiveEventsResult>;
337
544
  /** Soft visitor typing hint for the staff console. */
338
545
  typing(sessionId: string, isTyping: boolean): Promise<void>;
339
- action(type: ActionType, payload: Record<string, unknown>): Promise<ActionResult>;
546
+ action(type: string, payload: Record<string, unknown>, endpointOverride?: string): Promise<ActionResult>;
340
547
  /** Synthesize short widget UI prompts through the token's configured TTS voice. */
341
548
  speak(text: string): Promise<SpeechResult>;
342
549
  transcribe(audioBase64: string, mimeType: string, languageHint?: string, durationSeconds?: number): Promise<string>;
550
+ /** Preferred binary voice upload. Optional for backward-compatible custom transports. */
551
+ transcribeAudio?(audio: Blob, mimeType: string, languageHint?: string, durationSeconds?: number): Promise<string>;
343
552
  /**
344
553
  * Extract text from a visitor-attached image / PDF via the backend's
345
554
  * multimodal endpoint (`POST /public-chat/extract`). The returned text is
@@ -352,8 +561,8 @@ interface Transport {
352
561
  /**
353
562
  * Booking availability within [fromISO, toISO]: `taken` = exact slot instants
354
563
  * already booked via the widget; `busy` = ranges the connected calendar
355
- * (Google / Outlook) is occupied. The picker greys out both. Best-effort —
356
- * empty when unavailable (the picker then shows everything as open).
564
+ * (Google / Outlook) is occupied. Connected event calendars fail closed:
565
+ * provider errors reject this call instead of making every slot look open.
357
566
  */
358
567
  demoSlots(fromISO: string, toISO: string): Promise<DemoSlotsResult>;
359
568
  /**
@@ -372,6 +581,25 @@ interface Transport {
372
581
  //#endregion
373
582
  //#region src/types.d.ts
374
583
  type ChatSurface = 'floating' | 'full-page';
584
+ interface WidgetActionTranslation {
585
+ label?: string;
586
+ shortLabel?: string;
587
+ description?: string;
588
+ formTitle?: string;
589
+ submitLabel?: string;
590
+ delivery?: string;
591
+ prompt?: string;
592
+ readinessNote?: string;
593
+ fields?: Record<string, {
594
+ label?: string;
595
+ placeholder?: string;
596
+ }>;
597
+ }
598
+ interface WidgetTranslationBundle {
599
+ labels?: Partial<WidgetStrings>;
600
+ /** Action copy keyed by the stable backend action ID. */
601
+ actions?: Record<string, WidgetActionTranslation>;
602
+ }
375
603
  /** Public configuration surface passed to `Centrinfo.init()` / <CentrinfoWidget>. */
376
604
  interface WidgetConfig {
377
605
  /** The org's public chat token (`pub_*`). Required. It IS the org identity. */
@@ -419,6 +647,13 @@ interface WidgetConfig {
419
647
  * chat answers themselves are already multilingual server-side.
420
648
  */
421
649
  labels?: Partial<WidgetStrings>;
650
+ /** Locale used to select a translation bundle. Defaults to browser locale. */
651
+ locale?: string;
652
+ /**
653
+ * Translation data keyed by locale (`fr`, `fr-CA`, `yo`, ...). Exact locale
654
+ * wins, then its base language. Explicit `labels` still wins over the pack.
655
+ */
656
+ translations?: Record<string, WidgetTranslationBundle>;
422
657
  /**
423
658
  * Where the visible transcript is stored across reloads:
424
659
  * - `local` (default) — `localStorage`, survives browser restarts (30d TTL).
@@ -438,6 +673,11 @@ interface WidgetConfig {
438
673
  attachments?: boolean;
439
674
  /** Stacking context against the host page. */
440
675
  zIndex?: number;
676
+ /**
677
+ * CSP nonce applied to the fallback inline stylesheet on browsers without
678
+ * constructable stylesheet support. Pass the nonce used by the host page.
679
+ */
680
+ styleNonce?: string;
441
681
  /** Use the built-in mock transport (local preview, no backend/token needed). */
442
682
  demo?: boolean;
443
683
  /**
@@ -607,6 +847,19 @@ interface WidgetHandle {
607
847
  destroy: () => void;
608
848
  }
609
849
  /** A rendered chat message. */
850
+ interface ChatArtifact {
851
+ type: 'image' | 'resource_link' | 'visualization';
852
+ name?: string;
853
+ title?: string;
854
+ caption?: string;
855
+ altText?: string;
856
+ mimeType?: 'image/png' | 'image/jpeg' | 'image/webp' | string;
857
+ /** Base64 only, without a data-URL prefix. */
858
+ data?: string;
859
+ uri?: string;
860
+ /** Local compatibility bridge for the existing governed analytics result. */
861
+ visualization?: AnalyticsVisualization;
862
+ }
610
863
  interface ChatMessage {
611
864
  id: string;
612
865
  role: 'user' | 'assistant' | 'system';
@@ -624,6 +877,10 @@ interface ChatMessage {
624
877
  sources?: Source[];
625
878
  suggestedReplies?: string[];
626
879
  availableActions?: string[];
880
+ /** Structured action descriptors from the backend (preferred over ids). */
881
+ actions?: PublicChatAction[];
882
+ /** Action the backend resolved for this turn — its form opens directly. */
883
+ selectedAction?: string;
627
884
  handoffOffered?: boolean;
628
885
  /** Contact fields requested by final API metadata before handoff. */
629
886
  requestedContactFields?: string[];
@@ -638,6 +895,7 @@ interface ChatMessage {
638
895
  /** Visitor's 👍/👎 on this assistant reply (persisted so it survives reloads). */
639
896
  feedback?: 'up' | 'down';
640
897
  visualization?: AnalyticsVisualization;
898
+ artifacts?: ChatArtifact[];
641
899
  }
642
900
  interface Source {
643
901
  title?: string;
@@ -684,6 +942,8 @@ interface BootstrapInfo {
684
942
  memoryRetentionDays: number;
685
943
  memoryMessageCap: number;
686
944
  availableActions: string[];
945
+ /** Structured action descriptors. Empty from a backend that predates them. */
946
+ actions?: PublicChatAction[];
687
947
  accentColor?: string;
688
948
  /** One-line description under the agent name on the welcome screen (≤500). */
689
949
  agentDescription?: string;
@@ -710,6 +970,18 @@ interface SchedulerInfo {
710
970
  label?: string;
711
971
  mode?: 'event' | 'link';
712
972
  bookingLink?: string;
973
+ availability?: {
974
+ timezone: string;
975
+ weekdays: number[];
976
+ startTime: string;
977
+ endTime: string;
978
+ slotDurationMinutes: number;
979
+ bufferBeforeMinutes: number;
980
+ bufferAfterMinutes: number;
981
+ minimumNoticeMinutes: number;
982
+ bookingWindowDays: number;
983
+ calendarIds: string[];
984
+ };
713
985
  }
714
986
  //#endregion
715
- export { Visitor as a, WidgetThemeTokens as c, ActionType as d, AnalyticsVisualization as f, WidgetStrings as g, Transport as h, Source as i, WidgetUser as l, GifResult as m, ChatMessage as n, WidgetConfig as o, DemoSlotsResult as p, FeaturedLink as r, WidgetHandle as s, BootstrapInfo as t, ActionResult as u };
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 };