lumiverse-spindle-types 0.5.18 → 0.5.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/api.ts +22 -1
- package/src/dom.ts +67 -0
- package/src/index.ts +10 -0
- package/src/spindle-api.ts +19 -0
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -36,6 +36,14 @@ export interface LlmMessageDTO {
|
|
|
36
36
|
* only on `role: 'assistant'` messages.
|
|
37
37
|
*/
|
|
38
38
|
reasoning_content?: string;
|
|
39
|
+
/**
|
|
40
|
+
* True when this message is a chat-history turn (as opposed to a depth-injected
|
|
41
|
+
* world-info/preset/author's-note block that was spliced into the chat-history
|
|
42
|
+
* range). Set by the host only on the messages passed to the interceptor pipeline,
|
|
43
|
+
* so an extension applying prompt-target regex inline can reproduce the host's depth
|
|
44
|
+
* frame exactly.
|
|
45
|
+
*/
|
|
46
|
+
__isChatHistory?: boolean;
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
export type SpindleUserRoleDTO = "operator" | "admin" | "user";
|
|
@@ -159,12 +167,25 @@ export interface MacroInterceptorCtxDTO {
|
|
|
159
167
|
readonly userId?: string;
|
|
160
168
|
}
|
|
161
169
|
|
|
170
|
+
/**
|
|
171
|
+
* Lets an interceptor that resolves the template report its real cache
|
|
172
|
+
* dependencies so the host's display-regex cache can store the result
|
|
173
|
+
* and invalidate it precisely.
|
|
174
|
+
*/
|
|
175
|
+
export interface MacroInterceptorRichResultDTO {
|
|
176
|
+
text: string;
|
|
177
|
+
touchedVars?: readonly string[];
|
|
178
|
+
volatile?: boolean;
|
|
179
|
+
}
|
|
180
|
+
|
|
162
181
|
/**
|
|
163
182
|
* Return value of a macro interceptor handler.
|
|
164
183
|
* - `string` replaces the template for subsequent interceptors + parsing.
|
|
184
|
+
* (forces a non-cacheable resolution when it changes the template).
|
|
185
|
+
* - {@link MacroInterceptorRichResultDTO}
|
|
165
186
|
* - `void` / `undefined` passes the template through unchanged.
|
|
166
187
|
*/
|
|
167
|
-
export type MacroInterceptorResultDTO = string | void;
|
|
188
|
+
export type MacroInterceptorResultDTO = string | MacroInterceptorRichResultDTO | void;
|
|
168
189
|
|
|
169
190
|
// ─── Message Content Processor (permission: "chat_mutation") ───────────
|
|
170
191
|
|
package/src/dom.ts
CHANGED
|
@@ -630,6 +630,71 @@ export interface SpindleFrontendProcessRegistry {
|
|
|
630
630
|
): () => void;
|
|
631
631
|
}
|
|
632
632
|
|
|
633
|
+
export interface SpindleDisplayContext {
|
|
634
|
+
chatId?: string;
|
|
635
|
+
characterId?: string;
|
|
636
|
+
personaId?: string;
|
|
637
|
+
isUser: boolean;
|
|
638
|
+
depth: number;
|
|
639
|
+
messageId?: string;
|
|
640
|
+
messageIndex?: number;
|
|
641
|
+
role?: string;
|
|
642
|
+
dynamicMacros?: Record<string, string>;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
export interface SpindleDisplayResolveResult {
|
|
646
|
+
content: string;
|
|
647
|
+
touchedVars?: string[];
|
|
648
|
+
cacheable?: boolean;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
export interface SpindleDisplayTemplatesResult {
|
|
652
|
+
resolved: Record<string, string>;
|
|
653
|
+
touchedVars?: Record<string, string[]>;
|
|
654
|
+
cacheable?: Record<string, boolean>;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
export interface SpindleDisplayBodyArgs {
|
|
658
|
+
content: string;
|
|
659
|
+
context: SpindleDisplayContext;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
export interface SpindleDisplayTemplatesArgs {
|
|
663
|
+
templates: Record<string, string>;
|
|
664
|
+
context: SpindleDisplayContext;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
export interface SpindleDisplayScriptsArgs {
|
|
668
|
+
content: string;
|
|
669
|
+
scripts: unknown[];
|
|
670
|
+
context: SpindleDisplayContext;
|
|
671
|
+
resolvedFindPatterns?: Record<string, string>;
|
|
672
|
+
resolvedReplacements?: Record<string, string>;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* A frontend display resolver lets an extension take over display-time content
|
|
677
|
+
* resolution in the browser instead of round-tripping to the host backend. The
|
|
678
|
+
* host consults the registered resolver while rendering messages and falls back
|
|
679
|
+
* to its own backend resolution whenever the resolver is absent, reports it is
|
|
680
|
+
* not ready for the chat, throws, or returns `null`.
|
|
681
|
+
*/
|
|
682
|
+
export interface SpindleDisplayResolver {
|
|
683
|
+
ready(chatId: string): boolean;
|
|
684
|
+
resolveBody(args: SpindleDisplayBodyArgs): Promise<SpindleDisplayResolveResult | null>;
|
|
685
|
+
resolveTemplates(args: SpindleDisplayTemplatesArgs): Promise<SpindleDisplayTemplatesResult | null>;
|
|
686
|
+
applyScripts(args: SpindleDisplayScriptsArgs): Promise<SpindleDisplayResolveResult | null>;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
export interface SpindleDisplayResolverRegistry {
|
|
690
|
+
/** Register this extension's frontend display resolver. */
|
|
691
|
+
registerResolver(resolver: SpindleDisplayResolver): () => void;
|
|
692
|
+
/** Ask the host to invalidate cached display resolutions whose dependencies (a `<scope>:<name>` set) changed. */
|
|
693
|
+
invalidate(touchedVars: string[]): void;
|
|
694
|
+
/** Publish the set of character IDs whose display this extension owns. The host uses it to decide synchronously, at render time, whether a chat is owned by this resolver. */
|
|
695
|
+
setOwnedCharacters(characterIds: string[]): void;
|
|
696
|
+
}
|
|
697
|
+
|
|
633
698
|
/** Context object provided to frontend extension modules */
|
|
634
699
|
export interface SpindleFrontendContext {
|
|
635
700
|
dom: SpindleDOMHelper;
|
|
@@ -784,6 +849,8 @@ export interface SpindleFrontendContext {
|
|
|
784
849
|
/** Update a message through the host app's authenticated API. */
|
|
785
850
|
updateMessage(chatId: string, messageId: string, input: { content?: string }): Promise<unknown>;
|
|
786
851
|
};
|
|
852
|
+
/** Take over display-time content resolution in the browser. */
|
|
853
|
+
display?: SpindleDisplayResolverRegistry;
|
|
787
854
|
manifest: import("./manifest").SpindleManifest;
|
|
788
855
|
}
|
|
789
856
|
|
package/src/index.ts
CHANGED
|
@@ -162,6 +162,7 @@ export type {
|
|
|
162
162
|
MacroInterceptorEnvDTO,
|
|
163
163
|
MacroInterceptorCtxDTO,
|
|
164
164
|
MacroInterceptorResultDTO,
|
|
165
|
+
MacroInterceptorRichResultDTO,
|
|
165
166
|
MessageContentProcessorOrigin,
|
|
166
167
|
MessageContentProcessorCtxDTO,
|
|
167
168
|
MessageContentProcessorResultDTO,
|
|
@@ -222,6 +223,14 @@ export type {
|
|
|
222
223
|
SpindleUIEventsHelper,
|
|
223
224
|
SpindleFrontendProcessContext,
|
|
224
225
|
SpindleFrontendProcessRegistry,
|
|
226
|
+
SpindleDisplayResolver,
|
|
227
|
+
SpindleDisplayResolverRegistry,
|
|
228
|
+
SpindleDisplayContext,
|
|
229
|
+
SpindleDisplayBodyArgs,
|
|
230
|
+
SpindleDisplayTemplatesArgs,
|
|
231
|
+
SpindleDisplayScriptsArgs,
|
|
232
|
+
SpindleDisplayResolveResult,
|
|
233
|
+
SpindleDisplayTemplatesResult,
|
|
225
234
|
} from "./dom";
|
|
226
235
|
|
|
227
236
|
export type {
|
|
@@ -325,6 +334,7 @@ export type {
|
|
|
325
334
|
|
|
326
335
|
export type {
|
|
327
336
|
SpindleAPI,
|
|
337
|
+
SpindlePromptRegex,
|
|
328
338
|
FrontendProcessHandle,
|
|
329
339
|
BackendProcessHandle,
|
|
330
340
|
SpindleBackendProcessContext,
|
package/src/spindle-api.ts
CHANGED
|
@@ -209,6 +209,19 @@ export type SpindleBackendProcessModule = {
|
|
|
209
209
|
run?: (process: SpindleBackendProcessContext) => void | (() => void) | Promise<void | (() => void)>;
|
|
210
210
|
};
|
|
211
211
|
|
|
212
|
+
/**
|
|
213
|
+
* Lets an extension tell the host that it will apply `target:prompt` regex
|
|
214
|
+
* itself for a set of chats, so the host skips its own per-message prompt-regex
|
|
215
|
+
* pass for those chats.
|
|
216
|
+
*/
|
|
217
|
+
export interface SpindlePromptRegex {
|
|
218
|
+
/**
|
|
219
|
+
* Declare the chats this extension applies `target:prompt` regex for. Replaces
|
|
220
|
+
* the previously-declared set. Empty array clears ownership (host resumes its pass).
|
|
221
|
+
*/
|
|
222
|
+
setOwnedChats(chatIds: string[]): void;
|
|
223
|
+
}
|
|
224
|
+
|
|
212
225
|
/** The global `spindle` object available in backend extension workers */
|
|
213
226
|
export interface SpindleAPI {
|
|
214
227
|
/** Subscribe to generation-started events (requires `generation` permission). The optional `userId` identifies which user triggered the event. */
|
|
@@ -289,6 +302,12 @@ export interface SpindleAPI {
|
|
|
289
302
|
priority?: number
|
|
290
303
|
): void;
|
|
291
304
|
|
|
305
|
+
/**
|
|
306
|
+
* Declare the chats whose `target:prompt` regex this extension applies itself; the
|
|
307
|
+
* host skips its own pass for them.
|
|
308
|
+
*/
|
|
309
|
+
promptRegex: SpindlePromptRegex;
|
|
310
|
+
|
|
292
311
|
/** Register an LLM tool */
|
|
293
312
|
registerTool(tool: ToolRegistrationDTO): void;
|
|
294
313
|
/** Unregister an LLM tool */
|