lumiverse-spindle-types 0.4.31 → 0.4.32
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/index.ts +3 -0
- package/src/spindle-api.ts +7 -11
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -29,6 +29,27 @@ export interface MacroDefinitionDTO {
|
|
|
29
29
|
handler: string; // serialized function body (executed in worker context)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
/** Minimal shape exposed to extension macro handlers. Additional fields may be present. */
|
|
33
|
+
export interface MacroInvocationContextDTO {
|
|
34
|
+
/** False when the host is performing a dry / non-committing resolve. */
|
|
35
|
+
commit: boolean;
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface MacroResolveOptionsDTO {
|
|
40
|
+
chatId?: string;
|
|
41
|
+
characterId?: string;
|
|
42
|
+
/** For operator-scoped extensions only. */
|
|
43
|
+
userId?: string;
|
|
44
|
+
/** Defaults to true. Set false to request a dry / non-committing resolve. */
|
|
45
|
+
commit?: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface MacroResolveResultDTO {
|
|
49
|
+
text: string;
|
|
50
|
+
diagnostics: Array<{ message: string; offset: number; length: number }>;
|
|
51
|
+
}
|
|
52
|
+
|
|
32
53
|
export interface ToolRegistrationDTO {
|
|
33
54
|
name: string;
|
|
34
55
|
display_name: string;
|
|
@@ -1349,7 +1370,7 @@ export type WorkerToHost =
|
|
|
1349
1370
|
| { type: "confirm_open"; requestId: string; title: string; message: string; variant?: "info" | "warning" | "danger" | "success"; confirmLabel?: string; cancelLabel?: string; userId?: string }
|
|
1350
1371
|
| { type: "input_prompt_open"; requestId: string; title: string; message?: string; placeholder?: string; defaultValue?: string; submitLabel?: string; cancelLabel?: string; multiline?: boolean; userId?: string }
|
|
1351
1372
|
// ─── Macro Resolution (free tier) ──────────────────────────────────
|
|
1352
|
-
| { type: "macros_resolve"; requestId: string; template: string; chatId?: string; characterId?: string; userId?: string }
|
|
1373
|
+
| { type: "macros_resolve"; requestId: string; template: string; chatId?: string; characterId?: string; userId?: string; commit?: boolean }
|
|
1353
1374
|
// ─── Image Generation (gated: "image_gen") ──────────────────────────
|
|
1354
1375
|
| { type: "image_gen_generate"; requestId: string; input: ImageGenRequestDTO }
|
|
1355
1376
|
| { type: "image_gen_providers"; requestId: string; userId?: string }
|
package/src/index.ts
CHANGED
package/src/spindle-api.ts
CHANGED
|
@@ -3,6 +3,8 @@ import type {
|
|
|
3
3
|
LlmMessageDTO,
|
|
4
4
|
InterceptorResultDTO,
|
|
5
5
|
MacroDefinitionDTO,
|
|
6
|
+
MacroResolveOptionsDTO,
|
|
7
|
+
MacroResolveResultDTO,
|
|
6
8
|
ToolRegistrationDTO,
|
|
7
9
|
GenerationRequestDTO,
|
|
8
10
|
RequestInitDTO,
|
|
@@ -96,7 +98,7 @@ export interface SpindleAPI {
|
|
|
96
98
|
/** Subscribe to a Lumiverse event. */
|
|
97
99
|
on(event: string, handler: (payload: unknown, userId?: string) => void): () => void;
|
|
98
100
|
|
|
99
|
-
/** Register a macro */
|
|
101
|
+
/** Register a macro. Handler contexts expose `commit === false` during dry resolves. */
|
|
100
102
|
registerMacro(def: MacroDefinitionDTO): void;
|
|
101
103
|
/** Unregister a macro */
|
|
102
104
|
unregisterMacro(name: string): void;
|
|
@@ -763,6 +765,8 @@ export interface SpindleAPI {
|
|
|
763
765
|
* Resolve all macros in the given template string.
|
|
764
766
|
* Provide `chatId` and/or `characterId` for full context resolution.
|
|
765
767
|
* Without them, only context-free macros (time, random, etc.) resolve.
|
|
768
|
+
* Set `commit: false` for a dry / non-committing resolve; extension macro
|
|
769
|
+
* handlers will receive `ctx.commit === false`.
|
|
766
770
|
*
|
|
767
771
|
* @example
|
|
768
772
|
* ```ts
|
|
@@ -774,16 +778,8 @@ export interface SpindleAPI {
|
|
|
774
778
|
*/
|
|
775
779
|
resolve(
|
|
776
780
|
template: string,
|
|
777
|
-
options?:
|
|
778
|
-
|
|
779
|
-
characterId?: string;
|
|
780
|
-
/** For operator-scoped extensions only. */
|
|
781
|
-
userId?: string;
|
|
782
|
-
},
|
|
783
|
-
): Promise<{
|
|
784
|
-
text: string;
|
|
785
|
-
diagnostics: Array<{ message: string; offset: number; length: number }>;
|
|
786
|
-
}>;
|
|
781
|
+
options?: MacroResolveOptionsDTO,
|
|
782
|
+
): Promise<MacroResolveResultDTO>;
|
|
787
783
|
};
|
|
788
784
|
|
|
789
785
|
/**
|