mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-05-15 22:30:38 +08:00
Bypass trivial planner and empty-turn hooks
This commit is contained in:
@@ -1274,6 +1274,10 @@ async function runPlanningOnce(rawUserInput, silent = false, options = {}) {
|
|||||||
function getSendTextarea() { return document.getElementById('send_textarea'); }
|
function getSendTextarea() { return document.getElementById('send_textarea'); }
|
||||||
function getSendButton() { return document.getElementById('send_but') || document.getElementById('send_button'); }
|
function getSendButton() { return document.getElementById('send_but') || document.getElementById('send_button'); }
|
||||||
|
|
||||||
|
function isTrivialPlannerInput(text) {
|
||||||
|
return _bmeRuntime?.isTrivialUserInput?.(text)?.trivial === true;
|
||||||
|
}
|
||||||
|
|
||||||
function shouldInterceptNow() {
|
function shouldInterceptNow() {
|
||||||
const s = ensureSettings();
|
const s = ensureSettings();
|
||||||
if (!s.enabled || state.isPlanning) return false;
|
if (!s.enabled || state.isPlanning) return false;
|
||||||
@@ -1281,6 +1285,7 @@ function shouldInterceptNow() {
|
|||||||
if (!ta) return false;
|
if (!ta) return false;
|
||||||
const txt = String(ta.value ?? '').trim();
|
const txt = String(ta.value ?? '').trim();
|
||||||
if (!txt) return false;
|
if (!txt) return false;
|
||||||
|
if (isTrivialPlannerInput(txt)) return false;
|
||||||
if (state.bypassNextSend) return false;
|
if (state.bypassNextSend) return false;
|
||||||
if (s.skipIfPlotPresent && /<plot\b/i.test(txt)) return false;
|
if (s.skipIfPlotPresent && /<plot\b/i.test(txt)) return false;
|
||||||
return true;
|
return true;
|
||||||
@@ -1293,6 +1298,7 @@ async function doInterceptAndPlanThenSend() {
|
|||||||
|
|
||||||
const raw = String(ta.value ?? '').trim();
|
const raw = String(ta.value ?? '').trim();
|
||||||
if (!raw) return;
|
if (!raw) return;
|
||||||
|
if (isTrivialPlannerInput(raw)) return;
|
||||||
|
|
||||||
state.isPlanning = true;
|
state.isPlanning = true;
|
||||||
setSendUIBusy(true);
|
setSendUIBusy(true);
|
||||||
|
|||||||
@@ -315,8 +315,6 @@ export function onGenerationStartedController(
|
|||||||
: "";
|
: "";
|
||||||
const snapshotText =
|
const snapshotText =
|
||||||
runtime.normalizeRecallInputText?.(pendingIntentText || textareaText) || "";
|
runtime.normalizeRecallInputText?.(pendingIntentText || textareaText) || "";
|
||||||
|
|
||||||
if (!snapshotText) return null;
|
|
||||||
const trivialInputResult = runtime.isTrivialUserInput?.(snapshotText);
|
const trivialInputResult = runtime.isTrivialUserInput?.(snapshotText);
|
||||||
if (trivialInputResult?.trivial) {
|
if (trivialInputResult?.trivial) {
|
||||||
const context = runtime.getContext?.() || {};
|
const context = runtime.getContext?.() || {};
|
||||||
|
|||||||
20
index.js
20
index.js
@@ -6662,22 +6662,17 @@ function buildNormalGenerationRecallInput(chat, options = {}) {
|
|||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
].filter(Boolean);
|
].filter(Boolean);
|
||||||
|
const activeTrivialSkip = getCurrentGenerationTrivialSkip();
|
||||||
|
if (activeTrivialSkip) {
|
||||||
|
clearPendingRecallSendIntent();
|
||||||
|
clearPendingHostGenerationInputSnapshot();
|
||||||
|
return createTrivialRecallSkipSentinel(activeTrivialSkip.reason);
|
||||||
|
}
|
||||||
|
|
||||||
const selectedCandidate = sourceCandidates[0] || null;
|
const selectedCandidate = sourceCandidates[0] || null;
|
||||||
if (!selectedCandidate?.text) return null;
|
if (!selectedCandidate?.text) return null;
|
||||||
|
|
||||||
const trivialInputResult = isTrivialUserInput(selectedCandidate.text);
|
const trivialInputResult = isTrivialUserInput(selectedCandidate.text);
|
||||||
const activeTrivialSkip = getCurrentGenerationTrivialSkip();
|
|
||||||
if (activeTrivialSkip) {
|
|
||||||
if (!trivialInputResult.trivial) {
|
|
||||||
clearCurrentGenerationTrivialSkip("stale-trivial-skip-replaced");
|
|
||||||
} else {
|
|
||||||
clearPendingRecallSendIntent();
|
|
||||||
clearPendingHostGenerationInputSnapshot();
|
|
||||||
return createTrivialRecallSkipSentinel(
|
|
||||||
activeTrivialSkip.reason || trivialInputResult.reason,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (trivialInputResult.trivial) {
|
if (trivialInputResult.trivial) {
|
||||||
clearPendingRecallSendIntent();
|
clearPendingRecallSendIntent();
|
||||||
@@ -9837,6 +9832,7 @@ async function onReembedDirect() {
|
|||||||
await initEnaPlanner({
|
await initEnaPlanner({
|
||||||
getContext,
|
getContext,
|
||||||
getExtensionPath: () => `scripts/extensions/third-party/${MODULE_NAME}`,
|
getExtensionPath: () => `scripts/extensions/third-party/${MODULE_NAME}`,
|
||||||
|
isTrivialUserInput,
|
||||||
preparePlannerRecallHandoff,
|
preparePlannerRecallHandoff,
|
||||||
runPlannerRecallForEna,
|
runPlannerRecallForEna,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -89,6 +89,28 @@ async function testUnderMinTokensSkipsRecallAndExtraction() {
|
|||||||
assert.equal(harness.result.getCurrentGenerationTrivialSkip(), null);
|
assert.equal(harness.result.getCurrentGenerationTrivialSkip(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function testEmptyInputSkipsPriorHistoryFallback() {
|
||||||
|
const harness = await createGenerationRecallHarness();
|
||||||
|
harness.chat = [{ is_user: true, mes: "older real user message" }];
|
||||||
|
harness.__sendTextareaValue = " ";
|
||||||
|
|
||||||
|
const startResult = harness.result.onGenerationStarted("normal", {}, false);
|
||||||
|
assert.equal(startResult, null);
|
||||||
|
assert.equal(
|
||||||
|
harness.result.getCurrentGenerationTrivialSkip()?.reason,
|
||||||
|
"empty",
|
||||||
|
);
|
||||||
|
|
||||||
|
await harness.result.onGenerationAfterCommands("normal", {}, false);
|
||||||
|
assert.equal(harness.runRecallCalls.length, 0);
|
||||||
|
|
||||||
|
const beforeCombine = await harness.result.onBeforeCombinePrompts();
|
||||||
|
assert.deepEqual(beforeCombine, {
|
||||||
|
skipped: true,
|
||||||
|
reason: "trivial:empty",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function testNormalInputStillRecalls() {
|
async function testNormalInputStillRecalls() {
|
||||||
const harness = await createGenerationRecallHarness();
|
const harness = await createGenerationRecallHarness();
|
||||||
harness.chat = [];
|
harness.chat = [];
|
||||||
@@ -263,6 +285,7 @@ await Promise.resolve();
|
|||||||
testIsTrivialUserInputTable();
|
testIsTrivialUserInputTable();
|
||||||
await testSlashCommandSkipsRecallAndExtraction();
|
await testSlashCommandSkipsRecallAndExtraction();
|
||||||
await testUnderMinTokensSkipsRecallAndExtraction();
|
await testUnderMinTokensSkipsRecallAndExtraction();
|
||||||
|
await testEmptyInputSkipsPriorHistoryFallback();
|
||||||
await testNormalInputStillRecalls();
|
await testNormalInputStillRecalls();
|
||||||
await testSentinelBlocksHistoryFallback();
|
await testSentinelBlocksHistoryFallback();
|
||||||
await testAfterCommandsTrivialSentinelMarksExtractionBypass();
|
await testAfterCommandsTrivialSentinelMarksExtractionBypass();
|
||||||
|
|||||||
Reference in New Issue
Block a user