lumiverse-spindle-types 0.4.3 → 0.4.10
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 +13 -1
- package/src/index.ts +1 -0
- package/src/permissions.ts +4 -1
- package/src/spindle-api.ts +19 -2
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -8,6 +8,17 @@ export interface LlmMessageDTO {
|
|
|
8
8
|
name?: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Return type for interceptor handlers.
|
|
13
|
+
* Interceptors may return either a plain `LlmMessageDTO[]` (backwards-compatible)
|
|
14
|
+
* or this object to also inject generation parameters (requires `generation_parameters` permission).
|
|
15
|
+
*/
|
|
16
|
+
export interface InterceptorResultDTO {
|
|
17
|
+
messages: LlmMessageDTO[];
|
|
18
|
+
/** Provider parameters merged into the outgoing LLM request. Requires `generation_parameters` permission. */
|
|
19
|
+
parameters?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
|
|
11
22
|
export interface MacroDefinitionDTO {
|
|
12
23
|
name: string;
|
|
13
24
|
category: string;
|
|
@@ -753,7 +764,7 @@ export type WorkerToHost =
|
|
|
753
764
|
| { type: "unregister_macro"; name: string }
|
|
754
765
|
| { type: "update_macro_value"; name: string; value: string }
|
|
755
766
|
| { type: "register_interceptor"; priority?: number }
|
|
756
|
-
| { type: "intercept_result"; requestId: string; messages: LlmMessageDTO[] }
|
|
767
|
+
| { type: "intercept_result"; requestId: string; messages: LlmMessageDTO[]; parameters?: Record<string, unknown> }
|
|
757
768
|
| { type: "register_tool"; tool: ToolRegistrationDTO }
|
|
758
769
|
| { type: "unregister_tool"; name: string }
|
|
759
770
|
| { type: "request_generation"; requestId: string; input: GenerationRequestDTO }
|
|
@@ -973,6 +984,7 @@ export type WorkerToHost =
|
|
|
973
984
|
| { type: "text_editor_open"; requestId: string; title?: string; value?: string; placeholder?: string; userId?: string }
|
|
974
985
|
// ─── Modal (free tier) ────────────────────────────────────────────
|
|
975
986
|
| { type: "modal_open"; requestId: string; title: string; items: SpindleModalItemDTO[]; width?: number; maxHeight?: number; persistent?: boolean; userId?: string }
|
|
987
|
+
| { type: "modal_close"; requestId: string; userId?: string }
|
|
976
988
|
| { type: "confirm_open"; requestId: string; title: string; message: string; variant?: "info" | "warning" | "danger" | "success"; confirmLabel?: string; cancelLabel?: string; userId?: string }
|
|
977
989
|
| { type: "input_prompt_open"; requestId: string; title: string; message?: string; placeholder?: string; defaultValue?: string; submitLabel?: string; cancelLabel?: string; multiline?: boolean; userId?: string }
|
|
978
990
|
// ─── Macro Resolution (free tier) ──────────────────────────────────
|
package/src/index.ts
CHANGED
package/src/permissions.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* - "tools" — register LLM tools
|
|
10
10
|
* - "cors_proxy" — use CORS proxy
|
|
11
11
|
* - "context_handler" — register global context middleware
|
|
12
|
+
* - "generation_parameters" — inject parameters into in-flight generations via interceptors
|
|
12
13
|
* - "characters" — CRUD on character cards
|
|
13
14
|
* - "chats" — CRUD on chat sessions
|
|
14
15
|
* - "personas" — CRUD on personas
|
|
@@ -30,7 +31,8 @@ export type SpindlePermission =
|
|
|
30
31
|
| "world_books"
|
|
31
32
|
| "personas"
|
|
32
33
|
| "push_notification"
|
|
33
|
-
| "image_gen"
|
|
34
|
+
| "image_gen"
|
|
35
|
+
| "generation_parameters";
|
|
34
36
|
|
|
35
37
|
export const ALL_PERMISSIONS: readonly SpindlePermission[] = [
|
|
36
38
|
"generation",
|
|
@@ -50,6 +52,7 @@ export const ALL_PERMISSIONS: readonly SpindlePermission[] = [
|
|
|
50
52
|
"personas",
|
|
51
53
|
"push_notification",
|
|
52
54
|
"image_gen",
|
|
55
|
+
"generation_parameters",
|
|
53
56
|
] as const;
|
|
54
57
|
|
|
55
58
|
export function isValidPermission(p: string): p is SpindlePermission {
|
package/src/spindle-api.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SpindleManifest } from "./manifest";
|
|
2
2
|
import type {
|
|
3
3
|
LlmMessageDTO,
|
|
4
|
+
InterceptorResultDTO,
|
|
4
5
|
MacroDefinitionDTO,
|
|
5
6
|
ToolRegistrationDTO,
|
|
6
7
|
GenerationRequestDTO,
|
|
@@ -57,12 +58,22 @@ export interface SpindleAPI {
|
|
|
57
58
|
*/
|
|
58
59
|
updateMacroValue(name: string, value: string): void;
|
|
59
60
|
|
|
60
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* Register an interceptor for pre-generation prompt modification.
|
|
63
|
+
*
|
|
64
|
+
* The handler receives the assembled messages and a context object, and may
|
|
65
|
+
* return either a plain `LlmMessageDTO[]` (backwards-compatible) or an
|
|
66
|
+
* `InterceptorResultDTO` to also inject generation parameters into the
|
|
67
|
+
* outgoing LLM request.
|
|
68
|
+
*
|
|
69
|
+
* Returning `parameters` requires the `generation_parameters` permission.
|
|
70
|
+
* Without it, returned parameters are silently stripped.
|
|
71
|
+
*/
|
|
61
72
|
registerInterceptor(
|
|
62
73
|
handler: (
|
|
63
74
|
messages: LlmMessageDTO[],
|
|
64
75
|
context: unknown
|
|
65
|
-
) => Promise<LlmMessageDTO[]>,
|
|
76
|
+
) => Promise<LlmMessageDTO[] | InterceptorResultDTO>,
|
|
66
77
|
priority?: number
|
|
67
78
|
): void;
|
|
68
79
|
|
|
@@ -719,6 +730,12 @@ export interface SpindleAPI {
|
|
|
719
730
|
/** How the modal was dismissed. */
|
|
720
731
|
dismissedBy: "user" | "extension" | "cleanup";
|
|
721
732
|
}>;
|
|
733
|
+
/**
|
|
734
|
+
* Programmatically close a modal that was opened with `spindle.modal.open()`.
|
|
735
|
+
* `openRequestId` is the request ID returned alongside the modal handle.
|
|
736
|
+
* Resolves immediately after the dismiss event is emitted.
|
|
737
|
+
*/
|
|
738
|
+
close(openRequestId: string, userId?: string): Promise<void>;
|
|
722
739
|
/**
|
|
723
740
|
* Show a confirmation modal and wait for the user's response.
|
|
724
741
|
* The host renders a themed dialog with a message, variant-colored
|