@copilotkit/react-core 2.0.0-rc.64 → 2.0.0-rc.65

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.umd.js CHANGED
@@ -1287,9 +1287,18 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
1287
1287
  * Hook that returns a function to render tool calls based on the render functions
1288
1288
  * defined in CopilotKitProvider.
1289
1289
  *
1290
+ * @param removedArguments - None. In 1.x, `useRenderToolCall(tool, deps)`
1291
+ * registered a renderer for a tool. That call throws a
1292
+ * `CopilotKitRemovedApiError` in 2.0: register a renderer with `useRenderTool`.
1293
+ * See https://docs.copilotkit.ai/migrate/removed-apis-2.0#userendertoolcall-with-arguments
1290
1294
  * @returns A function that takes a tool call and optional tool message and returns the rendered component
1291
1295
  */
1292
- function useRenderToolCall() {
1296
+ function useRenderToolCall(...removedArguments) {
1297
+ if (removedArguments.length > 0) throw new _copilotkit_shared.CopilotKitRemovedApiError({
1298
+ what: "\"useRenderToolCall(tool, deps)\"",
1299
+ use: "To register a renderer for a tool, use useRenderTool from @copilotkit/react-core. useRenderToolCall() takes no arguments: it returns a function that renders a tool call.",
1300
+ docs: "/migrate/removed-apis-2.0#userendertoolcall-with-arguments"
1301
+ });
1293
1302
  const { copilotkit, executingToolCallIds } = useCopilotKit();
1294
1303
  const agentId = (0, _copilotkit_core.ɵresolveToolCallAgentId)(useCopilotChatConfiguration()?.agentId, void 0);
1295
1304
  const unrenderedToolNames = (0, react.useRef)(/* @__PURE__ */ new Set());
@@ -1377,7 +1386,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
1377
1386
 
1378
1387
  //#endregion
1379
1388
  //#region package.json
1380
- var version$1 = "2.0.0-rc.64";
1389
+ var version$1 = "2.0.0-rc.65";
1381
1390
 
1382
1391
  //#endregion
1383
1392
  //#region src/components/CopilotKitInspector.tsx
@@ -9259,7 +9268,8 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
9259
9268
  return value;
9260
9269
  }
9261
9270
  /** Provide a shared core instance and synchronize runtime, tool, and UI configuration. */
9262
- const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY_HEADERS, credentials, nonce, injectStyles = true, messageFilter, publicApiKey, publicLicenseKey, properties = EMPTY_PROPERTIES, agents__unsafe_dev_only: agents = EMPTY_AGENTS, selfManagedAgents = EMPTY_AGENTS, renderToolCalls, renderActivityMessages, renderCustomMessages, markdownRenderer, frontendTools, humanInTheLoop, openGenerativeUI, enableInspector, agentId, showIntelligenceIndicator = true, useSingleEndpoint, onError, generativeUI, a2ui, mcpApps, defaultThrottleMs, debug, learning }) => {
9271
+ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY_HEADERS, credentials, nonce, injectStyles = true, messageFilter, publicApiKey, publicLicenseKey, properties = EMPTY_PROPERTIES, agents__unsafe_dev_only: agents = EMPTY_AGENTS, selfManagedAgents = EMPTY_AGENTS, renderToolCalls, renderActivityMessages, renderCustomMessages, markdownRenderer, frontendTools, humanInTheLoop, openGenerativeUI, enableInspector, agentId, showIntelligenceIndicator = true, useSingleEndpoint, onError, generativeUI, a2ui, mcpApps, defaultThrottleMs, debug, learning, ...otherProps }) => {
9272
+ (0, _copilotkit_core.ɵcheckRemovedProviderProps)(otherProps);
9263
9273
  const learningConfig = (0, react.useMemo)(() => (0, _copilotkit_core.ɵtoLearningConfig)(learning), [learning]);
9264
9274
  const [shouldRenderInspector, setShouldRenderInspector] = (0, react.useState)(false);
9265
9275
  const [inspectorVisible, setInspectorVisible] = (0, react.useState)(false);
@@ -9753,6 +9763,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
9753
9763
  * ```
9754
9764
  */
9755
9765
  function useFrontendTool(tool, deps) {
9766
+ (0, _copilotkit_core.ɵcheckToolParameters)("useFrontendTool", tool.parameters);
9756
9767
  const { copilotkit } = useCopilotKit();
9757
9768
  const depsVersion = useDepsVersion(deps);
9758
9769
  (0, react.useLayoutEffect)(() => {
@@ -10488,6 +10499,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
10488
10499
  //#endregion
10489
10500
  //#region src/hooks/use-human-in-the-loop.tsx
10490
10501
  function useHumanInTheLoop(tool, deps) {
10502
+ (0, _copilotkit_core.ɵcheckToolParameters)("useHumanInTheLoop", tool.parameters);
10491
10503
  const { copilotkit } = useCopilotKit();
10492
10504
  const registry = copilotkit.ɵhumanInTheLoop;
10493
10505
  const RenderComponent = (0, react.useCallback)((props) => react.default.createElement(tool.render, (0, _copilotkit_core.ɵhitlRenderProps)(props, tool, registry)), [
@@ -10827,6 +10839,11 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
10827
10839
  * `deleteThread`) return promises that resolve once the platform confirms the
10828
10840
  * operation and reject with an `Error` on failure.
10829
10841
  *
10842
+ * In 1.x, `useThreads()` returned the current thread. A call without
10843
+ * arguments throws a `CopilotKitRemovedApiError`, and so does a read of
10844
+ * `threadId`, `setThreadId`, or `isThreadIdExplicit` on the result. Read the
10845
+ * current thread from `useCopilotChatConfiguration()`.
10846
+ *
10830
10847
  * @param input - Agent identifier and optional list controls.
10831
10848
  * @returns Thread list state and stable mutation callbacks.
10832
10849
  *
@@ -10855,7 +10872,9 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
10855
10872
  * }
10856
10873
  * ```
10857
10874
  */
10858
- function useThreads({ agentId, includeArchived, limit, enabled = true }) {
10875
+ function useThreads(input) {
10876
+ checkThreadsInput(input);
10877
+ const { agentId, includeArchived, limit, enabled = true } = input;
10859
10878
  const { copilotkit } = useCopilotKit();
10860
10879
  const [controller] = (0, react.useState)(() => new _copilotkit_core.ɵThreadsController((0, _copilotkit_core.ɵcreateThreadStore)({ fetch: copilotkit.ɵruntimeFetch }), {
10861
10880
  core: copilotkit,
@@ -10889,7 +10908,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
10889
10908
  copilotkit.threadEndpoints?.mutations
10890
10909
  ]);
10891
10910
  const { fetchMoreThreads, refetchThreads, startNewThread, renameThread, archiveThread, unarchiveThread, deleteThread } = controller;
10892
- return {
10911
+ return withRemovedThreadFields({
10893
10912
  threads,
10894
10913
  isLoading,
10895
10914
  error,
@@ -10905,7 +10924,42 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
10905
10924
  archiveThread,
10906
10925
  unarchiveThread,
10907
10926
  deleteThread
10908
- };
10927
+ });
10928
+ }
10929
+ const USE_THREADS_SECTION = "/migrate/removed-apis-2.0#usethreads";
10930
+ /** Throws for the 1.x call `useThreads()`, which has no input. */
10931
+ function checkThreadsInput(input) {
10932
+ if (input !== void 0) return;
10933
+ throw new _copilotkit_shared.CopilotKitRemovedApiError({
10934
+ what: "\"useThreads()\" without arguments",
10935
+ use: "useThreads({ agentId }) lists the threads of an agent. To read or set the current thread, use useCopilotChatConfiguration() from @copilotkit/react-core.",
10936
+ docs: USE_THREADS_SECTION
10937
+ });
10938
+ }
10939
+ /** The fields of the 1.x `useThreads()` result, and what to use in 2.0. */
10940
+ const REMOVED_THREAD_FIELDS = {
10941
+ threadId: "Read threadId from useCopilotChatConfiguration() of @copilotkit/react-core.",
10942
+ setThreadId: "Call setActiveThreadId(threadId) on useCopilotChatConfiguration() of @copilotkit/react-core.",
10943
+ isThreadIdExplicit: "Read hasExplicitThreadId from useCopilotChatConfiguration() of @copilotkit/react-core."
10944
+ };
10945
+ /**
10946
+ * Adds a getter that throws a `CopilotKitRemovedApiError` for each field of
10947
+ * the 1.x result. The getters are not enumerable, so a spread, a JSON copy,
10948
+ * or devtools do not call them.
10949
+ */
10950
+ function withRemovedThreadFields(result) {
10951
+ const fields = Object.entries(REMOVED_THREAD_FIELDS);
10952
+ for (const [field, use] of fields) Object.defineProperty(result, field, {
10953
+ enumerable: false,
10954
+ get() {
10955
+ throw new _copilotkit_shared.CopilotKitRemovedApiError({
10956
+ what: `"${field}" from useThreads`,
10957
+ use: `${use} useThreads({ agentId }) lists the threads of an agent.`,
10958
+ docs: USE_THREADS_SECTION
10959
+ });
10960
+ }
10961
+ });
10962
+ return result;
10909
10963
  }
10910
10964
 
10911
10965
  //#endregion
@@ -18354,6 +18408,18 @@ Object.defineProperty(exports, 'ɵcanPreviewDocument', {
18354
18408
  return _copilotkit_core.ɵcanPreviewDocument;
18355
18409
  }
18356
18410
  });
18411
+ Object.defineProperty(exports, 'ɵcheckRemovedProviderProps', {
18412
+ enumerable: true,
18413
+ get: function () {
18414
+ return _copilotkit_core.ɵcheckRemovedProviderProps;
18415
+ }
18416
+ });
18417
+ Object.defineProperty(exports, 'ɵcheckToolParameters', {
18418
+ enumerable: true,
18419
+ get: function () {
18420
+ return _copilotkit_core.ɵcheckToolParameters;
18421
+ }
18422
+ });
18357
18423
  Object.defineProperty(exports, 'ɵclampSlashIndex', {
18358
18424
  enumerable: true,
18359
18425
  get: function () {