diff --git a/plugins/ruflo-core/scripts/witness/lib.mjs b/plugins/ruflo-core/scripts/witness/lib.mjs index 57c9bac496..a802a8d9cb 100644 --- a/plugins/ruflo-core/scripts/witness/lib.mjs +++ b/plugins/ruflo-core/scripts/witness/lib.mjs @@ -21,8 +21,19 @@ import { createRequire } from 'node:module'; // install roots so the toolkit works in ruflo's monorepo layout *and* // a user's flat node_modules. function loadEd25519(probeRoots) { + // Expand caller-supplied roots with workspace-package locations so + // pnpm's isolated layout (where transitive deps don't hoist to the + // workspace root) still resolves @noble/ed25519. Callers don't need + // to know about this — the function just probes more places. + const expanded = [ + ...probeRoots, + ...probeRoots.flatMap(r => [ + join(r, 'v3/@claude-flow/cli'), + join(r, 'v3/@claude-flow/plugin-agent-federation'), + ]), + ]; let lastErr; - for (const root of probeRoots) { + for (const root of expanded) { try { const req = createRequire(join(root, 'noop.js')); const ed = req('@noble/ed25519'); @@ -37,7 +48,8 @@ function loadEd25519(probeRoots) { throw new Error( "Could not locate '@noble/ed25519'. Install it in your project " + "(npm i @noble/ed25519) or pass a node_modules root via the " + - "WITNESS_ED25519_ROOT env var. Last error: " + (lastErr?.message ?? '?') + "WITNESS_ED25519_ROOT env var. Probed: " + expanded.join(', ') + + ". Last error: " + (lastErr?.message ?? '?') ); } diff --git a/plugins/ruflo-core/scripts/witness/verify.mjs b/plugins/ruflo-core/scripts/witness/verify.mjs index cf87a8f4b9..48d27aefb1 100644 --- a/plugins/ruflo-core/scripts/witness/verify.mjs +++ b/plugins/ruflo-core/scripts/witness/verify.mjs @@ -83,11 +83,26 @@ process.exit(ok ? 0 : 1); // ─── ed25519 helpers ───────────────────────────────────────────── async function verifySignature(witness, repoRoot) { + // Probe multiple plausible install roots — pnpm's isolated linker + // doesn't hoist transitive deps to v3/node_modules, so we also check + // workspace packages that declare @noble/ed25519 directly. A user's + // flat npm install satisfies the first probe; pnpm satisfies the latter. let ed; - for (const root of [repoRoot, join(repoRoot, 'v3')]) { - try { ed = createRequire(join(root, 'noop.js'))('@noble/ed25519'); break; } catch { /* try next */ } + let probeErr; + const probes = [ + repoRoot, + join(repoRoot, 'v3'), + join(repoRoot, 'v3/@claude-flow/cli'), + join(repoRoot, 'v3/@claude-flow/plugin-agent-federation'), + ]; + for (const root of probes) { + try { ed = createRequire(join(root, 'noop.js'))('@noble/ed25519'); break; } + catch (e) { probeErr = e; } + } + if (!ed) { + console.error(`verify.mjs: could not load @noble/ed25519 from any of:\n ${probes.join('\n ')}\n last error: ${probeErr?.message ?? '?'}`); + return { manifestHashOk: false, publicKeyReproducible: false, signatureValid: false }; } - if (!ed) return { manifestHashOk: false, publicKeyReproducible: false, signatureValid: false }; ed.etc.sha512Sync = (...m) => { const h = createHash('sha512'); for (const x of m) h.update(x); return h.digest(); };