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