Fix hidden-message leakage into plugin prompts

This commit is contained in:
Youzini-afk
2026-04-10 14:06:17 +08:00
parent ed0df6eb7e
commit ef154b5950
7 changed files with 121 additions and 4 deletions

View File

@@ -2,6 +2,7 @@
// 为 prompt 变量扩展Phase 2提供统一的 ST 上下文数据接口
import { getContext } from "../../../../extensions.js";
import { buildPluginVisibleChatMessages } from "../maintenance/chat-history.js";
function safeClone(value, fallback) {
if (value == null) {
@@ -62,7 +63,9 @@ function resolveLastUserMessage(chat = []) {
function buildStructuredSnapshot(ctx = {}) {
const char = resolveCharacter(ctx);
const chat = Array.isArray(ctx.chat) ? safeClone(ctx.chat, []) : [];
const chat = Array.isArray(ctx.chat)
? buildPluginVisibleChatMessages(ctx.chat)
: [];
const currentTime = new Date().toLocaleString("zh-CN");
const globalVars = safeClone(
ctx.extensionSettings?.variables?.global || {},