Add WI prefix to timed effect logs

c6e612f15a9e53a1c760d5f903f610d5b919933d

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +15 -15Showing whitespace changes
public/scripts/world-info.js+15 -15
@@ -223,12 +223,12 @@ class WorldInfoBuffer {
223223 }
224224
225225 if (depth < 0) {
226226 console.error(`[WI] Invalid WI scan depth ${depth}. Must be >= 0`);
227227 return '';
228228 }
229229
230230 if (depth > MAX_SCAN_DEPTH) {
231231 console.warn(`[WI] Invalid WI scan depth ${depth}. Truncating to ${MAX_SCAN_DEPTH}`);
232232 depth = MAX_SCAN_DEPTH;
233233 }
234234
@@ -445,7 +445,7 @@ class WorldInfoTimedEffects {
445445 const key = this.#getEntryKey(entry);
446446 const effect = this.#getEntryTimedEffect('cooldown', entry, true);
447447 chat_metadata.timedWorldInfo.cooldown[key] = effect;
448448 console.log(`[WI] Adding cooldown entry ${key} on ended sticky: start=${effect.start}, end=${effect.end}, protected=${effect.protected}`);
449449 // Set the cooldown immediately for this evaluation
450450 this.#buffer.cooldown.push(entry);
451451 },
@@ -456,7 +456,7 @@ class WorldInfoTimedEffects {
456456 * @param {WIScanEntry} entry Entry that ended cooldown
457457 */
458458 'cooldown': (entry) => {
459459 console.debug('[WI] Cooldown ended for entry', entry.uid);
460460 },
461461
462462 'delay': () => { },
@@ -546,11 +546,11 @@ class WorldInfoTimedEffects {
546546 /** @type {[string, WITimedEffect][]} */
547547 const effects = Object.entries(chat_metadata.timedWorldInfo[type]);
548548 for (const [key, value] of effects) {
549549 console.log(`[WI] Processing ${type} entry ${key}`, value);
550550 const entry = this.#entries.find(x => String(this.#getEntryHash(x)) === String(value.hash));
551551
552552 if (this.#chat.length <= Number(value.start) && !value.protected) {
553553 console.log(`[WI] Removing ${type} entry ${key} from timedWorldInfo: chat not advanced`, value);
554554 delete chat_metadata.timedWorldInfo[type][key];
555555 continue;
556556 }
@@ -558,7 +558,7 @@ class WorldInfoTimedEffects {
558558 // Missing entries (they could be from another character's lorebook)
559559 if (!entry) {
560560 if (this.#chat.length >= Number(value.end)) {
561561 console.log(`[WI] Removing ${type} entry from timedWorldInfo: entry not found and interval passed`, entry);
562562 delete chat_metadata.timedWorldInfo[type][key];
563563 }
564564 continue;
@@ -566,13 +566,13 @@ class WorldInfoTimedEffects {
566566
567567 // Ignore invalid entries (not configured for timed effects)
568568 if (!entry[type]) {
569569 console.log(`[WI] Removing ${type} entry from timedWorldInfo: entry not ${type}`, entry);
570570 delete chat_metadata.timedWorldInfo[type][key];
571571 continue;
572572 }
573573
574574 if (this.#chat.length >= Number(value.end)) {
575575 console.log(`[WI] Removing ${type} entry from timedWorldInfo: ${type} interval passed`, entry);
576576 delete chat_metadata.timedWorldInfo[type][key];
577577 if (typeof onEnded === 'function') {
578578 onEnded(entry);
@@ -581,7 +581,7 @@ class WorldInfoTimedEffects {
581581 }
582582
583583 buffer.push(entry);
584584 console.log(`[WI] Timed effect "${type}" applied to entry`, entry);
585585 }
586586 }
587587
@@ -597,7 +597,7 @@ class WorldInfoTimedEffects {
597597
598598 if (this.#chat.length < entry.delay) {
599599 buffer.push(entry);
600600 console.log('[WI] Timed effect "delay" applied to entry', entry);
601601 }
602602 }
603603
@@ -644,7 +644,7 @@ class WorldInfoTimedEffects {
644644 const effect = this.#getEntryTimedEffect(type, entry, false);
645645 chat_metadata.timedWorldInfo[type][key] = effect;
646646
647647 console.log(`[WI] Adding ${type} entry ${key}: start=${effect.start}, end=${effect.end}, protected=${effect.protected}`);
648648 }
649649 }
650650
@@ -676,7 +676,7 @@ class WorldInfoTimedEffects {
676676 if (newState) {
677677 const effect = this.#getEntryTimedEffect(type, entry, false);
678678 chat_metadata.timedWorldInfo[type][key] = effect;
679679 console.log(`[WI] Adding ${type} entry ${key}: start=${effect.start}, end=${effect.end}, protected=${effect.protected}`);
680680 }
681681 }
682682
@@ -3847,7 +3847,7 @@ async function checkWorldInfo(chat, maxContext, isDryRun) {
38473847 }
38483848
38493849 allActivatedEntries.add(entry);
38503850 console.debug(`[WI] entryEntry ${entry.uid} activation successful, adding to prompt`, entry);
38513851 }
38523852
38533853 const successfulNewEntries = newEntries.filter(x => !failedProbabilityChecks.has(x));
@@ -3858,7 +3858,7 @@ async function checkWorldInfo(chat, maxContext, isDryRun) {
38583858 } else if (!successfulNewEntries.length) {
38593859 console.debug('[WI] Probability checks failed for all activated entries, stopping');
38603860 } else {
38613861 console.debug(`[WI] SucessfullySuccessfully activated ${successfulNewEntries.length} new entries to prompt. ${allActivatedEntries.size} total entries activated.`, successfulNewEntries);
38623862 }
38633863
38643864 // After processing and rolling entries is done, see if we should continue with normal recursion