@mcpjam/widget-react 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +54 -3
- package/dist/index.js +100 -41
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ComponentType, ReactNode } from 'react';
|
|
4
|
+
import { ToolResultPolicy, BrowserStoragePolicy, AppToolInvocationUpdate } from '@mcpjam/sdk/widget-runtime';
|
|
5
|
+
export { getToolVisibility, isVisibleToAppOnly, isVisibleToModelOnly } from '@mcpjam/sdk/widget-runtime';
|
|
4
6
|
import { McpUiResourceCsp, McpUiResourcePermissions, McpUiHostCapabilities, McpUiStyles, McpUiHostContext, AppBridge } from '@modelcontextprotocol/ext-apps/app-bridge';
|
|
5
7
|
import { SandboxCspPolicy, SandboxPermissionsPolicy, MCPPrompt, MCPResourceTemplate } from '@mcpjam/sdk/browser';
|
|
6
8
|
import * as zustand from 'zustand';
|
|
7
9
|
import { CallToolResult, ContentBlock } from '@modelcontextprotocol/client';
|
|
8
|
-
import { AppToolInvocationUpdate } from '@mcpjam/sdk/widget-runtime';
|
|
9
|
-
export { getToolVisibility, isVisibleToAppOnly, isVisibleToModelOnly } from '@mcpjam/sdk/widget-runtime';
|
|
10
10
|
|
|
11
11
|
/** Sandbox CSP-mode selection. Mirrors the inspector ui-playground-store. */
|
|
12
12
|
type CspMode = "permissive" | "widget-declared";
|
|
@@ -99,6 +99,11 @@ type ResolvedMcpAppsCapabilities = {
|
|
|
99
99
|
cspBaseUriDomains: boolean;
|
|
100
100
|
cspConnectDomains?: McpAppsCspConnectDomains;
|
|
101
101
|
cspResourceDomains?: McpAppsCspResourceDomains;
|
|
102
|
+
/**
|
|
103
|
+
* Which halves of a tool result reach a widget. Optional like the CSP
|
|
104
|
+
* subtype records above: absent means the host forwards everything.
|
|
105
|
+
*/
|
|
106
|
+
toolResult?: ToolResultPolicy;
|
|
102
107
|
resourcePrefersBorder: boolean;
|
|
103
108
|
downloadFile: boolean;
|
|
104
109
|
requestTeardown: boolean;
|
|
@@ -370,6 +375,13 @@ interface WidgetHostProfileSandbox {
|
|
|
370
375
|
permissions?: SandboxPermissionsPolicy;
|
|
371
376
|
sandboxAttrs?: string[];
|
|
372
377
|
allowFeatures?: Record<string, string>;
|
|
378
|
+
/**
|
|
379
|
+
* Probe-measured browser-storage availability inside the widget iframe.
|
|
380
|
+
* Absent or `true` = available; `false` makes the sandbox proxy throw
|
|
381
|
+
* `SecurityError` on access. This projection is minimal by design, so a
|
|
382
|
+
* field missing here silently disappears before reaching the renderer.
|
|
383
|
+
*/
|
|
384
|
+
browserStorage?: BrowserStoragePolicy;
|
|
373
385
|
}
|
|
374
386
|
/**
|
|
375
387
|
* Raw ambient ENV inputs the renderer reads (Phase 1b). The inspector's
|
|
@@ -762,6 +774,37 @@ interface UseToolInputStreamingReturn {
|
|
|
762
774
|
}
|
|
763
775
|
declare function useToolInputStreaming({ bridgeRef, isReady, isReadyRef, toolState, toolInput, toolOutput, toolErrorText, toolCallId, sendToolInput, onToolInputSent, reinitCount, mcpAppsCapabilitiesRef, }: UseToolInputStreamingParams): UseToolInputStreamingReturn;
|
|
764
776
|
|
|
777
|
+
/** The parts of `window.location` the sandbox origin is derived from. */
|
|
778
|
+
type SandboxProxyLocation = Pick<Location, "hostname" | "port" | "protocol" | "origin">;
|
|
779
|
+
/**
|
|
780
|
+
* Where the outer sandbox iframe loads from.
|
|
781
|
+
*
|
|
782
|
+
* SEP-1865: host and sandbox MUST have different origins.
|
|
783
|
+
*
|
|
784
|
+
* Hosted: prefer the operator-configured SANDBOX_ORIGIN
|
|
785
|
+
* (`VITE_MCPJAM_SANDBOX_ORIGIN`). It MUST be a distinct origin from the host
|
|
786
|
+
* app so the sandboxed iframe cannot reach host cookies or storage even when
|
|
787
|
+
* its sandbox carries `allow-same-origin`.
|
|
788
|
+
*
|
|
789
|
+
* A configured origin EQUAL to the app's own counts as unset. It produces
|
|
790
|
+
* exactly the same same-origin iframe as no value at all, and it is the more
|
|
791
|
+
* likely of the two mistakes because it looks configured. The client boot
|
|
792
|
+
* guard used to be the only thing that said so, and it could not tell that
|
|
793
|
+
* case apart from the app legitimately being loaded on the sandbox hostname
|
|
794
|
+
* (INSPECTOR-CLIENT-247) — so the deploy-level check moved to the server and
|
|
795
|
+
* this renderer stopped walking straight through the condition.
|
|
796
|
+
*
|
|
797
|
+
* Local: keep the localhost ↔ 127.0.0.1 swap so dev gets the same
|
|
798
|
+
* origin-separation property without operator config.
|
|
799
|
+
*
|
|
800
|
+
* Same-origin fallback exists only as a soft-fail for misconfigured hosted
|
|
801
|
+
* deploys; it emits a loud security warning.
|
|
802
|
+
*/
|
|
803
|
+
declare function resolveSandboxProxyUrl({ hostedMode, sandboxOrigin, location, }: {
|
|
804
|
+
hostedMode: boolean;
|
|
805
|
+
sandboxOrigin: string;
|
|
806
|
+
location: SandboxProxyLocation;
|
|
807
|
+
}): string;
|
|
765
808
|
interface SandboxedIframeHandle {
|
|
766
809
|
postMessage: (data: unknown) => void;
|
|
767
810
|
getIframeElement: () => HTMLIFrameElement | null;
|
|
@@ -799,6 +842,14 @@ interface SandboxedIframeProps {
|
|
|
799
842
|
cspDirectives?: Record<string, string[]>;
|
|
800
843
|
/** Probe-derived host policy for individual CSP-backed browser APIs. */
|
|
801
844
|
cspSubtypePolicy?: CspSubtypePolicy;
|
|
845
|
+
/**
|
|
846
|
+
* Probe-derived host policy for browser storage inside the widget.
|
|
847
|
+
* Absent or `true` means available; `false` makes the proxy install a guard
|
|
848
|
+
* that throws `SecurityError` on access, as a real iframe without
|
|
849
|
+
* `allow-same-origin` does. Not a CSP concern — applies in permissive mode
|
|
850
|
+
* too.
|
|
851
|
+
*/
|
|
852
|
+
browserStorage?: BrowserStoragePolicy;
|
|
802
853
|
/** Skip CSP injection entirely (for permissive/testing mode) */
|
|
803
854
|
permissive?: boolean;
|
|
804
855
|
/**
|
|
@@ -1037,4 +1088,4 @@ declare function getRenderableSurfaceEntries(surfaces: Map<WidgetSurfaceId, Widg
|
|
|
1037
1088
|
props: MCPAppsRendererProps;
|
|
1038
1089
|
}[];
|
|
1039
1090
|
|
|
1040
|
-
export { type AddTrafficLog, type AppInstance, type AppToolAlias, type AppToolAttribution, type AppToolDescriptor, type AppToolInvocationRecord, type AppToolSnapshotEntry, type BridgeId, type CspMode, type CspViolation, type DeviceCapabilities, type DeviceType, type DisplayMode, type EffectiveCompatRuntime, type FetchWidgetContentRequest, type FetchWidgetContentResponse, type ListResourcesResult, MCPAppsRenderer, type MCPAppsRendererProps, MCPAppsRendererSurface, type OpenAiAppsCapabilities, PARTIAL_INPUT_THROTTLE_MS, type ProjectHostContextDraft, type ResolvedHostCapabilities, type ResolvedHostInfo, type ResolvedHostStyle, type ResolvedMcpAppsCapabilities, type ResolvedOpenAiAppsCapabilities, SIGNATURE_MAX_ARRAY_ITEMS, SIGNATURE_MAX_DEPTH, SIGNATURE_MAX_OBJECT_KEYS, SIGNATURE_STRING_EDGE_LENGTH, STREAMING_REVEAL_FALLBACK_MS, type SafeAreaInsets, SandboxedIframe, type SandboxedIframeHandle, type ScenarioHostStyle, type ThemeMode, type ToolLike, type ToolState, UIType, type UiLogEvent, type UiProtocol, type UseToolInputStreamingParams, type UseToolInputStreamingReturn, type WidgetCheckoutProps, type WidgetDebugInfo, type WidgetDebugSink, type WidgetGlobals, type WidgetHost, type WidgetHostComponents, type WidgetHostEnvironment, type WidgetHostEnvironmentInputs, WidgetHostProvider, type WidgetHostProviderProps, type WidgetHostResolvers, type WidgetHostServices, type WidgetLifecycleEvent, type WidgetModalProps, type WidgetMount, type WidgetSandboxApplied, type WidgetSandboxInfo, WidgetSurfaceHost, WidgetSurfaceHostProvider, type WidgetSurfaceId, type WidgetSurfaceInfo, type WidgetSurfaceKind, type WidgetSurfaceRecord, __internal, detectUIType, detectUiTypeFromTool, getRenderableSurfaceEntries, getToolInputSignature, getUIResourceUri, readToolResultMeta, readToolResultObject, readToolResultServerId, recordAppToolInvocation, useAppToolAttribution, useAppToolAttributionResolver, useAppToolInvocationLog, useAppToolsRegistry, usePersistentWidgetSurfaceHost, useToolInputStreaming, useWidgetHost, useWidgetSurfaceStore };
|
|
1091
|
+
export { type AddTrafficLog, type AppInstance, type AppToolAlias, type AppToolAttribution, type AppToolDescriptor, type AppToolInvocationRecord, type AppToolSnapshotEntry, type BridgeId, type CspMode, type CspViolation, type DeviceCapabilities, type DeviceType, type DisplayMode, type EffectiveCompatRuntime, type FetchWidgetContentRequest, type FetchWidgetContentResponse, type ListResourcesResult, MCPAppsRenderer, type MCPAppsRendererProps, MCPAppsRendererSurface, type OpenAiAppsCapabilities, PARTIAL_INPUT_THROTTLE_MS, type ProjectHostContextDraft, type ResolvedHostCapabilities, type ResolvedHostInfo, type ResolvedHostStyle, type ResolvedMcpAppsCapabilities, type ResolvedOpenAiAppsCapabilities, SIGNATURE_MAX_ARRAY_ITEMS, SIGNATURE_MAX_DEPTH, SIGNATURE_MAX_OBJECT_KEYS, SIGNATURE_STRING_EDGE_LENGTH, STREAMING_REVEAL_FALLBACK_MS, type SafeAreaInsets, type SandboxProxyLocation, SandboxedIframe, type SandboxedIframeHandle, type ScenarioHostStyle, type ThemeMode, type ToolLike, type ToolState, UIType, type UiLogEvent, type UiProtocol, type UseToolInputStreamingParams, type UseToolInputStreamingReturn, type WidgetCheckoutProps, type WidgetDebugInfo, type WidgetDebugSink, type WidgetGlobals, type WidgetHost, type WidgetHostComponents, type WidgetHostEnvironment, type WidgetHostEnvironmentInputs, WidgetHostProvider, type WidgetHostProviderProps, type WidgetHostResolvers, type WidgetHostServices, type WidgetLifecycleEvent, type WidgetModalProps, type WidgetMount, type WidgetSandboxApplied, type WidgetSandboxInfo, WidgetSurfaceHost, WidgetSurfaceHostProvider, type WidgetSurfaceId, type WidgetSurfaceInfo, type WidgetSurfaceKind, type WidgetSurfaceRecord, __internal, detectUIType, detectUiTypeFromTool, getRenderableSurfaceEntries, getToolInputSignature, getUIResourceUri, readToolResultMeta, readToolResultObject, readToolResultServerId, recordAppToolInvocation, resolveSandboxProxyUrl, useAppToolAttribution, useAppToolAttributionResolver, useAppToolInvocationLog, useAppToolsRegistry, usePersistentWidgetSurfaceHost, useToolInputStreaming, useWidgetHost, useWidgetSurfaceStore };
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createContext, forwardRef, useRef, useState, useMemo, useImperativeHandle, useCallback, useEffect, useContext, useLayoutEffect } from 'react';
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { isUIResource } from '@mcp-ui/client';
|
|
4
|
-
import {
|
|
5
|
-
import { buildOuterAllowAttribute, buildOuterSandboxAttribute, stableStringifyJson, registerHostBridgeHandlers, LoggingTransport, extractMethod } from '@mcpjam/sdk/widget-runtime';
|
|
4
|
+
import { buildOuterAllowAttribute, buildOuterSandboxAttribute, stableStringifyJson, resolveToolUiResourceUri, applyToolResultPolicy, registerHostBridgeHandlers, LoggingTransport, extractMethod } from '@mcpjam/sdk/widget-runtime';
|
|
6
5
|
export { getToolVisibility, isVisibleToAppOnly, isVisibleToModelOnly } from '@mcpjam/sdk/widget-runtime';
|
|
7
6
|
import { create } from 'zustand';
|
|
8
7
|
import { useShallow } from 'zustand/react/shallow';
|
|
9
8
|
import { X, ExternalLink, Loader2 } from 'lucide-react';
|
|
10
9
|
import { resolveSandboxPermissions, resolveSandboxCsp } from '@mcpjam/sdk/browser';
|
|
10
|
+
import { AppBridge, PostMessageTransport } from '@modelcontextprotocol/ext-apps/app-bridge';
|
|
11
11
|
import { createPortal } from 'react-dom';
|
|
12
12
|
|
|
13
13
|
// src/widget-host-context.tsx
|
|
@@ -40,13 +40,13 @@ function detectUiTypeFromTool(tool) {
|
|
|
40
40
|
return detectUIType(toolMeta, void 0);
|
|
41
41
|
}
|
|
42
42
|
function detectUIType(toolMeta, toolResult) {
|
|
43
|
-
if (toolMeta?.["openai/outputTemplate"] &&
|
|
43
|
+
if (toolMeta?.["openai/outputTemplate"] && resolveToolUiResourceUri(toolMeta)) {
|
|
44
44
|
return "openai-sdk-and-mcp-apps" /* OPENAI_SDK_AND_MCP_APPS */;
|
|
45
45
|
}
|
|
46
46
|
if (toolMeta?.["openai/outputTemplate"]) {
|
|
47
47
|
return "openai-sdk" /* OPENAI_SDK */;
|
|
48
48
|
}
|
|
49
|
-
if (
|
|
49
|
+
if (resolveToolUiResourceUri(toolMeta)) {
|
|
50
50
|
return "mcp-apps" /* MCP_APPS */;
|
|
51
51
|
}
|
|
52
52
|
const directResource = toolResult?.resource;
|
|
@@ -67,7 +67,7 @@ function getUIResourceUri(uiType, toolMeta) {
|
|
|
67
67
|
switch (uiType) {
|
|
68
68
|
case "mcp-apps" /* MCP_APPS */:
|
|
69
69
|
case "openai-sdk-and-mcp-apps" /* OPENAI_SDK_AND_MCP_APPS */:
|
|
70
|
-
return
|
|
70
|
+
return resolveToolUiResourceUri(toolMeta);
|
|
71
71
|
case "openai-sdk" /* OPENAI_SDK */:
|
|
72
72
|
return toolMeta?.["openai/outputTemplate"] ?? null;
|
|
73
73
|
default:
|
|
@@ -769,10 +769,22 @@ function useToolInputStreaming({
|
|
|
769
769
|
const outputKey = `${toolCallId}:${serialized}`;
|
|
770
770
|
if (lastToolOutputRef.current === outputKey) return;
|
|
771
771
|
lastToolOutputRef.current = outputKey;
|
|
772
|
+
const shaped = applyToolResultPolicy(
|
|
773
|
+
toolOutput,
|
|
774
|
+
mcpAppsCapabilitiesRef.current?.toolResult
|
|
775
|
+
);
|
|
772
776
|
bridge.sendToolResult(
|
|
773
|
-
|
|
777
|
+
shaped
|
|
774
778
|
);
|
|
775
|
-
}, [
|
|
779
|
+
}, [
|
|
780
|
+
isReady,
|
|
781
|
+
toolCallId,
|
|
782
|
+
toolOutput,
|
|
783
|
+
toolState,
|
|
784
|
+
bridgeRef,
|
|
785
|
+
reinitCount,
|
|
786
|
+
mcpAppsCapabilitiesRef
|
|
787
|
+
]);
|
|
776
788
|
useEffect(() => {
|
|
777
789
|
if (!isReady || toolState !== "output-error") return;
|
|
778
790
|
const bridge = bridgeRef.current;
|
|
@@ -823,6 +835,53 @@ function recorderDebug(message, details) {
|
|
|
823
835
|
} catch {
|
|
824
836
|
}
|
|
825
837
|
}
|
|
838
|
+
function parseSandboxOrigin(value) {
|
|
839
|
+
let parsed;
|
|
840
|
+
try {
|
|
841
|
+
parsed = new URL(value);
|
|
842
|
+
} catch {
|
|
843
|
+
return null;
|
|
844
|
+
}
|
|
845
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") {
|
|
846
|
+
return null;
|
|
847
|
+
}
|
|
848
|
+
return parsed.origin;
|
|
849
|
+
}
|
|
850
|
+
function resolveSandboxProxyUrl({
|
|
851
|
+
hostedMode,
|
|
852
|
+
sandboxOrigin,
|
|
853
|
+
location
|
|
854
|
+
}) {
|
|
855
|
+
const proxyPath = hostedMode ? "/api/web/apps/mcp-apps/sandbox-proxy" : "/api/apps/mcp-apps/sandbox-proxy";
|
|
856
|
+
const configuredOrigin = hostedMode ? parseSandboxOrigin(sandboxOrigin) : null;
|
|
857
|
+
if (configuredOrigin && configuredOrigin !== location.origin) {
|
|
858
|
+
return `${configuredOrigin}${proxyPath}?v=${Date.now()}`;
|
|
859
|
+
}
|
|
860
|
+
const currentHost = location.hostname;
|
|
861
|
+
const currentPort = location.port;
|
|
862
|
+
const protocol = location.protocol;
|
|
863
|
+
let sandboxHost;
|
|
864
|
+
if (currentHost === "localhost") {
|
|
865
|
+
sandboxHost = "127.0.0.1";
|
|
866
|
+
} else if (currentHost === "127.0.0.1") {
|
|
867
|
+
sandboxHost = "localhost";
|
|
868
|
+
} else {
|
|
869
|
+
if (hostedMode) {
|
|
870
|
+
console.warn(
|
|
871
|
+
"[SandboxedIframe] VITE_MCPJAM_SANDBOX_ORIGIN is not set to an origin distinct from this app's; sandbox iframe is falling back to same-origin. This is a security regression \u2014 the sandbox shares cookies and storage with the host app. Configure a distinct origin (e.g. https://sandbox.mcpjam.com) and redeploy."
|
|
872
|
+
);
|
|
873
|
+
} else {
|
|
874
|
+
console.warn(
|
|
875
|
+
"[SandboxedIframe] Cross-origin isolation not available for hostname:",
|
|
876
|
+
currentHost,
|
|
877
|
+
"- falling back to same-origin sandbox"
|
|
878
|
+
);
|
|
879
|
+
}
|
|
880
|
+
sandboxHost = currentHost;
|
|
881
|
+
}
|
|
882
|
+
const portSuffix = currentPort ? `:${currentPort}` : "";
|
|
883
|
+
return `${protocol}//${sandboxHost}${portSuffix}${proxyPath}?v=${Date.now()}`;
|
|
884
|
+
}
|
|
826
885
|
var SandboxedIframe = forwardRef(function SandboxedIframe2({
|
|
827
886
|
html,
|
|
828
887
|
sandbox = "allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox",
|
|
@@ -832,6 +891,7 @@ var SandboxedIframe = forwardRef(function SandboxedIframe2({
|
|
|
832
891
|
allowFeatures,
|
|
833
892
|
cspDirectives,
|
|
834
893
|
cspSubtypePolicy,
|
|
894
|
+
browserStorage,
|
|
835
895
|
permissive,
|
|
836
896
|
recordMode,
|
|
837
897
|
onProxyReady,
|
|
@@ -850,36 +910,13 @@ var SandboxedIframe = forwardRef(function SandboxedIframe2({
|
|
|
850
910
|
const onProxyReadyRef = useRef(onProxyReady);
|
|
851
911
|
onMessageRef.current = onMessage;
|
|
852
912
|
onProxyReadyRef.current = onProxyReady;
|
|
853
|
-
const [sandboxProxyUrl] = useState(
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
const protocol = window.location.protocol;
|
|
861
|
-
let sandboxHost;
|
|
862
|
-
if (currentHost === "localhost") {
|
|
863
|
-
sandboxHost = "127.0.0.1";
|
|
864
|
-
} else if (currentHost === "127.0.0.1") {
|
|
865
|
-
sandboxHost = "localhost";
|
|
866
|
-
} else {
|
|
867
|
-
if (hostedMode) {
|
|
868
|
-
console.warn(
|
|
869
|
-
"[SandboxedIframe] VITE_MCPJAM_SANDBOX_ORIGIN is not configured; sandbox iframe is falling back to same-origin. This is a security regression \u2014 the sandbox shares cookies and storage with the host app. Configure a distinct origin (e.g. https://sandbox.mcpjam.com) and redeploy."
|
|
870
|
-
);
|
|
871
|
-
} else {
|
|
872
|
-
console.warn(
|
|
873
|
-
"[SandboxedIframe] Cross-origin isolation not available for hostname:",
|
|
874
|
-
currentHost,
|
|
875
|
-
"- falling back to same-origin sandbox"
|
|
876
|
-
);
|
|
877
|
-
}
|
|
878
|
-
sandboxHost = currentHost;
|
|
879
|
-
}
|
|
880
|
-
const portSuffix = currentPort ? `:${currentPort}` : "";
|
|
881
|
-
return `${protocol}//${sandboxHost}${portSuffix}${proxyPath}?v=${Date.now()}`;
|
|
882
|
-
});
|
|
913
|
+
const [sandboxProxyUrl] = useState(
|
|
914
|
+
() => resolveSandboxProxyUrl({
|
|
915
|
+
hostedMode,
|
|
916
|
+
sandboxOrigin,
|
|
917
|
+
location: window.location
|
|
918
|
+
})
|
|
919
|
+
);
|
|
883
920
|
const sandboxProxyOrigin = useMemo(() => {
|
|
884
921
|
try {
|
|
885
922
|
return new URL(sandboxProxyUrl).origin;
|
|
@@ -947,6 +984,7 @@ var SandboxedIframe = forwardRef(function SandboxedIframe2({
|
|
|
947
984
|
csp: csp ?? null,
|
|
948
985
|
cspDirectives: cspDirectives ?? null,
|
|
949
986
|
cspSubtypePolicy: cspSubtypePolicy ?? null,
|
|
987
|
+
browserStorage: browserStorage ?? null,
|
|
950
988
|
html: html ?? null,
|
|
951
989
|
permissive: permissive ?? null,
|
|
952
990
|
permissions: permissions ?? null,
|
|
@@ -960,6 +998,7 @@ var SandboxedIframe = forwardRef(function SandboxedIframe2({
|
|
|
960
998
|
csp,
|
|
961
999
|
cspDirectives,
|
|
962
1000
|
cspSubtypePolicy,
|
|
1001
|
+
browserStorage,
|
|
963
1002
|
html,
|
|
964
1003
|
permissive,
|
|
965
1004
|
permissions,
|
|
@@ -995,6 +1034,7 @@ var SandboxedIframe = forwardRef(function SandboxedIframe2({
|
|
|
995
1034
|
// field.
|
|
996
1035
|
cspDirectives,
|
|
997
1036
|
cspSubtypePolicy,
|
|
1037
|
+
browserStorage,
|
|
998
1038
|
permissive,
|
|
999
1039
|
colorScheme,
|
|
1000
1040
|
recordMode,
|
|
@@ -1055,6 +1095,8 @@ function McpAppsModal({
|
|
|
1055
1095
|
widgetAllowFeatures,
|
|
1056
1096
|
widgetCspDirectives,
|
|
1057
1097
|
widgetCspSubtypePolicy,
|
|
1098
|
+
widgetToolResult,
|
|
1099
|
+
widgetBrowserStorage,
|
|
1058
1100
|
hostContextRef,
|
|
1059
1101
|
serverId,
|
|
1060
1102
|
resourceUri,
|
|
@@ -1166,7 +1208,10 @@ function McpAppsModal({
|
|
|
1166
1208
|
bridge.sendToolInput({ arguments: resolvedToolInput });
|
|
1167
1209
|
if (toolOutputRef.current) {
|
|
1168
1210
|
bridge.sendToolResult(
|
|
1169
|
-
|
|
1211
|
+
applyToolResultPolicy(
|
|
1212
|
+
toolOutputRef.current,
|
|
1213
|
+
widgetToolResult
|
|
1214
|
+
)
|
|
1170
1215
|
);
|
|
1171
1216
|
}
|
|
1172
1217
|
const appCaps = bridge.getAppCapabilities();
|
|
@@ -1282,6 +1327,7 @@ function McpAppsModal({
|
|
|
1282
1327
|
allowFeatures: widgetAllowFeatures,
|
|
1283
1328
|
cspDirectives: widgetCspDirectives,
|
|
1284
1329
|
cspSubtypePolicy: widgetCspSubtypePolicy,
|
|
1330
|
+
browserStorage: widgetBrowserStorage,
|
|
1285
1331
|
colorScheme: modalColorScheme,
|
|
1286
1332
|
onMessage: handleModalMessage,
|
|
1287
1333
|
title: `MCP App Modal: ${title}`,
|
|
@@ -2838,6 +2884,10 @@ function MCPAppsRendererSurface({
|
|
|
2838
2884
|
() => profileSandbox?.csp?.cspDirectives,
|
|
2839
2885
|
[activeMcpProfileKey]
|
|
2840
2886
|
);
|
|
2887
|
+
const browserStoragePolicy = useMemo(
|
|
2888
|
+
() => profileSandbox?.browserStorage,
|
|
2889
|
+
[activeMcpProfileKey]
|
|
2890
|
+
);
|
|
2841
2891
|
const cspDirectivesEffective = useMemo(() => {
|
|
2842
2892
|
if (!cspDirectivesPolicy) return cspDirectivesPolicy;
|
|
2843
2893
|
if (!host.surface.hostedMode) return cspDirectivesPolicy;
|
|
@@ -2912,7 +2962,11 @@ function MCPAppsRendererSurface({
|
|
|
2912
2962
|
sandboxAttrs: sandboxAttrsPolicy,
|
|
2913
2963
|
allowFeatures: allowFeaturesPolicy,
|
|
2914
2964
|
cspDirectives: cspDirectivesEffective,
|
|
2915
|
-
cspSubtypePolicy: void 0
|
|
2965
|
+
cspSubtypePolicy: void 0,
|
|
2966
|
+
// Unlike `cspSubtypePolicy` above, storage is NOT dropped in
|
|
2967
|
+
// permissive mode: a host that serves no CSP can still deny storage,
|
|
2968
|
+
// and the proxy arms the guard on both branches.
|
|
2969
|
+
browserStorage: browserStoragePolicy
|
|
2916
2970
|
};
|
|
2917
2971
|
}
|
|
2918
2972
|
const isPureRelaxedCsp = sandboxCspPolicy?.mode === "relaxed" && !restrictToConfigured && !cspDirectivesConfigured && !host.surface.hostedMode;
|
|
@@ -3019,7 +3073,8 @@ function MCPAppsRendererSurface({
|
|
|
3019
3073
|
sandboxAttrs: sandboxAttrsPolicy,
|
|
3020
3074
|
allowFeatures: allowFeaturesPolicy,
|
|
3021
3075
|
cspDirectives: cspDirectivesEffective,
|
|
3022
|
-
cspSubtypePolicy: effectiveCspSubtypePolicy
|
|
3076
|
+
cspSubtypePolicy: effectiveCspSubtypePolicy,
|
|
3077
|
+
browserStorage: browserStoragePolicy
|
|
3023
3078
|
};
|
|
3024
3079
|
}, [
|
|
3025
3080
|
cspMode,
|
|
@@ -3034,6 +3089,7 @@ function MCPAppsRendererSurface({
|
|
|
3034
3089
|
sandboxAttrsPolicy,
|
|
3035
3090
|
allowFeaturesPolicy,
|
|
3036
3091
|
cspDirectivesEffective,
|
|
3092
|
+
browserStoragePolicy,
|
|
3037
3093
|
earlyEffectiveMcpAppsCapabilities.cspConnectDomains,
|
|
3038
3094
|
earlyEffectiveMcpAppsCapabilities.cspResourceDomains
|
|
3039
3095
|
]);
|
|
@@ -3883,6 +3939,7 @@ function MCPAppsRendererSurface({
|
|
|
3883
3939
|
allowFeatures: effectiveSandbox.allowFeatures,
|
|
3884
3940
|
cspDirectives: effectiveSandbox.cspDirectives,
|
|
3885
3941
|
cspSubtypePolicy: effectiveSandbox.cspSubtypePolicy,
|
|
3942
|
+
browserStorage: effectiveSandbox.browserStorage,
|
|
3886
3943
|
colorScheme: resolvedTheme,
|
|
3887
3944
|
recordMode,
|
|
3888
3945
|
onProxyReady: () => {
|
|
@@ -4033,6 +4090,8 @@ function MCPAppsRendererSurface({
|
|
|
4033
4090
|
widgetAllowFeatures: effectiveSandbox.allowFeatures,
|
|
4034
4091
|
widgetCspDirectives: effectiveSandbox.cspDirectives,
|
|
4035
4092
|
widgetCspSubtypePolicy: effectiveSandbox.cspSubtypePolicy,
|
|
4093
|
+
widgetBrowserStorage: effectiveSandbox.browserStorage,
|
|
4094
|
+
widgetToolResult: earlyEffectiveMcpAppsCapabilities.toolResult,
|
|
4036
4095
|
hostContextRef,
|
|
4037
4096
|
serverId,
|
|
4038
4097
|
resourceUri,
|
|
@@ -4158,6 +4217,6 @@ function WidgetSurfaceHost({
|
|
|
4158
4217
|
] });
|
|
4159
4218
|
}
|
|
4160
4219
|
|
|
4161
|
-
export { MCPAppsRenderer, MCPAppsRendererSurface, PARTIAL_INPUT_THROTTLE_MS, SIGNATURE_MAX_ARRAY_ITEMS, SIGNATURE_MAX_DEPTH, SIGNATURE_MAX_OBJECT_KEYS, SIGNATURE_STRING_EDGE_LENGTH, STREAMING_REVEAL_FALLBACK_MS, SandboxedIframe, UIType, WidgetHostProvider, WidgetSurfaceHost, WidgetSurfaceHostProvider, __internal, detectUIType, detectUiTypeFromTool, getRenderableSurfaceEntries, getToolInputSignature, getUIResourceUri, readToolResultMeta, readToolResultObject, readToolResultServerId, recordAppToolInvocation, useAppToolAttribution, useAppToolAttributionResolver, useAppToolInvocationLog, useAppToolsRegistry, usePersistentWidgetSurfaceHost, useToolInputStreaming, useWidgetHost, useWidgetSurfaceStore };
|
|
4220
|
+
export { MCPAppsRenderer, MCPAppsRendererSurface, PARTIAL_INPUT_THROTTLE_MS, SIGNATURE_MAX_ARRAY_ITEMS, SIGNATURE_MAX_DEPTH, SIGNATURE_MAX_OBJECT_KEYS, SIGNATURE_STRING_EDGE_LENGTH, STREAMING_REVEAL_FALLBACK_MS, SandboxedIframe, UIType, WidgetHostProvider, WidgetSurfaceHost, WidgetSurfaceHostProvider, __internal, detectUIType, detectUiTypeFromTool, getRenderableSurfaceEntries, getToolInputSignature, getUIResourceUri, readToolResultMeta, readToolResultObject, readToolResultServerId, recordAppToolInvocation, resolveSandboxProxyUrl, useAppToolAttribution, useAppToolAttributionResolver, useAppToolInvocationLog, useAppToolsRegistry, usePersistentWidgetSurfaceHost, useToolInputStreaming, useWidgetHost, useWidgetSurfaceStore };
|
|
4162
4221
|
//# sourceMappingURL=index.js.map
|
|
4163
4222
|
//# sourceMappingURL=index.js.map
|