






















@@ -1,14 +1,12 @@
11import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../../agents/agent-scope.js";
22import {
3-getChannelPluginCatalogEntry,
43listChannelPluginCatalogEntries,
54type ChannelPluginCatalogEntry,
65} from "../../channels/plugins/catalog.js";
76import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js";
87import type { ChannelPlugin } from "../../channels/plugins/types.plugin.js";
98import type { ChannelId } from "../../channels/plugins/types.public.js";
109import type { OpenClawConfig } from "../../config/types.openclaw.js";
11-import { normalizePluginsConfig, resolveEnableState } from "../../plugins/config-state.js";
1210import type { RuntimeEnv } from "../../runtime.js";
1311import { normalizeOptionalLowercaseString } from "../../shared/string-coerce.js";
1412import { createClackPrompter } from "../../wizard/clack-prompter.js";
@@ -17,6 +15,10 @@ import {
1715ensureChannelSetupPluginInstalled,
1816loadChannelSetupPluginRegistrySnapshotForChannel,
1917} from "./plugin-install.js";
18+import {
19+getTrustedChannelPluginCatalogEntry,
20+listTrustedChannelPluginCatalogEntries,
21+} from "./trusted-catalog.js";
20222123type ChannelPluginSnapshot = {
2224channels: Array<{ plugin: ChannelPlugin }>;
@@ -55,8 +57,13 @@ export function resolveCatalogChannelEntry(raw: string, cfg: OpenClawConfig | nu
5557if (!trimmed) {
5658return undefined;
5759}
58-const workspaceDir = cfg ? resolveWorkspaceDir(cfg) : undefined;
59-return listChannelPluginCatalogEntries({ workspaceDir }).find((entry) => {
60+const entries = cfg
61+ ? listTrustedChannelPluginCatalogEntries({
62+ cfg,
63+workspaceDir: resolveWorkspaceDir(cfg),
64+})
65+ : listChannelPluginCatalogEntries({ excludeWorkspace: true });
66+return entries.find((entry) => {
6067if (normalizeOptionalLowercaseString(entry.id) === trimmed) {
6168return true;
6269}
@@ -76,74 +83,6 @@ function findScopedChannelPlugin(
7683);
7784}
788579-function isTrustedWorkspaceChannelCatalogEntry(
80-entry: ChannelPluginCatalogEntry | undefined,
81-cfg: OpenClawConfig,
82-): boolean {
83-if (entry?.origin !== "workspace") {
84-return true;
85-}
86-if (!entry.pluginId) {
87-return false;
88-}
89-const plugins = cfg.plugins;
90-if (plugins?.enabled === false) {
91-return false;
92-}
93-const pluginEntry = plugins?.entries?.[entry.pluginId];
94-if (pluginEntry?.enabled === false) {
95-return false;
96-}
97-if (plugins?.deny?.length) {
98-return resolveEnableState(entry.pluginId, "workspace", normalizePluginsConfig(cfg.plugins))
99-.enabled;
100-}
101-if (plugins?.allow?.includes(entry.pluginId)) {
102-return true;
103-}
104-if (pluginEntry?.enabled === true && !plugins?.allow?.length) {
105-return true;
106-}
107-return resolveEnableState(entry.pluginId, "workspace", normalizePluginsConfig(cfg.plugins))
108-.enabled;
109-}
110-111-function resolveTrustedCatalogEntry(params: {
112-rawChannel?: string | null;
113-channelId?: ChannelId;
114-cfg: OpenClawConfig;
115-workspaceDir?: string;
116-catalogEntry?: ChannelPluginCatalogEntry;
117-}): ChannelPluginCatalogEntry | undefined {
118-if (isTrustedWorkspaceChannelCatalogEntry(params.catalogEntry, params.cfg)) {
119-return params.catalogEntry;
120-}
121-if (params.rawChannel) {
122-const trimmed = normalizeOptionalLowercaseString(params.rawChannel);
123-if (!trimmed) {
124-return undefined;
125-}
126-return listChannelPluginCatalogEntries({
127-workspaceDir: params.workspaceDir,
128-excludeWorkspace: true,
129-}).find((entry) => {
130-if (normalizeOptionalLowercaseString(entry.id) === trimmed) {
131-return true;
132-}
133-return (entry.meta.aliases ?? []).some(
134-(alias) => normalizeOptionalLowercaseString(alias) === trimmed,
135-);
136-});
137-}
138-if (!params.channelId) {
139-return undefined;
140-}
141-return getChannelPluginCatalogEntry(params.channelId, {
142-workspaceDir: params.workspaceDir,
143-excludeWorkspace: true,
144-});
145-}
146-14786function loadScopedChannelPlugin(params: {
14887cfg: OpenClawConfig;
14988runtime: RuntimeEnv;
@@ -173,20 +112,14 @@ export async function resolveInstallableChannelPlugin(params: {
173112const supports = params.supports ?? (() => true);
174113let nextCfg = params.cfg;
175114const workspaceDir = resolveWorkspaceDir(nextCfg);
176-const unresolvedCatalogEntry =
115+const catalogEntry =
177116(params.rawChannel ? resolveCatalogChannelEntry(params.rawChannel, nextCfg) : undefined) ??
178117(params.channelId
179- ? getChannelPluginCatalogEntry(params.channelId, {
118+ ? getTrustedChannelPluginCatalogEntry(params.channelId, {
119+cfg: nextCfg,
180120 workspaceDir,
181121})
182122 : undefined);
183-const catalogEntry = resolveTrustedCatalogEntry({
184-rawChannel: params.rawChannel,
185-channelId: params.channelId,
186-cfg: nextCfg,
187- workspaceDir,
188-catalogEntry: unresolvedCatalogEntry,
189-});
190123const channelId =
191124params.channelId ??
192125resolveResolvedChannelId({
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。