@copilotkit/react-core 1.68.1 → 1.68.3-canary.1786716392

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 (37) hide show
  1. package/dist/{copilotkit-BICg0AyJ.d.cts → copilotkit-B1K0Tgnz.d.cts} +47 -3
  2. package/dist/copilotkit-B1K0Tgnz.d.cts.map +1 -0
  3. package/dist/{copilotkit-BrfN8YeF.d.mts → copilotkit-CZjzQPdq.d.mts} +47 -3
  4. package/dist/copilotkit-CZjzQPdq.d.mts.map +1 -0
  5. package/dist/{copilotkit-Ck0RL8hh.mjs → copilotkit-DT2FmOwK.mjs} +263 -19
  6. package/dist/copilotkit-DT2FmOwK.mjs.map +1 -0
  7. package/dist/{copilotkit-8KSSmCH_.cjs → copilotkit-EFunREg5.cjs} +268 -18
  8. package/dist/copilotkit-EFunREg5.cjs.map +1 -0
  9. package/dist/index.cjs +14 -7
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +1 -1
  12. package/dist/index.d.mts +1 -1
  13. package/dist/index.mjs +14 -7
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/index.umd.js +62 -16
  16. package/dist/index.umd.js.map +1 -1
  17. package/dist/v2/headless.cjs +2 -0
  18. package/dist/v2/headless.cjs.map +1 -1
  19. package/dist/v2/headless.d.cts +2 -0
  20. package/dist/v2/headless.d.cts.map +1 -1
  21. package/dist/v2/headless.d.mts +2 -0
  22. package/dist/v2/headless.d.mts.map +1 -1
  23. package/dist/v2/headless.mjs +2 -0
  24. package/dist/v2/headless.mjs.map +1 -1
  25. package/dist/v2/index.cjs +2 -1
  26. package/dist/v2/index.css +1 -1
  27. package/dist/v2/index.d.cts +2 -2
  28. package/dist/v2/index.d.mts +2 -2
  29. package/dist/v2/index.mjs +2 -2
  30. package/dist/v2/index.umd.js +262 -17
  31. package/dist/v2/index.umd.js.map +1 -1
  32. package/package.json +8 -8
  33. package/skills/react-core/SKILL.md +1 -1
  34. package/dist/copilotkit-8KSSmCH_.cjs.map +0 -1
  35. package/dist/copilotkit-BICg0AyJ.d.cts.map +0 -1
  36. package/dist/copilotkit-BrfN8YeF.d.mts.map +0 -1
  37. package/dist/copilotkit-Ck0RL8hh.mjs.map +0 -1
package/dist/index.umd.js CHANGED
@@ -89,6 +89,8 @@ react_markdown = __toESM(react_markdown);
89
89
  assistantMessageToolbarCopyCodeLabel: "Copy",
90
90
  assistantMessageToolbarCopyCodeCopiedLabel: "Copied",
91
91
  assistantMessageToolbarCopyMessageLabel: "Copy",
92
+ assistantMessageToolbarInspectorLabel: "View in Inspector",
93
+ assistantMessageToolbarInspectorLocalOnlyLabel: "Local Only",
92
94
  assistantMessageToolbarThumbsUpLabel: "Good response",
93
95
  assistantMessageToolbarThumbsDownLabel: "Bad response",
94
96
  assistantMessageToolbarReadAloudLabel: "Read aloud",
@@ -478,8 +480,9 @@ react_markdown = __toESM(react_markdown);
478
480
 
479
481
  //#endregion
480
482
  //#region src/v2/components/CopilotKitInspector.tsx
481
- const CopilotKitInspector = ({ core, ...rest }) => {
483
+ const CopilotKitInspector = ({ core, openRequest, ...rest }) => {
482
484
  const [InspectorComponent, setInspectorComponent] = react.useState(null);
485
+ const inspectorRef = react.useRef(null);
483
486
  react.useEffect(() => {
484
487
  let mounted = true;
485
488
  import("@copilotkit/web-inspector").then((mod) => {
@@ -495,14 +498,26 @@ react_markdown = __toESM(react_markdown);
495
498
  mounted = false;
496
499
  };
497
500
  }, []);
501
+ react.useEffect(() => {
502
+ if (openRequest) inspectorRef.current?.openInspector("message_toolbar", openRequest);
503
+ }, [InspectorComponent, openRequest]);
498
504
  if (!InspectorComponent) return null;
499
505
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InspectorComponent, {
506
+ ref: inspectorRef,
500
507
  ...rest,
501
508
  core: core ?? null
502
509
  });
503
510
  };
504
511
  CopilotKitInspector.displayName = "CopilotKitInspector";
505
512
 
513
+ //#endregion
514
+ //#region src/v2/components/CopilotKitInspectorContext.tsx
515
+ const CopilotKitInspectorContext = react.createContext({
516
+ isLocalInspectorEnabled: false,
517
+ openInspector: () => void 0
518
+ });
519
+ const CopilotKitInspectorContextProvider = CopilotKitInspectorContext.Provider;
520
+
506
521
  //#endregion
507
522
  //#region src/v2/components/license-warning-banner.tsx
508
523
  const LICENSE_BANNER_OFFSET_PX = 52;
@@ -2322,6 +2337,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
2322
2337
  }
2323
2338
  const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY_HEADERS, credentials, publicApiKey, publicLicenseKey, licenseToken, properties = EMPTY_PROPERTIES, agents__unsafe_dev_only: agents = EMPTY_AGENTS, selfManagedAgents = EMPTY_AGENTS, renderToolCalls, renderActivityMessages, renderCustomMessages, frontendTools, humanInTheLoop, openGenerativeUI, showDevConsole = false, useSingleEndpoint, onError, a2ui, defaultThrottleMs, inspectorDefaultAnchor, debug }) => {
2324
2339
  const [shouldRenderInspector, setShouldRenderInspector] = (0, react.useState)(false);
2340
+ const [isLocalInspectorEnabled, setIsLocalInspectorEnabled] = (0, react.useState)(false);
2341
+ const [inspectorOpenRequest, setInspectorOpenRequest] = (0, react.useState)(null);
2325
2342
  const [runtimeA2UIEnabled, setRuntimeA2UIEnabled] = (0, react.useState)(false);
2326
2343
  const [runtimeOpenGenUIEnabled, setRuntimeOpenGenUIEnabled] = (0, react.useState)(false);
2327
2344
  const [catalogToggleVersion, setCatalogToggleVersion] = (0, react.useState)(0);
@@ -2331,11 +2348,30 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
2331
2348
  const [runtimeLicenseStatus, setRuntimeLicenseStatus] = (0, react.useState)(void 0);
2332
2349
  (0, react.useEffect)(() => {
2333
2350
  if (typeof window === "undefined") return;
2334
- if (showDevConsole === true) setShouldRenderInspector(true);
2335
- else if (showDevConsole === "auto") if (new Set(["localhost", "127.0.0.1"]).has(window.location.hostname)) setShouldRenderInspector(true);
2336
- else setShouldRenderInspector(false);
2337
- else setShouldRenderInspector(false);
2351
+ const isLocalhost = new Set(["localhost", "127.0.0.1"]).has(window.location?.hostname ?? "");
2352
+ const canShowLocalInspectorAction = process.env.NODE_ENV === "development" && isLocalhost;
2353
+ if (showDevConsole === true) {
2354
+ setShouldRenderInspector(true);
2355
+ setIsLocalInspectorEnabled(canShowLocalInspectorAction);
2356
+ } else if (showDevConsole === "auto") if (isLocalhost) {
2357
+ setShouldRenderInspector(true);
2358
+ setIsLocalInspectorEnabled(canShowLocalInspectorAction);
2359
+ } else {
2360
+ setShouldRenderInspector(false);
2361
+ setIsLocalInspectorEnabled(false);
2362
+ }
2363
+ else {
2364
+ setShouldRenderInspector(false);
2365
+ setIsLocalInspectorEnabled(false);
2366
+ }
2338
2367
  }, [showDevConsole]);
2368
+ const requestInspectorOpen = (0, react.useCallback)((request) => {
2369
+ setInspectorOpenRequest({ ...request });
2370
+ }, []);
2371
+ const inspectorContextValue = (0, react.useMemo)(() => ({
2372
+ isLocalInspectorEnabled,
2373
+ openInspector: requestInspectorOpen
2374
+ }), [isLocalInspectorEnabled, requestInspectorOpen]);
2339
2375
  const renderToolCallsList = useStableArrayProp(renderToolCalls, "renderToolCalls must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead.", (initial, next) => {
2340
2376
  const key = (rc) => `${rc?.agentId ?? ""}:${rc?.name ?? ""}`;
2341
2377
  const setFrom = (arr) => new Set(arr.map(key));
@@ -2672,11 +2708,14 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
2672
2708
  catalog: filteredCatalog,
2673
2709
  includeSchema: a2ui?.includeSchema
2674
2710
  }),
2675
- children,
2676
- shouldRenderInspector ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitInspector, {
2677
- core: copilotkit,
2678
- defaultAnchor: inspectorDefaultAnchor
2679
- }) : null,
2711
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(CopilotKitInspectorContextProvider, {
2712
+ value: inspectorContextValue,
2713
+ children: [children, shouldRenderInspector ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitInspector, {
2714
+ core: copilotkit,
2715
+ defaultAnchor: inspectorDefaultAnchor,
2716
+ openRequest: inspectorOpenRequest
2717
+ }) : null]
2718
+ }),
2680
2719
  runtimeLicenseStatus === "none" && !resolvedPublicKey && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "no_license" }),
2681
2720
  runtimeLicenseStatus === "expired" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "expired" }),
2682
2721
  runtimeLicenseStatus === "invalid" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "invalid" }),
@@ -6811,30 +6850,37 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
6811
6850
 
6812
6851
  //#endregion
6813
6852
  //#region src/hooks/use-agent-nodename.ts
6853
+ /**
6854
+ * Tracks the node the agent is currently executing.
6855
+ *
6856
+ * Backed by state rather than a ref: mutating a ref schedules no render, so
6857
+ * consumers such as `useCoAgent().nodeName` kept reporting whichever node was
6858
+ * current at their last render and never updated on their own.
6859
+ */
6814
6860
  function useAgentNodeName(agentName) {
6815
6861
  const { agent } = useAgent({ agentId: agentName });
6816
- const nodeNameRef = (0, react.useRef)("start");
6862
+ const [nodeName, setNodeName] = (0, react.useState)("start");
6817
6863
  (0, react.useEffect)(() => {
6818
6864
  if (!agent) return;
6819
6865
  const subscription = agent.subscribe({
6820
6866
  onStepStartedEvent: ({ event }) => {
6821
- nodeNameRef.current = event.stepName;
6867
+ setNodeName(event.stepName);
6822
6868
  },
6823
6869
  onRunStartedEvent: () => {
6824
- nodeNameRef.current = "start";
6870
+ setNodeName("start");
6825
6871
  },
6826
6872
  onRunFinishedEvent: () => {
6827
- nodeNameRef.current = "end";
6873
+ setNodeName("end");
6828
6874
  },
6829
6875
  onRunErrorEvent: () => {
6830
- nodeNameRef.current = "end";
6876
+ setNodeName("end");
6831
6877
  }
6832
6878
  });
6833
6879
  return () => {
6834
6880
  subscription.unsubscribe();
6835
6881
  };
6836
6882
  }, [agent]);
6837
- return nodeNameRef.current;
6883
+ return nodeName;
6838
6884
  }
6839
6885
 
6840
6886
  //#endregion