mirror of
http://192.168.0.88:13333/lywsvip/openclaw-zero-token.git
synced 2026-05-08 16:17:54 +08:00
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
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import path from "node:path";
|
|
import { pathToFileURL } from "node:url";
|
|
import { describe, expect, it } from "vitest";
|
|
import { resolveFileModuleUrl, resolveFunctionModuleExport } from "./module-loader.js";
|
|
|
|
describe("hooks module loader helpers", () => {
|
|
it("builds a file URL without cache-busting by default", () => {
|
|
const modulePath = path.resolve("/tmp/hook-handler.js");
|
|
expect(resolveFileModuleUrl({ modulePath })).toBe(pathToFileURL(modulePath).href);
|
|
});
|
|
|
|
it("adds a cache-busting query when requested", () => {
|
|
const modulePath = path.resolve("/tmp/hook-handler.js");
|
|
expect(
|
|
resolveFileModuleUrl({
|
|
modulePath,
|
|
cacheBust: true,
|
|
nowMs: 123,
|
|
}),
|
|
).toBe(`${pathToFileURL(modulePath).href}?t=123`);
|
|
});
|
|
|
|
it("resolves explicit function exports", () => {
|
|
const fn = () => "ok";
|
|
const resolved = resolveFunctionModuleExport({
|
|
mod: { run: fn },
|
|
exportName: "run",
|
|
});
|
|
expect(resolved).toBe(fn);
|
|
});
|
|
|
|
it("falls back through named exports when no explicit export is provided", () => {
|
|
const fallback = () => "ok";
|
|
const resolved = resolveFunctionModuleExport({
|
|
mod: { transform: fallback },
|
|
fallbackExportNames: ["default", "transform"],
|
|
});
|
|
expect(resolved).toBe(fallback);
|
|
});
|
|
|
|
it("returns undefined when export exists but is not callable", () => {
|
|
const resolved = resolveFunctionModuleExport({
|
|
mod: { run: "nope" },
|
|
exportName: "run",
|
|
});
|
|
expect(resolved).toBeUndefined();
|
|
});
|
|
});
|