Merge branch 'staging' into webpack-cache-dataroot

1ef5154770824ca876b22d494e55dff84b06da5a

Cohee <18619528+Cohee1207@users.noreply.github.com>

19 files changed, +43 -22Showing whitespace changes
public/index.html+1 -1
@@ -4666,7 +4666,7 @@
46664666 <small data-i18n="Enabled">Enabled</small>
46674667 </label>
46684668 <small data-i18n="Minimum generated message length">Minimum generated message length</small>
46694669 <input id="auto_swipe_minimum_length" name="auto_swipe_minimum_length" type="number" min="0" step="1" value="0" class="text_pole" title="If the generated message is shorter than thisthese many characters, trigger an auto-swipe." data-i18n="[title]If the generated message is shorter than thisthese many characters, trigger an auto-swipe">
46704670 <small data-i18n="Blacklisted words">Blacklisted words</small>
46714671 <div class="auto_swipe">
46724672 <textarea id="auto_swipe_blacklist" name="auto_swipe_blacklist" data-i18n="[placeholder]words you dont want generated separated by comma ','" placeholder="words you don't want generated separated by comma ','" class="text_pole textarea_compact" value="" autocomplete="off" rows="3"></textarea>
public/locales/ar-sa.json+1 -1
@@ -709,7 +709,7 @@
709709 "Auto-swipe": "السحب التلقائي",
710710 "Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "تمكين وظيفة السحب التلقائي. الإعدادات في هذا القسم تؤثر فقط عند تمكين السحب التلقائي",
711711 "Minimum generated message length": "الحد الأدنى لطول الرسالة المولدة",
712712 "If the generated message is shorter than thisthese many characters, trigger an auto-swipe": "إذا كانت الرسالة المولدة أقصر من هذا، فتحريض السحب التلقائي",
713713 "Blacklisted words": "الكلمات الممنوعة",
714714 "words you dont want generated separated by comma ','": "الكلمات التي لا تريد توليدها مفصولة بفاصلة ','",
715715 "Blacklisted word count to swipe": "عدد الكلمات الممنوعة للسحب",
public/locales/de-de.json+1 -1
@@ -709,7 +709,7 @@
709709 "Auto-swipe": "Automatisches Wischen",
710710 "Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "Aktiviere die Auto-Wisch-Funktion. Einstellungen in diesem Abschnitt haben nur dann Auswirkungen, wenn das automatische Wischen aktiviert ist",
711711 "Minimum generated message length": "Minimale generierte Nachrichtenlänge",
712712 "If the generated message is shorter than thisthese many characters, trigger an auto-swipe": "Wenn die generierte Nachricht kürzer ist als diese, löse automatisches Wischen aus",
713713 "Blacklisted words": "Verbotene Wörter",
714714 "words you dont want generated separated by comma ','": "Wörter, die du nicht generiert haben möchtest, durch Komma ',' getrennt",
715715 "Blacklisted word count to swipe": "Anzahl der verbotenen Wörter, um zu wischen",
public/locales/es-es.json+1 -1
@@ -709,7 +709,7 @@
709709 "Auto-swipe": "Deslizamiento automático",
710710 "Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "Habilitar la función de deslizamiento automático. La configuración en esta sección solo tiene efecto cuando el deslizamiento automático está habilitado",
711711 "Minimum generated message length": "Longitud mínima del mensaje generado",
712712 "If the generated message is shorter than thisthese many characters, trigger an auto-swipe": "Si el mensaje generado es más corto que esto, activar un deslizamiento automático",
713713 "Blacklisted words": "Palabras prohibidas",
714714 "words you dont want generated separated by comma ','": "palabras que no desea generar separadas por coma ','",
715715 "Blacklisted word count to swipe": "Número de palabras prohibidas para deslizar",
public/locales/fr-fr.json+1 -1
@@ -656,7 +656,7 @@
656656 "Auto-swipe": "Balayage automatique",
657657 "Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "Activer la fonction de balayage automatique. Les paramètres de cette section n'ont d'effet que lorsque le balayage automatique est activé",
658658 "Minimum generated message length": "Longueur minimale du message généré",
659659 "If the generated message is shorter than thisthese many characters, trigger an auto-swipe": "Si le message généré est plus court que cela, déclenchez un balayage automatique",
660660 "Blacklisted words": "Mots en liste noire",
661661 "words you dont want generated separated by comma ','": "mots que vous ne voulez pas générer séparés par des virgules ','",
662662 "Blacklisted word count to swipe": "Nombre de mots en liste noire pour balayer",
public/locales/is-is.json+1 -1
@@ -709,7 +709,7 @@
709709 "Auto-swipe": "Sjálfvirkur sveip",
710710 "Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "Virkjaðu sjálfvirka sveiflugerð. Stillingar í þessum hluta hafa aðeins áhrif þegar sjálfvirkur sveiflugerð er virk",
711711 "Minimum generated message length": "Lágmarks lengd á mynduðum skilaboðum",
712712 "If the generated message is shorter than thisthese many characters, trigger an auto-swipe": "Ef mynduðu skilaboðin eru styttri en þessi, kallaðu fram sjálfvirkar sveiflugerðar",
713713 "Blacklisted words": "Svört orð",
714714 "words you dont want generated separated by comma ','": "orð sem þú vilt ekki að framleiða aðskilin með kommu ','",
715715 "Blacklisted word count to swipe": "Fjöldi svörtra orða til að sveipa",
public/locales/it-it.json+1 -1
@@ -709,7 +709,7 @@
709709 "Auto-swipe": "Auto-swipe",
710710 "Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "Abilita la funzione di auto-swipe. Le impostazioni in questa sezione hanno effetto solo quando l'auto-swipe è abilitato",
711711 "Minimum generated message length": "Lunghezza minima del messaggio generato",
712712 "If the generated message is shorter than thisthese many characters, trigger an auto-swipe": "Se il messaggio generato è più breve di questo, attiva un'automatica rimozione",
713713 "Blacklisted words": "Parole in blacklist",
714714 "words you dont want generated separated by comma ','": "parole che non vuoi generate separate da virgola ','",
715715 "Blacklisted word count to swipe": "Numero di parole in blacklist per attivare un'automatica rimozione",
public/locales/ja-jp.json+1 -1
@@ -709,7 +709,7 @@
709709 "Auto-swipe": "オートスワイプ",
710710 "Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "自動スワイプ機能を有効にします。このセクションの設定は、自動スワイプが有効になっている場合にのみ効果があります",
711711 "Minimum generated message length": "生成されたメッセージの最小長",
712712 "If the generated message is shorter than thisthese many characters, trigger an auto-swipe": "生成されたメッセージがこれよりも短い場合、自動スワイプをトリガーします",
713713 "Blacklisted words": "ブラックリストされた単語",
714714 "words you dont want generated separated by comma ','": "コンマ ',' で区切られた生成したくない単語",
715715 "Blacklisted word count to swipe": "スワイプするブラックリストされた単語の数",
public/locales/ko-kr.json+1 -1
@@ -724,7 +724,7 @@
724724 "Auto-swipe": "자동 스와이프",
725725 "Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "자동 스와이프 기능을 활성화합니다. 이 섹션의 설정은 자동 스와이프가 활성화되었을 때만 영향을 미칩니다",
726726 "Minimum generated message length": "생성된 메시지 최소 길이",
727727 "If the generated message is shorter than thisthese many characters, trigger an auto-swipe": "생성된 메시지가이보다 짧으면 자동 스와이프를 트리거합니다",
728728 "Blacklisted words": "금지어",
729729 "words you dont want generated separated by comma ','": "쉼표로 구분된 생성하지 않으려는 단어",
730730 "Blacklisted word count to swipe": "스와이프할 금지어 개수",
public/locales/nl-nl.json+1 -1
@@ -709,7 +709,7 @@
709709 "Auto-swipe": "Automatisch vegen",
710710 "Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "Schakel de automatische-vegen functie in. Instellingen in dit gedeelte hebben alleen effect wanneer automatisch vegen is ingeschakeld",
711711 "Minimum generated message length": "Minimale gegenereerde berichtlengte",
712712 "If the generated message is shorter than thisthese many characters, trigger an auto-swipe": "Als het gegenereerde bericht korter is dan dit, activeer dan een automatische veeg",
713713 "Blacklisted words": "Verboden woorden",
714714 "words you dont want generated separated by comma ','": "woorden die je niet gegenereerd wilt hebben gescheiden door komma ','",
715715 "Blacklisted word count to swipe": "Aantal verboden woorden om te vegen",
public/locales/pt-pt.json+1 -1
@@ -709,7 +709,7 @@
709709 "Auto-swipe": "Auto-swipe",
710710 "Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "Ativar a função de auto-swipe. As configurações nesta seção só têm efeito quando o auto-swipe está ativado",
711711 "Minimum generated message length": "Comprimento mínimo da mensagem gerada",
712712 "If the generated message is shorter than thisthese many characters, trigger an auto-swipe": "Se a mensagem gerada for mais curta que isso, acione um auto-swipe",
713713 "Blacklisted words": "Palavras proibidas",
714714 "words you dont want generated separated by comma ','": "palavras que você não quer geradas separadas por vírgula ','",
715715 "Blacklisted word count to swipe": "Contagem de palavras proibidas para swipe",
public/locales/ru-ru.json+1 -1
@@ -426,7 +426,7 @@
426426 "Requests logprobs from the API for the Token Probabilities feature": "Запросить логпробы из API для функции Token Probabilities.",
427427 "Automatically reject and re-generate AI message based on configurable criteria": "Автоматическое отклонение и повторная генерация сообщений AI на основе настраиваемых критериев.",
428428 "Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "Включить авто-свайп. Настройки в этом разделе действуют только при включенном авто-свайпе.",
429429 "If the generated message is shorter than thisthese many characters, trigger an auto-swipe": "Если сгенерированное сообщение короче этого значения, срабатывает авто-свайп.",
430430 "Reload and redraw the currently open chat": "Перезагрузить и перерисовать открытый в данный момент чат.",
431431 "Auto-Expand Message Actions": "Развернуть действия",
432432 "Persona Management": "Управление персоной",
public/locales/uk-ua.json+1 -1
@@ -709,7 +709,7 @@
709709 "Auto-swipe": "Автоматичний змах",
710710 "Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "Вмикає функцію автоматичного змаху. Налаштування в цьому розділі діють лише тоді, коли увімкнено автоматичний змах",
711711 "Minimum generated message length": "Мінімальна довжина згенерованого повідомлення",
712712 "If the generated message is shorter than thisthese many characters, trigger an auto-swipe": "Якщо згенероване повідомлення коротше за це, викликайте автоматичний змаху",
713713 "Blacklisted words": "Список заборонених слів",
714714 "words you dont want generated separated by comma ','": "слова, які ви не хочете генерувати, розділені комою ','",
715715 "Blacklisted word count to swipe": "Кількість заборонених слів для змаху",
public/locales/vi-vn.json+1 -1
@@ -709,7 +709,7 @@
709709 "Auto-swipe": "Tự động vuốt",
710710 "Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "Bật chức năng tự động vuốt. Các cài đặt trong phần này chỉ có tác dụng khi tự động vuốt được bật",
711711 "Minimum generated message length": "Độ dài tối thiểu của tin nhắn được tạo",
712712 "If the generated message is shorter than thisthese many characters, trigger an auto-swipe": "Nếu tin nhắn được tạo ra ngắn hơn điều này, kích hoạt tự động vuốt",
713713 "Blacklisted words": "Từ trong danh sách đen",
714714 "words you dont want generated separated by comma ','": "các từ bạn không muốn được tạo ra được phân tách bằng dấu phẩy ','",
715715 "Blacklisted word count to swipe": "Số từ trong danh sách đen để vuốt",
public/locales/zh-cn.json+1 -1
@@ -804,7 +804,7 @@
804804 "Auto-swipe": "自动滑动",
805805 "Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "启用自动滑动功能。仅当启用自动滑动时,本节中的设置才会生效",
806806 "Minimum generated message length": "生成的消息的最小长度",
807807 "If the generated message is shorter than thisthese many characters, trigger an auto-swipe": "如果生成的消息短于此长度,则触发自动滑动",
808808 "Blacklisted words": "屏蔽词",
809809 "words you dont want generated separated by comma ','": "不想生成的词语,用半角逗号“,”分隔",
810810 "Blacklisted word count to swipe": "触发滑动的黑名单词语数量",
public/locales/zh-tw.json+1 -1
@@ -710,7 +710,7 @@
710710 "Auto-swipe": "自動滑動",
711711 "Enable the auto-swipe function. Settings in this section only have an effect when auto-swipe is enabled": "啟用自動滑動功能。此部分的設定僅在啟用自動滑動時有效。",
712712 "Minimum generated message length": "生成訊息的最小長度",
713713 "If the generated message is shorter than thisthese many characters, trigger an auto-swipe": "如果生成的訊息比這個短,將觸發自動滑動。",
714714 "Blacklisted words": "黑名單詞語",
715715 "words you dont want generated separated by comma ','": "您不想生成的文字,使用逗號分隔",
716716 "Blacklisted word count to swipe": "滑動的黑名單詞語數量",
public/scripts/extensions/tts/openai-compatible.js+3 -3
@@ -25,7 +25,7 @@ class OpenAICompatibleTtsProvider {
2525 <label for="openai_compatible_tts_endpoint">Provider Endpoint:</label>
2626 <div class="flex-container alignItemsCenter">
2727 <div class="flex1">
2828 <input id="openai_compatible_tts_endpoint" type="text" class="text_pole" maxlength="250500" value="${this.defaultSettings.provider_endpoint}"/>
2929 </div>
3030 <div id="openai_compatible_tts_key" class="menu_button menu_button_icon">
3131 <i class="fa-solid fa-key"></i>
@@ -33,9 +33,9 @@ class OpenAICompatibleTtsProvider {
3333 </div>
3434 </div>
3535 <label for="openai_compatible_model">Model:</label>
3636 <input id="openai_compatible_model" type="text" class="text_pole" maxlength="250500" value="${this.defaultSettings.model}"/>
3737 <label for="openai_compatible_tts_voices">Available Voices (comma separated):</label>
3838 <input id="openai_compatible_tts_voices" type="text" class="text_pole" maxlength="250" value="${this.defaultSettings.available_voices.join()}"/>
3939 <label for="openai_compatible_tts_speed">Speed: <span id="openai_compatible_tts_speed_output"></span></label>
4040 <input type="range" id="openai_compatible_tts_speed" value="1" min="0.25" max="4" step="0.05">`;
4141 return html;
server.js+3 -2
@@ -57,7 +57,7 @@ import {
5757
5858import getWebpackServeMiddleware from './src/middleware/webpack-serve.js';
5959import basicAuthMiddleware from './src/middleware/basicAuth.js';
6060import whitelistMiddleware, { getAccessLogPath, migrateAccessLog } from './src/middleware/whitelist.js';
6161import multerMonkeyPatch from './src/middleware/multerMonkeyPatch.js';
6262import initRequestProxy from './src/request-proxy.js';
6363import getCacheBusterMiddleware from './src/middleware/cacheBuster.js';
@@ -754,6 +754,7 @@ const preSetupTasks = async function () {
754754 await checkForNewContent(directories);
755755 await ensureThumbnailCache();
756756 cleanUploads();
757+ migrateAccessLog();
757758
758759 await settingsInit();
759760 await statsInit();
@@ -856,7 +857,7 @@ const postSetupTasks = async function (v6Failed, v4Failed, useIPv6, useIPv4) {
856857 if (listen) {
857858 console.log();
858859 console.log('To limit connections to internal localhost only ([::1] or 127.0.0.1), change the setting in config.yaml to "listen: false".');
859860 console.log('Check the "access.log" file in the SillyTaverndata directory to inspect incoming connections.:', color.green(getAccessLogPath()));
860861 }
861862 console.log('\n' + getSeparator(plainGoToLog.length) + '\n');
862863 console.log(goToLog);
src/middleware/whitelist.js+21 -1
@@ -12,6 +12,8 @@ const enableForwardedWhitelist = getConfigValue('enableForwardedWhitelist', fals
1212let whitelist = getConfigValue('whitelist', []);
1313let knownIPs = new Set();
1414
15+export const getAccessLogPath = () => path.join(globalThis.DATA_ROOT, 'access.log');
16+
1517if (fs.existsSync(whitelistPath)) {
1618 try {
1719 let whitelistTxt = fs.readFileSync(whitelistPath, 'utf-8');
@@ -46,6 +48,23 @@ function getForwardedIp(req) {
4648 return undefined;
4749}
4850
51+export function migrateAccessLog() {
52+ try {
53+ if (!fs.existsSync('access.log')) {
54+ return;
55+ }
56+ const logPath = getAccessLogPath();
57+ if (fs.existsSync(logPath)) {
58+ return;
59+ }
60+ fs.renameSync('access.log', logPath);
61+ console.log(color.yellow('Migrated access.log to new location:'), logPath);
62+ } catch (e) {
63+ console.error('Failed to migrate access log:', e);
64+ console.info('Please move access.log to the data directory manually.');
65+ }
66+}
67+
4968/**
5069 * Returns a middleware function that checks if the client IP is in the whitelist.
5170 * @param {boolean} whitelistMode If whitelist mode is enabled via config or command line
@@ -67,9 +86,10 @@ export default function whitelistMiddleware(whitelistMode, listen) {
6786 knownIPs.add(clientIp);
6887
6988 // Write access log
89+ const logPath = getAccessLogPath();
7090 const timestamp = new Date().toISOString();
7191 const log = `${timestamp} ${clientIp} ${userAgent}\n`;
7292 fs.appendFile('access.log'logPath, log, (err) => {
7393 if (err) {
7494 console.error('Failed to write access log:', err);
7595 }