lumiverse-spindle-types 0.4.72 → 0.4.74

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.72",
3
+ "version": "0.4.74",
4
4
  "types": "./src/index.ts",
5
5
  "keywords": [
6
6
  "lumiverse",
package/src/api.ts CHANGED
@@ -627,6 +627,108 @@ export interface ChatChangedPayloadDTO {
627
627
  changedFields?: string[];
628
628
  }
629
629
 
630
+ // ─── User Preset DTOs ───────────────────────────────────────────────────
631
+
632
+ export type PromptVariableDefDTO =
633
+ | {
634
+ id: string;
635
+ name: string;
636
+ label: string;
637
+ type: "text";
638
+ defaultValue: string;
639
+ description?: string;
640
+ }
641
+ | {
642
+ id: string;
643
+ name: string;
644
+ label: string;
645
+ type: "textarea";
646
+ defaultValue: string;
647
+ rows?: number;
648
+ description?: string;
649
+ }
650
+ | {
651
+ id: string;
652
+ name: string;
653
+ label: string;
654
+ type: "number";
655
+ defaultValue: number;
656
+ min?: number;
657
+ max?: number;
658
+ step?: number;
659
+ description?: string;
660
+ }
661
+ | {
662
+ id: string;
663
+ name: string;
664
+ label: string;
665
+ type: "slider";
666
+ defaultValue: number;
667
+ min: number;
668
+ max: number;
669
+ step?: number;
670
+ description?: string;
671
+ };
672
+
673
+ export type PromptVariableValueDTO = string | number;
674
+ export type PromptVariableValuesDTO = Record<string, Record<string, PromptVariableValueDTO>>;
675
+ export type PromptBlockRoleDTO = "system" | "user" | "assistant" | "user_append" | "assistant_append";
676
+ export type PromptBlockPositionDTO = "pre_history" | "post_history" | "in_history";
677
+ export type PromptBlockCategoryModeDTO = "radio" | "checkbox" | null;
678
+
679
+ export interface PromptBlockDTO {
680
+ id: string;
681
+ name: string;
682
+ content: string;
683
+ role: PromptBlockRoleDTO;
684
+ enabled: boolean;
685
+ position: PromptBlockPositionDTO;
686
+ depth: number;
687
+ /** `"category"` marks a structural category header; other strings are structural insertion markers. */
688
+ marker: string | null;
689
+ isLocked: boolean;
690
+ color: string | null;
691
+ injectionTrigger: string[];
692
+ group: string | null;
693
+ /** Only meaningful when `marker === "category"`. Radio categories allow one enabled child; checkbox categories allow many. */
694
+ categoryMode?: PromptBlockCategoryModeDTO;
695
+ variables?: PromptVariableDefDTO[];
696
+ }
697
+
698
+ export interface PromptBlockCategoryGroupDTO {
699
+ /** The category header block, or null for uncategorized leading blocks. */
700
+ categoryBlock: PromptBlockDTO | null;
701
+ /** Non-category blocks after the header until the next category header. */
702
+ children: PromptBlockDTO[];
703
+ }
704
+
705
+ export interface UserPresetDTO {
706
+ id: string;
707
+ name: string;
708
+ provider: string;
709
+ engine: string;
710
+ parameters: Record<string, unknown>;
711
+ prompt_order: PromptBlockDTO[];
712
+ prompts: Record<string, unknown>;
713
+ metadata: Record<string, unknown>;
714
+ created_at: number;
715
+ updated_at: number;
716
+ }
717
+
718
+ export interface UserPresetCreateDTO {
719
+ name: string;
720
+ provider: string;
721
+ engine?: string;
722
+ parameters?: Record<string, unknown>;
723
+ prompt_order?: PromptBlockDTO[];
724
+ prompts?: Record<string, unknown>;
725
+ metadata?: Record<string, unknown>;
726
+ }
727
+
728
+ export type UserPresetUpdateDTO = Partial<UserPresetCreateDTO>;
729
+ export type PromptBlockCreateDTO = Partial<PromptBlockDTO>;
730
+ export type PromptBlockUpdateDTO = Partial<Omit<PromptBlockDTO, "id">>;
731
+
630
732
  // ─── World Book DTOs ─────────────────────────────────────────────────────
631
733
 
632
734
  /**
@@ -1822,6 +1924,14 @@ export interface SharedRpcRequestContextDTO {
1822
1924
  endpoint: string;
1823
1925
  /** Identifier of the extension requesting the value. */
1824
1926
  requesterExtensionId: string;
1927
+ /** Gated permissions available while this delegated handler request is running. */
1928
+ effectivePermissions: readonly string[];
1929
+ }
1930
+
1931
+ /** Optional read policy for a shared RPC endpoint. Omit to require legacy owner-permission inheritance. */
1932
+ export interface SharedRpcEndpointPolicyDTO {
1933
+ /** Gated permissions both owner and requester must have; `[]` means no gated permissions are delegated. */
1934
+ requires?: readonly string[];
1825
1935
  }
1826
1936
 
1827
1937
  // ─── Worker → Host messages ──────────────────────────────────────────────
@@ -1906,15 +2016,16 @@ export type WorkerToHost =
1906
2016
  reservationId: string;
1907
2017
  }
1908
2018
  | { type: "permissions_get_granted"; requestId: string }
1909
- | { type: "rpc_pool_sync"; endpoint: string; value: unknown }
1910
- | { type: "rpc_pool_register_handler"; endpoint: string }
2019
+ | { type: "rpc_pool_sync"; endpoint: string; value: unknown; policy?: SharedRpcEndpointPolicyDTO; rpcPermissionScopeId?: string }
2020
+ | { type: "rpc_pool_register_handler"; endpoint: string; policy?: SharedRpcEndpointPolicyDTO; rpcPermissionScopeId?: string }
1911
2021
  | { type: "rpc_pool_unregister"; endpoint: string }
1912
- | { type: "rpc_pool_read"; requestId: string; endpoint: string }
2022
+ | { type: "rpc_pool_read"; requestId: string; endpoint: string; rpcPermissionScopeId?: string }
1913
2023
  | {
1914
2024
  type: "rpc_pool_handler_result";
1915
2025
  requestId: string;
1916
2026
  result?: unknown;
1917
2027
  error?: string;
2028
+ rpcPermissionScopeId?: string;
1918
2029
  }
1919
2030
  | { type: "connections_list"; requestId: string; userId?: string }
1920
2031
  | { type: "connections_get"; requestId: string; connectionId: string; userId?: string }
@@ -2105,6 +2216,18 @@ export type WorkerToHost =
2105
2216
  | { type: "chats_get_active"; requestId: string; userId?: string }
2106
2217
  | { type: "chats_update"; requestId: string; chatId: string; input: ChatUpdateDTO; userId?: string }
2107
2218
  | { type: "chats_delete"; requestId: string; chatId: string; userId?: string }
2219
+ // ─── User Presets (gated: "presets") ────────────────────────────────
2220
+ | { type: "presets_list"; requestId: string; limit?: number; offset?: number; userId?: string }
2221
+ | { type: "presets_get"; requestId: string; presetId: string; userId?: string }
2222
+ | { type: "presets_create"; requestId: string; input: UserPresetCreateDTO; userId?: string }
2223
+ | { type: "presets_update"; requestId: string; presetId: string; input: UserPresetUpdateDTO; userId?: string }
2224
+ | { type: "presets_delete"; requestId: string; presetId: string; userId?: string }
2225
+ | { type: "preset_blocks_list"; requestId: string; presetId: string; userId?: string }
2226
+ | { type: "preset_blocks_get"; requestId: string; presetId: string; blockId: string; userId?: string }
2227
+ | { type: "preset_blocks_create"; requestId: string; presetId: string; input: PromptBlockCreateDTO; index?: number; userId?: string }
2228
+ | { type: "preset_blocks_update"; requestId: string; presetId: string; blockId: string; input: PromptBlockUpdateDTO; userId?: string }
2229
+ | { type: "preset_blocks_delete"; requestId: string; presetId: string; blockId: string; userId?: string }
2230
+ | { type: "preset_categories_list"; requestId: string; presetId: string; userId?: string }
2108
2231
  // ─── World Books (gated: "world_books") ──────────────────────────────
2109
2232
  | { type: "world_books_list"; requestId: string; limit?: number; offset?: number; userId?: string }
2110
2233
  | { type: "world_books_get"; requestId: string; worldBookId: string; userId?: string }
@@ -2284,6 +2407,8 @@ export type HostToWorker =
2284
2407
  requestId: string;
2285
2408
  endpoint: string;
2286
2409
  requesterExtensionId: string;
2410
+ rpcPermissionScopeId: string;
2411
+ effectivePermissions: string[];
2287
2412
  }
2288
2413
  | {
2289
2414
  type: "intercept_request";
package/src/events.ts CHANGED
@@ -38,6 +38,10 @@ export enum CoreEventType {
38
38
  WORLD_INFO_ACTIVATED = "WORLD_INFO_ACTIVATED",
39
39
  REGEX_SCRIPT_CHANGED = "REGEX_SCRIPT_CHANGED",
40
40
  REGEX_SCRIPT_DELETED = "REGEX_SCRIPT_DELETED",
41
+ WORLD_BOOK_CHANGED = "WORLD_BOOK_CHANGED",
42
+ WORLD_BOOK_DELETED = "WORLD_BOOK_DELETED",
43
+ WORLD_BOOK_ENTRY_CHANGED = "WORLD_BOOK_ENTRY_CHANGED",
44
+ WORLD_BOOK_ENTRY_DELETED = "WORLD_BOOK_ENTRY_DELETED",
41
45
  MESSAGE_TAG_INTERCEPTED = "MESSAGE_TAG_INTERCEPTED",
42
46
  TOOL_INVOCATION = "TOOL_INVOCATION",
43
47
  }
package/src/index.ts CHANGED
@@ -36,11 +36,24 @@ export type {
36
36
  CharacterCreateDTO,
37
37
  CharacterAvatarUploadDTO,
38
38
  CharacterUpdateDTO,
39
- ChatDTO,
40
- ChatUpdateDTO,
41
- ChatSwitchedPayloadDTO,
42
- ChatChangedPayloadDTO,
43
- WorldBookDTO,
39
+ ChatDTO,
40
+ ChatUpdateDTO,
41
+ ChatSwitchedPayloadDTO,
42
+ ChatChangedPayloadDTO,
43
+ PromptVariableDefDTO,
44
+ PromptVariableValueDTO,
45
+ PromptVariableValuesDTO,
46
+ PromptBlockRoleDTO,
47
+ PromptBlockPositionDTO,
48
+ PromptBlockCategoryModeDTO,
49
+ PromptBlockDTO,
50
+ PromptBlockCreateDTO,
51
+ PromptBlockUpdateDTO,
52
+ PromptBlockCategoryGroupDTO,
53
+ UserPresetDTO,
54
+ UserPresetCreateDTO,
55
+ UserPresetUpdateDTO,
56
+ WorldBookDTO,
44
57
  WorldBookCreateDTO,
45
58
  WorldBookUpdateDTO,
46
59
  WorldBookEntryDTO,
@@ -130,6 +143,7 @@ export type {
130
143
  TokenCountOptionsDTO,
131
144
  TokenCountResultDTO,
132
145
  SharedRpcRequestContextDTO,
146
+ SharedRpcEndpointPolicyDTO,
133
147
  MacroInterceptorPhase,
134
148
  MacroInterceptorEnvDTO,
135
149
  MacroInterceptorCtxDTO,
@@ -12,6 +12,7 @@
12
12
  * - "generation_parameters" — inject parameters into in-flight generations via interceptors
13
13
  * - "characters" — CRUD on character cards
14
14
  * - "chats" — CRUD on chat sessions
15
+ * - "presets" — CRUD on user presets and prompt blocks
15
16
  * - "personas" — CRUD on personas
16
17
  * - "databanks" — CRUD on databanks and their documents
17
18
  * - "macro_interceptor" — transform raw templates before macro parsing/dispatch
@@ -30,6 +31,7 @@ export type SpindlePermission =
30
31
  | "oauth"
31
32
  | "characters"
32
33
  | "chats"
34
+ | "presets"
33
35
  | "world_books"
34
36
  | "regex_scripts"
35
37
  | "databanks"
@@ -54,6 +56,7 @@ export const ALL_PERMISSIONS: readonly SpindlePermission[] = [
54
56
  "oauth",
55
57
  "characters",
56
58
  "chats",
59
+ "presets",
57
60
  "world_books",
58
61
  "regex_scripts",
59
62
  "databanks",
@@ -22,6 +22,13 @@ import type {
22
22
  CharacterUpdateDTO,
23
23
  ChatDTO,
24
24
  ChatUpdateDTO,
25
+ UserPresetDTO,
26
+ UserPresetCreateDTO,
27
+ UserPresetUpdateDTO,
28
+ PromptBlockDTO,
29
+ PromptBlockCreateDTO,
30
+ PromptBlockUpdateDTO,
31
+ PromptBlockCategoryGroupDTO,
25
32
  WorldBookDTO,
26
33
  WorldBookCreateDTO,
27
34
  WorldBookUpdateDTO,
@@ -95,6 +102,7 @@ import type {
95
102
  MessageContentProcessorCtxDTO,
96
103
  MessageContentProcessorResultDTO,
97
104
  SharedRpcRequestContextDTO,
105
+ SharedRpcEndpointPolicyDTO,
98
106
  } from "./api";
99
107
 
100
108
  export interface FrontendProcessHandle {
@@ -729,6 +737,34 @@ export interface SpindleAPI {
729
737
  getMemories(chatId: string, options?: { topK?: number; userId?: string }): Promise<ChatMemoryResultDTO>;
730
738
  };
731
739
 
740
+ /**
741
+ * User Presets CRUD (permission: "presets").
742
+ * Preset categories are structural prompt blocks where `marker === "category"`;
743
+ * their children are the following non-category prompt blocks until the next
744
+ * category marker. Use `categories.list()` for the host-derived grouping, and
745
+ * use block CRUD to create/update/delete both normal prompt blocks and category
746
+ * marker blocks.
747
+ * For user-scoped extensions, userId is inferred from the extension owner.
748
+ * For operator-scoped extensions, pass userId to scope to a specific user.
749
+ */
750
+ presets: {
751
+ list(options?: { limit?: number; offset?: number; userId?: string }): Promise<{ data: UserPresetDTO[]; total: number }>;
752
+ get(presetId: string, userId?: string): Promise<UserPresetDTO | null>;
753
+ create(input: UserPresetCreateDTO, userId?: string): Promise<UserPresetDTO>;
754
+ update(presetId: string, input: UserPresetUpdateDTO, userId?: string): Promise<UserPresetDTO>;
755
+ delete(presetId: string, userId?: string): Promise<boolean>;
756
+ blocks: {
757
+ list(presetId: string, userId?: string): Promise<PromptBlockDTO[]>;
758
+ get(presetId: string, blockId: string, userId?: string): Promise<PromptBlockDTO | null>;
759
+ create(presetId: string, input: PromptBlockCreateDTO, options?: { index?: number; userId?: string }): Promise<PromptBlockDTO>;
760
+ update(presetId: string, blockId: string, input: PromptBlockUpdateDTO, userId?: string): Promise<PromptBlockDTO>;
761
+ delete(presetId: string, blockId: string, userId?: string): Promise<boolean>;
762
+ };
763
+ categories: {
764
+ list(presetId: string, userId?: string): Promise<PromptBlockCategoryGroupDTO[]>;
765
+ };
766
+ };
767
+
732
768
  /**
733
769
  * World Books CRUD (permission: "world_books").
734
770
  * Full access to world books and their entries.
@@ -860,7 +896,7 @@ export interface SpindleAPI {
860
896
  *
861
897
  * Returns the fully-qualified endpoint name.
862
898
  */
863
- sync(endpoint: string, value: unknown): string;
899
+ sync(endpoint: string, value: unknown, policy?: SharedRpcEndpointPolicyDTO): string;
864
900
  /**
865
901
  * Register an on-demand endpoint handler. Replaces any previously synced
866
902
  * value or handler for the same endpoint.
@@ -869,7 +905,8 @@ export interface SpindleAPI {
869
905
  */
870
906
  handle(
871
907
  endpoint: string,
872
- handler: (ctx: SharedRpcRequestContextDTO) => unknown | Promise<unknown>
908
+ handler: (ctx: SharedRpcRequestContextDTO) => unknown | Promise<unknown>,
909
+ policy?: SharedRpcEndpointPolicyDTO
873
910
  ): string;
874
911
  /** Read the latest value from another extension's fully-qualified endpoint. */
875
912
  read<T = unknown>(endpoint: string): Promise<T>;