@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.cjs CHANGED
@@ -1,25 +1,23 @@
1
1
  "use client";
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_MarkdownSurfaces = require('./MarkdownSurfaces-S4wfUl3J.cjs');
4
+ const require_MarkdownSurfaces = require('./MarkdownSurfaces-Ije2ZQh0.cjs');
5
5
  let _copilotkit_core = require("@copilotkit/core");
6
6
  let _ag_ui_client = require("@ag-ui/client");
7
7
  let react = require("react");
8
8
  react = require_MarkdownSurfaces.__toESM(react);
9
9
  let react_jsx_runtime = require("react/jsx-runtime");
10
- let lucide_react = require("lucide-react");
11
10
  let _copilotkit_shared = require("@copilotkit/shared");
12
11
  let _copilotkit_react_core_context = require("@copilotkit/react-core/context");
13
- let _radix_ui_react_slot = require("@radix-ui/react-slot");
14
12
  let _radix_ui_react_tooltip = require("@radix-ui/react-tooltip");
15
13
  _radix_ui_react_tooltip = require_MarkdownSurfaces.__toESM(_radix_ui_react_tooltip);
16
14
  let _radix_ui_react_dropdown_menu = require("@radix-ui/react-dropdown-menu");
17
15
  _radix_ui_react_dropdown_menu = require_MarkdownSurfaces.__toESM(_radix_ui_react_dropdown_menu);
18
16
  let _ag_ui_core = require("@ag-ui/core");
19
- let zod = require("zod");
20
17
  let _copilotkit_mcp_apps_renderer_activity = require("@copilotkit/mcp-apps-renderer/activity");
18
+ let zod = require("zod");
19
+ zod = require_MarkdownSurfaces.__toESM(zod);
21
20
  let _copilotkit_a2ui_renderer = require("@copilotkit/a2ui-renderer");
22
- let zod_to_json_schema = require("zod-to-json-schema");
23
21
  let _a2ui_web_core_v0_9 = require("@a2ui/web_core/v0_9");
24
22
  let _copilotkit_core_styles = require("@copilotkit/core/styles");
25
23
  let _radix_ui_react_popover = require("@radix-ui/react-popover");
@@ -30,111 +28,6 @@ let use_stick_to_bottom = require("use-stick-to-bottom");
30
28
  let _copilotkit_web_components_threads_drawer = require("@copilotkit/web-components/threads-drawer");
31
29
  let _ag_ui_core_schemas = require("@ag-ui/core/schemas");
32
30
 
33
- //#region src/components/chat/BasicMarkdownRenderer.tsx
34
- const SAFE_HREF = /^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i;
35
- const SAFE_IMG_SRC = /^(https?:|data:image\/(?!svg)|\/|\.\/|\.\.\/)/i;
36
- function sanitizeHref(href) {
37
- if (!href) return void 0;
38
- return SAFE_HREF.test(href.trim()) ? href : void 0;
39
- }
40
- function sanitizeImgSrc(src) {
41
- if (!src) return void 0;
42
- return SAFE_IMG_SRC.test(src.trim()) ? src : void 0;
43
- }
44
- /**
45
- * Dependency-light built-in markdown renderer (basic GFM). Walks the
46
- * framework-agnostic token tree from `@copilotkit/core` into React elements.
47
- * No syntax highlighting, no math, no table/image action buttons — plug in a
48
- * custom renderer via `CopilotKitProvider markdownRenderer={...}` for those.
49
- */
50
- function BasicMarkdownRenderer({ content, className }) {
51
- const tokens = react.default.useMemo(() => (0, _copilotkit_core.parseMarkdown)(content ?? ""), [content]);
52
- if (!tokens.length) return null;
53
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
54
- className,
55
- children: tokens.map((t, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BlockToken, { token: t }, i))
56
- });
57
- }
58
- function renderInline(tokens) {
59
- if (!tokens) return null;
60
- return tokens.map((token, i) => {
61
- switch (token.type) {
62
- case "text": return "tokens" in token && token.tokens ? renderInline(token.tokens) : token.text;
63
- case "strong": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: renderInline(token.tokens) }, i);
64
- case "em": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("em", { children: renderInline(token.tokens) }, i);
65
- case "del": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("del", { children: renderInline(token.tokens) }, i);
66
- case "codespan": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
67
- className: "cpk-markdown-inline-code",
68
- children: token.text
69
- }, i);
70
- case "br": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("br", {}, i);
71
- case "link": {
72
- const l = token;
73
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
74
- href: sanitizeHref(l.href),
75
- target: "_blank",
76
- rel: "noopener noreferrer",
77
- children: l.tokens ? renderInline(l.tokens) : l.text
78
- }, i);
79
- }
80
- case "image": {
81
- const img = token;
82
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
83
- src: sanitizeImgSrc(img.href),
84
- alt: img.text,
85
- className: "cpk-markdown-image"
86
- }, i);
87
- }
88
- case "escape": return token.text;
89
- default: return "text" in token ? token.text : null;
90
- }
91
- });
92
- }
93
- function BlockToken({ token }) {
94
- switch (token.type) {
95
- case "space": return null;
96
- case "heading": {
97
- const h = token;
98
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(`h${Math.min(Math.max(h.depth, 1), 6)}`, { children: renderInline(h.tokens) });
99
- }
100
- case "paragraph": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: renderInline(token.tokens ?? []) });
101
- 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)) });
102
- case "code": {
103
- const c = token;
104
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
105
- className: "cpk-markdown-code-block",
106
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
107
- "data-language": c.lang || void 0,
108
- children: c.text
109
- })
110
- });
111
- }
112
- case "hr": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("hr", {});
113
- case "list": {
114
- const list = token;
115
- 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));
116
- return list.ordered ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ol", {
117
- start: typeof list.start === "number" ? list.start : void 0,
118
- children: items
119
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", { children: items });
120
- }
121
- case "table": {
122
- const tbl = token;
123
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
124
- className: "cpk-markdown-table-container",
125
- 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)) })] })
126
- });
127
- }
128
- case "text": {
129
- const t = token;
130
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t.tokens ? renderInline(t.tokens) : t.text });
131
- }
132
- default: return "text" in token ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: token.text }) : null;
133
- }
134
- }
135
- BasicMarkdownRenderer.displayName = "BasicMarkdownRenderer";
136
-
137
- //#endregion
138
31
  //#region src/components/ui/button.tsx
139
32
  const variantClasses = {
140
33
  default: "cpk-button-default",
@@ -162,8 +55,8 @@ const sizeClasses = {
162
55
  function buttonVariants({ variant, size, className, class: classProp } = {}) {
163
56
  return require_MarkdownSurfaces.cn("cpk-button", variant !== null && variantClasses[variant ?? "default"], size !== null && sizeClasses[size ?? "default"], classProp, className);
164
57
  }
165
- const Button = react.forwardRef(function Button({ className, variant, size, asChild = false, ...props }, ref) {
166
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(asChild ? _radix_ui_react_slot.Slot : "button", {
58
+ const Button = react.forwardRef(function Button({ className, variant, size, ...props }, ref) {
59
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
167
60
  ref,
168
61
  "data-slot": "button",
169
62
  className: buttonVariants({
@@ -268,7 +161,10 @@ function DropdownMenuSubTrigger({ className, inset, children, ...props }) {
268
161
  "data-inset": inset,
269
162
  className: require_MarkdownSurfaces.cn("cpk-dropdown-menu-sub-trigger", className),
270
163
  ...props,
271
- children: [children, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRightIcon, { className: "cpk-dropdown-menu-sub-trigger-icon" })]
164
+ children: [children, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
165
+ name: "ChevronRight",
166
+ className: "cpk-dropdown-menu-sub-trigger-icon"
167
+ })]
272
168
  });
273
169
  }
274
170
  function DropdownMenuSubContent({ className, ...props }) {
@@ -508,7 +404,7 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
508
404
  const audioRecorderRef = (0, react.useRef)(null);
509
405
  const slashMenuRef = (0, react.useRef)(null);
510
406
  const config = require_MarkdownSurfaces.useCopilotChatConfiguration();
511
- const labels = config?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
407
+ const labels = config?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
512
408
  const previousModalStateRef = (0, react.useRef)(void 0);
513
409
  const measurementCanvasRef = (0, react.useRef)(null);
514
410
  const measurementsRef = (0, react.useRef)({
@@ -629,6 +525,14 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
629
525
  inputRef.current?.focus();
630
526
  });
631
527
  }, [clearInputValue]);
528
+ const composerInput = {
529
+ mode,
530
+ isRunning,
531
+ value: resolvedValue,
532
+ canSubmit: !!onSubmitMessage,
533
+ canStop: !!onStop
534
+ };
535
+ const { isProcessing, action: buttonAction, disabled: buttonDisabled } = (0, _copilotkit_core.ɵcomposerButtonState)(composerInput);
632
536
  const handleKeyDown = (e) => {
633
537
  if (e.nativeEvent.isComposing || e.keyCode === 229) return;
634
538
  if (commandQuery !== null && mode === "input") {
@@ -667,11 +571,15 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
667
571
  return;
668
572
  }
669
573
  }
670
- if (e.key === "Enter" && !e.shiftKey) {
671
- e.preventDefault();
672
- if (isProcessing && !canSend) onStop?.();
673
- else send();
674
- }
574
+ if (e.key === "Enter" && !e.shiftKey) e.preventDefault();
575
+ const action = (0, _copilotkit_core.ɵresolveComposerKey)({
576
+ key: e.key,
577
+ shiftKey: e.shiftKey,
578
+ isComposing: e.nativeEvent.isComposing,
579
+ keyCode: e.keyCode
580
+ }, composerInput);
581
+ if (action === "stop") onStop?.();
582
+ else if (action === "send") send();
675
583
  };
676
584
  const send = () => {
677
585
  if (!onSubmitMessage) return;
@@ -696,9 +604,6 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
696
604
  autoFocus,
697
605
  className: isExpanded ? "cpk-chat-input-textarea-expanded" : "cpk-chat-input-textarea-compact"
698
606
  });
699
- const isProcessing = mode !== "transcribe" && isRunning;
700
- const canSend = resolvedValue.trim().length > 0 && !!onSubmitMessage;
701
- const canStop = !!onStop;
702
607
  const handleSendButtonClick = () => {
703
608
  if (isProcessing) {
704
609
  onStop?.();
@@ -707,12 +612,15 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
707
612
  send();
708
613
  };
709
614
  const BoundAudioRecorder = require_MarkdownSurfaces.renderSlot(audioRecorder, CopilotChatAudioRecorder, { ref: audioRecorderRef });
710
- const showsStop = isProcessing && canStop;
615
+ const showsStop = buttonAction === "stop";
711
616
  const BoundSendButton = require_MarkdownSurfaces.renderSlot(sendButton, CopilotChatInput.SendButton, {
712
617
  onClick: handleSendButtonClick,
713
- disabled: isProcessing ? !canStop : !canSend,
618
+ disabled: buttonDisabled,
714
619
  "aria-label": showsStop ? labels.chatInputToolbarStopButtonLabel : labels.chatInputToolbarSendButtonLabel,
715
- children: showsStop ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Square, { className: "cpk-chat-input-stop-icon" }) : void 0
620
+ children: showsStop ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
621
+ name: "Square",
622
+ className: "cpk-chat-input-stop-icon"
623
+ }) : void 0
716
624
  });
717
625
  const BoundStartTranscribeButton = require_MarkdownSurfaces.renderSlot(startTranscribeButton, CopilotChatInput.StartTranscribeButton, { onClick: onStartTranscribe });
718
626
  const BoundCancelTranscribeButton = require_MarkdownSurfaces.renderSlot(cancelTranscribeButton, CopilotChatInput.CancelTranscribeButton, { onClick: onCancelTranscribe });
@@ -969,7 +877,10 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
969
877
  className: "cpk-chat-input-field",
970
878
  children: mode === "transcribe" ? BoundAudioRecorder : mode === "processing" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
971
879
  className: "cpk-chat-input-processing",
972
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Loader2, { className: "cpk-chat-input-processing-spinner" })
880
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
881
+ name: "Loader2",
882
+ className: "cpk-chat-input-processing-spinner"
883
+ })
973
884
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [BoundTextArea, slashMenu] })
974
885
  }),
975
886
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -1029,7 +940,7 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
1029
940
  }
1030
941
  (function(_CopilotChatInput) {
1031
942
  _CopilotChatInput.SendButton = ({ className, children, ...props }) => {
1032
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
943
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
1033
944
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1034
945
  className: "cpk-chat-input-send",
1035
946
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
@@ -1040,12 +951,15 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
1040
951
  className: require_MarkdownSurfaces.cn("cpk-chat-input-send-button", className),
1041
952
  "aria-label": labels.chatInputToolbarSendButtonLabel,
1042
953
  ...props,
1043
- children: children ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ArrowUp, { className: "cpk-chat-input-send-icon" })
954
+ children: children ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
955
+ name: "ArrowUp",
956
+ className: "cpk-chat-input-send-icon"
957
+ })
1044
958
  })
1045
959
  });
1046
960
  };
1047
961
  const ToolbarButton = _CopilotChatInput.ToolbarButton = ({ icon, labelKey, defaultClassName, className, ...props }) => {
1048
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
962
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
1049
963
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Tooltip, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipTrigger, {
1050
964
  asChild: true,
1051
965
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
@@ -1064,27 +978,36 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
1064
978
  };
1065
979
  _CopilotChatInput.StartTranscribeButton = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
1066
980
  "data-testid": "copilot-start-transcribe-button",
1067
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Mic, { className: "cpk-chat-input-toolbar-icon" }),
981
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
982
+ name: "Mic",
983
+ className: "cpk-chat-input-toolbar-icon"
984
+ }),
1068
985
  labelKey: "chatInputToolbarStartTranscribeButtonLabel",
1069
986
  defaultClassName: "cpk-chat-input-start-transcribe-button",
1070
987
  ...props
1071
988
  });
1072
989
  _CopilotChatInput.CancelTranscribeButton = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
1073
990
  "data-testid": "copilot-cancel-transcribe-button",
1074
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, { className: "cpk-chat-input-toolbar-icon" }),
991
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
992
+ name: "X",
993
+ className: "cpk-chat-input-toolbar-icon"
994
+ }),
1075
995
  labelKey: "chatInputToolbarCancelTranscribeButtonLabel",
1076
996
  defaultClassName: "cpk-chat-input-cancel-transcribe-button",
1077
997
  ...props
1078
998
  });
1079
999
  _CopilotChatInput.FinishTranscribeButton = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
1080
1000
  "data-testid": "copilot-finish-transcribe-button",
1081
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, { className: "cpk-chat-input-toolbar-icon" }),
1001
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
1002
+ name: "Check",
1003
+ className: "cpk-chat-input-toolbar-icon"
1004
+ }),
1082
1005
  labelKey: "chatInputToolbarFinishTranscribeButtonLabel",
1083
1006
  defaultClassName: "cpk-chat-input-finish-transcribe-button",
1084
1007
  ...props
1085
1008
  });
1086
1009
  _CopilotChatInput.AddMenuButton = ({ className, toolsMenu, onAddFile, disabled, ...props }) => {
1087
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
1010
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
1088
1011
  const [mounted, setMounted] = (0, react.useState)(false);
1089
1012
  (0, react.useEffect)(() => setMounted(true), []);
1090
1013
  const menuItems = (0, react.useMemo)(() => {
@@ -1126,7 +1049,10 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
1126
1049
  disabled: isDisabled,
1127
1050
  "aria-label": labels.chatInputToolbarAddButtonLabel,
1128
1051
  ...props,
1129
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Plus, { className: "cpk-chat-input-add-menu-icon" })
1052
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
1053
+ name: "Plus",
1054
+ className: "cpk-chat-input-add-menu-icon"
1055
+ })
1130
1056
  });
1131
1057
  if (!mounted) return button;
1132
1058
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DropdownMenu, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Tooltip, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipTrigger, {
@@ -1152,7 +1078,7 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
1152
1078
  };
1153
1079
  _CopilotChatInput.TextArea = (0, react.forwardRef)(function TextArea({ style, className, autoFocus, placeholder, ...props }, ref) {
1154
1080
  const internalTextareaRef = (0, react.useRef)(null);
1155
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
1081
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
1156
1082
  (0, react.useImperativeHandle)(ref, () => internalTextareaRef.current);
1157
1083
  (0, react.useEffect)(() => {
1158
1084
  if (autoFocus) internalTextareaRef.current?.focus({ preventScroll: true });
@@ -1173,7 +1099,7 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
1173
1099
  });
1174
1100
  _CopilotChatInput.AudioRecorder = CopilotChatAudioRecorder;
1175
1101
  _CopilotChatInput.Disclaimer = ({ className, ...props }) => {
1176
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
1102
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
1177
1103
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1178
1104
  className: require_MarkdownSurfaces.cn("cpk-chat-input-disclaimer", className),
1179
1105
  ...props,
@@ -1269,16 +1195,7 @@ function useToolCallRenderers() {
1269
1195
  */
1270
1196
  function useToolCallRendererNames() {
1271
1197
  const renderers = useToolCallRenderers();
1272
- return (0, react.useMemo)(() => {
1273
- const named = renderers.filter((rc) => rc.name !== "*");
1274
- const wildcards = renderers.filter((rc) => rc.name === "*");
1275
- return {
1276
- named: new Set(named.map((rc) => rc.name)),
1277
- groupedNames: new Set(named.filter((rc) => rc.group).map((rc) => rc.name)),
1278
- wildcard: wildcards.length > 0,
1279
- wildcardGroups: wildcards.some((rc) => rc.group)
1280
- };
1281
- }, [renderers]);
1198
+ return (0, react.useMemo)(() => (0, _copilotkit_core.ɵgetToolCallRendererNames)(renderers), [renderers]);
1282
1199
  }
1283
1200
  /**
1284
1201
  * Hook that returns a function to render tool calls based on the render functions
@@ -1293,18 +1210,17 @@ function useRenderToolCall() {
1293
1210
  const warnedToolNames = (0, react.useRef)(/* @__PURE__ */ new Set());
1294
1211
  const renderToolCalls = useToolCallRenderers();
1295
1212
  const renderToolCall = (0, react.useCallback)(({ toolCall, toolMessage }) => {
1296
- const exactMatches = renderToolCalls.filter((rc) => rc.name === toolCall.function.name);
1297
- const renderConfig = exactMatches.find((rc) => rc.agentId === agentId) || exactMatches.find((rc) => !rc.agentId) || exactMatches[0] || renderToolCalls.find((rc) => rc.name === "*");
1213
+ const renderConfig = (0, _copilotkit_core.ɵresolveToolCallRenderer)(renderToolCalls, toolCall.function.name, agentId);
1298
1214
  if (!renderConfig) {
1299
1215
  if (IS_DEVELOPMENT$1) unrenderedToolNames.current.add(toolCall.function.name);
1300
1216
  return null;
1301
1217
  }
1302
- const RenderComponent = renderConfig.render;
1218
+ const isExecuting = executingToolCallIds.has(toolCall.id);
1303
1219
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolCallRenderer, {
1304
1220
  toolCall,
1305
1221
  toolMessage,
1306
- RenderComponent,
1307
- isExecuting: executingToolCallIds.has(toolCall.id)
1222
+ RenderComponent: renderConfig.render,
1223
+ isExecuting
1308
1224
  }, toolCall.id);
1309
1225
  }, [
1310
1226
  renderToolCalls,
@@ -1326,7 +1242,7 @@ function useRenderToolCall() {
1326
1242
 
1327
1243
  //#endregion
1328
1244
  //#region package.json
1329
- var version$1 = "2.0.0-rc.7";
1245
+ var version$1 = "2.0.0-rc.9";
1330
1246
 
1331
1247
  //#endregion
1332
1248
  //#region src/components/CopilotKitInspector.tsx
@@ -1397,6 +1313,15 @@ function useCopilotKitInspector() {
1397
1313
 
1398
1314
  //#endregion
1399
1315
  //#region src/components/license-warning-banner.tsx
1316
+ const labels = _copilotkit_core.CopilotChatDefaultLabels;
1317
+ /**
1318
+ * The "expires soon" banner text. Without a day count it says "soon", never
1319
+ * "in undefined days".
1320
+ */
1321
+ function expiringMessage(graceRemaining) {
1322
+ if (graceRemaining === void 0) return labels.licenseExpiringText;
1323
+ return (0, _copilotkit_core.ɵformatLabel)(graceRemaining === 1 ? labels.licenseExpiringInDaysOne : labels.licenseExpiringInDaysOther, { days: graceRemaining });
1324
+ }
1400
1325
  const LICENSE_BANNER_OFFSET_PX = 52;
1401
1326
  const LICENSE_BANNER_OFFSET_VAR = "--copilotkit-license-banner-offset";
1402
1327
  const BANNER_STYLES = {
@@ -1487,36 +1412,36 @@ function LicenseWarningBanner({ type, featureName, expiryDate, graceRemaining, o
1487
1412
  switch (type) {
1488
1413
  case "no_license": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BannerShell, {
1489
1414
  severity: "info",
1490
- message: "Powered by CopilotKit",
1491
- actionLabel: "Get a license",
1415
+ message: labels.licensePoweredByText,
1416
+ actionLabel: labels.licenseGetLicenseLabel,
1492
1417
  actionUrl: "https://copilotkit.ai/pricing",
1493
1418
  onDismiss
1494
1419
  });
1495
1420
  case "feature_unlicensed": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BannerShell, {
1496
1421
  severity: "warning",
1497
- message: `⚠ The "${featureName}" feature requires a CopilotKit license.`,
1498
- actionLabel: "Get a license",
1422
+ message: (0, _copilotkit_core.ɵformatLabel)(labels.licenseFeatureUnlicensedText, { feature: featureName ?? "" }),
1423
+ actionLabel: labels.licenseGetLicenseLabel,
1499
1424
  actionUrl: "https://copilotkit.ai/pricing",
1500
1425
  onDismiss
1501
1426
  });
1502
1427
  case "expiring": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BannerShell, {
1503
1428
  severity: "warning",
1504
- message: `Your CopilotKit license expires in ${graceRemaining} day${graceRemaining !== 1 ? "s" : ""}. Please renew.`,
1505
- actionLabel: "Renew",
1429
+ message: expiringMessage(graceRemaining),
1430
+ actionLabel: labels.licenseRenewLabel,
1506
1431
  actionUrl: "https://dashboard.operations.copilotkit.ai",
1507
1432
  onDismiss
1508
1433
  });
1509
1434
  case "expired": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BannerShell, {
1510
1435
  severity: "critical",
1511
- message: `Your CopilotKit license expired${expiryDate ? ` on ${expiryDate}` : ""}. Please renew at copilotkit.ai/pricing`,
1512
- actionLabel: "Renew now",
1436
+ message: expiryDate ? (0, _copilotkit_core.ɵformatLabel)(labels.licenseExpiredOnDateText, { date: expiryDate }) : labels.licenseExpiredText,
1437
+ actionLabel: labels.licenseRenewNowLabel,
1513
1438
  actionUrl: "https://copilotkit.ai/pricing",
1514
1439
  onDismiss
1515
1440
  });
1516
1441
  case "invalid": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BannerShell, {
1517
1442
  severity: "critical",
1518
- message: "Invalid CopilotKit license token. Please check your configuration.",
1519
- actionLabel: "Get a license",
1443
+ message: labels.licenseInvalidText,
1444
+ actionLabel: labels.licenseGetLicenseLabel,
1520
1445
  actionUrl: "https://copilotkit.ai/pricing",
1521
1446
  onDismiss
1522
1447
  });
@@ -1535,9 +1460,7 @@ function InlineFeatureWarning({ featureName }) {
1535
1460
  fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif"
1536
1461
  },
1537
1462
  children: [
1538
- "⚠ The \"",
1539
- featureName,
1540
- "\" feature requires a CopilotKit license.",
1463
+ (0, _copilotkit_core.ɵformatLabel)(labels.licenseFeatureUnlicensedText, { feature: featureName }),
1541
1464
  " ",
1542
1465
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
1543
1466
  href: "https://copilotkit.ai/pricing",
@@ -1709,324 +1632,63 @@ function useSandboxFunctions() {
1709
1632
  return (0, react.useContext)(SandboxFunctionsContext);
1710
1633
  }
1711
1634
 
1712
- //#endregion
1713
- //#region src/lib/processPartialHtml.ts
1714
- /**
1715
- * Extracts all complete `<style>` blocks from the raw HTML.
1716
- * Returns the concatenated style tags, suitable for injection into `<head>`.
1717
- */
1718
- function extractCompleteStyles(html) {
1719
- const matches = html.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi);
1720
- return matches ? matches.join("") : "";
1721
- }
1722
- /**
1723
- * Processes raw accumulated HTML for safe preview via innerHTML injection.
1724
- * Pure function, no DOM dependencies.
1725
- *
1726
- * Pipeline (order matters):
1727
- * 1. Strip incomplete tag at end
1728
- * 2. Strip complete <style>, <script>, and <head> blocks
1729
- * 3. Strip incomplete <style>/<script>/<head> blocks
1730
- * 4. Strip incomplete HTML entities
1731
- * 5. Extract body content (or use full string if no <body>)
1732
- */
1733
- function processPartialHtml(html) {
1734
- let result = html;
1735
- result = result.replace(/<[^>]*$/, "");
1736
- result = result.replace(/<(style|script|head)\b[^>]*>[\s\S]*?<\/\1>/gi, "");
1737
- result = result.replace(/<(style|script|head)\b[^>]*>[\s\S]*$/gi, "");
1738
- result = result.replace(/&[a-zA-Z0-9#]*$/, "");
1739
- const bodyMatch = result.match(/<body[^>]*>([\s\S]*)/i);
1740
- if (bodyMatch) {
1741
- result = bodyMatch[1];
1742
- result = result.replace(/<\/body>[\s\S]*/i, "");
1743
- }
1744
- return result;
1745
- }
1746
-
1747
1635
  //#endregion
1748
1636
  //#region src/components/OpenGenerativeUIRenderer.tsx
1749
- const OpenGenerativeUIActivityType = "open-generative-ui";
1750
- const OpenGenerativeUIContentSchema = zod.z.object({
1751
- initialHeight: zod.z.number().optional(),
1752
- generating: zod.z.boolean().optional(),
1753
- css: zod.z.string().optional(),
1754
- cssComplete: zod.z.boolean().optional(),
1755
- html: zod.z.array(zod.z.string()).optional(),
1756
- htmlComplete: zod.z.boolean().optional(),
1757
- jsFunctions: zod.z.string().optional(),
1758
- jsFunctionsComplete: zod.z.boolean().optional(),
1759
- jsExpressions: zod.z.array(zod.z.string()).optional(),
1760
- jsExpressionsComplete: zod.z.boolean().optional()
1637
+ const OpenGenerativeUIActivityType = _copilotkit_core.OPEN_GENERATIVE_UI_ACTIVITY_TYPE;
1638
+ const OpenGenerativeUIContentSchema = zod.object({
1639
+ initialHeight: zod.number().optional(),
1640
+ generating: zod.boolean().optional(),
1641
+ css: zod.string().optional(),
1642
+ cssComplete: zod.boolean().optional(),
1643
+ html: zod.array(zod.string()).optional(),
1644
+ htmlComplete: zod.boolean().optional(),
1645
+ jsFunctions: zod.string().optional(),
1646
+ jsFunctionsComplete: zod.boolean().optional(),
1647
+ jsExpressions: zod.array(zod.string()).optional(),
1648
+ jsExpressionsComplete: zod.boolean().optional()
1761
1649
  });
1762
1650
  /**
1763
1651
  * Schema for the generateSandboxedUi tool call arguments.
1764
1652
  * Used by the frontend tool renderer to display placeholder messages.
1765
1653
  */
1766
- const GenerateSandboxedUiArgsSchema = zod.z.object({
1767
- initialHeight: zod.z.number().optional(),
1768
- placeholderMessages: zod.z.array(zod.z.string()).optional(),
1769
- css: zod.z.string().optional(),
1770
- html: zod.z.string().optional(),
1771
- jsFunctions: zod.z.string().optional(),
1772
- jsExpressions: zod.z.array(zod.z.string()).optional()
1773
- });
1774
- const THROTTLE_MS = 1e3;
1775
- /**
1776
- * Returns true when the inner component should re-render immediately
1777
- * (no throttle delay).
1778
- */
1779
- function shouldFlushImmediately(prev, next) {
1780
- if (next.cssComplete && (!prev || !prev.cssComplete)) return true;
1781
- if (next.htmlComplete) return true;
1782
- if (next.generating === false) return true;
1783
- if (next.jsFunctions && (!prev || !prev.jsFunctions)) return true;
1784
- if ((next.jsExpressions?.length ?? 0) > (prev?.jsExpressions?.length ?? 0)) return true;
1785
- if (next.html?.length && (!prev || !prev.html?.length)) return true;
1786
- return false;
1787
- }
1654
+ const GenerateSandboxedUiArgsSchema = zod.object({
1655
+ initialHeight: zod.number().optional(),
1656
+ placeholderMessages: zod.array(zod.string()).optional(),
1657
+ css: zod.string().optional(),
1658
+ html: zod.string().optional(),
1659
+ jsFunctions: zod.string().optional(),
1660
+ jsExpressions: zod.array(zod.string()).optional()
1661
+ });
1788
1662
  /**
1789
- * Outer wrapper — absorbs every parent re-render but only forwards
1790
- * throttled content snapshots to the memoized inner component.
1663
+ * Renders an Open Generative UI activity. The core controller throttles the
1664
+ * content and runs the websandbox iframes inside the container div.
1791
1665
  */
1792
1666
  const OpenGenerativeUIActivityRenderer = function OpenGenerativeUIActivityRenderer({ content }) {
1793
- const latestContentRef = (0, react.useRef)(content);
1794
- latestContentRef.current = content;
1795
- const [throttledContent, setThrottledContent] = (0, react.useState)(content);
1796
- const throttledContentRef = (0, react.useRef)(throttledContent);
1797
- const timerRef = (0, react.useRef)(null);
1798
- if (throttledContentRef.current !== content) {
1799
- if (shouldFlushImmediately(throttledContentRef.current, content)) {
1800
- if (timerRef.current !== null) {
1801
- clearTimeout(timerRef.current);
1802
- timerRef.current = null;
1803
- }
1804
- throttledContentRef.current = content;
1805
- setThrottledContent(content);
1806
- }
1807
- }
1808
- const flush = (0, react.useCallback)(() => {
1809
- timerRef.current = null;
1810
- const latest = latestContentRef.current;
1811
- throttledContentRef.current = latest;
1812
- setThrottledContent(latest);
1813
- }, []);
1814
- (0, react.useEffect)(() => {
1815
- if (throttledContentRef.current === content) return;
1816
- if (timerRef.current === null) timerRef.current = setTimeout(flush, THROTTLE_MS);
1817
- }, [content, flush]);
1818
- (0, react.useEffect)(() => {
1819
- return () => {
1820
- if (timerRef.current !== null) clearTimeout(timerRef.current);
1821
- };
1822
- }, []);
1823
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenGenerativeUIActivityRendererInner, { content: throttledContent });
1824
- };
1825
- function ensureHead(html) {
1826
- if (/<head[\s>]/i.test(html)) return html;
1827
- return `<head></head>${html}`;
1828
- }
1829
- function injectCssIntoHtml(html, css) {
1830
- const headCloseIdx = html.indexOf("</head>");
1831
- if (headCloseIdx !== -1) return html.slice(0, headCloseIdx) + `<style>${css}</style>` + html.slice(headCloseIdx);
1832
- return `<head><style>${css}</style></head>${html}`;
1833
- }
1834
- const OpenGenerativeUIActivityRendererInner = react.default.memo(function OpenGenerativeUIActivityRendererInner({ content }) {
1835
- const initialHeight = content.initialHeight ?? 200;
1836
- const [autoHeight, setAutoHeight] = (0, react.useState)(null);
1667
+ const [controller] = (0, react.useState)(() => {
1668
+ const created = new _copilotkit_core.ɵOpenGenerativeUIController();
1669
+ created.setContent(content);
1670
+ return created;
1671
+ });
1837
1672
  const sandboxFunctions = useSandboxFunctions();
1838
- const localApi = (0, react.useMemo)(() => {
1839
- const api = {};
1840
- for (const fn of sandboxFunctions) api[fn.name] = fn.handler;
1841
- return api;
1842
- }, [sandboxFunctions]);
1843
- const fullHtml = content.htmlComplete && content.html?.length ? content.html.join("") : void 0;
1844
- const css = content.cssComplete ? content.css : void 0;
1845
- const cssReady = !!content.cssComplete;
1846
- const partialHtml = !content.htmlComplete && content.html?.length ? content.html.join("") : void 0;
1847
- const previewBody = partialHtml ? processPartialHtml(partialHtml) : void 0;
1848
- const previewStyles = partialHtml ? extractCompleteStyles(partialHtml) : "";
1849
- const hasPreview = cssReady && !!previewBody?.trim();
1850
- const hasVisibleSandbox = !!fullHtml || hasPreview;
1851
1673
  const containerRef = (0, react.useRef)(null);
1852
- const sandboxRef = (0, react.useRef)(null);
1853
- const previewSandboxRef = (0, react.useRef)(null);
1854
- const previewReadyRef = (0, react.useRef)(false);
1855
- const sandboxReadyRef = (0, react.useRef)(false);
1856
- const executedIndexRef = (0, react.useRef)(0);
1857
- const pendingQueueRef = (0, react.useRef)([]);
1858
- const jsFunctionsInjectedRef = (0, react.useRef)(false);
1674
+ const state = (0, react.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
1859
1675
  (0, react.useEffect)(() => {
1860
- const container = containerRef.current;
1861
- if (!container || fullHtml || !hasPreview || previewSandboxRef.current) return;
1862
- let cancelled = false;
1863
- import("@jetbrains/websandbox").then((mod) => {
1864
- if (cancelled) return;
1865
- const sandbox = (mod.default?.default ?? mod.default).create({}, {
1866
- frameContainer: container,
1867
- frameContent: "<head></head><body></body>",
1868
- allowAdditionalAttributes: ""
1869
- });
1870
- previewSandboxRef.current = sandbox;
1871
- sandbox.iframe.style.width = "100%";
1872
- sandbox.iframe.style.height = "100%";
1873
- sandbox.iframe.style.border = "none";
1874
- sandbox.iframe.style.backgroundColor = "transparent";
1875
- sandbox.promise.then(() => {
1876
- if (cancelled) return;
1877
- previewReadyRef.current = true;
1878
- sandbox.run(`
1879
- var s = document.createElement('style');
1880
- s.textContent = 'html, body { overflow: hidden !important; }';
1881
- document.head.appendChild(s);
1882
- `);
1883
- const headParts = [];
1884
- if (css) headParts.push(`<style>${css}</style>`);
1885
- if (previewStyles) headParts.push(previewStyles);
1886
- if (headParts.length) sandbox.run(`document.head.innerHTML = ${JSON.stringify(headParts.join(""))}`);
1887
- if (previewBody) sandbox.run(`document.body.innerHTML = ${JSON.stringify(previewBody)}`);
1888
- });
1889
- }).catch((err) => {
1890
- console.error("[OpenGenerativeUI] Failed to load sandbox module:", err);
1891
- });
1892
- return () => {
1893
- cancelled = true;
1894
- };
1895
- }, [hasPreview, fullHtml]);
1896
- (0, react.useEffect)(() => {
1897
- if (!previewSandboxRef.current || !previewReadyRef.current) return;
1898
- const headParts = [];
1899
- if (css) headParts.push(`<style>${css}</style>`);
1900
- if (previewStyles) headParts.push(previewStyles);
1901
- if (headParts.length) previewSandboxRef.current.run(`document.head.innerHTML = ${JSON.stringify(headParts.join(""))}`);
1902
- if (!previewBody) return;
1903
- previewSandboxRef.current.run(`document.body.innerHTML = ${JSON.stringify(previewBody)}`);
1904
- }, [
1905
- previewBody,
1906
- previewStyles,
1907
- css
1908
- ]);
1909
- (0, react.useEffect)(() => {
1910
- const container = containerRef.current;
1911
- if (!container || !fullHtml) return;
1912
- if (previewSandboxRef.current) {
1913
- previewSandboxRef.current.destroy();
1914
- previewSandboxRef.current = null;
1915
- previewReadyRef.current = false;
1916
- }
1917
- let cancelled = false;
1918
- executedIndexRef.current = 0;
1919
- jsFunctionsInjectedRef.current = false;
1920
- sandboxReadyRef.current = false;
1921
- pendingQueueRef.current = [];
1922
- const htmlContent = css ? injectCssIntoHtml(fullHtml, css) : fullHtml;
1923
- import("@jetbrains/websandbox").then((mod) => {
1924
- if (cancelled) return;
1925
- const sandbox = (mod.default?.default ?? mod.default).create(localApi, {
1926
- frameContainer: container,
1927
- frameContent: ensureHead(htmlContent),
1928
- allowAdditionalAttributes: ""
1929
- });
1930
- sandboxRef.current = sandbox;
1931
- sandbox.iframe.style.width = "100%";
1932
- sandbox.iframe.style.height = "100%";
1933
- sandbox.iframe.style.border = "none";
1934
- sandbox.iframe.style.backgroundColor = "transparent";
1935
- sandbox.promise.then(() => {
1936
- if (cancelled) return;
1937
- sandboxReadyRef.current = true;
1938
- sandbox.run(`
1939
- var s = document.createElement('style');
1940
- s.textContent = 'html, body { overflow: hidden !important; }';
1941
- document.head.appendChild(s);
1942
- `);
1943
- const queue = pendingQueueRef.current;
1944
- pendingQueueRef.current = [];
1945
- for (const code of queue) sandbox.run(code);
1946
- });
1947
- }).catch((err) => {
1948
- console.error("[OpenGenerativeUI] Failed to load sandbox module:", err);
1949
- });
1950
- return () => {
1951
- cancelled = true;
1952
- if (previewSandboxRef.current) {
1953
- previewSandboxRef.current.destroy();
1954
- previewSandboxRef.current = null;
1955
- previewReadyRef.current = false;
1956
- }
1957
- if (sandboxRef.current) {
1958
- sandboxRef.current.destroy();
1959
- sandboxRef.current = null;
1960
- }
1961
- sandboxReadyRef.current = false;
1962
- setAutoHeight(null);
1963
- };
1964
- }, [
1965
- fullHtml,
1966
- css,
1967
- localApi
1968
- ]);
1969
- (0, react.useEffect)(() => {
1970
- if (!content.jsFunctions || jsFunctionsInjectedRef.current) return;
1971
- jsFunctionsInjectedRef.current = true;
1972
- const sandbox = sandboxRef.current;
1973
- if (sandboxReadyRef.current && sandbox) sandbox.run(content.jsFunctions);
1974
- else pendingQueueRef.current.push(content.jsFunctions);
1975
- }, [content.jsFunctions]);
1676
+ controller.setSandboxFunctions(sandboxFunctions);
1677
+ }, [controller, sandboxFunctions]);
1976
1678
  (0, react.useEffect)(() => {
1977
- const expressions = content.jsExpressions;
1978
- if (!expressions || expressions.length === 0) return;
1979
- const startIndex = executedIndexRef.current;
1980
- if (startIndex >= expressions.length) return;
1981
- const newExprs = expressions.slice(startIndex);
1982
- executedIndexRef.current = expressions.length;
1983
- const sandbox = sandboxRef.current;
1984
- if (sandboxReadyRef.current && sandbox) (async () => {
1985
- for (const expr of newExprs) await sandbox.run(expr);
1986
- })();
1987
- else pendingQueueRef.current.push(...newExprs);
1988
- }, [content.jsExpressions?.length]);
1989
- const generationDone = content.generating === false;
1679
+ controller.setContent(content);
1680
+ }, [controller, content]);
1990
1681
  (0, react.useEffect)(() => {
1991
- const sandbox = sandboxRef.current;
1992
- if (!generationDone || !sandbox) return;
1993
- let handled = false;
1994
- const onMessage = (e) => {
1995
- if (handled) return;
1996
- if (e.source === sandbox.iframe.contentWindow && e.data?.type === "__ck_resize") {
1997
- handled = true;
1998
- setAutoHeight(e.data.height);
1999
- window.removeEventListener("message", onMessage);
2000
- }
2001
- };
2002
- window.addEventListener("message", onMessage);
2003
- const measureOnce = `
2004
- (function() {
2005
- var s = document.createElement('style');
2006
- s.textContent = 'body { height: auto !important; min-height: 0 !important; }';
2007
- document.head.appendChild(s);
2008
- var h = document.body.scrollHeight;
2009
- var cs = getComputedStyle(document.body);
2010
- h += parseFloat(cs.marginTop) || 0;
2011
- h += parseFloat(cs.marginBottom) || 0;
2012
- s.remove();
2013
- parent.postMessage({ type: "__ck_resize", height: Math.ceil(h) }, "*");
2014
- })();
2015
- `;
2016
- if (sandboxReadyRef.current) sandbox.run(measureOnce);
2017
- else pendingQueueRef.current.push(measureOnce);
2018
- return () => {
2019
- window.removeEventListener("message", onMessage);
2020
- };
2021
- }, [generationDone]);
2022
- const height = autoHeight ?? initialHeight;
2023
- const isGenerating = content.generating !== false;
1682
+ controller.setHost(containerRef.current);
1683
+ return () => controller.destroy();
1684
+ }, [controller]);
1685
+ const hasVisibleSandbox = state.phase !== "placeholder";
2024
1686
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2025
1687
  ref: containerRef,
2026
1688
  style: {
2027
1689
  position: "relative",
2028
1690
  width: "100%",
2029
- height: `${height}px`,
1691
+ height: `${state.height}px`,
2030
1692
  borderRadius: "8px",
2031
1693
  backgroundColor: hasVisibleSandbox ? "transparent" : "#f5f5f5",
2032
1694
  border: hasVisibleSandbox ? "none" : "1px solid #e0e0e0",
@@ -2035,7 +1697,7 @@ const OpenGenerativeUIActivityRendererInner = react.default.memo(function OpenGe
2035
1697
  justifyContent: hasVisibleSandbox ? void 0 : "center",
2036
1698
  overflow: "hidden"
2037
1699
  },
2038
- children: isGenerating && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1700
+ children: state.generating && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2039
1701
  style: {
2040
1702
  position: "absolute",
2041
1703
  inset: 0,
@@ -2067,7 +1729,7 @@ const OpenGenerativeUIActivityRendererInner = react.default.memo(function OpenGe
2067
1729
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: `@keyframes ck-spin { to { transform: rotate(360deg) } }` })]
2068
1730
  })
2069
1731
  });
2070
- }, (prev, next) => prev.content === next.content);
1732
+ };
2071
1733
  /**
2072
1734
  * Frontend tool renderer for generateSandboxedUi.
2073
1735
  * Displays placeholder messages while the UI is being generated.
@@ -2104,22 +1766,22 @@ const OpenGenerativeUIToolRenderer = function OpenGenerativeUIToolRenderer(props
2104
1766
  //#region src/a2ui/A2UIRecoveryStates.tsx
2105
1767
  /**
2106
1768
  * The pre-paint lifecycle fields the middleware stamps onto the `a2ui-surface`
2107
- * activity content (alongside `a2ui_operations` on paint). `.passthrough()` keeps
1769
+ * activity content (alongside `a2ui_operations` on paint). `.loose()` keeps
2108
1770
  * `a2ui_operations` and any future fields intact.
2109
1771
  */
2110
1772
  const A2UILifecycleFields = {
2111
- status: zod.z.enum([
1773
+ status: zod.enum([
2112
1774
  "building",
2113
1775
  "retrying",
2114
1776
  "failed"
2115
1777
  ]).optional(),
2116
- attempt: zod.z.number().optional(),
2117
- maxAttempts: zod.z.number().optional(),
2118
- progressTokens: zod.z.number().optional(),
2119
- error: zod.z.string().optional(),
2120
- errors: zod.z.array(zod.z.any()).optional(),
2121
- attempts: zod.z.array(zod.z.any()).optional(),
2122
- debugExposure: zod.z.enum([
1778
+ attempt: zod.number().optional(),
1779
+ maxAttempts: zod.number().optional(),
1780
+ progressTokens: zod.number().optional(),
1781
+ error: zod.string().optional(),
1782
+ errors: zod.array(zod.any()).optional(),
1783
+ attempts: zod.array(zod.any()).optional(),
1784
+ debugExposure: zod.enum([
2123
1785
  "hidden",
2124
1786
  "collapsed",
2125
1787
  "verbose"
@@ -2510,12 +2172,12 @@ function ensureInitialized() {
2510
2172
  * stable messageId (OSS-162): pre-paint `status` ("building" | "retrying" |
2511
2173
  * "failed") with recovery detail, then `a2ui_operations` on paint. The states
2512
2174
  * swap in place, so the painted surface replaces the skeleton with no extra
2513
- * coordination. `.passthrough()` preserves operations + any future fields.
2175
+ * coordination. `.loose()` preserves operations + any future fields.
2514
2176
  */
2515
- const A2UISurfaceContentSchema = zod.z.object({
2516
- a2ui_operations: zod.z.array(zod.z.any()).optional(),
2177
+ const A2UISurfaceContentSchema = zod.object({
2178
+ a2ui_operations: zod.array(zod.any()).optional(),
2517
2179
  ...A2UILifecycleFields
2518
- }).passthrough();
2180
+ }).loose();
2519
2181
  const IS_DEVELOPMENT = process.env.NODE_ENV !== "production";
2520
2182
  /**
2521
2183
  * How long to wait for a surface to report its first paint before giving up on
@@ -2886,7 +2548,7 @@ function A2UIBuiltInToolCallRenderer() {
2886
2548
  (0, react.useEffect)(() => {
2887
2549
  const renderer = require_MarkdownSurfaces.defineToolCallRenderer({
2888
2550
  name: RENDER_A2UI_TOOL_NAME,
2889
- args: zod.z.any(),
2551
+ args: zod.any(),
2890
2552
  render: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, {})
2891
2553
  });
2892
2554
  const existing = copilotkit._renderToolCalls ?? [];
@@ -3777,7 +3439,7 @@ var GenerativeUISurfaceManager = class {
3777
3439
  this.getState = () => this.state;
3778
3440
  this.webCoreCatalog = new _a2ui_web_core_v0_9.Catalog(ui.id, [...ui.components.keys()].map((name) => ({
3779
3441
  name,
3780
- schema: zod.z.any()
3442
+ schema: zod.any()
3781
3443
  })), []);
3782
3444
  }
3783
3445
  notify() {
@@ -4768,9 +4430,28 @@ function useGenerativeUIRoot(copilotkit, config) {
4768
4430
 
4769
4431
  //#endregion
4770
4432
  //#region src/lib/react-core.ts
4433
+ /**
4434
+ * Wait for pending React state updates before the follow-up agent run.
4435
+ *
4436
+ * When a frontend tool handler calls setState(), React 18 batches the update
4437
+ * and schedules a commit via its internal scheduler (MessageChannel). The
4438
+ * useAgentContext hook registers context via useLayoutEffect, which runs
4439
+ * synchronously after React commits that batch.
4440
+ *
4441
+ * Awaiting a zero-delay timeout yields to the macrotask queue. React's
4442
+ * MessageChannel task runs first, committing the pending state and running
4443
+ * useLayoutEffect (which updates the context store). The follow-up runAgent
4444
+ * call then reads fresh context.
4445
+ */
4446
+ function waitForReactCommit() {
4447
+ return new Promise((resolve) => setTimeout(resolve, 0));
4448
+ }
4771
4449
  var CopilotKitCoreReact = class extends _copilotkit_core.CopilotKitCore {
4772
4450
  constructor(config) {
4773
- super(config);
4451
+ super({
4452
+ ...config,
4453
+ ɵwaitForFrameworkUpdates: waitForReactCommit
4454
+ });
4774
4455
  this._renderToolCalls = [];
4775
4456
  this._hookRenderToolCalls = /* @__PURE__ */ new Map();
4776
4457
  this._cachedMergedRenderToolCalls = null;
@@ -4844,22 +4525,6 @@ var CopilotKitCoreReact = class extends _copilotkit_core.CopilotKitCore {
4844
4525
  subscribe(subscriber) {
4845
4526
  return super.subscribe(subscriber);
4846
4527
  }
4847
- /**
4848
- * Wait for pending React state updates before the follow-up agent run.
4849
- *
4850
- * When a frontend tool handler calls setState(), React 18 batches the update
4851
- * and schedules a commit via its internal scheduler (MessageChannel). The
4852
- * useAgentContext hook registers context via useLayoutEffect, which runs
4853
- * synchronously after React commits that batch.
4854
- *
4855
- * Awaiting a zero-delay timeout yields to the macrotask queue. React's
4856
- * MessageChannel task runs first, committing the pending state and running
4857
- * useLayoutEffect (which updates the context store). The follow-up runAgent
4858
- * call then reads fresh context.
4859
- */
4860
- async waitForPendingFrameworkUpdates() {
4861
- await new Promise((resolve) => setTimeout(resolve, 0));
4862
- }
4863
4528
  };
4864
4529
 
4865
4530
  //#endregion
@@ -4901,10 +4566,6 @@ function CopilotKitStyles() {
4901
4566
 
4902
4567
  //#endregion
4903
4568
  //#region src/providers/CopilotKitProvider.tsx
4904
- const zodToJsonSchemaAdapter = (schema, options) => {
4905
- const refStrategy = options?.$refStrategy;
4906
- return (0, zod_to_json_schema.zodToJsonSchema)(schema, refStrategy === "root" || refStrategy === "relative" || refStrategy === "none" || refStrategy === "seen" ? { $refStrategy: refStrategy } : {});
4907
- };
4908
4569
  const HEADER_NAME = "X-CopilotCloud-Public-Api-Key";
4909
4570
  const COPILOT_CLOUD_CHAT_URL = "https://api.cloud.copilotkit.ai/copilotkit/v1";
4910
4571
  const EMPTY_HEADERS = Object.freeze({});
@@ -4913,16 +4574,6 @@ const EMPTY_AGENTS = Object.freeze({});
4913
4574
  /** Registration name of a catch-all tool: handles any otherwise-unhandled call. */
4914
4575
  const WILDCARD_TOOL_NAME$1 = "*";
4915
4576
  const HUMAN_IN_THE_LOOP_ABORTED_MESSAGE = "Human-in-the-loop interaction aborted";
4916
- const DEFAULT_DESIGN_SKILL = `When generating UI with generateSandboxedUi, follow these design principles inspired by shadcn/ui:
4917
-
4918
- - Use a minimal, flat aesthetic. Avoid drop shadows and gradients — rely on subtle borders (1px solid, light gray like #e5e7eb) to define surfaces.
4919
- - Neutral base palette: white backgrounds, zinc/slate gray text (#09090b for headings, #71717a for secondary text). One accent color for interactive elements.
4920
- - Use system font stacks (system-ui, -apple-system, sans-serif) at readable sizes (14px body, 600 weight for headings). Tight line-heights.
4921
- - Small, consistent border-radius (6–8px). Cards and containers use border, not shadow, for separation.
4922
- - Buttons: solid fill for primary (dark bg, white text), outline for secondary (border + transparent bg). Subtle hover state (slight opacity or background shift).
4923
- - Use CSS Grid or Flexbox for layout. Ensure the UI looks good at any width.
4924
- - Minimal transitions (150ms) for hover/focus states only. No decorative animations.
4925
- - Keep the UI focused and dense — avoid excessive padding. Use compact spacing (8–12px gaps, 10–14px padding in controls).`;
4926
4577
  /** The MCP Apps renderer with `mcpApps.allowSameOriginFallback` applied. */
4927
4578
  const SameOriginMCPAppsActivityRenderer = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MCPAppsActivityRenderer, {
4928
4579
  ...props,
@@ -5133,7 +4784,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
5133
4784
  const builtInFrontendTools = (0, react.useMemo)(() => {
5134
4785
  if (!openGenUIActive) return [];
5135
4786
  return [{
5136
- name: "generateSandboxedUi",
4787
+ name: _copilotkit_core.GENERATE_SANDBOXED_UI_TOOL_NAME,
5137
4788
  description: _copilotkit_shared.GENERATE_SANDBOXED_UI_DESCRIPTION,
5138
4789
  parameters: GenerateSandboxedUiArgsSchema,
5139
4790
  handler: async () => "UI generated",
@@ -5157,7 +4808,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
5157
4808
  const combined = [...renderToolCallsList];
5158
4809
  [...frontendToolsList, ...builtInFrontendTools].forEach((tool) => {
5159
4810
  if (tool.render) {
5160
- const args = tool.parameters || (tool.name === "*" ? zod.z.any() : void 0);
4811
+ const args = tool.parameters || (tool.name === "*" ? _copilotkit_shared.ɵanySchema : void 0);
5161
4812
  if (args) combined.push({
5162
4813
  name: tool.name,
5163
4814
  args,
@@ -5358,7 +5009,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
5358
5009
  (0, react.useEffect)(() => {
5359
5010
  copilotkit.setDefaultThrottleMs(defaultThrottleMs);
5360
5011
  }, [copilotkit, defaultThrottleMs]);
5361
- const designSkill = openGenerativeUI?.designSkill ?? DEFAULT_DESIGN_SKILL;
5012
+ const designSkill = openGenerativeUI?.designSkill ?? _copilotkit_core.DEFAULT_OPEN_GENERATIVE_UI_DESIGN_SKILL;
5362
5013
  (0, react.useLayoutEffect)(() => {
5363
5014
  if (!copilotkit || !openGenUIActive) return;
5364
5015
  const id = copilotkit.addContext({
@@ -5378,7 +5029,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
5378
5029
  return JSON.stringify(sandboxFunctionsList.map((fn) => ({
5379
5030
  name: fn.name,
5380
5031
  description: fn.description,
5381
- parameters: (0, _copilotkit_shared.schemaToJsonSchema)(fn.parameters, { zodToJsonSchema: zodToJsonSchemaAdapter })
5032
+ parameters: (0, _copilotkit_shared.schemaToJsonSchema)(fn.parameters)
5382
5033
  })));
5383
5034
  }, [sandboxFunctionsList]);
5384
5035
  (0, react.useLayoutEffect)(() => {
@@ -5404,26 +5055,17 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
5404
5055
  executingToolCallIds,
5405
5056
  showIntelligenceIndicator
5406
5057
  ]);
5407
- const retryableRuntimeEntitlementFailure = runtimeEntitlements?.status !== "ready" && runtimeEntitlements?.error.retryable === true;
5408
- const hasNonReadyRuntimeEntitlement = runtimeEntitlements !== void 0 && runtimeEntitlements.status !== "ready";
5409
- const hasLegacyRuntimeEntitlementFallback = runtimeLicenseStatus === "valid" || runtimeLicenseStatus === "expiring";
5410
- const runtimeEntitlementRetryInProgress = retryableRuntimeEntitlementFailure && runtimeEntitlementRetryPending && !hasLegacyRuntimeEntitlementFallback;
5411
- const terminalRuntimeEntitlementFailure = hasNonReadyRuntimeEntitlement && !retryableRuntimeEntitlementFailure && !hasLegacyRuntimeEntitlementFallback;
5412
- const licenseContextValue = (0, react.useMemo)(() => {
5413
- const runtimeLicenseContext = (0, _copilotkit_shared.createLicenseContextValue)(runtimeEntitlementRetryInProgress ? void 0 : runtimeLicenseStatus, runtimeEntitlements);
5414
- if (!terminalRuntimeEntitlementFailure) return runtimeLicenseContext;
5415
- return {
5416
- ...runtimeLicenseContext,
5417
- checkFeature: () => false,
5418
- getLimit: () => null
5419
- };
5420
- }, [
5421
- terminalRuntimeEntitlementFailure,
5422
- runtimeEntitlementRetryInProgress,
5058
+ const licenseState = (0, react.useMemo)(() => (0, _copilotkit_core.ɵresolveLicenseState)({
5059
+ status: runtimeLicenseStatus,
5060
+ entitlements: runtimeEntitlements,
5061
+ retryPending: runtimeEntitlementRetryPending,
5062
+ publicKey: resolvedPublicKey
5063
+ }), [
5064
+ runtimeLicenseStatus,
5423
5065
  runtimeEntitlements,
5424
- runtimeLicenseStatus
5066
+ runtimeEntitlementRetryPending,
5067
+ resolvedPublicKey
5425
5068
  ]);
5426
- const runtimeLicenseWarningStatus = runtimeEntitlementRetryInProgress ? void 0 : licenseContextValue.status ?? void 0;
5427
5069
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotStyleOptionsProvider, {
5428
5070
  value: (0, react.useMemo)(() => ({
5429
5071
  nonce,
@@ -5434,7 +5076,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
5434
5076
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_react_core_context.CopilotKitContext.Provider, {
5435
5077
  value: contextValue,
5436
5078
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_copilotkit_react_core_context.LicenseContext.Provider, {
5437
- value: licenseContextValue,
5079
+ value: licenseState.context,
5438
5080
  children: [
5439
5081
  a2uiActive && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(A2UIBuiltInToolCallRenderer, {}),
5440
5082
  generativeUIActive && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.GenerativeUIToolCallRenderer, {}),
@@ -5459,10 +5101,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
5459
5101
  }) : null]
5460
5102
  })
5461
5103
  }),
5462
- runtimeLicenseWarningStatus === "none" && !resolvedPublicKey && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "no_license" }),
5463
- runtimeLicenseWarningStatus === "expired" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "expired" }),
5464
- runtimeLicenseWarningStatus === "invalid" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "invalid" }),
5465
- runtimeLicenseWarningStatus === "expiring" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "expiring" })
5104
+ licenseState.bannerType && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: licenseState.bannerType })
5466
5105
  ]
5467
5106
  })
5468
5107
  })
@@ -5477,11 +5116,7 @@ function useRenderCustomMessages() {
5477
5116
  const config = require_MarkdownSurfaces.useCopilotChatConfiguration();
5478
5117
  if (!config) return null;
5479
5118
  const { agentId, threadId } = config;
5480
- const customMessageRenderers = copilotkit.renderCustomMessages.filter((renderer) => renderer.agentId === void 0 || renderer.agentId === agentId).sort((a, b) => {
5481
- const aHasAgent = a.agentId !== void 0;
5482
- if (aHasAgent === (b.agentId !== void 0)) return 0;
5483
- return aHasAgent ? -1 : 1;
5484
- });
5119
+ const customMessageRenderers = (0, _copilotkit_core.ɵresolveCustomMessageRenderers)(copilotkit.renderCustomMessages, agentId);
5485
5120
  if (!customMessageRenderers.length) return null;
5486
5121
  return function(params) {
5487
5122
  const { message, position } = params;
@@ -5517,6 +5152,18 @@ function useRenderCustomMessages() {
5517
5152
 
5518
5153
  //#endregion
5519
5154
  //#region src/hooks/use-render-activity-message.tsx
5155
+ /**
5156
+ * Explain why an activity message that has a renderer drew nothing: its
5157
+ * content validates asynchronously, or it fails the renderer's schema.
5158
+ */
5159
+ function warnAboutRejectedContent(renderer, message) {
5160
+ const result = renderer.content["~standard"].validate(message.content);
5161
+ if (result instanceof Promise) {
5162
+ console.warn(`Async content validation is not supported for activity message '${message.activityType}'`);
5163
+ return;
5164
+ }
5165
+ if (result.issues) console.warn(`Failed to parse content for activity message '${message.activityType}':`, result.issues);
5166
+ }
5520
5167
  function useRenderActivityMessage() {
5521
5168
  const { copilotkit } = (0, _copilotkit_react_core_context.useCopilotKit)();
5522
5169
  const agentId = require_MarkdownSurfaces.useCopilotChatConfiguration()?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
@@ -5527,29 +5174,29 @@ function useRenderActivityMessage() {
5527
5174
  return matches.find((candidate) => candidate.agentId === agentId) ?? matches.find((candidate) => candidate.agentId === void 0) ?? renderers.find((candidate) => candidate.activityType === "*") ?? null;
5528
5175
  }, [agentId, renderers]);
5529
5176
  const renderActivityMessage = (0, react.useCallback)((message) => {
5530
- const renderer = findRenderer(message.activityType);
5531
- if (!renderer) return null;
5532
- const parseResult = renderer.content["~standard"].validate(message.content);
5533
- if (parseResult instanceof Promise) {
5534
- console.warn(`Async content validation is not supported for activity message '${message.activityType}'`);
5535
- return null;
5536
- }
5537
- if (parseResult.issues) {
5538
- console.warn(`Failed to parse content for activity message '${message.activityType}':`, parseResult.issues);
5177
+ const match = (0, _copilotkit_core.ɵresolveActivityRenderer)(renderers, {
5178
+ activityType: message.activityType,
5179
+ agentId,
5180
+ content: message.content
5181
+ });
5182
+ if (!match) {
5183
+ const renderer = findRenderer(message.activityType);
5184
+ if (renderer) warnAboutRejectedContent(renderer, message);
5539
5185
  return null;
5540
5186
  }
5541
- const Component = renderer.render;
5187
+ const Component = match.renderer.render;
5542
5188
  const agent = copilotkit.getAgent(agentId);
5543
5189
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
5544
5190
  activityType: message.activityType,
5545
- content: parseResult.value,
5191
+ content: match.content,
5546
5192
  message,
5547
5193
  agent
5548
5194
  }, message.id);
5549
5195
  }, [
5550
5196
  agentId,
5551
5197
  copilotkit,
5552
- findRenderer
5198
+ findRenderer,
5199
+ renderers
5553
5200
  ]);
5554
5201
  return (0, react.useMemo)(() => ({
5555
5202
  renderActivityMessage,
@@ -5634,6 +5281,30 @@ function useDepsVersion(deps) {
5634
5281
 
5635
5282
  //#endregion
5636
5283
  //#region src/hooks/use-frontend-tool.tsx
5284
+ /**
5285
+ * Register a frontend tool while the component is mounted. The agent can
5286
+ * call it, and its `render` component draws the call in the chat.
5287
+ *
5288
+ * A tool with the same name and agentId as a tool that is already registered
5289
+ * (for example one from the provider's `tools`) overrides it while this
5290
+ * component is mounted. When the component unmounts, the overridden tool is
5291
+ * active again. The renderer stays registered after unmount, so past tool
5292
+ * calls still render in the chat history.
5293
+ *
5294
+ * @param tool - The tool to register.
5295
+ * @param deps - Extra values that re-register the tool when they change. Use
5296
+ * it when the handler closes over a value that is not part of the tool.
5297
+ *
5298
+ * @example
5299
+ * ```tsx
5300
+ * useFrontendTool({
5301
+ * name: "showWeather",
5302
+ * description: "Show the weather for a city",
5303
+ * parameters: z.object({ city: z.string() }),
5304
+ * handler: async ({ city }) => `Sunny in ${city}`,
5305
+ * });
5306
+ * ```
5307
+ */
5637
5308
  function useFrontendTool(tool, deps) {
5638
5309
  const { copilotkit } = (0, _copilotkit_react_core_context.useCopilotKit)();
5639
5310
  const depsVersion = useDepsVersion(deps);
@@ -5642,11 +5313,8 @@ function useFrontendTool(tool, deps) {
5642
5313
  if (copilotkit.getTool({
5643
5314
  toolName: name,
5644
5315
  agentId: tool.agentId
5645
- })) {
5646
- console.warn(`Tool '${name}' already exists for agent '${tool.agentId || "global"}'. Overriding with latest registration.`);
5647
- copilotkit.removeTool(name, tool.agentId);
5648
- }
5649
- copilotkit.addTool(tool);
5316
+ })) console.warn(`Tool '${name}' already exists for agent '${tool.agentId || "global"}'. Overriding with latest registration.`);
5317
+ const unregister = copilotkit.addTool(tool);
5650
5318
  if (tool.render) copilotkit.addHookRenderToolCall({
5651
5319
  name,
5652
5320
  args: tool.parameters,
@@ -5654,7 +5322,7 @@ function useFrontendTool(tool, deps) {
5654
5322
  render: tool.render
5655
5323
  });
5656
5324
  return () => {
5657
- copilotkit.removeTool(name, tool.agentId);
5325
+ unregister();
5658
5326
  };
5659
5327
  }, [
5660
5328
  tool.name,
@@ -5679,8 +5347,10 @@ const EMPTY_TOOLS = [];
5679
5347
  *
5680
5348
  * Tools are keyed by `name` plus `agentId`, the same as `useFrontendTool`. A
5681
5349
  * tool that disappears from the array is unregistered on the next render, and
5682
- * every tool is unregistered on unmount. Renderers stay registered after
5683
- * unmount so past tool calls still render in the chat history.
5350
+ * every tool is unregistered on unmount. A listed tool hides a tool with the
5351
+ * same name and agentId (for example one from the provider's `tools`) until it
5352
+ * is unregistered, and then the hidden tool is active again. Renderers stay
5353
+ * registered after unmount so past tool calls still render in the chat history.
5684
5354
  *
5685
5355
  * @param tools - The tools to register. May be empty and may change length.
5686
5356
  * @param deps - Extra dependencies that force re-registration, compared by
@@ -5730,15 +5400,13 @@ function useFrontendTools(tools, deps) {
5730
5400
  deduped.set(key, tool);
5731
5401
  }
5732
5402
  const registered = [...deduped.values()];
5403
+ const unregisters = [];
5733
5404
  for (const tool of registered) {
5734
5405
  if (copilotkit.getTool({
5735
5406
  toolName: tool.name,
5736
5407
  agentId: tool.agentId
5737
- })) {
5738
- console.warn(`Tool '${tool.name}' already exists for agent '${tool.agentId || "global"}'. Overriding with latest registration.`);
5739
- copilotkit.removeTool(tool.name, tool.agentId);
5740
- }
5741
- copilotkit.addTool(tool);
5408
+ })) console.warn(`Tool '${tool.name}' already exists for agent '${tool.agentId || "global"}'. Overriding with latest registration.`);
5409
+ unregisters.push(copilotkit.addTool(tool));
5742
5410
  if (tool.render) copilotkit.addHookRenderToolCall({
5743
5411
  name: tool.name,
5744
5412
  args: tool.parameters,
@@ -5747,7 +5415,7 @@ function useFrontendTools(tools, deps) {
5747
5415
  });
5748
5416
  }
5749
5417
  return () => {
5750
- for (const tool of registered) copilotkit.removeTool(tool.name, tool.agentId);
5418
+ for (const unregister of unregisters) unregister();
5751
5419
  };
5752
5420
  }, [
5753
5421
  JSON.stringify(toolList.map((tool) => [
@@ -5922,34 +5590,24 @@ function useRenderTool(config, deps) {
5922
5590
  * @internal
5923
5591
  */
5924
5592
  const ToolCallGroupContext = (0, react.createContext)(null);
5925
- /**
5926
- * A call without a result is running only while the group is active: once
5927
- * the run has moved on or ended, its result is never coming.
5928
- */
5929
- const entryStatus = ({ toolMessage }, active) => toolMessage ? toolMessage.error ? "failed" : "done" : active ? "running" : "stopped";
5930
- /** @internal */
5931
- const statusLabels = {
5932
- running: "Running",
5933
- done: "Done",
5934
- failed: "Failed",
5935
- stopped: "Stopped"
5593
+ /** The label key for each call status. */
5594
+ const STATUS_LABEL_KEYS = {
5595
+ running: "toolCallStatusRunningLabel",
5596
+ done: "toolCallStatusDoneLabel",
5597
+ failed: "toolCallStatusFailedLabel",
5598
+ stopped: "toolCallStatusStoppedLabel"
5936
5599
  };
5937
- /** The first non-empty string argument: usually a command, path or query. */
5938
- function argumentPreview(parameters) {
5939
- if (!parameters || typeof parameters !== "object") return void 0;
5940
- return Object.values(parameters).find((v) => typeof v === "string" && v.trim().length > 0)?.replace(/\s+/g, " ");
5941
- }
5942
- const entryPreview = (entry) => argumentPreview((0, _copilotkit_shared.partialJSONParse)(entry.toolCall.function.arguments));
5943
- /** "run_command ×2, read_file" */
5944
- function toolNames(calls) {
5945
- const counts = /* @__PURE__ */ new Map();
5946
- for (const { toolCall } of calls) {
5947
- const name = toolCall.function.name;
5948
- counts.set(name, (counts.get(name) ?? 0) + 1);
5949
- }
5950
- return [...counts].map(([name, count]) => count > 1 ? `${name} ×${count}` : name).join(", ");
5600
+ /** The icon for each call status. */
5601
+ const STATUS_ICONS = {
5602
+ running: "Loader2",
5603
+ done: "Check",
5604
+ failed: "X",
5605
+ stopped: "Circle"
5606
+ };
5607
+ /** The chat labels from the nearest chat configuration, or the defaults. */
5608
+ function useLabels$1() {
5609
+ return require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
5951
5610
  }
5952
- const pluralize = (count, noun) => `${count} ${noun}${count === 1 ? "" : "s"}`;
5953
5611
  /**
5954
5612
  * Height transition between closed and its content's height. Closed content
5955
5613
  * stays mounted (so its state survives) but is inert.
@@ -5972,55 +5630,35 @@ function Collapsible({ open, id, className, children }) {
5972
5630
  });
5973
5631
  }
5974
5632
  function StatusIcon({ status, className }) {
5975
- const Icon = {
5976
- running: lucide_react.Loader2,
5977
- done: lucide_react.Check,
5978
- failed: lucide_react.X,
5979
- stopped: lucide_react.Circle
5980
- }[status];
5981
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
5633
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
5634
+ name: STATUS_ICONS[status],
5982
5635
  "aria-hidden": "true",
5983
5636
  className: require_MarkdownSurfaces.cn("cpk-tool-call-status-icon", status === "running" && "cpk-tool-call-status-icon-running", status === "failed" && "cpk-tool-call-status-icon-failed", className)
5984
5637
  });
5985
5638
  }
5986
5639
  function Chevron({ open, className }) {
5987
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, {
5640
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
5641
+ name: "ChevronRight",
5988
5642
  "aria-hidden": "true",
5989
5643
  className: require_MarkdownSurfaces.cn("cpk-tool-call-chevron", open && "cpk-tool-call-chevron-open", className)
5990
5644
  });
5991
5645
  }
5992
5646
  function FailedCount({ calls }) {
5993
- const failed = calls.filter((call) => call.toolMessage?.error).length;
5647
+ const labels = useLabels$1();
5648
+ const failed = (0, _copilotkit_core.ɵcountFailedToolCalls)(calls);
5994
5649
  if (!failed) return null;
5995
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
5650
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
5996
5651
  className: "cpk-tool-call-failed-count",
5997
- children: [failed, " failed"]
5652
+ children: (0, _copilotkit_core.ɵformatLabel)(labels.toolCallFailedCountLabel, { count: failed })
5998
5653
  });
5999
5654
  }
6000
- /**
6001
- * Guarded JSON.stringify for the payload blocks. A circular reference would
6002
- * otherwise crash the entire React tree on render.
6003
- */
6004
- function stringifyPayload(value) {
6005
- if (typeof value === "string") return value;
6006
- try {
6007
- return JSON.stringify(value, null, 2);
6008
- } catch (err) {
6009
- console.warn("[CopilotKit] Failed to JSON.stringify tool-call payload; falling back to String():", err);
6010
- try {
6011
- return String(value);
6012
- } catch {
6013
- return "[unserializable]";
6014
- }
6015
- }
6016
- }
6017
5655
  function Payload({ label, value }) {
6018
5656
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6019
5657
  className: "cpk-tool-call-payload-label",
6020
5658
  children: label
6021
5659
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
6022
5660
  className: "cpk-tool-call-payload-code",
6023
- children: stringifyPayload(value)
5661
+ children: (0, _copilotkit_core.ɵstringifyToolCallPayload)(value)
6024
5662
  })] });
6025
5663
  }
6026
5664
  /**
@@ -6028,13 +5666,14 @@ function Payload({ label, value }) {
6028
5666
  * @internal
6029
5667
  */
6030
5668
  function ToolCallPayloads({ parameters, result, className }) {
5669
+ const labels = useLabels$1();
6031
5670
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6032
5671
  className: require_MarkdownSurfaces.cn("cpk-tool-call-payloads", className),
6033
5672
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Payload, {
6034
- label: "Arguments",
5673
+ label: labels.toolCallArgumentsLabel,
6035
5674
  value: parameters ?? {}
6036
5675
  }), result !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Payload, {
6037
- label: "Result",
5676
+ label: labels.toolCallResultLabel,
6038
5677
  value: result
6039
5678
  })]
6040
5679
  });
@@ -6045,9 +5684,10 @@ function ToolCallPayloads({ parameters, result, className }) {
6045
5684
  * @internal
6046
5685
  */
6047
5686
  function ToolCallRow({ name, parameters, result, status, appearance, className, ...props }) {
5687
+ const labels = useLabels$1();
6048
5688
  const [open, setOpen] = (0, react.useState)(false);
6049
5689
  const detailsId = (0, react.useId)();
6050
- const preview = argumentPreview(parameters);
5690
+ const preview = (0, _copilotkit_core.ɵgetArgumentPreview)(parameters);
6051
5691
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6052
5692
  "data-copilotkit": true,
6053
5693
  className: require_MarkdownSurfaces.cn("cpk-tool-call-row", `cpk-tool-call-row-${appearance}`, className),
@@ -6072,7 +5712,7 @@ function ToolCallRow({ name, parameters, result, status, appearance, className,
6072
5712
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
6073
5713
  "data-testid": "copilot-tool-render-status",
6074
5714
  className: "cpk-tool-call-row-status",
6075
- children: statusLabels[status]
5715
+ children: labels[STATUS_LABEL_KEYS[status]]
6076
5716
  }),
6077
5717
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chevron, {
6078
5718
  open,
@@ -6101,14 +5741,15 @@ function ToolCallRow({ name, parameters, result, status, appearance, className,
6101
5741
  * draws.
6102
5742
  */
6103
5743
  function CopilotChatToolCallGroup({ calls, renderCall, appearance = "card", isActive = false, className, ...props }) {
5744
+ const labels = useLabels$1();
6104
5745
  const [open, setOpen] = (0, react.useState)(false);
6105
5746
  const bodyId = (0, react.useId)();
6106
5747
  const latest = calls[calls.length - 1];
6107
5748
  if (!latest) return null;
6108
5749
  const current = isActive ? calls.find((call) => !call.toolMessage) ?? latest : void 0;
6109
- const preview = current ? entryPreview(current) : void 0;
5750
+ const preview = current ? (0, _copilotkit_core.ɵgetToolCallPreview)(current) : void 0;
6110
5751
  const done = calls.filter((call) => call.toolMessage).length;
6111
- const statuses = calls.map((call) => entryStatus(call, isActive));
5752
+ const statuses = calls.map((call) => (0, _copilotkit_core.ɵgetToolCallRowStatus)(call, isActive));
6112
5753
  const failedIds = new Set(calls.filter((_, index) => statuses[index] === "failed").map((call) => call.toolCall.id));
6113
5754
  const status = current ? "running" : failedIds.size > 0 ? "failed" : statuses.includes("stopped") ? "stopped" : "done";
6114
5755
  const rows = (rowAppearance) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolCallGroupContext.Provider, {
@@ -6126,9 +5767,9 @@ function CopilotChatToolCallGroup({ calls, renderCall, appearance = "card", isAc
6126
5767
  "data-state": status,
6127
5768
  ...props
6128
5769
  };
6129
- const runningLabel = current && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
5770
+ const runningLabel = current && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
6130
5771
  className: "cpk-tool-call-group-running cpk-shimmer",
6131
- children: ["Running ", current.toolCall.function.name]
5772
+ children: (0, _copilotkit_core.ɵformatLabel)(labels.toolCallRunningLabel, { name: current.toolCall.function.name })
6132
5773
  }), preview && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
6133
5774
  className: "cpk-tool-call-group-preview",
6134
5775
  children: preview
@@ -6156,13 +5797,16 @@ function CopilotChatToolCallGroup({ calls, renderCall, appearance = "card", isAc
6156
5797
  onClick: () => setOpen((value) => !value),
6157
5798
  className: "cpk-tool-call-group-line-toggle",
6158
5799
  children: [runningLabel || /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
6159
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
5800
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
6160
5801
  className: "cpk-tool-call-group-line-summary",
6161
- children: ["Used ", pluralize(calls.length, "tool")]
5802
+ children: (0, _copilotkit_core.ɵformatCountLabel)(calls.length, {
5803
+ one: labels.toolCallUsedToolsOne,
5804
+ other: labels.toolCallUsedToolsOther
5805
+ })
6162
5806
  }),
6163
5807
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
6164
5808
  className: "cpk-tool-call-group-line-names",
6165
- children: toolNames(calls)
5809
+ children: (0, _copilotkit_core.ɵformatToolNames)(calls)
6166
5810
  }),
6167
5811
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FailedCount, { calls })
6168
5812
  ] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chevron, { open })]
@@ -6179,8 +5823,8 @@ function CopilotChatToolCallGroup({ calls, renderCall, appearance = "card", isAc
6179
5823
  if (appearance === "stack") {
6180
5824
  const behind = open ? 0 : Math.min(calls.length - 1, 2);
6181
5825
  const layer = "cpk-tool-call-group-stack-layer";
6182
- const latestStatus = entryStatus(latest, isActive);
6183
- const latestPreview = entryPreview(latest);
5826
+ const latestStatus = (0, _copilotkit_core.ɵgetToolCallRowStatus)(latest, isActive);
5827
+ const latestPreview = (0, _copilotkit_core.ɵgetToolCallPreview)(latest);
6184
5828
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6185
5829
  ...groupProps,
6186
5830
  className: require_MarkdownSurfaces.cn("cpk-tool-call-group cpk-tool-call-group-stack", className),
@@ -6207,11 +5851,14 @@ function CopilotChatToolCallGroup({ calls, renderCall, appearance = "card", isAc
6207
5851
  onClick: () => setOpen((value) => !value),
6208
5852
  className: require_MarkdownSurfaces.cn("cpk-tool-call-group-stack-toggle", open ? "cpk-tool-call-group-stack-toggle-open" : [layer, "cpk-tool-call-group-stack-toggle-closed"]),
6209
5853
  children: open ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
6210
- pluralize(calls.length, "tool call"),
5854
+ (0, _copilotkit_core.ɵformatCountLabel)(calls.length, {
5855
+ one: labels.toolCallToolCallCountOne,
5856
+ other: labels.toolCallToolCallCountOther
5857
+ }),
6211
5858
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FailedCount, { calls }),
6212
5859
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
6213
5860
  className: "cpk-tool-call-group-stack-collapse",
6214
- children: ["Collapse", /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chevron, {
5861
+ children: [labels.toolCallCollapseLabel, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chevron, {
6215
5862
  open: true,
6216
5863
  className: "cpk-tool-call-group-stack-collapse-icon"
6217
5864
  })]
@@ -6230,7 +5877,7 @@ function CopilotChatToolCallGroup({ calls, renderCall, appearance = "card", isAc
6230
5877
  }),
6231
5878
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
6232
5879
  className: "cpk-tool-call-group-stack-status",
6233
- children: statusLabels[latestStatus]
5880
+ children: labels[STATUS_LABEL_KEYS[latestStatus]]
6234
5881
  })
6235
5882
  ]
6236
5883
  }, latest.toolCall.id), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
@@ -6239,7 +5886,10 @@ function CopilotChatToolCallGroup({ calls, renderCall, appearance = "card", isAc
6239
5886
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FailedCount, { calls }),
6240
5887
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
6241
5888
  className: "cpk-tool-call-group-stack-count",
6242
- children: pluralize(calls.length, "call")
5889
+ children: (0, _copilotkit_core.ɵformatCountLabel)(calls.length, {
5890
+ one: labels.toolCallCallCountOne,
5891
+ other: labels.toolCallCallCountOther
5892
+ })
6243
5893
  }),
6244
5894
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chevron, {
6245
5895
  open: false,
@@ -6251,7 +5901,7 @@ function CopilotChatToolCallGroup({ calls, renderCall, appearance = "card", isAc
6251
5901
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
6252
5902
  "aria-live": "polite",
6253
5903
  className: "cpk-tool-call-group-stack-live",
6254
- children: open ? "" : `${latest.toolCall.function.name}: ${statusLabels[latestStatus]}`
5904
+ children: open ? "" : `${latest.toolCall.function.name}: ${labels[STATUS_LABEL_KEYS[latestStatus]]}`
6255
5905
  })
6256
5906
  ]
6257
5907
  }), open && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -6283,18 +5933,21 @@ function CopilotChatToolCallGroup({ calls, renderCall, appearance = "card", isAc
6283
5933
  className: "cpk-tool-call-group-card-toggle",
6284
5934
  children: [
6285
5935
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusIcon, { status }),
6286
- runningLabel || /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
5936
+ runningLabel || /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
6287
5937
  className: "cpk-tool-call-group-card-summary",
6288
- children: ["Used ", pluralize(calls.length, "tool")]
5938
+ children: (0, _copilotkit_core.ɵformatCountLabel)(calls.length, {
5939
+ one: labels.toolCallUsedToolsOne,
5940
+ other: labels.toolCallUsedToolsOther
5941
+ })
6289
5942
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
6290
5943
  className: "cpk-tool-call-group-card-names",
6291
- children: toolNames(calls)
5944
+ children: (0, _copilotkit_core.ɵformatToolNames)(calls)
6292
5945
  })] }),
6293
5946
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
6294
5947
  className: "cpk-tool-call-group-card-meta",
6295
5948
  children: [status === "failed" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FailedCount, { calls }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
6296
5949
  className: "cpk-tool-call-group-card-status",
6297
- children: status !== "running" ? statusLabels[status] : done > 0 && `${done} done`
5950
+ children: status !== "running" ? labels[STATUS_LABEL_KEYS[status]] : done > 0 && (0, _copilotkit_core.ɵformatLabel)(labels.toolCallDoneCountLabel, { count: done })
6298
5951
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chevron, { open })]
6299
5952
  })
6300
5953
  ]
@@ -7061,11 +6714,6 @@ function normalizeStaticSuggestions(suggestions) {
7061
6714
  }));
7062
6715
  }
7063
6716
 
7064
- //#endregion
7065
- //#region src/types/interrupt.ts
7066
- /** Name of the legacy custom event agents emit to signal an interrupt. */
7067
- const INTERRUPT_EVENT_NAME = "on_interrupt";
7068
-
7069
6717
  //#endregion
7070
6718
  //#region src/hooks/use-interrupt.tsx
7071
6719
  /** Recognize thenables returned by interrupt preprocessing handlers. */
@@ -7076,7 +6724,7 @@ function isPromiseLike(value) {
7076
6724
  function toLegacyEvent(pending) {
7077
6725
  if (pending.kind === "legacy") return pending.event;
7078
6726
  return {
7079
- name: INTERRUPT_EVENT_NAME,
6727
+ name: _copilotkit_core.INTERRUPT_EVENT_NAME,
7080
6728
  value: pending.interrupts[0]
7081
6729
  };
7082
6730
  }
@@ -7123,7 +6771,7 @@ function useInterrupt(config) {
7123
6771
  let localStandard = null;
7124
6772
  const subscription = agent.subscribe({
7125
6773
  onCustomEvent: ({ event }) => {
7126
- if (event.name === INTERRUPT_EVENT_NAME) localLegacy = {
6774
+ if (event.name === _copilotkit_core.INTERRUPT_EVENT_NAME) localLegacy = {
7127
6775
  name: event.name,
7128
6776
  value: event.value
7129
6777
  };
@@ -7982,297 +7630,11 @@ function useAttachments({ config }) {
7982
7630
  };
7983
7631
  }
7984
7632
 
7985
- //#endregion
7986
- //#region src/hooks/use-learning-containers.tsx
7987
- /** The default learning containers value. Matches the backend default. */
7988
- const DEFAULT_CONTAINERS = ["project"];
7989
- /**
7990
- * Legacy compatibility hook that keeps a thread's plural learning-container
7991
- * annotation in sync by emitting
7992
- * `set_learning_containers` annotations via the CopilotKit runtime annotate
7993
- * endpoint (`POST ${runtimeUrl}/annotate`).
7994
- *
7995
- * **Emit rules:**
7996
- * - On mount with `["project"]` (the backend default) → does NOT emit.
7997
- * Absence of an annotation equals the default, so the round-trip is skipped.
7998
- * - On mount with any other value → emits immediately.
7999
- * - On any subsequent content change (including a switch back to
8000
- * `["project"]`) → emits (a deliberate switch is always recorded).
8001
- * - On unmount or threadId change → emits a reset to `["project"]`
8002
- * so the backend is left in a clean state for the next consumer.
8003
- * Changing `learningContainers` within the same thread does NOT reset the
8004
- * thread; only the new value is emitted.
8005
- *
8006
- * Content-equality is evaluated via `JSON.stringify` so a fresh array literal
8007
- * with the same items does NOT trigger a redundant emit.
8008
- *
8009
- * If `runtimeUrl` is absent, all emits are silently skipped.
8010
- *
8011
- * @example
8012
- * ```tsx
8013
- * function ThreadPane({ threadId, userScope }: Props) {
8014
- * useLearningContainers({
8015
- * threadId,
8016
- * learningContainers: [userScope],
8017
- * });
8018
- * // ...
8019
- * }
8020
- * ```
8021
- *
8022
- * @deprecated This hook supports only the legacy plural-container annotation.
8023
- * Configure `getLearningContainerId` on `CopilotKitIntelligence` for new
8024
- * Intelligence runtimes.
8025
- */
8026
- function useLearningContainers({ threadId, learningContainers }) {
8027
- const { copilotkit } = (0, _copilotkit_react_core_context.useCopilotKit)();
8028
- /**
8029
- * Tracks the last-synced container list so content-identical rerenders
8030
- * (fresh array, same values) do not fire a redundant emit.
8031
- * `null` = nothing synced yet (initial state or after a threadId reset).
8032
- */
8033
- const lastSyncedRef = (0, react.useRef)(null);
8034
- /** Guards the missing-runtimeUrl warning so it fires at most once per hook instance. */
8035
- const warnedMissingUrlRef = (0, react.useRef)(false);
8036
- const runtimeUrlRef = (0, react.useRef)(copilotkit.runtimeUrl);
8037
- const runtimeFetchRef = (0, react.useRef)(copilotkit.ɵruntimeFetch);
8038
- runtimeUrlRef.current = copilotkit.runtimeUrl;
8039
- runtimeFetchRef.current = copilotkit.ɵruntimeFetch;
8040
- const key = JSON.stringify(learningContainers);
8041
- const defaultKey = JSON.stringify(DEFAULT_CONTAINERS);
8042
- (0, react.useEffect)(() => {
8043
- const runtimeUrl = copilotkit.runtimeUrl;
8044
- /**
8045
- * Fire-and-forget emit; errors must not surface in render.
8046
- * Failures are logged as warnings so they are diagnosable without
8047
- * propagating into the React render cycle.
8048
- */
8049
- const emit = (containers) => {
8050
- if (!runtimeUrl) {
8051
- if (!warnedMissingUrlRef.current) {
8052
- warnedMissingUrlRef.current = true;
8053
- console.warn("useLearningContainers: runtimeUrl not configured; learning-container sync disabled");
8054
- }
8055
- return;
8056
- }
8057
- recordAnnotation({
8058
- fetch: copilotkit.ɵruntimeFetch,
8059
- runtimeUrl,
8060
- headers: {},
8061
- type: "set_learning_containers",
8062
- payload: { containers },
8063
- threadId
8064
- }).catch((err) => {
8065
- console.warn("useLearningContainers: failed to record set_learning_containers", err);
8066
- });
8067
- };
8068
- if (lastSyncedRef.current === null) {
8069
- if (key === defaultKey) {
8070
- lastSyncedRef.current = learningContainers;
8071
- return;
8072
- }
8073
- emit(learningContainers);
8074
- lastSyncedRef.current = learningContainers;
8075
- } else if (key !== JSON.stringify(lastSyncedRef.current)) {
8076
- emit(learningContainers);
8077
- lastSyncedRef.current = learningContainers;
8078
- }
8079
- }, [threadId, key]);
8080
- (0, react.useEffect)(() => {
8081
- const capturedThreadId = threadId;
8082
- return () => {
8083
- const capturedRuntimeUrl = runtimeUrlRef.current;
8084
- if (capturedRuntimeUrl) recordAnnotation({
8085
- fetch: runtimeFetchRef.current,
8086
- runtimeUrl: capturedRuntimeUrl,
8087
- headers: {},
8088
- type: "set_learning_containers",
8089
- payload: { containers: DEFAULT_CONTAINERS },
8090
- threadId: capturedThreadId
8091
- }).catch((err) => {
8092
- console.warn("useLearningContainers: failed to record set_learning_containers", err);
8093
- });
8094
- lastSyncedRef.current = null;
8095
- };
8096
- }, [threadId]);
8097
- }
8098
-
8099
- //#endregion
8100
- //#region src/hooks/use-learning-containers-in-current-thread.tsx
8101
- /**
8102
- * Legacy compatibility hook that keeps the **current chat thread's** plural
8103
- * learning-container annotation in sync. The `threadId` is sourced from the surrounding
8104
- * `<CopilotChatConfigurationProvider>` (the same provider `<CopilotChat>`,
8105
- * `<CopilotSidebar>`, and friends set up), so callers in a chat-aware
8106
- * subtree don't need to thread an id through manually.
8107
- *
8108
- * **Throws on render** when there is no chat-config provider in scope or
8109
- * when the provider does not yet have an active `threadId`. Mount the hook
8110
- * inside a subtree that is guaranteed to have a thread context.
8111
- *
8112
- * If you need to manage an explicit thread, use {@link useLearningContainers}
8113
- * directly — two hooks, two crisp contracts, no mode confusion.
8114
- *
8115
- * @throws When no `CopilotChatConfigurationProvider` is in scope or when the
8116
- * active `threadId` is absent/empty.
8117
- *
8118
- * @example
8119
- * ```tsx
8120
- * function ThreadPanel({ scope }: Props) {
8121
- * useLearningContainersInCurrentThread({
8122
- * learningContainers: [scope],
8123
- * });
8124
- * // ...
8125
- * }
8126
- * ```
8127
- *
8128
- * @deprecated This hook supports only the legacy plural-container annotation.
8129
- * Configure `getLearningContainerId` on `CopilotKitIntelligence` for new
8130
- * Intelligence runtimes.
8131
- */
8132
- function useLearningContainersInCurrentThread({ learningContainers }) {
8133
- const threadId = require_MarkdownSurfaces.useCopilotChatConfiguration()?.threadId;
8134
- 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.");
8135
- useLearningContainers({
8136
- threadId,
8137
- learningContainers
8138
- });
8139
- }
8140
-
8141
7633
  //#endregion
8142
7634
  //#region src/components/chat/tool-call-display-context.ts
8143
7635
  /** @internal */
8144
7636
  const ToolCallDisplayContext = (0, react.createContext)(null);
8145
7637
 
8146
- //#endregion
8147
- //#region src/components/chat/tool-call-layout.ts
8148
- function contentLength(content) {
8149
- return typeof content === "string" ? content.length : JSON.stringify(content ?? "").length;
8150
- }
8151
- const entrySignature = ({ toolCall, toolMessage }) => [
8152
- toolCall.id,
8153
- toolCall.function.name,
8154
- toolCall.function.arguments.length,
8155
- toolMessage ? `${contentLength(toolMessage.content)}${toolMessage.error ? "!" : ""}` : "-"
8156
- ].join(":");
8157
- function signatureOf(segments) {
8158
- return segments.map((segment) => segment.kind === "call" ? `c(${entrySignature(segment.call)})` : `g${segment.trailing ? "*" : ""}(${segment.calls.map(entrySignature).join(",")})`).join("|");
8159
- }
8160
- /** Index of tool results by the call they answer. */
8161
- function getToolResults(messages) {
8162
- const results = /* @__PURE__ */ new Map();
8163
- for (const message of messages) if (message.role === "tool") results.set(message.toolCallId, message);
8164
- return results;
8165
- }
8166
- /**
8167
- * Lays out the tool calls of every assistant message in `rendered`.
8168
- *
8169
- * Calls drawn by a renderer that opted into grouping join the group that's
8170
- * open; anything else that shows between them closes it: assistant text, a
8171
- * user, reasoning or activity message, or a call drawn by any other renderer. A group belongs to
8172
- * the message where it starts, so later messages whose calls joined it render
8173
- * no tool calls themselves.
8174
- *
8175
- * @param rendered - The messages as the chat renders them, in order.
8176
- * @param all - Every message, for finding tool results (a transform may hide them).
8177
- * @param renderers - The registered renderers.
8178
- */
8179
- function getToolCallLayouts(rendered, all, renderers) {
8180
- const results = getToolResults(all);
8181
- const layouts = /* @__PURE__ */ new Map();
8182
- let open;
8183
- for (const message of rendered) {
8184
- if (message.role === "tool") continue;
8185
- if (message.role !== "assistant") {
8186
- open = void 0;
8187
- continue;
8188
- }
8189
- if (typeof message.content === "string" && message.content.trim()) open = void 0;
8190
- const segments = [];
8191
- layouts.set(message.id, segments);
8192
- const toolCalls = /* @__PURE__ */ new Map();
8193
- for (const toolCall of message.toolCalls ?? []) toolCalls.set(toolCall.id, toolCall);
8194
- for (const toolCall of toolCalls.values()) {
8195
- const entry = {
8196
- toolCall,
8197
- toolMessage: results.get(toolCall.id)
8198
- };
8199
- const name = toolCall.function.name;
8200
- const named = renderers.named.has(name);
8201
- const rendered = named || renderers.wildcard;
8202
- const groups = named ? renderers.groupedNames.has(name) : renderers.wildcardGroups;
8203
- if (!rendered || !groups) {
8204
- if (rendered) open = void 0;
8205
- segments.push({
8206
- kind: "call",
8207
- id: toolCall.id,
8208
- call: entry,
8209
- rendered
8210
- });
8211
- } else if (open) open.calls.push(entry);
8212
- else {
8213
- open = {
8214
- kind: "group",
8215
- id: toolCall.id,
8216
- calls: [entry],
8217
- trailing: false
8218
- };
8219
- segments.push(open);
8220
- }
8221
- }
8222
- }
8223
- if (open) open.trailing = true;
8224
- const layout = /* @__PURE__ */ new Map();
8225
- for (const [id, segments] of layouts) layout.set(id, {
8226
- segments,
8227
- signature: signatureOf(segments)
8228
- });
8229
- return layout;
8230
- }
8231
- /**
8232
- * Finds the working phase of every reply in `rendered`: its messages up to the
8233
- * last one that calls a tool. Text in there was narration; what follows is the
8234
- * reply itself. Replies that called no tools are omitted, except the latest,
8235
- * which may be about to.
8236
- */
8237
- function getTurnWork(rendered, layouts) {
8238
- const turns = /* @__PURE__ */ new Map();
8239
- let start = 0;
8240
- while (start < rendered.length) {
8241
- let end = start;
8242
- while (end < rendered.length && rendered[end].role !== "user") end++;
8243
- const key = start > 0 ? rendered[start - 1].id : "start";
8244
- const visible = rendered.slice(start, end).filter((message) => message.role !== "tool");
8245
- const isLatest = end === rendered.length;
8246
- const calls = [];
8247
- for (const message of visible) for (const segment of layouts.get(message.id)?.segments ?? []) if (segment.kind === "group") calls.push(...segment.calls);
8248
- else if (segment.rendered) calls.push(segment.call);
8249
- const shown = new Set(calls.map((entry) => entry.toolCall.id));
8250
- let lastWork = -1;
8251
- visible.forEach((message, index) => {
8252
- if (message.role === "assistant" && message.toolCalls?.some((call) => shown.has(call.id))) lastWork = index;
8253
- });
8254
- const first = visible[0];
8255
- if (first && (calls.length > 0 || isLatest)) {
8256
- let lastAssistant = -1;
8257
- visible.forEach((message, index) => {
8258
- if (message.role === "assistant") lastAssistant = index;
8259
- });
8260
- const replyText = visible[lastAssistant]?.content;
8261
- const endsWithWork = lastAssistant >= 0 && lastAssistant <= lastWork && typeof replyText === "string" && replyText.trim().length > 0;
8262
- turns.set(key, {
8263
- key,
8264
- firstMessageId: first.id,
8265
- workMessageIds: new Set(visible.slice(0, lastWork + 1).map((message) => message.id)),
8266
- replyTextMessageId: endsWithWork ? visible[lastAssistant].id : void 0,
8267
- calls,
8268
- isLatest
8269
- });
8270
- }
8271
- start = end + 1;
8272
- }
8273
- return turns;
8274
- }
8275
-
8276
7638
  //#endregion
8277
7639
  //#region src/components/chat/CopilotChatToolCallsView.tsx
8278
7640
  const appearances = {
@@ -8292,7 +7654,7 @@ function CopilotChatToolCallsView({ message, messages = [], display: displayProp
8292
7654
  const viewLayout = context?.layouts.get(message.id);
8293
7655
  const layout = (0, react.useMemo)(() => {
8294
7656
  if (display === "separate") return void 0;
8295
- return viewLayout ?? getToolCallLayouts([message], messages, rendererNames).get(message.id);
7657
+ return viewLayout ?? (0, _copilotkit_core.ɵgetToolCallLayouts)([message], messages, rendererNames).get(message.id);
8296
7658
  }, [
8297
7659
  display,
8298
7660
  viewLayout,
@@ -8482,7 +7844,7 @@ function InspectorKiteIcon({ className, ...props }) {
8482
7844
  });
8483
7845
  }
8484
7846
  function CopilotChatInspectorButton({ title, className, onClick, onPointerDown, onPointerEnter, onPointerLeave, onKeyDown, disabled, ...props }) {
8485
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
7847
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
8486
7848
  const { isInspectorEnabled } = useCopilotKitInspector();
8487
7849
  const hidden = useInspectorShortcutsHidden();
8488
7850
  const [open, setOpen] = (0, react.useState)(false);
@@ -8551,7 +7913,8 @@ function CopilotChatInspectorButton({ title, className, onClick, onPointerDown,
8551
7913
  event.currentTarget.click();
8552
7914
  }
8553
7915
  },
8554
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Wrench, {
7916
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
7917
+ name: "Wrench",
8555
7918
  "aria-hidden": "true",
8556
7919
  className: "cpk-inspector-button-icon",
8557
7920
  "data-testid": "copilot-inspector-icon"
@@ -8618,7 +7981,8 @@ function CopilotChatInspectorButton({ title, className, onClick, onPointerDown,
8618
7981
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DropdownMenuItem, {
8619
7982
  onSelect: hideShortcuts,
8620
7983
  className: "cpk-inspector-button-menu-item cpk-inspector-button-hide-item",
8621
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.EyeOff, {
7984
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
7985
+ name: "EyeOff",
8622
7986
  "aria-hidden": "true",
8623
7987
  className: "cpk-inspector-button-menu-item-icon"
8624
7988
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
@@ -9012,7 +8376,7 @@ function nextFocusable(element, skip) {
9012
8376
  * control after the thumb, and Enter or Escape inside it returns to the thumb.
9013
8377
  */
9014
8378
  function FeedbackCommentPopover({ feedbackComment, comment, savedComment, rating, anchor, messageId }) {
9015
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
8379
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
9016
8380
  const contentRef = (0, react.useRef)(null);
9017
8381
  const focusInside = () => contentRef.current?.contains(document.activeElement) ?? false;
9018
8382
  const { focusRequest, takeFocusRequest, inputRef } = comment;
@@ -9316,7 +8680,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
9316
8680
  });
9317
8681
  };
9318
8682
  _CopilotChatAssistantMessage.CopyButton = ({ className, title, onClick, ...props }) => {
9319
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
8683
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
9320
8684
  const [copied, setCopied] = (0, react.useState)(false);
9321
8685
  const timerRef = (0, react.useRef)(null);
9322
8686
  (0, react.useEffect)(() => {
@@ -9342,36 +8706,44 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
9342
8706
  onClick: handleClick,
9343
8707
  className,
9344
8708
  ...props,
9345
- 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" })
8709
+ children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
8710
+ name: "Check",
8711
+ className: "cpk-assistant-message-toolbar-icon"
8712
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
8713
+ name: "Copy",
8714
+ className: "cpk-assistant-message-toolbar-icon"
8715
+ })
9346
8716
  });
9347
8717
  };
9348
8718
  _CopilotChatAssistantMessage.InspectorButton = CopilotChatInspectorButton;
9349
8719
  _CopilotChatAssistantMessage.ThumbsUpButton = ({ title, ...props }) => {
9350
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
8720
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
9351
8721
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
9352
8722
  "data-testid": "copilot-thumbs-up-button",
9353
8723
  title: title || labels.assistantMessageToolbarThumbsUpLabel,
9354
8724
  ...props,
9355
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ThumbsUp, {
8725
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
8726
+ name: "ThumbsUp",
9356
8727
  className: "cpk-assistant-message-toolbar-icon",
9357
8728
  fill: props["aria-pressed"] === true ? "currentColor" : "none"
9358
8729
  })
9359
8730
  });
9360
8731
  };
9361
8732
  _CopilotChatAssistantMessage.ThumbsDownButton = ({ title, ...props }) => {
9362
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
8733
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
9363
8734
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
9364
8735
  "data-testid": "copilot-thumbs-down-button",
9365
8736
  title: title || labels.assistantMessageToolbarThumbsDownLabel,
9366
8737
  ...props,
9367
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ThumbsDown, {
8738
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
8739
+ name: "ThumbsDown",
9368
8740
  className: "cpk-assistant-message-toolbar-icon",
9369
8741
  fill: props["aria-pressed"] === true ? "currentColor" : "none"
9370
8742
  })
9371
8743
  });
9372
8744
  };
9373
8745
  _CopilotChatAssistantMessage.FeedbackComment = ({ value, savedComment, inputRef, onChange, onSubmit, onEditingChange, onLeave, className }) => {
9374
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
8746
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
9375
8747
  const changed = value.trim() !== savedComment;
9376
8748
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
9377
8749
  "data-testid": "copilot-feedback-comment",
@@ -9401,26 +8773,35 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
9401
8773
  variant: "assistantMessageToolbarButton",
9402
8774
  "aria-label": labels.assistantMessageFeedbackCommentSubmitLabel,
9403
8775
  title: labels.assistantMessageFeedbackCommentSubmitLabel,
9404
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ArrowUp, { className: "cpk-assistant-message-feedback-comment-submit-icon" })
8776
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
8777
+ name: "ArrowUp",
8778
+ className: "cpk-assistant-message-feedback-comment-submit-icon"
8779
+ })
9405
8780
  })]
9406
8781
  });
9407
8782
  };
9408
8783
  _CopilotChatAssistantMessage.ReadAloudButton = ({ title, ...props }) => {
9409
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
8784
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
9410
8785
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
9411
8786
  "data-testid": "copilot-read-aloud-button",
9412
8787
  title: title || labels.assistantMessageToolbarReadAloudLabel,
9413
8788
  ...props,
9414
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Volume2, { className: "cpk-assistant-message-read-aloud-icon" })
8789
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
8790
+ name: "Volume2",
8791
+ className: "cpk-assistant-message-read-aloud-icon"
8792
+ })
9415
8793
  });
9416
8794
  };
9417
8795
  _CopilotChatAssistantMessage.RegenerateButton = ({ title, ...props }) => {
9418
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
8796
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
9419
8797
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
9420
8798
  "data-testid": "copilot-regenerate-button",
9421
8799
  title: title || labels.assistantMessageToolbarRegenerateLabel,
9422
8800
  ...props,
9423
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.RefreshCw, { className: "cpk-assistant-message-toolbar-icon" })
8801
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
8802
+ name: "RefreshCw",
8803
+ className: "cpk-assistant-message-toolbar-icon"
8804
+ })
9424
8805
  });
9425
8806
  };
9426
8807
  })(CopilotChatAssistantMessage || (CopilotChatAssistantMessage = {}));
@@ -9443,7 +8824,7 @@ var CopilotChatAssistantMessage_default = CopilotChatAssistantMessage;
9443
8824
  * `labels.attachmentPreviewCloseButtonLabel`.
9444
8825
  */
9445
8826
  function Lightbox({ onClose, children }) {
9446
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
8827
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
9447
8828
  (0, react.useEffect)(() => {
9448
8829
  const handleKey = (e) => {
9449
8830
  if (e.key === "Escape") onClose();
@@ -9459,7 +8840,10 @@ function Lightbox({ onClose, children }) {
9459
8840
  onClick: onClose,
9460
8841
  className: "cpk-attachment-lightbox-close-button",
9461
8842
  "aria-label": labels.attachmentPreviewCloseButtonLabel,
9462
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, { className: "cpk-attachment-lightbox-close-icon" })
8843
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
8844
+ name: "X",
8845
+ className: "cpk-attachment-lightbox-close-icon"
8846
+ })
9463
8847
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
9464
8848
  onClick: (e) => e.stopPropagation(),
9465
8849
  children
@@ -9513,17 +8897,22 @@ function useLightbox() {
9513
8897
 
9514
8898
  //#endregion
9515
8899
  //#region src/components/chat/CopilotChatAttachmentRenderer.tsx
8900
+ /** The chat labels from the nearest chat configuration, or the defaults. */
8901
+ function useLabels() {
8902
+ return require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
8903
+ }
9516
8904
  const ImageAttachment = (0, react.memo)(function ImageAttachment({ src, className }) {
8905
+ const labels = useLabels();
9517
8906
  const [error, setError] = (0, react.useState)(false);
9518
8907
  const { thumbnailRef, vtName, open, openLightbox, closeLightbox } = useLightbox();
9519
8908
  if (error) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
9520
8909
  className: require_MarkdownSurfaces.cn("cpk-attachment-renderer cpk-attachment-renderer-image-error", className),
9521
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "Failed to load image" })
8910
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: labels.attachmentImageLoadErrorText })
9522
8911
  });
9523
8912
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
9524
8913
  ref: thumbnailRef,
9525
8914
  src,
9526
- alt: "Image attachment",
8915
+ alt: labels.attachmentImageAltText,
9527
8916
  className: require_MarkdownSurfaces.cn("cpk-attachment-renderer cpk-attachment-renderer-image", className),
9528
8917
  onClick: openLightbox,
9529
8918
  onError: () => setError(true)
@@ -9532,7 +8921,7 @@ const ImageAttachment = (0, react.memo)(function ImageAttachment({ src, classNam
9532
8921
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
9533
8922
  style: { viewTransitionName: vtName },
9534
8923
  src,
9535
- alt: "Image attachment",
8924
+ alt: labels.attachmentImageAltText,
9536
8925
  className: "cpk-attachment-renderer-lightbox-image"
9537
8926
  })
9538
8927
  })] });
@@ -9560,7 +8949,8 @@ const VideoAttachment = (0, react.memo)(function VideoAttachment({ src, classNam
9560
8949
  });
9561
8950
  });
9562
8951
  const DocumentAttachment = (0, react.memo)(function DocumentAttachment({ src, source, filename, className }) {
9563
- const label = filename || source.mimeType || "Document attachment";
8952
+ const labels = useLabels();
8953
+ const label = filename || source.mimeType || labels.attachmentDocumentAltText;
9564
8954
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
9565
8955
  href: src,
9566
8956
  download: filename ?? "",
@@ -9573,7 +8963,7 @@ const DocumentAttachment = (0, react.memo)(function DocumentAttachment({ src, so
9573
8963
  children: (0, _copilotkit_shared.getDocumentIcon)(source.mimeType ?? "")
9574
8964
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
9575
8965
  className: "cpk-attachment-renderer-document-name",
9576
- children: filename || source.mimeType || "Unknown type"
8966
+ children: filename || source.mimeType || labels.attachmentUnknownTypeText
9577
8967
  })]
9578
8968
  });
9579
8969
  });
@@ -9712,7 +9102,7 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
9712
9102
  })] });
9713
9103
  };
9714
9104
  _CopilotChatUserMessage.CopyButton = ({ className, title, onClick, ...props }) => {
9715
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
9105
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
9716
9106
  const [copied, setCopied] = (0, react.useState)(false);
9717
9107
  const handleClick = async (event) => {
9718
9108
  let success = false;
@@ -9728,21 +9118,30 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
9728
9118
  onClick: handleClick,
9729
9119
  className,
9730
9120
  ...props,
9731
- 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" })
9121
+ children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
9122
+ name: "Check",
9123
+ className: "cpk-user-message-toolbar-icon"
9124
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
9125
+ name: "Copy",
9126
+ className: "cpk-user-message-toolbar-icon"
9127
+ })
9732
9128
  });
9733
9129
  };
9734
9130
  _CopilotChatUserMessage.EditButton = ({ className, title, ...props }) => {
9735
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
9131
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
9736
9132
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
9737
9133
  "data-testid": "copilot-edit-button",
9738
9134
  title: title || labels.userMessageToolbarEditMessageLabel,
9739
9135
  className,
9740
9136
  ...props,
9741
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Edit, { className: "cpk-user-message-toolbar-icon" })
9137
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
9138
+ name: "Edit",
9139
+ className: "cpk-user-message-toolbar-icon"
9140
+ })
9742
9141
  });
9743
9142
  };
9744
9143
  _CopilotChatUserMessage.BranchNavigation = ({ className, currentBranch = 0, numberOfBranches = 1, onSwitchToBranch, message, ...props }) => {
9745
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
9144
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
9746
9145
  if (!numberOfBranches || numberOfBranches <= 1 || !onSwitchToBranch) return null;
9747
9146
  const canGoPrev = currentBranch > 0;
9748
9147
  const canGoNext = currentBranch < numberOfBranches - 1;
@@ -9762,7 +9161,10 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
9762
9161
  disabled: !canGoPrev,
9763
9162
  className: "cpk-user-message-branch-button",
9764
9163
  "aria-label": labels.userMessageToolbarPreviousBranchLabel,
9765
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronLeft, { className: "cpk-user-message-branch-icon" })
9164
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
9165
+ name: "ChevronLeft",
9166
+ className: "cpk-user-message-branch-icon"
9167
+ })
9766
9168
  }),
9767
9169
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
9768
9170
  className: "cpk-user-message-branch-counter",
@@ -9783,7 +9185,10 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
9783
9185
  disabled: !canGoNext,
9784
9186
  className: "cpk-user-message-branch-button",
9785
9187
  "aria-label": labels.userMessageToolbarNextBranchLabel,
9786
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, { className: "cpk-user-message-branch-icon" })
9188
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
9189
+ name: "ChevronRight",
9190
+ className: "cpk-user-message-branch-icon"
9191
+ })
9787
9192
  })
9788
9193
  ]
9789
9194
  });
@@ -9801,24 +9206,35 @@ var CopilotChatUserMessage_default = CopilotChatUserMessage;
9801
9206
  //#endregion
9802
9207
  //#region src/components/chat/CopilotChatReasoningMessage.tsx
9803
9208
  /**
9804
- * Formats an elapsed duration (in seconds) to a human-readable string.
9209
+ * The reasoning time as label text, such as "4 seconds" or "1m 5s".
9210
+ *
9211
+ * @param seconds - The elapsed time in seconds. It may have a fraction.
9212
+ * @param labels - The chat labels that hold the duration texts.
9805
9213
  */
9806
- function formatDuration$1(seconds) {
9807
- if (seconds < 1) return "a few seconds";
9808
- if (seconds < 60) return `${Math.round(seconds)} seconds`;
9809
- const mins = Math.floor(seconds / 60);
9810
- const secs = Math.round(seconds % 60);
9811
- if (secs === 0) return `${mins} minute${mins > 1 ? "s" : ""}`;
9812
- return `${mins}m ${secs}s`;
9813
- }
9214
+ function formatDuration(seconds, labels) {
9215
+ const duration = (0, _copilotkit_core.ɵformatReasoningDuration)(seconds);
9216
+ switch (duration.unit) {
9217
+ case "fewSeconds": return labels.reasoningMessageDurationFewSeconds;
9218
+ case "seconds": return (0, _copilotkit_core.ɵformatLabel)(labels.reasoningMessageDurationSeconds, { count: duration.seconds });
9219
+ case "minutes": return (0, _copilotkit_core.ɵformatCountLabel)(duration.minutes, {
9220
+ one: labels.reasoningMessageDurationMinutesOne,
9221
+ other: labels.reasoningMessageDurationMinutesOther
9222
+ });
9223
+ case "minutesSeconds": return (0, _copilotkit_core.ɵformatLabel)(labels.reasoningMessageDurationMinutesSeconds, {
9224
+ minutes: duration.minutes,
9225
+ seconds: duration.seconds
9226
+ });
9227
+ }
9228
+ }
9814
9229
  /**
9815
9230
  * A reasoning message as a collapsible block. While the model reasons it is
9816
9231
  * open and the header shows `labels.reasoningMessageThinkingLabel`; when
9817
- * streaming ends it collapses and the header reads "Thought for …". The
9232
+ * streaming ends it collapses and the header reads
9233
+ * `labels.reasoningMessageThoughtForLabel` ("Thought for 4 seconds"). The
9818
9234
  * `header` slot also receives `elapsedSeconds`.
9819
9235
  */
9820
9236
  function CopilotChatReasoningMessage({ message, messages, isRunning, isLatest: isLatestProp, header, contentView, toggle, children, className, ...props }) {
9821
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
9237
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
9822
9238
  const isLatest = isLatestProp ?? messages?.[messages.length - 1]?.id === message.id;
9823
9239
  const isStreaming = !!(isRunning && isLatest);
9824
9240
  const hasContent = !!(message.content && message.content.length > 0);
@@ -9848,7 +9264,7 @@ function CopilotChatReasoningMessage({ message, messages, isRunning, isLatest: i
9848
9264
  userToggledRef.current = true;
9849
9265
  setIsOpen((prev) => !prev);
9850
9266
  } : void 0;
9851
- const label = isStreaming ? labels.reasoningMessageThinkingLabel : `Thought for ${formatDuration$1(elapsed)}`;
9267
+ const label = isStreaming ? labels.reasoningMessageThinkingLabel : (0, _copilotkit_core.ɵformatLabel)(labels.reasoningMessageThoughtForLabel, { duration: formatDuration(elapsed, labels) });
9852
9268
  const boundHeader = require_MarkdownSurfaces.renderSlot(header, CopilotChatReasoningMessage.Header, {
9853
9269
  isOpen,
9854
9270
  label,
@@ -9903,7 +9319,10 @@ function CopilotChatReasoningMessage({ message, messages, isRunning, isLatest: i
9903
9319
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "cpk-reasoning-message-indicator-dot" })
9904
9320
  }),
9905
9321
  headerChildren,
9906
- isExpandable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, { className: require_MarkdownSurfaces.cn("cpk-reasoning-message-chevron", isOpen && "cpk-reasoning-message-chevron-open") })
9322
+ isExpandable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
9323
+ name: "ChevronRight",
9324
+ className: require_MarkdownSurfaces.cn("cpk-reasoning-message-chevron", isOpen && "cpk-reasoning-message-chevron-open")
9325
+ })
9907
9326
  ]
9908
9327
  });
9909
9328
  };
@@ -9957,7 +9376,8 @@ const CopilotChatSuggestionPill = react.default.forwardRef(function CopilotChatS
9957
9376
  ...props,
9958
9377
  children: [isLoading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
9959
9378
  className: "cpk-suggestion-pill-icon",
9960
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Loader2, {
9379
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
9380
+ name: "Loader2",
9961
9381
  className: "cpk-suggestion-pill-spinner",
9962
9382
  "aria-hidden": "true"
9963
9383
  })
@@ -10074,14 +9494,6 @@ const ScrollPinnedContext = react.default.createContext(false);
10074
9494
 
10075
9495
  //#endregion
10076
9496
  //#region src/components/chat/CopilotChatWorkSummary.tsx
10077
- /** "45s", "1m 5s", "2m". Used for the live timer and the final duration. */
10078
- function formatDuration(ms) {
10079
- const seconds = Math.max(0, Math.floor(ms / 1e3));
10080
- if (seconds < 60) return `${seconds}s`;
10081
- const minutes = Math.floor(seconds / 60);
10082
- const rest = seconds % 60;
10083
- return rest ? `${minutes}m ${rest}s` : `${minutes}m`;
10084
- }
10085
9497
  /** Re-renders every second while `active`, returning the current time. */
10086
9498
  function useNow(active) {
10087
9499
  const [now, setNow] = (0, react.useState)(() => Date.now());
@@ -10095,14 +9507,20 @@ function useNow(active) {
10095
9507
  }
10096
9508
  /**
10097
9509
  * The line at the top of a reply in the `"turn"` tool-call display. While the
10098
- * agent works it reads "Working 4s"; once the reply is done it reads "Worked
10099
- * for 9s · 7 tools" and toggles the work it folded away.
9510
+ * agent works it reads "Working 4s". Once the reply is done it reads "Worked
9511
+ * for 9s" and "7 tools", and toggles the work it folded away. The text comes
9512
+ * from the `workSummary...` and `toolCall...` chat labels.
10100
9513
  */
10101
9514
  function CopilotChatWorkSummary({ isWorking, isOpen, calls, elapsedMs, workingSince, className, ...props }) {
9515
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
10102
9516
  const now = useNow(isWorking);
10103
- const failed = calls.filter((call) => call.toolMessage?.error).length;
9517
+ const failed = (0, _copilotkit_core.ɵcountFailedToolCalls)(calls);
9518
+ const toolCount = (0, _copilotkit_core.ɵformatCountLabel)(calls.length, {
9519
+ one: labels.toolCallToolCountOne,
9520
+ other: labels.toolCallToolCountOther
9521
+ });
10104
9522
  const liveMs = elapsedMs !== void 0 && workingSince !== void 0 ? elapsedMs + Math.max(0, now - workingSince) : void 0;
10105
- const duration = elapsedMs !== void 0 ? formatDuration(Math.max(1e3, elapsedMs)) : void 0;
9523
+ const duration = elapsedMs !== void 0 ? (0, _copilotkit_core.ɵformatWorkDuration)(Math.max(1e3, elapsedMs)) : void 0;
10106
9524
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
10107
9525
  type: "button",
10108
9526
  "data-copilotkit": true,
@@ -10113,24 +9531,28 @@ function CopilotChatWorkSummary({ isWorking, isOpen, calls, elapsedMs, workingSi
10113
9531
  ...props,
10114
9532
  children: [isWorking ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10115
9533
  className: "cpk-work-summary-label cpk-shimmer",
10116
- children: "Working"
9534
+ children: labels.workSummaryWorkingLabel
10117
9535
  }), liveMs !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10118
9536
  className: "cpk-work-summary-detail cpk-work-summary-timer",
10119
- children: formatDuration(liveMs)
9537
+ children: (0, _copilotkit_core.ɵformatWorkDuration)(liveMs)
10120
9538
  })] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
10121
9539
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10122
9540
  className: "cpk-work-summary-label",
10123
- children: duration ? `Worked for ${duration}` : `Used ${pluralize(calls.length, "tool")}`
9541
+ children: duration ? (0, _copilotkit_core.ɵformatLabel)(labels.workSummaryWorkedForLabel, { duration }) : (0, _copilotkit_core.ɵformatCountLabel)(calls.length, {
9542
+ one: labels.toolCallUsedToolsOne,
9543
+ other: labels.toolCallUsedToolsOther
9544
+ })
10124
9545
  }),
10125
9546
  duration && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10126
9547
  className: "cpk-work-summary-detail",
10127
- children: pluralize(calls.length, "tool")
9548
+ children: toolCount
10128
9549
  }),
10129
- failed > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
9550
+ failed > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10130
9551
  className: "cpk-work-summary-failed",
10131
- children: [failed, " failed"]
9552
+ children: (0, _copilotkit_core.ɵformatLabel)(labels.toolCallFailedCountLabel, { count: failed })
10132
9553
  })
10133
- ] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, {
9554
+ ] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
9555
+ name: "ChevronRight",
10134
9556
  "aria-hidden": "true",
10135
9557
  className: require_MarkdownSurfaces.cn("cpk-work-summary-chevron", isOpen && "cpk-work-summary-chevron-open")
10136
9558
  })]
@@ -10545,68 +9967,6 @@ const MemoizedCustomMessage = react.default.memo(function MemoizedCustomMessage(
10545
9967
  if (JSON.stringify(prevProps.stateSnapshot) !== JSON.stringify(nextProps.stateSnapshot)) return false;
10546
9968
  return true;
10547
9969
  });
10548
- /**
10549
- * Deduplicates messages by ID. For assistant messages, merges occurrences:
10550
- * recovers non-empty content from any earlier occurrence if the latest wiped it
10551
- * (empty string means the streaming update cleared the field, not blank text),
10552
- * and similarly recovers toolCalls from earlier occurrences if the latest is
10553
- * undefined (an empty array [] is treated as intentional and kept as-is).
10554
- * For all other roles, keeps the last entry.
10555
- *
10556
- * @internal Exported for unit testing only — not part of the public API.
10557
- */
10558
- /**
10559
- * Collapse tool calls that share an id, keeping first-seen order.
10560
- *
10561
- * AG-UI's TOOL_CALL_START handler appends to the parent message's `toolCalls`
10562
- * without checking whether that id is already present. So whenever a start
10563
- * event is applied twice — which the human-in-the-loop flow triggers when the
10564
- * run syncs after `respond()` — the message ends up carrying the same call
10565
- * twice. The second copy has EMPTY `arguments`, because a start event carries
10566
- * none; the args arrive later as TOOL_CALL_ARGS deltas addressed to the first
10567
- * copy.
10568
- *
10569
- * Left alone that renders the same tool call twice: once populated and once
10570
- * blank (an approval card with no transaction id, offering live buttons for an
10571
- * action already taken), and React warns "Encountered two children with the
10572
- * same key" because the call id is the render key.
10573
- *
10574
- * The empty copy is the redundant one, so prefer whichever entry actually
10575
- * carries arguments rather than blindly taking the first.
10576
- */
10577
- function dedupeToolCalls(toolCalls) {
10578
- const byId = /* @__PURE__ */ new Map();
10579
- for (const toolCall of toolCalls) {
10580
- const existing = byId.get(toolCall.id);
10581
- if (!existing) {
10582
- byId.set(toolCall.id, toolCall);
10583
- continue;
10584
- }
10585
- if (!existing.function?.arguments && toolCall.function?.arguments) byId.set(toolCall.id, toolCall);
10586
- }
10587
- return byId.size === toolCalls.length ? toolCalls : [...byId.values()];
10588
- }
10589
- function deduplicateMessages(messages) {
10590
- const acc = /* @__PURE__ */ new Map();
10591
- for (const message of messages) {
10592
- const existing = acc.get(message.id);
10593
- if (existing && message.role === "assistant" && existing.role === "assistant") {
10594
- const content = message.content || existing.content;
10595
- const toolCalls = message.toolCalls ?? existing.toolCalls;
10596
- acc.set(message.id, {
10597
- ...existing,
10598
- ...message,
10599
- content,
10600
- toolCalls: toolCalls ? dedupeToolCalls(toolCalls) : toolCalls
10601
- });
10602
- } else if (message.role === "assistant" && message.toolCalls) acc.set(message.id, {
10603
- ...message,
10604
- toolCalls: dedupeToolCalls(message.toolCalls)
10605
- });
10606
- else acc.set(message.id, message);
10607
- }
10608
- return [...acc.values()];
10609
- }
10610
9970
  /** A row holding a single message, rendered as it would be ungrouped. */
10611
9971
  function messageRow(message) {
10612
9972
  return {
@@ -10655,7 +10015,7 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
10655
10015
  if (!resolvedRunId) return void 0;
10656
10016
  return copilotkit.getStateByRun(config.agentId, config.threadId, resolvedRunId);
10657
10017
  };
10658
- const deduplicatedMessages = (0, react.useMemo)(() => deduplicateMessages(messages), [messages]);
10018
+ const deduplicatedMessages = (0, react.useMemo)(() => (0, _copilotkit_core.ɵdeduplicateMessages)(messages), [messages]);
10659
10019
  const transformedMessages = (0, react.useMemo)(() => transformMessages ? transformMessages(deduplicatedMessages) : deduplicatedMessages, [deduplicatedMessages, transformMessages]);
10660
10020
  const rows = (0, react.useMemo)(() => groupMessages ? groupMessages(transformedMessages) : transformedMessages.map(messageRow), [transformedMessages, groupMessages]);
10661
10021
  const renderedMessages = (0, react.useMemo)(() => groupMessages ? rows.flatMap((row) => row.type === "group" ? row.messages : [row.message]) : transformedMessages, [
@@ -10665,13 +10025,13 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
10665
10025
  ]);
10666
10026
  const latestRenderedId = renderedMessages[renderedMessages.length - 1]?.id;
10667
10027
  const rendererNames = useToolCallRendererNames();
10668
- const toolCallLayouts = (0, react.useMemo)(() => toolCallDisplay === "separate" ? /* @__PURE__ */ new Map() : getToolCallLayouts(renderedMessages, messages, rendererNames), [
10028
+ const toolCallLayouts = (0, react.useMemo)(() => toolCallDisplay === "separate" ? /* @__PURE__ */ new Map() : (0, _copilotkit_core.ɵgetToolCallLayouts)(renderedMessages, messages, rendererNames), [
10669
10029
  toolCallDisplay,
10670
10030
  renderedMessages,
10671
10031
  messages,
10672
10032
  rendererNames
10673
10033
  ]);
10674
- const turnWork = (0, react.useMemo)(() => toolCallDisplay === "turn" ? getTurnWork(renderedMessages, toolCallLayouts) : void 0, [
10034
+ const turnWork = (0, react.useMemo)(() => toolCallDisplay === "turn" ? (0, _copilotkit_core.ɵgetTurnWork)(renderedMessages, toolCallLayouts) : void 0, [
10675
10035
  toolCallDisplay,
10676
10036
  renderedMessages,
10677
10037
  toolCallLayouts
@@ -10681,46 +10041,25 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
10681
10041
  for (const turn of turnWork?.values() ?? []) byFirst.set(turn.firstMessageId, turn);
10682
10042
  return byFirst;
10683
10043
  }, [turnWork]);
10684
- let latestTurnKey = "start";
10685
- for (let i = renderedMessages.length - 1; i >= 0; i--) if (renderedMessages[i].role === "user") {
10686
- latestTurnKey = renderedMessages[i].id;
10687
- break;
10688
- }
10689
- const isWorkingOn = (turnKey) => isRunning && turnKey === latestTurnKey;
10044
+ const latestTurnKey = (0, _copilotkit_core.ɵgetLatestTurnKey)(renderedMessages);
10690
10045
  const [toggledTurns, setToggledTurns] = (0, react.useState)(() => /* @__PURE__ */ new Map());
10691
- const isWorkOpen = (turnKey) => toggledTurns.get(turnKey) ?? isWorkingOn(turnKey);
10046
+ const turnState = {
10047
+ toggledTurns,
10048
+ isRunning,
10049
+ latestTurnKey
10050
+ };
10692
10051
  const workTimesRef = (0, react.useRef)(/* @__PURE__ */ new Map());
10693
- if (toolCallDisplay === "turn") {
10694
- const now = Date.now();
10695
- const workTimes = workTimesRef.current;
10696
- if (isRunning) {
10697
- const times = workTimes.get(latestTurnKey);
10698
- if (times) times.workingSince ??= now;
10699
- else if (renderedMessages[renderedMessages.length - 1]?.role === "user") workTimes.set(latestTurnKey, {
10700
- elapsedMs: 0,
10701
- workingSince: now
10702
- });
10703
- } else for (const times of workTimes.values()) {
10704
- if (times.workingSince === void 0) continue;
10705
- times.elapsedMs += now - times.workingSince;
10706
- times.workingSince = void 0;
10707
- }
10708
- }
10709
- const { workOpen, workTextOpen } = (0, react.useMemo)(() => {
10710
- const open = /* @__PURE__ */ new Map();
10711
- const textOpen = /* @__PURE__ */ new Map();
10712
- for (const turn of turnWork?.values() ?? []) {
10713
- const turnOpen = toggledTurns.get(turn.key) ?? (isRunning && turn.key === latestTurnKey);
10714
- for (const id of turn.workMessageIds) {
10715
- open.set(id, turnOpen);
10716
- if (id !== turn.replyTextMessageId) textOpen.set(id, turnOpen);
10717
- }
10718
- }
10719
- return {
10720
- workOpen: open,
10721
- workTextOpen: textOpen
10722
- };
10723
- }, [
10052
+ if (toolCallDisplay === "turn") (0, _copilotkit_core.ɵrecordWorkTime)(workTimesRef.current, {
10053
+ isRunning,
10054
+ latestTurnKey,
10055
+ lastMessageRole: renderedMessages[renderedMessages.length - 1]?.role,
10056
+ now: Date.now()
10057
+ });
10058
+ const { workOpen, workTextOpen } = (0, react.useMemo)(() => (0, _copilotkit_core.ɵgetWorkOpenState)(turnWork?.values() ?? [], {
10059
+ toggledTurns,
10060
+ isRunning,
10061
+ latestTurnKey
10062
+ }), [
10724
10063
  turnWork,
10725
10064
  toggledTurns,
10726
10065
  isRunning,
@@ -10740,8 +10079,8 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
10740
10079
  workTextOpen
10741
10080
  ]);
10742
10081
  const renderWorkSummary = (turnKey, calls) => {
10743
- const working = isWorkingOn(turnKey);
10744
- const open = isWorkOpen(turnKey);
10082
+ const working = (0, _copilotkit_core.ɵisTurnWorking)(turnKey, turnState);
10083
+ const open = (0, _copilotkit_core.ɵisTurnWorkOpen)(turnKey, turnState);
10745
10084
  const times = workTimesRef.current.get(turnKey);
10746
10085
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Collapsible, {
10747
10086
  open: working || calls.length > 0,
@@ -11168,7 +10507,7 @@ CopilotChatMessageView.Cursor = function Cursor({ className, ...props }) {
11168
10507
  * button named by `labels.attachmentRemoveButtonLabel`.
11169
10508
  */
11170
10509
  const CopilotChatAttachmentQueue = ({ attachments, onRemoveAttachment, className }) => {
11171
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
10510
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
11172
10511
  if (attachments.length === 0) return null;
11173
10512
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
11174
10513
  "data-testid": "copilot-attachment-queue",
@@ -11244,7 +10583,7 @@ function AudioPreview({ attachment }) {
11244
10583
  * lightbox.
11245
10584
  */
11246
10585
  function VideoPreview({ attachment }) {
11247
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
10586
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
11248
10587
  const src = (0, _copilotkit_shared.getSourceUrl)(attachment.source);
11249
10588
  const { thumbnailRef, vtName, open, openLightbox, closeLightbox } = useLightbox();
11250
10589
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
@@ -11268,7 +10607,10 @@ function VideoPreview({ attachment }) {
11268
10607
  "aria-label": labels.attachmentPlayVideoButtonLabel,
11269
10608
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
11270
10609
  className: "cpk-attachment-queue-video-play-badge",
11271
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Play, { className: "cpk-attachment-queue-video-play-icon" })
10610
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
10611
+ name: "Play",
10612
+ className: "cpk-attachment-queue-video-play-icon"
10613
+ })
11272
10614
  })
11273
10615
  }),
11274
10616
  open && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Lightbox, {
@@ -11321,6 +10663,7 @@ function useBlobUrl(attachment) {
11321
10663
  return url;
11322
10664
  }
11323
10665
  function DocumentLightboxContent({ attachment, vtName }) {
10666
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
11324
10667
  const mimeType = attachment.source.mimeType;
11325
10668
  const blobUrl = useBlobUrl(attachment);
11326
10669
  if (isPdf(mimeType)) {
@@ -11368,20 +10711,21 @@ function DocumentLightboxContent({ attachment, vtName }) {
11368
10711
  className: "cpk-attachment-queue-document-card-details",
11369
10712
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
11370
10713
  className: "cpk-attachment-queue-document-card-name",
11371
- children: attachment.filename || "Document"
10714
+ children: attachment.filename || labels.attachmentDocumentLabel
11372
10715
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
11373
10716
  className: "cpk-attachment-queue-document-card-meta",
11374
- children: [mimeType || "Unknown type", attachment.size != null && ` · ${(0, _copilotkit_shared.formatFileSize)(attachment.size)}`]
10717
+ children: [mimeType || labels.attachmentUnknownTypeText, attachment.size != null && ` · ${(0, _copilotkit_shared.formatFileSize)(attachment.size)}`]
11375
10718
  })]
11376
10719
  }),
11377
10720
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
11378
10721
  className: "cpk-attachment-queue-document-card-note",
11379
- children: "No preview available for this file type"
10722
+ children: labels.attachmentNoPreviewText
11380
10723
  })
11381
10724
  ]
11382
10725
  });
11383
10726
  }
11384
10727
  function DocumentPreview({ attachment }) {
10728
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
11385
10729
  const { thumbnailRef, vtName, open, openLightbox, closeLightbox } = useLightbox();
11386
10730
  const mimeType = attachment.source.mimeType;
11387
10731
  const previewable = canPreviewInBrowser(mimeType);
@@ -11396,7 +10740,7 @@ function DocumentPreview({ attachment }) {
11396
10740
  className: "cpk-attachment-queue-document-info",
11397
10741
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
11398
10742
  className: "cpk-attachment-queue-document-name",
11399
- children: attachment.filename || "Document"
10743
+ children: attachment.filename || labels.attachmentDocumentLabel
11400
10744
  }), attachment.size != null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
11401
10745
  className: "cpk-attachment-queue-document-size",
11402
10746
  children: (0, _copilotkit_shared.formatFileSize)(attachment.size)
@@ -11533,13 +10877,17 @@ function computeOffsetTop(el, stopAt) {
11533
10877
  //#region src/components/chat/CopilotChatView.tsx
11534
10878
  const SCROLL_BUTTON_OFFSET = 16;
11535
10879
  function DropOverlay() {
10880
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
11536
10881
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
11537
10882
  className: "cpk-chat-view-drop-overlay",
11538
10883
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
11539
10884
  className: "cpk-chat-view-drop-overlay-content",
11540
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Upload, { className: "cpk-chat-view-drop-overlay-icon" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10885
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
10886
+ name: "Upload",
10887
+ className: "cpk-chat-view-drop-overlay-icon"
10888
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
11541
10889
  className: "cpk-chat-view-drop-overlay-label",
11542
- children: "Drop files here"
10890
+ children: labels.chatDropFilesLabel
11543
10891
  })]
11544
10892
  })
11545
10893
  });
@@ -11979,7 +11327,7 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
11979
11327
  });
11980
11328
  };
11981
11329
  _CopilotChatView.ScrollToBottomButton = ({ className, ...props }) => {
11982
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
11330
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
11983
11331
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
11984
11332
  "data-testid": "copilot-scroll-to-bottom",
11985
11333
  variant: "outline",
@@ -11987,7 +11335,10 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
11987
11335
  className: require_MarkdownSurfaces.cn("cpk-chat-view-scroll-to-bottom-button", className),
11988
11336
  "aria-label": labels.chatScrollToBottomLabel,
11989
11337
  ...props,
11990
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, { className: "cpk-chat-view-scroll-to-bottom-icon" })
11338
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
11339
+ name: "ChevronDown",
11340
+ className: "cpk-chat-view-scroll-to-bottom-icon"
11341
+ })
11991
11342
  });
11992
11343
  };
11993
11344
  _CopilotChatView.Feather = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -11995,7 +11346,7 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
11995
11346
  ...props
11996
11347
  });
11997
11348
  _CopilotChatView.WelcomeMessage = ({ className, ...props }) => {
11998
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
11349
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
11999
11350
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
12000
11351
  className: require_MarkdownSurfaces.cn("cpk-chat-view-welcome-message", className),
12001
11352
  ...props,
@@ -12041,119 +11392,6 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
12041
11392
  })(CopilotChatView || (CopilotChatView = {}));
12042
11393
  var CopilotChatView_default = CopilotChatView;
12043
11394
 
12044
- //#endregion
12045
- //#region src/lib/transcription-client.ts
12046
- /**
12047
- * Convert a Blob to a base64 string
12048
- */
12049
- async function blobToBase64(blob) {
12050
- return new Promise((resolve, reject) => {
12051
- const reader = new FileReader();
12052
- reader.onloadend = () => {
12053
- const base64 = reader.result.split(",")[1];
12054
- resolve(base64 ?? "");
12055
- };
12056
- reader.onerror = () => reject(/* @__PURE__ */ new Error("Failed to read audio data"));
12057
- reader.readAsDataURL(blob);
12058
- });
12059
- }
12060
- /**
12061
- * Check if an error response matches our expected format
12062
- */
12063
- function isTranscriptionErrorResponse(data) {
12064
- return typeof data === "object" && data !== null && "error" in data && "message" in data && typeof data.error === "string" && typeof data.message === "string";
12065
- }
12066
- /**
12067
- * Parse error info from a transcription error response
12068
- */
12069
- function parseTranscriptionError(response) {
12070
- return {
12071
- code: response.error,
12072
- message: response.message,
12073
- retryable: response.retryable ?? false
12074
- };
12075
- }
12076
- /**
12077
- * Custom error type for transcription failures.
12078
- * Extends Error with transcription-specific info for contextual error handling.
12079
- */
12080
- var TranscriptionError = class extends Error {
12081
- constructor(info) {
12082
- super(info.message);
12083
- this.name = "TranscriptionError";
12084
- this.info = info;
12085
- }
12086
- };
12087
- /**
12088
- * Transcribe an audio blob using the CopilotKit runtime
12089
- *
12090
- * Supports both REST mode (multipart/form-data) and single-endpoint mode (base64 JSON)
12091
- *
12092
- * @throws {TranscriptionError} When transcription fails with typed error information
12093
- */
12094
- async function transcribeAudio(core, audioBlob, filename = "recording.webm") {
12095
- const runtimeUrl = core.runtimeUrl;
12096
- if (!runtimeUrl) throw new TranscriptionError({
12097
- code: _copilotkit_shared.TranscriptionErrorCode.INVALID_REQUEST,
12098
- message: "Runtime URL is not configured",
12099
- retryable: false
12100
- });
12101
- const headers = { ...await core.resolveHeaders() };
12102
- let response;
12103
- try {
12104
- if (core.runtimeTransport === "single") {
12105
- const base64Audio = await blobToBase64(audioBlob);
12106
- headers["Content-Type"] = "application/json";
12107
- response = await fetch(runtimeUrl, {
12108
- method: "POST",
12109
- headers,
12110
- body: JSON.stringify({
12111
- method: "transcribe",
12112
- body: {
12113
- audio: base64Audio,
12114
- mimeType: audioBlob.type || "audio/webm",
12115
- filename
12116
- }
12117
- })
12118
- });
12119
- } else {
12120
- delete headers["Content-Type"];
12121
- const formData = new FormData();
12122
- formData.append("audio", audioBlob, filename);
12123
- response = await fetch(`${runtimeUrl}/transcribe`, {
12124
- method: "POST",
12125
- headers,
12126
- body: formData
12127
- });
12128
- }
12129
- } catch (error) {
12130
- throw new TranscriptionError({
12131
- code: _copilotkit_shared.TranscriptionErrorCode.NETWORK_ERROR,
12132
- message: error instanceof Error ? error.message : "Network request failed",
12133
- retryable: true
12134
- });
12135
- }
12136
- if (!response.ok) {
12137
- let errorData;
12138
- try {
12139
- errorData = await response.json();
12140
- } catch {
12141
- throw new TranscriptionError({
12142
- code: _copilotkit_shared.TranscriptionErrorCode.PROVIDER_ERROR,
12143
- message: `HTTP ${response.status}: ${response.statusText}`,
12144
- retryable: response.status >= 500
12145
- });
12146
- }
12147
- if (isTranscriptionErrorResponse(errorData)) throw new TranscriptionError(parseTranscriptionError(errorData));
12148
- throw new TranscriptionError({
12149
- code: _copilotkit_shared.TranscriptionErrorCode.PROVIDER_ERROR,
12150
- message: typeof errorData === "object" && errorData !== null && "message" in errorData ? String(errorData.message) : "Transcription failed",
12151
- retryable: response.status >= 500
12152
- });
12153
- }
12154
- return await response.json();
12155
- }
12156
-
12157
11395
  //#endregion
12158
11396
  //#region src/providers/use-inspector-thread-override.ts
12159
11397
  function useInspectorThreadOverride(args) {
@@ -12635,7 +11873,7 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
12635
11873
  }
12636
11874
  if (!isCurrentSelection()) return false;
12637
11875
  if (failedConnectionsRef.current.has(agent)) {
12638
- setTranscriptionError("Could not load saved conversation. Reopen the thread and try again.");
11876
+ setTranscriptionError({ labelKey: "threadLoadErrorText" });
12639
11877
  return "failed";
12640
11878
  }
12641
11879
  const maybeAware = agent;
@@ -12660,7 +11898,7 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
12660
11898
  const onSubmitInput = (0, react.useCallback)(async (value) => {
12661
11899
  if (selectedAttachmentsRef.current.some((a) => a.status === "uploading")) {
12662
11900
  console.error("[CopilotKit] Cannot send while attachments are uploading (pre-await guard)");
12663
- setTranscriptionError("Cannot send while attachments are uploading.");
11901
+ setTranscriptionError({ labelKey: "chatAttachmentsUploadingText" });
12664
11902
  return;
12665
11903
  }
12666
11904
  setInputValue("");
@@ -12672,7 +11910,7 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
12672
11910
  }
12673
11911
  if (selectedAttachmentsRef.current.some((a) => a.status === "uploading")) {
12674
11912
  console.error("[CopilotKit] Cannot send while attachments are uploading (post-await re-check)");
12675
- setTranscriptionError("Cannot send while attachments are uploading.");
11913
+ setTranscriptionError({ labelKey: "chatAttachmentsUploadingText" });
12676
11914
  setInputValue(value);
12677
11915
  return;
12678
11916
  }
@@ -12790,7 +12028,7 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
12790
12028
  setIsTranscribing(true);
12791
12029
  try {
12792
12030
  setTranscriptionError(null);
12793
- const result = await transcribeAudio(copilotkit, audioBlob);
12031
+ const result = await (0, _copilotkit_core.ɵtranscribeAudio)(copilotkit, audioBlob);
12794
12032
  setInputValue((prev) => {
12795
12033
  const trimmedPrev = prev.trim();
12796
12034
  if (trimmedPrev) return `${trimmedPrev} ${result.text}`;
@@ -12798,33 +12036,10 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
12798
12036
  });
12799
12037
  } catch (error) {
12800
12038
  console.error("CopilotChat: Transcription failed", error);
12801
- if (error instanceof TranscriptionError) {
12802
- const { code, retryable, message } = error.info;
12803
- switch (code) {
12804
- case _copilotkit_shared.TranscriptionErrorCode.RATE_LIMITED:
12805
- setTranscriptionError("Too many requests. Please wait a moment.");
12806
- break;
12807
- case _copilotkit_shared.TranscriptionErrorCode.AUTH_FAILED:
12808
- setTranscriptionError("Authentication error. Please check your configuration.");
12809
- break;
12810
- case _copilotkit_shared.TranscriptionErrorCode.AUDIO_TOO_LONG:
12811
- setTranscriptionError("Recording is too long. Please try a shorter recording.");
12812
- break;
12813
- case _copilotkit_shared.TranscriptionErrorCode.AUDIO_TOO_SHORT:
12814
- setTranscriptionError("Recording is too short. Please try again.");
12815
- break;
12816
- case _copilotkit_shared.TranscriptionErrorCode.INVALID_AUDIO_FORMAT:
12817
- setTranscriptionError("Audio format not supported.");
12818
- break;
12819
- case _copilotkit_shared.TranscriptionErrorCode.SERVICE_NOT_CONFIGURED:
12820
- setTranscriptionError("Transcription service is not available.");
12821
- break;
12822
- case _copilotkit_shared.TranscriptionErrorCode.NETWORK_ERROR:
12823
- setTranscriptionError("Network error. Please check your connection.");
12824
- break;
12825
- default: setTranscriptionError(retryable ? "Transcription failed. Please try again." : message);
12826
- }
12827
- } else setTranscriptionError("Transcription failed. Please try again.");
12039
+ if (error instanceof _copilotkit_core.TranscriptionError) {
12040
+ const labelKey = (0, _copilotkit_core.ɵtranscriptionErrorMessageKey)(error.info);
12041
+ setTranscriptionError(labelKey ? { labelKey } : { text: error.info.message });
12042
+ } else setTranscriptionError({ labelKey: "transcriptionErrorGenericText" });
12828
12043
  } finally {
12829
12044
  setIsTranscribing(false);
12830
12045
  }
@@ -12856,11 +12071,7 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
12856
12071
  const effectiveStopHandler = agent.isRunning && hasMessages ? providedStopHandler ?? stopCurrentRun : providedStopHandler;
12857
12072
  const showTranscription = isTranscriptionEnabled && isMediaRecorderSupported;
12858
12073
  const effectiveMode = isTranscribing ? "processing" : transcribeMode;
12859
- const messages = (0, react.useMemo)(() => [...agent.messages], [agent.messages.map((m) => {
12860
- 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;
12861
- const toolCallsKey = "toolCalls" in m && Array.isArray(m.toolCalls) ? m.toolCalls.map((tc) => `${tc.id}:${tc.function?.arguments?.length ?? 0}`).join(";") : "";
12862
- return `${m.id}:${m.role}:${contentKey}:${toolCallsKey}`;
12863
- }).join(",")]);
12074
+ const messages = (0, react.useMemo)(() => [...agent.messages], [(0, _copilotkit_core.ɵmessagesFingerprint)(agent.messages)]);
12864
12075
  const lastUserMessageId = (0, react.useMemo)(() => {
12865
12076
  for (let i = messages.length - 1; i >= 0; i--) if (messages[i].role === "user") return messages[i].id;
12866
12077
  return null;
@@ -12932,7 +12143,11 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
12932
12143
  fontSize: "14px",
12933
12144
  zIndex: 50
12934
12145
  },
12935
- children: transcriptionError
12146
+ children: "labelKey" in transcriptionError ? {
12147
+ ..._copilotkit_core.CopilotChatDefaultLabels,
12148
+ ...existingConfig?.labels,
12149
+ ...labels
12150
+ }[transcriptionError.labelKey] : transcriptionError.text
12936
12151
  }),
12937
12152
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LastUserMessageContext.Provider, {
12938
12153
  value: lastUserMessageState,
@@ -12955,16 +12170,18 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
12955
12170
  //#endregion
12956
12171
  //#region src/components/chat/CopilotChatToggleButton.tsx
12957
12172
  const ICON_CLASS = "cpk-chat-toggle-button-icon";
12958
- const DefaultOpenIcon = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.MessageCircle, {
12173
+ const DefaultOpenIcon = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
12959
12174
  className: className ?? ICON_CLASS,
12960
12175
  strokeWidth: 1.75,
12961
12176
  fill: "currentColor",
12962
- ...props
12177
+ ...props,
12178
+ name: "MessageCircle"
12963
12179
  });
12964
- const DefaultCloseIcon = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, {
12180
+ const DefaultCloseIcon = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
12965
12181
  className: className ?? ICON_CLASS,
12966
12182
  strokeWidth: 1.75,
12967
- ...props
12183
+ ...props,
12184
+ name: "X"
12968
12185
  });
12969
12186
  DefaultOpenIcon.displayName = "CopilotChatToggleButton.OpenIcon";
12970
12187
  DefaultCloseIcon.displayName = "CopilotChatToggleButton.CloseIcon";
@@ -12973,7 +12190,7 @@ const ICON_WRAPPER_CLASS = "cpk-chat-toggle-button-icon-wrapper";
12973
12190
  const CopilotChatToggleButton = react.default.forwardRef(function CopilotChatToggleButton({ openIcon, closeIcon, className, ...buttonProps }, ref) {
12974
12191
  const { onClick, type, disabled, ...restProps } = buttonProps;
12975
12192
  const configuration = require_MarkdownSurfaces.useCopilotChatConfiguration();
12976
- const labels = configuration?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
12193
+ const labels = configuration?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
12977
12194
  const [fallbackOpen, setFallbackOpen] = (0, react.useState)(false);
12978
12195
  const isOpen = configuration?.isModalOpen ?? fallbackOpen;
12979
12196
  const setModalOpen = configuration?.setModalOpen ?? setFallbackOpen;
@@ -13090,7 +12307,7 @@ function useIsMobileViewport() {
13090
12307
  }
13091
12308
  function CopilotModalHeader({ title, titleContent, closeButton, drawerLauncher, children, className, ...rest }) {
13092
12309
  const configuration = require_MarkdownSurfaces.useCopilotChatConfiguration();
13093
- const fallbackTitle = configuration?.labels.modalHeaderTitle ?? require_MarkdownSurfaces.CopilotChatDefaultLabels.modalHeaderTitle;
12310
+ const fallbackTitle = configuration?.labels.modalHeaderTitle ?? _copilotkit_core.CopilotChatDefaultLabels.modalHeaderTitle;
13094
12311
  const resolvedTitle = title ?? fallbackTitle;
13095
12312
  const isMobile = useIsMobileViewport();
13096
12313
  const drawerRegistered = (configuration?.drawerRegistered ?? false) && isMobile;
@@ -13146,28 +12363,30 @@ CopilotModalHeader.displayName = "CopilotModalHeader";
13146
12363
  children
13147
12364
  });
13148
12365
  _CopilotModalHeader.CloseButton = ({ className, ...props }) => {
13149
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
12366
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
13150
12367
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
13151
12368
  type: "button",
13152
12369
  "data-testid": "copilot-close-button",
13153
12370
  className: require_MarkdownSurfaces.cn("cpk-modal-header-close-button", className),
13154
12371
  "aria-label": labels.modalHeaderCloseButtonLabel,
13155
12372
  ...props,
13156
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, {
12373
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
12374
+ name: "X",
13157
12375
  className: "cpk-modal-header-close-icon",
13158
12376
  "aria-hidden": "true"
13159
12377
  })
13160
12378
  });
13161
12379
  };
13162
12380
  _CopilotModalHeader.DrawerLauncher = ({ className, ...props }) => {
13163
- const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
12381
+ const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
13164
12382
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
13165
12383
  type: "button",
13166
12384
  "data-testid": "copilot-threads-drawer-launcher",
13167
12385
  className: require_MarkdownSurfaces.cn("cpk-modal-header-drawer-launcher", className),
13168
12386
  "aria-label": labels.modalHeaderThreadsButtonLabel,
13169
12387
  ...props,
13170
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.PanelLeftOpen, {
12388
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.CopilotIcon, {
12389
+ name: "PanelLeftOpen",
13171
12390
  className: "cpk-modal-header-drawer-launcher-icon",
13172
12391
  "aria-hidden": "true"
13173
12392
  })
@@ -13272,7 +12491,7 @@ function CopilotSidebarViewInternal({ header, toggleButton, width, position = "r
13272
12491
  paddingBottom: "env(safe-area-inset-bottom)"
13273
12492
  },
13274
12493
  "aria-hidden": !isSidebarOpen,
13275
- "aria-label": configuration?.labels.sidebarLabel ?? require_MarkdownSurfaces.CopilotChatDefaultLabels.sidebarLabel,
12494
+ "aria-label": configuration?.labels.sidebarLabel ?? _copilotkit_core.CopilotChatDefaultLabels.sidebarLabel,
13276
12495
  role: "complementary",
13277
12496
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
13278
12497
  className: "cpk-sidebar-view-panel",
@@ -13353,7 +12572,7 @@ function CopilotPopupViewInternal({ header, toggleButton, width, height, clickOu
13353
12572
  const configuration = require_MarkdownSurfaces.useCopilotChatConfiguration();
13354
12573
  const isPopupOpen = configuration?.isModalOpen ?? false;
13355
12574
  const setModalOpen = configuration?.setModalOpen;
13356
- const labels = configuration?.labels ?? require_MarkdownSurfaces.CopilotChatDefaultLabels;
12575
+ const labels = configuration?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
13357
12576
  const containerRef = (0, react.useRef)(null);
13358
12577
  const [isRendered, setIsRendered] = (0, react.useState)(isPopupOpen);
13359
12578
  const [isAnimatingOut, setIsAnimatingOut] = (0, react.useState)(false);
@@ -14060,7 +13279,6 @@ Object.defineProperty(exports, 'BaseMessageSchema', {
14060
13279
  return _ag_ui_core_schemas.BaseMessageSchema;
14061
13280
  }
14062
13281
  });
14063
- exports.BasicMarkdownRenderer = BasicMarkdownRenderer;
14064
13282
  Object.defineProperty(exports, 'CompatibilityBoundary', {
14065
13283
  enumerable: true,
14066
13284
  get: function () {
@@ -14096,6 +13314,12 @@ exports.CopilotChatAttachmentQueue = CopilotChatAttachmentQueue;
14096
13314
  exports.CopilotChatAttachmentRenderer = CopilotChatAttachmentRenderer;
14097
13315
  exports.CopilotChatAudioRecorder = CopilotChatAudioRecorder;
14098
13316
  exports.CopilotChatConfigurationProvider = require_MarkdownSurfaces.CopilotChatConfigurationProvider;
13317
+ Object.defineProperty(exports, 'CopilotChatDefaultLabels', {
13318
+ enumerable: true,
13319
+ get: function () {
13320
+ return _copilotkit_core.CopilotChatDefaultLabels;
13321
+ }
13322
+ });
14099
13323
  exports.CopilotChatInput = CopilotChatInput_default;
14100
13324
  exports.CopilotChatMessageView = CopilotChatMessageView;
14101
13325
  exports.CopilotChatReasoningMessage = CopilotChatReasoningMessage_default;
@@ -14170,6 +13394,12 @@ Object.defineProperty(exports, 'CustomEventSchema', {
14170
13394
  return _ag_ui_core_schemas.CustomEventSchema;
14171
13395
  }
14172
13396
  });
13397
+ Object.defineProperty(exports, 'DEFAULT_OPEN_GENERATIVE_UI_DESIGN_SKILL', {
13398
+ enumerable: true,
13399
+ get: function () {
13400
+ return _copilotkit_core.DEFAULT_OPEN_GENERATIVE_UI_DESIGN_SKILL;
13401
+ }
13402
+ });
14173
13403
  Object.defineProperty(exports, 'DataSourceSchema', {
14174
13404
  enumerable: true,
14175
13405
  get: function () {
@@ -14260,6 +13490,12 @@ Object.defineProperty(exports, 'FunctionMiddleware', {
14260
13490
  return _ag_ui_client.FunctionMiddleware;
14261
13491
  }
14262
13492
  });
13493
+ Object.defineProperty(exports, 'GENERATE_SANDBOXED_UI_TOOL_NAME', {
13494
+ enumerable: true,
13495
+ get: function () {
13496
+ return _copilotkit_core.GENERATE_SANDBOXED_UI_TOOL_NAME;
13497
+ }
13498
+ });
14263
13499
  exports.GenerateSandboxedUiArgsSchema = GenerateSandboxedUiArgsSchema;
14264
13500
  Object.defineProperty(exports, 'HttpAgent', {
14265
13501
  enumerable: true,
@@ -14280,7 +13516,12 @@ Object.defineProperty(exports, 'INSPECTOR_THREAD_BRIDGE_PLUGIN_ID', {
14280
13516
  }
14281
13517
  });
14282
13518
  exports.INTELLIGENCE_TURN_HEAD = INTELLIGENCE_TURN_HEAD;
14283
- exports.INTERRUPT_EVENT_NAME = INTERRUPT_EVENT_NAME;
13519
+ Object.defineProperty(exports, 'INTERRUPT_EVENT_NAME', {
13520
+ enumerable: true,
13521
+ get: function () {
13522
+ return _copilotkit_core.INTERRUPT_EVENT_NAME;
13523
+ }
13524
+ });
14284
13525
  Object.defineProperty(exports, 'IdentityCapabilitiesSchema', {
14285
13526
  enumerable: true,
14286
13527
  get: function () {
@@ -14441,6 +13682,12 @@ Object.defineProperty(exports, 'MultimodalOutputCapabilitiesSchema', {
14441
13682
  return _ag_ui_core_schemas.MultimodalOutputCapabilitiesSchema;
14442
13683
  }
14443
13684
  });
13685
+ Object.defineProperty(exports, 'OPEN_GENERATIVE_UI_ACTIVITY_TYPE', {
13686
+ enumerable: true,
13687
+ get: function () {
13688
+ return _copilotkit_core.OPEN_GENERATIVE_UI_ACTIVITY_TYPE;
13689
+ }
13690
+ });
14444
13691
  exports.OpenGenerativeUIActivityRenderer = OpenGenerativeUIActivityRenderer;
14445
13692
  exports.OpenGenerativeUIActivityType = OpenGenerativeUIActivityType;
14446
13693
  exports.OpenGenerativeUIContentSchema = OpenGenerativeUIContentSchema;
@@ -14837,6 +14084,18 @@ Object.defineProperty(exports, 'ToolsCapabilitiesSchema', {
14837
14084
  return _ag_ui_core_schemas.ToolsCapabilitiesSchema;
14838
14085
  }
14839
14086
  });
14087
+ Object.defineProperty(exports, 'TranscriptionError', {
14088
+ enumerable: true,
14089
+ get: function () {
14090
+ return _copilotkit_core.TranscriptionError;
14091
+ }
14092
+ });
14093
+ Object.defineProperty(exports, 'TranscriptionErrorCode', {
14094
+ enumerable: true,
14095
+ get: function () {
14096
+ return _copilotkit_core.TranscriptionErrorCode;
14097
+ }
14098
+ });
14840
14099
  Object.defineProperty(exports, 'TransportCapabilitiesSchema', {
14841
14100
  enumerable: true,
14842
14101
  get: function () {
@@ -15162,12 +14421,6 @@ Object.defineProperty(exports, 'onInspectorViewThreadResult', {
15162
14421
  return _copilotkit_core.onInspectorViewThreadResult;
15163
14422
  }
15164
14423
  });
15165
- Object.defineProperty(exports, 'parseMarkdown', {
15166
- enumerable: true,
15167
- get: function () {
15168
- return _copilotkit_core.parseMarkdown;
15169
- }
15170
- });
15171
14424
  Object.defineProperty(exports, 'parseProtoStream', {
15172
14425
  enumerable: true,
15173
14426
  get: function () {
@@ -15290,8 +14543,6 @@ exports.useHumanInTheLoop = useHumanInTheLoop;
15290
14543
  exports.useInterrupt = useInterrupt;
15291
14544
  exports.useLearnFromUserAction = useLearnFromUserAction;
15292
14545
  exports.useLearnFromUserActionInCurrentThread = useLearnFromUserActionInCurrentThread;
15293
- exports.useLearningContainers = useLearningContainers;
15294
- exports.useLearningContainersInCurrentThread = useLearningContainersInCurrentThread;
15295
14546
  Object.defineProperty(exports, 'useLicenseContext', {
15296
14547
  enumerable: true,
15297
14548
  get: function () {
@@ -15337,6 +14588,12 @@ Object.defineProperty(exports, 'ɵMAX_SOCKET_RETRIES', {
15337
14588
  return _copilotkit_core.ɵMAX_SOCKET_RETRIES;
15338
14589
  }
15339
14590
  });
14591
+ Object.defineProperty(exports, 'ɵOpenGenerativeUIController', {
14592
+ enumerable: true,
14593
+ get: function () {
14594
+ return _copilotkit_core.ɵOpenGenerativeUIController;
14595
+ }
14596
+ });
15340
14597
  Object.defineProperty(exports, 'ɵRUNTIME_PROBE_TIMEOUT_MS', {
15341
14598
  enumerable: true,
15342
14599
  get: function () {
@@ -15355,6 +14612,30 @@ Object.defineProperty(exports, 'ɵclearAgentInterruptState', {
15355
14612
  return _copilotkit_core.ɵclearAgentInterruptState;
15356
14613
  }
15357
14614
  });
14615
+ Object.defineProperty(exports, 'ɵcomposerButtonState', {
14616
+ enumerable: true,
14617
+ get: function () {
14618
+ return _copilotkit_core.ɵcomposerButtonState;
14619
+ }
14620
+ });
14621
+ Object.defineProperty(exports, 'ɵcopilotIconSvgAttributes', {
14622
+ enumerable: true,
14623
+ get: function () {
14624
+ return _copilotkit_core.ɵcopilotIconSvgAttributes;
14625
+ }
14626
+ });
14627
+ Object.defineProperty(exports, 'ɵcopilotIcons', {
14628
+ enumerable: true,
14629
+ get: function () {
14630
+ return _copilotkit_core.ɵcopilotIcons;
14631
+ }
14632
+ });
14633
+ Object.defineProperty(exports, 'ɵcountFailedToolCalls', {
14634
+ enumerable: true,
14635
+ get: function () {
14636
+ return _copilotkit_core.ɵcountFailedToolCalls;
14637
+ }
14638
+ });
15358
14639
  Object.defineProperty(exports, 'ɵcreateMemoryStore', {
15359
14640
  enumerable: true,
15360
14641
  get: function () {
@@ -15373,12 +14654,108 @@ Object.defineProperty(exports, 'ɵcreateThreadStore', {
15373
14654
  return _copilotkit_core.ɵcreateThreadStore;
15374
14655
  }
15375
14656
  });
14657
+ Object.defineProperty(exports, 'ɵdeduplicateMessages', {
14658
+ enumerable: true,
14659
+ get: function () {
14660
+ return _copilotkit_core.ɵdeduplicateMessages;
14661
+ }
14662
+ });
14663
+ Object.defineProperty(exports, 'ɵextractCompleteStyles', {
14664
+ enumerable: true,
14665
+ get: function () {
14666
+ return _copilotkit_core.ɵextractCompleteStyles;
14667
+ }
14668
+ });
14669
+ Object.defineProperty(exports, 'ɵformatCountLabel', {
14670
+ enumerable: true,
14671
+ get: function () {
14672
+ return _copilotkit_core.ɵformatCountLabel;
14673
+ }
14674
+ });
14675
+ Object.defineProperty(exports, 'ɵformatLabel', {
14676
+ enumerable: true,
14677
+ get: function () {
14678
+ return _copilotkit_core.ɵformatLabel;
14679
+ }
14680
+ });
14681
+ Object.defineProperty(exports, 'ɵformatReasoningDuration', {
14682
+ enumerable: true,
14683
+ get: function () {
14684
+ return _copilotkit_core.ɵformatReasoningDuration;
14685
+ }
14686
+ });
14687
+ Object.defineProperty(exports, 'ɵformatToolNames', {
14688
+ enumerable: true,
14689
+ get: function () {
14690
+ return _copilotkit_core.ɵformatToolNames;
14691
+ }
14692
+ });
14693
+ Object.defineProperty(exports, 'ɵformatWorkDuration', {
14694
+ enumerable: true,
14695
+ get: function () {
14696
+ return _copilotkit_core.ɵformatWorkDuration;
14697
+ }
14698
+ });
15376
14699
  Object.defineProperty(exports, 'ɵgetAgentInterruptState', {
15377
14700
  enumerable: true,
15378
14701
  get: function () {
15379
14702
  return _copilotkit_core.ɵgetAgentInterruptState;
15380
14703
  }
15381
14704
  });
14705
+ Object.defineProperty(exports, 'ɵgetArgumentPreview', {
14706
+ enumerable: true,
14707
+ get: function () {
14708
+ return _copilotkit_core.ɵgetArgumentPreview;
14709
+ }
14710
+ });
14711
+ Object.defineProperty(exports, 'ɵgetLatestTurnKey', {
14712
+ enumerable: true,
14713
+ get: function () {
14714
+ return _copilotkit_core.ɵgetLatestTurnKey;
14715
+ }
14716
+ });
14717
+ Object.defineProperty(exports, 'ɵgetToolCallLayouts', {
14718
+ enumerable: true,
14719
+ get: function () {
14720
+ return _copilotkit_core.ɵgetToolCallLayouts;
14721
+ }
14722
+ });
14723
+ Object.defineProperty(exports, 'ɵgetToolCallPreview', {
14724
+ enumerable: true,
14725
+ get: function () {
14726
+ return _copilotkit_core.ɵgetToolCallPreview;
14727
+ }
14728
+ });
14729
+ Object.defineProperty(exports, 'ɵgetToolCallRendererNames', {
14730
+ enumerable: true,
14731
+ get: function () {
14732
+ return _copilotkit_core.ɵgetToolCallRendererNames;
14733
+ }
14734
+ });
14735
+ Object.defineProperty(exports, 'ɵgetToolCallRowStatus', {
14736
+ enumerable: true,
14737
+ get: function () {
14738
+ return _copilotkit_core.ɵgetToolCallRowStatus;
14739
+ }
14740
+ });
14741
+ Object.defineProperty(exports, 'ɵgetToolResults', {
14742
+ enumerable: true,
14743
+ get: function () {
14744
+ return _copilotkit_core.ɵgetToolResults;
14745
+ }
14746
+ });
14747
+ Object.defineProperty(exports, 'ɵgetTurnWork', {
14748
+ enumerable: true,
14749
+ get: function () {
14750
+ return _copilotkit_core.ɵgetTurnWork;
14751
+ }
14752
+ });
14753
+ Object.defineProperty(exports, 'ɵgetWorkOpenState', {
14754
+ enumerable: true,
14755
+ get: function () {
14756
+ return _copilotkit_core.ɵgetWorkOpenState;
14757
+ }
14758
+ });
15382
14759
  Object.defineProperty(exports, 'ɵisCopilotKitFeature', {
15383
14760
  enumerable: true,
15384
14761
  get: function () {
@@ -15397,12 +14774,30 @@ Object.defineProperty(exports, 'ɵisRetryableMemoryStatus', {
15397
14774
  return _copilotkit_core.ɵisRetryableMemoryStatus;
15398
14775
  }
15399
14776
  });
14777
+ Object.defineProperty(exports, 'ɵisTurnWorkOpen', {
14778
+ enumerable: true,
14779
+ get: function () {
14780
+ return _copilotkit_core.ɵisTurnWorkOpen;
14781
+ }
14782
+ });
14783
+ Object.defineProperty(exports, 'ɵisTurnWorking', {
14784
+ enumerable: true,
14785
+ get: function () {
14786
+ return _copilotkit_core.ɵisTurnWorking;
14787
+ }
14788
+ });
15400
14789
  Object.defineProperty(exports, 'ɵjoinPhoenixChannel$', {
15401
14790
  enumerable: true,
15402
14791
  get: function () {
15403
14792
  return _copilotkit_core.ɵjoinPhoenixChannel$;
15404
14793
  }
15405
14794
  });
14795
+ Object.defineProperty(exports, 'ɵloadWebsandbox', {
14796
+ enumerable: true,
14797
+ get: function () {
14798
+ return _copilotkit_core.ɵloadWebsandbox;
14799
+ }
14800
+ });
15406
14801
  Object.defineProperty(exports, 'ɵmapMemoryMetadataEvent', {
15407
14802
  enumerable: true,
15408
14803
  get: function () {
@@ -15433,6 +14828,12 @@ Object.defineProperty(exports, 'ɵmemoryRestEvents', {
15433
14828
  return _copilotkit_core.ɵmemoryRestEvents;
15434
14829
  }
15435
14830
  });
14831
+ Object.defineProperty(exports, 'ɵmessagesFingerprint', {
14832
+ enumerable: true,
14833
+ get: function () {
14834
+ return _copilotkit_core.ɵmessagesFingerprint;
14835
+ }
14836
+ });
15436
14837
  Object.defineProperty(exports, 'ɵobservePhoenixEvent$', {
15437
14838
  enumerable: true,
15438
14839
  get: function () {
@@ -15469,6 +14870,60 @@ Object.defineProperty(exports, 'ɵphoenixSocket$', {
15469
14870
  return _copilotkit_core.ɵphoenixSocket$;
15470
14871
  }
15471
14872
  });
14873
+ Object.defineProperty(exports, 'ɵpluralize', {
14874
+ enumerable: true,
14875
+ get: function () {
14876
+ return _copilotkit_core.ɵpluralize;
14877
+ }
14878
+ });
14879
+ Object.defineProperty(exports, 'ɵprocessPartialHtml', {
14880
+ enumerable: true,
14881
+ get: function () {
14882
+ return _copilotkit_core.ɵprocessPartialHtml;
14883
+ }
14884
+ });
14885
+ Object.defineProperty(exports, 'ɵrecordWorkTime', {
14886
+ enumerable: true,
14887
+ get: function () {
14888
+ return _copilotkit_core.ɵrecordWorkTime;
14889
+ }
14890
+ });
14891
+ Object.defineProperty(exports, 'ɵresolveActivityRenderer', {
14892
+ enumerable: true,
14893
+ get: function () {
14894
+ return _copilotkit_core.ɵresolveActivityRenderer;
14895
+ }
14896
+ });
14897
+ Object.defineProperty(exports, 'ɵresolveComposerKey', {
14898
+ enumerable: true,
14899
+ get: function () {
14900
+ return _copilotkit_core.ɵresolveComposerKey;
14901
+ }
14902
+ });
14903
+ Object.defineProperty(exports, 'ɵresolveCustomMessageRenderers', {
14904
+ enumerable: true,
14905
+ get: function () {
14906
+ return _copilotkit_core.ɵresolveCustomMessageRenderers;
14907
+ }
14908
+ });
14909
+ Object.defineProperty(exports, 'ɵresolveLicenseState', {
14910
+ enumerable: true,
14911
+ get: function () {
14912
+ return _copilotkit_core.ɵresolveLicenseState;
14913
+ }
14914
+ });
14915
+ Object.defineProperty(exports, 'ɵresolveThreadsLicense', {
14916
+ enumerable: true,
14917
+ get: function () {
14918
+ return _copilotkit_core.ɵresolveThreadsLicense;
14919
+ }
14920
+ });
14921
+ Object.defineProperty(exports, 'ɵresolveToolCallRenderer', {
14922
+ enumerable: true,
14923
+ get: function () {
14924
+ return _copilotkit_core.ɵresolveToolCallRenderer;
14925
+ }
14926
+ });
15472
14927
  Object.defineProperty(exports, 'ɵrunMcpFollowUp', {
15473
14928
  enumerable: true,
15474
14929
  get: function () {
@@ -15553,12 +15008,30 @@ Object.defineProperty(exports, 'ɵselectThreadsIsLoading', {
15553
15008
  return _copilotkit_core.ɵselectThreadsIsLoading;
15554
15009
  }
15555
15010
  });
15011
+ Object.defineProperty(exports, 'ɵstringifyToolCallPayload', {
15012
+ enumerable: true,
15013
+ get: function () {
15014
+ return _copilotkit_core.ɵstringifyToolCallPayload;
15015
+ }
15016
+ });
15556
15017
  Object.defineProperty(exports, 'ɵthreadAdapterEvents', {
15557
15018
  enumerable: true,
15558
15019
  get: function () {
15559
15020
  return _copilotkit_core.ɵthreadAdapterEvents;
15560
15021
  }
15561
15022
  });
15023
+ Object.defineProperty(exports, 'ɵtranscribeAudio', {
15024
+ enumerable: true,
15025
+ get: function () {
15026
+ return _copilotkit_core.ɵtranscribeAudio;
15027
+ }
15028
+ });
15029
+ Object.defineProperty(exports, 'ɵtranscriptionErrorMessageKey', {
15030
+ enumerable: true,
15031
+ get: function () {
15032
+ return _copilotkit_core.ɵtranscriptionErrorMessageKey;
15033
+ }
15034
+ });
15562
15035
  Object.defineProperty(exports, 'ɵwithHeaderDefaults', {
15563
15036
  enumerable: true,
15564
15037
  get: function () {