@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
package/dist/v2/index.umd.js
CHANGED
|
@@ -3628,6 +3628,10 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3628
3628
|
...selfManagedAgents
|
|
3629
3629
|
}), [agents, selfManagedAgents]);
|
|
3630
3630
|
const hasLocalAgents = mergedAgents && Object.keys(mergedAgents).length > 0;
|
|
3631
|
+
const hasSelfManagedAgents = Object.keys(selfManagedAgents).length > 0;
|
|
3632
|
+
(0, react.useEffect)(() => {
|
|
3633
|
+
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.");
|
|
3634
|
+
}, [hasSelfManagedAgents, resolvedPublicKey]);
|
|
3631
3635
|
const headers = typeof headersProp === "function" ? headersProp() : headersProp;
|
|
3632
3636
|
const mergedHeaders = (0, react.useMemo)(() => {
|
|
3633
3637
|
if (!resolvedPublicKey) return headers;
|
|
@@ -4092,49 +4096,72 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4092
4096
|
function useHumanInTheLoop(tool, deps) {
|
|
4093
4097
|
const { copilotkit } = useCopilotKit();
|
|
4094
4098
|
const resolvePromiseRef = (0, react.useRef)(null);
|
|
4099
|
+
const cleanupAbortRef = (0, react.useRef)(null);
|
|
4095
4100
|
const respond = (0, react.useCallback)(async (result) => {
|
|
4096
4101
|
if (resolvePromiseRef.current) {
|
|
4102
|
+
cleanupAbortRef.current?.();
|
|
4103
|
+
cleanupAbortRef.current = null;
|
|
4097
4104
|
resolvePromiseRef.current(result);
|
|
4098
4105
|
resolvePromiseRef.current = null;
|
|
4099
4106
|
}
|
|
4100
4107
|
}, []);
|
|
4101
|
-
const handler = (0, react.useCallback)(async () => {
|
|
4102
|
-
|
|
4108
|
+
const handler = (0, react.useCallback)(async (_args, context) => {
|
|
4109
|
+
const signal = context?.signal;
|
|
4110
|
+
return new Promise((resolve, reject) => {
|
|
4111
|
+
if (signal?.aborted) {
|
|
4112
|
+
reject(/* @__PURE__ */ new Error("Human-in-the-loop interaction aborted"));
|
|
4113
|
+
return;
|
|
4114
|
+
}
|
|
4103
4115
|
resolvePromiseRef.current = resolve;
|
|
4116
|
+
if (signal) {
|
|
4117
|
+
const onAbort = () => {
|
|
4118
|
+
cleanupAbortRef.current = null;
|
|
4119
|
+
resolvePromiseRef.current = null;
|
|
4120
|
+
reject(/* @__PURE__ */ new Error("Human-in-the-loop interaction aborted"));
|
|
4121
|
+
};
|
|
4122
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
4123
|
+
cleanupAbortRef.current = () => {
|
|
4124
|
+
signal.removeEventListener("abort", onAbort);
|
|
4125
|
+
};
|
|
4126
|
+
}
|
|
4104
4127
|
});
|
|
4105
4128
|
}, []);
|
|
4106
4129
|
const RenderComponent = (0, react.useCallback)((props) => {
|
|
4107
4130
|
const ToolComponent = tool.render;
|
|
4108
|
-
if (props.status ===
|
|
4131
|
+
if (props.status === _copilotkit_core.ToolCallStatus.InProgress) {
|
|
4109
4132
|
const enhancedProps = {
|
|
4110
4133
|
...props,
|
|
4111
4134
|
name: tool.name,
|
|
4112
4135
|
description: tool.description || "",
|
|
4136
|
+
agentId: tool.agentId,
|
|
4113
4137
|
respond: void 0
|
|
4114
4138
|
};
|
|
4115
4139
|
return react.default.createElement(ToolComponent, enhancedProps);
|
|
4116
|
-
} else if (props.status ===
|
|
4140
|
+
} else if (props.status === _copilotkit_core.ToolCallStatus.Executing) {
|
|
4117
4141
|
const enhancedProps = {
|
|
4118
4142
|
...props,
|
|
4119
4143
|
name: tool.name,
|
|
4120
4144
|
description: tool.description || "",
|
|
4145
|
+
agentId: tool.agentId,
|
|
4121
4146
|
respond
|
|
4122
4147
|
};
|
|
4123
4148
|
return react.default.createElement(ToolComponent, enhancedProps);
|
|
4124
|
-
} else if (props.status ===
|
|
4149
|
+
} else if (props.status === _copilotkit_core.ToolCallStatus.Complete) {
|
|
4125
4150
|
const enhancedProps = {
|
|
4126
4151
|
...props,
|
|
4127
4152
|
name: tool.name,
|
|
4128
4153
|
description: tool.description || "",
|
|
4154
|
+
agentId: tool.agentId,
|
|
4129
4155
|
respond: void 0
|
|
4130
4156
|
};
|
|
4131
4157
|
return react.default.createElement(ToolComponent, enhancedProps);
|
|
4132
4158
|
}
|
|
4133
|
-
return
|
|
4159
|
+
return props;
|
|
4134
4160
|
}, [
|
|
4135
4161
|
tool.render,
|
|
4136
4162
|
tool.name,
|
|
4137
4163
|
tool.description,
|
|
4164
|
+
tool.agentId,
|
|
4138
4165
|
respond
|
|
4139
4166
|
]);
|
|
4140
4167
|
useFrontendTool({
|
|
@@ -4801,21 +4828,32 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4801
4828
|
const headersKey = (0, react.useMemo)(() => {
|
|
4802
4829
|
return JSON.stringify(Object.entries(copilotkit.headers ?? {}).sort(([left], [right]) => left.localeCompare(right)));
|
|
4803
4830
|
}, [copilotkit.headers]);
|
|
4831
|
+
const runtimeStatus = copilotkit.runtimeConnectionStatus;
|
|
4832
|
+
const threadListEndpointSupported = copilotkit.threadEndpoints?.list !== false;
|
|
4833
|
+
const threadMutationsSupported = copilotkit.threadEndpoints?.mutations !== false;
|
|
4834
|
+
const threadEndpointsUnavailable = !!copilotkit.runtimeUrl && runtimeStatus === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Connected && !threadListEndpointSupported;
|
|
4804
4835
|
const runtimeError = (0, react.useMemo)(() => {
|
|
4805
4836
|
if (copilotkit.runtimeUrl) return null;
|
|
4806
4837
|
return /* @__PURE__ */ new Error("Runtime URL is not configured");
|
|
4807
4838
|
}, [copilotkit.runtimeUrl]);
|
|
4839
|
+
const threadEndpointsError = (0, react.useMemo)(() => {
|
|
4840
|
+
if (!threadEndpointsUnavailable) return null;
|
|
4841
|
+
return /* @__PURE__ */ new Error("Thread endpoints are not available on this CopilotKit runtime");
|
|
4842
|
+
}, [threadEndpointsUnavailable]);
|
|
4843
|
+
const threadMutationsError = (0, react.useMemo)(() => {
|
|
4844
|
+
if (threadMutationsSupported) return null;
|
|
4845
|
+
return /* @__PURE__ */ new Error("Thread mutations are not available on this CopilotKit runtime");
|
|
4846
|
+
}, [threadMutationsSupported]);
|
|
4808
4847
|
const [hasDispatchedContext, setHasDispatchedContext] = (0, react.useState)(false);
|
|
4809
|
-
const preConnectLoading = !!copilotkit.runtimeUrl && !hasDispatchedContext;
|
|
4810
|
-
const isLoading = runtimeError ? false : preConnectLoading || storeIsLoading;
|
|
4811
|
-
const error = runtimeError ?? storeError;
|
|
4848
|
+
const preConnectLoading = !!copilotkit.runtimeUrl && !threadEndpointsUnavailable && !hasDispatchedContext;
|
|
4849
|
+
const isLoading = runtimeError || threadEndpointsError ? false : preConnectLoading || storeIsLoading;
|
|
4850
|
+
const error = runtimeError ?? threadEndpointsError ?? storeError;
|
|
4812
4851
|
(0, react.useEffect)(() => {
|
|
4813
4852
|
store.start();
|
|
4814
4853
|
return () => {
|
|
4815
4854
|
store.stop();
|
|
4816
4855
|
};
|
|
4817
4856
|
}, [store]);
|
|
4818
|
-
const runtimeStatus = copilotkit.runtimeConnectionStatus;
|
|
4819
4857
|
(0, react.useEffect)(() => {
|
|
4820
4858
|
copilotkit.registerThreadStore(agentId, store);
|
|
4821
4859
|
return () => {
|
|
@@ -4829,9 +4867,15 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4829
4867
|
(0, react.useEffect)(() => {
|
|
4830
4868
|
if (!copilotkit.runtimeUrl) {
|
|
4831
4869
|
store.setContext(null);
|
|
4870
|
+
setHasDispatchedContext(false);
|
|
4832
4871
|
return;
|
|
4833
4872
|
}
|
|
4834
4873
|
if (runtimeStatus !== _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Connected) return;
|
|
4874
|
+
if (!threadListEndpointSupported) {
|
|
4875
|
+
store.setContext(null);
|
|
4876
|
+
setHasDispatchedContext(false);
|
|
4877
|
+
return;
|
|
4878
|
+
}
|
|
4835
4879
|
const context = {
|
|
4836
4880
|
runtimeUrl: copilotkit.runtimeUrl,
|
|
4837
4881
|
headers: { ...copilotkit.headers },
|
|
@@ -4848,13 +4892,20 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4848
4892
|
runtimeStatus,
|
|
4849
4893
|
headersKey,
|
|
4850
4894
|
copilotkit.intelligence?.wsUrl,
|
|
4895
|
+
threadListEndpointSupported,
|
|
4851
4896
|
agentId,
|
|
4852
4897
|
includeArchived,
|
|
4853
4898
|
limit
|
|
4854
4899
|
]);
|
|
4855
|
-
const
|
|
4856
|
-
|
|
4857
|
-
|
|
4900
|
+
const guardMutation = (0, react.useCallback)((mutation) => {
|
|
4901
|
+
return (...args) => {
|
|
4902
|
+
if (threadMutationsError) return Promise.reject(threadMutationsError);
|
|
4903
|
+
return mutation(...args);
|
|
4904
|
+
};
|
|
4905
|
+
}, [threadMutationsError]);
|
|
4906
|
+
const renameThread = (0, react.useMemo)(() => guardMutation((threadId, name) => store.renameThread(threadId, name)), [store, guardMutation]);
|
|
4907
|
+
const archiveThread = (0, react.useMemo)(() => guardMutation((threadId) => store.archiveThread(threadId)), [store, guardMutation]);
|
|
4908
|
+
const deleteThread = (0, react.useMemo)(() => guardMutation((threadId) => store.deleteThread(threadId)), [store, guardMutation]);
|
|
4858
4909
|
return {
|
|
4859
4910
|
threads,
|
|
4860
4911
|
isLoading,
|
|
@@ -9982,21 +10033,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
9982
10033
|
|
|
9983
10034
|
//#endregion
|
|
9984
10035
|
//#region src/components/copilot-provider/copilotkit.tsx
|
|
9985
|
-
/**
|
|
9986
|
-
* 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.
|
|
9987
|
-
*
|
|
9988
|
-
* ## Example
|
|
9989
|
-
*
|
|
9990
|
-
* You can find more information about self-hosting CopilotKit [here](/guides/self-hosting).
|
|
9991
|
-
*
|
|
9992
|
-
* ```tsx
|
|
9993
|
-
* import { CopilotKit } from "@copilotkit/react-core";
|
|
9994
|
-
*
|
|
9995
|
-
* <CopilotKit runtimeUrl="<your-runtime-url>">
|
|
9996
|
-
* // ... your app ...
|
|
9997
|
-
* </CopilotKit>
|
|
9998
|
-
* ```
|
|
9999
|
-
*/
|
|
10000
10036
|
function CopilotKit({ children, ...props }) {
|
|
10001
10037
|
const enabled = shouldShowDevConsole(props.showDevConsole);
|
|
10002
10038
|
const showInspector = shouldShowDevConsole(props.enableInspector);
|
|
@@ -10485,7 +10521,11 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
10485
10521
|
function validateProps(props) {
|
|
10486
10522
|
const cloudFeatures = Object.keys(props).filter((key) => key.endsWith("_c"));
|
|
10487
10523
|
const hasApiKey = props.publicApiKey || props.publicLicenseKey;
|
|
10488
|
-
|
|
10524
|
+
const hasLocalAgents = Object.keys({
|
|
10525
|
+
...props.agents__unsafe_dev_only,
|
|
10526
|
+
...props.selfManagedAgents
|
|
10527
|
+
}).length > 0;
|
|
10528
|
+
if (!props.runtimeUrl && !hasApiKey && !hasLocalAgents) throw new _copilotkit_shared.ConfigurationError("Missing required prop: 'runtimeUrl' or 'publicApiKey' or 'publicLicenseKey'");
|
|
10489
10529
|
if (cloudFeatures.length > 0 && !hasApiKey) throw new _copilotkit_shared.MissingPublicApiKeyError(`Missing required prop: 'publicApiKey' or 'publicLicenseKey' to use cloud features: ${cloudFeatures.map(formatFeatureName).join(", ")}`);
|
|
10490
10530
|
}
|
|
10491
10531
|
|