@vercel/agent-eval 2.4.1 → 2.6.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/dist/cli.js +27 -21
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/agents/claude-code/agent.d.ts.map +1 -1
- package/dist/lib/agents/claude-code/agent.js +5 -1
- package/dist/lib/agents/claude-code/agent.js.map +1 -1
- package/dist/lib/agents/codex/agent.d.ts.map +1 -1
- package/dist/lib/agents/codex/agent.js +5 -1
- package/dist/lib/agents/codex/agent.js.map +1 -1
- package/dist/lib/agents/cursor/agent.d.ts.map +1 -1
- package/dist/lib/agents/cursor/agent.js +5 -0
- package/dist/lib/agents/cursor/agent.js.map +1 -1
- package/dist/lib/agents/fx/agent.d.ts.map +1 -1
- package/dist/lib/agents/fx/agent.js +3 -0
- package/dist/lib/agents/fx/agent.js.map +1 -1
- package/dist/lib/agents/fx/run.mjs +26 -0
- package/dist/lib/agents/gemini/agent.d.ts.map +1 -1
- package/dist/lib/agents/gemini/agent.js +5 -1
- package/dist/lib/agents/gemini/agent.js.map +1 -1
- package/dist/lib/agents/index.d.ts +1 -0
- package/dist/lib/agents/index.d.ts.map +1 -1
- package/dist/lib/agents/index.js +4 -0
- package/dist/lib/agents/index.js.map +1 -1
- package/dist/lib/agents/opencode/agent.d.ts.map +1 -1
- package/dist/lib/agents/opencode/agent.js +6 -0
- package/dist/lib/agents/opencode/agent.js.map +1 -1
- package/dist/lib/agents/pi-coding-agent/agent.d.ts +61 -0
- package/dist/lib/agents/pi-coding-agent/agent.d.ts.map +1 -0
- package/dist/lib/agents/pi-coding-agent/agent.js +127 -0
- package/dist/lib/agents/pi-coding-agent/agent.js.map +1 -0
- package/dist/lib/agents/pi-coding-agent/run.mjs +278 -0
- package/dist/lib/agents/plugin/contract.d.ts +40 -0
- package/dist/lib/agents/plugin/contract.d.ts.map +1 -1
- package/dist/lib/agents/plugin/contract.js.map +1 -1
- package/dist/lib/agents/plugin/orchestrator.d.ts +19 -0
- package/dist/lib/agents/plugin/orchestrator.d.ts.map +1 -1
- package/dist/lib/agents/plugin/orchestrator.js +269 -53
- package/dist/lib/agents/plugin/orchestrator.js.map +1 -1
- package/dist/lib/agents/redact.d.ts +34 -3
- package/dist/lib/agents/redact.d.ts.map +1 -1
- package/dist/lib/agents/redact.js +148 -35
- package/dist/lib/agents/redact.js.map +1 -1
- package/dist/lib/agents/shared.d.ts +24 -1
- package/dist/lib/agents/shared.d.ts.map +1 -1
- package/dist/lib/agents/shared.js +48 -13
- package/dist/lib/agents/shared.js.map +1 -1
- package/dist/lib/agents/types.d.ts +24 -1
- package/dist/lib/agents/types.d.ts.map +1 -1
- package/dist/lib/agents/verifier.d.ts +96 -0
- package/dist/lib/agents/verifier.d.ts.map +1 -0
- package/dist/lib/agents/verifier.js +176 -0
- package/dist/lib/agents/verifier.js.map +1 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +24 -0
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/dashboard.d.ts +3 -1
- package/dist/lib/dashboard.d.ts.map +1 -1
- package/dist/lib/dashboard.js +12 -1
- package/dist/lib/dashboard.js.map +1 -1
- package/dist/lib/docker-sandbox.d.ts +9 -0
- package/dist/lib/docker-sandbox.d.ts.map +1 -1
- package/dist/lib/docker-sandbox.js +15 -0
- package/dist/lib/docker-sandbox.js.map +1 -1
- package/dist/lib/fingerprint.d.ts +3 -0
- package/dist/lib/fingerprint.d.ts.map +1 -1
- package/dist/lib/fingerprint.js +34 -0
- package/dist/lib/fingerprint.js.map +1 -1
- package/dist/lib/o11y/index.d.ts +3 -2
- package/dist/lib/o11y/index.d.ts.map +1 -1
- package/dist/lib/o11y/index.js +2 -1
- package/dist/lib/o11y/index.js.map +1 -1
- package/dist/lib/o11y/parsers/claude-code.d.ts +19 -1
- package/dist/lib/o11y/parsers/claude-code.d.ts.map +1 -1
- package/dist/lib/o11y/parsers/claude-code.js +72 -1
- package/dist/lib/o11y/parsers/claude-code.js.map +1 -1
- package/dist/lib/o11y/parsers/codex.d.ts +13 -1
- package/dist/lib/o11y/parsers/codex.d.ts.map +1 -1
- package/dist/lib/o11y/parsers/codex.js +68 -1
- package/dist/lib/o11y/parsers/codex.js.map +1 -1
- package/dist/lib/o11y/parsers/fx.d.ts +2 -1
- package/dist/lib/o11y/parsers/fx.d.ts.map +1 -1
- package/dist/lib/o11y/parsers/fx.js +21 -1
- package/dist/lib/o11y/parsers/fx.js.map +1 -1
- package/dist/lib/o11y/parsers/gemini.d.ts +13 -1
- package/dist/lib/o11y/parsers/gemini.d.ts.map +1 -1
- package/dist/lib/o11y/parsers/gemini.js +35 -1
- package/dist/lib/o11y/parsers/gemini.js.map +1 -1
- package/dist/lib/o11y/parsers/index.d.ts +9 -2
- package/dist/lib/o11y/parsers/index.d.ts.map +1 -1
- package/dist/lib/o11y/parsers/index.js +15 -1
- package/dist/lib/o11y/parsers/index.js.map +1 -1
- package/dist/lib/o11y/parsers/opencode.d.ts +17 -1
- package/dist/lib/o11y/parsers/opencode.d.ts.map +1 -1
- package/dist/lib/o11y/parsers/opencode.js +47 -4
- package/dist/lib/o11y/parsers/opencode.js.map +1 -1
- package/dist/lib/o11y/parsers/pi-coding-agent.d.ts +22 -0
- package/dist/lib/o11y/parsers/pi-coding-agent.d.ts.map +1 -0
- package/dist/lib/o11y/parsers/pi-coding-agent.js +217 -0
- package/dist/lib/o11y/parsers/pi-coding-agent.js.map +1 -0
- package/dist/lib/o11y/types.d.ts +30 -0
- package/dist/lib/o11y/types.d.ts.map +1 -1
- package/dist/lib/o11y/usage.d.ts +27 -0
- package/dist/lib/o11y/usage.d.ts.map +1 -0
- package/dist/lib/o11y/usage.js +75 -0
- package/dist/lib/o11y/usage.js.map +1 -0
- package/dist/lib/reporters.d.ts +101 -0
- package/dist/lib/reporters.d.ts.map +1 -0
- package/dist/lib/reporters.js +176 -0
- package/dist/lib/reporters.js.map +1 -0
- package/dist/lib/results.d.ts +15 -2
- package/dist/lib/results.d.ts.map +1 -1
- package/dist/lib/results.js +75 -4
- package/dist/lib/results.js.map +1 -1
- package/dist/lib/runner.d.ts +16 -1
- package/dist/lib/runner.d.ts.map +1 -1
- package/dist/lib/runner.js +85 -3
- package/dist/lib/runner.js.map +1 -1
- package/dist/lib/sandbox.d.ts +9 -0
- package/dist/lib/sandbox.d.ts.map +1 -1
- package/dist/lib/sandbox.js +14 -1
- package/dist/lib/sandbox.js.map +1 -1
- package/dist/lib/types.d.ts +185 -1
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js.map +1 -1
- package/dist/lib/version.d.ts +7 -0
- package/dist/lib/version.d.ts.map +1 -0
- package/dist/lib/version.js +8 -0
- package/dist/lib/version.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../../../src/lib/agents/gemini/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,YAAY;QACzB,YAAY,EAAE,sBAAsB;QACpC,aAAa,EAAE,QAAQ;QACvB,+EAA+E;QAC/E,6DAA6D;QAC7D,UAAU,EAAE,aAAa,CAAC,IAAI,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEhE,eAAe;YACb,OAAO,aAAa,CAAC,YAAY,CAAC;QACpC,CAAC;QAED,OAAO,CAAC,QAAyB;YAC/B,6DAA6D;YAC7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E,oBAAoB,CAAC,EAAE,WAAW,EAAE,2BAA2B,EAAE,SAAS,EAAE,QAAQ,EAAE;aAC9I,CAAC;QACJ,CAAC;QAED,6DAA6D;QAC7D,WAAW;YACT,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,0CAA0C;QAC1C,cAAc;YACZ,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC;QACjE,CAAC;QAED,OAAO,CAAC,OAAwB;YAC9B,OAAO,EAAE,CAAC,aAAa,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;QAC1D,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,UAAU,GAAG,sBAAsB,EAAE,CAAC;IAC5C,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,eAAe,EAAE,UAAU,CAAC,eAAe;QAC3C,eAAe;YACb,OAAO,UAAU,CAAC,YAAY,CAAC;QACjC,CAAC;QACD,GAAG,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,EAAE,CAAC,iBAAiB,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,CAAC;QAClF,UAAU;KACX,CAAC;AACJ,CAAC"}
|
|
@@ -9,5 +9,6 @@ export declare function assertRunRuntimeControls(agentName: AgentType, controls:
|
|
|
9
9
|
webResearch?: boolean;
|
|
10
10
|
}, judgeAgentName?: AgentType): void;
|
|
11
11
|
export { registerAgent, getAgent, listAgents, hasAgent };
|
|
12
|
+
export { runCredentials } from './plugin/orchestrator.js';
|
|
12
13
|
export type { Agent, AgentRunOptions, AgentRunResult } from './types.js';
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/agents/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/agents/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAa9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAa7C,sEAAsE;AACtE,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE;IAAE,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,EACnE,cAAc,CAAC,EAAE,SAAS,GACzB,IAAI,CAUN;AAGD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;AAGzD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/lib/agents/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { createOpenCodeAgent } from './opencode/agent.js';
|
|
|
8
8
|
import { createFxAgent } from './fx/agent.js';
|
|
9
9
|
import { createGeminiAgent } from './gemini/agent.js';
|
|
10
10
|
import { createCursorAgent } from './cursor/agent.js';
|
|
11
|
+
import { createPiCodingAgent } from './pi-coding-agent/agent.js';
|
|
11
12
|
import { assertBundledSkillsControl, assertCrossAgentJudgeSupport, assertWebResearchControl, } from './plugin/contract.js';
|
|
12
13
|
// Register all agent variants (Vercel AI Gateway + Direct API)
|
|
13
14
|
registerAgent(createClaudeCodeAgent({ useVercelAiGateway: true })); // vercel-ai-gateway/claude-code
|
|
@@ -18,6 +19,7 @@ registerAgent(createOpenCodeAgent()); // vercel-ai-gateway/opencode
|
|
|
18
19
|
registerAgent(createFxAgent()); // vercel-ai-gateway/fx
|
|
19
20
|
registerAgent(createGeminiAgent()); // gemini
|
|
20
21
|
registerAgent(createCursorAgent()); // cursor
|
|
22
|
+
registerAgent(createPiCodingAgent()); // vercel-ai-gateway/pi-coding-agent
|
|
21
23
|
/** Validate opt-in runtime controls for every agent used by a run. */
|
|
22
24
|
export function assertRunRuntimeControls(agentName, controls, judgeAgentName) {
|
|
23
25
|
const definition = getAgent(agentName).definition;
|
|
@@ -31,4 +33,6 @@ export function assertRunRuntimeControls(agentName, controls, judgeAgentName) {
|
|
|
31
33
|
}
|
|
32
34
|
// Re-export registry functions
|
|
33
35
|
export { registerAgent, getAgent, listAgents, hasAgent };
|
|
36
|
+
// Credentials a run injects, for redacting payloads built outside the agent.
|
|
37
|
+
export { runCredentials } from './plugin/orchestrator.js';
|
|
34
38
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/agents/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAG9B,+DAA+D;AAC/D,aA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AED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,KAAK,CAY3C"}
|
|
@@ -121,6 +121,7 @@ export function createOpenCodeDefinition() {
|
|
|
121
121
|
retryOnce: true,
|
|
122
122
|
errorPrefix: 'npm install failed',
|
|
123
123
|
errorBody: 'last10',
|
|
124
|
+
scope: 'project',
|
|
124
125
|
},
|
|
125
126
|
];
|
|
126
127
|
if (binaryUrl) {
|
|
@@ -153,6 +154,11 @@ export function createOpenCodeDefinition() {
|
|
|
153
154
|
}
|
|
154
155
|
return steps;
|
|
155
156
|
},
|
|
157
|
+
// The same `opencode` on PATH that run.mjs invokes (npm or a custom binaryUrl
|
|
158
|
+
// build); recorded as provenance.agentCliVersion.
|
|
159
|
+
versionCommand() {
|
|
160
|
+
return { kind: 'command', cmd: 'opencode', args: ['--version'] };
|
|
161
|
+
},
|
|
156
162
|
// OpenCode is configured via a project-local opencode.json (writeFiles target,
|
|
157
163
|
// relative to cwd — not a `~` path, so no viaShell heredoc needed).
|
|
158
164
|
configFiles(options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../../../src/lib/agents/opencode/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAqB9D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAa,EACb,cAAuD;IAEvD,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACvC,IAAI,UAAU,KAAK,QAAQ,IAAI,CAAC,cAAc,IAAI,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC;QAC7F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AI,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC,CAAC;QAC9C,CAAC;QAED,OAAO,CAAC,OAAwB;YAC9B,OAAO;gBACL,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,MAAM;gBACzC,yEAAyE;gBACzE,kEAAkE;gBAClE,0BAA0B;gBAC1B,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,mBAAmB,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC7D,CAAC;QACJ,CAAC;QAED;;;;;;WAMG;QACH,WAAW,CAAC,OAAwB;YAClC,MAAM,cAAc,GAAG,OAAO,CAAC,YAAY,EAAE,cAEhC,CAAC;YACd,OAAO;gBACL,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI;aACrF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,MAAM,UAAU,GAAG,wBAAwB,EAAE,CAAC;IAC9C,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,eAAe,EAAE,UAAU,CAAC,eAAe;QAC3C,eAAe;YACb,OAAO,UAAU,CAAC,YAAY,CAAC;QACjC,CAAC;QACD,GAAG,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,EAAE,CAAC,iBAAiB,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,CAAC;QAClF,UAAU;KACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PI coding agent (`pi`, @earendil-works/pi-coding-agent) — host-side definition +
|
|
3
|
+
* the thin Agent wrapper.
|
|
4
|
+
*
|
|
5
|
+
* The definition is pure data/auth/config; the actual CLI invocation + transcript
|
|
6
|
+
* capture live in ./run.mjs (shipped into the sandbox by the orchestrator). PI
|
|
7
|
+
* only ever runs as a child process of that runner, inside the sandbox — its SDK
|
|
8
|
+
* is never imported into the evaluator process, so a PI failure is an agent-run
|
|
9
|
+
* failure, not an evaluator crash.
|
|
10
|
+
*
|
|
11
|
+
* PI is multi-provider, but like OpenCode it only runs through the Vercel AI
|
|
12
|
+
* Gateway here (PI's built-in `vercel-ai-gateway` provider), so there is no
|
|
13
|
+
* gateway/direct fork: a single agent, always authenticated with
|
|
14
|
+
* AI_GATEWAY_API_KEY. See {@link PiAgentOptions} for what agentOptions accepts.
|
|
15
|
+
*/
|
|
16
|
+
import type { Agent } from '../types.js';
|
|
17
|
+
import type { AgentDefinition } from '../plugin/contract.js';
|
|
18
|
+
/**
|
|
19
|
+
* Additional provider configuration for PI's `models.json`, e.g. gateway models
|
|
20
|
+
* PI's built-in catalog does not list yet. Passed through
|
|
21
|
+
* agentOptions.extraProviders verbatim — see PI's "Custom Models" docs for every
|
|
22
|
+
* field.
|
|
23
|
+
*/
|
|
24
|
+
export interface PiProviderConfig {
|
|
25
|
+
baseUrl?: string;
|
|
26
|
+
/** 'openai-completions' | 'openai-responses' | 'anthropic-messages' | 'google-generative-ai' */
|
|
27
|
+
api?: string;
|
|
28
|
+
headers?: Record<string, string>;
|
|
29
|
+
models?: Array<{
|
|
30
|
+
id: string;
|
|
31
|
+
} & Record<string, unknown>>;
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
}
|
|
34
|
+
/** What `agentOptions` accepts for the PI agent. */
|
|
35
|
+
export interface PiAgentOptions {
|
|
36
|
+
/** Extra entries for PI's `~/.pi/agent/models.json`. Runs always use the
|
|
37
|
+
* `vercel-ai-gateway` provider, so this extends or overrides that provider. */
|
|
38
|
+
extraProviders?: Record<string, PiProviderConfig>;
|
|
39
|
+
/** PI thinking level: off | minimal | low | medium | high | xhigh | max. */
|
|
40
|
+
thinking?: string;
|
|
41
|
+
/** npm package (optionally versioned) to install instead of the latest PI. */
|
|
42
|
+
cliPackage?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Generate PI's `models.json` from `agentOptions.extraProviders`, or undefined
|
|
46
|
+
* when there are none. Passed through as-is.
|
|
47
|
+
*/
|
|
48
|
+
export declare function generatePiModelsConfig(extraProviders: Record<string, PiProviderConfig> | undefined): string | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Build the PI plugin definition.
|
|
51
|
+
*
|
|
52
|
+
* getApiKeyEnvVar() and authEnv() agree on AI_GATEWAY_API_KEY, so the host's key
|
|
53
|
+
* resolution and the sandbox env stay consistent.
|
|
54
|
+
*/
|
|
55
|
+
export declare function createPiCodingAgentDefinition(): AgentDefinition;
|
|
56
|
+
/**
|
|
57
|
+
* Create the PI Agent. Thin wrapper over the generic orchestrator so the Agent
|
|
58
|
+
* interface (and thus registry.ts / index.ts / runner.ts) is unchanged.
|
|
59
|
+
*/
|
|
60
|
+
export declare function createPiCodingAgent(): Agent;
|
|
61
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../../src/lib/agents/pi-coding-agent/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EAAE,KAAK,EAAmB,MAAM,aAAa,CAAC;AAG1D,OAAO,KAAK,EAAE,eAAe,EAA2B,MAAM,uBAAuB,CAAC;AAGtF;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gGAAgG;IAChG,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACzD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,oDAAoD;AACpD,MAAM,WAAW,cAAc;IAC7B;mFAC+E;IAC/E,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAClD,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8EAA8E;IAC9E,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAID;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAAG,SAAS,GAC3D,MAAM,GAAG,SAAS,CAGpB;AAyBD;;;;;GAKG;AACH,wBAAgB,6BAA6B,IAAI,eAAe,CAyD/D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,KAAK,CAY3C"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PI coding agent (`pi`, @earendil-works/pi-coding-agent) — host-side definition +
|
|
3
|
+
* the thin Agent wrapper.
|
|
4
|
+
*
|
|
5
|
+
* The definition is pure data/auth/config; the actual CLI invocation + transcript
|
|
6
|
+
* capture live in ./run.mjs (shipped into the sandbox by the orchestrator). PI
|
|
7
|
+
* only ever runs as a child process of that runner, inside the sandbox — its SDK
|
|
8
|
+
* is never imported into the evaluator process, so a PI failure is an agent-run
|
|
9
|
+
* failure, not an evaluator crash.
|
|
10
|
+
*
|
|
11
|
+
* PI is multi-provider, but like OpenCode it only runs through the Vercel AI
|
|
12
|
+
* Gateway here (PI's built-in `vercel-ai-gateway` provider), so there is no
|
|
13
|
+
* gateway/direct fork: a single agent, always authenticated with
|
|
14
|
+
* AI_GATEWAY_API_KEY. See {@link PiAgentOptions} for what agentOptions accepts.
|
|
15
|
+
*/
|
|
16
|
+
import { fileURLToPath } from 'node:url';
|
|
17
|
+
import { AI_GATEWAY } from '../shared.js';
|
|
18
|
+
import { runWithDefinition } from '../plugin/orchestrator.js';
|
|
19
|
+
const DEFAULT_CLI_PACKAGE = '@earendil-works/pi-coding-agent';
|
|
20
|
+
/**
|
|
21
|
+
* Generate PI's `models.json` from `agentOptions.extraProviders`, or undefined
|
|
22
|
+
* when there are none. Passed through as-is.
|
|
23
|
+
*/
|
|
24
|
+
export function generatePiModelsConfig(extraProviders) {
|
|
25
|
+
if (!extraProviders || Object.keys(extraProviders).length === 0)
|
|
26
|
+
return undefined;
|
|
27
|
+
return JSON.stringify({ providers: extraProviders }, null, 2);
|
|
28
|
+
}
|
|
29
|
+
/** Heredoc a config file into PI's global agent dir (an absolute `~` path writeFiles can't target). */
|
|
30
|
+
function writePiAgentFile(file, content) {
|
|
31
|
+
const marker = `PI_${file.replace(/\W/g, '_').toUpperCase()}_EOF`;
|
|
32
|
+
return { viaShell: `mkdir -p ~/.pi/agent && cat > ~/.pi/agent/${file} << '${marker}'\n${content}\n${marker}` };
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Default PI's global `defaultProjectTrust` to "always", merged into any
|
|
36
|
+
* settings.json a setup hook already wrote (an explicit trust choice wins).
|
|
37
|
+
*/
|
|
38
|
+
const TRUST_EVAL_WORKSPACE = {
|
|
39
|
+
viaShell: `node - << 'PI_SETTINGS_EOF'
|
|
40
|
+
const fs = require('node:fs');
|
|
41
|
+
const path = require('node:path');
|
|
42
|
+
const file = path.join(require('node:os').homedir(), '.pi/agent/settings.json');
|
|
43
|
+
let settings = {};
|
|
44
|
+
try { settings = JSON.parse(fs.readFileSync(file, 'utf8')); } catch {}
|
|
45
|
+
settings.defaultProjectTrust ??= 'always';
|
|
46
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
47
|
+
fs.writeFileSync(file, JSON.stringify(settings, null, 2));
|
|
48
|
+
PI_SETTINGS_EOF`,
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Build the PI plugin definition.
|
|
52
|
+
*
|
|
53
|
+
* getApiKeyEnvVar() and authEnv() agree on AI_GATEWAY_API_KEY, so the host's key
|
|
54
|
+
* resolution and the sandbox env stay consistent.
|
|
55
|
+
*/
|
|
56
|
+
export function createPiCodingAgentDefinition() {
|
|
57
|
+
return {
|
|
58
|
+
name: 'vercel-ai-gateway/pi-coding-agent',
|
|
59
|
+
displayName: 'PI Coding Agent (Vercel AI Gateway)',
|
|
60
|
+
defaultModel: 'anthropic/claude-sonnet-4.5',
|
|
61
|
+
o11yAgentName: 'vercel-ai-gateway/pi-coding-agent',
|
|
62
|
+
// PI ships no vendor-bundled skills; it only discovers caller-installed ones.
|
|
63
|
+
bundledSkillsControl: 'not-applicable',
|
|
64
|
+
// Resolve run.mjs next to this file (works in src during dev and in dist after
|
|
65
|
+
// the build copies run.mjs alongside the compiled agent.js).
|
|
66
|
+
runnerPath: fileURLToPath(new URL('./run.mjs', import.meta.url)),
|
|
67
|
+
// PI only supports the Vercel AI Gateway here, never direct provider APIs.
|
|
68
|
+
getApiKeyEnvVar() {
|
|
69
|
+
return AI_GATEWAY.apiKeyEnvVar;
|
|
70
|
+
},
|
|
71
|
+
install(options) {
|
|
72
|
+
// Project deps (retried once), then the PI CLI globally.
|
|
73
|
+
const cliPackage = options.agentOptions?.cliPackage || DEFAULT_CLI_PACKAGE;
|
|
74
|
+
return [
|
|
75
|
+
{ kind: 'command', cmd: 'npm', args: ['install'], retryOnce: true, errorPrefix: 'npm install failed', errorBody: 'last10' },
|
|
76
|
+
{ kind: 'command', cmd: 'npm', args: ['install', '-g', cliPackage], errorPrefix: 'PI coding agent install failed', errorBody: 'stderr' },
|
|
77
|
+
];
|
|
78
|
+
},
|
|
79
|
+
// The gateway provider needs no config. Everything goes to PI's global agent
|
|
80
|
+
// dir, which stays out of the workspace (and so out of the captured diff).
|
|
81
|
+
configFiles(options) {
|
|
82
|
+
const piOptions = options.agentOptions;
|
|
83
|
+
// PI (>= 0.79) only loads project skills and settings (.agents/skills, .pi/*)
|
|
84
|
+
// from a trusted folder, and JSON mode cannot prompt, so it would silently
|
|
85
|
+
// skip caller-installed skills. The sandbox and its workspace are the eval's own.
|
|
86
|
+
const files = [TRUST_EVAL_WORKSPACE];
|
|
87
|
+
const models = generatePiModelsConfig(piOptions?.extraProviders);
|
|
88
|
+
if (models)
|
|
89
|
+
files.push(writePiAgentFile('models.json', models));
|
|
90
|
+
return files;
|
|
91
|
+
},
|
|
92
|
+
authEnv(options) {
|
|
93
|
+
return {
|
|
94
|
+
// No update check / install ping from inside an eval sandbox.
|
|
95
|
+
PI_SKIP_VERSION_CHECK: '1',
|
|
96
|
+
PI_TELEMETRY: '0',
|
|
97
|
+
[AI_GATEWAY.apiKeyEnvVar]: options.apiKey,
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
/**
|
|
101
|
+
* Host-threaded `--thinking` level. Rides in extra (not agentOptions) because
|
|
102
|
+
* extra is what both runner entry points ship — the orchestrator and the
|
|
103
|
+
* judge's eval-helper. null when unset.
|
|
104
|
+
*/
|
|
105
|
+
runnerExtra(options) {
|
|
106
|
+
return { thinking: options.agentOptions?.thinking ?? null };
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Create the PI Agent. Thin wrapper over the generic orchestrator so the Agent
|
|
112
|
+
* interface (and thus registry.ts / index.ts / runner.ts) is unchanged.
|
|
113
|
+
*/
|
|
114
|
+
export function createPiCodingAgent() {
|
|
115
|
+
const definition = createPiCodingAgentDefinition();
|
|
116
|
+
return {
|
|
117
|
+
name: definition.name,
|
|
118
|
+
displayName: definition.displayName,
|
|
119
|
+
getApiKeyEnvVar: definition.getApiKeyEnvVar,
|
|
120
|
+
getDefaultModel() {
|
|
121
|
+
return definition.defaultModel;
|
|
122
|
+
},
|
|
123
|
+
run: (fixturePath, options) => runWithDefinition(definition, fixturePath, options),
|
|
124
|
+
definition,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|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,CAAC;QAED;;;;WAIG;QACH,WAAW,CAAC,OAAwB;YAClC,OAAO,EAAE,QAAQ,EAAG,OAAO,CAAC,YAA2C,EAAE,QAAQ,IAAI,IAAI,EAAE,CAAC;QAC9F,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,MAAM,UAAU,GAAG,6BAA6B,EAAE,CAAC;IACnD,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,eAAe,EAAE,UAAU,CAAC,eAAe;QAC3C,eAAe;YACb,OAAO,UAAU,CAAC,YAAY,CAAC;QACjC,CAAC;QACD,GAAG,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,EAAE,CAAC,iBAAiB,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,CAAC;QAClF,UAAU;KACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PI coding agent in-sandbox runner.
|
|
3
|
+
*
|
|
4
|
+
* This file is shipped INTO the sandbox by the orchestrator and executed there as
|
|
5
|
+
* `node __agent_eval__/run.mjs '<AgentRunInput JSON>'`. It is intentionally
|
|
6
|
+
* ZERO-DEPENDENCY (only `node:*` builtins) because the sandbox only has the
|
|
7
|
+
* fixture's own deps + the installed `pi` CLI — it cannot import anything from
|
|
8
|
+
* the @vercel/agent-eval package.
|
|
9
|
+
*
|
|
10
|
+
* Dual mode:
|
|
11
|
+
* - runnable: invoked directly → reads argv, runs the agent, writes the result
|
|
12
|
+
* file + prints a status line, exits 0.
|
|
13
|
+
* - importable: `import { runAgent } from './run.mjs'` → returns a RunnerResult
|
|
14
|
+
* (no file write, no exit). This is what the in-sandbox judge reuses.
|
|
15
|
+
*
|
|
16
|
+
* The pure helpers below are exported (not just `runAgent`) so they can be
|
|
17
|
+
* unit-tested directly — the same code the sandbox runs (see pi-coding-agent.test.ts).
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { spawnSync } from 'node:child_process';
|
|
21
|
+
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
22
|
+
import { dirname } from 'node:path';
|
|
23
|
+
import { fileURLToPath } from 'node:url';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Build the PI CLI argument list.
|
|
27
|
+
*
|
|
28
|
+
* - `--mode json` emits every session event as JSONL on stdout (the transcript)
|
|
29
|
+
* and exits when the agent is done. PI has no approval prompts, so there is
|
|
30
|
+
* no "yolo" flag to pass.
|
|
31
|
+
* - `--no-session`: the JSON stream already carries everything we persist.
|
|
32
|
+
* - `--provider vercel-ai-gateway --model <model>` when a model override is
|
|
33
|
+
* present. The provider is pinned because gateway ids (`anthropic/…`) would
|
|
34
|
+
* otherwise be read as `<provider>/<model>`. On a native-default run both
|
|
35
|
+
* are omitted — PI rejects `--provider` without `--model` — and PI picks its
|
|
36
|
+
* own default from the only authenticated provider, the gateway.
|
|
37
|
+
* - `--thinking <extra.thinking>` when set. HOST-threaded (agent.ts
|
|
38
|
+
* runnerExtra) rather than read from agentOptions, so the judge's
|
|
39
|
+
* eval-helper invocation — which ships extra but no agentOptions — gets it too.
|
|
40
|
+
*
|
|
41
|
+
* The prompt is deliberately NOT an argument: PI parses positionals starting
|
|
42
|
+
* with `@` as file attachments and `-` as flags. It is piped on stdin instead,
|
|
43
|
+
* which PI reads as the initial message (see runAgent).
|
|
44
|
+
*
|
|
45
|
+
* @param {{model?:string, extra?:Record<string,unknown>}} input
|
|
46
|
+
* @returns {string[]}
|
|
47
|
+
*/
|
|
48
|
+
export function buildPiCliArgs(input) {
|
|
49
|
+
const args = ['--mode', 'json', '--no-session'];
|
|
50
|
+
if (input.model) {
|
|
51
|
+
args.push('--provider', 'vercel-ai-gateway', '--model', input.model);
|
|
52
|
+
}
|
|
53
|
+
const thinking = input.extra?.thinking;
|
|
54
|
+
if (thinking) {
|
|
55
|
+
args.push('--thinking', String(thinking));
|
|
56
|
+
}
|
|
57
|
+
return args;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Events dropped from the transcript. `message_update` / `tool_execution_update`
|
|
62
|
+
* are per-token streaming deltas that each repeat the whole partial message, and
|
|
63
|
+
* `turn_end` / `agent_end` repeat every message already emitted by `message_end`
|
|
64
|
+
* — they bloat the raw stream while adding nothing the remaining events don't
|
|
65
|
+
* carry.
|
|
66
|
+
*/
|
|
67
|
+
const REDUNDANT_EVENT_TYPES = new Set([
|
|
68
|
+
'message_start',
|
|
69
|
+
'message_update',
|
|
70
|
+
'tool_execution_update',
|
|
71
|
+
'turn_end',
|
|
72
|
+
'agent_end',
|
|
73
|
+
]);
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Parse one line of PI's `--mode json` stdout into its event, or undefined for
|
|
77
|
+
* anything that is not a JSON event.
|
|
78
|
+
*
|
|
79
|
+
* @param {string} line
|
|
80
|
+
* @returns {Record<string, any>|undefined}
|
|
81
|
+
*/
|
|
82
|
+
export function parsePiEventLine(line) {
|
|
83
|
+
const trimmed = line.trim();
|
|
84
|
+
if (!trimmed.startsWith('{') || !trimmed.endsWith('}')) return undefined;
|
|
85
|
+
try {
|
|
86
|
+
const event = JSON.parse(trimmed);
|
|
87
|
+
return event && typeof event.type === 'string' ? event : undefined;
|
|
88
|
+
} catch {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Whether an event is left out of the transcript (see REDUNDANT_EVENT_TYPES).
|
|
95
|
+
*
|
|
96
|
+
* @param {Record<string, any>} event
|
|
97
|
+
* @returns {boolean}
|
|
98
|
+
*/
|
|
99
|
+
export function isRedundantPiEvent(event) {
|
|
100
|
+
return REDUNDANT_EVENT_TYPES.has(event.type);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Serialize the kept events as the JSONL transcript.
|
|
105
|
+
*
|
|
106
|
+
* @param {Array<Record<string, any>>} events
|
|
107
|
+
* @returns {string|undefined}
|
|
108
|
+
*/
|
|
109
|
+
export function serializeTranscript(events) {
|
|
110
|
+
if (events.length === 0) {
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
return events.map((event) => JSON.stringify(event)).join('\n');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** @param {Array<Record<string, any>>} events */
|
|
117
|
+
function lastAssistantMessage(events) {
|
|
118
|
+
for (let i = events.length - 1; i >= 0; i--) {
|
|
119
|
+
const event = events[i];
|
|
120
|
+
if (event.type === 'message_end' && event.message?.role === 'assistant') {
|
|
121
|
+
return event.message;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The model PI actually used: every assistant message carries it. Reported as
|
|
129
|
+
* PI's model id — the same namespace `--model` is requested in.
|
|
130
|
+
*
|
|
131
|
+
* @param {Array<Record<string, any>>} events
|
|
132
|
+
* @returns {string|undefined}
|
|
133
|
+
*/
|
|
134
|
+
export function extractObservedModelFromEvents(events) {
|
|
135
|
+
const model = lastAssistantMessage(events)?.model;
|
|
136
|
+
return typeof model === 'string' && model ? model : undefined;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* The run's failure, if PI reported one in-band. In JSON mode PI exits 0 even
|
|
141
|
+
* when the provider call failed (bad key, unknown model id, network error, all
|
|
142
|
+
* retries exhausted): the only signal is the final assistant message ending with
|
|
143
|
+
* stopReason 'error' / 'aborted'. Without this check such a run would be graded
|
|
144
|
+
* as a success that simply wrote no code.
|
|
145
|
+
*
|
|
146
|
+
* @param {Array<Record<string, any>>} events
|
|
147
|
+
* @returns {string|undefined}
|
|
148
|
+
*/
|
|
149
|
+
export function extractAgentErrorFromEvents(events) {
|
|
150
|
+
const message = lastAssistantMessage(events);
|
|
151
|
+
if (message?.stopReason === 'error' || message?.stopReason === 'aborted') {
|
|
152
|
+
return message.errorMessage || `PI stopped with reason "${message.stopReason}"`;
|
|
153
|
+
}
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Run PI over the workspace at `input.cwd` and return a RunnerResult.
|
|
159
|
+
*
|
|
160
|
+
* Auth (AI_GATEWAY_API_KEY) arrives via
|
|
161
|
+
* process.env — the orchestrator sets it on the `node run.mjs` invocation, and we
|
|
162
|
+
* pass process.env straight through to the CLI. The runner never handles secrets
|
|
163
|
+
* itself.
|
|
164
|
+
*
|
|
165
|
+
* @param {import('../plugin/contract.js').AgentRunInput} input
|
|
166
|
+
* @returns {Promise<import('../plugin/contract.js').RunnerResult>}
|
|
167
|
+
*/
|
|
168
|
+
export async function runAgent(input) {
|
|
169
|
+
const args = buildPiCliArgs(input);
|
|
170
|
+
|
|
171
|
+
// spawnSync (not a shell string), like the other runners. The prompt goes in on
|
|
172
|
+
// stdin (see buildPiCliArgs) — which also closes the pipe: PI waits for stdin
|
|
173
|
+
// EOF before it starts. Blocking is fine — the runner has nothing else to do
|
|
174
|
+
// while the agent works. The sandbox-level timeout bounds it.
|
|
175
|
+
const res = spawnSync('pi', args, {
|
|
176
|
+
cwd: input.cwd,
|
|
177
|
+
env: process.env,
|
|
178
|
+
encoding: 'utf8',
|
|
179
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
180
|
+
input: input.prompt,
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
const stderr = res.stderr || '';
|
|
184
|
+
// spawnSync sets status=null + error when the binary can't be spawned at all.
|
|
185
|
+
const agentExitCode = res.status == null ? -1 : res.status;
|
|
186
|
+
const spawnError = res.error;
|
|
187
|
+
|
|
188
|
+
// Split stdout into the kept events (the transcript) and anything PI printed
|
|
189
|
+
// outside the event stream.
|
|
190
|
+
const events = [];
|
|
191
|
+
let strayOutput = '';
|
|
192
|
+
for (const line of (res.stdout || '').split('\n')) {
|
|
193
|
+
const event = parsePiEventLine(line);
|
|
194
|
+
if (!event) {
|
|
195
|
+
if (line.trim()) strayOutput += line + '\n';
|
|
196
|
+
} else if (!isRedundantPiEvent(event)) {
|
|
197
|
+
events.push(event);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const transcript = serializeTranscript(events) ?? null;
|
|
202
|
+
const observedModel = extractObservedModelFromEvents(events) ?? null;
|
|
203
|
+
// stdout THEN stderr, like the other runners — with the filtered event stream
|
|
204
|
+
// standing in for the raw one.
|
|
205
|
+
const output = (transcript ? transcript + '\n' : '') + strayOutput + stderr;
|
|
206
|
+
|
|
207
|
+
const agentError = extractAgentErrorFromEvents(events);
|
|
208
|
+
|
|
209
|
+
if (spawnError || agentExitCode !== 0 || agentError) {
|
|
210
|
+
// Last 5 lines of what PI printed outside the event stream (startup errors go
|
|
211
|
+
// to stderr), else a coded fallback.
|
|
212
|
+
const errorLines = (strayOutput + stderr).trim().split('\n').slice(-5).join('\n');
|
|
213
|
+
const fallback = spawnError
|
|
214
|
+
? `Failed to run pi: ${spawnError.message}`
|
|
215
|
+
: `PI CLI exited with code ${agentExitCode}`;
|
|
216
|
+
return {
|
|
217
|
+
ok: false,
|
|
218
|
+
output,
|
|
219
|
+
transcript,
|
|
220
|
+
observedModel,
|
|
221
|
+
error: agentError || errorLines || fallback,
|
|
222
|
+
agentExitCode,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return { ok: true, output, transcript, observedModel, error: null, agentExitCode };
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/* ─────────────────────────── runnable (CLI) entry ─────────────────────────── */
|
|
230
|
+
|
|
231
|
+
// True when this file is executed directly (`node run.mjs ...`), false when imported.
|
|
232
|
+
const isMain = process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1];
|
|
233
|
+
|
|
234
|
+
if (isMain) {
|
|
235
|
+
// argv[2] is the AgentRunInput JSON (never contains secrets).
|
|
236
|
+
const input = JSON.parse(process.argv[2]);
|
|
237
|
+
|
|
238
|
+
// Always produce a RunnerResult, even if the runner itself throws, so the host
|
|
239
|
+
// always has a result file to read (node exit code stays 0 except on a truly
|
|
240
|
+
// unrecoverable crash before we can write).
|
|
241
|
+
let result;
|
|
242
|
+
try {
|
|
243
|
+
result = await runAgent(input);
|
|
244
|
+
} catch (e) {
|
|
245
|
+
result = {
|
|
246
|
+
ok: false,
|
|
247
|
+
output: '',
|
|
248
|
+
transcript: null,
|
|
249
|
+
observedModel: null,
|
|
250
|
+
error: e && e.message ? e.message : String(e),
|
|
251
|
+
agentExitCode: -1,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Source of truth: the result file the host reads back via sandbox.readFile.
|
|
256
|
+
try {
|
|
257
|
+
mkdirSync(dirname(input.resultPath), { recursive: true });
|
|
258
|
+
writeFileSync(input.resultPath, JSON.stringify(result));
|
|
259
|
+
} catch {
|
|
260
|
+
// If the file can't be written, the host falls back to the marker line below.
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Fallback channel: a compact status line (no transcript — it can be huge).
|
|
264
|
+
process.stdout.write(
|
|
265
|
+
'__AGENT_RESULT__ ' +
|
|
266
|
+
JSON.stringify({
|
|
267
|
+
ok: result.ok,
|
|
268
|
+
observedModel: result.observedModel,
|
|
269
|
+
error: result.error,
|
|
270
|
+
agentExitCode: result.agentExitCode,
|
|
271
|
+
}) +
|
|
272
|
+
'\n'
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
// Exit 0: "the runner ran". Agent success/failure is conveyed via result.ok, not
|
|
276
|
+
// the node exit code (the host distinguishes the two).
|
|
277
|
+
process.exit(0);
|
|
278
|
+
}
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* host. See the migration notes in the PR for the full rationale.
|
|
20
20
|
*/
|
|
21
21
|
import type { ModelTier, RunnableExperimentConfig } from '../../types.js';
|
|
22
|
+
import type { TokenUsage } from '../../o11y/types.js';
|
|
22
23
|
import type { AgentRunOptions } from '../types.js';
|
|
23
24
|
/**
|
|
24
25
|
* One install action the orchestrator runs in the sandbox before invocation.
|
|
@@ -38,6 +39,13 @@ export interface InstallStep {
|
|
|
38
39
|
script?: string;
|
|
39
40
|
/** Retry once on a non-zero exit before failing (the project `npm install`). */
|
|
40
41
|
retryOnce?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* What the step installs. `'project'` marks the fixture's own dependencies:
|
|
44
|
+
* a separate verifier re-runs only those steps (plus the agent steps when a
|
|
45
|
+
* judge needs the CLI). When no step in a definition sets a scope, the
|
|
46
|
+
* verifier runs every step.
|
|
47
|
+
*/
|
|
48
|
+
scope?: 'project' | 'agent';
|
|
41
49
|
/** Prefix of the thrown Error on final failure, e.g. 'Claude Code install failed'. */
|
|
42
50
|
errorPrefix: string;
|
|
43
51
|
/**
|
|
@@ -60,6 +68,22 @@ export interface ConfigFile {
|
|
|
60
68
|
/** Exact shell to run instead, e.g. `mkdir -p ~/.codex && cat > ~/.codex/... << 'EOF' ...`. */
|
|
61
69
|
viaShell?: string;
|
|
62
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* A command that prints the agent CLI's version: `cmd` with `args` or, for kind
|
|
73
|
+
* 'shell', a bash `script`. It is given `timeoutMs` (default 30 seconds) to
|
|
74
|
+
* finish; after that it is abandoned, killed in the sandbox where coreutils
|
|
75
|
+
* `timeout` is available, and the version is left unset.
|
|
76
|
+
*/
|
|
77
|
+
export type VersionCommand = {
|
|
78
|
+
kind: 'command';
|
|
79
|
+
cmd: string;
|
|
80
|
+
args?: string[];
|
|
81
|
+
timeoutMs?: number;
|
|
82
|
+
} | {
|
|
83
|
+
kind: 'shell';
|
|
84
|
+
script: string;
|
|
85
|
+
timeoutMs?: number;
|
|
86
|
+
};
|
|
63
87
|
/**
|
|
64
88
|
* Host-side plugin description for one agent. Pure data + tiny pure functions —
|
|
65
89
|
* no sandbox calls, no CLI invocation.
|
|
@@ -93,6 +117,14 @@ export interface AgentDefinition {
|
|
|
93
117
|
install(options: AgentRunOptions): InstallStep[];
|
|
94
118
|
/** Config files written before invocation (codex TOML, opencode.json). [] for most. */
|
|
95
119
|
configFiles(options: AgentRunOptions): ConfigFile[];
|
|
120
|
+
/**
|
|
121
|
+
* OPTIONAL command that prints the installed CLI's version. The orchestrator
|
|
122
|
+
* runs it once after install and records its trimmed stdout as
|
|
123
|
+
* `provenance.agentCliVersion`. A non-zero exit, empty output, or error leaves
|
|
124
|
+
* the version unset and never fails the run. Omit it (or return undefined)
|
|
125
|
+
* when the CLI has no version command.
|
|
126
|
+
*/
|
|
127
|
+
versionCommand?(options: AgentRunOptions): VersionCommand | undefined;
|
|
96
128
|
/**
|
|
97
129
|
* The agent-specific auth/env handed to the run.mjs process (merged with the
|
|
98
130
|
* neutral-workspace env by the orchestrator). This is the ONLY place provider
|
|
@@ -184,5 +216,13 @@ export interface RunnerResult {
|
|
|
184
216
|
* repairs dropping to zero means the upstream CLI is fixed).
|
|
185
217
|
*/
|
|
186
218
|
modelRepair?: string;
|
|
219
|
+
/**
|
|
220
|
+
* OPTIONAL token usage the CLI reported somewhere other than the transcript.
|
|
221
|
+
* fx prints its usage only in `fx ask --json`, while the transcript is the
|
|
222
|
+
* saved session, which records context size rather than consumed tokens.
|
|
223
|
+
* When set, it takes precedence over usage read from the transcript; omit it
|
|
224
|
+
* to have usage read from the transcript as usual.
|
|
225
|
+
*/
|
|
226
|
+
usage?: TokenUsage;
|
|
187
227
|
}
|
|
188
228
|
//# sourceMappingURL=contract.d.ts.map
|