lumiverse-spindle-types 0.4.56 → 0.4.58
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 +79 -0
- package/src/dom.ts +78 -0
- package/src/events.ts +2 -0
- package/src/index.ts +21 -5
- package/src/permissions.ts +2 -0
- package/src/spindle-api.ts +23 -0
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -667,6 +667,78 @@ export interface WorldBookEntryCreateDTO {
|
|
|
667
667
|
|
|
668
668
|
export type WorldBookEntryUpdateDTO = WorldBookEntryCreateDTO;
|
|
669
669
|
|
|
670
|
+
// ─── Regex Script DTOs ──────────────────────────────────────────────────
|
|
671
|
+
|
|
672
|
+
export type RegexPlacementDTO = "user_input" | "ai_output" | "world_info" | "reasoning";
|
|
673
|
+
export type RegexScopeDTO = "global" | "character" | "chat";
|
|
674
|
+
export type RegexTargetDTO = "prompt" | "response" | "display";
|
|
675
|
+
export type RegexMacroModeDTO = "none" | "raw" | "escaped";
|
|
676
|
+
|
|
677
|
+
export interface RegexScriptDTO {
|
|
678
|
+
id: string;
|
|
679
|
+
name: string;
|
|
680
|
+
script_id: string;
|
|
681
|
+
find_regex: string;
|
|
682
|
+
replace_string: string;
|
|
683
|
+
flags: string;
|
|
684
|
+
placement: RegexPlacementDTO[];
|
|
685
|
+
scope: RegexScopeDTO;
|
|
686
|
+
scope_id: string | null;
|
|
687
|
+
target: RegexTargetDTO;
|
|
688
|
+
min_depth: number | null;
|
|
689
|
+
max_depth: number | null;
|
|
690
|
+
trim_strings: string[];
|
|
691
|
+
run_on_edit: boolean;
|
|
692
|
+
substitute_macros: RegexMacroModeDTO;
|
|
693
|
+
disabled: boolean;
|
|
694
|
+
sort_order: number;
|
|
695
|
+
description: string;
|
|
696
|
+
folder: string;
|
|
697
|
+
metadata: Record<string, unknown>;
|
|
698
|
+
created_at: number;
|
|
699
|
+
updated_at: number;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
export interface RegexScriptListOptionsDTO {
|
|
703
|
+
scope?: RegexScopeDTO;
|
|
704
|
+
scopeId?: string;
|
|
705
|
+
target?: RegexTargetDTO;
|
|
706
|
+
limit?: number;
|
|
707
|
+
offset?: number;
|
|
708
|
+
userId?: string;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
export interface RegexScriptActiveOptionsDTO {
|
|
712
|
+
target: RegexTargetDTO;
|
|
713
|
+
characterId?: string;
|
|
714
|
+
chatId?: string;
|
|
715
|
+
userId?: string;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
export interface RegexScriptCreateDTO {
|
|
719
|
+
name: string;
|
|
720
|
+
find_regex: string;
|
|
721
|
+
replace_string?: string;
|
|
722
|
+
flags?: string;
|
|
723
|
+
placement?: RegexPlacementDTO[];
|
|
724
|
+
scope?: RegexScopeDTO;
|
|
725
|
+
scope_id?: string | null;
|
|
726
|
+
target?: RegexTargetDTO;
|
|
727
|
+
min_depth?: number | null;
|
|
728
|
+
max_depth?: number | null;
|
|
729
|
+
trim_strings?: string[];
|
|
730
|
+
run_on_edit?: boolean;
|
|
731
|
+
substitute_macros?: RegexMacroModeDTO;
|
|
732
|
+
disabled?: boolean;
|
|
733
|
+
sort_order?: number;
|
|
734
|
+
description?: string;
|
|
735
|
+
folder?: string;
|
|
736
|
+
metadata?: Record<string, unknown>;
|
|
737
|
+
script_id?: string;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
export type RegexScriptUpdateDTO = Partial<RegexScriptCreateDTO>;
|
|
741
|
+
|
|
670
742
|
// ─── Databank DTOs ───────────────────────────────────────────────────────
|
|
671
743
|
|
|
672
744
|
export type DatabankScopeDTO = "global" | "character" | "chat";
|
|
@@ -1911,6 +1983,13 @@ export type WorkerToHost =
|
|
|
1911
1983
|
| { type: "council_get_available_lumia_items"; requestId: string; userId?: string }
|
|
1912
1984
|
// ─── Activated World Info (gated: "world_books") ───────────────────
|
|
1913
1985
|
| { type: "world_books_get_activated"; requestId: string; chatId: string; userId?: string }
|
|
1986
|
+
// ─── Regex Scripts (gated: "regex_scripts") ────────────────────────
|
|
1987
|
+
| { type: "regex_scripts_list"; requestId: string; scope?: RegexScopeDTO; scopeId?: string; target?: RegexTargetDTO; limit?: number; offset?: number; userId?: string }
|
|
1988
|
+
| { type: "regex_scripts_get"; requestId: string; scriptId: string; userId?: string }
|
|
1989
|
+
| { type: "regex_scripts_get_active"; requestId: string; target: RegexTargetDTO; characterId?: string; chatId?: string; userId?: string }
|
|
1990
|
+
| { type: "regex_scripts_create"; requestId: string; input: RegexScriptCreateDTO; userId?: string }
|
|
1991
|
+
| { type: "regex_scripts_update"; requestId: string; scriptId: string; input: RegexScriptUpdateDTO; userId?: string }
|
|
1992
|
+
| { type: "regex_scripts_delete"; requestId: string; scriptId: string; userId?: string }
|
|
1914
1993
|
// ─── Dry Run (gated: "generation") ────────────────────────────────
|
|
1915
1994
|
| { type: "generate_dry_run"; requestId: string; input: DryRunRequestDTO; userId?: string }
|
|
1916
1995
|
// ─── Chat Memories (gated: "chats") ───────────────────────────────
|
package/src/dom.ts
CHANGED
|
@@ -377,6 +377,83 @@ export interface SpindleConfirmResult {
|
|
|
377
377
|
confirmed: boolean;
|
|
378
378
|
}
|
|
379
379
|
|
|
380
|
+
// ── UI Event Helpers ──
|
|
381
|
+
|
|
382
|
+
export type SpindleUIDomActionEventType = "click" | "pointerdown" | "pointerup";
|
|
383
|
+
|
|
384
|
+
export interface SpindleUIKeyboardState {
|
|
385
|
+
/** True when the host believes a virtual keyboard is currently visible. */
|
|
386
|
+
visible: boolean;
|
|
387
|
+
/** Safe bottom inset in CSS pixels that keeps content above the keyboard. */
|
|
388
|
+
insetBottom: number;
|
|
389
|
+
/** Current visual viewport width in CSS pixels. */
|
|
390
|
+
viewportWidth: number;
|
|
391
|
+
/** Current visual viewport height in CSS pixels. */
|
|
392
|
+
viewportHeight: number;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export interface SpindleUIDrawerState {
|
|
396
|
+
/** Whether the side drawer is currently visible. */
|
|
397
|
+
open: boolean;
|
|
398
|
+
/** Active drawer tab, if any. */
|
|
399
|
+
tabId: string | null;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
export interface SpindleUISettingsState {
|
|
403
|
+
/** Whether the settings modal is currently visible. */
|
|
404
|
+
open: boolean;
|
|
405
|
+
/** Active settings view identifier. */
|
|
406
|
+
view: string;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
export interface SpindleUIDomActionDetail {
|
|
410
|
+
/** Matched action identifier read from the target element. */
|
|
411
|
+
actionId: string;
|
|
412
|
+
/** DOM event type that triggered the callback. */
|
|
413
|
+
eventType: SpindleUIDomActionEventType;
|
|
414
|
+
/** Matched descendant element that carried the action identifier. */
|
|
415
|
+
element: HTMLElement;
|
|
416
|
+
/** Bound extension-owned root used for delegation. */
|
|
417
|
+
root: Element;
|
|
418
|
+
/** Native DOM event from the host document. */
|
|
419
|
+
originalEvent: Event;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export interface SpindleUIDomActionBindingOptions {
|
|
423
|
+
/** Attribute used to resolve action IDs. Default: `id`. */
|
|
424
|
+
attribute?: string;
|
|
425
|
+
/** Event types to listen for. Default: `["click"]`. */
|
|
426
|
+
events?: SpindleUIDomActionEventType[];
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
export interface SpindleUIEventsHelper {
|
|
430
|
+
/** Read the current virtual keyboard snapshot. */
|
|
431
|
+
getKeyboardState(): SpindleUIKeyboardState;
|
|
432
|
+
/** Subscribe to keyboard visibility / safe-area changes. */
|
|
433
|
+
onKeyboardChange(handler: (state: SpindleUIKeyboardState) => void): () => void;
|
|
434
|
+
/** Read the current side drawer snapshot. */
|
|
435
|
+
getDrawerState(): SpindleUIDrawerState;
|
|
436
|
+
/** Subscribe to side drawer open/close and tab changes. */
|
|
437
|
+
onDrawerChange(handler: (state: SpindleUIDrawerState) => void): () => void;
|
|
438
|
+
/** Read the current settings modal snapshot. */
|
|
439
|
+
getSettingsState(): SpindleUISettingsState;
|
|
440
|
+
/** Subscribe to settings modal open/close and active-view changes. */
|
|
441
|
+
onSettingsChange(handler: (state: SpindleUISettingsState) => void): () => void;
|
|
442
|
+
/**
|
|
443
|
+
* Delegate action handlers from extension-owned DOM.
|
|
444
|
+
*
|
|
445
|
+
* This is intended for non-sandbox UI where the extension injects or mounts
|
|
446
|
+
* host DOM directly and wants to react to user interaction without wiring
|
|
447
|
+
* global document listeners. By default the helper matches descendant
|
|
448
|
+
* elements by `id`, but `options.attribute` can be used instead.
|
|
449
|
+
*/
|
|
450
|
+
bindActionHandlers(
|
|
451
|
+
target: string | Element,
|
|
452
|
+
handlers: Record<string, (detail: SpindleUIDomActionDetail) => void>,
|
|
453
|
+
options?: SpindleUIDomActionBindingOptions,
|
|
454
|
+
): () => void;
|
|
455
|
+
}
|
|
456
|
+
|
|
380
457
|
// ── Frontend Process Lifecycle ──
|
|
381
458
|
|
|
382
459
|
/** Controller passed to a frontend process instance spawned by the backend runtime. */
|
|
@@ -432,6 +509,7 @@ export interface SpindleFrontendContext {
|
|
|
432
509
|
emit(event: string, payload: unknown): void;
|
|
433
510
|
};
|
|
434
511
|
ui: {
|
|
512
|
+
events: SpindleUIEventsHelper;
|
|
435
513
|
mount(point: SpindleMountPoint): Element;
|
|
436
514
|
registerDrawerTab(options: SpindleDrawerTabOptions): SpindleDrawerTabHandle;
|
|
437
515
|
createFloatWidget(options?: SpindleFloatWidgetOptions): SpindleFloatWidgetHandle;
|
package/src/events.ts
CHANGED
|
@@ -36,6 +36,8 @@ export enum CoreEventType {
|
|
|
36
36
|
CONNECTION_PROFILE_LOADED = "CONNECTION_PROFILE_LOADED",
|
|
37
37
|
MAIN_API_CHANGED = "MAIN_API_CHANGED",
|
|
38
38
|
WORLD_INFO_ACTIVATED = "WORLD_INFO_ACTIVATED",
|
|
39
|
+
REGEX_SCRIPT_CHANGED = "REGEX_SCRIPT_CHANGED",
|
|
40
|
+
REGEX_SCRIPT_DELETED = "REGEX_SCRIPT_DELETED",
|
|
39
41
|
MESSAGE_TAG_INTERCEPTED = "MESSAGE_TAG_INTERCEPTED",
|
|
40
42
|
TOOL_INVOCATION = "TOOL_INVOCATION",
|
|
41
43
|
}
|
package/src/index.ts
CHANGED
|
@@ -42,6 +42,15 @@ export type {
|
|
|
42
42
|
WorldBookEntryDTO,
|
|
43
43
|
WorldBookEntryCreateDTO,
|
|
44
44
|
WorldBookEntryUpdateDTO,
|
|
45
|
+
RegexPlacementDTO,
|
|
46
|
+
RegexScopeDTO,
|
|
47
|
+
RegexTargetDTO,
|
|
48
|
+
RegexMacroModeDTO,
|
|
49
|
+
RegexScriptDTO,
|
|
50
|
+
RegexScriptCreateDTO,
|
|
51
|
+
RegexScriptUpdateDTO,
|
|
52
|
+
RegexScriptListOptionsDTO,
|
|
53
|
+
RegexScriptActiveOptionsDTO,
|
|
45
54
|
DatabankScopeDTO,
|
|
46
55
|
DatabankDocumentStatusDTO,
|
|
47
56
|
DatabankDTO,
|
|
@@ -156,11 +165,18 @@ export type {
|
|
|
156
165
|
SpindleModalOptions,
|
|
157
166
|
SpindleModalHandle,
|
|
158
167
|
SpindleConfirmVariant,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
168
|
+
SpindleConfirmOptions,
|
|
169
|
+
SpindleConfirmResult,
|
|
170
|
+
SpindleUIDomActionEventType,
|
|
171
|
+
SpindleUIKeyboardState,
|
|
172
|
+
SpindleUIDrawerState,
|
|
173
|
+
SpindleUISettingsState,
|
|
174
|
+
SpindleUIDomActionDetail,
|
|
175
|
+
SpindleUIDomActionBindingOptions,
|
|
176
|
+
SpindleUIEventsHelper,
|
|
177
|
+
SpindleFrontendProcessContext,
|
|
178
|
+
SpindleFrontendProcessRegistry,
|
|
179
|
+
} from "./dom";
|
|
164
180
|
|
|
165
181
|
export type { ExtensionInfo } from "./extension-info";
|
|
166
182
|
|
package/src/permissions.ts
CHANGED
|
@@ -31,6 +31,7 @@ export type SpindlePermission =
|
|
|
31
31
|
| "characters"
|
|
32
32
|
| "chats"
|
|
33
33
|
| "world_books"
|
|
34
|
+
| "regex_scripts"
|
|
34
35
|
| "databanks"
|
|
35
36
|
| "personas"
|
|
36
37
|
| "push_notification"
|
|
@@ -54,6 +55,7 @@ export const ALL_PERMISSIONS: readonly SpindlePermission[] = [
|
|
|
54
55
|
"characters",
|
|
55
56
|
"chats",
|
|
56
57
|
"world_books",
|
|
58
|
+
"regex_scripts",
|
|
57
59
|
"databanks",
|
|
58
60
|
"personas",
|
|
59
61
|
"push_notification",
|
package/src/spindle-api.ts
CHANGED
|
@@ -27,6 +27,11 @@ import type {
|
|
|
27
27
|
WorldBookEntryDTO,
|
|
28
28
|
WorldBookEntryCreateDTO,
|
|
29
29
|
WorldBookEntryUpdateDTO,
|
|
30
|
+
RegexScriptDTO,
|
|
31
|
+
RegexScriptCreateDTO,
|
|
32
|
+
RegexScriptUpdateDTO,
|
|
33
|
+
RegexScriptListOptionsDTO,
|
|
34
|
+
RegexScriptActiveOptionsDTO,
|
|
30
35
|
DatabankDTO,
|
|
31
36
|
DatabankCreateDTO,
|
|
32
37
|
DatabankUpdateDTO,
|
|
@@ -741,6 +746,24 @@ export interface SpindleAPI {
|
|
|
741
746
|
getActivated(chatId: string, userId?: string): Promise<ActivatedWorldInfoEntryDTO[]>;
|
|
742
747
|
};
|
|
743
748
|
|
|
749
|
+
/**
|
|
750
|
+
* Regex Scripts CRUD (permission: "regex_scripts").
|
|
751
|
+
* Full access to regex scripts attached to the user's account, including
|
|
752
|
+
* global, character-scoped, and chat-scoped rules. Same shape Lumiverse uses
|
|
753
|
+
* internally during prompt assembly, response baking, and display rendering.
|
|
754
|
+
* For user-scoped extensions, userId is inferred from the extension owner.
|
|
755
|
+
* For operator-scoped extensions, pass userId to scope to a specific user.
|
|
756
|
+
*/
|
|
757
|
+
regex_scripts: {
|
|
758
|
+
list(options?: RegexScriptListOptionsDTO): Promise<{ data: RegexScriptDTO[]; total: number }>;
|
|
759
|
+
get(scriptId: string, userId?: string): Promise<RegexScriptDTO | null>;
|
|
760
|
+
create(input: RegexScriptCreateDTO, userId?: string): Promise<RegexScriptDTO>;
|
|
761
|
+
update(scriptId: string, input: RegexScriptUpdateDTO, userId?: string): Promise<RegexScriptDTO>;
|
|
762
|
+
delete(scriptId: string, userId?: string): Promise<boolean>;
|
|
763
|
+
/** Resolve the enabled scripts that would actually fire for the given target + character/chat context, merged across global + character + chat scopes and ordered by scope tier then sort_order. */
|
|
764
|
+
getActive(options: RegexScriptActiveOptionsDTO): Promise<RegexScriptDTO[]>;
|
|
765
|
+
};
|
|
766
|
+
|
|
744
767
|
/**
|
|
745
768
|
* Databank CRUD (permission: "databanks").
|
|
746
769
|
* Manage databanks plus the documents they contain.
|