- Implement tests for random ID generation, ensuring preference for crypto.randomUUID. - Create tests for runtime context capabilities, validating the injection of enabled skill capabilities. - Add tests for skill capability parsing, including classification and command example extraction. - Introduce tests for the skill planner, verifying tool call planning based on user requests and attachment requirements. - Establish tests for UV setup, ensuring proper handling of Python installation scenarios and environment checks.
99 lines
2.5 KiB
JavaScript
99 lines
2.5 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import { existsSync } from 'node:fs';
|
|
import { spawnSync } from 'node:child_process';
|
|
import path from 'node:path';
|
|
|
|
const ROOT_DIR = path.resolve(import.meta.dirname, '..');
|
|
const BIN_ROOT = path.join(ROOT_DIR, 'resources', 'bin');
|
|
|
|
const PLATFORM_CONFIG = {
|
|
win32: {
|
|
scripts: ['uv:download:win', 'node:download:win'],
|
|
required: [
|
|
['win32-x64', 'uv.exe'],
|
|
['win32-x64', 'node.exe'],
|
|
['win32-arm64', 'uv.exe'],
|
|
['win32-arm64', 'node.exe'],
|
|
],
|
|
},
|
|
darwin: {
|
|
scripts: ['uv:download:mac'],
|
|
required: [
|
|
['darwin-x64', 'uv'],
|
|
['darwin-arm64', 'uv'],
|
|
],
|
|
},
|
|
linux: {
|
|
scripts: ['uv:download:linux'],
|
|
required: [
|
|
['linux-x64', 'uv'],
|
|
['linux-arm64', 'uv'],
|
|
],
|
|
},
|
|
};
|
|
|
|
function getMissingBinaries(requiredEntries) {
|
|
return requiredEntries
|
|
.map(([target, fileName]) => ({
|
|
target,
|
|
fileName,
|
|
filePath: path.join(BIN_ROOT, target, fileName),
|
|
}))
|
|
.filter(({ filePath }) => !existsSync(filePath));
|
|
}
|
|
|
|
function runPnpmScript(scriptName) {
|
|
const command = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm';
|
|
const result = spawnSync(command, ['run', scriptName], {
|
|
cwd: ROOT_DIR,
|
|
stdio: 'inherit',
|
|
windowsHide: true,
|
|
});
|
|
|
|
if (result.status !== 0) {
|
|
throw new Error(`Failed to run "${scriptName}" (exit=${result.status ?? 'unknown'})`);
|
|
}
|
|
}
|
|
|
|
function formatMissing(missingEntries) {
|
|
return missingEntries
|
|
.map(({ target, fileName }) => `${target}/${fileName}`)
|
|
.join(', ');
|
|
}
|
|
|
|
function main() {
|
|
const config = PLATFORM_CONFIG[process.platform];
|
|
if (!config) {
|
|
console.log(`[bundled-runtime] No bundled runtime requirements for platform ${process.platform}; skipping.`);
|
|
return;
|
|
}
|
|
|
|
let missing = getMissingBinaries(config.required);
|
|
if (missing.length === 0) {
|
|
console.log(`[bundled-runtime] All required bundled runtime binaries are present for ${process.platform}.`);
|
|
return;
|
|
}
|
|
|
|
console.log(`[bundled-runtime] Missing bundled runtime binaries: ${formatMissing(missing)}`);
|
|
for (const scriptName of config.scripts) {
|
|
runPnpmScript(scriptName);
|
|
}
|
|
|
|
missing = getMissingBinaries(config.required);
|
|
if (missing.length > 0) {
|
|
throw new Error(
|
|
`[bundled-runtime] Required binaries are still missing after download: ${formatMissing(missing)}`,
|
|
);
|
|
}
|
|
|
|
console.log(`[bundled-runtime] Bundled runtime binaries are ready for ${process.platform}.`);
|
|
}
|
|
|
|
try {
|
|
main();
|
|
} catch (error) {
|
|
console.error(error instanceof Error ? error.message : String(error));
|
|
process.exit(1);
|
|
}
|