@copilotkit/react-core 1.56.4-canary.1777529757 → 1.56.4-canary.1777538870

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.
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
 
3
3
  (function(global, factory) {
4
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('./index.css'), require('@copilotkit/core'), require('@ag-ui/client'), require('react'), require('tailwind-merge'), require('lucide-react'), require('@copilotkit/shared'), require('react/jsx-runtime'), require('@radix-ui/react-slot'), require('class-variance-authority'), require('clsx'), require('@radix-ui/react-tooltip'), require('@radix-ui/react-dropdown-menu'), require('streamdown'), require('zod'), require('@lit-labs/react'), require('@copilotkit/a2ui-renderer'), require('zod-to-json-schema'), require('react-dom'), require('@tanstack/react-virtual'), require('use-stick-to-bottom')) :
5
- typeof define === 'function' && define.amd ? define(['exports', './index.css', '@copilotkit/core', '@ag-ui/client', 'react', 'tailwind-merge', 'lucide-react', '@copilotkit/shared', 'react/jsx-runtime', '@radix-ui/react-slot', 'class-variance-authority', 'clsx', '@radix-ui/react-tooltip', '@radix-ui/react-dropdown-menu', 'streamdown', 'zod', '@lit-labs/react', '@copilotkit/a2ui-renderer', 'zod-to-json-schema', 'react-dom', '@tanstack/react-virtual', 'use-stick-to-bottom'], factory) :
6
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.CopilotKitReactCoreV2 = {}), global.src_v2_index_css,global.CopilotKitCore,global.AgUIClient,global.React,global.tailwindMerge,global.lucideReact,global.CopilotKitShared,global.ReactJsxRuntime,global.RadixReactSlot,global.classVarianceAuthority,global.clsx,global.RadixReactTooltip,global.RadixReactDropdownMenu,global.streamdown,global.Zod,global.LitLabsReact,global.CopilotKitA2UIRenderer,global.zod_to_json_schema,global.ReactDOM,global._tanstack_react_virtual,global.useStickToBottom));
7
- })(this, function(exports, src_v2_index_css, _copilotkit_core, _ag_ui_client, react, tailwind_merge, lucide_react, _copilotkit_shared, react_jsx_runtime, _radix_ui_react_slot, class_variance_authority, clsx, _radix_ui_react_tooltip, _radix_ui_react_dropdown_menu, streamdown, zod, _lit_labs_react, _copilotkit_a2ui_renderer, zod_to_json_schema, react_dom, _tanstack_react_virtual, use_stick_to_bottom) {
4
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('./index.css'), require('@copilotkit/core'), require('@ag-ui/client'), require('react'), require('tailwind-merge'), require('lucide-react'), require('@copilotkit/shared'), require('react/jsx-runtime'), require('@radix-ui/react-slot'), require('class-variance-authority'), require('clsx'), require('@radix-ui/react-tooltip'), require('@radix-ui/react-dropdown-menu'), require('streamdown'), require('zod'), require('@lit-labs/react'), require('@copilotkit/a2ui-renderer'), require('zod-to-json-schema'), require('@tanstack/react-virtual'), require('react-dom'), require('use-stick-to-bottom')) :
5
+ typeof define === 'function' && define.amd ? define(['exports', './index.css', '@copilotkit/core', '@ag-ui/client', 'react', 'tailwind-merge', 'lucide-react', '@copilotkit/shared', 'react/jsx-runtime', '@radix-ui/react-slot', 'class-variance-authority', 'clsx', '@radix-ui/react-tooltip', '@radix-ui/react-dropdown-menu', 'streamdown', 'zod', '@lit-labs/react', '@copilotkit/a2ui-renderer', 'zod-to-json-schema', '@tanstack/react-virtual', 'react-dom', 'use-stick-to-bottom'], factory) :
6
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.CopilotKitReactCoreV2 = {}), global.src_v2_index_css,global.CopilotKitCore,global.AgUIClient,global.React,global.tailwindMerge,global.lucideReact,global.CopilotKitShared,global.ReactJsxRuntime,global.RadixReactSlot,global.classVarianceAuthority,global.clsx,global.RadixReactTooltip,global.RadixReactDropdownMenu,global.streamdown,global.Zod,global.LitLabsReact,global.CopilotKitA2UIRenderer,global.zod_to_json_schema,global._tanstack_react_virtual,global.ReactDOM,global.useStickToBottom));
7
+ })(this, function(exports, src_v2_index_css, _copilotkit_core, _ag_ui_client, react, tailwind_merge, lucide_react, _copilotkit_shared, react_jsx_runtime, _radix_ui_react_slot, class_variance_authority, clsx, _radix_ui_react_tooltip, _radix_ui_react_dropdown_menu, streamdown, zod, _lit_labs_react, _copilotkit_a2ui_renderer, zod_to_json_schema, _tanstack_react_virtual, react_dom, use_stick_to_bottom) {
8
8
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
9
9
  //#region \0rolldown/runtime.js
10
10
  var __create = Object.create;
@@ -5127,101 +5127,20 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
5127
5127
  CopilotChatAssistantMessage.RegenerateButton.displayName = "CopilotChatAssistantMessage.RegenerateButton";
5128
5128
  var CopilotChatAssistantMessage_default = CopilotChatAssistantMessage;
5129
5129
 
5130
- //#endregion
5131
- //#region src/v2/components/chat/Lightbox.tsx
5132
- function Lightbox({ onClose, children }) {
5133
- (0, react.useEffect)(() => {
5134
- const handleKey = (e) => {
5135
- if (e.key === "Escape") onClose();
5136
- };
5137
- document.addEventListener("keydown", handleKey);
5138
- return () => document.removeEventListener("keydown", handleKey);
5139
- }, [onClose]);
5140
- if (typeof document === "undefined") return null;
5141
- return (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5142
- className: "cpk:fixed cpk:inset-0 cpk:z-[9999] cpk:flex cpk:items-center cpk:justify-center cpk:bg-black/80 cpk:animate-fade-in",
5143
- onClick: onClose,
5144
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
5145
- onClick: onClose,
5146
- className: "cpk:absolute cpk:top-4 cpk:right-4 cpk:text-white cpk:bg-white/10 cpk:hover:bg-white/20 cpk:rounded-full cpk:w-10 cpk:h-10 cpk:flex cpk:items-center cpk:justify-center cpk:cursor-pointer cpk:border-none cpk:z-10",
5147
- "aria-label": "Close preview",
5148
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, { className: "cpk:w-5 cpk:h-5" })
5149
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5150
- onClick: (e) => e.stopPropagation(),
5151
- children
5152
- })]
5153
- }), document.body);
5154
- }
5155
- /**
5156
- * Hook that manages lightbox open/close and uses the View Transition API to
5157
- * morph the thumbnail into fullscreen content.
5158
- *
5159
- * The trick: `view-transition-name` must live on exactly ONE element at a time.
5160
- * - Old state (thumbnail visible): name is on the thumbnail.
5161
- * - New state (lightbox visible): name moves to the lightbox content.
5162
- * `flushSync` ensures React commits the DOM change synchronously inside the
5163
- * `startViewTransition` callback so the API can snapshot old → new correctly.
5164
- */
5165
- function useLightbox() {
5166
- const thumbnailRef = (0, react.useRef)(null);
5167
- const [open, setOpen] = (0, react.useState)(false);
5168
- const vtName = (0, react.useId)();
5169
- return {
5170
- thumbnailRef,
5171
- vtName,
5172
- open,
5173
- openLightbox: (0, react.useCallback)(() => {
5174
- const thumb = thumbnailRef.current;
5175
- const doc = document;
5176
- if (doc.startViewTransition && thumb) {
5177
- thumb.style.viewTransitionName = vtName;
5178
- doc.startViewTransition(() => {
5179
- thumb.style.viewTransitionName = "";
5180
- (0, react_dom.flushSync)(() => setOpen(true));
5181
- });
5182
- } else setOpen(true);
5183
- }, [vtName]),
5184
- closeLightbox: (0, react.useCallback)(() => {
5185
- const thumb = thumbnailRef.current;
5186
- const doc = document;
5187
- if (doc.startViewTransition && thumb) doc.startViewTransition(() => {
5188
- (0, react_dom.flushSync)(() => setOpen(false));
5189
- thumb.style.viewTransitionName = vtName;
5190
- }).finished.then(() => {
5191
- thumb.style.viewTransitionName = "";
5192
- }).catch(() => {
5193
- thumb.style.viewTransitionName = "";
5194
- });
5195
- else setOpen(false);
5196
- }, [vtName])
5197
- };
5198
- }
5199
-
5200
5130
  //#endregion
5201
5131
  //#region src/v2/components/chat/CopilotChatAttachmentRenderer.tsx
5202
5132
  const ImageAttachment = (0, react.memo)(function ImageAttachment({ src, className }) {
5203
5133
  const [error, setError] = (0, react.useState)(false);
5204
- const { thumbnailRef, vtName, open, openLightbox, closeLightbox } = useLightbox();
5205
5134
  if (error) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5206
5135
  className: cn("cpk:flex cpk:flex-col cpk:items-center cpk:justify-center cpk:rounded-lg cpk:bg-muted cpk:p-4 cpk:text-sm cpk:text-muted-foreground", className),
5207
5136
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "Failed to load image" })
5208
5137
  });
5209
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
5210
- ref: thumbnailRef,
5138
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
5211
5139
  src,
5212
5140
  alt: "Image attachment",
5213
- className: cn("cpk:max-w-[80px] cpk:max-h-[80px] cpk:w-auto cpk:h-auto cpk:rounded-xl cpk:object-cover cpk:cursor-pointer cpk:bg-muted", className),
5214
- onClick: openLightbox,
5141
+ className: cn("cpk:max-w-full cpk:h-auto cpk:rounded-lg", className),
5215
5142
  onError: () => setError(true)
5216
- }), open && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Lightbox, {
5217
- onClose: closeLightbox,
5218
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
5219
- style: { viewTransitionName: vtName },
5220
- src,
5221
- alt: "Image attachment",
5222
- className: "cpk:max-w-[90vw] cpk:max-h-[90vh] cpk:object-contain cpk:rounded-lg"
5223
- })
5224
- })] });
5143
+ });
5225
5144
  });
5226
5145
  const AudioAttachment = (0, react.memo)(function AudioAttachment({ src, filename, className }) {
5227
5146
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -5347,15 +5266,15 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
5347
5266
  "data-message-id": message.id,
5348
5267
  ...props,
5349
5268
  children: [
5269
+ BoundMessageRenderer,
5350
5270
  mediaParts.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
5351
- className: "cpk:flex cpk:flex-row cpk:flex-wrap cpk:justify-end cpk:gap-2 cpk:mb-2",
5271
+ className: "cpk:flex cpk:flex-col cpk:items-end cpk:gap-2 cpk:mt-2",
5352
5272
  children: mediaParts.map((part, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotChatAttachmentRenderer, {
5353
5273
  type: part.type,
5354
5274
  source: part.source,
5355
5275
  filename: getFilename(part)
5356
5276
  }, index))
5357
5277
  }),
5358
- BoundMessageRenderer,
5359
5278
  BoundToolbar
5360
5279
  ]
5361
5280
  });
@@ -6073,6 +5992,73 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
6073
5992
  case "document": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DocumentPreview, { attachment });
6074
5993
  }
6075
5994
  }
5995
+ function Lightbox({ onClose, children }) {
5996
+ (0, react.useEffect)(() => {
5997
+ const handleKey = (e) => {
5998
+ if (e.key === "Escape") onClose();
5999
+ };
6000
+ document.addEventListener("keydown", handleKey);
6001
+ return () => document.removeEventListener("keydown", handleKey);
6002
+ }, [onClose]);
6003
+ if (typeof document === "undefined") return null;
6004
+ return (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6005
+ className: "cpk:fixed cpk:inset-0 cpk:z-[9999] cpk:flex cpk:items-center cpk:justify-center cpk:bg-black/80 cpk:animate-fade-in",
6006
+ onClick: onClose,
6007
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
6008
+ onClick: onClose,
6009
+ className: "cpk:absolute cpk:top-4 cpk:right-4 cpk:text-white cpk:bg-white/10 cpk:hover:bg-white/20 cpk:rounded-full cpk:w-10 cpk:h-10 cpk:flex cpk:items-center cpk:justify-center cpk:cursor-pointer cpk:border-none cpk:z-10",
6010
+ "aria-label": "Close preview",
6011
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, { className: "cpk:w-5 cpk:h-5" })
6012
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6013
+ onClick: (e) => e.stopPropagation(),
6014
+ children
6015
+ })]
6016
+ }), document.body);
6017
+ }
6018
+ /**
6019
+ * Hook that manages lightbox open/close and uses the View Transition API to
6020
+ * morph the thumbnail into fullscreen content.
6021
+ *
6022
+ * The trick: `view-transition-name` must live on exactly ONE element at a time.
6023
+ * - Old state (thumbnail visible): name is on the thumbnail.
6024
+ * - New state (lightbox visible): name moves to the lightbox content.
6025
+ * `flushSync` ensures React commits the DOM change synchronously inside the
6026
+ * `startViewTransition` callback so the API can snapshot old → new correctly.
6027
+ */
6028
+ function useLightbox() {
6029
+ const thumbnailRef = (0, react.useRef)(null);
6030
+ const [open, setOpen] = (0, react.useState)(false);
6031
+ const vtName = (0, react.useId)();
6032
+ return {
6033
+ thumbnailRef,
6034
+ vtName,
6035
+ open,
6036
+ openLightbox: (0, react.useCallback)(() => {
6037
+ const thumb = thumbnailRef.current;
6038
+ const doc = document;
6039
+ if (doc.startViewTransition && thumb) {
6040
+ thumb.style.viewTransitionName = vtName;
6041
+ doc.startViewTransition(() => {
6042
+ thumb.style.viewTransitionName = "";
6043
+ (0, react_dom.flushSync)(() => setOpen(true));
6044
+ });
6045
+ } else setOpen(true);
6046
+ }, []),
6047
+ closeLightbox: (0, react.useCallback)(() => {
6048
+ const thumb = thumbnailRef.current;
6049
+ const doc = document;
6050
+ if (doc.startViewTransition && thumb) doc.startViewTransition(() => {
6051
+ (0, react_dom.flushSync)(() => setOpen(false));
6052
+ thumb.style.viewTransitionName = vtName;
6053
+ }).finished.then(() => {
6054
+ thumb.style.viewTransitionName = "";
6055
+ }).catch(() => {
6056
+ thumb.style.viewTransitionName = "";
6057
+ });
6058
+ else setOpen(false);
6059
+ }, [])
6060
+ };
6061
+ }
6076
6062
  function ImagePreview({ attachment }) {
6077
6063
  const src = (0, _copilotkit_shared.getSourceUrl)(attachment.source);
6078
6064
  const { thumbnailRef, vtName, open, openLightbox, closeLightbox } = useLightbox();
@@ -6412,17 +6398,14 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
6412
6398
  });
6413
6399
  }
6414
6400
  function CopilotChatView({ messageView, input, scrollView, suggestionView, welcomeScreen, messages = [], autoScroll = true, isRunning = false, suggestions, suggestionLoadingIndexes, onSelectSuggestion, onSubmitMessage, onStop, inputMode, inputValue, onInputChange, onStartTranscribe, onCancelTranscribe, onFinishTranscribe, onFinishTranscribeWithAudio, attachments, onRemoveAttachment, onAddFile, dragOver, onDragOver, onDragLeave, onDrop, isConnecting = false, hasExplicitThreadId = false, disclaimer, children, className, ...props }) {
6415
- const [inputContainerEl, setInputContainerEl] = (0, react.useState)(null);
6401
+ const inputContainerRef = (0, react.useRef)(null);
6416
6402
  const [inputContainerHeight, setInputContainerHeight] = (0, react.useState)(0);
6417
6403
  const [isResizing, setIsResizing] = (0, react.useState)(false);
6418
6404
  const resizeTimeoutRef = (0, react.useRef)(null);
6419
6405
  const { isKeyboardOpen, keyboardHeight, availableHeight } = useKeyboardHeight();
6420
6406
  (0, react.useEffect)(() => {
6421
- const element = inputContainerEl;
6422
- if (!element) {
6423
- setInputContainerHeight(0);
6424
- return;
6425
- }
6407
+ const element = inputContainerRef.current;
6408
+ if (!element) return;
6426
6409
  const resizeObserver = new ResizeObserver((entries) => {
6427
6410
  for (const entry of entries) {
6428
6411
  const newHeight = entry.contentRect.height;
@@ -6445,7 +6428,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
6445
6428
  resizeObserver.disconnect();
6446
6429
  if (resizeTimeoutRef.current) clearTimeout(resizeTimeoutRef.current);
6447
6430
  };
6448
- }, [inputContainerEl]);
6431
+ }, []);
6449
6432
  const BoundMessageView = renderSlot(messageView, CopilotChatMessageView, {
6450
6433
  messages,
6451
6434
  isRunning
@@ -6468,7 +6451,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
6468
6451
  bottomAnchored: true,
6469
6452
  ...disclaimer !== void 0 ? { disclaimer } : {}
6470
6453
  });
6471
- const hasSuggestions = !isConnecting && Array.isArray(suggestions) && suggestions.length > 0;
6454
+ const hasSuggestions = !isConnecting && !isRunning && Array.isArray(suggestions) && suggestions.length > 0;
6472
6455
  const BoundSuggestionView = hasSuggestions ? renderSlot(suggestionView, CopilotChatSuggestionView, {
6473
6456
  suggestions,
6474
6457
  loadingIndexes: suggestionLoadingIndexes,
@@ -6556,7 +6539,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
6556
6539
  dragOver && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropOverlay, {}),
6557
6540
  BoundScrollView,
6558
6541
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6559
- ref: setInputContainerEl,
6542
+ ref: inputContainerRef,
6560
6543
  "data-testid": "copilot-input-overlay",
6561
6544
  className: "cpk:absolute cpk:bottom-0 cpk:left-0 cpk:right-0 cpk:z-20 cpk:pointer-events-none",
6562
6545
  children: [attachments && attachments.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {