@copilotkit/react-core 2.0.0-rc.8 → 2.0.0-rc.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{MarkdownRendererContext-DAuVISwv.d.cts → MarkdownRendererContext-CS35epe1.d.mts} +5 -5
- package/dist/{MarkdownRendererContext-DAuVISwv.d.cts.map → MarkdownRendererContext-CS35epe1.d.mts.map} +1 -1
- package/dist/{MarkdownRendererContext-XWC2OXD5.d.mts → MarkdownRendererContext-CfTh92vk.d.cts} +5 -5
- package/dist/{MarkdownRendererContext-XWC2OXD5.d.mts.map → MarkdownRendererContext-CfTh92vk.d.cts.map} +1 -1
- package/dist/{MarkdownSurfaces-DQZM4lSI.cjs → MarkdownSurfaces-Ije2ZQh0.cjs} +16 -17
- package/dist/MarkdownSurfaces-Ije2ZQh0.cjs.map +1 -0
- package/dist/{MarkdownSurfaces-BXaxgpm_.mjs → MarkdownSurfaces-iFKorV2w.mjs} +5 -7
- package/dist/MarkdownSurfaces-iFKorV2w.mjs.map +1 -0
- package/dist/generative-ui.cjs +507 -506
- package/dist/generative-ui.cjs.map +1 -1
- package/dist/generative-ui.d.cts +2137 -4178
- package/dist/generative-ui.d.cts.map +1 -1
- package/dist/generative-ui.d.mts +2137 -4178
- package/dist/generative-ui.d.mts.map +1 -1
- package/dist/generative-ui.mjs +3 -3
- package/dist/generative-ui.mjs.map +1 -1
- package/dist/index.cjs +102 -335
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -51
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +13 -51
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +31 -307
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +118 -351
- package/dist/index.umd.js.map +1 -1
- package/package.json +14 -14
- package/dist/MarkdownSurfaces-BXaxgpm_.mjs.map +0 -1
- package/dist/MarkdownSurfaces-DQZM4lSI.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_MarkdownSurfaces = require('./MarkdownSurfaces-
|
|
4
|
+
const require_MarkdownSurfaces = require('./MarkdownSurfaces-Ije2ZQh0.cjs');
|
|
5
5
|
let _copilotkit_core = require("@copilotkit/core");
|
|
6
6
|
let _ag_ui_client = require("@ag-ui/client");
|
|
7
7
|
let react = require("react");
|
|
@@ -16,8 +16,8 @@ _radix_ui_react_dropdown_menu = require_MarkdownSurfaces.__toESM(_radix_ui_react
|
|
|
16
16
|
let _ag_ui_core = require("@ag-ui/core");
|
|
17
17
|
let _copilotkit_mcp_apps_renderer_activity = require("@copilotkit/mcp-apps-renderer/activity");
|
|
18
18
|
let zod = require("zod");
|
|
19
|
+
zod = require_MarkdownSurfaces.__toESM(zod);
|
|
19
20
|
let _copilotkit_a2ui_renderer = require("@copilotkit/a2ui-renderer");
|
|
20
|
-
let zod_to_json_schema = require("zod-to-json-schema");
|
|
21
21
|
let _a2ui_web_core_v0_9 = require("@a2ui/web_core/v0_9");
|
|
22
22
|
let _copilotkit_core_styles = require("@copilotkit/core/styles");
|
|
23
23
|
let _radix_ui_react_popover = require("@radix-ui/react-popover");
|
|
@@ -1242,7 +1242,7 @@ function useRenderToolCall() {
|
|
|
1242
1242
|
|
|
1243
1243
|
//#endregion
|
|
1244
1244
|
//#region package.json
|
|
1245
|
-
var version$1 = "2.0.0-rc.
|
|
1245
|
+
var version$1 = "2.0.0-rc.9";
|
|
1246
1246
|
|
|
1247
1247
|
//#endregion
|
|
1248
1248
|
//#region src/components/CopilotKitInspector.tsx
|
|
@@ -1632,324 +1632,63 @@ function useSandboxFunctions() {
|
|
|
1632
1632
|
return (0, react.useContext)(SandboxFunctionsContext);
|
|
1633
1633
|
}
|
|
1634
1634
|
|
|
1635
|
-
//#endregion
|
|
1636
|
-
//#region src/lib/processPartialHtml.ts
|
|
1637
|
-
/**
|
|
1638
|
-
* Extracts all complete `<style>` blocks from the raw HTML.
|
|
1639
|
-
* Returns the concatenated style tags, suitable for injection into `<head>`.
|
|
1640
|
-
*/
|
|
1641
|
-
function extractCompleteStyles(html) {
|
|
1642
|
-
const matches = html.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi);
|
|
1643
|
-
return matches ? matches.join("") : "";
|
|
1644
|
-
}
|
|
1645
|
-
/**
|
|
1646
|
-
* Processes raw accumulated HTML for safe preview via innerHTML injection.
|
|
1647
|
-
* Pure function, no DOM dependencies.
|
|
1648
|
-
*
|
|
1649
|
-
* Pipeline (order matters):
|
|
1650
|
-
* 1. Strip incomplete tag at end
|
|
1651
|
-
* 2. Strip complete <style>, <script>, and <head> blocks
|
|
1652
|
-
* 3. Strip incomplete <style>/<script>/<head> blocks
|
|
1653
|
-
* 4. Strip incomplete HTML entities
|
|
1654
|
-
* 5. Extract body content (or use full string if no <body>)
|
|
1655
|
-
*/
|
|
1656
|
-
function processPartialHtml(html) {
|
|
1657
|
-
let result = html;
|
|
1658
|
-
result = result.replace(/<[^>]*$/, "");
|
|
1659
|
-
result = result.replace(/<(style|script|head)\b[^>]*>[\s\S]*?<\/\1>/gi, "");
|
|
1660
|
-
result = result.replace(/<(style|script|head)\b[^>]*>[\s\S]*$/gi, "");
|
|
1661
|
-
result = result.replace(/&[a-zA-Z0-9#]*$/, "");
|
|
1662
|
-
const bodyMatch = result.match(/<body[^>]*>([\s\S]*)/i);
|
|
1663
|
-
if (bodyMatch) {
|
|
1664
|
-
result = bodyMatch[1];
|
|
1665
|
-
result = result.replace(/<\/body>[\s\S]*/i, "");
|
|
1666
|
-
}
|
|
1667
|
-
return result;
|
|
1668
|
-
}
|
|
1669
|
-
|
|
1670
1635
|
//#endregion
|
|
1671
1636
|
//#region src/components/OpenGenerativeUIRenderer.tsx
|
|
1672
|
-
const OpenGenerativeUIActivityType =
|
|
1673
|
-
const OpenGenerativeUIContentSchema = zod.
|
|
1674
|
-
initialHeight: zod.
|
|
1675
|
-
generating: zod.
|
|
1676
|
-
css: zod.
|
|
1677
|
-
cssComplete: zod.
|
|
1678
|
-
html: zod.
|
|
1679
|
-
htmlComplete: zod.
|
|
1680
|
-
jsFunctions: zod.
|
|
1681
|
-
jsFunctionsComplete: zod.
|
|
1682
|
-
jsExpressions: zod.
|
|
1683
|
-
jsExpressionsComplete: zod.
|
|
1637
|
+
const OpenGenerativeUIActivityType = _copilotkit_core.OPEN_GENERATIVE_UI_ACTIVITY_TYPE;
|
|
1638
|
+
const OpenGenerativeUIContentSchema = zod.object({
|
|
1639
|
+
initialHeight: zod.number().optional(),
|
|
1640
|
+
generating: zod.boolean().optional(),
|
|
1641
|
+
css: zod.string().optional(),
|
|
1642
|
+
cssComplete: zod.boolean().optional(),
|
|
1643
|
+
html: zod.array(zod.string()).optional(),
|
|
1644
|
+
htmlComplete: zod.boolean().optional(),
|
|
1645
|
+
jsFunctions: zod.string().optional(),
|
|
1646
|
+
jsFunctionsComplete: zod.boolean().optional(),
|
|
1647
|
+
jsExpressions: zod.array(zod.string()).optional(),
|
|
1648
|
+
jsExpressionsComplete: zod.boolean().optional()
|
|
1684
1649
|
});
|
|
1685
1650
|
/**
|
|
1686
1651
|
* Schema for the generateSandboxedUi tool call arguments.
|
|
1687
1652
|
* Used by the frontend tool renderer to display placeholder messages.
|
|
1688
1653
|
*/
|
|
1689
|
-
const GenerateSandboxedUiArgsSchema = zod.
|
|
1690
|
-
initialHeight: zod.
|
|
1691
|
-
placeholderMessages: zod.
|
|
1692
|
-
css: zod.
|
|
1693
|
-
html: zod.
|
|
1694
|
-
jsFunctions: zod.
|
|
1695
|
-
jsExpressions: zod.
|
|
1696
|
-
});
|
|
1697
|
-
const THROTTLE_MS = 1e3;
|
|
1698
|
-
/**
|
|
1699
|
-
* Returns true when the inner component should re-render immediately
|
|
1700
|
-
* (no throttle delay).
|
|
1701
|
-
*/
|
|
1702
|
-
function shouldFlushImmediately(prev, next) {
|
|
1703
|
-
if (next.cssComplete && (!prev || !prev.cssComplete)) return true;
|
|
1704
|
-
if (next.htmlComplete) return true;
|
|
1705
|
-
if (next.generating === false) return true;
|
|
1706
|
-
if (next.jsFunctions && (!prev || !prev.jsFunctions)) return true;
|
|
1707
|
-
if ((next.jsExpressions?.length ?? 0) > (prev?.jsExpressions?.length ?? 0)) return true;
|
|
1708
|
-
if (next.html?.length && (!prev || !prev.html?.length)) return true;
|
|
1709
|
-
return false;
|
|
1710
|
-
}
|
|
1654
|
+
const GenerateSandboxedUiArgsSchema = zod.object({
|
|
1655
|
+
initialHeight: zod.number().optional(),
|
|
1656
|
+
placeholderMessages: zod.array(zod.string()).optional(),
|
|
1657
|
+
css: zod.string().optional(),
|
|
1658
|
+
html: zod.string().optional(),
|
|
1659
|
+
jsFunctions: zod.string().optional(),
|
|
1660
|
+
jsExpressions: zod.array(zod.string()).optional()
|
|
1661
|
+
});
|
|
1711
1662
|
/**
|
|
1712
|
-
*
|
|
1713
|
-
*
|
|
1663
|
+
* Renders an Open Generative UI activity. The core controller throttles the
|
|
1664
|
+
* content and runs the websandbox iframes inside the container div.
|
|
1714
1665
|
*/
|
|
1715
1666
|
const OpenGenerativeUIActivityRenderer = function OpenGenerativeUIActivityRenderer({ content }) {
|
|
1716
|
-
const
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
if (throttledContentRef.current !== content) {
|
|
1722
|
-
if (shouldFlushImmediately(throttledContentRef.current, content)) {
|
|
1723
|
-
if (timerRef.current !== null) {
|
|
1724
|
-
clearTimeout(timerRef.current);
|
|
1725
|
-
timerRef.current = null;
|
|
1726
|
-
}
|
|
1727
|
-
throttledContentRef.current = content;
|
|
1728
|
-
setThrottledContent(content);
|
|
1729
|
-
}
|
|
1730
|
-
}
|
|
1731
|
-
const flush = (0, react.useCallback)(() => {
|
|
1732
|
-
timerRef.current = null;
|
|
1733
|
-
const latest = latestContentRef.current;
|
|
1734
|
-
throttledContentRef.current = latest;
|
|
1735
|
-
setThrottledContent(latest);
|
|
1736
|
-
}, []);
|
|
1737
|
-
(0, react.useEffect)(() => {
|
|
1738
|
-
if (throttledContentRef.current === content) return;
|
|
1739
|
-
if (timerRef.current === null) timerRef.current = setTimeout(flush, THROTTLE_MS);
|
|
1740
|
-
}, [content, flush]);
|
|
1741
|
-
(0, react.useEffect)(() => {
|
|
1742
|
-
return () => {
|
|
1743
|
-
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
1744
|
-
};
|
|
1745
|
-
}, []);
|
|
1746
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenGenerativeUIActivityRendererInner, { content: throttledContent });
|
|
1747
|
-
};
|
|
1748
|
-
function ensureHead(html) {
|
|
1749
|
-
if (/<head[\s>]/i.test(html)) return html;
|
|
1750
|
-
return `<head></head>${html}`;
|
|
1751
|
-
}
|
|
1752
|
-
function injectCssIntoHtml(html, css) {
|
|
1753
|
-
const headCloseIdx = html.indexOf("</head>");
|
|
1754
|
-
if (headCloseIdx !== -1) return html.slice(0, headCloseIdx) + `<style>${css}</style>` + html.slice(headCloseIdx);
|
|
1755
|
-
return `<head><style>${css}</style></head>${html}`;
|
|
1756
|
-
}
|
|
1757
|
-
const OpenGenerativeUIActivityRendererInner = react.default.memo(function OpenGenerativeUIActivityRendererInner({ content }) {
|
|
1758
|
-
const initialHeight = content.initialHeight ?? 200;
|
|
1759
|
-
const [autoHeight, setAutoHeight] = (0, react.useState)(null);
|
|
1667
|
+
const [controller] = (0, react.useState)(() => {
|
|
1668
|
+
const created = new _copilotkit_core.ɵOpenGenerativeUIController();
|
|
1669
|
+
created.setContent(content);
|
|
1670
|
+
return created;
|
|
1671
|
+
});
|
|
1760
1672
|
const sandboxFunctions = useSandboxFunctions();
|
|
1761
|
-
const localApi = (0, react.useMemo)(() => {
|
|
1762
|
-
const api = {};
|
|
1763
|
-
for (const fn of sandboxFunctions) api[fn.name] = fn.handler;
|
|
1764
|
-
return api;
|
|
1765
|
-
}, [sandboxFunctions]);
|
|
1766
|
-
const fullHtml = content.htmlComplete && content.html?.length ? content.html.join("") : void 0;
|
|
1767
|
-
const css = content.cssComplete ? content.css : void 0;
|
|
1768
|
-
const cssReady = !!content.cssComplete;
|
|
1769
|
-
const partialHtml = !content.htmlComplete && content.html?.length ? content.html.join("") : void 0;
|
|
1770
|
-
const previewBody = partialHtml ? processPartialHtml(partialHtml) : void 0;
|
|
1771
|
-
const previewStyles = partialHtml ? extractCompleteStyles(partialHtml) : "";
|
|
1772
|
-
const hasPreview = cssReady && !!previewBody?.trim();
|
|
1773
|
-
const hasVisibleSandbox = !!fullHtml || hasPreview;
|
|
1774
1673
|
const containerRef = (0, react.useRef)(null);
|
|
1775
|
-
const
|
|
1776
|
-
const previewSandboxRef = (0, react.useRef)(null);
|
|
1777
|
-
const previewReadyRef = (0, react.useRef)(false);
|
|
1778
|
-
const sandboxReadyRef = (0, react.useRef)(false);
|
|
1779
|
-
const executedIndexRef = (0, react.useRef)(0);
|
|
1780
|
-
const pendingQueueRef = (0, react.useRef)([]);
|
|
1781
|
-
const jsFunctionsInjectedRef = (0, react.useRef)(false);
|
|
1782
|
-
(0, react.useEffect)(() => {
|
|
1783
|
-
const container = containerRef.current;
|
|
1784
|
-
if (!container || fullHtml || !hasPreview || previewSandboxRef.current) return;
|
|
1785
|
-
let cancelled = false;
|
|
1786
|
-
import("@jetbrains/websandbox").then((mod) => {
|
|
1787
|
-
if (cancelled) return;
|
|
1788
|
-
const sandbox = (mod.default?.default ?? mod.default).create({}, {
|
|
1789
|
-
frameContainer: container,
|
|
1790
|
-
frameContent: "<head></head><body></body>",
|
|
1791
|
-
allowAdditionalAttributes: ""
|
|
1792
|
-
});
|
|
1793
|
-
previewSandboxRef.current = sandbox;
|
|
1794
|
-
sandbox.iframe.style.width = "100%";
|
|
1795
|
-
sandbox.iframe.style.height = "100%";
|
|
1796
|
-
sandbox.iframe.style.border = "none";
|
|
1797
|
-
sandbox.iframe.style.backgroundColor = "transparent";
|
|
1798
|
-
sandbox.promise.then(() => {
|
|
1799
|
-
if (cancelled) return;
|
|
1800
|
-
previewReadyRef.current = true;
|
|
1801
|
-
sandbox.run(`
|
|
1802
|
-
var s = document.createElement('style');
|
|
1803
|
-
s.textContent = 'html, body { overflow: hidden !important; }';
|
|
1804
|
-
document.head.appendChild(s);
|
|
1805
|
-
`);
|
|
1806
|
-
const headParts = [];
|
|
1807
|
-
if (css) headParts.push(`<style>${css}</style>`);
|
|
1808
|
-
if (previewStyles) headParts.push(previewStyles);
|
|
1809
|
-
if (headParts.length) sandbox.run(`document.head.innerHTML = ${JSON.stringify(headParts.join(""))}`);
|
|
1810
|
-
if (previewBody) sandbox.run(`document.body.innerHTML = ${JSON.stringify(previewBody)}`);
|
|
1811
|
-
});
|
|
1812
|
-
}).catch((err) => {
|
|
1813
|
-
console.error("[OpenGenerativeUI] Failed to load sandbox module:", err);
|
|
1814
|
-
});
|
|
1815
|
-
return () => {
|
|
1816
|
-
cancelled = true;
|
|
1817
|
-
};
|
|
1818
|
-
}, [hasPreview, fullHtml]);
|
|
1819
|
-
(0, react.useEffect)(() => {
|
|
1820
|
-
if (!previewSandboxRef.current || !previewReadyRef.current) return;
|
|
1821
|
-
const headParts = [];
|
|
1822
|
-
if (css) headParts.push(`<style>${css}</style>`);
|
|
1823
|
-
if (previewStyles) headParts.push(previewStyles);
|
|
1824
|
-
if (headParts.length) previewSandboxRef.current.run(`document.head.innerHTML = ${JSON.stringify(headParts.join(""))}`);
|
|
1825
|
-
if (!previewBody) return;
|
|
1826
|
-
previewSandboxRef.current.run(`document.body.innerHTML = ${JSON.stringify(previewBody)}`);
|
|
1827
|
-
}, [
|
|
1828
|
-
previewBody,
|
|
1829
|
-
previewStyles,
|
|
1830
|
-
css
|
|
1831
|
-
]);
|
|
1832
|
-
(0, react.useEffect)(() => {
|
|
1833
|
-
const container = containerRef.current;
|
|
1834
|
-
if (!container || !fullHtml) return;
|
|
1835
|
-
if (previewSandboxRef.current) {
|
|
1836
|
-
previewSandboxRef.current.destroy();
|
|
1837
|
-
previewSandboxRef.current = null;
|
|
1838
|
-
previewReadyRef.current = false;
|
|
1839
|
-
}
|
|
1840
|
-
let cancelled = false;
|
|
1841
|
-
executedIndexRef.current = 0;
|
|
1842
|
-
jsFunctionsInjectedRef.current = false;
|
|
1843
|
-
sandboxReadyRef.current = false;
|
|
1844
|
-
pendingQueueRef.current = [];
|
|
1845
|
-
const htmlContent = css ? injectCssIntoHtml(fullHtml, css) : fullHtml;
|
|
1846
|
-
import("@jetbrains/websandbox").then((mod) => {
|
|
1847
|
-
if (cancelled) return;
|
|
1848
|
-
const sandbox = (mod.default?.default ?? mod.default).create(localApi, {
|
|
1849
|
-
frameContainer: container,
|
|
1850
|
-
frameContent: ensureHead(htmlContent),
|
|
1851
|
-
allowAdditionalAttributes: ""
|
|
1852
|
-
});
|
|
1853
|
-
sandboxRef.current = sandbox;
|
|
1854
|
-
sandbox.iframe.style.width = "100%";
|
|
1855
|
-
sandbox.iframe.style.height = "100%";
|
|
1856
|
-
sandbox.iframe.style.border = "none";
|
|
1857
|
-
sandbox.iframe.style.backgroundColor = "transparent";
|
|
1858
|
-
sandbox.promise.then(() => {
|
|
1859
|
-
if (cancelled) return;
|
|
1860
|
-
sandboxReadyRef.current = true;
|
|
1861
|
-
sandbox.run(`
|
|
1862
|
-
var s = document.createElement('style');
|
|
1863
|
-
s.textContent = 'html, body { overflow: hidden !important; }';
|
|
1864
|
-
document.head.appendChild(s);
|
|
1865
|
-
`);
|
|
1866
|
-
const queue = pendingQueueRef.current;
|
|
1867
|
-
pendingQueueRef.current = [];
|
|
1868
|
-
for (const code of queue) sandbox.run(code);
|
|
1869
|
-
});
|
|
1870
|
-
}).catch((err) => {
|
|
1871
|
-
console.error("[OpenGenerativeUI] Failed to load sandbox module:", err);
|
|
1872
|
-
});
|
|
1873
|
-
return () => {
|
|
1874
|
-
cancelled = true;
|
|
1875
|
-
if (previewSandboxRef.current) {
|
|
1876
|
-
previewSandboxRef.current.destroy();
|
|
1877
|
-
previewSandboxRef.current = null;
|
|
1878
|
-
previewReadyRef.current = false;
|
|
1879
|
-
}
|
|
1880
|
-
if (sandboxRef.current) {
|
|
1881
|
-
sandboxRef.current.destroy();
|
|
1882
|
-
sandboxRef.current = null;
|
|
1883
|
-
}
|
|
1884
|
-
sandboxReadyRef.current = false;
|
|
1885
|
-
setAutoHeight(null);
|
|
1886
|
-
};
|
|
1887
|
-
}, [
|
|
1888
|
-
fullHtml,
|
|
1889
|
-
css,
|
|
1890
|
-
localApi
|
|
1891
|
-
]);
|
|
1674
|
+
const state = (0, react.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
|
|
1892
1675
|
(0, react.useEffect)(() => {
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
const sandbox = sandboxRef.current;
|
|
1896
|
-
if (sandboxReadyRef.current && sandbox) sandbox.run(content.jsFunctions);
|
|
1897
|
-
else pendingQueueRef.current.push(content.jsFunctions);
|
|
1898
|
-
}, [content.jsFunctions]);
|
|
1676
|
+
controller.setSandboxFunctions(sandboxFunctions);
|
|
1677
|
+
}, [controller, sandboxFunctions]);
|
|
1899
1678
|
(0, react.useEffect)(() => {
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
const startIndex = executedIndexRef.current;
|
|
1903
|
-
if (startIndex >= expressions.length) return;
|
|
1904
|
-
const newExprs = expressions.slice(startIndex);
|
|
1905
|
-
executedIndexRef.current = expressions.length;
|
|
1906
|
-
const sandbox = sandboxRef.current;
|
|
1907
|
-
if (sandboxReadyRef.current && sandbox) (async () => {
|
|
1908
|
-
for (const expr of newExprs) await sandbox.run(expr);
|
|
1909
|
-
})();
|
|
1910
|
-
else pendingQueueRef.current.push(...newExprs);
|
|
1911
|
-
}, [content.jsExpressions?.length]);
|
|
1912
|
-
const generationDone = content.generating === false;
|
|
1679
|
+
controller.setContent(content);
|
|
1680
|
+
}, [controller, content]);
|
|
1913
1681
|
(0, react.useEffect)(() => {
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
if (handled) return;
|
|
1919
|
-
if (e.source === sandbox.iframe.contentWindow && e.data?.type === "__ck_resize") {
|
|
1920
|
-
handled = true;
|
|
1921
|
-
setAutoHeight(e.data.height);
|
|
1922
|
-
window.removeEventListener("message", onMessage);
|
|
1923
|
-
}
|
|
1924
|
-
};
|
|
1925
|
-
window.addEventListener("message", onMessage);
|
|
1926
|
-
const measureOnce = `
|
|
1927
|
-
(function() {
|
|
1928
|
-
var s = document.createElement('style');
|
|
1929
|
-
s.textContent = 'body { height: auto !important; min-height: 0 !important; }';
|
|
1930
|
-
document.head.appendChild(s);
|
|
1931
|
-
var h = document.body.scrollHeight;
|
|
1932
|
-
var cs = getComputedStyle(document.body);
|
|
1933
|
-
h += parseFloat(cs.marginTop) || 0;
|
|
1934
|
-
h += parseFloat(cs.marginBottom) || 0;
|
|
1935
|
-
s.remove();
|
|
1936
|
-
parent.postMessage({ type: "__ck_resize", height: Math.ceil(h) }, "*");
|
|
1937
|
-
})();
|
|
1938
|
-
`;
|
|
1939
|
-
if (sandboxReadyRef.current) sandbox.run(measureOnce);
|
|
1940
|
-
else pendingQueueRef.current.push(measureOnce);
|
|
1941
|
-
return () => {
|
|
1942
|
-
window.removeEventListener("message", onMessage);
|
|
1943
|
-
};
|
|
1944
|
-
}, [generationDone]);
|
|
1945
|
-
const height = autoHeight ?? initialHeight;
|
|
1946
|
-
const isGenerating = content.generating !== false;
|
|
1682
|
+
controller.setHost(containerRef.current);
|
|
1683
|
+
return () => controller.destroy();
|
|
1684
|
+
}, [controller]);
|
|
1685
|
+
const hasVisibleSandbox = state.phase !== "placeholder";
|
|
1947
1686
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1948
1687
|
ref: containerRef,
|
|
1949
1688
|
style: {
|
|
1950
1689
|
position: "relative",
|
|
1951
1690
|
width: "100%",
|
|
1952
|
-
height: `${height}px`,
|
|
1691
|
+
height: `${state.height}px`,
|
|
1953
1692
|
borderRadius: "8px",
|
|
1954
1693
|
backgroundColor: hasVisibleSandbox ? "transparent" : "#f5f5f5",
|
|
1955
1694
|
border: hasVisibleSandbox ? "none" : "1px solid #e0e0e0",
|
|
@@ -1958,7 +1697,7 @@ const OpenGenerativeUIActivityRendererInner = react.default.memo(function OpenGe
|
|
|
1958
1697
|
justifyContent: hasVisibleSandbox ? void 0 : "center",
|
|
1959
1698
|
overflow: "hidden"
|
|
1960
1699
|
},
|
|
1961
|
-
children:
|
|
1700
|
+
children: state.generating && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1962
1701
|
style: {
|
|
1963
1702
|
position: "absolute",
|
|
1964
1703
|
inset: 0,
|
|
@@ -1990,7 +1729,7 @@ const OpenGenerativeUIActivityRendererInner = react.default.memo(function OpenGe
|
|
|
1990
1729
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: `@keyframes ck-spin { to { transform: rotate(360deg) } }` })]
|
|
1991
1730
|
})
|
|
1992
1731
|
});
|
|
1993
|
-
}
|
|
1732
|
+
};
|
|
1994
1733
|
/**
|
|
1995
1734
|
* Frontend tool renderer for generateSandboxedUi.
|
|
1996
1735
|
* Displays placeholder messages while the UI is being generated.
|
|
@@ -2027,22 +1766,22 @@ const OpenGenerativeUIToolRenderer = function OpenGenerativeUIToolRenderer(props
|
|
|
2027
1766
|
//#region src/a2ui/A2UIRecoveryStates.tsx
|
|
2028
1767
|
/**
|
|
2029
1768
|
* The pre-paint lifecycle fields the middleware stamps onto the `a2ui-surface`
|
|
2030
|
-
* activity content (alongside `a2ui_operations` on paint). `.
|
|
1769
|
+
* activity content (alongside `a2ui_operations` on paint). `.loose()` keeps
|
|
2031
1770
|
* `a2ui_operations` and any future fields intact.
|
|
2032
1771
|
*/
|
|
2033
1772
|
const A2UILifecycleFields = {
|
|
2034
|
-
status: zod.
|
|
1773
|
+
status: zod.enum([
|
|
2035
1774
|
"building",
|
|
2036
1775
|
"retrying",
|
|
2037
1776
|
"failed"
|
|
2038
1777
|
]).optional(),
|
|
2039
|
-
attempt: zod.
|
|
2040
|
-
maxAttempts: zod.
|
|
2041
|
-
progressTokens: zod.
|
|
2042
|
-
error: zod.
|
|
2043
|
-
errors: zod.
|
|
2044
|
-
attempts: zod.
|
|
2045
|
-
debugExposure: zod.
|
|
1778
|
+
attempt: zod.number().optional(),
|
|
1779
|
+
maxAttempts: zod.number().optional(),
|
|
1780
|
+
progressTokens: zod.number().optional(),
|
|
1781
|
+
error: zod.string().optional(),
|
|
1782
|
+
errors: zod.array(zod.any()).optional(),
|
|
1783
|
+
attempts: zod.array(zod.any()).optional(),
|
|
1784
|
+
debugExposure: zod.enum([
|
|
2046
1785
|
"hidden",
|
|
2047
1786
|
"collapsed",
|
|
2048
1787
|
"verbose"
|
|
@@ -2433,12 +2172,12 @@ function ensureInitialized() {
|
|
|
2433
2172
|
* stable messageId (OSS-162): pre-paint `status` ("building" | "retrying" |
|
|
2434
2173
|
* "failed") with recovery detail, then `a2ui_operations` on paint. The states
|
|
2435
2174
|
* swap in place, so the painted surface replaces the skeleton with no extra
|
|
2436
|
-
* coordination. `.
|
|
2175
|
+
* coordination. `.loose()` preserves operations + any future fields.
|
|
2437
2176
|
*/
|
|
2438
|
-
const A2UISurfaceContentSchema = zod.
|
|
2439
|
-
a2ui_operations: zod.
|
|
2177
|
+
const A2UISurfaceContentSchema = zod.object({
|
|
2178
|
+
a2ui_operations: zod.array(zod.any()).optional(),
|
|
2440
2179
|
...A2UILifecycleFields
|
|
2441
|
-
}).
|
|
2180
|
+
}).loose();
|
|
2442
2181
|
const IS_DEVELOPMENT = process.env.NODE_ENV !== "production";
|
|
2443
2182
|
/**
|
|
2444
2183
|
* How long to wait for a surface to report its first paint before giving up on
|
|
@@ -2809,7 +2548,7 @@ function A2UIBuiltInToolCallRenderer() {
|
|
|
2809
2548
|
(0, react.useEffect)(() => {
|
|
2810
2549
|
const renderer = require_MarkdownSurfaces.defineToolCallRenderer({
|
|
2811
2550
|
name: RENDER_A2UI_TOOL_NAME,
|
|
2812
|
-
args: zod.
|
|
2551
|
+
args: zod.any(),
|
|
2813
2552
|
render: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, {})
|
|
2814
2553
|
});
|
|
2815
2554
|
const existing = copilotkit._renderToolCalls ?? [];
|
|
@@ -3700,7 +3439,7 @@ var GenerativeUISurfaceManager = class {
|
|
|
3700
3439
|
this.getState = () => this.state;
|
|
3701
3440
|
this.webCoreCatalog = new _a2ui_web_core_v0_9.Catalog(ui.id, [...ui.components.keys()].map((name) => ({
|
|
3702
3441
|
name,
|
|
3703
|
-
schema: zod.
|
|
3442
|
+
schema: zod.any()
|
|
3704
3443
|
})), []);
|
|
3705
3444
|
}
|
|
3706
3445
|
notify() {
|
|
@@ -4827,10 +4566,6 @@ function CopilotKitStyles() {
|
|
|
4827
4566
|
|
|
4828
4567
|
//#endregion
|
|
4829
4568
|
//#region src/providers/CopilotKitProvider.tsx
|
|
4830
|
-
const zodToJsonSchemaAdapter = (schema, options) => {
|
|
4831
|
-
const refStrategy = options?.$refStrategy;
|
|
4832
|
-
return (0, zod_to_json_schema.zodToJsonSchema)(schema, refStrategy === "root" || refStrategy === "relative" || refStrategy === "none" || refStrategy === "seen" ? { $refStrategy: refStrategy } : {});
|
|
4833
|
-
};
|
|
4834
4569
|
const HEADER_NAME = "X-CopilotCloud-Public-Api-Key";
|
|
4835
4570
|
const COPILOT_CLOUD_CHAT_URL = "https://api.cloud.copilotkit.ai/copilotkit/v1";
|
|
4836
4571
|
const EMPTY_HEADERS = Object.freeze({});
|
|
@@ -4839,16 +4574,6 @@ const EMPTY_AGENTS = Object.freeze({});
|
|
|
4839
4574
|
/** Registration name of a catch-all tool: handles any otherwise-unhandled call. */
|
|
4840
4575
|
const WILDCARD_TOOL_NAME$1 = "*";
|
|
4841
4576
|
const HUMAN_IN_THE_LOOP_ABORTED_MESSAGE = "Human-in-the-loop interaction aborted";
|
|
4842
|
-
const DEFAULT_DESIGN_SKILL = `When generating UI with generateSandboxedUi, follow these design principles inspired by shadcn/ui:
|
|
4843
|
-
|
|
4844
|
-
- Use a minimal, flat aesthetic. Avoid drop shadows and gradients — rely on subtle borders (1px solid, light gray like #e5e7eb) to define surfaces.
|
|
4845
|
-
- Neutral base palette: white backgrounds, zinc/slate gray text (#09090b for headings, #71717a for secondary text). One accent color for interactive elements.
|
|
4846
|
-
- Use system font stacks (system-ui, -apple-system, sans-serif) at readable sizes (14px body, 600 weight for headings). Tight line-heights.
|
|
4847
|
-
- Small, consistent border-radius (6–8px). Cards and containers use border, not shadow, for separation.
|
|
4848
|
-
- Buttons: solid fill for primary (dark bg, white text), outline for secondary (border + transparent bg). Subtle hover state (slight opacity or background shift).
|
|
4849
|
-
- Use CSS Grid or Flexbox for layout. Ensure the UI looks good at any width.
|
|
4850
|
-
- Minimal transitions (150ms) for hover/focus states only. No decorative animations.
|
|
4851
|
-
- Keep the UI focused and dense — avoid excessive padding. Use compact spacing (8–12px gaps, 10–14px padding in controls).`;
|
|
4852
4577
|
/** The MCP Apps renderer with `mcpApps.allowSameOriginFallback` applied. */
|
|
4853
4578
|
const SameOriginMCPAppsActivityRenderer = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MCPAppsActivityRenderer, {
|
|
4854
4579
|
...props,
|
|
@@ -5059,7 +4784,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
5059
4784
|
const builtInFrontendTools = (0, react.useMemo)(() => {
|
|
5060
4785
|
if (!openGenUIActive) return [];
|
|
5061
4786
|
return [{
|
|
5062
|
-
name:
|
|
4787
|
+
name: _copilotkit_core.GENERATE_SANDBOXED_UI_TOOL_NAME,
|
|
5063
4788
|
description: _copilotkit_shared.GENERATE_SANDBOXED_UI_DESCRIPTION,
|
|
5064
4789
|
parameters: GenerateSandboxedUiArgsSchema,
|
|
5065
4790
|
handler: async () => "UI generated",
|
|
@@ -5284,7 +5009,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
5284
5009
|
(0, react.useEffect)(() => {
|
|
5285
5010
|
copilotkit.setDefaultThrottleMs(defaultThrottleMs);
|
|
5286
5011
|
}, [copilotkit, defaultThrottleMs]);
|
|
5287
|
-
const designSkill = openGenerativeUI?.designSkill ??
|
|
5012
|
+
const designSkill = openGenerativeUI?.designSkill ?? _copilotkit_core.DEFAULT_OPEN_GENERATIVE_UI_DESIGN_SKILL;
|
|
5288
5013
|
(0, react.useLayoutEffect)(() => {
|
|
5289
5014
|
if (!copilotkit || !openGenUIActive) return;
|
|
5290
5015
|
const id = copilotkit.addContext({
|
|
@@ -5304,7 +5029,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
5304
5029
|
return JSON.stringify(sandboxFunctionsList.map((fn) => ({
|
|
5305
5030
|
name: fn.name,
|
|
5306
5031
|
description: fn.description,
|
|
5307
|
-
parameters: (0, _copilotkit_shared.schemaToJsonSchema)(fn.parameters
|
|
5032
|
+
parameters: (0, _copilotkit_shared.schemaToJsonSchema)(fn.parameters)
|
|
5308
5033
|
})));
|
|
5309
5034
|
}, [sandboxFunctionsList]);
|
|
5310
5035
|
(0, react.useLayoutEffect)(() => {
|
|
@@ -13669,6 +13394,12 @@ Object.defineProperty(exports, 'CustomEventSchema', {
|
|
|
13669
13394
|
return _ag_ui_core_schemas.CustomEventSchema;
|
|
13670
13395
|
}
|
|
13671
13396
|
});
|
|
13397
|
+
Object.defineProperty(exports, 'DEFAULT_OPEN_GENERATIVE_UI_DESIGN_SKILL', {
|
|
13398
|
+
enumerable: true,
|
|
13399
|
+
get: function () {
|
|
13400
|
+
return _copilotkit_core.DEFAULT_OPEN_GENERATIVE_UI_DESIGN_SKILL;
|
|
13401
|
+
}
|
|
13402
|
+
});
|
|
13672
13403
|
Object.defineProperty(exports, 'DataSourceSchema', {
|
|
13673
13404
|
enumerable: true,
|
|
13674
13405
|
get: function () {
|
|
@@ -13759,6 +13490,12 @@ Object.defineProperty(exports, 'FunctionMiddleware', {
|
|
|
13759
13490
|
return _ag_ui_client.FunctionMiddleware;
|
|
13760
13491
|
}
|
|
13761
13492
|
});
|
|
13493
|
+
Object.defineProperty(exports, 'GENERATE_SANDBOXED_UI_TOOL_NAME', {
|
|
13494
|
+
enumerable: true,
|
|
13495
|
+
get: function () {
|
|
13496
|
+
return _copilotkit_core.GENERATE_SANDBOXED_UI_TOOL_NAME;
|
|
13497
|
+
}
|
|
13498
|
+
});
|
|
13762
13499
|
exports.GenerateSandboxedUiArgsSchema = GenerateSandboxedUiArgsSchema;
|
|
13763
13500
|
Object.defineProperty(exports, 'HttpAgent', {
|
|
13764
13501
|
enumerable: true,
|
|
@@ -13945,6 +13682,12 @@ Object.defineProperty(exports, 'MultimodalOutputCapabilitiesSchema', {
|
|
|
13945
13682
|
return _ag_ui_core_schemas.MultimodalOutputCapabilitiesSchema;
|
|
13946
13683
|
}
|
|
13947
13684
|
});
|
|
13685
|
+
Object.defineProperty(exports, 'OPEN_GENERATIVE_UI_ACTIVITY_TYPE', {
|
|
13686
|
+
enumerable: true,
|
|
13687
|
+
get: function () {
|
|
13688
|
+
return _copilotkit_core.OPEN_GENERATIVE_UI_ACTIVITY_TYPE;
|
|
13689
|
+
}
|
|
13690
|
+
});
|
|
13948
13691
|
exports.OpenGenerativeUIActivityRenderer = OpenGenerativeUIActivityRenderer;
|
|
13949
13692
|
exports.OpenGenerativeUIActivityType = OpenGenerativeUIActivityType;
|
|
13950
13693
|
exports.OpenGenerativeUIContentSchema = OpenGenerativeUIContentSchema;
|
|
@@ -14845,6 +14588,12 @@ Object.defineProperty(exports, 'ɵMAX_SOCKET_RETRIES', {
|
|
|
14845
14588
|
return _copilotkit_core.ɵMAX_SOCKET_RETRIES;
|
|
14846
14589
|
}
|
|
14847
14590
|
});
|
|
14591
|
+
Object.defineProperty(exports, 'ɵOpenGenerativeUIController', {
|
|
14592
|
+
enumerable: true,
|
|
14593
|
+
get: function () {
|
|
14594
|
+
return _copilotkit_core.ɵOpenGenerativeUIController;
|
|
14595
|
+
}
|
|
14596
|
+
});
|
|
14848
14597
|
Object.defineProperty(exports, 'ɵRUNTIME_PROBE_TIMEOUT_MS', {
|
|
14849
14598
|
enumerable: true,
|
|
14850
14599
|
get: function () {
|
|
@@ -14911,6 +14660,12 @@ Object.defineProperty(exports, 'ɵdeduplicateMessages', {
|
|
|
14911
14660
|
return _copilotkit_core.ɵdeduplicateMessages;
|
|
14912
14661
|
}
|
|
14913
14662
|
});
|
|
14663
|
+
Object.defineProperty(exports, 'ɵextractCompleteStyles', {
|
|
14664
|
+
enumerable: true,
|
|
14665
|
+
get: function () {
|
|
14666
|
+
return _copilotkit_core.ɵextractCompleteStyles;
|
|
14667
|
+
}
|
|
14668
|
+
});
|
|
14914
14669
|
Object.defineProperty(exports, 'ɵformatCountLabel', {
|
|
14915
14670
|
enumerable: true,
|
|
14916
14671
|
get: function () {
|
|
@@ -15037,6 +14792,12 @@ Object.defineProperty(exports, 'ɵjoinPhoenixChannel$', {
|
|
|
15037
14792
|
return _copilotkit_core.ɵjoinPhoenixChannel$;
|
|
15038
14793
|
}
|
|
15039
14794
|
});
|
|
14795
|
+
Object.defineProperty(exports, 'ɵloadWebsandbox', {
|
|
14796
|
+
enumerable: true,
|
|
14797
|
+
get: function () {
|
|
14798
|
+
return _copilotkit_core.ɵloadWebsandbox;
|
|
14799
|
+
}
|
|
14800
|
+
});
|
|
15040
14801
|
Object.defineProperty(exports, 'ɵmapMemoryMetadataEvent', {
|
|
15041
14802
|
enumerable: true,
|
|
15042
14803
|
get: function () {
|
|
@@ -15115,6 +14876,12 @@ Object.defineProperty(exports, 'ɵpluralize', {
|
|
|
15115
14876
|
return _copilotkit_core.ɵpluralize;
|
|
15116
14877
|
}
|
|
15117
14878
|
});
|
|
14879
|
+
Object.defineProperty(exports, 'ɵprocessPartialHtml', {
|
|
14880
|
+
enumerable: true,
|
|
14881
|
+
get: function () {
|
|
14882
|
+
return _copilotkit_core.ɵprocessPartialHtml;
|
|
14883
|
+
}
|
|
14884
|
+
});
|
|
15118
14885
|
Object.defineProperty(exports, 'ɵrecordWorkTime', {
|
|
15119
14886
|
enumerable: true,
|
|
15120
14887
|
get: function () {
|