@copilotkit/react-core 1.57.0-canary.1778146769 → 1.57.1
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-BNlJq5UO.d.mts → copilotkit-BN4I_y1n.d.mts} +6 -4
- package/dist/copilotkit-BN4I_y1n.d.mts.map +1 -0
- package/dist/{copilotkit-B_k0HSNz.cjs → copilotkit-C3k13WZn.cjs} +197 -198
- package/dist/copilotkit-C3k13WZn.cjs.map +1 -0
- package/dist/{copilotkit-ak8sGvQr.mjs → copilotkit-DjxXMYHG.mjs} +198 -199
- package/dist/copilotkit-DjxXMYHG.mjs.map +1 -0
- package/dist/{copilotkit-DgC5oCFO.d.cts → copilotkit-sQWiKtxA.d.cts} +6 -4
- package/dist/copilotkit-sQWiKtxA.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 +207 -205
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/context.cjs +135 -0
- package/dist/v2/context.cjs.map +1 -0
- package/dist/v2/context.d.cts +148 -0
- package/dist/v2/context.d.cts.map +1 -0
- package/dist/v2/context.d.mts +148 -0
- package/dist/v2/context.d.mts.map +1 -0
- package/dist/v2/context.mjs +129 -0
- package/dist/v2/context.mjs.map +1 -0
- package/dist/v2/headless.cjs +1043 -0
- package/dist/v2/headless.cjs.map +1 -0
- package/dist/v2/headless.d.cts +605 -0
- package/dist/v2/headless.d.cts.map +1 -0
- package/dist/v2/headless.d.mts +512 -0
- package/dist/v2/headless.d.mts.map +1 -0
- package/dist/v2/headless.mjs +997 -0
- package/dist/v2/headless.mjs.map +1 -0
- 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 +209 -208
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +14 -6
- package/src/v2/context.ts +62 -0
- package/src/v2/headless.ts +42 -0
- package/src/v2/hooks/__tests__/standard-schema.test.tsx +2 -2
- package/src/v2/hooks/__tests__/use-agent-context.test.tsx +3 -3
- package/src/v2/hooks/__tests__/use-agent-stability.test.tsx +3 -3
- package/src/v2/hooks/__tests__/use-agent-throttle.test.tsx +85 -85
- package/src/v2/hooks/__tests__/use-interrupt.test.tsx +2 -2
- package/src/v2/hooks/__tests__/use-render-tool.test.tsx +2 -2
- package/src/v2/hooks/__tests__/use-threads.test.tsx +2 -2
- package/src/v2/hooks/__tests__/zod-regression.test.tsx +2 -2
- package/src/v2/hooks/use-agent-context.tsx +1 -1
- package/src/v2/hooks/use-agent.tsx +2 -2
- package/src/v2/hooks/use-configure-suggestions.tsx +1 -1
- package/src/v2/hooks/use-frontend-tool.tsx +2 -2
- package/src/v2/hooks/use-human-in-the-loop.tsx +1 -1
- package/src/v2/hooks/use-interrupt.tsx +1 -1
- package/src/v2/hooks/use-render-tool-call.tsx +1 -1
- package/src/v2/hooks/use-render-tool.tsx +2 -2
- package/src/v2/hooks/use-suggestions.tsx +1 -1
- package/src/v2/hooks/use-threads.tsx +1 -1
- package/src/v2/providers/CopilotKitProvider.tsx +19 -59
- package/tsdown.config.ts +75 -0
- package/dist/copilotkit-BNlJq5UO.d.mts.map +0 -1
- package/dist/copilotkit-B_k0HSNz.cjs.map +0 -1
- package/dist/copilotkit-DgC5oCFO.d.cts.map +0 -1
- package/dist/copilotkit-ak8sGvQr.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@copilotkit/react-core",
|
|
3
|
-
"version": "1.57.
|
|
3
|
+
"version": "1.57.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -46,6 +46,14 @@
|
|
|
46
46
|
"require": "./dist/v2/index.cjs"
|
|
47
47
|
},
|
|
48
48
|
"./package.json": "./package.json",
|
|
49
|
+
"./v2/context": {
|
|
50
|
+
"import": "./dist/v2/context.mjs",
|
|
51
|
+
"require": "./dist/v2/context.cjs"
|
|
52
|
+
},
|
|
53
|
+
"./v2/headless": {
|
|
54
|
+
"import": "./dist/v2/headless.mjs",
|
|
55
|
+
"require": "./dist/v2/headless.cjs"
|
|
56
|
+
},
|
|
49
57
|
"./v2/styles.css": "./dist/v2/index.css"
|
|
50
58
|
},
|
|
51
59
|
"publishConfig": {
|
|
@@ -73,11 +81,11 @@
|
|
|
73
81
|
"untruncate-json": "^0.0.1",
|
|
74
82
|
"use-stick-to-bottom": "^1.1.1",
|
|
75
83
|
"zod-to-json-schema": "^3.24.5",
|
|
76
|
-
"@copilotkit/a2ui-renderer": "1.57.
|
|
77
|
-
"@copilotkit/core": "1.57.
|
|
78
|
-
"@copilotkit/
|
|
79
|
-
"@copilotkit/
|
|
80
|
-
"@copilotkit/
|
|
84
|
+
"@copilotkit/a2ui-renderer": "1.57.1",
|
|
85
|
+
"@copilotkit/core": "1.57.1",
|
|
86
|
+
"@copilotkit/web-inspector": "1.57.1",
|
|
87
|
+
"@copilotkit/runtime-client-gql": "1.57.1",
|
|
88
|
+
"@copilotkit/shared": "1.57.1"
|
|
81
89
|
},
|
|
82
90
|
"devDependencies": {
|
|
83
91
|
"@tailwindcss/cli": "^4.1.11",
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext, useEffect, useReducer } from "react";
|
|
4
|
+
import { CopilotKitCoreReact } from "./lib/react-core";
|
|
5
|
+
import type { CopilotKitCoreReactConfig } from "./lib/react-core";
|
|
6
|
+
import type { LicenseContextValue } from "@copilotkit/shared";
|
|
7
|
+
|
|
8
|
+
// Re-export so headless.ts (and consumers) reference the same type declaration.
|
|
9
|
+
export { CopilotKitCoreReact };
|
|
10
|
+
export type { CopilotKitCoreReactConfig };
|
|
11
|
+
|
|
12
|
+
export interface CopilotKitContextValue {
|
|
13
|
+
copilotkit: CopilotKitCoreReact;
|
|
14
|
+
/**
|
|
15
|
+
* Set of tool call IDs currently being executed.
|
|
16
|
+
* This is tracked at the provider level to ensure tool execution events
|
|
17
|
+
* are captured even before child components mount.
|
|
18
|
+
*/
|
|
19
|
+
executingToolCallIds: ReadonlySet<string>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const EMPTY_SET: ReadonlySet<string> = new Set();
|
|
23
|
+
|
|
24
|
+
export const CopilotKitContext = createContext<CopilotKitContextValue | null>(
|
|
25
|
+
null,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export const useCopilotKit = (): CopilotKitContextValue => {
|
|
29
|
+
const context = useContext(CopilotKitContext);
|
|
30
|
+
const [, forceUpdate] = useReducer((x: number) => x + 1, 0);
|
|
31
|
+
|
|
32
|
+
if (!context) {
|
|
33
|
+
throw new Error("useCopilotKit must be used within CopilotKitProvider");
|
|
34
|
+
}
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const subscription = context.copilotkit.subscribe({
|
|
37
|
+
onRuntimeConnectionStatusChanged: () => {
|
|
38
|
+
forceUpdate();
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
return () => {
|
|
42
|
+
subscription.unsubscribe();
|
|
43
|
+
};
|
|
44
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
45
|
+
}, []);
|
|
46
|
+
|
|
47
|
+
return context;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// License context — shared between web and RN providers.
|
|
51
|
+
// Default is permissive (all features allowed) — providers override via createLicenseContextValue.
|
|
52
|
+
// Inlined here to avoid a runtime import from @copilotkit/shared, which pulls in
|
|
53
|
+
// Node-only deps (jose) that break React Native's Metro bundler.
|
|
54
|
+
export const LicenseContext = createContext<LicenseContextValue>({
|
|
55
|
+
status: null,
|
|
56
|
+
license: null,
|
|
57
|
+
checkFeature: () => true,
|
|
58
|
+
getLimit: () => null,
|
|
59
|
+
} as LicenseContextValue);
|
|
60
|
+
|
|
61
|
+
export const useLicenseContext = (): LicenseContextValue =>
|
|
62
|
+
useContext(LicenseContext);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless (platform-agnostic) exports from @copilotkit/react-core/v2.
|
|
3
|
+
*
|
|
4
|
+
* No CSS, no web UI components, no DOM dependencies.
|
|
5
|
+
* Used by @copilotkit/react-native.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Re-export from context (which is external in this build) so the .d.ts
|
|
9
|
+
// references the same type declaration. This avoids a nominal type mismatch
|
|
10
|
+
// caused by private class members being declared in two separate .d.ts files.
|
|
11
|
+
export { CopilotKitCoreReact } from "./context";
|
|
12
|
+
export type { CopilotKitCoreReactConfig } from "./context";
|
|
13
|
+
|
|
14
|
+
// Chat configuration provider (no UI, just context)
|
|
15
|
+
export {
|
|
16
|
+
CopilotChatConfigurationProvider,
|
|
17
|
+
useCopilotChatConfiguration,
|
|
18
|
+
CopilotChatDefaultLabels,
|
|
19
|
+
type CopilotChatLabels,
|
|
20
|
+
type CopilotChatConfigurationValue,
|
|
21
|
+
type CopilotChatConfigurationProviderProps,
|
|
22
|
+
} from "./providers/CopilotChatConfigurationProvider";
|
|
23
|
+
|
|
24
|
+
// Platform-agnostic hooks
|
|
25
|
+
export { useAgent, type UseAgentUpdate } from "./hooks/use-agent";
|
|
26
|
+
export { useFrontendTool } from "./hooks/use-frontend-tool";
|
|
27
|
+
export { useComponent } from "./hooks/use-component";
|
|
28
|
+
export { useHumanInTheLoop } from "./hooks/use-human-in-the-loop";
|
|
29
|
+
export { useInterrupt, type UseInterruptConfig } from "./hooks/use-interrupt";
|
|
30
|
+
export { useSuggestions } from "./hooks/use-suggestions";
|
|
31
|
+
export { useConfigureSuggestions } from "./hooks/use-configure-suggestions";
|
|
32
|
+
export {
|
|
33
|
+
useAgentContext,
|
|
34
|
+
type AgentContextInput,
|
|
35
|
+
type JsonSerializable,
|
|
36
|
+
} from "./hooks/use-agent-context";
|
|
37
|
+
export {
|
|
38
|
+
useThreads,
|
|
39
|
+
type Thread,
|
|
40
|
+
type UseThreadsInput,
|
|
41
|
+
type UseThreadsResult,
|
|
42
|
+
} from "./hooks/use-threads";
|
|
@@ -6,12 +6,12 @@ import * as v from "valibot";
|
|
|
6
6
|
import { type } from "arktype";
|
|
7
7
|
import { useRenderTool, type RenderToolProps } from "../use-render-tool";
|
|
8
8
|
import { useComponent } from "../use-component";
|
|
9
|
-
import { useCopilotKit } from "../../
|
|
9
|
+
import { useCopilotKit } from "../../context";
|
|
10
10
|
import { useFrontendTool } from "../use-frontend-tool";
|
|
11
11
|
import type { ReactToolCallRenderer } from "../../types/react-tool-call-renderer";
|
|
12
12
|
import type { StandardSchemaV1 } from "@copilotkit/shared";
|
|
13
13
|
|
|
14
|
-
vi.mock("../../
|
|
14
|
+
vi.mock("../../context", () => ({
|
|
15
15
|
useCopilotKit: vi.fn(),
|
|
16
16
|
}));
|
|
17
17
|
|
|
@@ -2,10 +2,10 @@ import React, { useState } from "react";
|
|
|
2
2
|
import { render, act } from "@testing-library/react";
|
|
3
3
|
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
|
|
4
4
|
import { useAgentContext, type AgentContextInput } from "../use-agent-context";
|
|
5
|
-
import { useCopilotKit } from "../../
|
|
5
|
+
import { useCopilotKit } from "../../context";
|
|
6
6
|
|
|
7
|
-
// Mock the
|
|
8
|
-
vi.mock("../../
|
|
7
|
+
// Mock the CopilotKit context
|
|
8
|
+
vi.mock("../../context", () => ({
|
|
9
9
|
useCopilotKit: vi.fn(),
|
|
10
10
|
}));
|
|
11
11
|
|
|
@@ -2,13 +2,13 @@ import React from "react";
|
|
|
2
2
|
import { render } from "@testing-library/react";
|
|
3
3
|
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
4
4
|
import { AbstractAgent } from "@ag-ui/client";
|
|
5
|
-
import { useCopilotKit } from "../../
|
|
5
|
+
import { useCopilotKit } from "../../context";
|
|
6
6
|
import { MockStepwiseAgent } from "../../__tests__/utils/test-helpers";
|
|
7
7
|
import { useAgent } from "../use-agent";
|
|
8
8
|
import { CopilotKitCoreRuntimeConnectionStatus } from "@copilotkit/core";
|
|
9
9
|
|
|
10
|
-
// Mock the
|
|
11
|
-
vi.mock("../../
|
|
10
|
+
// Mock the CopilotKit context to control copilotkit state directly
|
|
11
|
+
vi.mock("../../context", () => ({
|
|
12
12
|
useCopilotKit: vi.fn(),
|
|
13
13
|
}));
|
|
14
14
|
|