@copilotkit/react-core 1.59.2 → 1.59.3

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
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_copilotkit = require('./copilotkit-IQO0VDZb.cjs');
4
+ const require_copilotkit = require('./copilotkit-DhONbYmz.cjs');
5
5
  let react = require("react");
6
6
  react = require_copilotkit.__toESM(react);
7
7
  let _copilotkit_core = require("@copilotkit/core");
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { B as useInterrupt, G as useAgent, H as useSuggestions, J as useFrontendTool$1, K as useHumanInTheLoop$1, V as useConfigureSuggestions, X as useRenderCustomMessages, a as ThreadsProvider, c as CoAgentStateRendersProvider, d as shouldShowDevConsole, f as useToast, g as useCopilotContext, gt as useCopilotChatConfiguration, h as CopilotContext, i as ThreadsContext, l as useCoAgentStateRenders, lt as defineToolCallRenderer, m as useCopilotMessagesContext, n as defaultCopilotContextCategories, o as useThreads, ot as useRenderToolCall$1, p as CopilotMessagesContext, r as CoAgentStateRenderBridge, s as CoAgentStateRendersContext, t as CopilotKit, u as useAsyncCallback, ut as useCopilotKit } from "./copilotkit-B5RsC6la.mjs";
3
+ import { B as useInterrupt, G as useAgent, H as useSuggestions, J as useFrontendTool$1, K as useHumanInTheLoop$1, V as useConfigureSuggestions, X as useRenderCustomMessages, a as ThreadsProvider, c as CoAgentStateRendersProvider, d as shouldShowDevConsole, f as useToast, g as useCopilotContext, gt as useCopilotChatConfiguration, h as CopilotContext, i as ThreadsContext, l as useCoAgentStateRenders, lt as defineToolCallRenderer, m as useCopilotMessagesContext, n as defaultCopilotContextCategories, o as useThreads, ot as useRenderToolCall$1, p as CopilotMessagesContext, r as CoAgentStateRenderBridge, s as CoAgentStateRendersContext, t as CopilotKit, u as useAsyncCallback, ut as useCopilotKit } from "./copilotkit-BRNy5UvX.mjs";
4
4
  import React, { Fragment, createElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
5
5
  import { CopilotKitCoreRuntimeConnectionStatus, ToolCallStatus } from "@copilotkit/core";
6
6
  import { AGUIConnectNotImplementedError, HttpAgent } from "@ag-ui/client";
package/dist/v2/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_copilotkit = require('../copilotkit-IQO0VDZb.cjs');
4
+ const require_copilotkit = require('../copilotkit-DhONbYmz.cjs');
5
5
  require("./index.css");
6
6
  let _copilotkit_a2ui_renderer = require("@copilotkit/a2ui-renderer");
7
7
 
package/dist/v2/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { $ as createA2UIMessageRenderer, A as IntelligenceIndicator, B as useInterrupt, C as CopilotChatToggleButton, D as CopilotChatView_default, E as CopilotChat, F as CopilotChatAttachmentRenderer, G as useAgent, H as useSuggestions, I as CopilotChatAssistantMessage_default, J as useFrontendTool, K as useHumanInTheLoop, L as CopilotChatToolCallsView, M as CopilotChatSuggestionPill, N as CopilotChatReasoningMessage_default, O as CopilotChatAttachmentQueue, P as CopilotChatUserMessage_default, Q as useAgentContext, R as useAttachments, S as CopilotModalHeader, T as DefaultOpenIcon, U as useCapabilities, V as useConfigureSuggestions, W as UseAgentUpdate, X as useRenderCustomMessages, Y as useRenderActivityMessage, Z as CopilotKitProvider, _ as WildcardToolCallRender, at as CopilotKitInspector, b as CopilotPopupView, ct as useRenderTool, dt as CopilotKitCoreReact, et as SandboxFunctionsContext, ft as CopilotChatInput_default, gt as useCopilotChatConfiguration, ht as CopilotChatConfigurationProvider, it as MCPAppsActivityType, j as CopilotChatSuggestionView, k as CopilotChatMessageView, lt as defineToolCallRenderer, mt as CopilotChatAudioRecorder, nt as MCPAppsActivityContentSchema, ot as useRenderToolCall, pt as AudioRecorderError, q as useComponent, rt as MCPAppsActivityRenderer, st as useDefaultRenderTool, t as CopilotKit, tt as useSandboxFunctions, ut as useCopilotKit, v as CopilotPopup, w as DefaultCloseIcon, x as CopilotSidebarView, y as CopilotSidebar, z as useThreads } from "../copilotkit-B5RsC6la.mjs";
3
+ import { $ as createA2UIMessageRenderer, A as IntelligenceIndicator, B as useInterrupt, C as CopilotChatToggleButton, D as CopilotChatView_default, E as CopilotChat, F as CopilotChatAttachmentRenderer, G as useAgent, H as useSuggestions, I as CopilotChatAssistantMessage_default, J as useFrontendTool, K as useHumanInTheLoop, L as CopilotChatToolCallsView, M as CopilotChatSuggestionPill, N as CopilotChatReasoningMessage_default, O as CopilotChatAttachmentQueue, P as CopilotChatUserMessage_default, Q as useAgentContext, R as useAttachments, S as CopilotModalHeader, T as DefaultOpenIcon, U as useCapabilities, V as useConfigureSuggestions, W as UseAgentUpdate, X as useRenderCustomMessages, Y as useRenderActivityMessage, Z as CopilotKitProvider, _ as WildcardToolCallRender, at as CopilotKitInspector, b as CopilotPopupView, ct as useRenderTool, dt as CopilotKitCoreReact, et as SandboxFunctionsContext, ft as CopilotChatInput_default, gt as useCopilotChatConfiguration, ht as CopilotChatConfigurationProvider, it as MCPAppsActivityType, j as CopilotChatSuggestionView, k as CopilotChatMessageView, lt as defineToolCallRenderer, mt as CopilotChatAudioRecorder, nt as MCPAppsActivityContentSchema, ot as useRenderToolCall, pt as AudioRecorderError, q as useComponent, rt as MCPAppsActivityRenderer, st as useDefaultRenderTool, t as CopilotKit, tt as useSandboxFunctions, ut as useCopilotKit, v as CopilotPopup, w as DefaultCloseIcon, x as CopilotSidebarView, y as CopilotSidebar, z as useThreads } from "../copilotkit-BRNy5UvX.mjs";
4
4
  import "./index.css";
5
5
  import { defaultTheme as a2uiDefaultTheme } from "@copilotkit/a2ui-renderer";
6
6
 
@@ -780,7 +780,7 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
780
780
  }
781
781
  if (e.key === "Enter" && !e.shiftKey) {
782
782
  e.preventDefault();
783
- if (isProcessing) onStop?.();
783
+ if (isProcessing && !canSend) onStop?.();
784
784
  else send();
785
785
  }
786
786
  };
@@ -7139,6 +7139,10 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
7139
7139
  const [transcriptionError, setTranscriptionError] = (0, react.useState)(null);
7140
7140
  const [isTranscribing, setIsTranscribing] = (0, react.useState)(false);
7141
7141
  const { attachments: selectedAttachments, enabled: attachmentsEnabled, dragOver, fileInputRef, containerRef: chatContainerRef, handleFileUpload, handleDragOver, handleDragLeave, handleDrop, removeAttachment, consumeAttachments } = useAttachments({ config: attachmentsConfig });
7142
+ const selectedAttachmentsRef = (0, react.useRef)(selectedAttachments);
7143
+ (0, react.useEffect)(() => {
7144
+ selectedAttachmentsRef.current = selectedAttachments;
7145
+ }, [selectedAttachments]);
7142
7146
  const isTranscriptionEnabled = copilotkit.audioFileTranscriptionEnabled;
7143
7147
  const isMediaRecorderSupported = typeof window !== "undefined" && typeof MediaRecorder !== "undefined";
7144
7148
  const { messageView: providedMessageView, suggestionView: providedSuggestionView, onStop: providedStopHandler, ...restProps } = props;
@@ -7175,8 +7179,21 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
7175
7179
  hasExplicitThreadId
7176
7180
  ]);
7177
7181
  const onSubmitInput = (0, react.useCallback)(async (value) => {
7178
- if (selectedAttachments.some((a) => a.status === "uploading")) {
7179
- console.error("[CopilotKit] Cannot send while attachments are uploading");
7182
+ if (selectedAttachmentsRef.current.some((a) => a.status === "uploading")) {
7183
+ console.error("[CopilotKit] Cannot send while attachments are uploading (pre-await guard)");
7184
+ setTranscriptionError("Cannot send while attachments are uploading.");
7185
+ return;
7186
+ }
7187
+ setInputValue("");
7188
+ if (agent.isRunning && "activeRunCompletionPromise" in agent && agent.activeRunCompletionPromise) try {
7189
+ await agent.activeRunCompletionPromise;
7190
+ } catch (error) {
7191
+ console.error("CopilotChat: in-flight run rejected while queuing send", error);
7192
+ }
7193
+ if (selectedAttachmentsRef.current.some((a) => a.status === "uploading")) {
7194
+ console.error("[CopilotKit] Cannot send while attachments are uploading (post-await re-check)");
7195
+ setTranscriptionError("Cannot send while attachments are uploading.");
7196
+ setInputValue(value);
7180
7197
  return;
7181
7198
  }
7182
7199
  const readyAttachments = consumeAttachments();
@@ -7204,17 +7221,12 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
7204
7221
  role: "user",
7205
7222
  content: value
7206
7223
  });
7207
- setInputValue("");
7208
7224
  try {
7209
7225
  await copilotkit.runAgent({ agent });
7210
7226
  } catch (error) {
7211
7227
  console.error("CopilotChat: runAgent failed", error);
7212
7228
  }
7213
- }, [
7214
- agent,
7215
- selectedAttachments,
7216
- consumeAttachments
7217
- ]);
7229
+ }, [agent, consumeAttachments]);
7218
7230
  const handleSelectSuggestion = (0, react.useCallback)(async (suggestion) => {
7219
7231
  agent.addMessage({
7220
7232
  id: (0, _copilotkit_shared.randomUUID)(),