@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.cjs CHANGED
@@ -715,9 +715,18 @@ function useToolCallRendererNames() {
715
715
  * Hook that returns a function to render tool calls based on the render functions
716
716
  * defined in CopilotKitProvider.
717
717
  *
718
+ * @param removedArguments - None. In 1.x, `useRenderToolCall(tool, deps)`
719
+ * registered a renderer for a tool. That call throws a
720
+ * `CopilotKitRemovedApiError` in 2.0: register a renderer with `useRenderTool`.
721
+ * See https://docs.copilotkit.ai/migrate/removed-apis-2.0#userendertoolcall-with-arguments
718
722
  * @returns A function that takes a tool call and optional tool message and returns the rendered component
719
723
  */
720
- function useRenderToolCall() {
724
+ function useRenderToolCall(...removedArguments) {
725
+ if (removedArguments.length > 0) throw new _copilotkit_shared.CopilotKitRemovedApiError({
726
+ what: "\"useRenderToolCall(tool, deps)\"",
727
+ 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.",
728
+ docs: "/migrate/removed-apis-2.0#userendertoolcall-with-arguments"
729
+ });
721
730
  const { copilotkit, executingToolCallIds } = (0, _copilotkit_react_core_context.useCopilotKit)();
722
731
  const agentId = (0, _copilotkit_core.ɵresolveToolCallAgentId)(require_chat.useCopilotChatConfiguration()?.agentId, void 0);
723
732
  const unrenderedToolNames = (0, react.useRef)(/* @__PURE__ */ new Set());
@@ -805,7 +814,7 @@ function ɵuseOwnedCore(ref, create) {
805
814
 
806
815
  //#endregion
807
816
  //#region package.json
808
- var version$1 = "2.0.0-rc.64";
817
+ var version$1 = "2.0.0-rc.65";
809
818
 
810
819
  //#endregion
811
820
  //#region src/components/CopilotKitInspector.tsx
@@ -1335,7 +1344,8 @@ function useStableArrayProp(prop, name) {
1335
1344
  return value;
1336
1345
  }
1337
1346
  /** Provide a shared core instance and synchronize runtime, tool, and UI configuration. */
1338
- 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 }) => {
1347
+ 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 }) => {
1348
+ (0, _copilotkit_core.ɵcheckRemovedProviderProps)(otherProps);
1339
1349
  const learningConfig = (0, react.useMemo)(() => (0, _copilotkit_core.ɵtoLearningConfig)(learning), [learning]);
1340
1350
  const [shouldRenderInspector, setShouldRenderInspector] = (0, react.useState)(false);
1341
1351
  const [inspectorVisible, setInspectorVisible] = (0, react.useState)(false);
@@ -1829,6 +1839,7 @@ function useDepsVersion(deps) {
1829
1839
  * ```
1830
1840
  */
1831
1841
  function useFrontendTool(tool, deps) {
1842
+ (0, _copilotkit_core.ɵcheckToolParameters)("useFrontendTool", tool.parameters);
1832
1843
  const { copilotkit } = (0, _copilotkit_react_core_context.useCopilotKit)();
1833
1844
  const depsVersion = useDepsVersion(deps);
1834
1845
  (0, react.useLayoutEffect)(() => {
@@ -2561,6 +2572,7 @@ function DefaultToolCallRenderer({ name, toolCallId, parameters, status, result
2561
2572
  //#endregion
2562
2573
  //#region src/hooks/use-human-in-the-loop.tsx
2563
2574
  function useHumanInTheLoop(tool, deps) {
2575
+ (0, _copilotkit_core.ɵcheckToolParameters)("useHumanInTheLoop", tool.parameters);
2564
2576
  const { copilotkit } = (0, _copilotkit_react_core_context.useCopilotKit)();
2565
2577
  const registry = copilotkit.ɵhumanInTheLoop;
2566
2578
  const RenderComponent = (0, react.useCallback)((props) => react.default.createElement(tool.render, (0, _copilotkit_core.ɵhitlRenderProps)(props, tool, registry)), [
@@ -2900,6 +2912,11 @@ function useInterrupt(config) {
2900
2912
  * `deleteThread`) return promises that resolve once the platform confirms the
2901
2913
  * operation and reject with an `Error` on failure.
2902
2914
  *
2915
+ * In 1.x, `useThreads()` returned the current thread. A call without
2916
+ * arguments throws a `CopilotKitRemovedApiError`, and so does a read of
2917
+ * `threadId`, `setThreadId`, or `isThreadIdExplicit` on the result. Read the
2918
+ * current thread from `useCopilotChatConfiguration()`.
2919
+ *
2903
2920
  * @param input - Agent identifier and optional list controls.
2904
2921
  * @returns Thread list state and stable mutation callbacks.
2905
2922
  *
@@ -2928,7 +2945,9 @@ function useInterrupt(config) {
2928
2945
  * }
2929
2946
  * ```
2930
2947
  */
2931
- function useThreads({ agentId, includeArchived, limit, enabled = true }) {
2948
+ function useThreads(input) {
2949
+ checkThreadsInput(input);
2950
+ const { agentId, includeArchived, limit, enabled = true } = input;
2932
2951
  const { copilotkit } = (0, _copilotkit_react_core_context.useCopilotKit)();
2933
2952
  const [controller] = (0, react.useState)(() => new _copilotkit_core.ɵThreadsController((0, _copilotkit_core.ɵcreateThreadStore)({ fetch: copilotkit.ɵruntimeFetch }), {
2934
2953
  core: copilotkit,
@@ -2962,7 +2981,7 @@ function useThreads({ agentId, includeArchived, limit, enabled = true }) {
2962
2981
  copilotkit.threadEndpoints?.mutations
2963
2982
  ]);
2964
2983
  const { fetchMoreThreads, refetchThreads, startNewThread, renameThread, archiveThread, unarchiveThread, deleteThread } = controller;
2965
- return {
2984
+ return withRemovedThreadFields({
2966
2985
  threads,
2967
2986
  isLoading,
2968
2987
  error,
@@ -2978,7 +2997,42 @@ function useThreads({ agentId, includeArchived, limit, enabled = true }) {
2978
2997
  archiveThread,
2979
2998
  unarchiveThread,
2980
2999
  deleteThread
2981
- };
3000
+ });
3001
+ }
3002
+ const USE_THREADS_SECTION = "/migrate/removed-apis-2.0#usethreads";
3003
+ /** Throws for the 1.x call `useThreads()`, which has no input. */
3004
+ function checkThreadsInput(input) {
3005
+ if (input !== void 0) return;
3006
+ throw new _copilotkit_shared.CopilotKitRemovedApiError({
3007
+ what: "\"useThreads()\" without arguments",
3008
+ use: "useThreads({ agentId }) lists the threads of an agent. To read or set the current thread, use useCopilotChatConfiguration() from @copilotkit/react-core.",
3009
+ docs: USE_THREADS_SECTION
3010
+ });
3011
+ }
3012
+ /** The fields of the 1.x `useThreads()` result, and what to use in 2.0. */
3013
+ const REMOVED_THREAD_FIELDS = {
3014
+ threadId: "Read threadId from useCopilotChatConfiguration() of @copilotkit/react-core.",
3015
+ setThreadId: "Call setActiveThreadId(threadId) on useCopilotChatConfiguration() of @copilotkit/react-core.",
3016
+ isThreadIdExplicit: "Read hasExplicitThreadId from useCopilotChatConfiguration() of @copilotkit/react-core."
3017
+ };
3018
+ /**
3019
+ * Adds a getter that throws a `CopilotKitRemovedApiError` for each field of
3020
+ * the 1.x result. The getters are not enumerable, so a spread, a JSON copy,
3021
+ * or devtools do not call them.
3022
+ */
3023
+ function withRemovedThreadFields(result) {
3024
+ const fields = Object.entries(REMOVED_THREAD_FIELDS);
3025
+ for (const [field, use] of fields) Object.defineProperty(result, field, {
3026
+ enumerable: false,
3027
+ get() {
3028
+ throw new _copilotkit_shared.CopilotKitRemovedApiError({
3029
+ what: `"${field}" from useThreads`,
3030
+ use: `${use} useThreads({ agentId }) lists the threads of an agent.`,
3031
+ docs: USE_THREADS_SECTION
3032
+ });
3033
+ }
3034
+ });
3035
+ return result;
2982
3036
  }
2983
3037
 
2984
3038
  //#endregion
@@ -10267,6 +10321,18 @@ Object.defineProperty(exports, 'ɵcanPreviewDocument', {
10267
10321
  return _copilotkit_core.ɵcanPreviewDocument;
10268
10322
  }
10269
10323
  });
10324
+ Object.defineProperty(exports, 'ɵcheckRemovedProviderProps', {
10325
+ enumerable: true,
10326
+ get: function () {
10327
+ return _copilotkit_core.ɵcheckRemovedProviderProps;
10328
+ }
10329
+ });
10330
+ Object.defineProperty(exports, 'ɵcheckToolParameters', {
10331
+ enumerable: true,
10332
+ get: function () {
10333
+ return _copilotkit_core.ɵcheckToolParameters;
10334
+ }
10335
+ });
10270
10336
  Object.defineProperty(exports, 'ɵclampSlashIndex', {
10271
10337
  enumerable: true,
10272
10338
  get: function () {