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>

ef25a0365014fe7c298e34b207907f390647d0d8

Robert de Forest <guitar.robot@gmail.com>

Signed
2 files changed, +7 -3Ignore whitespace
public/script.js+1 -1
@@ -1193,7 +1193,7 @@ export async function getOneCharacter(avatarUrl) {
11931193 }
11941194}
11951195
11961196export function getCharacterSource(chId = this_chid) {
11971197 const character = characters[chId];
11981198
11991199 if (!character) {
public/scripts/st-context.js+6 -2
@@ -66,6 +66,7 @@ import {
6666 scrollChatToBottom,
6767 scrollOnMediaLoad,
6868 getOneCharacter,
69+ getCharacterSource,
6970} from '../script.js';
7071import {
7172 extension_settings,
@@ -90,12 +91,12 @@ import { executeSlashCommands, executeSlashCommandsWithOptions, registerSlashCom
9091import { SlashCommand } from './slash-commands/SlashCommand.js';
9192import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from './slash-commands/SlashCommandArgument.js';
9293import { SlashCommandParser } from './slash-commands/SlashCommandParser.js';
9394import { tag_map, tags, importTags } from './tags.js';
9495import { getTextGenServer, textgenerationwebui_settings } from './textgen-settings.js';
9596import { tokenizers, getTextTokens, getTokenCount, getTokenCountAsync, getTokenizerModel } from './tokenizers.js';
9697import { ToolManager } from './tool-calling.js';
9798import { accountStorage } from './util/AccountStorage.js';
9899import { timestampToMoment, uuidv4, importFromExternalUrl } from './utils.js';
99100import { addGlobalVariable, addLocalVariable, decrementGlobalVariable, decrementLocalVariable, deleteGlobalVariable, deleteLocalVariable, existsGlobalVariable, existsLocalVariable, getGlobalVariable, getLocalVariable, incrementGlobalVariable, incrementLocalVariable, setGlobalVariable, setLocalVariable } from './variables.js';
100101import { convertCharacterBook, getWorldInfoPrompt, loadWorldInfo, reloadEditor, saveWorldInfo, updateWorldInfoList } from './world-info.js';
101102import { ChatCompletionService, TextCompletionService } from './custom-request.js';
@@ -217,6 +218,9 @@ export function getContext() {
217218 getCharacters,
218219 getOneCharacter,
219220 getCharacterCardFields,
221+ getCharacterSource,
222+ importFromExternalUrl,
223+ importTags,
220224 uuidv4,
221225 humanizedDateTime,
222226 updateMessageBlock,