openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
64 lines (63 loc) • 1.96 kB
JavaScript
import { t as applyExclusiveSlotSelection } from "./slots-CQdAEuat.js";
import { a as loadPluginMetadataSnapshot } from "./plugin-metadata-snapshot-w-4EjxI4.js";
import { a as buildPluginDiagnosticsReport } from "./status-DornsoQ9.js";
//#region src/plugins/slot-selection.ts
function mergeRuntimeKinds(report, runtimeReport) {
const runtimeKinds = new Map(runtimeReport.plugins.filter((plugin) => plugin.kind).map((plugin) => [plugin.id, plugin.kind]));
return { plugins: report.plugins.map((plugin) => {
if (plugin.kind) return plugin;
const runtimeKind = runtimeKinds.get(plugin.id);
return runtimeKind ? {
...plugin,
kind: runtimeKind
} : plugin;
}) };
}
function applySlotSelectionForPlugin(config, pluginId, preparedMetadata) {
const metadataSnapshot = preparedMetadata ?? loadPluginMetadataSnapshot({
allowCurrent: false,
config,
env: process.env
});
const report = { plugins: metadataSnapshot.plugins.filter((plugin) => plugin.id === pluginId).map((plugin) => ({
id: plugin.id,
kind: plugin.kind
})) };
const plugin = report.plugins.find((entry) => entry.id === pluginId);
if (!plugin) return {
config,
warnings: []
};
if (!plugin.kind) {
const runtimeReport = buildPluginDiagnosticsReport({
config,
onlyPluginIds: [plugin.id],
metadataSnapshot
});
const runtimePlugin = runtimeReport.plugins.find((entry) => entry.id === plugin.id);
if (runtimePlugin?.kind) {
const result = applyExclusiveSlotSelection({
config,
selectedId: runtimePlugin.id,
selectedKind: runtimePlugin.kind,
registry: mergeRuntimeKinds(report, runtimeReport)
});
return {
config: result.config,
warnings: result.warnings
};
}
}
const result = applyExclusiveSlotSelection({
config,
selectedId: plugin.id,
selectedKind: plugin.kind,
registry: report
});
return {
config: result.config,
warnings: result.warnings
};
}
//#endregion
export { applySlotSelectionForPlugin as t };