


























@@ -45,6 +45,8 @@ type ImplicitProviderParams = {
4545workspaceDir?: string;
4646explicitProviders?: Record<string, ProviderConfig> | null;
4747pluginMetadataSnapshot?: Pick<PluginMetadataSnapshot, "index" | "manifestRegistry" | "owners">;
48+providerDiscoveryProviderIds?: readonly string[];
49+providerDiscoveryTimeoutMs?: number;
4850};
49515052type ImplicitProviderContext = ImplicitProviderParams & {
@@ -73,6 +75,7 @@ function resolveProviderDiscoveryFilter(params: {
7375workspaceDir?: string;
7476env: NodeJS.ProcessEnv;
7577resolveOwners?: (provider: string) => readonly string[] | undefined;
78+providerIds?: readonly string[];
7679}): string[] | undefined {
7780const { config, workspaceDir, env } = params;
7881const testRaw = env.OPENCLAW_TEST_ONLY_PROVIDER_PLUGIN_IDS?.trim();
@@ -83,6 +86,18 @@ function resolveProviderDiscoveryFilter(params: {
8386.filter(Boolean);
8487return ids.length > 0 ? [...new Set(ids)] : undefined;
8588}
89+const scopedProviderIds = params.providerIds
90+?.map((value) => value.trim())
91+.filter((value) => value.length > 0);
92+if (scopedProviderIds) {
93+return resolveProviderPluginScopeFromProviderIds({
94+providerIds: scopedProviderIds,
95+ config,
96+ workspaceDir,
97+ env,
98+resolveOwners: params.resolveOwners,
99+});
100+}
86101const live =
87102env.OPENCLAW_LIVE_TEST === "1" || env.OPENCLAW_LIVE_GATEWAY === "1" || env.LIVE === "1";
88103if (!live) {
@@ -102,15 +117,31 @@ function resolveProviderDiscoveryFilter(params: {
102117if (ids.length === 0) {
103118return undefined;
104119}
120+return resolveProviderPluginScopeFromProviderIds({
121+providerIds: ids,
122+ config,
123+ workspaceDir,
124+ env,
125+resolveOwners: params.resolveOwners,
126+});
127+}
128+129+function resolveProviderPluginScopeFromProviderIds(params: {
130+providerIds: readonly string[];
131+config?: OpenClawConfig;
132+workspaceDir?: string;
133+env: NodeJS.ProcessEnv;
134+resolveOwners?: (provider: string) => readonly string[] | undefined;
135+}): string[] {
105136const pluginIds = new Set<string>();
106-for (const id of ids) {
137+for (const id of params.providerIds) {
107138const owners =
108139params.resolveOwners?.(id) ??
109140resolveOwningPluginIdsForProvider({
110141provider: id,
111- config,
112- workspaceDir,
113- env,
142+config: params.config,
143+workspaceDir: params.workspaceDir,
144+env: params.env,
114145}) ??
115146[];
116147if (owners.length > 0) {
@@ -121,9 +152,7 @@ function resolveProviderDiscoveryFilter(params: {
121152}
122153pluginIds.add(id);
123154}
124-return pluginIds.size > 0
125- ? [...pluginIds].toSorted((left, right) => left.localeCompare(right))
126- : undefined;
155+return [...pluginIds].toSorted((left, right) => left.localeCompare(right));
127156}
128157129158function resolvePluginMetadataProviderOwners(
@@ -140,13 +169,25 @@ function resolvePluginMetadataProviderOwners(
140169const owners = new Set<string>();
141170appendNormalizedPluginMetadataOwners(
142171owners,
143-pluginMetadataSnapshot.owners.providers,
172+pluginMetadataSnapshot.owners.providers ?? new Map(),
173+provider,
174+normalizedProvider,
175+);
176+appendNormalizedPluginMetadataOwners(
177+owners,
178+pluginMetadataSnapshot.owners.modelCatalogProviders ?? new Map(),
179+provider,
180+normalizedProvider,
181+);
182+appendNormalizedPluginMetadataOwners(
183+owners,
184+pluginMetadataSnapshot.owners.setupProviders ?? new Map(),
144185provider,
145186normalizedProvider,
146187);
147188appendNormalizedPluginMetadataOwners(
148189owners,
149-pluginMetadataSnapshot.owners.cliBackends,
190+pluginMetadataSnapshot.owners.cliBackends ?? new Map(),
150191provider,
151192normalizedProvider,
152193);
@@ -187,6 +228,7 @@ export function resolveProviderDiscoveryFilterForTest(params: {
187228workspaceDir?: string;
188229env: NodeJS.ProcessEnv;
189230resolveOwners?: (provider: string) => readonly string[] | undefined;
231+providerIds?: readonly string[];
190232}): string[] | undefined {
191233return resolveProviderDiscoveryFilter(params);
192234}
@@ -321,7 +363,7 @@ async function resolvePluginImplicitProviders(
321363resolveProviderApiKey: resolveCatalogProviderApiKey,
322364resolveProviderAuth: (providerId, options) =>
323365ctx.resolveProviderAuth(providerId?.trim() || provider.id, options),
324-timeoutMs: resolveLiveProviderCatalogTimeoutMs(ctx.env),
366+timeoutMs: ctx.providerDiscoveryTimeoutMs ?? resolveLiveProviderCatalogTimeoutMs(ctx.env),
325367});
326368if (!result) {
327369continue;
@@ -435,6 +477,7 @@ export async function resolveImplicitProviders(
435477resolveOwners: params.pluginMetadataSnapshot
436478 ? (provider) => resolvePluginMetadataProviderOwners(params.pluginMetadataSnapshot, provider)
437479 : undefined,
480+providerIds: params.providerDiscoveryProviderIds,
438481}),
439482 ...(params.pluginMetadataSnapshot
440483 ? { pluginMetadataSnapshot: params.pluginMetadataSnapshot }
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。