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) {
1193 }1193 }
1194}1194}
11951195
1196function getCharacterSource(chId = this_chid) {1196export function getCharacterSource(chId = this_chid) {
1197 const character = characters[chId];1197 const character = characters[chId];
11981198
1199 if (!character) {1199 if (!character) {
public/scripts/st-context.js+6 -2
@@ -66,6 +66,7 @@ import {
66 scrollChatToBottom,66 scrollChatToBottom,
67 scrollOnMediaLoad,67 scrollOnMediaLoad,
68 getOneCharacter,68 getOneCharacter,
69 getCharacterSource,
69} from '../script.js';70} from '../script.js';
70import {71import {
71 extension_settings,72 extension_settings,
@@ -90,12 +91,12 @@ import { executeSlashCommands, executeSlashCommandsWithOptions, registerSlashCom
90import { SlashCommand } from './slash-commands/SlashCommand.js';91import { SlashCommand } from './slash-commands/SlashCommand.js';
91import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from './slash-commands/SlashCommandArgument.js';92import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from './slash-commands/SlashCommandArgument.js';
92import { SlashCommandParser } from './slash-commands/SlashCommandParser.js';93import { SlashCommandParser } from './slash-commands/SlashCommandParser.js';
93import { tag_map, tags } from './tags.js';94import { tag_map, tags, importTags } from './tags.js';
94import { getTextGenServer, textgenerationwebui_settings } from './textgen-settings.js';95import { getTextGenServer, textgenerationwebui_settings } from './textgen-settings.js';
95import { tokenizers, getTextTokens, getTokenCount, getTokenCountAsync, getTokenizerModel } from './tokenizers.js';96import { tokenizers, getTextTokens, getTokenCount, getTokenCountAsync, getTokenizerModel } from './tokenizers.js';
96import { ToolManager } from './tool-calling.js';97import { ToolManager } from './tool-calling.js';
97import { accountStorage } from './util/AccountStorage.js';98import { accountStorage } from './util/AccountStorage.js';
98import { timestampToMoment, uuidv4 } from './utils.js';99import { timestampToMoment, uuidv4, importFromExternalUrl } from './utils.js';
99import { addGlobalVariable, addLocalVariable, decrementGlobalVariable, decrementLocalVariable, deleteGlobalVariable, deleteLocalVariable, existsGlobalVariable, existsLocalVariable, getGlobalVariable, getLocalVariable, incrementGlobalVariable, incrementLocalVariable, setGlobalVariable, setLocalVariable } from './variables.js';100import { addGlobalVariable, addLocalVariable, decrementGlobalVariable, decrementLocalVariable, deleteGlobalVariable, deleteLocalVariable, existsGlobalVariable, existsLocalVariable, getGlobalVariable, getLocalVariable, incrementGlobalVariable, incrementLocalVariable, setGlobalVariable, setLocalVariable } from './variables.js';
100import { convertCharacterBook, getWorldInfoPrompt, loadWorldInfo, reloadEditor, saveWorldInfo, updateWorldInfoList } from './world-info.js';101import { convertCharacterBook, getWorldInfoPrompt, loadWorldInfo, reloadEditor, saveWorldInfo, updateWorldInfoList } from './world-info.js';
101import { ChatCompletionService, TextCompletionService } from './custom-request.js';102import { ChatCompletionService, TextCompletionService } from './custom-request.js';
@@ -217,6 +218,9 @@ export function getContext() {
217 getCharacters,218 getCharacters,
218 getOneCharacter,219 getOneCharacter,
219 getCharacterCardFields,220 getCharacterCardFields,
221 getCharacterSource,
222 importFromExternalUrl,
223 importTags,
220 uuidv4,224 uuidv4,
221 humanizedDateTime,225 humanizedDateTime,
222 updateMessageBlock,226 updateMessageBlock,