@copilotkitnext/react 0.0.22-alpha.9 → 0.0.23

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.mjs CHANGED
@@ -1,24 +1,27 @@
1
- import * as React2 from 'react';
2
- import React2__default, { createContext, forwardRef, useRef, useEffect, useImperativeHandle, useMemo, useCallback, useState, useContext, useLayoutEffect, useReducer, useSyncExternalStore } from 'react';
3
- import { twMerge } from 'tailwind-merge';
4
- import { ArrowUp, Mic, X, Check, Plus, Copy, ThumbsUp, ThumbsDown, Volume2, RefreshCw, Edit, ChevronLeft, ChevronRight, Loader2, ChevronDown, ChevronRightIcon, Square, MessageCircle } from 'lucide-react';
5
- import { DEFAULT_AGENT_ID, randomUUID, partialJSONParse } from '@copilotkitnext/shared';
6
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
- import { Slot } from '@radix-ui/react-slot';
8
- import { cva } from 'class-variance-authority';
9
- import { clsx } from 'clsx';
10
- import * as TooltipPrimitive from '@radix-ui/react-tooltip';
11
- import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
12
- import 'katex/dist/katex.min.css';
13
- import { Streamdown } from 'streamdown';
14
- import { ToolCallStatus, CopilotKitCore } from '@copilotkitnext/core';
15
- import { z } from 'zod';
16
- import { createComponent } from '@lit-labs/react';
17
- import { defineWebInspector, WebInspectorElement, WEB_INSPECTOR_TAG } from '@copilotkitnext/web-inspector';
18
- import { useStickToBottom, StickToBottom, useStickToBottomContext } from 'use-stick-to-bottom';
19
- import { merge } from 'ts-deepmerge';
20
- import { AGUIConnectNotImplementedError } from '@ag-ui/client';
1
+ "use client";
21
2
 
3
+ // src/index.ts
4
+ export * from "@ag-ui/core";
5
+ export * from "@ag-ui/client";
6
+
7
+ // src/components/chat/CopilotChatInput.tsx
8
+ import {
9
+ useState as useState2,
10
+ useRef as useRef2,
11
+ useEffect as useEffect2,
12
+ useLayoutEffect,
13
+ forwardRef as forwardRef2,
14
+ useImperativeHandle as useImperativeHandle2,
15
+ useCallback,
16
+ useMemo as useMemo2
17
+ } from "react";
18
+ import { twMerge as twMerge3 } from "tailwind-merge";
19
+ import { Plus, Mic, ArrowUp, X, Check, Square } from "lucide-react";
20
+
21
+ // src/providers/CopilotChatConfigurationProvider.tsx
22
+ import { createContext, useContext, useMemo, useState } from "react";
23
+ import { DEFAULT_AGENT_ID, randomUUID } from "@copilotkitnext/shared";
24
+ import { jsx } from "react/jsx-runtime";
22
25
  var CopilotChatDefaultLabels = {
23
26
  chatInputPlaceholder: "Type a message...",
24
27
  chatInputToolbarStartTranscribeButtonLabel: "Transcribe",
@@ -91,9 +94,20 @@ var useCopilotChatConfiguration = () => {
91
94
  const configuration = useContext(CopilotChatConfiguration);
92
95
  return configuration;
93
96
  };
97
+
98
+ // src/components/ui/button.tsx
99
+ import { Slot } from "@radix-ui/react-slot";
100
+ import { cva } from "class-variance-authority";
101
+
102
+ // src/lib/utils.ts
103
+ import { clsx } from "clsx";
104
+ import { twMerge } from "tailwind-merge";
94
105
  function cn(...inputs) {
95
106
  return twMerge(clsx(inputs));
96
107
  }
108
+
109
+ // src/components/ui/button.tsx
110
+ import { jsx as jsx2 } from "react/jsx-runtime";
97
111
  var buttonVariants = cva(
98
112
  "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
99
113
  {
@@ -191,7 +205,7 @@ function Button({
191
205
  ...props
192
206
  }) {
193
207
  const Comp = asChild ? Slot : "button";
194
- return /* @__PURE__ */ jsx(
208
+ return /* @__PURE__ */ jsx2(
195
209
  Comp,
196
210
  {
197
211
  "data-slot": "button",
@@ -200,11 +214,15 @@ function Button({
200
214
  }
201
215
  );
202
216
  }
217
+
218
+ // src/components/ui/tooltip.tsx
219
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
220
+ import { jsx as jsx3, jsxs } from "react/jsx-runtime";
203
221
  function TooltipProvider({
204
222
  delayDuration = 0,
205
223
  ...props
206
224
  }) {
207
- return /* @__PURE__ */ jsx(
225
+ return /* @__PURE__ */ jsx3(
208
226
  TooltipPrimitive.Provider,
209
227
  {
210
228
  "data-slot": "tooltip-provider",
@@ -216,12 +234,12 @@ function TooltipProvider({
216
234
  function Tooltip({
217
235
  ...props
218
236
  }) {
219
- return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsx(TooltipPrimitive.Root, { "data-slot": "tooltip", ...props }) });
237
+ return /* @__PURE__ */ jsx3(TooltipProvider, { children: /* @__PURE__ */ jsx3(TooltipPrimitive.Root, { "data-slot": "tooltip", ...props }) });
220
238
  }
221
239
  function TooltipTrigger({
222
240
  ...props
223
241
  }) {
224
- return /* @__PURE__ */ jsx(TooltipPrimitive.Trigger, { "data-slot": "tooltip-trigger", ...props });
242
+ return /* @__PURE__ */ jsx3(TooltipPrimitive.Trigger, { "data-slot": "tooltip-trigger", ...props });
225
243
  }
226
244
  function TooltipContent({
227
245
  className,
@@ -229,7 +247,7 @@ function TooltipContent({
229
247
  children,
230
248
  ...props
231
249
  }) {
232
- return /* @__PURE__ */ jsx(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
250
+ return /* @__PURE__ */ jsx3(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
233
251
  TooltipPrimitive.Content,
234
252
  {
235
253
  "data-slot": "tooltip-content",
@@ -241,20 +259,25 @@ function TooltipContent({
241
259
  ...props,
242
260
  children: [
243
261
  children,
244
- /* @__PURE__ */ jsx(TooltipPrimitive.Arrow, { className: "bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })
262
+ /* @__PURE__ */ jsx3(TooltipPrimitive.Arrow, { className: "bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })
245
263
  ]
246
264
  }
247
265
  ) });
248
266
  }
267
+
268
+ // src/components/ui/dropdown-menu.tsx
269
+ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
270
+ import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react";
271
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
249
272
  function DropdownMenu({
250
273
  ...props
251
274
  }) {
252
- return /* @__PURE__ */ jsx(DropdownMenuPrimitive.Root, { "data-slot": "dropdown-menu", ...props });
275
+ return /* @__PURE__ */ jsx4(DropdownMenuPrimitive.Root, { "data-slot": "dropdown-menu", ...props });
253
276
  }
254
277
  function DropdownMenuTrigger({
255
278
  ...props
256
279
  }) {
257
- return /* @__PURE__ */ jsx(
280
+ return /* @__PURE__ */ jsx4(
258
281
  DropdownMenuPrimitive.Trigger,
259
282
  {
260
283
  "data-slot": "dropdown-menu-trigger",
@@ -267,7 +290,7 @@ function DropdownMenuContent({
267
290
  sideOffset = 4,
268
291
  ...props
269
292
  }) {
270
- return /* @__PURE__ */ jsx(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx(
293
+ return /* @__PURE__ */ jsx4(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx4(
271
294
  DropdownMenuPrimitive.Content,
272
295
  {
273
296
  "data-slot": "dropdown-menu-content",
@@ -286,7 +309,7 @@ function DropdownMenuItem({
286
309
  variant = "default",
287
310
  ...props
288
311
  }) {
289
- return /* @__PURE__ */ jsx(
312
+ return /* @__PURE__ */ jsx4(
290
313
  DropdownMenuPrimitive.Item,
291
314
  {
292
315
  "data-slot": "dropdown-menu-item",
@@ -304,7 +327,7 @@ function DropdownMenuSeparator({
304
327
  className,
305
328
  ...props
306
329
  }) {
307
- return /* @__PURE__ */ jsx(
330
+ return /* @__PURE__ */ jsx4(
308
331
  DropdownMenuPrimitive.Separator,
309
332
  {
310
333
  "data-slot": "dropdown-menu-separator",
@@ -316,7 +339,7 @@ function DropdownMenuSeparator({
316
339
  function DropdownMenuSub({
317
340
  ...props
318
341
  }) {
319
- return /* @__PURE__ */ jsx(DropdownMenuPrimitive.Sub, { "data-slot": "dropdown-menu-sub", ...props });
342
+ return /* @__PURE__ */ jsx4(DropdownMenuPrimitive.Sub, { "data-slot": "dropdown-menu-sub", ...props });
320
343
  }
321
344
  function DropdownMenuSubTrigger({
322
345
  className,
@@ -324,7 +347,7 @@ function DropdownMenuSubTrigger({
324
347
  children,
325
348
  ...props
326
349
  }) {
327
- return /* @__PURE__ */ jsxs(
350
+ return /* @__PURE__ */ jsxs2(
328
351
  DropdownMenuPrimitive.SubTrigger,
329
352
  {
330
353
  "data-slot": "dropdown-menu-sub-trigger",
@@ -336,7 +359,7 @@ function DropdownMenuSubTrigger({
336
359
  ...props,
337
360
  children: [
338
361
  children,
339
- /* @__PURE__ */ jsx(ChevronRightIcon, { className: "ml-auto size-4" })
362
+ /* @__PURE__ */ jsx4(ChevronRightIcon, { className: "ml-auto size-4" })
340
363
  ]
341
364
  }
342
365
  );
@@ -345,7 +368,7 @@ function DropdownMenuSubContent({
345
368
  className,
346
369
  ...props
347
370
  }) {
348
- return /* @__PURE__ */ jsx(
371
+ return /* @__PURE__ */ jsx4(
349
372
  DropdownMenuPrimitive.SubContent,
350
373
  {
351
374
  "data-slot": "dropdown-menu-sub-content",
@@ -357,6 +380,11 @@ function DropdownMenuSubContent({
357
380
  }
358
381
  );
359
382
  }
383
+
384
+ // src/components/chat/CopilotChatAudioRecorder.tsx
385
+ import { useRef, useEffect, useImperativeHandle, forwardRef } from "react";
386
+ import { twMerge as twMerge2 } from "tailwind-merge";
387
+ import { jsx as jsx5 } from "react/jsx-runtime";
360
388
  var AudioRecorderError = class extends Error {
361
389
  constructor(message) {
362
390
  super(message);
@@ -443,7 +471,7 @@ var CopilotChatAudioRecorder = forwardRef((props, ref) => {
443
471
  }),
444
472
  []
445
473
  );
446
- return /* @__PURE__ */ jsx("div", { className: twMerge("h-[44px] w-full px-5", className), ...divProps, children: /* @__PURE__ */ jsx(
474
+ return /* @__PURE__ */ jsx5("div", { className: twMerge2("h-[44px] w-full px-5", className), ...divProps, children: /* @__PURE__ */ jsx5(
447
475
  "canvas",
448
476
  {
449
477
  ref: canvasRef,
@@ -453,25 +481,63 @@ var CopilotChatAudioRecorder = forwardRef((props, ref) => {
453
481
  ) });
454
482
  });
455
483
  CopilotChatAudioRecorder.displayName = "WebAudioRecorder";
456
- function renderSlot(slot, DefaultComponent, props) {
484
+
485
+ // src/lib/slots.tsx
486
+ import React2 from "react";
487
+ function shallowEqual(obj1, obj2) {
488
+ const keys1 = Object.keys(obj1);
489
+ const keys2 = Object.keys(obj2);
490
+ if (keys1.length !== keys2.length) return false;
491
+ for (const key of keys1) {
492
+ if (obj1[key] !== obj2[key]) return false;
493
+ }
494
+ return true;
495
+ }
496
+ function renderSlotElement(slot, DefaultComponent, props) {
457
497
  if (typeof slot === "string") {
458
- return React2__default.createElement(DefaultComponent, {
498
+ return React2.createElement(DefaultComponent, {
459
499
  ...props,
460
500
  className: slot
461
501
  });
462
502
  }
463
503
  if (typeof slot === "function") {
464
- const Comp = slot;
465
- return React2__default.createElement(Comp, props);
504
+ return React2.createElement(slot, props);
466
505
  }
467
- if (slot && typeof slot === "object" && !React2__default.isValidElement(slot)) {
468
- return React2__default.createElement(DefaultComponent, {
506
+ if (slot && typeof slot === "object" && !React2.isValidElement(slot)) {
507
+ return React2.createElement(DefaultComponent, {
469
508
  ...props,
470
509
  ...slot
471
510
  });
472
511
  }
473
- return React2__default.createElement(DefaultComponent, props);
512
+ return React2.createElement(DefaultComponent, props);
474
513
  }
514
+ var MemoizedSlotWrapper = React2.memo(
515
+ React2.forwardRef(function MemoizedSlotWrapper2(props, ref) {
516
+ const { $slot, $component, ...rest } = props;
517
+ const propsWithRef = ref !== null ? { ...rest, ref } : rest;
518
+ return renderSlotElement($slot, $component, propsWithRef);
519
+ }),
520
+ (prev, next) => {
521
+ if (prev.$slot !== next.$slot) return false;
522
+ if (prev.$component !== next.$component) return false;
523
+ const { $slot: _ps, $component: _pc, ...prevRest } = prev;
524
+ const { $slot: _ns, $component: _nc, ...nextRest } = next;
525
+ return shallowEqual(
526
+ prevRest,
527
+ nextRest
528
+ );
529
+ }
530
+ );
531
+ function renderSlot(slot, DefaultComponent, props) {
532
+ return React2.createElement(MemoizedSlotWrapper, {
533
+ ...props,
534
+ $slot: slot,
535
+ $component: DefaultComponent
536
+ });
537
+ }
538
+
539
+ // src/components/chat/CopilotChatInput.tsx
540
+ import { Fragment, jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
475
541
  var SLASH_MENU_MAX_VISIBLE_ITEMS = 5;
476
542
  var SLASH_MENU_ITEM_HEIGHT_PX = 40;
477
543
  function CopilotChatInput({
@@ -499,36 +565,36 @@ function CopilotChatInput({
499
565
  ...props
500
566
  }) {
501
567
  const isControlled = value !== void 0;
502
- const [internalValue, setInternalValue] = useState(() => value ?? "");
503
- useEffect(() => {
568
+ const [internalValue, setInternalValue] = useState2(() => value ?? "");
569
+ useEffect2(() => {
504
570
  if (!isControlled && value !== void 0) {
505
571
  setInternalValue(value);
506
572
  }
507
573
  }, [isControlled, value]);
508
574
  const resolvedValue = isControlled ? value ?? "" : internalValue;
509
- const [layout, setLayout] = useState("compact");
510
- const ignoreResizeRef = useRef(false);
511
- const resizeEvaluationRafRef = useRef(null);
575
+ const [layout, setLayout] = useState2("compact");
576
+ const ignoreResizeRef = useRef2(false);
577
+ const resizeEvaluationRafRef = useRef2(null);
512
578
  const isExpanded = mode === "input" && layout === "expanded";
513
- const [commandQuery, setCommandQuery] = useState(null);
514
- const [slashHighlightIndex, setSlashHighlightIndex] = useState(0);
515
- const inputRef = useRef(null);
516
- const gridRef = useRef(null);
517
- const addButtonContainerRef = useRef(null);
518
- const actionsContainerRef = useRef(null);
519
- const audioRecorderRef = useRef(null);
520
- const slashMenuRef = useRef(null);
579
+ const [commandQuery, setCommandQuery] = useState2(null);
580
+ const [slashHighlightIndex, setSlashHighlightIndex] = useState2(0);
581
+ const inputRef = useRef2(null);
582
+ const gridRef = useRef2(null);
583
+ const addButtonContainerRef = useRef2(null);
584
+ const actionsContainerRef = useRef2(null);
585
+ const audioRecorderRef = useRef2(null);
586
+ const slashMenuRef = useRef2(null);
521
587
  const config = useCopilotChatConfiguration();
522
588
  const labels = config?.labels ?? CopilotChatDefaultLabels;
523
- const previousModalStateRef = useRef(void 0);
524
- const measurementCanvasRef = useRef(null);
525
- const measurementsRef = useRef({
589
+ const previousModalStateRef = useRef2(void 0);
590
+ const measurementCanvasRef = useRef2(null);
591
+ const measurementsRef = useRef2({
526
592
  singleLineHeight: 0,
527
593
  maxHeight: 0,
528
594
  paddingLeft: 0,
529
595
  paddingRight: 0
530
596
  });
531
- const commandItems = useMemo(() => {
597
+ const commandItems = useMemo2(() => {
532
598
  const entries = [];
533
599
  const seen = /* @__PURE__ */ new Set();
534
600
  const pushItem = (item) => {
@@ -559,7 +625,7 @@ function CopilotChatInput({
559
625
  }
560
626
  return entries;
561
627
  }, [labels.chatInputToolbarAddButtonLabel, onAddFile, toolsMenu]);
562
- const filteredCommands = useMemo(() => {
628
+ const filteredCommands = useMemo2(() => {
563
629
  if (commandQuery === null) {
564
630
  return [];
565
631
  }
@@ -582,7 +648,7 @@ function CopilotChatInput({
582
648
  }
583
649
  return [...startsWith, ...contains];
584
650
  }, [commandItems, commandQuery]);
585
- useEffect(() => {
651
+ useEffect2(() => {
586
652
  if (!autoFocus) {
587
653
  previousModalStateRef.current = config?.isModalOpen;
588
654
  return;
@@ -592,19 +658,19 @@ function CopilotChatInput({
592
658
  }
593
659
  previousModalStateRef.current = config?.isModalOpen;
594
660
  }, [config?.isModalOpen, autoFocus]);
595
- useEffect(() => {
661
+ useEffect2(() => {
596
662
  if (commandItems.length === 0 && commandQuery !== null) {
597
663
  setCommandQuery(null);
598
664
  }
599
665
  }, [commandItems.length, commandQuery]);
600
- const previousCommandQueryRef = useRef(null);
601
- useEffect(() => {
666
+ const previousCommandQueryRef = useRef2(null);
667
+ useEffect2(() => {
602
668
  if (commandQuery !== null && commandQuery !== previousCommandQueryRef.current && filteredCommands.length > 0) {
603
669
  setSlashHighlightIndex(0);
604
670
  }
605
671
  previousCommandQueryRef.current = commandQuery;
606
672
  }, [commandQuery, filteredCommands.length]);
607
- useEffect(() => {
673
+ useEffect2(() => {
608
674
  if (commandQuery === null) {
609
675
  setSlashHighlightIndex(0);
610
676
  return;
@@ -615,7 +681,7 @@ function CopilotChatInput({
615
681
  setSlashHighlightIndex(0);
616
682
  }
617
683
  }, [commandQuery, filteredCommands, slashHighlightIndex]);
618
- useEffect(() => {
684
+ useEffect2(() => {
619
685
  const recorder = audioRecorderRef.current;
620
686
  if (!recorder) {
621
687
  return;
@@ -628,7 +694,7 @@ function CopilotChatInput({
628
694
  }
629
695
  }
630
696
  }, [mode]);
631
- useEffect(() => {
697
+ useEffect2(() => {
632
698
  if (mode !== "input") {
633
699
  setLayout("compact");
634
700
  setCommandQuery(null);
@@ -650,7 +716,7 @@ function CopilotChatInput({
650
716
  },
651
717
  [commandItems.length]
652
718
  );
653
- useEffect(() => {
719
+ useEffect2(() => {
654
720
  updateSlashState(resolvedValue);
655
721
  }, [resolvedValue, updateSlashState]);
656
722
  const handleChange = (e) => {
@@ -757,7 +823,7 @@ function CopilotChatInput({
757
823
  onChange: handleChange,
758
824
  onKeyDown: handleKeyDown,
759
825
  autoFocus,
760
- className: twMerge(
826
+ className: twMerge3(
761
827
  "w-full py-3",
762
828
  isExpanded ? "px-5" : "pr-5"
763
829
  )
@@ -778,7 +844,7 @@ function CopilotChatInput({
778
844
  const BoundSendButton = renderSlot(sendButton, CopilotChatInput.SendButton, {
779
845
  onClick: handleSendButtonClick,
780
846
  disabled: isProcessing ? !canStop : !canSend,
781
- children: isProcessing && canStop ? /* @__PURE__ */ jsx(Square, { className: "size-[18px] fill-current" }) : void 0
847
+ children: isProcessing && canStop ? /* @__PURE__ */ jsx6(Square, { className: "size-[18px] fill-current" }) : void 0
782
848
  });
783
849
  const BoundStartTranscribeButton = renderSlot(startTranscribeButton, CopilotChatInput.StartTranscribeButton, {
784
850
  onClick: onStartTranscribe
@@ -814,7 +880,7 @@ function CopilotChatInput({
814
880
  toolsMenu,
815
881
  autoFocus
816
882
  };
817
- return /* @__PURE__ */ jsx(Fragment, { children: children(childProps) });
883
+ return /* @__PURE__ */ jsx6(Fragment, { children: children(childProps) });
818
884
  }
819
885
  const handleContainerClick = (e) => {
820
886
  const target = e.target;
@@ -953,7 +1019,7 @@ function CopilotChatInput({
953
1019
  useLayoutEffect(() => {
954
1020
  evaluateLayout();
955
1021
  }, [evaluateLayout]);
956
- useEffect(() => {
1022
+ useEffect2(() => {
957
1023
  if (typeof ResizeObserver === "undefined") {
958
1024
  return;
959
1025
  }
@@ -997,7 +1063,7 @@ function CopilotChatInput({
997
1063
  };
998
1064
  }, [evaluateLayout]);
999
1065
  const slashMenuVisible = commandQuery !== null && commandItems.length > 0;
1000
- useEffect(() => {
1066
+ useEffect2(() => {
1001
1067
  if (!slashMenuVisible || slashHighlightIndex < 0) {
1002
1068
  return;
1003
1069
  }
@@ -1006,7 +1072,7 @@ function CopilotChatInput({
1006
1072
  );
1007
1073
  active?.scrollIntoView({ block: "nearest" });
1008
1074
  }, [slashMenuVisible, slashHighlightIndex]);
1009
- const slashMenu = slashMenuVisible ? /* @__PURE__ */ jsx(
1075
+ const slashMenu = slashMenuVisible ? /* @__PURE__ */ jsx6(
1010
1076
  "div",
1011
1077
  {
1012
1078
  "data-testid": "copilot-slash-menu",
@@ -1015,9 +1081,9 @@ function CopilotChatInput({
1015
1081
  ref: slashMenuRef,
1016
1082
  className: "absolute bottom-full left-0 right-0 z-30 mb-2 max-h-64 overflow-y-auto rounded-lg border border-border bg-white shadow-lg dark:border-[#3a3a3a] dark:bg-[#1f1f1f]",
1017
1083
  style: { maxHeight: `${SLASH_MENU_MAX_VISIBLE_ITEMS * SLASH_MENU_ITEM_HEIGHT_PX}px` },
1018
- children: filteredCommands.length === 0 ? /* @__PURE__ */ jsx("div", { className: "px-3 py-2 text-sm text-muted-foreground", children: "No commands found" }) : filteredCommands.map((item, index) => {
1084
+ children: filteredCommands.length === 0 ? /* @__PURE__ */ jsx6("div", { className: "px-3 py-2 text-sm text-muted-foreground", children: "No commands found" }) : filteredCommands.map((item, index) => {
1019
1085
  const isActive = index === slashHighlightIndex;
1020
- return /* @__PURE__ */ jsx(
1086
+ return /* @__PURE__ */ jsx6(
1021
1087
  "button",
1022
1088
  {
1023
1089
  type: "button",
@@ -1025,7 +1091,7 @@ function CopilotChatInput({
1025
1091
  "aria-selected": isActive,
1026
1092
  "data-active": isActive ? "true" : void 0,
1027
1093
  "data-slash-index": index,
1028
- className: twMerge(
1094
+ className: twMerge3(
1029
1095
  "w-full px-3 py-2 text-left text-sm transition-colors",
1030
1096
  "hover:bg-muted dark:hover:bg-[#2f2f2f]",
1031
1097
  isActive ? "bg-muted dark:bg-[#2f2f2f]" : "bg-transparent"
@@ -1042,10 +1108,10 @@ function CopilotChatInput({
1042
1108
  })
1043
1109
  }
1044
1110
  ) : null;
1045
- return /* @__PURE__ */ jsx(
1111
+ return /* @__PURE__ */ jsx6(
1046
1112
  "div",
1047
1113
  {
1048
- className: twMerge(
1114
+ className: twMerge3(
1049
1115
  // Layout
1050
1116
  "flex w-full flex-col items-center justify-center",
1051
1117
  // Interaction
@@ -1061,21 +1127,21 @@ function CopilotChatInput({
1061
1127
  onClick: handleContainerClick,
1062
1128
  ...props,
1063
1129
  "data-layout": isExpanded ? "expanded" : "compact",
1064
- children: /* @__PURE__ */ jsxs(
1130
+ children: /* @__PURE__ */ jsxs3(
1065
1131
  "div",
1066
1132
  {
1067
1133
  ref: gridRef,
1068
- className: twMerge(
1134
+ className: twMerge3(
1069
1135
  "grid w-full gap-x-3 gap-y-3 px-3 py-2",
1070
1136
  isExpanded ? "grid-cols-[auto_minmax(0,1fr)_auto] grid-rows-[auto_auto]" : "grid-cols-[auto_minmax(0,1fr)_auto] items-center"
1071
1137
  ),
1072
1138
  "data-layout": isExpanded ? "expanded" : "compact",
1073
1139
  children: [
1074
- /* @__PURE__ */ jsx(
1140
+ /* @__PURE__ */ jsx6(
1075
1141
  "div",
1076
1142
  {
1077
1143
  ref: addButtonContainerRef,
1078
- className: twMerge(
1144
+ className: twMerge3(
1079
1145
  "flex items-center",
1080
1146
  isExpanded ? "row-start-2" : "row-start-1",
1081
1147
  "col-start-1"
@@ -1083,31 +1149,31 @@ function CopilotChatInput({
1083
1149
  children: BoundAddMenuButton
1084
1150
  }
1085
1151
  ),
1086
- /* @__PURE__ */ jsx(
1152
+ /* @__PURE__ */ jsx6(
1087
1153
  "div",
1088
1154
  {
1089
- className: twMerge(
1155
+ className: twMerge3(
1090
1156
  "relative flex min-w-0 flex-col",
1091
1157
  isExpanded ? "col-span-3 row-start-1" : "col-start-2 row-start-1"
1092
1158
  ),
1093
- children: mode === "transcribe" ? BoundAudioRecorder : /* @__PURE__ */ jsxs(Fragment, { children: [
1159
+ children: mode === "transcribe" ? BoundAudioRecorder : /* @__PURE__ */ jsxs3(Fragment, { children: [
1094
1160
  BoundTextArea,
1095
1161
  slashMenu
1096
1162
  ] })
1097
1163
  }
1098
1164
  ),
1099
- /* @__PURE__ */ jsx(
1165
+ /* @__PURE__ */ jsx6(
1100
1166
  "div",
1101
1167
  {
1102
1168
  ref: actionsContainerRef,
1103
- className: twMerge(
1169
+ className: twMerge3(
1104
1170
  "flex items-center justify-end gap-2",
1105
1171
  isExpanded ? "col-start-3 row-start-2" : "col-start-3 row-start-1"
1106
1172
  ),
1107
- children: mode === "transcribe" ? /* @__PURE__ */ jsxs(Fragment, { children: [
1173
+ children: mode === "transcribe" ? /* @__PURE__ */ jsxs3(Fragment, { children: [
1108
1174
  onCancelTranscribe && BoundCancelTranscribeButton,
1109
1175
  onFinishTranscribe && BoundFinishTranscribeButton
1110
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1176
+ ] }) : /* @__PURE__ */ jsxs3(Fragment, { children: [
1111
1177
  onStartTranscribe && BoundStartTranscribeButton,
1112
1178
  BoundSendButton
1113
1179
  ] })
@@ -1120,7 +1186,7 @@ function CopilotChatInput({
1120
1186
  );
1121
1187
  }
1122
1188
  ((CopilotChatInput2) => {
1123
- CopilotChatInput2.SendButton = ({ className, children, ...props }) => /* @__PURE__ */ jsx("div", { className: "mr-[10px]", children: /* @__PURE__ */ jsx(
1189
+ CopilotChatInput2.SendButton = ({ className, children, ...props }) => /* @__PURE__ */ jsx6("div", { className: "mr-[10px]", children: /* @__PURE__ */ jsx6(
1124
1190
  Button,
1125
1191
  {
1126
1192
  type: "button",
@@ -1128,49 +1194,49 @@ function CopilotChatInput({
1128
1194
  size: "chatInputToolbarIcon",
1129
1195
  className,
1130
1196
  ...props,
1131
- children: children ?? /* @__PURE__ */ jsx(ArrowUp, { className: "size-[18px]" })
1197
+ children: children ?? /* @__PURE__ */ jsx6(ArrowUp, { className: "size-[18px]" })
1132
1198
  }
1133
1199
  ) });
1134
1200
  CopilotChatInput2.ToolbarButton = ({ icon, labelKey, defaultClassName, className, ...props }) => {
1135
1201
  const config = useCopilotChatConfiguration();
1136
1202
  const labels = config?.labels ?? CopilotChatDefaultLabels;
1137
- return /* @__PURE__ */ jsxs(Tooltip, { children: [
1138
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
1203
+ return /* @__PURE__ */ jsxs3(Tooltip, { children: [
1204
+ /* @__PURE__ */ jsx6(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx6(
1139
1205
  Button,
1140
1206
  {
1141
1207
  type: "button",
1142
1208
  variant: "chatInputToolbarSecondary",
1143
1209
  size: "chatInputToolbarIcon",
1144
- className: twMerge(defaultClassName, className),
1210
+ className: twMerge3(defaultClassName, className),
1145
1211
  ...props,
1146
1212
  children: icon
1147
1213
  }
1148
1214
  ) }),
1149
- /* @__PURE__ */ jsx(TooltipContent, { side: "bottom", children: /* @__PURE__ */ jsx("p", { children: labels[labelKey] }) })
1215
+ /* @__PURE__ */ jsx6(TooltipContent, { side: "bottom", children: /* @__PURE__ */ jsx6("p", { children: labels[labelKey] }) })
1150
1216
  ] });
1151
1217
  };
1152
- CopilotChatInput2.StartTranscribeButton = (props) => /* @__PURE__ */ jsx(
1218
+ CopilotChatInput2.StartTranscribeButton = (props) => /* @__PURE__ */ jsx6(
1153
1219
  CopilotChatInput2.ToolbarButton,
1154
1220
  {
1155
- icon: /* @__PURE__ */ jsx(Mic, { className: "size-[18px]" }),
1221
+ icon: /* @__PURE__ */ jsx6(Mic, { className: "size-[18px]" }),
1156
1222
  labelKey: "chatInputToolbarStartTranscribeButtonLabel",
1157
1223
  defaultClassName: "mr-2",
1158
1224
  ...props
1159
1225
  }
1160
1226
  );
1161
- CopilotChatInput2.CancelTranscribeButton = (props) => /* @__PURE__ */ jsx(
1227
+ CopilotChatInput2.CancelTranscribeButton = (props) => /* @__PURE__ */ jsx6(
1162
1228
  CopilotChatInput2.ToolbarButton,
1163
1229
  {
1164
- icon: /* @__PURE__ */ jsx(X, { className: "size-[18px]" }),
1230
+ icon: /* @__PURE__ */ jsx6(X, { className: "size-[18px]" }),
1165
1231
  labelKey: "chatInputToolbarCancelTranscribeButtonLabel",
1166
1232
  defaultClassName: "mr-2",
1167
1233
  ...props
1168
1234
  }
1169
1235
  );
1170
- CopilotChatInput2.FinishTranscribeButton = (props) => /* @__PURE__ */ jsx(
1236
+ CopilotChatInput2.FinishTranscribeButton = (props) => /* @__PURE__ */ jsx6(
1171
1237
  CopilotChatInput2.ToolbarButton,
1172
1238
  {
1173
- icon: /* @__PURE__ */ jsx(Check, { className: "size-[18px]" }),
1239
+ icon: /* @__PURE__ */ jsx6(Check, { className: "size-[18px]" }),
1174
1240
  labelKey: "chatInputToolbarFinishTranscribeButtonLabel",
1175
1241
  defaultClassName: "mr-[10px]",
1176
1242
  ...props
@@ -1179,7 +1245,7 @@ function CopilotChatInput({
1179
1245
  CopilotChatInput2.AddMenuButton = ({ className, toolsMenu, onAddFile, disabled, ...props }) => {
1180
1246
  const config = useCopilotChatConfiguration();
1181
1247
  const labels = config?.labels ?? CopilotChatDefaultLabels;
1182
- const menuItems = useMemo(() => {
1248
+ const menuItems = useMemo2(() => {
1183
1249
  const items = [];
1184
1250
  if (onAddFile) {
1185
1251
  items.push({
@@ -1210,48 +1276,48 @@ function CopilotChatInput({
1210
1276
  const renderMenuItems = useCallback(
1211
1277
  (items) => items.map((item, index) => {
1212
1278
  if (item === "-") {
1213
- return /* @__PURE__ */ jsx(DropdownMenuSeparator, {}, `separator-${index}`);
1279
+ return /* @__PURE__ */ jsx6(DropdownMenuSeparator, {}, `separator-${index}`);
1214
1280
  }
1215
1281
  if (item.items && item.items.length > 0) {
1216
- return /* @__PURE__ */ jsxs(DropdownMenuSub, { children: [
1217
- /* @__PURE__ */ jsx(DropdownMenuSubTrigger, { children: item.label }),
1218
- /* @__PURE__ */ jsx(DropdownMenuSubContent, { children: renderMenuItems(item.items) })
1282
+ return /* @__PURE__ */ jsxs3(DropdownMenuSub, { children: [
1283
+ /* @__PURE__ */ jsx6(DropdownMenuSubTrigger, { children: item.label }),
1284
+ /* @__PURE__ */ jsx6(DropdownMenuSubContent, { children: renderMenuItems(item.items) })
1219
1285
  ] }, `group-${index}`);
1220
1286
  }
1221
- return /* @__PURE__ */ jsx(DropdownMenuItem, { onClick: item.action, children: item.label }, `item-${index}`);
1287
+ return /* @__PURE__ */ jsx6(DropdownMenuItem, { onClick: item.action, children: item.label }, `item-${index}`);
1222
1288
  }),
1223
1289
  []
1224
1290
  );
1225
1291
  const hasMenuItems = menuItems.length > 0;
1226
1292
  const isDisabled = disabled || !hasMenuItems;
1227
- return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
1228
- /* @__PURE__ */ jsxs(Tooltip, { children: [
1229
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
1293
+ return /* @__PURE__ */ jsxs3(DropdownMenu, { children: [
1294
+ /* @__PURE__ */ jsxs3(Tooltip, { children: [
1295
+ /* @__PURE__ */ jsx6(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx6(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx6(
1230
1296
  Button,
1231
1297
  {
1232
1298
  type: "button",
1233
1299
  variant: "chatInputToolbarSecondary",
1234
1300
  size: "chatInputToolbarIcon",
1235
- className: twMerge("ml-1", className),
1301
+ className: twMerge3("ml-1", className),
1236
1302
  disabled: isDisabled,
1237
1303
  ...props,
1238
- children: /* @__PURE__ */ jsx(Plus, { className: "size-[20px]" })
1304
+ children: /* @__PURE__ */ jsx6(Plus, { className: "size-[20px]" })
1239
1305
  }
1240
1306
  ) }) }),
1241
- /* @__PURE__ */ jsx(TooltipContent, { side: "bottom", children: /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-1 text-xs font-medium", children: [
1242
- /* @__PURE__ */ jsx("span", { children: "Add files and more" }),
1243
- /* @__PURE__ */ jsx("code", { className: "rounded bg-[#4a4a4a] px-1 py-[1px] font-mono text-[11px] text-white dark:bg-[#e0e0e0] dark:text-black", children: "/" })
1307
+ /* @__PURE__ */ jsx6(TooltipContent, { side: "bottom", children: /* @__PURE__ */ jsxs3("p", { className: "flex items-center gap-1 text-xs font-medium", children: [
1308
+ /* @__PURE__ */ jsx6("span", { children: "Add files and more" }),
1309
+ /* @__PURE__ */ jsx6("code", { className: "rounded bg-[#4a4a4a] px-1 py-[1px] font-mono text-[11px] text-white dark:bg-[#e0e0e0] dark:text-black", children: "/" })
1244
1310
  ] }) })
1245
1311
  ] }),
1246
- hasMenuItems && /* @__PURE__ */ jsx(DropdownMenuContent, { side: "top", align: "start", children: renderMenuItems(menuItems) })
1312
+ hasMenuItems && /* @__PURE__ */ jsx6(DropdownMenuContent, { side: "top", align: "start", children: renderMenuItems(menuItems) })
1247
1313
  ] });
1248
1314
  };
1249
- CopilotChatInput2.TextArea = forwardRef(function TextArea2({ style, className, autoFocus, ...props }, ref) {
1250
- const internalTextareaRef = useRef(null);
1315
+ CopilotChatInput2.TextArea = forwardRef2(function TextArea2({ style, className, autoFocus, ...props }, ref) {
1316
+ const internalTextareaRef = useRef2(null);
1251
1317
  const config = useCopilotChatConfiguration();
1252
1318
  const labels = config?.labels ?? CopilotChatDefaultLabels;
1253
- useImperativeHandle(ref, () => internalTextareaRef.current);
1254
- useEffect(() => {
1319
+ useImperativeHandle2(ref, () => internalTextareaRef.current);
1320
+ useEffect2(() => {
1255
1321
  const textarea = internalTextareaRef.current;
1256
1322
  if (!textarea) return;
1257
1323
  const handleFocus = () => {
@@ -1262,12 +1328,12 @@ function CopilotChatInput({
1262
1328
  textarea.addEventListener("focus", handleFocus);
1263
1329
  return () => textarea.removeEventListener("focus", handleFocus);
1264
1330
  }, []);
1265
- useEffect(() => {
1331
+ useEffect2(() => {
1266
1332
  if (autoFocus) {
1267
1333
  internalTextareaRef.current?.focus();
1268
1334
  }
1269
1335
  }, [autoFocus]);
1270
- return /* @__PURE__ */ jsx(
1336
+ return /* @__PURE__ */ jsx6(
1271
1337
  "textarea",
1272
1338
  {
1273
1339
  ref: internalTextareaRef,
@@ -1278,7 +1344,7 @@ function CopilotChatInput({
1278
1344
  ...style
1279
1345
  },
1280
1346
  placeholder: labels.chatInputPlaceholder,
1281
- className: twMerge(
1347
+ className: twMerge3(
1282
1348
  "bg-transparent outline-none antialiased font-regular leading-relaxed text-[16px] placeholder:text-[#00000077] dark:placeholder:text-[#fffc]",
1283
1349
  className
1284
1350
  ),
@@ -1296,6 +1362,39 @@ CopilotChatInput.CancelTranscribeButton.displayName = "CopilotChatInput.CancelTr
1296
1362
  CopilotChatInput.FinishTranscribeButton.displayName = "CopilotChatInput.FinishTranscribeButton";
1297
1363
  CopilotChatInput.AddMenuButton.displayName = "CopilotChatInput.AddMenuButton";
1298
1364
  var CopilotChatInput_default = CopilotChatInput;
1365
+
1366
+ // src/components/chat/CopilotChatAssistantMessage.tsx
1367
+ import { useState as useState6 } from "react";
1368
+ import {
1369
+ Copy,
1370
+ Check as Check2,
1371
+ ThumbsUp,
1372
+ ThumbsDown,
1373
+ Volume2,
1374
+ RefreshCw
1375
+ } from "lucide-react";
1376
+ import { twMerge as twMerge4 } from "tailwind-merge";
1377
+ import "katex/dist/katex.min.css";
1378
+ import { Streamdown } from "streamdown";
1379
+
1380
+ // src/hooks/use-render-tool-call.tsx
1381
+ import React6, { useCallback as useCallback2, useEffect as useEffect5, useMemo as useMemo4, useState as useState4, useSyncExternalStore } from "react";
1382
+ import { ToolCallStatus } from "@copilotkitnext/core";
1383
+
1384
+ // src/providers/CopilotKitProvider.tsx
1385
+ import {
1386
+ createContext as createContext2,
1387
+ useContext as useContext2,
1388
+ useMemo as useMemo3,
1389
+ useEffect as useEffect4,
1390
+ useReducer,
1391
+ useRef as useRef4,
1392
+ useState as useState3
1393
+ } from "react";
1394
+ import { z } from "zod";
1395
+
1396
+ // src/lib/react-core.ts
1397
+ import { CopilotKitCore } from "@copilotkitnext/core";
1299
1398
  var CopilotKitCoreReact = class extends CopilotKitCore {
1300
1399
  _renderToolCalls = [];
1301
1400
  _renderCustomMessages = [];
@@ -1334,26 +1433,33 @@ var CopilotKitCoreReact = class extends CopilotKitCore {
1334
1433
  subscribe(subscriber) {
1335
1434
  return super.subscribe(subscriber);
1336
1435
  }
1337
- unsubscribe(subscriber) {
1338
- super.unsubscribe(subscriber);
1339
- }
1340
1436
  };
1437
+
1438
+ // src/components/CopilotKitInspector.tsx
1439
+ import * as React4 from "react";
1440
+ import { createComponent } from "@lit-labs/react";
1441
+ import {
1442
+ WEB_INSPECTOR_TAG,
1443
+ WebInspectorElement,
1444
+ defineWebInspector
1445
+ } from "@copilotkitnext/web-inspector";
1446
+ import { jsx as jsx7 } from "react/jsx-runtime";
1341
1447
  defineWebInspector();
1342
1448
  var CopilotKitInspectorBase = createComponent({
1343
1449
  tagName: WEB_INSPECTOR_TAG,
1344
1450
  elementClass: WebInspectorElement,
1345
- react: React2
1451
+ react: React4
1346
1452
  });
1347
- var CopilotKitInspector = React2.forwardRef(
1453
+ var CopilotKitInspector = React4.forwardRef(
1348
1454
  ({ core, ...rest }, ref) => {
1349
- const innerRef = React2.useRef(null);
1350
- React2.useImperativeHandle(ref, () => innerRef.current, []);
1351
- React2.useEffect(() => {
1455
+ const innerRef = React4.useRef(null);
1456
+ React4.useImperativeHandle(ref, () => innerRef.current, []);
1457
+ React4.useEffect(() => {
1352
1458
  if (innerRef.current) {
1353
1459
  innerRef.current.core = core ?? null;
1354
1460
  }
1355
1461
  }, [core]);
1356
- return /* @__PURE__ */ jsx(
1462
+ return /* @__PURE__ */ jsx7(
1357
1463
  CopilotKitInspectorBase,
1358
1464
  {
1359
1465
  ...rest,
@@ -1363,14 +1469,17 @@ var CopilotKitInspector = React2.forwardRef(
1363
1469
  }
1364
1470
  );
1365
1471
  CopilotKitInspector.displayName = "CopilotKitInspector";
1366
- var CopilotKitContext = createContext({
1472
+
1473
+ // src/providers/CopilotKitProvider.tsx
1474
+ import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
1475
+ var CopilotKitContext = createContext2({
1367
1476
  copilotkit: null
1368
1477
  });
1369
1478
  function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
1370
- const empty = useMemo(() => [], []);
1479
+ const empty = useMemo3(() => [], []);
1371
1480
  const value = prop ?? empty;
1372
- const initial = useRef(value);
1373
- useEffect(() => {
1481
+ const initial = useRef4(value);
1482
+ useEffect4(() => {
1374
1483
  if (warningMessage && value !== initial.current && (isMeaningfulChange ? isMeaningfulChange(initial.current, value) : true)) {
1375
1484
  console.error(warningMessage);
1376
1485
  }
@@ -1391,8 +1500,8 @@ var CopilotKitProvider = ({
1391
1500
  showDevConsole = false,
1392
1501
  useSingleEndpoint = false
1393
1502
  }) => {
1394
- const [shouldRenderInspector, setShouldRenderInspector] = useState(false);
1395
- useEffect(() => {
1503
+ const [shouldRenderInspector, setShouldRenderInspector] = useState3(false);
1504
+ useEffect4(() => {
1396
1505
  if (typeof window === "undefined") {
1397
1506
  return;
1398
1507
  }
@@ -1438,7 +1547,7 @@ var CopilotKitProvider = ({
1438
1547
  humanInTheLoop,
1439
1548
  "humanInTheLoop must be a stable array. If you want to dynamically add or remove human-in-the-loop tools, use `useHumanInTheLoop` instead."
1440
1549
  );
1441
- const processedHumanInTheLoopTools = useMemo(() => {
1550
+ const processedHumanInTheLoopTools = useMemo3(() => {
1442
1551
  const processedTools = [];
1443
1552
  const processedRenderToolCalls = [];
1444
1553
  humanInTheLoopList.forEach((tool) => {
@@ -1467,13 +1576,13 @@ var CopilotKitProvider = ({
1467
1576
  });
1468
1577
  return { tools: processedTools, renderToolCalls: processedRenderToolCalls };
1469
1578
  }, [humanInTheLoopList]);
1470
- const allTools = useMemo(() => {
1579
+ const allTools = useMemo3(() => {
1471
1580
  const tools = [];
1472
1581
  tools.push(...frontendToolsList);
1473
1582
  tools.push(...processedHumanInTheLoopTools.tools);
1474
1583
  return tools;
1475
1584
  }, [frontendToolsList, processedHumanInTheLoopTools]);
1476
- const allRenderToolCalls = useMemo(() => {
1585
+ const allRenderToolCalls = useMemo3(() => {
1477
1586
  const combined = [...renderToolCallsList];
1478
1587
  frontendToolsList.forEach((tool) => {
1479
1588
  if (tool.render) {
@@ -1490,7 +1599,7 @@ var CopilotKitProvider = ({
1490
1599
  combined.push(...processedHumanInTheLoopTools.renderToolCalls);
1491
1600
  return combined;
1492
1601
  }, [renderToolCallsList, frontendToolsList, processedHumanInTheLoopTools]);
1493
- const copilotkit = useMemo(() => {
1602
+ const copilotkit = useMemo3(() => {
1494
1603
  const copilotkit2 = new CopilotKitCoreReact({
1495
1604
  runtimeUrl,
1496
1605
  runtimeTransport: useSingleEndpoint ? "single" : "rest",
@@ -1505,24 +1614,24 @@ var CopilotKitProvider = ({
1505
1614
  return copilotkit2;
1506
1615
  }, [allTools, allRenderToolCalls, renderActivityMessagesList, renderCustomMessagesList, useSingleEndpoint]);
1507
1616
  const [, forceUpdate] = useReducer((x) => x + 1, 0);
1508
- useEffect(() => {
1509
- const unsubscribe = copilotkit.subscribe({
1617
+ useEffect4(() => {
1618
+ const subscription = copilotkit.subscribe({
1510
1619
  onRenderToolCallsChanged: () => {
1511
1620
  forceUpdate();
1512
1621
  }
1513
1622
  });
1514
1623
  return () => {
1515
- unsubscribe();
1624
+ subscription.unsubscribe();
1516
1625
  };
1517
1626
  }, [copilotkit]);
1518
- useEffect(() => {
1627
+ useEffect4(() => {
1519
1628
  copilotkit.setRuntimeUrl(runtimeUrl);
1520
1629
  copilotkit.setRuntimeTransport(useSingleEndpoint ? "single" : "rest");
1521
1630
  copilotkit.setHeaders(headers);
1522
1631
  copilotkit.setProperties(properties);
1523
1632
  copilotkit.setAgents__unsafe_dev_only(agents);
1524
1633
  }, [runtimeUrl, headers, properties, agents, useSingleEndpoint]);
1525
- return /* @__PURE__ */ jsxs(
1634
+ return /* @__PURE__ */ jsxs4(
1526
1635
  CopilotKitContext.Provider,
1527
1636
  {
1528
1637
  value: {
@@ -1530,45 +1639,107 @@ var CopilotKitProvider = ({
1530
1639
  },
1531
1640
  children: [
1532
1641
  children,
1533
- shouldRenderInspector ? /* @__PURE__ */ jsx(CopilotKitInspector, { core: copilotkit }) : null
1642
+ shouldRenderInspector ? /* @__PURE__ */ jsx8(CopilotKitInspector, { core: copilotkit }) : null
1534
1643
  ]
1535
1644
  }
1536
1645
  );
1537
1646
  };
1538
1647
  var useCopilotKit = () => {
1539
- const context = useContext(CopilotKitContext);
1648
+ const context = useContext2(CopilotKitContext);
1540
1649
  const [, forceUpdate] = useReducer((x) => x + 1, 0);
1541
1650
  if (!context) {
1542
1651
  throw new Error("useCopilotKit must be used within CopilotKitProvider");
1543
1652
  }
1544
- useEffect(() => {
1545
- const unsubscribe = context.copilotkit.subscribe({
1653
+ useEffect4(() => {
1654
+ const subscription = context.copilotkit.subscribe({
1546
1655
  onRuntimeConnectionStatusChanged: () => {
1547
1656
  forceUpdate();
1548
1657
  }
1549
1658
  });
1550
1659
  return () => {
1551
- unsubscribe();
1660
+ subscription.unsubscribe();
1552
1661
  };
1553
1662
  }, []);
1554
1663
  return context;
1555
1664
  };
1665
+
1666
+ // src/hooks/use-render-tool-call.tsx
1667
+ import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID2 } from "@copilotkitnext/shared";
1668
+ import { partialJSONParse } from "@copilotkitnext/shared";
1669
+ import { jsx as jsx9 } from "react/jsx-runtime";
1670
+ var ToolCallRenderer = React6.memo(
1671
+ function ToolCallRenderer2({
1672
+ toolCall,
1673
+ toolMessage,
1674
+ RenderComponent,
1675
+ isExecuting
1676
+ }) {
1677
+ const args = useMemo4(
1678
+ () => partialJSONParse(toolCall.function.arguments),
1679
+ [toolCall.function.arguments]
1680
+ );
1681
+ const toolName = toolCall.function.name;
1682
+ if (toolMessage) {
1683
+ return /* @__PURE__ */ jsx9(
1684
+ RenderComponent,
1685
+ {
1686
+ name: toolName,
1687
+ args,
1688
+ status: ToolCallStatus.Complete,
1689
+ result: toolMessage.content
1690
+ }
1691
+ );
1692
+ } else if (isExecuting) {
1693
+ return /* @__PURE__ */ jsx9(
1694
+ RenderComponent,
1695
+ {
1696
+ name: toolName,
1697
+ args,
1698
+ status: ToolCallStatus.Executing,
1699
+ result: void 0
1700
+ }
1701
+ );
1702
+ } else {
1703
+ return /* @__PURE__ */ jsx9(
1704
+ RenderComponent,
1705
+ {
1706
+ name: toolName,
1707
+ args,
1708
+ status: ToolCallStatus.InProgress,
1709
+ result: void 0
1710
+ }
1711
+ );
1712
+ }
1713
+ },
1714
+ // Custom comparison function to prevent re-renders when tool call data hasn't changed
1715
+ (prevProps, nextProps) => {
1716
+ if (prevProps.toolCall.id !== nextProps.toolCall.id) return false;
1717
+ if (prevProps.toolCall.function.name !== nextProps.toolCall.function.name) return false;
1718
+ if (prevProps.toolCall.function.arguments !== nextProps.toolCall.function.arguments) return false;
1719
+ const prevResult = prevProps.toolMessage?.content;
1720
+ const nextResult = nextProps.toolMessage?.content;
1721
+ if (prevResult !== nextResult) return false;
1722
+ if (prevProps.isExecuting !== nextProps.isExecuting) return false;
1723
+ if (prevProps.RenderComponent !== nextProps.RenderComponent) return false;
1724
+ return true;
1725
+ }
1726
+ );
1556
1727
  function useRenderToolCall() {
1557
1728
  const { copilotkit } = useCopilotKit();
1558
1729
  const config = useCopilotChatConfiguration();
1559
- const agentId = config?.agentId ?? DEFAULT_AGENT_ID;
1560
- const [executingToolCallIds, setExecutingToolCallIds] = useState(() => /* @__PURE__ */ new Set());
1730
+ const agentId = config?.agentId ?? DEFAULT_AGENT_ID2;
1731
+ const [executingToolCallIds, setExecutingToolCallIds] = useState4(() => /* @__PURE__ */ new Set());
1561
1732
  const renderToolCalls = useSyncExternalStore(
1562
1733
  (callback) => {
1563
1734
  return copilotkit.subscribe({
1564
1735
  onRenderToolCallsChanged: callback
1565
- });
1736
+ }).unsubscribe;
1566
1737
  },
1567
1738
  () => copilotkit.renderToolCalls,
1568
1739
  () => copilotkit.renderToolCalls
1569
1740
  );
1570
- useEffect(() => {
1571
- const unsubscribe = copilotkit.subscribe({
1741
+ useEffect5(() => {
1742
+ const subscription = copilotkit.subscribe({
1572
1743
  onToolExecutionStart: ({ toolCallId }) => {
1573
1744
  setExecutingToolCallIds((prev) => {
1574
1745
  if (prev.has(toolCallId)) return prev;
@@ -1586,9 +1757,9 @@ function useRenderToolCall() {
1586
1757
  });
1587
1758
  }
1588
1759
  });
1589
- return () => unsubscribe();
1760
+ return () => subscription.unsubscribe();
1590
1761
  }, [copilotkit]);
1591
- const renderToolCall = useCallback(
1762
+ const renderToolCall = useCallback2(
1592
1763
  ({
1593
1764
  toolCall,
1594
1765
  toolMessage
@@ -1601,47 +1772,25 @@ function useRenderToolCall() {
1601
1772
  return null;
1602
1773
  }
1603
1774
  const RenderComponent = renderConfig.render;
1604
- const args = partialJSONParse(toolCall.function.arguments);
1605
- const toolName = toolCall.function.name;
1606
- if (toolMessage) {
1607
- return /* @__PURE__ */ jsx(
1608
- RenderComponent,
1609
- {
1610
- name: toolName,
1611
- args,
1612
- status: ToolCallStatus.Complete,
1613
- result: toolMessage.content
1614
- },
1615
- toolCall.id
1616
- );
1617
- } else if (executingToolCallIds.has(toolCall.id)) {
1618
- return /* @__PURE__ */ jsx(
1619
- RenderComponent,
1620
- {
1621
- name: toolName,
1622
- args,
1623
- status: ToolCallStatus.Executing,
1624
- result: void 0
1625
- },
1626
- toolCall.id
1627
- );
1628
- } else {
1629
- return /* @__PURE__ */ jsx(
1775
+ const isExecuting = executingToolCallIds.has(toolCall.id);
1776
+ return /* @__PURE__ */ jsx9(
1777
+ ToolCallRenderer,
1778
+ {
1779
+ toolCall,
1780
+ toolMessage,
1630
1781
  RenderComponent,
1631
- {
1632
- name: toolName,
1633
- args,
1634
- status: ToolCallStatus.InProgress,
1635
- result: void 0
1636
- },
1637
- toolCall.id
1638
- );
1639
- }
1782
+ isExecuting
1783
+ },
1784
+ toolCall.id
1785
+ );
1640
1786
  },
1641
1787
  [renderToolCalls, executingToolCallIds, agentId]
1642
1788
  );
1643
1789
  return renderToolCall;
1644
1790
  }
1791
+
1792
+ // src/hooks/use-render-custom-messages.tsx
1793
+ import { jsx as jsx10 } from "react/jsx-runtime";
1645
1794
  function useRenderCustomMessages() {
1646
1795
  const { copilotkit } = useCopilotKit();
1647
1796
  const config = useCopilotChatConfiguration();
@@ -1676,7 +1825,7 @@ function useRenderCustomMessages() {
1676
1825
  continue;
1677
1826
  }
1678
1827
  const Component = renderer.render;
1679
- result = /* @__PURE__ */ jsx(
1828
+ result = /* @__PURE__ */ jsx10(
1680
1829
  Component,
1681
1830
  {
1682
1831
  message,
@@ -1697,12 +1846,17 @@ function useRenderCustomMessages() {
1697
1846
  return result;
1698
1847
  };
1699
1848
  }
1849
+
1850
+ // src/hooks/use-render-activity-message.tsx
1851
+ import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID3 } from "@copilotkitnext/shared";
1852
+ import { useCallback as useCallback3 } from "react";
1853
+ import { jsx as jsx11 } from "react/jsx-runtime";
1700
1854
  function useRenderActivityMessage() {
1701
1855
  const { copilotkit } = useCopilotKit();
1702
1856
  const config = useCopilotChatConfiguration();
1703
- const agentId = config?.agentId ?? DEFAULT_AGENT_ID;
1857
+ const agentId = config?.agentId ?? DEFAULT_AGENT_ID3;
1704
1858
  const renderers = copilotkit.renderActivityMessages;
1705
- return useCallback(
1859
+ return useCallback3(
1706
1860
  (message) => {
1707
1861
  if (!renderers.length) {
1708
1862
  return null;
@@ -1724,7 +1878,7 @@ function useRenderActivityMessage() {
1724
1878
  }
1725
1879
  const Component = renderer.render;
1726
1880
  const agent = copilotkit.getAgent(agentId);
1727
- return /* @__PURE__ */ jsx(
1881
+ return /* @__PURE__ */ jsx11(
1728
1882
  Component,
1729
1883
  {
1730
1884
  activityType: message.activityType,
@@ -1738,9 +1892,14 @@ function useRenderActivityMessage() {
1738
1892
  [agentId, copilotkit, renderers]
1739
1893
  );
1740
1894
  }
1741
- function useFrontendTool(tool) {
1895
+
1896
+ // src/hooks/use-frontend-tool.tsx
1897
+ import { useEffect as useEffect6 } from "react";
1898
+ var EMPTY_DEPS = [];
1899
+ function useFrontendTool(tool, deps) {
1742
1900
  const { copilotkit } = useCopilotKit();
1743
- useEffect(() => {
1901
+ const extraDeps = deps ?? EMPTY_DEPS;
1902
+ useEffect6(() => {
1744
1903
  const name = tool.name;
1745
1904
  if (copilotkit.getTool({ toolName: name, agentId: tool.agentId })) {
1746
1905
  console.warn(
@@ -1768,23 +1927,27 @@ function useFrontendTool(tool) {
1768
1927
  return () => {
1769
1928
  copilotkit.removeTool(name, tool.agentId);
1770
1929
  };
1771
- }, [tool.name, copilotkit]);
1930
+ }, [tool.name, copilotkit, extraDeps.length, ...extraDeps]);
1772
1931
  }
1773
- function useHumanInTheLoop(tool) {
1932
+
1933
+ // src/hooks/use-human-in-the-loop.tsx
1934
+ import { useCallback as useCallback4, useRef as useRef5, useEffect as useEffect7 } from "react";
1935
+ import React7 from "react";
1936
+ function useHumanInTheLoop(tool, deps) {
1774
1937
  const { copilotkit } = useCopilotKit();
1775
- const resolvePromiseRef = useRef(null);
1776
- const respond = useCallback(async (result) => {
1938
+ const resolvePromiseRef = useRef5(null);
1939
+ const respond = useCallback4(async (result) => {
1777
1940
  if (resolvePromiseRef.current) {
1778
1941
  resolvePromiseRef.current(result);
1779
1942
  resolvePromiseRef.current = null;
1780
1943
  }
1781
1944
  }, []);
1782
- const handler = useCallback(async () => {
1945
+ const handler = useCallback4(async () => {
1783
1946
  return new Promise((resolve) => {
1784
1947
  resolvePromiseRef.current = resolve;
1785
1948
  });
1786
1949
  }, []);
1787
- const RenderComponent = useCallback(
1950
+ const RenderComponent = useCallback4(
1788
1951
  (props) => {
1789
1952
  const ToolComponent = tool.render;
1790
1953
  if (props.status === "inProgress") {
@@ -1794,7 +1957,7 @@ function useHumanInTheLoop(tool) {
1794
1957
  description: tool.description || "",
1795
1958
  respond: void 0
1796
1959
  };
1797
- return React2__default.createElement(ToolComponent, enhancedProps);
1960
+ return React7.createElement(ToolComponent, enhancedProps);
1798
1961
  } else if (props.status === "executing") {
1799
1962
  const enhancedProps = {
1800
1963
  ...props,
@@ -1802,7 +1965,7 @@ function useHumanInTheLoop(tool) {
1802
1965
  description: tool.description || "",
1803
1966
  respond
1804
1967
  };
1805
- return React2__default.createElement(ToolComponent, enhancedProps);
1968
+ return React7.createElement(ToolComponent, enhancedProps);
1806
1969
  } else if (props.status === "complete") {
1807
1970
  const enhancedProps = {
1808
1971
  ...props,
@@ -1810,9 +1973,9 @@ function useHumanInTheLoop(tool) {
1810
1973
  description: tool.description || "",
1811
1974
  respond: void 0
1812
1975
  };
1813
- return React2__default.createElement(ToolComponent, enhancedProps);
1976
+ return React7.createElement(ToolComponent, enhancedProps);
1814
1977
  }
1815
- return React2__default.createElement(ToolComponent, props);
1978
+ return React7.createElement(ToolComponent, props);
1816
1979
  },
1817
1980
  [tool.render, tool.name, tool.description, respond]
1818
1981
  );
@@ -1821,8 +1984,8 @@ function useHumanInTheLoop(tool) {
1821
1984
  handler,
1822
1985
  render: RenderComponent
1823
1986
  };
1824
- useFrontendTool(frontendTool);
1825
- useEffect(() => {
1987
+ useFrontendTool(frontendTool, deps);
1988
+ useEffect7(() => {
1826
1989
  return () => {
1827
1990
  const keyOf = (rc) => `${rc.agentId ?? ""}:${rc.name}`;
1828
1991
  const currentRenderToolCalls = copilotkit.renderToolCalls;
@@ -1833,31 +1996,55 @@ function useHumanInTheLoop(tool) {
1833
1996
  };
1834
1997
  }, [copilotkit, tool.name, tool.agentId]);
1835
1998
  }
1999
+
2000
+ // src/hooks/use-agent.tsx
2001
+ import { useMemo as useMemo5, useEffect as useEffect8, useReducer as useReducer2 } from "react";
2002
+ import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID4 } from "@copilotkitnext/shared";
2003
+ import { ProxiedCopilotRuntimeAgent, CopilotKitCoreRuntimeConnectionStatus } from "@copilotkitnext/core";
1836
2004
  var ALL_UPDATES = [
1837
2005
  "OnMessagesChanged" /* OnMessagesChanged */,
1838
2006
  "OnStateChanged" /* OnStateChanged */,
1839
2007
  "OnRunStatusChanged" /* OnRunStatusChanged */
1840
2008
  ];
1841
2009
  function useAgent({ agentId, updates } = {}) {
1842
- agentId ??= DEFAULT_AGENT_ID;
2010
+ agentId ??= DEFAULT_AGENT_ID4;
1843
2011
  const { copilotkit } = useCopilotKit();
1844
- const [, forceUpdate] = useReducer((x) => x + 1, 0);
1845
- const updateFlags = useMemo(
2012
+ const [, forceUpdate] = useReducer2((x) => x + 1, 0);
2013
+ const updateFlags = useMemo5(
1846
2014
  () => updates ?? ALL_UPDATES,
1847
2015
  [JSON.stringify(updates)]
1848
2016
  );
1849
- const agent = useMemo(() => {
1850
- return copilotkit.getAgent(agentId);
2017
+ const agent = useMemo5(() => {
2018
+ const existing = copilotkit.getAgent(agentId);
2019
+ if (existing) {
2020
+ return existing;
2021
+ }
2022
+ const isRuntimeConfigured = copilotkit.runtimeUrl !== void 0;
2023
+ const status = copilotkit.runtimeConnectionStatus;
2024
+ if (isRuntimeConfigured && (status === CopilotKitCoreRuntimeConnectionStatus.Disconnected || status === CopilotKitCoreRuntimeConnectionStatus.Connecting)) {
2025
+ const provisional = new ProxiedCopilotRuntimeAgent({
2026
+ runtimeUrl: copilotkit.runtimeUrl,
2027
+ agentId,
2028
+ transport: copilotkit.runtimeTransport
2029
+ });
2030
+ provisional.headers = { ...copilotkit.headers };
2031
+ return provisional;
2032
+ }
2033
+ const knownAgents = Object.keys(copilotkit.agents ?? {});
2034
+ const runtimePart = isRuntimeConfigured ? `runtimeUrl=${copilotkit.runtimeUrl}` : "no runtimeUrl";
2035
+ throw new Error(
2036
+ `useAgent: Agent '${agentId}' not found after runtime sync (${runtimePart}). ` + (knownAgents.length ? `Known agents: [${knownAgents.join(", ")}]` : "No agents registered.") + " Verify your runtime /info and/or agents__unsafe_dev_only."
2037
+ );
1851
2038
  }, [
1852
2039
  agentId,
1853
2040
  copilotkit.agents,
1854
2041
  copilotkit.runtimeConnectionStatus,
2042
+ copilotkit.runtimeUrl,
2043
+ copilotkit.runtimeTransport,
2044
+ JSON.stringify(copilotkit.headers),
1855
2045
  copilotkit
1856
2046
  ]);
1857
- useEffect(() => {
1858
- if (!agent) {
1859
- return;
1860
- }
2047
+ useEffect8(() => {
1861
2048
  if (updateFlags.length === 0) {
1862
2049
  return;
1863
2050
  }
@@ -1890,10 +2077,13 @@ function useAgent({ agentId, updates } = {}) {
1890
2077
  agent
1891
2078
  };
1892
2079
  }
2080
+
2081
+ // src/hooks/use-agent-context.tsx
2082
+ import { useEffect as useEffect9 } from "react";
1893
2083
  function useAgentContext(context) {
1894
2084
  const { description, value } = context;
1895
2085
  const { copilotkit } = useCopilotKit();
1896
- useEffect(() => {
2086
+ useEffect9(() => {
1897
2087
  if (!copilotkit) return;
1898
2088
  const id = copilotkit.addContext(context);
1899
2089
  return () => {
@@ -1901,25 +2091,29 @@ function useAgentContext(context) {
1901
2091
  };
1902
2092
  }, [description, value, copilotkit]);
1903
2093
  }
2094
+
2095
+ // src/hooks/use-suggestions.tsx
2096
+ import { useCallback as useCallback5, useEffect as useEffect10, useMemo as useMemo6, useState as useState5 } from "react";
2097
+ import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID5 } from "@copilotkitnext/shared";
1904
2098
  function useSuggestions({ agentId } = {}) {
1905
2099
  const { copilotkit } = useCopilotKit();
1906
2100
  const config = useCopilotChatConfiguration();
1907
- const resolvedAgentId = useMemo(() => agentId ?? config?.agentId ?? DEFAULT_AGENT_ID, [agentId, config?.agentId]);
1908
- const [suggestions, setSuggestions] = useState(() => {
2101
+ const resolvedAgentId = useMemo6(() => agentId ?? config?.agentId ?? DEFAULT_AGENT_ID5, [agentId, config?.agentId]);
2102
+ const [suggestions, setSuggestions] = useState5(() => {
1909
2103
  const result = copilotkit.getSuggestions(resolvedAgentId);
1910
2104
  return result.suggestions;
1911
2105
  });
1912
- const [isLoading, setIsLoading] = useState(() => {
2106
+ const [isLoading, setIsLoading] = useState5(() => {
1913
2107
  const result = copilotkit.getSuggestions(resolvedAgentId);
1914
2108
  return result.isLoading;
1915
2109
  });
1916
- useEffect(() => {
2110
+ useEffect10(() => {
1917
2111
  const result = copilotkit.getSuggestions(resolvedAgentId);
1918
2112
  setSuggestions(result.suggestions);
1919
2113
  setIsLoading(result.isLoading);
1920
2114
  }, [copilotkit, resolvedAgentId]);
1921
- useEffect(() => {
1922
- const unsubscribe = copilotkit.subscribe({
2115
+ useEffect10(() => {
2116
+ const subscription = copilotkit.subscribe({
1923
2117
  onSuggestionsChanged: ({ agentId: changedAgentId, suggestions: suggestions2 }) => {
1924
2118
  if (changedAgentId !== resolvedAgentId) {
1925
2119
  return;
@@ -1945,13 +2139,13 @@ function useSuggestions({ agentId } = {}) {
1945
2139
  }
1946
2140
  });
1947
2141
  return () => {
1948
- unsubscribe();
2142
+ subscription.unsubscribe();
1949
2143
  };
1950
2144
  }, [copilotkit, resolvedAgentId]);
1951
- const reloadSuggestions = useCallback(() => {
2145
+ const reloadSuggestions = useCallback5(() => {
1952
2146
  copilotkit.reloadSuggestions(resolvedAgentId);
1953
2147
  }, [copilotkit, resolvedAgentId]);
1954
- const clearSuggestions = useCallback(() => {
2148
+ const clearSuggestions = useCallback5(() => {
1955
2149
  copilotkit.clearSuggestions(resolvedAgentId);
1956
2150
  }, [copilotkit, resolvedAgentId]);
1957
2151
  return {
@@ -1961,18 +2155,21 @@ function useSuggestions({ agentId } = {}) {
1961
2155
  isLoading
1962
2156
  };
1963
2157
  }
1964
- var EMPTY_DEPS = [];
1965
- function useConfigureSuggestions(config, options) {
2158
+
2159
+ // src/hooks/use-configure-suggestions.tsx
2160
+ import { useCallback as useCallback6, useEffect as useEffect11, useMemo as useMemo7, useRef as useRef6 } from "react";
2161
+ import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID6 } from "@copilotkitnext/shared";
2162
+ function useConfigureSuggestions(config, deps) {
1966
2163
  const { copilotkit } = useCopilotKit();
1967
2164
  const chatConfig = useCopilotChatConfiguration();
1968
- const extraDeps = options?.deps ?? EMPTY_DEPS;
1969
- const resolvedConsumerAgentId = useMemo(() => chatConfig?.agentId ?? DEFAULT_AGENT_ID, [chatConfig?.agentId]);
1970
- const rawConsumerAgentId = useMemo(() => config ? config.consumerAgentId : void 0, [config]);
1971
- const normalizationCacheRef = useRef({
2165
+ const extraDeps = deps ?? [];
2166
+ const resolvedConsumerAgentId = useMemo7(() => chatConfig?.agentId ?? DEFAULT_AGENT_ID6, [chatConfig?.agentId]);
2167
+ const rawConsumerAgentId = useMemo7(() => config ? config.consumerAgentId : void 0, [config]);
2168
+ const normalizationCacheRef = useRef6({
1972
2169
  serialized: null,
1973
2170
  config: null
1974
2171
  });
1975
- const { normalizedConfig, serializedConfig } = useMemo(() => {
2172
+ const { normalizedConfig, serializedConfig } = useMemo7(() => {
1976
2173
  if (!config) {
1977
2174
  normalizationCacheRef.current = { serialized: null, config: null };
1978
2175
  return { normalizedConfig: null, serializedConfig: null };
@@ -2002,10 +2199,10 @@ function useConfigureSuggestions(config, options) {
2002
2199
  normalizationCacheRef.current = { serialized, config: built };
2003
2200
  return { normalizedConfig: built, serializedConfig: serialized };
2004
2201
  }, [config, resolvedConsumerAgentId, ...extraDeps]);
2005
- const latestConfigRef = useRef(null);
2202
+ const latestConfigRef = useRef6(null);
2006
2203
  latestConfigRef.current = normalizedConfig;
2007
- const previousSerializedConfigRef = useRef(null);
2008
- const targetAgentId = useMemo(() => {
2204
+ const previousSerializedConfigRef = useRef6(null);
2205
+ const targetAgentId = useMemo7(() => {
2009
2206
  if (!normalizedConfig) {
2010
2207
  return resolvedConsumerAgentId;
2011
2208
  }
@@ -2016,7 +2213,7 @@ function useConfigureSuggestions(config, options) {
2016
2213
  return consumer;
2017
2214
  }, [normalizedConfig, resolvedConsumerAgentId]);
2018
2215
  const isGlobalConfig = rawConsumerAgentId === void 0 || rawConsumerAgentId === "*";
2019
- const requestReload = useCallback(() => {
2216
+ const requestReload = useCallback6(() => {
2020
2217
  if (!normalizedConfig) {
2021
2218
  return;
2022
2219
  }
@@ -2038,7 +2235,7 @@ function useConfigureSuggestions(config, options) {
2038
2235
  }
2039
2236
  copilotkit.reloadSuggestions(targetAgentId);
2040
2237
  }, [copilotkit, isGlobalConfig, normalizedConfig, targetAgentId]);
2041
- useEffect(() => {
2238
+ useEffect11(() => {
2042
2239
  if (!serializedConfig || !latestConfigRef.current) {
2043
2240
  return;
2044
2241
  }
@@ -2048,7 +2245,7 @@ function useConfigureSuggestions(config, options) {
2048
2245
  copilotkit.removeSuggestionsConfig(id);
2049
2246
  };
2050
2247
  }, [copilotkit, serializedConfig, requestReload]);
2051
- useEffect(() => {
2248
+ useEffect11(() => {
2052
2249
  if (!normalizedConfig) {
2053
2250
  previousSerializedConfigRef.current = null;
2054
2251
  return;
@@ -2061,7 +2258,7 @@ function useConfigureSuggestions(config, options) {
2061
2258
  }
2062
2259
  requestReload();
2063
2260
  }, [normalizedConfig, requestReload, serializedConfig]);
2064
- useEffect(() => {
2261
+ useEffect11(() => {
2065
2262
  if (!normalizedConfig || extraDeps.length === 0) {
2066
2263
  return;
2067
2264
  }
@@ -2077,6 +2274,10 @@ function normalizeStaticSuggestions(suggestions) {
2077
2274
  isLoading: suggestion.isLoading ?? false
2078
2275
  }));
2079
2276
  }
2277
+
2278
+ // src/components/chat/CopilotChatToolCallsView.tsx
2279
+ import React8 from "react";
2280
+ import { Fragment as Fragment2, jsx as jsx12 } from "react/jsx-runtime";
2080
2281
  function CopilotChatToolCallsView({
2081
2282
  message,
2082
2283
  messages = []
@@ -2085,17 +2286,20 @@ function CopilotChatToolCallsView({
2085
2286
  if (!message.toolCalls || message.toolCalls.length === 0) {
2086
2287
  return null;
2087
2288
  }
2088
- return /* @__PURE__ */ jsx(Fragment, { children: message.toolCalls.map((toolCall) => {
2289
+ return /* @__PURE__ */ jsx12(Fragment2, { children: message.toolCalls.map((toolCall) => {
2089
2290
  const toolMessage = messages.find(
2090
2291
  (m) => m.role === "tool" && m.toolCallId === toolCall.id
2091
2292
  );
2092
- return /* @__PURE__ */ jsx(React2__default.Fragment, { children: renderToolCall({
2293
+ return /* @__PURE__ */ jsx12(React8.Fragment, { children: renderToolCall({
2093
2294
  toolCall,
2094
2295
  toolMessage
2095
2296
  }) }, toolCall.id);
2096
2297
  }) });
2097
2298
  }
2098
2299
  var CopilotChatToolCallsView_default = CopilotChatToolCallsView;
2300
+
2301
+ // src/components/chat/CopilotChatAssistantMessage.tsx
2302
+ import { Fragment as Fragment3, jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
2099
2303
  function CopilotChatAssistantMessage({
2100
2304
  message,
2101
2305
  messages,
@@ -2172,7 +2376,7 @@ function CopilotChatAssistantMessage({
2172
2376
  toolbar,
2173
2377
  CopilotChatAssistantMessage.Toolbar,
2174
2378
  {
2175
- children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
2379
+ children: /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-1", children: [
2176
2380
  boundCopyButton,
2177
2381
  (onThumbsUp || thumbsUpButton) && boundThumbsUpButton,
2178
2382
  (onThumbsDown || thumbsDownButton) && boundThumbsDownButton,
@@ -2194,7 +2398,7 @@ function CopilotChatAssistantMessage({
2194
2398
  const isLatestAssistantMessage = message.role === "assistant" && messages?.[messages.length - 1]?.id === message.id;
2195
2399
  const shouldShowToolbar = toolbarVisible && hasContent && !(isRunning && isLatestAssistantMessage);
2196
2400
  if (children) {
2197
- return /* @__PURE__ */ jsx(Fragment, { children: children({
2401
+ return /* @__PURE__ */ jsx13(Fragment3, { children: children({
2198
2402
  markdownRenderer: boundMarkdownRenderer,
2199
2403
  toolbar: boundToolbar,
2200
2404
  toolCallsView: boundToolCallsView,
@@ -2214,10 +2418,10 @@ function CopilotChatAssistantMessage({
2214
2418
  toolbarVisible: shouldShowToolbar
2215
2419
  }) });
2216
2420
  }
2217
- return /* @__PURE__ */ jsxs(
2421
+ return /* @__PURE__ */ jsxs5(
2218
2422
  "div",
2219
2423
  {
2220
- className: twMerge(
2424
+ className: twMerge4(
2221
2425
  "prose max-w-full break-words dark:prose-invert",
2222
2426
  className
2223
2427
  ),
@@ -2232,14 +2436,14 @@ function CopilotChatAssistantMessage({
2232
2436
  );
2233
2437
  }
2234
2438
  ((CopilotChatAssistantMessage2) => {
2235
- CopilotChatAssistantMessage2.MarkdownRenderer = ({ content, className, ...props }) => /* @__PURE__ */ jsx(Streamdown, { className, ...props, children: content ?? "" });
2439
+ CopilotChatAssistantMessage2.MarkdownRenderer = ({ content, className, ...props }) => /* @__PURE__ */ jsx13(Streamdown, { className, ...props, children: content ?? "" });
2236
2440
  CopilotChatAssistantMessage2.Toolbar = ({
2237
2441
  className,
2238
2442
  ...props
2239
- }) => /* @__PURE__ */ jsx(
2443
+ }) => /* @__PURE__ */ jsx13(
2240
2444
  "div",
2241
2445
  {
2242
- className: twMerge(
2446
+ className: twMerge4(
2243
2447
  "w-full bg-transparent flex items-center -ml-[5px] -mt-[0px]",
2244
2448
  className
2245
2449
  ),
@@ -2247,8 +2451,8 @@ function CopilotChatAssistantMessage({
2247
2451
  }
2248
2452
  );
2249
2453
  CopilotChatAssistantMessage2.ToolbarButton = ({ title, children, ...props }) => {
2250
- return /* @__PURE__ */ jsxs(Tooltip, { children: [
2251
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
2454
+ return /* @__PURE__ */ jsxs5(Tooltip, { children: [
2455
+ /* @__PURE__ */ jsx13(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx13(
2252
2456
  Button,
2253
2457
  {
2254
2458
  type: "button",
@@ -2258,13 +2462,13 @@ function CopilotChatAssistantMessage({
2258
2462
  children
2259
2463
  }
2260
2464
  ) }),
2261
- /* @__PURE__ */ jsx(TooltipContent, { side: "bottom", children: /* @__PURE__ */ jsx("p", { children: title }) })
2465
+ /* @__PURE__ */ jsx13(TooltipContent, { side: "bottom", children: /* @__PURE__ */ jsx13("p", { children: title }) })
2262
2466
  ] });
2263
2467
  };
2264
2468
  CopilotChatAssistantMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
2265
2469
  const config = useCopilotChatConfiguration();
2266
2470
  const labels = config?.labels ?? CopilotChatDefaultLabels;
2267
- const [copied, setCopied] = useState(false);
2471
+ const [copied, setCopied] = useState6(false);
2268
2472
  const handleClick = (event) => {
2269
2473
  setCopied(true);
2270
2474
  setTimeout(() => setCopied(false), 2e3);
@@ -2272,62 +2476,62 @@ function CopilotChatAssistantMessage({
2272
2476
  onClick(event);
2273
2477
  }
2274
2478
  };
2275
- return /* @__PURE__ */ jsx(
2479
+ return /* @__PURE__ */ jsx13(
2276
2480
  CopilotChatAssistantMessage2.ToolbarButton,
2277
2481
  {
2278
2482
  title: title || labels.assistantMessageToolbarCopyMessageLabel,
2279
2483
  onClick: handleClick,
2280
2484
  className,
2281
2485
  ...props,
2282
- children: copied ? /* @__PURE__ */ jsx(Check, { className: "size-[18px]" }) : /* @__PURE__ */ jsx(Copy, { className: "size-[18px]" })
2486
+ children: copied ? /* @__PURE__ */ jsx13(Check2, { className: "size-[18px]" }) : /* @__PURE__ */ jsx13(Copy, { className: "size-[18px]" })
2283
2487
  }
2284
2488
  );
2285
2489
  };
2286
2490
  CopilotChatAssistantMessage2.ThumbsUpButton = ({ title, ...props }) => {
2287
2491
  const config = useCopilotChatConfiguration();
2288
2492
  const labels = config?.labels ?? CopilotChatDefaultLabels;
2289
- return /* @__PURE__ */ jsx(
2493
+ return /* @__PURE__ */ jsx13(
2290
2494
  CopilotChatAssistantMessage2.ToolbarButton,
2291
2495
  {
2292
2496
  title: title || labels.assistantMessageToolbarThumbsUpLabel,
2293
2497
  ...props,
2294
- children: /* @__PURE__ */ jsx(ThumbsUp, { className: "size-[18px]" })
2498
+ children: /* @__PURE__ */ jsx13(ThumbsUp, { className: "size-[18px]" })
2295
2499
  }
2296
2500
  );
2297
2501
  };
2298
2502
  CopilotChatAssistantMessage2.ThumbsDownButton = ({ title, ...props }) => {
2299
2503
  const config = useCopilotChatConfiguration();
2300
2504
  const labels = config?.labels ?? CopilotChatDefaultLabels;
2301
- return /* @__PURE__ */ jsx(
2505
+ return /* @__PURE__ */ jsx13(
2302
2506
  CopilotChatAssistantMessage2.ToolbarButton,
2303
2507
  {
2304
2508
  title: title || labels.assistantMessageToolbarThumbsDownLabel,
2305
2509
  ...props,
2306
- children: /* @__PURE__ */ jsx(ThumbsDown, { className: "size-[18px]" })
2510
+ children: /* @__PURE__ */ jsx13(ThumbsDown, { className: "size-[18px]" })
2307
2511
  }
2308
2512
  );
2309
2513
  };
2310
2514
  CopilotChatAssistantMessage2.ReadAloudButton = ({ title, ...props }) => {
2311
2515
  const config = useCopilotChatConfiguration();
2312
2516
  const labels = config?.labels ?? CopilotChatDefaultLabels;
2313
- return /* @__PURE__ */ jsx(
2517
+ return /* @__PURE__ */ jsx13(
2314
2518
  CopilotChatAssistantMessage2.ToolbarButton,
2315
2519
  {
2316
2520
  title: title || labels.assistantMessageToolbarReadAloudLabel,
2317
2521
  ...props,
2318
- children: /* @__PURE__ */ jsx(Volume2, { className: "size-[20px]" })
2522
+ children: /* @__PURE__ */ jsx13(Volume2, { className: "size-[20px]" })
2319
2523
  }
2320
2524
  );
2321
2525
  };
2322
2526
  CopilotChatAssistantMessage2.RegenerateButton = ({ title, ...props }) => {
2323
2527
  const config = useCopilotChatConfiguration();
2324
2528
  const labels = config?.labels ?? CopilotChatDefaultLabels;
2325
- return /* @__PURE__ */ jsx(
2529
+ return /* @__PURE__ */ jsx13(
2326
2530
  CopilotChatAssistantMessage2.ToolbarButton,
2327
2531
  {
2328
2532
  title: title || labels.assistantMessageToolbarRegenerateLabel,
2329
2533
  ...props,
2330
- children: /* @__PURE__ */ jsx(RefreshCw, { className: "size-[18px]" })
2534
+ children: /* @__PURE__ */ jsx13(RefreshCw, { className: "size-[18px]" })
2331
2535
  }
2332
2536
  );
2333
2537
  };
@@ -2340,6 +2544,12 @@ CopilotChatAssistantMessage.ThumbsDownButton.displayName = "CopilotChatAssistant
2340
2544
  CopilotChatAssistantMessage.ReadAloudButton.displayName = "CopilotChatAssistantMessage.ReadAloudButton";
2341
2545
  CopilotChatAssistantMessage.RegenerateButton.displayName = "CopilotChatAssistantMessage.RegenerateButton";
2342
2546
  var CopilotChatAssistantMessage_default = CopilotChatAssistantMessage;
2547
+
2548
+ // src/components/chat/CopilotChatUserMessage.tsx
2549
+ import { useMemo as useMemo8, useState as useState7 } from "react";
2550
+ import { Copy as Copy2, Check as Check3, Edit, ChevronLeft, ChevronRight } from "lucide-react";
2551
+ import { twMerge as twMerge5 } from "tailwind-merge";
2552
+ import { Fragment as Fragment4, jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
2343
2553
  function flattenUserMessageContent(content) {
2344
2554
  if (!content) {
2345
2555
  return "";
@@ -2370,7 +2580,7 @@ function CopilotChatUserMessage({
2370
2580
  className,
2371
2581
  ...props
2372
2582
  }) {
2373
- const flattenedContent = useMemo(
2583
+ const flattenedContent = useMemo8(
2374
2584
  () => flattenUserMessageContent(message.content),
2375
2585
  [message.content]
2376
2586
  );
@@ -2415,7 +2625,7 @@ function CopilotChatUserMessage({
2415
2625
  );
2416
2626
  const showBranchNavigation = numberOfBranches && numberOfBranches > 1 && onSwitchToBranch;
2417
2627
  const BoundToolbar = renderSlot(toolbar, CopilotChatUserMessage.Toolbar, {
2418
- children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 justify-end", children: [
2628
+ children: /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-1 justify-end", children: [
2419
2629
  additionalToolbarItems,
2420
2630
  BoundCopyButton,
2421
2631
  onEditMessage && BoundEditButton,
@@ -2423,7 +2633,7 @@ function CopilotChatUserMessage({
2423
2633
  ] })
2424
2634
  });
2425
2635
  if (children) {
2426
- return /* @__PURE__ */ jsx(Fragment, { children: children({
2636
+ return /* @__PURE__ */ jsx14(Fragment4, { children: children({
2427
2637
  messageRenderer: BoundMessageRenderer,
2428
2638
  toolbar: BoundToolbar,
2429
2639
  copyButton: BoundCopyButton,
@@ -2435,10 +2645,10 @@ function CopilotChatUserMessage({
2435
2645
  additionalToolbarItems
2436
2646
  }) });
2437
2647
  }
2438
- return /* @__PURE__ */ jsxs(
2648
+ return /* @__PURE__ */ jsxs6(
2439
2649
  "div",
2440
2650
  {
2441
- className: twMerge("flex flex-col items-end group pt-10", className),
2651
+ className: twMerge5("flex flex-col items-end group pt-10", className),
2442
2652
  "data-message-id": message.id,
2443
2653
  ...props,
2444
2654
  children: [
@@ -2449,18 +2659,18 @@ function CopilotChatUserMessage({
2449
2659
  );
2450
2660
  }
2451
2661
  ((CopilotChatUserMessage2) => {
2452
- CopilotChatUserMessage2.Container = ({ children, className, ...props }) => /* @__PURE__ */ jsx(
2662
+ CopilotChatUserMessage2.Container = ({ children, className, ...props }) => /* @__PURE__ */ jsx14(
2453
2663
  "div",
2454
2664
  {
2455
- className: twMerge("flex flex-col items-end group", className),
2665
+ className: twMerge5("flex flex-col items-end group", className),
2456
2666
  ...props,
2457
2667
  children
2458
2668
  }
2459
2669
  );
2460
- CopilotChatUserMessage2.MessageRenderer = ({ content, className }) => /* @__PURE__ */ jsx(
2670
+ CopilotChatUserMessage2.MessageRenderer = ({ content, className }) => /* @__PURE__ */ jsx14(
2461
2671
  "div",
2462
2672
  {
2463
- className: twMerge(
2673
+ className: twMerge5(
2464
2674
  "prose dark:prose-invert bg-muted relative max-w-[80%] rounded-[18px] px-4 py-1.5 data-[multiline]:py-3 inline-block whitespace-pre-wrap",
2465
2675
  className
2466
2676
  ),
@@ -2470,10 +2680,10 @@ function CopilotChatUserMessage({
2470
2680
  CopilotChatUserMessage2.Toolbar = ({
2471
2681
  className,
2472
2682
  ...props
2473
- }) => /* @__PURE__ */ jsx(
2683
+ }) => /* @__PURE__ */ jsx14(
2474
2684
  "div",
2475
2685
  {
2476
- className: twMerge(
2686
+ className: twMerge5(
2477
2687
  "w-full bg-transparent flex items-center justify-end -mr-[5px] mt-[4px] invisible group-hover:visible",
2478
2688
  className
2479
2689
  ),
@@ -2481,25 +2691,25 @@ function CopilotChatUserMessage({
2481
2691
  }
2482
2692
  );
2483
2693
  CopilotChatUserMessage2.ToolbarButton = ({ title, children, className, ...props }) => {
2484
- return /* @__PURE__ */ jsxs(Tooltip, { children: [
2485
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
2694
+ return /* @__PURE__ */ jsxs6(Tooltip, { children: [
2695
+ /* @__PURE__ */ jsx14(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx14(
2486
2696
  Button,
2487
2697
  {
2488
2698
  type: "button",
2489
2699
  variant: "assistantMessageToolbarButton",
2490
2700
  "aria-label": title,
2491
- className: twMerge(className),
2701
+ className: twMerge5(className),
2492
2702
  ...props,
2493
2703
  children
2494
2704
  }
2495
2705
  ) }),
2496
- /* @__PURE__ */ jsx(TooltipContent, { side: "bottom", children: /* @__PURE__ */ jsx("p", { children: title }) })
2706
+ /* @__PURE__ */ jsx14(TooltipContent, { side: "bottom", children: /* @__PURE__ */ jsx14("p", { children: title }) })
2497
2707
  ] });
2498
2708
  };
2499
2709
  CopilotChatUserMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
2500
2710
  const config = useCopilotChatConfiguration();
2501
2711
  const labels = config?.labels ?? CopilotChatDefaultLabels;
2502
- const [copied, setCopied] = useState(false);
2712
+ const [copied, setCopied] = useState7(false);
2503
2713
  const handleClick = (event) => {
2504
2714
  setCopied(true);
2505
2715
  setTimeout(() => setCopied(false), 2e3);
@@ -2507,27 +2717,27 @@ function CopilotChatUserMessage({
2507
2717
  onClick(event);
2508
2718
  }
2509
2719
  };
2510
- return /* @__PURE__ */ jsx(
2720
+ return /* @__PURE__ */ jsx14(
2511
2721
  CopilotChatUserMessage2.ToolbarButton,
2512
2722
  {
2513
2723
  title: title || labels.userMessageToolbarCopyMessageLabel,
2514
2724
  onClick: handleClick,
2515
2725
  className,
2516
2726
  ...props,
2517
- children: copied ? /* @__PURE__ */ jsx(Check, { className: "size-[18px]" }) : /* @__PURE__ */ jsx(Copy, { className: "size-[18px]" })
2727
+ children: copied ? /* @__PURE__ */ jsx14(Check3, { className: "size-[18px]" }) : /* @__PURE__ */ jsx14(Copy2, { className: "size-[18px]" })
2518
2728
  }
2519
2729
  );
2520
2730
  };
2521
2731
  CopilotChatUserMessage2.EditButton = ({ className, title, ...props }) => {
2522
2732
  const config = useCopilotChatConfiguration();
2523
2733
  const labels = config?.labels ?? CopilotChatDefaultLabels;
2524
- return /* @__PURE__ */ jsx(
2734
+ return /* @__PURE__ */ jsx14(
2525
2735
  CopilotChatUserMessage2.ToolbarButton,
2526
2736
  {
2527
2737
  title: title || labels.userMessageToolbarEditMessageLabel,
2528
2738
  className,
2529
2739
  ...props,
2530
- children: /* @__PURE__ */ jsx(Edit, { className: "size-[18px]" })
2740
+ children: /* @__PURE__ */ jsx14(Edit, { className: "size-[18px]" })
2531
2741
  }
2532
2742
  );
2533
2743
  };
@@ -2544,8 +2754,8 @@ function CopilotChatUserMessage({
2544
2754
  }
2545
2755
  const canGoPrev = currentBranch > 0;
2546
2756
  const canGoNext = currentBranch < numberOfBranches - 1;
2547
- return /* @__PURE__ */ jsxs("div", { className: twMerge("flex items-center gap-1", className), ...props, children: [
2548
- /* @__PURE__ */ jsx(
2757
+ return /* @__PURE__ */ jsxs6("div", { className: twMerge5("flex items-center gap-1", className), ...props, children: [
2758
+ /* @__PURE__ */ jsx14(
2549
2759
  Button,
2550
2760
  {
2551
2761
  type: "button",
@@ -2557,15 +2767,15 @@ function CopilotChatUserMessage({
2557
2767
  }),
2558
2768
  disabled: !canGoPrev,
2559
2769
  className: "h-6 w-6 p-0",
2560
- children: /* @__PURE__ */ jsx(ChevronLeft, { className: "size-[20px]" })
2770
+ children: /* @__PURE__ */ jsx14(ChevronLeft, { className: "size-[20px]" })
2561
2771
  }
2562
2772
  ),
2563
- /* @__PURE__ */ jsxs("span", { className: "text-sm text-muted-foreground px-0 font-medium", children: [
2773
+ /* @__PURE__ */ jsxs6("span", { className: "text-sm text-muted-foreground px-0 font-medium", children: [
2564
2774
  currentBranch + 1,
2565
2775
  "/",
2566
2776
  numberOfBranches
2567
2777
  ] }),
2568
- /* @__PURE__ */ jsx(
2778
+ /* @__PURE__ */ jsx14(
2569
2779
  Button,
2570
2780
  {
2571
2781
  type: "button",
@@ -2577,7 +2787,7 @@ function CopilotChatUserMessage({
2577
2787
  }),
2578
2788
  disabled: !canGoNext,
2579
2789
  className: "h-6 w-6 p-0",
2580
- children: /* @__PURE__ */ jsx(ChevronRight, { className: "size-[20px]" })
2790
+ children: /* @__PURE__ */ jsx14(ChevronRight, { className: "size-[20px]" })
2581
2791
  }
2582
2792
  )
2583
2793
  ] });
@@ -2591,11 +2801,16 @@ CopilotChatUserMessage.CopyButton.displayName = "CopilotChatUserMessage.CopyButt
2591
2801
  CopilotChatUserMessage.EditButton.displayName = "CopilotChatUserMessage.EditButton";
2592
2802
  CopilotChatUserMessage.BranchNavigation.displayName = "CopilotChatUserMessage.BranchNavigation";
2593
2803
  var CopilotChatUserMessage_default = CopilotChatUserMessage;
2804
+
2805
+ // src/components/chat/CopilotChatSuggestionPill.tsx
2806
+ import React9 from "react";
2807
+ import { Loader2 } from "lucide-react";
2808
+ import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
2594
2809
  var baseClasses = "group inline-flex h-7 sm:h-8 items-center gap-1 sm:gap-1.5 rounded-full border border-border/60 bg-background px-2.5 sm:px-3 text-[11px] sm:text-xs leading-none text-foreground transition-colors cursor-pointer hover:bg-accent/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:text-muted-foreground disabled:hover:bg-background disabled:hover:text-muted-foreground pointer-events-auto";
2595
2810
  var labelClasses = "whitespace-nowrap font-medium leading-none";
2596
- var CopilotChatSuggestionPill = React2__default.forwardRef(function CopilotChatSuggestionPill2({ className, children, icon, isLoading, type, ...props }, ref) {
2811
+ var CopilotChatSuggestionPill = React9.forwardRef(function CopilotChatSuggestionPill2({ className, children, icon, isLoading, type, ...props }, ref) {
2597
2812
  const showIcon = !isLoading && icon;
2598
- return /* @__PURE__ */ jsxs(
2813
+ return /* @__PURE__ */ jsxs7(
2599
2814
  "button",
2600
2815
  {
2601
2816
  ref,
@@ -2606,16 +2821,20 @@ var CopilotChatSuggestionPill = React2__default.forwardRef(function CopilotChatS
2606
2821
  disabled: isLoading || props.disabled,
2607
2822
  ...props,
2608
2823
  children: [
2609
- isLoading ? /* @__PURE__ */ jsx("span", { className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground", children: /* @__PURE__ */ jsx(Loader2, { className: "h-3.5 sm:h-4 w-3.5 sm:w-4 animate-spin", "aria-hidden": "true" }) }) : showIcon && /* @__PURE__ */ jsx("span", { className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground", children: icon }),
2610
- /* @__PURE__ */ jsx("span", { className: labelClasses, children })
2824
+ isLoading ? /* @__PURE__ */ jsx15("span", { className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground", children: /* @__PURE__ */ jsx15(Loader2, { className: "h-3.5 sm:h-4 w-3.5 sm:w-4 animate-spin", "aria-hidden": "true" }) }) : showIcon && /* @__PURE__ */ jsx15("span", { className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground", children: icon }),
2825
+ /* @__PURE__ */ jsx15("span", { className: labelClasses, children })
2611
2826
  ]
2612
2827
  }
2613
2828
  );
2614
2829
  });
2615
2830
  CopilotChatSuggestionPill.displayName = "CopilotChatSuggestionPill";
2616
2831
  var CopilotChatSuggestionPill_default = CopilotChatSuggestionPill;
2617
- var DefaultContainer = React2__default.forwardRef(function DefaultContainer2({ className, ...props }, ref) {
2618
- return /* @__PURE__ */ jsx(
2832
+
2833
+ // src/components/chat/CopilotChatSuggestionView.tsx
2834
+ import React10 from "react";
2835
+ import { Fragment as Fragment5, jsx as jsx16, jsxs as jsxs8 } from "react/jsx-runtime";
2836
+ var DefaultContainer = React10.forwardRef(function DefaultContainer2({ className, ...props }, ref) {
2837
+ return /* @__PURE__ */ jsx16(
2619
2838
  "div",
2620
2839
  {
2621
2840
  ref,
@@ -2627,7 +2846,7 @@ var DefaultContainer = React2__default.forwardRef(function DefaultContainer2({ c
2627
2846
  }
2628
2847
  );
2629
2848
  });
2630
- var CopilotChatSuggestionView = React2__default.forwardRef(function CopilotChatSuggestionView2({
2849
+ var CopilotChatSuggestionView = React10.forwardRef(function CopilotChatSuggestionView2({
2631
2850
  suggestions,
2632
2851
  onSelectSuggestion,
2633
2852
  loadingIndexes,
@@ -2637,7 +2856,7 @@ var CopilotChatSuggestionView = React2__default.forwardRef(function CopilotChatS
2637
2856
  children,
2638
2857
  ...restProps
2639
2858
  }, ref) {
2640
- const loadingSet = React2__default.useMemo(() => {
2859
+ const loadingSet = React10.useMemo(() => {
2641
2860
  if (!loadingIndexes || loadingIndexes.length === 0) {
2642
2861
  return /* @__PURE__ */ new Set();
2643
2862
  }
@@ -2656,11 +2875,11 @@ var CopilotChatSuggestionView = React2__default.forwardRef(function CopilotChatS
2656
2875
  type: "button",
2657
2876
  onClick: () => onSelectSuggestion?.(suggestion, index)
2658
2877
  });
2659
- return React2__default.cloneElement(pill, {
2878
+ return React10.cloneElement(pill, {
2660
2879
  key: `${suggestion.title}-${index}`
2661
2880
  });
2662
2881
  });
2663
- const boundContainer = React2__default.cloneElement(
2882
+ const boundContainer = React10.cloneElement(
2664
2883
  ContainerElement,
2665
2884
  void 0,
2666
2885
  suggestionElements
@@ -2671,7 +2890,7 @@ var CopilotChatSuggestionView = React2__default.forwardRef(function CopilotChatS
2671
2890
  isLoading: suggestions.length > 0 ? loadingSet.has(0) || suggestions[0]?.isLoading === true : false,
2672
2891
  type: "button"
2673
2892
  });
2674
- return /* @__PURE__ */ jsx(Fragment, { children: children({
2893
+ return /* @__PURE__ */ jsx16(Fragment5, { children: children({
2675
2894
  container: boundContainer,
2676
2895
  suggestion: sampleSuggestion,
2677
2896
  suggestions,
@@ -2682,7 +2901,7 @@ var CopilotChatSuggestionView = React2__default.forwardRef(function CopilotChatS
2682
2901
  }) });
2683
2902
  }
2684
2903
  if (children) {
2685
- return /* @__PURE__ */ jsxs(Fragment, { children: [
2904
+ return /* @__PURE__ */ jsxs8(Fragment5, { children: [
2686
2905
  boundContainer,
2687
2906
  children
2688
2907
  ] });
@@ -2691,6 +2910,105 @@ var CopilotChatSuggestionView = React2__default.forwardRef(function CopilotChatS
2691
2910
  });
2692
2911
  CopilotChatSuggestionView.displayName = "CopilotChatSuggestionView";
2693
2912
  var CopilotChatSuggestionView_default = CopilotChatSuggestionView;
2913
+
2914
+ // src/components/chat/CopilotChatMessageView.tsx
2915
+ import React11 from "react";
2916
+ import { twMerge as twMerge6 } from "tailwind-merge";
2917
+ import { jsx as jsx17, jsxs as jsxs9 } from "react/jsx-runtime";
2918
+ var MemoizedAssistantMessage = React11.memo(
2919
+ function MemoizedAssistantMessage2({
2920
+ message,
2921
+ messages,
2922
+ isRunning,
2923
+ AssistantMessageComponent
2924
+ }) {
2925
+ return /* @__PURE__ */ jsx17(
2926
+ AssistantMessageComponent,
2927
+ {
2928
+ message,
2929
+ messages,
2930
+ isRunning
2931
+ }
2932
+ );
2933
+ },
2934
+ (prevProps, nextProps) => {
2935
+ if (prevProps.message.id !== nextProps.message.id) return false;
2936
+ if (prevProps.message.content !== nextProps.message.content) return false;
2937
+ const prevToolCalls = prevProps.message.toolCalls;
2938
+ const nextToolCalls = nextProps.message.toolCalls;
2939
+ if (prevToolCalls?.length !== nextToolCalls?.length) return false;
2940
+ if (prevToolCalls && nextToolCalls) {
2941
+ for (let i = 0; i < prevToolCalls.length; i++) {
2942
+ const prevTc = prevToolCalls[i];
2943
+ const nextTc = nextToolCalls[i];
2944
+ if (!prevTc || !nextTc) return false;
2945
+ if (prevTc.id !== nextTc.id) return false;
2946
+ if (prevTc.function.arguments !== nextTc.function.arguments) return false;
2947
+ }
2948
+ }
2949
+ if (prevToolCalls && prevToolCalls.length > 0) {
2950
+ const toolCallIds = new Set(prevToolCalls.map((tc) => tc.id));
2951
+ const prevToolResults = prevProps.messages.filter(
2952
+ (m) => m.role === "tool" && toolCallIds.has(m.toolCallId)
2953
+ );
2954
+ const nextToolResults = nextProps.messages.filter(
2955
+ (m) => m.role === "tool" && toolCallIds.has(m.toolCallId)
2956
+ );
2957
+ if (prevToolResults.length !== nextToolResults.length) return false;
2958
+ for (let i = 0; i < prevToolResults.length; i++) {
2959
+ if (prevToolResults[i].content !== nextToolResults[i].content) return false;
2960
+ }
2961
+ }
2962
+ const nextIsLatest = nextProps.messages[nextProps.messages.length - 1]?.id === nextProps.message.id;
2963
+ if (nextIsLatest && prevProps.isRunning !== nextProps.isRunning) return false;
2964
+ if (prevProps.AssistantMessageComponent !== nextProps.AssistantMessageComponent) return false;
2965
+ return true;
2966
+ }
2967
+ );
2968
+ var MemoizedUserMessage = React11.memo(
2969
+ function MemoizedUserMessage2({
2970
+ message,
2971
+ UserMessageComponent
2972
+ }) {
2973
+ return /* @__PURE__ */ jsx17(UserMessageComponent, { message });
2974
+ },
2975
+ (prevProps, nextProps) => {
2976
+ if (prevProps.message.id !== nextProps.message.id) return false;
2977
+ if (prevProps.message.content !== nextProps.message.content) return false;
2978
+ if (prevProps.UserMessageComponent !== nextProps.UserMessageComponent) return false;
2979
+ return true;
2980
+ }
2981
+ );
2982
+ var MemoizedActivityMessage = React11.memo(
2983
+ function MemoizedActivityMessage2({
2984
+ message,
2985
+ renderActivityMessage
2986
+ }) {
2987
+ return renderActivityMessage(message);
2988
+ },
2989
+ (prevProps, nextProps) => {
2990
+ if (prevProps.message.id !== nextProps.message.id) return false;
2991
+ if (prevProps.message.activityType !== nextProps.message.activityType) return false;
2992
+ if (JSON.stringify(prevProps.message.content) !== JSON.stringify(nextProps.message.content)) return false;
2993
+ return true;
2994
+ }
2995
+ );
2996
+ var MemoizedCustomMessage = React11.memo(
2997
+ function MemoizedCustomMessage2({
2998
+ message,
2999
+ position,
3000
+ renderCustomMessage
3001
+ }) {
3002
+ return renderCustomMessage({ message, position });
3003
+ },
3004
+ (prevProps, nextProps) => {
3005
+ if (prevProps.message.id !== nextProps.message.id) return false;
3006
+ if (prevProps.position !== nextProps.position) return false;
3007
+ if (prevProps.message.content !== nextProps.message.content) return false;
3008
+ if (prevProps.message.role !== nextProps.message.role) return false;
3009
+ return true;
3010
+ }
3011
+ );
2694
3012
  function CopilotChatMessageView({
2695
3013
  messages = [],
2696
3014
  assistantMessage,
@@ -2707,40 +3025,66 @@ function CopilotChatMessageView({
2707
3025
  const elements = [];
2708
3026
  if (renderCustomMessage) {
2709
3027
  elements.push(
2710
- renderCustomMessage({
2711
- message,
2712
- position: "before"
2713
- })
3028
+ /* @__PURE__ */ jsx17(
3029
+ MemoizedCustomMessage,
3030
+ {
3031
+ message,
3032
+ position: "before",
3033
+ renderCustomMessage
3034
+ },
3035
+ `${message.id}-custom-before`
3036
+ )
2714
3037
  );
2715
3038
  }
2716
3039
  if (message.role === "assistant") {
3040
+ const AssistantComponent = typeof assistantMessage === "function" ? assistantMessage : CopilotChatAssistantMessage_default;
2717
3041
  elements.push(
2718
- renderSlot(assistantMessage, CopilotChatAssistantMessage_default, {
2719
- key: message.id,
2720
- message,
2721
- messages,
2722
- isRunning
2723
- })
3042
+ /* @__PURE__ */ jsx17(
3043
+ MemoizedAssistantMessage,
3044
+ {
3045
+ message,
3046
+ messages,
3047
+ isRunning,
3048
+ AssistantMessageComponent: AssistantComponent
3049
+ },
3050
+ message.id
3051
+ )
2724
3052
  );
2725
3053
  } else if (message.role === "user") {
3054
+ const UserComponent = typeof userMessage === "function" ? userMessage : CopilotChatUserMessage_default;
2726
3055
  elements.push(
2727
- renderSlot(userMessage, CopilotChatUserMessage_default, {
2728
- key: message.id,
2729
- message
2730
- })
3056
+ /* @__PURE__ */ jsx17(
3057
+ MemoizedUserMessage,
3058
+ {
3059
+ message,
3060
+ UserMessageComponent: UserComponent
3061
+ },
3062
+ message.id
3063
+ )
2731
3064
  );
2732
3065
  } else if (message.role === "activity") {
2733
- const renderedActivity = renderActivityMessage(message);
2734
- if (renderedActivity) {
2735
- elements.push(renderedActivity);
2736
- }
3066
+ elements.push(
3067
+ /* @__PURE__ */ jsx17(
3068
+ MemoizedActivityMessage,
3069
+ {
3070
+ message,
3071
+ renderActivityMessage
3072
+ },
3073
+ message.id
3074
+ )
3075
+ );
2737
3076
  }
2738
3077
  if (renderCustomMessage) {
2739
3078
  elements.push(
2740
- renderCustomMessage({
2741
- message,
2742
- position: "after"
2743
- })
3079
+ /* @__PURE__ */ jsx17(
3080
+ MemoizedCustomMessage,
3081
+ {
3082
+ message,
3083
+ position: "after",
3084
+ renderCustomMessage
3085
+ },
3086
+ `${message.id}-custom-after`
3087
+ )
2744
3088
  );
2745
3089
  }
2746
3090
  return elements;
@@ -2748,29 +3092,38 @@ function CopilotChatMessageView({
2748
3092
  if (children) {
2749
3093
  return children({ messageElements, messages, isRunning });
2750
3094
  }
2751
- return /* @__PURE__ */ jsxs("div", { className: twMerge("flex flex-col", className), ...props, children: [
3095
+ return /* @__PURE__ */ jsxs9("div", { className: twMerge6("flex flex-col", className), ...props, children: [
2752
3096
  messageElements,
2753
3097
  isRunning && renderSlot(cursor, CopilotChatMessageView.Cursor, {})
2754
3098
  ] });
2755
3099
  }
2756
3100
  CopilotChatMessageView.Cursor = function Cursor({ className, ...props }) {
2757
- return /* @__PURE__ */ jsx(
3101
+ return /* @__PURE__ */ jsx17(
2758
3102
  "div",
2759
3103
  {
2760
- className: twMerge("w-[11px] h-[11px] rounded-full bg-foreground animate-pulse-cursor ml-1", className),
3104
+ className: twMerge6("w-[11px] h-[11px] rounded-full bg-foreground animate-pulse-cursor ml-1", className),
2761
3105
  ...props
2762
3106
  }
2763
3107
  );
2764
3108
  };
2765
3109
  var CopilotChatMessageView_default = CopilotChatMessageView;
3110
+
3111
+ // src/components/chat/CopilotChatView.tsx
3112
+ import React12, { useRef as useRef7, useState as useState9, useEffect as useEffect13 } from "react";
3113
+ import { twMerge as twMerge7 } from "tailwind-merge";
3114
+ import { StickToBottom, useStickToBottom, useStickToBottomContext } from "use-stick-to-bottom";
3115
+ import { ChevronDown } from "lucide-react";
3116
+
3117
+ // src/hooks/use-keyboard-height.tsx
3118
+ import { useState as useState8, useEffect as useEffect12 } from "react";
2766
3119
  function useKeyboardHeight() {
2767
- const [keyboardState, setKeyboardState] = useState({
3120
+ const [keyboardState, setKeyboardState] = useState8({
2768
3121
  isKeyboardOpen: false,
2769
3122
  keyboardHeight: 0,
2770
3123
  availableHeight: typeof window !== "undefined" ? window.innerHeight : 0,
2771
3124
  viewportHeight: typeof window !== "undefined" ? window.innerHeight : 0
2772
3125
  });
2773
- useEffect(() => {
3126
+ useEffect12(() => {
2774
3127
  if (typeof window === "undefined") {
2775
3128
  return;
2776
3129
  }
@@ -2800,6 +3153,9 @@ function useKeyboardHeight() {
2800
3153
  }, []);
2801
3154
  return keyboardState;
2802
3155
  }
3156
+
3157
+ // src/components/chat/CopilotChatView.tsx
3158
+ import { Fragment as Fragment6, jsx as jsx18, jsxs as jsxs10 } from "react/jsx-runtime";
2803
3159
  function CopilotChatView({
2804
3160
  messageView,
2805
3161
  input,
@@ -2820,12 +3176,12 @@ function CopilotChatView({
2820
3176
  className,
2821
3177
  ...props
2822
3178
  }) {
2823
- const inputContainerRef = useRef(null);
2824
- const [inputContainerHeight, setInputContainerHeight] = useState(0);
2825
- const [isResizing, setIsResizing] = useState(false);
2826
- const resizeTimeoutRef = useRef(null);
3179
+ const inputContainerRef = useRef7(null);
3180
+ const [inputContainerHeight, setInputContainerHeight] = useState9(0);
3181
+ const [isResizing, setIsResizing] = useState9(false);
3182
+ const resizeTimeoutRef = useRef7(null);
2827
3183
  const { isKeyboardOpen, keyboardHeight, availableHeight } = useKeyboardHeight();
2828
- useEffect(() => {
3184
+ useEffect13(() => {
2829
3185
  const element = inputContainerRef.current;
2830
3186
  if (!element) return;
2831
3187
  const resizeObserver = new ResizeObserver((entries) => {
@@ -2861,25 +3217,21 @@ function CopilotChatView({
2861
3217
  });
2862
3218
  const BoundInput = renderSlot(input, CopilotChatInput_default, inputProps ?? {});
2863
3219
  const hasSuggestions = Array.isArray(suggestions) && suggestions.length > 0;
2864
- const BoundSuggestionView = hasSuggestions ? renderSlot(
2865
- suggestionView,
2866
- CopilotChatSuggestionView_default,
2867
- {
2868
- suggestions,
2869
- loadingIndexes: suggestionLoadingIndexes,
2870
- onSelectSuggestion,
2871
- className: "mb-3 lg:ml-4 lg:mr-4 ml-0 mr-0"
2872
- }
2873
- ) : null;
3220
+ const BoundSuggestionView = hasSuggestions ? renderSlot(suggestionView, CopilotChatSuggestionView_default, {
3221
+ suggestions,
3222
+ loadingIndexes: suggestionLoadingIndexes,
3223
+ onSelectSuggestion,
3224
+ className: "mb-3 lg:ml-4 lg:mr-4 ml-0 mr-0"
3225
+ }) : null;
2874
3226
  const BoundFeather = renderSlot(feather, CopilotChatView.Feather, {});
2875
3227
  const BoundScrollView = renderSlot(scrollView, CopilotChatView.ScrollView, {
2876
3228
  autoScroll,
2877
3229
  scrollToBottomButton,
2878
3230
  inputContainerHeight,
2879
3231
  isResizing,
2880
- children: /* @__PURE__ */ jsx("div", { style: { paddingBottom: `${inputContainerHeight + (hasSuggestions ? 4 : 32)}px` }, children: /* @__PURE__ */ jsxs("div", { className: "max-w-3xl mx-auto", children: [
3232
+ children: /* @__PURE__ */ jsx18("div", { style: { paddingBottom: `${inputContainerHeight + (hasSuggestions ? 4 : 32)}px` }, children: /* @__PURE__ */ jsxs10("div", { className: "max-w-3xl mx-auto", children: [
2881
3233
  BoundMessageView,
2882
- hasSuggestions ? /* @__PURE__ */ jsx("div", { className: "pl-0 pr-4 sm:px-0 mt-4", children: BoundSuggestionView }) : null
3234
+ hasSuggestions ? /* @__PURE__ */ jsx18("div", { className: "pl-0 pr-4 sm:px-0 mt-4", children: BoundSuggestionView }) : null
2883
3235
  ] }) })
2884
3236
  });
2885
3237
  const BoundScrollToBottomButton = renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, {});
@@ -2887,8 +3239,8 @@ function CopilotChatView({
2887
3239
  const BoundInputContainer = renderSlot(inputContainer, CopilotChatView.InputContainer, {
2888
3240
  ref: inputContainerRef,
2889
3241
  keyboardHeight: isKeyboardOpen ? keyboardHeight : 0,
2890
- children: /* @__PURE__ */ jsxs(Fragment, { children: [
2891
- /* @__PURE__ */ jsx("div", { className: "max-w-3xl mx-auto py-0 px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6 pointer-events-auto", children: BoundInput }),
3242
+ children: /* @__PURE__ */ jsxs10(Fragment6, { children: [
3243
+ /* @__PURE__ */ jsx18("div", { className: "max-w-3xl mx-auto py-0 px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6 pointer-events-auto", children: BoundInput }),
2892
3244
  BoundDisclaimer
2893
3245
  ] })
2894
3246
  });
@@ -2901,10 +3253,10 @@ function CopilotChatView({
2901
3253
  feather: BoundFeather,
2902
3254
  inputContainer: BoundInputContainer,
2903
3255
  disclaimer: BoundDisclaimer,
2904
- suggestionView: BoundSuggestionView ?? /* @__PURE__ */ jsx(Fragment, {})
3256
+ suggestionView: BoundSuggestionView ?? /* @__PURE__ */ jsx18(Fragment6, {})
2905
3257
  });
2906
3258
  }
2907
- return /* @__PURE__ */ jsxs("div", { className: twMerge("relative h-full", className), ...props, children: [
3259
+ return /* @__PURE__ */ jsxs10("div", { className: twMerge7("relative h-full", className), ...props, children: [
2908
3260
  BoundScrollView,
2909
3261
  BoundFeather,
2910
3262
  BoundInputContainer
@@ -2913,9 +3265,9 @@ function CopilotChatView({
2913
3265
  ((CopilotChatView2) => {
2914
3266
  const ScrollContent = ({ children, scrollToBottomButton, inputContainerHeight, isResizing }) => {
2915
3267
  const { isAtBottom, scrollToBottom } = useStickToBottomContext();
2916
- return /* @__PURE__ */ jsxs(Fragment, { children: [
2917
- /* @__PURE__ */ jsx(StickToBottom.Content, { className: "overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ jsx("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) }),
2918
- !isAtBottom && !isResizing && /* @__PURE__ */ jsx(
3268
+ return /* @__PURE__ */ jsxs10(Fragment6, { children: [
3269
+ /* @__PURE__ */ jsx18(StickToBottom.Content, { className: "overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ jsx18("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) }),
3270
+ !isAtBottom && !isResizing && /* @__PURE__ */ jsx18(
2919
3271
  "div",
2920
3272
  {
2921
3273
  className: "absolute inset-x-0 flex justify-center z-10 pointer-events-none",
@@ -2938,13 +3290,13 @@ function CopilotChatView({
2938
3290
  className,
2939
3291
  ...props
2940
3292
  }) => {
2941
- const [hasMounted, setHasMounted] = useState(false);
3293
+ const [hasMounted, setHasMounted] = useState9(false);
2942
3294
  const { scrollRef, contentRef, scrollToBottom } = useStickToBottom();
2943
- const [showScrollButton, setShowScrollButton] = useState(false);
2944
- useEffect(() => {
3295
+ const [showScrollButton, setShowScrollButton] = useState9(false);
3296
+ useEffect13(() => {
2945
3297
  setHasMounted(true);
2946
3298
  }, []);
2947
- useEffect(() => {
3299
+ useEffect13(() => {
2948
3300
  if (autoScroll) return;
2949
3301
  const scrollElement = scrollRef.current;
2950
3302
  if (!scrollElement) return;
@@ -2962,10 +3314,10 @@ function CopilotChatView({
2962
3314
  };
2963
3315
  }, [scrollRef, autoScroll]);
2964
3316
  if (!hasMounted) {
2965
- return /* @__PURE__ */ jsx("div", { className: "h-full max-h-full flex flex-col min-h-0 overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ jsx("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) });
3317
+ return /* @__PURE__ */ jsx18("div", { className: "h-full max-h-full flex flex-col min-h-0 overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ jsx18("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) });
2966
3318
  }
2967
3319
  if (!autoScroll) {
2968
- return /* @__PURE__ */ jsxs(
3320
+ return /* @__PURE__ */ jsxs10(
2969
3321
  "div",
2970
3322
  {
2971
3323
  ref: scrollRef,
@@ -2975,8 +3327,8 @@ function CopilotChatView({
2975
3327
  ),
2976
3328
  ...props,
2977
3329
  children: [
2978
- /* @__PURE__ */ jsx("div", { ref: contentRef, className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }),
2979
- showScrollButton && !isResizing && /* @__PURE__ */ jsx(
3330
+ /* @__PURE__ */ jsx18("div", { ref: contentRef, className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }),
3331
+ showScrollButton && !isResizing && /* @__PURE__ */ jsx18(
2980
3332
  "div",
2981
3333
  {
2982
3334
  className: "absolute inset-x-0 flex justify-center z-10 pointer-events-none",
@@ -2992,14 +3344,14 @@ function CopilotChatView({
2992
3344
  }
2993
3345
  );
2994
3346
  }
2995
- return /* @__PURE__ */ jsx(
3347
+ return /* @__PURE__ */ jsx18(
2996
3348
  StickToBottom,
2997
3349
  {
2998
3350
  className: cn("h-full max-h-full flex flex-col min-h-0 relative", className),
2999
3351
  resize: "smooth",
3000
3352
  initial: "smooth",
3001
3353
  ...props,
3002
- children: /* @__PURE__ */ jsx(
3354
+ children: /* @__PURE__ */ jsx18(
3003
3355
  ScrollContent,
3004
3356
  {
3005
3357
  scrollToBottomButton,
@@ -3014,12 +3366,12 @@ function CopilotChatView({
3014
3366
  CopilotChatView2.ScrollToBottomButton = ({
3015
3367
  className,
3016
3368
  ...props
3017
- }) => /* @__PURE__ */ jsx(
3369
+ }) => /* @__PURE__ */ jsx18(
3018
3370
  Button,
3019
3371
  {
3020
3372
  variant: "outline",
3021
3373
  size: "sm",
3022
- className: twMerge(
3374
+ className: twMerge7(
3023
3375
  "rounded-full w-10 h-10 p-0 pointer-events-auto",
3024
3376
  "bg-white dark:bg-gray-900",
3025
3377
  "shadow-lg border border-gray-200 dark:border-gray-700",
@@ -3028,10 +3380,10 @@ function CopilotChatView({
3028
3380
  className
3029
3381
  ),
3030
3382
  ...props,
3031
- children: /* @__PURE__ */ jsx(ChevronDown, { className: "w-4 h-4 text-gray-600 dark:text-white" })
3383
+ children: /* @__PURE__ */ jsx18(ChevronDown, { className: "w-4 h-4 text-gray-600 dark:text-white" })
3032
3384
  }
3033
3385
  );
3034
- CopilotChatView2.Feather = ({ className, style, ...props }) => /* @__PURE__ */ jsx(
3386
+ CopilotChatView2.Feather = ({ className, style, ...props }) => /* @__PURE__ */ jsx18(
3035
3387
  "div",
3036
3388
  {
3037
3389
  className: cn(
@@ -3044,7 +3396,7 @@ function CopilotChatView({
3044
3396
  ...props
3045
3397
  }
3046
3398
  );
3047
- CopilotChatView2.InputContainer = React2__default.forwardRef(({ children, className, keyboardHeight = 0, ...props }, ref) => /* @__PURE__ */ jsx(
3399
+ CopilotChatView2.InputContainer = React12.forwardRef(({ children, className, keyboardHeight = 0, ...props }, ref) => /* @__PURE__ */ jsx18(
3048
3400
  "div",
3049
3401
  {
3050
3402
  ref,
@@ -3062,7 +3414,7 @@ function CopilotChatView({
3062
3414
  CopilotChatView2.Disclaimer = ({ className, ...props }) => {
3063
3415
  const config = useCopilotChatConfiguration();
3064
3416
  const labels = config?.labels ?? CopilotChatDefaultLabels;
3065
- return /* @__PURE__ */ jsx(
3417
+ return /* @__PURE__ */ jsx18(
3066
3418
  "div",
3067
3419
  {
3068
3420
  className: cn("text-center text-xs text-muted-foreground py-3 px-4 max-w-3xl mx-auto", className),
@@ -3073,11 +3425,18 @@ function CopilotChatView({
3073
3425
  };
3074
3426
  })(CopilotChatView || (CopilotChatView = {}));
3075
3427
  var CopilotChatView_default = CopilotChatView;
3428
+
3429
+ // src/components/chat/CopilotChat.tsx
3430
+ import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID7, randomUUID as randomUUID2 } from "@copilotkitnext/shared";
3431
+ import { useCallback as useCallback7, useEffect as useEffect14, useMemo as useMemo9 } from "react";
3432
+ import { merge } from "ts-deepmerge";
3433
+ import { AGUIConnectNotImplementedError } from "@ag-ui/client";
3434
+ import { jsx as jsx19 } from "react/jsx-runtime";
3076
3435
  function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen, ...props }) {
3077
3436
  const existingConfig = useCopilotChatConfiguration();
3078
- const resolvedAgentId = agentId ?? existingConfig?.agentId ?? DEFAULT_AGENT_ID;
3079
- const resolvedThreadId = useMemo(
3080
- () => threadId ?? existingConfig?.threadId ?? randomUUID(),
3437
+ const resolvedAgentId = agentId ?? existingConfig?.agentId ?? DEFAULT_AGENT_ID7;
3438
+ const resolvedThreadId = useMemo9(
3439
+ () => threadId ?? existingConfig?.threadId ?? randomUUID2(),
3081
3440
  [threadId, existingConfig?.threadId]
3082
3441
  );
3083
3442
  const { agent } = useAgent({ agentId: resolvedAgentId });
@@ -3089,47 +3448,41 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
3089
3448
  suggestionView: providedSuggestionView,
3090
3449
  ...restProps
3091
3450
  } = props;
3092
- useEffect(() => {
3451
+ useEffect14(() => {
3093
3452
  const connect = async (agent2) => {
3094
3453
  try {
3095
3454
  await copilotkit.connectAgent({ agent: agent2 });
3096
3455
  } catch (error) {
3097
- if (error instanceof AGUIConnectNotImplementedError) ; else {
3456
+ if (error instanceof AGUIConnectNotImplementedError) {
3457
+ } else {
3098
3458
  throw error;
3099
3459
  }
3100
3460
  }
3101
3461
  };
3102
- if (agent) {
3103
- agent.threadId = resolvedThreadId;
3104
- connect(agent);
3105
- }
3462
+ agent.threadId = resolvedThreadId;
3463
+ connect(agent);
3106
3464
  return () => {
3107
3465
  };
3108
3466
  }, [resolvedThreadId, agent, copilotkit, resolvedAgentId]);
3109
- const onSubmitInput = useCallback(
3467
+ const onSubmitInput = useCallback7(
3110
3468
  async (value) => {
3111
- agent?.addMessage({
3112
- id: randomUUID(),
3469
+ agent.addMessage({
3470
+ id: randomUUID2(),
3113
3471
  role: "user",
3114
3472
  content: value
3115
3473
  });
3116
- if (agent) {
3117
- try {
3118
- await copilotkit.runAgent({ agent });
3119
- } catch (error) {
3120
- console.error("CopilotChat: runAgent failed", error);
3121
- }
3474
+ try {
3475
+ await copilotkit.runAgent({ agent });
3476
+ } catch (error) {
3477
+ console.error("CopilotChat: runAgent failed", error);
3122
3478
  }
3123
3479
  },
3124
3480
  [agent, copilotkit]
3125
3481
  );
3126
- const handleSelectSuggestion = useCallback(
3482
+ const handleSelectSuggestion = useCallback7(
3127
3483
  async (suggestion) => {
3128
- if (!agent) {
3129
- return;
3130
- }
3131
3484
  agent.addMessage({
3132
- id: randomUUID(),
3485
+ id: randomUUID2(),
3133
3486
  role: "user",
3134
3487
  content: suggestion.message
3135
3488
  });
@@ -3141,10 +3494,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
3141
3494
  },
3142
3495
  [agent, copilotkit]
3143
3496
  );
3144
- const stopCurrentRun = useCallback(() => {
3145
- if (!agent) {
3146
- return;
3147
- }
3497
+ const stopCurrentRun = useCallback7(() => {
3148
3498
  try {
3149
3499
  copilotkit.stopAgent({ agent });
3150
3500
  } catch (error) {
@@ -3158,7 +3508,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
3158
3508
  }, [agent, copilotkit]);
3159
3509
  const mergedProps = merge(
3160
3510
  {
3161
- isRunning: agent?.isRunning ?? false,
3511
+ isRunning: agent.isRunning,
3162
3512
  suggestions: autoSuggestions,
3163
3513
  onSelectSuggestion: handleSelectSuggestion,
3164
3514
  suggestionView: providedSuggestionView
@@ -3169,22 +3519,22 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
3169
3519
  }
3170
3520
  );
3171
3521
  const providedStopHandler = providedInputProps?.onStop;
3172
- const hasMessages = (agent?.messages?.length ?? 0) > 0;
3173
- const shouldAllowStop = (agent?.isRunning ?? false) && hasMessages;
3522
+ const hasMessages = agent.messages.length > 0;
3523
+ const shouldAllowStop = agent.isRunning && hasMessages;
3174
3524
  const effectiveStopHandler = shouldAllowStop ? providedStopHandler ?? stopCurrentRun : providedStopHandler;
3175
3525
  const finalInputProps = {
3176
3526
  ...providedInputProps,
3177
3527
  onSubmitMessage: onSubmitInput,
3178
3528
  onStop: effectiveStopHandler,
3179
- isRunning: agent?.isRunning ?? false
3529
+ isRunning: agent.isRunning
3180
3530
  };
3181
- finalInputProps.mode = agent?.isRunning ? "processing" : finalInputProps.mode ?? "input";
3531
+ finalInputProps.mode = agent.isRunning ? "processing" : finalInputProps.mode ?? "input";
3182
3532
  const finalProps = merge(mergedProps, {
3183
- messages: agent?.messages ?? [],
3533
+ messages: agent.messages,
3184
3534
  inputProps: finalInputProps
3185
3535
  });
3186
3536
  const RenderedChatView = renderSlot(chatView, CopilotChatView, finalProps);
3187
- return /* @__PURE__ */ jsx(
3537
+ return /* @__PURE__ */ jsx19(
3188
3538
  CopilotChatConfigurationProvider,
3189
3539
  {
3190
3540
  agentId: resolvedAgentId,
@@ -3198,14 +3548,19 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
3198
3548
  ((CopilotChat2) => {
3199
3549
  CopilotChat2.View = CopilotChatView;
3200
3550
  })(CopilotChat || (CopilotChat = {}));
3551
+
3552
+ // src/components/chat/CopilotChatToggleButton.tsx
3553
+ import React13, { useState as useState10 } from "react";
3554
+ import { MessageCircle, X as X2 } from "lucide-react";
3555
+ import { jsx as jsx20, jsxs as jsxs11 } from "react/jsx-runtime";
3201
3556
  var DefaultOpenIcon = ({
3202
3557
  className,
3203
3558
  ...props
3204
- }) => /* @__PURE__ */ jsx(MessageCircle, { className: cn("h-6 w-6", className), strokeWidth: 1.75, fill: "currentColor", ...props });
3559
+ }) => /* @__PURE__ */ jsx20(MessageCircle, { className: cn("h-6 w-6", className), strokeWidth: 1.75, fill: "currentColor", ...props });
3205
3560
  var DefaultCloseIcon = ({
3206
3561
  className,
3207
3562
  ...props
3208
- }) => /* @__PURE__ */ jsx(X, { className: cn("h-6 w-6", className), strokeWidth: 1.75, ...props });
3563
+ }) => /* @__PURE__ */ jsx20(X2, { className: cn("h-6 w-6", className), strokeWidth: 1.75, ...props });
3209
3564
  DefaultOpenIcon.displayName = "CopilotChatToggleButton.OpenIcon";
3210
3565
  DefaultCloseIcon.displayName = "CopilotChatToggleButton.CloseIcon";
3211
3566
  var ICON_TRANSITION_STYLE = Object.freeze({
@@ -3222,11 +3577,11 @@ var BUTTON_BASE_CLASSES = cn(
3222
3577
  "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-2 focus-visible:ring-offset-background",
3223
3578
  "disabled:pointer-events-none disabled:opacity-60"
3224
3579
  );
3225
- var CopilotChatToggleButton = React2__default.forwardRef(function CopilotChatToggleButton2({ openIcon, closeIcon, className, ...buttonProps }, ref) {
3580
+ var CopilotChatToggleButton = React13.forwardRef(function CopilotChatToggleButton2({ openIcon, closeIcon, className, ...buttonProps }, ref) {
3226
3581
  const { onClick, type, disabled, ...restProps } = buttonProps;
3227
3582
  const configuration = useCopilotChatConfiguration();
3228
3583
  const labels = configuration?.labels ?? CopilotChatDefaultLabels;
3229
- const [fallbackOpen, setFallbackOpen] = useState(false);
3584
+ const [fallbackOpen, setFallbackOpen] = useState10(false);
3230
3585
  const isOpen = configuration?.isModalOpen ?? fallbackOpen;
3231
3586
  const setModalOpen = configuration?.setModalOpen ?? setFallbackOpen;
3232
3587
  const handleClick = (event) => {
@@ -3260,7 +3615,7 @@ var CopilotChatToggleButton = React2__default.forwardRef(function CopilotChatTog
3260
3615
  focusable: false
3261
3616
  }
3262
3617
  );
3263
- const openIconElement = /* @__PURE__ */ jsx(
3618
+ const openIconElement = /* @__PURE__ */ jsx20(
3264
3619
  "span",
3265
3620
  {
3266
3621
  "aria-hidden": "true",
@@ -3274,7 +3629,7 @@ var CopilotChatToggleButton = React2__default.forwardRef(function CopilotChatTog
3274
3629
  children: renderedOpenIcon
3275
3630
  }
3276
3631
  );
3277
- const closeIconElement = /* @__PURE__ */ jsx(
3632
+ const closeIconElement = /* @__PURE__ */ jsx20(
3278
3633
  "span",
3279
3634
  {
3280
3635
  "aria-hidden": "true",
@@ -3288,7 +3643,7 @@ var CopilotChatToggleButton = React2__default.forwardRef(function CopilotChatTog
3288
3643
  children: renderedCloseIcon
3289
3644
  }
3290
3645
  );
3291
- return /* @__PURE__ */ jsxs(
3646
+ return /* @__PURE__ */ jsxs11(
3292
3647
  "button",
3293
3648
  {
3294
3649
  ref,
@@ -3310,6 +3665,14 @@ var CopilotChatToggleButton = React2__default.forwardRef(function CopilotChatTog
3310
3665
  });
3311
3666
  CopilotChatToggleButton.displayName = "CopilotChatToggleButton";
3312
3667
  var CopilotChatToggleButton_default = CopilotChatToggleButton;
3668
+
3669
+ // src/components/chat/CopilotSidebarView.tsx
3670
+ import { useEffect as useEffect15, useRef as useRef8, useState as useState11 } from "react";
3671
+
3672
+ // src/components/chat/CopilotModalHeader.tsx
3673
+ import { useCallback as useCallback8 } from "react";
3674
+ import { X as X3 } from "lucide-react";
3675
+ import { jsx as jsx21, jsxs as jsxs12 } from "react/jsx-runtime";
3313
3676
  function CopilotModalHeader({
3314
3677
  title,
3315
3678
  titleContent,
@@ -3321,7 +3684,7 @@ function CopilotModalHeader({
3321
3684
  const configuration = useCopilotChatConfiguration();
3322
3685
  const fallbackTitle = configuration?.labels.modalHeaderTitle ?? CopilotChatDefaultLabels.modalHeaderTitle;
3323
3686
  const resolvedTitle = title ?? fallbackTitle;
3324
- const handleClose = useCallback(() => {
3687
+ const handleClose = useCallback8(() => {
3325
3688
  configuration?.setModalOpen(false);
3326
3689
  }, [configuration]);
3327
3690
  const BoundTitle = renderSlot(titleContent, CopilotModalHeader.Title, {
@@ -3338,7 +3701,7 @@ function CopilotModalHeader({
3338
3701
  ...rest
3339
3702
  });
3340
3703
  }
3341
- return /* @__PURE__ */ jsx(
3704
+ return /* @__PURE__ */ jsx21(
3342
3705
  "header",
3343
3706
  {
3344
3707
  "data-slot": "copilot-modal-header",
@@ -3348,17 +3711,17 @@ function CopilotModalHeader({
3348
3711
  className
3349
3712
  ),
3350
3713
  ...rest,
3351
- children: /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center gap-2", children: [
3352
- /* @__PURE__ */ jsx("div", { className: "flex-1", "aria-hidden": "true" }),
3353
- /* @__PURE__ */ jsx("div", { className: "flex flex-1 justify-center text-center", children: BoundTitle }),
3354
- /* @__PURE__ */ jsx("div", { className: "flex flex-1 justify-end", children: BoundCloseButton })
3714
+ children: /* @__PURE__ */ jsxs12("div", { className: "flex w-full items-center gap-2", children: [
3715
+ /* @__PURE__ */ jsx21("div", { className: "flex-1", "aria-hidden": "true" }),
3716
+ /* @__PURE__ */ jsx21("div", { className: "flex flex-1 justify-center text-center", children: BoundTitle }),
3717
+ /* @__PURE__ */ jsx21("div", { className: "flex flex-1 justify-end", children: BoundCloseButton })
3355
3718
  ] })
3356
3719
  }
3357
3720
  );
3358
3721
  }
3359
3722
  CopilotModalHeader.displayName = "CopilotModalHeader";
3360
3723
  ((CopilotModalHeader2) => {
3361
- CopilotModalHeader2.Title = ({ children, className, ...props }) => /* @__PURE__ */ jsx(
3724
+ CopilotModalHeader2.Title = ({ children, className, ...props }) => /* @__PURE__ */ jsx21(
3362
3725
  "div",
3363
3726
  {
3364
3727
  className: cn(
@@ -3372,7 +3735,7 @@ CopilotModalHeader.displayName = "CopilotModalHeader";
3372
3735
  CopilotModalHeader2.CloseButton = ({
3373
3736
  className,
3374
3737
  ...props
3375
- }) => /* @__PURE__ */ jsx(
3738
+ }) => /* @__PURE__ */ jsx21(
3376
3739
  "button",
3377
3740
  {
3378
3741
  type: "button",
@@ -3383,19 +3746,22 @@ CopilotModalHeader.displayName = "CopilotModalHeader";
3383
3746
  ),
3384
3747
  "aria-label": "Close",
3385
3748
  ...props,
3386
- children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4", "aria-hidden": "true" })
3749
+ children: /* @__PURE__ */ jsx21(X3, { className: "h-4 w-4", "aria-hidden": "true" })
3387
3750
  }
3388
3751
  );
3389
3752
  })(CopilotModalHeader || (CopilotModalHeader = {}));
3390
3753
  CopilotModalHeader.Title.displayName = "CopilotModalHeader.Title";
3391
3754
  CopilotModalHeader.CloseButton.displayName = "CopilotModalHeader.CloseButton";
3755
+
3756
+ // src/components/chat/CopilotSidebarView.tsx
3757
+ import { Fragment as Fragment7, jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
3392
3758
  var DEFAULT_SIDEBAR_WIDTH = 480;
3393
3759
  var SIDEBAR_TRANSITION_MS = 260;
3394
3760
  function CopilotSidebarView({ header, width, ...props }) {
3395
3761
  const configuration = useCopilotChatConfiguration();
3396
3762
  const isSidebarOpen = configuration?.isModalOpen ?? false;
3397
- const sidebarRef = useRef(null);
3398
- const [sidebarWidth, setSidebarWidth] = useState(width ?? DEFAULT_SIDEBAR_WIDTH);
3763
+ const sidebarRef = useRef8(null);
3764
+ const [sidebarWidth, setSidebarWidth] = useState11(width ?? DEFAULT_SIDEBAR_WIDTH);
3399
3765
  const widthToCss = (w) => {
3400
3766
  return typeof w === "number" ? `${w}px` : w;
3401
3767
  };
@@ -3405,7 +3771,7 @@ function CopilotSidebarView({ header, width, ...props }) {
3405
3771
  }
3406
3772
  return w;
3407
3773
  };
3408
- useEffect(() => {
3774
+ useEffect15(() => {
3409
3775
  if (width !== void 0) {
3410
3776
  return;
3411
3777
  }
@@ -3432,8 +3798,8 @@ function CopilotSidebarView({ header, width, ...props }) {
3432
3798
  return () => window.removeEventListener("resize", updateWidth);
3433
3799
  }, [width]);
3434
3800
  const headerElement = renderSlot(header, CopilotModalHeader, {});
3435
- return /* @__PURE__ */ jsxs(Fragment, { children: [
3436
- isSidebarOpen && /* @__PURE__ */ jsx(
3801
+ return /* @__PURE__ */ jsxs13(Fragment7, { children: [
3802
+ isSidebarOpen && /* @__PURE__ */ jsx22(
3437
3803
  "style",
3438
3804
  {
3439
3805
  dangerouslySetInnerHTML: {
@@ -3447,8 +3813,8 @@ function CopilotSidebarView({ header, width, ...props }) {
3447
3813
  }
3448
3814
  }
3449
3815
  ),
3450
- /* @__PURE__ */ jsx(CopilotChatToggleButton_default, {}),
3451
- /* @__PURE__ */ jsx(
3816
+ /* @__PURE__ */ jsx22(CopilotChatToggleButton_default, {}),
3817
+ /* @__PURE__ */ jsx22(
3452
3818
  "aside",
3453
3819
  {
3454
3820
  ref: sidebarRef,
@@ -3473,15 +3839,19 @@ function CopilotSidebarView({ header, width, ...props }) {
3473
3839
  "aria-hidden": !isSidebarOpen,
3474
3840
  "aria-label": "Copilot chat sidebar",
3475
3841
  role: "complementary",
3476
- children: /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col overflow-hidden", children: [
3842
+ children: /* @__PURE__ */ jsxs13("div", { className: "flex h-full w-full flex-col overflow-hidden", children: [
3477
3843
  headerElement,
3478
- /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-hidden", "data-sidebar-chat": true, children: /* @__PURE__ */ jsx(CopilotChatView_default, { ...props }) })
3844
+ /* @__PURE__ */ jsx22("div", { className: "flex-1 overflow-hidden", "data-sidebar-chat": true, children: /* @__PURE__ */ jsx22(CopilotChatView_default, { ...props }) })
3479
3845
  ] })
3480
3846
  }
3481
3847
  )
3482
3848
  ] });
3483
3849
  }
3484
3850
  CopilotSidebarView.displayName = "CopilotSidebarView";
3851
+
3852
+ // src/components/chat/CopilotPopupView.tsx
3853
+ import { useEffect as useEffect16, useMemo as useMemo10, useRef as useRef9, useState as useState12 } from "react";
3854
+ import { Fragment as Fragment8, jsx as jsx23, jsxs as jsxs14 } from "react/jsx-runtime";
3485
3855
  var DEFAULT_POPUP_WIDTH = 420;
3486
3856
  var DEFAULT_POPUP_HEIGHT = 560;
3487
3857
  var dimensionToCss = (value, fallback) => {
@@ -3505,10 +3875,10 @@ function CopilotPopupView({
3505
3875
  const isPopupOpen = configuration?.isModalOpen ?? false;
3506
3876
  const setModalOpen = configuration?.setModalOpen;
3507
3877
  const labels = configuration?.labels ?? CopilotChatDefaultLabels;
3508
- const containerRef = useRef(null);
3509
- const [isRendered, setIsRendered] = useState(isPopupOpen);
3510
- const [isAnimatingOut, setIsAnimatingOut] = useState(false);
3511
- useEffect(() => {
3878
+ const containerRef = useRef9(null);
3879
+ const [isRendered, setIsRendered] = useState12(isPopupOpen);
3880
+ const [isAnimatingOut, setIsAnimatingOut] = useState12(false);
3881
+ useEffect16(() => {
3512
3882
  if (isPopupOpen) {
3513
3883
  setIsRendered(true);
3514
3884
  setIsAnimatingOut(false);
@@ -3524,7 +3894,7 @@ function CopilotPopupView({
3524
3894
  }, 200);
3525
3895
  return () => clearTimeout(timeout);
3526
3896
  }, [isPopupOpen, isRendered]);
3527
- useEffect(() => {
3897
+ useEffect16(() => {
3528
3898
  if (!isPopupOpen) {
3529
3899
  return;
3530
3900
  }
@@ -3540,7 +3910,7 @@ function CopilotPopupView({
3540
3910
  window.addEventListener("keydown", handleKeyDown);
3541
3911
  return () => window.removeEventListener("keydown", handleKeyDown);
3542
3912
  }, [isPopupOpen, setModalOpen]);
3543
- useEffect(() => {
3913
+ useEffect16(() => {
3544
3914
  if (!isPopupOpen) {
3545
3915
  return;
3546
3916
  }
@@ -3549,7 +3919,7 @@ function CopilotPopupView({
3549
3919
  }, 200);
3550
3920
  return () => clearTimeout(focusTimer);
3551
3921
  }, [isPopupOpen]);
3552
- useEffect(() => {
3922
+ useEffect16(() => {
3553
3923
  if (!isPopupOpen || !clickOutsideToClose) {
3554
3924
  return;
3555
3925
  }
@@ -3574,10 +3944,10 @@ function CopilotPopupView({
3574
3944
  document.addEventListener("pointerdown", handlePointerDown);
3575
3945
  return () => document.removeEventListener("pointerdown", handlePointerDown);
3576
3946
  }, [isPopupOpen, clickOutsideToClose, setModalOpen]);
3577
- const headerElement = useMemo(() => renderSlot(header, CopilotModalHeader, {}), [header]);
3947
+ const headerElement = useMemo10(() => renderSlot(header, CopilotModalHeader, {}), [header]);
3578
3948
  const resolvedWidth = dimensionToCss(width, DEFAULT_POPUP_WIDTH);
3579
3949
  const resolvedHeight = dimensionToCss(height, DEFAULT_POPUP_HEIGHT);
3580
- const popupStyle = useMemo(
3950
+ const popupStyle = useMemo10(
3581
3951
  () => ({
3582
3952
  "--copilot-popup-width": resolvedWidth,
3583
3953
  "--copilot-popup-height": resolvedHeight,
@@ -3591,14 +3961,14 @@ function CopilotPopupView({
3591
3961
  [resolvedHeight, resolvedWidth]
3592
3962
  );
3593
3963
  const popupAnimationClass = isPopupOpen && !isAnimatingOut ? "pointer-events-auto translate-y-0 opacity-100 md:scale-100" : "pointer-events-none translate-y-4 opacity-0 md:translate-y-5 md:scale-[0.95]";
3594
- const popupContent = isRendered ? /* @__PURE__ */ jsx(
3964
+ const popupContent = isRendered ? /* @__PURE__ */ jsx23(
3595
3965
  "div",
3596
3966
  {
3597
3967
  className: cn(
3598
3968
  "fixed inset-0 z-[1200] flex max-w-full flex-col items-stretch",
3599
3969
  "md:inset-auto md:bottom-24 md:right-6 md:items-end md:gap-4"
3600
3970
  ),
3601
- children: /* @__PURE__ */ jsxs(
3971
+ children: /* @__PURE__ */ jsxs14(
3602
3972
  "div",
3603
3973
  {
3604
3974
  ref: containerRef,
@@ -3619,7 +3989,7 @@ function CopilotPopupView({
3619
3989
  style: popupStyle,
3620
3990
  children: [
3621
3991
  headerElement,
3622
- /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-hidden", "data-popup-chat": true, children: /* @__PURE__ */ jsx(
3992
+ /* @__PURE__ */ jsx23("div", { className: "flex-1 overflow-hidden", "data-popup-chat": true, children: /* @__PURE__ */ jsx23(
3623
3993
  CopilotChatView_default,
3624
3994
  {
3625
3995
  ...restProps,
@@ -3631,17 +4001,21 @@ function CopilotPopupView({
3631
4001
  )
3632
4002
  }
3633
4003
  ) : null;
3634
- return /* @__PURE__ */ jsxs(Fragment, { children: [
3635
- /* @__PURE__ */ jsx(CopilotChatToggleButton_default, {}),
4004
+ return /* @__PURE__ */ jsxs14(Fragment8, { children: [
4005
+ /* @__PURE__ */ jsx23(CopilotChatToggleButton_default, {}),
3636
4006
  popupContent
3637
4007
  ] });
3638
4008
  }
3639
4009
  CopilotPopupView.displayName = "CopilotPopupView";
4010
+
4011
+ // src/components/chat/CopilotSidebar.tsx
4012
+ import { useMemo as useMemo11 } from "react";
4013
+ import { jsx as jsx24 } from "react/jsx-runtime";
3640
4014
  function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
3641
- const SidebarViewOverride = useMemo(() => {
4015
+ const SidebarViewOverride = useMemo11(() => {
3642
4016
  const Component = (viewProps) => {
3643
4017
  const { header: viewHeader, width: viewWidth, ...restProps } = viewProps;
3644
- return /* @__PURE__ */ jsx(
4018
+ return /* @__PURE__ */ jsx24(
3645
4019
  CopilotSidebarView,
3646
4020
  {
3647
4021
  ...restProps,
@@ -3652,7 +4026,7 @@ function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
3652
4026
  };
3653
4027
  return Object.assign(Component, CopilotChatView_default);
3654
4028
  }, [header, width]);
3655
- return /* @__PURE__ */ jsx(
4029
+ return /* @__PURE__ */ jsx24(
3656
4030
  CopilotChat,
3657
4031
  {
3658
4032
  ...chatProps,
@@ -3662,6 +4036,10 @@ function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
3662
4036
  );
3663
4037
  }
3664
4038
  CopilotSidebar.displayName = "CopilotSidebar";
4039
+
4040
+ // src/components/chat/CopilotPopup.tsx
4041
+ import { useMemo as useMemo12 } from "react";
4042
+ import { jsx as jsx25 } from "react/jsx-runtime";
3665
4043
  function CopilotPopup({
3666
4044
  header,
3667
4045
  defaultOpen,
@@ -3670,7 +4048,7 @@ function CopilotPopup({
3670
4048
  clickOutsideToClose,
3671
4049
  ...chatProps
3672
4050
  }) {
3673
- const PopupViewOverride = useMemo(() => {
4051
+ const PopupViewOverride = useMemo12(() => {
3674
4052
  const Component = (viewProps) => {
3675
4053
  const {
3676
4054
  header: viewHeader,
@@ -3679,7 +4057,7 @@ function CopilotPopup({
3679
4057
  clickOutsideToClose: viewClickOutsideToClose,
3680
4058
  ...restProps
3681
4059
  } = viewProps;
3682
- return /* @__PURE__ */ jsx(
4060
+ return /* @__PURE__ */ jsx25(
3683
4061
  CopilotPopupView,
3684
4062
  {
3685
4063
  ...restProps,
@@ -3692,7 +4070,7 @@ function CopilotPopup({
3692
4070
  };
3693
4071
  return Object.assign(Component, CopilotChatView_default);
3694
4072
  }, [clickOutsideToClose, header, height, width]);
3695
- return /* @__PURE__ */ jsx(
4073
+ return /* @__PURE__ */ jsx25(
3696
4074
  CopilotChat,
3697
4075
  {
3698
4076
  ...chatProps,
@@ -3702,8 +4080,11 @@ function CopilotPopup({
3702
4080
  );
3703
4081
  }
3704
4082
  CopilotPopup.displayName = "CopilotPopup";
4083
+
4084
+ // src/types/defineToolCallRenderer.ts
4085
+ import { z as z2 } from "zod";
3705
4086
  function defineToolCallRenderer(def) {
3706
- const argsSchema = def.name === "*" && !def.args ? z.any() : def.args;
4087
+ const argsSchema = def.name === "*" && !def.args ? z2.any() : def.args;
3707
4088
  return {
3708
4089
  name: def.name,
3709
4090
  args: argsSchema,
@@ -3711,23 +4092,27 @@ function defineToolCallRenderer(def) {
3711
4092
  ...def.agentId ? { agentId: def.agentId } : {}
3712
4093
  };
3713
4094
  }
4095
+
4096
+ // src/components/WildcardToolCallRender.tsx
4097
+ import { useState as useState13 } from "react";
4098
+ import { jsx as jsx26, jsxs as jsxs15 } from "react/jsx-runtime";
3714
4099
  var WildcardToolCallRender = defineToolCallRenderer({
3715
4100
  name: "*",
3716
4101
  render: ({ args, result, name, status }) => {
3717
- const [isExpanded, setIsExpanded] = useState(false);
4102
+ const [isExpanded, setIsExpanded] = useState13(false);
3718
4103
  const statusString = String(status);
3719
4104
  const isActive = statusString === "inProgress" || statusString === "executing";
3720
4105
  const isComplete = statusString === "complete";
3721
4106
  const statusStyles = isActive ? "bg-amber-100 text-amber-800 dark:bg-amber-500/15 dark:text-amber-400" : isComplete ? "bg-emerald-100 text-emerald-800 dark:bg-emerald-500/15 dark:text-emerald-400" : "bg-zinc-100 text-zinc-800 dark:bg-zinc-700/40 dark:text-zinc-300";
3722
- return /* @__PURE__ */ jsx("div", { className: "mt-2 pb-2", children: /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-zinc-200/60 dark:border-zinc-800/60 bg-white/70 dark:bg-zinc-900/50 shadow-sm backdrop-blur p-4", children: [
3723
- /* @__PURE__ */ jsxs(
4107
+ return /* @__PURE__ */ jsx26("div", { className: "mt-2 pb-2", children: /* @__PURE__ */ jsxs15("div", { className: "rounded-xl border border-zinc-200/60 dark:border-zinc-800/60 bg-white/70 dark:bg-zinc-900/50 shadow-sm backdrop-blur p-4", children: [
4108
+ /* @__PURE__ */ jsxs15(
3724
4109
  "div",
3725
4110
  {
3726
4111
  className: "flex items-center justify-between gap-3 cursor-pointer",
3727
4112
  onClick: () => setIsExpanded(!isExpanded),
3728
4113
  children: [
3729
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 min-w-0", children: [
3730
- /* @__PURE__ */ jsx(
4114
+ /* @__PURE__ */ jsxs15("div", { className: "flex items-center gap-2 min-w-0", children: [
4115
+ /* @__PURE__ */ jsx26(
3731
4116
  "svg",
3732
4117
  {
3733
4118
  className: `h-4 w-4 text-zinc-500 dark:text-zinc-400 transition-transform ${isExpanded ? "rotate-90" : ""}`,
@@ -3735,7 +4120,7 @@ var WildcardToolCallRender = defineToolCallRenderer({
3735
4120
  viewBox: "0 0 24 24",
3736
4121
  strokeWidth: 2,
3737
4122
  stroke: "currentColor",
3738
- children: /* @__PURE__ */ jsx(
4123
+ children: /* @__PURE__ */ jsx26(
3739
4124
  "path",
3740
4125
  {
3741
4126
  strokeLinecap: "round",
@@ -3745,10 +4130,10 @@ var WildcardToolCallRender = defineToolCallRenderer({
3745
4130
  )
3746
4131
  }
3747
4132
  ),
3748
- /* @__PURE__ */ jsx("span", { className: "inline-block h-2 w-2 rounded-full bg-blue-500" }),
3749
- /* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium text-zinc-900 dark:text-zinc-100", children: name })
4133
+ /* @__PURE__ */ jsx26("span", { className: "inline-block h-2 w-2 rounded-full bg-blue-500" }),
4134
+ /* @__PURE__ */ jsx26("span", { className: "truncate text-sm font-medium text-zinc-900 dark:text-zinc-100", children: name })
3750
4135
  ] }),
3751
- /* @__PURE__ */ jsx(
4136
+ /* @__PURE__ */ jsx26(
3752
4137
  "span",
3753
4138
  {
3754
4139
  className: `inline-flex items-center rounded-full px-2 py-1 text-xs font-medium ${statusStyles}`,
@@ -3758,20 +4143,55 @@ var WildcardToolCallRender = defineToolCallRenderer({
3758
4143
  ]
3759
4144
  }
3760
4145
  ),
3761
- isExpanded && /* @__PURE__ */ jsxs("div", { className: "mt-3 grid gap-4", children: [
3762
- /* @__PURE__ */ jsxs("div", { children: [
3763
- /* @__PURE__ */ jsx("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Arguments" }),
3764
- /* @__PURE__ */ jsx("pre", { className: "mt-2 max-h-64 overflow-auto rounded-md bg-zinc-50 dark:bg-zinc-800/60 p-3 text-xs leading-relaxed text-zinc-800 dark:text-zinc-200 whitespace-pre-wrap break-words", children: JSON.stringify(args ?? {}, null, 2) })
4146
+ isExpanded && /* @__PURE__ */ jsxs15("div", { className: "mt-3 grid gap-4", children: [
4147
+ /* @__PURE__ */ jsxs15("div", { children: [
4148
+ /* @__PURE__ */ jsx26("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Arguments" }),
4149
+ /* @__PURE__ */ jsx26("pre", { className: "mt-2 max-h-64 overflow-auto rounded-md bg-zinc-50 dark:bg-zinc-800/60 p-3 text-xs leading-relaxed text-zinc-800 dark:text-zinc-200 whitespace-pre-wrap break-words", children: JSON.stringify(args ?? {}, null, 2) })
3765
4150
  ] }),
3766
- result !== void 0 && /* @__PURE__ */ jsxs("div", { children: [
3767
- /* @__PURE__ */ jsx("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Result" }),
3768
- /* @__PURE__ */ jsx("pre", { className: "mt-2 max-h-64 overflow-auto rounded-md bg-zinc-50 dark:bg-zinc-800/60 p-3 text-xs leading-relaxed text-zinc-800 dark:text-zinc-200 whitespace-pre-wrap break-words", children: typeof result === "string" ? result : JSON.stringify(result, null, 2) })
4151
+ result !== void 0 && /* @__PURE__ */ jsxs15("div", { children: [
4152
+ /* @__PURE__ */ jsx26("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Result" }),
4153
+ /* @__PURE__ */ jsx26("pre", { className: "mt-2 max-h-64 overflow-auto rounded-md bg-zinc-50 dark:bg-zinc-800/60 p-3 text-xs leading-relaxed text-zinc-800 dark:text-zinc-200 whitespace-pre-wrap break-words", children: typeof result === "string" ? result : JSON.stringify(result, null, 2) })
3769
4154
  ] })
3770
4155
  ] })
3771
4156
  ] }) });
3772
4157
  }
3773
4158
  });
3774
-
3775
- export { AudioRecorderError, CopilotChat, CopilotChatAssistantMessage_default as CopilotChatAssistantMessage, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, CopilotChatInput_default as CopilotChatInput, CopilotChatMessageView_default as CopilotChatMessageView, CopilotChatSuggestionPill_default as CopilotChatSuggestionPill, CopilotChatSuggestionView_default as CopilotChatSuggestionView, CopilotChatToggleButton, DefaultCloseIcon as CopilotChatToggleButtonCloseIcon, DefaultOpenIcon as CopilotChatToggleButtonOpenIcon, CopilotChatToolCallsView_default as CopilotChatToolCallsView, CopilotChatUserMessage_default as CopilotChatUserMessage, CopilotChatView_default as CopilotChatView, CopilotKitCoreReact, CopilotKitInspector, CopilotKitProvider, CopilotModalHeader, CopilotPopup, CopilotPopupView, CopilotSidebar, CopilotSidebarView, WildcardToolCallRender, defineToolCallRenderer, useAgent, useAgentContext, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useFrontendTool, useHumanInTheLoop, useRenderActivityMessage, useRenderCustomMessages, useRenderToolCall, useSuggestions };
3776
- //# sourceMappingURL=index.mjs.map
4159
+ export {
4160
+ AudioRecorderError,
4161
+ CopilotChat,
4162
+ CopilotChatAssistantMessage_default as CopilotChatAssistantMessage,
4163
+ CopilotChatAudioRecorder,
4164
+ CopilotChatConfigurationProvider,
4165
+ CopilotChatInput_default as CopilotChatInput,
4166
+ CopilotChatMessageView_default as CopilotChatMessageView,
4167
+ CopilotChatSuggestionPill_default as CopilotChatSuggestionPill,
4168
+ CopilotChatSuggestionView_default as CopilotChatSuggestionView,
4169
+ CopilotChatToggleButton,
4170
+ DefaultCloseIcon as CopilotChatToggleButtonCloseIcon,
4171
+ DefaultOpenIcon as CopilotChatToggleButtonOpenIcon,
4172
+ CopilotChatToolCallsView_default as CopilotChatToolCallsView,
4173
+ CopilotChatUserMessage_default as CopilotChatUserMessage,
4174
+ CopilotChatView_default as CopilotChatView,
4175
+ CopilotKitCoreReact,
4176
+ CopilotKitInspector,
4177
+ CopilotKitProvider,
4178
+ CopilotModalHeader,
4179
+ CopilotPopup,
4180
+ CopilotPopupView,
4181
+ CopilotSidebar,
4182
+ CopilotSidebarView,
4183
+ WildcardToolCallRender,
4184
+ defineToolCallRenderer,
4185
+ useAgent,
4186
+ useAgentContext,
4187
+ useConfigureSuggestions,
4188
+ useCopilotChatConfiguration,
4189
+ useCopilotKit,
4190
+ useFrontendTool,
4191
+ useHumanInTheLoop,
4192
+ useRenderActivityMessage,
4193
+ useRenderCustomMessages,
4194
+ useRenderToolCall,
4195
+ useSuggestions
4196
+ };
3777
4197
  //# sourceMappingURL=index.mjs.map