Expose character update APIs for extensions (#5062) * Expose character update APIs for extensions Add getCharacterSource, importFromExternalUrl, and importTags to the extension context (SillyTavern.getContext()). This allows extensions to: - Get the source URL for a character (Chub, etc.) - Import/update a character from an external URL - Import tags from a character's embedded tag data These functions already exist and are used internally but were not exposed to extensions. This enables extension developers to build features like bulk character update checking and tag synchronization. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Fix review comments --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
Signed| @@ -1193,7 +1193,7 @@ export async function getOneCharacter(avatarUrl) { | ||
| 1193 | 1193 | } |
| 1194 | 1194 | } |
| 1195 | 1195 | |
| 1196 | 1196 | export function getCharacterSource(chId = this_chid) { |
| 1197 | 1197 | const character = characters[chId]; |
| 1198 | 1198 | |
| 1199 | 1199 | if (!character) { |
| @@ -66,6 +66,7 @@ import { | ||
| 66 | 66 | scrollChatToBottom, |
| 67 | 67 | scrollOnMediaLoad, |
| 68 | 68 | getOneCharacter, |
| 69 | + getCharacterSource, | |
| 69 | 70 | } from '../script.js'; |
| 70 | 71 | import { |
| 71 | 72 | extension_settings, |
| @@ -90,12 +91,12 @@ import { executeSlashCommands, executeSlashCommandsWithOptions, registerSlashCom | ||
| 90 | 91 | import { SlashCommand } from './slash-commands/SlashCommand.js'; |
| 91 | 92 | import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from './slash-commands/SlashCommandArgument.js'; |
| 92 | 93 | import { SlashCommandParser } from './slash-commands/SlashCommandParser.js'; |
| 93 | 94 | import { tag_map, tags, importTags } from './tags.js'; |
| 94 | 95 | import { getTextGenServer, textgenerationwebui_settings } from './textgen-settings.js'; |
| 95 | 96 | import { tokenizers, getTextTokens, getTokenCount, getTokenCountAsync, getTokenizerModel } from './tokenizers.js'; |
| 96 | 97 | import { ToolManager } from './tool-calling.js'; |
| 97 | 98 | import { accountStorage } from './util/AccountStorage.js'; |
| 98 | 99 | import { timestampToMoment, uuidv4, importFromExternalUrl } from './utils.js'; |
| 99 | 100 | import { addGlobalVariable, addLocalVariable, decrementGlobalVariable, decrementLocalVariable, deleteGlobalVariable, deleteLocalVariable, existsGlobalVariable, existsLocalVariable, getGlobalVariable, getLocalVariable, incrementGlobalVariable, incrementLocalVariable, setGlobalVariable, setLocalVariable } from './variables.js'; |
| 100 | 101 | import { convertCharacterBook, getWorldInfoPrompt, loadWorldInfo, reloadEditor, saveWorldInfo, updateWorldInfoList } from './world-info.js'; |
| 101 | 102 | import { ChatCompletionService, TextCompletionService } from './custom-request.js'; |
| @@ -217,6 +218,9 @@ export function getContext() { | ||
| 217 | 218 | getCharacters, |
| 218 | 219 | getOneCharacter, |
| 219 | 220 | getCharacterCardFields, |
| 221 | + getCharacterSource, | |
| 222 | + importFromExternalUrl, | |
| 223 | + importTags, | |
| 220 | 224 | uuidv4, |
| 221 | 225 | humanizedDateTime, |
| 222 | 226 | updateMessageBlock, |