@copilotkit/react-core 2.0.0-rc.26 → 2.0.0-rc.28

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.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_MarkdownSurfaces = require('./MarkdownSurfaces-v9AplTEj.cjs');
4
+ const require_MarkdownSurfaces = require('./MarkdownSurfaces-BbrHcSHN.cjs');
5
5
  let _copilotkit_core = require("@copilotkit/core");
6
6
  let react = require("react");
7
7
  react = require_MarkdownSurfaces.__toESM(react);
@@ -30,6 +30,22 @@ let _copilotkit_web_components_threads_drawer = require("@copilotkit/web-compone
30
30
  let _ag_ui_core_schemas = require("@ag-ui/core/schemas");
31
31
  let _ag_ui_client = require("@ag-ui/client");
32
32
 
33
+ //#region src/lib/use-latest-ref.ts
34
+ const useIsomorphicLayoutEffect = typeof window === "undefined" ? react.useEffect : react.useLayoutEffect;
35
+ /**
36
+ * A ref that holds the latest `value`, for callbacks that run after render
37
+ * (event handlers, controller callbacks). The ref changes in a layout effect,
38
+ * not during render, so a render that React throws away leaves it alone.
39
+ */
40
+ function useLatestRef(value) {
41
+ const ref = (0, react.useRef)(value);
42
+ useIsomorphicLayoutEffect(() => {
43
+ ref.current = value;
44
+ });
45
+ return ref;
46
+ }
47
+
48
+ //#endregion
33
49
  //#region src/components/ui/button.tsx
34
50
  const variantClasses = {
35
51
  default: "cpk-button-default",
@@ -224,14 +240,6 @@ const SLASH_MENU_ITEM_HEIGHT_PX = 40;
224
240
  * starts with "/".
225
241
  */
226
242
  function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning = false, onStartTranscribe, onCancelTranscribe, onFinishTranscribe, onFinishTranscribeWithAudio, onAddFile, onChange, value, toolsMenu, autoFocus = false, positioning = "static", keyboardHeight = 0, containerRef, showDisclaimer, bottomAnchored = false, textArea, sendButton, startTranscribeButton, cancelTranscribeButton, finishTranscribeButton, addMenuButton, audioRecorder, disclaimer, children, className, ...props }) {
227
- const isControlled = value !== void 0;
228
- const [internalValue, setInternalValue] = (0, react.useState)(() => value ?? "");
229
- (0, react.useEffect)(() => {
230
- if (!isControlled && value !== void 0) setInternalValue(value);
231
- }, [isControlled, value]);
232
- const resolvedValue = isControlled ? value ?? "" : internalValue;
233
- const [commandQuery, setCommandQuery] = (0, react.useState)(null);
234
- const [slashHighlightIndex, setSlashHighlightIndex] = (0, react.useState)(0);
235
243
  const inputRef = (0, react.useRef)(null);
236
244
  const gridRef = (0, react.useRef)(null);
237
245
  const addButtonContainerRef = (0, react.useRef)(null);
@@ -249,18 +257,33 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
249
257
  const layout = (0, react.useSyncExternalStore)(autosize.subscribe, autosize.getSnapshot, autosize.getSnapshot);
250
258
  const isExpanded = mode === "input" && layout === "expanded";
251
259
  const previousModalStateRef = (0, react.useRef)(void 0);
252
- const commandItems = (0, react.useMemo)(() => {
253
- const menu = toolsMenu ?? [];
254
- return (0, _copilotkit_core.ɵflattenCommandItems)(onAddFile ? [{
255
- label: labels.chatInputToolbarAddButtonLabel,
256
- action: onAddFile
257
- }, ...menu] : menu);
258
- }, [
260
+ const onChangeRef = useLatestRef(onChange);
261
+ const [composer] = (0, react.useState)(() => new _copilotkit_core.ɵComposerController({
262
+ initialValue: value ?? "",
263
+ onChange: (next) => onChangeRef.current?.(next)
264
+ }));
265
+ const { value: composerValue, slashQuery: commandQuery, slashCommands: filteredCommands, slashHighlightIndex } = (0, react.useSyncExternalStore)(composer.subscribe, composer.getSnapshot, composer.getSnapshot);
266
+ const resolvedValue = value ?? composerValue;
267
+ const menu = (0, react.useMemo)(() => (0, _copilotkit_core.ɵnormalizeToolsMenu)(toolsMenu, onAddFile ? {
268
+ label: labels.chatInputToolbarAddButtonLabel,
269
+ action: onAddFile
270
+ } : void 0), [
259
271
  labels.chatInputToolbarAddButtonLabel,
260
272
  onAddFile,
261
273
  toolsMenu
262
274
  ]);
263
- const filteredCommands = (0, react.useMemo)(() => (0, _copilotkit_core.ɵfilterCommands)(commandItems, commandQuery), [commandItems, commandQuery]);
275
+ (0, react.useLayoutEffect)(() => {
276
+ composer.setInputs({
277
+ value,
278
+ mode,
279
+ menu
280
+ });
281
+ }, [
282
+ composer,
283
+ value,
284
+ mode,
285
+ menu
286
+ ]);
264
287
  (0, react.useEffect)(() => {
265
288
  if (!autoFocus) {
266
289
  previousModalStateRef.current = config?.isModalOpen;
@@ -269,48 +292,18 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
269
292
  if (config?.isModalOpen && !previousModalStateRef.current) inputRef.current?.focus({ preventScroll: true });
270
293
  previousModalStateRef.current = config?.isModalOpen;
271
294
  }, [config?.isModalOpen, autoFocus]);
272
- const previousCommandQueryRef = (0, react.useRef)(null);
273
- (0, react.useEffect)(() => {
274
- if (commandQuery !== null && commandQuery !== previousCommandQueryRef.current && filteredCommands.length > 0) setSlashHighlightIndex(0);
275
- previousCommandQueryRef.current = commandQuery;
276
- }, [commandQuery, filteredCommands.length]);
277
- (0, react.useEffect)(() => {
278
- setSlashHighlightIndex((index) => commandQuery === null ? 0 : (0, _copilotkit_core.ɵclampSlashIndex)(index, filteredCommands.length));
279
- }, [commandQuery, filteredCommands]);
280
- (0, react.useEffect)(() => {
281
- const recorder = audioRecorderRef.current;
282
- if (!recorder) return;
283
- if (mode === "transcribe") recorder.start().catch(console.error);
284
- else if (recorder.state === "recording") recorder.stop().catch(console.error);
285
- }, [mode]);
286
295
  (0, react.useEffect)(() => {
287
- if (mode !== "input") setCommandQuery(null);
296
+ (0, _copilotkit_core.ɵsyncRecorderToMode)(audioRecorderRef.current, mode);
288
297
  }, [mode]);
289
- const updateSlashState = (0, react.useCallback)((value) => {
290
- setCommandQuery((0, _copilotkit_core.ɵparseSlashQuery)(value, commandItems.length > 0));
291
- }, [commandItems.length]);
292
- (0, react.useEffect)(() => {
293
- updateSlashState(resolvedValue);
294
- }, [resolvedValue, updateSlashState]);
295
298
  const handleChange = (e) => {
296
- const nextValue = e.target.value;
297
- if (!isControlled) setInternalValue(nextValue);
298
- onChange?.(nextValue);
299
- updateSlashState(nextValue);
299
+ composer.setValue(e.target.value);
300
300
  };
301
- const clearInputValue = (0, react.useCallback)(() => {
302
- if (!isControlled) setInternalValue("");
303
- if (onChange) onChange("");
304
- }, [isControlled, onChange]);
305
301
  const runCommand = (0, react.useCallback)((item) => {
306
- clearInputValue();
307
- item.action?.();
308
- setCommandQuery(null);
309
- setSlashHighlightIndex(0);
302
+ composer.runCommand(item);
310
303
  requestAnimationFrame(() => {
311
304
  inputRef.current?.focus();
312
305
  });
313
- }, [clearInputValue]);
306
+ }, [composer]);
314
307
  const composerInput = {
315
308
  mode,
316
309
  isRunning,
@@ -320,43 +313,22 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
320
313
  };
321
314
  const { isProcessing, action: buttonAction, disabled: buttonDisabled } = (0, _copilotkit_core.ɵcomposerButtonState)(composerInput);
322
315
  const handleKeyDown = (e) => {
323
- if (e.nativeEvent.isComposing || e.keyCode === 229) return;
324
- const slash = (0, _copilotkit_core.ɵresolveSlashKey)(e, {
325
- query: mode === "input" ? commandQuery : null,
326
- commands: filteredCommands,
327
- highlightIndex: slashHighlightIndex
328
- });
329
- if (slash.type !== "none") e.preventDefault();
330
- switch (slash.type) {
331
- case "highlight":
332
- setSlashHighlightIndex(slash.index);
333
- return;
334
- case "run":
335
- runCommand(slash.command);
336
- return;
337
- case "close":
338
- setCommandQuery(null);
339
- return;
340
- case "none": break;
341
- }
342
- if (e.key === "Enter" && !e.shiftKey) e.preventDefault();
343
- const action = (0, _copilotkit_core.ɵresolveComposerKey)({
316
+ const { preventDefault, action } = composer.keyDown({
344
317
  key: e.key,
345
318
  shiftKey: e.shiftKey,
346
319
  isComposing: e.nativeEvent.isComposing,
347
320
  keyCode: e.keyCode
348
321
  }, composerInput);
349
- if (action === "stop") onStop?.();
322
+ if (preventDefault) e.preventDefault();
323
+ if (action === "command") requestAnimationFrame(() => {
324
+ inputRef.current?.focus();
325
+ });
326
+ else if (action === "stop") onStop?.();
350
327
  else if (action === "send") send();
351
328
  };
352
329
  const send = () => {
353
330
  if (!onSubmitMessage) return;
354
- const trimmed = resolvedValue.trim();
355
- if (!trimmed) return;
356
- onSubmitMessage(trimmed);
357
- if (!isControlled) setInternalValue("");
358
- onChange?.("");
359
- if (inputRef.current) inputRef.current.focus();
331
+ if (composer.submit(onSubmitMessage, { value: resolvedValue })) inputRef.current?.focus();
360
332
  };
361
333
  const BoundTextArea = require_MarkdownSurfaces.renderSlot(textArea, CopilotChatInput.TextArea, {
362
334
  ref: inputRef,
@@ -403,7 +375,10 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
403
375
  toolsMenu
404
376
  });
405
377
  const BoundDisclaimer = require_MarkdownSurfaces.renderSlot(disclaimer, CopilotChatInput.Disclaimer, {});
406
- const shouldShowDisclaimer = showDisclaimer ?? positioning === "absolute";
378
+ const shouldShowDisclaimer = (0, _copilotkit_core.ɵshowsComposerDisclaimer)({
379
+ showDisclaimer,
380
+ positioning
381
+ });
407
382
  const handleContainerClick = (e) => {
408
383
  const target = e.target;
409
384
  if (target.tagName !== "BUTTON" && !target.closest("button") && inputRef.current && mode === "input") inputRef.current.focus();
@@ -416,7 +391,7 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
416
391
  mode
417
392
  ]);
418
393
  (0, react.useEffect)(() => () => autosize.dispose(), [autosize]);
419
- const slashMenuVisible = commandQuery !== null && commandItems.length > 0;
394
+ const slashMenuVisible = commandQuery !== null;
420
395
  (0, react.useEffect)(() => {
421
396
  if (!slashMenuVisible || slashHighlightIndex < 0) return;
422
397
  (slashMenuRef.current?.querySelector(`[data-slash-index="${slashHighlightIndex}"]`))?.scrollIntoView({ block: "nearest" });
@@ -440,7 +415,7 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
440
415
  "data-active": isActive ? "true" : void 0,
441
416
  "data-slash-index": index,
442
417
  className: "cpk-chat-input-slash-menu-item",
443
- onMouseEnter: () => setSlashHighlightIndex(index),
418
+ onMouseEnter: () => composer.highlight(index),
444
419
  onMouseDown: (event) => {
445
420
  event.preventDefault();
446
421
  runCommand(item);
@@ -601,22 +576,10 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
601
576
  const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
602
577
  const [mounted, setMounted] = (0, react.useState)(false);
603
578
  (0, react.useEffect)(() => setMounted(true), []);
604
- const menuItems = (0, react.useMemo)(() => {
605
- const items = [];
606
- if (onAddFile) items.push({
607
- label: labels.chatInputToolbarAddButtonLabel,
608
- action: onAddFile
609
- });
610
- if (toolsMenu && toolsMenu.length > 0) {
611
- if (items.length > 0) items.push("-");
612
- for (const item of toolsMenu) if (item === "-") {
613
- if (items.length === 0 || items[items.length - 1] === "-") continue;
614
- items.push(item);
615
- } else items.push(item);
616
- while (items.length > 0 && items[items.length - 1] === "-") items.pop();
617
- }
618
- return items;
619
- }, [
579
+ const menuItems = (0, react.useMemo)(() => (0, _copilotkit_core.ɵnormalizeToolsMenu)(toolsMenu, onAddFile ? {
580
+ label: labels.chatInputToolbarAddButtonLabel,
581
+ action: onAddFile
582
+ } : void 0), [
620
583
  onAddFile,
621
584
  toolsMenu,
622
585
  labels.chatInputToolbarAddButtonLabel
@@ -860,7 +823,7 @@ function ɵuseOwnedCore(ref, create) {
860
823
 
861
824
  //#endregion
862
825
  //#region package.json
863
- var version$1 = "2.0.0-rc.26";
826
+ var version$1 = "2.0.0-rc.28";
864
827
 
865
828
  //#endregion
866
829
  //#region src/components/CopilotKitInspector.tsx
@@ -1490,8 +1453,9 @@ function SurfaceMessageProcessor({ operations, onRendered }) {
1490
1453
  * duplicate skeleton on retries / multi-call generations and a skeleton that
1491
1454
  * lingered after the surface painted — both fixed by retiring it here.
1492
1455
  *
1493
- * Users can still override with their own `useRenderTool({ name: "render_a2ui" })`
1494
- * (hook-based entries take priority over this prop-based registration).
1456
+ * It is a built-in renderer, so a `renderToolCalls` entry or a
1457
+ * `useRenderTool({ name: "render_a2ui" })` hook replaces it, and it never
1458
+ * removes the app's renderers. It is removed when A2UI turns off.
1495
1459
  */
1496
1460
  function A2UIBuiltInToolCallRenderer() {
1497
1461
  const { copilotkit } = (0, _copilotkit_react_core_context.useCopilotKit)();
@@ -1501,8 +1465,7 @@ function A2UIBuiltInToolCallRenderer() {
1501
1465
  args: zod.any(),
1502
1466
  render: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, {})
1503
1467
  });
1504
- const existing = copilotkit._renderToolCalls ?? [];
1505
- copilotkit.setRenderToolCalls([...existing.filter((rc) => rc.name !== _copilotkit_core.ɵRENDER_A2UI_TOOL_NAME), renderer]);
1468
+ return copilotkit.ɵaddBuiltInRenderToolCall(renderer);
1506
1469
  }, [copilotkit]);
1507
1470
  return null;
1508
1471
  }
@@ -3243,7 +3206,10 @@ var CopilotKitCoreReact = class extends _copilotkit_core.CopilotKitCore {
3243
3206
  get renderActivityMessages() {
3244
3207
  return this._renderers.activity;
3245
3208
  }
3246
- /** Prop and hook renderers merged; a hook renderer wins over a prop one. */
3209
+ /**
3210
+ * Prop, hook and built-in renderers merged. For one name and agentId, a
3211
+ * hook renderer wins over a prop one, and both win over a built-in one.
3212
+ */
3247
3213
  get renderToolCalls() {
3248
3214
  return this._renderers.toolCalls;
3249
3215
  }
@@ -3262,6 +3228,16 @@ var CopilotKitCoreReact = class extends _copilotkit_core.CopilotKitCore {
3262
3228
  removeHookRenderToolCall(name, agentId) {
3263
3229
  this._renderers.removeHookToolCall(name, agentId);
3264
3230
  }
3231
+ /**
3232
+ * @internal Add a renderer for a tool a built-in feature owns (A2UI,
3233
+ * generative UI). Prop and hook renderers with the same name and agent win
3234
+ * over it, and `setRenderToolCalls` never removes it.
3235
+ *
3236
+ * @returns A function that removes the renderer.
3237
+ */
3238
+ ɵaddBuiltInRenderToolCall(entry) {
3239
+ return this._renderers.addBuiltInToolCall(entry);
3240
+ }
3265
3241
  notifyRenderersChanged(kind) {
3266
3242
  this.notifySubscribers((subscriber) => {
3267
3243
  const reactSubscriber = subscriber;
@@ -3339,13 +3315,14 @@ const SameOriginMCPAppsActivityRenderer = (props) => /* @__PURE__ */ (0, react_j
3339
3315
  ...props,
3340
3316
  allowSameOriginFallback: true
3341
3317
  });
3342
- function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
3318
+ function useStableArrayProp(prop, name) {
3343
3319
  const empty = (0, react.useMemo)(() => [], []);
3344
3320
  const value = prop ?? empty;
3345
3321
  const initial = (0, react.useRef)(value);
3346
3322
  (0, react.useEffect)(() => {
3347
- if (warningMessage && value !== initial.current && (isMeaningfulChange ? isMeaningfulChange(initial.current, value) : true)) console.error(warningMessage);
3348
- }, [value, warningMessage]);
3323
+ const warning = (0, _copilotkit_core.ɵstableArrayPropWarning)(name, initial.current, value);
3324
+ if (warning) console.error(warning);
3325
+ }, [value, name]);
3349
3326
  return value;
3350
3327
  }
3351
3328
  /** Provide a shared core instance and synchronize runtime, tool, and UI configuration. */
@@ -3370,8 +3347,10 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3370
3347
  runtimeEnabled: runtimeOpenGenUIEnabled,
3371
3348
  configured: !!openGenerativeUI
3372
3349
  });
3373
- const a2uiCatalogProvided = !!a2ui?.catalog;
3374
- const a2uiActive = runtimeA2UIEnabled || a2uiCatalogProvided;
3350
+ const a2uiActive = (0, _copilotkit_core.ɵresolveA2UIActivation)({
3351
+ runtimeEnabled: runtimeA2UIEnabled,
3352
+ hasCatalog: !!a2ui?.catalog
3353
+ }).active;
3375
3354
  const generativeUIActive = !!generativeUI?.ui;
3376
3355
  const runtimeLicenseStatus = runtimeInfo?.licenseStatus;
3377
3356
  const runtimeEntitlements = runtimeInfo?.runtimeEntitlements;
@@ -3389,9 +3368,9 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3389
3368
  inspectorVisible,
3390
3369
  requestInspectorOpen
3391
3370
  ]);
3392
- const renderToolCallsList = useStableArrayProp(renderToolCalls, _copilotkit_core.ɵSTABLE_ARRAY_WARNINGS.renderToolCalls, _copilotkit_core.ɵtoolRendererShapeChanged);
3393
- const renderCustomMessagesList = useStableArrayProp(renderCustomMessages, _copilotkit_core.ɵSTABLE_ARRAY_WARNINGS.renderCustomMessages);
3394
- const renderActivityMessagesList = useStableArrayProp(renderActivityMessages, _copilotkit_core.ɵSTABLE_ARRAY_WARNINGS.renderActivityMessages);
3371
+ const renderToolCallsList = useStableArrayProp(renderToolCalls, "renderToolCalls");
3372
+ const renderCustomMessagesList = useStableArrayProp(renderCustomMessages, "renderCustomMessages");
3373
+ const renderActivityMessagesList = useStableArrayProp(renderActivityMessages, "renderActivityMessages");
3395
3374
  const copilotkitRef = (0, react.useRef)(null);
3396
3375
  const rawCatalog = a2ui?.catalog;
3397
3376
  const filteredCatalog = (0, react.useMemo)(() => {
@@ -3401,27 +3380,31 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3401
3380
  return (0, _copilotkit_a2ui_renderer.filterCatalog)(rawCatalog, (name) => core ? core.isCatalogComponentEnabled(name) : true);
3402
3381
  }, [rawCatalog, catalogToggleVersion]);
3403
3382
  const mcpAppsAllowSameOrigin = mcpApps?.allowSameOriginFallback === true;
3404
- const builtInActivityRenderers = (0, react.useMemo)(() => {
3405
- const renderers = [{
3406
- activityType: _copilotkit_mcp_apps_renderer_activity.MCPAppsActivityType,
3407
- content: _copilotkit_mcp_apps_renderer_activity.MCPAppsActivityContentSchema,
3408
- render: mcpAppsAllowSameOrigin ? SameOriginMCPAppsActivityRenderer : MCPAppsActivityRenderer
3409
- }];
3410
- if (openGenUIActive) renderers.push({
3411
- activityType: OpenGenerativeUIActivityType,
3412
- content: OpenGenerativeUIContentSchema,
3413
- render: OpenGenerativeUIActivityRenderer
3414
- });
3415
- if (a2uiActive) renderers.unshift(createA2UIMessageRenderer({
3383
+ const allActivityRenderers = (0, react.useMemo)(() => (0, _copilotkit_core.ɵassembleActivityRenderers)({
3384
+ app: renderActivityMessagesList,
3385
+ a2ui: a2uiActive ? createA2UIMessageRenderer({
3416
3386
  theme: a2ui?.theme ?? _copilotkit_a2ui_renderer.viewerTheme,
3417
3387
  catalog: filteredCatalog,
3418
3388
  loadingComponent: a2ui?.loadingComponent,
3419
3389
  recovery: a2ui?.recovery,
3420
3390
  onAction: a2ui?.onAction
3421
- }));
3422
- if (generativeUIActive) renderers.push(require_MarkdownSurfaces.createGenerativeUIActivityRenderer(), require_MarkdownSurfaces.createGenerativeUIFunctionCallActivityRenderer());
3423
- return renderers;
3424
- }, [
3391
+ }) : void 0,
3392
+ builtIns: [
3393
+ {
3394
+ activityType: _copilotkit_mcp_apps_renderer_activity.MCPAppsActivityType,
3395
+ content: _copilotkit_mcp_apps_renderer_activity.MCPAppsActivityContentSchema,
3396
+ render: mcpAppsAllowSameOrigin ? SameOriginMCPAppsActivityRenderer : MCPAppsActivityRenderer
3397
+ },
3398
+ openGenUIActive && {
3399
+ activityType: OpenGenerativeUIActivityType,
3400
+ content: OpenGenerativeUIContentSchema,
3401
+ render: OpenGenerativeUIActivityRenderer
3402
+ },
3403
+ generativeUIActive && require_MarkdownSurfaces.createGenerativeUIActivityRenderer(),
3404
+ generativeUIActive && require_MarkdownSurfaces.createGenerativeUIFunctionCallActivityRenderer()
3405
+ ]
3406
+ }), [
3407
+ renderActivityMessagesList,
3425
3408
  a2uiActive,
3426
3409
  openGenUIActive,
3427
3410
  generativeUIActive,
@@ -3429,9 +3412,6 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3429
3412
  filteredCatalog,
3430
3413
  mcpAppsAllowSameOrigin
3431
3414
  ]);
3432
- const allActivityRenderers = (0, react.useMemo)(() => {
3433
- return [...renderActivityMessagesList, ...builtInActivityRenderers];
3434
- }, [renderActivityMessagesList, builtInActivityRenderers]);
3435
3415
  const resolvedConfig = (0, react.useMemo)(() => (0, _copilotkit_core.ɵresolveProviderConfig)({
3436
3416
  runtimeUrl,
3437
3417
  publicApiKey,
@@ -3466,31 +3446,9 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3466
3446
  }, []);
3467
3447
  const headersInput = isHeadersBuilder ? stableHeadersBuilder : headersProp;
3468
3448
  const headersSource = (0, react.useMemo)(() => (0, _copilotkit_core.ɵwithHeaderDefaults)(headersInput, (0, _copilotkit_core.ɵpublicKeyHeaderDefaults)(resolvedPublicKey)), [headersInput, resolvedPublicKey]);
3469
- const frontendToolsList = useStableArrayProp(frontendTools, _copilotkit_core.ɵSTABLE_ARRAY_WARNINGS.frontendTools);
3470
- const humanInTheLoopList = useStableArrayProp(humanInTheLoop, _copilotkit_core.ɵSTABLE_ARRAY_WARNINGS.humanInTheLoop);
3471
- const sandboxFunctionsList = useStableArrayProp(openGenerativeUI?.sandboxFunctions, _copilotkit_core.ɵSTABLE_ARRAY_WARNINGS.sandboxFunctions);
3472
- const processedHumanInTheLoopTools = (0, react.useMemo)(() => {
3473
- const processedTools = [];
3474
- const processedRenderToolCalls = [];
3475
- const registry = () => copilotkitRef.current.ɵhumanInTheLoop;
3476
- humanInTheLoopList.forEach((tool) => {
3477
- const { render, ...config } = tool;
3478
- processedTools.push((0, _copilotkit_core.ɵbuildHumanInTheLoopTool)(config, registry));
3479
- if (render) {
3480
- const RenderComponent = (props) => (0, react.createElement)(render, (0, _copilotkit_core.ɵhitlRenderProps)(props, tool, registry()));
3481
- processedRenderToolCalls.push({
3482
- name: tool.name,
3483
- args: tool.parameters,
3484
- render: RenderComponent,
3485
- ...tool.agentId && { agentId: tool.agentId }
3486
- });
3487
- }
3488
- });
3489
- return {
3490
- tools: processedTools,
3491
- renderToolCalls: processedRenderToolCalls
3492
- };
3493
- }, [humanInTheLoopList]);
3449
+ const frontendToolsList = useStableArrayProp(frontendTools, "frontendTools");
3450
+ const humanInTheLoopList = useStableArrayProp(humanInTheLoop, "humanInTheLoop");
3451
+ const sandboxFunctionsList = useStableArrayProp(openGenerativeUI?.sandboxFunctions, "sandboxFunctions");
3494
3452
  const builtInFrontendTools = (0, react.useMemo)(() => {
3495
3453
  if (!openGenUIActive) return [];
3496
3454
  return [{
@@ -3498,36 +3456,30 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3498
3456
  render: OpenGenerativeUIToolRenderer
3499
3457
  }];
3500
3458
  }, [openGenUIActive]);
3501
- const allTools = (0, react.useMemo)(() => {
3502
- const tools = [];
3503
- tools.push(...frontendToolsList);
3504
- tools.push(...builtInFrontendTools);
3505
- tools.push(...processedHumanInTheLoopTools.tools);
3506
- return tools;
3507
- }, [
3459
+ const humanInTheLoopAssembly = (0, react.useMemo)(() => (0, _copilotkit_core.ɵassembleHumanInTheLoop)({
3460
+ humanInTheLoop: humanInTheLoopList,
3461
+ humanInTheLoopRegistry: () => copilotkitRef.current.ɵhumanInTheLoop,
3462
+ wrapHumanInTheLoopRender: (render, tool, registry) => (props) => (0, react.createElement)(render, (0, _copilotkit_core.ɵhitlRenderProps)(props, tool, registry()))
3463
+ }), [humanInTheLoopList]);
3464
+ const allTools = (0, react.useMemo)(() => (0, _copilotkit_core.ɵassembleProviderTools)({
3465
+ frontendTools: frontendToolsList,
3466
+ builtInFrontendTools,
3467
+ humanInTheLoop: humanInTheLoopAssembly
3468
+ }), [
3508
3469
  frontendToolsList,
3509
3470
  builtInFrontendTools,
3510
- processedHumanInTheLoopTools
3471
+ humanInTheLoopAssembly
3511
3472
  ]);
3512
- const allRenderToolCalls = (0, react.useMemo)(() => {
3513
- const combined = [...renderToolCallsList];
3514
- [...frontendToolsList, ...builtInFrontendTools].forEach((tool) => {
3515
- if (tool.render) {
3516
- const args = tool.parameters || (tool.name === "*" ? _copilotkit_shared.ɵanySchema : void 0);
3517
- if (args) combined.push({
3518
- name: tool.name,
3519
- args,
3520
- render: tool.render
3521
- });
3522
- }
3523
- });
3524
- combined.push(...processedHumanInTheLoopTools.renderToolCalls);
3525
- return combined;
3526
- }, [
3473
+ const allRenderToolCalls = (0, react.useMemo)(() => (0, _copilotkit_core.ɵassembleProviderToolRenderers)({
3474
+ renderToolCalls: renderToolCallsList,
3475
+ frontendTools: frontendToolsList,
3476
+ builtInFrontendTools,
3477
+ humanInTheLoop: humanInTheLoopAssembly
3478
+ }), [
3527
3479
  renderToolCallsList,
3528
3480
  frontendToolsList,
3529
3481
  builtInFrontendTools,
3530
- processedHumanInTheLoopTools
3482
+ humanInTheLoopAssembly
3531
3483
  ]);
3532
3484
  const copilotkit = ɵuseOwnedCore(copilotkitRef, () => new CopilotKitCoreReact({
3533
3485
  runtimeUrl: resolvedConfig.runtimeUrl,
@@ -3642,13 +3594,10 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3642
3594
  const designSkill = openGenerativeUI?.designSkill;
3643
3595
  (0, react.useLayoutEffect)(() => {
3644
3596
  if (!copilotkit || !openGenUIActive) return;
3645
- const ids = (0, _copilotkit_core.ɵbuildOpenGenerativeUIContexts)({
3597
+ return (0, _copilotkit_core.ɵaddOpenGenerativeUIContexts)(copilotkit, {
3646
3598
  designSkill,
3647
3599
  sandboxFunctions: sandboxFunctionsList
3648
- }).map((entry) => copilotkit.addContext(entry));
3649
- return () => {
3650
- for (const id of ids) copilotkit.removeContext(id);
3651
- };
3600
+ });
3652
3601
  }, [
3653
3602
  copilotkit,
3654
3603
  designSkill,
@@ -3749,7 +3698,10 @@ function useRenderCustomMessages() {
3749
3698
  //#region src/hooks/use-render-activity-message.tsx
3750
3699
  function useRenderActivityMessage() {
3751
3700
  const { copilotkit } = (0, _copilotkit_react_core_context.useCopilotKit)();
3752
- const agentId = require_MarkdownSurfaces.useCopilotChatConfiguration()?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
3701
+ const agentId = (0, _copilotkit_core.ɵresolveAgentId)({
3702
+ chatAgentId: require_MarkdownSurfaces.useCopilotChatConfiguration()?.agentId,
3703
+ providerAgentId: (0, _copilotkit_react_core_context.useDefaultAgentId)()
3704
+ });
3753
3705
  const renderers = copilotkit.renderActivityMessages;
3754
3706
  const findRenderer = (0, react.useCallback)((activityType) => (0, _copilotkit_core.ɵfindActivityRenderer)(renderers, {
3755
3707
  activityType,
@@ -3890,21 +3842,7 @@ function useFrontendTool(tool, deps) {
3890
3842
  const { copilotkit } = (0, _copilotkit_react_core_context.useCopilotKit)();
3891
3843
  const depsVersion = useDepsVersion(deps);
3892
3844
  (0, react.useLayoutEffect)(() => {
3893
- const name = tool.name;
3894
- if (copilotkit.getTool({
3895
- toolName: name,
3896
- agentId: tool.agentId
3897
- })) console.warn(`Tool '${name}' already exists for agent '${tool.agentId || "global"}'. Overriding with latest registration.`);
3898
- const unregister = copilotkit.addTool(tool);
3899
- if (tool.render) copilotkit.addHookRenderToolCall({
3900
- name,
3901
- args: tool.parameters,
3902
- agentId: tool.agentId,
3903
- render: tool.render
3904
- });
3905
- return () => {
3906
- unregister();
3907
- };
3845
+ return (0, _copilotkit_core.ɵregisterFrontendTools)(copilotkit, [tool], (renderer) => copilotkit.addHookRenderToolCall(renderer));
3908
3846
  }, [
3909
3847
  tool.name,
3910
3848
  tool.available,
@@ -3974,30 +3912,7 @@ function useFrontendTools(tools, deps) {
3974
3912
  const toolList = tools ?? EMPTY_TOOLS;
3975
3913
  const extraDeps = deps ?? EMPTY_DEPS;
3976
3914
  (0, react.useLayoutEffect)(() => {
3977
- const deduped = /* @__PURE__ */ new Map();
3978
- for (const tool of toolList) {
3979
- const key = `${tool.agentId ?? ""}:${tool.name}`;
3980
- if (deduped.has(key)) console.warn(`Tool '${tool.name}' is listed more than once for agent '${tool.agentId || "global"}' in the same useFrontendTools call. Using the last entry.`);
3981
- deduped.set(key, tool);
3982
- }
3983
- const registered = [...deduped.values()];
3984
- const unregisters = [];
3985
- for (const tool of registered) {
3986
- if (copilotkit.getTool({
3987
- toolName: tool.name,
3988
- agentId: tool.agentId
3989
- })) console.warn(`Tool '${tool.name}' already exists for agent '${tool.agentId || "global"}'. Overriding with latest registration.`);
3990
- unregisters.push(copilotkit.addTool(tool));
3991
- if (tool.render) copilotkit.addHookRenderToolCall({
3992
- name: tool.name,
3993
- args: tool.parameters,
3994
- agentId: tool.agentId,
3995
- render: tool.render
3996
- });
3997
- }
3998
- return () => {
3999
- for (const unregister of unregisters) unregister();
4000
- };
3915
+ return (0, _copilotkit_core.ɵregisterFrontendTools)(copilotkit, toolList, (renderer) => copilotkit.addHookRenderToolCall(renderer));
4001
3916
  }, [
4002
3917
  JSON.stringify(toolList.map((tool) => [
4003
3918
  tool.name,
@@ -4521,41 +4436,11 @@ function CopilotChatToolCallGroup({ calls, renderCall, appearance = "card", isAc
4521
4436
  //#endregion
4522
4437
  //#region src/hooks/use-default-render-tool.tsx
4523
4438
  /**
4524
- * Module-level dedup set so an unknown status value only emits a console
4525
- * warning the FIRST time we encounter it. Otherwise a stuck/unmapped status
4526
- * would log on every re-render (potentially many per second).
4527
- */
4528
- const warnedUnknownStatuses = /* @__PURE__ */ new Set();
4529
- /**
4530
- * Map a {@link ToolCallStatus} enum value to the documented string-union
4531
- * status the {@link DefaultRenderProps} contract exposes. Unknown / future
4532
- * enum members log a warning (once per distinct value) and fall back to
4533
- * `"inProgress"`.
4534
- */
4535
- function mapToolCallStatus(status) {
4536
- const normalized = (0, _copilotkit_core.ɵnormalizeToolCallStatus)(status);
4537
- if (normalized !== "unknown") return normalized;
4538
- const key = String(status);
4539
- if (!warnedUnknownStatuses.has(key)) {
4540
- warnedUnknownStatuses.add(key);
4541
- console.warn(`[CopilotKit] Unknown ToolCallStatus "${key}" in default tool-call renderer; falling back to "inProgress".`);
4542
- }
4543
- return "inProgress";
4544
- }
4545
- /**
4546
4439
  * Convert the framework-internal renderer props (`args`, enum status) into
4547
4440
  * the documented {@link DefaultRenderProps} shape (`parameters`, string-union
4548
4441
  * status) so a user `config.render` always sees the documented contract.
4549
4442
  */
4550
- function adaptRendererProps(props) {
4551
- return {
4552
- name: props.name,
4553
- toolCallId: props.toolCallId,
4554
- parameters: props.args,
4555
- status: mapToolCallStatus(props.status),
4556
- result: props.result
4557
- };
4558
- }
4443
+ const adaptRendererProps = _copilotkit_core.ɵadaptDefaultToolCallRenderProps;
4559
4444
  /**
4560
4445
  * Registers a wildcard (`"*"`) tool-call renderer via `useRenderTool`.
4561
4446
  *
@@ -4852,7 +4737,11 @@ function useSuggestions({ agentId } = {}) {
4852
4737
  const { copilotkit } = (0, _copilotkit_react_core_context.useCopilotKit)();
4853
4738
  const config = require_MarkdownSurfaces.useCopilotChatConfiguration();
4854
4739
  const providerAgentId = (0, _copilotkit_react_core_context.useDefaultAgentId)();
4855
- const resolvedAgentId = (0, react.useMemo)(() => agentId ?? config?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID, [
4740
+ const resolvedAgentId = (0, react.useMemo)(() => (0, _copilotkit_core.ɵresolveAgentId)({
4741
+ agentId,
4742
+ chatAgentId: config?.agentId,
4743
+ providerAgentId
4744
+ }), [
4856
4745
  agentId,
4857
4746
  config?.agentId,
4858
4747
  providerAgentId
@@ -4895,7 +4784,10 @@ function useConfigureSuggestions(config, deps) {
4895
4784
  const { copilotkit } = (0, _copilotkit_react_core_context.useCopilotKit)();
4896
4785
  const chatConfig = require_MarkdownSurfaces.useCopilotChatConfiguration();
4897
4786
  const providerAgentId = (0, _copilotkit_react_core_context.useDefaultAgentId)();
4898
- const chatAgentId = chatConfig?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
4787
+ const chatAgentId = (0, _copilotkit_core.ɵresolveAgentId)({
4788
+ chatAgentId: chatConfig?.agentId,
4789
+ providerAgentId
4790
+ });
4899
4791
  const extraDeps = deps ?? [];
4900
4792
  const bindingRef = (0, react.useRef)(null);
4901
4793
  const latestRef = (0, react.useRef)({
@@ -5676,8 +5568,11 @@ function useMessageFeedback(message) {
5676
5568
  function useFeedbackComment(controls) {
5677
5569
  const latestControls = (0, react.useRef)(controls);
5678
5570
  latestControls.current = controls;
5679
- const [controller] = (0, react.useState)(() => new _copilotkit_core.ɵFeedbackCommentController({ getControls: () => latestControls.current }));
5680
5571
  const inputRef = (0, react.useRef)(null);
5572
+ const [controller] = (0, react.useState)(() => new _copilotkit_core.ɵFeedbackCommentController({
5573
+ getControls: () => latestControls.current,
5574
+ getInput: () => inputRef.current
5575
+ }));
5681
5576
  const state = (0, react.useSyncExternalStore)(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
5682
5577
  (0, react.useEffect)(() => controller.dispose, [controller]);
5683
5578
  return {
@@ -5690,7 +5585,16 @@ function useFeedbackComment(controls) {
5690
5585
  leave: controller.leave,
5691
5586
  setEditing: controller.setEditing,
5692
5587
  close: controller.close,
5693
- returnFocus: controller.returnFocus
5588
+ returnFocus: controller.returnFocus,
5589
+ rate: controller.rate,
5590
+ thumb: controller.thumb,
5591
+ findAnchor: controller.findAnchor,
5592
+ sync: controller.sync,
5593
+ focusField: controller.focusField,
5594
+ submit: controller.submit,
5595
+ popoverEscape: controller.popoverEscape,
5596
+ popoverKeyDown: controller.popoverKeyDown,
5597
+ popoverFocusLeave: controller.popoverFocusLeave
5694
5598
  };
5695
5599
  }
5696
5600
 
@@ -5763,32 +5667,6 @@ function BoundInspectorButton({ inspectorButton, messageId, openInspector, ...pr
5763
5667
  })
5764
5668
  });
5765
5669
  }
5766
- /** Whether focus came from the keyboard; a pointer click also focuses buttons. */
5767
- function isFocusVisible(element) {
5768
- try {
5769
- return element.matches(":focus-visible");
5770
- } catch {
5771
- return false;
5772
- }
5773
- }
5774
- const HIDDEN_TOO = {
5775
- checkVisibilityCSS: true,
5776
- visibilityProperty: true
5777
- };
5778
- const FOCUSABLE = [
5779
- "a[href]",
5780
- "button:not([disabled])",
5781
- "input:not([disabled])",
5782
- "select:not([disabled])",
5783
- "textarea:not([disabled])",
5784
- "[tabindex]"
5785
- ].map((selector) => `${selector}:not([tabindex="-1"]):not([data-radix-focus-guard])`).join(", ");
5786
- /** Approximately the element Tab reaches after `element`, outside `skip`. */
5787
- function nextFocusable(element, skip) {
5788
- const all = Array.from(element.ownerDocument.querySelectorAll(FOCUSABLE)).filter((candidate) => candidate === element || !skip?.contains(candidate) && !candidate.closest("[hidden], [inert]"));
5789
- const index = all.indexOf(element);
5790
- return index === -1 ? null : all[index + 1] ?? null;
5791
- }
5792
5670
  /**
5793
5671
  * The comment popover of a rated message, pointing at the chosen thumb. Kept
5794
5672
  * apart so only it, not the whole message, follows chat configuration.
@@ -5797,19 +5675,12 @@ function nextFocusable(element, skip) {
5797
5675
  * from its start returns to the thumb, Tab from its end moves on to the
5798
5676
  * control after the thumb, and Enter or Escape inside it returns to the thumb.
5799
5677
  */
5800
- function FeedbackCommentPopover({ feedbackComment, comment, savedComment, rating, anchor, messageId }) {
5678
+ function FeedbackCommentPopover({ feedbackComment, comment, savedComment, rating, messageId }) {
5801
5679
  const labels = require_MarkdownSurfaces.useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
5802
5680
  const contentRef = (0, react.useRef)(null);
5803
- const focusInside = () => contentRef.current?.contains(document.activeElement) ?? false;
5804
- const { focusRequest, takeFocusRequest, inputRef } = comment;
5805
- const focusField = (0, react.useCallback)(() => {
5806
- if (inputRef.current && takeFocusRequest()) inputRef.current.focus();
5807
- }, [inputRef, takeFocusRequest]);
5681
+ const anchor = (0, react.useMemo)(() => ({ current: comment.anchor }), [comment.anchor]);
5682
+ const { focusRequest, focusField } = comment;
5808
5683
  (0, react.useEffect)(() => focusField(), [focusRequest, focusField]);
5809
- /** Whether `target` is a thumb of this message, whose click decides itself. */
5810
- const isOwnThumb = (target) => {
5811
- return (target instanceof Element ? target.closest("[data-copilotkit-rating]") : null)?.closest("[data-message-id]")?.getAttribute("data-message-id") === messageId;
5812
- };
5813
5684
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Popover, {
5814
5685
  open: comment.open,
5815
5686
  onOpenChange: (open) => {
@@ -5828,24 +5699,12 @@ function FeedbackCommentPopover({ feedbackComment, comment, savedComment, rating
5828
5699
  },
5829
5700
  onCloseAutoFocus: (event) => event.preventDefault(),
5830
5701
  onInteractOutside: (event) => {
5831
- if (isOwnThumb(event.target)) event.preventDefault();
5702
+ if ((0, _copilotkit_core.ɵisOwnFeedbackThumb)(event.target, messageId)) event.preventDefault();
5832
5703
  },
5833
5704
  onEscapeKeyDown: (event) => {
5834
- const returnFocus = focusInside();
5835
- if (returnFocus) event.stopPropagation();
5836
- comment.close({ save: false });
5837
- if (returnFocus) comment.returnFocus(anchor.current);
5838
- },
5839
- onKeyDown: (event) => {
5840
- if (event.key !== "Tab") return;
5841
- const focusables = Array.from(contentRef.current?.querySelectorAll(FOCUSABLE) ?? []);
5842
- if (!(event.shiftKey ? document.activeElement === focusables[0] : document.activeElement === focusables[focusables.length - 1]) || !anchor.current?.isConnected) return;
5843
- event.preventDefault();
5844
- const target = event.shiftKey ? anchor.current : nextFocusable(anchor.current, contentRef.current) ?? anchor.current;
5845
- comment.close();
5846
- if (target === anchor.current) comment.returnFocus(target);
5847
- else target.focus();
5705
+ if (comment.popoverEscape(contentRef.current)) event.stopPropagation();
5848
5706
  },
5707
+ onKeyDown: (event) => comment.popoverKeyDown(event, contentRef.current),
5849
5708
  onPointerEnter: () => comment.enter("pointer"),
5850
5709
  onPointerLeave: () => comment.leave("pointer"),
5851
5710
  className: "cpk-assistant-message-feedback-popover",
@@ -5854,15 +5713,9 @@ function FeedbackCommentPopover({ feedbackComment, comment, savedComment, rating
5854
5713
  savedComment,
5855
5714
  inputRef: comment.inputRef,
5856
5715
  onChange: comment.setDraft,
5857
- onSubmit: () => {
5858
- comment.close();
5859
- comment.returnFocus(anchor.current);
5860
- },
5716
+ onSubmit: comment.submit,
5861
5717
  onEditingChange: comment.setEditing,
5862
- onLeave: (next) => {
5863
- if (next && (contentRef.current?.contains(next) || isOwnThumb(next))) return;
5864
- comment.leave();
5865
- }
5718
+ onLeave: (next) => comment.popoverFocusLeave(next, contentRef.current, messageId)
5866
5719
  }) }, rating)
5867
5720
  })]
5868
5721
  });
@@ -5877,73 +5730,29 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
5877
5730
  const showInspectorShortcut = isInspectorEnabled && !shortcutsHidden;
5878
5731
  const feedback = useMessageFeedback(message);
5879
5732
  const comment = useFeedbackComment(feedback);
5880
- const rating = feedback?.feedback?.rating;
5881
5733
  const root = (0, react.useRef)(null);
5882
- const commentAnchor = (0, react.useRef)(null);
5883
- const commentRating = (0, react.useRef)(rating);
5884
- (0, react.useLayoutEffect)(() => {
5885
- if (comment.open && !commentAnchor.current?.isConnected && rating) commentAnchor.current = root.current?.querySelector(`[data-copilotkit-rating="${rating}"]`) ?? root.current?.querySelector("button[aria-pressed=\"true\"]") ?? null;
5886
- });
5734
+ (0, react.useLayoutEffect)(() => comment.findAnchor(root.current));
5887
5735
  /**
5888
- * Thumbs are toggles: a new rating is saved and opens its comment, and
5889
- * clicking the chosen thumb again removes the rating. A keyboard click
5890
- * (`detail` 0) moves focus into the comment, as there is no pointer.
5891
- * Custom thumb slots may call `onClick` without an event.
5892
- *
5893
- * @returns Whether the app's handler should run: true for a new rating and
5894
- * whenever this chat does not record ratings, false when one is removed.
5736
+ * A thumb click. A keyboard click (`detail` 0) moves focus into the
5737
+ * comment; custom thumb slots may call `onClick` without an event.
5895
5738
  */
5896
- const rate = (value, event) => {
5897
- if (!feedback) return true;
5898
- if (rating === value) {
5899
- comment.close({ save: false });
5900
- feedback.clear();
5901
- return false;
5902
- }
5903
- feedback.rate(value);
5904
- commentRating.current = value;
5905
- commentAnchor.current = event?.currentTarget ?? null;
5906
- comment.show({
5907
- comment: "",
5908
- focus: event?.detail === 0
5909
- });
5910
- return true;
5911
- };
5739
+ const rate = (value, event) => comment.rate(value, {
5740
+ target: event?.currentTarget ?? null,
5741
+ keyboard: event?.detail === 0
5742
+ });
5912
5743
  /** Props that let the chosen thumb open and point at its comment. */
5913
5744
  const thumbFeedbackProps = (value) => {
5914
- if (!feedback) return {};
5915
- const thumb = { "data-copilotkit-rating": value };
5916
- if (rating !== value) return {
5917
- ...thumb,
5918
- "aria-pressed": false
5919
- };
5920
- const enter = (target, via) => {
5921
- if (!comment.open) commentRating.current = value;
5922
- commentAnchor.current = target;
5923
- comment.enter(via);
5924
- };
5745
+ const thumb = comment.thumb(value);
5746
+ if (!thumb) return {};
5747
+ const { handlers } = thumb;
5748
+ if (!handlers) return thumb.attributes;
5925
5749
  return {
5926
- ...thumb,
5927
- "aria-pressed": true,
5928
- "aria-haspopup": "dialog",
5929
- "aria-expanded": comment.open,
5930
- onPointerEnter: (event) => {
5931
- if (event.pointerType !== "touch") enter(event.currentTarget, "pointer");
5932
- },
5933
- onPointerLeave: (event) => {
5934
- if (event.pointerType !== "touch") comment.leave("pointer");
5935
- },
5936
- onFocus: (event) => {
5937
- if (isFocusVisible(event.currentTarget)) enter(event.currentTarget, "focus");
5938
- },
5939
- onBlur: () => comment.leave(),
5940
- onKeyDown: (event) => {
5941
- const input = comment.inputRef.current;
5942
- if (event.key === "Tab" && !event.shiftKey && comment.open && input && input.checkVisibility?.(HIDDEN_TOO) !== false) {
5943
- event.preventDefault();
5944
- input.focus();
5945
- }
5946
- }
5750
+ ...thumb.attributes,
5751
+ onPointerEnter: handlers.pointerEnter,
5752
+ onPointerLeave: handlers.pointerLeave,
5753
+ onFocus: handlers.focus,
5754
+ onBlur: handlers.blur,
5755
+ onKeyDown: handlers.keyDown
5947
5756
  };
5948
5757
  };
5949
5758
  const boundMarkdownRenderer = require_MarkdownSurfaces.renderSlot(markdownRenderer, DefaultMarkdownRenderer, {
@@ -5997,23 +5806,21 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
5997
5806
  isRunning: !!isRunning,
5998
5807
  isLatest: isLatestAssistantMessage
5999
5808
  });
6000
- const { open: commentOpen, close: closeComment } = comment;
5809
+ const rating = feedback?.feedback?.rating;
5810
+ const { open: commentOpen, sync: syncComment } = comment;
6001
5811
  (0, react.useEffect)(() => {
6002
- if (!commentOpen) return;
6003
- if (rating !== commentRating.current) closeComment({ save: false });
6004
- else if (!shouldShowToolbar) closeComment();
5812
+ syncComment({ showsToolbar: shouldShowToolbar });
6005
5813
  }, [
6006
5814
  commentOpen,
6007
5815
  shouldShowToolbar,
6008
5816
  rating,
6009
- closeComment
5817
+ syncComment
6010
5818
  ]);
6011
5819
  const feedbackComment = feedback?.feedback && shouldShowToolbar && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FeedbackCommentPopover, {
6012
5820
  feedbackComment: feedbackCommentSlot,
6013
5821
  comment,
6014
5822
  savedComment: feedback.feedback.comment ?? "",
6015
5823
  rating: feedback.feedback.rating,
6016
- anchor: commentAnchor,
6017
5824
  messageId: message.id
6018
5825
  });
6019
5826
  if (children) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -6619,33 +6426,17 @@ function CopilotChatReasoningMessage({ message, messages, isRunning, isLatest: i
6619
6426
  const isLatest = isLatestProp ?? messages?.[messages.length - 1]?.id === message.id;
6620
6427
  const isStreaming = !!(isRunning && isLatest);
6621
6428
  const hasContent = !!(message.content && message.content.length > 0);
6622
- const startTimeRef = (0, react.useRef)(null);
6623
- const [elapsed, setElapsed] = (0, react.useState)(0);
6429
+ const [disclosure] = (0, react.useState)(() => new _copilotkit_core.ɵReasoningDisclosure({ isStreaming }));
6430
+ const { isOpen, elapsedSeconds: elapsed } = (0, react.useSyncExternalStore)(disclosure.subscribe, disclosure.getSnapshot, disclosure.getSnapshot);
6624
6431
  (0, react.useEffect)(() => {
6625
- if (isStreaming && startTimeRef.current === null) startTimeRef.current = Date.now();
6626
- if (!isStreaming && startTimeRef.current !== null) {
6627
- setElapsed((Date.now() - startTimeRef.current) / 1e3);
6628
- return;
6629
- }
6630
- if (!isStreaming) return;
6631
- const timer = setInterval(() => {
6632
- if (startTimeRef.current !== null) setElapsed((Date.now() - startTimeRef.current) / 1e3);
6633
- }, 1e3);
6634
- return () => clearInterval(timer);
6635
- }, [isStreaming]);
6636
- const [isOpen, setIsOpen] = (0, react.useState)(isStreaming);
6637
- const userToggledRef = (0, react.useRef)(false);
6638
- (0, react.useEffect)(() => {
6639
- if (isStreaming) {
6640
- userToggledRef.current = false;
6641
- setIsOpen(true);
6642
- } else if (!userToggledRef.current) setIsOpen(false);
6643
- }, [isStreaming]);
6644
- const handleToggle = hasContent ? () => {
6645
- userToggledRef.current = true;
6646
- setIsOpen((prev) => !prev);
6647
- } : void 0;
6648
- const label = isStreaming ? labels.reasoningMessageThinkingLabel : (0, _copilotkit_core.ɵformatLabel)(labels.reasoningMessageThoughtForLabel, { duration: (0, _copilotkit_core.ɵformatReasoningDurationLabel)(elapsed, labels) });
6432
+ disclosure.setStreaming(isStreaming);
6433
+ }, [disclosure, isStreaming]);
6434
+ (0, react.useEffect)(() => disclosure.dispose, [disclosure]);
6435
+ const handleToggle = hasContent ? disclosure.toggle : void 0;
6436
+ const label = (0, _copilotkit_core.ɵgetReasoningHeaderLabel)({
6437
+ isStreaming,
6438
+ elapsedSeconds: elapsed
6439
+ }, labels);
6649
6440
  const boundHeader = require_MarkdownSurfaces.renderSlot(header, CopilotChatReasoningMessage.Header, {
6650
6441
  isOpen,
6651
6442
  label,
@@ -7362,6 +7153,7 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
7362
7153
  const { renderActivityMessage } = useRenderActivityMessage();
7363
7154
  const { copilotkit, showIntelligenceIndicator = true } = (0, _copilotkit_react_core_context.useCopilotKit)();
7364
7155
  const config = require_MarkdownSurfaces.useCopilotChatConfiguration();
7156
+ const providerAgentId = (0, _copilotkit_react_core_context.useDefaultAgentId)();
7365
7157
  const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
7366
7158
  (0, react.useEffect)(() => {
7367
7159
  if (!config?.agentId) return;
@@ -7382,12 +7174,11 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
7382
7174
  } });
7383
7175
  return () => subscription.unsubscribe();
7384
7176
  }, [copilotkit]);
7385
- const getStateSnapshotForMessage = (messageId) => {
7386
- if (!config) return void 0;
7387
- const resolvedRunId = copilotkit.getRunIdForMessage(config.agentId, config.threadId, messageId) ?? copilotkit.getRunIdsForThread(config.agentId, config.threadId).slice(-1)[0];
7388
- if (!resolvedRunId) return void 0;
7389
- return copilotkit.getStateByRun(config.agentId, config.threadId, resolvedRunId);
7390
- };
7177
+ const getStateSnapshotForMessage = (messageId) => config ? (0, _copilotkit_core.ɵgetMessageRunStateSnapshot)(copilotkit, {
7178
+ agentId: config.agentId,
7179
+ threadId: config.threadId,
7180
+ messageId
7181
+ }) : void 0;
7391
7182
  const deduplicatedMessages = (0, react.useMemo)(() => (0, _copilotkit_core.ɵdeduplicateMessages)(messages), [messages]);
7392
7183
  const transformedMessages = (0, react.useMemo)(() => transformMessages ? transformMessages(deduplicatedMessages) : deduplicatedMessages, [deduplicatedMessages, transformMessages]);
7393
7184
  const rows = (0, react.useMemo)(() => groupMessages ? groupMessages(transformedMessages) : transformedMessages.map(messageRow), [transformedMessages, groupMessages]);
@@ -7641,7 +7432,7 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
7641
7432
  const nextRect = pendingRect;
7642
7433
  pendingRect = void 0;
7643
7434
  if (!instance.scrollElement?.clientHeight) return;
7644
- measuredWidthRef.current = instance.scrollElement?.clientWidth ?? nextRect.width;
7435
+ measuredWidthRef.current = instance.scrollElement.clientWidth;
7645
7436
  if (resizeAnchorRef.current) resizeAnchorRef.current.ready = true;
7646
7437
  instance.getTotalSize();
7647
7438
  measuredRef.current = {
@@ -7758,7 +7549,10 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
7758
7549
  const intelligenceTurnId = showIntelligenceIndicator ? intelligenceTurnAnchors.get(message.id) : void 0;
7759
7550
  if (intelligenceTurnId !== void 0) elements.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(IntelligenceIndicator, {
7760
7551
  message,
7761
- agentId: config?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID,
7552
+ agentId: (0, _copilotkit_core.ɵresolveAgentId)({
7553
+ chatAgentId: config?.agentId,
7554
+ providerAgentId
7555
+ }),
7762
7556
  intelligenceIndicator
7763
7557
  }, `intelligence-${intelligenceTurnId}`));
7764
7558
  return elements.filter(Boolean);
@@ -8279,36 +8073,18 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
8279
8073
  const [inputContainerEl, setInputContainerEl] = (0, react.useState)(null);
8280
8074
  const [inputContainerHeight, setInputContainerHeight] = (0, react.useState)(0);
8281
8075
  const [isResizing, setIsResizing] = (0, react.useState)(false);
8282
- const resizeTimeoutRef = (0, react.useRef)(null);
8283
8076
  const { isKeyboardOpen, keyboardHeight } = useKeyboardHeight();
8284
8077
  (0, react.useEffect)(() => {
8285
8078
  const element = inputContainerEl;
8286
8079
  if (!element) {
8287
8080
  setInputContainerHeight(0);
8081
+ setIsResizing(false);
8288
8082
  return;
8289
8083
  }
8290
- const resizeObserver = new ResizeObserver((entries) => {
8291
- for (const entry of entries) {
8292
- const newHeight = entry.contentRect.height;
8293
- setInputContainerHeight((prevHeight) => {
8294
- if (newHeight !== prevHeight) {
8295
- setIsResizing(true);
8296
- if (resizeTimeoutRef.current) clearTimeout(resizeTimeoutRef.current);
8297
- resizeTimeoutRef.current = setTimeout(() => {
8298
- setIsResizing(false);
8299
- }, 250);
8300
- return newHeight;
8301
- }
8302
- return prevHeight;
8303
- });
8304
- }
8084
+ return (0, _copilotkit_core.ɵwatchElementHeight)(element, (state) => {
8085
+ setInputContainerHeight(state.height);
8086
+ setIsResizing(state.isResizing);
8305
8087
  });
8306
- resizeObserver.observe(element);
8307
- setInputContainerHeight(element.offsetHeight);
8308
- return () => {
8309
- resizeObserver.disconnect();
8310
- if (resizeTimeoutRef.current) clearTimeout(resizeTimeoutRef.current);
8311
- };
8312
8088
  }, [inputContainerEl]);
8313
8089
  const BoundMessageView = require_MarkdownSurfaces.renderSlot(messageView, CopilotChatMessageView, {
8314
8090
  messages,
@@ -8645,7 +8421,7 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
8645
8421
  if (!scrollElement) return;
8646
8422
  const contentElement = contentRef.current;
8647
8423
  const checkScroll = () => {
8648
- setShowScrollButton((contentElement ? contentElement.getBoundingClientRect().bottom - scrollElement.getBoundingClientRect().bottom : scrollElement.scrollHeight - scrollElement.scrollTop - scrollElement.clientHeight) >= 10);
8424
+ setShowScrollButton(!(contentElement ? (0, _copilotkit_core.ɵisContentScrolledToBottom)(scrollElement, contentElement) : (0, _copilotkit_core.ɵisScrolledToBottom)(scrollElement)));
8649
8425
  };
8650
8426
  checkScroll();
8651
8427
  scrollElement.addEventListener("scroll", checkScroll);
@@ -8838,9 +8614,14 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
8838
8614
  isInspectorEnabled: inspector.isInspectorEnabled && (inspector.providerEnableInspector ?? inspectorTools ?? true)
8839
8615
  }), [inspector, inspectorTools]);
8840
8616
  const providerAgentId = (0, _copilotkit_react_core_context.useDefaultAgentId)();
8841
- const resolvedAgentId = agentId ?? existingConfig?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
8617
+ const resolvedAgentId = (0, _copilotkit_core.ɵresolveAgentId)({
8618
+ agentId,
8619
+ chatAgentId: existingConfig?.agentId,
8620
+ providerAgentId
8621
+ });
8842
8622
  const providedThreadId = threadId ?? existingConfig?.threadId;
8843
- const baseThreadId = (0, react.useMemo)(() => providedThreadId ?? (0, _copilotkit_shared.randomUUID)(), [providedThreadId]);
8623
+ const [freshThreadId] = (0, react.useState)(() => new _copilotkit_core.ɵFreshThreadId());
8624
+ const baseThreadId = (0, react.useMemo)(() => freshThreadId.resolve(providedThreadId), [freshThreadId, providedThreadId]);
8844
8625
  const baseHasExplicitThreadId = !!threadId || !!existingConfig?.hasExplicitThreadId;
8845
8626
  const { inspectorThreadId, inspectorRequestId, failInspectorOverride } = useInspectorThreadOverride({
8846
8627
  agentId: resolvedAgentId,
@@ -8865,35 +8646,16 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
8865
8646
  }, [onError]);
8866
8647
  (0, react.useEffect)(() => {
8867
8648
  if (!onErrorRef.current) return;
8868
- const subscription = copilotkit.subscribe({ onError: (event) => {
8869
- if (event.context?.agentId === resolvedAgentId || !event.context?.agentId) onErrorRef.current?.({
8870
- error: event.error,
8871
- code: event.code,
8872
- context: event.context
8873
- });
8874
- } });
8875
- return () => {
8876
- subscription.unsubscribe();
8877
- };
8649
+ return (0, _copilotkit_core.ɵsubscribeToAgentErrors)(copilotkit, resolvedAgentId, (event) => onErrorRef.current?.(event));
8878
8650
  }, [copilotkit, resolvedAgentId]);
8879
- (0, react.useEffect)(() => {
8880
- if (!inspectorRequestId) return;
8881
- const requestId = inspectorRequestId;
8882
- const expectedThreadId = resolvedThreadId;
8883
- const subscription = copilotkit.subscribe({ onError: (event) => {
8884
- if (event.code !== _copilotkit_core.CopilotKitCoreErrorCode.AGENT_CONNECT_FAILED) return;
8885
- if (event.context?.agentId !== resolvedAgentId) return;
8886
- if (event.context?.threadId !== expectedThreadId) return;
8887
- failInspectorOverride(requestId);
8888
- } });
8889
- return () => subscription.unsubscribe();
8890
- }, [
8891
- copilotkit,
8892
- failInspectorOverride,
8893
- inspectorRequestId,
8894
- resolvedAgentId,
8895
- resolvedThreadId
8896
- ]);
8651
+ const failInspectorOverrideRef = (0, react.useRef)(failInspectorOverride);
8652
+ failInspectorOverrideRef.current = failInspectorOverride;
8653
+ const [connection] = (0, react.useState)(() => new _copilotkit_core.ɵChatConnection({
8654
+ core: copilotkit,
8655
+ onInspectorOverrideFailed: (requestId) => failInspectorOverrideRef.current(requestId)
8656
+ }));
8657
+ const { threads } = connection;
8658
+ (0, react.useSyncExternalStore)((0, react.useCallback)((onChange) => connection.subscribe(onChange), [connection]), () => connection.getSnapshot(), () => connection.getSnapshot());
8897
8659
  const [transcribeMode, setTranscribeMode] = (0, react.useState)("input");
8898
8660
  const [inputValue, setInputValue] = (0, react.useState)("");
8899
8661
  const inputValueRef = (0, react.useRef)(inputValue);
@@ -8906,20 +8668,14 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
8906
8668
  const isTranscriptionEnabled = copilotkit.audioFileTranscriptionEnabled;
8907
8669
  const isMediaRecorderSupported = typeof window !== "undefined" && typeof MediaRecorder !== "undefined";
8908
8670
  const { messageView: providedMessageView, suggestionView: providedSuggestionView, onStop: providedStopHandler, ...restProps } = props;
8909
- const [lastConnectedThreadId, setLastConnectedThreadId] = (0, react.useState)(null);
8910
- const isConnecting = hasExplicitThreadId && lastConnectedThreadId !== resolvedThreadId;
8671
+ const isConnecting = connection.isConnecting({
8672
+ threadId: resolvedThreadId,
8673
+ explicit: hasExplicitThreadId
8674
+ });
8911
8675
  const activeConnectCountRef = (0, react.useRef)(0);
8912
- const [threads] = (0, react.useState)(() => new _copilotkit_core.ɵThreadSwitchCoordinator(copilotkit));
8913
8676
  const trackConnection = (0, react.useCallback)((connect) => {
8914
- const selection = threads.current;
8915
- if (selection) {
8916
- threads.trackConnection(selection, connect);
8917
- return;
8918
- }
8919
- connect().catch((error) => {
8920
- console.error("CopilotChat: connection failed", error);
8921
- });
8922
- }, [threads]);
8677
+ connection.track(connect);
8678
+ }, [connection]);
8923
8679
  const pendingRunActivityReconnectRef = (0, react.useRef)(false);
8924
8680
  const runActivityReconnectGenerationRef = (0, react.useRef)(0);
8925
8681
  const activeLocalRunIdsRef = (0, react.useRef)(/* @__PURE__ */ new Set());
@@ -8932,8 +8688,6 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
8932
8688
  const runtimeStatus = copilotkit.runtimeConnectionStatus === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Connected ? "Connected" : copilotkit.runtimeConnectionStatus;
8933
8689
  const hasNativeIntelligenceRunActivity = hasExplicitThreadId && runtimeStatus === "Connected" && !!copilotkit.intelligence?.wsUrl && copilotkit.threadEndpoints?.realtimeMetadata === true;
8934
8690
  const [standaloneRunActivityStore] = (0, react.useState)(() => (0, _copilotkit_core.ɵcreateThreadStore)({ fetch: copilotkit.ɵruntimeFetch }));
8935
- const hasExplicitThreadIdRef = (0, react.useRef)(hasExplicitThreadId);
8936
- hasExplicitThreadIdRef.current = hasExplicitThreadId;
8937
8691
  const rememberRecentlyLocalRunId = (0, react.useCallback)((runId) => {
8938
8692
  const existingTimeout = recentlyLocalRunIdsRef.current.get(runId);
8939
8693
  if (existingTimeout) clearTimeout(existingTimeout);
@@ -8971,57 +8725,33 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
8971
8725
  };
8972
8726
  }, []);
8973
8727
  (0, react.useEffect)(() => {
8974
- const selection = threads.select({
8728
+ const handle = connection.open({
8975
8729
  agent,
8976
8730
  threadId: resolvedThreadId,
8977
8731
  explicit: hasExplicitThreadId,
8978
8732
  inspectorRequestId
8979
- });
8980
- if (!selection.shouldConnect) return () => selection.release();
8981
- let detached = false;
8982
- const connectAbortController = new AbortController();
8983
- const connect = async (agentToConnect) => {
8984
- activeConnectCountRef.current += 1;
8985
- try {
8986
- await threads.whenTornDown();
8987
- if (detached) return;
8988
- if ((0, _copilotkit_core.ɵisHttpAgent)(agentToConnect)) agentToConnect.abortController = connectAbortController;
8989
- await copilotkit.connectAgent({ agent: agentToConnect });
8990
- } catch (error) {
8991
- if (detached) return;
8992
- if (inspectorRequestId) failInspectorOverride(inspectorRequestId);
8993
- throw error;
8994
- } finally {
8995
- if (!detached) (typeof requestAnimationFrame === "function" ? requestAnimationFrame : (cb) => setTimeout(cb, 16))(() => {
8996
- if (!detached) setLastConnectedThreadId(resolvedThreadId);
8997
- });
8998
- else if (!hasExplicitThreadIdRef.current) selection.clearDiscardedBaseline();
8733
+ }, {
8734
+ onStart: () => {
8735
+ activeConnectCountRef.current += 1;
8736
+ },
8737
+ onSettled: (current) => {
8999
8738
  activeConnectCountRef.current = Math.max(0, activeConnectCountRef.current - 1);
9000
- if (!detached && activeConnectCountRef.current === 0) {
9001
- const startReconnect = startRunActivityReconnectRef.current;
9002
- if (pendingRunActivityReconnectRef.current && startReconnect) {
9003
- pendingRunActivityReconnectRef.current = false;
9004
- startReconnect(runActivityReconnectGenerationRef.current);
9005
- }
8739
+ if (!current || activeConnectCountRef.current !== 0) return;
8740
+ const startReconnect = startRunActivityReconnectRef.current;
8741
+ if (pendingRunActivityReconnectRef.current && startReconnect) {
8742
+ pendingRunActivityReconnectRef.current = false;
8743
+ startReconnect(runActivityReconnectGenerationRef.current);
9006
8744
  }
9007
8745
  }
9008
- };
9009
- trackConnection(() => connect(agent));
9010
- return () => {
9011
- selection.release();
9012
- detached = true;
9013
- connectAbortController.abort();
9014
- threads.detach(agent);
9015
- };
8746
+ });
8747
+ return () => handle.release();
9016
8748
  }, [
8749
+ connection,
9017
8750
  resolvedThreadId,
9018
8751
  agent,
9019
8752
  resolvedAgentId,
9020
8753
  hasExplicitThreadId,
9021
- inspectorRequestId,
9022
- failInspectorOverride,
9023
- threads,
9024
- trackConnection
8754
+ inspectorRequestId
9025
8755
  ]);
9026
8756
  (0, react.useEffect)(() => {
9027
8757
  if (!hasNativeIntelligenceRunActivity) return;
@@ -9540,8 +9270,6 @@ CopilotModalHeader.DrawerLauncher.displayName = "CopilotModalHeader.DrawerLaunch
9540
9270
 
9541
9271
  //#endregion
9542
9272
  //#region src/components/chat/CopilotSidebarView.tsx
9543
- const DEFAULT_SIDEBAR_WIDTH = 480;
9544
- const SIDEBAR_TRANSITION_MS = 260;
9545
9273
  /**
9546
9274
  * The chat in a side panel: a `complementary` region named by
9547
9275
  * `labels.sidebarLabel`, with a header, the chat view and a toggle button.
@@ -9569,29 +9297,18 @@ function CopilotSidebarViewInternal({ header, toggleButton, width, position = "r
9569
9297
  const configuration = require_MarkdownSurfaces.useCopilotChatConfiguration();
9570
9298
  const isSidebarOpen = configuration?.isModalOpen ?? false;
9571
9299
  const sidebarRef = (0, react.useRef)(null);
9572
- const [sidebarWidth, setSidebarWidth] = (0, react.useState)(width ?? DEFAULT_SIDEBAR_WIDTH);
9300
+ const [measuredWidth, setMeasuredWidth] = (0, react.useState)(width ?? _copilotkit_core.ɵSIDEBAR_DEFAULT_WIDTH);
9301
+ const sidebarWidth = width ?? measuredWidth;
9573
9302
  (0, react.useEffect)(() => {
9574
9303
  if (width !== void 0) return;
9575
- if (typeof window === "undefined") return;
9576
9304
  const element = sidebarRef.current;
9577
9305
  if (!element) return;
9578
- const updateWidth = () => {
9579
- const rect = element.getBoundingClientRect();
9580
- if (rect.width > 0) setSidebarWidth(rect.width);
9581
- };
9582
- updateWidth();
9583
- if (typeof ResizeObserver !== "undefined") {
9584
- const observer = new ResizeObserver(() => updateWidth());
9585
- observer.observe(element);
9586
- return () => observer.disconnect();
9587
- }
9588
- window.addEventListener("resize", updateWidth);
9589
- return () => window.removeEventListener("resize", updateWidth);
9306
+ return (0, _copilotkit_core.ɵwatchElementWidth)(element, setMeasuredWidth);
9590
9307
  }, [width]);
9591
- const widthCss = (0, _copilotkit_core.ɵdimensionToCss)(sidebarWidth, DEFAULT_SIDEBAR_WIDTH);
9308
+ const widthCss = (0, _copilotkit_core.ɵdimensionToCss)(sidebarWidth, _copilotkit_core.ɵSIDEBAR_DEFAULT_WIDTH);
9592
9309
  const dockRef = (0, react.useRef)(null);
9593
9310
  (0, react.useLayoutEffect)(() => {
9594
- const dock = (0, _copilotkit_core.ɵcreateDockedSidebar)(document, { transitionMs: SIDEBAR_TRANSITION_MS });
9311
+ const dock = (0, _copilotkit_core.ɵcreateDockedSidebar)(document, { transitionMs: _copilotkit_core.ɵSIDEBAR_TRANSITION_MS });
9595
9312
  dockRef.current = dock;
9596
9313
  return () => {
9597
9314
  dock.dispose();
@@ -9672,8 +9389,6 @@ CopilotSidebarView.displayName = "CopilotSidebarView";
9672
9389
 
9673
9390
  //#endregion
9674
9391
  //#region src/components/chat/CopilotPopupView.tsx
9675
- const DEFAULT_POPUP_WIDTH = 420;
9676
- const DEFAULT_POPUP_HEIGHT = 560;
9677
9392
  function CopilotPopupView({ header, toggleButton, width, height, clickOutsideToClose, defaultOpen = true, className, ...restProps }) {
9678
9393
  const { open, onOpenChange } = useModalOpenControl();
9679
9394
  const hasOpenControl = open !== void 0 || onOpenChange !== void 0;
@@ -9701,22 +9416,12 @@ function CopilotPopupViewInternal({ header, toggleButton, width, height, clickOu
9701
9416
  const setModalOpen = configuration?.setModalOpen;
9702
9417
  const labels = configuration?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
9703
9418
  const containerRef = (0, react.useRef)(null);
9704
- const [isRendered, setIsRendered] = (0, react.useState)(isPopupOpen);
9705
- const [isAnimatingOut, setIsAnimatingOut] = (0, react.useState)(false);
9419
+ const [presence] = (0, react.useState)(() => (0, _copilotkit_core.ɵcreateExitPresence)(isPopupOpen));
9420
+ const { isRendered, isClosing: isAnimatingOut } = (0, react.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
9706
9421
  (0, react.useEffect)(() => {
9707
- if (isPopupOpen) {
9708
- setIsRendered(true);
9709
- setIsAnimatingOut(false);
9710
- return;
9711
- }
9712
- if (!isRendered) return;
9713
- setIsAnimatingOut(true);
9714
- const timeout = setTimeout(() => {
9715
- setIsRendered(false);
9716
- setIsAnimatingOut(false);
9717
- }, _copilotkit_core.ɵPOPUP_ANIMATION_MS);
9718
- return () => clearTimeout(timeout);
9719
- }, [isPopupOpen, isRendered]);
9422
+ presence.setOpen(isPopupOpen);
9423
+ }, [presence, isPopupOpen]);
9424
+ (0, react.useEffect)(() => () => presence.dispose(), [presence]);
9720
9425
  (0, react.useEffect)(() => {
9721
9426
  if (!isPopupOpen) return;
9722
9427
  return (0, _copilotkit_core.ɵbindPopupDismiss)({
@@ -9731,8 +9436,8 @@ function CopilotPopupViewInternal({ header, toggleButton, width, height, clickOu
9731
9436
  ]);
9732
9437
  const headerElement = (0, react.useMemo)(() => require_MarkdownSurfaces.renderSlot(header, CopilotModalHeader, {}), [header]);
9733
9438
  const toggleButtonElement = (0, react.useMemo)(() => require_MarkdownSurfaces.renderSlot(toggleButton, CopilotChatToggleButton, {}), [toggleButton]);
9734
- const resolvedWidth = (0, _copilotkit_core.ɵdimensionToCss)(width, DEFAULT_POPUP_WIDTH);
9735
- const resolvedHeight = (0, _copilotkit_core.ɵdimensionToCss)(height, DEFAULT_POPUP_HEIGHT);
9439
+ const resolvedWidth = (0, _copilotkit_core.ɵdimensionToCss)(width, _copilotkit_core.ɵPOPUP_DEFAULT_WIDTH);
9440
+ const resolvedHeight = (0, _copilotkit_core.ɵdimensionToCss)(height, _copilotkit_core.ɵPOPUP_DEFAULT_HEIGHT);
9736
9441
  const popupStyle = (0, react.useMemo)(() => ({
9737
9442
  "--copilot-popup-width": resolvedWidth,
9738
9443
  "--copilot-popup-height": resolvedHeight,
@@ -9932,7 +9637,11 @@ function CopilotThreadsDrawer({ agentId, onThreadSelect, onNewThread, onLicensed
9932
9637
  const configuration = require_MarkdownSurfaces.useCopilotChatConfiguration();
9933
9638
  const { licensed, licensePending } = (0, _copilotkit_core.ɵresolveThreadsLicense)((0, _copilotkit_react_core_context.useLicenseContext)());
9934
9639
  const providerAgentId = (0, _copilotkit_react_core_context.useDefaultAgentId)();
9935
- const resolvedAgentId = agentId ?? configuration?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
9640
+ const resolvedAgentId = (0, _copilotkit_core.ɵresolveAgentId)({
9641
+ agentId,
9642
+ chatAgentId: configuration?.agentId,
9643
+ providerAgentId
9644
+ });
9936
9645
  const activeThreadId = configuration?.threadId ?? null;
9937
9646
  const { threads, isLoading, listError, fetchMoreError, hasMoreThreads, isFetchingMoreThreads, archiveThread, unarchiveThread, deleteThread, fetchMoreThreads, refetchThreads, startNewThread } = useThreads({
9938
9647
  agentId: resolvedAgentId,
@@ -11747,6 +11456,12 @@ Object.defineProperty(exports, 'ɵChatConfigurationStore', {
11747
11456
  return _copilotkit_core.ɵChatConfigurationStore;
11748
11457
  }
11749
11458
  });
11459
+ Object.defineProperty(exports, 'ɵChatConnection', {
11460
+ enumerable: true,
11461
+ get: function () {
11462
+ return _copilotkit_core.ɵChatConnection;
11463
+ }
11464
+ });
11750
11465
  Object.defineProperty(exports, 'ɵChatSubmitter', {
11751
11466
  enumerable: true,
11752
11467
  get: function () {
@@ -11759,6 +11474,12 @@ Object.defineProperty(exports, 'ɵComposerAutosize', {
11759
11474
  return _copilotkit_core.ɵComposerAutosize;
11760
11475
  }
11761
11476
  });
11477
+ Object.defineProperty(exports, 'ɵComposerController', {
11478
+ enumerable: true,
11479
+ get: function () {
11480
+ return _copilotkit_core.ɵComposerController;
11481
+ }
11482
+ });
11762
11483
  Object.defineProperty(exports, 'ɵCopyFeedback', {
11763
11484
  enumerable: true,
11764
11485
  get: function () {
@@ -11777,6 +11498,12 @@ Object.defineProperty(exports, 'ɵDockedSidebarRegistry', {
11777
11498
  return _copilotkit_core.ɵDockedSidebarRegistry;
11778
11499
  }
11779
11500
  });
11501
+ Object.defineProperty(exports, 'ɵExitPresence', {
11502
+ enumerable: true,
11503
+ get: function () {
11504
+ return _copilotkit_core.ɵExitPresence;
11505
+ }
11506
+ });
11780
11507
  Object.defineProperty(exports, 'ɵFEEDBACK_COMMENT_CLOSE_DELAY_MS', {
11781
11508
  enumerable: true,
11782
11509
  get: function () {
@@ -11789,6 +11516,12 @@ Object.defineProperty(exports, 'ɵFeedbackCommentController', {
11789
11516
  return _copilotkit_core.ɵFeedbackCommentController;
11790
11517
  }
11791
11518
  });
11519
+ Object.defineProperty(exports, 'ɵFreshThreadId', {
11520
+ enumerable: true,
11521
+ get: function () {
11522
+ return _copilotkit_core.ɵFreshThreadId;
11523
+ }
11524
+ });
11792
11525
  Object.defineProperty(exports, 'ɵGENERATE_SANDBOXED_UI_ARGS_SCHEMA', {
11793
11526
  enumerable: true,
11794
11527
  get: function () {
@@ -11939,6 +11672,18 @@ Object.defineProperty(exports, 'ɵPOPUP_ANIMATION_MS', {
11939
11672
  return _copilotkit_core.ɵPOPUP_ANIMATION_MS;
11940
11673
  }
11941
11674
  });
11675
+ Object.defineProperty(exports, 'ɵPOPUP_DEFAULT_HEIGHT', {
11676
+ enumerable: true,
11677
+ get: function () {
11678
+ return _copilotkit_core.ɵPOPUP_DEFAULT_HEIGHT;
11679
+ }
11680
+ });
11681
+ Object.defineProperty(exports, 'ɵPOPUP_DEFAULT_WIDTH', {
11682
+ enumerable: true,
11683
+ get: function () {
11684
+ return _copilotkit_core.ɵPOPUP_DEFAULT_WIDTH;
11685
+ }
11686
+ });
11942
11687
  Object.defineProperty(exports, 'ɵPlaceholderCycler', {
11943
11688
  enumerable: true,
11944
11689
  get: function () {
@@ -11951,12 +11696,24 @@ Object.defineProperty(exports, 'ɵRENDER_A2UI_TOOL_NAME', {
11951
11696
  return _copilotkit_core.ɵRENDER_A2UI_TOOL_NAME;
11952
11697
  }
11953
11698
  });
11699
+ Object.defineProperty(exports, 'ɵRESIZE_SETTLE_MS', {
11700
+ enumerable: true,
11701
+ get: function () {
11702
+ return _copilotkit_core.ɵRESIZE_SETTLE_MS;
11703
+ }
11704
+ });
11954
11705
  Object.defineProperty(exports, 'ɵRUNTIME_PROBE_TIMEOUT_MS', {
11955
11706
  enumerable: true,
11956
11707
  get: function () {
11957
11708
  return _copilotkit_core.ɵRUNTIME_PROBE_TIMEOUT_MS;
11958
11709
  }
11959
11710
  });
11711
+ Object.defineProperty(exports, 'ɵReasoningDisclosure', {
11712
+ enumerable: true,
11713
+ get: function () {
11714
+ return _copilotkit_core.ɵReasoningDisclosure;
11715
+ }
11716
+ });
11960
11717
  Object.defineProperty(exports, 'ɵRendererRegistry', {
11961
11718
  enumerable: true,
11962
11719
  get: function () {
@@ -11975,12 +11732,36 @@ Object.defineProperty(exports, 'ɵSCROLL_BOTTOM_THRESHOLD_PX', {
11975
11732
  return _copilotkit_core.ɵSCROLL_BOTTOM_THRESHOLD_PX;
11976
11733
  }
11977
11734
  });
11735
+ Object.defineProperty(exports, 'ɵSIDEBAR_DEFAULT_WIDTH', {
11736
+ enumerable: true,
11737
+ get: function () {
11738
+ return _copilotkit_core.ɵSIDEBAR_DEFAULT_WIDTH;
11739
+ }
11740
+ });
11741
+ Object.defineProperty(exports, 'ɵSIDEBAR_TRANSITION_MS', {
11742
+ enumerable: true,
11743
+ get: function () {
11744
+ return _copilotkit_core.ɵSIDEBAR_TRANSITION_MS;
11745
+ }
11746
+ });
11978
11747
  Object.defineProperty(exports, 'ɵSTABLE_ARRAY_WARNINGS', {
11979
11748
  enumerable: true,
11980
11749
  get: function () {
11981
11750
  return _copilotkit_core.ɵSTABLE_ARRAY_WARNINGS;
11982
11751
  }
11983
11752
  });
11753
+ Object.defineProperty(exports, 'ɵStickToBottom', {
11754
+ enumerable: true,
11755
+ get: function () {
11756
+ return _copilotkit_core.ɵStickToBottom;
11757
+ }
11758
+ });
11759
+ Object.defineProperty(exports, 'ɵTAB_STOP_SELECTOR', {
11760
+ enumerable: true,
11761
+ get: function () {
11762
+ return _copilotkit_core.ɵTAB_STOP_SELECTOR;
11763
+ }
11764
+ });
11984
11765
  Object.defineProperty(exports, 'ɵTHREAD_REQUEST_TIMEOUT_MS', {
11985
11766
  enumerable: true,
11986
11767
  get: function () {
@@ -12023,6 +11804,18 @@ Object.defineProperty(exports, 'ɵThreadsController', {
12023
11804
  return _copilotkit_core.ɵThreadsController;
12024
11805
  }
12025
11806
  });
11807
+ Object.defineProperty(exports, 'ɵadaptDefaultToolCallRenderProps', {
11808
+ enumerable: true,
11809
+ get: function () {
11810
+ return _copilotkit_core.ɵadaptDefaultToolCallRenderProps;
11811
+ }
11812
+ });
11813
+ Object.defineProperty(exports, 'ɵaddOpenGenerativeUIContexts', {
11814
+ enumerable: true,
11815
+ get: function () {
11816
+ return _copilotkit_core.ɵaddOpenGenerativeUIContexts;
11817
+ }
11818
+ });
12026
11819
  Object.defineProperty(exports, 'ɵagentUpdateHandlers', {
12027
11820
  enumerable: true,
12028
11821
  get: function () {
@@ -12035,6 +11828,36 @@ Object.defineProperty(exports, 'ɵappendTranscript', {
12035
11828
  return _copilotkit_core.ɵappendTranscript;
12036
11829
  }
12037
11830
  });
11831
+ Object.defineProperty(exports, 'ɵassembleActivityRenderers', {
11832
+ enumerable: true,
11833
+ get: function () {
11834
+ return _copilotkit_core.ɵassembleActivityRenderers;
11835
+ }
11836
+ });
11837
+ Object.defineProperty(exports, 'ɵassembleHumanInTheLoop', {
11838
+ enumerable: true,
11839
+ get: function () {
11840
+ return _copilotkit_core.ɵassembleHumanInTheLoop;
11841
+ }
11842
+ });
11843
+ Object.defineProperty(exports, 'ɵassembleProviderRegistry', {
11844
+ enumerable: true,
11845
+ get: function () {
11846
+ return _copilotkit_core.ɵassembleProviderRegistry;
11847
+ }
11848
+ });
11849
+ Object.defineProperty(exports, 'ɵassembleProviderToolRenderers', {
11850
+ enumerable: true,
11851
+ get: function () {
11852
+ return _copilotkit_core.ɵassembleProviderToolRenderers;
11853
+ }
11854
+ });
11855
+ Object.defineProperty(exports, 'ɵassembleProviderTools', {
11856
+ enumerable: true,
11857
+ get: function () {
11858
+ return _copilotkit_core.ɵassembleProviderTools;
11859
+ }
11860
+ });
12038
11861
  Object.defineProperty(exports, 'ɵbindDialogFocus', {
12039
11862
  enumerable: true,
12040
11863
  get: function () {
@@ -12167,6 +11990,12 @@ Object.defineProperty(exports, 'ɵcreateDockedSidebar', {
12167
11990
  return _copilotkit_core.ɵcreateDockedSidebar;
12168
11991
  }
12169
11992
  });
11993
+ Object.defineProperty(exports, 'ɵcreateExitPresence', {
11994
+ enumerable: true,
11995
+ get: function () {
11996
+ return _copilotkit_core.ɵcreateExitPresence;
11997
+ }
11998
+ });
12170
11999
  Object.defineProperty(exports, 'ɵcreateLastUserMessageTracker', {
12171
12000
  enumerable: true,
12172
12001
  get: function () {
@@ -12197,6 +12026,12 @@ Object.defineProperty(exports, 'ɵcreateOpenGenerativeUITool', {
12197
12026
  return _copilotkit_core.ɵcreateOpenGenerativeUITool;
12198
12027
  }
12199
12028
  });
12029
+ Object.defineProperty(exports, 'ɵcreateStickToBottom', {
12030
+ enumerable: true,
12031
+ get: function () {
12032
+ return _copilotkit_core.ɵcreateStickToBottom;
12033
+ }
12034
+ });
12200
12035
  Object.defineProperty(exports, 'ɵcreateThreadSelectors', {
12201
12036
  enumerable: true,
12202
12037
  get: function () {
@@ -12323,6 +12158,12 @@ Object.defineProperty(exports, 'ɵflattenCommandItems', {
12323
12158
  return _copilotkit_core.ɵflattenCommandItems;
12324
12159
  }
12325
12160
  });
12161
+ Object.defineProperty(exports, 'ɵflattenToolsMenuForDisplay', {
12162
+ enumerable: true,
12163
+ get: function () {
12164
+ return _copilotkit_core.ɵflattenToolsMenuForDisplay;
12165
+ }
12166
+ });
12326
12167
  Object.defineProperty(exports, 'ɵflattenUserMessageContent', {
12327
12168
  enumerable: true,
12328
12169
  get: function () {
@@ -12473,6 +12314,18 @@ Object.defineProperty(exports, 'ɵgetMessageFeedbackControls', {
12473
12314
  return _copilotkit_core.ɵgetMessageFeedbackControls;
12474
12315
  }
12475
12316
  });
12317
+ Object.defineProperty(exports, 'ɵgetMessageRunStateSnapshot', {
12318
+ enumerable: true,
12319
+ get: function () {
12320
+ return _copilotkit_core.ɵgetMessageRunStateSnapshot;
12321
+ }
12322
+ });
12323
+ Object.defineProperty(exports, 'ɵgetReasoningHeaderLabel', {
12324
+ enumerable: true,
12325
+ get: function () {
12326
+ return _copilotkit_core.ɵgetReasoningHeaderLabel;
12327
+ }
12328
+ });
12476
12329
  Object.defineProperty(exports, 'ɵgetThreadsDrawerElementProps', {
12477
12330
  enumerable: true,
12478
12331
  get: function () {
@@ -12575,6 +12428,12 @@ Object.defineProperty(exports, 'ɵhitlRenderProps', {
12575
12428
  return _copilotkit_core.ɵhitlRenderProps;
12576
12429
  }
12577
12430
  });
12431
+ Object.defineProperty(exports, 'ɵimplementsConnect', {
12432
+ enumerable: true,
12433
+ get: function () {
12434
+ return _copilotkit_core.ɵimplementsConnect;
12435
+ }
12436
+ });
12578
12437
  Object.defineProperty(exports, 'ɵinitialKeyboardState', {
12579
12438
  enumerable: true,
12580
12439
  get: function () {
@@ -12599,12 +12458,30 @@ Object.defineProperty(exports, 'ɵinspectorShortcuts', {
12599
12458
  return _copilotkit_core.ɵinspectorShortcuts;
12600
12459
  }
12601
12460
  });
12461
+ Object.defineProperty(exports, 'ɵisContentPart', {
12462
+ enumerable: true,
12463
+ get: function () {
12464
+ return _copilotkit_core.ɵisContentPart;
12465
+ }
12466
+ });
12467
+ Object.defineProperty(exports, 'ɵisContentScrolledToBottom', {
12468
+ enumerable: true,
12469
+ get: function () {
12470
+ return _copilotkit_core.ɵisContentScrolledToBottom;
12471
+ }
12472
+ });
12602
12473
  Object.defineProperty(exports, 'ɵisCopilotKitFeature', {
12603
12474
  enumerable: true,
12604
12475
  get: function () {
12605
12476
  return _copilotkit_core.ɵisCopilotKitFeature;
12606
12477
  }
12607
12478
  });
12479
+ Object.defineProperty(exports, 'ɵisFocusVisible', {
12480
+ enumerable: true,
12481
+ get: function () {
12482
+ return _copilotkit_core.ɵisFocusVisible;
12483
+ }
12484
+ });
12608
12485
  Object.defineProperty(exports, 'ɵisHttpAgent', {
12609
12486
  enumerable: true,
12610
12487
  get: function () {
@@ -12629,6 +12506,12 @@ Object.defineProperty(exports, 'ɵisOpenGenerativeUIActive', {
12629
12506
  return _copilotkit_core.ɵisOpenGenerativeUIActive;
12630
12507
  }
12631
12508
  });
12509
+ Object.defineProperty(exports, 'ɵisOwnFeedbackThumb', {
12510
+ enumerable: true,
12511
+ get: function () {
12512
+ return _copilotkit_core.ɵisOwnFeedbackThumb;
12513
+ }
12514
+ });
12632
12515
  Object.defineProperty(exports, 'ɵisRetryableMemoryStatus', {
12633
12516
  enumerable: true,
12634
12517
  get: function () {
@@ -12725,6 +12608,12 @@ Object.defineProperty(exports, 'ɵnextSlashIndex', {
12725
12608
  return _copilotkit_core.ɵnextSlashIndex;
12726
12609
  }
12727
12610
  });
12611
+ Object.defineProperty(exports, 'ɵnextTabStop', {
12612
+ enumerable: true,
12613
+ get: function () {
12614
+ return _copilotkit_core.ɵnextTabStop;
12615
+ }
12616
+ });
12728
12617
  Object.defineProperty(exports, 'ɵnormalizeAutoScroll', {
12729
12618
  enumerable: true,
12730
12619
  get: function () {
@@ -12737,6 +12626,12 @@ Object.defineProperty(exports, 'ɵnormalizeToolCallStatus', {
12737
12626
  return _copilotkit_core.ɵnormalizeToolCallStatus;
12738
12627
  }
12739
12628
  });
12629
+ Object.defineProperty(exports, 'ɵnormalizeToolsMenu', {
12630
+ enumerable: true,
12631
+ get: function () {
12632
+ return _copilotkit_core.ɵnormalizeToolsMenu;
12633
+ }
12634
+ });
12740
12635
  Object.defineProperty(exports, 'ɵobservePhoenixEvent$', {
12741
12636
  enumerable: true,
12742
12637
  get: function () {
@@ -12839,6 +12734,12 @@ Object.defineProperty(exports, 'ɵrecordWorkTime', {
12839
12734
  return _copilotkit_core.ɵrecordWorkTime;
12840
12735
  }
12841
12736
  });
12737
+ Object.defineProperty(exports, 'ɵregisterFrontendTools', {
12738
+ enumerable: true,
12739
+ get: function () {
12740
+ return _copilotkit_core.ɵregisterFrontendTools;
12741
+ }
12742
+ });
12842
12743
  Object.defineProperty(exports, 'ɵreportProviderConfigDiagnostics', {
12843
12744
  enumerable: true,
12844
12745
  get: function () {
@@ -12863,6 +12764,12 @@ Object.defineProperty(exports, 'ɵresetMessageFeedbackCache', {
12863
12764
  return _copilotkit_core.ɵresetMessageFeedbackCache;
12864
12765
  }
12865
12766
  });
12767
+ Object.defineProperty(exports, 'ɵresolveA2UIActivation', {
12768
+ enumerable: true,
12769
+ get: function () {
12770
+ return _copilotkit_core.ɵresolveA2UIActivation;
12771
+ }
12772
+ });
12866
12773
  Object.defineProperty(exports, 'ɵresolveA2UIDebugExposure', {
12867
12774
  enumerable: true,
12868
12775
  get: function () {
@@ -13073,12 +12980,24 @@ Object.defineProperty(exports, 'ɵshouldShowMessageCursor', {
13073
12980
  return _copilotkit_core.ɵshouldShowMessageCursor;
13074
12981
  }
13075
12982
  });
12983
+ Object.defineProperty(exports, 'ɵshowsComposerDisclaimer', {
12984
+ enumerable: true,
12985
+ get: function () {
12986
+ return _copilotkit_core.ɵshowsComposerDisclaimer;
12987
+ }
12988
+ });
13076
12989
  Object.defineProperty(exports, 'ɵsnapshotAgentState', {
13077
12990
  enumerable: true,
13078
12991
  get: function () {
13079
12992
  return _copilotkit_core.ɵsnapshotAgentState;
13080
12993
  }
13081
12994
  });
12995
+ Object.defineProperty(exports, 'ɵstableArrayPropWarning', {
12996
+ enumerable: true,
12997
+ get: function () {
12998
+ return _copilotkit_core.ɵstableArrayPropWarning;
12999
+ }
13000
+ });
13082
13001
  Object.defineProperty(exports, 'ɵstopAgentWithFallback', {
13083
13002
  enumerable: true,
13084
13003
  get: function () {
@@ -13097,6 +13016,12 @@ Object.defineProperty(exports, 'ɵstringifyToolCallPayload', {
13097
13016
  return _copilotkit_core.ɵstringifyToolCallPayload;
13098
13017
  }
13099
13018
  });
13019
+ Object.defineProperty(exports, 'ɵsubscribeToAgentErrors', {
13020
+ enumerable: true,
13021
+ get: function () {
13022
+ return _copilotkit_core.ɵsubscribeToAgentErrors;
13023
+ }
13024
+ });
13100
13025
  Object.defineProperty(exports, 'ɵsubscribeToAgentSuggestions', {
13101
13026
  enumerable: true,
13102
13027
  get: function () {
@@ -13127,6 +13052,12 @@ Object.defineProperty(exports, 'ɵsurfaceHasRenderableContent', {
13127
13052
  return _copilotkit_core.ɵsurfaceHasRenderableContent;
13128
13053
  }
13129
13054
  });
13055
+ Object.defineProperty(exports, 'ɵsyncRecorderToMode', {
13056
+ enumerable: true,
13057
+ get: function () {
13058
+ return _copilotkit_core.ɵsyncRecorderToMode;
13059
+ }
13060
+ });
13130
13061
  Object.defineProperty(exports, 'ɵthreadAdapterEvents', {
13131
13062
  enumerable: true,
13132
13063
  get: function () {
@@ -13139,6 +13070,12 @@ Object.defineProperty(exports, 'ɵtoA2UIClientEvent', {
13139
13070
  return _copilotkit_core.ɵtoA2UIClientEvent;
13140
13071
  }
13141
13072
  });
13073
+ Object.defineProperty(exports, 'ɵtoDefaultToolCallStatus', {
13074
+ enumerable: true,
13075
+ get: function () {
13076
+ return _copilotkit_core.ɵtoDefaultToolCallStatus;
13077
+ }
13078
+ });
13142
13079
  Object.defineProperty(exports, 'ɵtoDrawerThread', {
13143
13080
  enumerable: true,
13144
13081
  get: function () {
@@ -13193,6 +13130,18 @@ Object.defineProperty(exports, 'ɵwaitForActiveRun', {
13193
13130
  return _copilotkit_core.ɵwaitForActiveRun;
13194
13131
  }
13195
13132
  });
13133
+ Object.defineProperty(exports, 'ɵwatchElementHeight', {
13134
+ enumerable: true,
13135
+ get: function () {
13136
+ return _copilotkit_core.ɵwatchElementHeight;
13137
+ }
13138
+ });
13139
+ Object.defineProperty(exports, 'ɵwatchElementWidth', {
13140
+ enumerable: true,
13141
+ get: function () {
13142
+ return _copilotkit_core.ɵwatchElementWidth;
13143
+ }
13144
+ });
13196
13145
  Object.defineProperty(exports, 'ɵwatchKeyboardState', {
13197
13146
  enumerable: true,
13198
13147
  get: function () {