mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 11:40:42 +00:00
fix(plugins): normalize windows override imports
This commit is contained in:
@@ -566,6 +566,17 @@ async function runFreshLane(params) {
|
||||
logPath: join(params.logsDir, "fresh-install.log"),
|
||||
});
|
||||
|
||||
let browserOverrideImportStatus = "skipped";
|
||||
if (shouldRunWindowsInstalledBrowserOverrideImportSmoke()) {
|
||||
logLanePhase(lane, "windows-browser-override-import");
|
||||
browserOverrideImportStatus = await runInstalledBrowserOverrideImportSmoke({
|
||||
lane,
|
||||
env,
|
||||
prefixDir: lane.prefixDir,
|
||||
logPath: join(params.logsDir, "fresh-windows-browser-override-import.log"),
|
||||
});
|
||||
}
|
||||
|
||||
logLanePhase(lane, "onboard");
|
||||
await runOnboard({
|
||||
lane,
|
||||
@@ -617,6 +628,7 @@ async function runFreshLane(params) {
|
||||
installedCommit: installed.commit,
|
||||
dashboardStatus: "pass",
|
||||
gatewayPort: lane.gatewayPort,
|
||||
browserOverrideImportStatus,
|
||||
agentOutput: trimForSummary(agent.stdout),
|
||||
};
|
||||
} finally {
|
||||
@@ -795,6 +807,17 @@ async function runInstallerFreshSuite(params) {
|
||||
const installed = readInstalledMetadataFromCliPath(freshShell.cliPath);
|
||||
verifyInstalledCandidate(installed, params.build);
|
||||
|
||||
let browserOverrideImportStatus = "skipped";
|
||||
if (shouldRunWindowsInstalledBrowserOverrideImportSmoke()) {
|
||||
logLanePhase(lane, "windows-browser-override-import");
|
||||
browserOverrideImportStatus = await runInstalledBrowserOverrideImportSmoke({
|
||||
lane,
|
||||
env,
|
||||
prefixDir: resolveInstalledPrefixDirFromCliPath(freshShell.cliPath),
|
||||
logPath: join(params.logsDir, "installer-fresh-windows-browser-override-import.log"),
|
||||
});
|
||||
}
|
||||
|
||||
logLanePhase(lane, "onboard");
|
||||
await runOnboardWithInstalledCli({
|
||||
lane,
|
||||
@@ -900,6 +923,7 @@ async function runInstallerFreshSuite(params) {
|
||||
installedCommit: installed.commit,
|
||||
gatewayPort: lane.gatewayPort,
|
||||
dashboardStatus: "pass",
|
||||
browserOverrideImportStatus,
|
||||
discordStatus,
|
||||
agentOutput: trimForSummary(agent.stdout),
|
||||
};
|
||||
@@ -2200,6 +2224,100 @@ async function runBundledPluginPostinstall(params) {
|
||||
});
|
||||
}
|
||||
|
||||
export function shouldRunWindowsInstalledBrowserOverrideImportSmoke(platform = process.platform) {
|
||||
return platform === "win32";
|
||||
}
|
||||
|
||||
export function buildInstalledBrowserOverrideImportProbeScript() {
|
||||
return `
|
||||
import { existsSync } from "node:fs";
|
||||
import { startLazyPluginServiceModule } from "openclaw/plugin-sdk/browser-node-runtime";
|
||||
|
||||
const startedPath = process.env.OPENCLAW_BROWSER_OVERRIDE_STARTED_PATH;
|
||||
const stoppedPath = process.env.OPENCLAW_BROWSER_OVERRIDE_STOPPED_PATH;
|
||||
|
||||
if (!process.env.OPENCLAW_BROWSER_CONTROL_MODULE) {
|
||||
throw new Error("Missing OPENCLAW_BROWSER_CONTROL_MODULE.");
|
||||
}
|
||||
if (!startedPath || !stoppedPath) {
|
||||
throw new Error("Missing browser override sentinel path env.");
|
||||
}
|
||||
|
||||
const handle = await startLazyPluginServiceModule({
|
||||
overrideEnvVar: "OPENCLAW_BROWSER_CONTROL_MODULE",
|
||||
validateOverrideSpecifier: (specifier) => specifier,
|
||||
loadDefaultModule: async () => {
|
||||
throw new Error("Default browser control service should not load during override probe.");
|
||||
},
|
||||
startExportNames: ["startBrowserControlService"],
|
||||
stopExportNames: ["stopBrowserControlService"],
|
||||
});
|
||||
|
||||
if (!handle) {
|
||||
throw new Error("Browser control override probe did not return a service handle.");
|
||||
}
|
||||
if (!existsSync(startedPath)) {
|
||||
throw new Error("Browser control override start sentinel was not written.");
|
||||
}
|
||||
|
||||
await handle.stop();
|
||||
|
||||
if (!existsSync(stoppedPath)) {
|
||||
throw new Error("Browser control override stop sentinel was not written.");
|
||||
}
|
||||
|
||||
console.log("windows browser override import OK");
|
||||
`.trim();
|
||||
}
|
||||
|
||||
function buildBrowserOverrideProbeServiceModule() {
|
||||
return `
|
||||
import { writeFileSync } from "node:fs";
|
||||
|
||||
export async function startBrowserControlService() {
|
||||
writeFileSync(process.env.OPENCLAW_BROWSER_OVERRIDE_STARTED_PATH, "started\\n", "utf8");
|
||||
}
|
||||
|
||||
export async function stopBrowserControlService() {
|
||||
writeFileSync(process.env.OPENCLAW_BROWSER_OVERRIDE_STOPPED_PATH, "stopped\\n", "utf8");
|
||||
}
|
||||
`.trim();
|
||||
}
|
||||
|
||||
async function runInstalledBrowserOverrideImportSmoke(params) {
|
||||
if (!shouldRunWindowsInstalledBrowserOverrideImportSmoke()) {
|
||||
return "skipped";
|
||||
}
|
||||
|
||||
const probeDir = join(params.lane.rootDir, "browser override import probe");
|
||||
mkdirSync(probeDir, { recursive: true });
|
||||
const overridePath = join(probeDir, "browser override #module.mjs");
|
||||
const probePath = join(probeDir, "run browser override probe.mjs");
|
||||
const startedPath = join(probeDir, "started.txt");
|
||||
const stoppedPath = join(probeDir, "stopped.txt");
|
||||
|
||||
writeFileSync(overridePath, `${buildBrowserOverrideProbeServiceModule()}\n`, "utf8");
|
||||
writeFileSync(probePath, `${buildInstalledBrowserOverrideImportProbeScript()}\n`, "utf8");
|
||||
|
||||
await runCommand(process.execPath, [probePath], {
|
||||
cwd: installedPackageRoot(params.prefixDir),
|
||||
env: {
|
||||
...params.env,
|
||||
OPENCLAW_BROWSER_CONTROL_MODULE: overridePath,
|
||||
OPENCLAW_BROWSER_OVERRIDE_STARTED_PATH: startedPath,
|
||||
OPENCLAW_BROWSER_OVERRIDE_STOPPED_PATH: stoppedPath,
|
||||
},
|
||||
logPath: params.logPath,
|
||||
timeoutMs: 60_000,
|
||||
});
|
||||
|
||||
if (!existsSync(startedPath) || !existsSync(stoppedPath)) {
|
||||
throw new Error("Browser control override import probe did not write both sentinels.");
|
||||
}
|
||||
|
||||
return "pass";
|
||||
}
|
||||
|
||||
function ensureLocalNpmShim(lane) {
|
||||
const shimPath = npmShimPath(lane.prefixDir);
|
||||
if (existsSync(shimPath)) {
|
||||
|
||||
Reference in New Issue
Block a user