@agent-native/core 0.20.8 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/dist/action.d.ts +61 -0
  2. package/dist/action.d.ts.map +1 -1
  3. package/dist/action.js +14 -0
  4. package/dist/action.js.map +1 -1
  5. package/dist/agent/production-agent.d.ts +4 -0
  6. package/dist/agent/production-agent.d.ts.map +1 -1
  7. package/dist/agent/production-agent.js +19 -7
  8. package/dist/agent/production-agent.js.map +1 -1
  9. package/dist/agent/types.d.ts +2 -0
  10. package/dist/agent/types.d.ts.map +1 -1
  11. package/dist/agent/types.js.map +1 -1
  12. package/dist/cli/code-agent-executor.d.ts.map +1 -1
  13. package/dist/cli/code-agent-executor.js +1 -0
  14. package/dist/cli/code-agent-executor.js.map +1 -1
  15. package/dist/cli/connect.d.ts +26 -4
  16. package/dist/cli/connect.d.ts.map +1 -1
  17. package/dist/cli/connect.js +578 -10
  18. package/dist/cli/connect.js.map +1 -1
  19. package/dist/cli/templates-meta.d.ts.map +1 -1
  20. package/dist/cli/templates-meta.js +1 -0
  21. package/dist/cli/templates-meta.js.map +1 -1
  22. package/dist/client/AssistantChat.d.ts.map +1 -1
  23. package/dist/client/AssistantChat.js +6 -5
  24. package/dist/client/AssistantChat.js.map +1 -1
  25. package/dist/client/agent-chat-adapter.d.ts.map +1 -1
  26. package/dist/client/agent-chat-adapter.js +25 -4
  27. package/dist/client/agent-chat-adapter.js.map +1 -1
  28. package/dist/client/code-agent-chat-adapter.js +1 -0
  29. package/dist/client/code-agent-chat-adapter.js.map +1 -1
  30. package/dist/client/composer/TiptapComposer.js +1 -1
  31. package/dist/client/composer/TiptapComposer.js.map +1 -1
  32. package/dist/client/conversation/AgentConversation.d.ts.map +1 -1
  33. package/dist/client/conversation/AgentConversation.js +3 -2
  34. package/dist/client/conversation/AgentConversation.js.map +1 -1
  35. package/dist/client/conversation/code-agent-transcript.js +1 -0
  36. package/dist/client/conversation/code-agent-transcript.js.map +1 -1
  37. package/dist/client/conversation/types.d.ts +2 -0
  38. package/dist/client/conversation/types.d.ts.map +1 -1
  39. package/dist/client/conversation/types.js.map +1 -1
  40. package/dist/client/extensions/EmbeddedExtension.d.ts.map +1 -1
  41. package/dist/client/extensions/EmbeddedExtension.js +2 -1
  42. package/dist/client/extensions/EmbeddedExtension.js.map +1 -1
  43. package/dist/client/extensions/ExtensionEditor.d.ts.map +1 -1
  44. package/dist/client/extensions/ExtensionEditor.js +6 -3
  45. package/dist/client/extensions/ExtensionEditor.js.map +1 -1
  46. package/dist/client/extensions/ExtensionViewer.d.ts.map +1 -1
  47. package/dist/client/extensions/ExtensionViewer.js +66 -2
  48. package/dist/client/extensions/ExtensionViewer.js.map +1 -1
  49. package/dist/client/extensions/ExtensionsListPage.d.ts.map +1 -1
  50. package/dist/client/extensions/ExtensionsListPage.js +2 -1
  51. package/dist/client/extensions/ExtensionsListPage.js.map +1 -1
  52. package/dist/client/extensions/ExtensionsSidebarSection.d.ts.map +1 -1
  53. package/dist/client/extensions/ExtensionsSidebarSection.js +5 -7
  54. package/dist/client/extensions/ExtensionsSidebarSection.js.map +1 -1
  55. package/dist/client/extensions/index.d.ts +1 -0
  56. package/dist/client/extensions/index.d.ts.map +1 -1
  57. package/dist/client/extensions/index.js +1 -0
  58. package/dist/client/extensions/index.js.map +1 -1
  59. package/dist/client/index.d.ts +1 -0
  60. package/dist/client/index.d.ts.map +1 -1
  61. package/dist/client/index.js +1 -0
  62. package/dist/client/index.js.map +1 -1
  63. package/dist/client/mcp-apps/McpAppRenderer.d.ts +10 -0
  64. package/dist/client/mcp-apps/McpAppRenderer.d.ts.map +1 -0
  65. package/dist/client/mcp-apps/McpAppRenderer.js +296 -0
  66. package/dist/client/mcp-apps/McpAppRenderer.js.map +1 -0
  67. package/dist/client/sse-event-processor.d.ts +3 -0
  68. package/dist/client/sse-event-processor.d.ts.map +1 -1
  69. package/dist/client/sse-event-processor.js +2 -0
  70. package/dist/client/sse-event-processor.js.map +1 -1
  71. package/dist/code-agents/transcript-normalizer.d.ts +2 -0
  72. package/dist/code-agents/transcript-normalizer.d.ts.map +1 -1
  73. package/dist/code-agents/transcript-normalizer.js +17 -0
  74. package/dist/code-agents/transcript-normalizer.js.map +1 -1
  75. package/dist/db/client.d.ts +19 -0
  76. package/dist/db/client.d.ts.map +1 -1
  77. package/dist/db/client.js +139 -6
  78. package/dist/db/client.js.map +1 -1
  79. package/dist/extensions/actions.d.ts.map +1 -1
  80. package/dist/extensions/actions.js +6 -2
  81. package/dist/extensions/actions.js.map +1 -1
  82. package/dist/extensions/path.d.ts +6 -0
  83. package/dist/extensions/path.d.ts.map +1 -0
  84. package/dist/extensions/path.js +38 -0
  85. package/dist/extensions/path.js.map +1 -0
  86. package/dist/index.browser.d.ts +1 -1
  87. package/dist/index.browser.d.ts.map +1 -1
  88. package/dist/index.browser.js +1 -1
  89. package/dist/index.browser.js.map +1 -1
  90. package/dist/index.d.ts +1 -1
  91. package/dist/index.d.ts.map +1 -1
  92. package/dist/index.js +1 -1
  93. package/dist/index.js.map +1 -1
  94. package/dist/mcp/build-server.d.ts.map +1 -1
  95. package/dist/mcp/build-server.js +154 -4
  96. package/dist/mcp/build-server.js.map +1 -1
  97. package/dist/mcp/connect-store.d.ts +1 -1
  98. package/dist/mcp/connect-store.d.ts.map +1 -1
  99. package/dist/mcp/connect-store.js +1 -1
  100. package/dist/mcp/connect-store.js.map +1 -1
  101. package/dist/mcp/stdio.d.ts +2 -2
  102. package/dist/mcp/stdio.d.ts.map +1 -1
  103. package/dist/mcp/stdio.js +26 -8
  104. package/dist/mcp/stdio.js.map +1 -1
  105. package/dist/mcp-client/app-result.d.ts +40 -0
  106. package/dist/mcp-client/app-result.d.ts.map +1 -0
  107. package/dist/mcp-client/app-result.js +19 -0
  108. package/dist/mcp-client/app-result.js.map +1 -0
  109. package/dist/mcp-client/index.d.ts +5 -2
  110. package/dist/mcp-client/index.d.ts.map +1 -1
  111. package/dist/mcp-client/index.js +185 -23
  112. package/dist/mcp-client/index.js.map +1 -1
  113. package/dist/mcp-client/manager.d.ts +16 -0
  114. package/dist/mcp-client/manager.d.ts.map +1 -1
  115. package/dist/mcp-client/manager.js +58 -1
  116. package/dist/mcp-client/manager.js.map +1 -1
  117. package/dist/mcp-client/routes.d.ts +4 -1
  118. package/dist/mcp-client/routes.d.ts.map +1 -1
  119. package/dist/mcp-client/routes.js +146 -0
  120. package/dist/mcp-client/routes.js.map +1 -1
  121. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  122. package/dist/server/agent-chat-plugin.js +8 -1
  123. package/dist/server/agent-chat-plugin.js.map +1 -1
  124. package/dist/server/auth.d.ts +2 -0
  125. package/dist/server/auth.d.ts.map +1 -1
  126. package/dist/server/auth.js +2 -2
  127. package/dist/server/auth.js.map +1 -1
  128. package/dist/server/framework-request-handler.d.ts +4 -2
  129. package/dist/server/framework-request-handler.d.ts.map +1 -1
  130. package/dist/server/framework-request-handler.js +25 -11
  131. package/dist/server/framework-request-handler.js.map +1 -1
  132. package/dist/server/index.d.ts +1 -1
  133. package/dist/server/index.d.ts.map +1 -1
  134. package/dist/server/index.js +1 -1
  135. package/dist/server/index.js.map +1 -1
  136. package/dist/styles/agent-conversation.css +53 -0
  137. package/docs/content/actions.md +25 -2
  138. package/docs/content/external-agents.md +62 -8
  139. package/docs/content/key-concepts.md +1 -1
  140. package/docs/content/mcp-clients.md +1 -1
  141. package/docs/content/mcp-protocol.md +16 -11
  142. package/package.json +2 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAEtE,yBAAyB,EAAE,CAAC;AAE5B,OAAO,EACL,eAAe,EACf,aAAa,GAEd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,U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L,YAAY,EACZ,YAAY,EACZ,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,sBAAsB,EACtB,cAAc,GACf,MAAM,0BAA0B,CAAC;AAClC,yBAAyB;AACzB,OAAO,EACL,WAAW,GAEZ,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,iBAAiB,GAElB,MAAM,mCAAmC,CAAC;AAC3C,sCAAsC;AACtC,OAAO,EACL,mBAAmB,EACnB,qBAAqB,GAKtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["import { installRouteChunkRecovery } from \"./route-chunk-recovery.js\";\n\ninstallRouteChunkRecovery();\n\nexport {\n sendToAgentChat,\n generateTabId,\n type AgentChatMessage,\n} from \"./agent-chat.js\";\nexport { useAgentChatGenerating } from \"./use-agent-chat.js\";\nexport { useDevMode } from \"./use-dev-mode.js\";\nexport {\n agentNativePath,\n appApiPath,\n appBasePath,\n appPath,\n} from \"./api-path.js\";\nexport {\n codeAgentTranscriptEventsToContent,\n createCodeAgentChatAdapter,\n type CodeAgentChatController,\n type CodeAgentChatControlResult,\n type CodeAgentChatFollowUpMode,\n type CodeAgentChatTranscriptEvent,\n type CreateCodeAgentChatAdapterOptions,\n} from \"./code-agent-chat-adapter.js\";\nexport {\n buildRepositoryFromCodeAgentTranscript,\n type BuildRepositoryFromCodeAgentTranscriptOptions,\n type CodeAgentThreadTranscriptEvent,\n} from \"../agent/thread-data-builder.js\";\nexport {\n compareCodeAgentTranscriptEvents,\n getCodeAgentTranscriptSeq,\n isCodeAgentRunActive,\n mergeCodeAgentTranscriptEvents,\n type CodeAgentRunStateLike,\n type CodeAgentTranscriptOrderEvent,\n} from \"../code-agents/transcript-order.js\";\nexport { useSendToAgentChat } from \"./use-send-to-agent-chat.js\";\nexport {\n useChatModels,\n type UseChatModelsResult,\n type EngineModelGroup,\n} from \"./use-chat-models.js\";\nexport {\n CodeRequiredDialog,\n type CodeRequiredDialogProps,\n} from \"./components/CodeRequiredDialog.js\";\nexport {\n AgentConversation,\n AgentConversationMessageView,\n normalizeCodeAgentTranscriptForConversation,\n useNearBottomAutoscroll,\n type CodeAgentConversationTranscriptEvent,\n type CodeAgentConversationTranscriptEventType,\n type NormalizeCodeAgentTranscriptOptions,\n type AgentConversationArtifact,\n type AgentConversationAttachment,\n type AgentConversationMessage,\n type AgentConversationMessagePart,\n type AgentConversationMessageRole,\n type AgentConversationNotice,\n type AgentConversationNoticeTone,\n type AgentConversationToolCall,\n type AgentConversationToolState,\n} from \"./conversation/index.js\";\nexport {\n CodeAgentIndicator,\n type CodeAgentIndicatorProps,\n} from \"./components/CodeAgentIndicator.js\";\nexport {\n useDbSync,\n useFileWatcher,\n useScreenRefreshKey,\n} from \"./use-db-sync.js\";\nexport {\n useChangeVersion,\n useChangeVersions,\n getChangeVersion,\n bumpChangeVersion,\n} from \"./use-change-version.js\";\nexport {\n buildDynamicAgentSuggestions,\n dedupeSuggestions,\n mergeAgentSuggestions,\n normalizeAgentDynamicSuggestionsConfig,\n useAgentDynamicSuggestions,\n type AgentDynamicSuggestionContext,\n type AgentDynamicSuggestionsConfig,\n type AgentDynamicSuggestionsOption,\n} from \"./dynamic-suggestions.js\";\nexport { cn } from \"./utils.js\";\nexport { ApiKeySettings } from \"./components/ApiKeySettings.js\";\nexport { useSession, type AuthSession } from \"./use-session.js\";\nexport {\n sendToFrame,\n onFrameMessage,\n requestUserInfo,\n getFrameOrigin,\n getCallbackOrigin,\n oauthRedirectUri,\n isInFrame,\n enterStyleEditing,\n enterTextEditing,\n exitSelectionMode,\n type UserInfo,\n} from \"./frame.js\";\nexport {\n getBuilderParentOrigin,\n isInBuilderFrame,\n sendToBuilderChat,\n type BuilderChatMessage,\n} from \"./builder-frame.js\";\nexport {\n AgentNative,\n useAgentNativeScreenContext,\n type AgentNativeCommandCallback,\n type AgentNativeCommandCallbackInfo,\n type AgentNativeProps,\n} from \"./AgentNative.js\";\nexport {\n AgentNativeEmbedded,\n useAgentNativeEmbeddedBrowserSession,\n type AgentNativeEmbeddedBrowserSessionOptions,\n type AgentNativeEmbeddedCommandCallback,\n type AgentNativeEmbeddedCommandCallbackInfo,\n type AgentNativeEmbeddedProps,\n type UseAgentNativeEmbeddedBrowserSessionOptions,\n} from \"./AgentNativeEmbedded.js\";\nexport {\n defineClientAction,\n type AgentNativeClientActionDefinition,\n type AgentNativeClientActionRunner,\n} from \"./client-action.js\";\nexport {\n AgentNativeFrame,\n type AgentNativeFrameProps,\n} from \"./AgentNativeFrame.js\";\nexport {\n AgentNativeExtensionFrame,\n AgentNativeExtensionSlot,\n type AgentNativeExtensionFrameProps,\n type AgentNativeExtensionPermissionList,\n type AgentNativeExtensionSlotProps,\n type AgentNativeExtensionStorageScopeList,\n} from \"./extensions/AgentNativeExtensionFrame.js\";\nexport {\n AGENT_NATIVE_EXTENSION_MESSAGE_TYPES,\n buildAgentNativeExtensionHtml,\n createHttpAgentNativeExtensionStorage,\n createLocalStorageAgentNativeExtensionStorage,\n getAgentNativeExtensionManifest,\n isAgentNativeExtensionAllowedInSlot,\n normalizeAgentNativeExtensionSandbox,\n type AgentNativeExtensionDefinition,\n type AgentNativeExtensionManifest,\n type AgentNativeExtensionMessageType,\n type AgentNativeExtensionStorage,\n type AgentNativeExtensionStorageContext,\n type AgentNativeExtensionStorageOptions,\n type AgentNativeExtensionStorageRow,\n type AgentNativeExtensionStorageScope,\n type BuildAgentNativeExtensionHtmlOptions,\n type CreateHttpAgentNativeExtensionStorageOptions,\n} from \"./extensions/portable-extension.js\";\nexport {\n AGENT_NATIVE_HOST_BRIDGE_VERSION,\n AGENT_NATIVE_HOST_MESSAGE_TYPES,\n announceAgentNativeFrameReady,\n createAgentNativeHostBridge,\n defaultAgentNativeHostCommands,\n onAgentNativeHostInit,\n readAgentNativeScreenContext,\n requestAgentNativeHostActions,\n requestAgentNativeHostContext,\n runAgentNativeHostAction,\n sendAgentNativeHostCommand,\n type AgentNativeActionAvailability,\n type AgentNativeActionManifestEntry,\n type AgentNativeClientAction,\n type AgentNativeClientActionApprovalConfig,\n type AgentNativeClientActionGetter,\n type AgentNativeClientActionRuntime,\n type AgentNativeClientActions,\n type AgentNativeHostAuth,\n type AgentNativeHostAuthPayload,\n type AgentNativeHostBridge,\n type AgentNativeHostBridgeEvent,\n type AgentNativeHostBridgeOptions,\n type AgentNativeHostCapabilities,\n type AgentNativeHostCommandHandler,\n type AgentNativeHostCommandHandlers,\n type AgentNativeHostCommandRequest,\n type AgentNativeHostContext,\n type AgentNativeHostContextGetter,\n type AgentNativeHostInit,\n type AgentNativeHostMessageType,\n type AgentNativeHostRequestOptions,\n type AgentNativeHostResourceContext,\n type AgentNativeHostRouteContext,\n type AgentNativeHostSelectionContext,\n type AgentNativeHostSession,\n type AgentNativeJsonSchema,\n type AgentNativeScreenSnapshot,\n type AgentNativeScreenSnapshotOptions,\n type BuiltInAgentNativeHostCommand,\n} from \"./host-bridge.js\";\nexport {\n AGENT_NATIVE_HOST_TOOL_NAMES,\n createAgentNativeHostTools,\n type AgentNativeHostToolDefinition,\n type AgentNativeHostToolName,\n type AgentNativeHostToolParameters,\n type AgentNativeHostToolSet,\n type CreateAgentNativeHostToolsOptions,\n type RunAgentNativeHostActionToolInput,\n type SendAgentNativeHostCommandToolInput,\n} from \"./host-tools.js\";\nexport {\n createAgentNativeBrowserSessionBridge,\n startAgentNativeBrowserSessionBridge,\n type AgentNativeBrowserSessionBridge,\n type AgentNativeBrowserSessionBridgeOptions,\n} from \"./browser-session-bridge.js\";\nexport type {\n AgentNativeBrowserSession,\n AgentNativeBrowserSessionAction,\n AgentNativeBrowserSessionRecord,\n AgentNativeBrowserSessionRequest,\n AgentNativeBrowserSessionRequestStatus,\n AgentNativeBrowserSessionRequestType,\n CreateAgentNativeBrowserSessionRequestInput,\n RegisterAgentNativeBrowserSessionInput,\n} from \"../browser-sessions/types.js\";\nexport {\n NewWorkspaceAppFlow,\n type NewWorkspaceAppFlowProps,\n type VaultSecretOption,\n} from \"./NewWorkspaceAppFlow.js\";\nexport {\n AssistantChat,\n clearChatStorage,\n type AssistantChatProps,\n type AssistantChatHandle,\n} from \"./AssistantChat.js\";\nexport {\n MultiTabAssistantChat,\n type MultiTabAssistantChatProps,\n type MultiTabAssistantChatHeaderProps,\n} from \"./MultiTabAssistantChat.js\";\nexport { RunStuckBanner, type RunStuckBannerProps } from \"./RunStuckBanner.js\";\nexport {\n useRunStuckDetection,\n useAbortRun,\n type RunStuckState,\n type UseRunStuckDetectionOptions,\n} from \"./use-run-stuck-detection.js\";\nexport { createAgentChatAdapter } from \"./agent-chat-adapter.js\";\nexport {\n AgentComposerFrame,\n type AgentComposerFrameProps,\n PromptComposer,\n AGENT_PROMPT_MAX_INLINE_IMAGE_BYTES,\n AGENT_PROMPT_MAX_INLINE_TEXT_CHARS,\n escapePromptAttachmentAttribute,\n formatPromptWithAttachments,\n isInlineableAgentPromptFile,\n readAgentPromptAttachment,\n type PromptComposerProps,\n type PromptComposerFile,\n type PromptComposerSubmitOptions,\n type AgentPromptAttachment,\n type ReadAgentPromptAttachmentOptions,\n type AgentComposerLayoutVariant,\n type SlashCommand,\n type SkillResult,\n} from \"./composer/index.js\";\nexport type { TiptapComposerHandle } from \"./composer/TiptapComposer.js\";\nexport {\n GuidedQuestionFlow,\n useGuidedQuestionFlow,\n formatGuidedAnswerValue,\n formatGuidedAnswersForAgent,\n getOtherGuidedAnswerText,\n hasGuidedAnswer,\n isOtherGuidedAnswer,\n makeOtherGuidedAnswer,\n normalizeGuidedAnswers,\n type GuidedQuestion,\n type GuidedQuestionAnswers,\n type GuidedQuestionFlowProps,\n type GuidedQuestionOption,\n type GuidedQuestionPayload,\n type GuidedQuestionType,\n type UseGuidedQuestionFlowOptions,\n} from \"./guided-questions.js\";\nexport {\n useChatThreads,\n type ChatThreadScope,\n type ChatThreadSummary,\n type ChatThreadData,\n} from \"./use-chat-threads.js\";\nexport {\n AgentChatSurface,\n AgentPanel,\n AgentSidebar,\n AgentToggleButton,\n focusAgentChat,\n type AgentChatSurfaceMode,\n type AgentChatSurfaceProps,\n type AgentPanelProps,\n type AgentSidebarProps,\n} from \"./AgentPanel.js\";\nexport {\n SIDEBAR_STATE_CHANGE_EVENT,\n type AgentSidebarStateChangeDetail,\n type AgentSidebarStateMode,\n type AgentSidebarStateSource,\n} from \"./agent-sidebar-state.js\";\nexport { AgentNativeIcon } from \"./components/icons/AgentNativeIcon.js\";\nexport { SettingsPanel, type SettingsPanelProps } from \"./settings/index.js\";\nexport { useBuilderStatus } from \"./settings/useBuilderStatus.js\";\nexport {\n openBuilderConnectPopup,\n useBuilderConnectFlow,\n type BuilderConnectFlow,\n type BuilderConnectFlowOptions,\n type OpenBuilderConnectPopupOptions,\n} from \"./settings/useBuilderStatus.js\";\n// Deprecated — use AgentSidebar + AgentToggleButton instead\nexport {\n ProductionAgentPanel,\n type ProductionAgentPanelProps,\n} from \"./ProductionAgentPanel.js\";\nexport {\n useProductionAgent,\n type ProductionAgentMessage,\n type UseProductionAgentOptions,\n type UseProductionAgentResult,\n} from \"./useProductionAgent.js\";\nexport { Turnstile, type TurnstileProps } from \"./Turnstile.js\";\nexport {\n OpenSourceBadge,\n PoweredByBadge,\n type OpenSourceBadgeProps,\n type PoweredByBadgeProps,\n} from \"./PoweredByBadge.js\";\nexport { FeedbackButton, type FeedbackButtonProps } from \"./FeedbackButton.js\";\nexport { ErrorBoundary } from \"./ErrorBoundary.js\";\nexport { installRouteChunkRecovery } from \"./route-chunk-recovery.js\";\nexport { ClientOnly } from \"./ClientOnly.js\";\nexport { DefaultSpinner } from \"./DefaultSpinner.js\";\nexport {\n getThemeInitScript,\n themeInitScript,\n type ThemePreference,\n} from \"./theme.js\";\nexport {\n APPEARANCE_PRESETS,\n applyAppearance,\n getStoredAppearance,\n useAppearance,\n useAppearanceSync,\n type AppearancePresetId,\n} from \"./appearance.js\";\nexport {\n AppearancePicker,\n type AppearancePickerProps,\n} from \"./AppearancePicker.js\";\nexport { AgentTerminal, type AgentTerminalProps } from \"./terminal/index.js\";\nexport {\n trackEvent,\n trackSessionStatus,\n configureTracking,\n setSentryUser,\n captureError,\n captureClientException,\n type ClientCaptureContext,\n} from \"./analytics.js\";\nexport {\n useCollaborativeDoc,\n emailToColor,\n emailToName,\n type UseCollaborativeDocOptions,\n type UseCollaborativeDocResult,\n type CollabUser,\n} from \"../collab/client.js\";\nexport {\n ResourcesPanel,\n ResourceTree,\n ResourceEditor,\n useResources,\n useResourceTree,\n useResource,\n useCreateResource,\n useUpdateResource,\n useDeleteResource,\n useUploadResource,\n type Resource,\n type ResourceMeta,\n type TreeNode,\n type ResourceScope,\n type ResourceTreeProps,\n type ResourceEditorProps,\n} from \"./resources/index.js\";\nexport type {\n AppToFrameMessage,\n FrameToAppMessage,\n FrameMessage,\n CodeCompleteMessage,\n ChatRunningMessage,\n} from \"./frame-protocol.js\";\nexport {\n CommandMenu,\n useCommandMenuShortcut,\n openAgentSidebar,\n submitToAgent,\n type CommandMenuProps,\n type CommandGroupProps,\n type CommandItemProps,\n type CommandShortcutProps,\n} from \"./CommandMenu.js\";\nexport {\n DevOverlay,\n useDevOverlayShortcut,\n registerDevPanel,\n unregisterDevPanel,\n listDevPanels,\n subscribeDevPanels,\n useDevOption,\n clearAllDevOverlayStorage,\n devOptionKey,\n DEV_OVERLAY_STORAGE_PREFIX,\n type DevOverlayProps,\n type DevPanel,\n type DevOption,\n type DevBooleanOption,\n type DevSelectOption,\n type DevStringOption,\n type DevActionOption,\n type DevOptionValue,\n} from \"./dev-overlay/index.js\";\nexport {\n useActionQuery,\n useActionMutation,\n type ActionRegistry,\n} from \"./use-action.js\";\nexport { usePinchZoom, type UsePinchZoomOptions } from \"./use-pinch-zoom.js\";\nexport {\n ShareButton,\n ShareDialog,\n VisibilityBadge,\n type ShareButtonProps,\n type ShareDialogProps,\n type VisibilityBadgeProps,\n} from \"./sharing/index.js\";\nexport {\n postNavigate,\n isInAgentEmbed,\n AGENT_NAVIGATE_MESSAGE_TYPE,\n type AgentNavigateMessage,\n} from \"./embed.js\";\nexport { IframeEmbed, parseEmbedBody } from \"./IframeEmbed.js\";\nexport {\n useAvatarUrl,\n uploadAvatar,\n invalidateAvatarCache,\n} from \"./use-avatar.js\";\nexport {\n ObservabilityDashboard,\n ThumbsFeedback,\n} from \"./observability/index.js\";\n// Presence UI components\nexport {\n PresenceBar,\n type PresenceBarProps,\n} from \"./components/PresenceBar.js\";\nexport {\n AgentPresenceChip,\n type AgentPresenceChipProps,\n} from \"./components/AgentPresenceChip.js\";\n// Structured data collaboration hooks\nexport {\n useCollaborativeMap,\n useCollaborativeArray,\n type UseCollaborativeMapOptions,\n type UseCollaborativeMapResult,\n type UseCollaborativeArrayOptions,\n type UseCollaborativeArrayResult,\n} from \"../collab/client-struct.js\";\nexport { NotificationsBell } from \"./notifications/index.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAEtE,yBAAyB,EAAE,CAAC;AAE5B,OAAO,EACL,eAAe,EACf,aAAa,GAEd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EACL,eAAe,EACf,UAAU,EACV,WAAW,EACX,OAAO,GACR,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,kCAAkC,EAClC,0BAA0B,GAM3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,sCAAsC,GAGvC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,gCAAgC,EAChC,yBAAyB,EACzB,oBAAoB,EACpB,8BAA8B,GAG/B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EACL,aAAa,GAGd,MAAM,sBAAsB,CA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","sourcesContent":["import { installRouteChunkRecovery } from \"./route-chunk-recovery.js\";\n\ninstallRouteChunkRecovery();\n\nexport {\n sendToAgentChat,\n generateTabId,\n type AgentChatMessage,\n} from \"./agent-chat.js\";\nexport { useAgentChatGenerating } from \"./use-agent-chat.js\";\nexport { useDevMode } from \"./use-dev-mode.js\";\nexport {\n agentNativePath,\n appApiPath,\n appBasePath,\n appPath,\n} from \"./api-path.js\";\nexport {\n codeAgentTranscriptEventsToContent,\n createCodeAgentChatAdapter,\n type CodeAgentChatController,\n type CodeAgentChatControlResult,\n type CodeAgentChatFollowUpMode,\n type CodeAgentChatTranscriptEvent,\n type CreateCodeAgentChatAdapterOptions,\n} from \"./code-agent-chat-adapter.js\";\nexport {\n buildRepositoryFromCodeAgentTranscript,\n type BuildRepositoryFromCodeAgentTranscriptOptions,\n type CodeAgentThreadTranscriptEvent,\n} from \"../agent/thread-data-builder.js\";\nexport {\n compareCodeAgentTranscriptEvents,\n getCodeAgentTranscriptSeq,\n isCodeAgentRunActive,\n mergeCodeAgentTranscriptEvents,\n type CodeAgentRunStateLike,\n type CodeAgentTranscriptOrderEvent,\n} from \"../code-agents/transcript-order.js\";\nexport { useSendToAgentChat } from \"./use-send-to-agent-chat.js\";\nexport {\n useChatModels,\n type UseChatModelsResult,\n type EngineModelGroup,\n} from \"./use-chat-models.js\";\nexport {\n CodeRequiredDialog,\n type CodeRequiredDialogProps,\n} from \"./components/CodeRequiredDialog.js\";\nexport {\n AgentConversation,\n AgentConversationMessageView,\n normalizeCodeAgentTranscriptForConversation,\n useNearBottomAutoscroll,\n type CodeAgentConversationTranscriptEvent,\n type CodeAgentConversationTranscriptEventType,\n type NormalizeCodeAgentTranscriptOptions,\n type AgentConversationArtifact,\n type AgentConversationAttachment,\n type AgentConversationMessage,\n type AgentConversationMessagePart,\n type AgentConversationMessageRole,\n type AgentConversationNotice,\n type AgentConversationNoticeTone,\n type AgentConversationToolCall,\n type AgentConversationToolState,\n} from \"./conversation/index.js\";\nexport { McpAppRenderer } from \"./mcp-apps/McpAppRenderer.js\";\nexport {\n CodeAgentIndicator,\n type CodeAgentIndicatorProps,\n} from \"./components/CodeAgentIndicator.js\";\nexport {\n useDbSync,\n useFileWatcher,\n useScreenRefreshKey,\n} from \"./use-db-sync.js\";\nexport {\n useChangeVersion,\n useChangeVersions,\n getChangeVersion,\n bumpChangeVersion,\n} from \"./use-change-version.js\";\nexport {\n buildDynamicAgentSuggestions,\n dedupeSuggestions,\n mergeAgentSuggestions,\n normalizeAgentDynamicSuggestionsConfig,\n useAgentDynamicSuggestions,\n type AgentDynamicSuggestionContext,\n type AgentDynamicSuggestionsConfig,\n type AgentDynamicSuggestionsOption,\n} from \"./dynamic-suggestions.js\";\nexport { cn } from \"./utils.js\";\nexport { ApiKeySettings } from \"./components/ApiKeySettings.js\";\nexport { useSession, type AuthSession } from \"./use-session.js\";\nexport {\n sendToFrame,\n onFrameMessage,\n requestUserInfo,\n getFrameOrigin,\n getCallbackOrigin,\n oauthRedirectUri,\n isInFrame,\n enterStyleEditing,\n enterTextEditing,\n exitSelectionMode,\n type UserInfo,\n} from \"./frame.js\";\nexport {\n getBuilderParentOrigin,\n isInBuilderFrame,\n sendToBuilderChat,\n type BuilderChatMessage,\n} from \"./builder-frame.js\";\nexport {\n AgentNative,\n useAgentNativeScreenContext,\n type AgentNativeCommandCallback,\n type AgentNativeCommandCallbackInfo,\n type AgentNativeProps,\n} from \"./AgentNative.js\";\nexport {\n AgentNativeEmbedded,\n useAgentNativeEmbeddedBrowserSession,\n type AgentNativeEmbeddedBrowserSessionOptions,\n type AgentNativeEmbeddedCommandCallback,\n type AgentNativeEmbeddedCommandCallbackInfo,\n type AgentNativeEmbeddedProps,\n type UseAgentNativeEmbeddedBrowserSessionOptions,\n} from \"./AgentNativeEmbedded.js\";\nexport {\n defineClientAction,\n type AgentNativeClientActionDefinition,\n type AgentNativeClientActionRunner,\n} from \"./client-action.js\";\nexport {\n AgentNativeFrame,\n type AgentNativeFrameProps,\n} from \"./AgentNativeFrame.js\";\nexport {\n AgentNativeExtensionFrame,\n AgentNativeExtensionSlot,\n type AgentNativeExtensionFrameProps,\n type AgentNativeExtensionPermissionList,\n type AgentNativeExtensionSlotProps,\n type AgentNativeExtensionStorageScopeList,\n} from \"./extensions/AgentNativeExtensionFrame.js\";\nexport {\n AGENT_NATIVE_EXTENSION_MESSAGE_TYPES,\n buildAgentNativeExtensionHtml,\n createHttpAgentNativeExtensionStorage,\n createLocalStorageAgentNativeExtensionStorage,\n getAgentNativeExtensionManifest,\n isAgentNativeExtensionAllowedInSlot,\n normalizeAgentNativeExtensionSandbox,\n type AgentNativeExtensionDefinition,\n type AgentNativeExtensionManifest,\n type AgentNativeExtensionMessageType,\n type AgentNativeExtensionStorage,\n type AgentNativeExtensionStorageContext,\n type AgentNativeExtensionStorageOptions,\n type AgentNativeExtensionStorageRow,\n type AgentNativeExtensionStorageScope,\n type BuildAgentNativeExtensionHtmlOptions,\n type CreateHttpAgentNativeExtensionStorageOptions,\n} from \"./extensions/portable-extension.js\";\nexport {\n AGENT_NATIVE_HOST_BRIDGE_VERSION,\n AGENT_NATIVE_HOST_MESSAGE_TYPES,\n announceAgentNativeFrameReady,\n createAgentNativeHostBridge,\n defaultAgentNativeHostCommands,\n onAgentNativeHostInit,\n readAgentNativeScreenContext,\n requestAgentNativeHostActions,\n requestAgentNativeHostContext,\n runAgentNativeHostAction,\n sendAgentNativeHostCommand,\n type AgentNativeActionAvailability,\n type AgentNativeActionManifestEntry,\n type AgentNativeClientAction,\n type AgentNativeClientActionApprovalConfig,\n type AgentNativeClientActionGetter,\n type AgentNativeClientActionRuntime,\n type AgentNativeClientActions,\n type AgentNativeHostAuth,\n type AgentNativeHostAuthPayload,\n type AgentNativeHostBridge,\n type AgentNativeHostBridgeEvent,\n type AgentNativeHostBridgeOptions,\n type AgentNativeHostCapabilities,\n type AgentNativeHostCommandHandler,\n type AgentNativeHostCommandHandlers,\n type AgentNativeHostCommandRequest,\n type AgentNativeHostContext,\n type AgentNativeHostContextGetter,\n type AgentNativeHostInit,\n type AgentNativeHostMessageType,\n type AgentNativeHostRequestOptions,\n type AgentNativeHostResourceContext,\n type AgentNativeHostRouteContext,\n type AgentNativeHostSelectionContext,\n type AgentNativeHostSession,\n type AgentNativeJsonSchema,\n type AgentNativeScreenSnapshot,\n type AgentNativeScreenSnapshotOptions,\n type BuiltInAgentNativeHostCommand,\n} from \"./host-bridge.js\";\nexport {\n AGENT_NATIVE_HOST_TOOL_NAMES,\n createAgentNativeHostTools,\n type AgentNativeHostToolDefinition,\n type AgentNativeHostToolName,\n type AgentNativeHostToolParameters,\n type AgentNativeHostToolSet,\n type CreateAgentNativeHostToolsOptions,\n type RunAgentNativeHostActionToolInput,\n type SendAgentNativeHostCommandToolInput,\n} from \"./host-tools.js\";\nexport {\n createAgentNativeBrowserSessionBridge,\n startAgentNativeBrowserSessionBridge,\n type AgentNativeBrowserSessionBridge,\n type AgentNativeBrowserSessionBridgeOptions,\n} from \"./browser-session-bridge.js\";\nexport type {\n AgentNativeBrowserSession,\n AgentNativeBrowserSessionAction,\n AgentNativeBrowserSessionRecord,\n AgentNativeBrowserSessionRequest,\n AgentNativeBrowserSessionRequestStatus,\n AgentNativeBrowserSessionRequestType,\n CreateAgentNativeBrowserSessionRequestInput,\n RegisterAgentNativeBrowserSessionInput,\n} from \"../browser-sessions/types.js\";\nexport {\n NewWorkspaceAppFlow,\n type NewWorkspaceAppFlowProps,\n type VaultSecretOption,\n} from \"./NewWorkspaceAppFlow.js\";\nexport {\n AssistantChat,\n clearChatStorage,\n type AssistantChatProps,\n type AssistantChatHandle,\n} from \"./AssistantChat.js\";\nexport {\n MultiTabAssistantChat,\n type MultiTabAssistantChatProps,\n type MultiTabAssistantChatHeaderProps,\n} from \"./MultiTabAssistantChat.js\";\nexport { RunStuckBanner, type RunStuckBannerProps } from \"./RunStuckBanner.js\";\nexport {\n useRunStuckDetection,\n useAbortRun,\n type RunStuckState,\n type UseRunStuckDetectionOptions,\n} from \"./use-run-stuck-detection.js\";\nexport { createAgentChatAdapter } from \"./agent-chat-adapter.js\";\nexport {\n AgentComposerFrame,\n type AgentComposerFrameProps,\n PromptComposer,\n AGENT_PROMPT_MAX_INLINE_IMAGE_BYTES,\n AGENT_PROMPT_MAX_INLINE_TEXT_CHARS,\n escapePromptAttachmentAttribute,\n formatPromptWithAttachments,\n isInlineableAgentPromptFile,\n readAgentPromptAttachment,\n type PromptComposerProps,\n type PromptComposerFile,\n type PromptComposerSubmitOptions,\n type AgentPromptAttachment,\n type ReadAgentPromptAttachmentOptions,\n type AgentComposerLayoutVariant,\n type SlashCommand,\n type SkillResult,\n} from \"./composer/index.js\";\nexport type { TiptapComposerHandle } from \"./composer/TiptapComposer.js\";\nexport {\n GuidedQuestionFlow,\n useGuidedQuestionFlow,\n formatGuidedAnswerValue,\n formatGuidedAnswersForAgent,\n getOtherGuidedAnswerText,\n hasGuidedAnswer,\n isOtherGuidedAnswer,\n makeOtherGuidedAnswer,\n normalizeGuidedAnswers,\n type GuidedQuestion,\n type GuidedQuestionAnswers,\n type GuidedQuestionFlowProps,\n type GuidedQuestionOption,\n type GuidedQuestionPayload,\n type GuidedQuestionType,\n type UseGuidedQuestionFlowOptions,\n} from \"./guided-questions.js\";\nexport {\n useChatThreads,\n type ChatThreadScope,\n type ChatThreadSummary,\n type ChatThreadData,\n} from \"./use-chat-threads.js\";\nexport {\n AgentChatSurface,\n AgentPanel,\n AgentSidebar,\n AgentToggleButton,\n focusAgentChat,\n type AgentChatSurfaceMode,\n type AgentChatSurfaceProps,\n type AgentPanelProps,\n type AgentSidebarProps,\n} from \"./AgentPanel.js\";\nexport {\n SIDEBAR_STATE_CHANGE_EVENT,\n type AgentSidebarStateChangeDetail,\n type AgentSidebarStateMode,\n type AgentSidebarStateSource,\n} from \"./agent-sidebar-state.js\";\nexport { AgentNativeIcon } from \"./components/icons/AgentNativeIcon.js\";\nexport { SettingsPanel, type SettingsPanelProps } from \"./settings/index.js\";\nexport { useBuilderStatus } from \"./settings/useBuilderStatus.js\";\nexport {\n openBuilderConnectPopup,\n useBuilderConnectFlow,\n type BuilderConnectFlow,\n type BuilderConnectFlowOptions,\n type OpenBuilderConnectPopupOptions,\n} from \"./settings/useBuilderStatus.js\";\n// Deprecated — use AgentSidebar + AgentToggleButton instead\nexport {\n ProductionAgentPanel,\n type ProductionAgentPanelProps,\n} from \"./ProductionAgentPanel.js\";\nexport {\n useProductionAgent,\n type ProductionAgentMessage,\n type UseProductionAgentOptions,\n type UseProductionAgentResult,\n} from \"./useProductionAgent.js\";\nexport { Turnstile, type TurnstileProps } from \"./Turnstile.js\";\nexport {\n OpenSourceBadge,\n PoweredByBadge,\n type OpenSourceBadgeProps,\n type PoweredByBadgeProps,\n} from \"./PoweredByBadge.js\";\nexport { FeedbackButton, type FeedbackButtonProps } from \"./FeedbackButton.js\";\nexport { ErrorBoundary } from \"./ErrorBoundary.js\";\nexport { installRouteChunkRecovery } from \"./route-chunk-recovery.js\";\nexport { ClientOnly } from \"./ClientOnly.js\";\nexport { DefaultSpinner } from \"./DefaultSpinner.js\";\nexport {\n getThemeInitScript,\n themeInitScript,\n type ThemePreference,\n} from \"./theme.js\";\nexport {\n APPEARANCE_PRESETS,\n applyAppearance,\n getStoredAppearance,\n useAppearance,\n useAppearanceSync,\n type AppearancePresetId,\n} from \"./appearance.js\";\nexport {\n AppearancePicker,\n type AppearancePickerProps,\n} from \"./AppearancePicker.js\";\nexport { AgentTerminal, type AgentTerminalProps } from \"./terminal/index.js\";\nexport {\n trackEvent,\n trackSessionStatus,\n configureTracking,\n setSentryUser,\n captureError,\n captureClientException,\n type ClientCaptureContext,\n} from \"./analytics.js\";\nexport {\n useCollaborativeDoc,\n emailToColor,\n emailToName,\n type UseCollaborativeDocOptions,\n type UseCollaborativeDocResult,\n type CollabUser,\n} from \"../collab/client.js\";\nexport {\n ResourcesPanel,\n ResourceTree,\n ResourceEditor,\n useResources,\n useResourceTree,\n useResource,\n useCreateResource,\n useUpdateResource,\n useDeleteResource,\n useUploadResource,\n type Resource,\n type ResourceMeta,\n type TreeNode,\n type ResourceScope,\n type ResourceTreeProps,\n type ResourceEditorProps,\n} from \"./resources/index.js\";\nexport type {\n AppToFrameMessage,\n FrameToAppMessage,\n FrameMessage,\n CodeCompleteMessage,\n ChatRunningMessage,\n} from \"./frame-protocol.js\";\nexport {\n CommandMenu,\n useCommandMenuShortcut,\n openAgentSidebar,\n submitToAgent,\n type CommandMenuProps,\n type CommandGroupProps,\n type CommandItemProps,\n type CommandShortcutProps,\n} from \"./CommandMenu.js\";\nexport {\n DevOverlay,\n useDevOverlayShortcut,\n registerDevPanel,\n unregisterDevPanel,\n listDevPanels,\n subscribeDevPanels,\n useDevOption,\n clearAllDevOverlayStorage,\n devOptionKey,\n DEV_OVERLAY_STORAGE_PREFIX,\n type DevOverlayProps,\n type DevPanel,\n type DevOption,\n type DevBooleanOption,\n type DevSelectOption,\n type DevStringOption,\n type DevActionOption,\n type DevOptionValue,\n} from \"./dev-overlay/index.js\";\nexport {\n useActionQuery,\n useActionMutation,\n type ActionRegistry,\n} from \"./use-action.js\";\nexport { usePinchZoom, type UsePinchZoomOptions } from \"./use-pinch-zoom.js\";\nexport {\n ShareButton,\n ShareDialog,\n VisibilityBadge,\n type ShareButtonProps,\n type ShareDialogProps,\n type VisibilityBadgeProps,\n} from \"./sharing/index.js\";\nexport {\n postNavigate,\n isInAgentEmbed,\n AGENT_NAVIGATE_MESSAGE_TYPE,\n type AgentNavigateMessage,\n} from \"./embed.js\";\nexport { IframeEmbed, parseEmbedBody } from \"./IframeEmbed.js\";\nexport {\n useAvatarUrl,\n uploadAvatar,\n invalidateAvatarCache,\n} from \"./use-avatar.js\";\nexport {\n ObservabilityDashboard,\n ThumbsFeedback,\n} from \"./observability/index.js\";\n// Presence UI components\nexport {\n PresenceBar,\n type PresenceBarProps,\n} from \"./components/PresenceBar.js\";\nexport {\n AgentPresenceChip,\n type AgentPresenceChipProps,\n} from \"./components/AgentPresenceChip.js\";\n// Structured data collaboration hooks\nexport {\n useCollaborativeMap,\n useCollaborativeArray,\n type UseCollaborativeMapOptions,\n type UseCollaborativeMapResult,\n type UseCollaborativeArrayOptions,\n type UseCollaborativeArrayResult,\n} from \"../collab/client-struct.js\";\nexport { NotificationsBell } from \"./notifications/index.js\";\n"]}
@@ -0,0 +1,10 @@
1
+ import { type McpUiResourceCsp, type McpUiResourcePermissions } from "@modelcontextprotocol/ext-apps/app-bridge";
2
+ import type { AgentMcpAppPayload } from "../../mcp-client/app-result.js";
3
+ export interface McpAppRendererProps {
4
+ app: AgentMcpAppPayload;
5
+ className?: string;
6
+ }
7
+ export declare function McpAppRenderer({ app, className }: McpAppRendererProps): import("react/jsx-runtime").JSX.Element;
8
+ export declare function supportedMcpAppPermissions(permissions: McpUiResourcePermissions | undefined): McpUiResourcePermissions;
9
+ export declare function buildMcpAppCsp(csp: McpUiResourceCsp | undefined): string;
10
+ //# sourceMappingURL=McpAppRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpAppRenderer.d.ts","sourceRoot":"","sources":["../../../src/client/mcp-apps/McpAppRenderer.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC9B,MAAM,2CAA2C,CAAC;AAGnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAQzE,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,kBAAkB,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAQD,wBAAgB,cAAc,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,mBAAmB,2CA6JrE;AAwBD,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,wBAAwB,GAAG,SAAS,GAChD,wBAAwB,CAE1B;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,gBAAgB,GAAG,SAAS,GAAG,MAAM,CAiBxE"}
@@ -0,0 +1,296 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useRef, useState } from "react";
3
+ import { AppBridge, PostMessageTransport, buildAllowAttribute, } from "@modelcontextprotocol/ext-apps/app-bridge";
4
+ import { IconAlertTriangle, IconLoader2 } from "@tabler/icons-react";
5
+ import { agentNativePath } from "../api-path.js";
6
+ import { cn } from "../utils.js";
7
+ const DEFAULT_IFRAME_HEIGHT = 360;
8
+ const MAX_IFRAME_HEIGHT = 720;
9
+ const SANDBOX_FLAGS = "allow-scripts allow-forms allow-popups";
10
+ export function McpAppRenderer({ app, className }) {
11
+ const iframeRef = useRef(null);
12
+ const [loadCount, setLoadCount] = useState(0);
13
+ const [height, setHeight] = useState(DEFAULT_IFRAME_HEIGHT);
14
+ const [error, setError] = useState(null);
15
+ const [ready, setReady] = useState(false);
16
+ const resourceHtml = app.resource ? htmlFromResource(app.resource) : "";
17
+ const uiMeta = useMemo(() => resourceUiMeta(app), [app]);
18
+ const supportedPermissions = useMemo(() => supportedMcpAppPermissions(uiMeta.permissions), [uiMeta.permissions]);
19
+ const csp = buildMcpAppCsp(uiMeta.csp);
20
+ const srcDoc = useMemo(() => (resourceHtml ? injectCsp(resourceHtml, csp) : ""), [resourceHtml, csp]);
21
+ useEffect(() => {
22
+ const iframe = iframeRef.current;
23
+ if (!iframe?.contentWindow || !srcDoc || loadCount === 0)
24
+ return;
25
+ let closed = false;
26
+ const bridge = new AppBridge(null, { name: "Agent Native", version: "1.0.0" }, {
27
+ openLinks: {},
28
+ serverTools: {},
29
+ serverResources: {},
30
+ logging: {},
31
+ sandbox: {
32
+ permissions: supportedPermissions,
33
+ csp: uiMeta.csp ?? {},
34
+ },
35
+ }, {
36
+ hostContext: buildHostContext(app),
37
+ });
38
+ bridge.addEventListener("sizechange", ({ height: nextHeight }) => {
39
+ if (typeof nextHeight !== "number" || !Number.isFinite(nextHeight)) {
40
+ return;
41
+ }
42
+ setHeight(Math.min(MAX_IFRAME_HEIGHT, Math.max(220, Math.ceil(nextHeight))));
43
+ });
44
+ bridge.addEventListener("initialized", () => {
45
+ if (closed)
46
+ return;
47
+ setReady(true);
48
+ void bridge.sendToolInput({ arguments: app.toolInput });
49
+ void bridge.sendToolResult(app.toolResult);
50
+ });
51
+ bridge.addEventListener("loggingmessage", ({ level, data }) => {
52
+ if (level === "error" || level === "critical" || level === "alert") {
53
+ console.warn("[mcp-app]", data);
54
+ }
55
+ });
56
+ bridge.onopenlink = async ({ url }) => {
57
+ if (!isSafeExternalUrl(url))
58
+ return { isError: true };
59
+ window.open(url, "_blank", "noopener,noreferrer");
60
+ return {};
61
+ };
62
+ bridge.oncalltool = async ({ name, arguments: toolArguments }) => {
63
+ const toolName = normalizeSameServerToolName(app.serverId, name);
64
+ if (!toolName) {
65
+ return errorToolResult("Cross-server MCP App tool calls are blocked.");
66
+ }
67
+ try {
68
+ return await postMcpAppEndpoint("call-tool", {
69
+ serverId: app.serverId,
70
+ toolName,
71
+ arguments: toolArguments && typeof toolArguments === "object"
72
+ ? toolArguments
73
+ : {},
74
+ });
75
+ }
76
+ catch (err) {
77
+ return errorToolResult(err?.message ?? "MCP App tool call failed.");
78
+ }
79
+ };
80
+ bridge.onlisttools = async () => postMcpAppEndpoint("list-tools", { serverId: app.serverId });
81
+ bridge.onreadresource = async ({ uri }) => postMcpAppEndpoint("read-resource", { serverId: app.serverId, uri });
82
+ bridge.onlistresources = async () => ({ resources: [] });
83
+ bridge.onlistresourcetemplates = async () => ({ resourceTemplates: [] });
84
+ bridge.ondownloadfile = async () => ({ isError: true });
85
+ bridge.onmessage = async () => ({ isError: true });
86
+ bridge.onupdatemodelcontext = async () => ({});
87
+ const transport = new PostMessageTransport(iframe.contentWindow, iframe.contentWindow);
88
+ setReady(false);
89
+ setError(null);
90
+ bridge.connect(transport).catch((err) => {
91
+ if (!closed) {
92
+ setError(err?.message ?? "Failed to initialize MCP App.");
93
+ }
94
+ });
95
+ return () => {
96
+ closed = true;
97
+ setReady(false);
98
+ void bridge
99
+ .teardownResource({}, { timeout: 500 })
100
+ .catch(() => undefined)
101
+ .finally(() => {
102
+ void bridge.close?.().catch?.(() => undefined);
103
+ });
104
+ };
105
+ }, [app, loadCount, srcDoc, supportedPermissions, uiMeta.csp]);
106
+ if (!resourceHtml) {
107
+ return (_jsxs("div", { className: cn("agent-mcp-app agent-mcp-app--error", className), children: [_jsx(IconAlertTriangle, { size: 15 }), _jsx("span", { children: "MCP App resource was not available." })] }));
108
+ }
109
+ return (_jsxs("div", { className: cn("agent-mcp-app", uiMeta.prefersBorder === false && "agent-mcp-app--flush", className), children: [!ready && !error && (_jsxs("div", { className: "agent-mcp-app__loading", children: [_jsx(IconLoader2, { size: 14, className: "agent-conversation-spin" }), _jsx("span", { children: "Loading MCP App" })] })), error && (_jsxs("div", { className: "agent-mcp-app__error", children: [_jsx(IconAlertTriangle, { size: 15 }), _jsx("span", { children: error })] })), _jsx("iframe", { ref: iframeRef, title: app.tool?.title ?? app.originalToolName, srcDoc: srcDoc, sandbox: SANDBOX_FLAGS, allow: buildAllowAttribute(supportedPermissions), style: { height }, onLoad: () => setLoadCount((value) => value + 1) })] }));
110
+ }
111
+ function resourceUiMeta(app) {
112
+ const meta = app.resource?._meta;
113
+ const ui = meta?.ui && typeof meta.ui === "object" && !Array.isArray(meta.ui)
114
+ ? meta.ui
115
+ : {};
116
+ return ui;
117
+ }
118
+ function htmlFromResource(resource) {
119
+ if (typeof resource.text === "string")
120
+ return resource.text;
121
+ if (typeof resource.blob !== "string")
122
+ return "";
123
+ try {
124
+ if (typeof atob !== "function")
125
+ return "";
126
+ return atob(resource.blob);
127
+ }
128
+ catch {
129
+ return "";
130
+ }
131
+ }
132
+ export function supportedMcpAppPermissions(permissions) {
133
+ return permissions?.clipboardWrite ? { clipboardWrite: {} } : {};
134
+ }
135
+ export function buildMcpAppCsp(csp) {
136
+ const connect = sanitizeCspSources(csp?.connectDomains);
137
+ const resources = sanitizeCspSources(csp?.resourceDomains);
138
+ const frames = sanitizeCspSources(csp?.frameDomains);
139
+ const base = sanitizeCspSources(csp?.baseUriDomains);
140
+ return [
141
+ "default-src 'none'",
142
+ `base-uri ${base.length ? base.join(" ") : "'none'"}`,
143
+ "form-action 'none'",
144
+ `connect-src ${connect.length ? connect.join(" ") : "'none'"}`,
145
+ `img-src data: blob:${resources.length ? ` ${resources.join(" ")}` : ""}`,
146
+ `media-src data: blob:${resources.length ? ` ${resources.join(" ")}` : ""}`,
147
+ `font-src data:${resources.length ? ` ${resources.join(" ")}` : ""}`,
148
+ `style-src 'unsafe-inline'${resources.length ? ` ${resources.join(" ")}` : ""}`,
149
+ `script-src 'unsafe-inline'${resources.length ? ` ${resources.join(" ")}` : ""}`,
150
+ `frame-src ${frames.length ? frames.join(" ") : "'none'"}`,
151
+ ].join("; ");
152
+ }
153
+ function sanitizeCspSources(values) {
154
+ const out = [];
155
+ for (const value of values ?? []) {
156
+ const source = sanitizeCspSource(value);
157
+ if (source)
158
+ out.push(source);
159
+ }
160
+ return [...new Set(out)];
161
+ }
162
+ function sanitizeCspSource(value) {
163
+ const source = value.trim();
164
+ if (!source || source.includes("'") || /[\s;]/.test(source))
165
+ return null;
166
+ if (/^https:\/\/\*\.[a-z0-9.-]+(?::\d+)?$/i.test(source))
167
+ return source;
168
+ try {
169
+ const url = new URL(source);
170
+ if (url.protocol === "https:")
171
+ return url.origin;
172
+ if (url.protocol === "http:" &&
173
+ ["localhost", "127.0.0.1", "::1"].includes(url.hostname)) {
174
+ return url.origin;
175
+ }
176
+ }
177
+ catch {
178
+ return null;
179
+ }
180
+ return null;
181
+ }
182
+ function injectCsp(html, csp) {
183
+ const meta = `<meta http-equiv="Content-Security-Policy" content="${escapeAttribute(csp)}">`;
184
+ if (/<head\b[^>]*>/i.test(html)) {
185
+ return html.replace(/<head\b[^>]*>/i, (head) => `${head}${meta}`);
186
+ }
187
+ if (/<html\b[^>]*>/i.test(html)) {
188
+ return html.replace(/<html\b[^>]*>/i, (htmlTag) => `${htmlTag}<head>${meta}</head>`);
189
+ }
190
+ return `<!doctype html><html><head>${meta}</head><body>${html}</body></html>`;
191
+ }
192
+ function escapeAttribute(value) {
193
+ return value
194
+ .replace(/&/g, "&amp;")
195
+ .replace(/"/g, "&quot;")
196
+ .replace(/</g, "&lt;");
197
+ }
198
+ function buildHostContext(app) {
199
+ const root = typeof window !== "undefined"
200
+ ? getComputedStyle(document.documentElement)
201
+ : null;
202
+ const cssVar = (name) => root?.getPropertyValue(name).trim() || "";
203
+ const theme = typeof document !== "undefined" &&
204
+ (document.documentElement.classList.contains("dark") ||
205
+ window.matchMedia?.("(prefers-color-scheme: dark)").matches)
206
+ ? "dark"
207
+ : "light";
208
+ return {
209
+ toolInfo: app.tool
210
+ ? {
211
+ tool: {
212
+ name: app.originalToolName,
213
+ description: app.tool.description,
214
+ inputSchema: app.tool.inputSchema ?? {
215
+ type: "object",
216
+ properties: {},
217
+ },
218
+ ...(app.tool._meta ? { _meta: app.tool._meta } : {}),
219
+ },
220
+ }
221
+ : undefined,
222
+ theme,
223
+ displayMode: "inline",
224
+ availableDisplayModes: ["inline"],
225
+ platform: "web",
226
+ userAgent: "agent-native",
227
+ locale: typeof navigator !== "undefined" ? navigator.language : undefined,
228
+ timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
229
+ containerDimensions: {
230
+ maxHeight: MAX_IFRAME_HEIGHT,
231
+ maxWidth: typeof window !== "undefined" ? window.innerWidth : undefined,
232
+ },
233
+ styles: {
234
+ variables: {
235
+ "--color-background-primary": hslVar(cssVar("--background")),
236
+ "--color-background-secondary": hslVar(cssVar("--muted")),
237
+ "--color-text-primary": hslVar(cssVar("--foreground")),
238
+ "--color-text-secondary": hslVar(cssVar("--muted-foreground")),
239
+ "--color-border-primary": hslVar(cssVar("--border")),
240
+ "--font-sans": cssVar("--font-sans") || "ui-sans-serif, system-ui",
241
+ "--font-mono": cssVar("--font-mono") ||
242
+ "ui-monospace, SFMono-Regular, Menlo, monospace",
243
+ "--border-radius-md": cssVar("--radius") || "8px",
244
+ },
245
+ },
246
+ };
247
+ }
248
+ function hslVar(value) {
249
+ return value ? `hsl(${value})` : undefined;
250
+ }
251
+ function normalizeSameServerToolName(serverId, rawName) {
252
+ if (!rawName.trim())
253
+ return null;
254
+ const prefix = `mcp__${serverId}__`;
255
+ if (rawName.startsWith("mcp__")) {
256
+ return rawName.startsWith(prefix) ? rawName.slice(prefix.length) : null;
257
+ }
258
+ return rawName;
259
+ }
260
+ async function postMcpAppEndpoint(endpoint, body) {
261
+ const response = await fetch(agentNativePath(`/_agent-native/mcp/apps/${endpoint}`), {
262
+ method: "POST",
263
+ credentials: "same-origin",
264
+ headers: { "Content-Type": "application/json" },
265
+ body: JSON.stringify(body),
266
+ });
267
+ if (!response.ok) {
268
+ let message = `MCP App request failed (${response.status})`;
269
+ try {
270
+ const json = await response.json();
271
+ if (typeof json?.error === "string")
272
+ message = json.error;
273
+ }
274
+ catch {
275
+ // ignore
276
+ }
277
+ throw new Error(message);
278
+ }
279
+ return (await response.json());
280
+ }
281
+ function errorToolResult(message) {
282
+ return {
283
+ content: [{ type: "text", text: `Error: ${message}` }],
284
+ isError: true,
285
+ };
286
+ }
287
+ function isSafeExternalUrl(value) {
288
+ try {
289
+ const url = new URL(value);
290
+ return url.protocol === "http:" || url.protocol === "https:";
291
+ }
292
+ catch {
293
+ return false;
294
+ }
295
+ }
296
+ //# sourceMappingURL=McpAppRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpAppRenderer.js","sourceRoot":"","sources":["../../../src/client/mcp-apps/McpAppRenderer.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,mBAAmB,GAGpB,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAErE,OAAO,EAAE,eAAe,EA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F,CAAC;IACF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,IAAI,OAAO,GAAG,2BAA2B,QAAQ,CAAC,MAAM,GAAG,CAAC;QAC5D,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,IAAI,OAAO,IAAI,EAAE,KAAK,KAAK,QAAQ;gBAAE,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC;QAC5D,CAAC;QAAC,MAAM,CAAC;YACP,SAAS;QACX,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAM,CAAC;AACtC,CAAC;AAED,SAAS,eAAe,CAAC,OAAe;IACtC,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,OAAO,EAAE,EAAE,CAAC;QACtD,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAa;IACtC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;QAC3B,OAAO,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport {\n AppBridge,\n PostMessageTransport,\n buildAllowAttribute,\n type McpUiResourceCsp,\n type McpUiResourcePermissions,\n} from \"@modelcontextprotocol/ext-apps/app-bridge\";\nimport type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { IconAlertTriangle, IconLoader2 } from \"@tabler/icons-react\";\nimport type { AgentMcpAppPayload } from \"../../mcp-client/app-result.js\";\nimport { agentNativePath } from \"../api-path.js\";\nimport { cn } from \"../utils.js\";\n\nconst DEFAULT_IFRAME_HEIGHT = 360;\nconst MAX_IFRAME_HEIGHT = 720;\nconst SANDBOX_FLAGS = \"allow-scripts allow-forms allow-popups\";\n\nexport interface McpAppRendererProps {\n app: AgentMcpAppPayload;\n className?: string;\n}\n\ntype ResourceUiMeta = {\n csp?: McpUiResourceCsp;\n permissions?: McpUiResourcePermissions;\n prefersBorder?: boolean;\n};\n\nexport function McpAppRenderer({ app, className }: McpAppRendererProps) {\n const iframeRef = useRef<HTMLIFrameElement | null>(null);\n const [loadCount, setLoadCount] = useState(0);\n const [height, setHeight] = useState(DEFAULT_IFRAME_HEIGHT);\n const [error, setError] = useState<string | null>(null);\n const [ready, setReady] = useState(false);\n const resourceHtml = app.resource ? htmlFromResource(app.resource) : \"\";\n const uiMeta = useMemo(() => resourceUiMeta(app), [app]);\n const supportedPermissions = useMemo(\n () => supportedMcpAppPermissions(uiMeta.permissions),\n [uiMeta.permissions],\n );\n const csp = buildMcpAppCsp(uiMeta.csp);\n const srcDoc = useMemo(\n () => (resourceHtml ? injectCsp(resourceHtml, csp) : \"\"),\n [resourceHtml, csp],\n );\n\n useEffect(() => {\n const iframe = iframeRef.current;\n if (!iframe?.contentWindow || !srcDoc || loadCount === 0) return;\n\n let closed = false;\n const bridge = new AppBridge(\n null,\n { name: \"Agent Native\", version: \"1.0.0\" },\n {\n openLinks: {},\n serverTools: {},\n serverResources: {},\n logging: {},\n sandbox: {\n permissions: supportedPermissions,\n csp: uiMeta.csp ?? {},\n },\n },\n {\n hostContext: buildHostContext(app) as any,\n },\n );\n\n bridge.addEventListener(\"sizechange\", ({ height: nextHeight }) => {\n if (typeof nextHeight !== \"number\" || !Number.isFinite(nextHeight)) {\n return;\n }\n setHeight(\n Math.min(MAX_IFRAME_HEIGHT, Math.max(220, Math.ceil(nextHeight))),\n );\n });\n bridge.addEventListener(\"initialized\", () => {\n if (closed) return;\n setReady(true);\n void bridge.sendToolInput({ arguments: app.toolInput });\n void bridge.sendToolResult(app.toolResult as CallToolResult);\n });\n bridge.addEventListener(\"loggingmessage\", ({ level, data }) => {\n if (level === \"error\" || level === \"critical\" || level === \"alert\") {\n console.warn(\"[mcp-app]\", data);\n }\n });\n bridge.onopenlink = async ({ url }) => {\n if (!isSafeExternalUrl(url)) return { isError: true };\n window.open(url, \"_blank\", \"noopener,noreferrer\");\n return {};\n };\n bridge.oncalltool = async ({ name, arguments: toolArguments }) => {\n const toolName = normalizeSameServerToolName(app.serverId, name);\n if (!toolName) {\n return errorToolResult(\"Cross-server MCP App tool calls are blocked.\");\n }\n try {\n return await postMcpAppEndpoint<CallToolResult>(\"call-tool\", {\n serverId: app.serverId,\n toolName,\n arguments:\n toolArguments && typeof toolArguments === \"object\"\n ? toolArguments\n : {},\n });\n } catch (err: any) {\n return errorToolResult(err?.message ?? \"MCP App tool call failed.\");\n }\n };\n (bridge as any).onlisttools = async () =>\n postMcpAppEndpoint(\"list-tools\", { serverId: app.serverId });\n bridge.onreadresource = async ({ uri }) =>\n postMcpAppEndpoint(\"read-resource\", { serverId: app.serverId, uri });\n bridge.onlistresources = async () => ({ resources: [] });\n bridge.onlistresourcetemplates = async () => ({ resourceTemplates: [] });\n bridge.ondownloadfile = async () => ({ isError: true });\n bridge.onmessage = async () => ({ isError: true });\n bridge.onupdatemodelcontext = async () => ({});\n\n const transport = new PostMessageTransport(\n iframe.contentWindow,\n iframe.contentWindow,\n );\n setReady(false);\n setError(null);\n bridge.connect(transport).catch((err: any) => {\n if (!closed) {\n setError(err?.message ?? \"Failed to initialize MCP App.\");\n }\n });\n\n return () => {\n closed = true;\n setReady(false);\n void bridge\n .teardownResource({}, { timeout: 500 })\n .catch(() => undefined)\n .finally(() => {\n void (bridge as any).close?.().catch?.(() => undefined);\n });\n };\n }, [app, loadCount, srcDoc, supportedPermissions, uiMeta.csp]);\n\n if (!resourceHtml) {\n return (\n <div className={cn(\"agent-mcp-app agent-mcp-app--error\", className)}>\n <IconAlertTriangle size={15} />\n <span>MCP App resource was not available.</span>\n </div>\n );\n }\n\n return (\n <div\n className={cn(\n \"agent-mcp-app\",\n uiMeta.prefersBorder === false && \"agent-mcp-app--flush\",\n className,\n )}\n >\n {!ready && !error && (\n <div className=\"agent-mcp-app__loading\">\n <IconLoader2 size={14} className=\"agent-conversation-spin\" />\n <span>Loading MCP App</span>\n </div>\n )}\n {error && (\n <div className=\"agent-mcp-app__error\">\n <IconAlertTriangle size={15} />\n <span>{error}</span>\n </div>\n )}\n <iframe\n ref={iframeRef}\n title={app.tool?.title ?? app.originalToolName}\n srcDoc={srcDoc}\n sandbox={SANDBOX_FLAGS}\n allow={buildAllowAttribute(supportedPermissions)}\n style={{ height }}\n onLoad={() => setLoadCount((value) => value + 1)}\n />\n </div>\n );\n}\n\nfunction resourceUiMeta(app: AgentMcpAppPayload): ResourceUiMeta {\n const meta = app.resource?._meta;\n const ui =\n meta?.ui && typeof meta.ui === \"object\" && !Array.isArray(meta.ui)\n ? (meta.ui as ResourceUiMeta)\n : {};\n return ui;\n}\n\nfunction htmlFromResource(\n resource: NonNullable<AgentMcpAppPayload[\"resource\"]>,\n): string {\n if (typeof resource.text === \"string\") return resource.text;\n if (typeof resource.blob !== \"string\") return \"\";\n try {\n if (typeof atob !== \"function\") return \"\";\n return atob(resource.blob);\n } catch {\n return \"\";\n }\n}\n\nexport function supportedMcpAppPermissions(\n permissions: McpUiResourcePermissions | undefined,\n): McpUiResourcePermissions {\n return permissions?.clipboardWrite ? { clipboardWrite: {} } : {};\n}\n\nexport function buildMcpAppCsp(csp: McpUiResourceCsp | undefined): string {\n const connect = sanitizeCspSources(csp?.connectDomains);\n const resources = sanitizeCspSources(csp?.resourceDomains);\n const frames = sanitizeCspSources(csp?.frameDomains);\n const base = sanitizeCspSources(csp?.baseUriDomains);\n return [\n \"default-src 'none'\",\n `base-uri ${base.length ? base.join(\" \") : \"'none'\"}`,\n \"form-action 'none'\",\n `connect-src ${connect.length ? connect.join(\" \") : \"'none'\"}`,\n `img-src data: blob:${resources.length ? ` ${resources.join(\" \")}` : \"\"}`,\n `media-src data: blob:${resources.length ? ` ${resources.join(\" \")}` : \"\"}`,\n `font-src data:${resources.length ? ` ${resources.join(\" \")}` : \"\"}`,\n `style-src 'unsafe-inline'${resources.length ? ` ${resources.join(\" \")}` : \"\"}`,\n `script-src 'unsafe-inline'${resources.length ? ` ${resources.join(\" \")}` : \"\"}`,\n `frame-src ${frames.length ? frames.join(\" \") : \"'none'\"}`,\n ].join(\"; \");\n}\n\nfunction sanitizeCspSources(values: string[] | undefined): string[] {\n const out: string[] = [];\n for (const value of values ?? []) {\n const source = sanitizeCspSource(value);\n if (source) out.push(source);\n }\n return [...new Set(out)];\n}\n\nfunction sanitizeCspSource(value: string): string | null {\n const source = value.trim();\n if (!source || source.includes(\"'\") || /[\\s;]/.test(source)) return null;\n if (/^https:\\/\\/\\*\\.[a-z0-9.-]+(?::\\d+)?$/i.test(source)) return source;\n try {\n const url = new URL(source);\n if (url.protocol === \"https:\") return url.origin;\n if (\n url.protocol === \"http:\" &&\n [\"localhost\", \"127.0.0.1\", \"::1\"].includes(url.hostname)\n ) {\n return url.origin;\n }\n } catch {\n return null;\n }\n return null;\n}\n\nfunction injectCsp(html: string, csp: string): string {\n const meta = `<meta http-equiv=\"Content-Security-Policy\" content=\"${escapeAttribute(csp)}\">`;\n if (/<head\\b[^>]*>/i.test(html)) {\n return html.replace(/<head\\b[^>]*>/i, (head) => `${head}${meta}`);\n }\n if (/<html\\b[^>]*>/i.test(html)) {\n return html.replace(\n /<html\\b[^>]*>/i,\n (htmlTag) => `${htmlTag}<head>${meta}</head>`,\n );\n }\n return `<!doctype html><html><head>${meta}</head><body>${html}</body></html>`;\n}\n\nfunction escapeAttribute(value: string): string {\n return value\n .replace(/&/g, \"&amp;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/</g, \"&lt;\");\n}\n\nfunction buildHostContext(app: AgentMcpAppPayload) {\n const root =\n typeof window !== \"undefined\"\n ? getComputedStyle(document.documentElement)\n : null;\n const cssVar = (name: string) => root?.getPropertyValue(name).trim() || \"\";\n const theme =\n typeof document !== \"undefined\" &&\n (document.documentElement.classList.contains(\"dark\") ||\n window.matchMedia?.(\"(prefers-color-scheme: dark)\").matches)\n ? \"dark\"\n : \"light\";\n return {\n toolInfo: app.tool\n ? {\n tool: {\n name: app.originalToolName,\n description: app.tool.description,\n inputSchema: app.tool.inputSchema ?? {\n type: \"object\",\n properties: {},\n },\n ...(app.tool._meta ? { _meta: app.tool._meta } : {}),\n },\n }\n : undefined,\n theme,\n displayMode: \"inline\",\n availableDisplayModes: [\"inline\"],\n platform: \"web\",\n userAgent: \"agent-native\",\n locale: typeof navigator !== \"undefined\" ? navigator.language : undefined,\n timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n containerDimensions: {\n maxHeight: MAX_IFRAME_HEIGHT,\n maxWidth: typeof window !== \"undefined\" ? window.innerWidth : undefined,\n },\n styles: {\n variables: {\n \"--color-background-primary\": hslVar(cssVar(\"--background\")),\n \"--color-background-secondary\": hslVar(cssVar(\"--muted\")),\n \"--color-text-primary\": hslVar(cssVar(\"--foreground\")),\n \"--color-text-secondary\": hslVar(cssVar(\"--muted-foreground\")),\n \"--color-border-primary\": hslVar(cssVar(\"--border\")),\n \"--font-sans\": cssVar(\"--font-sans\") || \"ui-sans-serif, system-ui\",\n \"--font-mono\":\n cssVar(\"--font-mono\") ||\n \"ui-monospace, SFMono-Regular, Menlo, monospace\",\n \"--border-radius-md\": cssVar(\"--radius\") || \"8px\",\n },\n },\n };\n}\n\nfunction hslVar(value: string): string | undefined {\n return value ? `hsl(${value})` : undefined;\n}\n\nfunction normalizeSameServerToolName(\n serverId: string,\n rawName: string,\n): string | null {\n if (!rawName.trim()) return null;\n const prefix = `mcp__${serverId}__`;\n if (rawName.startsWith(\"mcp__\")) {\n return rawName.startsWith(prefix) ? rawName.slice(prefix.length) : null;\n }\n return rawName;\n}\n\nasync function postMcpAppEndpoint<T>(\n endpoint: \"call-tool\" | \"list-tools\" | \"read-resource\",\n body: Record<string, unknown>,\n): Promise<T> {\n const response = await fetch(\n agentNativePath(`/_agent-native/mcp/apps/${endpoint}`),\n {\n method: \"POST\",\n credentials: \"same-origin\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(body),\n },\n );\n if (!response.ok) {\n let message = `MCP App request failed (${response.status})`;\n try {\n const json = await response.json();\n if (typeof json?.error === \"string\") message = json.error;\n } catch {\n // ignore\n }\n throw new Error(message);\n }\n return (await response.json()) as T;\n}\n\nfunction errorToolResult(message: string): CallToolResult {\n return {\n content: [{ type: \"text\", text: `Error: ${message}` }],\n isError: true,\n };\n}\n\nfunction isSafeExternalUrl(value: string): boolean {\n try {\n const url = new URL(value);\n return url.protocol === \"http:\" || url.protocol === \"https:\";\n } catch {\n return false;\n }\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import type { ChatModelRunResult } from "@assistant-ui/react";
2
+ import type { AgentMcpAppPayload } from "../mcp-client/app-result.js";
2
3
  export type ContentPart = {
3
4
  type: "text";
4
5
  text: string;
@@ -9,6 +10,7 @@ export type ContentPart = {
9
10
  argsText: string;
10
11
  args: Record<string, string>;
11
12
  result?: string;
13
+ mcpApp?: AgentMcpAppPayload;
12
14
  };
13
15
  export interface SSEEvent {
14
16
  type: string;
@@ -17,6 +19,7 @@ export interface SSEEvent {
17
19
  label?: string;
18
20
  input?: Record<string, string>;
19
21
  result?: string;
22
+ mcpApp?: AgentMcpAppPayload;
20
23
  error?: string;
21
24
  seq?: number;
22
25
  agent?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"sse-event-processor.d.ts","sourceRoot":"","sources":["../../src/client/sse-event-processor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAG9D,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IACE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KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,EAC7B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GACpB,cAAc,CAAC,kBAAkB,CAAC,CA+HpC;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,EAChC,OAAO,EAAE,WAAW,EAAE,EACtB,eAAe,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,EAClC,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,IAAI,GACzC,OAAO,CAAC,IAAI,CAAC,CAoFf"}
@@ -218,6 +218,8 @@ export function processEvent(ev, content, toolCallCounter, tabId) {
218
218
  part.toolName === ev.tool &&
219
219
  part.result === undefined) {
220
220
  part.result = ev.result ?? "";
221
+ if (ev.mcpApp)
222
+ part.mcpApp = ev.mcpApp;
221
223
  break;
222
224
  }
223
225
  }