




























@@ -1,5 +1,6 @@
11import fs from "node:fs";
22import path from "node:path";
3+import { normalizeProviderId } from "../agents/provider-id.js";
34import type { OpenClawConfig } from "../config/types.openclaw.js";
45import { normalizeOptionalLowercaseString } from "../shared/string-coerce.js";
56import { readRuntimeDepsJsonObject, type JsonObject } from "./bundled-runtime-deps-json.js";
@@ -207,6 +208,88 @@ function passesRuntimeDepsPluginPolicy(params: {
207208);
208209}
209210211+function isRecord(value: unknown): value is Record<string, unknown> {
212+return Boolean(value && typeof value === "object" && !Array.isArray(value));
213+}
214+215+function addConfiguredProviderId(providerIds: Set<string>, value: unknown): void {
216+if (typeof value !== "string") {
217+return;
218+}
219+const normalized = normalizeProviderId(value);
220+if (normalized) {
221+providerIds.add(normalized);
222+}
223+}
224+225+function addConfiguredProviderFromModelRef(providerIds: Set<string>, value: unknown): void {
226+if (typeof value !== "string") {
227+return;
228+}
229+const providerId = value.split("/", 1)[0]?.trim();
230+addConfiguredProviderId(providerIds, providerId);
231+}
232+233+function addConfiguredProvidersFromModelConfig(providerIds: Set<string>, value: unknown): void {
234+if (typeof value === "string") {
235+addConfiguredProviderFromModelRef(providerIds, value);
236+return;
237+}
238+if (!isRecord(value)) {
239+return;
240+}
241+addConfiguredProviderFromModelRef(providerIds, value.primary);
242+if (Array.isArray(value.fallbacks)) {
243+for (const fallback of value.fallbacks) {
244+addConfiguredProviderFromModelRef(providerIds, fallback);
245+}
246+}
247+}
248+249+function collectConfiguredProviderIds(config: OpenClawConfig): Set<string> {
250+const providerIds = new Set<string>();
251+for (const providerId of Object.keys(config.models?.providers ?? {})) {
252+addConfiguredProviderId(providerIds, providerId);
253+}
254+for (const profile of Object.values(config.auth?.profiles ?? {})) {
255+addConfiguredProviderId(providerIds, profile.provider);
256+}
257+for (const providerId of Object.keys(config.auth?.order ?? {})) {
258+addConfiguredProviderId(providerIds, providerId);
259+}
260+261+const defaults = config.agents?.defaults;
262+addConfiguredProvidersFromModelConfig(providerIds, defaults?.model);
263+addConfiguredProvidersFromModelConfig(providerIds, defaults?.imageModel);
264+addConfiguredProvidersFromModelConfig(providerIds, defaults?.imageGenerationModel);
265+addConfiguredProvidersFromModelConfig(providerIds, defaults?.videoGenerationModel);
266+addConfiguredProvidersFromModelConfig(providerIds, defaults?.musicGenerationModel);
267+addConfiguredProvidersFromModelConfig(providerIds, defaults?.pdfModel);
268+addConfiguredProvidersFromModelConfig(providerIds, defaults?.subagents?.model);
269+for (const providerId of Object.keys(defaults?.models ?? {})) {
270+addConfiguredProviderFromModelRef(providerIds, providerId);
271+}
272+273+for (const agent of config.agents?.list ?? []) {
274+addConfiguredProvidersFromModelConfig(providerIds, agent.model);
275+addConfiguredProvidersFromModelConfig(providerIds, agent.subagents?.model);
276+}
277+return providerIds;
278+}
279+280+function isBundledProviderConfiguredForRuntimeDeps(params: {
281+config: OpenClawConfig;
282+providers: readonly string[];
283+}): boolean {
284+if (params.providers.length === 0) {
285+return false;
286+}
287+const configuredProviderIds = collectConfiguredProviderIds(params.config);
288+return params.providers.some((provider) =>
289+configuredProviderIds.has(normalizeProviderId(provider)),
290+);
291+}
292+210293export function isBundledPluginConfiguredForRuntimeDeps(params: {
211294config: OpenClawConfig;
212295plugins: NormalizedPluginsConfig;
@@ -280,7 +363,15 @@ export function isBundledPluginConfiguredForRuntimeDeps(params: {
280363if (hasConfiguredChannel) {
281364return true;
282365}
283-return manifest.enabledByDefault;
366+if (
367+isBundledProviderConfiguredForRuntimeDeps({
368+config: params.config,
369+providers: manifest.providers,
370+})
371+) {
372+return true;
373+}
374+return manifest.enabledByDefault && manifest.providers.length === 0;
284375}
285376286377function isBundledPluginExplicitlyDisabledForRuntimeDeps(params: {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。