@copilotkit/react-core 1.62.2 → 1.63.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-Cga6AHO0.d.cts → copilotkit-BHs-vx6l.d.cts} +285 -6
- package/dist/copilotkit-BHs-vx6l.d.cts.map +1 -0
- package/dist/{copilotkit-CmcMFc8o.mjs → copilotkit-BLh58_Tt.mjs} +161 -27
- package/dist/copilotkit-BLh58_Tt.mjs.map +1 -0
- package/dist/{copilotkit-DnLpJ2Cl.d.mts → copilotkit-CN_LykOC.d.mts} +285 -6
- package/dist/copilotkit-CN_LykOC.d.mts.map +1 -0
- package/dist/{copilotkit-lHheGQWt.cjs → copilotkit-nu7NwzH6.cjs} +201 -25
- package/dist/copilotkit-nu7NwzH6.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 +62 -15
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +18 -14
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts +16 -2
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts +17 -3
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +19 -15
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +8 -1
- package/dist/v2/index.css +1 -1
- package/dist/v2/index.d.cts +2 -3
- package/dist/v2/index.d.mts +2 -3
- package/dist/v2/index.mjs +2 -2
- package/dist/v2/index.umd.js +165 -24
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +8 -8
- package/dist/copilotkit-Cga6AHO0.d.cts.map +0 -1
- package/dist/copilotkit-CmcMFc8o.mjs.map +0 -1
- package/dist/copilotkit-DnLpJ2Cl.d.mts.map +0 -1
- package/dist/copilotkit-lHheGQWt.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_copilotkit = require('./copilotkit-
|
|
4
|
+
const require_copilotkit = require('./copilotkit-nu7NwzH6.cjs');
|
|
5
5
|
let react = require("react");
|
|
6
6
|
react = require_copilotkit.__toESM(react);
|
|
7
7
|
let _copilotkit_core = require("@copilotkit/core");
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $n as
|
|
1
|
+
import { $n as LangGraphInterruptRender, Gn as CopilotApiConfig, Jn as useCopilotContext, Kn as CopilotContext, Qn as LangGraphInterruptActionSetterArgs, Sr as RenderFunctionStatus, Wn as CoagentInChatRenderFunction, Xn as LangGraphInterruptAction, Y as useAgent, Yn as CoAgentStateRender, Zn as LangGraphInterruptActionSetter, _r as ActionRenderPropsWait, ar as CrewsResponseStatus, br as FrontendAction, cr as CrewsToolStateItem, dr as DocumentPointer, er as LangGraphInterruptRenderHandlerProps, fr as Tree, gr as ActionRenderPropsNoArgsWait, hr as ActionRenderPropsNoArgs, ir as CrewsResponse, lr as CopilotChatSuggestionConfiguration, mr as ActionRenderProps, n as defaultCopilotContextCategories, nr as QueuedInterruptEvent, or as CrewsStateItem, pr as TreeNode, qn as CopilotContextParams, r as CopilotKitProps, rr as CrewsAgentState, sr as CrewsTaskStateItem, t as CopilotKit, tr as LangGraphInterruptRenderProps, ur as SystemMessageFunction, vr as CatchAllActionRenderProps, vt as useRenderToolCall$1, xr as FrontendActionAvailability, yr as CatchAllFrontendAction } from "./copilotkit-BHs-vx6l.cjs";
|
|
2
2
|
import "./v2/index.cjs";
|
|
3
3
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
4
|
import { CopilotRuntimeClient, CopilotRuntimeClientOptions, ForwardedParametersInput, Message } from "@copilotkit/runtime-client-gql";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $n as
|
|
1
|
+
import { $n as LangGraphInterruptRender, Gn as CopilotApiConfig, Jn as useCopilotContext, Kn as CopilotContext, Qn as LangGraphInterruptActionSetterArgs, Sr as RenderFunctionStatus, Wn as CoagentInChatRenderFunction, Xn as LangGraphInterruptAction, Y as useAgent, Yn as CoAgentStateRender, Zn as LangGraphInterruptActionSetter, _r as ActionRenderPropsWait, ar as CrewsResponseStatus, br as FrontendAction, cr as CrewsToolStateItem, dr as DocumentPointer, er as LangGraphInterruptRenderHandlerProps, fr as Tree, gr as ActionRenderPropsNoArgsWait, hr as ActionRenderPropsNoArgs, ir as CrewsResponse, lr as CopilotChatSuggestionConfiguration, mr as ActionRenderProps, n as defaultCopilotContextCategories, nr as QueuedInterruptEvent, or as CrewsStateItem, pr as TreeNode, qn as CopilotContextParams, r as CopilotKitProps, rr as CrewsAgentState, sr as CrewsTaskStateItem, t as CopilotKit, tr as LangGraphInterruptRenderProps, ur as SystemMessageFunction, vr as CatchAllActionRenderProps, vt as useRenderToolCall$1, xr as FrontendActionAvailability, yr as CatchAllFrontendAction } from "./copilotkit-CN_LykOC.mjs";
|
|
2
2
|
import "./v2/index.mjs";
|
|
3
3
|
import React, { ReactNode, RefObject, SetStateAction } from "react";
|
|
4
4
|
import { StaticSuggestionsConfig, Suggestion } from "@copilotkit/core";
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Tt as useCopilotKit, X as useConfigureSuggestions, Y as useInterrupt, Z as useSuggestions, a as ThreadsProvider, c as CoAgentStateRendersProvider, ct as useRenderCustomMessages, d as shouldShowDevConsole, f as useToast, g as useCopilotContext, h as CopilotContext, i as ThreadsContext, jt as useCopilotChatConfiguration, l as useCoAgentStateRenders, m as useCopilotMessagesContext, n as defaultCopilotContextCategories, nt as useHumanInTheLoop$1, o as useThreads, ot as useFrontendTool$1, p as CopilotMessagesContext, r as CoAgentStateRenderBridge, s as CoAgentStateRendersContext, t as CopilotKit, tt as useAgent, u as useAsyncCallback, ut as defineToolCallRenderer, wt as useRenderToolCall$1 } from "./copilotkit-BLh58_Tt.mjs";
|
|
4
4
|
import React, { Fragment, createElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { CopilotKitCoreRuntimeConnectionStatus, ToolCallStatus } from "@copilotkit/core";
|
|
6
6
|
import { AGUIConnectNotImplementedError, HttpAgent } from "@ag-ui/client";
|
package/dist/index.umd.js
CHANGED
|
@@ -677,6 +677,34 @@ react_markdown = __toESM(react_markdown);
|
|
|
677
677
|
|
|
678
678
|
//#endregion
|
|
679
679
|
//#region src/v2/components/MCPAppsActivityRenderer.tsx
|
|
680
|
+
/**
|
|
681
|
+
* Run an MCP app `ui/message` follow-up, scoped to the thread it was enqueued
|
|
682
|
+
* for (issue #5819).
|
|
683
|
+
*
|
|
684
|
+
* The MCP request queue delays follow-up work until the agent is idle. There is
|
|
685
|
+
* a single shared registry agent per id, and switching threads overwrites its
|
|
686
|
+
* `threadId`/`messages` in place. So if the host switches threads while a
|
|
687
|
+
* follow-up is queued, running it now would execute against — and stream into —
|
|
688
|
+
* the now-foreground thread.
|
|
689
|
+
*
|
|
690
|
+
* - **Same thread** (the common case): run on the shared agent, unchanged.
|
|
691
|
+
* - **Thread changed**: the shared agent has moved on, so the follow-up can no
|
|
692
|
+
* longer run in its originating thread's context. Drop it rather than leak it
|
|
693
|
+
* into the current thread. (The MCP app already received its `ui/message` ack
|
|
694
|
+
* at enqueue time; only the optional agent turn is skipped.)
|
|
695
|
+
*
|
|
696
|
+
* @internal exported for testing.
|
|
697
|
+
*/
|
|
698
|
+
async function ɵrunMcpFollowUp({ host, agent, capturedThreadId }) {
|
|
699
|
+
const currentThreadId = agent.threadId || "default";
|
|
700
|
+
const originThreadId = capturedThreadId || "default";
|
|
701
|
+
if (currentThreadId === originThreadId) return host.runAgent({ agent });
|
|
702
|
+
console.warn(`[MCPAppsRenderer] ui/message follow-up dropped: the thread changed (${originThreadId} → ${currentThreadId}) between enqueue and execution, so running it would leak into the now-foreground thread.`);
|
|
703
|
+
return {
|
|
704
|
+
result: void 0,
|
|
705
|
+
newMessages: []
|
|
706
|
+
};
|
|
707
|
+
}
|
|
680
708
|
const PROTOCOL_VERSION = "2025-06-18";
|
|
681
709
|
function buildSandboxHTML(extraCspDomains) {
|
|
682
710
|
const baseScriptSrc = "'self' 'wasm-unsafe-eval' 'unsafe-inline' 'unsafe-eval' blob: data: http://localhost:* https://localhost:*";
|
|
@@ -999,7 +1027,14 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
999
1027
|
content: textContent
|
|
1000
1028
|
});
|
|
1001
1029
|
sendResponse(msg.id, { isError: false });
|
|
1002
|
-
if ((params.followUp ?? role === "user") && textContent)
|
|
1030
|
+
if ((params.followUp ?? role === "user") && textContent) {
|
|
1031
|
+
const capturedThreadId = currentAgent.threadId || "default";
|
|
1032
|
+
mcpAppsRequestQueue.enqueue(currentAgent, () => ɵrunMcpFollowUp({
|
|
1033
|
+
host: copilotkit,
|
|
1034
|
+
agent: currentAgent,
|
|
1035
|
+
capturedThreadId
|
|
1036
|
+
})).catch((err) => console.error("[MCPAppsRenderer] ui/message agent run failed:", err));
|
|
1037
|
+
}
|
|
1003
1038
|
} catch (err) {
|
|
1004
1039
|
console.error("[MCPAppsRenderer] ui/message error:", err);
|
|
1005
1040
|
sendResponse(msg.id, { isError: true });
|
|
@@ -2482,6 +2517,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2482
2517
|
if (copilotkitRef.current === null) {
|
|
2483
2518
|
copilotkitRef.current = new CopilotKitCoreReact({
|
|
2484
2519
|
runtimeUrl: chatApiEndpoint,
|
|
2520
|
+
deferInitialConnection: true,
|
|
2485
2521
|
runtimeTransport: useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto",
|
|
2486
2522
|
headers: mergedHeaders,
|
|
2487
2523
|
credentials,
|
|
@@ -2565,6 +2601,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2565
2601
|
} : properties);
|
|
2566
2602
|
copilotkit.setAgents__unsafe_dev_only(mergedAgents);
|
|
2567
2603
|
copilotkit.setDebug(debug);
|
|
2604
|
+
copilotkit.connect();
|
|
2568
2605
|
}, [
|
|
2569
2606
|
copilotkit,
|
|
2570
2607
|
chatApiEndpoint,
|
|
@@ -2849,57 +2886,58 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2849
2886
|
UseAgentUpdate.OnRunStatusChanged
|
|
2850
2887
|
];
|
|
2851
2888
|
function useAgent({ agentId, updates, throttleMs } = {}) {
|
|
2852
|
-
|
|
2889
|
+
const chatConfig = useCopilotChatConfiguration();
|
|
2890
|
+
const resolvedAgentId = agentId ?? chatConfig?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
2853
2891
|
const { copilotkit } = useCopilotKit();
|
|
2854
2892
|
const providerThrottleMs = copilotkit.defaultThrottleMs;
|
|
2855
2893
|
const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
|
|
2856
2894
|
const updateFlags = (0, react.useMemo)(() => updates ?? ALL_UPDATES, [JSON.stringify(updates)]);
|
|
2857
2895
|
const provisionalAgentCache = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
2858
2896
|
const agent = (0, react.useMemo)(() => {
|
|
2859
|
-
const existing = copilotkit.getAgent(
|
|
2897
|
+
const existing = copilotkit.getAgent(resolvedAgentId);
|
|
2860
2898
|
if (existing) {
|
|
2861
|
-
provisionalAgentCache.current.delete(
|
|
2899
|
+
provisionalAgentCache.current.delete(resolvedAgentId);
|
|
2862
2900
|
return existing;
|
|
2863
2901
|
}
|
|
2864
2902
|
const isRuntimeConfigured = copilotkit.runtimeUrl !== void 0;
|
|
2865
2903
|
const status = copilotkit.runtimeConnectionStatus;
|
|
2866
2904
|
if (isRuntimeConfigured && (status === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Disconnected || status === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Connecting)) {
|
|
2867
|
-
const cached = provisionalAgentCache.current.get(
|
|
2905
|
+
const cached = provisionalAgentCache.current.get(resolvedAgentId);
|
|
2868
2906
|
if (cached) {
|
|
2869
2907
|
copilotkit.applyHeadersToAgent(cached);
|
|
2870
2908
|
return cached;
|
|
2871
2909
|
}
|
|
2872
2910
|
const provisional = new _copilotkit_core.ProxiedCopilotRuntimeAgent({
|
|
2873
2911
|
runtimeUrl: copilotkit.runtimeUrl,
|
|
2874
|
-
agentId,
|
|
2912
|
+
agentId: resolvedAgentId,
|
|
2875
2913
|
transport: copilotkit.runtimeTransport,
|
|
2876
2914
|
runtimeMode: "pending"
|
|
2877
2915
|
});
|
|
2878
2916
|
copilotkit.applyHeadersToAgent(provisional);
|
|
2879
|
-
provisionalAgentCache.current.set(
|
|
2917
|
+
provisionalAgentCache.current.set(resolvedAgentId, provisional);
|
|
2880
2918
|
return provisional;
|
|
2881
2919
|
}
|
|
2882
2920
|
if (isRuntimeConfigured && status === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Error) {
|
|
2883
|
-
const cached = provisionalAgentCache.current.get(
|
|
2921
|
+
const cached = provisionalAgentCache.current.get(resolvedAgentId);
|
|
2884
2922
|
if (cached) {
|
|
2885
2923
|
copilotkit.applyHeadersToAgent(cached);
|
|
2886
2924
|
return cached;
|
|
2887
2925
|
}
|
|
2888
2926
|
const provisional = new _copilotkit_core.ProxiedCopilotRuntimeAgent({
|
|
2889
2927
|
runtimeUrl: copilotkit.runtimeUrl,
|
|
2890
|
-
agentId,
|
|
2928
|
+
agentId: resolvedAgentId,
|
|
2891
2929
|
transport: copilotkit.runtimeTransport,
|
|
2892
2930
|
runtimeMode: "pending"
|
|
2893
2931
|
});
|
|
2894
2932
|
copilotkit.applyHeadersToAgent(provisional);
|
|
2895
|
-
provisionalAgentCache.current.set(
|
|
2933
|
+
provisionalAgentCache.current.set(resolvedAgentId, provisional);
|
|
2896
2934
|
return provisional;
|
|
2897
2935
|
}
|
|
2898
2936
|
const knownAgents = Object.keys(copilotkit.agents ?? {});
|
|
2899
2937
|
const runtimePart = isRuntimeConfigured ? `runtimeUrl=${copilotkit.runtimeUrl}` : "no runtimeUrl";
|
|
2900
|
-
throw new Error(`useAgent: Agent '${
|
|
2938
|
+
throw new Error(`useAgent: Agent '${resolvedAgentId}' not found after runtime sync (${runtimePart}). ` + (knownAgents.length ? `Known agents: [${knownAgents.join(", ")}]` : "No agents registered.") + " Verify your runtime /info and/or agents__unsafe_dev_only.");
|
|
2901
2939
|
}, [
|
|
2902
|
-
|
|
2940
|
+
resolvedAgentId,
|
|
2903
2941
|
copilotkit.agents,
|
|
2904
2942
|
copilotkit.runtimeConnectionStatus,
|
|
2905
2943
|
copilotkit.runtimeUrl,
|
|
@@ -2944,7 +2982,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2944
2982
|
(0, react.useEffect)(() => {
|
|
2945
2983
|
if (agent instanceof _ag_ui_client.HttpAgent) copilotkit.applyHeadersToAgent(agent);
|
|
2946
2984
|
}, [agent, JSON.stringify(copilotkit.headers)]);
|
|
2947
|
-
const chatConfig = useCopilotChatConfiguration();
|
|
2948
2985
|
const configThreadId = chatConfig?.threadId;
|
|
2949
2986
|
const configHasExplicitThreadId = chatConfig?.hasExplicitThreadId;
|
|
2950
2987
|
(0, react.useEffect)(() => {
|
|
@@ -5031,8 +5068,18 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5031
5068
|
}, [agent, getSubscriber]);
|
|
5032
5069
|
};
|
|
5033
5070
|
function CopilotListenersAgentSubscription() {
|
|
5034
|
-
const
|
|
5035
|
-
const
|
|
5071
|
+
const { copilotkit } = useCopilotKit();
|
|
5072
|
+
const configAgentId = useCopilotChatConfiguration()?.agentId;
|
|
5073
|
+
const { agent } = useAgent({ agentId: (0, react.useMemo)(() => {
|
|
5074
|
+
const requested = configAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
5075
|
+
const registered = copilotkit.agents ?? {};
|
|
5076
|
+
if (registered[requested]) return requested;
|
|
5077
|
+
if (requested === _copilotkit_shared.DEFAULT_AGENT_ID) {
|
|
5078
|
+
const firstRegistered = Object.keys(registered)[0];
|
|
5079
|
+
if (firstRegistered) return firstRegistered;
|
|
5080
|
+
}
|
|
5081
|
+
return requested;
|
|
5082
|
+
}, [configAgentId, copilotkit.agents]) });
|
|
5036
5083
|
usePredictStateSubscription(agent);
|
|
5037
5084
|
return null;
|
|
5038
5085
|
}
|