@copilotkit/react-core 1.62.0 → 1.62.2-canary.1783457132
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-BtRkFsNR.mjs → copilotkit-BQT2ngSh.mjs} +286 -10
- package/dist/copilotkit-BQT2ngSh.mjs.map +1 -0
- package/dist/{copilotkit-Cga6AHO0.d.cts → copilotkit-BnaWY11A.d.cts} +115 -3
- package/dist/copilotkit-BnaWY11A.d.cts.map +1 -0
- package/dist/{copilotkit-DnLpJ2Cl.d.mts → copilotkit-BpR0k6_Z.d.mts} +115 -3
- package/dist/copilotkit-BpR0k6_Z.d.mts.map +1 -0
- package/dist/{copilotkit-CdpDZi3i.cjs → copilotkit-Ces-OkSR.cjs} +290 -8
- package/dist/copilotkit-Ces-OkSR.cjs.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 +4 -3
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/index.cjs +2 -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 -7
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +7 -7
- package/dist/copilotkit-BtRkFsNR.mjs.map +0 -1
- package/dist/copilotkit-CdpDZi3i.cjs.map +0 -1
- package/dist/copilotkit-Cga6AHO0.d.cts.map +0 -1
- package/dist/copilotkit-DnLpJ2Cl.d.mts.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React$1 from "react";
|
|
2
2
|
import React, { createContext, forwardRef, memo, useCallback, useContext, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
|
|
3
|
-
import { CopilotKitCore, CopilotKitCoreRuntimeConnectionStatus, ProxiedCopilotRuntimeAgent, ToolCallStatus, isRunCompletionAware, ɵcreateThreadStore, ɵselectHasNextPage, ɵselectIsFetchingNextPage, ɵselectIsMutating, ɵselectThreads, ɵselectThreadsError, ɵselectThreadsIsLoading } from "@copilotkit/core";
|
|
3
|
+
import { CopilotKitCore, CopilotKitCoreRuntimeConnectionStatus, ProxiedCopilotRuntimeAgent, ToolCallStatus, isRunCompletionAware, ɵcreateThreadStore, ɵselectHasNextPage, ɵselectIsFetchingNextPage, ɵselectIsMutating, ɵselectMemories, ɵselectMemoriesAvailable, ɵselectMemoriesError, ɵselectMemoriesIsLoading, ɵselectMemoriesRealtimeStatus, ɵselectThreads, ɵselectThreadsError, ɵselectThreadsIsLoading } from "@copilotkit/core";
|
|
4
4
|
import { HttpAgent, buildResumeArray, isInterruptExpired, randomUUID } from "@ag-ui/client";
|
|
5
5
|
import { extendTailwindMerge, twMerge } from "tailwind-merge";
|
|
6
6
|
import { ArrowUp, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronRightIcon, Copy, Edit, Loader2, MessageCircle, Mic, PanelLeftOpen, Play, Plus, RefreshCw, Square, ThumbsDown, ThumbsUp, Upload, Volume2, X } from "lucide-react";
|
|
@@ -3620,12 +3620,13 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3620
3620
|
}
|
|
3621
3621
|
const copilotkit = copilotkitRef.current;
|
|
3622
3622
|
useEffect(() => {
|
|
3623
|
-
|
|
3624
|
-
const subscription = copilotkit.subscribe({ onRuntimeConnectionStatusChanged: () => {
|
|
3623
|
+
const syncRuntimeInfo = () => {
|
|
3625
3624
|
setRuntimeA2UIEnabled(copilotkit.a2uiEnabled);
|
|
3626
3625
|
setRuntimeOpenGenUIEnabled(copilotkit.openGenerativeUIEnabled);
|
|
3627
3626
|
setRuntimeLicenseStatus(copilotkit.licenseStatus);
|
|
3628
|
-
}
|
|
3627
|
+
};
|
|
3628
|
+
const subscription = copilotkit.subscribe({ onRuntimeConnectionStatusChanged: syncRuntimeInfo });
|
|
3629
|
+
syncRuntimeInfo();
|
|
3629
3630
|
return () => {
|
|
3630
3631
|
subscription.unsubscribe();
|
|
3631
3632
|
};
|
|
@@ -5163,6 +5164,70 @@ function useThreads$1({ agentId, includeArchived, limit, enabled = true }) {
|
|
|
5163
5164
|
};
|
|
5164
5165
|
}
|
|
5165
5166
|
|
|
5167
|
+
//#endregion
|
|
5168
|
+
//#region src/v2/hooks/use-memories.tsx
|
|
5169
|
+
function useMemoryStoreSelector(store, selector) {
|
|
5170
|
+
return useSyncExternalStore(useCallback((onStoreChange) => {
|
|
5171
|
+
const subscription = store.select(selector).subscribe(onStoreChange);
|
|
5172
|
+
return () => subscription.unsubscribe();
|
|
5173
|
+
}, [store, selector]), () => selector(store.getState()), () => selector(store.getServerState()));
|
|
5174
|
+
}
|
|
5175
|
+
/**
|
|
5176
|
+
* React hook for listing and managing platform memories.
|
|
5177
|
+
*
|
|
5178
|
+
* Reads the memory store owned and wired by `CopilotKitCore`. On mount the
|
|
5179
|
+
* hook exposes the live list plus stable `addMemory` / `updateMemory` /
|
|
5180
|
+
* `removeMemory` / `refresh` callbacks. Mutations are server-authoritative:
|
|
5181
|
+
* each resolves once the platform confirms the operation and rejects with an
|
|
5182
|
+
* `Error` on failure.
|
|
5183
|
+
*
|
|
5184
|
+
* Realtime updates are automatic: the core's memory store opens its own
|
|
5185
|
+
* `user_meta:memories:<joinCode>` channel and applies `memory_metadata` deltas
|
|
5186
|
+
* to the list. You can still call `refresh()` to re-pull the REST snapshot on
|
|
5187
|
+
* demand.
|
|
5188
|
+
*
|
|
5189
|
+
* @returns Memory list state and stable mutation callbacks.
|
|
5190
|
+
*
|
|
5191
|
+
* @example
|
|
5192
|
+
* ```tsx
|
|
5193
|
+
* import { useMemories } from "@copilotkit/react-core";
|
|
5194
|
+
*
|
|
5195
|
+
* function MemoryList() {
|
|
5196
|
+
* const { memories, isLoading, isAvailable, addMemory, removeMemory } =
|
|
5197
|
+
* useMemories();
|
|
5198
|
+
*
|
|
5199
|
+
* if (!isAvailable) return null;
|
|
5200
|
+
* if (isLoading) return <p>Loading…</p>;
|
|
5201
|
+
*
|
|
5202
|
+
* return (
|
|
5203
|
+
* <ul>
|
|
5204
|
+
* {memories.map((m) => (
|
|
5205
|
+
* <li key={m.id}>
|
|
5206
|
+
* {m.content}
|
|
5207
|
+
* <button onClick={() => removeMemory(m.id)}>Delete</button>
|
|
5208
|
+
* </li>
|
|
5209
|
+
* ))}
|
|
5210
|
+
* </ul>
|
|
5211
|
+
* );
|
|
5212
|
+
* }
|
|
5213
|
+
* ```
|
|
5214
|
+
*/
|
|
5215
|
+
function useMemories() {
|
|
5216
|
+
const { copilotkit } = useCopilotKit();
|
|
5217
|
+
const store = copilotkit.getMemoryStore();
|
|
5218
|
+
return {
|
|
5219
|
+
memories: useMemoryStoreSelector(store, ɵselectMemories),
|
|
5220
|
+
isLoading: useMemoryStoreSelector(store, ɵselectMemoriesIsLoading),
|
|
5221
|
+
error: useMemoryStoreSelector(store, ɵselectMemoriesError),
|
|
5222
|
+
isAvailable: useMemoryStoreSelector(store, ɵselectMemoriesAvailable),
|
|
5223
|
+
realtimeStatus: useMemoryStoreSelector(store, ɵselectMemoriesRealtimeStatus),
|
|
5224
|
+
refresh: useCallback(() => store.refresh(), [store]),
|
|
5225
|
+
addMemory: useCallback((input) => store.addMemory(input), [store]),
|
|
5226
|
+
updateMemory: useCallback((id, changes) => store.updateMemory(id, changes), [store]),
|
|
5227
|
+
removeMemory: useCallback((id) => store.removeMemory(id), [store])
|
|
5228
|
+
};
|
|
5229
|
+
}
|
|
5230
|
+
|
|
5166
5231
|
//#endregion
|
|
5167
5232
|
//#region src/v2/lib/record-annotation.ts
|
|
5168
5233
|
/**
|
|
@@ -7925,9 +7990,57 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
7925
7990
|
const { messageView: providedMessageView, suggestionView: providedSuggestionView, onStop: providedStopHandler, ...restProps } = props;
|
|
7926
7991
|
const [lastConnectedThreadId, setLastConnectedThreadId] = useState(null);
|
|
7927
7992
|
const isConnecting = hasExplicitThreadId && lastConnectedThreadId !== resolvedThreadId;
|
|
7993
|
+
const activeConnectCountRef = useRef(0);
|
|
7994
|
+
const pendingRunActivityReconnectRef = useRef(false);
|
|
7995
|
+
const runActivityReconnectGenerationRef = useRef(0);
|
|
7996
|
+
const activeLocalRunIdsRef = useRef(/* @__PURE__ */ new Set());
|
|
7997
|
+
const recentlyLocalRunIdsRef = useRef(/* @__PURE__ */ new Map());
|
|
7998
|
+
const activeWakeRunIdsRef = useRef(/* @__PURE__ */ new Set());
|
|
7999
|
+
const recentlyWakeRunIdsRef = useRef(/* @__PURE__ */ new Map());
|
|
8000
|
+
const pendingWakeRunIdRef = useRef(void 0);
|
|
8001
|
+
const startRunActivityReconnectRef = useRef(null);
|
|
8002
|
+
const runtimeStatus = copilotkit.runtimeConnectionStatus === CopilotKitCoreRuntimeConnectionStatus.Connected ? "Connected" : copilotkit.runtimeConnectionStatus;
|
|
8003
|
+
const hasNativeIntelligenceRunActivity = hasExplicitThreadId && runtimeStatus === "Connected" && !!copilotkit.intelligence?.wsUrl && copilotkit.threadEndpoints?.realtimeMetadata === true;
|
|
8004
|
+
const [standaloneRunActivityStore] = useState(() => ɵcreateThreadStore({ fetch: globalThis.fetch }));
|
|
7928
8005
|
const previousThreadIdRef = useRef(null);
|
|
7929
8006
|
const hasExplicitThreadIdRef = useRef(hasExplicitThreadId);
|
|
7930
8007
|
hasExplicitThreadIdRef.current = hasExplicitThreadId;
|
|
8008
|
+
const rememberRecentlyLocalRunId = useCallback((runId) => {
|
|
8009
|
+
const existingTimeout = recentlyLocalRunIdsRef.current.get(runId);
|
|
8010
|
+
if (existingTimeout) clearTimeout(existingTimeout);
|
|
8011
|
+
const timeout = setTimeout(() => {
|
|
8012
|
+
recentlyLocalRunIdsRef.current.delete(runId);
|
|
8013
|
+
}, 3e4);
|
|
8014
|
+
recentlyLocalRunIdsRef.current.set(runId, timeout);
|
|
8015
|
+
}, []);
|
|
8016
|
+
const rememberRecentlyWakeRunId = useCallback((runId) => {
|
|
8017
|
+
const existingTimeout = recentlyWakeRunIdsRef.current.get(runId);
|
|
8018
|
+
if (existingTimeout) clearTimeout(existingTimeout);
|
|
8019
|
+
const timeout = setTimeout(() => {
|
|
8020
|
+
recentlyWakeRunIdsRef.current.delete(runId);
|
|
8021
|
+
}, 3e4);
|
|
8022
|
+
recentlyWakeRunIdsRef.current.set(runId, timeout);
|
|
8023
|
+
}, []);
|
|
8024
|
+
const isLocalActiveRunActivity = useCallback((notification) => {
|
|
8025
|
+
if (notification.agentId && notification.agentId !== resolvedAgentId) return false;
|
|
8026
|
+
if (!notification.runId || !activeLocalRunIdsRef.current.has(notification.runId) && !recentlyLocalRunIdsRef.current.has(notification.runId)) return false;
|
|
8027
|
+
const eventType = notification.eventType.toUpperCase();
|
|
8028
|
+
return eventType === "RUN_STARTED" || eventType === "RUN_FINISHED" || eventType === "RUN_ERROR";
|
|
8029
|
+
}, [resolvedAgentId]);
|
|
8030
|
+
useEffect(() => {
|
|
8031
|
+
const recentlyLocalRunIds = recentlyLocalRunIdsRef.current;
|
|
8032
|
+
const recentlyWakeRunIds = recentlyWakeRunIdsRef.current;
|
|
8033
|
+
return () => {
|
|
8034
|
+
recentlyLocalRunIds.forEach((timeout) => {
|
|
8035
|
+
clearTimeout(timeout);
|
|
8036
|
+
});
|
|
8037
|
+
recentlyLocalRunIds.clear();
|
|
8038
|
+
recentlyWakeRunIds.forEach((timeout) => {
|
|
8039
|
+
clearTimeout(timeout);
|
|
8040
|
+
});
|
|
8041
|
+
recentlyWakeRunIds.clear();
|
|
8042
|
+
};
|
|
8043
|
+
}, []);
|
|
7931
8044
|
useEffect(() => {
|
|
7932
8045
|
const threadChanged = previousThreadIdRef.current !== resolvedThreadId;
|
|
7933
8046
|
previousThreadIdRef.current = resolvedThreadId;
|
|
@@ -7940,6 +8053,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
7940
8053
|
const connectAbortController = new AbortController();
|
|
7941
8054
|
if (agent instanceof HttpAgent) agent.abortController = connectAbortController;
|
|
7942
8055
|
const connect = async (agentToConnect) => {
|
|
8056
|
+
activeConnectCountRef.current += 1;
|
|
7943
8057
|
try {
|
|
7944
8058
|
await copilotkit.connectAgent({ agent: agentToConnect });
|
|
7945
8059
|
} catch (error) {
|
|
@@ -7950,6 +8064,14 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
7950
8064
|
if (!detached) setLastConnectedThreadId(resolvedThreadId);
|
|
7951
8065
|
});
|
|
7952
8066
|
else if (!hasExplicitThreadIdRef.current) agentToConnect.setMessages([]);
|
|
8067
|
+
activeConnectCountRef.current = Math.max(0, activeConnectCountRef.current - 1);
|
|
8068
|
+
if (!detached && activeConnectCountRef.current === 0) {
|
|
8069
|
+
const startReconnect = startRunActivityReconnectRef.current;
|
|
8070
|
+
if (pendingRunActivityReconnectRef.current && startReconnect) {
|
|
8071
|
+
pendingRunActivityReconnectRef.current = false;
|
|
8072
|
+
startReconnect(runActivityReconnectGenerationRef.current);
|
|
8073
|
+
}
|
|
8074
|
+
}
|
|
7953
8075
|
}
|
|
7954
8076
|
};
|
|
7955
8077
|
connect(agent);
|
|
@@ -7964,6 +8086,119 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
7964
8086
|
resolvedAgentId,
|
|
7965
8087
|
hasExplicitThreadId
|
|
7966
8088
|
]);
|
|
8089
|
+
useEffect(() => {
|
|
8090
|
+
if (!hasNativeIntelligenceRunActivity) return;
|
|
8091
|
+
const registeredThreadStore = copilotkit.getThreadStore(resolvedAgentId);
|
|
8092
|
+
const threadStore = registeredThreadStore ?? standaloneRunActivityStore;
|
|
8093
|
+
if (!threadStore?.subscribeToRunActivity) return;
|
|
8094
|
+
const ownsStandaloneStore = registeredThreadStore === void 0;
|
|
8095
|
+
if (ownsStandaloneStore) {
|
|
8096
|
+
threadStore.start();
|
|
8097
|
+
const context = copilotkit.runtimeUrl ? {
|
|
8098
|
+
runtimeUrl: copilotkit.runtimeUrl,
|
|
8099
|
+
headers: { ...copilotkit.headers },
|
|
8100
|
+
wsUrl: copilotkit.intelligence?.wsUrl,
|
|
8101
|
+
agentId: resolvedAgentId
|
|
8102
|
+
} : null;
|
|
8103
|
+
threadStore.setContext(context);
|
|
8104
|
+
}
|
|
8105
|
+
const generation = runActivityReconnectGenerationRef.current + 1;
|
|
8106
|
+
runActivityReconnectGenerationRef.current = generation;
|
|
8107
|
+
let detached = false;
|
|
8108
|
+
let wakeReconnectActive = false;
|
|
8109
|
+
let pendingAgentIdleDrain = null;
|
|
8110
|
+
const hasActiveAgentRun = () => activeLocalRunIdsRef.current.size > 0 || agent.isRunning;
|
|
8111
|
+
const scheduleAgentIdleDrain = () => {
|
|
8112
|
+
if (pendingAgentIdleDrain !== null) return;
|
|
8113
|
+
pendingAgentIdleDrain = setTimeout(() => {
|
|
8114
|
+
pendingAgentIdleDrain = null;
|
|
8115
|
+
if (detached || runActivityReconnectGenerationRef.current !== generation || !pendingRunActivityReconnectRef.current) return;
|
|
8116
|
+
if (hasActiveAgentRun()) {
|
|
8117
|
+
scheduleAgentIdleDrain();
|
|
8118
|
+
return;
|
|
8119
|
+
}
|
|
8120
|
+
startRunActivityReconnectRef.current?.(generation);
|
|
8121
|
+
}, 10);
|
|
8122
|
+
};
|
|
8123
|
+
const connect = async () => {
|
|
8124
|
+
activeConnectCountRef.current += 1;
|
|
8125
|
+
wakeReconnectActive = true;
|
|
8126
|
+
const wakeRunId = pendingWakeRunIdRef.current;
|
|
8127
|
+
pendingWakeRunIdRef.current = void 0;
|
|
8128
|
+
if (wakeRunId) activeWakeRunIdsRef.current.add(wakeRunId);
|
|
8129
|
+
let didConnect = false;
|
|
8130
|
+
try {
|
|
8131
|
+
await copilotkit.connectAgent({ agent });
|
|
8132
|
+
didConnect = true;
|
|
8133
|
+
} catch (error) {
|
|
8134
|
+
if (!detached) console.error("CopilotChat: run activity reconnect failed", error);
|
|
8135
|
+
} finally {
|
|
8136
|
+
if (wakeRunId) {
|
|
8137
|
+
activeWakeRunIdsRef.current.delete(wakeRunId);
|
|
8138
|
+
if (didConnect) rememberRecentlyWakeRunId(wakeRunId);
|
|
8139
|
+
}
|
|
8140
|
+
activeConnectCountRef.current = Math.max(0, activeConnectCountRef.current - 1);
|
|
8141
|
+
wakeReconnectActive = false;
|
|
8142
|
+
if (!detached && runActivityReconnectGenerationRef.current === generation && activeConnectCountRef.current === 0 && pendingRunActivityReconnectRef.current) {
|
|
8143
|
+
pendingRunActivityReconnectRef.current = false;
|
|
8144
|
+
connect();
|
|
8145
|
+
}
|
|
8146
|
+
}
|
|
8147
|
+
};
|
|
8148
|
+
startRunActivityReconnectRef.current = (requestedGeneration) => {
|
|
8149
|
+
if (detached || requestedGeneration !== generation || runActivityReconnectGenerationRef.current !== generation) return;
|
|
8150
|
+
if (hasActiveAgentRun()) {
|
|
8151
|
+
pendingRunActivityReconnectRef.current = true;
|
|
8152
|
+
scheduleAgentIdleDrain();
|
|
8153
|
+
return;
|
|
8154
|
+
}
|
|
8155
|
+
if (activeConnectCountRef.current > 0) {
|
|
8156
|
+
if (!wakeReconnectActive) pendingRunActivityReconnectRef.current = true;
|
|
8157
|
+
return;
|
|
8158
|
+
}
|
|
8159
|
+
pendingRunActivityReconnectRef.current = false;
|
|
8160
|
+
connect();
|
|
8161
|
+
};
|
|
8162
|
+
const subscription = threadStore.subscribeToRunActivity((notification) => {
|
|
8163
|
+
if (notification.threadId !== resolvedThreadId) return;
|
|
8164
|
+
if (notification.agentId && notification.agentId !== resolvedAgentId) return;
|
|
8165
|
+
if (isLocalActiveRunActivity(notification)) return;
|
|
8166
|
+
if (notification.runId && (activeWakeRunIdsRef.current.has(notification.runId) || recentlyWakeRunIdsRef.current.has(notification.runId))) return;
|
|
8167
|
+
pendingWakeRunIdRef.current = notification.runId;
|
|
8168
|
+
startRunActivityReconnectRef.current?.(generation);
|
|
8169
|
+
});
|
|
8170
|
+
return () => {
|
|
8171
|
+
detached = true;
|
|
8172
|
+
pendingRunActivityReconnectRef.current = false;
|
|
8173
|
+
pendingWakeRunIdRef.current = void 0;
|
|
8174
|
+
if (pendingAgentIdleDrain !== null) {
|
|
8175
|
+
clearTimeout(pendingAgentIdleDrain);
|
|
8176
|
+
pendingAgentIdleDrain = null;
|
|
8177
|
+
}
|
|
8178
|
+
if (startRunActivityReconnectRef.current) startRunActivityReconnectRef.current = null;
|
|
8179
|
+
if (wakeReconnectActive) agent.detachActiveRun().catch(() => {});
|
|
8180
|
+
activeWakeRunIdsRef.current.clear();
|
|
8181
|
+
subscription.unsubscribe();
|
|
8182
|
+
if (ownsStandaloneStore) {
|
|
8183
|
+
threadStore.setContext(null);
|
|
8184
|
+
threadStore.stop();
|
|
8185
|
+
}
|
|
8186
|
+
};
|
|
8187
|
+
}, [
|
|
8188
|
+
agent,
|
|
8189
|
+
resolvedAgentId,
|
|
8190
|
+
resolvedThreadId,
|
|
8191
|
+
hasExplicitThreadId,
|
|
8192
|
+
hasNativeIntelligenceRunActivity,
|
|
8193
|
+
copilotkit.runtimeConnectionStatus,
|
|
8194
|
+
copilotkit.runtimeUrl,
|
|
8195
|
+
copilotkit.headers,
|
|
8196
|
+
copilotkit.intelligence?.wsUrl,
|
|
8197
|
+
copilotkit.threadEndpoints?.realtimeMetadata,
|
|
8198
|
+
standaloneRunActivityStore,
|
|
8199
|
+
isLocalActiveRunActivity,
|
|
8200
|
+
rememberRecentlyWakeRunId
|
|
8201
|
+
]);
|
|
7967
8202
|
const waitForActiveRunToSettle = useCallback(async () => {
|
|
7968
8203
|
const maybeAware = agent;
|
|
7969
8204
|
const activeRunCompletionPromise = isRunCompletionAware(maybeAware) ? maybeAware.activeRunCompletionPromise : void 0;
|
|
@@ -8012,15 +8247,34 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
8012
8247
|
role: "user",
|
|
8013
8248
|
content: value
|
|
8014
8249
|
});
|
|
8250
|
+
const localRunId = hasNativeIntelligenceRunActivity ? randomUUID$1() : void 0;
|
|
8251
|
+
if (localRunId) activeLocalRunIdsRef.current.add(localRunId);
|
|
8015
8252
|
try {
|
|
8016
|
-
await copilotkit.runAgent({
|
|
8253
|
+
await copilotkit.runAgent({
|
|
8254
|
+
agent,
|
|
8255
|
+
...localRunId !== void 0 ? { runId: localRunId } : {}
|
|
8256
|
+
});
|
|
8017
8257
|
} catch (error) {
|
|
8018
8258
|
console.error("CopilotChat: runAgent failed", error);
|
|
8259
|
+
} finally {
|
|
8260
|
+
if (localRunId) {
|
|
8261
|
+
activeLocalRunIdsRef.current.delete(localRunId);
|
|
8262
|
+
rememberRecentlyLocalRunId(localRunId);
|
|
8263
|
+
}
|
|
8264
|
+
if (pendingRunActivityReconnectRef.current && activeLocalRunIdsRef.current.size === 0 && activeConnectCountRef.current === 0) {
|
|
8265
|
+
const startReconnect = startRunActivityReconnectRef.current;
|
|
8266
|
+
if (startReconnect) {
|
|
8267
|
+
pendingRunActivityReconnectRef.current = false;
|
|
8268
|
+
startReconnect(runActivityReconnectGenerationRef.current);
|
|
8269
|
+
}
|
|
8270
|
+
}
|
|
8019
8271
|
}
|
|
8020
8272
|
}, [
|
|
8021
8273
|
agent,
|
|
8022
8274
|
consumeAttachments,
|
|
8023
|
-
waitForActiveRunToSettle
|
|
8275
|
+
waitForActiveRunToSettle,
|
|
8276
|
+
hasNativeIntelligenceRunActivity,
|
|
8277
|
+
rememberRecentlyLocalRunId
|
|
8024
8278
|
]);
|
|
8025
8279
|
const handleSelectSuggestion = useCallback(async (suggestion) => {
|
|
8026
8280
|
await waitForActiveRunToSettle();
|
|
@@ -8029,12 +8283,34 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
8029
8283
|
role: "user",
|
|
8030
8284
|
content: suggestion.message
|
|
8031
8285
|
});
|
|
8286
|
+
const localRunId = hasNativeIntelligenceRunActivity ? randomUUID$1() : void 0;
|
|
8287
|
+
if (localRunId) activeLocalRunIdsRef.current.add(localRunId);
|
|
8032
8288
|
try {
|
|
8033
|
-
await copilotkit.runAgent({
|
|
8289
|
+
await copilotkit.runAgent({
|
|
8290
|
+
agent,
|
|
8291
|
+
...localRunId !== void 0 ? { runId: localRunId } : {}
|
|
8292
|
+
});
|
|
8034
8293
|
} catch (error) {
|
|
8035
8294
|
console.error("CopilotChat: runAgent failed after selecting suggestion", error);
|
|
8295
|
+
} finally {
|
|
8296
|
+
if (localRunId) {
|
|
8297
|
+
activeLocalRunIdsRef.current.delete(localRunId);
|
|
8298
|
+
rememberRecentlyLocalRunId(localRunId);
|
|
8299
|
+
}
|
|
8300
|
+
if (pendingRunActivityReconnectRef.current && activeLocalRunIdsRef.current.size === 0 && activeConnectCountRef.current === 0) {
|
|
8301
|
+
const startReconnect = startRunActivityReconnectRef.current;
|
|
8302
|
+
if (startReconnect) {
|
|
8303
|
+
pendingRunActivityReconnectRef.current = false;
|
|
8304
|
+
startReconnect(runActivityReconnectGenerationRef.current);
|
|
8305
|
+
}
|
|
8306
|
+
}
|
|
8036
8307
|
}
|
|
8037
|
-
}, [
|
|
8308
|
+
}, [
|
|
8309
|
+
agent,
|
|
8310
|
+
waitForActiveRunToSettle,
|
|
8311
|
+
hasNativeIntelligenceRunActivity,
|
|
8312
|
+
rememberRecentlyLocalRunId
|
|
8313
|
+
]);
|
|
8038
8314
|
const stopCurrentRun = useCallback(() => {
|
|
8039
8315
|
try {
|
|
8040
8316
|
copilotkit.stopAgent({ agent });
|
|
@@ -11256,5 +11532,5 @@ function validateProps(props) {
|
|
|
11256
11532
|
}
|
|
11257
11533
|
|
|
11258
11534
|
//#endregion
|
|
11259
|
-
export {
|
|
11260
|
-
//# sourceMappingURL=copilotkit-
|
|
11535
|
+
export { useCapabilities as $, CopilotChatMessageView as A, CopilotChatAssistantMessage_default as B, CopilotModalHeader as C, CopilotChatAudioRecorder as Ct, CopilotChat as D, DefaultOpenIcon as E, CopilotChatSuggestionView as F, useLearnFromUserActionInCurrentThread as G, useLearningContainersInCurrentThread as H, CopilotChatSuggestionPill as I, useThreads$1 as J, useLearnFromUserAction as K, CopilotChatReasoningMessage_default as L, IntelligenceIndicator as M, getIntelligenceTurnAnchors as N, CopilotChatView_default as O, IntelligenceIndicatorView as P, useAgentContext as Q, CopilotChatUserMessage_default as R, CopilotSidebarView as S, AudioRecorderError as St, DefaultCloseIcon as T, useCopilotChatConfiguration as Tt, useLearningContainers as U, CopilotChatToolCallsView as V, useAttachments as W, useConfigureSuggestions as X, useInterrupt as Y, useSuggestions as Z, WildcardToolCallRender as _, CopilotKitInspector as _t, ThreadsProvider as a, useComponent as at, CopilotSidebar as b, CopilotKitCoreReact as bt, CoAgentStateRendersProvider as c, useRenderCustomMessages as ct, shouldShowDevConsole as d, createA2UIMessageRenderer as dt, UseAgentUpdate as et, useToast as f, SandboxFunctionsContext as ft, useCopilotContext as g, MCPAppsActivityType as gt, CopilotContext as h, MCPAppsActivityRenderer as ht, ThreadsContext as i, useRenderTool as it, INTELLIGENCE_TURN_HEAD as j, CopilotChatAttachmentQueue as k, useCoAgentStateRenders as l, CopilotKitProvider as lt, useCopilotMessagesContext as m, MCPAppsActivityContentSchema as mt, defaultCopilotContextCategories as n, useHumanInTheLoop as nt, useThreads as o, useFrontendTool as ot, CopilotMessagesContext as p, useSandboxFunctions as pt, useMemories as q, CoAgentStateRenderBridge as r, useDefaultRenderTool as rt, CoAgentStateRendersContext as s, useRenderActivityMessage as st, CopilotKit as t, useAgent as tt, useAsyncCallback as u, defineToolCallRenderer as ut, CopilotThreadsDrawer as v, useRenderToolCall as vt, CopilotChatToggleButton as w, CopilotChatConfigurationProvider as wt, CopilotPopupView as x, CopilotChatInput_default as xt, CopilotPopup as y, useCopilotKit as yt, CopilotChatAttachmentRenderer as z };
|
|
11536
|
+
//# sourceMappingURL=copilotkit-BQT2ngSh.mjs.map
|