@waniwani/sdk 0.19.2 → 0.19.4
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/dist/chat/embed.js +61 -61
- package/dist/chat/embed.js.map +1 -1
- package/dist/chat/index.d.ts +51 -37
- package/dist/chat/index.js +7 -7
- package/dist/chat/index.js.map +1 -1
- package/dist/chat/styles.css +1 -1
- package/dist/legacy/index.d.ts +40 -27
- package/dist/legacy/index.js +13 -13
- package/dist/legacy/index.js.map +1 -1
- package/package.json +1 -1
package/dist/chat/index.d.ts
CHANGED
|
@@ -322,6 +322,33 @@ type MessageOverrides = DeepPartial<Messages>;
|
|
|
322
322
|
*/
|
|
323
323
|
type VisitorIdInput = string | (() => string | undefined | null | Promise<string | undefined | null>);
|
|
324
324
|
|
|
325
|
+
/** Source of truth; {@link SuggestionOrigin} derives from it. */
|
|
326
|
+
declare const SUGGESTION_ORIGINS: readonly ["channel", "page", "flow", "followup"];
|
|
327
|
+
type SuggestionOrigin = (typeof SUGGESTION_ORIGINS)[number];
|
|
328
|
+
/** One pill. `id` is null unless it came from an authored per-page prompt. */
|
|
329
|
+
interface Suggestion {
|
|
330
|
+
id: string | null;
|
|
331
|
+
text: string;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* One field per origin. `null` means the origin has nothing to say — no entry
|
|
335
|
+
* on this turn, or the rung no longer applies.
|
|
336
|
+
*
|
|
337
|
+
* `flow` alone treats `[]` as authoritative: it clears the row and suppresses
|
|
338
|
+
* every weaker rung. Elsewhere `[]` and `null` are the same.
|
|
339
|
+
*/
|
|
340
|
+
interface SuggestionCandidates {
|
|
341
|
+
flow: Suggestion[] | null;
|
|
342
|
+
followup: Suggestion[] | null;
|
|
343
|
+
page: Suggestion[] | null;
|
|
344
|
+
channel: Suggestion[] | null;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* The rungs an embed host reads from `/config`. Grouped because they share a
|
|
348
|
+
* source and a lifetime: both stop applying at the visitor's first message.
|
|
349
|
+
*/
|
|
350
|
+
type PreChatSuggestions = Pick<SuggestionCandidates, "page" | "channel">;
|
|
351
|
+
|
|
325
352
|
/** Surface the widget is mounted on. */
|
|
326
353
|
type WidgetMode = "inline" | "floating";
|
|
327
354
|
interface WidgetEventBase {
|
|
@@ -364,6 +391,13 @@ type WidgetEventDetail = {
|
|
|
364
391
|
/** Which provider supplied the clicked pill: `"channel"` (starter prompts), `"page"` (per-URL starter prompts), `"flow"` (an MCP flow's `interrupt({ suggestions })`), or `"followup"` (generated from the conversation). */
|
|
365
392
|
origin: SuggestionOrigin;
|
|
366
393
|
};
|
|
394
|
+
} | {
|
|
395
|
+
name: "suggestions.shown";
|
|
396
|
+
properties: {
|
|
397
|
+
texts: string[];
|
|
398
|
+
/** Origin of the rendered set, same taxonomy as `suggestion.clicked`. */
|
|
399
|
+
origin: SuggestionOrigin;
|
|
400
|
+
};
|
|
367
401
|
} | {
|
|
368
402
|
name: "link.clicked";
|
|
369
403
|
properties: {
|
|
@@ -465,6 +499,13 @@ interface ChatTheme {
|
|
|
465
499
|
fontSize?: number;
|
|
466
500
|
/** Base line height for message text (unitless string, e.g. `"1.5"`). Defaults to `"1.5"`. */
|
|
467
501
|
lineHeight?: string;
|
|
502
|
+
/** Frosted-glass tint color for the floating bar's suggestion card, layered
|
|
503
|
+
* over the backdrop blur. Programmatic-only via appearance.variables.
|
|
504
|
+
* Unset = the default neutral glass (unchanged). */
|
|
505
|
+
glassTint?: string;
|
|
506
|
+
/** Strength of the glass tint, 0–1 as a unitless string (e.g. "0.5").
|
|
507
|
+
* Unset/"0" = no tint (default rendering). */
|
|
508
|
+
glassTintStrength?: string;
|
|
468
509
|
}
|
|
469
510
|
interface WelcomeConfig {
|
|
470
511
|
/** Icon displayed above the title. Accepts any React node (e.g. an SVG or img). */
|
|
@@ -476,32 +517,12 @@ interface WelcomeConfig {
|
|
|
476
517
|
/** Suggestion cards shown in the welcome screen. Disappear after the first message. */
|
|
477
518
|
suggestions?: string[];
|
|
478
519
|
}
|
|
479
|
-
/** Where a suggestion pill came from. */
|
|
480
|
-
/**
|
|
481
|
-
* Every place a suggestion pill can come from. The single source of truth:
|
|
482
|
-
* {@link SuggestionOrigin} derives from it, and runtime validation reads it,
|
|
483
|
-
* so adding an origin is a one-line change.
|
|
484
|
-
*/
|
|
485
|
-
declare const SUGGESTION_ORIGINS: readonly ["channel", "page", "flow", "followup"];
|
|
486
|
-
/** Where a suggestion pill came from. */
|
|
487
|
-
type SuggestionOrigin = (typeof SUGGESTION_ORIGINS)[number];
|
|
488
520
|
interface SuggestionsConfig {
|
|
489
521
|
/**
|
|
490
|
-
*
|
|
522
|
+
* Starter prompts shown before the user sends their first message.
|
|
491
523
|
* Defaults to an empty array.
|
|
492
524
|
*/
|
|
493
525
|
initial?: string[];
|
|
494
|
-
/**
|
|
495
|
-
* Which providers may fill the pill row. Omitted, this defaults to
|
|
496
|
-
* `["channel", "page", "followup"]`: starter prompts and generated
|
|
497
|
-
* follow-ups render, flow-driven pills stay opt-in.
|
|
498
|
-
*/
|
|
499
|
-
origins?: SuggestionOrigin[];
|
|
500
|
-
/**
|
|
501
|
-
* @deprecated Use `origins`. `true` maps to every origin, `false` to none.
|
|
502
|
-
* Will be removed in a future minor release.
|
|
503
|
-
*/
|
|
504
|
-
dynamic?: boolean;
|
|
505
526
|
}
|
|
506
527
|
/**
|
|
507
528
|
* Per-slot class name overrides for the chat widget. Each string is appended
|
|
@@ -581,13 +602,15 @@ interface ChatBaseProps {
|
|
|
581
602
|
/** Callback fired when a response is received */
|
|
582
603
|
onResponseReceived?: () => void;
|
|
583
604
|
/**
|
|
584
|
-
* Suggestion
|
|
585
|
-
*
|
|
586
|
-
*
|
|
587
|
-
* `
|
|
588
|
-
*
|
|
605
|
+
* Suggestion pills. The row obeys a fixed hierarchy — flow > followup >
|
|
606
|
+
* page > channel — and every origin is always active.
|
|
607
|
+
*
|
|
608
|
+
* `false` hides the row; `true` / unset is the default. `{ initial: [...] }`
|
|
609
|
+
* sets starter prompts. Embed hosts pass the resolved
|
|
610
|
+
* {@link PreChatSuggestions} from `useSuggestions(config)` instead, which
|
|
611
|
+
* carries the prompt ids needed for click attribution.
|
|
589
612
|
*/
|
|
590
|
-
suggestions?: boolean | SuggestionsConfig;
|
|
613
|
+
suggestions?: boolean | SuggestionsConfig | PreChatSuggestions;
|
|
591
614
|
/**
|
|
592
615
|
* Handler for MCP tool calls from widgets.
|
|
593
616
|
* Called when a widget uses `callServerTool` (MCP Apps standard).
|
|
@@ -923,15 +946,6 @@ interface WaniwaniChatOverrides {
|
|
|
923
946
|
placeholder?: string;
|
|
924
947
|
/** Initial suggestion chips. */
|
|
925
948
|
suggestions?: string[];
|
|
926
|
-
/**
|
|
927
|
-
* Which providers may fill the per-turn pill row. Defaults to
|
|
928
|
-
* `["channel", "page", "followup"]` when unset: starter prompts and
|
|
929
|
-
* generated follow-ups render, flow-driven pills stay opt-in — include
|
|
930
|
-
* `"flow"` to render the pills a flow drives via
|
|
931
|
-
* `interrupt({ suggestions })`. Starter prompts (`suggestions`) are
|
|
932
|
-
* unaffected by this field and show either way.
|
|
933
|
-
*/
|
|
934
|
-
suggestionOrigins?: SuggestionOrigin[];
|
|
935
949
|
/** Persist conversations across reloads in IndexedDB. */
|
|
936
950
|
enableThreadHistory?: boolean;
|
|
937
951
|
/**
|
|
@@ -1053,7 +1067,7 @@ interface WaniwaniChatProps {
|
|
|
1053
1067
|
/**
|
|
1054
1068
|
* Callback fired on chat lifecycle events (`chat.ready`, `message.sent`,
|
|
1055
1069
|
* `message.received`, `session.started`, `thread.changed`, `chat.error`,
|
|
1056
|
-
* `suggestion.clicked`, `link.clicked`; `chat.opened`/`chat.closed` are
|
|
1070
|
+
* `suggestion.clicked`, `suggestions.shown`, `link.clicked`; `chat.opened`/`chat.closed` are
|
|
1057
1071
|
* floating-embed-only and never fire here). Message events never include
|
|
1058
1072
|
* the message text. Use it to mirror widget activity into the host page's
|
|
1059
1073
|
* analytics. Exceptions thrown by the callback are swallowed and never
|