Files
openclaw-zero-token/library.test.ts
sjhu 571e14a236 feat: upgrade to upstream v2026.3.28
Major upgrade from e26988a38 to upstream v2026.3.28 (f9b107928).
Key changes:
- Upstream src/, ui/, extensions/ (89 bundled extensions)
- Zero-token web providers preserved in src/zero-token/
- AskOnce plugin restored and registered as CLI command
- Added missing packages: @anthropic-ai/vertex-sdk, @modelcontextprotocol/sdk
- Fixed tsconfig rootDir, skipLibCheck for plugin-sdk DTS build
- Added askonce to bundled plugin metadata and package.json exports
- Fixed AskOnce CLI command registration (missing commands metadata)
- Restored AskOnce adapter imports (correct 5-level relative paths)
- Removed stale migration artifacts from root directory
2026-03-30 17:58:12 +08:00

59 lines
1.8 KiB
TypeScript

import { readFileSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import ts from "typescript";
import { describe, expect, it } from "vitest";
const libraryPath = resolve(dirname(fileURLToPath(import.meta.url)), "library.ts");
const lazyRuntimeSpecifiers = [
"./auto-reply/reply.runtime.js",
"./cli/prompt.js",
"./infra/binaries.js",
"./process/exec.js",
"./plugins/runtime/runtime-whatsapp-boundary.js",
] as const;
function readLibraryModuleImports() {
const sourceText = readFileSync(libraryPath, "utf8");
const sourceFile = ts.createSourceFile(libraryPath, sourceText, ts.ScriptTarget.Latest, true);
const staticImports = new Set<string>();
const dynamicImports = new Set<string>();
function visit(node: ts.Node) {
if (
ts.isImportDeclaration(node) &&
ts.isStringLiteral(node.moduleSpecifier) &&
!node.importClause?.isTypeOnly
) {
staticImports.add(node.moduleSpecifier.text);
}
if (
ts.isCallExpression(node) &&
node.expression.kind === ts.SyntaxKind.ImportKeyword &&
node.arguments.length === 1 &&
ts.isStringLiteral(node.arguments[0])
) {
dynamicImports.add(node.arguments[0].text);
}
ts.forEachChild(node, visit);
}
visit(sourceFile);
return { dynamicImports, staticImports };
}
describe("library module imports", () => {
it("keeps lazy runtime boundaries on dynamic imports", () => {
const { dynamicImports, staticImports } = readLibraryModuleImports();
for (const specifier of lazyRuntimeSpecifiers) {
expect(staticImports.has(specifier), `${specifier} should stay lazy`).toBe(false);
expect(dynamicImports.has(specifier), `${specifier} should remain dynamically imported`).toBe(
true,
);
}
});
});