@copilotkitnext/react 1.54.0 → 1.54.1-next.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.
package/dist/index.d.cts CHANGED
@@ -41,6 +41,7 @@ import { AgentContextInput, JsonSerializable, useAgentContext } from "./hooks/us
41
41
  import { useSuggestions } from "./hooks/use-suggestions.cjs";
42
42
  import { useConfigureSuggestions } from "./hooks/use-configure-suggestions.cjs";
43
43
  import { UseInterruptConfig, useInterrupt } from "./hooks/use-interrupt.cjs";
44
+ import { Thread, UseThreadsInput, UseThreadsResult, useThreads } from "./hooks/use-threads.cjs";
44
45
  import "./hooks/index.cjs";
45
46
  import { CopilotKitCoreReact, CopilotKitCoreReactConfig, CopilotKitCoreReactSubscriber } from "./lib/react-core.cjs";
46
47
  import { CopilotKitContextValue, CopilotKitProvider, CopilotKitProviderProps, useCopilotKit } from "./providers/CopilotKitProvider.cjs";
@@ -48,4 +49,4 @@ import "./providers/index.cjs";
48
49
  import { A2UIMessageRendererOptions, createA2UIMessageRenderer } from "./a2ui/A2UIMessageRenderer.cjs";
49
50
  import { Theme as A2UITheme } from "@copilotkit/a2ui-renderer";
50
51
  export * from "@ag-ui/client";
51
- export { type A2UIMessageRendererOptions, type A2UITheme, AgentContextInput, AudioRecorderError, AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, CopilotChatAssistantMessageProps, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, CopilotChatConfigurationProviderProps, CopilotChatConfigurationValue, CopilotChatInput, CopilotChatInputProps, CopilotChatLabels, CopilotChatMessageView, CopilotChatMessageViewProps, CopilotChatProps, CopilotChatReasoningMessage, CopilotChatReasoningMessageProps, CopilotChatSuggestionPill, CopilotChatSuggestionPillProps, CopilotChatSuggestionView, CopilotChatSuggestionViewProps, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, CopilotChatToggleButtonProps, CopilotChatToolCallsView, CopilotChatToolCallsViewProps, CopilotChatUserMessage, CopilotChatUserMessageProps, CopilotChatView, CopilotChatViewProps, CopilotKitContextValue, CopilotKitCoreReact, CopilotKitCoreReactConfig, CopilotKitCoreReactSubscriber, CopilotKitInspector, CopilotKitInspectorProps, CopilotKitProvider, CopilotKitProviderProps, CopilotModalHeader, CopilotModalHeaderProps, CopilotPopup, CopilotPopupProps, CopilotPopupView, CopilotPopupViewProps, CopilotSidebar, CopilotSidebarProps, CopilotSidebarView, CopilotSidebarViewProps, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, MCPAppsActivityContent, MCPAppsActivityContentSchema, MCPAppsActivityRenderer, MCPAppsActivityType, ReactActivityMessageRenderer, ReactCustomMessageRenderer, ReactCustomMessageRendererPosition, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, ToolsMenuItem, UseAgentUpdate, UseInterruptConfig, WildcardToolCallRender, createA2UIMessageRenderer, defineToolCallRenderer, useAgent, useAgentContext, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useDefaultRenderTool, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderActivityMessage, useRenderCustomMessages, useRenderTool, useRenderToolCall, useSuggestions };
52
+ export { type A2UIMessageRendererOptions, type A2UITheme, AgentContextInput, AudioRecorderError, AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, CopilotChatAssistantMessageProps, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, CopilotChatConfigurationProviderProps, CopilotChatConfigurationValue, CopilotChatInput, CopilotChatInputProps, CopilotChatLabels, CopilotChatMessageView, CopilotChatMessageViewProps, CopilotChatProps, CopilotChatReasoningMessage, CopilotChatReasoningMessageProps, CopilotChatSuggestionPill, CopilotChatSuggestionPillProps, CopilotChatSuggestionView, CopilotChatSuggestionViewProps, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, CopilotChatToggleButtonProps, CopilotChatToolCallsView, CopilotChatToolCallsViewProps, CopilotChatUserMessage, CopilotChatUserMessageProps, CopilotChatView, CopilotChatViewProps, CopilotKitContextValue, CopilotKitCoreReact, CopilotKitCoreReactConfig, CopilotKitCoreReactSubscriber, CopilotKitInspector, CopilotKitInspectorProps, CopilotKitProvider, CopilotKitProviderProps, CopilotModalHeader, CopilotModalHeaderProps, CopilotPopup, CopilotPopupProps, CopilotPopupView, CopilotPopupViewProps, CopilotSidebar, CopilotSidebarProps, CopilotSidebarView, CopilotSidebarViewProps, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, MCPAppsActivityContent, MCPAppsActivityContentSchema, MCPAppsActivityRenderer, MCPAppsActivityType, ReactActivityMessageRenderer, ReactCustomMessageRenderer, ReactCustomMessageRendererPosition, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, Thread, ToolsMenuItem, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, WildcardToolCallRender, createA2UIMessageRenderer, defineToolCallRenderer, useAgent, useAgentContext, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useDefaultRenderTool, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderActivityMessage, useRenderCustomMessages, useRenderTool, useRenderToolCall, useSuggestions, useThreads };
package/dist/index.d.mts CHANGED
@@ -41,6 +41,7 @@ import { AgentContextInput, JsonSerializable, useAgentContext } from "./hooks/us
41
41
  import { useSuggestions } from "./hooks/use-suggestions.mjs";
42
42
  import { useConfigureSuggestions } from "./hooks/use-configure-suggestions.mjs";
43
43
  import { UseInterruptConfig, useInterrupt } from "./hooks/use-interrupt.mjs";
44
+ import { Thread, UseThreadsInput, UseThreadsResult, useThreads } from "./hooks/use-threads.mjs";
44
45
  import "./hooks/index.mjs";
45
46
  import { CopilotKitCoreReact, CopilotKitCoreReactConfig, CopilotKitCoreReactSubscriber } from "./lib/react-core.mjs";
46
47
  import { CopilotKitContextValue, CopilotKitProvider, CopilotKitProviderProps, useCopilotKit } from "./providers/CopilotKitProvider.mjs";
@@ -48,4 +49,4 @@ import "./providers/index.mjs";
48
49
  import { A2UIMessageRendererOptions, createA2UIMessageRenderer } from "./a2ui/A2UIMessageRenderer.mjs";
49
50
  import { Theme as A2UITheme } from "@copilotkit/a2ui-renderer";
50
51
  export * from "@ag-ui/client";
51
- export { type A2UIMessageRendererOptions, type A2UITheme, AgentContextInput, AudioRecorderError, AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, CopilotChatAssistantMessageProps, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, CopilotChatConfigurationProviderProps, CopilotChatConfigurationValue, CopilotChatInput, CopilotChatInputProps, CopilotChatLabels, CopilotChatMessageView, CopilotChatMessageViewProps, CopilotChatProps, CopilotChatReasoningMessage, CopilotChatReasoningMessageProps, CopilotChatSuggestionPill, CopilotChatSuggestionPillProps, CopilotChatSuggestionView, CopilotChatSuggestionViewProps, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, CopilotChatToggleButtonProps, CopilotChatToolCallsView, CopilotChatToolCallsViewProps, CopilotChatUserMessage, CopilotChatUserMessageProps, CopilotChatView, CopilotChatViewProps, CopilotKitContextValue, CopilotKitCoreReact, CopilotKitCoreReactConfig, CopilotKitCoreReactSubscriber, CopilotKitInspector, CopilotKitInspectorProps, CopilotKitProvider, CopilotKitProviderProps, CopilotModalHeader, CopilotModalHeaderProps, CopilotPopup, CopilotPopupProps, CopilotPopupView, CopilotPopupViewProps, CopilotSidebar, CopilotSidebarProps, CopilotSidebarView, CopilotSidebarViewProps, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, MCPAppsActivityContent, MCPAppsActivityContentSchema, MCPAppsActivityRenderer, MCPAppsActivityType, ReactActivityMessageRenderer, ReactCustomMessageRenderer, ReactCustomMessageRendererPosition, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, ToolsMenuItem, UseAgentUpdate, UseInterruptConfig, WildcardToolCallRender, createA2UIMessageRenderer, defineToolCallRenderer, useAgent, useAgentContext, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useDefaultRenderTool, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderActivityMessage, useRenderCustomMessages, useRenderTool, useRenderToolCall, useSuggestions };
52
+ export { type A2UIMessageRendererOptions, type A2UITheme, AgentContextInput, AudioRecorderError, AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, CopilotChatAssistantMessageProps, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, CopilotChatConfigurationProviderProps, CopilotChatConfigurationValue, CopilotChatInput, CopilotChatInputProps, CopilotChatLabels, CopilotChatMessageView, CopilotChatMessageViewProps, CopilotChatProps, CopilotChatReasoningMessage, CopilotChatReasoningMessageProps, CopilotChatSuggestionPill, CopilotChatSuggestionPillProps, CopilotChatSuggestionView, CopilotChatSuggestionViewProps, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, CopilotChatToggleButtonProps, CopilotChatToolCallsView, CopilotChatToolCallsViewProps, CopilotChatUserMessage, CopilotChatUserMessageProps, CopilotChatView, CopilotChatViewProps, CopilotKitContextValue, CopilotKitCoreReact, CopilotKitCoreReactConfig, CopilotKitCoreReactSubscriber, CopilotKitInspector, CopilotKitInspectorProps, CopilotKitProvider, CopilotKitProviderProps, CopilotModalHeader, CopilotModalHeaderProps, CopilotPopup, CopilotPopupProps, CopilotPopupView, CopilotPopupViewProps, CopilotSidebar, CopilotSidebarProps, CopilotSidebarView, CopilotSidebarViewProps, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, MCPAppsActivityContent, MCPAppsActivityContentSchema, MCPAppsActivityRenderer, MCPAppsActivityType, ReactActivityMessageRenderer, ReactCustomMessageRenderer, ReactCustomMessageRendererPosition, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, Thread, ToolsMenuItem, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, WildcardToolCallRender, createA2UIMessageRenderer, defineToolCallRenderer, useAgent, useAgentContext, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useDefaultRenderTool, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderActivityMessage, useRenderCustomMessages, useRenderTool, useRenderToolCall, useSuggestions, useThreads };
package/dist/index.mjs CHANGED
@@ -23,6 +23,7 @@ import { useAgentContext } from "./hooks/use-agent-context.mjs";
23
23
  import { useSuggestions } from "./hooks/use-suggestions.mjs";
24
24
  import { useConfigureSuggestions } from "./hooks/use-configure-suggestions.mjs";
25
25
  import { useInterrupt } from "./hooks/use-interrupt.mjs";
26
+ import { useThreads } from "./hooks/use-threads.mjs";
26
27
  import "./hooks/index.mjs";
27
28
  import CopilotChatToolCallsView from "./components/chat/CopilotChatToolCallsView.mjs";
28
29
  import CopilotChatAssistantMessage_default from "./components/chat/CopilotChatAssistantMessage.mjs";
@@ -45,4 +46,4 @@ import "./types/index.mjs";
45
46
 
46
47
  export * from "@ag-ui/client"
47
48
 
48
- export { AudioRecorderError, CopilotChat, CopilotChatAssistantMessage_default as CopilotChatAssistantMessage, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, CopilotChatInput_default as CopilotChatInput, CopilotChatMessageView, CopilotChatReasoningMessage_default as CopilotChatReasoningMessage, CopilotChatSuggestionPill, CopilotChatSuggestionView, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, CopilotChatToolCallsView, CopilotChatUserMessage_default as CopilotChatUserMessage, CopilotChatView_default as CopilotChatView, CopilotKitCoreReact, CopilotKitInspector, CopilotKitProvider, CopilotModalHeader, CopilotPopup, CopilotPopupView, CopilotSidebar, CopilotSidebarView, MCPAppsActivityContentSchema, MCPAppsActivityRenderer, MCPAppsActivityType, UseAgentUpdate, WildcardToolCallRender, createA2UIMessageRenderer, defineToolCallRenderer, useAgent, useAgentContext, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useDefaultRenderTool, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderActivityMessage, useRenderCustomMessages, useRenderTool, useRenderToolCall, useSuggestions };
49
+ export { AudioRecorderError, CopilotChat, CopilotChatAssistantMessage_default as CopilotChatAssistantMessage, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, CopilotChatInput_default as CopilotChatInput, CopilotChatMessageView, CopilotChatReasoningMessage_default as CopilotChatReasoningMessage, CopilotChatSuggestionPill, CopilotChatSuggestionView, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, CopilotChatToolCallsView, CopilotChatUserMessage_default as CopilotChatUserMessage, CopilotChatView_default as CopilotChatView, CopilotKitCoreReact, CopilotKitInspector, CopilotKitProvider, CopilotModalHeader, CopilotPopup, CopilotPopupView, CopilotSidebar, CopilotSidebarView, MCPAppsActivityContentSchema, MCPAppsActivityRenderer, MCPAppsActivityType, UseAgentUpdate, WildcardToolCallRender, createA2UIMessageRenderer, defineToolCallRenderer, useAgent, useAgentContext, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useDefaultRenderTool, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderActivityMessage, useRenderCustomMessages, useRenderTool, useRenderToolCall, useSuggestions, useThreads };
package/dist/index.umd.js CHANGED
@@ -2943,7 +2943,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
2943
2943
  const provisional = new _copilotkitnext_core.ProxiedCopilotRuntimeAgent({
2944
2944
  runtimeUrl: copilotkit.runtimeUrl,
2945
2945
  agentId,
2946
- transport: copilotkit.runtimeTransport
2946
+ transport: copilotkit.runtimeTransport,
2947
+ runtimeMode: "pending"
2947
2948
  });
2948
2949
  provisional.headers = { ...copilotkit.headers };
2949
2950
  provisionalAgentCache.current.set(agentId, provisional);
@@ -2953,7 +2954,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
2953
2954
  const provisional = new _copilotkitnext_core.ProxiedCopilotRuntimeAgent({
2954
2955
  runtimeUrl: copilotkit.runtimeUrl,
2955
2956
  agentId,
2956
- transport: copilotkit.runtimeTransport
2957
+ transport: copilotkit.runtimeTransport,
2958
+ runtimeMode: "pending"
2957
2959
  });
2958
2960
  provisional.headers = { ...copilotkit.headers };
2959
2961
  return provisional;
@@ -3378,6 +3380,108 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
3378
3380
  if (config.renderInChat === false) return element;
3379
3381
  }
3380
3382
 
3383
+ //#endregion
3384
+ //#region src/hooks/use-threads.tsx
3385
+ function useThreadStoreSelector(store, selector) {
3386
+ return (0, react.useSyncExternalStore)((0, react.useCallback)((onStoreChange) => {
3387
+ const subscription = store.select(selector).subscribe(onStoreChange);
3388
+ return () => subscription.unsubscribe();
3389
+ }, [store, selector]), () => selector(store.getState()));
3390
+ }
3391
+ /**
3392
+ * React hook for listing and managing Intelligence platform threads.
3393
+ *
3394
+ * On mount the hook fetches the thread list for the given `userId`/`agentId`
3395
+ * pair. When the Intelligence platform exposes a WebSocket URL, it also opens
3396
+ * a realtime subscription so the `threads` array stays current without
3397
+ * polling — thread creates, renames, archives, and deletes from any client
3398
+ * are reflected immediately.
3399
+ *
3400
+ * Mutation methods (`renameThread`, `archiveThread`, `deleteThread`) return
3401
+ * promises that resolve once the platform confirms the operation and reject
3402
+ * with an `Error` on failure.
3403
+ *
3404
+ * @param input - User and agent identifiers that scope the thread list.
3405
+ * @returns Thread list state and stable mutation callbacks.
3406
+ *
3407
+ * @example
3408
+ * ```tsx
3409
+ * import { useThreads } from "@copilotkitnext/react";
3410
+ *
3411
+ * function ThreadList() {
3412
+ * const { threads, isLoading, renameThread, deleteThread } = useThreads({
3413
+ * userId: "user-1",
3414
+ * agentId: "agent-1",
3415
+ * });
3416
+ *
3417
+ * if (isLoading) return <p>Loading…</p>;
3418
+ *
3419
+ * return (
3420
+ * <ul>
3421
+ * {threads.map((t) => (
3422
+ * <li key={t.id}>
3423
+ * {t.name ?? "Untitled"}
3424
+ * <button onClick={() => renameThread(t.id, "New name")}>Rename</button>
3425
+ * <button onClick={() => deleteThread(t.id)}>Delete</button>
3426
+ * </li>
3427
+ * ))}
3428
+ * </ul>
3429
+ * );
3430
+ * }
3431
+ * ```
3432
+ */
3433
+ function useThreads({ userId, agentId }) {
3434
+ var _copilotkit$intellige2;
3435
+ const { copilotkit } = useCopilotKit();
3436
+ const [store] = (0, react.useState)(() => (0, _copilotkitnext_core.ɵcreateThreadStore)({ fetch: globalThis.fetch }));
3437
+ const threads = useThreadStoreSelector(store, _copilotkitnext_core.ɵselectThreads);
3438
+ const storeIsLoading = useThreadStoreSelector(store, _copilotkitnext_core.ɵselectThreadsIsLoading);
3439
+ const storeError = useThreadStoreSelector(store, _copilotkitnext_core.ɵselectThreadsError);
3440
+ const headersKey = (0, react.useMemo)(() => {
3441
+ var _copilotkit$headers;
3442
+ return JSON.stringify(Object.entries((_copilotkit$headers = copilotkit.headers) !== null && _copilotkit$headers !== void 0 ? _copilotkit$headers : {}).sort(([left], [right]) => left.localeCompare(right)));
3443
+ }, [copilotkit.headers]);
3444
+ const runtimeError = (0, react.useMemo)(() => {
3445
+ if (copilotkit.runtimeUrl) return null;
3446
+ return /* @__PURE__ */ new Error("Runtime URL is not configured");
3447
+ }, [copilotkit.runtimeUrl]);
3448
+ const isLoading = runtimeError ? false : storeIsLoading;
3449
+ const error = runtimeError !== null && runtimeError !== void 0 ? runtimeError : storeError;
3450
+ (0, react.useEffect)(() => {
3451
+ store.start();
3452
+ return () => {
3453
+ store.stop();
3454
+ };
3455
+ }, [store]);
3456
+ (0, react.useEffect)(() => {
3457
+ var _copilotkit$intellige;
3458
+ const context = copilotkit.runtimeUrl ? {
3459
+ runtimeUrl: copilotkit.runtimeUrl,
3460
+ headers: { ...copilotkit.headers },
3461
+ wsUrl: (_copilotkit$intellige = copilotkit.intelligence) === null || _copilotkit$intellige === void 0 ? void 0 : _copilotkit$intellige.wsUrl,
3462
+ userId,
3463
+ agentId
3464
+ } : null;
3465
+ store.setContext(context);
3466
+ }, [
3467
+ store,
3468
+ copilotkit.runtimeUrl,
3469
+ headersKey,
3470
+ (_copilotkit$intellige2 = copilotkit.intelligence) === null || _copilotkit$intellige2 === void 0 ? void 0 : _copilotkit$intellige2.wsUrl,
3471
+ userId,
3472
+ agentId,
3473
+ copilotkit.headers
3474
+ ]);
3475
+ return {
3476
+ threads,
3477
+ isLoading,
3478
+ error,
3479
+ renameThread: (0, react.useCallback)((threadId, name) => store.renameThread(threadId, name), [store]),
3480
+ archiveThread: (0, react.useCallback)((threadId) => store.archiveThread(threadId), [store]),
3481
+ deleteThread: (0, react.useCallback)((threadId) => store.deleteThread(threadId), [store])
3482
+ };
3483
+ }
3484
+
3381
3485
  //#endregion
3382
3486
  //#region src/components/chat/CopilotChatToolCallsView.tsx
3383
3487
  function CopilotChatToolCallsView({ message, messages = [] }) {
@@ -5455,6 +5559,7 @@ exports.useRenderCustomMessages = useRenderCustomMessages;
5455
5559
  exports.useRenderTool = useRenderTool;
5456
5560
  exports.useRenderToolCall = useRenderToolCall;
5457
5561
  exports.useSuggestions = useSuggestions;
5562
+ exports.useThreads = useThreads;
5458
5563
  Object.keys(_ag_ui_client).forEach(function (k) {
5459
5564
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
5460
5565
  enumerable: true,