fix: Slash command descriptions and argument help text are not translated (#4434) * fix: Slash command descriptions and argument help text are not translated #4428 * fix * fix: Refine slash command translation scope per review * fix * Join split multiline strings * Revert error name --------- Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
Signed| @@ -229,7 +229,7 @@ export function initDefaultSlashCommands() { | ||
| 229 | 229 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 230 | 230 | name: 'dupe', |
| 231 | 231 | callback: duplicateCharacter, |
| 232 | 232 | helpString: 't`Duplicates the currently selected character.'`, |
| 233 | 233 | })); |
| 234 | 234 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 235 | 235 | name: 'api', |
| @@ -306,11 +306,11 @@ export function initDefaultSlashCommands() { | ||
| 306 | 306 | toastr.clear(toast); |
| 307 | 307 | return text?.toString()?.trim() ?? ''; |
| 308 | 308 | }, |
| 309 | 309 | returns: 't`the current API'`, |
| 310 | 310 | namedArgumentList: [ |
| 311 | 311 | SlashCommandNamedArgument.fromProps({ |
| 312 | 312 | name: 'quiet', |
| 313 | 313 | description: 't`Suppress the toast message on connection'`, |
| 314 | 314 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 315 | 315 | defaultValue: 'false', |
| 316 | 316 | enumList: commonEnumProviders.boolean('trueFalse')(), |
| @@ -318,7 +318,7 @@ export function initDefaultSlashCommands() { | ||
| 318 | 318 | ], |
| 319 | 319 | unnamedArgumentList: [ |
| 320 | 320 | SlashCommandArgument.fromProps({ |
| 321 | 321 | description: 't`API to connect to'`, |
| 322 | 322 | typeList: [ARGUMENT_TYPE.STRING], |
| 323 | 323 | enumList: Object.entries(CONNECT_API_MAP).sort(([a], [b]) => a.localeCompare(b)).map(([api, { selected }]) => |
| 324 | 324 | new SlashCommandEnumValue(api, selected, enumTypes.getBasedOnIndex(UNIQUE_APIS.findIndex(x => x === selected)), |
| @@ -327,10 +327,10 @@ export function initDefaultSlashCommands() { | ||
| 327 | 327 | ], |
| 328 | 328 | helpString: ` |
| 329 | 329 | <div> |
| 330 | 330 | ${t`Connect to an API. If no argument is provided, it will return the currently connected API.`} |
| 331 | 331 | </div> |
| 332 | 332 | <div> |
| 333 | 333 | <strong>${t`Available APIs:`}</strong> |
| 334 | 334 | <pre><code>${Object.keys(CONNECT_API_MAP).sort((a, b) => a.localeCompare(b)).join(', ')}</code></pre> |
| 335 | 335 | </div> |
| 336 | 336 | `, |
| @@ -367,7 +367,7 @@ export function initDefaultSlashCommands() { | ||
| 367 | 367 | namedArgumentList: [ |
| 368 | 368 | new SlashCommandNamedArgument( |
| 369 | 369 | 'await', |
| 370 | 370 | 't`Whether to await for the triggered generation before continuing'`, |
| 371 | 371 | [ARGUMENT_TYPE.BOOLEAN], |
| 372 | 372 | false, |
| 373 | 373 | false, |
| @@ -381,13 +381,13 @@ export function initDefaultSlashCommands() { | ||
| 381 | 381 | ], |
| 382 | 382 | helpString: ` |
| 383 | 383 | <div> |
| 384 | 384 | ${t`Calls an impersonation response, with an optional additional prompt.`} |
| 385 | 385 | </div> |
| 386 | 386 | <div> |
| 387 | 387 | ${t`If <code>await=true</code> named argument is passed, the command will wait for the impersonation to end before continuing.`} |
| 388 | 388 | </div> |
| 389 | 389 | <div> |
| 390 | 390 | <strong>${t`Example:`}</strong> |
| 391 | 391 | <ul> |
| 392 | 392 | <li> |
| 393 | 393 | <pre><code class="language-stscript">/impersonate What is the meaning of life?</code></pre> |
| @@ -426,7 +426,7 @@ export function initDefaultSlashCommands() { | ||
| 426 | 426 | $(currentChatDeleteButton).trigger('click', { fromSlashCommand: true }); |
| 427 | 427 | })); |
| 428 | 428 | }, |
| 429 | 429 | helpString: 't`Deletes the current chat.'`, |
| 430 | 430 | })); |
| 431 | 431 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 432 | 432 | name: 'renamechat', |
| @@ -449,18 +449,18 @@ export function initDefaultSlashCommands() { | ||
| 449 | 449 | }, |
| 450 | 450 | unnamedArgumentList: [ |
| 451 | 451 | new SlashCommandArgument( |
| 452 | 452 | 't`new chat name'`, [ARGUMENT_TYPE.STRING], true, |
| 453 | 453 | ), |
| 454 | 454 | ], |
| 455 | 455 | helpString: 't`Renames the current chat.'`, |
| 456 | 456 | })); |
| 457 | 457 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 458 | 458 | name: 'getchatname', |
| 459 | 459 | callback: async function doGetChatName() { |
| 460 | 460 | return getCurrentChatDetails().sessionName; |
| 461 | 461 | }, |
| 462 | 462 | returns: 't`chat file name'`, |
| 463 | 463 | helpString: 't`Returns the name of the current chat file into the pipe.'`, |
| 464 | 464 | })); |
| 465 | 465 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 466 | 466 | name: 'closechat', |
| @@ -468,7 +468,7 @@ export function initDefaultSlashCommands() { | ||
| 468 | 468 | $('#option_close_chat').trigger('click'); |
| 469 | 469 | return ''; |
| 470 | 470 | }, |
| 471 | 471 | helpString: 't`Closes the current chat.'`, |
| 472 | 472 | })); |
| 473 | 473 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 474 | 474 | name: 'tempchat', |
| @@ -476,7 +476,7 @@ export function initDefaultSlashCommands() { | ||
| 476 | 476 | return new Promise((resolve, reject) => { |
| 477 | 477 | const eventCallback = async (chatId) => { |
| 478 | 478 | if (chatId) { |
| 479 | 479 | return reject('t`Not in a temporary chat'`); |
| 480 | 480 | } |
| 481 | 481 | await newAssistantChat({ temporary: true }); |
| 482 | 482 | return resolve(''); |
| @@ -484,12 +484,12 @@ export function initDefaultSlashCommands() { | ||
| 484 | 484 | eventSource.once(event_types.CHAT_CHANGED, eventCallback); |
| 485 | 485 | $('#option_close_chat').trigger('click'); |
| 486 | 486 | setTimeout(() => { |
| 487 | 487 | reject('t`Failed to open temporary chat'`); |
| 488 | 488 | eventSource.removeListener(event_types.CHAT_CHANGED, eventCallback); |
| 489 | 489 | }, debounce_timeout.relaxed); |
| 490 | 490 | }); |
| 491 | 491 | }, |
| 492 | 492 | helpString: 't`Opens a temporary chat with Assistant.'`, |
| 493 | 493 | })); |
| 494 | 494 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 495 | 495 | name: 'panels', |
| @@ -498,17 +498,17 @@ export function initDefaultSlashCommands() { | ||
| 498 | 498 | return ''; |
| 499 | 499 | }, |
| 500 | 500 | aliases: ['togglepanels'], |
| 501 | 501 | helpString: 't`Toggle UI panels on/off'`, |
| 502 | 502 | })); |
| 503 | 503 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 504 | 504 | name: 'forcesave', |
| 505 | 505 | callback: async function () { |
| 506 | 506 | await saveSettings(); |
| 507 | 507 | await saveChatConditional(); |
| 508 | 508 | toastr.success('t`Chat and settings saved.'`); |
| 509 | 509 | return ''; |
| 510 | 510 | }, |
| 511 | 511 | helpString: 't`Forces a save of the current chat and settings'`, |
| 512 | 512 | })); |
| 513 | 513 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 514 | 514 | name: 'instruct', |
| @@ -531,18 +531,18 @@ export function initDefaultSlashCommands() { | ||
| 531 | 531 | selectInstructPreset(foundName, { quiet: quiet }); |
| 532 | 532 | return foundName; |
| 533 | 533 | }, |
| 534 | 534 | returns: 't`current template'`, |
| 535 | 535 | namedArgumentList: [ |
| 536 | 536 | SlashCommandNamedArgument.fromProps({ |
| 537 | 537 | name: 'quiet', |
| 538 | 538 | description: 't`Suppress the toast message on template change'`, |
| 539 | 539 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 540 | 540 | defaultValue: 'false', |
| 541 | 541 | enumList: commonEnumProviders.boolean('trueFalse')(), |
| 542 | 542 | }), |
| 543 | 543 | SlashCommandNamedArgument.fromProps({ |
| 544 | 544 | name: 'forceGet', |
| 545 | 545 | description: 't`Force getting a name even if instruct mode is disabled'`, |
| 546 | 546 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 547 | 547 | defaultValue: 'false', |
| 548 | 548 | enumList: commonEnumProviders.boolean('trueFalse')(), |
| @@ -550,18 +550,18 @@ export function initDefaultSlashCommands() { | ||
| 550 | 550 | ], |
| 551 | 551 | unnamedArgumentList: [ |
| 552 | 552 | SlashCommandArgument.fromProps({ |
| 553 | 553 | description: 't`instruct template name'`, |
| 554 | 554 | typeList: [ARGUMENT_TYPE.STRING], |
| 555 | 555 | enumProvider: () => instruct_presets.map(preset => new SlashCommandEnumValue(preset.name, null, enumTypes.enum, enumIcons.preset)), |
| 556 | 556 | }), |
| 557 | 557 | ], |
| 558 | 558 | helpString: ` |
| 559 | 559 | <div> |
| 560 | 560 | ${t`Selects instruct mode template by name. Enables instruct mode if not already enabled.`} |
| 561 | 561 | ${t`Gets the current instruct template if no name is provided and instruct mode is enabled or <code>forceGet=true</code> is passed.`} |
| 562 | 562 | </div> |
| 563 | 563 | <div> |
| 564 | 564 | <strong>${t`Example:`}</strong> |
| 565 | 565 | <ul> |
| 566 | 566 | <li> |
| 567 | 567 | <pre><code class="language-stscript">/instruct creative</code></pre> |
| @@ -573,20 +573,20 @@ export function initDefaultSlashCommands() { | ||
| 573 | 573 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 574 | 574 | name: 'instruct-on', |
| 575 | 575 | callback: enableInstructCallback, |
| 576 | 576 | helpString: 't`Enables instruct mode.'`, |
| 577 | 577 | })); |
| 578 | 578 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 579 | 579 | name: 'instruct-off', |
| 580 | 580 | callback: disableInstructCallback, |
| 581 | 581 | helpString: 't`Disables instruct mode'`, |
| 582 | 582 | })); |
| 583 | 583 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 584 | 584 | name: 'instruct-state', |
| 585 | 585 | aliases: ['instruct-toggle'], |
| 586 | 586 | helpString: 't`Gets the current instruct mode state. If an argument is provided, it will set the instruct mode state.'`, |
| 587 | 587 | unnamedArgumentList: [ |
| 588 | 588 | SlashCommandArgument.fromProps({ |
| 589 | 589 | description: 't`instruct mode state'`, |
| 590 | 590 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 591 | 591 | enumList: commonEnumProviders.boolean('trueFalse')(), |
| 592 | 592 | }), |
| @@ -622,11 +622,11 @@ export function initDefaultSlashCommands() { | ||
| 622 | 622 | selectContextPreset(foundName, { quiet: quiet }); |
| 623 | 623 | return foundName; |
| 624 | 624 | }, |
| 625 | 625 | returns: 't`template name'`, |
| 626 | 626 | namedArgumentList: [ |
| 627 | 627 | SlashCommandNamedArgument.fromProps({ |
| 628 | 628 | name: 'quiet', |
| 629 | 629 | description: 't`Suppress the toast message on template change'`, |
| 630 | 630 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 631 | 631 | defaultValue: 'false', |
| 632 | 632 | enumList: commonEnumProviders.boolean('trueFalse')(), |
| @@ -634,12 +634,12 @@ export function initDefaultSlashCommands() { | ||
| 634 | 634 | ], |
| 635 | 635 | unnamedArgumentList: [ |
| 636 | 636 | SlashCommandArgument.fromProps({ |
| 637 | 637 | description: 't`context template name'`, |
| 638 | 638 | typeList: [ARGUMENT_TYPE.STRING], |
| 639 | 639 | enumProvider: () => context_presets.map(preset => new SlashCommandEnumValue(preset.name, null, enumTypes.enum, enumIcons.preset)), |
| 640 | 640 | }), |
| 641 | 641 | ], |
| 642 | 642 | helpString: 't`Selects context template by name. Gets the current template if no name is provided'`, |
| 643 | 643 | })); |
| 644 | 644 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 645 | 645 | name: 'chat-manager', |
| @@ -648,32 +648,32 @@ export function initDefaultSlashCommands() { | ||
| 648 | 648 | return ''; |
| 649 | 649 | }, |
| 650 | 650 | aliases: ['chat-history', 'manage-chats'], |
| 651 | 651 | helpString: 't`Opens the chat manager for the current character/group.'`, |
| 652 | 652 | })); |
| 653 | 653 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 654 | 654 | name: '?', |
| 655 | 655 | callback: helpCommandCallback, |
| 656 | 656 | aliases: ['help'], |
| 657 | 657 | unnamedArgumentList: [SlashCommandArgument.fromProps({ |
| 658 | 658 | description: 't`help topic'`, |
| 659 | 659 | typeList: [ARGUMENT_TYPE.STRING], |
| 660 | 660 | enumList: [ |
| 661 | 661 | new SlashCommandEnumValue('slash', 't`slash commands (STscript)'`, enumTypes.command, '/'), |
| 662 | 662 | new SlashCommandEnumValue('macros', 't`{{macros}} (text replacement)'`, enumTypes.macro, enumIcons.macro), |
| 663 | 663 | new SlashCommandEnumValue('format', 't`chat/text formatting'`, enumTypes.name, '★'), |
| 664 | 664 | new SlashCommandEnumValue('hotkeys', 't`keyboard shortcuts'`, enumTypes.enum, '⏎'), |
| 665 | 665 | ], |
| 666 | 666 | })], |
| 667 | 667 | helpString: 't`Get help on macros, chat formatting and commands.'`, |
| 668 | 668 | })); |
| 669 | 669 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 670 | 670 | name: 'bg', |
| 671 | 671 | callback: setBackgroundCallback, |
| 672 | 672 | aliases: ['background'], |
| 673 | 673 | returns: 't`the current background'`, |
| 674 | 674 | unnamedArgumentList: [ |
| 675 | 675 | SlashCommandArgument.fromProps({ |
| 676 | 676 | description: 't`background filename'`, |
| 677 | 677 | typeList: [ARGUMENT_TYPE.STRING], |
| 678 | 678 | enumProvider: () => [...document.querySelectorAll('.bg_example')] |
| 679 | 679 | .map(it => new SlashCommandEnumValue(it.getAttribute('bgfile'))) |
| @@ -682,13 +682,13 @@ export function initDefaultSlashCommands() { | ||
| 682 | 682 | ], |
| 683 | 683 | helpString: ` |
| 684 | 684 | <div> |
| 685 | 685 | ${t`Sets a background according to the provided filename. Partial names allowed.`} |
| 686 | 686 | </div> |
| 687 | 687 | <div> |
| 688 | 688 | ${t`If no background is provided, this will return the currently selected background.`} |
| 689 | 689 | </div> |
| 690 | 690 | <div> |
| 691 | 691 | <strong>${t`Example:`}</strong> |
| 692 | 692 | <ul> |
| 693 | 693 | <li> |
| 694 | 694 | <pre><code>/bg beach.jpg</code></pre> |
| @@ -704,31 +704,31 @@ export function initDefaultSlashCommands() { | ||
| 704 | 704 | name: 'char-find', |
| 705 | 705 | aliases: ['findchar'], |
| 706 | 706 | callback: (args, name) => { |
| 707 | 707 | if (typeof name !== 'string') throw new Error('t`name must be a string'`); |
| 708 | 708 | if (args.preferCurrent instanceof SlashCommandClosure || Array.isArray(args.preferCurrent)) throw new Error('t`preferCurrent cannot be a closure or array'`); |
| 709 | 709 | if (args.quiet instanceof SlashCommandClosure || Array.isArray(args.quiet)) throw new Error('t`quiet cannot be a closure or array'`); |
| 710 | 710 | |
| 711 | 711 | const char = findChar({ name: name, filteredByTags: validateArrayArgString(args.tag, 'tag'), preferCurrentChar: !isFalseBoolean(args.preferCurrent), quiet: isTrueBoolean(args.quiet) }); |
| 712 | 712 | return char?.avatar ?? ''; |
| 713 | 713 | }, |
| 714 | 714 | returns: 't`the avatar key (unique identifier) of the character'`, |
| 715 | 715 | namedArgumentList: [ |
| 716 | 716 | SlashCommandNamedArgument.fromProps({ |
| 717 | 717 | name: 'tag', |
| 718 | 718 | description: 't`Supply one or more tags to filter down to the correct character for the provided name, if multiple characters have the same name.'`, |
| 719 | 719 | typeList: [ARGUMENT_TYPE.STRING], |
| 720 | 720 | enumProvider: commonEnumProviders.tags('assigned'), |
| 721 | 721 | acceptsMultiple: true, |
| 722 | 722 | }), |
| 723 | 723 | SlashCommandNamedArgument.fromProps({ |
| 724 | 724 | name: 'preferCurrent', |
| 725 | 725 | description: 't`Prefer current character or characters in a group, if multiple characters match'`, |
| 726 | 726 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 727 | 727 | defaultValue: 'true', |
| 728 | 728 | }), |
| 729 | 729 | SlashCommandNamedArgument.fromProps({ |
| 730 | 730 | name: 'quiet', |
| 731 | 731 | description: 't`Do not show warning if multiple charactrers are found'`, |
| 732 | 732 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 733 | 733 | defaultValue: 'false', |
| 734 | 734 | enumProvider: commonEnumProviders.boolean('trueFalse'), |
| @@ -736,31 +736,29 @@ export function initDefaultSlashCommands() { | ||
| 736 | 736 | ], |
| 737 | 737 | unnamedArgumentList: [ |
| 738 | 738 | SlashCommandArgument.fromProps({ |
| 739 | 739 | description: 't`Character name - or unique character identifier (avatar key)'`, |
| 740 | 740 | typeList: [ARGUMENT_TYPE.STRING], |
| 741 | 741 | enumProvider: commonEnumProviders.characters('character'), |
| 742 | 742 | }), |
| 743 | 743 | ], |
| 744 | 744 | helpString: ` |
| 745 | 745 | <div> |
| 746 | 746 | ${t`Searches for a character and returns its avatar key.`} |
| 747 | 747 | </div> |
| 748 | 748 | <div> |
| 749 | 749 | ${t`This can be used to choose the correct character for something like <code>/sendas</code> or other commands in need of a character name if you have multiple characters with the same name.`} |
| 750 | - if you have multiple characters with the same name. | |
| 751 | 750 | </div> |
| 752 | 751 | <div> |
| 753 | 752 | <strong>${t`Example:`}</strong> |
| 754 | 753 | <ul> |
| 755 | 754 | <li> |
| 756 | 755 | <pre><code>/char-find name="Chloe"</code></pre> |
| 757 | 756 | ${t`Returns the avatar key for "Chloe".`} |
| 758 | 757 | </li> |
| 759 | 758 | <li> |
| 760 | 759 | <pre><code>/search name="Chloe" tag="friend"</code></pre> |
| 761 | 760 | ${t`Returns the avatar key for the character "Chloe" that is tagged with "friend".`} |
| 762 | 761 | ${t`This is useful if you for example have multiple characters named "Chloe", and the others are "foe", "goddess", or anything else, so you can actually select the character you are looking for.`} |
| 763 | - so you can actually select the character you are looking for. | |
| 764 | 762 | </li> |
| 765 | 763 | </ul> |
| 766 | 764 | </div> |
| @@ -770,36 +768,36 @@ export function initDefaultSlashCommands() { | ||
| 770 | 768 | name: 'sendas', |
| 771 | 769 | rawQuotes: true, |
| 772 | 770 | callback: sendMessageAs, |
| 773 | 771 | returns: 't`Optionally the text of the sent message, if specified in the "return" argument'`, |
| 774 | 772 | namedArgumentList: [ |
| 775 | 773 | SlashCommandNamedArgument.fromProps({ |
| 776 | 774 | name: 'name', |
| 777 | 775 | description: 't`Character name - or unique character identifier (avatar key)'`, |
| 778 | 776 | typeList: [ARGUMENT_TYPE.STRING], |
| 779 | 777 | isRequired: true, |
| 780 | 778 | enumProvider: commonEnumProviders.characters('character'), |
| 781 | 779 | }), |
| 782 | 780 | SlashCommandNamedArgument.fromProps({ |
| 783 | 781 | name: 'avatar', |
| 784 | 782 | description: 't`Character avatar override (Can be either avatar key or just the character name to pull the avatar from)'`, |
| 785 | 783 | typeList: [ARGUMENT_TYPE.STRING], |
| 786 | 784 | enumProvider: commonEnumProviders.characters('character'), |
| 787 | 785 | }), |
| 788 | 786 | SlashCommandNamedArgument.fromProps({ |
| 789 | 787 | name: 'compact', |
| 790 | 788 | description: 't`Use compact layout'`, |
| 791 | 789 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 792 | 790 | defaultValue: 'false', |
| 793 | 791 | }), |
| 794 | 792 | SlashCommandNamedArgument.fromProps({ |
| 795 | 793 | name: 'at', |
| 796 | 794 | description: 't`position to insert the message (index-based, corresponding to message id). If not set, the message will be inserted at the end of the chat.\nNegative values (including -0) are accepted and will work similarly to how \'depth\' usually works. For example, -1 will insert the message right before the last message in chat.'`, |
| 797 | 795 | typeList: [ARGUMENT_TYPE.NUMBER], |
| 798 | 796 | enumProvider: commonEnumProviders.messages({ allowIdAfter: true }), |
| 799 | 797 | }), |
| 800 | 798 | SlashCommandNamedArgument.fromProps({ |
| 801 | 799 | name: 'return', |
| 802 | 800 | description: 't`The way how you want the return value to be provided'`, |
| 803 | 801 | typeList: [ARGUMENT_TYPE.STRING], |
| 804 | 802 | defaultValue: 'none', |
| 805 | 803 | enumList: slashCommandReturnHelper.enumList({ allowObject: true }), |
| @@ -807,7 +805,7 @@ export function initDefaultSlashCommands() { | ||
| 807 | 805 | }), |
| 808 | 806 | SlashCommandNamedArgument.fromProps({ |
| 809 | 807 | name: 'raw', |
| 810 | 808 | description: 't`If true, does not alter quoted literal unnamed arguments'`, |
| 811 | 809 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 812 | 810 | defaultValue: 'true', |
| 813 | 811 | enumProvider: commonEnumProviders.boolean('trueFalse'), |
| @@ -821,23 +819,23 @@ export function initDefaultSlashCommands() { | ||
| 821 | 819 | ], |
| 822 | 820 | helpString: ` |
| 823 | 821 | <div> |
| 824 | 822 | ${t`Sends a message as a specific character. Uses the character avatar if it exists in the characters list.`} |
| 825 | 823 | </div> |
| 826 | 824 | <div> |
| 827 | 825 | <strong>${t`Example:`}</strong> |
| 828 | 826 | <ul> |
| 829 | 827 | <li> |
| 830 | 828 | <pre><code>/sendas name="Chloe" Hello, guys!</code></pre> |
| 831 | 829 | ${t`will send "Hello, guys!" from "Chloe".`} |
| 832 | 830 | </li> |
| 833 | 831 | <li> |
| 834 | 832 | <pre><code>/sendas name="Chloe" avatar="BigBadBoss" Hehehe, I am the big bad evil, fear me.</code></pre> |
| 835 | 833 | ${t`will send a message as the character "Chloe", but utilizing the avatar from a character named "BigBadBoss".`} |
| 836 | 834 | </li> |
| 837 | 835 | </ul> |
| 838 | 836 | </div> |
| 839 | 837 | <div> |
| 840 | 838 | ${t`If "compact" is set to true, the message is sent using a compact layout.`} |
| 841 | 839 | </div> |
| 842 | 840 | `, |
| 843 | 841 | })); |
| @@ -846,11 +844,11 @@ export function initDefaultSlashCommands() { | ||
| 846 | 844 | rawQuotes: true, |
| 847 | 845 | callback: sendNarratorMessage, |
| 848 | 846 | aliases: ['nar'], |
| 849 | 847 | returns: 't`Optionally the text of the sent message, if specified in the "return" argument'`, |
| 850 | 848 | namedArgumentList: [ |
| 851 | 849 | new SlashCommandNamedArgument( |
| 852 | 850 | 'compact', |
| 853 | 851 | 't`compact layout'`, |
| 854 | 852 | [ARGUMENT_TYPE.BOOLEAN], |
| 855 | 853 | false, |
| 856 | 854 | false, |
| @@ -858,18 +856,18 @@ export function initDefaultSlashCommands() { | ||
| 858 | 856 | ), |
| 859 | 857 | SlashCommandNamedArgument.fromProps({ |
| 860 | 858 | name: 'at', |
| 861 | 859 | description: 't`position to insert the message (index-based, corresponding to message id). If not set, the message will be inserted at the end of the chat.\nNegative values (including -0) are accepted and will work similarly to how \'depth\' usually works. For example, -1 will insert the message right before the last message in chat.'`, |
| 862 | 860 | typeList: [ARGUMENT_TYPE.NUMBER], |
| 863 | 861 | enumProvider: commonEnumProviders.messages({ allowIdAfter: true }), |
| 864 | 862 | }), |
| 865 | 863 | SlashCommandNamedArgument.fromProps({ |
| 866 | 864 | name: 'name', |
| 867 | 865 | description: 't`Optional custom display name to use for this system narrator message.'`, |
| 868 | 866 | typeList: [ARGUMENT_TYPE.STRING], |
| 869 | 867 | }), |
| 870 | 868 | SlashCommandNamedArgument.fromProps({ |
| 871 | 869 | name: 'return', |
| 872 | 870 | description: 't`The way how you want the return value to be provided'`, |
| 873 | 871 | typeList: [ARGUMENT_TYPE.STRING], |
| 874 | 872 | defaultValue: 'none', |
| 875 | 873 | enumList: slashCommandReturnHelper.enumList({ allowObject: true }), |
| @@ -877,7 +875,7 @@ export function initDefaultSlashCommands() { | ||
| 877 | 875 | }), |
| 878 | 876 | SlashCommandNamedArgument.fromProps({ |
| 879 | 877 | name: 'raw', |
| 880 | 878 | description: 't`If true, does not alter quoted literal unnamed arguments'`, |
| 881 | 879 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 882 | 880 | defaultValue: 'true', |
| 883 | 881 | enumProvider: commonEnumProviders.boolean('trueFalse'), |
| @@ -891,13 +889,13 @@ export function initDefaultSlashCommands() { | ||
| 891 | 889 | ], |
| 892 | 890 | helpString: ` |
| 893 | 891 | <div> |
| 894 | 892 | ${t`Sends a message as a system narrator.`} |
| 895 | 893 | </div> |
| 896 | 894 | <div> |
| 897 | 895 | ${t`If <code>compact</code> is set to <code>true</code>, the message is sent using a compact layout.`} |
| 898 | 896 | </div> |
| 899 | 897 | <div> |
| 900 | 898 | <strong>${t`Example:`}</strong> |
| 901 | 899 | <ul> |
| 902 | 900 | <li> |
| 903 | 901 | <pre><code>/sys The sun sets in the west.</code></pre> |
| @@ -914,20 +912,20 @@ export function initDefaultSlashCommands() { | ||
| 914 | 912 | callback: setNarratorName, |
| 915 | 913 | unnamedArgumentList: [ |
| 916 | 914 | new SlashCommandArgument( |
| 917 | 915 | 't`name'`, [ARGUMENT_TYPE.STRING], false, |
| 918 | 916 | ), |
| 919 | 917 | ], |
| 920 | 918 | helpString: 't`Sets a name for future system narrator messages in this chat (display only). Default: System. Leave empty to reset.'`, |
| 921 | 919 | })); |
| 922 | 920 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 923 | 921 | name: 'comment', |
| 924 | 922 | rawQuotes: true, |
| 925 | 923 | callback: sendCommentMessage, |
| 926 | 924 | returns: 't`Optionally the text of the sent message, if specified in the "return" argument'`, |
| 927 | 925 | namedArgumentList: [ |
| 928 | 926 | new SlashCommandNamedArgument( |
| 929 | 927 | 'compact', |
| 930 | 928 | 't`Whether to use a compact layout'`, |
| 931 | 929 | [ARGUMENT_TYPE.BOOLEAN], |
| 932 | 930 | false, |
| 933 | 931 | false, |
| @@ -935,13 +933,13 @@ export function initDefaultSlashCommands() { | ||
| 935 | 933 | ), |
| 936 | 934 | SlashCommandNamedArgument.fromProps({ |
| 937 | 935 | name: 'at', |
| 938 | 936 | description: 't`position to insert the message (index-based, corresponding to message id). If not set, the message will be inserted at the end of the chat.\nNegative values (including -0) are accepted and will work similarly to how \'depth\' usually works. For example, -1 will insert the message right before the last message in chat.'`, |
| 939 | 937 | typeList: [ARGUMENT_TYPE.NUMBER], |
| 940 | 938 | enumProvider: commonEnumProviders.messages({ allowIdAfter: true }), |
| 941 | 939 | }), |
| 942 | 940 | SlashCommandNamedArgument.fromProps({ |
| 943 | 941 | name: 'return', |
| 944 | 942 | description: 't`The way how you want the return value to be provided'`, |
| 945 | 943 | typeList: [ARGUMENT_TYPE.STRING], |
| 946 | 944 | defaultValue: 'none', |
| 947 | 945 | enumList: slashCommandReturnHelper.enumList({ allowObject: true }), |
| @@ -949,7 +947,7 @@ export function initDefaultSlashCommands() { | ||
| 949 | 947 | }), |
| 950 | 948 | SlashCommandNamedArgument.fromProps({ |
| 951 | 949 | name: 'raw', |
| 952 | 950 | description: 't`If true, does not alter quoted literal unnamed arguments'`, |
| 953 | 951 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 954 | 952 | defaultValue: 'true', |
| 955 | 953 | enumProvider: commonEnumProviders.boolean('trueFalse'), |
| @@ -965,13 +963,13 @@ export function initDefaultSlashCommands() { | ||
| 965 | 963 | ], |
| 966 | 964 | helpString: ` |
| 967 | 965 | <div> |
| 968 | 966 | ${t`Adds a note/comment message not part of the chat.`} |
| 969 | 967 | </div> |
| 970 | 968 | <div> |
| 971 | 969 | ${t`If <code>compact</code> is set to <code>true</code>, the message is sent using a compact layout.`} |
| 972 | 970 | </div> |
| 973 | 971 | <div> |
| 974 | 972 | <strong>${t`Example:`}</strong> |
| 975 | 973 | <ul> |
| 976 | 974 | <li> |
| 977 | 975 | <pre><code>/comment This is a comment</code></pre> |
| @@ -987,19 +985,19 @@ export function initDefaultSlashCommands() { | ||
| 987 | 985 | name: 'single', |
| 988 | 986 | callback: setStoryModeCallback, |
| 989 | 987 | aliases: ['story'], |
| 990 | 988 | helpString: 't`Sets the message style to single document mode without names or avatars visible.'`, |
| 991 | 989 | })); |
| 992 | 990 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 993 | 991 | name: 'bubble', |
| 994 | 992 | callback: setBubbleModeCallback, |
| 995 | 993 | aliases: ['bubbles'], |
| 996 | 994 | helpString: 't`Sets the message style to bubble chat mode.'`, |
| 997 | 995 | })); |
| 998 | 996 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 999 | 997 | name: 'flat', |
| 1000 | 998 | callback: setFlatModeCallback, |
| 1001 | 999 | aliases: ['default'], |
| 1002 | 1000 | helpString: 't`Sets the message style to flat chat mode.'`, |
| 1003 | 1001 | })); |
| 1004 | 1002 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1005 | 1003 | name: 'continue', |
| @@ -1008,7 +1006,7 @@ export function initDefaultSlashCommands() { | ||
| 1008 | 1006 | namedArgumentList: [ |
| 1009 | 1007 | new SlashCommandNamedArgument( |
| 1010 | 1008 | 'await', |
| 1011 | 1009 | 't`Whether to await for the continued generation before proceeding'`, |
| 1012 | 1010 | [ARGUMENT_TYPE.BOOLEAN], |
| 1013 | 1011 | false, |
| 1014 | 1012 | false, |
| @@ -1022,21 +1020,21 @@ export function initDefaultSlashCommands() { | ||
| 1022 | 1020 | ], |
| 1023 | 1021 | helpString: ` |
| 1024 | 1022 | <div> |
| 1025 | 1023 | ${t`Continues the last message in the chat, with an optional additional prompt.`} |
| 1026 | 1024 | </div> |
| 1027 | 1025 | <div> |
| 1028 | 1026 | ${t`If <code>await=true</code> named argument is passed, the command will await for the continued generation before proceeding.`} |
| 1029 | 1027 | </div> |
| 1030 | 1028 | <div> |
| 1031 | 1029 | <strong>${t`Example:`}</strong> |
| 1032 | 1030 | <ul> |
| 1033 | 1031 | <li> |
| 1034 | 1032 | <pre><code>/continue</code></pre> |
| 1035 | 1033 | ${t`Continues the chat with no additional prompt and immediately proceeds to the next command.`} |
| 1036 | 1034 | </li> |
| 1037 | 1035 | <li> |
| 1038 | 1036 | <pre><code>/continue await=true Let's explore this further...</code></pre> |
| 1039 | 1037 | ${t`Continues the chat with the provided prompt and waits for the generation to finish.`} |
| 1040 | 1038 | </li> |
| 1041 | 1039 | </ul> |
| 1042 | 1040 | </div> |
| @@ -1045,16 +1043,16 @@ export function initDefaultSlashCommands() { | ||
| 1045 | 1043 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1046 | 1044 | name: 'go', |
| 1047 | 1045 | callback: goToCharacterCallback, |
| 1048 | 1046 | returns: 't`The character/group name'`, |
| 1049 | 1047 | unnamedArgumentList: [ |
| 1050 | 1048 | SlashCommandArgument.fromProps({ |
| 1051 | 1049 | description: 't`Character name - or unique character identifier (avatar key)'`, |
| 1052 | 1050 | typeList: [ARGUMENT_TYPE.STRING], |
| 1053 | 1051 | isRequired: true, |
| 1054 | 1052 | enumProvider: commonEnumProviders.characters('all'), |
| 1055 | 1053 | }), |
| 1056 | 1054 | ], |
| 1057 | 1055 | helpString: 't`Opens up a chat with the character or group by its name'`, |
| 1058 | 1056 | aliases: ['char'], |
| 1059 | 1057 | })); |
| 1060 | 1058 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| @@ -1064,21 +1062,21 @@ export function initDefaultSlashCommands() { | ||
| 1064 | 1062 | const renamed = await renameCharacter(name, { silent: isTrueBoolean(silent), renameChats: chats !== null ? isTrueBoolean(chats) : null }); |
| 1065 | 1063 | return String(renamed); |
| 1066 | 1064 | }, |
| 1067 | 1065 | returns: 't`true/false - Whether the rename was successful'`, |
| 1068 | 1066 | namedArgumentList: [ |
| 1069 | 1067 | new SlashCommandNamedArgument( |
| 1070 | 1068 | 'silent', 't`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', |
| 1071 | 1069 | ), |
| 1072 | 1070 | new SlashCommandNamedArgument( |
| 1073 | 1071 | 'chats', 't`Rename char in all previous chats'`, [ARGUMENT_TYPE.BOOLEAN], false, false, '<null>', |
| 1074 | 1072 | ), |
| 1075 | 1073 | ], |
| 1076 | 1074 | unnamedArgumentList: [ |
| 1077 | 1075 | new SlashCommandArgument( |
| 1078 | 1076 | 't`new char name'`, [ARGUMENT_TYPE.STRING], true, |
| 1079 | 1077 | ), |
| 1080 | 1078 | ], |
| 1081 | 1079 | helpString: 't`Renames the current character.'`, |
| 1082 | 1080 | })); |
| 1083 | 1081 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1084 | 1082 | name: 'sysgen', |
| @@ -1086,7 +1084,7 @@ export function initDefaultSlashCommands() { | ||
| 1086 | 1084 | namedArgumentList: [ |
| 1087 | 1085 | SlashCommandNamedArgument.fromProps({ |
| 1088 | 1086 | name: 'trim', |
| 1089 | 1087 | description: 't`Trim the output by the last sentence boundary'`, |
| 1090 | 1088 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 1091 | 1089 | defaultValue: 'false', |
| 1092 | 1090 | isRequired: false, |
| @@ -1094,7 +1092,7 @@ export function initDefaultSlashCommands() { | ||
| 1094 | 1092 | }), |
| 1095 | 1093 | SlashCommandNamedArgument.fromProps({ |
| 1096 | 1094 | name: 'compact', |
| 1097 | 1095 | description: 't`Use a compact layout for the message'`, |
| 1098 | 1096 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 1099 | 1097 | defaultValue: 'false', |
| 1100 | 1098 | isRequired: false, |
| @@ -1103,18 +1101,18 @@ export function initDefaultSlashCommands() { | ||
| 1103 | 1101 | }), |
| 1104 | 1102 | SlashCommandNamedArgument.fromProps({ |
| 1105 | 1103 | name: 'at', |
| 1106 | 1104 | description: 't`Position to insert the message (index-based, corresponding to message id). If not set, the message will be inserted at the end of the chat.\nNegative values (including -0) are accepted and will work similarly to how \'depth\' usually works. For example, -1 will insert the message right before the last message in chat.'`, |
| 1107 | 1105 | typeList: [ARGUMENT_TYPE.NUMBER], |
| 1108 | 1106 | enumProvider: commonEnumProviders.messages({ allowIdAfter: true }), |
| 1109 | 1107 | }), |
| 1110 | 1108 | SlashCommandNamedArgument.fromProps({ |
| 1111 | 1109 | name: 'name', |
| 1112 | 1110 | description: 't`Optional custom display name to use for this system narrator message.'`, |
| 1113 | 1111 | typeList: [ARGUMENT_TYPE.STRING], |
| 1114 | 1112 | }), |
| 1115 | 1113 | SlashCommandNamedArgument.fromProps({ |
| 1116 | 1114 | name: 'return', |
| 1117 | 1115 | description: 't`The way how you want the return value to be provided'`, |
| 1118 | 1116 | typeList: [ARGUMENT_TYPE.STRING], |
| 1119 | 1117 | defaultValue: 'none', |
| 1120 | 1118 | enumList: slashCommandReturnHelper.enumList({ allowObject: true }), |
| @@ -1126,23 +1124,23 @@ export function initDefaultSlashCommands() { | ||
| 1126 | 1124 | 'prompt', [ARGUMENT_TYPE.STRING], true, |
| 1127 | 1125 | ), |
| 1128 | 1126 | ], |
| 1129 | 1127 | helpString: 't`Generates a system message using a specified prompt.'`, |
| 1130 | 1128 | })); |
| 1131 | 1129 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1132 | 1130 | name: 'ask', |
| 1133 | 1131 | callback: askCharacter, |
| 1134 | 1132 | returns: 't`Optionally the text of the sent message, if specified in the "return" argument'`, |
| 1135 | 1133 | namedArgumentList: [ |
| 1136 | 1134 | SlashCommandNamedArgument.fromProps({ |
| 1137 | 1135 | name: 'name', |
| 1138 | 1136 | description: 't`Character name - or unique character identifier (avatar key)'`, |
| 1139 | 1137 | typeList: [ARGUMENT_TYPE.STRING], |
| 1140 | 1138 | isRequired: true, |
| 1141 | 1139 | enumProvider: commonEnumProviders.characters('character'), |
| 1142 | 1140 | }), |
| 1143 | 1141 | SlashCommandNamedArgument.fromProps({ |
| 1144 | 1142 | name: 'return', |
| 1145 | 1143 | description: 't`The way how you want the return value to be provided'`, |
| 1146 | 1144 | typeList: [ARGUMENT_TYPE.STRING], |
| 1147 | 1145 | defaultValue: 'pipe', |
| 1148 | 1146 | enumList: slashCommandReturnHelper.enumList({ allowObject: true }), |
| @@ -1154,7 +1152,7 @@ export function initDefaultSlashCommands() { | ||
| 1154 | 1152 | 'prompt', [ARGUMENT_TYPE.STRING], false, false, |
| 1155 | 1153 | ), |
| 1156 | 1154 | ], |
| 1157 | 1155 | helpString: 't`Asks a specified character card a prompt. Character name must be provided in a named argument.'`, |
| 1158 | 1156 | })); |
| 1159 | 1157 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1160 | 1158 | name: 'delname', |
| @@ -1162,7 +1160,7 @@ export function initDefaultSlashCommands() { | ||
| 1162 | 1160 | namedArgumentList: [], |
| 1163 | 1161 | unnamedArgumentList: [ |
| 1164 | 1162 | SlashCommandArgument.fromProps({ |
| 1165 | 1163 | description: 't`Character name - or unique character identifier (avatar key)'`, |
| 1166 | 1164 | typeList: [ARGUMENT_TYPE.STRING], |
| 1167 | 1165 | isRequired: true, |
| 1168 | 1166 | enumProvider: commonEnumProviders.characters('character'), |
| @@ -1171,10 +1169,10 @@ export function initDefaultSlashCommands() { | ||
| 1171 | 1169 | aliases: ['cancel'], |
| 1172 | 1170 | helpString: ` |
| 1173 | 1171 | <div> |
| 1174 | 1172 | ${t`Deletes all messages attributed to a specified name.`} |
| 1175 | 1173 | </div> |
| 1176 | 1174 | <div> |
| 1177 | 1175 | <strong>${t`Example:`}</strong> |
| 1178 | 1176 | <ul> |
| 1179 | 1177 | <li> |
| 1180 | 1178 | <pre><code>/delname John</code></pre> |
| @@ -1187,11 +1185,11 @@ export function initDefaultSlashCommands() { | ||
| 1187 | 1185 | name: 'send', |
| 1188 | 1186 | rawQuotes: true, |
| 1189 | 1187 | callback: sendUserMessageCallback, |
| 1190 | 1188 | returns: 't`Optionally the text of the sent message, if specified in the "return" argument'`, |
| 1191 | 1189 | namedArgumentList: [ |
| 1192 | 1190 | new SlashCommandNamedArgument( |
| 1193 | 1191 | 'compact', |
| 1194 | 1192 | 't`whether to use a compact layout'`, |
| 1195 | 1193 | [ARGUMENT_TYPE.BOOLEAN], |
| 1196 | 1194 | false, |
| 1197 | 1195 | false, |
| @@ -1199,20 +1197,20 @@ export function initDefaultSlashCommands() { | ||
| 1199 | 1197 | ), |
| 1200 | 1198 | SlashCommandNamedArgument.fromProps({ |
| 1201 | 1199 | name: 'at', |
| 1202 | 1200 | description: 't`position to insert the message (index-based, corresponding to message id). If not set, the message will be inserted at the end of the chat.\nNegative values (including -0) are accepted and will work similarly to how \'depth\' usually works. For example, -1 will insert the message right before the last message in chat.'`, |
| 1203 | 1201 | typeList: [ARGUMENT_TYPE.NUMBER], |
| 1204 | 1202 | enumProvider: commonEnumProviders.messages({ allowIdAfter: true }), |
| 1205 | 1203 | }), |
| 1206 | 1204 | SlashCommandNamedArgument.fromProps({ |
| 1207 | 1205 | name: 'name', |
| 1208 | 1206 | description: 't`display name'`, |
| 1209 | 1207 | typeList: [ARGUMENT_TYPE.STRING], |
| 1210 | 1208 | defaultValue: '{{user}}', |
| 1211 | 1209 | enumProvider: commonEnumProviders.personas, |
| 1212 | 1210 | }), |
| 1213 | 1211 | SlashCommandNamedArgument.fromProps({ |
| 1214 | 1212 | name: 'return', |
| 1215 | 1213 | description: 't`The way how you want the return value to be provided'`, |
| 1216 | 1214 | typeList: [ARGUMENT_TYPE.STRING], |
| 1217 | 1215 | defaultValue: 'none', |
| 1218 | 1216 | enumList: slashCommandReturnHelper.enumList({ allowObject: true }), |
| @@ -1220,7 +1218,7 @@ export function initDefaultSlashCommands() { | ||
| 1220 | 1218 | }), |
| 1221 | 1219 | SlashCommandNamedArgument.fromProps({ |
| 1222 | 1220 | name: 'raw', |
| 1223 | 1221 | description: 't`If true, does not alter quoted literal unnamed arguments'`, |
| 1224 | 1222 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 1225 | 1223 | defaultValue: 'true', |
| 1226 | 1224 | enumProvider: commonEnumProviders.boolean('trueFalse'), |
| @@ -1236,16 +1234,16 @@ export function initDefaultSlashCommands() { | ||
| 1236 | 1234 | ], |
| 1237 | 1235 | helpString: ` |
| 1238 | 1236 | <div> |
| 1239 | 1237 | ${t`Adds a user message to the chat log without triggering a generation.`} |
| 1240 | 1238 | </div> |
| 1241 | 1239 | <div> |
| 1242 | 1240 | ${t`If <code>compact</code> is set to <code>true</code>, the message is sent using a compact layout.`} |
| 1243 | 1241 | </div> |
| 1244 | 1242 | <div> |
| 1245 | 1243 | ${t`If <code>name</code> is set, it will be displayed as the message sender. Can be an empty for no name.`} |
| 1246 | 1244 | </div> |
| 1247 | 1245 | <div> |
| 1248 | 1246 | <strong>${t`Example:`}</strong> |
| 1249 | 1247 | <ul> |
| 1250 | 1248 | <li> |
| 1251 | 1249 | <pre><code>/send Hello there!</code></pre> |
| @@ -1263,7 +1261,7 @@ export function initDefaultSlashCommands() { | ||
| 1263 | 1261 | namedArgumentList: [ |
| 1264 | 1262 | new SlashCommandNamedArgument( |
| 1265 | 1263 | 'await', |
| 1266 | 1264 | 't`Whether to await for the triggered generation before continuing'`, |
| 1267 | 1265 | [ARGUMENT_TYPE.BOOLEAN], |
| 1268 | 1266 | false, |
| 1269 | 1267 | false, |
| @@ -1272,7 +1270,7 @@ export function initDefaultSlashCommands() { | ||
| 1272 | 1270 | ], |
| 1273 | 1271 | unnamedArgumentList: [ |
| 1274 | 1272 | SlashCommandArgument.fromProps({ |
| 1275 | 1273 | description: 't`group member index (starts with 0) or name'`, |
| 1276 | 1274 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], |
| 1277 | 1275 | isRequired: false, |
| 1278 | 1276 | enumProvider: commonEnumProviders.groupMembers(), |
| @@ -1280,10 +1278,10 @@ export function initDefaultSlashCommands() { | ||
| 1280 | 1278 | ], |
| 1281 | 1279 | helpString: ` |
| 1282 | 1280 | <div> |
| 1283 | 1281 | ${t`Triggers a message generation. If in group, can trigger a message for the specified group member index or name.`} |
| 1284 | 1282 | </div> |
| 1285 | 1283 | <div> |
| 1286 | 1284 | ${t`If <code>await=true</code> named argument is passed, the command will await for the triggered generation before continuing.`} |
| 1287 | 1285 | </div> |
| 1288 | 1286 | `, |
| 1289 | 1287 | })); |
| @@ -1293,7 +1291,7 @@ export function initDefaultSlashCommands() { | ||
| 1293 | 1291 | namedArgumentList: [ |
| 1294 | 1292 | SlashCommandNamedArgument.fromProps({ |
| 1295 | 1293 | name: 'name', |
| 1296 | 1294 | description: 't`only hide messages from a certain character or persona'`, |
| 1297 | 1295 | typeList: [ARGUMENT_TYPE.STRING], |
| 1298 | 1296 | enumProvider: commonEnumProviders.messageNames, |
| 1299 | 1297 | isRequired: false, |
| @@ -1302,13 +1300,13 @@ export function initDefaultSlashCommands() { | ||
| 1302 | 1300 | ], |
| 1303 | 1301 | unnamedArgumentList: [ |
| 1304 | 1302 | SlashCommandArgument.fromProps({ |
| 1305 | 1303 | description: 't`message index (starts with 0) or range, defaults to the last message index if not provided'`, |
| 1306 | 1304 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.RANGE], |
| 1307 | 1305 | isRequired: false, |
| 1308 | 1306 | enumProvider: commonEnumProviders.messages(), |
| 1309 | 1307 | }), |
| 1310 | 1308 | ], |
| 1311 | 1309 | helpString: 't`Hides a chat message from the prompt.'`, |
| 1312 | 1310 | })); |
| 1313 | 1311 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1314 | 1312 | name: 'unhide', |
| @@ -1316,7 +1314,7 @@ export function initDefaultSlashCommands() { | ||
| 1316 | 1314 | namedArgumentList: [ |
| 1317 | 1315 | SlashCommandNamedArgument.fromProps({ |
| 1318 | 1316 | name: 'name', |
| 1319 | 1317 | description: 't`only unhide messages from a certain character or persona'`, |
| 1320 | 1318 | typeList: [ARGUMENT_TYPE.STRING], |
| 1321 | 1319 | enumProvider: commonEnumProviders.messageNames, |
| 1322 | 1320 | isRequired: false, |
| @@ -1325,36 +1323,36 @@ export function initDefaultSlashCommands() { | ||
| 1325 | 1323 | ], |
| 1326 | 1324 | unnamedArgumentList: [ |
| 1327 | 1325 | SlashCommandArgument.fromProps({ |
| 1328 | 1326 | description: 't`message index (starts with 0) or range, defaults to the last message index if not provided'`, |
| 1329 | 1327 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.RANGE], |
| 1330 | 1328 | isRequired: false, |
| 1331 | 1329 | enumProvider: commonEnumProviders.messages(), |
| 1332 | 1330 | }), |
| 1333 | 1331 | ], |
| 1334 | 1332 | helpString: 't`Unhides a message from the prompt.'`, |
| 1335 | 1333 | })); |
| 1336 | 1334 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1337 | 1335 | name: 'member-get', |
| 1338 | 1336 | aliases: ['getmember', 'memberget'], |
| 1339 | 1337 | callback: (async ({ field = 'name' }, arg) => { |
| 1340 | 1338 | if (!selected_group) { |
| 1341 | 1339 | toastr.warning('t`Cannot run /member-get command outside of a group chat.'`); |
| 1342 | 1340 | return ''; |
| 1343 | 1341 | } |
| 1344 | 1342 | if (field === '') { |
| 1345 | 1343 | toastr.warning('\t`'/member-get field=\' argument required!'`); |
| 1346 | 1344 | return ''; |
| 1347 | 1345 | } |
| 1348 | 1346 | field = field.toString(); |
| 1349 | 1347 | arg = arg.toString(); |
| 1350 | 1348 | if (!['name', 'index', 'id', 'avatar'].includes(field)) { |
| 1351 | 1349 | toastr.warning('\t`'/member-get field=\' argument required!'`); |
| 1352 | 1350 | return ''; |
| 1353 | 1351 | } |
| 1354 | 1352 | const isId = !isNaN(parseInt(arg)); |
| 1355 | 1353 | const groupMember = findGroupMemberId(arg, true); |
| 1356 | 1354 | if (!groupMember) { |
| 1357 | 1355 | toastr.warning(t`No group member found using ${isId ? 'id' : 'string'} ${arg}`); |
| 1358 | 1356 | return ''; |
| 1359 | 1357 | } |
| 1360 | 1358 | return groupMember[field]; |
| @@ -1362,27 +1360,27 @@ export function initDefaultSlashCommands() { | ||
| 1362 | 1360 | namedArgumentList: [ |
| 1363 | 1361 | SlashCommandNamedArgument.fromProps({ |
| 1364 | 1362 | name: 'field', |
| 1365 | 1363 | description: 't`Whether to retrieve the name, index, id, or avatar.'`, |
| 1366 | 1364 | typeList: [ARGUMENT_TYPE.STRING], |
| 1367 | 1365 | isRequired: true, |
| 1368 | 1366 | defaultValue: 'name', |
| 1369 | 1367 | enumList: [ |
| 1370 | 1368 | new SlashCommandEnumValue('name', 't`Character name'`), |
| 1371 | 1369 | new SlashCommandEnumValue('index', 't`Group member index'`), |
| 1372 | 1370 | new SlashCommandEnumValue('avatar', 't`Character avatar'`), |
| 1373 | 1371 | new SlashCommandEnumValue('id', 't`Character index'`), |
| 1374 | 1372 | ], |
| 1375 | 1373 | }), |
| 1376 | 1374 | ], |
| 1377 | 1375 | unnamedArgumentList: [ |
| 1378 | 1376 | SlashCommandArgument.fromProps({ |
| 1379 | 1377 | description: 't`member index (starts with 0), name, or avatar'`, |
| 1380 | 1378 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], |
| 1381 | 1379 | isRequired: true, |
| 1382 | 1380 | enumProvider: commonEnumProviders.groupMembers(), |
| 1383 | 1381 | }), |
| 1384 | 1382 | ], |
| 1385 | 1383 | helpString: 't`Retrieves a group member\'s name, index, id, or avatar.'`, |
| 1386 | 1384 | })); |
| 1387 | 1385 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1388 | 1386 | name: 'member-disable', |
| @@ -1390,13 +1388,13 @@ export function initDefaultSlashCommands() { | ||
| 1390 | 1388 | aliases: ['disable', 'disablemember', 'memberdisable'], |
| 1391 | 1389 | unnamedArgumentList: [ |
| 1392 | 1390 | SlashCommandArgument.fromProps({ |
| 1393 | 1391 | description: 't`member index (starts with 0) or name'`, |
| 1394 | 1392 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], |
| 1395 | 1393 | isRequired: true, |
| 1396 | 1394 | enumProvider: commonEnumProviders.groupMembers(), |
| 1397 | 1395 | }), |
| 1398 | 1396 | ], |
| 1399 | 1397 | helpString: 't`Disables a group member from being drafted for replies.'`, |
| 1400 | 1398 | })); |
| 1401 | 1399 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1402 | 1400 | name: 'member-enable', |
| @@ -1404,13 +1402,13 @@ export function initDefaultSlashCommands() { | ||
| 1404 | 1402 | callback: enableGroupMemberCallback, |
| 1405 | 1403 | unnamedArgumentList: [ |
| 1406 | 1404 | SlashCommandArgument.fromProps({ |
| 1407 | 1405 | description: 't`member index (starts with 0) or name'`, |
| 1408 | 1406 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], |
| 1409 | 1407 | isRequired: true, |
| 1410 | 1408 | enumProvider: commonEnumProviders.groupMembers(), |
| 1411 | 1409 | }), |
| 1412 | 1410 | ], |
| 1413 | 1411 | helpString: 't`Enables a group member to be drafted for replies.'`, |
| 1414 | 1412 | })); |
| 1415 | 1413 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1416 | 1414 | name: 'member-add', |
| @@ -1418,7 +1416,7 @@ export function initDefaultSlashCommands() { | ||
| 1418 | 1416 | aliases: ['addmember', 'memberadd'], |
| 1419 | 1417 | unnamedArgumentList: [ |
| 1420 | 1418 | SlashCommandArgument.fromProps({ |
| 1421 | 1419 | description: 't`Character name - or unique character identifier (avatar key)'`, |
| 1422 | 1420 | typeList: [ARGUMENT_TYPE.STRING], |
| 1423 | 1421 | isRequired: true, |
| 1424 | 1422 | enumProvider: () => selected_group ? commonEnumProviders.characters('character')() : [], |
| @@ -1426,10 +1424,10 @@ export function initDefaultSlashCommands() { | ||
| 1426 | 1424 | ], |
| 1427 | 1425 | helpString: ` |
| 1428 | 1426 | <div> |
| 1429 | 1427 | ${t`Adds a new group member to the group chat.`} |
| 1430 | 1428 | </div> |
| 1431 | 1429 | <div> |
| 1432 | 1430 | <strong>${t`Example:`}</strong> |
| 1433 | 1431 | <ul> |
| 1434 | 1432 | <li> |
| 1435 | 1433 | <pre><code>/member-add John Doe</code></pre> |
| @@ -1444,7 +1442,7 @@ export function initDefaultSlashCommands() { | ||
| 1444 | 1442 | aliases: ['removemember', 'memberremove'], |
| 1445 | 1443 | unnamedArgumentList: [ |
| 1446 | 1444 | SlashCommandArgument.fromProps({ |
| 1447 | 1445 | description: 't`member index (starts with 0) or name'`, |
| 1448 | 1446 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], |
| 1449 | 1447 | isRequired: true, |
| 1450 | 1448 | enumProvider: commonEnumProviders.groupMembers(), |
| @@ -1452,10 +1450,10 @@ export function initDefaultSlashCommands() { | ||
| 1452 | 1450 | ], |
| 1453 | 1451 | helpString: ` |
| 1454 | 1452 | <div> |
| 1455 | 1453 | ${t`Removes a group member from the group chat.`} |
| 1456 | 1454 | </div> |
| 1457 | 1455 | <div> |
| 1458 | 1456 | <strong>${t`Example:`}</strong> |
| 1459 | 1457 | <ul> |
| 1460 | 1458 | <li> |
| 1461 | 1459 | <pre><code>/member-remove 2</code></pre> |
| @@ -1471,13 +1469,13 @@ export function initDefaultSlashCommands() { | ||
| 1471 | 1469 | aliases: ['upmember', 'memberup'], |
| 1472 | 1470 | unnamedArgumentList: [ |
| 1473 | 1471 | SlashCommandArgument.fromProps({ |
| 1474 | 1472 | description: 't`member index (starts with 0) or name'`, |
| 1475 | 1473 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], |
| 1476 | 1474 | isRequired: true, |
| 1477 | 1475 | enumProvider: commonEnumProviders.groupMembers(), |
| 1478 | 1476 | }), |
| 1479 | 1477 | ], |
| 1480 | 1478 | helpString: 't`Moves a group member up in the group chat list.'`, |
| 1481 | 1479 | })); |
| 1482 | 1480 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1483 | 1481 | name: 'member-down', |
| @@ -1485,13 +1483,13 @@ export function initDefaultSlashCommands() { | ||
| 1485 | 1483 | aliases: ['downmember', 'memberdown'], |
| 1486 | 1484 | unnamedArgumentList: [ |
| 1487 | 1485 | SlashCommandArgument.fromProps({ |
| 1488 | 1486 | description: 't`member index (starts with 0) or name'`, |
| 1489 | 1487 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], |
| 1490 | 1488 | isRequired: true, |
| 1491 | 1489 | enumProvider: commonEnumProviders.groupMembers(), |
| 1492 | 1490 | }), |
| 1493 | 1491 | ], |
| 1494 | 1492 | helpString: 't`Moves a group member down in the group chat list.'`, |
| 1495 | 1493 | })); |
| 1496 | 1494 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1497 | 1495 | name: 'member-peek', |
| @@ -1499,7 +1497,7 @@ export function initDefaultSlashCommands() { | ||
| 1499 | 1497 | callback: peekCallback, |
| 1500 | 1498 | unnamedArgumentList: [ |
| 1501 | 1499 | SlashCommandArgument.fromProps({ |
| 1502 | 1500 | description: 't`member index (starts with 0) or name'`, |
| 1503 | 1501 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.STRING], |
| 1504 | 1502 | isRequired: true, |
| 1505 | 1503 | enumProvider: commonEnumProviders.groupMembers(), |
| @@ -1507,14 +1505,14 @@ export function initDefaultSlashCommands() { | ||
| 1507 | 1505 | ], |
| 1508 | 1506 | helpString: ` |
| 1509 | 1507 | <div> |
| 1510 | 1508 | ${t`Shows a group member character card without switching chats.`} |
| 1511 | 1509 | </div> |
| 1512 | 1510 | <div> |
| 1513 | 1511 | <strong>${t`Examples:`}</strong> |
| 1514 | 1512 | <ul> |
| 1515 | 1513 | <li> |
| 1516 | 1514 | <pre><code>/peek Gloria</code></pre> |
| 1517 | 1515 | ${t`Shows the character card for the character named "Gloria".`} |
| 1518 | 1516 | </li> |
| 1519 | 1517 | </ul> |
| 1520 | 1518 | </div> |
| @@ -1524,16 +1522,16 @@ export function initDefaultSlashCommands() { | ||
| 1524 | 1522 | name: 'member-count', |
| 1525 | 1523 | callback: countGroupMemberCallback, |
| 1526 | 1524 | aliases: ['countmember', 'membercount'], |
| 1527 | 1525 | helpString: 't`Returns the total number of group members in the group chat list.'`, |
| 1528 | 1526 | })); |
| 1529 | 1527 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1530 | 1528 | name: 'delswipe', |
| 1531 | 1529 | callback: deleteSwipeCallback, |
| 1532 | 1530 | returns: 't`the new, currently selected swipe id'`, |
| 1533 | 1531 | aliases: ['swipedel'], |
| 1534 | 1532 | unnamedArgumentList: [ |
| 1535 | 1533 | SlashCommandArgument.fromProps({ |
| 1536 | 1534 | description: 't`1-based swipe id'`, |
| 1537 | 1535 | typeList: [ARGUMENT_TYPE.NUMBER], |
| 1538 | 1536 | isRequired: true, |
| 1539 | 1537 | enumProvider: () => Array.isArray(chat[chat.length - 1]?.swipes) ? |
| @@ -1543,18 +1541,18 @@ export function initDefaultSlashCommands() { | ||
| 1543 | 1541 | ], |
| 1544 | 1542 | helpString: ` |
| 1545 | 1543 | <div> |
| 1546 | 1544 | ${t`Deletes a swipe from the last chat message. If swipe id is not provided, it deletes the current swipe.`} |
| 1547 | 1545 | </div> |
| 1548 | 1546 | <div> |
| 1549 | 1547 | <strong>${t`Example:`}</strong> |
| 1550 | 1548 | <ul> |
| 1551 | 1549 | <li> |
| 1552 | 1550 | <pre><code>/delswipe</code></pre> |
| 1553 | 1551 | ${t`Deletes the current swipe.`} |
| 1554 | 1552 | </li> |
| 1555 | 1553 | <li> |
| 1556 | 1554 | <pre><code>/delswipe 2</code></pre> |
| 1557 | 1555 | ${t`Deletes the second swipe from the last chat message.`} |
| 1558 | 1556 | </li> |
| 1559 | 1557 | </ul> |
| 1560 | 1558 | </div> |
| @@ -1564,14 +1562,14 @@ export function initDefaultSlashCommands() { | ||
| 1564 | 1562 | name: 'echo', |
| 1565 | 1563 | rawQuotes: true, |
| 1566 | 1564 | callback: echoCallback, |
| 1567 | 1565 | returns: 't`the text'`, |
| 1568 | 1566 | namedArgumentList: [ |
| 1569 | 1567 | new SlashCommandNamedArgument( |
| 1570 | 1568 | 'title', 't`title of the toast message'`, [ARGUMENT_TYPE.STRING], false, |
| 1571 | 1569 | ), |
| 1572 | 1570 | SlashCommandNamedArgument.fromProps({ |
| 1573 | 1571 | name: 'severity', |
| 1574 | 1572 | description: 't`severity level of the toast message'`, |
| 1575 | 1573 | typeList: [ARGUMENT_TYPE.STRING], |
| 1576 | 1574 | defaultValue: 'info', |
| 1577 | 1575 | enumProvider: () => [ |
| @@ -1583,54 +1581,54 @@ export function initDefaultSlashCommands() { | ||
| 1583 | 1581 | }), |
| 1584 | 1582 | SlashCommandNamedArgument.fromProps({ |
| 1585 | 1583 | name: 'timeout', |
| 1586 | 1584 | description: 't`time in milliseconds to display the toast message. Set this and \'extendedTimeout\' to 0 to show indefinitely until dismissed.'`, |
| 1587 | 1585 | typeList: [ARGUMENT_TYPE.NUMBER], |
| 1588 | 1586 | defaultValue: `${toastr.options.timeOut}`, |
| 1589 | 1587 | }), |
| 1590 | 1588 | SlashCommandNamedArgument.fromProps({ |
| 1591 | 1589 | name: 'extendedTimeout', |
| 1592 | 1590 | description: 't`time in milliseconds to display the toast message. Set this and \'timeout\' to 0 to show indefinitely until dismissed.'`, |
| 1593 | 1591 | typeList: [ARGUMENT_TYPE.NUMBER], |
| 1594 | 1592 | defaultValue: `${toastr.options.extendedTimeOut}`, |
| 1595 | 1593 | }), |
| 1596 | 1594 | SlashCommandNamedArgument.fromProps({ |
| 1597 | 1595 | name: 'preventDuplicates', |
| 1598 | 1596 | description: 't`prevent duplicate toasts with the same message from being displayed.'`, |
| 1599 | 1597 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 1600 | 1598 | defaultValue: 'false', |
| 1601 | 1599 | enumList: commonEnumProviders.boolean('trueFalse')(), |
| 1602 | 1600 | }), |
| 1603 | 1601 | SlashCommandNamedArgument.fromProps({ |
| 1604 | 1602 | name: 'awaitDismissal', |
| 1605 | 1603 | description: 't`wait for the toast to be dismissed before continuing.'`, |
| 1606 | 1604 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 1607 | 1605 | defaultValue: 'false', |
| 1608 | 1606 | enumList: commonEnumProviders.boolean('trueFalse')(), |
| 1609 | 1607 | }), |
| 1610 | 1608 | SlashCommandNamedArgument.fromProps({ |
| 1611 | 1609 | name: 'cssClass', |
| 1612 | 1610 | description: 't`additional CSS class to add to the toast message (e.g. for custom styling)'`, |
| 1613 | 1611 | typeList: [ARGUMENT_TYPE.STRING], |
| 1614 | 1612 | }), |
| 1615 | 1613 | SlashCommandNamedArgument.fromProps({ |
| 1616 | 1614 | name: 'color', |
| 1617 | 1615 | description: 't`custom CSS color of the toast message. Accepts all valid CSS color values (e.g. \'red\', \'#FF0000\', \'rgb(255, 0, 0)\').<br />>Can be more customizable with the \'cssClass\' argument and custom classes.'`, |
| 1618 | 1616 | }), |
| 1619 | 1617 | SlashCommandNamedArgument.fromProps({ |
| 1620 | 1618 | name: 'escapeHtml', |
| 1621 | 1619 | description: 't`whether to escape HTML in the toast message.'`, |
| 1622 | 1620 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 1623 | 1621 | defaultValue: 'true', |
| 1624 | 1622 | enumList: commonEnumProviders.boolean('trueFalse')(), |
| 1625 | 1623 | }), |
| 1626 | 1624 | SlashCommandNamedArgument.fromProps({ |
| 1627 | 1625 | name: 'onClick', |
| 1628 | 1626 | description: 't`a closure to call when the toast is clicked. This executed closure receives scope as provided in the script. Careful about possible side effects when manipulating variables and more.'`, |
| 1629 | 1627 | typeList: [ARGUMENT_TYPE.CLOSURE], |
| 1630 | 1628 | }), |
| 1631 | 1629 | SlashCommandNamedArgument.fromProps({ |
| 1632 | 1630 | name: 'raw', |
| 1633 | 1631 | description: 't`If true, does not alter quoted literal unnamed arguments'`, |
| 1634 | 1632 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 1635 | 1633 | defaultValue: 'true', |
| 1636 | 1634 | enumProvider: commonEnumProviders.boolean('trueFalse'), |
| @@ -1665,32 +1663,32 @@ export function initDefaultSlashCommands() { | ||
| 1665 | 1663 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1666 | 1664 | name: 'gen', |
| 1667 | 1665 | callback: generateCallback, |
| 1668 | 1666 | returns: 't`generated text'`, |
| 1669 | 1667 | namedArgumentList: [ |
| 1670 | 1668 | SlashCommandNamedArgument.fromProps({ |
| 1671 | 1669 | name: 'trim', |
| 1672 | 1670 | description: 't`Trim the output by the last sentence boundary'`, |
| 1673 | 1671 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 1674 | 1672 | defaultValue: 'false', |
| 1675 | 1673 | isRequired: false, |
| 1676 | 1674 | enumProvider: commonEnumProviders.boolean('trueFalse'), |
| 1677 | 1675 | }), |
| 1678 | 1676 | new SlashCommandNamedArgument( |
| 1679 | 1677 | 'lock', 't`lock user input during generation'`, [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(), |
| 1680 | 1678 | ), |
| 1681 | 1679 | SlashCommandNamedArgument.fromProps({ |
| 1682 | 1680 | name: 'name', |
| 1683 | 1681 | description: 't`in-prompt character name for instruct mode (or unique character identifier (avatar key), which will be used as name)'`, |
| 1684 | 1682 | typeList: [ARGUMENT_TYPE.STRING], |
| 1685 | 1683 | defaultValue: 'System', |
| 1686 | 1684 | enumProvider: () => [...commonEnumProviders.characters('character')(), new SlashCommandEnumValue('System', null, enumTypes.enum, enumIcons.assistant)], |
| 1687 | 1685 | }), |
| 1688 | 1686 | new SlashCommandNamedArgument( |
| 1689 | 1687 | 'length', 't`API response length in tokens'`, [ARGUMENT_TYPE.NUMBER], false, |
| 1690 | 1688 | ), |
| 1691 | 1689 | SlashCommandNamedArgument.fromProps({ |
| 1692 | 1690 | name: 'as', |
| 1693 | 1691 | description: 't`role of the output prompt'`, |
| 1694 | 1692 | typeList: [ARGUMENT_TYPE.STRING], |
| 1695 | 1693 | enumList: [ |
| 1696 | 1694 | new SlashCommandEnumValue('system', null, enumTypes.enum, enumIcons.assistant), |
| @@ -1705,30 +1703,30 @@ export function initDefaultSlashCommands() { | ||
| 1705 | 1703 | ], |
| 1706 | 1704 | helpString: ` |
| 1707 | 1705 | <div> |
| 1708 | 1706 | ${t`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").`} |
| 1709 | 1707 | </div> |
| 1710 | 1708 | <div> |
| 1711 | 1709 | ${t`"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.`} |
| 1712 | 1710 | </div> |
| 1713 | 1711 | `, |
| 1714 | 1712 | })); |
| 1715 | 1713 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1716 | 1714 | name: 'genraw', |
| 1717 | 1715 | callback: generateRawCallback, |
| 1718 | 1716 | returns: 't`generated text'`, |
| 1719 | 1717 | namedArgumentList: [ |
| 1720 | 1718 | new SlashCommandNamedArgument( |
| 1721 | 1719 | 'lock', 't`lock user input during generation'`, [ARGUMENT_TYPE.BOOLEAN], false, false, 'off', commonEnumProviders.boolean('onOff')(), |
| 1722 | 1720 | ), |
| 1723 | 1721 | new SlashCommandNamedArgument( |
| 1724 | 1722 | 'instruct', 't`use instruct mode'`, [ARGUMENT_TYPE.BOOLEAN], false, false, 'on', commonEnumProviders.boolean('onOff')(), |
| 1725 | 1723 | ), |
| 1726 | 1724 | new SlashCommandNamedArgument( |
| 1727 | 1725 | 'stop', 't`one-time custom stop strings'`, [ARGUMENT_TYPE.LIST], false, false, '[]', |
| 1728 | 1726 | ), |
| 1729 | 1727 | SlashCommandNamedArgument.fromProps({ |
| 1730 | 1728 | name: 'as', |
| 1731 | 1729 | description: 't`role of the output prompt'`, |
| 1732 | 1730 | defaultValue: 'system', |
| 1733 | 1731 | typeList: [ARGUMENT_TYPE.STRING], |
| 1734 | 1732 | enumList: [ |
| @@ -1737,16 +1735,16 @@ export function initDefaultSlashCommands() { | ||
| 1737 | 1735 | ], |
| 1738 | 1736 | }), |
| 1739 | 1737 | new SlashCommandNamedArgument( |
| 1740 | 1738 | 'system', 't`system prompt at the start'`, [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.VARIABLE_NAME], false, |
| 1741 | 1739 | ), |
| 1742 | 1740 | new SlashCommandNamedArgument( |
| 1743 | 1741 | 'prefill', 't`prefill prompt at the end'`, [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.VARIABLE_NAME], false, |
| 1744 | 1742 | ), |
| 1745 | 1743 | new SlashCommandNamedArgument( |
| 1746 | 1744 | 'length', 't`API response length in tokens'`, [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.VARIABLE_NAME], false, |
| 1747 | 1745 | ), |
| 1748 | 1746 | new SlashCommandNamedArgument( |
| 1749 | 1747 | 'trim', 't`trim {{user}} and {{char}} prefixes from the output'`, [ARGUMENT_TYPE.BOOLEAN], false, false, 'on', commonEnumProviders.boolean('onOff')(), |
| 1750 | 1748 | ), |
| 1751 | 1749 | ], |
| 1752 | 1750 | unnamedArgumentList: [ |
| @@ -1756,31 +1754,31 @@ export function initDefaultSlashCommands() { | ||
| 1756 | 1754 | ], |
| 1757 | 1755 | helpString: ` |
| 1758 | 1756 | <div> |
| 1759 | 1757 | ${t`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.`} |
| 1760 | 1758 | </div> |
| 1761 | 1759 | <div> |
| 1762 | 1760 | ${t`Use instruct=off to skip instruct formatting, e.g. <pre><code>/genraw instruct=off Why is the sky blue?</code></pre>`} |
| 1763 | 1761 | </div> |
| 1764 | 1762 | <div> |
| 1765 | 1763 | ${t`Use stop=... with a JSON-serialized array to add one-time custom stop strings, e.g. <pre><code>/genraw stop=["\\n"] Say hi</code></pre>`} |
| 1766 | 1764 | </div> |
| 1767 | 1765 | <div> |
| 1768 | 1766 | ${t`"as" argument controls the role of the output prompt: system (default) or char. "system" argument adds an (optional) system prompt at the start.`} |
| 1769 | 1767 | </div> |
| 1770 | 1768 | <div> |
| 1771 | 1769 | ${t`If "length" argument is provided as a number in tokens, allows to temporarily override an API response length.`} |
| 1772 | 1770 | </div> |
| 1773 | 1771 | `, |
| 1774 | 1772 | })); |
| 1775 | 1773 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1776 | 1774 | name: 'addswipe', |
| 1777 | 1775 | callback: addSwipeCallback, |
| 1778 | 1776 | returns: 't`the new swipe id'`, |
| 1779 | 1777 | aliases: ['swipeadd'], |
| 1780 | 1778 | namedArgumentList: [ |
| 1781 | 1779 | SlashCommandNamedArgument.fromProps({ |
| 1782 | 1780 | name: 'switch', |
| 1783 | 1781 | description: 't`switch to the new swipe'`, |
| 1784 | 1782 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 1785 | 1783 | enumList: commonEnumProviders.boolean()(), |
| 1786 | 1784 | }), |
| @@ -1792,10 +1790,10 @@ export function initDefaultSlashCommands() { | ||
| 1792 | 1790 | ], |
| 1793 | 1791 | helpString: ` |
| 1794 | 1792 | <div> |
| 1795 | 1793 | ${t`Adds a swipe to the last chat message.`} |
| 1796 | 1794 | </div> |
| 1797 | 1795 | <div> |
| 1798 | 1796 | ${t`Use switch=true to switch to directly switch to the new swipe.`} |
| 1799 | 1797 | </div>`, |
| 1800 | 1798 | })); |
| 1801 | 1799 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| @@ -1804,14 +1802,13 @@ export function initDefaultSlashCommands() { | ||
| 1804 | 1802 | const stopped = stopGeneration(); |
| 1805 | 1803 | return String(stopped); |
| 1806 | 1804 | }, |
| 1807 | 1805 | returns: 't`true/false, whether the generation was running and got stopped'`, |
| 1808 | 1806 | helpString: ` |
| 1809 | 1807 | <div> |
| 1810 | 1808 | ${t`Stops the generation and any streaming if it is currently running.`} |
| 1811 | 1809 | </div> |
| 1812 | 1810 | <div> |
| 1813 | 1811 | ${t`Note: This command cannot be executed from the chat input, as sending any message or script from there is blocked during generation. But it can be executed via automations or QR scripts/buttons.`} |
| 1814 | - But it can be executed via automations or QR scripts/buttons. | |
| 1815 | 1812 | </div> |
| 1816 | 1813 | `, |
| 1817 | 1814 | aliases: ['generate-stop'], |
| @@ -1822,27 +1819,27 @@ export function initDefaultSlashCommands() { | ||
| 1822 | 1819 | namedArgumentList: [ |
| 1823 | 1820 | SlashCommandNamedArgument.fromProps({ |
| 1824 | 1821 | name: 'quiet', |
| 1825 | 1822 | description: 't`Whether to suppress the toast message notifying about the /abort call.'`, |
| 1826 | 1823 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 1827 | 1824 | defaultValue: 'true', |
| 1828 | 1825 | }), |
| 1829 | 1826 | ], |
| 1830 | 1827 | unnamedArgumentList: [ |
| 1831 | 1828 | SlashCommandArgument.fromProps({ |
| 1832 | 1829 | description: 't`The reason for aborting command execution. Shown when quiet=false'`, |
| 1833 | 1830 | typeList: [ARGUMENT_TYPE.STRING], |
| 1834 | 1831 | }), |
| 1835 | 1832 | ], |
| 1836 | 1833 | helpString: 't`Aborts the slash command batch execution.'`, |
| 1837 | 1834 | })); |
| 1838 | 1835 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 1839 | 1836 | name: 'fuzzy', |
| 1840 | 1837 | callback: fuzzyCallback, |
| 1841 | 1838 | returns: 't`matching item'`, |
| 1842 | 1839 | namedArgumentList: [ |
| 1843 | 1840 | SlashCommandNamedArgument.fromProps({ |
| 1844 | 1841 | name: 'list', |
| 1845 | 1842 | description: 't`list of items to match against'`, |
| 1846 | 1843 | acceptsMultiple: false, |
| 1847 | 1844 | isRequired: true, |
| 1848 | 1845 | typeList: [ARGUMENT_TYPE.LIST, ARGUMENT_TYPE.VARIABLE_NAME], |
| @@ -1850,7 +1847,7 @@ export function initDefaultSlashCommands() { | ||
| 1850 | 1847 | }), |
| 1851 | 1848 | SlashCommandNamedArgument.fromProps({ |
| 1852 | 1849 | name: 'threshold', |
| 1853 | 1850 | description: 't`fuzzy match threshold (0.0 to 1.0)'`, |
| 1854 | 1851 | typeList: [ARGUMENT_TYPE.NUMBER], |
| 1855 | 1852 | isRequired: false, |
| 1856 | 1853 | defaultValue: '0.4', |
| @@ -1858,44 +1855,43 @@ export function initDefaultSlashCommands() { | ||
| 1858 | 1855 | }), |
| 1859 | 1856 | SlashCommandNamedArgument.fromProps({ |
| 1860 | 1857 | name: 'mode', |
| 1861 | 1858 | description: 't`fuzzy match mode'`, |
| 1862 | 1859 | typeList: [ARGUMENT_TYPE.STRING], |
| 1863 | 1860 | isRequired: false, |
| 1864 | 1861 | defaultValue: 'first', |
| 1865 | 1862 | acceptsMultiple: false, |
| 1866 | 1863 | enumList: [ |
| 1867 | 1864 | new SlashCommandEnumValue('first', 't`first match below the threshold'`, enumTypes.enum, enumIcons.default), |
| 1868 | 1865 | new SlashCommandEnumValue('best', 't`best match below the threshold'`, enumTypes.enum, enumIcons.default), |
| 1869 | 1866 | ], |
| 1870 | 1867 | }), |
| 1871 | 1868 | ], |
| 1872 | 1869 | unnamedArgumentList: [ |
| 1873 | 1870 | new SlashCommandArgument( |
| 1874 | 1871 | 't`text to search'`, [ARGUMENT_TYPE.STRING], true, |
| 1875 | 1872 | ), |
| 1876 | 1873 | ], |
| 1877 | 1874 | helpString: ` |
| 1878 | 1875 | <div> |
| 1879 | 1876 | ${t`Performs a fuzzy match of each item in the <code>list</code> against the <code>text to search</code>. If any item matches, then its name is returned. If no item matches the text, no value is returned.`} |
| 1880 | - If any item matches, then its name is returned. If no item matches the text, no value is returned. | |
| 1881 | 1877 | </div> |
| 1882 | 1878 | <div> |
| 1883 | 1879 | ${t`The optional <code>threshold</code> (default is 0.4) allows control over the match strictness.`} |
| 1884 | 1880 | ${t`A low value (min 0.0) means the match is very strict.`} |
| 1885 | 1881 | ${t`At 1.0 (max) the match is very loose and will match anything.`} |
| 1886 | 1882 | </div> |
| 1887 | 1883 | <div> |
| 1888 | 1884 | ${t`The optional <code>mode</code> argument allows to control the behavior when multiple items match the text.`} |
| 1889 | 1885 | <ul> |
| 1890 | 1886 | <li>${t`<code>first</code> (default) returns the first match below the threshold.`}</li> |
| 1891 | 1887 | <li>${t`<code>best</code> returns the best match below the threshold.`}</li> |
| 1892 | 1888 | </ul> |
| 1893 | 1889 | </div> |
| 1894 | 1890 | <div> |
| 1895 | 1891 | ${t`The returned value passes to the next command through the pipe.`} |
| 1896 | 1892 | </div> |
| 1897 | 1893 | <div> |
| 1898 | 1894 | <strong>${t`Example:`}</strong> |
| 1899 | 1895 | <ul> |
| 1900 | 1896 | <li> |
| 1901 | 1897 | <pre><code>/fuzzy list=["a","b","c"] threshold=0.4 abc</code></pre> |
| @@ -1908,23 +1904,23 @@ export function initDefaultSlashCommands() { | ||
| 1908 | 1904 | name: 'pass', |
| 1909 | 1905 | callback: (_, arg) => { |
| 1910 | 1906 | // We do not support arrays of closures. Arrays of strings will be send as JSON |
| 1911 | 1907 | if (Array.isArray(arg) && arg.some(x => x instanceof SlashCommandClosure)) throw new Error('t`Command /pass does not support multiple closures'`); |
| 1912 | 1908 | if (Array.isArray(arg)) return JSON.stringify(arg); |
| 1913 | 1909 | return arg; |
| 1914 | 1910 | }, |
| 1915 | 1911 | returns: 't`the provided value'`, |
| 1916 | 1912 | unnamedArgumentList: [ |
| 1917 | 1913 | new SlashCommandArgument( |
| 1918 | 1914 | 't`text'`, [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.BOOLEAN, ARGUMENT_TYPE.LIST, ARGUMENT_TYPE.DICTIONARY, ARGUMENT_TYPE.CLOSURE], true, |
| 1919 | 1915 | ), |
| 1920 | 1916 | ], |
| 1921 | 1917 | aliases: ['return'], |
| 1922 | 1918 | helpString: ` |
| 1923 | 1919 | <div> |
| 1924 | 1920 | <pre><span class="monospace">/pass (text)</span> – ${t`passes the text to the next command through the pipe.`}</pre> |
| 1925 | 1921 | </div> |
| 1926 | 1922 | <div> |
| 1927 | 1923 | <strong>${t`Example:`}</strong> |
| 1928 | 1924 | <ul> |
| 1929 | 1925 | <li><pre><code>/pass Hello world</code></pre></li> |
| 1930 | 1926 | </ul> |
| @@ -1937,15 +1933,15 @@ export function initDefaultSlashCommands() { | ||
| 1937 | 1933 | aliases: ['wait', 'sleep'], |
| 1938 | 1934 | unnamedArgumentList: [ |
| 1939 | 1935 | new SlashCommandArgument( |
| 1940 | 1936 | 't`milliseconds'`, [ARGUMENT_TYPE.NUMBER], true, |
| 1941 | 1937 | ), |
| 1942 | 1938 | ], |
| 1943 | 1939 | helpString: ` |
| 1944 | 1940 | <div> |
| 1945 | 1941 | ${t`Delays the next command in the pipe by the specified number of milliseconds.`} |
| 1946 | 1942 | </div> |
| 1947 | 1943 | <div> |
| 1948 | 1944 | <strong>${t`Example:`}</strong> |
| 1949 | 1945 | <ul> |
| 1950 | 1946 | <li> |
| 1951 | 1947 | <pre><code>/delay 1000</code></pre> |
| @@ -1958,59 +1954,59 @@ export function initDefaultSlashCommands() { | ||
| 1958 | 1954 | name: 'input', |
| 1959 | 1955 | aliases: ['prompt'], |
| 1960 | 1956 | callback: inputCallback, |
| 1961 | 1957 | returns: 't`user input'`, |
| 1962 | 1958 | namedArgumentList: [ |
| 1963 | 1959 | SlashCommandNamedArgument.fromProps({ |
| 1964 | 1960 | name: 'default', |
| 1965 | 1961 | description: 't`default value of the input field'`, |
| 1966 | 1962 | typeList: [ARGUMENT_TYPE.STRING], |
| 1967 | 1963 | }), |
| 1968 | 1964 | SlashCommandNamedArgument.fromProps({ |
| 1969 | 1965 | name: 'large', |
| 1970 | 1966 | description: 't`popup window will be shown larger in height, with more space for content (input field needs to be sized via \'rows\' argument)'`, |
| 1971 | 1967 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 1972 | 1968 | defaultValue: 'off', |
| 1973 | 1969 | enumList: commonEnumProviders.boolean('onOff')(), |
| 1974 | 1970 | }), |
| 1975 | 1971 | SlashCommandNamedArgument.fromProps({ |
| 1976 | 1972 | name: 'wide', |
| 1977 | 1973 | description: 't`popup window will be shown wider, with a wider input field'`, |
| 1978 | 1974 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 1979 | 1975 | defaultValue: 'off', |
| 1980 | 1976 | enumList: commonEnumProviders.boolean('onOff')(), |
| 1981 | 1977 | }), |
| 1982 | 1978 | SlashCommandNamedArgument.fromProps({ |
| 1983 | 1979 | name: 'okButton', |
| 1984 | 1980 | description: 't`text for the ok button'`, |
| 1985 | 1981 | typeList: [ARGUMENT_TYPE.STRING], |
| 1986 | 1982 | defaultValue: 'Ok', |
| 1987 | 1983 | }), |
| 1988 | 1984 | SlashCommandNamedArgument.fromProps({ |
| 1989 | 1985 | name: 'rows', |
| 1990 | 1986 | description: 't`number of rows for the input field (lines being displayed)'`, |
| 1991 | 1987 | typeList: [ARGUMENT_TYPE.NUMBER], |
| 1992 | 1988 | }), |
| 1993 | 1989 | SlashCommandNamedArgument.fromProps({ |
| 1994 | 1990 | name: 'onSuccess', |
| 1995 | 1991 | description: 't`closure to execute when the ok button is clicked or the input is closed as successful (via Enter, etc)'`, |
| 1996 | 1992 | typeList: [ARGUMENT_TYPE.CLOSURE], |
| 1997 | 1993 | }), |
| 1998 | 1994 | SlashCommandNamedArgument.fromProps({ |
| 1999 | 1995 | name: 'onCancel', |
| 2000 | 1996 | description: 't`closure to execute when the cancel button is clicked or the input is closed as cancelled (via Escape, etc)'`, |
| 2001 | 1997 | typeList: [ARGUMENT_TYPE.CLOSURE], |
| 2002 | 1998 | }), |
| 2003 | 1999 | ], |
| 2004 | 2000 | unnamedArgumentList: [ |
| 2005 | 2001 | SlashCommandArgument.fromProps({ |
| 2006 | 2002 | description: 't`text to display'`, |
| 2007 | 2003 | typeList: [ARGUMENT_TYPE.STRING], |
| 2008 | 2004 | }), |
| 2009 | 2005 | ], |
| 2010 | 2006 | helpString: ` |
| 2011 | 2007 | <div> |
| 2012 | 2008 | ${t`Shows a popup with the provided text and an input field.`} |
| 2013 | 2009 | ${t`The <code>default</code> argument is the default value of the input field, and the text argument is the text to display.`} |
| 2014 | 2010 | </div> |
| 2015 | 2011 | `, |
| 2016 | 2012 | })); |
| @@ -2018,15 +2014,15 @@ export function initDefaultSlashCommands() { | ||
| 2018 | 2014 | name: 'run', |
| 2019 | 2015 | aliases: ['call', 'exec'], |
| 2020 | 2016 | callback: runCallback, |
| 2021 | 2017 | returns: 't`result of the executed closure of QR'`, |
| 2022 | 2018 | namedArgumentList: [ |
| 2023 | 2019 | new SlashCommandNamedArgument( |
| 2024 | 2020 | 'args', 't`named arguments'`, [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.BOOLEAN, ARGUMENT_TYPE.LIST, ARGUMENT_TYPE.DICTIONARY], false, true, |
| 2025 | 2021 | ), |
| 2026 | 2022 | ], |
| 2027 | 2023 | unnamedArgumentList: [ |
| 2028 | 2024 | SlashCommandArgument.fromProps({ |
| 2029 | 2025 | description: 't`scoped variable or qr label'`, |
| 2030 | 2026 | typeList: [ARGUMENT_TYPE.VARIABLE_NAME, ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.CLOSURE], |
| 2031 | 2027 | isRequired: true, |
| 2032 | 2028 | enumProvider: (executor, scope) => [ |
| @@ -2037,8 +2033,8 @@ export function initDefaultSlashCommands() { | ||
| 2037 | 2033 | ], |
| 2038 | 2034 | helpString: ` |
| 2039 | 2035 | <div> |
| 2040 | 2036 | ${t`Runs a closure from a scoped variable, or a Quick Reply with the specified name from a currently active preset or from another preset.`} |
| 2041 | 2037 | ${t`Named arguments can be referenced in a QR with <code>{{arg::key}}</code>.`} |
| 2042 | 2038 | </div> |
| 2043 | 2039 | `, |
| 2044 | 2040 | })); |
| @@ -2048,14 +2044,14 @@ export function initDefaultSlashCommands() { | ||
| 2048 | 2044 | aliases: ['message'], |
| 2049 | 2045 | namedArgumentList: [ |
| 2050 | 2046 | new SlashCommandNamedArgument( |
| 2051 | 2047 | 'names', 't`show message author names'`, [ARGUMENT_TYPE.BOOLEAN], false, false, 'off', commonEnumProviders.boolean('onOff')(), |
| 2052 | 2048 | ), |
| 2053 | 2049 | new SlashCommandNamedArgument( |
| 2054 | 2050 | 'hidden', 't`include hidden messages'`, [ARGUMENT_TYPE.BOOLEAN], false, false, 'on', commonEnumProviders.boolean('onOff')(), |
| 2055 | 2051 | ), |
| 2056 | 2052 | SlashCommandNamedArgument.fromProps({ |
| 2057 | 2053 | name: 'role', |
| 2058 | 2054 | description: 't`filter messages by role'`, |
| 2059 | 2055 | typeList: [ARGUMENT_TYPE.STRING], |
| 2060 | 2056 | enumList: [ |
| 2061 | 2057 | new SlashCommandEnumValue('system', null, enumTypes.enum, enumIcons.system), |
| @@ -2066,33 +2062,33 @@ export function initDefaultSlashCommands() { | ||
| 2066 | 2062 | ], |
| 2067 | 2063 | unnamedArgumentList: [ |
| 2068 | 2064 | SlashCommandArgument.fromProps({ |
| 2069 | 2065 | description: 't`message index (starts with 0) or range'`, |
| 2070 | 2066 | typeList: [ARGUMENT_TYPE.NUMBER, ARGUMENT_TYPE.RANGE], |
| 2071 | 2067 | isRequired: true, |
| 2072 | 2068 | enumProvider: commonEnumProviders.messages(), |
| 2073 | 2069 | }), |
| 2074 | 2070 | ], |
| 2075 | 2071 | returns: 't`the specified message or range of messages as a string'`, |
| 2076 | 2072 | helpString: ` |
| 2077 | 2073 | <div> |
| 2078 | 2074 | ${t`Returns the specified message or range of messages as a string.`} |
| 2079 | 2075 | </div> |
| 2080 | 2076 | <div> |
| 2081 | 2077 | ${t`Use the <code>hidden=off</code> argument to exclude hidden messages.`} |
| 2082 | 2078 | </div> |
| 2083 | 2079 | <div> |
| 2084 | 2080 | ${t`Use the <code>role</code> argument to filter messages by role. Possible values are: system, assistant, user.`} |
| 2085 | 2081 | </div> |
| 2086 | 2082 | <div> |
| 2087 | 2083 | <strong>${t`Examples:`}</strong> |
| 2088 | 2084 | <ul> |
| 2089 | 2085 | <li> |
| 2090 | 2086 | <pre><code>/messages 10</code></pre> |
| 2091 | 2087 | ${t`Returns the 10th message.`} |
| 2092 | 2088 | </li> |
| 2093 | 2089 | <li> |
| 2094 | 2090 | <pre><code>/messages names=on 5-10</code></pre> |
| 2095 | 2091 | ${t`Returns messages 5 through 10 with author names.`} |
| 2096 | 2092 | </li> |
| 2097 | 2093 | </ul> |
| 2098 | 2094 | </div> |
| @@ -2103,15 +2099,15 @@ export function initDefaultSlashCommands() { | ||
| 2103 | 2099 | callback: setInputCallback, |
| 2104 | 2100 | unnamedArgumentList: [ |
| 2105 | 2101 | new SlashCommandArgument( |
| 2106 | 2102 | 't`text'`, [ARGUMENT_TYPE.STRING], true, |
| 2107 | 2103 | ), |
| 2108 | 2104 | ], |
| 2109 | 2105 | helpString: ` |
| 2110 | 2106 | <div> |
| 2111 | 2107 | ${t`Sets the user input to the specified text and passes it to the next command through the pipe.`} |
| 2112 | 2108 | </div> |
| 2113 | 2109 | <div> |
| 2114 | 2110 | <strong>${t`Example:`}</strong> |
| 2115 | 2111 | <ul> |
| 2116 | 2112 | <li> |
| 2117 | 2113 | <pre><code>/setinput Hello world</code></pre> |
| @@ -2123,57 +2119,57 @@ export function initDefaultSlashCommands() { | ||
| 2123 | 2119 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 2124 | 2120 | name: 'popup', |
| 2125 | 2121 | callback: popupCallback, |
| 2126 | 2122 | returns: 't`popup text'`, |
| 2127 | 2123 | namedArgumentList: [ |
| 2128 | 2124 | SlashCommandNamedArgument.fromProps({ |
| 2129 | 2125 | name: 'scroll', |
| 2130 | 2126 | description: 't`allows vertical scrolling of the content'`, |
| 2131 | 2127 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 2132 | 2128 | enumList: commonEnumProviders.boolean('trueFalse')(), |
| 2133 | 2129 | defaultValue: 'true', |
| 2134 | 2130 | }), |
| 2135 | 2131 | SlashCommandNamedArgument.fromProps({ |
| 2136 | 2132 | name: 'large', |
| 2137 | 2133 | description: 't`show large popup'`, |
| 2138 | 2134 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 2139 | 2135 | enumList: commonEnumProviders.boolean('trueFalse')(), |
| 2140 | 2136 | defaultValue: 'false', |
| 2141 | 2137 | }), |
| 2142 | 2138 | SlashCommandNamedArgument.fromProps({ |
| 2143 | 2139 | name: 'wide', |
| 2144 | 2140 | description: 't`show wide popup'`, |
| 2145 | 2141 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 2146 | 2142 | enumList: commonEnumProviders.boolean('trueFalse')(), |
| 2147 | 2143 | defaultValue: 'false', |
| 2148 | 2144 | }), |
| 2149 | 2145 | SlashCommandNamedArgument.fromProps({ |
| 2150 | 2146 | name: 'wider', |
| 2151 | 2147 | description: 't`show wider popup'`, |
| 2152 | 2148 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 2153 | 2149 | enumList: commonEnumProviders.boolean('trueFalse')(), |
| 2154 | 2150 | defaultValue: 'false', |
| 2155 | 2151 | }), |
| 2156 | 2152 | SlashCommandNamedArgument.fromProps({ |
| 2157 | 2153 | name: 'transparent', |
| 2158 | 2154 | description: 't`show transparent popup'`, |
| 2159 | 2155 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 2160 | 2156 | enumList: commonEnumProviders.boolean('trueFalse')(), |
| 2161 | 2157 | defaultValue: 'false', |
| 2162 | 2158 | }), |
| 2163 | 2159 | SlashCommandNamedArgument.fromProps({ |
| 2164 | 2160 | name: 'okButton', |
| 2165 | 2161 | description: 't`text for the OK button'`, |
| 2166 | 2162 | typeList: [ARGUMENT_TYPE.STRING], |
| 2167 | 2163 | defaultValue: 'OK', |
| 2168 | 2164 | }), |
| 2169 | 2165 | SlashCommandNamedArgument.fromProps({ |
| 2170 | 2166 | name: 'cancelButton', |
| 2171 | 2167 | description: 't`text for the Cancel button'`, |
| 2172 | 2168 | typeList: [ARGUMENT_TYPE.STRING], |
| 2173 | 2169 | }), |
| 2174 | 2170 | SlashCommandNamedArgument.fromProps({ |
| 2175 | 2171 | name: 'result', |
| 2176 | 2172 | description: 't`if enabled, returns the popup result (as an integer) instead of the popup text. Resolves to 1 for OK and 0 cancel button, empty string for exiting out.'`, |
| 2177 | 2173 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 2178 | 2174 | enumList: commonEnumProviders.boolean('trueFalse')(), |
| 2179 | 2175 | defaultValue: 'false', |
| @@ -2181,18 +2177,18 @@ export function initDefaultSlashCommands() { | ||
| 2181 | 2177 | ], |
| 2182 | 2178 | unnamedArgumentList: [ |
| 2183 | 2179 | SlashCommandArgument.fromProps({ |
| 2184 | 2180 | description: 't`popup text'`, |
| 2185 | 2181 | typeList: [ARGUMENT_TYPE.STRING], |
| 2186 | 2182 | isRequired: true, |
| 2187 | 2183 | }), |
| 2188 | 2184 | ], |
| 2189 | 2185 | helpString: ` |
| 2190 | 2186 | <div> |
| 2191 | 2187 | ${t`Shows a blocking popup with the specified text and buttons.`} |
| 2192 | 2188 | ${t`Returns the popup text.`} |
| 2193 | 2189 | </div> |
| 2194 | 2190 | <div> |
| 2195 | 2191 | <strong>${t`Example:`}</strong> |
| 2196 | 2192 | <ul> |
| 2197 | 2193 | <li> |
| 2198 | 2194 | <pre><code>/popup large=on wide=on okButton="Confirm" Please confirm this action.</code></pre> |
| @@ -2207,17 +2203,17 @@ export function initDefaultSlashCommands() { | ||
| 2207 | 2203 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 2208 | 2204 | name: 'buttons', |
| 2209 | 2205 | callback: buttonsCallback, |
| 2210 | 2206 | returns: 't`clicked button label (or array of labels if multiple is enabled)'`, |
| 2211 | 2207 | namedArgumentList: [ |
| 2212 | 2208 | SlashCommandNamedArgument.fromProps({ |
| 2213 | 2209 | name: 'labels', |
| 2214 | 2210 | description: 't`button labels'`, |
| 2215 | 2211 | typeList: [ARGUMENT_TYPE.LIST], |
| 2216 | 2212 | isRequired: true, |
| 2217 | 2213 | }), |
| 2218 | 2214 | SlashCommandNamedArgument.fromProps({ |
| 2219 | 2215 | name: 'multiple', |
| 2220 | 2216 | description: 't`if enabled multiple buttons can be clicked/toggled, and all clicked buttons are returned as an array'`, |
| 2221 | 2217 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 2222 | 2218 | enumList: commonEnumProviders.boolean('trueFalse')(), |
| 2223 | 2219 | defaultValue: 'false', |
| @@ -2225,18 +2221,18 @@ export function initDefaultSlashCommands() { | ||
| 2225 | 2221 | ], |
| 2226 | 2222 | unnamedArgumentList: [ |
| 2227 | 2223 | SlashCommandArgument.fromProps({ |
| 2228 | 2224 | description: 't`text'`, |
| 2229 | 2225 | typeList: [ARGUMENT_TYPE.STRING], |
| 2230 | 2226 | isRequired: true, |
| 2231 | 2227 | }), |
| 2232 | 2228 | ], |
| 2233 | 2229 | helpString: ` |
| 2234 | 2230 | <div> |
| 2235 | 2231 | ${t`Shows a blocking popup with the specified text and buttons.`} |
| 2236 | 2232 | ${t`Returns the clicked button label into the pipe or empty string if canceled.`} |
| 2237 | 2233 | </div> |
| 2238 | 2234 | <div> |
| 2239 | 2235 | <strong>${t`Example:`}</strong> |
| 2240 | 2236 | <ul> |
| 2241 | 2237 | <li> |
| 2242 | 2238 | <pre><code>/buttons labels=["Yes","No"] Do you want to continue?</code></pre> |
| @@ -2248,14 +2244,14 @@ export function initDefaultSlashCommands() { | ||
| 2248 | 2244 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 2249 | 2245 | name: 'trimtokens', |
| 2250 | 2246 | callback: trimTokensCallback, |
| 2251 | 2247 | returns: 't`trimmed text'`, |
| 2252 | 2248 | namedArgumentList: [ |
| 2253 | 2249 | new SlashCommandNamedArgument( |
| 2254 | 2250 | 'limit', 't`number of tokens to keep'`, [ARGUMENT_TYPE.NUMBER], true, |
| 2255 | 2251 | ), |
| 2256 | 2252 | SlashCommandNamedArgument.fromProps({ |
| 2257 | 2253 | name: 'direction', |
| 2258 | 2254 | description: 't`trim direction'`, |
| 2259 | 2255 | typeList: [ARGUMENT_TYPE.STRING], |
| 2260 | 2256 | isRequired: true, |
| 2261 | 2257 | enumList: [ |
| @@ -2266,15 +2262,15 @@ export function initDefaultSlashCommands() { | ||
| 2266 | 2262 | ], |
| 2267 | 2263 | unnamedArgumentList: [ |
| 2268 | 2264 | new SlashCommandArgument( |
| 2269 | 2265 | 't`text'`, [ARGUMENT_TYPE.STRING], false, |
| 2270 | 2266 | ), |
| 2271 | 2267 | ], |
| 2272 | 2268 | helpString: ` |
| 2273 | 2269 | <div> |
| 2274 | 2270 | ${t`Trims the start or end of text to the specified number of tokens.`} |
| 2275 | 2271 | </div> |
| 2276 | 2272 | <div> |
| 2277 | 2273 | <strong>${t`Example:`}</strong> |
| 2278 | 2274 | <ul> |
| 2279 | 2275 | <li> |
| 2280 | 2276 | <pre><code>/trimtokens limit=5 direction=start This is a long sentence with many words</code></pre> |
| @@ -2286,18 +2282,18 @@ export function initDefaultSlashCommands() { | ||
| 2286 | 2282 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 2287 | 2283 | name: 'trimstart', |
| 2288 | 2284 | callback: trimStartCallback, |
| 2289 | 2285 | returns: 't`trimmed text'`, |
| 2290 | 2286 | unnamedArgumentList: [ |
| 2291 | 2287 | new SlashCommandArgument( |
| 2292 | 2288 | 't`text'`, [ARGUMENT_TYPE.STRING], true, |
| 2293 | 2289 | ), |
| 2294 | 2290 | ], |
| 2295 | 2291 | helpString: ` |
| 2296 | 2292 | <div> |
| 2297 | 2293 | ${t`Trims the text to the start of the first full sentence.`} |
| 2298 | 2294 | </div> |
| 2299 | 2295 | <div> |
| 2300 | 2296 | <strong>${t`Example:`}</strong> |
| 2301 | 2297 | <ul> |
| 2302 | 2298 | <li> |
| 2303 | 2299 | <pre><code>/trimstart This is a sentence. And here is another sentence.</code></pre> |
| @@ -2309,38 +2305,38 @@ export function initDefaultSlashCommands() { | ||
| 2309 | 2305 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 2310 | 2306 | name: 'trimend', |
| 2311 | 2307 | callback: trimEndCallback, |
| 2312 | 2308 | returns: 't`trimmed text'`, |
| 2313 | 2309 | unnamedArgumentList: [ |
| 2314 | 2310 | new SlashCommandArgument( |
| 2315 | 2311 | 't`text'`, [ARGUMENT_TYPE.STRING], true, |
| 2316 | 2312 | ), |
| 2317 | 2313 | ], |
| 2318 | 2314 | helpString: 't`Trims the text to the end of the last full sentence.'`, |
| 2319 | 2315 | })); |
| 2320 | 2316 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 2321 | 2317 | name: 'inject', |
| 2322 | 2318 | returns: 't`injection ID'`, |
| 2323 | 2319 | callback: injectCallback, |
| 2324 | 2320 | namedArgumentList: [ |
| 2325 | 2321 | SlashCommandNamedArgument.fromProps({ |
| 2326 | 2322 | name: 'id', |
| 2327 | 2323 | description: 't`injection ID'`, |
| 2328 | 2324 | typeList: [ARGUMENT_TYPE.STRING], |
| 2329 | 2325 | isRequired: false, |
| 2330 | 2326 | enumProvider: commonEnumProviders.injects, |
| 2331 | 2327 | }), |
| 2332 | 2328 | new SlashCommandNamedArgument( |
| 2333 | 2329 | 'position', 't`injection position'`, [ARGUMENT_TYPE.STRING], false, false, 'after', ['before', 'after', 'chat', 'none'], |
| 2334 | 2330 | ), |
| 2335 | 2331 | new SlashCommandNamedArgument( |
| 2336 | 2332 | 'depth', 't`injection depth'`, [ARGUMENT_TYPE.NUMBER], false, false, '4', |
| 2337 | 2333 | ), |
| 2338 | 2334 | new SlashCommandNamedArgument( |
| 2339 | 2335 | 'scan', 't`include injection content into World Info scans'`, [ARGUMENT_TYPE.BOOLEAN], false, false, 'false', |
| 2340 | 2336 | ), |
| 2341 | 2337 | SlashCommandNamedArgument.fromProps({ |
| 2342 | 2338 | name: 'role', |
| 2343 | 2339 | description: 't`role for in-chat injections'`, |
| 2344 | 2340 | typeList: [ARGUMENT_TYPE.STRING], |
| 2345 | 2341 | isRequired: false, |
| 2346 | 2342 | enumList: [ |
| @@ -2350,11 +2346,11 @@ export function initDefaultSlashCommands() { | ||
| 2350 | 2346 | ], |
| 2351 | 2347 | }), |
| 2352 | 2348 | new SlashCommandNamedArgument( |
| 2353 | 2349 | 'ephemeral', 't`remove injection after generation'`, [ARGUMENT_TYPE.BOOLEAN], false, false, 'false', |
| 2354 | 2350 | ), |
| 2355 | 2351 | SlashCommandNamedArgument.fromProps({ |
| 2356 | 2352 | name: 'filter', |
| 2357 | 2353 | description: 't`if a filter is defined, an injection will only be performed if the closure returns true'`, |
| 2358 | 2354 | typeList: [ARGUMENT_TYPE.CLOSURE], |
| 2359 | 2355 | isRequired: false, |
| 2360 | 2356 | acceptsMultiple: false, |
| @@ -2362,20 +2358,20 @@ export function initDefaultSlashCommands() { | ||
| 2362 | 2358 | ], |
| 2363 | 2359 | unnamedArgumentList: [ |
| 2364 | 2360 | new SlashCommandArgument( |
| 2365 | 2361 | 't`text'`, [ARGUMENT_TYPE.STRING], false, |
| 2366 | 2362 | ), |
| 2367 | 2363 | ], |
| 2368 | 2364 | helpString: 't`Injects a text into the LLM prompt for the current chat. Requires a unique injection ID (will be auto-generated if not provided). Positions: "before" main prompt, "after" main prompt, in-"chat", hidden with "none" (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). Hidden injects in "none" position are not inserted into the prompt but can be used for triggering WI entries. Returns the injection ID.'`, |
| 2369 | 2365 | })); |
| 2370 | 2366 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 2371 | 2367 | name: 'listinjects', |
| 2372 | 2368 | callback: listInjectsCallback, |
| 2373 | 2369 | helpString: 't`Lists all script injections for the current chat. Displays injects in a popup by default. Use the <code>return</code> argument to change the return type.'`, |
| 2374 | 2370 | returns: 'Optionallst`Optionally the JSON object of script injections'`, |
| 2375 | 2371 | namedArgumentList: [ |
| 2376 | 2372 | SlashCommandNamedArgument.fromProps({ |
| 2377 | 2373 | name: 'return', |
| 2378 | 2374 | description: 't`The way how you want the return value to be provided'`, |
| 2379 | 2375 | typeList: [ARGUMENT_TYPE.STRING], |
| 2380 | 2376 | defaultValue: 'popup-html', |
| 2381 | 2377 | enumList: slashCommandReturnHelper.enumList({ allowPipe: false, allowObject: true, allowChat: true, allowPopup: true, allowTextVersion: false }), |
| @@ -2384,14 +2380,14 @@ export function initDefaultSlashCommands() { | ||
| 2384 | 2380 | // TODO remove some day |
| 2385 | 2381 | SlashCommandNamedArgument.fromProps({ |
| 2386 | 2382 | name: 'format', |
| 2387 | 2383 | description: 't`!!! DEPRECATED - use "return" instead !!! output format'`, |
| 2388 | 2384 | typeList: [ARGUMENT_TYPE.STRING], |
| 2389 | 2385 | isRequired: true, |
| 2390 | 2386 | forceEnum: true, |
| 2391 | 2387 | enumList: [ |
| 2392 | 2388 | new SlashCommandEnumValue('popup', 't`Show injects in a popup.'`, enumTypes.enum, enumIcons.default), |
| 2393 | 2389 | new SlashCommandEnumValue('chat', 't`Post a system message to the chat.'`, enumTypes.enum, enumIcons.default), |
| 2394 | 2390 | new SlashCommandEnumValue('none', 't`Just return the injects as a JSON object.'`, enumTypes.enum, enumIcons.default), |
| 2395 | 2391 | ], |
| 2396 | 2392 | }), |
| 2397 | 2393 | ], |
| @@ -2401,37 +2397,37 @@ export function initDefaultSlashCommands() { | ||
| 2401 | 2397 | aliases: ['flushinjects'], |
| 2402 | 2398 | unnamedArgumentList: [ |
| 2403 | 2399 | SlashCommandArgument.fromProps({ |
| 2404 | 2400 | description: 't`injection ID or a variable name pointing to ID'`, |
| 2405 | 2401 | typeList: [ARGUMENT_TYPE.STRING], |
| 2406 | 2402 | defaultValue: '', |
| 2407 | 2403 | enumProvider: commonEnumProviders.injects, |
| 2408 | 2404 | }), |
| 2409 | 2405 | ], |
| 2410 | 2406 | callback: flushInjectsCallback, |
| 2411 | 2407 | helpString: 't`Removes a script injection for the current chat. If no ID is provided, removes all script injections.'`, |
| 2412 | 2408 | })); |
| 2413 | 2409 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 2414 | 2410 | name: 'tokens', |
| 2415 | 2411 | callback: (_, text) => { |
| 2416 | 2412 | if (text instanceof SlashCommandClosure || Array.isArray(text)) throw new Error('t`Unnamed argument cannot be a closure for command /tokens'`); |
| 2417 | 2413 | return getTokenCountAsync(text).then(count => String(count)); |
| 2418 | 2414 | }, |
| 2419 | 2415 | returns: 't`number of tokens'`, |
| 2420 | 2416 | unnamedArgumentList: [ |
| 2421 | 2417 | new SlashCommandArgument( |
| 2422 | 2418 | 't`text'`, [ARGUMENT_TYPE.STRING], true, |
| 2423 | 2419 | ), |
| 2424 | 2420 | ], |
| 2425 | 2421 | helpString: 't`Counts the number of tokens in the provided text.'`, |
| 2426 | 2422 | })); |
| 2427 | 2423 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 2428 | 2424 | name: 'model', |
| 2429 | 2425 | callback: modelCallback, |
| 2430 | 2426 | returns: 't`current model'`, |
| 2431 | 2427 | namedArgumentList: [ |
| 2432 | 2428 | SlashCommandNamedArgument.fromProps({ |
| 2433 | 2429 | name: 'quiet', |
| 2434 | 2430 | description: 't`suppress the toast message on model change'`, |
| 2435 | 2431 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 2436 | 2432 | defaultValue: 'false', |
| 2437 | 2433 | enumList: commonEnumProviders.boolean('trueFalse')(), |
| @@ -2439,22 +2435,22 @@ export function initDefaultSlashCommands() { | ||
| 2439 | 2435 | ], |
| 2440 | 2436 | unnamedArgumentList: [ |
| 2441 | 2437 | SlashCommandArgument.fromProps({ |
| 2442 | 2438 | description: 't`model name'`, |
| 2443 | 2439 | typeList: [ARGUMENT_TYPE.STRING], |
| 2444 | 2440 | enumProvider: () => getModelOptions(true)?.options?.map(option => new SlashCommandEnumValue(option.value, option.value !== option.text ? option.text : null)) ?? [], |
| 2445 | 2441 | }), |
| 2446 | 2442 | ], |
| 2447 | 2443 | helpString: 't`Sets the model for the current API. Gets the current model name if no argument is provided.'`, |
| 2448 | 2444 | })); |
| 2449 | 2445 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 2450 | 2446 | name: 'getpromptentry', |
| 2451 | 2447 | aliases: ['getpromptentries'], |
| 2452 | 2448 | callback: getPromptEntryCallback, |
| 2453 | 2449 | returns: 't`true/false state of prompt(s)'`, |
| 2454 | 2450 | namedArgumentList: [ |
| 2455 | 2451 | SlashCommandNamedArgument.fromProps({ |
| 2456 | 2452 | name: 'identifier', |
| 2457 | 2453 | description: 't`Prompt entry identifier(s) to retrieve'`, |
| 2458 | 2454 | typeList: [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.LIST], |
| 2459 | 2455 | acceptsMultiple: true, |
| 2460 | 2456 | enumProvider: () => |
| @@ -2464,7 +2460,7 @@ export function initDefaultSlashCommands() { | ||
| 2464 | 2460 | }), |
| 2465 | 2461 | SlashCommandNamedArgument.fromProps({ |
| 2466 | 2462 | name: 'name', |
| 2467 | 2463 | description: 't`Prompt entry name(s) to retrieve'`, |
| 2468 | 2464 | typeList: [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.LIST], |
| 2469 | 2465 | acceptsMultiple: true, |
| 2470 | 2466 | enumProvider: () => |
| @@ -2474,7 +2470,7 @@ export function initDefaultSlashCommands() { | ||
| 2474 | 2470 | }), |
| 2475 | 2471 | SlashCommandNamedArgument.fromProps({ |
| 2476 | 2472 | name: 'return', |
| 2477 | 2473 | description: 't`Whether the return will be simple, a list, or a dict.'`, |
| 2478 | 2474 | typeList: [ARGUMENT_TYPE.STRING], |
| 2479 | 2475 | defaultValue: 'simple', |
| 2480 | 2476 | enumList: ['simple', 'list', 'dict'], |
| @@ -2482,10 +2478,10 @@ export function initDefaultSlashCommands() { | ||
| 2482 | 2478 | ], |
| 2483 | 2479 | helpString: ` |
| 2484 | 2480 | <div> |
| 2485 | 2481 | ${t`Gets the state of the specified prompt entries.`} |
| 2486 | 2482 | </div> |
| 2487 | 2483 | <div> |
| 2488 | 2484 | ${t`If <code>return</code> is <code>simple</code> (default) then the return will be a single value if only one value was retrieved; otherwise uses a dict (if the identifier parameter was used) or a list.`} |
| 2489 | 2485 | </div> |
| 2490 | 2486 | `, |
| 2491 | 2487 | })); |
| @@ -2496,7 +2492,7 @@ export function initDefaultSlashCommands() { | ||
| 2496 | 2492 | namedArgumentList: [ |
| 2497 | 2493 | SlashCommandNamedArgument.fromProps({ |
| 2498 | 2494 | name: 'identifier', |
| 2499 | 2495 | description: 't`Prompt entry identifier(s) to target'`, |
| 2500 | 2496 | typeList: [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.LIST], |
| 2501 | 2497 | acceptsMultiple: true, |
| 2502 | 2498 | enumProvider: () => { |
| @@ -2506,7 +2502,7 @@ export function initDefaultSlashCommands() { | ||
| 2506 | 2502 | }), |
| 2507 | 2503 | SlashCommandNamedArgument.fromProps({ |
| 2508 | 2504 | name: 'name', |
| 2509 | 2505 | description: 't`Prompt entry name(s) to target'`, |
| 2510 | 2506 | typeList: [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.LIST], |
| 2511 | 2507 | acceptsMultiple: true, |
| 2512 | 2508 | enumProvider: () => { |
| @@ -2517,7 +2513,7 @@ export function initDefaultSlashCommands() { | ||
| 2517 | 2513 | ], |
| 2518 | 2514 | unnamedArgumentList: [ |
| 2519 | 2515 | SlashCommandArgument.fromProps({ |
| 2520 | 2516 | description: 't`Set entry/entries on or off'`, |
| 2521 | 2517 | typeList: [ARGUMENT_TYPE.STRING], |
| 2522 | 2518 | isRequired: true, |
| 2523 | 2519 | acceptsMultiple: false, |
| @@ -2525,16 +2521,16 @@ export function initDefaultSlashCommands() { | ||
| 2525 | 2521 | enumList: commonEnumProviders.boolean('onOffToggle')(), |
| 2526 | 2522 | }), |
| 2527 | 2523 | ], |
| 2528 | 2524 | helpString: 't`Sets the specified prompt manager entry/entries on or off.'`, |
| 2529 | 2525 | })); |
| 2530 | 2526 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 2531 | 2527 | name: 'pick-icon', |
| 2532 | 2528 | callback: async () => ((await showFontAwesomePicker()) ?? false).toString(), |
| 2533 | 2529 | returns: 't`The chosen icon name or false if cancelled.'`, |
| 2534 | 2530 | helpString: ` |
| 2535 | 2531 | <div>${t`Opens a popup with all the available Font Awesome icons and returns the selected icon's name.`}</div> |
| 2536 | 2532 | <div> |
| 2537 | 2533 | <strong>${t`Example:`}</strong> |
| 2538 | 2534 | <ul> |
| 2539 | 2535 | <li> |
| 2540 | 2536 | <pre><code>/pick-icon |\n/if left={{pipe}} rule=eq right=false\n\telse={: /echo chosen icon: "{{pipe}}" :}\n\t{: /echo cancelled icon selection :}\n|</code></pre> |
| @@ -2546,12 +2542,12 @@ export function initDefaultSlashCommands() { | ||
| 2546 | 2542 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 2547 | 2543 | name: 'api-url', |
| 2548 | 2544 | callback: setApiUrlCallback, |
| 2549 | 2545 | returns: 't`the current API url'`, |
| 2550 | 2546 | aliases: ['server'], |
| 2551 | 2547 | namedArgumentList: [ |
| 2552 | 2548 | SlashCommandNamedArgument.fromProps({ |
| 2553 | 2549 | name: 'api', |
| 2554 | 2550 | description: 't`API to set/get the URL for - if not provided, current API is used'`, |
| 2555 | 2551 | typeList: [ARGUMENT_TYPE.STRING], |
| 2556 | 2552 | enumList: [ |
| 2557 | 2553 | new SlashCommandEnumValue('custom', 'custom OpenAI-compatible', enumTypes.getBasedOnIndex(UNIQUE_APIS.findIndex(x => x === 'openai')), 'O'), |
| @@ -2561,14 +2557,14 @@ export function initDefaultSlashCommands() { | ||
| 2561 | 2557 | }), |
| 2562 | 2558 | SlashCommandNamedArgument.fromProps({ |
| 2563 | 2559 | name: 'connect', |
| 2564 | 2560 | description: 't`Whether to auto-connect to the API after setting the URL'`, |
| 2565 | 2561 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 2566 | 2562 | defaultValue: 'true', |
| 2567 | 2563 | enumList: commonEnumProviders.boolean('trueFalse')(), |
| 2568 | 2564 | }), |
| 2569 | 2565 | SlashCommandNamedArgument.fromProps({ |
| 2570 | 2566 | name: 'quiet', |
| 2571 | 2567 | description: 't`suppress the toast message on API change'`, |
| 2572 | 2568 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 2573 | 2569 | defaultValue: 'false', |
| 2574 | 2570 | enumList: commonEnumProviders.boolean('trueFalse')(), |
| @@ -2576,31 +2572,29 @@ export function initDefaultSlashCommands() { | ||
| 2576 | 2572 | ], |
| 2577 | 2573 | unnamedArgumentList: [ |
| 2578 | 2574 | SlashCommandArgument.fromProps({ |
| 2579 | 2575 | description: 't`API url to connect to'`, |
| 2580 | 2576 | typeList: [ARGUMENT_TYPE.STRING], |
| 2581 | 2577 | }), |
| 2582 | 2578 | ], |
| 2583 | 2579 | helpString: ` |
| 2584 | 2580 | <div> |
| 2585 | 2581 | ${t`Set the API url / server url for the currently selected API, including the port. If no argument is provided, it will return the current API url.`} |
| 2586 | 2582 | </div> |
| 2587 | 2583 | <div> |
| 2588 | 2584 | ${t`If a manual API is provided to <b>set</b> the URL, make sure to set <code>connect=false</code>, as auto-connect only works for the currently selected API, or consider switching to it with <code>/api</code> first.`} |
| 2589 | - or consider switching to it with <code>/api</code> first. | |
| 2590 | 2585 | </div> |
| 2591 | 2586 | <div> |
| 2592 | 2587 | ${t`This slash command works for most of the Text Completion sources, KoboldAI Classic, and also Custom OpenAI compatible for the Chat Completion sources. If unsure which APIs are supported, check the auto-completion of the optional <code>api</code> argument of this command.`} |
| 2593 | - check the auto-completion of the optional <code>api</code> argument of this command. | |
| 2594 | 2588 | </div> |
| 2595 | 2589 | `, |
| 2596 | 2590 | })); |
| 2597 | 2591 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 2598 | 2592 | name: 'tokenizer', |
| 2599 | 2593 | callback: selectTokenizerCallback, |
| 2600 | 2594 | returns: 't`current tokenizer'`, |
| 2601 | 2595 | unnamedArgumentList: [ |
| 2602 | 2596 | SlashCommandArgument.fromProps({ |
| 2603 | 2597 | description: 't`tokenizer name'`, |
| 2604 | 2598 | typeList: [ARGUMENT_TYPE.STRING], |
| 2605 | 2599 | enumList: getAvailableTokenizers().map(tokenizer => |
| 2606 | 2600 | new SlashCommandEnumValue(tokenizer.tokenizerKey, tokenizer.tokenizerName, enumTypes.enum, enumIcons.default)), |
| @@ -2608,10 +2602,10 @@ export function initDefaultSlashCommands() { | ||
| 2608 | 2602 | ], |
| 2609 | 2603 | helpString: ` |
| 2610 | 2604 | <div> |
| 2611 | 2605 | ${t`Selects tokenizer by name. Gets the current tokenizer if no name is provided.`} |
| 2612 | 2606 | </div> |
| 2613 | 2607 | <div> |
| 2614 | 2608 | <strong>${t`Available tokenizers:`}</strong> |
| 2615 | 2609 | <pre><code>${getAvailableTokenizers().map(t => t.tokenizerKey).join(', ')}</code></pre> |
| 2616 | 2610 | </div> |
| 2617 | 2611 | `, |
| @@ -2620,58 +2614,58 @@ export function initDefaultSlashCommands() { | ||
| 2620 | 2614 | name: 'upper', |
| 2621 | 2615 | aliases: ['uppercase', 'to-upper'], |
| 2622 | 2616 | callback: (_, text) => typeof text === 'string' ? text.toUpperCase() : '', |
| 2623 | 2617 | returns: 't`uppercase string'`, |
| 2624 | 2618 | unnamedArgumentList: [ |
| 2625 | 2619 | new SlashCommandArgument( |
| 2626 | 2620 | 't`text to affect'`, [ARGUMENT_TYPE.STRING], true, false, |
| 2627 | 2621 | ), |
| 2628 | 2622 | ], |
| 2629 | 2623 | helpString: 't`Converts the provided string to uppercase.'`, |
| 2630 | 2624 | })); |
| 2631 | 2625 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 2632 | 2626 | name: 'lower', |
| 2633 | 2627 | aliases: ['lowercase', 'to-lower'], |
| 2634 | 2628 | callback: (_, text) => typeof text === 'string' ? text.toLowerCase() : '', |
| 2635 | 2629 | returns: 't`lowercase string'`, |
| 2636 | 2630 | unnamedArgumentList: [ |
| 2637 | 2631 | new SlashCommandArgument( |
| 2638 | 2632 | 't`text to affect'`, [ARGUMENT_TYPE.STRING], true, false, |
| 2639 | 2633 | ), |
| 2640 | 2634 | ], |
| 2641 | 2635 | helpString: 't`Converts the provided string to lowercase.'`, |
| 2642 | 2636 | })); |
| 2643 | 2637 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 2644 | 2638 | name: 'substr', |
| 2645 | 2639 | aliases: ['substring'], |
| 2646 | 2640 | callback: (arg, text) => typeof text === 'string' ? text.slice(...[Number(arg.start), arg.end && Number(arg.end)]) : '', |
| 2647 | 2641 | returns: 't`substring'`, |
| 2648 | 2642 | namedArgumentList: [ |
| 2649 | 2643 | new SlashCommandNamedArgument( |
| 2650 | 2644 | 'start', 't`start index'`, [ARGUMENT_TYPE.NUMBER], false, false, |
| 2651 | 2645 | ), |
| 2652 | 2646 | new SlashCommandNamedArgument( |
| 2653 | 2647 | 'end', 't`end index'`, [ARGUMENT_TYPE.NUMBER], false, false, |
| 2654 | 2648 | ), |
| 2655 | 2649 | ], |
| 2656 | 2650 | unnamedArgumentList: [ |
| 2657 | 2651 | new SlashCommandArgument( |
| 2658 | 2652 | 't`text to affect'`, [ARGUMENT_TYPE.STRING], true, false, |
| 2659 | 2653 | ), |
| 2660 | 2654 | ], |
| 2661 | 2655 | helpString: ` |
| 2662 | 2656 | <div> |
| 2663 | 2657 | ${t`Extracts text from the provided string.`} |
| 2664 | 2658 | </div> |
| 2665 | 2659 | <div> |
| 2666 | 2660 | ${t`If <code>start</code> is omitted, it's treated as 0.<br />`} |
| 2667 | 2661 | ${t`If <code>start</code> < 0, the index is counted from the end of the string.<br />`} |
| 2668 | 2662 | ${t`If <code>start</code> >= the string's length, an empty string is returned.<br />`} |
| 2669 | 2663 | ${t`If <code>end</code> is omitted, or if <code>end</code> >= the string's length, extracts to the end of the string.<br />`} |
| 2670 | 2664 | ${t`If <code>end</code> < 0, the index is counted from the end of the string.<br />`} |
| 2671 | 2665 | ${t`If <code>end</code> <= <code>start</code> after normalizing negative values, an empty string is returned.`} |
| 2672 | 2666 | </div> |
| 2673 | 2667 | <div> |
| 2674 | 2668 | <strong>${t`Example:`}</strong> |
| 2675 | 2669 | <pre>/let x The morning is upon us. || </pre> |
| 2676 | 2670 | <pre>/substr start=-3 {{var::x}} | /echo |/# us. ||</pre> |
| 2677 | 2671 | <pre>/substr start=-3 end=-1 {{var::x}} | /echo |/# us ||</pre> |
| @@ -2684,11 +2678,11 @@ export function initDefaultSlashCommands() { | ||
| 2684 | 2678 | name: 'is-mobile', |
| 2685 | 2679 | callback: () => String(isMobile()), |
| 2686 | 2680 | returns: ARGUMENT_TYPE.BOOLEAN, |
| 2687 | 2681 | helpString: 't`Returns true if the current device is a mobile device, false otherwise. Equivalent to <code>{{isMobile}}</code> macro.'`, |
| 2688 | 2682 | })); |
| 2689 | 2683 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 2690 | 2684 | name: 'chat-render', |
| 2691 | 2685 | helpString: 't`Renders a specified number of messages into the chat window. Displays all messages if no argument is provided.'`, |
| 2692 | 2686 | callback: async (args, number) => { |
| 2693 | 2687 | await showMoreMessages(number && !isNaN(Number(number)) ? Number(number) : Number.MAX_SAFE_INTEGER); |
| 2694 | 2688 | if (isTrueBoolean(String(args?.scroll ?? ''))) { |
| @@ -2699,7 +2693,7 @@ export function initDefaultSlashCommands() { | ||
| 2699 | 2693 | namedArgumentList: [ |
| 2700 | 2694 | SlashCommandNamedArgument.fromProps({ |
| 2701 | 2695 | name: 'scroll', |
| 2702 | 2696 | description: 't`scroll to the top after rendering'`, |
| 2703 | 2697 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| 2704 | 2698 | defaultValue: 'false', |
| 2705 | 2699 | enumList: commonEnumProviders.boolean('trueFalse')(), |
| @@ -2707,13 +2701,13 @@ export function initDefaultSlashCommands() { | ||
| 2707 | 2701 | ], |
| 2708 | 2702 | unnamedArgumentList: [ |
| 2709 | 2703 | new SlashCommandArgument( |
| 2710 | 2704 | 't`number of messages'`, [ARGUMENT_TYPE.NUMBER], false, |
| 2711 | 2705 | ), |
| 2712 | 2706 | ], |
| 2713 | 2707 | })); |
| 2714 | 2708 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 2715 | 2709 | name: 'chat-reload', |
| 2716 | 2710 | helpString: 't`Reloads the current chat.'`, |
| 2717 | 2711 | callback: async () => { |
| 2718 | 2712 | await reloadCurrentChat(); |
| 2719 | 2713 | return ''; |
| @@ -2724,7 +2718,7 @@ export function initDefaultSlashCommands() { | ||
| 2724 | 2718 | aliases: ['re'], |
| 2725 | 2719 | callback: (async ({ mode = 'literal', pattern, replacer = '' }, text) => { |
| 2726 | 2720 | if (!pattern) { |
| 2727 | 2721 | throw new Error('t`Argument of \'pattern=\' cannot be empty'`); |
| 2728 | 2722 | } |
| 2729 | 2723 | text = text.toString(); |
| 2730 | 2724 | pattern = pattern.toString(); |
| @@ -2735,42 +2729,42 @@ export function initDefaultSlashCommands() { | ||
| 2735 | 2729 | case 'regex': |
| 2736 | 2730 | return text.replace(regexFromString(pattern), replacer); |
| 2737 | 2731 | default: |
| 2738 | 2732 | throw new Error('t`Invalid \'/replace mode=\' argument specified!'`); |
| 2739 | 2733 | } |
| 2740 | 2734 | }), |
| 2741 | 2735 | returns: 't`replaced text'`, |
| 2742 | 2736 | namedArgumentList: [ |
| 2743 | 2737 | SlashCommandNamedArgument.fromProps({ |
| 2744 | 2738 | name: 'mode', |
| 2745 | 2739 | description: 't`Replaces occurrence(s) of a pattern'`, |
| 2746 | 2740 | typeList: [ARGUMENT_TYPE.STRING], |
| 2747 | 2741 | defaultValue: 'literal', |
| 2748 | 2742 | enumList: ['literal', 'regex'], |
| 2749 | 2743 | }), |
| 2750 | 2744 | new SlashCommandNamedArgument( |
| 2751 | 2745 | 'pattern', 't`pattern to search with'`, [ARGUMENT_TYPE.STRING], true, false, |
| 2752 | 2746 | ), |
| 2753 | 2747 | new SlashCommandNamedArgument( |
| 2754 | 2748 | 'replacer', 't`replacement text for matches'`, [ARGUMENT_TYPE.STRING], false, false, '', |
| 2755 | 2749 | ), |
| 2756 | 2750 | ], |
| 2757 | 2751 | unnamedArgumentList: [ |
| 2758 | 2752 | new SlashCommandArgument( |
| 2759 | 2753 | 't`text to affect'`, [ARGUMENT_TYPE.STRING], true, false, |
| 2760 | 2754 | ), |
| 2761 | 2755 | ], |
| 2762 | 2756 | helpString: ` |
| 2763 | 2757 | <div> |
| 2764 | 2758 | ${t`Replaces text within the provided string based on the pattern.`} |
| 2765 | 2759 | </div> |
| 2766 | 2760 | <div> |
| 2767 | 2761 | ${t`If <code>mode</code> is <code>literal</code> (or omitted), <code>pattern</code> is a literal search string (case-sensitive).<br />`} |
| 2768 | 2762 | ${t`If <code>mode</code> is <code>regex</code>, <code>pattern</code> is parsed as an ECMAScript Regular Expression.<br />`} |
| 2769 | 2763 | ${t`The <code>replacer</code> replaces based on the <code>pattern</code> in the input text.<br />`} |
| 2770 | 2764 | ${t`If <code>replacer</code> is omitted, the replacement(s) will be an empty string.<br />`} |
| 2771 | 2765 | </div> |
| 2772 | 2766 | <div> |
| 2773 | 2767 | <strong>${t`Example:`}</strong> |
| 2774 | 2768 | <pre><code class="language-stscript">/let x Blue house and blue car || </code></pre> |
| 2775 | 2769 | <pre><code class="language-stscript">/replace pattern="blue" {{var::x}} | /echo |/# Blue house and car ||</code></pre> |
| 2776 | 2770 | <pre><code class="language-stscript">/replace pattern="blue" replacer="red" {{var::x}} | /echo |/# Blue house and red car ||</code></pre> |
| @@ -2783,34 +2777,34 @@ export function initDefaultSlashCommands() { | ||
| 2783 | 2777 | name: 'test', |
| 2784 | 2778 | callback: (({ pattern }, text) => { |
| 2785 | 2779 | if (!pattern) { |
| 2786 | 2780 | throw new Error('t`Argument of \'pattern=\' cannot be empty'`); |
| 2787 | 2781 | } |
| 2788 | 2782 | const re = regexFromString(pattern.toString()); |
| 2789 | 2783 | if (!re) { |
| 2790 | 2784 | throw new Error('t`The value of \'pattern\' argument is not a valid regular expression.'`); |
| 2791 | 2785 | } |
| 2792 | 2786 | return JSON.stringify(re.test(text.toString())); |
| 2793 | 2787 | }), |
| 2794 | 2788 | returns: 'true | false', |
| 2795 | 2789 | namedArgumentList: [ |
| 2796 | 2790 | new SlashCommandNamedArgument( |
| 2797 | 2791 | 'pattern', 't`pattern to find'`, [ARGUMENT_TYPE.STRING], true, false, |
| 2798 | 2792 | ), |
| 2799 | 2793 | ], |
| 2800 | 2794 | unnamedArgumentList: [ |
| 2801 | 2795 | new SlashCommandArgument( |
| 2802 | 2796 | 't`text to test'`, [ARGUMENT_TYPE.STRING], true, false, |
| 2803 | 2797 | ), |
| 2804 | 2798 | ], |
| 2805 | 2799 | helpString: ` |
| 2806 | 2800 | <div> |
| 2807 | 2801 | ${t`Tests text for a regular expression match.`} |
| 2808 | 2802 | </div> |
| 2809 | 2803 | <div> |
| 2810 | 2804 | ${t`Returns <code>true</code> if the match is found, <code>false</code> otherwise.`} |
| 2811 | 2805 | </div> |
| 2812 | 2806 | <div> |
| 2813 | 2807 | <strong>${t`Example:`}</strong> |
| 2814 | 2808 | <pre><code class="language-stscript">/let x Blue house and green car ||</code></pre> |
| 2815 | 2809 | <pre><code class="language-stscript">/test pattern="green" {{var::x}} | /echo |/# true ||</code></pre> |
| 2816 | 2810 | <pre><code class="language-stscript">/test pattern="blue" {{var::x}} | /echo |/# false ||</code></pre> |
| @@ -2822,11 +2816,11 @@ export function initDefaultSlashCommands() { | ||
| 2822 | 2816 | name: 'match', |
| 2823 | 2817 | callback: (({ pattern }, text) => { |
| 2824 | 2818 | if (!pattern) { |
| 2825 | 2819 | throw new Error('t`Argument of \'pattern=\' cannot be empty'`); |
| 2826 | 2820 | } |
| 2827 | 2821 | const re = regexFromString(pattern.toString()); |
| 2828 | 2822 | if (!re) { |
| 2829 | 2823 | throw new Error('t`The value of \'pattern\' argument is not a valid regular expression.'`); |
| 2830 | 2824 | } |
| 2831 | 2825 | if (re.flags.includes('g')) { |
| 2832 | 2826 | return JSON.stringify([...text.toString().matchAll(re)]); |
| @@ -2835,28 +2829,26 @@ export function initDefaultSlashCommands() { | ||
| 2835 | 2829 | return match ? JSON.stringify(match) : ''; |
| 2836 | 2830 | } |
| 2837 | 2831 | }), |
| 2838 | 2832 | returns: 't`group array for each match'`, |
| 2839 | 2833 | namedArgumentList: [ |
| 2840 | 2834 | new SlashCommandNamedArgument( |
| 2841 | 2835 | 'pattern', 't`pattern to find'`, [ARGUMENT_TYPE.STRING], true, false, |
| 2842 | 2836 | ), |
| 2843 | 2837 | ], |
| 2844 | 2838 | unnamedArgumentList: [ |
| 2845 | 2839 | new SlashCommandArgument( |
| 2846 | 2840 | 't`text to match against'`, [ARGUMENT_TYPE.STRING], true, false, |
| 2847 | 2841 | ), |
| 2848 | 2842 | ], |
| 2849 | 2843 | helpString: ` |
| 2850 | 2844 | <div> |
| 2851 | 2845 | ${t`Retrieves regular expression matches in the given text`} |
| 2852 | 2846 | </div> |
| 2853 | 2847 | <div> |
| 2854 | 2848 | ${t`Returns an array of groups (with the first group being the full match). If the regex contains the global flag (i.e. <code>/g</code>), multiple nested arrays are returned for each match. If the regex is global, returns <code>[]</code> if no matches are found, otherwise it returns an empty string.`} |
| 2855 | - multiple nested arrays are returned for each match. If the regex is global, returns <code>[]</code> if no matches are found, | |
| 2856 | - otherwise it returns an empty string. | |
| 2857 | 2849 | </div> |
| 2858 | 2850 | <div> |
| 2859 | 2851 | <strong>${t`Example:`}</strong> |
| 2860 | 2852 | <pre><code class="language-stscript">/let x color_green green lamp color_blue ||</code></pre> |
| 2861 | 2853 | <pre><code class="language-stscript">/match pattern="green" {{var::x}} | /echo |/# [ "green" ] ||</code></pre> |
| 2862 | 2854 | <pre><code class="language-stscript">/match pattern="color_(\\w+)" {{var::x}} | /echo |/# [ "color_green", "green" ] ||</code></pre> |
| @@ -2910,7 +2902,7 @@ export function initDefaultSlashCommands() { | ||
| 2910 | 2902 | }, |
| 2911 | 2903 | unnamedArgumentList: [ |
| 2912 | 2904 | SlashCommandArgument.fromProps({ |
| 2913 | 2905 | description: 't`The message index (0-based) to scroll to.'`, |
| 2914 | 2906 | typeList: [ARGUMENT_TYPE.NUMBER], |
| 2915 | 2907 | isRequired: true, |
| 2916 | 2908 | enumProvider: commonEnumProviders.messages(), |
| @@ -2918,20 +2910,20 @@ export function initDefaultSlashCommands() { | ||
| 2918 | 2910 | ], |
| 2919 | 2911 | helpString: ` |
| 2920 | 2912 | <div> |
| 2921 | 2913 | ${t`Scrolls the chat view to the specified message index. Index starts at 0.`} |
| 2922 | 2914 | </div> |
| 2923 | 2915 | <div> |
| 2924 | 2916 | <strong>${t`Example:`}</strong> <pre><code>/chat-jump 10</code></pre> ${t`Scrolls to the 11th message (id=10).`} |
| 2925 | 2917 | </div> |
| 2926 | 2918 | `, |
| 2927 | 2919 | })); |
| 2928 | 2920 | |
| 2929 | 2921 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 2930 | 2922 | name: 'clipboard-get', |
| 2931 | 2923 | returns: 't`clipboard text'`, |
| 2932 | 2924 | callback: async () => { |
| 2933 | 2925 | if (!navigator.clipboard) { |
| 2934 | 2926 | toastr.warning('t`Clipboard API not available in this context.'`); |
| 2935 | 2927 | return ''; |
| 2936 | 2928 | } |
| 2937 | 2929 | |
| @@ -2941,11 +2933,11 @@ export function initDefaultSlashCommands() { | ||
| 2941 | 2933 | } |
| 2942 | 2934 | catch (error) { |
| 2943 | 2935 | console.error('Error reading clipboard:', error); |
| 2944 | 2936 | toastr.warning('t`Failed to read clipboard text. Have you granted the permission?'`); |
| 2945 | 2937 | return ''; |
| 2946 | 2938 | } |
| 2947 | 2939 | }, |
| 2948 | 2940 | helpString: 't`Retrieves the text from the OS clipboard. Only works in secure contexts (HTTPS or localhost). Browser may ask for permission.'`, |
| 2949 | 2941 | })); |
| 2950 | 2942 | |
| 2951 | 2943 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| @@ -2956,13 +2948,13 @@ export function initDefaultSlashCommands() { | ||
| 2956 | 2948 | }, |
| 2957 | 2949 | unnamedArgumentList: [ |
| 2958 | 2950 | SlashCommandArgument.fromProps({ |
| 2959 | 2951 | description: 't`text to copy to the clipboard'`, |
| 2960 | 2952 | typeList: [ARGUMENT_TYPE.STRING], |
| 2961 | 2953 | isRequired: true, |
| 2962 | 2954 | acceptsMultiple: false, |
| 2963 | 2955 | }), |
| 2964 | 2956 | ], |
| 2965 | 2957 | helpString: 't`Copies the provided text to the OS clipboard. Returns an empty string.'`, |
| 2966 | 2958 | })); |
| 2967 | 2959 | |
| 2968 | 2960 | |
| @@ -2974,10 +2966,10 @@ export function initDefaultSlashCommands() { | ||
| 2974 | 2966 | aliases: ['ppp'], |
| 2975 | 2967 | helpString: ` |
| 2976 | 2968 | <div> |
| 2977 | 2969 | ${t`Sets a "Prompt Post-Processing" type. Gets the current selection if no value is provided.`} |
| 2978 | 2970 | </div> |
| 2979 | 2971 | <div> |
| 2980 | 2972 | <strong>${t`Examples:`}</strong> |
| 2981 | 2973 | </div> |
| 2982 | 2974 | <ul> |
| 2983 | 2975 | <li><pre><code class="language-stscript">/prompt-post-processing | /echo</code></pre></li> |
| @@ -2987,7 +2979,7 @@ export function initDefaultSlashCommands() { | ||
| 2987 | 2979 | namedArgumentList: [], |
| 2988 | 2980 | unnamedArgumentList: [ |
| 2989 | 2981 | SlashCommandArgument.fromProps({ |
| 2990 | 2982 | description: 't`value'`, |
| 2991 | 2983 | typeList: [ARGUMENT_TYPE.STRING], |
| 2992 | 2984 | acceptsMultiple: false, |
| 2993 | 2985 | isRequired: true, |
| @@ -3003,7 +2995,7 @@ export function initDefaultSlashCommands() { | ||
| 3003 | 2995 | |
| 3004 | 2996 | const validValues = promptPostProcessingEnumProvider().map(option => option.value); |
| 3005 | 2997 | if (!validValues.includes(stringValue)) { |
| 3006 | 2998 | throw new Error(t`Invalid value "${stringValue}". Valid values are: ${validValues.join(', ')}`); |
| 3007 | 2999 | } |
| 3008 | 3000 | |
| 3009 | 3001 | // 'none' value must be coerced to an empty string |
| @@ -3056,9 +3048,8 @@ function injectCallback(args, value) { | ||
| 3056 | 3048 | const filter = args?.filter instanceof SlashCommandClosure ? args.filter.rawText : null; |
| 3057 | 3049 | const filterFunction = args?.filter instanceof SlashCommandClosure ? closureToFilter(args.filter) : null; |
| 3058 | 3050 | value = value || ''; |
| 3059 | - | |
| 3060 | 3051 | if (args?.filter && !String(filter ?? '').trim()) { |
| 3061 | 3052 | throw new Error('t`Failed to parse the filter argument. Make sure it is a valid non-empty closure.'`); |
| 3062 | 3053 | } |
| 3063 | 3054 | |
| 3064 | 3055 | const prefixedId = `${SCRIPT_PROMPT_KEY}${id}`; |
| @@ -3102,10 +3093,10 @@ async function listInjectsCallback(args) { | ||
| 3102 | 3093 | |
| 3103 | 3094 | // Old legacy return type handling |
| 3104 | 3095 | if (args.format) { |
| 3105 | 3096 | toastr.warning(t`Legacy argument 'format' with value '${args.format}' is deprecated. Please use 'return' instead. Routing to the correct return type...`, 't`Deprecation warning'`); |
| 3106 | 3097 | const type = String(args?.format).toLowerCase().trim(); |
| 3107 | 3098 | if (!chat_metadata.script_injects || !Object.keys(chat_metadata.script_injects).length) { |
| 3108 | 3099 | type !== 'none' && toastr.info('t`No script injections for the current chat'`); |
| 3109 | 3100 | } |
| 3110 | 3101 | switch (type) { |
| 3111 | 3102 | case 'none': |
| @@ -3126,11 +3117,11 @@ async function listInjectsCallback(args) { | ||
| 3126 | 3117 | const injectsStr = Object.entries(injects) |
| 3127 | 3118 | .map(([id, inject]) => { |
| 3128 | 3119 | const position = Object.entries(extension_prompt_types); |
| 3129 | 3120 | const positionName = position.find(([_, value]) => value === inject.position)?.[0] ?? 't`unknown'`; |
| 3130 | 3121 | return `* **${id}**: <code>${inject.value}</code> (${positionName}, ${t`depth`}: ${inject.depth}, ${t`scan`}: ${inject.scan ?? false}, ${t`role`}: ${inject.role ?? extension_prompt_roles.SYSTEM})`; |
| 3131 | 3122 | }) |
| 3132 | 3123 | .join('\n'); |
| 3133 | 3124 | return `### ${t`Script injections:`}\n${injectsStr || 't`No script injections for the current chat'`}`; |
| 3134 | 3125 | }; |
| 3135 | 3126 | |
| 3136 | 3127 | return await slashCommandReturnHelper.doReturn(returnType ?? 'popup-html', chat_metadata.script_injects ?? {}, { objectToStringFunc: buildTextValue }); |
| @@ -3381,7 +3372,7 @@ async function popupCallback(args, value) { | ||
| 3381 | 3372 | wide: isTrueBoolean(args?.wide), |
| 3382 | 3373 | wider: isTrueBoolean(args?.wider), |
| 3383 | 3374 | transparent: isTrueBoolean(args?.transparent), |
| 3384 | 3375 | okButton: args?.okButton !== undefined && typeof args?.okButton === 'string' ? args.okButton : 'Ok't`OK`, |
| 3385 | 3376 | cancelButton: args?.cancelButton !== undefined && typeof args?.cancelButton === 'string' ? args.cancelButton : null, |
| 3386 | 3377 | }; |
| 3387 | 3378 | const result = await Popup.show.text(safeHeader, safeBody, popupOptions); |
| @@ -3418,7 +3409,7 @@ async function getMessagesCallback(args, value) { | ||
| 3418 | 3409 | return !isNarrator && mes.is_user; |
| 3419 | 3410 | } |
| 3420 | 3411 | |
| 3421 | 3412 | throw new Error(t`Invalid role provided. Expected one of: system, assistant, user. Got: ${role}`); |
| 3422 | 3413 | }; |
| 3423 | 3414 | |
| 3424 | 3415 | const processMessage = async (mesId) => { |
| @@ -3453,7 +3444,7 @@ async function getMessagesCallback(args, value) { | ||
| 3453 | 3444 | |
| 3454 | 3445 | async function runCallback(args, name) { |
| 3455 | 3446 | if (!name) { |
| 3456 | 3447 | throw new Error('t`No name provided for /run command'`); |
| 3457 | 3448 | } |
| 3458 | 3449 | |
| 3459 | 3450 | if (name instanceof SlashCommandClosure) { |
| @@ -3466,7 +3457,7 @@ async function runCallback(args, name) { | ||
| 3466 | 3457 | if (scope.existsVariable(name)) { |
| 3467 | 3458 | const closure = scope.getVariable(name); |
| 3468 | 3459 | if (!(closure instanceof SlashCommandClosure)) { |
| 3469 | 3460 | throw new Error(t`"${name}" is not callable.`); |
| 3470 | 3461 | } |
| 3471 | 3462 | closure.scope.parent = scope; |
| 3472 | 3463 | closure.breakController = new SlashCommandBreakController(); |
| @@ -3487,7 +3478,7 @@ async function runCallback(args, name) { | ||
| 3487 | 3478 | } |
| 3488 | 3479 | |
| 3489 | 3480 | if (typeof window['executeQuickReplyByName'] !== 'function') { |
| 3490 | 3481 | throw new Error('t`Quick Reply extension is not loaded'`); |
| 3491 | 3482 | } |
| 3492 | 3483 | |
| 3493 | 3484 | try { |
| @@ -3499,7 +3490,7 @@ async function runCallback(args, name) { | ||
| 3499 | 3490 | }; |
| 3500 | 3491 | return await window['executeQuickReplyByName'](name, args, options); |
| 3501 | 3492 | } catch (error) { |
| 3502 | 3493 | throw new Error(t`Error running Quick Reply "${name}": ${error.message}`); |
| 3503 | 3494 | } |
| 3504 | 3495 | } |
| 3505 | 3496 | |
| @@ -3509,8 +3500,8 @@ async function runCallback(args, name) { | ||
| 3509 | 3500 | * @param {string} [reason] |
| 3510 | 3501 | */ |
| 3511 | 3502 | function abortCallback({ _abortController, quiet }, reason) { |
| 3512 | 3503 | if (quiet instanceof SlashCommandClosure) throw new Error('t`argument \'quiet\' cannot be a closure for command /abort'`); |
| 3513 | 3504 | _abortController.abort((reason ?? '').toString().length == 0 ? 't`/abort command executed'` : reason, !isFalseBoolean(quiet?.toString() ?? 'true')); |
| 3514 | 3505 | return ''; |
| 3515 | 3506 | } |
| 3516 | 3507 | |
| @@ -3536,7 +3527,7 @@ async function inputCallback(args, prompt) { | ||
| 3536 | 3527 | const popupOptions = { |
| 3537 | 3528 | large: isTrueBoolean(args?.large), |
| 3538 | 3529 | wide: isTrueBoolean(args?.wide), |
| 3539 | 3530 | okButton: args?.okButton !== undefined && typeof args?.okButton === 'string' ? args.okButton : 't`Ok'`, |
| 3540 | 3531 | rows: args?.rows !== undefined && typeof args?.rows === 'string' ? isNaN(Number(args.rows)) ? 4 : Number(args.rows) : 4, |
| 3541 | 3532 | }; |
| 3542 | 3533 | // Do not remove this delay, otherwise the prompt will not show up |
| @@ -3549,7 +3540,7 @@ async function inputCallback(args, prompt) { | ||
| 3549 | 3540 | // Veryify if a cancel handler exists and it is valid |
| 3550 | 3541 | if (args?.onCancel) { |
| 3551 | 3542 | if (!(args.onCancel instanceof SlashCommandClosure)) { |
| 3552 | 3543 | throw new Error('t`argument \'onCancel\' must be a closure for command /input'`); |
| 3553 | 3544 | } |
| 3554 | 3545 | await args.onCancel.execute(); |
| 3555 | 3546 | } |
| @@ -3557,7 +3548,7 @@ async function inputCallback(args, prompt) { | ||
| 3557 | 3548 | // Verify if an ok handler exists and it is valid |
| 3558 | 3549 | if (args?.onSuccess) { |
| 3559 | 3550 | if (!(args.onSuccess instanceof SlashCommandClosure)) { |
| 3560 | 3551 | throw new Error('t`argument \'onSuccess\' must be a closure for command /input'`); |
| 3561 | 3552 | } |
| 3562 | 3553 | await args.onSuccess.execute(); |
| 3563 | 3554 | } |
| @@ -3705,7 +3696,7 @@ async function generateRawCallback(args, value) { | ||
| 3705 | 3696 | return result; |
| 3706 | 3697 | } catch (err) { |
| 3707 | 3698 | console.error('Error on /genraw generation', err); |
| 3708 | 3699 | toastr.error(err.message, 't`API Error'`, { preventDuplicates: true }); |
| 3709 | 3700 | } finally { |
| 3710 | 3701 | if (lock) { |
| 3711 | 3702 | activateSendButtons(); |
| @@ -3751,7 +3742,7 @@ async function generateCallback(args, value) { | ||
| 3751 | 3742 | return result; |
| 3752 | 3743 | } catch (err) { |
| 3753 | 3744 | console.error('Error on /gen generation', err); |
| 3754 | 3745 | toastr.error(err.message, 't`API Error'`, { preventDuplicates: true }); |
| 3755 | 3746 | } finally { |
| 3756 | 3747 | if (lock) { |
| 3757 | 3748 | activateSendButtons(); |
| @@ -3775,7 +3766,7 @@ async function echoCallback(args, value) { | ||
| 3775 | 3766 | } |
| 3776 | 3767 | |
| 3777 | 3768 | if (args.severity && !['error', 'warning', 'success', 'info'].includes(args.severity)) { |
| 3778 | 3769 | toastr.warning(t`Invalid severity provided for /echo command: ${args.severity}`); |
| 3779 | 3770 | args.severity = null; |
| 3780 | 3771 | } |
| 3781 | 3772 | |
| @@ -3808,7 +3799,7 @@ async function echoCallback(args, value) { | ||
| 3808 | 3799 | await args.onClick.execute(); |
| 3809 | 3800 | }; |
| 3810 | 3801 | } else { |
| 3811 | 3802 | toastr.warning('t`Invalid onClick provided for /echo command. This is not a closure'`); |
| 3812 | 3803 | } |
| 3813 | 3804 | } |
| 3814 | 3805 | |
| @@ -3856,7 +3847,7 @@ async function addSwipeCallback(args, value) { | ||
| 3856 | 3847 | const lastMessage = chat[chat.length - 1]; |
| 3857 | 3848 | |
| 3858 | 3849 | if (!lastMessage) { |
| 3859 | 3850 | toastr.warning('t`No messages to add swipes to.'`); |
| 3860 | 3851 | return ''; |
| 3861 | 3852 | } |
| 3862 | 3853 | |
| @@ -3866,17 +3857,17 @@ async function addSwipeCallback(args, value) { | ||
| 3866 | 3857 | } |
| 3867 | 3858 | |
| 3868 | 3859 | if (lastMessage.is_user) { |
| 3869 | 3860 | toastr.warning('t`Can\'t add swipes to user messages.'`); |
| 3870 | 3861 | return ''; |
| 3871 | 3862 | } |
| 3872 | 3863 | |
| 3873 | 3864 | if (lastMessage.is_system) { |
| 3874 | 3865 | toastr.warning('t`Can\'t add swipes to system messages.'`); |
| 3875 | 3866 | return ''; |
| 3876 | 3867 | } |
| 3877 | 3868 | |
| 3878 | 3869 | if (lastMessage.extra?.image) { |
| 3879 | 3870 | toastr.warning('t`Can\'t add swipes to message containing an image.'`); |
| 3880 | 3871 | return ''; |
| 3881 | 3872 | } |
| 3882 | 3873 | |
| @@ -3934,12 +3925,12 @@ async function askCharacter(args, text) { | ||
| 3934 | 3925 | // Not supported in group chats |
| 3935 | 3926 | // TODO: Maybe support group chats? |
| 3936 | 3927 | if (selected_group) { |
| 3937 | 3928 | toastr.warning('t`Cannot run /ask command in a group chat!'`); |
| 3938 | 3929 | return ''; |
| 3939 | 3930 | } |
| 3940 | 3931 | |
| 3941 | 3932 | if (!args.name) { |
| 3942 | 3933 | toastr.warning('t`You must specify a name of the character to ask.'`); |
| 3943 | 3934 | return ''; |
| 3944 | 3935 | } |
| 3945 | 3936 | |
| @@ -3948,7 +3939,7 @@ async function askCharacter(args, text) { | ||
| 3948 | 3939 | // Find the character |
| 3949 | 3940 | const character = findChar({ name: args?.name }); |
| 3950 | 3941 | if (!character) { |
| 3951 | 3942 | toastr.error('t`Character not found.'`); |
| 3952 | 3943 | return ''; |
| 3953 | 3944 | } |
| 3954 | 3945 | |
| @@ -3995,7 +3986,7 @@ async function askCharacter(args, text) { | ||
| 3995 | 3986 | // Run generate and restore previous character |
| 3996 | 3987 | try { |
| 3997 | 3988 | eventSource.once(event_types.MESSAGE_RECEIVED, restoreCharacter); |
| 3998 | 3989 | toastr.info(t`Asking ${name} something...`); |
| 3999 | 3990 | askResult = await Generate('normal'); |
| 4000 | 3991 | } catch (error) { |
| 4001 | 3992 | restoreCharacter(); |
| @@ -4004,7 +3995,7 @@ async function askCharacter(args, text) { | ||
| 4004 | 3995 | if (String(this_chid) === String(prevChId)) { |
| 4005 | 3996 | await saveChatConditional(); |
| 4006 | 3997 | } else { |
| 4007 | 3998 | toastr.error('t`It is strongly recommended to reload the page.'`, 't`Something went wrong'`); |
| 4008 | 3999 | } |
| 4009 | 4000 | } |
| 4010 | 4001 | |
| @@ -4073,7 +4064,7 @@ function performGroupMemberAction(chid, action) { | ||
| 4073 | 4064 | |
| 4074 | 4065 | async function disableGroupMemberCallback(_, arg) { |
| 4075 | 4066 | if (!selected_group) { |
| 4076 | 4067 | toastr.warning('t`Cannot run /member-disable command outside of a group chat.'`); |
| 4077 | 4068 | return ''; |
| 4078 | 4069 | } |
| 4079 | 4070 | |
| @@ -4090,7 +4081,7 @@ async function disableGroupMemberCallback(_, arg) { | ||
| 4090 | 4081 | |
| 4091 | 4082 | async function enableGroupMemberCallback(_, arg) { |
| 4092 | 4083 | if (!selected_group) { |
| 4093 | 4084 | toastr.warning('t`Cannot run /member-enable command outside of a group chat.'`); |
| 4094 | 4085 | return ''; |
| 4095 | 4086 | } |
| 4096 | 4087 | |
| @@ -4107,7 +4098,7 @@ async function enableGroupMemberCallback(_, arg) { | ||
| 4107 | 4098 | |
| 4108 | 4099 | async function moveGroupMemberUpCallback(_, arg) { |
| 4109 | 4100 | if (!selected_group) { |
| 4110 | 4101 | toastr.warning('t`Cannot run /member-up command outside of a group chat.'`); |
| 4111 | 4102 | return ''; |
| 4112 | 4103 | } |
| 4113 | 4104 | |
| @@ -4124,7 +4115,7 @@ async function moveGroupMemberUpCallback(_, arg) { | ||
| 4124 | 4115 | |
| 4125 | 4116 | async function moveGroupMemberDownCallback(_, arg) { |
| 4126 | 4117 | if (!selected_group) { |
| 4127 | 4118 | toastr.warning('t`Cannot run /member-down command outside of a group chat.'`); |
| 4128 | 4119 | return ''; |
| 4129 | 4120 | } |
| 4130 | 4121 | |
| @@ -4141,12 +4132,12 @@ async function moveGroupMemberDownCallback(_, arg) { | ||
| 4141 | 4132 | |
| 4142 | 4133 | async function peekCallback(_, arg) { |
| 4143 | 4134 | if (!selected_group) { |
| 4144 | 4135 | toastr.warning('t`Cannot run /member-peek command outside of a group chat.'`); |
| 4145 | 4136 | return ''; |
| 4146 | 4137 | } |
| 4147 | 4138 | |
| 4148 | 4139 | if (is_group_generating) { |
| 4149 | 4140 | toastr.warning('t`Cannot run /member-peek command while the group reply is generating.'`); |
| 4150 | 4141 | return ''; |
| 4151 | 4142 | } |
| 4152 | 4143 | |
| @@ -4163,7 +4154,7 @@ async function peekCallback(_, arg) { | ||
| 4163 | 4154 | |
| 4164 | 4155 | async function countGroupMemberCallback() { |
| 4165 | 4156 | if (!selected_group) { |
| 4166 | 4157 | toastr.warning('t`Cannot run /member-count command outside of a group chat.'`); |
| 4167 | 4158 | return ''; |
| 4168 | 4159 | } |
| 4169 | 4160 | |
| @@ -4172,7 +4163,7 @@ async function countGroupMemberCallback() { | ||
| 4172 | 4163 | |
| 4173 | 4164 | async function removeGroupMemberCallback(_, arg) { |
| 4174 | 4165 | if (!selected_group) { |
| 4175 | 4166 | toastr.warning('t`Cannot run /member-remove command outside of a group chat.'`); |
| 4176 | 4167 | return ''; |
| 4177 | 4168 | } |
| 4178 | 4169 | |
| @@ -4189,7 +4180,7 @@ async function removeGroupMemberCallback(_, arg) { | ||
| 4189 | 4180 | |
| 4190 | 4181 | async function addGroupMemberCallback(_, name) { |
| 4191 | 4182 | if (!selected_group) { |
| 4192 | 4183 | toastr.warning('t`Cannot run /memberadd command outside of a group chat.'`); |
| 4193 | 4184 | return ''; |
| 4194 | 4185 | } |
| 4195 | 4186 | |
| @@ -4214,7 +4205,7 @@ async function addGroupMemberCallback(_, name) { | ||
| 4214 | 4205 | const avatar = character.avatar; |
| 4215 | 4206 | |
| 4216 | 4207 | if (group.members.includes(avatar)) { |
| 4217 | 4208 | toastr.warning(t`${character.name} is already a member of this group.`); |
| 4218 | 4209 | return ''; |
| 4219 | 4210 | } |
| 4220 | 4211 | |
| @@ -4233,7 +4224,7 @@ async function triggerGenerationCallback(args, value) { | ||
| 4233 | 4224 | await waitUntilCondition(() => !is_send_press && !is_group_generating, 10000, 100); |
| 4234 | 4225 | } catch { |
| 4235 | 4226 | console.warn('Timeout waiting for generation unlock'); |
| 4236 | 4227 | toastr.warning('t`Cannot run /trigger command while the reply is being generated.'`); |
| 4237 | 4228 | outerResolve(Promise.resolve('')); |
| 4238 | 4229 | return ''; |
| 4239 | 4230 | } |
| @@ -4338,7 +4329,7 @@ async function deleteMessagesByNameCallback(_, name) { | ||
| 4338 | 4329 | await saveChatConditional(); |
| 4339 | 4330 | await reloadCurrentChat(); |
| 4340 | 4331 | |
| 4341 | 4332 | toastr.info(t`Deleted ${messagesToDelete.length} messages from ${name}`); |
| 4342 | 4333 | return ''; |
| 4343 | 4334 | } |
| 4344 | 4335 | |
| @@ -4382,7 +4373,7 @@ async function continueChatCallback(args, prompt) { | ||
| 4382 | 4373 | await waitUntilCondition(() => !is_send_press && !is_group_generating, 10000, 100); |
| 4383 | 4374 | } catch { |
| 4384 | 4375 | console.warn('Timeout waiting for generation unlock'); |
| 4385 | 4376 | toastr.warning('t`Cannot run /continue command while the reply is being generated.'`); |
| 4386 | 4377 | return reject(); |
| 4387 | 4378 | } |
| 4388 | 4379 | |
| @@ -4412,14 +4403,14 @@ export async function generateSystemMessage(args, prompt) { | ||
| 4412 | 4403 | |
| 4413 | 4404 | if (!prompt) { |
| 4414 | 4405 | console.warn('WARN: No prompt provided for /sysgen command'); |
| 4415 | 4406 | toastr.warning('t`You must provide a prompt for the system message'`); |
| 4416 | 4407 | return ''; |
| 4417 | 4408 | } |
| 4418 | 4409 | |
| 4419 | 4410 | const trim = isTrueBoolean(args?.trim?.toString()); |
| 4420 | 4411 | |
| 4421 | 4412 | // Generate and regex the output if applicable |
| 4422 | 4413 | const toast = toastr.info('t`Please wait'`, 't`Generating...'`); |
| 4423 | 4414 | const message = await generateQuietPrompt({ quietPrompt: prompt, trimToSentence: trim }); |
| 4424 | 4415 | toastr.clear(toast); |
| 4425 | 4416 | |
| @@ -4444,7 +4435,7 @@ function setFlatModeCallback() { | ||
| 4444 | 4435 | async function setNarratorName(_, text) { |
| 4445 | 4436 | const name = text || NARRATOR_NAME_DEFAULT; |
| 4446 | 4437 | chat_metadata[NARRATOR_NAME_KEY] = name; |
| 4447 | 4438 | toastr.info(t`System narrator name set to ${name}`); |
| 4448 | 4439 | await saveChatConditional(); |
| 4449 | 4440 | return ''; |
| 4450 | 4441 | } |
| @@ -4461,10 +4452,10 @@ async function setNarratorName(_, text) { | ||
| 4461 | 4452 | export function validateArrayArgString(arg, name, { allowUndefined = true } = {}) { |
| 4462 | 4453 | if (arg === undefined) { |
| 4463 | 4454 | if (allowUndefined) return undefined; |
| 4464 | 4455 | throw new Error(t`Argument "${name}" is undefined, but must be a string array`); |
| 4465 | 4456 | } |
| 4466 | 4457 | if (!Array.isArray(arg)) throw new Error(t`Argument "${name}" must be an array`); |
| 4467 | 4458 | if (!arg.every(x => typeof x === 'string')) throw new Error(t`Argument "${name}" must be an array of strings`); |
| 4468 | 4459 | return arg; |
| 4469 | 4460 | } |
| 4470 | 4461 | |
| @@ -4480,10 +4471,10 @@ export function validateArrayArgString(arg, name, { allowUndefined = true } = {} | ||
| 4480 | 4471 | export function validateArrayArg(arg, name, { allowUndefined = true } = {}) { |
| 4481 | 4472 | if (arg === undefined) { |
| 4482 | 4473 | if (allowUndefined) return []; |
| 4483 | 4474 | throw new Error(t`Argument "${name}" is undefined, but must be an array of strings or closures`); |
| 4484 | 4475 | } |
| 4485 | 4476 | if (!Array.isArray(arg)) throw new Error(t`Argument "${name}" must be an array`); |
| 4486 | 4477 | if (!arg.every(x => typeof x === 'string' || x instanceof SlashCommandClosure)) throw new Error(t`Argument "${name}" must be an array of strings or closures`); |
| 4487 | 4478 | return arg; |
| 4488 | 4479 | } |
| 4489 | 4480 | |
| @@ -4528,7 +4519,7 @@ export async function sendMessageAs(args, text) { | ||
| 4528 | 4519 | if (!name) { |
| 4529 | 4520 | const namelessWarningKey = 'sendAsNamelessWarningShown'; |
| 4530 | 4521 | if (accountStorage.getItem(namelessWarningKey) !== 'true') { |
| 4531 | 4522 | toastr.warning('t`To avoid confusion, please use /sendas name="Character Name"'`, 't`Name defaulted to {{char}}'`, { timeOut: 10000 }); |
| 4532 | 4523 | accountStorage.setItem(namelessWarningKey, 'true'); |
| 4533 | 4524 | } |
| 4534 | 4525 | name = name2; |
| @@ -4548,7 +4539,7 @@ export async function sendMessageAs(args, text) { | ||
| 4548 | 4539 | |
| 4549 | 4540 | const avatarCharacter = args.avatar ? findChar({ name: args.avatar }) : character; |
| 4550 | 4541 | if (args.avatar && !avatarCharacter) { |
| 4551 | 4542 | toastr.warning(t`Character for avatar ${args.avatar} not found`); |
| 4552 | 4543 | return ''; |
| 4553 | 4544 | } |
| 4554 | 4545 | |
| @@ -4805,7 +4796,7 @@ function setBackgroundCallback(_, bg) { | ||
| 4805 | 4796 | const result = fuse.search(bg); |
| 4806 | 4797 | |
| 4807 | 4798 | if (!result.length) { |
| 4808 | 4799 | toastr.error(t`No background found with name "${bg}"`); |
| 4809 | 4800 | return ''; |
| 4810 | 4801 | } |
| 4811 | 4802 | |
| @@ -4877,14 +4868,14 @@ function getModelOptions(quiet) { | ||
| 4877 | 4868 | const modelSelectItem = modelSelectMap.find(x => x.api == main_api && x.type == apiSubType)?.id; |
| 4878 | 4869 | |
| 4879 | 4870 | if (!modelSelectItem) { |
| 4880 | 4871 | !quiet && toastr.info('t`Setting a model for your API is not supported or not implemented yet.'`); |
| 4881 | 4872 | return nullResult; |
| 4882 | 4873 | } |
| 4883 | 4874 | |
| 4884 | 4875 | const modelSelectControl = document.getElementById(modelSelectItem); |
| 4885 | 4876 | |
| 4886 | 4877 | if (!(modelSelectControl instanceof HTMLSelectElement) && !(modelSelectControl instanceof HTMLInputElement)) { |
| 4887 | 4878 | !quiet && toastr.error(t`Model select control not found: ${main_api}[${apiSubType}]`); |
| 4888 | 4879 | return nullResult; |
| 4889 | 4880 | } |
| 4890 | 4881 | |
| @@ -4937,12 +4928,12 @@ function modelCallback(args, model) { | ||
| 4937 | 4928 | if (modelSelectControl instanceof HTMLInputElement) { |
| 4938 | 4929 | modelSelectControl.value = model; |
| 4939 | 4930 | $(modelSelectControl).trigger('input'); |
| 4940 | 4931 | !quiet && toastr.success(t`Model set to "${model}"`); |
| 4941 | 4932 | return model; |
| 4942 | 4933 | } |
| 4943 | 4934 | |
| 4944 | 4935 | if (!options.length) { |
| 4945 | 4936 | !quiet && toastr.warning('t`No model options found. Check your API settings.'`); |
| 4946 | 4937 | return ''; |
| 4947 | 4938 | } |
| 4948 | 4939 | |
| @@ -4965,10 +4956,10 @@ function modelCallback(args, model) { | ||
| 4965 | 4956 | if (newSelectedOption) { |
| 4966 | 4957 | modelSelectControl.value = newSelectedOption.value; |
| 4967 | 4958 | $(modelSelectControl).trigger('change'); |
| 4968 | 4959 | !quiet && toastr.success(t`Model set to "${newSelectedOption.text}"`); |
| 4969 | 4960 | return newSelectedOption.value; |
| 4970 | 4961 | } else { |
| 4971 | 4962 | !quiet && toastr.warning(t`No model found with name "${model}"`); |
| 4972 | 4963 | return ''; |
| 4973 | 4964 | } |
| 4974 | 4965 | } |
| @@ -5149,7 +5140,7 @@ async function setApiUrlCallback({ api = null, connect = 'true', quiet = 'false' | ||
| 5149 | 5140 | } |
| 5150 | 5141 | |
| 5151 | 5142 | if (!isCurrentlyCustomOpenai && autoConnect) { |
| 5152 | 5143 | toastr.warning('t`Custom OpenAI API is not the currently selected API, so we cannot do an auto-connect. Consider switching to it via /api beforehand.'`); |
| 5153 | 5144 | return ''; |
| 5154 | 5145 | } |
| 5155 | 5146 | |
| @@ -5170,7 +5161,7 @@ async function setApiUrlCallback({ api = null, connect = 'true', quiet = 'false' | ||
| 5170 | 5161 | } |
| 5171 | 5162 | |
| 5172 | 5163 | if (!isCurrentlyKoboldClassic && autoConnect) { |
| 5173 | 5164 | toastr.warning('t`Kobold Classic API is not the currently selected API, so we cannot do an auto-connect. Consider switching to it via /api beforehand.'`); |
| 5174 | 5165 | return ''; |
| 5175 | 5166 | } |
| 5176 | 5167 | |
| @@ -5187,26 +5178,26 @@ async function setApiUrlCallback({ api = null, connect = 'true', quiet = 'false' | ||
| 5187 | 5178 | |
| 5188 | 5179 | // Do some checks and get the api type we are targeting with this command |
| 5189 | 5180 | if (api && !Object.values(textgen_types).includes(api)) { |
| 5190 | 5181 | !isQuiet && toastr.warning(t`API '${api}' is not a valid text_gen API.`); |
| 5191 | 5182 | return ''; |
| 5192 | 5183 | } |
| 5193 | 5184 | if (!api && !Object.values(textgen_types).includes(textgenerationwebui_settings.type)) { |
| 5194 | 5185 | !isQuiet && toastr.warning(t`API '${textgenerationwebui_settings.type}' is not a valid text_gen API.`); |
| 5195 | 5186 | return ''; |
| 5196 | 5187 | } |
| 5197 | 5188 | if (!api && main_api !== 'textgenerationwebui') { |
| 5198 | 5189 | !isQuiet && toastr.warning(t`API type '${main_api}' does not support setting the server URL.`); |
| 5199 | 5190 | return ''; |
| 5200 | 5191 | } |
| 5201 | 5192 | if (api && url && autoConnect && api !== textgenerationwebui_settings.type) { |
| 5202 | 5193 | !isQuiet && toastr.warning(t`API '${api}' is not the currently selected API, so we cannot do an auto-connect. Consider switching to it via /api beforehand.`); |
| 5203 | 5194 | return ''; |
| 5204 | 5195 | } |
| 5205 | 5196 | const type = api || textgenerationwebui_settings.type; |
| 5206 | 5197 | |
| 5207 | 5198 | const inputSelector = SERVER_INPUTS[type]; |
| 5208 | 5199 | if (!inputSelector) { |
| 5209 | 5200 | !isQuiet && toastr.warning(t`API '${type}' does not have a server url input.`); |
| 5210 | 5201 | return ''; |
| 5211 | 5202 | } |
| 5212 | 5203 | |
| @@ -5239,7 +5230,7 @@ async function selectTokenizerCallback(_, name) { | ||
| 5239 | 5230 | const result = fuse.search(name); |
| 5240 | 5231 | |
| 5241 | 5232 | if (result.length === 0) { |
| 5242 | 5233 | toastr.warning(t`Tokenizer "${name}" not found`); |
| 5243 | 5234 | return ''; |
| 5244 | 5235 | } |
| 5245 | 5236 | |
| @@ -5398,20 +5389,20 @@ export async function executeSlashCommandsOnChatInput(text, options = {}) { | ||
| 5398 | 5389 | document.querySelector('#form_sheld').classList.add('script_error'); |
| 5399 | 5390 | result = new SlashCommandClosureResult(); |
| 5400 | 5391 | result.isError = true; |
| 5401 | 5392 | result.errorMessage = e.message || 't`An unknown error occurred'`; |
| 5402 | 5393 | if (e.cause !== 'abort') { |
| 5403 | 5394 | if (e instanceof SlashCommandExecutionError) { |
| 5404 | 5395 | /**@type {SlashCommandExecutionError}*/ |
| 5405 | 5396 | const ex = e; |
| 5406 | 5397 | const toast = ` |
| 5407 | 5398 | <div>${ex.message}</div> |
| 5408 | 5399 | <div>${t`Line`}: ${ex.line} ${t`Column`}: ${ex.column}</div> |
| 5409 | 5400 | <pre style="text-align:left;">${ex.hint}</pre> |
| 5410 | 5401 | `; |
| 5411 | 5402 | const clickHint = '`<p>${t`Click to see details`}</p>'`; |
| 5412 | 5403 | toastr.error( |
| 5413 | 5404 | `${toast}${clickHint}`, |
| 5414 | 5405 | 'SlashCommandExecutionErrorSlash Command Execution Error', |
| 5415 | 5406 | { escapeHtml: false, timeOut: 10000, onclick: () => callGenericPopup(toast, POPUP_TYPE.TEXT, '', { allowHorizontalScrolling: true, allowVerticalScrolling: true }) }, |
| 5416 | 5407 | ); |
| 5417 | 5408 | } else { |
| @@ -5462,10 +5453,10 @@ async function executeSlashCommandsWithOptions(text, options = {}) { | ||
| 5462 | 5453 | const ex = e; |
| 5463 | 5454 | const toast = ` |
| 5464 | 5455 | <div>${ex.message}</div> |
| 5465 | 5456 | <div>${t`Line`}: ${ex.line} ${t`Column`}: ${ex.column}</div> |
| 5466 | 5457 | <pre style="text-align:left;">${ex.hint}</pre> |
| 5467 | 5458 | `; |
| 5468 | 5459 | const clickHint = '`<p>${t`Click to see details`}</p>'`; |
| 5469 | 5460 | toastr.error( |
| 5470 | 5461 | `${toast}${clickHint}`, |
| 5471 | 5462 | 'SlashCommandParserError', |
| @@ -5481,7 +5472,7 @@ async function executeSlashCommandsWithOptions(text, options = {}) { | ||
| 5481 | 5472 | try { |
| 5482 | 5473 | const result = await closure.execute(); |
| 5483 | 5474 | if (result.isAborted && !result.isQuietlyAborted) { |
| 5484 | 5475 | toastr.warning(result.abortReason, 't`Command execution aborted'`); |
| 5485 | 5476 | closure.abortController.signal.isQuiet = true; |
| 5486 | 5477 | } |
| 5487 | 5478 | return result; |
| @@ -7,13 +7,12 @@ import { SlashCommandDebugController } from './SlashCommandDebugController.js'; | ||
| 7 | 7 | import { SlashCommandScope } from './SlashCommandScope.js'; |
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * @typedef {NamedArgumentsCapture & { |
| 11 | 11 | * _scope:SlashCommandScope, |
| 12 | 12 | * _parserFlags:import('./SlashCommandParser.js').ParserFlags, |
| 13 | 13 | * _abortController:SlashCommandAbortController, |
| 14 | 14 | * _debugController:SlashCommandDebugController, |
| 15 | 15 | * _hasUnnamedArgument:boolean, |
| 16 | - * [id:string]:string|SlashCommandClosure|(string|SlashCommandClosure)[]|undefined, | |
| 17 | 16 | * }} NamedArguments |
| 18 | 17 | */ |
| 19 | 18 | |
| @@ -52,7 +51,7 @@ export class SlashCommand { | ||
| 52 | 51 | |
| 53 | 52 | |
| 54 | 53 | /**@type {string}*/ name; |
| 55 | 54 | /**@type {(namedArguments:{_scope:SlashCommandScope, _abortController:SlashCommandAbortController, [id:string]:string|SlashCommandClosure}NamedArguments, unnamedArguments:string|SlashCommandClosure|(string|SlashCommandClosure)[]UnnamedArguments)=>string|SlashCommandClosure|Promise<string|SlashCommandClosure>}*/ callback; |
| 56 | 55 | /**@type {string}*/ helpString; |
| 57 | 56 | /**@type {boolean}*/ splitUnnamedArgument = false; |
| 58 | 57 | /**@type {Number}*/ splitUnnamedArgumentCount; |
| @@ -238,7 +237,7 @@ export class SlashCommand { | ||
| 238 | 237 | const name = document.createElement('div'); { |
| 239 | 238 | name.classList.add('name'); |
| 240 | 239 | name.classList.add('monospace'); |
| 241 | 240 | name.title = 'commandt`Command name'`; |
| 242 | 241 | name.textContent = `/${key}`; |
| 243 | 242 | head.append(name); |
| 244 | 243 | } |
| @@ -284,19 +283,19 @@ export class SlashCommand { | ||
| 284 | 283 | const argItem = document.createElement('div'); { |
| 285 | 284 | argItem.classList.add('argument'); |
| 286 | 285 | argItem.classList.add('namedArgument'); |
| 287 | 286 | argItem.title = `${arg.isRequired ? ''t`Named argument` : 'optionalt`Optional '}named argument`; |
| 288 | 287 | if (!arg.isRequired || (arg.defaultValue ?? false)) argItem.classList.add('optional'); |
| 289 | 288 | if (arg.acceptsMultiple) argItem.classList.add('multiple'); |
| 290 | 289 | const name = document.createElement('span'); { |
| 291 | 290 | name.classList.add('argument-name'); |
| 292 | 291 | name.title = t`${argItem.title} - nameName`; |
| 293 | 292 | name.textContent = arg.name; |
| 294 | 293 | argItem.append(name); |
| 295 | 294 | } |
| 296 | 295 | if (arg.enumList.length > 0) { |
| 297 | 296 | const enums = document.createElement('span'); { |
| 298 | 297 | enums.classList.add('argument-enums'); |
| 299 | 298 | enums.title = t`${argItem.title} - acceptedAccepted values`; |
| 300 | 299 | for (const e of arg.enumList) { |
| 301 | 300 | const enumItem = document.createElement('span'); { |
| 302 | 301 | enumItem.classList.add('argument-enum'); |
| @@ -309,7 +308,7 @@ export class SlashCommand { | ||
| 309 | 308 | } else { |
| 310 | 309 | const types = document.createElement('span'); { |
| 311 | 310 | types.classList.add('argument-types'); |
| 312 | 311 | types.title = t`${argItem.title} - acceptedAccepted types`; |
| 313 | 312 | for (const t of arg.typeList) { |
| 314 | 313 | const type = document.createElement('span'); { |
| 315 | 314 | type.classList.add('argument-type'); |
| @@ -325,7 +324,7 @@ export class SlashCommand { | ||
| 325 | 324 | if (arg.defaultValue !== null) { |
| 326 | 325 | const argDefault = document.createElement('div'); { |
| 327 | 326 | argDefault.classList.add('argument-default'); |
| 328 | 327 | argDefault.title = 'defaultt`Default value'`; |
| 329 | 328 | argDefault.textContent = arg.defaultValue.toString(); |
| 330 | 329 | argSpec.append(argDefault); |
| 331 | 330 | } |
| @@ -348,13 +347,13 @@ export class SlashCommand { | ||
| 348 | 347 | const argItem = document.createElement('div'); { |
| 349 | 348 | argItem.classList.add('argument'); |
| 350 | 349 | argItem.classList.add('unnamedArgument'); |
| 351 | 350 | argItem.title = `${arg.isRequired ? ''t`Unnamed argument` : 'optionalt`Optional '}unnamed argument`; |
| 352 | 351 | if (!arg.isRequired || (arg.defaultValue ?? false)) argItem.classList.add('optional'); |
| 353 | 352 | if (arg.acceptsMultiple) argItem.classList.add('multiple'); |
| 354 | 353 | if (arg.enumList.length > 0) { |
| 355 | 354 | const enums = document.createElement('span'); { |
| 356 | 355 | enums.classList.add('argument-enums'); |
| 357 | 356 | enums.title = t`${argItem.title} - acceptedAccepted values`; |
| 358 | 357 | for (const e of arg.enumList) { |
| 359 | 358 | const enumItem = document.createElement('span'); { |
| 360 | 359 | enumItem.classList.add('argument-enum'); |
| @@ -367,7 +366,7 @@ export class SlashCommand { | ||
| 367 | 366 | } else { |
| 368 | 367 | const types = document.createElement('span'); { |
| 369 | 368 | types.classList.add('argument-types'); |
| 370 | 369 | types.title = t`${argItem.title} - acceptedAccepted types`; |
| 371 | 370 | for (const t of arg.typeList) { |
| 372 | 371 | const type = document.createElement('span'); { |
| 373 | 372 | type.classList.add('argument-type'); |
| @@ -383,7 +382,7 @@ export class SlashCommand { | ||
| 383 | 382 | if (arg.defaultValue !== null) { |
| 384 | 383 | const argDefault = document.createElement('div'); { |
| 385 | 384 | argDefault.classList.add('argument-default'); |
| 386 | 385 | argDefault.title = 'defaultt`Default value'`; |
| 387 | 386 | argDefault.textContent = arg.defaultValue.toString(); |
| 388 | 387 | argSpec.append(argDefault); |
| 389 | 388 | } |
| @@ -402,7 +401,7 @@ export class SlashCommand { | ||
| 402 | 401 | } |
| 403 | 402 | const returns = document.createElement('span'); { |
| 404 | 403 | returns.classList.add('returns'); |
| 405 | 404 | returns.title = [null, undefined, 'void'].includes(returnType) ? 'commandt`Command does not return anything'` : 'returnt`Return value'`; |
| 406 | 405 | returns.textContent = returnType ?? 'void'; |
| 407 | 406 | body.append(returns); |
| 408 | 407 | } |
| @@ -415,7 +414,7 @@ export class SlashCommand { | ||
| 415 | 414 | help.innerHTML = helpString; |
| 416 | 415 | for (const code of help.querySelectorAll('pre > code')) { |
| 417 | 416 | code.classList.add('language-stscript'); |
| 418 | 417 | hljs.highlightElement(/**@type {HTMLElement}*/(code)); |
| 419 | 418 | } |
| 420 | 419 | frag.append(help); |
| 421 | 420 | } |