@copilotkit/react-core 1.86.0 → 1.87.1
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/{copilotkit-B1OLgEU8.mjs → copilotkit-BJ-6BoJ_.mjs} +127 -28
- package/dist/copilotkit-BJ-6BoJ_.mjs.map +1 -0
- package/dist/{copilotkit-C7G95NO-.d.mts → copilotkit-BNPEXnEE.d.mts} +8 -3
- package/dist/{copilotkit-C7G95NO-.d.mts.map → copilotkit-BNPEXnEE.d.mts.map} +1 -1
- package/dist/{copilotkit-DwD7D6jJ.d.cts → copilotkit-Bop-sY6y.d.cts} +8 -3
- package/dist/{copilotkit-DwD7D6jJ.d.cts.map → copilotkit-Bop-sY6y.d.cts.map} +1 -1
- package/dist/{copilotkit-Ca0IcTZU.cjs → copilotkit-DFxtDD2N.cjs} +126 -27
- package/dist/copilotkit-DFxtDD2N.cjs.map +1 -0
- package/dist/{hooks-DMSkcNOl.d.cts → hooks-CEFWIeKR.d.cts} +4 -4
- package/dist/{hooks-DMSkcNOl.d.cts.map → hooks-CEFWIeKR.d.cts.map} +1 -1
- package/dist/{hooks-EwGvqYsW.d.mts → hooks-DFgYRjj3.d.mts} +4 -4
- package/dist/{hooks-EwGvqYsW.d.mts.map → hooks-DFgYRjj3.d.mts.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +125 -26
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/generative-ui/native.d.cts +1 -1
- package/dist/v2/generative-ui/native.d.mts +1 -1
- package/dist/v2/generative-ui.d.cts +166 -166
- package/dist/v2/generative-ui.d.cts.map +1 -1
- package/dist/v2/generative-ui.d.mts +166 -166
- package/dist/v2/generative-ui.d.mts.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.d.cts +1 -1
- package/dist/v2/index.d.mts +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +125 -26
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +8 -8
- package/dist/copilotkit-B1OLgEU8.mjs.map +0 -1
- package/dist/copilotkit-Ca0IcTZU.cjs.map +0 -1
|
@@ -27,14 +27,14 @@ declare function childList(description?: string): zod.ZodEffects<zod.ZodUnion<[z
|
|
|
27
27
|
componentId: zod.ZodString;
|
|
28
28
|
path: zod.ZodString;
|
|
29
29
|
}, zod.UnknownKeysParam, zod.ZodTypeAny, {
|
|
30
|
-
path: string;
|
|
31
30
|
componentId: string;
|
|
32
|
-
}, {
|
|
33
31
|
path: string;
|
|
32
|
+
}, {
|
|
34
33
|
componentId: string;
|
|
35
|
-
}>]>, ReactNode, string[] | {
|
|
36
34
|
path: string;
|
|
35
|
+
}>]>, ReactNode, string[] | {
|
|
37
36
|
componentId: string;
|
|
37
|
+
path: string;
|
|
38
38
|
}>;
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region src/v2/generative-ui/hooks.d.ts
|
|
@@ -86,4 +86,4 @@ declare function useGenerativeUIState<UI extends GenerativeUI$1<any>, Key extend
|
|
|
86
86
|
declare function useGenerativeUIFunction<UI extends GenerativeUI$1<any>, Name extends GenerativeUIFunctionName<UI>>(ui: UI, name: Name, handler: (args: GenerativeUIFunctionArgs<UI, Name>) => unknown): void;
|
|
87
87
|
//#endregion
|
|
88
88
|
export { childList as a, child as i, useGenerativeUIState as n, useManagerVersion as r, useGenerativeUIFunction as t };
|
|
89
|
-
//# sourceMappingURL=hooks-
|
|
89
|
+
//# sourceMappingURL=hooks-CEFWIeKR.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks-
|
|
1
|
+
{"version":3,"file":"hooks-CEFWIeKR.d.cts","names":[],"sources":["../src/v2/generative-ui/refs.ts","../src/v2/generative-ui/hooks.ts"],"mappings":";;;;;;;;;;;AAkBA;;;;;;;iBAAgB,KAAA,CAAM,WAAA,YAAoB,GAAA,CAAA,UAAA,CAArB,GAAA,CAAqB,SAAA,EAAA,SAAA;;;;;;;iBAU1B,SAAA,CAAU,WAAA,gBAAoB,UAAA,CAAA,GAAA,CAAA,QAAA,EAAA,GAAA,CAAA,QAAA,CAArB,GAAA,CAAqB,SAAA,eAAA,SAAA;eAAA,GAAA,CAAA,SAAA;;;;;;;;;;;;;;;iBCR9B,iBAAA,CAAkB,OAAA,EAAS,mBAAA;;KAStC,UAAA,YACQ,cAAA,yBACO,mBAAA,CAAoB,EAAA,KACpC,WAAA,CAAY,yBAAA,CAA0B,EAAA,WAAa,GAAA;;;;;;;;;;;;;;ADJvD;;;;;iBCwBgB,oBAAA,YACH,cAAA,yBACO,mBAAA,CAAoB,EAAA,WAAA,CACtC,EAAA,EAAI,EAAA,EAAI,GAAA,EAAK,GAAA,EAAK,KAAA,EAAO,UAAA,CAAW,EAAA,EAAI,GAAA;;;;;;;;;;;;;;;;;;;;;;;iBA0D1B,uBAAA,YACH,cAAA,oBACE,wBAAA,CAAyB,EAAA,EAAA,CAEtC,EAAA,EAAI,EAAA,EACJ,IAAA,EAAM,IAAA,EACN,OAAA,GAAU,IAAA,EAAM,wBAAA,CAAyB,EAAA,EAAI,IAAA"}
|
|
@@ -27,14 +27,14 @@ declare function childList$1(description?: string): zod.ZodEffects<zod.ZodUnion<
|
|
|
27
27
|
componentId: zod.ZodString;
|
|
28
28
|
path: zod.ZodString;
|
|
29
29
|
}, zod.UnknownKeysParam, zod.ZodTypeAny, {
|
|
30
|
-
path: string;
|
|
31
30
|
componentId: string;
|
|
32
|
-
}, {
|
|
33
31
|
path: string;
|
|
32
|
+
}, {
|
|
34
33
|
componentId: string;
|
|
35
|
-
}>]>, ReactNode, string[] | {
|
|
36
34
|
path: string;
|
|
35
|
+
}>]>, ReactNode, string[] | {
|
|
37
36
|
componentId: string;
|
|
37
|
+
path: string;
|
|
38
38
|
}>;
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region src/v2/generative-ui/hooks.d.ts
|
|
@@ -86,4 +86,4 @@ declare function useGenerativeUIState<UI extends GenerativeUI$1<any>, Key extend
|
|
|
86
86
|
declare function useGenerativeUIFunction<UI extends GenerativeUI$1<any>, Name extends GenerativeUIFunctionName<UI>>(ui: UI, name: Name, handler: (args: GenerativeUIFunctionArgs<UI, Name>) => unknown): void;
|
|
87
87
|
//#endregion
|
|
88
88
|
export { childList$1 as a, child$1 as i, useGenerativeUIState as n, useManagerVersion as r, useGenerativeUIFunction as t };
|
|
89
|
-
//# sourceMappingURL=hooks-
|
|
89
|
+
//# sourceMappingURL=hooks-DFgYRjj3.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks-
|
|
1
|
+
{"version":3,"file":"hooks-DFgYRjj3.d.mts","names":[],"sources":["../src/v2/generative-ui/refs.ts","../src/v2/generative-ui/hooks.ts"],"mappings":";;;;;;;;;;;AAkBA;;;;;;;iBAAgB,OAAA,CAAM,WAAA,YAAoB,GAAA,CAAA,UAAA,CAArB,GAAA,CAAqB,SAAA,EAAA,SAAA;;;;;;;iBAU1B,WAAA,CAAU,WAAA,gBAAoB,UAAA,CAAA,GAAA,CAAA,QAAA,EAAA,GAAA,CAAA,QAAA,CAArB,GAAA,CAAqB,SAAA,eAAA,SAAA;eAAA,GAAA,CAAA,SAAA;;;;;;;;;;;;;;;iBCR9B,iBAAA,CAAkB,OAAA,EAAS,mBAAA;;KAStC,UAAA,YACQ,cAAA,yBACO,mBAAA,CAAoB,EAAA,KACpC,WAAA,CAAY,yBAAA,CAA0B,EAAA,WAAa,GAAA;;;;;;;;;;;;;;ADJvD;;;;;iBCwBgB,oBAAA,YACH,cAAA,yBACO,mBAAA,CAAoB,EAAA,WAAA,CACtC,EAAA,EAAI,EAAA,EAAI,GAAA,EAAK,GAAA,EAAK,KAAA,EAAO,UAAA,CAAW,EAAA,EAAI,GAAA;;;;;;;;;;;;;;;;;;;;;;;iBA0D1B,uBAAA,YACH,cAAA,oBACE,wBAAA,CAAyB,EAAA,EAAA,CAEtC,EAAA,EAAI,EAAA,EACJ,IAAA,EAAM,IAAA,EACN,OAAA,GAAU,IAAA,EAAM,wBAAA,CAAyB,EAAA,EAAI,IAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
const require_chat = require('./chat-BnsrQ0VS.cjs');
|
|
5
|
-
const require_copilotkit = require('./copilotkit-
|
|
5
|
+
const require_copilotkit = require('./copilotkit-DFxtDD2N.cjs');
|
|
6
6
|
let react = require("react");
|
|
7
7
|
react = require_chat.__toESM(react);
|
|
8
8
|
let _copilotkit_core = require("@copilotkit/core");
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $f as QueuedInterruptEvent, Gf as useCopilotContext, Hf as CopilotApiConfig, Jf as LangGraphInterruptActionSetter, Kf as CoAgentStateRender, Qf as LangGraphInterruptRenderProps, Uf as CopilotContext, Vf as CoagentInChatRenderFunction, Wf as CopilotContextParams, X as useAgent, Xf as LangGraphInterruptRender, Yf as LangGraphInterruptActionSetterArgs, Zf as LangGraphInterruptRenderHandlerProps, _p as CatchAllFrontendAction, ap as CrewsToolStateItem, bp as RenderFunctionStatus, cp as DocumentPointer, dp as ActionRenderProps, ep as CrewsAgentState, fp as ActionRenderPropsNoArgs, gp as CatchAllActionRenderPropsWait, hp as CatchAllActionRenderProps, ip as CrewsTaskStateItem, lp as Tree, mp as ActionRenderPropsWait, n as defaultCopilotContextCategories, np as CrewsResponseStatus, op as CopilotChatSuggestionConfiguration, pp as ActionRenderPropsNoArgsWait, qf as LangGraphInterruptAction, r as CopilotKitProps, rp as CrewsStateItem, sp as SystemMessageFunction, t as CopilotKit, tp as CrewsResponse, up as TreeNode, vp as FrontendAction, yp as FrontendActionAvailability, yt as useRenderToolCall$1 } from "./copilotkit-
|
|
1
|
+
import { $f as QueuedInterruptEvent, Gf as useCopilotContext, Hf as CopilotApiConfig, Jf as LangGraphInterruptActionSetter, Kf as CoAgentStateRender, Qf as LangGraphInterruptRenderProps, Uf as CopilotContext, Vf as CoagentInChatRenderFunction, Wf as CopilotContextParams, X as useAgent, Xf as LangGraphInterruptRender, Yf as LangGraphInterruptActionSetterArgs, Zf as LangGraphInterruptRenderHandlerProps, _p as CatchAllFrontendAction, ap as CrewsToolStateItem, bp as RenderFunctionStatus, cp as DocumentPointer, dp as ActionRenderProps, ep as CrewsAgentState, fp as ActionRenderPropsNoArgs, gp as CatchAllActionRenderPropsWait, hp as CatchAllActionRenderProps, ip as CrewsTaskStateItem, lp as Tree, mp as ActionRenderPropsWait, n as defaultCopilotContextCategories, np as CrewsResponseStatus, op as CopilotChatSuggestionConfiguration, pp as ActionRenderPropsNoArgsWait, qf as LangGraphInterruptAction, r as CopilotKitProps, rp as CrewsStateItem, sp as SystemMessageFunction, t as CopilotKit, tp as CrewsResponse, up as TreeNode, vp as FrontendAction, yp as FrontendActionAvailability, yt as useRenderToolCall$1 } from "./copilotkit-Bop-sY6y.cjs";
|
|
2
2
|
import "./runtime-context-Da7T5vy4.cjs";
|
|
3
3
|
import "./v2/index.cjs";
|
|
4
4
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $f as QueuedInterruptEvent, Gf as useCopilotContext, Hf as CopilotApiConfig, Jf as LangGraphInterruptActionSetter, Kf as CoAgentStateRender, Qf as LangGraphInterruptRenderProps, Uf as CopilotContext, Vf as CoagentInChatRenderFunction, Wf as CopilotContextParams, X as useAgent, Xf as LangGraphInterruptRender, Yf as LangGraphInterruptActionSetterArgs, Zf as LangGraphInterruptRenderHandlerProps, _p as CatchAllFrontendAction, ap as CrewsToolStateItem, bp as RenderFunctionStatus, cp as DocumentPointer, dp as ActionRenderProps, ep as CrewsAgentState, fp as ActionRenderPropsNoArgs, gp as CatchAllActionRenderPropsWait, hp as CatchAllActionRenderProps, ip as CrewsTaskStateItem, lp as Tree, mp as ActionRenderPropsWait, n as defaultCopilotContextCategories, np as CrewsResponseStatus, op as CopilotChatSuggestionConfiguration, pp as ActionRenderPropsNoArgsWait, qf as LangGraphInterruptAction, r as CopilotKitProps, rp as CrewsStateItem, sp as SystemMessageFunction, t as CopilotKit, tp as CrewsResponse, up as TreeNode, vp as FrontendAction, yp as FrontendActionAvailability, yt as useRenderToolCall$1 } from "./copilotkit-
|
|
1
|
+
import { $f as QueuedInterruptEvent, Gf as useCopilotContext, Hf as CopilotApiConfig, Jf as LangGraphInterruptActionSetter, Kf as CoAgentStateRender, Qf as LangGraphInterruptRenderProps, Uf as CopilotContext, Vf as CoagentInChatRenderFunction, Wf as CopilotContextParams, X as useAgent, Xf as LangGraphInterruptRender, Yf as LangGraphInterruptActionSetterArgs, Zf as LangGraphInterruptRenderHandlerProps, _p as CatchAllFrontendAction, ap as CrewsToolStateItem, bp as RenderFunctionStatus, cp as DocumentPointer, dp as ActionRenderProps, ep as CrewsAgentState, fp as ActionRenderPropsNoArgs, gp as CatchAllActionRenderPropsWait, hp as CatchAllActionRenderProps, ip as CrewsTaskStateItem, lp as Tree, mp as ActionRenderPropsWait, n as defaultCopilotContextCategories, np as CrewsResponseStatus, op as CopilotChatSuggestionConfiguration, pp as ActionRenderPropsNoArgsWait, qf as LangGraphInterruptAction, r as CopilotKitProps, rp as CrewsStateItem, sp as SystemMessageFunction, t as CopilotKit, tp as CrewsResponse, up as TreeNode, vp as FrontendAction, yp as FrontendActionAvailability, yt as useRenderToolCall$1 } from "./copilotkit-BNPEXnEE.mjs";
|
|
2
2
|
import "./runtime-context-B4fKyzo6.mjs";
|
|
3
3
|
import "./v2/index.mjs";
|
|
4
4
|
import React, { ReactNode, RefObject, SetStateAction } from "react";
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { $ as INTERRUPT_EVENT_NAME, Mt as useRenderToolCall$1, Q as useInterrupt, a as ThreadsProvider, at as useAgent, c as CoAgentStateRendersProvider, d as shouldShowDevConsole, et as useConfigureSuggestions, f as useToast, ft as useFrontendTool$1, g as useCopilotContext, gt as useCopilotKit, h as CopilotContext, i as ThreadsContext, l as useCoAgentStateRenders, m as useCopilotMessagesContext, mt as useRenderCustomMessages, n as defaultCopilotContextCategories, o as useThreads, ot as useHumanInTheLoop$1, p as CopilotMessagesContext, r as CoAgentStateRenderBridge, s as CoAgentStateRendersContext, t as CopilotKit, tt as useSuggestions, u as useAsyncCallback } from "./copilotkit-
|
|
3
|
+
import { $ as INTERRUPT_EVENT_NAME, Mt as useRenderToolCall$1, Q as useInterrupt, a as ThreadsProvider, at as useAgent, c as CoAgentStateRendersProvider, d as shouldShowDevConsole, et as useConfigureSuggestions, f as useToast, ft as useFrontendTool$1, g as useCopilotContext, gt as useCopilotKit, h as CopilotContext, i as ThreadsContext, l as useCoAgentStateRenders, m as useCopilotMessagesContext, mt as useRenderCustomMessages, n as defaultCopilotContextCategories, o as useThreads, ot as useHumanInTheLoop$1, p as CopilotMessagesContext, r as CoAgentStateRenderBridge, s as CoAgentStateRendersContext, t as CopilotKit, tt as useSuggestions, u as useAsyncCallback } from "./copilotkit-BJ-6BoJ_.mjs";
|
|
4
4
|
import { A as useCopilotChatConfiguration, E as defineToolCallRenderer } from "./chat-IWySXWXP.mjs";
|
|
5
5
|
import React, { Fragment, createElement, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
6
6
|
import { CopilotKitCoreRuntimeConnectionStatus, ToolCallStatus, ɵisHttpAgent } from "@copilotkit/core";
|
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.87.1";
|
|
629
629
|
|
|
630
630
|
//#endregion
|
|
631
631
|
//#region src/v2/components/CopilotKitInspector.tsx
|
|
@@ -1821,7 +1821,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
1821
1821
|
function warnAboutUnpaintedSurfaces(grouped) {
|
|
1822
1822
|
for (const [surfaceId, operations] of grouped) {
|
|
1823
1823
|
if (surfaceHasRenderableContent(operations)) continue;
|
|
1824
|
-
const cause = operations.
|
|
1824
|
+
const cause = operations.flatMap(getOperationComponents).length === 0 ? "no updateComponents operation arrived, so the surface was never given anything to draw" : "its components address their values by \"path\" and no updateDataModel carried a non-empty value, so every bound component drew empty";
|
|
1825
1825
|
console.warn(`[CopilotKit] A2UI surface "${surfaceId}" received operations and never painted after ${String(PAINT_FALLBACK_MS)}ms: ${cause}. Operations received: ${describeOperationKinds(operations)}. The payload was accepted, so check what the agent sent rather than the client wiring. This warning is development-only.`);
|
|
1826
1826
|
}
|
|
1827
1827
|
}
|
|
@@ -1834,13 +1834,9 @@ react_markdown = __toESM(react_markdown);
|
|
|
1834
1834
|
*/
|
|
1835
1835
|
function describeComponentIds(operations) {
|
|
1836
1836
|
const ids = [];
|
|
1837
|
-
for (const operation of operations) {
|
|
1838
|
-
const
|
|
1839
|
-
if (!
|
|
1840
|
-
for (const component of components) {
|
|
1841
|
-
const id = component?.id;
|
|
1842
|
-
if (typeof id === "string" && !ids.includes(id)) ids.push(id);
|
|
1843
|
-
}
|
|
1837
|
+
for (const operation of operations) for (const component of getOperationComponents(operation)) {
|
|
1838
|
+
const id = component?.id;
|
|
1839
|
+
if (typeof id === "string" && !ids.includes(id)) ids.push(id);
|
|
1844
1840
|
}
|
|
1845
1841
|
return ids.length === 0 ? "none" : ids.map((id) => `"${id}"`).join(", ");
|
|
1846
1842
|
}
|
|
@@ -1867,9 +1863,9 @@ react_markdown = __toESM(react_markdown);
|
|
|
1867
1863
|
*/
|
|
1868
1864
|
function warnAboutUnresolvedRoot(surfaceId, operations, surface) {
|
|
1869
1865
|
if (surface?.componentsModel?.get?.(_copilotkit_a2ui_renderer.ROOT_COMPONENT_ID)) return;
|
|
1870
|
-
const
|
|
1871
|
-
if (
|
|
1872
|
-
const cause =
|
|
1866
|
+
const components = operations.flatMap(getOperationComponents);
|
|
1867
|
+
if (components.length === 0) return;
|
|
1868
|
+
const cause = components.some((c) => c?.id === _copilotkit_a2ui_renderer.ROOT_COMPONENT_ID) ? `a component with id "${_copilotkit_a2ui_renderer.ROOT_COMPONENT_ID}" WAS sent, so the components did not reach the surface's model — check for an A2UI render error above, or a catalog that took none of them` : `the components it received are named ${describeComponentIds(operations)}, and none of them is "${_copilotkit_a2ui_renderer.ROOT_COMPONENT_ID}" — rename the entry-point component to "${_copilotkit_a2ui_renderer.ROOT_COMPONENT_ID}", and make every other component reachable from it through child/children`;
|
|
1873
1869
|
console.warn(`[CopilotKit] A2UI surface "${surfaceId}" has no "${_copilotkit_a2ui_renderer.ROOT_COMPONENT_ID}" component ${String(PAINT_FALLBACK_MS)}ms after its last operations were processed, so it is showing the placeholder for a component that has not arrived yet and will keep showing it: ${cause}. Operations received: ${describeOperationKinds(operations)}. This warning is development-only.`);
|
|
1874
1870
|
}
|
|
1875
1871
|
function createA2UIMessageRenderer(options) {
|
|
@@ -2035,7 +2031,10 @@ react_markdown = __toESM(react_markdown);
|
|
|
2035
2031
|
surfaceId,
|
|
2036
2032
|
operations,
|
|
2037
2033
|
onReady
|
|
2038
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(A2UISurfaceOrError, {
|
|
2034
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(A2UISurfaceOrError, {
|
|
2035
|
+
surfaceId,
|
|
2036
|
+
onReady
|
|
2037
|
+
})]
|
|
2039
2038
|
})
|
|
2040
2039
|
});
|
|
2041
2040
|
}
|
|
@@ -2043,15 +2042,60 @@ react_markdown = __toESM(react_markdown);
|
|
|
2043
2042
|
* Renders the A2UI surface, or an error message if processing failed.
|
|
2044
2043
|
* Must be a child of A2UIProvider to access the error state.
|
|
2045
2044
|
*/
|
|
2046
|
-
function A2UISurfaceOrError({ surfaceId }) {
|
|
2045
|
+
function A2UISurfaceOrError({ surfaceId, onReady }) {
|
|
2047
2046
|
const error = (0, _copilotkit_a2ui_renderer.useA2UIError)();
|
|
2048
|
-
|
|
2047
|
+
(0, react.useEffect)(() => {
|
|
2048
|
+
if (error) onReady?.();
|
|
2049
|
+
}, [error, onReady]);
|
|
2050
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [error && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2051
|
+
role: "alert",
|
|
2049
2052
|
className: "cpk:rounded-lg cpk:border cpk:border-red-200 cpk:bg-red-50 cpk:p-3 cpk:text-sm cpk:text-red-700",
|
|
2050
2053
|
children: ["A2UI render error: ", error]
|
|
2051
|
-
})
|
|
2052
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_a2ui_renderer.A2UIRenderer, {
|
|
2054
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_a2ui_renderer.A2UIRenderer, {
|
|
2053
2055
|
surfaceId,
|
|
2054
2056
|
className: "cpk:flex cpk:flex-1"
|
|
2057
|
+
})] });
|
|
2058
|
+
}
|
|
2059
|
+
/**
|
|
2060
|
+
* Full activity snapshots repeat creation. Native 1.0 can carry the current
|
|
2061
|
+
* components and data inline there, so replay changed initialization data and
|
|
2062
|
+
* components as updates for an existing surface. Compare against the previous
|
|
2063
|
+
* wire snapshot, rather than the SDK's mutable data model, to retain local edits.
|
|
2064
|
+
* Retain invalid or version-changing creates for the
|
|
2065
|
+
* provider/SDK to reject, instead of sanitizing them while replaying.
|
|
2066
|
+
*/
|
|
2067
|
+
function replaySnapshotOperations(operations, existing, previousOperations) {
|
|
2068
|
+
if (!existing) return operations;
|
|
2069
|
+
let nativeSurfaceDeleted = false;
|
|
2070
|
+
return operations.flatMap((operation) => {
|
|
2071
|
+
if (operation?.version === "1.0" && operation.deleteSurface?.surfaceId === existing.id) nativeSurfaceDeleted = true;
|
|
2072
|
+
if (nativeSurfaceDeleted) return [operation];
|
|
2073
|
+
if (!operation?.createSurface) return [operation];
|
|
2074
|
+
const version = String(operation.version ?? "v0.9").replace(/^v/, "");
|
|
2075
|
+
if (version !== String(existing.protocolVersion).replace(/^v/, "")) return [operation];
|
|
2076
|
+
if (version === "0.9") return [];
|
|
2077
|
+
if (operation.version !== "1.0") return [operation];
|
|
2078
|
+
const validation = _copilotkit_a2ui_renderer.CreateSurfaceMessageSchemaV1.safeParse(operation);
|
|
2079
|
+
if (!validation.success) return [operation];
|
|
2080
|
+
const create = validation.data.createSurface;
|
|
2081
|
+
if (create.catalogId !== void 0 && create.catalogId !== existing.catalog?.id) return [operation];
|
|
2082
|
+
const updates = [];
|
|
2083
|
+
const previousCreate = previousOperations.find((previous) => previous?.version === "1.0" && previous.createSurface?.surfaceId === create.surfaceId)?.createSurface;
|
|
2084
|
+
if (Object.hasOwn(create, "dataModel") && (!previousCreate || !Object.hasOwn(previousCreate, "dataModel") || JSON.stringify(create.dataModel) !== JSON.stringify(previousCreate.dataModel))) updates.push({
|
|
2085
|
+
version: "1.0",
|
|
2086
|
+
updateDataModel: {
|
|
2087
|
+
surfaceId: create.surfaceId,
|
|
2088
|
+
value: create.dataModel
|
|
2089
|
+
}
|
|
2090
|
+
});
|
|
2091
|
+
if (Object.hasOwn(create, "components")) updates.push({
|
|
2092
|
+
version: "1.0",
|
|
2093
|
+
updateComponents: {
|
|
2094
|
+
surfaceId: create.surfaceId,
|
|
2095
|
+
components: create.components
|
|
2096
|
+
}
|
|
2097
|
+
});
|
|
2098
|
+
return updates;
|
|
2055
2099
|
});
|
|
2056
2100
|
}
|
|
2057
2101
|
/**
|
|
@@ -2064,10 +2108,11 @@ react_markdown = __toESM(react_markdown);
|
|
|
2064
2108
|
(0, react.useEffect)(() => {
|
|
2065
2109
|
const hash = JSON.stringify(operations);
|
|
2066
2110
|
if (hash === lastHashRef.current) return;
|
|
2111
|
+
const previousOperations = lastHashRef.current ? JSON.parse(lastHashRef.current) : [];
|
|
2067
2112
|
lastHashRef.current = hash;
|
|
2068
|
-
const ops = getSurface(surfaceId)
|
|
2113
|
+
const ops = replaySnapshotOperations(operations, getSurface(surfaceId), previousOperations);
|
|
2069
2114
|
processMessages(ops.map(stripRoutingSurfaceId));
|
|
2070
|
-
if (onReady && surfaceHasRenderableContent(operations)) onReady();
|
|
2115
|
+
if (onReady && getSurface(surfaceId)?.componentsModel.get(_copilotkit_a2ui_renderer.ROOT_COMPONENT_ID) && surfaceHasRenderableContent(operations)) onReady();
|
|
2071
2116
|
if (!IS_DEVELOPMENT) return;
|
|
2072
2117
|
if (!getSurface(surfaceId)) {
|
|
2073
2118
|
const missingSurfaceCheck = setTimeout(() => {
|
|
@@ -2097,15 +2142,26 @@ react_markdown = __toESM(react_markdown);
|
|
|
2097
2142
|
* arrival rather than a fixed delay. (OSS-162)
|
|
2098
2143
|
*/
|
|
2099
2144
|
function surfaceHasRenderableContent(operations) {
|
|
2100
|
-
const
|
|
2101
|
-
if (!
|
|
2102
|
-
|
|
2145
|
+
const components = operations.flatMap(getOperationComponents);
|
|
2146
|
+
if (!components.length) return false;
|
|
2147
|
+
const serialized = JSON.stringify(components);
|
|
2148
|
+
if (!(serialized.includes("\"path\"") || serialized.includes("\"@path\""))) return true;
|
|
2103
2149
|
return operations.some((o) => {
|
|
2104
|
-
const v = o?.updateDataModel?.value;
|
|
2150
|
+
const v = o?.updateDataModel?.value ?? (o?.version === "1.0" ? o?.createSurface?.dataModel : void 0);
|
|
2151
|
+
if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") {
|
|
2152
|
+
const path = o?.updateDataModel?.path ?? "/";
|
|
2153
|
+
const key = o?.version === "1.0" ? "@path" : "path";
|
|
2154
|
+
return v !== "" && serialized.includes(JSON.stringify({ [key]: path }));
|
|
2155
|
+
}
|
|
2105
2156
|
if (!v || typeof v !== "object") return false;
|
|
2106
2157
|
return Object.values(v).some((x) => Array.isArray(x) ? x.length > 0 : x !== null && x !== void 0 && x !== "");
|
|
2107
2158
|
});
|
|
2108
2159
|
}
|
|
2160
|
+
/** Component definitions can arrive in an update or a native inline create. */
|
|
2161
|
+
function getOperationComponents(operation) {
|
|
2162
|
+
const components = operation?.updateComponents?.components ?? (operation?.version === "1.0" ? operation?.createSurface?.components : void 0);
|
|
2163
|
+
return Array.isArray(components) ? components : [];
|
|
2164
|
+
}
|
|
2109
2165
|
const V0_9_ACTION_KEYS = [
|
|
2110
2166
|
"createSurface",
|
|
2111
2167
|
"updateComponents",
|
|
@@ -2128,7 +2184,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
2128
2184
|
* message, otherwise the operation unchanged.
|
|
2129
2185
|
*/
|
|
2130
2186
|
function stripRoutingSurfaceId(operation) {
|
|
2131
|
-
if (!operation || typeof operation !== "object" || !("surfaceId" in operation) || !V0_9_ACTION_KEYS.some((key) => key in operation)) return operation;
|
|
2187
|
+
if (!operation || typeof operation !== "object" || !(operation.version === void 0 || operation.version === "v0.9") || !("surfaceId" in operation) || !V0_9_ACTION_KEYS.some((key) => key in operation)) return operation;
|
|
2132
2188
|
const { surfaceId: _routingId, ...message } = operation;
|
|
2133
2189
|
return message;
|
|
2134
2190
|
}
|
|
@@ -2201,6 +2257,47 @@ react_markdown = __toESM(react_markdown);
|
|
|
2201
2257
|
return null;
|
|
2202
2258
|
}
|
|
2203
2259
|
|
|
2260
|
+
//#endregion
|
|
2261
|
+
//#region src/v2/a2ui/generation-guidelines.ts
|
|
2262
|
+
/** Native 1.0 tool guidance. Structural template paths retain their own syntax. */
|
|
2263
|
+
const A2UI_V1_GENERATION_GUIDELINES = `Generate A2UI 1.0 JSON.
|
|
2264
|
+
|
|
2265
|
+
Call render_a2ui with a unique surfaceId, the required components array, and optional
|
|
2266
|
+
root data object. Use only component names, properties and functions declared in
|
|
2267
|
+
the supplied catalog. Match its protocolVersion, catalogId and schemas.
|
|
2268
|
+
|
|
2269
|
+
Every component has a unique id and a component type. Exactly one component has
|
|
2270
|
+
id="root", the surface entry point. All other components must be reachable from
|
|
2271
|
+
root through child/children; never reference the same component as its own child,
|
|
2272
|
+
and never create a cycle.
|
|
2273
|
+
|
|
2274
|
+
Use literal values unless the property's catalog schema permits a dynamic value.
|
|
2275
|
+
Native value binding uses { "@path": "/form/name" }. A plain property schema does
|
|
2276
|
+
not accept a binding object. Pre-fill editable values via the data argument:
|
|
2277
|
+
"data": { "form": { "name": "Alice" } }
|
|
2278
|
+
"value": { "@path": "/form/name" }
|
|
2279
|
+
|
|
2280
|
+
Native function expressions use { "@call": "functionName", "args": { ... } },
|
|
2281
|
+
with only the parameters declared by the catalog; do not add returnType.
|
|
2282
|
+
|
|
2283
|
+
REPEATING CONTENT uses a structural children format, distinct from value binding:
|
|
2284
|
+
children: { componentId: "card-id", path: "/items" }
|
|
2285
|
+
The structural key remains path. Initialize its data array with real items before
|
|
2286
|
+
expecting a visible list. Components inside a template use relative value bindings:
|
|
2287
|
+
"text": { "@path": "name" }
|
|
2288
|
+
An absolute binding such as { "@path": "/name" } reads from the root instead.
|
|
2289
|
+
|
|
2290
|
+
Buttons send nested event actions, with bound context to capture edited values:
|
|
2291
|
+
"action": { "event": { "name": "submit", "context": { "name": { "@path": "/form/name" } } } }
|
|
2292
|
+
Local function actions use { "functionCall": { "@call": "functionName", "args": { ... } } }.
|
|
2293
|
+
Do not rename literal objects' path keys: only @path denotes native value binding.
|
|
2294
|
+
Keep an existing surface's protocol and catalog when updating it; create a new
|
|
2295
|
+
surface to use a different protocol.`;
|
|
2296
|
+
/** Preserve legacy prompt text exactly unless the selected catalog opts into 1.0. */
|
|
2297
|
+
function a2uiGenerationGuidelines(protocolVersion) {
|
|
2298
|
+
return protocolVersion === "1.0" ? A2UI_V1_GENERATION_GUIDELINES : _copilotkit_shared.A2UI_DEFAULT_GENERATION_GUIDELINES;
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2204
2301
|
//#endregion
|
|
2205
2302
|
//#region src/v2/a2ui/A2UICatalogContext.tsx
|
|
2206
2303
|
/**
|
|
@@ -2220,6 +2317,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
2220
2317
|
const capabilitiesValue = (0, react.useMemo)(() => (0, _copilotkit_a2ui_renderer.buildCatalogContextValue)(catalog, { includeSchema: includeSchema !== false }), [catalog, includeSchema]);
|
|
2221
2318
|
const schemaValue = (0, react.useMemo)(() => includeSchema !== false ? JSON.stringify((0, _copilotkit_a2ui_renderer.extractCatalogComponentSchemas)(catalog)) : null, [catalog, includeSchema]);
|
|
2222
2319
|
const a2uiAgentsKey = copilotkit?.a2uiAgents?.join(",");
|
|
2320
|
+
const generationGuidelines = a2uiGenerationGuidelines(catalog?.protocolVersion);
|
|
2223
2321
|
(0, react.useLayoutEffect)(() => {
|
|
2224
2322
|
if (!copilotkit) return;
|
|
2225
2323
|
const agentIds = copilotkit.a2uiAgents;
|
|
@@ -2238,7 +2336,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
2238
2336
|
}));
|
|
2239
2337
|
ids.push(copilotkit.addContext({
|
|
2240
2338
|
description: "A2UI generation guidelines — protocol rules, tool arguments, path rules, data model format, and form/two-way-binding instructions.",
|
|
2241
|
-
value:
|
|
2339
|
+
value: generationGuidelines,
|
|
2242
2340
|
...scope
|
|
2243
2341
|
}));
|
|
2244
2342
|
ids.push(copilotkit.addContext({
|
|
@@ -2254,7 +2352,8 @@ react_markdown = __toESM(react_markdown);
|
|
|
2254
2352
|
copilotkit,
|
|
2255
2353
|
capabilitiesValue,
|
|
2256
2354
|
schemaValue,
|
|
2257
|
-
a2uiAgentsKey
|
|
2355
|
+
a2uiAgentsKey,
|
|
2356
|
+
generationGuidelines
|
|
2258
2357
|
]);
|
|
2259
2358
|
return null;
|
|
2260
2359
|
}
|