@copilotkit/react-core 1.70.3 → 1.71.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-BU3OvveB.cjs → copilotkit-B4Jb1QEy.cjs} +365 -153
- package/dist/copilotkit-B4Jb1QEy.cjs.map +1 -0
- package/dist/{copilotkit-Bs98akp9.d.mts → copilotkit-ChjzWqn6.d.mts} +33 -8
- package/dist/copilotkit-ChjzWqn6.d.mts.map +1 -0
- package/dist/{copilotkit-X2eGbOwf.d.cts → copilotkit-DCIXZawe.d.cts} +33 -8
- package/dist/copilotkit-DCIXZawe.d.cts.map +1 -0
- package/dist/{copilotkit-Ap_yisA5.mjs → copilotkit-snbJkMqQ.mjs} +364 -152
- package/dist/copilotkit-snbJkMqQ.mjs.map +1 -0
- package/dist/index.cjs +3 -3
- 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 +4 -4
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +176 -138
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/context.cjs +4 -0
- package/dist/v2/context.cjs.map +1 -1
- package/dist/v2/context.d.cts +3 -1
- package/dist/v2/context.d.cts.map +1 -1
- package/dist/v2/context.d.mts +3 -1
- package/dist/v2/context.d.mts.map +1 -1
- package/dist/v2/context.mjs +3 -1
- package/dist/v2/context.mjs.map +1 -1
- package/dist/v2/headless.cjs +16 -4
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts +9 -4
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts +9 -4
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +17 -5
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.css +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 +491 -277
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +7 -7
- package/skills/react-core/SKILL.md +1 -1
- package/skills/react-core/references/agent-access.md +69 -26
- package/skills/react-core/references/chat-components.md +22 -5
- package/dist/copilotkit-Ap_yisA5.mjs.map +0 -1
- package/dist/copilotkit-BU3OvveB.cjs.map +0 -1
- package/dist/copilotkit-Bs98akp9.d.mts.map +0 -1
- package/dist/copilotkit-X2eGbOwf.d.cts.map +0 -1
package/dist/v2/index.umd.js
CHANGED
|
@@ -37,6 +37,134 @@ react = __toESM(react);
|
|
|
37
37
|
_radix_ui_react_tooltip = __toESM(_radix_ui_react_tooltip);
|
|
38
38
|
_radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
39
39
|
|
|
40
|
+
//#region src/v2/lib/react-core.ts
|
|
41
|
+
var CopilotKitCoreReact = class extends _copilotkit_core.CopilotKitCore {
|
|
42
|
+
constructor(config) {
|
|
43
|
+
super(config);
|
|
44
|
+
this._renderToolCalls = [];
|
|
45
|
+
this._hookRenderToolCalls = /* @__PURE__ */ new Map();
|
|
46
|
+
this._cachedMergedRenderToolCalls = null;
|
|
47
|
+
this._renderCustomMessages = [];
|
|
48
|
+
this._renderActivityMessages = [];
|
|
49
|
+
this._interruptElement = null;
|
|
50
|
+
this._renderToolCalls = config.renderToolCalls ?? [];
|
|
51
|
+
this._renderCustomMessages = config.renderCustomMessages ?? [];
|
|
52
|
+
this._renderActivityMessages = config.renderActivityMessages ?? [];
|
|
53
|
+
}
|
|
54
|
+
get renderCustomMessages() {
|
|
55
|
+
return this._renderCustomMessages;
|
|
56
|
+
}
|
|
57
|
+
get renderActivityMessages() {
|
|
58
|
+
return this._renderActivityMessages;
|
|
59
|
+
}
|
|
60
|
+
get renderToolCalls() {
|
|
61
|
+
if (this._hookRenderToolCalls.size === 0) return this._renderToolCalls;
|
|
62
|
+
if (this._cachedMergedRenderToolCalls) return this._cachedMergedRenderToolCalls;
|
|
63
|
+
const merged = /* @__PURE__ */ new Map();
|
|
64
|
+
for (const rc of this._renderToolCalls) merged.set(`${rc.agentId ?? ""}:${rc.name}`, rc);
|
|
65
|
+
for (const [key, rc] of this._hookRenderToolCalls) merged.set(key, rc);
|
|
66
|
+
this._cachedMergedRenderToolCalls = Array.from(merged.values());
|
|
67
|
+
return this._cachedMergedRenderToolCalls;
|
|
68
|
+
}
|
|
69
|
+
setRenderActivityMessages(renderers) {
|
|
70
|
+
this._renderActivityMessages = renderers;
|
|
71
|
+
}
|
|
72
|
+
setRenderCustomMessages(renderers) {
|
|
73
|
+
this._renderCustomMessages = renderers;
|
|
74
|
+
}
|
|
75
|
+
setRenderToolCalls(renderToolCalls) {
|
|
76
|
+
this._renderToolCalls = renderToolCalls;
|
|
77
|
+
this._cachedMergedRenderToolCalls = null;
|
|
78
|
+
this._notifyRenderToolCallsChanged();
|
|
79
|
+
}
|
|
80
|
+
addHookRenderToolCall(entry) {
|
|
81
|
+
const key = `${entry.agentId ?? ""}:${entry.name}`;
|
|
82
|
+
this._hookRenderToolCalls.set(key, entry);
|
|
83
|
+
this._cachedMergedRenderToolCalls = null;
|
|
84
|
+
this._notifyRenderToolCallsChanged();
|
|
85
|
+
}
|
|
86
|
+
removeHookRenderToolCall(name, agentId) {
|
|
87
|
+
const key = `${agentId ?? ""}:${name}`;
|
|
88
|
+
if (this._hookRenderToolCalls.delete(key)) {
|
|
89
|
+
this._cachedMergedRenderToolCalls = null;
|
|
90
|
+
this._notifyRenderToolCallsChanged();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
_notifyRenderToolCallsChanged() {
|
|
94
|
+
this.notifySubscribers((subscriber) => {
|
|
95
|
+
const reactSubscriber = subscriber;
|
|
96
|
+
if (reactSubscriber.onRenderToolCallsChanged) reactSubscriber.onRenderToolCallsChanged({
|
|
97
|
+
copilotkit: this,
|
|
98
|
+
renderToolCalls: this.renderToolCalls
|
|
99
|
+
});
|
|
100
|
+
}, "Subscriber onRenderToolCallsChanged error:");
|
|
101
|
+
}
|
|
102
|
+
get interruptElement() {
|
|
103
|
+
return this._interruptElement;
|
|
104
|
+
}
|
|
105
|
+
setInterruptElement(element) {
|
|
106
|
+
this._interruptElement = element;
|
|
107
|
+
this.notifySubscribers((subscriber) => {
|
|
108
|
+
subscriber.onInterruptElementChanged?.({
|
|
109
|
+
copilotkit: this,
|
|
110
|
+
interruptElement: this._interruptElement
|
|
111
|
+
});
|
|
112
|
+
}, "Subscriber onInterruptElementChanged error:");
|
|
113
|
+
}
|
|
114
|
+
subscribe(subscriber) {
|
|
115
|
+
return super.subscribe(subscriber);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Wait for pending React state updates before the follow-up agent run.
|
|
119
|
+
*
|
|
120
|
+
* When a frontend tool handler calls setState(), React 18 batches the update
|
|
121
|
+
* and schedules a commit via its internal scheduler (MessageChannel). The
|
|
122
|
+
* useAgentContext hook registers context via useLayoutEffect, which runs
|
|
123
|
+
* synchronously after React commits that batch.
|
|
124
|
+
*
|
|
125
|
+
* Awaiting a zero-delay timeout yields to the macrotask queue. React's
|
|
126
|
+
* MessageChannel task runs first, committing the pending state and running
|
|
127
|
+
* useLayoutEffect (which updates the context store). The follow-up runAgent
|
|
128
|
+
* call then reads fresh context.
|
|
129
|
+
*/
|
|
130
|
+
async waitForPendingFrameworkUpdates() {
|
|
131
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/v2/context.ts
|
|
137
|
+
const CopilotKitContext = (0, react.createContext)(null);
|
|
138
|
+
const useCopilotKit = () => {
|
|
139
|
+
const context = (0, react.useContext)(CopilotKitContext);
|
|
140
|
+
const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
|
|
141
|
+
if (!context) throw new Error("useCopilotKit must be used within CopilotKitProvider");
|
|
142
|
+
(0, react.useEffect)(() => {
|
|
143
|
+
const subscription = context.copilotkit.subscribe({
|
|
144
|
+
onRuntimeConnectionStatusChanged: () => {
|
|
145
|
+
forceUpdate();
|
|
146
|
+
},
|
|
147
|
+
onHeadersChanged: () => {
|
|
148
|
+
forceUpdate();
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
return () => {
|
|
152
|
+
subscription.unsubscribe();
|
|
153
|
+
};
|
|
154
|
+
}, []);
|
|
155
|
+
return context;
|
|
156
|
+
};
|
|
157
|
+
const LicenseContext = (0, react.createContext)({
|
|
158
|
+
status: null,
|
|
159
|
+
license: null,
|
|
160
|
+
checkFeature: () => true,
|
|
161
|
+
getLimit: () => null
|
|
162
|
+
});
|
|
163
|
+
const useLicenseContext = () => (0, react.useContext)(LicenseContext);
|
|
164
|
+
const CopilotKitAgentIdContext = (0, react.createContext)(void 0);
|
|
165
|
+
const useDefaultAgentId = () => (0, react.useContext)(CopilotKitAgentIdContext);
|
|
166
|
+
|
|
167
|
+
//#endregion
|
|
40
168
|
//#region src/v2/lib/shallow-stable-ref.ts
|
|
41
169
|
/**
|
|
42
170
|
* Shallow equality comparison for objects.
|
|
@@ -91,7 +219,12 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
91
219
|
assistantMessageToolbarCopyCodeCopiedLabel: "Copied",
|
|
92
220
|
assistantMessageToolbarCopyMessageLabel: "Copy",
|
|
93
221
|
assistantMessageToolbarInspectorLabel: "View in Inspector",
|
|
94
|
-
|
|
222
|
+
assistantMessageToolbarInspectorDescription: "Open this message in the Inspector",
|
|
223
|
+
assistantMessageToolbarInspectorLocalOnlyLabel: "Local only",
|
|
224
|
+
assistantMessageToolbarInspectorLocalOnlyDescription: "Only visible on localhost or loopback hosts in development. Never shown in production.",
|
|
225
|
+
assistantMessageToolbarInspectorTitle: "CopilotKit Inspector",
|
|
226
|
+
assistantMessageToolbarInspectorHideLabel: "Hide this icon",
|
|
227
|
+
assistantMessageToolbarInspectorHideDescription: "Until you reload this page",
|
|
95
228
|
assistantMessageToolbarThumbsUpLabel: "Good response",
|
|
96
229
|
assistantMessageToolbarThumbsDownLabel: "Bad response",
|
|
97
230
|
assistantMessageToolbarReadAloudLabel: "Read aloud",
|
|
@@ -132,7 +265,8 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
132
265
|
...parentConfig?.labels,
|
|
133
266
|
...stableLabels
|
|
134
267
|
}), [stableLabels, parentConfig?.labels]);
|
|
135
|
-
const
|
|
268
|
+
const providerAgentId = useDefaultAgentId();
|
|
269
|
+
const resolvedAgentId = agentId ?? parentConfig?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
136
270
|
const threadIdPropIsAuthoritative = threadId !== void 0 && hasExplicitThreadId !== false;
|
|
137
271
|
const isThreadIdControlled = threadIdPropIsAuthoritative;
|
|
138
272
|
const [activeThreadOverride, setActiveThreadOverride] = (0, react.useState)(null);
|
|
@@ -342,9 +476,9 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
342
476
|
|
|
343
477
|
//#endregion
|
|
344
478
|
//#region src/v2/lib/utils.ts
|
|
345
|
-
const twMerge$
|
|
479
|
+
const twMerge$10 = (0, tailwind_merge.extendTailwindMerge)({ prefix: "cpk" });
|
|
346
480
|
function cn(...inputs) {
|
|
347
|
-
return twMerge$
|
|
481
|
+
return twMerge$10((0, clsx.clsx)(inputs));
|
|
348
482
|
}
|
|
349
483
|
|
|
350
484
|
//#endregion
|
|
@@ -489,6 +623,14 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
489
623
|
...props
|
|
490
624
|
});
|
|
491
625
|
}
|
|
626
|
+
function DropdownMenuLabel({ className, inset, ...props }) {
|
|
627
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.Label, {
|
|
628
|
+
"data-slot": "dropdown-menu-label",
|
|
629
|
+
"data-inset": inset,
|
|
630
|
+
className: cn("cpk:px-2 cpk:py-1.5 cpk:text-sm cpk:font-medium cpk:data-[inset]:pl-8", className),
|
|
631
|
+
...props
|
|
632
|
+
});
|
|
633
|
+
}
|
|
492
634
|
function DropdownMenuSeparator({ className, ...props }) {
|
|
493
635
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.Separator, {
|
|
494
636
|
"data-slot": "dropdown-menu-separator",
|
|
@@ -1494,132 +1636,6 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
1494
1636
|
}, []);
|
|
1495
1637
|
}
|
|
1496
1638
|
|
|
1497
|
-
//#endregion
|
|
1498
|
-
//#region src/v2/lib/react-core.ts
|
|
1499
|
-
var CopilotKitCoreReact = class extends _copilotkit_core.CopilotKitCore {
|
|
1500
|
-
constructor(config) {
|
|
1501
|
-
super(config);
|
|
1502
|
-
this._renderToolCalls = [];
|
|
1503
|
-
this._hookRenderToolCalls = /* @__PURE__ */ new Map();
|
|
1504
|
-
this._cachedMergedRenderToolCalls = null;
|
|
1505
|
-
this._renderCustomMessages = [];
|
|
1506
|
-
this._renderActivityMessages = [];
|
|
1507
|
-
this._interruptElement = null;
|
|
1508
|
-
this._renderToolCalls = config.renderToolCalls ?? [];
|
|
1509
|
-
this._renderCustomMessages = config.renderCustomMessages ?? [];
|
|
1510
|
-
this._renderActivityMessages = config.renderActivityMessages ?? [];
|
|
1511
|
-
}
|
|
1512
|
-
get renderCustomMessages() {
|
|
1513
|
-
return this._renderCustomMessages;
|
|
1514
|
-
}
|
|
1515
|
-
get renderActivityMessages() {
|
|
1516
|
-
return this._renderActivityMessages;
|
|
1517
|
-
}
|
|
1518
|
-
get renderToolCalls() {
|
|
1519
|
-
if (this._hookRenderToolCalls.size === 0) return this._renderToolCalls;
|
|
1520
|
-
if (this._cachedMergedRenderToolCalls) return this._cachedMergedRenderToolCalls;
|
|
1521
|
-
const merged = /* @__PURE__ */ new Map();
|
|
1522
|
-
for (const rc of this._renderToolCalls) merged.set(`${rc.agentId ?? ""}:${rc.name}`, rc);
|
|
1523
|
-
for (const [key, rc] of this._hookRenderToolCalls) merged.set(key, rc);
|
|
1524
|
-
this._cachedMergedRenderToolCalls = Array.from(merged.values());
|
|
1525
|
-
return this._cachedMergedRenderToolCalls;
|
|
1526
|
-
}
|
|
1527
|
-
setRenderActivityMessages(renderers) {
|
|
1528
|
-
this._renderActivityMessages = renderers;
|
|
1529
|
-
}
|
|
1530
|
-
setRenderCustomMessages(renderers) {
|
|
1531
|
-
this._renderCustomMessages = renderers;
|
|
1532
|
-
}
|
|
1533
|
-
setRenderToolCalls(renderToolCalls) {
|
|
1534
|
-
this._renderToolCalls = renderToolCalls;
|
|
1535
|
-
this._cachedMergedRenderToolCalls = null;
|
|
1536
|
-
this._notifyRenderToolCallsChanged();
|
|
1537
|
-
}
|
|
1538
|
-
addHookRenderToolCall(entry) {
|
|
1539
|
-
const key = `${entry.agentId ?? ""}:${entry.name}`;
|
|
1540
|
-
this._hookRenderToolCalls.set(key, entry);
|
|
1541
|
-
this._cachedMergedRenderToolCalls = null;
|
|
1542
|
-
this._notifyRenderToolCallsChanged();
|
|
1543
|
-
}
|
|
1544
|
-
removeHookRenderToolCall(name, agentId) {
|
|
1545
|
-
const key = `${agentId ?? ""}:${name}`;
|
|
1546
|
-
if (this._hookRenderToolCalls.delete(key)) {
|
|
1547
|
-
this._cachedMergedRenderToolCalls = null;
|
|
1548
|
-
this._notifyRenderToolCallsChanged();
|
|
1549
|
-
}
|
|
1550
|
-
}
|
|
1551
|
-
_notifyRenderToolCallsChanged() {
|
|
1552
|
-
this.notifySubscribers((subscriber) => {
|
|
1553
|
-
const reactSubscriber = subscriber;
|
|
1554
|
-
if (reactSubscriber.onRenderToolCallsChanged) reactSubscriber.onRenderToolCallsChanged({
|
|
1555
|
-
copilotkit: this,
|
|
1556
|
-
renderToolCalls: this.renderToolCalls
|
|
1557
|
-
});
|
|
1558
|
-
}, "Subscriber onRenderToolCallsChanged error:");
|
|
1559
|
-
}
|
|
1560
|
-
get interruptElement() {
|
|
1561
|
-
return this._interruptElement;
|
|
1562
|
-
}
|
|
1563
|
-
setInterruptElement(element) {
|
|
1564
|
-
this._interruptElement = element;
|
|
1565
|
-
this.notifySubscribers((subscriber) => {
|
|
1566
|
-
subscriber.onInterruptElementChanged?.({
|
|
1567
|
-
copilotkit: this,
|
|
1568
|
-
interruptElement: this._interruptElement
|
|
1569
|
-
});
|
|
1570
|
-
}, "Subscriber onInterruptElementChanged error:");
|
|
1571
|
-
}
|
|
1572
|
-
subscribe(subscriber) {
|
|
1573
|
-
return super.subscribe(subscriber);
|
|
1574
|
-
}
|
|
1575
|
-
/**
|
|
1576
|
-
* Wait for pending React state updates before the follow-up agent run.
|
|
1577
|
-
*
|
|
1578
|
-
* When a frontend tool handler calls setState(), React 18 batches the update
|
|
1579
|
-
* and schedules a commit via its internal scheduler (MessageChannel). The
|
|
1580
|
-
* useAgentContext hook registers context via useLayoutEffect, which runs
|
|
1581
|
-
* synchronously after React commits that batch.
|
|
1582
|
-
*
|
|
1583
|
-
* Awaiting a zero-delay timeout yields to the macrotask queue. React's
|
|
1584
|
-
* MessageChannel task runs first, committing the pending state and running
|
|
1585
|
-
* useLayoutEffect (which updates the context store). The follow-up runAgent
|
|
1586
|
-
* call then reads fresh context.
|
|
1587
|
-
*/
|
|
1588
|
-
async waitForPendingFrameworkUpdates() {
|
|
1589
|
-
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
1590
|
-
}
|
|
1591
|
-
};
|
|
1592
|
-
|
|
1593
|
-
//#endregion
|
|
1594
|
-
//#region src/v2/context.ts
|
|
1595
|
-
const CopilotKitContext = (0, react.createContext)(null);
|
|
1596
|
-
const useCopilotKit = () => {
|
|
1597
|
-
const context = (0, react.useContext)(CopilotKitContext);
|
|
1598
|
-
const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
|
|
1599
|
-
if (!context) throw new Error("useCopilotKit must be used within CopilotKitProvider");
|
|
1600
|
-
(0, react.useEffect)(() => {
|
|
1601
|
-
const subscription = context.copilotkit.subscribe({
|
|
1602
|
-
onRuntimeConnectionStatusChanged: () => {
|
|
1603
|
-
forceUpdate();
|
|
1604
|
-
},
|
|
1605
|
-
onHeadersChanged: () => {
|
|
1606
|
-
forceUpdate();
|
|
1607
|
-
}
|
|
1608
|
-
});
|
|
1609
|
-
return () => {
|
|
1610
|
-
subscription.unsubscribe();
|
|
1611
|
-
};
|
|
1612
|
-
}, []);
|
|
1613
|
-
return context;
|
|
1614
|
-
};
|
|
1615
|
-
const LicenseContext = (0, react.createContext)({
|
|
1616
|
-
status: null,
|
|
1617
|
-
license: null,
|
|
1618
|
-
checkFeature: () => true,
|
|
1619
|
-
getLimit: () => null
|
|
1620
|
-
});
|
|
1621
|
-
const useLicenseContext = () => (0, react.useContext)(LicenseContext);
|
|
1622
|
-
|
|
1623
1639
|
//#endregion
|
|
1624
1640
|
//#region src/v2/hooks/use-render-tool-call.tsx
|
|
1625
1641
|
/**
|
|
@@ -1731,21 +1747,28 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
1731
1747
|
|
|
1732
1748
|
//#endregion
|
|
1733
1749
|
//#region src/v2/components/CopilotKitInspector.tsx
|
|
1734
|
-
const CopilotKitInspector = ({ core, openRequest }) => {
|
|
1750
|
+
const CopilotKitInspector = ({ core, openRequest, onVisibilityChange }) => {
|
|
1735
1751
|
const mountRef = react.useRef(null);
|
|
1736
1752
|
const inspectorRef = react.useRef(null);
|
|
1737
1753
|
const latestCoreRef = react.useRef(core ?? null);
|
|
1738
1754
|
const latestOpenRequestRef = react.useRef(openRequest);
|
|
1755
|
+
const visibilityCallbackRef = react.useRef(onVisibilityChange);
|
|
1756
|
+
visibilityCallbackRef.current = onVisibilityChange;
|
|
1739
1757
|
latestCoreRef.current = core ?? null;
|
|
1740
1758
|
latestOpenRequestRef.current = openRequest;
|
|
1741
1759
|
react.useEffect(() => {
|
|
1742
1760
|
let mounted = true;
|
|
1743
1761
|
let inspector = null;
|
|
1762
|
+
const handleVisibilityChange = (event) => {
|
|
1763
|
+
const visible = event.detail?.visible;
|
|
1764
|
+
visibilityCallbackRef.current?.(visible === true);
|
|
1765
|
+
};
|
|
1744
1766
|
import("@copilotkit/web-inspector").then((mod) => {
|
|
1745
1767
|
if (!mounted || !mountRef.current) return;
|
|
1746
1768
|
mod.defineWebInspector?.();
|
|
1747
1769
|
inspector = mountRef.current.ownerDocument.createElement(mod.WEB_INSPECTOR_TAG);
|
|
1748
1770
|
mod.configureWebInspectorElement(inspector, latestCoreRef.current);
|
|
1771
|
+
inspector.addEventListener("cpk-inspector-visibility-change", handleVisibilityChange);
|
|
1749
1772
|
mountRef.current.appendChild(inspector);
|
|
1750
1773
|
inspectorRef.current = inspector;
|
|
1751
1774
|
const request = latestOpenRequestRef.current;
|
|
@@ -1755,7 +1778,9 @@ _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
|
1755
1778
|
});
|
|
1756
1779
|
return () => {
|
|
1757
1780
|
mounted = false;
|
|
1781
|
+
inspector?.removeEventListener("cpk-inspector-visibility-change", handleVisibilityChange);
|
|
1758
1782
|
inspector?.remove();
|
|
1783
|
+
visibilityCallbackRef.current?.(false);
|
|
1759
1784
|
if (inspectorRef.current === inspector) inspectorRef.current = null;
|
|
1760
1785
|
};
|
|
1761
1786
|
}, []);
|
|
@@ -3688,14 +3713,19 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3688
3713
|
}, [value, warningMessage]);
|
|
3689
3714
|
return value;
|
|
3690
3715
|
}
|
|
3691
|
-
const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY_HEADERS, credentials, publicApiKey, publicLicenseKey, licenseToken, properties = EMPTY_PROPERTIES, agents__unsafe_dev_only: agents = EMPTY_AGENTS, selfManagedAgents = EMPTY_AGENTS, renderToolCalls, renderActivityMessages, renderCustomMessages, frontendTools, humanInTheLoop, openGenerativeUI, enableInspector, useSingleEndpoint, onError, a2ui, defaultThrottleMs, debug }) => {
|
|
3716
|
+
const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY_HEADERS, credentials, publicApiKey, publicLicenseKey, licenseToken, properties = EMPTY_PROPERTIES, agents__unsafe_dev_only: agents = EMPTY_AGENTS, selfManagedAgents = EMPTY_AGENTS, renderToolCalls, renderActivityMessages, renderCustomMessages, frontendTools, humanInTheLoop, openGenerativeUI, enableInspector, agentId, useSingleEndpoint, onError, a2ui, defaultThrottleMs, debug }) => {
|
|
3692
3717
|
const [shouldRenderInspector, setShouldRenderInspector] = (0, react.useState)(false);
|
|
3718
|
+
const [inspectorVisible, setInspectorVisible] = (0, react.useState)(false);
|
|
3693
3719
|
(0, react.useEffect)(() => {
|
|
3694
3720
|
setShouldRenderInspector((0, _copilotkit_shared.shouldEnableInspector)({
|
|
3695
3721
|
enableInspector,
|
|
3696
3722
|
isBrowser: true,
|
|
3697
3723
|
isDevelopment: process.env.NODE_ENV === "development"
|
|
3698
|
-
})
|
|
3724
|
+
}) && [
|
|
3725
|
+
"localhost",
|
|
3726
|
+
"127.0.0.1",
|
|
3727
|
+
"[::1]"
|
|
3728
|
+
].includes(window.location.hostname));
|
|
3699
3729
|
}, [enableInspector]);
|
|
3700
3730
|
const [inspectorOpenRequest, setInspectorOpenRequest] = (0, react.useState)(null);
|
|
3701
3731
|
const [runtimeA2UIEnabled, setRuntimeA2UIEnabled] = (0, react.useState)(false);
|
|
@@ -3711,9 +3741,15 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
3711
3741
|
setInspectorOpenRequest({ ...request });
|
|
3712
3742
|
}, []);
|
|
3713
3743
|
const inspectorContextValue = (0, react.useMemo)(() => ({
|
|
3714
|
-
|
|
3744
|
+
providerEnableInspector: enableInspector,
|
|
3745
|
+
isInspectorEnabled: shouldRenderInspector && inspectorVisible,
|
|
3715
3746
|
openInspector: requestInspectorOpen
|
|
3716
|
-
}), [
|
|
3747
|
+
}), [
|
|
3748
|
+
enableInspector,
|
|
3749
|
+
shouldRenderInspector,
|
|
3750
|
+
inspectorVisible,
|
|
3751
|
+
requestInspectorOpen
|
|
3752
|
+
]);
|
|
3717
3753
|
const renderToolCallsList = useStableArrayProp(renderToolCalls, "renderToolCalls must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead.", (initial, next) => {
|
|
3718
3754
|
const key = (rc) => `${rc?.agentId ?? ""}:${rc?.name ?? ""}`;
|
|
3719
3755
|
const setFrom = (arr) => new Set(arr.map(key));
|
|
@@ -4110,9 +4146,13 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4110
4146
|
}),
|
|
4111
4147
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(CopilotKitInspectorContextProvider, {
|
|
4112
4148
|
value: inspectorContextValue,
|
|
4113
|
-
children: [
|
|
4149
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitAgentIdContext.Provider, {
|
|
4150
|
+
value: agentId,
|
|
4151
|
+
children
|
|
4152
|
+
}), shouldRenderInspector ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitInspector, {
|
|
4114
4153
|
core: copilotkit,
|
|
4115
|
-
openRequest: inspectorOpenRequest
|
|
4154
|
+
openRequest: inspectorOpenRequest,
|
|
4155
|
+
onVisibilityChange: setInspectorVisible
|
|
4116
4156
|
}) : null]
|
|
4117
4157
|
}),
|
|
4118
4158
|
runtimeLicenseWarningStatus === "none" && !resolvedPublicKey && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "no_license" }),
|
|
@@ -4694,7 +4734,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4694
4734
|
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}" }).`);
|
|
4695
4735
|
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 "${_copilotkit_shared.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 }).`);
|
|
4696
4736
|
const chatConfig = useCopilotChatConfiguration();
|
|
4697
|
-
const
|
|
4737
|
+
const providerAgentId = useDefaultAgentId();
|
|
4738
|
+
const resolvedAgentId = agentId ?? chatConfig?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
4698
4739
|
const { copilotkit } = useCopilotKit();
|
|
4699
4740
|
const providerThrottleMs = copilotkit.defaultThrottleMs;
|
|
4700
4741
|
const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
|
|
@@ -4922,7 +4963,12 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4922
4963
|
function useSuggestions({ agentId } = {}) {
|
|
4923
4964
|
const { copilotkit } = useCopilotKit();
|
|
4924
4965
|
const config = useCopilotChatConfiguration();
|
|
4925
|
-
const
|
|
4966
|
+
const providerAgentId = useDefaultAgentId();
|
|
4967
|
+
const resolvedAgentId = (0, react.useMemo)(() => agentId ?? config?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID, [
|
|
4968
|
+
agentId,
|
|
4969
|
+
config?.agentId,
|
|
4970
|
+
providerAgentId
|
|
4971
|
+
]);
|
|
4926
4972
|
const [suggestions, setSuggestions] = (0, react.useState)(() => {
|
|
4927
4973
|
return copilotkit.getSuggestions(resolvedAgentId).suggestions;
|
|
4928
4974
|
});
|
|
@@ -6226,6 +6272,289 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6226
6272
|
}) });
|
|
6227
6273
|
}
|
|
6228
6274
|
|
|
6275
|
+
//#endregion
|
|
6276
|
+
//#region src/v2/components/chat/CopilotChatInspectorButton.tsx
|
|
6277
|
+
let shortcutsHidden = false;
|
|
6278
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
6279
|
+
const subscribe = (listener) => {
|
|
6280
|
+
listeners.add(listener);
|
|
6281
|
+
return () => {
|
|
6282
|
+
listeners.delete(listener);
|
|
6283
|
+
};
|
|
6284
|
+
};
|
|
6285
|
+
const getSnapshot = () => shortcutsHidden;
|
|
6286
|
+
const getServerSnapshot = () => false;
|
|
6287
|
+
function useInspectorShortcutsHidden() {
|
|
6288
|
+
return (0, react.useSyncExternalStore)(subscribe, getSnapshot, getServerSnapshot);
|
|
6289
|
+
}
|
|
6290
|
+
function hideShortcuts() {
|
|
6291
|
+
shortcutsHidden = true;
|
|
6292
|
+
listeners.forEach((listener) => listener());
|
|
6293
|
+
}
|
|
6294
|
+
function InspectorKiteIcon({ className, ...props }) {
|
|
6295
|
+
const id = (0, react.useId)();
|
|
6296
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
6297
|
+
...props,
|
|
6298
|
+
"aria-hidden": "true",
|
|
6299
|
+
className: (0, tailwind_merge.twMerge)("cpk:size-4", className),
|
|
6300
|
+
viewBox: "4.57 3.36 17.8 17.8",
|
|
6301
|
+
fill: "none",
|
|
6302
|
+
children: [
|
|
6303
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6304
|
+
d: "M6.36084 10.9855C8.34277 8.393 9.98843 5.82939 10.6204 3.75914C10.6382 3.70281 10.7043 3.67888 10.7534 3.7114C12.9536 5.16894 16.9635 6.12833 20.5086 6.15085C20.5703 6.15124 20.6124 6.2114 20.5895 6.26829C19.4109 9.25938 17.9705 14.6189 17.9148 20.7392C17.9148 20.8301 17.7873 20.8627 17.7419 20.7837C15.7236 17.2522 9.26021 12.2898 6.39414 11.1186C6.34112 11.0968 6.32556 11.0313 6.36084 10.9855Z",
|
|
6305
|
+
fill: `url(#${id}-paint0_linear)`
|
|
6306
|
+
}),
|
|
6307
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6308
|
+
d: "M13.0475 9.39974C9.95016 10.3806 7.11935 10.9259 6.44331 11.0498C6.40027 11.0577 6.39115 11.1172 6.43152 11.134C9.3203 12.3347 15.7516 17.2826 17.7511 20.7998C17.7551 20.8075 17.7647 20.8103 17.7728 20.8068C17.7809 20.803 17.7853 20.793 17.7819 20.7844L13.0475 9.39974Z",
|
|
6309
|
+
fill: `url(#${id}-paint1_linear)`
|
|
6310
|
+
}),
|
|
6311
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6312
|
+
d: "M10.762 3.705C13.4137 5.15161 16.4787 5.80132 20.545 6.14367C20.5703 6.14585 20.5787 6.18008 20.5557 6.19197C20.0359 6.45923 17.0574 7.97512 14.8455 8.78701C14.2524 9.00453 13.6564 9.20632 13.0692 9.39249C13.0562 9.39656 13.0419 9.39015 13.0369 9.37774L10.7005 3.75979C10.6849 3.72196 10.7257 3.68538 10.762 3.705Z",
|
|
6313
|
+
fill: `url(#${id}-paint2_linear)`
|
|
6314
|
+
}),
|
|
6315
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6316
|
+
d: "M10.7145 3.79041L17.8305 20.7659",
|
|
6317
|
+
stroke: "#513C9F",
|
|
6318
|
+
strokeWidth: "0.17284",
|
|
6319
|
+
strokeLinecap: "round"
|
|
6320
|
+
}),
|
|
6321
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6322
|
+
d: "M6.44531 11.0476C6.44531 11.0476 10.375 10.3422 14.0686 9.06804C17.7623 7.7939 20.5122 6.23373 20.5122 6.23373",
|
|
6323
|
+
stroke: "#513C9F",
|
|
6324
|
+
strokeWidth: "0.17284",
|
|
6325
|
+
strokeLinecap: "round"
|
|
6326
|
+
}),
|
|
6327
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6328
|
+
d: "M11.6914 5.93518L9.05534 14.7068M9.05534 14.7068H15.3203M9.05534 14.7068L0.15625 26.3646",
|
|
6329
|
+
stroke: "#ABABAB",
|
|
6330
|
+
strokeWidth: "0.302474",
|
|
6331
|
+
strokeLinecap: "round"
|
|
6332
|
+
}),
|
|
6333
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6334
|
+
d: "M6.02539 23.9646L4.85806 24.1287C5.46272 25.7287 6.70381 26.4276 8.18528 26.4276C11.8147 26.4276 10.707 22.3227 12.8103 22.3227C14.3358 22.3227 13.7155 25.6498 16.9992 25.6498C19.0029 25.6498 19.2028 23.631 18.8607 22.7625C18.8589 22.7572 18.8568 22.7524 18.8538 22.7476L18.3166 21.9253C18.2817 21.8706 18.1968 21.8912 18.1907 21.9562L18.0908 22.9529C18.0838 23.0222 18.0857 23.0913 18.0936 23.1605C18.1764 23.8491 18.2291 25.5202 16.9992 25.5202C15.7015 25.5202 15.3895 22.2362 12.8103 22.2362C9.78393 22.2362 10.1726 26.298 8.31487 26.298C7.08938 26.298 6.15447 24.9153 6.02539 23.9646Z",
|
|
6335
|
+
fill: `url(#${id}-paint3_linear)`
|
|
6336
|
+
}),
|
|
6337
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("defs", { children: [
|
|
6338
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
|
|
6339
|
+
id: `${id}-paint0_linear`,
|
|
6340
|
+
x1: "15.5372",
|
|
6341
|
+
y1: "5.0278",
|
|
6342
|
+
x2: "12.0802",
|
|
6343
|
+
y2: "14.534",
|
|
6344
|
+
gradientUnits: "userSpaceOnUse",
|
|
6345
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", { stopColor: "#6430AB" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6346
|
+
offset: "1",
|
|
6347
|
+
stopColor: "#AA89D8"
|
|
6348
|
+
})]
|
|
6349
|
+
}),
|
|
6350
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
|
|
6351
|
+
id: `${id}-paint1_linear`,
|
|
6352
|
+
x1: "12.8583",
|
|
6353
|
+
y1: "10.3858",
|
|
6354
|
+
x2: "8.40764",
|
|
6355
|
+
y2: "18.9846",
|
|
6356
|
+
gradientUnits: "userSpaceOnUse",
|
|
6357
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", { stopColor: "#005DBB" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6358
|
+
offset: "1",
|
|
6359
|
+
stopColor: "#3D92E8"
|
|
6360
|
+
})]
|
|
6361
|
+
}),
|
|
6362
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
|
|
6363
|
+
id: `${id}-paint2_linear`,
|
|
6364
|
+
x1: "14.8452",
|
|
6365
|
+
y1: "5.02774",
|
|
6366
|
+
x2: "13.5047",
|
|
6367
|
+
y2: "9.21911",
|
|
6368
|
+
gradientUnits: "userSpaceOnUse",
|
|
6369
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", { stopColor: "#1B70C4" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6370
|
+
offset: "1",
|
|
6371
|
+
stopColor: "#54A4F2"
|
|
6372
|
+
})]
|
|
6373
|
+
}),
|
|
6374
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
|
|
6375
|
+
id: `${id}-paint3_linear`,
|
|
6376
|
+
x1: "4.85806",
|
|
6377
|
+
y1: "24.2455",
|
|
6378
|
+
x2: "18.9963",
|
|
6379
|
+
y2: "24.2455",
|
|
6380
|
+
gradientUnits: "userSpaceOnUse",
|
|
6381
|
+
children: [
|
|
6382
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", { stopColor: "#4497EA" }),
|
|
6383
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6384
|
+
offset: "0.254755",
|
|
6385
|
+
stopColor: "#1463B2"
|
|
6386
|
+
}),
|
|
6387
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6388
|
+
offset: "0.498725",
|
|
6389
|
+
stopColor: "#0A437D"
|
|
6390
|
+
}),
|
|
6391
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6392
|
+
offset: "0.666667",
|
|
6393
|
+
stopColor: "#2476C8"
|
|
6394
|
+
}),
|
|
6395
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6396
|
+
offset: "0.972542",
|
|
6397
|
+
stopColor: "#0C549A"
|
|
6398
|
+
})
|
|
6399
|
+
]
|
|
6400
|
+
})
|
|
6401
|
+
] })
|
|
6402
|
+
]
|
|
6403
|
+
});
|
|
6404
|
+
}
|
|
6405
|
+
function CopilotChatInspectorButton({ title, className, onClick, onPointerDown, onPointerEnter, onPointerLeave, onKeyDown, disabled, ...props }) {
|
|
6406
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
6407
|
+
const { isInspectorEnabled } = useCopilotKitInspector();
|
|
6408
|
+
const hidden = useInspectorShortcutsHidden();
|
|
6409
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
6410
|
+
const [dark, setDark] = (0, react.useState)(false);
|
|
6411
|
+
const trigger = (0, react.useRef)(null);
|
|
6412
|
+
const closeTimer = (0, react.useRef)(null);
|
|
6413
|
+
const openedByHover = (0, react.useRef)(false);
|
|
6414
|
+
const primaryLabel = title || labels.assistantMessageToolbarInspectorLabel;
|
|
6415
|
+
const cancelClose = () => {
|
|
6416
|
+
if (closeTimer.current !== null) clearTimeout(closeTimer.current);
|
|
6417
|
+
closeTimer.current = null;
|
|
6418
|
+
};
|
|
6419
|
+
(0, react.useEffect)(() => cancelClose, []);
|
|
6420
|
+
const changeOpen = (next) => {
|
|
6421
|
+
cancelClose();
|
|
6422
|
+
if (next) setDark(!!trigger.current?.closest(".dark"));
|
|
6423
|
+
setOpen(next);
|
|
6424
|
+
};
|
|
6425
|
+
const scheduleClose = () => {
|
|
6426
|
+
cancelClose();
|
|
6427
|
+
closeTimer.current = setTimeout(() => {
|
|
6428
|
+
if (openedByHover.current) setOpen(false);
|
|
6429
|
+
}, 180);
|
|
6430
|
+
};
|
|
6431
|
+
if (!isInspectorEnabled || hidden) return null;
|
|
6432
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DropdownMenu, {
|
|
6433
|
+
open,
|
|
6434
|
+
onOpenChange: changeOpen,
|
|
6435
|
+
modal: false,
|
|
6436
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuTrigger, {
|
|
6437
|
+
asChild: true,
|
|
6438
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
6439
|
+
...props,
|
|
6440
|
+
ref: trigger,
|
|
6441
|
+
type: "button",
|
|
6442
|
+
disabled,
|
|
6443
|
+
variant: "assistantMessageToolbarButton",
|
|
6444
|
+
size: "icon",
|
|
6445
|
+
"data-testid": "copilot-inspector-button",
|
|
6446
|
+
"aria-label": `${labels.assistantMessageToolbarInspectorTitle} (${labels.assistantMessageToolbarInspectorLocalOnlyLabel.toLowerCase()})`,
|
|
6447
|
+
className: (0, tailwind_merge.twMerge)("cpk:size-8 cpk:p-1.5", className),
|
|
6448
|
+
onPointerEnter: (event) => {
|
|
6449
|
+
onPointerEnter?.(event);
|
|
6450
|
+
if (!disabled && event.pointerType !== "touch") {
|
|
6451
|
+
openedByHover.current = true;
|
|
6452
|
+
changeOpen(true);
|
|
6453
|
+
}
|
|
6454
|
+
},
|
|
6455
|
+
onPointerLeave: (event) => {
|
|
6456
|
+
onPointerLeave?.(event);
|
|
6457
|
+
scheduleClose();
|
|
6458
|
+
},
|
|
6459
|
+
onPointerDown: (event) => {
|
|
6460
|
+
onPointerDown?.(event);
|
|
6461
|
+
event.preventDefault();
|
|
6462
|
+
},
|
|
6463
|
+
onClick: (event) => {
|
|
6464
|
+
changeOpen(false);
|
|
6465
|
+
onClick?.(event);
|
|
6466
|
+
},
|
|
6467
|
+
onKeyDown: (event) => {
|
|
6468
|
+
openedByHover.current = false;
|
|
6469
|
+
onKeyDown?.(event);
|
|
6470
|
+
if (!event.defaultPrevented && (event.key === "Enter" || event.key === " ")) {
|
|
6471
|
+
event.preventDefault();
|
|
6472
|
+
event.currentTarget.click();
|
|
6473
|
+
}
|
|
6474
|
+
},
|
|
6475
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Wrench, {
|
|
6476
|
+
"aria-hidden": "true",
|
|
6477
|
+
className: "cpk:size-4",
|
|
6478
|
+
"data-testid": "copilot-inspector-icon"
|
|
6479
|
+
})
|
|
6480
|
+
})
|
|
6481
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DropdownMenuContent, {
|
|
6482
|
+
align: "start",
|
|
6483
|
+
side: "top",
|
|
6484
|
+
sideOffset: 6,
|
|
6485
|
+
className: (0, tailwind_merge.twMerge)("cpk:w-64 cpk:p-1 cpk:text-sm", dark && "dark"),
|
|
6486
|
+
onPointerEnter: cancelClose,
|
|
6487
|
+
onPointerLeave: scheduleClose,
|
|
6488
|
+
onKeyDown: () => {
|
|
6489
|
+
openedByHover.current = false;
|
|
6490
|
+
},
|
|
6491
|
+
onOpenAutoFocus: (event) => {
|
|
6492
|
+
if (openedByHover.current) event.preventDefault();
|
|
6493
|
+
},
|
|
6494
|
+
onCloseAutoFocus: (event) => {
|
|
6495
|
+
if (openedByHover.current) event.preventDefault();
|
|
6496
|
+
},
|
|
6497
|
+
onFocusOutside: () => changeOpen(false),
|
|
6498
|
+
children: [
|
|
6499
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DropdownMenuLabel, {
|
|
6500
|
+
className: "cpk:flex cpk:items-center cpk:justify-between cpk:gap-3 cpk:px-2 cpk:py-2",
|
|
6501
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6502
|
+
className: "cpk:text-xs cpk:font-medium",
|
|
6503
|
+
children: labels.assistantMessageToolbarInspectorTitle
|
|
6504
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Tooltip, {
|
|
6505
|
+
delayDuration: 1e3,
|
|
6506
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipTrigger, {
|
|
6507
|
+
asChild: true,
|
|
6508
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6509
|
+
tabIndex: 0,
|
|
6510
|
+
className: "cpk:cursor-help cpk:rounded cpk:bg-muted cpk:px-1.5 cpk:py-0.5 cpk:text-[10px] cpk:font-normal cpk:text-muted-foreground",
|
|
6511
|
+
children: labels.assistantMessageToolbarInspectorLocalOnlyLabel
|
|
6512
|
+
})
|
|
6513
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipContent, {
|
|
6514
|
+
side: "top",
|
|
6515
|
+
sideOffset: 6,
|
|
6516
|
+
className: (0, tailwind_merge.twMerge)("cpk:max-w-48 cpk:text-wrap", dark && "dark"),
|
|
6517
|
+
onPointerEnter: cancelClose,
|
|
6518
|
+
onPointerLeave: scheduleClose,
|
|
6519
|
+
children: labels.assistantMessageToolbarInspectorLocalOnlyDescription
|
|
6520
|
+
})]
|
|
6521
|
+
})]
|
|
6522
|
+
}),
|
|
6523
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuSeparator, {}),
|
|
6524
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuItem, {
|
|
6525
|
+
asChild: true,
|
|
6526
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
6527
|
+
type: "button",
|
|
6528
|
+
onClick,
|
|
6529
|
+
className: "cpk:w-full cpk:cursor-pointer cpk:items-start cpk:text-left",
|
|
6530
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(InspectorKiteIcon, { className: "cpk:mt-0.5" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6531
|
+
className: "cpk:block",
|
|
6532
|
+
children: primaryLabel
|
|
6533
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6534
|
+
className: "cpk:block cpk:text-xs cpk:text-muted-foreground",
|
|
6535
|
+
children: labels.assistantMessageToolbarInspectorDescription
|
|
6536
|
+
})] })]
|
|
6537
|
+
})
|
|
6538
|
+
}),
|
|
6539
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DropdownMenuItem, {
|
|
6540
|
+
onSelect: hideShortcuts,
|
|
6541
|
+
className: "cpk:cursor-pointer cpk:items-start",
|
|
6542
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.EyeOff, {
|
|
6543
|
+
"aria-hidden": "true",
|
|
6544
|
+
className: "cpk:mt-0.5"
|
|
6545
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6546
|
+
className: "cpk:block",
|
|
6547
|
+
children: labels.assistantMessageToolbarInspectorHideLabel
|
|
6548
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6549
|
+
className: "cpk:block cpk:text-xs cpk:text-muted-foreground",
|
|
6550
|
+
children: labels.assistantMessageToolbarInspectorHideDescription
|
|
6551
|
+
})] })]
|
|
6552
|
+
})
|
|
6553
|
+
]
|
|
6554
|
+
})]
|
|
6555
|
+
});
|
|
6556
|
+
}
|
|
6557
|
+
|
|
6229
6558
|
//#endregion
|
|
6230
6559
|
//#region src/v2/components/chat/CopilotChatAssistantMessage.tsx
|
|
6231
6560
|
/**
|
|
@@ -6246,30 +6575,32 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6246
6575
|
function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp, onThumbsDown, onReadAloud, onRegenerate, additionalToolbarItems, toolbarVisible = true, markdownRenderer, toolbar, copyButton, inspectorButton, thumbsUpButton, thumbsDownButton, readAloudButton, regenerateButton, toolCallsView, children, className, ...props }) {
|
|
6247
6576
|
useKatexStyles();
|
|
6248
6577
|
const { isInspectorEnabled, openInspector } = useCopilotKitInspector();
|
|
6578
|
+
const shortcutsHidden = useInspectorShortcutsHidden();
|
|
6579
|
+
const showInspectorShortcut = isInspectorEnabled && !shortcutsHidden;
|
|
6249
6580
|
const boundMarkdownRenderer = renderSlot(markdownRenderer, CopilotChatAssistantMessage.MarkdownRenderer, { content: message.content || "" });
|
|
6250
6581
|
const boundCopyButton = renderSlot(copyButton, CopilotChatAssistantMessage.CopyButton, { onClick: async () => {
|
|
6251
6582
|
if (message.content) return await (0, _copilotkit_shared.copyToClipboard)(message.content);
|
|
6252
6583
|
return false;
|
|
6253
6584
|
} });
|
|
6254
6585
|
const boundThumbsUpButton = renderSlot(thumbsUpButton, CopilotChatAssistantMessage.ThumbsUpButton, { onClick: onThumbsUp ? () => onThumbsUp(message) : void 0 });
|
|
6255
|
-
const boundInspectorButton = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BoundInspectorButton, {
|
|
6586
|
+
const boundInspectorButton = showInspectorShortcut ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BoundInspectorButton, {
|
|
6256
6587
|
inspectorButton,
|
|
6257
6588
|
messageId: message.id,
|
|
6258
6589
|
openInspector
|
|
6259
|
-
});
|
|
6590
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, {});
|
|
6260
6591
|
const boundThumbsDownButton = renderSlot(thumbsDownButton, CopilotChatAssistantMessage.ThumbsDownButton, { onClick: onThumbsDown ? () => onThumbsDown(message) : void 0 });
|
|
6261
6592
|
const boundReadAloudButton = renderSlot(readAloudButton, CopilotChatAssistantMessage.ReadAloudButton, { onClick: onReadAloud ? () => onReadAloud(message) : void 0 });
|
|
6262
6593
|
const boundRegenerateButton = renderSlot(regenerateButton, CopilotChatAssistantMessage.RegenerateButton, { onClick: onRegenerate ? () => onRegenerate(message) : void 0 });
|
|
6263
6594
|
const boundToolbar = renderSlot(toolbar, CopilotChatAssistantMessage.Toolbar, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6264
|
-
className: "cpk:flex cpk:items-center cpk:gap-1",
|
|
6595
|
+
className: "cpk:flex cpk:w-full cpk:items-center cpk:gap-1",
|
|
6265
6596
|
children: [
|
|
6266
6597
|
boundCopyButton,
|
|
6267
|
-
isInspectorEnabled && boundInspectorButton,
|
|
6268
6598
|
(onThumbsUp || thumbsUpButton) && boundThumbsUpButton,
|
|
6269
6599
|
(onThumbsDown || thumbsDownButton) && boundThumbsDownButton,
|
|
6270
6600
|
(onReadAloud || readAloudButton) && boundReadAloudButton,
|
|
6271
6601
|
(onRegenerate || regenerateButton) && boundRegenerateButton,
|
|
6272
|
-
additionalToolbarItems
|
|
6602
|
+
additionalToolbarItems,
|
|
6603
|
+
showInspectorShortcut && boundInspectorButton
|
|
6273
6604
|
]
|
|
6274
6605
|
}) });
|
|
6275
6606
|
const boundToolCallsView = renderSlot(toolCallsView, CopilotChatToolCallsView, {
|
|
@@ -6278,7 +6609,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6278
6609
|
});
|
|
6279
6610
|
const hasContent = !!(message.content && message.content.trim().length > 0);
|
|
6280
6611
|
const isLatestAssistantMessage = message.role === "assistant" && messages?.[messages.length - 1]?.id === message.id;
|
|
6281
|
-
const shouldShowToolbar = toolbarVisible && (hasContent ||
|
|
6612
|
+
const shouldShowToolbar = toolbarVisible && (hasContent || showInspectorShortcut) && !(isRunning && isLatestAssistantMessage);
|
|
6282
6613
|
if (children) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6283
6614
|
"data-copilotkit": true,
|
|
6284
6615
|
style: { display: "contents" },
|
|
@@ -6319,110 +6650,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6319
6650
|
]
|
|
6320
6651
|
});
|
|
6321
6652
|
}
|
|
6322
|
-
function CopilotKitColoredIcon() {
|
|
6323
|
-
const gradientId = (0, react.useId)().replace(/:/g, "");
|
|
6324
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
6325
|
-
"aria-hidden": "true",
|
|
6326
|
-
className: "cpk:size-5",
|
|
6327
|
-
"data-testid": "copilot-inspector-icon",
|
|
6328
|
-
viewBox: "0 0 24 24",
|
|
6329
|
-
children: [
|
|
6330
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6331
|
-
d: "M8.162 7.758c2.093-2.738 3.831-5.445 4.498-7.63a.093.093 0 01.14-.051c2.324 1.539 6.558 2.552 10.301 2.576a.09.09 0 01.085.124c-1.243 3.158-2.765 8.817-2.823 15.28-.001.095-.135.13-.183.046-2.131-3.729-8.955-8.968-11.982-10.205a.09.09 0 01-.036-.14z",
|
|
6332
|
-
fill: `url(#${gradientId}-purple)`
|
|
6333
|
-
}),
|
|
6334
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6335
|
-
d: "M15.223 6.083A61.492 61.492 0 018.25 7.827c-.045.008-.055.071-.012.089 3.05 1.267 9.84 6.492 11.952 10.206a.017.017 0 00.022.007.018.018 0 00.01-.024l-4.999-12.02z",
|
|
6336
|
-
fill: `url(#${gradientId}-blue)`
|
|
6337
|
-
}),
|
|
6338
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6339
|
-
d: "M12.81.07c2.8 1.528 6.037 2.214 10.33 2.575.028.002.036.039.012.051-.55.282-3.695 1.883-6.03 2.74-.626.23-1.256.443-1.876.64a.028.028 0 01-.033-.016L12.746.128c-.017-.04.027-.078.065-.058z",
|
|
6340
|
-
fill: `url(#${gradientId}-light-blue)`
|
|
6341
|
-
}),
|
|
6342
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6343
|
-
className: "cpk:fill-[#513C9F] cpk:dark:fill-[#B99AE8]",
|
|
6344
|
-
d: "M12.725.075c.046-.019.1.003.119.05l7.514 17.923a.091.091 0 01-.148.1l-.02-.03L12.675.195a.091.091 0 01.049-.12z"
|
|
6345
|
-
}),
|
|
6346
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6347
|
-
className: "cpk:fill-[#513C9F] cpk:dark:fill-[#B99AE8]",
|
|
6348
|
-
d: "M23.06 2.66c.044-.025.1-.01.125.034.025.044.009.1-.035.124v.001l-.008.004-.025.015-.1.054a41.384 41.384 0 01-1.811.92A47.05 47.05 0 0116.33 5.82c-1.954.674-3.97 1.197-5.497 1.552a66.27 66.27 0 01-2.38.507l-.138.026-.036.007h-.01l-.002.002a.091.091 0 11-.033-.18l.016.09-.015-.09h.002l.01-.002.035-.007.137-.025a66.16 66.16 0 002.373-.506c1.524-.354 3.533-.876 5.479-1.547a46.857 46.857 0 006.276-2.709c.166-.087.295-.156.381-.204l.099-.054.024-.014.008-.004z"
|
|
6349
|
-
}),
|
|
6350
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6351
|
-
className: "cpk:fill-[#ABABAB] cpk:dark:fill-[#D4D4D4]",
|
|
6352
|
-
d: "M13.838 2.272a.16.16 0 01.107.2l-2.72 9.055h6.4l.061.013a.16.16 0 010 .295l-.061.013h-6.541L.679 24.099l-.05.04a.16.16 0 01-.194-.245l10.43-12.285 2.773-9.23a.16.16 0 01.2-.107z"
|
|
6353
|
-
}),
|
|
6354
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6355
|
-
d: "M7.809 21.461l-1.232.173c.638 1.69 1.949 2.427 3.514 2.427 3.831 0 2.661-4.334 4.883-4.334 1.61 0 .956 3.513 4.423 3.513 2.116 0 2.326-2.131 1.966-3.048l-.008-.016-.567-.868c-.037-.058-.127-.036-.133.032l-.106 1.053a1.01 1.01 0 00.003.219c.088.727.144 2.491-1.155 2.491-1.37 0-1.7-3.467-4.423-3.467-3.196 0-2.785 4.289-4.747 4.289-1.294 0-2.28-1.46-2.418-2.464z",
|
|
6356
|
-
fill: `url(#${gradientId}-tail)`
|
|
6357
|
-
}),
|
|
6358
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("defs", { children: [
|
|
6359
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
|
|
6360
|
-
gradientUnits: "userSpaceOnUse",
|
|
6361
|
-
id: `${gradientId}-purple`,
|
|
6362
|
-
x1: "17.852",
|
|
6363
|
-
x2: "14.202",
|
|
6364
|
-
y1: "1.467",
|
|
6365
|
-
y2: "11.504",
|
|
6366
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", { className: "cpk:[stop-color:#6430AB] cpk:dark:[stop-color:#B792F0]" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6367
|
-
className: "cpk:[stop-color:#AA89D8] cpk:dark:[stop-color:#D3BDF7]",
|
|
6368
|
-
offset: "1"
|
|
6369
|
-
})]
|
|
6370
|
-
}),
|
|
6371
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
|
|
6372
|
-
gradientUnits: "userSpaceOnUse",
|
|
6373
|
-
id: `${gradientId}-blue`,
|
|
6374
|
-
x1: "15.024",
|
|
6375
|
-
x2: "10.324",
|
|
6376
|
-
y1: "7.125",
|
|
6377
|
-
y2: "16.204",
|
|
6378
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", { className: "cpk:[stop-color:#005DBB] cpk:dark:[stop-color:#4D9FEF]" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6379
|
-
className: "cpk:[stop-color:#3D92E8] cpk:dark:[stop-color:#84C0FA]",
|
|
6380
|
-
offset: "1"
|
|
6381
|
-
})]
|
|
6382
|
-
}),
|
|
6383
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
|
|
6384
|
-
gradientUnits: "userSpaceOnUse",
|
|
6385
|
-
id: `${gradientId}-light-blue`,
|
|
6386
|
-
x1: "17.122",
|
|
6387
|
-
x2: "15.707",
|
|
6388
|
-
y1: "1.467",
|
|
6389
|
-
y2: "5.892",
|
|
6390
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", { className: "cpk:[stop-color:#1B70C4] cpk:dark:[stop-color:#61ACF2]" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6391
|
-
className: "cpk:[stop-color:#54A4F2] cpk:dark:[stop-color:#9ACDFF]",
|
|
6392
|
-
offset: "1"
|
|
6393
|
-
})]
|
|
6394
|
-
}),
|
|
6395
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
|
|
6396
|
-
gradientUnits: "userSpaceOnUse",
|
|
6397
|
-
id: `${gradientId}-tail`,
|
|
6398
|
-
x1: "6.577",
|
|
6399
|
-
x2: "21.506",
|
|
6400
|
-
y1: "21.758",
|
|
6401
|
-
y2: "21.758",
|
|
6402
|
-
children: [
|
|
6403
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", { className: "cpk:[stop-color:#4497EA] cpk:dark:[stop-color:#79BCF5]" }),
|
|
6404
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6405
|
-
className: "cpk:[stop-color:#1463B2] cpk:dark:[stop-color:#4594D8]",
|
|
6406
|
-
offset: ".255"
|
|
6407
|
-
}),
|
|
6408
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6409
|
-
className: "cpk:[stop-color:#0A437D] cpk:dark:[stop-color:#347CB7]",
|
|
6410
|
-
offset: ".499"
|
|
6411
|
-
}),
|
|
6412
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6413
|
-
className: "cpk:[stop-color:#2476C8] cpk:dark:[stop-color:#58A4E5]",
|
|
6414
|
-
offset: ".667"
|
|
6415
|
-
}),
|
|
6416
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6417
|
-
className: "cpk:[stop-color:#0C549A] cpk:dark:[stop-color:#3C87C7]",
|
|
6418
|
-
offset: ".973"
|
|
6419
|
-
})
|
|
6420
|
-
]
|
|
6421
|
-
})
|
|
6422
|
-
] })
|
|
6423
|
-
]
|
|
6424
|
-
});
|
|
6425
|
-
}
|
|
6426
6653
|
(function(_CopilotChatAssistantMessage) {
|
|
6427
6654
|
_CopilotChatAssistantMessage.MarkdownRenderer = ({ content, className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.Streamdown, {
|
|
6428
6655
|
className,
|
|
@@ -6480,30 +6707,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
6480
6707
|
children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, { className: "cpk:size-[18px]" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Copy, { className: "cpk:size-[18px]" })
|
|
6481
6708
|
});
|
|
6482
6709
|
};
|
|
6483
|
-
_CopilotChatAssistantMessage.InspectorButton =
|
|
6484
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
6485
|
-
const primaryLabel = title || labels.assistantMessageToolbarInspectorLabel;
|
|
6486
|
-
const accessibleLabel = `${primaryLabel} (local only)`;
|
|
6487
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ToolbarButton, {
|
|
6488
|
-
"data-testid": "copilot-inspector-button",
|
|
6489
|
-
title: accessibleLabel,
|
|
6490
|
-
className: (0, tailwind_merge.twMerge)("cpk:w-auto cpk:gap-1.5 cpk:px-2", className),
|
|
6491
|
-
tooltipClassName: "cpk:max-w-64 cpk:text-left cpk:leading-4",
|
|
6492
|
-
tooltip: "View this message in the Inspector to get more information. This button and the inspector only display during local development (localhost, dev env).",
|
|
6493
|
-
...props,
|
|
6494
|
-
children: [
|
|
6495
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitColoredIcon, {}),
|
|
6496
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6497
|
-
className: "cpk:font-medium",
|
|
6498
|
-
children: primaryLabel
|
|
6499
|
-
}),
|
|
6500
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6501
|
-
className: "cpk:text-xs cpk:text-muted-foreground",
|
|
6502
|
-
children: "(local only)"
|
|
6503
|
-
})
|
|
6504
|
-
]
|
|
6505
|
-
});
|
|
6506
|
-
};
|
|
6710
|
+
_CopilotChatAssistantMessage.InspectorButton = CopilotChatInspectorButton;
|
|
6507
6711
|
_CopilotChatAssistantMessage.ThumbsUpButton = ({ title, ...props }) => {
|
|
6508
6712
|
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
6509
6713
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
@@ -8753,9 +8957,15 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
8753
8957
|
|
|
8754
8958
|
//#endregion
|
|
8755
8959
|
//#region src/v2/components/chat/CopilotChat.tsx
|
|
8756
|
-
function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen, attachments: attachmentsConfig, onError, throttleMs, ...props }) {
|
|
8960
|
+
function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isModalDefaultOpen, attachments: attachmentsConfig, onError, throttleMs, ...props }) {
|
|
8757
8961
|
const existingConfig = useCopilotChatConfiguration();
|
|
8758
|
-
const
|
|
8962
|
+
const inspector = useCopilotKitInspector();
|
|
8963
|
+
const inspectorContextValue = (0, react.useMemo)(() => ({
|
|
8964
|
+
...inspector,
|
|
8965
|
+
isInspectorEnabled: inspector.isInspectorEnabled && (inspector.providerEnableInspector ?? inspectorTools ?? true)
|
|
8966
|
+
}), [inspector, inspectorTools]);
|
|
8967
|
+
const providerAgentId = useDefaultAgentId();
|
|
8968
|
+
const resolvedAgentId = agentId ?? existingConfig?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
8759
8969
|
const providedThreadId = threadId ?? existingConfig?.threadId;
|
|
8760
8970
|
const baseThreadId = (0, react.useMemo)(() => providedThreadId ?? (0, _copilotkit_shared.randomUUID)(), [providedThreadId]);
|
|
8761
8971
|
const baseHasExplicitThreadId = !!threadId || !!existingConfig?.hasExplicitThreadId;
|
|
@@ -9328,7 +9538,10 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
9328
9538
|
}),
|
|
9329
9539
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(LastUserMessageContext.Provider, {
|
|
9330
9540
|
value: lastUserMessageState,
|
|
9331
|
-
children:
|
|
9541
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitInspectorContextProvider, {
|
|
9542
|
+
value: inspectorContextValue,
|
|
9543
|
+
children: RenderedChatView
|
|
9544
|
+
})
|
|
9332
9545
|
})
|
|
9333
9546
|
]
|
|
9334
9547
|
})
|
|
@@ -10036,7 +10249,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
10036
10249
|
const featureLicensed = checkFeature("threads");
|
|
10037
10250
|
const licensed = licensePresent && featureLicensed;
|
|
10038
10251
|
const licensePending = status === null;
|
|
10039
|
-
const
|
|
10252
|
+
const providerAgentId = useDefaultAgentId();
|
|
10253
|
+
const resolvedAgentId = agentId ?? configuration?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
10040
10254
|
const activeThreadId = configuration?.threadId ?? null;
|
|
10041
10255
|
const { threads, isLoading, listError, fetchMoreError, hasMoreThreads, isFetchingMoreThreads, archiveThread, unarchiveThread, deleteThread, fetchMoreThreads, refetchThreads, startNewThread } = useThreads({
|
|
10042
10256
|
agentId: resolvedAgentId,
|