@assistant-ui/react 0.15.18 → 0.15.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/dist/context/providers/ThreadViewportProvider.js +2 -2
- package/dist/context/providers/ThreadViewportProvider.js.map +1 -1
- package/dist/hooks/useToolCallElapsed.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/mcp-apps/app-frame.d.ts.map +1 -1
- package/dist/mcp-apps/app-frame.js +17 -12
- package/dist/mcp-apps/app-frame.js.map +1 -1
- package/dist/mcp-apps/bridge.js +7 -1
- package/dist/mcp-apps/bridge.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalRoot.d.ts.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalRoot.js +47 -79
- package/dist/primitives/assistantModal/AssistantModalRoot.js.map +1 -1
- package/dist/primitives/composer/ComposerAttachmentDropzone.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerAttachmentDropzone.js +61 -138
- package/dist/primitives/composer/ComposerAttachmentDropzone.js.map +1 -1
- package/dist/primitives/composer/ComposerInput.js +3 -8
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/composer/trigger/triggerKeyboardResource.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/triggerKeyboardResource.js +53 -61
- package/dist/primitives/composer/trigger/triggerKeyboardResource.js.map +1 -1
- package/dist/primitives/composer/trigger/triggerNavigationResource.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/triggerNavigationResource.js +127 -137
- package/dist/primitives/composer/trigger/triggerNavigationResource.js.map +1 -1
- package/dist/primitives/message/MessageParts.js +2 -14
- package/dist/primitives/message/MessageParts.js.map +1 -1
- package/dist/primitives/message/MessagePartsGrouped.d.ts +3 -3
- package/dist/primitives/message/MessagePartsGrouped.js +2 -2
- package/dist/primitives/message/MessagePartsGrouped.js.map +1 -1
- package/dist/primitives/messagePart/MessagePartText.d.ts +3 -1
- package/dist/primitives/messagePart/MessagePartText.d.ts.map +1 -1
- package/dist/primitives/messagePart/MessagePartText.js +13 -36
- package/dist/primitives/messagePart/MessagePartText.js.map +1 -1
- package/dist/primitives/reasoning/useScrollLock.js +3 -1
- package/dist/primitives/reasoning/useScrollLock.js.map +1 -1
- package/dist/sandbox-host/SandboxHost.js +22 -4
- package/dist/sandbox-host/SandboxHost.js.map +1 -1
- package/dist/unstable/useLiveCompletionAdapter.js +24 -2
- package/dist/unstable/useLiveCompletionAdapter.js.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 -5
- package/dist/unstable/useMessageStallDetection.d.ts.map +1 -1
- package/dist/unstable/useMessageStallDetection.js +16 -15
- package/dist/unstable/useMessageStallDetection.js.map +1 -1
- package/dist/unstable/webmcp/convertTools.d.ts.map +1 -1
- package/dist/unstable/webmcp/convertTools.js +54 -3
- package/dist/unstable/webmcp/convertTools.js.map +1 -1
- package/dist/unstable/webmcp/useWebMcpProvider.d.ts.map +1 -1
- package/dist/unstable/webmcp/useWebMcpProvider.js +2 -1
- package/dist/unstable/webmcp/useWebMcpProvider.js.map +1 -1
- package/dist/utils/Primitive.d.ts +14 -6
- package/dist/utils/Primitive.d.ts.map +1 -1
- package/dist/utils/Primitive.js +25 -6
- package/dist/utils/Primitive.js.map +1 -1
- package/dist/utils/getSelectionMessageId.d.ts.map +1 -1
- package/dist/utils/getSelectionMessageId.js +17 -3
- package/dist/utils/getSelectionMessageId.js.map +1 -1
- package/package.json +11 -11
- package/src/context/providers/ThreadViewportProvider.tsx +2 -2
- package/src/hooks/useToolCallElapsed.ts +3 -0
- package/src/index.ts +1 -1
- package/src/mcp-apps/app-frame.test.tsx +189 -0
- package/src/mcp-apps/app-frame.tsx +31 -22
- package/src/mcp-apps/bridge.test.ts +98 -0
- package/src/mcp-apps/bridge.ts +7 -1
- package/src/primitives/assistantModal/AssistantModalRoot.test.tsx +123 -0
- package/src/primitives/assistantModal/AssistantModalRoot.tsx +11 -31
- package/src/primitives/assistantModal/AssistantModalTrigger.test.tsx +1 -16
- package/src/primitives/composer/ComposerAttachmentDropzone.test.tsx +43 -0
- package/src/primitives/composer/ComposerAttachmentDropzone.tsx +2 -10
- package/src/primitives/composer/ComposerInput.test.tsx +22 -0
- package/src/primitives/composer/ComposerInput.tsx +5 -9
- package/src/primitives/composer/trigger/triggerKeyboardResource.ts +13 -7
- package/src/primitives/composer/trigger/triggerNavigationResource.ts +5 -3
- package/src/primitives/message/MessageParts.tsx +1 -21
- package/src/primitives/message/MessagePartsGrouped.test.tsx +93 -0
- package/src/primitives/message/MessagePartsGrouped.tsx +6 -6
- package/src/primitives/messagePart/MessagePartText.test.tsx +69 -0
- package/src/primitives/messagePart/MessagePartText.tsx +22 -9
- package/src/primitives/reasoning/useScrollLock.test.tsx +129 -0
- package/src/primitives/reasoning/useScrollLock.ts +15 -1
- package/src/primitives/thread/useThreadViewportAutoScroll.test.tsx +38 -1
- package/src/sandbox-host/SandboxHost.test.tsx +40 -0
- package/src/sandbox-host/SandboxHost.tsx +24 -4
- package/src/tests/MessageParts.rendererOptions.test.tsx +117 -0
- package/src/tests/toolCallTiming.test.tsx +55 -1
- package/src/unstable/useLiveCompletionAdapter.test.tsx +202 -1
- package/src/unstable/useLiveCompletionAdapter.ts +38 -8
- package/src/unstable/useMentionAdapter.test.tsx +47 -1
- package/src/unstable/useMentionAdapter.ts +2 -2
- package/src/unstable/useMessageStallDetection.ts +26 -19
- package/src/unstable/webmcp/convertTools.test.ts +181 -21
- package/src/unstable/webmcp/convertTools.ts +87 -7
- package/src/unstable/webmcp/useWebMcpProvider.ts +2 -4
- package/src/utils/Primitive.test.tsx +46 -1
- package/src/utils/Primitive.tsx +37 -7
- package/src/utils/getSelectionMessageId.test.ts +176 -1
- package/src/utils/getSelectionMessageId.ts +21 -3
package/README.md
CHANGED
|
@@ -98,7 +98,13 @@ Sample customization to make a Perplexity lookalike:
|
|
|
98
98
|
|
|
99
99
|
<a href="https://mastra.ai/?ref=assistant-ui" target="_blank" rel="noopener noreferrer"><img src="https://raw.githubusercontent.com/assistant-ui/assistant-ui/main/.github/assets/logos/Mastra.svg" height="20" alt="Mastra"></a>, <a href="https://langchain.com/?ref=assistant-ui" target="_blank" rel="noopener noreferrer"><img src="https://raw.githubusercontent.com/assistant-ui/assistant-ui/main/.github/assets/logos/LangChain.svg" height="20" alt="LangChain"></a>, <a href="https://athenaintelligence.ai/?ref=assistant-ui" target="_blank" rel="noopener noreferrer"><img src="https://raw.githubusercontent.com/assistant-ui/assistant-ui/main/.github/assets/logos/Athena-Intelligence.svg" height="20" alt="Athena Intelligence"></a>, <a href="https://browser-use.com/?ref=assistant-ui" target="_blank" rel="noopener noreferrer"><img src="https://raw.githubusercontent.com/assistant-ui/assistant-ui/main/.github/assets/logos/Browser-Use.svg" height="20" alt="Browser Use"></a>, <a href="https://stack-ai.com/?ref=assistant-ui" target="_blank" rel="noopener noreferrer"><img src="https://raw.githubusercontent.com/assistant-ui/assistant-ui/main/.github/assets/logos/Stack.svg" height="20" alt="Stack"></a>, <a href="https://inconvo.com/?ref=assistant-ui" target="_blank" rel="noopener noreferrer"><img src="https://raw.githubusercontent.com/assistant-ui/assistant-ui/main/.github/assets/logos/Inconvo.svg" height="20" alt="Inconvo"></a>, <a href="https://iterable.com/?ref=assistant-ui" target="_blank" rel="noopener noreferrer"><img src="https://raw.githubusercontent.com/assistant-ui/assistant-ui/main/.github/assets/logos/Iterable.svg" height="20" alt="Iterable"></a>, <a href="https://helicone.ai/?ref=assistant-ui" target="_blank" rel="noopener noreferrer"><img src="https://raw.githubusercontent.com/assistant-ui/assistant-ui/main/.github/assets/logos/helicone.svg" height="20" alt="Helicone"></a>, <a href="https://getgram.ai/?ref=assistant-ui" target="_blank" rel="noopener noreferrer"><img src="https://raw.githubusercontent.com/assistant-ui/assistant-ui/main/.github/assets/logos/gram.svg" height="20" alt="Gram"></a>, <a href="https://coreviz.io/?ref=assistant-ui" target="_blank" rel="noopener noreferrer"><img src="https://raw.githubusercontent.com/assistant-ui/assistant-ui/main/.github/assets/logos/Coreviz.svg" height="20" alt="Coreviz"></a>, and many more.
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
<a href="https://www.assistant-ui.com/traction">
|
|
102
|
+
<picture>
|
|
103
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://www.assistant-ui.com/traction-dark.png" />
|
|
104
|
+
<source media="(prefers-color-scheme: light)" srcset="https://www.assistant-ui.com/traction.png" />
|
|
105
|
+
<img src="https://www.assistant-ui.com/traction.png" alt="Chart of assistant-ui's traction" width="100%" />
|
|
106
|
+
</picture>
|
|
107
|
+
</a>
|
|
102
108
|
|
|
103
109
|
## Demos
|
|
104
110
|
|
|
@@ -24,8 +24,8 @@ const useThreadViewportStoreValue = (options) => {
|
|
|
24
24
|
let t2;
|
|
25
25
|
let t3;
|
|
26
26
|
if ($[3] !== outerViewport || $[4] !== store) {
|
|
27
|
-
t2 = () => outerViewport?.getState().onScrollToBottom(() => {
|
|
28
|
-
store.getState().scrollToBottom();
|
|
27
|
+
t2 = () => outerViewport?.getState().onScrollToBottom((config) => {
|
|
28
|
+
store.getState().scrollToBottom(config);
|
|
29
29
|
});
|
|
30
30
|
t3 = [outerViewport, store];
|
|
31
31
|
$[3] = outerViewport;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadViewportProvider.js","names":["c","_c","FC","PropsWithChildren","useEffect","useState","makeThreadViewportStore","ThreadViewportStoreOptions","ThreadViewportContext","ThreadViewportContextValue","useThreadViewportStore","writableStore","ThreadViewportProviderProps","options","useThreadViewportStoreValue","$","t0","Symbol","for","optional","outerViewport","t1","store","t2","t3","getState","onScrollToBottom","scrollToBottom","t4","t5","subscribe","state","isAtBottom","setState","ThreadPrimitiveViewportProvider","children","undefined","useThreadViewport","context"],"sources":["../../../src/context/providers/ThreadViewportProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport { type FC, type PropsWithChildren, useEffect, useState } from \"react\";\n\nimport {\n makeThreadViewportStore,\n type ThreadViewportStoreOptions,\n} from \"../stores/ThreadViewport\";\nimport {\n ThreadViewportContext,\n type ThreadViewportContextValue,\n useThreadViewportStore,\n} from \"../react/ThreadViewportContext\";\nimport { writableStore } from \"../ReadonlyStore\";\n\nexport type ThreadViewportProviderProps = PropsWithChildren<{\n options?: ThreadViewportStoreOptions;\n}>;\n\nconst useThreadViewportStoreValue = (options: ThreadViewportStoreOptions) => {\n const outerViewport = useThreadViewportStore({ optional: true });\n // Viewport options are initial configuration. Keeping them non-reactive avoids\n // fanout through every message in long threads when anchoring config changes.\n const [store] = useState(() => makeThreadViewportStore(options));\n\n // Forward scrollToBottom from outer viewport to inner viewport\n useEffect(() => {\n return outerViewport?.getState().onScrollToBottom(() => {\n store.getState().scrollToBottom();\n });\n }, [outerViewport, store]);\n\n useEffect(() => {\n if (!outerViewport) return;\n return store.subscribe((state) => {\n if (outerViewport.getState().isAtBottom !== state.isAtBottom) {\n writableStore(outerViewport).setState({ isAtBottom: state.isAtBottom });\n }\n });\n }, [store, outerViewport]);\n\n return store;\n};\n\nexport const ThreadPrimitiveViewportProvider: FC<\n ThreadViewportProviderProps\n> = ({ children, options = {} }) => {\n const useThreadViewport = useThreadViewportStoreValue(options);\n\n const [context] = useState<ThreadViewportContextValue>(() => {\n return {\n useThreadViewport,\n };\n });\n\n return (\n <ThreadViewportContext.Provider value={context}>\n {children}\n </ThreadViewportContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;AAmBA,MAAMc,+BAA8BD,YAAA;CAAA,MAAAE,IAAAd,EAAA,EAAA;CAAA,IAAAe;CAAA,IAAAD,EAAA,OAAAE,OAAAC,IAAA,2BAAA,GAAA;EACWF,KAAA,EAAAG,UAAY,KAAK;EAACJ,EAAA,KAAAC;CAAA,OAAAA,KAAAD,EAAA;CAA/D,MAAAK,gBAAsBV,uBAAuBM,EAAkB;CAAE,IAAAK;CAAA,IAAAN,EAAA,OAAAF,SAAA;EAGxCQ,WAAMf,wBAAwBO,OAAO;EAACE,EAAA,KAAAF;EAAAE,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAA/D,MAAA,CAAAO,SAAgBjB,SAASgB,EAAsC;CAAE,IAAAE;CAAA,IAAAC;CAAA,IAAAT,EAAA,OAAAK,iBAAAL,EAAA,OAAAO,OAAA;EAGvDC,WACDH,eAAaK,SAA4B,CAAC,CAAAC,
|
|
1
|
+
{"version":3,"file":"ThreadViewportProvider.js","names":["c","_c","FC","PropsWithChildren","useEffect","useState","makeThreadViewportStore","ThreadViewportStoreOptions","ThreadViewportContext","ThreadViewportContextValue","useThreadViewportStore","writableStore","ThreadViewportProviderProps","options","useThreadViewportStoreValue","$","t0","Symbol","for","optional","outerViewport","t1","store","t2","t3","getState","onScrollToBottom","config","scrollToBottom","t4","t5","subscribe","state","isAtBottom","setState","ThreadPrimitiveViewportProvider","children","undefined","useThreadViewport","context"],"sources":["../../../src/context/providers/ThreadViewportProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport { type FC, type PropsWithChildren, useEffect, useState } from \"react\";\n\nimport {\n makeThreadViewportStore,\n type ThreadViewportStoreOptions,\n} from \"../stores/ThreadViewport\";\nimport {\n ThreadViewportContext,\n type ThreadViewportContextValue,\n useThreadViewportStore,\n} from \"../react/ThreadViewportContext\";\nimport { writableStore } from \"../ReadonlyStore\";\n\nexport type ThreadViewportProviderProps = PropsWithChildren<{\n options?: ThreadViewportStoreOptions;\n}>;\n\nconst useThreadViewportStoreValue = (options: ThreadViewportStoreOptions) => {\n const outerViewport = useThreadViewportStore({ optional: true });\n // Viewport options are initial configuration. Keeping them non-reactive avoids\n // fanout through every message in long threads when anchoring config changes.\n const [store] = useState(() => makeThreadViewportStore(options));\n\n // Forward scrollToBottom from outer viewport to inner viewport\n useEffect(() => {\n return outerViewport?.getState().onScrollToBottom((config) => {\n store.getState().scrollToBottom(config);\n });\n }, [outerViewport, store]);\n\n useEffect(() => {\n if (!outerViewport) return;\n return store.subscribe((state) => {\n if (outerViewport.getState().isAtBottom !== state.isAtBottom) {\n writableStore(outerViewport).setState({ isAtBottom: state.isAtBottom });\n }\n });\n }, [store, outerViewport]);\n\n return store;\n};\n\nexport const ThreadPrimitiveViewportProvider: FC<\n ThreadViewportProviderProps\n> = ({ children, options = {} }) => {\n const useThreadViewport = useThreadViewportStoreValue(options);\n\n const [context] = useState<ThreadViewportContextValue>(() => {\n return {\n useThreadViewport,\n };\n });\n\n return (\n <ThreadViewportContext.Provider value={context}>\n {children}\n </ThreadViewportContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;AAmBA,MAAMc,+BAA8BD,YAAA;CAAA,MAAAE,IAAAd,EAAA,EAAA;CAAA,IAAAe;CAAA,IAAAD,EAAA,OAAAE,OAAAC,IAAA,2BAAA,GAAA;EACWF,KAAA,EAAAG,UAAY,KAAK;EAACJ,EAAA,KAAAC;CAAA,OAAAA,KAAAD,EAAA;CAA/D,MAAAK,gBAAsBV,uBAAuBM,EAAkB;CAAE,IAAAK;CAAA,IAAAN,EAAA,OAAAF,SAAA;EAGxCQ,WAAMf,wBAAwBO,OAAO;EAACE,EAAA,KAAAF;EAAAE,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAA/D,MAAA,CAAAO,SAAgBjB,SAASgB,EAAsC;CAAE,IAAAE;CAAA,IAAAC;CAAA,IAAAT,EAAA,OAAAK,iBAAAL,EAAA,OAAAO,OAAA;EAGvDC,WACDH,eAAaK,SAA4B,CAAC,CAAAC,kBAACC,WAAA;GAChDL,MAAKG,SAAU,CAAC,CAAAG,eAAgBD,MAAM;EAAC,CACxC;EACAH,KAAA,CAACJ,eAAeE,KAAK;EAACP,EAAA,KAAAK;EAAAL,EAAA,KAAAO;EAAAP,EAAA,KAAAQ;EAAAR,EAAA,KAAAS;CAAA,OAAA;EAAAD,KAAAR,EAAA;EAAAS,KAAAT,EAAA;CAAA;CAJzBX,UAAUmB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B,EAAA,KAAAc;CAAA,OAAAA,KAAAd,EAAA;CAAA,OAFjCc;AAEiC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToolCallElapsed.js","names":["c","_c","useEffect","useState","useAuiState","useToolCallElapsed","$","timing","_temp","partRunning","_temp2","running","undefined","completedAt","now","setNow","_temp3","t0","t1","Date","id","setInterval","clearInterval","Math","max","startedAt","s","part","optional","type","s_0","part_0","status"],"sources":["../../src/hooks/useToolCallElapsed.ts"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useState } from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\n/**\n * Hook that returns the elapsed wall-clock time of the current tool call in\n * milliseconds, ticking once per second while the call runs.\n *\n * Reads `part.timing`. Returns `undefined` when the part is not a tool call,\n * carries no timing, ended without a recorded completion (the duration is\n * unknown), or when no message part scope is available (so kit components\n * stay renderable standalone, e.g. in docs previews).\n *\n * @example\n * ```tsx\n * function ToolDuration() {\n * const elapsedMs = useToolCallElapsed();\n * if (elapsedMs === undefined) return null;\n * return <span>{(elapsedMs / 1000).toFixed(1)}s</span>;\n * }\n * ```\n */\nexport const useToolCallElapsed = (): number | undefined => {\n const timing = useAuiState((s) => {\n const part = s.optional.part;\n return part?.type === \"tool-call\" ? part.timing : undefined;\n });\n const partRunning = useAuiState((s) => {\n const part = s.optional.part;\n return part?.type === \"tool-call\" && part.status.type === \"running\";\n });\n const running =\n timing !== undefined && timing.completedAt === undefined && partRunning;\n const [now, setNow] = useState(() => Date.now());\n\n useEffect(() => {\n if (!running) return undefined;\n setNow(Date.now());\n const id = setInterval(() => setNow(Date.now()), 1000);\n return () => clearInterval(id);\n }, [running]);\n\n if (timing === undefined) return undefined;\n if (timing.completedAt !== undefined)\n return Math.max(0, timing.completedAt - timing.startedAt);\n if (!running) return undefined;\n return Math.max(0, now - timing.startedAt);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAaK,2BAAqB;CAAA,MAAAC,IAAAL,EAAA,CAAA;CAChC,MAAAM,SAAeH,YAAYI,KAG1B;CACD,MAAAC,cAAoBL,YAAYM,MAG/B;CACD,MAAAC,UACEJ,WAAWK,KAAAA,KAAaL,OAAMM,gBAAiBD,KAAAA,KAA/CH;CACF,MAAA,CAAAK,KAAAC,UAAsBZ,SAASa,MAAgB;CAAE,IAAAC;CAAA,IAAAC;CAAA,IAAAZ,EAAA,OAAAK,SAAA;EAEvCM,WAAA;GACR,IAAI,CAACN,SAAO;
|
|
1
|
+
{"version":3,"file":"useToolCallElapsed.js","names":["c","_c","useEffect","useState","useAuiState","useToolCallElapsed","$","timing","_temp","partRunning","_temp2","running","undefined","completedAt","now","setNow","_temp3","t0","t1","Date","id","setInterval","clearInterval","Math","max","startedAt","s","part","optional","type","s_0","part_0","status"],"sources":["../../src/hooks/useToolCallElapsed.ts"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useState } from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\n/**\n * Hook that returns the elapsed wall-clock time of the current tool call in\n * milliseconds, ticking once per second while the call runs.\n *\n * Reads `part.timing`. Returns `undefined` when the part is not a tool call,\n * carries no timing, ended without a recorded completion (the duration is\n * unknown), or when no message part scope is available (so kit components\n * stay renderable standalone, e.g. in docs previews).\n *\n * @example\n * ```tsx\n * function ToolDuration() {\n * const elapsedMs = useToolCallElapsed();\n * if (elapsedMs === undefined) return null;\n * return <span>{(elapsedMs / 1000).toFixed(1)}s</span>;\n * }\n * ```\n */\nexport const useToolCallElapsed = (): number | undefined => {\n const timing = useAuiState((s) => {\n const part = s.optional.part;\n return part?.type === \"tool-call\" ? part.timing : undefined;\n });\n const partRunning = useAuiState((s) => {\n const part = s.optional.part;\n return part?.type === \"tool-call\" && part.status.type === \"running\";\n });\n const running =\n timing !== undefined && timing.completedAt === undefined && partRunning;\n const [now, setNow] = useState(() => Date.now());\n\n useEffect(() => {\n if (!running) return undefined;\n // The clock is an external source; this catches the elapsed value up before\n // the interval takes over.\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setNow(Date.now());\n const id = setInterval(() => setNow(Date.now()), 1000);\n return () => clearInterval(id);\n }, [running]);\n\n if (timing === undefined) return undefined;\n if (timing.completedAt !== undefined)\n return Math.max(0, timing.completedAt - timing.startedAt);\n if (!running) return undefined;\n return Math.max(0, now - timing.startedAt);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAaK,2BAAqB;CAAA,MAAAC,IAAAL,EAAA,CAAA;CAChC,MAAAM,SAAeH,YAAYI,KAG1B;CACD,MAAAC,cAAoBL,YAAYM,MAG/B;CACD,MAAAC,UACEJ,WAAWK,KAAAA,KAAaL,OAAMM,gBAAiBD,KAAAA,KAA/CH;CACF,MAAA,CAAAK,KAAAC,UAAsBZ,SAASa,MAAgB;CAAE,IAAAC;CAAA,IAAAC;CAAA,IAAAZ,EAAA,OAAAK,SAAA;EAEvCM,WAAA;GACR,IAAI,CAACN,SAAO;GAIZI,OAAOI,KAAIL,IAAK,CAAC;GACjB,MAAAM,KAAWC,kBAAkBN,OAAOI,KAAIL,IAAK,CAAC,GAAG,GAAI;GAAE,aAC1CQ,cAAcF,EAAE;EAAC;EAC7BF,KAAA,CAACP,OAAO;EAACL,EAAA,KAAAK;EAAAL,EAAA,KAAAW;EAAAX,EAAA,KAAAY;CAAA,OAAA;EAAAD,KAAAX,EAAA;EAAAY,KAAAZ,EAAA;CAAA;CARZJ,UAAUe,IAQPC,EAAS;CAEZ,IAAIX,WAAWK,KAAAA,GAAS;CACxB,IAAIL,OAAMM,gBAAiBD,KAAAA,GAAS,OAC3BW,KAAIC,IAAK,GAAGjB,OAAMM,cAAeN,OAAMkB,SAAU;CAC1D,IAAI,CAACd,SAAO;CAAmB,OACxBY,KAAIC,IAAK,GAAGV,MAAMP,OAAMkB,SAAU;AAAC;AA3BV,SAAAjB,MAAAkB,GAAA;CAE9B,MAAAC,OAAaD,EAACE,SAASD;CAAM,OACtBA,MAAIE,SAAW,cAAcF,KAAIpB,SAAjCK,KAAAA;AAAoD;AAH7B,SAAAF,OAAAoB,KAAA;CAM9B,MAAAC,SAAaL,IAACE,SAASD;CAAM,OACtBA,QAAIE,SAAW,eAAeF,OAAIK,OAAOH,SAAU;AAAS;AAPrC,SAAAb,SAAA;CAAA,OAWKG,KAAIL,IAAK;AAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -75,8 +75,8 @@ import { defaultWebMcpFilter } from "./unstable/webmcp/convertTools.js";
|
|
|
75
75
|
import { AssistantContextConfig, AssistantDataUI, AssistantDataUIProps, AssistantInteractableProps, AssistantTool, AssistantToolProps, AssistantToolUI, AssistantToolUIProps, DataMessagePartComponent, DataMessagePartProps, DataRenderers, EmptyMessagePartComponent, EmptyMessagePartProps, EnrichedPartState, FileMessagePartComponent, FileMessagePartProps, GenerativeUIComponentRegistry, GenerativeUIMessagePartComponent, GenerativeUIMessagePartProps, GenerativeUIRender, GenerativeUIRenderError, GenerativeUIRenderProps, GroupByContext, ImageMessagePartComponent, ImageMessagePartProps, Interactables, McpAppResourceOutput, McpToolkitDefinition, McpToolkitEntry, McpToolkitToolConfig, PartState, ProviderToolConfig, QuoteMessagePartComponent, QuoteMessagePartProps, ReasoningGroupComponent, ReasoningGroupProps, ReasoningMessagePartComponent, ReasoningMessagePartProps, RuntimeAdapterProvider, RuntimeAdapters, SourceMessagePartComponent, SourceMessagePartProps, TextMessagePartComponent, TextMessagePartProps, ToolArgsStatus, ToolCallMessagePartComponent, ToolCallMessagePartProps, ToolCallText, ToolDefinition, Toolkit, ToolkitDefinition, ToolkitDefinitionEntry, Tools, Unstable_AudioMessagePartComponent, Unstable_AudioMessagePartProps, Unstable_InferInteractableState, Unstable_InteractableConfig, Unstable_InteractableDefinition, Unstable_InteractablePersistedState, Unstable_InteractablePersistenceAdapter, Unstable_InteractablePersistenceStatus, Unstable_InteractableRegistration, Unstable_InteractableStateSchema, Unstable_InteractableToolConfig, Unstable_InteractableToolRenderProps, Unstable_InteractableVersionInfo, Unstable_InteractablesClientSchema, Unstable_InteractablesConfig, Unstable_InteractablesMethods, Unstable_InteractablesState, defineMcpToolkit, defineToolkit, externalTool, groupPartByType, hitl, hitlTool, humanTool, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, providerTool, stubTool, unstable_Interactables, unstable_interactableTool, unstable_useInteractable, unstable_useInteractableState, unstable_useInteractableVersions, unstable_useThreadMessageIds, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAuiToolOverrides, useCloudThreadListRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useRuntimeAdapters, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume } from "@assistant-ui/core/react";
|
|
76
76
|
import { AssistantClient, AssistantEventCallback, AssistantEventName, AssistantEventPayload, AssistantEventScope, AssistantEventSelector, AssistantState, AuiConfig, AuiIf, AuiProvider, useAui, useAuiEvent, useAuiState } from "@assistant-ui/store";
|
|
77
77
|
import { AddToolResultOptions, AppendMessage, AssistantFrameHost, AssistantFrameProvider, AssistantRuntime, Attachment, AttachmentAdapter, AttachmentRuntime, AttachmentState, AttachmentStatus, ChatModelAdapter, ChatModelRunOptions, ChatModelRunResult, ChatModelRunUpdate, CompleteAttachment, ComposerRuntime, ComposerState, CompositeAttachmentAdapter, CreateAppendMessage, CreateAttachment, CreateResumeRunConfig, CreateStartRunConfig, CreateSuggestionAdapterOptions, DataMessagePart, DictationAdapter, DictationState, EditComposerRuntime, EditComposerState, ExportedMessageRepository, ExportedMessageRepositoryItem, ExternalStoreAdapter, ExternalStoreBranchChange, ExternalStoreMessageConverter, ExternalStoreSharedOptions, ExternalStoreThreadData, ExternalStoreThreadListAdapter, ExternalThreadBranchAdapter, ExternalThreadQueueAdapter, FRAME_MESSAGE_CHANNEL, FeedbackAdapter, FileMessagePart, FrameMessage, FrameMessageType, GenerativeUIMessagePart, GenerativeUINode, GenerativeUISpec, GenericThreadHistoryAdapter, ImageMessagePart, InMemoryThreadListAdapter, LanguageModelConfig, LanguageModelV1CallSettings, LocalRuntimeOptionsBase, MessageFormatAdapter, MessageFormatItem, MessageFormatRepository, MessageNotSentError, MessagePartRuntime, MessagePartState, MessagePartStatus, MessagePartStreamStatus, MessageQueueController, MessageQueueDriver, MessageRuntime, MessageState, MessageStatus, MessageStorageEntry, MessageTiming, ModelContext, ModelContextProvider, ModelContextRegistry, ModelContextRegistryInstructionHandle, ModelContextRegistryProviderHandle, ModelContextRegistryToolHandle, PartProviderMetadata, PendingAttachment, QuoteInfo, RealtimeVoiceAdapter, ReasoningMessagePart, RemoteThreadListAdapter, RemoteThreadListProviderComponent, RespondToToolApprovalOptions, SerializedModelContext, SerializedTool, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SourceMessagePart, SourceProviderMetadata, SpeechSynthesisAdapter, SubmitFeedbackOptions, SuggestionAdapter, SuggestionAdapterGenerateOptions, TextMessagePart, ThreadAssistantMessage, ThreadAssistantMessagePart, ThreadComposerRuntime, ThreadComposerState, ThreadHistoryAdapter, ThreadListItemRuntime, ThreadListItemState, ThreadListItemStatus, ThreadListRuntime, ThreadListState, ThreadMessage, ThreadMessageLike, ThreadRuntime, ThreadState, ThreadSuggestion, ThreadSystemMessage, ThreadUserMessage, ThreadUserMessagePart, ToolApprovalDisplay, ToolApprovalOption, ToolApprovalOptionKind, ToolApprovalResponse, ToolCallMessagePart, ToolCallMessagePartStatus, ToolCallTiming, ToolModelContentPart, Unstable_AudioMessagePart, Unstable_DirectiveFormatter, Unstable_DirectiveSegment, Unstable_InteractableSnapshotEntry, Unstable_InteractableVersion, Unstable_TriggerItem, Unsubscribe, VoiceSessionControls, VoiceSessionHelpers, VoiceSessionState, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createSuggestionAdapter, createVoiceSession, fromThreadMessageLike, generateId, getExternalStoreMessages, isMessageNotSentError, mergeModelContexts, pickExternalStoreSharedOptions, tool, toolApprovalAcceptsText, unstable_defaultDirectiveFormatter, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions } from "@assistant-ui/core";
|
|
78
|
-
import { AssistantCloud } from "assistant-cloud";
|
|
78
|
+
import { AssistantCloud, readAnonymousRefreshToken } from "assistant-cloud";
|
|
79
79
|
import { ChainOfThoughtClient, ComposerSendOptions, ExternalThread, ExternalThreadMessage, ExternalThreadProps, InMemoryThreadList, InMemoryThreadListProps, ModelContext as ModelContextClient, QueueItemMethods, QueueItemState, RemoteThreadList, RemoteThreadListProps, SingleThreadList, SuggestionConfig, Suggestions } from "@assistant-ui/core/store";
|
|
80
80
|
import { ShimLoadError, ShimLoadErrorCode } from "safe-content-frame";
|
|
81
81
|
import { Tool } from "assistant-stream";
|
|
82
|
-
export { actionBarMore_d_exports as ActionBarMorePrimitive, actionBar_d_exports as ActionBarPrimitive, type AddToolResultOptions, type AppendMessage, type Assistant, type AssistantClient, AssistantCloud, type AssistantContextConfig, type AssistantDataUI, type AssistantDataUIProps, type AssistantEventCallback, type AssistantEventName, type AssistantEventPayload, type AssistantEventScope, type AssistantEventSelector, AssistantFrameHost, AssistantFrameProvider, type AssistantInteractableProps, assistantModal_d_exports as AssistantModalPrimitive, type AssistantRuntime, AssistantRuntimeProvider, type AssistantState, type AssistantTool, type AssistantToolProps, type AssistantToolUI, type AssistantToolUIProps, type AssistantTransportCommand, type AssistantTransportConnectionMetadata, type AssistantTransportProtocol, type Attachment, type AttachmentAdapter, attachment_d_exports as AttachmentPrimitive, type AttachmentRuntime, type AttachmentState, type AttachmentStatus, AuiConfig, AuiIf, AuiProvider, branchPicker_d_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, chainOfThought_d_exports as ChainOfThoughtPrimitive, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, CloudFileAttachmentAdapter, type CompleteAttachment, ComposerAttachmentByIndexProvider, composer_d_exports as ComposerPrimitive, type ComposerRuntime, type ComposerSendOptions, type ComposerState, CompositeAttachmentAdapter, type CreateAppendMessage, type CreateAttachment, type CreateResumeRunConfig, type CreateStartRunConfig, type CreateSuggestionAdapterOptions, type DataMessagePart, type DataMessagePartComponent, type DataMessagePartProps, DataRenderers, DevToolsHooks, DevToolsProviderApi, type DictationAdapter, type DictationState, type EditComposerRuntime, type EditComposerState, type EmptyMessagePartComponent, type EmptyMessagePartProps, type EnrichedPartState, error_d_exports as ErrorPrimitive, ExportedMessageRepository, type ExportedMessageRepositoryItem, type ExternalStoreAdapter, type ExternalStoreBranchChange, type ExternalStoreMessageConverter, type ExternalStoreSharedOptions, type ExternalStoreThreadData, type ExternalStoreThreadListAdapter, ExternalThread, type ExternalThreadBranchAdapter, type ExternalThreadMessage, type ExternalThreadProps, type ExternalThreadQueueAdapter, FRAME_MESSAGE_CHANNEL, type FeedbackAdapter, type FileMessagePart, type FileMessagePartComponent, type FileMessagePartProps, type FrameMessage, type FrameMessageType, type GenerativeUIComponentRegistry, type GenerativeUIMessagePart, type GenerativeUIMessagePartComponent, type GenerativeUIMessagePartProps, type GenerativeUINode, GenerativeUIRender, GenerativeUIRenderError, type GenerativeUIRenderProps, type GenerativeUISpec, type GenericThreadHistoryAdapter, type GroupByContext, internal_d_exports as INTERNAL, type ImageMessagePart, type ImageMessagePartComponent, type ImageMessagePartProps, InMemoryThreadList, InMemoryThreadListAdapter, type InMemoryThreadListProps, Interactables, type LanguageModelConfig, type LanguageModelV1CallSettings, type LocalRuntimeOptions, type LocalRuntimeOptionsBase, type McpAppBridgeHandlers, type McpAppDisplayMode, type McpAppHostContext, type McpAppHostInfo, type McpAppMetadata, type McpAppPartOptions, McpAppRenderer, type McpAppRendererOptions, type McpAppResource, type McpAppResourceCSP, type McpAppResourceMeta, type McpAppResourceOutput, type McpAppSandboxConfig, type McpAppToolCallParams, type McpAppsHost, McpAppsRemoteHost, type McpAppsRemoteHostOptions, type McpToolkitDefinition, type McpToolkitEntry, type McpToolkitToolConfig, MessageAttachmentByIndexProvider, MessageByIndexProvider, type MessageFormatAdapter, type MessageFormatItem, type MessageFormatRepository, MessageNotSentError, messagePart_d_exports as MessagePartPrimitive, type MessagePartRuntime, type MessagePartState, type MessagePartStatus, type MessagePartStreamStatus, message_d_exports as MessagePrimitive, MessageProvider, type MessageQueueController, type MessageQueueDriver, type MessageRuntime, type MessageState, type MessageStatus, type MessageStorageEntry, type MessageTiming, type ModelContext, ModelContextClient, type ModelContextProvider, ModelContextRegistry, type ModelContextRegistryInstructionHandle, type ModelContextRegistryProviderHandle, type ModelContextRegistryToolHandle, PartByIndexProvider, type PartProviderMetadata, type PartState, type PendingAttachment, type ProviderToolConfig, type QueueItemMethods, queueItem_d_exports as QueueItemPrimitive, type QueueItemState, type QuoteInfo, type QuoteMessagePartComponent, type QuoteMessagePartProps, ReadonlyThreadProvider, type RealtimeVoiceAdapter, type ReasoningGroupComponent, type ReasoningGroupProps, type ReasoningMessagePart, type ReasoningMessagePartComponent, type ReasoningMessagePartProps, RemoteThreadList, type RemoteThreadListAdapter, type RemoteThreadListProps, type RemoteThreadListProviderComponent, type RespondToToolApprovalOptions, RuntimeAdapterProvider, type RuntimeAdapters, selectionToolbar_d_exports as SelectionToolbarPrimitive, type SendCommandsRequestBody, type SerializedModelContext, type SerializedTool, type ShimLoadError, type ShimLoadErrorCode, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SingleThreadList, type SmoothOptions, type SourceMessagePart, type SourceMessagePartComponent, type SourceMessagePartProps, type SourceProviderMetadata, type SpeechSynthesisAdapter, type SubmitFeedbackOptions, type SuggestionAdapter, type SuggestionAdapterGenerateOptions, SuggestionByIndexProvider, type SuggestionConfig, suggestion_d_exports as SuggestionPrimitive, Suggestions, type TextMessagePart, type TextMessagePartComponent, type TextMessagePartProps, TextMessagePartProvider, type ThreadAssistantMessage, type ThreadAssistantMessagePart, type ThreadComposerRuntime, type ThreadComposerState, type ThreadHistoryAdapter, ThreadListItemByIndexProvider, threadListItemMore_d_exports as ThreadListItemMorePrimitive, threadListItem_d_exports as ThreadListItemPrimitive, type ThreadListItemRuntime, ThreadListItemRuntimeProvider, type ThreadListItemState, type ThreadListItemStatus, threadList_d_exports as ThreadListPrimitive, type ThreadListRuntime, type ThreadListState, type ThreadMessage, type ThreadMessageLike, thread_d_exports as ThreadPrimitive, type ThreadRuntime, type ThreadState, type ThreadSuggestion, type ThreadSystemMessage, type ThreadUserMessage, type ThreadUserMessagePart, type ThreadViewportState, type Tool, type ToolApprovalDisplay, type ToolApprovalOption, type ToolApprovalOptionKind, type ToolApprovalResponse, type ToolArgsStatus, type ToolCallMessagePart, type ToolCallMessagePartComponent, type ToolCallMessagePartMcpMetadata, type ToolCallMessagePartProps, type ToolCallMessagePartStatus, type ToolCallText, type ToolCallTiming, type ToolDefinition, type ToolExecutionStatus, type ToolModelContentPart, type Toolkit, type ToolkitDefinition, type ToolkitDefinitionEntry, Tools, type Unstable_AudioMessagePart, type Unstable_AudioMessagePartComponent, type Unstable_AudioMessagePartProps, type Unstable_ComposerInput, type Unstable_ComposerInputHistory, type Unstable_DirectiveFormatter, type Unstable_DirectiveSegment, type Unstable_IconComponent, type Unstable_InferInteractableState, type Unstable_InteractableConfig, type Unstable_InteractableDefinition, type Unstable_InteractablePersistedState, type Unstable_InteractablePersistenceAdapter, type Unstable_InteractablePersistenceStatus, type Unstable_InteractableRegistration, type Unstable_InteractableSnapshotEntry, type Unstable_InteractableStateSchema, type Unstable_InteractableToolConfig, type Unstable_InteractableToolRenderProps, type Unstable_InteractableVersion, type Unstable_InteractableVersionInfo, type Unstable_InteractablesClientSchema, type Unstable_InteractablesConfig, type Unstable_InteractablesMethods, type Unstable_InteractablesState, type Unstable_Mention, type Unstable_MentionCategory, type Unstable_MentionDirective, type Unstable_MessageStallDetection, type Unstable_MessageStallDetectionOptions, type Unstable_ModelContextToolsOptions, type RegisteredTrigger as Unstable_RegisteredTrigger, type Unstable_SlashCommand, type Unstable_SlashCommandAction, type TriggerBehavior as Unstable_TriggerBehavior, type Unstable_TriggerItem, type TriggerMatch as Unstable_TriggerMatch, type TriggerMatcher as Unstable_TriggerMatcher, type Unstable_TriggerPopoverAriaProps, type Unstable_UseComposerInputOptions, type Unstable_UseLiveCompletionAdapterOptions, type Unstable_UseMentionAdapterOptions, type Unstable_UseSlashCommandAdapterOptions, type Unstable_WebMcpProviderOptions, type Unstable_WebMcpProviderResult, type Unsubscribe, type VoiceSessionControls, type VoiceSessionHelpers, type VoiceSessionState, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createSuggestionAdapter, createVoiceSession, defineMcpToolkit, defineToolkit, externalTool, fromThreadMessageLike, generateId, getExternalStoreMessages, getMcpAppFromToolPart, groupPartByType, hitl, hitlTool, humanTool, isMessageNotSentError, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, makeAssistantVisible, mergeModelContexts, pickExternalStoreSharedOptions, providerTool, stubTool, tool, toolApprovalAcceptsText, unstable_Interactables, convertExternalMessages as unstable_convertExternalMessages, createMessageConverter as unstable_createMessageConverter, unstable_defaultDirectiveFormatter, defaultWebMcpFilter as unstable_defaultWebMcpFilter, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions, unstable_interactableTool, unstable_useComposerInput, unstable_useComposerInputHistory, unstable_useInteractable, unstable_useInteractableState, unstable_useInteractableVersions, unstable_useLiveCompletionAdapter, unstable_useMentionAdapter, unstable_useMessageStallDetection, unstable_useSlashCommandAdapter, unstable_useThreadMessageIds, unstable_useTriggerPopoverAriaProps, useTriggerPopoverRootContext as unstable_useTriggerPopoverRootContext, useTriggerPopoverRootContextOptional as unstable_useTriggerPopoverRootContextOptional, useTriggerPopoverScopeContext as unstable_useTriggerPopoverScopeContext, useTriggerPopoverScopeContextOptional as unstable_useTriggerPopoverScopeContextOptional, useTriggerPopoverTriggers as unstable_useTriggerPopoverTriggers, useTriggerPopoverTriggersOptional as unstable_useTriggerPopoverTriggersOptional, unstable_useWebMcpProvider, useAssistantContext, useAssistantDataUI, useAssistantFrameHost, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAssistantTransportRuntime, useAssistantTransportSendCommand, useAssistantTransportState, useAui, useAuiEvent, useAuiState, useAuiToolOverrides, useCloudThreadListAdapter, useCloudThreadListRuntime, useExternalMessageConverter, useExternalStoreRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useLocalRuntime, useMessagePartData, useMessagePartFile, useMessagePartImage, useMessagePartReasoning, useMessagePartSource, useMessagePartText, useMessageQuote, useMessageTiming, useRemoteThreadListRuntime, useRuntimeAdapters, useScrollLock, useSmooth, useThreadViewport, useThreadViewportAutoScroll, useThreadViewportStore, useToolArgsStatus, useToolCallElapsed, useVoiceControls, useVoiceState, useVoiceVolume };
|
|
82
|
+
export { actionBarMore_d_exports as ActionBarMorePrimitive, actionBar_d_exports as ActionBarPrimitive, type AddToolResultOptions, type AppendMessage, type Assistant, type AssistantClient, AssistantCloud, type AssistantContextConfig, type AssistantDataUI, type AssistantDataUIProps, type AssistantEventCallback, type AssistantEventName, type AssistantEventPayload, type AssistantEventScope, type AssistantEventSelector, AssistantFrameHost, AssistantFrameProvider, type AssistantInteractableProps, assistantModal_d_exports as AssistantModalPrimitive, type AssistantRuntime, AssistantRuntimeProvider, type AssistantState, type AssistantTool, type AssistantToolProps, type AssistantToolUI, type AssistantToolUIProps, type AssistantTransportCommand, type AssistantTransportConnectionMetadata, type AssistantTransportProtocol, type Attachment, type AttachmentAdapter, attachment_d_exports as AttachmentPrimitive, type AttachmentRuntime, type AttachmentState, type AttachmentStatus, AuiConfig, AuiIf, AuiProvider, branchPicker_d_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, chainOfThought_d_exports as ChainOfThoughtPrimitive, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, CloudFileAttachmentAdapter, type CompleteAttachment, ComposerAttachmentByIndexProvider, composer_d_exports as ComposerPrimitive, type ComposerRuntime, type ComposerSendOptions, type ComposerState, CompositeAttachmentAdapter, type CreateAppendMessage, type CreateAttachment, type CreateResumeRunConfig, type CreateStartRunConfig, type CreateSuggestionAdapterOptions, type DataMessagePart, type DataMessagePartComponent, type DataMessagePartProps, DataRenderers, DevToolsHooks, DevToolsProviderApi, type DictationAdapter, type DictationState, type EditComposerRuntime, type EditComposerState, type EmptyMessagePartComponent, type EmptyMessagePartProps, type EnrichedPartState, error_d_exports as ErrorPrimitive, ExportedMessageRepository, type ExportedMessageRepositoryItem, type ExternalStoreAdapter, type ExternalStoreBranchChange, type ExternalStoreMessageConverter, type ExternalStoreSharedOptions, type ExternalStoreThreadData, type ExternalStoreThreadListAdapter, ExternalThread, type ExternalThreadBranchAdapter, type ExternalThreadMessage, type ExternalThreadProps, type ExternalThreadQueueAdapter, FRAME_MESSAGE_CHANNEL, type FeedbackAdapter, type FileMessagePart, type FileMessagePartComponent, type FileMessagePartProps, type FrameMessage, type FrameMessageType, type GenerativeUIComponentRegistry, type GenerativeUIMessagePart, type GenerativeUIMessagePartComponent, type GenerativeUIMessagePartProps, type GenerativeUINode, GenerativeUIRender, GenerativeUIRenderError, type GenerativeUIRenderProps, type GenerativeUISpec, type GenericThreadHistoryAdapter, type GroupByContext, internal_d_exports as INTERNAL, type ImageMessagePart, type ImageMessagePartComponent, type ImageMessagePartProps, InMemoryThreadList, InMemoryThreadListAdapter, type InMemoryThreadListProps, Interactables, type LanguageModelConfig, type LanguageModelV1CallSettings, type LocalRuntimeOptions, type LocalRuntimeOptionsBase, type McpAppBridgeHandlers, type McpAppDisplayMode, type McpAppHostContext, type McpAppHostInfo, type McpAppMetadata, type McpAppPartOptions, McpAppRenderer, type McpAppRendererOptions, type McpAppResource, type McpAppResourceCSP, type McpAppResourceMeta, type McpAppResourceOutput, type McpAppSandboxConfig, type McpAppToolCallParams, type McpAppsHost, McpAppsRemoteHost, type McpAppsRemoteHostOptions, type McpToolkitDefinition, type McpToolkitEntry, type McpToolkitToolConfig, MessageAttachmentByIndexProvider, MessageByIndexProvider, type MessageFormatAdapter, type MessageFormatItem, type MessageFormatRepository, MessageNotSentError, messagePart_d_exports as MessagePartPrimitive, type MessagePartRuntime, type MessagePartState, type MessagePartStatus, type MessagePartStreamStatus, message_d_exports as MessagePrimitive, MessageProvider, type MessageQueueController, type MessageQueueDriver, type MessageRuntime, type MessageState, type MessageStatus, type MessageStorageEntry, type MessageTiming, type ModelContext, ModelContextClient, type ModelContextProvider, ModelContextRegistry, type ModelContextRegistryInstructionHandle, type ModelContextRegistryProviderHandle, type ModelContextRegistryToolHandle, PartByIndexProvider, type PartProviderMetadata, type PartState, type PendingAttachment, type ProviderToolConfig, type QueueItemMethods, queueItem_d_exports as QueueItemPrimitive, type QueueItemState, type QuoteInfo, type QuoteMessagePartComponent, type QuoteMessagePartProps, ReadonlyThreadProvider, type RealtimeVoiceAdapter, type ReasoningGroupComponent, type ReasoningGroupProps, type ReasoningMessagePart, type ReasoningMessagePartComponent, type ReasoningMessagePartProps, RemoteThreadList, type RemoteThreadListAdapter, type RemoteThreadListProps, type RemoteThreadListProviderComponent, type RespondToToolApprovalOptions, RuntimeAdapterProvider, type RuntimeAdapters, selectionToolbar_d_exports as SelectionToolbarPrimitive, type SendCommandsRequestBody, type SerializedModelContext, type SerializedTool, type ShimLoadError, type ShimLoadErrorCode, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SingleThreadList, type SmoothOptions, type SourceMessagePart, type SourceMessagePartComponent, type SourceMessagePartProps, type SourceProviderMetadata, type SpeechSynthesisAdapter, type SubmitFeedbackOptions, type SuggestionAdapter, type SuggestionAdapterGenerateOptions, SuggestionByIndexProvider, type SuggestionConfig, suggestion_d_exports as SuggestionPrimitive, Suggestions, type TextMessagePart, type TextMessagePartComponent, type TextMessagePartProps, TextMessagePartProvider, type ThreadAssistantMessage, type ThreadAssistantMessagePart, type ThreadComposerRuntime, type ThreadComposerState, type ThreadHistoryAdapter, ThreadListItemByIndexProvider, threadListItemMore_d_exports as ThreadListItemMorePrimitive, threadListItem_d_exports as ThreadListItemPrimitive, type ThreadListItemRuntime, ThreadListItemRuntimeProvider, type ThreadListItemState, type ThreadListItemStatus, threadList_d_exports as ThreadListPrimitive, type ThreadListRuntime, type ThreadListState, type ThreadMessage, type ThreadMessageLike, thread_d_exports as ThreadPrimitive, type ThreadRuntime, type ThreadState, type ThreadSuggestion, type ThreadSystemMessage, type ThreadUserMessage, type ThreadUserMessagePart, type ThreadViewportState, type Tool, type ToolApprovalDisplay, type ToolApprovalOption, type ToolApprovalOptionKind, type ToolApprovalResponse, type ToolArgsStatus, type ToolCallMessagePart, type ToolCallMessagePartComponent, type ToolCallMessagePartMcpMetadata, type ToolCallMessagePartProps, type ToolCallMessagePartStatus, type ToolCallText, type ToolCallTiming, type ToolDefinition, type ToolExecutionStatus, type ToolModelContentPart, type Toolkit, type ToolkitDefinition, type ToolkitDefinitionEntry, Tools, type Unstable_AudioMessagePart, type Unstable_AudioMessagePartComponent, type Unstable_AudioMessagePartProps, type Unstable_ComposerInput, type Unstable_ComposerInputHistory, type Unstable_DirectiveFormatter, type Unstable_DirectiveSegment, type Unstable_IconComponent, type Unstable_InferInteractableState, type Unstable_InteractableConfig, type Unstable_InteractableDefinition, type Unstable_InteractablePersistedState, type Unstable_InteractablePersistenceAdapter, type Unstable_InteractablePersistenceStatus, type Unstable_InteractableRegistration, type Unstable_InteractableSnapshotEntry, type Unstable_InteractableStateSchema, type Unstable_InteractableToolConfig, type Unstable_InteractableToolRenderProps, type Unstable_InteractableVersion, type Unstable_InteractableVersionInfo, type Unstable_InteractablesClientSchema, type Unstable_InteractablesConfig, type Unstable_InteractablesMethods, type Unstable_InteractablesState, type Unstable_Mention, type Unstable_MentionCategory, type Unstable_MentionDirective, type Unstable_MessageStallDetection, type Unstable_MessageStallDetectionOptions, type Unstable_ModelContextToolsOptions, type RegisteredTrigger as Unstable_RegisteredTrigger, type Unstable_SlashCommand, type Unstable_SlashCommandAction, type TriggerBehavior as Unstable_TriggerBehavior, type Unstable_TriggerItem, type TriggerMatch as Unstable_TriggerMatch, type TriggerMatcher as Unstable_TriggerMatcher, type Unstable_TriggerPopoverAriaProps, type Unstable_UseComposerInputOptions, type Unstable_UseLiveCompletionAdapterOptions, type Unstable_UseMentionAdapterOptions, type Unstable_UseSlashCommandAdapterOptions, type Unstable_WebMcpProviderOptions, type Unstable_WebMcpProviderResult, type Unsubscribe, type VoiceSessionControls, type VoiceSessionHelpers, type VoiceSessionState, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createSuggestionAdapter, createVoiceSession, defineMcpToolkit, defineToolkit, externalTool, fromThreadMessageLike, generateId, getExternalStoreMessages, getMcpAppFromToolPart, groupPartByType, hitl, hitlTool, humanTool, isMessageNotSentError, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, makeAssistantVisible, mergeModelContexts, pickExternalStoreSharedOptions, providerTool, readAnonymousRefreshToken, stubTool, tool, toolApprovalAcceptsText, unstable_Interactables, convertExternalMessages as unstable_convertExternalMessages, createMessageConverter as unstable_createMessageConverter, unstable_defaultDirectiveFormatter, defaultWebMcpFilter as unstable_defaultWebMcpFilter, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions, unstable_interactableTool, unstable_useComposerInput, unstable_useComposerInputHistory, unstable_useInteractable, unstable_useInteractableState, unstable_useInteractableVersions, unstable_useLiveCompletionAdapter, unstable_useMentionAdapter, unstable_useMessageStallDetection, unstable_useSlashCommandAdapter, unstable_useThreadMessageIds, unstable_useTriggerPopoverAriaProps, useTriggerPopoverRootContext as unstable_useTriggerPopoverRootContext, useTriggerPopoverRootContextOptional as unstable_useTriggerPopoverRootContextOptional, useTriggerPopoverScopeContext as unstable_useTriggerPopoverScopeContext, useTriggerPopoverScopeContextOptional as unstable_useTriggerPopoverScopeContextOptional, useTriggerPopoverTriggers as unstable_useTriggerPopoverTriggers, useTriggerPopoverTriggersOptional as unstable_useTriggerPopoverTriggersOptional, unstable_useWebMcpProvider, useAssistantContext, useAssistantDataUI, useAssistantFrameHost, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAssistantTransportRuntime, useAssistantTransportSendCommand, useAssistantTransportState, useAui, useAuiEvent, useAuiState, useAuiToolOverrides, useCloudThreadListAdapter, useCloudThreadListRuntime, useExternalMessageConverter, useExternalStoreRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useLocalRuntime, useMessagePartData, useMessagePartFile, useMessagePartImage, useMessagePartReasoning, useMessagePartSource, useMessagePartText, useMessageQuote, useMessageTiming, useRemoteThreadListRuntime, useRuntimeAdapters, useScrollLock, useSmooth, useThreadViewport, useThreadViewportAutoScroll, useThreadViewportStore, useToolArgsStatus, useToolCallElapsed, useVoiceControls, useVoiceState, useVoiceVolume };
|
package/dist/index.js
CHANGED
|
@@ -66,6 +66,6 @@ import { unstable_useWebMcpProvider } from "./unstable/webmcp/useWebMcpProvider.
|
|
|
66
66
|
import { DataRenderers, GenerativeUIRender, GenerativeUIRenderError, Interactables, RuntimeAdapterProvider, Tools, defineMcpToolkit, defineToolkit, externalTool, groupPartByType, hitl, hitlTool, humanTool, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, providerTool, stubTool, unstable_Interactables, unstable_interactableTool, unstable_useInteractable, unstable_useInteractableState, unstable_useInteractableVersions, unstable_useThreadMessageIds, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAuiToolOverrides, useCloudThreadListRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useRuntimeAdapters, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume } from "@assistant-ui/core/react";
|
|
67
67
|
import { AuiConfig, AuiIf, AuiProvider, useAui, useAuiEvent, useAuiState } from "@assistant-ui/store";
|
|
68
68
|
import { AssistantFrameHost, AssistantFrameProvider, CompositeAttachmentAdapter, ExportedMessageRepository, FRAME_MESSAGE_CHANNEL, InMemoryThreadListAdapter, MessageNotSentError, ModelContextRegistry, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createSuggestionAdapter, createVoiceSession, fromThreadMessageLike, generateId, getExternalStoreMessages, isMessageNotSentError, mergeModelContexts, pickExternalStoreSharedOptions, tool, toolApprovalAcceptsText, unstable_defaultDirectiveFormatter, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions } from "@assistant-ui/core";
|
|
69
|
-
import { AssistantCloud } from "assistant-cloud";
|
|
69
|
+
import { AssistantCloud, readAnonymousRefreshToken } from "assistant-cloud";
|
|
70
70
|
import { ChainOfThoughtClient, ExternalThread, InMemoryThreadList, ModelContext as ModelContextClient, RemoteThreadList, SingleThreadList, Suggestions } from "@assistant-ui/core/store";
|
|
71
|
-
export { actionBarMore_exports as ActionBarMorePrimitive, actionBar_exports as ActionBarPrimitive, AssistantCloud, AssistantFrameHost, AssistantFrameProvider, assistantModal_exports as AssistantModalPrimitive, AssistantRuntimeProvider, attachment_exports as AttachmentPrimitive, AuiConfig, AuiIf, AuiProvider, branchPicker_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, chainOfThought_exports as ChainOfThoughtPrimitive, CloudFileAttachmentAdapter, ComposerAttachmentByIndexProvider, composer_exports as ComposerPrimitive, CompositeAttachmentAdapter, DataRenderers, DevToolsHooks, DevToolsProviderApi, error_exports as ErrorPrimitive, ExportedMessageRepository, ExternalThread, FRAME_MESSAGE_CHANNEL, GenerativeUIRender, GenerativeUIRenderError, internal_exports as INTERNAL, InMemoryThreadList, InMemoryThreadListAdapter, Interactables, McpAppRenderer, McpAppsRemoteHost, MessageAttachmentByIndexProvider, MessageByIndexProvider, MessageNotSentError, messagePart_exports as MessagePartPrimitive, message_exports as MessagePrimitive, MessageProvider, ModelContextClient, ModelContextRegistry, PartByIndexProvider, queueItem_exports as QueueItemPrimitive, ReadonlyThreadProvider, RemoteThreadList, RuntimeAdapterProvider, selectionToolbar_exports as SelectionToolbarPrimitive, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SingleThreadList, SuggestionByIndexProvider, suggestion_exports as SuggestionPrimitive, Suggestions, TextMessagePartProvider, ThreadListItemByIndexProvider, threadListItemMore_exports as ThreadListItemMorePrimitive, threadListItem_exports as ThreadListItemPrimitive, ThreadListItemRuntimeProvider, threadList_exports as ThreadListPrimitive, thread_exports as ThreadPrimitive, Tools, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createSuggestionAdapter, createVoiceSession, defineMcpToolkit, defineToolkit, externalTool, fromThreadMessageLike, generateId, getExternalStoreMessages, getMcpAppFromToolPart, groupPartByType, hitl, hitlTool, humanTool, isMessageNotSentError, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, makeAssistantVisible, mergeModelContexts, pickExternalStoreSharedOptions, providerTool, stubTool, tool, toolApprovalAcceptsText, unstable_Interactables, convertExternalMessages as unstable_convertExternalMessages, createMessageConverter as unstable_createMessageConverter, unstable_defaultDirectiveFormatter, defaultWebMcpFilter as unstable_defaultWebMcpFilter, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions, unstable_interactableTool, unstable_useComposerInput, unstable_useComposerInputHistory, unstable_useInteractable, unstable_useInteractableState, unstable_useInteractableVersions, unstable_useLiveCompletionAdapter, unstable_useMentionAdapter, unstable_useMessageStallDetection, unstable_useSlashCommandAdapter, unstable_useThreadMessageIds, unstable_useTriggerPopoverAriaProps, useTriggerPopoverRootContext as unstable_useTriggerPopoverRootContext, useTriggerPopoverRootContextOptional as unstable_useTriggerPopoverRootContextOptional, useTriggerPopoverScopeContext as unstable_useTriggerPopoverScopeContext, useTriggerPopoverScopeContextOptional as unstable_useTriggerPopoverScopeContextOptional, useTriggerPopoverTriggers as unstable_useTriggerPopoverTriggers, useTriggerPopoverTriggersOptional as unstable_useTriggerPopoverTriggersOptional, unstable_useWebMcpProvider, useAssistantContext, useAssistantDataUI, useAssistantFrameHost, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAssistantTransportRuntime, useAssistantTransportSendCommand, useAssistantTransportState, useAui, useAuiEvent, useAuiState, useAuiToolOverrides, useCloudThreadListAdapter, useCloudThreadListRuntime, useExternalMessageConverter, useExternalStoreRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useLocalRuntime, useMessagePartData, useMessagePartFile, useMessagePartImage, useMessagePartReasoning, useMessagePartSource, useMessagePartText, useMessageQuote, useMessageTiming, useRemoteThreadListRuntime, useRuntimeAdapters, useScrollLock, useSmooth, useThreadViewport, useThreadViewportAutoScroll, useThreadViewportStore, useToolArgsStatus, useToolCallElapsed, useVoiceControls, useVoiceState, useVoiceVolume };
|
|
71
|
+
export { actionBarMore_exports as ActionBarMorePrimitive, actionBar_exports as ActionBarPrimitive, AssistantCloud, AssistantFrameHost, AssistantFrameProvider, assistantModal_exports as AssistantModalPrimitive, AssistantRuntimeProvider, attachment_exports as AttachmentPrimitive, AuiConfig, AuiIf, AuiProvider, branchPicker_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, chainOfThought_exports as ChainOfThoughtPrimitive, CloudFileAttachmentAdapter, ComposerAttachmentByIndexProvider, composer_exports as ComposerPrimitive, CompositeAttachmentAdapter, DataRenderers, DevToolsHooks, DevToolsProviderApi, error_exports as ErrorPrimitive, ExportedMessageRepository, ExternalThread, FRAME_MESSAGE_CHANNEL, GenerativeUIRender, GenerativeUIRenderError, internal_exports as INTERNAL, InMemoryThreadList, InMemoryThreadListAdapter, Interactables, McpAppRenderer, McpAppsRemoteHost, MessageAttachmentByIndexProvider, MessageByIndexProvider, MessageNotSentError, messagePart_exports as MessagePartPrimitive, message_exports as MessagePrimitive, MessageProvider, ModelContextClient, ModelContextRegistry, PartByIndexProvider, queueItem_exports as QueueItemPrimitive, ReadonlyThreadProvider, RemoteThreadList, RuntimeAdapterProvider, selectionToolbar_exports as SelectionToolbarPrimitive, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SingleThreadList, SuggestionByIndexProvider, suggestion_exports as SuggestionPrimitive, Suggestions, TextMessagePartProvider, ThreadListItemByIndexProvider, threadListItemMore_exports as ThreadListItemMorePrimitive, threadListItem_exports as ThreadListItemPrimitive, ThreadListItemRuntimeProvider, threadList_exports as ThreadListPrimitive, thread_exports as ThreadPrimitive, Tools, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createSuggestionAdapter, createVoiceSession, defineMcpToolkit, defineToolkit, externalTool, fromThreadMessageLike, generateId, getExternalStoreMessages, getMcpAppFromToolPart, groupPartByType, hitl, hitlTool, humanTool, isMessageNotSentError, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, makeAssistantVisible, mergeModelContexts, pickExternalStoreSharedOptions, providerTool, readAnonymousRefreshToken, stubTool, tool, toolApprovalAcceptsText, unstable_Interactables, convertExternalMessages as unstable_convertExternalMessages, createMessageConverter as unstable_createMessageConverter, unstable_defaultDirectiveFormatter, defaultWebMcpFilter as unstable_defaultWebMcpFilter, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions, unstable_interactableTool, unstable_useComposerInput, unstable_useComposerInputHistory, unstable_useInteractable, unstable_useInteractableState, unstable_useInteractableVersions, unstable_useLiveCompletionAdapter, unstable_useMentionAdapter, unstable_useMessageStallDetection, unstable_useSlashCommandAdapter, unstable_useThreadMessageIds, unstable_useTriggerPopoverAriaProps, useTriggerPopoverRootContext as unstable_useTriggerPopoverRootContext, useTriggerPopoverRootContextOptional as unstable_useTriggerPopoverRootContextOptional, useTriggerPopoverScopeContext as unstable_useTriggerPopoverScopeContext, useTriggerPopoverScopeContextOptional as unstable_useTriggerPopoverScopeContextOptional, useTriggerPopoverTriggers as unstable_useTriggerPopoverTriggers, useTriggerPopoverTriggersOptional as unstable_useTriggerPopoverTriggersOptional, unstable_useWebMcpProvider, useAssistantContext, useAssistantDataUI, useAssistantFrameHost, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAssistantTransportRuntime, useAssistantTransportSendCommand, useAssistantTransportState, useAui, useAuiEvent, useAuiState, useAuiToolOverrides, useCloudThreadListAdapter, useCloudThreadListRuntime, useExternalMessageConverter, useExternalStoreRuntime, useExternalStoreSharedOptions, useInlineRender, useInteractableState, useLocalRuntime, useMessagePartData, useMessagePartFile, useMessagePartImage, useMessagePartReasoning, useMessagePartSource, useMessagePartText, useMessageQuote, useMessageTiming, useRemoteThreadListRuntime, useRuntimeAdapters, useScrollLock, useSmooth, useThreadViewport, useThreadViewportAutoScroll, useThreadViewportStore, useToolArgsStatus, useToolCallElapsed, useVoiceControls, useVoiceState, useVoiceVolume };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-frame.d.ts","names":[],"sources":["../../src/mcp-apps/app-frame.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"app-frame.d.ts","names":[],"sources":["../../src/mcp-apps/app-frame.tsx"],"mappings":";;iBA8JgB,cACd,KACA,UACA,OACA,QACA,SACA,UACA,UACA,aACA,aACC,mCAAgB,IAAA"}
|
|
@@ -17,7 +17,11 @@ const isPlainObject = (value) => {
|
|
|
17
17
|
const isSameHostContext = (a, b, depth = 0) => {
|
|
18
18
|
if (Object.is(a, b)) return true;
|
|
19
19
|
if (depth > 100) return false;
|
|
20
|
-
if (Array.isArray(a) || Array.isArray(b))
|
|
20
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
21
|
+
if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;
|
|
22
|
+
for (let i = 0; i < a.length; i++) if (!isSameHostContext(a[i], b[i], depth + 1)) return false;
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
21
25
|
if (!isPlainObject(a) || !isPlainObject(b)) return false;
|
|
22
26
|
const aKeys = Object.keys(a);
|
|
23
27
|
return aKeys.length === Object.keys(b).length && aKeys.every((key) => Object.hasOwn(b, key) && isSameHostContext(a[key], b[key], depth + 1));
|
|
@@ -57,11 +61,11 @@ function useBridgeNotify(value, bridgeRef, widgetReadyRef, pendingRef, lastSentR
|
|
|
57
61
|
} else t2 = $[9];
|
|
58
62
|
useEffect(t1, t2);
|
|
59
63
|
}
|
|
60
|
-
function buildLiveHandlers(initial, liveRef) {
|
|
64
|
+
function buildLiveHandlers(initial, liveRef, lifecycle) {
|
|
61
65
|
const live = () => liveRef.current.handlers;
|
|
62
66
|
const has = (key) => initial?.[key] !== void 0;
|
|
63
67
|
const out = {};
|
|
64
|
-
|
|
68
|
+
Object.defineProperty(out, "allowedTools", {
|
|
65
69
|
get: () => live()?.allowedTools,
|
|
66
70
|
enumerable: true,
|
|
67
71
|
configurable: true
|
|
@@ -78,8 +82,14 @@ function buildLiveHandlers(initial, liveRef) {
|
|
|
78
82
|
if (has("sendMessage")) out.sendMessage = liveCall("sendMessage");
|
|
79
83
|
if (has("updateModelContext")) out.updateModelContext = liveCall("updateModelContext");
|
|
80
84
|
if (has("requestDisplayMode")) out.requestDisplayMode = liveCall("requestDisplayMode");
|
|
81
|
-
out.onSizeChange = (p) =>
|
|
82
|
-
|
|
85
|
+
out.onSizeChange = (p) => {
|
|
86
|
+
lifecycle.onSizeChange(p);
|
|
87
|
+
live()?.onSizeChange?.(p);
|
|
88
|
+
};
|
|
89
|
+
out.onInitialized = () => {
|
|
90
|
+
lifecycle.onInitialized();
|
|
91
|
+
live()?.onInitialized?.();
|
|
92
|
+
};
|
|
83
93
|
out.onRequestTeardown = (p) => live()?.onRequestTeardown?.(p);
|
|
84
94
|
out.onLog = (p) => live()?.onLog?.(p);
|
|
85
95
|
out.onError = (e) => live()?.onError?.(e);
|
|
@@ -171,23 +181,18 @@ function McpAppFrame(t0) {
|
|
|
171
181
|
pendingHostContextRef.current = void 0;
|
|
172
182
|
}
|
|
173
183
|
};
|
|
174
|
-
const
|
|
175
|
-
const liveOnInitialized = liveHandlers.onInitialized;
|
|
176
|
-
const wrappedHandlers = {
|
|
177
|
-
...liveHandlers,
|
|
184
|
+
const wrappedHandlers = buildLiveHandlers(current.handlers, liveRef, {
|
|
178
185
|
onInitialized: () => {
|
|
179
186
|
if (initTimeoutId !== null) {
|
|
180
187
|
clearTimeout(initTimeoutId);
|
|
181
188
|
initTimeoutId = null;
|
|
182
189
|
}
|
|
183
190
|
flushPending();
|
|
184
|
-
liveOnInitialized?.();
|
|
185
191
|
},
|
|
186
192
|
onSizeChange: (p) => {
|
|
187
193
|
if (p.height != null) host.setHeight(p.height);
|
|
188
|
-
liveHandlers.onSizeChange?.(p);
|
|
189
194
|
}
|
|
190
|
-
};
|
|
195
|
+
});
|
|
191
196
|
initTimeoutId = setTimeout(() => {
|
|
192
197
|
initTimeoutId = null;
|
|
193
198
|
flushPending();
|
|
@@ -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","every","item","index","aKeys","keys","key","hasOwn","useBridgeNotify","bridgeRef","widgetReadyRef","pendingRef","lastSentRef","notify","t0","$","isEqual","undefined","t1","current","t2","LiveSnapshot","handlers","hostInfo","hostContext","input","output","buildLiveHandlers","initial","liveRef","live","has","K","out","defineProperty","get","allowedTools","enumerable","configurable","liveCall","NonNullable","p","fn","Error","callTool","readResource","listResources","openLink","sendMessage","updateModelContext","requestDisplayMode","onSizeChange","onInitialized","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","liveHandlers","liveOnInitialized","wrappedHandlers","clearTimeout","height","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"],"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 return (\n Array.isArray(a) &&\n Array.isArray(b) &&\n a.length === b.length &&\n a.every((item, index) => isSameHostContext(item, b[index], depth + 1))\n );\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\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.\nfunction buildLiveHandlers(\n initial: McpAppBridgeHandlers | undefined,\n liveRef: { readonly current: LiveSnapshot },\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 if (has(\"allowedTools\")) {\n Object.defineProperty(out, \"allowedTools\", {\n get: () => live()?.allowedTools,\n enumerable: true,\n configurable: true,\n });\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) => live()?.onSizeChange?.(p);\n out.onInitialized = () => live()?.onInitialized?.();\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 liveHandlers = buildLiveHandlers(current.handlers, liveRef);\n const liveOnInitialized = liveHandlers.onInitialized;\n const wrappedHandlers: McpAppBridgeHandlers = {\n ...liveHandlers,\n onInitialized: () => {\n if (initTimeoutId !== null) {\n clearTimeout(initTimeoutId);\n initTimeoutId = null;\n }\n flushPending();\n liveOnInitialized?.();\n },\n onSizeChange: (p) => {\n if (p.height != null) host.setHeight(p.height);\n liveHandlers.onSizeChange?.(p);\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,S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,UAAGgD,GAAG;EAACxF,EAAA,MAAAuF;CAAA,OAAAA,MAAAvF,EAAA;CAGzB,MAAAyF,MAAA7C,SAAQ8C,MAAoBC,gBAA5B,KAAAzF,KAAAA;CAElB,IAAA0F;CAAA,IAAA5F,EAAA,QAAA2C,IAAAkD,eAAA7F,EAAA,QAAAyF,KAAA;EAJCG,MAAA;GAAA,yBACWjD,IAAGkD;GAAY,+BACTJ;EAGjC;EAACzF,EAAA,MAAA2C,IAAAkD;EAAA7F,EAAA,MAAAyF;EAAAzF,EAAA,MAAA4F;CAAA,OAAAA,MAAA5F,EAAA;CAAA,IAAA8F;CAAA,IAAA9F,EAAA,QAAA8C,aAAA9C,EAAA,QAAA4F,OAAA5F,EAAA,QAAA+E,MAAA/E,EAAA,QAAAiF,MAAAjF,EAAA,QAAAsF,IAAA;EAdHQ,MAAA,oBAAC,aAAD;GACW,SAAAf;GAEP,YAAAE;GAEO,SAAAK;GACExC;GACG6B;GACL,SAAAY;GACO,gBAAAK;EAKf,CAAA;EACD5F,EAAA,MAAA8C;EAAA9C,EAAA,MAAA4F;EAAA5F,EAAA,MAAA+E;EAAA/E,EAAA,MAAAiF;EAAAjF,EAAA,MAAAsF;EAAAtF,EAAA,MAAA8F;CAAA,OAAAA,MAAA9F,EAAA;CAAA,OAfF8F;AAeE;AAhLC,SAAAhB,OAAAiB,KAAAC,KAAA;CAAA,OA4JOpH,IAACoF,yBAA0BiC,GAAC;AAAC;AA5JpC,SAAApB,OAAAqB,KAAAC,KAAA;CAAA,OAoJOvH,IAACmF,iBAAkBkC,GAAC;AAAC;AApJ5B,SAAArB,MAAAwB,KAAAH,GAAA;CAAA,OA4IOrH,IAACkF,gBAAiBmC,CAAC;AAAC"}
|
|
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"],"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,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,C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AAE;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"}
|
package/dist/mcp-apps/bridge.js
CHANGED
|
@@ -40,7 +40,9 @@ function isNotification(msg) {
|
|
|
40
40
|
}
|
|
41
41
|
function createMcpAppBridge(opts) {
|
|
42
42
|
const { frame, handlers = {}, hostInfo = DEFAULT_HOST_INFO, hostContext = {} } = opts;
|
|
43
|
+
let disposed = false;
|
|
43
44
|
const post = (msg) => {
|
|
45
|
+
if (disposed) return;
|
|
44
46
|
frame.sendMessage(msg);
|
|
45
47
|
};
|
|
46
48
|
const respond = (id, payload) => {
|
|
@@ -59,6 +61,7 @@ function createMcpAppBridge(opts) {
|
|
|
59
61
|
} });
|
|
60
62
|
};
|
|
61
63
|
const reportError = (error) => {
|
|
64
|
+
if (disposed) return;
|
|
62
65
|
invokeUserCallback("assistant-ui", "MCP App onError", handlers.onError?.bind(handlers), error);
|
|
63
66
|
};
|
|
64
67
|
const handleRequest = async (req) => {
|
|
@@ -234,6 +237,7 @@ function createMcpAppBridge(opts) {
|
|
|
234
237
|
}
|
|
235
238
|
};
|
|
236
239
|
const onMessage = (event) => {
|
|
240
|
+
if (disposed) return;
|
|
237
241
|
if (!isJsonRpcMessage(event.data)) return;
|
|
238
242
|
const msg = event.data;
|
|
239
243
|
if (isRequest(msg)) handleRequest(msg);
|
|
@@ -241,7 +245,9 @@ function createMcpAppBridge(opts) {
|
|
|
241
245
|
};
|
|
242
246
|
return {
|
|
243
247
|
onMessage,
|
|
244
|
-
dispose: () => {
|
|
248
|
+
dispose: () => {
|
|
249
|
+
disposed = true;
|
|
250
|
+
},
|
|
245
251
|
notifyToolInput: (input) => {
|
|
246
252
|
post({
|
|
247
253
|
jsonrpc: "2.0",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.js","names":["SandboxHostFrame","invokeUserCallback","MCP_APP_PROTOCOL_VERSION","McpAppBridgeHandlers","McpAppDisplayMode","McpAppHostContext","McpAppHostInfo","McpAppJsonRpcMessage","McpAppJsonRpcNotification","McpAppJsonRpcRequest","McpAppJsonRpcResponse","isRecord","VALID_DISPLAY_MODES","const","McpAppBridgeFrame","CreateMcpAppBridgeOptions","frame","handlers","hostInfo","hostContext","McpAppBridge","onMessage","event","MessageEvent","dispose","notifyToolInput","input","notifyToolResult","result","notifyHostContextChanged","DEFAULT_HOST_INFO","name","version","METHOD_ALIASES","Record","normalizeMethod","method","JSONRPC_ERROR","parseError","invalidRequest","methodNotFound","invalidParams","internalError","isJsonRpcMessage","value","v","jsonrpc","isRequest","msg","isNotification","createMcpAppBridge","opts","post","sendMessage","respond","id","payload","error","code","message","data","res","errorResponse","undefined","reportError","Error","onError","bind","handleRequest","req","params","requestedProtocolVersion","protocolVersion","host","capabilities","tools","callTool","resources","readResource","listResources","ui","openLink","requestDisplayMode","updateModelContext","hostCapabilities","openLinks","serverTools","serverResources","text","onLog","logging","callParams","arguments","allowedTools","includes","callArgs","Array","isArray","readParams","uri","linkParams","url","linkProtocol","URL","protocol","modeParams","mode","err","String","handleNotification","note","onInitialized","p","width","height","onSizeChange","onRequestTeardown","content","type","ctx"],"sources":["../../src/mcp-apps/bridge.ts"],"sourcesContent":["import type { SandboxHostFrame } from \"../sandbox-host/SandboxHost\";\nimport { invokeUserCallback } from \"@assistant-ui/core/internal\";\nimport {\n MCP_APP_PROTOCOL_VERSION,\n type McpAppBridgeHandlers,\n type McpAppDisplayMode,\n type McpAppHostContext,\n type McpAppHostInfo,\n type McpAppJsonRpcMessage,\n type McpAppJsonRpcNotification,\n type McpAppJsonRpcRequest,\n type McpAppJsonRpcResponse,\n} from \"./types\";\nimport { isRecord } from \"@assistant-ui/core/internal\";\n\nconst VALID_DISPLAY_MODES = [\n \"inline\",\n \"fullscreen\",\n \"pip\",\n] as const satisfies readonly McpAppDisplayMode[];\n\nexport type McpAppBridgeFrame = SandboxHostFrame;\n\nexport type CreateMcpAppBridgeOptions = {\n frame: McpAppBridgeFrame;\n handlers?: McpAppBridgeHandlers | undefined;\n hostInfo?: McpAppHostInfo | undefined;\n hostContext?: McpAppHostContext | undefined;\n};\n\nexport type McpAppBridge = {\n onMessage: (event: MessageEvent) => void;\n dispose: () => void;\n notifyToolInput: (input: unknown) => void;\n notifyToolResult: (result: unknown) => void;\n notifyHostContextChanged: (hostContext: McpAppHostContext) => void;\n};\n\nconst DEFAULT_HOST_INFO: McpAppHostInfo = {\n name: \"assistant-ui\",\n version: \"0.1\",\n};\n\n// Accept both the legacy method names and the MCP-UI 2026-01-26 names that\n// `ui/*` capable widgets (e.g. xmcp's host-bridge) emit. Normalize on input\n// so downstream switch statements only need to know the legacy names.\nconst METHOD_ALIASES: Record<string, string> = {\n \"ui/notifications/initialized\": \"notifications/initialized\",\n \"ui/notifications/size-changed\": \"notifications/size_changed\",\n \"ui/request-display-mode\": \"requestDisplayMode\",\n \"ui/open-link\": \"openLink\",\n \"ui/update-model-context\": \"updateModelContext\",\n \"ui/message\": \"sendMessage\",\n \"notifications/message\": \"notifications/log\",\n};\n\nconst normalizeMethod = (method: string): string =>\n METHOD_ALIASES[method] ?? method;\n\nconst JSONRPC_ERROR = {\n parseError: -32700,\n invalidRequest: -32600,\n methodNotFound: -32601,\n invalidParams: -32602,\n internalError: -32603,\n} as const;\n\nfunction isJsonRpcMessage(value: unknown): value is McpAppJsonRpcMessage {\n if (!value || typeof value !== \"object\") return false;\n const v = value as Record<string, unknown>;\n return v.jsonrpc === \"2.0\" && typeof v.method === \"string\";\n}\n\nfunction isRequest(msg: McpAppJsonRpcMessage): msg is McpAppJsonRpcRequest {\n return \"id\" in msg;\n}\n\nfunction isNotification(\n msg: McpAppJsonRpcMessage,\n): msg is McpAppJsonRpcNotification {\n return !(\"id\" in msg);\n}\n\nexport function createMcpAppBridge(\n opts: CreateMcpAppBridgeOptions,\n): McpAppBridge {\n const {\n frame,\n handlers = {},\n hostInfo = DEFAULT_HOST_INFO,\n hostContext = {},\n } = opts;\n\n const post = (msg: McpAppJsonRpcMessage) => {\n frame.sendMessage(msg);\n };\n\n const respond = (\n id: McpAppJsonRpcRequest[\"id\"],\n payload:\n | { result: unknown }\n | { error: { code: number; message: string; data?: unknown } },\n ) => {\n const res: McpAppJsonRpcResponse = {\n jsonrpc: \"2.0\",\n id,\n ...payload,\n };\n post(res);\n };\n\n const errorResponse = (\n id: McpAppJsonRpcRequest[\"id\"],\n code: number,\n message: string,\n data?: unknown,\n ) => {\n respond(id, {\n error: {\n code,\n message,\n ...(data !== undefined ? { data } : {}),\n },\n });\n };\n\n const reportError = (error: Error) => {\n invokeUserCallback(\n \"assistant-ui\",\n \"MCP App onError\",\n handlers.onError?.bind(handlers),\n error,\n );\n };\n\n const handleRequest = async (req: McpAppJsonRpcRequest) => {\n try {\n const params = req.params;\n\n switch (normalizeMethod(req.method)) {\n case \"ui/initialize\": {\n const requestedProtocolVersion =\n isRecord(params) && typeof params.protocolVersion === \"string\"\n ? params.protocolVersion\n : MCP_APP_PROTOCOL_VERSION;\n respond(req.id, {\n result: {\n protocolVersion: requestedProtocolVersion,\n host: hostInfo,\n hostInfo,\n hostContext,\n capabilities: {\n tools: handlers.callTool ? {} : undefined,\n resources:\n handlers.readResource || handlers.listResources\n ? {}\n : undefined,\n ui: {\n sendMessage: !!handlers.sendMessage,\n openLink: !!handlers.openLink,\n requestDisplayMode: !!handlers.requestDisplayMode,\n updateModelContext: !!handlers.updateModelContext,\n },\n },\n hostCapabilities: {\n ...(handlers.openLink ? { openLinks: {} } : {}),\n ...(handlers.callTool ? { serverTools: {} } : {}),\n ...(handlers.readResource || handlers.listResources\n ? { serverResources: {} }\n : {}),\n ...(handlers.updateModelContext\n ? { updateModelContext: { text: {} } }\n : {}),\n ...(handlers.sendMessage ? { message: { text: {} } } : {}),\n ...(handlers.onLog ? { logging: {} } : {}),\n },\n },\n });\n return;\n }\n\n case \"tools/call\": {\n if (!handlers.callTool) {\n errorResponse(\n req.id,\n JSONRPC_ERROR.methodNotFound,\n \"tools/call is not supported by this host\",\n );\n return;\n }\n const callParams = (params ?? {}) as {\n name?: unknown;\n arguments?: unknown;\n };\n if (typeof callParams.name !== \"string\") {\n errorResponse(\n req.id,\n JSONRPC_ERROR.invalidParams,\n \"tools/call requires a string 'name'\",\n );\n return;\n }\n if (\n handlers.allowedTools &&\n !handlers.allowedTools.includes(callParams.name)\n ) {\n errorResponse(\n req.id,\n JSONRPC_ERROR.invalidParams,\n `tool '${callParams.name}' is not allowed for this app`,\n );\n return;\n }\n let callArgs: Record<string, unknown> | undefined;\n if (callParams.arguments !== undefined) {\n if (\n callParams.arguments === null ||\n typeof callParams.arguments !== \"object\" ||\n Array.isArray(callParams.arguments)\n ) {\n errorResponse(\n req.id,\n JSONRPC_ERROR.invalidParams,\n \"tools/call 'arguments' must be an object\",\n );\n return;\n }\n callArgs = callParams.arguments as Record<string, unknown>;\n }\n const result = await handlers.callTool({\n name: callParams.name,\n ...(callArgs !== undefined ? { arguments: callArgs } : {}),\n });\n respond(req.id, { result });\n return;\n }\n\n case \"resources/read\": {\n if (!handlers.readResource) {\n errorResponse(\n req.id,\n JSONRPC_ERROR.methodNotFound,\n \"resources/read is not supported by this host\",\n );\n return;\n }\n const readParams = (params ?? {}) as { uri?: unknown };\n if (typeof readParams.uri !== \"string\") {\n errorResponse(\n req.id,\n JSONRPC_ERROR.invalidParams,\n \"resources/read requires a string 'uri'\",\n );\n return;\n }\n respond(req.id, {\n result: await handlers.readResource({ uri: readParams.uri }),\n });\n return;\n }\n\n case \"resources/list\": {\n if (!handlers.listResources) {\n errorResponse(\n req.id,\n JSONRPC_ERROR.methodNotFound,\n \"resources/list is not supported by this host\",\n );\n return;\n }\n respond(req.id, {\n result: (await handlers.listResources(params)) ?? null,\n });\n return;\n }\n\n case \"openLink\": {\n if (!handlers.openLink) {\n errorResponse(\n req.id,\n JSONRPC_ERROR.methodNotFound,\n \"openLink is not supported by this host\",\n );\n return;\n }\n const linkParams = (params ?? {}) as { url?: unknown };\n if (typeof linkParams.url !== \"string\") {\n errorResponse(\n req.id,\n JSONRPC_ERROR.invalidParams,\n \"openLink requires a string 'url'\",\n );\n return;\n }\n let linkProtocol: string;\n try {\n linkProtocol = new URL(linkParams.url).protocol;\n } catch {\n errorResponse(\n req.id,\n JSONRPC_ERROR.invalidParams,\n \"openLink requires a valid URL\",\n );\n return;\n }\n if (linkProtocol !== \"https:\" && linkProtocol !== \"http:\") {\n errorResponse(\n req.id,\n JSONRPC_ERROR.invalidParams,\n \"openLink only accepts http(s) URLs\",\n );\n return;\n }\n respond(req.id, {\n result: await handlers.openLink({ url: linkParams.url }),\n });\n return;\n }\n\n case \"sendMessage\": {\n if (!handlers.sendMessage) {\n errorResponse(\n req.id,\n JSONRPC_ERROR.methodNotFound,\n \"sendMessage is not supported by this host\",\n );\n return;\n }\n respond(req.id, {\n result: (await handlers.sendMessage(params)) ?? null,\n });\n return;\n }\n\n case \"updateModelContext\": {\n if (!handlers.updateModelContext) {\n errorResponse(\n req.id,\n JSONRPC_ERROR.methodNotFound,\n \"updateModelContext is not supported by this host\",\n );\n return;\n }\n respond(req.id, {\n result: (await handlers.updateModelContext(params)) ?? null,\n });\n return;\n }\n\n case \"requestDisplayMode\": {\n if (!handlers.requestDisplayMode) {\n errorResponse(\n req.id,\n JSONRPC_ERROR.methodNotFound,\n \"requestDisplayMode is not supported by this host\",\n );\n return;\n }\n const modeParams = (params ?? {}) as { mode?: unknown };\n if (\n typeof modeParams.mode !== \"string\" ||\n !VALID_DISPLAY_MODES.includes(modeParams.mode as McpAppDisplayMode)\n ) {\n errorResponse(\n req.id,\n JSONRPC_ERROR.invalidParams,\n \"requestDisplayMode requires a valid 'mode'\",\n );\n return;\n }\n respond(req.id, {\n result: await handlers.requestDisplayMode({\n mode: modeParams.mode as McpAppDisplayMode,\n }),\n });\n return;\n }\n\n default: {\n errorResponse(\n req.id,\n JSONRPC_ERROR.methodNotFound,\n `Unknown method: ${req.method}`,\n );\n }\n }\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n reportError(error);\n errorResponse(req.id, JSONRPC_ERROR.internalError, error.message);\n }\n };\n\n const handleNotification = (note: McpAppJsonRpcNotification) => {\n try {\n switch (normalizeMethod(note.method)) {\n case \"notifications/initialized\": {\n handlers.onInitialized?.();\n return;\n }\n case \"notifications/size_changed\": {\n const p = (note.params ?? {}) as { width?: number; height?: number };\n handlers.onSizeChange?.({\n ...(typeof p.width === \"number\" ? { width: p.width } : {}),\n ...(typeof p.height === \"number\" ? { height: p.height } : {}),\n });\n return;\n }\n case \"notifications/log\": {\n handlers.onLog?.(note.params);\n return;\n }\n case \"notifications/request_teardown\": {\n handlers.onRequestTeardown?.(note.params);\n return;\n }\n case \"notifications/error\": {\n const p = (note.params ?? {}) as { message?: string };\n reportError(\n new Error(\n typeof p.message === \"string\" ? p.message : \"Widget error\",\n ),\n );\n return;\n }\n default:\n return;\n }\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n reportError(error);\n }\n };\n\n // The host applies the cross-origin guard before delegating; this only\n // validates the JSON-RPC envelope.\n const onMessage = (event: MessageEvent) => {\n if (!isJsonRpcMessage(event.data)) return;\n\n const msg = event.data;\n if (isRequest(msg)) {\n void handleRequest(msg);\n } else if (isNotification(msg)) {\n handleNotification(msg);\n }\n };\n\n return {\n onMessage,\n dispose: () => {},\n notifyToolInput: (input: unknown) => {\n post({\n jsonrpc: \"2.0\",\n method: \"notifications/tools/call/input\",\n params: { input },\n });\n post({\n jsonrpc: \"2.0\",\n method: \"ui/notifications/tool-input\",\n params: isRecord(input) ? { arguments: input } : {},\n });\n },\n notifyToolResult: (result: unknown) => {\n post({\n jsonrpc: \"2.0\",\n method: \"notifications/tools/call/result\",\n params: { result },\n });\n post({\n jsonrpc: \"2.0\",\n method: \"ui/notifications/tool-result\",\n params: isRecord(result)\n ? result\n : { content: [{ type: \"text\", text: String(result) }] },\n });\n },\n notifyHostContextChanged: (ctx: McpAppHostContext) => {\n post({\n jsonrpc: \"2.0\",\n method: \"notifications/host_context/changed\",\n params: ctx,\n });\n post({\n jsonrpc: \"2.0\",\n method: \"ui/notifications/host-context-changed\",\n params: ctx,\n });\n },\n };\n}\n"],"mappings":";;;AAeA,MAAMY,sBAAsB;CAC1B;CACA;CACA;AAAK;AAoBP,MAAMkB,oBAAoC;CACxCC,MAAM;CACNC,SAAS;AACX;AAKA,MAAMC,iBAAyC;CAC7C,gCAAgC;CAChC,iCAAiC;CACjC,2BAA2B;CAC3B,gBAAgB;CAChB,2BAA2B;CAC3B,cAAc;CACd,yBAAyB;AAC3B;AAEA,MAAME,mBAAmBC,WACvBH,eAAeG,WAAWA;AAE5B,MAAMC,gBAAgB;CACpBC,YAAY;CACZC,gBAAgB;CAChBC,gBAAgB;CAChBC,eAAe;CACfC,eAAe;AACjB;AAEA,SAASC,iBAAiBC,OAA+C;CACvE,IAAI,CAACA,SAAS,OAAOA,UAAU,UAAU,OAAO;CAChD,MAAMC,IAAID;CACV,OAAOC,EAAEC,YAAY,SAAS,OAAOD,EAAET,WAAW;AACpD;AAEA,SAASW,UAAUC,KAAwD;CACzE,OAAO,QAAQA;AACjB;AAEA,SAASC,eACPD,KACkC;CAClC,OAAO,EAAE,QAAQA;AACnB;AAEA,SAAgBE,mBACdC,MACc;CACd,MAAM,EACJnC,OACAC,WAAW,CAAC,GACZC,WAAWY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MoB,OAAOhF,MAAM;IAAE,CAAC,EAAE;GAC1D,CAAC;EACH;EACAC,2BAA2B0F,QAA2B;GACpDnE,KAAK;IACHN,SAAS;IACTV,QAAQ;IACRkC,QAAQiD;GACV,CAAC;GACDnE,KAAK;IACHN,SAAS;IACTV,QAAQ;IACRkC,QAAQiD;GACV,CAAC;EACH;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"bridge.js","names":["SandboxHostFrame","invokeUserCallback","MCP_APP_PROTOCOL_VERSION","McpAppBridgeHandlers","McpAppDisplayMode","McpAppHostContext","McpAppHostInfo","McpAppJsonRpcMessage","McpAppJsonRpcNotification","McpAppJsonRpcRequest","McpAppJsonRpcResponse","isRecord","VALID_DISPLAY_MODES","const","McpAppBridgeFrame","CreateMcpAppBridgeOptions","frame","handlers","hostInfo","hostContext","McpAppBridge","onMessage","event","MessageEvent","dispose","notifyToolInput","input","notifyToolResult","result","notifyHostContextChanged","DEFAULT_HOST_INFO","name","version","METHOD_ALIASES","Record","normalizeMethod","method","JSONRPC_ERROR","parseError","invalidRequest","methodNotFound","invalidParams","internalError","isJsonRpcMessage","value","v","jsonrpc","isRequest","msg","isNotification","createMcpAppBridge","opts","disposed","post","sendMessage","respond","id","payload","error","code","message","data","res","errorResponse","undefined","reportError","Error","onError","bind","handleRequest","req","params","requestedProtocolVersion","protocolVersion","host","capabilities","tools","callTool","resources","readResource","listResources","ui","openLink","requestDisplayMode","updateModelContext","hostCapabilities","openLinks","serverTools","serverResources","text","onLog","logging","callParams","arguments","allowedTools","includes","callArgs","Array","isArray","readParams","uri","linkParams","url","linkProtocol","URL","protocol","modeParams","mode","err","String","handleNotification","note","onInitialized","p","width","height","onSizeChange","onRequestTeardown","content","type","ctx"],"sources":["../../src/mcp-apps/bridge.ts"],"sourcesContent":["import type { SandboxHostFrame } from \"../sandbox-host/SandboxHost\";\nimport { invokeUserCallback } from \"@assistant-ui/core/internal\";\nimport {\n MCP_APP_PROTOCOL_VERSION,\n type McpAppBridgeHandlers,\n type McpAppDisplayMode,\n type McpAppHostContext,\n type McpAppHostInfo,\n type McpAppJsonRpcMessage,\n type McpAppJsonRpcNotification,\n type McpAppJsonRpcRequest,\n type McpAppJsonRpcResponse,\n} from \"./types\";\nimport { isRecord } from \"@assistant-ui/core/internal\";\n\nconst VALID_DISPLAY_MODES = [\n \"inline\",\n \"fullscreen\",\n \"pip\",\n] as const satisfies readonly McpAppDisplayMode[];\n\nexport type McpAppBridgeFrame = SandboxHostFrame;\n\nexport type CreateMcpAppBridgeOptions = {\n frame: McpAppBridgeFrame;\n handlers?: McpAppBridgeHandlers | undefined;\n hostInfo?: McpAppHostInfo | undefined;\n hostContext?: McpAppHostContext | undefined;\n};\n\nexport type McpAppBridge = {\n onMessage: (event: MessageEvent) => void;\n dispose: () => void;\n notifyToolInput: (input: unknown) => void;\n notifyToolResult: (result: unknown) => void;\n notifyHostContextChanged: (hostContext: McpAppHostContext) => void;\n};\n\nconst DEFAULT_HOST_INFO: McpAppHostInfo = {\n name: \"assistant-ui\",\n version: \"0.1\",\n};\n\n// Accept both the legacy method names and the MCP-UI 2026-01-26 names that\n// `ui/*` capable widgets (e.g. xmcp's host-bridge) emit. Normalize on input\n// so downstream switch statements only need to know the legacy names.\nconst METHOD_ALIASES: Record<string, string> = {\n \"ui/notifications/initialized\": \"notifications/initialized\",\n \"ui/notifications/size-changed\": \"notifications/size_changed\",\n \"ui/request-display-mode\": \"requestDisplayMode\",\n \"ui/open-link\": \"openLink\",\n \"ui/update-model-context\": \"updateModelContext\",\n \"ui/message\": \"sendMessage\",\n \"notifications/message\": \"notifications/log\",\n};\n\nconst normalizeMethod = (method: string): string =>\n METHOD_ALIASES[method] ?? method;\n\nconst JSONRPC_ERROR = {\n parseError: -32700,\n invalidRequest: -32600,\n methodNotFound: -32601,\n invalidParams: -32602,\n internalError: -32603,\n} as const;\n\nfunction isJsonRpcMessage(value: unknown): value is McpAppJsonRpcMessage {\n if (!value || typeof value !== \"object\") return false;\n const v = value as Record<string, unknown>;\n return v.jsonrpc === \"2.0\" && typeof v.method === \"string\";\n}\n\nfunction isRequest(msg: McpAppJsonRpcMessage): msg is McpAppJsonRpcRequest {\n return \"id\" in msg;\n}\n\nfunction isNotification(\n msg: McpAppJsonRpcMessage,\n): msg is McpAppJsonRpcNotification {\n return !(\"id\" in msg);\n}\n\nexport function createMcpAppBridge(\n opts: CreateMcpAppBridgeOptions,\n): McpAppBridge {\n const {\n frame,\n handlers = {},\n hostInfo = DEFAULT_HOST_INFO,\n hostContext = {},\n } = opts;\n let disposed = false;\n\n const post = (msg: McpAppJsonRpcMessage) => {\n if (disposed) return;\n frame.sendMessage(msg);\n };\n\n const respond = (\n id: McpAppJsonRpcRequest[\"id\"],\n payload:\n | { result: unknown }\n | { error: { code: number; message: string; data?: unknown } },\n ) => {\n const res: McpAppJsonRpcResponse = {\n jsonrpc: \"2.0\",\n id,\n ...payload,\n };\n post(res);\n };\n\n const errorResponse = (\n id: McpAppJsonRpcRequest[\"id\"],\n code: number,\n message: string,\n data?: unknown,\n ) => {\n respond(id, {\n error: {\n code,\n message,\n ...(data !== undefined ? { data } : {}),\n },\n });\n };\n\n const reportError = (error: Error) => {\n if (disposed) return;\n invokeUserCallback(\n \"assistant-ui\",\n \"MCP App onError\",\n handlers.onError?.bind(handlers),\n error,\n );\n };\n\n const handleRequest = async (req: McpAppJsonRpcRequest) => {\n try {\n const params = req.params;\n\n switch (normalizeMethod(req.method)) {\n case \"ui/initialize\": {\n const requestedProtocolVersion =\n isRecord(params) && typeof params.protocolVersion === \"string\"\n ? params.protocolVersion\n : MCP_APP_PROTOCOL_VERSION;\n respond(req.id, {\n result: {\n protocolVersion: requestedProtocolVersion,\n host: hostInfo,\n hostInfo,\n hostContext,\n capabilities: {\n tools: handlers.callTool ? {} : undefined,\n resources:\n handlers.readResource || handlers.listResources\n ? {}\n : undefined,\n ui: {\n sendMessage: !!handlers.sendMessage,\n openLink: !!handlers.openLink,\n requestDisplayMode: !!handlers.requestDisplayMode,\n updateModelContext: !!handlers.updateModelContext,\n },\n },\n hostCapabilities: {\n ...(handlers.openLink ? { openLinks: {} } : {}),\n ...(handlers.callTool ? { serverTools: {} } : {}),\n ...(handlers.readResource || handlers.listResources\n ? { serverResources: {} }\n : {}),\n ...(handlers.updateModelContext\n ? { updateModelContext: { text: {} } }\n : {}),\n ...(handlers.sendMessage ? { message: { text: {} } } : {}),\n ...(handlers.onLog ? { logging: {} } : {}),\n },\n },\n });\n return;\n }\n\n case \"tools/call\": {\n if (!handlers.callTool) {\n errorResponse(\n req.id,\n JSONRPC_ERROR.methodNotFound,\n \"tools/call is not supported by this host\",\n );\n return;\n }\n const callParams = (params ?? {}) as {\n name?: unknown;\n arguments?: unknown;\n };\n if (typeof callParams.name !== \"string\") {\n errorResponse(\n req.id,\n JSONRPC_ERROR.invalidParams,\n \"tools/call requires a string 'name'\",\n );\n return;\n }\n if (\n handlers.allowedTools &&\n !handlers.allowedTools.includes(callParams.name)\n ) {\n errorResponse(\n req.id,\n JSONRPC_ERROR.invalidParams,\n `tool '${callParams.name}' is not allowed for this app`,\n );\n return;\n }\n let callArgs: Record<string, unknown> | undefined;\n if (callParams.arguments !== undefined) {\n if (\n callParams.arguments === null ||\n typeof callParams.arguments !== \"object\" ||\n Array.isArray(callParams.arguments)\n ) {\n errorResponse(\n req.id,\n JSONRPC_ERROR.invalidParams,\n \"tools/call 'arguments' must be an object\",\n );\n return;\n }\n callArgs = callParams.arguments as Record<string, unknown>;\n }\n const result = await handlers.callTool({\n name: callParams.name,\n ...(callArgs !== undefined ? { arguments: callArgs } : {}),\n });\n respond(req.id, { result });\n return;\n }\n\n case \"resources/read\": {\n if (!handlers.readResource) {\n errorResponse(\n req.id,\n JSONRPC_ERROR.methodNotFound,\n \"resources/read is not supported by this host\",\n );\n return;\n }\n const readParams = (params ?? {}) as { uri?: unknown };\n if (typeof readParams.uri !== \"string\") {\n errorResponse(\n req.id,\n JSONRPC_ERROR.invalidParams,\n \"resources/read requires a string 'uri'\",\n );\n return;\n }\n respond(req.id, {\n result: await handlers.readResource({ uri: readParams.uri }),\n });\n return;\n }\n\n case \"resources/list\": {\n if (!handlers.listResources) {\n errorResponse(\n req.id,\n JSONRPC_ERROR.methodNotFound,\n \"resources/list is not supported by this host\",\n );\n return;\n }\n respond(req.id, {\n result: (await handlers.listResources(params)) ?? null,\n });\n return;\n }\n\n case \"openLink\": {\n if (!handlers.openLink) {\n errorResponse(\n req.id,\n JSONRPC_ERROR.methodNotFound,\n \"openLink is not supported by this host\",\n );\n return;\n }\n const linkParams = (params ?? {}) as { url?: unknown };\n if (typeof linkParams.url !== \"string\") {\n errorResponse(\n req.id,\n JSONRPC_ERROR.invalidParams,\n \"openLink requires a string 'url'\",\n );\n return;\n }\n let linkProtocol: string;\n try {\n linkProtocol = new URL(linkParams.url).protocol;\n } catch {\n errorResponse(\n req.id,\n JSONRPC_ERROR.invalidParams,\n \"openLink requires a valid URL\",\n );\n return;\n }\n if (linkProtocol !== \"https:\" && linkProtocol !== \"http:\") {\n errorResponse(\n req.id,\n JSONRPC_ERROR.invalidParams,\n \"openLink only accepts http(s) URLs\",\n );\n return;\n }\n respond(req.id, {\n result: await handlers.openLink({ url: linkParams.url }),\n });\n return;\n }\n\n case \"sendMessage\": {\n if (!handlers.sendMessage) {\n errorResponse(\n req.id,\n JSONRPC_ERROR.methodNotFound,\n \"sendMessage is not supported by this host\",\n );\n return;\n }\n respond(req.id, {\n result: (await handlers.sendMessage(params)) ?? null,\n });\n return;\n }\n\n case \"updateModelContext\": {\n if (!handlers.updateModelContext) {\n errorResponse(\n req.id,\n JSONRPC_ERROR.methodNotFound,\n \"updateModelContext is not supported by this host\",\n );\n return;\n }\n respond(req.id, {\n result: (await handlers.updateModelContext(params)) ?? null,\n });\n return;\n }\n\n case \"requestDisplayMode\": {\n if (!handlers.requestDisplayMode) {\n errorResponse(\n req.id,\n JSONRPC_ERROR.methodNotFound,\n \"requestDisplayMode is not supported by this host\",\n );\n return;\n }\n const modeParams = (params ?? {}) as { mode?: unknown };\n if (\n typeof modeParams.mode !== \"string\" ||\n !VALID_DISPLAY_MODES.includes(modeParams.mode as McpAppDisplayMode)\n ) {\n errorResponse(\n req.id,\n JSONRPC_ERROR.invalidParams,\n \"requestDisplayMode requires a valid 'mode'\",\n );\n return;\n }\n respond(req.id, {\n result: await handlers.requestDisplayMode({\n mode: modeParams.mode as McpAppDisplayMode,\n }),\n });\n return;\n }\n\n default: {\n errorResponse(\n req.id,\n JSONRPC_ERROR.methodNotFound,\n `Unknown method: ${req.method}`,\n );\n }\n }\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n reportError(error);\n errorResponse(req.id, JSONRPC_ERROR.internalError, error.message);\n }\n };\n\n const handleNotification = (note: McpAppJsonRpcNotification) => {\n try {\n switch (normalizeMethod(note.method)) {\n case \"notifications/initialized\": {\n handlers.onInitialized?.();\n return;\n }\n case \"notifications/size_changed\": {\n const p = (note.params ?? {}) as { width?: number; height?: number };\n handlers.onSizeChange?.({\n ...(typeof p.width === \"number\" ? { width: p.width } : {}),\n ...(typeof p.height === \"number\" ? { height: p.height } : {}),\n });\n return;\n }\n case \"notifications/log\": {\n handlers.onLog?.(note.params);\n return;\n }\n case \"notifications/request_teardown\": {\n handlers.onRequestTeardown?.(note.params);\n return;\n }\n case \"notifications/error\": {\n const p = (note.params ?? {}) as { message?: string };\n reportError(\n new Error(\n typeof p.message === \"string\" ? p.message : \"Widget error\",\n ),\n );\n return;\n }\n default:\n return;\n }\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n reportError(error);\n }\n };\n\n // The host applies the cross-origin guard before delegating; this only\n // validates the JSON-RPC envelope.\n const onMessage = (event: MessageEvent) => {\n if (disposed) return;\n if (!isJsonRpcMessage(event.data)) return;\n\n const msg = event.data;\n if (isRequest(msg)) {\n void handleRequest(msg);\n } else if (isNotification(msg)) {\n handleNotification(msg);\n }\n };\n\n return {\n onMessage,\n dispose: () => {\n disposed = true;\n },\n notifyToolInput: (input: unknown) => {\n post({\n jsonrpc: \"2.0\",\n method: \"notifications/tools/call/input\",\n params: { input },\n });\n post({\n jsonrpc: \"2.0\",\n method: \"ui/notifications/tool-input\",\n params: isRecord(input) ? { arguments: input } : {},\n });\n },\n notifyToolResult: (result: unknown) => {\n post({\n jsonrpc: \"2.0\",\n method: \"notifications/tools/call/result\",\n params: { result },\n });\n post({\n jsonrpc: \"2.0\",\n method: \"ui/notifications/tool-result\",\n params: isRecord(result)\n ? result\n : { content: [{ type: \"text\", text: String(result) }] },\n });\n },\n notifyHostContextChanged: (ctx: McpAppHostContext) => {\n post({\n jsonrpc: \"2.0\",\n method: \"notifications/host_context/changed\",\n params: ctx,\n });\n post({\n jsonrpc: \"2.0\",\n method: \"ui/notifications/host-context-changed\",\n params: ctx,\n });\n },\n };\n}\n"],"mappings":";;;AAeA,MAAMY,sBAAsB;CAC1B;CACA;CACA;AAAK;AAoBP,MAAMkB,oBAAoC;CACxCC,MAAM;CACNC,SAAS;AACX;AAKA,MAAMC,iBAAyC;CAC7C,gCAAgC;CAChC,iCAAiC;CACjC,2BAA2B;CAC3B,gBAAgB;CAChB,2BAA2B;CAC3B,cAAc;CACd,yBAAyB;AAC3B;AAEA,MAAME,mBAAmBC,WACvBH,eAAeG,WAAWA;AAE5B,MAAMC,gBAAgB;CACpBC,YAAY;CACZC,gBAAgB;CAChBC,gBAAgB;CAChBC,eAAe;CACfC,eAAe;AACjB;AAEA,SAASC,iBAAiBC,OAA+C;CACvE,IAAI,CAACA,SAAS,OAAOA,UAAU,UAAU,OAAO;CAChD,MAAMC,IAAID;CACV,OAAOC,EAAEC,YAAY,SAAS,OAAOD,EAAET,WAAW;AACpD;AAEA,SAASW,UAAUC,KAAwD;CACzE,OAAO,QAAQA;AACjB;AAEA,SAASC,eACPD,KACkC;CAClC,OAAO,EAAE,QAAQA;AACnB;AAEA,SAAgBE,mBACdC,MACc;CACd,MAAM,EACJnC,OACAC,WAAW,CAAC,GACZC,WAAWY,mBACXX,cAAc,CAAC,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M,IACnBA,SACA,EAAE0F,SAAS,CAAC;KAAEC,MAAM;KAAQ9B,MAAMoB,OAAOjF,MAAM;IAAE,CAAC,EAAE;GAC1D,CAAC;EACH;EACAC,2BAA2B2F,QAA2B;GACpDnE,KAAK;IACHP,SAAS;IACTV,QAAQ;IACRmC,QAAQiD;GACV,CAAC;GACDnE,KAAK;IACHP,SAAS;IACTV,QAAQ;IACRmC,QAAQiD;GACV,CAAC;EACH;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantModalRoot.d.ts","names":[],"sources":["../../../src/primitives/assistantModal/AssistantModalRoot.tsx"],"mappings":";;;kBAOiB;OACH,QAAQ,QAAiB;IACnC;;;
|
|
1
|
+
{"version":3,"file":"AssistantModalRoot.d.ts","names":[],"sources":["../../../src/primitives/assistantModal/AssistantModalRoot.tsx"],"mappings":";;;kBAOiB;OACH,QAAQ,QAAiB;IACnC;;;cAIS,6BAA6B,GACxC,4BAA4B"}
|