@copilotkitnext/agent 1.52.2-next.1 → 1.52.2-next.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @copilotkitnext/agent
2
2
 
3
+ ## 1.52.2-next.2
4
+
3
5
  ## 1.52.2-next.1
4
6
 
5
7
  ## 1.52.2-next.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copilotkitnext/agent",
3
- "version": "1.52.2-next.1",
3
+ "version": "1.52.2-next.2",
4
4
  "description": "Basic Agent for CopilotKit",
5
5
  "main": "./dist/index.cjs",
6
6
  "types": "./dist/index.d.cts",
@@ -22,17 +22,17 @@
22
22
  "tsdown": "^0.20.3",
23
23
  "typescript": "5.8.2",
24
24
  "vitest": "^3.0.5",
25
- "@copilotkitnext/eslint-config": "1.52.2-next.1",
26
- "@copilotkitnext/typescript-config": "1.52.2-next.1"
25
+ "@copilotkitnext/eslint-config": "1.52.2-next.2",
26
+ "@copilotkitnext/typescript-config": "1.52.2-next.2"
27
27
  },
28
28
  "dependencies": {
29
29
  "@ag-ui/client": "0.0.46",
30
- "@ai-sdk/anthropic": "^2.0.22",
31
- "@ai-sdk/google": "^2.0.17",
32
- "@ai-sdk/mcp": "^0.0.8",
33
- "@ai-sdk/openai": "^2.0.42",
30
+ "@ai-sdk/anthropic": "^3.0.49",
31
+ "@ai-sdk/google": "^3.0.33",
32
+ "@ai-sdk/mcp": "^1.0.21",
33
+ "@ai-sdk/openai": "^3.0.36",
34
34
  "@modelcontextprotocol/sdk": "^1.18.2",
35
- "ai": "^5.0.92",
35
+ "ai": "^6.0.104",
36
36
  "rxjs": "7.8.1",
37
37
  "zod": "^3.25.75"
38
38
  },
@@ -0,0 +1,116 @@
1
+ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
2
+ import { BuiltInAgent } from "../index";
3
+ import { EventType, type RunAgentInput } from "@ag-ui/client";
4
+ import { streamText } from "ai";
5
+ import {
6
+ mockStreamTextResponse,
7
+ textDelta,
8
+ finish,
9
+ collectEvents,
10
+ } from "./test-helpers";
11
+
12
+ // Mock the ai module
13
+ vi.mock("ai", () => ({
14
+ streamText: vi.fn(),
15
+ tool: vi.fn((config) => config),
16
+ stepCountIs: vi.fn((count: number) => ({ type: "stepCount", count })),
17
+ }));
18
+
19
+ // Mock SDK providers (not used directly, but resolveModel imports them)
20
+ vi.mock("@ai-sdk/openai", () => ({
21
+ createOpenAI: vi.fn(() => (modelId: string) => ({
22
+ specificationVersion: "v3",
23
+ modelId,
24
+ provider: "openai",
25
+ })),
26
+ }));
27
+
28
+ vi.mock("@ai-sdk/anthropic", () => ({
29
+ createAnthropic: vi.fn(() => (modelId: string) => ({
30
+ specificationVersion: "v3",
31
+ modelId,
32
+ provider: "anthropic",
33
+ })),
34
+ }));
35
+
36
+ vi.mock("@ai-sdk/google", () => ({
37
+ createGoogleGenerativeAI: vi.fn(() => (modelId: string) => ({
38
+ specificationVersion: "v3",
39
+ modelId,
40
+ provider: "google",
41
+ })),
42
+ }));
43
+
44
+ describe("AI SDK v6 Compatibility", () => {
45
+ const originalEnv = process.env;
46
+
47
+ beforeEach(() => {
48
+ vi.clearAllMocks();
49
+ process.env = { ...originalEnv };
50
+ process.env.OPENAI_API_KEY = "test-key";
51
+ });
52
+
53
+ afterEach(() => {
54
+ process.env = originalEnv;
55
+ });
56
+
57
+ it("should accept a LanguageModelV3 instance (specificationVersion 'v3')", async () => {
58
+ // Simulate what @ai-sdk/openai@^3 (AI SDK v6) returns:
59
+ // a model object with specificationVersion: "v3"
60
+ const v3Model = {
61
+ specificationVersion: "v3" as const,
62
+ modelId: "gpt-4o-mini",
63
+ provider: "openai",
64
+ supportedUrls: {},
65
+ doGenerate: vi.fn(),
66
+ doStream: vi.fn(),
67
+ };
68
+
69
+ // After upgrading to ai@^6, LanguageModel = string | LanguageModelV2 | LanguageModelV3.
70
+ // No 'as any' cast needed — the type accepts V3 models natively.
71
+ const agent = new BuiltInAgent({
72
+ model: v3Model,
73
+ });
74
+
75
+ vi.mocked(streamText).mockReturnValue(
76
+ mockStreamTextResponse([
77
+ textDelta("Hello from V3 model"),
78
+ finish(),
79
+ ]) as any,
80
+ );
81
+
82
+ const input: RunAgentInput = {
83
+ threadId: "thread-v3",
84
+ runId: "run-v3",
85
+ messages: [{ id: "1", role: "user", content: "Hi" }],
86
+ tools: [],
87
+ context: [],
88
+ state: {},
89
+ };
90
+
91
+ const events = await collectEvents(agent["run"](input));
92
+
93
+ // Verify the model was passed through to streamText
94
+ const callArgs = vi.mocked(streamText).mock.calls[0][0];
95
+ expect(callArgs.model).toBe(v3Model);
96
+
97
+ // Verify normal event emission still works
98
+ expect(events[0]).toMatchObject({
99
+ type: EventType.RUN_STARTED,
100
+ threadId: "thread-v3",
101
+ runId: "run-v3",
102
+ });
103
+
104
+ const textEvents = events.filter(
105
+ (e: any) => e.type === EventType.TEXT_MESSAGE_CHUNK,
106
+ );
107
+ expect(textEvents).toHaveLength(1);
108
+ expect(textEvents[0]).toMatchObject({
109
+ delta: "Hello from V3 model",
110
+ });
111
+
112
+ expect(events[events.length - 1]).toMatchObject({
113
+ type: EventType.RUN_FINISHED,
114
+ });
115
+ });
116
+ });