lumiverse-spindle-types 0.6.9 → 0.6.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 +51 -4
- package/src/index.ts +4 -0
- package/src/spindle-api.ts +6 -2
- package/test/interceptor-consumer.ts +18 -0
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -252,11 +252,25 @@ export type MacroInterceptorPhase =
|
|
|
252
252
|
* them has no effect on the real environment. Persist state via
|
|
253
253
|
* `spindle.variables.*` helpers instead.
|
|
254
254
|
*/
|
|
255
|
+
export type MacroInterceptorCharacterEnvDTO =
|
|
256
|
+
Readonly<Record<string, unknown>> & {
|
|
257
|
+
/** Selected greeting stored in the current chat, including edits. */
|
|
258
|
+
readonly firstMessage: string;
|
|
259
|
+
/** Card-defined alternatives, excluding the default greeting. */
|
|
260
|
+
readonly alternateGreetings: readonly string[];
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
export type MacroInterceptorChatEnvDTO =
|
|
264
|
+
Readonly<Record<string, unknown>> & {
|
|
265
|
+
/** Selected index in [default greeting, ...alternate greetings]. */
|
|
266
|
+
readonly greetingIndex: number;
|
|
267
|
+
};
|
|
268
|
+
|
|
255
269
|
export interface MacroInterceptorEnvDTO {
|
|
256
270
|
readonly commit: boolean;
|
|
257
271
|
readonly names: Record<string, string>;
|
|
258
|
-
readonly character:
|
|
259
|
-
readonly chat:
|
|
272
|
+
readonly character: MacroInterceptorCharacterEnvDTO;
|
|
273
|
+
readonly chat: MacroInterceptorChatEnvDTO;
|
|
260
274
|
readonly system: Record<string, unknown>;
|
|
261
275
|
readonly variables: {
|
|
262
276
|
readonly local: Record<string, string>;
|
|
@@ -337,6 +351,8 @@ export interface MessageContentProcessorCtxDTO {
|
|
|
337
351
|
/** Undefined for `"create"` origins (the row doesn't exist yet). */
|
|
338
352
|
messageId?: string;
|
|
339
353
|
content: string;
|
|
354
|
+
/** True when the message was authored by the user. */
|
|
355
|
+
isUser: boolean;
|
|
340
356
|
extra?: Record<string, unknown>;
|
|
341
357
|
origin: MessageContentProcessorOrigin;
|
|
342
358
|
/** Set for `"swipe_update"` only — the zero-based index of the swipe being rewritten. */
|
|
@@ -1442,6 +1458,8 @@ export interface WorldBookEntryDTO {
|
|
|
1442
1458
|
group_weight: number;
|
|
1443
1459
|
probability: number;
|
|
1444
1460
|
scan_depth: number | null;
|
|
1461
|
+
/** Exclude the synthetic character greeting from lexical activation scans. */
|
|
1462
|
+
exclude_greeting: boolean;
|
|
1445
1463
|
case_sensitive: boolean;
|
|
1446
1464
|
match_whole_words: boolean;
|
|
1447
1465
|
automation_id: string | null;
|
|
@@ -1478,6 +1496,8 @@ export interface WorldBookEntryCreateDTO {
|
|
|
1478
1496
|
group_weight?: number;
|
|
1479
1497
|
probability?: number;
|
|
1480
1498
|
scan_depth?: number;
|
|
1499
|
+
/** Exclude the synthetic character greeting from lexical activation scans. */
|
|
1500
|
+
exclude_greeting?: boolean;
|
|
1481
1501
|
case_sensitive?: boolean;
|
|
1482
1502
|
match_whole_words?: boolean;
|
|
1483
1503
|
automation_id?: string;
|
|
@@ -1600,6 +1620,8 @@ export interface WorldInfoInterceptorEntryDTO {
|
|
|
1600
1620
|
readonly prevent_recursion: boolean;
|
|
1601
1621
|
readonly exclude_recursion: boolean;
|
|
1602
1622
|
readonly delay_until_recursion: boolean;
|
|
1623
|
+
/** Exclude the synthetic character greeting from lexical activation scans. */
|
|
1624
|
+
readonly exclude_greeting: boolean;
|
|
1603
1625
|
readonly scan_depth: number | null;
|
|
1604
1626
|
readonly order_value: number;
|
|
1605
1627
|
/** Attachment scope that contributed the entry's book to this chat. */
|
|
@@ -1622,6 +1644,22 @@ export interface WorldInfoInterceptorMessageDTO {
|
|
|
1622
1644
|
readonly index_in_chat: number;
|
|
1623
1645
|
}
|
|
1624
1646
|
|
|
1647
|
+
/** Effective host settings for world-info activation. */
|
|
1648
|
+
export interface WorldInfoActivationSettingsDTO {
|
|
1649
|
+
/** Default entry scan depth, or null to scan all available messages. */
|
|
1650
|
+
readonly globalScanDepth: number | null;
|
|
1651
|
+
readonly maxRecursionPasses: number;
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
/**
|
|
1655
|
+
* Restrictive, prompt-local changes to world info activation. Overrides from
|
|
1656
|
+
* multiple interceptors compose monotonically: `true` always wins.
|
|
1657
|
+
*/
|
|
1658
|
+
export interface WorldInfoActivationOverridesDTO {
|
|
1659
|
+
/** Set the effective recursion-pass limit to zero for this prompt. */
|
|
1660
|
+
readonly disableRecursion?: true;
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1625
1663
|
/**
|
|
1626
1664
|
* Context passed to a `registerWorldInfoInterceptor` handler. Fires inside
|
|
1627
1665
|
* `assemblePrompt` immediately before `activateWorldInfo` runs, so any
|
|
@@ -1636,15 +1674,23 @@ export interface WorldInfoInterceptorCtxDTO {
|
|
|
1636
1674
|
readonly messages: readonly WorldInfoInterceptorMessageDTO[];
|
|
1637
1675
|
readonly chatTurn: number;
|
|
1638
1676
|
readonly chatMetadata: Readonly<Record<string, unknown>>;
|
|
1677
|
+
readonly activationSettings: WorldInfoActivationSettingsDTO;
|
|
1639
1678
|
}
|
|
1640
1679
|
|
|
1641
1680
|
/**
|
|
1642
|
-
* Per-entry content
|
|
1643
|
-
* handler.
|
|
1681
|
+
* Per-entry content overrides emitted by a `registerWorldInfoInterceptor`
|
|
1682
|
+
* handler. Both values are prompt-local and never persist to the world book.
|
|
1644
1683
|
*/
|
|
1645
1684
|
export interface WorldInfoInterceptorMutationDTO {
|
|
1646
1685
|
readonly id: string;
|
|
1686
|
+
/** Replaces the entry content used for final prompt insertion. */
|
|
1647
1687
|
readonly content?: string;
|
|
1688
|
+
/**
|
|
1689
|
+
* Alternate content used only for empty filtering, content deduplication,
|
|
1690
|
+
* token accounting, and activation caps. Final insertion still uses
|
|
1691
|
+
* `content` (or the stored entry content when `content` is omitted).
|
|
1692
|
+
*/
|
|
1693
|
+
readonly selectionContent?: string;
|
|
1648
1694
|
}
|
|
1649
1695
|
|
|
1650
1696
|
/**
|
|
@@ -1658,6 +1704,7 @@ export interface WorldInfoInterceptorResultDTO {
|
|
|
1658
1704
|
readonly forced?: readonly string[];
|
|
1659
1705
|
readonly mutated?: readonly WorldInfoInterceptorMutationDTO[];
|
|
1660
1706
|
readonly captured?: readonly string[];
|
|
1707
|
+
readonly activationOverrides?: WorldInfoActivationOverridesDTO;
|
|
1661
1708
|
}
|
|
1662
1709
|
|
|
1663
1710
|
// ─── Databank DTOs ───────────────────────────────────────────────────────
|
package/src/index.ts
CHANGED
|
@@ -113,6 +113,8 @@ export type {
|
|
|
113
113
|
RegexScriptActiveOptionsDTO,
|
|
114
114
|
WorldInfoInterceptorEntryDTO,
|
|
115
115
|
WorldInfoInterceptorMessageDTO,
|
|
116
|
+
WorldInfoActivationSettingsDTO,
|
|
117
|
+
WorldInfoActivationOverridesDTO,
|
|
116
118
|
WorldInfoInterceptorCtxDTO,
|
|
117
119
|
WorldInfoInterceptorMutationDTO,
|
|
118
120
|
WorldInfoInterceptorResultDTO,
|
|
@@ -229,6 +231,8 @@ export type {
|
|
|
229
231
|
SharedRpcRequestContextDTO,
|
|
230
232
|
SharedRpcEndpointPolicyDTO,
|
|
231
233
|
MacroInterceptorPhase,
|
|
234
|
+
MacroInterceptorCharacterEnvDTO,
|
|
235
|
+
MacroInterceptorChatEnvDTO,
|
|
232
236
|
MacroInterceptorEnvDTO,
|
|
233
237
|
MacroInterceptorCtxDTO,
|
|
234
238
|
MacroInterceptorResultDTO,
|
package/src/spindle-api.ts
CHANGED
|
@@ -1402,7 +1402,11 @@ export interface SpindleAPI {
|
|
|
1402
1402
|
*
|
|
1403
1403
|
* Fires inside `assemblePrompt` immediately before `activateWorldInfo`
|
|
1404
1404
|
* runs. Handlers can disable, force-enable, or content-override world info
|
|
1405
|
-
* entries based on chat state, message history, or external rules.
|
|
1405
|
+
* entries based on chat state, message history, or external rules. A
|
|
1406
|
+
* separate selection-only content view can influence empty filtering,
|
|
1407
|
+
* deduplication, and host budget selection without changing final inserted
|
|
1408
|
+
* content. Handlers can also narrow the prompt-local activation scope by
|
|
1409
|
+
* disabling recursive keyword chaining.
|
|
1406
1410
|
* Multiple handlers chain in priority order and a later handler sees the
|
|
1407
1411
|
* prior handlers' votes applied — useful for cross-entry injection
|
|
1408
1412
|
* patterns where one entry merges into another and then disables itself.
|
|
@@ -1413,7 +1417,7 @@ export interface SpindleAPI {
|
|
|
1413
1417
|
* Returning `void` passes the activation set through unchanged. Per-handler
|
|
1414
1418
|
* 10s timeout; errors are logged and the chain continues.
|
|
1415
1419
|
*
|
|
1416
|
-
* @param handler Returns
|
|
1420
|
+
* @param handler Returns entry changes, capture requests, activation overrides, or `void`.
|
|
1417
1421
|
* @param priority Lower values run first. Default `100`.
|
|
1418
1422
|
*
|
|
1419
1423
|
* @example
|
|
@@ -127,6 +127,24 @@ const legacyArrayCallback: InterceptorHandler = async (input) => input;
|
|
|
127
127
|
const legacyResultCallback: InterceptorHandler = async (input) => ({ messages: input });
|
|
128
128
|
|
|
129
129
|
declare const spindle: SpindleAPI;
|
|
130
|
+
spindle.registerWorldInfoInterceptor(async (worldInfoContext) => {
|
|
131
|
+
const globalScanDepth: number | null =
|
|
132
|
+
worldInfoContext.activationSettings.globalScanDepth;
|
|
133
|
+
void globalScanDepth;
|
|
134
|
+
});
|
|
135
|
+
spindle.registerMessageContentProcessor(async (messageContext) => {
|
|
136
|
+
const isUser: boolean = messageContext.isUser;
|
|
137
|
+
void isUser;
|
|
138
|
+
});
|
|
139
|
+
spindle.registerMacroInterceptor(async (macroContext) => {
|
|
140
|
+
const firstMessage: string = macroContext.env.character.firstMessage;
|
|
141
|
+
const alternateGreetings: readonly string[] =
|
|
142
|
+
macroContext.env.character.alternateGreetings;
|
|
143
|
+
const greetingIndex: number = macroContext.env.chat.greetingIndex;
|
|
144
|
+
void firstMessage;
|
|
145
|
+
void alternateGreetings;
|
|
146
|
+
void greetingIndex;
|
|
147
|
+
});
|
|
130
148
|
const priorityDisposer: InterceptorDisposer = spindle.registerInterceptor(callback, 900, matchOptions);
|
|
131
149
|
const optionsDisposer: InterceptorDisposer = spindle.registerInterceptor(callback, options);
|
|
132
150
|
const handlerOnlyDisposer: InterceptorDisposer = spindle.registerInterceptor(legacyArrayCallback);
|