mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-07 18:42:25 +00:00
fix(plugin-sdk): stabilize surface report after builds
This commit is contained in:
@@ -203,9 +203,25 @@ function hasDeprecatedTag(symbol) {
|
||||
return symbol.getJsDocTags().some((tag) => tag.name === "deprecated");
|
||||
}
|
||||
|
||||
const generatedLlmCoreValidatorExports = new Set(["validateToolArguments", "validateToolCall"]);
|
||||
|
||||
function isGeneratedLlmCoreValidatorDeclaration(exportName, declaration) {
|
||||
if (!generatedLlmCoreValidatorExports.has(exportName)) {
|
||||
return false;
|
||||
}
|
||||
const relative = path.relative(repoRoot, declaration.getSourceFile().fileName);
|
||||
const relativePath = relative.split(path.sep).join(path.posix.sep);
|
||||
// Build artifacts can make agent-core's package-name validator reexports look
|
||||
// newly callable. Keep this source report independent of generated dist state.
|
||||
return relativePath.includes("llm-core/dist/validation.d.");
|
||||
}
|
||||
|
||||
function isCallableExport(checker, symbol, sourceFile) {
|
||||
const target = unwrapAlias(checker, symbol);
|
||||
const declaration = target.valueDeclaration ?? target.declarations?.[0] ?? sourceFile;
|
||||
if (isGeneratedLlmCoreValidatorDeclaration(symbol.getName(), declaration)) {
|
||||
return false;
|
||||
}
|
||||
const type = checker.getTypeOfSymbolAtLocation(target, declaration);
|
||||
return checker.getSignaturesOfType(type, ts.SignatureKind.Call).length > 0;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,15 @@ describe("plugin SDK surface report", () => {
|
||||
expect(result.stderr).toBe("");
|
||||
});
|
||||
|
||||
it("keeps generated package declarations out of source surface counts", () => {
|
||||
const result = runSurfaceReport({
|
||||
OPENCLAW_PLUGIN_SDK_MAX_PUBLIC_FUNCTION_EXPORTS: "5186",
|
||||
});
|
||||
|
||||
expect(result.status).toBe(1);
|
||||
expect(result.stderr).toContain("public callable exports 5187 > 5186");
|
||||
});
|
||||
|
||||
it("rejects deprecated export growth by public entrypoint", () => {
|
||||
const result = runSurfaceReport({
|
||||
OPENCLAW_PLUGIN_SDK_MAX_PUBLIC_DEPRECATED_EXPORTS_BY_ENTRYPOINT: JSON.stringify({ core: 1 }),
|
||||
|
||||
Reference in New Issue
Block a user