openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
63 lines (62 loc) • 2.81 kB
JavaScript
import { s as resolveInstalledPluginIndexStorePath } from "./installed-plugin-index-record-reader-CPHayOZI.js";
import { a as refreshPersistedInstalledPluginIndex, o as refreshPersistedInstalledPluginIndexSync } from "./installed-plugin-index-store-DyTBte5L.js";
import { n as recordPluginInstall } from "./installs-6qpt1tFm.js";
//#region src/plugins/installed-plugin-index-records.ts
/** Config path for legacy plugin install records kept for migration/doctor flows. */
const PLUGIN_INSTALLS_CONFIG_PATH = ["plugins", "installs"];
/** Resolves the installed plugin index record store path. */
function resolveInstalledPluginIndexRecordsStorePath(options = {}) {
return resolveInstalledPluginIndexStorePath(options);
}
/** Refreshes persisted installed plugin index records asynchronously. */
async function writePersistedInstalledPluginIndexInstallRecords(records, options = {}) {
await refreshPersistedInstalledPluginIndex({
...options,
reason: "source-changed",
installRecords: records
});
return resolveInstalledPluginIndexRecordsStorePath(options);
}
/** Refreshes persisted installed plugin index records synchronously. */
function writePersistedInstalledPluginIndexInstallRecordsSync(records, options = {}) {
refreshPersistedInstalledPluginIndexSync({
...options,
reason: "source-changed",
installRecords: records
});
return resolveInstalledPluginIndexRecordsStorePath(options);
}
/** Returns config with plugin install records attached at the canonical config path. */
function withPluginInstallRecords(config, records) {
return {
...config,
plugins: {
...config.plugins,
installs: records
}
};
}
/** Returns config with legacy plugin install records removed. */
function withoutPluginInstallRecords(config) {
if (!config.plugins?.installs) return config;
const { installs: _installs, ...plugins } = config.plugins;
if (Object.keys(plugins).length === 0) {
const { plugins: _plugins, ...rest } = config;
return rest;
}
return {
...config,
plugins
};
}
/** Applies one install update to an in-memory install record map. */
function recordPluginInstallInRecords(records, update) {
return recordPluginInstall({ plugins: { installs: records } }, update).plugins?.installs ?? {};
}
/** Removes one plugin install record from an in-memory record map. */
function removePluginInstallRecordFromRecords(records, pluginId) {
const { [pluginId]: _removed, ...rest } = records;
return rest;
}
//#endregion
export { withPluginInstallRecords as a, writePersistedInstalledPluginIndexInstallRecordsSync as c, resolveInstalledPluginIndexRecordsStorePath as i, recordPluginInstallInRecords as n, withoutPluginInstallRecords as o, removePluginInstallRecordFromRecords as r, writePersistedInstalledPluginIndexInstallRecords as s, PLUGIN_INSTALLS_CONFIG_PATH as t };