mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-17 16:12:21 -06:00
964c8c84c1
* refactor: consolidate coercion ownership Centralize four canonical coercion helpers, migrate exact core and plugin duplicates through narrow Plugin SDK facades, and enforce declaration and plugin-normalization ownership boundaries. The sweep adds eight focused SDK exports while deleting more production and tooling code than it adds. User-visible behavior is unchanged except for safer equivalent object and UI parsing at existing boundaries. * fix: guard integer option ownership Register resolveIntegerOption with the canonical function owner and extend the declaration-guard fixture so future local duplicates fail validation. * fix: keep integer helpers on numeric facade Remove the unshipped duplicate string-coerce exports and route every affected plugin consumer through the existing number-runtime contract. * fix: point numeric coercion to number runtime Make boundary and declaration diagnostics recommend the canonical numeric facade, with failing-before coverage for both guidance paths.
35 lines
1.4 KiB
TypeScript
35 lines
1.4 KiB
TypeScript
// Prepares the trusted harness manifest for npm Telegram live E2E scenarios.
|
|
import fs from "node:fs";
|
|
import { isRecord as isPackageJsonRecord } from "../../../../packages/normalization-core/src/record-coerce.ts";
|
|
import { privateLocalOnlyPluginSdkEntrypoints } from "../../../lib/plugin-sdk-entries.mts";
|
|
|
|
const packageJsonPaths = process.argv.slice(2);
|
|
if (packageJsonPaths.length !== 1) {
|
|
throw new Error("expected exactly one trusted harness package.json path");
|
|
}
|
|
|
|
const packageJsonPath = packageJsonPaths[0];
|
|
if (!packageJsonPath) {
|
|
throw new Error("trusted harness package.json path is missing");
|
|
}
|
|
const parsedPackageJson: unknown = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
if (!isPackageJsonRecord(parsedPackageJson)) {
|
|
throw new Error("trusted harness package.json must be an object");
|
|
}
|
|
const packageExports = isPackageJsonRecord(parsedPackageJson.exports)
|
|
? parsedPackageJson.exports
|
|
: {};
|
|
parsedPackageJson.exports = packageExports;
|
|
|
|
// Private QA builds emit these two harness-only facades outside the regular SDK inventory.
|
|
for (const subpath of [...privateLocalOnlyPluginSdkEntrypoints, "qa-lab", "qa-runtime"]) {
|
|
const exportPath = `./plugin-sdk/${subpath}`;
|
|
if (!packageExports[exportPath]) {
|
|
packageExports[exportPath] = {
|
|
default: `./dist/plugin-sdk/${subpath}.js`,
|
|
};
|
|
}
|
|
}
|
|
|
|
fs.writeFileSync(packageJsonPath, `${JSON.stringify(parsedPackageJson, null, 2)}\n`);
|