@cline/agents 0.0.38 → 0.0.39

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cline/agents",
3
- "version": "0.0.38",
3
+ "version": "0.0.39",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/cline/sdk",
@@ -8,22 +8,20 @@
8
8
  },
9
9
  "main": "dist/index.js",
10
10
  "dependencies": {
11
- "@cline/llms": "workspace:*",
12
- "@cline/shared": "workspace:*",
11
+ "@cline/llms": "0.0.39",
12
+ "@cline/shared": "0.0.39",
13
13
  "nanoid": "^5.1.7"
14
14
  },
15
15
  "exports": {
16
16
  ".": {
17
17
  "browser": "./dist/index.js",
18
- "development": "./src/index.ts",
19
18
  "types": "./dist/index.d.ts",
20
19
  "import": "./dist/index.js"
21
20
  }
22
21
  },
23
22
  "description": "Browser-safe agent runtime for the next-generation Cline SDK",
24
23
  "files": [
25
- "dist",
26
- "src"
24
+ "dist"
27
25
  ],
28
26
  "keywords": [
29
27
  "llm",
@@ -1,198 +0,0 @@
1
- import type {
2
- AgentMessage,
3
- AgentModel,
4
- AgentModelEvent,
5
- AgentModelRequest,
6
- AgentRuntimeEvent,
7
- } from "@cline/shared";
8
- import { beforeEach, describe, expect, it, vi } from "vitest";
9
- import { AgentRuntime } from "./agent-runtime";
10
- import { Agent, createAgent } from "./index";
11
-
12
- const { createAgentModel, createGateway } = vi.hoisted(() => {
13
- const createAgentModel = vi.fn();
14
- const createGateway = vi.fn(() => ({
15
- createAgentModel,
16
- }));
17
- return { createAgentModel, createGateway };
18
- });
19
-
20
- vi.mock("@cline/llms", () => ({
21
- createGateway,
22
- }));
23
-
24
- class ScriptedModel implements AgentModel {
25
- constructor(
26
- private readonly steps: Array<
27
- (
28
- request: AgentModelRequest,
29
- ) => Iterable<AgentModelEvent> | AsyncIterable<AgentModelEvent>
30
- >,
31
- ) {}
32
-
33
- async stream(
34
- request: AgentModelRequest,
35
- ): Promise<AsyncIterable<AgentModelEvent>> {
36
- const step = this.steps.shift();
37
- if (!step) {
38
- throw new Error("No scripted model step available");
39
- }
40
- return toAsyncIterable(step(request));
41
- }
42
- }
43
-
44
- async function* toAsyncIterable(
45
- events: Iterable<AgentModelEvent> | AsyncIterable<AgentModelEvent>,
46
- ): AsyncIterable<AgentModelEvent> {
47
- for await (const event of events) {
48
- yield event;
49
- }
50
- }
51
-
52
- describe("AgentRuntime (provider-form config + Agent alias)", () => {
53
- beforeEach(() => {
54
- createGateway.mockClear();
55
- createAgentModel.mockReset();
56
- });
57
-
58
- it("constructs the runtime via the llms gateway in ESM-safe code", () => {
59
- const model = new ScriptedModel([]);
60
- createAgentModel.mockReturnValue(model);
61
-
62
- const agent = new Agent({
63
- providerId: "openai",
64
- modelId: "gpt-5",
65
- apiKey: "test-key",
66
- });
67
-
68
- expect(agent).toBeInstanceOf(Agent);
69
- expect(createGateway).toHaveBeenCalledWith({
70
- providerConfigs: [
71
- {
72
- providerId: "openai",
73
- apiKey: "test-key",
74
- baseUrl: undefined,
75
- headers: undefined,
76
- },
77
- ],
78
- });
79
- expect(createAgentModel).toHaveBeenCalledWith({
80
- providerId: "openai",
81
- modelId: "gpt-5",
82
- });
83
- });
84
-
85
- it("forwards abort() to the active AgentRuntime", async () => {
86
- const model = new ScriptedModel([
87
- async function* (request) {
88
- yield { type: "text-delta", text: "partial" };
89
- await new Promise<void>((resolve) => {
90
- request.signal?.addEventListener("abort", () => resolve(), {
91
- once: true,
92
- });
93
- });
94
- yield { type: "finish", reason: "aborted" };
95
- },
96
- ]);
97
- createAgentModel.mockReturnValue(model);
98
-
99
- const agent = new Agent({
100
- providerId: "openai",
101
- modelId: "gpt-5",
102
- });
103
-
104
- const runPromise = agent.run("cancel me");
105
- for (let i = 0; i < 20; i += 1) {
106
- if (agent.snapshot().status === "running") {
107
- break;
108
- }
109
- await new Promise((resolve) => setTimeout(resolve, 0));
110
- }
111
- agent.abort("user cancelled");
112
-
113
- await expect(runPromise).resolves.toMatchObject({
114
- status: "aborted",
115
- });
116
- });
117
-
118
- it("createAgent() and new Agent() both return an AgentRuntime instance", () => {
119
- const model = new ScriptedModel([]);
120
- createAgentModel.mockReturnValue(model);
121
-
122
- const agent = createAgent({
123
- providerId: "anthropic",
124
- modelId: "claude-sonnet-4-6",
125
- });
126
-
127
- // After the facade/runtime merge (Option B), `Agent` is an alias for
128
- // `AgentRuntime`. Both constructors return the same class — verified
129
- // here so future refactors don't silently reintroduce a split.
130
- expect(agent).toBeInstanceOf(Agent);
131
- expect(agent).toBeInstanceOf(AgentRuntime);
132
- expect(Agent).toBe(AgentRuntime);
133
- });
134
-
135
- it("restores conversation state by rebuilding the runtime", () => {
136
- const model = new ScriptedModel([]);
137
- createAgentModel.mockReturnValue(model);
138
-
139
- const agent = new Agent({
140
- providerId: "openai",
141
- modelId: "gpt-5",
142
- });
143
- const messages: AgentMessage[] = [
144
- {
145
- id: "msg_1",
146
- role: "user",
147
- content: [{ type: "text", text: "hello" }],
148
- createdAt: 1,
149
- },
150
- ];
151
-
152
- agent.restore(messages);
153
-
154
- expect(agent.snapshot().messages).toEqual(messages);
155
- expect(agent.snapshot().status).toBe("idle");
156
- });
157
-
158
- it("rebinds existing subscribers when restore() replaces the runtime", async () => {
159
- const model = new ScriptedModel([
160
- () => [
161
- { type: "text-delta", text: "hello" },
162
- { type: "finish", reason: "stop" },
163
- ],
164
- () => [
165
- { type: "text-delta", text: "again" },
166
- { type: "finish", reason: "stop" },
167
- ],
168
- ]);
169
- createAgentModel.mockReturnValue(model);
170
-
171
- const agent = new Agent({
172
- providerId: "openai",
173
- modelId: "gpt-5",
174
- });
175
- const received: AgentRuntimeEvent["type"][] = [];
176
- const unsubscribe = agent.subscribe((event) => {
177
- received.push(event.type);
178
- });
179
-
180
- agent.restore([
181
- {
182
- id: "msg_1",
183
- role: "user",
184
- content: [{ type: "text", text: "restored" }],
185
- createdAt: 1,
186
- },
187
- ]);
188
- await agent.run("hello");
189
-
190
- expect(received).toContain("run-started");
191
- expect(received).toContain("run-finished");
192
-
193
- const countAfterRun = received.length;
194
- unsubscribe();
195
- await agent.run("again");
196
- expect(received).toHaveLength(countAfterRun);
197
- });
198
- });