mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-09-04 05:28:30 +00:00
* feat: introduce optional content protection seam * feat: enforce source-aware content filters * feat: complete source-aware content enforcement * test: activate skill file-text fail-close fixtures * fix: harden source-aware content filters * fix: harden model-bound content filtering * fix: preserve legacy filters and generated files * fix: inspect shared scalar metadata * test: align mocks with current dev dependencies * feat: add persisted content filter safeguards * feat: complete source-aware content filter enforcement * fix: move resume content preflight into TypeScript * fix: close content inspection edge cases * fix: harden content protection boundaries * fix: complete content protection safeguards * test: align persisted memory filter coverage * fix: reconcile content protection with current dev * fix: reconcile content protection with latest dev * fix: close content protection review gaps * fix: enforce source-aware provider boundaries * fix: preserve legacy PII preflight semantics * test: stabilize stored branch preflight fixture * fix: defer agent writes until protected model admission * perf: harden source-aware model-bound filtering * fix: canonicalize provider lineage before validation * fix: satisfy model-bound callback type checks * perf: Bound content protection filtering work * fix: Bound submission array traversal * fix: Stabilize bounded content snapshots * fix: Scope model-bound traversal overflows * fix: Preserve scoped content inspection * fix: Accumulate aggregate traversal scopes * fix: centralize content policy boundaries * test: align deferred tool policy context * test: align controller policy mocks * style: normalize content protection imports * fix: close content policy review gaps * fix: narrow active skill policy config * fix: address content protection review boundaries * fix: retain exact provenance overflow sentinel * fix: preserve literal and scoped provenance updates * fix: narrow persisted edit provenance * fix: isolate exact overflow attribution * fix: centralize stored prompt protection * fix: fail closed on incomplete transcript evidence * fix: align canonical transcript routing * refactor: centralize content policy preflights * fix: isolate upload policy error typing * style: sort policy preflight imports * refactor: centralize content policy boundaries
50 lines
1.8 KiB
JavaScript
50 lines
1.8 KiB
JavaScript
const fs = require('fs').promises;
|
|
const { resolveImportMaxFileSize } = require('@librechat/api');
|
|
const { logger } = require('@librechat/data-schemas');
|
|
const { getImporter } = require('./importers');
|
|
const { createImportBatchBuilder } = require('./importBatchBuilder');
|
|
|
|
const maxFileSize = resolveImportMaxFileSize();
|
|
|
|
/**
|
|
* Job definition for importing a conversation.
|
|
* @param {{ filepath: string, requestUserId: string, userRole?: string, interfaceConfig?: object, filters?: object, legacyPii?: object }} job
|
|
*/
|
|
const importConversations = async (job) => {
|
|
const { filepath, requestUserId, userRole, interfaceConfig, filters, legacyPii } = job;
|
|
try {
|
|
logger.debug(`user: ${requestUserId} | Importing conversation(s) from file...`);
|
|
|
|
const fileInfo = await fs.stat(filepath);
|
|
if (fileInfo.size > maxFileSize) {
|
|
throw new Error(
|
|
`File size is ${fileInfo.size} bytes. It exceeds the maximum limit of ${maxFileSize} bytes.`,
|
|
);
|
|
}
|
|
|
|
const fileData = await fs.readFile(filepath, 'utf8');
|
|
const jsonData = JSON.parse(fileData);
|
|
const importer = getImporter(jsonData);
|
|
await importer(
|
|
jsonData,
|
|
requestUserId,
|
|
(userId) =>
|
|
legacyPii == null
|
|
? createImportBatchBuilder(userId, interfaceConfig, filters)
|
|
: createImportBatchBuilder(userId, interfaceConfig, filters, legacyPii),
|
|
userRole,
|
|
);
|
|
logger.debug(`user: ${requestUserId} | Finished importing conversations`);
|
|
} catch (error) {
|
|
logger.error(`user: ${requestUserId} | Failed to import conversation: `, error);
|
|
throw error; // throw error all the way up so request does not return success
|
|
} finally {
|
|
try {
|
|
await fs.unlink(filepath);
|
|
} catch (error) {
|
|
logger.error(`user: ${requestUserId} | Failed to delete file: ${filepath}`, error);
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = importConversations;
|