fix(harness): move harness-specific output handling into the harness plugins (#1855)
This commit is contained in:
1 parent
ad9b2dee42
commit
08b7db413b
14 files changed
+129
-83
No files matched your search
@@ -657,6 +657,8 @@ export function createLauncher({
|
||||
const { manifest, ...files } = bundle.files;
|
||||
const adapter = call(model.harness, "adapter", () => harness.adapter());
|
||||
const turnEnd = call(model.harness, "turnEnd", () => harness.turnEnd());
|
||||
const outputPolicy = call(model.harness, "outputPolicy", () => harness.outputPolicy({ proxy: Boolean(sessionProxy) }));
|
||||
if (!["adapter", "non-newline-stdout", "stdout"].includes(outputPolicy)) throw new Refusal("harness-refused", "invalid harness output policy");
|
||||
const transcript = call(model.harness, "transcript", () => harness.transcript({ runDir, store }));
|
||||
const harnessMounts = call(model.harness, "mounts", () => harness.mounts({ env }));
|
||||
// Row 93: the git socket, for a role that pushes work or reviews it. Row 137: or lands it.
|
||||
@@ -688,6 +690,8 @@ export function createLauncher({
|
||||
bundle: files,
|
||||
harnessEnv,
|
||||
turnEnd,
|
||||
outputPolicy,
|
||||
outputPolicyVersion: 1,
|
||||
toolSocket,
|
||||
turnMarker,
|
||||
...(holding?.length ? { landing: holding.map(({ decision, task_ref }) => ({ decision, task_ref })) } : {}),
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import { writeFileSync, openSync, closeSync, linkSync, unlinkSync } from 'node:fs';
|
||||
import { join, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { constants } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
// The host needs a model-activity signal, never event/output text or a credential.
|
||||
// The historical filename/token stays stable for the host watchdog protocol.
|
||||
export function firstOutputMarker(runDir) {
|
||||
@@ -34,66 +31,3 @@ export function firstTurnMarker(runDir) {
|
||||
if (failed) throw new Error('first-turn marker publication failed');
|
||||
};
|
||||
}
|
||||
|
||||
// The managed Pi adapter uses this monitor to translate its native JSON event
|
||||
// streams back into the answer-only adapter contract. Startup, headers and
|
||||
// keepalives are not model output; substantive deltas and named tool calls count.
|
||||
export function modelEventStream({ harness, runDir }) {
|
||||
if (harness !== 'pi') throw new Error('unknown model event stream');
|
||||
const mark = firstOutputMarker(runDir);
|
||||
let pending = '', answer = null, failed = false;
|
||||
const line = value => {
|
||||
if (!value) return;
|
||||
const event = JSON.parse(value);
|
||||
const delta = event.type === 'message_update' && event.assistantMessageEvent;
|
||||
if (delta && ['text_delta', 'thinking_delta', 'toolcall_delta'].includes(delta.type) && typeof delta.delta === 'string' && delta.delta.length) mark(delta.delta);
|
||||
if (delta?.type === 'toolcall_start' && typeof delta.id === 'string' && delta.id.length && typeof delta.toolName === 'string' && delta.toolName.length) mark('output');
|
||||
if (event.type === 'agent_end') {
|
||||
const last = event.messages?.at(-1);
|
||||
if (last?.role === 'assistant') {
|
||||
failed = ['error', 'aborted'].includes(last.stopReason);
|
||||
answer = (last.content ?? []).filter(part => part.type === 'text').map(part => part.text + '\n').join('');
|
||||
}
|
||||
}
|
||||
};
|
||||
return {
|
||||
push(chunk) {
|
||||
pending += chunk;
|
||||
if (pending.length > 32 * 1024 * 1024) throw new Error('model event too large');
|
||||
let i; while ((i = pending.indexOf('\n')) !== -1) { line(pending.slice(0, i)); pending = pending.slice(i + 1); }
|
||||
},
|
||||
finish() {
|
||||
if (pending) line(pending);
|
||||
if (failed || typeof answer !== 'string') throw new Error('model stream did not complete');
|
||||
return answer;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// Invoked only by managed proxy adapter turns; the model CLI keeps its normal
|
||||
// process group and stderr, while stdout remains the final answer alone.
|
||||
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
||||
const [, , harness, runDir, command, ...args] = process.argv;
|
||||
const stream = modelEventStream({ harness, runDir });
|
||||
const child = spawn(command, args, { stdio: ['ignore', 'pipe', 'inherit'] });
|
||||
let bad = false;
|
||||
child.stdout.setEncoding('utf8');
|
||||
child.stdout.on('data', chunk => {
|
||||
if (bad) return;
|
||||
try { stream.push(chunk); }
|
||||
catch { bad = true; child.kill('SIGTERM'); }
|
||||
});
|
||||
child.on('error', () => { bad = true; });
|
||||
child.on('close', (code, signal) => {
|
||||
if (bad) { process.stderr.write('model event stream failed\n'); process.exitCode = 1; return; }
|
||||
if (signal) {
|
||||
process.stderr.write(`model child killed by ${signal}\n`);
|
||||
const number = constants.signals[signal];
|
||||
process.exitCode = Number.isInteger(number) && number > 0 ? 128 + number : 1;
|
||||
return;
|
||||
}
|
||||
if (code !== 0) { process.exitCode = code ?? 1; return; }
|
||||
try { process.stdout.write(stream.finish()); }
|
||||
catch { process.stderr.write('model event stream failed\n'); process.exitCode = 1; }
|
||||
});
|
||||
}
|
||||
@@ -395,13 +395,16 @@ function runTurn({ session, request, n, env, onChild }) {
|
||||
// Such adapters can print synthetic error results, which aren't activity.
|
||||
// Read the declaration from module metadata, never the ambient environment;
|
||||
// adapters without it retain the stdout fallback (including worker paths).
|
||||
const markOutput = session.harnessEnv.MOSAIC_MODEL_ACTIVITY_SOURCE === 'adapter'
|
||||
? () => {} : firstOutputMarker(session.runDir);
|
||||
// Sessions written before outputPolicyVersion use their recorded activity metadata.
|
||||
const policy = session.outputPolicyVersion === undefined
|
||||
? (session.harnessEnv.MOSAIC_MODEL_ACTIVITY_SOURCE === 'adapter' ? 'adapter' : session.proxyFirstTurn ? 'non-newline-stdout' : 'stdout')
|
||||
: session.outputPolicy;
|
||||
const markOutput = policy === 'adapter' ? () => {} : firstOutputMarker(session.runDir);
|
||||
child.stdout.setEncoding("utf8");
|
||||
child.stdout.on("data", (s) => {
|
||||
// Empty text blocks can render only newlines; they are not model output.
|
||||
// Preserve the stdout fallback for content emitted by a managed adapter.
|
||||
if (!session.proxyFirstTurn || !['pi', 'claude-code'].includes(session.harness) || /[^\n]/.test(s)) markOutput(s);
|
||||
if (policy !== 'non-newline-stdout' || !session.proxyFirstTurn || /[^\n]/.test(s)) markOutput(s);
|
||||
if (out.length < 4 * BODY_MAX) out += s;
|
||||
});
|
||||
return new Promise((resolve) => {
|
||||
@@ -449,7 +452,9 @@ function runTurn({ session, request, n, env, onChild }) {
|
||||
|
||||
export const harnessOk = (s) => (s.turnEnd === "marker" || s.turnEnd === "exit")
|
||||
&& s.harnessEnv !== null && typeof s.harnessEnv === "object" && !Array.isArray(s.harnessEnv)
|
||||
&& Object.values(s.harnessEnv).every((v) => typeof v === "string");
|
||||
&& Object.values(s.harnessEnv).every((v) => typeof v === "string")
|
||||
&& (s.outputPolicyVersion === undefined ? s.outputPolicy === undefined
|
||||
: s.outputPolicyVersion === 1 && ["adapter", "non-newline-stdout", "stdout"].includes(s.outputPolicy));
|
||||
|
||||
// The adapter's environment: the host's allowlisted environment, the bundle,
|
||||
// and the harness module's own variables, which the host computed into
|
||||
@@ -472,7 +477,7 @@ export function adapterEnv(session, env) {
|
||||
...(session.runDir ? { MOSAIC_MODEL_ACTIVITY_DIR: session.runDir } : {}),
|
||||
// Row 66: after the module's variables, so the log is always the run's own.
|
||||
...(session.runDir ? { MOSAIC_UNSLOP_LOG: unslopLog(session.runDir) } : {}),
|
||||
...(session.proxyFirstTurn ? { MOSAIC_MODEL_EVENT_MONITOR: fileURLToPath(new URL('./first-output.mjs', import.meta.url)), MOSAIC_FIRST_OUTPUT_DIR: session.runDir } : {}),
|
||||
...(session.proxyFirstTurn ? { MOSAIC_MODEL_EVENT_MONITOR: 'managed', MOSAIC_FIRST_OUTPUT_DIR: session.runDir } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ test('a signalled model child exits 128 plus its signal number, an unmapped sign
|
||||
+ "cp.spawn = () => { const child = new EventEmitter(); child.stdout = new EventEmitter(); child.stdout.setEncoding = () => {}; child.kill = () => {};\n"
|
||||
+ " setImmediate(() => child.emit('close', null, process.env.FAKE_SIGNAL)); return child; };\n"
|
||||
+ "require('node:module').syncBuiltinESMExports();\n");
|
||||
const entry = new URL('../src/first-output.mjs', import.meta.url).pathname;
|
||||
const entry = new URL('../../plugins/harness/pi/model-stream.mjs', import.meta.url).pathname;
|
||||
for (const [signal, expected] of [['SIGKILL', 137], ['SIGTERM', 143], ['SIGUNKNOWN', 1]]) {
|
||||
const child = spawn(process.execPath, ['--require', fake, entry, 'pi', root, 'unused'], { env: { PATH: process.env.PATH, FAKE_SIGNAL: signal }, stdio: ['ignore', 'pipe', 'pipe'] });
|
||||
let stdout = '', stderr = '';
|
||||
|
||||
@@ -3,7 +3,7 @@ import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import * as output from '../src/first-output.mjs';
|
||||
import * as output from '../../plugins/harness/pi/model-stream.mjs';
|
||||
|
||||
for (const harness of ['pi']) {
|
||||
test(`${harness} counts a named tool call even when it has no input delta`, t => {
|
||||
@@ -46,7 +46,7 @@ test('monitor forwards only the answer and keeps model events private', async t
|
||||
const { fileURLToPath } = await import('node:url');
|
||||
const root = fs.mkdtempSync(join(tmpdir(), 'stream797-'));
|
||||
t.after(() => fs.rmSync(root, { recursive: true, force: true }));
|
||||
const monitor = fileURLToPath(new URL('../src/first-output.mjs', import.meta.url));
|
||||
const monitor = fileURLToPath(new URL('../../plugins/harness/pi/model-stream.mjs', import.meta.url));
|
||||
const producer = `console.log(JSON.stringify({type:'message_update',assistantMessageEvent:{type:'text_delta',delta:'private'}}));console.log(JSON.stringify({type:'agent_end',messages:[{role:'assistant',stopReason:'stop',content:[{type:'text',text:'answer'}]}]}))`;
|
||||
const child = spawn(process.execPath, [monitor, 'pi', root, process.execPath, '-e', producer], { stdio:['ignore','pipe','pipe'] });
|
||||
let stdout='', stderr=''; child.stdout.on('data', c => stdout += c); child.stderr.on('data', c => stderr += c);
|
||||
@@ -74,7 +74,7 @@ for (const [harness, parts, expected] of [
|
||||
const { fileURLToPath } = await import('node:url');
|
||||
const root = fs.mkdtempSync(join(tmpdir(), 'stream797-parity-'));
|
||||
t.after(() => fs.rmSync(root, { recursive: true, force: true }));
|
||||
const monitor = fileURLToPath(new URL('../src/first-output.mjs', import.meta.url));
|
||||
const monitor = fileURLToPath(new URL('../../plugins/harness/pi/model-stream.mjs', import.meta.url));
|
||||
const event = harness === 'pi'
|
||||
? {type:'agent_end',messages:[{role:'assistant',stopReason:'stop',content:parts.map(text => text === null ? {type:'toolCall',id:'t',name:'read'} : {type:'text',text})}]}
|
||||
: {type:'result',subtype:'success',result:parts.filter(x => x !== null).at(-1) ?? ''};
|
||||
|
||||
@@ -1045,3 +1045,32 @@ test("row 66 a refused send keeps the note: it rides the next RESULT the session
|
||||
assert.equal(next.body, 'env: fake-model\n\n[unslop: 1 reply of this session flagged since the last note: banned word "delve" x1. The session gets a correction notice on its next turn.]');
|
||||
assert.equal(ctx.inbox.length, 1);
|
||||
});
|
||||
|
||||
test('output policy is required and validated for new sessions while legacy metadata remains readable', async () => {
|
||||
const { harnessOk } = await import('../src/runner.mjs');
|
||||
const legacy = { turnEnd: 'marker', harnessEnv: {} };
|
||||
assert.equal(harnessOk(legacy), true);
|
||||
for (const outputPolicy of ['adapter', 'non-newline-stdout', 'stdout']) {
|
||||
assert.equal(harnessOk({ ...legacy, outputPolicyVersion: 1, outputPolicy }), true);
|
||||
}
|
||||
for (const session of [
|
||||
{ ...legacy, outputPolicyVersion: 1 },
|
||||
{ ...legacy, outputPolicyVersion: 1, outputPolicy: 'unknown' },
|
||||
{ ...legacy, outputPolicyVersion: 2, outputPolicy: 'stdout' },
|
||||
{ ...legacy, outputPolicy: 'stdout' },
|
||||
]) assert.equal(harnessOk(session), false);
|
||||
});
|
||||
|
||||
test('non-newline stdout policy only suppresses blank output for monitored proxy turns', async t => {
|
||||
for (const managed of [false, true]) {
|
||||
const ctx = await setup(t, { session: { turnEnd: 'exit', outputPolicyVersion: 1, outputPolicy: 'non-newline-stdout' } });
|
||||
if (managed) writeFileSync(join(ctx.runDir, 'proxy-first-turn-enabled'), 'enabled\n');
|
||||
ctx.inbox = [];
|
||||
writeFileSync(join(ctx.dir, 'adapter.sh'), "printf '\\n\\n'\n");
|
||||
const r = startRunner(ctx.runDir, ctx.cap);
|
||||
t.after(async () => { r.child.kill('SIGTERM'); await r.exited; });
|
||||
await ask(ctx);
|
||||
assert.equal(existsSync(join(ctx.runDir, 'proxy-first-output')), !managed);
|
||||
r.child.kill('SIGTERM'); await r.exited;
|
||||
}
|
||||
});
|
||||
@@ -20,7 +20,7 @@ loader.
|
||||
| `limit-check` | 2 | list | `interfaceVersion`, `mayLaunch`, `mustStop`, `report` |
|
||||
| `search-source` | 1 | one | `interfaceVersion`, `search` |
|
||||
| `channel` | 1 | list | `interfaceVersion`, `dispatch` |
|
||||
| `harness` | 1 | list | `interfaceVersion`, `adapter`, `levels`, `preflight`, `version`, `countsAccount`, `mounts`, `builtinWeb`, `builtins`, `typedName`, `reliesOn`, `gateTimeout`, `bundle`, `env`, `turnEnd`, `transcript` |
|
||||
| `harness` | 1 | list | `interfaceVersion`, `adapter`, `levels`, `preflight`, `version`, `countsAccount`, `mounts`, `builtinWeb`, `builtins`, `typedName`, `reliesOn`, `gateTimeout`, `bundle`, `env`, `turnEnd`, `outputPolicy`, `transcript` |
|
||||
|
||||
Every module exports `interfaceVersion`, equal to its kind's interface
|
||||
version, plus the kind's functions. PRD REQ-LIMIT-4 says what the two kinds
|
||||
@@ -150,7 +150,7 @@ export returns:
|
||||
- `countsAccount()` says whether its launches spend `launch.account` and get
|
||||
the row 126 account checks.
|
||||
- `mounts`, `builtinWeb`, `builtins`, `typedName`, `reliesOn`,
|
||||
`gateTimeout`, `bundle`, `env`, `turnEnd` and `transcript` give its
|
||||
`gateTimeout`, `bundle`, `env`, `turnEnd`, `outputPolicy` and `transcript` give its
|
||||
sandbox binds, web, tool names, S0 lines, bundle files, adapter variables,
|
||||
how a turn ends and where its transcripts land.
|
||||
- `compactions({store, cursors, budget, streams, first})` reads a thread
|
||||
@@ -391,3 +391,5 @@ It supplies proxy-labelled per-account numbers alongside the native per-key
|
||||
counts; it has no quota authority. See
|
||||
[the module contract](usage/cliproxy-queue/README.md) for poll settings, ID mapping,
|
||||
record separation, bounded reads and per-key quota settings.
|
||||
|
||||
A harness declares `outputPolicy({ proxy })` as `adapter`, `non-newline-stdout`, or `stdout`. The launcher validates and serializes that declaration; old sessions retain their recorded activity behavior.
|
||||
@@ -36,6 +36,7 @@ const GATE_TIMEOUT = Object.freeze({ n: 10, k: 2, hook: 20 });
|
||||
|
||||
export const adapter = () => join(REPO, "adapters", "claude", "adapter.sh");
|
||||
export const levels = () => LEVELS;
|
||||
export const outputPolicy = () => "adapter";
|
||||
|
||||
const executable = (path) => {
|
||||
try {
|
||||
|
||||
@@ -34,6 +34,7 @@ const RELIES_ON = Object.freeze(["S0-1 tool_call block", "S0-2 a throw blocks",
|
||||
|
||||
export const adapter = () => join(REPO, "adapters", "pi", "adapter.sh");
|
||||
export const levels = () => LEVELS;
|
||||
export const outputPolicy = ({ proxy }) => proxy ? "non-newline-stdout" : "stdout";
|
||||
|
||||
// The session runs pi from the repository's node_modules, which the sandbox mounts.
|
||||
export function preflight({ env = {}, proxy = null } = {}) {
|
||||
@@ -58,6 +59,7 @@ export function version() {
|
||||
// Pi sessions run on a provider key, never the Claude account limit.
|
||||
export const countsAccount = () => false;
|
||||
export const mounts = () => [
|
||||
{ src: join(REPO, "packages/plugins/harness/pi/model-stream.mjs"), why: "the managed model event stream" },
|
||||
{ src: realpathSync(join(REPO, "node_modules")), dest: join(REPO, "node_modules"), why: "pi and its packages, on the session's PATH" },
|
||||
...Object.values(UNSLOP).map((src) => ({ src, why: "the unslop check the session's second extension runs" })),
|
||||
];
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
import { firstOutputMarker } from '../../../harness/src/first-output.mjs';
|
||||
import { resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { constants } from 'node:os';
|
||||
// The managed Pi adapter uses this monitor to translate its native JSON event
|
||||
// streams back into the answer-only adapter contract. Startup, headers and
|
||||
// keepalives are not model output; substantive deltas and named tool calls count.
|
||||
export function modelEventStream({ runDir }) {
|
||||
const mark = firstOutputMarker(runDir);
|
||||
let pending = '', answer = null, failed = false;
|
||||
const line = value => {
|
||||
if (!value) return;
|
||||
const event = JSON.parse(value);
|
||||
const delta = event.type === 'message_update' && event.assistantMessageEvent;
|
||||
if (delta && ['text_delta', 'thinking_delta', 'toolcall_delta'].includes(delta.type) && typeof delta.delta === 'string' && delta.delta.length) mark(delta.delta);
|
||||
if (delta?.type === 'toolcall_start' && typeof delta.id === 'string' && delta.id.length && typeof delta.toolName === 'string' && delta.toolName.length) mark('output');
|
||||
if (event.type === 'agent_end') {
|
||||
const last = event.messages?.at(-1);
|
||||
if (last?.role === 'assistant') {
|
||||
failed = ['error', 'aborted'].includes(last.stopReason);
|
||||
answer = (last.content ?? []).filter(part => part.type === 'text').map(part => part.text + '\n').join('');
|
||||
}
|
||||
}
|
||||
};
|
||||
return {
|
||||
push(chunk) {
|
||||
pending += chunk;
|
||||
if (pending.length > 32 * 1024 * 1024) throw new Error('model event too large');
|
||||
let i; while ((i = pending.indexOf('\n')) !== -1) { line(pending.slice(0, i)); pending = pending.slice(i + 1); }
|
||||
},
|
||||
finish() {
|
||||
if (pending) line(pending);
|
||||
if (failed || typeof answer !== 'string') throw new Error('model stream did not complete');
|
||||
return answer;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// Invoked only by managed proxy adapter turns; the model CLI keeps its normal
|
||||
// process group and stderr, while stdout remains the final answer alone.
|
||||
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
||||
const [, , harness, runDir, command, ...args] = process.argv;
|
||||
const stream = modelEventStream({ harness, runDir });
|
||||
const child = spawn(command, args, { stdio: ['ignore', 'pipe', 'inherit'] });
|
||||
let bad = false;
|
||||
child.stdout.setEncoding('utf8');
|
||||
child.stdout.on('data', chunk => {
|
||||
if (bad) return;
|
||||
try { stream.push(chunk); }
|
||||
catch { bad = true; child.kill('SIGTERM'); }
|
||||
});
|
||||
child.on('error', () => { bad = true; });
|
||||
child.on('close', (code, signal) => {
|
||||
if (bad) { process.stderr.write('model event stream failed\n'); process.exitCode = 1; return; }
|
||||
if (signal) {
|
||||
process.stderr.write(`model child killed by ${signal}\n`);
|
||||
const number = constants.signals[signal];
|
||||
process.exitCode = Number.isInteger(number) && number > 0 ? 128 + number : 1;
|
||||
return;
|
||||
}
|
||||
if (code !== 0) { process.exitCode = code ?? 1; return; }
|
||||
try { process.stdout.write(stream.finish()); }
|
||||
catch { process.stderr.write('model event stream failed\n'); process.exitCode = 1; }
|
||||
});
|
||||
}
|
||||
@@ -63,13 +63,14 @@ export const KINDS = Object.freeze({
|
||||
// bundle({ dir, files, session, write, quote }) -> { files, digests, sources }, its own bundle files
|
||||
// env({ files, policy, tools, session }) -> its adapter variables, written into session.json
|
||||
// turnEnd() -> "marker" (a turn ends only with the turn marker) | "exit"
|
||||
// outputPolicy({ proxy }) -> "adapter" | "non-newline-stdout" | "stdout"
|
||||
// transcript({ runDir, store }) -> the directory its transcripts land in, for usage
|
||||
// compactions({ store, cursors, budget, streams, first }) -> { found, cursors, known, reason, version },
|
||||
// the session store's compactions past the ledger's cursors (row 307)
|
||||
harness: Object.freeze({
|
||||
kind: "harness", interfaceVersion: 1, switch: "list",
|
||||
exports: Object.freeze(["adapter", "levels", "preflight", "version", "countsAccount", "mounts", "builtinWeb", "builtins",
|
||||
"typedName", "reliesOn", "gateTimeout", "bundle", "env", "turnEnd", "transcript", "compactions"]),
|
||||
"typedName", "reliesOn", "gateTimeout", "bundle", "env", "turnEnd", "outputPolicy", "transcript", "compactions"]),
|
||||
}),
|
||||
// Optional proxy telemetry (row 333): read({ readUsageQueue }) -> the drained events. The bus
|
||||
// hands the module that one function and nothing else from its management client (R3).
|
||||
|
||||
@@ -47,6 +47,7 @@ test("row 65 each module answers for its own harness: adapter, levels, account,
|
||||
assert.deepEqual([pi.countsAccount(), claude.countsAccount()], [false, true]);
|
||||
assert.deepEqual([pi.builtinWeb(), claude.builtinWeb()], [false, true]);
|
||||
assert.deepEqual([pi.turnEnd(), claude.turnEnd()], ["marker", "exit"]);
|
||||
assert.deepEqual([pi.outputPolicy({ proxy: true }), pi.outputPolicy({ proxy: false }), claude.outputPolicy({ proxy: true }), claude.outputPolicy({ proxy: false })], ["non-newline-stdout", "stdout", "adapter", "adapter"]);
|
||||
assert.deepEqual([pi.typedName("list_tasks"), claude.typedName("list_tasks")], ["list_tasks", "mcp__mosaic__list_tasks"]);
|
||||
assert.equal(pi.gateTimeout(), null);
|
||||
assert.deepEqual(claude.gateTimeout(), { n: 10, k: 2, hook: 20 });
|
||||
@@ -103,7 +104,7 @@ test("row 65 pi preflight refuses missing credentials, and its version is the pa
|
||||
const pkg = JSON.parse(readFileSync(join(REPO, "package.json"), "utf8"));
|
||||
assert.equal(pi.version({ env: {} }), pkg.dependencies?.["@earendil-works/pi-coding-agent"] ?? pkg.devDependencies?.["@earendil-works/pi-coding-agent"]);
|
||||
// Row 66: the unslop extension's files, bound read-only at their own paths.
|
||||
assert.deepEqual(pi.mounts({ env: {} }).map(m => m.dest ?? m.src), [join(REPO, "node_modules"), ...["extension.ts", "unslop-check.js", "lists.json"].map(f => join(REPO, "tools", "unslop-hook", f))]);
|
||||
assert.deepEqual(pi.mounts({ env: {} }).map(m => m.dest ?? m.src), [join(REPO, "packages/plugins/harness/pi/model-stream.mjs"), join(REPO, "node_modules"), ...["extension.ts", "unslop-check.js", "lists.json"].map(f => join(REPO, "tools", "unslop-hook", f))]);
|
||||
});
|
||||
|
||||
test("row 65 env passes the thinking level to both adapters, and claude-code's bundle writes its hook and MCP files", async t => {
|
||||
@@ -216,6 +217,6 @@ test("row 65 no core source outside packages/plugins names a harness, apart from
|
||||
});
|
||||
|
||||
test("row 65 the grep's pattern catches a quoted name and a regex alternation, and not a word in prose", () => {
|
||||
for (const line of ['if (harness === "pi")', "x = 'claude-code';", "/^(pi|codex)$/", "/^(codex|claude-code)$/"]) assert.ok(NAMED.test(line), line);
|
||||
for (const line of ['if (harness === "pi")', "x = 'claude-code';", "/^(pi|codex)$/", "/^(codex|claude-code)$/", "if (harness !== 'pi')", "['pi', 'claude-code'].includes(harness)"]) assert.ok(NAMED.test(line), line);
|
||||
for (const line of ["// pi runs the bundle", "const piModel = 1;", "pipeline"]) assert.ok(!NAMED.test(line), line);
|
||||
});
|
||||
@@ -17,7 +17,7 @@ test("REQ-PLUG-1 REQ-LIMIT-4 the registry: usage-source at interface version 1,
|
||||
assert.deepEqual({ ...KINDS.harness, exports: [...KINDS.harness.exports] }, {
|
||||
kind: "harness", interfaceVersion: 1, switch: "list",
|
||||
exports: ["adapter", "levels", "preflight", "version", "countsAccount", "mounts", "builtinWeb", "builtins",
|
||||
"typedName", "reliesOn", "gateTimeout", "bundle", "env", "turnEnd", "transcript", "compactions"],
|
||||
"typedName", "reliesOn", "gateTimeout", "bundle", "env", "turnEnd", "outputPolicy", "transcript", "compactions"],
|
||||
});
|
||||
assert.ok(Object.isFrozen(KINDS.harness) && Object.isFrozen(KINDS.harness.exports));
|
||||
assert.ok(Object.isFrozen(KINDS) && Object.isFrozen(KINDS["usage-source"]) && Object.isFrozen(KINDS["limit-check"].exports));
|
||||
|
||||
Reference in new issue
Block a user