@copilotkit/react-core 1.62.2 → 1.62.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-lHheGQWt.cjs → copilotkit-5MptLWNR.cjs} +127 -24
- package/dist/copilotkit-5MptLWNR.cjs.map +1 -0
- package/dist/{copilotkit-Cga6AHO0.d.cts → copilotkit-BfFY1fzd.d.cts} +153 -6
- package/dist/copilotkit-BfFY1fzd.d.cts.map +1 -0
- package/dist/{copilotkit-DnLpJ2Cl.d.mts → copilotkit-Bp6BD8xe.d.mts} +153 -6
- package/dist/copilotkit-Bp6BD8xe.d.mts.map +1 -0
- package/dist/{copilotkit-CmcMFc8o.mjs → copilotkit-ympAovXs.mjs} +123 -26
- package/dist/copilotkit-ympAovXs.mjs.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 +24 -14
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +18 -14
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts +16 -2
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts +16 -2
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +19 -15
- package/dist/v2/headless.mjs.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 +121 -23
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +7 -7
- package/dist/copilotkit-Cga6AHO0.d.cts.map +0 -1
- package/dist/copilotkit-CmcMFc8o.mjs.map +0 -1
- package/dist/copilotkit-DnLpJ2Cl.d.mts.map +0 -1
- package/dist/copilotkit-lHheGQWt.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_copilotkit = require('./copilotkit-
|
|
4
|
+
const require_copilotkit = require('./copilotkit-5MptLWNR.cjs');
|
|
5
5
|
let react = require("react");
|
|
6
6
|
react = require_copilotkit.__toESM(react);
|
|
7
7
|
let _copilotkit_core = require("@copilotkit/core");
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $n as
|
|
1
|
+
import { $n as CrewsToolStateItem, Bn as CoAgentStateRender, Fn as CoagentInChatRenderFunction, Gn as LangGraphInterruptRenderHandlerProps, Hn as LangGraphInterruptActionSetter, In as CopilotApiConfig, Jn as CrewsAgentState, Kn as LangGraphInterruptRenderProps, Ln as CopilotContext, Qn as CrewsTaskStateItem, Rn as CopilotContextParams, Un as LangGraphInterruptActionSetterArgs, Vn as LangGraphInterruptAction, Wn as LangGraphInterruptRender, Xn as CrewsResponseStatus, Y as useAgent, Yn as CrewsResponse, Zn as CrewsStateItem, ar as ActionRenderProps, cr as ActionRenderPropsWait, dr as FrontendAction, er as CopilotChatSuggestionConfiguration, fr as FrontendActionAvailability, ir as TreeNode, lr as CatchAllActionRenderProps, n as defaultCopilotContextCategories, nr as DocumentPointer, or as ActionRenderPropsNoArgs, pr as RenderFunctionStatus, qn as QueuedInterruptEvent, r as CopilotKitProps, rr as Tree, sr as ActionRenderPropsNoArgsWait, t as CopilotKit, tr as SystemMessageFunction, ur as CatchAllFrontendAction, vt as useRenderToolCall$1, zn as useCopilotContext } from "./copilotkit-BfFY1fzd.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 { $n as
|
|
1
|
+
import { $n as CrewsToolStateItem, Bn as CoAgentStateRender, Fn as CoagentInChatRenderFunction, Gn as LangGraphInterruptRenderHandlerProps, Hn as LangGraphInterruptActionSetter, In as CopilotApiConfig, Jn as CrewsAgentState, Kn as LangGraphInterruptRenderProps, Ln as CopilotContext, Qn as CrewsTaskStateItem, Rn as CopilotContextParams, Un as LangGraphInterruptActionSetterArgs, Vn as LangGraphInterruptAction, Wn as LangGraphInterruptRender, Xn as CrewsResponseStatus, Y as useAgent, Yn as CrewsResponse, Zn as CrewsStateItem, ar as ActionRenderProps, cr as ActionRenderPropsWait, dr as FrontendAction, er as CopilotChatSuggestionConfiguration, fr as FrontendActionAvailability, ir as TreeNode, lr as CatchAllActionRenderProps, n as defaultCopilotContextCategories, nr as DocumentPointer, or as ActionRenderPropsNoArgs, pr as RenderFunctionStatus, qn as QueuedInterruptEvent, r as CopilotKitProps, rr as Tree, sr as ActionRenderPropsNoArgsWait, t as CopilotKit, tr as SystemMessageFunction, ur as CatchAllFrontendAction, vt as useRenderToolCall$1, zn as useCopilotContext } from "./copilotkit-Bp6BD8xe.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 {
|
|
3
|
+
import { Tt as useCopilotChatConfiguration, X as useConfigureSuggestions, Y as useInterrupt, Z as useSuggestions, a as ThreadsProvider, c as CoAgentStateRendersProvider, ct as useRenderCustomMessages, d as shouldShowDevConsole, f as useToast, g as useCopilotContext, h as CopilotContext, i as ThreadsContext, l as useCoAgentStateRenders, m as useCopilotMessagesContext, n as defaultCopilotContextCategories, nt as useHumanInTheLoop$1, o as useThreads, ot as useFrontendTool$1, p as CopilotMessagesContext, r as CoAgentStateRenderBridge, s as CoAgentStateRendersContext, t as CopilotKit, tt as useAgent, u as useAsyncCallback, ut as defineToolCallRenderer, vt as useRenderToolCall$1, yt as useCopilotKit } from "./copilotkit-ympAovXs.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
|
@@ -2849,57 +2849,58 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2849
2849
|
UseAgentUpdate.OnRunStatusChanged
|
|
2850
2850
|
];
|
|
2851
2851
|
function useAgent({ agentId, updates, throttleMs } = {}) {
|
|
2852
|
-
|
|
2852
|
+
const chatConfig = useCopilotChatConfiguration();
|
|
2853
|
+
const resolvedAgentId = agentId ?? chatConfig?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
2853
2854
|
const { copilotkit } = useCopilotKit();
|
|
2854
2855
|
const providerThrottleMs = copilotkit.defaultThrottleMs;
|
|
2855
2856
|
const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
|
|
2856
2857
|
const updateFlags = (0, react.useMemo)(() => updates ?? ALL_UPDATES, [JSON.stringify(updates)]);
|
|
2857
2858
|
const provisionalAgentCache = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
2858
2859
|
const agent = (0, react.useMemo)(() => {
|
|
2859
|
-
const existing = copilotkit.getAgent(
|
|
2860
|
+
const existing = copilotkit.getAgent(resolvedAgentId);
|
|
2860
2861
|
if (existing) {
|
|
2861
|
-
provisionalAgentCache.current.delete(
|
|
2862
|
+
provisionalAgentCache.current.delete(resolvedAgentId);
|
|
2862
2863
|
return existing;
|
|
2863
2864
|
}
|
|
2864
2865
|
const isRuntimeConfigured = copilotkit.runtimeUrl !== void 0;
|
|
2865
2866
|
const status = copilotkit.runtimeConnectionStatus;
|
|
2866
2867
|
if (isRuntimeConfigured && (status === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Disconnected || status === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Connecting)) {
|
|
2867
|
-
const cached = provisionalAgentCache.current.get(
|
|
2868
|
+
const cached = provisionalAgentCache.current.get(resolvedAgentId);
|
|
2868
2869
|
if (cached) {
|
|
2869
2870
|
copilotkit.applyHeadersToAgent(cached);
|
|
2870
2871
|
return cached;
|
|
2871
2872
|
}
|
|
2872
2873
|
const provisional = new _copilotkit_core.ProxiedCopilotRuntimeAgent({
|
|
2873
2874
|
runtimeUrl: copilotkit.runtimeUrl,
|
|
2874
|
-
agentId,
|
|
2875
|
+
agentId: resolvedAgentId,
|
|
2875
2876
|
transport: copilotkit.runtimeTransport,
|
|
2876
2877
|
runtimeMode: "pending"
|
|
2877
2878
|
});
|
|
2878
2879
|
copilotkit.applyHeadersToAgent(provisional);
|
|
2879
|
-
provisionalAgentCache.current.set(
|
|
2880
|
+
provisionalAgentCache.current.set(resolvedAgentId, provisional);
|
|
2880
2881
|
return provisional;
|
|
2881
2882
|
}
|
|
2882
2883
|
if (isRuntimeConfigured && status === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Error) {
|
|
2883
|
-
const cached = provisionalAgentCache.current.get(
|
|
2884
|
+
const cached = provisionalAgentCache.current.get(resolvedAgentId);
|
|
2884
2885
|
if (cached) {
|
|
2885
2886
|
copilotkit.applyHeadersToAgent(cached);
|
|
2886
2887
|
return cached;
|
|
2887
2888
|
}
|
|
2888
2889
|
const provisional = new _copilotkit_core.ProxiedCopilotRuntimeAgent({
|
|
2889
2890
|
runtimeUrl: copilotkit.runtimeUrl,
|
|
2890
|
-
agentId,
|
|
2891
|
+
agentId: resolvedAgentId,
|
|
2891
2892
|
transport: copilotkit.runtimeTransport,
|
|
2892
2893
|
runtimeMode: "pending"
|
|
2893
2894
|
});
|
|
2894
2895
|
copilotkit.applyHeadersToAgent(provisional);
|
|
2895
|
-
provisionalAgentCache.current.set(
|
|
2896
|
+
provisionalAgentCache.current.set(resolvedAgentId, provisional);
|
|
2896
2897
|
return provisional;
|
|
2897
2898
|
}
|
|
2898
2899
|
const knownAgents = Object.keys(copilotkit.agents ?? {});
|
|
2899
2900
|
const runtimePart = isRuntimeConfigured ? `runtimeUrl=${copilotkit.runtimeUrl}` : "no runtimeUrl";
|
|
2900
|
-
throw new Error(`useAgent: Agent '${
|
|
2901
|
+
throw new Error(`useAgent: Agent '${resolvedAgentId}' not found after runtime sync (${runtimePart}). ` + (knownAgents.length ? `Known agents: [${knownAgents.join(", ")}]` : "No agents registered.") + " Verify your runtime /info and/or agents__unsafe_dev_only.");
|
|
2901
2902
|
}, [
|
|
2902
|
-
|
|
2903
|
+
resolvedAgentId,
|
|
2903
2904
|
copilotkit.agents,
|
|
2904
2905
|
copilotkit.runtimeConnectionStatus,
|
|
2905
2906
|
copilotkit.runtimeUrl,
|
|
@@ -2944,7 +2945,6 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
2944
2945
|
(0, react.useEffect)(() => {
|
|
2945
2946
|
if (agent instanceof _ag_ui_client.HttpAgent) copilotkit.applyHeadersToAgent(agent);
|
|
2946
2947
|
}, [agent, JSON.stringify(copilotkit.headers)]);
|
|
2947
|
-
const chatConfig = useCopilotChatConfiguration();
|
|
2948
2948
|
const configThreadId = chatConfig?.threadId;
|
|
2949
2949
|
const configHasExplicitThreadId = chatConfig?.hasExplicitThreadId;
|
|
2950
2950
|
(0, react.useEffect)(() => {
|
|
@@ -5031,8 +5031,18 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5031
5031
|
}, [agent, getSubscriber]);
|
|
5032
5032
|
};
|
|
5033
5033
|
function CopilotListenersAgentSubscription() {
|
|
5034
|
-
const
|
|
5035
|
-
const
|
|
5034
|
+
const { copilotkit } = useCopilotKit();
|
|
5035
|
+
const configAgentId = useCopilotChatConfiguration()?.agentId;
|
|
5036
|
+
const { agent } = useAgent({ agentId: (0, react.useMemo)(() => {
|
|
5037
|
+
const requested = configAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
5038
|
+
const registered = copilotkit.agents ?? {};
|
|
5039
|
+
if (registered[requested]) return requested;
|
|
5040
|
+
if (requested === _copilotkit_shared.DEFAULT_AGENT_ID) {
|
|
5041
|
+
const firstRegistered = Object.keys(registered)[0];
|
|
5042
|
+
if (firstRegistered) return firstRegistered;
|
|
5043
|
+
}
|
|
5044
|
+
return requested;
|
|
5045
|
+
}, [configAgentId, copilotkit.agents]) });
|
|
5036
5046
|
usePredictStateSubscription(agent);
|
|
5037
5047
|
return null;
|
|
5038
5048
|
}
|