@copilotkit/react-core 1.78.0 → 1.79.1-canary.1792034358
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-gn5p8gXk.d.cts → copilotkit-BA0vyDds.d.cts} +43 -9
- package/dist/{copilotkit-gn5p8gXk.d.cts.map → copilotkit-BA0vyDds.d.cts.map} +1 -1
- package/dist/{copilotkit-DgJj6xa0.mjs → copilotkit-DtOQtboh.mjs} +73 -56
- package/dist/copilotkit-DtOQtboh.mjs.map +1 -0
- package/dist/{copilotkit-D1y8IyXh.d.mts → copilotkit-kcYN96tM.d.mts} +43 -9
- package/dist/{copilotkit-D1y8IyXh.d.mts.map → copilotkit-kcYN96tM.d.mts.map} +1 -1
- package/dist/{copilotkit-BFeenQQ0.cjs → copilotkit-t6Gs-59F.cjs} +71 -54
- package/dist/copilotkit-t6Gs-59F.cjs.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 +61 -38
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +1 -4
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.mjs +1 -4
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +19 -1
- package/dist/v2/index.css +1 -1
- package/dist/v2/index.d.cts +2 -2
- package/dist/v2/index.d.mts +2 -2
- package/dist/v2/index.mjs +2 -2
- package/dist/v2/index.umd.js +88 -53
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +9 -9
- package/dist/copilotkit-BFeenQQ0.cjs.map +0 -1
- package/dist/copilotkit-DgJj6xa0.mjs.map +0 -1
|
@@ -1655,7 +1655,7 @@ function useRenderToolCall() {
|
|
|
1655
1655
|
|
|
1656
1656
|
//#endregion
|
|
1657
1657
|
//#region package.json
|
|
1658
|
-
var version = "1.
|
|
1658
|
+
var version = "1.79.1-canary.1792034358";
|
|
1659
1659
|
|
|
1660
1660
|
//#endregion
|
|
1661
1661
|
//#region src/v2/components/CopilotKitInspector.tsx
|
|
@@ -3522,15 +3522,15 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3522
3522
|
(0, react.useEffect)(() => {
|
|
3523
3523
|
if (hasSelfManagedAgents && !resolvedPublicKey) console.warn("[CopilotKit] `selfManagedAgents` is part of CopilotKit's Enterprise Intelligence tier. Provide a `publicLicenseKey` for production use — contact the CopilotKit team about licensing.");
|
|
3524
3524
|
}, [hasSelfManagedAgents, resolvedPublicKey]);
|
|
3525
|
-
const
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
}, [
|
|
3525
|
+
const headersRef = (0, react.useRef)(headersProp);
|
|
3526
|
+
headersRef.current = headersProp;
|
|
3527
|
+
const isHeadersBuilder = typeof headersProp === "function";
|
|
3528
|
+
const stableHeadersBuilder = (0, react.useCallback)(() => {
|
|
3529
|
+
const current = headersRef.current;
|
|
3530
|
+
return typeof current === "function" ? current() : current;
|
|
3531
|
+
}, []);
|
|
3532
|
+
const headersInput = isHeadersBuilder ? stableHeadersBuilder : headersProp;
|
|
3533
|
+
const headersSource = (0, react.useMemo)(() => (0, _copilotkit_core.ɵwithHeaderDefaults)(headersInput, resolvedPublicKey ? { [HEADER_NAME]: resolvedPublicKey } : {}), [headersInput, resolvedPublicKey]);
|
|
3534
3534
|
if (!runtimeUrl && !resolvedPublicKey && !hasLocalAgents) {
|
|
3535
3535
|
const message = "Missing required prop: 'runtimeUrl' or 'publicApiKey' or 'publicLicenseKey'";
|
|
3536
3536
|
if (process.env.NODE_ENV === "production") throw new Error(message);
|
|
@@ -3655,7 +3655,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3655
3655
|
runtimeUrl: chatApiEndpoint,
|
|
3656
3656
|
deferInitialConnection: true,
|
|
3657
3657
|
runtimeTransport: useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto",
|
|
3658
|
-
headers:
|
|
3658
|
+
headers: headersSource,
|
|
3659
3659
|
credentials,
|
|
3660
3660
|
messageFilter,
|
|
3661
3661
|
properties,
|
|
@@ -3750,7 +3750,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3750
3750
|
(0, react.useEffect)(() => {
|
|
3751
3751
|
copilotkit.setRuntimeUrl(chatApiEndpoint);
|
|
3752
3752
|
copilotkit.setRuntimeTransport(useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto");
|
|
3753
|
-
copilotkit.setHeaders(
|
|
3753
|
+
copilotkit.setHeaders(headersSource);
|
|
3754
3754
|
copilotkit.setCredentials(credentials);
|
|
3755
3755
|
copilotkit.setProperties(a2uiCatalogProvided ? {
|
|
3756
3756
|
...properties,
|
|
@@ -3762,7 +3762,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3762
3762
|
}, [
|
|
3763
3763
|
copilotkit,
|
|
3764
3764
|
chatApiEndpoint,
|
|
3765
|
-
|
|
3765
|
+
headersSource,
|
|
3766
3766
|
credentials,
|
|
3767
3767
|
properties,
|
|
3768
3768
|
a2uiCatalogProvided,
|
|
@@ -3779,7 +3779,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3779
3779
|
(0, react.useEffect)(() => {
|
|
3780
3780
|
copilotkit.setLearningConfig(learningConfig);
|
|
3781
3781
|
learningContainerIdsRef.current = learningConfig?.learningContainerIds;
|
|
3782
|
-
if (learningConfig?.sink === void 0 && !autoStart && learningConfig?.learningContainerIds !== void 0) console.warn("[CopilotKit] learningContainerIds is supported only with a custom sink. Authenticated Trajectory capture
|
|
3782
|
+
if (learningConfig?.sink === void 0 && !autoStart && learningConfig?.learningContainerIds !== void 0) console.warn("[CopilotKit] learningContainerIds is supported only with a custom sink. Authenticated Trajectory capture ignores it; assign Learning Spaces on the server with getTrajectoryLearningContainerIds on CopilotKitIntelligence, and remove learningContainerIds from the capture options.");
|
|
3783
3783
|
}, [
|
|
3784
3784
|
copilotkit,
|
|
3785
3785
|
learningConfig,
|
|
@@ -5386,9 +5386,7 @@ function useThreads$1({ agentId, includeArchived, limit, enabled = true }) {
|
|
|
5386
5386
|
const hasMoreThreads = useThreadStoreSelector(store, _copilotkit_core.ɵselectHasNextPage);
|
|
5387
5387
|
const isFetchingMoreThreads = useThreadStoreSelector(store, _copilotkit_core.ɵselectIsFetchingNextPage);
|
|
5388
5388
|
const isMutating = useThreadStoreSelector(store, _copilotkit_core.ɵselectIsMutating);
|
|
5389
|
-
const headersKey =
|
|
5390
|
-
return JSON.stringify(Object.entries(copilotkit.headers ?? {}).sort(([left], [right]) => left.localeCompare(right)));
|
|
5391
|
-
}, [copilotkit.headers]);
|
|
5389
|
+
const headersKey = copilotkit.ɵheadersGeneration;
|
|
5392
5390
|
const runtimeStatus = copilotkit.runtimeConnectionStatus;
|
|
5393
5391
|
const threadListEndpointSupported = copilotkit.threadEndpoints?.list !== false;
|
|
5394
5392
|
const threadMutationsSupported = copilotkit.threadEndpoints?.mutations !== false;
|
|
@@ -5453,7 +5451,6 @@ function useThreads$1({ agentId, includeArchived, limit, enabled = true }) {
|
|
|
5453
5451
|
}
|
|
5454
5452
|
const context = {
|
|
5455
5453
|
runtimeUrl: copilotkit.runtimeUrl,
|
|
5456
|
-
headers: { ...copilotkit.headers },
|
|
5457
5454
|
wsUrl: copilotkit.intelligence?.wsUrl,
|
|
5458
5455
|
agentId,
|
|
5459
5456
|
includeArchived,
|
|
@@ -5581,7 +5578,9 @@ function useMemories() {
|
|
|
5581
5578
|
*
|
|
5582
5579
|
* The function uses the same transport as `useLearnFromUserAction`:
|
|
5583
5580
|
* - `runtimeUrl` from `copilotkit.runtimeUrl` (BFF proxies to the platform)
|
|
5584
|
-
* - `
|
|
5581
|
+
* - `fetch: copilotkit.ɵruntimeFetch`, which adds the current core headers at
|
|
5582
|
+
* send time (#1937); `headers` here is only for extra request-specific
|
|
5583
|
+
* headers on top of that
|
|
5585
5584
|
* - `clientEventId` auto-generated via `randomUUID()` when omitted
|
|
5586
5585
|
* - `userId` is resolved server-side by the runtime; the client never sends it
|
|
5587
5586
|
* - Errors propagate to the caller (fire-and-propagate, not fire-and-forget)
|
|
@@ -5673,7 +5672,7 @@ function useLearnFromUserAction() {
|
|
|
5673
5672
|
return recordAnnotation({
|
|
5674
5673
|
fetch: copilotkit.ɵruntimeFetch,
|
|
5675
5674
|
runtimeUrl,
|
|
5676
|
-
headers:
|
|
5675
|
+
headers: {},
|
|
5677
5676
|
type: "user_action",
|
|
5678
5677
|
payload: Object.keys(payload).length > 0 ? payload : void 0,
|
|
5679
5678
|
threadId: input.threadId,
|
|
@@ -6001,16 +6000,13 @@ function useLearningContainers({ threadId, learningContainers }) {
|
|
|
6001
6000
|
/** Guards the missing-runtimeUrl warning so it fires at most once per hook instance. */
|
|
6002
6001
|
const warnedMissingUrlRef = (0, react.useRef)(false);
|
|
6003
6002
|
const runtimeUrlRef = (0, react.useRef)(copilotkit.runtimeUrl);
|
|
6004
|
-
const headersRef = (0, react.useRef)(copilotkit.headers ?? {});
|
|
6005
6003
|
const runtimeFetchRef = (0, react.useRef)(copilotkit.ɵruntimeFetch);
|
|
6006
6004
|
runtimeUrlRef.current = copilotkit.runtimeUrl;
|
|
6007
|
-
headersRef.current = copilotkit.headers ?? {};
|
|
6008
6005
|
runtimeFetchRef.current = copilotkit.ɵruntimeFetch;
|
|
6009
6006
|
const key = JSON.stringify(learningContainers);
|
|
6010
6007
|
const defaultKey = JSON.stringify(DEFAULT_CONTAINERS);
|
|
6011
6008
|
(0, react.useEffect)(() => {
|
|
6012
6009
|
const runtimeUrl = copilotkit.runtimeUrl;
|
|
6013
|
-
const headers = copilotkit.headers ?? {};
|
|
6014
6010
|
/**
|
|
6015
6011
|
* Fire-and-forget emit; errors must not surface in render.
|
|
6016
6012
|
* Failures are logged as warnings so they are diagnosable without
|
|
@@ -6027,7 +6023,7 @@ function useLearningContainers({ threadId, learningContainers }) {
|
|
|
6027
6023
|
recordAnnotation({
|
|
6028
6024
|
fetch: copilotkit.ɵruntimeFetch,
|
|
6029
6025
|
runtimeUrl,
|
|
6030
|
-
headers,
|
|
6026
|
+
headers: {},
|
|
6031
6027
|
type: "set_learning_containers",
|
|
6032
6028
|
payload: { containers },
|
|
6033
6029
|
threadId
|
|
@@ -6051,11 +6047,10 @@ function useLearningContainers({ threadId, learningContainers }) {
|
|
|
6051
6047
|
const capturedThreadId = threadId;
|
|
6052
6048
|
return () => {
|
|
6053
6049
|
const capturedRuntimeUrl = runtimeUrlRef.current;
|
|
6054
|
-
const capturedHeaders = headersRef.current;
|
|
6055
6050
|
if (capturedRuntimeUrl) recordAnnotation({
|
|
6056
6051
|
fetch: runtimeFetchRef.current,
|
|
6057
6052
|
runtimeUrl: capturedRuntimeUrl,
|
|
6058
|
-
headers:
|
|
6053
|
+
headers: {},
|
|
6059
6054
|
type: "set_learning_containers",
|
|
6060
6055
|
payload: { containers: DEFAULT_CONTAINERS },
|
|
6061
6056
|
threadId: capturedThreadId
|
|
@@ -8861,7 +8856,7 @@ async function transcribeAudio(core, audioBlob, filename = "recording.webm") {
|
|
|
8861
8856
|
message: "Runtime URL is not configured",
|
|
8862
8857
|
retryable: false
|
|
8863
8858
|
});
|
|
8864
|
-
const headers = { ...core.
|
|
8859
|
+
const headers = { ...await core.resolveHeaders() };
|
|
8865
8860
|
let response;
|
|
8866
8861
|
try {
|
|
8867
8862
|
if (core.runtimeTransport === "single") {
|
|
@@ -9273,7 +9268,6 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
9273
9268
|
threadStore.start();
|
|
9274
9269
|
const context = copilotkit.runtimeUrl ? {
|
|
9275
9270
|
runtimeUrl: copilotkit.runtimeUrl,
|
|
9276
|
-
headers: { ...copilotkit.headers },
|
|
9277
9271
|
wsUrl: copilotkit.intelligence?.wsUrl,
|
|
9278
9272
|
agentId: resolvedAgentId
|
|
9279
9273
|
} : null;
|
|
@@ -9369,7 +9363,7 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
9369
9363
|
hasNativeIntelligenceRunActivity,
|
|
9370
9364
|
copilotkit.runtimeConnectionStatus,
|
|
9371
9365
|
copilotkit.runtimeUrl,
|
|
9372
|
-
copilotkit
|
|
9366
|
+
copilotkit.ɵheadersGeneration,
|
|
9373
9367
|
copilotkit.intelligence?.wsUrl,
|
|
9374
9368
|
copilotkit.threadEndpoints?.realtimeMetadata,
|
|
9375
9369
|
standaloneRunActivityStore,
|
|
@@ -12360,6 +12354,16 @@ function CopilotListeners() {
|
|
|
12360
12354
|
|
|
12361
12355
|
//#endregion
|
|
12362
12356
|
//#region src/v1-deprecated/components/copilot-provider/copilotkit.tsx
|
|
12357
|
+
/**
|
|
12358
|
+
* Drops `null`/`undefined` entries so a `CopilotKitHeadersSource` record (or
|
|
12359
|
+
* a builder's resolved record) matches `CopilotApiConfig.headers`'s
|
|
12360
|
+
* `Record<string, string>` shape. Mirrors core's own (internal-only)
|
|
12361
|
+
* `normalizeHeaders`.
|
|
12362
|
+
*/
|
|
12363
|
+
function normalizeV1Headers(headers) {
|
|
12364
|
+
if (!headers) return {};
|
|
12365
|
+
return Object.fromEntries(Object.entries(headers).filter((entry) => entry[1] != null));
|
|
12366
|
+
}
|
|
12363
12367
|
function CopilotKit({ children, ...props }) {
|
|
12364
12368
|
const enabled = shouldShowDevConsole(props.showDevConsole);
|
|
12365
12369
|
const publicApiKey = props.publicApiKey || props.publicLicenseKey;
|
|
@@ -12439,6 +12443,13 @@ function CopilotKitInternal(cpkProps) {
|
|
|
12439
12443
|
* This will throw an error if the props are invalid.
|
|
12440
12444
|
*/
|
|
12441
12445
|
validateProps(cpkProps);
|
|
12446
|
+
const headersPropRef = (0, react.useRef)(props.headers);
|
|
12447
|
+
headersPropRef.current = props.headers;
|
|
12448
|
+
const headersBuilderStateRef = (0, react.useRef)({
|
|
12449
|
+
fn: void 0,
|
|
12450
|
+
isAsync: false
|
|
12451
|
+
});
|
|
12452
|
+
const warnedAsyncHeadersRef = (0, react.useRef)(false);
|
|
12442
12453
|
const publicApiKey = props.publicLicenseKey || props.publicApiKey;
|
|
12443
12454
|
const chatApiEndpoint = props.runtimeUrl || _copilotkit_shared.COPILOT_CLOUD_CHAT_URL;
|
|
12444
12455
|
const [actions, setActions] = (0, react.useState)({});
|
|
@@ -12506,19 +12517,46 @@ function CopilotKitInternal(cpkProps) {
|
|
|
12506
12517
|
validTopics: props.guardrails_c?.validTopics || [],
|
|
12507
12518
|
invalidTopics: props.guardrails_c?.invalidTopics || []
|
|
12508
12519
|
} } } };
|
|
12509
|
-
|
|
12520
|
+
const config = {
|
|
12510
12521
|
publicApiKey,
|
|
12511
12522
|
...cloud ? { cloud } : {},
|
|
12512
12523
|
chatApiEndpoint,
|
|
12513
|
-
headers: typeof props.headers === "function" ? props.headers() : props.headers || {},
|
|
12514
12524
|
properties: props.properties || {},
|
|
12515
12525
|
transcribeAudioUrl: props.transcribeAudioUrl,
|
|
12516
12526
|
textToSpeechUrl: props.textToSpeechUrl,
|
|
12517
12527
|
credentials: props.credentials
|
|
12518
12528
|
};
|
|
12529
|
+
Object.defineProperty(config, "headers", {
|
|
12530
|
+
enumerable: true,
|
|
12531
|
+
configurable: true,
|
|
12532
|
+
get() {
|
|
12533
|
+
const source = headersPropRef.current;
|
|
12534
|
+
if (typeof source !== "function") return normalizeV1Headers(source);
|
|
12535
|
+
const state = headersBuilderStateRef.current;
|
|
12536
|
+
if (state.fn === source && state.isAsync) return {};
|
|
12537
|
+
const result = source();
|
|
12538
|
+
if (typeof result === "object" && result !== null && typeof result.then === "function") {
|
|
12539
|
+
headersBuilderStateRef.current = {
|
|
12540
|
+
fn: source,
|
|
12541
|
+
isAsync: true
|
|
12542
|
+
};
|
|
12543
|
+
result.then(void 0, () => {});
|
|
12544
|
+
if (process.env.NODE_ENV !== "production" && !warnedAsyncHeadersRef.current) {
|
|
12545
|
+
warnedAsyncHeadersRef.current = true;
|
|
12546
|
+
console.warn("[CopilotKit] An async `headers` builder is not supported by the v1 CopilotTask / GraphQL path; its headers are not sent there.");
|
|
12547
|
+
}
|
|
12548
|
+
return {};
|
|
12549
|
+
}
|
|
12550
|
+
headersBuilderStateRef.current = {
|
|
12551
|
+
fn: source,
|
|
12552
|
+
isAsync: false
|
|
12553
|
+
};
|
|
12554
|
+
return normalizeV1Headers(result);
|
|
12555
|
+
}
|
|
12556
|
+
});
|
|
12557
|
+
return config;
|
|
12519
12558
|
}, [
|
|
12520
12559
|
publicApiKey,
|
|
12521
|
-
props.headers,
|
|
12522
12560
|
props.properties,
|
|
12523
12561
|
props.transcribeAudioUrl,
|
|
12524
12562
|
props.textToSpeechUrl,
|
|
@@ -12526,27 +12564,6 @@ function CopilotKitInternal(cpkProps) {
|
|
|
12526
12564
|
props.cloudRestrictToTopic,
|
|
12527
12565
|
props.guardrails_c
|
|
12528
12566
|
]);
|
|
12529
|
-
(0, react.useMemo)(() => {
|
|
12530
|
-
const authHeaders = Object.values(authStates || {}).reduce((acc, state) => {
|
|
12531
|
-
if (state.status === "authenticated" && state.authHeaders) return {
|
|
12532
|
-
...acc,
|
|
12533
|
-
...Object.entries(state.authHeaders).reduce((headers, [key, value]) => ({
|
|
12534
|
-
...headers,
|
|
12535
|
-
[key.startsWith("X-Custom-") ? key : `X-Custom-${key}`]: value
|
|
12536
|
-
}), {})
|
|
12537
|
-
};
|
|
12538
|
-
return acc;
|
|
12539
|
-
}, {});
|
|
12540
|
-
return {
|
|
12541
|
-
...copilotApiConfig.headers,
|
|
12542
|
-
...copilotApiConfig.publicApiKey ? { [_copilotkit_shared.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey } : {},
|
|
12543
|
-
...authHeaders
|
|
12544
|
-
};
|
|
12545
|
-
}, [
|
|
12546
|
-
copilotApiConfig.headers,
|
|
12547
|
-
copilotApiConfig.publicApiKey,
|
|
12548
|
-
authStates
|
|
12549
|
-
]);
|
|
12550
12567
|
const [internalErrorHandlers, _setInternalErrorHandler] = (0, react.useState)({});
|
|
12551
12568
|
const setInternalErrorHandler = (0, react.useCallback)((handler) => {
|
|
12552
12569
|
_setInternalErrorHandler((prev) => ({
|
|
@@ -13377,4 +13394,4 @@ Object.defineProperty(exports, 'useToast', {
|
|
|
13377
13394
|
return useToast;
|
|
13378
13395
|
}
|
|
13379
13396
|
});
|
|
13380
|
-
//# sourceMappingURL=copilotkit-
|
|
13397
|
+
//# sourceMappingURL=copilotkit-t6Gs-59F.cjs.map
|