@copilotkit/react-core 1.70.2 → 1.70.3

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 (33) hide show
  1. package/dist/{copilotkit-B1jSvZeb.mjs → copilotkit-Ap_yisA5.mjs} +220 -18
  2. package/dist/{copilotkit-DcFo270Y.cjs.map → copilotkit-Ap_yisA5.mjs.map} +1 -1
  3. package/dist/{copilotkit-DcFo270Y.cjs → copilotkit-BU3OvveB.cjs} +218 -16
  4. package/dist/copilotkit-BU3OvveB.cjs.map +1 -0
  5. package/dist/{copilotkit--Jyzm6hS.d.mts → copilotkit-Bs98akp9.d.mts} +2 -2
  6. package/dist/{copilotkit--Jyzm6hS.d.mts.map → copilotkit-Bs98akp9.d.mts.map} +1 -1
  7. package/dist/{copilotkit-BLYaCGcz.d.cts → copilotkit-X2eGbOwf.d.cts} +2 -2
  8. package/dist/{copilotkit-BLYaCGcz.d.cts.map → copilotkit-X2eGbOwf.d.cts.map} +1 -1
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +1 -1
  12. package/dist/index.d.cts.map +1 -1
  13. package/dist/index.d.mts +1 -1
  14. package/dist/index.d.mts.map +1 -1
  15. package/dist/index.mjs +1 -1
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/index.umd.js +217 -15
  18. package/dist/index.umd.js.map +1 -1
  19. package/dist/v2/headless.cjs +41 -2
  20. package/dist/v2/headless.cjs.map +1 -1
  21. package/dist/v2/headless.d.cts.map +1 -1
  22. package/dist/v2/headless.d.mts.map +1 -1
  23. package/dist/v2/headless.mjs +41 -2
  24. package/dist/v2/headless.mjs.map +1 -1
  25. package/dist/v2/index.cjs +1 -1
  26. package/dist/v2/index.d.cts +1 -1
  27. package/dist/v2/index.d.mts +1 -1
  28. package/dist/v2/index.mjs +1 -1
  29. package/dist/v2/index.umd.js +217 -15
  30. package/dist/v2/index.umd.js.map +1 -1
  31. package/package.json +7 -7
  32. package/skills/react-core/SKILL.md +1 -1
  33. package/dist/copilotkit-B1jSvZeb.mjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import * as React$1 from "react";
2
- import React, { createContext, forwardRef, memo, useCallback, useContext, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
2
+ import React, { createContext, createElement, forwardRef, memo, useCallback, useContext, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
3
3
  import { CopilotKitCore, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, ProxiedCopilotRuntimeAgent, ToolCallStatus, emitInspectorActiveThread, emitInspectorViewThreadResult, isInspectorThreadBridgeEnabled, isRunCompletionAware, onInspectorStopViewing, onInspectorViewThread, ɵInterruptState, ɵcreateThreadStore, ɵselectFetchMoreError, ɵselectHasNextPage, ɵselectIsFetchingNextPage, ɵselectIsMutating, ɵselectMemories, ɵselectMemoriesAvailable, ɵselectMemoriesError, ɵselectMemoriesIsLoading, ɵselectMemoriesRealtimeStatus, ɵselectThreads, ɵselectThreadsError, ɵselectThreadsIsLoading } from "@copilotkit/core";
4
4
  import { HttpAgent, randomUUID } from "@ag-ui/client";
5
5
  import { extendTailwindMerge, twMerge } from "tailwind-merge";
@@ -14,7 +14,7 @@ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
14
14
  import { Streamdown } from "streamdown";
15
15
  import { CopilotKitContext, LicenseContext, useCopilotKit, useCopilotKit as useCopilotKit$1, useLicenseContext, useLicenseContext as useLicenseContext$1 } from "@copilotkit/react-core/v2/context";
16
16
  import { z } from "zod";
17
- import { A2UIProvider, A2UIRenderer, A2UI_SCHEMA_CONTEXT_DESCRIPTION, Catalog, DEFAULT_SURFACE_ID, buildCatalogContextValue, extractCatalogComponentSchemas, filterCatalog, initializeDefaultCatalog, injectStyles, useA2UIActions, useA2UIError, viewerTheme } from "@copilotkit/a2ui-renderer";
17
+ import { A2UIProvider, A2UIRenderer, A2UI_SCHEMA_CONTEXT_DESCRIPTION, Catalog, DEFAULT_SURFACE_ID, ROOT_COMPONENT_ID, buildCatalogContextValue, extractCatalogComponentSchemas, filterCatalog, initializeDefaultCatalog, injectStyles, useA2UIActions, useA2UIError, viewerTheme } from "@copilotkit/a2ui-renderer";
18
18
  import { zodToJsonSchema } from "zod-to-json-schema";
19
19
  import { createPortal, flushSync } from "react-dom";
20
20
  import { useVirtualizer } from "@tanstack/react-virtual";
@@ -1519,6 +1519,29 @@ const ToolCallRenderer = React.memo(function ToolCallRenderer({ toolCall, toolMe
1519
1519
  if (prevProps.RenderComponent !== nextProps.RenderComponent) return false;
1520
1520
  return true;
1521
1521
  });
1522
+ const IS_DEVELOPMENT$1 = process.env.NODE_ENV !== "production";
1523
+ /**
1524
+ * Reports tool calls that resolved to no renderer.
1525
+ *
1526
+ * A tool call with no renderer paints an empty message container and says
1527
+ * nothing else, so the only signal a developer gets today is a blank space in
1528
+ * the chat. This names the call and the renderers that *are* registered, which
1529
+ * is the whole diagnosis when the cause is a name that does not match.
1530
+ *
1531
+ * @param toolNames - The unmatched tool names collected during render.
1532
+ * @param registered - The registry as it stands now, re-read at report time.
1533
+ * @param alreadyWarned - Names already reported, mutated to keep this once per name.
1534
+ */
1535
+ function warnAboutUnrenderedToolCalls(toolNames, registered, alreadyWarned) {
1536
+ const registeredNames = Array.from(new Set(registered.map((rc) => rc.name)));
1537
+ const hasWildcard = registeredNames.includes("*");
1538
+ for (const toolName of toolNames) {
1539
+ if (hasWildcard || registeredNames.includes(toolName)) continue;
1540
+ if (alreadyWarned.has(toolName)) continue;
1541
+ alreadyWarned.add(toolName);
1542
+ console.warn(`[CopilotKit] The agent called the tool "${toolName}", and no renderer is registered for it, so that message rendered nothing. ` + (registeredNames.length === 0 ? "No tool-call renderers are registered. " : `Registered renderers: ${registeredNames.map((name) => `"${name}"`).join(", ")}. `) + `Register one with useRenderTool({ name: "${toolName}", ... }), or call useDefaultRenderTool() for a built-in card that covers every tool the agent calls. This warning is development-only.`);
1543
+ }
1544
+ }
1522
1545
  /**
1523
1546
  * Hook that returns a function to render tool calls based on the render functions
1524
1547
  * defined in CopilotKitProvider.
@@ -1528,13 +1551,18 @@ const ToolCallRenderer = React.memo(function ToolCallRenderer({ toolCall, toolMe
1528
1551
  function useRenderToolCall() {
1529
1552
  const { copilotkit, executingToolCallIds } = useCopilotKit();
1530
1553
  const agentId = useCopilotChatConfiguration()?.agentId ?? DEFAULT_AGENT_ID;
1554
+ const unrenderedToolNames = useRef(/* @__PURE__ */ new Set());
1555
+ const warnedToolNames = useRef(/* @__PURE__ */ new Set());
1531
1556
  const renderToolCalls = useSyncExternalStore((callback) => {
1532
1557
  return copilotkit.subscribe({ onRenderToolCallsChanged: callback }).unsubscribe;
1533
1558
  }, () => copilotkit.renderToolCalls, () => copilotkit.renderToolCalls);
1534
- return useCallback(({ toolCall, toolMessage }) => {
1559
+ const renderToolCall = useCallback(({ toolCall, toolMessage }) => {
1535
1560
  const exactMatches = renderToolCalls.filter((rc) => rc.name === toolCall.function.name);
1536
1561
  const renderConfig = exactMatches.find((rc) => rc.agentId === agentId) || exactMatches.find((rc) => !rc.agentId) || exactMatches[0] || renderToolCalls.find((rc) => rc.name === "*");
1537
- if (!renderConfig) return null;
1562
+ if (!renderConfig) {
1563
+ if (IS_DEVELOPMENT$1) unrenderedToolNames.current.add(toolCall.function.name);
1564
+ return null;
1565
+ }
1538
1566
  const RenderComponent = renderConfig.render;
1539
1567
  return /* @__PURE__ */ jsx(ToolCallRenderer, {
1540
1568
  toolCall,
@@ -1547,6 +1575,17 @@ function useRenderToolCall() {
1547
1575
  executingToolCallIds,
1548
1576
  agentId
1549
1577
  ]);
1578
+ useEffect(() => {
1579
+ if (!IS_DEVELOPMENT$1) return;
1580
+ if (unrenderedToolNames.current.size === 0) return;
1581
+ const timer = setTimeout(() => {
1582
+ const pending = Array.from(unrenderedToolNames.current);
1583
+ unrenderedToolNames.current.clear();
1584
+ warnAboutUnrenderedToolCalls(pending, copilotkit.renderToolCalls, warnedToolNames.current);
1585
+ }, 0);
1586
+ return () => clearTimeout(timer);
1587
+ });
1588
+ return renderToolCall;
1550
1589
  }
1551
1590
 
1552
1591
  //#endregion
@@ -3025,6 +3064,95 @@ const A2UISurfaceContentSchema = z.object({
3025
3064
  a2ui_operations: z.array(z.any()).optional(),
3026
3065
  ...A2UILifecycleFields
3027
3066
  }).passthrough();
3067
+ const IS_DEVELOPMENT = process.env.NODE_ENV !== "production";
3068
+ /**
3069
+ * How long to wait for a surface to report its first paint before giving up on
3070
+ * the loader cross-over. Reaching it also means `onReady` never fired, which is
3071
+ * the signal the warning below reports.
3072
+ */
3073
+ const PAINT_FALLBACK_MS = 8e3;
3074
+ /**
3075
+ * Names the operation kinds a surface received, for a warning that has to say
3076
+ * what did arrive as well as what did not.
3077
+ *
3078
+ * @param operations - The operations grouped under one surface.
3079
+ * @returns A comma-separated list of operation keys, or "none".
3080
+ */
3081
+ function describeOperationKinds(operations) {
3082
+ const kinds = /* @__PURE__ */ new Set();
3083
+ for (const operation of operations) {
3084
+ if (!operation || typeof operation !== "object") continue;
3085
+ for (const key of Object.keys(operation)) if (key !== "version") kinds.add(key);
3086
+ }
3087
+ return kinds.size === 0 ? "none" : Array.from(kinds).join(", ");
3088
+ }
3089
+ /**
3090
+ * Reports surfaces that received operations and never painted.
3091
+ *
3092
+ * Reaching {@link PAINT_FALLBACK_MS} with no `onReady` means the operations were
3093
+ * accepted, were not malformed enough to raise the provider's error state, and
3094
+ * still put nothing on screen. Left alone that is invisible: the loader drops,
3095
+ * the turn finishes, and the only trace is an empty placeholder above the reply.
3096
+ *
3097
+ * `surfaceHasRenderableContent` already knows which half is missing, so the
3098
+ * warning says which rather than making the reader re-derive it.
3099
+ *
3100
+ * @param grouped - Operations grouped by surface id.
3101
+ */
3102
+ function warnAboutUnpaintedSurfaces(grouped) {
3103
+ for (const [surfaceId, operations] of grouped) {
3104
+ if (surfaceHasRenderableContent(operations)) continue;
3105
+ const cause = operations.filter((o) => o?.updateComponents).length === 0 ? "no updateComponents operation arrived, so the surface was never given anything to draw" : "its components address their values by \"path\" and no updateDataModel carried a non-empty value, so every bound component drew empty";
3106
+ console.warn(`[CopilotKit] A2UI surface "${surfaceId}" received operations and never painted after ${String(PAINT_FALLBACK_MS)}ms: ${cause}. Operations received: ${describeOperationKinds(operations)}. The payload was accepted, so check what the agent sent rather than the client wiring. This warning is development-only.`);
3107
+ }
3108
+ }
3109
+ /**
3110
+ * Names the component ids a surface was sent, for a warning about the one id
3111
+ * that is missing.
3112
+ *
3113
+ * @param operations - The operations grouped under one surface.
3114
+ * @returns A quoted, comma-separated list of ids, or "none".
3115
+ */
3116
+ function describeComponentIds(operations) {
3117
+ const ids = [];
3118
+ for (const operation of operations) {
3119
+ const components = operation?.updateComponents?.components;
3120
+ if (!Array.isArray(components)) continue;
3121
+ for (const component of components) {
3122
+ const id = component?.id;
3123
+ if (typeof id === "string" && !ids.includes(id)) ids.push(id);
3124
+ }
3125
+ }
3126
+ return ids.length === 0 ? "none" : ids.map((id) => `"${id}"`).join(", ");
3127
+ }
3128
+ /**
3129
+ * Reports a surface that is still waiting for its {@link ROOT_COMPONENT_ID}
3130
+ * component once its operations have stopped arriving.
3131
+ *
3132
+ * Both renderers begin walking a surface at that one id, and treat an id they
3133
+ * cannot find as not arrived yet — an animated placeholder. That is right while
3134
+ * operations stream. Once they have stopped it is not waiting, it is stuck, and
3135
+ * every other check calls it healthy: the surface exists, `processMessages` did
3136
+ * not throw, the component types were never reached, and
3137
+ * `surfaceHasRenderableContent` says yes on the strength of components plus a
3138
+ * data model, so `onReady` fires and the never-painted report is suppressed.
3139
+ * A complete, accepted payload therefore animates a grey box forever in silence.
3140
+ *
3141
+ * Reads the live components model rather than scanning the operations for the
3142
+ * id, so it covers every way the root can fail to resolve — not only a payload
3143
+ * that never named one.
3144
+ *
3145
+ * @param surfaceId - The surface the operations were addressed to.
3146
+ * @param operations - The operations processed for that surface.
3147
+ * @param surface - The live surface model, already known to exist.
3148
+ */
3149
+ function warnAboutUnresolvedRoot(surfaceId, operations, surface) {
3150
+ if (surface?.componentsModel?.get?.(ROOT_COMPONENT_ID)) return;
3151
+ const componentOps = operations.filter((o) => o?.updateComponents);
3152
+ if (componentOps.length === 0) return;
3153
+ const cause = componentOps.some((o) => o.updateComponents?.components?.some?.((c) => c?.id === ROOT_COMPONENT_ID)) ? `a component with id "${ROOT_COMPONENT_ID}" WAS sent, so the components did not reach the surface's model — check for an A2UI render error above, or a catalog that took none of them` : `the components it received are named ${describeComponentIds(operations)}, and none of them is "${ROOT_COMPONENT_ID}" — rename the entry-point component to "${ROOT_COMPONENT_ID}", and make every other component reachable from it through child/children`;
3154
+ console.warn(`[CopilotKit] A2UI surface "${surfaceId}" has no "${ROOT_COMPONENT_ID}" component ${String(PAINT_FALLBACK_MS)}ms after its last operations were processed, so it is showing the placeholder for a component that has not arrived yet and will keep showing it: ${cause}. Operations received: ${describeOperationKinds(operations)}. This warning is development-only.`);
3155
+ }
3028
3156
  function createA2UIMessageRenderer(options) {
3029
3157
  const { theme, catalog, loadingComponent, recovery, onAction } = options;
3030
3158
  const showAfterMs = recovery?.showAfterMs ?? 2e3;
@@ -3058,6 +3186,8 @@ function createA2UIMessageRenderer(options) {
3058
3186
  return groups;
3059
3187
  }, [operations]);
3060
3188
  const hasOps = groupedOperations.size > 0;
3189
+ const groupedOperationsRef = useRef(groupedOperations);
3190
+ groupedOperationsRef.current = groupedOperations;
3061
3191
  const renderLifecycle = (c) => {
3062
3192
  const status = c?.status;
3063
3193
  const debugExposure = resolveDebugExposure(c, optionDebugExposure);
@@ -3089,7 +3219,10 @@ function createA2UIMessageRenderer(options) {
3089
3219
  readyRef.current = false;
3090
3220
  return;
3091
3221
  }
3092
- const t = setTimeout(() => setSurfaceReady(true), 8e3);
3222
+ const t = setTimeout(() => {
3223
+ setSurfaceReady(true);
3224
+ if (IS_DEVELOPMENT && !readyRef.current) warnAboutUnpaintedSurfaces(groupedOperationsRef.current);
3225
+ }, PAINT_FALLBACK_MS);
3093
3226
  return () => clearTimeout(t);
3094
3227
  }, [hasOps]);
3095
3228
  if (!hasOps) return renderLifecycle(content);
@@ -3213,8 +3346,21 @@ function SurfaceMessageProcessor({ surfaceId, operations, onReady }) {
3213
3346
  const hash = JSON.stringify(operations);
3214
3347
  if (hash === lastHashRef.current) return;
3215
3348
  lastHashRef.current = hash;
3216
- processMessages(getSurface(surfaceId) ? operations.filter((op) => !op?.createSurface) : operations);
3349
+ const ops = getSurface(surfaceId) ? operations.filter((op) => !op?.createSurface) : operations;
3350
+ processMessages(ops);
3217
3351
  if (onReady && surfaceHasRenderableContent(operations)) onReady();
3352
+ if (!IS_DEVELOPMENT) return;
3353
+ if (!getSurface(surfaceId)) {
3354
+ const missingSurfaceCheck = setTimeout(() => {
3355
+ if (getSurface(surfaceId)) return;
3356
+ console.warn(`[CopilotKit] A2UI processed ${String(ops.length)} operation(s) addressed to surface "${surfaceId}" and no surface by that id exists, so this card rendered nothing. Operations received: ${describeOperationKinds(ops)}. A createSurface for "${surfaceId}" has to arrive before, or with, the operations that target it. This warning is development-only.`);
3357
+ }, 0);
3358
+ return () => clearTimeout(missingSurfaceCheck);
3359
+ }
3360
+ const unresolvedRootCheck = setTimeout(() => {
3361
+ warnAboutUnresolvedRoot(surfaceId, operations, getSurface(surfaceId));
3362
+ }, PAINT_FALLBACK_MS);
3363
+ return () => clearTimeout(unresolvedRootCheck);
3218
3364
  }, [
3219
3365
  processMessages,
3220
3366
  getSurface,
@@ -3241,10 +3387,26 @@ function surfaceHasRenderableContent(operations) {
3241
3387
  return Object.values(v).some((x) => Array.isArray(x) ? x.length > 0 : x !== null && x !== void 0 && x !== "");
3242
3388
  });
3243
3389
  }
3390
+ /**
3391
+ * Resolves the surface an operation addresses.
3392
+ *
3393
+ * The nested v0.9 `surfaceId` wins, because that is the id `MessageProcessor`
3394
+ * creates the surface under. Grouping by a top-level `surfaceId` instead files
3395
+ * the operations against a surface that never exists, which paints nothing —
3396
+ * the silence the missing-surface report above now names. A top-level
3397
+ * `surfaceId` is not the v0.9 shape, so it is honoured only when no nested id is
3398
+ * present. `getSurfaceId` in `@copilotkit/a2ui-renderer`'s web-components path
3399
+ * resolves it in the same order; the two disagreeing is what OSS-1048 recorded.
3400
+ *
3401
+ * @param operation - One A2UI operation, of any shape.
3402
+ * @returns The surface id, or null when the operation names none.
3403
+ */
3244
3404
  function getOperationSurfaceId(operation) {
3245
3405
  if (!operation || typeof operation !== "object") return null;
3406
+ const nested = operation?.createSurface?.surfaceId ?? operation?.updateComponents?.surfaceId ?? operation?.updateDataModel?.surfaceId ?? operation?.deleteSurface?.surfaceId;
3407
+ if (typeof nested === "string") return nested;
3246
3408
  if (typeof operation.surfaceId === "string") return operation.surfaceId;
3247
- return operation?.createSurface?.surfaceId ?? operation?.updateComponents?.surfaceId ?? operation?.updateDataModel?.surfaceId ?? operation?.deleteSurface?.surfaceId ?? null;
3409
+ return null;
3248
3410
  }
3249
3411
 
3250
3412
  //#endregion
@@ -3458,6 +3620,9 @@ const COPILOT_CLOUD_CHAT_URL$1 = "https://api.cloud.copilotkit.ai/copilotkit/v1"
3458
3620
  const EMPTY_HEADERS = Object.freeze({});
3459
3621
  const EMPTY_PROPERTIES = Object.freeze({});
3460
3622
  const EMPTY_AGENTS = Object.freeze({});
3623
+ /** Registration name of a catch-all tool: handles any otherwise-unhandled call. */
3624
+ const WILDCARD_TOOL_NAME$1 = "*";
3625
+ const HUMAN_IN_THE_LOOP_ABORTED_MESSAGE = "Human-in-the-loop interaction aborted";
3461
3626
  const DEFAULT_DESIGN_SKILL = `When generating UI with generateSandboxedUi, follow these design principles inspired by shadcn/ui:
3462
3627
 
3463
3628
  - Use a minimal, flat aesthetic. Avoid drop shadows and gradients — rely on subtle borders (1px solid, light gray like #e5e7eb) to define surfaces.
@@ -3576,6 +3741,11 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3576
3741
  }
3577
3742
  const chatApiEndpoint = runtimeUrl ?? (resolvedPublicKey ? COPILOT_CLOUD_CHAT_URL$1 : void 0);
3578
3743
  const frontendToolsList = useStableArrayProp(frontendTools, "frontendTools must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead.");
3744
+ /**
3745
+ * A `humanInTheLoop` prop tool call that is parked, waiting on the user.
3746
+ * Keyed by tool call id, so parallel calls of one tool stay independent.
3747
+ */
3748
+ const pendingHumanInTheLoopRef = useRef(/* @__PURE__ */ new Map());
3579
3749
  const humanInTheLoopList = useStableArrayProp(humanInTheLoop, "humanInTheLoop must be a stable array. If you want to dynamically add or remove human-in-the-loop tools, use `useHumanInTheLoop` instead.");
3580
3750
  const sandboxFunctionsList = useStableArrayProp(openGenerativeUI?.sandboxFunctions, "openGenerativeUI.sandboxFunctions must be a stable array.");
3581
3751
  const processedHumanInTheLoopTools = useMemo(() => {
@@ -3588,20 +3758,52 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3588
3758
  parameters: tool.parameters,
3589
3759
  followUp: tool.followUp,
3590
3760
  ...tool.agentId && { agentId: tool.agentId },
3591
- handler: async () => {
3592
- return new Promise((resolve) => {
3593
- console.warn(`Human-in-the-loop tool '${tool.name}' called but no interactive handler is set up.`);
3594
- resolve(void 0);
3761
+ handler: async (_args, context) => {
3762
+ const signal = context?.signal;
3763
+ const key = context?.toolCall?.id ?? tool.name;
3764
+ return new Promise((resolve, reject) => {
3765
+ if (signal?.aborted) {
3766
+ reject(new Error(HUMAN_IN_THE_LOOP_ABORTED_MESSAGE));
3767
+ return;
3768
+ }
3769
+ const pending = { resolve };
3770
+ pendingHumanInTheLoopRef.current.set(key, pending);
3771
+ if (signal) {
3772
+ const onAbort = () => {
3773
+ pendingHumanInTheLoopRef.current.delete(key);
3774
+ reject(new Error(HUMAN_IN_THE_LOOP_ABORTED_MESSAGE));
3775
+ };
3776
+ signal.addEventListener("abort", onAbort, { once: true });
3777
+ pending.detachAbort = () => {
3778
+ signal.removeEventListener("abort", onAbort);
3779
+ };
3780
+ }
3595
3781
  });
3596
3782
  }
3597
3783
  };
3598
3784
  processedTools.push(frontendTool);
3599
- if (tool.render) processedRenderToolCalls.push({
3600
- name: tool.name,
3601
- args: tool.parameters,
3602
- render: tool.render,
3603
- ...tool.agentId && { agentId: tool.agentId }
3604
- });
3785
+ if (tool.render) {
3786
+ const ToolComponent = tool.render;
3787
+ const RenderComponent = (props) => createElement(ToolComponent, {
3788
+ ...props,
3789
+ name: tool.name === WILDCARD_TOOL_NAME$1 ? props.name : tool.name,
3790
+ description: tool.description || "",
3791
+ agentId: tool.agentId,
3792
+ respond: props.status === ToolCallStatus.Executing ? async (result) => {
3793
+ const pending = pendingHumanInTheLoopRef.current.get(props.toolCallId);
3794
+ if (!pending) return;
3795
+ pending.detachAbort?.();
3796
+ pendingHumanInTheLoopRef.current.delete(props.toolCallId);
3797
+ pending.resolve(result);
3798
+ } : void 0
3799
+ });
3800
+ processedRenderToolCalls.push({
3801
+ name: tool.name,
3802
+ args: tool.parameters,
3803
+ render: RenderComponent,
3804
+ ...tool.agentId && { agentId: tool.agentId }
3805
+ });
3806
+ }
3605
3807
  });
3606
3808
  return {
3607
3809
  tools: processedTools,
@@ -12248,4 +12450,4 @@ function validateProps(props) {
12248
12450
 
12249
12451
  //#endregion
12250
12452
  export { useAgentContext as $, CopilotChatMessageView as A, AudioRecorderError as At, CopilotChatAssistantMessage_default as B, CopilotModalHeader as C, MCPAppsActivityContentSchema as Ct, CopilotChat as D, CopilotKitInspector as Dt, DefaultOpenIcon as E, ɵrunMcpFollowUp as Et, CopilotChatSuggestionView as F, useLearnFromUserActionInCurrentThread as G, useLearningContainersInCurrentThread as H, CopilotChatSuggestionPill as I, useThreads$1 as J, useLearnFromUserAction as K, CopilotChatReasoningMessage_default as L, IntelligenceIndicator as M, CopilotChatConfigurationProvider as Mt, getIntelligenceTurnAnchors as N, useCopilotChatConfiguration as Nt, CopilotChatView_default as O, useRenderToolCall as Ot, IntelligenceIndicatorView as P, useSuggestions as Q, CopilotChatUserMessage_default as R, CopilotSidebarView as S, useSandboxFunctions as St, DefaultCloseIcon as T, MCPAppsActivityType as Tt, useLearningContainers as U, CopilotChatToolCallsView as V, useAttachments as W, INTERRUPT_EVENT_NAME as X, useInterrupt as Y, useConfigureSuggestions as Z, WildcardToolCallRender as _, OpenGenerativeUIActivityRenderer as _t, ThreadsProvider as a, useRenderTool as at, CopilotSidebar as b, OpenGenerativeUIToolRenderer as bt, CoAgentStateRendersProvider as c, useRenderActivityMessage as ct, shouldShowDevConsole as d, useCopilotKit$1 as dt, useCapabilities as et, useToast as f, useLicenseContext$1 as ft, useCopilotContext as g, GenerateSandboxedUiArgsSchema as gt, CopilotContext as h, createA2UIMessageRenderer as ht, ThreadsContext as i, useDefaultRenderTool as it, INTELLIGENCE_TURN_HEAD as j, CopilotChatAudioRecorder as jt, CopilotChatAttachmentQueue as k, CopilotChatInput_default as kt, useCoAgentStateRenders as l, useRenderCustomMessages as lt, useCopilotMessagesContext as m, defineToolCallRenderer as mt, defaultCopilotContextCategories as n, useAgent as nt, useThreads as o, useComponent as ot, CopilotMessagesContext as p, CopilotKitCoreReact as pt, useMemories as q, CoAgentStateRenderBridge as r, useHumanInTheLoop as rt, CoAgentStateRendersContext as s, useFrontendTool as st, CopilotKit as t, UseAgentUpdate as tt, useAsyncCallback as u, CopilotKitProvider as ut, CopilotThreadsDrawer as v, OpenGenerativeUIActivityType as vt, CopilotChatToggleButton as w, MCPAppsActivityRenderer as wt, CopilotPopupView as x, SandboxFunctionsContext as xt, CopilotPopup as y, OpenGenerativeUIContentSchema as yt, CopilotChatAttachmentRenderer as z };
12251
- //# sourceMappingURL=copilotkit-B1jSvZeb.mjs.map
12453
+ //# sourceMappingURL=copilotkit-Ap_yisA5.mjs.map