@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.
Files changed (63) hide show
  1. package/dist/{copilotkit-BNlJq5UO.d.mts → copilotkit-BN4I_y1n.d.mts} +6 -4
  2. package/dist/copilotkit-BN4I_y1n.d.mts.map +1 -0
  3. package/dist/{copilotkit-B_k0HSNz.cjs → copilotkit-C3k13WZn.cjs} +197 -198
  4. package/dist/copilotkit-C3k13WZn.cjs.map +1 -0
  5. package/dist/{copilotkit-ak8sGvQr.mjs → copilotkit-DjxXMYHG.mjs} +198 -199
  6. package/dist/copilotkit-DjxXMYHG.mjs.map +1 -0
  7. package/dist/{copilotkit-DgC5oCFO.d.cts → copilotkit-sQWiKtxA.d.cts} +6 -4
  8. package/dist/copilotkit-sQWiKtxA.d.cts.map +1 -0
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.d.cts +1 -1
  11. package/dist/index.d.mts +1 -1
  12. package/dist/index.mjs +1 -1
  13. package/dist/index.umd.js +207 -205
  14. package/dist/index.umd.js.map +1 -1
  15. package/dist/v2/context.cjs +135 -0
  16. package/dist/v2/context.cjs.map +1 -0
  17. package/dist/v2/context.d.cts +148 -0
  18. package/dist/v2/context.d.cts.map +1 -0
  19. package/dist/v2/context.d.mts +148 -0
  20. package/dist/v2/context.d.mts.map +1 -0
  21. package/dist/v2/context.mjs +129 -0
  22. package/dist/v2/context.mjs.map +1 -0
  23. package/dist/v2/headless.cjs +1043 -0
  24. package/dist/v2/headless.cjs.map +1 -0
  25. package/dist/v2/headless.d.cts +605 -0
  26. package/dist/v2/headless.d.cts.map +1 -0
  27. package/dist/v2/headless.d.mts +512 -0
  28. package/dist/v2/headless.d.mts.map +1 -0
  29. package/dist/v2/headless.mjs +997 -0
  30. package/dist/v2/headless.mjs.map +1 -0
  31. package/dist/v2/index.cjs +1 -1
  32. package/dist/v2/index.d.cts +1 -1
  33. package/dist/v2/index.d.mts +1 -1
  34. package/dist/v2/index.mjs +1 -1
  35. package/dist/v2/index.umd.js +209 -208
  36. package/dist/v2/index.umd.js.map +1 -1
  37. package/package.json +14 -6
  38. package/src/v2/context.ts +62 -0
  39. package/src/v2/headless.ts +42 -0
  40. package/src/v2/hooks/__tests__/standard-schema.test.tsx +2 -2
  41. package/src/v2/hooks/__tests__/use-agent-context.test.tsx +3 -3
  42. package/src/v2/hooks/__tests__/use-agent-stability.test.tsx +3 -3
  43. package/src/v2/hooks/__tests__/use-agent-throttle.test.tsx +85 -85
  44. package/src/v2/hooks/__tests__/use-interrupt.test.tsx +2 -2
  45. package/src/v2/hooks/__tests__/use-render-tool.test.tsx +2 -2
  46. package/src/v2/hooks/__tests__/use-threads.test.tsx +2 -2
  47. package/src/v2/hooks/__tests__/zod-regression.test.tsx +2 -2
  48. package/src/v2/hooks/use-agent-context.tsx +1 -1
  49. package/src/v2/hooks/use-agent.tsx +2 -2
  50. package/src/v2/hooks/use-configure-suggestions.tsx +1 -1
  51. package/src/v2/hooks/use-frontend-tool.tsx +2 -2
  52. package/src/v2/hooks/use-human-in-the-loop.tsx +1 -1
  53. package/src/v2/hooks/use-interrupt.tsx +1 -1
  54. package/src/v2/hooks/use-render-tool-call.tsx +1 -1
  55. package/src/v2/hooks/use-render-tool.tsx +2 -2
  56. package/src/v2/hooks/use-suggestions.tsx +1 -1
  57. package/src/v2/hooks/use-threads.tsx +1 -1
  58. package/src/v2/providers/CopilotKitProvider.tsx +19 -59
  59. package/tsdown.config.ts +75 -0
  60. package/dist/copilotkit-BNlJq5UO.d.mts.map +0 -1
  61. package/dist/copilotkit-B_k0HSNz.cjs.map +0 -1
  62. package/dist/copilotkit-DgC5oCFO.d.cts.map +0 -1
  63. 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.0-canary.1778146769",
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.0-canary.1778146769",
77
- "@copilotkit/core": "1.57.0-canary.1778146769",
78
- "@copilotkit/runtime-client-gql": "1.57.0-canary.1778146769",
79
- "@copilotkit/shared": "1.57.0-canary.1778146769",
80
- "@copilotkit/web-inspector": "1.57.0-canary.1778146769"
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 "../../providers/CopilotKitProvider";
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("../../providers/CopilotKitProvider", () => ({
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 "../../providers/CopilotKitProvider";
5
+ import { useCopilotKit } from "../../context";
6
6
 
7
- // Mock the CopilotKitProvider
8
- vi.mock("../../providers/CopilotKitProvider", () => ({
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 "../../providers/CopilotKitProvider";
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 CopilotKitProvider to control copilotkit state directly
11
- vi.mock("../../providers/CopilotKitProvider", () => ({
10
+ // Mock the CopilotKit context to control copilotkit state directly
11
+ vi.mock("../../context", () => ({
12
12
  useCopilotKit: vi.fn(),
13
13
  }));
14
14