@copilotkit/react-core 1.55.2-next.1 → 1.55.3-canary.1776215089
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/CHANGELOG.md +12 -0
- package/dist/{copilotkit-Dgdpbqjt.cjs → copilotkit-BZuXjQLc.cjs} +43 -7
- package/dist/copilotkit-BZuXjQLc.cjs.map +1 -0
- package/dist/{copilotkit-Cd-NrDyp.mjs → copilotkit-BzVUuD95.mjs} +38 -8
- package/dist/copilotkit-BzVUuD95.mjs.map +1 -0
- package/dist/{copilotkit-dwDWYpya.d.cts → copilotkit-EfopO2gn.d.cts} +27 -9
- package/dist/copilotkit-EfopO2gn.d.cts.map +1 -0
- package/dist/{copilotkit-BuhSUZHb.d.mts → copilotkit-opur-20s.d.mts} +27 -9
- package/dist/copilotkit-opur-20s.d.mts.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 +18 -6
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/index.cjs +2 -1
- package/dist/v2/index.d.cts +2 -2
- package/dist/v2/index.d.mts +2 -2
- package/dist/v2/index.mjs +2 -2
- package/dist/v2/index.umd.js +37 -6
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +6 -6
- package/src/components/copilot-provider/copilotkit-props.tsx +9 -5
- package/src/components/copilot-provider/copilotkit.tsx +4 -1
- package/src/v2/hooks/__tests__/use-agent-throttle.test.tsx +10 -10
- package/src/v2/hooks/__tests__/use-capabilities.test.tsx +76 -0
- package/src/v2/hooks/index.ts +1 -0
- package/src/v2/hooks/use-agent.tsx +23 -4
- package/src/v2/hooks/use-capabilities.tsx +25 -0
- package/src/v2/providers/CopilotKitProvider.tsx +6 -2
- package/dist/copilotkit-BuhSUZHb.d.mts.map +0 -1
- package/dist/copilotkit-Cd-NrDyp.mjs.map +0 -1
- package/dist/copilotkit-Dgdpbqjt.cjs.map +0 -1
- package/dist/copilotkit-dwDWYpya.d.cts.map +0 -1
|
@@ -3042,7 +3042,7 @@ function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
|
|
|
3042
3042
|
}, [value, warningMessage]);
|
|
3043
3043
|
return value;
|
|
3044
3044
|
}
|
|
3045
|
-
const CopilotKitProvider = ({ children, runtimeUrl, headers = {}, credentials, publicApiKey, publicLicenseKey, licenseToken, properties = {}, agents__unsafe_dev_only: agents = {}, selfManagedAgents = {}, renderToolCalls, renderActivityMessages, renderCustomMessages, frontendTools, humanInTheLoop, openGenerativeUI, showDevConsole = false, useSingleEndpoint, onError, a2ui, defaultThrottleMs, inspectorDefaultAnchor }) => {
|
|
3045
|
+
const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = {}, credentials, publicApiKey, publicLicenseKey, licenseToken, properties = {}, agents__unsafe_dev_only: agents = {}, selfManagedAgents = {}, renderToolCalls, renderActivityMessages, renderCustomMessages, frontendTools, humanInTheLoop, openGenerativeUI, showDevConsole = false, useSingleEndpoint, onError, a2ui, defaultThrottleMs, inspectorDefaultAnchor }) => {
|
|
3046
3046
|
const [shouldRenderInspector, setShouldRenderInspector] = useState(false);
|
|
3047
3047
|
const [runtimeA2UIEnabled, setRuntimeA2UIEnabled] = useState(false);
|
|
3048
3048
|
const [runtimeOpenGenUIEnabled, setRuntimeOpenGenUIEnabled] = useState(false);
|
|
@@ -3097,6 +3097,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers = {}, credentials, p
|
|
|
3097
3097
|
...selfManagedAgents
|
|
3098
3098
|
}), [agents, selfManagedAgents]);
|
|
3099
3099
|
const hasLocalAgents = mergedAgents && Object.keys(mergedAgents).length > 0;
|
|
3100
|
+
const headers = typeof headersProp === "function" ? headersProp() : headersProp;
|
|
3100
3101
|
const mergedHeaders = useMemo(() => {
|
|
3101
3102
|
if (!resolvedPublicKey) return headers;
|
|
3102
3103
|
if (headers[HEADER_NAME]) return headers;
|
|
@@ -3589,6 +3590,17 @@ function useAgent({ agentId, threadId, updates, throttleMs } = {}) {
|
|
|
3589
3590
|
const handlers = {};
|
|
3590
3591
|
let timerId = null;
|
|
3591
3592
|
let active = true;
|
|
3593
|
+
let batchScheduled = false;
|
|
3594
|
+
const batchedForceUpdate = () => {
|
|
3595
|
+
if (!active) return;
|
|
3596
|
+
if (!batchScheduled) {
|
|
3597
|
+
batchScheduled = true;
|
|
3598
|
+
queueMicrotask(() => {
|
|
3599
|
+
batchScheduled = false;
|
|
3600
|
+
if (active) forceUpdate();
|
|
3601
|
+
});
|
|
3602
|
+
}
|
|
3603
|
+
};
|
|
3592
3604
|
if (updateFlags.includes(UseAgentUpdate.OnMessagesChanged)) {
|
|
3593
3605
|
const ms = effectiveThrottleMs;
|
|
3594
3606
|
if (ms > 0) {
|
|
@@ -3613,11 +3625,11 @@ function useAgent({ agentId, threadId, updates, throttleMs } = {}) {
|
|
|
3613
3625
|
handlers.onMessagesChanged = throttledNotify;
|
|
3614
3626
|
} else handlers.onMessagesChanged = forceUpdate;
|
|
3615
3627
|
}
|
|
3616
|
-
if (updateFlags.includes(UseAgentUpdate.OnStateChanged)) handlers.onStateChanged =
|
|
3628
|
+
if (updateFlags.includes(UseAgentUpdate.OnStateChanged)) handlers.onStateChanged = batchedForceUpdate;
|
|
3617
3629
|
if (updateFlags.includes(UseAgentUpdate.OnRunStatusChanged)) {
|
|
3618
|
-
handlers.onRunInitialized =
|
|
3619
|
-
handlers.onRunFinalized =
|
|
3620
|
-
handlers.onRunFailed =
|
|
3630
|
+
handlers.onRunInitialized = batchedForceUpdate;
|
|
3631
|
+
handlers.onRunFinalized = batchedForceUpdate;
|
|
3632
|
+
handlers.onRunFailed = batchedForceUpdate;
|
|
3621
3633
|
}
|
|
3622
3634
|
const subscription = agent.subscribe(handlers);
|
|
3623
3635
|
return () => {
|
|
@@ -4154,6 +4166,24 @@ function useHumanInTheLoop(tool, deps) {
|
|
|
4154
4166
|
]);
|
|
4155
4167
|
}
|
|
4156
4168
|
|
|
4169
|
+
//#endregion
|
|
4170
|
+
//#region src/v2/hooks/use-capabilities.tsx
|
|
4171
|
+
/**
|
|
4172
|
+
* Returns the capabilities declared by the given agent (or the default agent).
|
|
4173
|
+
* Capabilities are populated from the runtime `/info` response at connection
|
|
4174
|
+
* time. The hook reads them synchronously from the agent instance — there is
|
|
4175
|
+
* no separate loading state, but the value will be `undefined` until the
|
|
4176
|
+
* runtime handshake completes.
|
|
4177
|
+
*
|
|
4178
|
+
* @param agentId - Optional agent ID. If omitted, uses the default agent.
|
|
4179
|
+
* @returns The agent's capabilities, or `undefined` if the agent doesn't
|
|
4180
|
+
* declare capabilities.
|
|
4181
|
+
*/
|
|
4182
|
+
function useCapabilities(agentId) {
|
|
4183
|
+
const { agent } = useAgent({ agentId });
|
|
4184
|
+
if (agent && "capabilities" in agent) return agent.capabilities;
|
|
4185
|
+
}
|
|
4186
|
+
|
|
4157
4187
|
//#endregion
|
|
4158
4188
|
//#region src/v2/hooks/use-suggestions.tsx
|
|
4159
4189
|
function useSuggestions({ agentId } = {}) {
|
|
@@ -9156,7 +9186,7 @@ function CopilotKitInternal(cpkProps) {
|
|
|
9156
9186
|
publicApiKey,
|
|
9157
9187
|
...cloud ? { cloud } : {},
|
|
9158
9188
|
chatApiEndpoint,
|
|
9159
|
-
headers: props.headers || {},
|
|
9189
|
+
headers: typeof props.headers === "function" ? props.headers() : props.headers || {},
|
|
9160
9190
|
properties: props.properties || {},
|
|
9161
9191
|
transcribeAudioUrl: props.transcribeAudioUrl,
|
|
9162
9192
|
textToSpeechUrl: props.textToSpeechUrl,
|
|
@@ -9502,5 +9532,5 @@ function validateProps(props) {
|
|
|
9502
9532
|
}
|
|
9503
9533
|
|
|
9504
9534
|
//#endregion
|
|
9505
|
-
export {
|
|
9506
|
-
//# sourceMappingURL=copilotkit-
|
|
9535
|
+
export { CopilotKitProvider as $, CopilotChatSuggestionView as A, useConfigureSuggestions as B, CopilotChatToggleButton as C, CopilotChatView_default as D, CopilotChat as E, CopilotChatAssistantMessage_default as F, useRenderTool as G, useCapabilities as H, CopilotChatToolCallsView as I, useRenderActivityMessage as J, useComponent as K, useAttachments as L, CopilotChatReasoningMessage_default as M, CopilotChatUserMessage_default as N, CopilotChatAttachmentQueue as O, CopilotChatAttachmentRenderer as P, useRenderToolCall as Q, useThreads$1 as R, CopilotModalHeader as S, DefaultOpenIcon as T, useHumanInTheLoop as U, useSuggestions as V, useDefaultRenderTool as W, UseAgentUpdate as X, useRenderCustomMessages as Y, useAgent as Z, WildcardToolCallRender as _, ThreadsProvider as a, SandboxFunctionsContext as at, CopilotPopupView as b, CoAgentStateRendersProvider as c, MCPAppsActivityRenderer as ct, shouldShowDevConsole as d, CopilotChatInput_default as dt, useCopilotKit as et, useToast as f, AudioRecorderError as ft, useCopilotContext as g, CopilotContext as h, useCopilotChatConfiguration as ht, ThreadsContext as i, createA2UIMessageRenderer as it, CopilotChatSuggestionPill as j, CopilotChatMessageView as k, useCoAgentStateRenders as l, MCPAppsActivityType as lt, useCopilotMessagesContext as m, CopilotChatConfigurationProvider as mt, defaultCopilotContextCategories as n, useAgentContext as nt, useThreads as o, useSandboxFunctions as ot, CopilotMessagesContext as p, CopilotChatAudioRecorder as pt, useFrontendTool as q, CoAgentStateRenderBridge as r, defineToolCallRenderer as rt, CoAgentStateRendersContext as s, MCPAppsActivityContentSchema as st, CopilotKit as t, CopilotKitCoreReact as tt, useAsyncCallback as u, CopilotKitInspector as ut, CopilotPopup as v, DefaultCloseIcon as w, CopilotSidebarView as x, CopilotSidebar as y, useInterrupt as z };
|
|
9536
|
+
//# sourceMappingURL=copilotkit-BzVUuD95.mjs.map
|