lumiverse-spindle-types 0.5.18 → 0.5.19

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lumiverse-spindle-types",
3
- "version": "0.5.18",
3
+ "version": "0.5.19",
4
4
  "types": "./src/index.ts",
5
5
  "keywords": [
6
6
  "lumiverse",
package/src/api.ts CHANGED
@@ -159,12 +159,25 @@ export interface MacroInterceptorCtxDTO {
159
159
  readonly userId?: string;
160
160
  }
161
161
 
162
+ /**
163
+ * Lets an interceptor that resolves the template report its real cache
164
+ * dependencies so the host's display-regex cache can store the result
165
+ * and invalidate it precisely.
166
+ */
167
+ export interface MacroInterceptorRichResultDTO {
168
+ text: string;
169
+ touchedVars?: readonly string[];
170
+ volatile?: boolean;
171
+ }
172
+
162
173
  /**
163
174
  * Return value of a macro interceptor handler.
164
175
  * - `string` replaces the template for subsequent interceptors + parsing.
176
+ * (forces a non-cacheable resolution when it changes the template).
177
+ * - {@link MacroInterceptorRichResultDTO}
165
178
  * - `void` / `undefined` passes the template through unchanged.
166
179
  */
167
- export type MacroInterceptorResultDTO = string | void;
180
+ export type MacroInterceptorResultDTO = string | MacroInterceptorRichResultDTO | void;
168
181
 
169
182
  // ─── Message Content Processor (permission: "chat_mutation") ───────────
170
183
 
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 {