Refactor main slassh-commands into init func
| @@ -159,7 +159,7 @@ import { | |||
| 159 | import { debounce_timeout } from './scripts/constants.js'; | 159 | import { debounce_timeout } from './scripts/constants.js'; |
| 160 | 160 | ||
| 161 | import { ModuleWorkerWrapper, doDailyExtensionUpdatesCheck, extension_settings, getContext, loadExtensionSettings, renderExtensionTemplate, renderExtensionTemplateAsync, runGenerationInterceptors, saveMetadataDebounced, writeExtensionField } from './scripts/extensions.js'; | 161 | import { ModuleWorkerWrapper, doDailyExtensionUpdatesCheck, extension_settings, getContext, loadExtensionSettings, renderExtensionTemplate, renderExtensionTemplateAsync, runGenerationInterceptors, saveMetadataDebounced, writeExtensionField } from './scripts/extensions.js'; |
| 162 | import { COMMENT_NAME_DEFAULT, executeSlashCommands, executeSlashCommandsOnChatInput, getSlashCommandsHelp, isExecutingCommandsFromChatInput, pauseScriptExecution, processChatSlashCommands, registerSlashCommand, stopScriptExecution } from './scripts/slash-commands.js'; | 162 | import { COMMENT_NAME_DEFAULT, executeSlashCommands, executeSlashCommandsOnChatInput, getSlashCommandsHelp, initDefaultSlashCommands, isExecutingCommandsFromChatInput, pauseScriptExecution, processChatSlashCommands, registerSlashCommand, stopScriptExecution } from './scripts/slash-commands.js'; |
| 163 | import { | 163 | import { |
| 164 | tag_map, | 164 | tag_map, |
| 165 | tags, | 165 | tags, |
| @@ -911,6 +911,7 @@ async function firstLoadInit() { | |||
| 911 | initKeyboard(); | 911 | initKeyboard(); |
| 912 | initDynamicStyles(); | 912 | initDynamicStyles(); |
| 913 | initTags(); | 913 | initTags(); |
| 914 | initDefaultSlashCommands(); | ||
| 914 | await getUserAvatars(true, user_avatar); | 915 | await getUserAvatars(true, user_avatar); |
| 915 | await getCharacters(); | 916 | await getCharacters(); |
| 916 | await getBackgrounds(); | 917 | await getBackgrounds(); |
| @@ -38,13 +38,13 @@ import { | |||
| 38 | system_message_types, | 38 | system_message_types, |
| 39 | this_chid, | 39 | this_chid, |
| 40 | } from '../script.js'; | 40 | } from '../script.js'; |
| 41 | import { PARSER_FLAG, SlashCommandParser } from './slash-commands/SlashCommandParser.js'; | 41 | import { SlashCommandParser } from './slash-commands/SlashCommandParser.js'; |
| 42 | import { SlashCommandParserError } from './slash-commands/SlashCommandParserError.js'; | 42 | import { SlashCommandParserError } from './slash-commands/SlashCommandParserError.js'; |
| 43 | import { getMessageTimeStamp } from './RossAscends-mods.js'; | 43 | import { getMessageTimeStamp } from './RossAscends-mods.js'; |
| 44 | import { hideChatMessageRange } from './chats.js'; | 44 | import { hideChatMessageRange } from './chats.js'; |
| 45 | import { extension_settings, getContext, saveMetadataDebounced } from './extensions.js'; | 45 | import { getContext, saveMetadataDebounced } from './extensions.js'; |
| 46 | import { getRegexedString, regex_placement } from './extensions/regex/engine.js'; | 46 | import { getRegexedString, regex_placement } from './extensions/regex/engine.js'; |
| 47 | import { findGroupMemberId, getGroupMembers, groups, is_group_generating, openGroupById, resetSelectedGroup, saveGroupChat, selected_group } from './group-chats.js'; | 47 | import { findGroupMemberId, groups, is_group_generating, openGroupById, resetSelectedGroup, saveGroupChat, selected_group } from './group-chats.js'; |
| 48 | import { chat_completion_sources, oai_settings, setupChatCompletionPromptManager } from './openai.js'; | 48 | import { chat_completion_sources, oai_settings, setupChatCompletionPromptManager } from './openai.js'; |
| 49 | import { autoSelectPersona, retriggerFirstMessageOnEmptyChat, setPersonaLockState, togglePersonaLock, user_avatar } from './personas.js'; | 49 | import { autoSelectPersona, retriggerFirstMessageOnEmptyChat, setPersonaLockState, togglePersonaLock, user_avatar } from './personas.js'; |
| 50 | import { addEphemeralStoppingString, chat_styles, flushEphemeralStoppingStrings, power_user } from './power-user.js'; | 50 | import { addEphemeralStoppingString, chat_styles, flushEphemeralStoppingStrings, power_user } from './power-user.js'; |
| @@ -53,7 +53,6 @@ import { decodeTextTokens, getFriendlyTokenizerName, getTextTokens, getTokenCoun | |||
| 53 | import { debounce, delay, isFalseBoolean, isTrueBoolean, stringToRange, trimToEndSentence, trimToStartSentence, waitUntilCondition } from './utils.js'; | 53 | import { debounce, delay, isFalseBoolean, isTrueBoolean, stringToRange, trimToEndSentence, trimToStartSentence, waitUntilCondition } from './utils.js'; |
| 54 | import { registerVariableCommands, resolveVariable } from './variables.js'; | 54 | import { registerVariableCommands, resolveVariable } from './variables.js'; |
| 55 | import { background_settings } from './backgrounds.js'; | 55 | import { background_settings } from './backgrounds.js'; |
| 56 | import { SlashCommandScope } from './slash-commands/SlashCommandScope.js'; | ||
| 57 | import { SlashCommandClosure } from './slash-commands/SlashCommandClosure.js'; | 56 | import { SlashCommandClosure } from './slash-commands/SlashCommandClosure.js'; |
| 58 | import { SlashCommandClosureResult } from './slash-commands/SlashCommandClosureResult.js'; | 57 | import { SlashCommandClosureResult } from './slash-commands/SlashCommandClosureResult.js'; |
| 59 | import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from './slash-commands/SlashCommandArgument.js'; | 58 | import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from './slash-commands/SlashCommandArgument.js'; |
| @@ -75,78 +74,79 @@ export const parser = new SlashCommandParser(); | |||
| 75 | const registerSlashCommand = SlashCommandParser.addCommand.bind(SlashCommandParser); | 74 | const registerSlashCommand = SlashCommandParser.addCommand.bind(SlashCommandParser); |
| 76 | const getSlashCommandsHelp = parser.getHelpString.bind(parser); | 75 | const getSlashCommandsHelp = parser.getHelpString.bind(parser); |
| 77 | 76 | ||
| 78 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 77 | export function initDefaultSlashCommands() { |
| 79 | name: '?', | 78 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 80 | callback: helpCommandCallback, | 79 | name: '?', |
| 81 | aliases: ['help'], | 80 | callback: helpCommandCallback, |
| 82 | unnamedArgumentList: [SlashCommandArgument.fromProps({ | 81 | aliases: ['help'], |
| 83 | description: 'help topic', | 82 | unnamedArgumentList: [SlashCommandArgument.fromProps({ |
| 84 | typeList: [ARGUMENT_TYPE.STRING], | 83 | description: 'help topic', |
| 85 | enumList: [ | ||
| 86 | new SlashCommandEnumValue('slash', 'slash commands (STscript)', enumTypes.command, '/'), | ||
| 87 | new SlashCommandEnumValue('macros', '{{macros}} (text replacement)', enumTypes.macro, enumIcons.macro), | ||
| 88 | new SlashCommandEnumValue('format', 'chat/text formatting', enumTypes.name, '★'), | ||
| 89 | new SlashCommandEnumValue('hotkeys', 'keyboard shortcuts', enumTypes.enum, '⏎'), | ||
| 90 | ], | ||
| 91 | })], | ||
| 92 | helpString: 'Get help on macros, chat formatting and commands.', | ||
| 93 | })); | ||
| 94 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | ||
| 95 | name: 'persona', | ||
| 96 | callback: setNameCallback, | ||
| 97 | namedArgumentList: [ | ||
| 98 | new SlashCommandNamedArgument( | ||
| 99 | 'mode', 'The mode for persona selection. ("lookup" = search for existing persona, "temp" = create a temporary name, set a temporary name, "all" = allow both in the same command)', | ||
| 100 | [ARGUMENT_TYPE.STRING], false, false, 'all', ['lookup', 'temp', 'all'], | ||
| 101 | ), | ||
| 102 | ], | ||
| 103 | unnamedArgumentList: [ | ||
| 104 | SlashCommandArgument.fromProps({ | ||
| 105 | description: 'persona name', | ||
| 106 | typeList: [ARGUMENT_TYPE.STRING], | 84 | typeList: [ARGUMENT_TYPE.STRING], |
| 107 | isRequired: true, | 85 | enumList: [ |
| 108 | enumProvider: commonEnumProviders.personas, | 86 | new SlashCommandEnumValue('slash', 'slash commands (STscript)', enumTypes.command, '/'), |
| 109 | }), | 87 | new SlashCommandEnumValue('macros', '{{macros}} (text replacement)', enumTypes.macro, enumIcons.macro), |
| 110 | ], | 88 | new SlashCommandEnumValue('format', 'chat/text formatting', enumTypes.name, '★'), |
| 111 | helpString: 'Selects the given persona with its name and avatar (by name or avatar url). If no matching persona exists, applies a temporary name.', | 89 | new SlashCommandEnumValue('hotkeys', 'keyboard shortcuts', enumTypes.enum, '⏎'), |
| 112 | aliases: ['name'], | 90 | ], |
| 113 | })); | 91 | })], |
| 114 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 92 | helpString: 'Get help on macros, chat formatting and commands.', |
| 115 | name: 'sync', | 93 | })); |
| 116 | callback: syncCallback, | 94 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 117 | helpString: 'Syncs the user persona in user-attributed messages in the current chat.', | 95 | name: 'persona', |
| 118 | })); | 96 | callback: setNameCallback, |
| 119 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 97 | namedArgumentList: [ |
| 120 | name: 'lock', | 98 | new SlashCommandNamedArgument( |
| 121 | callback: lockPersonaCallback, | 99 | 'mode', 'The mode for persona selection. ("lookup" = search for existing persona, "temp" = create a temporary name, set a temporary name, "all" = allow both in the same command)', |
| 122 | aliases: ['bind'], | 100 | [ARGUMENT_TYPE.STRING], false, false, 'all', ['lookup', 'temp', 'all'], |
| 123 | helpString: 'Locks/unlocks a persona (name and avatar) to the current chat', | 101 | ), |
| 124 | unnamedArgumentList: [ | 102 | ], |
| 125 | SlashCommandArgument.fromProps({ | 103 | unnamedArgumentList: [ |
| 126 | description: 'state', | 104 | SlashCommandArgument.fromProps({ |
| 127 | typeList: [ARGUMENT_TYPE.STRING], | 105 | description: 'persona name', |
| 128 | isRequired: true, | 106 | typeList: [ARGUMENT_TYPE.STRING], |
| 129 | defaultValue: 'toggle', | 107 | isRequired: true, |
| 130 | enumProvider: commonEnumProviders.boolean('onOffToggle'), | 108 | enumProvider: commonEnumProviders.personas, |
| 131 | }), | 109 | }), |
| 132 | ], | 110 | ], |
| 133 | })); | 111 | helpString: 'Selects the given persona with its name and avatar (by name or avatar url). If no matching persona exists, applies a temporary name.', |
| 134 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 112 | aliases: ['name'], |
| 135 | name: 'bg', | 113 | })); |
| 136 | callback: setBackgroundCallback, | 114 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 137 | aliases: ['background'], | 115 | name: 'sync', |
| 138 | returns: 'the current background', | 116 | callback: syncCallback, |
| 139 | unnamedArgumentList: [ | 117 | helpString: 'Syncs the user persona in user-attributed messages in the current chat.', |
| 140 | SlashCommandArgument.fromProps({ | 118 | })); |
| 141 | description: 'filename', | 119 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 142 | typeList: [ARGUMENT_TYPE.STRING], | 120 | name: 'lock', |
| 143 | isRequired: true, | 121 | callback: lockPersonaCallback, |
| 144 | enumProvider: () => [...document.querySelectorAll('.bg_example')] | 122 | aliases: ['bind'], |
| 145 | .map(it => new SlashCommandEnumValue(it.getAttribute('bgfile'))) | 123 | helpString: 'Locks/unlocks a persona (name and avatar) to the current chat', |
| 146 | .filter(it => it.value?.length), | 124 | unnamedArgumentList: [ |
| 147 | }), | 125 | SlashCommandArgument.fromProps({ |
| 148 | ], | 126 | description: 'state', |
| 149 | helpString: ` | 127 | typeList: [ARGUMENT_TYPE.STRING], |
| 128 | isRequired: true, | ||
| 129 | defaultValue: 'toggle', | ||
| 130 | enumProvider: commonEnumProviders.boolean('onOffToggle'), | ||
| 131 | }), | ||
| 132 | ], | ||
| 133 | })); | ||
| 134 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | ||
| 135 | name: 'bg', | ||
| 136 | callback: setBackgroundCallback, | ||
| 137 | aliases: ['background'], | ||
| 138 | returns: 'the current background', | ||
| 139 | unnamedArgumentList: [ | ||
| 140 | SlashCommandArgument.fromProps({ | ||
| 141 | description: 'filename', | ||
| 142 | typeList: [ARGUMENT_TYPE.STRING], | ||
| 143 | isRequired: true, | ||
| 144 | enumProvider: () => [...document.querySelectorAll('.bg_example')] | ||
| 145 | .map(it => new SlashCommandEnumValue(it.getAttribute('bgfile'))) | ||
| 146 | .filter(it => it.value?.length), | ||
| 147 | }), | ||
| 148 | ], | ||
| 149 | helpString: ` | ||
| 150 | <div> | 150 | <div> |
| 151 | Sets a background according to the provided filename. Partial names allowed. | 151 | Sets a background according to the provided filename. Partial names allowed. |
| 152 | </div> | 152 | </div> |
| @@ -159,35 +159,35 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 159 | </ul> | 159 | </ul> |
| 160 | </div> | 160 | </div> |
| 161 | `, | 161 | `, |
| 162 | })); | 162 | })); |
| 163 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 163 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 164 | name: 'sendas', | 164 | name: 'sendas', |
| 165 | callback: sendMessageAs, | 165 | callback: sendMessageAs, |
| 166 | namedArgumentList: [ | 166 | namedArgumentList: [ |
| 167 | SlashCommandNamedArgument.fromProps({ | 167 | SlashCommandNamedArgument.fromProps({ |
| 168 | name: 'name', | 168 | name: 'name', |
| 169 | description: 'Character name', | 169 | description: 'Character name', |
| 170 | typeList: [ARGUMENT_TYPE.STRING], | 170 | typeList: [ARGUMENT_TYPE.STRING], |
| 171 | isRequired: true, | 171 | isRequired: true, |
| 172 | enumProvider: commonEnumProviders.characters('character'), | 172 | enumProvider: commonEnumProviders.characters('character'), |
| 173 | forceEnum: false, | 173 | forceEnum: false, |
| 174 | }), | 174 | }), |
| 175 | new SlashCommandNamedArgument( | 175 | new SlashCommandNamedArgument( |
| 176 | 'compact', 'Use compact layout', [ARGUMENT_TYPE.BOOLEAN], false, false, 'false', | 176 | 'compact', 'Use compact layout', [ARGUMENT_TYPE.BOOLEAN], false, false, 'false', |
| 177 | ), | 177 | ), |
| 178 | SlashCommandNamedArgument.fromProps({ | 178 | SlashCommandNamedArgument.fromProps({ |
| 179 | name: 'at', | 179 | name: 'at', |
| 180 | description: 'position to insert the message', | 180 | description: 'position to insert the message', |
| 181 | typeList: [ARGUMENT_TYPE.NUMBER], | 181 | typeList: [ARGUMENT_TYPE.NUMBER], |
| 182 | enumProvider: commonEnumProviders.messages({ allowIdAfter: true }), | 182 | enumProvider: commonEnumProviders.messages({ allowIdAfter: true }), |
| 183 | }), | 183 | }), |
| 184 | ], | 184 | ], |
| 185 | unnamedArgumentList: [ | 185 | unnamedArgumentList: [ |
| 186 | new SlashCommandArgument( | 186 | new SlashCommandArgument( |
| 187 | 'text', [ARGUMENT_TYPE.STRING], true, | 187 | 'text', [ARGUMENT_TYPE.STRING], true, |
| 188 | ), | 188 | ), |
| 189 | ], | 189 | ], |
| 190 | helpString: ` | 190 | helpString: ` |
| 191 | <div> | 191 | <div> |
| 192 | Sends a message as a specific character. Uses the character avatar if it exists in the characters list. | 192 | Sends a message as a specific character. Uses the character avatar if it exists in the characters list. |
| 193 | </div> | 193 | </div> |
| @@ -204,33 +204,33 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 204 | If "compact" is set to true, the message is sent using a compact layout. | 204 | If "compact" is set to true, the message is sent using a compact layout. |
| 205 | </div> | 205 | </div> |
| 206 | `, | 206 | `, |
| 207 | })); | 207 | })); |
| 208 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 208 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 209 | name: 'sys', | 209 | name: 'sys', |
| 210 | callback: sendNarratorMessage, | 210 | callback: sendNarratorMessage, |
| 211 | aliases: ['nar'], | 211 | aliases: ['nar'], |
| 212 | namedArgumentList: [ | 212 | namedArgumentList: [ |
| 213 | new SlashCommandNamedArgument( | 213 | new SlashCommandNamedArgument( |
| 214 | 'compact', | 214 | 'compact', |
| 215 | 'compact layout', | 215 | 'compact layout', |
| 216 | [ARGUMENT_TYPE.BOOLEAN], | 216 | [ARGUMENT_TYPE.BOOLEAN], |
| 217 | false, | 217 | false, |
| 218 | false, | 218 | false, |
| 219 | 'false', | 219 | 'false', |
| 220 | ), | 220 | ), |
| 221 | SlashCommandNamedArgument.fromProps({ | 221 | SlashCommandNamedArgument.fromProps({ |
| 222 | name: 'at', | 222 | name: 'at', |
| 223 | description: 'position to insert the message', | 223 | description: 'position to insert the message', |
| 224 | typeList: [ARGUMENT_TYPE.NUMBER], | 224 | typeList: [ARGUMENT_TYPE.NUMBER], |
| 225 | enumProvider: commonEnumProviders.messages({ allowIdAfter: true }), | 225 | enumProvider: commonEnumProviders.messages({ allowIdAfter: true }), |
| 226 | }), | 226 | }), |
| 227 | ], | 227 | ], |
| 228 | unnamedArgumentList: [ | 228 | unnamedArgumentList: [ |
| 229 | new SlashCommandArgument( | 229 | new SlashCommandArgument( |
| 230 | 'text', [ARGUMENT_TYPE.STRING], true, | 230 | 'text', [ARGUMENT_TYPE.STRING], true, |
| 231 | ), | 231 | ), |
| 232 | ], | 232 | ], |
| 233 | helpString: ` | 233 | helpString: ` |
| 234 | <div> | 234 | <div> |
| 235 | Sends a message as a system narrator. | 235 | Sends a message as a system narrator. |
| 236 | </div> | 236 | </div> |
| @@ -249,44 +249,44 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 249 | </ul> | 249 | </ul> |
| 250 | </div> | 250 | </div> |
| 251 | `, | 251 | `, |
| 252 | })); | 252 | })); |
| 253 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 253 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 254 | name: 'sysname', | 254 | name: 'sysname', |
| 255 | callback: setNarratorName, | 255 | callback: setNarratorName, |
| 256 | unnamedArgumentList: [ | 256 | unnamedArgumentList: [ |
| 257 | new SlashCommandArgument( | 257 | new SlashCommandArgument( |
| 258 | 'name', [ARGUMENT_TYPE.STRING], false, | 258 | 'name', [ARGUMENT_TYPE.STRING], false, |
| 259 | ), | 259 | ), |
| 260 | ], | 260 | ], |
| 261 | helpString: 'Sets a name for future system narrator messages in this chat (display only). Default: System. Leave empty to reset.', | 261 | helpString: 'Sets a name for future system narrator messages in this chat (display only). Default: System. Leave empty to reset.', |
| 262 | })); | 262 | })); |
| 263 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 263 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 264 | name: 'comment', | 264 | name: 'comment', |
| 265 | callback: sendCommentMessage, | 265 | callback: sendCommentMessage, |
| 266 | namedArgumentList: [ | 266 | namedArgumentList: [ |
| 267 | new SlashCommandNamedArgument( | 267 | new SlashCommandNamedArgument( |
| 268 | 'compact', | 268 | 'compact', |
| 269 | 'Whether to use a compact layout', | 269 | 'Whether to use a compact layout', |
| 270 | [ARGUMENT_TYPE.BOOLEAN], | 270 | [ARGUMENT_TYPE.BOOLEAN], |
| 271 | false, | 271 | false, |
| 272 | false, | 272 | false, |
| 273 | 'false', | 273 | 'false', |
| 274 | ), | 274 | ), |
| 275 | SlashCommandNamedArgument.fromProps({ | 275 | SlashCommandNamedArgument.fromProps({ |
| 276 | name: 'at', | 276 | name: 'at', |
| 277 | description: 'position to insert the message', | 277 | description: 'position to insert the message', |
| 278 | typeList: [ARGUMENT_TYPE.NUMBER], | 278 | typeList: [ARGUMENT_TYPE.NUMBER], |
| 279 | enumProvider: commonEnumProviders.messages({ allowIdAfter: true }), | 279 | enumProvider: commonEnumProviders.messages({ allowIdAfter: true }), |
| 280 | }), | 280 | }), |
| 281 | ], | 281 | ], |
| 282 | unnamedArgumentList: [ | 282 | unnamedArgumentList: [ |
| 283 | new SlashCommandArgument( | 283 | new SlashCommandArgument( |
| 284 | 'text', | 284 | 'text', |
| 285 | [ARGUMENT_TYPE.STRING], | 285 | [ARGUMENT_TYPE.STRING], |
| 286 | true, | 286 | true, |
| 287 | ), | 287 | ), |
| 288 | ], | 288 | ], |
| 289 | helpString: ` | 289 | helpString: ` |
| 290 | <div> | 290 | <div> |
| 291 | Adds a note/comment message not part of the chat. | 291 | Adds a note/comment message not part of the chat. |
| 292 | </div> | 292 | </div> |
| @@ -305,35 +305,35 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 305 | </ul> | 305 | </ul> |
| 306 | </div> | 306 | </div> |
| 307 | `, | 307 | `, |
| 308 | })); | 308 | })); |
| 309 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 309 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 310 | name: 'single', | 310 | name: 'single', |
| 311 | callback: setStoryModeCallback, | 311 | callback: setStoryModeCallback, |
| 312 | aliases: ['story'], | 312 | aliases: ['story'], |
| 313 | helpString: 'Sets the message style to single document mode without names or avatars visible.', | 313 | helpString: 'Sets the message style to single document mode without names or avatars visible.', |
| 314 | })); | 314 | })); |
| 315 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 315 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 316 | name: 'bubble', | 316 | name: 'bubble', |
| 317 | callback: setBubbleModeCallback, | 317 | callback: setBubbleModeCallback, |
| 318 | aliases: ['bubbles'], | 318 | aliases: ['bubbles'], |
| 319 | helpString: 'Sets the message style to bubble chat mode.', | 319 | helpString: 'Sets the message style to bubble chat mode.', |
| 320 | })); | 320 | })); |
| 321 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 321 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 322 | name: 'flat', | 322 | name: 'flat', |
| 323 | callback: setFlatModeCallback, | 323 | callback: setFlatModeCallback, |
| 324 | aliases: ['default'], | 324 | aliases: ['default'], |
| 325 | helpString: 'Sets the message style to flat chat mode.', | 325 | helpString: 'Sets the message style to flat chat mode.', |
| 326 | })); | 326 | })); |
| 327 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 327 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 328 | name: 'continue', | 328 | name: 'continue', |
| 329 | callback: continueChatCallback, | 329 | callback: continueChatCallback, |
| 330 | aliases: ['cont'], | 330 | aliases: ['cont'], |
| 331 | unnamedArgumentList: [ | 331 | unnamedArgumentList: [ |
| 332 | new SlashCommandArgument( | 332 | new SlashCommandArgument( |
| 333 | 'prompt', [ARGUMENT_TYPE.STRING], false, | 333 | 'prompt', [ARGUMENT_TYPE.STRING], false, |
| 334 | ), | 334 | ), |
| 335 | ], | 335 | ], |
| 336 | helpString: ` | 336 | helpString: ` |
| 337 | <div> | 337 | <div> |
| 338 | Continues the last message in the chat, with an optional additional prompt. | 338 | Continues the last message in the chat, with an optional additional prompt. |
| 339 | </div> | 339 | </div> |
| @@ -351,87 +351,87 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 351 | </ul> | 351 | </ul> |
| 352 | </div> | 352 | </div> |
| 353 | `, | 353 | `, |
| 354 | })); | 354 | })); |
| 355 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 355 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 356 | name: 'go', | 356 | name: 'go', |
| 357 | callback: goToCharacterCallback, | 357 | callback: goToCharacterCallback, |
| 358 | unnamedArgumentList: [ | 358 | unnamedArgumentList: [ |
| 359 | SlashCommandArgument.fromProps({ | 359 | SlashCommandArgument.fromProps({ |
| 360 | description: 'name', | 360 | description: 'name', |
| 361 | typeList: [ARGUMENT_TYPE.STRING], | 361 | typeList: [ARGUMENT_TYPE.STRING], |
| 362 | isRequired: true, | 362 | isRequired: true, |
| 363 | enumProvider: commonEnumProviders.characters('all'), | 363 | enumProvider: commonEnumProviders.characters('all'), |
| 364 | }), | 364 | }), |
| 365 | ], | 365 | ], |
| 366 | helpString: 'Opens up a chat with the character or group by its name', | 366 | helpString: 'Opens up a chat with the character or group by its name', |
| 367 | aliases: ['char'], | 367 | aliases: ['char'], |
| 368 | })); | 368 | })); |
| 369 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 369 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 370 | name: 'rename-char', | 370 | name: 'rename-char', |
| 371 | /** @param {{silent: string, chats: string}} options @param {string} name */ | 371 | /** @param {{silent: string, chats: string}} options @param {string} name */ |
| 372 | callback: async ({ silent = 'true', chats = null }, name) => { | 372 | callback: async ({ silent = 'true', chats = null }, name) => { |
| 373 | const renamed = await renameCharacter(name, { silent: isTrueBoolean(silent), renameChats: chats !== null ? isTrueBoolean(chats) : null }); | 373 | const renamed = await renameCharacter(name, { silent: isTrueBoolean(silent), renameChats: chats !== null ? isTrueBoolean(chats) : null }); |
| 374 | return String(renamed); | 374 | return String(renamed); |
| 375 | }, | 375 | }, |
| 376 | returns: 'true/false - Whether the rename was successful', | 376 | returns: 'true/false - Whether the rename was successful', |
| 377 | namedArgumentList: [ | 377 | namedArgumentList: [ |
| 378 | new SlashCommandNamedArgument( | 378 | new SlashCommandNamedArgument( |
| 379 | 'silent', 'Hide any blocking popups. (if false, the name is optional. If not supplied, a popup asking for it will appear)', [ARGUMENT_TYPE.BOOLEAN], false, false, 'true', | 379 | 'silent', 'Hide any blocking popups. (if false, the name is optional. If not supplied, a popup asking for it will appear)', [ARGUMENT_TYPE.BOOLEAN], false, false, 'true', |
| 380 | ), | 380 | ), |
| 381 | new SlashCommandNamedArgument( | 381 | new SlashCommandNamedArgument( |
| 382 | 'chats', 'Rename char in all previous chats', [ARGUMENT_TYPE.BOOLEAN], false, false, '<null>', | 382 | 'chats', 'Rename char in all previous chats', [ARGUMENT_TYPE.BOOLEAN], false, false, '<null>', |
| 383 | ), | 383 | ), |
| 384 | ], | 384 | ], |
| 385 | unnamedArgumentList: [ | 385 | unnamedArgumentList: [ |
| 386 | new SlashCommandArgument( | 386 | new SlashCommandArgument( |
| 387 | 'new char name', [ARGUMENT_TYPE.STRING], true, | 387 | 'new char name', [ARGUMENT_TYPE.STRING], true, |
| 388 | ), | 388 | ), |
| 389 | ], | 389 | ], |
| 390 | helpString: 'Renames the current character.', | 390 | helpString: 'Renames the current character.', |
| 391 | })); | 391 | })); |
| 392 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 392 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 393 | name: 'sysgen', | 393 | name: 'sysgen', |
| 394 | callback: generateSystemMessage, | 394 | callback: generateSystemMessage, |
| 395 | unnamedArgumentList: [ | 395 | unnamedArgumentList: [ |
| 396 | new SlashCommandArgument( | 396 | new SlashCommandArgument( |
| 397 | 'prompt', [ARGUMENT_TYPE.STRING], true, | 397 | 'prompt', [ARGUMENT_TYPE.STRING], true, |
| 398 | ), | 398 | ), |
| 399 | ], | 399 | ], |
| 400 | helpString: 'Generates a system message using a specified prompt.', | 400 | helpString: 'Generates a system message using a specified prompt.', |
| 401 | })); | 401 | })); |
| 402 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 402 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 403 | name: 'ask', | 403 | name: 'ask', |
| 404 | callback: askCharacter, | 404 | callback: askCharacter, |
| 405 | namedArgumentList: [ | 405 | namedArgumentList: [ |
| 406 | SlashCommandNamedArgument.fromProps({ | 406 | SlashCommandNamedArgument.fromProps({ |
| 407 | name: 'name', | 407 | name: 'name', |
| 408 | description: 'character name', | 408 | description: 'character name', |
| 409 | typeList: [ARGUMENT_TYPE.STRING], | 409 | typeList: [ARGUMENT_TYPE.STRING], |
| 410 | isRequired: true, | 410 | isRequired: true, |
| 411 | enumProvider: commonEnumProviders.characters('character'), | 411 | enumProvider: commonEnumProviders.characters('character'), |
| 412 | }), | 412 | }), |
| 413 | ], | 413 | ], |
| 414 | unnamedArgumentList: [ | 414 | unnamedArgumentList: [ |
| 415 | new SlashCommandArgument( | 415 | new SlashCommandArgument( |
| 416 | 'prompt', [ARGUMENT_TYPE.STRING], true, false, | 416 | 'prompt', [ARGUMENT_TYPE.STRING], true, false, |
| 417 | ), | 417 | ), |
| 418 | ], | 418 | ], |
| 419 | helpString: 'Asks a specified character card a prompt. Character name must be provided in a named argument.', | 419 | helpString: 'Asks a specified character card a prompt. Character name must be provided in a named argument.', |
| 420 | })); | 420 | })); |
| 421 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 421 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 422 | name: 'delname', | 422 | name: 'delname', |
| 423 | callback: deleteMessagesByNameCallback, | 423 | callback: deleteMessagesByNameCallback, |
| 424 | namedArgumentList: [], | 424 | namedArgumentList: [], |
| 425 | unnamedArgumentList: [ | 425 | unnamedArgumentList: [ |
| 426 | SlashCommandArgument.fromProps({ | 426 | SlashCommandArgument.fromProps({ |
| 427 | description: 'name', | 427 | description: 'name', |
| 428 | typeList: [ARGUMENT_TYPE.STRING], | 428 | typeList: [ARGUMENT_TYPE.STRING], |
| 429 | isRequired: true, | 429 | isRequired: true, |
| 430 | enumProvider: commonEnumProviders.characters('character'), | 430 | enumProvider: commonEnumProviders.characters('character'), |
| 431 | }), | 431 | }), |
| 432 | ], | 432 | ], |
| 433 | aliases: ['cancel'], | 433 | aliases: ['cancel'], |
| 434 | helpString: ` | 434 | helpString: ` |
| 435 | <div> | 435 | <div> |
| 436 | Deletes all messages attributed to a specified name. | 436 | Deletes all messages attributed to a specified name. |
| 437 | </div> | 437 | </div> |
| @@ -444,41 +444,41 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 444 | </ul> | 444 | </ul> |
| 445 | </div> | 445 | </div> |
| 446 | `, | 446 | `, |
| 447 | })); | 447 | })); |
| 448 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 448 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 449 | name: 'send', | 449 | name: 'send', |
| 450 | callback: sendUserMessageCallback, | 450 | callback: sendUserMessageCallback, |
| 451 | namedArgumentList: [ | 451 | namedArgumentList: [ |
| 452 | new SlashCommandNamedArgument( | 452 | new SlashCommandNamedArgument( |
| 453 | 'compact', | 453 | 'compact', |
| 454 | 'whether to use a compact layout', | 454 | 'whether to use a compact layout', |
| 455 | [ARGUMENT_TYPE.BOOLEAN], | 455 | [ARGUMENT_TYPE.BOOLEAN], |
| 456 | false, | 456 | false, |
| 457 | false, | 457 | false, |
| 458 | 'false', | 458 | 'false', |
| 459 | ), | 459 | ), |
| 460 | SlashCommandNamedArgument.fromProps({ | 460 | SlashCommandNamedArgument.fromProps({ |
| 461 | name: 'at', | 461 | name: 'at', |
| 462 | description: 'position to insert the message', | 462 | description: 'position to insert the message', |
| 463 | typeList: [ARGUMENT_TYPE.NUMBER], | 463 | typeList: [ARGUMENT_TYPE.NUMBER], |
| 464 | enumProvider: commonEnumProviders.messages({ allowIdAfter: true }), | 464 | enumProvider: commonEnumProviders.messages({ allowIdAfter: true }), |
| 465 | }), | 465 | }), |
| 466 | SlashCommandNamedArgument.fromProps({ | 466 | SlashCommandNamedArgument.fromProps({ |
| 467 | name: 'name', | 467 | name: 'name', |
| 468 | description: 'display name', | 468 | description: 'display name', |
| 469 | typeList: [ARGUMENT_TYPE.STRING], | 469 | typeList: [ARGUMENT_TYPE.STRING], |
| 470 | defaultValue: '{{user}}', | 470 | defaultValue: '{{user}}', |
| 471 | enumProvider: commonEnumProviders.characters('character'), | 471 | enumProvider: commonEnumProviders.characters('character'), |
| 472 | }), | 472 | }), |
| 473 | ], | 473 | ], |
| 474 | unnamedArgumentList: [ | 474 | unnamedArgumentList: [ |
| 475 | new SlashCommandArgument( | 475 | new SlashCommandArgument( |
| 476 | 'text', | 476 | 'text', |
| 477 | [ARGUMENT_TYPE.STRING], | 477 | [ARGUMENT_TYPE.STRING], |
| 478 | true, | 478 | true, |
| 479 | ), | 479 | ), |
| 480 | ], | 480 | ], |
| 481 | helpString: ` | 481 | helpString: ` |
| 482 | <div> | 482 | <div> |
| 483 | Adds a user message to the chat log without triggering a generation. | 483 | Adds a user message to the chat log without triggering a generation. |
| 484 | </div> | 484 | </div> |
| @@ -500,29 +500,29 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 500 | </ul> | 500 | </ul> |
| 501 | </div> | 501 | </div> |
| 502 | `, | 502 | `, |
| 503 | })); | 503 | })); |
| 504 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 504 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 505 | name: 'trigger', | 505 | name: 'trigger', |
| 506 | callback: triggerGenerationCallback, | 506 | callback: triggerGenerationCallback, |
| 507 | namedArgumentList: [ | 507 | namedArgumentList: [ |
| 508 | new SlashCommandNamedArgument( | 508 | new SlashCommandNamedArgument( |
| 509 | 'await', | 509 | 'await', |
| 510 | 'Whether to await for the triggered generation before continuing', | 510 | 'Whether to await for the triggered generation before continuing', |
| 511 | [ARGUMENT_TYPE.BOOLEAN], | 511 | [ARGUMENT_TYPE.BOOLEAN], |
| 512 | false, | 512 | false, |
| 513 | false, | 513 | false, |
| 514 | 'false', | 514 | 'false', |
| 515 | ), | 515 | ), |
| 516 | ], | 516 | ], |
| 517 | unnamedArgumentList: [ | 517 | unnamedArgumentList: [ |
| 518 | SlashCommandArgument.fromProps({ | 518 | SlashCommandArgument.fromProps({ |
| 519 | description: 'group member index (starts with 0) or name', | 519 | description: 'group member index (starts with 0) or name', |
| 520 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], | 520 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], |
| 521 | isRequired: false, | 521 | isRequired: false, |
| 522 | enumProvider: commonEnumProviders.groupMembers(), | 522 | enumProvider: commonEnumProviders.groupMembers(), |
| 523 | }), | 523 | }), |
| 524 | ], | 524 | ], |
| 525 | helpString: ` | 525 | helpString: ` |
| 526 | <div> | 526 | <div> |
| 527 | Triggers a message generation. If in group, can trigger a message for the specified group member index or name. | 527 | Triggers a message generation. If in group, can trigger a message for the specified group member index or name. |
| 528 | </div> | 528 | </div> |
| @@ -530,74 +530,74 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 530 | If <code>await=true</code> named argument is passed, the command will await for the triggered generation before continuing. | 530 | If <code>await=true</code> named argument is passed, the command will await for the triggered generation before continuing. |
| 531 | </div> | 531 | </div> |
| 532 | `, | 532 | `, |
| 533 | })); | 533 | })); |
| 534 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 534 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 535 | name: 'hide', | 535 | name: 'hide', |
| 536 | callback: hideMessageCallback, | 536 | callback: hideMessageCallback, |
| 537 | unnamedArgumentList: [ | 537 | unnamedArgumentList: [ |
| 538 | SlashCommandArgument.fromProps({ | 538 | SlashCommandArgument.fromProps({ |
| 539 | description: 'message index (starts with 0) or range', | 539 | description: 'message index (starts with 0) or range', |
| 540 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.RANGE], | 540 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.RANGE], |
| 541 | isRequired: true, | 541 | isRequired: true, |
| 542 | enumProvider: commonEnumProviders.messages(), | 542 | enumProvider: commonEnumProviders.messages(), |
| 543 | }), | 543 | }), |
| 544 | ], | 544 | ], |
| 545 | helpString: 'Hides a chat message from the prompt.', | 545 | helpString: 'Hides a chat message from the prompt.', |
| 546 | })); | 546 | })); |
| 547 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 547 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 548 | name: 'unhide', | 548 | name: 'unhide', |
| 549 | callback: unhideMessageCallback, | 549 | callback: unhideMessageCallback, |
| 550 | unnamedArgumentList: [ | 550 | unnamedArgumentList: [ |
| 551 | SlashCommandArgument.fromProps({ | 551 | SlashCommandArgument.fromProps({ |
| 552 | description: 'message index (starts with 0) or range', | 552 | description: 'message index (starts with 0) or range', |
| 553 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.RANGE], | 553 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.RANGE], |
| 554 | isRequired: true, | 554 | isRequired: true, |
| 555 | enumProvider: commonEnumProviders.messages(), | 555 | enumProvider: commonEnumProviders.messages(), |
| 556 | }), | 556 | }), |
| 557 | ], | 557 | ], |
| 558 | helpString: 'Unhides a message from the prompt.', | 558 | helpString: 'Unhides a message from the prompt.', |
| 559 | })); | 559 | })); |
| 560 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 560 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 561 | name: 'member-disable', | 561 | name: 'member-disable', |
| 562 | callback: disableGroupMemberCallback, | 562 | callback: disableGroupMemberCallback, |
| 563 | aliases: ['disable', 'disablemember', 'memberdisable'], | 563 | aliases: ['disable', 'disablemember', 'memberdisable'], |
| 564 | unnamedArgumentList: [ | 564 | unnamedArgumentList: [ |
| 565 | SlashCommandArgument.fromProps({ | 565 | SlashCommandArgument.fromProps({ |
| 566 | description: 'member index (starts with 0) or name', | 566 | description: 'member index (starts with 0) or name', |
| 567 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], | 567 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], |
| 568 | isRequired: true, | 568 | isRequired: true, |
| 569 | enumProvider: commonEnumProviders.groupMembers(), | 569 | enumProvider: commonEnumProviders.groupMembers(), |
| 570 | }), | 570 | }), |
| 571 | ], | 571 | ], |
| 572 | helpString: 'Disables a group member from being drafted for replies.', | 572 | helpString: 'Disables a group member from being drafted for replies.', |
| 573 | })); | 573 | })); |
| 574 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 574 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 575 | name: 'member-enable', | 575 | name: 'member-enable', |
| 576 | aliases: ['enable', 'enablemember', 'memberenable'], | 576 | aliases: ['enable', 'enablemember', 'memberenable'], |
| 577 | callback: enableGroupMemberCallback, | 577 | callback: enableGroupMemberCallback, |
| 578 | unnamedArgumentList: [ | 578 | unnamedArgumentList: [ |
| 579 | SlashCommandArgument.fromProps({ | 579 | SlashCommandArgument.fromProps({ |
| 580 | description: 'member index (starts with 0) or name', | 580 | description: 'member index (starts with 0) or name', |
| 581 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], | 581 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], |
| 582 | isRequired: true, | 582 | isRequired: true, |
| 583 | enumProvider: commonEnumProviders.groupMembers(), | 583 | enumProvider: commonEnumProviders.groupMembers(), |
| 584 | }), | 584 | }), |
| 585 | ], | 585 | ], |
| 586 | helpString: 'Enables a group member to be drafted for replies.', | 586 | helpString: 'Enables a group member to be drafted for replies.', |
| 587 | })); | 587 | })); |
| 588 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 588 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 589 | name: 'member-add', | 589 | name: 'member-add', |
| 590 | callback: addGroupMemberCallback, | 590 | callback: addGroupMemberCallback, |
| 591 | aliases: ['addmember', 'memberadd'], | 591 | aliases: ['addmember', 'memberadd'], |
| 592 | unnamedArgumentList: [ | 592 | unnamedArgumentList: [ |
| 593 | SlashCommandArgument.fromProps({ | 593 | SlashCommandArgument.fromProps({ |
| 594 | description: 'character name', | 594 | description: 'character name', |
| 595 | typeList: [ARGUMENT_TYPE.STRING], | 595 | typeList: [ARGUMENT_TYPE.STRING], |
| 596 | isRequired: true, | 596 | isRequired: true, |
| 597 | enumProvider: () => selected_group ? commonEnumProviders.characters('character')() : [], | 597 | enumProvider: () => selected_group ? commonEnumProviders.characters('character')() : [], |
| 598 | }), | 598 | }), |
| 599 | ], | 599 | ], |
| 600 | helpString: ` | 600 | helpString: ` |
| 601 | <div> | 601 | <div> |
| 602 | Adds a new group member to the group chat. | 602 | Adds a new group member to the group chat. |
| 603 | </div> | 603 | </div> |
| @@ -610,20 +610,20 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 610 | </ul> | 610 | </ul> |
| 611 | </div> | 611 | </div> |
| 612 | `, | 612 | `, |
| 613 | })); | 613 | })); |
| 614 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 614 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 615 | name: 'member-remove', | 615 | name: 'member-remove', |
| 616 | callback: removeGroupMemberCallback, | 616 | callback: removeGroupMemberCallback, |
| 617 | aliases: ['removemember', 'memberremove'], | 617 | aliases: ['removemember', 'memberremove'], |
| 618 | unnamedArgumentList: [ | 618 | unnamedArgumentList: [ |
| 619 | SlashCommandArgument.fromProps({ | 619 | SlashCommandArgument.fromProps({ |
| 620 | description: 'member index (starts with 0) or name', | 620 | description: 'member index (starts with 0) or name', |
| 621 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], | 621 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], |
| 622 | isRequired: true, | 622 | isRequired: true, |
| 623 | enumProvider: commonEnumProviders.groupMembers(), | 623 | enumProvider: commonEnumProviders.groupMembers(), |
| 624 | }), | 624 | }), |
| 625 | ], | 625 | ], |
| 626 | helpString: ` | 626 | helpString: ` |
| 627 | <div> | 627 | <div> |
| 628 | Removes a group member from the group chat. | 628 | Removes a group member from the group chat. |
| 629 | </div> | 629 | </div> |
| @@ -637,47 +637,47 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 637 | </ul> | 637 | </ul> |
| 638 | </div> | 638 | </div> |
| 639 | `, | 639 | `, |
| 640 | })); | 640 | })); |
| 641 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 641 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 642 | name: 'member-up', | 642 | name: 'member-up', |
| 643 | callback: moveGroupMemberUpCallback, | 643 | callback: moveGroupMemberUpCallback, |
| 644 | aliases: ['upmember', 'memberup'], | 644 | aliases: ['upmember', 'memberup'], |
| 645 | unnamedArgumentList: [ | 645 | unnamedArgumentList: [ |
| 646 | SlashCommandArgument.fromProps({ | 646 | SlashCommandArgument.fromProps({ |
| 647 | description: 'member index (starts with 0) or name', | 647 | description: 'member index (starts with 0) or name', |
| 648 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], | 648 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], |
| 649 | isRequired: true, | 649 | isRequired: true, |
| 650 | enumProvider: commonEnumProviders.groupMembers(), | 650 | enumProvider: commonEnumProviders.groupMembers(), |
| 651 | }), | 651 | }), |
| 652 | ], | 652 | ], |
| 653 | helpString: 'Moves a group member up in the group chat list.', | 653 | helpString: 'Moves a group member up in the group chat list.', |
| 654 | })); | 654 | })); |
| 655 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 655 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 656 | name: 'member-down', | 656 | name: 'member-down', |
| 657 | callback: moveGroupMemberDownCallback, | 657 | callback: moveGroupMemberDownCallback, |
| 658 | aliases: ['downmember', 'memberdown'], | 658 | aliases: ['downmember', 'memberdown'], |
| 659 | unnamedArgumentList: [ | 659 | unnamedArgumentList: [ |
| 660 | SlashCommandArgument.fromProps({ | 660 | SlashCommandArgument.fromProps({ |
| 661 | description: 'member index (starts with 0) or name', | 661 | description: 'member index (starts with 0) or name', |
| 662 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], | 662 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], |
| 663 | isRequired: true, | 663 | isRequired: true, |
| 664 | enumProvider: commonEnumProviders.groupMembers(), | 664 | enumProvider: commonEnumProviders.groupMembers(), |
| 665 | }), | 665 | }), |
| 666 | ], | 666 | ], |
| 667 | helpString: 'Moves a group member down in the group chat list.', | 667 | helpString: 'Moves a group member down in the group chat list.', |
| 668 | })); | 668 | })); |
| 669 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 669 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 670 | name: 'peek', | 670 | name: 'peek', |
| 671 | callback: peekCallback, | 671 | callback: peekCallback, |
| 672 | unnamedArgumentList: [ | 672 | unnamedArgumentList: [ |
| 673 | SlashCommandArgument.fromProps({ | 673 | SlashCommandArgument.fromProps({ |
| 674 | description: 'member index (starts with 0) or name', | 674 | description: 'member index (starts with 0) or name', |
| 675 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], | 675 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], |
| 676 | isRequired: true, | 676 | isRequired: true, |
| 677 | enumProvider: commonEnumProviders.groupMembers(), | 677 | enumProvider: commonEnumProviders.groupMembers(), |
| 678 | }), | 678 | }), |
| 679 | ], | 679 | ], |
| 680 | helpString: ` | 680 | helpString: ` |
| 681 | <div> | 681 | <div> |
| 682 | Shows a group member character card without switching chats. | 682 | Shows a group member character card without switching chats. |
| 683 | </div> | 683 | </div> |
| @@ -691,22 +691,22 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 691 | </ul> | 691 | </ul> |
| 692 | </div> | 692 | </div> |
| 693 | `, | 693 | `, |
| 694 | })); | 694 | })); |
| 695 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 695 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 696 | name: 'delswipe', | 696 | name: 'delswipe', |
| 697 | callback: deleteSwipeCallback, | 697 | callback: deleteSwipeCallback, |
| 698 | aliases: ['swipedel'], | 698 | aliases: ['swipedel'], |
| 699 | unnamedArgumentList: [ | 699 | unnamedArgumentList: [ |
| 700 | SlashCommandArgument.fromProps({ | 700 | SlashCommandArgument.fromProps({ |
| 701 | description: '1-based swipe id', | 701 | description: '1-based swipe id', |
| 702 | typeList: [ARGUMENT_TYPE.NUMBER], | 702 | typeList: [ARGUMENT_TYPE.NUMBER], |
| 703 | isRequired: true, | 703 | isRequired: true, |
| 704 | enumProvider: () => Array.isArray(chat[chat.length - 1]?.swipes) ? | 704 | enumProvider: () => Array.isArray(chat[chat.length - 1]?.swipes) ? |
| 705 | chat[chat.length - 1].swipes.map((/** @type {string} */ swipe, /** @type {number} */ i) => new SlashCommandEnumValue(String(i + 1), swipe, enumTypes.enum, enumIcons.message)) | 705 | chat[chat.length - 1].swipes.map((/** @type {string} */ swipe, /** @type {number} */ i) => new SlashCommandEnumValue(String(i + 1), swipe, enumTypes.enum, enumIcons.message)) |
| 706 | : [], | 706 | : [], |
| 707 | }), | 707 | }), |
| 708 | ], | 708 | ], |
| 709 | helpString: ` | 709 | helpString: ` |
| 710 | <div> | 710 | <div> |
| 711 | Deletes a swipe from the last chat message. If swipe id is not provided, it deletes the current swipe. | 711 | Deletes a swipe from the last chat message. If swipe id is not provided, it deletes the current swipe. |
| 712 | </div> | 712 | </div> |
| @@ -724,34 +724,34 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 724 | </ul> | 724 | </ul> |
| 725 | </div> | 725 | </div> |
| 726 | `, | 726 | `, |
| 727 | })); | 727 | })); |
| 728 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 728 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 729 | name: 'echo', | 729 | name: 'echo', |
| 730 | callback: echoCallback, | 730 | callback: echoCallback, |
| 731 | returns: 'the text', | 731 | returns: 'the text', |
| 732 | namedArgumentList: [ | 732 | namedArgumentList: [ |
| 733 | new SlashCommandNamedArgument( | 733 | new SlashCommandNamedArgument( |
| 734 | 'title', 'title of the toast message', [ARGUMENT_TYPE.STRING], false, | 734 | 'title', 'title of the toast message', [ARGUMENT_TYPE.STRING], false, |
| 735 | ), | 735 | ), |
| 736 | SlashCommandNamedArgument.fromProps({ | 736 | SlashCommandNamedArgument.fromProps({ |
| 737 | name: 'severity', | 737 | name: 'severity', |
| 738 | description: 'severity level of the toast message', | 738 | description: 'severity level of the toast message', |
| 739 | typeList: [ARGUMENT_TYPE.STRING], | 739 | typeList: [ARGUMENT_TYPE.STRING], |
| 740 | defaultValue: 'info', | 740 | defaultValue: 'info', |
| 741 | enumProvider: () => [ | 741 | enumProvider: () => [ |
| 742 | new SlashCommandEnumValue('info', 'info', enumTypes.macro, 'ℹ️'), | 742 | new SlashCommandEnumValue('info', 'info', enumTypes.macro, 'ℹ️'), |
| 743 | new SlashCommandEnumValue('warning', 'warning', enumTypes.enum, '⚠️'), | 743 | new SlashCommandEnumValue('warning', 'warning', enumTypes.enum, '⚠️'), |
| 744 | new SlashCommandEnumValue('error', 'error', enumTypes.enum, '❗'), | 744 | new SlashCommandEnumValue('error', 'error', enumTypes.enum, '❗'), |
| 745 | new SlashCommandEnumValue('success', 'success', enumTypes.enum, '✅'), | 745 | new SlashCommandEnumValue('success', 'success', enumTypes.enum, '✅'), |
| 746 | ], | 746 | ], |
| 747 | }), | 747 | }), |
| 748 | ], | 748 | ], |
| 749 | unnamedArgumentList: [ | 749 | unnamedArgumentList: [ |
| 750 | new SlashCommandArgument( | 750 | new SlashCommandArgument( |
| 751 | 'text', [ARGUMENT_TYPE.STRING], true, | 751 | 'text', [ARGUMENT_TYPE.STRING], true, |
| 752 | ), | 752 | ), |
| 753 | ], | 753 | ], |
| 754 | helpString: ` | 754 | helpString: ` |
| 755 | <div> | 755 | <div> |
| 756 | Echoes the provided text to a toast message. Useful for pipes debugging. | 756 | Echoes the provided text to a toast message. Useful for pipes debugging. |
| 757 | </div> | 757 | </div> |
| @@ -764,42 +764,42 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 764 | </ul> | 764 | </ul> |
| 765 | </div> | 765 | </div> |
| 766 | `, | 766 | `, |
| 767 | })); | 767 | })); |
| 768 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 768 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 769 | name: 'gen', | 769 | name: 'gen', |
| 770 | callback: generateCallback, | 770 | callback: generateCallback, |
| 771 | returns: 'generated text', | 771 | returns: 'generated text', |
| 772 | namedArgumentList: [ | 772 | namedArgumentList: [ |
| 773 | new SlashCommandNamedArgument( | 773 | new SlashCommandNamedArgument( |
| 774 | 'lock', 'lock user input during generation', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(), | 774 | 'lock', 'lock user input during generation', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(), |
| 775 | ), | 775 | ), |
| 776 | SlashCommandNamedArgument.fromProps({ | 776 | SlashCommandNamedArgument.fromProps({ |
| 777 | name: 'name', | 777 | name: 'name', |
| 778 | description: 'in-prompt name for instruct mode', | 778 | description: 'in-prompt name for instruct mode', |
| 779 | typeList: [ARGUMENT_TYPE.STRING], | 779 | typeList: [ARGUMENT_TYPE.STRING], |
| 780 | defaultValue: 'System', | 780 | defaultValue: 'System', |
| 781 | enumProvider: () => [...commonEnumProviders.characters('character')(), new SlashCommandEnumValue('System', null, enumTypes.enum, enumIcons.assistant)], | 781 | enumProvider: () => [...commonEnumProviders.characters('character')(), new SlashCommandEnumValue('System', null, enumTypes.enum, enumIcons.assistant)], |
| 782 | forceEnum: false, | 782 | forceEnum: false, |
| 783 | }), | 783 | }), |
| 784 | new SlashCommandNamedArgument( | 784 | new SlashCommandNamedArgument( |
| 785 | 'length', 'API response length in tokens', [ARGUMENT_TYPE.NUMBER], false, | 785 | 'length', 'API response length in tokens', [ARGUMENT_TYPE.NUMBER], false, |
| 786 | ), | 786 | ), |
| 787 | SlashCommandNamedArgument.fromProps({ | 787 | SlashCommandNamedArgument.fromProps({ |
| 788 | name: 'as', | 788 | name: 'as', |
| 789 | description: 'role of the output prompt', | 789 | description: 'role of the output prompt', |
| 790 | typeList: [ARGUMENT_TYPE.STRING], | 790 | typeList: [ARGUMENT_TYPE.STRING], |
| 791 | enumList: [ | 791 | enumList: [ |
| 792 | new SlashCommandEnumValue('system', null, enumTypes.enum, enumIcons.assistant), | 792 | new SlashCommandEnumValue('system', null, enumTypes.enum, enumIcons.assistant), |
| 793 | new SlashCommandEnumValue('char', null, enumTypes.enum, enumIcons.character), | 793 | new SlashCommandEnumValue('char', null, enumTypes.enum, enumIcons.character), |
| 794 | ], | 794 | ], |
| 795 | }), | 795 | }), |
| 796 | ], | 796 | ], |
| 797 | unnamedArgumentList: [ | 797 | unnamedArgumentList: [ |
| 798 | new SlashCommandArgument( | 798 | new SlashCommandArgument( |
| 799 | 'prompt', [ARGUMENT_TYPE.STRING], true, | 799 | 'prompt', [ARGUMENT_TYPE.STRING], true, |
| 800 | ), | 800 | ), |
| 801 | ], | 801 | ], |
| 802 | helpString: ` | 802 | helpString: ` |
| 803 | <div> | 803 | <div> |
| 804 | Generates text using the provided prompt and passes it to the next command through the pipe, optionally locking user input while generating and allowing to configure the in-prompt name for instruct mode (default = "System"). | 804 | Generates text using the provided prompt and passes it to the next command through the pipe, optionally locking user input while generating and allowing to configure the in-prompt name for instruct mode (default = "System"). |
| 805 | </div> | 805 | </div> |
| @@ -807,43 +807,43 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 807 | "as" argument controls the role of the output prompt: system (default) or char. If "length" argument is provided as a number in tokens, allows to temporarily override an API response length. | 807 | "as" argument controls the role of the output prompt: system (default) or char. If "length" argument is provided as a number in tokens, allows to temporarily override an API response length. |
| 808 | </div> | 808 | </div> |
| 809 | `, | 809 | `, |
| 810 | })); | 810 | })); |
| 811 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 811 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 812 | name: 'genraw', | 812 | name: 'genraw', |
| 813 | callback: generateRawCallback, | 813 | callback: generateRawCallback, |
| 814 | returns: 'generated text', | 814 | returns: 'generated text', |
| 815 | namedArgumentList: [ | 815 | namedArgumentList: [ |
| 816 | new SlashCommandNamedArgument( | 816 | new SlashCommandNamedArgument( |
| 817 | 'lock', 'lock user input during generation', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(), | 817 | 'lock', 'lock user input during generation', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(), |
| 818 | ), | 818 | ), |
| 819 | new SlashCommandNamedArgument( | 819 | new SlashCommandNamedArgument( |
| 820 | 'instruct', 'use instruct mode', [ARGUMENT_TYPE.BOOLEAN], false, false, 'on', commonEnumProviders.boolean('onOff')(), | 820 | 'instruct', 'use instruct mode', [ARGUMENT_TYPE.BOOLEAN], false, false, 'on', commonEnumProviders.boolean('onOff')(), |
| 821 | ), | 821 | ), |
| 822 | new SlashCommandNamedArgument( | 822 | new SlashCommandNamedArgument( |
| 823 | 'stop', 'one-time custom stop strings', [ARGUMENT_TYPE.LIST], false, | 823 | 'stop', 'one-time custom stop strings', [ARGUMENT_TYPE.LIST], false, |
| 824 | ), | 824 | ), |
| 825 | SlashCommandNamedArgument.fromProps({ | 825 | SlashCommandNamedArgument.fromProps({ |
| 826 | name: 'as', | 826 | name: 'as', |
| 827 | description: 'role of the output prompt', | 827 | description: 'role of the output prompt', |
| 828 | typeList: [ARGUMENT_TYPE.STRING], | 828 | typeList: [ARGUMENT_TYPE.STRING], |
| 829 | enumList: [ | 829 | enumList: [ |
| 830 | new SlashCommandEnumValue('system', null, enumTypes.enum, enumIcons.assistant), | 830 | new SlashCommandEnumValue('system', null, enumTypes.enum, enumIcons.assistant), |
| 831 | new SlashCommandEnumValue('char', null, enumTypes.enum, enumIcons.character), | 831 | new SlashCommandEnumValue('char', null, enumTypes.enum, enumIcons.character), |
| 832 | ], | 832 | ], |
| 833 | }), | 833 | }), |
| 834 | new SlashCommandNamedArgument( | 834 | new SlashCommandNamedArgument( |
| 835 | 'system', 'system prompt at the start', [ARGUMENT_TYPE.STRING], false, | 835 | 'system', 'system prompt at the start', [ARGUMENT_TYPE.STRING], false, |
| 836 | ), | 836 | ), |
| 837 | new SlashCommandNamedArgument( | 837 | new SlashCommandNamedArgument( |
| 838 | 'length', 'API response length in tokens', [ARGUMENT_TYPE.NUMBER], false, | 838 | 'length', 'API response length in tokens', [ARGUMENT_TYPE.NUMBER], false, |
| 839 | ), | 839 | ), |
| 840 | ], | 840 | ], |
| 841 | unnamedArgumentList: [ | 841 | unnamedArgumentList: [ |
| 842 | new SlashCommandArgument( | 842 | new SlashCommandArgument( |
| 843 | 'prompt', [ARGUMENT_TYPE.STRING], true, | 843 | 'prompt', [ARGUMENT_TYPE.STRING], true, |
| 844 | ), | 844 | ), |
| 845 | ], | 845 | ], |
| 846 | helpString: ` | 846 | helpString: ` |
| 847 | <div> | 847 | <div> |
| 848 | Generates text using the provided prompt and passes it to the next command through the pipe, optionally locking user input while generating. Does not include chat history or character card. | 848 | Generates text using the provided prompt and passes it to the next command through the pipe, optionally locking user input while generating. Does not include chat history or character card. |
| 849 | </div> | 849 | </div> |
| @@ -860,55 +860,55 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 860 | If "length" argument is provided as a number in tokens, allows to temporarily override an API response length. | 860 | If "length" argument is provided as a number in tokens, allows to temporarily override an API response length. |
| 861 | </div> | 861 | </div> |
| 862 | `, | 862 | `, |
| 863 | })); | 863 | })); |
| 864 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 864 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 865 | name: 'addswipe', | 865 | name: 'addswipe', |
| 866 | callback: addSwipeCallback, | 866 | callback: addSwipeCallback, |
| 867 | aliases: ['swipeadd'], | 867 | aliases: ['swipeadd'], |
| 868 | unnamedArgumentList: [ | 868 | unnamedArgumentList: [ |
| 869 | new SlashCommandArgument( | 869 | new SlashCommandArgument( |
| 870 | 'text', [ARGUMENT_TYPE.STRING], true, | 870 | 'text', [ARGUMENT_TYPE.STRING], true, |
| 871 | ), | 871 | ), |
| 872 | ], | 872 | ], |
| 873 | helpString: 'Adds a swipe to the last chat message.', | 873 | helpString: 'Adds a swipe to the last chat message.', |
| 874 | })); | 874 | })); |
| 875 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 875 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 876 | name: 'abort', | 876 | name: 'abort', |
| 877 | callback: abortCallback, | 877 | callback: abortCallback, |
| 878 | namedArgumentList: [ | 878 | namedArgumentList: [ |
| 879 | SlashCommandNamedArgument.fromProps({ | 879 | SlashCommandNamedArgument.fromProps({ |
| 880 | name: 'quiet', | 880 | name: 'quiet', |
| 881 | description: 'Whether to suppress the toast message notifying about the /abort call.', | 881 | description: 'Whether to suppress the toast message notifying about the /abort call.', |
| 882 | typeList: [ARGUMENT_TYPE.BOOLEAN], | 882 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 883 | defaultValue: 'true', | 883 | defaultValue: 'true', |
| 884 | }), | 884 | }), |
| 885 | ], | 885 | ], |
| 886 | unnamedArgumentList: [ | 886 | unnamedArgumentList: [ |
| 887 | SlashCommandArgument.fromProps({ | 887 | SlashCommandArgument.fromProps({ |
| 888 | description: 'The reason for aborting command execution. Shown when quiet=false', | 888 | description: 'The reason for aborting command execution. Shown when quiet=false', |
| 889 | typeList: [ARGUMENT_TYPE.STRING], | 889 | typeList: [ARGUMENT_TYPE.STRING], |
| 890 | }), | 890 | }), |
| 891 | ], | 891 | ], |
| 892 | helpString: 'Aborts the slash command batch execution.', | 892 | helpString: 'Aborts the slash command batch execution.', |
| 893 | })); | 893 | })); |
| 894 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 894 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 895 | name: 'fuzzy', | 895 | name: 'fuzzy', |
| 896 | callback: fuzzyCallback, | 896 | callback: fuzzyCallback, |
| 897 | returns: 'first matching item', | 897 | returns: 'first matching item', |
| 898 | namedArgumentList: [ | 898 | namedArgumentList: [ |
| 899 | new SlashCommandNamedArgument( | 899 | new SlashCommandNamedArgument( |
| 900 | 'list', 'list of items to match against', [ARGUMENT_TYPE.LIST], true, | 900 | 'list', 'list of items to match against', [ARGUMENT_TYPE.LIST], true, |
| 901 | ), | 901 | ), |
| 902 | new SlashCommandNamedArgument( | 902 | new SlashCommandNamedArgument( |
| 903 | 'threshold', 'fuzzy match threshold (0.0 to 1.0)', [ARGUMENT_TYPE.NUMBER], false, false, '0.4', | 903 | 'threshold', 'fuzzy match threshold (0.0 to 1.0)', [ARGUMENT_TYPE.NUMBER], false, false, '0.4', |
| 904 | ), | 904 | ), |
| 905 | ], | 905 | ], |
| 906 | unnamedArgumentList: [ | 906 | unnamedArgumentList: [ |
| 907 | new SlashCommandArgument( | 907 | new SlashCommandArgument( |
| 908 | 'text to search', [ARGUMENT_TYPE.STRING], true, | 908 | 'text to search', [ARGUMENT_TYPE.STRING], true, |
| 909 | ), | 909 | ), |
| 910 | ], | 910 | ], |
| 911 | helpString: ` | 911 | helpString: ` |
| 912 | <div> | 912 | <div> |
| 913 | Performs a fuzzy match of each item in the <code>list</code> against the <code>text to search</code>. | 913 | Performs a fuzzy match of each item in the <code>list</code> against the <code>text to search</code>. |
| 914 | If any item matches, then its name is returned. If no item matches the text, no value is returned. | 914 | If any item matches, then its name is returned. If no item matches the text, no value is returned. |
| @@ -930,23 +930,23 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 930 | </ul> | 930 | </ul> |
| 931 | </div> | 931 | </div> |
| 932 | `, | 932 | `, |
| 933 | })); | 933 | })); |
| 934 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 934 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 935 | name: 'pass', | 935 | name: 'pass', |
| 936 | callback: (_, arg) => { | 936 | callback: (_, arg) => { |
| 937 | // We do not support arrays of closures. Arrays of strings will be send as JSON | 937 | // We do not support arrays of closures. Arrays of strings will be send as JSON |
| 938 | if (Array.isArray(arg) && arg.some(x => x instanceof SlashCommandClosure)) throw new Error('Command /pass does not support multiple closures'); | 938 | if (Array.isArray(arg) && arg.some(x => x instanceof SlashCommandClosure)) throw new Error('Command /pass does not support multiple closures'); |
| 939 | if (Array.isArray(arg)) return JSON.stringify(arg); | 939 | if (Array.isArray(arg)) return JSON.stringify(arg); |
| 940 | return arg; | 940 | return arg; |
| 941 | }, | 941 | }, |
| 942 | returns: 'the provided value', | 942 | returns: 'the provided value', |
| 943 | unnamedArgumentList: [ | 943 | unnamedArgumentList: [ |
| 944 | new SlashCommandArgument( | 944 | new SlashCommandArgument( |
| 945 | 'text', [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.BOOLEAN, ARGUMENT_TYPE.LIST, ARGUMENT_TYPE.DICTIONARY, ARGUMENT_TYPE.CLOSURE], true, | 945 | 'text', [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.BOOLEAN, ARGUMENT_TYPE.LIST, ARGUMENT_TYPE.DICTIONARY, ARGUMENT_TYPE.CLOSURE], true, |
| 946 | ), | 946 | ), |
| 947 | ], | 947 | ], |
| 948 | aliases: ['return'], | 948 | aliases: ['return'], |
| 949 | helpString: ` | 949 | helpString: ` |
| 950 | <div> | 950 | <div> |
| 951 | <pre><span class="monospace">/pass (text)</span> – passes the text to the next command through the pipe.</pre> | 951 | <pre><span class="monospace">/pass (text)</span> – passes the text to the next command through the pipe.</pre> |
| 952 | </div> | 952 | </div> |
| @@ -957,17 +957,17 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 957 | </ul> | 957 | </ul> |
| 958 | </div> | 958 | </div> |
| 959 | `, | 959 | `, |
| 960 | })); | 960 | })); |
| 961 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 961 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 962 | name: 'delay', | 962 | name: 'delay', |
| 963 | callback: delayCallback, | 963 | callback: delayCallback, |
| 964 | aliases: ['wait', 'sleep'], | 964 | aliases: ['wait', 'sleep'], |
| 965 | unnamedArgumentList: [ | 965 | unnamedArgumentList: [ |
| 966 | new SlashCommandArgument( | 966 | new SlashCommandArgument( |
| 967 | 'milliseconds', [ARGUMENT_TYPE.NUMBER], true, | 967 | 'milliseconds', [ARGUMENT_TYPE.NUMBER], true, |
| 968 | ), | 968 | ), |
| 969 | ], | 969 | ], |
| 970 | helpString: ` | 970 | helpString: ` |
| 971 | <div> | 971 | <div> |
| 972 | Delays the next command in the pipe by the specified number of milliseconds. | 972 | Delays the next command in the pipe by the specified number of milliseconds. |
| 973 | </div> | 973 | </div> |
| @@ -980,101 +980,101 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 980 | </ul> | 980 | </ul> |
| 981 | </div> | 981 | </div> |
| 982 | `, | 982 | `, |
| 983 | })); | 983 | })); |
| 984 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 984 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 985 | name: 'input', | 985 | name: 'input', |
| 986 | aliases: ['prompt'], | 986 | aliases: ['prompt'], |
| 987 | callback: inputCallback, | 987 | callback: inputCallback, |
| 988 | returns: 'user input', | 988 | returns: 'user input', |
| 989 | namedArgumentList: [ | 989 | namedArgumentList: [ |
| 990 | new SlashCommandNamedArgument( | 990 | new SlashCommandNamedArgument( |
| 991 | 'default', 'default value of the input field', [ARGUMENT_TYPE.STRING], false, false, '"string"', | 991 | 'default', 'default value of the input field', [ARGUMENT_TYPE.STRING], false, false, '"string"', |
| 992 | ), | 992 | ), |
| 993 | new SlashCommandNamedArgument( | 993 | new SlashCommandNamedArgument( |
| 994 | 'large', 'show large input field', [ARGUMENT_TYPE.BOOLEAN], false, false, 'off', commonEnumProviders.boolean('onOff')(), | 994 | 'large', 'show large input field', [ARGUMENT_TYPE.BOOLEAN], false, false, 'off', commonEnumProviders.boolean('onOff')(), |
| 995 | ), | 995 | ), |
| 996 | new SlashCommandNamedArgument( | 996 | new SlashCommandNamedArgument( |
| 997 | 'wide', 'show wide input field', [ARGUMENT_TYPE.BOOLEAN], false, false, 'off', commonEnumProviders.boolean('onOff')(), | 997 | 'wide', 'show wide input field', [ARGUMENT_TYPE.BOOLEAN], false, false, 'off', commonEnumProviders.boolean('onOff')(), |
| 998 | ), | 998 | ), |
| 999 | new SlashCommandNamedArgument( | 999 | new SlashCommandNamedArgument( |
| 1000 | 'okButton', 'text for the ok button', [ARGUMENT_TYPE.STRING], false, | 1000 | 'okButton', 'text for the ok button', [ARGUMENT_TYPE.STRING], false, |
| 1001 | ), | 1001 | ), |
| 1002 | new SlashCommandNamedArgument( | 1002 | new SlashCommandNamedArgument( |
| 1003 | 'rows', 'number of rows for the input field', [ARGUMENT_TYPE.NUMBER], false, | 1003 | 'rows', 'number of rows for the input field', [ARGUMENT_TYPE.NUMBER], false, |
| 1004 | ), | 1004 | ), |
| 1005 | ], | 1005 | ], |
| 1006 | unnamedArgumentList: [ | 1006 | unnamedArgumentList: [ |
| 1007 | new SlashCommandArgument( | 1007 | new SlashCommandArgument( |
| 1008 | 'text to display', [ARGUMENT_TYPE.STRING], false, | 1008 | 'text to display', [ARGUMENT_TYPE.STRING], false, |
| 1009 | ), | 1009 | ), |
| 1010 | ], | 1010 | ], |
| 1011 | helpString: ` | 1011 | helpString: ` |
| 1012 | <div> | 1012 | <div> |
| 1013 | Shows a popup with the provided text and an input field. | 1013 | Shows a popup with the provided text and an input field. |
| 1014 | The <code>default</code> argument is the default value of the input field, and the text argument is the text to display. | 1014 | The <code>default</code> argument is the default value of the input field, and the text argument is the text to display. |
| 1015 | </div> | 1015 | </div> |
| 1016 | `, | 1016 | `, |
| 1017 | })); | 1017 | })); |
| 1018 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 1018 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1019 | name: 'run', | 1019 | name: 'run', |
| 1020 | aliases: ['call', 'exec'], | 1020 | aliases: ['call', 'exec'], |
| 1021 | callback: runCallback, | 1021 | callback: runCallback, |
| 1022 | returns: 'result of the executed closure of QR', | 1022 | returns: 'result of the executed closure of QR', |
| 1023 | namedArgumentList: [ | 1023 | namedArgumentList: [ |
| 1024 | new SlashCommandNamedArgument( | 1024 | new SlashCommandNamedArgument( |
| 1025 | 'args', 'named arguments', [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.BOOLEAN, ARGUMENT_TYPE.LIST, ARGUMENT_TYPE.DICTIONARY], false, true, | 1025 | 'args', 'named arguments', [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.BOOLEAN, ARGUMENT_TYPE.LIST, ARGUMENT_TYPE.DICTIONARY], false, true, |
| 1026 | ), | 1026 | ), |
| 1027 | ], | 1027 | ], |
| 1028 | unnamedArgumentList: [ | 1028 | unnamedArgumentList: [ |
| 1029 | SlashCommandArgument.fromProps({ | 1029 | SlashCommandArgument.fromProps({ |
| 1030 | description: 'scoped variable or qr label', | 1030 | description: 'scoped variable or qr label', |
| 1031 | typeList: [ARGUMENT_TYPE.VARIABLE_NAME, ARGUMENT_TYPE.STRING], | 1031 | typeList: [ARGUMENT_TYPE.VARIABLE_NAME, ARGUMENT_TYPE.STRING], |
| 1032 | isRequired: true, | 1032 | isRequired: true, |
| 1033 | enumProvider: () => [ | 1033 | enumProvider: () => [ |
| 1034 | ...commonEnumProviders.variables('scope')(), | 1034 | ...commonEnumProviders.variables('scope')(), |
| 1035 | ...(typeof window['qrEnumProviderExecutables'] === 'function') ? window['qrEnumProviderExecutables']() : [], | 1035 | ...(typeof window['qrEnumProviderExecutables'] === 'function') ? window['qrEnumProviderExecutables']() : [], |
| 1036 | ], | 1036 | ], |
| 1037 | }), | 1037 | }), |
| 1038 | ], | 1038 | ], |
| 1039 | helpString: ` | 1039 | helpString: ` |
| 1040 | <div> | 1040 | <div> |
| 1041 | Runs a closure from a scoped variable, or a Quick Reply with the specified name from a currently active preset or from another preset. | 1041 | Runs a closure from a scoped variable, or a Quick Reply with the specified name from a currently active preset or from another preset. |
| 1042 | Named arguments can be referenced in a QR with <code>{{arg::key}}</code>. | 1042 | Named arguments can be referenced in a QR with <code>{{arg::key}}</code>. |
| 1043 | </div> | 1043 | </div> |
| 1044 | `, | 1044 | `, |
| 1045 | })); | 1045 | })); |
| 1046 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 1046 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1047 | name: 'messages', | 1047 | name: 'messages', |
| 1048 | callback: getMessagesCallback, | 1048 | callback: getMessagesCallback, |
| 1049 | aliases: ['message'], | 1049 | aliases: ['message'], |
| 1050 | namedArgumentList: [ | 1050 | namedArgumentList: [ |
| 1051 | new SlashCommandNamedArgument( | 1051 | new SlashCommandNamedArgument( |
| 1052 | 'names', 'show message author names', [ARGUMENT_TYPE.BOOLEAN], false, false, 'off', commonEnumProviders.boolean('onOff')(), | 1052 | 'names', 'show message author names', [ARGUMENT_TYPE.BOOLEAN], false, false, 'off', commonEnumProviders.boolean('onOff')(), |
| 1053 | ), | 1053 | ), |
| 1054 | new SlashCommandNamedArgument( | 1054 | new SlashCommandNamedArgument( |
| 1055 | 'hidden', 'include hidden messages', [ARGUMENT_TYPE.BOOLEAN], false, false, 'on', commonEnumProviders.boolean('onOff')(), | 1055 | 'hidden', 'include hidden messages', [ARGUMENT_TYPE.BOOLEAN], false, false, 'on', commonEnumProviders.boolean('onOff')(), |
| 1056 | ), | 1056 | ), |
| 1057 | SlashCommandNamedArgument.fromProps({ | 1057 | SlashCommandNamedArgument.fromProps({ |
| 1058 | name: 'role', | 1058 | name: 'role', |
| 1059 | description: 'filter messages by role', | 1059 | description: 'filter messages by role', |
| 1060 | typeList: [ARGUMENT_TYPE.STRING], | 1060 | typeList: [ARGUMENT_TYPE.STRING], |
| 1061 | enumList: [ | 1061 | enumList: [ |
| 1062 | new SlashCommandEnumValue('system', null, enumTypes.enum, enumIcons.system), | 1062 | new SlashCommandEnumValue('system', null, enumTypes.enum, enumIcons.system), |
| 1063 | new SlashCommandEnumValue('assistant', null, enumTypes.enum, enumIcons.assistant), | 1063 | new SlashCommandEnumValue('assistant', null, enumTypes.enum, enumIcons.assistant), |
| 1064 | new SlashCommandEnumValue('user', null, enumTypes.enum, enumIcons.user), | 1064 | new SlashCommandEnumValue('user', null, enumTypes.enum, enumIcons.user), |
| 1065 | ], | 1065 | ], |
| 1066 | }), | 1066 | }), |
| 1067 | ], | 1067 | ], |
| 1068 | unnamedArgumentList: [ | 1068 | unnamedArgumentList: [ |
| 1069 | SlashCommandArgument.fromProps({ | 1069 | SlashCommandArgument.fromProps({ |
| 1070 | description: 'message index (starts with 0) or range', | 1070 | description: 'message index (starts with 0) or range', |
| 1071 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.RANGE], | 1071 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.RANGE], |
| 1072 | isRequired: true, | 1072 | isRequired: true, |
| 1073 | enumProvider: commonEnumProviders.messages(), | 1073 | enumProvider: commonEnumProviders.messages(), |
| 1074 | }), | 1074 | }), |
| 1075 | ], | 1075 | ], |
| 1076 | returns: 'the specified message or range of messages as a string', | 1076 | returns: 'the specified message or range of messages as a string', |
| 1077 | helpString: ` | 1077 | helpString: ` |
| 1078 | <div> | 1078 | <div> |
| 1079 | Returns the specified message or range of messages as a string. | 1079 | Returns the specified message or range of messages as a string. |
| 1080 | </div> | 1080 | </div> |
| @@ -1098,16 +1098,16 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 1098 | </ul> | 1098 | </ul> |
| 1099 | </div> | 1099 | </div> |
| 1100 | `, | 1100 | `, |
| 1101 | })); | 1101 | })); |
| 1102 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 1102 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1103 | name: 'setinput', | 1103 | name: 'setinput', |
| 1104 | callback: setInputCallback, | 1104 | callback: setInputCallback, |
| 1105 | unnamedArgumentList: [ | 1105 | unnamedArgumentList: [ |
| 1106 | new SlashCommandArgument( | 1106 | new SlashCommandArgument( |
| 1107 | 'text', [ARGUMENT_TYPE.STRING], true, | 1107 | 'text', [ARGUMENT_TYPE.STRING], true, |
| 1108 | ), | 1108 | ), |
| 1109 | ], | 1109 | ], |
| 1110 | helpString: ` | 1110 | helpString: ` |
| 1111 | <div> | 1111 | <div> |
| 1112 | Sets the user input to the specified text and passes it to the next command through the pipe. | 1112 | Sets the user input to the specified text and passes it to the next command through the pipe. |
| 1113 | </div> | 1113 | </div> |
| @@ -1120,28 +1120,28 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 1120 | </ul> | 1120 | </ul> |
| 1121 | </div> | 1121 | </div> |
| 1122 | `, | 1122 | `, |
| 1123 | })); | 1123 | })); |
| 1124 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 1124 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1125 | name: 'popup', | 1125 | name: 'popup', |
| 1126 | callback: popupCallback, | 1126 | callback: popupCallback, |
| 1127 | returns: 'popup text', | 1127 | returns: 'popup text', |
| 1128 | namedArgumentList: [ | 1128 | namedArgumentList: [ |
| 1129 | new SlashCommandNamedArgument( | 1129 | new SlashCommandNamedArgument( |
| 1130 | 'large', 'show large popup', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(), | 1130 | 'large', 'show large popup', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(), |
| 1131 | ), | 1131 | ), |
| 1132 | new SlashCommandNamedArgument( | 1132 | new SlashCommandNamedArgument( |
| 1133 | 'wide', 'show wide popup', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(), | 1133 | 'wide', 'show wide popup', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(), |
| 1134 | ), | 1134 | ), |
| 1135 | new SlashCommandNamedArgument( | 1135 | new SlashCommandNamedArgument( |
| 1136 | 'okButton', 'text for the OK button', [ARGUMENT_TYPE.STRING], false, | 1136 | 'okButton', 'text for the OK button', [ARGUMENT_TYPE.STRING], false, |
| 1137 | ), | 1137 | ), |
| 1138 | ], | 1138 | ], |
| 1139 | unnamedArgumentList: [ | 1139 | unnamedArgumentList: [ |
| 1140 | new SlashCommandArgument( | 1140 | new SlashCommandArgument( |
| 1141 | 'text', [ARGUMENT_TYPE.STRING], true, | 1141 | 'text', [ARGUMENT_TYPE.STRING], true, |
| 1142 | ), | 1142 | ), |
| 1143 | ], | 1143 | ], |
| 1144 | helpString: ` | 1144 | helpString: ` |
| 1145 | <div> | 1145 | <div> |
| 1146 | Shows a blocking popup with the specified text and buttons. | 1146 | Shows a blocking popup with the specified text and buttons. |
| 1147 | Returns the popup text. | 1147 | Returns the popup text. |
| @@ -1155,22 +1155,22 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 1155 | </ul> | 1155 | </ul> |
| 1156 | </div> | 1156 | </div> |
| 1157 | `, | 1157 | `, |
| 1158 | })); | 1158 | })); |
| 1159 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 1159 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1160 | name: 'buttons', | 1160 | name: 'buttons', |
| 1161 | callback: buttonsCallback, | 1161 | callback: buttonsCallback, |
| 1162 | returns: 'clicked button label', | 1162 | returns: 'clicked button label', |
| 1163 | namedArgumentList: [ | 1163 | namedArgumentList: [ |
| 1164 | new SlashCommandNamedArgument( | 1164 | new SlashCommandNamedArgument( |
| 1165 | 'labels', 'button labels', [ARGUMENT_TYPE.LIST], true, | 1165 | 'labels', 'button labels', [ARGUMENT_TYPE.LIST], true, |
| 1166 | ), | 1166 | ), |
| 1167 | ], | 1167 | ], |
| 1168 | unnamedArgumentList: [ | 1168 | unnamedArgumentList: [ |
| 1169 | new SlashCommandArgument( | 1169 | new SlashCommandArgument( |
| 1170 | 'text', [ARGUMENT_TYPE.STRING], true, | 1170 | 'text', [ARGUMENT_TYPE.STRING], true, |
| 1171 | ), | 1171 | ), |
| 1172 | ], | 1172 | ], |
| 1173 | helpString: ` | 1173 | helpString: ` |
| 1174 | <div> | 1174 | <div> |
| 1175 | Shows a blocking popup with the specified text and buttons. | 1175 | Shows a blocking popup with the specified text and buttons. |
| 1176 | Returns the clicked button label into the pipe or empty string if canceled. | 1176 | Returns the clicked button label into the pipe or empty string if canceled. |
| @@ -1184,32 +1184,32 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 1184 | </ul> | 1184 | </ul> |
| 1185 | </div> | 1185 | </div> |
| 1186 | `, | 1186 | `, |
| 1187 | })); | 1187 | })); |
| 1188 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 1188 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1189 | name: 'trimtokens', | 1189 | name: 'trimtokens', |
| 1190 | callback: trimTokensCallback, | 1190 | callback: trimTokensCallback, |
| 1191 | returns: 'trimmed text', | 1191 | returns: 'trimmed text', |
| 1192 | namedArgumentList: [ | 1192 | namedArgumentList: [ |
| 1193 | new SlashCommandNamedArgument( | 1193 | new SlashCommandNamedArgument( |
| 1194 | 'limit', 'number of tokens to keep', [ARGUMENT_TYPE.NUMBER], true, | 1194 | 'limit', 'number of tokens to keep', [ARGUMENT_TYPE.NUMBER], true, |
| 1195 | ), | 1195 | ), |
| 1196 | SlashCommandNamedArgument.fromProps({ | 1196 | SlashCommandNamedArgument.fromProps({ |
| 1197 | name: 'direction', | 1197 | name: 'direction', |
| 1198 | description: 'trim direction', | 1198 | description: 'trim direction', |
| 1199 | typeList: [ARGUMENT_TYPE.STRING], | 1199 | typeList: [ARGUMENT_TYPE.STRING], |
| 1200 | isRequired: true, | 1200 | isRequired: true, |
| 1201 | enumList: [ | 1201 | enumList: [ |
| 1202 | new SlashCommandEnumValue('start', null, enumTypes.enum, '⏪'), | 1202 | new SlashCommandEnumValue('start', null, enumTypes.enum, '⏪'), |
| 1203 | new SlashCommandEnumValue('end', null, enumTypes.enum, '⏩'), | 1203 | new SlashCommandEnumValue('end', null, enumTypes.enum, '⏩'), |
| 1204 | ], | 1204 | ], |
| 1205 | }), | 1205 | }), |
| 1206 | ], | 1206 | ], |
| 1207 | unnamedArgumentList: [ | 1207 | unnamedArgumentList: [ |
| 1208 | new SlashCommandArgument( | 1208 | new SlashCommandArgument( |
| 1209 | 'text', [ARGUMENT_TYPE.STRING], false, | 1209 | 'text', [ARGUMENT_TYPE.STRING], false, |
| 1210 | ), | 1210 | ), |
| 1211 | ], | 1211 | ], |
| 1212 | helpString: ` | 1212 | helpString: ` |
| 1213 | <div> | 1213 | <div> |
| 1214 | Trims the start or end of text to the specified number of tokens. | 1214 | Trims the start or end of text to the specified number of tokens. |
| 1215 | </div> | 1215 | </div> |
| @@ -1222,17 +1222,17 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 1222 | </ul> | 1222 | </ul> |
| 1223 | </div> | 1223 | </div> |
| 1224 | `, | 1224 | `, |
| 1225 | })); | 1225 | })); |
| 1226 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 1226 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1227 | name: 'trimstart', | 1227 | name: 'trimstart', |
| 1228 | callback: trimStartCallback, | 1228 | callback: trimStartCallback, |
| 1229 | returns: 'trimmed text', | 1229 | returns: 'trimmed text', |
| 1230 | unnamedArgumentList: [ | 1230 | unnamedArgumentList: [ |
| 1231 | new SlashCommandArgument( | 1231 | new SlashCommandArgument( |
| 1232 | 'text', [ARGUMENT_TYPE.STRING], true, | 1232 | 'text', [ARGUMENT_TYPE.STRING], true, |
| 1233 | ), | 1233 | ), |
| 1234 | ], | 1234 | ], |
| 1235 | helpString: ` | 1235 | helpString: ` |
| 1236 | <div> | 1236 | <div> |
| 1237 | Trims the text to the start of the first full sentence. | 1237 | Trims the text to the start of the first full sentence. |
| 1238 | </div> | 1238 | </div> |
| @@ -1245,148 +1245,149 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | |||
| 1245 | </ul> | 1245 | </ul> |
| 1246 | </div> | 1246 | </div> |
| 1247 | `, | 1247 | `, |
| 1248 | })); | 1248 | })); |
| 1249 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 1249 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1250 | name: 'trimend', | 1250 | name: 'trimend', |
| 1251 | callback: trimEndCallback, | 1251 | callback: trimEndCallback, |
| 1252 | returns: 'trimmed text', | 1252 | returns: 'trimmed text', |
| 1253 | unnamedArgumentList: [ | 1253 | unnamedArgumentList: [ |
| 1254 | new SlashCommandArgument( | 1254 | new SlashCommandArgument( |
| 1255 | 'text', [ARGUMENT_TYPE.STRING], true, | 1255 | 'text', [ARGUMENT_TYPE.STRING], true, |
| 1256 | ), | 1256 | ), |
| 1257 | ], | 1257 | ], |
| 1258 | helpString: 'Trims the text to the end of the last full sentence.', | 1258 | helpString: 'Trims the text to the end of the last full sentence.', |
| 1259 | })); | 1259 | })); |
| 1260 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 1260 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1261 | name: 'inject', | 1261 | name: 'inject', |
| 1262 | callback: injectCallback, | 1262 | callback: injectCallback, |
| 1263 | namedArgumentList: [ | 1263 | namedArgumentList: [ |
| 1264 | SlashCommandNamedArgument.fromProps({ | 1264 | SlashCommandNamedArgument.fromProps({ |
| 1265 | name: 'id', | 1265 | name: 'id', |
| 1266 | description: 'injection ID or variable name pointing to ID', | 1266 | description: 'injection ID or variable name pointing to ID', |
| 1267 | typeList: [ARGUMENT_TYPE.STRING], | 1267 | typeList: [ARGUMENT_TYPE.STRING], |
| 1268 | isRequired: true, | 1268 | isRequired: true, |
| 1269 | enumProvider: commonEnumProviders.injects, | 1269 | enumProvider: commonEnumProviders.injects, |
| 1270 | }), | 1270 | }), |
| 1271 | new SlashCommandNamedArgument( | 1271 | new SlashCommandNamedArgument( |
| 1272 | 'position', 'injection position', [ARGUMENT_TYPE.STRING], false, false, 'after', ['before', 'after', 'chat'], | 1272 | 'position', 'injection position', [ARGUMENT_TYPE.STRING], false, false, 'after', ['before', 'after', 'chat'], |
| 1273 | ), | 1273 | ), |
| 1274 | new SlashCommandNamedArgument( | 1274 | new SlashCommandNamedArgument( |
| 1275 | 'depth', 'injection depth', [ARGUMENT_TYPE.NUMBER], false, false, '4', | 1275 | 'depth', 'injection depth', [ARGUMENT_TYPE.NUMBER], false, false, '4', |
| 1276 | ), | 1276 | ), |
| 1277 | new SlashCommandNamedArgument( | 1277 | new SlashCommandNamedArgument( |
| 1278 | 'scan', 'include injection content into World Info scans', [ARGUMENT_TYPE.BOOLEAN], false, false, 'false', | 1278 | 'scan', 'include injection content into World Info scans', [ARGUMENT_TYPE.BOOLEAN], false, false, 'false', |
| 1279 | ), | 1279 | ), |
| 1280 | SlashCommandNamedArgument.fromProps({ | 1280 | SlashCommandNamedArgument.fromProps({ |
| 1281 | name: 'role', | 1281 | name: 'role', |
| 1282 | description: 'role for in-chat injections', | 1282 | description: 'role for in-chat injections', |
| 1283 | typeList: [ARGUMENT_TYPE.STRING], | 1283 | typeList: [ARGUMENT_TYPE.STRING], |
| 1284 | isRequired: false, | 1284 | isRequired: false, |
| 1285 | enumList: [ | 1285 | enumList: [ |
| 1286 | new SlashCommandEnumValue('system', null, enumTypes.enum, enumIcons.system), | 1286 | new SlashCommandEnumValue('system', null, enumTypes.enum, enumIcons.system), |
| 1287 | new SlashCommandEnumValue('assistant', null, enumTypes.enum, enumIcons.assistant), | 1287 | new SlashCommandEnumValue('assistant', null, enumTypes.enum, enumIcons.assistant), |
| 1288 | new SlashCommandEnumValue('user', null, enumTypes.enum, enumIcons.user), | 1288 | new SlashCommandEnumValue('user', null, enumTypes.enum, enumIcons.user), |
| 1289 | ], | 1289 | ], |
| 1290 | }), | 1290 | }), |
| 1291 | new SlashCommandNamedArgument( | 1291 | new SlashCommandNamedArgument( |
| 1292 | 'ephemeral', 'remove injection after generation', [ARGUMENT_TYPE.BOOLEAN], false, false, 'false', | 1292 | 'ephemeral', 'remove injection after generation', [ARGUMENT_TYPE.BOOLEAN], false, false, 'false', |
| 1293 | ), | 1293 | ), |
| 1294 | ], | 1294 | ], |
| 1295 | unnamedArgumentList: [ | 1295 | unnamedArgumentList: [ |
| 1296 | new SlashCommandArgument( | 1296 | new SlashCommandArgument( |
| 1297 | 'text', [ARGUMENT_TYPE.STRING], false, | 1297 | 'text', [ARGUMENT_TYPE.STRING], false, |
| 1298 | ), | 1298 | ), |
| 1299 | ], | 1299 | ], |
| 1300 | helpString: 'Injects a text into the LLM prompt for the current chat. Requires a unique injection ID. Positions: "before" main prompt, "after" main prompt, in-"chat" (default: after). Depth: injection depth for the prompt (default: 4). Role: role for in-chat injections (default: system). Scan: include injection content into World Info scans (default: false).', | 1300 | helpString: 'Injects a text into the LLM prompt for the current chat. Requires a unique injection ID. Positions: "before" main prompt, "after" main prompt, in-"chat" (default: after). Depth: injection depth for the prompt (default: 4). Role: role for in-chat injections (default: system). Scan: include injection content into World Info scans (default: false).', |
| 1301 | })); | 1301 | })); |
| 1302 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 1302 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1303 | name: 'listinjects', | 1303 | name: 'listinjects', |
| 1304 | callback: listInjectsCallback, | 1304 | callback: listInjectsCallback, |
| 1305 | helpString: 'Lists all script injections for the current chat.', | 1305 | helpString: 'Lists all script injections for the current chat.', |
| 1306 | })); | 1306 | })); |
| 1307 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 1307 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1308 | name: 'flushinject', | 1308 | name: 'flushinject', |
| 1309 | aliases: ['flushinjects'], | 1309 | aliases: ['flushinjects'], |
| 1310 | unnamedArgumentList: [ | 1310 | unnamedArgumentList: [ |
| 1311 | SlashCommandArgument.fromProps({ | 1311 | SlashCommandArgument.fromProps({ |
| 1312 | description: 'injection ID or a variable name pointing to ID', | 1312 | description: 'injection ID or a variable name pointing to ID', |
| 1313 | typeList: [ARGUMENT_TYPE.STRING], | 1313 | typeList: [ARGUMENT_TYPE.STRING], |
| 1314 | defaultValue: '', | 1314 | defaultValue: '', |
| 1315 | enumProvider: commonEnumProviders.injects, | 1315 | enumProvider: commonEnumProviders.injects, |
| 1316 | }), | 1316 | }), |
| 1317 | ], | 1317 | ], |
| 1318 | callback: flushInjectsCallback, | 1318 | callback: flushInjectsCallback, |
| 1319 | helpString: 'Removes a script injection for the current chat. If no ID is provided, removes all script injections.', | 1319 | helpString: 'Removes a script injection for the current chat. If no ID is provided, removes all script injections.', |
| 1320 | })); | 1320 | })); |
| 1321 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 1321 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1322 | name: 'tokens', | 1322 | name: 'tokens', |
| 1323 | callback: (_, text) => { | 1323 | callback: (_, text) => { |
| 1324 | if (text instanceof SlashCommandClosure || Array.isArray(text)) throw new Error('Unnamed argument cannot be a closure for command /tokens'); | 1324 | if (text instanceof SlashCommandClosure || Array.isArray(text)) throw new Error('Unnamed argument cannot be a closure for command /tokens'); |
| 1325 | return getTokenCountAsync(text).then(count => String(count)); | 1325 | return getTokenCountAsync(text).then(count => String(count)); |
| 1326 | }, | 1326 | }, |
| 1327 | returns: 'number of tokens', | 1327 | returns: 'number of tokens', |
| 1328 | unnamedArgumentList: [ | 1328 | unnamedArgumentList: [ |
| 1329 | new SlashCommandArgument( | 1329 | new SlashCommandArgument( |
| 1330 | 'text', [ARGUMENT_TYPE.STRING], true, | 1330 | 'text', [ARGUMENT_TYPE.STRING], true, |
| 1331 | ), | 1331 | ), |
| 1332 | ], | 1332 | ], |
| 1333 | helpString: 'Counts the number of tokens in the provided text.', | 1333 | helpString: 'Counts the number of tokens in the provided text.', |
| 1334 | })); | 1334 | })); |
| 1335 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 1335 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1336 | name: 'model', | 1336 | name: 'model', |
| 1337 | callback: modelCallback, | 1337 | callback: modelCallback, |
| 1338 | returns: 'current model', | 1338 | returns: 'current model', |
| 1339 | unnamedArgumentList: [ | 1339 | unnamedArgumentList: [ |
| 1340 | SlashCommandArgument.fromProps({ | 1340 | SlashCommandArgument.fromProps({ |
| 1341 | description: 'model name', | 1341 | description: 'model name', |
| 1342 | typeList: [ARGUMENT_TYPE.STRING], | 1342 | typeList: [ARGUMENT_TYPE.STRING], |
| 1343 | enumProvider: () => getModelOptions()?.options.map(option => new SlashCommandEnumValue(option.value, option.value !== option.text ? option.text : null)), | 1343 | enumProvider: () => getModelOptions()?.options.map(option => new SlashCommandEnumValue(option.value, option.value !== option.text ? option.text : null)), |
| 1344 | }), | 1344 | }), |
| 1345 | ], | 1345 | ], |
| 1346 | helpString: 'Sets the model for the current API. Gets the current model name if no argument is provided.', | 1346 | helpString: 'Sets the model for the current API. Gets the current model name if no argument is provided.', |
| 1347 | })); | 1347 | })); |
| 1348 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | 1348 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1349 | name: 'setpromptentry', | 1349 | name: 'setpromptentry', |
| 1350 | aliases: ['setpromptentries'], | 1350 | aliases: ['setpromptentries'], |
| 1351 | callback: setPromptEntryCallback, | 1351 | callback: setPromptEntryCallback, |
| 1352 | namedArgumentList: [ | 1352 | namedArgumentList: [ |
| 1353 | SlashCommandNamedArgument.fromProps({ | 1353 | SlashCommandNamedArgument.fromProps({ |
| 1354 | name: 'identifier', | 1354 | name: 'identifier', |
| 1355 | description: 'Prompt entry identifier(s) to target', | 1355 | description: 'Prompt entry identifier(s) to target', |
| 1356 | typeList: [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.LIST], | 1356 | typeList: [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.LIST], |
| 1357 | acceptsMultiple: true, | 1357 | acceptsMultiple: true, |
| 1358 | enumProvider: () => { | 1358 | enumProvider: () => { |
| 1359 | const promptManager = setupChatCompletionPromptManager(oai_settings); | 1359 | const promptManager = setupChatCompletionPromptManager(oai_settings); |
| 1360 | const prompts = promptManager.serviceSettings.prompts; | 1360 | const prompts = promptManager.serviceSettings.prompts; |
| 1361 | return prompts.map(prompt => new SlashCommandEnumValue(prompt.identifier, prompt.name, enumTypes.enum)); | 1361 | return prompts.map(prompt => new SlashCommandEnumValue(prompt.identifier, prompt.name, enumTypes.enum)); |
| 1362 | }, | 1362 | }, |
| 1363 | }), | 1363 | }), |
| 1364 | SlashCommandNamedArgument.fromProps({ | 1364 | SlashCommandNamedArgument.fromProps({ |
| 1365 | name: 'name', | 1365 | name: 'name', |
| 1366 | description: 'Prompt entry name(s) to target', | 1366 | description: 'Prompt entry name(s) to target', |
| 1367 | typeList: [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.LIST], | 1367 | typeList: [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.LIST], |
| 1368 | acceptsMultiple: true, | 1368 | acceptsMultiple: true, |
| 1369 | enumProvider: () => { | 1369 | enumProvider: () => { |
| 1370 | const promptManager = setupChatCompletionPromptManager(oai_settings); | 1370 | const promptManager = setupChatCompletionPromptManager(oai_settings); |
| 1371 | const prompts = promptManager.serviceSettings.prompts; | 1371 | const prompts = promptManager.serviceSettings.prompts; |
| 1372 | return prompts.map(prompt => new SlashCommandEnumValue(prompt.name, prompt.identifier, enumTypes.enum)); | 1372 | return prompts.map(prompt => new SlashCommandEnumValue(prompt.name, prompt.identifier, enumTypes.enum)); |
| 1373 | }, | 1373 | }, |
| 1374 | }), | 1374 | }), |
| 1375 | ], | 1375 | ], |
| 1376 | unnamedArgumentList: [ | 1376 | unnamedArgumentList: [ |
| 1377 | SlashCommandArgument.fromProps({ | 1377 | SlashCommandArgument.fromProps({ |
| 1378 | description: 'Set entry/entries on or off', | 1378 | description: 'Set entry/entries on or off', |
| 1379 | typeList: [ARGUMENT_TYPE.STRING], | 1379 | typeList: [ARGUMENT_TYPE.STRING], |
| 1380 | isRequired: true, | 1380 | isRequired: true, |
| 1381 | acceptsMultiple: false, | 1381 | acceptsMultiple: false, |
| 1382 | defaultValue: 'toggle', // unnamed arguments don't support default values yet | 1382 | defaultValue: 'toggle', // unnamed arguments don't support default values yet |
| 1383 | enumList: commonEnumProviders.boolean('onOffToggle')(), | 1383 | enumList: commonEnumProviders.boolean('onOffToggle')(), |
| 1384 | }), | 1384 | }), |
| 1385 | ], | 1385 | ], |
| 1386 | helpString: 'Sets the specified prompt manager entry/entries on or off.', | 1386 | helpString: 'Sets the specified prompt manager entry/entries on or off.', |
| 1387 | })); | 1387 | })); |
| 1388 | 1388 | ||
| 1389 | registerVariableCommands(); | 1389 | registerVariableCommands(); |
| 1390 | } | ||
| 1390 | 1391 | ||
| 1391 | const NARRATOR_NAME_KEY = 'narrator_name'; | 1392 | const NARRATOR_NAME_KEY = 'narrator_name'; |
| 1392 | const NARRATOR_NAME_DEFAULT = 'System'; | 1393 | const NARRATOR_NAME_DEFAULT = 'System'; |