skill manager 添加脚本管理功能,支持写入和删除可复用脚本
This commit is contained in:
@@ -14,12 +14,15 @@ const FORBIDDEN_PERSISTENCE_PATTERNS = [
|
||||
/eyJ[a-zA-Z0-9_-]{8,}\.[a-zA-Z0-9._-]{8,}\.[a-zA-Z0-9._-]{8,}/,
|
||||
];
|
||||
|
||||
export const containsForbiddenPersistentContent = (content: string) =>
|
||||
FORBIDDEN_PERSISTENCE_PATTERNS.some((pattern) => pattern.test(content));
|
||||
|
||||
export const sanitizePersistentLine = (content: string, maxLength: number) => {
|
||||
const normalized = content.replace(/\s+/g, " ").trim();
|
||||
if (!normalized) {
|
||||
return "";
|
||||
}
|
||||
if (FORBIDDEN_PERSISTENCE_PATTERNS.some((pattern) => pattern.test(normalized))) {
|
||||
if (containsForbiddenPersistentContent(normalized)) {
|
||||
return "";
|
||||
}
|
||||
if (normalized.length > maxLength) {
|
||||
@@ -39,7 +42,7 @@ export const sanitizePersistentDocument = (content: string, maxLength: number) =
|
||||
if (!normalized) {
|
||||
return "";
|
||||
}
|
||||
if (FORBIDDEN_PERSISTENCE_PATTERNS.some((pattern) => pattern.test(normalized))) {
|
||||
if (containsForbiddenPersistentContent(normalized)) {
|
||||
return "";
|
||||
}
|
||||
if (normalized.length > maxLength) {
|
||||
@@ -47,3 +50,17 @@ export const sanitizePersistentDocument = (content: string, maxLength: number) =
|
||||
}
|
||||
return normalized;
|
||||
};
|
||||
|
||||
export const sanitizePersistentScript = (content: string, maxLength: number) => {
|
||||
const normalized = content.replace(/\r\n/g, "\n").replace(/\t/g, " ").trim();
|
||||
if (!normalized) {
|
||||
return "";
|
||||
}
|
||||
if (containsForbiddenPersistentContent(normalized)) {
|
||||
return "";
|
||||
}
|
||||
if (normalized.length > maxLength) {
|
||||
return "";
|
||||
}
|
||||
return `${normalized}\n`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user