




















@@ -43,6 +43,10 @@ import {
4343type PluginPackageInstall,
4444} from "./manifest.js";
4545import { checkMinHostVersion } from "./min-host-version.js";
46+import {
47+getOfficialExternalPluginCatalogEntryForPackage,
48+getOfficialExternalPluginCatalogManifest,
49+} from "./official-external-plugin-catalog.js";
4650import { isPathInside, safeRealpathSync } from "./path-safety.js";
4751import type { PluginKind } from "./plugin-kind.types.js";
4852import type { PluginOrigin } from "./plugin-origin.types.js";
@@ -258,6 +262,72 @@ function mergePackageChannelMetaIntoChannelConfigs(params: {
258262return merged;
259263}
260264265+function mergeContractLists(
266+left: readonly string[] | undefined,
267+right: readonly string[] | undefined,
268+): string[] | undefined {
269+const merged = [...(left ?? []), ...(right ?? [])]
270+.map((value) => value.trim())
271+.filter((value, index, all) => value.length > 0 && all.indexOf(value) === index);
272+return merged.length > 0 ? merged : undefined;
273+}
274+275+function mergeManifestContracts(
276+manifestContracts: PluginManifestContracts | undefined,
277+catalogContracts: PluginManifestContracts | undefined,
278+): PluginManifestContracts | undefined {
279+if (!catalogContracts) {
280+return manifestContracts;
281+}
282+const contracts: PluginManifestContracts = {};
283+for (const key of [
284+"embeddedExtensionFactories",
285+"agentToolResultMiddleware",
286+"externalAuthProviders",
287+"memoryEmbeddingProviders",
288+"speechProviders",
289+"realtimeTranscriptionProviders",
290+"realtimeVoiceProviders",
291+"mediaUnderstandingProviders",
292+"documentExtractors",
293+"imageGenerationProviders",
294+"videoGenerationProviders",
295+"musicGenerationProviders",
296+"webContentExtractors",
297+"webFetchProviders",
298+"webSearchProviders",
299+"migrationProviders",
300+"tools",
301+] as const) {
302+const merged = mergeContractLists(manifestContracts?.[key], catalogContracts[key]);
303+if (merged) {
304+contracts[key] = merged;
305+}
306+}
307+return Object.keys(contracts).length > 0 ? contracts : undefined;
308+}
309+310+function mergeCatalogChannelConfigs(params: {
311+manifestChannelConfigs?: Record<string, PluginManifestChannelConfig>;
312+catalogChannelConfigs?: Record<string, PluginManifestChannelConfig>;
313+}): Record<string, PluginManifestChannelConfig> | undefined {
314+if (!params.catalogChannelConfigs) {
315+return params.manifestChannelConfigs;
316+}
317+const merged: Record<string, PluginManifestChannelConfig> = Object.create(null);
318+for (const [key, value] of Object.entries(params.catalogChannelConfigs)) {
319+if (!isBlockedObjectKey(key)) {
320+merged[key] = value;
321+}
322+}
323+for (const [key, value] of Object.entries(params.manifestChannelConfigs ?? {})) {
324+if (!isBlockedObjectKey(key)) {
325+merged[key] = value;
326+}
327+}
328+return Object.keys(merged).length > 0 ? merged : undefined;
329+}
330+261331function buildRecord(params: {
262332manifest: PluginManifest;
263333candidate: PluginCandidate;
@@ -274,8 +344,17 @@ function buildRecord(params: {
274344packageManifest: params.candidate.packageManifest,
275345})
276346 : params.manifest.channelConfigs;
347+const officialCatalogManifest =
348+params.candidate.origin !== "bundled"
349+ ? getOfficialExternalPluginCatalogManifest(
350+getOfficialExternalPluginCatalogEntryForPackage(params.candidate.packageName) ?? {},
351+)
352+ : undefined;
277353const channelConfigs = mergePackageChannelMetaIntoChannelConfigs({
278-channelConfigs: manifestChannelConfigs,
354+channelConfigs: mergeCatalogChannelConfigs({
355+ manifestChannelConfigs,
356+catalogChannelConfigs: officialCatalogManifest?.channelConfigs,
357+}),
279358packageChannel: params.candidate.packageManifest?.channel,
280359});
281360const packageChannelCommands = normalizePackageChannelCommands(
@@ -341,7 +420,10 @@ function buildRecord(params: {
341420schemaCacheKey: params.schemaCacheKey,
342421configSchema: params.configSchema,
343422configUiHints: params.manifest.uiHints,
344-contracts: params.manifest.contracts,
423+contracts: mergeManifestContracts(
424+params.manifest.contracts,
425+officialCatalogManifest?.contracts,
426+),
345427mediaUnderstandingProviderMetadata: params.manifest.mediaUnderstandingProviderMetadata,
346428imageGenerationProviderMetadata: params.manifest.imageGenerationProviderMetadata,
347429videoGenerationProviderMetadata: params.manifest.videoGenerationProviderMetadata,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。