@copilotkit/react-core 1.68.3-canary.1787220377 → 1.69.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-EFunREg5.cjs → copilotkit-DOMr3DRO.cjs} +26 -78
- package/dist/copilotkit-DOMr3DRO.cjs.map +1 -0
- package/dist/{copilotkit-B1K0Tgnz.d.cts → copilotkit-DYM5ChMS.d.cts} +8 -35
- package/dist/copilotkit-DYM5ChMS.d.cts.map +1 -0
- package/dist/{copilotkit-CZjzQPdq.d.mts → copilotkit-pkDPhwkR.d.mts} +8 -35
- package/dist/copilotkit-pkDPhwkR.d.mts.map +1 -0
- package/dist/{copilotkit-DT2FmOwK.mjs → copilotkit-ykQW_VJZ.mjs} +27 -73
- package/dist/copilotkit-ykQW_VJZ.mjs.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 +0 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/index.cjs +1 -2
- 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 +25 -72
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +8 -8
- package/skills/react-core/SKILL.md +1 -1
- package/skills/react-core/references/provider-setup.md +22 -1
- package/skills/react-core/references/threads.md +1 -2
- package/dist/copilotkit-B1K0Tgnz.d.cts.map +0 -1
- package/dist/copilotkit-CZjzQPdq.d.mts.map +0 -1
- package/dist/copilotkit-DT2FmOwK.mjs.map +0 -1
- package/dist/copilotkit-EFunREg5.cjs.map +0 -1
|
@@ -4643,75 +4643,6 @@ function useAgent({ agentId, threadId, runtimeAgentId, updates, throttleMs } = {
|
|
|
4643
4643
|
};
|
|
4644
4644
|
}
|
|
4645
4645
|
|
|
4646
|
-
//#endregion
|
|
4647
|
-
//#region src/v2/hooks/use-subagent.tsx
|
|
4648
|
-
const warnedAmbiguousNames = /* @__PURE__ */ new Set();
|
|
4649
|
-
function resolveSubagent(subagents, subagentRunId, subagentName) {
|
|
4650
|
-
if (subagentRunId) {
|
|
4651
|
-
const match = subagents[subagentRunId];
|
|
4652
|
-
return match ? { ...match } : void 0;
|
|
4653
|
-
}
|
|
4654
|
-
if (subagentName) {
|
|
4655
|
-
const matches = Object.values(subagents).filter((s) => s.name === subagentName);
|
|
4656
|
-
if (matches.length === 0) return;
|
|
4657
|
-
const chosen = matches[matches.length - 1];
|
|
4658
|
-
return matches.length > 1 ? {
|
|
4659
|
-
...chosen,
|
|
4660
|
-
isAmbiguous: true,
|
|
4661
|
-
matchCount: matches.length
|
|
4662
|
-
} : { ...chosen };
|
|
4663
|
-
}
|
|
4664
|
-
}
|
|
4665
|
-
/**
|
|
4666
|
-
* Read a subagent's live lifecycle state (name, description, running status)
|
|
4667
|
-
* from the CopilotKit core subagent registry, by id or by declared name.
|
|
4668
|
-
*
|
|
4669
|
-
* @example
|
|
4670
|
-
* const sub = useSubagent({ subagentRunId: message.subagentRunId });
|
|
4671
|
-
* // sub?.name, sub?.description, sub?.status
|
|
4672
|
-
*/
|
|
4673
|
-
function useSubagent(params) {
|
|
4674
|
-
const { subagentRunId, subagentName, agentId } = params;
|
|
4675
|
-
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
4676
|
-
const config = useCopilotChatConfiguration();
|
|
4677
|
-
const resolvedAgentId = (0, react.useMemo)(() => agentId ?? config?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID, [agentId, config?.agentId]);
|
|
4678
|
-
const [subagent, setSubagent] = (0, react.useState)(() => resolveSubagent(copilotkit.getSubagents(resolvedAgentId), subagentRunId, subagentName));
|
|
4679
|
-
(0, react.useEffect)(() => {
|
|
4680
|
-
setSubagent(resolveSubagent(copilotkit.getSubagents(resolvedAgentId), subagentRunId, subagentName));
|
|
4681
|
-
}, [
|
|
4682
|
-
copilotkit,
|
|
4683
|
-
resolvedAgentId,
|
|
4684
|
-
subagentRunId,
|
|
4685
|
-
subagentName
|
|
4686
|
-
]);
|
|
4687
|
-
(0, react.useEffect)(() => {
|
|
4688
|
-
const subscription = copilotkit.subscribe({ onSubagentsChanged: ({ agentId: changedAgentId, subagents }) => {
|
|
4689
|
-
if (changedAgentId !== resolvedAgentId) return;
|
|
4690
|
-
setSubagent(resolveSubagent(subagents, subagentRunId, subagentName));
|
|
4691
|
-
} });
|
|
4692
|
-
return () => {
|
|
4693
|
-
subscription.unsubscribe();
|
|
4694
|
-
};
|
|
4695
|
-
}, [
|
|
4696
|
-
copilotkit,
|
|
4697
|
-
resolvedAgentId,
|
|
4698
|
-
subagentRunId,
|
|
4699
|
-
subagentName
|
|
4700
|
-
]);
|
|
4701
|
-
(0, react.useEffect)(() => {
|
|
4702
|
-
if (process.env.NODE_ENV === "production" || !subagentName || !subagent?.isAmbiguous) return;
|
|
4703
|
-
const key = `${subagentName}:${subagent.matchCount}`;
|
|
4704
|
-
if (warnedAmbiguousNames.has(key)) return;
|
|
4705
|
-
warnedAmbiguousNames.add(key);
|
|
4706
|
-
console.warn(`[CopilotKit] useSubagent({ subagentName: ${JSON.stringify(subagentName)} }) matched ${subagent.matchCount} subagents. Returning the most recently started one; pass a subagentRunId for a stable reference.`);
|
|
4707
|
-
}, [
|
|
4708
|
-
subagentName,
|
|
4709
|
-
subagent?.isAmbiguous,
|
|
4710
|
-
subagent?.matchCount
|
|
4711
|
-
]);
|
|
4712
|
-
return subagent;
|
|
4713
|
-
}
|
|
4714
|
-
|
|
4715
4646
|
//#endregion
|
|
4716
4647
|
//#region src/v2/hooks/use-capabilities.tsx
|
|
4717
4648
|
/**
|
|
@@ -7394,6 +7325,30 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
7394
7325
|
const deduplicatedMessages = (0, react.useMemo)(() => deduplicateMessages(messages), [messages]);
|
|
7395
7326
|
if (process.env.NODE_ENV === "development" && deduplicatedMessages.length < messages.length) console.warn(`CopilotChatMessageView: Merged ${messages.length - deduplicatedMessages.length} message(s) with duplicate IDs.`);
|
|
7396
7327
|
const { Component: AssistantComponent, slotProps: assistantSlotProps } = (0, react.useMemo)(() => resolveSlotComponent(assistantMessage, CopilotChatAssistantMessage_default), [assistantMessage]);
|
|
7328
|
+
const agentId = config?.agentId;
|
|
7329
|
+
const threadId = config?.threadId;
|
|
7330
|
+
const assistantSlotPropsWithFeedback = (0, react.useMemo)(() => {
|
|
7331
|
+
const onThumbsUp = assistantSlotProps?.onThumbsUp;
|
|
7332
|
+
const onThumbsDown = assistantSlotProps?.onThumbsDown;
|
|
7333
|
+
if (!onThumbsUp && !onThumbsDown) return assistantSlotProps;
|
|
7334
|
+
const withRawEvent = (message) => {
|
|
7335
|
+
const rawEvent = agentId === void 0 || threadId === void 0 ? void 0 : copilotkit.getRawEventForMessage(agentId, threadId, message.id);
|
|
7336
|
+
return rawEvent === void 0 ? message : {
|
|
7337
|
+
...message,
|
|
7338
|
+
rawEvent
|
|
7339
|
+
};
|
|
7340
|
+
};
|
|
7341
|
+
return {
|
|
7342
|
+
...assistantSlotProps,
|
|
7343
|
+
...onThumbsUp && { onThumbsUp: (message) => onThumbsUp(withRawEvent(message)) },
|
|
7344
|
+
...onThumbsDown && { onThumbsDown: (message) => onThumbsDown(withRawEvent(message)) }
|
|
7345
|
+
};
|
|
7346
|
+
}, [
|
|
7347
|
+
assistantSlotProps,
|
|
7348
|
+
agentId,
|
|
7349
|
+
threadId,
|
|
7350
|
+
copilotkit
|
|
7351
|
+
]);
|
|
7397
7352
|
const { Component: UserComponent, slotProps: userSlotProps } = (0, react.useMemo)(() => resolveSlotComponent(userMessage, CopilotChatUserMessage_default), [userMessage]);
|
|
7398
7353
|
const { Component: ReasoningComponent, slotProps: reasoningSlotProps } = (0, react.useMemo)(() => resolveSlotComponent(reasoningMessage, CopilotChatReasoningMessage_default), [reasoningMessage]);
|
|
7399
7354
|
const scrollElementFromCtx = (0, react.useContext)(ScrollElementContext);
|
|
@@ -7433,7 +7388,7 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
7433
7388
|
messages,
|
|
7434
7389
|
isRunning,
|
|
7435
7390
|
AssistantMessageComponent: AssistantComponent,
|
|
7436
|
-
slotProps:
|
|
7391
|
+
slotProps: assistantSlotPropsWithFeedback
|
|
7437
7392
|
}, message.id));
|
|
7438
7393
|
else if (message.role === "user") elements.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemoizedUserMessage, {
|
|
7439
7394
|
message,
|
|
@@ -11548,7 +11503,6 @@ function CopilotKit({ children, ...props }) {
|
|
|
11548
11503
|
...v2Props,
|
|
11549
11504
|
showDevConsole: showInspector,
|
|
11550
11505
|
renderCustomMessages: renderArr,
|
|
11551
|
-
useSingleEndpoint: props.useSingleEndpoint ?? true,
|
|
11552
11506
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitInternal, {
|
|
11553
11507
|
...props,
|
|
11554
11508
|
children
|
|
@@ -12509,12 +12463,6 @@ Object.defineProperty(exports, 'useSandboxFunctions', {
|
|
|
12509
12463
|
return useSandboxFunctions;
|
|
12510
12464
|
}
|
|
12511
12465
|
});
|
|
12512
|
-
Object.defineProperty(exports, 'useSubagent', {
|
|
12513
|
-
enumerable: true,
|
|
12514
|
-
get: function () {
|
|
12515
|
-
return useSubagent;
|
|
12516
|
-
}
|
|
12517
|
-
});
|
|
12518
12466
|
Object.defineProperty(exports, 'useSuggestions', {
|
|
12519
12467
|
enumerable: true,
|
|
12520
12468
|
get: function () {
|
|
@@ -12545,4 +12493,4 @@ Object.defineProperty(exports, 'ɵrunMcpFollowUp', {
|
|
|
12545
12493
|
return ɵrunMcpFollowUp;
|
|
12546
12494
|
}
|
|
12547
12495
|
});
|
|
12548
|
-
//# sourceMappingURL=copilotkit-
|
|
12496
|
+
//# sourceMappingURL=copilotkit-DOMr3DRO.cjs.map
|