@copilotkit/react-core 1.10.4 → 1.10.5-next.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.
Files changed (65) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/{chunk-AALETENN.mjs → chunk-FRXYSJGZ.mjs} +64 -3
  3. package/dist/chunk-FRXYSJGZ.mjs.map +1 -0
  4. package/dist/{chunk-QNJNOZH3.mjs → chunk-O73FZGSU.mjs} +2 -2
  5. package/dist/{chunk-CLAHAV6J.mjs → chunk-OLXYK6PP.mjs} +3 -3
  6. package/dist/{chunk-ID5JRMGN.mjs → chunk-RLT4KZR4.mjs} +2 -2
  7. package/dist/{chunk-5KVEE73R.mjs → chunk-UPQPBCUW.mjs} +2 -2
  8. package/dist/{chunk-LLLCUHOO.mjs → chunk-WBBJMOZI.mjs} +18 -6
  9. package/dist/chunk-WBBJMOZI.mjs.map +1 -0
  10. package/dist/{chunk-EBSAU46C.mjs → chunk-WRPXFDFL.mjs} +2 -2
  11. package/dist/{chunk-HWM2Z3J3.mjs → chunk-XFJNMZ6X.mjs} +2 -2
  12. package/dist/{chunk-6WTWBXEJ.mjs → chunk-ZRDV3MVW.mjs} +2 -2
  13. package/dist/components/copilot-provider/copilotkit.js +63 -2
  14. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  15. package/dist/components/copilot-provider/copilotkit.mjs +2 -2
  16. package/dist/components/copilot-provider/index.js +63 -2
  17. package/dist/components/copilot-provider/index.js.map +1 -1
  18. package/dist/components/copilot-provider/index.mjs +2 -2
  19. package/dist/components/dev-console/console-trigger.js +63 -2
  20. package/dist/components/dev-console/console-trigger.js.map +1 -1
  21. package/dist/components/dev-console/console-trigger.mjs +1 -1
  22. package/dist/components/index.js +63 -2
  23. package/dist/components/index.js.map +1 -1
  24. package/dist/components/index.mjs +2 -2
  25. package/dist/hooks/index.js +16 -4
  26. package/dist/hooks/index.js.map +1 -1
  27. package/dist/hooks/index.mjs +8 -8
  28. package/dist/hooks/use-chat.js +16 -4
  29. package/dist/hooks/use-chat.js.map +1 -1
  30. package/dist/hooks/use-chat.mjs +1 -1
  31. package/dist/hooks/use-coagent.js +16 -4
  32. package/dist/hooks/use-coagent.js.map +1 -1
  33. package/dist/hooks/use-coagent.mjs +5 -5
  34. package/dist/hooks/use-copilot-chat-headless_c.js +16 -4
  35. package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -1
  36. package/dist/hooks/use-copilot-chat-headless_c.mjs +5 -5
  37. package/dist/hooks/use-copilot-chat.js +16 -4
  38. package/dist/hooks/use-copilot-chat.js.map +1 -1
  39. package/dist/hooks/use-copilot-chat.mjs +5 -5
  40. package/dist/hooks/use-copilot-chat_internal.js +16 -4
  41. package/dist/hooks/use-copilot-chat_internal.js.map +1 -1
  42. package/dist/hooks/use-copilot-chat_internal.mjs +4 -4
  43. package/dist/hooks/use-langgraph-interrupt.js +16 -4
  44. package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
  45. package/dist/hooks/use-langgraph-interrupt.mjs +5 -5
  46. package/dist/index.js +79 -6
  47. package/dist/index.js.map +1 -1
  48. package/dist/index.mjs +9 -9
  49. package/dist/lib/copilot-task.mjs +3 -3
  50. package/dist/lib/index.mjs +3 -3
  51. package/dist/utils/extract.mjs +2 -2
  52. package/dist/utils/index.mjs +2 -2
  53. package/dist/utils/suggestions.mjs +2 -2
  54. package/package.json +3 -3
  55. package/src/components/dev-console/console-trigger.tsx +66 -2
  56. package/src/hooks/use-chat.ts +18 -4
  57. package/dist/chunk-AALETENN.mjs.map +0 -1
  58. package/dist/chunk-LLLCUHOO.mjs.map +0 -1
  59. /package/dist/{chunk-QNJNOZH3.mjs.map → chunk-O73FZGSU.mjs.map} +0 -0
  60. /package/dist/{chunk-CLAHAV6J.mjs.map → chunk-OLXYK6PP.mjs.map} +0 -0
  61. /package/dist/{chunk-ID5JRMGN.mjs.map → chunk-RLT4KZR4.mjs.map} +0 -0
  62. /package/dist/{chunk-5KVEE73R.mjs.map → chunk-UPQPBCUW.mjs.map} +0 -0
  63. /package/dist/{chunk-EBSAU46C.mjs.map → chunk-WRPXFDFL.mjs.map} +0 -0
  64. /package/dist/{chunk-HWM2Z3J3.mjs.map → chunk-XFJNMZ6X.mjs.map} +0 -0
  65. /package/dist/{chunk-6WTWBXEJ.mjs.map → chunk-ZRDV3MVW.mjs.map} +0 -0
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  useLangGraphInterrupt
3
- } from "../chunk-EBSAU46C.mjs";
4
- import "../chunk-CLAHAV6J.mjs";
3
+ } from "../chunk-WRPXFDFL.mjs";
4
+ import "../chunk-OLXYK6PP.mjs";
5
5
  import "../chunk-QF3Q5LUN.mjs";
6
- import "../chunk-LLLCUHOO.mjs";
6
+ import "../chunk-WBBJMOZI.mjs";
7
7
  import "../chunk-4CEQJ2X6.mjs";
8
- import "../chunk-6WTWBXEJ.mjs";
8
+ import "../chunk-ZRDV3MVW.mjs";
9
9
  import "../chunk-N4VN2B5S.mjs";
10
10
  import "../chunk-2MGJO3FY.mjs";
11
- import "../chunk-AALETENN.mjs";
11
+ import "../chunk-FRXYSJGZ.mjs";
12
12
  import "../chunk-DSDAZA3B.mjs";
13
13
  import "../chunk-PIF5KJYI.mjs";
14
14
  import "../chunk-2IDV5OHF.mjs";
package/dist/index.js CHANGED
@@ -2566,6 +2566,7 @@ function ContextTab({ context }) {
2566
2566
 
2567
2567
  // src/components/dev-console/console-trigger.tsx
2568
2568
  var import_jsx_runtime9 = require("react/jsx-runtime");
2569
+ var INSPECTOR_HIDE_KEY = "cpk:inspector:hidden";
2569
2570
  function ConsoleTrigger({ position = "bottom-right" }) {
2570
2571
  const context = useCopilotContext();
2571
2572
  const hasApiKey = Boolean(context.copilotApiConfig.publicApiKey);
@@ -2574,10 +2575,18 @@ function ConsoleTrigger({ position = "bottom-right" }) {
2574
2575
  const [isDragging, setIsDragging] = (0, import_react11.useState)(false);
2575
2576
  const [buttonPosition, setButtonPosition] = (0, import_react11.useState)(null);
2576
2577
  const [mounted, setMounted] = (0, import_react11.useState)(false);
2578
+ const [isHidden, setIsHidden] = (0, import_react11.useState)(false);
2577
2579
  const dragRef = (0, import_react11.useRef)(null);
2578
2580
  const buttonRef = (0, import_react11.useRef)(null);
2579
2581
  (0, import_react11.useEffect)(() => {
2580
2582
  setMounted(true);
2583
+ try {
2584
+ const hidden = typeof window !== "undefined" ? localStorage.getItem(INSPECTOR_HIDE_KEY) : null;
2585
+ if (hidden === "1" || hidden === "true") {
2586
+ setIsHidden(true);
2587
+ }
2588
+ } catch (e) {
2589
+ }
2581
2590
  if (typeof window !== "undefined" && !buttonPosition) {
2582
2591
  const buttonSize = 60;
2583
2592
  const margin = 24;
@@ -2629,7 +2638,7 @@ function ConsoleTrigger({ position = "bottom-right" }) {
2629
2638
  document.removeEventListener("mouseup", handleMouseUp, { capture: true });
2630
2639
  };
2631
2640
  }, [isDragging]);
2632
- if (!mounted || !buttonPosition) {
2641
+ if (!mounted || !buttonPosition || isHidden) {
2633
2642
  return null;
2634
2643
  }
2635
2644
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
@@ -2637,11 +2646,27 @@ function ConsoleTrigger({ position = "bottom-right" }) {
2637
2646
  "button",
2638
2647
  {
2639
2648
  ref: buttonRef,
2640
- onClick: () => {
2649
+ onClick: (e) => {
2641
2650
  if (!isDragging) {
2651
+ if (e.metaKey || e.altKey) {
2652
+ try {
2653
+ localStorage.setItem(INSPECTOR_HIDE_KEY, "1");
2654
+ } catch (e2) {
2655
+ }
2656
+ setIsHidden(true);
2657
+ return;
2658
+ }
2642
2659
  setIsModalOpen(true);
2643
2660
  }
2644
2661
  },
2662
+ onContextMenu: (e) => {
2663
+ e.preventDefault();
2664
+ try {
2665
+ localStorage.setItem(INSPECTOR_HIDE_KEY, "1");
2666
+ } catch (e2) {
2667
+ }
2668
+ setIsHidden(true);
2669
+ },
2645
2670
  onMouseDown: handleMouseDown,
2646
2671
  onMouseEnter: () => setIsHovered(true),
2647
2672
  onMouseLeave: () => setIsHovered(false),
@@ -2671,6 +2696,42 @@ function ConsoleTrigger({ position = "bottom-right" }) {
2671
2696
  },
2672
2697
  title: hasApiKey ? "Open Inspector (Drag to move)" : "Inspector (License Key Required, Drag to move)",
2673
2698
  children: [
2699
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2700
+ "div",
2701
+ {
2702
+ onClick: (e) => {
2703
+ e.preventDefault();
2704
+ e.stopPropagation();
2705
+ try {
2706
+ localStorage.setItem(INSPECTOR_HIDE_KEY, "1");
2707
+ } catch (e2) {
2708
+ }
2709
+ setIsHidden(true);
2710
+ },
2711
+ style: {
2712
+ position: "absolute",
2713
+ bottom: "2px",
2714
+ right: "2px",
2715
+ width: "20px",
2716
+ height: "20px",
2717
+ borderRadius: "50%",
2718
+ background: "#ffffff",
2719
+ color: "#ef4444",
2720
+ fontSize: "14px",
2721
+ lineHeight: "18px",
2722
+ textAlign: "center",
2723
+ boxShadow: "0 2px 6px rgba(0,0,0,0.35)",
2724
+ cursor: "pointer",
2725
+ border: "1px solid #e5e7eb",
2726
+ display: "flex",
2727
+ alignItems: "center",
2728
+ justifyContent: "center",
2729
+ zIndex: 1
2730
+ },
2731
+ title: "Hide Inspector",
2732
+ children: "\xD7"
2733
+ }
2734
+ ),
2674
2735
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2675
2736
  "div",
2676
2737
  {
@@ -3244,7 +3305,18 @@ function useChat(options) {
3244
3305
  const runChatCompletionRef = (0, import_react13.useRef)();
3245
3306
  const addErrorToast = useErrorToast();
3246
3307
  const { setBannerError } = useToast();
3247
- const { onError } = useCopilotContext();
3308
+ const { onError, showDevConsole, getAllContext } = useCopilotContext();
3309
+ const copilotReadableContext = getAllContext();
3310
+ const context = (0, import_react13.useMemo)(
3311
+ () => copilotReadableContext.map((contextItem) => {
3312
+ const [description, ...valueParts] = contextItem.value.split(":");
3313
+ return {
3314
+ description: description.trim(),
3315
+ value: valueParts.join(":").trim()
3316
+ };
3317
+ }),
3318
+ [copilotReadableContext]
3319
+ );
3248
3320
  const traceUIError = (error, originalError) => __async(this, null, function* () {
3249
3321
  try {
3250
3322
  const traceEvent = {
@@ -3278,7 +3350,6 @@ function useChat(options) {
3278
3350
  extensionsRef.current = extensions;
3279
3351
  const publicApiKey = copilotConfig.publicApiKey;
3280
3352
  const headers = __spreadValues(__spreadValues({}, copilotConfig.headers || {}), publicApiKey ? { [import_shared14.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {});
3281
- const { showDevConsole } = useCopilotContext();
3282
3353
  const runtimeClient = useCopilotRuntimeClient({
3283
3354
  url: copilotConfig.chatApiEndpoint,
3284
3355
  publicApiKey: copilotConfig.publicApiKey,
@@ -3359,7 +3430,8 @@ function useChat(options) {
3359
3430
  }
3360
3431
  return stateObject;
3361
3432
  }),
3362
- forwardedParameters: options.forwardedParameters || {}
3433
+ forwardedParameters: options.forwardedParameters || {},
3434
+ context
3363
3435
  }),
3364
3436
  properties: finalProperties,
3365
3437
  signal: (_e = chatAbortControllerRef.current) == null ? void 0 : _e.signal
@@ -3671,7 +3743,8 @@ function useChat(options) {
3671
3743
  coagentStatesRef,
3672
3744
  agentSession,
3673
3745
  setAgentSession,
3674
- disableSystemMessage
3746
+ disableSystemMessage,
3747
+ context
3675
3748
  ]
3676
3749
  );
3677
3750
  runChatCompletionRef.current = runChatCompletion;