openclaw/scripts/lib/managed-handoff-build-config.mts
Peter Steinberger b107d4af14
fix: recover interrupted npm package updates (#158491)
Recover interrupted POSIX npm package publication with one durable journal and an external-Node helper. Keep database, configuration, and service recovery with their existing owners, and settle delegated children before releasing update authority.

Remove the unused state-generation engine, inverse migrations, private store transport, and their tests. The result reduces net PR growth by about 64%; production growth is 4,168 lines. Preserve the read-only legacy-journal route and its original-helper guidance.

Installed Crabbox proof at d1621807 covers the published 2026.9.6 updater, automatic same-schema rollback preserving acknowledged cron/transcript writes, and helper recovery after updater SIGKILL followed by an explicit Gateway restart. Final integration proof is recorded in the PR body with its exact source binding and limits.

Related: #142770. Full-state checkpoint replay and reverse database migrations remain separate; #144005 and #145169 remain open.

Co-authored-by: Jason (Json) <263060202+fuller-stack-dev@users.noreply.github.com>
2026-09-28 00:09:13 -07:00

56 lines
2.2 KiB
TypeScript

import { isBuiltin } from "node:module";
import { fileURLToPath } from "node:url";
import type { UserConfig } from "tsdown";
import { packageActivationRuntimeEntrypoint } from "../../src/infra/package-update-activation-runtime-assets.ts";
import { managedHandoffRuntimeEntrypoint } from "../../src/infra/update-managed-service-handoff-runtime-assets.ts";
import { createStateSchemaInlinePlugin } from "./state-schema-inline-plugin.mts";
/** The installed CLI and invocation compiler seal the same typed lease owner. */
export function createManagedHandoffBuildConfigs() {
return [managedHandoffRuntimeEntrypoint, packageActivationRuntimeEntrypoint].map((entry) =>
createSealedRecoveryBuildConfig(entry),
);
}
function createSealedRecoveryBuildConfig(entry: typeof managedHandoffRuntimeEntrypoint) {
const identityReader = fileURLToPath(
new URL("../../src/shared/freebsd-process-identity.ts", import.meta.url),
);
const privateNativeLoader = fileURLToPath(
new URL("../../src/infra/update-managed-service-handoff-native-loader.ts", import.meta.url),
);
return {
entry: {
[entry.distWorkerPath.replace(/\.mjs$/u, "")]: fileURLToPath(
new URL(`./${entry.sourceWorkerName}.ts`, entry.currentModuleUrl),
),
},
outDir: "dist",
format: "esm",
platform: "node",
target: "node22",
dts: false,
envPrefix: [],
define: { SEALED_RUNTIME_BUILD: "true" },
plugins: [
createStateSchemaInlinePlugin(),
{
name: "openclaw:managed-handoff-native-loader",
// All shared identity consumers in this bundle use the same private loader.
// Normal installations and sibling sealed builds keep their own loader policy.
resolveId(source, importer) {
return entry === managedHandoffRuntimeEntrypoint &&
source === "./freebsd-process-identity-native.ts" &&
importer === identityReader
? privateNativeLoader
: null;
},
},
],
deps: { alwaysBundle: (id) => !isBuiltin(id), onlyBundle: false },
outExtensions: () => ({ js: ".mjs" }),
outputOptions: { codeSplitting: false },
shims: true,
sourcemap: false,
} satisfies UserConfig;
}