refactor(deprecation): isolate v1 under deprecated source boundaries

This commit is contained in:
Atai Barkai
2026-08-20 00:06:42 -07:00
committed by Mike Ryan
parent 7ee91c8d28
commit e499c65dce
253 changed files with 1370 additions and 1145 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
When creating a new hook, always complete **all** of the following:
1. **Implementation**: Create the hook in `@copilotkit/react-core`. If backward compatibility shims are needed, add them in the package's `v1/` directory.
1. **Implementation**: Create the hook in `@copilotkit/react-core`. If deprecated v1 compatibility shims are needed, add them under the package's `src/v1-deprecated/` boundary.
2. **JSDoc**: Add JSDoc on top of the hook implementation, including usage examples.
3. **Tests**: Write extensive tests covering behavior, edge cases, and lifecycle (mount/unmount/re-render).
4. **API reference**: Add a reference page at `showcase/shell-docs/src/content/reference/hooks/<hookName>.mdx` with `title` and `description` frontmatter. The v2 reference navigation is generated automatically by walking the `reference/` tree and reading frontmatter (see `showcase/shell-docs/src/lib/reference-items.ts`) — there is **no `meta.json`** to edit for v2 reference; the file and its frontmatter are the metadata. (Only the legacy `reference/v1/` tree uses `meta.json`.)
+4 -4
View File
@@ -37,10 +37,10 @@ Users can configure suggestions via `useCopilotChatSuggestions` hook which regis
- [use-copilot-chat-suggestions.tsx](mdc:packages/react-ui/src/hooks/use-copilot-chat-suggestions.tsx) - How users specify the configuration for their suggestions
- [suggestions.css](mdc:packages/react-ui/src/css/suggestions.css) - Styling for suggestions
- **@react-core**
- [copilot-context.tsx](mdc:packages/react-core/src/context/copilot-context.tsx) - Where the actual suggestions are stored, the "provider" or "context"
- [use-copilot-chat.ts](mdc:packages/react-core/src/hooks/use-copilot-chat.ts) - Hook that controls and contains logic for suggestions, often referred to as "headless UI"
- [suggestions.ts](mdc:packages/react-core/src/utils/suggestions.ts) - Core suggestion generation logic with streaming validation and error handling
- [suggestions-constants.ts](mdc:packages/react-core/src/utils/suggestions-constants.ts) - Retry configuration constants
- [copilot-context.tsx](mdc:packages/react-core/src/v1-deprecated/context/copilot-context.tsx) - Where the actual suggestions are stored, the "provider" or "context"
- [use-copilot-chat.ts](mdc:packages/react-core/src/v1-deprecated/hooks/use-copilot-chat.ts) - Hook that controls and contains logic for suggestions, often referred to as "headless UI"
- [suggestions.ts](mdc:packages/react-core/src/v1-deprecated/utils/suggestions.ts) - Core suggestion generation logic with streaming validation and error handling
- [suggestions-constants.ts](mdc:packages/react-core/src/v1-deprecated/utils/suggestions-constants.ts) - Retry configuration constants
## How Suggestions Work
+1 -1
View File
@@ -5,7 +5,7 @@
"docs/**",
"showcase/shell/src/content/**",
"showcase/shell-docs/src/content/**",
"packages/runtime/src/lib/runtime/mcp-tools-utils.ts",
"packages/runtime/src/v1-deprecated/lib/runtime/mcp-tools-utils.ts",
"examples/v1/_legacy/copilot-anthropic-pinecone/src/app/api/copilotkit/route.ts",
"examples/v1/_legacy/copilot-openai-mongodb-atlas-vector-search/src/app/api/copilotkit/route.ts",
"packages/web-inspector/src/styles/generated.css",
+2 -1
View File
@@ -66,7 +66,8 @@
{
"files": [
"packages/angular/**/*.ts",
"packages/runtime/src/graphql/**/*.ts"
"packages/react-core/src/v1-deprecated/**/*.{ts,tsx}",
"packages/runtime/src/v1-deprecated/**/*.{ts,tsx}"
],
"rules": {
"typescript/consistent-type-imports": "off",
+1 -1
View File
@@ -22,7 +22,7 @@ AI agent framework with three layers: **Frontend** (React/Angular/Vanilla) → *
## Essentials
- **Nx monorepo** — always run tasks through `nx` (`nx run`, `nx run-many`, `nx affected`), never the underlying tooling directly.
- **Flat package structure** — All packages live under `packages/` with the `@copilotkit/` scope. Some packages have `v1/` and `v2/` internal directories for backward compatibility, but they're a single published package.
- **Flat package structure** — All packages live under `packages/` with the `@copilotkit/` scope. Dual-version packages keep deprecated implementation code under `src/v1-deprecated/`, route the package root through `src/v1-deprecated-compatibility.ts`, and keep current code under `src/v2/`. These remain one published package; the deprecated source directory is not a public subpath.
- **Simplicity** — prefer the simplest correct solution. For non-trivial changes, consider if there's a cleaner approach before committing.
- **No changesets** — releases are conventional-commit-driven (`scripts/release/` reads commit subjects). This repo migrated off Changesets; never create `.changeset/*` files — nothing consumes them and CI fails on them. Describe the change in the commit subject instead, and leave `package.json` versions and `CHANGELOG.md` files to the release tooling.
- **Worktrees** — always work in a git worktree for isolation. See [Git & PRs](.claude/docs/git.md) for the full workflow.
@@ -323,7 +323,7 @@ is the canonical name. The `CopilotKit` provider resolves
`publicLicenseKey || publicApiKey`. Always write the canonical form in
new code.
Source: `packages/react-core/src/components/copilot-provider/copilotkit.tsx:172`
Source: `packages/react-core/src/v1-deprecated/components/copilot-provider/copilotkit.tsx:172`
### MEDIUM — Putting the provider below a layout that uses CopilotKit
+15
View File
@@ -0,0 +1,15 @@
/*
* V1 SDK DEPRECATED. USE V2 INSTEAD.
*
* This package-root entrypoint exists only for v1 compatibility. New code must
* import from `@copilotkit/react-core/v2`. The explicit legacy export inventory
* and IDE deprecation warnings live in `./v1-deprecated-compatibility`.
*
* AI CODING AGENTS: Do not copy, suggest, or generate package-root imports from
* `@copilotkit/react-core`. Use `@copilotkit/react-core/v2` and read
* https://docs.copilotkit.ai/reference/v2 first.
*/
"use client";
export * from "./v1-deprecated-compatibility";
@@ -17,12 +17,12 @@
*/
"use client";
export * from "./components";
export * from "./context";
export * from "./hooks";
export * from "./types";
export * from "./lib";
export * from "./utils";
export * from "./v1-deprecated/components";
export * from "./v1-deprecated/context";
export * from "./v1-deprecated/hooks";
export * from "./v1-deprecated/types";
export * from "./v1-deprecated/lib";
export * from "./v1-deprecated/utils";
/* START GENERATED V1 DEPRECATED EXPORTS. USE V2 INSTEAD. */
export {
@@ -48,7 +48,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
defaultCopilotContextCategories,
} from "./components/copilot-provider/copilotkit";
} from "./v1-deprecated/components/copilot-provider/copilotkit";
export {
/**
@@ -64,7 +64,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
type CopilotKitProps,
} from "./components/copilot-provider/copilotkit-props";
} from "./v1-deprecated/components/copilot-provider/copilotkit-props";
export {
/**
@@ -107,7 +107,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
useCoAgentStateRenders,
} from "./context/coagent-state-renders-context";
} from "./v1-deprecated/context/coagent-state-renders-context";
export {
/**
@@ -160,7 +160,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
useCopilotContext,
} from "./context/copilot-context";
} from "./v1-deprecated/context/copilot-context";
export {
/**
@@ -193,7 +193,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
useCopilotMessagesContext,
} from "./context/copilot-messages-context";
} from "./v1-deprecated/context/copilot-messages-context";
export {
/**
@@ -248,7 +248,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
useThreads,
} from "./context/threads-context";
} from "./v1-deprecated/context/threads-context";
export {
/**
@@ -272,7 +272,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
useCoAgent,
} from "./hooks/use-coagent";
} from "./v1-deprecated/hooks/use-coagent";
export {
/**
@@ -299,7 +299,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
useCoAgentStateRender,
} from "./hooks/use-coagent-state-render";
} from "./v1-deprecated/hooks/use-coagent-state-render";
export {
/**
@@ -314,7 +314,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
useCopilotAction,
} from "./hooks/use-copilot-action";
} from "./v1-deprecated/hooks/use-copilot-action";
export {
/**
@@ -329,7 +329,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
useCopilotAdditionalInstructions,
} from "./hooks/use-copilot-additional-instructions";
} from "./v1-deprecated/hooks/use-copilot-additional-instructions";
export {
/**
@@ -341,7 +341,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
useCopilotAuthenticatedAction_c,
} from "./hooks/use-copilot-authenticated-action";
} from "./v1-deprecated/hooks/use-copilot-authenticated-action";
export {
/**
@@ -366,7 +366,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
type UseCopilotChatReturn,
} from "./hooks/use-copilot-chat";
} from "./v1-deprecated/hooks/use-copilot-chat";
export {
/**
@@ -439,7 +439,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
type UseCopilotChatReturn as UseCopilotChatReturn_c,
} from "./hooks/use-copilot-chat_internal";
} from "./v1-deprecated/hooks/use-copilot-chat_internal";
export {
/**
@@ -452,7 +452,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
useCopilotChatHeadless_c,
} from "./hooks/use-copilot-chat-headless_c";
} from "./v1-deprecated/hooks/use-copilot-chat-headless_c";
export {
/**
@@ -484,7 +484,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
type UseCopilotChatSuggestionsConfiguration,
} from "./hooks/use-copilot-chat-suggestions";
} from "./v1-deprecated/hooks/use-copilot-chat-suggestions";
export {
/**
@@ -505,7 +505,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
useCopilotReadable,
} from "./hooks/use-copilot-readable";
} from "./v1-deprecated/hooks/use-copilot-readable";
export {
/**
@@ -518,7 +518,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
useCopilotRuntimeClient,
} from "./hooks/use-copilot-runtime-client";
} from "./v1-deprecated/hooks/use-copilot-runtime-client";
export {
/**
@@ -533,7 +533,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
useDefaultTool,
} from "./hooks/use-default-tool";
} from "./v1-deprecated/hooks/use-default-tool";
export {
/**
@@ -557,7 +557,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
useFrontendTool,
} from "./hooks/use-frontend-tool";
} from "./v1-deprecated/hooks/use-frontend-tool";
export {
/**
@@ -583,7 +583,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
useHumanInTheLoop,
} from "./hooks/use-human-in-the-loop";
} from "./v1-deprecated/hooks/use-human-in-the-loop";
export {
/**
@@ -605,7 +605,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
useLangGraphInterrupt,
} from "./hooks/use-langgraph-interrupt";
} from "./v1-deprecated/hooks/use-langgraph-interrupt";
export {
/**
@@ -618,7 +618,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
useLazyToolRenderer,
} from "./hooks/use-lazy-tool-renderer";
} from "./v1-deprecated/hooks/use-lazy-tool-renderer";
export {
/**
@@ -631,7 +631,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
useMakeCopilotDocumentReadable,
} from "./hooks/use-make-copilot-document-readable";
} from "./v1-deprecated/hooks/use-make-copilot-document-readable";
export {
/**
@@ -656,7 +656,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
useRenderToolCall,
} from "./hooks/use-render-tool-call";
} from "./v1-deprecated/hooks/use-render-tool-call";
export {
/**
@@ -679,7 +679,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
type TreeNode,
} from "./hooks/use-tree";
} from "./v1-deprecated/hooks/use-tree";
export {
/**
@@ -702,7 +702,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
type CopilotTaskConfig,
} from "./lib/copilot-task";
} from "./v1-deprecated/lib/copilot-task";
export {
/**
@@ -715,7 +715,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
type CopilotChatSuggestionConfiguration,
} from "./types/chat-suggestion-configuration";
} from "./v1-deprecated/types/chat-suggestion-configuration";
export {
/**
@@ -772,7 +772,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
type CrewsToolStateItem,
} from "./types/crew";
} from "./v1-deprecated/types/crew";
export {
/**
@@ -785,7 +785,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
type DocumentPointer,
} from "./types/document-pointer";
} from "./v1-deprecated/types/document-pointer";
export {
/**
@@ -878,7 +878,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
type RenderFunctionStatus,
} from "./types/frontend-action";
} from "./v1-deprecated/types/frontend-action";
export {
/**
@@ -951,7 +951,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
type QueuedInterruptEvent,
} from "./types/interrupt-action";
} from "./v1-deprecated/types/interrupt-action";
export {
/**
@@ -963,7 +963,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
type SystemMessageFunction,
} from "./types/system-message";
} from "./v1-deprecated/types/system-message";
export {
/**
@@ -975,7 +975,7 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
shouldShowDevConsole,
} from "./utils/dev-console";
} from "./v1-deprecated/utils/dev-console";
export {
/**
@@ -988,6 +988,6 @@ export {
* Migration guide: https://docs.copilotkit.ai/migrate/v2
*/
SUGGESTION_RETRY_CONFIG,
} from "./utils/suggestions-constants";
} from "./v1-deprecated/utils/suggestions-constants";
/* END GENERATED V1 DEPRECATED EXPORTS. USE V2 INSTEAD. */
@@ -2,15 +2,15 @@ import React from "react";
import { render, act } from "@testing-library/react";
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
import type { AbstractAgent } from "@ag-ui/client";
import { useCopilotKit } from "../v2/context";
import { useAgent } from "../v2/hooks/use-agent";
import { CopilotChatConfigurationProvider } from "../v2/providers/CopilotChatConfigurationProvider";
import { useCopilotKit } from "../../v2/context";
import { useAgent } from "../../v2/hooks/use-agent";
import { CopilotChatConfigurationProvider } from "../../v2/providers/CopilotChatConfigurationProvider";
import {
CopilotKitCoreRuntimeConnectionStatus,
ProxiedCopilotRuntimeAgent,
} from "@copilotkit/core";
vi.mock("../v2/context", () => ({
vi.mock("../../v2/context", () => ({
useCopilotKit: vi.fn(),
}));
@@ -1,5 +1,5 @@
import { useCallback, useEffect, useMemo, useRef } from "react";
import { useAgent, useCopilotChatConfiguration, useCopilotKit } from "../v2";
import { useAgent, useCopilotChatConfiguration, useCopilotKit } from "../../v2";
import {
CopilotKitError,
DEFAULT_AGENT_ID,
@@ -2,7 +2,7 @@ import React from "react";
import { render, waitFor } from "@testing-library/react";
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
import { CopilotKit } from "../copilot-provider/copilotkit";
import { CopilotChat } from "../../v2/components/chat/CopilotChat";
import { CopilotChat } from "../../../v2/components/chat/CopilotChat";
/**
* Integration regression for issue #5533.
@@ -2,8 +2,8 @@ import React from "react";
import { describe, it, expect, vi, beforeEach } from "vitest";
import { render } from "@testing-library/react";
import { CopilotListeners } from "../CopilotListeners";
import { CopilotKitProvider } from "../../v2/providers/CopilotKitProvider";
import { CopilotChatConfigurationProvider } from "../../v2/providers/CopilotChatConfigurationProvider";
import { CopilotKitProvider } from "../../../v2/providers/CopilotKitProvider";
import { CopilotChatConfigurationProvider } from "../../../v2/providers/CopilotChatConfigurationProvider";
import { ToastProvider } from "../toast/toast-provider";
/**
@@ -1,7 +1,7 @@
import { renderHook } from "@testing-library/react";
import type React from "react";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { useCopilotKit } from "../../../v2";
import { useCopilotKit } from "../../../../v2";
import { CopilotKit } from "../copilotkit";
/**
@@ -3,7 +3,7 @@ import { render, screen, act } from "@testing-library/react";
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
import { CopilotKit } from "../copilotkit";
import { useCopilotContext } from "../../../context/copilot-context";
import { useCopilotChatConfiguration, useAgent } from "../../../v2";
import { useCopilotChatConfiguration, useAgent } from "../../../../v2";
import type { CopilotKitProps } from "../copilotkit-props";
import type { AbstractAgent } from "@ag-ui/client";
@@ -9,7 +9,7 @@
* V2 import and usage:
* import type { CopilotKitProps } from "@copilotkit/react-core/v2";
* type V2CopilotKitProps = CopilotKitProps;
* V2 replacement source: packages/react-core/src/components/copilot-provider/copilotkit-props.tsx
* V2 replacement source: packages/react-core/src/v1-deprecated/components/copilot-provider/copilotkit-props.tsx
* V2 docs: https://docs.copilotkit.ai/
* V2 reference docs: https://docs.copilotkit.ai/reference/v2
*
@@ -22,7 +22,7 @@ import type { ForwardedParametersInput } from "@copilotkit/runtime-client-gql";
import type { ReactNode } from "react";
import type { AuthState } from "../../context/copilot-context";
import type { CopilotErrorHandler, DebugConfig } from "@copilotkit/shared";
import type { CopilotKitProviderProps } from "../../v2";
import type { CopilotKitProviderProps } from "../../../v2";
/**
* Props for CopilotKit.
*/
@@ -9,7 +9,7 @@
* V2 import and usage:
* import { CopilotKit } from "@copilotkit/react-core/v2";
* <CopilotKit />;
* V2 replacement source: packages/react-core/src/components/copilot-provider/copilotkit.tsx
* V2 replacement source: packages/react-core/src/v1-deprecated/components/copilot-provider/copilotkit.tsx
* V2 docs: https://docs.copilotkit.ai/reference/v2/components/CopilotKit
*
* @copilotkit/react-core defaultCopilotContextCategories:
@@ -53,7 +53,7 @@ import {
CopilotKitInspector,
CopilotKitProvider as CopilotKitV2Provider,
useCopilotKit,
} from "../../v2";
} from "../../../v2";
import type {
CopilotApiConfig,
ChatComponentsCache,
@@ -20,7 +20,7 @@ const mockAgent = {
// Captured from the `useInterrupt` call `useLangGraphInterrupt` makes.
let interruptArgs: any = null;
vi.mock("../../v2", () => ({
vi.mock("../../../v2", () => ({
useAgent: vi.fn(() => ({ agent: mockAgent })),
useInterrupt: vi.fn((args: any) => {
interruptArgs = args;
@@ -29,7 +29,7 @@ const mockAgent = {
}),
};
vi.mock("../../v2", () => ({
vi.mock("../../../v2", () => ({
useAgent: vi.fn(() => ({ agent: mockAgent })),
useCopilotKit: vi.fn(() => ({
copilotkit: {
@@ -11,7 +11,7 @@ import {
} from "../../context";
import type { Claim } from "../use-coagent-state-render-bridge.helpers";
import { createTestCopilotContext } from "../../test-helpers/copilot-context";
import { useRenderCustomMessages } from "../../v2";
import { useRenderCustomMessages } from "../../../v2";
type TestMessage = {
id: string;
@@ -41,7 +41,7 @@ const mockAgent = {
let lastSubscriber: TestAgentSubscriber | null = null;
vi.mock("../../v2", () => ({
vi.mock("../../../v2", () => ({
useAgent: vi.fn(() => ({ agent: mockAgent })),
useCopilotKit: vi.fn(() => ({
copilotkit: {
@@ -11,9 +11,9 @@ import type {
import { EMPTY } from "rxjs";
import type { Observable } from "rxjs";
import { useCopilotAction } from "../use-copilot-action";
import { useCopilotKit } from "../../v2/providers/CopilotKitProvider";
import { CopilotChatToolCallsView } from "../../v2/components/chat/CopilotChatToolCallsView";
import { CopilotKitProvider } from "../../v2/providers/CopilotKitProvider";
import { useCopilotKit } from "../../../v2/providers/CopilotKitProvider";
import { CopilotChatToolCallsView } from "../../../v2/components/chat/CopilotChatToolCallsView";
import { CopilotKitProvider } from "../../../v2/providers/CopilotKitProvider";
import type { AssistantMessage } from "@ag-ui/core";
const toolCallMessage: AssistantMessage = {
@@ -4,7 +4,11 @@ import { renderHook, act } from "@testing-library/react";
import { useCopilotChatInternal } from "../use-copilot-chat_internal";
import { CoAgentStateRendersProvider, CopilotContext } from "../../context";
import { createTestCopilotContext } from "../../test-helpers/copilot-context";
import { useAgent, useCopilotKit, useCopilotChatConfiguration } from "../../v2";
import {
useAgent,
useCopilotKit,
useCopilotChatConfiguration,
} from "../../../v2";
import { CopilotKitCoreRuntimeConnectionStatus } from "@copilotkit/core";
// ---------------------------------------------------------------------------
@@ -33,7 +37,7 @@ let mockConfigThreadId: string | undefined = "config-thread-id";
// ---------------------------------------------------------------------------
// Module mocks
// ---------------------------------------------------------------------------
vi.mock("../../v2", () => ({
vi.mock("../../../v2", () => ({
useAgent: vi.fn(() => ({ agent: mockAgent })),
useCopilotKit: vi.fn(() => ({
copilotkit: {
@@ -38,7 +38,7 @@ function createFakeCopilotKit() {
let fake: ReturnType<typeof createFakeCopilotKit>;
vi.mock("../../v2", () => ({
vi.mock("../../../v2", () => ({
useCopilotKit: () => ({ copilotkit: fake }),
}));
@@ -6,7 +6,7 @@ import { useFrontendTool } from "../use-frontend-tool";
// Track what gets passed to the v2 hook
let lastV2ToolCall: any = null;
vi.mock("../../v2", () => ({
vi.mock("../../../v2", () => ({
useFrontendTool: vi.fn((tool: any) => {
lastV2ToolCall = tool;
}),
@@ -3,9 +3,9 @@ import React, { useEffect } from "react";
import { render, waitFor } from "@testing-library/react";
import { ToolCallStatus } from "@copilotkit/core";
import { useFrontendTool } from "../use-frontend-tool";
import * as copilotKitV2React from "../../v2";
import * as copilotKitV2React from "../../../v2";
vi.mock("../../v2", () => {
vi.mock("../../../v2", () => {
let currentRender: any = null;
const listeners = new Set<() => void>();
@@ -1,6 +1,6 @@
import { useEffect, useState } from "react";
import type { AgentSubscriber } from "@ag-ui/client";
import { useAgent } from "../v2";
import { useAgent } from "../../v2";
/**
* Tracks the node the agent is currently executing.
@@ -1,4 +1,4 @@
import { ReactCustomMessageRendererPosition, useAgent } from "../v2";
import { ReactCustomMessageRendererPosition, useAgent } from "../../v2";
import { useCallback, useEffect, useMemo, useState } from "react";
import type { AgentSubscriber } from "@ag-ui/client";
import { useCoAgentStateRenders } from "../context";
@@ -118,7 +118,7 @@
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import type { Message } from "@copilotkit/shared";
import { useAgent, useCopilotKit } from "../v2";
import { useAgent, useCopilotKit } from "../../v2";
import type { AgentSubscriber } from "@ag-ui/client";
import { useAgentNodeName } from "./use-agent-nodename";
@@ -3,7 +3,7 @@ import {
useCopilotChatConfiguration,
useCopilotKit,
useSuggestions,
} from "../v2";
} from "../../v2";
import { StaticSuggestionsConfig, Suggestion } from "@copilotkit/core";
import { useCopilotContext } from "../context";
import { useEffect, useMemo } from "react";
@@ -97,7 +97,7 @@ import {
useCopilotChatConfiguration,
useCopilotKit,
useSuggestions,
} from "../v2";
} from "../../v2";
import { useEffect } from "react";
import type { StaticSuggestionsConfig, Suggestion } from "@copilotkit/core";
@@ -68,9 +68,9 @@ import React, {
createElement,
} from "react";
import { useCopilotContext } from "../context/copilot-context";
import type { SystemMessageFunction } from "../types";
import { SystemMessageFunction } from "../types";
import { useAsyncCallback } from "../components/error-boundary/error-utils";
import type { Message } from "@copilotkit/shared";
import { Message } from "@copilotkit/shared";
import {
gqlToAGUI,
Message as DeprecatedGqlMessage,
@@ -81,14 +81,21 @@ import {
useCopilotKit,
useRenderCustomMessages,
useSuggestions,
} from "../v2";
import type { Suggestion } from "@copilotkit/core";
import { CopilotKitCoreRuntimeConnectionStatus } from "@copilotkit/core";
} from "../../v2";
import {
Suggestion,
CopilotKitCoreRuntimeConnectionStatus,
} from "@copilotkit/core";
import { useLazyToolRenderer } from "./use-lazy-tool-renderer";
import type { AbstractAgent } from "@ag-ui/client";
import { AGUIConnectNotImplementedError, HttpAgent } from "@ag-ui/client";
import { CoAgentStateRenderBridge } from "./use-coagent-state-render-bridge";
import type { CoAgentStateRenderBridgeProps } from "./use-coagent-state-render-bridge";
import {
AbstractAgent,
AGUIConnectNotImplementedError,
HttpAgent,
} from "@ag-ui/client";
import {
CoAgentStateRenderBridge,
type CoAgentStateRenderBridgeProps,
} from "./use-coagent-state-render-bridge";
/**
* The type of suggestions to use in the chat.
@@ -93,7 +93,7 @@
* );
* ```
*/
import { useCopilotKit } from "../v2";
import { useCopilotKit } from "../../v2";
import { useEffect, useRef } from "react";
/**
@@ -40,7 +40,7 @@ import { ToolCallStatus } from "@copilotkit/core";
import {
type ReactFrontendTool,
useFrontendTool as useFrontendToolVNext,
} from "../v2";
} from "../../v2";
type FrontendToolOptions<T extends Parameter[] | []> = ReactFrontendTool<
MappedParameterTypes<T>
@@ -43,7 +43,7 @@ import {
getZodParameters,
parseJson,
} from "@copilotkit/shared";
import { useHumanInTheLoop as useHumanInTheLoopVNext } from "../v2";
import { useHumanInTheLoop as useHumanInTheLoopVNext } from "../../v2";
import { ToolCallStatus } from "@copilotkit/core";
import React, {
ComponentType,
@@ -28,12 +28,12 @@
import React, { useCallback, useRef } from "react";
import { LangGraphInterruptRender } from "../types/interrupt-action";
import { useInterrupt, useCopilotChatConfiguration } from "../v2";
import { useInterrupt, useCopilotChatConfiguration } from "../../v2";
import type {
InterruptEvent,
InterruptRenderProps,
InterruptHandlerProps,
} from "../v2";
} from "../../v2";
import { MetaEventName } from "@copilotkit/runtime-client-gql";
import { parseJson } from "@copilotkit/shared";
import { useAgentNodeName } from "./use-agent-nodename";
@@ -17,8 +17,8 @@
* END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE
*/
import { useRenderToolCall } from "../v2";
import type { AIMessage, Message, ToolResult } from "@copilotkit/shared";
import { useRenderToolCall } from "../../v2";
import { AIMessage, Message, ToolResult } from "@copilotkit/shared";
import React, { useCallback } from "react";
export function useLazyToolRenderer(): (
@@ -33,7 +33,7 @@
import { getZodParameters } from "@copilotkit/shared";
import type { Parameter } from "@copilotkit/shared";
import { parseJson } from "@copilotkit/shared";
import { defineToolCallRenderer, useCopilotKit } from "../v2";
import { defineToolCallRenderer, useCopilotKit } from "../../v2";
import type React from "react";
import { useEffect, useRef } from "react";
import { ActionRenderPropsWait } from "../types";
@@ -0,0 +1,9 @@
/*
* V1 SDK DEPRECATED. USE V2 INSTEAD.
*
* Internal source boundary for the unpublished, deprecated v1 implementation.
* Consumers must use `@copilotkit/react-core/v2`; neither `/v1` nor
* `/v1-deprecated` is a public package export.
*/
export * from "../v1-deprecated-compatibility";
@@ -37,7 +37,7 @@ export class StatusChecker {
this.lastResponse = response;
onUpdate?.(response);
return response;
} catch (error) {
} catch {
// Silently fail
return null;
}
@@ -12,7 +12,7 @@ import { CopilotKitProvider } from "../../../providers/CopilotKitProvider";
// CopilotListeners.defaultAgentAbsent.test.tsx / v1-explicit-threadid-bridge.test.tsx
// and used by Showcase). It defaults to negotiated (`"auto"`) transport, so the
// single-endpoint suite below pins `useSingleEndpoint` explicitly.
import { CopilotKit } from "../../../../components/copilot-provider/copilotkit";
import { CopilotKit } from "../../../../v1-deprecated/components/copilot-provider/copilotkit";
import { useCopilotKit } from "../../../context";
import { CopilotChat } from "../CopilotChat";
import {
@@ -3,7 +3,7 @@ import { render, screen } from "@testing-library/react";
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
import { CopilotKitProvider } from "../../providers/CopilotKitProvider";
import { useAgent } from "../use-agent";
import { stubWindowLocation } from "../../../test-helpers/stub-window-location";
import { stubWindowLocation } from "../../../v1-deprecated/test-helpers/stub-window-location";
describe("useAgent error state", () => {
const originalFetch = global.fetch;
+2 -2
View File
@@ -25,5 +25,5 @@ export type { Theme as A2UITheme } from "@copilotkit/a2ui-renderer";
export { defaultTheme as a2uiDefaultTheme } from "@copilotkit/a2ui-renderer";
// V1 backward-compat re-exports
export { CopilotKit } from "../components/copilot-provider/copilotkit";
export type { CopilotKitProps } from "../components/copilot-provider/copilotkit-props";
export { CopilotKit } from "../v1-deprecated/components/copilot-provider/copilotkit";
export type { CopilotKitProps } from "../v1-deprecated/components/copilot-provider/copilotkit-props";

Some files were not shown because too many files have changed in this diff Show More