feat: message interception

This commit is contained in:
Subarashimo
2025-12-05 11:40:50 +01:00
parent 271c69ec49
commit 806a7078a7
12 changed files with 374 additions and 69 deletions
+36
View File
@@ -289,6 +289,20 @@
<small data-i18n-key="template.settingsModal.advanced.contextMessagesNote">Number of recent messages to include (Separate mode only)</small>
</div>
<label class="checkbox_label">
<input type="checkbox" id="rpg-toggle-message-interception" />
<span data-i18n-key="template.settingsModal.advanced.enableMessageInterception">Intercept & rewrite user messages with AI</span>
</label>
<small style="display: block; margin-left: 24px; margin-top: -8px; color: #888; font-size: 11px;" data-i18n-key="template.settingsModal.advanced.enableMessageInterceptionNote">
When enabled, user messages are sent to the AI along with current RPG state and recent chat, then rewritten in-place.
</small>
<div class="rpg-setting-row">
<label for="rpg-message-interception-depth" data-i18n-key="template.settingsModal.advanced.messageInterceptionDepth">Interception Context Messages:</label>
<input type="number" id="rpg-message-interception-depth" min="1" max="20" value="4" class="rpg-input" />
<small data-i18n-key="template.settingsModal.advanced.messageInterceptionDepthNote">How many recent messages to send with the interception prompt.</small>
</div>
<div class="rpg-setting-row">
<label for="rpg-memory-messages" data-i18n-key="template.settingsModal.advanced.memoryBatchSize">Memory Batch Size:</label>
<input type="number" id="rpg-memory-messages" min="4" max="50" value="16" class="rpg-input" />
@@ -359,6 +373,28 @@
</small>
</div>
<!-- Custom Message Interception Prompt Editor -->
<div class="rpg-setting-row" style="margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--rpg-border);">
<label for="rpg-custom-message-interception-prompt" style="display: block; margin-bottom: 8px; font-weight: 600;" data-i18n-key="template.settingsModal.advanced.customMessageInterceptionPromptTitle">
<i class="fa-solid fa-pen-to-square" aria-hidden="true"></i> Custom Message Interception Prompt:
</label>
<textarea id="rpg-custom-message-interception-prompt"
style="width: 100%; min-height: 120px; padding: 10px; border-radius: 4px;
border: 1px solid var(--SmartThemeBorderColor); background: var(--SmartThemeBlurTintColor);
color: var(--SmartThemeBodyColor); font-family: 'Courier New', monospace; font-size: 12px;
resize: vertical; line-height: 1.5;"
placeholder=""></textarea>
<div style="margin-top: 8px; display: flex; gap: 8px;">
<button id="rpg-restore-default-message-interception-prompt" class="menu_button" style="flex: 1;">
<i class="fa-solid fa-rotate-left" aria-hidden="true"></i> <span data-i18n-key="template.settingsModal.advanced.restoreDefaultMessageInterceptionPrompt">Restore Default</span>
</button>
</div>
<small style="display: block; margin-top: 8px; color: #888; font-size: 11px;" data-i18n-key="template.settingsModal.advanced.customMessageInterceptionPromptNote">
Customize the instructions sent to the AI when rewriting user messages. Leave empty to use the default guidance. The AI receives this prompt, the current RPG state JSON, and the recent messages you specify above.
</small>
</div>
<!-- Clear Cache Button -->
<div style="margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--rpg-border);">
<button id="rpg-clear-cache" class="rpg-btn-clear-cache">