const { CacheKeys } = require('librechat-data-provider'); const { AppService } = require('@librechat/data-schemas'); const { createAppConfigService } = require('@librechat/api'); const { loadAndFormatTools } = require('~/server/services/start/tools'); const loadCustomConfig = require('./loadCustomConfig'); const { setCachedTools } = require('./getCachedTools'); const getLogStores = require('~/cache/getLogStores'); const paths = require('~/config/paths'); const db = require('~/models'); const loadBaseConfig = async () => { /** @type {TCustomConfig} */ const config = (await loadCustomConfig()) ?? {}; /** @type {Record} */ const systemTools = loadAndFormatTools({ adminFilter: config.filteredTools, adminIncluded: config.includedTools, directory: paths.structuredTools, }); return AppService({ config, paths, systemTools }); }; const { getAppConfig, clearAppConfigCache } = createAppConfigService({ loadBaseConfig, setCachedTools, getCache: getLogStores, cacheKeys: CacheKeys, getApplicableConfigs: db.getApplicableConfigs, getUserPrincipals: db.getUserPrincipals, }); module.exports = { getAppConfig, clearAppConfigCache, };