@assistant-ui/react 0.15.24 → 0.15.26
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/hooks/useToolCallElapsed.d.ts +3 -1
- package/dist/hooks/useToolCallElapsed.d.ts.map +1 -1
- package/dist/hooks/useToolCallElapsed.js +8 -8
- package/dist/hooks/useToolCallElapsed.js.map +1 -1
- package/dist/index.d.ts +39 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/mcp-apps/McpAppRenderer.d.ts.map +1 -1
- package/dist/mcp-apps/McpAppRenderer.js +3 -2
- 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 +56 -46
- package/dist/mcp-apps/app-frame.js.map +1 -1
- package/dist/mcp-apps/csp.d.ts +4 -0
- package/dist/mcp-apps/csp.d.ts.map +1 -0
- package/dist/mcp-apps/csp.js +93 -0
- package/dist/mcp-apps/csp.js.map +1 -0
- package/dist/mcp-apps/types.d.ts +1 -0
- package/dist/mcp-apps/types.d.ts.map +1 -1
- package/dist/mcp-apps/types.js.map +1 -1
- package/dist/model-context/makeAssistantVisible.d.ts +1 -0
- package/dist/model-context/makeAssistantVisible.d.ts.map +1 -1
- package/dist/model-context/makeAssistantVisible.js +31 -12
- package/dist/model-context/makeAssistantVisible.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalRoot.d.ts +1 -0
- package/dist/primitives/assistantModal/AssistantModalRoot.d.ts.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalRoot.js.map +1 -1
- package/dist/primitives/attachment.d.ts +3 -1
- package/dist/primitives/attachment.d.ts.map +1 -1
- package/dist/primitives/attachment.js.map +1 -1
- package/dist/primitives/composer/ComposerCancel.d.ts +5 -1
- package/dist/primitives/composer/ComposerCancel.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerCancel.js +14 -1
- package/dist/primitives/composer/ComposerCancel.js.map +1 -1
- package/dist/primitives/composer/ComposerInput.d.ts +15 -1
- package/dist/primitives/composer/ComposerInput.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerInput.js +5 -4
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/composer/ComposerRoot.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerRoot.js +24 -19
- package/dist/primitives/composer/ComposerRoot.js.map +1 -1
- package/dist/primitives/composer/composerInputSelector.d.ts +3 -0
- package/dist/primitives/composer/composerInputSelector.d.ts.map +1 -0
- package/dist/primitives/composer/composerInputSelector.js +7 -0
- package/dist/primitives/composer/composerInputSelector.js.map +1 -0
- package/dist/primitives/composer/trigger/TriggerPopover.d.ts +11 -11
- package/dist/primitives/composer/trigger/TriggerPopover.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopover.js +62 -60
- package/dist/primitives/composer/trigger/TriggerPopover.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverAction.d.ts +8 -8
- package/dist/primitives/composer/trigger/TriggerPopoverAction.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverAction.js +6 -6
- package/dist/primitives/composer/trigger/TriggerPopoverAction.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverCategories.d.ts +3 -3
- package/dist/primitives/composer/trigger/TriggerPopoverCategories.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverCategories.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverDirective.d.ts +9 -9
- package/dist/primitives/composer/trigger/TriggerPopoverDirective.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverDirective.js +7 -7
- package/dist/primitives/composer/trigger/TriggerPopoverDirective.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverItems.d.ts +5 -5
- package/dist/primitives/composer/trigger/TriggerPopoverItems.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverItems.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverRootContext.d.ts +8 -8
- package/dist/primitives/composer/trigger/TriggerPopoverRootContext.js +8 -8
- package/dist/primitives/composer/trigger/TriggerPopoverRootContext.js.map +1 -1
- package/dist/primitives/composer/trigger/index.d.ts +1 -1
- package/dist/primitives/composer/useComposerCancelWithFocus.d.ts +2 -0
- package/dist/primitives/composer/useComposerCancelWithFocus.d.ts.map +1 -0
- package/dist/primitives/composer/useComposerCancelWithFocus.js +42 -0
- package/dist/primitives/composer/useComposerCancelWithFocus.js.map +1 -0
- package/dist/primitives/composer.d.ts +55 -15
- package/dist/primitives/composer.d.ts.map +1 -1
- package/dist/primitives/composer.js +8 -1
- package/dist/primitives/composer.js.map +1 -1
- package/dist/primitives/message/MessagePartsGrouped.d.ts +8 -1
- package/dist/primitives/message/MessagePartsGrouped.d.ts.map +1 -1
- package/dist/primitives/message/MessagePartsGrouped.js +58 -278
- package/dist/primitives/message/MessagePartsGrouped.js.map +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.d.ts.map +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.js +5 -2
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.js.map +1 -1
- package/dist/primitives/thread/ThreadLoadEarlier.d.ts +19 -0
- package/dist/primitives/thread/ThreadLoadEarlier.d.ts.map +1 -0
- package/dist/primitives/thread/ThreadLoadEarlier.js +36 -0
- package/dist/primitives/thread/ThreadLoadEarlier.js.map +1 -0
- package/dist/primitives/thread/ThreadMessages.d.ts +1 -1
- package/dist/primitives/thread/ThreadMessages.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadMessages.js +2 -2
- package/dist/primitives/thread/ThreadViewport.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadViewport.js +4 -3
- package/dist/primitives/thread/ThreadViewport.js.map +1 -1
- package/dist/primitives/thread/topAnchor/useTopAnchorReserve.js +2 -2
- package/dist/primitives/thread/topAnchor/useTopAnchorReserve.js.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.d.ts.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.js +195 -17
- package/dist/primitives/thread/useThreadViewportAutoScroll.js.map +1 -1
- package/dist/primitives/thread.d.ts +2 -0
- package/dist/primitives/thread.d.ts.map +1 -1
- package/dist/primitives/thread.js +5 -2
- package/dist/primitives/thread.js.map +1 -1
- package/dist/sandbox-host/SandboxHost.d.ts.map +1 -1
- package/dist/sandbox-host/SandboxHost.js +9 -3
- package/dist/sandbox-host/SandboxHost.js.map +1 -1
- package/dist/unstable/useComposerInput.d.ts +7 -4
- package/dist/unstable/useComposerInput.d.ts.map +1 -1
- package/dist/unstable/useComposerInput.js +4 -4
- package/dist/unstable/useComposerInput.js.map +1 -1
- package/dist/unstable/useComposerInputHistory.d.ts +3 -2
- package/dist/unstable/useComposerInputHistory.d.ts.map +1 -1
- package/dist/unstable/useComposerInputHistory.js +2 -2
- package/dist/unstable/useComposerInputHistory.js.map +1 -1
- package/dist/unstable/useLiveCompletionAdapter.d.ts +3 -2
- package/dist/unstable/useLiveCompletionAdapter.d.ts.map +1 -1
- package/dist/unstable/useLiveCompletionAdapter.js +8 -7
- package/dist/unstable/useLiveCompletionAdapter.js.map +1 -1
- package/dist/unstable/useMentionAdapter.d.ts +12 -3
- package/dist/unstable/useMentionAdapter.d.ts.map +1 -1
- package/dist/unstable/useMentionAdapter.js +2 -2
- package/dist/unstable/useMentionAdapter.js.map +1 -1
- package/dist/unstable/useMessageStallDetection.d.ts +4 -2
- package/dist/unstable/useMessageStallDetection.d.ts.map +1 -1
- package/dist/unstable/useMessageStallDetection.js +12 -8
- package/dist/unstable/useMessageStallDetection.js.map +1 -1
- package/dist/unstable/useSlashCommandAdapter.d.ts +5 -2
- package/dist/unstable/useSlashCommandAdapter.d.ts.map +1 -1
- package/dist/unstable/useSlashCommandAdapter.js +5 -4
- package/dist/unstable/useSlashCommandAdapter.js.map +1 -1
- package/dist/unstable/webmcp/useWebMcpProvider.d.ts +4 -0
- package/dist/unstable/webmcp/useWebMcpProvider.d.ts.map +1 -1
- package/dist/unstable/webmcp/useWebMcpProvider.js +2 -0
- package/dist/unstable/webmcp/useWebMcpProvider.js.map +1 -1
- package/dist/utils/getSelectionMessageId.d.ts.map +1 -1
- package/dist/utils/getSelectionMessageId.js +31 -8
- package/dist/utils/getSelectionMessageId.js.map +1 -1
- package/dist/utils/hooks/useOnResizeContent.d.ts.map +1 -1
- package/dist/utils/hooks/useOnResizeContent.js +2 -22
- package/dist/utils/hooks/useOnResizeContent.js.map +1 -1
- package/dist/utils/smooth/useSmooth.js +6 -6
- package/dist/utils/smooth/useSmooth.js.map +1 -1
- package/dist/utils/useIsomorphicLayoutEffect.d.ts +3 -0
- package/dist/utils/useIsomorphicLayoutEffect.d.ts.map +1 -0
- package/dist/utils/useIsomorphicLayoutEffect.js +6 -0
- package/dist/utils/useIsomorphicLayoutEffect.js.map +1 -0
- package/package.json +12 -11
- package/src/hooks/useToolCallElapsed.test.tsx +37 -0
- package/src/hooks/useToolCallElapsed.ts +10 -7
- package/src/index.ts +47 -5
- package/src/mcp-apps/McpAppRenderer.tsx +3 -9
- package/src/mcp-apps/app-frame.test.tsx +38 -0
- package/src/mcp-apps/app-frame.tsx +5 -8
- package/src/mcp-apps/csp.test.ts +112 -0
- package/src/mcp-apps/csp.ts +124 -0
- package/src/mcp-apps/types.ts +1 -0
- package/src/model-context/frame/AssistantFrame.test.ts +45 -0
- package/src/model-context/frame/SPEC_AssistantFrame.md +1 -0
- package/src/model-context/makeAssistantVisible.test.tsx +315 -5
- package/src/model-context/makeAssistantVisible.tsx +43 -7
- package/src/primitives/assistantModal/AssistantModalRoot.tsx +1 -0
- package/src/primitives/attachment.ts +4 -1
- package/src/primitives/composer/ComposerCancel.focus.test.tsx +307 -0
- package/src/primitives/composer/ComposerCancel.ts +8 -1
- package/src/primitives/composer/ComposerInput.tsx +20 -2
- package/src/primitives/composer/ComposerRoot.tsx +6 -5
- package/src/primitives/composer/composerInputSelector.ts +4 -0
- package/src/primitives/composer/trigger/TriggerPopover.tsx +11 -11
- package/src/primitives/composer/trigger/TriggerPopoverAction.tsx +10 -13
- package/src/primitives/composer/trigger/TriggerPopoverCategories.tsx +2 -2
- package/src/primitives/composer/trigger/TriggerPopoverDirective.tsx +11 -14
- package/src/primitives/composer/trigger/TriggerPopoverExports.test.ts +61 -0
- package/src/primitives/composer/trigger/TriggerPopoverItems.tsx +3 -3
- package/src/primitives/composer/trigger/TriggerPopoverRootContext.tsx +8 -8
- package/src/primitives/composer/useComposerCancelWithFocus.ts +57 -0
- package/src/primitives/composer.ts +70 -15
- package/src/primitives/message/MessagePartsGrouped.test.tsx +106 -2
- package/src/primitives/message/MessagePartsGrouped.tsx +36 -134
- package/src/primitives/message/MessageRoot.test.tsx +125 -2
- package/src/primitives/selectionToolbar/SelectionToolbarRoot.test.tsx +20 -12
- package/src/primitives/selectionToolbar/SelectionToolbarRoot.tsx +6 -2
- package/src/primitives/thread/ThreadLoadEarlier.tsx +35 -0
- package/src/primitives/thread/ThreadMessages.tsx +1 -0
- package/src/primitives/thread/ThreadViewport.tsx +3 -3
- package/src/primitives/thread/topAnchor/useTopAnchorReserve.ts +2 -2
- package/src/primitives/thread/useThreadViewportAutoScroll.test.tsx +922 -68
- package/src/primitives/thread/useThreadViewportAutoScroll.ts +330 -56
- package/src/primitives/thread.ts +2 -0
- package/src/sandbox-host/SandboxHost.test.tsx +34 -0
- package/src/sandbox-host/SandboxHost.tsx +11 -12
- package/src/tests/toolCallTiming.test.tsx +19 -2
- package/src/unstable/useComposerInput.ts +7 -4
- package/src/unstable/useComposerInputHistory.ts +3 -2
- package/src/unstable/useLiveCompletionAdapter.ts +9 -14
- package/src/unstable/useMentionAdapter.ts +12 -3
- package/src/unstable/useMessageStallDetection.test.tsx +40 -0
- package/src/unstable/useMessageStallDetection.ts +14 -8
- package/src/unstable/useSlashCommandAdapter.ts +8 -4
- package/src/unstable/webmcp/useWebMcpProvider.ts +4 -0
- package/src/utils/getSelectionMessageId.test.ts +231 -0
- package/src/utils/getSelectionMessageId.ts +45 -7
- package/src/utils/hooks/useOnResizeContent.ts +2 -29
- package/src/utils/smooth/useSmooth.test.tsx +16 -5
- package/src/utils/smooth/useSmooth.ts +7 -7
- package/src/utils/useIsomorphicLayoutEffect.test.tsx +21 -0
- package/src/utils/useIsomorphicLayoutEffect.ts +9 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-frame.js","names":["c","_c","MutableRefObject","useEffect","useLayoutEffect","useRef","McpAppBridge","createMcpAppBridge","SandboxHost","SandboxBridge","SandboxHostApi","SandboxHostFrame","McpAppBridgeHandlers","McpAppFrameProps","McpAppHostContext","isRecord","DEFAULT_PRODUCT","INIT_TIMEOUT_MS","DEFAULT_MAX_HEIGHT","isPlainObject","value","Record","prototype","Object","getPrototypeOf","isSameHostContext","a","b","depth","is","Array","isArray","length","i","aKeys","keys","every","key","hasOwn","useBridgeNotify","bridgeRef","widgetReadyRef","pendingRef","lastSentRef","notify","t0","$","isEqual","undefined","t1","current","t2","LiveSnapshot","handlers","hostInfo","hostContext","input","output","FrameLifecycle","onInitialized","onSizeChange","params","width","height","buildLiveHandlers","initial","liveRef","lifecycle","live","has","K","out","defineProperty","get","allowedTools","enumerable","configurable","liveCall","NonNullable","p","fn","Error","callTool","readResource","listResources","openLink","sendMessage","updateModelContext","requestDisplayMode","onRequestTeardown","onLog","onError","e","McpAppFrame","app","resource","sandbox","maxHeight","lastSentInputRef","lastSentOutputRef","lastSentHostContextRef","pendingInputRef","pendingOutputRef","pendingHostContextRef","t3","t4","t5","Symbol","for","frame","host","initTimeoutId","flushPending","notifyToolInput","notifyToolResult","notifyHostContextChanged","wrappedHandlers","clearTimeout","setHeight","setTimeout","bridge","onMessage","dispose","createBridge","_temp","_temp2","_temp3","t6","html","t7","serverId","uri","t8","product","t9","t10","err","t11","meta","prefersBorder","t12","resourceUri","t13","b_2","v_1","v","b_1","v_0","b_0","_c"],"sources":["../../src/mcp-apps/app-frame.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type MutableRefObject,\n useEffect,\n useLayoutEffect,\n useRef,\n} from \"react\";\nimport { type McpAppBridge, createMcpAppBridge } from \"./bridge\";\nimport {\n SandboxHost,\n type SandboxBridge,\n type SandboxHostApi,\n type SandboxHostFrame,\n} from \"../sandbox-host/SandboxHost\";\nimport type {\n McpAppBridgeHandlers,\n McpAppFrameProps,\n McpAppHostContext,\n} from \"./types\";\nimport { isRecord } from \"@assistant-ui/core/internal\";\n\nconst DEFAULT_PRODUCT = \"assistant-ui-mcp-app\";\nconst INIT_TIMEOUT_MS = 5000;\nconst DEFAULT_MAX_HEIGHT = 800;\n\n// Only a plain object can be compared by its own keys. Structured clone carries\n// a Date, Map, or class instance to the widget intact, and those expose no\n// enumerable keys, so walking them would report two different values as equal.\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n if (!isRecord(value)) return false;\n const prototype = Object.getPrototypeOf(value);\n return prototype === null || prototype === Object.prototype;\n};\n\n// Hosts commonly rebuild an equal context object on every render, and the\n// widget cannot tell a repeated notification apart from a real change. The\n// open index signature on McpAppHostContext admits values JSON rejects (an\n// undefined property value is enough), so leaves the walk cannot compare fall\n// back to identity rather than failing the whole comparison.\nconst isSameHostContext = (a: unknown, b: unknown, depth = 0): boolean => {\n if (Object.is(a, b)) return true;\n if (depth > 100) return false;\n if (Array.isArray(a) || Array.isArray(b)) {\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length)\n return false;\n for (let i = 0; i < a.length; i++) {\n if (!isSameHostContext(a[i], b[i], depth + 1)) return false;\n }\n return true;\n }\n if (!isPlainObject(a) || !isPlainObject(b)) return false;\n const aKeys = Object.keys(a);\n return (\n aKeys.length === Object.keys(b).length &&\n aKeys.every(\n (key) =>\n Object.hasOwn(b, key) && isSameHostContext(a[key], b[key], depth + 1),\n )\n );\n};\n\nfunction useBridgeNotify<T>(\n value: T | undefined,\n bridgeRef: MutableRefObject<McpAppBridge | null>,\n widgetReadyRef: MutableRefObject<boolean>,\n pendingRef: MutableRefObject<T | undefined>,\n lastSentRef: MutableRefObject<T | undefined>,\n notify: (bridge: McpAppBridge, v: T) => void,\n isEqual: (sent: T | undefined, next: T) => boolean = Object.is,\n) {\n useEffect(() => {\n if (!bridgeRef.current) return;\n // Nothing to deliver, either because there is no value or because the\n // widget already holds it; a queued value here is superseded and would\n // otherwise flush after initialization as a stale update.\n if (value === undefined || isEqual(lastSentRef.current, value)) {\n pendingRef.current = undefined;\n return;\n }\n if (!widgetReadyRef.current) {\n pendingRef.current = value;\n return;\n }\n notify(bridgeRef.current, value);\n lastSentRef.current = value;\n // oxlint-disable-next-line react/exhaustive-deps -- refs are stable; notify and isEqual are assumed stable; re-run only when value changes\n }, [value]);\n}\n\ntype LiveSnapshot = {\n handlers: McpAppBridgeHandlers | undefined;\n hostInfo: McpAppFrameProps[\"hostInfo\"];\n hostContext: McpAppFrameProps[\"hostContext\"];\n input: unknown;\n output: unknown;\n};\n\ntype FrameLifecycle = {\n onInitialized: () => void;\n onSizeChange: (params: { width?: number; height?: number }) => void;\n};\n\n// Proxy each per-call handler through liveRef so the bridge always dispatches\n// to the latest handler reference (e.g. inline callbacks closing over state).\n// Capability presence is snapshot at mount: a handler added later requires a\n// remount (keyed on resource URI) to expose the capability to the widget.\n// allowedTools is the exception: it is never advertised in the ui/initialize\n// response, so it stays a live getter, which means this object must reach the\n// bridge uncopied and the frame passes its lifecycle work in rather than\n// wrapping the result.\nfunction buildLiveHandlers(\n initial: McpAppBridgeHandlers | undefined,\n liveRef: { readonly current: LiveSnapshot },\n lifecycle: FrameLifecycle,\n): McpAppBridgeHandlers {\n const live = () => liveRef.current.handlers;\n const has = <K extends keyof McpAppBridgeHandlers>(key: K) =>\n initial?.[key] !== undefined;\n const out: McpAppBridgeHandlers = {};\n Object.defineProperty(out, \"allowedTools\", {\n get: () => live()?.allowedTools,\n enumerable: true,\n configurable: true,\n });\n const liveCall = <K extends keyof McpAppBridgeHandlers>(\n key: K,\n ): NonNullable<McpAppBridgeHandlers[K]> =>\n ((p: unknown) => {\n const fn = live()?.[key] as ((p: unknown) => unknown) | undefined;\n if (!fn) {\n throw new Error(`${key} handler is no longer available`);\n }\n return fn(p);\n }) as NonNullable<McpAppBridgeHandlers[K]>;\n if (has(\"callTool\")) out.callTool = liveCall(\"callTool\");\n if (has(\"readResource\")) out.readResource = liveCall(\"readResource\");\n if (has(\"listResources\")) out.listResources = liveCall(\"listResources\");\n if (has(\"openLink\")) out.openLink = liveCall(\"openLink\");\n if (has(\"sendMessage\")) out.sendMessage = liveCall(\"sendMessage\");\n if (has(\"updateModelContext\"))\n out.updateModelContext = liveCall(\"updateModelContext\");\n if (has(\"requestDisplayMode\"))\n out.requestDisplayMode = liveCall(\"requestDisplayMode\");\n out.onSizeChange = (p) => {\n lifecycle.onSizeChange(p);\n live()?.onSizeChange?.(p);\n };\n out.onInitialized = () => {\n lifecycle.onInitialized();\n live()?.onInitialized?.();\n };\n out.onRequestTeardown = (p) => live()?.onRequestTeardown?.(p);\n out.onLog = (p) => live()?.onLog?.(p);\n out.onError = (e) => live()?.onError?.(e);\n return out;\n}\n\nexport function McpAppFrame({\n app,\n resource,\n input,\n output,\n sandbox,\n handlers,\n hostInfo,\n hostContext,\n maxHeight = DEFAULT_MAX_HEIGHT,\n}: McpAppFrameProps) {\n const bridgeRef = useRef<McpAppBridge | null>(null);\n const lastSentInputRef = useRef<unknown>(undefined);\n const lastSentOutputRef = useRef<unknown>(undefined);\n const lastSentHostContextRef = useRef<McpAppHostContext | undefined>(\n undefined,\n );\n // Per MCP Apps spec, the host should defer notifications until the widget\n // signals readiness via `notifications/initialized`. Until then, we record\n // pending values and flush them on init.\n const widgetReadyRef = useRef(false);\n const pendingInputRef = useRef<unknown>(undefined);\n const pendingOutputRef = useRef<unknown>(undefined);\n const pendingHostContextRef = useRef<McpAppHostContext | undefined>(\n undefined,\n );\n\n const liveRef = useRef<LiveSnapshot>({\n handlers,\n hostInfo,\n hostContext,\n input,\n output,\n });\n useLayoutEffect(() => {\n liveRef.current = {\n handlers,\n hostInfo,\n hostContext,\n input,\n output,\n };\n }, [handlers, hostInfo, hostContext, input, output]);\n\n const createBridge = (\n frame: SandboxHostFrame,\n host: SandboxHostApi,\n ): SandboxBridge => {\n const current = liveRef.current;\n let initTimeoutId: ReturnType<typeof setTimeout> | null = null;\n\n const flushPending = () => {\n if (widgetReadyRef.current) return;\n widgetReadyRef.current = true;\n const b = bridgeRef.current;\n if (!b) return;\n if (pendingInputRef.current !== undefined) {\n b.notifyToolInput(pendingInputRef.current);\n lastSentInputRef.current = pendingInputRef.current;\n pendingInputRef.current = undefined;\n }\n if (pendingOutputRef.current !== undefined) {\n b.notifyToolResult(pendingOutputRef.current);\n lastSentOutputRef.current = pendingOutputRef.current;\n pendingOutputRef.current = undefined;\n }\n if (pendingHostContextRef.current !== undefined) {\n b.notifyHostContextChanged(pendingHostContextRef.current);\n lastSentHostContextRef.current = pendingHostContextRef.current;\n pendingHostContextRef.current = undefined;\n }\n };\n\n const wrappedHandlers = buildLiveHandlers(current.handlers, liveRef, {\n onInitialized: () => {\n if (initTimeoutId !== null) {\n clearTimeout(initTimeoutId);\n initTimeoutId = null;\n }\n flushPending();\n },\n onSizeChange: (p) => {\n if (p.height != null) host.setHeight(p.height);\n },\n });\n\n // Safety net: if the widget never sends notifications/initialized (broken\n // or non-spec-compliant), flush the queue anyway so the host doesn't\n // appear hung.\n initTimeoutId = setTimeout(() => {\n initTimeoutId = null;\n flushPending();\n }, INIT_TIMEOUT_MS);\n\n const bridge = createMcpAppBridge({\n frame,\n handlers: wrappedHandlers,\n hostInfo: current.hostInfo,\n hostContext: current.hostContext,\n });\n bridgeRef.current = bridge;\n\n if (current.input !== undefined) pendingInputRef.current = current.input;\n if (current.output !== undefined) pendingOutputRef.current = current.output;\n // hostContext is delivered inside the ui/initialize response, where the\n // bridge defaults it to {}; recording that same normalized value keeps the\n // first later change from repeating what the widget already holds.\n lastSentHostContextRef.current = current.hostContext ?? {};\n\n return {\n onMessage: bridge.onMessage,\n dispose: () => {\n if (initTimeoutId !== null) {\n clearTimeout(initTimeoutId);\n initTimeoutId = null;\n }\n bridge.dispose();\n bridgeRef.current = null;\n lastSentInputRef.current = undefined;\n lastSentOutputRef.current = undefined;\n lastSentHostContextRef.current = undefined;\n widgetReadyRef.current = false;\n pendingInputRef.current = undefined;\n pendingOutputRef.current = undefined;\n pendingHostContextRef.current = undefined;\n },\n };\n };\n\n useBridgeNotify(\n input,\n bridgeRef,\n widgetReadyRef,\n pendingInputRef,\n lastSentInputRef,\n (b, v) => b.notifyToolInput(v),\n );\n useBridgeNotify(\n output,\n bridgeRef,\n widgetReadyRef,\n pendingOutputRef,\n lastSentOutputRef,\n (b, v) => b.notifyToolResult(v),\n );\n useBridgeNotify(\n hostContext,\n bridgeRef,\n widgetReadyRef,\n pendingHostContextRef,\n lastSentHostContextRef,\n (b, v) => b.notifyHostContextChanged(v),\n isSameHostContext,\n );\n\n return (\n <SandboxHost\n content={{ html: resource.html }}\n contentKey={\n app.serverId ? `${app.serverId} ${resource.uri}` : resource.uri\n }\n sandbox={{ ...sandbox, product: sandbox?.product ?? DEFAULT_PRODUCT }}\n maxHeight={maxHeight}\n createBridge={createBridge}\n onError={(err) => liveRef.current.handlers?.onError?.(err)}\n containerProps={{\n \"data-mcp-app-resource\": app.resourceUri,\n \"data-mcp-app-prefers-border\": resource.meta?.prefersBorder\n ? \"\"\n : undefined,\n }}\n />\n );\n}\n"],"mappings":";;;;;;;;AAsBA,MAAMgB,kBAAkB;AACxB,MAAMC,kBAAkB;AACxB,MAAMC,qBAAqB;AAK3B,MAAMC,iBAAiBC,UAAqD;CAC1E,IAAI,CAACL,SAASK,KAAK,GAAG,OAAO;CAC7B,MAAME,YAAYC,OAAOC,eAAeJ,KAAK;CAC7C,OAAOE,cAAc,QAAQA,cAAcC,OAAOD;AACpD;AAOA,MAAMG,qBAAqBC,GAAYC,GAAYC,QAAQ,MAAe;CACxE,I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,IAAA4F;CAAA,IAAA9F,EAAA,QAAAgD,IAAA+C,eAAA/F,EAAA,QAAA2F,KAAA;EAJCG,MAAA;GAAA,yBACW9C,IAAG+C;GAAY,+BACTJ;EAGjC;EAAC3F,EAAA,MAAAgD,IAAA+C;EAAA/F,EAAA,MAAA2F;EAAA3F,EAAA,MAAA8F;CAAA,OAAAA,MAAA9F,EAAA;CAAA,IAAAgG;CAAA,IAAAhG,EAAA,QAAAmD,aAAAnD,EAAA,QAAA8F,OAAA9F,EAAA,QAAAiF,MAAAjF,EAAA,QAAAmF,MAAAnF,EAAA,QAAAwF,IAAA;EAdHQ,MAAA,oBAAC,aAAD;GACW,SAAAf;GAEP,YAAAE;GAEO,SAAAK;GACErC;GACG0B;GACL,SAAAY;GACO,gBAAAK;EAKf,CAAA;EACD9F,EAAA,MAAAmD;EAAAnD,EAAA,MAAA8F;EAAA9F,EAAA,MAAAiF;EAAAjF,EAAA,MAAAmF;EAAAnF,EAAA,MAAAwF;EAAAxF,EAAA,MAAAgG;CAAA,OAAAA,MAAAhG,EAAA;CAAA,OAfFgG;AAeE;AA3KC,SAAAhB,OAAAiB,KAAAC,KAAA;CAAA,OAuJOrH,IAACwF,yBAA0B8B,GAAC;AAAC;AAvJpC,SAAApB,OAAAqB,KAAAC,KAAA;CAAA,OA+IOxH,IAACuF,iBAAkB+B,GAAC;AAAC;AA/I5B,SAAArB,MAAAwB,KAAAH,GAAA;CAAA,OAuIOtH,IAACsF,gBAAiBgC,CAAC;AAAC"}
|
|
1
|
+
{"version":3,"file":"app-frame.js","names":["c","_c","MutableRefObject","useEffect","useRef","useIsomorphicLayoutEffect","McpAppBridge","createMcpAppBridge","SandboxHost","SandboxBridge","SandboxHostApi","SandboxHostFrame","McpAppBridgeHandlers","McpAppFrameProps","McpAppHostContext","isRecord","applyMcpAppCsp","DEFAULT_PRODUCT","INIT_TIMEOUT_MS","DEFAULT_MAX_HEIGHT","isPlainObject","value","Record","prototype","Object","getPrototypeOf","isSameHostContext","a","b","depth","is","Array","isArray","length","i","aKeys","keys","every","key","hasOwn","useBridgeNotify","bridgeRef","widgetReadyRef","pendingRef","lastSentRef","notify","t0","$","isEqual","undefined","t1","current","t2","LiveSnapshot","handlers","hostInfo","hostContext","input","output","FrameLifecycle","onInitialized","onSizeChange","params","width","height","buildLiveHandlers","initial","liveRef","lifecycle","live","has","K","out","defineProperty","get","allowedTools","enumerable","configurable","liveCall","NonNullable","p","fn","Error","callTool","readResource","listResources","openLink","sendMessage","updateModelContext","requestDisplayMode","onRequestTeardown","onLog","onError","e","McpAppFrame","app","resource","sandbox","maxHeight","lastSentInputRef","lastSentOutputRef","lastSentHostContextRef","pendingInputRef","pendingOutputRef","pendingHostContextRef","t3","t4","t5","Symbol","for","frame","host","initTimeoutId","flushPending","notifyToolInput","notifyToolResult","notifyHostContextChanged","wrappedHandlers","clearTimeout","setHeight","setTimeout","bridge","onMessage","dispose","createBridge","_temp","_temp2","_temp3","t6","meta","csp","t7","html","t8","t9","serverId","uri","t10","product","t11","t12","err","t13","prefersBorder","t14","resourceUri","t15","b_2","v_1","v","b_1","v_0","b_0","_c"],"sources":["../../src/mcp-apps/app-frame.tsx"],"sourcesContent":["\"use client\";\n\nimport { type MutableRefObject, useEffect, useRef } from \"react\";\nimport { useIsomorphicLayoutEffect } from \"../utils/useIsomorphicLayoutEffect\";\nimport { type McpAppBridge, createMcpAppBridge } from \"./bridge\";\nimport {\n SandboxHost,\n type SandboxBridge,\n type SandboxHostApi,\n type SandboxHostFrame,\n} from \"../sandbox-host/SandboxHost\";\nimport type {\n McpAppBridgeHandlers,\n McpAppFrameProps,\n McpAppHostContext,\n} from \"./types\";\nimport { isRecord } from \"@assistant-ui/core/internal\";\nimport { applyMcpAppCsp } from \"./csp\";\n\nconst DEFAULT_PRODUCT = \"assistant-ui-mcp-app\";\nconst INIT_TIMEOUT_MS = 5000;\nconst DEFAULT_MAX_HEIGHT = 800;\n\n// Only a plain object can be compared by its own keys. Structured clone carries\n// a Date, Map, or class instance to the widget intact, and those expose no\n// enumerable keys, so walking them would report two different values as equal.\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n if (!isRecord(value)) return false;\n const prototype = Object.getPrototypeOf(value);\n return prototype === null || prototype === Object.prototype;\n};\n\n// Hosts commonly rebuild an equal context object on every render, and the\n// widget cannot tell a repeated notification apart from a real change. The\n// open index signature on McpAppHostContext admits values JSON rejects (an\n// undefined property value is enough), so leaves the walk cannot compare fall\n// back to identity rather than failing the whole comparison.\nconst isSameHostContext = (a: unknown, b: unknown, depth = 0): boolean => {\n if (Object.is(a, b)) return true;\n if (depth > 100) return false;\n if (Array.isArray(a) || Array.isArray(b)) {\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length)\n return false;\n for (let i = 0; i < a.length; i++) {\n if (!isSameHostContext(a[i], b[i], depth + 1)) return false;\n }\n return true;\n }\n if (!isPlainObject(a) || !isPlainObject(b)) return false;\n const aKeys = Object.keys(a);\n return (\n aKeys.length === Object.keys(b).length &&\n aKeys.every(\n (key) =>\n Object.hasOwn(b, key) && isSameHostContext(a[key], b[key], depth + 1),\n )\n );\n};\n\nfunction useBridgeNotify<T>(\n value: T | undefined,\n bridgeRef: MutableRefObject<McpAppBridge | null>,\n widgetReadyRef: MutableRefObject<boolean>,\n pendingRef: MutableRefObject<T | undefined>,\n lastSentRef: MutableRefObject<T | undefined>,\n notify: (bridge: McpAppBridge, v: T) => void,\n isEqual: (sent: T | undefined, next: T) => boolean = Object.is,\n) {\n useEffect(() => {\n if (!bridgeRef.current) return;\n // Nothing to deliver, either because there is no value or because the\n // widget already holds it; a queued value here is superseded and would\n // otherwise flush after initialization as a stale update.\n if (value === undefined || isEqual(lastSentRef.current, value)) {\n pendingRef.current = undefined;\n return;\n }\n if (!widgetReadyRef.current) {\n pendingRef.current = value;\n return;\n }\n notify(bridgeRef.current, value);\n lastSentRef.current = value;\n // oxlint-disable-next-line react/exhaustive-deps -- refs are stable; notify and isEqual are assumed stable; re-run only when value changes\n }, [value]);\n}\n\ntype LiveSnapshot = {\n handlers: McpAppBridgeHandlers | undefined;\n hostInfo: McpAppFrameProps[\"hostInfo\"];\n hostContext: McpAppFrameProps[\"hostContext\"];\n input: unknown;\n output: unknown;\n};\n\ntype FrameLifecycle = {\n onInitialized: () => void;\n onSizeChange: (params: { width?: number; height?: number }) => void;\n};\n\n// Proxy each per-call handler through liveRef so the bridge always dispatches\n// to the latest handler reference (e.g. inline callbacks closing over state).\n// Capability presence is snapshot at mount: a handler added later requires a\n// remount (keyed on resource URI) to expose the capability to the widget.\n// allowedTools is the exception: it is never advertised in the ui/initialize\n// response, so it stays a live getter, which means this object must reach the\n// bridge uncopied and the frame passes its lifecycle work in rather than\n// wrapping the result.\nfunction buildLiveHandlers(\n initial: McpAppBridgeHandlers | undefined,\n liveRef: { readonly current: LiveSnapshot },\n lifecycle: FrameLifecycle,\n): McpAppBridgeHandlers {\n const live = () => liveRef.current.handlers;\n const has = <K extends keyof McpAppBridgeHandlers>(key: K) =>\n initial?.[key] !== undefined;\n const out: McpAppBridgeHandlers = {};\n Object.defineProperty(out, \"allowedTools\", {\n get: () => live()?.allowedTools,\n enumerable: true,\n configurable: true,\n });\n const liveCall = <K extends keyof McpAppBridgeHandlers>(\n key: K,\n ): NonNullable<McpAppBridgeHandlers[K]> =>\n ((p: unknown) => {\n const fn = live()?.[key] as ((p: unknown) => unknown) | undefined;\n if (!fn) {\n throw new Error(`${key} handler is no longer available`);\n }\n return fn(p);\n }) as NonNullable<McpAppBridgeHandlers[K]>;\n if (has(\"callTool\")) out.callTool = liveCall(\"callTool\");\n if (has(\"readResource\")) out.readResource = liveCall(\"readResource\");\n if (has(\"listResources\")) out.listResources = liveCall(\"listResources\");\n if (has(\"openLink\")) out.openLink = liveCall(\"openLink\");\n if (has(\"sendMessage\")) out.sendMessage = liveCall(\"sendMessage\");\n if (has(\"updateModelContext\"))\n out.updateModelContext = liveCall(\"updateModelContext\");\n if (has(\"requestDisplayMode\"))\n out.requestDisplayMode = liveCall(\"requestDisplayMode\");\n out.onSizeChange = (p) => {\n lifecycle.onSizeChange(p);\n live()?.onSizeChange?.(p);\n };\n out.onInitialized = () => {\n lifecycle.onInitialized();\n live()?.onInitialized?.();\n };\n out.onRequestTeardown = (p) => live()?.onRequestTeardown?.(p);\n out.onLog = (p) => live()?.onLog?.(p);\n out.onError = (e) => live()?.onError?.(e);\n return out;\n}\n\nexport function McpAppFrame({\n app,\n resource,\n input,\n output,\n sandbox,\n handlers,\n hostInfo,\n hostContext,\n maxHeight = DEFAULT_MAX_HEIGHT,\n}: McpAppFrameProps) {\n const bridgeRef = useRef<McpAppBridge | null>(null);\n const lastSentInputRef = useRef<unknown>(undefined);\n const lastSentOutputRef = useRef<unknown>(undefined);\n const lastSentHostContextRef = useRef<McpAppHostContext | undefined>(\n undefined,\n );\n // Per MCP Apps spec, the host should defer notifications until the widget\n // signals readiness via `notifications/initialized`. Until then, we record\n // pending values and flush them on init.\n const widgetReadyRef = useRef(false);\n const pendingInputRef = useRef<unknown>(undefined);\n const pendingOutputRef = useRef<unknown>(undefined);\n const pendingHostContextRef = useRef<McpAppHostContext | undefined>(\n undefined,\n );\n\n const liveRef = useRef<LiveSnapshot>({\n handlers,\n hostInfo,\n hostContext,\n input,\n output,\n });\n useIsomorphicLayoutEffect(() => {\n liveRef.current = {\n handlers,\n hostInfo,\n hostContext,\n input,\n output,\n };\n }, [handlers, hostInfo, hostContext, input, output]);\n\n const createBridge = (\n frame: SandboxHostFrame,\n host: SandboxHostApi,\n ): SandboxBridge => {\n const current = liveRef.current;\n let initTimeoutId: ReturnType<typeof setTimeout> | null = null;\n\n const flushPending = () => {\n if (widgetReadyRef.current) return;\n widgetReadyRef.current = true;\n const b = bridgeRef.current;\n if (!b) return;\n if (pendingInputRef.current !== undefined) {\n b.notifyToolInput(pendingInputRef.current);\n lastSentInputRef.current = pendingInputRef.current;\n pendingInputRef.current = undefined;\n }\n if (pendingOutputRef.current !== undefined) {\n b.notifyToolResult(pendingOutputRef.current);\n lastSentOutputRef.current = pendingOutputRef.current;\n pendingOutputRef.current = undefined;\n }\n if (pendingHostContextRef.current !== undefined) {\n b.notifyHostContextChanged(pendingHostContextRef.current);\n lastSentHostContextRef.current = pendingHostContextRef.current;\n pendingHostContextRef.current = undefined;\n }\n };\n\n const wrappedHandlers = buildLiveHandlers(current.handlers, liveRef, {\n onInitialized: () => {\n if (initTimeoutId !== null) {\n clearTimeout(initTimeoutId);\n initTimeoutId = null;\n }\n flushPending();\n },\n onSizeChange: (p) => {\n if (p.height != null) host.setHeight(p.height);\n },\n });\n\n // Safety net: if the widget never sends notifications/initialized (broken\n // or non-spec-compliant), flush the queue anyway so the host doesn't\n // appear hung.\n initTimeoutId = setTimeout(() => {\n initTimeoutId = null;\n flushPending();\n }, INIT_TIMEOUT_MS);\n\n const bridge = createMcpAppBridge({\n frame,\n handlers: wrappedHandlers,\n hostInfo: current.hostInfo,\n hostContext: current.hostContext,\n });\n bridgeRef.current = bridge;\n\n if (current.input !== undefined) pendingInputRef.current = current.input;\n if (current.output !== undefined) pendingOutputRef.current = current.output;\n // hostContext is delivered inside the ui/initialize response, where the\n // bridge defaults it to {}; recording that same normalized value keeps the\n // first later change from repeating what the widget already holds.\n lastSentHostContextRef.current = current.hostContext ?? {};\n\n return {\n onMessage: bridge.onMessage,\n dispose: () => {\n if (initTimeoutId !== null) {\n clearTimeout(initTimeoutId);\n initTimeoutId = null;\n }\n bridge.dispose();\n bridgeRef.current = null;\n lastSentInputRef.current = undefined;\n lastSentOutputRef.current = undefined;\n lastSentHostContextRef.current = undefined;\n widgetReadyRef.current = false;\n pendingInputRef.current = undefined;\n pendingOutputRef.current = undefined;\n pendingHostContextRef.current = undefined;\n },\n };\n };\n\n useBridgeNotify(\n input,\n bridgeRef,\n widgetReadyRef,\n pendingInputRef,\n lastSentInputRef,\n (b, v) => b.notifyToolInput(v),\n );\n useBridgeNotify(\n output,\n bridgeRef,\n widgetReadyRef,\n pendingOutputRef,\n lastSentOutputRef,\n (b, v) => b.notifyToolResult(v),\n );\n useBridgeNotify(\n hostContext,\n bridgeRef,\n widgetReadyRef,\n pendingHostContextRef,\n lastSentHostContextRef,\n (b, v) => b.notifyHostContextChanged(v),\n isSameHostContext,\n );\n\n return (\n <SandboxHost\n content={{ html: applyMcpAppCsp(resource.html, resource.meta?.csp) }}\n contentKey={\n app.serverId ? `${app.serverId} ${resource.uri}` : resource.uri\n }\n sandbox={{ ...sandbox, product: sandbox?.product ?? DEFAULT_PRODUCT }}\n maxHeight={maxHeight}\n createBridge={createBridge}\n onError={(err) => liveRef.current.handlers?.onError?.(err)}\n containerProps={{\n \"data-mcp-app-resource\": app.resourceUri,\n \"data-mcp-app-prefers-border\": resource.meta?.prefersBorder\n ? \"\"\n : undefined,\n }}\n />\n );\n}\n"],"mappings":";;;;;;;;;;AAmBA,MAAMiB,kBAAkB;AACxB,MAAMC,kBAAkB;AACxB,MAAMC,qBAAqB;AAK3B,MAAMC,iBAAiBC,UAAqD;CAC1E,IAAI,CAACN,SAASM,KAAK,GAAG,OAAO;CAC7B,MAAME,YAAYC,OAAOC,eAAeJ,KAAK;CAC7C,OAAOE,cAAc,QAAQA,cAAcC,OAAOD;AACpD;AAOA,MAAMG,qBAAqBC,GAAYC,GAAYC,QAAQ,MAAe;CACxE,IAAIL,OAAOM,GAAGH,GAAGC,CAAC,GAAG,OAAO;CAC5B,IAAIC,QAAQ,KAAK,OAAO;CACxB,IAAIE,MAAMC,QAAQL,CAAC,KAAKI,MAAMC,QAAQJ,CAAC,GAAG;EACxC,IAAI,CAACG,MAAMC,QAAQL,CAAC,KAAK,CAACI,MAAMC,QAAQJ,CAAC,KAAKD,EAAEM,WAAWL,EAAEK,QAC3D,OAAO;EACT,KAAK,IAAIC,IAAI,GAAGA,IAAIP,EAAEM,QAAQC,KAC5B,IAAI,CAACR,kBAAkBC,EAAEO,IAAIN,EAAEM,IAAIL,QAAQ,CAAC,GAAG,OAAO;EAExD,OAAO;CACT;CACA,IAAI,CAACT,cA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AA/F,EAAA,MAAAiG;CAAA,OAAAA,MAAAjG,EAAA;CAAA,IAAAmG;CAAA,IAAAnG,EAAA,QAAAmD,aAAAnD,EAAA,QAAA4F,OAAA5F,EAAA,QAAAiG,OAAAjG,EAAA,QAAAsF,MAAAtF,EAAA,QAAAuF,IAAA;EAdHY,MAAA,oBAAC,aAAD;GACW,SAAAb;GAEP,YAAAC;GAEO,SAAAK;GACEzC;GACG0B;GACL,SAAAgB;GACO,gBAAAI;EAKf,CAAA;EACDjG,EAAA,MAAAmD;EAAAnD,EAAA,MAAA4F;EAAA5F,EAAA,MAAAiG;EAAAjG,EAAA,MAAAsF;EAAAtF,EAAA,MAAAuF;EAAAvF,EAAA,MAAAmG;CAAA,OAAAA,MAAAnG,EAAA;CAAA,OAfFmG;AAeE;AA3KC,SAAAnB,OAAAoB,KAAAC,KAAA;CAAA,OAuJOxH,IAACwF,yBAA0BiC,GAAC;AAAC;AAvJpC,SAAAvB,OAAAwB,KAAAC,KAAA;CAAA,OA+IO3H,IAACuF,iBAAkBkC,GAAC;AAAC;AA/I5B,SAAAxB,MAAA2B,KAAAH,GAAA;CAAA,OAuIOzH,IAACsF,gBAAiBmC,CAAC;AAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csp.d.ts","sourceRoot":"","sources":["../../src/mcp-apps/csp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAgB;AAyCjD,eAAO,MAAM,cAAc,GAAI,MAAM,iBAAiB,KAAG,MAyBxD,CAAC;AAiDF,eAAO,MAAM,cAAc,GACzB,MAAM,MAAM,EACZ,MAAM,iBAAiB,KACtB,MAKF,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
//#region src/mcp-apps/csp.ts
|
|
2
|
+
const isAllowedOrigin = (value, allowWebSocket) => {
|
|
3
|
+
if (!(allowWebSocket ? /^(?:https?|wss?):\/\//i : /^https?:\/\//i).test(value) || /[\s;'"`,]/.test(value)) return false;
|
|
4
|
+
try {
|
|
5
|
+
const url = new URL(value.replace("://*.", "://wildcard."));
|
|
6
|
+
return url.username === "" && url.password === "" && url.pathname === "/" && url.search === "" && url.hash === "";
|
|
7
|
+
} catch {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
const getAllowedOrigins = (values, allowWebSocket = false) => Array.isArray(values) ? [...new Set(values.filter((value) => typeof value === "string" && isAllowedOrigin(value, allowWebSocket)))] : [];
|
|
12
|
+
const directive = (name, values) => `${name} ${values.join(" ")}`;
|
|
13
|
+
const buildMcpAppCsp = (csp) => {
|
|
14
|
+
const connectDomains = getAllowedOrigins(csp?.connectDomains, true);
|
|
15
|
+
const resourceDomains = getAllowedOrigins(csp?.resourceDomains);
|
|
16
|
+
const frameDomains = getAllowedOrigins(csp?.frameDomains);
|
|
17
|
+
const baseUriDomains = getAllowedOrigins(csp?.baseUriDomains);
|
|
18
|
+
return [
|
|
19
|
+
"default-src 'none'",
|
|
20
|
+
directive("script-src", [
|
|
21
|
+
"'self'",
|
|
22
|
+
"'unsafe-inline'",
|
|
23
|
+
...resourceDomains
|
|
24
|
+
]),
|
|
25
|
+
directive("style-src", [
|
|
26
|
+
"'self'",
|
|
27
|
+
"'unsafe-inline'",
|
|
28
|
+
...resourceDomains
|
|
29
|
+
]),
|
|
30
|
+
directive("connect-src", connectDomains.length > 0 ? ["'self'", ...connectDomains] : ["'none'"]),
|
|
31
|
+
directive("img-src", [
|
|
32
|
+
"'self'",
|
|
33
|
+
"data:",
|
|
34
|
+
...resourceDomains
|
|
35
|
+
]),
|
|
36
|
+
directive("font-src", ["'self'", ...resourceDomains]),
|
|
37
|
+
directive("media-src", [
|
|
38
|
+
"'self'",
|
|
39
|
+
"data:",
|
|
40
|
+
...resourceDomains
|
|
41
|
+
]),
|
|
42
|
+
directive("frame-src", frameDomains.length > 0 ? frameDomains : ["'none'"]),
|
|
43
|
+
directive("base-uri", baseUriDomains.length > 0 ? baseUriDomains : ["'self'"]),
|
|
44
|
+
"object-src 'none'",
|
|
45
|
+
"form-action 'none'"
|
|
46
|
+
].join("; ");
|
|
47
|
+
};
|
|
48
|
+
const findDoctypeEnd = (html) => {
|
|
49
|
+
let offset = 0;
|
|
50
|
+
while (offset < html.length) {
|
|
51
|
+
const whitespace = html.slice(offset).match(/^[\t\n\f\r ]+/)?.[0];
|
|
52
|
+
if (whitespace) {
|
|
53
|
+
offset += whitespace.length;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (html.startsWith("<!--", offset)) {
|
|
57
|
+
if (html.startsWith("<!-->", offset)) {
|
|
58
|
+
offset += 5;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (html.startsWith("<!--->", offset)) {
|
|
62
|
+
offset += 6;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const commentEnd = html.indexOf("-->", offset + 4);
|
|
66
|
+
const bangCommentEnd = html.indexOf("--!>", offset + 4);
|
|
67
|
+
if (commentEnd === -1 && bangCommentEnd === -1) return 0;
|
|
68
|
+
offset = bangCommentEnd !== -1 && (commentEnd === -1 || bangCommentEnd < commentEnd) ? bangCommentEnd + 4 : commentEnd + 3;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (html.slice(offset, offset + 9).toLowerCase() === "<!doctype") break;
|
|
72
|
+
if (html.startsWith("<?", offset) || html.startsWith("<!", offset)) {
|
|
73
|
+
const bogusCommentEnd = html.indexOf(">", offset + 2);
|
|
74
|
+
if (bogusCommentEnd === -1) return 0;
|
|
75
|
+
offset = bogusCommentEnd + 1;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
if (html.slice(offset, offset + 9).toLowerCase() !== "<!doctype") return offset;
|
|
81
|
+
const end = html.indexOf(">", offset + 9);
|
|
82
|
+
return end === -1 ? 0 : end + 1;
|
|
83
|
+
};
|
|
84
|
+
const applyMcpAppCsp = (html, csp) => {
|
|
85
|
+
const normalizedHtml = html.charCodeAt(0) === 65279 ? html.slice(1) : html;
|
|
86
|
+
const meta = `<meta http-equiv="Content-Security-Policy" content="${buildMcpAppCsp(csp)}">`;
|
|
87
|
+
const insertionPoint = findDoctypeEnd(normalizedHtml);
|
|
88
|
+
return `${normalizedHtml.slice(0, insertionPoint)}${meta}${normalizedHtml.slice(insertionPoint)}`;
|
|
89
|
+
};
|
|
90
|
+
//#endregion
|
|
91
|
+
export { applyMcpAppCsp, buildMcpAppCsp };
|
|
92
|
+
|
|
93
|
+
//# sourceMappingURL=csp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csp.js","names":["McpAppResourceCSP","isAllowedOrigin","value","allowWebSocket","scheme","test","url","URL","replace","username","password","pathname","search","hash","getAllowedOrigins","values","Array","isArray","Set","filter","directive","name","join","buildMcpAppCsp","csp","connectDomains","resourceDomains","frameDomains","baseUriDomains","length","findDoctypeEnd","html","offset","whitespace","slice","match","startsWith","commentEnd","indexOf","bangCommentEnd","toLowerCase","bogusCommentEnd","end","applyMcpAppCsp","normalizedHtml","charCodeAt","meta","insertionPoint"],"sources":["../../src/mcp-apps/csp.ts"],"sourcesContent":["import type { McpAppResourceCSP } from \"./types\";\n\nconst isAllowedOrigin = (value: string, allowWebSocket: boolean): boolean => {\n const scheme = allowWebSocket ? /^(?:https?|wss?):\\/\\//i : /^https?:\\/\\//i;\n if (!scheme.test(value) || /[\\s;'\"`,]/.test(value)) {\n return false;\n }\n\n try {\n const url = new URL(value.replace(\"://*.\", \"://wildcard.\"));\n return (\n url.username === \"\" &&\n url.password === \"\" &&\n url.pathname === \"/\" &&\n url.search === \"\" &&\n url.hash === \"\"\n );\n } catch {\n return false;\n }\n};\n\nconst getAllowedOrigins = (\n values: unknown,\n allowWebSocket = false,\n): string[] =>\n Array.isArray(values)\n ? [\n ...new Set(\n values.filter(\n (value): value is string =>\n typeof value === \"string\" &&\n isAllowedOrigin(value, allowWebSocket),\n ),\n ),\n ]\n : [];\n\nconst directive = (name: string, values: readonly string[]) =>\n `${name} ${values.join(\" \")}`;\n\nexport const buildMcpAppCsp = (csp?: McpAppResourceCSP): string => {\n const connectDomains = getAllowedOrigins(csp?.connectDomains, true);\n const resourceDomains = getAllowedOrigins(csp?.resourceDomains);\n const frameDomains = getAllowedOrigins(csp?.frameDomains);\n const baseUriDomains = getAllowedOrigins(csp?.baseUriDomains);\n\n return [\n \"default-src 'none'\",\n directive(\"script-src\", [\"'self'\", \"'unsafe-inline'\", ...resourceDomains]),\n directive(\"style-src\", [\"'self'\", \"'unsafe-inline'\", ...resourceDomains]),\n directive(\n \"connect-src\",\n connectDomains.length > 0 ? [\"'self'\", ...connectDomains] : [\"'none'\"],\n ),\n directive(\"img-src\", [\"'self'\", \"data:\", ...resourceDomains]),\n directive(\"font-src\", [\"'self'\", ...resourceDomains]),\n directive(\"media-src\", [\"'self'\", \"data:\", ...resourceDomains]),\n directive(\"frame-src\", frameDomains.length > 0 ? frameDomains : [\"'none'\"]),\n directive(\n \"base-uri\",\n baseUriDomains.length > 0 ? baseUriDomains : [\"'self'\"],\n ),\n \"object-src 'none'\",\n \"form-action 'none'\",\n ].join(\"; \");\n};\n\nconst findDoctypeEnd = (html: string): number => {\n let offset = 0;\n\n while (offset < html.length) {\n const whitespace = html.slice(offset).match(/^[\\t\\n\\f\\r ]+/)?.[0];\n if (whitespace) {\n offset += whitespace.length;\n continue;\n }\n if (html.startsWith(\"<!--\", offset)) {\n if (html.startsWith(\"<!-->\", offset)) {\n offset += 5;\n continue;\n }\n if (html.startsWith(\"<!--->\", offset)) {\n offset += 6;\n continue;\n }\n const commentEnd = html.indexOf(\"-->\", offset + 4);\n const bangCommentEnd = html.indexOf(\"--!>\", offset + 4);\n if (commentEnd === -1 && bangCommentEnd === -1) return 0;\n offset =\n bangCommentEnd !== -1 &&\n (commentEnd === -1 || bangCommentEnd < commentEnd)\n ? bangCommentEnd + 4\n : commentEnd + 3;\n continue;\n }\n if (html.slice(offset, offset + 9).toLowerCase() === \"<!doctype\") {\n break;\n }\n if (html.startsWith(\"<?\", offset) || html.startsWith(\"<!\", offset)) {\n const bogusCommentEnd = html.indexOf(\">\", offset + 2);\n if (bogusCommentEnd === -1) return 0;\n offset = bogusCommentEnd + 1;\n continue;\n }\n break;\n }\n\n if (html.slice(offset, offset + 9).toLowerCase() !== \"<!doctype\") {\n return offset;\n }\n const end = html.indexOf(\">\", offset + 9);\n return end === -1 ? 0 : end + 1;\n};\n\nexport const applyMcpAppCsp = (\n html: string,\n csp?: McpAppResourceCSP,\n): string => {\n const normalizedHtml = html.charCodeAt(0) === 0xfeff ? html.slice(1) : html;\n const meta = `<meta http-equiv=\"Content-Security-Policy\" content=\"${buildMcpAppCsp(csp)}\">`;\n const insertionPoint = findDoctypeEnd(normalizedHtml);\n return `${normalizedHtml.slice(0, insertionPoint)}${meta}${normalizedHtml.slice(insertionPoint)}`;\n};\n"],"mappings":";AAEA,MAAMC,mBAAmBC,OAAeC,mBAAqC;CAE3E,IAAI,EADWA,iBAAiB,2BAA2B,gBAAA,CAC/CE,KAAKH,KAAK,KAAK,YAAYG,KAAKH,KAAK,GAC/C,OAAO;CAGT,IAAI;EACF,MAAMI,MAAM,IAAIC,IAAIL,MAAMM,QAAQ,SAAS,cAAc,CAAC;EAC1D,OACEF,IAAIG,aAAa,MACjBH,IAAII,aAAa,MACjBJ,IAAIK,aAAa,OACjBL,IAAIM,WAAW,MACfN,IAAIO,SAAS;CAEjB,QAAQ;EACN,OAAO;CACT;AACF;AAEA,MAAMC,qBACJC,QACAZ,iBAAiB,UAEjBa,MAAMC,QAAQF,MAAM,IAChB,CACE,GAAG,IAAIG,IACLH,OAAOI,QACJjB,UACC,OAAOA,UAAU,YACjBD,gBAAgBC,OAAOC,cAAc,CACzC,CACF,CAAC,IAEH,CAAA;AAEN,MAAMiB,aAAaC,MAAcN,WAC/B,GAAGM,KAAI,GAAIN,OAAOO,KAAK,GAAG;AAE5B,MAAa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MAAM,CAAC,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,kBAAkB,CAAC;CAC3B,CAAC;AAEN,MAAM,MAAM,oBAAoB,GAC5B,oBAAoB,GACpB,yBAAyB,GACzB,qBAAqB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["McpAppMetadata","ToolCallMessagePartMcpMetadata","SandboxHostConfig","MCP_APP_MIME_TYPE","const","MCP_APP_PROTOCOL_VERSION","McpAppResourceCSP","connectDomains","resourceDomains","frameDomains","k","McpAppResourceMeta","prefersBorder","csp","permissions","Record","McpAppResource","uri","mimeType","html","meta","McpAppDisplayMode","McpAppHostContext","theme","displayMode","availableDisplayModes","McpAppHostInfo","name","version","McpAppsHost","loadResource","params","serverId","Promise","callTool","McpAppToolCallParams","readResource","listResources","McpAppsRemoteHostOptions","url","fetch","headers","arguments","McpAppBridgeHandlers","allowedTools","openLink","sendMessage","updateModelContext","requestDisplayMode","mode","onSizeChange","width","height","onInitialized","onRequestTeardown","onLog","onError","error","Error","McpAppSandboxConfig","McpAppFrameProps","app","resource","input","output","sandbox","handlers","hostInfo","hostContext","maxHeight","McpAppJsonRpcRequest","jsonrpc","id","method","McpAppJsonRpcNotification","McpAppJsonRpcError","code","message","data","McpAppJsonRpcResponse","result","McpAppJsonRpcMessage"],"sources":["../../src/mcp-apps/types.ts"],"sourcesContent":["import type {\n McpAppMetadata,\n ToolCallMessagePartMcpMetadata,\n} from \"@assistant-ui/core\";\nimport type { SandboxHostConfig } from \"../sandbox-host/SandboxHost\";\n\nexport type { McpAppMetadata, ToolCallMessagePartMcpMetadata };\n\nexport const MCP_APP_MIME_TYPE = \"text/html;profile=mcp-app\" as const;\n\nexport const MCP_APP_PROTOCOL_VERSION = \"0.1\" as const;\n\nexport type McpAppResourceCSP = {\n connectDomains?: string[];\n resourceDomains?: string[];\n frameDomains?: string[];\n [k: string]: unknown;\n};\n\nexport type McpAppResourceMeta = {\n prefersBorder?: boolean;\n csp?: McpAppResourceCSP;\n permissions?: Record<string, unknown>;\n [k: string]: unknown;\n};\n\nexport type McpAppResource = {\n uri: string;\n mimeType: typeof MCP_APP_MIME_TYPE;\n html: string;\n meta?: McpAppResourceMeta;\n};\n\nexport type McpAppDisplayMode = \"inline\" | \"fullscreen\" | \"pip\";\n\nexport type McpAppHostContext = {\n theme?: \"light\" | \"dark\";\n displayMode?: McpAppDisplayMode;\n availableDisplayModes?: McpAppDisplayMode[];\n [k: string]: unknown;\n};\n\nexport type McpAppHostInfo = {\n name: string;\n version: string;\n};\n\n/**\n * What `McpAppRenderer` needs from its host — the data-plane operations\n * the widget can request. Provided by a host resource like\n * `McpAppsRemoteHost`.\n */\nexport type McpAppsHost = {\n loadResource: (params: {\n uri: string;\n serverId?: string;\n }) => Promise<McpAppResource>;\n callTool: (\n params: McpAppToolCallParams & { serverId?: string },\n ) => Promise<unknown>;\n readResource: (params: {\n uri: string;\n serverId?: string;\n }) => Promise<unknown>;\n listResources: (params?: unknown) => Promise<unknown>;\n};\n\n/**\n * Options for `McpAppsRemoteHost`. The host POSTs `{ method, params }` to\n * `url` and expects JSON responses. Params may carry `serverId` for host-side routing. Method names sent:\n * - `mcp-apps/read-resource` (`{ uri, serverId? }`) → `McpAppResource`\n * - `tools/call` (`{ name, arguments?, serverId? }`) → tool result\n * - `resources/read` (`{ uri, serverId? }`) → resource read result\n * - `resources/list` (`{ serverId?, ...params }?`) → list result\n */\nexport type McpAppsRemoteHostOptions = {\n url: string;\n fetch?: typeof fetch;\n headers?:\n | Record<string, string>\n | (() => Record<string, string> | Promise<Record<string, string>>);\n};\n\nexport type McpAppToolCallParams = {\n name: string;\n arguments?: Record<string, unknown>;\n};\n\nexport type McpAppBridgeHandlers = {\n allowedTools?: readonly string[];\n callTool?: (params: McpAppToolCallParams) => Promise<unknown> | unknown;\n readResource?: (params: { uri: string }) => Promise<unknown> | unknown;\n listResources?: (params?: unknown) => Promise<unknown> | unknown;\n openLink?: (params: { url: string }) => Promise<unknown> | unknown;\n sendMessage?: (params: unknown) => Promise<unknown> | unknown;\n updateModelContext?: (params: unknown) => Promise<unknown> | unknown;\n requestDisplayMode?: (params: {\n mode: McpAppDisplayMode;\n }) => Promise<{ mode: McpAppDisplayMode }> | { mode: McpAppDisplayMode };\n onSizeChange?: (params: { width?: number; height?: number }) => void;\n onInitialized?: () => void;\n onRequestTeardown?: (params: unknown) => void;\n onLog?: (params: unknown) => void;\n onError?: (error: Error) => void;\n};\n\nexport type McpAppSandboxConfig = SandboxHostConfig;\n\nexport type McpAppFrameProps = {\n app: McpAppMetadata;\n resource: McpAppResource;\n input?: unknown;\n output?: unknown;\n sandbox?: McpAppSandboxConfig | undefined;\n handlers?: McpAppBridgeHandlers | undefined;\n hostInfo?: McpAppHostInfo | undefined;\n hostContext?: McpAppHostContext | undefined;\n /**\n * Upper bound (in pixels) for the auto-resize height driven by the widget's\n * `notifications/size_changed`. Defaults to 800.\n */\n maxHeight?: number | undefined;\n};\n\nexport type McpAppJsonRpcRequest = {\n jsonrpc: \"2.0\";\n id: string | number;\n method: string;\n params?: unknown;\n};\n\nexport type McpAppJsonRpcNotification = {\n jsonrpc: \"2.0\";\n method: string;\n params?: unknown;\n};\n\nexport type McpAppJsonRpcError = {\n code: number;\n message: string;\n data?: unknown;\n};\n\nexport type McpAppJsonRpcResponse =\n | {\n jsonrpc: \"2.0\";\n id: string | number;\n result: unknown;\n error?: never;\n }\n | {\n jsonrpc: \"2.0\";\n id: string | number;\n result?: never;\n error: McpAppJsonRpcError;\n };\n\nexport type McpAppJsonRpcMessage =\n | McpAppJsonRpcRequest\n | McpAppJsonRpcNotification\n | McpAppJsonRpcResponse;\n"],"mappings":";AAQA,MAAaG,oBAAoB;AAEjC,MAAaE,2BAA2B"}
|
|
1
|
+
{"version":3,"file":"types.js","names":["McpAppMetadata","ToolCallMessagePartMcpMetadata","SandboxHostConfig","MCP_APP_MIME_TYPE","const","MCP_APP_PROTOCOL_VERSION","McpAppResourceCSP","connectDomains","resourceDomains","frameDomains","baseUriDomains","k","McpAppResourceMeta","prefersBorder","csp","permissions","Record","McpAppResource","uri","mimeType","html","meta","McpAppDisplayMode","McpAppHostContext","theme","displayMode","availableDisplayModes","McpAppHostInfo","name","version","McpAppsHost","loadResource","params","serverId","Promise","callTool","McpAppToolCallParams","readResource","listResources","McpAppsRemoteHostOptions","url","fetch","headers","arguments","McpAppBridgeHandlers","allowedTools","openLink","sendMessage","updateModelContext","requestDisplayMode","mode","onSizeChange","width","height","onInitialized","onRequestTeardown","onLog","onError","error","Error","McpAppSandboxConfig","McpAppFrameProps","app","resource","input","output","sandbox","handlers","hostInfo","hostContext","maxHeight","McpAppJsonRpcRequest","jsonrpc","id","method","McpAppJsonRpcNotification","McpAppJsonRpcError","code","message","data","McpAppJsonRpcResponse","result","McpAppJsonRpcMessage"],"sources":["../../src/mcp-apps/types.ts"],"sourcesContent":["import type {\n McpAppMetadata,\n ToolCallMessagePartMcpMetadata,\n} from \"@assistant-ui/core\";\nimport type { SandboxHostConfig } from \"../sandbox-host/SandboxHost\";\n\nexport type { McpAppMetadata, ToolCallMessagePartMcpMetadata };\n\nexport const MCP_APP_MIME_TYPE = \"text/html;profile=mcp-app\" as const;\n\nexport const MCP_APP_PROTOCOL_VERSION = \"0.1\" as const;\n\nexport type McpAppResourceCSP = {\n connectDomains?: string[];\n resourceDomains?: string[];\n frameDomains?: string[];\n baseUriDomains?: string[];\n [k: string]: unknown;\n};\n\nexport type McpAppResourceMeta = {\n prefersBorder?: boolean;\n csp?: McpAppResourceCSP;\n permissions?: Record<string, unknown>;\n [k: string]: unknown;\n};\n\nexport type McpAppResource = {\n uri: string;\n mimeType: typeof MCP_APP_MIME_TYPE;\n html: string;\n meta?: McpAppResourceMeta;\n};\n\nexport type McpAppDisplayMode = \"inline\" | \"fullscreen\" | \"pip\";\n\nexport type McpAppHostContext = {\n theme?: \"light\" | \"dark\";\n displayMode?: McpAppDisplayMode;\n availableDisplayModes?: McpAppDisplayMode[];\n [k: string]: unknown;\n};\n\nexport type McpAppHostInfo = {\n name: string;\n version: string;\n};\n\n/**\n * What `McpAppRenderer` needs from its host — the data-plane operations\n * the widget can request. Provided by a host resource like\n * `McpAppsRemoteHost`.\n */\nexport type McpAppsHost = {\n loadResource: (params: {\n uri: string;\n serverId?: string;\n }) => Promise<McpAppResource>;\n callTool: (\n params: McpAppToolCallParams & { serverId?: string },\n ) => Promise<unknown>;\n readResource: (params: {\n uri: string;\n serverId?: string;\n }) => Promise<unknown>;\n listResources: (params?: unknown) => Promise<unknown>;\n};\n\n/**\n * Options for `McpAppsRemoteHost`. The host POSTs `{ method, params }` to\n * `url` and expects JSON responses. Params may carry `serverId` for host-side routing. Method names sent:\n * - `mcp-apps/read-resource` (`{ uri, serverId? }`) → `McpAppResource`\n * - `tools/call` (`{ name, arguments?, serverId? }`) → tool result\n * - `resources/read` (`{ uri, serverId? }`) → resource read result\n * - `resources/list` (`{ serverId?, ...params }?`) → list result\n */\nexport type McpAppsRemoteHostOptions = {\n url: string;\n fetch?: typeof fetch;\n headers?:\n | Record<string, string>\n | (() => Record<string, string> | Promise<Record<string, string>>);\n};\n\nexport type McpAppToolCallParams = {\n name: string;\n arguments?: Record<string, unknown>;\n};\n\nexport type McpAppBridgeHandlers = {\n allowedTools?: readonly string[];\n callTool?: (params: McpAppToolCallParams) => Promise<unknown> | unknown;\n readResource?: (params: { uri: string }) => Promise<unknown> | unknown;\n listResources?: (params?: unknown) => Promise<unknown> | unknown;\n openLink?: (params: { url: string }) => Promise<unknown> | unknown;\n sendMessage?: (params: unknown) => Promise<unknown> | unknown;\n updateModelContext?: (params: unknown) => Promise<unknown> | unknown;\n requestDisplayMode?: (params: {\n mode: McpAppDisplayMode;\n }) => Promise<{ mode: McpAppDisplayMode }> | { mode: McpAppDisplayMode };\n onSizeChange?: (params: { width?: number; height?: number }) => void;\n onInitialized?: () => void;\n onRequestTeardown?: (params: unknown) => void;\n onLog?: (params: unknown) => void;\n onError?: (error: Error) => void;\n};\n\nexport type McpAppSandboxConfig = SandboxHostConfig;\n\nexport type McpAppFrameProps = {\n app: McpAppMetadata;\n resource: McpAppResource;\n input?: unknown;\n output?: unknown;\n sandbox?: McpAppSandboxConfig | undefined;\n handlers?: McpAppBridgeHandlers | undefined;\n hostInfo?: McpAppHostInfo | undefined;\n hostContext?: McpAppHostContext | undefined;\n /**\n * Upper bound (in pixels) for the auto-resize height driven by the widget's\n * `notifications/size_changed`. Defaults to 800.\n */\n maxHeight?: number | undefined;\n};\n\nexport type McpAppJsonRpcRequest = {\n jsonrpc: \"2.0\";\n id: string | number;\n method: string;\n params?: unknown;\n};\n\nexport type McpAppJsonRpcNotification = {\n jsonrpc: \"2.0\";\n method: string;\n params?: unknown;\n};\n\nexport type McpAppJsonRpcError = {\n code: number;\n message: string;\n data?: unknown;\n};\n\nexport type McpAppJsonRpcResponse =\n | {\n jsonrpc: \"2.0\";\n id: string | number;\n result: unknown;\n error?: never;\n }\n | {\n jsonrpc: \"2.0\";\n id: string | number;\n result?: never;\n error: McpAppJsonRpcError;\n };\n\nexport type McpAppJsonRpcMessage =\n | McpAppJsonRpcRequest\n | McpAppJsonRpcNotification\n | McpAppJsonRpcResponse;\n"],"mappings":";AAQA,MAAaG,oBAAoB;AAEjC,MAAaE,2BAA2B"}
|
|
@@ -2,6 +2,7 @@ import { type ComponentType } from "react";
|
|
|
2
2
|
export declare const makeAssistantVisible: <T extends ComponentType<any>>(Component: T, config?: {
|
|
3
3
|
clickable?: boolean | undefined;
|
|
4
4
|
editable?: boolean | undefined;
|
|
5
|
+
settleDelayMs?: number | undefined;
|
|
5
6
|
}) => T;
|
|
6
7
|
export default makeAssistantVisible;
|
|
7
8
|
//# sourceMappingURL=makeAssistantVisible.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makeAssistantVisible.d.ts","sourceRoot":"","sources":["../../src/model-context/makeAssistantVisible.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,aAAa,EAMnB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"makeAssistantVisible.d.ts","sourceRoot":"","sources":["../../src/model-context/makeAssistantVisible.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,aAAa,EAMnB,MAAM,OAAO,CAAC;AAgGf,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,aAAa,CAAC,GAAG,CAAC,EAC/D,WAAW,CAAC,EACZ,SAAS;IACP,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC,KA4DsC,CACxC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -6,6 +6,17 @@ import { jsx } from "react/jsx-runtime";
|
|
|
6
6
|
import { tool } from "@assistant-ui/core";
|
|
7
7
|
import { useComposedRefs } from "radix-ui/internal";
|
|
8
8
|
//#region src/model-context/makeAssistantVisible.tsx
|
|
9
|
+
const DEFAULT_ACTION_SETTLE_DELAY_MS = 2e3;
|
|
10
|
+
const MAX_ACTION_SETTLE_DELAY_MS = 2147483647;
|
|
11
|
+
const waitForSettle = async (settleDelayMs) => {
|
|
12
|
+
const delay = Number.isFinite(settleDelayMs) && settleDelayMs >= 0 && settleDelayMs <= MAX_ACTION_SETTLE_DELAY_MS ? settleDelayMs : DEFAULT_ACTION_SETTLE_DELAY_MS;
|
|
13
|
+
if (delay === 0) return;
|
|
14
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
15
|
+
};
|
|
16
|
+
const readActionSettleDelay = (element) => {
|
|
17
|
+
const value = element.dataset.actionSettleDelay;
|
|
18
|
+
return value === void 0 || value.trim() === "" ? DEFAULT_ACTION_SETTLE_DELAY_MS : Number(value);
|
|
19
|
+
};
|
|
9
20
|
const click = tool({
|
|
10
21
|
parameters: {
|
|
11
22
|
type: "object",
|
|
@@ -17,7 +28,7 @@ const click = tool({
|
|
|
17
28
|
const el = document.querySelector(`[data-click-id='${escapedClickId}']`);
|
|
18
29
|
if (el instanceof HTMLElement) {
|
|
19
30
|
el.click();
|
|
20
|
-
await
|
|
31
|
+
await waitForSettle(readActionSettleDelay(el));
|
|
21
32
|
return {};
|
|
22
33
|
} else return "Element not found";
|
|
23
34
|
}
|
|
@@ -44,15 +55,17 @@ const edit = tool({
|
|
|
44
55
|
setNativeValue(el, value);
|
|
45
56
|
el.dispatchEvent(new Event("input", { bubbles: true }));
|
|
46
57
|
el.dispatchEvent(new Event("change", { bubbles: true }));
|
|
47
|
-
await
|
|
58
|
+
await waitForSettle(readActionSettleDelay(el));
|
|
48
59
|
return {};
|
|
49
60
|
} else return "Element not found";
|
|
50
61
|
}
|
|
51
62
|
});
|
|
52
63
|
const ReadableContext = createContext(false);
|
|
53
64
|
const makeAssistantVisible = (Component, config) => {
|
|
65
|
+
const settleDelayMs = config?.settleDelayMs ?? DEFAULT_ACTION_SETTLE_DELAY_MS;
|
|
66
|
+
if (!Number.isFinite(settleDelayMs) || settleDelayMs < 0 || settleDelayMs > MAX_ACTION_SETTLE_DELAY_MS) throw new RangeError(`settleDelayMs must be between 0 and ${MAX_ACTION_SETTLE_DELAY_MS}`);
|
|
54
67
|
const ReadableComponent = forwardRef((props, outerRef) => {
|
|
55
|
-
const $ = c(
|
|
68
|
+
const $ = c(16);
|
|
56
69
|
const isNestedReadable = useContext(ReadableContext);
|
|
57
70
|
const clickId = useId();
|
|
58
71
|
const componentRef = useRef(null);
|
|
@@ -104,23 +117,29 @@ const makeAssistantVisible = (Component, config) => {
|
|
|
104
117
|
t5 = $[9];
|
|
105
118
|
}
|
|
106
119
|
let t6;
|
|
107
|
-
if ($[10]
|
|
108
|
-
t6 =
|
|
120
|
+
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
121
|
+
t6 = config?.settleDelayMs !== void 0 && (config.clickable || config.editable) ? { "data-action-settle-delay": settleDelayMs } : {};
|
|
122
|
+
$[10] = t6;
|
|
123
|
+
} else t6 = $[10];
|
|
124
|
+
let t7;
|
|
125
|
+
if ($[11] !== ref || $[12] !== t3 || $[13] !== t4 || $[14] !== t5) {
|
|
126
|
+
t7 = /* @__PURE__ */ jsx(ReadableContext.Provider, {
|
|
109
127
|
value: true,
|
|
110
128
|
children: /* @__PURE__ */ jsx(Component, {
|
|
111
129
|
...t3,
|
|
112
130
|
...t4,
|
|
113
131
|
...t5,
|
|
132
|
+
...t6,
|
|
114
133
|
ref
|
|
115
134
|
})
|
|
116
135
|
});
|
|
117
|
-
$[
|
|
118
|
-
$[
|
|
119
|
-
$[
|
|
120
|
-
$[
|
|
121
|
-
$[
|
|
122
|
-
} else
|
|
123
|
-
return
|
|
136
|
+
$[11] = ref;
|
|
137
|
+
$[12] = t3;
|
|
138
|
+
$[13] = t4;
|
|
139
|
+
$[14] = t5;
|
|
140
|
+
$[15] = t7;
|
|
141
|
+
} else t7 = $[15];
|
|
142
|
+
return t7;
|
|
124
143
|
});
|
|
125
144
|
ReadableComponent.displayName = Component.displayName;
|
|
126
145
|
return ReadableComponent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makeAssistantVisible.js","names":["c","_c","useEffect","useRef","forwardRef","ComponentType","ForwardedRef","PropsWithoutRef","useId","createContext","useContext","useAui","useComposedRefs","tool","
|
|
1
|
+
{"version":3,"file":"makeAssistantVisible.js","names":["c","_c","useEffect","useRef","forwardRef","ComponentType","ForwardedRef","PropsWithoutRef","useId","createContext","useContext","useAui","useComposedRefs","tool","DEFAULT_ACTION_SETTLE_DELAY_MS","MAX_ACTION_SETTLE_DELAY_MS","waitForSettle","settleDelayMs","delay","Number","isFinite","Promise","resolve","setTimeout","readActionSettleDelay","element","HTMLElement","value","dataset","actionSettleDelay","undefined","trim","click","parameters","type","properties","clickId","required","execute","escapedClickId","CSS","escape","el","document","querySelector","setNativeValue","HTMLInputElement","HTMLTextAreaElement","prototype","setter","Object","getOwnPropertyDescriptor","set","call","edit","editId","escapedEditId","dispatchEvent","Event","bubbles","ReadableContext","makeAssistantVisible","Component","T","config","clickable","editable","RangeError","ReadableComponent","props","outerRef","$","isNestedReadable","componentRef","aui","t0","Symbol","for","t1","modelContext","register","getModelContext","tools","system","current","outerHTML","t2","ref","t3","t4","t5","t6","t7","displayName","_c"],"sources":["../../src/model-context/makeAssistantVisible.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n useEffect,\n useRef,\n forwardRef,\n type ComponentType,\n type ForwardedRef,\n type PropsWithoutRef,\n useId,\n createContext,\n useContext,\n} from \"react\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useComposedRefs } from \"radix-ui/internal\";\nimport { tool } from \"@assistant-ui/core\";\n\nconst DEFAULT_ACTION_SETTLE_DELAY_MS = 2000;\nconst MAX_ACTION_SETTLE_DELAY_MS = 2_147_483_647;\n\nconst waitForSettle = async (settleDelayMs: number) => {\n const delay =\n Number.isFinite(settleDelayMs) &&\n settleDelayMs >= 0 &&\n settleDelayMs <= MAX_ACTION_SETTLE_DELAY_MS\n ? settleDelayMs\n : DEFAULT_ACTION_SETTLE_DELAY_MS;\n if (delay === 0) return;\n await new Promise<void>((resolve) => setTimeout(resolve, delay));\n};\n\nconst readActionSettleDelay = (element: HTMLElement) => {\n const value = element.dataset.actionSettleDelay;\n return value === undefined || value.trim() === \"\"\n ? DEFAULT_ACTION_SETTLE_DELAY_MS\n : Number(value);\n};\n\nconst click = tool({\n parameters: {\n type: \"object\",\n properties: {\n clickId: {\n type: \"string\",\n },\n },\n required: [\"clickId\"],\n },\n execute: async ({ clickId }: { clickId: string }) => {\n const escapedClickId = CSS.escape(clickId);\n const el = document.querySelector(`[data-click-id='${escapedClickId}']`);\n if (el instanceof HTMLElement) {\n el.click();\n await waitForSettle(readActionSettleDelay(el));\n return {};\n } else {\n return \"Element not found\";\n }\n },\n});\n\nconst setNativeValue = (\n element: HTMLInputElement | HTMLTextAreaElement,\n value: string,\n) => {\n const prototype =\n element instanceof HTMLInputElement\n ? HTMLInputElement.prototype\n : HTMLTextAreaElement.prototype;\n const setter = Object.getOwnPropertyDescriptor(prototype, \"value\")?.set;\n\n if (setter) {\n setter.call(element, value);\n } else {\n element.value = value;\n }\n};\n\nconst edit = tool({\n parameters: {\n type: \"object\",\n properties: {\n editId: {\n type: \"string\",\n },\n value: {\n type: \"string\",\n },\n },\n required: [\"editId\", \"value\"],\n },\n execute: async ({ editId, value }: { editId: string; value: string }) => {\n const escapedEditId = CSS.escape(editId);\n const el = document.querySelector(`[data-edit-id='${escapedEditId}']`);\n if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {\n setNativeValue(el, value);\n el.dispatchEvent(new Event(\"input\", { bubbles: true }));\n el.dispatchEvent(new Event(\"change\", { bubbles: true }));\n await waitForSettle(readActionSettleDelay(el));\n return {};\n } else {\n return \"Element not found\";\n }\n },\n});\n\nconst ReadableContext = createContext<boolean>(false);\n\nexport const makeAssistantVisible = <T extends ComponentType<any>>(\n Component: T,\n config?: {\n clickable?: boolean | undefined;\n editable?: boolean | undefined;\n settleDelayMs?: number | undefined;\n },\n) => {\n const settleDelayMs = config?.settleDelayMs ?? DEFAULT_ACTION_SETTLE_DELAY_MS;\n if (\n !Number.isFinite(settleDelayMs) ||\n settleDelayMs < 0 ||\n settleDelayMs > MAX_ACTION_SETTLE_DELAY_MS\n ) {\n throw new RangeError(\n `settleDelayMs must be between 0 and ${MAX_ACTION_SETTLE_DELAY_MS}`,\n );\n }\n\n const ReadableComponent = forwardRef(\n (props: PropsWithoutRef<T>, outerRef: ForwardedRef<any>) => {\n const isNestedReadable = useContext(ReadableContext);\n\n const clickId = useId();\n const componentRef = useRef<HTMLElement>(null);\n\n const aui = useAui();\n\n const { clickable, editable } = config ?? {};\n useEffect(() => {\n return aui.modelContext.register({\n getModelContext: () => {\n return {\n tools: {\n ...(clickable ? { click } : {}),\n ...(editable ? { edit } : {}),\n },\n system: !isNestedReadable // only pass content if this readable isn't nested in another readable\n ? componentRef.current?.outerHTML\n : undefined,\n };\n },\n });\n }, [isNestedReadable, aui, clickable, editable]);\n\n const ref = useComposedRefs(componentRef, outerRef);\n\n return (\n <ReadableContext.Provider value={true}>\n <Component\n {...(props as any)}\n {...(config?.clickable ? { \"data-click-id\": clickId } : {})}\n {...(config?.editable ? { \"data-edit-id\": clickId } : {})}\n {...(config?.settleDelayMs !== undefined &&\n (config.clickable || config.editable)\n ? { \"data-action-settle-delay\": settleDelayMs }\n : {})}\n ref={ref}\n />\n </ReadableContext.Provider>\n );\n },\n );\n\n ReadableComponent.displayName = Component.displayName;\n\n return ReadableComponent as unknown as T;\n};\n\nexport default makeAssistantVisible;\n"],"mappings":";;;;;;;;AAiBA,MAAMc,iCAAiC;AACvC,MAAMC,6BAA6B;AAEnC,MAAMC,gBAAgB,OAAOC,kBAA0B;CACrD,MAAMC,QACJC,OAAOC,SAASH,aAAa,KAC7BA,iBAAiB,KACjBA,iBAAiBF,6BACbE,gBACAH;CACN,IAAII,UAAU,GAAG;CACjB,MAAM,IAAIG,SAAeC,YAAYC,WAAWD,SAASJ,KAAK,CAAC;AACjE;AAEA,MAAMM,yBAAyBC,YAAyB;CACtD,MAAME,QAAQF,QAAQG,QAAQC;CAC9B,OAAOF,UAAUG,KAAAA,KAAaH,MAAMI,KAAK,MAAM,KAC3CjB,iCACAK,OAAOQ,KAAK;AAClB;AAEA,MAAMK,QAAQnB,KAAK;CACjBoB,YAAY;EACVC,MAAM;EACNC,YAAY,EACVC,SAAS,EACPF,MAAM,SACR,EACF;EACAG,UAAU,CAAC,SAAS;CACtB;CACAC,SAAS,OAAO,EAAEF,cAAmC;EACnD,MAAMG,iBAAiBC,IAAIC,OAAOL,OAAO;EACzC,MAAMM,KAAKC,SAASC,cAAc,mBAAmBL,eAAc,GAAI;EACvE,IAAIG,cAAchB,aAAa;GAC7BgB,GAAGV,MAAM;GACT,MAAMhB,cAAcQ,sBAAsBkB,EAAE,CAAC;GAC7C,OAAO,CAAC;EACV,OACE,OAAO;CAEX;AACF,CAAC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AAlB,EAAA,KAAAmB;EAAA,OAAA;GAAAD,KAAAlB,EAAA;GAAAmB,KAAAnB,EAAA;EAAA;EAAA,IAAAoB;EAAA,IAAApB,EAAA,QAAAK,OAAAC,IAAA,2BAAA,GAAA;GACnDc,KAAA3B,QAAM/C,kBAAoBa,KAAAA,MAC9BkC,OAAMC,aAAcD,OAAME,YADtB,EAAA,4BAE6BjD,cAC7B,IAHA,CAGA;GAACsD,EAAA,MAAAoB;EAAA,OAAAA,KAAApB,EAAA;EAAA,IAAAqB;EAAA,IAAArB,EAAA,QAAAgB,OAAAhB,EAAA,QAAAiB,MAAAjB,EAAA,QAAAkB,MAAAlB,EAAA,QAAAmB,IAAA;GARVE,KAAA,oBAAA,gBAAA,UAAA;IAAiC,OAAA;IAC/B,UAAA,oBAAC,WAAD;KAAU,GACHJ;KAAY,GACZC;KAAqD,GACrDC;KAAmD,GACnDC;KAIAJ;IAAG,CAAA;GAEZ,CAAA;GAA2BhB,EAAA,MAAAgB;GAAAhB,EAAA,MAAAiB;GAAAjB,EAAA,MAAAkB;GAAAlB,EAAA,MAAAmB;GAAAnB,EAAA,MAAAqB;EAAA,OAAAA,KAAArB,EAAA;EAAA,OAX3BqB;CAW2B,CAGjC;CAEAxB,kBAAkByB,cAAc/B,UAAU+B;CAE1C,OAAOzB;AACT"}
|
|
@@ -2,6 +2,7 @@ import { type FC } from "react";
|
|
|
2
2
|
import { Popover as PopoverPrimitive } from "radix-ui";
|
|
3
3
|
export declare namespace AssistantModalPrimitiveRoot {
|
|
4
4
|
type Props = PopoverPrimitive.PopoverProps & {
|
|
5
|
+
/** @deprecated Experimental since 2024-10-12. Not scheduled for removal; the API may change in any release. */
|
|
5
6
|
unstable_openOnRunStart?: boolean | undefined;
|
|
6
7
|
};
|
|
7
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantModalRoot.d.ts","sourceRoot":"","sources":["../../../src/primitives/assistantModal/AssistantModalRoot.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,EAAY,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAIvD,yBAAiB,2BAA2B,CAAC;IAC3C,KAAY,KAAK,GAAG,gBAAgB,CAAC,YAAY,GAAG;QAClD,uBAAuB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;KAC/C,CAAC;CACH;AAED,eAAO,MAAM,2BAA2B,EAAE,EAAE,CAC1C,2BAA2B,CAAC,KAAK,CA+BlC,CAAC"}
|
|
1
|
+
{"version":3,"file":"AssistantModalRoot.d.ts","sourceRoot":"","sources":["../../../src/primitives/assistantModal/AssistantModalRoot.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,EAAY,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAIvD,yBAAiB,2BAA2B,CAAC;IAC3C,KAAY,KAAK,GAAG,gBAAgB,CAAC,YAAY,GAAG;QAClD,+GAA+G;QAC/G,uBAAuB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;KAC/C,CAAC;CACH;AAED,eAAO,MAAM,2BAA2B,EAAE,EAAE,CAC1C,2BAA2B,CAAC,KAAK,CA+BlC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantModalRoot.js","names":["c","_c","FC","useState","Popover","PopoverPrimitive","ScopedProps","usePopoverScope","useAuiEvent","AssistantModalPrimitiveRoot","Props","PopoverProps","unstable_openOnRunStart","t0","$","__scopeAssistantModal","onOpenChange","open","rest","t1","t2","defaultOpen","undefined","scope","modalOpen","setOpen","isOpen","t3","open_0","openChangeHandler","t4","t5","displayName","_c","PopoverPrimitive"],"sources":["../../../src/primitives/assistantModal/AssistantModalRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { type FC, useState } from \"react\";\nimport { Popover as PopoverPrimitive } from \"radix-ui\";\nimport { type ScopedProps, usePopoverScope } from \"./scope\";\nimport { useAuiEvent } from \"@assistant-ui/store\";\n\nexport namespace AssistantModalPrimitiveRoot {\n export type Props = PopoverPrimitive.PopoverProps & {\n unstable_openOnRunStart?: boolean | undefined;\n };\n}\n\nexport const AssistantModalPrimitiveRoot: FC<\n AssistantModalPrimitiveRoot.Props\n> = ({\n __scopeAssistantModal,\n defaultOpen = false,\n unstable_openOnRunStart = true,\n open,\n onOpenChange,\n ...rest\n}: ScopedProps<AssistantModalPrimitiveRoot.Props>) => {\n const scope = usePopoverScope(__scopeAssistantModal);\n\n const [modalOpen, setOpen] = useState(defaultOpen);\n const isOpen = open ?? modalOpen;\n\n const openChangeHandler = (open: boolean) => {\n onOpenChange?.(open);\n setOpen(open);\n };\n\n useAuiEvent(\"thread.runStart\", () => {\n if (unstable_openOnRunStart && !isOpen) openChangeHandler(true);\n });\n\n return (\n <PopoverPrimitive.Root\n {...scope}\n open={isOpen}\n onOpenChange={openChangeHandler}\n {...rest}\n />\n );\n};\n\nAssistantModalPrimitiveRoot.displayName = \"AssistantModalPrimitive.Root\";\n"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"AssistantModalRoot.js","names":["c","_c","FC","useState","Popover","PopoverPrimitive","ScopedProps","usePopoverScope","useAuiEvent","AssistantModalPrimitiveRoot","Props","PopoverProps","unstable_openOnRunStart","t0","$","__scopeAssistantModal","onOpenChange","open","rest","t1","t2","defaultOpen","undefined","scope","modalOpen","setOpen","isOpen","t3","open_0","openChangeHandler","t4","t5","displayName","_c","PopoverPrimitive"],"sources":["../../../src/primitives/assistantModal/AssistantModalRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { type FC, useState } from \"react\";\nimport { Popover as PopoverPrimitive } from \"radix-ui\";\nimport { type ScopedProps, usePopoverScope } from \"./scope\";\nimport { useAuiEvent } from \"@assistant-ui/store\";\n\nexport namespace AssistantModalPrimitiveRoot {\n export type Props = PopoverPrimitive.PopoverProps & {\n /** @deprecated Experimental since 2024-10-12. Not scheduled for removal; the API may change in any release. */\n unstable_openOnRunStart?: boolean | undefined;\n };\n}\n\nexport const AssistantModalPrimitiveRoot: FC<\n AssistantModalPrimitiveRoot.Props\n> = ({\n __scopeAssistantModal,\n defaultOpen = false,\n unstable_openOnRunStart = true,\n open,\n onOpenChange,\n ...rest\n}: ScopedProps<AssistantModalPrimitiveRoot.Props>) => {\n const scope = usePopoverScope(__scopeAssistantModal);\n\n const [modalOpen, setOpen] = useState(defaultOpen);\n const isOpen = open ?? modalOpen;\n\n const openChangeHandler = (open: boolean) => {\n onOpenChange?.(open);\n setOpen(open);\n };\n\n useAuiEvent(\"thread.runStart\", () => {\n if (unstable_openOnRunStart && !isOpen) openChangeHandler(true);\n });\n\n return (\n <PopoverPrimitive.Root\n {...scope}\n open={isOpen}\n onOpenChange={openChangeHandler}\n {...rest}\n />\n );\n};\n\nAssistantModalPrimitiveRoot.displayName = \"AssistantModalPrimitive.Root\";\n"],"mappings":";;;;;;;;AAcA,MAAaS,+BAETI,OAAA;CAAA,MAAAC,IAAAb,EAAA,EAAA;CAAA,IAAAc;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAN,EAAA,OAAAD,IAAA;EAAC,CAAA,CAAAE,uBAAAM,aAAAF,IAAAP,yBAAAQ,IAAAH,MAAAD,cAAA,GAAAE,QAAAL;EAO4CC,EAAA,KAAAD;EAAAC,EAAA,KAAAC;EAAAD,EAAA,KAAAE;EAAAF,EAAA,KAAAG;EAAAH,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;EAAAL,EAAA,KAAAM;CAAA,OAAA;EAAAL,wBAAAD,EAAA;EAAAE,eAAAF,EAAA;EAAAG,OAAAH,EAAA;EAAAI,OAAAJ,EAAA;EAAAK,KAAAL,EAAA;EAAAM,KAAAN,EAAA;CAAA;CAL/C,MAAAO,cAAAF,OAAAG,KAAAA,IAAA,QAAAH;CACA,MAAAP,0BAAAQ,OAAAE,KAAAA,IAAA,OAAAF;CAKA,MAAAG,QAAchB,gBAAgBQ,qBAAqB;CAEnD,MAAA,CAAAS,WAAAC,WAA6BtB,SAASkB,WAAW;CACjD,MAAAK,SAAeT,QAAAO;CAAkB,IAAAG;CAAA,IAAAb,EAAA,OAAAE,cAAA;EAEPW,MAAAC,WAAA;GACxBZ,eAAeC,MAAI;GACnBQ,QAAQR,MAAI;EAAC;EACdH,EAAA,KAAAE;EAAAF,EAAA,KAAAa;CAAA,OAAAA,KAAAb,EAAA;CAHD,MAAAe,oBAA0BF;CAGxB,IAAAG;CAAA,IAAAhB,EAAA,OAAAY,UAAAZ,EAAA,QAAAe,qBAAAf,EAAA,QAAAF,yBAAA;EAE6BkB,WAAA;GAC7B,IAAIlB,2BAAA,CAA4Bc,QAAQG,kBAAkB,IAAI;EAAE;EACjEf,EAAA,KAAAY;EAAAZ,EAAA,MAAAe;EAAAf,EAAA,MAAAF;EAAAE,EAAA,MAAAgB;CAAA,OAAAA,KAAAhB,EAAA;CAFDN,YAAY,mBAAmBsB,EAE9B;CAAC,IAAAC;CAAA,IAAAjB,EAAA,QAAAY,UAAAZ,EAAA,QAAAe,qBAAAf,EAAA,QAAAI,QAAAJ,EAAA,QAAAS,OAAA;EAGAQ,KAAA,oBAAAG,QAAA,MAAA;GAAA,GACMX;GACEG,MAAAA;GACQG,cAAAA;GAAiB,GAC3BX;EAAI,CAAA;EACRJ,EAAA,MAAAY;EAAAZ,EAAA,MAAAe;EAAAf,EAAA,MAAAI;EAAAJ,EAAA,MAAAS;EAAAT,EAAA,MAAAiB;CAAA,OAAAA,KAAAjB,EAAA;CAAA,OALFiB;AAKE;AAINtB,4BAA4BuB,cAAc"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { AttachmentPrimitiveRoot as Root } from "./attachment/AttachmentRoot.js";
|
|
2
|
-
export {
|
|
2
|
+
export {
|
|
3
|
+
/** @deprecated Experimental since 2024-10-10. Not scheduled for removal; the API may change in any release. */
|
|
4
|
+
AttachmentPrimitiveThumb as unstable_Thumb, } from "./attachment/AttachmentThumb.js";
|
|
3
5
|
export { AttachmentPrimitiveName as Name } from "./attachment/AttachmentName.js";
|
|
4
6
|
export { AttachmentPrimitiveRemove as Remove } from "./attachment/AttachmentRemove.js";
|
|
5
7
|
//# sourceMappingURL=attachment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment.d.ts","sourceRoot":"","sources":["../../src/primitives/attachment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,IAAI,IAAI,EAAE,uCAAoC;AAC9E,OAAO,
|
|
1
|
+
{"version":3,"file":"attachment.d.ts","sourceRoot":"","sources":["../../src/primitives/attachment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,IAAI,IAAI,EAAE,uCAAoC;AAC9E,OAAO;AACL,+GAA+G;AAC/G,wBAAwB,IAAI,cAAc,GAC3C,wCAAqC;AACtC,OAAO,EAAE,uBAAuB,IAAI,IAAI,EAAE,uCAAoC;AAC9E,OAAO,EAAE,yBAAyB,IAAI,MAAM,EAAE,yCAAsC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment.js","names":["AttachmentPrimitiveRoot","Root","AttachmentPrimitiveThumb","unstable_Thumb","AttachmentPrimitiveName","Name","AttachmentPrimitiveRemove","Remove"],"sources":["../../src/primitives/attachment.ts"],"sourcesContent":["export { AttachmentPrimitiveRoot as Root } from \"./attachment/AttachmentRoot\";\nexport { AttachmentPrimitiveThumb as unstable_Thumb
|
|
1
|
+
{"version":3,"file":"attachment.js","names":["AttachmentPrimitiveRoot","Root","AttachmentPrimitiveThumb","unstable_Thumb","AttachmentPrimitiveName","Name","AttachmentPrimitiveRemove","Remove"],"sources":["../../src/primitives/attachment.ts"],"sourcesContent":["export { AttachmentPrimitiveRoot as Root } from \"./attachment/AttachmentRoot\";\nexport {\n /** @deprecated Experimental since 2024-10-10. Not scheduled for removal; the API may change in any release. */\n AttachmentPrimitiveThumb as unstable_Thumb,\n} from \"./attachment/AttachmentThumb\";\nexport { AttachmentPrimitiveName as Name } from \"./attachment/AttachmentName\";\nexport { AttachmentPrimitiveRemove as Remove } from \"./attachment/AttachmentRemove\";\n"],"mappings":""}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ActionButtonElement, type ActionButtonProps } from "../../utils/createActionButton.js";
|
|
2
|
-
|
|
2
|
+
import type { MouseEvent } from "react";
|
|
3
|
+
declare const useComposerCancel: () => ((event: MouseEvent<HTMLButtonElement>) => void) | null;
|
|
3
4
|
export declare namespace ComposerPrimitiveCancel {
|
|
4
5
|
type Element = ActionButtonElement;
|
|
5
6
|
/**
|
|
@@ -13,6 +14,9 @@ export declare namespace ComposerPrimitiveCancel {
|
|
|
13
14
|
*
|
|
14
15
|
* This component automatically handles the cancel functionality and is disabled
|
|
15
16
|
* when canceling is not available.
|
|
17
|
+
* Keyboard or assistive-technology activation after editing returns focus to the
|
|
18
|
+
* main thread composer when available, unless a handler has moved focus elsewhere.
|
|
19
|
+
* Pointer activation preserves the existing focus behavior.
|
|
16
20
|
*
|
|
17
21
|
* @example
|
|
18
22
|
* ```tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerCancel.d.ts","sourceRoot":"","sources":["../../../src/primitives/composer/ComposerCancel.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EAEvB,0CAAuC;
|
|
1
|
+
{"version":3,"file":"ComposerCancel.d.ts","sourceRoot":"","sources":["../../../src/primitives/composer/ComposerCancel.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EAEvB,0CAAuC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAIxC,QAAA,MAAM,iBAAiB,iBAIN,UAAU,CAAC,iBAAiB,CAAC,iBAE7C,CAAC;AAEF,yBAAiB,uBAAuB,CAAC;IACvC,KAAY,OAAO,GAAG,mBAAmB,CAAC;IAC1C;;;OAGG;IACH,KAAY,KAAK,GAAG,iBAAiB,CAAC,OAAO,iBAAiB,CAAC,CAAC;CACjE;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,uBAAuB;;;;gHAGnC,CAAC"}
|
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createActionButton } from "../../utils/createActionButton.js";
|
|
3
|
+
import { useComposerCancelWithFocus } from "./useComposerCancelWithFocus.js";
|
|
4
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
3
5
|
import { useComposerCancel } from "@assistant-ui/core/react";
|
|
4
6
|
//#region src/primitives/composer/ComposerCancel.ts
|
|
5
7
|
const useComposerCancel$1 = () => {
|
|
8
|
+
const $ = c(2);
|
|
6
9
|
const { disabled, cancel } = useComposerCancel();
|
|
10
|
+
const cancelWithFocus = useComposerCancelWithFocus(cancel);
|
|
7
11
|
if (disabled) return null;
|
|
8
|
-
|
|
12
|
+
let t0;
|
|
13
|
+
if ($[0] !== cancelWithFocus) {
|
|
14
|
+
t0 = (event) => cancelWithFocus(event.detail === 0 ? event.currentTarget : null);
|
|
15
|
+
$[0] = cancelWithFocus;
|
|
16
|
+
$[1] = t0;
|
|
17
|
+
} else t0 = $[1];
|
|
18
|
+
return t0;
|
|
9
19
|
};
|
|
10
20
|
/**
|
|
11
21
|
* A button component that cancels the current message composition.
|
|
12
22
|
*
|
|
13
23
|
* This component automatically handles the cancel functionality and is disabled
|
|
14
24
|
* when canceling is not available.
|
|
25
|
+
* Keyboard or assistive-technology activation after editing returns focus to the
|
|
26
|
+
* main thread composer when available, unless a handler has moved focus elsewhere.
|
|
27
|
+
* Pointer activation preserves the existing focus behavior.
|
|
15
28
|
*
|
|
16
29
|
* @example
|
|
17
30
|
* ```tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerCancel.js","names":["ActionButtonElement","ActionButtonProps","createActionButton","useComposerCancel","useComposerCancelBehavior","disabled","cancel","ComposerPrimitiveCancel","Element","Props","useComposerCancel","useComposerCancelBehavior"],"sources":["../../../src/primitives/composer/ComposerCancel.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useComposerCancel as useComposerCancelBehavior } from \"@assistant-ui/core/react\";\n\nconst useComposerCancel = () => {\n const { disabled, cancel } = useComposerCancelBehavior();\n if (disabled) return null;\n return
|
|
1
|
+
{"version":3,"file":"ComposerCancel.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","MouseEvent","useComposerCancel","useComposerCancelBehavior","useComposerCancelWithFocus","$","disabled","cancel","cancelWithFocus","t0","event","detail","currentTarget","ComposerPrimitiveCancel","Element","Props","useComposerCancel","_c","useComposerCancelBehavior"],"sources":["../../../src/primitives/composer/ComposerCancel.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport type { MouseEvent } from \"react\";\nimport { useComposerCancel as useComposerCancelBehavior } from \"@assistant-ui/core/react\";\nimport { useComposerCancelWithFocus } from \"./useComposerCancelWithFocus\";\n\nconst useComposerCancel = () => {\n const { disabled, cancel } = useComposerCancelBehavior();\n const cancelWithFocus = useComposerCancelWithFocus(cancel);\n if (disabled) return null;\n return (event: MouseEvent<HTMLButtonElement>) =>\n cancelWithFocus(event.detail === 0 ? event.currentTarget : null);\n};\n\nexport namespace ComposerPrimitiveCancel {\n export type Element = ActionButtonElement;\n /**\n * Props for the ComposerPrimitive.Cancel component.\n * Inherits all button element props and action button functionality.\n */\n export type Props = ActionButtonProps<typeof useComposerCancel>;\n}\n\n/**\n * A button component that cancels the current message composition.\n *\n * This component automatically handles the cancel functionality and is disabled\n * when canceling is not available.\n * Keyboard or assistive-technology activation after editing returns focus to the\n * main thread composer when available, unless a handler has moved focus elsewhere.\n * Pointer activation preserves the existing focus behavior.\n *\n * @example\n * ```tsx\n * <ComposerPrimitive.Cancel>\n * Cancel\n * </ComposerPrimitive.Cancel>\n * ```\n */\nexport const ComposerPrimitiveCancel = createActionButton(\n \"ComposerPrimitive.Cancel\",\n useComposerCancel,\n);\n"],"mappings":";;;;;;AAWA,MAAMM,4BAAoB;CAAA,MAAAG,IAAAR,EAAA,CAAA;CACxB,MAAA,EAAAS,UAAAC,WAA6BJ,kBAA0B;CACvD,MAAAK,kBAAwBJ,2BAA2BG,MAAM;CACzD,IAAID,UAAQ,OAAS;CAAK,IAAAG;CAAA,IAAAJ,EAAA,OAAAG,iBAAA;EACnBC,MAAAC,UACLF,gBAAgBE,MAAKC,WAAY,IAAID,MAAKE,gBAA1B,IAA+C;EAACP,EAAA,KAAAG;EAAAH,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,OAD3DI;AAC2D;;;;;;;;;;;;;;;;;AA4BpE,MAAaI,0BAA0Bb,mBACrC,4BACAE,mBACF"}
|