lumiverse-spindle-types 0.4.25 → 0.4.27
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 +42 -0
- package/src/events.ts +1 -0
- package/src/index.ts +1 -0
- package/src/spindle-api.ts +42 -0
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -947,6 +947,28 @@ export interface MessageSwipedPayloadDTO {
|
|
|
947
947
|
previousSwipeId?: number;
|
|
948
948
|
}
|
|
949
949
|
|
|
950
|
+
/**
|
|
951
|
+
* Payload for `SWIPE_EDITED` events.
|
|
952
|
+
*
|
|
953
|
+
* Fires when `spindle.chat.updateMessage()` explicitly supplies one or more
|
|
954
|
+
* swipe-shaped fields (`swipes`, `swipe_id`, or `swipe_dates`). Plain content
|
|
955
|
+
* edits that mirror into the active swipe slot continue to emit only
|
|
956
|
+
* `MESSAGE_EDITED` — this event is for extension-driven rewrites of the
|
|
957
|
+
* swipe array itself, index navigation, or date-array rewrites.
|
|
958
|
+
*
|
|
959
|
+
* `MESSAGE_SWIPED` still fires for the dedicated swipe REST routes
|
|
960
|
+
* (`addSwipe`, `updateSwipe`, `deleteSwipe`, `cycleSwipe`) with its
|
|
961
|
+
* `action` discriminator. Consumers that need fine-grained action semantics
|
|
962
|
+
* should prefer `MESSAGE_SWIPED`; `SWIPE_EDITED` is intentionally coarser.
|
|
963
|
+
*/
|
|
964
|
+
export interface SwipeEditedPayloadDTO {
|
|
965
|
+
chatId: string;
|
|
966
|
+
/** The full message after the mutation. */
|
|
967
|
+
message: ChatMessageDTO;
|
|
968
|
+
/** Active swipe index before the mutation. Equals `message.swipe_id` when navigation did not occur. */
|
|
969
|
+
previousSwipeId: number;
|
|
970
|
+
}
|
|
971
|
+
|
|
950
972
|
/**
|
|
951
973
|
* Payload delivered to `spindle.on("TOOL_INVOCATION", ...)` handlers.
|
|
952
974
|
*
|
|
@@ -958,6 +980,13 @@ export interface MessageSwipedPayloadDTO {
|
|
|
958
980
|
* execution cycle, providing the assigned member's identity, role, chance,
|
|
959
981
|
* avatar URL, and Lumia personality fields. It is `undefined` for all other
|
|
960
982
|
* invocation paths.
|
|
983
|
+
*
|
|
984
|
+
* `contextMessages` is populated when the invocation originates from a council
|
|
985
|
+
* execution cycle — carrying the structured chat context (system enrichment +
|
|
986
|
+
* chat history) that was assembled for this member. Extensions can inspect
|
|
987
|
+
* role boundaries directly instead of re-parsing the flattened `args.context`
|
|
988
|
+
* string. Multi-part message content is flattened to its text portion before
|
|
989
|
+
* being delivered. `undefined` for non-council invocation paths.
|
|
961
990
|
*/
|
|
962
991
|
export interface ToolInvocationPayloadDTO {
|
|
963
992
|
/** The bare (unqualified) tool name, matching what was passed to `registerTool`. */
|
|
@@ -968,6 +997,12 @@ export interface ToolInvocationPayloadDTO {
|
|
|
968
997
|
requestId: string;
|
|
969
998
|
/** Council member snapshot when invoked via council — otherwise `undefined`. */
|
|
970
999
|
councilMember?: CouncilMemberContext;
|
|
1000
|
+
/**
|
|
1001
|
+
* Structured chat context for council invocations — preserves role
|
|
1002
|
+
* boundaries lost by the flattened `args.context` string. `undefined` for
|
|
1003
|
+
* non-council paths.
|
|
1004
|
+
*/
|
|
1005
|
+
contextMessages?: LlmMessageDTO[];
|
|
971
1006
|
}
|
|
972
1007
|
|
|
973
1008
|
/**
|
|
@@ -1334,6 +1369,13 @@ export type HostToWorker =
|
|
|
1334
1369
|
* Undefined for non-council invocation paths.
|
|
1335
1370
|
*/
|
|
1336
1371
|
councilMember?: CouncilMemberContext;
|
|
1372
|
+
/**
|
|
1373
|
+
* Structured chat context for council invocations — the same messages
|
|
1374
|
+
* that populated `args.context` (flattened string), but with role
|
|
1375
|
+
* boundaries preserved so extensions can re-render or filter them
|
|
1376
|
+
* without parsing. Undefined for non-council invocation paths.
|
|
1377
|
+
*/
|
|
1378
|
+
contextMessages?: LlmMessageDTO[];
|
|
1337
1379
|
}
|
|
1338
1380
|
| { type: "shutdown" }
|
|
1339
1381
|
| { type: "frontend_message"; payload: unknown; userId: string }
|
package/src/events.ts
CHANGED
|
@@ -17,6 +17,7 @@ export enum CoreEventType {
|
|
|
17
17
|
MESSAGE_EDITED = "MESSAGE_EDITED",
|
|
18
18
|
MESSAGE_DELETED = "MESSAGE_DELETED",
|
|
19
19
|
MESSAGE_SWIPED = "MESSAGE_SWIPED",
|
|
20
|
+
SWIPE_EDITED = "SWIPE_EDITED",
|
|
20
21
|
CHARACTER_MESSAGE_RENDERED = "CHARACTER_MESSAGE_RENDERED",
|
|
21
22
|
USER_MESSAGE_RENDERED = "USER_MESSAGE_RENDERED",
|
|
22
23
|
GENERATION_STARTED = "GENERATION_STARTED",
|
package/src/index.ts
CHANGED
package/src/spindle-api.ts
CHANGED
|
@@ -45,6 +45,7 @@ import type {
|
|
|
45
45
|
GenerationStoppedPayloadDTO,
|
|
46
46
|
GenerationObserver,
|
|
47
47
|
MessageSwipedPayloadDTO,
|
|
48
|
+
SwipeEditedPayloadDTO,
|
|
48
49
|
ToolInvocationPayloadDTO,
|
|
49
50
|
StreamChunkDTO,
|
|
50
51
|
} from "./api";
|
|
@@ -65,6 +66,15 @@ export interface SpindleAPI {
|
|
|
65
66
|
* `swipeId` identifies which slot the event concerns.
|
|
66
67
|
*/
|
|
67
68
|
on(event: "MESSAGE_SWIPED", handler: (payload: MessageSwipedPayloadDTO, userId?: string) => void): () => void;
|
|
69
|
+
/**
|
|
70
|
+
* Subscribe to `SWIPE_EDITED` events. Emitted when {@link SpindleAPI.chat.updateMessage}
|
|
71
|
+
* explicitly rewrites one or more swipe-shaped fields (`swipes`, `swipe_id`,
|
|
72
|
+
* or `swipe_dates`). Plain content-only edits continue to emit `MESSAGE_EDITED`
|
|
73
|
+
* only. This event is coarser than `MESSAGE_SWIPED` by design — use
|
|
74
|
+
* `MESSAGE_SWIPED` when you need the `added`/`updated`/`deleted`/`navigated`
|
|
75
|
+
* discriminator.
|
|
76
|
+
*/
|
|
77
|
+
on(event: "SWIPE_EDITED", handler: (payload: SwipeEditedPayloadDTO, userId?: string) => void): () => void;
|
|
68
78
|
/**
|
|
69
79
|
* Receive invocations for tools registered via {@link SpindleAPI.registerTool}.
|
|
70
80
|
*
|
|
@@ -308,6 +318,12 @@ export interface SpindleAPI {
|
|
|
308
318
|
id: string;
|
|
309
319
|
role: "system" | "user" | "assistant";
|
|
310
320
|
content: string;
|
|
321
|
+
/**
|
|
322
|
+
* The free-form `extra` bag minus `spindle_metadata` (which is surfaced
|
|
323
|
+
* separately on `metadata`). Carries reasoning text/duration, attachments,
|
|
324
|
+
* and any host-owned housekeeping fields.
|
|
325
|
+
*/
|
|
326
|
+
extra: Record<string, unknown>;
|
|
311
327
|
metadata?: Record<string, unknown>;
|
|
312
328
|
/** Index of the active swipe in `swipes`. `0` when the message has no alternates. */
|
|
313
329
|
swipe_id: number;
|
|
@@ -316,6 +332,8 @@ export interface SpindleAPI {
|
|
|
316
332
|
* `swipes[swipe_id]` always equals `content`.
|
|
317
333
|
*/
|
|
318
334
|
swipes: string[];
|
|
335
|
+
/** Per-swipe creation timestamps (unix epoch seconds), aligned with `swipes`. */
|
|
336
|
+
swipe_dates: number[];
|
|
319
337
|
}>>;
|
|
320
338
|
appendMessage(
|
|
321
339
|
chatId: string,
|
|
@@ -325,12 +343,36 @@ export interface SpindleAPI {
|
|
|
325
343
|
metadata?: Record<string, unknown>;
|
|
326
344
|
}
|
|
327
345
|
): Promise<{ id: string }>;
|
|
346
|
+
/**
|
|
347
|
+
* Patch an existing message. All fields are optional; `undefined` leaves
|
|
348
|
+
* the field untouched. Precedence rules:
|
|
349
|
+
*
|
|
350
|
+
* - If `content` is supplied, it overwrites both `messages.content` and
|
|
351
|
+
* `swipes[swipe_id]` (the active slot).
|
|
352
|
+
* - If `swipes` is supplied without `content`, the new active content is
|
|
353
|
+
* derived from `swipes[swipe_id]` (either the supplied `swipe_id` or
|
|
354
|
+
* the existing one).
|
|
355
|
+
* - If only `swipe_id` is supplied, it acts as a navigation and content
|
|
356
|
+
* is re-derived from the existing swipes array.
|
|
357
|
+
* - `reasoning.text === null` clears `extra.reasoning`; `reasoning.duration
|
|
358
|
+
* === null` clears `extra.reasoning_duration`. The two are independent.
|
|
359
|
+
*
|
|
360
|
+
* When any of `swipes`/`swipe_id`/`swipe_dates` are supplied, a
|
|
361
|
+
* `SWIPE_EDITED` event is emitted alongside (or instead of) `MESSAGE_EDITED`.
|
|
362
|
+
*/
|
|
328
363
|
updateMessage(
|
|
329
364
|
chatId: string,
|
|
330
365
|
messageId: string,
|
|
331
366
|
patch: {
|
|
332
367
|
content?: string;
|
|
333
368
|
metadata?: Record<string, unknown>;
|
|
369
|
+
swipes?: string[];
|
|
370
|
+
swipe_id?: number;
|
|
371
|
+
swipe_dates?: number[];
|
|
372
|
+
reasoning?: {
|
|
373
|
+
text?: string | null;
|
|
374
|
+
duration?: number | null;
|
|
375
|
+
};
|
|
334
376
|
}
|
|
335
377
|
): Promise<void>;
|
|
336
378
|
deleteMessage(chatId: string, messageId: string): Promise<void>;
|