@copilotkit/react-core 1.85.0 → 1.86.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/MarkdownSurfaces-BCVdnDAk.cjs +161 -0
- package/dist/MarkdownSurfaces-BCVdnDAk.cjs.map +1 -0
- package/dist/MarkdownSurfaces-CjJduaJR.mjs +149 -0
- package/dist/MarkdownSurfaces-CjJduaJR.mjs.map +1 -0
- package/dist/{MarkdownSurfaces-3cGU5_0H.cjs → chat-BnsrQ0VS.cjs} +667 -320
- package/dist/chat-BnsrQ0VS.cjs.map +1 -0
- package/dist/{MarkdownSurfaces-D-W4f9Dy.mjs → chat-IWySXWXP.mjs} +647 -312
- package/dist/chat-IWySXWXP.mjs.map +1 -0
- package/dist/{copilotkit-D6mTCuNU.mjs → copilotkit-B1OLgEU8.mjs} +6 -354
- package/dist/copilotkit-B1OLgEU8.mjs.map +1 -0
- package/dist/{copilotkit-Dn4PbHJV.d.mts → copilotkit-C7G95NO-.d.mts} +4 -4
- package/dist/{copilotkit-Dn4PbHJV.d.mts.map → copilotkit-C7G95NO-.d.mts.map} +1 -1
- package/dist/{copilotkit-BpKHgURs.cjs → copilotkit-Ca0IcTZU.cjs} +79 -427
- package/dist/copilotkit-Ca0IcTZU.cjs.map +1 -0
- package/dist/{copilotkit-CuTAoQF2.d.cts → copilotkit-DwD7D6jJ.d.cts} +2 -2
- package/dist/{copilotkit-CuTAoQF2.d.cts.map → copilotkit-DwD7D6jJ.d.cts.map} +1 -1
- package/dist/hooks-DMSkcNOl.d.cts +89 -0
- package/dist/hooks-DMSkcNOl.d.cts.map +1 -0
- package/dist/hooks-EwGvqYsW.d.mts +89 -0
- package/dist/hooks-EwGvqYsW.d.mts.map +1 -0
- package/dist/index.cjs +8 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/index.umd.js +645 -140
- package/dist/index.umd.js.map +1 -1
- package/dist/refs-DL7ITFFD.cjs +43 -0
- package/dist/refs-DL7ITFFD.cjs.map +1 -0
- package/dist/refs-DiZXJ63p.mjs +31 -0
- package/dist/refs-DiZXJ63p.mjs.map +1 -0
- package/dist/{runtime-context-Er5UIbZA.d.mts → runtime-context-B4fKyzo6.d.mts} +31 -9
- package/dist/runtime-context-B4fKyzo6.d.mts.map +1 -0
- package/dist/{runtime-context-DrVNUYLi.d.cts → runtime-context-Da7T5vy4.d.cts} +31 -9
- package/dist/runtime-context-Da7T5vy4.d.cts.map +1 -0
- package/dist/use-generative-ui-root-CaTyBFNR.cjs +390 -0
- package/dist/use-generative-ui-root-CaTyBFNR.cjs.map +1 -0
- package/dist/use-generative-ui-root-WI9ERMpo.mjs +385 -0
- package/dist/use-generative-ui-root-WI9ERMpo.mjs.map +1 -0
- package/dist/v2/generative-ui/native.cjs +66 -0
- package/dist/v2/generative-ui/native.cjs.map +1 -0
- package/dist/v2/generative-ui/native.d.cts +155 -0
- package/dist/v2/generative-ui/native.d.cts.map +1 -0
- package/dist/v2/generative-ui/native.d.mts +155 -0
- package/dist/v2/generative-ui/native.d.mts.map +1 -0
- package/dist/v2/generative-ui/native.mjs +24 -0
- package/dist/v2/generative-ui/native.mjs.map +1 -0
- package/dist/v2/generative-ui.cjs +45 -70
- package/dist/v2/generative-ui.cjs.map +1 -1
- package/dist/v2/generative-ui.d.cts +229 -308
- package/dist/v2/generative-ui.d.cts.map +1 -1
- package/dist/v2/generative-ui.d.mts +229 -308
- package/dist/v2/generative-ui.d.mts.map +1 -1
- package/dist/v2/generative-ui.mjs +4 -29
- package/dist/v2/generative-ui.mjs.map +1 -1
- package/dist/v2/headless.d.cts +185 -294
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/index.cjs +5 -5
- package/dist/v2/index.d.cts +2 -2
- package/dist/v2/index.d.mts +2 -2
- package/dist/v2/index.mjs +2 -2
- package/dist/v2/index.umd.js +645 -140
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +14 -10
- package/dist/MarkdownSurfaces-3cGU5_0H.cjs.map +0 -1
- package/dist/MarkdownSurfaces-D-W4f9Dy.mjs.map +0 -1
- package/dist/copilotkit-BpKHgURs.cjs.map +0 -1
- package/dist/copilotkit-D6mTCuNU.mjs.map +0 -1
- package/dist/runtime-context-DrVNUYLi.d.cts.map +0 -1
- package/dist/runtime-context-Er5UIbZA.d.mts.map +0 -1
package/dist/index.umd.js
CHANGED
|
@@ -625,7 +625,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
625
625
|
|
|
626
626
|
//#endregion
|
|
627
627
|
//#region package.json
|
|
628
|
-
var version = "1.
|
|
628
|
+
var version = "1.86.0";
|
|
629
629
|
|
|
630
630
|
//#endregion
|
|
631
631
|
//#region src/v2/components/CopilotKitInspector.tsx
|
|
@@ -2259,6 +2259,81 @@ react_markdown = __toESM(react_markdown);
|
|
|
2259
2259
|
return null;
|
|
2260
2260
|
}
|
|
2261
2261
|
|
|
2262
|
+
//#endregion
|
|
2263
|
+
//#region src/v2/generative-ui/runtime-context.ts
|
|
2264
|
+
const GenerativeUIRuntimeContext = (0, react.createContext)(null);
|
|
2265
|
+
function useGenerativeUIRuntime() {
|
|
2266
|
+
return (0, react.useContext)(GenerativeUIRuntimeContext);
|
|
2267
|
+
}
|
|
2268
|
+
function useRequiredGenerativeUIRuntime() {
|
|
2269
|
+
const runtime = (0, react.useContext)(GenerativeUIRuntimeContext);
|
|
2270
|
+
if (!runtime) throw new Error("Generative UI components must be rendered inside a generative UI provider: <CopilotKitProvider generativeUI={{ ui }}> on the web, or <GenerativeUIProvider> from @copilotkit/react-native/generative-ui on React Native.");
|
|
2271
|
+
return runtime;
|
|
2272
|
+
}
|
|
2273
|
+
const GenerativeUINodeContext = (0, react.createContext)(null);
|
|
2274
|
+
|
|
2275
|
+
//#endregion
|
|
2276
|
+
//#region src/v2/generative-ui/hooks.ts
|
|
2277
|
+
const noopSubscribe$1 = () => () => {};
|
|
2278
|
+
const zero = () => 0;
|
|
2279
|
+
/** Re-renders on any surface-manager change. */
|
|
2280
|
+
function useManagerVersion(runtime) {
|
|
2281
|
+
return (0, react.useSyncExternalStore)(runtime?.manager.subscribe ?? noopSubscribe$1, runtime?.manager.getVersion ?? zero, zero);
|
|
2282
|
+
}
|
|
2283
|
+
|
|
2284
|
+
//#endregion
|
|
2285
|
+
//#region src/v2/generative-ui/activity.ts
|
|
2286
|
+
/**
|
|
2287
|
+
* The rejected operations of a surface (the runtime's first, then the
|
|
2288
|
+
* client's) and the error that goes with them, for a wrapper: a generic
|
|
2289
|
+
* message, with the same list as its `cause`. The `cause` is not enumerable,
|
|
2290
|
+
* so `JSON.stringify`, a spread and error reporters leave the list out.
|
|
2291
|
+
* `clientRejected` is appended to in place by the manager, so its length is
|
|
2292
|
+
* part of the key.
|
|
2293
|
+
*/
|
|
2294
|
+
function useGenerativeUIRejected(serverRejected, clientRejected) {
|
|
2295
|
+
const rejected = (0, react.useMemo)(() => [...serverRejected ?? [], ...clientRejected ?? []], [
|
|
2296
|
+
serverRejected,
|
|
2297
|
+
clientRejected,
|
|
2298
|
+
clientRejected?.length ?? 0
|
|
2299
|
+
]);
|
|
2300
|
+
return {
|
|
2301
|
+
rejected,
|
|
2302
|
+
error: (0, react.useMemo)(() => rejected.length ? (0, _copilotkit_shared_generative_ui.withCause)(/* @__PURE__ */ new Error(`${rejected.length} UI update(s) could not be shown`), rejected) : void 0, [rejected])
|
|
2303
|
+
};
|
|
2304
|
+
}
|
|
2305
|
+
/**
|
|
2306
|
+
* What a renderer of one surface activity message shows: the surface (or the
|
|
2307
|
+
* failed surface whose `createSurface` was rejected), and its rejected
|
|
2308
|
+
* operations with their error (see {@link useGenerativeUIRejected}). It
|
|
2309
|
+
* ingests `content` into the manager (idempotent: the root ingests the
|
|
2310
|
+
* agent's messages too, and this covers an agent the root has not seen yet),
|
|
2311
|
+
* and renders again on every change of the manager.
|
|
2312
|
+
*
|
|
2313
|
+
* `surface` is undefined when there is no runtime, thread or content, when
|
|
2314
|
+
* the surface's target is not `target`, or when the surface does not exist
|
|
2315
|
+
* (the agent deleted it). Both rejected lists cover only the latest
|
|
2316
|
+
* `render_ui` call (see the manager's ingest).
|
|
2317
|
+
*/
|
|
2318
|
+
function useGenerativeUIActivitySurface({ runtime, threadId, agentId, content, target }) {
|
|
2319
|
+
useManagerVersion(runtime);
|
|
2320
|
+
(0, react.useLayoutEffect)(() => {
|
|
2321
|
+
if (runtime && threadId && content) runtime.manager.ingest(threadId, agentId, content);
|
|
2322
|
+
}, [
|
|
2323
|
+
runtime,
|
|
2324
|
+
threadId,
|
|
2325
|
+
agentId,
|
|
2326
|
+
content
|
|
2327
|
+
]);
|
|
2328
|
+
const surface = runtime && threadId && content && content.target === target ? runtime.manager.getSurface(threadId, content.surfaceId) ?? runtime.manager.getFailedSurface(threadId, content.surfaceId) : void 0;
|
|
2329
|
+
const { rejected, error } = useGenerativeUIRejected(content?.rejected, surface?.clientRejected);
|
|
2330
|
+
return {
|
|
2331
|
+
surface,
|
|
2332
|
+
rejected,
|
|
2333
|
+
error
|
|
2334
|
+
};
|
|
2335
|
+
}
|
|
2336
|
+
|
|
2262
2337
|
//#endregion
|
|
2263
2338
|
//#region src/v2/generative-ui/markdown/context.ts
|
|
2264
2339
|
/**
|
|
@@ -2340,9 +2415,38 @@ react_markdown = __toESM(react_markdown);
|
|
|
2340
2415
|
//#endregion
|
|
2341
2416
|
//#region src/v2/generative-ui/use-generative-ui-root.ts
|
|
2342
2417
|
const isDevelopment = () => process.env.NODE_ENV !== "production";
|
|
2418
|
+
/**
|
|
2419
|
+
* The malformed-content warnings already printed, by manager, so each
|
|
2420
|
+
* distinct issue warns once while the manager lives.
|
|
2421
|
+
*/
|
|
2422
|
+
const warnedMalformed = /* @__PURE__ */ new WeakMap();
|
|
2423
|
+
/**
|
|
2424
|
+
* Ingests the surface activity messages of `messages`. A message whose
|
|
2425
|
+
* content is malformed (for example `null`) is skipped, in development with a
|
|
2426
|
+
* warning once for each distinct issue, so it cannot throw inside the
|
|
2427
|
+
* agent's run; the messages after it are still ingested.
|
|
2428
|
+
*/
|
|
2343
2429
|
function ingestMessages(manager, agent, messages) {
|
|
2344
|
-
|
|
2345
|
-
|
|
2430
|
+
const { threadId } = agent;
|
|
2431
|
+
if (!threadId) return;
|
|
2432
|
+
for (const message of messages) {
|
|
2433
|
+
if (message.role !== "activity" || message.activityType !== _copilotkit_shared.GENERATIVE_UI_ACTIVITY_TYPE) continue;
|
|
2434
|
+
const parsed = (0, _copilotkit_core_generative_ui.parseGenerativeUISurfaceContent)(message.content);
|
|
2435
|
+
if (parsed.content) {
|
|
2436
|
+
manager.ingest(threadId, agent.agentId, parsed.content);
|
|
2437
|
+
continue;
|
|
2438
|
+
}
|
|
2439
|
+
if (!isDevelopment()) continue;
|
|
2440
|
+
const warning = `[generativeUI] skipped an activity message of thread ${JSON.stringify(threadId)}: its content is malformed: ${parsed.issues.join("; ")}.`;
|
|
2441
|
+
let warned = warnedMalformed.get(manager);
|
|
2442
|
+
if (!warned) {
|
|
2443
|
+
warned = /* @__PURE__ */ new Set();
|
|
2444
|
+
warnedMalformed.set(manager, warned);
|
|
2445
|
+
}
|
|
2446
|
+
if (warned.has(warning)) continue;
|
|
2447
|
+
warned.add(warning);
|
|
2448
|
+
console.warn(warning);
|
|
2449
|
+
}
|
|
2346
2450
|
}
|
|
2347
2451
|
/** Provider-side wiring: manager, dispatcher, agent subscriptions, envelope. */
|
|
2348
2452
|
function useGenerativeUIRoot(copilotkit, config) {
|
|
@@ -2608,29 +2712,35 @@ react_markdown = __toESM(react_markdown);
|
|
|
2608
2712
|
}
|
|
2609
2713
|
|
|
2610
2714
|
//#endregion
|
|
2611
|
-
//#region src/v2/generative-ui/
|
|
2612
|
-
const
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2715
|
+
//#region src/v2/generative-ui/host.tsx
|
|
2716
|
+
const DISPLAY_CONTENTS = { display: "contents" };
|
|
2717
|
+
/**
|
|
2718
|
+
* The root element is always there, so a theme change does not remount the
|
|
2719
|
+
* surface. `display: contents` keeps it out of the layout, and the CSS
|
|
2720
|
+
* variables still reach every component of the surface. The `a2ui-surface`
|
|
2721
|
+
* class scopes the standard catalog's surface CSS rules. The theme is a
|
|
2722
|
+
* stylesheet, not an inline style, so that its `dark` values can apply in
|
|
2723
|
+
* dark mode only. The values are checked in `themeStyleSheet`, and the HTML
|
|
2724
|
+
* is set as is, so the server render keeps the quotes of the rule.
|
|
2725
|
+
*/
|
|
2726
|
+
function DomSurfaceRoot({ surfaceId, theme, children }) {
|
|
2727
|
+
const sheet = react.default.useMemo(() => (0, _copilotkit_shared_generative_ui.themeStyleSheet)(theme), [theme]);
|
|
2728
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2729
|
+
className: "a2ui-surface",
|
|
2730
|
+
"data-generative-ui-root": surfaceId,
|
|
2731
|
+
"data-a2ui-theme": sheet?.id,
|
|
2732
|
+
style: DISPLAY_CONTENTS,
|
|
2733
|
+
children: [sheet ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { dangerouslySetInnerHTML: { __html: sheet.css } }) : null, children]
|
|
2734
|
+
});
|
|
2620
2735
|
}
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
function useManagerVersion(runtime) {
|
|
2629
|
-
return (0, react.useSyncExternalStore)(runtime?.manager.subscribe ?? noopSubscribe$1, runtime?.manager.getVersion ?? zero, zero);
|
|
2736
|
+
function DomAccessibilityWrapper({ attributes, children }) {
|
|
2737
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2738
|
+
"data-a2ui-accessibility": "",
|
|
2739
|
+
style: DISPLAY_CONTENTS,
|
|
2740
|
+
...attributes,
|
|
2741
|
+
children
|
|
2742
|
+
});
|
|
2630
2743
|
}
|
|
2631
|
-
|
|
2632
|
-
//#endregion
|
|
2633
|
-
//#region src/v2/generative-ui/boundaries.tsx
|
|
2634
2744
|
function DefaultNodeFallback({ message, componentId, retry }) {
|
|
2635
2745
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2636
2746
|
role: "alert",
|
|
@@ -2658,7 +2768,24 @@ react_markdown = __toESM(react_markdown);
|
|
|
2658
2768
|
]
|
|
2659
2769
|
});
|
|
2660
2770
|
}
|
|
2771
|
+
/** The DOM host: what a surface draws on the web. */
|
|
2772
|
+
const domGenerativeUIHost = {
|
|
2773
|
+
SurfaceRoot: DomSurfaceRoot,
|
|
2774
|
+
AccessibilityWrapper: DomAccessibilityWrapper,
|
|
2775
|
+
NodeFallback: DefaultNodeFallback
|
|
2776
|
+
};
|
|
2661
2777
|
/**
|
|
2778
|
+
* The host elements of the surfaces below. Defaults to the DOM host, so a
|
|
2779
|
+
* web app never sets it.
|
|
2780
|
+
*/
|
|
2781
|
+
const GenerativeUIHostContext = (0, react.createContext)(domGenerativeUIHost);
|
|
2782
|
+
function useGenerativeUIHost() {
|
|
2783
|
+
return (0, react.useContext)(GenerativeUIHostContext);
|
|
2784
|
+
}
|
|
2785
|
+
|
|
2786
|
+
//#endregion
|
|
2787
|
+
//#region src/v2/generative-ui/boundaries.tsx
|
|
2788
|
+
/**
|
|
2662
2789
|
* A child that has not streamed yet renders nothing. The prose keeps
|
|
2663
2790
|
* streaming above the surface, and each component appears as soon as it is
|
|
2664
2791
|
* complete. A grey block in its place would read as a broken layout.
|
|
@@ -2666,18 +2793,188 @@ react_markdown = __toESM(react_markdown);
|
|
|
2666
2793
|
function NodePlaceholder(_props) {
|
|
2667
2794
|
return null;
|
|
2668
2795
|
}
|
|
2669
|
-
/**
|
|
2670
|
-
|
|
2796
|
+
/**
|
|
2797
|
+
* The error that a fallback threw, told apart from the error of the
|
|
2798
|
+
* component it stood in for. The fallback's own error is the `cause`.
|
|
2799
|
+
*/
|
|
2800
|
+
function fallbackError(error, componentId) {
|
|
2801
|
+
const subject = componentId === void 0 ? "the surface" : componentId;
|
|
2802
|
+
return (0, _copilotkit_shared_generative_ui.withCause)(/* @__PURE__ */ new Error(`The error fallback of ${subject} threw: ${error.message}`), error);
|
|
2803
|
+
}
|
|
2804
|
+
function createFailureLog() {
|
|
2805
|
+
const last = /* @__PURE__ */ new Map();
|
|
2806
|
+
const released = /* @__PURE__ */ new Set();
|
|
2807
|
+
const releasedSinceSettle = /* @__PURE__ */ new Set();
|
|
2808
|
+
const heldBack = /* @__PURE__ */ new Map();
|
|
2809
|
+
return {
|
|
2810
|
+
report(runtime, slot, info, context = "") {
|
|
2811
|
+
released.delete(slot);
|
|
2812
|
+
const signature = [
|
|
2813
|
+
info.kind,
|
|
2814
|
+
info.error.name,
|
|
2815
|
+
info.error.message,
|
|
2816
|
+
context
|
|
2817
|
+
].join("\n");
|
|
2818
|
+
if (last.get(slot) === signature) {
|
|
2819
|
+
if (releasedSinceSettle.has(slot)) heldBack.set(slot, {
|
|
2820
|
+
runtime,
|
|
2821
|
+
info,
|
|
2822
|
+
signature
|
|
2823
|
+
});
|
|
2824
|
+
return;
|
|
2825
|
+
}
|
|
2826
|
+
heldBack.delete(slot);
|
|
2827
|
+
last.set(slot, signature);
|
|
2828
|
+
(0, _copilotkit_core_generative_ui.reportErrorSafely)(runtime, info);
|
|
2829
|
+
},
|
|
2830
|
+
clear(slot) {
|
|
2831
|
+
released.delete(slot);
|
|
2832
|
+
last.delete(slot);
|
|
2833
|
+
heldBack.delete(slot);
|
|
2834
|
+
},
|
|
2835
|
+
retain(slot) {
|
|
2836
|
+
released.delete(slot);
|
|
2837
|
+
},
|
|
2838
|
+
release(slot) {
|
|
2839
|
+
heldBack.delete(slot);
|
|
2840
|
+
if (!last.has(slot)) return;
|
|
2841
|
+
released.add(slot);
|
|
2842
|
+
releasedSinceSettle.add(slot);
|
|
2843
|
+
},
|
|
2844
|
+
settle(missed = false) {
|
|
2845
|
+
for (const slot of missed ? releasedSinceSettle : released) last.delete(slot);
|
|
2846
|
+
if (missed) for (const [slot, { runtime, info, signature }] of heldBack) {
|
|
2847
|
+
if (!releasedSinceSettle.has(slot) || last.has(slot)) continue;
|
|
2848
|
+
last.set(slot, signature);
|
|
2849
|
+
(0, _copilotkit_core_generative_ui.reportErrorSafely)(runtime, info);
|
|
2850
|
+
}
|
|
2851
|
+
heldBack.clear();
|
|
2852
|
+
released.clear();
|
|
2853
|
+
releasedSinceSettle.clear();
|
|
2854
|
+
}
|
|
2855
|
+
};
|
|
2856
|
+
}
|
|
2857
|
+
/** Outside a surface, every failure is reported. */
|
|
2858
|
+
const UNLOGGED = {
|
|
2859
|
+
report: (runtime, _slot, info) => (0, _copilotkit_core_generative_ui.reportErrorSafely)(runtime, info),
|
|
2860
|
+
clear: () => {},
|
|
2861
|
+
retain: () => {},
|
|
2862
|
+
release: () => {},
|
|
2863
|
+
settle: () => {}
|
|
2864
|
+
};
|
|
2865
|
+
/** The failure log of the surface being rendered; set by `SurfaceView`. */
|
|
2866
|
+
const GenerativeUIFailureLogContext = (0, react.createContext)(UNLOGGED);
|
|
2867
|
+
function useFailureLog() {
|
|
2868
|
+
return (0, react.useContext)(GenerativeUIFailureLogContext);
|
|
2869
|
+
}
|
|
2870
|
+
/**
|
|
2871
|
+
* The slots of a failure log, per node place (one rendered copy of a node,
|
|
2872
|
+
* see `placeOf` in SurfaceView) and surface boundary.
|
|
2873
|
+
*/
|
|
2874
|
+
const failureSlots = {
|
|
2875
|
+
node: (place) => `node ${place}`,
|
|
2876
|
+
appFallback: (place) => `app-fallback ${place}`,
|
|
2877
|
+
renderFallback: (place) => `render-fallback ${place}`,
|
|
2878
|
+
fallback: (place) => `fallback ${place}`,
|
|
2879
|
+
cycle: (place) => `cycle ${place}`,
|
|
2880
|
+
props: (place) => `props ${place}`,
|
|
2881
|
+
surface: (level) => `surface ${level}`,
|
|
2882
|
+
surfaceFallback: (level) => `surface-fallback ${level}`
|
|
2883
|
+
};
|
|
2884
|
+
function sameKeys(a, b) {
|
|
2885
|
+
return a.length === b.length && a.every((value, i) => Object.is(value, b[i]));
|
|
2886
|
+
}
|
|
2887
|
+
var FallbackGuard = class extends react.Component {
|
|
2671
2888
|
constructor(..._args) {
|
|
2672
2889
|
super(..._args);
|
|
2890
|
+
this.state = {
|
|
2891
|
+
failed: false,
|
|
2892
|
+
resetKeys: this.props.resetKeys
|
|
2893
|
+
};
|
|
2894
|
+
}
|
|
2895
|
+
static getDerivedStateFromError(thrown) {
|
|
2896
|
+
return {
|
|
2897
|
+
failed: true,
|
|
2898
|
+
error: (0, _copilotkit_shared_generative_ui.toError)(thrown)
|
|
2899
|
+
};
|
|
2900
|
+
}
|
|
2901
|
+
static getDerivedStateFromProps(props, state) {
|
|
2902
|
+
return sameKeys(props.resetKeys, state.resetKeys) ? null : {
|
|
2903
|
+
failed: false,
|
|
2904
|
+
error: void 0,
|
|
2905
|
+
resetKeys: props.resetKeys
|
|
2906
|
+
};
|
|
2907
|
+
}
|
|
2908
|
+
report(error) {
|
|
2909
|
+
const { runtime, surfaceId, componentId, log, slot, context } = this.props;
|
|
2910
|
+
log.report(runtime, slot, {
|
|
2911
|
+
kind: "render",
|
|
2912
|
+
surfaceId,
|
|
2913
|
+
...componentId === void 0 ? {} : { componentId },
|
|
2914
|
+
error: fallbackError(error, componentId)
|
|
2915
|
+
}, context);
|
|
2916
|
+
}
|
|
2917
|
+
componentDidCatch(thrown) {
|
|
2918
|
+
this.report(this.state.error ?? (0, _copilotkit_shared_generative_ui.toError)(thrown));
|
|
2919
|
+
}
|
|
2920
|
+
componentDidMount() {
|
|
2921
|
+
if (!this.state.failed) {
|
|
2922
|
+
this.props.log.clear(this.props.slot);
|
|
2923
|
+
return;
|
|
2924
|
+
}
|
|
2925
|
+
if (this.state.error) this.report(this.state.error);
|
|
2926
|
+
}
|
|
2927
|
+
componentDidUpdate() {
|
|
2928
|
+
if (!this.state.failed) this.props.log.clear(this.props.slot);
|
|
2929
|
+
}
|
|
2930
|
+
render() {
|
|
2931
|
+
return this.state.failed ? this.props.replacement ?? null : this.props.children;
|
|
2932
|
+
}
|
|
2933
|
+
};
|
|
2934
|
+
/**
|
|
2935
|
+
* The host's `NodeFallback`, guarded: when it throws, the node renders
|
|
2936
|
+
* nothing and the error is reported, and the parent node keeps rendering.
|
|
2937
|
+
* Every place that shows the host fallback goes through this.
|
|
2938
|
+
*/
|
|
2939
|
+
function GuardedNodeFallback({ surfaceId, componentId, runtime, message, retry, slot, revision }) {
|
|
2940
|
+
const { NodeFallback } = useGenerativeUIHost();
|
|
2941
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FallbackGuard, {
|
|
2942
|
+
surfaceId,
|
|
2943
|
+
componentId,
|
|
2944
|
+
runtime,
|
|
2945
|
+
log: useFailureLog(),
|
|
2946
|
+
slot,
|
|
2947
|
+
context: message,
|
|
2948
|
+
resetKeys: [message, revision],
|
|
2949
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NodeFallback, {
|
|
2950
|
+
message,
|
|
2951
|
+
componentId: componentId ?? "surface",
|
|
2952
|
+
retry
|
|
2953
|
+
})
|
|
2954
|
+
});
|
|
2955
|
+
}
|
|
2956
|
+
/**
|
|
2957
|
+
* Calls the app's `errorBoundary.fallback` in a render of its own, so that
|
|
2958
|
+
* the guard above it catches what it throws.
|
|
2959
|
+
*/
|
|
2960
|
+
function AppErrorFallback({ render, ...props }) {
|
|
2961
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: render(props) });
|
|
2962
|
+
}
|
|
2963
|
+
/**
|
|
2964
|
+
* Per-node boundary. Resets on retry or a new agent revision, not on data
|
|
2965
|
+
* ticks. A failure that stays the same across revisions is reported once.
|
|
2966
|
+
*/
|
|
2967
|
+
var NodeBoundary = class extends react.Component {
|
|
2968
|
+
constructor(..._args2) {
|
|
2969
|
+
super(..._args2);
|
|
2673
2970
|
this.state = {
|
|
2674
2971
|
error: null,
|
|
2675
2972
|
revision: this.props.revision
|
|
2676
2973
|
};
|
|
2677
2974
|
this.retry = () => this.setState({ error: null });
|
|
2678
2975
|
}
|
|
2679
|
-
static getDerivedStateFromError(
|
|
2680
|
-
return { error };
|
|
2976
|
+
static getDerivedStateFromError(thrown) {
|
|
2977
|
+
return { error: (0, _copilotkit_shared_generative_ui.toError)(thrown) };
|
|
2681
2978
|
}
|
|
2682
2979
|
static getDerivedStateFromProps(props, state) {
|
|
2683
2980
|
return props.revision !== state.revision ? {
|
|
@@ -2685,53 +2982,138 @@ react_markdown = __toESM(react_markdown);
|
|
|
2685
2982
|
revision: props.revision
|
|
2686
2983
|
} : null;
|
|
2687
2984
|
}
|
|
2688
|
-
componentDidCatch(
|
|
2689
|
-
const { runtime, surfaceId, componentId } = this.props;
|
|
2690
|
-
(
|
|
2985
|
+
componentDidCatch(thrown) {
|
|
2986
|
+
const { runtime, surfaceId, componentId, log, place } = this.props;
|
|
2987
|
+
log.clear(failureSlots.fallback(place));
|
|
2988
|
+
log.report(runtime, failureSlots.node(place), {
|
|
2691
2989
|
kind: "render",
|
|
2692
2990
|
surfaceId,
|
|
2693
2991
|
componentId,
|
|
2694
|
-
error
|
|
2992
|
+
error: this.state.error ?? (0, _copilotkit_shared_generative_ui.toError)(thrown)
|
|
2993
|
+
});
|
|
2994
|
+
}
|
|
2995
|
+
slots() {
|
|
2996
|
+
const { place } = this.props;
|
|
2997
|
+
return [
|
|
2998
|
+
failureSlots.node(place),
|
|
2999
|
+
failureSlots.appFallback(place),
|
|
3000
|
+
failureSlots.renderFallback(place)
|
|
3001
|
+
];
|
|
3002
|
+
}
|
|
3003
|
+
clearSlots() {
|
|
3004
|
+
for (const slot of this.slots()) this.props.log.clear(slot);
|
|
3005
|
+
}
|
|
3006
|
+
componentDidMount() {
|
|
3007
|
+
for (const slot of this.slots()) this.props.log.retain(slot);
|
|
3008
|
+
if (!this.state.error) {
|
|
3009
|
+
this.clearSlots();
|
|
3010
|
+
return;
|
|
3011
|
+
}
|
|
3012
|
+
const { runtime, surfaceId, componentId, log, place } = this.props;
|
|
3013
|
+
log.report(runtime, failureSlots.node(place), {
|
|
3014
|
+
kind: "render",
|
|
3015
|
+
surfaceId,
|
|
3016
|
+
componentId,
|
|
3017
|
+
error: this.state.error
|
|
2695
3018
|
});
|
|
2696
3019
|
}
|
|
3020
|
+
componentDidUpdate(prevProps) {
|
|
3021
|
+
if (prevProps.place !== this.props.place) {
|
|
3022
|
+
const { log } = this.props;
|
|
3023
|
+
log.release(failureSlots.node(prevProps.place));
|
|
3024
|
+
log.release(failureSlots.appFallback(prevProps.place));
|
|
3025
|
+
log.release(failureSlots.renderFallback(prevProps.place));
|
|
3026
|
+
for (const slot of this.slots()) log.retain(slot);
|
|
3027
|
+
}
|
|
3028
|
+
if (!this.state.error) this.clearSlots();
|
|
3029
|
+
}
|
|
3030
|
+
componentWillUnmount() {
|
|
3031
|
+
for (const slot of this.slots()) this.props.log.release(slot);
|
|
3032
|
+
}
|
|
2697
3033
|
render() {
|
|
2698
3034
|
const { error } = this.state;
|
|
2699
3035
|
if (!error) return this.props.children;
|
|
2700
|
-
const { runtime, surfaceId, componentId } = this.props;
|
|
2701
|
-
const
|
|
2702
|
-
return fallback ? fallback({
|
|
2703
|
-
error,
|
|
2704
|
-
retry: this.retry,
|
|
3036
|
+
const { runtime, surfaceId, componentId, place, log } = this.props;
|
|
3037
|
+
const hostFallback = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GuardedNodeFallback, {
|
|
2705
3038
|
surfaceId,
|
|
2706
|
-
componentId
|
|
2707
|
-
|
|
3039
|
+
componentId,
|
|
3040
|
+
runtime,
|
|
2708
3041
|
message: error.message,
|
|
3042
|
+
retry: this.retry,
|
|
3043
|
+
slot: failureSlots.renderFallback(place)
|
|
3044
|
+
});
|
|
3045
|
+
const fallback = runtime.errorFallback;
|
|
3046
|
+
if (!fallback) return hostFallback;
|
|
3047
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FallbackGuard, {
|
|
3048
|
+
surfaceId,
|
|
2709
3049
|
componentId,
|
|
2710
|
-
|
|
3050
|
+
runtime,
|
|
3051
|
+
log,
|
|
3052
|
+
slot: failureSlots.appFallback(place),
|
|
3053
|
+
context: error.message,
|
|
3054
|
+
resetKeys: [error],
|
|
3055
|
+
replacement: hostFallback,
|
|
3056
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AppErrorFallback, {
|
|
3057
|
+
render: fallback,
|
|
3058
|
+
error,
|
|
3059
|
+
retry: this.retry,
|
|
3060
|
+
surfaceId,
|
|
3061
|
+
componentId
|
|
3062
|
+
})
|
|
2711
3063
|
});
|
|
2712
3064
|
}
|
|
2713
3065
|
};
|
|
2714
|
-
/**
|
|
3066
|
+
/**
|
|
3067
|
+
* Surface boundary: a failure here must not reach the chat or the host page.
|
|
3068
|
+
* It resets on a new revision, and on Retry when `retryable`. A failure that
|
|
3069
|
+
* stays the same across revisions is reported once.
|
|
3070
|
+
*/
|
|
2715
3071
|
var SurfaceBoundary = class extends react.Component {
|
|
2716
|
-
constructor(...
|
|
2717
|
-
super(...
|
|
2718
|
-
this.state = {
|
|
3072
|
+
constructor(..._args3) {
|
|
3073
|
+
super(..._args3);
|
|
3074
|
+
this.state = {
|
|
3075
|
+
error: null,
|
|
3076
|
+
revision: this.props.revision
|
|
3077
|
+
};
|
|
3078
|
+
this.retry = () => this.setState({ error: null });
|
|
2719
3079
|
}
|
|
2720
|
-
static getDerivedStateFromError(
|
|
2721
|
-
return { error };
|
|
3080
|
+
static getDerivedStateFromError(thrown) {
|
|
3081
|
+
return { error: (0, _copilotkit_shared_generative_ui.toError)(thrown) };
|
|
3082
|
+
}
|
|
3083
|
+
static getDerivedStateFromProps(props, state) {
|
|
3084
|
+
return props.revision !== state.revision ? {
|
|
3085
|
+
error: null,
|
|
3086
|
+
revision: props.revision
|
|
3087
|
+
} : null;
|
|
2722
3088
|
}
|
|
2723
|
-
componentDidCatch(
|
|
2724
|
-
|
|
3089
|
+
componentDidCatch(thrown) {
|
|
3090
|
+
const { runtime, surfaceId, log, level } = this.props;
|
|
3091
|
+
log.report(runtime, failureSlots.surface(level), {
|
|
2725
3092
|
kind: "render",
|
|
2726
|
-
surfaceId
|
|
2727
|
-
error
|
|
3093
|
+
surfaceId,
|
|
3094
|
+
error: this.state.error ?? (0, _copilotkit_shared_generative_ui.toError)(thrown)
|
|
2728
3095
|
});
|
|
2729
3096
|
}
|
|
3097
|
+
clearSlots() {
|
|
3098
|
+
const { log, level } = this.props;
|
|
3099
|
+
log.clear(failureSlots.surface(level));
|
|
3100
|
+
log.clear(failureSlots.surfaceFallback(level));
|
|
3101
|
+
}
|
|
3102
|
+
componentDidMount() {
|
|
3103
|
+
if (!this.state.error) this.clearSlots();
|
|
3104
|
+
}
|
|
3105
|
+
componentDidUpdate() {
|
|
3106
|
+
if (!this.state.error) this.clearSlots();
|
|
3107
|
+
}
|
|
2730
3108
|
render() {
|
|
2731
3109
|
if (!this.state.error) return this.props.children;
|
|
2732
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
3110
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GuardedNodeFallback, {
|
|
3111
|
+
surfaceId: this.props.surfaceId,
|
|
3112
|
+
componentId: void 0,
|
|
3113
|
+
runtime: this.props.runtime,
|
|
2733
3114
|
message: "this generated UI failed to render",
|
|
2734
|
-
|
|
3115
|
+
retry: this.props.retryable ? this.retry : void 0,
|
|
3116
|
+
slot: failureSlots.surfaceFallback(this.props.level)
|
|
2735
3117
|
});
|
|
2736
3118
|
}
|
|
2737
3119
|
};
|
|
@@ -2739,7 +3121,6 @@ react_markdown = __toESM(react_markdown);
|
|
|
2739
3121
|
//#endregion
|
|
2740
3122
|
//#region src/v2/generative-ui/SurfaceView.tsx
|
|
2741
3123
|
const NO_ANCESTORS = [];
|
|
2742
|
-
const ROOT_STYLE = { display: "contents" };
|
|
2743
3124
|
const undefinedSnapshot = () => void 0;
|
|
2744
3125
|
const noopSubscribe = () => () => {};
|
|
2745
3126
|
const zeroSnapshot = () => 0;
|
|
@@ -2749,23 +3130,80 @@ react_markdown = __toESM(react_markdown);
|
|
|
2749
3130
|
}
|
|
2750
3131
|
function SurfaceView({ surface }) {
|
|
2751
3132
|
const runtime = useRequiredGenerativeUIRuntime();
|
|
2752
|
-
const {
|
|
2753
|
-
const
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
3133
|
+
const { SurfaceRoot } = useGenerativeUIHost();
|
|
3134
|
+
const appliedCount = (0, react.useSyncExternalStore)(runtime.manager.subscribe, () => surface.operations.length, undefinedSnapshot);
|
|
3135
|
+
const revision = (0, react.useMemo)(() => ({
|
|
3136
|
+
surface,
|
|
3137
|
+
appliedCount
|
|
3138
|
+
}), [surface, appliedCount]);
|
|
3139
|
+
const [scopedLog, setScopedLog] = (0, react.useState)(() => ({
|
|
3140
|
+
key: surface.key,
|
|
3141
|
+
log: createFailureLog()
|
|
3142
|
+
}));
|
|
3143
|
+
let failureLog = scopedLog.log;
|
|
3144
|
+
if (scopedLog.key !== surface.key) {
|
|
3145
|
+
const next = {
|
|
3146
|
+
key: surface.key,
|
|
3147
|
+
log: createFailureLog()
|
|
3148
|
+
};
|
|
3149
|
+
setScopedLog(next);
|
|
3150
|
+
failureLog = next.log;
|
|
3151
|
+
}
|
|
3152
|
+
const { threadId, surfaceId } = surface;
|
|
3153
|
+
const { manager } = runtime;
|
|
3154
|
+
const seen = (0, react.useRef)(void 0);
|
|
3155
|
+
(0, react.useLayoutEffect)(() => {
|
|
3156
|
+
const contentOf = () => {
|
|
3157
|
+
const current = manager.getSurface(threadId, surfaceId);
|
|
3158
|
+
return {
|
|
3159
|
+
log: failureLog,
|
|
3160
|
+
current,
|
|
3161
|
+
applied: current?.operations.length
|
|
3162
|
+
};
|
|
3163
|
+
};
|
|
3164
|
+
const observe = (missed) => {
|
|
3165
|
+
const last = seen.current;
|
|
3166
|
+
const next = contentOf();
|
|
3167
|
+
seen.current = next;
|
|
3168
|
+
if (last?.log === failureLog && (next.current !== last.current || next.applied !== last.applied)) failureLog.settle(missed);
|
|
3169
|
+
};
|
|
3170
|
+
observe(true);
|
|
3171
|
+
return manager.subscribe(() => observe(false));
|
|
3172
|
+
}, [
|
|
3173
|
+
manager,
|
|
3174
|
+
threadId,
|
|
3175
|
+
surfaceId,
|
|
3176
|
+
failureLog
|
|
3177
|
+
]);
|
|
3178
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GenerativeUIFailureLogContext.Provider, {
|
|
3179
|
+
value: failureLog,
|
|
3180
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SurfaceBoundary, {
|
|
2760
3181
|
surfaceId: surface.surfaceId,
|
|
2761
3182
|
runtime,
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
3183
|
+
log: failureLog,
|
|
3184
|
+
level: "outer",
|
|
3185
|
+
revision,
|
|
3186
|
+
retryable: true,
|
|
3187
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SurfaceRoot, {
|
|
3188
|
+
surfaceId: surface.surfaceId,
|
|
3189
|
+
theme: runtime.theme,
|
|
3190
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SurfaceBoundary, {
|
|
3191
|
+
surfaceId: surface.surfaceId,
|
|
3192
|
+
runtime,
|
|
3193
|
+
log: failureLog,
|
|
3194
|
+
level: "inner",
|
|
3195
|
+
revision,
|
|
3196
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NodeView, {
|
|
3197
|
+
surface,
|
|
3198
|
+
componentId: _copilotkit_shared.GENERATIVE_UI_ROOT_ID,
|
|
3199
|
+
basePath: void 0,
|
|
3200
|
+
ancestors: NO_ANCESTORS,
|
|
3201
|
+
parentPlace: "",
|
|
3202
|
+
via: ""
|
|
3203
|
+
})
|
|
3204
|
+
})
|
|
2767
3205
|
})
|
|
2768
|
-
})
|
|
3206
|
+
})
|
|
2769
3207
|
});
|
|
2770
3208
|
}
|
|
2771
3209
|
/**
|
|
@@ -2790,27 +3228,63 @@ react_markdown = __toESM(react_markdown);
|
|
|
2790
3228
|
* repeats both.
|
|
2791
3229
|
*/
|
|
2792
3230
|
function scopedId(componentId, basePath) {
|
|
2793
|
-
return `${basePath
|
|
3231
|
+
return `${basePath === void 0 ? "" : JSON.stringify(basePath)}#${JSON.stringify(componentId)}`;
|
|
2794
3232
|
}
|
|
2795
|
-
|
|
3233
|
+
/**
|
|
3234
|
+
* Where one rendered copy of a node is: the place of its parent, the slot
|
|
3235
|
+
* or child reference of the parent it renders in, and its scoped id. Names
|
|
3236
|
+
* the node's failure-log slots. A scoped id alone is not enough: the same
|
|
3237
|
+
* id can render under two parents, and a cyclic reference repeats the
|
|
3238
|
+
* scoped id of an ancestor. Each copy keeps its own memory of what it
|
|
3239
|
+
* reported, so one copy that renders, goes away or remounts does not clear
|
|
3240
|
+
* the memory of another that still fails.
|
|
3241
|
+
*/
|
|
3242
|
+
function placeOf(parentPlace, via, position) {
|
|
3243
|
+
return `${parentPlace}/${via === "" ? "" : JSON.stringify(via)}${position}`;
|
|
3244
|
+
}
|
|
3245
|
+
const NodeView = (0, react.memo)(function NodeView({ surface, componentId, basePath, ancestors, parentPlace, via }) {
|
|
2796
3246
|
const runtime = useRequiredGenerativeUIRuntime();
|
|
3247
|
+
const log = useFailureLog();
|
|
2797
3248
|
const component = useComponentModel(runtime.manager, surface.model, componentId);
|
|
2798
3249
|
const properties = useComponentProperties(runtime.manager, component);
|
|
2799
|
-
|
|
3250
|
+
const position = scopedId(componentId, basePath);
|
|
3251
|
+
const place = placeOf(parentPlace, via, position);
|
|
3252
|
+
(0, react.useEffect)(() => {
|
|
3253
|
+
const slots = [
|
|
3254
|
+
failureSlots.fallback(place),
|
|
3255
|
+
failureSlots.cycle(place),
|
|
3256
|
+
failureSlots.props(place)
|
|
3257
|
+
];
|
|
3258
|
+
for (const slot of slots) log.retain(slot);
|
|
3259
|
+
return () => {
|
|
3260
|
+
for (const slot of slots) log.release(slot);
|
|
3261
|
+
};
|
|
3262
|
+
}, [log, place]);
|
|
3263
|
+
if (ancestors.includes(position)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GuardedNodeFallback, {
|
|
3264
|
+
surfaceId: surface.surfaceId,
|
|
3265
|
+
componentId,
|
|
3266
|
+
runtime,
|
|
2800
3267
|
message: `cyclic reference to ${componentId}`,
|
|
2801
|
-
|
|
3268
|
+
slot: failureSlots.cycle(place),
|
|
3269
|
+
revision: properties
|
|
2802
3270
|
});
|
|
2803
3271
|
if (!component || !properties) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NodePlaceholder, { componentId });
|
|
2804
3272
|
const definition = runtime.ui.components.get(component.type);
|
|
2805
|
-
if (!definition) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
3273
|
+
if (!definition) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GuardedNodeFallback, {
|
|
3274
|
+
surfaceId: surface.surfaceId,
|
|
3275
|
+
componentId,
|
|
3276
|
+
runtime,
|
|
2806
3277
|
message: `unknown component "${component.type}"`,
|
|
2807
|
-
|
|
3278
|
+
slot: failureSlots.fallback(place),
|
|
3279
|
+
revision: properties
|
|
2808
3280
|
});
|
|
2809
3281
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NodeBoundary, {
|
|
2810
3282
|
surfaceId: surface.surfaceId,
|
|
2811
3283
|
componentId,
|
|
3284
|
+
place,
|
|
2812
3285
|
revision: properties,
|
|
2813
3286
|
runtime,
|
|
3287
|
+
log,
|
|
2814
3288
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResolvedNode, {
|
|
2815
3289
|
surface,
|
|
2816
3290
|
componentId,
|
|
@@ -2818,7 +3292,8 @@ react_markdown = __toESM(react_markdown);
|
|
|
2818
3292
|
properties,
|
|
2819
3293
|
runtime,
|
|
2820
3294
|
basePath,
|
|
2821
|
-
ancestors
|
|
3295
|
+
ancestors,
|
|
3296
|
+
place
|
|
2822
3297
|
})
|
|
2823
3298
|
}, component.type);
|
|
2824
3299
|
});
|
|
@@ -2826,7 +3301,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
2826
3301
|
* Renders the component of a template once for each item of the list at the
|
|
2827
3302
|
* template path, keyed by index. Renders nothing when there is no list.
|
|
2828
3303
|
*/
|
|
2829
|
-
function TemplateChildren({ surface, template, basePath, ancestors }) {
|
|
3304
|
+
function TemplateChildren({ surface, template, basePath, ancestors, parentPlace, via }) {
|
|
2830
3305
|
const dataModel = surface.model.dataModel;
|
|
2831
3306
|
const listPath = (0, _copilotkit_core_generative_ui.resolvePath)(template.path, basePath);
|
|
2832
3307
|
const subscribe = (0, react.useCallback)((onChange) => {
|
|
@@ -2842,17 +3317,25 @@ react_markdown = __toESM(react_markdown);
|
|
|
2842
3317
|
surface,
|
|
2843
3318
|
componentId: template.componentId,
|
|
2844
3319
|
basePath: (0, _copilotkit_core_generative_ui.joinPath)(listPath, String(index)),
|
|
2845
|
-
ancestors
|
|
3320
|
+
ancestors,
|
|
3321
|
+
parentPlace,
|
|
3322
|
+
via
|
|
2846
3323
|
}, index)) });
|
|
2847
3324
|
}
|
|
2848
3325
|
/**
|
|
2849
3326
|
* The props the model sets, with their dynamic values resolved from the
|
|
2850
3327
|
* surface data model: `{"@path"}` bindings, `{"@call"}` function values and
|
|
2851
|
-
* `{"@call":"@index"}` in a template, at any depth.
|
|
2852
|
-
*
|
|
2853
|
-
*
|
|
2854
|
-
*
|
|
2855
|
-
*
|
|
3328
|
+
* `{"@call":"@index"}` in a template, at any depth. Bound props, events and
|
|
3329
|
+
* slots are left out, and so are the keys of the A2UI component envelope;
|
|
3330
|
+
* `accessibility` is resolved the same way and given on its own.
|
|
3331
|
+
*
|
|
3332
|
+
* A writable prop that is not bound to a path and that the component set
|
|
3333
|
+
* shows the local value from `overrides`, also when the model never set the
|
|
3334
|
+
* prop. That is intended: the user's edit wins over the model's literal
|
|
3335
|
+
* value, also over a newer literal the agent sends later, until the node
|
|
3336
|
+
* remounts. A literal is not data the agent and the user share; a prop
|
|
3337
|
+
* that both must write is bound to a path, and the setter writes the data
|
|
3338
|
+
* model.
|
|
2856
3339
|
*
|
|
2857
3340
|
* A prop is resolved again only when its raw value or a data model value it
|
|
2858
3341
|
* read has changed, so the result keeps its identity otherwise. A function
|
|
@@ -2863,7 +3346,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
2863
3346
|
const units = (0, react.useMemo)(() => {
|
|
2864
3347
|
const list = [];
|
|
2865
3348
|
for (const key of Object.keys(properties)) {
|
|
2866
|
-
if (definition.events?.[key] || definition.slots?.[key] ||
|
|
3349
|
+
if (definition.events?.[key] || definition.slots?.[key] || (0, _copilotkit_shared_generative_ui.hasOwnKey)(definition.selectors, key) || _copilotkit_shared.A2UI_COMPONENT_ENVELOPE_KEYS.has(key)) continue;
|
|
2867
3350
|
list.push({
|
|
2868
3351
|
key,
|
|
2869
3352
|
raw: properties[key]
|
|
@@ -2964,9 +3447,10 @@ react_markdown = __toESM(react_markdown);
|
|
|
2964
3447
|
for (const [key, selector] of selectors) try {
|
|
2965
3448
|
values[key] = selector(state, modelProps);
|
|
2966
3449
|
} catch (error) {
|
|
3450
|
+
const { message } = (0, _copilotkit_shared_generative_ui.toError)(error);
|
|
2967
3451
|
return {
|
|
2968
3452
|
ok: false,
|
|
2969
|
-
problem: `${key}: selector threw: ${
|
|
3453
|
+
problem: `${key}: selector threw: ${message}`
|
|
2970
3454
|
};
|
|
2971
3455
|
}
|
|
2972
3456
|
return {
|
|
@@ -2977,8 +3461,10 @@ react_markdown = __toESM(react_markdown);
|
|
|
2977
3461
|
/**
|
|
2978
3462
|
* The values of the bound props of a node, read from the app state.
|
|
2979
3463
|
*
|
|
2980
|
-
* The selectors
|
|
2981
|
-
*
|
|
3464
|
+
* The selectors get the checked model props: the resolved values that
|
|
3465
|
+
* passed the props schema (without the nulls it rejected), not the
|
|
3466
|
+
* schema's parsed output, so its defaults and transforms are not applied
|
|
3467
|
+
* yet. They run again only when the state object or those props change. When the new values are shallow-equal to the last ones, the
|
|
2982
3468
|
* last snapshot is kept. So the node re-renders only when a selected value
|
|
2983
3469
|
* changes. A selector that returns a new array on each call cannot cause a
|
|
2984
3470
|
* render loop: with the same inputs, the cached snapshot comes back.
|
|
@@ -3008,7 +3494,10 @@ react_markdown = __toESM(react_markdown);
|
|
|
3008
3494
|
* Checks the model-set props with the props schema before the selectors run.
|
|
3009
3495
|
* The bound props are not set yet, so their issues do not count. Neither do
|
|
3010
3496
|
* issues with no path (a check over several props), which the full check
|
|
3011
|
-
* after the selectors reports.
|
|
3497
|
+
* after the selectors reports. The exception is the issue that an async
|
|
3498
|
+
* props schema gives (`isAsyncIssue`): the render checks props
|
|
3499
|
+
* synchronously only, so the full check would fail the same way, and it is
|
|
3500
|
+
* reported here.
|
|
3012
3501
|
*/
|
|
3013
3502
|
function checkModelProps(definition, modelData) {
|
|
3014
3503
|
if (!definition.props) return {
|
|
@@ -3027,7 +3516,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
3027
3516
|
if (!result.success) {
|
|
3028
3517
|
const issues = result.issues.filter((issue) => {
|
|
3029
3518
|
const key = (0, _copilotkit_shared_generative_ui.issueKey)(issue);
|
|
3030
|
-
return key === void 0 ? (0, _copilotkit_shared_generative_ui.isAsyncIssue)(issue) : !
|
|
3519
|
+
return key === void 0 ? (0, _copilotkit_shared_generative_ui.isAsyncIssue)(issue) : !(0, _copilotkit_shared_generative_ui.hasOwnKey)(definition.selectors, key);
|
|
3031
3520
|
});
|
|
3032
3521
|
if (issues.length > 0) return {
|
|
3033
3522
|
ok: false,
|
|
@@ -3090,7 +3579,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
3090
3579
|
function useEventProps(runtime, surface, componentId, definition, properties, basePath) {
|
|
3091
3580
|
const latest = (0, react.useRef)(properties);
|
|
3092
3581
|
latest.current = properties;
|
|
3093
|
-
const boundNames = Object.keys(definition.events ?? {}).filter((name) =>
|
|
3582
|
+
const boundNames = Object.keys(definition.events ?? {}).filter((name) => (0, _copilotkit_shared_generative_ui.hasOwnKey)(definition.eventFunctions, name) || (0, _copilotkit_shared.isActionBinding)(properties[name])).join("|");
|
|
3094
3583
|
return (0, react.useMemo)(() => {
|
|
3095
3584
|
const handlers = {};
|
|
3096
3585
|
const names = boundNames ? boundNames.split("|") : [];
|
|
@@ -3102,7 +3591,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
3102
3591
|
name,
|
|
3103
3592
|
parameters: definition.events?.[name]?.parameters
|
|
3104
3593
|
};
|
|
3105
|
-
const functionName =
|
|
3594
|
+
const functionName = (0, _copilotkit_shared_generative_ui.hasOwnKey)(definition.eventFunctions, name) ? definition.eventFunctions[name] : void 0;
|
|
3106
3595
|
handlers[name] = functionName === void 0 ? (args) => (0, _copilotkit_core_generative_ui.invokeBoundEvent)({
|
|
3107
3596
|
...call,
|
|
3108
3597
|
binding: latest.current[name],
|
|
@@ -3128,7 +3617,9 @@ react_markdown = __toESM(react_markdown);
|
|
|
3128
3617
|
* The setter props of a node: `setValue` for the writable prop `value`. For
|
|
3129
3618
|
* a prop the model bound to `{"@path"}`, the setter writes the data model
|
|
3130
3619
|
* and makes the path user-owned. For a literal prop, it sets `overrides`, a
|
|
3131
|
-
* local value of this mounted node
|
|
3620
|
+
* local value of this mounted node that wins over the model's value until
|
|
3621
|
+
* the node remounts (see `useModelDataProps`). The setters keep their
|
|
3622
|
+
* identity.
|
|
3132
3623
|
*/
|
|
3133
3624
|
function useSetterProps(runtime, surface, componentId, definition, properties, basePath) {
|
|
3134
3625
|
const [overrides, setOverrides] = (0, react.useState)({});
|
|
@@ -3151,7 +3642,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
3151
3642
|
try {
|
|
3152
3643
|
runtime.manager.setOwnedValue(surface.key, (0, _copilotkit_core_generative_ui.resolvePath)(binding["@path"], basePath), value);
|
|
3153
3644
|
} catch (cause) {
|
|
3154
|
-
const message =
|
|
3645
|
+
const { message } = (0, _copilotkit_shared_generative_ui.toError)(cause);
|
|
3155
3646
|
(0, _copilotkit_core_generative_ui.reportErrorSafely)(runtime, {
|
|
3156
3647
|
kind: "props",
|
|
3157
3648
|
surfaceId: surface.surfaceId,
|
|
@@ -3170,29 +3661,36 @@ react_markdown = __toESM(react_markdown);
|
|
|
3170
3661
|
])
|
|
3171
3662
|
};
|
|
3172
3663
|
}
|
|
3173
|
-
function useSlotProps(surface, definition, properties, componentId, basePath, ancestors) {
|
|
3664
|
+
function useSlotProps(surface, definition, properties, componentId, basePath, ancestors, place) {
|
|
3174
3665
|
return (0, react.useMemo)(() => {
|
|
3175
3666
|
const childAncestors = [...ancestors, scopedId(componentId, basePath)];
|
|
3176
3667
|
const slots = {};
|
|
3177
3668
|
for (const [name, kind] of Object.entries(definition.slots ?? {})) {
|
|
3178
3669
|
const value = properties[name];
|
|
3670
|
+
const via = `${name}:`;
|
|
3179
3671
|
if (kind === "single" && typeof value === "string") slots[name] = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NodeView, {
|
|
3180
3672
|
surface,
|
|
3181
3673
|
componentId: value,
|
|
3182
3674
|
basePath,
|
|
3183
|
-
ancestors: childAncestors
|
|
3675
|
+
ancestors: childAncestors,
|
|
3676
|
+
parentPlace: place,
|
|
3677
|
+
via
|
|
3184
3678
|
});
|
|
3185
3679
|
else if (kind === "multiple" && isTemplateChildren(value)) slots[name] = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TemplateChildren, {
|
|
3186
3680
|
surface,
|
|
3187
3681
|
template: value,
|
|
3188
3682
|
basePath,
|
|
3189
|
-
ancestors: childAncestors
|
|
3683
|
+
ancestors: childAncestors,
|
|
3684
|
+
parentPlace: place,
|
|
3685
|
+
via
|
|
3190
3686
|
});
|
|
3191
3687
|
else if (kind === "multiple" && Array.isArray(value)) slots[name] = [...new Set(value.filter((id) => typeof id === "string"))].map((id) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NodeView, {
|
|
3192
3688
|
surface,
|
|
3193
3689
|
componentId: id,
|
|
3194
3690
|
basePath,
|
|
3195
|
-
ancestors: childAncestors
|
|
3691
|
+
ancestors: childAncestors,
|
|
3692
|
+
parentPlace: place,
|
|
3693
|
+
via
|
|
3196
3694
|
}, id));
|
|
3197
3695
|
}
|
|
3198
3696
|
return slots;
|
|
@@ -3202,7 +3700,8 @@ react_markdown = __toESM(react_markdown);
|
|
|
3202
3700
|
properties,
|
|
3203
3701
|
componentId,
|
|
3204
3702
|
basePath,
|
|
3205
|
-
ancestors
|
|
3703
|
+
ancestors,
|
|
3704
|
+
place
|
|
3206
3705
|
]);
|
|
3207
3706
|
}
|
|
3208
3707
|
/**
|
|
@@ -3210,33 +3709,43 @@ react_markdown = __toESM(react_markdown);
|
|
|
3210
3709
|
* `childList()`, at any depth) replaced by the rendered component. Without
|
|
3211
3710
|
* references, the parsed props come back as they are.
|
|
3212
3711
|
*/
|
|
3213
|
-
function useChildRefProps(surface, refs, props, componentId, basePath, ancestors) {
|
|
3712
|
+
function useChildRefProps(surface, refs, props, componentId, basePath, ancestors, place) {
|
|
3214
3713
|
return (0, react.useMemo)(() => {
|
|
3215
3714
|
if (props === void 0 || refs.length === 0) return props;
|
|
3216
3715
|
const childAncestors = [...ancestors, scopedId(componentId, basePath)];
|
|
3217
|
-
const render = (kind, value) => {
|
|
3716
|
+
const render = (kind, value, via) => {
|
|
3218
3717
|
if (kind === "single") return typeof value === "string" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NodeView, {
|
|
3219
3718
|
surface,
|
|
3220
3719
|
componentId: value,
|
|
3221
3720
|
basePath,
|
|
3222
|
-
ancestors: childAncestors
|
|
3721
|
+
ancestors: childAncestors,
|
|
3722
|
+
parentPlace: place,
|
|
3723
|
+
via
|
|
3223
3724
|
}) : void 0;
|
|
3224
3725
|
if (isTemplateChildren(value)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TemplateChildren, {
|
|
3225
3726
|
surface,
|
|
3226
3727
|
template: value,
|
|
3227
3728
|
basePath,
|
|
3228
|
-
ancestors: childAncestors
|
|
3729
|
+
ancestors: childAncestors,
|
|
3730
|
+
parentPlace: place,
|
|
3731
|
+
via
|
|
3229
3732
|
});
|
|
3230
3733
|
if (!Array.isArray(value)) return void 0;
|
|
3231
3734
|
return [...new Set(value.filter((id) => typeof id === "string"))].map((id) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NodeView, {
|
|
3232
3735
|
surface,
|
|
3233
3736
|
componentId: id,
|
|
3234
3737
|
basePath,
|
|
3235
|
-
ancestors: childAncestors
|
|
3738
|
+
ancestors: childAncestors,
|
|
3739
|
+
parentPlace: place,
|
|
3740
|
+
via
|
|
3236
3741
|
}, id));
|
|
3237
3742
|
};
|
|
3238
3743
|
let result = props;
|
|
3239
|
-
for (const ref of refs)
|
|
3744
|
+
for (const ref of refs) {
|
|
3745
|
+
let found = 0;
|
|
3746
|
+
const path = ref.path.join(".");
|
|
3747
|
+
result = (0, _copilotkit_shared.mapAtChildRef)(result, ref.path, (value) => render(ref.kind, value, `${path}[${found++}]:`));
|
|
3748
|
+
}
|
|
3240
3749
|
return result;
|
|
3241
3750
|
}, [
|
|
3242
3751
|
surface,
|
|
@@ -3244,15 +3753,17 @@ react_markdown = __toESM(react_markdown);
|
|
|
3244
3753
|
props,
|
|
3245
3754
|
componentId,
|
|
3246
3755
|
basePath,
|
|
3247
|
-
ancestors
|
|
3756
|
+
ancestors,
|
|
3757
|
+
place
|
|
3248
3758
|
]);
|
|
3249
3759
|
}
|
|
3250
|
-
function ResolvedNode({ surface, componentId, definition, properties, runtime, basePath, ancestors }) {
|
|
3760
|
+
function ResolvedNode({ surface, componentId, definition, properties, runtime, basePath, ancestors, place }) {
|
|
3761
|
+
const { AccessibilityWrapper } = useGenerativeUIHost();
|
|
3251
3762
|
const { overrides, setters } = useSetterProps(runtime, surface, componentId, definition, properties, basePath);
|
|
3252
3763
|
const dataProps = useDataProps(runtime, surface, definition, properties, basePath, overrides);
|
|
3253
3764
|
const eventProps = useEventProps(runtime, surface, componentId, definition, properties, basePath);
|
|
3254
|
-
const slotProps = useSlotProps(surface, definition, properties, componentId, basePath, ancestors);
|
|
3255
|
-
const childRefProps = useChildRefProps(surface, definition.childRefs, dataProps.ok ? dataProps.props : void 0, componentId, basePath, ancestors);
|
|
3765
|
+
const slotProps = useSlotProps(surface, definition, properties, componentId, basePath, ancestors, place);
|
|
3766
|
+
const childRefProps = useChildRefProps(surface, definition.childRefs, dataProps.ok ? dataProps.props : void 0, componentId, basePath, ancestors, place);
|
|
3256
3767
|
const accessibility = dataProps.ok ? dataProps.accessibility : void 0;
|
|
3257
3768
|
const nodeContext = (0, react.useMemo)(() => ({
|
|
3258
3769
|
surfaceKey: surface.key,
|
|
@@ -3266,8 +3777,19 @@ react_markdown = __toESM(react_markdown);
|
|
|
3266
3777
|
accessibility
|
|
3267
3778
|
]);
|
|
3268
3779
|
const problem = dataProps.ok ? void 0 : dataProps.problem;
|
|
3780
|
+
const log = useFailureLog();
|
|
3269
3781
|
(0, react.useEffect)(() => {
|
|
3270
|
-
if (problem)
|
|
3782
|
+
if (!problem) {
|
|
3783
|
+
log.clear(failureSlots.fallback(place));
|
|
3784
|
+
log.clear(failureSlots.props(place));
|
|
3785
|
+
}
|
|
3786
|
+
}, [
|
|
3787
|
+
problem,
|
|
3788
|
+
log,
|
|
3789
|
+
place
|
|
3790
|
+
]);
|
|
3791
|
+
(0, react.useEffect)(() => {
|
|
3792
|
+
if (problem) log.report(runtime, failureSlots.props(place), {
|
|
3271
3793
|
kind: "props",
|
|
3272
3794
|
surfaceId: surface.surfaceId,
|
|
3273
3795
|
componentId,
|
|
@@ -3275,13 +3797,19 @@ react_markdown = __toESM(react_markdown);
|
|
|
3275
3797
|
});
|
|
3276
3798
|
}, [
|
|
3277
3799
|
problem,
|
|
3800
|
+
log,
|
|
3801
|
+
place,
|
|
3278
3802
|
runtime,
|
|
3279
3803
|
surface.surfaceId,
|
|
3280
3804
|
componentId
|
|
3281
3805
|
]);
|
|
3282
|
-
if (!dataProps.ok) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
3806
|
+
if (!dataProps.ok) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GuardedNodeFallback, {
|
|
3807
|
+
surfaceId: surface.surfaceId,
|
|
3808
|
+
componentId,
|
|
3809
|
+
runtime,
|
|
3283
3810
|
message: `invalid props (${problem})`,
|
|
3284
|
-
|
|
3811
|
+
slot: failureSlots.fallback(place),
|
|
3812
|
+
revision: properties
|
|
3285
3813
|
});
|
|
3286
3814
|
const Component = definition.component;
|
|
3287
3815
|
const rendered = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
|
|
@@ -3293,10 +3821,8 @@ react_markdown = __toESM(react_markdown);
|
|
|
3293
3821
|
const hasEnvelope = properties.accessibility !== void 0 && definition.accessibility !== "self";
|
|
3294
3822
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GenerativeUINodeContext.Provider, {
|
|
3295
3823
|
value: nodeContext,
|
|
3296
|
-
children: hasEnvelope ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
3297
|
-
|
|
3298
|
-
style: ROOT_STYLE,
|
|
3299
|
-
...(0, _copilotkit_core_generative_ui.wrapperAria)((0, _copilotkit_core_generative_ui.accessibilityAttributes)(accessibility)),
|
|
3824
|
+
children: hasEnvelope ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AccessibilityWrapper, {
|
|
3825
|
+
attributes: (0, _copilotkit_core_generative_ui.wrapperAria)((0, _copilotkit_core_generative_ui.accessibilityAttributes)(accessibility)),
|
|
3300
3826
|
children: rendered
|
|
3301
3827
|
}) : rendered
|
|
3302
3828
|
});
|
|
@@ -3316,39 +3842,18 @@ react_markdown = __toESM(react_markdown);
|
|
|
3316
3842
|
})]
|
|
3317
3843
|
});
|
|
3318
3844
|
}
|
|
3319
|
-
const ContentSchema = zod.z.object({
|
|
3320
|
-
surfaceId: zod.z.string(),
|
|
3321
|
-
target: zod.z.string(),
|
|
3322
|
-
catalogId: zod.z.string(),
|
|
3323
|
-
operations: zod.z.array(zod.z.any()),
|
|
3324
|
-
status: zod.z.enum([
|
|
3325
|
-
"streaming",
|
|
3326
|
-
"ready",
|
|
3327
|
-
"error"
|
|
3328
|
-
]),
|
|
3329
|
-
rejected: zod.z.array(zod.z.object({
|
|
3330
|
-
index: zod.z.number(),
|
|
3331
|
-
reason: zod.z.string()
|
|
3332
|
-
})).default([])
|
|
3333
|
-
}).passthrough();
|
|
3334
3845
|
function GenerativeUIChatActivity({ content, agent }) {
|
|
3335
3846
|
const runtime = useGenerativeUIRuntime();
|
|
3336
3847
|
const threadId = useCopilotChatConfiguration()?.threadId ?? agent?.threadId;
|
|
3337
3848
|
const Wrapper = (0, react.useContext)(GenerativeUIChatSlotContext) ?? DefaultGenerativeUIChatCard;
|
|
3338
|
-
|
|
3339
|
-
(0, react.useLayoutEffect)(() => {
|
|
3340
|
-
if (runtime && threadId) runtime.manager.ingest(threadId, agent?.agentId, content);
|
|
3341
|
-
}, [
|
|
3849
|
+
const { surface, rejected, error } = useGenerativeUIActivitySurface({
|
|
3342
3850
|
runtime,
|
|
3343
3851
|
threadId,
|
|
3344
|
-
agent?.agentId,
|
|
3345
|
-
content
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
const surface = runtime.manager.getSurface(threadId, content.surfaceId) ?? runtime.manager.getFailedSurface(threadId, content.surfaceId);
|
|
3852
|
+
agentId: agent?.agentId,
|
|
3853
|
+
content,
|
|
3854
|
+
target: _copilotkit_shared.GENERATIVE_UI_CHAT_TARGET
|
|
3855
|
+
});
|
|
3349
3856
|
if (!surface) return null;
|
|
3350
|
-
const rejected = [...content.rejected ?? [], ...surface.clientRejected];
|
|
3351
|
-
const error = rejected.length ? new Error(`${rejected.length} UI update(s) could not be shown`, { cause: rejected }) : void 0;
|
|
3352
3857
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Wrapper, {
|
|
3353
3858
|
surfaceId: content.surfaceId,
|
|
3354
3859
|
isStreaming: content.status === "streaming",
|
|
@@ -3360,7 +3865,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
3360
3865
|
function createGenerativeUIActivityRenderer() {
|
|
3361
3866
|
return {
|
|
3362
3867
|
activityType: _copilotkit_shared.GENERATIVE_UI_ACTIVITY_TYPE,
|
|
3363
|
-
content:
|
|
3868
|
+
content: _copilotkit_core_generative_ui.GenerativeUISurfaceContentSchema,
|
|
3364
3869
|
render: GenerativeUIChatActivity
|
|
3365
3870
|
};
|
|
3366
3871
|
}
|