@ai-sdk/harness-cline 0.0.0 → 1.0.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/CHANGELOG.md +23 -0
- package/LICENSE +13 -0
- package/README.md +56 -3
- package/dist/index.d.ts +127 -0
- package/dist/index.js +1655 -0
- package/dist/index.js.map +1 -0
- package/package.json +63 -11
- package/src/cline-auth.ts +40 -0
- package/src/cline-harness.ts +197 -0
- package/src/cline-mcp.ts +153 -0
- package/src/cline-remote-ops.ts +243 -0
- package/src/cline-resume-state.ts +139 -0
- package/src/cline-session.ts +915 -0
- package/src/cline-skills.ts +59 -0
- package/src/cline-tools.ts +381 -0
- package/src/cline-translate.ts +261 -0
- package/src/cline-utils.ts +151 -0
- package/src/index.ts +13 -0
- package/src/version.ts +6 -0
- package/index.js +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# @ai-sdk/harness-cline
|
|
2
|
+
|
|
3
|
+
## 1.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 62a9c2a: feat(harness): add support for structured output to `HarnessAgent` via `output` property
|
|
8
|
+
- Updated dependencies [62a9c2a]
|
|
9
|
+
- Updated dependencies [d25cae2]
|
|
10
|
+
- @ai-sdk/harness@1.0.73
|
|
11
|
+
|
|
12
|
+
## 1.0.0
|
|
13
|
+
|
|
14
|
+
### Major Changes
|
|
15
|
+
|
|
16
|
+
- 80b40aa: feat(harness-cline): implement Cline harness adapter
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [69bb613]
|
|
21
|
+
- Updated dependencies [52bc889]
|
|
22
|
+
- Updated dependencies [4cd4989]
|
|
23
|
+
- @ai-sdk/harness@1.0.72
|
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 Vercel, Inc.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
|
-
#
|
|
1
|
+
# AI SDK - Cline Harness
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`HarnessV1` adapter backed by [`@cline/agents`](https://www.npmjs.com/package/@cline/agents). Cline runs in the host Node.js process and uses the sandbox as a remote filesystem and shell, so no bridge process is installed inside the sandbox.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i @ai-sdk/harness-cline @ai-sdk/harness @ai-sdk/sandbox-vercel
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { HarnessAgent } from '@ai-sdk/harness/agent';
|
|
15
|
+
import { createCline } from '@ai-sdk/harness-cline';
|
|
16
|
+
import { createVercelSandbox } from '@ai-sdk/sandbox-vercel';
|
|
17
|
+
import { tool } from 'ai';
|
|
18
|
+
import { z } from 'zod/v4';
|
|
19
|
+
|
|
20
|
+
const agent = new HarnessAgent({
|
|
21
|
+
harness: createCline({ reasoningEffort: 'medium' }),
|
|
22
|
+
id: 'demo',
|
|
23
|
+
sandbox: createVercelSandbox({ runtime: 'node24' }),
|
|
24
|
+
skills: [
|
|
25
|
+
{
|
|
26
|
+
name: 'careful-refactors',
|
|
27
|
+
description: 'Make minimal diffs and keep tests green.',
|
|
28
|
+
content: 'Prefer changes that touch the fewest files possible.',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
tools: {
|
|
32
|
+
deploy: tool({
|
|
33
|
+
description: 'Deploy a service.',
|
|
34
|
+
inputSchema: z.object({ env: z.enum(['staging', 'production']) }),
|
|
35
|
+
execute: async ({ env }) => ({ url: `https://${env}.example.com` }),
|
|
36
|
+
}),
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const session = await agent.createSession();
|
|
41
|
+
try {
|
|
42
|
+
const result = await agent.generate({
|
|
43
|
+
session,
|
|
44
|
+
prompt: 'Read README.md and summarise the goals.',
|
|
45
|
+
});
|
|
46
|
+
console.log(result.text);
|
|
47
|
+
} finally {
|
|
48
|
+
await session.destroy();
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The adapter requires a `HarnessV1SandboxProvider`. Cline has no in-sandbox bridge, so the sandbox does not need to expose any ports. Its built-in tools operate on the session sandbox remotely from the host process.
|
|
53
|
+
|
|
54
|
+
## Authentication
|
|
55
|
+
|
|
56
|
+
The default `auto` authentication mode uses `AI_GATEWAY_API_KEY` or `VERCEL_OIDC_TOKEN` when available and otherwise falls back to `CLINE_API_KEY`. Use `createCline({ auth: 'ai-gateway' })` or `createCline({ auth: 'direct' })` to select a mode explicitly. `AI_GATEWAY_BASE_URL` and `CLINE_API_BASE_URL` configure their respective endpoints.
|
|
57
|
+
|
|
58
|
+
See the [Cline harness documentation](https://ai-sdk.dev/providers/ai-sdk-harnesses/cline) for model configuration, reasoning, tools, skills, MCP, and session lifecycle details.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import * as _ai_sdk_harness from '@ai-sdk/harness';
|
|
2
|
+
import { HarnessV1, HarnessV1BuiltinTool } from '@ai-sdk/harness';
|
|
3
|
+
|
|
4
|
+
type ClineAuthenticationMode = 'auto' | 'direct' | 'ai-gateway';
|
|
5
|
+
type ClineAuthOptions = ClineAuthenticationMode;
|
|
6
|
+
|
|
7
|
+
type ClineReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Configuration knobs for `createCline`. The Cline runtime
|
|
11
|
+
* (`@cline/agents`, part of the Cline SDK) runs as an in-process Node
|
|
12
|
+
* library — no bridge, so there is no `port` or `startupTimeoutMs` to set.
|
|
13
|
+
*/
|
|
14
|
+
type ClineHarnessSettings = {
|
|
15
|
+
/** Where Cline sources direct or AI Gateway credentials from. */
|
|
16
|
+
readonly auth?: ClineAuthOptions;
|
|
17
|
+
/**
|
|
18
|
+
* MCP server definitions keyed by server name. Each definition uses the
|
|
19
|
+
* underlying runtime's native MCP server configuration format.
|
|
20
|
+
*/
|
|
21
|
+
readonly mcpServers?: Record<string, unknown>;
|
|
22
|
+
/**
|
|
23
|
+
* Cline LLM provider id (e.g. `'anthropic'`, `'openai'`, `'gemini'`).
|
|
24
|
+
* When omitted, direct authentication uses the Cline backend.
|
|
25
|
+
*/
|
|
26
|
+
readonly providerId?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Model id for the configured provider. When omitted, Cline selects the
|
|
29
|
+
* provider's default model.
|
|
30
|
+
*/
|
|
31
|
+
readonly modelId?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Provider API key. When omitted, the Cline gateway falls back to the
|
|
34
|
+
* provider's environment variable (e.g. `ANTHROPIC_API_KEY`).
|
|
35
|
+
*/
|
|
36
|
+
readonly apiKey?: string;
|
|
37
|
+
/** Custom provider endpoint. */
|
|
38
|
+
readonly baseUrl?: string;
|
|
39
|
+
/** Extra headers sent to the provider. */
|
|
40
|
+
readonly headers?: Record<string, string>;
|
|
41
|
+
/**
|
|
42
|
+
* Reasoning effort for reasoning-capable models. Use `'none'` to disable
|
|
43
|
+
* reasoning. When omitted, the Cline SDK selects the reasoning behavior.
|
|
44
|
+
*/
|
|
45
|
+
readonly reasoningEffort?: ClineReasoningEffort;
|
|
46
|
+
/**
|
|
47
|
+
* Safety cap on agent-loop iterations per turn. Unbounded when omitted.
|
|
48
|
+
*/
|
|
49
|
+
readonly maxIterations?: number;
|
|
50
|
+
};
|
|
51
|
+
declare const CLINE_BUILTIN_TOOLS: {
|
|
52
|
+
readonly read: HarnessV1BuiltinTool<{
|
|
53
|
+
file_path: string;
|
|
54
|
+
}, unknown>;
|
|
55
|
+
readonly write: HarnessV1BuiltinTool<{
|
|
56
|
+
file_path: string;
|
|
57
|
+
content: string;
|
|
58
|
+
}, unknown>;
|
|
59
|
+
readonly edit: HarnessV1BuiltinTool<{
|
|
60
|
+
file_path: string;
|
|
61
|
+
old_string: string;
|
|
62
|
+
new_string: string;
|
|
63
|
+
}, unknown>;
|
|
64
|
+
readonly bash: HarnessV1BuiltinTool<{
|
|
65
|
+
command: string;
|
|
66
|
+
timeout?: number | undefined;
|
|
67
|
+
}, unknown>;
|
|
68
|
+
readonly grep: HarnessV1BuiltinTool<{
|
|
69
|
+
pattern: string;
|
|
70
|
+
path?: string | undefined;
|
|
71
|
+
glob?: string | undefined;
|
|
72
|
+
ignoreCase?: boolean | undefined;
|
|
73
|
+
literal?: boolean | undefined;
|
|
74
|
+
context?: number | undefined;
|
|
75
|
+
limit?: number | undefined;
|
|
76
|
+
}, unknown>;
|
|
77
|
+
readonly glob: HarnessV1BuiltinTool<{
|
|
78
|
+
pattern: string;
|
|
79
|
+
path?: string | undefined;
|
|
80
|
+
limit?: number | undefined;
|
|
81
|
+
}, unknown>;
|
|
82
|
+
readonly ls: HarnessV1BuiltinTool;
|
|
83
|
+
};
|
|
84
|
+
declare function createCline(settings?: ClineHarnessSettings): HarnessV1<typeof CLINE_BUILTIN_TOOLS>;
|
|
85
|
+
|
|
86
|
+
declare const VERSION: string;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Default `cline` harness instance with no overrides — suitable for the
|
|
90
|
+
* common case where the Cline SDK's defaults are fine. Equivalent to
|
|
91
|
+
* `createCline()`.
|
|
92
|
+
*/
|
|
93
|
+
declare const cline: _ai_sdk_harness.HarnessV1<{
|
|
94
|
+
readonly read: _ai_sdk_harness.HarnessV1BuiltinTool<{
|
|
95
|
+
file_path: string;
|
|
96
|
+
}, unknown>;
|
|
97
|
+
readonly write: _ai_sdk_harness.HarnessV1BuiltinTool<{
|
|
98
|
+
file_path: string;
|
|
99
|
+
content: string;
|
|
100
|
+
}, unknown>;
|
|
101
|
+
readonly edit: _ai_sdk_harness.HarnessV1BuiltinTool<{
|
|
102
|
+
file_path: string;
|
|
103
|
+
old_string: string;
|
|
104
|
+
new_string: string;
|
|
105
|
+
}, unknown>;
|
|
106
|
+
readonly bash: _ai_sdk_harness.HarnessV1BuiltinTool<{
|
|
107
|
+
command: string;
|
|
108
|
+
timeout?: number | undefined;
|
|
109
|
+
}, unknown>;
|
|
110
|
+
readonly grep: _ai_sdk_harness.HarnessV1BuiltinTool<{
|
|
111
|
+
pattern: string;
|
|
112
|
+
path?: string | undefined;
|
|
113
|
+
glob?: string | undefined;
|
|
114
|
+
ignoreCase?: boolean | undefined;
|
|
115
|
+
literal?: boolean | undefined;
|
|
116
|
+
context?: number | undefined;
|
|
117
|
+
limit?: number | undefined;
|
|
118
|
+
}, unknown>;
|
|
119
|
+
readonly glob: _ai_sdk_harness.HarnessV1BuiltinTool<{
|
|
120
|
+
pattern: string;
|
|
121
|
+
path?: string | undefined;
|
|
122
|
+
limit?: number | undefined;
|
|
123
|
+
}, unknown>;
|
|
124
|
+
readonly ls: _ai_sdk_harness.HarnessV1BuiltinTool;
|
|
125
|
+
}>;
|
|
126
|
+
|
|
127
|
+
export { type ClineAuthOptions, type ClineAuthenticationMode, type ClineHarnessSettings, VERSION, cline, createCline };
|