@copilotkitnext/react 0.0.34-alpha.0 → 0.0.34-pr.fix-express-endpoint

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.mts CHANGED
@@ -741,4 +741,4 @@ interface CopilotKitProviderProps {
741
741
  declare const CopilotKitProvider: React__default.FC<CopilotKitProviderProps>;
742
742
  declare const useCopilotKit: () => CopilotKitContextValue;
743
743
 
744
- export { type AgentContextInput, AudioRecorderError, type AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, type CopilotChatAssistantMessageProps, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatInput, type CopilotChatInputProps, type CopilotChatLabels, CopilotChatMessageView, type CopilotChatMessageViewProps, type CopilotChatProps, CopilotChatSuggestionPill, type CopilotChatSuggestionPillProps, CopilotChatSuggestionView, type CopilotChatSuggestionViewProps, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, type CopilotChatToggleButtonProps, CopilotChatToolCallsView, type CopilotChatToolCallsViewProps, CopilotChatUserMessage, type CopilotChatUserMessageProps, CopilotChatView, type CopilotChatViewProps, type CopilotKitContextValue, CopilotKitCoreReact, type CopilotKitCoreReactConfig, type CopilotKitCoreReactSubscriber, CopilotKitInspector, type CopilotKitInspectorProps, CopilotKitProvider, type CopilotKitProviderProps, CopilotModalHeader, type CopilotModalHeaderProps, CopilotPopup, type CopilotPopupProps, CopilotPopupView, type CopilotPopupViewProps, CopilotSidebar, type CopilotSidebarProps, CopilotSidebarView, type CopilotSidebarViewProps, type JsonSerializable, type MCPAppsActivityContent, MCPAppsActivityContentSchema, MCPAppsActivityRenderer, MCPAppsActivityType, type ReactActivityMessageRenderer, type ReactCustomMessageRenderer, type ReactCustomMessageRendererPosition, type ReactFrontendTool, type ReactHumanInTheLoop, type ReactToolCallRenderer, type ToolsMenuItem, WildcardToolCallRender, defineToolCallRenderer, useAgent, useAgentContext, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useFrontendTool, useHumanInTheLoop, useRenderActivityMessage, useRenderCustomMessages, useRenderToolCall, useSuggestions };
744
+ export { type AgentContextInput, AudioRecorderError, type AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, type CopilotChatAssistantMessageProps, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatInput, type CopilotChatInputProps, type CopilotChatLabels, CopilotChatMessageView, type CopilotChatMessageViewProps, type CopilotChatProps, CopilotChatSuggestionPill, type CopilotChatSuggestionPillProps, CopilotChatSuggestionView, type CopilotChatSuggestionViewProps, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, type CopilotChatToggleButtonProps, CopilotChatToolCallsView, type CopilotChatToolCallsViewProps, CopilotChatUserMessage, type CopilotChatUserMessageProps, CopilotChatView, type CopilotChatViewProps, type CopilotKitContextValue, CopilotKitCoreReact, type CopilotKitCoreReactConfig, type CopilotKitCoreReactSubscriber, CopilotKitInspector, type CopilotKitInspectorProps, CopilotKitProvider, type CopilotKitProviderProps, CopilotModalHeader, type CopilotModalHeaderProps, CopilotPopup, type CopilotPopupProps, CopilotPopupView, type CopilotPopupViewProps, CopilotSidebar, type CopilotSidebarProps, CopilotSidebarView, type CopilotSidebarViewProps, type JsonSerializable, type MCPAppsActivityContent, MCPAppsActivityContentSchema, MCPAppsActivityRenderer, MCPAppsActivityType, type ReactActivityMessageRenderer, type ReactCustomMessageRenderer, type ReactCustomMessageRendererPosition, type ReactFrontendTool, type ReactHumanInTheLoop, type ReactToolCallRenderer, type ToolsMenuItem, UseAgentUpdate, WildcardToolCallRender, defineToolCallRenderer, useAgent, useAgentContext, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useFrontendTool, useHumanInTheLoop, useRenderActivityMessage, useRenderCustomMessages, useRenderToolCall, useSuggestions };
package/dist/index.d.ts CHANGED
@@ -741,4 +741,4 @@ interface CopilotKitProviderProps {
741
741
  declare const CopilotKitProvider: React__default.FC<CopilotKitProviderProps>;
742
742
  declare const useCopilotKit: () => CopilotKitContextValue;
743
743
 
744
- export { type AgentContextInput, AudioRecorderError, type AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, type CopilotChatAssistantMessageProps, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatInput, type CopilotChatInputProps, type CopilotChatLabels, CopilotChatMessageView, type CopilotChatMessageViewProps, type CopilotChatProps, CopilotChatSuggestionPill, type CopilotChatSuggestionPillProps, CopilotChatSuggestionView, type CopilotChatSuggestionViewProps, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, type CopilotChatToggleButtonProps, CopilotChatToolCallsView, type CopilotChatToolCallsViewProps, CopilotChatUserMessage, type CopilotChatUserMessageProps, CopilotChatView, type CopilotChatViewProps, type CopilotKitContextValue, CopilotKitCoreReact, type CopilotKitCoreReactConfig, type CopilotKitCoreReactSubscriber, CopilotKitInspector, type CopilotKitInspectorProps, CopilotKitProvider, type CopilotKitProviderProps, CopilotModalHeader, type CopilotModalHeaderProps, CopilotPopup, type CopilotPopupProps, CopilotPopupView, type CopilotPopupViewProps, CopilotSidebar, type CopilotSidebarProps, CopilotSidebarView, type CopilotSidebarViewProps, type JsonSerializable, type MCPAppsActivityContent, MCPAppsActivityContentSchema, MCPAppsActivityRenderer, MCPAppsActivityType, type ReactActivityMessageRenderer, type ReactCustomMessageRenderer, type ReactCustomMessageRendererPosition, type ReactFrontendTool, type ReactHumanInTheLoop, type ReactToolCallRenderer, type ToolsMenuItem, WildcardToolCallRender, defineToolCallRenderer, useAgent, useAgentContext, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useFrontendTool, useHumanInTheLoop, useRenderActivityMessage, useRenderCustomMessages, useRenderToolCall, useSuggestions };
744
+ export { type AgentContextInput, AudioRecorderError, type AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, type CopilotChatAssistantMessageProps, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatInput, type CopilotChatInputProps, type CopilotChatLabels, CopilotChatMessageView, type CopilotChatMessageViewProps, type CopilotChatProps, CopilotChatSuggestionPill, type CopilotChatSuggestionPillProps, CopilotChatSuggestionView, type CopilotChatSuggestionViewProps, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, type CopilotChatToggleButtonProps, CopilotChatToolCallsView, type CopilotChatToolCallsViewProps, CopilotChatUserMessage, type CopilotChatUserMessageProps, CopilotChatView, type CopilotChatViewProps, type CopilotKitContextValue, CopilotKitCoreReact, type CopilotKitCoreReactConfig, type CopilotKitCoreReactSubscriber, CopilotKitInspector, type CopilotKitInspectorProps, CopilotKitProvider, type CopilotKitProviderProps, CopilotModalHeader, type CopilotModalHeaderProps, CopilotPopup, type CopilotPopupProps, CopilotPopupView, type CopilotPopupViewProps, CopilotSidebar, type CopilotSidebarProps, CopilotSidebarView, type CopilotSidebarViewProps, type JsonSerializable, type MCPAppsActivityContent, MCPAppsActivityContentSchema, MCPAppsActivityRenderer, MCPAppsActivityType, type ReactActivityMessageRenderer, type ReactCustomMessageRenderer, type ReactCustomMessageRendererPosition, type ReactFrontendTool, type ReactHumanInTheLoop, type ReactToolCallRenderer, type ToolsMenuItem, UseAgentUpdate, WildcardToolCallRender, defineToolCallRenderer, useAgent, useAgentContext, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useFrontendTool, useHumanInTheLoop, useRenderActivityMessage, useRenderCustomMessages, useRenderToolCall, useSuggestions };
package/dist/index.js CHANGED
@@ -58,6 +58,7 @@ __export(index_exports, {
58
58
  MCPAppsActivityContentSchema: () => MCPAppsActivityContentSchema,
59
59
  MCPAppsActivityRenderer: () => MCPAppsActivityRenderer,
60
60
  MCPAppsActivityType: () => MCPAppsActivityType,
61
+ UseAgentUpdate: () => UseAgentUpdate,
61
62
  WildcardToolCallRender: () => WildcardToolCallRender,
62
63
  defineToolCallRenderer: () => defineToolCallRenderer,
63
64
  useAgent: () => useAgent,
@@ -2349,6 +2350,12 @@ function useHumanInTheLoop(tool, deps) {
2349
2350
  var import_react13 = require("react");
2350
2351
  var import_shared5 = require("@copilotkitnext/shared");
2351
2352
  var import_core3 = require("@copilotkitnext/core");
2353
+ var UseAgentUpdate = /* @__PURE__ */ ((UseAgentUpdate2) => {
2354
+ UseAgentUpdate2["OnMessagesChanged"] = "OnMessagesChanged";
2355
+ UseAgentUpdate2["OnStateChanged"] = "OnStateChanged";
2356
+ UseAgentUpdate2["OnRunStatusChanged"] = "OnRunStatusChanged";
2357
+ return UseAgentUpdate2;
2358
+ })(UseAgentUpdate || {});
2352
2359
  var ALL_UPDATES = [
2353
2360
  "OnMessagesChanged" /* OnMessagesChanged */,
2354
2361
  "OnStateChanged" /* OnStateChanged */,
@@ -3360,6 +3367,7 @@ var MemoizedCustomMessage = import_react22.default.memo(
3360
3367
  if (prevProps.position !== nextProps.position) return false;
3361
3368
  if (prevProps.message.content !== nextProps.message.content) return false;
3362
3369
  if (prevProps.message.role !== nextProps.message.role) return false;
3370
+ if (JSON.stringify(prevProps.stateSnapshot) !== JSON.stringify(nextProps.stateSnapshot)) return false;
3363
3371
  return true;
3364
3372
  }
3365
3373
  );
@@ -3375,8 +3383,27 @@ function CopilotChatMessageView({
3375
3383
  }) {
3376
3384
  const renderCustomMessage = useRenderCustomMessages();
3377
3385
  const renderActivityMessage = useRenderActivityMessage();
3386
+ const { copilotkit } = useCopilotKit();
3387
+ const config = useCopilotChatConfiguration();
3388
+ const [, forceUpdate] = (0, import_react22.useReducer)((x) => x + 1, 0);
3389
+ (0, import_react22.useEffect)(() => {
3390
+ if (!config?.agentId) return;
3391
+ const agent = copilotkit.getAgent(config.agentId);
3392
+ if (!agent) return;
3393
+ const subscription = agent.subscribe({
3394
+ onStateChanged: () => forceUpdate()
3395
+ });
3396
+ return () => subscription.unsubscribe();
3397
+ }, [config?.agentId, copilotkit]);
3398
+ const getStateSnapshotForMessage = (messageId) => {
3399
+ if (!config) return void 0;
3400
+ const runId = copilotkit.getRunIdForMessage(config.agentId, config.threadId, messageId);
3401
+ if (!runId) return void 0;
3402
+ return copilotkit.getStateByRun(config.agentId, config.threadId, runId);
3403
+ };
3378
3404
  const messageElements = messages.flatMap((message) => {
3379
3405
  const elements = [];
3406
+ const stateSnapshot = getStateSnapshotForMessage(message.id);
3380
3407
  if (renderCustomMessage) {
3381
3408
  elements.push(
3382
3409
  /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
@@ -3384,7 +3411,8 @@ function CopilotChatMessageView({
3384
3411
  {
3385
3412
  message,
3386
3413
  position: "before",
3387
- renderCustomMessage
3414
+ renderCustomMessage,
3415
+ stateSnapshot
3388
3416
  },
3389
3417
  `${message.id}-custom-before`
3390
3418
  )
@@ -3435,7 +3463,8 @@ function CopilotChatMessageView({
3435
3463
  {
3436
3464
  message,
3437
3465
  position: "after",
3438
- renderCustomMessage
3466
+ renderCustomMessage,
3467
+ stateSnapshot
3439
3468
  },
3440
3469
  `${message.id}-custom-after`
3441
3470
  )
@@ -4538,6 +4567,7 @@ var WildcardToolCallRender = defineToolCallRenderer({
4538
4567
  MCPAppsActivityContentSchema,
4539
4568
  MCPAppsActivityRenderer,
4540
4569
  MCPAppsActivityType,
4570
+ UseAgentUpdate,
4541
4571
  WildcardToolCallRender,
4542
4572
  defineToolCallRenderer,
4543
4573
  useAgent,