Add WI prefix to timed effect logs
| @@ -223,12 +223,12 @@ class WorldInfoBuffer { | |||
| 223 | } | 223 | } |
| 224 | 224 | ||
| 225 | if (depth < 0) { | 225 | if (depth < 0) { |
| 226 | console.error(`Invalid WI scan depth ${depth}. Must be >= 0`); | 226 | console.error(`[WI] Invalid WI scan depth ${depth}. Must be >= 0`); |
| 227 | return ''; | 227 | return ''; |
| 228 | } | 228 | } |
| 229 | 229 | ||
| 230 | if (depth > MAX_SCAN_DEPTH) { | 230 | if (depth > MAX_SCAN_DEPTH) { |
| 231 | console.warn(`Invalid WI scan depth ${depth}. Truncating to ${MAX_SCAN_DEPTH}`); | 231 | console.warn(`[WI] Invalid WI scan depth ${depth}. Truncating to ${MAX_SCAN_DEPTH}`); |
| 232 | depth = MAX_SCAN_DEPTH; | 232 | depth = MAX_SCAN_DEPTH; |
| 233 | } | 233 | } |
| 234 | 234 | ||
| @@ -445,7 +445,7 @@ class WorldInfoTimedEffects { | |||
| 445 | const key = this.#getEntryKey(entry); | 445 | const key = this.#getEntryKey(entry); |
| 446 | const effect = this.#getEntryTimedEffect('cooldown', entry, true); | 446 | const effect = this.#getEntryTimedEffect('cooldown', entry, true); |
| 447 | chat_metadata.timedWorldInfo.cooldown[key] = effect; | 447 | chat_metadata.timedWorldInfo.cooldown[key] = effect; |
| 448 | console.log(`Adding cooldown entry ${key} on ended sticky: start=${effect.start}, end=${effect.end}, protected=${effect.protected}`); | 448 | console.log(`[WI] Adding cooldown entry ${key} on ended sticky: start=${effect.start}, end=${effect.end}, protected=${effect.protected}`); |
| 449 | // Set the cooldown immediately for this evaluation | 449 | // Set the cooldown immediately for this evaluation |
| 450 | this.#buffer.cooldown.push(entry); | 450 | this.#buffer.cooldown.push(entry); |
| 451 | }, | 451 | }, |
| @@ -456,7 +456,7 @@ class WorldInfoTimedEffects { | |||
| 456 | * @param {WIScanEntry} entry Entry that ended cooldown | 456 | * @param {WIScanEntry} entry Entry that ended cooldown |
| 457 | */ | 457 | */ |
| 458 | 'cooldown': (entry) => { | 458 | 'cooldown': (entry) => { |
| 459 | console.debug('Cooldown ended for entry', entry.uid); | 459 | console.debug('[WI] Cooldown ended for entry', entry.uid); |
| 460 | }, | 460 | }, |
| 461 | 461 | ||
| 462 | 'delay': () => { }, | 462 | 'delay': () => { }, |
| @@ -546,11 +546,11 @@ class WorldInfoTimedEffects { | |||
| 546 | /** @type {[string, WITimedEffect][]} */ | 546 | /** @type {[string, WITimedEffect][]} */ |
| 547 | const effects = Object.entries(chat_metadata.timedWorldInfo[type]); | 547 | const effects = Object.entries(chat_metadata.timedWorldInfo[type]); |
| 548 | for (const [key, value] of effects) { | 548 | for (const [key, value] of effects) { |
| 549 | console.log(`Processing ${type} entry ${key}`, value); | 549 | console.log(`[WI] Processing ${type} entry ${key}`, value); |
| 550 | const entry = this.#entries.find(x => String(this.#getEntryHash(x)) === String(value.hash)); | 550 | const entry = this.#entries.find(x => String(this.#getEntryHash(x)) === String(value.hash)); |
| 551 | 551 | ||
| 552 | if (this.#chat.length <= Number(value.start) && !value.protected) { | 552 | if (this.#chat.length <= Number(value.start) && !value.protected) { |
| 553 | console.log(`Removing ${type} entry ${key} from timedWorldInfo: chat not advanced`, value); | 553 | console.log(`[WI] Removing ${type} entry ${key} from timedWorldInfo: chat not advanced`, value); |
| 554 | delete chat_metadata.timedWorldInfo[type][key]; | 554 | delete chat_metadata.timedWorldInfo[type][key]; |
| 555 | continue; | 555 | continue; |
| 556 | } | 556 | } |
| @@ -558,7 +558,7 @@ class WorldInfoTimedEffects { | |||
| 558 | // Missing entries (they could be from another character's lorebook) | 558 | // Missing entries (they could be from another character's lorebook) |
| 559 | if (!entry) { | 559 | if (!entry) { |
| 560 | if (this.#chat.length >= Number(value.end)) { | 560 | if (this.#chat.length >= Number(value.end)) { |
| 561 | console.log(`Removing ${type} entry from timedWorldInfo: entry not found and interval passed`, entry); | 561 | console.log(`[WI] Removing ${type} entry from timedWorldInfo: entry not found and interval passed`, entry); |
| 562 | delete chat_metadata.timedWorldInfo[type][key]; | 562 | delete chat_metadata.timedWorldInfo[type][key]; |
| 563 | } | 563 | } |
| 564 | continue; | 564 | continue; |
| @@ -566,13 +566,13 @@ class WorldInfoTimedEffects { | |||
| 566 | 566 | ||
| 567 | // Ignore invalid entries (not configured for timed effects) | 567 | // Ignore invalid entries (not configured for timed effects) |
| 568 | if (!entry[type]) { | 568 | if (!entry[type]) { |
| 569 | console.log(`Removing ${type} entry from timedWorldInfo: entry not ${type}`, entry); | 569 | console.log(`[WI] Removing ${type} entry from timedWorldInfo: entry not ${type}`, entry); |
| 570 | delete chat_metadata.timedWorldInfo[type][key]; | 570 | delete chat_metadata.timedWorldInfo[type][key]; |
| 571 | continue; | 571 | continue; |
| 572 | } | 572 | } |
| 573 | 573 | ||
| 574 | if (this.#chat.length >= Number(value.end)) { | 574 | if (this.#chat.length >= Number(value.end)) { |
| 575 | console.log(`Removing ${type} entry from timedWorldInfo: ${type} interval passed`, entry); | 575 | console.log(`[WI] Removing ${type} entry from timedWorldInfo: ${type} interval passed`, entry); |
| 576 | delete chat_metadata.timedWorldInfo[type][key]; | 576 | delete chat_metadata.timedWorldInfo[type][key]; |
| 577 | if (typeof onEnded === 'function') { | 577 | if (typeof onEnded === 'function') { |
| 578 | onEnded(entry); | 578 | onEnded(entry); |
| @@ -581,7 +581,7 @@ class WorldInfoTimedEffects { | |||
| 581 | } | 581 | } |
| 582 | 582 | ||
| 583 | buffer.push(entry); | 583 | buffer.push(entry); |
| 584 | console.log(`Timed effect "${type}" applied to entry`, entry); | 584 | console.log(`[WI] Timed effect "${type}" applied to entry`, entry); |
| 585 | } | 585 | } |
| 586 | } | 586 | } |
| 587 | 587 | ||
| @@ -597,7 +597,7 @@ class WorldInfoTimedEffects { | |||
| 597 | 597 | ||
| 598 | if (this.#chat.length < entry.delay) { | 598 | if (this.#chat.length < entry.delay) { |
| 599 | buffer.push(entry); | 599 | buffer.push(entry); |
| 600 | console.log('Timed effect "delay" applied to entry', entry); | 600 | console.log('[WI] Timed effect "delay" applied to entry', entry); |
| 601 | } | 601 | } |
| 602 | } | 602 | } |
| 603 | 603 | ||
| @@ -644,7 +644,7 @@ class WorldInfoTimedEffects { | |||
| 644 | const effect = this.#getEntryTimedEffect(type, entry, false); | 644 | const effect = this.#getEntryTimedEffect(type, entry, false); |
| 645 | chat_metadata.timedWorldInfo[type][key] = effect; | 645 | chat_metadata.timedWorldInfo[type][key] = effect; |
| 646 | 646 | ||
| 647 | console.log(`Adding ${type} entry ${key}: start=${effect.start}, end=${effect.end}, protected=${effect.protected}`); | 647 | console.log(`[WI] Adding ${type} entry ${key}: start=${effect.start}, end=${effect.end}, protected=${effect.protected}`); |
| 648 | } | 648 | } |
| 649 | } | 649 | } |
| 650 | 650 | ||
| @@ -676,7 +676,7 @@ class WorldInfoTimedEffects { | |||
| 676 | if (newState) { | 676 | if (newState) { |
| 677 | const effect = this.#getEntryTimedEffect(type, entry, false); | 677 | const effect = this.#getEntryTimedEffect(type, entry, false); |
| 678 | chat_metadata.timedWorldInfo[type][key] = effect; | 678 | chat_metadata.timedWorldInfo[type][key] = effect; |
| 679 | console.log(`Adding ${type} entry ${key}: start=${effect.start}, end=${effect.end}, protected=${effect.protected}`); | 679 | console.log(`[WI] Adding ${type} entry ${key}: start=${effect.start}, end=${effect.end}, protected=${effect.protected}`); |
| 680 | } | 680 | } |
| 681 | } | 681 | } |
| 682 | 682 | ||
| @@ -3847,7 +3847,7 @@ async function checkWorldInfo(chat, maxContext, isDryRun) { | |||
| 3847 | } | 3847 | } |
| 3848 | 3848 | ||
| 3849 | allActivatedEntries.add(entry); | 3849 | allActivatedEntries.add(entry); |
| 3850 | console.debug(`WI entry ${entry.uid} activation successful, adding to prompt`, entry); | 3850 | console.debug(`[WI] Entry ${entry.uid} activation successful, adding to prompt`, entry); |
| 3851 | } | 3851 | } |
| 3852 | 3852 | ||
| 3853 | const successfulNewEntries = newEntries.filter(x => !failedProbabilityChecks.has(x)); | 3853 | const successfulNewEntries = newEntries.filter(x => !failedProbabilityChecks.has(x)); |
| @@ -3858,7 +3858,7 @@ async function checkWorldInfo(chat, maxContext, isDryRun) { | |||
| 3858 | } else if (!successfulNewEntries.length) { | 3858 | } else if (!successfulNewEntries.length) { |
| 3859 | console.debug('[WI] Probability checks failed for all activated entries, stopping'); | 3859 | console.debug('[WI] Probability checks failed for all activated entries, stopping'); |
| 3860 | } else { | 3860 | } else { |
| 3861 | console.debug(`[WI] Sucessfully activated ${successfulNewEntries.length} new entries to prompt. ${allActivatedEntries.size} total entries activated.`, successfulNewEntries); | 3861 | console.debug(`[WI] Successfully activated ${successfulNewEntries.length} new entries to prompt. ${allActivatedEntries.size} total entries activated.`, successfulNewEntries); |
| 3862 | } | 3862 | } |
| 3863 | 3863 | ||
| 3864 | // After processing and rolling entries is done, see if we should continue with normal recursion | 3864 | // After processing and rolling entries is done, see if we should continue with normal recursion |