* update: improve fetching of selected default expression It includes the fallback values #emoji and #none. * update: allow expression-list to filter custom expressions It can allow, filter out, or only include custom expressions in the result. * update: separate getLastExpression from the slash command to use on macros * feat: register defaultExpression macro It will fetch the label of the currently selected global fallback expression. * feat: register lastExpression macro It will return the last expression used by the selected character. * feat: register availableExpressions macro Returns a list of all expressions provided by the Classifier API. * update: fix macros labels * update: normalize return label for defaultExpression macro * Fix - Typos * Update - Add compatibility with old macro engine * Fix - Remove redundant structuredClone * Update - Consider sprite folders to fetch the last expression used * Update - Improve last message handling when name is provided * Fix - Update description of getLastCharacterMessage * Update - Bring back using active character as fallback for groups Just weighted that if no name is provided, doing fallback to the active character generating prompt is more useful for groups than grabbing the expression used by another character, after randomly removing that prev commit.
86 lines
3.3 KiB
JavaScript
86 lines
3.3 KiB
JavaScript
/**
|
|
* Central entry point for the new macro system.
|
|
*
|
|
* Exposes the MacroEngine / MacroRegistry singletons and provides a
|
|
* single registerMacros() function that wires up all built-in macro
|
|
* definition sets (core, env, state, chat, time, variables, instruct).
|
|
*/
|
|
|
|
// Engine singletons and enums
|
|
import { MacroEngine } from './engine/MacroEngine.js';
|
|
import { MacroRegistry, MacroCategory, MacroValueType } from './engine/MacroRegistry.js';
|
|
import { MacroLexer } from './engine/MacroLexer.js';
|
|
import { MacroParser } from './engine/MacroParser.js';
|
|
import { MacroCstWalker } from './engine/MacroCstWalker.js';
|
|
import { MacroEnvBuilder } from './engine/MacroEnvBuilder.js';
|
|
|
|
// Macro definition groups
|
|
import { registerCoreMacros } from './definitions/core-macros.js';
|
|
import { registerEnvMacros } from './definitions/env-macros.js';
|
|
import { registerStateMacros } from './definitions/state-macros.js';
|
|
import { registerChatMacros } from './definitions/chat-macros.js';
|
|
import { registerTimeMacros } from './definitions/time-macros.js';
|
|
import { registerVariableMacros } from './definitions/variable-macros.js';
|
|
import { registerInstructMacros } from './definitions/instruct-macros.js';
|
|
|
|
// Re-export the category enum for external use
|
|
export { MacroCategory, MacroValueType };
|
|
|
|
// Re-export most-used jsdoc definitions
|
|
/** @typedef {import('./engine/MacroRegistry.js').MacroDefinitionOptions} MacroDefinitionOptions */
|
|
/** @typedef {import('./engine/MacroRegistry.js').MacroDefinition} MacroDefinition */
|
|
/** @typedef {import('./engine/MacroRegistry.js').MacroUnnamedArgDef} MacroUnnamedArgDef */
|
|
/** @typedef {import('./engine/MacroRegistry.js').MacroListSpec} MacroListSpec */
|
|
/** @typedef {import('./engine/MacroRegistry.js').MacroHandler} MacroHandler */
|
|
/** @typedef {import('./engine/MacroRegistry.js').MacroExecutionContext} MacroExecutionContext */
|
|
|
|
/** @typedef {import('chevrotain').CstNode} CstNode */
|
|
/** @typedef {import('./engine/MacroEnv.types.js').MacroEnv} MacroEnv */
|
|
/** @typedef {import('./engine/MacroEnv.types.js').MacroEnvNames} MacroEnvNames */
|
|
/** @typedef {import('./engine/MacroEnv.types.js').MacroEnvCharacter} MacroEnvCharacter */
|
|
/** @typedef {import('./engine/MacroEnv.types.js').MacroEnvSystem} MacroEnvSystem */
|
|
/** @typedef {import('./engine/MacroEnv.types.js').MacroEnvFunctions} MacroEnvFunctions */
|
|
|
|
export const macros = {
|
|
// engine singletons
|
|
engine: MacroEngine,
|
|
registry: MacroRegistry,
|
|
envBuilder: MacroEnvBuilder,
|
|
lexer: MacroLexer,
|
|
parser: MacroParser,
|
|
cstWalker: MacroCstWalker,
|
|
|
|
// enums
|
|
category: MacroCategory,
|
|
valueType: MacroValueType,
|
|
|
|
// shorthand functions
|
|
register: MacroRegistry.registerMacro.bind(MacroRegistry),
|
|
registerAlias: MacroRegistry.registerMacroAlias.bind(MacroRegistry),
|
|
};
|
|
|
|
/**
|
|
* Registers all built-in macros in a well-defined order.
|
|
* Intended to be called once during app initialization.
|
|
*/
|
|
export function initRegisterMacros() {
|
|
// Core utilities and generic helpers
|
|
registerCoreMacros();
|
|
|
|
// Env / character / system / extras
|
|
registerEnvMacros();
|
|
|
|
// Runtime state tracking (eventSource etc.)
|
|
registerStateMacros();
|
|
|
|
// Chat/history inspection macros
|
|
registerChatMacros();
|
|
|
|
// Time / date / durations
|
|
registerTimeMacros();
|
|
|
|
// Variable and instruct macros
|
|
registerVariableMacros();
|
|
registerInstructMacros();
|
|
}
|