Back up unknown legacy Agents, reconnect settled Conversation observation, remove remaining active repository residue, and restore the bundled Python verifier import.
41 lines
1.6 KiB
JavaScript
41 lines
1.6 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import { spawnSync } from 'node:child_process';
|
|
import path from 'node:path';
|
|
import { getPythonTarget, PYTHON_VERSION } from './bundled-python-manifest.mjs';
|
|
|
|
function readOption(name) {
|
|
const prefix = `--${name}=`;
|
|
const inline = process.argv.find((value) => value.startsWith(prefix));
|
|
if (inline) return inline.slice(prefix.length);
|
|
const index = process.argv.indexOf(`--${name}`);
|
|
return index >= 0 ? process.argv[index + 1] : undefined;
|
|
}
|
|
|
|
function runProbe(executable, label, args) {
|
|
const result = spawnSync(executable, args, { encoding: 'utf8', windowsHide: true });
|
|
if (result.status !== 0) {
|
|
const detail = String(result.stderr || result.stdout || result.error?.message || 'unknown error').trim();
|
|
throw new Error(`${label} failed: ${detail}`);
|
|
}
|
|
process.stdout.write(`[python] ${label}: ${String(result.stdout || result.stderr).trim()}\n`);
|
|
}
|
|
|
|
const targetId = readOption('target');
|
|
const root = readOption('root');
|
|
if (!targetId || !root) {
|
|
process.stderr.write('Usage: verify-bundled-python.mjs --root <target-root> --target <target-id>\n');
|
|
process.exit(2);
|
|
}
|
|
|
|
try {
|
|
const target = getPythonTarget(targetId);
|
|
const executable = path.resolve(root, target.executable);
|
|
runProbe(executable, 'version', ['--version']);
|
|
runProbe(executable, 'stdlib', ['-c', "import json, pathlib, urllib.request; print('stdlib-ok')"]);
|
|
process.stdout.write(`[python] ${targetId} verified for Python ${PYTHON_VERSION}\n`);
|
|
} catch (error) {
|
|
process.stderr.write(`[python] ${targetId} verification failed: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
process.exit(1);
|
|
}
|