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
59 lines
1.9 KiB
TypeScript
59 lines
1.9 KiB
TypeScript
import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
|
|
|
|
const readFileSyncMock = vi.hoisted(() => vi.fn());
|
|
|
|
vi.mock("node:fs", async () => {
|
|
const actual = await vi.importActual<typeof import("node:fs")>("node:fs");
|
|
const base = ("default" in actual ? actual.default : actual) as Record<string, unknown>;
|
|
return {
|
|
...actual,
|
|
default: {
|
|
...base,
|
|
readFileSync: readFileSyncMock,
|
|
},
|
|
readFileSync: readFileSyncMock,
|
|
};
|
|
});
|
|
|
|
vi.mock("../channels/registry.js", () => ({
|
|
CHAT_CHANNEL_ORDER: ["telegram", "discord"],
|
|
}));
|
|
|
|
let resolveCliChannelOptions: typeof import("./channel-options.js").resolveCliChannelOptions;
|
|
let __testing: typeof import("./channel-options.js").__testing;
|
|
|
|
beforeAll(async () => {
|
|
({ resolveCliChannelOptions, __testing } = await import("./channel-options.js"));
|
|
});
|
|
|
|
describe("resolveCliChannelOptions", () => {
|
|
afterEach(() => {
|
|
__testing.resetPrecomputedChannelOptionsForTests();
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it("uses precomputed startup metadata when available", async () => {
|
|
readFileSyncMock.mockReturnValue(
|
|
JSON.stringify({ channelOptions: ["cached", "telegram", "cached"] }),
|
|
);
|
|
|
|
expect(resolveCliChannelOptions()).toEqual(["cached", "telegram"]);
|
|
});
|
|
|
|
it("falls back to core channel order when metadata is missing", async () => {
|
|
readFileSyncMock.mockImplementation(() => {
|
|
throw new Error("ENOENT");
|
|
});
|
|
|
|
expect(resolveCliChannelOptions()).toEqual(["telegram", "discord"]);
|
|
});
|
|
|
|
it("ignores external catalog env during CLI bootstrap", async () => {
|
|
process.env.OPENCLAW_PLUGIN_CATALOG_PATHS = "/tmp/plugins-catalog.json";
|
|
readFileSyncMock.mockReturnValue(JSON.stringify({ channelOptions: ["cached", "telegram"] }));
|
|
|
|
expect(resolveCliChannelOptions()).toEqual(["cached", "telegram"]);
|
|
delete process.env.OPENCLAW_PLUGIN_CATALOG_PATHS;
|
|
});
|
|
});
|