@copilotkit/react-core 1.64.1 → 1.64.2-canary.1785346263
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-DiLTL1ZM.cjs → copilotkit-BrNiD3wI.cjs} +64 -9
- package/dist/copilotkit-BrNiD3wI.cjs.map +1 -0
- package/dist/{copilotkit-D_Ao1X-u.mjs → copilotkit-BrZGzZw6.mjs} +64 -9
- package/dist/copilotkit-BrZGzZw6.mjs.map +1 -0
- package/dist/{copilotkit-CXvuYw_F.d.cts → copilotkit-CBCT7BlL.d.cts} +90 -7
- package/dist/{copilotkit-BE1n5tSI.d.mts.map → copilotkit-CBCT7BlL.d.cts.map} +1 -1
- package/dist/{copilotkit-BE1n5tSI.d.mts → copilotkit-D0aAnD3i.d.mts} +90 -7
- package/dist/{copilotkit-CXvuYw_F.d.cts.map → copilotkit-D0aAnD3i.d.mts.map} +1 -1
- 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 +63 -8
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +61 -8
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts +89 -6
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts +89 -6
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +61 -8
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.d.cts +1 -1
- package/dist/v2/index.d.mts +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +63 -8
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +7 -7
- package/dist/copilotkit-D_Ao1X-u.mjs.map +0 -1
- package/dist/copilotkit-DiLTL1ZM.cjs.map +0 -1
|
@@ -2086,6 +2086,8 @@ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agen
|
|
|
2086
2086
|
iframe.style.backgroundColor = "transparent";
|
|
2087
2087
|
iframe.style.display = "block";
|
|
2088
2088
|
iframe.setAttribute("sandbox", "allow-scripts allow-same-origin allow-forms");
|
|
2089
|
+
iframe.setAttribute("data-testid", "mcp-app-iframe");
|
|
2090
|
+
iframe.setAttribute("title", "Interactive MCP application");
|
|
2089
2091
|
const sandboxReady = new Promise((resolve) => {
|
|
2090
2092
|
initialListener = (event) => {
|
|
2091
2093
|
if (event.source === iframe.contentWindow) {
|
|
@@ -4392,7 +4394,10 @@ const ALL_UPDATES = [
|
|
|
4392
4394
|
UseAgentUpdate.OnStateChanged,
|
|
4393
4395
|
UseAgentUpdate.OnRunStatusChanged
|
|
4394
4396
|
];
|
|
4395
|
-
function useAgent({ agentId, updates, throttleMs } = {}) {
|
|
4397
|
+
function useAgent({ agentId, threadId, runtimeAgentId, updates, throttleMs } = {}) {
|
|
4398
|
+
if (threadId != null && runtimeAgentId == null) throw new Error(`useAgent: \`threadId\` requires \`runtimeAgentId\`. A threadId is written onto a single agent, but an agent resolved by agentId alone is shared, so scoping a thread to it would clobber other useAgent callers. Pass a distinct local \`agentId\` and the runtime agent to route to, e.g. useAgent({ agentId: "chat-1", runtimeAgentId: "${agentId ?? "default"}", threadId }).`);
|
|
4399
|
+
if (runtimeAgentId != null && threadId == null) throw new Error(`useAgent: \`runtimeAgentId\` requires \`threadId\`. A proxied agent exists to scope a thread to a private instance; without a threadId it behaves like the shared agent while adding a registration and a local agentId to keep unique. Either pass the thread, e.g. useAgent({ agentId: "${agentId ?? "chat-1"}", runtimeAgentId: "${runtimeAgentId}", threadId }), or bind to the agent directly with useAgent({ agentId: "${runtimeAgentId}" }).`);
|
|
4400
|
+
if (runtimeAgentId != null && agentId == null) throw new Error(`useAgent: \`runtimeAgentId\` requires an explicit \`agentId\`. The proxied agent is registered under \`agentId\`, and the usual fallbacks (chat configuration, then "${DEFAULT_AGENT_ID}") name agents that already exist — registering over one throws or shadows it. Pick a local id for this hook, e.g. useAgent({ agentId: "chat-1", runtimeAgentId: "${runtimeAgentId}", threadId }).`);
|
|
4396
4401
|
const chatConfig = useCopilotChatConfiguration();
|
|
4397
4402
|
const resolvedAgentId = agentId ?? chatConfig?.agentId ?? DEFAULT_AGENT_ID;
|
|
4398
4403
|
const { copilotkit } = useCopilotKit();
|
|
@@ -4400,7 +4405,58 @@ function useAgent({ agentId, updates, throttleMs } = {}) {
|
|
|
4400
4405
|
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
|
4401
4406
|
const updateFlags = useMemo(() => updates ?? ALL_UPDATES, [JSON.stringify(updates)]);
|
|
4402
4407
|
const provisionalAgentCache = useRef(/* @__PURE__ */ new Map());
|
|
4408
|
+
const [registeredProxyAgent, setRegisteredProxyAgent] = useState(null);
|
|
4409
|
+
useEffect(() => {
|
|
4410
|
+
if (runtimeAgentId == null) {
|
|
4411
|
+
setRegisteredProxyAgent(null);
|
|
4412
|
+
return;
|
|
4413
|
+
}
|
|
4414
|
+
const { agent: proxy, unregister } = copilotkit.registerProxiedAgent({
|
|
4415
|
+
agentId: resolvedAgentId,
|
|
4416
|
+
runtimeAgentId
|
|
4417
|
+
});
|
|
4418
|
+
provisionalAgentCache.current.delete(resolvedAgentId);
|
|
4419
|
+
setRegisteredProxyAgent(proxy);
|
|
4420
|
+
return () => {
|
|
4421
|
+
unregister();
|
|
4422
|
+
setRegisteredProxyAgent(null);
|
|
4423
|
+
};
|
|
4424
|
+
}, [
|
|
4425
|
+
copilotkit,
|
|
4426
|
+
resolvedAgentId,
|
|
4427
|
+
runtimeAgentId
|
|
4428
|
+
]);
|
|
4403
4429
|
const { agent, isReady } = useMemo(() => {
|
|
4430
|
+
if (runtimeAgentId != null) {
|
|
4431
|
+
if (registeredProxyAgent) {
|
|
4432
|
+
provisionalAgentCache.current.delete(resolvedAgentId);
|
|
4433
|
+
return {
|
|
4434
|
+
agent: registeredProxyAgent,
|
|
4435
|
+
isReady: true
|
|
4436
|
+
};
|
|
4437
|
+
}
|
|
4438
|
+
const cached = provisionalAgentCache.current.get(resolvedAgentId);
|
|
4439
|
+
if (cached) {
|
|
4440
|
+
copilotkit.applyHeadersToAgent(cached);
|
|
4441
|
+
return {
|
|
4442
|
+
agent: cached,
|
|
4443
|
+
isReady: false
|
|
4444
|
+
};
|
|
4445
|
+
}
|
|
4446
|
+
const provisional = new ProxiedCopilotRuntimeAgent({
|
|
4447
|
+
runtimeUrl: copilotkit.runtimeUrl,
|
|
4448
|
+
agentId: resolvedAgentId,
|
|
4449
|
+
runtimeAgentId,
|
|
4450
|
+
transport: copilotkit.runtimeTransport,
|
|
4451
|
+
runtimeMode: "pending"
|
|
4452
|
+
});
|
|
4453
|
+
copilotkit.applyHeadersToAgent(provisional);
|
|
4454
|
+
provisionalAgentCache.current.set(resolvedAgentId, provisional);
|
|
4455
|
+
return {
|
|
4456
|
+
agent: provisional,
|
|
4457
|
+
isReady: false
|
|
4458
|
+
};
|
|
4459
|
+
}
|
|
4404
4460
|
const existing = copilotkit.getAgent(resolvedAgentId);
|
|
4405
4461
|
if (existing) {
|
|
4406
4462
|
provisionalAgentCache.current.delete(resolvedAgentId);
|
|
@@ -4456,6 +4512,8 @@ function useAgent({ agentId, updates, throttleMs } = {}) {
|
|
|
4456
4512
|
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.");
|
|
4457
4513
|
}, [
|
|
4458
4514
|
resolvedAgentId,
|
|
4515
|
+
runtimeAgentId,
|
|
4516
|
+
registeredProxyAgent,
|
|
4459
4517
|
copilotkit.agents,
|
|
4460
4518
|
copilotkit.runtimeConnectionStatus,
|
|
4461
4519
|
copilotkit.runtimeUrl,
|
|
@@ -4508,14 +4566,11 @@ function useAgent({ agentId, updates, throttleMs } = {}) {
|
|
|
4508
4566
|
]);
|
|
4509
4567
|
const configThreadId = chatConfig?.threadId;
|
|
4510
4568
|
const configHasExplicitThreadId = chatConfig?.hasExplicitThreadId;
|
|
4569
|
+
const resolvedThreadId = threadId ?? (configHasExplicitThreadId ? configThreadId : void 0);
|
|
4511
4570
|
useEffect(() => {
|
|
4512
|
-
if (!
|
|
4513
|
-
agent.threadId =
|
|
4514
|
-
}, [
|
|
4515
|
-
agent,
|
|
4516
|
-
configThreadId,
|
|
4517
|
-
configHasExplicitThreadId
|
|
4518
|
-
]);
|
|
4571
|
+
if (!resolvedThreadId) return;
|
|
4572
|
+
agent.threadId = resolvedThreadId;
|
|
4573
|
+
}, [agent, resolvedThreadId]);
|
|
4519
4574
|
return {
|
|
4520
4575
|
agent,
|
|
4521
4576
|
isReady
|
|
@@ -11644,4 +11699,4 @@ function validateProps(props) {
|
|
|
11644
11699
|
|
|
11645
11700
|
//#endregion
|
|
11646
11701
|
export { useCapabilities as $, CopilotChatMessageView as A, CopilotChatConfigurationProvider as At, CopilotChatAssistantMessage_default as B, CopilotModalHeader as C, CopilotKitInspector as Ct, CopilotChat as D, CopilotChatInput_default as Dt, DefaultOpenIcon as E, CopilotKitCoreReact as Et, 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, AudioRecorderError as Ot, IntelligenceIndicatorView as P, useAgentContext as Q, CopilotChatUserMessage_default as R, CopilotSidebarView as S, ɵrunMcpFollowUp as St, DefaultCloseIcon as T, useCopilotKit as Tt, useLearningContainers as U, CopilotChatToolCallsView as V, useAttachments as W, useConfigureSuggestions as X, useInterrupt as Y, useSuggestions as Z, WildcardToolCallRender as _, SandboxFunctionsContext as _t, ThreadsProvider as a, useComponent as at, CopilotSidebar as b, MCPAppsActivityRenderer as bt, CoAgentStateRendersProvider as c, useRenderCustomMessages as ct, shouldShowDevConsole as d, createA2UIMessageRenderer as dt, UseAgentUpdate as et, useToast as f, GenerateSandboxedUiArgsSchema as ft, useCopilotContext as g, OpenGenerativeUIToolRenderer as gt, CopilotContext as h, OpenGenerativeUIContentSchema as ht, ThreadsContext as i, useRenderTool as it, INTELLIGENCE_TURN_HEAD as j, useCopilotChatConfiguration as jt, CopilotChatAttachmentQueue as k, CopilotChatAudioRecorder as kt, useCoAgentStateRenders as l, CopilotKitProvider as lt, useCopilotMessagesContext as m, OpenGenerativeUIActivityType as mt, defaultCopilotContextCategories as n, useHumanInTheLoop as nt, useThreads as o, useFrontendTool as ot, CopilotMessagesContext as p, OpenGenerativeUIActivityRenderer 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, useSandboxFunctions as vt, CopilotChatToggleButton as w, useRenderToolCall as wt, CopilotPopupView as x, MCPAppsActivityType as xt, CopilotPopup as y, MCPAppsActivityContentSchema as yt, CopilotChatAttachmentRenderer as z };
|
|
11647
|
-
//# sourceMappingURL=copilotkit-
|
|
11702
|
+
//# sourceMappingURL=copilotkit-BrZGzZw6.mjs.map
|