mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
fix: bundle private llm core declarations (#89336)
This commit is contained in:
@@ -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).`,
|
||||
|
||||
@@ -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/"),
|
||||
|
||||
@@ -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/") ||
|
||||
|
||||
Reference in New Issue
Block a user