@copilotkit/react-core 0.0.0-feat-use-frontend-component-20260218215423 → 0.0.0-feat-a2ui-mcp-runtime-props-20260304140424
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 +160 -6
- package/dist/index.cjs +92 -136
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -7
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +8 -7
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +94 -137
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +95 -138
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/index.css +3 -3
- package/package.json +11 -9
- package/src/components/copilot-provider/copilotkit.tsx +1 -1
- package/src/hooks/__tests__/use-coagent-state-render.e2e.test.tsx +2 -4
- package/src/hooks/__tests__/use-frontend-tool-available.test.tsx +72 -0
- package/src/hooks/index.ts +0 -1
- package/src/hooks/use-copilot-chat_internal.ts +14 -3
- package/src/hooks/use-frontend-tool.ts +2 -1
- package/src/hooks/use-langgraph-interrupt.ts +98 -38
- package/src/types/interrupt-action.ts +5 -0
- package/src/hooks/use-langgraph-interrupt-render.ts +0 -147
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,170 @@
|
|
|
1
1
|
# ui
|
|
2
2
|
|
|
3
|
-
## 0.0.0-feat-
|
|
3
|
+
## 0.0.0-feat-a2ui-mcp-runtime-props-20260304140424
|
|
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-mcp-runtime-props-20260304140424
|
|
10
|
+
- @copilotkitnext/core@0.0.0-feat-a2ui-mcp-runtime-props-20260304140424
|
|
11
|
+
- @copilotkitnext/react@0.0.0-feat-a2ui-mcp-runtime-props-20260304140424
|
|
12
|
+
- @copilotkit/runtime-client-gql@0.0.0-feat-a2ui-mcp-runtime-props-20260304140424
|
|
13
|
+
|
|
14
|
+
## 1.52.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- b555ac4: fix(react-core): allow overriding useSingleEndpoint in CopilotKit provider
|
|
19
|
+
|
|
20
|
+
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.
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [bbdf67d]
|
|
23
|
+
- @copilotkitnext/react@1.52.1
|
|
24
|
+
- @copilotkit/runtime-client-gql@1.52.1
|
|
25
|
+
- @copilotkit/shared@1.52.1
|
|
26
|
+
- @copilotkitnext/core@1.52.1
|
|
27
|
+
|
|
28
|
+
## 1.52.1-next.1
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- b555ac4: fix(react-core): allow overriding useSingleEndpoint in CopilotKit provider
|
|
33
|
+
|
|
34
|
+
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.
|
|
35
|
+
- @copilotkit/runtime-client-gql@1.52.1-next.1
|
|
36
|
+
- @copilotkit/shared@1.52.1-next.1
|
|
37
|
+
- @copilotkitnext/core@1.52.1-next.1
|
|
38
|
+
- @copilotkitnext/react@1.52.1-next.1
|
|
39
|
+
|
|
40
|
+
## 1.52.1-next.0
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- Updated dependencies [bbdf67d]
|
|
45
|
+
- @copilotkitnext/react@1.52.1-next.0
|
|
46
|
+
- @copilotkit/runtime-client-gql@1.52.1-next.0
|
|
47
|
+
- @copilotkit/shared@1.52.1-next.0
|
|
48
|
+
- @copilotkitnext/core@1.52.1-next.0
|
|
49
|
+
|
|
50
|
+
## 1.52.0
|
|
51
|
+
|
|
52
|
+
### Minor Changes
|
|
53
|
+
|
|
54
|
+
- 6dd6c84: Adding new v2 features:
|
|
55
|
+
- useComponent
|
|
56
|
+
- useRenderTool
|
|
57
|
+
- useDefaultRenderTool
|
|
58
|
+
|
|
59
|
+
Also, fixing issues with styles not being
|
|
60
|
+
properly scoped for tailwind.
|
|
61
|
+
|
|
62
|
+
### Patch Changes
|
|
63
|
+
|
|
64
|
+
- d77f347: Added in the useInterrupt hook
|
|
65
|
+
- 2007f8b: feat: useComponent improvements
|
|
7
66
|
- ef0f539: Add reasoning support and default components for reasoning messages
|
|
8
|
-
-
|
|
67
|
+
- 412965a: Introducing available prop to useFrontendTool()
|
|
68
|
+
- 5f941db: Prevent CPK styles from polluting user app
|
|
69
|
+
- Updated dependencies [593859f]
|
|
70
|
+
- Updated dependencies [d77f347]
|
|
71
|
+
- Updated dependencies [2007f8b]
|
|
9
72
|
- Updated dependencies [ef0f539]
|
|
10
|
-
|
|
11
|
-
- @
|
|
12
|
-
- @copilotkitnext/core@
|
|
13
|
-
- @copilotkit/
|
|
73
|
+
- Updated dependencies [942d397]
|
|
74
|
+
- @copilotkitnext/react@1.52.0
|
|
75
|
+
- @copilotkitnext/core@1.52.0
|
|
76
|
+
- @copilotkit/shared@1.52.0
|
|
77
|
+
- @copilotkit/runtime-client-gql@1.52.0
|
|
78
|
+
|
|
79
|
+
## 1.52.0-next.8
|
|
80
|
+
|
|
81
|
+
### Patch Changes
|
|
82
|
+
|
|
83
|
+
- Updated dependencies [942d397]
|
|
84
|
+
- @copilotkitnext/react@1.52.0-next.8
|
|
85
|
+
- @copilotkit/runtime-client-gql@1.52.0-next.8
|
|
86
|
+
- @copilotkit/shared@1.52.0-next.8
|
|
87
|
+
- @copilotkitnext/core@1.52.0-next.8
|
|
88
|
+
|
|
89
|
+
## 1.52.0-next.7
|
|
90
|
+
|
|
91
|
+
### Patch Changes
|
|
92
|
+
|
|
93
|
+
- d77f347: Added in the useInterrupt hook
|
|
94
|
+
- Updated dependencies [d77f347]
|
|
95
|
+
- @copilotkitnext/react@1.52.0-next.7
|
|
96
|
+
- @copilotkitnext/core@1.52.0-next.7
|
|
97
|
+
- @copilotkit/runtime-client-gql@1.52.0-next.7
|
|
98
|
+
- @copilotkit/shared@1.52.0-next.7
|
|
99
|
+
|
|
100
|
+
## 1.52.0-next.6
|
|
101
|
+
|
|
102
|
+
### Patch Changes
|
|
103
|
+
|
|
104
|
+
- 2007f8b: feat: useComponent improvements
|
|
105
|
+
- 5f941db: Prevent CPK styles from polluting user app
|
|
106
|
+
- Updated dependencies [2007f8b]
|
|
107
|
+
- @copilotkitnext/react@1.52.0-next.6
|
|
108
|
+
- @copilotkit/runtime-client-gql@1.52.0-next.6
|
|
109
|
+
- @copilotkit/shared@1.52.0-next.6
|
|
110
|
+
- @copilotkitnext/core@1.52.0-next.6
|
|
111
|
+
|
|
112
|
+
## 1.52.0-next.5
|
|
113
|
+
|
|
114
|
+
### Minor Changes
|
|
115
|
+
|
|
116
|
+
- 6dd6c84: Adding new v2 features:
|
|
117
|
+
- useComponent
|
|
118
|
+
- useRenderTool
|
|
119
|
+
- useDefaultRenderTool
|
|
120
|
+
|
|
121
|
+
Also, fixing issues with styles not being
|
|
122
|
+
properly scoped for tailwind.
|
|
123
|
+
|
|
124
|
+
### Patch Changes
|
|
125
|
+
|
|
126
|
+
- @copilotkit/runtime-client-gql@1.52.0-next.5
|
|
127
|
+
- @copilotkit/shared@1.52.0-next.5
|
|
128
|
+
- @copilotkitnext/core@1.52.0-next.5
|
|
129
|
+
- @copilotkitnext/react@1.52.0-next.5
|
|
130
|
+
|
|
131
|
+
## 1.51.5-next.4
|
|
132
|
+
|
|
133
|
+
### Patch Changes
|
|
134
|
+
|
|
135
|
+
- @copilotkit/runtime-client-gql@1.51.5-next.4
|
|
136
|
+
- @copilotkit/shared@1.51.5-next.4
|
|
137
|
+
- @copilotkitnext/core@1.51.5-next.4
|
|
138
|
+
- @copilotkitnext/react@1.51.5-next.4
|
|
139
|
+
|
|
140
|
+
## 1.51.5-next.3
|
|
141
|
+
|
|
142
|
+
### Patch Changes
|
|
143
|
+
|
|
144
|
+
- Updated dependencies [593859f]
|
|
145
|
+
- @copilotkitnext/react@1.51.5-next.3
|
|
146
|
+
- @copilotkit/runtime-client-gql@1.51.5-next.3
|
|
147
|
+
- @copilotkit/shared@1.51.5-next.3
|
|
148
|
+
- @copilotkitnext/core@1.51.5-next.3
|
|
149
|
+
|
|
150
|
+
## 1.51.5-next.2
|
|
151
|
+
|
|
152
|
+
### Patch Changes
|
|
153
|
+
|
|
154
|
+
- @copilotkit/runtime-client-gql@1.51.5-next.2
|
|
155
|
+
- @copilotkit/shared@1.51.5-next.2
|
|
156
|
+
- @copilotkitnext/core@1.51.5-next.2
|
|
157
|
+
- @copilotkitnext/react@1.51.5-next.2
|
|
158
|
+
|
|
159
|
+
## 1.51.5-next.1
|
|
160
|
+
|
|
161
|
+
### Patch Changes
|
|
162
|
+
|
|
163
|
+
- 412965a: Introducing available prop to useFrontendTool()
|
|
164
|
+
- @copilotkit/runtime-client-gql@1.51.5-next.1
|
|
165
|
+
- @copilotkit/shared@1.51.5-next.1
|
|
166
|
+
- @copilotkitnext/core@1.51.5-next.1
|
|
167
|
+
- @copilotkitnext/react@1.51.5-next.1
|
|
14
168
|
|
|
15
169
|
## 1.51.5-next.0
|
|
16
170
|
|
package/dist/index.cjs
CHANGED
|
@@ -1596,7 +1596,7 @@ function CopilotKit({ children, ...props }) {
|
|
|
1596
1596
|
...props,
|
|
1597
1597
|
showDevConsole: showInspector,
|
|
1598
1598
|
renderCustomMessages: renderArr,
|
|
1599
|
-
useSingleEndpoint: true,
|
|
1599
|
+
useSingleEndpoint: props.useSingleEndpoint ?? true,
|
|
1600
1600
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitInternal, {
|
|
1601
1601
|
...props,
|
|
1602
1602
|
children
|
|
@@ -2021,118 +2021,6 @@ function validateProps(props) {
|
|
|
2021
2021
|
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
2022
|
}
|
|
2023
2023
|
|
|
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
2024
|
//#endregion
|
|
2137
2025
|
//#region src/hooks/use-lazy-tool-renderer.tsx
|
|
2138
2026
|
function useLazyToolRenderer() {
|
|
@@ -2182,7 +2070,14 @@ function useCopilotChatInternal({ suggestions, onInProgress, onSubmitMessage, on
|
|
|
2182
2070
|
(0, react.useEffect)(() => {
|
|
2183
2071
|
onInProgress?.(Boolean(agent?.isRunning));
|
|
2184
2072
|
}, [agent?.isRunning, onInProgress]);
|
|
2185
|
-
const interrupt =
|
|
2073
|
+
const [interrupt, setInterrupt] = (0, react.useState)(null);
|
|
2074
|
+
(0, react.useEffect)(() => {
|
|
2075
|
+
setInterrupt(copilotkit.interruptElement);
|
|
2076
|
+
const subscription = copilotkit.subscribe({ onInterruptElementChanged: ({ interruptElement }) => {
|
|
2077
|
+
setInterrupt(interruptElement);
|
|
2078
|
+
} });
|
|
2079
|
+
return () => subscription.unsubscribe();
|
|
2080
|
+
}, [copilotkit]);
|
|
2186
2081
|
const reset = () => {
|
|
2187
2082
|
agent?.setMessages([]);
|
|
2188
2083
|
agent?.setState(null);
|
|
@@ -2750,7 +2645,7 @@ function useCopilotChatHeadless_c(options = {}) {
|
|
|
2750
2645
|
//#endregion
|
|
2751
2646
|
//#region src/hooks/use-frontend-tool.ts
|
|
2752
2647
|
function useFrontendTool(tool, dependencies) {
|
|
2753
|
-
const { name, description, parameters, render, followUp } = tool;
|
|
2648
|
+
const { name, description, parameters, render, followUp, available } = tool;
|
|
2754
2649
|
const zodParameters = (0, _copilotkit_shared.getZodParameters)(parameters);
|
|
2755
2650
|
const renderRef = (0, react.useRef)(render);
|
|
2756
2651
|
(0, react.useEffect)(() => {
|
|
@@ -2780,7 +2675,8 @@ function useFrontendTool(tool, dependencies) {
|
|
|
2780
2675
|
parameters: zodParameters,
|
|
2781
2676
|
handler: tool.handler ? (args) => handlerRef.current?.(args) : void 0,
|
|
2782
2677
|
followUp,
|
|
2783
|
-
render: normalizedRender
|
|
2678
|
+
render: normalizedRender,
|
|
2679
|
+
available: available === void 0 ? void 0 : available !== "disabled"
|
|
2784
2680
|
});
|
|
2785
2681
|
}
|
|
2786
2682
|
|
|
@@ -3310,6 +3206,31 @@ function useCopilotReadable({ description, value, convert, available }, dependen
|
|
|
3310
3206
|
return ctxIdRef.current;
|
|
3311
3207
|
}
|
|
3312
3208
|
|
|
3209
|
+
//#endregion
|
|
3210
|
+
//#region src/hooks/use-agent-nodename.ts
|
|
3211
|
+
function useAgentNodeName(agentName) {
|
|
3212
|
+
const { agent } = (0, _copilotkitnext_react.useAgent)({ agentId: agentName });
|
|
3213
|
+
const nodeNameRef = (0, react.useRef)("start");
|
|
3214
|
+
(0, react.useEffect)(() => {
|
|
3215
|
+
if (!agent) return;
|
|
3216
|
+
const subscription = agent.subscribe({
|
|
3217
|
+
onStepStartedEvent: ({ event }) => {
|
|
3218
|
+
nodeNameRef.current = event.stepName;
|
|
3219
|
+
},
|
|
3220
|
+
onRunStartedEvent: () => {
|
|
3221
|
+
nodeNameRef.current = "start";
|
|
3222
|
+
},
|
|
3223
|
+
onRunFinishedEvent: () => {
|
|
3224
|
+
nodeNameRef.current = "end";
|
|
3225
|
+
}
|
|
3226
|
+
});
|
|
3227
|
+
return () => {
|
|
3228
|
+
subscription.unsubscribe();
|
|
3229
|
+
};
|
|
3230
|
+
}, [agent]);
|
|
3231
|
+
return nodeNameRef.current;
|
|
3232
|
+
}
|
|
3233
|
+
|
|
3313
3234
|
//#endregion
|
|
3314
3235
|
//#region src/hooks/use-coagent.ts
|
|
3315
3236
|
/**
|
|
@@ -3665,26 +3586,62 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
|
|
|
3665
3586
|
|
|
3666
3587
|
//#endregion
|
|
3667
3588
|
//#region src/hooks/use-langgraph-interrupt.ts
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3589
|
+
/**
|
|
3590
|
+
* Transforms a v2 InterruptEvent into the v1 LangGraphInterruptEvent shape
|
|
3591
|
+
* expected by existing useLangGraphInterrupt callbacks.
|
|
3592
|
+
*/
|
|
3593
|
+
function toV1Event(event) {
|
|
3594
|
+
const value = typeof event.value === "string" ? (0, _copilotkit_shared.parseJson)(event.value, event.value) : event.value;
|
|
3595
|
+
return {
|
|
3596
|
+
name: _copilotkit_runtime_client_gql.MetaEventName.LangGraphInterruptEvent,
|
|
3597
|
+
type: "MetaEvent",
|
|
3598
|
+
value
|
|
3599
|
+
};
|
|
3600
|
+
}
|
|
3601
|
+
function useLangGraphInterrupt(action, _dependencies) {
|
|
3602
|
+
const actionRef = (0, react.useRef)(action);
|
|
3603
|
+
actionRef.current = action;
|
|
3604
|
+
const existingConfig = (0, _copilotkitnext_react.useCopilotChatConfiguration)();
|
|
3605
|
+
const resolvedAgentId = action.agentId ?? existingConfig?.agentId ?? "default";
|
|
3606
|
+
const threadId = existingConfig?.threadId;
|
|
3607
|
+
const nodeName = useAgentNodeName(resolvedAgentId);
|
|
3608
|
+
const metadataRef = (0, react.useRef)({
|
|
3609
|
+
agentName: resolvedAgentId,
|
|
3684
3610
|
threadId,
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3611
|
+
nodeName
|
|
3612
|
+
});
|
|
3613
|
+
metadataRef.current = {
|
|
3614
|
+
agentName: resolvedAgentId,
|
|
3615
|
+
threadId,
|
|
3616
|
+
nodeName
|
|
3617
|
+
};
|
|
3618
|
+
(0, _copilotkitnext_react.useInterrupt)({
|
|
3619
|
+
render: (0, react.useCallback)(({ event, result, resolve }) => {
|
|
3620
|
+
const renderFn = actionRef.current.render;
|
|
3621
|
+
if (!renderFn) return react.default.createElement(react.default.Fragment);
|
|
3622
|
+
const rendered = renderFn({
|
|
3623
|
+
event: toV1Event(event),
|
|
3624
|
+
result,
|
|
3625
|
+
resolve: (r) => resolve(r)
|
|
3626
|
+
});
|
|
3627
|
+
if (typeof rendered === "string") return react.default.createElement(react.default.Fragment, null, rendered);
|
|
3628
|
+
return rendered;
|
|
3629
|
+
}, []),
|
|
3630
|
+
handler: (0, react.useCallback)(({ event, resolve }) => {
|
|
3631
|
+
return actionRef.current.handler?.({
|
|
3632
|
+
event: toV1Event(event),
|
|
3633
|
+
resolve: (r) => resolve(r)
|
|
3634
|
+
});
|
|
3635
|
+
}, []),
|
|
3636
|
+
enabled: (0, react.useCallback)((event) => {
|
|
3637
|
+
if (!actionRef.current.enabled) return true;
|
|
3638
|
+
return actionRef.current.enabled({
|
|
3639
|
+
eventValue: toV1Event(event).value,
|
|
3640
|
+
agentMetadata: metadataRef.current
|
|
3641
|
+
});
|
|
3642
|
+
}, []),
|
|
3643
|
+
agentId: resolvedAgentId
|
|
3644
|
+
});
|
|
3688
3645
|
}
|
|
3689
3646
|
|
|
3690
3647
|
//#endregion
|
|
@@ -4001,7 +3958,6 @@ exports.useDefaultTool = useDefaultTool;
|
|
|
4001
3958
|
exports.useFrontendTool = useFrontendTool;
|
|
4002
3959
|
exports.useHumanInTheLoop = useHumanInTheLoop;
|
|
4003
3960
|
exports.useLangGraphInterrupt = useLangGraphInterrupt;
|
|
4004
|
-
exports.useLangGraphInterruptRender = useLangGraphInterruptRender;
|
|
4005
3961
|
exports.useLazyToolRenderer = useLazyToolRenderer;
|
|
4006
3962
|
exports.useMakeCopilotDocumentReadable = useMakeCopilotDocumentReadable;
|
|
4007
3963
|
exports.useRenderToolCall = useRenderToolCall;
|