@copilotkit/react-core 1.61.0 → 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-DtPCrXXd.cjs → copilotkit-BCJDP8qd.cjs} +53 -10
- package/dist/copilotkit-BCJDP8qd.cjs.map +1 -0
- package/dist/copilotkit-CEdu_aie.d.cts.map +1 -1
- package/dist/copilotkit-M1FiciGd.d.mts.map +1 -1
- package/dist/{copilotkit-BCxdKlMw.mjs → copilotkit-UY-H6Kx7.mjs} +53 -10
- package/dist/copilotkit-UY-H6Kx7.mjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +21 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +52 -9
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +52 -9
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +52 -9
- 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-BCxdKlMw.mjs.map +0 -1
- package/dist/copilotkit-DtPCrXXd.cjs.map +0 -1
|
@@ -4110,15 +4110,34 @@ function useComponent(config, deps) {
|
|
|
4110
4110
|
function useHumanInTheLoop(tool, deps) {
|
|
4111
4111
|
const { copilotkit } = useCopilotKit();
|
|
4112
4112
|
const resolvePromiseRef = (0, react.useRef)(null);
|
|
4113
|
+
const cleanupAbortRef = (0, react.useRef)(null);
|
|
4113
4114
|
const respond = (0, react.useCallback)(async (result) => {
|
|
4114
4115
|
if (resolvePromiseRef.current) {
|
|
4116
|
+
cleanupAbortRef.current?.();
|
|
4117
|
+
cleanupAbortRef.current = null;
|
|
4115
4118
|
resolvePromiseRef.current(result);
|
|
4116
4119
|
resolvePromiseRef.current = null;
|
|
4117
4120
|
}
|
|
4118
4121
|
}, []);
|
|
4119
|
-
const handler = (0, react.useCallback)(async () => {
|
|
4120
|
-
|
|
4122
|
+
const handler = (0, react.useCallback)(async (_args, context) => {
|
|
4123
|
+
const signal = context?.signal;
|
|
4124
|
+
return new Promise((resolve, reject) => {
|
|
4125
|
+
if (signal?.aborted) {
|
|
4126
|
+
reject(/* @__PURE__ */ new Error("Human-in-the-loop interaction aborted"));
|
|
4127
|
+
return;
|
|
4128
|
+
}
|
|
4121
4129
|
resolvePromiseRef.current = resolve;
|
|
4130
|
+
if (signal) {
|
|
4131
|
+
const onAbort = () => {
|
|
4132
|
+
cleanupAbortRef.current = null;
|
|
4133
|
+
resolvePromiseRef.current = null;
|
|
4134
|
+
reject(/* @__PURE__ */ new Error("Human-in-the-loop interaction aborted"));
|
|
4135
|
+
};
|
|
4136
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
4137
|
+
cleanupAbortRef.current = () => {
|
|
4138
|
+
signal.removeEventListener("abort", onAbort);
|
|
4139
|
+
};
|
|
4140
|
+
}
|
|
4122
4141
|
});
|
|
4123
4142
|
}, []);
|
|
4124
4143
|
const RenderComponent = (0, react.useCallback)((props) => {
|
|
@@ -4823,21 +4842,32 @@ function useThreads$1({ agentId, includeArchived, limit }) {
|
|
|
4823
4842
|
const headersKey = (0, react.useMemo)(() => {
|
|
4824
4843
|
return JSON.stringify(Object.entries(copilotkit.headers ?? {}).sort(([left], [right]) => left.localeCompare(right)));
|
|
4825
4844
|
}, [copilotkit.headers]);
|
|
4845
|
+
const runtimeStatus = copilotkit.runtimeConnectionStatus;
|
|
4846
|
+
const threadListEndpointSupported = copilotkit.threadEndpoints?.list !== false;
|
|
4847
|
+
const threadMutationsSupported = copilotkit.threadEndpoints?.mutations !== false;
|
|
4848
|
+
const threadEndpointsUnavailable = !!copilotkit.runtimeUrl && runtimeStatus === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Connected && !threadListEndpointSupported;
|
|
4826
4849
|
const runtimeError = (0, react.useMemo)(() => {
|
|
4827
4850
|
if (copilotkit.runtimeUrl) return null;
|
|
4828
4851
|
return /* @__PURE__ */ new Error("Runtime URL is not configured");
|
|
4829
4852
|
}, [copilotkit.runtimeUrl]);
|
|
4853
|
+
const threadEndpointsError = (0, react.useMemo)(() => {
|
|
4854
|
+
if (!threadEndpointsUnavailable) return null;
|
|
4855
|
+
return /* @__PURE__ */ new Error("Thread endpoints are not available on this CopilotKit runtime");
|
|
4856
|
+
}, [threadEndpointsUnavailable]);
|
|
4857
|
+
const threadMutationsError = (0, react.useMemo)(() => {
|
|
4858
|
+
if (threadMutationsSupported) return null;
|
|
4859
|
+
return /* @__PURE__ */ new Error("Thread mutations are not available on this CopilotKit runtime");
|
|
4860
|
+
}, [threadMutationsSupported]);
|
|
4830
4861
|
const [hasDispatchedContext, setHasDispatchedContext] = (0, react.useState)(false);
|
|
4831
|
-
const preConnectLoading = !!copilotkit.runtimeUrl && !hasDispatchedContext;
|
|
4832
|
-
const isLoading = runtimeError ? false : preConnectLoading || storeIsLoading;
|
|
4833
|
-
const error = runtimeError ?? storeError;
|
|
4862
|
+
const preConnectLoading = !!copilotkit.runtimeUrl && !threadEndpointsUnavailable && !hasDispatchedContext;
|
|
4863
|
+
const isLoading = runtimeError || threadEndpointsError ? false : preConnectLoading || storeIsLoading;
|
|
4864
|
+
const error = runtimeError ?? threadEndpointsError ?? storeError;
|
|
4834
4865
|
(0, react.useEffect)(() => {
|
|
4835
4866
|
store.start();
|
|
4836
4867
|
return () => {
|
|
4837
4868
|
store.stop();
|
|
4838
4869
|
};
|
|
4839
4870
|
}, [store]);
|
|
4840
|
-
const runtimeStatus = copilotkit.runtimeConnectionStatus;
|
|
4841
4871
|
(0, react.useEffect)(() => {
|
|
4842
4872
|
copilotkit.registerThreadStore(agentId, store);
|
|
4843
4873
|
return () => {
|
|
@@ -4851,9 +4881,15 @@ function useThreads$1({ agentId, includeArchived, limit }) {
|
|
|
4851
4881
|
(0, react.useEffect)(() => {
|
|
4852
4882
|
if (!copilotkit.runtimeUrl) {
|
|
4853
4883
|
store.setContext(null);
|
|
4884
|
+
setHasDispatchedContext(false);
|
|
4854
4885
|
return;
|
|
4855
4886
|
}
|
|
4856
4887
|
if (runtimeStatus !== _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Connected) return;
|
|
4888
|
+
if (!threadListEndpointSupported) {
|
|
4889
|
+
store.setContext(null);
|
|
4890
|
+
setHasDispatchedContext(false);
|
|
4891
|
+
return;
|
|
4892
|
+
}
|
|
4857
4893
|
const context = {
|
|
4858
4894
|
runtimeUrl: copilotkit.runtimeUrl,
|
|
4859
4895
|
headers: { ...copilotkit.headers },
|
|
@@ -4870,13 +4906,20 @@ function useThreads$1({ agentId, includeArchived, limit }) {
|
|
|
4870
4906
|
runtimeStatus,
|
|
4871
4907
|
headersKey,
|
|
4872
4908
|
copilotkit.intelligence?.wsUrl,
|
|
4909
|
+
threadListEndpointSupported,
|
|
4873
4910
|
agentId,
|
|
4874
4911
|
includeArchived,
|
|
4875
4912
|
limit
|
|
4876
4913
|
]);
|
|
4877
|
-
const
|
|
4878
|
-
|
|
4879
|
-
|
|
4914
|
+
const guardMutation = (0, react.useCallback)((mutation) => {
|
|
4915
|
+
return (...args) => {
|
|
4916
|
+
if (threadMutationsError) return Promise.reject(threadMutationsError);
|
|
4917
|
+
return mutation(...args);
|
|
4918
|
+
};
|
|
4919
|
+
}, [threadMutationsError]);
|
|
4920
|
+
const renameThread = (0, react.useMemo)(() => guardMutation((threadId, name) => store.renameThread(threadId, name)), [store, guardMutation]);
|
|
4921
|
+
const archiveThread = (0, react.useMemo)(() => guardMutation((threadId) => store.archiveThread(threadId)), [store, guardMutation]);
|
|
4922
|
+
const deleteThread = (0, react.useMemo)(() => guardMutation((threadId) => store.deleteThread(threadId)), [store, guardMutation]);
|
|
4880
4923
|
return {
|
|
4881
4924
|
threads,
|
|
4882
4925
|
isLoading,
|
|
@@ -11083,4 +11126,4 @@ Object.defineProperty(exports, 'useToast', {
|
|
|
11083
11126
|
return useToast;
|
|
11084
11127
|
}
|
|
11085
11128
|
});
|
|
11086
|
-
//# sourceMappingURL=copilotkit-
|
|
11129
|
+
//# sourceMappingURL=copilotkit-BCJDP8qd.cjs.map
|