Skip to content

Latest commit

 

History

History
95 lines (80 loc) · 8.05 KB

index.md

File metadata and controls

95 lines (80 loc) · 8.05 KB

Extension API Reference

This is the complete reference for the Luker Extension API, intended for plugin developers. All APIs are exposed through Luker.getContext(). The reference is split into the following pages:

Page What's covered
Chat & State Chat data, the unified Messages API, chat persistence, Chat State, Floor State, Character State, chat lifecycle, swipe API, extension prompts, media helpers
Characters Character cards, V2/legacy Proxy semantics, tags, import / export, per-character state
World Info Lorebook CRUD, activation scanning, character auxiliary world books
Presets & Prompts context.presets.*, buildPresetAwarePromptMessages, resolveWorldInfoForMessages, prompt structure inspection, reasoning helpers, settings views
Generation generateTask, tool registration, generateRaw / generateQuietPrompt, service classes, connection profiles
Image Generation context.imageGeneration.*, getExtensionApi('sd'), CardApp ctx.imageGeneration, reference image roles, capabilities, and attribution
Slash Commands Registering and executing slash commands, named/unnamed arguments, enums
Macros & Variables Macro registration, built-in macro reference, substituteParams, local & global variables
Skills context.skills.* — install, read, write, search, scope migration, embed pack/extract; CardApp ctx parity
Character Card Replace Flow The registries that run when a character card is replaced: card binding preservation slots and post-replace world book actions
UI & Popups Popups, loaders, templates, message formatting
Workbench API Unified Workbench platform — embedded workspaces, AI iteration targets, Q&A providers, local suggestion rules
Iteration Library Shared iterationLibrary helpers — runner, storage, diffs, proposal bus, and lorebook/skill/preset tools
Run Panel Shared in-memory run trace and floating Run Dock for multi-step LLM tasks — rounds, streaming sections, Stop, export
Plugin Integration Regex runtime, search tools, extension API registry, event system, i18n, settings storage, debug & scraper registration, tokenization, utilities, symbols & constants
Low-Level Endpoints Raw HTTP routes (advanced / debugging only)

Global Entry Point

const context = Luker.getContext();
Alias Description
Luker.getContext() Recommended
SillyTavern.getContext() Compatibility alias
st.getContext() Compatibility alias

New plugins should use Luker.getContext() exclusively. Compatibility aliases are retained only for the migration period.

Namespace Quick Reference

For quickly finding where an API lives, the context object groups related APIs into namespaces:

Namespace Contents
context.presets list, getSelected, getLive, getStored, save, resolve, readExtensions, writeExtensions, state.*
context.connectionProfiles list, resolve (deprecated for direct use)
context.variables.local get, set, add, inc, dec, del, has
context.variables.global get, set, add, inc, dec, del, has
context.swipe left, right, to, show, hide, refresh, isAllowed, state
context.symbols ignore (the IGNORE_SYMBOL sentinel)
context.constants unset, promptRoles, promptTypes, wiAnchor, wiPosition
context.macros register, registerAlias, registry, engine, category, envBuilder
context.loader show, hide, active, get, isBlocking, ToastMode, Handle
context.workbench registerWorkspace, registerIterateTarget, registerAskProvider, registerSuggestRuleProvider, open, saveSettingsChecked, getWorkspaces, getIterateTargets, getAskProviders, getSuggestRuleProviders, subscribe
context.runPanel createRunStore, createRunPanel, attachDock, openRunDock, toggleRunDock, getRunRecorder, events, withRound, withStreamingSection
context.iterationLibrary applyEdits, inverseEdit, registerOp, runner, storage, proposalBus, tools, render, textDiff, zoomOverlay, ui
context.skills list, get, readFile, listFiles, search, writeFile, editFile, deleteFile, install, delete, rename, moveScope, importBundled, listBundledManifest, packForEmbed, previewExtractEmbed, executeExtractEmbed, importFromUrl
context.imageGeneration isAvailable, generate, getCapabilities, listPresets, getCurrentPreset, switchPreset, getAvailableLoras
context.worldInfoEntry template, create, delete, setButtonClass, setGlobalSelection, getSorted
context.chatWorldInfo getNames, setSelection, globalSelection
context.openai proxies, ZAI_ENDPOINT, stripPresetConnectionFields
context.textCompletion types
context.secrets KEYS, state
context.lib DOMPurify, lodash, DiffMatchPatch, showdown, yaml

API Differences from SillyTavern

Luker is built on SillyTavern but has the following major API-level differences:

Area SillyTavern Luker
Chat persistence Full-file overwrite Patch-first (RFC 6902 incremental updates)
Chat-bound state chat_metadata only New Chat State mechanism + Floor State
Per-character state None getCharacterState / setCharacterState (separate from card JSON)
Preset management Direct import of internal modules Unified context.presets.* API
Prompt assembly Manual concatenation required buildPresetAwarePromptMessages()
World Info simulation None simulateWorldInfoActivation()
Character auxiliary world books None getCharaAuxWorlds()
Generation hooks Basic events New fine-grained hooks such as GENERATION_CONTEXT_READY, GENERATION_BEFORE_WORLD_INFO_SCAN, etc.
Event ordering Registration order Supports priority, pluginOrder, makeFirst/makeLast
Regex runtime No plugin API Unified context.regex.* API (registerRegexProvider, registerManagedRegexProvider, applyRegex)
Search tools No plugin API Luker.searchTools global API
Function calling Basic ToolManager Plain-text mode support + connection-level toggle + sendOpenAIRequest preset override
Connection config Single global config context.presets.resolve() supports per-preset connection resolution
Macro engine String substitution Structured macros.register() with handler context, args, categories
Character object Plain V1/V2 fields Proxy with V2 canonicalization and legacy-write deprecation warnings

Important

Prefer the APIs provided by Luker.getContext() over calling the underlying HTTP endpoints directly. The Context API encapsulates patch-first semantics, conflict handling, and retry logic; calling endpoints directly requires you to handle these details yourself.

Related Pages