@copilotkit/react-core 2.0.0-rc.7 → 2.0.0-rc.9

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.
Files changed (47) hide show
  1. package/dist/{MarkdownRendererContext-B4Us6mwL.d.cts → MarkdownRendererContext-CS35epe1.d.mts} +17 -33
  2. package/dist/MarkdownRendererContext-CS35epe1.d.mts.map +1 -0
  3. package/dist/{MarkdownRendererContext-CRKFzsEB.d.mts → MarkdownRendererContext-CfTh92vk.d.cts} +17 -33
  4. package/dist/MarkdownRendererContext-CfTh92vk.d.cts.map +1 -0
  5. package/dist/{MarkdownSurfaces-S4wfUl3J.cjs → MarkdownSurfaces-Ije2ZQh0.cjs} +111 -89
  6. package/dist/MarkdownSurfaces-Ije2ZQh0.cjs.map +1 -0
  7. package/dist/{MarkdownSurfaces-Bd--93O1.mjs → MarkdownSurfaces-iFKorV2w.mjs} +95 -80
  8. package/dist/MarkdownSurfaces-iFKorV2w.mjs.map +1 -0
  9. package/dist/context.cjs +20 -17
  10. package/dist/context.cjs.map +1 -1
  11. package/dist/context.d.cts +38 -98
  12. package/dist/context.d.cts.map +1 -1
  13. package/dist/context.d.mts +38 -98
  14. package/dist/context.d.mts.map +1 -1
  15. package/dist/context.mjs +20 -17
  16. package/dist/context.mjs.map +1 -1
  17. package/dist/generative-ui.cjs +541 -520
  18. package/dist/generative-ui.cjs.map +1 -1
  19. package/dist/generative-ui.d.cts +2137 -4178
  20. package/dist/generative-ui.d.cts.map +1 -1
  21. package/dist/generative-ui.d.mts +2137 -4178
  22. package/dist/generative-ui.d.mts.map +1 -1
  23. package/dist/generative-ui.mjs +37 -17
  24. package/dist/generative-ui.mjs.map +1 -1
  25. package/dist/headless.cjs +50 -76
  26. package/dist/headless.cjs.map +1 -1
  27. package/dist/headless.d.cts +78 -253
  28. package/dist/headless.d.cts.map +1 -1
  29. package/dist/headless.d.mts +56 -202
  30. package/dist/headless.d.mts.map +1 -1
  31. package/dist/headless.mjs +43 -74
  32. package/dist/headless.mjs.map +1 -1
  33. package/dist/index.cjs +765 -1292
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +176 -518
  36. package/dist/index.d.cts.map +1 -1
  37. package/dist/index.d.mts +175 -517
  38. package/dist/index.d.mts.map +1 -1
  39. package/dist/index.mjs +469 -1251
  40. package/dist/index.mjs.map +1 -1
  41. package/dist/index.umd.js +867 -1375
  42. package/dist/index.umd.js.map +1 -1
  43. package/package.json +15 -16
  44. package/dist/MarkdownRendererContext-B4Us6mwL.d.cts.map +0 -1
  45. package/dist/MarkdownRendererContext-CRKFzsEB.d.mts.map +0 -1
  46. package/dist/MarkdownSurfaces-Bd--93O1.mjs.map +0 -1
  47. 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('react/jsx-runtime'), require('@copilotkit/markdown-renderer/react'), require('@copilotkit/markdown-renderer'), require('lucide-react'), require('@copilotkit/shared'), require('@radix-ui/react-slot'), require('@radix-ui/react-tooltip'), require('@radix-ui/react-dropdown-menu'), require('@ag-ui/core'), require('zod'), require('@copilotkit/mcp-apps-renderer/activity'), 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', 'react/jsx-runtime', '@copilotkit/markdown-renderer/react', '@copilotkit/markdown-renderer', 'lucide-react', '@copilotkit/shared', '@radix-ui/react-slot', '@radix-ui/react-tooltip', '@radix-ui/react-dropdown-menu', '@ag-ui/core', 'zod', '@copilotkit/mcp-apps-renderer/activity', '@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.ReactJsxRuntime,global.CopilotKitMarkdownRendererReact,global.CopilotKitMarkdownRenderer,global.lucideReact,global.CopilotKitShared,global.RadixReactSlot,global.RadixReactTooltip,global.RadixReactDropdownMenu,global.AgUICore,global.Zod,global.CopilotKitMcpAppsRendererActivity,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, react_jsx_runtime, _copilotkit_markdown_renderer_react, _copilotkit_markdown_renderer, lucide_react, _copilotkit_shared, _radix_ui_react_slot, _radix_ui_react_tooltip, _radix_ui_react_dropdown_menu, _ag_ui_core, zod, _copilotkit_mcp_apps_renderer_activity, _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) {
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('@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', '@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._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, _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;
@@ -36,113 +36,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
36
36
  react = __toESM(react);
37
37
  _radix_ui_react_tooltip = __toESM(_radix_ui_react_tooltip);
38
38
  _radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
39
+ zod = __toESM(zod);
39
40
  _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
40
41
 
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
42
  //#region src/components/chat/StreamingMarkdownDefaultRenderer.tsx
147
43
  const defaultNodeRenderers = (0, _copilotkit_markdown_renderer_react.createStreamingMarkdownNodeRenderers)({ codeBlock: ({ node }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
148
44
  className: "cpk-markdown-code-block",
@@ -178,11 +74,114 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
178
74
  }
179
75
  StreamingMarkdownDefaultRenderer.displayName = "StreamingMarkdownDefaultRenderer";
180
76
 
77
+ //#endregion
78
+ //#region src/lib/utils.ts
79
+ /**
80
+ * Joins class names, skipping falsy values. Takes the same inputs as `clsx`.
81
+ * Classes are not merged: every rule CopilotKit ships sits in `:where()`, so a
82
+ * class the app adds wins without removing ours.
83
+ */
84
+ function cn(...inputs) {
85
+ const out = [];
86
+ for (const input of inputs) {
87
+ if (!input) continue;
88
+ if (typeof input === "string" || typeof input === "number" || typeof input === "bigint") out.push(String(input));
89
+ else if (Array.isArray(input)) {
90
+ const nested = cn(...input);
91
+ if (nested) out.push(nested);
92
+ } else if (typeof input === "object") {
93
+ for (const key in input) if (input[key]) out.push(key);
94
+ }
95
+ }
96
+ return out.join(" ");
97
+ }
98
+
99
+ //#endregion
100
+ //#region src/components/icons/CopilotIcon.tsx
101
+ /** Turns SVG attribute names such as `stroke-width` into React's `strokeWidth`. */
102
+ function toReactAttributes(attributes) {
103
+ return Object.fromEntries(Object.entries(attributes).map(([key, value]) => [key.replace(/-([a-z])/g, (_match, letter) => letter.toUpperCase()), value]));
104
+ }
105
+ const svgDefaults = toReactAttributes(_copilotkit_core.ɵcopilotIconSvgAttributes);
106
+ /** True when the props give the icon an accessible name or role. */
107
+ function hasAccessibleProp(props) {
108
+ return Object.keys(props).some((key) => key.startsWith("aria-") || key === "role" || key === "title");
109
+ }
110
+ /**
111
+ * Internal. Draws a Lucide icon from its node data, the way Lucide's React package
112
+ * does: Lucide's default SVG attributes, the `lucide lucide-<name>` classes,
113
+ * and `aria-hidden="true"` when no `aria-*`, `role` or `title` prop names it.
114
+ */
115
+ const IconSvg = (0, react.forwardRef)(function IconSvg({ lucideName, nodes, size = 24, color = "currentColor", strokeWidth = 2, className, children, ...props }, ref) {
116
+ const isDecorative = !children && !hasAccessibleProp(props);
117
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
118
+ ref,
119
+ ...svgDefaults,
120
+ width: size,
121
+ height: size,
122
+ stroke: color,
123
+ strokeWidth,
124
+ className: cn("lucide", `lucide-${lucideName}`, className),
125
+ "aria-hidden": isDecorative || void 0,
126
+ ...props,
127
+ children: [nodes.map((node, index) => (0, react.createElement)(node.tag, {
128
+ key: index,
129
+ ...node.attributes
130
+ })), children]
131
+ });
132
+ });
133
+ /**
134
+ * Draws one of the chat icons as an inline `<svg>`.
135
+ *
136
+ * The `<svg>` has the classes `lucide lucide-<icon name>`, so CSS that selects
137
+ * them (for example `svg.lucide-arrow-up`) keeps working. The icon is hidden
138
+ * from screen readers unless you give it an `aria-label`, `role` or `title`.
139
+ *
140
+ * @param props.name - The chat icon, for example `"ArrowUp"` or `"X"`.
141
+ * @param props.size - Width and height. Defaults to `24`.
142
+ * @param props.strokeWidth - Line width. Defaults to `2`.
143
+ * @param props.color - Line color. Defaults to `currentColor`.
144
+ *
145
+ * @example
146
+ * ```tsx
147
+ * <CopilotIcon name="ArrowUp" className="cpk-chat-input-send-icon" />
148
+ * <CopilotIcon name="X" aria-label="Close" />
149
+ * ```
150
+ */
151
+ const CopilotIcon = (0, react.forwardRef)(function CopilotIcon({ name, ...props }, ref) {
152
+ const icon = _copilotkit_core.ɵcopilotIcons[name];
153
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconSvg, {
154
+ ref,
155
+ lucideName: icon.name,
156
+ nodes: icon.nodes,
157
+ ...props
158
+ });
159
+ });
160
+
181
161
  //#endregion
182
162
  //#region src/lib/react-core.ts
163
+ /**
164
+ * Wait for pending React state updates before the follow-up agent run.
165
+ *
166
+ * When a frontend tool handler calls setState(), React 18 batches the update
167
+ * and schedules a commit via its internal scheduler (MessageChannel). The
168
+ * useAgentContext hook registers context via useLayoutEffect, which runs
169
+ * synchronously after React commits that batch.
170
+ *
171
+ * Awaiting a zero-delay timeout yields to the macrotask queue. React's
172
+ * MessageChannel task runs first, committing the pending state and running
173
+ * useLayoutEffect (which updates the context store). The follow-up runAgent
174
+ * call then reads fresh context.
175
+ */
176
+ function waitForReactCommit() {
177
+ return new Promise((resolve) => setTimeout(resolve, 0));
178
+ }
183
179
  var CopilotKitCoreReact = class extends _copilotkit_core.CopilotKitCore {
184
180
  constructor(config) {
185
- super(config);
181
+ super({
182
+ ...config,
183
+ ɵwaitForFrameworkUpdates: waitForReactCommit
184
+ });
186
185
  this._renderToolCalls = [];
187
186
  this._hookRenderToolCalls = /* @__PURE__ */ new Map();
188
187
  this._cachedMergedRenderToolCalls = null;
@@ -256,22 +255,6 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
256
255
  subscribe(subscriber) {
257
256
  return super.subscribe(subscriber);
258
257
  }
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
258
  };
276
259
 
277
260
  //#endregion
@@ -350,52 +333,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
350
333
 
351
334
  //#endregion
352
335
  //#region src/providers/CopilotChatConfigurationProvider.tsx
353
- const CopilotChatDefaultLabels = {
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
- /**
336
+ /**
399
337
  * Mobile breakpoint below which the chat modal and the thread-list drawer are
400
338
  * mutually exclusive. At or above this width both surfaces may coexist. This
401
339
  * mirrors the `(max-width: 767px)` / `(min-width: 768px)` split already used by
@@ -419,7 +357,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
419
357
  const parentConfig = (0, react.useContext)(CopilotChatConfiguration);
420
358
  const stableLabels = useShallowStableRef(labels);
421
359
  const mergedLabels = (0, react.useMemo)(() => ({
422
- ...CopilotChatDefaultLabels,
360
+ ..._copilotkit_core.CopilotChatDefaultLabels,
423
361
  ...parentConfig?.labels,
424
362
  ...stableLabels
425
363
  }), [stableLabels, parentConfig?.labels]);
@@ -651,28 +589,6 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
651
589
  };
652
590
  ControlledModalOpenScope.displayName = "ControlledModalOpenScope";
653
591
 
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
592
  //#endregion
677
593
  //#region src/components/ui/button.tsx
678
594
  const variantClasses = {
@@ -701,8 +617,8 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
701
617
  function buttonVariants({ variant, size, className, class: classProp } = {}) {
702
618
  return cn("cpk-button", variant !== null && variantClasses[variant ?? "default"], size !== null && sizeClasses[size ?? "default"], classProp, className);
703
619
  }
704
- const Button = react.forwardRef(function Button({ className, variant, size, asChild = false, ...props }, ref) {
705
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(asChild ? _radix_ui_react_slot.Slot : "button", {
620
+ const Button = react.forwardRef(function Button({ className, variant, size, ...props }, ref) {
621
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
706
622
  ref,
707
623
  "data-slot": "button",
708
624
  className: buttonVariants({
@@ -807,7 +723,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
807
723
  "data-inset": inset,
808
724
  className: cn("cpk-dropdown-menu-sub-trigger", className),
809
725
  ...props,
810
- children: [children, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRightIcon, { className: "cpk-dropdown-menu-sub-trigger-icon" })]
726
+ children: [children, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
727
+ name: "ChevronRight",
728
+ className: "cpk-dropdown-menu-sub-trigger-icon"
729
+ })]
811
730
  });
812
731
  }
813
732
  function DropdownMenuSubContent({ className, ...props }) {
@@ -1108,7 +1027,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
1108
1027
  const audioRecorderRef = (0, react.useRef)(null);
1109
1028
  const slashMenuRef = (0, react.useRef)(null);
1110
1029
  const config = useCopilotChatConfiguration();
1111
- const labels = config?.labels ?? CopilotChatDefaultLabels;
1030
+ const labels = config?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
1112
1031
  const previousModalStateRef = (0, react.useRef)(void 0);
1113
1032
  const measurementCanvasRef = (0, react.useRef)(null);
1114
1033
  const measurementsRef = (0, react.useRef)({
@@ -1229,6 +1148,14 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
1229
1148
  inputRef.current?.focus();
1230
1149
  });
1231
1150
  }, [clearInputValue]);
1151
+ const composerInput = {
1152
+ mode,
1153
+ isRunning,
1154
+ value: resolvedValue,
1155
+ canSubmit: !!onSubmitMessage,
1156
+ canStop: !!onStop
1157
+ };
1158
+ const { isProcessing, action: buttonAction, disabled: buttonDisabled } = (0, _copilotkit_core.ɵcomposerButtonState)(composerInput);
1232
1159
  const handleKeyDown = (e) => {
1233
1160
  if (e.nativeEvent.isComposing || e.keyCode === 229) return;
1234
1161
  if (commandQuery !== null && mode === "input") {
@@ -1267,11 +1194,15 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
1267
1194
  return;
1268
1195
  }
1269
1196
  }
1270
- if (e.key === "Enter" && !e.shiftKey) {
1271
- e.preventDefault();
1272
- if (isProcessing && !canSend) onStop?.();
1273
- else send();
1274
- }
1197
+ if (e.key === "Enter" && !e.shiftKey) e.preventDefault();
1198
+ const action = (0, _copilotkit_core.ɵresolveComposerKey)({
1199
+ key: e.key,
1200
+ shiftKey: e.shiftKey,
1201
+ isComposing: e.nativeEvent.isComposing,
1202
+ keyCode: e.keyCode
1203
+ }, composerInput);
1204
+ if (action === "stop") onStop?.();
1205
+ else if (action === "send") send();
1275
1206
  };
1276
1207
  const send = () => {
1277
1208
  if (!onSubmitMessage) return;
@@ -1296,9 +1227,6 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
1296
1227
  autoFocus,
1297
1228
  className: isExpanded ? "cpk-chat-input-textarea-expanded" : "cpk-chat-input-textarea-compact"
1298
1229
  });
1299
- const isProcessing = mode !== "transcribe" && isRunning;
1300
- const canSend = resolvedValue.trim().length > 0 && !!onSubmitMessage;
1301
- const canStop = !!onStop;
1302
1230
  const handleSendButtonClick = () => {
1303
1231
  if (isProcessing) {
1304
1232
  onStop?.();
@@ -1307,12 +1235,15 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
1307
1235
  send();
1308
1236
  };
1309
1237
  const BoundAudioRecorder = renderSlot(audioRecorder, CopilotChatAudioRecorder, { ref: audioRecorderRef });
1310
- const showsStop = isProcessing && canStop;
1238
+ const showsStop = buttonAction === "stop";
1311
1239
  const BoundSendButton = renderSlot(sendButton, CopilotChatInput.SendButton, {
1312
1240
  onClick: handleSendButtonClick,
1313
- disabled: isProcessing ? !canStop : !canSend,
1241
+ disabled: buttonDisabled,
1314
1242
  "aria-label": showsStop ? labels.chatInputToolbarStopButtonLabel : labels.chatInputToolbarSendButtonLabel,
1315
- children: showsStop ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Square, { className: "cpk-chat-input-stop-icon" }) : void 0
1243
+ children: showsStop ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
1244
+ name: "Square",
1245
+ className: "cpk-chat-input-stop-icon"
1246
+ }) : void 0
1316
1247
  });
1317
1248
  const BoundStartTranscribeButton = renderSlot(startTranscribeButton, CopilotChatInput.StartTranscribeButton, { onClick: onStartTranscribe });
1318
1249
  const BoundCancelTranscribeButton = renderSlot(cancelTranscribeButton, CopilotChatInput.CancelTranscribeButton, { onClick: onCancelTranscribe });
@@ -1569,7 +1500,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
1569
1500
  className: "cpk-chat-input-field",
1570
1501
  children: mode === "transcribe" ? BoundAudioRecorder : mode === "processing" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1571
1502
  className: "cpk-chat-input-processing",
1572
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Loader2, { className: "cpk-chat-input-processing-spinner" })
1503
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
1504
+ name: "Loader2",
1505
+ className: "cpk-chat-input-processing-spinner"
1506
+ })
1573
1507
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [BoundTextArea, slashMenu] })
1574
1508
  }),
1575
1509
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -1629,7 +1563,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
1629
1563
  }
1630
1564
  (function(_CopilotChatInput) {
1631
1565
  _CopilotChatInput.SendButton = ({ className, children, ...props }) => {
1632
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
1566
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
1633
1567
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1634
1568
  className: "cpk-chat-input-send",
1635
1569
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
@@ -1640,12 +1574,15 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
1640
1574
  className: cn("cpk-chat-input-send-button", className),
1641
1575
  "aria-label": labels.chatInputToolbarSendButtonLabel,
1642
1576
  ...props,
1643
- children: children ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ArrowUp, { className: "cpk-chat-input-send-icon" })
1577
+ children: children ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
1578
+ name: "ArrowUp",
1579
+ className: "cpk-chat-input-send-icon"
1580
+ })
1644
1581
  })
1645
1582
  });
1646
1583
  };
1647
1584
  const ToolbarButton = _CopilotChatInput.ToolbarButton = ({ icon, labelKey, defaultClassName, className, ...props }) => {
1648
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
1585
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
1649
1586
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Tooltip, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipTrigger, {
1650
1587
  asChild: true,
1651
1588
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
@@ -1664,27 +1601,36 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
1664
1601
  };
1665
1602
  _CopilotChatInput.StartTranscribeButton = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
1666
1603
  "data-testid": "copilot-start-transcribe-button",
1667
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Mic, { className: "cpk-chat-input-toolbar-icon" }),
1604
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
1605
+ name: "Mic",
1606
+ className: "cpk-chat-input-toolbar-icon"
1607
+ }),
1668
1608
  labelKey: "chatInputToolbarStartTranscribeButtonLabel",
1669
1609
  defaultClassName: "cpk-chat-input-start-transcribe-button",
1670
1610
  ...props
1671
1611
  });
1672
1612
  _CopilotChatInput.CancelTranscribeButton = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
1673
1613
  "data-testid": "copilot-cancel-transcribe-button",
1674
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, { className: "cpk-chat-input-toolbar-icon" }),
1614
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
1615
+ name: "X",
1616
+ className: "cpk-chat-input-toolbar-icon"
1617
+ }),
1675
1618
  labelKey: "chatInputToolbarCancelTranscribeButtonLabel",
1676
1619
  defaultClassName: "cpk-chat-input-cancel-transcribe-button",
1677
1620
  ...props
1678
1621
  });
1679
1622
  _CopilotChatInput.FinishTranscribeButton = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
1680
1623
  "data-testid": "copilot-finish-transcribe-button",
1681
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, { className: "cpk-chat-input-toolbar-icon" }),
1624
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
1625
+ name: "Check",
1626
+ className: "cpk-chat-input-toolbar-icon"
1627
+ }),
1682
1628
  labelKey: "chatInputToolbarFinishTranscribeButtonLabel",
1683
1629
  defaultClassName: "cpk-chat-input-finish-transcribe-button",
1684
1630
  ...props
1685
1631
  });
1686
1632
  _CopilotChatInput.AddMenuButton = ({ className, toolsMenu, onAddFile, disabled, ...props }) => {
1687
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
1633
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
1688
1634
  const [mounted, setMounted] = (0, react.useState)(false);
1689
1635
  (0, react.useEffect)(() => setMounted(true), []);
1690
1636
  const menuItems = (0, react.useMemo)(() => {
@@ -1726,7 +1672,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
1726
1672
  disabled: isDisabled,
1727
1673
  "aria-label": labels.chatInputToolbarAddButtonLabel,
1728
1674
  ...props,
1729
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Plus, { className: "cpk-chat-input-add-menu-icon" })
1675
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
1676
+ name: "Plus",
1677
+ className: "cpk-chat-input-add-menu-icon"
1678
+ })
1730
1679
  });
1731
1680
  if (!mounted) return button;
1732
1681
  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 +1701,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
1752
1701
  };
1753
1702
  _CopilotChatInput.TextArea = (0, react.forwardRef)(function TextArea({ style, className, autoFocus, placeholder, ...props }, ref) {
1754
1703
  const internalTextareaRef = (0, react.useRef)(null);
1755
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
1704
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
1756
1705
  (0, react.useImperativeHandle)(ref, () => internalTextareaRef.current);
1757
1706
  (0, react.useEffect)(() => {
1758
1707
  if (autoFocus) internalTextareaRef.current?.focus({ preventScroll: true });
@@ -1773,7 +1722,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
1773
1722
  });
1774
1723
  _CopilotChatInput.AudioRecorder = CopilotChatAudioRecorder;
1775
1724
  _CopilotChatInput.Disclaimer = ({ className, ...props }) => {
1776
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
1725
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
1777
1726
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1778
1727
  className: cn("cpk-chat-input-disclaimer", className),
1779
1728
  ...props,
@@ -1886,16 +1835,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
1886
1835
  */
1887
1836
  function useToolCallRendererNames() {
1888
1837
  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]);
1838
+ return (0, react.useMemo)(() => (0, _copilotkit_core.ɵgetToolCallRendererNames)(renderers), [renderers]);
1899
1839
  }
1900
1840
  /**
1901
1841
  * Hook that returns a function to render tool calls based on the render functions
@@ -1910,18 +1850,17 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
1910
1850
  const warnedToolNames = (0, react.useRef)(/* @__PURE__ */ new Set());
1911
1851
  const renderToolCalls = useToolCallRenderers();
1912
1852
  const renderToolCall = (0, react.useCallback)(({ toolCall, toolMessage }) => {
1913
- const exactMatches = renderToolCalls.filter((rc) => rc.name === toolCall.function.name);
1914
- const renderConfig = exactMatches.find((rc) => rc.agentId === agentId) || exactMatches.find((rc) => !rc.agentId) || exactMatches[0] || renderToolCalls.find((rc) => rc.name === "*");
1853
+ const renderConfig = (0, _copilotkit_core.ɵresolveToolCallRenderer)(renderToolCalls, toolCall.function.name, agentId);
1915
1854
  if (!renderConfig) {
1916
1855
  if (IS_DEVELOPMENT$1) unrenderedToolNames.current.add(toolCall.function.name);
1917
1856
  return null;
1918
1857
  }
1919
- const RenderComponent = renderConfig.render;
1858
+ const isExecuting = executingToolCallIds.has(toolCall.id);
1920
1859
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolCallRenderer, {
1921
1860
  toolCall,
1922
1861
  toolMessage,
1923
- RenderComponent,
1924
- isExecuting: executingToolCallIds.has(toolCall.id)
1862
+ RenderComponent: renderConfig.render,
1863
+ isExecuting
1925
1864
  }, toolCall.id);
1926
1865
  }, [
1927
1866
  renderToolCalls,
@@ -1943,7 +1882,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
1943
1882
 
1944
1883
  //#endregion
1945
1884
  //#region package.json
1946
- var version$1 = "2.0.0-rc.7";
1885
+ var version$1 = "2.0.0-rc.9";
1947
1886
 
1948
1887
  //#endregion
1949
1888
  //#region src/components/CopilotKitInspector.tsx
@@ -2014,6 +1953,15 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
2014
1953
 
2015
1954
  //#endregion
2016
1955
  //#region src/components/license-warning-banner.tsx
1956
+ const labels = _copilotkit_core.CopilotChatDefaultLabels;
1957
+ /**
1958
+ * The "expires soon" banner text. Without a day count it says "soon", never
1959
+ * "in undefined days".
1960
+ */
1961
+ function expiringMessage(graceRemaining) {
1962
+ if (graceRemaining === void 0) return labels.licenseExpiringText;
1963
+ return (0, _copilotkit_core.ɵformatLabel)(graceRemaining === 1 ? labels.licenseExpiringInDaysOne : labels.licenseExpiringInDaysOther, { days: graceRemaining });
1964
+ }
2017
1965
  const LICENSE_BANNER_OFFSET_PX = 52;
2018
1966
  const LICENSE_BANNER_OFFSET_VAR = "--copilotkit-license-banner-offset";
2019
1967
  const BANNER_STYLES = {
@@ -2104,36 +2052,36 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
2104
2052
  switch (type) {
2105
2053
  case "no_license": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BannerShell, {
2106
2054
  severity: "info",
2107
- message: "Powered by CopilotKit",
2108
- actionLabel: "Get a license",
2055
+ message: labels.licensePoweredByText,
2056
+ actionLabel: labels.licenseGetLicenseLabel,
2109
2057
  actionUrl: "https://copilotkit.ai/pricing",
2110
2058
  onDismiss
2111
2059
  });
2112
2060
  case "feature_unlicensed": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BannerShell, {
2113
2061
  severity: "warning",
2114
- message: `⚠ The "${featureName}" feature requires a CopilotKit license.`,
2115
- actionLabel: "Get a license",
2062
+ message: (0, _copilotkit_core.ɵformatLabel)(labels.licenseFeatureUnlicensedText, { feature: featureName ?? "" }),
2063
+ actionLabel: labels.licenseGetLicenseLabel,
2116
2064
  actionUrl: "https://copilotkit.ai/pricing",
2117
2065
  onDismiss
2118
2066
  });
2119
2067
  case "expiring": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BannerShell, {
2120
2068
  severity: "warning",
2121
- message: `Your CopilotKit license expires in ${graceRemaining} day${graceRemaining !== 1 ? "s" : ""}. Please renew.`,
2122
- actionLabel: "Renew",
2069
+ message: expiringMessage(graceRemaining),
2070
+ actionLabel: labels.licenseRenewLabel,
2123
2071
  actionUrl: "https://dashboard.operations.copilotkit.ai",
2124
2072
  onDismiss
2125
2073
  });
2126
2074
  case "expired": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BannerShell, {
2127
2075
  severity: "critical",
2128
- message: `Your CopilotKit license expired${expiryDate ? ` on ${expiryDate}` : ""}. Please renew at copilotkit.ai/pricing`,
2129
- actionLabel: "Renew now",
2076
+ message: expiryDate ? (0, _copilotkit_core.ɵformatLabel)(labels.licenseExpiredOnDateText, { date: expiryDate }) : labels.licenseExpiredText,
2077
+ actionLabel: labels.licenseRenewNowLabel,
2130
2078
  actionUrl: "https://copilotkit.ai/pricing",
2131
2079
  onDismiss
2132
2080
  });
2133
2081
  case "invalid": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BannerShell, {
2134
2082
  severity: "critical",
2135
- message: "Invalid CopilotKit license token. Please check your configuration.",
2136
- actionLabel: "Get a license",
2083
+ message: labels.licenseInvalidText,
2084
+ actionLabel: labels.licenseGetLicenseLabel,
2137
2085
  actionUrl: "https://copilotkit.ai/pricing",
2138
2086
  onDismiss
2139
2087
  });
@@ -2152,9 +2100,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
2152
2100
  fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif"
2153
2101
  },
2154
2102
  children: [
2155
- "⚠ The \"",
2156
- featureName,
2157
- "\" feature requires a CopilotKit license.",
2103
+ (0, _copilotkit_core.ɵformatLabel)(labels.licenseFeatureUnlicensedText, { feature: featureName }),
2158
2104
  " ",
2159
2105
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
2160
2106
  href: "https://copilotkit.ai/pricing",
@@ -2326,324 +2272,63 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
2326
2272
  return (0, react.useContext)(SandboxFunctionsContext);
2327
2273
  }
2328
2274
 
2329
- //#endregion
2330
- //#region src/lib/processPartialHtml.ts
2331
- /**
2332
- * Extracts all complete `<style>` blocks from the raw HTML.
2333
- * Returns the concatenated style tags, suitable for injection into `<head>`.
2334
- */
2335
- function extractCompleteStyles(html) {
2336
- const matches = html.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi);
2337
- return matches ? matches.join("") : "";
2338
- }
2339
- /**
2340
- * Processes raw accumulated HTML for safe preview via innerHTML injection.
2341
- * Pure function, no DOM dependencies.
2342
- *
2343
- * Pipeline (order matters):
2344
- * 1. Strip incomplete tag at end
2345
- * 2. Strip complete <style>, <script>, and <head> blocks
2346
- * 3. Strip incomplete <style>/<script>/<head> blocks
2347
- * 4. Strip incomplete HTML entities
2348
- * 5. Extract body content (or use full string if no <body>)
2349
- */
2350
- function processPartialHtml(html) {
2351
- let result = html;
2352
- result = result.replace(/<[^>]*$/, "");
2353
- result = result.replace(/<(style|script|head)\b[^>]*>[\s\S]*?<\/\1>/gi, "");
2354
- result = result.replace(/<(style|script|head)\b[^>]*>[\s\S]*$/gi, "");
2355
- result = result.replace(/&[a-zA-Z0-9#]*$/, "");
2356
- const bodyMatch = result.match(/<body[^>]*>([\s\S]*)/i);
2357
- if (bodyMatch) {
2358
- result = bodyMatch[1];
2359
- result = result.replace(/<\/body>[\s\S]*/i, "");
2360
- }
2361
- return result;
2362
- }
2363
-
2364
2275
  //#endregion
2365
2276
  //#region src/components/OpenGenerativeUIRenderer.tsx
2366
- const OpenGenerativeUIActivityType = "open-generative-ui";
2367
- const OpenGenerativeUIContentSchema = zod.z.object({
2368
- initialHeight: zod.z.number().optional(),
2369
- generating: zod.z.boolean().optional(),
2370
- css: zod.z.string().optional(),
2371
- cssComplete: zod.z.boolean().optional(),
2372
- html: zod.z.array(zod.z.string()).optional(),
2373
- htmlComplete: zod.z.boolean().optional(),
2374
- jsFunctions: zod.z.string().optional(),
2375
- jsFunctionsComplete: zod.z.boolean().optional(),
2376
- jsExpressions: zod.z.array(zod.z.string()).optional(),
2377
- jsExpressionsComplete: zod.z.boolean().optional()
2277
+ const OpenGenerativeUIActivityType = _copilotkit_core.OPEN_GENERATIVE_UI_ACTIVITY_TYPE;
2278
+ const OpenGenerativeUIContentSchema = zod.object({
2279
+ initialHeight: zod.number().optional(),
2280
+ generating: zod.boolean().optional(),
2281
+ css: zod.string().optional(),
2282
+ cssComplete: zod.boolean().optional(),
2283
+ html: zod.array(zod.string()).optional(),
2284
+ htmlComplete: zod.boolean().optional(),
2285
+ jsFunctions: zod.string().optional(),
2286
+ jsFunctionsComplete: zod.boolean().optional(),
2287
+ jsExpressions: zod.array(zod.string()).optional(),
2288
+ jsExpressionsComplete: zod.boolean().optional()
2378
2289
  });
2379
2290
  /**
2380
2291
  * Schema for the generateSandboxedUi tool call arguments.
2381
2292
  * Used by the frontend tool renderer to display placeholder messages.
2382
2293
  */
2383
- const GenerateSandboxedUiArgsSchema = zod.z.object({
2384
- initialHeight: zod.z.number().optional(),
2385
- placeholderMessages: zod.z.array(zod.z.string()).optional(),
2386
- css: zod.z.string().optional(),
2387
- html: zod.z.string().optional(),
2388
- jsFunctions: zod.z.string().optional(),
2389
- jsExpressions: zod.z.array(zod.z.string()).optional()
2294
+ const GenerateSandboxedUiArgsSchema = zod.object({
2295
+ initialHeight: zod.number().optional(),
2296
+ placeholderMessages: zod.array(zod.string()).optional(),
2297
+ css: zod.string().optional(),
2298
+ html: zod.string().optional(),
2299
+ jsFunctions: zod.string().optional(),
2300
+ jsExpressions: zod.array(zod.string()).optional()
2390
2301
  });
2391
- const THROTTLE_MS = 1e3;
2392
- /**
2393
- * Returns true when the inner component should re-render immediately
2394
- * (no throttle delay).
2395
- */
2396
- function shouldFlushImmediately(prev, next) {
2397
- if (next.cssComplete && (!prev || !prev.cssComplete)) return true;
2398
- if (next.htmlComplete) return true;
2399
- if (next.generating === false) return true;
2400
- if (next.jsFunctions && (!prev || !prev.jsFunctions)) return true;
2401
- if ((next.jsExpressions?.length ?? 0) > (prev?.jsExpressions?.length ?? 0)) return true;
2402
- if (next.html?.length && (!prev || !prev.html?.length)) return true;
2403
- return false;
2404
- }
2405
2302
  /**
2406
- * Outer wrapper — absorbs every parent re-render but only forwards
2407
- * throttled content snapshots to the memoized inner component.
2303
+ * Renders an Open Generative UI activity. The core controller throttles the
2304
+ * content and runs the websandbox iframes inside the container div.
2408
2305
  */
2409
2306
  const OpenGenerativeUIActivityRenderer = function OpenGenerativeUIActivityRenderer({ content }) {
2410
- const latestContentRef = (0, react.useRef)(content);
2411
- latestContentRef.current = content;
2412
- const [throttledContent, setThrottledContent] = (0, react.useState)(content);
2413
- const throttledContentRef = (0, react.useRef)(throttledContent);
2414
- const timerRef = (0, react.useRef)(null);
2415
- if (throttledContentRef.current !== content) {
2416
- if (shouldFlushImmediately(throttledContentRef.current, content)) {
2417
- if (timerRef.current !== null) {
2418
- clearTimeout(timerRef.current);
2419
- timerRef.current = null;
2420
- }
2421
- throttledContentRef.current = content;
2422
- setThrottledContent(content);
2423
- }
2424
- }
2425
- const flush = (0, react.useCallback)(() => {
2426
- timerRef.current = null;
2427
- const latest = latestContentRef.current;
2428
- throttledContentRef.current = latest;
2429
- setThrottledContent(latest);
2430
- }, []);
2431
- (0, react.useEffect)(() => {
2432
- if (throttledContentRef.current === content) return;
2433
- if (timerRef.current === null) timerRef.current = setTimeout(flush, THROTTLE_MS);
2434
- }, [content, flush]);
2435
- (0, react.useEffect)(() => {
2436
- return () => {
2437
- if (timerRef.current !== null) clearTimeout(timerRef.current);
2438
- };
2439
- }, []);
2440
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenGenerativeUIActivityRendererInner, { content: throttledContent });
2441
- };
2442
- function ensureHead(html) {
2443
- if (/<head[\s>]/i.test(html)) return html;
2444
- return `<head></head>${html}`;
2445
- }
2446
- function injectCssIntoHtml(html, css) {
2447
- const headCloseIdx = html.indexOf("</head>");
2448
- if (headCloseIdx !== -1) return html.slice(0, headCloseIdx) + `<style>${css}</style>` + html.slice(headCloseIdx);
2449
- return `<head><style>${css}</style></head>${html}`;
2450
- }
2451
- const OpenGenerativeUIActivityRendererInner = react.default.memo(function OpenGenerativeUIActivityRendererInner({ content }) {
2452
- const initialHeight = content.initialHeight ?? 200;
2453
- const [autoHeight, setAutoHeight] = (0, react.useState)(null);
2307
+ const [controller] = (0, react.useState)(() => {
2308
+ const created = new _copilotkit_core.ɵOpenGenerativeUIController();
2309
+ created.setContent(content);
2310
+ return created;
2311
+ });
2454
2312
  const sandboxFunctions = useSandboxFunctions();
2455
- const localApi = (0, react.useMemo)(() => {
2456
- const api = {};
2457
- for (const fn of sandboxFunctions) api[fn.name] = fn.handler;
2458
- return api;
2459
- }, [sandboxFunctions]);
2460
- const fullHtml = content.htmlComplete && content.html?.length ? content.html.join("") : void 0;
2461
- const css = content.cssComplete ? content.css : void 0;
2462
- const cssReady = !!content.cssComplete;
2463
- const partialHtml = !content.htmlComplete && content.html?.length ? content.html.join("") : void 0;
2464
- const previewBody = partialHtml ? processPartialHtml(partialHtml) : void 0;
2465
- const previewStyles = partialHtml ? extractCompleteStyles(partialHtml) : "";
2466
- const hasPreview = cssReady && !!previewBody?.trim();
2467
- const hasVisibleSandbox = !!fullHtml || hasPreview;
2468
2313
  const containerRef = (0, react.useRef)(null);
2469
- const sandboxRef = (0, react.useRef)(null);
2470
- const previewSandboxRef = (0, react.useRef)(null);
2471
- const previewReadyRef = (0, react.useRef)(false);
2472
- const sandboxReadyRef = (0, react.useRef)(false);
2473
- const executedIndexRef = (0, react.useRef)(0);
2474
- const pendingQueueRef = (0, react.useRef)([]);
2475
- const jsFunctionsInjectedRef = (0, react.useRef)(false);
2476
- (0, react.useEffect)(() => {
2477
- const container = containerRef.current;
2478
- if (!container || fullHtml || !hasPreview || previewSandboxRef.current) return;
2479
- let cancelled = false;
2480
- import("@jetbrains/websandbox").then((mod) => {
2481
- if (cancelled) return;
2482
- const sandbox = (mod.default?.default ?? mod.default).create({}, {
2483
- frameContainer: container,
2484
- frameContent: "<head></head><body></body>",
2485
- allowAdditionalAttributes: ""
2486
- });
2487
- previewSandboxRef.current = sandbox;
2488
- sandbox.iframe.style.width = "100%";
2489
- sandbox.iframe.style.height = "100%";
2490
- sandbox.iframe.style.border = "none";
2491
- sandbox.iframe.style.backgroundColor = "transparent";
2492
- sandbox.promise.then(() => {
2493
- if (cancelled) return;
2494
- previewReadyRef.current = true;
2495
- sandbox.run(`
2496
- var s = document.createElement('style');
2497
- s.textContent = 'html, body { overflow: hidden !important; }';
2498
- document.head.appendChild(s);
2499
- `);
2500
- const headParts = [];
2501
- if (css) headParts.push(`<style>${css}</style>`);
2502
- if (previewStyles) headParts.push(previewStyles);
2503
- if (headParts.length) sandbox.run(`document.head.innerHTML = ${JSON.stringify(headParts.join(""))}`);
2504
- if (previewBody) sandbox.run(`document.body.innerHTML = ${JSON.stringify(previewBody)}`);
2505
- });
2506
- }).catch((err) => {
2507
- console.error("[OpenGenerativeUI] Failed to load sandbox module:", err);
2508
- });
2509
- return () => {
2510
- cancelled = true;
2511
- };
2512
- }, [hasPreview, fullHtml]);
2513
- (0, react.useEffect)(() => {
2514
- if (!previewSandboxRef.current || !previewReadyRef.current) return;
2515
- const headParts = [];
2516
- if (css) headParts.push(`<style>${css}</style>`);
2517
- if (previewStyles) headParts.push(previewStyles);
2518
- if (headParts.length) previewSandboxRef.current.run(`document.head.innerHTML = ${JSON.stringify(headParts.join(""))}`);
2519
- if (!previewBody) return;
2520
- previewSandboxRef.current.run(`document.body.innerHTML = ${JSON.stringify(previewBody)}`);
2521
- }, [
2522
- previewBody,
2523
- previewStyles,
2524
- css
2525
- ]);
2526
- (0, react.useEffect)(() => {
2527
- const container = containerRef.current;
2528
- if (!container || !fullHtml) return;
2529
- if (previewSandboxRef.current) {
2530
- previewSandboxRef.current.destroy();
2531
- previewSandboxRef.current = null;
2532
- previewReadyRef.current = false;
2533
- }
2534
- let cancelled = false;
2535
- executedIndexRef.current = 0;
2536
- jsFunctionsInjectedRef.current = false;
2537
- sandboxReadyRef.current = false;
2538
- pendingQueueRef.current = [];
2539
- const htmlContent = css ? injectCssIntoHtml(fullHtml, css) : fullHtml;
2540
- import("@jetbrains/websandbox").then((mod) => {
2541
- if (cancelled) return;
2542
- const sandbox = (mod.default?.default ?? mod.default).create(localApi, {
2543
- frameContainer: container,
2544
- frameContent: ensureHead(htmlContent),
2545
- allowAdditionalAttributes: ""
2546
- });
2547
- sandboxRef.current = sandbox;
2548
- sandbox.iframe.style.width = "100%";
2549
- sandbox.iframe.style.height = "100%";
2550
- sandbox.iframe.style.border = "none";
2551
- sandbox.iframe.style.backgroundColor = "transparent";
2552
- sandbox.promise.then(() => {
2553
- if (cancelled) return;
2554
- sandboxReadyRef.current = true;
2555
- sandbox.run(`
2556
- var s = document.createElement('style');
2557
- s.textContent = 'html, body { overflow: hidden !important; }';
2558
- document.head.appendChild(s);
2559
- `);
2560
- const queue = pendingQueueRef.current;
2561
- pendingQueueRef.current = [];
2562
- for (const code of queue) sandbox.run(code);
2563
- });
2564
- }).catch((err) => {
2565
- console.error("[OpenGenerativeUI] Failed to load sandbox module:", err);
2566
- });
2567
- return () => {
2568
- cancelled = true;
2569
- if (previewSandboxRef.current) {
2570
- previewSandboxRef.current.destroy();
2571
- previewSandboxRef.current = null;
2572
- previewReadyRef.current = false;
2573
- }
2574
- if (sandboxRef.current) {
2575
- sandboxRef.current.destroy();
2576
- sandboxRef.current = null;
2577
- }
2578
- sandboxReadyRef.current = false;
2579
- setAutoHeight(null);
2580
- };
2581
- }, [
2582
- fullHtml,
2583
- css,
2584
- localApi
2585
- ]);
2314
+ const state = (0, react.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
2586
2315
  (0, react.useEffect)(() => {
2587
- if (!content.jsFunctions || jsFunctionsInjectedRef.current) return;
2588
- jsFunctionsInjectedRef.current = true;
2589
- const sandbox = sandboxRef.current;
2590
- if (sandboxReadyRef.current && sandbox) sandbox.run(content.jsFunctions);
2591
- else pendingQueueRef.current.push(content.jsFunctions);
2592
- }, [content.jsFunctions]);
2316
+ controller.setSandboxFunctions(sandboxFunctions);
2317
+ }, [controller, sandboxFunctions]);
2593
2318
  (0, react.useEffect)(() => {
2594
- const expressions = content.jsExpressions;
2595
- if (!expressions || expressions.length === 0) return;
2596
- const startIndex = executedIndexRef.current;
2597
- if (startIndex >= expressions.length) return;
2598
- const newExprs = expressions.slice(startIndex);
2599
- executedIndexRef.current = expressions.length;
2600
- const sandbox = sandboxRef.current;
2601
- if (sandboxReadyRef.current && sandbox) (async () => {
2602
- for (const expr of newExprs) await sandbox.run(expr);
2603
- })();
2604
- else pendingQueueRef.current.push(...newExprs);
2605
- }, [content.jsExpressions?.length]);
2606
- const generationDone = content.generating === false;
2319
+ controller.setContent(content);
2320
+ }, [controller, content]);
2607
2321
  (0, react.useEffect)(() => {
2608
- const sandbox = sandboxRef.current;
2609
- if (!generationDone || !sandbox) return;
2610
- let handled = false;
2611
- const onMessage = (e) => {
2612
- if (handled) return;
2613
- if (e.source === sandbox.iframe.contentWindow && e.data?.type === "__ck_resize") {
2614
- handled = true;
2615
- setAutoHeight(e.data.height);
2616
- window.removeEventListener("message", onMessage);
2617
- }
2618
- };
2619
- window.addEventListener("message", onMessage);
2620
- const measureOnce = `
2621
- (function() {
2622
- var s = document.createElement('style');
2623
- s.textContent = 'body { height: auto !important; min-height: 0 !important; }';
2624
- document.head.appendChild(s);
2625
- var h = document.body.scrollHeight;
2626
- var cs = getComputedStyle(document.body);
2627
- h += parseFloat(cs.marginTop) || 0;
2628
- h += parseFloat(cs.marginBottom) || 0;
2629
- s.remove();
2630
- parent.postMessage({ type: "__ck_resize", height: Math.ceil(h) }, "*");
2631
- })();
2632
- `;
2633
- if (sandboxReadyRef.current) sandbox.run(measureOnce);
2634
- else pendingQueueRef.current.push(measureOnce);
2635
- return () => {
2636
- window.removeEventListener("message", onMessage);
2637
- };
2638
- }, [generationDone]);
2639
- const height = autoHeight ?? initialHeight;
2640
- const isGenerating = content.generating !== false;
2322
+ controller.setHost(containerRef.current);
2323
+ return () => controller.destroy();
2324
+ }, [controller]);
2325
+ const hasVisibleSandbox = state.phase !== "placeholder";
2641
2326
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2642
2327
  ref: containerRef,
2643
2328
  style: {
2644
2329
  position: "relative",
2645
2330
  width: "100%",
2646
- height: `${height}px`,
2331
+ height: `${state.height}px`,
2647
2332
  borderRadius: "8px",
2648
2333
  backgroundColor: hasVisibleSandbox ? "transparent" : "#f5f5f5",
2649
2334
  border: hasVisibleSandbox ? "none" : "1px solid #e0e0e0",
@@ -2652,7 +2337,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
2652
2337
  justifyContent: hasVisibleSandbox ? void 0 : "center",
2653
2338
  overflow: "hidden"
2654
2339
  },
2655
- children: isGenerating && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2340
+ children: state.generating && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2656
2341
  style: {
2657
2342
  position: "absolute",
2658
2343
  inset: 0,
@@ -2684,7 +2369,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
2684
2369
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: `@keyframes ck-spin { to { transform: rotate(360deg) } }` })]
2685
2370
  })
2686
2371
  });
2687
- }, (prev, next) => prev.content === next.content);
2372
+ };
2688
2373
  /**
2689
2374
  * Frontend tool renderer for generateSandboxedUi.
2690
2375
  * Displays placeholder messages while the UI is being generated.
@@ -2721,22 +2406,22 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
2721
2406
  //#region src/a2ui/A2UIRecoveryStates.tsx
2722
2407
  /**
2723
2408
  * The pre-paint lifecycle fields the middleware stamps onto the `a2ui-surface`
2724
- * activity content (alongside `a2ui_operations` on paint). `.passthrough()` keeps
2409
+ * activity content (alongside `a2ui_operations` on paint). `.loose()` keeps
2725
2410
  * `a2ui_operations` and any future fields intact.
2726
2411
  */
2727
2412
  const A2UILifecycleFields = {
2728
- status: zod.z.enum([
2413
+ status: zod.enum([
2729
2414
  "building",
2730
2415
  "retrying",
2731
2416
  "failed"
2732
2417
  ]).optional(),
2733
- attempt: zod.z.number().optional(),
2734
- maxAttempts: zod.z.number().optional(),
2735
- progressTokens: zod.z.number().optional(),
2736
- error: zod.z.string().optional(),
2737
- errors: zod.z.array(zod.z.any()).optional(),
2738
- attempts: zod.z.array(zod.z.any()).optional(),
2739
- debugExposure: zod.z.enum([
2418
+ attempt: zod.number().optional(),
2419
+ maxAttempts: zod.number().optional(),
2420
+ progressTokens: zod.number().optional(),
2421
+ error: zod.string().optional(),
2422
+ errors: zod.array(zod.any()).optional(),
2423
+ attempts: zod.array(zod.any()).optional(),
2424
+ debugExposure: zod.enum([
2740
2425
  "hidden",
2741
2426
  "collapsed",
2742
2427
  "verbose"
@@ -3127,12 +2812,12 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
3127
2812
  * stable messageId (OSS-162): pre-paint `status` ("building" | "retrying" |
3128
2813
  * "failed") with recovery detail, then `a2ui_operations` on paint. The states
3129
2814
  * swap in place, so the painted surface replaces the skeleton with no extra
3130
- * coordination. `.passthrough()` preserves operations + any future fields.
2815
+ * coordination. `.loose()` preserves operations + any future fields.
3131
2816
  */
3132
- const A2UISurfaceContentSchema = zod.z.object({
3133
- a2ui_operations: zod.z.array(zod.z.any()).optional(),
2817
+ const A2UISurfaceContentSchema = zod.object({
2818
+ a2ui_operations: zod.array(zod.any()).optional(),
3134
2819
  ...A2UILifecycleFields
3135
- }).passthrough();
2820
+ }).loose();
3136
2821
  const IS_DEVELOPMENT = process.env.NODE_ENV !== "production";
3137
2822
  /**
3138
2823
  * How long to wait for a surface to report its first paint before giving up on
@@ -3481,7 +3166,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
3481
3166
  //#endregion
3482
3167
  //#region src/types/defineToolCallRenderer.ts
3483
3168
  function defineToolCallRenderer(def) {
3484
- const argsSchema = def.name === "*" && !def.args ? zod.z.any() : def.args;
3169
+ const argsSchema = def.name === "*" && !def.args ? _copilotkit_shared.ɵanySchema : def.args;
3485
3170
  return {
3486
3171
  name: def.name,
3487
3172
  args: argsSchema,
@@ -3516,7 +3201,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
3516
3201
  (0, react.useEffect)(() => {
3517
3202
  const renderer = defineToolCallRenderer({
3518
3203
  name: RENDER_A2UI_TOOL_NAME,
3519
- args: zod.z.any(),
3204
+ args: zod.any(),
3520
3205
  render: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, {})
3521
3206
  });
3522
3207
  const existing = copilotkit._renderToolCalls ?? [];
@@ -3687,12 +3372,11 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
3687
3372
  //#endregion
3688
3373
  //#region src/generative-ui/json-schema.ts
3689
3374
  /**
3690
- * JSON Schema for a Standard Schema (zod v3 via zod-to-json-schema),
3691
- * inlined, no `$schema`. A prop marked by `child()` or `childList()`
3375
+ * JSON Schema for a Standard Schema, without `$schema`. A prop marked by `child()` or `childList()`
3692
3376
  * becomes an A2UI `$ref` to `ComponentId` or `ChildList`.
3693
3377
  */
3694
3378
  function toJsonSchema(schema) {
3695
- const { $schema: _omit, ...rest } = (0, _copilotkit_shared.schemaToJsonSchema)(schema, { zodToJsonSchema: (s) => (0, zod_to_json_schema.zodToJsonSchema)(s, { $refStrategy: "none" }) });
3379
+ const { $schema: _omit, ...rest } = (0, _copilotkit_shared.schemaToJsonSchema)(schema);
3696
3380
  return (0, _copilotkit_shared.applyChildRefMarks)(rest);
3697
3381
  }
3698
3382
 
@@ -5965,7 +5649,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
5965
5649
  this.getState = () => this.state;
5966
5650
  this.webCoreCatalog = new _a2ui_web_core_v0_9.Catalog(ui.id, [...ui.components.keys()].map((name) => ({
5967
5651
  name,
5968
- schema: zod.z.any()
5652
+ schema: zod.any()
5969
5653
  })), []);
5970
5654
  }
5971
5655
  notify() {
@@ -7954,21 +7638,21 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
7954
7638
  })]
7955
7639
  });
7956
7640
  }
7957
- const ContentSchema = zod.z.object({
7958
- surfaceId: zod.z.string(),
7959
- target: zod.z.string(),
7960
- catalogId: zod.z.string(),
7961
- operations: zod.z.array(zod.z.any()),
7962
- status: zod.z.enum([
7641
+ const ContentSchema = zod.object({
7642
+ surfaceId: zod.string(),
7643
+ target: zod.string(),
7644
+ catalogId: zod.string(),
7645
+ operations: zod.array(zod.any()),
7646
+ status: zod.enum([
7963
7647
  "streaming",
7964
7648
  "ready",
7965
7649
  "error"
7966
7650
  ]),
7967
- rejected: zod.z.array(zod.z.object({
7968
- index: zod.z.number(),
7969
- reason: zod.z.string()
7651
+ rejected: zod.array(zod.object({
7652
+ index: zod.number(),
7653
+ reason: zod.string()
7970
7654
  })).default([])
7971
- }).passthrough();
7655
+ }).loose();
7972
7656
  function GenerativeUIChatActivity({ content, agent }) {
7973
7657
  const runtime = useGenerativeUIRuntime();
7974
7658
  const threadId = useCopilotChatConfiguration()?.threadId ?? agent?.threadId;
@@ -8010,7 +7694,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
8010
7694
  function createGenerativeUIFunctionCallActivityRenderer() {
8011
7695
  return {
8012
7696
  activityType: _copilotkit_shared.GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE,
8013
- content: zod.z.unknown(),
7697
+ content: zod.unknown(),
8014
7698
  render: () => null
8015
7699
  };
8016
7700
  }
@@ -8020,7 +7704,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
8020
7704
  (0, react.useEffect)(() => {
8021
7705
  const renderer = defineToolCallRenderer({
8022
7706
  name: _copilotkit_shared.GENERATIVE_UI_RENDER_TOOL,
8023
- args: zod.z.any(),
7707
+ args: zod.any(),
8024
7708
  render: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, {})
8025
7709
  });
8026
7710
  const existing = copilotkit._renderToolCalls ?? [];
@@ -8068,10 +7752,6 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
8068
7752
 
8069
7753
  //#endregion
8070
7754
  //#region src/providers/CopilotKitProvider.tsx
8071
- const zodToJsonSchemaAdapter = (schema, options) => {
8072
- const refStrategy = options?.$refStrategy;
8073
- return (0, zod_to_json_schema.zodToJsonSchema)(schema, refStrategy === "root" || refStrategy === "relative" || refStrategy === "none" || refStrategy === "seen" ? { $refStrategy: refStrategy } : {});
8074
- };
8075
7755
  const HEADER_NAME = "X-CopilotCloud-Public-Api-Key";
8076
7756
  const COPILOT_CLOUD_CHAT_URL = "https://api.cloud.copilotkit.ai/copilotkit/v1";
8077
7757
  const EMPTY_HEADERS = Object.freeze({});
@@ -8080,16 +7760,6 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
8080
7760
  /** Registration name of a catch-all tool: handles any otherwise-unhandled call. */
8081
7761
  const WILDCARD_TOOL_NAME$1 = "*";
8082
7762
  const HUMAN_IN_THE_LOOP_ABORTED_MESSAGE = "Human-in-the-loop interaction aborted";
8083
- const DEFAULT_DESIGN_SKILL = `When generating UI with generateSandboxedUi, follow these design principles inspired by shadcn/ui:
8084
-
8085
- - Use a minimal, flat aesthetic. Avoid drop shadows and gradients — rely on subtle borders (1px solid, light gray like #e5e7eb) to define surfaces.
8086
- - Neutral base palette: white backgrounds, zinc/slate gray text (#09090b for headings, #71717a for secondary text). One accent color for interactive elements.
8087
- - Use system font stacks (system-ui, -apple-system, sans-serif) at readable sizes (14px body, 600 weight for headings). Tight line-heights.
8088
- - Small, consistent border-radius (6–8px). Cards and containers use border, not shadow, for separation.
8089
- - Buttons: solid fill for primary (dark bg, white text), outline for secondary (border + transparent bg). Subtle hover state (slight opacity or background shift).
8090
- - Use CSS Grid or Flexbox for layout. Ensure the UI looks good at any width.
8091
- - Minimal transitions (150ms) for hover/focus states only. No decorative animations.
8092
- - Keep the UI focused and dense — avoid excessive padding. Use compact spacing (8–12px gaps, 10–14px padding in controls).`;
8093
7763
  /** The MCP Apps renderer with `mcpApps.allowSameOriginFallback` applied. */
8094
7764
  const SameOriginMCPAppsActivityRenderer = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MCPAppsActivityRenderer, {
8095
7765
  ...props,
@@ -8300,7 +7970,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
8300
7970
  const builtInFrontendTools = (0, react.useMemo)(() => {
8301
7971
  if (!openGenUIActive) return [];
8302
7972
  return [{
8303
- name: "generateSandboxedUi",
7973
+ name: _copilotkit_core.GENERATE_SANDBOXED_UI_TOOL_NAME,
8304
7974
  description: _copilotkit_shared.GENERATE_SANDBOXED_UI_DESCRIPTION,
8305
7975
  parameters: GenerateSandboxedUiArgsSchema,
8306
7976
  handler: async () => "UI generated",
@@ -8324,7 +7994,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
8324
7994
  const combined = [...renderToolCallsList];
8325
7995
  [...frontendToolsList, ...builtInFrontendTools].forEach((tool) => {
8326
7996
  if (tool.render) {
8327
- const args = tool.parameters || (tool.name === "*" ? zod.z.any() : void 0);
7997
+ const args = tool.parameters || (tool.name === "*" ? _copilotkit_shared.ɵanySchema : void 0);
8328
7998
  if (args) combined.push({
8329
7999
  name: tool.name,
8330
8000
  args,
@@ -8525,7 +8195,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
8525
8195
  (0, react.useEffect)(() => {
8526
8196
  copilotkit.setDefaultThrottleMs(defaultThrottleMs);
8527
8197
  }, [copilotkit, defaultThrottleMs]);
8528
- const designSkill = openGenerativeUI?.designSkill ?? DEFAULT_DESIGN_SKILL;
8198
+ const designSkill = openGenerativeUI?.designSkill ?? _copilotkit_core.DEFAULT_OPEN_GENERATIVE_UI_DESIGN_SKILL;
8529
8199
  (0, react.useLayoutEffect)(() => {
8530
8200
  if (!copilotkit || !openGenUIActive) return;
8531
8201
  const id = copilotkit.addContext({
@@ -8545,7 +8215,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
8545
8215
  return JSON.stringify(sandboxFunctionsList.map((fn) => ({
8546
8216
  name: fn.name,
8547
8217
  description: fn.description,
8548
- parameters: (0, _copilotkit_shared.schemaToJsonSchema)(fn.parameters, { zodToJsonSchema: zodToJsonSchemaAdapter })
8218
+ parameters: (0, _copilotkit_shared.schemaToJsonSchema)(fn.parameters)
8549
8219
  })));
8550
8220
  }, [sandboxFunctionsList]);
8551
8221
  (0, react.useLayoutEffect)(() => {
@@ -8571,26 +8241,17 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
8571
8241
  executingToolCallIds,
8572
8242
  showIntelligenceIndicator
8573
8243
  ]);
8574
- const retryableRuntimeEntitlementFailure = runtimeEntitlements?.status !== "ready" && runtimeEntitlements?.error.retryable === true;
8575
- const hasNonReadyRuntimeEntitlement = runtimeEntitlements !== void 0 && runtimeEntitlements.status !== "ready";
8576
- const hasLegacyRuntimeEntitlementFallback = runtimeLicenseStatus === "valid" || runtimeLicenseStatus === "expiring";
8577
- const runtimeEntitlementRetryInProgress = retryableRuntimeEntitlementFailure && runtimeEntitlementRetryPending && !hasLegacyRuntimeEntitlementFallback;
8578
- const terminalRuntimeEntitlementFailure = hasNonReadyRuntimeEntitlement && !retryableRuntimeEntitlementFailure && !hasLegacyRuntimeEntitlementFallback;
8579
- const licenseContextValue = (0, react.useMemo)(() => {
8580
- const runtimeLicenseContext = (0, _copilotkit_shared.createLicenseContextValue)(runtimeEntitlementRetryInProgress ? void 0 : runtimeLicenseStatus, runtimeEntitlements);
8581
- if (!terminalRuntimeEntitlementFailure) return runtimeLicenseContext;
8582
- return {
8583
- ...runtimeLicenseContext,
8584
- checkFeature: () => false,
8585
- getLimit: () => null
8586
- };
8587
- }, [
8588
- terminalRuntimeEntitlementFailure,
8589
- runtimeEntitlementRetryInProgress,
8244
+ const licenseState = (0, react.useMemo)(() => (0, _copilotkit_core.ɵresolveLicenseState)({
8245
+ status: runtimeLicenseStatus,
8246
+ entitlements: runtimeEntitlements,
8247
+ retryPending: runtimeEntitlementRetryPending,
8248
+ publicKey: resolvedPublicKey
8249
+ }), [
8250
+ runtimeLicenseStatus,
8590
8251
  runtimeEntitlements,
8591
- runtimeLicenseStatus
8252
+ runtimeEntitlementRetryPending,
8253
+ resolvedPublicKey
8592
8254
  ]);
8593
- const runtimeLicenseWarningStatus = runtimeEntitlementRetryInProgress ? void 0 : licenseContextValue.status ?? void 0;
8594
8255
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotStyleOptionsProvider, {
8595
8256
  value: (0, react.useMemo)(() => ({
8596
8257
  nonce,
@@ -8601,7 +8262,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
8601
8262
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitContext.Provider, {
8602
8263
  value: contextValue,
8603
8264
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(LicenseContext.Provider, {
8604
- value: licenseContextValue,
8265
+ value: licenseState.context,
8605
8266
  children: [
8606
8267
  a2uiActive && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(A2UIBuiltInToolCallRenderer, {}),
8607
8268
  generativeUIActive && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GenerativeUIToolCallRenderer, {}),
@@ -8626,10 +8287,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
8626
8287
  }) : null]
8627
8288
  })
8628
8289
  }),
8629
- runtimeLicenseWarningStatus === "none" && !resolvedPublicKey && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "no_license" }),
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" })
8290
+ licenseState.bannerType && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: licenseState.bannerType })
8633
8291
  ]
8634
8292
  })
8635
8293
  })
@@ -8644,11 +8302,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
8644
8302
  const config = useCopilotChatConfiguration();
8645
8303
  if (!config) return null;
8646
8304
  const { agentId, threadId } = config;
8647
- const customMessageRenderers = copilotkit.renderCustomMessages.filter((renderer) => renderer.agentId === void 0 || renderer.agentId === agentId).sort((a, b) => {
8648
- const aHasAgent = a.agentId !== void 0;
8649
- if (aHasAgent === (b.agentId !== void 0)) return 0;
8650
- return aHasAgent ? -1 : 1;
8651
- });
8305
+ const customMessageRenderers = (0, _copilotkit_core.ɵresolveCustomMessageRenderers)(copilotkit.renderCustomMessages, agentId);
8652
8306
  if (!customMessageRenderers.length) return null;
8653
8307
  return function(params) {
8654
8308
  const { message, position } = params;
@@ -8684,6 +8338,18 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
8684
8338
 
8685
8339
  //#endregion
8686
8340
  //#region src/hooks/use-render-activity-message.tsx
8341
+ /**
8342
+ * Explain why an activity message that has a renderer drew nothing: its
8343
+ * content validates asynchronously, or it fails the renderer's schema.
8344
+ */
8345
+ function warnAboutRejectedContent(renderer, message) {
8346
+ const result = renderer.content["~standard"].validate(message.content);
8347
+ if (result instanceof Promise) {
8348
+ console.warn(`Async content validation is not supported for activity message '${message.activityType}'`);
8349
+ return;
8350
+ }
8351
+ if (result.issues) console.warn(`Failed to parse content for activity message '${message.activityType}':`, result.issues);
8352
+ }
8687
8353
  function useRenderActivityMessage() {
8688
8354
  const { copilotkit } = useCopilotKit();
8689
8355
  const agentId = useCopilotChatConfiguration()?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
@@ -8694,29 +8360,29 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
8694
8360
  return matches.find((candidate) => candidate.agentId === agentId) ?? matches.find((candidate) => candidate.agentId === void 0) ?? renderers.find((candidate) => candidate.activityType === "*") ?? null;
8695
8361
  }, [agentId, renderers]);
8696
8362
  const renderActivityMessage = (0, react.useCallback)((message) => {
8697
- const renderer = findRenderer(message.activityType);
8698
- if (!renderer) return null;
8699
- const parseResult = renderer.content["~standard"].validate(message.content);
8700
- if (parseResult instanceof Promise) {
8701
- console.warn(`Async content validation is not supported for activity message '${message.activityType}'`);
8702
- return null;
8703
- }
8704
- if (parseResult.issues) {
8705
- console.warn(`Failed to parse content for activity message '${message.activityType}':`, parseResult.issues);
8363
+ const match = (0, _copilotkit_core.ɵresolveActivityRenderer)(renderers, {
8364
+ activityType: message.activityType,
8365
+ agentId,
8366
+ content: message.content
8367
+ });
8368
+ if (!match) {
8369
+ const renderer = findRenderer(message.activityType);
8370
+ if (renderer) warnAboutRejectedContent(renderer, message);
8706
8371
  return null;
8707
8372
  }
8708
- const Component = renderer.render;
8373
+ const Component = match.renderer.render;
8709
8374
  const agent = copilotkit.getAgent(agentId);
8710
8375
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
8711
8376
  activityType: message.activityType,
8712
- content: parseResult.value,
8377
+ content: match.content,
8713
8378
  message,
8714
8379
  agent
8715
8380
  }, message.id);
8716
8381
  }, [
8717
8382
  agentId,
8718
8383
  copilotkit,
8719
- findRenderer
8384
+ findRenderer,
8385
+ renderers
8720
8386
  ]);
8721
8387
  return (0, react.useMemo)(() => ({
8722
8388
  renderActivityMessage,
@@ -8801,6 +8467,30 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
8801
8467
 
8802
8468
  //#endregion
8803
8469
  //#region src/hooks/use-frontend-tool.tsx
8470
+ /**
8471
+ * Register a frontend tool while the component is mounted. The agent can
8472
+ * call it, and its `render` component draws the call in the chat.
8473
+ *
8474
+ * A tool with the same name and agentId as a tool that is already registered
8475
+ * (for example one from the provider's `tools`) overrides it while this
8476
+ * component is mounted. When the component unmounts, the overridden tool is
8477
+ * active again. The renderer stays registered after unmount, so past tool
8478
+ * calls still render in the chat history.
8479
+ *
8480
+ * @param tool - The tool to register.
8481
+ * @param deps - Extra values that re-register the tool when they change. Use
8482
+ * it when the handler closes over a value that is not part of the tool.
8483
+ *
8484
+ * @example
8485
+ * ```tsx
8486
+ * useFrontendTool({
8487
+ * name: "showWeather",
8488
+ * description: "Show the weather for a city",
8489
+ * parameters: z.object({ city: z.string() }),
8490
+ * handler: async ({ city }) => `Sunny in ${city}`,
8491
+ * });
8492
+ * ```
8493
+ */
8804
8494
  function useFrontendTool(tool, deps) {
8805
8495
  const { copilotkit } = useCopilotKit();
8806
8496
  const depsVersion = useDepsVersion(deps);
@@ -8809,11 +8499,8 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
8809
8499
  if (copilotkit.getTool({
8810
8500
  toolName: name,
8811
8501
  agentId: tool.agentId
8812
- })) {
8813
- console.warn(`Tool '${name}' already exists for agent '${tool.agentId || "global"}'. Overriding with latest registration.`);
8814
- copilotkit.removeTool(name, tool.agentId);
8815
- }
8816
- copilotkit.addTool(tool);
8502
+ })) console.warn(`Tool '${name}' already exists for agent '${tool.agentId || "global"}'. Overriding with latest registration.`);
8503
+ const unregister = copilotkit.addTool(tool);
8817
8504
  if (tool.render) copilotkit.addHookRenderToolCall({
8818
8505
  name,
8819
8506
  args: tool.parameters,
@@ -8821,7 +8508,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
8821
8508
  render: tool.render
8822
8509
  });
8823
8510
  return () => {
8824
- copilotkit.removeTool(name, tool.agentId);
8511
+ unregister();
8825
8512
  };
8826
8513
  }, [
8827
8514
  tool.name,
@@ -8846,8 +8533,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
8846
8533
  *
8847
8534
  * Tools are keyed by `name` plus `agentId`, the same as `useFrontendTool`. A
8848
8535
  * tool that disappears from the array is unregistered on the next render, and
8849
- * every tool is unregistered on unmount. Renderers stay registered after
8850
- * unmount so past tool calls still render in the chat history.
8536
+ * every tool is unregistered on unmount. A listed tool hides a tool with the
8537
+ * same name and agentId (for example one from the provider's `tools`) until it
8538
+ * is unregistered, and then the hidden tool is active again. Renderers stay
8539
+ * registered after unmount so past tool calls still render in the chat history.
8851
8540
  *
8852
8541
  * @param tools - The tools to register. May be empty and may change length.
8853
8542
  * @param deps - Extra dependencies that force re-registration, compared by
@@ -8897,15 +8586,13 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
8897
8586
  deduped.set(key, tool);
8898
8587
  }
8899
8588
  const registered = [...deduped.values()];
8589
+ const unregisters = [];
8900
8590
  for (const tool of registered) {
8901
8591
  if (copilotkit.getTool({
8902
8592
  toolName: tool.name,
8903
8593
  agentId: tool.agentId
8904
- })) {
8905
- console.warn(`Tool '${tool.name}' already exists for agent '${tool.agentId || "global"}'. Overriding with latest registration.`);
8906
- copilotkit.removeTool(tool.name, tool.agentId);
8907
- }
8908
- copilotkit.addTool(tool);
8594
+ })) console.warn(`Tool '${tool.name}' already exists for agent '${tool.agentId || "global"}'. Overriding with latest registration.`);
8595
+ unregisters.push(copilotkit.addTool(tool));
8909
8596
  if (tool.render) copilotkit.addHookRenderToolCall({
8910
8597
  name: tool.name,
8911
8598
  args: tool.parameters,
@@ -8914,7 +8601,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
8914
8601
  });
8915
8602
  }
8916
8603
  return () => {
8917
- for (const tool of registered) copilotkit.removeTool(tool.name, tool.agentId);
8604
+ for (const unregister of unregisters) unregister();
8918
8605
  };
8919
8606
  }, [
8920
8607
  JSON.stringify(toolList.map((tool) => [
@@ -9089,34 +8776,24 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
9089
8776
  * @internal
9090
8777
  */
9091
8778
  const ToolCallGroupContext = (0, react.createContext)(null);
9092
- /**
9093
- * A call without a result is running only while the group is active: once
9094
- * the run has moved on or ended, its result is never coming.
9095
- */
9096
- const entryStatus = ({ toolMessage }, active) => toolMessage ? toolMessage.error ? "failed" : "done" : active ? "running" : "stopped";
9097
- /** @internal */
9098
- const statusLabels = {
9099
- running: "Running",
9100
- done: "Done",
9101
- failed: "Failed",
9102
- stopped: "Stopped"
8779
+ /** The label key for each call status. */
8780
+ const STATUS_LABEL_KEYS = {
8781
+ running: "toolCallStatusRunningLabel",
8782
+ done: "toolCallStatusDoneLabel",
8783
+ failed: "toolCallStatusFailedLabel",
8784
+ stopped: "toolCallStatusStoppedLabel"
9103
8785
  };
9104
- /** The first non-empty string argument: usually a command, path or query. */
9105
- function argumentPreview(parameters) {
9106
- if (!parameters || typeof parameters !== "object") return void 0;
9107
- return Object.values(parameters).find((v) => typeof v === "string" && v.trim().length > 0)?.replace(/\s+/g, " ");
9108
- }
9109
- const entryPreview = (entry) => argumentPreview((0, _copilotkit_shared.partialJSONParse)(entry.toolCall.function.arguments));
9110
- /** "run_command ×2, read_file" */
9111
- function toolNames(calls) {
9112
- const counts = /* @__PURE__ */ new Map();
9113
- for (const { toolCall } of calls) {
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(", ");
8786
+ /** The icon for each call status. */
8787
+ const STATUS_ICONS = {
8788
+ running: "Loader2",
8789
+ done: "Check",
8790
+ failed: "X",
8791
+ stopped: "Circle"
8792
+ };
8793
+ /** The chat labels from the nearest chat configuration, or the defaults. */
8794
+ function useLabels$1() {
8795
+ return useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
9118
8796
  }
9119
- const pluralize = (count, noun) => `${count} ${noun}${count === 1 ? "" : "s"}`;
9120
8797
  /**
9121
8798
  * Height transition between closed and its content's height. Closed content
9122
8799
  * stays mounted (so its state survives) but is inert.
@@ -9139,55 +8816,35 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
9139
8816
  });
9140
8817
  }
9141
8818
  function StatusIcon({ status, className }) {
9142
- const Icon = {
9143
- running: lucide_react.Loader2,
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, {
8819
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
8820
+ name: STATUS_ICONS[status],
9149
8821
  "aria-hidden": "true",
9150
8822
  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
8823
  });
9152
8824
  }
9153
8825
  function Chevron({ open, className }) {
9154
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, {
8826
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
8827
+ name: "ChevronRight",
9155
8828
  "aria-hidden": "true",
9156
8829
  className: cn("cpk-tool-call-chevron", open && "cpk-tool-call-chevron-open", className)
9157
8830
  });
9158
8831
  }
9159
8832
  function FailedCount({ calls }) {
9160
- const failed = calls.filter((call) => call.toolMessage?.error).length;
8833
+ const labels = useLabels$1();
8834
+ const failed = (0, _copilotkit_core.ɵcountFailedToolCalls)(calls);
9161
8835
  if (!failed) return null;
9162
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
8836
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
9163
8837
  className: "cpk-tool-call-failed-count",
9164
- children: [failed, " failed"]
8838
+ children: (0, _copilotkit_core.ɵformatLabel)(labels.toolCallFailedCountLabel, { count: failed })
9165
8839
  });
9166
8840
  }
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
8841
  function Payload({ label, value }) {
9185
8842
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
9186
8843
  className: "cpk-tool-call-payload-label",
9187
8844
  children: label
9188
8845
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
9189
8846
  className: "cpk-tool-call-payload-code",
9190
- children: stringifyPayload(value)
8847
+ children: (0, _copilotkit_core.ɵstringifyToolCallPayload)(value)
9191
8848
  })] });
9192
8849
  }
9193
8850
  /**
@@ -9195,13 +8852,14 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
9195
8852
  * @internal
9196
8853
  */
9197
8854
  function ToolCallPayloads({ parameters, result, className }) {
8855
+ const labels = useLabels$1();
9198
8856
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
9199
8857
  className: cn("cpk-tool-call-payloads", className),
9200
8858
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Payload, {
9201
- label: "Arguments",
8859
+ label: labels.toolCallArgumentsLabel,
9202
8860
  value: parameters ?? {}
9203
8861
  }), result !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Payload, {
9204
- label: "Result",
8862
+ label: labels.toolCallResultLabel,
9205
8863
  value: result
9206
8864
  })]
9207
8865
  });
@@ -9212,9 +8870,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
9212
8870
  * @internal
9213
8871
  */
9214
8872
  function ToolCallRow({ name, parameters, result, status, appearance, className, ...props }) {
8873
+ const labels = useLabels$1();
9215
8874
  const [open, setOpen] = (0, react.useState)(false);
9216
8875
  const detailsId = (0, react.useId)();
9217
- const preview = argumentPreview(parameters);
8876
+ const preview = (0, _copilotkit_core.ɵgetArgumentPreview)(parameters);
9218
8877
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
9219
8878
  "data-copilotkit": true,
9220
8879
  className: cn("cpk-tool-call-row", `cpk-tool-call-row-${appearance}`, className),
@@ -9239,7 +8898,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
9239
8898
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
9240
8899
  "data-testid": "copilot-tool-render-status",
9241
8900
  className: "cpk-tool-call-row-status",
9242
- children: statusLabels[status]
8901
+ children: labels[STATUS_LABEL_KEYS[status]]
9243
8902
  }),
9244
8903
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chevron, {
9245
8904
  open,
@@ -9268,14 +8927,15 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
9268
8927
  * draws.
9269
8928
  */
9270
8929
  function CopilotChatToolCallGroup({ calls, renderCall, appearance = "card", isActive = false, className, ...props }) {
8930
+ const labels = useLabels$1();
9271
8931
  const [open, setOpen] = (0, react.useState)(false);
9272
8932
  const bodyId = (0, react.useId)();
9273
8933
  const latest = calls[calls.length - 1];
9274
8934
  if (!latest) return null;
9275
8935
  const current = isActive ? calls.find((call) => !call.toolMessage) ?? latest : void 0;
9276
- const preview = current ? entryPreview(current) : void 0;
8936
+ const preview = current ? (0, _copilotkit_core.ɵgetToolCallPreview)(current) : void 0;
9277
8937
  const done = calls.filter((call) => call.toolMessage).length;
9278
- const statuses = calls.map((call) => entryStatus(call, isActive));
8938
+ const statuses = calls.map((call) => (0, _copilotkit_core.ɵgetToolCallRowStatus)(call, isActive));
9279
8939
  const failedIds = new Set(calls.filter((_, index) => statuses[index] === "failed").map((call) => call.toolCall.id));
9280
8940
  const status = current ? "running" : failedIds.size > 0 ? "failed" : statuses.includes("stopped") ? "stopped" : "done";
9281
8941
  const rows = (rowAppearance) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolCallGroupContext.Provider, {
@@ -9293,9 +8953,9 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
9293
8953
  "data-state": status,
9294
8954
  ...props
9295
8955
  };
9296
- const runningLabel = current && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
8956
+ const runningLabel = current && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
9297
8957
  className: "cpk-tool-call-group-running cpk-shimmer",
9298
- children: ["Running ", current.toolCall.function.name]
8958
+ children: (0, _copilotkit_core.ɵformatLabel)(labels.toolCallRunningLabel, { name: current.toolCall.function.name })
9299
8959
  }), preview && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
9300
8960
  className: "cpk-tool-call-group-preview",
9301
8961
  children: preview
@@ -9323,13 +8983,16 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
9323
8983
  onClick: () => setOpen((value) => !value),
9324
8984
  className: "cpk-tool-call-group-line-toggle",
9325
8985
  children: [runningLabel || /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
9326
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
8986
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
9327
8987
  className: "cpk-tool-call-group-line-summary",
9328
- children: ["Used ", pluralize(calls.length, "tool")]
8988
+ children: (0, _copilotkit_core.ɵformatCountLabel)(calls.length, {
8989
+ one: labels.toolCallUsedToolsOne,
8990
+ other: labels.toolCallUsedToolsOther
8991
+ })
9329
8992
  }),
9330
8993
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
9331
8994
  className: "cpk-tool-call-group-line-names",
9332
- children: toolNames(calls)
8995
+ children: (0, _copilotkit_core.ɵformatToolNames)(calls)
9333
8996
  }),
9334
8997
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FailedCount, { calls })
9335
8998
  ] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chevron, { open })]
@@ -9346,8 +9009,8 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
9346
9009
  if (appearance === "stack") {
9347
9010
  const behind = open ? 0 : Math.min(calls.length - 1, 2);
9348
9011
  const layer = "cpk-tool-call-group-stack-layer";
9349
- const latestStatus = entryStatus(latest, isActive);
9350
- const latestPreview = entryPreview(latest);
9012
+ const latestStatus = (0, _copilotkit_core.ɵgetToolCallRowStatus)(latest, isActive);
9013
+ const latestPreview = (0, _copilotkit_core.ɵgetToolCallPreview)(latest);
9351
9014
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
9352
9015
  ...groupProps,
9353
9016
  className: cn("cpk-tool-call-group cpk-tool-call-group-stack", className),
@@ -9374,11 +9037,14 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
9374
9037
  onClick: () => setOpen((value) => !value),
9375
9038
  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
9039
  children: open ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
9377
- pluralize(calls.length, "tool call"),
9040
+ (0, _copilotkit_core.ɵformatCountLabel)(calls.length, {
9041
+ one: labels.toolCallToolCallCountOne,
9042
+ other: labels.toolCallToolCallCountOther
9043
+ }),
9378
9044
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FailedCount, { calls }),
9379
9045
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
9380
9046
  className: "cpk-tool-call-group-stack-collapse",
9381
- children: ["Collapse", /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chevron, {
9047
+ children: [labels.toolCallCollapseLabel, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chevron, {
9382
9048
  open: true,
9383
9049
  className: "cpk-tool-call-group-stack-collapse-icon"
9384
9050
  })]
@@ -9397,7 +9063,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
9397
9063
  }),
9398
9064
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
9399
9065
  className: "cpk-tool-call-group-stack-status",
9400
- children: statusLabels[latestStatus]
9066
+ children: labels[STATUS_LABEL_KEYS[latestStatus]]
9401
9067
  })
9402
9068
  ]
9403
9069
  }, latest.toolCall.id), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
@@ -9406,7 +9072,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
9406
9072
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FailedCount, { calls }),
9407
9073
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
9408
9074
  className: "cpk-tool-call-group-stack-count",
9409
- children: pluralize(calls.length, "call")
9075
+ children: (0, _copilotkit_core.ɵformatCountLabel)(calls.length, {
9076
+ one: labels.toolCallCallCountOne,
9077
+ other: labels.toolCallCallCountOther
9078
+ })
9410
9079
  }),
9411
9080
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chevron, {
9412
9081
  open: false,
@@ -9418,7 +9087,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
9418
9087
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
9419
9088
  "aria-live": "polite",
9420
9089
  className: "cpk-tool-call-group-stack-live",
9421
- children: open ? "" : `${latest.toolCall.function.name}: ${statusLabels[latestStatus]}`
9090
+ children: open ? "" : `${latest.toolCall.function.name}: ${labels[STATUS_LABEL_KEYS[latestStatus]]}`
9422
9091
  })
9423
9092
  ]
9424
9093
  }), open && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -9450,18 +9119,21 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
9450
9119
  className: "cpk-tool-call-group-card-toggle",
9451
9120
  children: [
9452
9121
  /* @__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.jsxs)("span", {
9122
+ runningLabel || /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
9454
9123
  className: "cpk-tool-call-group-card-summary",
9455
- children: ["Used ", pluralize(calls.length, "tool")]
9124
+ children: (0, _copilotkit_core.ɵformatCountLabel)(calls.length, {
9125
+ one: labels.toolCallUsedToolsOne,
9126
+ other: labels.toolCallUsedToolsOther
9127
+ })
9456
9128
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
9457
9129
  className: "cpk-tool-call-group-card-names",
9458
- children: toolNames(calls)
9130
+ children: (0, _copilotkit_core.ɵformatToolNames)(calls)
9459
9131
  })] }),
9460
9132
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
9461
9133
  className: "cpk-tool-call-group-card-meta",
9462
9134
  children: [status === "failed" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FailedCount, { calls }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
9463
9135
  className: "cpk-tool-call-group-card-status",
9464
- children: status !== "running" ? statusLabels[status] : done > 0 && `${done} done`
9136
+ children: status !== "running" ? labels[STATUS_LABEL_KEYS[status]] : done > 0 && (0, _copilotkit_core.ɵformatLabel)(labels.toolCallDoneCountLabel, { count: done })
9465
9137
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chevron, { open })]
9466
9138
  })
9467
9139
  ]
@@ -10228,11 +9900,6 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
10228
9900
  }));
10229
9901
  }
10230
9902
 
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
9903
  //#endregion
10237
9904
  //#region src/hooks/use-interrupt.tsx
10238
9905
  /** Recognize thenables returned by interrupt preprocessing handlers. */
@@ -10243,7 +9910,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
10243
9910
  function toLegacyEvent(pending) {
10244
9911
  if (pending.kind === "legacy") return pending.event;
10245
9912
  return {
10246
- name: INTERRUPT_EVENT_NAME,
9913
+ name: _copilotkit_core.INTERRUPT_EVENT_NAME,
10247
9914
  value: pending.interrupts[0]
10248
9915
  };
10249
9916
  }
@@ -10290,7 +9957,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
10290
9957
  let localStandard = null;
10291
9958
  const subscription = agent.subscribe({
10292
9959
  onCustomEvent: ({ event }) => {
10293
- if (event.name === INTERRUPT_EVENT_NAME) localLegacy = {
9960
+ if (event.name === _copilotkit_core.INTERRUPT_EVENT_NAME) localLegacy = {
10294
9961
  name: event.name,
10295
9962
  value: event.value
10296
9963
  };
@@ -11149,297 +10816,11 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
11149
10816
  };
11150
10817
  }
11151
10818
 
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
10819
  //#endregion
11309
10820
  //#region src/components/chat/tool-call-display-context.ts
11310
10821
  /** @internal */
11311
10822
  const ToolCallDisplayContext = (0, react.createContext)(null);
11312
10823
 
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
10824
  //#endregion
11444
10825
  //#region src/components/chat/CopilotChatToolCallsView.tsx
11445
10826
  const appearances = {
@@ -11459,7 +10840,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
11459
10840
  const viewLayout = context?.layouts.get(message.id);
11460
10841
  const layout = (0, react.useMemo)(() => {
11461
10842
  if (display === "separate") return void 0;
11462
- return viewLayout ?? getToolCallLayouts([message], messages, rendererNames).get(message.id);
10843
+ return viewLayout ?? (0, _copilotkit_core.ɵgetToolCallLayouts)([message], messages, rendererNames).get(message.id);
11463
10844
  }, [
11464
10845
  display,
11465
10846
  viewLayout,
@@ -11649,7 +11030,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
11649
11030
  });
11650
11031
  }
11651
11032
  function CopilotChatInspectorButton({ title, className, onClick, onPointerDown, onPointerEnter, onPointerLeave, onKeyDown, disabled, ...props }) {
11652
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
11033
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
11653
11034
  const { isInspectorEnabled } = useCopilotKitInspector();
11654
11035
  const hidden = useInspectorShortcutsHidden();
11655
11036
  const [open, setOpen] = (0, react.useState)(false);
@@ -11718,7 +11099,8 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
11718
11099
  event.currentTarget.click();
11719
11100
  }
11720
11101
  },
11721
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Wrench, {
11102
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
11103
+ name: "Wrench",
11722
11104
  "aria-hidden": "true",
11723
11105
  className: "cpk-inspector-button-icon",
11724
11106
  "data-testid": "copilot-inspector-icon"
@@ -11785,7 +11167,8 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
11785
11167
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DropdownMenuItem, {
11786
11168
  onSelect: hideShortcuts,
11787
11169
  className: "cpk-inspector-button-menu-item cpk-inspector-button-hide-item",
11788
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.EyeOff, {
11170
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
11171
+ name: "EyeOff",
11789
11172
  "aria-hidden": "true",
11790
11173
  className: "cpk-inspector-button-menu-item-icon"
11791
11174
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
@@ -12326,7 +11709,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
12326
11709
  * control after the thumb, and Enter or Escape inside it returns to the thumb.
12327
11710
  */
12328
11711
  function FeedbackCommentPopover({ feedbackComment, comment, savedComment, rating, anchor, messageId }) {
12329
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
11712
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
12330
11713
  const contentRef = (0, react.useRef)(null);
12331
11714
  const focusInside = () => contentRef.current?.contains(document.activeElement) ?? false;
12332
11715
  const { focusRequest, takeFocusRequest, inputRef } = comment;
@@ -12630,7 +12013,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
12630
12013
  });
12631
12014
  };
12632
12015
  _CopilotChatAssistantMessage.CopyButton = ({ className, title, onClick, ...props }) => {
12633
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
12016
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
12634
12017
  const [copied, setCopied] = (0, react.useState)(false);
12635
12018
  const timerRef = (0, react.useRef)(null);
12636
12019
  (0, react.useEffect)(() => {
@@ -12656,36 +12039,44 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
12656
12039
  onClick: handleClick,
12657
12040
  className,
12658
12041
  ...props,
12659
- children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, { className: "cpk-assistant-message-toolbar-icon" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Copy, { className: "cpk-assistant-message-toolbar-icon" })
12042
+ children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
12043
+ name: "Check",
12044
+ className: "cpk-assistant-message-toolbar-icon"
12045
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
12046
+ name: "Copy",
12047
+ className: "cpk-assistant-message-toolbar-icon"
12048
+ })
12660
12049
  });
12661
12050
  };
12662
12051
  _CopilotChatAssistantMessage.InspectorButton = CopilotChatInspectorButton;
12663
12052
  _CopilotChatAssistantMessage.ThumbsUpButton = ({ title, ...props }) => {
12664
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
12053
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
12665
12054
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
12666
12055
  "data-testid": "copilot-thumbs-up-button",
12667
12056
  title: title || labels.assistantMessageToolbarThumbsUpLabel,
12668
12057
  ...props,
12669
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ThumbsUp, {
12058
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
12059
+ name: "ThumbsUp",
12670
12060
  className: "cpk-assistant-message-toolbar-icon",
12671
12061
  fill: props["aria-pressed"] === true ? "currentColor" : "none"
12672
12062
  })
12673
12063
  });
12674
12064
  };
12675
12065
  _CopilotChatAssistantMessage.ThumbsDownButton = ({ title, ...props }) => {
12676
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
12066
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
12677
12067
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
12678
12068
  "data-testid": "copilot-thumbs-down-button",
12679
12069
  title: title || labels.assistantMessageToolbarThumbsDownLabel,
12680
12070
  ...props,
12681
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ThumbsDown, {
12071
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
12072
+ name: "ThumbsDown",
12682
12073
  className: "cpk-assistant-message-toolbar-icon",
12683
12074
  fill: props["aria-pressed"] === true ? "currentColor" : "none"
12684
12075
  })
12685
12076
  });
12686
12077
  };
12687
12078
  _CopilotChatAssistantMessage.FeedbackComment = ({ value, savedComment, inputRef, onChange, onSubmit, onEditingChange, onLeave, className }) => {
12688
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
12079
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
12689
12080
  const changed = value.trim() !== savedComment;
12690
12081
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
12691
12082
  "data-testid": "copilot-feedback-comment",
@@ -12715,26 +12106,35 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
12715
12106
  variant: "assistantMessageToolbarButton",
12716
12107
  "aria-label": labels.assistantMessageFeedbackCommentSubmitLabel,
12717
12108
  title: labels.assistantMessageFeedbackCommentSubmitLabel,
12718
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ArrowUp, { className: "cpk-assistant-message-feedback-comment-submit-icon" })
12109
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
12110
+ name: "ArrowUp",
12111
+ className: "cpk-assistant-message-feedback-comment-submit-icon"
12112
+ })
12719
12113
  })]
12720
12114
  });
12721
12115
  };
12722
12116
  _CopilotChatAssistantMessage.ReadAloudButton = ({ title, ...props }) => {
12723
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
12117
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
12724
12118
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
12725
12119
  "data-testid": "copilot-read-aloud-button",
12726
12120
  title: title || labels.assistantMessageToolbarReadAloudLabel,
12727
12121
  ...props,
12728
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Volume2, { className: "cpk-assistant-message-read-aloud-icon" })
12122
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
12123
+ name: "Volume2",
12124
+ className: "cpk-assistant-message-read-aloud-icon"
12125
+ })
12729
12126
  });
12730
12127
  };
12731
12128
  _CopilotChatAssistantMessage.RegenerateButton = ({ title, ...props }) => {
12732
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
12129
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
12733
12130
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
12734
12131
  "data-testid": "copilot-regenerate-button",
12735
12132
  title: title || labels.assistantMessageToolbarRegenerateLabel,
12736
12133
  ...props,
12737
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.RefreshCw, { className: "cpk-assistant-message-toolbar-icon" })
12134
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
12135
+ name: "RefreshCw",
12136
+ className: "cpk-assistant-message-toolbar-icon"
12137
+ })
12738
12138
  });
12739
12139
  };
12740
12140
  })(CopilotChatAssistantMessage || (CopilotChatAssistantMessage = {}));
@@ -12757,7 +12157,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
12757
12157
  * `labels.attachmentPreviewCloseButtonLabel`.
12758
12158
  */
12759
12159
  function Lightbox({ onClose, children }) {
12760
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
12160
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
12761
12161
  (0, react.useEffect)(() => {
12762
12162
  const handleKey = (e) => {
12763
12163
  if (e.key === "Escape") onClose();
@@ -12773,7 +12173,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
12773
12173
  onClick: onClose,
12774
12174
  className: "cpk-attachment-lightbox-close-button",
12775
12175
  "aria-label": labels.attachmentPreviewCloseButtonLabel,
12776
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, { className: "cpk-attachment-lightbox-close-icon" })
12176
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
12177
+ name: "X",
12178
+ className: "cpk-attachment-lightbox-close-icon"
12179
+ })
12777
12180
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
12778
12181
  onClick: (e) => e.stopPropagation(),
12779
12182
  children
@@ -12827,17 +12230,22 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
12827
12230
 
12828
12231
  //#endregion
12829
12232
  //#region src/components/chat/CopilotChatAttachmentRenderer.tsx
12233
+ /** The chat labels from the nearest chat configuration, or the defaults. */
12234
+ function useLabels() {
12235
+ return useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
12236
+ }
12830
12237
  const ImageAttachment = (0, react.memo)(function ImageAttachment({ src, className }) {
12238
+ const labels = useLabels();
12831
12239
  const [error, setError] = (0, react.useState)(false);
12832
12240
  const { thumbnailRef, vtName, open, openLightbox, closeLightbox } = useLightbox();
12833
12241
  if (error) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
12834
12242
  className: cn("cpk-attachment-renderer cpk-attachment-renderer-image-error", className),
12835
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "Failed to load image" })
12243
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: labels.attachmentImageLoadErrorText })
12836
12244
  });
12837
12245
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
12838
12246
  ref: thumbnailRef,
12839
12247
  src,
12840
- alt: "Image attachment",
12248
+ alt: labels.attachmentImageAltText,
12841
12249
  className: cn("cpk-attachment-renderer cpk-attachment-renderer-image", className),
12842
12250
  onClick: openLightbox,
12843
12251
  onError: () => setError(true)
@@ -12846,7 +12254,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
12846
12254
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
12847
12255
  style: { viewTransitionName: vtName },
12848
12256
  src,
12849
- alt: "Image attachment",
12257
+ alt: labels.attachmentImageAltText,
12850
12258
  className: "cpk-attachment-renderer-lightbox-image"
12851
12259
  })
12852
12260
  })] });
@@ -12874,7 +12282,8 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
12874
12282
  });
12875
12283
  });
12876
12284
  const DocumentAttachment = (0, react.memo)(function DocumentAttachment({ src, source, filename, className }) {
12877
- const label = filename || source.mimeType || "Document attachment";
12285
+ const labels = useLabels();
12286
+ const label = filename || source.mimeType || labels.attachmentDocumentAltText;
12878
12287
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
12879
12288
  href: src,
12880
12289
  download: filename ?? "",
@@ -12887,7 +12296,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
12887
12296
  children: (0, _copilotkit_shared.getDocumentIcon)(source.mimeType ?? "")
12888
12297
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
12889
12298
  className: "cpk-attachment-renderer-document-name",
12890
- children: filename || source.mimeType || "Unknown type"
12299
+ children: filename || source.mimeType || labels.attachmentUnknownTypeText
12891
12300
  })]
12892
12301
  });
12893
12302
  });
@@ -13026,7 +12435,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
13026
12435
  })] });
13027
12436
  };
13028
12437
  _CopilotChatUserMessage.CopyButton = ({ className, title, onClick, ...props }) => {
13029
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
12438
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
13030
12439
  const [copied, setCopied] = (0, react.useState)(false);
13031
12440
  const handleClick = async (event) => {
13032
12441
  let success = false;
@@ -13042,21 +12451,30 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
13042
12451
  onClick: handleClick,
13043
12452
  className,
13044
12453
  ...props,
13045
- children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, { className: "cpk-user-message-toolbar-icon" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Copy, { className: "cpk-user-message-toolbar-icon" })
12454
+ children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
12455
+ name: "Check",
12456
+ className: "cpk-user-message-toolbar-icon"
12457
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
12458
+ name: "Copy",
12459
+ className: "cpk-user-message-toolbar-icon"
12460
+ })
13046
12461
  });
13047
12462
  };
13048
12463
  _CopilotChatUserMessage.EditButton = ({ className, title, ...props }) => {
13049
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
12464
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
13050
12465
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
13051
12466
  "data-testid": "copilot-edit-button",
13052
12467
  title: title || labels.userMessageToolbarEditMessageLabel,
13053
12468
  className,
13054
12469
  ...props,
13055
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Edit, { className: "cpk-user-message-toolbar-icon" })
12470
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
12471
+ name: "Edit",
12472
+ className: "cpk-user-message-toolbar-icon"
12473
+ })
13056
12474
  });
13057
12475
  };
13058
12476
  _CopilotChatUserMessage.BranchNavigation = ({ className, currentBranch = 0, numberOfBranches = 1, onSwitchToBranch, message, ...props }) => {
13059
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
12477
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
13060
12478
  if (!numberOfBranches || numberOfBranches <= 1 || !onSwitchToBranch) return null;
13061
12479
  const canGoPrev = currentBranch > 0;
13062
12480
  const canGoNext = currentBranch < numberOfBranches - 1;
@@ -13076,7 +12494,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
13076
12494
  disabled: !canGoPrev,
13077
12495
  className: "cpk-user-message-branch-button",
13078
12496
  "aria-label": labels.userMessageToolbarPreviousBranchLabel,
13079
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronLeft, { className: "cpk-user-message-branch-icon" })
12497
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
12498
+ name: "ChevronLeft",
12499
+ className: "cpk-user-message-branch-icon"
12500
+ })
13080
12501
  }),
13081
12502
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
13082
12503
  className: "cpk-user-message-branch-counter",
@@ -13097,7 +12518,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
13097
12518
  disabled: !canGoNext,
13098
12519
  className: "cpk-user-message-branch-button",
13099
12520
  "aria-label": labels.userMessageToolbarNextBranchLabel,
13100
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, { className: "cpk-user-message-branch-icon" })
12521
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
12522
+ name: "ChevronRight",
12523
+ className: "cpk-user-message-branch-icon"
12524
+ })
13101
12525
  })
13102
12526
  ]
13103
12527
  });
@@ -13115,24 +12539,35 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
13115
12539
  //#endregion
13116
12540
  //#region src/components/chat/CopilotChatReasoningMessage.tsx
13117
12541
  /**
13118
- * Formats an elapsed duration (in seconds) to a human-readable string.
12542
+ * The reasoning time as label text, such as "4 seconds" or "1m 5s".
12543
+ *
12544
+ * @param seconds - The elapsed time in seconds. It may have a fraction.
12545
+ * @param labels - The chat labels that hold the duration texts.
13119
12546
  */
13120
- function formatDuration$1(seconds) {
13121
- if (seconds < 1) return "a few seconds";
13122
- if (seconds < 60) return `${Math.round(seconds)} seconds`;
13123
- const mins = Math.floor(seconds / 60);
13124
- const secs = Math.round(seconds % 60);
13125
- if (secs === 0) return `${mins} minute${mins > 1 ? "s" : ""}`;
13126
- return `${mins}m ${secs}s`;
12547
+ function formatDuration(seconds, labels) {
12548
+ const duration = (0, _copilotkit_core.ɵformatReasoningDuration)(seconds);
12549
+ switch (duration.unit) {
12550
+ case "fewSeconds": return labels.reasoningMessageDurationFewSeconds;
12551
+ case "seconds": return (0, _copilotkit_core.ɵformatLabel)(labels.reasoningMessageDurationSeconds, { count: duration.seconds });
12552
+ case "minutes": return (0, _copilotkit_core.ɵformatCountLabel)(duration.minutes, {
12553
+ one: labels.reasoningMessageDurationMinutesOne,
12554
+ other: labels.reasoningMessageDurationMinutesOther
12555
+ });
12556
+ case "minutesSeconds": return (0, _copilotkit_core.ɵformatLabel)(labels.reasoningMessageDurationMinutesSeconds, {
12557
+ minutes: duration.minutes,
12558
+ seconds: duration.seconds
12559
+ });
12560
+ }
13127
12561
  }
13128
12562
  /**
13129
12563
  * A reasoning message as a collapsible block. While the model reasons it is
13130
12564
  * open and the header shows `labels.reasoningMessageThinkingLabel`; when
13131
- * streaming ends it collapses and the header reads "Thought for …". The
12565
+ * streaming ends it collapses and the header reads
12566
+ * `labels.reasoningMessageThoughtForLabel` ("Thought for 4 seconds"). The
13132
12567
  * `header` slot also receives `elapsedSeconds`.
13133
12568
  */
13134
12569
  function CopilotChatReasoningMessage({ message, messages, isRunning, isLatest: isLatestProp, header, contentView, toggle, children, className, ...props }) {
13135
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
12570
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
13136
12571
  const isLatest = isLatestProp ?? messages?.[messages.length - 1]?.id === message.id;
13137
12572
  const isStreaming = !!(isRunning && isLatest);
13138
12573
  const hasContent = !!(message.content && message.content.length > 0);
@@ -13162,7 +12597,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
13162
12597
  userToggledRef.current = true;
13163
12598
  setIsOpen((prev) => !prev);
13164
12599
  } : void 0;
13165
- const label = isStreaming ? labels.reasoningMessageThinkingLabel : `Thought for ${formatDuration$1(elapsed)}`;
12600
+ const label = isStreaming ? labels.reasoningMessageThinkingLabel : (0, _copilotkit_core.ɵformatLabel)(labels.reasoningMessageThoughtForLabel, { duration: formatDuration(elapsed, labels) });
13166
12601
  const boundHeader = renderSlot(header, CopilotChatReasoningMessage.Header, {
13167
12602
  isOpen,
13168
12603
  label,
@@ -13217,7 +12652,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
13217
12652
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "cpk-reasoning-message-indicator-dot" })
13218
12653
  }),
13219
12654
  headerChildren,
13220
- isExpandable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, { className: cn("cpk-reasoning-message-chevron", isOpen && "cpk-reasoning-message-chevron-open") })
12655
+ isExpandable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
12656
+ name: "ChevronRight",
12657
+ className: cn("cpk-reasoning-message-chevron", isOpen && "cpk-reasoning-message-chevron-open")
12658
+ })
13221
12659
  ]
13222
12660
  });
13223
12661
  };
@@ -13271,7 +12709,8 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
13271
12709
  ...props,
13272
12710
  children: [isLoading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
13273
12711
  className: "cpk-suggestion-pill-icon",
13274
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Loader2, {
12712
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
12713
+ name: "Loader2",
13275
12714
  className: "cpk-suggestion-pill-spinner",
13276
12715
  "aria-hidden": "true"
13277
12716
  })
@@ -13388,15 +12827,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
13388
12827
 
13389
12828
  //#endregion
13390
12829
  //#region src/components/chat/CopilotChatWorkSummary.tsx
13391
- /** "45s", "1m 5s", "2m". Used for the live timer and the final duration. */
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. */
12830
+ /** Re-renders every second while `active`, returning the current time. */
13400
12831
  function useNow(active) {
13401
12832
  const [now, setNow] = (0, react.useState)(() => Date.now());
13402
12833
  (0, react.useEffect)(() => {
@@ -13409,14 +12840,20 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
13409
12840
  }
13410
12841
  /**
13411
12842
  * The line at the top of a reply in the `"turn"` tool-call display. While the
13412
- * agent works it reads "Working 4s"; once the reply is done it reads "Worked
13413
- * for 9s · 7 tools" and toggles the work it folded away.
12843
+ * agent works it reads "Working 4s". Once the reply is done it reads "Worked
12844
+ * for 9s" and "7 tools", and toggles the work it folded away. The text comes
12845
+ * from the `workSummary...` and `toolCall...` chat labels.
13414
12846
  */
13415
12847
  function CopilotChatWorkSummary({ isWorking, isOpen, calls, elapsedMs, workingSince, className, ...props }) {
12848
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
13416
12849
  const now = useNow(isWorking);
13417
- const failed = calls.filter((call) => call.toolMessage?.error).length;
12850
+ const failed = (0, _copilotkit_core.ɵcountFailedToolCalls)(calls);
12851
+ const toolCount = (0, _copilotkit_core.ɵformatCountLabel)(calls.length, {
12852
+ one: labels.toolCallToolCountOne,
12853
+ other: labels.toolCallToolCountOther
12854
+ });
13418
12855
  const liveMs = elapsedMs !== void 0 && workingSince !== void 0 ? elapsedMs + Math.max(0, now - workingSince) : void 0;
13419
- const duration = elapsedMs !== void 0 ? formatDuration(Math.max(1e3, elapsedMs)) : void 0;
12856
+ const duration = elapsedMs !== void 0 ? (0, _copilotkit_core.ɵformatWorkDuration)(Math.max(1e3, elapsedMs)) : void 0;
13420
12857
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
13421
12858
  type: "button",
13422
12859
  "data-copilotkit": true,
@@ -13427,24 +12864,28 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
13427
12864
  ...props,
13428
12865
  children: [isWorking ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
13429
12866
  className: "cpk-work-summary-label cpk-shimmer",
13430
- children: "Working"
12867
+ children: labels.workSummaryWorkingLabel
13431
12868
  }), liveMs !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
13432
12869
  className: "cpk-work-summary-detail cpk-work-summary-timer",
13433
- children: formatDuration(liveMs)
12870
+ children: (0, _copilotkit_core.ɵformatWorkDuration)(liveMs)
13434
12871
  })] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
13435
12872
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
13436
12873
  className: "cpk-work-summary-label",
13437
- children: duration ? `Worked for ${duration}` : `Used ${pluralize(calls.length, "tool")}`
12874
+ children: duration ? (0, _copilotkit_core.ɵformatLabel)(labels.workSummaryWorkedForLabel, { duration }) : (0, _copilotkit_core.ɵformatCountLabel)(calls.length, {
12875
+ one: labels.toolCallUsedToolsOne,
12876
+ other: labels.toolCallUsedToolsOther
12877
+ })
13438
12878
  }),
13439
12879
  duration && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
13440
12880
  className: "cpk-work-summary-detail",
13441
- children: pluralize(calls.length, "tool")
12881
+ children: toolCount
13442
12882
  }),
13443
- failed > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
12883
+ failed > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
13444
12884
  className: "cpk-work-summary-failed",
13445
- children: [failed, " failed"]
12885
+ children: (0, _copilotkit_core.ɵformatLabel)(labels.toolCallFailedCountLabel, { count: failed })
13446
12886
  })
13447
- ] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, {
12887
+ ] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
12888
+ name: "ChevronRight",
13448
12889
  "aria-hidden": "true",
13449
12890
  className: cn("cpk-work-summary-chevron", isOpen && "cpk-work-summary-chevron-open")
13450
12891
  })]
@@ -13859,68 +13300,6 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
13859
13300
  if (JSON.stringify(prevProps.stateSnapshot) !== JSON.stringify(nextProps.stateSnapshot)) return false;
13860
13301
  return true;
13861
13302
  });
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
13303
  /** A row holding a single message, rendered as it would be ungrouped. */
13925
13304
  function messageRow(message) {
13926
13305
  return {
@@ -13969,7 +13348,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
13969
13348
  if (!resolvedRunId) return void 0;
13970
13349
  return copilotkit.getStateByRun(config.agentId, config.threadId, resolvedRunId);
13971
13350
  };
13972
- const deduplicatedMessages = (0, react.useMemo)(() => deduplicateMessages(messages), [messages]);
13351
+ const deduplicatedMessages = (0, react.useMemo)(() => (0, _copilotkit_core.ɵdeduplicateMessages)(messages), [messages]);
13973
13352
  const transformedMessages = (0, react.useMemo)(() => transformMessages ? transformMessages(deduplicatedMessages) : deduplicatedMessages, [deduplicatedMessages, transformMessages]);
13974
13353
  const rows = (0, react.useMemo)(() => groupMessages ? groupMessages(transformedMessages) : transformedMessages.map(messageRow), [transformedMessages, groupMessages]);
13975
13354
  const renderedMessages = (0, react.useMemo)(() => groupMessages ? rows.flatMap((row) => row.type === "group" ? row.messages : [row.message]) : transformedMessages, [
@@ -13979,13 +13358,13 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
13979
13358
  ]);
13980
13359
  const latestRenderedId = renderedMessages[renderedMessages.length - 1]?.id;
13981
13360
  const rendererNames = useToolCallRendererNames();
13982
- const toolCallLayouts = (0, react.useMemo)(() => toolCallDisplay === "separate" ? /* @__PURE__ */ new Map() : getToolCallLayouts(renderedMessages, messages, rendererNames), [
13361
+ const toolCallLayouts = (0, react.useMemo)(() => toolCallDisplay === "separate" ? /* @__PURE__ */ new Map() : (0, _copilotkit_core.ɵgetToolCallLayouts)(renderedMessages, messages, rendererNames), [
13983
13362
  toolCallDisplay,
13984
13363
  renderedMessages,
13985
13364
  messages,
13986
13365
  rendererNames
13987
13366
  ]);
13988
- const turnWork = (0, react.useMemo)(() => toolCallDisplay === "turn" ? getTurnWork(renderedMessages, toolCallLayouts) : void 0, [
13367
+ const turnWork = (0, react.useMemo)(() => toolCallDisplay === "turn" ? (0, _copilotkit_core.ɵgetTurnWork)(renderedMessages, toolCallLayouts) : void 0, [
13989
13368
  toolCallDisplay,
13990
13369
  renderedMessages,
13991
13370
  toolCallLayouts
@@ -13995,46 +13374,25 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
13995
13374
  for (const turn of turnWork?.values() ?? []) byFirst.set(turn.firstMessageId, turn);
13996
13375
  return byFirst;
13997
13376
  }, [turnWork]);
13998
- let latestTurnKey = "start";
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;
13377
+ const latestTurnKey = (0, _copilotkit_core.ɵgetLatestTurnKey)(renderedMessages);
14004
13378
  const [toggledTurns, setToggledTurns] = (0, react.useState)(() => /* @__PURE__ */ new Map());
14005
- const isWorkOpen = (turnKey) => toggledTurns.get(turnKey) ?? isWorkingOn(turnKey);
13379
+ const turnState = {
13380
+ toggledTurns,
13381
+ isRunning,
13382
+ latestTurnKey
13383
+ };
14006
13384
  const workTimesRef = (0, react.useRef)(/* @__PURE__ */ new Map());
14007
- if (toolCallDisplay === "turn") {
14008
- const now = Date.now();
14009
- const workTimes = workTimesRef.current;
14010
- if (isRunning) {
14011
- const times = workTimes.get(latestTurnKey);
14012
- if (times) times.workingSince ?? (times.workingSince = now);
14013
- else if (renderedMessages[renderedMessages.length - 1]?.role === "user") workTimes.set(latestTurnKey, {
14014
- elapsedMs: 0,
14015
- workingSince: now
14016
- });
14017
- } else for (const times of workTimes.values()) {
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
- }, [
13385
+ if (toolCallDisplay === "turn") (0, _copilotkit_core.ɵrecordWorkTime)(workTimesRef.current, {
13386
+ isRunning,
13387
+ latestTurnKey,
13388
+ lastMessageRole: renderedMessages[renderedMessages.length - 1]?.role,
13389
+ now: Date.now()
13390
+ });
13391
+ const { workOpen, workTextOpen } = (0, react.useMemo)(() => (0, _copilotkit_core.ɵgetWorkOpenState)(turnWork?.values() ?? [], {
13392
+ toggledTurns,
13393
+ isRunning,
13394
+ latestTurnKey
13395
+ }), [
14038
13396
  turnWork,
14039
13397
  toggledTurns,
14040
13398
  isRunning,
@@ -14054,8 +13412,8 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
14054
13412
  workTextOpen
14055
13413
  ]);
14056
13414
  const renderWorkSummary = (turnKey, calls) => {
14057
- const working = isWorkingOn(turnKey);
14058
- const open = isWorkOpen(turnKey);
13415
+ const working = (0, _copilotkit_core.ɵisTurnWorking)(turnKey, turnState);
13416
+ const open = (0, _copilotkit_core.ɵisTurnWorkOpen)(turnKey, turnState);
14059
13417
  const times = workTimesRef.current.get(turnKey);
14060
13418
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Collapsible, {
14061
13419
  open: working || calls.length > 0,
@@ -14482,7 +13840,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
14482
13840
  * button named by `labels.attachmentRemoveButtonLabel`.
14483
13841
  */
14484
13842
  const CopilotChatAttachmentQueue = ({ attachments, onRemoveAttachment, className }) => {
14485
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
13843
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
14486
13844
  if (attachments.length === 0) return null;
14487
13845
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
14488
13846
  "data-testid": "copilot-attachment-queue",
@@ -14558,7 +13916,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
14558
13916
  * lightbox.
14559
13917
  */
14560
13918
  function VideoPreview({ attachment }) {
14561
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
13919
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
14562
13920
  const src = (0, _copilotkit_shared.getSourceUrl)(attachment.source);
14563
13921
  const { thumbnailRef, vtName, open, openLightbox, closeLightbox } = useLightbox();
14564
13922
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
@@ -14582,7 +13940,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
14582
13940
  "aria-label": labels.attachmentPlayVideoButtonLabel,
14583
13941
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
14584
13942
  className: "cpk-attachment-queue-video-play-badge",
14585
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Play, { className: "cpk-attachment-queue-video-play-icon" })
13943
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
13944
+ name: "Play",
13945
+ className: "cpk-attachment-queue-video-play-icon"
13946
+ })
14586
13947
  })
14587
13948
  }),
14588
13949
  open && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Lightbox, {
@@ -14635,6 +13996,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
14635
13996
  return url;
14636
13997
  }
14637
13998
  function DocumentLightboxContent({ attachment, vtName }) {
13999
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
14638
14000
  const mimeType = attachment.source.mimeType;
14639
14001
  const blobUrl = useBlobUrl(attachment);
14640
14002
  if (isPdf(mimeType)) {
@@ -14682,20 +14044,21 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
14682
14044
  className: "cpk-attachment-queue-document-card-details",
14683
14045
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
14684
14046
  className: "cpk-attachment-queue-document-card-name",
14685
- children: attachment.filename || "Document"
14047
+ children: attachment.filename || labels.attachmentDocumentLabel
14686
14048
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
14687
14049
  className: "cpk-attachment-queue-document-card-meta",
14688
- children: [mimeType || "Unknown type", attachment.size != null && ` · ${(0, _copilotkit_shared.formatFileSize)(attachment.size)}`]
14050
+ children: [mimeType || labels.attachmentUnknownTypeText, attachment.size != null && ` · ${(0, _copilotkit_shared.formatFileSize)(attachment.size)}`]
14689
14051
  })]
14690
14052
  }),
14691
14053
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
14692
14054
  className: "cpk-attachment-queue-document-card-note",
14693
- children: "No preview available for this file type"
14055
+ children: labels.attachmentNoPreviewText
14694
14056
  })
14695
14057
  ]
14696
14058
  });
14697
14059
  }
14698
14060
  function DocumentPreview({ attachment }) {
14061
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
14699
14062
  const { thumbnailRef, vtName, open, openLightbox, closeLightbox } = useLightbox();
14700
14063
  const mimeType = attachment.source.mimeType;
14701
14064
  const previewable = canPreviewInBrowser(mimeType);
@@ -14710,7 +14073,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
14710
14073
  className: "cpk-attachment-queue-document-info",
14711
14074
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
14712
14075
  className: "cpk-attachment-queue-document-name",
14713
- children: attachment.filename || "Document"
14076
+ children: attachment.filename || labels.attachmentDocumentLabel
14714
14077
  }), attachment.size != null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
14715
14078
  className: "cpk-attachment-queue-document-size",
14716
14079
  children: (0, _copilotkit_shared.formatFileSize)(attachment.size)
@@ -14847,13 +14210,17 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
14847
14210
  //#region src/components/chat/CopilotChatView.tsx
14848
14211
  const SCROLL_BUTTON_OFFSET = 16;
14849
14212
  function DropOverlay() {
14213
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
14850
14214
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
14851
14215
  className: "cpk-chat-view-drop-overlay",
14852
14216
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
14853
14217
  className: "cpk-chat-view-drop-overlay-content",
14854
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Upload, { className: "cpk-chat-view-drop-overlay-icon" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
14218
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
14219
+ name: "Upload",
14220
+ className: "cpk-chat-view-drop-overlay-icon"
14221
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
14855
14222
  className: "cpk-chat-view-drop-overlay-label",
14856
- children: "Drop files here"
14223
+ children: labels.chatDropFilesLabel
14857
14224
  })]
14858
14225
  })
14859
14226
  });
@@ -15293,7 +14660,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
15293
14660
  });
15294
14661
  };
15295
14662
  _CopilotChatView.ScrollToBottomButton = ({ className, ...props }) => {
15296
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
14663
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
15297
14664
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
15298
14665
  "data-testid": "copilot-scroll-to-bottom",
15299
14666
  variant: "outline",
@@ -15301,7 +14668,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
15301
14668
  className: cn("cpk-chat-view-scroll-to-bottom-button", className),
15302
14669
  "aria-label": labels.chatScrollToBottomLabel,
15303
14670
  ...props,
15304
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, { className: "cpk-chat-view-scroll-to-bottom-icon" })
14671
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
14672
+ name: "ChevronDown",
14673
+ className: "cpk-chat-view-scroll-to-bottom-icon"
14674
+ })
15305
14675
  });
15306
14676
  };
15307
14677
  _CopilotChatView.Feather = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -15309,7 +14679,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
15309
14679
  ...props
15310
14680
  });
15311
14681
  _CopilotChatView.WelcomeMessage = ({ className, ...props }) => {
15312
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
14682
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
15313
14683
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
15314
14684
  className: cn("cpk-chat-view-welcome-message", className),
15315
14685
  ...props,
@@ -15355,119 +14725,6 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
15355
14725
  })(CopilotChatView || (CopilotChatView = {}));
15356
14726
  var CopilotChatView_default = CopilotChatView;
15357
14727
 
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
14728
  //#endregion
15472
14729
  //#region src/providers/use-inspector-thread-override.ts
15473
14730
  function useInspectorThreadOverride(args) {
@@ -15949,7 +15206,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
15949
15206
  }
15950
15207
  if (!isCurrentSelection()) return false;
15951
15208
  if (failedConnectionsRef.current.has(agent)) {
15952
- setTranscriptionError("Could not load saved conversation. Reopen the thread and try again.");
15209
+ setTranscriptionError({ labelKey: "threadLoadErrorText" });
15953
15210
  return "failed";
15954
15211
  }
15955
15212
  const maybeAware = agent;
@@ -15974,7 +15231,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
15974
15231
  const onSubmitInput = (0, react.useCallback)(async (value) => {
15975
15232
  if (selectedAttachmentsRef.current.some((a) => a.status === "uploading")) {
15976
15233
  console.error("[CopilotKit] Cannot send while attachments are uploading (pre-await guard)");
15977
- setTranscriptionError("Cannot send while attachments are uploading.");
15234
+ setTranscriptionError({ labelKey: "chatAttachmentsUploadingText" });
15978
15235
  return;
15979
15236
  }
15980
15237
  setInputValue("");
@@ -15986,7 +15243,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
15986
15243
  }
15987
15244
  if (selectedAttachmentsRef.current.some((a) => a.status === "uploading")) {
15988
15245
  console.error("[CopilotKit] Cannot send while attachments are uploading (post-await re-check)");
15989
- setTranscriptionError("Cannot send while attachments are uploading.");
15246
+ setTranscriptionError({ labelKey: "chatAttachmentsUploadingText" });
15990
15247
  setInputValue(value);
15991
15248
  return;
15992
15249
  }
@@ -16104,7 +15361,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
16104
15361
  setIsTranscribing(true);
16105
15362
  try {
16106
15363
  setTranscriptionError(null);
16107
- const result = await transcribeAudio(copilotkit, audioBlob);
15364
+ const result = await (0, _copilotkit_core.ɵtranscribeAudio)(copilotkit, audioBlob);
16108
15365
  setInputValue((prev) => {
16109
15366
  const trimmedPrev = prev.trim();
16110
15367
  if (trimmedPrev) return `${trimmedPrev} ${result.text}`;
@@ -16112,33 +15369,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
16112
15369
  });
16113
15370
  } catch (error) {
16114
15371
  console.error("CopilotChat: Transcription failed", error);
16115
- if (error instanceof TranscriptionError) {
16116
- const { code, retryable, message } = error.info;
16117
- switch (code) {
16118
- case _copilotkit_shared.TranscriptionErrorCode.RATE_LIMITED:
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.");
15372
+ if (error instanceof _copilotkit_core.TranscriptionError) {
15373
+ const labelKey = (0, _copilotkit_core.ɵtranscriptionErrorMessageKey)(error.info);
15374
+ setTranscriptionError(labelKey ? { labelKey } : { text: error.info.message });
15375
+ } else setTranscriptionError({ labelKey: "transcriptionErrorGenericText" });
16142
15376
  } finally {
16143
15377
  setIsTranscribing(false);
16144
15378
  }
@@ -16170,11 +15404,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
16170
15404
  const effectiveStopHandler = agent.isRunning && hasMessages ? providedStopHandler ?? stopCurrentRun : providedStopHandler;
16171
15405
  const showTranscription = isTranscriptionEnabled && isMediaRecorderSupported;
16172
15406
  const effectiveMode = isTranscribing ? "processing" : transcribeMode;
16173
- const messages = (0, react.useMemo)(() => [...agent.messages], [agent.messages.map((m) => {
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(",")]);
15407
+ const messages = (0, react.useMemo)(() => [...agent.messages], [(0, _copilotkit_core.ɵmessagesFingerprint)(agent.messages)]);
16178
15408
  const lastUserMessageId = (0, react.useMemo)(() => {
16179
15409
  for (let i = messages.length - 1; i >= 0; i--) if (messages[i].role === "user") return messages[i].id;
16180
15410
  return null;
@@ -16246,7 +15476,11 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
16246
15476
  fontSize: "14px",
16247
15477
  zIndex: 50
16248
15478
  },
16249
- children: transcriptionError
15479
+ children: "labelKey" in transcriptionError ? {
15480
+ ..._copilotkit_core.CopilotChatDefaultLabels,
15481
+ ...existingConfig?.labels,
15482
+ ...labels
15483
+ }[transcriptionError.labelKey] : transcriptionError.text
16250
15484
  }),
16251
15485
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LastUserMessageContext.Provider, {
16252
15486
  value: lastUserMessageState,
@@ -16269,16 +15503,18 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
16269
15503
  //#endregion
16270
15504
  //#region src/components/chat/CopilotChatToggleButton.tsx
16271
15505
  const ICON_CLASS = "cpk-chat-toggle-button-icon";
16272
- const DefaultOpenIcon = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.MessageCircle, {
15506
+ const DefaultOpenIcon = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
16273
15507
  className: className ?? ICON_CLASS,
16274
15508
  strokeWidth: 1.75,
16275
15509
  fill: "currentColor",
16276
- ...props
15510
+ ...props,
15511
+ name: "MessageCircle"
16277
15512
  });
16278
- const DefaultCloseIcon = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, {
15513
+ const DefaultCloseIcon = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
16279
15514
  className: className ?? ICON_CLASS,
16280
15515
  strokeWidth: 1.75,
16281
- ...props
15516
+ ...props,
15517
+ name: "X"
16282
15518
  });
16283
15519
  DefaultOpenIcon.displayName = "CopilotChatToggleButton.OpenIcon";
16284
15520
  DefaultCloseIcon.displayName = "CopilotChatToggleButton.CloseIcon";
@@ -16287,7 +15523,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
16287
15523
  const CopilotChatToggleButton = react.default.forwardRef(function CopilotChatToggleButton({ openIcon, closeIcon, className, ...buttonProps }, ref) {
16288
15524
  const { onClick, type, disabled, ...restProps } = buttonProps;
16289
15525
  const configuration = useCopilotChatConfiguration();
16290
- const labels = configuration?.labels ?? CopilotChatDefaultLabels;
15526
+ const labels = configuration?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
16291
15527
  const [fallbackOpen, setFallbackOpen] = (0, react.useState)(false);
16292
15528
  const isOpen = configuration?.isModalOpen ?? fallbackOpen;
16293
15529
  const setModalOpen = configuration?.setModalOpen ?? setFallbackOpen;
@@ -16404,7 +15640,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
16404
15640
  }
16405
15641
  function CopilotModalHeader({ title, titleContent, closeButton, drawerLauncher, children, className, ...rest }) {
16406
15642
  const configuration = useCopilotChatConfiguration();
16407
- const fallbackTitle = configuration?.labels.modalHeaderTitle ?? CopilotChatDefaultLabels.modalHeaderTitle;
15643
+ const fallbackTitle = configuration?.labels.modalHeaderTitle ?? _copilotkit_core.CopilotChatDefaultLabels.modalHeaderTitle;
16408
15644
  const resolvedTitle = title ?? fallbackTitle;
16409
15645
  const isMobile = useIsMobileViewport();
16410
15646
  const drawerRegistered = (configuration?.drawerRegistered ?? false) && isMobile;
@@ -16460,28 +15696,30 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
16460
15696
  children
16461
15697
  });
16462
15698
  _CopilotModalHeader.CloseButton = ({ className, ...props }) => {
16463
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
15699
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
16464
15700
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
16465
15701
  type: "button",
16466
15702
  "data-testid": "copilot-close-button",
16467
15703
  className: cn("cpk-modal-header-close-button", className),
16468
15704
  "aria-label": labels.modalHeaderCloseButtonLabel,
16469
15705
  ...props,
16470
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, {
15706
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
15707
+ name: "X",
16471
15708
  className: "cpk-modal-header-close-icon",
16472
15709
  "aria-hidden": "true"
16473
15710
  })
16474
15711
  });
16475
15712
  };
16476
15713
  _CopilotModalHeader.DrawerLauncher = ({ className, ...props }) => {
16477
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
15714
+ const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
16478
15715
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
16479
15716
  type: "button",
16480
15717
  "data-testid": "copilot-threads-drawer-launcher",
16481
15718
  className: cn("cpk-modal-header-drawer-launcher", className),
16482
15719
  "aria-label": labels.modalHeaderThreadsButtonLabel,
16483
15720
  ...props,
16484
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.PanelLeftOpen, {
15721
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
15722
+ name: "PanelLeftOpen",
16485
15723
  className: "cpk-modal-header-drawer-launcher-icon",
16486
15724
  "aria-hidden": "true"
16487
15725
  })
@@ -16586,7 +15824,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
16586
15824
  paddingBottom: "env(safe-area-inset-bottom)"
16587
15825
  },
16588
15826
  "aria-hidden": !isSidebarOpen,
16589
- "aria-label": configuration?.labels.sidebarLabel ?? CopilotChatDefaultLabels.sidebarLabel,
15827
+ "aria-label": configuration?.labels.sidebarLabel ?? _copilotkit_core.CopilotChatDefaultLabels.sidebarLabel,
16590
15828
  role: "complementary",
16591
15829
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
16592
15830
  className: "cpk-sidebar-view-panel",
@@ -16667,7 +15905,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
16667
15905
  const configuration = useCopilotChatConfiguration();
16668
15906
  const isPopupOpen = configuration?.isModalOpen ?? false;
16669
15907
  const setModalOpen = configuration?.setModalOpen;
16670
- const labels = configuration?.labels ?? CopilotChatDefaultLabels;
15908
+ const labels = configuration?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
16671
15909
  const containerRef = (0, react.useRef)(null);
16672
15910
  const [isRendered, setIsRendered] = (0, react.useState)(isPopupOpen);
16673
15911
  const [isAnimatingOut, setIsAnimatingOut] = (0, react.useState)(false);
@@ -17374,7 +16612,6 @@ Object.defineProperty(exports, 'BaseMessageSchema', {
17374
16612
  return _ag_ui_core_schemas.BaseMessageSchema;
17375
16613
  }
17376
16614
  });
17377
- exports.BasicMarkdownRenderer = BasicMarkdownRenderer;
17378
16615
  Object.defineProperty(exports, 'CompatibilityBoundary', {
17379
16616
  enumerable: true,
17380
16617
  get: function () {
@@ -17410,6 +16647,12 @@ exports.CopilotChatAttachmentQueue = CopilotChatAttachmentQueue;
17410
16647
  exports.CopilotChatAttachmentRenderer = CopilotChatAttachmentRenderer;
17411
16648
  exports.CopilotChatAudioRecorder = CopilotChatAudioRecorder;
17412
16649
  exports.CopilotChatConfigurationProvider = CopilotChatConfigurationProvider;
16650
+ Object.defineProperty(exports, 'CopilotChatDefaultLabels', {
16651
+ enumerable: true,
16652
+ get: function () {
16653
+ return _copilotkit_core.CopilotChatDefaultLabels;
16654
+ }
16655
+ });
17413
16656
  exports.CopilotChatInput = CopilotChatInput_default;
17414
16657
  exports.CopilotChatMessageView = CopilotChatMessageView;
17415
16658
  exports.CopilotChatReasoningMessage = CopilotChatReasoningMessage_default;
@@ -17484,6 +16727,12 @@ Object.defineProperty(exports, 'CustomEventSchema', {
17484
16727
  return _ag_ui_core_schemas.CustomEventSchema;
17485
16728
  }
17486
16729
  });
16730
+ Object.defineProperty(exports, 'DEFAULT_OPEN_GENERATIVE_UI_DESIGN_SKILL', {
16731
+ enumerable: true,
16732
+ get: function () {
16733
+ return _copilotkit_core.DEFAULT_OPEN_GENERATIVE_UI_DESIGN_SKILL;
16734
+ }
16735
+ });
17487
16736
  Object.defineProperty(exports, 'DataSourceSchema', {
17488
16737
  enumerable: true,
17489
16738
  get: function () {
@@ -17574,6 +16823,12 @@ Object.defineProperty(exports, 'FunctionMiddleware', {
17574
16823
  return _ag_ui_client.FunctionMiddleware;
17575
16824
  }
17576
16825
  });
16826
+ Object.defineProperty(exports, 'GENERATE_SANDBOXED_UI_TOOL_NAME', {
16827
+ enumerable: true,
16828
+ get: function () {
16829
+ return _copilotkit_core.GENERATE_SANDBOXED_UI_TOOL_NAME;
16830
+ }
16831
+ });
17577
16832
  exports.GenerateSandboxedUiArgsSchema = GenerateSandboxedUiArgsSchema;
17578
16833
  Object.defineProperty(exports, 'HttpAgent', {
17579
16834
  enumerable: true,
@@ -17594,7 +16849,12 @@ Object.defineProperty(exports, 'INSPECTOR_THREAD_BRIDGE_PLUGIN_ID', {
17594
16849
  }
17595
16850
  });
17596
16851
  exports.INTELLIGENCE_TURN_HEAD = INTELLIGENCE_TURN_HEAD;
17597
- exports.INTERRUPT_EVENT_NAME = INTERRUPT_EVENT_NAME;
16852
+ Object.defineProperty(exports, 'INTERRUPT_EVENT_NAME', {
16853
+ enumerable: true,
16854
+ get: function () {
16855
+ return _copilotkit_core.INTERRUPT_EVENT_NAME;
16856
+ }
16857
+ });
17598
16858
  Object.defineProperty(exports, 'IdentityCapabilitiesSchema', {
17599
16859
  enumerable: true,
17600
16860
  get: function () {
@@ -17755,6 +17015,12 @@ Object.defineProperty(exports, 'MultimodalOutputCapabilitiesSchema', {
17755
17015
  return _ag_ui_core_schemas.MultimodalOutputCapabilitiesSchema;
17756
17016
  }
17757
17017
  });
17018
+ Object.defineProperty(exports, 'OPEN_GENERATIVE_UI_ACTIVITY_TYPE', {
17019
+ enumerable: true,
17020
+ get: function () {
17021
+ return _copilotkit_core.OPEN_GENERATIVE_UI_ACTIVITY_TYPE;
17022
+ }
17023
+ });
17758
17024
  exports.OpenGenerativeUIActivityRenderer = OpenGenerativeUIActivityRenderer;
17759
17025
  exports.OpenGenerativeUIActivityType = OpenGenerativeUIActivityType;
17760
17026
  exports.OpenGenerativeUIContentSchema = OpenGenerativeUIContentSchema;
@@ -18151,6 +17417,18 @@ Object.defineProperty(exports, 'ToolsCapabilitiesSchema', {
18151
17417
  return _ag_ui_core_schemas.ToolsCapabilitiesSchema;
18152
17418
  }
18153
17419
  });
17420
+ Object.defineProperty(exports, 'TranscriptionError', {
17421
+ enumerable: true,
17422
+ get: function () {
17423
+ return _copilotkit_core.TranscriptionError;
17424
+ }
17425
+ });
17426
+ Object.defineProperty(exports, 'TranscriptionErrorCode', {
17427
+ enumerable: true,
17428
+ get: function () {
17429
+ return _copilotkit_core.TranscriptionErrorCode;
17430
+ }
17431
+ });
18154
17432
  Object.defineProperty(exports, 'TransportCapabilitiesSchema', {
18155
17433
  enumerable: true,
18156
17434
  get: function () {
@@ -18476,12 +17754,6 @@ Object.defineProperty(exports, 'onInspectorViewThreadResult', {
18476
17754
  return _copilotkit_core.onInspectorViewThreadResult;
18477
17755
  }
18478
17756
  });
18479
- Object.defineProperty(exports, 'parseMarkdown', {
18480
- enumerable: true,
18481
- get: function () {
18482
- return _copilotkit_core.parseMarkdown;
18483
- }
18484
- });
18485
17757
  Object.defineProperty(exports, 'parseProtoStream', {
18486
17758
  enumerable: true,
18487
17759
  get: function () {
@@ -18599,8 +17871,6 @@ exports.useHumanInTheLoop = useHumanInTheLoop;
18599
17871
  exports.useInterrupt = useInterrupt;
18600
17872
  exports.useLearnFromUserAction = useLearnFromUserAction;
18601
17873
  exports.useLearnFromUserActionInCurrentThread = useLearnFromUserActionInCurrentThread;
18602
- exports.useLearningContainers = useLearningContainers;
18603
- exports.useLearningContainersInCurrentThread = useLearningContainersInCurrentThread;
18604
17874
  exports.useLicenseContext = useLicenseContext;
18605
17875
  exports.useMarkdownRenderer = useMarkdownRenderer;
18606
17876
  exports.useMemories = useMemories;
@@ -18641,6 +17911,12 @@ Object.defineProperty(exports, 'ɵMAX_SOCKET_RETRIES', {
18641
17911
  return _copilotkit_core.ɵMAX_SOCKET_RETRIES;
18642
17912
  }
18643
17913
  });
17914
+ Object.defineProperty(exports, 'ɵOpenGenerativeUIController', {
17915
+ enumerable: true,
17916
+ get: function () {
17917
+ return _copilotkit_core.ɵOpenGenerativeUIController;
17918
+ }
17919
+ });
18644
17920
  Object.defineProperty(exports, 'ɵRUNTIME_PROBE_TIMEOUT_MS', {
18645
17921
  enumerable: true,
18646
17922
  get: function () {
@@ -18659,6 +17935,30 @@ Object.defineProperty(exports, 'ɵclearAgentInterruptState', {
18659
17935
  return _copilotkit_core.ɵclearAgentInterruptState;
18660
17936
  }
18661
17937
  });
17938
+ Object.defineProperty(exports, 'ɵcomposerButtonState', {
17939
+ enumerable: true,
17940
+ get: function () {
17941
+ return _copilotkit_core.ɵcomposerButtonState;
17942
+ }
17943
+ });
17944
+ Object.defineProperty(exports, 'ɵcopilotIconSvgAttributes', {
17945
+ enumerable: true,
17946
+ get: function () {
17947
+ return _copilotkit_core.ɵcopilotIconSvgAttributes;
17948
+ }
17949
+ });
17950
+ Object.defineProperty(exports, 'ɵcopilotIcons', {
17951
+ enumerable: true,
17952
+ get: function () {
17953
+ return _copilotkit_core.ɵcopilotIcons;
17954
+ }
17955
+ });
17956
+ Object.defineProperty(exports, 'ɵcountFailedToolCalls', {
17957
+ enumerable: true,
17958
+ get: function () {
17959
+ return _copilotkit_core.ɵcountFailedToolCalls;
17960
+ }
17961
+ });
18662
17962
  Object.defineProperty(exports, 'ɵcreateMemoryStore', {
18663
17963
  enumerable: true,
18664
17964
  get: function () {
@@ -18677,12 +17977,108 @@ Object.defineProperty(exports, 'ɵcreateThreadStore', {
18677
17977
  return _copilotkit_core.ɵcreateThreadStore;
18678
17978
  }
18679
17979
  });
17980
+ Object.defineProperty(exports, 'ɵdeduplicateMessages', {
17981
+ enumerable: true,
17982
+ get: function () {
17983
+ return _copilotkit_core.ɵdeduplicateMessages;
17984
+ }
17985
+ });
17986
+ Object.defineProperty(exports, 'ɵextractCompleteStyles', {
17987
+ enumerable: true,
17988
+ get: function () {
17989
+ return _copilotkit_core.ɵextractCompleteStyles;
17990
+ }
17991
+ });
17992
+ Object.defineProperty(exports, 'ɵformatCountLabel', {
17993
+ enumerable: true,
17994
+ get: function () {
17995
+ return _copilotkit_core.ɵformatCountLabel;
17996
+ }
17997
+ });
17998
+ Object.defineProperty(exports, 'ɵformatLabel', {
17999
+ enumerable: true,
18000
+ get: function () {
18001
+ return _copilotkit_core.ɵformatLabel;
18002
+ }
18003
+ });
18004
+ Object.defineProperty(exports, 'ɵformatReasoningDuration', {
18005
+ enumerable: true,
18006
+ get: function () {
18007
+ return _copilotkit_core.ɵformatReasoningDuration;
18008
+ }
18009
+ });
18010
+ Object.defineProperty(exports, 'ɵformatToolNames', {
18011
+ enumerable: true,
18012
+ get: function () {
18013
+ return _copilotkit_core.ɵformatToolNames;
18014
+ }
18015
+ });
18016
+ Object.defineProperty(exports, 'ɵformatWorkDuration', {
18017
+ enumerable: true,
18018
+ get: function () {
18019
+ return _copilotkit_core.ɵformatWorkDuration;
18020
+ }
18021
+ });
18680
18022
  Object.defineProperty(exports, 'ɵgetAgentInterruptState', {
18681
18023
  enumerable: true,
18682
18024
  get: function () {
18683
18025
  return _copilotkit_core.ɵgetAgentInterruptState;
18684
18026
  }
18685
18027
  });
18028
+ Object.defineProperty(exports, 'ɵgetArgumentPreview', {
18029
+ enumerable: true,
18030
+ get: function () {
18031
+ return _copilotkit_core.ɵgetArgumentPreview;
18032
+ }
18033
+ });
18034
+ Object.defineProperty(exports, 'ɵgetLatestTurnKey', {
18035
+ enumerable: true,
18036
+ get: function () {
18037
+ return _copilotkit_core.ɵgetLatestTurnKey;
18038
+ }
18039
+ });
18040
+ Object.defineProperty(exports, 'ɵgetToolCallLayouts', {
18041
+ enumerable: true,
18042
+ get: function () {
18043
+ return _copilotkit_core.ɵgetToolCallLayouts;
18044
+ }
18045
+ });
18046
+ Object.defineProperty(exports, 'ɵgetToolCallPreview', {
18047
+ enumerable: true,
18048
+ get: function () {
18049
+ return _copilotkit_core.ɵgetToolCallPreview;
18050
+ }
18051
+ });
18052
+ Object.defineProperty(exports, 'ɵgetToolCallRendererNames', {
18053
+ enumerable: true,
18054
+ get: function () {
18055
+ return _copilotkit_core.ɵgetToolCallRendererNames;
18056
+ }
18057
+ });
18058
+ Object.defineProperty(exports, 'ɵgetToolCallRowStatus', {
18059
+ enumerable: true,
18060
+ get: function () {
18061
+ return _copilotkit_core.ɵgetToolCallRowStatus;
18062
+ }
18063
+ });
18064
+ Object.defineProperty(exports, 'ɵgetToolResults', {
18065
+ enumerable: true,
18066
+ get: function () {
18067
+ return _copilotkit_core.ɵgetToolResults;
18068
+ }
18069
+ });
18070
+ Object.defineProperty(exports, 'ɵgetTurnWork', {
18071
+ enumerable: true,
18072
+ get: function () {
18073
+ return _copilotkit_core.ɵgetTurnWork;
18074
+ }
18075
+ });
18076
+ Object.defineProperty(exports, 'ɵgetWorkOpenState', {
18077
+ enumerable: true,
18078
+ get: function () {
18079
+ return _copilotkit_core.ɵgetWorkOpenState;
18080
+ }
18081
+ });
18686
18082
  Object.defineProperty(exports, 'ɵisCopilotKitFeature', {
18687
18083
  enumerable: true,
18688
18084
  get: function () {
@@ -18701,12 +18097,30 @@ Object.defineProperty(exports, 'ɵisRetryableMemoryStatus', {
18701
18097
  return _copilotkit_core.ɵisRetryableMemoryStatus;
18702
18098
  }
18703
18099
  });
18100
+ Object.defineProperty(exports, 'ɵisTurnWorkOpen', {
18101
+ enumerable: true,
18102
+ get: function () {
18103
+ return _copilotkit_core.ɵisTurnWorkOpen;
18104
+ }
18105
+ });
18106
+ Object.defineProperty(exports, 'ɵisTurnWorking', {
18107
+ enumerable: true,
18108
+ get: function () {
18109
+ return _copilotkit_core.ɵisTurnWorking;
18110
+ }
18111
+ });
18704
18112
  Object.defineProperty(exports, 'ɵjoinPhoenixChannel$', {
18705
18113
  enumerable: true,
18706
18114
  get: function () {
18707
18115
  return _copilotkit_core.ɵjoinPhoenixChannel$;
18708
18116
  }
18709
18117
  });
18118
+ Object.defineProperty(exports, 'ɵloadWebsandbox', {
18119
+ enumerable: true,
18120
+ get: function () {
18121
+ return _copilotkit_core.ɵloadWebsandbox;
18122
+ }
18123
+ });
18710
18124
  Object.defineProperty(exports, 'ɵmapMemoryMetadataEvent', {
18711
18125
  enumerable: true,
18712
18126
  get: function () {
@@ -18737,6 +18151,12 @@ Object.defineProperty(exports, 'ɵmemoryRestEvents', {
18737
18151
  return _copilotkit_core.ɵmemoryRestEvents;
18738
18152
  }
18739
18153
  });
18154
+ Object.defineProperty(exports, 'ɵmessagesFingerprint', {
18155
+ enumerable: true,
18156
+ get: function () {
18157
+ return _copilotkit_core.ɵmessagesFingerprint;
18158
+ }
18159
+ });
18740
18160
  Object.defineProperty(exports, 'ɵobservePhoenixEvent$', {
18741
18161
  enumerable: true,
18742
18162
  get: function () {
@@ -18773,6 +18193,60 @@ Object.defineProperty(exports, 'ɵphoenixSocket$', {
18773
18193
  return _copilotkit_core.ɵphoenixSocket$;
18774
18194
  }
18775
18195
  });
18196
+ Object.defineProperty(exports, 'ɵpluralize', {
18197
+ enumerable: true,
18198
+ get: function () {
18199
+ return _copilotkit_core.ɵpluralize;
18200
+ }
18201
+ });
18202
+ Object.defineProperty(exports, 'ɵprocessPartialHtml', {
18203
+ enumerable: true,
18204
+ get: function () {
18205
+ return _copilotkit_core.ɵprocessPartialHtml;
18206
+ }
18207
+ });
18208
+ Object.defineProperty(exports, 'ɵrecordWorkTime', {
18209
+ enumerable: true,
18210
+ get: function () {
18211
+ return _copilotkit_core.ɵrecordWorkTime;
18212
+ }
18213
+ });
18214
+ Object.defineProperty(exports, 'ɵresolveActivityRenderer', {
18215
+ enumerable: true,
18216
+ get: function () {
18217
+ return _copilotkit_core.ɵresolveActivityRenderer;
18218
+ }
18219
+ });
18220
+ Object.defineProperty(exports, 'ɵresolveComposerKey', {
18221
+ enumerable: true,
18222
+ get: function () {
18223
+ return _copilotkit_core.ɵresolveComposerKey;
18224
+ }
18225
+ });
18226
+ Object.defineProperty(exports, 'ɵresolveCustomMessageRenderers', {
18227
+ enumerable: true,
18228
+ get: function () {
18229
+ return _copilotkit_core.ɵresolveCustomMessageRenderers;
18230
+ }
18231
+ });
18232
+ Object.defineProperty(exports, 'ɵresolveLicenseState', {
18233
+ enumerable: true,
18234
+ get: function () {
18235
+ return _copilotkit_core.ɵresolveLicenseState;
18236
+ }
18237
+ });
18238
+ Object.defineProperty(exports, 'ɵresolveThreadsLicense', {
18239
+ enumerable: true,
18240
+ get: function () {
18241
+ return _copilotkit_core.ɵresolveThreadsLicense;
18242
+ }
18243
+ });
18244
+ Object.defineProperty(exports, 'ɵresolveToolCallRenderer', {
18245
+ enumerable: true,
18246
+ get: function () {
18247
+ return _copilotkit_core.ɵresolveToolCallRenderer;
18248
+ }
18249
+ });
18776
18250
  Object.defineProperty(exports, 'ɵrunMcpFollowUp', {
18777
18251
  enumerable: true,
18778
18252
  get: function () {
@@ -18857,12 +18331,30 @@ Object.defineProperty(exports, 'ɵselectThreadsIsLoading', {
18857
18331
  return _copilotkit_core.ɵselectThreadsIsLoading;
18858
18332
  }
18859
18333
  });
18334
+ Object.defineProperty(exports, 'ɵstringifyToolCallPayload', {
18335
+ enumerable: true,
18336
+ get: function () {
18337
+ return _copilotkit_core.ɵstringifyToolCallPayload;
18338
+ }
18339
+ });
18860
18340
  Object.defineProperty(exports, 'ɵthreadAdapterEvents', {
18861
18341
  enumerable: true,
18862
18342
  get: function () {
18863
18343
  return _copilotkit_core.ɵthreadAdapterEvents;
18864
18344
  }
18865
18345
  });
18346
+ Object.defineProperty(exports, 'ɵtranscribeAudio', {
18347
+ enumerable: true,
18348
+ get: function () {
18349
+ return _copilotkit_core.ɵtranscribeAudio;
18350
+ }
18351
+ });
18352
+ Object.defineProperty(exports, 'ɵtranscriptionErrorMessageKey', {
18353
+ enumerable: true,
18354
+ get: function () {
18355
+ return _copilotkit_core.ɵtranscriptionErrorMessageKey;
18356
+ }
18357
+ });
18866
18358
  Object.defineProperty(exports, 'ɵwithHeaderDefaults', {
18867
18359
  enumerable: true,
18868
18360
  get: function () {