@copilotkit/react-core 1.52.2-next.2 → 1.52.2-next.4
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 +22 -0
- package/dist/index.cjs +111 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +111 -60
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +114 -63
- package/dist/index.umd.js.map +1 -1
- package/package.json +6 -6
- package/src/components/copilot-provider/copilotkit.tsx +112 -60
- package/src/hooks/__tests__/use-copilot-chat-internal-connect.test.tsx +234 -0
- package/src/hooks/use-copilot-chat_internal.ts +14 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# ui
|
|
2
2
|
|
|
3
|
+
## 1.52.2-next.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ac31331: - Prevents error propagating out of CPK when an agent runtime is defined but not reachable
|
|
8
|
+
- Adds an onError callback to CopilotChat and CopilotKitProvider
|
|
9
|
+
- @copilotkit/runtime-client-gql@1.52.2-next.4
|
|
10
|
+
- @copilotkit/shared@1.52.2-next.4
|
|
11
|
+
- @copilotkitnext/core@1.52.2-next.4
|
|
12
|
+
- @copilotkitnext/react@1.52.2-next.4
|
|
13
|
+
|
|
14
|
+
## 1.52.2-next.3
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 1510f64: feat: enable mcp and a2ui middleware directly from copilotkit runtime
|
|
19
|
+
- Updated dependencies [1510f64]
|
|
20
|
+
- @copilotkit/shared@1.52.2-next.3
|
|
21
|
+
- @copilotkitnext/core@1.52.2-next.3
|
|
22
|
+
- @copilotkitnext/react@1.52.2-next.3
|
|
23
|
+
- @copilotkit/runtime-client-gql@1.52.2-next.3
|
|
24
|
+
|
|
3
25
|
## 1.52.2-next.2
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -37,8 +37,8 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
37
37
|
let react_markdown = require("react-markdown");
|
|
38
38
|
react_markdown = __toESM(react_markdown);
|
|
39
39
|
let _copilotkit_runtime_client_gql = require("@copilotkit/runtime-client-gql");
|
|
40
|
-
let _ag_ui_client = require("@ag-ui/client");
|
|
41
40
|
let _copilotkitnext_core = require("@copilotkitnext/core");
|
|
41
|
+
let _ag_ui_client = require("@ag-ui/client");
|
|
42
42
|
|
|
43
43
|
//#region src/context/copilot-context.tsx
|
|
44
44
|
const emptyCopilotContext$1 = {
|
|
@@ -1913,68 +1913,118 @@ function CopilotKitInternal(cpkProps) {
|
|
|
1913
1913
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, { action: config.action }, key);
|
|
1914
1914
|
}) });
|
|
1915
1915
|
}, [registeredActionConfigs]);
|
|
1916
|
+
const copilotContextValue = (0, react.useMemo)(() => ({
|
|
1917
|
+
actions,
|
|
1918
|
+
chatComponentsCache,
|
|
1919
|
+
getFunctionCallHandler,
|
|
1920
|
+
setAction,
|
|
1921
|
+
removeAction,
|
|
1922
|
+
setRegisteredActions: handleSetRegisteredActions,
|
|
1923
|
+
removeRegisteredAction: handleRemoveRegisteredAction,
|
|
1924
|
+
getContextString,
|
|
1925
|
+
addContext,
|
|
1926
|
+
removeContext,
|
|
1927
|
+
getAllContext,
|
|
1928
|
+
getDocumentsContext,
|
|
1929
|
+
addDocumentContext,
|
|
1930
|
+
removeDocumentContext,
|
|
1931
|
+
copilotApiConfig,
|
|
1932
|
+
isLoading,
|
|
1933
|
+
setIsLoading,
|
|
1934
|
+
chatSuggestionConfiguration,
|
|
1935
|
+
addChatSuggestionConfiguration,
|
|
1936
|
+
removeChatSuggestionConfiguration,
|
|
1937
|
+
chatInstructions,
|
|
1938
|
+
setChatInstructions,
|
|
1939
|
+
additionalInstructions,
|
|
1940
|
+
setAdditionalInstructions,
|
|
1941
|
+
showDevConsole,
|
|
1942
|
+
coagentStates,
|
|
1943
|
+
setCoagentStates,
|
|
1944
|
+
coagentStatesRef,
|
|
1945
|
+
setCoagentStatesWithRef,
|
|
1946
|
+
agentSession,
|
|
1947
|
+
setAgentSession,
|
|
1948
|
+
forwardedParameters,
|
|
1949
|
+
agentLock,
|
|
1950
|
+
threadId,
|
|
1951
|
+
setThreadId,
|
|
1952
|
+
runId,
|
|
1953
|
+
setRunId,
|
|
1954
|
+
chatAbortControllerRef,
|
|
1955
|
+
availableAgents,
|
|
1956
|
+
authConfig_c: props.authConfig_c,
|
|
1957
|
+
authStates_c: authStates,
|
|
1958
|
+
setAuthStates_c: updateAuthStates,
|
|
1959
|
+
extensions,
|
|
1960
|
+
setExtensions: updateExtensions,
|
|
1961
|
+
interruptActions,
|
|
1962
|
+
setInterruptAction,
|
|
1963
|
+
removeInterruptAction,
|
|
1964
|
+
interruptEventQueue,
|
|
1965
|
+
addInterruptEvent,
|
|
1966
|
+
resolveInterruptEvent,
|
|
1967
|
+
bannerError,
|
|
1968
|
+
setBannerError,
|
|
1969
|
+
onError: handleErrors,
|
|
1970
|
+
internalErrorHandlers,
|
|
1971
|
+
setInternalErrorHandler,
|
|
1972
|
+
removeInternalErrorHandler
|
|
1973
|
+
}), [
|
|
1974
|
+
actions,
|
|
1975
|
+
chatComponentsCache,
|
|
1976
|
+
getFunctionCallHandler,
|
|
1977
|
+
setAction,
|
|
1978
|
+
removeAction,
|
|
1979
|
+
handleSetRegisteredActions,
|
|
1980
|
+
handleRemoveRegisteredAction,
|
|
1981
|
+
getContextString,
|
|
1982
|
+
addContext,
|
|
1983
|
+
removeContext,
|
|
1984
|
+
getAllContext,
|
|
1985
|
+
getDocumentsContext,
|
|
1986
|
+
addDocumentContext,
|
|
1987
|
+
removeDocumentContext,
|
|
1988
|
+
copilotApiConfig,
|
|
1989
|
+
isLoading,
|
|
1990
|
+
chatSuggestionConfiguration,
|
|
1991
|
+
addChatSuggestionConfiguration,
|
|
1992
|
+
removeChatSuggestionConfiguration,
|
|
1993
|
+
chatInstructions,
|
|
1994
|
+
additionalInstructions,
|
|
1995
|
+
showDevConsole,
|
|
1996
|
+
coagentStates,
|
|
1997
|
+
setCoagentStatesWithRef,
|
|
1998
|
+
agentSession,
|
|
1999
|
+
setAgentSession,
|
|
2000
|
+
forwardedParameters,
|
|
2001
|
+
agentLock,
|
|
2002
|
+
threadId,
|
|
2003
|
+
setThreadId,
|
|
2004
|
+
runId,
|
|
2005
|
+
availableAgents,
|
|
2006
|
+
props.authConfig_c,
|
|
2007
|
+
authStates,
|
|
2008
|
+
updateAuthStates,
|
|
2009
|
+
extensions,
|
|
2010
|
+
updateExtensions,
|
|
2011
|
+
interruptActions,
|
|
2012
|
+
setInterruptAction,
|
|
2013
|
+
removeInterruptAction,
|
|
2014
|
+
interruptEventQueue,
|
|
2015
|
+
addInterruptEvent,
|
|
2016
|
+
resolveInterruptEvent,
|
|
2017
|
+
bannerError,
|
|
2018
|
+
handleErrors,
|
|
2019
|
+
internalErrorHandlers,
|
|
2020
|
+
setInternalErrorHandler,
|
|
2021
|
+
removeInternalErrorHandler
|
|
2022
|
+
]);
|
|
1916
2023
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkitnext_react.CopilotChatConfigurationProvider, {
|
|
1917
2024
|
agentId: props.agent ?? "default",
|
|
1918
2025
|
threadId,
|
|
1919
2026
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(CopilotContext.Provider, {
|
|
1920
|
-
value:
|
|
1921
|
-
actions,
|
|
1922
|
-
chatComponentsCache,
|
|
1923
|
-
getFunctionCallHandler,
|
|
1924
|
-
setAction,
|
|
1925
|
-
removeAction,
|
|
1926
|
-
setRegisteredActions: handleSetRegisteredActions,
|
|
1927
|
-
removeRegisteredAction: handleRemoveRegisteredAction,
|
|
1928
|
-
getContextString,
|
|
1929
|
-
addContext,
|
|
1930
|
-
removeContext,
|
|
1931
|
-
getAllContext,
|
|
1932
|
-
getDocumentsContext,
|
|
1933
|
-
addDocumentContext,
|
|
1934
|
-
removeDocumentContext,
|
|
1935
|
-
copilotApiConfig,
|
|
1936
|
-
isLoading,
|
|
1937
|
-
setIsLoading,
|
|
1938
|
-
chatSuggestionConfiguration,
|
|
1939
|
-
addChatSuggestionConfiguration,
|
|
1940
|
-
removeChatSuggestionConfiguration,
|
|
1941
|
-
chatInstructions,
|
|
1942
|
-
setChatInstructions,
|
|
1943
|
-
additionalInstructions,
|
|
1944
|
-
setAdditionalInstructions,
|
|
1945
|
-
showDevConsole,
|
|
1946
|
-
coagentStates,
|
|
1947
|
-
setCoagentStates,
|
|
1948
|
-
coagentStatesRef,
|
|
1949
|
-
setCoagentStatesWithRef,
|
|
1950
|
-
agentSession,
|
|
1951
|
-
setAgentSession,
|
|
1952
|
-
forwardedParameters,
|
|
1953
|
-
agentLock,
|
|
1954
|
-
threadId,
|
|
1955
|
-
setThreadId,
|
|
1956
|
-
runId,
|
|
1957
|
-
setRunId,
|
|
1958
|
-
chatAbortControllerRef,
|
|
1959
|
-
availableAgents,
|
|
1960
|
-
authConfig_c: props.authConfig_c,
|
|
1961
|
-
authStates_c: authStates,
|
|
1962
|
-
setAuthStates_c: updateAuthStates,
|
|
1963
|
-
extensions,
|
|
1964
|
-
setExtensions: updateExtensions,
|
|
1965
|
-
interruptActions,
|
|
1966
|
-
setInterruptAction,
|
|
1967
|
-
removeInterruptAction,
|
|
1968
|
-
interruptEventQueue,
|
|
1969
|
-
addInterruptEvent,
|
|
1970
|
-
resolveInterruptEvent,
|
|
1971
|
-
bannerError,
|
|
1972
|
-
setBannerError,
|
|
1973
|
-
onError: handleErrors,
|
|
1974
|
-
internalErrorHandlers,
|
|
1975
|
-
setInternalErrorHandler,
|
|
1976
|
-
removeInternalErrorHandler
|
|
1977
|
-
},
|
|
2027
|
+
value: copilotContextValue,
|
|
1978
2028
|
children: [
|
|
1979
2029
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotListeners, {}),
|
|
1980
2030
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitErrorBridge, {}),
|
|
@@ -2056,7 +2106,7 @@ function useCopilotChatInternal({ suggestions, onInProgress, onSubmitMessage, on
|
|
|
2056
2106
|
if (error instanceof _ag_ui_client.AGUIConnectNotImplementedError) {} else console.error("CopilotChat: connectAgent failed", error);
|
|
2057
2107
|
}
|
|
2058
2108
|
};
|
|
2059
|
-
if (agent && existingConfig?.threadId && agent.threadId !== existingConfig.threadId) {
|
|
2109
|
+
if (agent && existingConfig?.threadId && agent.threadId !== existingConfig.threadId && copilotkit.runtimeConnectionStatus === _copilotkitnext_core.CopilotKitCoreRuntimeConnectionStatus.Connected) {
|
|
2060
2110
|
agent.threadId = existingConfig.threadId;
|
|
2061
2111
|
connect(agent);
|
|
2062
2112
|
}
|
|
@@ -2065,6 +2115,7 @@ function useCopilotChatInternal({ suggestions, onInProgress, onSubmitMessage, on
|
|
|
2065
2115
|
existingConfig?.threadId,
|
|
2066
2116
|
agent,
|
|
2067
2117
|
copilotkit,
|
|
2118
|
+
copilotkit.runtimeConnectionStatus,
|
|
2068
2119
|
resolvedAgentId
|
|
2069
2120
|
]);
|
|
2070
2121
|
(0, react.useEffect)(() => {
|