Align custom world info rendering with ST runtime

This commit is contained in:
Hao19911125
2026-04-07 15:15:33 +08:00
parent a2bde74583
commit f21f2c4c1d
8 changed files with 431 additions and 1115 deletions

View File

@@ -940,6 +940,7 @@ export async function evalTaskEjsTemplate(content, renderCtx, extraEnv = {}) {
_: utilityLib,
console,
...templateRuntimeEnv,
stat_data: renderCtx.variableState?.cacheVars?.stat_data,
user: templateAliases.user,
char: templateAliases.char,
persona:
@@ -963,6 +964,9 @@ export async function evalTaskEjsTemplate(content, renderCtx, extraEnv = {}) {
get variables() {
return renderCtx.variableState.cacheVars;
},
get stat_data() {
return renderCtx.variableState?.cacheVars?.stat_data;
},
get lastUserMessageId() {
if (typeof chat.findLastIndex === "function") {
return chat.findLastIndex((message) => message?.is_user);