openclaw/scripts/lib/plugin-asset-command.mts
Peter Steinberger 5e81e62b87
perf(build): avoid duplicate isolated asset generation (#162997)
* perf(build): generate isolated plugin assets once

* fix(build): bound isolated plugin asset execution

* test(ui): inherit model picker readiness fix

Apply the existing fixture correction from dd2a7baba6 (#162869). The picker can be visible while its controls still await catalog hydration; assert readiness before interacting.

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-10-01 23:29:41 -05:00

34 lines
1,018 B
TypeScript

// Keep asset deadlines and child cleanup identical across root and isolated builds.
import { runManagedCommand } from "./managed-child-process.mts";
const PLUGIN_ASSET_HOOK_TIMEOUT_MS = 600_000;
export async function runPluginAssetCommand(params: {
command: string;
cwd: string;
pluginId: string;
phase: "build" | "copy";
}): Promise<number> {
try {
return await runManagedCommand({
bin: params.command,
cwd: params.cwd,
env: process.env,
shell: true,
stdio: "inherit",
timeoutMs: PLUGIN_ASSET_HOOK_TIMEOUT_MS,
requireProcessTreeExit: process.platform !== "win32",
});
} catch (error) {
if (error && typeof error === "object" && "code" in error && error.code === "ETIMEDOUT") {
throw Object.assign(
new Error(
`Plugin asset ${params.phase} hook timed out after ${PLUGIN_ASSET_HOOK_TIMEOUT_MS}ms: ${params.pluginId}`,
{ cause: error },
),
{ code: "ETIMEDOUT" },
);
}
throw error;
}
}