lumiverse-spindle-types 0.4.16 → 0.4.18

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.4.16",
3
+ "version": "0.4.18",
4
4
  "types": "./src/index.ts",
5
5
  "keywords": [
6
6
  "lumiverse",
package/src/api.ts CHANGED
@@ -169,7 +169,8 @@ export interface ImageGenResultDTO {
169
169
 
170
170
  /**
171
171
  * Safe representation of a character exposed to extensions.
172
- * Omits raw extensions blob — only exposes user-facing fields.
172
+ * Omits the raw `extensions` blob — only exposes user-facing fields plus
173
+ * a small allowlist of structured extension state (e.g. `world_book_ids`).
173
174
  */
174
175
  export interface CharacterDTO {
175
176
  id: string;
@@ -186,6 +187,11 @@ export interface CharacterDTO {
186
187
  alternate_greetings: string[];
187
188
  creator: string;
188
189
  image_id: string | null;
190
+ /**
191
+ * IDs of world books attached directly to this character. The legacy
192
+ * single-id form is auto-migrated, so consumers can rely on the array.
193
+ */
194
+ world_book_ids: string[];
189
195
  created_at: number;
190
196
  updated_at: number;
191
197
  }
@@ -203,6 +209,8 @@ export interface CharacterCreateDTO {
203
209
  tags?: string[];
204
210
  alternate_greetings?: string[];
205
211
  creator?: string;
212
+ /** Optional initial world book attachments. */
213
+ world_book_ids?: string[];
206
214
  }
207
215
 
208
216
  export interface CharacterUpdateDTO {
@@ -218,6 +226,11 @@ export interface CharacterUpdateDTO {
218
226
  tags?: string[];
219
227
  alternate_greetings?: string[];
220
228
  creator?: string;
229
+ /**
230
+ * Replace the character's world book attachments. Pass an empty array to
231
+ * detach all books. Omit the field to leave attachments unchanged.
232
+ */
233
+ world_book_ids?: string[];
221
234
  }
222
235
 
223
236
  // ─── Chat DTOs ──────────────────────────────────────────────────────────
@@ -799,6 +812,81 @@ export interface GenerationStoppedPayloadDTO {
799
812
  content?: string;
800
813
  }
801
814
 
815
+ // ─── Chat Message Event Payload DTOs ────────────────────────────────────
816
+
817
+ /**
818
+ * Wire shape of a chat message as delivered in WebSocket event payloads
819
+ * (e.g. `MESSAGE_SENT`, `MESSAGE_EDITED`, `MESSAGE_SWIPED`).
820
+ *
821
+ * This is the raw backend message shape and is distinct from the normalized
822
+ * `{ id, role, content, ... }` object returned by `spindle.chat.getMessages()`,
823
+ * which collapses `is_user`/`name` into a `role` discriminator.
824
+ */
825
+ export interface ChatMessageDTO {
826
+ id: string;
827
+ chat_id: string;
828
+ index_in_chat: number;
829
+ is_user: boolean;
830
+ name: string;
831
+ /** The currently active swipe content (mirrors `swipes[swipe_id]`). */
832
+ content: string;
833
+ send_date: number;
834
+ /** Index of the active swipe in `swipes`. `0` when the message has no alternates. */
835
+ swipe_id: number;
836
+ /** All swipe variants for this message, including the currently active one. */
837
+ swipes: string[];
838
+ /** Per-swipe creation timestamps (unix epoch seconds), aligned with `swipes`. */
839
+ swipe_dates: number[];
840
+ /** Free-form metadata bag (attachments, spindle metadata, reasoning, etc.). */
841
+ extra: Record<string, unknown>;
842
+ parent_message_id: string | null;
843
+ branch_id: string | null;
844
+ created_at: number;
845
+ }
846
+
847
+ /**
848
+ * Distinguishes the four ways a `MESSAGE_SWIPED` event can be triggered.
849
+ *
850
+ * - `'added'` — a new swipe variant was created (e.g. regenerate, manual add)
851
+ * - `'updated'` — an existing swipe's content was edited in place
852
+ * - `'deleted'` — a swipe variant was removed from the message
853
+ * - `'navigated'` — the user (or an extension) cycled the active swipe slot
854
+ */
855
+ export type MessageSwipeAction = "added" | "updated" | "deleted" | "navigated";
856
+
857
+ /**
858
+ * Payload for `MESSAGE_SWIPED` events.
859
+ *
860
+ * The discriminator fields (`action`, `swipeId`, `previousSwipeId`) let
861
+ * extensions tell the four swipe operations apart and maintain swipe-keyed
862
+ * state correctly without diffing the `swipes` array on every event.
863
+ */
864
+ export interface MessageSwipedPayloadDTO {
865
+ chatId: string;
866
+ /** The full message after the mutation. */
867
+ message: ChatMessageDTO;
868
+ /** Distinguishes which swipe operation produced this event. */
869
+ action: MessageSwipeAction;
870
+ /**
871
+ * The swipe index this event concerns. Semantics depend on `action`:
872
+ *
873
+ * - `'added'` — index of the new swipe (equal to `message.swipe_id` post-add)
874
+ * - `'updated'` — index of the edited swipe (may or may not equal `message.swipe_id`)
875
+ * - `'deleted'` — index that was removed. Note: this slot is no longer present
876
+ * in `message.swipes`, and `message.swipe_id` may have shifted
877
+ * if the deleted slot was at or before the previously active one.
878
+ * - `'navigated'` — destination index (equal to `message.swipe_id`)
879
+ */
880
+ swipeId: number;
881
+ /**
882
+ * For `'navigated'` and `'deleted'` events: the active swipe index *before*
883
+ * the change. Useful for direction detection on navigation, and for detecting
884
+ * whether the active slot was the one removed on deletion. Omitted for
885
+ * `'added'` and `'updated'`.
886
+ */
887
+ previousSwipeId?: number;
888
+ }
889
+
802
890
  /**
803
891
  * Observer handle returned by `spindle.generate.observe()`.
804
892
  * Provides a high-level API for watching an in-flight generation on a
@@ -916,6 +1004,26 @@ export type WorkerToHost =
916
1004
  chatId: string;
917
1005
  messageId: string;
918
1006
  }
1007
+ | {
1008
+ type: "chat_set_message_hidden";
1009
+ requestId: string;
1010
+ chatId: string;
1011
+ messageId: string;
1012
+ hidden: boolean;
1013
+ }
1014
+ | {
1015
+ type: "chat_set_messages_hidden";
1016
+ requestId: string;
1017
+ chatId: string;
1018
+ messageIds: string[];
1019
+ hidden: boolean;
1020
+ }
1021
+ | {
1022
+ type: "chat_is_message_hidden";
1023
+ requestId: string;
1024
+ chatId: string;
1025
+ messageId: string;
1026
+ }
919
1027
  | {
920
1028
  type: "events_track";
921
1029
  requestId: string;
package/src/index.ts CHANGED
@@ -67,6 +67,9 @@ export type {
67
67
  GenerationEndedPayloadDTO,
68
68
  GenerationStoppedPayloadDTO,
69
69
  GenerationObserver,
70
+ ChatMessageDTO,
71
+ MessageSwipeAction,
72
+ MessageSwipedPayloadDTO,
70
73
  WorkerToHost,
71
74
  HostToWorker,
72
75
  } from "./api";
@@ -44,6 +44,7 @@ import type {
44
44
  GenerationEndedPayloadDTO,
45
45
  GenerationStoppedPayloadDTO,
46
46
  GenerationObserver,
47
+ MessageSwipedPayloadDTO,
47
48
  } from "./api";
48
49
 
49
50
  /** The global `spindle` object available in backend extension workers */
@@ -56,6 +57,12 @@ export interface SpindleAPI {
56
57
  on(event: "GENERATION_ENDED", handler: (payload: GenerationEndedPayloadDTO) => void): () => void;
57
58
  /** Subscribe to generation-stopped events (requires `generation` permission). */
58
59
  on(event: "GENERATION_STOPPED", handler: (payload: GenerationStoppedPayloadDTO) => void): () => void;
60
+ /**
61
+ * Subscribe to swipe lifecycle events. The payload's `action` discriminator
62
+ * tells you whether a swipe was added, updated, deleted, or navigated, and
63
+ * `swipeId` identifies which slot the event concerns.
64
+ */
65
+ on(event: "MESSAGE_SWIPED", handler: (payload: MessageSwipedPayloadDTO) => void): () => void;
59
66
  /** Subscribe to a Lumiverse event. */
60
67
  on(event: string, handler: (payload: unknown) => void): () => void;
61
68
 
@@ -245,6 +252,27 @@ export interface SpindleAPI {
245
252
  }
246
253
  ): Promise<void>;
247
254
  deleteMessage(chatId: string, messageId: string): Promise<void>;
255
+ /**
256
+ * Mark a single message as hidden or visible. Hidden messages are
257
+ * excluded from chat memory embeddings (vector retrieval) but, in the
258
+ * current build, are still included in chat history during prompt
259
+ * assembly. See `chat-mutation.md` for the full semantics.
260
+ *
261
+ * Requires the `chat_mutation` permission.
262
+ */
263
+ setMessageHidden(chatId: string, messageId: string, hidden: boolean): Promise<void>;
264
+ /**
265
+ * Bulk variant of {@link setMessageHidden}. Capped at 500 message IDs
266
+ * per call (matching the underlying service limit).
267
+ *
268
+ * Requires the `chat_mutation` permission.
269
+ */
270
+ setMessagesHidden(chatId: string, messageIds: string[], hidden: boolean): Promise<void>;
271
+ /**
272
+ * Read the hidden flag for a single message. Returns `false` for messages
273
+ * that have never had the flag set. Requires the `chat_mutation` permission.
274
+ */
275
+ isMessageHidden(chatId: string, messageId: string): Promise<boolean>;
248
276
  };
249
277
 
250
278
  /** Extension-level telemetry */