@assistant-ui/react 0.15.17 → 0.15.18
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/README.md +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.js +4 -2
- package/dist/mcp-apps/McpAppRenderer.d.ts +30 -8
- package/dist/mcp-apps/McpAppRenderer.d.ts.map +1 -1
- package/dist/mcp-apps/McpAppRenderer.js +91 -47
- package/dist/mcp-apps/McpAppRenderer.js.map +1 -1
- package/dist/mcp-apps/app-frame.d.ts.map +1 -1
- package/dist/mcp-apps/app-frame.js +41 -22
- package/dist/mcp-apps/app-frame.js.map +1 -1
- package/dist/mcp-apps/bridge.js +2 -3
- package/dist/mcp-apps/bridge.js.map +1 -1
- package/dist/mcp-apps/index.d.ts +2 -2
- package/dist/primitives/composer/ComposerInputPluginContext.d.ts +1 -2
- package/dist/primitives/composer/ComposerInputPluginContext.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerInputPluginContext.js +1 -6
- package/dist/primitives/composer/ComposerInputPluginContext.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverAction.js +46 -15
- package/dist/primitives/composer/trigger/TriggerPopoverAction.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverDirective.js +40 -10
- package/dist/primitives/composer/trigger/TriggerPopoverDirective.js.map +1 -1
- package/dist/primitives/composer/trigger/matchesTriggerItemQuery.d.ts +6 -0
- package/dist/primitives/composer/trigger/matchesTriggerItemQuery.d.ts.map +1 -0
- package/dist/primitives/composer/trigger/matchesTriggerItemQuery.js +9 -0
- package/dist/primitives/composer/trigger/matchesTriggerItemQuery.js.map +1 -0
- package/dist/primitives/composer/trigger/triggerNavigationResource.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/triggerNavigationResource.js +3 -5
- package/dist/primitives/composer/trigger/triggerNavigationResource.js.map +1 -1
- package/dist/primitives/messagePart/MessagePartText.d.ts +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.d.ts.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.js +3 -3
- package/dist/primitives/thread/useThreadViewportAutoScroll.js.map +1 -1
- package/dist/sandbox-host/SandboxHost.d.ts.map +1 -1
- package/dist/sandbox-host/SandboxHost.js +14 -5
- package/dist/sandbox-host/SandboxHost.js.map +1 -1
- package/dist/unstable/useMentionAdapter.d.ts +9 -3
- package/dist/unstable/useMentionAdapter.d.ts.map +1 -1
- package/dist/unstable/useMentionAdapter.js +50 -43
- package/dist/unstable/useMentionAdapter.js.map +1 -1
- package/dist/unstable/useModelContextSnapshot.d.ts +34 -0
- package/dist/unstable/useModelContextSnapshot.d.ts.map +1 -0
- package/dist/unstable/useModelContextSnapshot.js +61 -0
- package/dist/unstable/useModelContextSnapshot.js.map +1 -0
- package/dist/unstable/useSlashCommandAdapter.d.ts.map +1 -1
- package/dist/unstable/useSlashCommandAdapter.js +2 -8
- package/dist/unstable/useSlashCommandAdapter.js.map +1 -1
- package/dist/unstable/webmcp/WebMcpRegistrationResource.d.ts +14 -0
- package/dist/unstable/webmcp/WebMcpRegistrationResource.d.ts.map +1 -0
- package/dist/unstable/webmcp/WebMcpRegistrationResource.js +85 -0
- package/dist/unstable/webmcp/WebMcpRegistrationResource.js.map +1 -0
- package/dist/unstable/webmcp/convertTools.d.ts +21 -0
- package/dist/unstable/webmcp/convertTools.d.ts.map +1 -0
- package/dist/unstable/webmcp/convertTools.js +110 -0
- package/dist/unstable/webmcp/convertTools.js.map +1 -0
- package/dist/unstable/webmcp/useWebMcpProvider.d.ts +21 -0
- package/dist/unstable/webmcp/useWebMcpProvider.d.ts.map +1 -0
- package/dist/unstable/webmcp/useWebMcpProvider.js +105 -0
- package/dist/unstable/webmcp/useWebMcpProvider.js.map +1 -0
- package/dist/unstable/webmcp/webmcp-host.d.ts +39 -0
- package/dist/unstable/webmcp/webmcp-host.d.ts.map +1 -0
- package/dist/unstable/webmcp/webmcp-host.js +29 -0
- package/dist/unstable/webmcp/webmcp-host.js.map +1 -0
- package/dist/utils/Primitive.d.ts +4 -4
- package/package.json +12 -12
- package/src/index.ts +13 -0
- package/src/mcp-apps/McpAppRenderer.test.tsx +253 -5
- package/src/mcp-apps/McpAppRenderer.tsx +147 -52
- package/src/mcp-apps/app-frame.test.tsx +248 -1
- package/src/mcp-apps/app-frame.tsx +51 -5
- package/src/mcp-apps/bridge.ts +7 -2
- package/src/mcp-apps/index.ts +5 -1
- package/src/primitives/composer/ComposerInputPluginContext.tsx +0 -10
- package/src/primitives/composer/trigger/TriggerPopoverAction.tsx +4 -2
- package/src/primitives/composer/trigger/TriggerPopoverBehavior.test.tsx +109 -0
- package/src/primitives/composer/trigger/TriggerPopoverDirective.tsx +4 -2
- package/src/primitives/composer/trigger/matchesTriggerItemQuery.test.ts +52 -0
- package/src/primitives/composer/trigger/matchesTriggerItemQuery.ts +13 -0
- package/src/primitives/composer/trigger/triggerNavigationResource.ts +3 -10
- package/src/primitives/thread/useThreadViewportAutoScroll.ts +7 -6
- package/src/sandbox-host/SandboxHost.test.tsx +120 -2
- package/src/sandbox-host/SandboxHost.tsx +26 -6
- package/src/unstable/useComposerInputHistory.test.tsx +2 -1
- package/src/unstable/useMentionAdapter.test.tsx +337 -0
- package/src/unstable/useMentionAdapter.ts +94 -57
- package/src/unstable/useModelContextSnapshot.test.tsx +132 -0
- package/src/unstable/useModelContextSnapshot.ts +67 -0
- package/src/unstable/useSlashCommandAdapter.ts +2 -9
- package/src/unstable/webmcp/WebMcpRegistrationResource.ts +92 -0
- package/src/unstable/webmcp/__tests__/webmcp.fake.tsx +168 -0
- package/src/unstable/webmcp/convertTools.test.ts +393 -0
- package/src/unstable/webmcp/convertTools.ts +180 -0
- package/src/unstable/webmcp/useWebMcpProvider.test.tsx +466 -0
- package/src/unstable/webmcp/useWebMcpProvider.ts +150 -0
- package/src/unstable/webmcp/webmcp-host.test.ts +142 -0
- package/src/unstable/webmcp/webmcp-host.ts +83 -0
- package/dist/utils/invokeCallbackSafely.d.ts +0 -5
- package/dist/utils/invokeCallbackSafely.d.ts.map +0 -1
- package/dist/utils/invokeCallbackSafely.js +0 -15
- package/dist/utils/invokeCallbackSafely.js.map +0 -1
- package/dist/utils/useToolArgsFieldStatus.d.ts +0 -19
- package/dist/utils/useToolArgsFieldStatus.d.ts.map +0 -1
- package/dist/utils/useToolArgsFieldStatus.js +0 -23
- package/dist/utils/useToolArgsFieldStatus.js.map +0 -1
- package/src/utils/invokeCallbackSafely.ts +0 -11
- package/src/utils/useToolArgsFieldStatus.ts +0 -18
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ npm install @assistant-ui/react @assistant-ui/ai-sdk
|
|
|
48
48
|
|
|
49
49
|
import { AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
50
50
|
import { useChatRuntime } from "@assistant-ui/ai-sdk";
|
|
51
|
-
import { Thread } from "@/components/assistant-ui/thread";
|
|
51
|
+
import { Thread } from "@/components/assistant-ui/elements/thread.aui";
|
|
52
52
|
|
|
53
53
|
export function Chat() {
|
|
54
54
|
const runtime = useChatRuntime();
|
package/dist/index.d.ts
CHANGED
|
@@ -66,14 +66,17 @@ import { Unstable_UseLiveCompletionAdapterOptions, unstable_useLiveCompletionAda
|
|
|
66
66
|
import { Unstable_ComposerInputHistory, unstable_useComposerInputHistory } from "./unstable/useComposerInputHistory.js";
|
|
67
67
|
import { Unstable_ComposerInput, Unstable_TriggerPopoverAriaProps, Unstable_UseComposerInputOptions, unstable_useComposerInput, unstable_useTriggerPopoverAriaProps } from "./unstable/useComposerInput.js";
|
|
68
68
|
import { McpAppBridgeHandlers, McpAppDisplayMode, McpAppHostContext, McpAppHostInfo, McpAppMetadata, McpAppResource, McpAppResourceCSP, McpAppResourceMeta, McpAppSandboxConfig, McpAppToolCallParams, McpAppsHost, McpAppsRemoteHostOptions, ToolCallMessagePartMcpMetadata } from "./mcp-apps/types.js";
|
|
69
|
-
import { McpAppRenderer, McpAppRendererOptions } from "./mcp-apps/McpAppRenderer.js";
|
|
69
|
+
import { McpAppPartOptions, McpAppRenderer, McpAppRendererOptions } from "./mcp-apps/McpAppRenderer.js";
|
|
70
70
|
import { McpAppsRemoteHost } from "./mcp-apps/McpAppsRemoteHost.js";
|
|
71
71
|
import { getMcpAppFromToolPart } from "./mcp-apps/utils.js";
|
|
72
72
|
import "./mcp-apps/index.js";
|
|
73
|
+
import { Unstable_WebMcpProviderOptions, Unstable_WebMcpProviderResult, unstable_useWebMcpProvider } from "./unstable/webmcp/useWebMcpProvider.js";
|
|
74
|
+
import { defaultWebMcpFilter } from "./unstable/webmcp/convertTools.js";
|
|
73
75
|
import { AssistantContextConfig, AssistantDataUI, AssistantDataUIProps, AssistantInteractableProps, AssistantTool, AssistantToolProps, AssistantToolUI, AssistantToolUIProps, DataMessagePartComponent, DataMessagePartProps, DataRenderers, EmptyMessagePartComponent, EmptyMessagePartProps, EnrichedPartState, FileMessagePartComponent, FileMessagePartProps, GenerativeUIComponentRegistry, GenerativeUIMessagePartComponent, GenerativeUIMessagePartProps, GenerativeUIRender, GenerativeUIRenderError, GenerativeUIRenderProps, GroupByContext, ImageMessagePartComponent, ImageMessagePartProps, Interactables, McpAppResourceOutput, McpToolkitDefinition, McpToolkitEntry, McpToolkitToolConfig, PartState, ProviderToolConfig, QuoteMessagePartComponent, QuoteMessagePartProps, ReasoningGroupComponent, ReasoningGroupProps, ReasoningMessagePartComponent, ReasoningMessagePartProps, RuntimeAdapterProvider, RuntimeAdapters, SourceMessagePartComponent, SourceMessagePartProps, TextMessagePartComponent, TextMessagePartProps, ToolArgsStatus, ToolCallMessagePartComponent, ToolCallMessagePartProps, ToolCallText, ToolDefinition, Toolkit, ToolkitDefinition, ToolkitDefinitionEntry, Tools, Unstable_AudioMessagePartComponent, Unstable_AudioMessagePartProps, Unstable_InferInteractableState, Unstable_InteractableConfig, Unstable_InteractableDefinition, Unstable_InteractablePersistedState, Unstable_InteractablePersistenceAdapter, Unstable_InteractablePersistenceStatus, Unstable_InteractableRegistration, Unstable_InteractableStateSchema, Unstable_InteractableToolConfig, Unstable_InteractableToolRenderProps, Unstable_InteractableVersionInfo, Unstable_InteractablesClientSchema, Unstable_InteractablesConfig, Unstable_InteractablesMethods, Unstable_InteractablesState, defineMcpToolkit, defineToolkit, externalTool, groupPartByType, hitl, hitlTool, humanTool, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, providerTool, stubTool, unstable_Interactables, unstable_interactableTool, unstable_useInteractable, unstable_useInteractableState, unstable_useInteractableVersions, unstable_useThreadMessageIds, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAuiToolOverrides, useCloudThreadListRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useRuntimeAdapters, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume } from "@assistant-ui/core/react";
|
|
74
76
|
import { AssistantClient, AssistantEventCallback, AssistantEventName, AssistantEventPayload, AssistantEventScope, AssistantEventSelector, AssistantState, AuiConfig, AuiIf, AuiProvider, useAui, useAuiEvent, useAuiState } from "@assistant-ui/store";
|
|
77
|
+
import { AddToolResultOptions, AppendMessage, AssistantFrameHost, AssistantFrameProvider, AssistantRuntime, Attachment, AttachmentAdapter, AttachmentRuntime, AttachmentState, AttachmentStatus, ChatModelAdapter, ChatModelRunOptions, ChatModelRunResult, ChatModelRunUpdate, CompleteAttachment, ComposerRuntime, ComposerState, CompositeAttachmentAdapter, CreateAppendMessage, CreateAttachment, CreateResumeRunConfig, CreateStartRunConfig, CreateSuggestionAdapterOptions, DataMessagePart, DictationAdapter, DictationState, EditComposerRuntime, EditComposerState, ExportedMessageRepository, ExportedMessageRepositoryItem, ExternalStoreAdapter, ExternalStoreBranchChange, ExternalStoreMessageConverter, ExternalStoreSharedOptions, ExternalStoreThreadData, ExternalStoreThreadListAdapter, ExternalThreadBranchAdapter, ExternalThreadQueueAdapter, FRAME_MESSAGE_CHANNEL, FeedbackAdapter, FileMessagePart, FrameMessage, FrameMessageType, GenerativeUIMessagePart, GenerativeUINode, GenerativeUISpec, GenericThreadHistoryAdapter, ImageMessagePart, InMemoryThreadListAdapter, LanguageModelConfig, LanguageModelV1CallSettings, LocalRuntimeOptionsBase, MessageFormatAdapter, MessageFormatItem, MessageFormatRepository, MessageNotSentError, MessagePartRuntime, MessagePartState, MessagePartStatus, MessagePartStreamStatus, MessageQueueController, MessageQueueDriver, MessageRuntime, MessageState, MessageStatus, MessageStorageEntry, MessageTiming, ModelContext, ModelContextProvider, ModelContextRegistry, ModelContextRegistryInstructionHandle, ModelContextRegistryProviderHandle, ModelContextRegistryToolHandle, PartProviderMetadata, PendingAttachment, QuoteInfo, RealtimeVoiceAdapter, ReasoningMessagePart, RemoteThreadListAdapter, RemoteThreadListProviderComponent, RespondToToolApprovalOptions, SerializedModelContext, SerializedTool, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SourceMessagePart, SourceProviderMetadata, SpeechSynthesisAdapter, SubmitFeedbackOptions, SuggestionAdapter, SuggestionAdapterGenerateOptions, TextMessagePart, ThreadAssistantMessage, ThreadAssistantMessagePart, ThreadComposerRuntime, ThreadComposerState, ThreadHistoryAdapter, ThreadListItemRuntime, ThreadListItemState, ThreadListItemStatus, ThreadListRuntime, ThreadListState, ThreadMessage, ThreadMessageLike, ThreadRuntime, ThreadState, ThreadSuggestion, ThreadSystemMessage, ThreadUserMessage, ThreadUserMessagePart, ToolApprovalDisplay, ToolApprovalOption, ToolApprovalOptionKind, ToolApprovalResponse, ToolCallMessagePart, ToolCallMessagePartStatus, ToolCallTiming, ToolModelContentPart, Unstable_AudioMessagePart, Unstable_DirectiveFormatter, Unstable_DirectiveSegment, Unstable_InteractableSnapshotEntry, Unstable_InteractableVersion, Unstable_TriggerItem, Unsubscribe, VoiceSessionControls, VoiceSessionHelpers, VoiceSessionState, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createSuggestionAdapter, createVoiceSession, fromThreadMessageLike, generateId, getExternalStoreMessages, isMessageNotSentError, mergeModelContexts, pickExternalStoreSharedOptions, tool, toolApprovalAcceptsText, unstable_defaultDirectiveFormatter, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions } from "@assistant-ui/core";
|
|
75
78
|
import { AssistantCloud } from "assistant-cloud";
|
|
76
|
-
import { AddToolResultOptions, AppendMessage, AssistantFrameHost, AssistantFrameProvider, AssistantRuntime, Attachment, AttachmentAdapter, AttachmentRuntime, AttachmentState, AttachmentStatus, ChatModelAdapter, ChatModelRunOptions, ChatModelRunResult, ChatModelRunUpdate, CompleteAttachment, ComposerRuntime, ComposerState, CompositeAttachmentAdapter, CreateAppendMessage, CreateAttachment, CreateResumeRunConfig, CreateStartRunConfig, CreateSuggestionAdapterOptions, DataMessagePart, DictationAdapter, DictationState, EditComposerRuntime, EditComposerState, ExportedMessageRepository, ExportedMessageRepositoryItem, ExternalStoreAdapter, ExternalStoreBranchChange, ExternalStoreMessageConverter, ExternalStoreSharedOptions, ExternalStoreThreadData, ExternalStoreThreadListAdapter, ExternalThreadBranchAdapter, ExternalThreadQueueAdapter, FRAME_MESSAGE_CHANNEL, FeedbackAdapter, FileMessagePart, FrameMessage, FrameMessageType, GenerativeUIMessagePart, GenerativeUINode, GenerativeUISpec, GenericThreadHistoryAdapter, ImageMessagePart, InMemoryThreadListAdapter, LanguageModelConfig, LanguageModelV1CallSettings, LocalRuntimeOptionsBase, MessageFormatAdapter, MessageFormatItem, MessageFormatRepository, MessageNotSentError, MessagePartRuntime, MessagePartState, MessagePartStatus, MessagePartStreamStatus, MessageQueueController, MessageQueueDriver, MessageRuntime, MessageState, MessageStatus, MessageStorageEntry, MessageTiming, ModelContext, ModelContextProvider, ModelContextRegistry, ModelContextRegistryInstructionHandle, ModelContextRegistryProviderHandle, ModelContextRegistryToolHandle, PartProviderMetadata, PendingAttachment, QuoteInfo, RealtimeVoiceAdapter, ReasoningMessagePart, RemoteThreadListAdapter, RemoteThreadListProviderComponent, RespondToToolApprovalOptions, SerializedModelContext, SerializedTool, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SourceMessagePart, SourceProviderMetadata, SpeechSynthesisAdapter, SubmitFeedbackOptions, SuggestionAdapter, SuggestionAdapterGenerateOptions, TextMessagePart, ThreadAssistantMessage, ThreadAssistantMessagePart, ThreadComposerRuntime, ThreadComposerState, ThreadHistoryAdapter, ThreadListItemRuntime, ThreadListItemState, ThreadListItemStatus, ThreadListRuntime, ThreadListState, ThreadMessage, ThreadMessageLike, ThreadRuntime, ThreadState, ThreadSuggestion, ThreadSystemMessage, ThreadUserMessage, ThreadUserMessagePart, ToolApprovalOption, ToolApprovalOptionKind, ToolApprovalResponse, ToolCallMessagePart, ToolCallMessagePartStatus, ToolCallTiming, ToolModelContentPart, Unstable_AudioMessagePart, Unstable_DirectiveFormatter, Unstable_DirectiveSegment, Unstable_InteractableSnapshotEntry, Unstable_InteractableVersion, Unstable_TriggerItem, Unsubscribe, VoiceSessionControls, VoiceSessionHelpers, VoiceSessionState, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createSuggestionAdapter, createVoiceSession, fromThreadMessageLike, generateId, getExternalStoreMessages, isMessageNotSentError, mergeModelContexts, pickExternalStoreSharedOptions, tool, unstable_defaultDirectiveFormatter, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions } from "@assistant-ui/core";
|
|
77
79
|
import { ChainOfThoughtClient, ComposerSendOptions, ExternalThread, ExternalThreadMessage, ExternalThreadProps, InMemoryThreadList, InMemoryThreadListProps, ModelContext as ModelContextClient, QueueItemMethods, QueueItemState, RemoteThreadList, RemoteThreadListProps, SingleThreadList, SuggestionConfig, Suggestions } from "@assistant-ui/core/store";
|
|
80
|
+
import { ShimLoadError, ShimLoadErrorCode } from "safe-content-frame";
|
|
78
81
|
import { Tool } from "assistant-stream";
|
|
79
|
-
export { actionBarMore_d_exports as ActionBarMorePrimitive, actionBar_d_exports as ActionBarPrimitive, type AddToolResultOptions, type AppendMessage, type Assistant, type AssistantClient, AssistantCloud, type AssistantContextConfig, type AssistantDataUI, type AssistantDataUIProps, type AssistantEventCallback, type AssistantEventName, type AssistantEventPayload, type AssistantEventScope, type AssistantEventSelector, AssistantFrameHost, AssistantFrameProvider, type AssistantInteractableProps, assistantModal_d_exports as AssistantModalPrimitive, type AssistantRuntime, AssistantRuntimeProvider, type AssistantState, type AssistantTool, type AssistantToolProps, type AssistantToolUI, type AssistantToolUIProps, type AssistantTransportCommand, type AssistantTransportConnectionMetadata, type AssistantTransportProtocol, type Attachment, type AttachmentAdapter, attachment_d_exports as AttachmentPrimitive, type AttachmentRuntime, type AttachmentState, type AttachmentStatus, AuiConfig, AuiIf, AuiProvider, branchPicker_d_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, chainOfThought_d_exports as ChainOfThoughtPrimitive, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, CloudFileAttachmentAdapter, type CompleteAttachment, ComposerAttachmentByIndexProvider, composer_d_exports as ComposerPrimitive, type ComposerRuntime, type ComposerSendOptions, type ComposerState, CompositeAttachmentAdapter, type CreateAppendMessage, type CreateAttachment, type CreateResumeRunConfig, type CreateStartRunConfig, type CreateSuggestionAdapterOptions, type DataMessagePart, type DataMessagePartComponent, type DataMessagePartProps, DataRenderers, DevToolsHooks, DevToolsProviderApi, type DictationAdapter, type DictationState, type EditComposerRuntime, type EditComposerState, type EmptyMessagePartComponent, type EmptyMessagePartProps, type EnrichedPartState, error_d_exports as ErrorPrimitive, ExportedMessageRepository, type ExportedMessageRepositoryItem, type ExternalStoreAdapter, type ExternalStoreBranchChange, type ExternalStoreMessageConverter, type ExternalStoreSharedOptions, type ExternalStoreThreadData, type ExternalStoreThreadListAdapter, ExternalThread, type ExternalThreadBranchAdapter, type ExternalThreadMessage, type ExternalThreadProps, type ExternalThreadQueueAdapter, FRAME_MESSAGE_CHANNEL, type FeedbackAdapter, type FileMessagePart, type FileMessagePartComponent, type FileMessagePartProps, type FrameMessage, type FrameMessageType, type GenerativeUIComponentRegistry, type GenerativeUIMessagePart, type GenerativeUIMessagePartComponent, type GenerativeUIMessagePartProps, type GenerativeUINode, GenerativeUIRender, GenerativeUIRenderError, type GenerativeUIRenderProps, type GenerativeUISpec, type GenericThreadHistoryAdapter, type GroupByContext, internal_d_exports as INTERNAL, type ImageMessagePart, type ImageMessagePartComponent, type ImageMessagePartProps, InMemoryThreadList, InMemoryThreadListAdapter, type InMemoryThreadListProps, Interactables, type LanguageModelConfig, type LanguageModelV1CallSettings, type LocalRuntimeOptions, type LocalRuntimeOptionsBase, type McpAppBridgeHandlers, type McpAppDisplayMode, type McpAppHostContext, type McpAppHostInfo, type McpAppMetadata, McpAppRenderer, type McpAppRendererOptions, type McpAppResource, type McpAppResourceCSP, type McpAppResourceMeta, type McpAppResourceOutput, type McpAppSandboxConfig, type McpAppToolCallParams, type McpAppsHost, McpAppsRemoteHost, type McpAppsRemoteHostOptions, type McpToolkitDefinition, type McpToolkitEntry, type McpToolkitToolConfig, MessageAttachmentByIndexProvider, MessageByIndexProvider, type MessageFormatAdapter, type MessageFormatItem, type MessageFormatRepository, MessageNotSentError, messagePart_d_exports as MessagePartPrimitive, type MessagePartRuntime, type MessagePartState, type MessagePartStatus, type MessagePartStreamStatus, message_d_exports as MessagePrimitive, MessageProvider, type MessageQueueController, type MessageQueueDriver, type MessageRuntime, type MessageState, type MessageStatus, type MessageStorageEntry, type MessageTiming, type ModelContext, ModelContextClient, type ModelContextProvider, ModelContextRegistry, type ModelContextRegistryInstructionHandle, type ModelContextRegistryProviderHandle, type ModelContextRegistryToolHandle, PartByIndexProvider, type PartProviderMetadata, type PartState, type PendingAttachment, type ProviderToolConfig, type QueueItemMethods, queueItem_d_exports as QueueItemPrimitive, type QueueItemState, type QuoteInfo, type QuoteMessagePartComponent, type QuoteMessagePartProps, ReadonlyThreadProvider, type RealtimeVoiceAdapter, type ReasoningGroupComponent, type ReasoningGroupProps, type ReasoningMessagePart, type ReasoningMessagePartComponent, type ReasoningMessagePartProps, RemoteThreadList, type RemoteThreadListAdapter, type RemoteThreadListProps, type RemoteThreadListProviderComponent, type RespondToToolApprovalOptions, RuntimeAdapterProvider, type RuntimeAdapters, selectionToolbar_d_exports as SelectionToolbarPrimitive, type SendCommandsRequestBody, type SerializedModelContext, type SerializedTool, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SingleThreadList, type SmoothOptions, type SourceMessagePart, type SourceMessagePartComponent, type SourceMessagePartProps, type SourceProviderMetadata, type SpeechSynthesisAdapter, type SubmitFeedbackOptions, type SuggestionAdapter, type SuggestionAdapterGenerateOptions, SuggestionByIndexProvider, type SuggestionConfig, suggestion_d_exports as SuggestionPrimitive, Suggestions, type TextMessagePart, type TextMessagePartComponent, type TextMessagePartProps, TextMessagePartProvider, type ThreadAssistantMessage, type ThreadAssistantMessagePart, type ThreadComposerRuntime, type ThreadComposerState, type ThreadHistoryAdapter, ThreadListItemByIndexProvider, threadListItemMore_d_exports as ThreadListItemMorePrimitive, threadListItem_d_exports as ThreadListItemPrimitive, type ThreadListItemRuntime, ThreadListItemRuntimeProvider, type ThreadListItemState, type ThreadListItemStatus, threadList_d_exports as ThreadListPrimitive, type ThreadListRuntime, type ThreadListState, type ThreadMessage, type ThreadMessageLike, thread_d_exports as ThreadPrimitive, type ThreadRuntime, type ThreadState, type ThreadSuggestion, type ThreadSystemMessage, type ThreadUserMessage, type ThreadUserMessagePart, type ThreadViewportState, type Tool, type ToolApprovalOption, type ToolApprovalOptionKind, type ToolApprovalResponse, type ToolArgsStatus, type ToolCallMessagePart, type ToolCallMessagePartComponent, type ToolCallMessagePartMcpMetadata, type ToolCallMessagePartProps, type ToolCallMessagePartStatus, type ToolCallText, type ToolCallTiming, type ToolDefinition, type ToolExecutionStatus, type ToolModelContentPart, type Toolkit, type ToolkitDefinition, type ToolkitDefinitionEntry, Tools, type Unstable_AudioMessagePart, type Unstable_AudioMessagePartComponent, type Unstable_AudioMessagePartProps, type Unstable_ComposerInput, type Unstable_ComposerInputHistory, type Unstable_DirectiveFormatter, type Unstable_DirectiveSegment, type Unstable_IconComponent, type Unstable_InferInteractableState, type Unstable_InteractableConfig, type Unstable_InteractableDefinition, type Unstable_InteractablePersistedState, type Unstable_InteractablePersistenceAdapter, type Unstable_InteractablePersistenceStatus, type Unstable_InteractableRegistration, type Unstable_InteractableSnapshotEntry, type Unstable_InteractableStateSchema, type Unstable_InteractableToolConfig, type Unstable_InteractableToolRenderProps, type Unstable_InteractableVersion, type Unstable_InteractableVersionInfo, type Unstable_InteractablesClientSchema, type Unstable_InteractablesConfig, type Unstable_InteractablesMethods, type Unstable_InteractablesState, type Unstable_Mention, type Unstable_MentionCategory, type Unstable_MentionDirective, type Unstable_MessageStallDetection, type Unstable_MessageStallDetectionOptions, type Unstable_ModelContextToolsOptions, type RegisteredTrigger as Unstable_RegisteredTrigger, type Unstable_SlashCommand, type Unstable_SlashCommandAction, type TriggerBehavior as Unstable_TriggerBehavior, type Unstable_TriggerItem, type TriggerMatch as Unstable_TriggerMatch, type TriggerMatcher as Unstable_TriggerMatcher, type Unstable_TriggerPopoverAriaProps, type Unstable_UseComposerInputOptions, type Unstable_UseLiveCompletionAdapterOptions, type Unstable_UseMentionAdapterOptions, type Unstable_UseSlashCommandAdapterOptions, type Unsubscribe, type VoiceSessionControls, type VoiceSessionHelpers, type VoiceSessionState, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createSuggestionAdapter, createVoiceSession, defineMcpToolkit, defineToolkit, externalTool, fromThreadMessageLike, generateId, getExternalStoreMessages, getMcpAppFromToolPart, groupPartByType, hitl, hitlTool, humanTool, isMessageNotSentError, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, makeAssistantVisible, mergeModelContexts, pickExternalStoreSharedOptions, providerTool, stubTool, tool, unstable_Interactables, convertExternalMessages as unstable_convertExternalMessages, createMessageConverter as unstable_createMessageConverter, unstable_defaultDirectiveFormatter, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions, unstable_interactableTool, unstable_useComposerInput, unstable_useComposerInputHistory, unstable_useInteractable, unstable_useInteractableState, unstable_useInteractableVersions, unstable_useLiveCompletionAdapter, unstable_useMentionAdapter, unstable_useMessageStallDetection, unstable_useSlashCommandAdapter, unstable_useThreadMessageIds, unstable_useTriggerPopoverAriaProps, useTriggerPopoverRootContext as unstable_useTriggerPopoverRootContext, useTriggerPopoverRootContextOptional as unstable_useTriggerPopoverRootContextOptional, useTriggerPopoverScopeContext as unstable_useTriggerPopoverScopeContext, useTriggerPopoverScopeContextOptional as unstable_useTriggerPopoverScopeContextOptional, useTriggerPopoverTriggers as unstable_useTriggerPopoverTriggers, useTriggerPopoverTriggersOptional as unstable_useTriggerPopoverTriggersOptional, useAssistantContext, useAssistantDataUI, useAssistantFrameHost, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAssistantTransportRuntime, useAssistantTransportSendCommand, useAssistantTransportState, useAui, useAuiEvent, useAuiState, useAuiToolOverrides, useCloudThreadListAdapter, useCloudThreadListRuntime, useExternalMessageConverter, useExternalStoreRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useLocalRuntime, useMessagePartData, useMessagePartFile, useMessagePartImage, useMessagePartReasoning, useMessagePartSource, useMessagePartText, useMessageQuote, useMessageTiming, useRemoteThreadListRuntime, useRuntimeAdapters, useScrollLock, useSmooth, useThreadViewport, useThreadViewportAutoScroll, useThreadViewportStore, useToolArgsStatus, useToolCallElapsed, useVoiceControls, useVoiceState, useVoiceVolume };
|
|
82
|
+
export { actionBarMore_d_exports as ActionBarMorePrimitive, actionBar_d_exports as ActionBarPrimitive, type AddToolResultOptions, type AppendMessage, type Assistant, type AssistantClient, AssistantCloud, type AssistantContextConfig, type AssistantDataUI, type AssistantDataUIProps, type AssistantEventCallback, type AssistantEventName, type AssistantEventPayload, type AssistantEventScope, type AssistantEventSelector, AssistantFrameHost, AssistantFrameProvider, type AssistantInteractableProps, assistantModal_d_exports as AssistantModalPrimitive, type AssistantRuntime, AssistantRuntimeProvider, type AssistantState, type AssistantTool, type AssistantToolProps, type AssistantToolUI, type AssistantToolUIProps, type AssistantTransportCommand, type AssistantTransportConnectionMetadata, type AssistantTransportProtocol, type Attachment, type AttachmentAdapter, attachment_d_exports as AttachmentPrimitive, type AttachmentRuntime, type AttachmentState, type AttachmentStatus, AuiConfig, AuiIf, AuiProvider, branchPicker_d_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, chainOfThought_d_exports as ChainOfThoughtPrimitive, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, CloudFileAttachmentAdapter, type CompleteAttachment, ComposerAttachmentByIndexProvider, composer_d_exports as ComposerPrimitive, type ComposerRuntime, type ComposerSendOptions, type ComposerState, CompositeAttachmentAdapter, type CreateAppendMessage, type CreateAttachment, type CreateResumeRunConfig, type CreateStartRunConfig, type CreateSuggestionAdapterOptions, type DataMessagePart, type DataMessagePartComponent, type DataMessagePartProps, DataRenderers, DevToolsHooks, DevToolsProviderApi, type DictationAdapter, type DictationState, type EditComposerRuntime, type EditComposerState, type EmptyMessagePartComponent, type EmptyMessagePartProps, type EnrichedPartState, error_d_exports as ErrorPrimitive, ExportedMessageRepository, type ExportedMessageRepositoryItem, type ExternalStoreAdapter, type ExternalStoreBranchChange, type ExternalStoreMessageConverter, type ExternalStoreSharedOptions, type ExternalStoreThreadData, type ExternalStoreThreadListAdapter, ExternalThread, type ExternalThreadBranchAdapter, type ExternalThreadMessage, type ExternalThreadProps, type ExternalThreadQueueAdapter, FRAME_MESSAGE_CHANNEL, type FeedbackAdapter, type FileMessagePart, type FileMessagePartComponent, type FileMessagePartProps, type FrameMessage, type FrameMessageType, type GenerativeUIComponentRegistry, type GenerativeUIMessagePart, type GenerativeUIMessagePartComponent, type GenerativeUIMessagePartProps, type GenerativeUINode, GenerativeUIRender, GenerativeUIRenderError, type GenerativeUIRenderProps, type GenerativeUISpec, type GenericThreadHistoryAdapter, type GroupByContext, internal_d_exports as INTERNAL, type ImageMessagePart, type ImageMessagePartComponent, type ImageMessagePartProps, InMemoryThreadList, InMemoryThreadListAdapter, type InMemoryThreadListProps, Interactables, type LanguageModelConfig, type LanguageModelV1CallSettings, type LocalRuntimeOptions, type LocalRuntimeOptionsBase, type McpAppBridgeHandlers, type McpAppDisplayMode, type McpAppHostContext, type McpAppHostInfo, type McpAppMetadata, type McpAppPartOptions, McpAppRenderer, type McpAppRendererOptions, type McpAppResource, type McpAppResourceCSP, type McpAppResourceMeta, type McpAppResourceOutput, type McpAppSandboxConfig, type McpAppToolCallParams, type McpAppsHost, McpAppsRemoteHost, type McpAppsRemoteHostOptions, type McpToolkitDefinition, type McpToolkitEntry, type McpToolkitToolConfig, MessageAttachmentByIndexProvider, MessageByIndexProvider, type MessageFormatAdapter, type MessageFormatItem, type MessageFormatRepository, MessageNotSentError, messagePart_d_exports as MessagePartPrimitive, type MessagePartRuntime, type MessagePartState, type MessagePartStatus, type MessagePartStreamStatus, message_d_exports as MessagePrimitive, MessageProvider, type MessageQueueController, type MessageQueueDriver, type MessageRuntime, type MessageState, type MessageStatus, type MessageStorageEntry, type MessageTiming, type ModelContext, ModelContextClient, type ModelContextProvider, ModelContextRegistry, type ModelContextRegistryInstructionHandle, type ModelContextRegistryProviderHandle, type ModelContextRegistryToolHandle, PartByIndexProvider, type PartProviderMetadata, type PartState, type PendingAttachment, type ProviderToolConfig, type QueueItemMethods, queueItem_d_exports as QueueItemPrimitive, type QueueItemState, type QuoteInfo, type QuoteMessagePartComponent, type QuoteMessagePartProps, ReadonlyThreadProvider, type RealtimeVoiceAdapter, type ReasoningGroupComponent, type ReasoningGroupProps, type ReasoningMessagePart, type ReasoningMessagePartComponent, type ReasoningMessagePartProps, RemoteThreadList, type RemoteThreadListAdapter, type RemoteThreadListProps, type RemoteThreadListProviderComponent, type RespondToToolApprovalOptions, RuntimeAdapterProvider, type RuntimeAdapters, selectionToolbar_d_exports as SelectionToolbarPrimitive, type SendCommandsRequestBody, type SerializedModelContext, type SerializedTool, type ShimLoadError, type ShimLoadErrorCode, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SingleThreadList, type SmoothOptions, type SourceMessagePart, type SourceMessagePartComponent, type SourceMessagePartProps, type SourceProviderMetadata, type SpeechSynthesisAdapter, type SubmitFeedbackOptions, type SuggestionAdapter, type SuggestionAdapterGenerateOptions, SuggestionByIndexProvider, type SuggestionConfig, suggestion_d_exports as SuggestionPrimitive, Suggestions, type TextMessagePart, type TextMessagePartComponent, type TextMessagePartProps, TextMessagePartProvider, type ThreadAssistantMessage, type ThreadAssistantMessagePart, type ThreadComposerRuntime, type ThreadComposerState, type ThreadHistoryAdapter, ThreadListItemByIndexProvider, threadListItemMore_d_exports as ThreadListItemMorePrimitive, threadListItem_d_exports as ThreadListItemPrimitive, type ThreadListItemRuntime, ThreadListItemRuntimeProvider, type ThreadListItemState, type ThreadListItemStatus, threadList_d_exports as ThreadListPrimitive, type ThreadListRuntime, type ThreadListState, type ThreadMessage, type ThreadMessageLike, thread_d_exports as ThreadPrimitive, type ThreadRuntime, type ThreadState, type ThreadSuggestion, type ThreadSystemMessage, type ThreadUserMessage, type ThreadUserMessagePart, type ThreadViewportState, type Tool, type ToolApprovalDisplay, type ToolApprovalOption, type ToolApprovalOptionKind, type ToolApprovalResponse, type ToolArgsStatus, type ToolCallMessagePart, type ToolCallMessagePartComponent, type ToolCallMessagePartMcpMetadata, type ToolCallMessagePartProps, type ToolCallMessagePartStatus, type ToolCallText, type ToolCallTiming, type ToolDefinition, type ToolExecutionStatus, type ToolModelContentPart, type Toolkit, type ToolkitDefinition, type ToolkitDefinitionEntry, Tools, type Unstable_AudioMessagePart, type Unstable_AudioMessagePartComponent, type Unstable_AudioMessagePartProps, type Unstable_ComposerInput, type Unstable_ComposerInputHistory, type Unstable_DirectiveFormatter, type Unstable_DirectiveSegment, type Unstable_IconComponent, type Unstable_InferInteractableState, type Unstable_InteractableConfig, type Unstable_InteractableDefinition, type Unstable_InteractablePersistedState, type Unstable_InteractablePersistenceAdapter, type Unstable_InteractablePersistenceStatus, type Unstable_InteractableRegistration, type Unstable_InteractableSnapshotEntry, type Unstable_InteractableStateSchema, type Unstable_InteractableToolConfig, type Unstable_InteractableToolRenderProps, type Unstable_InteractableVersion, type Unstable_InteractableVersionInfo, type Unstable_InteractablesClientSchema, type Unstable_InteractablesConfig, type Unstable_InteractablesMethods, type Unstable_InteractablesState, type Unstable_Mention, type Unstable_MentionCategory, type Unstable_MentionDirective, type Unstable_MessageStallDetection, type Unstable_MessageStallDetectionOptions, type Unstable_ModelContextToolsOptions, type RegisteredTrigger as Unstable_RegisteredTrigger, type Unstable_SlashCommand, type Unstable_SlashCommandAction, type TriggerBehavior as Unstable_TriggerBehavior, type Unstable_TriggerItem, type TriggerMatch as Unstable_TriggerMatch, type TriggerMatcher as Unstable_TriggerMatcher, type Unstable_TriggerPopoverAriaProps, type Unstable_UseComposerInputOptions, type Unstable_UseLiveCompletionAdapterOptions, type Unstable_UseMentionAdapterOptions, type Unstable_UseSlashCommandAdapterOptions, type Unstable_WebMcpProviderOptions, type Unstable_WebMcpProviderResult, type Unsubscribe, type VoiceSessionControls, type VoiceSessionHelpers, type VoiceSessionState, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createSuggestionAdapter, createVoiceSession, defineMcpToolkit, defineToolkit, externalTool, fromThreadMessageLike, generateId, getExternalStoreMessages, getMcpAppFromToolPart, groupPartByType, hitl, hitlTool, humanTool, isMessageNotSentError, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, makeAssistantVisible, mergeModelContexts, pickExternalStoreSharedOptions, providerTool, stubTool, tool, toolApprovalAcceptsText, unstable_Interactables, convertExternalMessages as unstable_convertExternalMessages, createMessageConverter as unstable_createMessageConverter, unstable_defaultDirectiveFormatter, defaultWebMcpFilter as unstable_defaultWebMcpFilter, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions, unstable_interactableTool, unstable_useComposerInput, unstable_useComposerInputHistory, unstable_useInteractable, unstable_useInteractableState, unstable_useInteractableVersions, unstable_useLiveCompletionAdapter, unstable_useMentionAdapter, unstable_useMessageStallDetection, unstable_useSlashCommandAdapter, unstable_useThreadMessageIds, unstable_useTriggerPopoverAriaProps, useTriggerPopoverRootContext as unstable_useTriggerPopoverRootContext, useTriggerPopoverRootContextOptional as unstable_useTriggerPopoverRootContextOptional, useTriggerPopoverScopeContext as unstable_useTriggerPopoverScopeContext, useTriggerPopoverScopeContextOptional as unstable_useTriggerPopoverScopeContextOptional, useTriggerPopoverTriggers as unstable_useTriggerPopoverTriggers, useTriggerPopoverTriggersOptional as unstable_useTriggerPopoverTriggersOptional, unstable_useWebMcpProvider, useAssistantContext, useAssistantDataUI, useAssistantFrameHost, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAssistantTransportRuntime, useAssistantTransportSendCommand, useAssistantTransportState, useAui, useAuiEvent, useAuiState, useAuiToolOverrides, useCloudThreadListAdapter, useCloudThreadListRuntime, useExternalMessageConverter, useExternalStoreRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useLocalRuntime, useMessagePartData, useMessagePartFile, useMessagePartImage, useMessagePartReasoning, useMessagePartSource, useMessagePartText, useMessageQuote, useMessageTiming, useRemoteThreadListRuntime, useRuntimeAdapters, useScrollLock, useSmooth, useThreadViewport, useThreadViewportAutoScroll, useThreadViewportStore, useToolArgsStatus, useToolCallElapsed, useVoiceControls, useVoiceState, useVoiceVolume };
|
package/dist/index.js
CHANGED
|
@@ -61,9 +61,11 @@ import { unstable_useComposerInput, unstable_useTriggerPopoverAriaProps } from "
|
|
|
61
61
|
import { getMcpAppFromToolPart } from "./mcp-apps/utils.js";
|
|
62
62
|
import { McpAppRenderer } from "./mcp-apps/McpAppRenderer.js";
|
|
63
63
|
import { McpAppsRemoteHost } from "./mcp-apps/McpAppsRemoteHost.js";
|
|
64
|
+
import { defaultWebMcpFilter } from "./unstable/webmcp/convertTools.js";
|
|
65
|
+
import { unstable_useWebMcpProvider } from "./unstable/webmcp/useWebMcpProvider.js";
|
|
64
66
|
import { DataRenderers, GenerativeUIRender, GenerativeUIRenderError, Interactables, RuntimeAdapterProvider, Tools, defineMcpToolkit, defineToolkit, externalTool, groupPartByType, hitl, hitlTool, humanTool, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, providerTool, stubTool, unstable_Interactables, unstable_interactableTool, unstable_useInteractable, unstable_useInteractableState, unstable_useInteractableVersions, unstable_useThreadMessageIds, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAuiToolOverrides, useCloudThreadListRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useRuntimeAdapters, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume } from "@assistant-ui/core/react";
|
|
65
67
|
import { AuiConfig, AuiIf, AuiProvider, useAui, useAuiEvent, useAuiState } from "@assistant-ui/store";
|
|
68
|
+
import { AssistantFrameHost, AssistantFrameProvider, CompositeAttachmentAdapter, ExportedMessageRepository, FRAME_MESSAGE_CHANNEL, InMemoryThreadListAdapter, MessageNotSentError, ModelContextRegistry, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createSuggestionAdapter, createVoiceSession, fromThreadMessageLike, generateId, getExternalStoreMessages, isMessageNotSentError, mergeModelContexts, pickExternalStoreSharedOptions, tool, toolApprovalAcceptsText, unstable_defaultDirectiveFormatter, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions } from "@assistant-ui/core";
|
|
66
69
|
import { AssistantCloud } from "assistant-cloud";
|
|
67
|
-
import { AssistantFrameHost, AssistantFrameProvider, CompositeAttachmentAdapter, ExportedMessageRepository, FRAME_MESSAGE_CHANNEL, InMemoryThreadListAdapter, MessageNotSentError, ModelContextRegistry, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createSuggestionAdapter, createVoiceSession, fromThreadMessageLike, generateId, getExternalStoreMessages, isMessageNotSentError, mergeModelContexts, pickExternalStoreSharedOptions, tool, unstable_defaultDirectiveFormatter, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions } from "@assistant-ui/core";
|
|
68
70
|
import { ChainOfThoughtClient, ExternalThread, InMemoryThreadList, ModelContext as ModelContextClient, RemoteThreadList, SingleThreadList, Suggestions } from "@assistant-ui/core/store";
|
|
69
|
-
export { actionBarMore_exports as ActionBarMorePrimitive, actionBar_exports as ActionBarPrimitive, AssistantCloud, AssistantFrameHost, AssistantFrameProvider, assistantModal_exports as AssistantModalPrimitive, AssistantRuntimeProvider, attachment_exports as AttachmentPrimitive, AuiConfig, AuiIf, AuiProvider, branchPicker_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, chainOfThought_exports as ChainOfThoughtPrimitive, CloudFileAttachmentAdapter, ComposerAttachmentByIndexProvider, composer_exports as ComposerPrimitive, CompositeAttachmentAdapter, DataRenderers, DevToolsHooks, DevToolsProviderApi, error_exports as ErrorPrimitive, ExportedMessageRepository, ExternalThread, FRAME_MESSAGE_CHANNEL, GenerativeUIRender, GenerativeUIRenderError, internal_exports as INTERNAL, InMemoryThreadList, InMemoryThreadListAdapter, Interactables, McpAppRenderer, McpAppsRemoteHost, MessageAttachmentByIndexProvider, MessageByIndexProvider, MessageNotSentError, messagePart_exports as MessagePartPrimitive, message_exports as MessagePrimitive, MessageProvider, ModelContextClient, ModelContextRegistry, PartByIndexProvider, queueItem_exports as QueueItemPrimitive, ReadonlyThreadProvider, RemoteThreadList, RuntimeAdapterProvider, selectionToolbar_exports as SelectionToolbarPrimitive, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SingleThreadList, SuggestionByIndexProvider, suggestion_exports as SuggestionPrimitive, Suggestions, TextMessagePartProvider, ThreadListItemByIndexProvider, threadListItemMore_exports as ThreadListItemMorePrimitive, threadListItem_exports as ThreadListItemPrimitive, ThreadListItemRuntimeProvider, threadList_exports as ThreadListPrimitive, thread_exports as ThreadPrimitive, Tools, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createSuggestionAdapter, createVoiceSession, defineMcpToolkit, defineToolkit, externalTool, fromThreadMessageLike, generateId, getExternalStoreMessages, getMcpAppFromToolPart, groupPartByType, hitl, hitlTool, humanTool, isMessageNotSentError, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, makeAssistantVisible, mergeModelContexts, pickExternalStoreSharedOptions, providerTool, stubTool, tool, unstable_Interactables, convertExternalMessages as unstable_convertExternalMessages, createMessageConverter as unstable_createMessageConverter, unstable_defaultDirectiveFormatter, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions, unstable_interactableTool, unstable_useComposerInput, unstable_useComposerInputHistory, unstable_useInteractable, unstable_useInteractableState, unstable_useInteractableVersions, unstable_useLiveCompletionAdapter, unstable_useMentionAdapter, unstable_useMessageStallDetection, unstable_useSlashCommandAdapter, unstable_useThreadMessageIds, unstable_useTriggerPopoverAriaProps, useTriggerPopoverRootContext as unstable_useTriggerPopoverRootContext, useTriggerPopoverRootContextOptional as unstable_useTriggerPopoverRootContextOptional, useTriggerPopoverScopeContext as unstable_useTriggerPopoverScopeContext, useTriggerPopoverScopeContextOptional as unstable_useTriggerPopoverScopeContextOptional, useTriggerPopoverTriggers as unstable_useTriggerPopoverTriggers, useTriggerPopoverTriggersOptional as unstable_useTriggerPopoverTriggersOptional, useAssistantContext, useAssistantDataUI, useAssistantFrameHost, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAssistantTransportRuntime, useAssistantTransportSendCommand, useAssistantTransportState, useAui, useAuiEvent, useAuiState, useAuiToolOverrides, useCloudThreadListAdapter, useCloudThreadListRuntime, useExternalMessageConverter, useExternalStoreRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useLocalRuntime, useMessagePartData, useMessagePartFile, useMessagePartImage, useMessagePartReasoning, useMessagePartSource, useMessagePartText, useMessageQuote, useMessageTiming, useRemoteThreadListRuntime, useRuntimeAdapters, useScrollLock, useSmooth, useThreadViewport, useThreadViewportAutoScroll, useThreadViewportStore, useToolArgsStatus, useToolCallElapsed, useVoiceControls, useVoiceState, useVoiceVolume };
|
|
71
|
+
export { actionBarMore_exports as ActionBarMorePrimitive, actionBar_exports as ActionBarPrimitive, AssistantCloud, AssistantFrameHost, AssistantFrameProvider, assistantModal_exports as AssistantModalPrimitive, AssistantRuntimeProvider, attachment_exports as AttachmentPrimitive, AuiConfig, AuiIf, AuiProvider, branchPicker_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, chainOfThought_exports as ChainOfThoughtPrimitive, CloudFileAttachmentAdapter, ComposerAttachmentByIndexProvider, composer_exports as ComposerPrimitive, CompositeAttachmentAdapter, DataRenderers, DevToolsHooks, DevToolsProviderApi, error_exports as ErrorPrimitive, ExportedMessageRepository, ExternalThread, FRAME_MESSAGE_CHANNEL, GenerativeUIRender, GenerativeUIRenderError, internal_exports as INTERNAL, InMemoryThreadList, InMemoryThreadListAdapter, Interactables, McpAppRenderer, McpAppsRemoteHost, MessageAttachmentByIndexProvider, MessageByIndexProvider, MessageNotSentError, messagePart_exports as MessagePartPrimitive, message_exports as MessagePrimitive, MessageProvider, ModelContextClient, ModelContextRegistry, PartByIndexProvider, queueItem_exports as QueueItemPrimitive, ReadonlyThreadProvider, RemoteThreadList, RuntimeAdapterProvider, selectionToolbar_exports as SelectionToolbarPrimitive, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SingleThreadList, SuggestionByIndexProvider, suggestion_exports as SuggestionPrimitive, Suggestions, TextMessagePartProvider, ThreadListItemByIndexProvider, threadListItemMore_exports as ThreadListItemMorePrimitive, threadListItem_exports as ThreadListItemPrimitive, ThreadListItemRuntimeProvider, threadList_exports as ThreadListPrimitive, thread_exports as ThreadPrimitive, Tools, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createSuggestionAdapter, createVoiceSession, defineMcpToolkit, defineToolkit, externalTool, fromThreadMessageLike, generateId, getExternalStoreMessages, getMcpAppFromToolPart, groupPartByType, hitl, hitlTool, humanTool, isMessageNotSentError, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, makeAssistantVisible, mergeModelContexts, pickExternalStoreSharedOptions, providerTool, stubTool, tool, toolApprovalAcceptsText, unstable_Interactables, convertExternalMessages as unstable_convertExternalMessages, createMessageConverter as unstable_createMessageConverter, unstable_defaultDirectiveFormatter, defaultWebMcpFilter as unstable_defaultWebMcpFilter, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions, unstable_interactableTool, unstable_useComposerInput, unstable_useComposerInputHistory, unstable_useInteractable, unstable_useInteractableState, unstable_useInteractableVersions, unstable_useLiveCompletionAdapter, unstable_useMentionAdapter, unstable_useMessageStallDetection, unstable_useSlashCommandAdapter, unstable_useThreadMessageIds, unstable_useTriggerPopoverAriaProps, useTriggerPopoverRootContext as unstable_useTriggerPopoverRootContext, useTriggerPopoverRootContextOptional as unstable_useTriggerPopoverRootContextOptional, useTriggerPopoverScopeContext as unstable_useTriggerPopoverScopeContext, useTriggerPopoverScopeContextOptional as unstable_useTriggerPopoverScopeContextOptional, useTriggerPopoverTriggers as unstable_useTriggerPopoverTriggers, useTriggerPopoverTriggersOptional as unstable_useTriggerPopoverTriggersOptional, unstable_useWebMcpProvider, useAssistantContext, useAssistantDataUI, useAssistantFrameHost, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAssistantTransportRuntime, useAssistantTransportSendCommand, useAssistantTransportState, useAui, useAuiEvent, useAuiState, useAuiToolOverrides, useCloudThreadListAdapter, useCloudThreadListRuntime, useExternalMessageConverter, useExternalStoreRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useLocalRuntime, useMessagePartData, useMessagePartFile, useMessagePartImage, useMessagePartReasoning, useMessagePartSource, useMessagePartText, useMessageQuote, useMessageTiming, useRemoteThreadListRuntime, useRuntimeAdapters, useScrollLock, useSmooth, useThreadViewport, useThreadViewportAutoScroll, useThreadViewportStore, useToolArgsStatus, useToolCallElapsed, useVoiceControls, useVoiceState, useVoiceVolume };
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { McpAppBridgeHandlers, McpAppHostContext, McpAppHostInfo, McpAppSandboxConfig, McpAppsHost } from "./types.js";
|
|
2
2
|
import { ToolCallMessagePartComponent } from "@assistant-ui/core/react";
|
|
3
|
+
import { ToolCallMessagePart } from "@assistant-ui/core";
|
|
3
4
|
import { ReactNode } from "react";
|
|
4
5
|
import { ResourceElement } from "@assistant-ui/tap";
|
|
5
6
|
//#region src/mcp-apps/McpAppRenderer.d.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
host: ResourceElement<McpAppsHost>;
|
|
7
|
+
/**
|
|
8
|
+
* Options that apply to a single MCP app. `McpAppRenderer` takes them as
|
|
9
|
+
* thread-wide defaults, and its `forPart` resolver overrides them for one part.
|
|
10
|
+
*/
|
|
11
|
+
type McpAppPartOptions = {
|
|
13
12
|
/** Sandbox + container styling. Passes through to SafeContentFrame. */
|
|
14
13
|
sandbox?: McpAppSandboxConfig;
|
|
15
14
|
/**
|
|
@@ -24,6 +23,10 @@ type McpAppRendererOptions = {
|
|
|
24
23
|
/**
|
|
25
24
|
* Optional widget interaction and lifecycle handlers. Data-plane handlers
|
|
26
25
|
* (`callTool`, `readResource`, `listResources`) always use `host`.
|
|
26
|
+
*
|
|
27
|
+
* Which handlers a widget may call is captured when its frame mounts, so a
|
|
28
|
+
* `forPart` resolver returns the same handler keys for a part on every
|
|
29
|
+
* render even when the implementations change.
|
|
27
30
|
*/
|
|
28
31
|
handlers?: Omit<McpAppBridgeHandlers, "callTool" | "readResource" | "listResources">;
|
|
29
32
|
/** Rendered when no MCP app is on the part, or while load is in flight / failed (unless overridden). */
|
|
@@ -33,9 +36,28 @@ type McpAppRendererOptions = {
|
|
|
33
36
|
/** Rendered when the resource load rejects. Defaults to `fallback`. */
|
|
34
37
|
errorFallback?: ReactNode | ((error: Error) => ReactNode);
|
|
35
38
|
};
|
|
39
|
+
type McpAppRendererOptions = McpAppPartOptions & {
|
|
40
|
+
/**
|
|
41
|
+
* Provides the data-plane operations the widget can request
|
|
42
|
+
* (`loadResource`, `callTool`, `readResource`, `listResources`). Use
|
|
43
|
+
* `McpAppsRemoteHost({ url })` for the default HTTP-route convention.
|
|
44
|
+
*/
|
|
45
|
+
host: ResourceElement<McpAppsHost>;
|
|
46
|
+
/**
|
|
47
|
+
* Resolves the options for one part. Each returned value replaces the
|
|
48
|
+
* thread-wide option of the same name, so a host can give every MCP app its
|
|
49
|
+
* own display mode and answer `requestDisplayMode` for the part that asked.
|
|
50
|
+
*
|
|
51
|
+
* `handlers` is the exception and merges per key. Its keys are capabilities
|
|
52
|
+
* negotiated with the widget rather than data, so replacing the whole bag to
|
|
53
|
+
* add one handler would withdraw the others from that part's widget with
|
|
54
|
+
* nothing to observe it by.
|
|
55
|
+
*/
|
|
56
|
+
forPart?: (part: ToolCallMessagePart) => McpAppPartOptions;
|
|
57
|
+
};
|
|
36
58
|
declare const McpAppRenderer: import("@assistant-ui/tap").Resource<{
|
|
37
59
|
readonly render: ToolCallMessagePartComponent;
|
|
38
60
|
}, [options: McpAppRendererOptions]>;
|
|
39
61
|
//#endregion
|
|
40
|
-
export { McpAppRenderer, McpAppRendererOptions };
|
|
62
|
+
export { McpAppPartOptions, McpAppRenderer, McpAppRendererOptions };
|
|
41
63
|
//# sourceMappingURL=McpAppRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"McpAppRenderer.d.ts","names":[],"sources":["../../src/mcp-apps/McpAppRenderer.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"McpAppRenderer.d.ts","names":[],"sources":["../../src/mcp-apps/McpAppRenderer.tsx"],"mappings":";;;;;;;;;;KAuCY;;EAEV,UAAU;;;;;EAKV;;EAEA,WAAW;;EAEX,cAAc;;;;;;;;;EASd,WAAW,KACT;;EAIF,WAAW;;EAEX,kBAAkB;;EAElB,gBAAgB,cAAc,OAAO,UAAU;;KAGrC,wBAAwB;;;;;;EAMlC,MAAM,gBAAgB;;;;;;;;;;;EAWtB,WAAW,MAAM,wBAAwB;;cA+R9B,4CAAc;WA3BL,QAAA;IA2BmC,SAAA"}
|
|
@@ -8,6 +8,14 @@ import { Fragment, jsx } from "react/jsx-runtime";
|
|
|
8
8
|
import { isRecord } from "@assistant-ui/core/internal";
|
|
9
9
|
import { resource, useResource } from "@assistant-ui/tap";
|
|
10
10
|
//#region src/mcp-apps/McpAppRenderer.tsx
|
|
11
|
+
const isSameOptions = (a, b) => {
|
|
12
|
+
const aKeys = Object.keys(a).filter((key) => key !== "host");
|
|
13
|
+
const bKeys = Object.keys(b).filter((key) => key !== "host");
|
|
14
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
15
|
+
const aValues = a;
|
|
16
|
+
const bValues = b;
|
|
17
|
+
return aKeys.every((key) => Object.hasOwn(bValues, key) && Object.is(aValues[key], bValues[key]));
|
|
18
|
+
};
|
|
11
19
|
function getInput(part) {
|
|
12
20
|
if (part.status.type === "running" && (part.argsText === "" || part.argsText === "{}")) return;
|
|
13
21
|
return part.args;
|
|
@@ -15,17 +23,41 @@ function getInput(part) {
|
|
|
15
23
|
const defaultOpenLink = ({ url }) => {
|
|
16
24
|
window.open(url, "_blank", "noopener,noreferrer");
|
|
17
25
|
};
|
|
18
|
-
function
|
|
19
|
-
if (typeof params === "string") return params;
|
|
26
|
+
function extractSendMessageTexts(params) {
|
|
27
|
+
if (typeof params === "string") return [params];
|
|
20
28
|
if (!params || typeof params !== "object") return void 0;
|
|
21
29
|
const obj = params;
|
|
22
|
-
if (typeof obj["prompt"] === "string") return obj["prompt"];
|
|
23
|
-
if (typeof obj["text"] === "string") return obj["text"];
|
|
24
|
-
if (typeof obj["message"] === "string") return obj["message"];
|
|
30
|
+
if (typeof obj["prompt"] === "string") return [obj["prompt"]];
|
|
31
|
+
if (typeof obj["text"] === "string") return [obj["text"]];
|
|
32
|
+
if (typeof obj["message"] === "string") return [obj["message"]];
|
|
33
|
+
if (Array.isArray(obj["content"])) return obj["content"].filter((block) => isRecord(block) && block["type"] === "text" && typeof block["text"] === "string").map((block) => block.text);
|
|
34
|
+
}
|
|
35
|
+
function extractSendMessageContent(params) {
|
|
36
|
+
const texts = extractSendMessageTexts(params);
|
|
37
|
+
if (!texts) return { reason: "unrecognised params shape" };
|
|
38
|
+
const content = texts.filter((text) => text !== "").map((text) => ({
|
|
39
|
+
type: "text",
|
|
40
|
+
text
|
|
41
|
+
}));
|
|
42
|
+
if (content.length === 0) return { reason: "no text content to append" };
|
|
43
|
+
return { content };
|
|
25
44
|
}
|
|
26
|
-
function
|
|
27
|
-
const
|
|
45
|
+
function resolvePartOptions(options, part) {
|
|
46
|
+
const overrides = options.forPart?.(part);
|
|
47
|
+
if (!overrides) return options;
|
|
48
|
+
const handlers = options.handlers && overrides.handlers ? {
|
|
49
|
+
...options.handlers,
|
|
50
|
+
...overrides.handlers
|
|
51
|
+
} : overrides.handlers ?? options.handlers;
|
|
52
|
+
return {
|
|
53
|
+
...options,
|
|
54
|
+
...overrides,
|
|
55
|
+
...handlers === void 0 ? {} : { handlers }
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function InlineRenderer({ part, useRendererStore }) {
|
|
28
59
|
const aui = useAui();
|
|
60
|
+
const opts = resolvePartOptions(useRendererStore((state) => state.options), part);
|
|
29
61
|
const app = getMcpAppFromToolPart(part);
|
|
30
62
|
const cachedAppRef = useRef(void 0);
|
|
31
63
|
useLayoutEffect(() => {
|
|
@@ -33,7 +65,7 @@ function InlineRenderer({ part, useHostStore, optionsRef }) {
|
|
|
33
65
|
}, [app]);
|
|
34
66
|
const appForRender = app ?? cachedAppRef.current;
|
|
35
67
|
const [loadedResource, setLoadedResource] = useState();
|
|
36
|
-
const host =
|
|
68
|
+
const host = useRendererStore((state_0) => state_0.host);
|
|
37
69
|
const resourceUri = appForRender?.resourceUri;
|
|
38
70
|
const serverId = appForRender?.serverId;
|
|
39
71
|
const callerHandlers = opts.handlers;
|
|
@@ -43,58 +75,63 @@ function InlineRenderer({ part, useHostStore, optionsRef }) {
|
|
|
43
75
|
const targetHost = host;
|
|
44
76
|
const targetUri = resourceUri;
|
|
45
77
|
const targetServerId = serverId;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
78
|
+
const loadResource = async () => {
|
|
79
|
+
await Promise.resolve();
|
|
80
|
+
if (cancelled || useRendererStore.getState().host !== targetHost) return;
|
|
81
|
+
try {
|
|
82
|
+
const res = await targetHost.loadResource({
|
|
83
|
+
uri: targetUri,
|
|
84
|
+
...targetServerId ? { serverId: targetServerId } : {}
|
|
85
|
+
});
|
|
86
|
+
if (!cancelled) setLoadedResource({
|
|
87
|
+
host: targetHost,
|
|
88
|
+
resourceUri: targetUri,
|
|
89
|
+
...targetServerId !== void 0 ? { serverId: targetServerId } : {},
|
|
90
|
+
resource: res
|
|
91
|
+
});
|
|
92
|
+
} catch (error) {
|
|
93
|
+
if (!cancelled) setLoadedResource({
|
|
94
|
+
host: targetHost,
|
|
95
|
+
resourceUri: targetUri,
|
|
96
|
+
...targetServerId !== void 0 ? { serverId: targetServerId } : {},
|
|
97
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
loadResource();
|
|
64
102
|
return () => {
|
|
65
103
|
cancelled = true;
|
|
66
104
|
};
|
|
67
105
|
}, [
|
|
68
106
|
host,
|
|
69
107
|
resourceUri,
|
|
70
|
-
serverId
|
|
108
|
+
serverId,
|
|
109
|
+
useRendererStore
|
|
71
110
|
]);
|
|
72
111
|
const bridgeHandlers = useMemo(() => ({
|
|
73
112
|
...callerHandlers,
|
|
74
113
|
openLink: callerHandlers?.openLink ?? defaultOpenLink,
|
|
75
114
|
sendMessage: callerHandlers?.sendMessage ?? ((params) => {
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
115
|
+
const result = extractSendMessageContent(params);
|
|
116
|
+
if ("reason" in result) return {
|
|
117
|
+
isError: true,
|
|
78
118
|
ok: false,
|
|
79
|
-
reason:
|
|
119
|
+
reason: result.reason
|
|
80
120
|
};
|
|
81
|
-
aui.thread.append({ content:
|
|
82
|
-
type: "text",
|
|
83
|
-
text
|
|
84
|
-
}] });
|
|
121
|
+
aui.thread.append({ content: result.content });
|
|
85
122
|
return { ok: true };
|
|
86
123
|
}),
|
|
87
|
-
callTool: (params_0) =>
|
|
124
|
+
callTool: (params_0) => useRendererStore.getState().host.callTool({
|
|
88
125
|
...params_0,
|
|
89
126
|
...serverId ? { serverId } : {}
|
|
90
127
|
}),
|
|
91
|
-
readResource: (params_1) =>
|
|
128
|
+
readResource: (params_1) => useRendererStore.getState().host.readResource({
|
|
92
129
|
...params_1,
|
|
93
130
|
...serverId ? { serverId } : {}
|
|
94
131
|
}),
|
|
95
132
|
listResources: (params_2) => {
|
|
96
|
-
if (!serverId) return
|
|
97
|
-
return
|
|
133
|
+
if (!serverId) return useRendererStore.getState().host.listResources(params_2);
|
|
134
|
+
return useRendererStore.getState().host.listResources({
|
|
98
135
|
...isRecord(params_2) ? params_2 : {},
|
|
99
136
|
serverId
|
|
100
137
|
});
|
|
@@ -103,7 +140,7 @@ function InlineRenderer({ part, useHostStore, optionsRef }) {
|
|
|
103
140
|
aui,
|
|
104
141
|
callerHandlers,
|
|
105
142
|
serverId,
|
|
106
|
-
|
|
143
|
+
useRendererStore
|
|
107
144
|
]);
|
|
108
145
|
const loadedResourceForApp = loadedResource?.host === host && loadedResource?.resourceUri === appForRender?.resourceUri && loadedResource?.serverId === appForRender?.serverId ? loadedResource : void 0;
|
|
109
146
|
const appResource = loadedResourceForApp?.resource;
|
|
@@ -139,21 +176,28 @@ function InlineRenderer({ part, useHostStore, optionsRef }) {
|
|
|
139
176
|
*/
|
|
140
177
|
const useMcpAppRenderer = (options) => {
|
|
141
178
|
const host = useResource(options.host);
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
179
|
+
const [useRendererStore] = useState(() => create(() => ({
|
|
180
|
+
host,
|
|
181
|
+
options
|
|
182
|
+
})));
|
|
145
183
|
useEffect(() => {
|
|
146
|
-
|
|
147
|
-
|
|
184
|
+
useRendererStore.setState((prev) => prev.host === host && isSameOptions(prev.options, options) ? prev : {
|
|
185
|
+
host,
|
|
186
|
+
options
|
|
187
|
+
});
|
|
188
|
+
}, [
|
|
189
|
+
host,
|
|
190
|
+
options,
|
|
191
|
+
useRendererStore
|
|
192
|
+
]);
|
|
148
193
|
return { render: useMemo(() => {
|
|
149
194
|
const Render = (props) => /* @__PURE__ */ jsx(InlineRenderer, {
|
|
150
195
|
part: props,
|
|
151
|
-
|
|
152
|
-
optionsRef
|
|
196
|
+
useRendererStore
|
|
153
197
|
});
|
|
154
198
|
Render.displayName = "McpAppRenderer";
|
|
155
199
|
return Render;
|
|
156
|
-
}, [
|
|
200
|
+
}, [useRendererStore]) };
|
|
157
201
|
};
|
|
158
202
|
const McpAppRenderer = resource(useMcpAppRenderer);
|
|
159
203
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"McpAppRenderer.js","names":["useEffect","useLayoutEffect","useMemo","useRef","useState","MutableRefObject","ReactNode","McpAppMetadata","ToolCallMessagePartComponent","ToolCallMessagePartProps","useAui","create","StoreApi","UseBoundStore","useResource","resource","ResourceElement","McpAppFrame","McpAppBridgeHandlers","McpAppHostContext","McpAppHostInfo","McpAppResource","McpAppSandboxConfig","McpAppsHost","getMcpAppFromToolPart","isRecord","McpAppRendererOptions","host","sandbox","maxHeight","hostInfo","hostContext","handlers","Omit","fallback","loadingFallback","errorFallback","error","Error","LoadedResourceState","resourceUri","serverId","UseHostStore","getInput","part","status","type","argsText","args","undefined","defaultOpenLink","url","window","open","extractSendMessageText","params","obj","Record","InlineRenderer","useHostStore","optionsRef","opts","current","aui","app","cachedAppRef","appForRender","loadedResource","setLoadedResource","state","callerHandlers","cancelled","targetHost","targetUri","targetServerId","loadResource","uri","then","res","catch","String","bridgeHandlers","openLink","sendMessage","text","ok","reason","thread","append","content","callTool","getState","readResource","listResources","loadedResourceForApp","appResource","result","useMcpAppRenderer","options","render","setState","Render","props","displayName","McpAppRenderer"],"sources":["../../src/mcp-apps/McpAppRenderer.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type MutableRefObject,\n type ReactNode,\n} from \"react\";\nimport type { McpAppMetadata } from \"@assistant-ui/core\";\nimport type {\n ToolCallMessagePartComponent,\n ToolCallMessagePartProps,\n} from \"@assistant-ui/core/react\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { create, type StoreApi, type UseBoundStore } from \"zustand\";\n\nimport { useResource, resource, type ResourceElement } from \"@assistant-ui/tap\";\nimport { McpAppFrame } from \"./app-frame\";\nimport type {\n McpAppBridgeHandlers,\n McpAppHostContext,\n McpAppHostInfo,\n McpAppResource,\n McpAppSandboxConfig,\n McpAppsHost,\n} from \"./types\";\nimport { getMcpAppFromToolPart } from \"./utils\";\nimport { isRecord } from \"@assistant-ui/core/internal\";\n\nexport type McpAppRendererOptions = {\n /**\n * Provides the data-plane operations the widget can request\n * (`loadResource`, `callTool`, `readResource`, `listResources`). Use\n * `McpAppsRemoteHost({ url })` for the default HTTP-route convention.\n */\n host: ResourceElement<McpAppsHost>;\n /** Sandbox + container styling. Passes through to SafeContentFrame. */\n sandbox?: McpAppSandboxConfig;\n /**\n * Upper bound (in pixels) applied to the widget-driven auto-resize height.\n * Defaults to 800.\n */\n maxHeight?: number;\n /** Identifies the host to the widget in the `ui/initialize` response. */\n hostInfo?: McpAppHostInfo;\n /** Delivered to the widget on initialize and pushed via `notifications/host_context/changed` on change. */\n hostContext?: McpAppHostContext;\n /**\n * Optional widget interaction and lifecycle handlers. Data-plane handlers\n * (`callTool`, `readResource`, `listResources`) always use `host`.\n */\n handlers?: Omit<\n McpAppBridgeHandlers,\n \"callTool\" | \"readResource\" | \"listResources\"\n >;\n /** Rendered when no MCP app is on the part, or while load is in flight / failed (unless overridden). */\n fallback?: ReactNode;\n /** Rendered while the resource is loading. Defaults to `fallback`. */\n loadingFallback?: ReactNode;\n /** Rendered when the resource load rejects. Defaults to `fallback`. */\n errorFallback?: ReactNode | ((error: Error) => ReactNode);\n};\n\ntype LoadedResourceState = {\n host: McpAppsHost;\n resourceUri: string;\n serverId?: string;\n resource?: McpAppResource;\n error?: Error;\n};\n\ntype UseHostStore = UseBoundStore<StoreApi<{ host: McpAppsHost }>>;\n\nfunction getInput(part: {\n status: { type: string };\n argsText: string;\n args: unknown;\n}): unknown {\n if (\n part.status.type === \"running\" &&\n (part.argsText === \"\" || part.argsText === \"{}\")\n ) {\n return undefined;\n }\n return part.args;\n}\n\nconst defaultOpenLink = ({ url }: { url: string }) => {\n window.open(url, \"_blank\", \"noopener,noreferrer\");\n};\n\nfunction extractSendMessageText(params: unknown): string | undefined {\n if (typeof params === \"string\") return params;\n if (!params || typeof params !== \"object\") return undefined;\n const obj = params as Record<string, unknown>;\n if (typeof obj[\"prompt\"] === \"string\") return obj[\"prompt\"];\n if (typeof obj[\"text\"] === \"string\") return obj[\"text\"];\n if (typeof obj[\"message\"] === \"string\") return obj[\"message\"];\n return undefined;\n}\n\nfunction InlineRenderer({\n part,\n useHostStore,\n optionsRef,\n}: {\n part: ToolCallMessagePartProps;\n useHostStore: UseHostStore;\n optionsRef: MutableRefObject<McpAppRendererOptions>;\n}) {\n const opts = optionsRef.current;\n const aui = useAui();\n const app = getMcpAppFromToolPart(part);\n const cachedAppRef = useRef<McpAppMetadata | undefined>(undefined);\n useLayoutEffect(() => {\n if (app != null) cachedAppRef.current = app;\n }, [app]);\n const appForRender = app ?? cachedAppRef.current;\n\n const [loadedResource, setLoadedResource] = useState<LoadedResourceState>();\n\n const host = useHostStore((state) => state.host);\n const resourceUri = appForRender?.resourceUri;\n const serverId = appForRender?.serverId;\n const callerHandlers = opts.handlers;\n useEffect(() => {\n if (resourceUri == null) return;\n let cancelled = false;\n const targetHost = host;\n const targetUri = resourceUri;\n const targetServerId = serverId;\n\n targetHost\n .loadResource({\n uri: targetUri,\n ...(targetServerId ? { serverId: targetServerId } : {}),\n })\n .then((res) => {\n if (!cancelled)\n setLoadedResource({\n host: targetHost,\n resourceUri: targetUri,\n ...(targetServerId !== undefined\n ? { serverId: targetServerId }\n : {}),\n resource: res,\n });\n })\n .catch((error: unknown) => {\n if (!cancelled) {\n setLoadedResource({\n host: targetHost,\n resourceUri: targetUri,\n ...(targetServerId !== undefined\n ? { serverId: targetServerId }\n : {}),\n error: error instanceof Error ? error : new Error(String(error)),\n });\n }\n });\n\n return () => {\n cancelled = true;\n };\n }, [host, resourceUri, serverId]);\n\n const bridgeHandlers = useMemo<McpAppBridgeHandlers>(\n () => ({\n ...callerHandlers,\n openLink: callerHandlers?.openLink ?? defaultOpenLink,\n sendMessage:\n callerHandlers?.sendMessage ??\n ((params) => {\n const text = extractSendMessageText(params);\n if (!text) return { ok: false, reason: \"unrecognised params shape\" };\n aui.thread.append({ content: [{ type: \"text\", text }] });\n return { ok: true };\n }),\n callTool: (params) =>\n useHostStore.getState().host.callTool({\n ...params,\n ...(serverId ? { serverId } : {}),\n }),\n readResource: (params) =>\n useHostStore.getState().host.readResource({\n ...params,\n ...(serverId ? { serverId } : {}),\n }),\n listResources: (params) => {\n if (!serverId) {\n return useHostStore.getState().host.listResources(params);\n }\n return useHostStore.getState().host.listResources({\n ...(isRecord(params) ? params : {}),\n serverId,\n });\n },\n }),\n [aui, callerHandlers, serverId, useHostStore],\n );\n\n const loadedResourceForApp =\n loadedResource?.host === host &&\n loadedResource?.resourceUri === appForRender?.resourceUri &&\n loadedResource?.serverId === appForRender?.serverId\n ? loadedResource\n : undefined;\n const appResource = loadedResourceForApp?.resource;\n const error = loadedResourceForApp?.error;\n\n const fallback = opts.fallback ?? null;\n if (appForRender == null) {\n return <>{fallback}</>;\n }\n if (error != null) {\n const errorFallback = opts.errorFallback;\n if (errorFallback === undefined) return <>{fallback}</>;\n if (typeof errorFallback === \"function\") return <>{errorFallback(error)}</>;\n return <>{errorFallback}</>;\n }\n if (appResource == null) {\n return <>{opts.loadingFallback ?? fallback}</>;\n }\n\n return (\n <McpAppFrame\n app={appForRender}\n resource={appResource}\n input={getInput(part)}\n output={part.result}\n sandbox={opts.sandbox}\n handlers={bridgeHandlers}\n hostInfo={opts.hostInfo}\n hostContext={opts.hostContext}\n maxHeight={opts.maxHeight}\n />\n );\n}\n\n/**\n * Creates a tool-call renderer for MCP Apps embedded in assistant messages.\n *\n * Compose this into the `Tools` resource through its `mcpApp` option. When a\n * tool-call part carries `mcp.app` metadata for a `ui://` resource, the\n * renderer loads that resource from the configured host and displays it in a\n * sandboxed frame.\n */\nconst useMcpAppRenderer = (\n options: McpAppRendererOptions,\n): { readonly render: ToolCallMessagePartComponent } => {\n const host = useResource(options.host);\n\n const optionsRef = useRef<McpAppRendererOptions>(options);\n optionsRef.current = options;\n\n const [useHostStore] = useState(() =>\n create<{ host: McpAppsHost }>(() => ({ host })),\n );\n useEffect(() => {\n useHostStore.setState({ host });\n }, [host, useHostStore]);\n\n const render = useMemo((): ToolCallMessagePartComponent => {\n const Render: ToolCallMessagePartComponent = (props) => (\n <InlineRenderer\n part={props}\n useHostStore={useHostStore}\n optionsRef={optionsRef}\n />\n );\n Render.displayName = \"McpAppRenderer\";\n return Render;\n }, [useHostStore]);\n\n return { render };\n};\n\nexport const McpAppRenderer = resource(useMcpAppRenderer);\n"],"mappings":";;;;;;;;;;AA4EA,SAAS2C,SAASC,MAIN;CACV,IACEA,KAAKC,OAAOC,SAAS,cACpBF,KAAKG,aAAa,MAAMH,KAAKG,aAAa,OAE3C;CAEF,OAAOH,KAAKI;AACd;AAEA,MAAME,mBAAmB,EAAEC,UAA2B;CACpDC,OAAOC,KAAKF,KAAK,UAAU,qBAAqB;AAClD;AAEA,SAASG,uBAAuBC,QAAqC;CACnE,IAAI,OAAOA,WAAW,UAAU,OAAOA;CACvC,IAAI,CAACA,UAAU,OAAOA,WAAW,UAAU,OAAON,KAAAA;CAClD,MAAMO,MAAMD;CACZ,IAAI,OAAOC,IAAI,cAAc,UAAU,OAAOA,IAAI;CAClD,IAAI,OAAOA,IAAI,YAAY,UAAU,OAAOA,IAAI;CAChD,IAAI,OAAOA,IAAI,eAAe,UAAU,OAAOA,IAAI;AAErD;AAEA,SAASE,eAAe,EACtBd,MACAe,cACAC,cAKC;CACD,MAAMC,OAAOD,WAAWE;CACxB,MAAMC,MAAMrD,OAAO;CACnB,MAAMsD,MAAMxC,sBAAsBoB,IAAI;CACtC,MAAMqB,eAAe9D,OAAmC8C,KAAAA,CAAS;CACjEhD,sBAAsB;EACpB,IAAI+D,OAAO,MAAMC,aAAaH,UAAUE;CAC1C,GAAG,CAACA,GAAG,CAAC;CACR,MAAME,eAAeF,OAAOC,aAAaH;CAEzC,MAAM,CAACK,gBAAgBC,qBAAqBhE,SAA8B;CAE1E,MAAMuB,OAAOgC,cAAcU,UAAUA,MAAM1C,IAAI;CAC/C,MAAMa,cAAc0B,cAAc1B;CAClC,MAAMC,WAAWyB,cAAczB;CAC/B,MAA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;EACpB,QAAQA,KAAKoD;EACb,SAASnC,KAAKjC;EACd,UAAUqD;EACV,UAAUpB,KAAK/B;EACf,aAAa+B,KAAK9B;EAClB,WAAW8B,KAAKhC;CAAU,CAAA;AAGhC;;;;;;;;;AAUA,MAAMoE,qBACJC,YACsD;CACtD,MAAMvE,OAAOb,YAAYoF,QAAQvE,IAAI;CAErC,MAAMiC,aAAazD,OAA8B+F,OAAO;CACxDtC,WAAWE,UAAUoC;CAErB,MAAM,CAACvC,gBAAgBvD,eACrBO,cAAqC,EAAEgB,KAAK,EAAE,CAChD;CACA3B,gBAAgB;EACd2D,aAAayC,SAAS,EAAEzE,KAAK,CAAC;CAChC,GAAG,CAACA,MAAMgC,YAAY,CAAC;CAcvB,OAAO,EAAEwC,QAZMjG,cAA4C;EACzD,MAAMmG,UAAwCC,UAC5C,oBAAC,gBAAD;GACE,MAAMA;GACQ3C;GACFC;EAAW,CAAA;EAG3ByC,OAAOE,cAAc;EACrB,OAAOF;CACT,GAAG,CAAC1C,YAAY,CAEPwC,EAAO;AAClB;AAEA,MAAaK,iBAAiBzF,SAASkF,iBAAiB"}
|
|
1
|
+
{"version":3,"file":"McpAppRenderer.js","names":["useEffect","useLayoutEffect","useMemo","useRef","useState","ReactNode","McpAppMetadata","TextMessagePart","ToolCallMessagePart","ToolCallMessagePartComponent","ToolCallMessagePartProps","useAui","create","StoreApi","UseBoundStore","useResource","resource","ResourceElement","McpAppFrame","McpAppBridgeHandlers","McpAppHostContext","McpAppHostInfo","McpAppResource","McpAppSandboxConfig","McpAppsHost","getMcpAppFromToolPart","isRecord","McpAppPartOptions","sandbox","maxHeight","hostInfo","hostContext","handlers","Omit","fallback","loadingFallback","errorFallback","error","Error","McpAppRendererOptions","host","forPart","part","LoadedResourceState","resourceUri","serverId","RendererState","options","UseRendererStore","isSameOptions","a","b","aKeys","Object","keys","filter","key","bKeys","length","aValues","Record","bValues","every","hasOwn","is","getInput","status","type","argsText","args","undefined","defaultOpenLink","url","window","open","extractSendMessageTexts","params","obj","Array","isArray","block","text","map","extractSendMessageContent","content","reason","texts","resolvePartOptions","overrides","InlineRenderer","useRendererStore","aui","rendererOptions","state","opts","app","cachedAppRef","current","appForRender","loadedResource","setLoadedResource","callerHandlers","cancelled","targetHost","targetUri","targetServerId","loadResource","Promise","resolve","getState","res","uri","String","bridgeHandlers","openLink","sendMessage","result","isError","ok","thread","append","callTool","readResource","listResources","loadedResourceForApp","appResource","useMcpAppRenderer","render","setState","prev","Render","props","displayName","McpAppRenderer"],"sources":["../../src/mcp-apps/McpAppRenderer.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport type {\n McpAppMetadata,\n TextMessagePart,\n ToolCallMessagePart,\n} from \"@assistant-ui/core\";\nimport type {\n ToolCallMessagePartComponent,\n ToolCallMessagePartProps,\n} from \"@assistant-ui/core/react\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { create, type StoreApi, type UseBoundStore } from \"zustand\";\n\nimport { useResource, resource, type ResourceElement } from \"@assistant-ui/tap\";\nimport { McpAppFrame } from \"./app-frame\";\nimport type {\n McpAppBridgeHandlers,\n McpAppHostContext,\n McpAppHostInfo,\n McpAppResource,\n McpAppSandboxConfig,\n McpAppsHost,\n} from \"./types\";\nimport { getMcpAppFromToolPart } from \"./utils\";\nimport { isRecord } from \"@assistant-ui/core/internal\";\n\n/**\n * Options that apply to a single MCP app. `McpAppRenderer` takes them as\n * thread-wide defaults, and its `forPart` resolver overrides them for one part.\n */\nexport type McpAppPartOptions = {\n /** Sandbox + container styling. Passes through to SafeContentFrame. */\n sandbox?: McpAppSandboxConfig;\n /**\n * Upper bound (in pixels) applied to the widget-driven auto-resize height.\n * Defaults to 800.\n */\n maxHeight?: number;\n /** Identifies the host to the widget in the `ui/initialize` response. */\n hostInfo?: McpAppHostInfo;\n /** Delivered to the widget on initialize and pushed via `notifications/host_context/changed` on change. */\n hostContext?: McpAppHostContext;\n /**\n * Optional widget interaction and lifecycle handlers. Data-plane handlers\n * (`callTool`, `readResource`, `listResources`) always use `host`.\n *\n * Which handlers a widget may call is captured when its frame mounts, so a\n * `forPart` resolver returns the same handler keys for a part on every\n * render even when the implementations change.\n */\n handlers?: Omit<\n McpAppBridgeHandlers,\n \"callTool\" | \"readResource\" | \"listResources\"\n >;\n /** Rendered when no MCP app is on the part, or while load is in flight / failed (unless overridden). */\n fallback?: ReactNode;\n /** Rendered while the resource is loading. Defaults to `fallback`. */\n loadingFallback?: ReactNode;\n /** Rendered when the resource load rejects. Defaults to `fallback`. */\n errorFallback?: ReactNode | ((error: Error) => ReactNode);\n};\n\nexport type McpAppRendererOptions = McpAppPartOptions & {\n /**\n * Provides the data-plane operations the widget can request\n * (`loadResource`, `callTool`, `readResource`, `listResources`). Use\n * `McpAppsRemoteHost({ url })` for the default HTTP-route convention.\n */\n host: ResourceElement<McpAppsHost>;\n /**\n * Resolves the options for one part. Each returned value replaces the\n * thread-wide option of the same name, so a host can give every MCP app its\n * own display mode and answer `requestDisplayMode` for the part that asked.\n *\n * `handlers` is the exception and merges per key. Its keys are capabilities\n * negotiated with the widget rather than data, so replacing the whole bag to\n * add one handler would withdraw the others from that part's widget with\n * nothing to observe it by.\n */\n forPart?: (part: ToolCallMessagePart) => McpAppPartOptions;\n};\n\ntype LoadedResourceState = {\n host: McpAppsHost;\n resourceUri: string;\n serverId?: string;\n resource?: McpAppResource;\n error?: Error;\n};\n\ntype RendererState = {\n host: McpAppsHost;\n options: McpAppRendererOptions;\n};\n\ntype UseRendererStore = UseBoundStore<StoreApi<RendererState>>;\n\n// Callers pass options as an object literal, so the resource hands this a fresh\n// identity on every run; comparing the values keeps an unchanged run from\n// re-rendering every mounted part. `host` is excluded because it is an element\n// rebuilt on every run, and the store carries the resolved host separately.\nconst isSameOptions = (\n a: McpAppRendererOptions,\n b: McpAppRendererOptions,\n): boolean => {\n const aKeys = Object.keys(a).filter((key) => key !== \"host\");\n const bKeys = Object.keys(b).filter((key) => key !== \"host\");\n if (aKeys.length !== bKeys.length) return false;\n const aValues = a as Record<string, unknown>;\n const bValues = b as Record<string, unknown>;\n return aKeys.every(\n (key) =>\n Object.hasOwn(bValues, key) && Object.is(aValues[key], bValues[key]),\n );\n};\n\nfunction getInput(part: {\n status: { type: string };\n argsText: string;\n args: unknown;\n}): unknown {\n if (\n part.status.type === \"running\" &&\n (part.argsText === \"\" || part.argsText === \"{}\")\n ) {\n return undefined;\n }\n return part.args;\n}\n\nconst defaultOpenLink = ({ url }: { url: string }) => {\n window.open(url, \"_blank\", \"noopener,noreferrer\");\n};\n\nfunction extractSendMessageTexts(params: unknown): string[] | undefined {\n if (typeof params === \"string\") return [params];\n if (!params || typeof params !== \"object\") return undefined;\n const obj = params as Record<string, unknown>;\n if (typeof obj[\"prompt\"] === \"string\") return [obj[\"prompt\"]];\n if (typeof obj[\"text\"] === \"string\") return [obj[\"text\"]];\n if (typeof obj[\"message\"] === \"string\") return [obj[\"message\"]];\n if (Array.isArray(obj[\"content\"])) {\n return obj[\"content\"]\n .filter(\n (block): block is { type: \"text\"; text: string } =>\n isRecord(block) &&\n block[\"type\"] === \"text\" &&\n typeof block[\"text\"] === \"string\",\n )\n .map((block) => block.text);\n }\n return undefined;\n}\n\nfunction extractSendMessageContent(\n params: unknown,\n): { content: TextMessagePart[] } | { reason: string } {\n const texts = extractSendMessageTexts(params);\n if (!texts) return { reason: \"unrecognised params shape\" };\n const content = texts\n .filter((text) => text !== \"\")\n .map((text): TextMessagePart => ({ type: \"text\", text }));\n if (content.length === 0) {\n return { reason: \"no text content to append\" };\n }\n return { content };\n}\n\nfunction resolvePartOptions(\n options: McpAppRendererOptions,\n part: ToolCallMessagePartProps,\n): McpAppRendererOptions {\n const overrides = options.forPart?.(part);\n if (!overrides) return options;\n const handlers =\n options.handlers && overrides.handlers\n ? { ...options.handlers, ...overrides.handlers }\n : (overrides.handlers ?? options.handlers);\n return {\n ...options,\n ...overrides,\n ...(handlers === undefined ? {} : { handlers }),\n };\n}\n\nfunction InlineRenderer({\n part,\n useRendererStore,\n}: {\n part: ToolCallMessagePartProps;\n useRendererStore: UseRendererStore;\n}) {\n const aui = useAui();\n const rendererOptions = useRendererStore((state) => state.options);\n const opts = resolvePartOptions(rendererOptions, part);\n const app = getMcpAppFromToolPart(part);\n const cachedAppRef = useRef<McpAppMetadata | undefined>(undefined);\n useLayoutEffect(() => {\n if (app != null) cachedAppRef.current = app;\n }, [app]);\n const appForRender = app ?? cachedAppRef.current;\n\n const [loadedResource, setLoadedResource] = useState<LoadedResourceState>();\n\n const host = useRendererStore((state) => state.host);\n const resourceUri = appForRender?.resourceUri;\n const serverId = appForRender?.serverId;\n const callerHandlers = opts.handlers;\n useEffect(() => {\n if (resourceUri == null) return;\n let cancelled = false;\n const targetHost = host;\n const targetUri = resourceUri;\n const targetServerId = serverId;\n\n // Host changes are published later in this passive flush. Defer until that\n // publication lands, then verify this effect still owns the current host.\n const loadResource = async () => {\n await Promise.resolve();\n if (cancelled || useRendererStore.getState().host !== targetHost) return;\n try {\n const res = await targetHost.loadResource({\n uri: targetUri,\n ...(targetServerId ? { serverId: targetServerId } : {}),\n });\n if (!cancelled)\n setLoadedResource({\n host: targetHost,\n resourceUri: targetUri,\n ...(targetServerId !== undefined\n ? { serverId: targetServerId }\n : {}),\n resource: res,\n });\n } catch (error: unknown) {\n if (!cancelled) {\n setLoadedResource({\n host: targetHost,\n resourceUri: targetUri,\n ...(targetServerId !== undefined\n ? { serverId: targetServerId }\n : {}),\n error: error instanceof Error ? error : new Error(String(error)),\n });\n }\n }\n };\n void loadResource();\n\n return () => {\n cancelled = true;\n };\n }, [host, resourceUri, serverId, useRendererStore]);\n\n const bridgeHandlers = useMemo<McpAppBridgeHandlers>(\n () => ({\n ...callerHandlers,\n openLink: callerHandlers?.openLink ?? defaultOpenLink,\n sendMessage:\n callerHandlers?.sendMessage ??\n ((params) => {\n const result = extractSendMessageContent(params);\n if (\"reason\" in result) {\n return { isError: true, ok: false, reason: result.reason };\n }\n aui.thread.append({ content: result.content });\n return { ok: true };\n }),\n callTool: (params) =>\n useRendererStore.getState().host.callTool({\n ...params,\n ...(serverId ? { serverId } : {}),\n }),\n readResource: (params) =>\n useRendererStore.getState().host.readResource({\n ...params,\n ...(serverId ? { serverId } : {}),\n }),\n listResources: (params) => {\n if (!serverId) {\n return useRendererStore.getState().host.listResources(params);\n }\n return useRendererStore.getState().host.listResources({\n ...(isRecord(params) ? params : {}),\n serverId,\n });\n },\n }),\n [aui, callerHandlers, serverId, useRendererStore],\n );\n\n const loadedResourceForApp =\n loadedResource?.host === host &&\n loadedResource?.resourceUri === appForRender?.resourceUri &&\n loadedResource?.serverId === appForRender?.serverId\n ? loadedResource\n : undefined;\n const appResource = loadedResourceForApp?.resource;\n const error = loadedResourceForApp?.error;\n\n const fallback = opts.fallback ?? null;\n if (appForRender == null) {\n return <>{fallback}</>;\n }\n if (error != null) {\n const errorFallback = opts.errorFallback;\n if (errorFallback === undefined) return <>{fallback}</>;\n if (typeof errorFallback === \"function\") return <>{errorFallback(error)}</>;\n return <>{errorFallback}</>;\n }\n if (appResource == null) {\n return <>{opts.loadingFallback ?? fallback}</>;\n }\n\n return (\n <McpAppFrame\n app={appForRender}\n resource={appResource}\n input={getInput(part)}\n output={part.result}\n sandbox={opts.sandbox}\n handlers={bridgeHandlers}\n hostInfo={opts.hostInfo}\n hostContext={opts.hostContext}\n maxHeight={opts.maxHeight}\n />\n );\n}\n\n/**\n * Creates a tool-call renderer for MCP Apps embedded in assistant messages.\n *\n * Compose this into the `Tools` resource through its `mcpApp` option. When a\n * tool-call part carries `mcp.app` metadata for a `ui://` resource, the\n * renderer loads that resource from the configured host and displays it in a\n * sandboxed frame.\n */\nconst useMcpAppRenderer = (\n options: McpAppRendererOptions,\n): { readonly render: ToolCallMessagePartComponent } => {\n const host = useResource(options.host);\n\n // The rendered component identity has to stay stable, or every part remounts\n // its frame; options reach the parts through the store instead of props.\n const [useRendererStore] = useState(() =>\n create<RendererState>(() => ({ host, options })),\n );\n useEffect(() => {\n useRendererStore.setState((prev) =>\n prev.host === host && isSameOptions(prev.options, options)\n ? prev\n : { host, options },\n );\n }, [host, options, useRendererStore]);\n\n const render = useMemo((): ToolCallMessagePartComponent => {\n const Render: ToolCallMessagePartComponent = (props) => (\n <InlineRenderer part={props} useRendererStore={useRendererStore} />\n );\n Render.displayName = \"McpAppRenderer\";\n return Render;\n }, [useRendererStore]);\n\n return { render };\n};\n\nexport const McpAppRenderer = resource(useMcpAppRenderer);\n"],"mappings":";;;;;;;;;;AA8GA,MAAMiD,iBACJC,GACAC,MACY;CACZ,MAAMC,QAAQC,OAAOC,KAAKJ,CAAC,CAAC,CAACK,QAAQC,QAAQA,QAAQ,MAAM;CAC3D,MAAMC,QAAQJ,OAAOC,KAAKH,CAAC,CAAC,CAACI,QAAQC,QAAQA,QAAQ,MAAM;CAC3D,IAAIJ,MAAMM,WAAWD,MAAMC,QAAQ,OAAO;CAC1C,MAAMC,UAAUT;CAChB,MAAMW,UAAUV;CAChB,OAAOC,MAAMU,OACVN,QACCH,OAAOU,OAAOF,SAASL,GAAG,KAAKH,OAAOW,GAAGL,QAAQH,MAAMK,QAAQL,IAAI,CACvE;AACF;AAEA,SAASS,SAASvB,MAIN;CACV,IACEA,KAAKwB,OAAOC,SAAS,cACpBzB,KAAK0B,aAAa,MAAM1B,KAAK0B,aAAa,OAE3C;CAEF,OAAO1B,KAAK2B;AACd;AAEA,MAAME,mBAAmB,EAAEC,UAA2B;CACpDC,OAAOC,KAAKF,KAAK,UAAU,qBAAqB;AAClD;AAEA,SAASG,wBAAwBC,QAAuC;CACtE,IAAI,OAAOA,WAAW,UAAU,OAAO,CAACA,MAAM;CAC9C,IAAI,CAACA,UAAU,OAAOA,WAAW,UAAU,OAAON,KAAAA;CAClD,MAAMO,MAAMD;CACZ,IAAI,OAAOC,IAAI,cAAc,UAAU,OAAO,CAACA,IAAI,SAAS;CAC5D,IAAI,OAAOA,IAAI,YA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["../../src/mcp-apps/app-frame.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"app-frame.d.ts","names":[],"sources":["../../src/mcp-apps/app-frame.tsx"],"mappings":";;iBAgJgB,cACd,KACA,UACA,OACA,QACA,SACA,UACA,UACA,aACA,aACC,mCAAgB,IAAA"}
|
|
@@ -4,18 +4,35 @@ import { SandboxHost } from "../sandbox-host/SandboxHost.js";
|
|
|
4
4
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
5
5
|
import { useEffect, useLayoutEffect, useRef } from "@assistant-ui/tap/react-shim";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { isRecord } from "@assistant-ui/core/internal";
|
|
7
8
|
//#region src/mcp-apps/app-frame.tsx
|
|
8
9
|
const DEFAULT_PRODUCT = "assistant-ui-mcp-app";
|
|
9
10
|
const INIT_TIMEOUT_MS = 5e3;
|
|
10
11
|
const DEFAULT_MAX_HEIGHT = 800;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const isPlainObject = (value) => {
|
|
13
|
+
if (!isRecord(value)) return false;
|
|
14
|
+
const prototype = Object.getPrototypeOf(value);
|
|
15
|
+
return prototype === null || prototype === Object.prototype;
|
|
16
|
+
};
|
|
17
|
+
const isSameHostContext = (a, b, depth = 0) => {
|
|
18
|
+
if (Object.is(a, b)) return true;
|
|
19
|
+
if (depth > 100) return false;
|
|
20
|
+
if (Array.isArray(a) || Array.isArray(b)) return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((item, index) => isSameHostContext(item, b[index], depth + 1));
|
|
21
|
+
if (!isPlainObject(a) || !isPlainObject(b)) return false;
|
|
22
|
+
const aKeys = Object.keys(a);
|
|
23
|
+
return aKeys.length === Object.keys(b).length && aKeys.every((key) => Object.hasOwn(b, key) && isSameHostContext(a[key], b[key], depth + 1));
|
|
24
|
+
};
|
|
25
|
+
function useBridgeNotify(value, bridgeRef, widgetReadyRef, pendingRef, lastSentRef, notify, t0) {
|
|
26
|
+
const $ = c(10);
|
|
27
|
+
const isEqual = t0 === void 0 ? Object.is : t0;
|
|
28
|
+
let t1;
|
|
29
|
+
if ($[0] !== bridgeRef || $[1] !== isEqual || $[2] !== lastSentRef || $[3] !== notify || $[4] !== pendingRef || $[5] !== value || $[6] !== widgetReadyRef) {
|
|
30
|
+
t1 = () => {
|
|
16
31
|
if (!bridgeRef.current) return;
|
|
17
|
-
if (value === void 0)
|
|
18
|
-
|
|
32
|
+
if (value === void 0 || isEqual(lastSentRef.current, value)) {
|
|
33
|
+
pendingRef.current = void 0;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
19
36
|
if (!widgetReadyRef.current) {
|
|
20
37
|
pendingRef.current = value;
|
|
21
38
|
return;
|
|
@@ -24,20 +41,21 @@ function useBridgeNotify(value, bridgeRef, widgetReadyRef, pendingRef, lastSentR
|
|
|
24
41
|
lastSentRef.current = value;
|
|
25
42
|
};
|
|
26
43
|
$[0] = bridgeRef;
|
|
27
|
-
$[1] =
|
|
28
|
-
$[2] =
|
|
29
|
-
$[3] =
|
|
30
|
-
$[4] =
|
|
31
|
-
$[5] =
|
|
32
|
-
$[6] =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
$[8] =
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
$[1] = isEqual;
|
|
45
|
+
$[2] = lastSentRef;
|
|
46
|
+
$[3] = notify;
|
|
47
|
+
$[4] = pendingRef;
|
|
48
|
+
$[5] = value;
|
|
49
|
+
$[6] = widgetReadyRef;
|
|
50
|
+
$[7] = t1;
|
|
51
|
+
} else t1 = $[7];
|
|
52
|
+
let t2;
|
|
53
|
+
if ($[8] !== value) {
|
|
54
|
+
t2 = [value];
|
|
55
|
+
$[8] = value;
|
|
56
|
+
$[9] = t2;
|
|
57
|
+
} else t2 = $[9];
|
|
58
|
+
useEffect(t1, t2);
|
|
41
59
|
}
|
|
42
60
|
function buildLiveHandlers(initial, liveRef) {
|
|
43
61
|
const live = () => liveRef.current.handlers;
|
|
@@ -183,6 +201,7 @@ function McpAppFrame(t0) {
|
|
|
183
201
|
bridgeRef.current = bridge;
|
|
184
202
|
if (current.input !== void 0) pendingInputRef.current = current.input;
|
|
185
203
|
if (current.output !== void 0) pendingOutputRef.current = current.output;
|
|
204
|
+
lastSentHostContextRef.current = current.hostContext ?? {};
|
|
186
205
|
return {
|
|
187
206
|
onMessage: bridge.onMessage,
|
|
188
207
|
dispose: () => {
|
|
@@ -207,7 +226,7 @@ function McpAppFrame(t0) {
|
|
|
207
226
|
const createBridge = t5;
|
|
208
227
|
useBridgeNotify(input, bridgeRef, widgetReadyRef, pendingInputRef, lastSentInputRef, _temp);
|
|
209
228
|
useBridgeNotify(output, bridgeRef, widgetReadyRef, pendingOutputRef, lastSentOutputRef, _temp2);
|
|
210
|
-
useBridgeNotify(hostContext, bridgeRef, widgetReadyRef, pendingHostContextRef, lastSentHostContextRef, _temp3);
|
|
229
|
+
useBridgeNotify(hostContext, bridgeRef, widgetReadyRef, pendingHostContextRef, lastSentHostContextRef, _temp3, isSameHostContext);
|
|
211
230
|
let t6;
|
|
212
231
|
if ($[14] !== resource.html) {
|
|
213
232
|
t6 = { html: resource.html };
|