build: package the sidecar without the legacy memory runtime (P1.5, P1.3b)

- Stop building and staging the hive-mind CLI, the coding-agent hook
  packages and the memory MCP server: the hooks, Waggle Room and the
  memory MCP server are hidden in v1 (ADR-0002) and all of them write to
  the legacy .mind files.
- Drop sqlite-vec: nothing loads a SQLite extension since the legacy
  memory engine left. bundle-native-deps no longer copies vec0, the
  resource check no longer probes it, the Tauri shell no longer sets
  WAGGLE_SQLITE_VEC_PATH and install.sh checks plain SQLite.
- Stage bundle roots that npm keeps inside a workspace. mem0ai is not
  hoisted (it stays in packages/memory-mem0), so staging skipped it
  silently and the packaged sidecar would fail on the first memory
  access. Roots that are not installed are now listed in the output.
- js-yaml is a runtime dependency of Puppeteer's config loader since the
  WhatsApp channel moved to whatsapp-web.js (ADR-0005); it leaves the
  resource-check denylist. chromium-bidi stays unstaged: Puppeteer loads
  it only for WebDriver BiDi sessions.
This commit is contained in:
shumeiko.it
2026-10-24 16:37:48 +02:00
parent e435e7da94
commit bbfb3c7f82
6 changed files with 60 additions and 119 deletions

View File

@@ -33,9 +33,8 @@ const targetArch = process.env.TARGET_ARCH || process.arch;
const SIDECAR_PROVENANCE_PREFIX = '// Waggle-Sidecar-Provenance: ';
const SOURCE_ARTIFACT_PATTERN = /(?:\.map|\.(?:[cm]?ts|tsx)|\.tsbuildinfo)$/i;
const FIRST_PARTY_RUNTIME_ENTRY_PATTERN = /^(?:dist|package\.json|licen[cs]e(?:\.(?:md|txt))?|notice(?:\.(?:md|txt))?)$/i;
const MANUAL_FIRST_PARTY_RUNTIME_TARGETS = new Map([
['@waggle/hive-mind-hooks-openclaw', ['dist/handler.bundle.cjs']],
]);
// Runtime files of a staged first-party package that its manifest does not name.
const MANUAL_FIRST_PARTY_RUNTIME_TARGETS = new Map();
const REQUIRED_SHARP_VERSION = '0.35.3';
const REQUIRED_BETTER_SQLITE_RANGE = '>=12.6.2 <13';
const STAGED_DEPENDENCY_VERSION_ALLOWLISTS = new Map([
@@ -43,7 +42,10 @@ const STAGED_DEPENDENCY_VERSION_ALLOWLISTS = new Map([
['fast-uri', new Set(['3.1.5'])],
['ip-address', new Set(['10.4.0'])],
]);
const STAGED_DEPENDENCY_DENYLIST = new Set(['js-yaml']);
// Packages that must never reach the installer. js-yaml left this list with the
// WhatsApp channel (ADR-0005): Puppeteer reads its config through cosmiconfig,
// which parses YAML with it at runtime.
const STAGED_DEPENDENCY_DENYLIST = new Set();
const missing = [];
const unsafe = [];
@@ -717,7 +719,6 @@ const nativeEntries = fs.existsSync(nativeDir)
: [];
const requiredWindowsNativeFiles = [
'better_sqlite3.node',
'vec0.dll',
'onnxruntime/onnxruntime_binding.node',
];
if (process.platform === 'win32') {
@@ -731,7 +732,6 @@ if (process.platform === 'win32') {
} else if (process.platform === 'darwin') {
const requiredMacNativeFiles = [
'better_sqlite3.node',
'vec0.dylib',
'onnxruntime/onnxruntime_binding.node',
];
for (const entry of requiredMacNativeFiles) {
@@ -772,10 +772,6 @@ const stagedSharpWindowsBinding = path.join(
'lib',
`sharp-win32-x64-${REQUIRED_SHARP_VERSION}.node`,
);
const vecExtension = path.join(
nativeDir,
`vec0.${process.platform === 'win32' ? 'dll' : process.platform === 'darwin' ? 'dylib' : 'so'}`,
);
if (!fs.existsSync(path.join(stagedBetterSqlite, 'package.json'))) {
missing.push('resources/node_modules/* (run: node scripts/stage-sidecar-deps.mjs)');
}
@@ -902,20 +898,16 @@ if (
fs.existsSync(nodePath)
&& fs.existsSync(path.join(stagedBetterSqlite, 'package.json'))
&& fs.existsSync(path.join(stagedOnnxRuntime, 'package.json'))
&& fs.existsSync(vecExtension)
) {
try {
const probe = [
'const Database = require(process.argv[1]);',
'if (process.arch !== process.argv[2]) throw new Error(`architecture ${process.arch}`);',
'const database = new Database(\':memory:\');',
'database.loadExtension(process.argv[3]);',
'const row = database.prepare(\'SELECT 1 AS ok\').get();',
'const vec = database.prepare(\'SELECT vec_version() AS version\').get();',
'database.close();',
'if (row.ok !== 1) throw new Error(\'SQLite query failed\');',
'if (typeof vec.version !== \'string\' || vec.version.length === 0) throw new Error(\'sqlite-vec query failed\');',
'const onnx = require(process.argv[4]);',
'const onnx = require(process.argv[3]);',
'if (typeof onnx.InferenceSession !== \'function\') throw new Error(\'ONNX binding failed\');',
].join('');
execFileSync(nodePath, [
@@ -923,7 +915,6 @@ if (
probe,
stagedBetterSqlite,
targetArch,
vecExtension,
stagedOnnxRuntime,
], {
cwd: resourcesDir,
@@ -932,32 +923,12 @@ if (
});
} catch {
missing.push(
`resources native runtime probe failed for better-sqlite3, sqlite-vec, or onnxruntime-node `
`resources native runtime probe failed for better-sqlite3 or onnxruntime-node `
+ `using bundled ${nodeBinary} for ${targetArch}`,
);
}
}
// External agents and hook management run directly from this staged payload;
// none of these packages are available from npm in a packaged installation.
const hookRuntimeEntries = [
'@waggle/hive-mind-cli/dist/index.js',
'@waggle/hive-mind-hooks-claude-code/dist/bin/claude-code-hooks-cli.js',
'@waggle/hive-mind-hooks-claude-desktop/dist/bin/claude-desktop-hooks.js',
'@waggle/hive-mind-hooks-codex/dist/bin/codex-hooks.js',
'@waggle/hive-mind-hooks-codex-desktop/dist/bin/codex-desktop-hooks.js',
'@waggle/hive-mind-hooks-cursor/dist/bin/cursor-hooks.js',
'@waggle/hive-mind-hooks-hermes/dist/bin/hermes-hooks.js',
'@waggle/hive-mind-hooks-openclaw/dist/bin/openclaw-hooks.js',
'@waggle/hive-mind-hooks-openclaw/dist/handler.bundle.cjs',
'waggle-memory-mcp/dist/index.js',
];
for (const entry of hookRuntimeEntries) {
if (!fs.existsSync(path.join(stagedDepsDir, ...entry.split('/')))) {
missing.push(`resources/node_modules/${entry} (run: node scripts/stage-sidecar-deps.mjs)`);
}
}
if (missing.length > 0 || unsafe.length > 0) {
console.error('[check-sidecar-resources] FATAL — sidecar resources are not release-safe:');
for (const m of missing) console.error(` - ${m}`);