Files
openclaw/scripts/lib/plugin-sdk-declaration-budget.mts
Peter Steinberger c70aee247e refactor(scripts): migrate JavaScript tools to TypeScript (#121005)
* refactor(scripts): migrate JavaScript tools to TypeScript

* fix(ci): keep changed-scope preflight zero-install

* fix(ci): preserve zero-install script owners

* fix(ci): complete script migration follow-through

* fix(release): keep stable closeout zero-install

* fix(scripts): preserve standalone execution boundaries

* fix(scripts): repair standalone loader boundaries

* fix(scripts): normalize gateway observation ids

* fix(scripts): keep Docker packager standalone

* test(scripts): preserve rebase cleanup helpers

* test(sessions): use tracked temp directory
2026-08-09 07:21:35 -07:00

34 lines
1.5 KiB
TypeScript

// Raised for meeting-browser origin permissions and current browser-session contracts;
// the cap exists to force a conscious decision on published declaration growth.
export const MAX_PUBLIC_PLUGIN_SDK_DECLARATION_BYTES = 5_250_000;
// Private-only entrypoints reshape chunks reachable from public roots but are never published.
// Bound that topology overhead without counting local-only declarations as package surface.
export const MAX_PRIVATE_QA_PUBLIC_PLUGIN_SDK_DECLARATION_BYTES = 5_275_000;
// Rolldown can repartition equivalent declaration chunks between clean builds; measured spread is
// about 29 KiB across hosts. Keep one 64 KiB scheduling window above the intentional size ratchet.
export const PLUGIN_SDK_DECLARATION_OUTPUT_VARIANCE_BYTES = 64 * 1024;
export function isPrivateQaPluginSdkBuild(env: NodeJS.ProcessEnv): boolean {
return env.OPENCLAW_BUILD_PRIVATE_QA === "1";
}
export function evaluatePluginSdkDeclarationBudget({
declarationBytes,
buildPrivateQa,
}: {
declarationBytes: number;
buildPrivateQa: boolean;
}) {
const ratchetBytes = buildPrivateQa
? MAX_PRIVATE_QA_PUBLIC_PLUGIN_SDK_DECLARATION_BYTES
: MAX_PUBLIC_PLUGIN_SDK_DECLARATION_BYTES;
const budgetBytes = ratchetBytes + PLUGIN_SDK_DECLARATION_OUTPUT_VARIANCE_BYTES;
return {
budgetBytes,
budgetKind: buildPrivateQa ? "private-qa-public-entry" : "public",
ratchetBytes,
shouldFail: declarationBytes > budgetBytes,
varianceBytes: PLUGIN_SDK_DECLARATION_OUTPUT_VARIANCE_BYTES,
};
}