mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-05-15 22:30:38 +08:00
phase2-4 recall prompt-flow hardening
This commit is contained in:
@@ -1,11 +1,27 @@
|
||||
import { register, registerHooks } from "node:module";
|
||||
|
||||
const DEFAULT_REGEX_ENGINE_HOOK_ENTRIES = Object.freeze([
|
||||
{
|
||||
specifiers: ["../../../../regex/engine.js"],
|
||||
url: toDataModuleUrl([
|
||||
"export const regex_placement = { USER_INPUT: 1, AI_OUTPUT: 2, SLASH_COMMAND: 3, WORLD_INFO: 5, REASONING: 6 };",
|
||||
"export function getRegexedString(...args) {",
|
||||
" const fn = globalThis.__taskRegexTestCoreGetRegexedString;",
|
||||
" return typeof fn === 'function' ? fn(...args) : String(args?.[0] ?? '');",
|
||||
"}",
|
||||
].join("\n")),
|
||||
},
|
||||
]);
|
||||
|
||||
export function toDataModuleUrl(source = "") {
|
||||
return `data:text/javascript,${encodeURIComponent(String(source || ""))}`;
|
||||
}
|
||||
|
||||
export function installResolveHooks(entries = []) {
|
||||
const normalizedEntries = (Array.isArray(entries) ? entries : [])
|
||||
const normalizedEntries = [
|
||||
...(Array.isArray(entries) ? entries : []),
|
||||
...DEFAULT_REGEX_ENGINE_HOOK_ENTRIES,
|
||||
]
|
||||
.map((entry) => ({
|
||||
specifiers: Array.isArray(entry?.specifiers)
|
||||
? entry.specifiers.map((value) => String(value || "")).filter(Boolean)
|
||||
|
||||
Reference in New Issue
Block a user