@copilotkit/react-core 1.75.2 → 1.76.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-CGlSOKHM.d.mts → copilotkit-B90cY0Zg.d.mts} +18 -17
- package/dist/copilotkit-B90cY0Zg.d.mts.map +1 -0
- package/dist/{copilotkit-D9iy3p2l.mjs → copilotkit-LD7Gp2aV.mjs} +72 -35
- package/dist/copilotkit-LD7Gp2aV.mjs.map +1 -0
- package/dist/{copilotkit-Cjj9wDI8.d.cts → copilotkit-W-bV_OSs.d.cts} +5 -4
- package/dist/copilotkit-W-bV_OSs.d.cts.map +1 -0
- package/dist/{copilotkit-Beiw32bn.cjs → copilotkit-dHdNF7H5.cjs} +68 -32
- package/dist/copilotkit-dHdNF7H5.cjs.map +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +21 -29
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +17 -24
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts +2 -2
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +18 -25
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +302 -121
- 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 +370 -155
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +10 -10
- package/dist/copilotkit-Beiw32bn.cjs.map +0 -1
- package/dist/copilotkit-CGlSOKHM.d.mts.map +0 -1
- package/dist/copilotkit-Cjj9wDI8.d.cts.map +0 -1
- package/dist/copilotkit-D9iy3p2l.mjs.map +0 -1
|
@@ -1,7 +1,8 @@
|
|
|
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 { 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,
|
|
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, ɵ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 } from "@copilotkit/core";
|
|
4
|
+
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";
|
|
5
|
+
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";
|
|
5
6
|
import { extendTailwindMerge, twMerge } from "tailwind-merge";
|
|
6
7
|
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
8
|
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";
|
|
@@ -13,6 +14,7 @@ import { clsx } from "clsx";
|
|
|
13
14
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
14
15
|
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
15
16
|
import { Streamdown } from "streamdown";
|
|
17
|
+
import { contentToText } from "@ag-ui/core";
|
|
16
18
|
import { z } from "zod";
|
|
17
19
|
import { MCPAppsActivityContentSchema, MCPAppsActivityType, ɵrunMcpFollowUp } from "@copilotkit/mcp-apps-renderer/activity";
|
|
18
20
|
import { A2UIProvider, A2UIRenderer, A2UI_SCHEMA_CONTEXT_DESCRIPTION, Catalog, DEFAULT_SURFACE_ID, ROOT_COMPONENT_ID, buildCatalogContextValue, extractCatalogComponentSchemas, filterCatalog, initializeDefaultCatalog, injectStyles, useA2UIActions, useA2UIError, viewerTheme } from "@copilotkit/a2ui-renderer";
|
|
@@ -1509,7 +1511,7 @@ const ToolCallRenderer = React.memo(function ToolCallRenderer({ toolCall, toolMe
|
|
|
1509
1511
|
toolCallId: toolCall.id,
|
|
1510
1512
|
args,
|
|
1511
1513
|
status: ToolCallStatus.Complete,
|
|
1512
|
-
result: toolMessage.content
|
|
1514
|
+
result: contentToText(toolMessage.content)
|
|
1513
1515
|
});
|
|
1514
1516
|
else if (isExecuting) return /* @__PURE__ */ jsx(RenderComponent, {
|
|
1515
1517
|
name: toolName,
|
|
@@ -1605,7 +1607,7 @@ function useRenderToolCall() {
|
|
|
1605
1607
|
|
|
1606
1608
|
//#endregion
|
|
1607
1609
|
//#region package.json
|
|
1608
|
-
var version = "1.
|
|
1610
|
+
var version = "1.76.0";
|
|
1609
1611
|
|
|
1610
1612
|
//#endregion
|
|
1611
1613
|
//#region src/v2/components/CopilotKitInspector.tsx
|
|
@@ -4653,7 +4655,7 @@ function useAgent({ agentId, threadId, runtimeAgentId, updates, throttleMs } = {
|
|
|
4653
4655
|
updateFlags
|
|
4654
4656
|
]);
|
|
4655
4657
|
useEffect(() => {
|
|
4656
|
-
if (agent
|
|
4658
|
+
if (ɵisHttpAgent(agent)) copilotkit.applyHeadersToAgent(agent);
|
|
4657
4659
|
if (agent instanceof ProxiedCopilotRuntimeAgent) agent.credentials = copilotkit.credentials;
|
|
4658
4660
|
}, [
|
|
4659
4661
|
agent,
|
|
@@ -4991,7 +4993,6 @@ function useInterrupt(config) {
|
|
|
4991
4993
|
pendingRef.current = pending;
|
|
4992
4994
|
const [handlerResult, setHandlerResult] = useState(null);
|
|
4993
4995
|
const interruptStateRef = useRef(new ɵInterruptState());
|
|
4994
|
-
const legacyRunIdRef = useRef(void 0);
|
|
4995
4996
|
useEffect(() => {
|
|
4996
4997
|
const interruptState = interruptStateRef.current;
|
|
4997
4998
|
let localLegacy = null;
|
|
@@ -5009,16 +5010,14 @@ function useInterrupt(config) {
|
|
|
5009
5010
|
onRunStartedEvent: () => {
|
|
5010
5011
|
localLegacy = null;
|
|
5011
5012
|
localStandard = null;
|
|
5012
|
-
legacyRunIdRef.current = void 0;
|
|
5013
5013
|
interruptState.clear();
|
|
5014
5014
|
setPending(null);
|
|
5015
5015
|
},
|
|
5016
|
-
onRunFinalized: (
|
|
5016
|
+
onRunFinalized: () => {
|
|
5017
5017
|
if (localStandard && localStandard.length > 0) {
|
|
5018
5018
|
interruptState.setStandard(localStandard);
|
|
5019
5019
|
setPending(interruptState.pending);
|
|
5020
5020
|
} else if (localLegacy) {
|
|
5021
|
-
legacyRunIdRef.current = params.input.runId;
|
|
5022
5021
|
interruptState.setLegacy(localLegacy);
|
|
5023
5022
|
setPending(interruptState.pending);
|
|
5024
5023
|
}
|
|
@@ -5028,7 +5027,6 @@ function useInterrupt(config) {
|
|
|
5028
5027
|
onRunFailed: () => {
|
|
5029
5028
|
localLegacy = null;
|
|
5030
5029
|
localStandard = null;
|
|
5031
|
-
legacyRunIdRef.current = void 0;
|
|
5032
5030
|
interruptState.clear();
|
|
5033
5031
|
setPending(null);
|
|
5034
5032
|
}
|
|
@@ -5043,22 +5041,18 @@ function useInterrupt(config) {
|
|
|
5043
5041
|
if (!current) return;
|
|
5044
5042
|
if (current.kind === "standard" && current.interrupts.length > 1 && interruptId === void 0) console.warn(`[CopilotKit] useInterrupt: resolve()/cancel() called without an interruptId while ${current.interrupts.length} interrupts are open; defaulting to the first. Pass an interruptId to address a specific interrupt.`);
|
|
5045
5043
|
const decision = interruptStateRef.current.resolve(payload, interruptId);
|
|
5046
|
-
if (decision.kind === "legacy-resume") {
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
|
|
5059
|
-
setPending(null);
|
|
5060
|
-
throw err;
|
|
5061
|
-
}
|
|
5044
|
+
if (decision.kind === "legacy-resume") try {
|
|
5045
|
+
return await copilotkit.runAgent({
|
|
5046
|
+
agent,
|
|
5047
|
+
forwardedProps: { command: {
|
|
5048
|
+
resume: decision.payload,
|
|
5049
|
+
interruptEvent: decision.interruptValue
|
|
5050
|
+
} }
|
|
5051
|
+
});
|
|
5052
|
+
} catch (err) {
|
|
5053
|
+
console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
|
|
5054
|
+
setPending(null);
|
|
5055
|
+
throw err;
|
|
5062
5056
|
}
|
|
5063
5057
|
if (decision.kind === "expired") {
|
|
5064
5058
|
console.error(`[CopilotKit] useInterrupt: interrupt ${decision.interrupt.id} expired at ${decision.interrupt.expiresAt}; not resuming.`);
|
|
@@ -8913,6 +8907,8 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
8913
8907
|
const hasNativeIntelligenceRunActivity = hasExplicitThreadId && runtimeStatus === "Connected" && !!copilotkit.intelligence?.wsUrl && copilotkit.threadEndpoints?.realtimeMetadata === true;
|
|
8914
8908
|
const [standaloneRunActivityStore] = useState(() => ɵcreateThreadStore({ fetch: copilotkit.ɵruntimeFetch }));
|
|
8915
8909
|
const previousThreadRef = useRef(null);
|
|
8910
|
+
const detachPromisesRef = useRef(/* @__PURE__ */ new WeakMap());
|
|
8911
|
+
const pendingTeardownRef = useRef(Promise.resolve());
|
|
8916
8912
|
const hasExplicitThreadIdRef = useRef(hasExplicitThreadId);
|
|
8917
8913
|
hasExplicitThreadIdRef.current = hasExplicitThreadId;
|
|
8918
8914
|
const rememberRecentlyLocalRunId = useCallback((runId) => {
|
|
@@ -8955,23 +8951,59 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
8955
8951
|
const previousThread = previousThreadRef.current;
|
|
8956
8952
|
const threadChanged = previousThread?.threadId !== resolvedThreadId;
|
|
8957
8953
|
const inspectorTransition = threadChanged && previousThread !== null && previousThread.inspectorRequestId !== inspectorRequestId && (previousThread.inspectorRequestId !== null || inspectorRequestId !== null);
|
|
8958
|
-
|
|
8954
|
+
const selection = {
|
|
8959
8955
|
threadId: resolvedThreadId,
|
|
8960
|
-
inspectorRequestId
|
|
8956
|
+
inspectorRequestId,
|
|
8957
|
+
agent
|
|
8961
8958
|
};
|
|
8959
|
+
previousThreadRef.current = selection;
|
|
8960
|
+
const discardedThreadId = previousThread?.agent === agent ? previousThread.threadId : agent.threadId;
|
|
8962
8961
|
if (inspectorTransition) if (typeof copilotkit.stopAgent === "function") copilotkit.stopAgent({ agent });
|
|
8963
8962
|
else agent.abortRun?.();
|
|
8964
8963
|
agent.threadId = resolvedThreadId;
|
|
8965
8964
|
if (!hasExplicitThreadId) {
|
|
8966
|
-
|
|
8967
|
-
|
|
8965
|
+
let active = true;
|
|
8966
|
+
if (threadChanged && previousThread !== null) {
|
|
8967
|
+
let resetPending = true;
|
|
8968
|
+
const clearCursor = () => {
|
|
8969
|
+
if ("clearReplayCursor" in agent && typeof agent.clearReplayCursor === "function") agent.clearReplayCursor(discardedThreadId);
|
|
8970
|
+
if ("clearReconnectCursor" in agent && typeof agent.clearReconnectCursor === "function") agent.clearReconnectCursor(discardedThreadId);
|
|
8971
|
+
};
|
|
8972
|
+
const clearDiscardedBaseline = () => {
|
|
8973
|
+
if (!active || !resetPending || previousThreadRef.current !== selection) return;
|
|
8974
|
+
agent.setMessages([]);
|
|
8975
|
+
agent.setState({});
|
|
8976
|
+
agent.pendingInterrupts = [];
|
|
8977
|
+
clearCursor();
|
|
8978
|
+
};
|
|
8979
|
+
if (previousThread.agent === agent) previousThread.clearDiscardedBaseline = clearDiscardedBaseline;
|
|
8980
|
+
const detach = detachPromisesRef.current.get(agent) ?? agent.detachActiveRun();
|
|
8981
|
+
detachPromisesRef.current.set(agent, detach);
|
|
8982
|
+
const finishReset = () => {
|
|
8983
|
+
if (!resetPending) return;
|
|
8984
|
+
clearCursor();
|
|
8985
|
+
clearDiscardedBaseline();
|
|
8986
|
+
resetPending = false;
|
|
8987
|
+
};
|
|
8988
|
+
clearDiscardedBaseline();
|
|
8989
|
+
pendingTeardownRef.current = Promise.all([pendingTeardownRef.current, detach]).then(finishReset).catch((error) => {
|
|
8990
|
+
console.error("CopilotChat: detachActiveRun failed", error);
|
|
8991
|
+
}).finally(() => {
|
|
8992
|
+
if (detachPromisesRef.current.get(agent) === detach) detachPromisesRef.current.delete(agent);
|
|
8993
|
+
});
|
|
8994
|
+
}
|
|
8995
|
+
return () => {
|
|
8996
|
+
active = false;
|
|
8997
|
+
};
|
|
8968
8998
|
}
|
|
8969
8999
|
let detached = false;
|
|
8970
9000
|
const connectAbortController = new AbortController();
|
|
8971
|
-
if (agent instanceof HttpAgent) agent.abortController = connectAbortController;
|
|
8972
9001
|
const connect = async (agentToConnect) => {
|
|
8973
9002
|
activeConnectCountRef.current += 1;
|
|
8974
9003
|
try {
|
|
9004
|
+
await pendingTeardownRef.current;
|
|
9005
|
+
if (detached) return;
|
|
9006
|
+
if (ɵisHttpAgent(agentToConnect)) agentToConnect.abortController = connectAbortController;
|
|
8975
9007
|
await copilotkit.connectAgent({ agent: agentToConnect });
|
|
8976
9008
|
} catch (error) {
|
|
8977
9009
|
if (detached) return;
|
|
@@ -8981,7 +9013,7 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
8981
9013
|
if (!detached) (typeof requestAnimationFrame === "function" ? requestAnimationFrame : (cb) => setTimeout(cb, 16))(() => {
|
|
8982
9014
|
if (!detached) setLastConnectedThreadId(resolvedThreadId);
|
|
8983
9015
|
});
|
|
8984
|
-
else if (!hasExplicitThreadIdRef.current)
|
|
9016
|
+
else if (!hasExplicitThreadIdRef.current) selection.clearDiscardedBaseline?.();
|
|
8985
9017
|
activeConnectCountRef.current = Math.max(0, activeConnectCountRef.current - 1);
|
|
8986
9018
|
if (!detached && activeConnectCountRef.current === 0) {
|
|
8987
9019
|
const startReconnect = startRunActivityReconnectRef.current;
|
|
@@ -8996,7 +9028,12 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
8996
9028
|
return () => {
|
|
8997
9029
|
detached = true;
|
|
8998
9030
|
connectAbortController.abort();
|
|
8999
|
-
agent.detachActiveRun().catch(() => {});
|
|
9031
|
+
const detach = agent.detachActiveRun().catch(() => {});
|
|
9032
|
+
detachPromisesRef.current.set(agent, detach);
|
|
9033
|
+
pendingTeardownRef.current = Promise.all([pendingTeardownRef.current, detach]).then(() => {});
|
|
9034
|
+
detach.then(() => {
|
|
9035
|
+
if (detachPromisesRef.current.get(agent) === detach) detachPromisesRef.current.delete(agent);
|
|
9036
|
+
});
|
|
9000
9037
|
};
|
|
9001
9038
|
}, [
|
|
9002
9039
|
resolvedThreadId,
|
|
@@ -12571,5 +12608,5 @@ function validateProps(props) {
|
|
|
12571
12608
|
}
|
|
12572
12609
|
|
|
12573
12610
|
//#endregion
|
|
12574
|
-
export { useAgentContext as $,
|
|
12575
|
-
//# sourceMappingURL=copilotkit-
|
|
12611
|
+
export { useAgentContext as $, ɵselectThreadsError$1 as $a, onInspectorActiveThread as $i, MultimodalOutputCapabilitiesSchema as $n, TextPartSchema as $r, BackwardCompatibility_0_0_45 as $t, CopilotChatMessageView as A, ɵjoinPhoenixChannel$ as Aa, createReducer as Ai, IdentityCapabilitiesSchema as An, StateDeltaEventSchema as Ar, CopilotChatInput_default as At, CopilotChatAssistantMessage_default as B, ɵphoenixChannel$ as Ba, enforceOutgoingInput as Bi, JsonPatchOperationSchema as Bn, SubagentFinishedSuspendedOutcomeSchema as Br, ActivityDeltaEventSchema as Bt, CopilotModalHeader as C, ɵTHREAD_REQUEST_TIMEOUT_MS as Ca, contentHasMedia as Ci, FileSourceSchema as Cn, RunFinishedEventSchema as Cr, useSandboxFunctions as Ct, CopilotChat as D, ɵisCopilotKitFeature as Da, createDebugLogger as Di, HttpAgent as Dn, RunHandler as Dr, ɵrunMcpFollowUp as Dt, DefaultOpenIcon as E, ɵcreateThreadStore$1 as Ea, createActionGroup as Ei, FunctionMiddleware as En, RunFinishedSuccessOutcomeSchema as Er, MCPAppsActivityType as Et, CopilotChatSuggestionView as F, ɵmemoryRestEvents as Fa, emitInspectorStopViewing as Fi, InputContentSchema as Fn, StepStartedEventSchema as Fr, ACTIVITY_HISTORY_METADATA as Ft, useLearnFromUserActionInCurrentThread as G, ɵselectIsMutating$1 as Ga, isInspectorThreadBridgeEnabled$1 as Gi, MessageSchema as Gn, SystemMessageSchema as Gr, AgentRegistry as Gt, useLearningContainersInCurrentThread as H, ɵselectFetchMoreError$1 as Ha, getRunOutcome as Hi, JsonPointerSchema as Hn, SubagentRunIdSchema as Hr, ActivitySnapshotEventSchema as Ht, CopilotChatSuggestionPill as I, ɵobservePhoenixEvent$ as Ia, emitInspectorViewThread as Ii, InputContentSourceSchema as In, SubagentErrorEventSchema as Ir, AGUIConnectNotImplementedError$1 as It, useThreads$1 as J, ɵselectMemoriesError$1 as Ja, isRunCompletionAware$1 as Ji, Middleware as Jn, TextMessageChunkEventSchema as Jr, AttributableSchema as Jt, useLearnFromUserAction as K, ɵselectMemories$1 as Ka, isInterruptExpired as Ki, MessagesSnapshotEventSchema as Kn, TestOperationSchema as Kr, AgentThreadLockedError as Kt, CopilotChatReasoningMessage_default as L, ɵobservePhoenixJoinOutcome$ as La, emitInspectorViewThreadResult$1 as Li, InputContentUrlSourceSchema as Ln, SubagentFinishedEventSchema as Lr, AGUIError as Lt, IntelligenceIndicator as M, ɵmemoryAdapterEvents as Ma, createStore as Mi, ImageInputPartSchema as Mn, StateSchema as Mr, CopilotChatAudioRecorder as Mt, getIntelligenceTurnAnchors as N, ɵmemoryDomainEvents as Na, defaultApplyEvents as Ni, ImagePartSchema as Nn, StateSnapshotEventSchema as Nr, CopilotChatConfigurationProvider as Nt, CopilotChatView_default as O, ɵisHttpAgent$1 as Oa, createEffect as Oi, HumanInTheLoopCapabilitiesSchema as On, RunStartedEventSchema as Or, CopilotKitInspector as Ot, IntelligenceIndicatorView as P, ɵmemoryReducer as Pa, emitInspectorActiveThread$1 as Pi, InputContentDataSourceSchema as Pn, StepFinishedEventSchema as Pr, useCopilotChatConfiguration as Pt, useSuggestions as Q, ɵselectThreads$1 as Qa, on as Qi, MultimodalInputCapabilitiesSchema as Qn, TextMessageStartEventSchema as Qr, BackwardCompatibility_0_0_39 as Qt, CopilotChatUserMessage_default as R, ɵobservePhoenixSocketHealth$ as Ra, empty as Ri, IntelligenceAgent as Rn, SubagentFinishedOutcomeSchema as Rr, AGUI_METADATA_KEY as Rt, CopilotSidebarView as S, ɵRUNTIME_PROBE_TIMEOUT_MS as Sa, completePartialMarkdown as Si, ExecutionCapabilitiesSchema as Sn, RunFinishedCancelledOutcomeSchema as Sr, SandboxFunctionsContext as St, DefaultCloseIcon as T, ɵcreateThreadSelectors as Ta, convertToLegacyEvents as Ti, FunctionCallSchema as Tn, RunFinishedOutcomeSchema as Tr, MCPAppsActivityRenderer as Tt, useLearningContainers as U, ɵselectHasNextPage$1 as Ua, getWebMCPModelContext as Ui, MEMORY_ERROR_REGISTRY as Un, SubagentStartedEventSchema as Ur, AddOperationSchema as Ut, CopilotChatToolCallsView as V, ɵphoenixSocket$ as Va, ensureObjectArgs as Vi, JsonPatchSchema as Vn, SubagentInfoSchema as Vr, ActivityMessageSchema as Vt, useAttachments as W, ɵselectIsFetchingNextPage$1 as Wa, isAbortError as Wi, MemoryError as Wn, SuggestionEngine as Wr, AgentCapabilitiesSchema as Wt, INTERRUPT_EVENT_NAME as X, ɵselectMemoriesIsMutating as Xa, ofType as Xi, MultiAgentCapabilitiesSchema as Xn, TextMessageEndEventSchema as Xr, AudioInputPartSchema as Xt, useInterrupt as Y, ɵselectMemoriesIsLoading$1 as Ya, mergeMetadata as Yi, MoveOperationSchema as Yn, TextMessageContentEventSchema as Yr, AudioInputContentSchema as Yt, useConfigureSuggestions as Z, ɵselectMemoriesRealtimeStatus$1 as Za, omitOptionalNulls as Zi, MultimodalCapabilitiesSchema as Zn, TextMessageRoleSchema as Zr, AudioPartSchema as Zt, WildcardToolCallRender as _, verifyEvents as _a, WebMCPRegistry as _i, DocumentPartSchema as _n, ReplaceOperationSchema as _r, GenerateSandboxedUiArgsSchema as _t, ThreadsProvider as a, parseToolArguments as aa, ToolCallSchema as ai, ContextSchema as an, RawEventSchema as ar, useRenderTool as at, CopilotSidebar as b, ɵInterruptState$1 as ba, buildResumeArray as bi, EventType as bn, RunAgentInputSchema as br, OpenGenerativeUIContentSchema as bt, CoAgentStateRendersProvider as c, resolveAgentDebugConfig as ca, ToolMessageSchema as ci, CopilotKitCoreErrorCode$1 as cn, ReasoningEncryptedValueSubtypeSchema as cr, useFrontendTool as ct, shouldShowDevConsole as d, select as da, TransportCapabilitiesSchema as di, CustomEventSchema as dn, ReasoningMessageContentEventSchema as dr, CopilotKitProvider as dt, onInspectorStopViewing$1 as ea, TokenUsageSchema as ei, BackwardCompatibility_0_0_57 as en, ɵselectThreadsIsLoading$1 as eo, OptionalMetadataSchema as er, useCapabilities as et, useToast as f, structuredClone_ as fa, UrlSourceSchema as fi, DataSourceSchema as fn, ReasoningMessageEndEventSchema as fr, useCopilotKit$1 as ft, useCopilotContext as g, transformHttpEventStream as ga, VideoPartSchema as gi, DocumentInputPartSchema as gn, RemoveOperationSchema as gr, createA2UIMessageRenderer as gt, CopilotContext as h, transformChunks as ha, VideoInputPartSchema as hi, DocumentInputContentSchema as hn, ReasoningStartEventSchema as hr, defineToolCallRenderer as ht, ThreadsContext as i, parseSSEStream as ia, ToolCallResultEventSchema as ii, ContentPartSchema as in, ProxiedCopilotRuntimeAgent$1 as ir, useDefaultRenderTool as it, INTELLIGENCE_TURN_HEAD as j, ɵmapMemoryMetadataEvent as ja, createSelector as ji, ImageInputContentSchema as jn, StateManager as jr, AudioRecorderError as jt, CopilotChatAttachmentQueue as k, ɵisRetryableMemoryStatus as ka, createInspectorThreadRequestId as ki, INSPECTOR_THREAD_BRIDGE_PLUGIN_ID as kn, StateCapabilitiesSchema as kr, useRenderToolCall as kt, useCoAgentStateRenders as l, resolveDebugLogger as la, ToolSchema as li, CopilotKitCoreRuntimeConnectionStatus$1 as ln, ReasoningEndEventSchema as lr, useRenderActivityMessage as lt, useCopilotMessagesContext as m, tokenUsageFromLangChainMetadata as ma, VideoInputContentSchema as mi, DeveloperMessageSchema as mn, ReasoningMessageStartEventSchema as mr, CopilotKitCoreReact as mt, defaultCopilotContextCategories as n, onInspectorViewThreadResult as na, ToolCallChunkEventSchema as ni, BaseMessageSchema as nn, PROTOCOL_VERSION as nr, useAgent as nt, useThreads as o, props as oa, ToolCallStartEventSchema as oi, ContextStore as on, ReasoningCapabilitiesSchema as or, useComponent as ot, CopilotMessagesContext as p, tokenUsageFromAiSdkUsage as pa, UserMessageSchema as pi, DebugLogger as pn, ReasoningMessageSchema as pr, useLicenseContext$1 as pt, useMemories as q, ɵselectMemoriesAvailable$1 as qa, isRecognizedEvent as qi, MetadataSchema as qn, TextInputContentSchema as qr, AssistantMessageSchema as qt, CoAgentStateRenderBridge as r, parseProtoStream as ra, ToolCallEndEventSchema as ri, CompatibilityBoundary as rn, PartSourceSchema as rr, useHumanInTheLoop as rt, CoAgentStateRendersContext as s, randomUUID$2 as sa, ToolCallStatus$1 as si, CopilotKitCore$1 as sn, ReasoningEncryptedValueEventSchema as sr, useFrontendTools as st, CopilotKit as t, onInspectorViewThread$1 as ta, ToolCallArgsEventSchema as ti, BaseEventSchema as tn, ɵthreadAdapterEvents as to, OutputCapabilitiesSchema as tr, UseAgentUpdate as tt, useAsyncCallback as u, runHttpRequest as ua, ToolsCapabilitiesSchema as ui, CopyOperationSchema as un, ReasoningMessageChunkEventSchema as ur, useRenderCustomMessages as ut, CopilotThreadsDrawer as v, withAuthoritativeActivityTypes as va, aggregateTokenUsage as vi, EventSchema as vn, ResumeEntrySchema as vr, OpenGenerativeUIActivityRenderer as vt, CopilotChatToggleButton as w, ɵcreateMemoryStore as wa, contentToText$1 as wi, FilterToolCallsMiddleware as wn, RunFinishedInterruptOutcomeSchema as wr, MCPAppsActivityContentSchema as wt, CopilotPopupView as x, ɵMAX_SOCKET_RETRIES as xa, compactEvents as xi, EventTypeSchema as xn, RunErrorEventSchema as xr, OpenGenerativeUIToolRenderer as xt, CopilotPopup as y, ɵCOPILOTKIT_FEATURES as ya, authoritativeActivityTypes as yi, EventSchemas as yn, RoleSchema as yr, OpenGenerativeUIActivityType as yt, CopilotChatAttachmentRenderer as z, ɵobservePhoenixSocketSignals$ as za, enforceEvents as zi, InterruptSchema as zn, SubagentFinishedSuccessOutcomeSchema as zr, AbstractAgent$1 as zt };
|
|
12612
|
+
//# sourceMappingURL=copilotkit-LD7Gp2aV.mjs.map
|