@copilotkit/react-core 1.59.5-canary.1781104893 → 1.60.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-CWGR3Ict.cjs → copilotkit-BTHcCAVQ.cjs} +68 -103
- package/dist/copilotkit-BTHcCAVQ.cjs.map +1 -0
- package/dist/{copilotkit-CD3EqiJ4.d.cts → copilotkit-C9ptuh-b.d.cts} +9 -35
- package/dist/{copilotkit-B83H_vWJ.d.mts.map → copilotkit-C9ptuh-b.d.cts.map} +1 -1
- package/dist/{copilotkit-DBOofUYQ.mjs → copilotkit-CV519nFv.mjs} +69 -104
- package/dist/copilotkit-CV519nFv.mjs.map +1 -0
- package/dist/{copilotkit-B83H_vWJ.d.mts → copilotkit-DvbI8G0d.d.mts} +9 -35
- package/dist/{copilotkit-CD3EqiJ4.d.cts.map → copilotkit-DvbI8G0d.d.mts.map} +1 -1
- package/dist/index.cjs +5 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -6
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -9
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +39 -49
- 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 +67 -102
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +6 -6
- package/skills/react-core/SKILL.md +5 -5
- package/skills/react-core/references/chat-components.md +2 -1
- package/skills/react-core/references/client-side-tools.md +1 -1
- package/skills/react-core/references/custom-message-renderers.md +8 -11
- package/skills/react-core/references/debug-mode.md +15 -15
- package/skills/react-core/references/provider-setup.md +45 -52
- package/skills/react-core/references/rendering-activity-messages.md +6 -12
- package/dist/copilotkit-CWGR3Ict.cjs.map +0 -1
- package/dist/copilotkit-DBOofUYQ.mjs.map +0 -1
|
@@ -3593,67 +3593,61 @@ function A2UIBuiltInToolCallRenderer() {
|
|
|
3593
3593
|
return null;
|
|
3594
3594
|
}
|
|
3595
3595
|
|
|
3596
|
-
//#endregion
|
|
3597
|
-
//#region src/v2/hooks/use-agent-context.tsx
|
|
3598
|
-
function useAgentContext(context) {
|
|
3599
|
-
const { description, value } = context;
|
|
3600
|
-
const { copilotkit } = useCopilotKit();
|
|
3601
|
-
const stringValue = (0, react.useMemo)(() => {
|
|
3602
|
-
if (typeof value === "string") return value;
|
|
3603
|
-
return JSON.stringify(value);
|
|
3604
|
-
}, [value]);
|
|
3605
|
-
(0, react.useLayoutEffect)(() => {
|
|
3606
|
-
if (!copilotkit) return;
|
|
3607
|
-
const id = copilotkit.addContext({
|
|
3608
|
-
description,
|
|
3609
|
-
value: stringValue
|
|
3610
|
-
});
|
|
3611
|
-
return () => {
|
|
3612
|
-
copilotkit.removeContext(id);
|
|
3613
|
-
};
|
|
3614
|
-
}, [
|
|
3615
|
-
description,
|
|
3616
|
-
stringValue,
|
|
3617
|
-
copilotkit
|
|
3618
|
-
]);
|
|
3619
|
-
}
|
|
3620
|
-
|
|
3621
3596
|
//#endregion
|
|
3622
3597
|
//#region src/v2/a2ui/A2UICatalogContext.tsx
|
|
3623
3598
|
/**
|
|
3624
3599
|
* Renders agent context describing the available A2UI catalog and custom components.
|
|
3625
3600
|
* Only mount this component when A2UI is enabled.
|
|
3626
3601
|
*
|
|
3602
|
+
* The entries are scoped to the agents the runtime applies A2UI to
|
|
3603
|
+
* (`copilotkit.a2uiAgents`, #5369), so agents outside that list don't receive
|
|
3604
|
+
* the catalog/schema/guidelines payload on their runs.
|
|
3605
|
+
*
|
|
3627
3606
|
* When `includeSchema` is true, the full component schemas (JSON Schema) are also
|
|
3628
3607
|
* sent as context using the same description key as the A2UI middleware, so the
|
|
3629
3608
|
* middleware can optionally overwrite it with a server-side schema.
|
|
3630
3609
|
*/
|
|
3631
3610
|
function A2UICatalogContext({ catalog, includeSchema }) {
|
|
3632
|
-
useAgentContext({
|
|
3633
|
-
description: "A2UI catalog capabilities: available catalog IDs and custom component definitions the client can render.",
|
|
3634
|
-
value: (0, _copilotkit_a2ui_renderer.buildCatalogContextValue)(catalog)
|
|
3635
|
-
});
|
|
3636
3611
|
const { copilotkit } = useCopilotKit();
|
|
3612
|
+
const capabilitiesValue = (0, react.useMemo)(() => (0, _copilotkit_a2ui_renderer.buildCatalogContextValue)(catalog), [catalog]);
|
|
3637
3613
|
const schemaValue = (0, react.useMemo)(() => includeSchema !== false ? JSON.stringify((0, _copilotkit_a2ui_renderer.extractCatalogComponentSchemas)(catalog)) : null, [catalog, includeSchema]);
|
|
3614
|
+
const a2uiAgentsKey = copilotkit?.a2uiAgents?.join(",");
|
|
3638
3615
|
(0, react.useLayoutEffect)(() => {
|
|
3639
|
-
if (!copilotkit
|
|
3616
|
+
if (!copilotkit) return;
|
|
3617
|
+
const agentIds = copilotkit.a2uiAgents;
|
|
3618
|
+
const scope = agentIds ? { agentIds } : {};
|
|
3640
3619
|
const ids = [];
|
|
3641
3620
|
ids.push(copilotkit.addContext({
|
|
3642
|
-
description:
|
|
3643
|
-
value:
|
|
3644
|
-
|
|
3645
|
-
ids.push(copilotkit.addContext({
|
|
3646
|
-
description: "A2UI generation guidelines — protocol rules, tool arguments, path rules, data model format, and form/two-way-binding instructions.",
|
|
3647
|
-
value: _copilotkit_shared.A2UI_DEFAULT_GENERATION_GUIDELINES
|
|
3648
|
-
}));
|
|
3649
|
-
ids.push(copilotkit.addContext({
|
|
3650
|
-
description: "A2UI design guidelines — visual design rules, component hierarchy tips, and action handler patterns.",
|
|
3651
|
-
value: _copilotkit_shared.A2UI_DEFAULT_DESIGN_GUIDELINES
|
|
3621
|
+
description: "A2UI catalog capabilities: available catalog IDs and custom component definitions the client can render.",
|
|
3622
|
+
value: capabilitiesValue,
|
|
3623
|
+
...scope
|
|
3652
3624
|
}));
|
|
3625
|
+
if (schemaValue) {
|
|
3626
|
+
ids.push(copilotkit.addContext({
|
|
3627
|
+
description: _copilotkit_a2ui_renderer.A2UI_SCHEMA_CONTEXT_DESCRIPTION,
|
|
3628
|
+
value: schemaValue,
|
|
3629
|
+
...scope
|
|
3630
|
+
}));
|
|
3631
|
+
ids.push(copilotkit.addContext({
|
|
3632
|
+
description: "A2UI generation guidelines — protocol rules, tool arguments, path rules, data model format, and form/two-way-binding instructions.",
|
|
3633
|
+
value: _copilotkit_shared.A2UI_DEFAULT_GENERATION_GUIDELINES,
|
|
3634
|
+
...scope
|
|
3635
|
+
}));
|
|
3636
|
+
ids.push(copilotkit.addContext({
|
|
3637
|
+
description: "A2UI design guidelines — visual design rules, component hierarchy tips, and action handler patterns.",
|
|
3638
|
+
value: _copilotkit_shared.A2UI_DEFAULT_DESIGN_GUIDELINES,
|
|
3639
|
+
...scope
|
|
3640
|
+
}));
|
|
3641
|
+
}
|
|
3653
3642
|
return () => {
|
|
3654
3643
|
for (const id of ids) copilotkit.removeContext(id);
|
|
3655
3644
|
};
|
|
3656
|
-
}, [
|
|
3645
|
+
}, [
|
|
3646
|
+
copilotkit,
|
|
3647
|
+
capabilitiesValue,
|
|
3648
|
+
schemaValue,
|
|
3649
|
+
a2uiAgentsKey
|
|
3650
|
+
]);
|
|
3657
3651
|
return null;
|
|
3658
3652
|
}
|
|
3659
3653
|
|
|
@@ -4406,6 +4400,31 @@ function useCapabilities(agentId) {
|
|
|
4406
4400
|
if (agent && "capabilities" in agent) return agent.capabilities;
|
|
4407
4401
|
}
|
|
4408
4402
|
|
|
4403
|
+
//#endregion
|
|
4404
|
+
//#region src/v2/hooks/use-agent-context.tsx
|
|
4405
|
+
function useAgentContext(context) {
|
|
4406
|
+
const { description, value } = context;
|
|
4407
|
+
const { copilotkit } = useCopilotKit();
|
|
4408
|
+
const stringValue = (0, react.useMemo)(() => {
|
|
4409
|
+
if (typeof value === "string") return value;
|
|
4410
|
+
return JSON.stringify(value);
|
|
4411
|
+
}, [value]);
|
|
4412
|
+
(0, react.useLayoutEffect)(() => {
|
|
4413
|
+
if (!copilotkit) return;
|
|
4414
|
+
const id = copilotkit.addContext({
|
|
4415
|
+
description,
|
|
4416
|
+
value: stringValue
|
|
4417
|
+
});
|
|
4418
|
+
return () => {
|
|
4419
|
+
copilotkit.removeContext(id);
|
|
4420
|
+
};
|
|
4421
|
+
}, [
|
|
4422
|
+
description,
|
|
4423
|
+
stringValue,
|
|
4424
|
+
copilotkit
|
|
4425
|
+
]);
|
|
4426
|
+
}
|
|
4427
|
+
|
|
4409
4428
|
//#endregion
|
|
4410
4429
|
//#region src/v2/hooks/use-suggestions.tsx
|
|
4411
4430
|
function useSuggestions({ agentId } = {}) {
|
|
@@ -6477,58 +6496,6 @@ function IntelligenceIndicator(props) {
|
|
|
6477
6496
|
//#endregion
|
|
6478
6497
|
//#region src/v2/components/chat/CopilotChatMessageView.tsx
|
|
6479
6498
|
/**
|
|
6480
|
-
* Builds a map of message.id → stable per-row React key for an entire message
|
|
6481
|
-
* list. A message's canonical `id` is not stable within a turn: some backends
|
|
6482
|
-
* re-key a message mid-stream (e.g. LangChain replaces its transient
|
|
6483
|
-
* `lc_run--…` streaming id with the provider's final `resp_…` id in the
|
|
6484
|
-
* MESSAGES_SNAPSHOT). Keying rows by `id` made React unmount/remount the row
|
|
6485
|
-
* on that swap — the visible HITL chat flash. Tool-call ids survive the
|
|
6486
|
-
* rename, so an assistant message anchored by a tool call is keyed by its
|
|
6487
|
-
* first tool-call id (`tc:<anchorToolCallId>`); everything else falls back to
|
|
6488
|
-
* `id`.
|
|
6489
|
-
*
|
|
6490
|
-
* Load-bearing assumption: this only helps when the first tool-call id itself
|
|
6491
|
-
* is stable across the rename; backends that re-key tool-call ids mid-stream
|
|
6492
|
-
* still remount.
|
|
6493
|
-
*
|
|
6494
|
-
* Collision rule: two distinct assistant messages can occasionally share a
|
|
6495
|
-
* first-tool-call id (e.g. due to upstream bugs or replayed state). First
|
|
6496
|
-
* occurrence (in list order) claims `tc:<id>`; later collisions fall back to
|
|
6497
|
-
* `message.id`. Every assigned key is checked against the claimed set, so
|
|
6498
|
-
* keys are unique even for pathological ids (e.g. a raw message id beginning
|
|
6499
|
-
* with "tc:"); collisions disambiguate with a deterministic numeric suffix.
|
|
6500
|
-
*
|
|
6501
|
-
* Precondition: callers must pass a deduplicated list (see
|
|
6502
|
-
* `deduplicateMessages`); duplicate message ids would silently overwrite map
|
|
6503
|
-
* entries.
|
|
6504
|
-
*
|
|
6505
|
-
* Order caveat: the collision rule is order-sensitive — if two messages
|
|
6506
|
-
* sharing a first tool-call id swap list positions across renders, the
|
|
6507
|
-
* claimant changes and both rows remount. Acceptable: that situation already
|
|
6508
|
-
* indicates an upstream id bug, and keys remain unique.
|
|
6509
|
-
*/
|
|
6510
|
-
function buildRowRenderKeys(messages) {
|
|
6511
|
-
const keys = /* @__PURE__ */ new Map();
|
|
6512
|
-
const claimed = /* @__PURE__ */ new Set();
|
|
6513
|
-
for (const message of messages) {
|
|
6514
|
-
let candidate;
|
|
6515
|
-
if (message.role === "assistant") {
|
|
6516
|
-
const anchorToolCallId = message.toolCalls?.[0]?.id;
|
|
6517
|
-
if (anchorToolCallId) candidate = `tc:${anchorToolCallId}`;
|
|
6518
|
-
}
|
|
6519
|
-
let assigned = message.id;
|
|
6520
|
-
if (candidate && !claimed.has(candidate)) assigned = candidate;
|
|
6521
|
-
else if (claimed.has(assigned)) {
|
|
6522
|
-
let n = 2;
|
|
6523
|
-
while (claimed.has(`${assigned}:${n}`)) n += 1;
|
|
6524
|
-
assigned = `${assigned}:${n}`;
|
|
6525
|
-
}
|
|
6526
|
-
keys.set(message.id, assigned);
|
|
6527
|
-
claimed.add(assigned);
|
|
6528
|
-
}
|
|
6529
|
-
return keys;
|
|
6530
|
-
}
|
|
6531
|
-
/**
|
|
6532
6499
|
* Resolves a slot value into a { Component, slotProps } pair, handling the three
|
|
6533
6500
|
* slot forms: a component type, a className string, or a partial-props object.
|
|
6534
6501
|
*/
|
|
@@ -6707,7 +6674,6 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
6707
6674
|
return copilotkit.getStateByRun(config.agentId, config.threadId, resolvedRunId);
|
|
6708
6675
|
};
|
|
6709
6676
|
const deduplicatedMessages = (0, react.useMemo)(() => deduplicateMessages(messages), [messages]);
|
|
6710
|
-
const rowRenderKeys = (0, react.useMemo)(() => buildRowRenderKeys(deduplicatedMessages), [deduplicatedMessages]);
|
|
6711
6677
|
if (process.env.NODE_ENV === "development" && deduplicatedMessages.length < messages.length) console.warn(`CopilotChatMessageView: Merged ${messages.length - deduplicatedMessages.length} message(s) with duplicate IDs.`);
|
|
6712
6678
|
const { Component: AssistantComponent, slotProps: assistantSlotProps } = (0, react.useMemo)(() => resolveSlotComponent(assistantMessage, CopilotChatAssistantMessage_default), [assistantMessage]);
|
|
6713
6679
|
const { Component: UserComponent, slotProps: userSlotProps } = (0, react.useMemo)(() => resolveSlotComponent(userMessage, CopilotChatUserMessage_default), [userMessage]);
|
|
@@ -6738,42 +6704,41 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
6738
6704
|
const renderMessageBlock = (message) => {
|
|
6739
6705
|
const elements = [];
|
|
6740
6706
|
const stateSnapshot = getStateSnapshotForMessage(message.id);
|
|
6741
|
-
const rowKey = rowRenderKeys.get(message.id) ?? message.id;
|
|
6742
6707
|
if (renderCustomMessage) elements.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemoizedCustomMessage, {
|
|
6743
6708
|
message,
|
|
6744
6709
|
position: "before",
|
|
6745
6710
|
renderCustomMessage,
|
|
6746
6711
|
stateSnapshot
|
|
6747
|
-
}, `${
|
|
6712
|
+
}, `${message.id}-custom-before`));
|
|
6748
6713
|
if (message.role === "assistant") elements.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemoizedAssistantMessage, {
|
|
6749
6714
|
message,
|
|
6750
6715
|
messages,
|
|
6751
6716
|
isRunning,
|
|
6752
6717
|
AssistantMessageComponent: AssistantComponent,
|
|
6753
6718
|
slotProps: assistantSlotProps
|
|
6754
|
-
},
|
|
6719
|
+
}, message.id));
|
|
6755
6720
|
else if (message.role === "user") elements.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemoizedUserMessage, {
|
|
6756
6721
|
message,
|
|
6757
6722
|
UserMessageComponent: UserComponent,
|
|
6758
6723
|
slotProps: userSlotProps
|
|
6759
|
-
},
|
|
6724
|
+
}, message.id));
|
|
6760
6725
|
else if (message.role === "activity") elements.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemoizedActivityMessage, {
|
|
6761
6726
|
message,
|
|
6762
6727
|
renderActivityMessage
|
|
6763
|
-
},
|
|
6728
|
+
}, message.id));
|
|
6764
6729
|
else if (message.role === "reasoning") elements.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemoizedReasoningMessage, {
|
|
6765
6730
|
message,
|
|
6766
6731
|
messages,
|
|
6767
6732
|
isRunning,
|
|
6768
6733
|
ReasoningMessageComponent: ReasoningComponent,
|
|
6769
6734
|
slotProps: reasoningSlotProps
|
|
6770
|
-
},
|
|
6735
|
+
}, message.id));
|
|
6771
6736
|
if (renderCustomMessage) elements.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemoizedCustomMessage, {
|
|
6772
6737
|
message,
|
|
6773
6738
|
position: "after",
|
|
6774
6739
|
renderCustomMessage,
|
|
6775
6740
|
stateSnapshot
|
|
6776
|
-
}, `${
|
|
6741
|
+
}, `${message.id}-custom-after`));
|
|
6777
6742
|
const intelligenceTurnId = intelligenceTurnAnchors.get(message.id);
|
|
6778
6743
|
if (intelligenceTurnId !== void 0) elements.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(IntelligenceIndicator, {
|
|
6779
6744
|
message,
|
|
@@ -6819,7 +6784,7 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
6819
6784
|
transform: `translateY(${virtualItem.start}px)`
|
|
6820
6785
|
},
|
|
6821
6786
|
children: renderMessageBlock(message)
|
|
6822
|
-
},
|
|
6787
|
+
}, message.id);
|
|
6823
6788
|
})
|
|
6824
6789
|
}) : messageElements,
|
|
6825
6790
|
interruptElement,
|
|
@@ -11211,4 +11176,4 @@ Object.defineProperty(exports, 'useToast', {
|
|
|
11211
11176
|
return useToast;
|
|
11212
11177
|
}
|
|
11213
11178
|
});
|
|
11214
|
-
//# sourceMappingURL=copilotkit-
|
|
11179
|
+
//# sourceMappingURL=copilotkit-BTHcCAVQ.cjs.map
|