@waniwani/sdk 0.12.1 → 0.12.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/legacy/index.d.ts +87 -15
- package/dist/legacy/index.js +13 -13
- package/dist/legacy/index.js.map +1 -1
- package/dist/legacy/mcp/react.d.ts +87 -15
- package/dist/legacy/mcp/react.js +7 -7
- package/dist/legacy/mcp/react.js.map +1 -1
- package/dist/mcp/react.d.ts +87 -15
- package/dist/mcp/react.js +7 -7
- package/dist/mcp/react.js.map +1 -1
- package/package.json +1 -1
package/dist/legacy/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { ZodRawShapeCompat } from '@modelcontextprotocol/sdk/server/zod-compat.j
|
|
|
6
6
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
7
|
import { ContentBlock, CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
8
8
|
import * as React$1 from 'react';
|
|
9
|
-
import React__default, { ReactNode, SetStateAction } from 'react';
|
|
9
|
+
import React__default, { ReactNode, JSX, SetStateAction } from 'react';
|
|
10
10
|
import * as ai from 'ai';
|
|
11
11
|
import { UIMessage } from 'ai';
|
|
12
12
|
|
|
@@ -528,6 +528,91 @@ type ModelContextUpdate = {
|
|
|
528
528
|
structuredContent?: Record<string, unknown>;
|
|
529
529
|
};
|
|
530
530
|
|
|
531
|
+
interface SendFollowUpOptions {
|
|
532
|
+
modelContext?: ModelContextUpdate | null;
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Get a function to send follow-up messages to the AI.
|
|
536
|
+
* Works on both OpenAI widgets and MCP Apps.
|
|
537
|
+
*
|
|
538
|
+
* @deprecated Legacy MCP-widget-in-host stack. Preserved for back-compat; will move to
|
|
539
|
+
* `@waniwani/sdk/legacy/react` in a future minor release.
|
|
540
|
+
* @returns A function that sends a follow-up message
|
|
541
|
+
*/
|
|
542
|
+
declare function useSendFollowUp(): (prompt: string, options?: SendFollowUpOptions) => void;
|
|
543
|
+
|
|
544
|
+
interface UnstableSendFollowUpWithGhostGuardResult {
|
|
545
|
+
/** Wrapped `sendFollowUp`. Same signature as the one you passed in. */
|
|
546
|
+
sendFollowUp: (prompt: string, options?: SendFollowUpOptions) => void;
|
|
547
|
+
/**
|
|
548
|
+
* Wrap your widget's root render with this so the suppression can take
|
|
549
|
+
* effect. On non-ChatGPT hosts it is a transparent pass-through.
|
|
550
|
+
*/
|
|
551
|
+
Guard: (props: {
|
|
552
|
+
children: ReactNode;
|
|
553
|
+
}) => JSX.Element | null;
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* ⚠️ EXPERIMENTAL — DO NOT USE UNLESS YOU UNDERSTAND THE TRADE-OFFS ⚠️
|
|
557
|
+
*
|
|
558
|
+
* Wraps an existing `sendFollowUp` with ghost-guard suppression specific
|
|
559
|
+
* to ChatGPT. ChatGPT renders the source widget a SECOND time alongside
|
|
560
|
+
* the new user message a widget emits via `sendFollowUpMessage`. The
|
|
561
|
+
* second iframe is a brand-new React tree with no link to the original;
|
|
562
|
+
* skybridge's `useViewState` persistence does not survive across them.
|
|
563
|
+
* The result is a visible duplicate widget for ~1s before ChatGPT
|
|
564
|
+
* collapses one of them.
|
|
565
|
+
*
|
|
566
|
+
* On ChatGPT the hook adds a per-`viewUUID` `localStorage` write before
|
|
567
|
+
* each `sendFollowUp` call, and the returned `Guard` checks that record
|
|
568
|
+
* on mount — if it sees a record set by a different `mountId` within
|
|
569
|
+
* `ADVANCED_WINDOW_MS`, it collapses the iframe to 0×0.
|
|
570
|
+
*
|
|
571
|
+
* On every other host (WaniWani embed, MCP Apps, etc.) the hook is a
|
|
572
|
+
* pure pass-through: `sendFollowUp` is your function unchanged and
|
|
573
|
+
* `Guard` is a transparent fragment.
|
|
574
|
+
*
|
|
575
|
+
* The hook does NOT require `WidgetProvider`. It reads the widget's
|
|
576
|
+
* `viewUUID` from `WidgetClientContext` when one is available and falls
|
|
577
|
+
* back to `window.openai.toolResponseMetadata.viewUUID` otherwise.
|
|
578
|
+
*
|
|
579
|
+
* Caveats:
|
|
580
|
+
* - Relies on ChatGPT's widget iframes sharing a single `localStorage`
|
|
581
|
+
* scope — verified at the time of writing but not guaranteed.
|
|
582
|
+
* - 10s suppression window per `viewUUID`. Two unrelated `sendFollowUp`
|
|
583
|
+
* calls inside 10s with the same viewUUID could mistakenly suppress one.
|
|
584
|
+
* - The `Guard` MUST wrap the widget's root render. If you forget it,
|
|
585
|
+
* the localStorage write happens but nothing is suppressed.
|
|
586
|
+
*
|
|
587
|
+
* @param sendFollowUp - The underlying `sendFollowUp` to wrap. On ChatGPT the
|
|
588
|
+
* hook adds the per-`viewUUID` localStorage write before delegating; on any
|
|
589
|
+
* other host the hook is a pure pass-through. Typically the value of
|
|
590
|
+
* `useSendFollowUpMessage()` from `skybridge/web` or `useSendFollowUp()`
|
|
591
|
+
* from this module.
|
|
592
|
+
*
|
|
593
|
+
* @example
|
|
594
|
+
* function MyWidget() {
|
|
595
|
+
* const sendFollowUpMessage = useSendFollowUpMessage(); // skybridge/web
|
|
596
|
+
* const { sendFollowUp, Guard } =
|
|
597
|
+
* unstable_useSendFollowUpWithGhostGuard(sendFollowUpMessage);
|
|
598
|
+
*
|
|
599
|
+
* // The Guard MUST wrap the widget's root render, otherwise the ghost
|
|
600
|
+
* // iframe will not be suppressed.
|
|
601
|
+
* return (
|
|
602
|
+
* <Guard>
|
|
603
|
+
* <div className="my-widget">
|
|
604
|
+
* <button onClick={() => sendFollowUp("I uploaded my bill")}>
|
|
605
|
+
* Continue
|
|
606
|
+
* </button>
|
|
607
|
+
* </div>
|
|
608
|
+
* </Guard>
|
|
609
|
+
* );
|
|
610
|
+
* }
|
|
611
|
+
*
|
|
612
|
+
* @experimental Subject to change or removal without notice.
|
|
613
|
+
*/
|
|
614
|
+
declare function unstable_useSendFollowUpWithGhostGuard(sendFollowUp: (prompt: string) => void | Promise<void>): UnstableSendFollowUpWithGhostGuardResult;
|
|
615
|
+
|
|
531
616
|
/**
|
|
532
617
|
* Result from calling a tool
|
|
533
618
|
*/
|
|
@@ -786,19 +871,6 @@ declare function useRequestDisplayMode(): (mode: DisplayMode) => Promise<Display
|
|
|
786
871
|
*/
|
|
787
872
|
declare function useSafeArea(): SafeArea | null;
|
|
788
873
|
|
|
789
|
-
interface SendFollowUpOptions {
|
|
790
|
-
modelContext?: ModelContextUpdate | null;
|
|
791
|
-
}
|
|
792
|
-
/**
|
|
793
|
-
* Get a function to send follow-up messages to the AI.
|
|
794
|
-
* Works on both OpenAI widgets and MCP Apps.
|
|
795
|
-
*
|
|
796
|
-
* @deprecated Legacy MCP-widget-in-host stack. Preserved for back-compat; will move to
|
|
797
|
-
* `@waniwani/sdk/legacy/react` in a future minor release.
|
|
798
|
-
* @returns A function that sends a follow-up message
|
|
799
|
-
*/
|
|
800
|
-
declare function useSendFollowUp(): (prompt: string, options?: SendFollowUpOptions) => void;
|
|
801
|
-
|
|
802
874
|
/**
|
|
803
875
|
* Get the current theme.
|
|
804
876
|
* Works on both OpenAI widgets and MCP Apps.
|
|
@@ -1351,4 +1423,4 @@ interface ChatCardProps extends ChatBaseProps {
|
|
|
1351
1423
|
*/
|
|
1352
1424
|
declare const ChatCard: React$1.ForwardRefExoticComponent<ChatCardProps & React$1.RefAttributes<ChatHandle>>;
|
|
1353
1425
|
|
|
1354
|
-
export { ChatCard, type ChatCardProps, DevModeProvider, type DeviceType, type DisplayMode, type FlowActionResult, type HostContext, InitializeNextJsInIframe, LoadingWidget, type ModelContextContentBlock, type ModelContextUpdate, type NextJsHandlerOptions, type NextJsHandlerResult, type RegisteredResource, type RegisteredTool, type ResourceConfig, type SafeArea, type SafeAreaInsets, type SendFollowUpOptions, type Theme, type ToolCallResult, type ToolConfig, type ToolHandler, type ToolHandlerContext, type ToolResult, type ToolToolCallback, type UnifiedWidgetClient, type UnknownObject, type UserAgent, type WidgetCSP, type WidgetPlatform, WidgetProvider, createResource, createTool, detectPlatform, getMockState, initializeMockOpenAI, isMCPApps, isOpenAI, registerTools, toNextJsHandler, updateMockDisplayMode, updateMockGlobal, updateMockTheme, updateMockToolOutput, useCallTool, useDisplayMode, useFlowAction, useIsChatGptApp, useLocale, useMaxHeight, useOpenExternal, useRequestDisplayMode, useSafeArea, useSendFollowUp, useTheme, useToolOutput, useToolResponseMetadata, useUpdateModelContext, useWidgetClient, useWidgetState };
|
|
1426
|
+
export { ChatCard, type ChatCardProps, DevModeProvider, type DeviceType, type DisplayMode, type FlowActionResult, type HostContext, InitializeNextJsInIframe, LoadingWidget, type ModelContextContentBlock, type ModelContextUpdate, type NextJsHandlerOptions, type NextJsHandlerResult, type RegisteredResource, type RegisteredTool, type ResourceConfig, type SafeArea, type SafeAreaInsets, type SendFollowUpOptions, type Theme, type ToolCallResult, type ToolConfig, type ToolHandler, type ToolHandlerContext, type ToolResult, type ToolToolCallback, type UnifiedWidgetClient, type UnknownObject, type UnstableSendFollowUpWithGhostGuardResult, type UserAgent, type WidgetCSP, type WidgetPlatform, WidgetProvider, createResource, createTool, detectPlatform, getMockState, initializeMockOpenAI, isMCPApps, isOpenAI, registerTools, toNextJsHandler, unstable_useSendFollowUpWithGhostGuard, updateMockDisplayMode, updateMockGlobal, updateMockTheme, updateMockToolOutput, useCallTool, useDisplayMode, useFlowAction, useIsChatGptApp, useLocale, useMaxHeight, useOpenExternal, useRequestDisplayMode, useSafeArea, useSendFollowUp, useTheme, useToolOutput, useToolResponseMetadata, useUpdateModelContext, useWidgetClient, useWidgetState };
|