@copilotkit/react-core 1.73.0 → 1.73.2-canary.1790068297

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.
@@ -1,10 +1,10 @@
1
1
  import * as React$1 from "react";
2
2
  import React, { createContext, createElement, forwardRef, memo, useCallback, useContext, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
3
- import { CopilotKitCore, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, ProxiedCopilotRuntimeAgent, ToolCallStatus, emitInspectorActiveThread, emitInspectorViewThreadResult, isInspectorThreadBridgeEnabled, isRunCompletionAware, onInspectorStopViewing, onInspectorViewThread, ɵInterruptState, ɵcreateThreadStore, ɵselectFetchMoreError, ɵselectHasNextPage, ɵselectIsFetchingNextPage, ɵselectIsMutating, ɵselectMemories, ɵselectMemoriesAvailable, ɵselectMemoriesError, ɵselectMemoriesIsLoading, ɵselectMemoriesRealtimeStatus, ɵselectThreads, ɵselectThreadsError, ɵselectThreadsIsLoading } from "@copilotkit/core";
4
- import { HttpAgent, randomUUID } from "@ag-ui/client";
3
+ import { AgentRegistry, AgentThreadLockedError, ContextStore, CopilotKitCore, CopilotKitCore as CopilotKitCore$1, CopilotKitCoreErrorCode, CopilotKitCoreErrorCode as CopilotKitCoreErrorCode$1, CopilotKitCoreRuntimeConnectionStatus, CopilotKitCoreRuntimeConnectionStatus as CopilotKitCoreRuntimeConnectionStatus$1, INSPECTOR_THREAD_BRIDGE_PLUGIN_ID, IntelligenceAgent, MEMORY_ERROR_REGISTRY, MemoryError, ProxiedCopilotRuntimeAgent, ProxiedCopilotRuntimeAgent as ProxiedCopilotRuntimeAgent$1, RunHandler, StateManager, SuggestionEngine, ToolCallStatus, ToolCallStatus as ToolCallStatus$1, WebMCPRegistry, completePartialMarkdown, createActionGroup, createEffect, createInspectorThreadRequestId, createReducer, createSelector, createStore, emitInspectorActiveThread, emitInspectorActiveThread as emitInspectorActiveThread$1, emitInspectorStopViewing, emitInspectorViewThread, emitInspectorViewThreadResult, emitInspectorViewThreadResult as emitInspectorViewThreadResult$1, empty, ensureObjectArgs, getWebMCPModelContext, isAbortError, isInspectorThreadBridgeEnabled, isInspectorThreadBridgeEnabled as isInspectorThreadBridgeEnabled$1, isRunCompletionAware, isRunCompletionAware as isRunCompletionAware$1, ofType, on, onInspectorActiveThread, onInspectorStopViewing, onInspectorStopViewing as onInspectorStopViewing$1, onInspectorViewThread, onInspectorViewThread as onInspectorViewThread$1, onInspectorViewThreadResult, parseToolArguments, props, select, ɵCOPILOTKIT_FEATURES, ɵInterruptState, ɵInterruptState as ɵInterruptState$1, ɵMAX_SOCKET_RETRIES, ɵRUNTIME_PROBE_TIMEOUT_MS, ɵTHREAD_REQUEST_TIMEOUT_MS, ɵcreateMemoryStore, ɵcreateThreadSelectors, ɵcreateThreadStore, ɵcreateThreadStore as ɵcreateThreadStore$1, ɵisCopilotKitFeature, ɵisRetryableMemoryStatus, ɵjoinPhoenixChannel$, ɵmapMemoryMetadataEvent, ɵmemoryAdapterEvents, ɵmemoryDomainEvents, ɵmemoryReducer, ɵmemoryRestEvents, ɵobservePhoenixEvent$, ɵobservePhoenixJoinOutcome$, ɵobservePhoenixSocketHealth$, ɵobservePhoenixSocketSignals$, ɵphoenixChannel$, ɵphoenixSocket$, ɵselectFetchMoreError, ɵselectFetchMoreError as ɵselectFetchMoreError$1, ɵselectHasNextPage, ɵselectHasNextPage as ɵselectHasNextPage$1, ɵselectIsFetchingNextPage, ɵselectIsFetchingNextPage as ɵselectIsFetchingNextPage$1, ɵselectIsMutating, ɵselectIsMutating as ɵselectIsMutating$1, ɵselectMemories, ɵselectMemories as ɵselectMemories$1, ɵselectMemoriesAvailable, ɵselectMemoriesAvailable as ɵselectMemoriesAvailable$1, ɵselectMemoriesError, ɵselectMemoriesError as ɵselectMemoriesError$1, ɵselectMemoriesIsLoading, ɵselectMemoriesIsLoading as ɵselectMemoriesIsLoading$1, ɵselectMemoriesIsMutating, ɵselectMemoriesRealtimeStatus, ɵselectMemoriesRealtimeStatus as ɵselectMemoriesRealtimeStatus$1, ɵselectThreads, ɵselectThreads as ɵselectThreads$1, ɵselectThreadsError, ɵselectThreadsError as ɵselectThreadsError$1, ɵselectThreadsIsLoading, ɵselectThreadsIsLoading as ɵselectThreadsIsLoading$1, ɵthreadAdapterEvents } from "@copilotkit/core";
4
+ import { AGUIConnectNotImplementedError as AGUIConnectNotImplementedError$1, AGUIError, AGUI_METADATA_KEY, AbstractAgent as AbstractAgent$1, ActivityDeltaEventSchema, ActivityMessageSchema, ActivitySnapshotEventSchema, AgentCapabilitiesSchema, AssistantMessageSchema, AudioInputContentSchema, AudioInputPartSchema, BackwardCompatibility_0_0_39, BackwardCompatibility_0_0_45, BackwardCompatibility_0_0_47, BackwardCompatibility_0_0_57, BaseEventSchema, BaseMessageSchema, BinaryInputContentSchema, ContextSchema, CustomEventSchema, DebugLogger, DeveloperMessageSchema, DocumentInputContentSchema, DocumentInputPartSchema, EventSchemas, EventType, ExecutionCapabilitiesSchema, FilterToolCallsMiddleware, FunctionCallSchema, FunctionMiddleware, HttpAgent, HttpAgent as HttpAgent$1, HumanInTheLoopCapabilitiesSchema, IdentityCapabilitiesSchema, ImageInputContentSchema, ImageInputPartSchema, InputContentDataSourceSchema, InputContentSchema, InputContentSourceSchema, InputContentUrlSourceSchema, InterruptSchema, MessageSchema, MessagesSnapshotEventSchema, MetadataSchema, Middleware, MultiAgentCapabilitiesSchema, MultimodalCapabilitiesSchema, MultimodalInputCapabilitiesSchema, MultimodalOutputCapabilitiesSchema, OptionalMetadataSchema, OutputCapabilitiesSchema, RawEventSchema, ReasoningCapabilitiesSchema, ReasoningEncryptedValueEventSchema, ReasoningEncryptedValueSubtypeSchema, ReasoningEndEventSchema, ReasoningMessageChunkEventSchema, ReasoningMessageContentEventSchema, ReasoningMessageEndEventSchema, ReasoningMessageSchema, ReasoningMessageStartEventSchema, ReasoningStartEventSchema, ResumeEntrySchema, RoleSchema, RunAgentInputSchema, RunErrorEventSchema, RunFinishedEventSchema, RunFinishedInterruptOutcomeSchema, RunFinishedOutcomeSchema, RunFinishedSuccessOutcomeSchema, RunStartedEventSchema, StateCapabilitiesSchema, StateDeltaEventSchema, StateSchema, StateSnapshotEventSchema, StepFinishedEventSchema, StepStartedEventSchema, SubAgentInfoSchema, SubagentErrorEventSchema, SubagentFinishedEventSchema, SubagentFinishedOutcomeSchema, SubagentFinishedSuccessOutcomeSchema, SubagentFinishedSuspendedOutcomeSchema, SubagentStartedEventSchema, SystemMessageSchema, TextInputContentSchema, TextMessageChunkEventSchema, TextMessageContentEventSchema, TextMessageEndEventSchema, TextMessageStartEventSchema, ThinkingEndEventSchema, ThinkingStartEventSchema, ThinkingTextMessageContentEventSchema, ThinkingTextMessageEndEventSchema, ThinkingTextMessageStartEventSchema, TokenUsageSchema, ToolCallArgsEventSchema, ToolCallChunkEventSchema, ToolCallEndEventSchema, ToolCallResultEventSchema, ToolCallSchema, ToolCallStartEventSchema, ToolMessageSchema, ToolSchema, ToolsCapabilitiesSchema, TransportCapabilitiesSchema, UserMessageSchema, VideoInputContentSchema, VideoInputPartSchema, aggregateTokenUsage, buildResumeArray, compactEvents, convertToLegacyEvents, createDebugLogger, defaultApplyEvents, getRunOutcome, isInterruptExpired, mergeMetadata, parseProtoStream, parseSSEStream, randomUUID, randomUUID as randomUUID$2, resolveAgentDebugConfig, resolveDebugLogger, runHttpRequest, structuredClone_, tokenUsageFromAiSdkUsage, tokenUsageFromLangChainMetadata, transformChunks, transformHttpEventStream, verifyEvents } from "@ag-ui/client";
5
5
  import { extendTailwindMerge, twMerge } from "tailwind-merge";
6
6
  import { ArrowUp, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronRightIcon, Copy, Edit, EyeOff, Loader2, MessageCircle, Mic, PanelLeftOpen, Play, Plus, RefreshCw, Square, ThumbsDown, ThumbsUp, Upload, Volume2, Wrench, X } from "lucide-react";
7
- import { A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, ConfigurationError, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitRemoteEndpointDiscoveryError, DEFAULT_AGENT_ID, ErrorVisibility, MissingPublicApiKeyError, Severity, TranscriptionErrorCode, TranscriptionErrorCode as TranscriptionErrorCode$1, copyToClipboard, createLicenseContextValue, dataToUUID, exceedsMaxSize, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getSourceUrl, matchesAcceptFilter, parseJson, partialJSONParse, randomId, randomUUID as randomUUID$1, readFileAsBase64, schemaToJsonSchema, shouldEnableInspector } from "@copilotkit/shared";
7
+ import { A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, ConfigurationError, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitRemoteEndpointDiscoveryError, DEFAULT_AGENT_ID, ErrorVisibility, MissingPublicApiKeyError, Severity, TranscriptionErrorCode, TranscriptionErrorCode as TranscriptionErrorCode$1, commitRowKeyStore, copyToClipboard, createAttachmentContent, createLicenseContextValue, createRowKeyStore, dataToUUID, exceedsMaxSize, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getSourceUrl, matchesAcceptFilter, parseJson, partialJSONParse, randomId, randomUUID as randomUUID$1, readFileAsBase64, resolveRowRenderKeysById, schemaToJsonSchema, shouldEnableInspector } from "@copilotkit/shared";
8
8
  import { CopilotKitAgentIdContext, CopilotKitContext, LicenseContext, useCopilotKit, useCopilotKit as useCopilotKit$1, useDefaultAgentId, useLicenseContext, useLicenseContext as useLicenseContext$1 } from "@copilotkit/react-core/v2/context";
9
9
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
10
10
  import { Slot } from "@radix-ui/react-slot";
@@ -3361,7 +3361,7 @@ function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
3361
3361
  }, [value, warningMessage]);
3362
3362
  return value;
3363
3363
  }
3364
- const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY_HEADERS, credentials, publicApiKey, publicLicenseKey, licenseToken, properties = EMPTY_PROPERTIES, agents__unsafe_dev_only: agents = EMPTY_AGENTS, selfManagedAgents = EMPTY_AGENTS, renderToolCalls, renderActivityMessages, renderCustomMessages, frontendTools, humanInTheLoop, openGenerativeUI, enableInspector, agentId, useSingleEndpoint, onError, a2ui, defaultThrottleMs, debug }) => {
3364
+ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY_HEADERS, credentials, messageFilter, publicApiKey, publicLicenseKey, licenseToken, properties = EMPTY_PROPERTIES, agents__unsafe_dev_only: agents = EMPTY_AGENTS, selfManagedAgents = EMPTY_AGENTS, renderToolCalls, renderActivityMessages, renderCustomMessages, frontendTools, humanInTheLoop, openGenerativeUI, enableInspector, agentId, useSingleEndpoint, onError, a2ui, defaultThrottleMs, debug }) => {
3365
3365
  const [shouldRenderInspector, setShouldRenderInspector] = useState(false);
3366
3366
  const [inspectorVisible, setInspectorVisible] = useState(false);
3367
3367
  useEffect(() => {
@@ -3482,6 +3482,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3482
3482
  const processedRenderToolCalls = [];
3483
3483
  humanInTheLoopList.forEach((tool) => {
3484
3484
  const frontendTool = {
3485
+ type: "human-in-the-loop",
3485
3486
  name: tool.name,
3486
3487
  description: tool.description,
3487
3488
  parameters: tool.parameters,
@@ -3588,6 +3589,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3588
3589
  runtimeTransport: useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto",
3589
3590
  headers: mergedHeaders,
3590
3591
  credentials,
3592
+ messageFilter,
3591
3593
  properties,
3592
3594
  agents__unsafe_dev_only: mergedAgents,
3593
3595
  tools: allTools,
@@ -3673,6 +3675,9 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3673
3675
  subscription.unsubscribe();
3674
3676
  };
3675
3677
  }, [copilotkit]);
3678
+ useEffect(() => {
3679
+ copilotkit.setMessageFilter(messageFilter);
3680
+ }, [copilotkit, messageFilter]);
3676
3681
  useEffect(() => {
3677
3682
  copilotkit.setRuntimeUrl(chatApiEndpoint);
3678
3683
  copilotkit.setRuntimeTransport(useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto");
@@ -3902,10 +3907,10 @@ function useRenderActivityMessage() {
3902
3907
 
3903
3908
  //#endregion
3904
3909
  //#region src/v2/hooks/use-frontend-tool.tsx
3905
- const EMPTY_DEPS$1 = [];
3910
+ const EMPTY_DEPS$2 = [];
3906
3911
  function useFrontendTool(tool, deps) {
3907
3912
  const { copilotkit } = useCopilotKit();
3908
- const extraDeps = deps ?? EMPTY_DEPS$1;
3913
+ const extraDeps = deps ?? EMPTY_DEPS$2;
3909
3914
  useLayoutEffect(() => {
3910
3915
  const name = tool.name;
3911
3916
  if (copilotkit.getTool({
@@ -3934,6 +3939,103 @@ function useFrontendTool(tool, deps) {
3934
3939
  ]);
3935
3940
  }
3936
3941
 
3942
+ //#endregion
3943
+ //#region src/v2/hooks/use-frontend-tools.tsx
3944
+ const EMPTY_DEPS$1 = [];
3945
+ const EMPTY_TOOLS = [];
3946
+ /**
3947
+ * Register a list of frontend tools whose length can change between renders.
3948
+ *
3949
+ * `useFrontendTool` registers exactly one tool per call, so it cannot be called
3950
+ * in a loop over a runtime-length list without breaking the rules of hooks.
3951
+ * This hook runs a single effect over the whole array instead, which makes it
3952
+ * safe to build the list from state, props, or a server response.
3953
+ *
3954
+ * Tools are keyed by `name` plus `agentId`, the same as `useFrontendTool`. A
3955
+ * tool that disappears from the array is unregistered on the next render, and
3956
+ * every tool is unregistered on unmount. Renderers stay registered after
3957
+ * unmount so past tool calls still render in the chat history.
3958
+ *
3959
+ * @param tools - The tools to register. May be empty and may change length.
3960
+ * @param deps - Extra dependencies that force re-registration, compared by
3961
+ * identity like the second argument of `useEffect`. Use this when a handler
3962
+ * closes over a value that is not part of the tool definition. Keep the array
3963
+ * a constant length across renders.
3964
+ *
3965
+ * @example
3966
+ * Register one tool per item in application state:
3967
+ * ```tsx
3968
+ * const [reports, setReports] = useState<Report[]>([]);
3969
+ *
3970
+ * useFrontendTools(
3971
+ * reports.map((report) => ({
3972
+ * name: `open_${report.id}`,
3973
+ * description: `Open the ${report.title} report`,
3974
+ * handler: async () => navigate(`/reports/${report.id}`),
3975
+ * })),
3976
+ * [navigate],
3977
+ * );
3978
+ * ```
3979
+ *
3980
+ * @example
3981
+ * Register tools described by the backend:
3982
+ * ```tsx
3983
+ * const { data } = useQuery(fetchToolDescriptors);
3984
+ *
3985
+ * useFrontendTools(
3986
+ * (data ?? []).map((descriptor) => ({
3987
+ * name: descriptor.name,
3988
+ * description: descriptor.description,
3989
+ * parameters: z.object({ query: z.string() }),
3990
+ * handler: async ({ query }) => runDescriptor(descriptor.id, query),
3991
+ * })),
3992
+ * );
3993
+ * ```
3994
+ */
3995
+ function useFrontendTools(tools, deps) {
3996
+ const { copilotkit } = useCopilotKit();
3997
+ const toolList = tools ?? EMPTY_TOOLS;
3998
+ const extraDeps = deps ?? EMPTY_DEPS$1;
3999
+ useLayoutEffect(() => {
4000
+ const deduped = /* @__PURE__ */ new Map();
4001
+ for (const tool of toolList) {
4002
+ const key = `${tool.agentId ?? ""}:${tool.name}`;
4003
+ if (deduped.has(key)) console.warn(`Tool '${tool.name}' is listed more than once for agent '${tool.agentId || "global"}' in the same useFrontendTools call. Using the last entry.`);
4004
+ deduped.set(key, tool);
4005
+ }
4006
+ const registered = [...deduped.values()];
4007
+ for (const tool of registered) {
4008
+ if (copilotkit.getTool({
4009
+ toolName: tool.name,
4010
+ agentId: tool.agentId
4011
+ })) {
4012
+ console.warn(`Tool '${tool.name}' already exists for agent '${tool.agentId || "global"}'. Overriding with latest registration.`);
4013
+ copilotkit.removeTool(tool.name, tool.agentId);
4014
+ }
4015
+ copilotkit.addTool(tool);
4016
+ if (tool.render) copilotkit.addHookRenderToolCall({
4017
+ name: tool.name,
4018
+ args: tool.parameters,
4019
+ agentId: tool.agentId,
4020
+ render: tool.render
4021
+ });
4022
+ }
4023
+ return () => {
4024
+ for (const tool of registered) copilotkit.removeTool(tool.name, tool.agentId);
4025
+ };
4026
+ }, [
4027
+ JSON.stringify(toolList.map((tool) => [
4028
+ tool.name,
4029
+ tool.description ?? null,
4030
+ tool.agentId ?? null,
4031
+ tool.available ?? null,
4032
+ tool.webmcp ?? null
4033
+ ])),
4034
+ copilotkit,
4035
+ ...extraDeps
4036
+ ]);
4037
+ }
4038
+
3937
4039
  //#endregion
3938
4040
  //#region src/v2/hooks/use-component.tsx
3939
4041
  /**
@@ -4350,6 +4452,7 @@ function useHumanInTheLoop(tool, deps) {
4350
4452
  ]);
4351
4453
  useFrontendTool({
4352
4454
  ...tool,
4455
+ type: "human-in-the-loop",
4353
4456
  handler,
4354
4457
  render: RenderComponent
4355
4458
  }, deps);
@@ -7495,6 +7598,13 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
7495
7598
  return copilotkit.getStateByRun(config.agentId, config.threadId, resolvedRunId);
7496
7599
  };
7497
7600
  const deduplicatedMessages = useMemo(() => deduplicateMessages(messages), [messages]);
7601
+ const rowKeyStoreRef = useRef(null);
7602
+ rowKeyStoreRef.current ??= createRowKeyStore();
7603
+ const rowKeyStore = rowKeyStoreRef.current;
7604
+ const rowRenderKeys = useMemo(() => resolveRowRenderKeysById(rowKeyStore, deduplicatedMessages), [rowKeyStore, deduplicatedMessages]);
7605
+ useLayoutEffect(() => {
7606
+ commitRowKeyStore(rowKeyStore, deduplicatedMessages);
7607
+ }, [rowKeyStore, deduplicatedMessages]);
7498
7608
  if (process.env.NODE_ENV === "development" && deduplicatedMessages.length < messages.length) console.warn(`CopilotChatMessageView: Merged ${messages.length - deduplicatedMessages.length} message(s) with duplicate IDs.`);
7499
7609
  const { Component: AssistantComponent, slotProps: assistantSlotProps } = useMemo(() => resolveSlotComponent(assistantMessage, CopilotChatAssistantMessage_default), [assistantMessage]);
7500
7610
  const agentId = config?.agentId;
@@ -7549,41 +7659,42 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
7549
7659
  const renderMessageBlock = (message) => {
7550
7660
  const elements = [];
7551
7661
  const stateSnapshot = getStateSnapshotForMessage(message.id);
7662
+ const rowKey = rowRenderKeys.get(message.id) ?? message.id;
7552
7663
  if (renderCustomMessage) elements.push(/* @__PURE__ */ jsx(MemoizedCustomMessage, {
7553
7664
  message,
7554
7665
  position: "before",
7555
7666
  renderCustomMessage,
7556
7667
  stateSnapshot
7557
- }, `${message.id}-custom-before`));
7668
+ }, `${rowKey}-custom-before`));
7558
7669
  if (message.role === "assistant") elements.push(/* @__PURE__ */ jsx(MemoizedAssistantMessage, {
7559
7670
  message,
7560
7671
  messages,
7561
7672
  isRunning,
7562
7673
  AssistantMessageComponent: AssistantComponent,
7563
7674
  slotProps: assistantSlotPropsWithFeedback
7564
- }, message.id));
7675
+ }, rowKey));
7565
7676
  else if (message.role === "user") elements.push(/* @__PURE__ */ jsx(MemoizedUserMessage, {
7566
7677
  message,
7567
7678
  UserMessageComponent: UserComponent,
7568
7679
  slotProps: userSlotProps
7569
- }, message.id));
7680
+ }, rowKey));
7570
7681
  else if (message.role === "activity") elements.push(/* @__PURE__ */ jsx(MemoizedActivityMessage, {
7571
7682
  message,
7572
7683
  renderActivityMessage
7573
- }, message.id));
7684
+ }, rowKey));
7574
7685
  else if (message.role === "reasoning") elements.push(/* @__PURE__ */ jsx(MemoizedReasoningMessage, {
7575
7686
  message,
7576
7687
  messages,
7577
7688
  isRunning,
7578
7689
  ReasoningMessageComponent: ReasoningComponent,
7579
7690
  slotProps: reasoningSlotProps
7580
- }, message.id));
7691
+ }, rowKey));
7581
7692
  if (renderCustomMessage) elements.push(/* @__PURE__ */ jsx(MemoizedCustomMessage, {
7582
7693
  message,
7583
7694
  position: "after",
7584
7695
  renderCustomMessage,
7585
7696
  stateSnapshot
7586
- }, `${message.id}-custom-after`));
7697
+ }, `${rowKey}-custom-after`));
7587
7698
  const intelligenceTurnId = intelligenceTurnAnchors.get(message.id);
7588
7699
  if (intelligenceTurnId !== void 0) elements.push(/* @__PURE__ */ jsx(IntelligenceIndicator, {
7589
7700
  message,
@@ -7629,7 +7740,7 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
7629
7740
  transform: `translateY(${virtualItem.start}px)`
7630
7741
  },
7631
7742
  children: renderMessageBlock(message)
7632
- }, message.id);
7743
+ }, rowRenderKeys.get(message.id) ?? message.id);
7633
7744
  })
7634
7745
  }) : messageElements,
7635
7746
  interruptElement,
@@ -8942,14 +9053,7 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
8942
9053
  type: "text",
8943
9054
  text: value
8944
9055
  });
8945
- for (const att of readyAttachments) contentParts.push({
8946
- type: att.type,
8947
- source: att.source,
8948
- metadata: {
8949
- ...att.filename ? { filename: att.filename } : {},
8950
- ...att.metadata
8951
- }
8952
- });
9056
+ for (const att of readyAttachments) contentParts.push(createAttachmentContent(att));
8953
9057
  agent.addMessage({
8954
9058
  id: randomUUID$1(),
8955
9059
  role: "user",
@@ -12371,5 +12475,5 @@ function validateProps(props) {
12371
12475
  }
12372
12476
 
12373
12477
  //#endregion
12374
- export { useAgentContext as $, CopilotChatMessageView as A, AudioRecorderError as At, CopilotChatAssistantMessage_default as B, CopilotModalHeader as C, MCPAppsActivityContentSchema as Ct, CopilotChat as D, CopilotKitInspector as Dt, DefaultOpenIcon as E, ɵrunMcpFollowUp as Et, CopilotChatSuggestionView as F, useLearnFromUserActionInCurrentThread as G, useLearningContainersInCurrentThread as H, CopilotChatSuggestionPill as I, useThreads$1 as J, useLearnFromUserAction as K, CopilotChatReasoningMessage_default as L, IntelligenceIndicator as M, CopilotChatConfigurationProvider as Mt, getIntelligenceTurnAnchors as N, useCopilotChatConfiguration as Nt, CopilotChatView_default as O, useRenderToolCall as Ot, IntelligenceIndicatorView as P, useSuggestions as Q, CopilotChatUserMessage_default as R, CopilotSidebarView as S, useSandboxFunctions as St, DefaultCloseIcon as T, MCPAppsActivityType as Tt, useLearningContainers as U, CopilotChatToolCallsView as V, useAttachments as W, INTERRUPT_EVENT_NAME as X, useInterrupt as Y, useConfigureSuggestions as Z, WildcardToolCallRender as _, OpenGenerativeUIActivityRenderer as _t, ThreadsProvider as a, useRenderTool as at, CopilotSidebar as b, OpenGenerativeUIToolRenderer as bt, CoAgentStateRendersProvider as c, useRenderActivityMessage as ct, shouldShowDevConsole as d, useCopilotKit$1 as dt, useCapabilities as et, useToast as f, useLicenseContext$1 as ft, useCopilotContext as g, GenerateSandboxedUiArgsSchema as gt, CopilotContext as h, createA2UIMessageRenderer as ht, ThreadsContext as i, useDefaultRenderTool as it, INTELLIGENCE_TURN_HEAD as j, CopilotChatAudioRecorder as jt, CopilotChatAttachmentQueue as k, CopilotChatInput_default as kt, useCoAgentStateRenders as l, useRenderCustomMessages as lt, useCopilotMessagesContext as m, defineToolCallRenderer as mt, defaultCopilotContextCategories as n, useAgent as nt, useThreads as o, useComponent as ot, CopilotMessagesContext as p, CopilotKitCoreReact as pt, useMemories as q, CoAgentStateRenderBridge as r, useHumanInTheLoop as rt, CoAgentStateRendersContext as s, useFrontendTool as st, CopilotKit as t, UseAgentUpdate as tt, useAsyncCallback as u, CopilotKitProvider as ut, CopilotThreadsDrawer as v, OpenGenerativeUIActivityType as vt, CopilotChatToggleButton as w, MCPAppsActivityRenderer as wt, CopilotPopupView as x, SandboxFunctionsContext as xt, CopilotPopup as y, OpenGenerativeUIContentSchema as yt, CopilotChatAttachmentRenderer as z };
12375
- //# sourceMappingURL=copilotkit-BkeaNR3A.mjs.map
12478
+ export { useAgentContext as $, ɵisRetryableMemoryStatus as $i, ResumeEntrySchema as $n, compactEvents as $r, BaseMessageSchema as $t, CopilotChatMessageView as A, parseSSEStream as Ai, MemoryError as An, ThinkingEndEventSchema as Ar, CopilotChatInput_default as At, CopilotChatAssistantMessage_default as B, tokenUsageFromLangChainMetadata as Bi, OutputCapabilitiesSchema as Bn, ToolCallSchema as Br, ActivityMessageSchema as Bt, CopilotModalHeader as C, ɵselectThreadsError$1 as Ca, ofType as Ci, InputContentDataSourceSchema as Cn, SuggestionEngine as Cr, useSandboxFunctions as Ct, CopilotChat as D, onInspectorViewThread$1 as Di, IntelligenceAgent as Dn, TextMessageContentEventSchema as Dr, ɵrunMcpFollowUp as Dt, DefaultOpenIcon as E, onInspectorStopViewing$1 as Ei, InputContentUrlSourceSchema as En, TextMessageChunkEventSchema as Er, MCPAppsActivityType as Et, CopilotChatSuggestionView as F, resolveDebugLogger as Fi, MultiAgentCapabilitiesSchema as Fn, TokenUsageSchema as Fr, AGUIConnectNotImplementedError$1 as Ft, useLearnFromUserActionInCurrentThread as G, ɵInterruptState$1 as Gi, ReasoningEncryptedValueSubtypeSchema as Gn, ToolsCapabilitiesSchema as Gr, AssistantMessageSchema as Gt, useLearningContainersInCurrentThread as H, transformHttpEventStream as Hi, RawEventSchema as Hn, ToolCallStatus$1 as Hr, AgentCapabilitiesSchema as Ht, CopilotChatSuggestionPill as I, runHttpRequest as Ii, MultimodalCapabilitiesSchema as In, ToolCallArgsEventSchema as Ir, AGUIError as It, useThreads$1 as J, ɵTHREAD_REQUEST_TIMEOUT_MS as Ji, ReasoningMessageContentEventSchema as Jn, VideoInputContentSchema as Jr, BackwardCompatibility_0_0_39 as Jt, useLearnFromUserAction as K, ɵMAX_SOCKET_RETRIES as Ki, ReasoningEndEventSchema as Kn, TransportCapabilitiesSchema as Kr, AudioInputContentSchema as Kt, CopilotChatReasoningMessage_default as L, select as Li, MultimodalInputCapabilitiesSchema as Ln, ToolCallChunkEventSchema as Lr, AGUI_METADATA_KEY as Lt, IntelligenceIndicator as M, props as Mi, MessagesSnapshotEventSchema as Mn, ThinkingTextMessageContentEventSchema as Mr, CopilotChatAudioRecorder as Mt, getIntelligenceTurnAnchors as N, randomUUID$2 as Ni, MetadataSchema as Nn, ThinkingTextMessageEndEventSchema as Nr, CopilotChatConfigurationProvider as Nt, CopilotChatView_default as O, onInspectorViewThreadResult as Oi, InterruptSchema as On, TextMessageEndEventSchema as Or, CopilotKitInspector as Ot, IntelligenceIndicatorView as P, resolveAgentDebugConfig as Pi, Middleware as Pn, ThinkingTextMessageStartEventSchema as Pr, useCopilotChatConfiguration as Pt, useSuggestions as Q, ɵisCopilotKitFeature as Qi, ReasoningStartEventSchema as Qn, buildResumeArray as Qr, BaseEventSchema as Qt, CopilotChatUserMessage_default as R, structuredClone_ as Ri, MultimodalOutputCapabilitiesSchema as Rn, ToolCallEndEventSchema as Rr, AbstractAgent$1 as Rt, CopilotSidebarView as S, ɵselectThreads$1 as Sa, mergeMetadata as Si, ImageInputPartSchema as Sn, SubagentStartedEventSchema as Sr, SandboxFunctionsContext as St, DefaultCloseIcon as T, ɵthreadAdapterEvents as Ta, onInspectorActiveThread as Ti, InputContentSourceSchema as Tn, TextInputContentSchema as Tr, MCPAppsActivityRenderer as Tt, useLearningContainers as U, verifyEvents as Ui, ReasoningCapabilitiesSchema as Un, ToolMessageSchema as Ur, AgentRegistry as Ut, CopilotChatToolCallsView as V, transformChunks as Vi, ProxiedCopilotRuntimeAgent$1 as Vn, ToolCallStartEventSchema as Vr, ActivitySnapshotEventSchema as Vt, useAttachments as W, ɵCOPILOTKIT_FEATURES as Wi, ReasoningEncryptedValueEventSchema as Wn, ToolSchema as Wr, AgentThreadLockedError as Wt, INTERRUPT_EVENT_NAME as X, ɵcreateThreadSelectors as Xi, ReasoningMessageSchema as Xn, WebMCPRegistry as Xr, BackwardCompatibility_0_0_47 as Xt, useInterrupt as Y, ɵcreateMemoryStore as Yi, ReasoningMessageEndEventSchema as Yn, VideoInputPartSchema as Yr, BackwardCompatibility_0_0_45 as Yt, useConfigureSuggestions as Z, ɵcreateThreadStore$1 as Zi, ReasoningMessageStartEventSchema as Zn, aggregateTokenUsage as Zr, BackwardCompatibility_0_0_57 as Zt, WildcardToolCallRender as _, ɵselectMemoriesAvailable$1 as _a, getWebMCPModelContext as _i, HttpAgent$1 as _n, SubagentErrorEventSchema as _r, GenerateSandboxedUiArgsSchema as _t, ThreadsProvider as a, ɵmemoryRestEvents as aa, createInspectorThreadRequestId as ai, CopilotKitCoreRuntimeConnectionStatus$1 as an, RunFinishedOutcomeSchema as ar, useRenderTool as at, CopilotSidebar as b, ɵselectMemoriesIsMutating as ba, isInterruptExpired as bi, IdentityCapabilitiesSchema as bn, SubagentFinishedSuccessOutcomeSchema as br, OpenGenerativeUIContentSchema as bt, CoAgentStateRendersProvider as c, ɵobservePhoenixSocketHealth$ as ca, createStore as ci, DeveloperMessageSchema as cn, RunStartedEventSchema as cr, useFrontendTool as ct, shouldShowDevConsole as d, ɵphoenixSocket$ as da, emitInspectorStopViewing as di, EventSchemas as dn, StateManager as dr, CopilotKitProvider as dt, ɵjoinPhoenixChannel$ as ea, completePartialMarkdown as ei, BinaryInputContentSchema as en, RoleSchema as er, useCapabilities as et, useToast as f, ɵselectFetchMoreError$1 as fa, emitInspectorViewThread as fi, EventType as fn, StateSchema as fr, useCopilotKit$1 as ft, useCopilotContext as g, ɵselectMemories$1 as ga, getRunOutcome as gi, FunctionMiddleware as gn, SubAgentInfoSchema as gr, createA2UIMessageRenderer as gt, CopilotContext as h, ɵselectIsMutating$1 as ha, ensureObjectArgs as hi, FunctionCallSchema as hn, StepStartedEventSchema as hr, defineToolCallRenderer as ht, ThreadsContext as i, ɵmemoryReducer as ia, createEffect as ii, CopilotKitCoreErrorCode$1 as in, RunFinishedInterruptOutcomeSchema as ir, useDefaultRenderTool as it, INTELLIGENCE_TURN_HEAD as j, parseToolArguments as ji, MessageSchema as jn, ThinkingStartEventSchema as jr, AudioRecorderError as jt, CopilotChatAttachmentQueue as k, parseProtoStream as ki, MEMORY_ERROR_REGISTRY as kn, TextMessageStartEventSchema as kr, useRenderToolCall as kt, useCoAgentStateRenders as l, ɵobservePhoenixSocketSignals$ as la, defaultApplyEvents as li, DocumentInputContentSchema as ln, StateCapabilitiesSchema as lr, useRenderActivityMessage as lt, useCopilotMessagesContext as m, ɵselectIsFetchingNextPage$1 as ma, empty as mi, FilterToolCallsMiddleware as mn, StepFinishedEventSchema as mr, CopilotKitCoreReact as mt, defaultCopilotContextCategories as n, ɵmemoryAdapterEvents as na, createActionGroup as ni, ContextStore as nn, RunErrorEventSchema as nr, useAgent as nt, useThreads as o, ɵobservePhoenixEvent$ as oa, createReducer as oi, CustomEventSchema as on, RunFinishedSuccessOutcomeSchema as or, useComponent as ot, CopilotMessagesContext as p, ɵselectHasNextPage$1 as pa, emitInspectorViewThreadResult$1 as pi, ExecutionCapabilitiesSchema as pn, StateSnapshotEventSchema as pr, useLicenseContext$1 as pt, useMemories as q, ɵRUNTIME_PROBE_TIMEOUT_MS as qi, ReasoningMessageChunkEventSchema as qn, UserMessageSchema as qr, AudioInputPartSchema as qt, CoAgentStateRenderBridge as r, ɵmemoryDomainEvents as ra, createDebugLogger as ri, CopilotKitCore$1 as rn, RunFinishedEventSchema as rr, useHumanInTheLoop as rt, CoAgentStateRendersContext as s, ɵobservePhoenixJoinOutcome$ as sa, createSelector as si, DebugLogger as sn, RunHandler as sr, useFrontendTools as st, CopilotKit as t, ɵmapMemoryMetadataEvent as ta, convertToLegacyEvents as ti, ContextSchema as tn, RunAgentInputSchema as tr, UseAgentUpdate as tt, useAsyncCallback as u, ɵphoenixChannel$ as ua, emitInspectorActiveThread$1 as ui, DocumentInputPartSchema as un, StateDeltaEventSchema as ur, useRenderCustomMessages as ut, CopilotThreadsDrawer as v, ɵselectMemoriesError$1 as va, isAbortError as vi, HumanInTheLoopCapabilitiesSchema as vn, SubagentFinishedEventSchema as vr, OpenGenerativeUIActivityRenderer as vt, CopilotChatToggleButton as w, ɵselectThreadsIsLoading$1 as wa, on as wi, InputContentSchema as wn, SystemMessageSchema as wr, MCPAppsActivityContentSchema as wt, CopilotPopupView as x, ɵselectMemoriesRealtimeStatus$1 as xa, isRunCompletionAware$1 as xi, ImageInputContentSchema as xn, SubagentFinishedSuspendedOutcomeSchema as xr, OpenGenerativeUIToolRenderer as xt, CopilotPopup as y, ɵselectMemoriesIsLoading$1 as ya, isInspectorThreadBridgeEnabled$1 as yi, INSPECTOR_THREAD_BRIDGE_PLUGIN_ID as yn, SubagentFinishedOutcomeSchema as yr, OpenGenerativeUIActivityType as yt, CopilotChatAttachmentRenderer as z, tokenUsageFromAiSdkUsage as zi, OptionalMetadataSchema as zn, ToolCallResultEventSchema as zr, ActivityDeltaEventSchema as zt };
12479
+ //# sourceMappingURL=copilotkit-CwVE-0JG.mjs.map