@waniwani/sdk 0.20.0 → 0.20.2
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 +70 -68
- package/dist/chat/embed.js.map +1 -1
- package/dist/chat/index.d.ts +128 -2
- package/dist/chat/index.js +9 -7
- package/dist/chat/index.js.map +1 -1
- package/dist/chat/styles.css +1 -1
- package/dist/documents/index.d.ts +104 -0
- package/dist/documents/index.js +2 -0
- package/dist/documents/index.js.map +1 -0
- package/dist/index.d.ts +79 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.d.ts +480 -1
- package/dist/mcp/index.js +5 -5
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/react/skybridge.js +1 -1
- package/dist/mcp/react/skybridge.js.map +1 -1
- package/dist/mcp/react.js +1 -1
- package/dist/mcp/react.js.map +1 -1
- package/package.json +6 -1
package/dist/chat/index.d.ts
CHANGED
|
@@ -258,9 +258,20 @@ interface Messages {
|
|
|
258
258
|
promptInput: {
|
|
259
259
|
placeholder: string;
|
|
260
260
|
uploadFiles: string;
|
|
261
|
+
uploadFilesUpTo: string;
|
|
262
|
+
uploadFilesUpToWithPages: string;
|
|
261
263
|
stop: string;
|
|
262
264
|
submit: string;
|
|
263
265
|
removeAttachments: string;
|
|
266
|
+
removeAttachment: string;
|
|
267
|
+
uploading: string;
|
|
268
|
+
retry: string;
|
|
269
|
+
retryUpload: string;
|
|
270
|
+
uploadFailed: string;
|
|
271
|
+
dropToAttach: string;
|
|
272
|
+
errorAccept: string;
|
|
273
|
+
errorTooLarge: string;
|
|
274
|
+
errorTooMany: string;
|
|
264
275
|
};
|
|
265
276
|
workingIndicator: {
|
|
266
277
|
default: string;
|
|
@@ -284,6 +295,9 @@ interface Messages {
|
|
|
284
295
|
};
|
|
285
296
|
attachments: {
|
|
286
297
|
attachmentFallback: string;
|
|
298
|
+
kindPdf: string;
|
|
299
|
+
kindImage: string;
|
|
300
|
+
kindFile: string;
|
|
287
301
|
fileFallback: string;
|
|
288
302
|
};
|
|
289
303
|
threadMenu: {
|
|
@@ -364,7 +378,7 @@ interface SuggestionCandidates {
|
|
|
364
378
|
type PreChatSuggestions = Pick<SuggestionCandidates, "page" | "channel">;
|
|
365
379
|
|
|
366
380
|
/** Surface the widget is mounted on. */
|
|
367
|
-
type WidgetMode = "inline" | "floating";
|
|
381
|
+
type WidgetMode = "inline" | "floating" | "composer";
|
|
368
382
|
interface WidgetEventBase {
|
|
369
383
|
/** Surface the widget is mounted on. */
|
|
370
384
|
mode: WidgetMode;
|
|
@@ -559,6 +573,18 @@ interface ChatClassNames {
|
|
|
559
573
|
/** The input bar container. */
|
|
560
574
|
input?: string;
|
|
561
575
|
}
|
|
576
|
+
/** What the platform reports about the documents module for this project. */
|
|
577
|
+
interface DocumentUploadConfig {
|
|
578
|
+
enabled: boolean;
|
|
579
|
+
/** Refused before the upload starts. */
|
|
580
|
+
maxBytes: number;
|
|
581
|
+
/** Stated to the visitor; the OCR vendor is what enforces it. */
|
|
582
|
+
maxPdfPages: number;
|
|
583
|
+
/** The chat request refuses more than this, so the composer must not take more. */
|
|
584
|
+
maxFiles: number;
|
|
585
|
+
/** MIME types the platform accepts. */
|
|
586
|
+
accept: string[];
|
|
587
|
+
}
|
|
562
588
|
interface ChatBaseProps {
|
|
563
589
|
/** Waniwani project API key */
|
|
564
590
|
apiKey?: string;
|
|
@@ -603,6 +629,12 @@ interface ChatBaseProps {
|
|
|
603
629
|
body?: Record<string, unknown>;
|
|
604
630
|
/** Enable file attachments in the input. Defaults to false. */
|
|
605
631
|
allowAttachments?: boolean;
|
|
632
|
+
/**
|
|
633
|
+
* Document upload, as the platform reports it on `GET /api/mcp/chat/config`.
|
|
634
|
+
* The composer offers a paperclip, a drop target and paste only while
|
|
635
|
+
* `enabled` is true, and the upload endpoint enforces the same flag.
|
|
636
|
+
*/
|
|
637
|
+
documentUpload?: DocumentUploadConfig;
|
|
606
638
|
/** Placeholder text shown in the input field. Defaults to "Ask me anything...". Animates with a typing effect. */
|
|
607
639
|
placeholder?: string;
|
|
608
640
|
/**
|
|
@@ -900,6 +932,100 @@ interface McpAppFrameProps {
|
|
|
900
932
|
}
|
|
901
933
|
declare function McpAppFrame({ resourceUri, toolInput, toolResult, resourceEndpoint, chatSessionId, isDark, className, autoHeight, onOpenLink, onFollowUp, onCallTool, onDisplayModeChange, isFullscreen, toolDefinitions, }: McpAppFrameProps): react_jsx_runtime.JSX.Element;
|
|
902
934
|
|
|
935
|
+
/**
|
|
936
|
+
* The shapes crossing the WebMCP boundary.
|
|
937
|
+
*
|
|
938
|
+
* Structural rather than imported from `@modelcontextprotocol/sdk`, because
|
|
939
|
+
* everything here is also read by the browser bridge, and the MCP SDK is an
|
|
940
|
+
* optional peer dependency that has no business in a page bundle. What the
|
|
941
|
+
* server sends and what the page reads is JSON either way.
|
|
942
|
+
*/
|
|
943
|
+
/**
|
|
944
|
+
* One MCP content block. `type` is the discriminator every block carries; the
|
|
945
|
+
* index signature keeps the rest of whichever block it is, since nothing on
|
|
946
|
+
* this path reads them and re-deriving the union would only restate a schema
|
|
947
|
+
* the server already validated on the way out.
|
|
948
|
+
*/
|
|
949
|
+
type WebMcpContentBlock = {
|
|
950
|
+
type: string;
|
|
951
|
+
text?: string;
|
|
952
|
+
[key: string]: unknown;
|
|
953
|
+
};
|
|
954
|
+
/**
|
|
955
|
+
* Everything the page needs to mount a widget itself.
|
|
956
|
+
*
|
|
957
|
+
* Assembled server-side because none of it is derivable on the page: the view
|
|
958
|
+
* URI carries a content hash that moves every deploy, and the display tool's
|
|
959
|
+
* result is what the view reads its own configuration from.
|
|
960
|
+
*/
|
|
961
|
+
type WebMcpWidgetPayload = {
|
|
962
|
+
/**
|
|
963
|
+
* The `ui://` the view was resolved from.
|
|
964
|
+
*
|
|
965
|
+
* Carries a content hash that moves on every deploy, which is why this is
|
|
966
|
+
* resolved server-side per call and why nothing on the page can cache it.
|
|
967
|
+
*
|
|
968
|
+
* The only half of the view the page is told. Where to fetch it from is the
|
|
969
|
+
* resource endpoint the page already derived from its token, the same one
|
|
970
|
+
* the chat's own widget iframes use.
|
|
971
|
+
*/
|
|
972
|
+
viewUri: string;
|
|
973
|
+
/** Display tool the view belongs to. */
|
|
974
|
+
tool: string;
|
|
975
|
+
/** Props, delivered to the view as `ui/notifications/tool-input`. */
|
|
976
|
+
data: Record<string, unknown>;
|
|
977
|
+
/** The display tool's own result, delivered as `ui/notifications/tool-result`. */
|
|
978
|
+
result: {
|
|
979
|
+
content: WebMcpContentBlock[];
|
|
980
|
+
structuredContent?: Record<string, unknown>;
|
|
981
|
+
_meta?: Record<string, unknown>;
|
|
982
|
+
};
|
|
983
|
+
/** Whether the flow is waiting on the visitor before it can advance. */
|
|
984
|
+
interactive: boolean;
|
|
985
|
+
/**
|
|
986
|
+
* Set by the preview endpoint. A real widget step is a flow waiting on the
|
|
987
|
+
* visitor and has no way out; a preview is something someone opened to look
|
|
988
|
+
* at, so the host can give it one.
|
|
989
|
+
*/
|
|
990
|
+
preview?: boolean;
|
|
991
|
+
};
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* `McpAppFrame` is used exactly as the chat uses it, with no new props.
|
|
995
|
+
*
|
|
996
|
+
* Three things would be worth telling it on this surface, and none of them are
|
|
997
|
+
* worth touching a component every customer's chat renders:
|
|
998
|
+
*
|
|
999
|
+
* - It advertises a `message` capability in its handshake, which is how a view
|
|
1000
|
+
* pushes a follow-up into the conversation. There is no channel back to a
|
|
1001
|
+
* browsing agent, so a view that uses it is ignored. The panel's own content
|
|
1002
|
+
* still works; only the agent's narration is lost.
|
|
1003
|
+
* - Its `hostInfo` says "Waniwani Chat". A view reading it is told the wrong
|
|
1004
|
+
* host, and nothing in ours reads it.
|
|
1005
|
+
* - It clamps its own height. The panel below sets `maxHeight` and scrolls, so
|
|
1006
|
+
* an oversized view is contained here rather than there.
|
|
1007
|
+
*
|
|
1008
|
+
* Each becomes worth doing once this surface has run in front of real traffic
|
|
1009
|
+
* and one of them has actually cost something.
|
|
1010
|
+
*/
|
|
1011
|
+
type WebMcpOverlayProps = {
|
|
1012
|
+
/** The step to show, or `null` for nothing. */
|
|
1013
|
+
widget: WebMcpWidgetPayload | null;
|
|
1014
|
+
/** The tools endpoint, so a view's own `tools/call` can be proxied. */
|
|
1015
|
+
toolsEndpoint: string;
|
|
1016
|
+
/** Auth for that endpoint, matching what the bridge sends. */
|
|
1017
|
+
headers?: Record<string, string>;
|
|
1018
|
+
/**
|
|
1019
|
+
* Where view HTML is fetched from, resolved from the token the same way the
|
|
1020
|
+
* chat's own widget iframes resolve theirs.
|
|
1021
|
+
*/
|
|
1022
|
+
resourceEndpoint: string;
|
|
1023
|
+
/** Raised when the view says it is finished, and on Escape for a preview. */
|
|
1024
|
+
onClose: () => void;
|
|
1025
|
+
isDark?: boolean;
|
|
1026
|
+
};
|
|
1027
|
+
declare function WebMcpOverlay({ widget, toolsEndpoint, resourceEndpoint, headers, onClose, isDark, }: WebMcpOverlayProps): react_jsx_runtime.JSX.Element | null;
|
|
1028
|
+
|
|
903
1029
|
/**
|
|
904
1030
|
* **Bare-bones, bring-your-own-backend chat primitive.** Most apps want
|
|
905
1031
|
* `WaniwaniChat` (the hosted version) — `ChatEmbed` is the unmanaged
|
|
@@ -1085,4 +1211,4 @@ declare function mergeTheme(userTheme?: ChatTheme): Required<ChatTheme>;
|
|
|
1085
1211
|
*/
|
|
1086
1212
|
declare function themeToCSSProperties(theme: ChatTheme): Record<string, string>;
|
|
1087
1213
|
|
|
1088
|
-
export { type ChatAppearance, type ChatBaseProps, ChatEmbed, type ChatEmbedMcpConfig, type ChatEmbedProps, type ChatHandle, type ChatTheme, DARK_THEME, DEFAULT_THEME, type McpAppDisplayMode, McpAppFrame, type McpAppFrameProps, type ShowToolCalls, type SuggestionsConfig, type ThemePreset, WaniwaniChat, type WaniwaniChatOverrides, type WaniwaniChatProps, type WelcomeConfig, type WidgetEvent, type WidgetEventName, type WidgetMode, mergeTheme, themeToCSSProperties };
|
|
1214
|
+
export { type ChatAppearance, type ChatBaseProps, ChatEmbed, type ChatEmbedMcpConfig, type ChatEmbedProps, type ChatHandle, type ChatTheme, DARK_THEME, DEFAULT_THEME, type McpAppDisplayMode, McpAppFrame, type McpAppFrameProps, type ShowToolCalls, type SuggestionsConfig, type ThemePreset, WaniwaniChat, type WaniwaniChatOverrides, type WaniwaniChatProps, WebMcpOverlay, type WebMcpOverlayProps, type WelcomeConfig, type WidgetEvent, type WidgetEventName, type WidgetMode, mergeTheme, themeToCSSProperties };
|