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:
@@ -29,7 +29,6 @@
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { builtinModules } from 'node:module';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
@@ -40,18 +39,6 @@ const resourcesDir = path.join(root, 'app', 'src-tauri', 'resources');
|
||||
const metaFile = path.join(os.tmpdir(), 'waggle-sidecar-meta.json');
|
||||
const stageDir = path.join(resourcesDir, 'node_modules');
|
||||
const bundledNpmRuntimeDir = path.join(stageDir, 'waggle-node-runtime');
|
||||
const hookRuntimeBuild = path.join(root, 'scripts', 'build-hook-runtime.mjs');
|
||||
const HOOK_RUNTIME_ROOTS = new Set([
|
||||
'@waggle/hive-mind-cli',
|
||||
'@waggle/hive-mind-hooks-claude-code',
|
||||
'@waggle/hive-mind-hooks-claude-desktop',
|
||||
'@waggle/hive-mind-hooks-codex',
|
||||
'@waggle/hive-mind-hooks-codex-desktop',
|
||||
'@waggle/hive-mind-hooks-cursor',
|
||||
'@waggle/hive-mind-hooks-hermes',
|
||||
'@waggle/hive-mind-hooks-openclaw',
|
||||
'waggle-memory-mcp',
|
||||
]);
|
||||
// These are loaded through computed require() calls, so esbuild's metafile
|
||||
// cannot discover them even though installed desktop features require them.
|
||||
const DYNAMIC_RUNTIME_ROOTS = new Set(['adm-zip']);
|
||||
@@ -109,9 +96,8 @@ const RUNTIME_PRUNED_DIR_NAMES = new Set([
|
||||
]);
|
||||
const SOURCE_ARTIFACT_PATTERN = /(?:\.map|\.(?:[cm]?ts|tsx)|\.tsbuildinfo)$/i;
|
||||
const WORKSPACE_RUNTIME_ENTRY_PATTERN = /^(?:dist|package\.json|licen[cs]e(?:\.(?:md|txt))?|notice(?:\.(?:md|txt))?)$/i;
|
||||
const MANUAL_WORKSPACE_RUNTIME_TARGETS = new Map([
|
||||
['@waggle/hive-mind-hooks-openclaw', ['dist/handler.bundle.cjs']],
|
||||
]);
|
||||
// Runtime files of a staged workspace package that its manifest does not name.
|
||||
const MANUAL_WORKSPACE_RUNTIME_TARGETS = new Map();
|
||||
const WINDOWS_1252_EXTRA_CODEPOINTS = new Set([
|
||||
0x20ac, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021, 0x02c6, 0x2030,
|
||||
0x0160, 0x2039, 0x0152, 0x017d, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022,
|
||||
@@ -168,6 +154,26 @@ function resolvePkgDir(name, fromDir) {
|
||||
}
|
||||
}
|
||||
|
||||
const WORKSPACE_DIRS = ['packages', 'apps'].flatMap((base) => {
|
||||
const dir = path.join(root, base);
|
||||
return fs.existsSync(dir) ? fs.readdirSync(dir).map((name) => path.join(dir, name)) : [];
|
||||
});
|
||||
|
||||
/**
|
||||
* Resolve a bundle root. npm keeps a package inside the workspace that depends
|
||||
* on it when it cannot hoist it (mem0ai stays in packages/memory-mem0), so look
|
||||
* in the workspaces when the repo root does not have it.
|
||||
*/
|
||||
function resolveRootPkgDir(name) {
|
||||
const fromRoot = resolvePkgDir(name, root);
|
||||
if (fromRoot) return fromRoot;
|
||||
for (const workspaceDir of WORKSPACE_DIRS) {
|
||||
const candidate = path.join(workspaceDir, 'node_modules', name);
|
||||
if (fs.existsSync(path.join(candidate, 'package.json'))) return candidate;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
let copiedPackages = 0;
|
||||
let prunedRuntimeDirs = 0;
|
||||
let prunedRuntimeFiles = 0;
|
||||
@@ -243,16 +249,18 @@ function readManifest(pkgDir) {
|
||||
*/
|
||||
function stageClosure(rootNames) {
|
||||
const processedDirs = new Set();
|
||||
const queue = [...rootNames].map((name) => ({ name, fromDir: root }));
|
||||
const queue = [...rootNames].map((name) => ({ name, fromDir: null }));
|
||||
const absentRoots = [];
|
||||
|
||||
while (queue.length > 0) {
|
||||
const { name, fromDir } = queue.shift();
|
||||
if (SKIP.has(name)) continue;
|
||||
|
||||
const pkgDir = resolvePkgDir(name, fromDir);
|
||||
const pkgDir = fromDir === null ? resolveRootPkgDir(name) : resolvePkgDir(name, fromDir);
|
||||
if (!pkgDir) {
|
||||
// Optional/absent (e.g. bufferutil, utf-8-validate, pg): the bundle
|
||||
// guards these or never reaches them — nothing to stage.
|
||||
if (fromDir === null) absentRoots.push(name);
|
||||
continue;
|
||||
}
|
||||
const pkgKey = fs.realpathSync.native(pkgDir);
|
||||
@@ -267,6 +275,9 @@ function stageClosure(rootNames) {
|
||||
queue.push({ name: dep, fromDir: pkgDir });
|
||||
}
|
||||
}
|
||||
if (absentRoots.length) {
|
||||
console.log(`[stage-sidecar-deps] not installed, not staged: ${absentRoots.sort().join(', ')}`);
|
||||
}
|
||||
return processedDirs;
|
||||
}
|
||||
|
||||
@@ -622,11 +633,6 @@ function preserveBundledNpmRuntime() {
|
||||
// ── main ───────────────────────────────────────────────────────────
|
||||
console.log(`[stage-sidecar-deps] Platform: ${platform}-${arch}`);
|
||||
|
||||
// These workspace packages are loaded by hook installers/external agents, not
|
||||
// by the sidecar bundle itself, so the esbuild metafile cannot discover them.
|
||||
// Build them explicitly before copying their production dependency closure.
|
||||
execFileSync(process.execPath, [hookRuntimeBuild], { cwd: root, stdio: 'inherit' });
|
||||
|
||||
// Fresh stage dir each run so a removed dep never lingers in a stale bundle.
|
||||
const preservedNpmRuntime = preserveBundledNpmRuntime();
|
||||
try {
|
||||
@@ -643,7 +649,6 @@ try {
|
||||
const externals = readExternalPackages();
|
||||
const runtimeRoots = new Set([
|
||||
...externals,
|
||||
...HOOK_RUNTIME_ROOTS,
|
||||
...DYNAMIC_RUNTIME_ROOTS,
|
||||
]);
|
||||
const staged = [...runtimeRoots].filter((n) => !SKIP.has(n)).sort();
|
||||
|
||||
Reference in New Issue
Block a user