@copilotkit/react-core 1.88.0 → 1.89.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/{copilotkit-RAr-1JSr.d.mts → copilotkit-CfnudBCL.d.mts} +20 -5
- package/dist/copilotkit-CfnudBCL.d.mts.map +1 -0
- package/dist/{copilotkit-D4AAgBT1.cjs → copilotkit-DHJJxCeI.cjs} +267 -61
- package/dist/copilotkit-DHJJxCeI.cjs.map +1 -0
- package/dist/{copilotkit-CYqkB8Nv.mjs → copilotkit-GWoyxfzS.mjs} +271 -65
- package/dist/copilotkit-GWoyxfzS.mjs.map +1 -0
- package/dist/{copilotkit-BS_3fQrS.d.cts → copilotkit-XLp7jKQk.d.cts} +20 -5
- package/dist/copilotkit-XLp7jKQk.d.cts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +15 -10
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/generative-ui.d.cts +46 -46
- package/dist/v2/generative-ui.d.cts.map +1 -1
- package/dist/v2/generative-ui.d.mts +46 -46
- package/dist/v2/generative-ui.d.mts.map +1 -1
- package/dist/v2/index.cjs +19 -1
- package/dist/v2/index.css +1 -1
- package/dist/v2/index.d.cts +2 -2
- package/dist/v2/index.d.mts +2 -2
- package/dist/v2/index.mjs +2 -2
- package/dist/v2/index.umd.js +284 -60
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +10 -10
- package/dist/copilotkit-BS_3fQrS.d.cts.map +0 -1
- package/dist/copilotkit-CYqkB8Nv.mjs.map +0 -1
- package/dist/copilotkit-D4AAgBT1.cjs.map +0 -1
- package/dist/copilotkit-RAr-1JSr.d.mts.map +0 -1
|
@@ -3,8 +3,8 @@ import { n as useKatexStyles, t as MarkdownSurfaces } from "./MarkdownSurfaces-C
|
|
|
3
3
|
import { t as useGenerativeUIRoot } from "./use-generative-ui-root-WI9ERMpo.mjs";
|
|
4
4
|
import * as React$1 from "react";
|
|
5
5
|
import React, { Fragment, createContext, createElement, forwardRef, memo, useCallback, useContext, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
|
|
6
|
-
import { A2UI_FENCE_LANGUAGE, AgentRegistry, AgentThreadLockedError, ContextStore, CopilotKitCore, CopilotKitCore as CopilotKitCore$1, CopilotKitCoreErrorCode, CopilotKitCoreErrorCode as CopilotKitCoreErrorCode$1, CopilotKitCoreRuntimeConnectionStatus, CopilotKitCoreRuntimeConnectionStatus as CopilotKitCoreRuntimeConnectionStatus$1, CopilotKitHeaderResolutionError, INSPECTOR_THREAD_BRIDGE_PLUGIN_ID, IntelligenceAgent, MEMORY_ERROR_REGISTRY, MemoryError, ProxiedCopilotRuntimeAgent, ProxiedCopilotRuntimeAgent as ProxiedCopilotRuntimeAgent$1, RunHandler, StateManager, SuggestionEngine, ToolCallStatus, ToolCallStatus as ToolCallStatus$1, WebMCPRegistry, classifySurfaceCards, completePartialMarkdown, createActionGroup, createEffect, createInspectorThreadRequestId, createReducer, createSelector, createStore, emitInspectorActiveThread, emitInspectorActiveThread as emitInspectorActiveThread$1, emitInspectorStopViewing, emitInspectorViewThread, emitInspectorViewThreadResult, emitInspectorViewThreadResult as emitInspectorViewThreadResult$1, empty, ensureObjectArgs, extractCompleteArrayItems, extractFenceOperations, extractStringField, flattenInformationalCards, getMarkdownOperationSurfaceId, 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, prepareSurfaceOperations, props, segmentSurfaceProse, select, splitA2UIMarkdown as splitA2UIMarkdown$1, ɵCOPILOTKIT_FEATURES, ɵInterruptState, ɵInterruptState as ɵInterruptState$1, ɵMAX_SOCKET_RETRIES, ɵRUNTIME_PROBE_TIMEOUT_MS, ɵTHREAD_REQUEST_TIMEOUT_MS, ɵclearAgentInterruptState, ɵclearAgentInterruptState as ɵclearAgentInterruptState$1, ɵcreateMemoryStore, ɵcreateThreadSelectors, ɵcreateThreadStore, ɵcreateThreadStore as ɵcreateThreadStore$1, ɵgetAgentInterruptState, ɵgetAgentInterruptState as ɵgetAgentInterruptState$1, ɵisCopilotKitFeature, ɵisHttpAgent, ɵisHttpAgent as ɵisHttpAgent$1, ɵ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, ɵwithHeaderDefaults, ɵwithHeaderDefaults as ɵwithHeaderDefaults$1 } from "@copilotkit/core";
|
|
7
|
-
import { ACTIVITY_HISTORY_METADATA, AGUIConnectNotImplementedError as AGUIConnectNotImplementedError$1, AGUIError, AGUI_METADATA_KEY, AbstractAgent as AbstractAgent$1, BackwardCompatibility_0_0_39, BackwardCompatibility_0_0_45, BackwardCompatibility_0_0_57, CompatibilityBoundary, DebugLogger, EventType, FilterToolCallsMiddleware, FunctionMiddleware, HttpAgent, Middleware, PROTOCOL_VERSION, aggregateTokenUsage, authoritativeActivityTypes, buildResumeArray, compactEvents, contentHasMedia, contentToText as contentToText$1, convertToLegacyEvents, createDebugLogger, defaultApplyEvents, enforceEvents, enforceOutgoingInput, getRunOutcome, isInterruptExpired, isRecognizedEvent, mergeMetadata, omitOptionalNulls, parseProtoStream, parseSSEStream, randomUUID, randomUUID as randomUUID$2, resolveAgentDebugConfig, resolveDebugLogger, runHttpRequest, structuredClone_, tokenUsageFromAiSdkUsage, tokenUsageFromLangChainMetadata, transformChunks, transformHttpEventStream, verifyEvents, withAuthoritativeActivityTypes } from "@ag-ui/client";
|
|
6
|
+
import { A2UI_FENCE_LANGUAGE, AgentRegistry, AgentThreadLockedError, ContextStore, CopilotKitCore, CopilotKitCore as CopilotKitCore$1, CopilotKitCoreErrorCode, CopilotKitCoreErrorCode as CopilotKitCoreErrorCode$1, CopilotKitCoreRuntimeConnectionStatus, CopilotKitCoreRuntimeConnectionStatus as CopilotKitCoreRuntimeConnectionStatus$1, CopilotKitHeaderResolutionError, INSPECTOR_THREAD_BRIDGE_PLUGIN_ID, IntelligenceAgent, IntelligenceReplayFailedError, MEMORY_ERROR_REGISTRY, MemoryError, ProxiedCopilotRuntimeAgent, ProxiedCopilotRuntimeAgent as ProxiedCopilotRuntimeAgent$1, RunHandler, StateManager, SuggestionEngine, ToolCallStatus, ToolCallStatus as ToolCallStatus$1, WebMCPRegistry, classifySurfaceCards, completePartialMarkdown, createActionGroup, createEffect, createInspectorThreadRequestId, createReducer, createSelector, createStore, emitInspectorActiveThread, emitInspectorActiveThread as emitInspectorActiveThread$1, emitInspectorStopViewing, emitInspectorViewThread, emitInspectorViewThreadResult, emitInspectorViewThreadResult as emitInspectorViewThreadResult$1, empty, ensureObjectArgs, extractCompleteArrayItems, extractFenceOperations, extractStringField, flattenInformationalCards, getMarkdownOperationSurfaceId, 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, prepareSurfaceOperations, props, segmentSurfaceProse, select, splitA2UIMarkdown as splitA2UIMarkdown$1, ɵCOPILOTKIT_FEATURES, ɵInterruptState, ɵInterruptState as ɵInterruptState$1, ɵMAX_SOCKET_RETRIES, ɵRUNTIME_PROBE_TIMEOUT_MS, ɵTHREAD_REQUEST_TIMEOUT_MS, ɵclearAgentInterruptState, ɵclearAgentInterruptState as ɵclearAgentInterruptState$1, ɵcreateMemoryStore, ɵcreateThreadSelectors, ɵcreateThreadStore, ɵcreateThreadStore as ɵcreateThreadStore$1, ɵgetAgentInterruptState, ɵgetAgentInterruptState as ɵgetAgentInterruptState$1, ɵisCopilotKitFeature, ɵisHttpAgent, ɵisHttpAgent as ɵisHttpAgent$1, ɵ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, ɵwithHeaderDefaults, ɵwithHeaderDefaults as ɵwithHeaderDefaults$1 } from "@copilotkit/core";
|
|
7
|
+
import { ACTIVITY_HISTORY_METADATA, AGUIConnectNotImplementedError as AGUIConnectNotImplementedError$1, AGUIEnforcementLimitError, AGUIError, AGUI_METADATA_KEY, AbstractAgent as AbstractAgent$1, BackwardCompatibility_0_0_39, BackwardCompatibility_0_0_45, BackwardCompatibility_0_0_57, CompatibilityBoundary, DEFAULT_MAX_ENFORCED_ENTRIES, DebugLogger, EventType, FilterToolCallsMiddleware, FunctionMiddleware, HttpAgent, Middleware, PROTOCOL_VERSION, aggregateTokenUsage, authoritativeActivityTypes, buildResumeArray, compactEvents, contentHasMedia, contentToText as contentToText$1, convertToLegacyEvents, createDebugLogger, defaultApplyEvents, enforceEvents, enforceOutgoingInput, getRunOutcome, isInterruptExpired, isRecognizedEvent, mergeMetadata, omitOptionalNulls, parseProtoStream, parseSSEStream, randomUUID, randomUUID as randomUUID$2, resolveAgentDebugConfig, resolveDebugLogger, runHttpRequest, structuredClone_, tokenUsageFromAiSdkUsage, tokenUsageFromLangChainMetadata, transformChunks, transformHttpEventStream, verifyEvents, withAuthoritativeActivityTypes } from "@ag-ui/client";
|
|
8
8
|
import { ActivityDeltaEventSchema, ActivityMessageSchema, ActivitySnapshotEventSchema, AddOperationSchema, AgentCapabilitiesSchema, AssistantMessageSchema, AttributableSchema, AudioInputContentSchema, AudioInputPartSchema, AudioPartSchema, BaseEventSchema, BaseMessageSchema, ContentPartSchema, ContextSchema, CopyOperationSchema, CustomEventSchema, DataSourceSchema, DeveloperMessageSchema, DocumentInputContentSchema, DocumentInputPartSchema, DocumentPartSchema, EventSchema, EventSchemas, EventTypeSchema, ExecutionCapabilitiesSchema, FileSourceSchema, FunctionCallSchema, HumanInTheLoopCapabilitiesSchema, IdentityCapabilitiesSchema, ImageInputContentSchema, ImageInputPartSchema, ImagePartSchema, InputContentDataSourceSchema, InputContentSchema, InputContentSourceSchema, InputContentUrlSourceSchema, InterruptSchema, JsonPatchOperationSchema, JsonPatchSchema, JsonPointerSchema, MessageSchema, MessagesSnapshotEventSchema, MetadataSchema, MoveOperationSchema, MultiAgentCapabilitiesSchema, MultimodalCapabilitiesSchema, MultimodalInputCapabilitiesSchema, MultimodalOutputCapabilitiesSchema, OptionalMetadataSchema, OutputCapabilitiesSchema, PartSourceSchema, RawEventSchema, ReasoningCapabilitiesSchema, ReasoningEncryptedValueEventSchema, ReasoningEncryptedValueSubtypeSchema, ReasoningEndEventSchema, ReasoningMessageChunkEventSchema, ReasoningMessageContentEventSchema, ReasoningMessageEndEventSchema, ReasoningMessageSchema, ReasoningMessageStartEventSchema, ReasoningStartEventSchema, RemoveOperationSchema, ReplaceOperationSchema, ResumeEntrySchema, RoleSchema, RunAgentInputSchema, RunErrorEventSchema, RunFinishedCancelledOutcomeSchema, RunFinishedEventSchema, RunFinishedInterruptOutcomeSchema, RunFinishedOutcomeSchema, RunFinishedSuccessOutcomeSchema, RunStartedEventSchema, StateCapabilitiesSchema, StateDeltaEventSchema, StateSchema, StateSnapshotEventSchema, StepFinishedEventSchema, StepStartedEventSchema, SubagentErrorEventSchema, SubagentFinishedEventSchema, SubagentFinishedOutcomeSchema, SubagentFinishedSuccessOutcomeSchema, SubagentFinishedSuspendedOutcomeSchema, SubagentInfoSchema, SubagentRunIdSchema, SubagentStartedEventSchema, SystemMessageSchema, TestOperationSchema, TextInputContentSchema, TextMessageChunkEventSchema, TextMessageContentEventSchema, TextMessageEndEventSchema, TextMessageRoleSchema, TextMessageStartEventSchema, TextPartSchema, TokenUsageSchema, ToolCallArgsEventSchema, ToolCallChunkEventSchema, ToolCallEndEventSchema, ToolCallResultEventSchema, ToolCallSchema, ToolCallStartEventSchema, ToolMessageSchema, ToolSchema, ToolsCapabilitiesSchema, TransportCapabilitiesSchema, UrlSourceSchema, UserMessageSchema, VideoInputContentSchema, VideoInputPartSchema, VideoPartSchema } from "@ag-ui/core/schemas";
|
|
9
9
|
import { extendTailwindMerge, twMerge } from "tailwind-merge";
|
|
10
10
|
import { ArrowUp, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronRightIcon, Circle, Copy, Edit, EyeOff, Loader2, MessageCircle, Mic, PanelLeftOpen, Play, Plus, RefreshCw, Square, ThumbsDown, ThumbsUp, Upload, Volume2, Wrench, X } from "lucide-react";
|
|
@@ -24,7 +24,7 @@ import { A2UIProvider, A2UIRenderer, A2UI_SCHEMA_CONTEXT_DESCRIPTION, Catalog, C
|
|
|
24
24
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
25
25
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
26
26
|
import { createPortal, flushSync } from "react-dom";
|
|
27
|
-
import { observeElementRect, useVirtualizer } from "@tanstack/react-virtual";
|
|
27
|
+
import { defaultRangeExtractor, elementScroll, observeElementOffset, observeElementRect, useVirtualizer } from "@tanstack/react-virtual";
|
|
28
28
|
import { StickToBottom, useStickToBottomContext } from "use-stick-to-bottom";
|
|
29
29
|
import { COPILOTKIT_THREADS_DRAWER_TAG, defineCopilotKitThreadsDrawer } from "@copilotkit/web-components/threads-drawer";
|
|
30
30
|
import ReactMarkdown from "react-markdown";
|
|
@@ -1323,7 +1323,7 @@ function useRenderToolCall() {
|
|
|
1323
1323
|
|
|
1324
1324
|
//#endregion
|
|
1325
1325
|
//#region package.json
|
|
1326
|
-
var version = "1.
|
|
1326
|
+
var version = "1.89.0";
|
|
1327
1327
|
|
|
1328
1328
|
//#endregion
|
|
1329
1329
|
//#region src/v2/components/CopilotKitInspector.tsx
|
|
@@ -1559,7 +1559,7 @@ function InlineFeatureWarning({ featureName }) {
|
|
|
1559
1559
|
* Fetches resource content on-demand via proxied MCP requests. The React shell
|
|
1560
1560
|
* owns the iframe; `bindMcpApp` owns the protocol.
|
|
1561
1561
|
*/
|
|
1562
|
-
const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, message, agent, allowSameOriginFallback }) {
|
|
1562
|
+
const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, message, agent, allowSameOriginFallback, modelContext }) {
|
|
1563
1563
|
const { copilotkit } = useCopilotKit$1();
|
|
1564
1564
|
const messageId = message?.id;
|
|
1565
1565
|
const containerRef = useRef(null);
|
|
@@ -1609,7 +1609,10 @@ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, mess
|
|
|
1609
1609
|
getAgent: () => agentRef.current,
|
|
1610
1610
|
host: copilotkit,
|
|
1611
1611
|
messageId,
|
|
1612
|
-
options: {
|
|
1612
|
+
options: {
|
|
1613
|
+
allowSameOriginFallback,
|
|
1614
|
+
modelContext
|
|
1615
|
+
},
|
|
1613
1616
|
hooks: {
|
|
1614
1617
|
onResource: (resource) => {
|
|
1615
1618
|
if (!mounted) return;
|
|
@@ -1652,6 +1655,7 @@ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, mess
|
|
|
1652
1655
|
copilotkit,
|
|
1653
1656
|
messageId,
|
|
1654
1657
|
allowSameOriginFallback,
|
|
1658
|
+
modelContext,
|
|
1655
1659
|
content.resourceUri,
|
|
1656
1660
|
content.serverHash,
|
|
1657
1661
|
content.serverId
|
|
@@ -3195,11 +3199,6 @@ const DEFAULT_DESIGN_SKILL = `When generating UI with generateSandboxedUi, follo
|
|
|
3195
3199
|
- Use CSS Grid or Flexbox for layout. Ensure the UI looks good at any width.
|
|
3196
3200
|
- Minimal transitions (150ms) for hover/focus states only. No decorative animations.
|
|
3197
3201
|
- Keep the UI focused and dense — avoid excessive padding. Use compact spacing (8–12px gaps, 10–14px padding in controls).`;
|
|
3198
|
-
/** The MCP Apps renderer with `mcpApps.allowSameOriginFallback` applied. */
|
|
3199
|
-
const SameOriginMCPAppsActivityRenderer = (props) => /* @__PURE__ */ jsx(MCPAppsActivityRenderer, {
|
|
3200
|
-
...props,
|
|
3201
|
-
allowSameOriginFallback: true
|
|
3202
|
-
});
|
|
3203
3202
|
const DEFAULT_LEARNING = Object.freeze({});
|
|
3204
3203
|
function toLearningConfig(learning) {
|
|
3205
3204
|
if (learning === true) return DEFAULT_LEARNING;
|
|
@@ -3276,11 +3275,17 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3276
3275
|
return filterCatalog(rawCatalog, (name) => core ? core.isCatalogComponentEnabled(name) : true);
|
|
3277
3276
|
}, [rawCatalog, catalogToggleVersion]);
|
|
3278
3277
|
const mcpAppsAllowSameOrigin = mcpApps?.allowSameOriginFallback === true;
|
|
3278
|
+
const mcpAppsModelContext = mcpApps?.modelContext === true;
|
|
3279
|
+
const mcpAppsRenderer = useMemo(() => mcpAppsAllowSameOrigin || mcpAppsModelContext ? (props) => /* @__PURE__ */ jsx(MCPAppsActivityRenderer, {
|
|
3280
|
+
...props,
|
|
3281
|
+
allowSameOriginFallback: mcpAppsAllowSameOrigin,
|
|
3282
|
+
modelContext: mcpAppsModelContext
|
|
3283
|
+
}) : MCPAppsActivityRenderer, [mcpAppsAllowSameOrigin, mcpAppsModelContext]);
|
|
3279
3284
|
const builtInActivityRenderers = useMemo(() => {
|
|
3280
3285
|
const renderers = [{
|
|
3281
3286
|
activityType: MCPAppsActivityType,
|
|
3282
3287
|
content: MCPAppsActivityContentSchema,
|
|
3283
|
-
render:
|
|
3288
|
+
render: mcpAppsRenderer
|
|
3284
3289
|
}];
|
|
3285
3290
|
if (openGenUIActive) renderers.push({
|
|
3286
3291
|
activityType: OpenGenerativeUIActivityType,
|
|
@@ -3301,7 +3306,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3301
3306
|
generativeUIActive,
|
|
3302
3307
|
a2ui,
|
|
3303
3308
|
filteredCatalog,
|
|
3304
|
-
|
|
3309
|
+
mcpAppsRenderer
|
|
3305
3310
|
]);
|
|
3306
3311
|
const allActivityRenderers = useMemo(() => {
|
|
3307
3312
|
return [...renderActivityMessagesList, ...builtInActivityRenderers];
|
|
@@ -7427,9 +7432,12 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
|
|
|
7427
7432
|
}
|
|
7428
7433
|
};
|
|
7429
7434
|
};
|
|
7435
|
+
const isLatestAssistantMessage = message.role === "assistant" && (isLatest ?? messages?.[messages.length - 1]?.id === message.id);
|
|
7436
|
+
const isStreaming = !!isRunning && (isLatest === void 0 && messages === void 0 ? true : isLatestAssistantMessage);
|
|
7430
7437
|
const boundMarkdownRenderer = renderSlot(markdownRenderer, CopilotChatAssistantMessage.MarkdownRenderer, {
|
|
7431
7438
|
content: message.content || "",
|
|
7432
|
-
messageId: message.id
|
|
7439
|
+
messageId: message.id,
|
|
7440
|
+
mode: isStreaming ? "streaming" : "static"
|
|
7433
7441
|
});
|
|
7434
7442
|
const boundCopyButton = renderSlot(copyButton, CopilotChatAssistantMessage.CopyButton, { onClick: async () => {
|
|
7435
7443
|
if (message.content) return await copyToClipboard(message.content);
|
|
@@ -7471,7 +7479,6 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
|
|
|
7471
7479
|
messages
|
|
7472
7480
|
});
|
|
7473
7481
|
const hasContent = !!(message.content && message.content.trim().length > 0);
|
|
7474
|
-
const isLatestAssistantMessage = message.role === "assistant" && (isLatest ?? messages?.[messages.length - 1]?.id === message.id);
|
|
7475
7482
|
const shouldShowToolbar = toolbarVisible && (hasContent || showInspectorShortcut) && !(isRunning && isLatestAssistantMessage);
|
|
7476
7483
|
const { open: commentOpen, close: closeComment } = comment;
|
|
7477
7484
|
useEffect(() => {
|
|
@@ -8811,25 +8818,14 @@ const MemoizedCustomMessage = React.memo(function MemoizedCustomMessage({ messag
|
|
|
8811
8818
|
return true;
|
|
8812
8819
|
});
|
|
8813
8820
|
/**
|
|
8814
|
-
* Deduplicates messages by ID. For assistant messages, merges occurrences:
|
|
8815
|
-
* recovers non-empty content from any earlier occurrence if the latest wiped it
|
|
8816
|
-
* (empty string means the streaming update cleared the field, not blank text),
|
|
8817
|
-
* and similarly recovers toolCalls from earlier occurrences if the latest is
|
|
8818
|
-
* undefined (an empty array [] is treated as intentional and kept as-is).
|
|
8819
|
-
* For all other roles, keeps the last entry.
|
|
8820
|
-
*
|
|
8821
|
-
* @internal Exported for unit testing only — not part of the public API.
|
|
8822
|
-
*/
|
|
8823
|
-
/**
|
|
8824
8821
|
* Collapse tool calls that share an id, keeping first-seen order.
|
|
8825
8822
|
*
|
|
8826
|
-
* AG-UI
|
|
8827
|
-
*
|
|
8828
|
-
*
|
|
8829
|
-
*
|
|
8830
|
-
*
|
|
8831
|
-
*
|
|
8832
|
-
* copy.
|
|
8823
|
+
* Older AG-UI clients appended to the parent message's `toolCalls` without
|
|
8824
|
+
* checking whether that id was already present. So whenever a start event was
|
|
8825
|
+
* applied twice — which the human-in-the-loop flow triggers when the run syncs
|
|
8826
|
+
* after `respond()` — the message ended up carrying the same call twice. The
|
|
8827
|
+
* second copy has EMPTY `arguments`, because a start event carries none; the
|
|
8828
|
+
* args arrive later as TOOL_CALL_ARGS deltas addressed to the first copy.
|
|
8833
8829
|
*
|
|
8834
8830
|
* Left alone that renders the same tool call twice: once populated and once
|
|
8835
8831
|
* blank (an approval card with no transaction id, offering live buttons for an
|
|
@@ -8851,13 +8847,42 @@ function dedupeToolCalls(toolCalls) {
|
|
|
8851
8847
|
}
|
|
8852
8848
|
return byId.size === toolCalls.length ? toolCalls : [...byId.values()];
|
|
8853
8849
|
}
|
|
8850
|
+
/**
|
|
8851
|
+
* Unite the tool calls of two occurrences of the same assistant message,
|
|
8852
|
+
* keeping first-seen order. Each occurrence can hold only some of the calls,
|
|
8853
|
+
* so neither list may replace the other.
|
|
8854
|
+
*
|
|
8855
|
+
* For an id present in both, the later occurrence wins when it carries
|
|
8856
|
+
* arguments: it is the newer streaming update. A blank later copy never
|
|
8857
|
+
* replaces a populated one.
|
|
8858
|
+
*/
|
|
8859
|
+
function mergeToolCalls(earlier, later) {
|
|
8860
|
+
const byId = new Map(earlier.map((toolCall) => [toolCall.id, toolCall]));
|
|
8861
|
+
for (const toolCall of later) {
|
|
8862
|
+
const existing = byId.get(toolCall.id);
|
|
8863
|
+
if (!existing || toolCall.function?.arguments || !existing.function?.arguments) byId.set(toolCall.id, toolCall);
|
|
8864
|
+
}
|
|
8865
|
+
return [...byId.values()];
|
|
8866
|
+
}
|
|
8867
|
+
/**
|
|
8868
|
+
* Deduplicates messages by ID. For assistant messages, merges occurrences:
|
|
8869
|
+
* recovers non-empty content from any earlier occurrence if the latest wiped it
|
|
8870
|
+
* (empty string means the streaming update cleared the field, not blank text).
|
|
8871
|
+
* Tool calls from every occurrence are kept: a copy can hold only some of the
|
|
8872
|
+
* calls, so when two occurrences both carry tool calls they are united by id.
|
|
8873
|
+
* If the latest has undefined toolCalls they are recovered from earlier
|
|
8874
|
+
* occurrences; an explicit empty array [] is treated as intentional and kept.
|
|
8875
|
+
* For all other roles, keeps the last entry.
|
|
8876
|
+
*
|
|
8877
|
+
* @internal Exported for unit testing only — not part of the public API.
|
|
8878
|
+
*/
|
|
8854
8879
|
function deduplicateMessages(messages) {
|
|
8855
8880
|
const acc = /* @__PURE__ */ new Map();
|
|
8856
8881
|
for (const message of messages) {
|
|
8857
8882
|
const existing = acc.get(message.id);
|
|
8858
8883
|
if (existing && message.role === "assistant" && existing.role === "assistant") {
|
|
8859
8884
|
const content = message.content || existing.content;
|
|
8860
|
-
const toolCalls = message.toolCalls ?? existing.toolCalls;
|
|
8885
|
+
const toolCalls = message.toolCalls?.length && existing.toolCalls?.length ? mergeToolCalls(dedupeToolCalls(existing.toolCalls), dedupeToolCalls(message.toolCalls)) : message.toolCalls ?? existing.toolCalls;
|
|
8861
8886
|
acc.set(message.id, {
|
|
8862
8887
|
...existing,
|
|
8863
8888
|
...message,
|
|
@@ -8872,6 +8897,8 @@ function deduplicateMessages(messages) {
|
|
|
8872
8897
|
}
|
|
8873
8898
|
return [...acc.values()];
|
|
8874
8899
|
}
|
|
8900
|
+
/** At most this many rows are rendered beyond the viewport on either side. */
|
|
8901
|
+
const MAX_OVERSCAN_ROWS = 400;
|
|
8875
8902
|
/** A row holding a single message, rendered as it would be ungrouped. */
|
|
8876
8903
|
function messageRow(message) {
|
|
8877
8904
|
return {
|
|
@@ -8889,6 +8916,17 @@ function messageGroup(group) {
|
|
|
8889
8916
|
const GROUP_ROW_KEY_PREFIX = "copilotkit-group:";
|
|
8890
8917
|
const MESSAGE_ROW_KEY_PREFIX = "copilotkit-message:";
|
|
8891
8918
|
const VIRTUALIZE_THRESHOLD = 50;
|
|
8919
|
+
/**
|
|
8920
|
+
* How long the scroll position must stay still, with no wheel or touch input,
|
|
8921
|
+
* before a correction held back during scrolling is written to `scrollTop`.
|
|
8922
|
+
*/
|
|
8923
|
+
const SCROLL_SETTLE_MS = 250;
|
|
8924
|
+
/**
|
|
8925
|
+
* The most a held correction moves per frame once it is written. Safari can
|
|
8926
|
+
* still drop a write when a new gesture starts in the same frame; a small
|
|
8927
|
+
* step keeps that from showing.
|
|
8928
|
+
*/
|
|
8929
|
+
const SETTLE_STEP_PX = 4;
|
|
8892
8930
|
function CopilotChatMessageView({ messages = [], assistantMessage, userMessage, reasoningMessage, cursor, intelligenceIndicator, workSummary, isRunning = false, transformMessages, groupMessages, messageFeedback = true, toolCallDisplay = "grouped", children, className, ...props }) {
|
|
8893
8931
|
const isPinnedToBottom = useContext(ScrollPinnedContext);
|
|
8894
8932
|
const renderCustomMessage = useRenderCustomMessages();
|
|
@@ -9163,20 +9201,49 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
9163
9201
|
]);
|
|
9164
9202
|
const measuredRef = React.useRef({
|
|
9165
9203
|
total: 0,
|
|
9166
|
-
sizes: /* @__PURE__ */ new Map()
|
|
9204
|
+
sizes: /* @__PURE__ */ new Map(),
|
|
9205
|
+
estimates: /* @__PURE__ */ new Map()
|
|
9167
9206
|
});
|
|
9168
9207
|
const rowKeysRef = React.useRef(rowKeys);
|
|
9169
9208
|
rowKeysRef.current = rowKeys;
|
|
9170
9209
|
const resizeAnchorRef = React.useRef(null);
|
|
9171
9210
|
const restoringVisibilityRef = React.useRef(false);
|
|
9211
|
+
const heldOffsetRef = React.useRef(0);
|
|
9212
|
+
const spacerRef = React.useRef(null);
|
|
9213
|
+
const shiftedRowsRef = React.useRef(null);
|
|
9214
|
+
const lastMeasuredRef = React.useRef(null);
|
|
9215
|
+
const userScrollingRef = React.useRef(false);
|
|
9216
|
+
const ownScrollWriteRef = React.useRef(null);
|
|
9217
|
+
const renderedTotalRef = useRef(0);
|
|
9218
|
+
const applyHeldOffset = React.useCallback(() => {
|
|
9219
|
+
const held = heldOffsetRef.current;
|
|
9220
|
+
if (spacerRef.current) spacerRef.current.style.height = `${renderedTotalRef.current - held}px`;
|
|
9221
|
+
if (shiftedRowsRef.current) shiftedRowsRef.current.style.transform = held ? `translateY(${-held}px)` : "";
|
|
9222
|
+
}, []);
|
|
9223
|
+
const keepListTopInView = React.useCallback((scrollTop) => {
|
|
9224
|
+
if (heldOffsetRef.current >= 0 || scrollTop + heldOffsetRef.current >= 0) return false;
|
|
9225
|
+
heldOffsetRef.current = scrollTop > 0 ? -scrollTop : 0;
|
|
9226
|
+
return true;
|
|
9227
|
+
}, []);
|
|
9228
|
+
const releaseHeldOffset = React.useCallback((element, amount) => {
|
|
9229
|
+
if (amount === 0) return;
|
|
9230
|
+
const scrollTop = element.scrollTop;
|
|
9231
|
+
heldOffsetRef.current -= amount;
|
|
9232
|
+
applyHeldOffset();
|
|
9233
|
+
const target = Math.max(0, scrollTop + amount);
|
|
9234
|
+
ownScrollWriteRef.current = target;
|
|
9235
|
+
element.scrollTop = target;
|
|
9236
|
+
}, [applyHeldOffset]);
|
|
9172
9237
|
const firstMessageId = deduplicatedMessages[0]?.id;
|
|
9173
9238
|
const measuredThreadRef = React.useRef(firstMessageId);
|
|
9174
9239
|
if (measuredThreadRef.current !== firstMessageId) {
|
|
9175
9240
|
measuredThreadRef.current = firstMessageId;
|
|
9176
9241
|
resizeAnchorRef.current = null;
|
|
9242
|
+
heldOffsetRef.current = 0;
|
|
9177
9243
|
measuredRef.current = {
|
|
9178
9244
|
total: 0,
|
|
9179
|
-
sizes: /* @__PURE__ */ new Map()
|
|
9245
|
+
sizes: /* @__PURE__ */ new Map(),
|
|
9246
|
+
estimates: /* @__PURE__ */ new Map()
|
|
9180
9247
|
};
|
|
9181
9248
|
}
|
|
9182
9249
|
const measuredKeysRef = React.useRef(rowKeys);
|
|
@@ -9188,10 +9255,19 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
9188
9255
|
measured.sizes.delete(key);
|
|
9189
9256
|
measured.total -= height;
|
|
9190
9257
|
}
|
|
9258
|
+
for (const key of measured.estimates.keys()) if (!live.has(key)) measured.estimates.delete(key);
|
|
9191
9259
|
}
|
|
9192
|
-
const estimateRowSize = React.useCallback(() => {
|
|
9193
|
-
const { total, sizes } = measuredRef.current;
|
|
9194
|
-
|
|
9260
|
+
const estimateRowSize = React.useCallback((index) => {
|
|
9261
|
+
const { total, sizes, estimates } = measuredRef.current;
|
|
9262
|
+
const mean = sizes.size > 0 ? Math.max(1, Math.round(total / sizes.size)) : 100;
|
|
9263
|
+
const key = rowKeysRef.current[index];
|
|
9264
|
+
if (key === void 0) return mean;
|
|
9265
|
+
let estimate = estimates.get(key);
|
|
9266
|
+
if (estimate === void 0) {
|
|
9267
|
+
estimate = mean;
|
|
9268
|
+
estimates.set(key, estimate);
|
|
9269
|
+
}
|
|
9270
|
+
return estimate;
|
|
9195
9271
|
}, []);
|
|
9196
9272
|
const getRowKey = React.useCallback((index) => rowKeys[index] ?? index, [rowKeys]);
|
|
9197
9273
|
const isPinnedToBottomRef = React.useRef(isPinnedToBottom);
|
|
@@ -9206,7 +9282,7 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
9206
9282
|
};
|
|
9207
9283
|
return;
|
|
9208
9284
|
}
|
|
9209
|
-
const offset = instance.scrollElement?.scrollTop ?? 0;
|
|
9285
|
+
const offset = (instance.scrollElement?.scrollTop ?? 0) + heldOffsetRef.current;
|
|
9210
9286
|
const anchor = instance.getVirtualItemForOffset(offset);
|
|
9211
9287
|
if (anchor) resizeAnchorRef.current = {
|
|
9212
9288
|
index: anchor.index,
|
|
@@ -9216,20 +9292,46 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
9216
9292
|
}, []);
|
|
9217
9293
|
const measureRowElement = React.useCallback((el, _entry, instance) => {
|
|
9218
9294
|
captureResizeAnchor(instance);
|
|
9219
|
-
const
|
|
9295
|
+
const rect = el?.getBoundingClientRect();
|
|
9296
|
+
const height = rect?.height ?? 0;
|
|
9220
9297
|
const index = Number(el?.dataset?.index);
|
|
9221
9298
|
const key = Number.isInteger(index) ? rowKeysRef.current[index] : void 0;
|
|
9222
|
-
|
|
9299
|
+
const viewportTop = typeof rect?.top === "number" ? instance.scrollElement?.getBoundingClientRect().top : void 0;
|
|
9300
|
+
lastMeasuredRef.current = Number.isInteger(index) && typeof rect?.top === "number" && typeof viewportTop === "number" ? {
|
|
9301
|
+
index,
|
|
9302
|
+
above: rect.top < viewportTop
|
|
9303
|
+
} : null;
|
|
9304
|
+
const hidden = !el?.isConnected || !instance.scrollElement?.clientHeight;
|
|
9305
|
+
if ((height > 0 || !hidden) && key !== void 0) {
|
|
9223
9306
|
const { total, sizes } = measuredRef.current;
|
|
9224
9307
|
measuredRef.current.total = total - (sizes.get(key) ?? 0) + height;
|
|
9225
9308
|
sizes.set(key, height);
|
|
9226
9309
|
}
|
|
9227
|
-
return height > 0 ? height : (key === void 0 ? void 0 : measuredRef.current.sizes.get(key)) ?? 100;
|
|
9310
|
+
return height > 0 || !hidden ? height : (key === void 0 ? void 0 : measuredRef.current.sizes.get(key)) ?? 100;
|
|
9228
9311
|
}, [captureResizeAnchor]);
|
|
9229
|
-
const shouldAdjustScrollOnResize = React.useCallback((item,
|
|
9312
|
+
const shouldAdjustScrollOnResize = React.useCallback((item, delta, instance) => {
|
|
9313
|
+
const measured = lastMeasuredRef.current;
|
|
9314
|
+
lastMeasuredRef.current = null;
|
|
9230
9315
|
if (isPinnedToBottomRef.current || resizeAnchorRef.current || restoringVisibilityRef.current) return false;
|
|
9231
9316
|
const scrollAdjustments = instance.scrollAdjustments ?? 0;
|
|
9232
|
-
|
|
9317
|
+
if (!(measured?.index === item.index ? measured.above : item.start < (instance.scrollOffset ?? 0) + scrollAdjustments)) return false;
|
|
9318
|
+
if (userScrollingRef.current || heldOffsetRef.current !== 0) {
|
|
9319
|
+
const held = heldOffsetRef.current;
|
|
9320
|
+
heldOffsetRef.current += delta;
|
|
9321
|
+
keepListTopInView(instance.scrollElement?.scrollTop ?? 0);
|
|
9322
|
+
instance.scrollOffset = (instance.scrollOffset ?? 0) + heldOffsetRef.current - held;
|
|
9323
|
+
return false;
|
|
9324
|
+
}
|
|
9325
|
+
return true;
|
|
9326
|
+
}, [keepListTopInView]);
|
|
9327
|
+
const observeListOffset = React.useCallback((instance, notify) => observeElementOffset(instance, (offset, isScrolling) => {
|
|
9328
|
+
if (keepListTopInView(offset)) applyHeldOffset();
|
|
9329
|
+
notify(offset + heldOffsetRef.current, isScrolling);
|
|
9330
|
+
}), [keepListTopInView, applyHeldOffset]);
|
|
9331
|
+
const scrollToListOffset = React.useCallback((offset, options, instance) => {
|
|
9332
|
+
const elementOffset = offset - heldOffsetRef.current;
|
|
9333
|
+
ownScrollWriteRef.current = elementOffset + (options.adjustments ?? 0);
|
|
9334
|
+
elementScroll(elementOffset, options, instance);
|
|
9233
9335
|
}, []);
|
|
9234
9336
|
const observeScrollRect = React.useCallback((instance, notify) => {
|
|
9235
9337
|
let frame;
|
|
@@ -9260,7 +9362,8 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
9260
9362
|
instance.getTotalSize();
|
|
9261
9363
|
measuredRef.current = {
|
|
9262
9364
|
total: 0,
|
|
9263
|
-
sizes: /* @__PURE__ */ new Map()
|
|
9365
|
+
sizes: /* @__PURE__ */ new Map(),
|
|
9366
|
+
estimates: /* @__PURE__ */ new Map()
|
|
9264
9367
|
};
|
|
9265
9368
|
instance.elementsCache.forEach((element) => {
|
|
9266
9369
|
measureRowElement(element, void 0, instance);
|
|
@@ -9285,28 +9388,120 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
9285
9388
|
resizeAnchorRef.current = null;
|
|
9286
9389
|
};
|
|
9287
9390
|
}, [captureResizeAnchor, measureRowElement]);
|
|
9391
|
+
const virtualizerRef = useRef(null);
|
|
9392
|
+
const rangeExtractor = React.useCallback((range) => {
|
|
9393
|
+
const instance = virtualizerRef.current;
|
|
9394
|
+
const items = instance?.measurementsCache;
|
|
9395
|
+
const reach = instance?.scrollRect?.height ?? 0;
|
|
9396
|
+
if (!items || items.length !== range.count || reach <= 0) return defaultRangeExtractor(range);
|
|
9397
|
+
let start = range.startIndex;
|
|
9398
|
+
for (let above = 0; start > 0 && range.startIndex - start < MAX_OVERSCAN_ROWS && (range.startIndex - start < range.overscan || above < reach);) {
|
|
9399
|
+
start -= 1;
|
|
9400
|
+
above += items[start].size;
|
|
9401
|
+
}
|
|
9402
|
+
let end = range.endIndex;
|
|
9403
|
+
for (let below = 0; end < range.count - 1 && end - range.endIndex < MAX_OVERSCAN_ROWS && (end - range.endIndex < range.overscan || below < reach);) {
|
|
9404
|
+
end += 1;
|
|
9405
|
+
below += items[end].size;
|
|
9406
|
+
}
|
|
9407
|
+
const indexes = [];
|
|
9408
|
+
for (let index = start; index <= end; index++) indexes.push(index);
|
|
9409
|
+
return indexes;
|
|
9410
|
+
}, []);
|
|
9288
9411
|
const virtualizer = useVirtualizer({
|
|
9289
9412
|
count: shouldVirtualize ? rows.length : 0,
|
|
9290
9413
|
getScrollElement: () => shouldVirtualize ? scrollElement : null,
|
|
9291
9414
|
observeElementRect: observeScrollRect,
|
|
9415
|
+
observeElementOffset: observeListOffset,
|
|
9416
|
+
scrollToFn: scrollToListOffset,
|
|
9292
9417
|
estimateSize: estimateRowSize,
|
|
9293
9418
|
getItemKey: getRowKey,
|
|
9294
9419
|
overscan: 5,
|
|
9420
|
+
rangeExtractor,
|
|
9295
9421
|
measureElement: measureRowElement,
|
|
9296
9422
|
initialRect: {
|
|
9297
9423
|
width: 0,
|
|
9298
9424
|
height: 600
|
|
9299
9425
|
}
|
|
9300
9426
|
});
|
|
9427
|
+
virtualizerRef.current = virtualizer;
|
|
9428
|
+
renderedTotalRef.current = virtualizer.getTotalSize();
|
|
9429
|
+
useLayoutEffect(applyHeldOffset);
|
|
9430
|
+
useEffect(() => {
|
|
9431
|
+
const element = shouldVirtualize ? scrollElement : null;
|
|
9432
|
+
if (!element) return;
|
|
9433
|
+
let settleTimer;
|
|
9434
|
+
let settleFrame;
|
|
9435
|
+
let touching = false;
|
|
9436
|
+
const settleStep = () => {
|
|
9437
|
+
settleFrame = void 0;
|
|
9438
|
+
const held = heldOffsetRef.current;
|
|
9439
|
+
if (userScrollingRef.current || touching || held === 0) return;
|
|
9440
|
+
releaseHeldOffset(element, Math.sign(held) * Math.min(Math.abs(held), SETTLE_STEP_PX));
|
|
9441
|
+
if (heldOffsetRef.current !== 0) settleFrame = requestAnimationFrame(settleStep);
|
|
9442
|
+
};
|
|
9443
|
+
const settle = () => {
|
|
9444
|
+
settleTimer = void 0;
|
|
9445
|
+
if (touching) return;
|
|
9446
|
+
userScrollingRef.current = false;
|
|
9447
|
+
if (heldOffsetRef.current !== 0 && settleFrame === void 0) settleFrame = requestAnimationFrame(settleStep);
|
|
9448
|
+
};
|
|
9449
|
+
const scrolling = () => {
|
|
9450
|
+
userScrollingRef.current = true;
|
|
9451
|
+
if (settleFrame !== void 0) {
|
|
9452
|
+
cancelAnimationFrame(settleFrame);
|
|
9453
|
+
settleFrame = void 0;
|
|
9454
|
+
}
|
|
9455
|
+
if (settleTimer !== void 0) clearTimeout(settleTimer);
|
|
9456
|
+
settleTimer = setTimeout(settle, SCROLL_SETTLE_MS);
|
|
9457
|
+
};
|
|
9458
|
+
const onScroll = () => {
|
|
9459
|
+
const own = ownScrollWriteRef.current;
|
|
9460
|
+
if (own !== null && Math.abs(element.scrollTop - own) < 1) {
|
|
9461
|
+
ownScrollWriteRef.current = null;
|
|
9462
|
+
return;
|
|
9463
|
+
}
|
|
9464
|
+
scrolling();
|
|
9465
|
+
};
|
|
9466
|
+
const onTouchStart = () => {
|
|
9467
|
+
touching = true;
|
|
9468
|
+
scrolling();
|
|
9469
|
+
};
|
|
9470
|
+
const onTouchEnd = () => {
|
|
9471
|
+
touching = false;
|
|
9472
|
+
scrolling();
|
|
9473
|
+
};
|
|
9474
|
+
element.addEventListener("scroll", onScroll, { passive: true });
|
|
9475
|
+
element.addEventListener("wheel", scrolling, { passive: true });
|
|
9476
|
+
element.addEventListener("touchstart", onTouchStart, { passive: true });
|
|
9477
|
+
element.addEventListener("touchend", onTouchEnd, { passive: true });
|
|
9478
|
+
element.addEventListener("touchcancel", onTouchEnd, { passive: true });
|
|
9479
|
+
return () => {
|
|
9480
|
+
if (settleTimer !== void 0) clearTimeout(settleTimer);
|
|
9481
|
+
if (settleFrame !== void 0) cancelAnimationFrame(settleFrame);
|
|
9482
|
+
userScrollingRef.current = false;
|
|
9483
|
+
element.removeEventListener("scroll", onScroll);
|
|
9484
|
+
element.removeEventListener("wheel", scrolling);
|
|
9485
|
+
element.removeEventListener("touchstart", onTouchStart);
|
|
9486
|
+
element.removeEventListener("touchend", onTouchEnd);
|
|
9487
|
+
element.removeEventListener("touchcancel", onTouchEnd);
|
|
9488
|
+
};
|
|
9489
|
+
}, [
|
|
9490
|
+
shouldVirtualize,
|
|
9491
|
+
scrollElement,
|
|
9492
|
+
releaseHeldOffset
|
|
9493
|
+
]);
|
|
9301
9494
|
isPinnedToBottomRef.current = isPinnedToBottom;
|
|
9302
9495
|
virtualizer.shouldAdjustScrollPositionOnItemSizeChange = shouldAdjustScrollOnResize;
|
|
9303
9496
|
useLayoutEffect(() => {
|
|
9304
9497
|
const anchor = resizeAnchorRef.current;
|
|
9305
9498
|
if (!anchor?.ready || restoringVisibilityRef.current) return;
|
|
9499
|
+
if (scrollElement) releaseHeldOffset(scrollElement, heldOffsetRef.current);
|
|
9306
9500
|
const position = virtualizer.getOffsetForIndex(anchor.index, "start");
|
|
9307
9501
|
if (position && !isPinnedToBottomRef.current) {
|
|
9308
9502
|
const target = position[0] + anchor.offset;
|
|
9309
|
-
|
|
9503
|
+
const listOffset = (scrollElement?.scrollTop ?? 0) + heldOffsetRef.current;
|
|
9504
|
+
if (Math.abs(listOffset - target) > .5) virtualizer.scrollToOffset(target);
|
|
9310
9505
|
}
|
|
9311
9506
|
const frame = requestAnimationFrame(() => {
|
|
9312
9507
|
if (resizeAnchorRef.current === anchor) resizeAnchorRef.current = null;
|
|
@@ -9524,26 +9719,37 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
9524
9719
|
...props,
|
|
9525
9720
|
children: [
|
|
9526
9721
|
shouldVirtualize ? /* @__PURE__ */ jsx("div", {
|
|
9722
|
+
ref: spacerRef,
|
|
9527
9723
|
style: {
|
|
9528
|
-
height:
|
|
9724
|
+
height: renderedTotalRef.current - heldOffsetRef.current,
|
|
9529
9725
|
position: "relative",
|
|
9530
9726
|
overflowAnchor: "none"
|
|
9531
9727
|
},
|
|
9532
|
-
children:
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
"
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
|
|
9541
|
-
|
|
9542
|
-
|
|
9543
|
-
|
|
9544
|
-
|
|
9545
|
-
|
|
9546
|
-
|
|
9728
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
9729
|
+
ref: shiftedRowsRef,
|
|
9730
|
+
style: {
|
|
9731
|
+
position: "absolute",
|
|
9732
|
+
top: 0,
|
|
9733
|
+
left: 0,
|
|
9734
|
+
width: "100%",
|
|
9735
|
+
transform: heldOffsetRef.current ? `translateY(${-heldOffsetRef.current}px)` : void 0
|
|
9736
|
+
},
|
|
9737
|
+
children: virtualizer.getVirtualItems().map((virtualItem) => {
|
|
9738
|
+
const row = rows[virtualItem.index];
|
|
9739
|
+
return /* @__PURE__ */ jsx("div", {
|
|
9740
|
+
"data-index": virtualItem.index,
|
|
9741
|
+
"data-scroll-anchor": rowKey(row),
|
|
9742
|
+
ref: virtualizer.measureElement,
|
|
9743
|
+
style: {
|
|
9744
|
+
position: "absolute",
|
|
9745
|
+
top: 0,
|
|
9746
|
+
left: 0,
|
|
9747
|
+
width: "100%",
|
|
9748
|
+
transform: `translateY(${virtualItem.start}px)`
|
|
9749
|
+
},
|
|
9750
|
+
children: renderRow(row)
|
|
9751
|
+
}, rowKey(row));
|
|
9752
|
+
})
|
|
9547
9753
|
})
|
|
9548
9754
|
}) : messageElements,
|
|
9549
9755
|
interruptElement,
|
|
@@ -10424,7 +10630,7 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
10424
10630
|
...props,
|
|
10425
10631
|
children: [/* @__PURE__ */ jsx(Loader2, {
|
|
10426
10632
|
"aria-hidden": "true",
|
|
10427
|
-
className: "cpk:size-6 cpk:
|
|
10633
|
+
className: "cpk:size-6 cpk:text-muted-foreground cpk:*:origin-center cpk:*:animate-spin"
|
|
10428
10634
|
}), /* @__PURE__ */ jsx("span", {
|
|
10429
10635
|
className: "cpk:sr-only",
|
|
10430
10636
|
children: labels.chatConnectingLabel
|
|
@@ -14537,5 +14743,5 @@ function validateProps(props) {
|
|
|
14537
14743
|
}
|
|
14538
14744
|
|
|
14539
14745
|
//#endregion
|
|
14540
|
-
export { INTERRUPT_EVENT_NAME as $,
|
|
14541
|
-
//# sourceMappingURL=copilotkit-
|
|
14746
|
+
export { INTERRUPT_EVENT_NAME as $, ɵobservePhoenixEvent$ as $a, getMarkdownOperationSurfaceId as $i, MetadataSchema as $n, TextInputContentSchema as $r, AudioInputPartSchema as $t, CopilotChatMessageView as A, transformChunks as Aa, contentHasMedia as Ai, FunctionCallSchema as An, RunFinishedInterruptOutcomeSchema as Ar, ɵrunMcpFollowUp as At, CopilotChatReasoningMessage_default as B, ɵcreateMemoryStore as Ba, defaultApplyEvents as Bi, InputContentSchema as Bn, StepFinishedEventSchema as Br, AGUIError as Bt, CopilotModalHeader as C, runHttpRequest as Ca, WebMCPRegistry as Ci, EventSchema as Cn, ReplaceOperationSchema as Cr, OpenGenerativeUIContentSchema as Ct, CopilotChat as D, structuredClone_ as Da, classifySurfaceCards as Di, ExecutionCapabilitiesSchema as Dn, RunErrorEventSchema as Dr, MCPAppsActivityContentSchema as Dt, DefaultOpenIcon as E, splitA2UIMarkdown$1 as Ea, buildResumeArray as Ei, EventTypeSchema as En, RunAgentInputSchema as Er, useSandboxFunctions as Et, getIntelligenceTurnAnchors as F, ɵInterruptState$1 as Fa, createEffect as Fi, IdentityCapabilitiesSchema as Fn, StateCapabilitiesSchema as Fr, CopilotChatAudioRecorder as Ft, useLearningContainersInCurrentThread as G, ɵisHttpAgent$1 as Ga, empty as Gi, InterruptSchema as Gn, SubagentFinishedSuccessOutcomeSchema as Gr, ActivitySnapshotEventSchema as Gt, CopilotChatAttachmentRenderer as H, ɵcreateThreadStore$1 as Ha, emitInspectorStopViewing as Hi, InputContentUrlSourceSchema as Hn, SubagentErrorEventSchema as Hr, AbstractAgent$1 as Ht, IntelligenceIndicatorView as I, ɵMAX_SOCKET_RETRIES as Ia, createInspectorThreadRequestId as Ii, ImageInputContentSchema as In, StateDeltaEventSchema as Ir, A2UI_FENCE_LANGUAGE as It, useLearnFromUserActionInCurrentThread as J, ɵmapMemoryMetadataEvent as Ja, ensureObjectArgs as Ji, JsonPointerSchema as Jn, SubagentRunIdSchema as Jr, AgentRegistry as Jt, useLearningContainers as K, ɵisRetryableMemoryStatus as Ka, enforceEvents as Ki, JsonPatchOperationSchema as Kn, SubagentFinishedSuspendedOutcomeSchema as Kr, AddOperationSchema as Kt, CopilotChatWorkSummary as L, ɵRUNTIME_PROBE_TIMEOUT_MS as La, createReducer as Li, ImageInputPartSchema as Ln, StateManager as Lr, ACTIVITY_HISTORY_METADATA as Lt, messageRow as M, verifyEvents as Ma, convertToLegacyEvents as Mi, HttpAgent as Mn, RunFinishedSuccessOutcomeSchema as Mr, useRenderToolCall as Mt, INTELLIGENCE_TURN_HEAD as N, withAuthoritativeActivityTypes as Na, createActionGroup as Ni, HumanInTheLoopCapabilitiesSchema as Nn, RunHandler as Nr, CopilotChatInput_default as Nt, CopilotChatView_default as O, tokenUsageFromAiSdkUsage as Oa, compactEvents as Oi, FileSourceSchema as On, RunFinishedCancelledOutcomeSchema as Or, MCPAppsActivityRenderer as Ot, IntelligenceIndicator as P, ɵCOPILOTKIT_FEATURES as Pa, createDebugLogger as Pi, INSPECTOR_THREAD_BRIDGE_PLUGIN_ID as Pn, RunStartedEventSchema as Pr, AudioRecorderError as Pt, useInterrupt as Q, ɵmemoryRestEvents as Qa, flattenInformationalCards as Qi, MessagesSnapshotEventSchema as Qn, TestOperationSchema as Qr, AudioInputContentSchema as Qt, CopilotChatSuggestionView as R, ɵTHREAD_REQUEST_TIMEOUT_MS as Ra, createSelector as Ri, ImagePartSchema as Rn, StateSchema as Rr, AGUIConnectNotImplementedError$1 as Rt, CopilotSidebarView as S, resolveDebugLogger as Sa, VideoPartSchema as Si, DocumentPartSchema as Sn, RemoveOperationSchema as Sr, OpenGenerativeUIActivityType as St, DefaultCloseIcon as T, select as Ta, authoritativeActivityTypes as Ti, EventType as Tn, RoleSchema as Tr, SandboxFunctionsContext as Tt, CopilotChatAssistantMessage_default as U, ɵgetAgentInterruptState$1 as Ua, emitInspectorViewThread as Ui, IntelligenceAgent as Un, SubagentFinishedEventSchema as Ur, ActivityDeltaEventSchema as Ut, CopilotChatUserMessage_default as V, ɵcreateThreadSelectors as Va, emitInspectorActiveThread$1 as Vi, InputContentSourceSchema as Vn, StepStartedEventSchema as Vr, AGUI_METADATA_KEY as Vt, CopilotChatToolCallsView as W, ɵisCopilotKitFeature as Wa, emitInspectorViewThreadResult$1 as Wi, IntelligenceReplayFailedError as Wn, SubagentFinishedOutcomeSchema as Wr, ActivityMessageSchema as Wt, useMemories as X, ɵmemoryDomainEvents as Xa, extractFenceOperations as Xi, MemoryError as Xn, SuggestionEngine as Xr, AssistantMessageSchema as Xt, useLearnFromUserAction as Y, ɵmemoryAdapterEvents as Ya, extractCompleteArrayItems as Yi, MEMORY_ERROR_REGISTRY as Yn, SubagentStartedEventSchema as Yr, AgentThreadLockedError as Yt, useThreads$1 as Z, ɵmemoryReducer as Za, extractStringField as Zi, MessageSchema as Zn, SystemMessageSchema as Zr, AttributableSchema as Zt, WildcardToolCallRender as _, parseToolArguments as _a, TransportCapabilitiesSchema as _i, DataSourceSchema as _n, ɵselectThreadsIsLoading$1 as _o, ReasoningMessageContentEventSchema as _r, useLicenseContext$1 as _t, ThreadsProvider as a, isRecognizedEvent as aa, TextPartSchema as ai, BaseMessageSchema as an, ɵselectFetchMoreError$1 as ao, MultimodalOutputCapabilitiesSchema as ar, useAgent as at, CopilotSidebar as b, randomUUID$2 as ba, VideoInputContentSchema as bi, DocumentInputContentSchema as bn, ReasoningMessageStartEventSchema as br, GenerateSandboxedUiArgsSchema as bt, CoAgentStateRendersProvider as c, ofType as ca, ToolCallChunkEventSchema as ci, ContextSchema as cn, ɵselectIsMutating$1 as co, PROTOCOL_VERSION as cr, CopilotChatToolCallGroup as ct, shouldShowDevConsole as d, onInspectorActiveThread as da, ToolCallSchema as di, CopilotKitCoreErrorCode$1 as dn, ɵselectMemoriesError$1 as do, RawEventSchema as dr, useFrontendTools as dt, getRunOutcome as ea, TextMessageChunkEventSchema as ei, AudioPartSchema as en, ɵobservePhoenixJoinOutcome$ as eo, Middleware as er, useConfigureSuggestions as et, useToast as f, onInspectorStopViewing$1 as fa, ToolCallStartEventSchema as fi, CopilotKitCoreRuntimeConnectionStatus$1 as fn, ɵselectMemoriesIsLoading$1 as fo, ReasoningCapabilitiesSchema as fr, useFrontendTool as ft, useCopilotContext as g, parseSSEStream as ga, ToolsCapabilitiesSchema as gi, DEFAULT_MAX_ENFORCED_ENTRIES as gn, ɵselectThreadsError$1 as go, ReasoningMessageChunkEventSchema as gr, useCopilotKit$1 as gt, CopilotContext as h, parseProtoStream as ha, ToolSchema as hi, CustomEventSchema as hn, ɵselectThreads$1 as ho, ReasoningEndEventSchema as hr, CopilotKitProvider as ht, ThreadsContext as i, isInterruptExpired as ia, TextMessageStartEventSchema as ii, BaseEventSchema as in, ɵphoenixSocket$ as io, MultimodalInputCapabilitiesSchema as ir, UseAgentUpdate as it, messageGroup as j, transformHttpEventStream as ja, contentToText$1 as ji, FunctionMiddleware as jn, RunFinishedOutcomeSchema as jr, CopilotKitInspector as jt, CopilotChatAttachmentQueue as k, tokenUsageFromLangChainMetadata as ka, completePartialMarkdown as ki, FilterToolCallsMiddleware as kn, RunFinishedEventSchema as kr, MCPAppsActivityType as kt, useCoAgentStateRenders as l, omitOptionalNulls as la, ToolCallEndEventSchema as li, ContextStore as ln, ɵselectMemories$1 as lo, PartSourceSchema as lr, useRenderTool as lt, useCopilotMessagesContext as m, onInspectorViewThreadResult as ma, ToolMessageSchema as mi, CopyOperationSchema as mn, ɵselectMemoriesRealtimeStatus$1 as mo, ReasoningEncryptedValueSubtypeSchema as mr, useRenderCustomMessages as mt, defaultCopilotContextCategories as n, isAbortError as na, TextMessageEndEventSchema as ni, BackwardCompatibility_0_0_45 as nn, ɵobservePhoenixSocketSignals$ as no, MultiAgentCapabilitiesSchema as nr, useAgentContext as nt, useThreads as o, isRunCompletionAware$1 as oa, TokenUsageSchema as oi, CompatibilityBoundary as on, ɵselectHasNextPage$1 as oo, OptionalMetadataSchema as or, useHumanInTheLoop as ot, CopilotMessagesContext as p, onInspectorViewThread$1 as pa, ToolCallStatus$1 as pi, CopilotKitHeaderResolutionError as pn, ɵselectMemoriesIsMutating as po, ReasoningEncryptedValueEventSchema as pr, useRenderActivityMessage as pt, useAttachments as q, ɵjoinPhoenixChannel$ as qa, enforceOutgoingInput as qi, JsonPatchSchema as qn, SubagentInfoSchema as qr, AgentCapabilitiesSchema as qt, CoAgentStateRenderBridge as r, isInspectorThreadBridgeEnabled$1 as ra, TextMessageRoleSchema as ri, BackwardCompatibility_0_0_57 as rn, ɵphoenixChannel$ as ro, MultimodalCapabilitiesSchema as rr, useCapabilities as rt, CoAgentStateRendersContext as s, mergeMetadata as sa, ToolCallArgsEventSchema as si, ContentPartSchema as sn, ɵselectIsFetchingNextPage$1 as so, OutputCapabilitiesSchema as sr, useDefaultRenderTool as st, CopilotKit as t, getWebMCPModelContext as ta, TextMessageContentEventSchema as ti, BackwardCompatibility_0_0_39 as tn, ɵobservePhoenixSocketHealth$ as to, MoveOperationSchema as tr, useSuggestions as tt, useAsyncCallback as u, on as ua, ToolCallResultEventSchema as ui, CopilotKitCore$1 as un, ɵselectMemoriesAvailable$1 as uo, ProxiedCopilotRuntimeAgent$1 as ur, useComponent as ut, CopilotThreadsDrawer as v, prepareSurfaceOperations as va, UrlSourceSchema as vi, DebugLogger as vn, ɵthreadAdapterEvents as vo, ReasoningMessageEndEventSchema as vr, CopilotKitCoreReact as vt, CopilotChatToggleButton as w, segmentSurfaceProse as wa, aggregateTokenUsage as wi, EventSchemas as wn, ResumeEntrySchema as wr, OpenGenerativeUIToolRenderer as wt, CopilotPopupView as x, resolveAgentDebugConfig as xa, VideoInputPartSchema as xi, DocumentInputPartSchema as xn, ReasoningStartEventSchema as xr, OpenGenerativeUIActivityRenderer as xt, CopilotPopup as y, props as ya, UserMessageSchema as yi, DeveloperMessageSchema as yn, ɵwithHeaderDefaults$1 as yo, ReasoningMessageSchema as yr, createA2UIMessageRenderer as yt, CopilotChatSuggestionPill as z, ɵclearAgentInterruptState$1 as za, createStore as zi, InputContentDataSourceSchema as zn, StateSnapshotEventSchema as zr, AGUIEnforcementLimitError as zt };
|
|
14747
|
+
//# sourceMappingURL=copilotkit-GWoyxfzS.mjs.map
|