// --- UNIX LINKER INTERCEPT (TIER 1 & TIER 3) ---
const providerName = node.provider ? node.provider.toLowerCase() : '';
if (providerName === 'library' || providerName === 'stable') {
const isStable = providerName === 'stable';
console.log(` [LINKER] Mounting artifact from ${isStable ?
'Stable Core' : 'Alpha Library'}: ${node.id}`);
// Route to the correct source directory based on the provider tag
const sourceDir = isStable
? path.join(__dirname, 'kernel', 'stable')
: path.join(__dirname, 'library');
const libPath = path.join(sourceDir, `${node.id}.js`);
if (!fs.existsSync(libPath)) {
throw new Error(`[KERNEL PANIC] Linker requested ${node.id},
but it is missing from ${sourceDir}!`);
}
// 1. Copy the executable binary to the volatile build folder
fs.copyFileSync(libPath, STATE_MANAGER.getFilePath(node.id));
// 2. Load it into the State Manager for subsequent dependencies
const libCode = fs.readFileSync(libPath, 'utf-8');
STATE_MANAGER.writeArtifact(node.id, libCode);
console.log(` [STATE] Registered ${node.id} to execution
environment.
`);
continue; // Skip the API call and move to the next node!
}
// -----------------------------------------------