@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/dist/index.umd.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
(function(global, factory) {
|
|
4
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@copilotkitnext/react'), require('@copilotkit/shared'), require('react-dom'), require('react/jsx-runtime'), require('react-markdown'), require('@copilotkit/runtime-client-gql'), require('@
|
|
5
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react', '@copilotkitnext/react', '@copilotkit/shared', 'react-dom', 'react/jsx-runtime', 'react-markdown', '@copilotkit/runtime-client-gql', '@
|
|
6
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.CopilotKitReactCore = {}), global.React,global.CopilotKitNextReact,global.CopilotKitShared,global.ReactDOM,global.ReactJsxRuntime,global.ReactMarkdown,global.CopilotKitRuntimeClientGQL,global.
|
|
7
|
-
})(this, function(exports, react, _copilotkitnext_react, _copilotkit_shared, react_dom, react_jsx_runtime, react_markdown, _copilotkit_runtime_client_gql,
|
|
4
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@copilotkitnext/react'), require('@copilotkit/shared'), require('react-dom'), require('react/jsx-runtime'), require('react-markdown'), require('@copilotkit/runtime-client-gql'), require('@copilotkitnext/core'), require('@ag-ui/client')) :
|
|
5
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react', '@copilotkitnext/react', '@copilotkit/shared', 'react-dom', 'react/jsx-runtime', 'react-markdown', '@copilotkit/runtime-client-gql', '@copilotkitnext/core', '@ag-ui/client'], factory) :
|
|
6
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.CopilotKitReactCore = {}), global.React,global.CopilotKitNextReact,global.CopilotKitShared,global.ReactDOM,global.ReactJsxRuntime,global.ReactMarkdown,global.CopilotKitRuntimeClientGQL,global.CopilotKitNextCore,global.AgUIClient));
|
|
7
|
+
})(this, function(exports, react, _copilotkitnext_react, _copilotkit_shared, react_dom, react_jsx_runtime, react_markdown, _copilotkit_runtime_client_gql, _copilotkitnext_core, _ag_ui_client) {
|
|
8
8
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
9
9
|
//#region \0rolldown/runtime.js
|
|
10
10
|
var __create = Object.create;
|
|
@@ -1946,68 +1946,118 @@ react_markdown = __toESM(react_markdown);
|
|
|
1946
1946
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, { action: config.action }, key);
|
|
1947
1947
|
}) });
|
|
1948
1948
|
}, [registeredActionConfigs]);
|
|
1949
|
+
const copilotContextValue = (0, react.useMemo)(() => ({
|
|
1950
|
+
actions,
|
|
1951
|
+
chatComponentsCache,
|
|
1952
|
+
getFunctionCallHandler,
|
|
1953
|
+
setAction,
|
|
1954
|
+
removeAction,
|
|
1955
|
+
setRegisteredActions: handleSetRegisteredActions,
|
|
1956
|
+
removeRegisteredAction: handleRemoveRegisteredAction,
|
|
1957
|
+
getContextString,
|
|
1958
|
+
addContext,
|
|
1959
|
+
removeContext,
|
|
1960
|
+
getAllContext,
|
|
1961
|
+
getDocumentsContext,
|
|
1962
|
+
addDocumentContext,
|
|
1963
|
+
removeDocumentContext,
|
|
1964
|
+
copilotApiConfig,
|
|
1965
|
+
isLoading,
|
|
1966
|
+
setIsLoading,
|
|
1967
|
+
chatSuggestionConfiguration,
|
|
1968
|
+
addChatSuggestionConfiguration,
|
|
1969
|
+
removeChatSuggestionConfiguration,
|
|
1970
|
+
chatInstructions,
|
|
1971
|
+
setChatInstructions,
|
|
1972
|
+
additionalInstructions,
|
|
1973
|
+
setAdditionalInstructions,
|
|
1974
|
+
showDevConsole,
|
|
1975
|
+
coagentStates,
|
|
1976
|
+
setCoagentStates,
|
|
1977
|
+
coagentStatesRef,
|
|
1978
|
+
setCoagentStatesWithRef,
|
|
1979
|
+
agentSession,
|
|
1980
|
+
setAgentSession,
|
|
1981
|
+
forwardedParameters,
|
|
1982
|
+
agentLock,
|
|
1983
|
+
threadId,
|
|
1984
|
+
setThreadId,
|
|
1985
|
+
runId,
|
|
1986
|
+
setRunId,
|
|
1987
|
+
chatAbortControllerRef,
|
|
1988
|
+
availableAgents,
|
|
1989
|
+
authConfig_c: props.authConfig_c,
|
|
1990
|
+
authStates_c: authStates,
|
|
1991
|
+
setAuthStates_c: updateAuthStates,
|
|
1992
|
+
extensions,
|
|
1993
|
+
setExtensions: updateExtensions,
|
|
1994
|
+
interruptActions,
|
|
1995
|
+
setInterruptAction,
|
|
1996
|
+
removeInterruptAction,
|
|
1997
|
+
interruptEventQueue,
|
|
1998
|
+
addInterruptEvent,
|
|
1999
|
+
resolveInterruptEvent,
|
|
2000
|
+
bannerError,
|
|
2001
|
+
setBannerError,
|
|
2002
|
+
onError: handleErrors,
|
|
2003
|
+
internalErrorHandlers,
|
|
2004
|
+
setInternalErrorHandler,
|
|
2005
|
+
removeInternalErrorHandler
|
|
2006
|
+
}), [
|
|
2007
|
+
actions,
|
|
2008
|
+
chatComponentsCache,
|
|
2009
|
+
getFunctionCallHandler,
|
|
2010
|
+
setAction,
|
|
2011
|
+
removeAction,
|
|
2012
|
+
handleSetRegisteredActions,
|
|
2013
|
+
handleRemoveRegisteredAction,
|
|
2014
|
+
getContextString,
|
|
2015
|
+
addContext,
|
|
2016
|
+
removeContext,
|
|
2017
|
+
getAllContext,
|
|
2018
|
+
getDocumentsContext,
|
|
2019
|
+
addDocumentContext,
|
|
2020
|
+
removeDocumentContext,
|
|
2021
|
+
copilotApiConfig,
|
|
2022
|
+
isLoading,
|
|
2023
|
+
chatSuggestionConfiguration,
|
|
2024
|
+
addChatSuggestionConfiguration,
|
|
2025
|
+
removeChatSuggestionConfiguration,
|
|
2026
|
+
chatInstructions,
|
|
2027
|
+
additionalInstructions,
|
|
2028
|
+
showDevConsole,
|
|
2029
|
+
coagentStates,
|
|
2030
|
+
setCoagentStatesWithRef,
|
|
2031
|
+
agentSession,
|
|
2032
|
+
setAgentSession,
|
|
2033
|
+
forwardedParameters,
|
|
2034
|
+
agentLock,
|
|
2035
|
+
threadId,
|
|
2036
|
+
setThreadId,
|
|
2037
|
+
runId,
|
|
2038
|
+
availableAgents,
|
|
2039
|
+
props.authConfig_c,
|
|
2040
|
+
authStates,
|
|
2041
|
+
updateAuthStates,
|
|
2042
|
+
extensions,
|
|
2043
|
+
updateExtensions,
|
|
2044
|
+
interruptActions,
|
|
2045
|
+
setInterruptAction,
|
|
2046
|
+
removeInterruptAction,
|
|
2047
|
+
interruptEventQueue,
|
|
2048
|
+
addInterruptEvent,
|
|
2049
|
+
resolveInterruptEvent,
|
|
2050
|
+
bannerError,
|
|
2051
|
+
handleErrors,
|
|
2052
|
+
internalErrorHandlers,
|
|
2053
|
+
setInternalErrorHandler,
|
|
2054
|
+
removeInternalErrorHandler
|
|
2055
|
+
]);
|
|
1949
2056
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkitnext_react.CopilotChatConfigurationProvider, {
|
|
1950
2057
|
agentId: (_props$agent2 = props.agent) !== null && _props$agent2 !== void 0 ? _props$agent2 : "default",
|
|
1951
2058
|
threadId,
|
|
1952
2059
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(CopilotContext.Provider, {
|
|
1953
|
-
value:
|
|
1954
|
-
actions,
|
|
1955
|
-
chatComponentsCache,
|
|
1956
|
-
getFunctionCallHandler,
|
|
1957
|
-
setAction,
|
|
1958
|
-
removeAction,
|
|
1959
|
-
setRegisteredActions: handleSetRegisteredActions,
|
|
1960
|
-
removeRegisteredAction: handleRemoveRegisteredAction,
|
|
1961
|
-
getContextString,
|
|
1962
|
-
addContext,
|
|
1963
|
-
removeContext,
|
|
1964
|
-
getAllContext,
|
|
1965
|
-
getDocumentsContext,
|
|
1966
|
-
addDocumentContext,
|
|
1967
|
-
removeDocumentContext,
|
|
1968
|
-
copilotApiConfig,
|
|
1969
|
-
isLoading,
|
|
1970
|
-
setIsLoading,
|
|
1971
|
-
chatSuggestionConfiguration,
|
|
1972
|
-
addChatSuggestionConfiguration,
|
|
1973
|
-
removeChatSuggestionConfiguration,
|
|
1974
|
-
chatInstructions,
|
|
1975
|
-
setChatInstructions,
|
|
1976
|
-
additionalInstructions,
|
|
1977
|
-
setAdditionalInstructions,
|
|
1978
|
-
showDevConsole,
|
|
1979
|
-
coagentStates,
|
|
1980
|
-
setCoagentStates,
|
|
1981
|
-
coagentStatesRef,
|
|
1982
|
-
setCoagentStatesWithRef,
|
|
1983
|
-
agentSession,
|
|
1984
|
-
setAgentSession,
|
|
1985
|
-
forwardedParameters,
|
|
1986
|
-
agentLock,
|
|
1987
|
-
threadId,
|
|
1988
|
-
setThreadId,
|
|
1989
|
-
runId,
|
|
1990
|
-
setRunId,
|
|
1991
|
-
chatAbortControllerRef,
|
|
1992
|
-
availableAgents,
|
|
1993
|
-
authConfig_c: props.authConfig_c,
|
|
1994
|
-
authStates_c: authStates,
|
|
1995
|
-
setAuthStates_c: updateAuthStates,
|
|
1996
|
-
extensions,
|
|
1997
|
-
setExtensions: updateExtensions,
|
|
1998
|
-
interruptActions,
|
|
1999
|
-
setInterruptAction,
|
|
2000
|
-
removeInterruptAction,
|
|
2001
|
-
interruptEventQueue,
|
|
2002
|
-
addInterruptEvent,
|
|
2003
|
-
resolveInterruptEvent,
|
|
2004
|
-
bannerError,
|
|
2005
|
-
setBannerError,
|
|
2006
|
-
onError: handleErrors,
|
|
2007
|
-
internalErrorHandlers,
|
|
2008
|
-
setInternalErrorHandler,
|
|
2009
|
-
removeInternalErrorHandler
|
|
2010
|
-
},
|
|
2060
|
+
value: copilotContextValue,
|
|
2011
2061
|
children: [
|
|
2012
2062
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotListeners, {}),
|
|
2013
2063
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitErrorBridge, {}),
|
|
@@ -2092,7 +2142,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
2092
2142
|
if (error instanceof _ag_ui_client.AGUIConnectNotImplementedError) {} else console.error("CopilotChat: connectAgent failed", error);
|
|
2093
2143
|
}
|
|
2094
2144
|
};
|
|
2095
|
-
if (agent && (existingConfig === null || existingConfig === void 0 ? void 0 : existingConfig.threadId) && agent.threadId !== existingConfig.threadId) {
|
|
2145
|
+
if (agent && (existingConfig === null || existingConfig === void 0 ? void 0 : existingConfig.threadId) && agent.threadId !== existingConfig.threadId && copilotkit.runtimeConnectionStatus === _copilotkitnext_core.CopilotKitCoreRuntimeConnectionStatus.Connected) {
|
|
2096
2146
|
agent.threadId = existingConfig.threadId;
|
|
2097
2147
|
connect(agent);
|
|
2098
2148
|
}
|
|
@@ -2101,6 +2151,7 @@ react_markdown = __toESM(react_markdown);
|
|
|
2101
2151
|
existingConfig === null || existingConfig === void 0 ? void 0 : existingConfig.threadId,
|
|
2102
2152
|
agent,
|
|
2103
2153
|
copilotkit,
|
|
2154
|
+
copilotkit.runtimeConnectionStatus,
|
|
2104
2155
|
resolvedAgentId
|
|
2105
2156
|
]);
|
|
2106
2157
|
(0, react.useEffect)(() => {
|