@copilotkit/react-core 1.56.0 → 1.56.2-canary.pin-to-send
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-BebqQrYT.mjs → copilotkit-BBYbekCa.mjs} +265 -76
- package/dist/copilotkit-BBYbekCa.mjs.map +1 -0
- package/dist/{copilotkit-Cvb6WpAX.cjs → copilotkit-D5JT2Pu3.cjs} +264 -75
- package/dist/copilotkit-D5JT2Pu3.cjs.map +1 -0
- package/dist/{copilotkit-f2Uq0RwG.d.mts → copilotkit-DArT2Iuw.d.mts} +71 -18
- package/dist/copilotkit-DArT2Iuw.d.mts.map +1 -0
- package/dist/{copilotkit-Dv8zU8_U.d.cts → copilotkit-KEc28l8G.d.cts} +71 -18
- package/dist/copilotkit-KEc28l8G.d.cts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +30 -46
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.css +1 -1
- package/dist/v2/index.d.cts +2 -2
- package/dist/v2/index.d.mts +2 -2
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +264 -79
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +6 -6
- package/src/components/CopilotListeners.tsx +15 -4
- package/src/components/__tests__/CopilotListeners.test.tsx +38 -0
- package/src/v2/components/chat/CopilotChat.tsx +80 -4
- package/src/v2/components/chat/CopilotChatAssistantMessage.tsx +4 -4
- package/src/v2/components/chat/CopilotChatInput.tsx +43 -2
- package/src/v2/components/chat/CopilotChatView.tsx +206 -11
- package/src/v2/components/chat/__tests__/CopilotChat.absentThreadConnect.test.tsx +66 -0
- package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.tsx +300 -2
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.thumbs.test.tsx +72 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.test.tsx +38 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.connectingGate.test.tsx +56 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.pinToSend.test.tsx +94 -0
- package/src/v2/components/chat/__tests__/copilot-chat-throttle.test.tsx +0 -1
- package/src/v2/components/chat/__tests__/normalize-auto-scroll.test.ts +37 -0
- package/src/v2/components/chat/index.ts +2 -0
- package/src/v2/components/chat/last-user-message-context.ts +21 -0
- package/src/v2/components/chat/normalize-auto-scroll.ts +17 -0
- package/src/v2/components/license-warning-banner.tsx +20 -1
- package/src/v2/components/ui/button.tsx +12 -11
- package/src/v2/hooks/__tests__/use-agent-stability.test.tsx +6 -0
- package/src/v2/hooks/__tests__/use-agent-thread-isolation.test.tsx +6 -0
- package/src/v2/hooks/__tests__/use-agent-throttle.test.tsx +76 -50
- package/src/v2/hooks/__tests__/use-pin-to-send.test.tsx +219 -0
- package/src/v2/hooks/__tests__/use-render-custom-messages.test.tsx +55 -0
- package/src/v2/hooks/__tests__/use-threads.test.tsx +68 -0
- package/src/v2/hooks/use-agent.tsx +34 -77
- package/src/v2/hooks/use-pin-to-send.ts +94 -0
- package/src/v2/hooks/use-render-custom-messages.tsx +1 -1
- package/src/v2/hooks/use-render-tool-call.tsx +3 -0
- package/src/v2/hooks/use-render-tool.tsx +3 -0
- package/src/v2/hooks/use-threads.tsx +55 -12
- package/src/v2/providers/CopilotKitProvider.tsx +2 -11
- package/src/v2/types/defineToolCallRenderer.ts +3 -0
- package/src/v2/types/react-tool-call-renderer.ts +3 -0
- package/dist/copilotkit-BebqQrYT.mjs.map +0 -1
- package/dist/copilotkit-Cvb6WpAX.cjs.map +0 -1
- package/dist/copilotkit-Dv8zU8_U.d.cts.map +0 -1
- package/dist/copilotkit-f2Uq0RwG.d.mts.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { An as
|
|
1
|
+
import { An as CatchAllFrontendAction, Cn as Tree, Dn as ActionRenderPropsNoArgsWait, En as ActionRenderPropsNoArgs, Mn as FrontendActionAvailability, N as useAgent, Nn as RenderFunctionStatus, On as ActionRenderPropsWait, Q as useRenderToolCall$1, Sn as DocumentPointer, Tn as ActionRenderProps, _n as CrewsStateItem, an as useCopilotContext, bn as CopilotChatSuggestionConfiguration, cn as LangGraphInterruptActionSetter, dn as LangGraphInterruptRenderHandlerProps, fn as LangGraphInterruptRenderProps, gn as CrewsResponseStatus, hn as CrewsResponse, in as CopilotContextParams, jn as FrontendAction, kn as CatchAllActionRenderProps, ln as LangGraphInterruptActionSetterArgs, mn as CrewsAgentState, n as defaultCopilotContextCategories, nn as CopilotApiConfig, on as CoAgentStateRender, pn as QueuedInterruptEvent, r as CopilotKitProps, rn as CopilotContext, sn as LangGraphInterruptAction, t as CopilotKit, tn as CoagentInChatRenderFunction, un as LangGraphInterruptRender, vn as CrewsTaskStateItem, wn as TreeNode, xn as SystemMessageFunction, yn as CrewsToolStateItem } from "./copilotkit-KEc28l8G.cjs";
|
|
2
2
|
import "./v2/index.cjs";
|
|
3
3
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
4
|
import { CopilotRuntimeClient, CopilotRuntimeClientOptions, ForwardedParametersInput, Message } from "@copilotkit/runtime-client-gql";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { An as
|
|
1
|
+
import { An as CatchAllFrontendAction, Cn as Tree, Dn as ActionRenderPropsNoArgsWait, En as ActionRenderPropsNoArgs, Mn as FrontendActionAvailability, N as useAgent, Nn as RenderFunctionStatus, On as ActionRenderPropsWait, Q as useRenderToolCall$1, Sn as DocumentPointer, Tn as ActionRenderProps, _n as CrewsStateItem, an as useCopilotContext, bn as CopilotChatSuggestionConfiguration, cn as LangGraphInterruptActionSetter, dn as LangGraphInterruptRenderHandlerProps, fn as LangGraphInterruptRenderProps, gn as CrewsResponseStatus, hn as CrewsResponse, in as CopilotContextParams, jn as FrontendAction, kn as CatchAllActionRenderProps, ln as LangGraphInterruptActionSetterArgs, mn as CrewsAgentState, n as defaultCopilotContextCategories, nn as CopilotApiConfig, on as CoAgentStateRender, pn as QueuedInterruptEvent, r as CopilotKitProps, rn as CopilotContext, sn as LangGraphInterruptAction, t as CopilotKit, tn as CoagentInChatRenderFunction, un as LangGraphInterruptRender, vn as CrewsTaskStateItem, wn as TreeNode, xn as SystemMessageFunction, yn as CrewsToolStateItem } from "./copilotkit-DArT2Iuw.mjs";
|
|
2
2
|
import "./v2/index.mjs";
|
|
3
3
|
import React, { ReactNode, RefObject, SetStateAction } from "react";
|
|
4
4
|
import { StaticSuggestionsConfig, Suggestion } from "@copilotkit/core";
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { B as useConfigureSuggestions, Q as useRenderToolCall$1, U as useHumanInTheLoop$1, V as useSuggestions, Y as useRenderCustomMessages, Z as useAgent, a as ThreadsProvider, c as CoAgentStateRendersProvider, d as shouldShowDevConsole, et as useCopilotKit, f as useToast, g as useCopilotContext, h as CopilotContext, ht as useCopilotChatConfiguration, i as ThreadsContext, l as useCoAgentStateRenders, m as useCopilotMessagesContext, n as defaultCopilotContextCategories, o as useThreads, p as CopilotMessagesContext, q as useFrontendTool$1, r as CoAgentStateRenderBridge, rt as defineToolCallRenderer, s as CoAgentStateRendersContext, t as CopilotKit, u as useAsyncCallback, z as useInterrupt } from "./copilotkit-
|
|
3
|
+
import { B as useConfigureSuggestions, Q as useRenderToolCall$1, U as useHumanInTheLoop$1, V as useSuggestions, Y as useRenderCustomMessages, Z as useAgent, a as ThreadsProvider, c as CoAgentStateRendersProvider, d as shouldShowDevConsole, et as useCopilotKit, f as useToast, g as useCopilotContext, h as CopilotContext, ht as useCopilotChatConfiguration, i as ThreadsContext, l as useCoAgentStateRenders, m as useCopilotMessagesContext, n as defaultCopilotContextCategories, o as useThreads, p as CopilotMessagesContext, q as useFrontendTool$1, r as CoAgentStateRenderBridge, rt as defineToolCallRenderer, s as CoAgentStateRendersContext, t as CopilotKit, u as useAsyncCallback, z as useInterrupt } from "./copilotkit-BBYbekCa.mjs";
|
|
4
4
|
import React, { Fragment, createElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { CopilotKitCoreRuntimeConnectionStatus, ToolCallStatus } from "@copilotkit/core";
|
|
6
6
|
import { AGUIConnectNotImplementedError, HttpAgent } from "@ag-ui/client";
|
package/dist/index.umd.js
CHANGED
|
@@ -230,6 +230,8 @@ react_markdown = __toESM(react_markdown);
|
|
|
230
230
|
|
|
231
231
|
//#endregion
|
|
232
232
|
//#region src/v2/components/license-warning-banner.tsx
|
|
233
|
+
const LICENSE_BANNER_OFFSET_PX = 52;
|
|
234
|
+
const LICENSE_BANNER_OFFSET_VAR = "--copilotkit-license-banner-offset";
|
|
233
235
|
const BANNER_STYLES = {
|
|
234
236
|
base: {
|
|
235
237
|
position: "fixed",
|
|
@@ -271,6 +273,14 @@ react_markdown = __toESM(react_markdown);
|
|
|
271
273
|
}
|
|
272
274
|
}
|
|
273
275
|
function BannerShell({ severity, message, actionLabel, actionUrl, onDismiss }) {
|
|
276
|
+
(0, react.useEffect)(() => {
|
|
277
|
+
if (typeof document === "undefined") return;
|
|
278
|
+
const root = document.documentElement;
|
|
279
|
+
root.style.setProperty(LICENSE_BANNER_OFFSET_VAR, `${LICENSE_BANNER_OFFSET_PX}px`);
|
|
280
|
+
return () => {
|
|
281
|
+
root.style.removeProperty(LICENSE_BANNER_OFFSET_VAR);
|
|
282
|
+
};
|
|
283
|
+
}, []);
|
|
274
284
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
275
285
|
style: {
|
|
276
286
|
...BANNER_STYLES.base,
|
|
@@ -2225,7 +2235,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2225
2235
|
didMountRef.current = true;
|
|
2226
2236
|
}, []);
|
|
2227
2237
|
(0, react.useEffect)(() => {
|
|
2228
|
-
if (defaultThrottleMs !== void 0 && (!Number.isFinite(defaultThrottleMs) || defaultThrottleMs < 0)) console.error(`CopilotKitProvider: defaultThrottleMs must be a non-negative finite number, got ${defaultThrottleMs}. useAgent hooks without an explicit throttleMs will fall back to unthrottled.`);
|
|
2229
2238
|
copilotkit.setDefaultThrottleMs(defaultThrottleMs);
|
|
2230
2239
|
}, [copilotkit, defaultThrottleMs]);
|
|
2231
2240
|
const designSkill = (_openGenerativeUI$des = openGenerativeUI === null || openGenerativeUI === void 0 ? void 0 : openGenerativeUI.designSkill) !== null && _openGenerativeUI$des !== void 0 ? _openGenerativeUI$des : DEFAULT_DESIGN_SKILL;
|
|
@@ -2323,18 +2332,21 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2323
2332
|
const toolName = toolCall.function.name;
|
|
2324
2333
|
if (toolMessage) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderComponent, {
|
|
2325
2334
|
name: toolName,
|
|
2335
|
+
toolCallId: toolCall.id,
|
|
2326
2336
|
args,
|
|
2327
2337
|
status: _copilotkit_core.ToolCallStatus.Complete,
|
|
2328
2338
|
result: toolMessage.content
|
|
2329
2339
|
});
|
|
2330
2340
|
else if (isExecuting) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderComponent, {
|
|
2331
2341
|
name: toolName,
|
|
2342
|
+
toolCallId: toolCall.id,
|
|
2332
2343
|
args,
|
|
2333
2344
|
status: _copilotkit_core.ToolCallStatus.Executing,
|
|
2334
2345
|
result: void 0
|
|
2335
2346
|
});
|
|
2336
2347
|
else return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderComponent, {
|
|
2337
2348
|
name: toolName,
|
|
2349
|
+
toolCallId: toolCall.id,
|
|
2338
2350
|
args,
|
|
2339
2351
|
status: _copilotkit_core.ToolCallStatus.InProgress,
|
|
2340
2352
|
result: void 0
|
|
@@ -2444,16 +2456,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2444
2456
|
const providerThrottleMs = copilotkit.defaultThrottleMs;
|
|
2445
2457
|
const chatConfig = useCopilotChatConfiguration();
|
|
2446
2458
|
(_threadId = threadId) !== null && _threadId !== void 0 || (threadId = chatConfig === null || chatConfig === void 0 ? void 0 : chatConfig.threadId);
|
|
2447
|
-
const effectiveThrottleMs = (0, react.useMemo)(() => {
|
|
2448
|
-
var _ref;
|
|
2449
|
-
const resolved = (_ref = throttleMs !== null && throttleMs !== void 0 ? throttleMs : providerThrottleMs) !== null && _ref !== void 0 ? _ref : 0;
|
|
2450
|
-
if (!Number.isFinite(resolved) || resolved < 0) {
|
|
2451
|
-
const source = throttleMs !== void 0 ? "hook-level throttleMs" : "provider-level defaultThrottleMs";
|
|
2452
|
-
console.error(`useAgent: ${source} must be a non-negative finite number, got ${resolved}. Falling back to unthrottled.`);
|
|
2453
|
-
return 0;
|
|
2454
|
-
}
|
|
2455
|
-
return resolved;
|
|
2456
|
-
}, [throttleMs, providerThrottleMs]);
|
|
2457
2459
|
const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
|
|
2458
2460
|
const updateFlags = (0, react.useMemo)(() => updates !== null && updates !== void 0 ? updates : ALL_UPDATES, [JSON.stringify(updates)]);
|
|
2459
2461
|
const provisionalAgentCache = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
@@ -2517,9 +2519,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2517
2519
|
]);
|
|
2518
2520
|
(0, react.useEffect)(() => {
|
|
2519
2521
|
if (updateFlags.length === 0) return;
|
|
2520
|
-
const handlers = {};
|
|
2521
|
-
let timerId = null;
|
|
2522
2522
|
let active = true;
|
|
2523
|
+
const handlers = {};
|
|
2523
2524
|
let batchScheduled = false;
|
|
2524
2525
|
const batchedForceUpdate = () => {
|
|
2525
2526
|
if (!active) return;
|
|
@@ -2531,46 +2532,24 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2531
2532
|
});
|
|
2532
2533
|
}
|
|
2533
2534
|
};
|
|
2534
|
-
if (updateFlags.includes(UseAgentUpdate.OnMessagesChanged))
|
|
2535
|
-
const ms = effectiveThrottleMs;
|
|
2536
|
-
if (ms > 0) {
|
|
2537
|
-
let throttleActive = false;
|
|
2538
|
-
let pending = false;
|
|
2539
|
-
const throttledNotify = () => {
|
|
2540
|
-
if (!active) return;
|
|
2541
|
-
if (!throttleActive) {
|
|
2542
|
-
throttleActive = true;
|
|
2543
|
-
pending = false;
|
|
2544
|
-
forceUpdate();
|
|
2545
|
-
timerId = setTimeout(function trailingEdge() {
|
|
2546
|
-
timerId = null;
|
|
2547
|
-
if (active && pending) {
|
|
2548
|
-
pending = false;
|
|
2549
|
-
forceUpdate();
|
|
2550
|
-
timerId = setTimeout(trailingEdge, ms);
|
|
2551
|
-
} else throttleActive = false;
|
|
2552
|
-
}, ms);
|
|
2553
|
-
} else pending = true;
|
|
2554
|
-
};
|
|
2555
|
-
handlers.onMessagesChanged = throttledNotify;
|
|
2556
|
-
} else handlers.onMessagesChanged = forceUpdate;
|
|
2557
|
-
}
|
|
2535
|
+
if (updateFlags.includes(UseAgentUpdate.OnMessagesChanged)) handlers.onMessagesChanged = forceUpdate;
|
|
2558
2536
|
if (updateFlags.includes(UseAgentUpdate.OnStateChanged)) handlers.onStateChanged = batchedForceUpdate;
|
|
2559
2537
|
if (updateFlags.includes(UseAgentUpdate.OnRunStatusChanged)) {
|
|
2560
2538
|
handlers.onRunInitialized = batchedForceUpdate;
|
|
2561
2539
|
handlers.onRunFinalized = batchedForceUpdate;
|
|
2562
2540
|
handlers.onRunFailed = batchedForceUpdate;
|
|
2541
|
+
handlers.onRunErrorEvent = batchedForceUpdate;
|
|
2563
2542
|
}
|
|
2564
|
-
const subscription =
|
|
2543
|
+
const subscription = copilotkit.subscribeToAgentWithOptions(agent, handlers, { throttleMs });
|
|
2565
2544
|
return () => {
|
|
2566
2545
|
active = false;
|
|
2567
|
-
if (timerId !== null) clearTimeout(timerId);
|
|
2568
2546
|
subscription.unsubscribe();
|
|
2569
2547
|
};
|
|
2570
2548
|
}, [
|
|
2571
2549
|
agent,
|
|
2572
2550
|
forceUpdate,
|
|
2573
|
-
|
|
2551
|
+
throttleMs,
|
|
2552
|
+
providerThrottleMs,
|
|
2574
2553
|
updateFlags
|
|
2575
2554
|
]);
|
|
2576
2555
|
(0, react.useEffect)(() => {
|
|
@@ -2599,7 +2578,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2599
2578
|
const runId = resolvedRunId !== null && resolvedRunId !== void 0 ? resolvedRunId : `missing-run-id:${message.id}`;
|
|
2600
2579
|
const registryAgent = copilotkit.getAgent(agentId);
|
|
2601
2580
|
const agent = (_getThreadClone = getThreadClone(registryAgent, threadId)) !== null && _getThreadClone !== void 0 ? _getThreadClone : registryAgent;
|
|
2602
|
-
if (!agent)
|
|
2581
|
+
if (!agent) return null;
|
|
2603
2582
|
const messagesIdsInRun = resolvedRunId ? agent.messages.filter((msg) => copilotkit.getRunIdForMessage(agentId, threadId, msg.id) === resolvedRunId).map((msg) => msg.id) : [message.id];
|
|
2604
2583
|
const rawMessageIndex = agent.messages.findIndex((msg) => msg.id === message.id);
|
|
2605
2584
|
const messageIndex = rawMessageIndex >= 0 ? rawMessageIndex : 0;
|
|
@@ -4703,13 +4682,18 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4703
4682
|
};
|
|
4704
4683
|
}, [agent, getSubscriber]);
|
|
4705
4684
|
};
|
|
4685
|
+
function CopilotListenersAgentSubscription() {
|
|
4686
|
+
const existingConfig = useCopilotChatConfiguration();
|
|
4687
|
+
const { agent } = useAgent({ agentId: existingConfig === null || existingConfig === void 0 ? void 0 : existingConfig.agentId });
|
|
4688
|
+
usePredictStateSubscription(agent);
|
|
4689
|
+
return null;
|
|
4690
|
+
}
|
|
4706
4691
|
function CopilotListeners() {
|
|
4692
|
+
var _copilotkit$agents;
|
|
4707
4693
|
const { copilotkit } = useCopilotKit();
|
|
4708
|
-
const existingConfig = useCopilotChatConfiguration();
|
|
4709
|
-
const resolvedAgentId = existingConfig === null || existingConfig === void 0 ? void 0 : existingConfig.agentId;
|
|
4710
4694
|
const { setBannerError } = useToast();
|
|
4711
|
-
const
|
|
4712
|
-
|
|
4695
|
+
const hasAgents = Object.keys((_copilotkit$agents = copilotkit.agents) !== null && _copilotkit$agents !== void 0 ? _copilotkit$agents : {}).length > 0;
|
|
4696
|
+
const hasRuntime = copilotkit.runtimeUrl !== void 0;
|
|
4713
4697
|
(0, react.useEffect)(() => {
|
|
4714
4698
|
const subscription = copilotkit.subscribe({ onError: ({ error, code, context }) => {
|
|
4715
4699
|
if (error.name === "AbortError" || error.message === "Fetch is aborted" || error.message === "signal is aborted without reason" || error.message === "component unmounted" || !error.message) return;
|
|
@@ -4731,7 +4715,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4731
4715
|
subscription.unsubscribe();
|
|
4732
4716
|
};
|
|
4733
4717
|
}, [copilotkit === null || copilotkit === void 0 ? void 0 : copilotkit.subscribe]);
|
|
4734
|
-
return null;
|
|
4718
|
+
return hasAgents || hasRuntime ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotListenersAgentSubscription, {}) : null;
|
|
4735
4719
|
}
|
|
4736
4720
|
|
|
4737
4721
|
//#endregion
|