@copilotkit/react-core 1.63.2 → 1.64.0
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-BE1n5tSI.d.mts.map +1 -1
- package/dist/copilotkit-CXvuYw_F.d.cts.map +1 -1
- package/dist/{copilotkit-CN2JVeH3.mjs → copilotkit-D_Ao1X-u.mjs} +117 -100
- package/dist/copilotkit-D_Ao1X-u.mjs.map +1 -0
- package/dist/{copilotkit-DDVfoiRM.cjs → copilotkit-DiLTL1ZM.cjs} +119 -102
- package/dist/copilotkit-DiLTL1ZM.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +22 -63
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +96 -60
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts +30 -2
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts +19 -3
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +100 -72
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +118 -101
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +7 -7
- package/skills/react-core/references/threads.md +1 -2
- package/dist/copilotkit-CN2JVeH3.mjs.map +0 -1
- package/dist/copilotkit-DDVfoiRM.cjs.map +0 -1
package/dist/v2/headless.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React$1, { ComponentType, ReactNode } from "react";
|
|
2
2
|
import { InferSchemaOutput, StandardSchemaV1 } from "@copilotkit/shared";
|
|
3
3
|
import { CopilotKitCore, CopilotKitCoreConfig, CopilotKitCoreSubscriber, CopilotKitCoreSubscription, DynamicSuggestionsConfig, FrontendTool, StaticSuggestionsConfig, Suggestion, ToolCallStatus } from "@copilotkit/core";
|
|
4
|
-
import { ActivityMessage, AgentCapabilities, Message } from "@ag-ui/core";
|
|
4
|
+
import { ActivityMessage, AgentCapabilities, Message, ToolCall, ToolMessage } from "@ag-ui/core";
|
|
5
5
|
import { AbstractAgent, Interrupt, ResumeEntry, ResumeStatus, RunAgentResult } from "@ag-ui/client";
|
|
6
6
|
|
|
7
7
|
//#region src/v2/types/react-tool-call-renderer.d.ts
|
|
@@ -269,6 +269,18 @@ declare class CopilotKitCoreReact extends CopilotKitCore {
|
|
|
269
269
|
waitForPendingFrameworkUpdates(): Promise<void>;
|
|
270
270
|
}
|
|
271
271
|
//#endregion
|
|
272
|
+
//#region src/v2/context.d.ts
|
|
273
|
+
interface CopilotKitContextValue {
|
|
274
|
+
copilotkit: CopilotKitCoreReact;
|
|
275
|
+
/**
|
|
276
|
+
* Set of tool call IDs currently being executed.
|
|
277
|
+
* This is tracked at the provider level to ensure tool execution events
|
|
278
|
+
* are captured even before child components mount.
|
|
279
|
+
*/
|
|
280
|
+
executingToolCallIds: ReadonlySet<string>;
|
|
281
|
+
}
|
|
282
|
+
declare const useCopilotKit: () => CopilotKitContextValue;
|
|
283
|
+
//#endregion
|
|
272
284
|
//#region src/v2/providers/CopilotChatConfigurationProvider.d.ts
|
|
273
285
|
declare const CopilotChatDefaultLabels: {
|
|
274
286
|
chatInputPlaceholder: string;
|
|
@@ -894,6 +906,22 @@ declare function useRenderTool<S extends StandardSchemaV1>(config: {
|
|
|
894
906
|
agentId?: string;
|
|
895
907
|
}, deps?: ReadonlyArray<unknown>): void;
|
|
896
908
|
//#endregion
|
|
909
|
+
//#region src/v2/hooks/use-render-tool-call.d.ts
|
|
910
|
+
interface UseRenderToolCallProps {
|
|
911
|
+
toolCall: ToolCall;
|
|
912
|
+
toolMessage?: ToolMessage;
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
915
|
+
* Hook that returns a function to render tool calls based on the render functions
|
|
916
|
+
* defined in CopilotKitProvider.
|
|
917
|
+
*
|
|
918
|
+
* @returns A function that takes a tool call and optional tool message and returns the rendered component
|
|
919
|
+
*/
|
|
920
|
+
declare function useRenderToolCall(): ({
|
|
921
|
+
toolCall,
|
|
922
|
+
toolMessage
|
|
923
|
+
}: UseRenderToolCallProps) => React$1.ReactElement | null;
|
|
924
|
+
//#endregion
|
|
897
925
|
//#region src/v2/hooks/use-capabilities.d.ts
|
|
898
926
|
/**
|
|
899
927
|
* Returns the capabilities declared by the given agent (or the agent resolved
|
|
@@ -910,5 +938,5 @@ declare function useRenderTool<S extends StandardSchemaV1>(config: {
|
|
|
910
938
|
*/
|
|
911
939
|
declare function useCapabilities(agentId?: string): AgentCapabilities | undefined;
|
|
912
940
|
//#endregion
|
|
913
|
-
export { type AgentContextInput, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatDefaultLabels, type CopilotChatLabels, CopilotKitCoreReact, type CopilotKitCoreReactConfig, type Interrupt, type InterruptEvent, type InterruptHandlerProps, type InterruptRenderProps, type JsonSerializable, type ReactFrontendTool, type ReactHumanInTheLoop, type RenderToolCompleteProps, type RenderToolExecutingProps, type RenderToolInProgressProps, type RenderToolProps, type ResumeEntry, type ResumeStatus, type Thread,
|
|
941
|
+
export { type AgentContextInput, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatDefaultLabels, type CopilotChatLabels, CopilotKitCoreReact, type CopilotKitCoreReactConfig, type Interrupt, type InterruptEvent, type InterruptHandlerProps, type InterruptRenderProps, type JsonSerializable, type ReactFrontendTool, type ReactHumanInTheLoop, type RenderToolCompleteProps, type RenderToolExecutingProps, type RenderToolInProgressProps, type RenderToolProps, type ResumeEntry, type ResumeStatus, type Thread, UseAgentUpdate, type UseInterruptConfig, type UseThreadsInput, type UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderTool, useRenderToolCall, useSuggestions, useThreads };
|
|
914
942
|
//# sourceMappingURL=headless.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headless.d.cts","names":[],"sources":["../../src/v2/types/react-tool-call-renderer.ts","../../src/v2/types/react-activity-message-renderer.ts","../../src/v2/types/react-custom-message-renderer.ts","../../src/v2/types/frontend-tool.ts","../../src/v2/types/human-in-the-loop.ts","../../src/v2/types/defineToolCallRenderer.ts","../../src/v2/types/interrupt.ts","../../src/v2/lib/react-core.ts","../../src/v2/providers/CopilotChatConfigurationProvider.tsx","../../src/v2/hooks/use-agent.tsx","../../src/v2/hooks/use-frontend-tool.tsx","../../src/v2/hooks/use-component.tsx","../../src/v2/hooks/use-human-in-the-loop.tsx","../../src/v2/hooks/use-interrupt.tsx","../../src/v2/hooks/use-suggestions.tsx","../../src/v2/hooks/use-configure-suggestions.tsx","../../src/v2/hooks/use-agent-context.tsx","../../src/v2/hooks/use-threads.tsx","../../src/v2/hooks/use-render-tool.tsx","../../src/v2/hooks/use-capabilities.tsx"],"mappings":";;;;;;;UAGiB,qBAAA;EACf,IAAA;;;;AADF;EAME,IAAA,GAAO,gBAAA,MAAsB,CAAA;EANO;;;;EAWpC,OAAA;EACA,MAAA,EAAQ,KAAA,CAAM,aAAA;IAER,IAAA;IACA,UAAA;IACA,IAAA,EAAM,OAAA,CAAQ,CAAA;IACd,MAAA,EAAQ,cAAA,CAAe,UAAA;IACvB,MAAA;EAAA;IAGA,IAAA;IACA,UAAA;IACA,IAAA,EAAM,CAAA;IACN,MAAA,EAAQ,cAAA,CAAe,SAAA;IACvB,MAAA;EAAA;IAGA,IAAA;IACA,UAAA;IACA,IAAA,EAAM,CAAA;IACN,MAAA,EAAQ,cAAA,CAAe,QAAA;IACvB,MAAA;EAAA;AAAA;;;UC/BS,4BAAA;;;;EAIf,YAAA;EDLoC;;;ECSpC,OAAA;EDOoB;;;ECHpB,OAAA,EAAS,gBAAA,MAAsB,gBAAA;EDWjB;;;ECPd,MAAA,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wBAAA,IAA4B,KAAA;IAC1B,UAAA,EAAY,cAAA;IACZ,eAAA,EAAiB,qBAAA;EAAA,aACN,OAAA;EACb,yBAAA,IAA6B,KAAA;IAC3B,UAAA,EAAY,cAAA;IACZ,gBAAA,EAAkB,OAAA,CAAM,YAAA;EAAA,aACb,OAAA;AAAA;AAAA,cAGF,mBAAA,SAA4B,cAAA;EAAA,QAC/B,gBAAA;EAAA,QACA,oBAAA;EAAA,QAEA,4BAAA;EAAA,QAEA,qBAAA;EAAA,QACA,uBAAA;EAAA,QACA,iBAAA;cAEI,MAAA,EAAQ,yBAAA;EAAA,IAOhB,oBAAA,CAAA,GAAwB,QAAA,CAAS,0BAAA;EAAA,IAIjC,sBAAA,CAAA,GAA0B,QAAA,CAAS,4BAAA;EAAA,IAInC,eAAA,CAAA,GAAmB,QAAA,CAAS,qBAAA;EAmBhC,yBAAA,CACE,SAAA,EAAW,4BAAA;EAKb,uBAAA,CAAwB,SAAA,EAAW,0BAAA;EAInC,kBAAA,CAAmB,eAAA,EAAiB,qBAAA;EAMpC,qBAAA,CAAsB,KAAA,EAAO,qBAAA;EAO7B,wBAAA,CAAyB,IAAA,UAAc,OAAA;EAAA,QAQ/B,6BAAA;EAAA,IAYJ,gBAAA,CAAA,GAAoB,OAAA,CAAM,YAAA;EAI9B,mBAAA,CAAoB,OAAA,EAAS,OAAA,CAAM,YAAA;EAYnC,SAAA,CACE,UAAA,EAAY,6BAAA,GACX,0BAAA;EPlHG;;;;;;;;;;;;;EOmIA,8BAAA,CAAA,GAAkC,OAAA;AAAA;;;
|
|
1
|
+
{"version":3,"file":"headless.d.cts","names":[],"sources":["../../src/v2/types/react-tool-call-renderer.ts","../../src/v2/types/react-activity-message-renderer.ts","../../src/v2/types/react-custom-message-renderer.ts","../../src/v2/types/frontend-tool.ts","../../src/v2/types/human-in-the-loop.ts","../../src/v2/types/defineToolCallRenderer.ts","../../src/v2/types/interrupt.ts","../../src/v2/lib/react-core.ts","../../src/v2/context.ts","../../src/v2/providers/CopilotChatConfigurationProvider.tsx","../../src/v2/hooks/use-agent.tsx","../../src/v2/hooks/use-frontend-tool.tsx","../../src/v2/hooks/use-component.tsx","../../src/v2/hooks/use-human-in-the-loop.tsx","../../src/v2/hooks/use-interrupt.tsx","../../src/v2/hooks/use-suggestions.tsx","../../src/v2/hooks/use-configure-suggestions.tsx","../../src/v2/hooks/use-agent-context.tsx","../../src/v2/hooks/use-threads.tsx","../../src/v2/hooks/use-render-tool.tsx","../../src/v2/hooks/use-render-tool-call.tsx","../../src/v2/hooks/use-capabilities.tsx"],"mappings":";;;;;;;UAGiB,qBAAA;EACf,IAAA;;;;AADF;EAME,IAAA,GAAO,gBAAA,MAAsB,CAAA;EANO;;;;EAWpC,OAAA;EACA,MAAA,EAAQ,KAAA,CAAM,aAAA;IAER,IAAA;IACA,UAAA;IACA,IAAA,EAAM,OAAA,CAAQ,CAAA;IACd,MAAA,EAAQ,cAAA,CAAe,UAAA;IACvB,MAAA;EAAA;IAGA,IAAA;IACA,UAAA;IACA,IAAA,EAAM,CAAA;IACN,MAAA,EAAQ,cAAA,CAAe,SAAA;IACvB,MAAA;EAAA;IAGA,IAAA;IACA,UAAA;IACA,IAAA,EAAM,CAAA;IACN,MAAA,EAAQ,cAAA,CAAe,QAAA;IACvB,MAAA;EAAA;AAAA;;;UC/BS,4BAAA;;;;EAIf,YAAA;EDLoC;;;ECSpC,OAAA;EDOoB;;;ECHpB,OAAA,EAAS,gBAAA,MAAsB,gBAAA;EDWjB;;;ECPd,MAAA,EAAQ,KAAA,CAAM,aAAA;IACZ,YAAA;IACA,OAAA,EAAS,gBAAA;IACT,OAAA,EAAS,eAAA;IACT,KAAA,EAAO,aAAA;EAAA;AAAA;;;KCtBC,kCAAA;AAAA,UAEK,0BAAA;EACf,OAAA;EACA,MAAA,EAAQ,KAAA,CAAM,aAAA;IACZ,OAAA,EAAS,OAAA;IACT,QAAA,EAAU,kCAAA;IACV,KAAA;IACA,YAAA;IACA,iBAAA;IACA,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mts
CHANGED
|
@@ -2,8 +2,8 @@ import React$1, { ComponentType, ReactNode } from "react";
|
|
|
2
2
|
import { InferSchemaOutput, StandardSchemaV1 } from "@copilotkit/shared";
|
|
3
3
|
import { AbstractAgent, Interrupt, ResumeEntry, ResumeStatus, RunAgentResult } from "@ag-ui/client";
|
|
4
4
|
import { DynamicSuggestionsConfig, FrontendTool, StaticSuggestionsConfig, Suggestion, ToolCallStatus } from "@copilotkit/core";
|
|
5
|
-
import { CopilotKitCoreReact, CopilotKitCoreReactConfig } from "@copilotkit/react-core/v2/context";
|
|
6
|
-
import { AgentCapabilities } from "@ag-ui/core";
|
|
5
|
+
import { CopilotKitCoreReact, CopilotKitCoreReactConfig, useCopilotKit } from "@copilotkit/react-core/v2/context";
|
|
6
|
+
import { AgentCapabilities, ToolCall, ToolMessage } from "@ag-ui/core";
|
|
7
7
|
|
|
8
8
|
//#region src/v2/providers/CopilotChatConfigurationProvider.d.ts
|
|
9
9
|
declare const CopilotChatDefaultLabels: {
|
|
@@ -763,6 +763,22 @@ declare function useRenderTool<S extends StandardSchemaV1>(config: {
|
|
|
763
763
|
agentId?: string;
|
|
764
764
|
}, deps?: ReadonlyArray<unknown>): void;
|
|
765
765
|
//#endregion
|
|
766
|
+
//#region src/v2/hooks/use-render-tool-call.d.ts
|
|
767
|
+
interface UseRenderToolCallProps {
|
|
768
|
+
toolCall: ToolCall;
|
|
769
|
+
toolMessage?: ToolMessage;
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* Hook that returns a function to render tool calls based on the render functions
|
|
773
|
+
* defined in CopilotKitProvider.
|
|
774
|
+
*
|
|
775
|
+
* @returns A function that takes a tool call and optional tool message and returns the rendered component
|
|
776
|
+
*/
|
|
777
|
+
declare function useRenderToolCall(): ({
|
|
778
|
+
toolCall,
|
|
779
|
+
toolMessage
|
|
780
|
+
}: UseRenderToolCallProps) => React$1.ReactElement | null;
|
|
781
|
+
//#endregion
|
|
766
782
|
//#region src/v2/types/defineToolCallRenderer.d.ts
|
|
767
783
|
/**
|
|
768
784
|
* Helper to define a type-safe tool call renderer entry.
|
|
@@ -818,5 +834,5 @@ declare function defineToolCallRenderer<S extends StandardSchemaV1>(def: {
|
|
|
818
834
|
*/
|
|
819
835
|
declare function useCapabilities(agentId?: string): AgentCapabilities | undefined;
|
|
820
836
|
//#endregion
|
|
821
|
-
export { type AgentContextInput, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatDefaultLabels, type CopilotChatLabels, CopilotKitCoreReact, type CopilotKitCoreReactConfig, type Interrupt, type InterruptEvent, type InterruptHandlerProps, type InterruptRenderProps, type JsonSerializable, type ReactFrontendTool, type ReactHumanInTheLoop, type RenderToolCompleteProps, type RenderToolExecutingProps, type RenderToolInProgressProps, type RenderToolProps, type ResumeEntry, type ResumeStatus, type Thread,
|
|
837
|
+
export { type AgentContextInput, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatDefaultLabels, type CopilotChatLabels, CopilotKitCoreReact, type CopilotKitCoreReactConfig, type Interrupt, type InterruptEvent, type InterruptHandlerProps, type InterruptRenderProps, type JsonSerializable, type ReactFrontendTool, type ReactHumanInTheLoop, type RenderToolCompleteProps, type RenderToolExecutingProps, type RenderToolInProgressProps, type RenderToolProps, type ResumeEntry, type ResumeStatus, type Thread, UseAgentUpdate, type UseInterruptConfig, type UseThreadsInput, type UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderTool, useRenderToolCall, useSuggestions, useThreads };
|
|
822
838
|
//# sourceMappingURL=headless.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headless.d.mts","names":[],"sources":["../../src/v2/providers/CopilotChatConfigurationProvider.tsx","../../src/v2/hooks/use-agent.tsx","../../src/v2/types/react-tool-call-renderer.ts","../../src/v2/types/frontend-tool.ts","../../src/v2/hooks/use-frontend-tool.tsx","../../src/v2/hooks/use-component.tsx","../../src/v2/types/human-in-the-loop.ts","../../src/v2/hooks/use-human-in-the-loop.tsx","../../src/v2/types/interrupt.ts","../../src/v2/hooks/use-interrupt.tsx","../../src/v2/hooks/use-suggestions.tsx","../../src/v2/hooks/use-configure-suggestions.tsx","../../src/v2/hooks/use-agent-context.tsx","../../src/v2/hooks/use-threads.tsx","../../src/v2/hooks/use-render-tool.tsx","../../src/v2/types/defineToolCallRenderer.ts","../../src/v2/hooks/use-capabilities.tsx"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"headless.d.mts","names":[],"sources":["../../src/v2/providers/CopilotChatConfigurationProvider.tsx","../../src/v2/hooks/use-agent.tsx","../../src/v2/types/react-tool-call-renderer.ts","../../src/v2/types/frontend-tool.ts","../../src/v2/hooks/use-frontend-tool.tsx","../../src/v2/hooks/use-component.tsx","../../src/v2/types/human-in-the-loop.ts","../../src/v2/hooks/use-human-in-the-loop.tsx","../../src/v2/types/interrupt.ts","../../src/v2/hooks/use-interrupt.tsx","../../src/v2/hooks/use-suggestions.tsx","../../src/v2/hooks/use-configure-suggestions.tsx","../../src/v2/hooks/use-agent-context.tsx","../../src/v2/hooks/use-threads.tsx","../../src/v2/hooks/use-render-tool.tsx","../../src/v2/hooks/use-render-tool-call.tsx","../../src/v2/types/defineToolCallRenderer.ts","../../src/v2/hooks/use-capabilities.tsx"],"mappings":";;;;;;;;cAgBa,wBAAA;;;;;;;;;;;;;;;;;;;;;;KAwBD,iBAAA,UAA2B,wBAAA;AAAA,UA6BtB,6BAAA;EACf,MAAA,EAAQ,iBAAA;EACR,OAAA;EACA,QAAA;EACA,WAAA;EACA,YAAA,GAAe,IAAA;;;;AAlCjB;;EAwCE,UAAA;EAxCqC;;AA6BvC;;;EAiBE,aAAA,GAAgB,IAAA;EAhBhB;;;;;EAsBA,gBAAA;EAlBe;;;;;;;EA0Bf,c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|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { CopilotKitCoreReact, useCopilotKit } from "@copilotkit/react-core/v2/context";
|
|
1
|
+
import { CopilotKitCoreReact, useCopilotKit, useCopilotKit as useCopilotKit$1 } from "@copilotkit/react-core/v2/context";
|
|
2
2
|
import React, { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
|
|
3
|
-
import { DEFAULT_AGENT_ID, randomUUID } from "@copilotkit/shared";
|
|
4
|
-
import { twMerge } from "tailwind-merge";
|
|
3
|
+
import { DEFAULT_AGENT_ID, partialJSONParse, randomUUID } from "@copilotkit/shared";
|
|
5
4
|
import { jsx } from "react/jsx-runtime";
|
|
6
5
|
import { HttpAgent, randomUUID as randomUUID$1 } from "@ag-ui/client";
|
|
7
6
|
import { CopilotKitCoreRuntimeConnectionStatus, ProxiedCopilotRuntimeAgent, ToolCallStatus, ɵInterruptState, ɵcreateThreadStore, ɵselectFetchMoreError, ɵselectHasNextPage, ɵselectIsFetchingNextPage, ɵselectIsMutating, ɵselectThreads, ɵselectThreadsError, ɵselectThreadsIsLoading } from "@copilotkit/core";
|
|
8
7
|
import { z } from "zod";
|
|
9
8
|
|
|
10
|
-
//#region src/v2/lib/
|
|
9
|
+
//#region src/v2/lib/shallow-stable-ref.ts
|
|
11
10
|
/**
|
|
12
11
|
* Shallow equality comparison for objects.
|
|
13
12
|
*/
|
|
@@ -47,49 +46,6 @@ function useShallowStableRef(value) {
|
|
|
47
46
|
ref.current = value;
|
|
48
47
|
return ref.current;
|
|
49
48
|
}
|
|
50
|
-
/**
|
|
51
|
-
* Check if a value is a React component type (function, class, forwardRef, memo, etc.)
|
|
52
|
-
*/
|
|
53
|
-
function isReactComponentType(value) {
|
|
54
|
-
if (typeof value === "function") return true;
|
|
55
|
-
if (value && typeof value === "object" && "$$typeof" in value && !React.isValidElement(value)) return true;
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Internal function to render a slot value as a React element (non-memoized).
|
|
60
|
-
*/
|
|
61
|
-
function renderSlotElement(slot, DefaultComponent, props) {
|
|
62
|
-
if (typeof slot === "string") {
|
|
63
|
-
const existingClassName = props.className;
|
|
64
|
-
return React.createElement(DefaultComponent, {
|
|
65
|
-
...props,
|
|
66
|
-
className: twMerge(existingClassName, slot)
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
if (isReactComponentType(slot)) return React.createElement(slot, props);
|
|
70
|
-
if (slot && typeof slot === "object" && !React.isValidElement(slot)) return React.createElement(DefaultComponent, {
|
|
71
|
-
...props,
|
|
72
|
-
...slot
|
|
73
|
-
});
|
|
74
|
-
return React.createElement(DefaultComponent, props);
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Internal memoized wrapper component for renderSlot.
|
|
78
|
-
* Uses forwardRef to support ref forwarding.
|
|
79
|
-
*/
|
|
80
|
-
const MemoizedSlotWrapper = React.memo(React.forwardRef(function MemoizedSlotWrapper(props, ref) {
|
|
81
|
-
const { $slot, $component, ...rest } = props;
|
|
82
|
-
return renderSlotElement($slot, $component, ref !== null ? {
|
|
83
|
-
...rest,
|
|
84
|
-
ref
|
|
85
|
-
} : rest);
|
|
86
|
-
}), (prev, next) => {
|
|
87
|
-
if (prev.$slot !== next.$slot) return false;
|
|
88
|
-
if (prev.$component !== next.$component) return false;
|
|
89
|
-
const { $slot: _ps, $component: _pc, ...prevRest } = prev;
|
|
90
|
-
const { $slot: _ns, $component: _nc, ...nextRest } = next;
|
|
91
|
-
return shallowEqual(prevRest, nextRest);
|
|
92
|
-
});
|
|
93
49
|
|
|
94
50
|
//#endregion
|
|
95
51
|
//#region src/v2/providers/CopilotChatConfigurationProvider.tsx
|
|
@@ -311,7 +267,7 @@ const ALL_UPDATES = [
|
|
|
311
267
|
function useAgent({ agentId, updates, throttleMs } = {}) {
|
|
312
268
|
const chatConfig = useCopilotChatConfiguration();
|
|
313
269
|
const resolvedAgentId = agentId ?? chatConfig?.agentId ?? DEFAULT_AGENT_ID;
|
|
314
|
-
const { copilotkit } = useCopilotKit();
|
|
270
|
+
const { copilotkit } = useCopilotKit$1();
|
|
315
271
|
const providerThrottleMs = copilotkit.defaultThrottleMs;
|
|
316
272
|
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
|
317
273
|
const updateFlags = useMemo(() => updates ?? ALL_UPDATES, [JSON.stringify(updates)]);
|
|
@@ -329,17 +285,15 @@ function useAgent({ agentId, updates, throttleMs } = {}) {
|
|
|
329
285
|
const status = copilotkit.runtimeConnectionStatus;
|
|
330
286
|
if (isRuntimeConfigured && (status === CopilotKitCoreRuntimeConnectionStatus.Disconnected || status === CopilotKitCoreRuntimeConnectionStatus.Connecting)) {
|
|
331
287
|
const cached = provisionalAgentCache.current.get(resolvedAgentId);
|
|
332
|
-
if (cached) {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
isReady: false
|
|
337
|
-
};
|
|
338
|
-
}
|
|
288
|
+
if (cached) return {
|
|
289
|
+
agent: cached,
|
|
290
|
+
isReady: false
|
|
291
|
+
};
|
|
339
292
|
const provisional = new ProxiedCopilotRuntimeAgent({
|
|
340
293
|
runtimeUrl: copilotkit.runtimeUrl,
|
|
341
294
|
agentId: resolvedAgentId,
|
|
342
295
|
transport: copilotkit.runtimeTransport,
|
|
296
|
+
credentials: copilotkit.credentials,
|
|
343
297
|
runtimeMode: "pending"
|
|
344
298
|
});
|
|
345
299
|
copilotkit.applyHeadersToAgent(provisional);
|
|
@@ -351,17 +305,15 @@ function useAgent({ agentId, updates, throttleMs } = {}) {
|
|
|
351
305
|
}
|
|
352
306
|
if (isRuntimeConfigured && status === CopilotKitCoreRuntimeConnectionStatus.Error) {
|
|
353
307
|
const cached = provisionalAgentCache.current.get(resolvedAgentId);
|
|
354
|
-
if (cached) {
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
isReady: false
|
|
359
|
-
};
|
|
360
|
-
}
|
|
308
|
+
if (cached) return {
|
|
309
|
+
agent: cached,
|
|
310
|
+
isReady: false
|
|
311
|
+
};
|
|
361
312
|
const provisional = new ProxiedCopilotRuntimeAgent({
|
|
362
313
|
runtimeUrl: copilotkit.runtimeUrl,
|
|
363
314
|
agentId: resolvedAgentId,
|
|
364
315
|
transport: copilotkit.runtimeTransport,
|
|
316
|
+
credentials: copilotkit.credentials,
|
|
365
317
|
runtimeMode: "pending"
|
|
366
318
|
});
|
|
367
319
|
copilotkit.applyHeadersToAgent(provisional);
|
|
@@ -380,6 +332,7 @@ function useAgent({ agentId, updates, throttleMs } = {}) {
|
|
|
380
332
|
copilotkit.runtimeConnectionStatus,
|
|
381
333
|
copilotkit.runtimeUrl,
|
|
382
334
|
copilotkit.runtimeTransport,
|
|
335
|
+
copilotkit.credentials,
|
|
383
336
|
JSON.stringify(copilotkit.headers)
|
|
384
337
|
]);
|
|
385
338
|
useEffect(() => {
|
|
@@ -419,7 +372,12 @@ function useAgent({ agentId, updates, throttleMs } = {}) {
|
|
|
419
372
|
]);
|
|
420
373
|
useEffect(() => {
|
|
421
374
|
if (agent instanceof HttpAgent) copilotkit.applyHeadersToAgent(agent);
|
|
422
|
-
|
|
375
|
+
if (agent instanceof ProxiedCopilotRuntimeAgent) agent.credentials = copilotkit.credentials;
|
|
376
|
+
}, [
|
|
377
|
+
agent,
|
|
378
|
+
JSON.stringify(copilotkit.headers),
|
|
379
|
+
copilotkit.credentials
|
|
380
|
+
]);
|
|
423
381
|
const configThreadId = chatConfig?.threadId;
|
|
424
382
|
const configHasExplicitThreadId = chatConfig?.hasExplicitThreadId;
|
|
425
383
|
useEffect(() => {
|
|
@@ -440,7 +398,7 @@ function useAgent({ agentId, updates, throttleMs } = {}) {
|
|
|
440
398
|
//#region src/v2/hooks/use-frontend-tool.tsx
|
|
441
399
|
const EMPTY_DEPS$1 = [];
|
|
442
400
|
function useFrontendTool(tool, deps) {
|
|
443
|
-
const { copilotkit } = useCopilotKit();
|
|
401
|
+
const { copilotkit } = useCopilotKit$1();
|
|
444
402
|
const extraDeps = deps ?? EMPTY_DEPS$1;
|
|
445
403
|
useEffect(() => {
|
|
446
404
|
const name = tool.name;
|
|
@@ -540,7 +498,7 @@ function useComponent(config, deps) {
|
|
|
540
498
|
//#endregion
|
|
541
499
|
//#region src/v2/hooks/use-human-in-the-loop.tsx
|
|
542
500
|
function useHumanInTheLoop(tool, deps) {
|
|
543
|
-
const { copilotkit } = useCopilotKit();
|
|
501
|
+
const { copilotkit } = useCopilotKit$1();
|
|
544
502
|
const resolvePromiseRef = useRef(null);
|
|
545
503
|
const cleanupAbortRef = useRef(null);
|
|
546
504
|
const respond = useCallback(async (result) => {
|
|
@@ -668,7 +626,7 @@ function toLegacyEvent(pending) {
|
|
|
668
626
|
* ```
|
|
669
627
|
*/
|
|
670
628
|
function useInterrupt(config) {
|
|
671
|
-
const { copilotkit } = useCopilotKit();
|
|
629
|
+
const { copilotkit } = useCopilotKit$1();
|
|
672
630
|
const { agent } = useAgent({ agentId: config.agentId });
|
|
673
631
|
const [pending, setPending] = useState(null);
|
|
674
632
|
const pendingRef = useRef(pending);
|
|
@@ -898,7 +856,7 @@ function useInterrupt(config) {
|
|
|
898
856
|
//#endregion
|
|
899
857
|
//#region src/v2/hooks/use-suggestions.tsx
|
|
900
858
|
function useSuggestions({ agentId } = {}) {
|
|
901
|
-
const { copilotkit } = useCopilotKit();
|
|
859
|
+
const { copilotkit } = useCopilotKit$1();
|
|
902
860
|
const config = useCopilotChatConfiguration();
|
|
903
861
|
const resolvedAgentId = useMemo(() => agentId ?? config?.agentId ?? DEFAULT_AGENT_ID, [agentId, config?.agentId]);
|
|
904
862
|
const [suggestions, setSuggestions] = useState(() => {
|
|
@@ -951,7 +909,7 @@ function useSuggestions({ agentId } = {}) {
|
|
|
951
909
|
//#endregion
|
|
952
910
|
//#region src/v2/hooks/use-configure-suggestions.tsx
|
|
953
911
|
function useConfigureSuggestions(config, deps) {
|
|
954
|
-
const { copilotkit } = useCopilotKit();
|
|
912
|
+
const { copilotkit } = useCopilotKit$1();
|
|
955
913
|
const chatConfig = useCopilotChatConfiguration();
|
|
956
914
|
const extraDeps = deps ?? [];
|
|
957
915
|
const resolvedConsumerAgentId = useMemo(() => chatConfig?.agentId ?? DEFAULT_AGENT_ID, [chatConfig?.agentId]);
|
|
@@ -1111,7 +1069,7 @@ function normalizeStaticSuggestions(suggestions) {
|
|
|
1111
1069
|
//#region src/v2/hooks/use-agent-context.tsx
|
|
1112
1070
|
function useAgentContext(context) {
|
|
1113
1071
|
const { description, value } = context;
|
|
1114
|
-
const { copilotkit } = useCopilotKit();
|
|
1072
|
+
const { copilotkit } = useCopilotKit$1();
|
|
1115
1073
|
const stringValue = useMemo(() => {
|
|
1116
1074
|
if (typeof value === "string") return value;
|
|
1117
1075
|
return JSON.stringify(value);
|
|
@@ -1182,7 +1140,7 @@ function useThreadStoreSelector(store, selector) {
|
|
|
1182
1140
|
* ```
|
|
1183
1141
|
*/
|
|
1184
1142
|
function useThreads({ agentId, includeArchived, limit, enabled = true }) {
|
|
1185
|
-
const { copilotkit } = useCopilotKit();
|
|
1143
|
+
const { copilotkit } = useCopilotKit$1();
|
|
1186
1144
|
const [store] = useState(() => ɵcreateThreadStore({ fetch: globalThis.fetch }));
|
|
1187
1145
|
const coreThreads = useThreadStoreSelector(store, ɵselectThreads);
|
|
1188
1146
|
const threads = useMemo(() => coreThreads.map(({ id, agentId, name, archived, createdAt, updatedAt, lastRunAt }) => ({
|
|
@@ -1376,7 +1334,7 @@ const EMPTY_DEPS = [];
|
|
|
1376
1334
|
* ```
|
|
1377
1335
|
*/
|
|
1378
1336
|
function useRenderTool(config, deps) {
|
|
1379
|
-
const { copilotkit } = useCopilotKit();
|
|
1337
|
+
const { copilotkit } = useCopilotKit$1();
|
|
1380
1338
|
const extraDeps = deps ?? EMPTY_DEPS;
|
|
1381
1339
|
useEffect(() => {
|
|
1382
1340
|
const renderer = config.name === "*" && !config.parameters ? defineToolCallRenderer({
|
|
@@ -1413,6 +1371,76 @@ function useRenderTool(config, deps) {
|
|
|
1413
1371
|
]);
|
|
1414
1372
|
}
|
|
1415
1373
|
|
|
1374
|
+
//#endregion
|
|
1375
|
+
//#region src/v2/hooks/use-render-tool-call.tsx
|
|
1376
|
+
/**
|
|
1377
|
+
* Memoized component that renders a single tool call.
|
|
1378
|
+
* This prevents unnecessary re-renders when parent components update
|
|
1379
|
+
* but the tool call data hasn't changed.
|
|
1380
|
+
*/
|
|
1381
|
+
const ToolCallRenderer = React.memo(function ToolCallRenderer({ toolCall, toolMessage, RenderComponent, isExecuting }) {
|
|
1382
|
+
const args = useMemo(() => partialJSONParse(toolCall.function.arguments), [toolCall.function.arguments]);
|
|
1383
|
+
const toolName = toolCall.function.name;
|
|
1384
|
+
if (toolMessage) return /* @__PURE__ */ jsx(RenderComponent, {
|
|
1385
|
+
name: toolName,
|
|
1386
|
+
toolCallId: toolCall.id,
|
|
1387
|
+
args,
|
|
1388
|
+
status: ToolCallStatus.Complete,
|
|
1389
|
+
result: toolMessage.content
|
|
1390
|
+
});
|
|
1391
|
+
else if (isExecuting) return /* @__PURE__ */ jsx(RenderComponent, {
|
|
1392
|
+
name: toolName,
|
|
1393
|
+
toolCallId: toolCall.id,
|
|
1394
|
+
args,
|
|
1395
|
+
status: ToolCallStatus.Executing,
|
|
1396
|
+
result: void 0
|
|
1397
|
+
});
|
|
1398
|
+
else return /* @__PURE__ */ jsx(RenderComponent, {
|
|
1399
|
+
name: toolName,
|
|
1400
|
+
toolCallId: toolCall.id,
|
|
1401
|
+
args,
|
|
1402
|
+
status: ToolCallStatus.InProgress,
|
|
1403
|
+
result: void 0
|
|
1404
|
+
});
|
|
1405
|
+
}, (prevProps, nextProps) => {
|
|
1406
|
+
if (prevProps.toolCall.id !== nextProps.toolCall.id) return false;
|
|
1407
|
+
if (prevProps.toolCall.function.name !== nextProps.toolCall.function.name) return false;
|
|
1408
|
+
if (prevProps.toolCall.function.arguments !== nextProps.toolCall.function.arguments) return false;
|
|
1409
|
+
if (prevProps.toolMessage?.content !== nextProps.toolMessage?.content) return false;
|
|
1410
|
+
if (prevProps.isExecuting !== nextProps.isExecuting) return false;
|
|
1411
|
+
if (prevProps.RenderComponent !== nextProps.RenderComponent) return false;
|
|
1412
|
+
return true;
|
|
1413
|
+
});
|
|
1414
|
+
/**
|
|
1415
|
+
* Hook that returns a function to render tool calls based on the render functions
|
|
1416
|
+
* defined in CopilotKitProvider.
|
|
1417
|
+
*
|
|
1418
|
+
* @returns A function that takes a tool call and optional tool message and returns the rendered component
|
|
1419
|
+
*/
|
|
1420
|
+
function useRenderToolCall() {
|
|
1421
|
+
const { copilotkit, executingToolCallIds } = useCopilotKit$1();
|
|
1422
|
+
const agentId = useCopilotChatConfiguration()?.agentId ?? DEFAULT_AGENT_ID;
|
|
1423
|
+
const renderToolCalls = useSyncExternalStore((callback) => {
|
|
1424
|
+
return copilotkit.subscribe({ onRenderToolCallsChanged: callback }).unsubscribe;
|
|
1425
|
+
}, () => copilotkit.renderToolCalls, () => copilotkit.renderToolCalls);
|
|
1426
|
+
return useCallback(({ toolCall, toolMessage }) => {
|
|
1427
|
+
const exactMatches = renderToolCalls.filter((rc) => rc.name === toolCall.function.name);
|
|
1428
|
+
const renderConfig = exactMatches.find((rc) => rc.agentId === agentId) || exactMatches.find((rc) => !rc.agentId) || exactMatches[0] || renderToolCalls.find((rc) => rc.name === "*");
|
|
1429
|
+
if (!renderConfig) return null;
|
|
1430
|
+
const RenderComponent = renderConfig.render;
|
|
1431
|
+
return /* @__PURE__ */ jsx(ToolCallRenderer, {
|
|
1432
|
+
toolCall,
|
|
1433
|
+
toolMessage,
|
|
1434
|
+
RenderComponent,
|
|
1435
|
+
isExecuting: executingToolCallIds.has(toolCall.id)
|
|
1436
|
+
}, toolCall.id);
|
|
1437
|
+
}, [
|
|
1438
|
+
renderToolCalls,
|
|
1439
|
+
executingToolCallIds,
|
|
1440
|
+
agentId
|
|
1441
|
+
]);
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1416
1444
|
//#endregion
|
|
1417
1445
|
//#region src/v2/hooks/use-capabilities.tsx
|
|
1418
1446
|
/**
|
|
@@ -1434,5 +1462,5 @@ function useCapabilities(agentId) {
|
|
|
1434
1462
|
}
|
|
1435
1463
|
|
|
1436
1464
|
//#endregion
|
|
1437
|
-
export { CopilotChatConfigurationProvider, CopilotChatDefaultLabels, CopilotKitCoreReact, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderTool, useSuggestions, useThreads };
|
|
1465
|
+
export { CopilotChatConfigurationProvider, CopilotChatDefaultLabels, CopilotKitCoreReact, UseAgentUpdate, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderTool, useRenderToolCall, useSuggestions, useThreads };
|
|
1438
1466
|
//# sourceMappingURL=headless.mjs.map
|