@ai-sdk/harness-pi 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-pi
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,52 @@
1
+ # AI SDK - Pi Harness
2
+
3
+ `HarnessV1` adapter backed by [`@earendil-works/pi-coding-agent`](https://www.npmjs.com/package/@earendil-works/pi-coding-agent). Pi runs in the host Node.js process and uses the sandbox as a remote filesystem + shell — no bridge process is installed inside the sandbox.
4
+
5
+ ## Setup
6
+
7
+ ```bash
8
+ npm i @ai-sdk/harness-pi @ai-sdk/harness @ai-sdk/sandbox-vercel @earendil-works/pi-coding-agent
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { HarnessAgent } from '@ai-sdk/harness/agent';
15
+ import { createPi } from '@ai-sdk/harness-pi';
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: createPi({ thinkingLevel: '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`. Pi has no in-sandbox bridge, so the sandbox doesn't need to expose any ports — `@ai-sdk/sandbox-vercel` or `@ai-sdk/sandbox-just-bash` both work.
@@ -0,0 +1,122 @@
1
+ import * as _ai_sdk_harness from '@ai-sdk/harness';
2
+ import { HarnessV1, HarnessV1BuiltinTool } from '@ai-sdk/harness';
3
+
4
+ /**
5
+ * Pi auth options. Exactly one of `gateway` or `customEnv` is honoured
6
+ * (precedence: explicit `customEnv`, then explicit `gateway`, then ambient
7
+ * gateway from `process.env`). To use multiple providers, use `customEnv`
8
+ * with the standard `<PREFIX>_API_KEY` / `<PREFIX>_BASE_URL` pattern.
9
+ */
10
+ type PiAuthOptions = {
11
+ readonly gateway?: {
12
+ readonly apiKey?: string;
13
+ readonly baseUrl?: string;
14
+ };
15
+ /**
16
+ * Resolved environment-variable pairs of the form `<PREFIX>_API_KEY` and
17
+ * (optionally) `<PREFIX>_BASE_URL`. Special-cased prefixes:
18
+ * - `AI_GATEWAY` → registers `vercel-ai-gateway`
19
+ * - `OPENAI` → registers `openai`
20
+ * - `ANTHROPIC` → registers `anthropic` (`ANTHROPIC_AUTH_TOKEN` adds a
21
+ * bearer auth header)
22
+ * Any other `<PREFIX>_API_KEY` with a matching `<PREFIX>_BASE_URL` is
23
+ * registered as the lowercased, dash-separated prefix.
24
+ */
25
+ readonly customEnv?: Record<string, string>;
26
+ };
27
+
28
+ type PiThinkingLevel = 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
29
+
30
+ /**
31
+ * Configuration knobs for `createPi`. Pi runs as an in-process Node library
32
+ * (no bridge), so there's no `port` or `startupTimeoutMs` to set.
33
+ */
34
+ type PiHarnessSettings = {
35
+ /** Where Pi sources API keys / gateway credentials from. */
36
+ readonly auth?: PiAuthOptions;
37
+ /**
38
+ * Pi model id (or name). Leaving this unset falls back to the AI Gateway
39
+ * default when `AI_GATEWAY_API_KEY` / `VERCEL_OIDC_TOKEN` is set, and to
40
+ * Pi's own resolution otherwise.
41
+ */
42
+ readonly model?: string;
43
+ /**
44
+ * Pi's extended-thinking budget level. Maps directly to the SDK's
45
+ * `thinkingLevel` option on `createAgentSession`.
46
+ */
47
+ readonly thinkingLevel?: PiThinkingLevel;
48
+ };
49
+ declare const PI_BUILTIN_TOOLS: {
50
+ readonly read: HarnessV1BuiltinTool<{
51
+ file_path: string;
52
+ }, unknown>;
53
+ readonly write: HarnessV1BuiltinTool<{
54
+ file_path: string;
55
+ content: string;
56
+ }, unknown>;
57
+ readonly edit: HarnessV1BuiltinTool<{
58
+ file_path: string;
59
+ old_string: string;
60
+ new_string: string;
61
+ }, unknown>;
62
+ readonly bash: HarnessV1BuiltinTool<{
63
+ command: string;
64
+ timeout?: number | undefined;
65
+ }, unknown>;
66
+ readonly grep: HarnessV1BuiltinTool<{
67
+ pattern: string;
68
+ glob?: string | undefined;
69
+ path?: string | undefined;
70
+ ignoreCase?: boolean | undefined;
71
+ literal?: boolean | undefined;
72
+ context?: number | undefined;
73
+ limit?: number | undefined;
74
+ }, unknown>;
75
+ readonly glob: HarnessV1BuiltinTool<{
76
+ pattern: string;
77
+ path?: string | undefined;
78
+ limit?: number | undefined;
79
+ }, unknown>;
80
+ readonly ls: HarnessV1BuiltinTool;
81
+ };
82
+ declare function createPi(settings?: PiHarnessSettings): HarnessV1<typeof PI_BUILTIN_TOOLS>;
83
+
84
+ /**
85
+ * Default `pi` harness instance with no overrides — suitable for the common
86
+ * case where Pi's defaults are fine. Equivalent to `createPi()`.
87
+ */
88
+ declare const pi: _ai_sdk_harness.HarnessV1<{
89
+ readonly read: _ai_sdk_harness.HarnessV1BuiltinTool<{
90
+ file_path: string;
91
+ }, unknown>;
92
+ readonly write: _ai_sdk_harness.HarnessV1BuiltinTool<{
93
+ file_path: string;
94
+ content: string;
95
+ }, unknown>;
96
+ readonly edit: _ai_sdk_harness.HarnessV1BuiltinTool<{
97
+ file_path: string;
98
+ old_string: string;
99
+ new_string: string;
100
+ }, unknown>;
101
+ readonly bash: _ai_sdk_harness.HarnessV1BuiltinTool<{
102
+ command: string;
103
+ timeout?: number | undefined;
104
+ }, unknown>;
105
+ readonly grep: _ai_sdk_harness.HarnessV1BuiltinTool<{
106
+ pattern: string;
107
+ glob?: string | undefined;
108
+ path?: string | undefined;
109
+ ignoreCase?: boolean | undefined;
110
+ literal?: boolean | undefined;
111
+ context?: number | undefined;
112
+ limit?: number | undefined;
113
+ }, unknown>;
114
+ readonly glob: _ai_sdk_harness.HarnessV1BuiltinTool<{
115
+ pattern: string;
116
+ path?: string | undefined;
117
+ limit?: number | undefined;
118
+ }, unknown>;
119
+ readonly ls: _ai_sdk_harness.HarnessV1BuiltinTool;
120
+ }>;
121
+
122
+ export { type PiAuthOptions, type PiHarnessSettings, createPi, pi };