@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/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_copilotkit = require('./copilotkit-BFeenQQ0.cjs');
4
+ const require_copilotkit = require('./copilotkit-t6Gs-59F.cjs');
5
5
  let react = require("react");
6
6
  react = require_copilotkit.__toESM(react);
7
7
  let _copilotkit_core = require("@copilotkit/core");
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { Af as Tree, Bf as FrontendActionAvailability, Cf as CrewsResponseStatus, Df as CopilotChatSuggestionConfiguration, Ef as CrewsToolStateItem, Ff as ActionRenderPropsWait, If as CatchAllActionRenderProps, Lf as CatchAllActionRenderPropsWait, Mf as ActionRenderProps, Nf as ActionRenderPropsNoArgs, Of as SystemMessageFunction, Pf as ActionRenderPropsNoArgsWait, Rf as CatchAllFrontendAction, Sf as CrewsResponse, Tf as CrewsTaskStateItem, Vf as RenderFunctionStatus, X as useAgent, _f as LangGraphInterruptRender, bf as QueuedInterruptEvent, cf as CoagentInChatRenderFunction, df as CopilotContextParams, ff as useCopilotContext, gf as LangGraphInterruptActionSetterArgs, hf as LangGraphInterruptActionSetter, jf as TreeNode, kf as DocumentPointer, lf as CopilotApiConfig, mf as LangGraphInterruptAction, n as defaultCopilotContextCategories, pf as CoAgentStateRender, r as CopilotKitProps, t as CopilotKit, uf as CopilotContext, vf as LangGraphInterruptRenderHandlerProps, wf as CrewsStateItem, xf as CrewsAgentState, xt as useRenderToolCall$1, yf as LangGraphInterruptRenderProps, zf as FrontendAction } from "./copilotkit-gn5p8gXk.cjs";
1
+ import { Af as CrewsTaskStateItem, Bf as ActionRenderPropsWait, Cf as LangGraphInterruptRenderHandlerProps, Df as CrewsResponse, Ef as CrewsAgentState, Ff as Tree, Gf as FrontendActionAvailability, Hf as CatchAllActionRenderPropsWait, If as TreeNode, Kf as RenderFunctionStatus, Lf as ActionRenderProps, Mf as CopilotChatSuggestionConfiguration, Nf as SystemMessageFunction, Of as CrewsResponseStatus, Pf as DocumentPointer, Rf as ActionRenderPropsNoArgs, Sf as LangGraphInterruptRender, Tf as QueuedInterruptEvent, Uf as CatchAllFrontendAction, Vf as CatchAllActionRenderProps, Wf as FrontendAction, X as useAgent, _f as useCopilotContext, bf as LangGraphInterruptActionSetter, gf as CopilotContextParams, hf as CopilotContext, jf as CrewsToolStateItem, kf as CrewsStateItem, mf as CopilotApiConfig, n as defaultCopilotContextCategories, pf as CoagentInChatRenderFunction, r as CopilotKitProps, t as CopilotKit, vf as CoAgentStateRender, wf as LangGraphInterruptRenderProps, xf as LangGraphInterruptActionSetterArgs, xt as useRenderToolCall$1, yf as LangGraphInterruptAction, zf as ActionRenderPropsNoArgsWait } from "./copilotkit-BA0vyDds.cjs";
2
2
  import "./v2/index.cjs";
3
3
  import * as react_jsx_runtime0 from "react/jsx-runtime";
4
4
  import { CopilotRuntimeClient, CopilotRuntimeClientOptions, ForwardedParametersInput, Message } from "@copilotkit/runtime-client-gql";
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Af as Tree, Bf as FrontendActionAvailability, Cf as CrewsResponseStatus, Df as CopilotChatSuggestionConfiguration, Ef as CrewsToolStateItem, Ff as ActionRenderPropsWait, If as CatchAllActionRenderProps, Lf as CatchAllActionRenderPropsWait, Mf as ActionRenderProps, Nf as ActionRenderPropsNoArgs, Of as SystemMessageFunction, Pf as ActionRenderPropsNoArgsWait, Rf as CatchAllFrontendAction, Sf as CrewsResponse, Tf as CrewsTaskStateItem, Vf as RenderFunctionStatus, X as useAgent, _f as LangGraphInterruptRender, bf as QueuedInterruptEvent, cf as CoagentInChatRenderFunction, df as CopilotContextParams, ff as useCopilotContext, gf as LangGraphInterruptActionSetterArgs, hf as LangGraphInterruptActionSetter, jf as TreeNode, kf as DocumentPointer, lf as CopilotApiConfig, mf as LangGraphInterruptAction, n as defaultCopilotContextCategories, pf as CoAgentStateRender, r as CopilotKitProps, t as CopilotKit, uf as CopilotContext, vf as LangGraphInterruptRenderHandlerProps, wf as CrewsStateItem, xf as CrewsAgentState, xt as useRenderToolCall$1, yf as LangGraphInterruptRenderProps, zf as FrontendAction } from "./copilotkit-D1y8IyXh.mjs";
1
+ import { Af as CrewsTaskStateItem, Bf as ActionRenderPropsWait, Cf as LangGraphInterruptRenderHandlerProps, Df as CrewsResponse, Ef as CrewsAgentState, Ff as Tree, Gf as FrontendActionAvailability, Hf as CatchAllActionRenderPropsWait, If as TreeNode, Kf as RenderFunctionStatus, Lf as ActionRenderProps, Mf as CopilotChatSuggestionConfiguration, Nf as SystemMessageFunction, Of as CrewsResponseStatus, Pf as DocumentPointer, Rf as ActionRenderPropsNoArgs, Sf as LangGraphInterruptRender, Tf as QueuedInterruptEvent, Uf as CatchAllFrontendAction, Vf as CatchAllActionRenderProps, Wf as FrontendAction, X as useAgent, _f as useCopilotContext, bf as LangGraphInterruptActionSetter, gf as CopilotContextParams, hf as CopilotContext, jf as CrewsToolStateItem, kf as CrewsStateItem, mf as CopilotApiConfig, n as defaultCopilotContextCategories, pf as CoagentInChatRenderFunction, r as CopilotKitProps, t as CopilotKit, vf as CoAgentStateRender, wf as LangGraphInterruptRenderProps, xf as LangGraphInterruptActionSetterArgs, xt as useRenderToolCall$1, yf as LangGraphInterruptAction, zf as ActionRenderPropsNoArgsWait } from "./copilotkit-kcYN96tM.mjs";
2
2
  import "./v2/index.mjs";
3
3
  import React, { ReactNode, RefObject, SetStateAction } from "react";
4
4
  import { StaticSuggestionsConfig, Suggestion } from "@copilotkit/core";
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { $ as useConfigureSuggestions, It as useCopilotChatConfiguration, Q as INTERRUPT_EVENT_NAME, Z as useInterrupt, _t as defineToolCallRenderer, a as ThreadsProvider, at as useHumanInTheLoop$1, c as CoAgentStateRendersProvider, d as shouldShowDevConsole, et as useSuggestions, f as useToast, ft as useRenderCustomMessages, g as useCopilotContext, h as CopilotContext, i as ThreadsContext, it as useAgent, jt as useRenderToolCall$1, l as useCoAgentStateRenders, m as useCopilotMessagesContext, mt as useCopilotKit, n as defaultCopilotContextCategories, o as useThreads, p as CopilotMessagesContext, r as CoAgentStateRenderBridge, s as CoAgentStateRendersContext, t as CopilotKit, u as useAsyncCallback, ut as useFrontendTool$1 } from "./copilotkit-DgJj6xa0.mjs";
3
+ import { $ as useConfigureSuggestions, It as useCopilotChatConfiguration, Q as INTERRUPT_EVENT_NAME, Z as useInterrupt, _t as defineToolCallRenderer, a as ThreadsProvider, at as useHumanInTheLoop$1, c as CoAgentStateRendersProvider, d as shouldShowDevConsole, et as useSuggestions, f as useToast, ft as useRenderCustomMessages, g as useCopilotContext, h as CopilotContext, i as ThreadsContext, it as useAgent, jt as useRenderToolCall$1, l as useCoAgentStateRenders, m as useCopilotMessagesContext, mt as useCopilotKit, n as defaultCopilotContextCategories, o as useThreads, p as CopilotMessagesContext, r as CoAgentStateRenderBridge, s as CoAgentStateRendersContext, t as CopilotKit, u as useAsyncCallback, ut as useFrontendTool$1 } from "./copilotkit-DtOQtboh.mjs";
4
4
  import React, { Fragment, createElement, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
5
5
  import { CopilotKitCoreRuntimeConnectionStatus, ToolCallStatus, ɵisHttpAgent } from "@copilotkit/core";
6
6
  import { AGUIConnectNotImplementedError } from "@ag-ui/client";
package/dist/index.umd.js CHANGED
@@ -602,7 +602,7 @@ react_markdown = __toESM(react_markdown);
602
602
 
603
603
  //#endregion
604
604
  //#region package.json
605
- var version = "1.78.0";
605
+ var version = "1.79.1-canary.1792034358";
606
606
 
607
607
  //#endregion
608
608
  //#region src/v2/components/CopilotKitInspector.tsx
@@ -2341,15 +2341,15 @@ react_markdown = __toESM(react_markdown);
2341
2341
  (0, react.useEffect)(() => {
2342
2342
  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.");
2343
2343
  }, [hasSelfManagedAgents, resolvedPublicKey]);
2344
- const headers = typeof headersProp === "function" ? headersProp() : headersProp;
2345
- const mergedHeaders = (0, react.useMemo)(() => {
2346
- if (!resolvedPublicKey) return headers;
2347
- if (headers[HEADER_NAME]) return headers;
2348
- return {
2349
- ...headers,
2350
- [HEADER_NAME]: resolvedPublicKey
2351
- };
2352
- }, [headers, resolvedPublicKey]);
2344
+ const headersRef = (0, react.useRef)(headersProp);
2345
+ headersRef.current = headersProp;
2346
+ const isHeadersBuilder = typeof headersProp === "function";
2347
+ const stableHeadersBuilder = (0, react.useCallback)(() => {
2348
+ const current = headersRef.current;
2349
+ return typeof current === "function" ? current() : current;
2350
+ }, []);
2351
+ const headersInput = isHeadersBuilder ? stableHeadersBuilder : headersProp;
2352
+ const headersSource = (0, react.useMemo)(() => (0, _copilotkit_core.ɵwithHeaderDefaults)(headersInput, resolvedPublicKey ? { [HEADER_NAME]: resolvedPublicKey } : {}), [headersInput, resolvedPublicKey]);
2353
2353
  if (!runtimeUrl && !resolvedPublicKey && !hasLocalAgents) {
2354
2354
  const message = "Missing required prop: 'runtimeUrl' or 'publicApiKey' or 'publicLicenseKey'";
2355
2355
  if (process.env.NODE_ENV === "production") throw new Error(message);
@@ -2474,7 +2474,7 @@ react_markdown = __toESM(react_markdown);
2474
2474
  runtimeUrl: chatApiEndpoint,
2475
2475
  deferInitialConnection: true,
2476
2476
  runtimeTransport: useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto",
2477
- headers: mergedHeaders,
2477
+ headers: headersSource,
2478
2478
  credentials,
2479
2479
  messageFilter,
2480
2480
  properties,
@@ -2569,7 +2569,7 @@ react_markdown = __toESM(react_markdown);
2569
2569
  (0, react.useEffect)(() => {
2570
2570
  copilotkit.setRuntimeUrl(chatApiEndpoint);
2571
2571
  copilotkit.setRuntimeTransport(useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto");
2572
- copilotkit.setHeaders(mergedHeaders);
2572
+ copilotkit.setHeaders(headersSource);
2573
2573
  copilotkit.setCredentials(credentials);
2574
2574
  copilotkit.setProperties(a2uiCatalogProvided ? {
2575
2575
  ...properties,
@@ -2581,7 +2581,7 @@ react_markdown = __toESM(react_markdown);
2581
2581
  }, [
2582
2582
  copilotkit,
2583
2583
  chatApiEndpoint,
2584
- mergedHeaders,
2584
+ headersSource,
2585
2585
  credentials,
2586
2586
  properties,
2587
2587
  a2uiCatalogProvided,
@@ -2598,7 +2598,7 @@ react_markdown = __toESM(react_markdown);
2598
2598
  (0, react.useEffect)(() => {
2599
2599
  copilotkit.setLearningConfig(learningConfig);
2600
2600
  learningContainerIdsRef.current = learningConfig?.learningContainerIds;
2601
- 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.");
2601
+ 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.");
2602
2602
  }, [
2603
2603
  copilotkit,
2604
2604
  learningConfig,
@@ -5281,6 +5281,16 @@ react_markdown = __toESM(react_markdown);
5281
5281
 
5282
5282
  //#endregion
5283
5283
  //#region src/v1-deprecated/components/copilot-provider/copilotkit.tsx
5284
+ /**
5285
+ * Drops `null`/`undefined` entries so a `CopilotKitHeadersSource` record (or
5286
+ * a builder's resolved record) matches `CopilotApiConfig.headers`'s
5287
+ * `Record<string, string>` shape. Mirrors core's own (internal-only)
5288
+ * `normalizeHeaders`.
5289
+ */
5290
+ function normalizeV1Headers(headers) {
5291
+ if (!headers) return {};
5292
+ return Object.fromEntries(Object.entries(headers).filter((entry) => entry[1] != null));
5293
+ }
5284
5294
  function CopilotKit({ children, ...props }) {
5285
5295
  const enabled = shouldShowDevConsole(props.showDevConsole);
5286
5296
  const publicApiKey = props.publicApiKey || props.publicLicenseKey;
@@ -5360,6 +5370,13 @@ react_markdown = __toESM(react_markdown);
5360
5370
  * This will throw an error if the props are invalid.
5361
5371
  */
5362
5372
  validateProps(cpkProps);
5373
+ const headersPropRef = (0, react.useRef)(props.headers);
5374
+ headersPropRef.current = props.headers;
5375
+ const headersBuilderStateRef = (0, react.useRef)({
5376
+ fn: void 0,
5377
+ isAsync: false
5378
+ });
5379
+ const warnedAsyncHeadersRef = (0, react.useRef)(false);
5363
5380
  const publicApiKey = props.publicLicenseKey || props.publicApiKey;
5364
5381
  const chatApiEndpoint = props.runtimeUrl || _copilotkit_shared.COPILOT_CLOUD_CHAT_URL;
5365
5382
  const [actions, setActions] = (0, react.useState)({});
@@ -5427,19 +5444,46 @@ react_markdown = __toESM(react_markdown);
5427
5444
  validTopics: props.guardrails_c?.validTopics || [],
5428
5445
  invalidTopics: props.guardrails_c?.invalidTopics || []
5429
5446
  } } } };
5430
- return {
5447
+ const config = {
5431
5448
  publicApiKey,
5432
5449
  ...cloud ? { cloud } : {},
5433
5450
  chatApiEndpoint,
5434
- headers: typeof props.headers === "function" ? props.headers() : props.headers || {},
5435
5451
  properties: props.properties || {},
5436
5452
  transcribeAudioUrl: props.transcribeAudioUrl,
5437
5453
  textToSpeechUrl: props.textToSpeechUrl,
5438
5454
  credentials: props.credentials
5439
5455
  };
5456
+ Object.defineProperty(config, "headers", {
5457
+ enumerable: true,
5458
+ configurable: true,
5459
+ get() {
5460
+ const source = headersPropRef.current;
5461
+ if (typeof source !== "function") return normalizeV1Headers(source);
5462
+ const state = headersBuilderStateRef.current;
5463
+ if (state.fn === source && state.isAsync) return {};
5464
+ const result = source();
5465
+ if (typeof result === "object" && result !== null && typeof result.then === "function") {
5466
+ headersBuilderStateRef.current = {
5467
+ fn: source,
5468
+ isAsync: true
5469
+ };
5470
+ result.then(void 0, () => {});
5471
+ if (process.env.NODE_ENV !== "production" && !warnedAsyncHeadersRef.current) {
5472
+ warnedAsyncHeadersRef.current = true;
5473
+ console.warn("[CopilotKit] An async `headers` builder is not supported by the v1 CopilotTask / GraphQL path; its headers are not sent there.");
5474
+ }
5475
+ return {};
5476
+ }
5477
+ headersBuilderStateRef.current = {
5478
+ fn: source,
5479
+ isAsync: false
5480
+ };
5481
+ return normalizeV1Headers(result);
5482
+ }
5483
+ });
5484
+ return config;
5440
5485
  }, [
5441
5486
  publicApiKey,
5442
- props.headers,
5443
5487
  props.properties,
5444
5488
  props.transcribeAudioUrl,
5445
5489
  props.textToSpeechUrl,
@@ -5447,27 +5491,6 @@ react_markdown = __toESM(react_markdown);
5447
5491
  props.cloudRestrictToTopic,
5448
5492
  props.guardrails_c
5449
5493
  ]);
5450
- (0, react.useMemo)(() => {
5451
- const authHeaders = Object.values(authStates || {}).reduce((acc, state) => {
5452
- if (state.status === "authenticated" && state.authHeaders) return {
5453
- ...acc,
5454
- ...Object.entries(state.authHeaders).reduce((headers, [key, value]) => ({
5455
- ...headers,
5456
- [key.startsWith("X-Custom-") ? key : `X-Custom-${key}`]: value
5457
- }), {})
5458
- };
5459
- return acc;
5460
- }, {});
5461
- return {
5462
- ...copilotApiConfig.headers,
5463
- ...copilotApiConfig.publicApiKey ? { [_copilotkit_shared.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey } : {},
5464
- ...authHeaders
5465
- };
5466
- }, [
5467
- copilotApiConfig.headers,
5468
- copilotApiConfig.publicApiKey,
5469
- authStates
5470
- ]);
5471
5494
  const [internalErrorHandlers, _setInternalErrorHandler] = (0, react.useState)({});
5472
5495
  const setInternalErrorHandler = (0, react.useCallback)((handler) => {
5473
5496
  _setInternalErrorHandler((prev) => ({