mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-13 17:06:04 +00:00
refactor(channels): remove stale bundled channel helpers
This commit is contained in:
@@ -197,7 +197,7 @@ afterEach(() => {
|
||||
describe("bundled channel entry shape guards", () => {
|
||||
const bundledPluginRoots = listSourceBundledPluginRoots();
|
||||
let realBundledSourceTreeProbe: {
|
||||
hasAccountInspect: boolean;
|
||||
hasAccountInspector: boolean;
|
||||
pluginIds: readonly string[];
|
||||
};
|
||||
|
||||
@@ -221,7 +221,7 @@ describe("bundled channel entry shape guards", () => {
|
||||
"./bundled.js?scope=real-bundled-source-tree-preload",
|
||||
);
|
||||
realBundledSourceTreeProbe = {
|
||||
hasAccountInspect: bundled.hasBundledChannelEntryFeature("slack", "accountInspect"),
|
||||
hasAccountInspector: typeof bundled.getBundledChannelAccountInspector("slack") === "function",
|
||||
pluginIds: [...bundled.listBundledChannelPluginIds()],
|
||||
};
|
||||
});
|
||||
@@ -256,7 +256,7 @@ describe("bundled channel entry shape guards", () => {
|
||||
|
||||
it("loads real bundled channel entry contracts from the source tree", async () => {
|
||||
expect(realBundledSourceTreeProbe.pluginIds).toEqual(["slack"]);
|
||||
expect(realBundledSourceTreeProbe.hasAccountInspect).toBe(true);
|
||||
expect(realBundledSourceTreeProbe.hasAccountInspector).toBe(true);
|
||||
});
|
||||
|
||||
it("fills sparse bundled channel plugin metadata from package metadata", async () => {
|
||||
@@ -316,12 +316,12 @@ describe("bundled channel entry shape guards", () => {
|
||||
"./bundled.js?scope=bundled-package-metadata",
|
||||
);
|
||||
|
||||
const plugin = bundled.requireBundledChannelPlugin("alpha");
|
||||
expect(plugin.meta.id).toBe("alpha");
|
||||
expect(plugin.meta.label).toBe("Alpha");
|
||||
expect(plugin.meta.selectionLabel).toBe("Use Alpha");
|
||||
expect(plugin.meta.docsPath).toBe("/channels/alpha");
|
||||
expect(plugin.meta.blurb).toBe("Alpha channel metadata.");
|
||||
const plugin = bundled.getBundledChannelPlugin("alpha");
|
||||
expect(plugin?.meta.id).toBe("alpha");
|
||||
expect(plugin?.meta.label).toBe("Alpha");
|
||||
expect(plugin?.meta.selectionLabel).toBe("Use Alpha");
|
||||
expect(plugin?.meta.docsPath).toBe("/channels/alpha");
|
||||
expect(plugin?.meta.blurb).toBe("Alpha channel metadata.");
|
||||
} finally {
|
||||
restoreBundledPluginsDir(previousBundledPluginsDir);
|
||||
fs.rmSync(tempRoot, { recursive: true, force: true });
|
||||
@@ -392,7 +392,7 @@ describe("bundled channel entry shape guards", () => {
|
||||
expect(metadataRootDir).toBe(tempRoot);
|
||||
expect(generatedRootDir).toBe(tempRoot);
|
||||
expect(testGlobal["__bundledOverrideRuntime"]).toBe("ok");
|
||||
expect(bundled.requireBundledChannelPlugin("alpha").id).toBe("alpha");
|
||||
expect(bundled.getBundledChannelPlugin("alpha")?.id).toBe("alpha");
|
||||
} finally {
|
||||
restoreBundledPluginsDir(previousBundledPluginsDir);
|
||||
fs.rmSync(tempRoot, { recursive: true, force: true });
|
||||
@@ -459,7 +459,7 @@ describe("bundled channel entry shape guards", () => {
|
||||
"./bundled.js?scope=bundled-package-local-dist-sdk-alias",
|
||||
);
|
||||
|
||||
expect(bundled.requireBundledChannelPlugin("alpha").meta.label).toBe("Package dist Alpha");
|
||||
expect(bundled.getBundledChannelPlugin("alpha")?.meta.label).toBe("Package dist Alpha");
|
||||
} finally {
|
||||
fs.rmSync(root, { recursive: true, force: true });
|
||||
}
|
||||
@@ -514,7 +514,7 @@ describe("bundled channel entry shape guards", () => {
|
||||
"./bundled.js?scope=bundled-direct-dist-sdk-alias",
|
||||
);
|
||||
|
||||
expect(bundled.requireBundledChannelPlugin("alpha").meta.label).toBe("Direct dist Alpha");
|
||||
expect(bundled.getBundledChannelPlugin("alpha")?.meta.label).toBe("Direct dist Alpha");
|
||||
} finally {
|
||||
restoreBundledPluginsDir(previousBundledPluginsDir);
|
||||
fs.rmSync(root, { recursive: true, force: true });
|
||||
@@ -588,7 +588,7 @@ describe("bundled channel entry shape guards", () => {
|
||||
expect(generatedRootDir).toBe(pluginsRoot);
|
||||
expect(generatedScanDir).toBe(pluginsRoot);
|
||||
expect(testGlobal["__bundledOverrideRuntime"]).toBe("ok");
|
||||
expect(bundled.requireBundledChannelPlugin("alpha").id).toBe("alpha");
|
||||
expect(bundled.getBundledChannelPlugin("alpha")?.id).toBe("alpha");
|
||||
} finally {
|
||||
restoreBundledPluginsDir(previousBundledPluginsDir);
|
||||
fs.rmSync(tempRoot, { recursive: true, force: true });
|
||||
@@ -673,7 +673,7 @@ describe("bundled channel entry shape guards", () => {
|
||||
);
|
||||
|
||||
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = path.join(rootA, "dist", "extensions");
|
||||
expect(bundled.requireBundledChannelPlugin("alpha").meta.label).toBe("Alpha A");
|
||||
expect(bundled.getBundledChannelPlugin("alpha")?.meta.label).toBe("Alpha A");
|
||||
expect(bundled.getBundledChannelSetupPlugin("alpha")?.meta.label).toBe("Setup A");
|
||||
expect(bundled.getBundledChannelSecrets("alpha")?.secretTargetRegistryEntries?.[0]?.id).toBe(
|
||||
"channels.alpha.A.entry-token",
|
||||
@@ -684,7 +684,7 @@ describe("bundled channel entry shape guards", () => {
|
||||
bundled.setBundledChannelRuntime("alpha", { marker: "first" } as never);
|
||||
|
||||
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = path.join(rootB, "dist", "extensions");
|
||||
expect(bundled.requireBundledChannelPlugin("alpha").meta.label).toBe("Alpha B");
|
||||
expect(bundled.getBundledChannelPlugin("alpha")?.meta.label).toBe("Alpha B");
|
||||
expect(bundled.getBundledChannelSetupPlugin("alpha")?.meta.label).toBe("Setup B");
|
||||
expect(bundled.getBundledChannelSecrets("alpha")?.secretTargetRegistryEntries?.[0]?.id).toBe(
|
||||
"channels.alpha.B.entry-token",
|
||||
|
||||
@@ -172,13 +172,6 @@ function hasSetupEntryFeature(
|
||||
return entry?.features?.[feature] === true;
|
||||
}
|
||||
|
||||
function hasChannelEntryFeature(
|
||||
entry: BundledChannelEntryRuntimeContract | undefined,
|
||||
feature: keyof NonNullable<BundledChannelEntryRuntimeContract["features"]>,
|
||||
): boolean {
|
||||
return entry?.features?.[feature] === true;
|
||||
}
|
||||
|
||||
function resolveBundledChannelBoundaryRoot(params: {
|
||||
packageRoot: string;
|
||||
pluginsDir?: string;
|
||||
@@ -879,15 +872,6 @@ export function listBundledChannelLegacyStateMigrationDetectors(
|
||||
});
|
||||
}
|
||||
|
||||
export function hasBundledChannelEntryFeature(
|
||||
id: ChannelId,
|
||||
feature: keyof NonNullable<BundledChannelEntryRuntimeContract["features"]>,
|
||||
): boolean {
|
||||
const { rootScope, loadContext } = resolveActiveBundledChannelLoadScope();
|
||||
const entry = getLazyGeneratedBundledChannelEntryForRoot(id, rootScope, loadContext)?.entry;
|
||||
return hasChannelEntryFeature(entry, feature);
|
||||
}
|
||||
|
||||
export function getBundledChannelAccountInspector(
|
||||
id: ChannelId,
|
||||
): NonNullable<ChannelPlugin["config"]["inspectAccount"]> | undefined {
|
||||
@@ -921,14 +905,6 @@ export function getBundledChannelSetupSecrets(
|
||||
return getBundledChannelSetupSecretsForRoot(id, rootScope, loadContext);
|
||||
}
|
||||
|
||||
export function requireBundledChannelPlugin(id: ChannelId): ChannelPlugin {
|
||||
const plugin = getBundledChannelPlugin(id);
|
||||
if (!plugin) {
|
||||
throw new Error(`missing bundled channel plugin: ${id}`);
|
||||
}
|
||||
return plugin;
|
||||
}
|
||||
|
||||
export function setBundledChannelRuntime(id: ChannelId, runtime: PluginRuntime): void {
|
||||
const { rootScope, loadContext } = resolveActiveBundledChannelLoadScope();
|
||||
const setter = getLazyGeneratedBundledChannelEntryForRoot(id, rootScope, loadContext)?.entry
|
||||
|
||||
Reference in New Issue
Block a user