From 20e0d068a78aab4c8d9d6ea942b68771f6989942 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 1 Jun 2026 23:51:38 -0700 Subject: [PATCH] fix: bundle private llm core declarations (#89336) --- scripts/check-plugin-sdk-exports.mjs | 21 +++++++++++++++- scripts/openclaw-npm-postpublish-verify.ts | 29 ++++++++++++++++++++++ scripts/write-plugin-sdk-entry-dts.ts | 2 ++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/scripts/check-plugin-sdk-exports.mjs b/scripts/check-plugin-sdk-exports.mjs index b210c4bb6bd5..90b28c99eef1 100755 --- a/scripts/check-plugin-sdk-exports.mjs +++ b/scripts/check-plugin-sdk-exports.mjs @@ -8,7 +8,7 @@ * aliases before release. */ -import { readFileSync, existsSync } from "node:fs"; +import { readFileSync, existsSync, readdirSync } from "node:fs"; import { resolve, dirname } from "node:path"; import { fileURLToPath, pathToFileURL } from "node:url"; import { publicPluginSdkSubpaths } from "./lib/plugin-sdk-entries.mjs"; @@ -42,6 +42,7 @@ const exportedNames = exportMatch[1] const exportSet = new Set(exportedNames); const requiredRuntimeShimEntries = ["compat.js", "root-alias.cjs"]; +const forbiddenPublicDeclarationSpecifiers = ["@openclaw/llm-core"]; const requiredSubpathExports = { "secret-input-runtime": [ "coerceSecretRef", @@ -113,6 +114,24 @@ for (const [entry, names] of Object.entries(requiredSubpathExports)) { } } +for (const entry of readdirSync(resolve(scriptDir, "..", "dist", "plugin-sdk"), { + withFileTypes: true, +})) { + if (!entry.isFile() || !entry.name.endsWith(".d.ts")) { + continue; + } + const dtsPath = resolve(scriptDir, "..", "dist", "plugin-sdk", entry.name); + const dtsContent = readFileSync(dtsPath, "utf8"); + for (const specifier of forbiddenPublicDeclarationSpecifiers) { + if (dtsContent.includes(`"${specifier}`) || dtsContent.includes(`'${specifier}`)) { + console.error( + `FORBIDDEN PUBLIC DTS SPECIFIER: dist/plugin-sdk/${entry.name} imports ${specifier}`, + ); + missing += 1; + } + } +} + if (missing > 0) { console.error( `\nERROR: ${missing} required plugin-sdk artifact(s) missing (named exports or subpath files).`, diff --git a/scripts/openclaw-npm-postpublish-verify.ts b/scripts/openclaw-npm-postpublish-verify.ts index e9aafbc8ee50..bf885da8229e 100644 --- a/scripts/openclaw-npm-postpublish-verify.ts +++ b/scripts/openclaw-npm-postpublish-verify.ts @@ -138,6 +138,7 @@ export function collectInstalledPackageErrors(params: { errors.push(...collectInstalledContextEngineRuntimeErrors(params.packageRoot)); errors.push(...collectInstalledPluginSdkZodArtifactErrors(params.packageRoot)); + errors.push(...collectInstalledPluginSdkDeclarationErrors(params.packageRoot)); errors.push(...collectInstalledRootDependencyManifestErrors(params.packageRoot)); return errors; @@ -314,6 +315,34 @@ export function collectInstalledPluginSdkZodArtifactErrors(packageRoot: string): return []; } +export function collectInstalledPluginSdkDeclarationErrors(packageRoot: string): string[] { + const pluginSdkDistRoot = join(packageRoot, "dist", "plugin-sdk"); + const errors: string[] = []; + const forbiddenPrivateWorkspaceSpecifiers = ["@openclaw/llm-core"]; + + if (!existsSync(pluginSdkDistRoot)) { + return []; + } + + for (const entry of readdirSync(pluginSdkDistRoot, { withFileTypes: true })) { + if (!entry.isFile() || !entry.name.endsWith(".d.ts")) { + continue; + } + + const relativePath = `dist/plugin-sdk/${entry.name}`; + const content = readFileSync(join(pluginSdkDistRoot, entry.name), "utf8"); + for (const specifier of forbiddenPrivateWorkspaceSpecifiers) { + if (content.includes(`"${specifier}`) || content.includes(`'${specifier}`)) { + errors.push( + `installed package plugin SDK declaration '${relativePath}' references private workspace package ${specifier}.`, + ); + } + } + } + + return errors; +} + function listInstalledRootDistJavaScriptFiles(packageRoot: string): string[] { return listDistJavaScriptFiles(packageRoot, { skipRelativePath: (relativePath) => relativePath.startsWith("extensions/"), diff --git a/scripts/write-plugin-sdk-entry-dts.ts b/scripts/write-plugin-sdk-entry-dts.ts index 4034b6096071..3ed38fcd11fb 100644 --- a/scripts/write-plugin-sdk-entry-dts.ts +++ b/scripts/write-plugin-sdk-entry-dts.ts @@ -45,6 +45,8 @@ const RUNTIME_SHIMS: Partial> = { function isBareImportSpecifier(id: string): boolean { if ( + id === "@openclaw/llm-core" || + id.startsWith("@openclaw/llm-core/") || id === "@openclaw/model-catalog-core/model-catalog-types" || id.startsWith("@openclaw/normalization-core/") || id.startsWith("@openclaw/media-core/") ||