openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
597 lines (596 loc) • 25.2 kB
JavaScript
import { l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs";
import { u as normalizeSortedUniqueStringEntries } from "./string-normalization-DLmfYZXI.mjs";
import { t as pruneMapToMaxSize } from "./map-size-BBr20tbc.mjs";
import { n as freezeTrustedJsonSnapshot, r as isDeeplyFrozenPlainData } from "./immutable-data-Y7xVjZoy.mjs";
import { g as isPluginCandidateInstallOwnerAmbiguous, n as discoverOpenClawPlugins, y as resolvePluginCandidateInstallOwner } from "./discovery-DvJYrQFY.mjs";
import { a as getPluginCache } from "./plugin-cache-B_eRuqTM.mjs";
import { n as recordInstalledPluginIndexInstallOwner, r as resolveInstalledPluginIndexInstallOwner, t as isInstalledPluginIndexInstallOwnerAmbiguous } from "./installed-plugin-index-install-owner-DoEpptXw.mjs";
import { a as resolveCompatibilityHostVersion } from "./version-GlxUMdxI.mjs";
import { i as readBundledDiscoveryModeMemoized } from "./bundled-discovery-state-Bb0zCvZZ.mjs";
import { t as listPluginCompatRecords } from "./registry-C9ivbeN-.mjs";
import { n as isPathInside } from "./path-safety-CTChYC4Z.mjs";
import { a as pluginCacheRealpathSync, c as readPluginCacheFile, r as pluginCacheExistsSync } from "./plugin-cache-files-e1aGp2KM.mjs";
import { t as isPluginEnabledByDefaultForPlatform } from "./default-enablement-DLXVIwwO.mjs";
import { D as hasKind, c as normalizePluginId, f as resolveEffectiveEnableState, p as resolveEffectivePluginActivationState, r as createPluginActivationSource, u as normalizePluginsConfig } from "./config-state-B1JlHgba.mjs";
import { t as hashJson } from "./installed-plugin-index-hash-BfBbMPjv.mjs";
import { t as shouldRejectHardlinkedPluginFiles } from "./hardlink-policy-Kq1Lxk7_.mjs";
import { r as getRuntimeConfigCapture } from "./runtime-config-capture-state-CvRIlfib.mjs";
import { a as createPluginInstallRecordMap, c as parsePluginInstallRecordMap, o as getPluginInstallRecordMapEntry, u as setPluginInstallRecordMapEntry } from "./installed-plugin-index-row-CdwQuK63.mjs";
import { t as resolvePluginDoctorContractArtifact } from "./doctor-contract-artifact-DcW-zBOM.mjs";
import { t as describePluginInstallSource } from "./install-source-info-CLoSLSDu.mjs";
import { i as resolvePluginManifestInstallOwner } from "./manifest-registry-build-BbYTyBDW.mjs";
import { r as resolveInstalledPluginIndexStorePath } from "./installed-plugin-index-store-path-VYnur1Rc.mjs";
import { i as loadInstalledPluginIndexInstallRecordsSync } from "./installed-plugin-index-record-reader-B-7uGQZ9.mjs";
import { t as loadPluginManifestRegistryCore } from "./manifest-registry-CuWv8ibc.mjs";
import { t as resolvePluginMetadataEnvFingerprint } from "./plugin-metadata-env-DmZ06vdA.mjs";
import path from "node:path";
//#region src/plugins/installed-plugin-index-policy.ts
/** Hashes plugin compat registry state that can affect installed index validity. */
function resolveCompatRegistryVersion() {
return hashJson(listPluginCompatRecords().map((e) => ({
code: e.code,
status: e.status,
deprecated: e.deprecated,
warningStarts: e.warningStarts,
removeAfter: e.removeAfter,
removalGate: e.removalGate,
replacement: e.replacement
})));
}
/** Hashes config policy inputs that can change installed plugin activation. */
function resolveInstalledPluginIndexPolicyHash(e, t, n = {}) {
const r = normalizePluginsConfig(e?.plugins);
const i = {};
const a = e?.channels;
if (a && typeof a === "object" && !Array.isArray(a)) {
for (const [e, t] of Object.entries(a)) if (t && typeof t === "object" && !Array.isArray(t)) {
const n = t.enabled;
if (typeof n === "boolean") i[e] = n;
}
}
return hashJson({
plugins: {
enabled: r.enabled,
allow: r.allow,
deny: r.deny,
bundledDiscovery: readBundledDiscoveryModeMemoized(t, n) ?? null,
slots: r.slots,
entries: Object.fromEntries(Object.entries(r.entries).flatMap(([e, t]) => typeof t.enabled === "boolean" ? [[e, t.enabled]] : []).sort(([e], [t]) => e.localeCompare(t)))
},
channels: Object.fromEntries(Object.entries(i).sort(([e], [t]) => e.localeCompare(t)))
});
}
//#endregion
//#region src/plugins/installed-plugin-index-facts.ts
/** Package facts share the existing generation; mutable management inputs stay uncached. */
function getInstalledPluginIndexFacts(e) {
const t = getPluginCache().metadata.indexFacts;
const n = t.get(e);
if (n) return n;
if (!isDeeplyFrozenPlainData(e)) return;
const r = {};
t.set(e, r);
return r;
}
//#endregion
//#region src/plugins/bundled-compat.ts
/** Returns config with selected bundled plugins explicitly enabled when compat rules require it. */
function withBundledPluginEnablementCompat(e) {
if (e.pluginIds.length === 0) return e.config;
const t = e.config?.plugins?.entries ?? {};
const n = e.activation !== "defaults";
const r = n && e.config?.plugins?.enabled === false;
const i = e.config?.plugins?.allow;
const a = readBundledDiscoveryModeMemoized(e.env, { artifactPreservingReadOnly: e.artifactPreservingReadOnly }) === "compat";
const o = !a && Array.isArray(i) && i.length > 0 ? new Set(i.map((e) => normalizePluginId(e)).filter(Boolean)) : void 0;
let s = false;
let c = false;
const l = { ...t };
const u = a && Array.isArray(i) ? new Set(i) : void 0;
for (const r of e.pluginIds) {
if (o && !o.has(r)) continue;
s = true;
const e = u?.size;
u?.add(r);
if (u && u.size !== e) c = true;
if (!n || t[r] !== void 0) continue;
l[r] = { enabled: true };
c = true;
}
if (!c && (!r || !s)) return e.config;
return {
...e.config,
plugins: {
...e.config?.plugins,
...r ? { enabled: true } : {},
...u ? { allow: [...u] } : {},
...n ? { entries: l } : {}
}
};
}
//#endregion
//#region src/plugins/bundled-provider-compat.ts
const BUNDLED_PROVIDER_COMPAT_CONTRACT_KEYS = [
"speechProviders",
"externalAuthProviders",
"embeddingProviders",
"mediaUnderstandingProviders",
"transcriptSourceProviders",
"realtimeVoiceProviders",
"realtimeTranscriptionProviders",
"imageGenerationProviders",
"videoGenerationProviders",
"musicGenerationProviders",
"webFetchProviders",
"webSearchProviders",
"workerProviders",
"storageProviders",
"usageProviders",
"migrationProviders"
];
const BUNDLED_PROVIDER_COMPAT_CONTRACTS = new Set(BUNDLED_PROVIDER_COMPAT_CONTRACT_KEYS);
function isBundledProviderCompatContract(e) {
return BUNDLED_PROVIDER_COMPAT_CONTRACTS.has(e);
}
function isBundledProviderCompatPlugin(e) {
return e.origin === "bundled" && ((e.providers?.length ?? 0) > 0 || BUNDLED_PROVIDER_COMPAT_CONTRACT_KEYS.some((t) => (e.contracts?.[t]?.length ?? 0) > 0));
}
//#endregion
//#region src/plugins/installed-plugin-index-config-path-scope.ts
/** Compat code marking install records that need config-path activation metadata. */
const CONFIG_PATH_ACTIVATION_COMPAT_CODE = "activation-config-path-hint";
function recordUsesConfigPathActivation(e) {
return e.compat.includes(CONFIG_PATH_ACTIVATION_COMPAT_CODE);
}
/** True when an index still has config-path activation records missing startup metadata. */
function hasMissingConfigPathActivationMetadata(e) {
return e.plugins.some((e) => recordUsesConfigPathActivation(e) && e.startup.configPaths === void 0);
}
/** True when a record migrated config-path activation startup metadata. */
function hasConfigPathActivationMetadataMigration(e) {
return recordUsesConfigPathActivation(e.previous) && e.previous.startup.configPaths === void 0 && e.current.startup.configPaths !== void 0;
}
//#endregion
//#region src/plugins/installed-plugin-index-install-records.ts
/** Normalizes durable plugin install records into installed-index metadata and back. */
/** Normalizes raw plugin install records into index-safe install record metadata. */
function normalizeInstallRecordMap(e) {
const t = parsePluginInstallRecordMap(e ?? {});
if (!t) throw new Error("Invalid plugin install record map");
return t;
}
function restoreInstallRecordMap(e) {
const t = parsePluginInstallRecordMap(e ?? {});
if (!t) throw new Error("Invalid persisted plugin install record map");
return t;
}
/** Copies canonical install records out of the installed index. */
function extractPluginInstallRecordsFromInstalledPluginIndex(e) {
const t = e ? getInstalledPluginIndexFacts(e) : void 0;
if (!t) return restoreInstallRecordMap(e?.installRecords);
const n = t.installRecords ??= restoreInstallRecordMap(e?.installRecords);
const r = createPluginInstallRecordMap();
for (const [e, t] of Object.entries(n)) setPluginInstallRecordMapEntry(r, e, {
...t,
...t.clawhubTrustReasons ? { clawhubTrustReasons: [...t.clawhubTrustReasons] } : {},
...t.contextEngineIdsByPlugin ? { contextEngineIdsByPlugin: structuredClone(t.contextEngineIdsByPlugin) } : {},
...t.acceptedSurface ? { acceptedSurface: structuredClone(t.acceptedSurface) } : {}
});
return r;
}
//#endregion
//#region src/plugins/installed-plugin-index-manifest.ts
/** True when the bundle format permits omitting its manifest file. */
function isOptionalPluginManifestFile(e) {
return e.format === "bundle" && e.bundleFormat === "claude";
}
/** True when a Claude bundle record omits its optional manifest file. */
function hasOptionalMissingPluginManifestFile(e) {
return isOptionalPluginManifestFile(e) && !pluginCacheExistsSync(e.manifestPath);
}
//#endregion
//#region src/plugins/installed-plugin-index-record-builder.ts
/** Builds installed-index records from normalized plugin manifest registry entries. */
function buildStartupInfo(e) {
return {
sidecar: e.activation?.onStartup === true,
memory: hasKind(e.kind, "memory"),
agentHarnesses: normalizeSortedUniqueStringEntries([...e.activation?.onAgentHarnesses ?? [], ...e.cliBackends ?? []]),
configPaths: normalizeSortedUniqueStringEntries(e.activation?.onConfigPaths)
};
}
function buildContributionInfo(e) {
const t = Object.fromEntries(Object.entries(e.contracts ?? {}).map(([e, t]) => [e, normalizeSortedUniqueStringEntries(t)]));
return {
channels: normalizeSortedUniqueStringEntries(e.channels),
channelConfigs: normalizeSortedUniqueStringEntries(Object.keys(e.channelConfigs ?? {})),
providers: normalizeSortedUniqueStringEntries(e.providers),
modelCatalogProviders: normalizeSortedUniqueStringEntries([
...Object.keys(e.modelCatalog?.providers ?? {}),
...Object.keys(e.modelCatalog?.aliases ?? {}),
...(e.modelCatalog?.suppressions ?? []).map((e) => e.provider)
]),
modelSupportPrefixes: normalizeSortedUniqueStringEntries(e.modelSupport?.modelPrefixes),
modelSupportPatterns: normalizeSortedUniqueStringEntries(e.modelSupport?.modelPatterns),
autoEnableProviderIds: normalizeSortedUniqueStringEntries(e.autoEnableWhenConfiguredProviders),
commandAliases: normalizeSortedUniqueStringEntries(e.commandAliases?.map((e) => e.name)),
contracts: t
};
}
const ACTIVATION_COMPAT_CODES = [
["onProviders", "activation-provider-hint"],
["onAgentHarnesses", "activation-agent-harness-hint"],
["onChannels", "activation-channel-hint"],
["onCommands", "activation-command-hint"],
["onRoutes", "activation-route-hint"],
["onConfigPaths", "activation-config-path-hint"],
["onCapabilities", "activation-capability-hint"]
];
/** Collects compatibility codes implied by a manifest's legacy or activation surfaces. */
function collectPluginManifestCompatCodes(e) {
return ACTIVATION_COMPAT_CODES.filter(([t]) => e.activation?.[t]?.length).map(([, e]) => e).toSorted();
}
function resolvePackageJsonRecord(e) {
const { candidate: t } = e;
if (!t?.packageDir) return;
const n = readPluginCacheFile({
rootDir: t.packageDir,
relativePath: "package.json",
rejectHardlinks: e.rejectHardlinks
});
if (!n.ok) return;
const r = t.rootDir === t.packageDir ? n.rootRealPath : pluginCacheRealpathSync(t.rootDir) ?? path.resolve(t.rootDir);
if (!isPathInside(r, n.path)) return;
const i = path.join(n.rootRealPath, "package.json");
return {
path: (path.relative(r, i) || "package.json").split(path.sep).join("/"),
hash: n.hash,
fileSignature: n.signature
};
}
function describePackageInstallSource(e) {
const t = e?.packageManifest?.install;
if (!t) return;
return describePluginInstallSource(t, { expectedPackageName: e?.packageName });
}
function normalizePackageChannel(e) {
const t = normalizeOptionalString(e?.id);
if (!t) return;
return {
...structuredClone(e),
id: t
};
}
function hashManifestlessBundleRecord(e) {
return hashJson({
id: e.id,
name: e.name,
description: e.description,
version: e.version,
format: e.format,
bundleFormat: e.bundleFormat,
bundleCapabilities: e.bundleCapabilities ?? [],
skills: e.skills ?? [],
settingsFiles: e.settingsFiles ?? [],
hooks: e.hooks ?? []
});
}
function readRecordFile(e) {
const t = e.boundaryRoot ?? e.record.rootDir;
const n = readPluginCacheFile({
rootDir: t,
relativePath: path.relative(t, e.filePath),
rejectHardlinks: e.rejectHardlinks,
...e.required && path.extname(e.filePath) === ".json" ? { maxBytes: 262144 } : {}
});
if (n.ok) return n;
if (e.required) e.diagnostics.push({
level: "warn",
pluginId: e.record.id,
source: e.filePath,
message: `installed plugin index could not hash ${e.filePath}: ${n.failure.reason}`
});
}
function buildInstalledPluginIndexRecords(e) {
const t = new Map(e.candidates.map((e) => [e.source, e]));
return e.registry.plugins.map((n) => {
const r = t.get(n.source);
const i = shouldRejectHardlinkedPluginFiles({
origin: n.origin,
rootDir: n.rootDir,
env: e.env
});
const a = r && isPluginCandidateInstallOwnerAmbiguous(r) ? void 0 : resolvePluginManifestInstallOwner(n) ?? (r ? resolvePluginCandidateInstallOwner(r) : void 0);
const o = a ? getPluginInstallRecordMapEntry(e.installRecords, a) : void 0;
const s = describePackageInstallSource(r);
const c = normalizePackageChannel(n.packageChannel ?? r?.packageManifest?.channel);
const l = hasOptionalMissingPluginManifestFile(n);
const u = l ? void 0 : readRecordFile({
record: n,
filePath: n.manifestPath,
rejectHardlinks: i,
required: true,
diagnostics: e.diagnostics
});
const d = l ? hashManifestlessBundleRecord(n) : u?.hash ?? "";
const f = resolvePluginDoctorContractArtifact(n);
const p = f ? readRecordFile({
record: n,
filePath: f.modulePath,
boundaryRoot: f.boundaryRoot,
rejectHardlinks: i,
diagnostics: e.diagnostics,
required: false
}) : void 0;
const m = resolvePackageJsonRecord({
candidate: r,
rejectHardlinks: i
});
const h = {
pluginId: n.id,
...n.contextEngineIds ? { contextEngineIds: n.contextEngineIds } : {},
manifestPath: n.manifestPath,
manifestHash: d,
...p ? {
doctorContractHash: p.hash,
doctorContractFile: p.signature
} : {},
...u ? { manifestFile: u.signature } : {},
source: n.source,
rootDir: n.rootDir,
origin: n.origin,
startup: buildStartupInfo(n),
contributions: buildContributionInfo(n),
compat: collectPluginManifestCompatCodes(n)
};
if (n.format && n.format !== "openclaw") h.format = n.format;
if (n.bundleFormat) h.bundleFormat = n.bundleFormat;
if (n.enabledByDefault === true) h.enabledByDefault = true;
if (n.enabledByDefaultOnPlatforms?.length) h.enabledByDefaultOnPlatforms = [...n.enabledByDefaultOnPlatforms];
if (n.syntheticAuthRefs?.length) h.syntheticAuthRefs = [...n.syntheticAuthRefs];
if (n.setupSource) h.setupSource = n.setupSource;
if (r?.packageName) h.packageName = r.packageName;
if (r?.packageVersion) h.packageVersion = r.packageVersion;
if (o) h.installRecordHash = hashJson(o);
if (s) h.packageInstall = s;
if (c) h.packageChannel = c;
if (r?.packageManifest?.build) h.packageBuild = structuredClone(r.packageManifest.build);
if (m) h.packageJson = m;
return recordInstalledPluginIndexInstallOwner(h, a, r ? isPluginCandidateInstallOwnerAmbiguous(r) : false);
});
}
//#endregion
//#region src/plugins/installed-plugin-index-types.ts
const INSTALLED_PLUGIN_INDEX_WARNING = "DO NOT EDIT. This file is generated by OpenClaw from plugin manifests, install records, and config policy. Use `openclaw plugins registry --refresh`, `openclaw plugins install/update/uninstall`, or `openclaw plugins enable/disable` instead.";
//#endregion
//#region src/plugins/installed-plugin-index.ts
/** Public installed-plugin-index API for load, refresh, policy hash, and invalidation checks. */
function buildInstalledPluginIndex(e) {
const t = e.env ?? process.env;
const n = normalizeInstallRecordMap(e.installRecords ?? loadInstalledPluginIndexInstallRecordsSync({
env: t,
...e.stateDir ? { stateDir: e.stateDir } : {},
...e.pluginIndexFilePath ? { filePath: e.pluginIndexFilePath } : {}
}));
const r = e.candidates ? {
candidates: e.candidates,
diagnostics: e.diagnostics ?? []
} : e.discovery ?? discoverOpenClawPlugins({
workspaceDir: e.workspaceDir,
extraPaths: normalizePluginsConfig(e.config?.plugins).loadPaths,
env: t,
installRecords: n
});
const i = !e.candidates && e.diagnostics?.length ? {
...r,
diagnostics: [...r.diagnostics, ...e.diagnostics]
} : r;
const a = e.config;
const o = a && getRuntimeConfigCapture(a) && !e.candidates && !e.discovery && !e.refreshReason ? getPluginCache().metadata.derivedIndexes : void 0;
const s = resolveInstalledPluginIndexStorePath({
env: t,
stateDir: e.stateDir,
filePath: e.pluginIndexFilePath
});
const c = resolveCompatibilityHostVersion(t);
const l = resolveCompatRegistryVersion();
const u = o ? hashJson({
discovery: i,
installRecords: n,
registryPath: s,
hostContractVersion: c,
compatRegistryVersion: l,
artifactPreservingReadOnly: e.artifactPreservingReadOnly === true,
env: resolvePluginMetadataEnvFingerprint(t),
policy: resolveInstalledPluginIndexPolicyHash(a, t, { artifactPreservingReadOnly: e.artifactPreservingReadOnly })
}) : void 0;
const d = a && u ? o?.get(a)?.get(u) : void 0;
if (d) {
const { workspaceDir: t, ...n } = d.index;
const r = freezeTrustedJsonSnapshot({
...n,
generatedAtMs: (e.now?.() ?? /* @__PURE__ */ new Date()).getTime(),
...e.workspaceDir !== void 0 ? { workspaceDir: e.workspaceDir } : {}
});
const a = getInstalledPluginIndexFacts(d.index);
const o = getInstalledPluginIndexFacts(r);
if (o && a?.fingerprint) o.fingerprint = a.fingerprint;
return {
index: r,
discovery: i,
manifestRegistry: d.manifestRegistry
};
}
const f = loadPluginManifestRegistryCore({
registryPath: s,
config: e.config,
workspaceDir: e.workspaceDir,
env: t,
candidates: i.candidates,
diagnostics: i.diagnostics,
installRecords: n
});
const p = [...f.diagnostics ?? []];
const m = (e.now?.() ?? /* @__PURE__ */ new Date()).getTime();
const h = projectInstalledPluginIndexPolicy({
plugins: buildInstalledPluginIndexRecords({
candidates: i.candidates,
registry: f,
env: t,
diagnostics: p,
installRecords: n
}),
config: e.config,
env: t,
artifactPreservingReadOnly: e.artifactPreservingReadOnly
});
let g = {
version: 1,
warning: INSTALLED_PLUGIN_INDEX_WARNING,
hostContractVersion: c,
compatRegistryVersion: l,
migrationVersion: 1,
policyHash: resolveInstalledPluginIndexPolicyHash(e.config, t, { artifactPreservingReadOnly: e.artifactPreservingReadOnly }),
generatedAtMs: m,
...e.workspaceDir !== void 0 ? { workspaceDir: e.workspaceDir } : {},
...e.refreshReason ? { refreshReason: e.refreshReason } : {},
installRecords: n,
plugins: h,
diagnostics: p
};
if (o && u && a) {
let e = o.get(a);
if (!e) o.set(a, e = /* @__PURE__ */ new Map());
g = freezeTrustedJsonSnapshot(structuredClone(g));
e.set(u, {
index: g,
manifestRegistry: f
});
pruneMapToMaxSize(e, 64);
}
return {
index: g,
discovery: e.candidates ? void 0 : i,
manifestRegistry: f
};
}
/**
* Activation is the only config-owned index fact. A policy change re-projects the
* same disk inventory in memory; only install, uninstall or source changes rescan.
*/
function projectInstalledPluginIndexPolicy(e) {
const t = withBundledPluginEnablementCompat({
config: e.config,
env: e.env,
pluginIds: e.plugins.filter(isInstalledBundledProvider).map((e) => e.pluginId),
activation: "defaults",
artifactPreservingReadOnly: e.artifactPreservingReadOnly
});
const n = normalizePluginsConfig(t?.plugins);
return e.plugins.map((e) => ({
...e,
enabled: resolveEffectiveEnableState({
id: e.pluginId,
origin: e.origin,
channelIds: e.contributions?.channels,
config: n,
rootConfig: t,
enabledByDefault: isPluginEnabledByDefaultForPlatform(e)
}).enabled
}));
}
function loadInstalledPluginIndex(e = {}) {
return buildInstalledPluginIndex(e).index;
}
function loadInstalledPluginIndexWithDiscovery(e = {}) {
return buildInstalledPluginIndex(e);
}
/** True when a persisted index cannot represent the requested workspace discovery scope. */
function hasInstalledPluginIndexWorkspaceScopeMismatch(e, t) {
if (t !== void 0) return e.workspaceDir !== t;
return e.workspaceDir !== void 0 || e.plugins.some((e) => e.origin === "workspace");
}
function refreshInstalledPluginIndex(e) {
return buildInstalledPluginIndex({
...e,
refreshReason: e.reason
}).index;
}
function isInstalledPluginEnabled(e, t, n, r) {
const i = e.plugins.find((e) => e.pluginId === t);
if (!i || !n) return i?.enabled ?? false;
return createInstalledPluginEnabledPredicate([i], n, r)(t);
}
function isInstalledBundledProvider(e) {
return isBundledProviderCompatPlugin({
origin: e.origin,
providers: e.contributions?.providers,
contracts: e.contributions?.contracts
});
}
/** Prepare live policy for one synchronous operation, never across config/root changes. */
function createInstalledPluginEnabledPredicate(e, t, n) {
let r;
let i;
let a;
return (o) => {
if (!a) {
a = /* @__PURE__ */ new Map();
for (const t of e) if (!a.has(t.pluginId)) a.set(t.pluginId, t);
}
const s = a.get(o);
if (!s || !t) return s?.enabled ?? false;
let c;
if (isInstalledBundledProvider(s)) {
if (!i) {
const a = withBundledPluginEnablementCompat({
config: t,
env: n,
pluginIds: e.filter(isInstalledBundledProvider).map((e) => e.pluginId),
activation: "defaults"
});
i = a === t ? r ??= createPluginActivationSource({ config: t }) : createPluginActivationSource({ config: a });
}
c = i;
} else c = r ??= createPluginActivationSource({ config: t });
return resolveEffectivePluginActivationState({
id: s.pluginId,
origin: s.origin,
channelIds: s.contributions?.channels,
config: c.plugins,
rootConfig: c.rootConfig,
activationSource: c,
enabledByDefault: isPluginEnabledByDefaultForPlatform(s)
}).enabled;
};
}
function diffInstalledPluginIndexInvalidationReasons(e, t) {
const n = /* @__PURE__ */ new Set();
if (e.version !== t.version) n.add("missing");
if (e.hostContractVersion !== t.hostContractVersion) n.add("host-contract-changed");
if (e.compatRegistryVersion !== t.compatRegistryVersion) n.add("compat-registry-changed");
if (e.migrationVersion !== t.migrationVersion) n.add("migration");
if (e.policyHash !== t.policyHash) n.add("policy-changed");
if (hashJson(e.installRecords ?? {}) !== hashJson(t.installRecords ?? {})) n.add("source-changed");
const r = new Map(e.plugins.map((e) => [e.pluginId, e]));
const i = new Map(t.plugins.map((e) => [e.pluginId, e]));
for (const [e, t] of r) {
const r = i.get(e);
if (!r) {
n.add("source-changed");
continue;
}
if (t.rootDir !== r.rootDir || t.manifestPath !== r.manifestPath || t.source !== r.source || t.setupSource !== r.setupSource || resolveInstalledPluginIndexInstallOwner(t) !== resolveInstalledPluginIndexInstallOwner(r) || isInstalledPluginIndexInstallOwnerAmbiguous(t) !== isInstalledPluginIndexInstallOwnerAmbiguous(r) || t.installRecordHash !== r.installRecordHash) n.add("source-changed");
if (t.enabled !== r.enabled) n.add("policy-changed");
if (hasConfigPathActivationMetadataMigration({
previous: t,
current: r
})) n.add("migration");
if (t.manifestHash !== r.manifestHash || t.doctorContractHash !== r.doctorContractHash) n.add("stale-manifest");
if (t.packageVersion !== r.packageVersion || t.packageJson?.path !== r.packageJson?.path || t.packageJson?.hash !== r.packageJson?.hash) n.add("stale-package");
}
for (const [e, t] of i) if (!r.has(e) && t.enabled) n.add("source-changed");
return Array.from(n).toSorted((e, t) => e.localeCompare(t));
}
//#endregion
export { withBundledPluginEnablementCompat as _, loadInstalledPluginIndex as a, resolveInstalledPluginIndexPolicyHash as b, refreshInstalledPluginIndex as c, hasOptionalMissingPluginManifestFile as d, isOptionalPluginManifestFile as f, isBundledProviderCompatPlugin as g, isBundledProviderCompatContract as h, isInstalledPluginEnabled as i, INSTALLED_PLUGIN_INDEX_WARNING as l, hasMissingConfigPathActivationMetadata as m, diffInstalledPluginIndexInvalidationReasons as n, loadInstalledPluginIndexWithDiscovery as o, extractPluginInstallRecordsFromInstalledPluginIndex as p, hasInstalledPluginIndexWorkspaceScopeMismatch as r, projectInstalledPluginIndexPolicy as s, createInstalledPluginEnabledPredicate as t, collectPluginManifestCompatCodes as u, getInstalledPluginIndexFacts as v, resolveCompatRegistryVersion as y };