@waniwani/sdk 0.19.3 → 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 +59 -59
- package/dist/chat/embed.js.map +1 -1
- package/dist/chat/index.d.ts +36 -36
- package/dist/chat/index.js +7 -7
- package/dist/chat/index.js.map +1 -1
- package/dist/legacy/index.d.ts +33 -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 {
|
|
@@ -490,32 +517,12 @@ interface WelcomeConfig {
|
|
|
490
517
|
/** Suggestion cards shown in the welcome screen. Disappear after the first message. */
|
|
491
518
|
suggestions?: string[];
|
|
492
519
|
}
|
|
493
|
-
/** Where a suggestion pill came from. */
|
|
494
|
-
/**
|
|
495
|
-
* Every place a suggestion pill can come from. The single source of truth:
|
|
496
|
-
* {@link SuggestionOrigin} derives from it, and runtime validation reads it,
|
|
497
|
-
* so adding an origin is a one-line change.
|
|
498
|
-
*/
|
|
499
|
-
declare const SUGGESTION_ORIGINS: readonly ["channel", "page", "flow", "followup"];
|
|
500
|
-
/** Where a suggestion pill came from. */
|
|
501
|
-
type SuggestionOrigin = (typeof SUGGESTION_ORIGINS)[number];
|
|
502
520
|
interface SuggestionsConfig {
|
|
503
521
|
/**
|
|
504
|
-
*
|
|
522
|
+
* Starter prompts shown before the user sends their first message.
|
|
505
523
|
* Defaults to an empty array.
|
|
506
524
|
*/
|
|
507
525
|
initial?: string[];
|
|
508
|
-
/**
|
|
509
|
-
* Which providers may fill the pill row. Omitted, this defaults to
|
|
510
|
-
* `["channel", "page", "followup"]`: starter prompts and generated
|
|
511
|
-
* follow-ups render, flow-driven pills stay opt-in.
|
|
512
|
-
*/
|
|
513
|
-
origins?: SuggestionOrigin[];
|
|
514
|
-
/**
|
|
515
|
-
* @deprecated Use `origins`. `true` maps to every origin, `false` to none.
|
|
516
|
-
* Will be removed in a future minor release.
|
|
517
|
-
*/
|
|
518
|
-
dynamic?: boolean;
|
|
519
526
|
}
|
|
520
527
|
/**
|
|
521
528
|
* Per-slot class name overrides for the chat widget. Each string is appended
|
|
@@ -595,13 +602,15 @@ interface ChatBaseProps {
|
|
|
595
602
|
/** Callback fired when a response is received */
|
|
596
603
|
onResponseReceived?: () => void;
|
|
597
604
|
/**
|
|
598
|
-
* Suggestion
|
|
599
|
-
*
|
|
600
|
-
*
|
|
601
|
-
* `
|
|
602
|
-
*
|
|
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.
|
|
603
612
|
*/
|
|
604
|
-
suggestions?: boolean | SuggestionsConfig;
|
|
613
|
+
suggestions?: boolean | SuggestionsConfig | PreChatSuggestions;
|
|
605
614
|
/**
|
|
606
615
|
* Handler for MCP tool calls from widgets.
|
|
607
616
|
* Called when a widget uses `callServerTool` (MCP Apps standard).
|
|
@@ -937,15 +946,6 @@ interface WaniwaniChatOverrides {
|
|
|
937
946
|
placeholder?: string;
|
|
938
947
|
/** Initial suggestion chips. */
|
|
939
948
|
suggestions?: string[];
|
|
940
|
-
/**
|
|
941
|
-
* Which providers may fill the per-turn pill row. Defaults to
|
|
942
|
-
* `["channel", "page", "followup"]` when unset: starter prompts and
|
|
943
|
-
* generated follow-ups render, flow-driven pills stay opt-in — include
|
|
944
|
-
* `"flow"` to render the pills a flow drives via
|
|
945
|
-
* `interrupt({ suggestions })`. Starter prompts (`suggestions`) are
|
|
946
|
-
* unaffected by this field and show either way.
|
|
947
|
-
*/
|
|
948
|
-
suggestionOrigins?: SuggestionOrigin[];
|
|
949
949
|
/** Persist conversations across reloads in IndexedDB. */
|
|
950
950
|
enableThreadHistory?: boolean;
|
|
951
951
|
/**
|