@copilotkit/react-core 2.0.0-rc.7 → 2.0.0-rc.8
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/{MarkdownRendererContext-B4Us6mwL.d.cts → MarkdownRendererContext-DAuVISwv.d.cts} +14 -30
- package/dist/MarkdownRendererContext-DAuVISwv.d.cts.map +1 -0
- package/dist/{MarkdownRendererContext-CRKFzsEB.d.mts → MarkdownRendererContext-XWC2OXD5.d.mts} +15 -31
- package/dist/MarkdownRendererContext-XWC2OXD5.d.mts.map +1 -0
- package/dist/{MarkdownSurfaces-Bd--93O1.mjs → MarkdownSurfaces-BXaxgpm_.mjs} +91 -74
- package/dist/MarkdownSurfaces-BXaxgpm_.mjs.map +1 -0
- package/dist/{MarkdownSurfaces-S4wfUl3J.cjs → MarkdownSurfaces-DQZM4lSI.cjs} +96 -73
- package/dist/MarkdownSurfaces-DQZM4lSI.cjs.map +1 -0
- package/dist/context.cjs +20 -17
- package/dist/context.cjs.map +1 -1
- package/dist/context.d.cts +38 -98
- package/dist/context.d.cts.map +1 -1
- package/dist/context.d.mts +38 -98
- package/dist/context.d.mts.map +1 -1
- package/dist/context.mjs +20 -17
- package/dist/context.mjs.map +1 -1
- package/dist/generative-ui.cjs +35 -15
- package/dist/generative-ui.cjs.map +1 -1
- package/dist/generative-ui.d.cts +9 -9
- package/dist/generative-ui.d.mts +9 -9
- package/dist/generative-ui.mjs +35 -15
- package/dist/generative-ui.mjs.map +1 -1
- package/dist/headless.cjs +50 -76
- package/dist/headless.cjs.map +1 -1
- package/dist/headless.d.cts +78 -253
- package/dist/headless.d.cts.map +1 -1
- package/dist/headless.d.mts +56 -202
- package/dist/headless.d.mts.map +1 -1
- package/dist/headless.mjs +43 -74
- package/dist/headless.mjs.map +1 -1
- package/dist/index.cjs +664 -958
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +168 -472
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +168 -472
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +443 -949
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +754 -1029
- package/dist/index.umd.js.map +1 -1
- package/package.json +9 -10
- package/dist/MarkdownRendererContext-B4Us6mwL.d.cts.map +0 -1
- package/dist/MarkdownRendererContext-CRKFzsEB.d.mts.map +0 -1
- package/dist/MarkdownSurfaces-Bd--93O1.mjs.map +0 -1
- package/dist/MarkdownSurfaces-S4wfUl3J.cjs.map +0 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
(function(global, factory) {
|
|
4
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@copilotkit/core'), require('@ag-ui/client'), require('react'), require('
|
|
5
|
-
typeof define === 'function' && define.amd ? define(['exports', '@copilotkit/core', '@ag-ui/client', 'react', '
|
|
6
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.CopilotKitReactCore = {}), global.CopilotKitCore,global.AgUIClient,global.React,global.
|
|
7
|
-
})(this, function(exports, _copilotkit_core, _ag_ui_client, react,
|
|
4
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@copilotkit/core'), require('@ag-ui/client'), require('react'), require('@copilotkit/markdown-renderer/react'), require('@copilotkit/markdown-renderer'), require('react/jsx-runtime'), require('@copilotkit/shared'), require('@radix-ui/react-tooltip'), require('@radix-ui/react-dropdown-menu'), require('@ag-ui/core'), require('@copilotkit/mcp-apps-renderer/activity'), require('zod'), require('@copilotkit/a2ui-renderer'), require('zod-to-json-schema'), require('@a2ui/web_core/v0_9'), require('@copilotkit/core/styles'), require('@radix-ui/react-popover'), require('react-dom'), require('@tanstack/react-virtual'), require('use-stick-to-bottom'), require('@copilotkit/web-components/threads-drawer')) :
|
|
5
|
+
typeof define === 'function' && define.amd ? define(['exports', '@copilotkit/core', '@ag-ui/client', 'react', '@copilotkit/markdown-renderer/react', '@copilotkit/markdown-renderer', 'react/jsx-runtime', '@copilotkit/shared', '@radix-ui/react-tooltip', '@radix-ui/react-dropdown-menu', '@ag-ui/core', '@copilotkit/mcp-apps-renderer/activity', 'zod', '@copilotkit/a2ui-renderer', 'zod-to-json-schema', '@a2ui/web_core/v0_9', '@copilotkit/core/styles', '@radix-ui/react-popover', 'react-dom', '@tanstack/react-virtual', 'use-stick-to-bottom', '@copilotkit/web-components/threads-drawer'], factory) :
|
|
6
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.CopilotKitReactCore = {}), global.CopilotKitCore,global.AgUIClient,global.React,global.CopilotKitMarkdownRendererReact,global.CopilotKitMarkdownRenderer,global.ReactJsxRuntime,global.CopilotKitShared,global.RadixReactTooltip,global.RadixReactDropdownMenu,global.AgUICore,global.CopilotKitMcpAppsRendererActivity,global.Zod,global.CopilotKitA2UIRenderer,global.zod_to_json_schema,global._a2ui_web_core_v0_9,global._copilotkit_core_styles,global._radix_ui_react_popover,global.ReactDOM,global._tanstack_react_virtual,global.useStickToBottom,global._copilotkit_web_components_threads_drawer));
|
|
7
|
+
})(this, function(exports, _copilotkit_core, _ag_ui_client, react, _copilotkit_markdown_renderer_react, _copilotkit_markdown_renderer, react_jsx_runtime, _copilotkit_shared, _radix_ui_react_tooltip, _radix_ui_react_dropdown_menu, _ag_ui_core, _copilotkit_mcp_apps_renderer_activity, zod, _copilotkit_a2ui_renderer, zod_to_json_schema, _a2ui_web_core_v0_9, _copilotkit_core_styles, _radix_ui_react_popover, react_dom, _tanstack_react_virtual, use_stick_to_bottom, _copilotkit_web_components_threads_drawer) {
|
|
8
8
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
9
9
|
//#region \0rolldown/runtime.js
|
|
10
10
|
var __create = Object.create;
|
|
@@ -38,111 +38,6 @@ _radix_ui_react_tooltip = __toESM(_radix_ui_react_tooltip);
|
|
|
38
38
|
_radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
39
39
|
_radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
40
40
|
|
|
41
|
-
//#region src/components/chat/BasicMarkdownRenderer.tsx
|
|
42
|
-
const SAFE_HREF = /^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i;
|
|
43
|
-
const SAFE_IMG_SRC = /^(https?:|data:image\/(?!svg)|\/|\.\/|\.\.\/)/i;
|
|
44
|
-
function sanitizeHref(href) {
|
|
45
|
-
if (!href) return void 0;
|
|
46
|
-
return SAFE_HREF.test(href.trim()) ? href : void 0;
|
|
47
|
-
}
|
|
48
|
-
function sanitizeImgSrc(src) {
|
|
49
|
-
if (!src) return void 0;
|
|
50
|
-
return SAFE_IMG_SRC.test(src.trim()) ? src : void 0;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Dependency-light built-in markdown renderer (basic GFM). Walks the
|
|
54
|
-
* framework-agnostic token tree from `@copilotkit/core` into React elements.
|
|
55
|
-
* No syntax highlighting, no math, no table/image action buttons — plug in a
|
|
56
|
-
* custom renderer via `CopilotKitProvider markdownRenderer={...}` for those.
|
|
57
|
-
*/
|
|
58
|
-
function BasicMarkdownRenderer({ content, className }) {
|
|
59
|
-
const tokens = react.default.useMemo(() => (0, _copilotkit_core.parseMarkdown)(content ?? ""), [content]);
|
|
60
|
-
if (!tokens.length) return null;
|
|
61
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
62
|
-
className,
|
|
63
|
-
children: tokens.map((t, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BlockToken, { token: t }, i))
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
function renderInline(tokens) {
|
|
67
|
-
if (!tokens) return null;
|
|
68
|
-
return tokens.map((token, i) => {
|
|
69
|
-
switch (token.type) {
|
|
70
|
-
case "text": return "tokens" in token && token.tokens ? renderInline(token.tokens) : token.text;
|
|
71
|
-
case "strong": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: renderInline(token.tokens) }, i);
|
|
72
|
-
case "em": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("em", { children: renderInline(token.tokens) }, i);
|
|
73
|
-
case "del": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("del", { children: renderInline(token.tokens) }, i);
|
|
74
|
-
case "codespan": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
75
|
-
className: "cpk-markdown-inline-code",
|
|
76
|
-
children: token.text
|
|
77
|
-
}, i);
|
|
78
|
-
case "br": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("br", {}, i);
|
|
79
|
-
case "link": {
|
|
80
|
-
const l = token;
|
|
81
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
82
|
-
href: sanitizeHref(l.href),
|
|
83
|
-
target: "_blank",
|
|
84
|
-
rel: "noopener noreferrer",
|
|
85
|
-
children: l.tokens ? renderInline(l.tokens) : l.text
|
|
86
|
-
}, i);
|
|
87
|
-
}
|
|
88
|
-
case "image": {
|
|
89
|
-
const img = token;
|
|
90
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
91
|
-
src: sanitizeImgSrc(img.href),
|
|
92
|
-
alt: img.text,
|
|
93
|
-
className: "cpk-markdown-image"
|
|
94
|
-
}, i);
|
|
95
|
-
}
|
|
96
|
-
case "escape": return token.text;
|
|
97
|
-
default: return "text" in token ? token.text : null;
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
function BlockToken({ token }) {
|
|
102
|
-
switch (token.type) {
|
|
103
|
-
case "space": return null;
|
|
104
|
-
case "heading": {
|
|
105
|
-
const h = token;
|
|
106
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(`h${Math.min(Math.max(h.depth, 1), 6)}`, { children: renderInline(h.tokens) });
|
|
107
|
-
}
|
|
108
|
-
case "paragraph": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: renderInline(token.tokens ?? []) });
|
|
109
|
-
case "blockquote": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("blockquote", { children: (token.tokens ?? []).map((t, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BlockToken, { token: t }, i)) });
|
|
110
|
-
case "code": {
|
|
111
|
-
const c = token;
|
|
112
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
|
113
|
-
className: "cpk-markdown-code-block",
|
|
114
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
115
|
-
"data-language": c.lang || void 0,
|
|
116
|
-
children: c.text
|
|
117
|
-
})
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
case "hr": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hr", {});
|
|
121
|
-
case "list": {
|
|
122
|
-
const list = token;
|
|
123
|
-
const items = list.items.map((item, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: (item.tokens ?? []).map((t, j) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BlockToken, { token: t }, j)) }, i));
|
|
124
|
-
return list.ordered ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ol", {
|
|
125
|
-
start: typeof list.start === "number" ? list.start : void 0,
|
|
126
|
-
children: items
|
|
127
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", { children: items });
|
|
128
|
-
}
|
|
129
|
-
case "table": {
|
|
130
|
-
const tbl = token;
|
|
131
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
132
|
-
className: "cpk-markdown-table-container",
|
|
133
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", { children: tbl.header.map((cell, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", { children: renderInline(cell.tokens) }, i)) }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: tbl.rows.map((row, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", { children: row.map((cell, j) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", { children: renderInline(cell.tokens) }, j)) }, i)) })] })
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
case "text": {
|
|
137
|
-
const t = token;
|
|
138
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t.tokens ? renderInline(t.tokens) : t.text });
|
|
139
|
-
}
|
|
140
|
-
default: return "text" in token ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: token.text }) : null;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
BasicMarkdownRenderer.displayName = "BasicMarkdownRenderer";
|
|
144
|
-
|
|
145
|
-
//#endregion
|
|
146
41
|
//#region src/components/chat/StreamingMarkdownDefaultRenderer.tsx
|
|
147
42
|
const defaultNodeRenderers = (0, _copilotkit_markdown_renderer_react.createStreamingMarkdownNodeRenderers)({ codeBlock: ({ node }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
|
148
43
|
className: "cpk-markdown-code-block",
|
|
@@ -178,11 +73,114 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
178
73
|
}
|
|
179
74
|
StreamingMarkdownDefaultRenderer.displayName = "StreamingMarkdownDefaultRenderer";
|
|
180
75
|
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/lib/utils.ts
|
|
78
|
+
/**
|
|
79
|
+
* Joins class names, skipping falsy values. Takes the same inputs as `clsx`.
|
|
80
|
+
* Classes are not merged: every rule CopilotKit ships sits in `:where()`, so a
|
|
81
|
+
* class the app adds wins without removing ours.
|
|
82
|
+
*/
|
|
83
|
+
function cn(...inputs) {
|
|
84
|
+
const out = [];
|
|
85
|
+
for (const input of inputs) {
|
|
86
|
+
if (!input) continue;
|
|
87
|
+
if (typeof input === "string" || typeof input === "number" || typeof input === "bigint") out.push(String(input));
|
|
88
|
+
else if (Array.isArray(input)) {
|
|
89
|
+
const nested = cn(...input);
|
|
90
|
+
if (nested) out.push(nested);
|
|
91
|
+
} else if (typeof input === "object") {
|
|
92
|
+
for (const key in input) if (input[key]) out.push(key);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return out.join(" ");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/components/icons/CopilotIcon.tsx
|
|
100
|
+
/** Turns SVG attribute names such as `stroke-width` into React's `strokeWidth`. */
|
|
101
|
+
function toReactAttributes(attributes) {
|
|
102
|
+
return Object.fromEntries(Object.entries(attributes).map(([key, value]) => [key.replace(/-([a-z])/g, (_match, letter) => letter.toUpperCase()), value]));
|
|
103
|
+
}
|
|
104
|
+
const svgDefaults = toReactAttributes(_copilotkit_core.ɵcopilotIconSvgAttributes);
|
|
105
|
+
/** True when the props give the icon an accessible name or role. */
|
|
106
|
+
function hasAccessibleProp(props) {
|
|
107
|
+
return Object.keys(props).some((key) => key.startsWith("aria-") || key === "role" || key === "title");
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Internal. Draws a Lucide icon from its node data, the way Lucide's React package
|
|
111
|
+
* does: Lucide's default SVG attributes, the `lucide lucide-<name>` classes,
|
|
112
|
+
* and `aria-hidden="true"` when no `aria-*`, `role` or `title` prop names it.
|
|
113
|
+
*/
|
|
114
|
+
const IconSvg = (0, react.forwardRef)(function IconSvg({ lucideName, nodes, size = 24, color = "currentColor", strokeWidth = 2, className, children, ...props }, ref) {
|
|
115
|
+
const isDecorative = !children && !hasAccessibleProp(props);
|
|
116
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
117
|
+
ref,
|
|
118
|
+
...svgDefaults,
|
|
119
|
+
width: size,
|
|
120
|
+
height: size,
|
|
121
|
+
stroke: color,
|
|
122
|
+
strokeWidth,
|
|
123
|
+
className: cn("lucide", `lucide-${lucideName}`, className),
|
|
124
|
+
"aria-hidden": isDecorative || void 0,
|
|
125
|
+
...props,
|
|
126
|
+
children: [nodes.map((node, index) => (0, react.createElement)(node.tag, {
|
|
127
|
+
key: index,
|
|
128
|
+
...node.attributes
|
|
129
|
+
})), children]
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
/**
|
|
133
|
+
* Draws one of the chat icons as an inline `<svg>`.
|
|
134
|
+
*
|
|
135
|
+
* The `<svg>` has the classes `lucide lucide-<icon name>`, so CSS that selects
|
|
136
|
+
* them (for example `svg.lucide-arrow-up`) keeps working. The icon is hidden
|
|
137
|
+
* from screen readers unless you give it an `aria-label`, `role` or `title`.
|
|
138
|
+
*
|
|
139
|
+
* @param props.name - The chat icon, for example `"ArrowUp"` or `"X"`.
|
|
140
|
+
* @param props.size - Width and height. Defaults to `24`.
|
|
141
|
+
* @param props.strokeWidth - Line width. Defaults to `2`.
|
|
142
|
+
* @param props.color - Line color. Defaults to `currentColor`.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```tsx
|
|
146
|
+
* <CopilotIcon name="ArrowUp" className="cpk-chat-input-send-icon" />
|
|
147
|
+
* <CopilotIcon name="X" aria-label="Close" />
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
const CopilotIcon = (0, react.forwardRef)(function CopilotIcon({ name, ...props }, ref) {
|
|
151
|
+
const icon = _copilotkit_core.ɵcopilotIcons[name];
|
|
152
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconSvg, {
|
|
153
|
+
ref,
|
|
154
|
+
lucideName: icon.name,
|
|
155
|
+
nodes: icon.nodes,
|
|
156
|
+
...props
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
|
|
181
160
|
//#endregion
|
|
182
161
|
//#region src/lib/react-core.ts
|
|
162
|
+
/**
|
|
163
|
+
* Wait for pending React state updates before the follow-up agent run.
|
|
164
|
+
*
|
|
165
|
+
* When a frontend tool handler calls setState(), React 18 batches the update
|
|
166
|
+
* and schedules a commit via its internal scheduler (MessageChannel). The
|
|
167
|
+
* useAgentContext hook registers context via useLayoutEffect, which runs
|
|
168
|
+
* synchronously after React commits that batch.
|
|
169
|
+
*
|
|
170
|
+
* Awaiting a zero-delay timeout yields to the macrotask queue. React's
|
|
171
|
+
* MessageChannel task runs first, committing the pending state and running
|
|
172
|
+
* useLayoutEffect (which updates the context store). The follow-up runAgent
|
|
173
|
+
* call then reads fresh context.
|
|
174
|
+
*/
|
|
175
|
+
function waitForReactCommit() {
|
|
176
|
+
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
177
|
+
}
|
|
183
178
|
var CopilotKitCoreReact = class extends _copilotkit_core.CopilotKitCore {
|
|
184
179
|
constructor(config) {
|
|
185
|
-
super(
|
|
180
|
+
super({
|
|
181
|
+
...config,
|
|
182
|
+
ɵwaitForFrameworkUpdates: waitForReactCommit
|
|
183
|
+
});
|
|
186
184
|
this._renderToolCalls = [];
|
|
187
185
|
this._hookRenderToolCalls = /* @__PURE__ */ new Map();
|
|
188
186
|
this._cachedMergedRenderToolCalls = null;
|
|
@@ -256,22 +254,6 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
256
254
|
subscribe(subscriber) {
|
|
257
255
|
return super.subscribe(subscriber);
|
|
258
256
|
}
|
|
259
|
-
/**
|
|
260
|
-
* Wait for pending React state updates before the follow-up agent run.
|
|
261
|
-
*
|
|
262
|
-
* When a frontend tool handler calls setState(), React 18 batches the update
|
|
263
|
-
* and schedules a commit via its internal scheduler (MessageChannel). The
|
|
264
|
-
* useAgentContext hook registers context via useLayoutEffect, which runs
|
|
265
|
-
* synchronously after React commits that batch.
|
|
266
|
-
*
|
|
267
|
-
* Awaiting a zero-delay timeout yields to the macrotask queue. React's
|
|
268
|
-
* MessageChannel task runs first, committing the pending state and running
|
|
269
|
-
* useLayoutEffect (which updates the context store). The follow-up runAgent
|
|
270
|
-
* call then reads fresh context.
|
|
271
|
-
*/
|
|
272
|
-
async waitForPendingFrameworkUpdates() {
|
|
273
|
-
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
274
|
-
}
|
|
275
257
|
};
|
|
276
258
|
|
|
277
259
|
//#endregion
|
|
@@ -350,52 +332,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
350
332
|
|
|
351
333
|
//#endregion
|
|
352
334
|
//#region src/providers/CopilotChatConfigurationProvider.tsx
|
|
353
|
-
|
|
354
|
-
chatInputPlaceholder: "Type a message...",
|
|
355
|
-
chatInputToolbarStartTranscribeButtonLabel: "Transcribe",
|
|
356
|
-
chatInputToolbarCancelTranscribeButtonLabel: "Cancel",
|
|
357
|
-
chatInputToolbarFinishTranscribeButtonLabel: "Finish",
|
|
358
|
-
chatInputToolbarAddButtonLabel: "Add attachments",
|
|
359
|
-
chatInputToolbarToolsButtonLabel: "Tools",
|
|
360
|
-
chatInputToolbarSendButtonLabel: "Send message",
|
|
361
|
-
chatInputToolbarStopButtonLabel: "Stop",
|
|
362
|
-
assistantMessageToolbarCopyCodeLabel: "Copy",
|
|
363
|
-
assistantMessageToolbarCopyCodeCopiedLabel: "Copied",
|
|
364
|
-
assistantMessageToolbarCopyMessageLabel: "Copy",
|
|
365
|
-
assistantMessageToolbarInspectorLabel: "View in Inspector",
|
|
366
|
-
assistantMessageToolbarInspectorDescription: "Open this message in the Inspector",
|
|
367
|
-
assistantMessageToolbarInspectorLocalOnlyLabel: "Local only",
|
|
368
|
-
assistantMessageToolbarInspectorLocalOnlyDescription: "Only visible on localhost or loopback hosts in development. Never shown in production.",
|
|
369
|
-
assistantMessageToolbarInspectorTitle: "CopilotKit Inspector",
|
|
370
|
-
assistantMessageToolbarInspectorHideLabel: "Hide this icon",
|
|
371
|
-
assistantMessageToolbarInspectorHideDescription: "Until you reload this page",
|
|
372
|
-
assistantMessageToolbarThumbsUpLabel: "Good response",
|
|
373
|
-
assistantMessageToolbarThumbsDownLabel: "Bad response",
|
|
374
|
-
assistantMessageFeedbackCommentPlaceholder: "Add a comment (optional)",
|
|
375
|
-
assistantMessageFeedbackCommentSubmitLabel: "Send comment",
|
|
376
|
-
assistantMessageToolbarReadAloudLabel: "Read aloud",
|
|
377
|
-
assistantMessageToolbarRegenerateLabel: "Regenerate",
|
|
378
|
-
userMessageToolbarCopyMessageLabel: "Copy",
|
|
379
|
-
userMessageToolbarEditMessageLabel: "Edit",
|
|
380
|
-
userMessageToolbarPreviousBranchLabel: "Previous branch",
|
|
381
|
-
userMessageToolbarNextBranchLabel: "Next branch",
|
|
382
|
-
chatDisclaimerText: "AI can make mistakes. Please verify important information.",
|
|
383
|
-
chatToggleOpenLabel: "Open chat",
|
|
384
|
-
chatToggleCloseLabel: "Close chat",
|
|
385
|
-
chatScrollToBottomLabel: "Scroll to bottom",
|
|
386
|
-
modalHeaderTitle: "CopilotKit Chat",
|
|
387
|
-
welcomeMessageText: "How can I help you today?",
|
|
388
|
-
reasoningMessageThinkingLabel: "Thinking…",
|
|
389
|
-
chatInputSlashMenuLabel: "Slash commands",
|
|
390
|
-
chatInputSlashMenuEmptyText: "No commands found",
|
|
391
|
-
attachmentRemoveButtonLabel: "Remove attachment",
|
|
392
|
-
attachmentPlayVideoButtonLabel: "Play video",
|
|
393
|
-
attachmentPreviewCloseButtonLabel: "Close preview",
|
|
394
|
-
modalHeaderCloseButtonLabel: "Close",
|
|
395
|
-
modalHeaderThreadsButtonLabel: "Open threads",
|
|
396
|
-
sidebarLabel: "Copilot chat sidebar"
|
|
397
|
-
};
|
|
398
|
-
/**
|
|
335
|
+
/**
|
|
399
336
|
* Mobile breakpoint below which the chat modal and the thread-list drawer are
|
|
400
337
|
* mutually exclusive. At or above this width both surfaces may coexist. This
|
|
401
338
|
* mirrors the `(max-width: 767px)` / `(min-width: 768px)` split already used by
|
|
@@ -419,7 +356,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
419
356
|
const parentConfig = (0, react.useContext)(CopilotChatConfiguration);
|
|
420
357
|
const stableLabels = useShallowStableRef(labels);
|
|
421
358
|
const mergedLabels = (0, react.useMemo)(() => ({
|
|
422
|
-
...CopilotChatDefaultLabels,
|
|
359
|
+
..._copilotkit_core.CopilotChatDefaultLabels,
|
|
423
360
|
...parentConfig?.labels,
|
|
424
361
|
...stableLabels
|
|
425
362
|
}), [stableLabels, parentConfig?.labels]);
|
|
@@ -651,28 +588,6 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
651
588
|
};
|
|
652
589
|
ControlledModalOpenScope.displayName = "ControlledModalOpenScope";
|
|
653
590
|
|
|
654
|
-
//#endregion
|
|
655
|
-
//#region src/lib/utils.ts
|
|
656
|
-
/**
|
|
657
|
-
* Joins class names, skipping falsy values. Takes the same inputs as `clsx`.
|
|
658
|
-
* Classes are not merged: every rule CopilotKit ships sits in `:where()`, so a
|
|
659
|
-
* class the app adds wins without removing ours.
|
|
660
|
-
*/
|
|
661
|
-
function cn(...inputs) {
|
|
662
|
-
const out = [];
|
|
663
|
-
for (const input of inputs) {
|
|
664
|
-
if (!input) continue;
|
|
665
|
-
if (typeof input === "string" || typeof input === "number" || typeof input === "bigint") out.push(String(input));
|
|
666
|
-
else if (Array.isArray(input)) {
|
|
667
|
-
const nested = cn(...input);
|
|
668
|
-
if (nested) out.push(nested);
|
|
669
|
-
} else if (typeof input === "object") {
|
|
670
|
-
for (const key in input) if (input[key]) out.push(key);
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
return out.join(" ");
|
|
674
|
-
}
|
|
675
|
-
|
|
676
591
|
//#endregion
|
|
677
592
|
//#region src/components/ui/button.tsx
|
|
678
593
|
const variantClasses = {
|
|
@@ -701,8 +616,8 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
701
616
|
function buttonVariants({ variant, size, className, class: classProp } = {}) {
|
|
702
617
|
return cn("cpk-button", variant !== null && variantClasses[variant ?? "default"], size !== null && sizeClasses[size ?? "default"], classProp, className);
|
|
703
618
|
}
|
|
704
|
-
const Button = react.forwardRef(function Button({ className, variant, size,
|
|
705
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
619
|
+
const Button = react.forwardRef(function Button({ className, variant, size, ...props }, ref) {
|
|
620
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
706
621
|
ref,
|
|
707
622
|
"data-slot": "button",
|
|
708
623
|
className: buttonVariants({
|
|
@@ -807,7 +722,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
807
722
|
"data-inset": inset,
|
|
808
723
|
className: cn("cpk-dropdown-menu-sub-trigger", className),
|
|
809
724
|
...props,
|
|
810
|
-
children: [children, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
725
|
+
children: [children, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
726
|
+
name: "ChevronRight",
|
|
727
|
+
className: "cpk-dropdown-menu-sub-trigger-icon"
|
|
728
|
+
})]
|
|
811
729
|
});
|
|
812
730
|
}
|
|
813
731
|
function DropdownMenuSubContent({ className, ...props }) {
|
|
@@ -1108,7 +1026,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
1108
1026
|
const audioRecorderRef = (0, react.useRef)(null);
|
|
1109
1027
|
const slashMenuRef = (0, react.useRef)(null);
|
|
1110
1028
|
const config = useCopilotChatConfiguration();
|
|
1111
|
-
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
1029
|
+
const labels = config?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
1112
1030
|
const previousModalStateRef = (0, react.useRef)(void 0);
|
|
1113
1031
|
const measurementCanvasRef = (0, react.useRef)(null);
|
|
1114
1032
|
const measurementsRef = (0, react.useRef)({
|
|
@@ -1229,6 +1147,14 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
1229
1147
|
inputRef.current?.focus();
|
|
1230
1148
|
});
|
|
1231
1149
|
}, [clearInputValue]);
|
|
1150
|
+
const composerInput = {
|
|
1151
|
+
mode,
|
|
1152
|
+
isRunning,
|
|
1153
|
+
value: resolvedValue,
|
|
1154
|
+
canSubmit: !!onSubmitMessage,
|
|
1155
|
+
canStop: !!onStop
|
|
1156
|
+
};
|
|
1157
|
+
const { isProcessing, action: buttonAction, disabled: buttonDisabled } = (0, _copilotkit_core.ɵcomposerButtonState)(composerInput);
|
|
1232
1158
|
const handleKeyDown = (e) => {
|
|
1233
1159
|
if (e.nativeEvent.isComposing || e.keyCode === 229) return;
|
|
1234
1160
|
if (commandQuery !== null && mode === "input") {
|
|
@@ -1267,11 +1193,15 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
1267
1193
|
return;
|
|
1268
1194
|
}
|
|
1269
1195
|
}
|
|
1270
|
-
if (e.key === "Enter" && !e.shiftKey)
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1196
|
+
if (e.key === "Enter" && !e.shiftKey) e.preventDefault();
|
|
1197
|
+
const action = (0, _copilotkit_core.ɵresolveComposerKey)({
|
|
1198
|
+
key: e.key,
|
|
1199
|
+
shiftKey: e.shiftKey,
|
|
1200
|
+
isComposing: e.nativeEvent.isComposing,
|
|
1201
|
+
keyCode: e.keyCode
|
|
1202
|
+
}, composerInput);
|
|
1203
|
+
if (action === "stop") onStop?.();
|
|
1204
|
+
else if (action === "send") send();
|
|
1275
1205
|
};
|
|
1276
1206
|
const send = () => {
|
|
1277
1207
|
if (!onSubmitMessage) return;
|
|
@@ -1296,9 +1226,6 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
1296
1226
|
autoFocus,
|
|
1297
1227
|
className: isExpanded ? "cpk-chat-input-textarea-expanded" : "cpk-chat-input-textarea-compact"
|
|
1298
1228
|
});
|
|
1299
|
-
const isProcessing = mode !== "transcribe" && isRunning;
|
|
1300
|
-
const canSend = resolvedValue.trim().length > 0 && !!onSubmitMessage;
|
|
1301
|
-
const canStop = !!onStop;
|
|
1302
1229
|
const handleSendButtonClick = () => {
|
|
1303
1230
|
if (isProcessing) {
|
|
1304
1231
|
onStop?.();
|
|
@@ -1307,12 +1234,15 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
1307
1234
|
send();
|
|
1308
1235
|
};
|
|
1309
1236
|
const BoundAudioRecorder = renderSlot(audioRecorder, CopilotChatAudioRecorder, { ref: audioRecorderRef });
|
|
1310
|
-
const showsStop =
|
|
1237
|
+
const showsStop = buttonAction === "stop";
|
|
1311
1238
|
const BoundSendButton = renderSlot(sendButton, CopilotChatInput.SendButton, {
|
|
1312
1239
|
onClick: handleSendButtonClick,
|
|
1313
|
-
disabled:
|
|
1240
|
+
disabled: buttonDisabled,
|
|
1314
1241
|
"aria-label": showsStop ? labels.chatInputToolbarStopButtonLabel : labels.chatInputToolbarSendButtonLabel,
|
|
1315
|
-
children: showsStop ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1242
|
+
children: showsStop ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
1243
|
+
name: "Square",
|
|
1244
|
+
className: "cpk-chat-input-stop-icon"
|
|
1245
|
+
}) : void 0
|
|
1316
1246
|
});
|
|
1317
1247
|
const BoundStartTranscribeButton = renderSlot(startTranscribeButton, CopilotChatInput.StartTranscribeButton, { onClick: onStartTranscribe });
|
|
1318
1248
|
const BoundCancelTranscribeButton = renderSlot(cancelTranscribeButton, CopilotChatInput.CancelTranscribeButton, { onClick: onCancelTranscribe });
|
|
@@ -1569,7 +1499,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
1569
1499
|
className: "cpk-chat-input-field",
|
|
1570
1500
|
children: mode === "transcribe" ? BoundAudioRecorder : mode === "processing" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1571
1501
|
className: "cpk-chat-input-processing",
|
|
1572
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1502
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
1503
|
+
name: "Loader2",
|
|
1504
|
+
className: "cpk-chat-input-processing-spinner"
|
|
1505
|
+
})
|
|
1573
1506
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [BoundTextArea, slashMenu] })
|
|
1574
1507
|
}),
|
|
1575
1508
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -1629,7 +1562,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
1629
1562
|
}
|
|
1630
1563
|
(function(_CopilotChatInput) {
|
|
1631
1564
|
_CopilotChatInput.SendButton = ({ className, children, ...props }) => {
|
|
1632
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
1565
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
1633
1566
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1634
1567
|
className: "cpk-chat-input-send",
|
|
1635
1568
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
@@ -1640,12 +1573,15 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
1640
1573
|
className: cn("cpk-chat-input-send-button", className),
|
|
1641
1574
|
"aria-label": labels.chatInputToolbarSendButtonLabel,
|
|
1642
1575
|
...props,
|
|
1643
|
-
children: children ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1576
|
+
children: children ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
1577
|
+
name: "ArrowUp",
|
|
1578
|
+
className: "cpk-chat-input-send-icon"
|
|
1579
|
+
})
|
|
1644
1580
|
})
|
|
1645
1581
|
});
|
|
1646
1582
|
};
|
|
1647
1583
|
const ToolbarButton = _CopilotChatInput.ToolbarButton = ({ icon, labelKey, defaultClassName, className, ...props }) => {
|
|
1648
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
1584
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
1649
1585
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Tooltip, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipTrigger, {
|
|
1650
1586
|
asChild: true,
|
|
1651
1587
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
@@ -1664,27 +1600,36 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
1664
1600
|
};
|
|
1665
1601
|
_CopilotChatInput.StartTranscribeButton = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
1666
1602
|
"data-testid": "copilot-start-transcribe-button",
|
|
1667
|
-
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1603
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
1604
|
+
name: "Mic",
|
|
1605
|
+
className: "cpk-chat-input-toolbar-icon"
|
|
1606
|
+
}),
|
|
1668
1607
|
labelKey: "chatInputToolbarStartTranscribeButtonLabel",
|
|
1669
1608
|
defaultClassName: "cpk-chat-input-start-transcribe-button",
|
|
1670
1609
|
...props
|
|
1671
1610
|
});
|
|
1672
1611
|
_CopilotChatInput.CancelTranscribeButton = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
1673
1612
|
"data-testid": "copilot-cancel-transcribe-button",
|
|
1674
|
-
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1613
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
1614
|
+
name: "X",
|
|
1615
|
+
className: "cpk-chat-input-toolbar-icon"
|
|
1616
|
+
}),
|
|
1675
1617
|
labelKey: "chatInputToolbarCancelTranscribeButtonLabel",
|
|
1676
1618
|
defaultClassName: "cpk-chat-input-cancel-transcribe-button",
|
|
1677
1619
|
...props
|
|
1678
1620
|
});
|
|
1679
1621
|
_CopilotChatInput.FinishTranscribeButton = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
1680
1622
|
"data-testid": "copilot-finish-transcribe-button",
|
|
1681
|
-
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1623
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
1624
|
+
name: "Check",
|
|
1625
|
+
className: "cpk-chat-input-toolbar-icon"
|
|
1626
|
+
}),
|
|
1682
1627
|
labelKey: "chatInputToolbarFinishTranscribeButtonLabel",
|
|
1683
1628
|
defaultClassName: "cpk-chat-input-finish-transcribe-button",
|
|
1684
1629
|
...props
|
|
1685
1630
|
});
|
|
1686
1631
|
_CopilotChatInput.AddMenuButton = ({ className, toolsMenu, onAddFile, disabled, ...props }) => {
|
|
1687
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
1632
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
1688
1633
|
const [mounted, setMounted] = (0, react.useState)(false);
|
|
1689
1634
|
(0, react.useEffect)(() => setMounted(true), []);
|
|
1690
1635
|
const menuItems = (0, react.useMemo)(() => {
|
|
@@ -1726,7 +1671,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
1726
1671
|
disabled: isDisabled,
|
|
1727
1672
|
"aria-label": labels.chatInputToolbarAddButtonLabel,
|
|
1728
1673
|
...props,
|
|
1729
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1674
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
1675
|
+
name: "Plus",
|
|
1676
|
+
className: "cpk-chat-input-add-menu-icon"
|
|
1677
|
+
})
|
|
1730
1678
|
});
|
|
1731
1679
|
if (!mounted) return button;
|
|
1732
1680
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DropdownMenu, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Tooltip, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipTrigger, {
|
|
@@ -1752,7 +1700,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
1752
1700
|
};
|
|
1753
1701
|
_CopilotChatInput.TextArea = (0, react.forwardRef)(function TextArea({ style, className, autoFocus, placeholder, ...props }, ref) {
|
|
1754
1702
|
const internalTextareaRef = (0, react.useRef)(null);
|
|
1755
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
1703
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
1756
1704
|
(0, react.useImperativeHandle)(ref, () => internalTextareaRef.current);
|
|
1757
1705
|
(0, react.useEffect)(() => {
|
|
1758
1706
|
if (autoFocus) internalTextareaRef.current?.focus({ preventScroll: true });
|
|
@@ -1773,7 +1721,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
1773
1721
|
});
|
|
1774
1722
|
_CopilotChatInput.AudioRecorder = CopilotChatAudioRecorder;
|
|
1775
1723
|
_CopilotChatInput.Disclaimer = ({ className, ...props }) => {
|
|
1776
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
1724
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
1777
1725
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1778
1726
|
className: cn("cpk-chat-input-disclaimer", className),
|
|
1779
1727
|
...props,
|
|
@@ -1886,16 +1834,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
1886
1834
|
*/
|
|
1887
1835
|
function useToolCallRendererNames() {
|
|
1888
1836
|
const renderers = useToolCallRenderers();
|
|
1889
|
-
return (0, react.useMemo)(() =>
|
|
1890
|
-
const named = renderers.filter((rc) => rc.name !== "*");
|
|
1891
|
-
const wildcards = renderers.filter((rc) => rc.name === "*");
|
|
1892
|
-
return {
|
|
1893
|
-
named: new Set(named.map((rc) => rc.name)),
|
|
1894
|
-
groupedNames: new Set(named.filter((rc) => rc.group).map((rc) => rc.name)),
|
|
1895
|
-
wildcard: wildcards.length > 0,
|
|
1896
|
-
wildcardGroups: wildcards.some((rc) => rc.group)
|
|
1897
|
-
};
|
|
1898
|
-
}, [renderers]);
|
|
1837
|
+
return (0, react.useMemo)(() => (0, _copilotkit_core.ɵgetToolCallRendererNames)(renderers), [renderers]);
|
|
1899
1838
|
}
|
|
1900
1839
|
/**
|
|
1901
1840
|
* Hook that returns a function to render tool calls based on the render functions
|
|
@@ -1910,18 +1849,17 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
1910
1849
|
const warnedToolNames = (0, react.useRef)(/* @__PURE__ */ new Set());
|
|
1911
1850
|
const renderToolCalls = useToolCallRenderers();
|
|
1912
1851
|
const renderToolCall = (0, react.useCallback)(({ toolCall, toolMessage }) => {
|
|
1913
|
-
const
|
|
1914
|
-
const renderConfig = exactMatches.find((rc) => rc.agentId === agentId) || exactMatches.find((rc) => !rc.agentId) || exactMatches[0] || renderToolCalls.find((rc) => rc.name === "*");
|
|
1852
|
+
const renderConfig = (0, _copilotkit_core.ɵresolveToolCallRenderer)(renderToolCalls, toolCall.function.name, agentId);
|
|
1915
1853
|
if (!renderConfig) {
|
|
1916
1854
|
if (IS_DEVELOPMENT$1) unrenderedToolNames.current.add(toolCall.function.name);
|
|
1917
1855
|
return null;
|
|
1918
1856
|
}
|
|
1919
|
-
const
|
|
1857
|
+
const isExecuting = executingToolCallIds.has(toolCall.id);
|
|
1920
1858
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolCallRenderer, {
|
|
1921
1859
|
toolCall,
|
|
1922
1860
|
toolMessage,
|
|
1923
|
-
RenderComponent,
|
|
1924
|
-
isExecuting
|
|
1861
|
+
RenderComponent: renderConfig.render,
|
|
1862
|
+
isExecuting
|
|
1925
1863
|
}, toolCall.id);
|
|
1926
1864
|
}, [
|
|
1927
1865
|
renderToolCalls,
|
|
@@ -1943,7 +1881,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
1943
1881
|
|
|
1944
1882
|
//#endregion
|
|
1945
1883
|
//#region package.json
|
|
1946
|
-
var version$1 = "2.0.0-rc.
|
|
1884
|
+
var version$1 = "2.0.0-rc.8";
|
|
1947
1885
|
|
|
1948
1886
|
//#endregion
|
|
1949
1887
|
//#region src/components/CopilotKitInspector.tsx
|
|
@@ -2014,6 +1952,15 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
2014
1952
|
|
|
2015
1953
|
//#endregion
|
|
2016
1954
|
//#region src/components/license-warning-banner.tsx
|
|
1955
|
+
const labels = _copilotkit_core.CopilotChatDefaultLabels;
|
|
1956
|
+
/**
|
|
1957
|
+
* The "expires soon" banner text. Without a day count it says "soon", never
|
|
1958
|
+
* "in undefined days".
|
|
1959
|
+
*/
|
|
1960
|
+
function expiringMessage(graceRemaining) {
|
|
1961
|
+
if (graceRemaining === void 0) return labels.licenseExpiringText;
|
|
1962
|
+
return (0, _copilotkit_core.ɵformatLabel)(graceRemaining === 1 ? labels.licenseExpiringInDaysOne : labels.licenseExpiringInDaysOther, { days: graceRemaining });
|
|
1963
|
+
}
|
|
2017
1964
|
const LICENSE_BANNER_OFFSET_PX = 52;
|
|
2018
1965
|
const LICENSE_BANNER_OFFSET_VAR = "--copilotkit-license-banner-offset";
|
|
2019
1966
|
const BANNER_STYLES = {
|
|
@@ -2104,36 +2051,36 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
2104
2051
|
switch (type) {
|
|
2105
2052
|
case "no_license": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BannerShell, {
|
|
2106
2053
|
severity: "info",
|
|
2107
|
-
message:
|
|
2108
|
-
actionLabel:
|
|
2054
|
+
message: labels.licensePoweredByText,
|
|
2055
|
+
actionLabel: labels.licenseGetLicenseLabel,
|
|
2109
2056
|
actionUrl: "https://copilotkit.ai/pricing",
|
|
2110
2057
|
onDismiss
|
|
2111
2058
|
});
|
|
2112
2059
|
case "feature_unlicensed": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BannerShell, {
|
|
2113
2060
|
severity: "warning",
|
|
2114
|
-
message:
|
|
2115
|
-
actionLabel:
|
|
2061
|
+
message: (0, _copilotkit_core.ɵformatLabel)(labels.licenseFeatureUnlicensedText, { feature: featureName ?? "" }),
|
|
2062
|
+
actionLabel: labels.licenseGetLicenseLabel,
|
|
2116
2063
|
actionUrl: "https://copilotkit.ai/pricing",
|
|
2117
2064
|
onDismiss
|
|
2118
2065
|
});
|
|
2119
2066
|
case "expiring": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BannerShell, {
|
|
2120
2067
|
severity: "warning",
|
|
2121
|
-
message:
|
|
2122
|
-
actionLabel:
|
|
2068
|
+
message: expiringMessage(graceRemaining),
|
|
2069
|
+
actionLabel: labels.licenseRenewLabel,
|
|
2123
2070
|
actionUrl: "https://dashboard.operations.copilotkit.ai",
|
|
2124
2071
|
onDismiss
|
|
2125
2072
|
});
|
|
2126
2073
|
case "expired": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BannerShell, {
|
|
2127
2074
|
severity: "critical",
|
|
2128
|
-
message:
|
|
2129
|
-
actionLabel:
|
|
2075
|
+
message: expiryDate ? (0, _copilotkit_core.ɵformatLabel)(labels.licenseExpiredOnDateText, { date: expiryDate }) : labels.licenseExpiredText,
|
|
2076
|
+
actionLabel: labels.licenseRenewNowLabel,
|
|
2130
2077
|
actionUrl: "https://copilotkit.ai/pricing",
|
|
2131
2078
|
onDismiss
|
|
2132
2079
|
});
|
|
2133
2080
|
case "invalid": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BannerShell, {
|
|
2134
2081
|
severity: "critical",
|
|
2135
|
-
message:
|
|
2136
|
-
actionLabel:
|
|
2082
|
+
message: labels.licenseInvalidText,
|
|
2083
|
+
actionLabel: labels.licenseGetLicenseLabel,
|
|
2137
2084
|
actionUrl: "https://copilotkit.ai/pricing",
|
|
2138
2085
|
onDismiss
|
|
2139
2086
|
});
|
|
@@ -2152,9 +2099,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
2152
2099
|
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif"
|
|
2153
2100
|
},
|
|
2154
2101
|
children: [
|
|
2155
|
-
|
|
2156
|
-
featureName,
|
|
2157
|
-
"\" feature requires a CopilotKit license.",
|
|
2102
|
+
(0, _copilotkit_core.ɵformatLabel)(labels.licenseFeatureUnlicensedText, { feature: featureName }),
|
|
2158
2103
|
" ",
|
|
2159
2104
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
2160
2105
|
href: "https://copilotkit.ai/pricing",
|
|
@@ -3481,7 +3426,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
3481
3426
|
//#endregion
|
|
3482
3427
|
//#region src/types/defineToolCallRenderer.ts
|
|
3483
3428
|
function defineToolCallRenderer(def) {
|
|
3484
|
-
const argsSchema = def.name === "*" && !def.args ?
|
|
3429
|
+
const argsSchema = def.name === "*" && !def.args ? _copilotkit_shared.ɵanySchema : def.args;
|
|
3485
3430
|
return {
|
|
3486
3431
|
name: def.name,
|
|
3487
3432
|
args: argsSchema,
|
|
@@ -8324,7 +8269,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
8324
8269
|
const combined = [...renderToolCallsList];
|
|
8325
8270
|
[...frontendToolsList, ...builtInFrontendTools].forEach((tool) => {
|
|
8326
8271
|
if (tool.render) {
|
|
8327
|
-
const args = tool.parameters || (tool.name === "*" ?
|
|
8272
|
+
const args = tool.parameters || (tool.name === "*" ? _copilotkit_shared.ɵanySchema : void 0);
|
|
8328
8273
|
if (args) combined.push({
|
|
8329
8274
|
name: tool.name,
|
|
8330
8275
|
args,
|
|
@@ -8571,26 +8516,17 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
8571
8516
|
executingToolCallIds,
|
|
8572
8517
|
showIntelligenceIndicator
|
|
8573
8518
|
]);
|
|
8574
|
-
const
|
|
8575
|
-
|
|
8576
|
-
|
|
8577
|
-
|
|
8578
|
-
|
|
8579
|
-
|
|
8580
|
-
|
|
8581
|
-
if (!terminalRuntimeEntitlementFailure) return runtimeLicenseContext;
|
|
8582
|
-
return {
|
|
8583
|
-
...runtimeLicenseContext,
|
|
8584
|
-
checkFeature: () => false,
|
|
8585
|
-
getLimit: () => null
|
|
8586
|
-
};
|
|
8587
|
-
}, [
|
|
8588
|
-
terminalRuntimeEntitlementFailure,
|
|
8589
|
-
runtimeEntitlementRetryInProgress,
|
|
8519
|
+
const licenseState = (0, react.useMemo)(() => (0, _copilotkit_core.ɵresolveLicenseState)({
|
|
8520
|
+
status: runtimeLicenseStatus,
|
|
8521
|
+
entitlements: runtimeEntitlements,
|
|
8522
|
+
retryPending: runtimeEntitlementRetryPending,
|
|
8523
|
+
publicKey: resolvedPublicKey
|
|
8524
|
+
}), [
|
|
8525
|
+
runtimeLicenseStatus,
|
|
8590
8526
|
runtimeEntitlements,
|
|
8591
|
-
|
|
8527
|
+
runtimeEntitlementRetryPending,
|
|
8528
|
+
resolvedPublicKey
|
|
8592
8529
|
]);
|
|
8593
|
-
const runtimeLicenseWarningStatus = runtimeEntitlementRetryInProgress ? void 0 : licenseContextValue.status ?? void 0;
|
|
8594
8530
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotStyleOptionsProvider, {
|
|
8595
8531
|
value: (0, react.useMemo)(() => ({
|
|
8596
8532
|
nonce,
|
|
@@ -8601,7 +8537,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
8601
8537
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitContext.Provider, {
|
|
8602
8538
|
value: contextValue,
|
|
8603
8539
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(LicenseContext.Provider, {
|
|
8604
|
-
value:
|
|
8540
|
+
value: licenseState.context,
|
|
8605
8541
|
children: [
|
|
8606
8542
|
a2uiActive && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(A2UIBuiltInToolCallRenderer, {}),
|
|
8607
8543
|
generativeUIActive && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GenerativeUIToolCallRenderer, {}),
|
|
@@ -8626,10 +8562,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
8626
8562
|
}) : null]
|
|
8627
8563
|
})
|
|
8628
8564
|
}),
|
|
8629
|
-
|
|
8630
|
-
runtimeLicenseWarningStatus === "expired" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "expired" }),
|
|
8631
|
-
runtimeLicenseWarningStatus === "invalid" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "invalid" }),
|
|
8632
|
-
runtimeLicenseWarningStatus === "expiring" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "expiring" })
|
|
8565
|
+
licenseState.bannerType && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: licenseState.bannerType })
|
|
8633
8566
|
]
|
|
8634
8567
|
})
|
|
8635
8568
|
})
|
|
@@ -8644,11 +8577,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
8644
8577
|
const config = useCopilotChatConfiguration();
|
|
8645
8578
|
if (!config) return null;
|
|
8646
8579
|
const { agentId, threadId } = config;
|
|
8647
|
-
const customMessageRenderers =
|
|
8648
|
-
const aHasAgent = a.agentId !== void 0;
|
|
8649
|
-
if (aHasAgent === (b.agentId !== void 0)) return 0;
|
|
8650
|
-
return aHasAgent ? -1 : 1;
|
|
8651
|
-
});
|
|
8580
|
+
const customMessageRenderers = (0, _copilotkit_core.ɵresolveCustomMessageRenderers)(copilotkit.renderCustomMessages, agentId);
|
|
8652
8581
|
if (!customMessageRenderers.length) return null;
|
|
8653
8582
|
return function(params) {
|
|
8654
8583
|
const { message, position } = params;
|
|
@@ -8684,6 +8613,18 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
8684
8613
|
|
|
8685
8614
|
//#endregion
|
|
8686
8615
|
//#region src/hooks/use-render-activity-message.tsx
|
|
8616
|
+
/**
|
|
8617
|
+
* Explain why an activity message that has a renderer drew nothing: its
|
|
8618
|
+
* content validates asynchronously, or it fails the renderer's schema.
|
|
8619
|
+
*/
|
|
8620
|
+
function warnAboutRejectedContent(renderer, message) {
|
|
8621
|
+
const result = renderer.content["~standard"].validate(message.content);
|
|
8622
|
+
if (result instanceof Promise) {
|
|
8623
|
+
console.warn(`Async content validation is not supported for activity message '${message.activityType}'`);
|
|
8624
|
+
return;
|
|
8625
|
+
}
|
|
8626
|
+
if (result.issues) console.warn(`Failed to parse content for activity message '${message.activityType}':`, result.issues);
|
|
8627
|
+
}
|
|
8687
8628
|
function useRenderActivityMessage() {
|
|
8688
8629
|
const { copilotkit } = useCopilotKit();
|
|
8689
8630
|
const agentId = useCopilotChatConfiguration()?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
@@ -8694,29 +8635,29 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
8694
8635
|
return matches.find((candidate) => candidate.agentId === agentId) ?? matches.find((candidate) => candidate.agentId === void 0) ?? renderers.find((candidate) => candidate.activityType === "*") ?? null;
|
|
8695
8636
|
}, [agentId, renderers]);
|
|
8696
8637
|
const renderActivityMessage = (0, react.useCallback)((message) => {
|
|
8697
|
-
const
|
|
8698
|
-
|
|
8699
|
-
|
|
8700
|
-
|
|
8701
|
-
|
|
8702
|
-
|
|
8703
|
-
|
|
8704
|
-
|
|
8705
|
-
console.warn(`Failed to parse content for activity message '${message.activityType}':`, parseResult.issues);
|
|
8638
|
+
const match = (0, _copilotkit_core.ɵresolveActivityRenderer)(renderers, {
|
|
8639
|
+
activityType: message.activityType,
|
|
8640
|
+
agentId,
|
|
8641
|
+
content: message.content
|
|
8642
|
+
});
|
|
8643
|
+
if (!match) {
|
|
8644
|
+
const renderer = findRenderer(message.activityType);
|
|
8645
|
+
if (renderer) warnAboutRejectedContent(renderer, message);
|
|
8706
8646
|
return null;
|
|
8707
8647
|
}
|
|
8708
|
-
const Component = renderer.render;
|
|
8648
|
+
const Component = match.renderer.render;
|
|
8709
8649
|
const agent = copilotkit.getAgent(agentId);
|
|
8710
8650
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
|
|
8711
8651
|
activityType: message.activityType,
|
|
8712
|
-
content:
|
|
8652
|
+
content: match.content,
|
|
8713
8653
|
message,
|
|
8714
8654
|
agent
|
|
8715
8655
|
}, message.id);
|
|
8716
8656
|
}, [
|
|
8717
8657
|
agentId,
|
|
8718
8658
|
copilotkit,
|
|
8719
|
-
findRenderer
|
|
8659
|
+
findRenderer,
|
|
8660
|
+
renderers
|
|
8720
8661
|
]);
|
|
8721
8662
|
return (0, react.useMemo)(() => ({
|
|
8722
8663
|
renderActivityMessage,
|
|
@@ -8801,6 +8742,30 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
8801
8742
|
|
|
8802
8743
|
//#endregion
|
|
8803
8744
|
//#region src/hooks/use-frontend-tool.tsx
|
|
8745
|
+
/**
|
|
8746
|
+
* Register a frontend tool while the component is mounted. The agent can
|
|
8747
|
+
* call it, and its `render` component draws the call in the chat.
|
|
8748
|
+
*
|
|
8749
|
+
* A tool with the same name and agentId as a tool that is already registered
|
|
8750
|
+
* (for example one from the provider's `tools`) overrides it while this
|
|
8751
|
+
* component is mounted. When the component unmounts, the overridden tool is
|
|
8752
|
+
* active again. The renderer stays registered after unmount, so past tool
|
|
8753
|
+
* calls still render in the chat history.
|
|
8754
|
+
*
|
|
8755
|
+
* @param tool - The tool to register.
|
|
8756
|
+
* @param deps - Extra values that re-register the tool when they change. Use
|
|
8757
|
+
* it when the handler closes over a value that is not part of the tool.
|
|
8758
|
+
*
|
|
8759
|
+
* @example
|
|
8760
|
+
* ```tsx
|
|
8761
|
+
* useFrontendTool({
|
|
8762
|
+
* name: "showWeather",
|
|
8763
|
+
* description: "Show the weather for a city",
|
|
8764
|
+
* parameters: z.object({ city: z.string() }),
|
|
8765
|
+
* handler: async ({ city }) => `Sunny in ${city}`,
|
|
8766
|
+
* });
|
|
8767
|
+
* ```
|
|
8768
|
+
*/
|
|
8804
8769
|
function useFrontendTool(tool, deps) {
|
|
8805
8770
|
const { copilotkit } = useCopilotKit();
|
|
8806
8771
|
const depsVersion = useDepsVersion(deps);
|
|
@@ -8809,11 +8774,8 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
8809
8774
|
if (copilotkit.getTool({
|
|
8810
8775
|
toolName: name,
|
|
8811
8776
|
agentId: tool.agentId
|
|
8812
|
-
})) {
|
|
8813
|
-
|
|
8814
|
-
copilotkit.removeTool(name, tool.agentId);
|
|
8815
|
-
}
|
|
8816
|
-
copilotkit.addTool(tool);
|
|
8777
|
+
})) console.warn(`Tool '${name}' already exists for agent '${tool.agentId || "global"}'. Overriding with latest registration.`);
|
|
8778
|
+
const unregister = copilotkit.addTool(tool);
|
|
8817
8779
|
if (tool.render) copilotkit.addHookRenderToolCall({
|
|
8818
8780
|
name,
|
|
8819
8781
|
args: tool.parameters,
|
|
@@ -8821,7 +8783,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
8821
8783
|
render: tool.render
|
|
8822
8784
|
});
|
|
8823
8785
|
return () => {
|
|
8824
|
-
|
|
8786
|
+
unregister();
|
|
8825
8787
|
};
|
|
8826
8788
|
}, [
|
|
8827
8789
|
tool.name,
|
|
@@ -8846,8 +8808,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
8846
8808
|
*
|
|
8847
8809
|
* Tools are keyed by `name` plus `agentId`, the same as `useFrontendTool`. A
|
|
8848
8810
|
* tool that disappears from the array is unregistered on the next render, and
|
|
8849
|
-
* every tool is unregistered on unmount.
|
|
8850
|
-
*
|
|
8811
|
+
* every tool is unregistered on unmount. A listed tool hides a tool with the
|
|
8812
|
+
* same name and agentId (for example one from the provider's `tools`) until it
|
|
8813
|
+
* is unregistered, and then the hidden tool is active again. Renderers stay
|
|
8814
|
+
* registered after unmount so past tool calls still render in the chat history.
|
|
8851
8815
|
*
|
|
8852
8816
|
* @param tools - The tools to register. May be empty and may change length.
|
|
8853
8817
|
* @param deps - Extra dependencies that force re-registration, compared by
|
|
@@ -8897,15 +8861,13 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
8897
8861
|
deduped.set(key, tool);
|
|
8898
8862
|
}
|
|
8899
8863
|
const registered = [...deduped.values()];
|
|
8864
|
+
const unregisters = [];
|
|
8900
8865
|
for (const tool of registered) {
|
|
8901
8866
|
if (copilotkit.getTool({
|
|
8902
8867
|
toolName: tool.name,
|
|
8903
8868
|
agentId: tool.agentId
|
|
8904
|
-
})) {
|
|
8905
|
-
|
|
8906
|
-
copilotkit.removeTool(tool.name, tool.agentId);
|
|
8907
|
-
}
|
|
8908
|
-
copilotkit.addTool(tool);
|
|
8869
|
+
})) console.warn(`Tool '${tool.name}' already exists for agent '${tool.agentId || "global"}'. Overriding with latest registration.`);
|
|
8870
|
+
unregisters.push(copilotkit.addTool(tool));
|
|
8909
8871
|
if (tool.render) copilotkit.addHookRenderToolCall({
|
|
8910
8872
|
name: tool.name,
|
|
8911
8873
|
args: tool.parameters,
|
|
@@ -8914,7 +8876,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
8914
8876
|
});
|
|
8915
8877
|
}
|
|
8916
8878
|
return () => {
|
|
8917
|
-
for (const
|
|
8879
|
+
for (const unregister of unregisters) unregister();
|
|
8918
8880
|
};
|
|
8919
8881
|
}, [
|
|
8920
8882
|
JSON.stringify(toolList.map((tool) => [
|
|
@@ -9089,34 +9051,24 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
9089
9051
|
* @internal
|
|
9090
9052
|
*/
|
|
9091
9053
|
const ToolCallGroupContext = (0, react.createContext)(null);
|
|
9092
|
-
/**
|
|
9093
|
-
|
|
9094
|
-
|
|
9095
|
-
|
|
9096
|
-
|
|
9097
|
-
|
|
9098
|
-
const statusLabels = {
|
|
9099
|
-
running: "Running",
|
|
9100
|
-
done: "Done",
|
|
9101
|
-
failed: "Failed",
|
|
9102
|
-
stopped: "Stopped"
|
|
9054
|
+
/** The label key for each call status. */
|
|
9055
|
+
const STATUS_LABEL_KEYS = {
|
|
9056
|
+
running: "toolCallStatusRunningLabel",
|
|
9057
|
+
done: "toolCallStatusDoneLabel",
|
|
9058
|
+
failed: "toolCallStatusFailedLabel",
|
|
9059
|
+
stopped: "toolCallStatusStoppedLabel"
|
|
9103
9060
|
};
|
|
9104
|
-
/** The
|
|
9105
|
-
|
|
9106
|
-
|
|
9107
|
-
|
|
9108
|
-
|
|
9109
|
-
|
|
9110
|
-
|
|
9111
|
-
|
|
9112
|
-
|
|
9113
|
-
|
|
9114
|
-
const name = toolCall.function.name;
|
|
9115
|
-
counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
9116
|
-
}
|
|
9117
|
-
return [...counts].map(([name, count]) => count > 1 ? `${name} ×${count}` : name).join(", ");
|
|
9061
|
+
/** The icon for each call status. */
|
|
9062
|
+
const STATUS_ICONS = {
|
|
9063
|
+
running: "Loader2",
|
|
9064
|
+
done: "Check",
|
|
9065
|
+
failed: "X",
|
|
9066
|
+
stopped: "Circle"
|
|
9067
|
+
};
|
|
9068
|
+
/** The chat labels from the nearest chat configuration, or the defaults. */
|
|
9069
|
+
function useLabels$1() {
|
|
9070
|
+
return useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
9118
9071
|
}
|
|
9119
|
-
const pluralize = (count, noun) => `${count} ${noun}${count === 1 ? "" : "s"}`;
|
|
9120
9072
|
/**
|
|
9121
9073
|
* Height transition between closed and its content's height. Closed content
|
|
9122
9074
|
* stays mounted (so its state survives) but is inert.
|
|
@@ -9139,55 +9091,35 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
9139
9091
|
});
|
|
9140
9092
|
}
|
|
9141
9093
|
function StatusIcon({ status, className }) {
|
|
9142
|
-
|
|
9143
|
-
|
|
9144
|
-
done: lucide_react.Check,
|
|
9145
|
-
failed: lucide_react.X,
|
|
9146
|
-
stopped: lucide_react.Circle
|
|
9147
|
-
}[status];
|
|
9148
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
|
|
9094
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
9095
|
+
name: STATUS_ICONS[status],
|
|
9149
9096
|
"aria-hidden": "true",
|
|
9150
9097
|
className: cn("cpk-tool-call-status-icon", status === "running" && "cpk-tool-call-status-icon-running", status === "failed" && "cpk-tool-call-status-icon-failed", className)
|
|
9151
9098
|
});
|
|
9152
9099
|
}
|
|
9153
9100
|
function Chevron({ open, className }) {
|
|
9154
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
9101
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
9102
|
+
name: "ChevronRight",
|
|
9155
9103
|
"aria-hidden": "true",
|
|
9156
9104
|
className: cn("cpk-tool-call-chevron", open && "cpk-tool-call-chevron-open", className)
|
|
9157
9105
|
});
|
|
9158
9106
|
}
|
|
9159
9107
|
function FailedCount({ calls }) {
|
|
9160
|
-
const
|
|
9108
|
+
const labels = useLabels$1();
|
|
9109
|
+
const failed = (0, _copilotkit_core.ɵcountFailedToolCalls)(calls);
|
|
9161
9110
|
if (!failed) return null;
|
|
9162
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.
|
|
9111
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
9163
9112
|
className: "cpk-tool-call-failed-count",
|
|
9164
|
-
children:
|
|
9113
|
+
children: (0, _copilotkit_core.ɵformatLabel)(labels.toolCallFailedCountLabel, { count: failed })
|
|
9165
9114
|
});
|
|
9166
9115
|
}
|
|
9167
|
-
/**
|
|
9168
|
-
* Guarded JSON.stringify for the payload blocks. A circular reference would
|
|
9169
|
-
* otherwise crash the entire React tree on render.
|
|
9170
|
-
*/
|
|
9171
|
-
function stringifyPayload(value) {
|
|
9172
|
-
if (typeof value === "string") return value;
|
|
9173
|
-
try {
|
|
9174
|
-
return JSON.stringify(value, null, 2);
|
|
9175
|
-
} catch (err) {
|
|
9176
|
-
console.warn("[CopilotKit] Failed to JSON.stringify tool-call payload; falling back to String():", err);
|
|
9177
|
-
try {
|
|
9178
|
-
return String(value);
|
|
9179
|
-
} catch {
|
|
9180
|
-
return "[unserializable]";
|
|
9181
|
-
}
|
|
9182
|
-
}
|
|
9183
|
-
}
|
|
9184
9116
|
function Payload({ label, value }) {
|
|
9185
9117
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
9186
9118
|
className: "cpk-tool-call-payload-label",
|
|
9187
9119
|
children: label
|
|
9188
9120
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
|
9189
9121
|
className: "cpk-tool-call-payload-code",
|
|
9190
|
-
children:
|
|
9122
|
+
children: (0, _copilotkit_core.ɵstringifyToolCallPayload)(value)
|
|
9191
9123
|
})] });
|
|
9192
9124
|
}
|
|
9193
9125
|
/**
|
|
@@ -9195,13 +9127,14 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
9195
9127
|
* @internal
|
|
9196
9128
|
*/
|
|
9197
9129
|
function ToolCallPayloads({ parameters, result, className }) {
|
|
9130
|
+
const labels = useLabels$1();
|
|
9198
9131
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
9199
9132
|
className: cn("cpk-tool-call-payloads", className),
|
|
9200
9133
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Payload, {
|
|
9201
|
-
label:
|
|
9134
|
+
label: labels.toolCallArgumentsLabel,
|
|
9202
9135
|
value: parameters ?? {}
|
|
9203
9136
|
}), result !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Payload, {
|
|
9204
|
-
label:
|
|
9137
|
+
label: labels.toolCallResultLabel,
|
|
9205
9138
|
value: result
|
|
9206
9139
|
})]
|
|
9207
9140
|
});
|
|
@@ -9212,9 +9145,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
9212
9145
|
* @internal
|
|
9213
9146
|
*/
|
|
9214
9147
|
function ToolCallRow({ name, parameters, result, status, appearance, className, ...props }) {
|
|
9148
|
+
const labels = useLabels$1();
|
|
9215
9149
|
const [open, setOpen] = (0, react.useState)(false);
|
|
9216
9150
|
const detailsId = (0, react.useId)();
|
|
9217
|
-
const preview =
|
|
9151
|
+
const preview = (0, _copilotkit_core.ɵgetArgumentPreview)(parameters);
|
|
9218
9152
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
9219
9153
|
"data-copilotkit": true,
|
|
9220
9154
|
className: cn("cpk-tool-call-row", `cpk-tool-call-row-${appearance}`, className),
|
|
@@ -9239,7 +9173,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
9239
9173
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
9240
9174
|
"data-testid": "copilot-tool-render-status",
|
|
9241
9175
|
className: "cpk-tool-call-row-status",
|
|
9242
|
-
children:
|
|
9176
|
+
children: labels[STATUS_LABEL_KEYS[status]]
|
|
9243
9177
|
}),
|
|
9244
9178
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chevron, {
|
|
9245
9179
|
open,
|
|
@@ -9268,14 +9202,15 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
9268
9202
|
* draws.
|
|
9269
9203
|
*/
|
|
9270
9204
|
function CopilotChatToolCallGroup({ calls, renderCall, appearance = "card", isActive = false, className, ...props }) {
|
|
9205
|
+
const labels = useLabels$1();
|
|
9271
9206
|
const [open, setOpen] = (0, react.useState)(false);
|
|
9272
9207
|
const bodyId = (0, react.useId)();
|
|
9273
9208
|
const latest = calls[calls.length - 1];
|
|
9274
9209
|
if (!latest) return null;
|
|
9275
9210
|
const current = isActive ? calls.find((call) => !call.toolMessage) ?? latest : void 0;
|
|
9276
|
-
const preview = current ?
|
|
9211
|
+
const preview = current ? (0, _copilotkit_core.ɵgetToolCallPreview)(current) : void 0;
|
|
9277
9212
|
const done = calls.filter((call) => call.toolMessage).length;
|
|
9278
|
-
const statuses = calls.map((call) =>
|
|
9213
|
+
const statuses = calls.map((call) => (0, _copilotkit_core.ɵgetToolCallRowStatus)(call, isActive));
|
|
9279
9214
|
const failedIds = new Set(calls.filter((_, index) => statuses[index] === "failed").map((call) => call.toolCall.id));
|
|
9280
9215
|
const status = current ? "running" : failedIds.size > 0 ? "failed" : statuses.includes("stopped") ? "stopped" : "done";
|
|
9281
9216
|
const rows = (rowAppearance) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolCallGroupContext.Provider, {
|
|
@@ -9293,9 +9228,9 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
9293
9228
|
"data-state": status,
|
|
9294
9229
|
...props
|
|
9295
9230
|
};
|
|
9296
|
-
const runningLabel = current && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
9231
|
+
const runningLabel = current && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
9297
9232
|
className: "cpk-tool-call-group-running cpk-shimmer",
|
|
9298
|
-
children:
|
|
9233
|
+
children: (0, _copilotkit_core.ɵformatLabel)(labels.toolCallRunningLabel, { name: current.toolCall.function.name })
|
|
9299
9234
|
}), preview && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
9300
9235
|
className: "cpk-tool-call-group-preview",
|
|
9301
9236
|
children: preview
|
|
@@ -9323,13 +9258,16 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
9323
9258
|
onClick: () => setOpen((value) => !value),
|
|
9324
9259
|
className: "cpk-tool-call-group-line-toggle",
|
|
9325
9260
|
children: [runningLabel || /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
9326
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
9261
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
9327
9262
|
className: "cpk-tool-call-group-line-summary",
|
|
9328
|
-
children:
|
|
9263
|
+
children: (0, _copilotkit_core.ɵformatCountLabel)(calls.length, {
|
|
9264
|
+
one: labels.toolCallUsedToolsOne,
|
|
9265
|
+
other: labels.toolCallUsedToolsOther
|
|
9266
|
+
})
|
|
9329
9267
|
}),
|
|
9330
9268
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
9331
9269
|
className: "cpk-tool-call-group-line-names",
|
|
9332
|
-
children:
|
|
9270
|
+
children: (0, _copilotkit_core.ɵformatToolNames)(calls)
|
|
9333
9271
|
}),
|
|
9334
9272
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(FailedCount, { calls })
|
|
9335
9273
|
] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chevron, { open })]
|
|
@@ -9346,8 +9284,8 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
9346
9284
|
if (appearance === "stack") {
|
|
9347
9285
|
const behind = open ? 0 : Math.min(calls.length - 1, 2);
|
|
9348
9286
|
const layer = "cpk-tool-call-group-stack-layer";
|
|
9349
|
-
const latestStatus =
|
|
9350
|
-
const latestPreview =
|
|
9287
|
+
const latestStatus = (0, _copilotkit_core.ɵgetToolCallRowStatus)(latest, isActive);
|
|
9288
|
+
const latestPreview = (0, _copilotkit_core.ɵgetToolCallPreview)(latest);
|
|
9351
9289
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
9352
9290
|
...groupProps,
|
|
9353
9291
|
className: cn("cpk-tool-call-group cpk-tool-call-group-stack", className),
|
|
@@ -9374,11 +9312,14 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
9374
9312
|
onClick: () => setOpen((value) => !value),
|
|
9375
9313
|
className: cn("cpk-tool-call-group-stack-toggle", open ? "cpk-tool-call-group-stack-toggle-open" : [layer, "cpk-tool-call-group-stack-toggle-closed"]),
|
|
9376
9314
|
children: open ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
9377
|
-
|
|
9315
|
+
(0, _copilotkit_core.ɵformatCountLabel)(calls.length, {
|
|
9316
|
+
one: labels.toolCallToolCallCountOne,
|
|
9317
|
+
other: labels.toolCallToolCallCountOther
|
|
9318
|
+
}),
|
|
9378
9319
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(FailedCount, { calls }),
|
|
9379
9320
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
9380
9321
|
className: "cpk-tool-call-group-stack-collapse",
|
|
9381
|
-
children: [
|
|
9322
|
+
children: [labels.toolCallCollapseLabel, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chevron, {
|
|
9382
9323
|
open: true,
|
|
9383
9324
|
className: "cpk-tool-call-group-stack-collapse-icon"
|
|
9384
9325
|
})]
|
|
@@ -9397,7 +9338,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
9397
9338
|
}),
|
|
9398
9339
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
9399
9340
|
className: "cpk-tool-call-group-stack-status",
|
|
9400
|
-
children:
|
|
9341
|
+
children: labels[STATUS_LABEL_KEYS[latestStatus]]
|
|
9401
9342
|
})
|
|
9402
9343
|
]
|
|
9403
9344
|
}, latest.toolCall.id), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
@@ -9406,7 +9347,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
9406
9347
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(FailedCount, { calls }),
|
|
9407
9348
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
9408
9349
|
className: "cpk-tool-call-group-stack-count",
|
|
9409
|
-
children:
|
|
9350
|
+
children: (0, _copilotkit_core.ɵformatCountLabel)(calls.length, {
|
|
9351
|
+
one: labels.toolCallCallCountOne,
|
|
9352
|
+
other: labels.toolCallCallCountOther
|
|
9353
|
+
})
|
|
9410
9354
|
}),
|
|
9411
9355
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chevron, {
|
|
9412
9356
|
open: false,
|
|
@@ -9418,7 +9362,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
9418
9362
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
9419
9363
|
"aria-live": "polite",
|
|
9420
9364
|
className: "cpk-tool-call-group-stack-live",
|
|
9421
|
-
children: open ? "" : `${latest.toolCall.function.name}: ${
|
|
9365
|
+
children: open ? "" : `${latest.toolCall.function.name}: ${labels[STATUS_LABEL_KEYS[latestStatus]]}`
|
|
9422
9366
|
})
|
|
9423
9367
|
]
|
|
9424
9368
|
}), open && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -9450,18 +9394,21 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
9450
9394
|
className: "cpk-tool-call-group-card-toggle",
|
|
9451
9395
|
children: [
|
|
9452
9396
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusIcon, { status }),
|
|
9453
|
-
runningLabel || /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
9397
|
+
runningLabel || /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
9454
9398
|
className: "cpk-tool-call-group-card-summary",
|
|
9455
|
-
children:
|
|
9399
|
+
children: (0, _copilotkit_core.ɵformatCountLabel)(calls.length, {
|
|
9400
|
+
one: labels.toolCallUsedToolsOne,
|
|
9401
|
+
other: labels.toolCallUsedToolsOther
|
|
9402
|
+
})
|
|
9456
9403
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
9457
9404
|
className: "cpk-tool-call-group-card-names",
|
|
9458
|
-
children:
|
|
9405
|
+
children: (0, _copilotkit_core.ɵformatToolNames)(calls)
|
|
9459
9406
|
})] }),
|
|
9460
9407
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
9461
9408
|
className: "cpk-tool-call-group-card-meta",
|
|
9462
9409
|
children: [status === "failed" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FailedCount, { calls }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
9463
9410
|
className: "cpk-tool-call-group-card-status",
|
|
9464
|
-
children: status !== "running" ?
|
|
9411
|
+
children: status !== "running" ? labels[STATUS_LABEL_KEYS[status]] : done > 0 && (0, _copilotkit_core.ɵformatLabel)(labels.toolCallDoneCountLabel, { count: done })
|
|
9465
9412
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chevron, { open })]
|
|
9466
9413
|
})
|
|
9467
9414
|
]
|
|
@@ -10228,11 +10175,6 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
10228
10175
|
}));
|
|
10229
10176
|
}
|
|
10230
10177
|
|
|
10231
|
-
//#endregion
|
|
10232
|
-
//#region src/types/interrupt.ts
|
|
10233
|
-
/** Name of the legacy custom event agents emit to signal an interrupt. */
|
|
10234
|
-
const INTERRUPT_EVENT_NAME = "on_interrupt";
|
|
10235
|
-
|
|
10236
10178
|
//#endregion
|
|
10237
10179
|
//#region src/hooks/use-interrupt.tsx
|
|
10238
10180
|
/** Recognize thenables returned by interrupt preprocessing handlers. */
|
|
@@ -10243,7 +10185,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
10243
10185
|
function toLegacyEvent(pending) {
|
|
10244
10186
|
if (pending.kind === "legacy") return pending.event;
|
|
10245
10187
|
return {
|
|
10246
|
-
name: INTERRUPT_EVENT_NAME,
|
|
10188
|
+
name: _copilotkit_core.INTERRUPT_EVENT_NAME,
|
|
10247
10189
|
value: pending.interrupts[0]
|
|
10248
10190
|
};
|
|
10249
10191
|
}
|
|
@@ -10290,7 +10232,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
10290
10232
|
let localStandard = null;
|
|
10291
10233
|
const subscription = agent.subscribe({
|
|
10292
10234
|
onCustomEvent: ({ event }) => {
|
|
10293
|
-
if (event.name === INTERRUPT_EVENT_NAME) localLegacy = {
|
|
10235
|
+
if (event.name === _copilotkit_core.INTERRUPT_EVENT_NAME) localLegacy = {
|
|
10294
10236
|
name: event.name,
|
|
10295
10237
|
value: event.value
|
|
10296
10238
|
};
|
|
@@ -11149,297 +11091,11 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
11149
11091
|
};
|
|
11150
11092
|
}
|
|
11151
11093
|
|
|
11152
|
-
//#endregion
|
|
11153
|
-
//#region src/hooks/use-learning-containers.tsx
|
|
11154
|
-
/** The default learning containers value. Matches the backend default. */
|
|
11155
|
-
const DEFAULT_CONTAINERS = ["project"];
|
|
11156
|
-
/**
|
|
11157
|
-
* Legacy compatibility hook that keeps a thread's plural learning-container
|
|
11158
|
-
* annotation in sync by emitting
|
|
11159
|
-
* `set_learning_containers` annotations via the CopilotKit runtime annotate
|
|
11160
|
-
* endpoint (`POST ${runtimeUrl}/annotate`).
|
|
11161
|
-
*
|
|
11162
|
-
* **Emit rules:**
|
|
11163
|
-
* - On mount with `["project"]` (the backend default) → does NOT emit.
|
|
11164
|
-
* Absence of an annotation equals the default, so the round-trip is skipped.
|
|
11165
|
-
* - On mount with any other value → emits immediately.
|
|
11166
|
-
* - On any subsequent content change (including a switch back to
|
|
11167
|
-
* `["project"]`) → emits (a deliberate switch is always recorded).
|
|
11168
|
-
* - On unmount or threadId change → emits a reset to `["project"]`
|
|
11169
|
-
* so the backend is left in a clean state for the next consumer.
|
|
11170
|
-
* Changing `learningContainers` within the same thread does NOT reset the
|
|
11171
|
-
* thread; only the new value is emitted.
|
|
11172
|
-
*
|
|
11173
|
-
* Content-equality is evaluated via `JSON.stringify` so a fresh array literal
|
|
11174
|
-
* with the same items does NOT trigger a redundant emit.
|
|
11175
|
-
*
|
|
11176
|
-
* If `runtimeUrl` is absent, all emits are silently skipped.
|
|
11177
|
-
*
|
|
11178
|
-
* @example
|
|
11179
|
-
* ```tsx
|
|
11180
|
-
* function ThreadPane({ threadId, userScope }: Props) {
|
|
11181
|
-
* useLearningContainers({
|
|
11182
|
-
* threadId,
|
|
11183
|
-
* learningContainers: [userScope],
|
|
11184
|
-
* });
|
|
11185
|
-
* // ...
|
|
11186
|
-
* }
|
|
11187
|
-
* ```
|
|
11188
|
-
*
|
|
11189
|
-
* @deprecated This hook supports only the legacy plural-container annotation.
|
|
11190
|
-
* Configure `getLearningContainerId` on `CopilotKitIntelligence` for new
|
|
11191
|
-
* Intelligence runtimes.
|
|
11192
|
-
*/
|
|
11193
|
-
function useLearningContainers({ threadId, learningContainers }) {
|
|
11194
|
-
const { copilotkit } = useCopilotKit();
|
|
11195
|
-
/**
|
|
11196
|
-
* Tracks the last-synced container list so content-identical rerenders
|
|
11197
|
-
* (fresh array, same values) do not fire a redundant emit.
|
|
11198
|
-
* `null` = nothing synced yet (initial state or after a threadId reset).
|
|
11199
|
-
*/
|
|
11200
|
-
const lastSyncedRef = (0, react.useRef)(null);
|
|
11201
|
-
/** Guards the missing-runtimeUrl warning so it fires at most once per hook instance. */
|
|
11202
|
-
const warnedMissingUrlRef = (0, react.useRef)(false);
|
|
11203
|
-
const runtimeUrlRef = (0, react.useRef)(copilotkit.runtimeUrl);
|
|
11204
|
-
const runtimeFetchRef = (0, react.useRef)(copilotkit.ɵruntimeFetch);
|
|
11205
|
-
runtimeUrlRef.current = copilotkit.runtimeUrl;
|
|
11206
|
-
runtimeFetchRef.current = copilotkit.ɵruntimeFetch;
|
|
11207
|
-
const key = JSON.stringify(learningContainers);
|
|
11208
|
-
const defaultKey = JSON.stringify(DEFAULT_CONTAINERS);
|
|
11209
|
-
(0, react.useEffect)(() => {
|
|
11210
|
-
const runtimeUrl = copilotkit.runtimeUrl;
|
|
11211
|
-
/**
|
|
11212
|
-
* Fire-and-forget emit; errors must not surface in render.
|
|
11213
|
-
* Failures are logged as warnings so they are diagnosable without
|
|
11214
|
-
* propagating into the React render cycle.
|
|
11215
|
-
*/
|
|
11216
|
-
const emit = (containers) => {
|
|
11217
|
-
if (!runtimeUrl) {
|
|
11218
|
-
if (!warnedMissingUrlRef.current) {
|
|
11219
|
-
warnedMissingUrlRef.current = true;
|
|
11220
|
-
console.warn("useLearningContainers: runtimeUrl not configured; learning-container sync disabled");
|
|
11221
|
-
}
|
|
11222
|
-
return;
|
|
11223
|
-
}
|
|
11224
|
-
recordAnnotation({
|
|
11225
|
-
fetch: copilotkit.ɵruntimeFetch,
|
|
11226
|
-
runtimeUrl,
|
|
11227
|
-
headers: {},
|
|
11228
|
-
type: "set_learning_containers",
|
|
11229
|
-
payload: { containers },
|
|
11230
|
-
threadId
|
|
11231
|
-
}).catch((err) => {
|
|
11232
|
-
console.warn("useLearningContainers: failed to record set_learning_containers", err);
|
|
11233
|
-
});
|
|
11234
|
-
};
|
|
11235
|
-
if (lastSyncedRef.current === null) {
|
|
11236
|
-
if (key === defaultKey) {
|
|
11237
|
-
lastSyncedRef.current = learningContainers;
|
|
11238
|
-
return;
|
|
11239
|
-
}
|
|
11240
|
-
emit(learningContainers);
|
|
11241
|
-
lastSyncedRef.current = learningContainers;
|
|
11242
|
-
} else if (key !== JSON.stringify(lastSyncedRef.current)) {
|
|
11243
|
-
emit(learningContainers);
|
|
11244
|
-
lastSyncedRef.current = learningContainers;
|
|
11245
|
-
}
|
|
11246
|
-
}, [threadId, key]);
|
|
11247
|
-
(0, react.useEffect)(() => {
|
|
11248
|
-
const capturedThreadId = threadId;
|
|
11249
|
-
return () => {
|
|
11250
|
-
const capturedRuntimeUrl = runtimeUrlRef.current;
|
|
11251
|
-
if (capturedRuntimeUrl) recordAnnotation({
|
|
11252
|
-
fetch: runtimeFetchRef.current,
|
|
11253
|
-
runtimeUrl: capturedRuntimeUrl,
|
|
11254
|
-
headers: {},
|
|
11255
|
-
type: "set_learning_containers",
|
|
11256
|
-
payload: { containers: DEFAULT_CONTAINERS },
|
|
11257
|
-
threadId: capturedThreadId
|
|
11258
|
-
}).catch((err) => {
|
|
11259
|
-
console.warn("useLearningContainers: failed to record set_learning_containers", err);
|
|
11260
|
-
});
|
|
11261
|
-
lastSyncedRef.current = null;
|
|
11262
|
-
};
|
|
11263
|
-
}, [threadId]);
|
|
11264
|
-
}
|
|
11265
|
-
|
|
11266
|
-
//#endregion
|
|
11267
|
-
//#region src/hooks/use-learning-containers-in-current-thread.tsx
|
|
11268
|
-
/**
|
|
11269
|
-
* Legacy compatibility hook that keeps the **current chat thread's** plural
|
|
11270
|
-
* learning-container annotation in sync. The `threadId` is sourced from the surrounding
|
|
11271
|
-
* `<CopilotChatConfigurationProvider>` (the same provider `<CopilotChat>`,
|
|
11272
|
-
* `<CopilotSidebar>`, and friends set up), so callers in a chat-aware
|
|
11273
|
-
* subtree don't need to thread an id through manually.
|
|
11274
|
-
*
|
|
11275
|
-
* **Throws on render** when there is no chat-config provider in scope or
|
|
11276
|
-
* when the provider does not yet have an active `threadId`. Mount the hook
|
|
11277
|
-
* inside a subtree that is guaranteed to have a thread context.
|
|
11278
|
-
*
|
|
11279
|
-
* If you need to manage an explicit thread, use {@link useLearningContainers}
|
|
11280
|
-
* directly — two hooks, two crisp contracts, no mode confusion.
|
|
11281
|
-
*
|
|
11282
|
-
* @throws When no `CopilotChatConfigurationProvider` is in scope or when the
|
|
11283
|
-
* active `threadId` is absent/empty.
|
|
11284
|
-
*
|
|
11285
|
-
* @example
|
|
11286
|
-
* ```tsx
|
|
11287
|
-
* function ThreadPanel({ scope }: Props) {
|
|
11288
|
-
* useLearningContainersInCurrentThread({
|
|
11289
|
-
* learningContainers: [scope],
|
|
11290
|
-
* });
|
|
11291
|
-
* // ...
|
|
11292
|
-
* }
|
|
11293
|
-
* ```
|
|
11294
|
-
*
|
|
11295
|
-
* @deprecated This hook supports only the legacy plural-container annotation.
|
|
11296
|
-
* Configure `getLearningContainerId` on `CopilotKitIntelligence` for new
|
|
11297
|
-
* Intelligence runtimes.
|
|
11298
|
-
*/
|
|
11299
|
-
function useLearningContainersInCurrentThread({ learningContainers }) {
|
|
11300
|
-
const threadId = useCopilotChatConfiguration()?.threadId;
|
|
11301
|
-
if (!threadId) throw new Error("useLearningContainersInCurrentThread must be used within a thread context (no active threadId). Wrap the component in <CopilotChat>, <CopilotSidebar>, or <CopilotChatConfigurationProvider>, or use `useLearningContainers()` and pass `threadId` explicitly.");
|
|
11302
|
-
useLearningContainers({
|
|
11303
|
-
threadId,
|
|
11304
|
-
learningContainers
|
|
11305
|
-
});
|
|
11306
|
-
}
|
|
11307
|
-
|
|
11308
11094
|
//#endregion
|
|
11309
11095
|
//#region src/components/chat/tool-call-display-context.ts
|
|
11310
11096
|
/** @internal */
|
|
11311
11097
|
const ToolCallDisplayContext = (0, react.createContext)(null);
|
|
11312
11098
|
|
|
11313
|
-
//#endregion
|
|
11314
|
-
//#region src/components/chat/tool-call-layout.ts
|
|
11315
|
-
function contentLength(content) {
|
|
11316
|
-
return typeof content === "string" ? content.length : JSON.stringify(content ?? "").length;
|
|
11317
|
-
}
|
|
11318
|
-
const entrySignature = ({ toolCall, toolMessage }) => [
|
|
11319
|
-
toolCall.id,
|
|
11320
|
-
toolCall.function.name,
|
|
11321
|
-
toolCall.function.arguments.length,
|
|
11322
|
-
toolMessage ? `${contentLength(toolMessage.content)}${toolMessage.error ? "!" : ""}` : "-"
|
|
11323
|
-
].join(":");
|
|
11324
|
-
function signatureOf(segments) {
|
|
11325
|
-
return segments.map((segment) => segment.kind === "call" ? `c(${entrySignature(segment.call)})` : `g${segment.trailing ? "*" : ""}(${segment.calls.map(entrySignature).join(",")})`).join("|");
|
|
11326
|
-
}
|
|
11327
|
-
/** Index of tool results by the call they answer. */
|
|
11328
|
-
function getToolResults(messages) {
|
|
11329
|
-
const results = /* @__PURE__ */ new Map();
|
|
11330
|
-
for (const message of messages) if (message.role === "tool") results.set(message.toolCallId, message);
|
|
11331
|
-
return results;
|
|
11332
|
-
}
|
|
11333
|
-
/**
|
|
11334
|
-
* Lays out the tool calls of every assistant message in `rendered`.
|
|
11335
|
-
*
|
|
11336
|
-
* Calls drawn by a renderer that opted into grouping join the group that's
|
|
11337
|
-
* open; anything else that shows between them closes it: assistant text, a
|
|
11338
|
-
* user, reasoning or activity message, or a call drawn by any other renderer. A group belongs to
|
|
11339
|
-
* the message where it starts, so later messages whose calls joined it render
|
|
11340
|
-
* no tool calls themselves.
|
|
11341
|
-
*
|
|
11342
|
-
* @param rendered - The messages as the chat renders them, in order.
|
|
11343
|
-
* @param all - Every message, for finding tool results (a transform may hide them).
|
|
11344
|
-
* @param renderers - The registered renderers.
|
|
11345
|
-
*/
|
|
11346
|
-
function getToolCallLayouts(rendered, all, renderers) {
|
|
11347
|
-
const results = getToolResults(all);
|
|
11348
|
-
const layouts = /* @__PURE__ */ new Map();
|
|
11349
|
-
let open;
|
|
11350
|
-
for (const message of rendered) {
|
|
11351
|
-
if (message.role === "tool") continue;
|
|
11352
|
-
if (message.role !== "assistant") {
|
|
11353
|
-
open = void 0;
|
|
11354
|
-
continue;
|
|
11355
|
-
}
|
|
11356
|
-
if (typeof message.content === "string" && message.content.trim()) open = void 0;
|
|
11357
|
-
const segments = [];
|
|
11358
|
-
layouts.set(message.id, segments);
|
|
11359
|
-
const toolCalls = /* @__PURE__ */ new Map();
|
|
11360
|
-
for (const toolCall of message.toolCalls ?? []) toolCalls.set(toolCall.id, toolCall);
|
|
11361
|
-
for (const toolCall of toolCalls.values()) {
|
|
11362
|
-
const entry = {
|
|
11363
|
-
toolCall,
|
|
11364
|
-
toolMessage: results.get(toolCall.id)
|
|
11365
|
-
};
|
|
11366
|
-
const name = toolCall.function.name;
|
|
11367
|
-
const named = renderers.named.has(name);
|
|
11368
|
-
const rendered = named || renderers.wildcard;
|
|
11369
|
-
const groups = named ? renderers.groupedNames.has(name) : renderers.wildcardGroups;
|
|
11370
|
-
if (!rendered || !groups) {
|
|
11371
|
-
if (rendered) open = void 0;
|
|
11372
|
-
segments.push({
|
|
11373
|
-
kind: "call",
|
|
11374
|
-
id: toolCall.id,
|
|
11375
|
-
call: entry,
|
|
11376
|
-
rendered
|
|
11377
|
-
});
|
|
11378
|
-
} else if (open) open.calls.push(entry);
|
|
11379
|
-
else {
|
|
11380
|
-
open = {
|
|
11381
|
-
kind: "group",
|
|
11382
|
-
id: toolCall.id,
|
|
11383
|
-
calls: [entry],
|
|
11384
|
-
trailing: false
|
|
11385
|
-
};
|
|
11386
|
-
segments.push(open);
|
|
11387
|
-
}
|
|
11388
|
-
}
|
|
11389
|
-
}
|
|
11390
|
-
if (open) open.trailing = true;
|
|
11391
|
-
const layout = /* @__PURE__ */ new Map();
|
|
11392
|
-
for (const [id, segments] of layouts) layout.set(id, {
|
|
11393
|
-
segments,
|
|
11394
|
-
signature: signatureOf(segments)
|
|
11395
|
-
});
|
|
11396
|
-
return layout;
|
|
11397
|
-
}
|
|
11398
|
-
/**
|
|
11399
|
-
* Finds the working phase of every reply in `rendered`: its messages up to the
|
|
11400
|
-
* last one that calls a tool. Text in there was narration; what follows is the
|
|
11401
|
-
* reply itself. Replies that called no tools are omitted, except the latest,
|
|
11402
|
-
* which may be about to.
|
|
11403
|
-
*/
|
|
11404
|
-
function getTurnWork(rendered, layouts) {
|
|
11405
|
-
const turns = /* @__PURE__ */ new Map();
|
|
11406
|
-
let start = 0;
|
|
11407
|
-
while (start < rendered.length) {
|
|
11408
|
-
let end = start;
|
|
11409
|
-
while (end < rendered.length && rendered[end].role !== "user") end++;
|
|
11410
|
-
const key = start > 0 ? rendered[start - 1].id : "start";
|
|
11411
|
-
const visible = rendered.slice(start, end).filter((message) => message.role !== "tool");
|
|
11412
|
-
const isLatest = end === rendered.length;
|
|
11413
|
-
const calls = [];
|
|
11414
|
-
for (const message of visible) for (const segment of layouts.get(message.id)?.segments ?? []) if (segment.kind === "group") calls.push(...segment.calls);
|
|
11415
|
-
else if (segment.rendered) calls.push(segment.call);
|
|
11416
|
-
const shown = new Set(calls.map((entry) => entry.toolCall.id));
|
|
11417
|
-
let lastWork = -1;
|
|
11418
|
-
visible.forEach((message, index) => {
|
|
11419
|
-
if (message.role === "assistant" && message.toolCalls?.some((call) => shown.has(call.id))) lastWork = index;
|
|
11420
|
-
});
|
|
11421
|
-
const first = visible[0];
|
|
11422
|
-
if (first && (calls.length > 0 || isLatest)) {
|
|
11423
|
-
let lastAssistant = -1;
|
|
11424
|
-
visible.forEach((message, index) => {
|
|
11425
|
-
if (message.role === "assistant") lastAssistant = index;
|
|
11426
|
-
});
|
|
11427
|
-
const replyText = visible[lastAssistant]?.content;
|
|
11428
|
-
const endsWithWork = lastAssistant >= 0 && lastAssistant <= lastWork && typeof replyText === "string" && replyText.trim().length > 0;
|
|
11429
|
-
turns.set(key, {
|
|
11430
|
-
key,
|
|
11431
|
-
firstMessageId: first.id,
|
|
11432
|
-
workMessageIds: new Set(visible.slice(0, lastWork + 1).map((message) => message.id)),
|
|
11433
|
-
replyTextMessageId: endsWithWork ? visible[lastAssistant].id : void 0,
|
|
11434
|
-
calls,
|
|
11435
|
-
isLatest
|
|
11436
|
-
});
|
|
11437
|
-
}
|
|
11438
|
-
start = end + 1;
|
|
11439
|
-
}
|
|
11440
|
-
return turns;
|
|
11441
|
-
}
|
|
11442
|
-
|
|
11443
11099
|
//#endregion
|
|
11444
11100
|
//#region src/components/chat/CopilotChatToolCallsView.tsx
|
|
11445
11101
|
const appearances = {
|
|
@@ -11459,7 +11115,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
11459
11115
|
const viewLayout = context?.layouts.get(message.id);
|
|
11460
11116
|
const layout = (0, react.useMemo)(() => {
|
|
11461
11117
|
if (display === "separate") return void 0;
|
|
11462
|
-
return viewLayout ?? getToolCallLayouts([message], messages, rendererNames).get(message.id);
|
|
11118
|
+
return viewLayout ?? (0, _copilotkit_core.ɵgetToolCallLayouts)([message], messages, rendererNames).get(message.id);
|
|
11463
11119
|
}, [
|
|
11464
11120
|
display,
|
|
11465
11121
|
viewLayout,
|
|
@@ -11649,7 +11305,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
11649
11305
|
});
|
|
11650
11306
|
}
|
|
11651
11307
|
function CopilotChatInspectorButton({ title, className, onClick, onPointerDown, onPointerEnter, onPointerLeave, onKeyDown, disabled, ...props }) {
|
|
11652
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
11308
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
11653
11309
|
const { isInspectorEnabled } = useCopilotKitInspector();
|
|
11654
11310
|
const hidden = useInspectorShortcutsHidden();
|
|
11655
11311
|
const [open, setOpen] = (0, react.useState)(false);
|
|
@@ -11718,7 +11374,8 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
11718
11374
|
event.currentTarget.click();
|
|
11719
11375
|
}
|
|
11720
11376
|
},
|
|
11721
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
11377
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
11378
|
+
name: "Wrench",
|
|
11722
11379
|
"aria-hidden": "true",
|
|
11723
11380
|
className: "cpk-inspector-button-icon",
|
|
11724
11381
|
"data-testid": "copilot-inspector-icon"
|
|
@@ -11785,7 +11442,8 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
11785
11442
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DropdownMenuItem, {
|
|
11786
11443
|
onSelect: hideShortcuts,
|
|
11787
11444
|
className: "cpk-inspector-button-menu-item cpk-inspector-button-hide-item",
|
|
11788
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
11445
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
11446
|
+
name: "EyeOff",
|
|
11789
11447
|
"aria-hidden": "true",
|
|
11790
11448
|
className: "cpk-inspector-button-menu-item-icon"
|
|
11791
11449
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -12326,7 +11984,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
12326
11984
|
* control after the thumb, and Enter or Escape inside it returns to the thumb.
|
|
12327
11985
|
*/
|
|
12328
11986
|
function FeedbackCommentPopover({ feedbackComment, comment, savedComment, rating, anchor, messageId }) {
|
|
12329
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
11987
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
12330
11988
|
const contentRef = (0, react.useRef)(null);
|
|
12331
11989
|
const focusInside = () => contentRef.current?.contains(document.activeElement) ?? false;
|
|
12332
11990
|
const { focusRequest, takeFocusRequest, inputRef } = comment;
|
|
@@ -12630,7 +12288,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
12630
12288
|
});
|
|
12631
12289
|
};
|
|
12632
12290
|
_CopilotChatAssistantMessage.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
12633
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
12291
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
12634
12292
|
const [copied, setCopied] = (0, react.useState)(false);
|
|
12635
12293
|
const timerRef = (0, react.useRef)(null);
|
|
12636
12294
|
(0, react.useEffect)(() => {
|
|
@@ -12656,36 +12314,44 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
12656
12314
|
onClick: handleClick,
|
|
12657
12315
|
className,
|
|
12658
12316
|
...props,
|
|
12659
|
-
children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
12317
|
+
children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
12318
|
+
name: "Check",
|
|
12319
|
+
className: "cpk-assistant-message-toolbar-icon"
|
|
12320
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
12321
|
+
name: "Copy",
|
|
12322
|
+
className: "cpk-assistant-message-toolbar-icon"
|
|
12323
|
+
})
|
|
12660
12324
|
});
|
|
12661
12325
|
};
|
|
12662
12326
|
_CopilotChatAssistantMessage.InspectorButton = CopilotChatInspectorButton;
|
|
12663
12327
|
_CopilotChatAssistantMessage.ThumbsUpButton = ({ title, ...props }) => {
|
|
12664
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
12328
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
12665
12329
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
12666
12330
|
"data-testid": "copilot-thumbs-up-button",
|
|
12667
12331
|
title: title || labels.assistantMessageToolbarThumbsUpLabel,
|
|
12668
12332
|
...props,
|
|
12669
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
12333
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
12334
|
+
name: "ThumbsUp",
|
|
12670
12335
|
className: "cpk-assistant-message-toolbar-icon",
|
|
12671
12336
|
fill: props["aria-pressed"] === true ? "currentColor" : "none"
|
|
12672
12337
|
})
|
|
12673
12338
|
});
|
|
12674
12339
|
};
|
|
12675
12340
|
_CopilotChatAssistantMessage.ThumbsDownButton = ({ title, ...props }) => {
|
|
12676
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
12341
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
12677
12342
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
12678
12343
|
"data-testid": "copilot-thumbs-down-button",
|
|
12679
12344
|
title: title || labels.assistantMessageToolbarThumbsDownLabel,
|
|
12680
12345
|
...props,
|
|
12681
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
12346
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
12347
|
+
name: "ThumbsDown",
|
|
12682
12348
|
className: "cpk-assistant-message-toolbar-icon",
|
|
12683
12349
|
fill: props["aria-pressed"] === true ? "currentColor" : "none"
|
|
12684
12350
|
})
|
|
12685
12351
|
});
|
|
12686
12352
|
};
|
|
12687
12353
|
_CopilotChatAssistantMessage.FeedbackComment = ({ value, savedComment, inputRef, onChange, onSubmit, onEditingChange, onLeave, className }) => {
|
|
12688
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
12354
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
12689
12355
|
const changed = value.trim() !== savedComment;
|
|
12690
12356
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
|
|
12691
12357
|
"data-testid": "copilot-feedback-comment",
|
|
@@ -12715,26 +12381,35 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
12715
12381
|
variant: "assistantMessageToolbarButton",
|
|
12716
12382
|
"aria-label": labels.assistantMessageFeedbackCommentSubmitLabel,
|
|
12717
12383
|
title: labels.assistantMessageFeedbackCommentSubmitLabel,
|
|
12718
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
12384
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
12385
|
+
name: "ArrowUp",
|
|
12386
|
+
className: "cpk-assistant-message-feedback-comment-submit-icon"
|
|
12387
|
+
})
|
|
12719
12388
|
})]
|
|
12720
12389
|
});
|
|
12721
12390
|
};
|
|
12722
12391
|
_CopilotChatAssistantMessage.ReadAloudButton = ({ title, ...props }) => {
|
|
12723
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
12392
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
12724
12393
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
12725
12394
|
"data-testid": "copilot-read-aloud-button",
|
|
12726
12395
|
title: title || labels.assistantMessageToolbarReadAloudLabel,
|
|
12727
12396
|
...props,
|
|
12728
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
12397
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
12398
|
+
name: "Volume2",
|
|
12399
|
+
className: "cpk-assistant-message-read-aloud-icon"
|
|
12400
|
+
})
|
|
12729
12401
|
});
|
|
12730
12402
|
};
|
|
12731
12403
|
_CopilotChatAssistantMessage.RegenerateButton = ({ title, ...props }) => {
|
|
12732
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
12404
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
12733
12405
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
12734
12406
|
"data-testid": "copilot-regenerate-button",
|
|
12735
12407
|
title: title || labels.assistantMessageToolbarRegenerateLabel,
|
|
12736
12408
|
...props,
|
|
12737
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
12409
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
12410
|
+
name: "RefreshCw",
|
|
12411
|
+
className: "cpk-assistant-message-toolbar-icon"
|
|
12412
|
+
})
|
|
12738
12413
|
});
|
|
12739
12414
|
};
|
|
12740
12415
|
})(CopilotChatAssistantMessage || (CopilotChatAssistantMessage = {}));
|
|
@@ -12757,7 +12432,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
12757
12432
|
* `labels.attachmentPreviewCloseButtonLabel`.
|
|
12758
12433
|
*/
|
|
12759
12434
|
function Lightbox({ onClose, children }) {
|
|
12760
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
12435
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
12761
12436
|
(0, react.useEffect)(() => {
|
|
12762
12437
|
const handleKey = (e) => {
|
|
12763
12438
|
if (e.key === "Escape") onClose();
|
|
@@ -12773,7 +12448,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
12773
12448
|
onClick: onClose,
|
|
12774
12449
|
className: "cpk-attachment-lightbox-close-button",
|
|
12775
12450
|
"aria-label": labels.attachmentPreviewCloseButtonLabel,
|
|
12776
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
12451
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
12452
|
+
name: "X",
|
|
12453
|
+
className: "cpk-attachment-lightbox-close-icon"
|
|
12454
|
+
})
|
|
12777
12455
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
12778
12456
|
onClick: (e) => e.stopPropagation(),
|
|
12779
12457
|
children
|
|
@@ -12827,17 +12505,22 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
12827
12505
|
|
|
12828
12506
|
//#endregion
|
|
12829
12507
|
//#region src/components/chat/CopilotChatAttachmentRenderer.tsx
|
|
12508
|
+
/** The chat labels from the nearest chat configuration, or the defaults. */
|
|
12509
|
+
function useLabels() {
|
|
12510
|
+
return useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
12511
|
+
}
|
|
12830
12512
|
const ImageAttachment = (0, react.memo)(function ImageAttachment({ src, className }) {
|
|
12513
|
+
const labels = useLabels();
|
|
12831
12514
|
const [error, setError] = (0, react.useState)(false);
|
|
12832
12515
|
const { thumbnailRef, vtName, open, openLightbox, closeLightbox } = useLightbox();
|
|
12833
12516
|
if (error) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
12834
12517
|
className: cn("cpk-attachment-renderer cpk-attachment-renderer-image-error", className),
|
|
12835
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children:
|
|
12518
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: labels.attachmentImageLoadErrorText })
|
|
12836
12519
|
});
|
|
12837
12520
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
12838
12521
|
ref: thumbnailRef,
|
|
12839
12522
|
src,
|
|
12840
|
-
alt:
|
|
12523
|
+
alt: labels.attachmentImageAltText,
|
|
12841
12524
|
className: cn("cpk-attachment-renderer cpk-attachment-renderer-image", className),
|
|
12842
12525
|
onClick: openLightbox,
|
|
12843
12526
|
onError: () => setError(true)
|
|
@@ -12846,7 +12529,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
12846
12529
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
12847
12530
|
style: { viewTransitionName: vtName },
|
|
12848
12531
|
src,
|
|
12849
|
-
alt:
|
|
12532
|
+
alt: labels.attachmentImageAltText,
|
|
12850
12533
|
className: "cpk-attachment-renderer-lightbox-image"
|
|
12851
12534
|
})
|
|
12852
12535
|
})] });
|
|
@@ -12874,7 +12557,8 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
12874
12557
|
});
|
|
12875
12558
|
});
|
|
12876
12559
|
const DocumentAttachment = (0, react.memo)(function DocumentAttachment({ src, source, filename, className }) {
|
|
12877
|
-
const
|
|
12560
|
+
const labels = useLabels();
|
|
12561
|
+
const label = filename || source.mimeType || labels.attachmentDocumentAltText;
|
|
12878
12562
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
|
|
12879
12563
|
href: src,
|
|
12880
12564
|
download: filename ?? "",
|
|
@@ -12887,7 +12571,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
12887
12571
|
children: (0, _copilotkit_shared.getDocumentIcon)(source.mimeType ?? "")
|
|
12888
12572
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
12889
12573
|
className: "cpk-attachment-renderer-document-name",
|
|
12890
|
-
children: filename || source.mimeType ||
|
|
12574
|
+
children: filename || source.mimeType || labels.attachmentUnknownTypeText
|
|
12891
12575
|
})]
|
|
12892
12576
|
});
|
|
12893
12577
|
});
|
|
@@ -13026,7 +12710,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
13026
12710
|
})] });
|
|
13027
12711
|
};
|
|
13028
12712
|
_CopilotChatUserMessage.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
13029
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
12713
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
13030
12714
|
const [copied, setCopied] = (0, react.useState)(false);
|
|
13031
12715
|
const handleClick = async (event) => {
|
|
13032
12716
|
let success = false;
|
|
@@ -13042,21 +12726,30 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
13042
12726
|
onClick: handleClick,
|
|
13043
12727
|
className,
|
|
13044
12728
|
...props,
|
|
13045
|
-
children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
12729
|
+
children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
12730
|
+
name: "Check",
|
|
12731
|
+
className: "cpk-user-message-toolbar-icon"
|
|
12732
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
12733
|
+
name: "Copy",
|
|
12734
|
+
className: "cpk-user-message-toolbar-icon"
|
|
12735
|
+
})
|
|
13046
12736
|
});
|
|
13047
12737
|
};
|
|
13048
12738
|
_CopilotChatUserMessage.EditButton = ({ className, title, ...props }) => {
|
|
13049
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
12739
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
13050
12740
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
13051
12741
|
"data-testid": "copilot-edit-button",
|
|
13052
12742
|
title: title || labels.userMessageToolbarEditMessageLabel,
|
|
13053
12743
|
className,
|
|
13054
12744
|
...props,
|
|
13055
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
12745
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
12746
|
+
name: "Edit",
|
|
12747
|
+
className: "cpk-user-message-toolbar-icon"
|
|
12748
|
+
})
|
|
13056
12749
|
});
|
|
13057
12750
|
};
|
|
13058
12751
|
_CopilotChatUserMessage.BranchNavigation = ({ className, currentBranch = 0, numberOfBranches = 1, onSwitchToBranch, message, ...props }) => {
|
|
13059
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
12752
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
13060
12753
|
if (!numberOfBranches || numberOfBranches <= 1 || !onSwitchToBranch) return null;
|
|
13061
12754
|
const canGoPrev = currentBranch > 0;
|
|
13062
12755
|
const canGoNext = currentBranch < numberOfBranches - 1;
|
|
@@ -13076,7 +12769,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
13076
12769
|
disabled: !canGoPrev,
|
|
13077
12770
|
className: "cpk-user-message-branch-button",
|
|
13078
12771
|
"aria-label": labels.userMessageToolbarPreviousBranchLabel,
|
|
13079
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
12772
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
12773
|
+
name: "ChevronLeft",
|
|
12774
|
+
className: "cpk-user-message-branch-icon"
|
|
12775
|
+
})
|
|
13080
12776
|
}),
|
|
13081
12777
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
13082
12778
|
className: "cpk-user-message-branch-counter",
|
|
@@ -13097,7 +12793,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
13097
12793
|
disabled: !canGoNext,
|
|
13098
12794
|
className: "cpk-user-message-branch-button",
|
|
13099
12795
|
"aria-label": labels.userMessageToolbarNextBranchLabel,
|
|
13100
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
12796
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
12797
|
+
name: "ChevronRight",
|
|
12798
|
+
className: "cpk-user-message-branch-icon"
|
|
12799
|
+
})
|
|
13101
12800
|
})
|
|
13102
12801
|
]
|
|
13103
12802
|
});
|
|
@@ -13115,24 +12814,35 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
13115
12814
|
//#endregion
|
|
13116
12815
|
//#region src/components/chat/CopilotChatReasoningMessage.tsx
|
|
13117
12816
|
/**
|
|
13118
|
-
*
|
|
12817
|
+
* The reasoning time as label text, such as "4 seconds" or "1m 5s".
|
|
12818
|
+
*
|
|
12819
|
+
* @param seconds - The elapsed time in seconds. It may have a fraction.
|
|
12820
|
+
* @param labels - The chat labels that hold the duration texts.
|
|
13119
12821
|
*/
|
|
13120
|
-
function formatDuration
|
|
13121
|
-
|
|
13122
|
-
|
|
13123
|
-
|
|
13124
|
-
|
|
13125
|
-
|
|
13126
|
-
|
|
12822
|
+
function formatDuration(seconds, labels) {
|
|
12823
|
+
const duration = (0, _copilotkit_core.ɵformatReasoningDuration)(seconds);
|
|
12824
|
+
switch (duration.unit) {
|
|
12825
|
+
case "fewSeconds": return labels.reasoningMessageDurationFewSeconds;
|
|
12826
|
+
case "seconds": return (0, _copilotkit_core.ɵformatLabel)(labels.reasoningMessageDurationSeconds, { count: duration.seconds });
|
|
12827
|
+
case "minutes": return (0, _copilotkit_core.ɵformatCountLabel)(duration.minutes, {
|
|
12828
|
+
one: labels.reasoningMessageDurationMinutesOne,
|
|
12829
|
+
other: labels.reasoningMessageDurationMinutesOther
|
|
12830
|
+
});
|
|
12831
|
+
case "minutesSeconds": return (0, _copilotkit_core.ɵformatLabel)(labels.reasoningMessageDurationMinutesSeconds, {
|
|
12832
|
+
minutes: duration.minutes,
|
|
12833
|
+
seconds: duration.seconds
|
|
12834
|
+
});
|
|
12835
|
+
}
|
|
13127
12836
|
}
|
|
13128
12837
|
/**
|
|
13129
12838
|
* A reasoning message as a collapsible block. While the model reasons it is
|
|
13130
12839
|
* open and the header shows `labels.reasoningMessageThinkingLabel`; when
|
|
13131
|
-
* streaming ends it collapses and the header reads
|
|
12840
|
+
* streaming ends it collapses and the header reads
|
|
12841
|
+
* `labels.reasoningMessageThoughtForLabel` ("Thought for 4 seconds"). The
|
|
13132
12842
|
* `header` slot also receives `elapsedSeconds`.
|
|
13133
12843
|
*/
|
|
13134
12844
|
function CopilotChatReasoningMessage({ message, messages, isRunning, isLatest: isLatestProp, header, contentView, toggle, children, className, ...props }) {
|
|
13135
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
12845
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
13136
12846
|
const isLatest = isLatestProp ?? messages?.[messages.length - 1]?.id === message.id;
|
|
13137
12847
|
const isStreaming = !!(isRunning && isLatest);
|
|
13138
12848
|
const hasContent = !!(message.content && message.content.length > 0);
|
|
@@ -13162,7 +12872,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
13162
12872
|
userToggledRef.current = true;
|
|
13163
12873
|
setIsOpen((prev) => !prev);
|
|
13164
12874
|
} : void 0;
|
|
13165
|
-
const label = isStreaming ? labels.reasoningMessageThinkingLabel :
|
|
12875
|
+
const label = isStreaming ? labels.reasoningMessageThinkingLabel : (0, _copilotkit_core.ɵformatLabel)(labels.reasoningMessageThoughtForLabel, { duration: formatDuration(elapsed, labels) });
|
|
13166
12876
|
const boundHeader = renderSlot(header, CopilotChatReasoningMessage.Header, {
|
|
13167
12877
|
isOpen,
|
|
13168
12878
|
label,
|
|
@@ -13217,7 +12927,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
13217
12927
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "cpk-reasoning-message-indicator-dot" })
|
|
13218
12928
|
}),
|
|
13219
12929
|
headerChildren,
|
|
13220
|
-
isExpandable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
12930
|
+
isExpandable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
12931
|
+
name: "ChevronRight",
|
|
12932
|
+
className: cn("cpk-reasoning-message-chevron", isOpen && "cpk-reasoning-message-chevron-open")
|
|
12933
|
+
})
|
|
13221
12934
|
]
|
|
13222
12935
|
});
|
|
13223
12936
|
};
|
|
@@ -13271,7 +12984,8 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
13271
12984
|
...props,
|
|
13272
12985
|
children: [isLoading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
13273
12986
|
className: "cpk-suggestion-pill-icon",
|
|
13274
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
12987
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
12988
|
+
name: "Loader2",
|
|
13275
12989
|
className: "cpk-suggestion-pill-spinner",
|
|
13276
12990
|
"aria-hidden": "true"
|
|
13277
12991
|
})
|
|
@@ -13388,15 +13102,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
13388
13102
|
|
|
13389
13103
|
//#endregion
|
|
13390
13104
|
//#region src/components/chat/CopilotChatWorkSummary.tsx
|
|
13391
|
-
/**
|
|
13392
|
-
function formatDuration(ms) {
|
|
13393
|
-
const seconds = Math.max(0, Math.floor(ms / 1e3));
|
|
13394
|
-
if (seconds < 60) return `${seconds}s`;
|
|
13395
|
-
const minutes = Math.floor(seconds / 60);
|
|
13396
|
-
const rest = seconds % 60;
|
|
13397
|
-
return rest ? `${minutes}m ${rest}s` : `${minutes}m`;
|
|
13398
|
-
}
|
|
13399
|
-
/** Re-renders every second while `active`, returning the current time. */
|
|
13105
|
+
/** Re-renders every second while `active`, returning the current time. */
|
|
13400
13106
|
function useNow(active) {
|
|
13401
13107
|
const [now, setNow] = (0, react.useState)(() => Date.now());
|
|
13402
13108
|
(0, react.useEffect)(() => {
|
|
@@ -13409,14 +13115,20 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
13409
13115
|
}
|
|
13410
13116
|
/**
|
|
13411
13117
|
* The line at the top of a reply in the `"turn"` tool-call display. While the
|
|
13412
|
-
* agent works it reads "Working 4s"
|
|
13413
|
-
* for 9s
|
|
13118
|
+
* agent works it reads "Working 4s". Once the reply is done it reads "Worked
|
|
13119
|
+
* for 9s" and "7 tools", and toggles the work it folded away. The text comes
|
|
13120
|
+
* from the `workSummary...` and `toolCall...` chat labels.
|
|
13414
13121
|
*/
|
|
13415
13122
|
function CopilotChatWorkSummary({ isWorking, isOpen, calls, elapsedMs, workingSince, className, ...props }) {
|
|
13123
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
13416
13124
|
const now = useNow(isWorking);
|
|
13417
|
-
const failed =
|
|
13125
|
+
const failed = (0, _copilotkit_core.ɵcountFailedToolCalls)(calls);
|
|
13126
|
+
const toolCount = (0, _copilotkit_core.ɵformatCountLabel)(calls.length, {
|
|
13127
|
+
one: labels.toolCallToolCountOne,
|
|
13128
|
+
other: labels.toolCallToolCountOther
|
|
13129
|
+
});
|
|
13418
13130
|
const liveMs = elapsedMs !== void 0 && workingSince !== void 0 ? elapsedMs + Math.max(0, now - workingSince) : void 0;
|
|
13419
|
-
const duration = elapsedMs !== void 0 ?
|
|
13131
|
+
const duration = elapsedMs !== void 0 ? (0, _copilotkit_core.ɵformatWorkDuration)(Math.max(1e3, elapsedMs)) : void 0;
|
|
13420
13132
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
13421
13133
|
type: "button",
|
|
13422
13134
|
"data-copilotkit": true,
|
|
@@ -13427,24 +13139,28 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
13427
13139
|
...props,
|
|
13428
13140
|
children: [isWorking ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
13429
13141
|
className: "cpk-work-summary-label cpk-shimmer",
|
|
13430
|
-
children:
|
|
13142
|
+
children: labels.workSummaryWorkingLabel
|
|
13431
13143
|
}), liveMs !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
13432
13144
|
className: "cpk-work-summary-detail cpk-work-summary-timer",
|
|
13433
|
-
children:
|
|
13145
|
+
children: (0, _copilotkit_core.ɵformatWorkDuration)(liveMs)
|
|
13434
13146
|
})] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
13435
13147
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
13436
13148
|
className: "cpk-work-summary-label",
|
|
13437
|
-
children: duration ?
|
|
13149
|
+
children: duration ? (0, _copilotkit_core.ɵformatLabel)(labels.workSummaryWorkedForLabel, { duration }) : (0, _copilotkit_core.ɵformatCountLabel)(calls.length, {
|
|
13150
|
+
one: labels.toolCallUsedToolsOne,
|
|
13151
|
+
other: labels.toolCallUsedToolsOther
|
|
13152
|
+
})
|
|
13438
13153
|
}),
|
|
13439
13154
|
duration && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
13440
13155
|
className: "cpk-work-summary-detail",
|
|
13441
|
-
children:
|
|
13156
|
+
children: toolCount
|
|
13442
13157
|
}),
|
|
13443
|
-
failed > 0 && /* @__PURE__ */ (0, react_jsx_runtime.
|
|
13158
|
+
failed > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
13444
13159
|
className: "cpk-work-summary-failed",
|
|
13445
|
-
children:
|
|
13160
|
+
children: (0, _copilotkit_core.ɵformatLabel)(labels.toolCallFailedCountLabel, { count: failed })
|
|
13446
13161
|
})
|
|
13447
|
-
] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
13162
|
+
] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
13163
|
+
name: "ChevronRight",
|
|
13448
13164
|
"aria-hidden": "true",
|
|
13449
13165
|
className: cn("cpk-work-summary-chevron", isOpen && "cpk-work-summary-chevron-open")
|
|
13450
13166
|
})]
|
|
@@ -13859,68 +13575,6 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
13859
13575
|
if (JSON.stringify(prevProps.stateSnapshot) !== JSON.stringify(nextProps.stateSnapshot)) return false;
|
|
13860
13576
|
return true;
|
|
13861
13577
|
});
|
|
13862
|
-
/**
|
|
13863
|
-
* Deduplicates messages by ID. For assistant messages, merges occurrences:
|
|
13864
|
-
* recovers non-empty content from any earlier occurrence if the latest wiped it
|
|
13865
|
-
* (empty string means the streaming update cleared the field, not blank text),
|
|
13866
|
-
* and similarly recovers toolCalls from earlier occurrences if the latest is
|
|
13867
|
-
* undefined (an empty array [] is treated as intentional and kept as-is).
|
|
13868
|
-
* For all other roles, keeps the last entry.
|
|
13869
|
-
*
|
|
13870
|
-
* @internal Exported for unit testing only — not part of the public API.
|
|
13871
|
-
*/
|
|
13872
|
-
/**
|
|
13873
|
-
* Collapse tool calls that share an id, keeping first-seen order.
|
|
13874
|
-
*
|
|
13875
|
-
* AG-UI's TOOL_CALL_START handler appends to the parent message's `toolCalls`
|
|
13876
|
-
* without checking whether that id is already present. So whenever a start
|
|
13877
|
-
* event is applied twice — which the human-in-the-loop flow triggers when the
|
|
13878
|
-
* run syncs after `respond()` — the message ends up carrying the same call
|
|
13879
|
-
* twice. The second copy has EMPTY `arguments`, because a start event carries
|
|
13880
|
-
* none; the args arrive later as TOOL_CALL_ARGS deltas addressed to the first
|
|
13881
|
-
* copy.
|
|
13882
|
-
*
|
|
13883
|
-
* Left alone that renders the same tool call twice: once populated and once
|
|
13884
|
-
* blank (an approval card with no transaction id, offering live buttons for an
|
|
13885
|
-
* action already taken), and React warns "Encountered two children with the
|
|
13886
|
-
* same key" because the call id is the render key.
|
|
13887
|
-
*
|
|
13888
|
-
* The empty copy is the redundant one, so prefer whichever entry actually
|
|
13889
|
-
* carries arguments rather than blindly taking the first.
|
|
13890
|
-
*/
|
|
13891
|
-
function dedupeToolCalls(toolCalls) {
|
|
13892
|
-
const byId = /* @__PURE__ */ new Map();
|
|
13893
|
-
for (const toolCall of toolCalls) {
|
|
13894
|
-
const existing = byId.get(toolCall.id);
|
|
13895
|
-
if (!existing) {
|
|
13896
|
-
byId.set(toolCall.id, toolCall);
|
|
13897
|
-
continue;
|
|
13898
|
-
}
|
|
13899
|
-
if (!existing.function?.arguments && toolCall.function?.arguments) byId.set(toolCall.id, toolCall);
|
|
13900
|
-
}
|
|
13901
|
-
return byId.size === toolCalls.length ? toolCalls : [...byId.values()];
|
|
13902
|
-
}
|
|
13903
|
-
function deduplicateMessages(messages) {
|
|
13904
|
-
const acc = /* @__PURE__ */ new Map();
|
|
13905
|
-
for (const message of messages) {
|
|
13906
|
-
const existing = acc.get(message.id);
|
|
13907
|
-
if (existing && message.role === "assistant" && existing.role === "assistant") {
|
|
13908
|
-
const content = message.content || existing.content;
|
|
13909
|
-
const toolCalls = message.toolCalls ?? existing.toolCalls;
|
|
13910
|
-
acc.set(message.id, {
|
|
13911
|
-
...existing,
|
|
13912
|
-
...message,
|
|
13913
|
-
content,
|
|
13914
|
-
toolCalls: toolCalls ? dedupeToolCalls(toolCalls) : toolCalls
|
|
13915
|
-
});
|
|
13916
|
-
} else if (message.role === "assistant" && message.toolCalls) acc.set(message.id, {
|
|
13917
|
-
...message,
|
|
13918
|
-
toolCalls: dedupeToolCalls(message.toolCalls)
|
|
13919
|
-
});
|
|
13920
|
-
else acc.set(message.id, message);
|
|
13921
|
-
}
|
|
13922
|
-
return [...acc.values()];
|
|
13923
|
-
}
|
|
13924
13578
|
/** A row holding a single message, rendered as it would be ungrouped. */
|
|
13925
13579
|
function messageRow(message) {
|
|
13926
13580
|
return {
|
|
@@ -13969,7 +13623,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
13969
13623
|
if (!resolvedRunId) return void 0;
|
|
13970
13624
|
return copilotkit.getStateByRun(config.agentId, config.threadId, resolvedRunId);
|
|
13971
13625
|
};
|
|
13972
|
-
const deduplicatedMessages = (0, react.useMemo)(() => deduplicateMessages(messages), [messages]);
|
|
13626
|
+
const deduplicatedMessages = (0, react.useMemo)(() => (0, _copilotkit_core.ɵdeduplicateMessages)(messages), [messages]);
|
|
13973
13627
|
const transformedMessages = (0, react.useMemo)(() => transformMessages ? transformMessages(deduplicatedMessages) : deduplicatedMessages, [deduplicatedMessages, transformMessages]);
|
|
13974
13628
|
const rows = (0, react.useMemo)(() => groupMessages ? groupMessages(transformedMessages) : transformedMessages.map(messageRow), [transformedMessages, groupMessages]);
|
|
13975
13629
|
const renderedMessages = (0, react.useMemo)(() => groupMessages ? rows.flatMap((row) => row.type === "group" ? row.messages : [row.message]) : transformedMessages, [
|
|
@@ -13979,13 +13633,13 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
13979
13633
|
]);
|
|
13980
13634
|
const latestRenderedId = renderedMessages[renderedMessages.length - 1]?.id;
|
|
13981
13635
|
const rendererNames = useToolCallRendererNames();
|
|
13982
|
-
const toolCallLayouts = (0, react.useMemo)(() => toolCallDisplay === "separate" ? /* @__PURE__ */ new Map() : getToolCallLayouts(renderedMessages, messages, rendererNames), [
|
|
13636
|
+
const toolCallLayouts = (0, react.useMemo)(() => toolCallDisplay === "separate" ? /* @__PURE__ */ new Map() : (0, _copilotkit_core.ɵgetToolCallLayouts)(renderedMessages, messages, rendererNames), [
|
|
13983
13637
|
toolCallDisplay,
|
|
13984
13638
|
renderedMessages,
|
|
13985
13639
|
messages,
|
|
13986
13640
|
rendererNames
|
|
13987
13641
|
]);
|
|
13988
|
-
const turnWork = (0, react.useMemo)(() => toolCallDisplay === "turn" ? getTurnWork(renderedMessages, toolCallLayouts) : void 0, [
|
|
13642
|
+
const turnWork = (0, react.useMemo)(() => toolCallDisplay === "turn" ? (0, _copilotkit_core.ɵgetTurnWork)(renderedMessages, toolCallLayouts) : void 0, [
|
|
13989
13643
|
toolCallDisplay,
|
|
13990
13644
|
renderedMessages,
|
|
13991
13645
|
toolCallLayouts
|
|
@@ -13995,46 +13649,25 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
13995
13649
|
for (const turn of turnWork?.values() ?? []) byFirst.set(turn.firstMessageId, turn);
|
|
13996
13650
|
return byFirst;
|
|
13997
13651
|
}, [turnWork]);
|
|
13998
|
-
|
|
13999
|
-
for (let i = renderedMessages.length - 1; i >= 0; i--) if (renderedMessages[i].role === "user") {
|
|
14000
|
-
latestTurnKey = renderedMessages[i].id;
|
|
14001
|
-
break;
|
|
14002
|
-
}
|
|
14003
|
-
const isWorkingOn = (turnKey) => isRunning && turnKey === latestTurnKey;
|
|
13652
|
+
const latestTurnKey = (0, _copilotkit_core.ɵgetLatestTurnKey)(renderedMessages);
|
|
14004
13653
|
const [toggledTurns, setToggledTurns] = (0, react.useState)(() => /* @__PURE__ */ new Map());
|
|
14005
|
-
const
|
|
13654
|
+
const turnState = {
|
|
13655
|
+
toggledTurns,
|
|
13656
|
+
isRunning,
|
|
13657
|
+
latestTurnKey
|
|
13658
|
+
};
|
|
14006
13659
|
const workTimesRef = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
14007
|
-
if (toolCallDisplay === "turn") {
|
|
14008
|
-
|
|
14009
|
-
|
|
14010
|
-
|
|
14011
|
-
|
|
14012
|
-
|
|
14013
|
-
|
|
14014
|
-
|
|
14015
|
-
|
|
14016
|
-
|
|
14017
|
-
|
|
14018
|
-
if (times.workingSince === void 0) continue;
|
|
14019
|
-
times.elapsedMs += now - times.workingSince;
|
|
14020
|
-
times.workingSince = void 0;
|
|
14021
|
-
}
|
|
14022
|
-
}
|
|
14023
|
-
const { workOpen, workTextOpen } = (0, react.useMemo)(() => {
|
|
14024
|
-
const open = /* @__PURE__ */ new Map();
|
|
14025
|
-
const textOpen = /* @__PURE__ */ new Map();
|
|
14026
|
-
for (const turn of turnWork?.values() ?? []) {
|
|
14027
|
-
const turnOpen = toggledTurns.get(turn.key) ?? (isRunning && turn.key === latestTurnKey);
|
|
14028
|
-
for (const id of turn.workMessageIds) {
|
|
14029
|
-
open.set(id, turnOpen);
|
|
14030
|
-
if (id !== turn.replyTextMessageId) textOpen.set(id, turnOpen);
|
|
14031
|
-
}
|
|
14032
|
-
}
|
|
14033
|
-
return {
|
|
14034
|
-
workOpen: open,
|
|
14035
|
-
workTextOpen: textOpen
|
|
14036
|
-
};
|
|
14037
|
-
}, [
|
|
13660
|
+
if (toolCallDisplay === "turn") (0, _copilotkit_core.ɵrecordWorkTime)(workTimesRef.current, {
|
|
13661
|
+
isRunning,
|
|
13662
|
+
latestTurnKey,
|
|
13663
|
+
lastMessageRole: renderedMessages[renderedMessages.length - 1]?.role,
|
|
13664
|
+
now: Date.now()
|
|
13665
|
+
});
|
|
13666
|
+
const { workOpen, workTextOpen } = (0, react.useMemo)(() => (0, _copilotkit_core.ɵgetWorkOpenState)(turnWork?.values() ?? [], {
|
|
13667
|
+
toggledTurns,
|
|
13668
|
+
isRunning,
|
|
13669
|
+
latestTurnKey
|
|
13670
|
+
}), [
|
|
14038
13671
|
turnWork,
|
|
14039
13672
|
toggledTurns,
|
|
14040
13673
|
isRunning,
|
|
@@ -14054,8 +13687,8 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
14054
13687
|
workTextOpen
|
|
14055
13688
|
]);
|
|
14056
13689
|
const renderWorkSummary = (turnKey, calls) => {
|
|
14057
|
-
const working =
|
|
14058
|
-
const open =
|
|
13690
|
+
const working = (0, _copilotkit_core.ɵisTurnWorking)(turnKey, turnState);
|
|
13691
|
+
const open = (0, _copilotkit_core.ɵisTurnWorkOpen)(turnKey, turnState);
|
|
14059
13692
|
const times = workTimesRef.current.get(turnKey);
|
|
14060
13693
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Collapsible, {
|
|
14061
13694
|
open: working || calls.length > 0,
|
|
@@ -14482,7 +14115,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
14482
14115
|
* button named by `labels.attachmentRemoveButtonLabel`.
|
|
14483
14116
|
*/
|
|
14484
14117
|
const CopilotChatAttachmentQueue = ({ attachments, onRemoveAttachment, className }) => {
|
|
14485
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
14118
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
14486
14119
|
if (attachments.length === 0) return null;
|
|
14487
14120
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
14488
14121
|
"data-testid": "copilot-attachment-queue",
|
|
@@ -14558,7 +14191,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
14558
14191
|
* lightbox.
|
|
14559
14192
|
*/
|
|
14560
14193
|
function VideoPreview({ attachment }) {
|
|
14561
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
14194
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
14562
14195
|
const src = (0, _copilotkit_shared.getSourceUrl)(attachment.source);
|
|
14563
14196
|
const { thumbnailRef, vtName, open, openLightbox, closeLightbox } = useLightbox();
|
|
14564
14197
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
@@ -14582,7 +14215,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
14582
14215
|
"aria-label": labels.attachmentPlayVideoButtonLabel,
|
|
14583
14216
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
14584
14217
|
className: "cpk-attachment-queue-video-play-badge",
|
|
14585
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
14218
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
14219
|
+
name: "Play",
|
|
14220
|
+
className: "cpk-attachment-queue-video-play-icon"
|
|
14221
|
+
})
|
|
14586
14222
|
})
|
|
14587
14223
|
}),
|
|
14588
14224
|
open && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Lightbox, {
|
|
@@ -14635,6 +14271,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
14635
14271
|
return url;
|
|
14636
14272
|
}
|
|
14637
14273
|
function DocumentLightboxContent({ attachment, vtName }) {
|
|
14274
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
14638
14275
|
const mimeType = attachment.source.mimeType;
|
|
14639
14276
|
const blobUrl = useBlobUrl(attachment);
|
|
14640
14277
|
if (isPdf(mimeType)) {
|
|
@@ -14682,20 +14319,21 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
14682
14319
|
className: "cpk-attachment-queue-document-card-details",
|
|
14683
14320
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
14684
14321
|
className: "cpk-attachment-queue-document-card-name",
|
|
14685
|
-
children: attachment.filename ||
|
|
14322
|
+
children: attachment.filename || labels.attachmentDocumentLabel
|
|
14686
14323
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
14687
14324
|
className: "cpk-attachment-queue-document-card-meta",
|
|
14688
|
-
children: [mimeType ||
|
|
14325
|
+
children: [mimeType || labels.attachmentUnknownTypeText, attachment.size != null && ` · ${(0, _copilotkit_shared.formatFileSize)(attachment.size)}`]
|
|
14689
14326
|
})]
|
|
14690
14327
|
}),
|
|
14691
14328
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
14692
14329
|
className: "cpk-attachment-queue-document-card-note",
|
|
14693
|
-
children:
|
|
14330
|
+
children: labels.attachmentNoPreviewText
|
|
14694
14331
|
})
|
|
14695
14332
|
]
|
|
14696
14333
|
});
|
|
14697
14334
|
}
|
|
14698
14335
|
function DocumentPreview({ attachment }) {
|
|
14336
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
14699
14337
|
const { thumbnailRef, vtName, open, openLightbox, closeLightbox } = useLightbox();
|
|
14700
14338
|
const mimeType = attachment.source.mimeType;
|
|
14701
14339
|
const previewable = canPreviewInBrowser(mimeType);
|
|
@@ -14710,7 +14348,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
14710
14348
|
className: "cpk-attachment-queue-document-info",
|
|
14711
14349
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
14712
14350
|
className: "cpk-attachment-queue-document-name",
|
|
14713
|
-
children: attachment.filename ||
|
|
14351
|
+
children: attachment.filename || labels.attachmentDocumentLabel
|
|
14714
14352
|
}), attachment.size != null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
14715
14353
|
className: "cpk-attachment-queue-document-size",
|
|
14716
14354
|
children: (0, _copilotkit_shared.formatFileSize)(attachment.size)
|
|
@@ -14847,13 +14485,17 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
14847
14485
|
//#region src/components/chat/CopilotChatView.tsx
|
|
14848
14486
|
const SCROLL_BUTTON_OFFSET = 16;
|
|
14849
14487
|
function DropOverlay() {
|
|
14488
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
14850
14489
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
14851
14490
|
className: "cpk-chat-view-drop-overlay",
|
|
14852
14491
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
14853
14492
|
className: "cpk-chat-view-drop-overlay-content",
|
|
14854
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
14493
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
14494
|
+
name: "Upload",
|
|
14495
|
+
className: "cpk-chat-view-drop-overlay-icon"
|
|
14496
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
14855
14497
|
className: "cpk-chat-view-drop-overlay-label",
|
|
14856
|
-
children:
|
|
14498
|
+
children: labels.chatDropFilesLabel
|
|
14857
14499
|
})]
|
|
14858
14500
|
})
|
|
14859
14501
|
});
|
|
@@ -15293,7 +14935,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
15293
14935
|
});
|
|
15294
14936
|
};
|
|
15295
14937
|
_CopilotChatView.ScrollToBottomButton = ({ className, ...props }) => {
|
|
15296
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
14938
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
15297
14939
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
15298
14940
|
"data-testid": "copilot-scroll-to-bottom",
|
|
15299
14941
|
variant: "outline",
|
|
@@ -15301,7 +14943,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
15301
14943
|
className: cn("cpk-chat-view-scroll-to-bottom-button", className),
|
|
15302
14944
|
"aria-label": labels.chatScrollToBottomLabel,
|
|
15303
14945
|
...props,
|
|
15304
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
14946
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
14947
|
+
name: "ChevronDown",
|
|
14948
|
+
className: "cpk-chat-view-scroll-to-bottom-icon"
|
|
14949
|
+
})
|
|
15305
14950
|
});
|
|
15306
14951
|
};
|
|
15307
14952
|
_CopilotChatView.Feather = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -15309,7 +14954,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
15309
14954
|
...props
|
|
15310
14955
|
});
|
|
15311
14956
|
_CopilotChatView.WelcomeMessage = ({ className, ...props }) => {
|
|
15312
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
14957
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
15313
14958
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
|
|
15314
14959
|
className: cn("cpk-chat-view-welcome-message", className),
|
|
15315
14960
|
...props,
|
|
@@ -15355,119 +15000,6 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
15355
15000
|
})(CopilotChatView || (CopilotChatView = {}));
|
|
15356
15001
|
var CopilotChatView_default = CopilotChatView;
|
|
15357
15002
|
|
|
15358
|
-
//#endregion
|
|
15359
|
-
//#region src/lib/transcription-client.ts
|
|
15360
|
-
/**
|
|
15361
|
-
* Convert a Blob to a base64 string
|
|
15362
|
-
*/
|
|
15363
|
-
async function blobToBase64(blob) {
|
|
15364
|
-
return new Promise((resolve, reject) => {
|
|
15365
|
-
const reader = new FileReader();
|
|
15366
|
-
reader.onloadend = () => {
|
|
15367
|
-
const base64 = reader.result.split(",")[1];
|
|
15368
|
-
resolve(base64 ?? "");
|
|
15369
|
-
};
|
|
15370
|
-
reader.onerror = () => reject(/* @__PURE__ */ new Error("Failed to read audio data"));
|
|
15371
|
-
reader.readAsDataURL(blob);
|
|
15372
|
-
});
|
|
15373
|
-
}
|
|
15374
|
-
/**
|
|
15375
|
-
* Check if an error response matches our expected format
|
|
15376
|
-
*/
|
|
15377
|
-
function isTranscriptionErrorResponse(data) {
|
|
15378
|
-
return typeof data === "object" && data !== null && "error" in data && "message" in data && typeof data.error === "string" && typeof data.message === "string";
|
|
15379
|
-
}
|
|
15380
|
-
/**
|
|
15381
|
-
* Parse error info from a transcription error response
|
|
15382
|
-
*/
|
|
15383
|
-
function parseTranscriptionError(response) {
|
|
15384
|
-
return {
|
|
15385
|
-
code: response.error,
|
|
15386
|
-
message: response.message,
|
|
15387
|
-
retryable: response.retryable ?? false
|
|
15388
|
-
};
|
|
15389
|
-
}
|
|
15390
|
-
/**
|
|
15391
|
-
* Custom error type for transcription failures.
|
|
15392
|
-
* Extends Error with transcription-specific info for contextual error handling.
|
|
15393
|
-
*/
|
|
15394
|
-
var TranscriptionError = class extends Error {
|
|
15395
|
-
constructor(info) {
|
|
15396
|
-
super(info.message);
|
|
15397
|
-
this.name = "TranscriptionError";
|
|
15398
|
-
this.info = info;
|
|
15399
|
-
}
|
|
15400
|
-
};
|
|
15401
|
-
/**
|
|
15402
|
-
* Transcribe an audio blob using the CopilotKit runtime
|
|
15403
|
-
*
|
|
15404
|
-
* Supports both REST mode (multipart/form-data) and single-endpoint mode (base64 JSON)
|
|
15405
|
-
*
|
|
15406
|
-
* @throws {TranscriptionError} When transcription fails with typed error information
|
|
15407
|
-
*/
|
|
15408
|
-
async function transcribeAudio(core, audioBlob, filename = "recording.webm") {
|
|
15409
|
-
const runtimeUrl = core.runtimeUrl;
|
|
15410
|
-
if (!runtimeUrl) throw new TranscriptionError({
|
|
15411
|
-
code: _copilotkit_shared.TranscriptionErrorCode.INVALID_REQUEST,
|
|
15412
|
-
message: "Runtime URL is not configured",
|
|
15413
|
-
retryable: false
|
|
15414
|
-
});
|
|
15415
|
-
const headers = { ...await core.resolveHeaders() };
|
|
15416
|
-
let response;
|
|
15417
|
-
try {
|
|
15418
|
-
if (core.runtimeTransport === "single") {
|
|
15419
|
-
const base64Audio = await blobToBase64(audioBlob);
|
|
15420
|
-
headers["Content-Type"] = "application/json";
|
|
15421
|
-
response = await fetch(runtimeUrl, {
|
|
15422
|
-
method: "POST",
|
|
15423
|
-
headers,
|
|
15424
|
-
body: JSON.stringify({
|
|
15425
|
-
method: "transcribe",
|
|
15426
|
-
body: {
|
|
15427
|
-
audio: base64Audio,
|
|
15428
|
-
mimeType: audioBlob.type || "audio/webm",
|
|
15429
|
-
filename
|
|
15430
|
-
}
|
|
15431
|
-
})
|
|
15432
|
-
});
|
|
15433
|
-
} else {
|
|
15434
|
-
delete headers["Content-Type"];
|
|
15435
|
-
const formData = new FormData();
|
|
15436
|
-
formData.append("audio", audioBlob, filename);
|
|
15437
|
-
response = await fetch(`${runtimeUrl}/transcribe`, {
|
|
15438
|
-
method: "POST",
|
|
15439
|
-
headers,
|
|
15440
|
-
body: formData
|
|
15441
|
-
});
|
|
15442
|
-
}
|
|
15443
|
-
} catch (error) {
|
|
15444
|
-
throw new TranscriptionError({
|
|
15445
|
-
code: _copilotkit_shared.TranscriptionErrorCode.NETWORK_ERROR,
|
|
15446
|
-
message: error instanceof Error ? error.message : "Network request failed",
|
|
15447
|
-
retryable: true
|
|
15448
|
-
});
|
|
15449
|
-
}
|
|
15450
|
-
if (!response.ok) {
|
|
15451
|
-
let errorData;
|
|
15452
|
-
try {
|
|
15453
|
-
errorData = await response.json();
|
|
15454
|
-
} catch {
|
|
15455
|
-
throw new TranscriptionError({
|
|
15456
|
-
code: _copilotkit_shared.TranscriptionErrorCode.PROVIDER_ERROR,
|
|
15457
|
-
message: `HTTP ${response.status}: ${response.statusText}`,
|
|
15458
|
-
retryable: response.status >= 500
|
|
15459
|
-
});
|
|
15460
|
-
}
|
|
15461
|
-
if (isTranscriptionErrorResponse(errorData)) throw new TranscriptionError(parseTranscriptionError(errorData));
|
|
15462
|
-
throw new TranscriptionError({
|
|
15463
|
-
code: _copilotkit_shared.TranscriptionErrorCode.PROVIDER_ERROR,
|
|
15464
|
-
message: typeof errorData === "object" && errorData !== null && "message" in errorData ? String(errorData.message) : "Transcription failed",
|
|
15465
|
-
retryable: response.status >= 500
|
|
15466
|
-
});
|
|
15467
|
-
}
|
|
15468
|
-
return await response.json();
|
|
15469
|
-
}
|
|
15470
|
-
|
|
15471
15003
|
//#endregion
|
|
15472
15004
|
//#region src/providers/use-inspector-thread-override.ts
|
|
15473
15005
|
function useInspectorThreadOverride(args) {
|
|
@@ -15949,7 +15481,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
15949
15481
|
}
|
|
15950
15482
|
if (!isCurrentSelection()) return false;
|
|
15951
15483
|
if (failedConnectionsRef.current.has(agent)) {
|
|
15952
|
-
setTranscriptionError(
|
|
15484
|
+
setTranscriptionError({ labelKey: "threadLoadErrorText" });
|
|
15953
15485
|
return "failed";
|
|
15954
15486
|
}
|
|
15955
15487
|
const maybeAware = agent;
|
|
@@ -15974,7 +15506,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
15974
15506
|
const onSubmitInput = (0, react.useCallback)(async (value) => {
|
|
15975
15507
|
if (selectedAttachmentsRef.current.some((a) => a.status === "uploading")) {
|
|
15976
15508
|
console.error("[CopilotKit] Cannot send while attachments are uploading (pre-await guard)");
|
|
15977
|
-
setTranscriptionError(
|
|
15509
|
+
setTranscriptionError({ labelKey: "chatAttachmentsUploadingText" });
|
|
15978
15510
|
return;
|
|
15979
15511
|
}
|
|
15980
15512
|
setInputValue("");
|
|
@@ -15986,7 +15518,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
15986
15518
|
}
|
|
15987
15519
|
if (selectedAttachmentsRef.current.some((a) => a.status === "uploading")) {
|
|
15988
15520
|
console.error("[CopilotKit] Cannot send while attachments are uploading (post-await re-check)");
|
|
15989
|
-
setTranscriptionError(
|
|
15521
|
+
setTranscriptionError({ labelKey: "chatAttachmentsUploadingText" });
|
|
15990
15522
|
setInputValue(value);
|
|
15991
15523
|
return;
|
|
15992
15524
|
}
|
|
@@ -16104,7 +15636,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
16104
15636
|
setIsTranscribing(true);
|
|
16105
15637
|
try {
|
|
16106
15638
|
setTranscriptionError(null);
|
|
16107
|
-
const result = await transcribeAudio(copilotkit, audioBlob);
|
|
15639
|
+
const result = await (0, _copilotkit_core.ɵtranscribeAudio)(copilotkit, audioBlob);
|
|
16108
15640
|
setInputValue((prev) => {
|
|
16109
15641
|
const trimmedPrev = prev.trim();
|
|
16110
15642
|
if (trimmedPrev) return `${trimmedPrev} ${result.text}`;
|
|
@@ -16112,33 +15644,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
16112
15644
|
});
|
|
16113
15645
|
} catch (error) {
|
|
16114
15646
|
console.error("CopilotChat: Transcription failed", error);
|
|
16115
|
-
if (error instanceof TranscriptionError) {
|
|
16116
|
-
const
|
|
16117
|
-
|
|
16118
|
-
|
|
16119
|
-
setTranscriptionError("Too many requests. Please wait a moment.");
|
|
16120
|
-
break;
|
|
16121
|
-
case _copilotkit_shared.TranscriptionErrorCode.AUTH_FAILED:
|
|
16122
|
-
setTranscriptionError("Authentication error. Please check your configuration.");
|
|
16123
|
-
break;
|
|
16124
|
-
case _copilotkit_shared.TranscriptionErrorCode.AUDIO_TOO_LONG:
|
|
16125
|
-
setTranscriptionError("Recording is too long. Please try a shorter recording.");
|
|
16126
|
-
break;
|
|
16127
|
-
case _copilotkit_shared.TranscriptionErrorCode.AUDIO_TOO_SHORT:
|
|
16128
|
-
setTranscriptionError("Recording is too short. Please try again.");
|
|
16129
|
-
break;
|
|
16130
|
-
case _copilotkit_shared.TranscriptionErrorCode.INVALID_AUDIO_FORMAT:
|
|
16131
|
-
setTranscriptionError("Audio format not supported.");
|
|
16132
|
-
break;
|
|
16133
|
-
case _copilotkit_shared.TranscriptionErrorCode.SERVICE_NOT_CONFIGURED:
|
|
16134
|
-
setTranscriptionError("Transcription service is not available.");
|
|
16135
|
-
break;
|
|
16136
|
-
case _copilotkit_shared.TranscriptionErrorCode.NETWORK_ERROR:
|
|
16137
|
-
setTranscriptionError("Network error. Please check your connection.");
|
|
16138
|
-
break;
|
|
16139
|
-
default: setTranscriptionError(retryable ? "Transcription failed. Please try again." : message);
|
|
16140
|
-
}
|
|
16141
|
-
} else setTranscriptionError("Transcription failed. Please try again.");
|
|
15647
|
+
if (error instanceof _copilotkit_core.TranscriptionError) {
|
|
15648
|
+
const labelKey = (0, _copilotkit_core.ɵtranscriptionErrorMessageKey)(error.info);
|
|
15649
|
+
setTranscriptionError(labelKey ? { labelKey } : { text: error.info.message });
|
|
15650
|
+
} else setTranscriptionError({ labelKey: "transcriptionErrorGenericText" });
|
|
16142
15651
|
} finally {
|
|
16143
15652
|
setIsTranscribing(false);
|
|
16144
15653
|
}
|
|
@@ -16170,11 +15679,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
16170
15679
|
const effectiveStopHandler = agent.isRunning && hasMessages ? providedStopHandler ?? stopCurrentRun : providedStopHandler;
|
|
16171
15680
|
const showTranscription = isTranscriptionEnabled && isMediaRecorderSupported;
|
|
16172
15681
|
const effectiveMode = isTranscribing ? "processing" : transcribeMode;
|
|
16173
|
-
const messages = (0, react.useMemo)(() => [...agent.messages], [agent.messages
|
|
16174
|
-
const contentKey = typeof m.content === "string" ? m.content.length : Array.isArray(m.content) ? m.content.length : m.content && typeof m.content === "object" ? JSON.stringify(m.content) : 0;
|
|
16175
|
-
const toolCallsKey = "toolCalls" in m && Array.isArray(m.toolCalls) ? m.toolCalls.map((tc) => `${tc.id}:${tc.function?.arguments?.length ?? 0}`).join(";") : "";
|
|
16176
|
-
return `${m.id}:${m.role}:${contentKey}:${toolCallsKey}`;
|
|
16177
|
-
}).join(",")]);
|
|
15682
|
+
const messages = (0, react.useMemo)(() => [...agent.messages], [(0, _copilotkit_core.ɵmessagesFingerprint)(agent.messages)]);
|
|
16178
15683
|
const lastUserMessageId = (0, react.useMemo)(() => {
|
|
16179
15684
|
for (let i = messages.length - 1; i >= 0; i--) if (messages[i].role === "user") return messages[i].id;
|
|
16180
15685
|
return null;
|
|
@@ -16246,7 +15751,11 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
16246
15751
|
fontSize: "14px",
|
|
16247
15752
|
zIndex: 50
|
|
16248
15753
|
},
|
|
16249
|
-
children: transcriptionError
|
|
15754
|
+
children: "labelKey" in transcriptionError ? {
|
|
15755
|
+
..._copilotkit_core.CopilotChatDefaultLabels,
|
|
15756
|
+
...existingConfig?.labels,
|
|
15757
|
+
...labels
|
|
15758
|
+
}[transcriptionError.labelKey] : transcriptionError.text
|
|
16250
15759
|
}),
|
|
16251
15760
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(LastUserMessageContext.Provider, {
|
|
16252
15761
|
value: lastUserMessageState,
|
|
@@ -16269,16 +15778,18 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
16269
15778
|
//#endregion
|
|
16270
15779
|
//#region src/components/chat/CopilotChatToggleButton.tsx
|
|
16271
15780
|
const ICON_CLASS = "cpk-chat-toggle-button-icon";
|
|
16272
|
-
const DefaultOpenIcon = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
15781
|
+
const DefaultOpenIcon = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
16273
15782
|
className: className ?? ICON_CLASS,
|
|
16274
15783
|
strokeWidth: 1.75,
|
|
16275
15784
|
fill: "currentColor",
|
|
16276
|
-
...props
|
|
15785
|
+
...props,
|
|
15786
|
+
name: "MessageCircle"
|
|
16277
15787
|
});
|
|
16278
|
-
const DefaultCloseIcon = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
15788
|
+
const DefaultCloseIcon = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
16279
15789
|
className: className ?? ICON_CLASS,
|
|
16280
15790
|
strokeWidth: 1.75,
|
|
16281
|
-
...props
|
|
15791
|
+
...props,
|
|
15792
|
+
name: "X"
|
|
16282
15793
|
});
|
|
16283
15794
|
DefaultOpenIcon.displayName = "CopilotChatToggleButton.OpenIcon";
|
|
16284
15795
|
DefaultCloseIcon.displayName = "CopilotChatToggleButton.CloseIcon";
|
|
@@ -16287,7 +15798,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
16287
15798
|
const CopilotChatToggleButton = react.default.forwardRef(function CopilotChatToggleButton({ openIcon, closeIcon, className, ...buttonProps }, ref) {
|
|
16288
15799
|
const { onClick, type, disabled, ...restProps } = buttonProps;
|
|
16289
15800
|
const configuration = useCopilotChatConfiguration();
|
|
16290
|
-
const labels = configuration?.labels ?? CopilotChatDefaultLabels;
|
|
15801
|
+
const labels = configuration?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
16291
15802
|
const [fallbackOpen, setFallbackOpen] = (0, react.useState)(false);
|
|
16292
15803
|
const isOpen = configuration?.isModalOpen ?? fallbackOpen;
|
|
16293
15804
|
const setModalOpen = configuration?.setModalOpen ?? setFallbackOpen;
|
|
@@ -16404,7 +15915,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
16404
15915
|
}
|
|
16405
15916
|
function CopilotModalHeader({ title, titleContent, closeButton, drawerLauncher, children, className, ...rest }) {
|
|
16406
15917
|
const configuration = useCopilotChatConfiguration();
|
|
16407
|
-
const fallbackTitle = configuration?.labels.modalHeaderTitle ?? CopilotChatDefaultLabels.modalHeaderTitle;
|
|
15918
|
+
const fallbackTitle = configuration?.labels.modalHeaderTitle ?? _copilotkit_core.CopilotChatDefaultLabels.modalHeaderTitle;
|
|
16408
15919
|
const resolvedTitle = title ?? fallbackTitle;
|
|
16409
15920
|
const isMobile = useIsMobileViewport();
|
|
16410
15921
|
const drawerRegistered = (configuration?.drawerRegistered ?? false) && isMobile;
|
|
@@ -16460,28 +15971,30 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
16460
15971
|
children
|
|
16461
15972
|
});
|
|
16462
15973
|
_CopilotModalHeader.CloseButton = ({ className, ...props }) => {
|
|
16463
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
15974
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
16464
15975
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
16465
15976
|
type: "button",
|
|
16466
15977
|
"data-testid": "copilot-close-button",
|
|
16467
15978
|
className: cn("cpk-modal-header-close-button", className),
|
|
16468
15979
|
"aria-label": labels.modalHeaderCloseButtonLabel,
|
|
16469
15980
|
...props,
|
|
16470
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
15981
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
15982
|
+
name: "X",
|
|
16471
15983
|
className: "cpk-modal-header-close-icon",
|
|
16472
15984
|
"aria-hidden": "true"
|
|
16473
15985
|
})
|
|
16474
15986
|
});
|
|
16475
15987
|
};
|
|
16476
15988
|
_CopilotModalHeader.DrawerLauncher = ({ className, ...props }) => {
|
|
16477
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
15989
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
16478
15990
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
16479
15991
|
type: "button",
|
|
16480
15992
|
"data-testid": "copilot-threads-drawer-launcher",
|
|
16481
15993
|
className: cn("cpk-modal-header-drawer-launcher", className),
|
|
16482
15994
|
"aria-label": labels.modalHeaderThreadsButtonLabel,
|
|
16483
15995
|
...props,
|
|
16484
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
15996
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
15997
|
+
name: "PanelLeftOpen",
|
|
16485
15998
|
className: "cpk-modal-header-drawer-launcher-icon",
|
|
16486
15999
|
"aria-hidden": "true"
|
|
16487
16000
|
})
|
|
@@ -16586,7 +16099,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
16586
16099
|
paddingBottom: "env(safe-area-inset-bottom)"
|
|
16587
16100
|
},
|
|
16588
16101
|
"aria-hidden": !isSidebarOpen,
|
|
16589
|
-
"aria-label": configuration?.labels.sidebarLabel ?? CopilotChatDefaultLabels.sidebarLabel,
|
|
16102
|
+
"aria-label": configuration?.labels.sidebarLabel ?? _copilotkit_core.CopilotChatDefaultLabels.sidebarLabel,
|
|
16590
16103
|
role: "complementary",
|
|
16591
16104
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
16592
16105
|
className: "cpk-sidebar-view-panel",
|
|
@@ -16667,7 +16180,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
16667
16180
|
const configuration = useCopilotChatConfiguration();
|
|
16668
16181
|
const isPopupOpen = configuration?.isModalOpen ?? false;
|
|
16669
16182
|
const setModalOpen = configuration?.setModalOpen;
|
|
16670
|
-
const labels = configuration?.labels ?? CopilotChatDefaultLabels;
|
|
16183
|
+
const labels = configuration?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
16671
16184
|
const containerRef = (0, react.useRef)(null);
|
|
16672
16185
|
const [isRendered, setIsRendered] = (0, react.useState)(isPopupOpen);
|
|
16673
16186
|
const [isAnimatingOut, setIsAnimatingOut] = (0, react.useState)(false);
|
|
@@ -17374,7 +16887,6 @@ Object.defineProperty(exports, 'BaseMessageSchema', {
|
|
|
17374
16887
|
return _ag_ui_core_schemas.BaseMessageSchema;
|
|
17375
16888
|
}
|
|
17376
16889
|
});
|
|
17377
|
-
exports.BasicMarkdownRenderer = BasicMarkdownRenderer;
|
|
17378
16890
|
Object.defineProperty(exports, 'CompatibilityBoundary', {
|
|
17379
16891
|
enumerable: true,
|
|
17380
16892
|
get: function () {
|
|
@@ -17410,6 +16922,12 @@ exports.CopilotChatAttachmentQueue = CopilotChatAttachmentQueue;
|
|
|
17410
16922
|
exports.CopilotChatAttachmentRenderer = CopilotChatAttachmentRenderer;
|
|
17411
16923
|
exports.CopilotChatAudioRecorder = CopilotChatAudioRecorder;
|
|
17412
16924
|
exports.CopilotChatConfigurationProvider = CopilotChatConfigurationProvider;
|
|
16925
|
+
Object.defineProperty(exports, 'CopilotChatDefaultLabels', {
|
|
16926
|
+
enumerable: true,
|
|
16927
|
+
get: function () {
|
|
16928
|
+
return _copilotkit_core.CopilotChatDefaultLabels;
|
|
16929
|
+
}
|
|
16930
|
+
});
|
|
17413
16931
|
exports.CopilotChatInput = CopilotChatInput_default;
|
|
17414
16932
|
exports.CopilotChatMessageView = CopilotChatMessageView;
|
|
17415
16933
|
exports.CopilotChatReasoningMessage = CopilotChatReasoningMessage_default;
|
|
@@ -17594,7 +17112,12 @@ Object.defineProperty(exports, 'INSPECTOR_THREAD_BRIDGE_PLUGIN_ID', {
|
|
|
17594
17112
|
}
|
|
17595
17113
|
});
|
|
17596
17114
|
exports.INTELLIGENCE_TURN_HEAD = INTELLIGENCE_TURN_HEAD;
|
|
17597
|
-
exports
|
|
17115
|
+
Object.defineProperty(exports, 'INTERRUPT_EVENT_NAME', {
|
|
17116
|
+
enumerable: true,
|
|
17117
|
+
get: function () {
|
|
17118
|
+
return _copilotkit_core.INTERRUPT_EVENT_NAME;
|
|
17119
|
+
}
|
|
17120
|
+
});
|
|
17598
17121
|
Object.defineProperty(exports, 'IdentityCapabilitiesSchema', {
|
|
17599
17122
|
enumerable: true,
|
|
17600
17123
|
get: function () {
|
|
@@ -18151,6 +17674,18 @@ Object.defineProperty(exports, 'ToolsCapabilitiesSchema', {
|
|
|
18151
17674
|
return _ag_ui_core_schemas.ToolsCapabilitiesSchema;
|
|
18152
17675
|
}
|
|
18153
17676
|
});
|
|
17677
|
+
Object.defineProperty(exports, 'TranscriptionError', {
|
|
17678
|
+
enumerable: true,
|
|
17679
|
+
get: function () {
|
|
17680
|
+
return _copilotkit_core.TranscriptionError;
|
|
17681
|
+
}
|
|
17682
|
+
});
|
|
17683
|
+
Object.defineProperty(exports, 'TranscriptionErrorCode', {
|
|
17684
|
+
enumerable: true,
|
|
17685
|
+
get: function () {
|
|
17686
|
+
return _copilotkit_core.TranscriptionErrorCode;
|
|
17687
|
+
}
|
|
17688
|
+
});
|
|
18154
17689
|
Object.defineProperty(exports, 'TransportCapabilitiesSchema', {
|
|
18155
17690
|
enumerable: true,
|
|
18156
17691
|
get: function () {
|
|
@@ -18476,12 +18011,6 @@ Object.defineProperty(exports, 'onInspectorViewThreadResult', {
|
|
|
18476
18011
|
return _copilotkit_core.onInspectorViewThreadResult;
|
|
18477
18012
|
}
|
|
18478
18013
|
});
|
|
18479
|
-
Object.defineProperty(exports, 'parseMarkdown', {
|
|
18480
|
-
enumerable: true,
|
|
18481
|
-
get: function () {
|
|
18482
|
-
return _copilotkit_core.parseMarkdown;
|
|
18483
|
-
}
|
|
18484
|
-
});
|
|
18485
18014
|
Object.defineProperty(exports, 'parseProtoStream', {
|
|
18486
18015
|
enumerable: true,
|
|
18487
18016
|
get: function () {
|
|
@@ -18599,8 +18128,6 @@ exports.useHumanInTheLoop = useHumanInTheLoop;
|
|
|
18599
18128
|
exports.useInterrupt = useInterrupt;
|
|
18600
18129
|
exports.useLearnFromUserAction = useLearnFromUserAction;
|
|
18601
18130
|
exports.useLearnFromUserActionInCurrentThread = useLearnFromUserActionInCurrentThread;
|
|
18602
|
-
exports.useLearningContainers = useLearningContainers;
|
|
18603
|
-
exports.useLearningContainersInCurrentThread = useLearningContainersInCurrentThread;
|
|
18604
18131
|
exports.useLicenseContext = useLicenseContext;
|
|
18605
18132
|
exports.useMarkdownRenderer = useMarkdownRenderer;
|
|
18606
18133
|
exports.useMemories = useMemories;
|
|
@@ -18659,6 +18186,30 @@ Object.defineProperty(exports, 'ɵclearAgentInterruptState', {
|
|
|
18659
18186
|
return _copilotkit_core.ɵclearAgentInterruptState;
|
|
18660
18187
|
}
|
|
18661
18188
|
});
|
|
18189
|
+
Object.defineProperty(exports, 'ɵcomposerButtonState', {
|
|
18190
|
+
enumerable: true,
|
|
18191
|
+
get: function () {
|
|
18192
|
+
return _copilotkit_core.ɵcomposerButtonState;
|
|
18193
|
+
}
|
|
18194
|
+
});
|
|
18195
|
+
Object.defineProperty(exports, 'ɵcopilotIconSvgAttributes', {
|
|
18196
|
+
enumerable: true,
|
|
18197
|
+
get: function () {
|
|
18198
|
+
return _copilotkit_core.ɵcopilotIconSvgAttributes;
|
|
18199
|
+
}
|
|
18200
|
+
});
|
|
18201
|
+
Object.defineProperty(exports, 'ɵcopilotIcons', {
|
|
18202
|
+
enumerable: true,
|
|
18203
|
+
get: function () {
|
|
18204
|
+
return _copilotkit_core.ɵcopilotIcons;
|
|
18205
|
+
}
|
|
18206
|
+
});
|
|
18207
|
+
Object.defineProperty(exports, 'ɵcountFailedToolCalls', {
|
|
18208
|
+
enumerable: true,
|
|
18209
|
+
get: function () {
|
|
18210
|
+
return _copilotkit_core.ɵcountFailedToolCalls;
|
|
18211
|
+
}
|
|
18212
|
+
});
|
|
18662
18213
|
Object.defineProperty(exports, 'ɵcreateMemoryStore', {
|
|
18663
18214
|
enumerable: true,
|
|
18664
18215
|
get: function () {
|
|
@@ -18677,12 +18228,102 @@ Object.defineProperty(exports, 'ɵcreateThreadStore', {
|
|
|
18677
18228
|
return _copilotkit_core.ɵcreateThreadStore;
|
|
18678
18229
|
}
|
|
18679
18230
|
});
|
|
18231
|
+
Object.defineProperty(exports, 'ɵdeduplicateMessages', {
|
|
18232
|
+
enumerable: true,
|
|
18233
|
+
get: function () {
|
|
18234
|
+
return _copilotkit_core.ɵdeduplicateMessages;
|
|
18235
|
+
}
|
|
18236
|
+
});
|
|
18237
|
+
Object.defineProperty(exports, 'ɵformatCountLabel', {
|
|
18238
|
+
enumerable: true,
|
|
18239
|
+
get: function () {
|
|
18240
|
+
return _copilotkit_core.ɵformatCountLabel;
|
|
18241
|
+
}
|
|
18242
|
+
});
|
|
18243
|
+
Object.defineProperty(exports, 'ɵformatLabel', {
|
|
18244
|
+
enumerable: true,
|
|
18245
|
+
get: function () {
|
|
18246
|
+
return _copilotkit_core.ɵformatLabel;
|
|
18247
|
+
}
|
|
18248
|
+
});
|
|
18249
|
+
Object.defineProperty(exports, 'ɵformatReasoningDuration', {
|
|
18250
|
+
enumerable: true,
|
|
18251
|
+
get: function () {
|
|
18252
|
+
return _copilotkit_core.ɵformatReasoningDuration;
|
|
18253
|
+
}
|
|
18254
|
+
});
|
|
18255
|
+
Object.defineProperty(exports, 'ɵformatToolNames', {
|
|
18256
|
+
enumerable: true,
|
|
18257
|
+
get: function () {
|
|
18258
|
+
return _copilotkit_core.ɵformatToolNames;
|
|
18259
|
+
}
|
|
18260
|
+
});
|
|
18261
|
+
Object.defineProperty(exports, 'ɵformatWorkDuration', {
|
|
18262
|
+
enumerable: true,
|
|
18263
|
+
get: function () {
|
|
18264
|
+
return _copilotkit_core.ɵformatWorkDuration;
|
|
18265
|
+
}
|
|
18266
|
+
});
|
|
18680
18267
|
Object.defineProperty(exports, 'ɵgetAgentInterruptState', {
|
|
18681
18268
|
enumerable: true,
|
|
18682
18269
|
get: function () {
|
|
18683
18270
|
return _copilotkit_core.ɵgetAgentInterruptState;
|
|
18684
18271
|
}
|
|
18685
18272
|
});
|
|
18273
|
+
Object.defineProperty(exports, 'ɵgetArgumentPreview', {
|
|
18274
|
+
enumerable: true,
|
|
18275
|
+
get: function () {
|
|
18276
|
+
return _copilotkit_core.ɵgetArgumentPreview;
|
|
18277
|
+
}
|
|
18278
|
+
});
|
|
18279
|
+
Object.defineProperty(exports, 'ɵgetLatestTurnKey', {
|
|
18280
|
+
enumerable: true,
|
|
18281
|
+
get: function () {
|
|
18282
|
+
return _copilotkit_core.ɵgetLatestTurnKey;
|
|
18283
|
+
}
|
|
18284
|
+
});
|
|
18285
|
+
Object.defineProperty(exports, 'ɵgetToolCallLayouts', {
|
|
18286
|
+
enumerable: true,
|
|
18287
|
+
get: function () {
|
|
18288
|
+
return _copilotkit_core.ɵgetToolCallLayouts;
|
|
18289
|
+
}
|
|
18290
|
+
});
|
|
18291
|
+
Object.defineProperty(exports, 'ɵgetToolCallPreview', {
|
|
18292
|
+
enumerable: true,
|
|
18293
|
+
get: function () {
|
|
18294
|
+
return _copilotkit_core.ɵgetToolCallPreview;
|
|
18295
|
+
}
|
|
18296
|
+
});
|
|
18297
|
+
Object.defineProperty(exports, 'ɵgetToolCallRendererNames', {
|
|
18298
|
+
enumerable: true,
|
|
18299
|
+
get: function () {
|
|
18300
|
+
return _copilotkit_core.ɵgetToolCallRendererNames;
|
|
18301
|
+
}
|
|
18302
|
+
});
|
|
18303
|
+
Object.defineProperty(exports, 'ɵgetToolCallRowStatus', {
|
|
18304
|
+
enumerable: true,
|
|
18305
|
+
get: function () {
|
|
18306
|
+
return _copilotkit_core.ɵgetToolCallRowStatus;
|
|
18307
|
+
}
|
|
18308
|
+
});
|
|
18309
|
+
Object.defineProperty(exports, 'ɵgetToolResults', {
|
|
18310
|
+
enumerable: true,
|
|
18311
|
+
get: function () {
|
|
18312
|
+
return _copilotkit_core.ɵgetToolResults;
|
|
18313
|
+
}
|
|
18314
|
+
});
|
|
18315
|
+
Object.defineProperty(exports, 'ɵgetTurnWork', {
|
|
18316
|
+
enumerable: true,
|
|
18317
|
+
get: function () {
|
|
18318
|
+
return _copilotkit_core.ɵgetTurnWork;
|
|
18319
|
+
}
|
|
18320
|
+
});
|
|
18321
|
+
Object.defineProperty(exports, 'ɵgetWorkOpenState', {
|
|
18322
|
+
enumerable: true,
|
|
18323
|
+
get: function () {
|
|
18324
|
+
return _copilotkit_core.ɵgetWorkOpenState;
|
|
18325
|
+
}
|
|
18326
|
+
});
|
|
18686
18327
|
Object.defineProperty(exports, 'ɵisCopilotKitFeature', {
|
|
18687
18328
|
enumerable: true,
|
|
18688
18329
|
get: function () {
|
|
@@ -18701,6 +18342,18 @@ Object.defineProperty(exports, 'ɵisRetryableMemoryStatus', {
|
|
|
18701
18342
|
return _copilotkit_core.ɵisRetryableMemoryStatus;
|
|
18702
18343
|
}
|
|
18703
18344
|
});
|
|
18345
|
+
Object.defineProperty(exports, 'ɵisTurnWorkOpen', {
|
|
18346
|
+
enumerable: true,
|
|
18347
|
+
get: function () {
|
|
18348
|
+
return _copilotkit_core.ɵisTurnWorkOpen;
|
|
18349
|
+
}
|
|
18350
|
+
});
|
|
18351
|
+
Object.defineProperty(exports, 'ɵisTurnWorking', {
|
|
18352
|
+
enumerable: true,
|
|
18353
|
+
get: function () {
|
|
18354
|
+
return _copilotkit_core.ɵisTurnWorking;
|
|
18355
|
+
}
|
|
18356
|
+
});
|
|
18704
18357
|
Object.defineProperty(exports, 'ɵjoinPhoenixChannel$', {
|
|
18705
18358
|
enumerable: true,
|
|
18706
18359
|
get: function () {
|
|
@@ -18737,6 +18390,12 @@ Object.defineProperty(exports, 'ɵmemoryRestEvents', {
|
|
|
18737
18390
|
return _copilotkit_core.ɵmemoryRestEvents;
|
|
18738
18391
|
}
|
|
18739
18392
|
});
|
|
18393
|
+
Object.defineProperty(exports, 'ɵmessagesFingerprint', {
|
|
18394
|
+
enumerable: true,
|
|
18395
|
+
get: function () {
|
|
18396
|
+
return _copilotkit_core.ɵmessagesFingerprint;
|
|
18397
|
+
}
|
|
18398
|
+
});
|
|
18740
18399
|
Object.defineProperty(exports, 'ɵobservePhoenixEvent$', {
|
|
18741
18400
|
enumerable: true,
|
|
18742
18401
|
get: function () {
|
|
@@ -18773,6 +18432,54 @@ Object.defineProperty(exports, 'ɵphoenixSocket$', {
|
|
|
18773
18432
|
return _copilotkit_core.ɵphoenixSocket$;
|
|
18774
18433
|
}
|
|
18775
18434
|
});
|
|
18435
|
+
Object.defineProperty(exports, 'ɵpluralize', {
|
|
18436
|
+
enumerable: true,
|
|
18437
|
+
get: function () {
|
|
18438
|
+
return _copilotkit_core.ɵpluralize;
|
|
18439
|
+
}
|
|
18440
|
+
});
|
|
18441
|
+
Object.defineProperty(exports, 'ɵrecordWorkTime', {
|
|
18442
|
+
enumerable: true,
|
|
18443
|
+
get: function () {
|
|
18444
|
+
return _copilotkit_core.ɵrecordWorkTime;
|
|
18445
|
+
}
|
|
18446
|
+
});
|
|
18447
|
+
Object.defineProperty(exports, 'ɵresolveActivityRenderer', {
|
|
18448
|
+
enumerable: true,
|
|
18449
|
+
get: function () {
|
|
18450
|
+
return _copilotkit_core.ɵresolveActivityRenderer;
|
|
18451
|
+
}
|
|
18452
|
+
});
|
|
18453
|
+
Object.defineProperty(exports, 'ɵresolveComposerKey', {
|
|
18454
|
+
enumerable: true,
|
|
18455
|
+
get: function () {
|
|
18456
|
+
return _copilotkit_core.ɵresolveComposerKey;
|
|
18457
|
+
}
|
|
18458
|
+
});
|
|
18459
|
+
Object.defineProperty(exports, 'ɵresolveCustomMessageRenderers', {
|
|
18460
|
+
enumerable: true,
|
|
18461
|
+
get: function () {
|
|
18462
|
+
return _copilotkit_core.ɵresolveCustomMessageRenderers;
|
|
18463
|
+
}
|
|
18464
|
+
});
|
|
18465
|
+
Object.defineProperty(exports, 'ɵresolveLicenseState', {
|
|
18466
|
+
enumerable: true,
|
|
18467
|
+
get: function () {
|
|
18468
|
+
return _copilotkit_core.ɵresolveLicenseState;
|
|
18469
|
+
}
|
|
18470
|
+
});
|
|
18471
|
+
Object.defineProperty(exports, 'ɵresolveThreadsLicense', {
|
|
18472
|
+
enumerable: true,
|
|
18473
|
+
get: function () {
|
|
18474
|
+
return _copilotkit_core.ɵresolveThreadsLicense;
|
|
18475
|
+
}
|
|
18476
|
+
});
|
|
18477
|
+
Object.defineProperty(exports, 'ɵresolveToolCallRenderer', {
|
|
18478
|
+
enumerable: true,
|
|
18479
|
+
get: function () {
|
|
18480
|
+
return _copilotkit_core.ɵresolveToolCallRenderer;
|
|
18481
|
+
}
|
|
18482
|
+
});
|
|
18776
18483
|
Object.defineProperty(exports, 'ɵrunMcpFollowUp', {
|
|
18777
18484
|
enumerable: true,
|
|
18778
18485
|
get: function () {
|
|
@@ -18857,12 +18564,30 @@ Object.defineProperty(exports, 'ɵselectThreadsIsLoading', {
|
|
|
18857
18564
|
return _copilotkit_core.ɵselectThreadsIsLoading;
|
|
18858
18565
|
}
|
|
18859
18566
|
});
|
|
18567
|
+
Object.defineProperty(exports, 'ɵstringifyToolCallPayload', {
|
|
18568
|
+
enumerable: true,
|
|
18569
|
+
get: function () {
|
|
18570
|
+
return _copilotkit_core.ɵstringifyToolCallPayload;
|
|
18571
|
+
}
|
|
18572
|
+
});
|
|
18860
18573
|
Object.defineProperty(exports, 'ɵthreadAdapterEvents', {
|
|
18861
18574
|
enumerable: true,
|
|
18862
18575
|
get: function () {
|
|
18863
18576
|
return _copilotkit_core.ɵthreadAdapterEvents;
|
|
18864
18577
|
}
|
|
18865
18578
|
});
|
|
18579
|
+
Object.defineProperty(exports, 'ɵtranscribeAudio', {
|
|
18580
|
+
enumerable: true,
|
|
18581
|
+
get: function () {
|
|
18582
|
+
return _copilotkit_core.ɵtranscribeAudio;
|
|
18583
|
+
}
|
|
18584
|
+
});
|
|
18585
|
+
Object.defineProperty(exports, 'ɵtranscriptionErrorMessageKey', {
|
|
18586
|
+
enumerable: true,
|
|
18587
|
+
get: function () {
|
|
18588
|
+
return _copilotkit_core.ɵtranscriptionErrorMessageKey;
|
|
18589
|
+
}
|
|
18590
|
+
});
|
|
18866
18591
|
Object.defineProperty(exports, 'ɵwithHeaderDefaults', {
|
|
18867
18592
|
enumerable: true,
|
|
18868
18593
|
get: function () {
|