@copilotkit/react-core 2.0.0-rc.25 → 2.0.0-rc.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -64,6 +64,22 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
64
64
  }
65
65
  StreamingMarkdownDefaultRenderer.displayName = "StreamingMarkdownDefaultRenderer";
66
66
 
67
+ //#endregion
68
+ //#region src/lib/use-latest-ref.ts
69
+ const useIsomorphicLayoutEffect = typeof window === "undefined" ? react.useEffect : react.useLayoutEffect;
70
+ /**
71
+ * A ref that holds the latest `value`, for callbacks that run after render
72
+ * (event handlers, controller callbacks). The ref changes in a layout effect,
73
+ * not during render, so a render that React throws away leaves it alone.
74
+ */
75
+ function useLatestRef(value) {
76
+ const ref = (0, react.useRef)(value);
77
+ useIsomorphicLayoutEffect(() => {
78
+ ref.current = value;
79
+ });
80
+ return ref;
81
+ }
82
+
67
83
  //#endregion
68
84
  //#region src/components/icons/CopilotIcon.tsx
69
85
  /** Turns SVG attribute names such as `stroke-width` into React's `strokeWidth`. */
@@ -214,7 +230,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
214
230
  get renderActivityMessages() {
215
231
  return this._renderers.activity;
216
232
  }
217
- /** Prop and hook renderers merged; a hook renderer wins over a prop one. */
233
+ /**
234
+ * Prop, hook and built-in renderers merged. For one name and agentId, a
235
+ * hook renderer wins over a prop one, and both win over a built-in one.
236
+ */
218
237
  get renderToolCalls() {
219
238
  return this._renderers.toolCalls;
220
239
  }
@@ -233,6 +252,16 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
233
252
  removeHookRenderToolCall(name, agentId) {
234
253
  this._renderers.removeHookToolCall(name, agentId);
235
254
  }
255
+ /**
256
+ * @internal Add a renderer for a tool a built-in feature owns (A2UI,
257
+ * generative UI). Prop and hook renderers with the same name and agent win
258
+ * over it, and `setRenderToolCalls` never removes it.
259
+ *
260
+ * @returns A function that removes the renderer.
261
+ */
262
+ ɵaddBuiltInRenderToolCall(entry) {
263
+ return this._renderers.addBuiltInToolCall(entry);
264
+ }
236
265
  notifyRenderersChanged(kind) {
237
266
  this.notifySubscribers((subscriber) => {
238
267
  const reactSubscriber = subscriber;
@@ -729,14 +758,6 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
729
758
  * starts with "/".
730
759
  */
731
760
  function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning = false, onStartTranscribe, onCancelTranscribe, onFinishTranscribe, onFinishTranscribeWithAudio, onAddFile, onChange, value, toolsMenu, autoFocus = false, positioning = "static", keyboardHeight = 0, containerRef, showDisclaimer, bottomAnchored = false, textArea, sendButton, startTranscribeButton, cancelTranscribeButton, finishTranscribeButton, addMenuButton, audioRecorder, disclaimer, children, className, ...props }) {
732
- const isControlled = value !== void 0;
733
- const [internalValue, setInternalValue] = (0, react.useState)(() => value ?? "");
734
- (0, react.useEffect)(() => {
735
- if (!isControlled && value !== void 0) setInternalValue(value);
736
- }, [isControlled, value]);
737
- const resolvedValue = isControlled ? value ?? "" : internalValue;
738
- const [commandQuery, setCommandQuery] = (0, react.useState)(null);
739
- const [slashHighlightIndex, setSlashHighlightIndex] = (0, react.useState)(0);
740
761
  const inputRef = (0, react.useRef)(null);
741
762
  const gridRef = (0, react.useRef)(null);
742
763
  const addButtonContainerRef = (0, react.useRef)(null);
@@ -754,18 +775,33 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
754
775
  const layout = (0, react.useSyncExternalStore)(autosize.subscribe, autosize.getSnapshot, autosize.getSnapshot);
755
776
  const isExpanded = mode === "input" && layout === "expanded";
756
777
  const previousModalStateRef = (0, react.useRef)(void 0);
757
- const commandItems = (0, react.useMemo)(() => {
758
- const menu = toolsMenu ?? [];
759
- return (0, _copilotkit_core.ɵflattenCommandItems)(onAddFile ? [{
760
- label: labels.chatInputToolbarAddButtonLabel,
761
- action: onAddFile
762
- }, ...menu] : menu);
763
- }, [
778
+ const onChangeRef = useLatestRef(onChange);
779
+ const [composer] = (0, react.useState)(() => new _copilotkit_core.ɵComposerController({
780
+ initialValue: value ?? "",
781
+ onChange: (next) => onChangeRef.current?.(next)
782
+ }));
783
+ const { value: composerValue, slashQuery: commandQuery, slashCommands: filteredCommands, slashHighlightIndex } = (0, react.useSyncExternalStore)(composer.subscribe, composer.getSnapshot, composer.getSnapshot);
784
+ const resolvedValue = value ?? composerValue;
785
+ const menu = (0, react.useMemo)(() => (0, _copilotkit_core.ɵnormalizeToolsMenu)(toolsMenu, onAddFile ? {
786
+ label: labels.chatInputToolbarAddButtonLabel,
787
+ action: onAddFile
788
+ } : void 0), [
764
789
  labels.chatInputToolbarAddButtonLabel,
765
790
  onAddFile,
766
791
  toolsMenu
767
792
  ]);
768
- const filteredCommands = (0, react.useMemo)(() => (0, _copilotkit_core.ɵfilterCommands)(commandItems, commandQuery), [commandItems, commandQuery]);
793
+ (0, react.useLayoutEffect)(() => {
794
+ composer.setInputs({
795
+ value,
796
+ mode,
797
+ menu
798
+ });
799
+ }, [
800
+ composer,
801
+ value,
802
+ mode,
803
+ menu
804
+ ]);
769
805
  (0, react.useEffect)(() => {
770
806
  if (!autoFocus) {
771
807
  previousModalStateRef.current = config?.isModalOpen;
@@ -774,48 +810,18 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
774
810
  if (config?.isModalOpen && !previousModalStateRef.current) inputRef.current?.focus({ preventScroll: true });
775
811
  previousModalStateRef.current = config?.isModalOpen;
776
812
  }, [config?.isModalOpen, autoFocus]);
777
- const previousCommandQueryRef = (0, react.useRef)(null);
778
- (0, react.useEffect)(() => {
779
- if (commandQuery !== null && commandQuery !== previousCommandQueryRef.current && filteredCommands.length > 0) setSlashHighlightIndex(0);
780
- previousCommandQueryRef.current = commandQuery;
781
- }, [commandQuery, filteredCommands.length]);
782
813
  (0, react.useEffect)(() => {
783
- setSlashHighlightIndex((index) => commandQuery === null ? 0 : (0, _copilotkit_core.ɵclampSlashIndex)(index, filteredCommands.length));
784
- }, [commandQuery, filteredCommands]);
785
- (0, react.useEffect)(() => {
786
- const recorder = audioRecorderRef.current;
787
- if (!recorder) return;
788
- if (mode === "transcribe") recorder.start().catch(console.error);
789
- else if (recorder.state === "recording") recorder.stop().catch(console.error);
814
+ (0, _copilotkit_core.ɵsyncRecorderToMode)(audioRecorderRef.current, mode);
790
815
  }, [mode]);
791
- (0, react.useEffect)(() => {
792
- if (mode !== "input") setCommandQuery(null);
793
- }, [mode]);
794
- const updateSlashState = (0, react.useCallback)((value) => {
795
- setCommandQuery((0, _copilotkit_core.ɵparseSlashQuery)(value, commandItems.length > 0));
796
- }, [commandItems.length]);
797
- (0, react.useEffect)(() => {
798
- updateSlashState(resolvedValue);
799
- }, [resolvedValue, updateSlashState]);
800
816
  const handleChange = (e) => {
801
- const nextValue = e.target.value;
802
- if (!isControlled) setInternalValue(nextValue);
803
- onChange?.(nextValue);
804
- updateSlashState(nextValue);
817
+ composer.setValue(e.target.value);
805
818
  };
806
- const clearInputValue = (0, react.useCallback)(() => {
807
- if (!isControlled) setInternalValue("");
808
- if (onChange) onChange("");
809
- }, [isControlled, onChange]);
810
819
  const runCommand = (0, react.useCallback)((item) => {
811
- clearInputValue();
812
- item.action?.();
813
- setCommandQuery(null);
814
- setSlashHighlightIndex(0);
820
+ composer.runCommand(item);
815
821
  requestAnimationFrame(() => {
816
822
  inputRef.current?.focus();
817
823
  });
818
- }, [clearInputValue]);
824
+ }, [composer]);
819
825
  const composerInput = {
820
826
  mode,
821
827
  isRunning,
@@ -825,43 +831,22 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
825
831
  };
826
832
  const { isProcessing, action: buttonAction, disabled: buttonDisabled } = (0, _copilotkit_core.ɵcomposerButtonState)(composerInput);
827
833
  const handleKeyDown = (e) => {
828
- if (e.nativeEvent.isComposing || e.keyCode === 229) return;
829
- const slash = (0, _copilotkit_core.ɵresolveSlashKey)(e, {
830
- query: mode === "input" ? commandQuery : null,
831
- commands: filteredCommands,
832
- highlightIndex: slashHighlightIndex
833
- });
834
- if (slash.type !== "none") e.preventDefault();
835
- switch (slash.type) {
836
- case "highlight":
837
- setSlashHighlightIndex(slash.index);
838
- return;
839
- case "run":
840
- runCommand(slash.command);
841
- return;
842
- case "close":
843
- setCommandQuery(null);
844
- return;
845
- case "none": break;
846
- }
847
- if (e.key === "Enter" && !e.shiftKey) e.preventDefault();
848
- const action = (0, _copilotkit_core.ɵresolveComposerKey)({
834
+ const { preventDefault, action } = composer.keyDown({
849
835
  key: e.key,
850
836
  shiftKey: e.shiftKey,
851
837
  isComposing: e.nativeEvent.isComposing,
852
838
  keyCode: e.keyCode
853
839
  }, composerInput);
854
- if (action === "stop") onStop?.();
840
+ if (preventDefault) e.preventDefault();
841
+ if (action === "command") requestAnimationFrame(() => {
842
+ inputRef.current?.focus();
843
+ });
844
+ else if (action === "stop") onStop?.();
855
845
  else if (action === "send") send();
856
846
  };
857
847
  const send = () => {
858
848
  if (!onSubmitMessage) return;
859
- const trimmed = resolvedValue.trim();
860
- if (!trimmed) return;
861
- onSubmitMessage(trimmed);
862
- if (!isControlled) setInternalValue("");
863
- onChange?.("");
864
- if (inputRef.current) inputRef.current.focus();
849
+ if (composer.submit(onSubmitMessage, { value: resolvedValue })) inputRef.current?.focus();
865
850
  };
866
851
  const BoundTextArea = renderSlot(textArea, CopilotChatInput.TextArea, {
867
852
  ref: inputRef,
@@ -908,7 +893,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
908
893
  toolsMenu
909
894
  });
910
895
  const BoundDisclaimer = renderSlot(disclaimer, CopilotChatInput.Disclaimer, {});
911
- const shouldShowDisclaimer = showDisclaimer ?? positioning === "absolute";
896
+ const shouldShowDisclaimer = (0, _copilotkit_core.ɵshowsComposerDisclaimer)({
897
+ showDisclaimer,
898
+ positioning
899
+ });
912
900
  const handleContainerClick = (e) => {
913
901
  const target = e.target;
914
902
  if (target.tagName !== "BUTTON" && !target.closest("button") && inputRef.current && mode === "input") inputRef.current.focus();
@@ -921,7 +909,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
921
909
  mode
922
910
  ]);
923
911
  (0, react.useEffect)(() => () => autosize.dispose(), [autosize]);
924
- const slashMenuVisible = commandQuery !== null && commandItems.length > 0;
912
+ const slashMenuVisible = commandQuery !== null;
925
913
  (0, react.useEffect)(() => {
926
914
  if (!slashMenuVisible || slashHighlightIndex < 0) return;
927
915
  (slashMenuRef.current?.querySelector(`[data-slash-index="${slashHighlightIndex}"]`))?.scrollIntoView({ block: "nearest" });
@@ -945,7 +933,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
945
933
  "data-active": isActive ? "true" : void 0,
946
934
  "data-slash-index": index,
947
935
  className: "cpk-chat-input-slash-menu-item",
948
- onMouseEnter: () => setSlashHighlightIndex(index),
936
+ onMouseEnter: () => composer.highlight(index),
949
937
  onMouseDown: (event) => {
950
938
  event.preventDefault();
951
939
  runCommand(item);
@@ -1106,22 +1094,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
1106
1094
  const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
1107
1095
  const [mounted, setMounted] = (0, react.useState)(false);
1108
1096
  (0, react.useEffect)(() => setMounted(true), []);
1109
- const menuItems = (0, react.useMemo)(() => {
1110
- const items = [];
1111
- if (onAddFile) items.push({
1112
- label: labels.chatInputToolbarAddButtonLabel,
1113
- action: onAddFile
1114
- });
1115
- if (toolsMenu && toolsMenu.length > 0) {
1116
- if (items.length > 0) items.push("-");
1117
- for (const item of toolsMenu) if (item === "-") {
1118
- if (items.length === 0 || items[items.length - 1] === "-") continue;
1119
- items.push(item);
1120
- } else items.push(item);
1121
- while (items.length > 0 && items[items.length - 1] === "-") items.pop();
1122
- }
1123
- return items;
1124
- }, [
1097
+ const menuItems = (0, react.useMemo)(() => (0, _copilotkit_core.ɵnormalizeToolsMenu)(toolsMenu, onAddFile ? {
1098
+ label: labels.chatInputToolbarAddButtonLabel,
1099
+ action: onAddFile
1100
+ } : void 0), [
1125
1101
  onAddFile,
1126
1102
  toolsMenu,
1127
1103
  labels.chatInputToolbarAddButtonLabel
@@ -1382,7 +1358,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
1382
1358
 
1383
1359
  //#endregion
1384
1360
  //#region package.json
1385
- var version$1 = "2.0.0-rc.25";
1361
+ var version$1 = "2.0.0-rc.27";
1386
1362
 
1387
1363
  //#endregion
1388
1364
  //#region src/components/CopilotKitInspector.tsx
@@ -2025,8 +2001,9 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
2025
2001
  * duplicate skeleton on retries / multi-call generations and a skeleton that
2026
2002
  * lingered after the surface painted — both fixed by retiring it here.
2027
2003
  *
2028
- * Users can still override with their own `useRenderTool({ name: "render_a2ui" })`
2029
- * (hook-based entries take priority over this prop-based registration).
2004
+ * It is a built-in renderer, so a `renderToolCalls` entry or a
2005
+ * `useRenderTool({ name: "render_a2ui" })` hook replaces it, and it never
2006
+ * removes the app's renderers. It is removed when A2UI turns off.
2030
2007
  */
2031
2008
  function A2UIBuiltInToolCallRenderer() {
2032
2009
  const { copilotkit } = useCopilotKit();
@@ -2036,8 +2013,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
2036
2013
  args: zod.any(),
2037
2014
  render: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, {})
2038
2015
  });
2039
- const existing = copilotkit._renderToolCalls ?? [];
2040
- copilotkit.setRenderToolCalls([...existing.filter((rc) => rc.name !== _copilotkit_core.ɵRENDER_A2UI_TOOL_NAME), renderer]);
2016
+ return copilotkit.ɵaddBuiltInRenderToolCall(renderer);
2041
2017
  }, [copilotkit]);
2042
2018
  return null;
2043
2019
  }
@@ -6402,8 +6378,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
6402
6378
  args: zod.any(),
6403
6379
  render: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, {})
6404
6380
  });
6405
- const existing = copilotkit._renderToolCalls ?? [];
6406
- copilotkit.setRenderToolCalls([...existing.filter((rc) => rc.name !== _copilotkit_shared.GENERATIVE_UI_RENDER_TOOL), renderer]);
6381
+ return copilotkit.ɵaddBuiltInRenderToolCall(renderer);
6407
6382
  }, [copilotkit]);
6408
6383
  return null;
6409
6384
  }
@@ -6455,13 +6430,14 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
6455
6430
  ...props,
6456
6431
  allowSameOriginFallback: true
6457
6432
  });
6458
- function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
6433
+ function useStableArrayProp(prop, name) {
6459
6434
  const empty = (0, react.useMemo)(() => [], []);
6460
6435
  const value = prop ?? empty;
6461
6436
  const initial = (0, react.useRef)(value);
6462
6437
  (0, react.useEffect)(() => {
6463
- if (warningMessage && value !== initial.current && (isMeaningfulChange ? isMeaningfulChange(initial.current, value) : true)) console.error(warningMessage);
6464
- }, [value, warningMessage]);
6438
+ const warning = (0, _copilotkit_core.ɵstableArrayPropWarning)(name, initial.current, value);
6439
+ if (warning) console.error(warning);
6440
+ }, [value, name]);
6465
6441
  return value;
6466
6442
  }
6467
6443
  /** Provide a shared core instance and synchronize runtime, tool, and UI configuration. */
@@ -6486,8 +6462,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
6486
6462
  runtimeEnabled: runtimeOpenGenUIEnabled,
6487
6463
  configured: !!openGenerativeUI
6488
6464
  });
6489
- const a2uiCatalogProvided = !!a2ui?.catalog;
6490
- const a2uiActive = runtimeA2UIEnabled || a2uiCatalogProvided;
6465
+ const a2uiActive = (0, _copilotkit_core.ɵresolveA2UIActivation)({
6466
+ runtimeEnabled: runtimeA2UIEnabled,
6467
+ hasCatalog: !!a2ui?.catalog
6468
+ }).active;
6491
6469
  const generativeUIActive = !!generativeUI?.ui;
6492
6470
  const runtimeLicenseStatus = runtimeInfo?.licenseStatus;
6493
6471
  const runtimeEntitlements = runtimeInfo?.runtimeEntitlements;
@@ -6505,9 +6483,9 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
6505
6483
  inspectorVisible,
6506
6484
  requestInspectorOpen
6507
6485
  ]);
6508
- const renderToolCallsList = useStableArrayProp(renderToolCalls, _copilotkit_core.ɵSTABLE_ARRAY_WARNINGS.renderToolCalls, _copilotkit_core.ɵtoolRendererShapeChanged);
6509
- const renderCustomMessagesList = useStableArrayProp(renderCustomMessages, _copilotkit_core.ɵSTABLE_ARRAY_WARNINGS.renderCustomMessages);
6510
- const renderActivityMessagesList = useStableArrayProp(renderActivityMessages, _copilotkit_core.ɵSTABLE_ARRAY_WARNINGS.renderActivityMessages);
6486
+ const renderToolCallsList = useStableArrayProp(renderToolCalls, "renderToolCalls");
6487
+ const renderCustomMessagesList = useStableArrayProp(renderCustomMessages, "renderCustomMessages");
6488
+ const renderActivityMessagesList = useStableArrayProp(renderActivityMessages, "renderActivityMessages");
6511
6489
  const copilotkitRef = (0, react.useRef)(null);
6512
6490
  const rawCatalog = a2ui?.catalog;
6513
6491
  const filteredCatalog = (0, react.useMemo)(() => {
@@ -6517,27 +6495,31 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
6517
6495
  return (0, _copilotkit_a2ui_renderer.filterCatalog)(rawCatalog, (name) => core ? core.isCatalogComponentEnabled(name) : true);
6518
6496
  }, [rawCatalog, catalogToggleVersion]);
6519
6497
  const mcpAppsAllowSameOrigin = mcpApps?.allowSameOriginFallback === true;
6520
- const builtInActivityRenderers = (0, react.useMemo)(() => {
6521
- const renderers = [{
6522
- activityType: _copilotkit_mcp_apps_renderer_activity.MCPAppsActivityType,
6523
- content: _copilotkit_mcp_apps_renderer_activity.MCPAppsActivityContentSchema,
6524
- render: mcpAppsAllowSameOrigin ? SameOriginMCPAppsActivityRenderer : MCPAppsActivityRenderer
6525
- }];
6526
- if (openGenUIActive) renderers.push({
6527
- activityType: OpenGenerativeUIActivityType,
6528
- content: OpenGenerativeUIContentSchema,
6529
- render: OpenGenerativeUIActivityRenderer
6530
- });
6531
- if (a2uiActive) renderers.unshift(createA2UIMessageRenderer({
6498
+ const allActivityRenderers = (0, react.useMemo)(() => (0, _copilotkit_core.ɵassembleActivityRenderers)({
6499
+ app: renderActivityMessagesList,
6500
+ a2ui: a2uiActive ? createA2UIMessageRenderer({
6532
6501
  theme: a2ui?.theme ?? _copilotkit_a2ui_renderer.viewerTheme,
6533
6502
  catalog: filteredCatalog,
6534
6503
  loadingComponent: a2ui?.loadingComponent,
6535
6504
  recovery: a2ui?.recovery,
6536
6505
  onAction: a2ui?.onAction
6537
- }));
6538
- if (generativeUIActive) renderers.push(createGenerativeUIActivityRenderer(), createGenerativeUIFunctionCallActivityRenderer());
6539
- return renderers;
6540
- }, [
6506
+ }) : void 0,
6507
+ builtIns: [
6508
+ {
6509
+ activityType: _copilotkit_mcp_apps_renderer_activity.MCPAppsActivityType,
6510
+ content: _copilotkit_mcp_apps_renderer_activity.MCPAppsActivityContentSchema,
6511
+ render: mcpAppsAllowSameOrigin ? SameOriginMCPAppsActivityRenderer : MCPAppsActivityRenderer
6512
+ },
6513
+ openGenUIActive && {
6514
+ activityType: OpenGenerativeUIActivityType,
6515
+ content: OpenGenerativeUIContentSchema,
6516
+ render: OpenGenerativeUIActivityRenderer
6517
+ },
6518
+ generativeUIActive && createGenerativeUIActivityRenderer(),
6519
+ generativeUIActive && createGenerativeUIFunctionCallActivityRenderer()
6520
+ ]
6521
+ }), [
6522
+ renderActivityMessagesList,
6541
6523
  a2uiActive,
6542
6524
  openGenUIActive,
6543
6525
  generativeUIActive,
@@ -6545,9 +6527,6 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
6545
6527
  filteredCatalog,
6546
6528
  mcpAppsAllowSameOrigin
6547
6529
  ]);
6548
- const allActivityRenderers = (0, react.useMemo)(() => {
6549
- return [...renderActivityMessagesList, ...builtInActivityRenderers];
6550
- }, [renderActivityMessagesList, builtInActivityRenderers]);
6551
6530
  const resolvedConfig = (0, react.useMemo)(() => (0, _copilotkit_core.ɵresolveProviderConfig)({
6552
6531
  runtimeUrl,
6553
6532
  publicApiKey,
@@ -6582,31 +6561,9 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
6582
6561
  }, []);
6583
6562
  const headersInput = isHeadersBuilder ? stableHeadersBuilder : headersProp;
6584
6563
  const headersSource = (0, react.useMemo)(() => (0, _copilotkit_core.ɵwithHeaderDefaults)(headersInput, (0, _copilotkit_core.ɵpublicKeyHeaderDefaults)(resolvedPublicKey)), [headersInput, resolvedPublicKey]);
6585
- const frontendToolsList = useStableArrayProp(frontendTools, _copilotkit_core.ɵSTABLE_ARRAY_WARNINGS.frontendTools);
6586
- const humanInTheLoopList = useStableArrayProp(humanInTheLoop, _copilotkit_core.ɵSTABLE_ARRAY_WARNINGS.humanInTheLoop);
6587
- const sandboxFunctionsList = useStableArrayProp(openGenerativeUI?.sandboxFunctions, _copilotkit_core.ɵSTABLE_ARRAY_WARNINGS.sandboxFunctions);
6588
- const processedHumanInTheLoopTools = (0, react.useMemo)(() => {
6589
- const processedTools = [];
6590
- const processedRenderToolCalls = [];
6591
- const registry = () => copilotkitRef.current.ɵhumanInTheLoop;
6592
- humanInTheLoopList.forEach((tool) => {
6593
- const { render, ...config } = tool;
6594
- processedTools.push((0, _copilotkit_core.ɵbuildHumanInTheLoopTool)(config, registry));
6595
- if (render) {
6596
- const RenderComponent = (props) => (0, react.createElement)(render, (0, _copilotkit_core.ɵhitlRenderProps)(props, tool, registry()));
6597
- processedRenderToolCalls.push({
6598
- name: tool.name,
6599
- args: tool.parameters,
6600
- render: RenderComponent,
6601
- ...tool.agentId && { agentId: tool.agentId }
6602
- });
6603
- }
6604
- });
6605
- return {
6606
- tools: processedTools,
6607
- renderToolCalls: processedRenderToolCalls
6608
- };
6609
- }, [humanInTheLoopList]);
6564
+ const frontendToolsList = useStableArrayProp(frontendTools, "frontendTools");
6565
+ const humanInTheLoopList = useStableArrayProp(humanInTheLoop, "humanInTheLoop");
6566
+ const sandboxFunctionsList = useStableArrayProp(openGenerativeUI?.sandboxFunctions, "sandboxFunctions");
6610
6567
  const builtInFrontendTools = (0, react.useMemo)(() => {
6611
6568
  if (!openGenUIActive) return [];
6612
6569
  return [{
@@ -6614,36 +6571,30 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
6614
6571
  render: OpenGenerativeUIToolRenderer
6615
6572
  }];
6616
6573
  }, [openGenUIActive]);
6617
- const allTools = (0, react.useMemo)(() => {
6618
- const tools = [];
6619
- tools.push(...frontendToolsList);
6620
- tools.push(...builtInFrontendTools);
6621
- tools.push(...processedHumanInTheLoopTools.tools);
6622
- return tools;
6623
- }, [
6574
+ const humanInTheLoopAssembly = (0, react.useMemo)(() => (0, _copilotkit_core.ɵassembleHumanInTheLoop)({
6575
+ humanInTheLoop: humanInTheLoopList,
6576
+ humanInTheLoopRegistry: () => copilotkitRef.current.ɵhumanInTheLoop,
6577
+ wrapHumanInTheLoopRender: (render, tool, registry) => (props) => (0, react.createElement)(render, (0, _copilotkit_core.ɵhitlRenderProps)(props, tool, registry()))
6578
+ }), [humanInTheLoopList]);
6579
+ const allTools = (0, react.useMemo)(() => (0, _copilotkit_core.ɵassembleProviderTools)({
6580
+ frontendTools: frontendToolsList,
6581
+ builtInFrontendTools,
6582
+ humanInTheLoop: humanInTheLoopAssembly
6583
+ }), [
6624
6584
  frontendToolsList,
6625
6585
  builtInFrontendTools,
6626
- processedHumanInTheLoopTools
6586
+ humanInTheLoopAssembly
6627
6587
  ]);
6628
- const allRenderToolCalls = (0, react.useMemo)(() => {
6629
- const combined = [...renderToolCallsList];
6630
- [...frontendToolsList, ...builtInFrontendTools].forEach((tool) => {
6631
- if (tool.render) {
6632
- const args = tool.parameters || (tool.name === "*" ? _copilotkit_shared.ɵanySchema : void 0);
6633
- if (args) combined.push({
6634
- name: tool.name,
6635
- args,
6636
- render: tool.render
6637
- });
6638
- }
6639
- });
6640
- combined.push(...processedHumanInTheLoopTools.renderToolCalls);
6641
- return combined;
6642
- }, [
6588
+ const allRenderToolCalls = (0, react.useMemo)(() => (0, _copilotkit_core.ɵassembleProviderToolRenderers)({
6589
+ renderToolCalls: renderToolCallsList,
6590
+ frontendTools: frontendToolsList,
6591
+ builtInFrontendTools,
6592
+ humanInTheLoop: humanInTheLoopAssembly
6593
+ }), [
6643
6594
  renderToolCallsList,
6644
6595
  frontendToolsList,
6645
6596
  builtInFrontendTools,
6646
- processedHumanInTheLoopTools
6597
+ humanInTheLoopAssembly
6647
6598
  ]);
6648
6599
  const copilotkit = ɵuseOwnedCore(copilotkitRef, () => new CopilotKitCoreReact({
6649
6600
  runtimeUrl: resolvedConfig.runtimeUrl,
@@ -6758,13 +6709,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
6758
6709
  const designSkill = openGenerativeUI?.designSkill;
6759
6710
  (0, react.useLayoutEffect)(() => {
6760
6711
  if (!copilotkit || !openGenUIActive) return;
6761
- const ids = (0, _copilotkit_core.ɵbuildOpenGenerativeUIContexts)({
6712
+ return (0, _copilotkit_core.ɵaddOpenGenerativeUIContexts)(copilotkit, {
6762
6713
  designSkill,
6763
6714
  sandboxFunctions: sandboxFunctionsList
6764
- }).map((entry) => copilotkit.addContext(entry));
6765
- return () => {
6766
- for (const id of ids) copilotkit.removeContext(id);
6767
- };
6715
+ });
6768
6716
  }, [
6769
6717
  copilotkit,
6770
6718
  designSkill,
@@ -6865,7 +6813,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
6865
6813
  //#region src/hooks/use-render-activity-message.tsx
6866
6814
  function useRenderActivityMessage() {
6867
6815
  const { copilotkit } = useCopilotKit();
6868
- const agentId = useCopilotChatConfiguration()?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
6816
+ const agentId = (0, _copilotkit_core.ɵresolveAgentId)({
6817
+ chatAgentId: useCopilotChatConfiguration()?.agentId,
6818
+ providerAgentId: useDefaultAgentId()
6819
+ });
6869
6820
  const renderers = copilotkit.renderActivityMessages;
6870
6821
  const findRenderer = (0, react.useCallback)((activityType) => (0, _copilotkit_core.ɵfindActivityRenderer)(renderers, {
6871
6822
  activityType,
@@ -7006,21 +6957,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
7006
6957
  const { copilotkit } = useCopilotKit();
7007
6958
  const depsVersion = useDepsVersion(deps);
7008
6959
  (0, react.useLayoutEffect)(() => {
7009
- const name = tool.name;
7010
- if (copilotkit.getTool({
7011
- toolName: name,
7012
- agentId: tool.agentId
7013
- })) console.warn(`Tool '${name}' already exists for agent '${tool.agentId || "global"}'. Overriding with latest registration.`);
7014
- const unregister = copilotkit.addTool(tool);
7015
- if (tool.render) copilotkit.addHookRenderToolCall({
7016
- name,
7017
- args: tool.parameters,
7018
- agentId: tool.agentId,
7019
- render: tool.render
7020
- });
7021
- return () => {
7022
- unregister();
7023
- };
6960
+ return (0, _copilotkit_core.ɵregisterFrontendTools)(copilotkit, [tool], (renderer) => copilotkit.addHookRenderToolCall(renderer));
7024
6961
  }, [
7025
6962
  tool.name,
7026
6963
  tool.available,
@@ -7090,30 +7027,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
7090
7027
  const toolList = tools ?? EMPTY_TOOLS;
7091
7028
  const extraDeps = deps ?? EMPTY_DEPS;
7092
7029
  (0, react.useLayoutEffect)(() => {
7093
- const deduped = /* @__PURE__ */ new Map();
7094
- for (const tool of toolList) {
7095
- const key = `${tool.agentId ?? ""}:${tool.name}`;
7096
- if (deduped.has(key)) console.warn(`Tool '${tool.name}' is listed more than once for agent '${tool.agentId || "global"}' in the same useFrontendTools call. Using the last entry.`);
7097
- deduped.set(key, tool);
7098
- }
7099
- const registered = [...deduped.values()];
7100
- const unregisters = [];
7101
- for (const tool of registered) {
7102
- if (copilotkit.getTool({
7103
- toolName: tool.name,
7104
- agentId: tool.agentId
7105
- })) console.warn(`Tool '${tool.name}' already exists for agent '${tool.agentId || "global"}'. Overriding with latest registration.`);
7106
- unregisters.push(copilotkit.addTool(tool));
7107
- if (tool.render) copilotkit.addHookRenderToolCall({
7108
- name: tool.name,
7109
- args: tool.parameters,
7110
- agentId: tool.agentId,
7111
- render: tool.render
7112
- });
7113
- }
7114
- return () => {
7115
- for (const unregister of unregisters) unregister();
7116
- };
7030
+ return (0, _copilotkit_core.ɵregisterFrontendTools)(copilotkit, toolList, (renderer) => copilotkit.addHookRenderToolCall(renderer));
7117
7031
  }, [
7118
7032
  JSON.stringify(toolList.map((tool) => [
7119
7033
  tool.name,
@@ -7637,41 +7551,11 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
7637
7551
  //#endregion
7638
7552
  //#region src/hooks/use-default-render-tool.tsx
7639
7553
  /**
7640
- * Module-level dedup set so an unknown status value only emits a console
7641
- * warning the FIRST time we encounter it. Otherwise a stuck/unmapped status
7642
- * would log on every re-render (potentially many per second).
7643
- */
7644
- const warnedUnknownStatuses = /* @__PURE__ */ new Set();
7645
- /**
7646
- * Map a {@link ToolCallStatus} enum value to the documented string-union
7647
- * status the {@link DefaultRenderProps} contract exposes. Unknown / future
7648
- * enum members log a warning (once per distinct value) and fall back to
7649
- * `"inProgress"`.
7650
- */
7651
- function mapToolCallStatus(status) {
7652
- const normalized = (0, _copilotkit_core.ɵnormalizeToolCallStatus)(status);
7653
- if (normalized !== "unknown") return normalized;
7654
- const key = String(status);
7655
- if (!warnedUnknownStatuses.has(key)) {
7656
- warnedUnknownStatuses.add(key);
7657
- console.warn(`[CopilotKit] Unknown ToolCallStatus "${key}" in default tool-call renderer; falling back to "inProgress".`);
7658
- }
7659
- return "inProgress";
7660
- }
7661
- /**
7662
7554
  * Convert the framework-internal renderer props (`args`, enum status) into
7663
7555
  * the documented {@link DefaultRenderProps} shape (`parameters`, string-union
7664
7556
  * status) so a user `config.render` always sees the documented contract.
7665
7557
  */
7666
- function adaptRendererProps(props) {
7667
- return {
7668
- name: props.name,
7669
- toolCallId: props.toolCallId,
7670
- parameters: props.args,
7671
- status: mapToolCallStatus(props.status),
7672
- result: props.result
7673
- };
7674
- }
7558
+ const adaptRendererProps = _copilotkit_core.ɵadaptDefaultToolCallRenderProps;
7675
7559
  /**
7676
7560
  * Registers a wildcard (`"*"`) tool-call renderer via `useRenderTool`.
7677
7561
  *
@@ -7968,7 +7852,11 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
7968
7852
  const { copilotkit } = useCopilotKit();
7969
7853
  const config = useCopilotChatConfiguration();
7970
7854
  const providerAgentId = useDefaultAgentId();
7971
- const resolvedAgentId = (0, react.useMemo)(() => agentId ?? config?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID, [
7855
+ const resolvedAgentId = (0, react.useMemo)(() => (0, _copilotkit_core.ɵresolveAgentId)({
7856
+ agentId,
7857
+ chatAgentId: config?.agentId,
7858
+ providerAgentId
7859
+ }), [
7972
7860
  agentId,
7973
7861
  config?.agentId,
7974
7862
  providerAgentId
@@ -8011,7 +7899,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
8011
7899
  const { copilotkit } = useCopilotKit();
8012
7900
  const chatConfig = useCopilotChatConfiguration();
8013
7901
  const providerAgentId = useDefaultAgentId();
8014
- const chatAgentId = chatConfig?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
7902
+ const chatAgentId = (0, _copilotkit_core.ɵresolveAgentId)({
7903
+ chatAgentId: chatConfig?.agentId,
7904
+ providerAgentId
7905
+ });
8015
7906
  const extraDeps = deps ?? [];
8016
7907
  const bindingRef = (0, react.useRef)(null);
8017
7908
  const latestRef = (0, react.useRef)({
@@ -8939,8 +8830,11 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
8939
8830
  function useFeedbackComment(controls) {
8940
8831
  const latestControls = (0, react.useRef)(controls);
8941
8832
  latestControls.current = controls;
8942
- const [controller] = (0, react.useState)(() => new _copilotkit_core.ɵFeedbackCommentController({ getControls: () => latestControls.current }));
8943
8833
  const inputRef = (0, react.useRef)(null);
8834
+ const [controller] = (0, react.useState)(() => new _copilotkit_core.ɵFeedbackCommentController({
8835
+ getControls: () => latestControls.current,
8836
+ getInput: () => inputRef.current
8837
+ }));
8944
8838
  const state = (0, react.useSyncExternalStore)(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
8945
8839
  (0, react.useEffect)(() => controller.dispose, [controller]);
8946
8840
  return {
@@ -8953,7 +8847,16 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
8953
8847
  leave: controller.leave,
8954
8848
  setEditing: controller.setEditing,
8955
8849
  close: controller.close,
8956
- returnFocus: controller.returnFocus
8850
+ returnFocus: controller.returnFocus,
8851
+ rate: controller.rate,
8852
+ thumb: controller.thumb,
8853
+ findAnchor: controller.findAnchor,
8854
+ sync: controller.sync,
8855
+ focusField: controller.focusField,
8856
+ submit: controller.submit,
8857
+ popoverEscape: controller.popoverEscape,
8858
+ popoverKeyDown: controller.popoverKeyDown,
8859
+ popoverFocusLeave: controller.popoverFocusLeave
8957
8860
  };
8958
8861
  }
8959
8862
 
@@ -9026,32 +8929,6 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
9026
8929
  })
9027
8930
  });
9028
8931
  }
9029
- /** Whether focus came from the keyboard; a pointer click also focuses buttons. */
9030
- function isFocusVisible(element) {
9031
- try {
9032
- return element.matches(":focus-visible");
9033
- } catch {
9034
- return false;
9035
- }
9036
- }
9037
- const HIDDEN_TOO = {
9038
- checkVisibilityCSS: true,
9039
- visibilityProperty: true
9040
- };
9041
- const FOCUSABLE = [
9042
- "a[href]",
9043
- "button:not([disabled])",
9044
- "input:not([disabled])",
9045
- "select:not([disabled])",
9046
- "textarea:not([disabled])",
9047
- "[tabindex]"
9048
- ].map((selector) => `${selector}:not([tabindex="-1"]):not([data-radix-focus-guard])`).join(", ");
9049
- /** Approximately the element Tab reaches after `element`, outside `skip`. */
9050
- function nextFocusable(element, skip) {
9051
- const all = Array.from(element.ownerDocument.querySelectorAll(FOCUSABLE)).filter((candidate) => candidate === element || !skip?.contains(candidate) && !candidate.closest("[hidden], [inert]"));
9052
- const index = all.indexOf(element);
9053
- return index === -1 ? null : all[index + 1] ?? null;
9054
- }
9055
8932
  /**
9056
8933
  * The comment popover of a rated message, pointing at the chosen thumb. Kept
9057
8934
  * apart so only it, not the whole message, follows chat configuration.
@@ -9060,19 +8937,12 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
9060
8937
  * from its start returns to the thumb, Tab from its end moves on to the
9061
8938
  * control after the thumb, and Enter or Escape inside it returns to the thumb.
9062
8939
  */
9063
- function FeedbackCommentPopover({ feedbackComment, comment, savedComment, rating, anchor, messageId }) {
8940
+ function FeedbackCommentPopover({ feedbackComment, comment, savedComment, rating, messageId }) {
9064
8941
  const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
9065
8942
  const contentRef = (0, react.useRef)(null);
9066
- const focusInside = () => contentRef.current?.contains(document.activeElement) ?? false;
9067
- const { focusRequest, takeFocusRequest, inputRef } = comment;
9068
- const focusField = (0, react.useCallback)(() => {
9069
- if (inputRef.current && takeFocusRequest()) inputRef.current.focus();
9070
- }, [inputRef, takeFocusRequest]);
8943
+ const anchor = (0, react.useMemo)(() => ({ current: comment.anchor }), [comment.anchor]);
8944
+ const { focusRequest, focusField } = comment;
9071
8945
  (0, react.useEffect)(() => focusField(), [focusRequest, focusField]);
9072
- /** Whether `target` is a thumb of this message, whose click decides itself. */
9073
- const isOwnThumb = (target) => {
9074
- return (target instanceof Element ? target.closest("[data-copilotkit-rating]") : null)?.closest("[data-message-id]")?.getAttribute("data-message-id") === messageId;
9075
- };
9076
8946
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Popover, {
9077
8947
  open: comment.open,
9078
8948
  onOpenChange: (open) => {
@@ -9091,24 +8961,12 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
9091
8961
  },
9092
8962
  onCloseAutoFocus: (event) => event.preventDefault(),
9093
8963
  onInteractOutside: (event) => {
9094
- if (isOwnThumb(event.target)) event.preventDefault();
8964
+ if ((0, _copilotkit_core.ɵisOwnFeedbackThumb)(event.target, messageId)) event.preventDefault();
9095
8965
  },
9096
8966
  onEscapeKeyDown: (event) => {
9097
- const returnFocus = focusInside();
9098
- if (returnFocus) event.stopPropagation();
9099
- comment.close({ save: false });
9100
- if (returnFocus) comment.returnFocus(anchor.current);
9101
- },
9102
- onKeyDown: (event) => {
9103
- if (event.key !== "Tab") return;
9104
- const focusables = Array.from(contentRef.current?.querySelectorAll(FOCUSABLE) ?? []);
9105
- if (!(event.shiftKey ? document.activeElement === focusables[0] : document.activeElement === focusables[focusables.length - 1]) || !anchor.current?.isConnected) return;
9106
- event.preventDefault();
9107
- const target = event.shiftKey ? anchor.current : nextFocusable(anchor.current, contentRef.current) ?? anchor.current;
9108
- comment.close();
9109
- if (target === anchor.current) comment.returnFocus(target);
9110
- else target.focus();
8967
+ if (comment.popoverEscape(contentRef.current)) event.stopPropagation();
9111
8968
  },
8969
+ onKeyDown: (event) => comment.popoverKeyDown(event, contentRef.current),
9112
8970
  onPointerEnter: () => comment.enter("pointer"),
9113
8971
  onPointerLeave: () => comment.leave("pointer"),
9114
8972
  className: "cpk-assistant-message-feedback-popover",
@@ -9117,15 +8975,9 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
9117
8975
  savedComment,
9118
8976
  inputRef: comment.inputRef,
9119
8977
  onChange: comment.setDraft,
9120
- onSubmit: () => {
9121
- comment.close();
9122
- comment.returnFocus(anchor.current);
9123
- },
8978
+ onSubmit: comment.submit,
9124
8979
  onEditingChange: comment.setEditing,
9125
- onLeave: (next) => {
9126
- if (next && (contentRef.current?.contains(next) || isOwnThumb(next))) return;
9127
- comment.leave();
9128
- }
8980
+ onLeave: (next) => comment.popoverFocusLeave(next, contentRef.current, messageId)
9129
8981
  }) }, rating)
9130
8982
  })]
9131
8983
  });
@@ -9140,73 +8992,29 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
9140
8992
  const showInspectorShortcut = isInspectorEnabled && !shortcutsHidden;
9141
8993
  const feedback = useMessageFeedback(message);
9142
8994
  const comment = useFeedbackComment(feedback);
9143
- const rating = feedback?.feedback?.rating;
9144
8995
  const root = (0, react.useRef)(null);
9145
- const commentAnchor = (0, react.useRef)(null);
9146
- const commentRating = (0, react.useRef)(rating);
9147
- (0, react.useLayoutEffect)(() => {
9148
- if (comment.open && !commentAnchor.current?.isConnected && rating) commentAnchor.current = root.current?.querySelector(`[data-copilotkit-rating="${rating}"]`) ?? root.current?.querySelector("button[aria-pressed=\"true\"]") ?? null;
9149
- });
8996
+ (0, react.useLayoutEffect)(() => comment.findAnchor(root.current));
9150
8997
  /**
9151
- * Thumbs are toggles: a new rating is saved and opens its comment, and
9152
- * clicking the chosen thumb again removes the rating. A keyboard click
9153
- * (`detail` 0) moves focus into the comment, as there is no pointer.
9154
- * Custom thumb slots may call `onClick` without an event.
9155
- *
9156
- * @returns Whether the app's handler should run: true for a new rating and
9157
- * whenever this chat does not record ratings, false when one is removed.
8998
+ * A thumb click. A keyboard click (`detail` 0) moves focus into the
8999
+ * comment; custom thumb slots may call `onClick` without an event.
9158
9000
  */
9159
- const rate = (value, event) => {
9160
- if (!feedback) return true;
9161
- if (rating === value) {
9162
- comment.close({ save: false });
9163
- feedback.clear();
9164
- return false;
9165
- }
9166
- feedback.rate(value);
9167
- commentRating.current = value;
9168
- commentAnchor.current = event?.currentTarget ?? null;
9169
- comment.show({
9170
- comment: "",
9171
- focus: event?.detail === 0
9172
- });
9173
- return true;
9174
- };
9001
+ const rate = (value, event) => comment.rate(value, {
9002
+ target: event?.currentTarget ?? null,
9003
+ keyboard: event?.detail === 0
9004
+ });
9175
9005
  /** Props that let the chosen thumb open and point at its comment. */
9176
9006
  const thumbFeedbackProps = (value) => {
9177
- if (!feedback) return {};
9178
- const thumb = { "data-copilotkit-rating": value };
9179
- if (rating !== value) return {
9180
- ...thumb,
9181
- "aria-pressed": false
9182
- };
9183
- const enter = (target, via) => {
9184
- if (!comment.open) commentRating.current = value;
9185
- commentAnchor.current = target;
9186
- comment.enter(via);
9187
- };
9007
+ const thumb = comment.thumb(value);
9008
+ if (!thumb) return {};
9009
+ const { handlers } = thumb;
9010
+ if (!handlers) return thumb.attributes;
9188
9011
  return {
9189
- ...thumb,
9190
- "aria-pressed": true,
9191
- "aria-haspopup": "dialog",
9192
- "aria-expanded": comment.open,
9193
- onPointerEnter: (event) => {
9194
- if (event.pointerType !== "touch") enter(event.currentTarget, "pointer");
9195
- },
9196
- onPointerLeave: (event) => {
9197
- if (event.pointerType !== "touch") comment.leave("pointer");
9198
- },
9199
- onFocus: (event) => {
9200
- if (isFocusVisible(event.currentTarget)) enter(event.currentTarget, "focus");
9201
- },
9202
- onBlur: () => comment.leave(),
9203
- onKeyDown: (event) => {
9204
- const input = comment.inputRef.current;
9205
- if (event.key === "Tab" && !event.shiftKey && comment.open && input && input.checkVisibility?.(HIDDEN_TOO) !== false) {
9206
- event.preventDefault();
9207
- input.focus();
9208
- }
9209
- }
9012
+ ...thumb.attributes,
9013
+ onPointerEnter: handlers.pointerEnter,
9014
+ onPointerLeave: handlers.pointerLeave,
9015
+ onFocus: handlers.focus,
9016
+ onBlur: handlers.blur,
9017
+ onKeyDown: handlers.keyDown
9210
9018
  };
9211
9019
  };
9212
9020
  const boundMarkdownRenderer = renderSlot(markdownRenderer, DefaultMarkdownRenderer, {
@@ -9260,23 +9068,21 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
9260
9068
  isRunning: !!isRunning,
9261
9069
  isLatest: isLatestAssistantMessage
9262
9070
  });
9263
- const { open: commentOpen, close: closeComment } = comment;
9071
+ const rating = feedback?.feedback?.rating;
9072
+ const { open: commentOpen, sync: syncComment } = comment;
9264
9073
  (0, react.useEffect)(() => {
9265
- if (!commentOpen) return;
9266
- if (rating !== commentRating.current) closeComment({ save: false });
9267
- else if (!shouldShowToolbar) closeComment();
9074
+ syncComment({ showsToolbar: shouldShowToolbar });
9268
9075
  }, [
9269
9076
  commentOpen,
9270
9077
  shouldShowToolbar,
9271
9078
  rating,
9272
- closeComment
9079
+ syncComment
9273
9080
  ]);
9274
9081
  const feedbackComment = feedback?.feedback && shouldShowToolbar && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FeedbackCommentPopover, {
9275
9082
  feedbackComment: feedbackCommentSlot,
9276
9083
  comment,
9277
9084
  savedComment: feedback.feedback.comment ?? "",
9278
9085
  rating: feedback.feedback.rating,
9279
- anchor: commentAnchor,
9280
9086
  messageId: message.id
9281
9087
  });
9282
9088
  if (children) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -9882,33 +9688,17 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
9882
9688
  const isLatest = isLatestProp ?? messages?.[messages.length - 1]?.id === message.id;
9883
9689
  const isStreaming = !!(isRunning && isLatest);
9884
9690
  const hasContent = !!(message.content && message.content.length > 0);
9885
- const startTimeRef = (0, react.useRef)(null);
9886
- const [elapsed, setElapsed] = (0, react.useState)(0);
9691
+ const [disclosure] = (0, react.useState)(() => new _copilotkit_core.ɵReasoningDisclosure({ isStreaming }));
9692
+ const { isOpen, elapsedSeconds: elapsed } = (0, react.useSyncExternalStore)(disclosure.subscribe, disclosure.getSnapshot, disclosure.getSnapshot);
9887
9693
  (0, react.useEffect)(() => {
9888
- if (isStreaming && startTimeRef.current === null) startTimeRef.current = Date.now();
9889
- if (!isStreaming && startTimeRef.current !== null) {
9890
- setElapsed((Date.now() - startTimeRef.current) / 1e3);
9891
- return;
9892
- }
9893
- if (!isStreaming) return;
9894
- const timer = setInterval(() => {
9895
- if (startTimeRef.current !== null) setElapsed((Date.now() - startTimeRef.current) / 1e3);
9896
- }, 1e3);
9897
- return () => clearInterval(timer);
9898
- }, [isStreaming]);
9899
- const [isOpen, setIsOpen] = (0, react.useState)(isStreaming);
9900
- const userToggledRef = (0, react.useRef)(false);
9901
- (0, react.useEffect)(() => {
9902
- if (isStreaming) {
9903
- userToggledRef.current = false;
9904
- setIsOpen(true);
9905
- } else if (!userToggledRef.current) setIsOpen(false);
9906
- }, [isStreaming]);
9907
- const handleToggle = hasContent ? () => {
9908
- userToggledRef.current = true;
9909
- setIsOpen((prev) => !prev);
9910
- } : void 0;
9911
- const label = isStreaming ? labels.reasoningMessageThinkingLabel : (0, _copilotkit_core.ɵformatLabel)(labels.reasoningMessageThoughtForLabel, { duration: (0, _copilotkit_core.ɵformatReasoningDurationLabel)(elapsed, labels) });
9694
+ disclosure.setStreaming(isStreaming);
9695
+ }, [disclosure, isStreaming]);
9696
+ (0, react.useEffect)(() => disclosure.dispose, [disclosure]);
9697
+ const handleToggle = hasContent ? disclosure.toggle : void 0;
9698
+ const label = (0, _copilotkit_core.ɵgetReasoningHeaderLabel)({
9699
+ isStreaming,
9700
+ elapsedSeconds: elapsed
9701
+ }, labels);
9912
9702
  const boundHeader = renderSlot(header, CopilotChatReasoningMessage.Header, {
9913
9703
  isOpen,
9914
9704
  label,
@@ -10625,6 +10415,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
10625
10415
  const { renderActivityMessage } = useRenderActivityMessage();
10626
10416
  const { copilotkit, showIntelligenceIndicator = true } = useCopilotKit();
10627
10417
  const config = useCopilotChatConfiguration();
10418
+ const providerAgentId = useDefaultAgentId();
10628
10419
  const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
10629
10420
  (0, react.useEffect)(() => {
10630
10421
  if (!config?.agentId) return;
@@ -10645,12 +10436,11 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
10645
10436
  } });
10646
10437
  return () => subscription.unsubscribe();
10647
10438
  }, [copilotkit]);
10648
- const getStateSnapshotForMessage = (messageId) => {
10649
- if (!config) return void 0;
10650
- const resolvedRunId = copilotkit.getRunIdForMessage(config.agentId, config.threadId, messageId) ?? copilotkit.getRunIdsForThread(config.agentId, config.threadId).slice(-1)[0];
10651
- if (!resolvedRunId) return void 0;
10652
- return copilotkit.getStateByRun(config.agentId, config.threadId, resolvedRunId);
10653
- };
10439
+ const getStateSnapshotForMessage = (messageId) => config ? (0, _copilotkit_core.ɵgetMessageRunStateSnapshot)(copilotkit, {
10440
+ agentId: config.agentId,
10441
+ threadId: config.threadId,
10442
+ messageId
10443
+ }) : void 0;
10654
10444
  const deduplicatedMessages = (0, react.useMemo)(() => (0, _copilotkit_core.ɵdeduplicateMessages)(messages), [messages]);
10655
10445
  const transformedMessages = (0, react.useMemo)(() => transformMessages ? transformMessages(deduplicatedMessages) : deduplicatedMessages, [deduplicatedMessages, transformMessages]);
10656
10446
  const rows = (0, react.useMemo)(() => groupMessages ? groupMessages(transformedMessages) : transformedMessages.map(messageRow), [transformedMessages, groupMessages]);
@@ -10904,7 +10694,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
10904
10694
  const nextRect = pendingRect;
10905
10695
  pendingRect = void 0;
10906
10696
  if (!instance.scrollElement?.clientHeight) return;
10907
- measuredWidthRef.current = instance.scrollElement?.clientWidth ?? nextRect.width;
10697
+ measuredWidthRef.current = instance.scrollElement.clientWidth;
10908
10698
  if (resizeAnchorRef.current) resizeAnchorRef.current.ready = true;
10909
10699
  instance.getTotalSize();
10910
10700
  measuredRef.current = {
@@ -11021,7 +10811,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
11021
10811
  const intelligenceTurnId = showIntelligenceIndicator ? intelligenceTurnAnchors.get(message.id) : void 0;
11022
10812
  if (intelligenceTurnId !== void 0) elements.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(IntelligenceIndicator, {
11023
10813
  message,
11024
- agentId: config?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID,
10814
+ agentId: (0, _copilotkit_core.ɵresolveAgentId)({
10815
+ chatAgentId: config?.agentId,
10816
+ providerAgentId
10817
+ }),
11025
10818
  intelligenceIndicator
11026
10819
  }, `intelligence-${intelligenceTurnId}`));
11027
10820
  return elements.filter(Boolean);
@@ -11542,36 +11335,18 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
11542
11335
  const [inputContainerEl, setInputContainerEl] = (0, react.useState)(null);
11543
11336
  const [inputContainerHeight, setInputContainerHeight] = (0, react.useState)(0);
11544
11337
  const [isResizing, setIsResizing] = (0, react.useState)(false);
11545
- const resizeTimeoutRef = (0, react.useRef)(null);
11546
11338
  const { isKeyboardOpen, keyboardHeight } = useKeyboardHeight();
11547
11339
  (0, react.useEffect)(() => {
11548
11340
  const element = inputContainerEl;
11549
11341
  if (!element) {
11550
11342
  setInputContainerHeight(0);
11343
+ setIsResizing(false);
11551
11344
  return;
11552
11345
  }
11553
- const resizeObserver = new ResizeObserver((entries) => {
11554
- for (const entry of entries) {
11555
- const newHeight = entry.contentRect.height;
11556
- setInputContainerHeight((prevHeight) => {
11557
- if (newHeight !== prevHeight) {
11558
- setIsResizing(true);
11559
- if (resizeTimeoutRef.current) clearTimeout(resizeTimeoutRef.current);
11560
- resizeTimeoutRef.current = setTimeout(() => {
11561
- setIsResizing(false);
11562
- }, 250);
11563
- return newHeight;
11564
- }
11565
- return prevHeight;
11566
- });
11567
- }
11346
+ return (0, _copilotkit_core.ɵwatchElementHeight)(element, (state) => {
11347
+ setInputContainerHeight(state.height);
11348
+ setIsResizing(state.isResizing);
11568
11349
  });
11569
- resizeObserver.observe(element);
11570
- setInputContainerHeight(element.offsetHeight);
11571
- return () => {
11572
- resizeObserver.disconnect();
11573
- if (resizeTimeoutRef.current) clearTimeout(resizeTimeoutRef.current);
11574
- };
11575
11350
  }, [inputContainerEl]);
11576
11351
  const BoundMessageView = renderSlot(messageView, CopilotChatMessageView, {
11577
11352
  messages,
@@ -11908,7 +11683,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
11908
11683
  if (!scrollElement) return;
11909
11684
  const contentElement = contentRef.current;
11910
11685
  const checkScroll = () => {
11911
- setShowScrollButton((contentElement ? contentElement.getBoundingClientRect().bottom - scrollElement.getBoundingClientRect().bottom : scrollElement.scrollHeight - scrollElement.scrollTop - scrollElement.clientHeight) >= 10);
11686
+ setShowScrollButton(!(contentElement ? (0, _copilotkit_core.ɵisContentScrolledToBottom)(scrollElement, contentElement) : (0, _copilotkit_core.ɵisScrolledToBottom)(scrollElement)));
11912
11687
  };
11913
11688
  checkScroll();
11914
11689
  scrollElement.addEventListener("scroll", checkScroll);
@@ -12101,9 +11876,14 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
12101
11876
  isInspectorEnabled: inspector.isInspectorEnabled && (inspector.providerEnableInspector ?? inspectorTools ?? true)
12102
11877
  }), [inspector, inspectorTools]);
12103
11878
  const providerAgentId = useDefaultAgentId();
12104
- const resolvedAgentId = agentId ?? existingConfig?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
11879
+ const resolvedAgentId = (0, _copilotkit_core.ɵresolveAgentId)({
11880
+ agentId,
11881
+ chatAgentId: existingConfig?.agentId,
11882
+ providerAgentId
11883
+ });
12105
11884
  const providedThreadId = threadId ?? existingConfig?.threadId;
12106
- const baseThreadId = (0, react.useMemo)(() => providedThreadId ?? (0, _copilotkit_shared.randomUUID)(), [providedThreadId]);
11885
+ const [freshThreadId] = (0, react.useState)(() => new _copilotkit_core.ɵFreshThreadId());
11886
+ const baseThreadId = (0, react.useMemo)(() => freshThreadId.resolve(providedThreadId), [freshThreadId, providedThreadId]);
12107
11887
  const baseHasExplicitThreadId = !!threadId || !!existingConfig?.hasExplicitThreadId;
12108
11888
  const { inspectorThreadId, inspectorRequestId, failInspectorOverride } = useInspectorThreadOverride({
12109
11889
  agentId: resolvedAgentId,
@@ -12128,35 +11908,16 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
12128
11908
  }, [onError]);
12129
11909
  (0, react.useEffect)(() => {
12130
11910
  if (!onErrorRef.current) return;
12131
- const subscription = copilotkit.subscribe({ onError: (event) => {
12132
- if (event.context?.agentId === resolvedAgentId || !event.context?.agentId) onErrorRef.current?.({
12133
- error: event.error,
12134
- code: event.code,
12135
- context: event.context
12136
- });
12137
- } });
12138
- return () => {
12139
- subscription.unsubscribe();
12140
- };
11911
+ return (0, _copilotkit_core.ɵsubscribeToAgentErrors)(copilotkit, resolvedAgentId, (event) => onErrorRef.current?.(event));
12141
11912
  }, [copilotkit, resolvedAgentId]);
12142
- (0, react.useEffect)(() => {
12143
- if (!inspectorRequestId) return;
12144
- const requestId = inspectorRequestId;
12145
- const expectedThreadId = resolvedThreadId;
12146
- const subscription = copilotkit.subscribe({ onError: (event) => {
12147
- if (event.code !== _copilotkit_core.CopilotKitCoreErrorCode.AGENT_CONNECT_FAILED) return;
12148
- if (event.context?.agentId !== resolvedAgentId) return;
12149
- if (event.context?.threadId !== expectedThreadId) return;
12150
- failInspectorOverride(requestId);
12151
- } });
12152
- return () => subscription.unsubscribe();
12153
- }, [
12154
- copilotkit,
12155
- failInspectorOverride,
12156
- inspectorRequestId,
12157
- resolvedAgentId,
12158
- resolvedThreadId
12159
- ]);
11913
+ const failInspectorOverrideRef = (0, react.useRef)(failInspectorOverride);
11914
+ failInspectorOverrideRef.current = failInspectorOverride;
11915
+ const [connection] = (0, react.useState)(() => new _copilotkit_core.ɵChatConnection({
11916
+ core: copilotkit,
11917
+ onInspectorOverrideFailed: (requestId) => failInspectorOverrideRef.current(requestId)
11918
+ }));
11919
+ const { threads } = connection;
11920
+ (0, react.useSyncExternalStore)((0, react.useCallback)((onChange) => connection.subscribe(onChange), [connection]), () => connection.getSnapshot(), () => connection.getSnapshot());
12160
11921
  const [transcribeMode, setTranscribeMode] = (0, react.useState)("input");
12161
11922
  const [inputValue, setInputValue] = (0, react.useState)("");
12162
11923
  const inputValueRef = (0, react.useRef)(inputValue);
@@ -12169,20 +11930,14 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
12169
11930
  const isTranscriptionEnabled = copilotkit.audioFileTranscriptionEnabled;
12170
11931
  const isMediaRecorderSupported = typeof window !== "undefined" && typeof MediaRecorder !== "undefined";
12171
11932
  const { messageView: providedMessageView, suggestionView: providedSuggestionView, onStop: providedStopHandler, ...restProps } = props;
12172
- const [lastConnectedThreadId, setLastConnectedThreadId] = (0, react.useState)(null);
12173
- const isConnecting = hasExplicitThreadId && lastConnectedThreadId !== resolvedThreadId;
11933
+ const isConnecting = connection.isConnecting({
11934
+ threadId: resolvedThreadId,
11935
+ explicit: hasExplicitThreadId
11936
+ });
12174
11937
  const activeConnectCountRef = (0, react.useRef)(0);
12175
- const [threads] = (0, react.useState)(() => new _copilotkit_core.ɵThreadSwitchCoordinator(copilotkit));
12176
11938
  const trackConnection = (0, react.useCallback)((connect) => {
12177
- const selection = threads.current;
12178
- if (selection) {
12179
- threads.trackConnection(selection, connect);
12180
- return;
12181
- }
12182
- connect().catch((error) => {
12183
- console.error("CopilotChat: connection failed", error);
12184
- });
12185
- }, [threads]);
11939
+ connection.track(connect);
11940
+ }, [connection]);
12186
11941
  const pendingRunActivityReconnectRef = (0, react.useRef)(false);
12187
11942
  const runActivityReconnectGenerationRef = (0, react.useRef)(0);
12188
11943
  const activeLocalRunIdsRef = (0, react.useRef)(/* @__PURE__ */ new Set());
@@ -12195,8 +11950,6 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
12195
11950
  const runtimeStatus = copilotkit.runtimeConnectionStatus === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Connected ? "Connected" : copilotkit.runtimeConnectionStatus;
12196
11951
  const hasNativeIntelligenceRunActivity = hasExplicitThreadId && runtimeStatus === "Connected" && !!copilotkit.intelligence?.wsUrl && copilotkit.threadEndpoints?.realtimeMetadata === true;
12197
11952
  const [standaloneRunActivityStore] = (0, react.useState)(() => (0, _copilotkit_core.ɵcreateThreadStore)({ fetch: copilotkit.ɵruntimeFetch }));
12198
- const hasExplicitThreadIdRef = (0, react.useRef)(hasExplicitThreadId);
12199
- hasExplicitThreadIdRef.current = hasExplicitThreadId;
12200
11953
  const rememberRecentlyLocalRunId = (0, react.useCallback)((runId) => {
12201
11954
  const existingTimeout = recentlyLocalRunIdsRef.current.get(runId);
12202
11955
  if (existingTimeout) clearTimeout(existingTimeout);
@@ -12234,57 +11987,33 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
12234
11987
  };
12235
11988
  }, []);
12236
11989
  (0, react.useEffect)(() => {
12237
- const selection = threads.select({
11990
+ const handle = connection.open({
12238
11991
  agent,
12239
11992
  threadId: resolvedThreadId,
12240
11993
  explicit: hasExplicitThreadId,
12241
11994
  inspectorRequestId
12242
- });
12243
- if (!selection.shouldConnect) return () => selection.release();
12244
- let detached = false;
12245
- const connectAbortController = new AbortController();
12246
- const connect = async (agentToConnect) => {
12247
- activeConnectCountRef.current += 1;
12248
- try {
12249
- await threads.whenTornDown();
12250
- if (detached) return;
12251
- if ((0, _copilotkit_core.ɵisHttpAgent)(agentToConnect)) agentToConnect.abortController = connectAbortController;
12252
- await copilotkit.connectAgent({ agent: agentToConnect });
12253
- } catch (error) {
12254
- if (detached) return;
12255
- if (inspectorRequestId) failInspectorOverride(inspectorRequestId);
12256
- throw error;
12257
- } finally {
12258
- if (!detached) (typeof requestAnimationFrame === "function" ? requestAnimationFrame : (cb) => setTimeout(cb, 16))(() => {
12259
- if (!detached) setLastConnectedThreadId(resolvedThreadId);
12260
- });
12261
- else if (!hasExplicitThreadIdRef.current) selection.clearDiscardedBaseline();
11995
+ }, {
11996
+ onStart: () => {
11997
+ activeConnectCountRef.current += 1;
11998
+ },
11999
+ onSettled: (current) => {
12262
12000
  activeConnectCountRef.current = Math.max(0, activeConnectCountRef.current - 1);
12263
- if (!detached && activeConnectCountRef.current === 0) {
12264
- const startReconnect = startRunActivityReconnectRef.current;
12265
- if (pendingRunActivityReconnectRef.current && startReconnect) {
12266
- pendingRunActivityReconnectRef.current = false;
12267
- startReconnect(runActivityReconnectGenerationRef.current);
12268
- }
12001
+ if (!current || activeConnectCountRef.current !== 0) return;
12002
+ const startReconnect = startRunActivityReconnectRef.current;
12003
+ if (pendingRunActivityReconnectRef.current && startReconnect) {
12004
+ pendingRunActivityReconnectRef.current = false;
12005
+ startReconnect(runActivityReconnectGenerationRef.current);
12269
12006
  }
12270
12007
  }
12271
- };
12272
- trackConnection(() => connect(agent));
12273
- return () => {
12274
- selection.release();
12275
- detached = true;
12276
- connectAbortController.abort();
12277
- threads.detach(agent);
12278
- };
12008
+ });
12009
+ return () => handle.release();
12279
12010
  }, [
12011
+ connection,
12280
12012
  resolvedThreadId,
12281
12013
  agent,
12282
12014
  resolvedAgentId,
12283
12015
  hasExplicitThreadId,
12284
- inspectorRequestId,
12285
- failInspectorOverride,
12286
- threads,
12287
- trackConnection
12016
+ inspectorRequestId
12288
12017
  ]);
12289
12018
  (0, react.useEffect)(() => {
12290
12019
  if (!hasNativeIntelligenceRunActivity) return;
@@ -12803,9 +12532,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
12803
12532
 
12804
12533
  //#endregion
12805
12534
  //#region src/components/chat/CopilotSidebarView.tsx
12806
- const DEFAULT_SIDEBAR_WIDTH = 480;
12807
- const SIDEBAR_TRANSITION_MS = 260;
12808
- /**
12535
+ /**
12809
12536
  * The chat in a side panel: a `complementary` region named by
12810
12537
  * `labels.sidebarLabel`, with a header, the chat view and a toggle button.
12811
12538
  */
@@ -12832,29 +12559,18 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
12832
12559
  const configuration = useCopilotChatConfiguration();
12833
12560
  const isSidebarOpen = configuration?.isModalOpen ?? false;
12834
12561
  const sidebarRef = (0, react.useRef)(null);
12835
- const [sidebarWidth, setSidebarWidth] = (0, react.useState)(width ?? DEFAULT_SIDEBAR_WIDTH);
12562
+ const [measuredWidth, setMeasuredWidth] = (0, react.useState)(width ?? _copilotkit_core.ɵSIDEBAR_DEFAULT_WIDTH);
12563
+ const sidebarWidth = width ?? measuredWidth;
12836
12564
  (0, react.useEffect)(() => {
12837
12565
  if (width !== void 0) return;
12838
- if (typeof window === "undefined") return;
12839
12566
  const element = sidebarRef.current;
12840
12567
  if (!element) return;
12841
- const updateWidth = () => {
12842
- const rect = element.getBoundingClientRect();
12843
- if (rect.width > 0) setSidebarWidth(rect.width);
12844
- };
12845
- updateWidth();
12846
- if (typeof ResizeObserver !== "undefined") {
12847
- const observer = new ResizeObserver(() => updateWidth());
12848
- observer.observe(element);
12849
- return () => observer.disconnect();
12850
- }
12851
- window.addEventListener("resize", updateWidth);
12852
- return () => window.removeEventListener("resize", updateWidth);
12568
+ return (0, _copilotkit_core.ɵwatchElementWidth)(element, setMeasuredWidth);
12853
12569
  }, [width]);
12854
- const widthCss = (0, _copilotkit_core.ɵdimensionToCss)(sidebarWidth, DEFAULT_SIDEBAR_WIDTH);
12570
+ const widthCss = (0, _copilotkit_core.ɵdimensionToCss)(sidebarWidth, _copilotkit_core.ɵSIDEBAR_DEFAULT_WIDTH);
12855
12571
  const dockRef = (0, react.useRef)(null);
12856
12572
  (0, react.useLayoutEffect)(() => {
12857
- const dock = (0, _copilotkit_core.ɵcreateDockedSidebar)(document, { transitionMs: SIDEBAR_TRANSITION_MS });
12573
+ const dock = (0, _copilotkit_core.ɵcreateDockedSidebar)(document, { transitionMs: _copilotkit_core.ɵSIDEBAR_TRANSITION_MS });
12858
12574
  dockRef.current = dock;
12859
12575
  return () => {
12860
12576
  dock.dispose();
@@ -12935,8 +12651,6 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
12935
12651
 
12936
12652
  //#endregion
12937
12653
  //#region src/components/chat/CopilotPopupView.tsx
12938
- const DEFAULT_POPUP_WIDTH = 420;
12939
- const DEFAULT_POPUP_HEIGHT = 560;
12940
12654
  function CopilotPopupView({ header, toggleButton, width, height, clickOutsideToClose, defaultOpen = true, className, ...restProps }) {
12941
12655
  const { open, onOpenChange } = useModalOpenControl();
12942
12656
  const hasOpenControl = open !== void 0 || onOpenChange !== void 0;
@@ -12964,22 +12678,12 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
12964
12678
  const setModalOpen = configuration?.setModalOpen;
12965
12679
  const labels = configuration?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
12966
12680
  const containerRef = (0, react.useRef)(null);
12967
- const [isRendered, setIsRendered] = (0, react.useState)(isPopupOpen);
12968
- const [isAnimatingOut, setIsAnimatingOut] = (0, react.useState)(false);
12681
+ const [presence] = (0, react.useState)(() => (0, _copilotkit_core.ɵcreateExitPresence)(isPopupOpen));
12682
+ const { isRendered, isClosing: isAnimatingOut } = (0, react.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
12969
12683
  (0, react.useEffect)(() => {
12970
- if (isPopupOpen) {
12971
- setIsRendered(true);
12972
- setIsAnimatingOut(false);
12973
- return;
12974
- }
12975
- if (!isRendered) return;
12976
- setIsAnimatingOut(true);
12977
- const timeout = setTimeout(() => {
12978
- setIsRendered(false);
12979
- setIsAnimatingOut(false);
12980
- }, _copilotkit_core.ɵPOPUP_ANIMATION_MS);
12981
- return () => clearTimeout(timeout);
12982
- }, [isPopupOpen, isRendered]);
12684
+ presence.setOpen(isPopupOpen);
12685
+ }, [presence, isPopupOpen]);
12686
+ (0, react.useEffect)(() => () => presence.dispose(), [presence]);
12983
12687
  (0, react.useEffect)(() => {
12984
12688
  if (!isPopupOpen) return;
12985
12689
  return (0, _copilotkit_core.ɵbindPopupDismiss)({
@@ -12994,8 +12698,8 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
12994
12698
  ]);
12995
12699
  const headerElement = (0, react.useMemo)(() => renderSlot(header, CopilotModalHeader, {}), [header]);
12996
12700
  const toggleButtonElement = (0, react.useMemo)(() => renderSlot(toggleButton, CopilotChatToggleButton, {}), [toggleButton]);
12997
- const resolvedWidth = (0, _copilotkit_core.ɵdimensionToCss)(width, DEFAULT_POPUP_WIDTH);
12998
- const resolvedHeight = (0, _copilotkit_core.ɵdimensionToCss)(height, DEFAULT_POPUP_HEIGHT);
12701
+ const resolvedWidth = (0, _copilotkit_core.ɵdimensionToCss)(width, _copilotkit_core.ɵPOPUP_DEFAULT_WIDTH);
12702
+ const resolvedHeight = (0, _copilotkit_core.ɵdimensionToCss)(height, _copilotkit_core.ɵPOPUP_DEFAULT_HEIGHT);
12999
12703
  const popupStyle = (0, react.useMemo)(() => ({
13000
12704
  "--copilot-popup-width": resolvedWidth,
13001
12705
  "--copilot-popup-height": resolvedHeight,
@@ -13195,7 +12899,11 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
13195
12899
  const configuration = useCopilotChatConfiguration();
13196
12900
  const { licensed, licensePending } = (0, _copilotkit_core.ɵresolveThreadsLicense)(useLicenseContext());
13197
12901
  const providerAgentId = useDefaultAgentId();
13198
- const resolvedAgentId = agentId ?? configuration?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
12902
+ const resolvedAgentId = (0, _copilotkit_core.ɵresolveAgentId)({
12903
+ agentId,
12904
+ chatAgentId: configuration?.agentId,
12905
+ providerAgentId
12906
+ });
13199
12907
  const activeThreadId = configuration?.threadId ?? null;
13200
12908
  const { threads, isLoading, listError, fetchMoreError, hasMoreThreads, isFetchingMoreThreads, archiveThread, unarchiveThread, deleteThread, fetchMoreThreads, refetchThreads, startNewThread } = useThreads({
13201
12909
  agentId: resolvedAgentId,
@@ -15000,6 +14708,12 @@ Object.defineProperty(exports, 'ɵChatConfigurationStore', {
15000
14708
  return _copilotkit_core.ɵChatConfigurationStore;
15001
14709
  }
15002
14710
  });
14711
+ Object.defineProperty(exports, 'ɵChatConnection', {
14712
+ enumerable: true,
14713
+ get: function () {
14714
+ return _copilotkit_core.ɵChatConnection;
14715
+ }
14716
+ });
15003
14717
  Object.defineProperty(exports, 'ɵChatSubmitter', {
15004
14718
  enumerable: true,
15005
14719
  get: function () {
@@ -15012,6 +14726,12 @@ Object.defineProperty(exports, 'ɵComposerAutosize', {
15012
14726
  return _copilotkit_core.ɵComposerAutosize;
15013
14727
  }
15014
14728
  });
14729
+ Object.defineProperty(exports, 'ɵComposerController', {
14730
+ enumerable: true,
14731
+ get: function () {
14732
+ return _copilotkit_core.ɵComposerController;
14733
+ }
14734
+ });
15015
14735
  Object.defineProperty(exports, 'ɵCopyFeedback', {
15016
14736
  enumerable: true,
15017
14737
  get: function () {
@@ -15030,6 +14750,12 @@ Object.defineProperty(exports, 'ɵDockedSidebarRegistry', {
15030
14750
  return _copilotkit_core.ɵDockedSidebarRegistry;
15031
14751
  }
15032
14752
  });
14753
+ Object.defineProperty(exports, 'ɵExitPresence', {
14754
+ enumerable: true,
14755
+ get: function () {
14756
+ return _copilotkit_core.ɵExitPresence;
14757
+ }
14758
+ });
15033
14759
  Object.defineProperty(exports, 'ɵFEEDBACK_COMMENT_CLOSE_DELAY_MS', {
15034
14760
  enumerable: true,
15035
14761
  get: function () {
@@ -15042,6 +14768,12 @@ Object.defineProperty(exports, 'ɵFeedbackCommentController', {
15042
14768
  return _copilotkit_core.ɵFeedbackCommentController;
15043
14769
  }
15044
14770
  });
14771
+ Object.defineProperty(exports, 'ɵFreshThreadId', {
14772
+ enumerable: true,
14773
+ get: function () {
14774
+ return _copilotkit_core.ɵFreshThreadId;
14775
+ }
14776
+ });
15045
14777
  Object.defineProperty(exports, 'ɵGENERATE_SANDBOXED_UI_ARGS_SCHEMA', {
15046
14778
  enumerable: true,
15047
14779
  get: function () {
@@ -15192,6 +14924,18 @@ Object.defineProperty(exports, 'ɵPOPUP_ANIMATION_MS', {
15192
14924
  return _copilotkit_core.ɵPOPUP_ANIMATION_MS;
15193
14925
  }
15194
14926
  });
14927
+ Object.defineProperty(exports, 'ɵPOPUP_DEFAULT_HEIGHT', {
14928
+ enumerable: true,
14929
+ get: function () {
14930
+ return _copilotkit_core.ɵPOPUP_DEFAULT_HEIGHT;
14931
+ }
14932
+ });
14933
+ Object.defineProperty(exports, 'ɵPOPUP_DEFAULT_WIDTH', {
14934
+ enumerable: true,
14935
+ get: function () {
14936
+ return _copilotkit_core.ɵPOPUP_DEFAULT_WIDTH;
14937
+ }
14938
+ });
15195
14939
  Object.defineProperty(exports, 'ɵPlaceholderCycler', {
15196
14940
  enumerable: true,
15197
14941
  get: function () {
@@ -15204,12 +14948,24 @@ Object.defineProperty(exports, 'ɵRENDER_A2UI_TOOL_NAME', {
15204
14948
  return _copilotkit_core.ɵRENDER_A2UI_TOOL_NAME;
15205
14949
  }
15206
14950
  });
14951
+ Object.defineProperty(exports, 'ɵRESIZE_SETTLE_MS', {
14952
+ enumerable: true,
14953
+ get: function () {
14954
+ return _copilotkit_core.ɵRESIZE_SETTLE_MS;
14955
+ }
14956
+ });
15207
14957
  Object.defineProperty(exports, 'ɵRUNTIME_PROBE_TIMEOUT_MS', {
15208
14958
  enumerable: true,
15209
14959
  get: function () {
15210
14960
  return _copilotkit_core.ɵRUNTIME_PROBE_TIMEOUT_MS;
15211
14961
  }
15212
14962
  });
14963
+ Object.defineProperty(exports, 'ɵReasoningDisclosure', {
14964
+ enumerable: true,
14965
+ get: function () {
14966
+ return _copilotkit_core.ɵReasoningDisclosure;
14967
+ }
14968
+ });
15213
14969
  Object.defineProperty(exports, 'ɵRendererRegistry', {
15214
14970
  enumerable: true,
15215
14971
  get: function () {
@@ -15228,12 +14984,36 @@ Object.defineProperty(exports, 'ɵSCROLL_BOTTOM_THRESHOLD_PX', {
15228
14984
  return _copilotkit_core.ɵSCROLL_BOTTOM_THRESHOLD_PX;
15229
14985
  }
15230
14986
  });
14987
+ Object.defineProperty(exports, 'ɵSIDEBAR_DEFAULT_WIDTH', {
14988
+ enumerable: true,
14989
+ get: function () {
14990
+ return _copilotkit_core.ɵSIDEBAR_DEFAULT_WIDTH;
14991
+ }
14992
+ });
14993
+ Object.defineProperty(exports, 'ɵSIDEBAR_TRANSITION_MS', {
14994
+ enumerable: true,
14995
+ get: function () {
14996
+ return _copilotkit_core.ɵSIDEBAR_TRANSITION_MS;
14997
+ }
14998
+ });
15231
14999
  Object.defineProperty(exports, 'ɵSTABLE_ARRAY_WARNINGS', {
15232
15000
  enumerable: true,
15233
15001
  get: function () {
15234
15002
  return _copilotkit_core.ɵSTABLE_ARRAY_WARNINGS;
15235
15003
  }
15236
15004
  });
15005
+ Object.defineProperty(exports, 'ɵStickToBottom', {
15006
+ enumerable: true,
15007
+ get: function () {
15008
+ return _copilotkit_core.ɵStickToBottom;
15009
+ }
15010
+ });
15011
+ Object.defineProperty(exports, 'ɵTAB_STOP_SELECTOR', {
15012
+ enumerable: true,
15013
+ get: function () {
15014
+ return _copilotkit_core.ɵTAB_STOP_SELECTOR;
15015
+ }
15016
+ });
15237
15017
  Object.defineProperty(exports, 'ɵTHREAD_REQUEST_TIMEOUT_MS', {
15238
15018
  enumerable: true,
15239
15019
  get: function () {
@@ -15276,6 +15056,18 @@ Object.defineProperty(exports, 'ɵThreadsController', {
15276
15056
  return _copilotkit_core.ɵThreadsController;
15277
15057
  }
15278
15058
  });
15059
+ Object.defineProperty(exports, 'ɵadaptDefaultToolCallRenderProps', {
15060
+ enumerable: true,
15061
+ get: function () {
15062
+ return _copilotkit_core.ɵadaptDefaultToolCallRenderProps;
15063
+ }
15064
+ });
15065
+ Object.defineProperty(exports, 'ɵaddOpenGenerativeUIContexts', {
15066
+ enumerable: true,
15067
+ get: function () {
15068
+ return _copilotkit_core.ɵaddOpenGenerativeUIContexts;
15069
+ }
15070
+ });
15279
15071
  Object.defineProperty(exports, 'ɵagentUpdateHandlers', {
15280
15072
  enumerable: true,
15281
15073
  get: function () {
@@ -15288,6 +15080,36 @@ Object.defineProperty(exports, 'ɵappendTranscript', {
15288
15080
  return _copilotkit_core.ɵappendTranscript;
15289
15081
  }
15290
15082
  });
15083
+ Object.defineProperty(exports, 'ɵassembleActivityRenderers', {
15084
+ enumerable: true,
15085
+ get: function () {
15086
+ return _copilotkit_core.ɵassembleActivityRenderers;
15087
+ }
15088
+ });
15089
+ Object.defineProperty(exports, 'ɵassembleHumanInTheLoop', {
15090
+ enumerable: true,
15091
+ get: function () {
15092
+ return _copilotkit_core.ɵassembleHumanInTheLoop;
15093
+ }
15094
+ });
15095
+ Object.defineProperty(exports, 'ɵassembleProviderRegistry', {
15096
+ enumerable: true,
15097
+ get: function () {
15098
+ return _copilotkit_core.ɵassembleProviderRegistry;
15099
+ }
15100
+ });
15101
+ Object.defineProperty(exports, 'ɵassembleProviderToolRenderers', {
15102
+ enumerable: true,
15103
+ get: function () {
15104
+ return _copilotkit_core.ɵassembleProviderToolRenderers;
15105
+ }
15106
+ });
15107
+ Object.defineProperty(exports, 'ɵassembleProviderTools', {
15108
+ enumerable: true,
15109
+ get: function () {
15110
+ return _copilotkit_core.ɵassembleProviderTools;
15111
+ }
15112
+ });
15291
15113
  Object.defineProperty(exports, 'ɵbindDialogFocus', {
15292
15114
  enumerable: true,
15293
15115
  get: function () {
@@ -15420,6 +15242,12 @@ Object.defineProperty(exports, 'ɵcreateDockedSidebar', {
15420
15242
  return _copilotkit_core.ɵcreateDockedSidebar;
15421
15243
  }
15422
15244
  });
15245
+ Object.defineProperty(exports, 'ɵcreateExitPresence', {
15246
+ enumerable: true,
15247
+ get: function () {
15248
+ return _copilotkit_core.ɵcreateExitPresence;
15249
+ }
15250
+ });
15423
15251
  Object.defineProperty(exports, 'ɵcreateLastUserMessageTracker', {
15424
15252
  enumerable: true,
15425
15253
  get: function () {
@@ -15450,6 +15278,12 @@ Object.defineProperty(exports, 'ɵcreateOpenGenerativeUITool', {
15450
15278
  return _copilotkit_core.ɵcreateOpenGenerativeUITool;
15451
15279
  }
15452
15280
  });
15281
+ Object.defineProperty(exports, 'ɵcreateStickToBottom', {
15282
+ enumerable: true,
15283
+ get: function () {
15284
+ return _copilotkit_core.ɵcreateStickToBottom;
15285
+ }
15286
+ });
15453
15287
  Object.defineProperty(exports, 'ɵcreateThreadSelectors', {
15454
15288
  enumerable: true,
15455
15289
  get: function () {
@@ -15576,6 +15410,12 @@ Object.defineProperty(exports, 'ɵflattenCommandItems', {
15576
15410
  return _copilotkit_core.ɵflattenCommandItems;
15577
15411
  }
15578
15412
  });
15413
+ Object.defineProperty(exports, 'ɵflattenToolsMenuForDisplay', {
15414
+ enumerable: true,
15415
+ get: function () {
15416
+ return _copilotkit_core.ɵflattenToolsMenuForDisplay;
15417
+ }
15418
+ });
15579
15419
  Object.defineProperty(exports, 'ɵflattenUserMessageContent', {
15580
15420
  enumerable: true,
15581
15421
  get: function () {
@@ -15726,6 +15566,18 @@ Object.defineProperty(exports, 'ɵgetMessageFeedbackControls', {
15726
15566
  return _copilotkit_core.ɵgetMessageFeedbackControls;
15727
15567
  }
15728
15568
  });
15569
+ Object.defineProperty(exports, 'ɵgetMessageRunStateSnapshot', {
15570
+ enumerable: true,
15571
+ get: function () {
15572
+ return _copilotkit_core.ɵgetMessageRunStateSnapshot;
15573
+ }
15574
+ });
15575
+ Object.defineProperty(exports, 'ɵgetReasoningHeaderLabel', {
15576
+ enumerable: true,
15577
+ get: function () {
15578
+ return _copilotkit_core.ɵgetReasoningHeaderLabel;
15579
+ }
15580
+ });
15729
15581
  Object.defineProperty(exports, 'ɵgetThreadsDrawerElementProps', {
15730
15582
  enumerable: true,
15731
15583
  get: function () {
@@ -15828,6 +15680,12 @@ Object.defineProperty(exports, 'ɵhitlRenderProps', {
15828
15680
  return _copilotkit_core.ɵhitlRenderProps;
15829
15681
  }
15830
15682
  });
15683
+ Object.defineProperty(exports, 'ɵimplementsConnect', {
15684
+ enumerable: true,
15685
+ get: function () {
15686
+ return _copilotkit_core.ɵimplementsConnect;
15687
+ }
15688
+ });
15831
15689
  Object.defineProperty(exports, 'ɵinitialKeyboardState', {
15832
15690
  enumerable: true,
15833
15691
  get: function () {
@@ -15852,12 +15710,30 @@ Object.defineProperty(exports, 'ɵinspectorShortcuts', {
15852
15710
  return _copilotkit_core.ɵinspectorShortcuts;
15853
15711
  }
15854
15712
  });
15713
+ Object.defineProperty(exports, 'ɵisContentPart', {
15714
+ enumerable: true,
15715
+ get: function () {
15716
+ return _copilotkit_core.ɵisContentPart;
15717
+ }
15718
+ });
15719
+ Object.defineProperty(exports, 'ɵisContentScrolledToBottom', {
15720
+ enumerable: true,
15721
+ get: function () {
15722
+ return _copilotkit_core.ɵisContentScrolledToBottom;
15723
+ }
15724
+ });
15855
15725
  Object.defineProperty(exports, 'ɵisCopilotKitFeature', {
15856
15726
  enumerable: true,
15857
15727
  get: function () {
15858
15728
  return _copilotkit_core.ɵisCopilotKitFeature;
15859
15729
  }
15860
15730
  });
15731
+ Object.defineProperty(exports, 'ɵisFocusVisible', {
15732
+ enumerable: true,
15733
+ get: function () {
15734
+ return _copilotkit_core.ɵisFocusVisible;
15735
+ }
15736
+ });
15861
15737
  Object.defineProperty(exports, 'ɵisHttpAgent', {
15862
15738
  enumerable: true,
15863
15739
  get: function () {
@@ -15882,6 +15758,12 @@ Object.defineProperty(exports, 'ɵisOpenGenerativeUIActive', {
15882
15758
  return _copilotkit_core.ɵisOpenGenerativeUIActive;
15883
15759
  }
15884
15760
  });
15761
+ Object.defineProperty(exports, 'ɵisOwnFeedbackThumb', {
15762
+ enumerable: true,
15763
+ get: function () {
15764
+ return _copilotkit_core.ɵisOwnFeedbackThumb;
15765
+ }
15766
+ });
15885
15767
  Object.defineProperty(exports, 'ɵisRetryableMemoryStatus', {
15886
15768
  enumerable: true,
15887
15769
  get: function () {
@@ -15978,6 +15860,12 @@ Object.defineProperty(exports, 'ɵnextSlashIndex', {
15978
15860
  return _copilotkit_core.ɵnextSlashIndex;
15979
15861
  }
15980
15862
  });
15863
+ Object.defineProperty(exports, 'ɵnextTabStop', {
15864
+ enumerable: true,
15865
+ get: function () {
15866
+ return _copilotkit_core.ɵnextTabStop;
15867
+ }
15868
+ });
15981
15869
  Object.defineProperty(exports, 'ɵnormalizeAutoScroll', {
15982
15870
  enumerable: true,
15983
15871
  get: function () {
@@ -15990,6 +15878,12 @@ Object.defineProperty(exports, 'ɵnormalizeToolCallStatus', {
15990
15878
  return _copilotkit_core.ɵnormalizeToolCallStatus;
15991
15879
  }
15992
15880
  });
15881
+ Object.defineProperty(exports, 'ɵnormalizeToolsMenu', {
15882
+ enumerable: true,
15883
+ get: function () {
15884
+ return _copilotkit_core.ɵnormalizeToolsMenu;
15885
+ }
15886
+ });
15993
15887
  Object.defineProperty(exports, 'ɵobservePhoenixEvent$', {
15994
15888
  enumerable: true,
15995
15889
  get: function () {
@@ -16092,6 +15986,12 @@ Object.defineProperty(exports, 'ɵrecordWorkTime', {
16092
15986
  return _copilotkit_core.ɵrecordWorkTime;
16093
15987
  }
16094
15988
  });
15989
+ Object.defineProperty(exports, 'ɵregisterFrontendTools', {
15990
+ enumerable: true,
15991
+ get: function () {
15992
+ return _copilotkit_core.ɵregisterFrontendTools;
15993
+ }
15994
+ });
16095
15995
  Object.defineProperty(exports, 'ɵreportProviderConfigDiagnostics', {
16096
15996
  enumerable: true,
16097
15997
  get: function () {
@@ -16116,6 +16016,12 @@ Object.defineProperty(exports, 'ɵresetMessageFeedbackCache', {
16116
16016
  return _copilotkit_core.ɵresetMessageFeedbackCache;
16117
16017
  }
16118
16018
  });
16019
+ Object.defineProperty(exports, 'ɵresolveA2UIActivation', {
16020
+ enumerable: true,
16021
+ get: function () {
16022
+ return _copilotkit_core.ɵresolveA2UIActivation;
16023
+ }
16024
+ });
16119
16025
  Object.defineProperty(exports, 'ɵresolveA2UIDebugExposure', {
16120
16026
  enumerable: true,
16121
16027
  get: function () {
@@ -16326,12 +16232,24 @@ Object.defineProperty(exports, 'ɵshouldShowMessageCursor', {
16326
16232
  return _copilotkit_core.ɵshouldShowMessageCursor;
16327
16233
  }
16328
16234
  });
16235
+ Object.defineProperty(exports, 'ɵshowsComposerDisclaimer', {
16236
+ enumerable: true,
16237
+ get: function () {
16238
+ return _copilotkit_core.ɵshowsComposerDisclaimer;
16239
+ }
16240
+ });
16329
16241
  Object.defineProperty(exports, 'ɵsnapshotAgentState', {
16330
16242
  enumerable: true,
16331
16243
  get: function () {
16332
16244
  return _copilotkit_core.ɵsnapshotAgentState;
16333
16245
  }
16334
16246
  });
16247
+ Object.defineProperty(exports, 'ɵstableArrayPropWarning', {
16248
+ enumerable: true,
16249
+ get: function () {
16250
+ return _copilotkit_core.ɵstableArrayPropWarning;
16251
+ }
16252
+ });
16335
16253
  Object.defineProperty(exports, 'ɵstopAgentWithFallback', {
16336
16254
  enumerable: true,
16337
16255
  get: function () {
@@ -16350,6 +16268,12 @@ Object.defineProperty(exports, 'ɵstringifyToolCallPayload', {
16350
16268
  return _copilotkit_core.ɵstringifyToolCallPayload;
16351
16269
  }
16352
16270
  });
16271
+ Object.defineProperty(exports, 'ɵsubscribeToAgentErrors', {
16272
+ enumerable: true,
16273
+ get: function () {
16274
+ return _copilotkit_core.ɵsubscribeToAgentErrors;
16275
+ }
16276
+ });
16353
16277
  Object.defineProperty(exports, 'ɵsubscribeToAgentSuggestions', {
16354
16278
  enumerable: true,
16355
16279
  get: function () {
@@ -16380,6 +16304,12 @@ Object.defineProperty(exports, 'ɵsurfaceHasRenderableContent', {
16380
16304
  return _copilotkit_core.ɵsurfaceHasRenderableContent;
16381
16305
  }
16382
16306
  });
16307
+ Object.defineProperty(exports, 'ɵsyncRecorderToMode', {
16308
+ enumerable: true,
16309
+ get: function () {
16310
+ return _copilotkit_core.ɵsyncRecorderToMode;
16311
+ }
16312
+ });
16383
16313
  Object.defineProperty(exports, 'ɵthreadAdapterEvents', {
16384
16314
  enumerable: true,
16385
16315
  get: function () {
@@ -16392,6 +16322,12 @@ Object.defineProperty(exports, 'ɵtoA2UIClientEvent', {
16392
16322
  return _copilotkit_core.ɵtoA2UIClientEvent;
16393
16323
  }
16394
16324
  });
16325
+ Object.defineProperty(exports, 'ɵtoDefaultToolCallStatus', {
16326
+ enumerable: true,
16327
+ get: function () {
16328
+ return _copilotkit_core.ɵtoDefaultToolCallStatus;
16329
+ }
16330
+ });
16395
16331
  Object.defineProperty(exports, 'ɵtoDrawerThread', {
16396
16332
  enumerable: true,
16397
16333
  get: function () {
@@ -16446,6 +16382,18 @@ Object.defineProperty(exports, 'ɵwaitForActiveRun', {
16446
16382
  return _copilotkit_core.ɵwaitForActiveRun;
16447
16383
  }
16448
16384
  });
16385
+ Object.defineProperty(exports, 'ɵwatchElementHeight', {
16386
+ enumerable: true,
16387
+ get: function () {
16388
+ return _copilotkit_core.ɵwatchElementHeight;
16389
+ }
16390
+ });
16391
+ Object.defineProperty(exports, 'ɵwatchElementWidth', {
16392
+ enumerable: true,
16393
+ get: function () {
16394
+ return _copilotkit_core.ɵwatchElementWidth;
16395
+ }
16396
+ });
16449
16397
  Object.defineProperty(exports, 'ɵwatchKeyboardState', {
16450
16398
  enumerable: true,
16451
16399
  get: function () {