@copilotkit/react-core 1.72.1-canary.sp-longthread-perf → 1.73.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/{copilotkit-D5fPO8hJ.d.cts → copilotkit-C7c_w9iV.d.cts} +88 -9
  2. package/dist/copilotkit-C7c_w9iV.d.cts.map +1 -0
  3. package/dist/{copilotkit-BRPxLJnI.d.mts → copilotkit-CfyJ1-Nx.d.mts} +88 -9
  4. package/dist/copilotkit-CfyJ1-Nx.d.mts.map +1 -0
  5. package/dist/{copilotkit-B2TZRWwp.mjs → copilotkit-CwVE-0JG.mjs} +154 -99
  6. package/dist/copilotkit-CwVE-0JG.mjs.map +1 -0
  7. package/dist/{copilotkit-BV7MguMm.cjs → copilotkit-D_c2dJ9t.cjs} +156 -95
  8. package/dist/copilotkit-D_c2dJ9t.cjs.map +1 -0
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +2 -2
  12. package/dist/index.d.mts +2 -2
  13. package/dist/index.mjs +1 -1
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/index.umd.js +8 -2
  16. package/dist/index.umd.js.map +1 -1
  17. package/dist/v2/headless.cjs +101 -2
  18. package/dist/v2/headless.cjs.map +1 -1
  19. package/dist/v2/headless.d.cts +53 -1
  20. package/dist/v2/headless.d.cts.map +1 -1
  21. package/dist/v2/headless.d.mts +53 -1
  22. package/dist/v2/headless.d.mts.map +1 -1
  23. package/dist/v2/headless.mjs +101 -3
  24. package/dist/v2/headless.mjs.map +1 -1
  25. package/dist/v2/index.cjs +1285 -55
  26. package/dist/v2/index.d.cts +2 -4
  27. package/dist/v2/index.d.mts +2 -4
  28. package/dist/v2/index.mjs +2 -6
  29. package/dist/v2/index.umd.js +1439 -155
  30. package/dist/v2/index.umd.js.map +1 -1
  31. package/package.json +13 -12
  32. package/dist/copilotkit-B2TZRWwp.mjs.map +0 -1
  33. package/dist/copilotkit-BRPxLJnI.d.mts.map +0 -1
  34. package/dist/copilotkit-BV7MguMm.cjs.map +0 -1
  35. package/dist/copilotkit-D5fPO8hJ.d.cts.map +0 -1
@@ -3391,7 +3391,7 @@ function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
3391
3391
  }, [value, warningMessage]);
3392
3392
  return value;
3393
3393
  }
3394
- const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY_HEADERS, credentials, publicApiKey, publicLicenseKey, licenseToken, properties = EMPTY_PROPERTIES, agents__unsafe_dev_only: agents = EMPTY_AGENTS, selfManagedAgents = EMPTY_AGENTS, renderToolCalls, renderActivityMessages, renderCustomMessages, frontendTools, humanInTheLoop, openGenerativeUI, enableInspector, agentId, useSingleEndpoint, onError, a2ui, defaultThrottleMs, debug }) => {
3394
+ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY_HEADERS, credentials, messageFilter, publicApiKey, publicLicenseKey, licenseToken, properties = EMPTY_PROPERTIES, agents__unsafe_dev_only: agents = EMPTY_AGENTS, selfManagedAgents = EMPTY_AGENTS, renderToolCalls, renderActivityMessages, renderCustomMessages, frontendTools, humanInTheLoop, openGenerativeUI, enableInspector, agentId, useSingleEndpoint, onError, a2ui, defaultThrottleMs, debug }) => {
3395
3395
  const [shouldRenderInspector, setShouldRenderInspector] = (0, react.useState)(false);
3396
3396
  const [inspectorVisible, setInspectorVisible] = (0, react.useState)(false);
3397
3397
  (0, react.useEffect)(() => {
@@ -3512,6 +3512,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3512
3512
  const processedRenderToolCalls = [];
3513
3513
  humanInTheLoopList.forEach((tool) => {
3514
3514
  const frontendTool = {
3515
+ type: "human-in-the-loop",
3515
3516
  name: tool.name,
3516
3517
  description: tool.description,
3517
3518
  parameters: tool.parameters,
@@ -3618,6 +3619,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3618
3619
  runtimeTransport: useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto",
3619
3620
  headers: mergedHeaders,
3620
3621
  credentials,
3622
+ messageFilter,
3621
3623
  properties,
3622
3624
  agents__unsafe_dev_only: mergedAgents,
3623
3625
  tools: allTools,
@@ -3703,6 +3705,9 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3703
3705
  subscription.unsubscribe();
3704
3706
  };
3705
3707
  }, [copilotkit]);
3708
+ (0, react.useEffect)(() => {
3709
+ copilotkit.setMessageFilter(messageFilter);
3710
+ }, [copilotkit, messageFilter]);
3706
3711
  (0, react.useEffect)(() => {
3707
3712
  copilotkit.setRuntimeUrl(chatApiEndpoint);
3708
3713
  copilotkit.setRuntimeTransport(useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto");
@@ -3855,8 +3860,8 @@ function useRenderCustomMessages() {
3855
3860
  if (aHasAgent === (b.agentId !== void 0)) return 0;
3856
3861
  return aHasAgent ? -1 : 1;
3857
3862
  });
3858
- if (!customMessageRenderers.length) return null;
3859
3863
  return function(params) {
3864
+ if (!customMessageRenderers.length) return null;
3860
3865
  const { message, position } = params;
3861
3866
  const resolvedRunId = copilotkit.getRunIdForMessage(agentId, threadId, message.id) ?? copilotkit.getRunIdsForThread(agentId, threadId).slice(-1)[0];
3862
3867
  const runId = resolvedRunId ?? `missing-run-id:${message.id}`;
@@ -3932,10 +3937,10 @@ function useRenderActivityMessage() {
3932
3937
 
3933
3938
  //#endregion
3934
3939
  //#region src/v2/hooks/use-frontend-tool.tsx
3935
- const EMPTY_DEPS$1 = [];
3940
+ const EMPTY_DEPS$2 = [];
3936
3941
  function useFrontendTool(tool, deps) {
3937
3942
  const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
3938
- const extraDeps = deps ?? EMPTY_DEPS$1;
3943
+ const extraDeps = deps ?? EMPTY_DEPS$2;
3939
3944
  (0, react.useLayoutEffect)(() => {
3940
3945
  const name = tool.name;
3941
3946
  if (copilotkit.getTool({
@@ -3964,6 +3969,103 @@ function useFrontendTool(tool, deps) {
3964
3969
  ]);
3965
3970
  }
3966
3971
 
3972
+ //#endregion
3973
+ //#region src/v2/hooks/use-frontend-tools.tsx
3974
+ const EMPTY_DEPS$1 = [];
3975
+ const EMPTY_TOOLS = [];
3976
+ /**
3977
+ * Register a list of frontend tools whose length can change between renders.
3978
+ *
3979
+ * `useFrontendTool` registers exactly one tool per call, so it cannot be called
3980
+ * in a loop over a runtime-length list without breaking the rules of hooks.
3981
+ * This hook runs a single effect over the whole array instead, which makes it
3982
+ * safe to build the list from state, props, or a server response.
3983
+ *
3984
+ * Tools are keyed by `name` plus `agentId`, the same as `useFrontendTool`. A
3985
+ * tool that disappears from the array is unregistered on the next render, and
3986
+ * every tool is unregistered on unmount. Renderers stay registered after
3987
+ * unmount so past tool calls still render in the chat history.
3988
+ *
3989
+ * @param tools - The tools to register. May be empty and may change length.
3990
+ * @param deps - Extra dependencies that force re-registration, compared by
3991
+ * identity like the second argument of `useEffect`. Use this when a handler
3992
+ * closes over a value that is not part of the tool definition. Keep the array
3993
+ * a constant length across renders.
3994
+ *
3995
+ * @example
3996
+ * Register one tool per item in application state:
3997
+ * ```tsx
3998
+ * const [reports, setReports] = useState<Report[]>([]);
3999
+ *
4000
+ * useFrontendTools(
4001
+ * reports.map((report) => ({
4002
+ * name: `open_${report.id}`,
4003
+ * description: `Open the ${report.title} report`,
4004
+ * handler: async () => navigate(`/reports/${report.id}`),
4005
+ * })),
4006
+ * [navigate],
4007
+ * );
4008
+ * ```
4009
+ *
4010
+ * @example
4011
+ * Register tools described by the backend:
4012
+ * ```tsx
4013
+ * const { data } = useQuery(fetchToolDescriptors);
4014
+ *
4015
+ * useFrontendTools(
4016
+ * (data ?? []).map((descriptor) => ({
4017
+ * name: descriptor.name,
4018
+ * description: descriptor.description,
4019
+ * parameters: z.object({ query: z.string() }),
4020
+ * handler: async ({ query }) => runDescriptor(descriptor.id, query),
4021
+ * })),
4022
+ * );
4023
+ * ```
4024
+ */
4025
+ function useFrontendTools(tools, deps) {
4026
+ const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
4027
+ const toolList = tools ?? EMPTY_TOOLS;
4028
+ const extraDeps = deps ?? EMPTY_DEPS$1;
4029
+ (0, react.useLayoutEffect)(() => {
4030
+ const deduped = /* @__PURE__ */ new Map();
4031
+ for (const tool of toolList) {
4032
+ const key = `${tool.agentId ?? ""}:${tool.name}`;
4033
+ 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.`);
4034
+ deduped.set(key, tool);
4035
+ }
4036
+ const registered = [...deduped.values()];
4037
+ for (const tool of registered) {
4038
+ if (copilotkit.getTool({
4039
+ toolName: tool.name,
4040
+ agentId: tool.agentId
4041
+ })) {
4042
+ console.warn(`Tool '${tool.name}' already exists for agent '${tool.agentId || "global"}'. Overriding with latest registration.`);
4043
+ copilotkit.removeTool(tool.name, tool.agentId);
4044
+ }
4045
+ copilotkit.addTool(tool);
4046
+ if (tool.render) copilotkit.addHookRenderToolCall({
4047
+ name: tool.name,
4048
+ args: tool.parameters,
4049
+ agentId: tool.agentId,
4050
+ render: tool.render
4051
+ });
4052
+ }
4053
+ return () => {
4054
+ for (const tool of registered) copilotkit.removeTool(tool.name, tool.agentId);
4055
+ };
4056
+ }, [
4057
+ JSON.stringify(toolList.map((tool) => [
4058
+ tool.name,
4059
+ tool.description ?? null,
4060
+ tool.agentId ?? null,
4061
+ tool.available ?? null,
4062
+ tool.webmcp ?? null
4063
+ ])),
4064
+ copilotkit,
4065
+ ...extraDeps
4066
+ ]);
4067
+ }
4068
+
3967
4069
  //#endregion
3968
4070
  //#region src/v2/hooks/use-component.tsx
3969
4071
  /**
@@ -4380,6 +4482,7 @@ function useHumanInTheLoop(tool, deps) {
4380
4482
  ]);
4381
4483
  useFrontendTool({
4382
4484
  ...tool,
4485
+ type: "human-in-the-loop",
4383
4486
  handler,
4384
4487
  render: RenderComponent
4385
4488
  }, deps);
@@ -7029,32 +7132,6 @@ CopilotChatSuggestionView.displayName = "CopilotChatSuggestionView";
7029
7132
  */
7030
7133
  const ScrollElementContext = react.default.createContext(null);
7031
7134
 
7032
- //#endregion
7033
- //#region src/v2/components/chat/scroll-pinned-context.ts
7034
- /**
7035
- * True while the pin-to-bottom behaviour is actively following the bottom of
7036
- * the thread — i.e. `use-stick-to-bottom` will animate the scroll position to
7037
- * the bottom the next time the content grows.
7038
- *
7039
- * Only CopilotChatView's pin-to-bottom branch provides this. The other scroll
7040
- * modes leave it `false`, which is correct: nothing else writes the scroll
7041
- * position on its own, so no one is competing with the virtualizer.
7042
- *
7043
- * Why this exists: the virtualizer and `use-stick-to-bottom` both write
7044
- * `scrollTop` on the same element. The virtualizer writes it to compensate
7045
- * when a row above the viewport turns out taller than its estimate, so that
7046
- * what the reader is looking at does not shift. That compensation is essential
7047
- * while the reader is scrolled up — and pointless while pinned to the bottom,
7048
- * because the pin is about to move the scroll position anyway. Worse than
7049
- * pointless: the compensation changes the virtual container's height, the pin
7050
- * reads that as content growth and animates, the animation brings unmeasured
7051
- * rows into view, they measure, and the two keep shoving each other.
7052
- *
7053
- * Consumed by CopilotChatMessageView to stand the virtualizer down while the
7054
- * pin owns the scroll position.
7055
- */
7056
- const ScrollPinnedContext = react.default.createContext(false);
7057
-
7058
7135
  //#endregion
7059
7136
  //#region src/v2/components/intelligence-indicator/IntelligenceIndicatorView.tsx
7060
7137
  /**
@@ -7520,7 +7597,6 @@ function deduplicateMessages(messages) {
7520
7597
  }
7521
7598
  const VIRTUALIZE_THRESHOLD = 50;
7522
7599
  function CopilotChatMessageView({ messages = [], assistantMessage, userMessage, reasoningMessage, cursor, intelligenceIndicator, isRunning = false, children, className, ...props }) {
7523
- const isPinnedToBottom = (0, react.useContext)(ScrollPinnedContext);
7524
7600
  const renderCustomMessage = useRenderCustomMessages();
7525
7601
  const { renderActivityMessage } = useRenderActivityMessage();
7526
7602
  const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
@@ -7552,6 +7628,13 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
7552
7628
  return copilotkit.getStateByRun(config.agentId, config.threadId, resolvedRunId);
7553
7629
  };
7554
7630
  const deduplicatedMessages = (0, react.useMemo)(() => deduplicateMessages(messages), [messages]);
7631
+ const rowKeyStoreRef = (0, react.useRef)(null);
7632
+ rowKeyStoreRef.current ??= (0, _copilotkit_shared.createRowKeyStore)();
7633
+ const rowKeyStore = rowKeyStoreRef.current;
7634
+ const rowRenderKeys = (0, react.useMemo)(() => (0, _copilotkit_shared.resolveRowRenderKeysById)(rowKeyStore, deduplicatedMessages), [rowKeyStore, deduplicatedMessages]);
7635
+ (0, react.useLayoutEffect)(() => {
7636
+ (0, _copilotkit_shared.commitRowKeyStore)(rowKeyStore, deduplicatedMessages);
7637
+ }, [rowKeyStore, deduplicatedMessages]);
7555
7638
  if (process.env.NODE_ENV === "development" && deduplicatedMessages.length < messages.length) console.warn(`CopilotChatMessageView: Merged ${messages.length - deduplicatedMessages.length} message(s) with duplicate IDs.`);
7556
7639
  const { Component: AssistantComponent, slotProps: assistantSlotProps } = (0, react.useMemo)(() => resolveSlotComponent(assistantMessage, CopilotChatAssistantMessage_default), [assistantMessage]);
7557
7640
  const agentId = config?.agentId;
@@ -7586,36 +7669,17 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
7586
7669
  if (process.env.NODE_ENV !== "production" && scrollElementFromCtx && scrollElementFromCtx.clientHeight === 0) console.warn("[CopilotKit] Chat scroll container has clientHeight=0 — virtualization disabled. Ensure the chat is rendered in a visible container with a non-zero height.");
7587
7670
  }, [scrollElementFromCtx]);
7588
7671
  const shouldVirtualize = !!scrollElement && !children && deduplicatedMessages.length > VIRTUALIZE_THRESHOLD;
7589
- const measuredRef = react.default.useRef({
7590
- count: 0,
7591
- total: 0
7592
- });
7593
- const isPinnedToBottomRef = react.default.useRef(isPinnedToBottom);
7594
- const shouldAdjustScrollOnResize = react.default.useCallback(() => !isPinnedToBottomRef.current, []);
7595
- const estimateRowSize = react.default.useCallback(() => {
7596
- const { count, total } = measuredRef.current;
7597
- return count > 0 ? Math.max(1, Math.round(total / count)) : 100;
7598
- }, []);
7599
7672
  const virtualizer = (0, _tanstack_react_virtual.useVirtualizer)({
7600
7673
  count: shouldVirtualize ? deduplicatedMessages.length : 0,
7601
7674
  getScrollElement: () => scrollElement,
7602
- estimateSize: estimateRowSize,
7675
+ estimateSize: () => 100,
7603
7676
  overscan: 5,
7604
- measureElement: (el) => {
7605
- const height = el?.getBoundingClientRect().height ?? 0;
7606
- if (height > 0) {
7607
- measuredRef.current.count += 1;
7608
- measuredRef.current.total += height;
7609
- }
7610
- return height;
7611
- },
7677
+ measureElement: (el) => el?.getBoundingClientRect().height ?? 0,
7612
7678
  initialRect: {
7613
7679
  width: 0,
7614
7680
  height: 600
7615
7681
  }
7616
7682
  });
7617
- isPinnedToBottomRef.current = isPinnedToBottom;
7618
- virtualizer.shouldAdjustScrollPositionOnItemSizeChange = shouldAdjustScrollOnResize;
7619
7683
  const firstMessageId = deduplicatedMessages[0]?.id;
7620
7684
  (0, react.useLayoutEffect)(() => {
7621
7685
  if (!shouldVirtualize || !deduplicatedMessages.length) return;
@@ -7624,42 +7688,43 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
7624
7688
  const intelligenceTurnAnchors = (0, react.useMemo)(() => getIntelligenceTurnAnchors(deduplicatedMessages), [deduplicatedMessages]);
7625
7689
  const renderMessageBlock = (message) => {
7626
7690
  const elements = [];
7627
- const stateSnapshot = renderCustomMessage ? getStateSnapshotForMessage(message.id) : void 0;
7691
+ const stateSnapshot = getStateSnapshotForMessage(message.id);
7692
+ const rowKey = rowRenderKeys.get(message.id) ?? message.id;
7628
7693
  if (renderCustomMessage) elements.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemoizedCustomMessage, {
7629
7694
  message,
7630
7695
  position: "before",
7631
7696
  renderCustomMessage,
7632
7697
  stateSnapshot
7633
- }, `${message.id}-custom-before`));
7698
+ }, `${rowKey}-custom-before`));
7634
7699
  if (message.role === "assistant") elements.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemoizedAssistantMessage, {
7635
7700
  message,
7636
7701
  messages,
7637
7702
  isRunning,
7638
7703
  AssistantMessageComponent: AssistantComponent,
7639
7704
  slotProps: assistantSlotPropsWithFeedback
7640
- }, message.id));
7705
+ }, rowKey));
7641
7706
  else if (message.role === "user") elements.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemoizedUserMessage, {
7642
7707
  message,
7643
7708
  UserMessageComponent: UserComponent,
7644
7709
  slotProps: userSlotProps
7645
- }, message.id));
7710
+ }, rowKey));
7646
7711
  else if (message.role === "activity") elements.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemoizedActivityMessage, {
7647
7712
  message,
7648
7713
  renderActivityMessage
7649
- }, message.id));
7714
+ }, rowKey));
7650
7715
  else if (message.role === "reasoning") elements.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemoizedReasoningMessage, {
7651
7716
  message,
7652
7717
  messages,
7653
7718
  isRunning,
7654
7719
  ReasoningMessageComponent: ReasoningComponent,
7655
7720
  slotProps: reasoningSlotProps
7656
- }, message.id));
7721
+ }, rowKey));
7657
7722
  if (renderCustomMessage) elements.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemoizedCustomMessage, {
7658
7723
  message,
7659
7724
  position: "after",
7660
7725
  renderCustomMessage,
7661
7726
  stateSnapshot
7662
- }, `${message.id}-custom-after`));
7727
+ }, `${rowKey}-custom-after`));
7663
7728
  const intelligenceTurnId = intelligenceTurnAnchors.get(message.id);
7664
7729
  if (intelligenceTurnId !== void 0) elements.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(IntelligenceIndicator, {
7665
7730
  message,
@@ -7705,7 +7770,7 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
7705
7770
  transform: `translateY(${virtualItem.start}px)`
7706
7771
  },
7707
7772
  children: renderMessageBlock(message)
7708
- }, message.id);
7773
+ }, rowRenderKeys.get(message.id) ?? message.id);
7709
7774
  })
7710
7775
  }) : messageElements,
7711
7776
  interruptElement,
@@ -8268,28 +8333,25 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
8268
8333
  const BoundFeather = renderSlot(feather, CopilotChatView.Feather, {});
8269
8334
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ScrollElementContext.Provider, {
8270
8335
  value: scrollEl,
8271
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ScrollPinnedContext.Provider, {
8272
- value: isAtBottom,
8273
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
8274
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(use_stick_to_bottom.StickToBottom.Content, {
8275
- className: "cpk:overflow-y-auto cpk:overflow-x-hidden",
8276
- style: {
8277
- flex: "1 1 0%",
8278
- minHeight: 0
8279
- },
8280
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
8281
- className: "cpk:px-4 cpk:@3xl:px-0 cpk:[div[data-sidebar-chat]_&]:px-8 cpk:[div[data-popup-chat]_&]:px-6",
8282
- children
8283
- })
8284
- }),
8285
- BoundFeather,
8286
- !isAtBottom && !isResizing && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
8287
- className: "cpk:absolute cpk:inset-x-0 cpk:flex cpk:justify-center cpk:z-30 cpk:pointer-events-none",
8288
- style: { bottom: `${inputContainerHeight + SCROLL_BUTTON_OFFSET}px` },
8289
- children: renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, { onClick: () => scrollToBottom() })
8336
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
8337
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(use_stick_to_bottom.StickToBottom.Content, {
8338
+ className: "cpk:overflow-y-auto cpk:overflow-x-hidden",
8339
+ style: {
8340
+ flex: "1 1 0%",
8341
+ minHeight: 0
8342
+ },
8343
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
8344
+ className: "cpk:px-4 cpk:@3xl:px-0 cpk:[div[data-sidebar-chat]_&]:px-8 cpk:[div[data-popup-chat]_&]:px-6",
8345
+ children
8290
8346
  })
8291
- ] })
8292
- })
8347
+ }),
8348
+ BoundFeather,
8349
+ !isAtBottom && !isResizing && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
8350
+ className: "cpk:absolute cpk:inset-x-0 cpk:flex cpk:justify-center cpk:z-30 cpk:pointer-events-none",
8351
+ style: { bottom: `${inputContainerHeight + SCROLL_BUTTON_OFFSET}px` },
8352
+ children: renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, { onClick: () => scrollToBottom() })
8353
+ })
8354
+ ] })
8293
8355
  });
8294
8356
  };
8295
8357
  const PinToSendScrollContainer = ({ children, scrollRef, contentRef, scrollToBottom, scrollToBottomButton, feather, inputContainerHeight, isResizing, nonAutoScrollEl, nonAutoScrollRefCallback, showScrollButton, className, ...props }) => {
@@ -9021,14 +9083,7 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
9021
9083
  type: "text",
9022
9084
  text: value
9023
9085
  });
9024
- for (const att of readyAttachments) contentParts.push({
9025
- type: att.type,
9026
- source: att.source,
9027
- metadata: {
9028
- ...att.filename ? { filename: att.filename } : {},
9029
- ...att.metadata
9030
- }
9031
- });
9086
+ for (const att of readyAttachments) contentParts.push((0, _copilotkit_shared.createAttachmentContent)(att));
9032
9087
  agent.addMessage({
9033
9088
  id: (0, _copilotkit_shared.randomUUID)(),
9034
9089
  role: "user",
@@ -9958,10 +10013,10 @@ function findChatInput(origin) {
9958
10013
  * thread-list launcher appears, and binds the element `open` state to the
9959
10014
  * configuration's `drawerOpen`.
9960
10015
  *
9961
- * License gating is two-pronged: the locked view shows when no license is configured
9962
- * (the runtime reported no license status) OR the `threads` feature is
9963
- * explicitly unlicensed. While unlicensed, the thread fetch is skipped entirely
9964
- * so an unlicensed drawer issues no network requests.
10016
+ * Intelligence gating is two-pronged: the locked view shows when the runtime
10017
+ * reports no active entitlement OR the `threads` feature is unavailable. While
10018
+ * unavailable, the thread fetch is skipped entirely so the drawer issues no
10019
+ * network requests.
9965
10020
  *
9966
10021
  * Thread switching needs no host wiring: when `onThreadSelect`/`onNewThread`
9967
10022
  * are omitted, the wrapper drives the surrounding chat configuration directly
@@ -9973,7 +10028,7 @@ function findChatInput(origin) {
9973
10028
  * @example
9974
10029
  * ```tsx
9975
10030
  * // Callback-free: the drawer drives the chat configuration itself.
9976
- * <CopilotKitProvider runtimeUrl="/api/copilotkit" publicLicenseKey="ck_pub_...">
10031
+ * <CopilotKitProvider runtimeUrl="/api/copilotkit">
9977
10032
  * <CopilotChat />
9978
10033
  * <CopilotThreadsDrawer />
9979
10034
  * </CopilotKitProvider>
@@ -12852,6 +12907,12 @@ Object.defineProperty(exports, 'useFrontendTool', {
12852
12907
  return useFrontendTool;
12853
12908
  }
12854
12909
  });
12910
+ Object.defineProperty(exports, 'useFrontendTools', {
12911
+ enumerable: true,
12912
+ get: function () {
12913
+ return useFrontendTools;
12914
+ }
12915
+ });
12855
12916
  Object.defineProperty(exports, 'useHumanInTheLoop', {
12856
12917
  enumerable: true,
12857
12918
  get: function () {
@@ -12948,4 +13009,4 @@ Object.defineProperty(exports, 'useToast', {
12948
13009
  return useToast;
12949
13010
  }
12950
13011
  });
12951
- //# sourceMappingURL=copilotkit-BV7MguMm.cjs.map
13012
+ //# sourceMappingURL=copilotkit-D_c2dJ9t.cjs.map