@accurix/centrinfo-widget 1.0.1 → 2.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.
- package/README.md +53 -3
- package/dist/cdn/centrinfo-widget.js +552 -85
- package/dist/cdn/manifest.json +6 -6
- package/dist/config-CkU4urQY.mjs +30 -0
- package/dist/config-DsNMbdKp.cjs +36 -0
- package/dist/index.cjs +531 -65
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +531 -65
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.d.cts +43 -10
- package/dist/runtime.d.mts +43 -10
- package/dist/runtime.mjs +1 -1
- package/dist/{types-DQWp12Cg.d.mts → types-1ZJJY7Da.d.mts} +337 -11
- package/dist/{types-rfkc-TtX.d.cts → types-B0r4SXaT.d.cts} +337 -11
- package/package.json +5 -4
- package/dist/config-CCkOySUT.mjs +0 -29
- package/dist/config-CzrfVSPp.cjs +0 -35
|
@@ -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' | 'stacked_bar';
|
|
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;
|
|
@@ -238,6 +439,31 @@ interface LiveEventsResult {
|
|
|
238
439
|
conversationEnded?: boolean;
|
|
239
440
|
events: LiveEvent[];
|
|
240
441
|
}
|
|
442
|
+
interface AuthenticatedHistoryMessage {
|
|
443
|
+
id: string;
|
|
444
|
+
role: 'user' | 'assistant' | 'system';
|
|
445
|
+
content: string;
|
|
446
|
+
authorName?: string;
|
|
447
|
+
messageType?: string;
|
|
448
|
+
sources?: Array<{
|
|
449
|
+
title?: string;
|
|
450
|
+
url?: string;
|
|
451
|
+
}>;
|
|
452
|
+
visualization?: AnalyticsVisualization;
|
|
453
|
+
artifacts?: ChatArtifact[];
|
|
454
|
+
createdAt: string;
|
|
455
|
+
}
|
|
456
|
+
interface AuthenticatedHistoryConversation {
|
|
457
|
+
sessionId: string;
|
|
458
|
+
title: string;
|
|
459
|
+
ended: boolean;
|
|
460
|
+
lastSeenAt: string;
|
|
461
|
+
messages: AuthenticatedHistoryMessage[];
|
|
462
|
+
}
|
|
463
|
+
interface AuthenticatedHistoryResult {
|
|
464
|
+
activeSessionId?: string;
|
|
465
|
+
conversations: AuthenticatedHistoryConversation[];
|
|
466
|
+
}
|
|
241
467
|
interface StreamCallbacks {
|
|
242
468
|
/** Called with each incremental text chunk. */
|
|
243
469
|
onChunk: (text: string) => void;
|
|
@@ -245,7 +471,6 @@ interface StreamCallbacks {
|
|
|
245
471
|
/** True only for turns sent from the active Speak-with-AI call. */
|
|
246
472
|
voicePlaybackRequested?: boolean;
|
|
247
473
|
}
|
|
248
|
-
type ActionType = 'contact' | 'inquiry' | 'book-demo' | 'request-callback' | 'subscribe-newsletter';
|
|
249
474
|
interface ActionResult {
|
|
250
475
|
ok: boolean;
|
|
251
476
|
note?: string;
|
|
@@ -282,6 +507,12 @@ interface BusyRange {
|
|
|
282
507
|
}
|
|
283
508
|
/** Booking availability for the picker. */
|
|
284
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[];
|
|
285
516
|
/** Exact slot instants (UTC ISO) already booked via the widget. */
|
|
286
517
|
taken: string[];
|
|
287
518
|
/** Busy ranges from the connected calendar (Google / Outlook). */
|
|
@@ -301,16 +532,20 @@ interface GifResult {
|
|
|
301
532
|
*/
|
|
302
533
|
interface Transport {
|
|
303
534
|
bootstrap(): Promise<BootstrapInfo>;
|
|
535
|
+
/** Server-backed history for the verified SDK customer. Anonymous returns empty. */
|
|
536
|
+
history(): Promise<AuthenticatedHistoryResult>;
|
|
304
537
|
/** Stream a turn; resolves with final metadata once `done`. */
|
|
305
538
|
stream(question: string, sessionId: string, cb: StreamCallbacks): Promise<TurnResult>;
|
|
306
539
|
/** Poll for staff/system events after a timestamp during live handoff. */
|
|
307
540
|
liveEvents(sessionId: string, after: string): Promise<LiveEventsResult>;
|
|
308
541
|
/** Soft visitor typing hint for the staff console. */
|
|
309
542
|
typing(sessionId: string, isTyping: boolean): Promise<void>;
|
|
310
|
-
action(type:
|
|
543
|
+
action(type: string, payload: Record<string, unknown>, endpointOverride?: string): Promise<ActionResult>;
|
|
311
544
|
/** Synthesize short widget UI prompts through the token's configured TTS voice. */
|
|
312
545
|
speak(text: string): Promise<SpeechResult>;
|
|
313
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>;
|
|
314
549
|
/**
|
|
315
550
|
* Extract text from a visitor-attached image / PDF via the backend's
|
|
316
551
|
* multimodal endpoint (`POST /public-chat/extract`). The returned text is
|
|
@@ -323,8 +558,8 @@ interface Transport {
|
|
|
323
558
|
/**
|
|
324
559
|
* Booking availability within [fromISO, toISO]: `taken` = exact slot instants
|
|
325
560
|
* already booked via the widget; `busy` = ranges the connected calendar
|
|
326
|
-
* (Google / Outlook) is occupied.
|
|
327
|
-
*
|
|
561
|
+
* (Google / Outlook) is occupied. Connected event calendars fail closed:
|
|
562
|
+
* provider errors reject this call instead of making every slot look open.
|
|
328
563
|
*/
|
|
329
564
|
demoSlots(fromISO: string, toISO: string): Promise<DemoSlotsResult>;
|
|
330
565
|
/**
|
|
@@ -342,10 +577,32 @@ interface Transport {
|
|
|
342
577
|
}
|
|
343
578
|
//#endregion
|
|
344
579
|
//#region src/types.d.ts
|
|
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
|
+
}
|
|
345
600
|
/** Public configuration surface passed to `Centrinfo.init()` / <CentrinfoWidget>. */
|
|
346
601
|
interface WidgetConfig {
|
|
347
602
|
/** The org's public chat token (`pub_*`). Required. It IS the org identity. */
|
|
348
603
|
token: string;
|
|
604
|
+
/** Conversation namespace. Set by the SDK surface mounting the chat. */
|
|
605
|
+
chatSurface?: ChatSurface;
|
|
349
606
|
/** Short-lived server-signed context token for governed customer analytics. */
|
|
350
607
|
analyticsContextToken?: string;
|
|
351
608
|
/** Short-lived SDK customer identity JWT for authenticated chat access. */
|
|
@@ -356,6 +613,11 @@ interface WidgetConfig {
|
|
|
356
613
|
apiBaseUrl?: string;
|
|
357
614
|
/** Brand accent (any CSS color). Overrides the persona/default green. */
|
|
358
615
|
accentColor?: string;
|
|
616
|
+
/**
|
|
617
|
+
* Full brand token map for SDK-rendered chat surfaces. `accentColor` remains
|
|
618
|
+
* a shorthand for `themeTokens.accent` and wins when both are supplied.
|
|
619
|
+
*/
|
|
620
|
+
themeTokens?: WidgetThemeTokens;
|
|
359
621
|
/** Optional display-name override. Normally loaded from the token bootstrap. */
|
|
360
622
|
agentName?: string;
|
|
361
623
|
/** Optional header avatar URL override. Normally loaded from the token bootstrap. */
|
|
@@ -382,14 +644,22 @@ interface WidgetConfig {
|
|
|
382
644
|
* chat answers themselves are already multilingual server-side.
|
|
383
645
|
*/
|
|
384
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>;
|
|
385
654
|
/**
|
|
386
655
|
* Where the visible transcript is stored across reloads:
|
|
387
656
|
* - `local` (default) — `localStorage`, survives browser restarts (30d TTL).
|
|
388
657
|
* - `session` — `sessionStorage`, cleared when the tab closes (better on
|
|
389
658
|
* shared / kiosk machines so the next visitor can't read prior chats).
|
|
390
659
|
* - `none` — never persisted; the transcript lives only in memory.
|
|
391
|
-
*
|
|
392
|
-
*
|
|
660
|
+
* Authenticated SDK users also restore retained conversations from the
|
|
661
|
+
* backend on a new browser or device. This setting controls the local cache
|
|
662
|
+
* and remains the only persistence layer for anonymous visitors.
|
|
393
663
|
*/
|
|
394
664
|
persistence?: 'local' | 'session' | 'none';
|
|
395
665
|
/**
|
|
@@ -400,6 +670,11 @@ interface WidgetConfig {
|
|
|
400
670
|
attachments?: boolean;
|
|
401
671
|
/** Stacking context against the host page. */
|
|
402
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;
|
|
403
678
|
/** Use the built-in mock transport (local preview, no backend/token needed). */
|
|
404
679
|
demo?: boolean;
|
|
405
680
|
/**
|
|
@@ -437,7 +712,7 @@ interface WidgetConfig {
|
|
|
437
712
|
/** CSS selector for host-page element(s) that open the widget on click
|
|
438
713
|
* (your own launcher). Listeners are (re)bound automatically. */
|
|
439
714
|
customLauncherSelector?: string;
|
|
440
|
-
/** Auto-logout (wipe local
|
|
715
|
+
/** Auto-logout (wipe local cache) after this many minutes of inactivity.
|
|
441
716
|
* 0 / omitted = never. Use on shared / kiosk devices. */
|
|
442
717
|
sessionDurationMinutes?: number;
|
|
443
718
|
/**
|
|
@@ -473,6 +748,25 @@ interface WidgetConfig {
|
|
|
473
748
|
onAction?: (action: string) => void;
|
|
474
749
|
onHandoff?: () => void;
|
|
475
750
|
}
|
|
751
|
+
/** Shared theme tokens consumed by the floating widget and full-page chat app. */
|
|
752
|
+
interface WidgetThemeTokens {
|
|
753
|
+
accent?: string;
|
|
754
|
+
accentStrong?: string;
|
|
755
|
+
accentSoft?: string;
|
|
756
|
+
accentText?: string;
|
|
757
|
+
background?: string;
|
|
758
|
+
surface?: string;
|
|
759
|
+
surfaceMuted?: string;
|
|
760
|
+
text?: string;
|
|
761
|
+
mutedText?: string;
|
|
762
|
+
border?: string;
|
|
763
|
+
shadow?: string;
|
|
764
|
+
radius?: string;
|
|
765
|
+
fontFamily?: string;
|
|
766
|
+
success?: string;
|
|
767
|
+
warning?: string;
|
|
768
|
+
danger?: string;
|
|
769
|
+
}
|
|
476
770
|
/** A B2B company / account the visitor belongs to (Intercom "Company object").
|
|
477
771
|
* Folded into the session metadata for the staff inbox. */
|
|
478
772
|
interface WidgetCompany {
|
|
@@ -550,6 +844,19 @@ interface WidgetHandle {
|
|
|
550
844
|
destroy: () => void;
|
|
551
845
|
}
|
|
552
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
|
+
}
|
|
553
860
|
interface ChatMessage {
|
|
554
861
|
id: string;
|
|
555
862
|
role: 'user' | 'assistant' | 'system';
|
|
@@ -567,6 +874,10 @@ interface ChatMessage {
|
|
|
567
874
|
sources?: Source[];
|
|
568
875
|
suggestedReplies?: string[];
|
|
569
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;
|
|
570
881
|
handoffOffered?: boolean;
|
|
571
882
|
/** Contact fields requested by final API metadata before handoff. */
|
|
572
883
|
requestedContactFields?: string[];
|
|
@@ -581,6 +892,7 @@ interface ChatMessage {
|
|
|
581
892
|
/** Visitor's 👍/👎 on this assistant reply (persisted so it survives reloads). */
|
|
582
893
|
feedback?: 'up' | 'down';
|
|
583
894
|
visualization?: AnalyticsVisualization;
|
|
895
|
+
artifacts?: ChatArtifact[];
|
|
584
896
|
}
|
|
585
897
|
interface Source {
|
|
586
898
|
title?: string;
|
|
@@ -627,6 +939,8 @@ interface BootstrapInfo {
|
|
|
627
939
|
memoryRetentionDays: number;
|
|
628
940
|
memoryMessageCap: number;
|
|
629
941
|
availableActions: string[];
|
|
942
|
+
/** Structured action descriptors. Empty from a backend that predates them. */
|
|
943
|
+
actions?: PublicChatAction[];
|
|
630
944
|
accentColor?: string;
|
|
631
945
|
/** One-line description under the agent name on the welcome screen (≤500). */
|
|
632
946
|
agentDescription?: string;
|
|
@@ -653,6 +967,18 @@ interface SchedulerInfo {
|
|
|
653
967
|
label?: string;
|
|
654
968
|
mode?: 'event' | 'link';
|
|
655
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
|
+
};
|
|
656
982
|
}
|
|
657
983
|
//#endregion
|
|
658
|
-
export {
|
|
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": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -43,9 +43,6 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"preact": "^10.27.0"
|
|
45
45
|
},
|
|
46
|
-
"peerDependencies": {
|
|
47
|
-
"@accurix/centrinfo": "^0.1.1"
|
|
48
|
-
},
|
|
49
46
|
"devDependencies": {
|
|
50
47
|
"@playwright/test": "^1.50.0",
|
|
51
48
|
"@types/node": "^22.0.0",
|
|
@@ -56,10 +53,14 @@
|
|
|
56
53
|
"typescript": "^5.8.0",
|
|
57
54
|
"vite": "^7.0.0",
|
|
58
55
|
"vitest": "^3.2.0",
|
|
56
|
+
"wrangler": "^4.91.0",
|
|
59
57
|
"@accurix/centrinfo-results": "^0.1.0",
|
|
60
58
|
"@accurix/web-config-eslint": "^0.0.0"
|
|
61
59
|
},
|
|
62
60
|
"module": "./dist/index.mjs",
|
|
61
|
+
"peerDependencies": {
|
|
62
|
+
"@accurix/centrinfo": "^0.2.0"
|
|
63
|
+
},
|
|
63
64
|
"publishConfig": {
|
|
64
65
|
"access": "public",
|
|
65
66
|
"registry": "https://registry.npmjs.org/"
|