lumiverse-spindle-types 0.4.34 → 0.4.37
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 +36 -3
- package/src/dom.ts +2 -0
- package/src/index.ts +1 -0
- package/src/spindle-api.ts +14 -10
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -9,6 +9,21 @@ export interface LlmMessageDTO {
|
|
|
9
9
|
name?: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Optional metadata returned by an interceptor so Lumiverse can surface
|
|
14
|
+
* extension-injected prompt messages as first-class items in Prompt Breakdown.
|
|
15
|
+
*
|
|
16
|
+
* `messageIndex` points at the message inside the interceptor's returned
|
|
17
|
+
* `messages` array. The host resolves role/content/extension attribution from
|
|
18
|
+
* that message and from the installed extension manifest, so extensions only
|
|
19
|
+
* need to identify which injected messages should appear in the breakdown.
|
|
20
|
+
*/
|
|
21
|
+
export interface InterceptorBreakdownEntryDTO {
|
|
22
|
+
messageIndex: number;
|
|
23
|
+
/** Optional human label for this injected prompt block. */
|
|
24
|
+
name?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
12
27
|
/**
|
|
13
28
|
* Return type for interceptor handlers.
|
|
14
29
|
* Interceptors may return either a plain `LlmMessageDTO[]` (backwards-compatible)
|
|
@@ -18,6 +33,8 @@ export interface InterceptorResultDTO {
|
|
|
18
33
|
messages: LlmMessageDTO[];
|
|
19
34
|
/** Provider parameters merged into the outgoing LLM request. Requires `generation_parameters` permission. */
|
|
20
35
|
parameters?: Record<string, unknown>;
|
|
36
|
+
/** Optional prompt-breakdown entries for injected messages. */
|
|
37
|
+
breakdown?: InterceptorBreakdownEntryDTO[];
|
|
21
38
|
}
|
|
22
39
|
|
|
23
40
|
export interface MacroDefinitionDTO {
|
|
@@ -522,6 +539,8 @@ export interface AssemblyBreakdownEntryDTO {
|
|
|
522
539
|
firstMessageIndex?: number;
|
|
523
540
|
preCountedTokens?: number;
|
|
524
541
|
excludeFromTotal?: boolean;
|
|
542
|
+
extensionId?: string;
|
|
543
|
+
extensionName?: string;
|
|
525
544
|
}
|
|
526
545
|
|
|
527
546
|
export interface ActivationStatsDTO {
|
|
@@ -552,7 +571,14 @@ export interface MemoryStatsDTO {
|
|
|
552
571
|
|
|
553
572
|
export interface DryRunTokenCountDTO {
|
|
554
573
|
total_tokens: number;
|
|
555
|
-
breakdown: Array<{
|
|
574
|
+
breakdown: Array<{
|
|
575
|
+
name: string;
|
|
576
|
+
type: string;
|
|
577
|
+
tokens: number;
|
|
578
|
+
role?: string;
|
|
579
|
+
extensionId?: string;
|
|
580
|
+
extensionName?: string;
|
|
581
|
+
}>;
|
|
556
582
|
tokenizer_id: string | null;
|
|
557
583
|
tokenizer_name: string | null;
|
|
558
584
|
}
|
|
@@ -868,6 +894,7 @@ export interface GenerationStartedPayloadDTO {
|
|
|
868
894
|
targetMessageId?: string;
|
|
869
895
|
characterId?: string;
|
|
870
896
|
characterName?: string;
|
|
897
|
+
breakdown?: AssemblyBreakdownEntryDTO[];
|
|
871
898
|
}
|
|
872
899
|
|
|
873
900
|
/** Payload for `STREAM_TOKEN_RECEIVED` events. */
|
|
@@ -1108,7 +1135,13 @@ export type WorkerToHost =
|
|
|
1108
1135
|
| { type: "unregister_macro"; name: string }
|
|
1109
1136
|
| { type: "update_macro_value"; name: string; value: string }
|
|
1110
1137
|
| { type: "register_interceptor"; priority?: number }
|
|
1111
|
-
| {
|
|
1138
|
+
| {
|
|
1139
|
+
type: "intercept_result";
|
|
1140
|
+
requestId: string;
|
|
1141
|
+
messages: LlmMessageDTO[];
|
|
1142
|
+
parameters?: Record<string, unknown>;
|
|
1143
|
+
breakdown?: InterceptorBreakdownEntryDTO[];
|
|
1144
|
+
}
|
|
1112
1145
|
| { type: "register_tool"; tool: ToolRegistrationDTO }
|
|
1113
1146
|
| { type: "unregister_tool"; name: string }
|
|
1114
1147
|
| { type: "request_generation"; requestId: string; input: GenerationRequestDTO }
|
|
@@ -1366,7 +1399,7 @@ export type WorkerToHost =
|
|
|
1366
1399
|
// ─── Chat Memories (gated: "chats") ───────────────────────────────
|
|
1367
1400
|
| { type: "chats_get_memories"; requestId: string; chatId: string; topK?: number; userId?: string }
|
|
1368
1401
|
// ─── Toast (free tier) ───────────────────────────────────────────────
|
|
1369
|
-
| { type: "toast_show"; toastType: "success" | "warning" | "error" | "info"; message: string; title?: string; duration?: number }
|
|
1402
|
+
| { type: "toast_show"; toastType: "success" | "warning" | "error" | "info"; message: string; title?: string; duration?: number; userId?: string }
|
|
1370
1403
|
// ─── Push Notifications (gated: "push_notification") ────────────────
|
|
1371
1404
|
| { type: "push_send"; requestId: string; title: string; body: string; tag?: string; url?: string; userId?: string; icon?: string; rawTitle?: boolean; image?: string }
|
|
1372
1405
|
| { type: "push_get_status"; requestId: string; userId?: string }
|
package/src/dom.ts
CHANGED
|
@@ -135,6 +135,7 @@ export interface SpindleAppMountHandle {
|
|
|
135
135
|
export interface SpindleInputBarActionOptions {
|
|
136
136
|
id: string;
|
|
137
137
|
label: string;
|
|
138
|
+
subtitle?: string;
|
|
138
139
|
iconSvg?: string;
|
|
139
140
|
iconUrl?: string;
|
|
140
141
|
enabled?: boolean;
|
|
@@ -143,6 +144,7 @@ export interface SpindleInputBarActionOptions {
|
|
|
143
144
|
export interface SpindleInputBarActionHandle {
|
|
144
145
|
actionId: string;
|
|
145
146
|
setLabel(label: string): void;
|
|
147
|
+
setSubtitle(subtitle?: string): void;
|
|
146
148
|
setEnabled(enabled: boolean): void;
|
|
147
149
|
onClick(handler: () => void): () => void;
|
|
148
150
|
destroy(): void;
|
package/src/index.ts
CHANGED
package/src/spindle-api.ts
CHANGED
|
@@ -57,13 +57,13 @@ import type {
|
|
|
57
57
|
|
|
58
58
|
/** The global `spindle` object available in backend extension workers */
|
|
59
59
|
export interface SpindleAPI {
|
|
60
|
-
/** Subscribe to generation-started events (requires `generation` permission). */
|
|
60
|
+
/** Subscribe to generation-started events (requires `generation` permission). The optional `userId` identifies which user triggered the event. */
|
|
61
61
|
on(event: "GENERATION_STARTED", handler: (payload: GenerationStartedPayloadDTO, userId?: string) => void): () => void;
|
|
62
|
-
/** Subscribe to streamed token events (requires `generation` permission). */
|
|
62
|
+
/** Subscribe to streamed token events (requires `generation` permission). The optional `userId` identifies which user triggered the event. */
|
|
63
63
|
on(event: "STREAM_TOKEN_RECEIVED", handler: (payload: StreamTokenPayloadDTO, userId?: string) => void): () => void;
|
|
64
|
-
/** Subscribe to generation-ended events (requires `generation` permission). */
|
|
64
|
+
/** Subscribe to generation-ended events (requires `generation` permission). The optional `userId` identifies which user triggered the event. */
|
|
65
65
|
on(event: "GENERATION_ENDED", handler: (payload: GenerationEndedPayloadDTO, userId?: string) => void): () => void;
|
|
66
|
-
/** Subscribe to generation-stopped events (requires `generation` permission). */
|
|
66
|
+
/** Subscribe to generation-stopped events (requires `generation` permission). The optional `userId` identifies which user triggered the event. */
|
|
67
67
|
on(event: "GENERATION_STOPPED", handler: (payload: GenerationStoppedPayloadDTO, userId?: string) => void): () => void;
|
|
68
68
|
/**
|
|
69
69
|
* Subscribe to swipe lifecycle events. The payload's `action` discriminator
|
|
@@ -95,7 +95,7 @@ export interface SpindleAPI {
|
|
|
95
95
|
event: "TOOL_INVOCATION",
|
|
96
96
|
handler: (payload: ToolInvocationPayloadDTO) => string | Promise<string> | void | Promise<void>
|
|
97
97
|
): () => void;
|
|
98
|
-
/** Subscribe to a Lumiverse event. */
|
|
98
|
+
/** Subscribe to a Lumiverse event. Multi-user extensions should use the optional `userId` to keep per-user state and notifications isolated. */
|
|
99
99
|
on(event: string, handler: (payload: unknown, userId?: string) => void): () => void;
|
|
100
100
|
|
|
101
101
|
/** Register a macro. Handler contexts expose `commit === false` during dry resolves. */
|
|
@@ -116,7 +116,9 @@ export interface SpindleAPI {
|
|
|
116
116
|
* The handler receives the assembled messages and a context object, and may
|
|
117
117
|
* return either a plain `LlmMessageDTO[]` (backwards-compatible) or an
|
|
118
118
|
* `InterceptorResultDTO` to also inject generation parameters into the
|
|
119
|
-
* outgoing LLM request.
|
|
119
|
+
* outgoing LLM request. `InterceptorResultDTO.breakdown` can be used to mark
|
|
120
|
+
* specific injected messages as Prompt Breakdown entries so dry-run/live UI
|
|
121
|
+
* and saved breakdowns can attribute them back to the extension.
|
|
120
122
|
*
|
|
121
123
|
* Returning `parameters` requires the `generation_parameters` permission.
|
|
122
124
|
* Without it, returned parameters are silently stripped.
|
|
@@ -708,6 +710,8 @@ export interface SpindleAPI {
|
|
|
708
710
|
/**
|
|
709
711
|
* Send a push notification to a user's registered devices.
|
|
710
712
|
* Only delivered when the app is not focused (avoids double-notification).
|
|
713
|
+
* Operator-scoped extensions should pass the `userId` from the triggering
|
|
714
|
+
* frontend message or event handler to avoid cross-user delivery.
|
|
711
715
|
*/
|
|
712
716
|
send(input: {
|
|
713
717
|
title: string;
|
|
@@ -810,10 +814,10 @@ export interface SpindleAPI {
|
|
|
810
814
|
|
|
811
815
|
/** Show toast notifications in the frontend UI (free tier — no permission needed) */
|
|
812
816
|
toast: {
|
|
813
|
-
success(message: string, options?: { title?: string; duration?: number }): void;
|
|
814
|
-
warning(message: string, options?: { title?: string; duration?: number }): void;
|
|
815
|
-
error(message: string, options?: { title?: string; duration?: number }): void;
|
|
816
|
-
info(message: string, options?: { title?: string; duration?: number }): void;
|
|
817
|
+
success(message: string, options?: { title?: string; duration?: number; /** For operator-scoped extensions only. */ userId?: string }): void;
|
|
818
|
+
warning(message: string, options?: { title?: string; duration?: number; /** For operator-scoped extensions only. */ userId?: string }): void;
|
|
819
|
+
error(message: string, options?: { title?: string; duration?: number; /** For operator-scoped extensions only. */ userId?: string }): void;
|
|
820
|
+
info(message: string, options?: { title?: string; duration?: number; /** For operator-scoped extensions only. */ userId?: string }): void;
|
|
817
821
|
};
|
|
818
822
|
|
|
819
823
|
/** OAuth callback handling (permission: "oauth") */
|