@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.
- package/dist/{copilotkit-B1jSvZeb.mjs → copilotkit-Ap_yisA5.mjs} +220 -18
- package/dist/{copilotkit-DcFo270Y.cjs.map → copilotkit-Ap_yisA5.mjs.map} +1 -1
- package/dist/{copilotkit-DcFo270Y.cjs → copilotkit-BU3OvveB.cjs} +218 -16
- package/dist/copilotkit-BU3OvveB.cjs.map +1 -0
- package/dist/{copilotkit--Jyzm6hS.d.mts → copilotkit-Bs98akp9.d.mts} +2 -2
- package/dist/{copilotkit--Jyzm6hS.d.mts.map → copilotkit-Bs98akp9.d.mts.map} +1 -1
- package/dist/{copilotkit-BLYaCGcz.d.cts → copilotkit-X2eGbOwf.d.cts} +2 -2
- package/dist/{copilotkit-BLYaCGcz.d.cts.map → copilotkit-X2eGbOwf.d.cts.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +217 -15
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +41 -2
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +41 -2
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.d.cts +1 -1
- package/dist/v2/index.d.mts +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +217 -15
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +7 -7
- package/skills/react-core/SKILL.md +1 -1
- package/dist/copilotkit-B1jSvZeb.mjs.map +0 -1
|
@@ -1549,6 +1549,29 @@ const ToolCallRenderer = react.default.memo(function ToolCallRenderer({ toolCall
|
|
|
1549
1549
|
if (prevProps.RenderComponent !== nextProps.RenderComponent) return false;
|
|
1550
1550
|
return true;
|
|
1551
1551
|
});
|
|
1552
|
+
const IS_DEVELOPMENT$1 = process.env.NODE_ENV !== "production";
|
|
1553
|
+
/**
|
|
1554
|
+
* Reports tool calls that resolved to no renderer.
|
|
1555
|
+
*
|
|
1556
|
+
* A tool call with no renderer paints an empty message container and says
|
|
1557
|
+
* nothing else, so the only signal a developer gets today is a blank space in
|
|
1558
|
+
* the chat. This names the call and the renderers that *are* registered, which
|
|
1559
|
+
* is the whole diagnosis when the cause is a name that does not match.
|
|
1560
|
+
*
|
|
1561
|
+
* @param toolNames - The unmatched tool names collected during render.
|
|
1562
|
+
* @param registered - The registry as it stands now, re-read at report time.
|
|
1563
|
+
* @param alreadyWarned - Names already reported, mutated to keep this once per name.
|
|
1564
|
+
*/
|
|
1565
|
+
function warnAboutUnrenderedToolCalls(toolNames, registered, alreadyWarned) {
|
|
1566
|
+
const registeredNames = Array.from(new Set(registered.map((rc) => rc.name)));
|
|
1567
|
+
const hasWildcard = registeredNames.includes("*");
|
|
1568
|
+
for (const toolName of toolNames) {
|
|
1569
|
+
if (hasWildcard || registeredNames.includes(toolName)) continue;
|
|
1570
|
+
if (alreadyWarned.has(toolName)) continue;
|
|
1571
|
+
alreadyWarned.add(toolName);
|
|
1572
|
+
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.`);
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1552
1575
|
/**
|
|
1553
1576
|
* Hook that returns a function to render tool calls based on the render functions
|
|
1554
1577
|
* defined in CopilotKitProvider.
|
|
@@ -1558,13 +1581,18 @@ const ToolCallRenderer = react.default.memo(function ToolCallRenderer({ toolCall
|
|
|
1558
1581
|
function useRenderToolCall() {
|
|
1559
1582
|
const { copilotkit, executingToolCallIds } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
1560
1583
|
const agentId = useCopilotChatConfiguration()?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
1584
|
+
const unrenderedToolNames = (0, react.useRef)(/* @__PURE__ */ new Set());
|
|
1585
|
+
const warnedToolNames = (0, react.useRef)(/* @__PURE__ */ new Set());
|
|
1561
1586
|
const renderToolCalls = (0, react.useSyncExternalStore)((callback) => {
|
|
1562
1587
|
return copilotkit.subscribe({ onRenderToolCallsChanged: callback }).unsubscribe;
|
|
1563
1588
|
}, () => copilotkit.renderToolCalls, () => copilotkit.renderToolCalls);
|
|
1564
|
-
|
|
1589
|
+
const renderToolCall = (0, react.useCallback)(({ toolCall, toolMessage }) => {
|
|
1565
1590
|
const exactMatches = renderToolCalls.filter((rc) => rc.name === toolCall.function.name);
|
|
1566
1591
|
const renderConfig = exactMatches.find((rc) => rc.agentId === agentId) || exactMatches.find((rc) => !rc.agentId) || exactMatches[0] || renderToolCalls.find((rc) => rc.name === "*");
|
|
1567
|
-
if (!renderConfig)
|
|
1592
|
+
if (!renderConfig) {
|
|
1593
|
+
if (IS_DEVELOPMENT$1) unrenderedToolNames.current.add(toolCall.function.name);
|
|
1594
|
+
return null;
|
|
1595
|
+
}
|
|
1568
1596
|
const RenderComponent = renderConfig.render;
|
|
1569
1597
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolCallRenderer, {
|
|
1570
1598
|
toolCall,
|
|
@@ -1577,6 +1605,17 @@ function useRenderToolCall() {
|
|
|
1577
1605
|
executingToolCallIds,
|
|
1578
1606
|
agentId
|
|
1579
1607
|
]);
|
|
1608
|
+
(0, react.useEffect)(() => {
|
|
1609
|
+
if (!IS_DEVELOPMENT$1) return;
|
|
1610
|
+
if (unrenderedToolNames.current.size === 0) return;
|
|
1611
|
+
const timer = setTimeout(() => {
|
|
1612
|
+
const pending = Array.from(unrenderedToolNames.current);
|
|
1613
|
+
unrenderedToolNames.current.clear();
|
|
1614
|
+
warnAboutUnrenderedToolCalls(pending, copilotkit.renderToolCalls, warnedToolNames.current);
|
|
1615
|
+
}, 0);
|
|
1616
|
+
return () => clearTimeout(timer);
|
|
1617
|
+
});
|
|
1618
|
+
return renderToolCall;
|
|
1580
1619
|
}
|
|
1581
1620
|
|
|
1582
1621
|
//#endregion
|
|
@@ -3055,6 +3094,95 @@ const A2UISurfaceContentSchema = zod.z.object({
|
|
|
3055
3094
|
a2ui_operations: zod.z.array(zod.z.any()).optional(),
|
|
3056
3095
|
...A2UILifecycleFields
|
|
3057
3096
|
}).passthrough();
|
|
3097
|
+
const IS_DEVELOPMENT = process.env.NODE_ENV !== "production";
|
|
3098
|
+
/**
|
|
3099
|
+
* How long to wait for a surface to report its first paint before giving up on
|
|
3100
|
+
* the loader cross-over. Reaching it also means `onReady` never fired, which is
|
|
3101
|
+
* the signal the warning below reports.
|
|
3102
|
+
*/
|
|
3103
|
+
const PAINT_FALLBACK_MS = 8e3;
|
|
3104
|
+
/**
|
|
3105
|
+
* Names the operation kinds a surface received, for a warning that has to say
|
|
3106
|
+
* what did arrive as well as what did not.
|
|
3107
|
+
*
|
|
3108
|
+
* @param operations - The operations grouped under one surface.
|
|
3109
|
+
* @returns A comma-separated list of operation keys, or "none".
|
|
3110
|
+
*/
|
|
3111
|
+
function describeOperationKinds(operations) {
|
|
3112
|
+
const kinds = /* @__PURE__ */ new Set();
|
|
3113
|
+
for (const operation of operations) {
|
|
3114
|
+
if (!operation || typeof operation !== "object") continue;
|
|
3115
|
+
for (const key of Object.keys(operation)) if (key !== "version") kinds.add(key);
|
|
3116
|
+
}
|
|
3117
|
+
return kinds.size === 0 ? "none" : Array.from(kinds).join(", ");
|
|
3118
|
+
}
|
|
3119
|
+
/**
|
|
3120
|
+
* Reports surfaces that received operations and never painted.
|
|
3121
|
+
*
|
|
3122
|
+
* Reaching {@link PAINT_FALLBACK_MS} with no `onReady` means the operations were
|
|
3123
|
+
* accepted, were not malformed enough to raise the provider's error state, and
|
|
3124
|
+
* still put nothing on screen. Left alone that is invisible: the loader drops,
|
|
3125
|
+
* the turn finishes, and the only trace is an empty placeholder above the reply.
|
|
3126
|
+
*
|
|
3127
|
+
* `surfaceHasRenderableContent` already knows which half is missing, so the
|
|
3128
|
+
* warning says which rather than making the reader re-derive it.
|
|
3129
|
+
*
|
|
3130
|
+
* @param grouped - Operations grouped by surface id.
|
|
3131
|
+
*/
|
|
3132
|
+
function warnAboutUnpaintedSurfaces(grouped) {
|
|
3133
|
+
for (const [surfaceId, operations] of grouped) {
|
|
3134
|
+
if (surfaceHasRenderableContent(operations)) continue;
|
|
3135
|
+
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";
|
|
3136
|
+
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.`);
|
|
3137
|
+
}
|
|
3138
|
+
}
|
|
3139
|
+
/**
|
|
3140
|
+
* Names the component ids a surface was sent, for a warning about the one id
|
|
3141
|
+
* that is missing.
|
|
3142
|
+
*
|
|
3143
|
+
* @param operations - The operations grouped under one surface.
|
|
3144
|
+
* @returns A quoted, comma-separated list of ids, or "none".
|
|
3145
|
+
*/
|
|
3146
|
+
function describeComponentIds(operations) {
|
|
3147
|
+
const ids = [];
|
|
3148
|
+
for (const operation of operations) {
|
|
3149
|
+
const components = operation?.updateComponents?.components;
|
|
3150
|
+
if (!Array.isArray(components)) continue;
|
|
3151
|
+
for (const component of components) {
|
|
3152
|
+
const id = component?.id;
|
|
3153
|
+
if (typeof id === "string" && !ids.includes(id)) ids.push(id);
|
|
3154
|
+
}
|
|
3155
|
+
}
|
|
3156
|
+
return ids.length === 0 ? "none" : ids.map((id) => `"${id}"`).join(", ");
|
|
3157
|
+
}
|
|
3158
|
+
/**
|
|
3159
|
+
* Reports a surface that is still waiting for its {@link ROOT_COMPONENT_ID}
|
|
3160
|
+
* component once its operations have stopped arriving.
|
|
3161
|
+
*
|
|
3162
|
+
* Both renderers begin walking a surface at that one id, and treat an id they
|
|
3163
|
+
* cannot find as not arrived yet — an animated placeholder. That is right while
|
|
3164
|
+
* operations stream. Once they have stopped it is not waiting, it is stuck, and
|
|
3165
|
+
* every other check calls it healthy: the surface exists, `processMessages` did
|
|
3166
|
+
* not throw, the component types were never reached, and
|
|
3167
|
+
* `surfaceHasRenderableContent` says yes on the strength of components plus a
|
|
3168
|
+
* data model, so `onReady` fires and the never-painted report is suppressed.
|
|
3169
|
+
* A complete, accepted payload therefore animates a grey box forever in silence.
|
|
3170
|
+
*
|
|
3171
|
+
* Reads the live components model rather than scanning the operations for the
|
|
3172
|
+
* id, so it covers every way the root can fail to resolve — not only a payload
|
|
3173
|
+
* that never named one.
|
|
3174
|
+
*
|
|
3175
|
+
* @param surfaceId - The surface the operations were addressed to.
|
|
3176
|
+
* @param operations - The operations processed for that surface.
|
|
3177
|
+
* @param surface - The live surface model, already known to exist.
|
|
3178
|
+
*/
|
|
3179
|
+
function warnAboutUnresolvedRoot(surfaceId, operations, surface) {
|
|
3180
|
+
if (surface?.componentsModel?.get?.(_copilotkit_a2ui_renderer.ROOT_COMPONENT_ID)) return;
|
|
3181
|
+
const componentOps = operations.filter((o) => o?.updateComponents);
|
|
3182
|
+
if (componentOps.length === 0) return;
|
|
3183
|
+
const cause = componentOps.some((o) => o.updateComponents?.components?.some?.((c) => c?.id === _copilotkit_a2ui_renderer.ROOT_COMPONENT_ID)) ? `a component with id "${_copilotkit_a2ui_renderer.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 "${_copilotkit_a2ui_renderer.ROOT_COMPONENT_ID}" — rename the entry-point component to "${_copilotkit_a2ui_renderer.ROOT_COMPONENT_ID}", and make every other component reachable from it through child/children`;
|
|
3184
|
+
console.warn(`[CopilotKit] A2UI surface "${surfaceId}" has no "${_copilotkit_a2ui_renderer.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.`);
|
|
3185
|
+
}
|
|
3058
3186
|
function createA2UIMessageRenderer(options) {
|
|
3059
3187
|
const { theme, catalog, loadingComponent, recovery, onAction } = options;
|
|
3060
3188
|
const showAfterMs = recovery?.showAfterMs ?? 2e3;
|
|
@@ -3088,6 +3216,8 @@ function createA2UIMessageRenderer(options) {
|
|
|
3088
3216
|
return groups;
|
|
3089
3217
|
}, [operations]);
|
|
3090
3218
|
const hasOps = groupedOperations.size > 0;
|
|
3219
|
+
const groupedOperationsRef = (0, react.useRef)(groupedOperations);
|
|
3220
|
+
groupedOperationsRef.current = groupedOperations;
|
|
3091
3221
|
const renderLifecycle = (c) => {
|
|
3092
3222
|
const status = c?.status;
|
|
3093
3223
|
const debugExposure = resolveDebugExposure(c, optionDebugExposure);
|
|
@@ -3119,7 +3249,10 @@ function createA2UIMessageRenderer(options) {
|
|
|
3119
3249
|
readyRef.current = false;
|
|
3120
3250
|
return;
|
|
3121
3251
|
}
|
|
3122
|
-
const t = setTimeout(() =>
|
|
3252
|
+
const t = setTimeout(() => {
|
|
3253
|
+
setSurfaceReady(true);
|
|
3254
|
+
if (IS_DEVELOPMENT && !readyRef.current) warnAboutUnpaintedSurfaces(groupedOperationsRef.current);
|
|
3255
|
+
}, PAINT_FALLBACK_MS);
|
|
3123
3256
|
return () => clearTimeout(t);
|
|
3124
3257
|
}, [hasOps]);
|
|
3125
3258
|
if (!hasOps) return renderLifecycle(content);
|
|
@@ -3243,8 +3376,21 @@ function SurfaceMessageProcessor({ surfaceId, operations, onReady }) {
|
|
|
3243
3376
|
const hash = JSON.stringify(operations);
|
|
3244
3377
|
if (hash === lastHashRef.current) return;
|
|
3245
3378
|
lastHashRef.current = hash;
|
|
3246
|
-
|
|
3379
|
+
const ops = getSurface(surfaceId) ? operations.filter((op) => !op?.createSurface) : operations;
|
|
3380
|
+
processMessages(ops);
|
|
3247
3381
|
if (onReady && surfaceHasRenderableContent(operations)) onReady();
|
|
3382
|
+
if (!IS_DEVELOPMENT) return;
|
|
3383
|
+
if (!getSurface(surfaceId)) {
|
|
3384
|
+
const missingSurfaceCheck = setTimeout(() => {
|
|
3385
|
+
if (getSurface(surfaceId)) return;
|
|
3386
|
+
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.`);
|
|
3387
|
+
}, 0);
|
|
3388
|
+
return () => clearTimeout(missingSurfaceCheck);
|
|
3389
|
+
}
|
|
3390
|
+
const unresolvedRootCheck = setTimeout(() => {
|
|
3391
|
+
warnAboutUnresolvedRoot(surfaceId, operations, getSurface(surfaceId));
|
|
3392
|
+
}, PAINT_FALLBACK_MS);
|
|
3393
|
+
return () => clearTimeout(unresolvedRootCheck);
|
|
3248
3394
|
}, [
|
|
3249
3395
|
processMessages,
|
|
3250
3396
|
getSurface,
|
|
@@ -3271,10 +3417,26 @@ function surfaceHasRenderableContent(operations) {
|
|
|
3271
3417
|
return Object.values(v).some((x) => Array.isArray(x) ? x.length > 0 : x !== null && x !== void 0 && x !== "");
|
|
3272
3418
|
});
|
|
3273
3419
|
}
|
|
3420
|
+
/**
|
|
3421
|
+
* Resolves the surface an operation addresses.
|
|
3422
|
+
*
|
|
3423
|
+
* The nested v0.9 `surfaceId` wins, because that is the id `MessageProcessor`
|
|
3424
|
+
* creates the surface under. Grouping by a top-level `surfaceId` instead files
|
|
3425
|
+
* the operations against a surface that never exists, which paints nothing —
|
|
3426
|
+
* the silence the missing-surface report above now names. A top-level
|
|
3427
|
+
* `surfaceId` is not the v0.9 shape, so it is honoured only when no nested id is
|
|
3428
|
+
* present. `getSurfaceId` in `@copilotkit/a2ui-renderer`'s web-components path
|
|
3429
|
+
* resolves it in the same order; the two disagreeing is what OSS-1048 recorded.
|
|
3430
|
+
*
|
|
3431
|
+
* @param operation - One A2UI operation, of any shape.
|
|
3432
|
+
* @returns The surface id, or null when the operation names none.
|
|
3433
|
+
*/
|
|
3274
3434
|
function getOperationSurfaceId(operation) {
|
|
3275
3435
|
if (!operation || typeof operation !== "object") return null;
|
|
3436
|
+
const nested = operation?.createSurface?.surfaceId ?? operation?.updateComponents?.surfaceId ?? operation?.updateDataModel?.surfaceId ?? operation?.deleteSurface?.surfaceId;
|
|
3437
|
+
if (typeof nested === "string") return nested;
|
|
3276
3438
|
if (typeof operation.surfaceId === "string") return operation.surfaceId;
|
|
3277
|
-
return
|
|
3439
|
+
return null;
|
|
3278
3440
|
}
|
|
3279
3441
|
|
|
3280
3442
|
//#endregion
|
|
@@ -3488,6 +3650,9 @@ const COPILOT_CLOUD_CHAT_URL$1 = "https://api.cloud.copilotkit.ai/copilotkit/v1"
|
|
|
3488
3650
|
const EMPTY_HEADERS = Object.freeze({});
|
|
3489
3651
|
const EMPTY_PROPERTIES = Object.freeze({});
|
|
3490
3652
|
const EMPTY_AGENTS = Object.freeze({});
|
|
3653
|
+
/** Registration name of a catch-all tool: handles any otherwise-unhandled call. */
|
|
3654
|
+
const WILDCARD_TOOL_NAME$1 = "*";
|
|
3655
|
+
const HUMAN_IN_THE_LOOP_ABORTED_MESSAGE = "Human-in-the-loop interaction aborted";
|
|
3491
3656
|
const DEFAULT_DESIGN_SKILL = `When generating UI with generateSandboxedUi, follow these design principles inspired by shadcn/ui:
|
|
3492
3657
|
|
|
3493
3658
|
- Use a minimal, flat aesthetic. Avoid drop shadows and gradients — rely on subtle borders (1px solid, light gray like #e5e7eb) to define surfaces.
|
|
@@ -3606,6 +3771,11 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3606
3771
|
}
|
|
3607
3772
|
const chatApiEndpoint = runtimeUrl ?? (resolvedPublicKey ? COPILOT_CLOUD_CHAT_URL$1 : void 0);
|
|
3608
3773
|
const frontendToolsList = useStableArrayProp(frontendTools, "frontendTools must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead.");
|
|
3774
|
+
/**
|
|
3775
|
+
* A `humanInTheLoop` prop tool call that is parked, waiting on the user.
|
|
3776
|
+
* Keyed by tool call id, so parallel calls of one tool stay independent.
|
|
3777
|
+
*/
|
|
3778
|
+
const pendingHumanInTheLoopRef = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
3609
3779
|
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.");
|
|
3610
3780
|
const sandboxFunctionsList = useStableArrayProp(openGenerativeUI?.sandboxFunctions, "openGenerativeUI.sandboxFunctions must be a stable array.");
|
|
3611
3781
|
const processedHumanInTheLoopTools = (0, react.useMemo)(() => {
|
|
@@ -3618,20 +3788,52 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3618
3788
|
parameters: tool.parameters,
|
|
3619
3789
|
followUp: tool.followUp,
|
|
3620
3790
|
...tool.agentId && { agentId: tool.agentId },
|
|
3621
|
-
handler: async () => {
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3791
|
+
handler: async (_args, context) => {
|
|
3792
|
+
const signal = context?.signal;
|
|
3793
|
+
const key = context?.toolCall?.id ?? tool.name;
|
|
3794
|
+
return new Promise((resolve, reject) => {
|
|
3795
|
+
if (signal?.aborted) {
|
|
3796
|
+
reject(new Error(HUMAN_IN_THE_LOOP_ABORTED_MESSAGE));
|
|
3797
|
+
return;
|
|
3798
|
+
}
|
|
3799
|
+
const pending = { resolve };
|
|
3800
|
+
pendingHumanInTheLoopRef.current.set(key, pending);
|
|
3801
|
+
if (signal) {
|
|
3802
|
+
const onAbort = () => {
|
|
3803
|
+
pendingHumanInTheLoopRef.current.delete(key);
|
|
3804
|
+
reject(new Error(HUMAN_IN_THE_LOOP_ABORTED_MESSAGE));
|
|
3805
|
+
};
|
|
3806
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
3807
|
+
pending.detachAbort = () => {
|
|
3808
|
+
signal.removeEventListener("abort", onAbort);
|
|
3809
|
+
};
|
|
3810
|
+
}
|
|
3625
3811
|
});
|
|
3626
3812
|
}
|
|
3627
3813
|
};
|
|
3628
3814
|
processedTools.push(frontendTool);
|
|
3629
|
-
if (tool.render)
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3815
|
+
if (tool.render) {
|
|
3816
|
+
const ToolComponent = tool.render;
|
|
3817
|
+
const RenderComponent = (props) => (0, react.createElement)(ToolComponent, {
|
|
3818
|
+
...props,
|
|
3819
|
+
name: tool.name === WILDCARD_TOOL_NAME$1 ? props.name : tool.name,
|
|
3820
|
+
description: tool.description || "",
|
|
3821
|
+
agentId: tool.agentId,
|
|
3822
|
+
respond: props.status === _copilotkit_core.ToolCallStatus.Executing ? async (result) => {
|
|
3823
|
+
const pending = pendingHumanInTheLoopRef.current.get(props.toolCallId);
|
|
3824
|
+
if (!pending) return;
|
|
3825
|
+
pending.detachAbort?.();
|
|
3826
|
+
pendingHumanInTheLoopRef.current.delete(props.toolCallId);
|
|
3827
|
+
pending.resolve(result);
|
|
3828
|
+
} : void 0
|
|
3829
|
+
});
|
|
3830
|
+
processedRenderToolCalls.push({
|
|
3831
|
+
name: tool.name,
|
|
3832
|
+
args: tool.parameters,
|
|
3833
|
+
render: RenderComponent,
|
|
3834
|
+
...tool.agentId && { agentId: tool.agentId }
|
|
3835
|
+
});
|
|
3836
|
+
}
|
|
3635
3837
|
});
|
|
3636
3838
|
return {
|
|
3637
3839
|
tools: processedTools,
|
|
@@ -12793,4 +12995,4 @@ Object.defineProperty(exports, 'ɵrunMcpFollowUp', {
|
|
|
12793
12995
|
return ɵrunMcpFollowUp;
|
|
12794
12996
|
}
|
|
12795
12997
|
});
|
|
12796
|
-
//# sourceMappingURL=copilotkit-
|
|
12998
|
+
//# sourceMappingURL=copilotkit-BU3OvveB.cjs.map
|