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