@copilotkit/react-core 1.60.1 → 1.61.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.
Files changed (40) hide show
  1. package/dist/{copilotkit-CV519nFv.mjs → copilotkit-BCxdKlMw.mjs} +60 -153
  2. package/dist/copilotkit-BCxdKlMw.mjs.map +1 -0
  3. package/dist/{copilotkit-C9ptuh-b.d.cts → copilotkit-CEdu_aie.d.cts} +29 -7
  4. package/dist/{copilotkit-DvbI8G0d.d.mts.map → copilotkit-CEdu_aie.d.cts.map} +1 -1
  5. package/dist/{copilotkit-BTHcCAVQ.cjs → copilotkit-DtPCrXXd.cjs} +60 -153
  6. package/dist/copilotkit-DtPCrXXd.cjs.map +1 -0
  7. package/dist/{copilotkit-DvbI8G0d.d.mts → copilotkit-M1FiciGd.d.mts} +29 -7
  8. package/dist/{copilotkit-C9ptuh-b.d.cts.map → copilotkit-M1FiciGd.d.mts.map} +1 -1
  9. package/dist/index.cjs +6 -6
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +3 -3
  12. package/dist/index.d.mts +3 -3
  13. package/dist/index.mjs +6 -6
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/index.umd.js +61 -149
  16. package/dist/index.umd.js.map +1 -1
  17. package/dist/v2/context.cjs +8 -3
  18. package/dist/v2/context.cjs.map +1 -1
  19. package/dist/v2/context.d.cts.map +1 -1
  20. package/dist/v2/context.d.mts.map +1 -1
  21. package/dist/v2/context.mjs +8 -3
  22. package/dist/v2/context.mjs.map +1 -1
  23. package/dist/v2/headless.cjs +23 -12
  24. package/dist/v2/headless.cjs.map +1 -1
  25. package/dist/v2/headless.d.cts +25 -3
  26. package/dist/v2/headless.d.cts.map +1 -1
  27. package/dist/v2/headless.d.mts +25 -3
  28. package/dist/v2/headless.d.mts.map +1 -1
  29. package/dist/v2/headless.mjs +24 -13
  30. package/dist/v2/headless.mjs.map +1 -1
  31. package/dist/v2/index.cjs +1 -1
  32. package/dist/v2/index.css +1 -1
  33. package/dist/v2/index.d.cts +1 -1
  34. package/dist/v2/index.d.mts +1 -1
  35. package/dist/v2/index.mjs +1 -1
  36. package/dist/v2/index.umd.js +59 -152
  37. package/dist/v2/index.umd.js.map +1 -1
  38. package/package.json +6 -6
  39. package/dist/copilotkit-BTHcCAVQ.cjs.map +0 -1
  40. package/dist/copilotkit-CV519nFv.mjs.map +0 -1
package/dist/index.umd.js CHANGED
@@ -306,9 +306,14 @@ react_markdown = __toESM(react_markdown);
306
306
  const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
307
307
  if (!context) throw new Error("useCopilotKit must be used within CopilotKitProvider");
308
308
  (0, react.useEffect)(() => {
309
- const subscription = context.copilotkit.subscribe({ onRuntimeConnectionStatusChanged: () => {
310
- forceUpdate();
311
- } });
309
+ const subscription = context.copilotkit.subscribe({
310
+ onRuntimeConnectionStatusChanged: () => {
311
+ forceUpdate();
312
+ },
313
+ onHeadersChanged: () => {
314
+ forceUpdate();
315
+ }
316
+ });
312
317
  return () => {
313
318
  subscription.unsubscribe();
314
319
  };
@@ -385,9 +390,8 @@ react_markdown = __toESM(react_markdown);
385
390
  const isActive = status === "inProgress" || status === "executing";
386
391
  const isComplete = status === "complete";
387
392
  const statusLabel = isActive ? "Running" : isComplete ? "Done" : status;
388
- const dotColor = isActive ? "#f59e0b" : isComplete ? "#10b981" : "#a1a1aa";
389
- const badgeBg = isActive ? "#fef3c7" : isComplete ? "#d1fae5" : "#f4f4f5";
390
- const badgeColor = isActive ? "#92400e" : isComplete ? "#065f46" : "#3f3f46";
393
+ const dotClassName = isActive ? "cpk:bg-amber-500" : isComplete ? "cpk:bg-emerald-500" : "cpk:bg-zinc-400";
394
+ const badgeClassName = isActive ? "cpk:bg-amber-100 cpk:text-amber-800 cpk:dark:bg-amber-500/15 cpk:dark:text-amber-400" : isComplete ? "cpk:bg-emerald-100 cpk:text-emerald-800 cpk:dark:bg-emerald-500/15 cpk:dark:text-emerald-400" : "cpk:bg-zinc-100 cpk:text-zinc-800 cpk:dark:bg-zinc-700/40 cpk:dark:text-zinc-300";
391
395
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
392
396
  "data-testid": "copilot-tool-render",
393
397
  "data-tool-name": name,
@@ -395,54 +399,20 @@ react_markdown = __toESM(react_markdown);
395
399
  "data-status": status,
396
400
  "data-args": safeStringifyForAttr(parameters),
397
401
  "data-result": safeStringifyForAttr(result),
398
- style: {
399
- marginTop: "8px",
400
- paddingBottom: "8px"
401
- },
402
+ className: "cpk:mt-2 cpk:pb-2",
402
403
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
403
- style: {
404
- borderRadius: "12px",
405
- border: "1px solid #e4e4e7",
406
- backgroundColor: "#fafafa",
407
- padding: "14px 16px"
408
- },
404
+ className: "cpk:rounded-xl cpk:border cpk:border-zinc-200/60 cpk:bg-white/70 cpk:p-4 cpk:shadow-sm cpk:backdrop-blur cpk:dark:border-zinc-800/60 cpk:dark:bg-zinc-900/50",
409
405
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
410
406
  type: "button",
411
407
  "aria-expanded": isExpanded,
412
408
  onClick: () => setIsExpanded(!isExpanded),
413
- style: {
414
- display: "flex",
415
- alignItems: "center",
416
- justifyContent: "space-between",
417
- gap: "10px",
418
- cursor: "pointer",
419
- userSelect: "none",
420
- width: "100%",
421
- border: "none",
422
- padding: 0,
423
- margin: 0,
424
- background: "transparent",
425
- textAlign: "left",
426
- font: "inherit",
427
- color: "inherit"
428
- },
409
+ className: "cpk:flex cpk:w-full cpk:cursor-pointer cpk:select-none cpk:items-center cpk:justify-between cpk:gap-2.5 cpk:border-none cpk:bg-transparent cpk:p-0 cpk:m-0 cpk:text-left cpk:text-inherit",
410
+ style: { font: "inherit" },
429
411
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
430
- style: {
431
- display: "flex",
432
- alignItems: "center",
433
- gap: "8px",
434
- minWidth: 0
435
- },
412
+ className: "cpk:flex cpk:min-w-0 cpk:items-center cpk:gap-2",
436
413
  children: [
437
414
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
438
- style: {
439
- height: "14px",
440
- width: "14px",
441
- color: "#71717a",
442
- transition: "transform 0.15s",
443
- transform: isExpanded ? "rotate(90deg)" : "rotate(0deg)",
444
- flexShrink: 0
445
- },
415
+ className: `cpk:h-3.5 cpk:w-3.5 cpk:flex-shrink-0 cpk:text-zinc-500 cpk:transition-transform cpk:dark:text-zinc-400 ${isExpanded ? "cpk:rotate-90" : ""}`,
446
416
  fill: "none",
447
417
  viewBox: "0 0 24 24",
448
418
  strokeWidth: 2,
@@ -453,93 +423,31 @@ react_markdown = __toESM(react_markdown);
453
423
  d: "M8.25 4.5l7.5 7.5-7.5 7.5"
454
424
  })
455
425
  }),
456
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { style: {
457
- display: "inline-block",
458
- height: "8px",
459
- width: "8px",
460
- borderRadius: "50%",
461
- backgroundColor: dotColor,
462
- flexShrink: 0
463
- } }),
426
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: `cpk:inline-block cpk:h-2 cpk:w-2 cpk:flex-shrink-0 cpk:rounded-full ${dotClassName}` }),
464
427
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
465
428
  "data-testid": "copilot-tool-render-name",
466
- style: {
467
- fontSize: "13px",
468
- fontWeight: 600,
469
- color: "#18181b",
470
- overflow: "hidden",
471
- textOverflow: "ellipsis",
472
- whiteSpace: "nowrap"
473
- },
429
+ className: "cpk:truncate cpk:text-[13px] cpk:font-semibold cpk:text-zinc-900 cpk:dark:text-zinc-100",
474
430
  children: name
475
431
  })
476
432
  ]
477
433
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
478
434
  "data-testid": "copilot-tool-render-status",
479
- style: {
480
- display: "inline-flex",
481
- alignItems: "center",
482
- borderRadius: "9999px",
483
- padding: "2px 8px",
484
- fontSize: "11px",
485
- fontWeight: 500,
486
- backgroundColor: badgeBg,
487
- color: badgeColor,
488
- flexShrink: 0
489
- },
435
+ className: `cpk:inline-flex cpk:flex-shrink-0 cpk:items-center cpk:rounded-full cpk:px-2 cpk:py-0.5 cpk:text-[11px] cpk:font-medium ${badgeClassName}`,
490
436
  children: statusLabel
491
437
  })]
492
438
  }), isExpanded && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
493
- style: {
494
- marginTop: "12px",
495
- display: "grid",
496
- gap: "12px"
497
- },
439
+ className: "cpk:mt-3 cpk:grid cpk:gap-3",
498
440
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
499
- style: {
500
- fontSize: "10px",
501
- textTransform: "uppercase",
502
- letterSpacing: "0.05em",
503
- color: "#71717a"
504
- },
441
+ className: "cpk:text-[10px] cpk:uppercase cpk:text-zinc-500 cpk:dark:text-zinc-400",
505
442
  children: "Arguments"
506
443
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
507
- style: {
508
- marginTop: "6px",
509
- maxHeight: "200px",
510
- overflow: "auto",
511
- borderRadius: "6px",
512
- backgroundColor: "#f4f4f5",
513
- padding: "10px",
514
- fontSize: "11px",
515
- lineHeight: 1.6,
516
- color: "#27272a",
517
- whiteSpace: "pre-wrap",
518
- wordBreak: "break-word"
519
- },
444
+ className: "cpk:mt-1.5 cpk:max-h-[200px] cpk:overflow-auto cpk:rounded-md cpk:bg-zinc-100 cpk:p-2.5 cpk:text-[11px] cpk:leading-relaxed cpk:text-zinc-800 cpk:whitespace-pre-wrap cpk:break-words cpk:dark:bg-zinc-800/60 cpk:dark:text-zinc-200",
520
445
  children: safeStringifyForPre(parameters ?? {})
521
446
  })] }), result !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
522
- style: {
523
- fontSize: "10px",
524
- textTransform: "uppercase",
525
- letterSpacing: "0.05em",
526
- color: "#71717a"
527
- },
447
+ className: "cpk:text-[10px] cpk:uppercase cpk:text-zinc-500 cpk:dark:text-zinc-400",
528
448
  children: "Result"
529
449
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
530
- style: {
531
- marginTop: "6px",
532
- maxHeight: "200px",
533
- overflow: "auto",
534
- borderRadius: "6px",
535
- backgroundColor: "#f4f4f5",
536
- padding: "10px",
537
- fontSize: "11px",
538
- lineHeight: 1.6,
539
- color: "#27272a",
540
- whiteSpace: "pre-wrap",
541
- wordBreak: "break-word"
542
- },
450
+ className: "cpk:mt-1.5 cpk:max-h-[200px] cpk:overflow-auto cpk:rounded-md cpk:bg-zinc-100 cpk:p-2.5 cpk:text-[11px] cpk:leading-relaxed cpk:text-zinc-800 cpk:whitespace-pre-wrap cpk:break-words cpk:dark:bg-zinc-800/60 cpk:dark:text-zinc-200",
543
451
  children: typeof result === "string" ? result : safeStringifyForPre(result)
544
452
  })] })]
545
453
  })]
@@ -2453,6 +2361,10 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
2453
2361
  ...selfManagedAgents
2454
2362
  }), [agents, selfManagedAgents]);
2455
2363
  const hasLocalAgents = mergedAgents && Object.keys(mergedAgents).length > 0;
2364
+ const hasSelfManagedAgents = Object.keys(selfManagedAgents).length > 0;
2365
+ (0, react.useEffect)(() => {
2366
+ 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.");
2367
+ }, [hasSelfManagedAgents, resolvedPublicKey]);
2456
2368
  const headers = typeof headersProp === "function" ? headersProp() : headersProp;
2457
2369
  const mergedHeaders = (0, react.useMemo)(() => {
2458
2370
  if (!resolvedPublicKey) return headers;
@@ -2824,36 +2736,40 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
2824
2736
  }, []);
2825
2737
  const RenderComponent = (0, react.useCallback)((props) => {
2826
2738
  const ToolComponent = tool.render;
2827
- if (props.status === "inProgress") {
2739
+ if (props.status === _copilotkit_core.ToolCallStatus.InProgress) {
2828
2740
  const enhancedProps = {
2829
2741
  ...props,
2830
2742
  name: tool.name,
2831
2743
  description: tool.description || "",
2744
+ agentId: tool.agentId,
2832
2745
  respond: void 0
2833
2746
  };
2834
2747
  return react.default.createElement(ToolComponent, enhancedProps);
2835
- } else if (props.status === "executing") {
2748
+ } else if (props.status === _copilotkit_core.ToolCallStatus.Executing) {
2836
2749
  const enhancedProps = {
2837
2750
  ...props,
2838
2751
  name: tool.name,
2839
2752
  description: tool.description || "",
2753
+ agentId: tool.agentId,
2840
2754
  respond
2841
2755
  };
2842
2756
  return react.default.createElement(ToolComponent, enhancedProps);
2843
- } else if (props.status === "complete") {
2757
+ } else if (props.status === _copilotkit_core.ToolCallStatus.Complete) {
2844
2758
  const enhancedProps = {
2845
2759
  ...props,
2846
2760
  name: tool.name,
2847
2761
  description: tool.description || "",
2762
+ agentId: tool.agentId,
2848
2763
  respond: void 0
2849
2764
  };
2850
2765
  return react.default.createElement(ToolComponent, enhancedProps);
2851
2766
  }
2852
- return react.default.createElement(ToolComponent, props);
2767
+ return props;
2853
2768
  }, [
2854
2769
  tool.render,
2855
2770
  tool.name,
2856
2771
  tool.description,
2772
+ tool.agentId,
2857
2773
  respond
2858
2774
  ]);
2859
2775
  useFrontendTool$1({
@@ -3301,18 +3217,25 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
3301
3217
  },
3302
3218
  onRunFailed: () => {
3303
3219
  localInterrupt = null;
3220
+ setPendingEvent(null);
3304
3221
  }
3305
3222
  });
3306
3223
  return () => subscription.unsubscribe();
3307
3224
  }, [agent]);
3308
- const resolve = (0, react.useCallback)((response) => {
3309
- copilotkit.runAgent({
3310
- agent,
3311
- forwardedProps: { command: {
3312
- resume: response,
3313
- interruptEvent: pendingEventRef.current?.value
3314
- } }
3315
- });
3225
+ const resolve = (0, react.useCallback)(async (response) => {
3226
+ try {
3227
+ return await copilotkit.runAgent({
3228
+ agent,
3229
+ forwardedProps: { command: {
3230
+ resume: response,
3231
+ interruptEvent: pendingEventRef.current?.value
3232
+ } }
3233
+ });
3234
+ } catch (err) {
3235
+ console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
3236
+ setPendingEvent(null);
3237
+ throw err;
3238
+ }
3316
3239
  }, [agent, copilotkit]);
3317
3240
  const renderRef = (0, react.useRef)(config.render);
3318
3241
  renderRef.current = config.render;
@@ -5035,21 +4958,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
5035
4958
 
5036
4959
  //#endregion
5037
4960
  //#region src/components/copilot-provider/copilotkit.tsx
5038
- /**
5039
- * 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.
5040
- *
5041
- * ## Example
5042
- *
5043
- * You can find more information about self-hosting CopilotKit [here](/guides/self-hosting).
5044
- *
5045
- * ```tsx
5046
- * import { CopilotKit } from "@copilotkit/react-core";
5047
- *
5048
- * <CopilotKit runtimeUrl="<your-runtime-url>">
5049
- * // ... your app ...
5050
- * </CopilotKit>
5051
- * ```
5052
- */
5053
4961
  function CopilotKit({ children, ...props }) {
5054
4962
  const enabled = shouldShowDevConsole(props.showDevConsole);
5055
4963
  const showInspector = shouldShowDevConsole(props.enableInspector);
@@ -5538,7 +5446,11 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
5538
5446
  function validateProps(props) {
5539
5447
  const cloudFeatures = Object.keys(props).filter((key) => key.endsWith("_c"));
5540
5448
  const hasApiKey = props.publicApiKey || props.publicLicenseKey;
5541
- if (!props.runtimeUrl && !hasApiKey) throw new _copilotkit_shared.ConfigurationError("Missing required prop: 'runtimeUrl' or 'publicApiKey' or 'publicLicenseKey'");
5449
+ const hasLocalAgents = Object.keys({
5450
+ ...props.agents__unsafe_dev_only,
5451
+ ...props.selfManagedAgents
5452
+ }).length > 0;
5453
+ if (!props.runtimeUrl && !hasApiKey && !hasLocalAgents) throw new _copilotkit_shared.ConfigurationError("Missing required prop: 'runtimeUrl' or 'publicApiKey' or 'publicLicenseKey'");
5542
5454
  if (cloudFeatures.length > 0 && !hasApiKey) throw new _copilotkit_shared.MissingPublicApiKeyError(`Missing required prop: 'publicApiKey' or 'publicLicenseKey' to use cloud features: ${cloudFeatures.map(formatFeatureName).join(", ")}`);
5543
5455
  }
5544
5456
 
@@ -5888,8 +5800,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
5888
5800
  /**
5889
5801
  * `useCopilotChatHeadless_c` is for building fully custom UI (headless UI) implementations.
5890
5802
  *
5891
- * <Callout title="This is a premium-only feature">
5892
- * Read more about <a href="/premium/overview">premium features</a>.
5803
+ * <Callout title="This is an Enterprise Intelligence Platform feature">
5804
+ * Read more about <a href="/premium/overview">the Enterprise Intelligence Platform</a>.
5893
5805
  *
5894
5806
  * Usage is generous and **free** to get started.
5895
5807
  * </Callout>
@@ -6068,11 +5980,11 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
6068
5980
  interrupt: null
6069
5981
  });
6070
5982
  /**
6071
- * Enterprise React hook that provides complete chat functionality for fully custom UI implementations.
5983
+ * Enterprise Intelligence Platform React hook that provides complete chat functionality for fully custom UI implementations.
6072
5984
  * Includes all advanced features like direct message access, suggestions array, interrupt handling, and MCP support.
6073
5985
  *
6074
5986
  * @param options - Configuration options for the chat
6075
- * @returns Complete chat interface with all enterprise features
5987
+ * @returns Complete chat interface with all Enterprise Intelligence Platform features
6076
5988
  *
6077
5989
  * @example
6078
5990
  * ```tsx
@@ -6086,7 +5998,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
6086
5998
  (0, react.useEffect)(() => {
6087
5999
  if (!hasPublicApiKey) {
6088
6000
  setBannerError(new _copilotkit_shared.CopilotKitError({
6089
- message: "You're using useCopilotChatHeadless_c, a premium-only feature, which offers extensive headless chat capabilities. To continue, you'll need to provide a free public license key.",
6001
+ message: "You're using useCopilotChatHeadless_c, an Enterprise Intelligence Platform feature that offers extensive headless chat capabilities. To continue, you'll need to provide a free public license key.",
6090
6002
  code: _copilotkit_shared.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
6091
6003
  severity: _copilotkit_shared.Severity.WARNING,
6092
6004
  visibility: _copilotkit_shared.ErrorVisibility.BANNER