@copilotkit/react-core 1.56.5-canary.1777664617 → 1.56.5-canary.1777915231
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-CPe2-340.mjs → copilotkit-B6kDTnFY.mjs} +119 -175
- package/dist/copilotkit-B6kDTnFY.mjs.map +1 -0
- package/dist/{copilotkit-DGbvw8n2.cjs → copilotkit-BoiGcRsU.cjs} +118 -174
- package/dist/copilotkit-BoiGcRsU.cjs.map +1 -0
- package/dist/{copilotkit-Dg4r4Gi_.d.cts → copilotkit-DTyTNR6Y.d.cts} +3 -5
- package/dist/{copilotkit-Dg4r4Gi_.d.cts.map → copilotkit-DTyTNR6Y.d.cts.map} +1 -1
- package/dist/{copilotkit-DFaI4j2r.d.mts → copilotkit-FJWQLKBE.d.mts} +3 -5
- package/dist/{copilotkit-DFaI4j2r.d.mts.map → copilotkit-FJWQLKBE.d.mts.map} +1 -1
- package/dist/index.cjs +2 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +2 -5
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +117 -172
- package/dist/index.umd.js.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 +121 -180
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +6 -6
- package/src/hooks/__tests__/use-copilot-chat-internal-connect.test.tsx +5 -6
- package/src/hooks/use-copilot-chat_internal.ts +0 -1
- package/src/v2/components/chat/CopilotChat.tsx +2 -1
- package/src/v2/components/chat/CopilotChatMessageView.tsx +2 -7
- package/src/v2/components/chat/CopilotChatView.tsx +2 -2
- package/src/v2/components/chat/__tests__/CopilotChat.welcomeGate.test.tsx +1 -3
- package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.tsx +29 -25
- package/src/v2/components/chat/__tests__/MCPAppsUiMessage.e2e.test.tsx +5 -60
- package/src/v2/hooks/use-agent.tsx +7 -116
- package/src/v2/hooks/use-render-activity-message.tsx +3 -11
- package/src/v2/hooks/use-render-custom-messages.tsx +1 -6
- package/dist/copilotkit-CPe2-340.mjs.map +0 -1
- package/dist/copilotkit-DGbvw8n2.cjs.map +0 -1
- package/src/v2/hooks/__tests__/use-agent-thread-isolation.test.tsx +0 -333
|
@@ -3481,168 +3481,6 @@ function useRenderToolCall() {
|
|
|
3481
3481
|
]);
|
|
3482
3482
|
}
|
|
3483
3483
|
|
|
3484
|
-
//#endregion
|
|
3485
|
-
//#region src/v2/hooks/use-agent.tsx
|
|
3486
|
-
let UseAgentUpdate = /* @__PURE__ */ function(UseAgentUpdate) {
|
|
3487
|
-
UseAgentUpdate["OnMessagesChanged"] = "OnMessagesChanged";
|
|
3488
|
-
UseAgentUpdate["OnStateChanged"] = "OnStateChanged";
|
|
3489
|
-
UseAgentUpdate["OnRunStatusChanged"] = "OnRunStatusChanged";
|
|
3490
|
-
return UseAgentUpdate;
|
|
3491
|
-
}({});
|
|
3492
|
-
const ALL_UPDATES = [
|
|
3493
|
-
UseAgentUpdate.OnMessagesChanged,
|
|
3494
|
-
UseAgentUpdate.OnStateChanged,
|
|
3495
|
-
UseAgentUpdate.OnRunStatusChanged
|
|
3496
|
-
];
|
|
3497
|
-
/**
|
|
3498
|
-
* Clone a registry agent for per-thread isolation.
|
|
3499
|
-
* Copies agent configuration (transport, headers, etc.) but resets conversation
|
|
3500
|
-
* state (messages, threadId, state) so each thread starts fresh.
|
|
3501
|
-
*/
|
|
3502
|
-
function cloneForThread(source, threadId, headers) {
|
|
3503
|
-
const clone = source.clone();
|
|
3504
|
-
if (clone === source) throw new Error(`useAgent: ${source.constructor.name}.clone() returned the same instance. clone() must return a new, independent object.`);
|
|
3505
|
-
clone.threadId = threadId;
|
|
3506
|
-
clone.setMessages([]);
|
|
3507
|
-
clone.setState({});
|
|
3508
|
-
if (clone instanceof HttpAgent) clone.headers = { ...headers };
|
|
3509
|
-
return clone;
|
|
3510
|
-
}
|
|
3511
|
-
/**
|
|
3512
|
-
* Module-level WeakMap: registryAgent → (threadId → clone).
|
|
3513
|
-
* Shared across all useAgent() calls so that every component using the same
|
|
3514
|
-
* (agentId, threadId) pair receives the same agent instance. Using WeakMap
|
|
3515
|
-
* ensures the clone map is garbage-collected when the registry agent is
|
|
3516
|
-
* replaced (e.g. after reconnect or hot-reload).
|
|
3517
|
-
*/
|
|
3518
|
-
const globalThreadCloneMap = /* @__PURE__ */ new WeakMap();
|
|
3519
|
-
/**
|
|
3520
|
-
* Look up an existing per-thread clone without creating one.
|
|
3521
|
-
* Returns undefined when no clone has been created yet for this pair.
|
|
3522
|
-
*/
|
|
3523
|
-
function getThreadClone(registryAgent, threadId) {
|
|
3524
|
-
if (!registryAgent || !threadId) return void 0;
|
|
3525
|
-
return globalThreadCloneMap.get(registryAgent)?.get(threadId);
|
|
3526
|
-
}
|
|
3527
|
-
function getOrCreateThreadClone(existing, threadId, headers) {
|
|
3528
|
-
let byThread = globalThreadCloneMap.get(existing);
|
|
3529
|
-
if (!byThread) {
|
|
3530
|
-
byThread = /* @__PURE__ */ new Map();
|
|
3531
|
-
globalThreadCloneMap.set(existing, byThread);
|
|
3532
|
-
}
|
|
3533
|
-
const cached = byThread.get(threadId);
|
|
3534
|
-
if (cached) return cached;
|
|
3535
|
-
const clone = cloneForThread(existing, threadId, headers);
|
|
3536
|
-
byThread.set(threadId, clone);
|
|
3537
|
-
return clone;
|
|
3538
|
-
}
|
|
3539
|
-
function useAgent({ agentId, threadId, updates, throttleMs } = {}) {
|
|
3540
|
-
agentId ??= DEFAULT_AGENT_ID;
|
|
3541
|
-
const { copilotkit } = useCopilotKit();
|
|
3542
|
-
const providerThrottleMs = copilotkit.defaultThrottleMs;
|
|
3543
|
-
const chatConfig = useCopilotChatConfiguration();
|
|
3544
|
-
threadId ??= chatConfig?.threadId;
|
|
3545
|
-
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
|
3546
|
-
const updateFlags = useMemo(() => updates ?? ALL_UPDATES, [JSON.stringify(updates)]);
|
|
3547
|
-
const provisionalAgentCache = useRef(/* @__PURE__ */ new Map());
|
|
3548
|
-
const agent = useMemo(() => {
|
|
3549
|
-
const cacheKey = threadId ? `${agentId}:${threadId}` : agentId;
|
|
3550
|
-
const existing = copilotkit.getAgent(agentId);
|
|
3551
|
-
if (existing) {
|
|
3552
|
-
provisionalAgentCache.current.delete(cacheKey);
|
|
3553
|
-
provisionalAgentCache.current.delete(agentId);
|
|
3554
|
-
if (!threadId) return existing;
|
|
3555
|
-
return getOrCreateThreadClone(existing, threadId, copilotkit.headers);
|
|
3556
|
-
}
|
|
3557
|
-
const isRuntimeConfigured = copilotkit.runtimeUrl !== void 0;
|
|
3558
|
-
const status = copilotkit.runtimeConnectionStatus;
|
|
3559
|
-
if (isRuntimeConfigured && (status === CopilotKitCoreRuntimeConnectionStatus.Disconnected || status === CopilotKitCoreRuntimeConnectionStatus.Connecting)) {
|
|
3560
|
-
const cached = provisionalAgentCache.current.get(cacheKey);
|
|
3561
|
-
if (cached) {
|
|
3562
|
-
cached.headers = { ...copilotkit.headers };
|
|
3563
|
-
return cached;
|
|
3564
|
-
}
|
|
3565
|
-
const provisional = new ProxiedCopilotRuntimeAgent({
|
|
3566
|
-
runtimeUrl: copilotkit.runtimeUrl,
|
|
3567
|
-
agentId,
|
|
3568
|
-
transport: copilotkit.runtimeTransport,
|
|
3569
|
-
runtimeMode: "pending"
|
|
3570
|
-
});
|
|
3571
|
-
provisional.headers = { ...copilotkit.headers };
|
|
3572
|
-
if (threadId) provisional.threadId = threadId;
|
|
3573
|
-
provisionalAgentCache.current.set(cacheKey, provisional);
|
|
3574
|
-
return provisional;
|
|
3575
|
-
}
|
|
3576
|
-
if (isRuntimeConfigured && status === CopilotKitCoreRuntimeConnectionStatus.Error) {
|
|
3577
|
-
const cached = provisionalAgentCache.current.get(cacheKey);
|
|
3578
|
-
if (cached) {
|
|
3579
|
-
cached.headers = { ...copilotkit.headers };
|
|
3580
|
-
return cached;
|
|
3581
|
-
}
|
|
3582
|
-
const provisional = new ProxiedCopilotRuntimeAgent({
|
|
3583
|
-
runtimeUrl: copilotkit.runtimeUrl,
|
|
3584
|
-
agentId,
|
|
3585
|
-
transport: copilotkit.runtimeTransport,
|
|
3586
|
-
runtimeMode: "pending"
|
|
3587
|
-
});
|
|
3588
|
-
provisional.headers = { ...copilotkit.headers };
|
|
3589
|
-
if (threadId) provisional.threadId = threadId;
|
|
3590
|
-
provisionalAgentCache.current.set(cacheKey, provisional);
|
|
3591
|
-
return provisional;
|
|
3592
|
-
}
|
|
3593
|
-
const knownAgents = Object.keys(copilotkit.agents ?? {});
|
|
3594
|
-
const runtimePart = isRuntimeConfigured ? `runtimeUrl=${copilotkit.runtimeUrl}` : "no runtimeUrl";
|
|
3595
|
-
throw new Error(`useAgent: Agent '${agentId}' 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.");
|
|
3596
|
-
}, [
|
|
3597
|
-
agentId,
|
|
3598
|
-
threadId,
|
|
3599
|
-
copilotkit.agents,
|
|
3600
|
-
copilotkit.runtimeConnectionStatus,
|
|
3601
|
-
copilotkit.runtimeUrl,
|
|
3602
|
-
copilotkit.runtimeTransport,
|
|
3603
|
-
JSON.stringify(copilotkit.headers)
|
|
3604
|
-
]);
|
|
3605
|
-
useEffect(() => {
|
|
3606
|
-
if (updateFlags.length === 0) return;
|
|
3607
|
-
let active = true;
|
|
3608
|
-
const handlers = {};
|
|
3609
|
-
let batchScheduled = false;
|
|
3610
|
-
const batchedForceUpdate = () => {
|
|
3611
|
-
if (!active) return;
|
|
3612
|
-
if (!batchScheduled) {
|
|
3613
|
-
batchScheduled = true;
|
|
3614
|
-
queueMicrotask(() => {
|
|
3615
|
-
batchScheduled = false;
|
|
3616
|
-
if (active) forceUpdate();
|
|
3617
|
-
});
|
|
3618
|
-
}
|
|
3619
|
-
};
|
|
3620
|
-
if (updateFlags.includes(UseAgentUpdate.OnMessagesChanged)) handlers.onMessagesChanged = forceUpdate;
|
|
3621
|
-
if (updateFlags.includes(UseAgentUpdate.OnStateChanged)) handlers.onStateChanged = batchedForceUpdate;
|
|
3622
|
-
if (updateFlags.includes(UseAgentUpdate.OnRunStatusChanged)) {
|
|
3623
|
-
handlers.onRunInitialized = batchedForceUpdate;
|
|
3624
|
-
handlers.onRunFinalized = batchedForceUpdate;
|
|
3625
|
-
handlers.onRunFailed = batchedForceUpdate;
|
|
3626
|
-
handlers.onRunErrorEvent = batchedForceUpdate;
|
|
3627
|
-
}
|
|
3628
|
-
const subscription = copilotkit.subscribeToAgentWithOptions(agent, handlers, { throttleMs });
|
|
3629
|
-
return () => {
|
|
3630
|
-
active = false;
|
|
3631
|
-
subscription.unsubscribe();
|
|
3632
|
-
};
|
|
3633
|
-
}, [
|
|
3634
|
-
agent,
|
|
3635
|
-
forceUpdate,
|
|
3636
|
-
throttleMs,
|
|
3637
|
-
providerThrottleMs,
|
|
3638
|
-
updateFlags
|
|
3639
|
-
]);
|
|
3640
|
-
useEffect(() => {
|
|
3641
|
-
if (agent instanceof HttpAgent) agent.headers = { ...copilotkit.headers };
|
|
3642
|
-
}, [agent, JSON.stringify(copilotkit.headers)]);
|
|
3643
|
-
return { agent };
|
|
3644
|
-
}
|
|
3645
|
-
|
|
3646
3484
|
//#endregion
|
|
3647
3485
|
//#region src/v2/hooks/use-render-custom-messages.tsx
|
|
3648
3486
|
function useRenderCustomMessages() {
|
|
@@ -3660,8 +3498,7 @@ function useRenderCustomMessages() {
|
|
|
3660
3498
|
const { message, position } = params;
|
|
3661
3499
|
const resolvedRunId = copilotkit.getRunIdForMessage(agentId, threadId, message.id) ?? copilotkit.getRunIdsForThread(agentId, threadId).slice(-1)[0];
|
|
3662
3500
|
const runId = resolvedRunId ?? `missing-run-id:${message.id}`;
|
|
3663
|
-
const
|
|
3664
|
-
const agent = getThreadClone(registryAgent, threadId) ?? registryAgent;
|
|
3501
|
+
const agent = copilotkit.getAgent(agentId);
|
|
3665
3502
|
if (!agent) return null;
|
|
3666
3503
|
const messagesIdsInRun = resolvedRunId ? agent.messages.filter((msg) => copilotkit.getRunIdForMessage(agentId, threadId, msg.id) === resolvedRunId).map((msg) => msg.id) : [message.id];
|
|
3667
3504
|
const rawMessageIndex = agent.messages.findIndex((msg) => msg.id === message.id);
|
|
@@ -3693,8 +3530,7 @@ function useRenderCustomMessages() {
|
|
|
3693
3530
|
//#region src/v2/hooks/use-render-activity-message.tsx
|
|
3694
3531
|
function useRenderActivityMessage() {
|
|
3695
3532
|
const { copilotkit } = useCopilotKit();
|
|
3696
|
-
const
|
|
3697
|
-
const agentId = config?.agentId ?? DEFAULT_AGENT_ID;
|
|
3533
|
+
const agentId = useCopilotChatConfiguration()?.agentId ?? DEFAULT_AGENT_ID;
|
|
3698
3534
|
const renderers = copilotkit.renderActivityMessages;
|
|
3699
3535
|
const findRenderer = useCallback((activityType) => {
|
|
3700
3536
|
if (!renderers.length) return null;
|
|
@@ -3710,8 +3546,7 @@ function useRenderActivityMessage() {
|
|
|
3710
3546
|
return null;
|
|
3711
3547
|
}
|
|
3712
3548
|
const Component = renderer.render;
|
|
3713
|
-
const
|
|
3714
|
-
const agent = getThreadClone(registryAgent, config?.threadId) ?? registryAgent;
|
|
3549
|
+
const agent = copilotkit.getAgent(agentId);
|
|
3715
3550
|
return /* @__PURE__ */ jsx(Component, {
|
|
3716
3551
|
activityType: message.activityType,
|
|
3717
3552
|
content: parseResult.data,
|
|
@@ -3720,7 +3555,6 @@ function useRenderActivityMessage() {
|
|
|
3720
3555
|
}, message.id);
|
|
3721
3556
|
}, [
|
|
3722
3557
|
agentId,
|
|
3723
|
-
config?.threadId,
|
|
3724
3558
|
copilotkit,
|
|
3725
3559
|
findRenderer
|
|
3726
3560
|
]);
|
|
@@ -4160,6 +3994,118 @@ function useHumanInTheLoop(tool, deps) {
|
|
|
4160
3994
|
]);
|
|
4161
3995
|
}
|
|
4162
3996
|
|
|
3997
|
+
//#endregion
|
|
3998
|
+
//#region src/v2/hooks/use-agent.tsx
|
|
3999
|
+
let UseAgentUpdate = /* @__PURE__ */ function(UseAgentUpdate) {
|
|
4000
|
+
UseAgentUpdate["OnMessagesChanged"] = "OnMessagesChanged";
|
|
4001
|
+
UseAgentUpdate["OnStateChanged"] = "OnStateChanged";
|
|
4002
|
+
UseAgentUpdate["OnRunStatusChanged"] = "OnRunStatusChanged";
|
|
4003
|
+
return UseAgentUpdate;
|
|
4004
|
+
}({});
|
|
4005
|
+
const ALL_UPDATES = [
|
|
4006
|
+
UseAgentUpdate.OnMessagesChanged,
|
|
4007
|
+
UseAgentUpdate.OnStateChanged,
|
|
4008
|
+
UseAgentUpdate.OnRunStatusChanged
|
|
4009
|
+
];
|
|
4010
|
+
function useAgent({ agentId, updates, throttleMs } = {}) {
|
|
4011
|
+
agentId ??= DEFAULT_AGENT_ID;
|
|
4012
|
+
const { copilotkit } = useCopilotKit();
|
|
4013
|
+
const providerThrottleMs = copilotkit.defaultThrottleMs;
|
|
4014
|
+
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
|
4015
|
+
const updateFlags = useMemo(() => updates ?? ALL_UPDATES, [JSON.stringify(updates)]);
|
|
4016
|
+
const provisionalAgentCache = useRef(/* @__PURE__ */ new Map());
|
|
4017
|
+
const agent = useMemo(() => {
|
|
4018
|
+
const existing = copilotkit.getAgent(agentId);
|
|
4019
|
+
if (existing) {
|
|
4020
|
+
provisionalAgentCache.current.delete(agentId);
|
|
4021
|
+
return existing;
|
|
4022
|
+
}
|
|
4023
|
+
const isRuntimeConfigured = copilotkit.runtimeUrl !== void 0;
|
|
4024
|
+
const status = copilotkit.runtimeConnectionStatus;
|
|
4025
|
+
if (isRuntimeConfigured && (status === CopilotKitCoreRuntimeConnectionStatus.Disconnected || status === CopilotKitCoreRuntimeConnectionStatus.Connecting)) {
|
|
4026
|
+
const cached = provisionalAgentCache.current.get(agentId);
|
|
4027
|
+
if (cached) {
|
|
4028
|
+
cached.headers = { ...copilotkit.headers };
|
|
4029
|
+
return cached;
|
|
4030
|
+
}
|
|
4031
|
+
const provisional = new ProxiedCopilotRuntimeAgent({
|
|
4032
|
+
runtimeUrl: copilotkit.runtimeUrl,
|
|
4033
|
+
agentId,
|
|
4034
|
+
transport: copilotkit.runtimeTransport,
|
|
4035
|
+
runtimeMode: "pending"
|
|
4036
|
+
});
|
|
4037
|
+
provisional.headers = { ...copilotkit.headers };
|
|
4038
|
+
provisionalAgentCache.current.set(agentId, provisional);
|
|
4039
|
+
return provisional;
|
|
4040
|
+
}
|
|
4041
|
+
if (isRuntimeConfigured && status === CopilotKitCoreRuntimeConnectionStatus.Error) {
|
|
4042
|
+
const cached = provisionalAgentCache.current.get(agentId);
|
|
4043
|
+
if (cached) {
|
|
4044
|
+
cached.headers = { ...copilotkit.headers };
|
|
4045
|
+
return cached;
|
|
4046
|
+
}
|
|
4047
|
+
const provisional = new ProxiedCopilotRuntimeAgent({
|
|
4048
|
+
runtimeUrl: copilotkit.runtimeUrl,
|
|
4049
|
+
agentId,
|
|
4050
|
+
transport: copilotkit.runtimeTransport,
|
|
4051
|
+
runtimeMode: "pending"
|
|
4052
|
+
});
|
|
4053
|
+
provisional.headers = { ...copilotkit.headers };
|
|
4054
|
+
provisionalAgentCache.current.set(agentId, provisional);
|
|
4055
|
+
return provisional;
|
|
4056
|
+
}
|
|
4057
|
+
const knownAgents = Object.keys(copilotkit.agents ?? {});
|
|
4058
|
+
const runtimePart = isRuntimeConfigured ? `runtimeUrl=${copilotkit.runtimeUrl}` : "no runtimeUrl";
|
|
4059
|
+
throw new Error(`useAgent: Agent '${agentId}' 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.");
|
|
4060
|
+
}, [
|
|
4061
|
+
agentId,
|
|
4062
|
+
copilotkit.agents,
|
|
4063
|
+
copilotkit.runtimeConnectionStatus,
|
|
4064
|
+
copilotkit.runtimeUrl,
|
|
4065
|
+
copilotkit.runtimeTransport,
|
|
4066
|
+
JSON.stringify(copilotkit.headers)
|
|
4067
|
+
]);
|
|
4068
|
+
useEffect(() => {
|
|
4069
|
+
if (updateFlags.length === 0) return;
|
|
4070
|
+
let active = true;
|
|
4071
|
+
const handlers = {};
|
|
4072
|
+
let batchScheduled = false;
|
|
4073
|
+
const batchedForceUpdate = () => {
|
|
4074
|
+
if (!active) return;
|
|
4075
|
+
if (!batchScheduled) {
|
|
4076
|
+
batchScheduled = true;
|
|
4077
|
+
queueMicrotask(() => {
|
|
4078
|
+
batchScheduled = false;
|
|
4079
|
+
if (active) forceUpdate();
|
|
4080
|
+
});
|
|
4081
|
+
}
|
|
4082
|
+
};
|
|
4083
|
+
if (updateFlags.includes(UseAgentUpdate.OnMessagesChanged)) handlers.onMessagesChanged = forceUpdate;
|
|
4084
|
+
if (updateFlags.includes(UseAgentUpdate.OnStateChanged)) handlers.onStateChanged = batchedForceUpdate;
|
|
4085
|
+
if (updateFlags.includes(UseAgentUpdate.OnRunStatusChanged)) {
|
|
4086
|
+
handlers.onRunInitialized = batchedForceUpdate;
|
|
4087
|
+
handlers.onRunFinalized = batchedForceUpdate;
|
|
4088
|
+
handlers.onRunFailed = batchedForceUpdate;
|
|
4089
|
+
handlers.onRunErrorEvent = batchedForceUpdate;
|
|
4090
|
+
}
|
|
4091
|
+
const subscription = copilotkit.subscribeToAgentWithOptions(agent, handlers, { throttleMs });
|
|
4092
|
+
return () => {
|
|
4093
|
+
active = false;
|
|
4094
|
+
subscription.unsubscribe();
|
|
4095
|
+
};
|
|
4096
|
+
}, [
|
|
4097
|
+
agent,
|
|
4098
|
+
forceUpdate,
|
|
4099
|
+
throttleMs,
|
|
4100
|
+
providerThrottleMs,
|
|
4101
|
+
updateFlags
|
|
4102
|
+
]);
|
|
4103
|
+
useEffect(() => {
|
|
4104
|
+
if (agent instanceof HttpAgent) agent.headers = { ...copilotkit.headers };
|
|
4105
|
+
}, [agent, JSON.stringify(copilotkit.headers)]);
|
|
4106
|
+
return { agent };
|
|
4107
|
+
}
|
|
4108
|
+
|
|
4163
4109
|
//#endregion
|
|
4164
4110
|
//#region src/v2/hooks/use-capabilities.tsx
|
|
4165
4111
|
/**
|
|
@@ -5782,14 +5728,12 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
5782
5728
|
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
|
5783
5729
|
useEffect(() => {
|
|
5784
5730
|
if (!config?.agentId) return;
|
|
5785
|
-
const
|
|
5786
|
-
const agent = getThreadClone(registryAgent, config.threadId) ?? registryAgent;
|
|
5731
|
+
const agent = copilotkit.getAgent(config.agentId);
|
|
5787
5732
|
if (!agent) return;
|
|
5788
5733
|
const subscription = agent.subscribe({ onStateChanged: forceUpdate });
|
|
5789
5734
|
return () => subscription.unsubscribe();
|
|
5790
5735
|
}, [
|
|
5791
5736
|
config?.agentId,
|
|
5792
|
-
config?.threadId,
|
|
5793
5737
|
copilotkit,
|
|
5794
5738
|
forceUpdate
|
|
5795
5739
|
]);
|
|
@@ -6820,7 +6764,6 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
6820
6764
|
const hasExplicitThreadId = !!threadId || !!existingConfig?.hasExplicitThreadId;
|
|
6821
6765
|
const { agent } = useAgent({
|
|
6822
6766
|
agentId: resolvedAgentId,
|
|
6823
|
-
threadId: resolvedThreadId,
|
|
6824
6767
|
throttleMs
|
|
6825
6768
|
});
|
|
6826
6769
|
const { copilotkit } = useCopilotKit();
|
|
@@ -6862,6 +6805,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
6862
6805
|
let detached = false;
|
|
6863
6806
|
const connectAbortController = new AbortController();
|
|
6864
6807
|
if (agent instanceof HttpAgent) agent.abortController = connectAbortController;
|
|
6808
|
+
agent.threadId = resolvedThreadId;
|
|
6865
6809
|
const connect = async (agent) => {
|
|
6866
6810
|
try {
|
|
6867
6811
|
await copilotkit.connectAgent({ agent });
|
|
@@ -9802,5 +9746,5 @@ function validateProps(props) {
|
|
|
9802
9746
|
}
|
|
9803
9747
|
|
|
9804
9748
|
//#endregion
|
|
9805
|
-
export { CopilotKitProvider as $, CopilotChatSuggestionView as A, useConfigureSuggestions as B, CopilotChatToggleButton as C, CopilotChatView_default as D, CopilotChat as E, CopilotChatAssistantMessage_default as F,
|
|
9806
|
-
//# sourceMappingURL=copilotkit-
|
|
9749
|
+
export { CopilotKitProvider as $, CopilotChatSuggestionView as A, useConfigureSuggestions as B, CopilotChatToggleButton as C, CopilotChatView_default as D, CopilotChat as E, CopilotChatAssistantMessage_default as F, useHumanInTheLoop as G, useCapabilities as H, CopilotChatToolCallsView as I, useComponent as J, useDefaultRenderTool as K, useAttachments as L, CopilotChatReasoningMessage_default as M, CopilotChatUserMessage_default as N, CopilotChatAttachmentQueue as O, CopilotChatAttachmentRenderer as P, useRenderToolCall as Q, useThreads$1 as R, CopilotModalHeader as S, DefaultOpenIcon as T, UseAgentUpdate as U, useSuggestions as V, useAgent as W, useRenderActivityMessage as X, useFrontendTool as Y, useRenderCustomMessages as Z, WildcardToolCallRender as _, ThreadsProvider as a, SandboxFunctionsContext as at, CopilotPopupView as b, CoAgentStateRendersProvider as c, MCPAppsActivityRenderer as ct, shouldShowDevConsole as d, CopilotChatInput_default as dt, useCopilotKit as et, useToast as f, AudioRecorderError as ft, useCopilotContext as g, CopilotContext as h, useCopilotChatConfiguration as ht, ThreadsContext as i, createA2UIMessageRenderer as it, CopilotChatSuggestionPill as j, CopilotChatMessageView as k, useCoAgentStateRenders as l, MCPAppsActivityType as lt, useCopilotMessagesContext as m, CopilotChatConfigurationProvider as mt, defaultCopilotContextCategories as n, useAgentContext as nt, useThreads as o, useSandboxFunctions as ot, CopilotMessagesContext as p, CopilotChatAudioRecorder as pt, useRenderTool as q, CoAgentStateRenderBridge as r, defineToolCallRenderer as rt, CoAgentStateRendersContext as s, MCPAppsActivityContentSchema as st, CopilotKit as t, CopilotKitCoreReact as tt, useAsyncCallback as u, CopilotKitInspector as ut, CopilotPopup as v, DefaultCloseIcon as w, CopilotSidebarView as x, CopilotSidebar as y, useInterrupt as z };
|
|
9750
|
+
//# sourceMappingURL=copilotkit-B6kDTnFY.mjs.map
|