fix(tool): flatten resolveChildModel adapter, remove unsafe cast, add compatibility shim and comments
This commit is contained in:
48
debug-run-wrapper.js
Normal file
48
debug-run-wrapper.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import { mkdtemp, writeFile, chmod } from 'node:fs/promises';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { dirname } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
async function run() {
|
||||
const dir = await mkdtemp(join(tmpdir(), 'pi-subagents-wrapper-'));
|
||||
const metaPath = join(dir, 'meta.json');
|
||||
const resultPath = join(dir, 'result.json');
|
||||
const capturePath = join(dir, 'capture.json');
|
||||
const piPath = join(dir, 'pi');
|
||||
|
||||
await writeFile(piPath, `#!${process.execPath}\nconst fs = require('fs');\nconst capturePath = ${JSON.stringify(capturePath)};\nconst obj = { PI_SUBAGENTS_GITHUB_COPILOT_INITIATOR: process.env.PI_SUBAGENTS_GITHUB_COPILOT_INITIATOR || '', PI_SUBAGENTS_CHILD: process.env.PI_SUBAGENTS_CHILD || '', argv: process.argv.slice(2) }; fs.writeFileSync(capturePath, JSON.stringify(obj), 'utf8'); console.log(JSON.stringify({type:'message_end',message:{role:'assistant',content:[{type:'text',text:'done'}],model:'github-copilot/gpt-4o',stopReason:'stop'}}));`, 'utf8');
|
||||
await chmod(piPath, 0o755);
|
||||
|
||||
const meta = {
|
||||
runId: 'run-1',
|
||||
mode: 'single',
|
||||
task: 'inspect auth',
|
||||
cwd: dir,
|
||||
requestedModel: 'github-copilot/gpt-4o',
|
||||
resolvedModel: 'github-copilot/gpt-4o',
|
||||
startedAt: '2026-04-09T00:00:00.000Z',
|
||||
sessionPath: join(dir, 'child-session.jsonl'),
|
||||
eventsPath: join(dir, 'events.jsonl'),
|
||||
resultPath,
|
||||
stdoutPath: join(dir, 'stdout.log'),
|
||||
stderrPath: join(dir, 'stderr.log'),
|
||||
transcriptPath: join(dir, 'transcript.log'),
|
||||
tools: ['read', 'grep'],
|
||||
systemPromptPath: join(dir, 'system-prompt.md'),
|
||||
};
|
||||
|
||||
await writeFile(metaPath, JSON.stringify(meta, null, 2), 'utf8');
|
||||
|
||||
const wrapperPath = join(dirname(fileURLToPath(import.meta.url)), 'src/wrapper/cli.mjs');
|
||||
console.log('wrapperPath', wrapperPath, 'metaPath', metaPath);
|
||||
const child = spawn(process.execPath, [wrapperPath, metaPath], { env: { ...process.env, PATH: dir }, stdio: ['ignore','pipe','pipe'] });
|
||||
|
||||
child.stdout.on('data', (c) => console.log('wrapper stdout:', c.toString()));
|
||||
child.stderr.on('data', (c) => console.error('wrapper stderr:', c.toString()));
|
||||
|
||||
child.on('close', (code) => { console.log('wrapper exited', code); process.exit(code ?? 0); });
|
||||
}
|
||||
|
||||
run().catch(err => { console.error(err); process.exit(1); });
|
||||
Reference in New Issue
Block a user