@copilotkit/react-core 1.75.1 → 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-DfsHZUuo.mjs → copilotkit-LD7Gp2aV.mjs} +75 -49
- 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-DIudpHkM.cjs → copilotkit-dHdNF7H5.cjs} +71 -46
- 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 +24 -43
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +20 -38
- 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 +21 -39
- 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 +373 -169
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +10 -10
- package/dist/copilotkit-CGlSOKHM.d.mts.map +0 -1
- package/dist/copilotkit-Cjj9wDI8.d.cts.map +0 -1
- package/dist/copilotkit-DIudpHkM.cjs.map +0 -1
- package/dist/copilotkit-DfsHZUuo.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,8 +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 interruptRunIdsRef = useRef(/* @__PURE__ */ new Map());
|
|
4995
|
-
const legacyRunIdRef = useRef(void 0);
|
|
4996
4996
|
useEffect(() => {
|
|
4997
4997
|
const interruptState = interruptStateRef.current;
|
|
4998
4998
|
let localLegacy = null;
|
|
@@ -5005,26 +5005,19 @@ function useInterrupt(config) {
|
|
|
5005
5005
|
};
|
|
5006
5006
|
},
|
|
5007
5007
|
onRunFinishedEvent: (params) => {
|
|
5008
|
-
if (params.outcome === "interrupt")
|
|
5009
|
-
const runId = params.input.runId;
|
|
5010
|
-
for (const interrupt of params.interrupts) interruptRunIdsRef.current.set(interrupt.id, runId);
|
|
5011
|
-
localStandard = params.interrupts;
|
|
5012
|
-
}
|
|
5008
|
+
if (params.outcome === "interrupt") localStandard = params.interrupts;
|
|
5013
5009
|
},
|
|
5014
5010
|
onRunStartedEvent: () => {
|
|
5015
5011
|
localLegacy = null;
|
|
5016
5012
|
localStandard = null;
|
|
5017
|
-
interruptRunIdsRef.current.clear();
|
|
5018
|
-
legacyRunIdRef.current = void 0;
|
|
5019
5013
|
interruptState.clear();
|
|
5020
5014
|
setPending(null);
|
|
5021
5015
|
},
|
|
5022
|
-
onRunFinalized: (
|
|
5016
|
+
onRunFinalized: () => {
|
|
5023
5017
|
if (localStandard && localStandard.length > 0) {
|
|
5024
5018
|
interruptState.setStandard(localStandard);
|
|
5025
5019
|
setPending(interruptState.pending);
|
|
5026
5020
|
} else if (localLegacy) {
|
|
5027
|
-
legacyRunIdRef.current = params.input.runId;
|
|
5028
5021
|
interruptState.setLegacy(localLegacy);
|
|
5029
5022
|
setPending(interruptState.pending);
|
|
5030
5023
|
}
|
|
@@ -5034,8 +5027,6 @@ function useInterrupt(config) {
|
|
|
5034
5027
|
onRunFailed: () => {
|
|
5035
5028
|
localLegacy = null;
|
|
5036
5029
|
localStandard = null;
|
|
5037
|
-
interruptRunIdsRef.current.clear();
|
|
5038
|
-
legacyRunIdRef.current = void 0;
|
|
5039
5030
|
interruptState.clear();
|
|
5040
5031
|
setPending(null);
|
|
5041
5032
|
}
|
|
@@ -5050,22 +5041,18 @@ function useInterrupt(config) {
|
|
|
5050
5041
|
if (!current) return;
|
|
5051
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.`);
|
|
5052
5043
|
const decision = interruptStateRef.current.resolve(payload, interruptId);
|
|
5053
|
-
if (decision.kind === "legacy-resume") {
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
|
|
5066
|
-
setPending(null);
|
|
5067
|
-
throw err;
|
|
5068
|
-
}
|
|
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;
|
|
5069
5056
|
}
|
|
5070
5057
|
if (decision.kind === "expired") {
|
|
5071
5058
|
console.error(`[CopilotKit] useInterrupt: interrupt ${decision.interrupt.id} expired at ${decision.interrupt.expiresAt}; not resuming.`);
|
|
@@ -5074,7 +5061,6 @@ function useInterrupt(config) {
|
|
|
5074
5061
|
return;
|
|
5075
5062
|
}
|
|
5076
5063
|
if (decision.kind !== "resume") return;
|
|
5077
|
-
const runId = decision.resume.map((entry) => interruptRunIdsRef.current.get(entry.interruptId)).find((candidate) => candidate !== void 0);
|
|
5078
5064
|
for (const toolResult of decision.toolResults) agent.addMessage({
|
|
5079
5065
|
id: randomUUID(),
|
|
5080
5066
|
role: "tool",
|
|
@@ -5084,8 +5070,7 @@ function useInterrupt(config) {
|
|
|
5084
5070
|
try {
|
|
5085
5071
|
return await copilotkit.runAgent({
|
|
5086
5072
|
agent,
|
|
5087
|
-
resume: decision.resume
|
|
5088
|
-
...runId !== void 0 ? { runId } : {}
|
|
5073
|
+
resume: decision.resume
|
|
5089
5074
|
});
|
|
5090
5075
|
} catch (err) {
|
|
5091
5076
|
console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
|
|
@@ -5112,7 +5097,6 @@ function useInterrupt(config) {
|
|
|
5112
5097
|
return;
|
|
5113
5098
|
}
|
|
5114
5099
|
if (decision.kind !== "resume") return;
|
|
5115
|
-
const runId = decision.resume.map((entry) => interruptRunIdsRef.current.get(entry.interruptId)).find((candidate) => candidate !== void 0);
|
|
5116
5100
|
for (const toolResult of decision.toolResults) agent.addMessage({
|
|
5117
5101
|
id: randomUUID(),
|
|
5118
5102
|
role: "tool",
|
|
@@ -5122,8 +5106,7 @@ function useInterrupt(config) {
|
|
|
5122
5106
|
try {
|
|
5123
5107
|
return await copilotkit.runAgent({
|
|
5124
5108
|
agent,
|
|
5125
|
-
resume: decision.resume
|
|
5126
|
-
...runId !== void 0 ? { runId } : {}
|
|
5109
|
+
resume: decision.resume
|
|
5127
5110
|
});
|
|
5128
5111
|
} catch (err) {
|
|
5129
5112
|
console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
|
|
@@ -8924,6 +8907,8 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
8924
8907
|
const hasNativeIntelligenceRunActivity = hasExplicitThreadId && runtimeStatus === "Connected" && !!copilotkit.intelligence?.wsUrl && copilotkit.threadEndpoints?.realtimeMetadata === true;
|
|
8925
8908
|
const [standaloneRunActivityStore] = useState(() => ɵcreateThreadStore({ fetch: copilotkit.ɵruntimeFetch }));
|
|
8926
8909
|
const previousThreadRef = useRef(null);
|
|
8910
|
+
const detachPromisesRef = useRef(/* @__PURE__ */ new WeakMap());
|
|
8911
|
+
const pendingTeardownRef = useRef(Promise.resolve());
|
|
8927
8912
|
const hasExplicitThreadIdRef = useRef(hasExplicitThreadId);
|
|
8928
8913
|
hasExplicitThreadIdRef.current = hasExplicitThreadId;
|
|
8929
8914
|
const rememberRecentlyLocalRunId = useCallback((runId) => {
|
|
@@ -8966,23 +8951,59 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
8966
8951
|
const previousThread = previousThreadRef.current;
|
|
8967
8952
|
const threadChanged = previousThread?.threadId !== resolvedThreadId;
|
|
8968
8953
|
const inspectorTransition = threadChanged && previousThread !== null && previousThread.inspectorRequestId !== inspectorRequestId && (previousThread.inspectorRequestId !== null || inspectorRequestId !== null);
|
|
8969
|
-
|
|
8954
|
+
const selection = {
|
|
8970
8955
|
threadId: resolvedThreadId,
|
|
8971
|
-
inspectorRequestId
|
|
8956
|
+
inspectorRequestId,
|
|
8957
|
+
agent
|
|
8972
8958
|
};
|
|
8959
|
+
previousThreadRef.current = selection;
|
|
8960
|
+
const discardedThreadId = previousThread?.agent === agent ? previousThread.threadId : agent.threadId;
|
|
8973
8961
|
if (inspectorTransition) if (typeof copilotkit.stopAgent === "function") copilotkit.stopAgent({ agent });
|
|
8974
8962
|
else agent.abortRun?.();
|
|
8975
8963
|
agent.threadId = resolvedThreadId;
|
|
8976
8964
|
if (!hasExplicitThreadId) {
|
|
8977
|
-
|
|
8978
|
-
|
|
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
|
+
};
|
|
8979
8998
|
}
|
|
8980
8999
|
let detached = false;
|
|
8981
9000
|
const connectAbortController = new AbortController();
|
|
8982
|
-
if (agent instanceof HttpAgent) agent.abortController = connectAbortController;
|
|
8983
9001
|
const connect = async (agentToConnect) => {
|
|
8984
9002
|
activeConnectCountRef.current += 1;
|
|
8985
9003
|
try {
|
|
9004
|
+
await pendingTeardownRef.current;
|
|
9005
|
+
if (detached) return;
|
|
9006
|
+
if (ɵisHttpAgent(agentToConnect)) agentToConnect.abortController = connectAbortController;
|
|
8986
9007
|
await copilotkit.connectAgent({ agent: agentToConnect });
|
|
8987
9008
|
} catch (error) {
|
|
8988
9009
|
if (detached) return;
|
|
@@ -8992,7 +9013,7 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
8992
9013
|
if (!detached) (typeof requestAnimationFrame === "function" ? requestAnimationFrame : (cb) => setTimeout(cb, 16))(() => {
|
|
8993
9014
|
if (!detached) setLastConnectedThreadId(resolvedThreadId);
|
|
8994
9015
|
});
|
|
8995
|
-
else if (!hasExplicitThreadIdRef.current)
|
|
9016
|
+
else if (!hasExplicitThreadIdRef.current) selection.clearDiscardedBaseline?.();
|
|
8996
9017
|
activeConnectCountRef.current = Math.max(0, activeConnectCountRef.current - 1);
|
|
8997
9018
|
if (!detached && activeConnectCountRef.current === 0) {
|
|
8998
9019
|
const startReconnect = startRunActivityReconnectRef.current;
|
|
@@ -9007,7 +9028,12 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
9007
9028
|
return () => {
|
|
9008
9029
|
detached = true;
|
|
9009
9030
|
connectAbortController.abort();
|
|
9010
|
-
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
|
+
});
|
|
9011
9037
|
};
|
|
9012
9038
|
}, [
|
|
9013
9039
|
resolvedThreadId,
|
|
@@ -12582,5 +12608,5 @@ function validateProps(props) {
|
|
|
12582
12608
|
}
|
|
12583
12609
|
|
|
12584
12610
|
//#endregion
|
|
12585
|
-
export { useAgentContext as $,
|
|
12586
|
-
//# 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
|