@waniwani/sdk 0.11.27 → 0.12.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.
@@ -3,6 +3,29 @@ import * as ai from 'ai';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import { ContentBlock } from '@modelcontextprotocol/sdk/types.js';
5
5
 
6
+ /**
7
+ * Built-in theme presets. `auto` follows the host's `prefers-color-scheme`
8
+ * and switches at runtime without re-rendering.
9
+ */
10
+ type ThemePreset = "light" | "dark" | "auto";
11
+ /**
12
+ * Appearance config for the chat widget. Pick a preset and (optionally) layer
13
+ * per-property `variables` on top.
14
+ *
15
+ * ```ts
16
+ * appearance: { theme: "dark", variables: { primaryColor: "#ff6b6b" } }
17
+ * ```
18
+ *
19
+ * The same shape is accepted by the `embed.js` script (`init({ appearance })`),
20
+ * `<WaniwaniChat overrides={{ appearance }} />`, and `<ChatEmbed appearance />`.
21
+ */
22
+ interface ChatAppearance {
23
+ /** Base theme preset. Defaults to `"light"`. */
24
+ theme?: ThemePreset;
25
+ /** Per-property overrides applied on top of the preset. */
26
+ variables?: ChatTheme;
27
+ }
28
+
6
29
  interface ChatTheme {
7
30
  /** Primary brand color (bubble, send button, user messages) */
8
31
  primaryColor?: string;
@@ -16,6 +39,10 @@ interface ChatTheme {
16
39
  mutedColor?: string;
17
40
  /** Border color */
18
41
  borderColor?: string;
42
+ /** Border width for the panel (px). Defaults to 0 (no border). */
43
+ borderWidth?: number;
44
+ /** Box-shadow shorthand applied to the panel. Use any valid CSS box-shadow string (e.g. `"0 10px 25px rgba(0,0,0,0.1)"`). Defaults to `none`. */
45
+ boxShadow?: string;
19
46
  /** Assistant message bubble background */
20
47
  assistantBubbleColor?: string;
21
48
  /** User message bubble background */
@@ -75,8 +102,11 @@ interface ChatBaseProps {
75
102
  * Takes precedence over `welcomeMessage` when provided.
76
103
  */
77
104
  welcome?: WelcomeConfig;
78
- /** Theme overrides */
79
- theme?: ChatTheme;
105
+ /**
106
+ * Theme preset (`light`/`dark`/`auto`) plus per-property overrides.
107
+ * See `ChatAppearance` for the shape.
108
+ */
109
+ appearance?: ChatAppearance;
80
110
  /** Additional headers to send with chat API requests */
81
111
  headers?: Record<string, string>;
82
112
  /** Additional body fields to send with each chat request */
@@ -140,6 +170,12 @@ interface ChatBaseProps {
140
170
  activeThreadId?: string;
141
171
  /** Fired whenever the active thread changes (new chat, switch, delete). */
142
172
  onThreadChange?: (threadId: string) => void;
173
+ /**
174
+ * AI transparency notice rendered under the input (EU AI Act compliance).
175
+ * Defaults to `"AI can make mistakes. Verify important information."`.
176
+ * Pass a string to override the wording, or `false` to hide it entirely.
177
+ */
178
+ disclaimer?: string | false;
143
179
  }
144
180
  /**
145
181
  * MCP Apps configuration for {@link ChatEmbedProps}.
@@ -194,7 +230,7 @@ type CallToolHandler = (params: {
194
230
  * <ChatEmbed
195
231
  * api="/api/my-chat-endpoint"
196
232
  * body={{ environmentId, sessionId }}
197
- * theme={{ backgroundColor: "#fff" }}
233
+ * appearance={{ theme: "dark" }}
198
234
  * />
199
235
  *
200
236
  * // Self-hosted chat endpoint with MCP App widgets
@@ -261,6 +297,8 @@ interface ChatCardProps extends ChatBaseProps {
261
297
  height?: number | string;
262
298
  /** Additional class names applied to the root element (e.g. Tailwind classes). */
263
299
  className?: string;
300
+ /** Theme overrides. Legacy API; new code should use the `appearance` field on `WaniwaniChat` / `ChatEmbed`. */
301
+ theme?: ChatTheme;
264
302
  }
265
303
  /**
266
304
  * @deprecated Use `WaniwaniChat` from `@waniwani/sdk/chat` for new code.
@@ -384,12 +422,23 @@ interface WaniwaniChatOverrides {
384
422
  showToolCalls?: boolean;
385
423
  /** Enable file attachments in the input. */
386
424
  allowAttachments?: boolean;
387
- /** Theme overrides. */
388
- theme?: ChatTheme;
425
+ /**
426
+ * Theme preset (`light`/`dark`/`auto`) plus per-property overrides.
427
+ *
428
+ * ```tsx
429
+ * appearance={{ theme: "dark", variables: { primaryColor: "#ff6b6b" } }}
430
+ * ```
431
+ */
432
+ appearance?: ChatAppearance;
389
433
  /** Chat API URL. Defaults to `https://app.waniwani.ai/api/mcp/chat`. */
390
434
  api?: string;
391
435
  /** Override the MCP server URL (rarely needed). */
392
436
  mcpServerUrl?: string;
437
+ /**
438
+ * AI transparency notice rendered under the input (EU AI Act compliance).
439
+ * String overrides the default wording; `false` hides it.
440
+ */
441
+ disclaimer?: string | false;
393
442
  }
394
443
  /**
395
444
  * Hosted-tier WaniWani chat. The React counterpart to the `<script>` embed.
@@ -451,6 +500,13 @@ declare const WaniwaniChat: react.ForwardRefExoticComponent<WaniwaniChatProps &
451
500
  declare const DEFAULT_THEME: Required<ChatTheme>;
452
501
  declare const DARK_THEME: ChatTheme;
453
502
  declare function mergeTheme(userTheme?: ChatTheme): Required<ChatTheme>;
454
- declare function themeToCSSProperties(theme: Required<ChatTheme>): Record<string, string>;
503
+ /**
504
+ * Serialise a (partial) `ChatTheme` to inline CSS custom properties. Only
505
+ * keys present on the input are emitted — unspecified properties fall back
506
+ * to the cascade in `tailwind.css` (`var(--ww-primary, #6366f1)` chain).
507
+ * This lets a customer's `[data-waniwani-embed] { --ww-primary: ... }` win
508
+ * over the chat root's defaults when only a few keys are customised.
509
+ */
510
+ declare function themeToCSSProperties(theme: ChatTheme): Record<string, string>;
455
511
 
456
- export { type ChatBaseProps, ChatCard, type ChatCardProps, ChatEmbed, type ChatEmbedMcpConfig, type ChatEmbedProps, type ChatHandle, type ChatTheme, DARK_THEME, DEFAULT_THEME, type McpAppDisplayMode, McpAppFrame, type McpAppFrameProps, type SuggestionsConfig, WaniwaniChat, type WaniwaniChatOverrides, type WaniwaniChatProps, type WelcomeConfig, mergeTheme, themeToCSSProperties };
512
+ export { type ChatAppearance, type ChatBaseProps, ChatCard, type ChatCardProps, ChatEmbed, type ChatEmbedMcpConfig, type ChatEmbedProps, type ChatHandle, type ChatTheme, DARK_THEME, DEFAULT_THEME, type McpAppDisplayMode, McpAppFrame, type McpAppFrameProps, type SuggestionsConfig, type ThemePreset, WaniwaniChat, type WaniwaniChatOverrides, type WaniwaniChatProps, type WelcomeConfig, mergeTheme, themeToCSSProperties };