Upgrade openclaw to 4.1 (#742)
This commit is contained in:
committed by
GitHub
Unverified
parent
5a3da41562
commit
06266cb4d2
@@ -575,7 +575,6 @@ exports.default = async function afterPack(context) {
|
||||
const BUNDLED_PLUGINS = [
|
||||
{ npmName: '@soimy/dingtalk', pluginId: 'dingtalk' },
|
||||
{ npmName: '@wecom/wecom-openclaw-plugin', pluginId: 'wecom' },
|
||||
{ npmName: '@tencent-connect/openclaw-qqbot', pluginId: 'qqbot' },
|
||||
{ npmName: '@larksuite/openclaw-lark', pluginId: 'feishu-openclaw-plugin' },
|
||||
{ npmName: '@tencent-weixin/openclaw-weixin', pluginId: 'openclaw-weixin' },
|
||||
];
|
||||
@@ -597,6 +596,63 @@ exports.default = async function afterPack(context) {
|
||||
}
|
||||
}
|
||||
|
||||
// 1.2 Copy built-in extension node_modules that electron-builder skipped.
|
||||
// OpenClaw 3.31+ ships built-in extensions (discord, qqbot, etc.) under
|
||||
// dist/extensions/<ext>/node_modules/. These are skipped by extraResources
|
||||
// because .gitignore contains "node_modules/".
|
||||
//
|
||||
// Extension code is loaded via shared chunks in dist/ (e.g. outbound-*.js)
|
||||
// which resolve modules from the top-level openclaw/node_modules/, NOT from
|
||||
// the extension's own node_modules/. So we must merge extension deps into
|
||||
// the top-level node_modules/ as well.
|
||||
const buildExtDir = join(__dirname, '..', 'build', 'openclaw', 'dist', 'extensions');
|
||||
const packExtDir = join(openclawRoot, 'dist', 'extensions');
|
||||
if (existsSync(buildExtDir)) {
|
||||
let extNMCount = 0;
|
||||
let mergedPkgCount = 0;
|
||||
for (const extEntry of readdirSync(buildExtDir, { withFileTypes: true })) {
|
||||
if (!extEntry.isDirectory()) continue;
|
||||
const srcNM = join(buildExtDir, extEntry.name, 'node_modules');
|
||||
if (!existsSync(srcNM)) continue;
|
||||
|
||||
// Copy to extension's own node_modules (for direct requires from extension code)
|
||||
const destExtNM = join(packExtDir, extEntry.name, 'node_modules');
|
||||
if (!existsSync(destExtNM)) {
|
||||
cpSync(srcNM, destExtNM, { recursive: true });
|
||||
}
|
||||
extNMCount++;
|
||||
|
||||
// Merge into top-level openclaw/node_modules/ (for shared chunks in dist/)
|
||||
for (const pkgEntry of readdirSync(srcNM, { withFileTypes: true })) {
|
||||
if (!pkgEntry.isDirectory() || pkgEntry.name === '.bin') continue;
|
||||
const srcPkg = join(srcNM, pkgEntry.name);
|
||||
const destPkg = join(dest, pkgEntry.name);
|
||||
|
||||
if (pkgEntry.name.startsWith('@')) {
|
||||
// Scoped package — iterate sub-entries
|
||||
for (const scopeEntry of readdirSync(srcPkg, { withFileTypes: true })) {
|
||||
if (!scopeEntry.isDirectory()) continue;
|
||||
const srcScoped = join(srcPkg, scopeEntry.name);
|
||||
const destScoped = join(destPkg, scopeEntry.name);
|
||||
if (!existsSync(destScoped)) {
|
||||
mkdirSync(dirname(destScoped), { recursive: true });
|
||||
cpSync(srcScoped, destScoped, { recursive: true });
|
||||
mergedPkgCount++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!existsSync(destPkg)) {
|
||||
cpSync(srcPkg, destPkg, { recursive: true });
|
||||
mergedPkgCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (extNMCount > 0) {
|
||||
console.log(`[after-pack] ✅ Copied node_modules for ${extNMCount} built-in extension(s), merged ${mergedPkgCount} packages into top-level.`);
|
||||
}
|
||||
}
|
||||
|
||||
// 2. General cleanup on the full openclaw directory (not just node_modules)
|
||||
console.log('[after-pack] 🧹 Cleaning up unnecessary files ...');
|
||||
const removedRoot = cleanupUnnecessaryFiles(openclawRoot);
|
||||
|
||||
@@ -38,7 +38,6 @@ function normWin(p) {
|
||||
const PLUGINS = [
|
||||
{ npmName: '@soimy/dingtalk', pluginId: 'dingtalk' },
|
||||
{ npmName: '@wecom/wecom-openclaw-plugin', pluginId: 'wecom' },
|
||||
{ npmName: '@tencent-connect/openclaw-qqbot', pluginId: 'qqbot' },
|
||||
{ npmName: '@larksuite/openclaw-lark', pluginId: 'feishu-openclaw-plugin' },
|
||||
{ npmName: '@tencent-weixin/openclaw-weixin', pluginId: 'openclaw-weixin' },
|
||||
];
|
||||
|
||||
@@ -458,34 +458,7 @@ function patchBrokenModules(nodeModulesDir) {
|
||||
].join('\n'),
|
||||
};
|
||||
const replacePatches = [
|
||||
{
|
||||
rel: '@mariozechner/pi-coding-agent/dist/core/bash-executor.js',
|
||||
search: ` const child = spawn(shell, [...args, command], {
|
||||
detached: true,
|
||||
env: getShellEnv(),
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
});`,
|
||||
replace: ` const child = spawn(shell, [...args, command], {
|
||||
detached: true,
|
||||
env: getShellEnv(),
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
windowsHide: true,
|
||||
});`,
|
||||
},
|
||||
{
|
||||
rel: '@mariozechner/pi-coding-agent/dist/core/exec.js',
|
||||
search: ` const proc = spawn(command, args, {
|
||||
cwd,
|
||||
shell: false,
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
});`,
|
||||
replace: ` const proc = spawn(command, args, {
|
||||
cwd,
|
||||
shell: false,
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
windowsHide: true,
|
||||
});`,
|
||||
},
|
||||
// Note: @mariozechner/pi-coding-agent is no longer a dep of openclaw 3.31.
|
||||
];
|
||||
|
||||
let count = 0;
|
||||
@@ -671,76 +644,9 @@ function patchBundledRuntime(outputDir) {
|
||||
\t\t}) ? { shell: true } : {}
|
||||
\t});`,
|
||||
},
|
||||
{
|
||||
label: 'agent scope command runner',
|
||||
target: () => findFirstFileByName(path.join(outputDir, 'dist', 'plugin-sdk'), /^agent-scope-.*\.js$/),
|
||||
search: `\tconst child = spawn(resolvedCommand, finalArgv.slice(1), {
|
||||
\t\tstdio,
|
||||
\t\tcwd,
|
||||
\t\tenv: resolvedEnv,
|
||||
\t\twindowsVerbatimArguments,
|
||||
\t\t...shouldSpawnWithShell({
|
||||
\t\t\tresolvedCommand,
|
||||
\t\t\tplatform: process$1.platform
|
||||
\t\t}) ? { shell: true } : {}
|
||||
\t});`,
|
||||
replace: `\tconst child = spawn(resolvedCommand, finalArgv.slice(1), {
|
||||
\t\tstdio,
|
||||
\t\tcwd,
|
||||
\t\tenv: resolvedEnv,
|
||||
\t\twindowsVerbatimArguments,
|
||||
\t\twindowsHide: true,
|
||||
\t\t...shouldSpawnWithShell({
|
||||
\t\t\tresolvedCommand,
|
||||
\t\t\tplatform: process$1.platform
|
||||
\t\t}) ? { shell: true } : {}
|
||||
\t});`,
|
||||
},
|
||||
{
|
||||
label: 'chrome launcher',
|
||||
target: () => findFirstFileByName(path.join(outputDir, 'dist', 'plugin-sdk'), /^chrome-.*\.js$/),
|
||||
search: `\t\treturn spawn(exe.path, args, {
|
||||
\t\t\tstdio: "pipe",
|
||||
\t\t\tenv: {
|
||||
\t\t\t\t...process.env,
|
||||
\t\t\t\tHOME: os.homedir()
|
||||
\t\t\t}
|
||||
\t\t});`,
|
||||
replace: `\t\treturn spawn(exe.path, args, {
|
||||
\t\t\tstdio: "pipe",
|
||||
\t\t\twindowsHide: true,
|
||||
\t\t\tenv: {
|
||||
\t\t\t\t...process.env,
|
||||
\t\t\t\tHOME: os.homedir()
|
||||
\t\t\t}
|
||||
\t\t});`,
|
||||
},
|
||||
{
|
||||
label: 'qmd runner',
|
||||
target: () => findFirstFileByName(path.join(outputDir, 'dist', 'plugin-sdk'), /^qmd-manager-.*\.js$/),
|
||||
search: `\t\t\tconst child = spawn(resolveWindowsCommandShim(this.qmd.command), args, {
|
||||
\t\t\t\tenv: this.env,
|
||||
\t\t\t\tcwd: this.workspaceDir
|
||||
\t\t\t});`,
|
||||
replace: `\t\t\tconst child = spawn(resolveWindowsCommandShim(this.qmd.command), args, {
|
||||
\t\t\t\tenv: this.env,
|
||||
\t\t\t\tcwd: this.workspaceDir,
|
||||
\t\t\t\twindowsHide: true
|
||||
\t\t\t});`,
|
||||
},
|
||||
{
|
||||
label: 'mcporter runner',
|
||||
target: () => findFirstFileByName(path.join(outputDir, 'dist', 'plugin-sdk'), /^qmd-manager-.*\.js$/),
|
||||
search: `\t\t\tconst child = spawn(resolveWindowsCommandShim("mcporter"), args, {
|
||||
\t\t\t\tenv: this.env,
|
||||
\t\t\t\tcwd: this.workspaceDir
|
||||
\t\t\t});`,
|
||||
replace: `\t\t\tconst child = spawn(resolveWindowsCommandShim("mcporter"), args, {
|
||||
\t\t\t\tenv: this.env,
|
||||
\t\t\t\tcwd: this.workspaceDir,
|
||||
\t\t\t\twindowsHide: true
|
||||
\t\t\t});`,
|
||||
},
|
||||
// Note: OpenClaw 3.31 removed the hash-suffixed agent-scope-*.js, chrome-*.js,
|
||||
// and qmd-manager-*.js files from dist/plugin-sdk/. Patches for those spawn
|
||||
// sites are no longer needed — the runtime now uses windowsHide natively.
|
||||
];
|
||||
|
||||
let count = 0;
|
||||
|
||||
Reference in New Issue
Block a user