@ai-sdk/harness-claude-code 0.0.0 → 1.0.0-canary.0

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 ADDED
@@ -0,0 +1,12 @@
1
+ # @ai-sdk/harness-claude-code
2
+
3
+ ## 1.0.0-canary.0
4
+
5
+ ### Major Changes
6
+
7
+ - 3d9a50c: feat(harness): implement harness adapters for Claude Code, Codex, Pi
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [3d9a50c]
12
+ - @ai-sdk/harness@1.0.0-canary.4
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 ADDED
@@ -0,0 +1,62 @@
1
+ # AI SDK - Claude Code Harness
2
+
3
+ `HarnessV1` adapter backed by [`@anthropic-ai/claude-agent-sdk`](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk), which drives the `claude` CLI. The adapter ships a bridge process that runs inside a sandbox and talks to the host over a WebSocket on a sandbox-proxied loopback port.
4
+
5
+ ## Setup
6
+
7
+ ```bash
8
+ npm i @ai-sdk/harness-claude-code @ai-sdk/harness @ai-sdk/sandbox-vercel
9
+ ```
10
+
11
+ The bridge installs `@anthropic-ai/claude-agent-sdk` and `@anthropic-ai/claude-code` inside the sandbox the first time the session starts.
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import { HarnessAgent } from '@ai-sdk/harness/agent';
17
+ import { createClaudeCode } from '@ai-sdk/harness-claude-code';
18
+ import { createVercelSandbox } from '@ai-sdk/sandbox-vercel';
19
+ import { tool } from 'ai';
20
+ import { z } from 'zod/v4';
21
+
22
+ const agent = new HarnessAgent({
23
+ harness: createClaudeCode({
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
+ }),
32
+ id: 'demo',
33
+ sandbox: createVercelSandbox({
34
+ runtime: 'node24',
35
+ ports: [4000],
36
+ }),
37
+ tools: {
38
+ deploy: tool({
39
+ description: 'Deploy a service.',
40
+ inputSchema: z.object({ env: z.enum(['staging', 'production']) }),
41
+ execute: async ({ env }) => ({ url: `https://${env}.example.com` }),
42
+ }),
43
+ },
44
+ harnessOptions: {
45
+ 'claude-code': { thinking: 'adaptive' },
46
+ },
47
+ });
48
+
49
+ const session = await agent.createSession();
50
+
51
+ try {
52
+ const result = await agent.generate({
53
+ session,
54
+ prompt: 'Read README.md and summarise the goals.',
55
+ });
56
+ console.log(result.text);
57
+ } finally {
58
+ await session.destroy();
59
+ }
60
+ ```
61
+
62
+ The adapter requires a `HarnessV1SandboxProvider` whose handles expose at least one port — `@ai-sdk/sandbox-vercel` is the supported choice today. The agent calls `provider.createSession()` when a session starts. Use `session.detach()` to park the bridge and sandbox, `session.stop()` to save state and stop the sandbox, or `session.destroy()` to clean up without keeping resume state.