@copilotkit/react-core 1.77.2 → 1.79.0
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-BQBy80gH.d.cts → copilotkit-2Fbb5_CC.d.cts} +60 -20
- package/dist/{copilotkit-BQBy80gH.d.cts.map → copilotkit-2Fbb5_CC.d.cts.map} +1 -1
- package/dist/{copilotkit-DkLb1sf9.d.mts → copilotkit-DFMMPW2I.d.mts} +60 -20
- package/dist/{copilotkit-DkLb1sf9.d.mts.map → copilotkit-DFMMPW2I.d.mts.map} +1 -1
- package/dist/{copilotkit-BI7KSQQw.mjs → copilotkit-DQvE96lZ.mjs} +93 -65
- package/dist/copilotkit-DQvE96lZ.mjs.map +1 -0
- package/dist/{copilotkit-D7_J5Hs_.cjs → copilotkit-DjrKQjfL.cjs} +91 -63
- package/dist/copilotkit-DjrKQjfL.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 +81 -47
- 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 +13 -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 +102 -62
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +8 -8
- package/dist/copilotkit-BI7KSQQw.mjs.map +0 -1
- package/dist/copilotkit-D7_J5Hs_.cjs.map +0 -1
package/dist/v2/index.umd.js
CHANGED
|
@@ -1766,7 +1766,7 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
1766
1766
|
|
|
1767
1767
|
//#endregion
|
|
1768
1768
|
//#region package.json
|
|
1769
|
-
var version = "1.
|
|
1769
|
+
var version = "1.79.0";
|
|
1770
1770
|
|
|
1771
1771
|
//#endregion
|
|
1772
1772
|
//#region src/v2/components/CopilotKitInspector.tsx
|
|
@@ -3430,8 +3430,9 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
3430
3430
|
const DEFAULT_LEARNING = Object.freeze({});
|
|
3431
3431
|
function toLearningConfig(learning) {
|
|
3432
3432
|
if (learning === true) return DEFAULT_LEARNING;
|
|
3433
|
-
if (learning === false) return void 0;
|
|
3434
|
-
|
|
3433
|
+
if (learning === false || learning === void 0) return void 0;
|
|
3434
|
+
const { autoStart: _autoStart, ...config } = learning;
|
|
3435
|
+
return config;
|
|
3435
3436
|
}
|
|
3436
3437
|
function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
|
|
3437
3438
|
const empty = (0, react.useMemo)(() => [], []);
|
|
@@ -3443,7 +3444,7 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
3443
3444
|
return value;
|
|
3444
3445
|
}
|
|
3445
3446
|
const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY_HEADERS, credentials, messageFilter, publicApiKey, publicLicenseKey, licenseToken, properties = EMPTY_PROPERTIES, agents__unsafe_dev_only: agents = EMPTY_AGENTS, selfManagedAgents = EMPTY_AGENTS, renderToolCalls, renderActivityMessages, renderCustomMessages, frontendTools, humanInTheLoop, openGenerativeUI, enableInspector, agentId, showIntelligenceIndicator = true, useSingleEndpoint, onError, a2ui, defaultThrottleMs, debug, learning }) => {
|
|
3446
|
-
const learningConfig = toLearningConfig(learning);
|
|
3447
|
+
const learningConfig = (0, react.useMemo)(() => toLearningConfig(learning), [learning]);
|
|
3447
3448
|
const [shouldRenderInspector, setShouldRenderInspector] = (0, react.useState)(false);
|
|
3448
3449
|
const [inspectorVisible, setInspectorVisible] = (0, react.useState)(false);
|
|
3449
3450
|
(0, react.useEffect)(() => {
|
|
@@ -3536,15 +3537,15 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
3536
3537
|
(0, react.useEffect)(() => {
|
|
3537
3538
|
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.");
|
|
3538
3539
|
}, [hasSelfManagedAgents, resolvedPublicKey]);
|
|
3539
|
-
const
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
}, [
|
|
3540
|
+
const headersRef = (0, react.useRef)(headersProp);
|
|
3541
|
+
headersRef.current = headersProp;
|
|
3542
|
+
const isHeadersBuilder = typeof headersProp === "function";
|
|
3543
|
+
const stableHeadersBuilder = (0, react.useCallback)(() => {
|
|
3544
|
+
const current = headersRef.current;
|
|
3545
|
+
return typeof current === "function" ? current() : current;
|
|
3546
|
+
}, []);
|
|
3547
|
+
const headersInput = isHeadersBuilder ? stableHeadersBuilder : headersProp;
|
|
3548
|
+
const headersSource = (0, react.useMemo)(() => (0, _copilotkit_core.ɵwithHeaderDefaults)(headersInput, resolvedPublicKey ? { [HEADER_NAME]: resolvedPublicKey } : {}), [headersInput, resolvedPublicKey]);
|
|
3548
3549
|
if (!runtimeUrl && !resolvedPublicKey && !hasLocalAgents) {
|
|
3549
3550
|
const message = "Missing required prop: 'runtimeUrl' or 'publicApiKey' or 'publicLicenseKey'";
|
|
3550
3551
|
if (process.env.NODE_ENV === "production") throw new Error(message);
|
|
@@ -3669,7 +3670,7 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
3669
3670
|
runtimeUrl: chatApiEndpoint,
|
|
3670
3671
|
deferInitialConnection: true,
|
|
3671
3672
|
runtimeTransport: useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto",
|
|
3672
|
-
headers:
|
|
3673
|
+
headers: headersSource,
|
|
3673
3674
|
credentials,
|
|
3674
3675
|
messageFilter,
|
|
3675
3676
|
properties,
|
|
@@ -3764,7 +3765,7 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
3764
3765
|
(0, react.useEffect)(() => {
|
|
3765
3766
|
copilotkit.setRuntimeUrl(chatApiEndpoint);
|
|
3766
3767
|
copilotkit.setRuntimeTransport(useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto");
|
|
3767
|
-
copilotkit.setHeaders(
|
|
3768
|
+
copilotkit.setHeaders(headersSource);
|
|
3768
3769
|
copilotkit.setCredentials(credentials);
|
|
3769
3770
|
copilotkit.setProperties(a2uiCatalogProvided ? {
|
|
3770
3771
|
...properties,
|
|
@@ -3776,7 +3777,7 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
3776
3777
|
}, [
|
|
3777
3778
|
copilotkit,
|
|
3778
3779
|
chatApiEndpoint,
|
|
3779
|
-
|
|
3780
|
+
headersSource,
|
|
3780
3781
|
credentials,
|
|
3781
3782
|
properties,
|
|
3782
3783
|
a2uiCatalogProvided,
|
|
@@ -3785,15 +3786,25 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
3785
3786
|
debug
|
|
3786
3787
|
]);
|
|
3787
3788
|
const learningEnabled = learningConfig !== void 0;
|
|
3788
|
-
const
|
|
3789
|
-
const suppliedTrajectoryId = learningConfig?.trajectoryId;
|
|
3789
|
+
const autoStart = learningEnabled && (typeof learning !== "object" || learning.autoStart !== false);
|
|
3790
|
+
const suppliedTrajectoryId = autoStart ? learningConfig?.trajectoryId : void 0;
|
|
3791
|
+
const generatesTrajectoryId = autoStart && suppliedTrajectoryId === void 0;
|
|
3790
3792
|
const learningContainerIdsRef = (0, react.useRef)(learningConfig?.learningContainerIds);
|
|
3791
3793
|
const generatedTrajectoryIdRef = (0, react.useRef)(void 0);
|
|
3792
3794
|
(0, react.useEffect)(() => {
|
|
3793
3795
|
copilotkit.setLearningConfig(learningConfig);
|
|
3794
3796
|
learningContainerIdsRef.current = learningConfig?.learningContainerIds;
|
|
3795
|
-
if (learningConfig?.sink === void 0 &&
|
|
3796
|
-
}, [
|
|
3797
|
+
if (learningConfig?.sink === void 0 && !autoStart && learningConfig?.learningContainerIds !== void 0) console.warn("[CopilotKit] learningContainerIds is supported only with a custom sink. Authenticated Trajectory capture does not assign Learning Containers; remove learningContainerIds from the capture options.");
|
|
3798
|
+
}, [
|
|
3799
|
+
copilotkit,
|
|
3800
|
+
learningConfig,
|
|
3801
|
+
autoStart
|
|
3802
|
+
]);
|
|
3803
|
+
const ignoresTrajectoryId = !autoStart && learningConfig?.trajectoryId !== void 0;
|
|
3804
|
+
(0, react.useEffect)(() => {
|
|
3805
|
+
if (!ignoresTrajectoryId) return;
|
|
3806
|
+
console.warn("[CopilotKit] learning.trajectoryId is ignored when autoStart is false; pass the ID to startTrajectory() instead.");
|
|
3807
|
+
}, [ignoresTrajectoryId]);
|
|
3797
3808
|
(0, react.useEffect)(() => {
|
|
3798
3809
|
if (!generatesTrajectoryId) generatedTrajectoryIdRef.current = void 0;
|
|
3799
3810
|
if (!learningEnabled) return;
|
|
@@ -3888,17 +3899,17 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
3888
3899
|
const hasNonReadyRuntimeEntitlement = runtimeEntitlements !== void 0 && runtimeEntitlements.status !== "ready";
|
|
3889
3900
|
const hasLegacyRuntimeEntitlementFallback = runtimeLicenseStatus === "valid" || runtimeLicenseStatus === "expiring";
|
|
3890
3901
|
const runtimeEntitlementRetryInProgress = retryableRuntimeEntitlementFailure && runtimeEntitlementRetryPending && !hasLegacyRuntimeEntitlementFallback;
|
|
3891
|
-
const
|
|
3902
|
+
const terminalRuntimeEntitlementFailure = hasNonReadyRuntimeEntitlement && !retryableRuntimeEntitlementFailure && !hasLegacyRuntimeEntitlementFallback;
|
|
3892
3903
|
const licenseContextValue = (0, react.useMemo)(() => {
|
|
3893
3904
|
const runtimeLicenseContext = (0, _copilotkit_shared.createLicenseContextValue)(runtimeEntitlementRetryInProgress ? void 0 : runtimeLicenseStatus, runtimeEntitlements);
|
|
3894
|
-
if (!
|
|
3905
|
+
if (!terminalRuntimeEntitlementFailure) return runtimeLicenseContext;
|
|
3895
3906
|
return {
|
|
3896
3907
|
...runtimeLicenseContext,
|
|
3897
3908
|
checkFeature: () => false,
|
|
3898
3909
|
getLimit: () => null
|
|
3899
3910
|
};
|
|
3900
3911
|
}, [
|
|
3901
|
-
|
|
3912
|
+
terminalRuntimeEntitlementFailure,
|
|
3902
3913
|
runtimeEntitlementRetryInProgress,
|
|
3903
3914
|
runtimeEntitlements,
|
|
3904
3915
|
runtimeLicenseStatus
|
|
@@ -5390,9 +5401,7 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
5390
5401
|
const hasMoreThreads = useThreadStoreSelector(store, _copilotkit_core.ɵselectHasNextPage);
|
|
5391
5402
|
const isFetchingMoreThreads = useThreadStoreSelector(store, _copilotkit_core.ɵselectIsFetchingNextPage);
|
|
5392
5403
|
const isMutating = useThreadStoreSelector(store, _copilotkit_core.ɵselectIsMutating);
|
|
5393
|
-
const headersKey =
|
|
5394
|
-
return JSON.stringify(Object.entries(copilotkit.headers ?? {}).sort(([left], [right]) => left.localeCompare(right)));
|
|
5395
|
-
}, [copilotkit.headers]);
|
|
5404
|
+
const headersKey = copilotkit.ɵheadersGeneration;
|
|
5396
5405
|
const runtimeStatus = copilotkit.runtimeConnectionStatus;
|
|
5397
5406
|
const threadListEndpointSupported = copilotkit.threadEndpoints?.list !== false;
|
|
5398
5407
|
const threadMutationsSupported = copilotkit.threadEndpoints?.mutations !== false;
|
|
@@ -5457,7 +5466,6 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
5457
5466
|
}
|
|
5458
5467
|
const context = {
|
|
5459
5468
|
runtimeUrl: copilotkit.runtimeUrl,
|
|
5460
|
-
headers: { ...copilotkit.headers },
|
|
5461
5469
|
wsUrl: copilotkit.intelligence?.wsUrl,
|
|
5462
5470
|
agentId,
|
|
5463
5471
|
includeArchived,
|
|
@@ -5585,7 +5593,9 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
5585
5593
|
*
|
|
5586
5594
|
* The function uses the same transport as `useLearnFromUserAction`:
|
|
5587
5595
|
* - `runtimeUrl` from `copilotkit.runtimeUrl` (BFF proxies to the platform)
|
|
5588
|
-
* - `
|
|
5596
|
+
* - `fetch: copilotkit.ɵruntimeFetch`, which adds the current core headers at
|
|
5597
|
+
* send time (#1937); `headers` here is only for extra request-specific
|
|
5598
|
+
* headers on top of that
|
|
5589
5599
|
* - `clientEventId` auto-generated via `randomUUID()` when omitted
|
|
5590
5600
|
* - `userId` is resolved server-side by the runtime; the client never sends it
|
|
5591
5601
|
* - Errors propagate to the caller (fire-and-propagate, not fire-and-forget)
|
|
@@ -5677,7 +5687,7 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
5677
5687
|
return recordAnnotation({
|
|
5678
5688
|
fetch: copilotkit.ɵruntimeFetch,
|
|
5679
5689
|
runtimeUrl,
|
|
5680
|
-
headers:
|
|
5690
|
+
headers: {},
|
|
5681
5691
|
type: "user_action",
|
|
5682
5692
|
payload: Object.keys(payload).length > 0 ? payload : void 0,
|
|
5683
5693
|
threadId: input.threadId,
|
|
@@ -6005,16 +6015,13 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
6005
6015
|
/** Guards the missing-runtimeUrl warning so it fires at most once per hook instance. */
|
|
6006
6016
|
const warnedMissingUrlRef = (0, react.useRef)(false);
|
|
6007
6017
|
const runtimeUrlRef = (0, react.useRef)(copilotkit.runtimeUrl);
|
|
6008
|
-
const headersRef = (0, react.useRef)(copilotkit.headers ?? {});
|
|
6009
6018
|
const runtimeFetchRef = (0, react.useRef)(copilotkit.ɵruntimeFetch);
|
|
6010
6019
|
runtimeUrlRef.current = copilotkit.runtimeUrl;
|
|
6011
|
-
headersRef.current = copilotkit.headers ?? {};
|
|
6012
6020
|
runtimeFetchRef.current = copilotkit.ɵruntimeFetch;
|
|
6013
6021
|
const key = JSON.stringify(learningContainers);
|
|
6014
6022
|
const defaultKey = JSON.stringify(DEFAULT_CONTAINERS);
|
|
6015
6023
|
(0, react.useEffect)(() => {
|
|
6016
6024
|
const runtimeUrl = copilotkit.runtimeUrl;
|
|
6017
|
-
const headers = copilotkit.headers ?? {};
|
|
6018
6025
|
/**
|
|
6019
6026
|
* Fire-and-forget emit; errors must not surface in render.
|
|
6020
6027
|
* Failures are logged as warnings so they are diagnosable without
|
|
@@ -6031,7 +6038,7 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
6031
6038
|
recordAnnotation({
|
|
6032
6039
|
fetch: copilotkit.ɵruntimeFetch,
|
|
6033
6040
|
runtimeUrl,
|
|
6034
|
-
headers,
|
|
6041
|
+
headers: {},
|
|
6035
6042
|
type: "set_learning_containers",
|
|
6036
6043
|
payload: { containers },
|
|
6037
6044
|
threadId
|
|
@@ -6055,11 +6062,10 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
6055
6062
|
const capturedThreadId = threadId;
|
|
6056
6063
|
return () => {
|
|
6057
6064
|
const capturedRuntimeUrl = runtimeUrlRef.current;
|
|
6058
|
-
const capturedHeaders = headersRef.current;
|
|
6059
6065
|
if (capturedRuntimeUrl) recordAnnotation({
|
|
6060
6066
|
fetch: runtimeFetchRef.current,
|
|
6061
6067
|
runtimeUrl: capturedRuntimeUrl,
|
|
6062
|
-
headers:
|
|
6068
|
+
headers: {},
|
|
6063
6069
|
type: "set_learning_containers",
|
|
6064
6070
|
payload: { containers: DEFAULT_CONTAINERS },
|
|
6065
6071
|
threadId: capturedThreadId
|
|
@@ -8865,7 +8871,7 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
8865
8871
|
message: "Runtime URL is not configured",
|
|
8866
8872
|
retryable: false
|
|
8867
8873
|
});
|
|
8868
|
-
const headers = { ...core.
|
|
8874
|
+
const headers = { ...await core.resolveHeaders() };
|
|
8869
8875
|
let response;
|
|
8870
8876
|
try {
|
|
8871
8877
|
if (core.runtimeTransport === "single") {
|
|
@@ -9277,7 +9283,6 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
9277
9283
|
threadStore.start();
|
|
9278
9284
|
const context = copilotkit.runtimeUrl ? {
|
|
9279
9285
|
runtimeUrl: copilotkit.runtimeUrl,
|
|
9280
|
-
headers: { ...copilotkit.headers },
|
|
9281
9286
|
wsUrl: copilotkit.intelligence?.wsUrl,
|
|
9282
9287
|
agentId: resolvedAgentId
|
|
9283
9288
|
} : null;
|
|
@@ -9373,7 +9378,7 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
9373
9378
|
hasNativeIntelligenceRunActivity,
|
|
9374
9379
|
copilotkit.runtimeConnectionStatus,
|
|
9375
9380
|
copilotkit.runtimeUrl,
|
|
9376
|
-
copilotkit
|
|
9381
|
+
copilotkit.ɵheadersGeneration,
|
|
9377
9382
|
copilotkit.intelligence?.wsUrl,
|
|
9378
9383
|
copilotkit.threadEndpoints?.realtimeMetadata,
|
|
9379
9384
|
standaloneRunActivityStore,
|
|
@@ -12250,6 +12255,16 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
12250
12255
|
|
|
12251
12256
|
//#endregion
|
|
12252
12257
|
//#region src/v1-deprecated/components/copilot-provider/copilotkit.tsx
|
|
12258
|
+
/**
|
|
12259
|
+
* Drops `null`/`undefined` entries so a `CopilotKitHeadersSource` record (or
|
|
12260
|
+
* a builder's resolved record) matches `CopilotApiConfig.headers`'s
|
|
12261
|
+
* `Record<string, string>` shape. Mirrors core's own (internal-only)
|
|
12262
|
+
* `normalizeHeaders`.
|
|
12263
|
+
*/
|
|
12264
|
+
function normalizeV1Headers(headers) {
|
|
12265
|
+
if (!headers) return {};
|
|
12266
|
+
return Object.fromEntries(Object.entries(headers).filter((entry) => entry[1] != null));
|
|
12267
|
+
}
|
|
12253
12268
|
function CopilotKit({ children, ...props }) {
|
|
12254
12269
|
const enabled = shouldShowDevConsole(props.showDevConsole);
|
|
12255
12270
|
const publicApiKey = props.publicApiKey || props.publicLicenseKey;
|
|
@@ -12329,6 +12344,13 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
12329
12344
|
* This will throw an error if the props are invalid.
|
|
12330
12345
|
*/
|
|
12331
12346
|
validateProps(cpkProps);
|
|
12347
|
+
const headersPropRef = (0, react.useRef)(props.headers);
|
|
12348
|
+
headersPropRef.current = props.headers;
|
|
12349
|
+
const headersBuilderStateRef = (0, react.useRef)({
|
|
12350
|
+
fn: void 0,
|
|
12351
|
+
isAsync: false
|
|
12352
|
+
});
|
|
12353
|
+
const warnedAsyncHeadersRef = (0, react.useRef)(false);
|
|
12332
12354
|
const publicApiKey = props.publicLicenseKey || props.publicApiKey;
|
|
12333
12355
|
const chatApiEndpoint = props.runtimeUrl || _copilotkit_shared.COPILOT_CLOUD_CHAT_URL;
|
|
12334
12356
|
const [actions, setActions] = (0, react.useState)({});
|
|
@@ -12396,19 +12418,46 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
12396
12418
|
validTopics: props.guardrails_c?.validTopics || [],
|
|
12397
12419
|
invalidTopics: props.guardrails_c?.invalidTopics || []
|
|
12398
12420
|
} } } };
|
|
12399
|
-
|
|
12421
|
+
const config = {
|
|
12400
12422
|
publicApiKey,
|
|
12401
12423
|
...cloud ? { cloud } : {},
|
|
12402
12424
|
chatApiEndpoint,
|
|
12403
|
-
headers: typeof props.headers === "function" ? props.headers() : props.headers || {},
|
|
12404
12425
|
properties: props.properties || {},
|
|
12405
12426
|
transcribeAudioUrl: props.transcribeAudioUrl,
|
|
12406
12427
|
textToSpeechUrl: props.textToSpeechUrl,
|
|
12407
12428
|
credentials: props.credentials
|
|
12408
12429
|
};
|
|
12430
|
+
Object.defineProperty(config, "headers", {
|
|
12431
|
+
enumerable: true,
|
|
12432
|
+
configurable: true,
|
|
12433
|
+
get() {
|
|
12434
|
+
const source = headersPropRef.current;
|
|
12435
|
+
if (typeof source !== "function") return normalizeV1Headers(source);
|
|
12436
|
+
const state = headersBuilderStateRef.current;
|
|
12437
|
+
if (state.fn === source && state.isAsync) return {};
|
|
12438
|
+
const result = source();
|
|
12439
|
+
if (typeof result === "object" && result !== null && typeof result.then === "function") {
|
|
12440
|
+
headersBuilderStateRef.current = {
|
|
12441
|
+
fn: source,
|
|
12442
|
+
isAsync: true
|
|
12443
|
+
};
|
|
12444
|
+
result.then(void 0, () => {});
|
|
12445
|
+
if (process.env.NODE_ENV !== "production" && !warnedAsyncHeadersRef.current) {
|
|
12446
|
+
warnedAsyncHeadersRef.current = true;
|
|
12447
|
+
console.warn("[CopilotKit] An async `headers` builder is not supported by the v1 CopilotTask / GraphQL path; its headers are not sent there.");
|
|
12448
|
+
}
|
|
12449
|
+
return {};
|
|
12450
|
+
}
|
|
12451
|
+
headersBuilderStateRef.current = {
|
|
12452
|
+
fn: source,
|
|
12453
|
+
isAsync: false
|
|
12454
|
+
};
|
|
12455
|
+
return normalizeV1Headers(result);
|
|
12456
|
+
}
|
|
12457
|
+
});
|
|
12458
|
+
return config;
|
|
12409
12459
|
}, [
|
|
12410
12460
|
publicApiKey,
|
|
12411
|
-
props.headers,
|
|
12412
12461
|
props.properties,
|
|
12413
12462
|
props.transcribeAudioUrl,
|
|
12414
12463
|
props.textToSpeechUrl,
|
|
@@ -12416,27 +12465,6 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
12416
12465
|
props.cloudRestrictToTopic,
|
|
12417
12466
|
props.guardrails_c
|
|
12418
12467
|
]);
|
|
12419
|
-
(0, react.useMemo)(() => {
|
|
12420
|
-
const authHeaders = Object.values(authStates || {}).reduce((acc, state) => {
|
|
12421
|
-
if (state.status === "authenticated" && state.authHeaders) return {
|
|
12422
|
-
...acc,
|
|
12423
|
-
...Object.entries(state.authHeaders).reduce((headers, [key, value]) => ({
|
|
12424
|
-
...headers,
|
|
12425
|
-
[key.startsWith("X-Custom-") ? key : `X-Custom-${key}`]: value
|
|
12426
|
-
}), {})
|
|
12427
|
-
};
|
|
12428
|
-
return acc;
|
|
12429
|
-
}, {});
|
|
12430
|
-
return {
|
|
12431
|
-
...copilotApiConfig.headers,
|
|
12432
|
-
...copilotApiConfig.publicApiKey ? { [_copilotkit_shared.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey } : {},
|
|
12433
|
-
...authHeaders
|
|
12434
|
-
};
|
|
12435
|
-
}, [
|
|
12436
|
-
copilotApiConfig.headers,
|
|
12437
|
-
copilotApiConfig.publicApiKey,
|
|
12438
|
-
authStates
|
|
12439
|
-
]);
|
|
12440
12468
|
const [internalErrorHandlers, _setInternalErrorHandler] = (0, react.useState)({});
|
|
12441
12469
|
const setInternalErrorHandler = (0, react.useCallback)((handler) => {
|
|
12442
12470
|
_setInternalErrorHandler((prev) => ({
|
|
@@ -12950,6 +12978,12 @@ Object.defineProperty(exports, 'CopilotKitCoreRuntimeConnectionStatus', {
|
|
|
12950
12978
|
return _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus;
|
|
12951
12979
|
}
|
|
12952
12980
|
});
|
|
12981
|
+
Object.defineProperty(exports, 'CopilotKitHeaderResolutionError', {
|
|
12982
|
+
enumerable: true,
|
|
12983
|
+
get: function () {
|
|
12984
|
+
return _copilotkit_core.CopilotKitHeaderResolutionError;
|
|
12985
|
+
}
|
|
12986
|
+
});
|
|
12953
12987
|
exports.CopilotKitInspector = CopilotKitInspector;
|
|
12954
12988
|
exports.CopilotKitProvider = CopilotKitProvider;
|
|
12955
12989
|
Object.defineProperty(exports, 'CopilotModalHeader', {
|
|
@@ -14289,5 +14323,11 @@ Object.defineProperty(exports, 'ɵthreadAdapterEvents', {
|
|
|
14289
14323
|
return _copilotkit_core.ɵthreadAdapterEvents;
|
|
14290
14324
|
}
|
|
14291
14325
|
});
|
|
14326
|
+
Object.defineProperty(exports, 'ɵwithHeaderDefaults', {
|
|
14327
|
+
enumerable: true,
|
|
14328
|
+
get: function () {
|
|
14329
|
+
return _copilotkit_core.ɵwithHeaderDefaults;
|
|
14330
|
+
}
|
|
14331
|
+
});
|
|
14292
14332
|
});
|
|
14293
14333
|
//# sourceMappingURL=index.umd.js.map
|