Update streaming handling and improve model validation

Add MAX_STREAM_CHUNKS constant and update message handling to mark streaming as complete even without tool results.
Improve model name validation to support colons and add comprehensive test suite. Refactor VaultIndexer to simplify
constructor and remove unused methods. Fix path normalization in tool executor and remove unused safeWriteFile export.
Update error handling to remove redundant console suppressions.
This commit is contained in:
2026-05-06 21:48:27 +02:00
parent 3f23335ba1
commit ccb0603d0c
19 changed files with 1214 additions and 1508 deletions
+2 -13
View File
@@ -7,7 +7,6 @@ exports.validateModelName = validateModelName;
exports.validatePluginSettings = validatePluginSettings;
exports.safeParseJson = safeParseJson;
exports.sanitizeFilePath = sanitizeFilePath;
exports.safeWriteFile = safeWriteFile;
exports.isValidHttpUrl = isValidHttpUrl;
exports.convertMarkdownToHtml = convertMarkdownToHtml;
// ==================== Logger ====================
@@ -36,25 +35,21 @@ class Logger {
}
static debug(message, category = 'general') {
if (LogLevel.DEBUG >= Logger.minLevel) {
// eslint-disable-next-line no-console
console.debug(`[${category}] DEBUG: ${message}`);
}
}
static info(message, category = 'general') {
if (LogLevel.INFO >= Logger.minLevel) {
// eslint-disable-next-line no-console
console.info(`[${category}] INFO: ${message}`);
}
}
static warn(message, category = 'general') {
if (LogLevel.WARN >= Logger.minLevel) {
// eslint-disable-next-line no-console
console.warn(`[${category}] WARN: ${message}`);
}
}
static error(message, category = 'general') {
if (LogLevel.ERROR >= Logger.minLevel) {
// eslint-disable-next-line no-console
console.error(`[${category}] ERROR: ${message}`);
}
}
@@ -96,10 +91,10 @@ function validateModelName(model) {
if (trimmedModel.length > 100) {
return { valid: false, error: 'Model name must be less than 100 characters long' };
}
if (!/^[a-zA-Z0-9._-]+$/.test(trimmedModel)) {
if (!/^[a-zA-Z0-9._:-]+$/.test(trimmedModel)) {
return {
valid: false,
error: 'Model name can only contain letters, numbers, dots, dashes, and underscores',
error: 'Model name can only contain letters, numbers, dots, dashes, underscores, and colons',
};
}
return { valid: true };
@@ -169,12 +164,6 @@ function sanitizeFilePath(path) {
}
return path;
}
function safeWriteFile(filePath, content) {
const sanitizedPath = sanitizeFilePath(filePath);
// eslint-disable-next-line no-console
console.log(`Writing to ${sanitizedPath}:`, content);
return Promise.resolve();
}
// ==================== HTTP Helpers ====================
function isValidHttpUrl(url) {
try {