@copilotkit/react-core 1.60.2 → 1.61.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-CP5uyB2h.cjs → copilotkit-BCJDP8qd.cjs} +70 -30
- package/dist/copilotkit-BCJDP8qd.cjs.map +1 -0
- package/dist/{copilotkit-CyL6ZsLP.d.cts → copilotkit-CEdu_aie.d.cts} +23 -1
- package/dist/{copilotkit-UaQ7KSUq.d.mts.map → copilotkit-CEdu_aie.d.cts.map} +1 -1
- package/dist/{copilotkit-UaQ7KSUq.d.mts → copilotkit-M1FiciGd.d.mts} +23 -1
- package/dist/{copilotkit-CyL6ZsLP.d.cts.map → copilotkit-M1FiciGd.d.mts.map} +1 -1
- package/dist/{copilotkit-DheptEiV.mjs → copilotkit-UY-H6Kx7.mjs} +70 -30
- package/dist/copilotkit-UY-H6Kx7.mjs.map +1 -0
- 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 +38 -22
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +60 -13
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts +22 -0
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts +22 -0
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +61 -14
- package/dist/v2/headless.mjs.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 +69 -29
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +6 -6
- package/skills/react-core/references/provider-setup.md +20 -2
- package/dist/copilotkit-CP5uyB2h.cjs.map +0 -1
- package/dist/copilotkit-DheptEiV.mjs.map +0 -1
|
@@ -3612,6 +3612,10 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3612
3612
|
...selfManagedAgents
|
|
3613
3613
|
}), [agents, selfManagedAgents]);
|
|
3614
3614
|
const hasLocalAgents = mergedAgents && Object.keys(mergedAgents).length > 0;
|
|
3615
|
+
const hasSelfManagedAgents = Object.keys(selfManagedAgents).length > 0;
|
|
3616
|
+
useEffect(() => {
|
|
3617
|
+
if (hasSelfManagedAgents && !resolvedPublicKey) console.warn("[CopilotKit] `selfManagedAgents` is part of CopilotKit's Enterprise Intelligence offering. Provide a `publicLicenseKey` for production use — contact the CopilotKit team about licensing.");
|
|
3618
|
+
}, [hasSelfManagedAgents, resolvedPublicKey]);
|
|
3615
3619
|
const headers = typeof headersProp === "function" ? headersProp() : headersProp;
|
|
3616
3620
|
const mergedHeaders = useMemo(() => {
|
|
3617
3621
|
if (!resolvedPublicKey) return headers;
|
|
@@ -4076,49 +4080,72 @@ function useComponent(config, deps) {
|
|
|
4076
4080
|
function useHumanInTheLoop(tool, deps) {
|
|
4077
4081
|
const { copilotkit } = useCopilotKit();
|
|
4078
4082
|
const resolvePromiseRef = useRef(null);
|
|
4083
|
+
const cleanupAbortRef = useRef(null);
|
|
4079
4084
|
const respond = useCallback(async (result) => {
|
|
4080
4085
|
if (resolvePromiseRef.current) {
|
|
4086
|
+
cleanupAbortRef.current?.();
|
|
4087
|
+
cleanupAbortRef.current = null;
|
|
4081
4088
|
resolvePromiseRef.current(result);
|
|
4082
4089
|
resolvePromiseRef.current = null;
|
|
4083
4090
|
}
|
|
4084
4091
|
}, []);
|
|
4085
|
-
const handler = useCallback(async () => {
|
|
4086
|
-
|
|
4092
|
+
const handler = useCallback(async (_args, context) => {
|
|
4093
|
+
const signal = context?.signal;
|
|
4094
|
+
return new Promise((resolve, reject) => {
|
|
4095
|
+
if (signal?.aborted) {
|
|
4096
|
+
reject(/* @__PURE__ */ new Error("Human-in-the-loop interaction aborted"));
|
|
4097
|
+
return;
|
|
4098
|
+
}
|
|
4087
4099
|
resolvePromiseRef.current = resolve;
|
|
4100
|
+
if (signal) {
|
|
4101
|
+
const onAbort = () => {
|
|
4102
|
+
cleanupAbortRef.current = null;
|
|
4103
|
+
resolvePromiseRef.current = null;
|
|
4104
|
+
reject(/* @__PURE__ */ new Error("Human-in-the-loop interaction aborted"));
|
|
4105
|
+
};
|
|
4106
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
4107
|
+
cleanupAbortRef.current = () => {
|
|
4108
|
+
signal.removeEventListener("abort", onAbort);
|
|
4109
|
+
};
|
|
4110
|
+
}
|
|
4088
4111
|
});
|
|
4089
4112
|
}, []);
|
|
4090
4113
|
const RenderComponent = useCallback((props) => {
|
|
4091
4114
|
const ToolComponent = tool.render;
|
|
4092
|
-
if (props.status ===
|
|
4115
|
+
if (props.status === ToolCallStatus.InProgress) {
|
|
4093
4116
|
const enhancedProps = {
|
|
4094
4117
|
...props,
|
|
4095
4118
|
name: tool.name,
|
|
4096
4119
|
description: tool.description || "",
|
|
4120
|
+
agentId: tool.agentId,
|
|
4097
4121
|
respond: void 0
|
|
4098
4122
|
};
|
|
4099
4123
|
return React.createElement(ToolComponent, enhancedProps);
|
|
4100
|
-
} else if (props.status ===
|
|
4124
|
+
} else if (props.status === ToolCallStatus.Executing) {
|
|
4101
4125
|
const enhancedProps = {
|
|
4102
4126
|
...props,
|
|
4103
4127
|
name: tool.name,
|
|
4104
4128
|
description: tool.description || "",
|
|
4129
|
+
agentId: tool.agentId,
|
|
4105
4130
|
respond
|
|
4106
4131
|
};
|
|
4107
4132
|
return React.createElement(ToolComponent, enhancedProps);
|
|
4108
|
-
} else if (props.status ===
|
|
4133
|
+
} else if (props.status === ToolCallStatus.Complete) {
|
|
4109
4134
|
const enhancedProps = {
|
|
4110
4135
|
...props,
|
|
4111
4136
|
name: tool.name,
|
|
4112
4137
|
description: tool.description || "",
|
|
4138
|
+
agentId: tool.agentId,
|
|
4113
4139
|
respond: void 0
|
|
4114
4140
|
};
|
|
4115
4141
|
return React.createElement(ToolComponent, enhancedProps);
|
|
4116
4142
|
}
|
|
4117
|
-
return
|
|
4143
|
+
return props;
|
|
4118
4144
|
}, [
|
|
4119
4145
|
tool.render,
|
|
4120
4146
|
tool.name,
|
|
4121
4147
|
tool.description,
|
|
4148
|
+
tool.agentId,
|
|
4122
4149
|
respond
|
|
4123
4150
|
]);
|
|
4124
4151
|
useFrontendTool({
|
|
@@ -4785,21 +4812,32 @@ function useThreads$1({ agentId, includeArchived, limit }) {
|
|
|
4785
4812
|
const headersKey = useMemo(() => {
|
|
4786
4813
|
return JSON.stringify(Object.entries(copilotkit.headers ?? {}).sort(([left], [right]) => left.localeCompare(right)));
|
|
4787
4814
|
}, [copilotkit.headers]);
|
|
4815
|
+
const runtimeStatus = copilotkit.runtimeConnectionStatus;
|
|
4816
|
+
const threadListEndpointSupported = copilotkit.threadEndpoints?.list !== false;
|
|
4817
|
+
const threadMutationsSupported = copilotkit.threadEndpoints?.mutations !== false;
|
|
4818
|
+
const threadEndpointsUnavailable = !!copilotkit.runtimeUrl && runtimeStatus === CopilotKitCoreRuntimeConnectionStatus.Connected && !threadListEndpointSupported;
|
|
4788
4819
|
const runtimeError = useMemo(() => {
|
|
4789
4820
|
if (copilotkit.runtimeUrl) return null;
|
|
4790
4821
|
return /* @__PURE__ */ new Error("Runtime URL is not configured");
|
|
4791
4822
|
}, [copilotkit.runtimeUrl]);
|
|
4823
|
+
const threadEndpointsError = useMemo(() => {
|
|
4824
|
+
if (!threadEndpointsUnavailable) return null;
|
|
4825
|
+
return /* @__PURE__ */ new Error("Thread endpoints are not available on this CopilotKit runtime");
|
|
4826
|
+
}, [threadEndpointsUnavailable]);
|
|
4827
|
+
const threadMutationsError = useMemo(() => {
|
|
4828
|
+
if (threadMutationsSupported) return null;
|
|
4829
|
+
return /* @__PURE__ */ new Error("Thread mutations are not available on this CopilotKit runtime");
|
|
4830
|
+
}, [threadMutationsSupported]);
|
|
4792
4831
|
const [hasDispatchedContext, setHasDispatchedContext] = useState(false);
|
|
4793
|
-
const preConnectLoading = !!copilotkit.runtimeUrl && !hasDispatchedContext;
|
|
4794
|
-
const isLoading = runtimeError ? false : preConnectLoading || storeIsLoading;
|
|
4795
|
-
const error = runtimeError ?? storeError;
|
|
4832
|
+
const preConnectLoading = !!copilotkit.runtimeUrl && !threadEndpointsUnavailable && !hasDispatchedContext;
|
|
4833
|
+
const isLoading = runtimeError || threadEndpointsError ? false : preConnectLoading || storeIsLoading;
|
|
4834
|
+
const error = runtimeError ?? threadEndpointsError ?? storeError;
|
|
4796
4835
|
useEffect(() => {
|
|
4797
4836
|
store.start();
|
|
4798
4837
|
return () => {
|
|
4799
4838
|
store.stop();
|
|
4800
4839
|
};
|
|
4801
4840
|
}, [store]);
|
|
4802
|
-
const runtimeStatus = copilotkit.runtimeConnectionStatus;
|
|
4803
4841
|
useEffect(() => {
|
|
4804
4842
|
copilotkit.registerThreadStore(agentId, store);
|
|
4805
4843
|
return () => {
|
|
@@ -4813,9 +4851,15 @@ function useThreads$1({ agentId, includeArchived, limit }) {
|
|
|
4813
4851
|
useEffect(() => {
|
|
4814
4852
|
if (!copilotkit.runtimeUrl) {
|
|
4815
4853
|
store.setContext(null);
|
|
4854
|
+
setHasDispatchedContext(false);
|
|
4816
4855
|
return;
|
|
4817
4856
|
}
|
|
4818
4857
|
if (runtimeStatus !== CopilotKitCoreRuntimeConnectionStatus.Connected) return;
|
|
4858
|
+
if (!threadListEndpointSupported) {
|
|
4859
|
+
store.setContext(null);
|
|
4860
|
+
setHasDispatchedContext(false);
|
|
4861
|
+
return;
|
|
4862
|
+
}
|
|
4819
4863
|
const context = {
|
|
4820
4864
|
runtimeUrl: copilotkit.runtimeUrl,
|
|
4821
4865
|
headers: { ...copilotkit.headers },
|
|
@@ -4832,13 +4876,20 @@ function useThreads$1({ agentId, includeArchived, limit }) {
|
|
|
4832
4876
|
runtimeStatus,
|
|
4833
4877
|
headersKey,
|
|
4834
4878
|
copilotkit.intelligence?.wsUrl,
|
|
4879
|
+
threadListEndpointSupported,
|
|
4835
4880
|
agentId,
|
|
4836
4881
|
includeArchived,
|
|
4837
4882
|
limit
|
|
4838
4883
|
]);
|
|
4839
|
-
const
|
|
4840
|
-
|
|
4841
|
-
|
|
4884
|
+
const guardMutation = useCallback((mutation) => {
|
|
4885
|
+
return (...args) => {
|
|
4886
|
+
if (threadMutationsError) return Promise.reject(threadMutationsError);
|
|
4887
|
+
return mutation(...args);
|
|
4888
|
+
};
|
|
4889
|
+
}, [threadMutationsError]);
|
|
4890
|
+
const renameThread = useMemo(() => guardMutation((threadId, name) => store.renameThread(threadId, name)), [store, guardMutation]);
|
|
4891
|
+
const archiveThread = useMemo(() => guardMutation((threadId) => store.archiveThread(threadId)), [store, guardMutation]);
|
|
4892
|
+
const deleteThread = useMemo(() => guardMutation((threadId) => store.deleteThread(threadId)), [store, guardMutation]);
|
|
4842
4893
|
return {
|
|
4843
4894
|
threads,
|
|
4844
4895
|
isLoading,
|
|
@@ -10080,21 +10131,6 @@ function CopilotListeners() {
|
|
|
10080
10131
|
|
|
10081
10132
|
//#endregion
|
|
10082
10133
|
//#region src/components/copilot-provider/copilotkit.tsx
|
|
10083
|
-
/**
|
|
10084
|
-
* This component will typically wrap your entire application (or a sub-tree of your application where you want to have a copilot). It provides the copilot context to all other components and hooks.
|
|
10085
|
-
*
|
|
10086
|
-
* ## Example
|
|
10087
|
-
*
|
|
10088
|
-
* You can find more information about self-hosting CopilotKit [here](/guides/self-hosting).
|
|
10089
|
-
*
|
|
10090
|
-
* ```tsx
|
|
10091
|
-
* import { CopilotKit } from "@copilotkit/react-core";
|
|
10092
|
-
*
|
|
10093
|
-
* <CopilotKit runtimeUrl="<your-runtime-url>">
|
|
10094
|
-
* // ... your app ...
|
|
10095
|
-
* </CopilotKit>
|
|
10096
|
-
* ```
|
|
10097
|
-
*/
|
|
10098
10134
|
function CopilotKit({ children, ...props }) {
|
|
10099
10135
|
const enabled = shouldShowDevConsole(props.showDevConsole);
|
|
10100
10136
|
const showInspector = shouldShowDevConsole(props.enableInspector);
|
|
@@ -10583,10 +10619,14 @@ function formatFeatureName(featureName) {
|
|
|
10583
10619
|
function validateProps(props) {
|
|
10584
10620
|
const cloudFeatures = Object.keys(props).filter((key) => key.endsWith("_c"));
|
|
10585
10621
|
const hasApiKey = props.publicApiKey || props.publicLicenseKey;
|
|
10586
|
-
|
|
10622
|
+
const hasLocalAgents = Object.keys({
|
|
10623
|
+
...props.agents__unsafe_dev_only,
|
|
10624
|
+
...props.selfManagedAgents
|
|
10625
|
+
}).length > 0;
|
|
10626
|
+
if (!props.runtimeUrl && !hasApiKey && !hasLocalAgents) throw new ConfigurationError("Missing required prop: 'runtimeUrl' or 'publicApiKey' or 'publicLicenseKey'");
|
|
10587
10627
|
if (cloudFeatures.length > 0 && !hasApiKey) throw new MissingPublicApiKeyError(`Missing required prop: 'publicApiKey' or 'publicLicenseKey' to use cloud features: ${cloudFeatures.map(formatFeatureName).join(", ")}`);
|
|
10588
10628
|
}
|
|
10589
10629
|
|
|
10590
10630
|
//#endregion
|
|
10591
10631
|
export { useAgent as $, INTELLIGENCE_TURN_HEAD as A, CopilotChatToolCallsView as B, CopilotChatToggleButton as C, useCopilotChatConfiguration as Ct, CopilotChatView_default as D, CopilotChat as E, CopilotChatSuggestionPill as F, useLearnFromUserAction as G, useLearningContainers as H, CopilotChatReasoningMessage_default as I, useConfigureSuggestions as J, useThreads$1 as K, CopilotChatUserMessage_default as L, getIntelligenceTurnAnchors as M, IntelligenceIndicatorView as N, CopilotChatAttachmentQueue as O, CopilotChatSuggestionView as P, UseAgentUpdate as Q, CopilotChatAttachmentRenderer as R, CopilotModalHeader as S, CopilotChatConfigurationProvider as St, DefaultOpenIcon as T, useAttachments as U, useLearningContainersInCurrentThread as V, useLearnFromUserActionInCurrentThread as W, useAgentContext as X, useSuggestions as Y, useCapabilities as Z, WildcardToolCallRender as _, useCopilotKit as _t, ThreadsProvider as a, CopilotKitProvider as at, CopilotPopupView as b, AudioRecorderError as bt, CoAgentStateRendersProvider as c, useSandboxFunctions as ct, shouldShowDevConsole as d, MCPAppsActivityType as dt, useHumanInTheLoop as et, useToast as f, CopilotKitInspector as ft, useCopilotContext as g, defineToolCallRenderer as gt, CopilotContext as h, useRenderTool as ht, ThreadsContext as i, useRenderCustomMessages as it, IntelligenceIndicator as j, CopilotChatMessageView as k, useCoAgentStateRenders as l, MCPAppsActivityContentSchema as lt, useCopilotMessagesContext as m, useDefaultRenderTool as mt, defaultCopilotContextCategories as n, useFrontendTool as nt, useThreads as o, createA2UIMessageRenderer as ot, CopilotMessagesContext as p, useRenderToolCall as pt, useInterrupt as q, CoAgentStateRenderBridge as r, useRenderActivityMessage as rt, CoAgentStateRendersContext as s, SandboxFunctionsContext as st, CopilotKit as t, useComponent as tt, useAsyncCallback as u, MCPAppsActivityRenderer as ut, CopilotPopup as v, CopilotKitCoreReact as vt, DefaultCloseIcon as w, CopilotSidebarView as x, CopilotChatAudioRecorder as xt, CopilotSidebar as y, CopilotChatInput_default as yt, CopilotChatAssistantMessage_default as z };
|
|
10592
|
-
//# sourceMappingURL=copilotkit-
|
|
10632
|
+
//# sourceMappingURL=copilotkit-UY-H6Kx7.mjs.map
|