fix: bundle private llm core declarations (#89336)

This commit is contained in:
Dallin Romney
2026-06-01 23:51:38 -07:00
committed by GitHub
parent c0400397df
commit 20e0d068a7
3 changed files with 51 additions and 1 deletions

View File

@@ -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).`,

View File

@@ -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/"),

View File

@@ -45,6 +45,8 @@ const RUNTIME_SHIMS: Partial<Record<string, string>> = {
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/") ||