@copilotkit/react-core 0.0.0-feat-use-frontend-component-20260219223758 → 0.0.0-feat-a2ui-default-renderer-20260305151820

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/CHANGELOG.md CHANGED
@@ -1,17 +1,152 @@
1
1
  # ui
2
2
 
3
- ## 0.0.0-feat-use-frontend-component-20260219223758
3
+ ## 0.0.0-feat-a2ui-default-renderer-20260305151820
4
4
 
5
5
  ### Patch Changes
6
6
 
7
+ - 2ae1705: feat: enable mcp and a2ui middleware directly from copilotkit runtime
8
+ - Updated dependencies [2ae1705]
9
+ - @copilotkit/shared@0.0.0-feat-a2ui-default-renderer-20260305151820
10
+ - @copilotkitnext/core@0.0.0-feat-a2ui-default-renderer-20260305151820
11
+ - @copilotkitnext/react@0.0.0-feat-a2ui-default-renderer-20260305151820
12
+ - @copilotkit/runtime-client-gql@0.0.0-feat-a2ui-default-renderer-20260305151820
13
+ - @copilotkit/a2ui-renderer@0.0.0-feat-a2ui-default-renderer-20260305151820
14
+
15
+ ## 1.52.1
16
+
17
+ ### Patch Changes
18
+
19
+ - b555ac4: fix(react-core): allow overriding useSingleEndpoint in CopilotKit provider
20
+
21
+ The V1 `<CopilotKit>` provider previously hardcoded `useSingleEndpoint={true}` when wrapping the V2 provider, preventing users from opting into REST transport mode. The prop is now passed through from user config, defaulting to `true` to preserve backward compatibility.
22
+
23
+ - Updated dependencies [bbdf67d]
24
+ - @copilotkitnext/react@1.52.1
25
+ - @copilotkit/runtime-client-gql@1.52.1
26
+ - @copilotkit/shared@1.52.1
27
+ - @copilotkitnext/core@1.52.1
28
+
29
+ ## 1.52.1-next.1
30
+
31
+ ### Patch Changes
32
+
33
+ - b555ac4: fix(react-core): allow overriding useSingleEndpoint in CopilotKit provider
34
+
35
+ The V1 `<CopilotKit>` provider previously hardcoded `useSingleEndpoint={true}` when wrapping the V2 provider, preventing users from opting into REST transport mode. The prop is now passed through from user config, defaulting to `true` to preserve backward compatibility.
36
+ - @copilotkit/runtime-client-gql@1.52.1-next.1
37
+ - @copilotkit/shared@1.52.1-next.1
38
+ - @copilotkitnext/core@1.52.1-next.1
39
+ - @copilotkitnext/react@1.52.1-next.1
40
+
41
+ ## 1.52.1-next.0
42
+
43
+ ### Patch Changes
44
+
45
+ - Updated dependencies [bbdf67d]
46
+ - @copilotkitnext/react@1.52.1-next.0
47
+ - @copilotkit/runtime-client-gql@1.52.1-next.0
48
+ - @copilotkit/shared@1.52.1-next.0
49
+ - @copilotkitnext/core@1.52.1-next.0
50
+
51
+ ## 1.52.0
52
+
53
+ ### Minor Changes
54
+
55
+ - 6dd6c84: Adding new v2 features:
56
+ - useComponent
57
+ - useRenderTool
58
+ - useDefaultRenderTool
59
+
60
+ Also, fixing issues with styles not being
61
+ properly scoped for tailwind.
62
+
63
+ ### Patch Changes
64
+
65
+ - d77f347: Added in the useInterrupt hook
66
+ - 2007f8b: feat: useComponent improvements
7
67
  - ef0f539: Add reasoning support and default components for reasoning messages
8
68
  - 412965a: Introducing available prop to useFrontendTool()
9
- - Updated dependencies [ea7c2f7]
69
+ - 5f941db: Prevent CPK styles from polluting user app
70
+ - Updated dependencies [593859f]
71
+ - Updated dependencies [d77f347]
72
+ - Updated dependencies [2007f8b]
10
73
  - Updated dependencies [ef0f539]
11
- - @copilotkitnext/react@0.0.0-feat-use-frontend-component-20260219223758
12
- - @copilotkit/shared@0.0.0-feat-use-frontend-component-20260219223758
13
- - @copilotkitnext/core@0.0.0-feat-use-frontend-component-20260219223758
14
- - @copilotkit/runtime-client-gql@0.0.0-feat-use-frontend-component-20260219223758
74
+ - Updated dependencies [942d397]
75
+ - @copilotkitnext/react@1.52.0
76
+ - @copilotkitnext/core@1.52.0
77
+ - @copilotkit/shared@1.52.0
78
+ - @copilotkit/runtime-client-gql@1.52.0
79
+
80
+ ## 1.52.0-next.8
81
+
82
+ ### Patch Changes
83
+
84
+ - Updated dependencies [942d397]
85
+ - @copilotkitnext/react@1.52.0-next.8
86
+ - @copilotkit/runtime-client-gql@1.52.0-next.8
87
+ - @copilotkit/shared@1.52.0-next.8
88
+ - @copilotkitnext/core@1.52.0-next.8
89
+
90
+ ## 1.52.0-next.7
91
+
92
+ ### Patch Changes
93
+
94
+ - d77f347: Added in the useInterrupt hook
95
+ - Updated dependencies [d77f347]
96
+ - @copilotkitnext/react@1.52.0-next.7
97
+ - @copilotkitnext/core@1.52.0-next.7
98
+ - @copilotkit/runtime-client-gql@1.52.0-next.7
99
+ - @copilotkit/shared@1.52.0-next.7
100
+
101
+ ## 1.52.0-next.6
102
+
103
+ ### Patch Changes
104
+
105
+ - 2007f8b: feat: useComponent improvements
106
+ - 5f941db: Prevent CPK styles from polluting user app
107
+ - Updated dependencies [2007f8b]
108
+ - @copilotkitnext/react@1.52.0-next.6
109
+ - @copilotkit/runtime-client-gql@1.52.0-next.6
110
+ - @copilotkit/shared@1.52.0-next.6
111
+ - @copilotkitnext/core@1.52.0-next.6
112
+
113
+ ## 1.52.0-next.5
114
+
115
+ ### Minor Changes
116
+
117
+ - 6dd6c84: Adding new v2 features:
118
+ - useComponent
119
+ - useRenderTool
120
+ - useDefaultRenderTool
121
+
122
+ Also, fixing issues with styles not being
123
+ properly scoped for tailwind.
124
+
125
+ ### Patch Changes
126
+
127
+ - @copilotkit/runtime-client-gql@1.52.0-next.5
128
+ - @copilotkit/shared@1.52.0-next.5
129
+ - @copilotkitnext/core@1.52.0-next.5
130
+ - @copilotkitnext/react@1.52.0-next.5
131
+
132
+ ## 1.51.5-next.4
133
+
134
+ ### Patch Changes
135
+
136
+ - @copilotkit/runtime-client-gql@1.51.5-next.4
137
+ - @copilotkit/shared@1.51.5-next.4
138
+ - @copilotkitnext/core@1.51.5-next.4
139
+ - @copilotkitnext/react@1.51.5-next.4
140
+
141
+ ## 1.51.5-next.3
142
+
143
+ ### Patch Changes
144
+
145
+ - Updated dependencies [593859f]
146
+ - @copilotkitnext/react@1.51.5-next.3
147
+ - @copilotkit/runtime-client-gql@1.51.5-next.3
148
+ - @copilotkit/shared@1.51.5-next.3
149
+ - @copilotkitnext/core@1.51.5-next.3
15
150
 
16
151
  ## 1.51.5-next.2
17
152
 
package/dist/index.cjs CHANGED
@@ -31,6 +31,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
31
31
  let react = require("react");
32
32
  react = __toESM(react);
33
33
  let _copilotkitnext_react = require("@copilotkitnext/react");
34
+ let _copilotkit_a2ui_renderer = require("@copilotkit/a2ui-renderer");
34
35
  let _copilotkit_shared = require("@copilotkit/shared");
35
36
  let react_dom = require("react-dom");
36
37
  let react_jsx_runtime = require("react/jsx-runtime");
@@ -1585,6 +1586,7 @@ function CopilotKit({ children, ...props }) {
1585
1586
  const showInspector = shouldShowDevConsole(props.enableInspector);
1586
1587
  const publicApiKey = props.publicApiKey || props.publicLicenseKey;
1587
1588
  const renderArr = (0, react.useMemo)(() => [{ render: CoAgentStateRenderBridge }], []);
1589
+ const defaultA2UIRendererFactory = (0, react.useCallback)(() => (0, _copilotkit_a2ui_renderer.createA2UIMessageRenderer)({ theme: _copilotkit_a2ui_renderer.viewerTheme }), []);
1588
1590
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToastProvider, {
1589
1591
  enabled,
1590
1592
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotErrorBoundary, {
@@ -1593,10 +1595,11 @@ function CopilotKit({ children, ...props }) {
1593
1595
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThreadsProvider, {
1594
1596
  threadId: props.threadId,
1595
1597
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkitnext_react.CopilotKitProvider, {
1598
+ renderActivityMessages: [defaultA2UIRendererFactory()],
1596
1599
  ...props,
1597
1600
  showDevConsole: showInspector,
1598
1601
  renderCustomMessages: renderArr,
1599
- useSingleEndpoint: true,
1602
+ useSingleEndpoint: props.useSingleEndpoint ?? true,
1600
1603
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitInternal, {
1601
1604
  ...props,
1602
1605
  children
@@ -2021,118 +2024,6 @@ function validateProps(props) {
2021
2024
  if (cloudFeatures.length > 0 && !hasApiKey) throw new _copilotkit_shared.MissingPublicApiKeyError(`Missing required prop: 'publicApiKey' or 'publicLicenseKey' to use cloud features: ${cloudFeatures.map(formatFeatureName).join(", ")}`);
2022
2025
  }
2023
2026
 
2024
- //#endregion
2025
- //#region src/hooks/use-agent-nodename.ts
2026
- function useAgentNodeName(agentName) {
2027
- const { agent } = (0, _copilotkitnext_react.useAgent)({ agentId: agentName });
2028
- const nodeNameRef = (0, react.useRef)("start");
2029
- (0, react.useEffect)(() => {
2030
- if (!agent) return;
2031
- const subscription = agent.subscribe({
2032
- onStepStartedEvent: ({ event }) => {
2033
- nodeNameRef.current = event.stepName;
2034
- },
2035
- onRunStartedEvent: () => {
2036
- nodeNameRef.current = "start";
2037
- },
2038
- onRunFinishedEvent: () => {
2039
- nodeNameRef.current = "end";
2040
- }
2041
- });
2042
- return () => {
2043
- subscription.unsubscribe();
2044
- };
2045
- }, [agent]);
2046
- return nodeNameRef.current;
2047
- }
2048
-
2049
- //#endregion
2050
- //#region src/hooks/use-langgraph-interrupt-render.ts
2051
- const InterruptRenderer = ({ event, result, render, resolve }) => {
2052
- return render({
2053
- event,
2054
- result,
2055
- resolve
2056
- });
2057
- };
2058
- function useLangGraphInterruptRender(agent) {
2059
- const { interruptActions, agentSession, threadId, interruptEventQueue, addInterruptEvent, resolveInterruptEvent } = useCopilotContext();
2060
- const nodeName = useAgentNodeName((0, _copilotkitnext_react.useCopilotChatConfiguration)()?.agentId ?? "default");
2061
- (0, react.useEffect)(() => {
2062
- if (!agent) return;
2063
- let localInterrupt = null;
2064
- const { unsubscribe } = agent.subscribe({
2065
- onCustomEvent: ({ event }) => {
2066
- if (event.name === "on_interrupt") {
2067
- const eventData = {
2068
- name: _copilotkit_runtime_client_gql.MetaEventName.LangGraphInterruptEvent,
2069
- type: event.type,
2070
- value: (0, _copilotkit_shared.parseJson)(event.value, event.value)
2071
- };
2072
- localInterrupt = {
2073
- eventId: (0, _copilotkit_shared.dataToUUID)(eventData, "interruptEvents"),
2074
- threadId,
2075
- event: eventData
2076
- };
2077
- }
2078
- },
2079
- onRunStartedEvent: () => {
2080
- localInterrupt = null;
2081
- },
2082
- onRunFinalized: () => {
2083
- if (localInterrupt) {
2084
- addInterruptEvent(localInterrupt);
2085
- localInterrupt = null;
2086
- }
2087
- }
2088
- });
2089
- return () => {
2090
- unsubscribe();
2091
- };
2092
- }, [agent, threadId]);
2093
- const handleResolve = (0, react.useCallback)((eventId, response) => {
2094
- agent?.runAgent({ forwardedProps: { command: { resume: response } } });
2095
- resolveInterruptEvent(threadId, eventId, response ?? "");
2096
- }, [agent, threadId]);
2097
- return (0, react.useMemo)(() => {
2098
- const currentQueuedEvent = (interruptEventQueue[threadId] || []).find((qe) => !qe.event.response);
2099
- if (!currentQueuedEvent || !agentSession) return null;
2100
- const matchingAction = Object.values(interruptActions).find((action) => {
2101
- if (!action.enabled) return true;
2102
- return action.enabled({
2103
- eventValue: currentQueuedEvent.event.value,
2104
- agentMetadata: {
2105
- ...agentSession,
2106
- nodeName
2107
- }
2108
- });
2109
- });
2110
- if (!matchingAction) return null;
2111
- const { render, handler } = matchingAction;
2112
- const resolveInterrupt = (response) => {
2113
- handleResolve(currentQueuedEvent.eventId, response);
2114
- };
2115
- let result = null;
2116
- if (handler) result = handler({
2117
- event: currentQueuedEvent.event,
2118
- resolve: resolveInterrupt
2119
- });
2120
- if (!render) return null;
2121
- return react.default.createElement(InterruptRenderer, {
2122
- event: currentQueuedEvent.event,
2123
- result,
2124
- render,
2125
- resolve: resolveInterrupt
2126
- });
2127
- }, [
2128
- interruptActions,
2129
- interruptEventQueue,
2130
- threadId,
2131
- agentSession,
2132
- handleResolve
2133
- ]);
2134
- }
2135
-
2136
2027
  //#endregion
2137
2028
  //#region src/hooks/use-lazy-tool-renderer.tsx
2138
2029
  function useLazyToolRenderer() {
@@ -2182,7 +2073,14 @@ function useCopilotChatInternal({ suggestions, onInProgress, onSubmitMessage, on
2182
2073
  (0, react.useEffect)(() => {
2183
2074
  onInProgress?.(Boolean(agent?.isRunning));
2184
2075
  }, [agent?.isRunning, onInProgress]);
2185
- const interrupt = useLangGraphInterruptRender(agent);
2076
+ const [interrupt, setInterrupt] = (0, react.useState)(null);
2077
+ (0, react.useEffect)(() => {
2078
+ setInterrupt(copilotkit.interruptElement);
2079
+ const subscription = copilotkit.subscribe({ onInterruptElementChanged: ({ interruptElement }) => {
2080
+ setInterrupt(interruptElement);
2081
+ } });
2082
+ return () => subscription.unsubscribe();
2083
+ }, [copilotkit]);
2186
2084
  const reset = () => {
2187
2085
  agent?.setMessages([]);
2188
2086
  agent?.setState(null);
@@ -3311,6 +3209,31 @@ function useCopilotReadable({ description, value, convert, available }, dependen
3311
3209
  return ctxIdRef.current;
3312
3210
  }
3313
3211
 
3212
+ //#endregion
3213
+ //#region src/hooks/use-agent-nodename.ts
3214
+ function useAgentNodeName(agentName) {
3215
+ const { agent } = (0, _copilotkitnext_react.useAgent)({ agentId: agentName });
3216
+ const nodeNameRef = (0, react.useRef)("start");
3217
+ (0, react.useEffect)(() => {
3218
+ if (!agent) return;
3219
+ const subscription = agent.subscribe({
3220
+ onStepStartedEvent: ({ event }) => {
3221
+ nodeNameRef.current = event.stepName;
3222
+ },
3223
+ onRunStartedEvent: () => {
3224
+ nodeNameRef.current = "start";
3225
+ },
3226
+ onRunFinishedEvent: () => {
3227
+ nodeNameRef.current = "end";
3228
+ }
3229
+ });
3230
+ return () => {
3231
+ subscription.unsubscribe();
3232
+ };
3233
+ }, [agent]);
3234
+ return nodeNameRef.current;
3235
+ }
3236
+
3314
3237
  //#endregion
3315
3238
  //#region src/hooks/use-coagent.ts
3316
3239
  /**
@@ -3666,26 +3589,62 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
3666
3589
 
3667
3590
  //#endregion
3668
3591
  //#region src/hooks/use-langgraph-interrupt.ts
3669
- function useLangGraphInterrupt(action, dependencies) {
3670
- const { setInterruptAction, removeInterruptAction, interruptActions, threadId } = (0, react.useContext)(CopilotContext);
3671
- const { addToast } = useToast();
3672
- const actionId = (0, _copilotkit_shared.dataToUUID)(action, "lgAction");
3673
- (0, react.useEffect)(() => {
3674
- if (!action) return;
3675
- setInterruptAction({
3676
- ...action,
3677
- id: actionId
3678
- });
3679
- return () => {
3680
- removeInterruptAction(actionId);
3681
- };
3682
- }, [
3683
- setInterruptAction,
3684
- removeInterruptAction,
3592
+ /**
3593
+ * Transforms a v2 InterruptEvent into the v1 LangGraphInterruptEvent shape
3594
+ * expected by existing useLangGraphInterrupt callbacks.
3595
+ */
3596
+ function toV1Event(event) {
3597
+ const value = typeof event.value === "string" ? (0, _copilotkit_shared.parseJson)(event.value, event.value) : event.value;
3598
+ return {
3599
+ name: _copilotkit_runtime_client_gql.MetaEventName.LangGraphInterruptEvent,
3600
+ type: "MetaEvent",
3601
+ value
3602
+ };
3603
+ }
3604
+ function useLangGraphInterrupt(action, _dependencies) {
3605
+ const actionRef = (0, react.useRef)(action);
3606
+ actionRef.current = action;
3607
+ const existingConfig = (0, _copilotkitnext_react.useCopilotChatConfiguration)();
3608
+ const resolvedAgentId = action.agentId ?? existingConfig?.agentId ?? "default";
3609
+ const threadId = existingConfig?.threadId;
3610
+ const nodeName = useAgentNodeName(resolvedAgentId);
3611
+ const metadataRef = (0, react.useRef)({
3612
+ agentName: resolvedAgentId,
3685
3613
  threadId,
3686
- actionId,
3687
- ...dependencies || []
3688
- ]);
3614
+ nodeName
3615
+ });
3616
+ metadataRef.current = {
3617
+ agentName: resolvedAgentId,
3618
+ threadId,
3619
+ nodeName
3620
+ };
3621
+ (0, _copilotkitnext_react.useInterrupt)({
3622
+ render: (0, react.useCallback)(({ event, result, resolve }) => {
3623
+ const renderFn = actionRef.current.render;
3624
+ if (!renderFn) return react.default.createElement(react.default.Fragment);
3625
+ const rendered = renderFn({
3626
+ event: toV1Event(event),
3627
+ result,
3628
+ resolve: (r) => resolve(r)
3629
+ });
3630
+ if (typeof rendered === "string") return react.default.createElement(react.default.Fragment, null, rendered);
3631
+ return rendered;
3632
+ }, []),
3633
+ handler: (0, react.useCallback)(({ event, resolve }) => {
3634
+ return actionRef.current.handler?.({
3635
+ event: toV1Event(event),
3636
+ resolve: (r) => resolve(r)
3637
+ });
3638
+ }, []),
3639
+ enabled: (0, react.useCallback)((event) => {
3640
+ if (!actionRef.current.enabled) return true;
3641
+ return actionRef.current.enabled({
3642
+ eventValue: toV1Event(event).value,
3643
+ agentMetadata: metadataRef.current
3644
+ });
3645
+ }, []),
3646
+ agentId: resolvedAgentId
3647
+ });
3689
3648
  }
3690
3649
 
3691
3650
  //#endregion
@@ -4002,7 +3961,6 @@ exports.useDefaultTool = useDefaultTool;
4002
3961
  exports.useFrontendTool = useFrontendTool;
4003
3962
  exports.useHumanInTheLoop = useHumanInTheLoop;
4004
3963
  exports.useLangGraphInterrupt = useLangGraphInterrupt;
4005
- exports.useLangGraphInterruptRender = useLangGraphInterruptRender;
4006
3964
  exports.useLazyToolRenderer = useLazyToolRenderer;
4007
3965
  exports.useMakeCopilotDocumentReadable = useMakeCopilotDocumentReadable;
4008
3966
  exports.useRenderToolCall = useRenderToolCall;