



























@@ -10,6 +10,11 @@ type BundledChannelEntryPathPair = {
1010built: string;
1111};
121213+type BundledMetadataScope =
14+| { kind: "default" }
15+| { kind: "empty" }
16+| { kind: "env"; env: NodeJS.ProcessEnv };
17+1318export type BundledChannelPluginMetadata = {
1419dirName: string;
1520source: BundledChannelEntryPathPair;
@@ -22,22 +27,28 @@ export type BundledChannelPluginMetadata = {
2227rootDir: string;
2328};
242925-function resolveBundledMetadataEnv(params?: {
30+function resolveBundledMetadataScope(params?: {
2631rootDir?: string;
2732scanDir?: string;
28-}): NodeJS.ProcessEnv | undefined {
33+}): BundledMetadataScope {
2934const overrideDir = params?.scanDir
3035 ? path.resolve(params.scanDir)
3136 : params?.rootDir
3237 ? resolveBundledPluginsDirForRoot(params.rootDir)
3338 : undefined;
3439if (!overrideDir) {
35-return undefined;
40+return params?.rootDir ? { kind: "empty" } : { kind: "default" };
41+}
42+if (!fs.existsSync(overrideDir)) {
43+return { kind: "empty" };
3644}
3745return {
38- ...process.env,
39-OPENCLAW_BUNDLED_PLUGINS_DIR: overrideDir,
40-OPENCLAW_TEST_TRUST_BUNDLED_PLUGINS_DIR: "1",
46+kind: "env",
47+env: {
48+ ...process.env,
49+OPENCLAW_BUNDLED_PLUGINS_DIR: overrideDir,
50+OPENCLAW_TEST_TRUST_BUNDLED_PLUGINS_DIR: "1",
51+},
4152};
4253}
4354@@ -87,8 +98,12 @@ export function listBundledChannelPluginMetadata(params?: {
8798includeChannelConfigs?: boolean;
8899includeSyntheticChannelConfigs?: boolean;
89100}): readonly BundledChannelPluginMetadata[] {
101+const scope = resolveBundledMetadataScope(params);
102+if (scope.kind === "empty") {
103+return [];
104+}
90105return loadPluginManifestRegistryForPluginRegistry({
91-env: resolveBundledMetadataEnv(params),
106+env: scope.kind === "env" ? scope.env : undefined,
92107includeDisabled: true,
93108}).plugins.flatMap((record) => toBundledChannelPluginMetadata(record) ?? []);
94109}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。