@agent-harness-experimental/adapter-pi 0.0.0 → 0.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/LICENSE +1 -0
- package/README.md +101 -2
- package/dist/adapter.d.ts +18 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +143 -0
- package/dist/adapter.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/model-resolver.d.mts +31 -0
- package/dist/model-resolver.d.mts.map +1 -0
- package/dist/model-resolver.mjs +42 -0
- package/dist/model-resolver.mjs.map +1 -0
- package/dist/model-resolver.mts +76 -0
- package/dist/prepare-step-extension.d.ts +31 -0
- package/dist/prepare-step-extension.d.ts.map +1 -0
- package/dist/prepare-step-extension.js +48 -0
- package/dist/prepare-step-extension.js.map +1 -0
- package/dist/remote-ops.d.ts +40 -0
- package/dist/remote-ops.d.ts.map +1 -0
- package/dist/remote-ops.js +217 -0
- package/dist/remote-ops.js.map +1 -0
- package/dist/setup.d.ts +6 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +56 -0
- package/dist/setup.js.map +1 -0
- package/dist/shared.d.ts +7 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +41 -0
- package/dist/shared.js.map +1 -0
- package/dist/split-runtime-support.d.ts +92 -0
- package/dist/split-runtime-support.d.ts.map +1 -0
- package/dist/split-runtime-support.js +429 -0
- package/dist/split-runtime-support.js.map +1 -0
- package/dist/split-runtime.d.ts +63 -0
- package/dist/split-runtime.d.ts.map +1 -0
- package/dist/split-runtime.js +894 -0
- package/dist/split-runtime.js.map +1 -0
- package/dist/workspace-mirror.d.ts +8 -0
- package/dist/workspace-mirror.d.ts.map +1 -0
- package/dist/workspace-mirror.js +150 -0
- package/dist/workspace-mirror.js.map +1 -0
- package/dist/workspace-vfs.d.ts +8 -0
- package/dist/workspace-vfs.d.ts.map +1 -0
- package/dist/workspace-vfs.js +300 -0
- package/dist/workspace-vfs.js.map +1 -0
- package/package.json +59 -3
package/LICENSE
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Copyright Vercel Inc. Pre-release. Not licensed as OSS yet.
|
package/README.md
CHANGED
|
@@ -1,3 +1,102 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@agent-harness-experimental/adapter-pi`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Adapter for running the host-side [pi.dev](https://pi.dev) coding agent with
|
|
4
|
+
`agent-harness-experimental`.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install agent-harness-experimental @agent-harness-experimental/adapter-pi
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { createAgentSession } from "agent-harness-experimental";
|
|
16
|
+
import { piDev } from "@agent-harness-experimental/adapter-pi";
|
|
17
|
+
|
|
18
|
+
const agent = createAgentSession({
|
|
19
|
+
adapter: piDev(),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const result = await agent.generate("Write unit tests for the auth module");
|
|
23
|
+
console.log(result.text);
|
|
24
|
+
await agent.close("stop");
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Configuration
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
piDev({
|
|
31
|
+
// Model ID
|
|
32
|
+
model: "claude-sonnet-4",
|
|
33
|
+
|
|
34
|
+
// Thinking/reasoning level
|
|
35
|
+
thinkingLevel: "extended",
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
| Option | Type | Default | Description |
|
|
40
|
+
| --- | --- | --- | --- |
|
|
41
|
+
| `model` | `string` | — | Model ID |
|
|
42
|
+
| `thinkingLevel` | `string` | — | Thinking/reasoning level |
|
|
43
|
+
| `auth` | `object` | — | Optional per-adapter auth override (`gateway` or `customEnv`) |
|
|
44
|
+
|
|
45
|
+
Sandbox runtime options such as `template`, `timeoutMs`, and `httpHandler`
|
|
46
|
+
belong on `createAgentSession({ sandbox })`.
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
const agent = createAgentSession({
|
|
50
|
+
adapter: piDev({ model: "claude-sonnet-4", thinkingLevel: "extended" }),
|
|
51
|
+
sandbox: {
|
|
52
|
+
template: "snap_abc123",
|
|
53
|
+
timeoutMs: 60000,
|
|
54
|
+
httpHandler: async (request: Request) => fetch(request),
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Auth
|
|
60
|
+
|
|
61
|
+
`auth` is optional. If you omit it, pi.dev keeps the existing gateway fallback.
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
piDev({
|
|
65
|
+
model: "claude-sonnet-4",
|
|
66
|
+
auth: {
|
|
67
|
+
customEnv: {
|
|
68
|
+
env: {
|
|
69
|
+
OPENAI_API_KEY: { env: "OPENAI_TEAM_B_API_KEY" },
|
|
70
|
+
OPENAI_BASE_URL: "https://team-b.example.invalid/v1",
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Pi runs on the host and keeps model credentials outside the sandbox, so both
|
|
78
|
+
`auth.gateway` and `auth.customEnv` are supported.
|
|
79
|
+
|
|
80
|
+
## Built-in Tools
|
|
81
|
+
|
|
82
|
+
Pi exposes standardized builtin names through `agent-harness-experimental`.
|
|
83
|
+
|
|
84
|
+
| Tool | Native Tool | Description |
|
|
85
|
+
| --- | --- | --- |
|
|
86
|
+
| `read` | `read` | Read file contents |
|
|
87
|
+
| `write` | `write` | Write content to file |
|
|
88
|
+
| `edit` | `edit` | Edit file (find and replace) |
|
|
89
|
+
| `bash` | `bash` | Execute shell command |
|
|
90
|
+
| `grep` | `grep` | Search file contents |
|
|
91
|
+
| `find` | `find` | Find files matching a glob pattern |
|
|
92
|
+
| `ls` | `ls` | List directory contents |
|
|
93
|
+
|
|
94
|
+
## Features
|
|
95
|
+
|
|
96
|
+
- **Tool interception**: Built-in tools can be intercepted for approval via the
|
|
97
|
+
`permissions` option on `createAgentSession`
|
|
98
|
+
- **Host-side runtime**: Pi runs on the host with sandbox-backed file and shell execution
|
|
99
|
+
- **Durable resume**: Pi persists session state through workflow export/import
|
|
100
|
+
- **Skills**: Written to `.pi/skills/{name}/SKILL.md` with YAML frontmatter
|
|
101
|
+
- **Subagents**: Written to `.pi/agents/{name}.md` with model and tool metadata
|
|
102
|
+
- **Token-level streaming**: Real-time text deltas
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AgentAdapter, CustomEnvAuthOptions, GatewayAuthOptions } from 'agent-harness-experimental';
|
|
2
|
+
import { type SplitPiAdapterState } from './split-runtime-support.js';
|
|
3
|
+
export declare const PI_BUILTIN_TOOLS: {
|
|
4
|
+
name: string;
|
|
5
|
+
inputSchema: import("agent-harness-experimental").JsonSchema;
|
|
6
|
+
nativeName?: string | undefined;
|
|
7
|
+
description?: string | undefined;
|
|
8
|
+
}[], PI_PERMISSION_TOOL_CATEGORIES: import("agent-harness-experimental").PermissionToolCategories;
|
|
9
|
+
export interface PiAdapterOptions {
|
|
10
|
+
model?: string;
|
|
11
|
+
thinkingLevel?: string;
|
|
12
|
+
auth?: {
|
|
13
|
+
gateway?: GatewayAuthOptions;
|
|
14
|
+
customEnv?: CustomEnvAuthOptions;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export declare function piDev(options?: PiAdapterOptions): AgentAdapter<SplitPiAdapterState | undefined>;
|
|
18
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAkB,oBAAoB,EAAE,kBAAkB,EAAc,MAAM,4BAA4B,CAAC;AAIrI,OAAO,EAA6B,KAAK,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGjG,eAAO,MAAe,gBAAgB;;;;;KAA4B,6BAA6B,+DAiD7F,CAAC;AAEH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,kBAAkB,CAAC;QAC7B,SAAS,CAAC,EAAE,oBAAoB,CAAC;KAClC,CAAC;CACH;AAsGD,wBAAgB,KAAK,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,YAAY,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAE/F"}
|
package/dist/adapter.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { defineAdapterBuiltinTools, normalizeAdapterError, selectConfiguredAuthBag } from 'agent-harness-experimental';
|
|
2
|
+
import { getSandboxImageName, withVercelSandboxBackend } from '@agent-harness-experimental/sandbox-vercel';
|
|
3
|
+
import { getPiSandboxSetup, PI_DEFAULT_CONTEXT_WINDOW } from './setup.js';
|
|
4
|
+
import { splitPiAdapterStateSchema } from './split-runtime-support.js';
|
|
5
|
+
export const { tools: PI_BUILTIN_TOOLS, permissionToolCategories: PI_PERMISSION_TOOL_CATEGORIES } = defineAdapterBuiltinTools([
|
|
6
|
+
'read',
|
|
7
|
+
'write',
|
|
8
|
+
{
|
|
9
|
+
name: 'edit',
|
|
10
|
+
description: 'Edit a file by replacing a string',
|
|
11
|
+
},
|
|
12
|
+
'bash',
|
|
13
|
+
{
|
|
14
|
+
name: 'grep',
|
|
15
|
+
description: 'Search file contents',
|
|
16
|
+
inputSchema: {
|
|
17
|
+
type: 'object',
|
|
18
|
+
properties: {
|
|
19
|
+
pattern: { type: 'string' },
|
|
20
|
+
path: { type: 'string' },
|
|
21
|
+
glob: { type: 'string' },
|
|
22
|
+
ignoreCase: { type: 'boolean' },
|
|
23
|
+
literal: { type: 'boolean' },
|
|
24
|
+
context: { type: 'number' },
|
|
25
|
+
limit: { type: 'number' },
|
|
26
|
+
},
|
|
27
|
+
required: ['pattern'],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'find',
|
|
32
|
+
description: 'Find files matching a glob pattern',
|
|
33
|
+
inputSchema: {
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: {
|
|
36
|
+
pattern: { type: 'string' },
|
|
37
|
+
path: { type: 'string' },
|
|
38
|
+
limit: { type: 'number' },
|
|
39
|
+
},
|
|
40
|
+
required: ['pattern'],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'ls',
|
|
45
|
+
description: 'List directory contents',
|
|
46
|
+
inputSchema: {
|
|
47
|
+
type: 'object',
|
|
48
|
+
properties: {
|
|
49
|
+
path: { type: 'string' },
|
|
50
|
+
limit: { type: 'number' },
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
]);
|
|
55
|
+
function resolvePiErrorProvider(options) {
|
|
56
|
+
if (typeof options?.model === 'string' && options.model.includes('/')) {
|
|
57
|
+
const [provider] = options.model.split('/');
|
|
58
|
+
return provider;
|
|
59
|
+
}
|
|
60
|
+
if (selectConfiguredAuthBag(options?.auth, ['customEnv', 'gateway']) === 'gateway') {
|
|
61
|
+
return 'ai-gateway';
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
function createPiAdapter(options) {
|
|
66
|
+
let runtime = null;
|
|
67
|
+
let runtimeLoad = null;
|
|
68
|
+
let pendingState;
|
|
69
|
+
const sandboxSetup = getPiSandboxSetup();
|
|
70
|
+
const sandboxImageName = getSandboxImageName('pi', sandboxSetup);
|
|
71
|
+
const getRuntime = async () => {
|
|
72
|
+
if (runtime) {
|
|
73
|
+
return runtime;
|
|
74
|
+
}
|
|
75
|
+
runtimeLoad ??= import('./split-runtime.js').then(({ SplitPiRuntime }) => {
|
|
76
|
+
const loadedRuntime = new SplitPiRuntime(options, sandboxImageName);
|
|
77
|
+
if (pendingState !== undefined) {
|
|
78
|
+
loadedRuntime.importState(pendingState);
|
|
79
|
+
pendingState = undefined;
|
|
80
|
+
}
|
|
81
|
+
runtime = loadedRuntime;
|
|
82
|
+
return loadedRuntime;
|
|
83
|
+
});
|
|
84
|
+
runtime = await runtimeLoad;
|
|
85
|
+
return runtime;
|
|
86
|
+
};
|
|
87
|
+
return {
|
|
88
|
+
name: 'pi',
|
|
89
|
+
supportsToolInterception: true,
|
|
90
|
+
supportsHostAccessRequests: true,
|
|
91
|
+
prepareStepSupport: 'continuation',
|
|
92
|
+
adapterStateSchema: splitPiAdapterStateSchema.optional(),
|
|
93
|
+
normalizeError(error) {
|
|
94
|
+
return normalizeAdapterError(error, {
|
|
95
|
+
adapter: 'pi',
|
|
96
|
+
provider: resolvePiErrorProvider(options),
|
|
97
|
+
model: options?.model,
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
builtinTools: PI_BUILTIN_TOOLS,
|
|
101
|
+
defaultContextWindow: PI_DEFAULT_CONTEXT_WINDOW,
|
|
102
|
+
permissionToolCategories: PI_PERMISSION_TOOL_CATEGORIES,
|
|
103
|
+
getBridgeFiles: () => sandboxSetup.getBridgeFiles(),
|
|
104
|
+
getSandboxFiles: (ctx) => sandboxSetup.getSandboxFiles(ctx),
|
|
105
|
+
resolveSandboxConfig: (sandboxConfig) => withVercelSandboxBackend(sandboxConfig),
|
|
106
|
+
exportAdapterState() {
|
|
107
|
+
return runtime?.exportState() ?? pendingState;
|
|
108
|
+
},
|
|
109
|
+
importAdapterState(state) {
|
|
110
|
+
pendingState = state;
|
|
111
|
+
runtime?.importState(state);
|
|
112
|
+
},
|
|
113
|
+
async start(ctx) {
|
|
114
|
+
await (await getRuntime()).start(ctx);
|
|
115
|
+
},
|
|
116
|
+
async prompt(message, ctx) {
|
|
117
|
+
await (await getRuntime()).prompt(message, ctx);
|
|
118
|
+
},
|
|
119
|
+
async registerTools(tools, ctx) {
|
|
120
|
+
ctx.registeredTools = tools;
|
|
121
|
+
},
|
|
122
|
+
async stop() {
|
|
123
|
+
if (!runtime) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
await runtime.stop();
|
|
127
|
+
runtime = null;
|
|
128
|
+
runtimeLoad = null;
|
|
129
|
+
},
|
|
130
|
+
async detach() {
|
|
131
|
+
if (!runtime) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
await runtime.detach();
|
|
135
|
+
runtime = null;
|
|
136
|
+
runtimeLoad = null;
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
export function piDev(options) {
|
|
141
|
+
return createPiAdapter(options);
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACvH,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAC;AAC3G,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,yBAAyB,EAA4B,MAAM,4BAA4B,CAAC;AAGjG,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,GAAG,yBAAyB,CAAC;IAC5H,MAAM;IACN,OAAO;IACP;QACE,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,mCAAmC;KACjD;IACD,MAAM;IACN;QACE,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,sBAAsB;QACnC,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV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AAC;QAED,KAAK,CAAC,MAAM;YACV,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO;YACT,CAAC;YAED,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC;YACvB,OAAO,GAAG,IAAI,CAAC;YACf,WAAW,GAAG,IAAI,CAAC;QACrB,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,OAA0B;IAC9C,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { PI_BUILTIN_TOOLS, PI_PERMISSION_TOOL_CATEGORIES, piDev } from './adapter.js';
|
|
2
|
+
export type { PiAdapterOptions } from './adapter.js';
|
|
3
|
+
export { PI_DEFAULT_CONTEXT_WINDOW, PI_SANDBOX_SETUP, PI_SUPPORT_MATRIX_ROW, getPiSandboxSetup, } from './setup.js';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,6BAA6B,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACtF,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,6BAA6B,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAEtF,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
type PiBridgeConfig = {
|
|
2
|
+
workDir?: string;
|
|
3
|
+
model?: string;
|
|
4
|
+
thinkingLevel?: string;
|
|
5
|
+
agents?: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
type PiModel = {
|
|
8
|
+
id?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
api?: string;
|
|
11
|
+
provider?: string;
|
|
12
|
+
baseUrl?: string;
|
|
13
|
+
reasoning?: boolean;
|
|
14
|
+
input?: string[];
|
|
15
|
+
cost?: {
|
|
16
|
+
input: number;
|
|
17
|
+
output: number;
|
|
18
|
+
cacheRead: number;
|
|
19
|
+
cacheWrite: number;
|
|
20
|
+
};
|
|
21
|
+
contextWindow?: number;
|
|
22
|
+
maxTokens?: number;
|
|
23
|
+
};
|
|
24
|
+
type PiModelRegistry = {
|
|
25
|
+
getModels?(): PiModel[];
|
|
26
|
+
getAll?(): PiModel[];
|
|
27
|
+
};
|
|
28
|
+
export declare const DEFAULT_PI_GATEWAY_MODEL: PiModel;
|
|
29
|
+
export declare function createPiModelResolver(modelRegistry: PiModelRegistry, env?: NodeJS.ProcessEnv): (config: PiBridgeConfig, override?: string) => PiModel | undefined;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=model-resolver.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-resolver.d.mts","sourceRoot":"","sources":["../src/model-resolver.mts"],"names":[],"mappings":"AAAA,KAAK,cAAc,GAAG;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,CAAC,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,SAAS,CAAC,IAAI,OAAO,EAAE,CAAC;IACxB,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,OAWtC,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,eAAe,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,IAgBhG,QAAQ,cAAc,EAAE,WAAW,MAAM,KAAG,OAAO,GAAG,SAAS,CAgBxE"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export const DEFAULT_PI_GATEWAY_MODEL = {
|
|
2
|
+
id: 'anthropic/claude-sonnet-4',
|
|
3
|
+
name: 'Claude Sonnet 4 (Gateway)',
|
|
4
|
+
api: 'anthropic-messages',
|
|
5
|
+
provider: 'vercel-ai-gateway',
|
|
6
|
+
baseUrl: 'https://ai-gateway.vercel.sh',
|
|
7
|
+
reasoning: true,
|
|
8
|
+
input: ['text', 'image'],
|
|
9
|
+
cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 },
|
|
10
|
+
contextWindow: 200000,
|
|
11
|
+
maxTokens: 16384,
|
|
12
|
+
};
|
|
13
|
+
export function createPiModelResolver(modelRegistry, env = process.env) {
|
|
14
|
+
let cachedModels;
|
|
15
|
+
const loadModels = () => {
|
|
16
|
+
if (cachedModels) {
|
|
17
|
+
return cachedModels;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
cachedModels = modelRegistry.getModels?.() ?? modelRegistry.getAll?.() ?? [];
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
cachedModels = [];
|
|
24
|
+
}
|
|
25
|
+
return cachedModels;
|
|
26
|
+
};
|
|
27
|
+
return (config, override) => {
|
|
28
|
+
const modelId = override ?? config.model;
|
|
29
|
+
let model;
|
|
30
|
+
if (modelId) {
|
|
31
|
+
model = loadModels().find((candidate) => candidate.id === modelId || candidate.name === modelId);
|
|
32
|
+
}
|
|
33
|
+
if (!model && !modelId && env.AI_GATEWAY_API_KEY) {
|
|
34
|
+
return {
|
|
35
|
+
...DEFAULT_PI_GATEWAY_MODEL,
|
|
36
|
+
...(env.AI_GATEWAY_BASE_URL ? { baseUrl: env.AI_GATEWAY_BASE_URL } : {}),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return model;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=model-resolver.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-resolver.mjs","sourceRoot":"","sources":["../src/model-resolver.mts"],"names":[],"mappings":"AA8BA,MAAM,CAAC,MAAM,wBAAwB,GAAY;IAC/C,EAAE,EAAE,2BAA2B;IAC/B,IAAI,EAAE,2BAA2B;IACjC,GAAG,EAAE,oBAAoB;IACzB,QAAQ,EAAE,mBAAmB;IAC7B,OAAO,EAAE,8BAA8B;IACvC,SAAS,EAAE,IAAI;IACf,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;IACxB,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE;IAChE,aAAa,EAAE,MAAM;IACrB,SAAS,EAAE,KAAK;CAC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+
agents?: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
type PiModel = {
|
|
9
|
+
id?: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
api?: string;
|
|
12
|
+
provider?: string;
|
|
13
|
+
baseUrl?: string;
|
|
14
|
+
reasoning?: boolean;
|
|
15
|
+
input?: string[];
|
|
16
|
+
cost?: {
|
|
17
|
+
input: number;
|
|
18
|
+
output: number;
|
|
19
|
+
cacheRead: number;
|
|
20
|
+
cacheWrite: number;
|
|
21
|
+
};
|
|
22
|
+
contextWindow?: number;
|
|
23
|
+
maxTokens?: number;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type PiModelRegistry = {
|
|
27
|
+
getModels?(): PiModel[];
|
|
28
|
+
getAll?(): PiModel[];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const DEFAULT_PI_GATEWAY_MODEL: PiModel = {
|
|
32
|
+
id: 'anthropic/claude-sonnet-4',
|
|
33
|
+
name: 'Claude Sonnet 4 (Gateway)',
|
|
34
|
+
api: 'anthropic-messages',
|
|
35
|
+
provider: 'vercel-ai-gateway',
|
|
36
|
+
baseUrl: 'https://ai-gateway.vercel.sh',
|
|
37
|
+
reasoning: true,
|
|
38
|
+
input: ['text', 'image'],
|
|
39
|
+
cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 },
|
|
40
|
+
contextWindow: 200000,
|
|
41
|
+
maxTokens: 16384,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export function createPiModelResolver(modelRegistry: PiModelRegistry, env: NodeJS.ProcessEnv = process.env) {
|
|
45
|
+
let cachedModels: PiModel[] | undefined;
|
|
46
|
+
|
|
47
|
+
const loadModels = (): PiModel[] => {
|
|
48
|
+
if (cachedModels) {
|
|
49
|
+
return cachedModels;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
cachedModels = modelRegistry.getModels?.() ?? modelRegistry.getAll?.() ?? [];
|
|
54
|
+
} catch {
|
|
55
|
+
cachedModels = [];
|
|
56
|
+
}
|
|
57
|
+
return cachedModels;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return (config: PiBridgeConfig, override?: string): PiModel | undefined => {
|
|
61
|
+
const modelId = override ?? config.model;
|
|
62
|
+
let model: PiModel | undefined;
|
|
63
|
+
if (modelId) {
|
|
64
|
+
model = loadModels().find((candidate) => candidate.id === modelId || candidate.name === modelId);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (!model && !modelId && env.AI_GATEWAY_API_KEY) {
|
|
68
|
+
return {
|
|
69
|
+
...DEFAULT_PI_GATEWAY_MODEL,
|
|
70
|
+
...(env.AI_GATEWAY_BASE_URL ? { baseUrl: env.AI_GATEWAY_BASE_URL } : {}),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return model;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { AdapterContext, BridgePrepareStepConfig } from 'agent-harness-experimental';
|
|
2
|
+
import type { ExtensionFactory } from '@mariozechner/pi-coding-agent';
|
|
3
|
+
/**
|
|
4
|
+
* Host-side bridge for per-step prepareStep on Pi.
|
|
5
|
+
*
|
|
6
|
+
* `SplitPiRuntime` owns one of these. The extension reads the current
|
|
7
|
+
* `AdapterContext` via `getCtx()` and stores the latest resolved step config.
|
|
8
|
+
*
|
|
9
|
+
* We separate the bridge object from the factory so the extension can be
|
|
10
|
+
* loaded once per session while the adapter context rotates per prompt.
|
|
11
|
+
*/
|
|
12
|
+
interface PrepareStepBridge {
|
|
13
|
+
getCtx: () => AdapterContext | null;
|
|
14
|
+
getInstructionsAppend: () => string | undefined;
|
|
15
|
+
setResolved: (config: BridgePrepareStepConfig) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function createPrepareStepBridge(): PrepareStepBridge & {
|
|
18
|
+
setCtx: (ctx: AdapterContext | null) => void;
|
|
19
|
+
setInitialConfig: (config: BridgePrepareStepConfig) => void;
|
|
20
|
+
getResolved: () => BridgePrepareStepConfig | undefined;
|
|
21
|
+
reset: () => void;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Build a Pi extension factory that wires `ctx.resolvePrepareStep` into Pi's
|
|
25
|
+
* per-turn lifecycle. `before_agent_start` handles the initial step resolved
|
|
26
|
+
* by the host; `turn_start` re-resolves inside the prompt loop; the resolved
|
|
27
|
+
* config shapes the outgoing system prompt and the active tool set.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createPrepareStepExtension(bridge: PrepareStepBridge): ExtensionFactory;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=prepare-step-extension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare-step-extension.d.ts","sourceRoot":"","sources":["../src/prepare-step-extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAC1F,OAAO,KAAK,EAAgB,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEpF;;;;;;;;GAQG;AACH,UAAU,iBAAiB;IACzB,MAAM,EAAE,MAAM,cAAc,GAAG,IAAI,CAAC;IACpC,qBAAqB,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IAChD,WAAW,EAAE,CAAC,MAAM,EAAE,uBAAuB,KAAK,IAAI,CAAC;CACxD;AAED,wBAAgB,uBAAuB,IAAI,iBAAiB,GAAG;IAC7D,MAAM,EAAE,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,KAAK,IAAI,CAAC;IAC7C,gBAAgB,EAAE,CAAC,MAAM,EAAE,uBAAuB,KAAK,IAAI,CAAC;IAC5D,WAAW,EAAE,MAAM,uBAAuB,GAAG,SAAS,CAAC;IACvD,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAwBA;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,iBAAiB,GAAG,gBAAgB,CAetF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export function createPrepareStepBridge() {
|
|
2
|
+
let ctx = null;
|
|
3
|
+
let initial;
|
|
4
|
+
let resolved;
|
|
5
|
+
return {
|
|
6
|
+
getCtx: () => ctx,
|
|
7
|
+
getInstructionsAppend: () => resolved?.instructions ?? initial?.instructions,
|
|
8
|
+
setResolved: (config) => {
|
|
9
|
+
resolved = config;
|
|
10
|
+
},
|
|
11
|
+
setCtx: (next) => {
|
|
12
|
+
ctx = next;
|
|
13
|
+
},
|
|
14
|
+
setInitialConfig: (config) => {
|
|
15
|
+
initial = config;
|
|
16
|
+
resolved = undefined;
|
|
17
|
+
},
|
|
18
|
+
getResolved: () => resolved,
|
|
19
|
+
reset: () => {
|
|
20
|
+
initial = undefined;
|
|
21
|
+
resolved = undefined;
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Build a Pi extension factory that wires `ctx.resolvePrepareStep` into Pi's
|
|
27
|
+
* per-turn lifecycle. `before_agent_start` handles the initial step resolved
|
|
28
|
+
* by the host; `turn_start` re-resolves inside the prompt loop; the resolved
|
|
29
|
+
* config shapes the outgoing system prompt and the active tool set.
|
|
30
|
+
*/
|
|
31
|
+
export function createPrepareStepExtension(bridge) {
|
|
32
|
+
return (pi) => {
|
|
33
|
+
pi.on('before_agent_start', async (event) => {
|
|
34
|
+
const append = bridge.getInstructionsAppend();
|
|
35
|
+
if (!append)
|
|
36
|
+
return undefined;
|
|
37
|
+
return { systemPrompt: `${event.systemPrompt}\n\n${append}` };
|
|
38
|
+
});
|
|
39
|
+
pi.on('turn_start', async (event) => {
|
|
40
|
+
const ctx = bridge.getCtx();
|
|
41
|
+
if (!ctx?.resolvePrepareStep)
|
|
42
|
+
return;
|
|
43
|
+
const resolved = await ctx.resolvePrepareStep(event.turnIndex);
|
|
44
|
+
bridge.setResolved(resolved);
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=prepare-step-extension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare-step-extension.js","sourceRoot":"","sources":["../src/prepare-step-extension.ts"],"names":[],"mappings":"AAkBA,MAAM,UAAU,uBAAuB;IAMrC,IAAI,GAAG,GAA0B,IAAI,CAAC;IACtC,IAAI,OAA4C,CAAC;IACjD,IAAI,QAA6C,CAAC;IAElD,OAAO;QACL,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG;QACjB,qBAAqB,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,YAAY,IAAI,OAAO,EAAE,YAAY;QAC5E,WAAW,EAAE,CAAC,MAAM,EAAE,EAAE;YACtB,QAAQ,GAAG,MAAM,CAAC;QACpB,CAAC;QACD,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YACf,GAAG,GAAG,IAAI,CAAC;QACb,CAAC;QACD,gBAAgB,EAAE,CAAC,MAAM,EAAE,EAAE;YAC3B,OAAO,GAAG,MAAM,CAAC;YACjB,QAAQ,GAAG,SAAS,CAAC;QACvB,CAAC;QACD,WAAW,EAAE,GAAG,EAAE,CAAC,QAAQ;QAC3B,KAAK,EAAE,GAAG,EAAE;YACV,OAAO,GAAG,SAAS,CAAC;YACpB,QAAQ,GAAG,SAAS,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CAAC,MAAyB;IAClE,OAAO,CAAC,EAAgB,EAAE,EAAE;QAC1B,EAAE,CAAC,EAAE,CAAC,oBAAoB,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;YAC1C,MAAM,MAAM,GAAG,MAAM,CAAC,qBAAqB,EAAE,CAAC;YAC9C,IAAI,CAAC,MAAM;gBAAE,OAAO,SAAS,CAAC;YAC9B,OAAO,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC,YAAY,OAAO,MAAM,EAAE,EAAE,CAAC;QAChE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,EAAE,CAAC,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;YAClC,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;YAC5B,IAAI,CAAC,GAAG,EAAE,kBAAkB;gBAAE,OAAO;YACrC,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,kBAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YAC/D,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { SandboxWorkspace } from 'agent-harness-experimental';
|
|
2
|
+
interface SplitPathMapper {
|
|
3
|
+
localWorkDir: string;
|
|
4
|
+
remoteWorkDir: string;
|
|
5
|
+
toRemotePath(inputPath: string): string;
|
|
6
|
+
toRelativePath(inputPath: string): string;
|
|
7
|
+
}
|
|
8
|
+
interface RemoteOpsOptions {
|
|
9
|
+
sandbox: SandboxWorkspace;
|
|
10
|
+
paths: SplitPathMapper;
|
|
11
|
+
env?: Record<string, string>;
|
|
12
|
+
onFileChange?: (event: 'create' | 'modify', relativePath: string, content: Buffer) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare function createSplitPathMapper(localWorkDir: string, remoteWorkDir: string): SplitPathMapper;
|
|
15
|
+
export declare function createRemoteOperations(options: RemoteOpsOptions): {
|
|
16
|
+
paths: SplitPathMapper;
|
|
17
|
+
readBuffer: (inputPath: string) => Promise<Buffer>;
|
|
18
|
+
writeFile: (inputPath: string, content: string) => Promise<void>;
|
|
19
|
+
editFile: (inputPath: string, oldText: string, newText: string) => Promise<string>;
|
|
20
|
+
listDirectory: (inputPath?: string, limit?: number) => Promise<string[]>;
|
|
21
|
+
findFiles: (pattern: string, inputPath?: string, limit?: number) => Promise<string[]>;
|
|
22
|
+
grepFiles: (pattern: string, input: {
|
|
23
|
+
path?: string;
|
|
24
|
+
glob?: string;
|
|
25
|
+
ignoreCase?: boolean;
|
|
26
|
+
literal?: boolean;
|
|
27
|
+
context?: number;
|
|
28
|
+
limit?: number;
|
|
29
|
+
}) => Promise<string>;
|
|
30
|
+
access(inputPath: string): Promise<void>;
|
|
31
|
+
exec(command: string, cwd: string, input: {
|
|
32
|
+
onData: (data: Buffer) => void;
|
|
33
|
+
signal?: AbortSignal;
|
|
34
|
+
timeout?: number;
|
|
35
|
+
}): Promise<{
|
|
36
|
+
exitCode: number | null;
|
|
37
|
+
}>;
|
|
38
|
+
};
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=remote-ops.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-ops.d.ts","sourceRoot":"","sources":["../src/remote-ops.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAInE,UAAU,eAAe;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IACxC,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3C;AAED,UAAU,gBAAgB;IACxB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,KAAK,EAAE,eAAe,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,GAAG,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5F;AA4BD,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,eAAe,CAmClG;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,gBAAgB;;4BA4BzB,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