@character-foundry/character-foundry 0.1.3 → 0.1.6

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.
Files changed (100) hide show
  1. package/README.md +70 -0
  2. package/dist/app-framework.cjs +1859 -0
  3. package/dist/app-framework.cjs.map +1 -0
  4. package/dist/app-framework.d.cts +896 -0
  5. package/dist/app-framework.d.ts +896 -2
  6. package/dist/app-framework.js +1835 -1
  7. package/dist/app-framework.js.map +1 -1
  8. package/dist/charx.cjs +979 -0
  9. package/dist/charx.cjs.map +1 -0
  10. package/dist/charx.d.cts +640 -0
  11. package/dist/charx.d.ts +640 -2
  12. package/dist/charx.js +955 -1
  13. package/dist/charx.js.map +1 -1
  14. package/dist/core.cjs +755 -0
  15. package/dist/core.cjs.map +1 -0
  16. package/dist/core.d.cts +404 -0
  17. package/dist/core.d.ts +404 -2
  18. package/dist/core.js +731 -1
  19. package/dist/core.js.map +1 -1
  20. package/dist/exporter.cjs +7619 -0
  21. package/dist/exporter.cjs.map +1 -0
  22. package/dist/exporter.d.cts +681 -0
  23. package/dist/exporter.d.ts +681 -2
  24. package/dist/exporter.js +7602 -1
  25. package/dist/exporter.js.map +1 -1
  26. package/dist/federation.cjs +3916 -0
  27. package/dist/federation.cjs.map +1 -0
  28. package/dist/federation.d.cts +2951 -0
  29. package/dist/federation.d.ts +2951 -2
  30. package/dist/federation.js +3892 -1
  31. package/dist/federation.js.map +1 -1
  32. package/dist/index.cjs +9213 -0
  33. package/dist/index.cjs.map +1 -0
  34. package/dist/index.d.cts +1119 -0
  35. package/dist/index.d.ts +1113 -20
  36. package/dist/index.js +9196 -26
  37. package/dist/index.js.map +1 -1
  38. package/dist/loader.cjs +8951 -0
  39. package/dist/loader.cjs.map +1 -0
  40. package/dist/loader.d.cts +1037 -0
  41. package/dist/loader.d.ts +1037 -2
  42. package/dist/loader.js +8934 -1
  43. package/dist/loader.js.map +1 -1
  44. package/dist/lorebook.cjs +866 -0
  45. package/dist/lorebook.cjs.map +1 -0
  46. package/dist/lorebook.d.cts +1008 -0
  47. package/dist/lorebook.d.ts +1008 -2
  48. package/dist/lorebook.js +842 -1
  49. package/dist/lorebook.js.map +1 -1
  50. package/dist/media.cjs +6661 -0
  51. package/dist/media.cjs.map +1 -0
  52. package/dist/media.d.cts +87 -0
  53. package/dist/media.d.ts +87 -2
  54. package/dist/media.js +6644 -1
  55. package/dist/media.js.map +1 -1
  56. package/dist/normalizer.cjs +503 -0
  57. package/dist/normalizer.cjs.map +1 -0
  58. package/dist/normalizer.d.cts +1217 -0
  59. package/dist/normalizer.d.ts +1217 -2
  60. package/dist/normalizer.js +479 -1
  61. package/dist/normalizer.js.map +1 -1
  62. package/dist/png.cjs +797 -0
  63. package/dist/png.cjs.map +1 -0
  64. package/dist/png.d.cts +786 -0
  65. package/dist/png.d.ts +786 -2
  66. package/dist/png.js +773 -1
  67. package/dist/png.js.map +1 -1
  68. package/dist/schemas.cjs +879 -0
  69. package/dist/schemas.cjs.map +1 -0
  70. package/dist/schemas.d.cts +2208 -0
  71. package/dist/schemas.d.ts +2208 -2
  72. package/dist/schemas.js +855 -1
  73. package/dist/schemas.js.map +1 -1
  74. package/dist/tokenizers.cjs +153 -0
  75. package/dist/tokenizers.cjs.map +1 -0
  76. package/dist/tokenizers.d.cts +155 -0
  77. package/dist/tokenizers.d.ts +155 -2
  78. package/dist/tokenizers.js +129 -1
  79. package/dist/tokenizers.js.map +1 -1
  80. package/dist/voxta.cjs +7907 -0
  81. package/dist/voxta.cjs.map +1 -0
  82. package/dist/voxta.d.cts +1349 -0
  83. package/dist/voxta.d.ts +1349 -2
  84. package/dist/voxta.js +7890 -1
  85. package/dist/voxta.js.map +1 -1
  86. package/package.json +177 -45
  87. package/dist/app-framework.d.ts.map +0 -1
  88. package/dist/charx.d.ts.map +0 -1
  89. package/dist/core.d.ts.map +0 -1
  90. package/dist/exporter.d.ts.map +0 -1
  91. package/dist/federation.d.ts.map +0 -1
  92. package/dist/index.d.ts.map +0 -1
  93. package/dist/loader.d.ts.map +0 -1
  94. package/dist/lorebook.d.ts.map +0 -1
  95. package/dist/media.d.ts.map +0 -1
  96. package/dist/normalizer.d.ts.map +0 -1
  97. package/dist/png.d.ts.map +0 -1
  98. package/dist/schemas.d.ts.map +0 -1
  99. package/dist/tokenizers.d.ts.map +0 -1
  100. package/dist/voxta.d.ts.map +0 -1
package/dist/loader.d.ts CHANGED
@@ -1,2 +1,1037 @@
1
- export * from '@character-foundry/loader';
2
- //# sourceMappingURL=loader.d.ts.map
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Binary Data Utilities
5
+ *
6
+ * Universal binary data operations using Uint8Array.
7
+ * Works in both Node.js and browser environments.
8
+ */
9
+ /**
10
+ * Universal binary data type (works in both environments)
11
+ */
12
+ export type BinaryData = Uint8Array;
13
+ declare const CCv3CharacterBookSchema: z.ZodObject<{
14
+ name: z.ZodOptional<z.ZodString>;
15
+ description: z.ZodOptional<z.ZodString>;
16
+ scan_depth: z.ZodOptional<z.ZodNumber>;
17
+ token_budget: z.ZodOptional<z.ZodNumber>;
18
+ recursive_scanning: z.ZodOptional<z.ZodBoolean>;
19
+ extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
20
+ entries: z.ZodArray<z.ZodObject<{
21
+ keys: z.ZodArray<z.ZodString, "many">;
22
+ content: z.ZodString;
23
+ enabled: z.ZodBoolean;
24
+ insertion_order: z.ZodNumber;
25
+ case_sensitive: z.ZodOptional<z.ZodBoolean>;
26
+ name: z.ZodOptional<z.ZodString>;
27
+ priority: z.ZodOptional<z.ZodNumber>;
28
+ id: z.ZodOptional<z.ZodNumber>;
29
+ comment: z.ZodOptional<z.ZodString>;
30
+ selective: z.ZodOptional<z.ZodBoolean>;
31
+ secondary_keys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
32
+ constant: z.ZodOptional<z.ZodBoolean>;
33
+ position: z.ZodOptional<z.ZodEnum<[
34
+ "before_char",
35
+ "after_char"
36
+ ]>>;
37
+ extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
38
+ automation_id: z.ZodOptional<z.ZodString>;
39
+ role: z.ZodOptional<z.ZodEnum<[
40
+ "system",
41
+ "user",
42
+ "assistant"
43
+ ]>>;
44
+ group: z.ZodOptional<z.ZodString>;
45
+ scan_frequency: z.ZodOptional<z.ZodNumber>;
46
+ probability: z.ZodOptional<z.ZodNumber>;
47
+ use_regex: z.ZodOptional<z.ZodBoolean>;
48
+ depth: z.ZodOptional<z.ZodNumber>;
49
+ selective_logic: z.ZodOptional<z.ZodEnum<[
50
+ "AND",
51
+ "NOT"
52
+ ]>>;
53
+ }, "strip", z.ZodTypeAny, {
54
+ keys: string[];
55
+ content: string;
56
+ enabled: boolean;
57
+ insertion_order: number;
58
+ name?: string | undefined;
59
+ extensions?: Record<string, unknown> | undefined;
60
+ case_sensitive?: boolean | undefined;
61
+ priority?: number | undefined;
62
+ id?: number | undefined;
63
+ comment?: string | undefined;
64
+ selective?: boolean | undefined;
65
+ secondary_keys?: string[] | undefined;
66
+ constant?: boolean | undefined;
67
+ position?: "before_char" | "after_char" | undefined;
68
+ automation_id?: string | undefined;
69
+ role?: "system" | "user" | "assistant" | undefined;
70
+ group?: string | undefined;
71
+ scan_frequency?: number | undefined;
72
+ probability?: number | undefined;
73
+ use_regex?: boolean | undefined;
74
+ depth?: number | undefined;
75
+ selective_logic?: "AND" | "NOT" | undefined;
76
+ }, {
77
+ keys: string[];
78
+ content: string;
79
+ enabled: boolean;
80
+ insertion_order: number;
81
+ name?: string | undefined;
82
+ extensions?: Record<string, unknown> | undefined;
83
+ case_sensitive?: boolean | undefined;
84
+ priority?: number | undefined;
85
+ id?: number | undefined;
86
+ comment?: string | undefined;
87
+ selective?: boolean | undefined;
88
+ secondary_keys?: string[] | undefined;
89
+ constant?: boolean | undefined;
90
+ position?: "before_char" | "after_char" | undefined;
91
+ automation_id?: string | undefined;
92
+ role?: "system" | "user" | "assistant" | undefined;
93
+ group?: string | undefined;
94
+ scan_frequency?: number | undefined;
95
+ probability?: number | undefined;
96
+ use_regex?: boolean | undefined;
97
+ depth?: number | undefined;
98
+ selective_logic?: "AND" | "NOT" | undefined;
99
+ }>, "many">;
100
+ }, "strip", z.ZodTypeAny, {
101
+ entries: {
102
+ keys: string[];
103
+ content: string;
104
+ enabled: boolean;
105
+ insertion_order: number;
106
+ name?: string | undefined;
107
+ extensions?: Record<string, unknown> | undefined;
108
+ case_sensitive?: boolean | undefined;
109
+ priority?: number | undefined;
110
+ id?: number | undefined;
111
+ comment?: string | undefined;
112
+ selective?: boolean | undefined;
113
+ secondary_keys?: string[] | undefined;
114
+ constant?: boolean | undefined;
115
+ position?: "before_char" | "after_char" | undefined;
116
+ automation_id?: string | undefined;
117
+ role?: "system" | "user" | "assistant" | undefined;
118
+ group?: string | undefined;
119
+ scan_frequency?: number | undefined;
120
+ probability?: number | undefined;
121
+ use_regex?: boolean | undefined;
122
+ depth?: number | undefined;
123
+ selective_logic?: "AND" | "NOT" | undefined;
124
+ }[];
125
+ name?: string | undefined;
126
+ description?: string | undefined;
127
+ scan_depth?: number | undefined;
128
+ token_budget?: number | undefined;
129
+ recursive_scanning?: boolean | undefined;
130
+ extensions?: Record<string, unknown> | undefined;
131
+ }, {
132
+ entries: {
133
+ keys: string[];
134
+ content: string;
135
+ enabled: boolean;
136
+ insertion_order: number;
137
+ name?: string | undefined;
138
+ extensions?: Record<string, unknown> | undefined;
139
+ case_sensitive?: boolean | undefined;
140
+ priority?: number | undefined;
141
+ id?: number | undefined;
142
+ comment?: string | undefined;
143
+ selective?: boolean | undefined;
144
+ secondary_keys?: string[] | undefined;
145
+ constant?: boolean | undefined;
146
+ position?: "before_char" | "after_char" | undefined;
147
+ automation_id?: string | undefined;
148
+ role?: "system" | "user" | "assistant" | undefined;
149
+ group?: string | undefined;
150
+ scan_frequency?: number | undefined;
151
+ probability?: number | undefined;
152
+ use_regex?: boolean | undefined;
153
+ depth?: number | undefined;
154
+ selective_logic?: "AND" | "NOT" | undefined;
155
+ }[];
156
+ name?: string | undefined;
157
+ description?: string | undefined;
158
+ scan_depth?: number | undefined;
159
+ token_budget?: number | undefined;
160
+ recursive_scanning?: boolean | undefined;
161
+ extensions?: Record<string, unknown> | undefined;
162
+ }>;
163
+ declare const CCv3DataSchema: z.ZodObject<{
164
+ spec: z.ZodLiteral<"chara_card_v3">;
165
+ spec_version: z.ZodLiteral<"3.0">;
166
+ data: z.ZodObject<{
167
+ name: z.ZodDefault<z.ZodString>;
168
+ description: z.ZodDefault<z.ZodString>;
169
+ personality: z.ZodDefault<z.ZodNullable<z.ZodString>>;
170
+ scenario: z.ZodDefault<z.ZodString>;
171
+ first_mes: z.ZodDefault<z.ZodString>;
172
+ mes_example: z.ZodDefault<z.ZodNullable<z.ZodString>>;
173
+ creator: z.ZodDefault<z.ZodString>;
174
+ character_version: z.ZodDefault<z.ZodString>;
175
+ tags: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
176
+ group_only_greetings: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
177
+ creator_notes: z.ZodOptional<z.ZodString>;
178
+ system_prompt: z.ZodOptional<z.ZodString>;
179
+ post_history_instructions: z.ZodOptional<z.ZodString>;
180
+ alternate_greetings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
181
+ character_book: z.ZodNullable<z.ZodOptional<z.ZodObject<{
182
+ name: z.ZodOptional<z.ZodString>;
183
+ description: z.ZodOptional<z.ZodString>;
184
+ scan_depth: z.ZodOptional<z.ZodNumber>;
185
+ token_budget: z.ZodOptional<z.ZodNumber>;
186
+ recursive_scanning: z.ZodOptional<z.ZodBoolean>;
187
+ extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
188
+ entries: z.ZodArray<z.ZodObject<{
189
+ keys: z.ZodArray<z.ZodString, "many">;
190
+ content: z.ZodString;
191
+ enabled: z.ZodBoolean;
192
+ insertion_order: z.ZodNumber;
193
+ case_sensitive: z.ZodOptional<z.ZodBoolean>;
194
+ name: z.ZodOptional<z.ZodString>;
195
+ priority: z.ZodOptional<z.ZodNumber>;
196
+ id: z.ZodOptional<z.ZodNumber>;
197
+ comment: z.ZodOptional<z.ZodString>;
198
+ selective: z.ZodOptional<z.ZodBoolean>;
199
+ secondary_keys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
200
+ constant: z.ZodOptional<z.ZodBoolean>;
201
+ position: z.ZodOptional<z.ZodEnum<[
202
+ "before_char",
203
+ "after_char"
204
+ ]>>;
205
+ extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
206
+ automation_id: z.ZodOptional<z.ZodString>;
207
+ role: z.ZodOptional<z.ZodEnum<[
208
+ "system",
209
+ "user",
210
+ "assistant"
211
+ ]>>;
212
+ group: z.ZodOptional<z.ZodString>;
213
+ scan_frequency: z.ZodOptional<z.ZodNumber>;
214
+ probability: z.ZodOptional<z.ZodNumber>;
215
+ use_regex: z.ZodOptional<z.ZodBoolean>;
216
+ depth: z.ZodOptional<z.ZodNumber>;
217
+ selective_logic: z.ZodOptional<z.ZodEnum<[
218
+ "AND",
219
+ "NOT"
220
+ ]>>;
221
+ }, "strip", z.ZodTypeAny, {
222
+ keys: string[];
223
+ content: string;
224
+ enabled: boolean;
225
+ insertion_order: number;
226
+ name?: string | undefined;
227
+ extensions?: Record<string, unknown> | undefined;
228
+ case_sensitive?: boolean | undefined;
229
+ priority?: number | undefined;
230
+ id?: number | undefined;
231
+ comment?: string | undefined;
232
+ selective?: boolean | undefined;
233
+ secondary_keys?: string[] | undefined;
234
+ constant?: boolean | undefined;
235
+ position?: "before_char" | "after_char" | undefined;
236
+ automation_id?: string | undefined;
237
+ role?: "system" | "user" | "assistant" | undefined;
238
+ group?: string | undefined;
239
+ scan_frequency?: number | undefined;
240
+ probability?: number | undefined;
241
+ use_regex?: boolean | undefined;
242
+ depth?: number | undefined;
243
+ selective_logic?: "AND" | "NOT" | undefined;
244
+ }, {
245
+ keys: string[];
246
+ content: string;
247
+ enabled: boolean;
248
+ insertion_order: number;
249
+ name?: string | undefined;
250
+ extensions?: Record<string, unknown> | undefined;
251
+ case_sensitive?: boolean | undefined;
252
+ priority?: number | undefined;
253
+ id?: number | undefined;
254
+ comment?: string | undefined;
255
+ selective?: boolean | undefined;
256
+ secondary_keys?: string[] | undefined;
257
+ constant?: boolean | undefined;
258
+ position?: "before_char" | "after_char" | undefined;
259
+ automation_id?: string | undefined;
260
+ role?: "system" | "user" | "assistant" | undefined;
261
+ group?: string | undefined;
262
+ scan_frequency?: number | undefined;
263
+ probability?: number | undefined;
264
+ use_regex?: boolean | undefined;
265
+ depth?: number | undefined;
266
+ selective_logic?: "AND" | "NOT" | undefined;
267
+ }>, "many">;
268
+ }, "strip", z.ZodTypeAny, {
269
+ entries: {
270
+ keys: string[];
271
+ content: string;
272
+ enabled: boolean;
273
+ insertion_order: number;
274
+ name?: string | undefined;
275
+ extensions?: Record<string, unknown> | undefined;
276
+ case_sensitive?: boolean | undefined;
277
+ priority?: number | undefined;
278
+ id?: number | undefined;
279
+ comment?: string | undefined;
280
+ selective?: boolean | undefined;
281
+ secondary_keys?: string[] | undefined;
282
+ constant?: boolean | undefined;
283
+ position?: "before_char" | "after_char" | undefined;
284
+ automation_id?: string | undefined;
285
+ role?: "system" | "user" | "assistant" | undefined;
286
+ group?: string | undefined;
287
+ scan_frequency?: number | undefined;
288
+ probability?: number | undefined;
289
+ use_regex?: boolean | undefined;
290
+ depth?: number | undefined;
291
+ selective_logic?: "AND" | "NOT" | undefined;
292
+ }[];
293
+ name?: string | undefined;
294
+ description?: string | undefined;
295
+ scan_depth?: number | undefined;
296
+ token_budget?: number | undefined;
297
+ recursive_scanning?: boolean | undefined;
298
+ extensions?: Record<string, unknown> | undefined;
299
+ }, {
300
+ entries: {
301
+ keys: string[];
302
+ content: string;
303
+ enabled: boolean;
304
+ insertion_order: number;
305
+ name?: string | undefined;
306
+ extensions?: Record<string, unknown> | undefined;
307
+ case_sensitive?: boolean | undefined;
308
+ priority?: number | undefined;
309
+ id?: number | undefined;
310
+ comment?: string | undefined;
311
+ selective?: boolean | undefined;
312
+ secondary_keys?: string[] | undefined;
313
+ constant?: boolean | undefined;
314
+ position?: "before_char" | "after_char" | undefined;
315
+ automation_id?: string | undefined;
316
+ role?: "system" | "user" | "assistant" | undefined;
317
+ group?: string | undefined;
318
+ scan_frequency?: number | undefined;
319
+ probability?: number | undefined;
320
+ use_regex?: boolean | undefined;
321
+ depth?: number | undefined;
322
+ selective_logic?: "AND" | "NOT" | undefined;
323
+ }[];
324
+ name?: string | undefined;
325
+ description?: string | undefined;
326
+ scan_depth?: number | undefined;
327
+ token_budget?: number | undefined;
328
+ recursive_scanning?: boolean | undefined;
329
+ extensions?: Record<string, unknown> | undefined;
330
+ }>>>;
331
+ extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
332
+ assets: z.ZodOptional<z.ZodArray<z.ZodObject<{
333
+ type: z.ZodEnum<[
334
+ "icon",
335
+ "background",
336
+ "emotion",
337
+ "user_icon",
338
+ "sound",
339
+ "video",
340
+ "custom",
341
+ "x-risu-asset"
342
+ ]>;
343
+ uri: z.ZodString;
344
+ name: z.ZodString;
345
+ ext: z.ZodString;
346
+ }, "strip", z.ZodTypeAny, {
347
+ name: string;
348
+ type: "custom" | "icon" | "background" | "emotion" | "user_icon" | "sound" | "video" | "x-risu-asset";
349
+ uri: string;
350
+ ext: string;
351
+ }, {
352
+ name: string;
353
+ type: "custom" | "icon" | "background" | "emotion" | "user_icon" | "sound" | "video" | "x-risu-asset";
354
+ uri: string;
355
+ ext: string;
356
+ }>, "many">>;
357
+ nickname: z.ZodOptional<z.ZodString>;
358
+ creator_notes_multilingual: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
359
+ source: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
360
+ creation_date: z.ZodOptional<z.ZodNumber>;
361
+ modification_date: z.ZodOptional<z.ZodNumber>;
362
+ }, "strip", z.ZodTypeAny, {
363
+ name: string;
364
+ description: string;
365
+ personality: string | null;
366
+ scenario: string;
367
+ first_mes: string;
368
+ mes_example: string | null;
369
+ tags: string[];
370
+ creator: string;
371
+ character_version: string;
372
+ group_only_greetings: string[];
373
+ extensions?: Record<string, unknown> | undefined;
374
+ creator_notes?: string | undefined;
375
+ system_prompt?: string | undefined;
376
+ post_history_instructions?: string | undefined;
377
+ alternate_greetings?: string[] | undefined;
378
+ character_book?: {
379
+ entries: {
380
+ keys: string[];
381
+ content: string;
382
+ enabled: boolean;
383
+ insertion_order: number;
384
+ name?: string | undefined;
385
+ extensions?: Record<string, unknown> | undefined;
386
+ case_sensitive?: boolean | undefined;
387
+ priority?: number | undefined;
388
+ id?: number | undefined;
389
+ comment?: string | undefined;
390
+ selective?: boolean | undefined;
391
+ secondary_keys?: string[] | undefined;
392
+ constant?: boolean | undefined;
393
+ position?: "before_char" | "after_char" | undefined;
394
+ automation_id?: string | undefined;
395
+ role?: "system" | "user" | "assistant" | undefined;
396
+ group?: string | undefined;
397
+ scan_frequency?: number | undefined;
398
+ probability?: number | undefined;
399
+ use_regex?: boolean | undefined;
400
+ depth?: number | undefined;
401
+ selective_logic?: "AND" | "NOT" | undefined;
402
+ }[];
403
+ name?: string | undefined;
404
+ description?: string | undefined;
405
+ scan_depth?: number | undefined;
406
+ token_budget?: number | undefined;
407
+ recursive_scanning?: boolean | undefined;
408
+ extensions?: Record<string, unknown> | undefined;
409
+ } | null | undefined;
410
+ assets?: {
411
+ name: string;
412
+ type: "custom" | "icon" | "background" | "emotion" | "user_icon" | "sound" | "video" | "x-risu-asset";
413
+ uri: string;
414
+ ext: string;
415
+ }[] | undefined;
416
+ nickname?: string | undefined;
417
+ creator_notes_multilingual?: Record<string, string> | undefined;
418
+ source?: string[] | undefined;
419
+ creation_date?: number | undefined;
420
+ modification_date?: number | undefined;
421
+ }, {
422
+ name?: string | undefined;
423
+ description?: string | undefined;
424
+ extensions?: Record<string, unknown> | undefined;
425
+ personality?: string | null | undefined;
426
+ scenario?: string | undefined;
427
+ first_mes?: string | undefined;
428
+ mes_example?: string | null | undefined;
429
+ creator_notes?: string | undefined;
430
+ system_prompt?: string | undefined;
431
+ post_history_instructions?: string | undefined;
432
+ alternate_greetings?: string[] | undefined;
433
+ character_book?: {
434
+ entries: {
435
+ keys: string[];
436
+ content: string;
437
+ enabled: boolean;
438
+ insertion_order: number;
439
+ name?: string | undefined;
440
+ extensions?: Record<string, unknown> | undefined;
441
+ case_sensitive?: boolean | undefined;
442
+ priority?: number | undefined;
443
+ id?: number | undefined;
444
+ comment?: string | undefined;
445
+ selective?: boolean | undefined;
446
+ secondary_keys?: string[] | undefined;
447
+ constant?: boolean | undefined;
448
+ position?: "before_char" | "after_char" | undefined;
449
+ automation_id?: string | undefined;
450
+ role?: "system" | "user" | "assistant" | undefined;
451
+ group?: string | undefined;
452
+ scan_frequency?: number | undefined;
453
+ probability?: number | undefined;
454
+ use_regex?: boolean | undefined;
455
+ depth?: number | undefined;
456
+ selective_logic?: "AND" | "NOT" | undefined;
457
+ }[];
458
+ name?: string | undefined;
459
+ description?: string | undefined;
460
+ scan_depth?: number | undefined;
461
+ token_budget?: number | undefined;
462
+ recursive_scanning?: boolean | undefined;
463
+ extensions?: Record<string, unknown> | undefined;
464
+ } | null | undefined;
465
+ tags?: string[] | undefined;
466
+ creator?: string | undefined;
467
+ character_version?: string | undefined;
468
+ group_only_greetings?: string[] | undefined;
469
+ assets?: {
470
+ name: string;
471
+ type: "custom" | "icon" | "background" | "emotion" | "user_icon" | "sound" | "video" | "x-risu-asset";
472
+ uri: string;
473
+ ext: string;
474
+ }[] | undefined;
475
+ nickname?: string | undefined;
476
+ creator_notes_multilingual?: Record<string, string> | undefined;
477
+ source?: string[] | undefined;
478
+ creation_date?: number | undefined;
479
+ modification_date?: number | undefined;
480
+ }>;
481
+ }, "strip", z.ZodTypeAny, {
482
+ data: {
483
+ name: string;
484
+ description: string;
485
+ personality: string | null;
486
+ scenario: string;
487
+ first_mes: string;
488
+ mes_example: string | null;
489
+ tags: string[];
490
+ creator: string;
491
+ character_version: string;
492
+ group_only_greetings: string[];
493
+ extensions?: Record<string, unknown> | undefined;
494
+ creator_notes?: string | undefined;
495
+ system_prompt?: string | undefined;
496
+ post_history_instructions?: string | undefined;
497
+ alternate_greetings?: string[] | undefined;
498
+ character_book?: {
499
+ entries: {
500
+ keys: string[];
501
+ content: string;
502
+ enabled: boolean;
503
+ insertion_order: number;
504
+ name?: string | undefined;
505
+ extensions?: Record<string, unknown> | undefined;
506
+ case_sensitive?: boolean | undefined;
507
+ priority?: number | undefined;
508
+ id?: number | undefined;
509
+ comment?: string | undefined;
510
+ selective?: boolean | undefined;
511
+ secondary_keys?: string[] | undefined;
512
+ constant?: boolean | undefined;
513
+ position?: "before_char" | "after_char" | undefined;
514
+ automation_id?: string | undefined;
515
+ role?: "system" | "user" | "assistant" | undefined;
516
+ group?: string | undefined;
517
+ scan_frequency?: number | undefined;
518
+ probability?: number | undefined;
519
+ use_regex?: boolean | undefined;
520
+ depth?: number | undefined;
521
+ selective_logic?: "AND" | "NOT" | undefined;
522
+ }[];
523
+ name?: string | undefined;
524
+ description?: string | undefined;
525
+ scan_depth?: number | undefined;
526
+ token_budget?: number | undefined;
527
+ recursive_scanning?: boolean | undefined;
528
+ extensions?: Record<string, unknown> | undefined;
529
+ } | null | undefined;
530
+ assets?: {
531
+ name: string;
532
+ type: "custom" | "icon" | "background" | "emotion" | "user_icon" | "sound" | "video" | "x-risu-asset";
533
+ uri: string;
534
+ ext: string;
535
+ }[] | undefined;
536
+ nickname?: string | undefined;
537
+ creator_notes_multilingual?: Record<string, string> | undefined;
538
+ source?: string[] | undefined;
539
+ creation_date?: number | undefined;
540
+ modification_date?: number | undefined;
541
+ };
542
+ spec: "chara_card_v3";
543
+ spec_version: "3.0";
544
+ }, {
545
+ data: {
546
+ name?: string | undefined;
547
+ description?: string | undefined;
548
+ extensions?: Record<string, unknown> | undefined;
549
+ personality?: string | null | undefined;
550
+ scenario?: string | undefined;
551
+ first_mes?: string | undefined;
552
+ mes_example?: string | null | undefined;
553
+ creator_notes?: string | undefined;
554
+ system_prompt?: string | undefined;
555
+ post_history_instructions?: string | undefined;
556
+ alternate_greetings?: string[] | undefined;
557
+ character_book?: {
558
+ entries: {
559
+ keys: string[];
560
+ content: string;
561
+ enabled: boolean;
562
+ insertion_order: number;
563
+ name?: string | undefined;
564
+ extensions?: Record<string, unknown> | undefined;
565
+ case_sensitive?: boolean | undefined;
566
+ priority?: number | undefined;
567
+ id?: number | undefined;
568
+ comment?: string | undefined;
569
+ selective?: boolean | undefined;
570
+ secondary_keys?: string[] | undefined;
571
+ constant?: boolean | undefined;
572
+ position?: "before_char" | "after_char" | undefined;
573
+ automation_id?: string | undefined;
574
+ role?: "system" | "user" | "assistant" | undefined;
575
+ group?: string | undefined;
576
+ scan_frequency?: number | undefined;
577
+ probability?: number | undefined;
578
+ use_regex?: boolean | undefined;
579
+ depth?: number | undefined;
580
+ selective_logic?: "AND" | "NOT" | undefined;
581
+ }[];
582
+ name?: string | undefined;
583
+ description?: string | undefined;
584
+ scan_depth?: number | undefined;
585
+ token_budget?: number | undefined;
586
+ recursive_scanning?: boolean | undefined;
587
+ extensions?: Record<string, unknown> | undefined;
588
+ } | null | undefined;
589
+ tags?: string[] | undefined;
590
+ creator?: string | undefined;
591
+ character_version?: string | undefined;
592
+ group_only_greetings?: string[] | undefined;
593
+ assets?: {
594
+ name: string;
595
+ type: "custom" | "icon" | "background" | "emotion" | "user_icon" | "sound" | "video" | "x-risu-asset";
596
+ uri: string;
597
+ ext: string;
598
+ }[] | undefined;
599
+ nickname?: string | undefined;
600
+ creator_notes_multilingual?: Record<string, string> | undefined;
601
+ source?: string[] | undefined;
602
+ creation_date?: number | undefined;
603
+ modification_date?: number | undefined;
604
+ };
605
+ spec: "chara_card_v3";
606
+ spec_version: "3.0";
607
+ }>;
608
+ /**
609
+ * Character book (lorebook) for v3 cards
610
+ */
611
+ export type CCv3CharacterBook = z.infer<typeof CCv3CharacterBookSchema>;
612
+ /**
613
+ * Character Card v3 full structure
614
+ */
615
+ export type CCv3Data = z.infer<typeof CCv3DataSchema>;
616
+ declare const SpecSchema: z.ZodEnum<[
617
+ "v2",
618
+ "v3"
619
+ ]>;
620
+ declare const SourceFormatSchema: z.ZodEnum<[
621
+ "png_v2",
622
+ "png_v3",
623
+ "json_v2",
624
+ "json_v3",
625
+ "charx",
626
+ "charx_risu",
627
+ "charx_jpeg",
628
+ "voxta"
629
+ ]>;
630
+ /**
631
+ * Card specification version
632
+ */
633
+ export type Spec = z.infer<typeof SpecSchema>;
634
+ /**
635
+ * Source format identifier
636
+ */
637
+ export type SourceFormat = z.infer<typeof SourceFormatSchema>;
638
+ /**
639
+ * Loader Types
640
+ *
641
+ * Types for the universal card loader API.
642
+ */
643
+ /**
644
+ * Detected container format (the file type)
645
+ */
646
+ export type ContainerFormat = "png" | "charx" | "voxta" | "json" | "lorebook" | "unknown";
647
+ /**
648
+ * Asset extracted from a card
649
+ */
650
+ export interface ExtractedAsset {
651
+ /** Asset name/identifier */
652
+ name: string;
653
+ /** Asset type */
654
+ type: "icon" | "emotion" | "background" | "sound" | "data" | "unknown";
655
+ /** File extension */
656
+ ext: string;
657
+ /** Binary data */
658
+ data: BinaryData;
659
+ /** Asset path within archive (if applicable) */
660
+ path?: string;
661
+ /** Whether this is the main/primary asset */
662
+ isMain?: boolean;
663
+ /** Associated character ID (for multi-character packages) */
664
+ characterId?: string;
665
+ /** Additional tags */
666
+ tags?: string[];
667
+ }
668
+ /**
669
+ * Result of parsing a character card
670
+ */
671
+ export interface ParseResult {
672
+ /** Normalized card data in CCv3 format */
673
+ card: CCv3Data;
674
+ /** Extracted assets */
675
+ assets: ExtractedAsset[];
676
+ /** Original container format */
677
+ containerFormat: ContainerFormat;
678
+ /** Detected spec version */
679
+ spec: Spec;
680
+ /** Original source format indicator */
681
+ sourceFormat: SourceFormat;
682
+ /** The raw JSON object before normalization */
683
+ originalShape: unknown;
684
+ /** Raw JSON string (if available) */
685
+ rawJson?: string;
686
+ /** Original file buffer */
687
+ rawBuffer: BinaryData;
688
+ /** Additional metadata from container */
689
+ metadata?: {
690
+ /** Character ID (for Voxta/CharX) */
691
+ characterId?: string;
692
+ /** Package ID (for Voxta) */
693
+ packageId?: string;
694
+ /** Creation date */
695
+ dateCreated?: string;
696
+ /** Modification date */
697
+ dateModified?: string;
698
+ /** Risu module.risum binary (opaque, preserved for round-trip) */
699
+ moduleRisum?: BinaryData;
700
+ };
701
+ /** Non-fatal warnings encountered during parsing */
702
+ warnings?: string[];
703
+ }
704
+ /**
705
+ * Options for the parseCard function
706
+ */
707
+ export interface ParseOptions {
708
+ /** Maximum file size to process (default: 50MB) */
709
+ maxFileSize?: number;
710
+ /** Maximum individual asset size (default: 50MB) */
711
+ maxAssetSize?: number;
712
+ /** Maximum total size for archives (default: 500MB) */
713
+ maxTotalSize?: number;
714
+ /** Whether to extract assets (default: true) */
715
+ extractAssets?: boolean;
716
+ }
717
+ /**
718
+ * Detection result
719
+ */
720
+ export interface DetectionResult {
721
+ /** Detected container format */
722
+ format: ContainerFormat;
723
+ /** Confidence level */
724
+ confidence: "high" | "medium" | "low";
725
+ /** Reason for detection */
726
+ reason: string;
727
+ }
728
+ /**
729
+ * Known lorebook formats (from @character-foundry/lorebook)
730
+ */
731
+ export type LorebookFormat = "ccv3" | "sillytavern" | "agnai" | "risu" | "wyvern" | "unknown";
732
+ /**
733
+ * Result of parsing a standalone lorebook
734
+ */
735
+ export interface LorebookParseResult {
736
+ /** Discriminator for type narrowing */
737
+ type: "lorebook";
738
+ /** Normalized lorebook in CCv3 format */
739
+ book: CCv3CharacterBook;
740
+ /** Original container format */
741
+ containerFormat: "lorebook";
742
+ /** Detected lorebook format */
743
+ lorebookFormat: LorebookFormat;
744
+ /** The raw JSON object before normalization */
745
+ originalShape: unknown;
746
+ /** Raw JSON string */
747
+ rawJson: string;
748
+ /** Original file buffer */
749
+ rawBuffer: BinaryData;
750
+ }
751
+ /**
752
+ * Result of parsing a character card (with discriminator)
753
+ */
754
+ export interface CardParseResult extends ParseResult {
755
+ /** Discriminator for type narrowing */
756
+ type: "card";
757
+ }
758
+ /**
759
+ * Union result from the universal parse() function
760
+ */
761
+ export type UniversalParseResult = CardParseResult | LorebookParseResult;
762
+ /**
763
+ * Format Detector
764
+ *
765
+ * Detects the container format of character card data.
766
+ */
767
+ /**
768
+ * Detect the container format of data
769
+ */
770
+ export declare function detectFormat(data: BinaryData): DetectionResult;
771
+ /**
772
+ * Quick check if data might be a character card
773
+ */
774
+ export declare function mightBeCard(data: BinaryData): boolean;
775
+ /**
776
+ * Universal Card Loader
777
+ *
778
+ * Loads character cards from any supported format.
779
+ */
780
+ /**
781
+ * Parse a character card from any supported format
782
+ *
783
+ * @param data - Binary data of the card file
784
+ * @param options - Parsing options
785
+ * @returns ParseResult with normalized card and extracted assets
786
+ */
787
+ export declare function parseCard(data: BinaryData, options?: ParseOptions): ParseResult;
788
+ /**
789
+ * Async version of parseCard
790
+ */
791
+ export declare function parseCardAsync(data: BinaryData, options?: ParseOptions): Promise<ParseResult>;
792
+ /**
793
+ * Get the container format of data without fully parsing
794
+ */
795
+ export declare function getContainerFormat(data: BinaryData): ContainerFormat;
796
+ /**
797
+ * Parse a standalone lorebook file
798
+ *
799
+ * @param data - Binary data of the lorebook file
800
+ * @returns LorebookParseResult with normalized lorebook
801
+ */
802
+ export declare function parseLorebook(data: BinaryData): LorebookParseResult;
803
+ /**
804
+ * Async version of parseLorebook
805
+ */
806
+ export declare function parseLorebookAsync(data: BinaryData): Promise<LorebookParseResult>;
807
+ /**
808
+ * Universal parser that handles both character cards and standalone lorebooks.
809
+ *
810
+ * Returns a discriminated union - check result.type to narrow:
811
+ * - 'card': CardParseResult with card data
812
+ * - 'lorebook': LorebookParseResult with lorebook data
813
+ *
814
+ * @param data - Binary data of the file
815
+ * @param options - Parsing options
816
+ * @returns UniversalParseResult (CardParseResult | LorebookParseResult)
817
+ *
818
+ * @example
819
+ * ```ts
820
+ * const result = parse(buffer);
821
+ * if (result.type === 'card') {
822
+ * console.log(result.card.data.name);
823
+ * } else {
824
+ * console.log(result.book.name, result.book.entries.length);
825
+ * }
826
+ * ```
827
+ */
828
+ export declare function parse(data: BinaryData, options?: ParseOptions): UniversalParseResult;
829
+ /**
830
+ * Async version of parse
831
+ */
832
+ export declare function parseAsync(data: BinaryData, options?: ParseOptions): Promise<UniversalParseResult>;
833
+ /**
834
+ * Server-side Metadata Validation
835
+ *
836
+ * Validates client-provided metadata against actual parsed card data,
837
+ * supporting optimistic UI while maintaining server authority.
838
+ *
839
+ * @example
840
+ * ```typescript
841
+ * import { validateClientMetadata } from '@character-foundry/loader';
842
+ *
843
+ * // Client sends metadata with upload
844
+ * const clientMeta = {
845
+ * name: 'My Character',
846
+ * tokens: { description: 150, total: 500 },
847
+ * contentHash: 'abc123',
848
+ * hasLorebook: true,
849
+ * lorebookEntriesCount: 5,
850
+ * };
851
+ *
852
+ * // Server parses and validates
853
+ * const result = await validateClientMetadata(clientMeta, parseResult);
854
+ *
855
+ * if (!result.isValid) {
856
+ * // Client metadata has significant discrepancies
857
+ * console.warn('Metadata discrepancies:', result.discrepancies);
858
+ * }
859
+ *
860
+ * // Use authoritative values
861
+ * const trustedMeta = result.authoritative;
862
+ * ```
863
+ */
864
+ /**
865
+ * Token counts for a character card
866
+ * Must match @character-foundry/tokenizers CardTokenCounts
867
+ */
868
+ export interface TokenCounts {
869
+ description: number;
870
+ personality: number;
871
+ scenario: number;
872
+ firstMes: number;
873
+ mesExample: number;
874
+ systemPrompt: number;
875
+ postHistoryInstructions: number;
876
+ alternateGreetings: number;
877
+ lorebook: number;
878
+ creatorNotes: number;
879
+ total: number;
880
+ }
881
+ /**
882
+ * Client-provided metadata submitted with upload
883
+ */
884
+ export interface ClientMetadata {
885
+ /** Character name */
886
+ name: string;
887
+ /** Character description (for display) */
888
+ description?: string;
889
+ /** Token counts computed client-side */
890
+ tokens: Partial<TokenCounts>;
891
+ /** Content hash computed client-side */
892
+ contentHash: string;
893
+ /** User-supplied tags */
894
+ tags?: string[];
895
+ /** Whether the card has a lorebook */
896
+ hasLorebook: boolean;
897
+ /** Number of lorebook entries */
898
+ lorebookEntriesCount: number;
899
+ }
900
+ /**
901
+ * A discrepancy between client and server values
902
+ */
903
+ export interface MetadataDiscrepancy {
904
+ /** Field that differs */
905
+ field: string;
906
+ /** Value provided by client */
907
+ clientValue: unknown;
908
+ /** Value computed by server */
909
+ computedValue: unknown;
910
+ /** Whether this discrepancy is within tolerance */
911
+ withinTolerance: boolean;
912
+ }
913
+ /**
914
+ * Authoritative metadata computed by server
915
+ */
916
+ export interface AuthoritativeMetadata {
917
+ /** Character name from card */
918
+ name: string;
919
+ /** Token counts computed server-side */
920
+ tokens: TokenCounts;
921
+ /** Content hash computed server-side */
922
+ contentHash: string;
923
+ /** Whether the card has a lorebook */
924
+ hasLorebook: boolean;
925
+ /** Number of lorebook entries */
926
+ lorebookEntriesCount: number;
927
+ }
928
+ /**
929
+ * Result of metadata validation
930
+ */
931
+ export interface ValidationResult {
932
+ /** Whether client metadata is valid (no significant discrepancies) */
933
+ isValid: boolean;
934
+ /** Whether client can be fully trusted (no discrepancies at all) */
935
+ isTrusted: boolean;
936
+ /** List of discrepancies found */
937
+ discrepancies: MetadataDiscrepancy[];
938
+ /** Server-computed authoritative values */
939
+ authoritative: AuthoritativeMetadata;
940
+ /** Warning messages (non-blocking) */
941
+ warnings: string[];
942
+ /** Error messages (blocking) */
943
+ errors: string[];
944
+ }
945
+ /**
946
+ * Tag validation function signature
947
+ */
948
+ export type TagValidator = (tags: string[]) => {
949
+ valid: boolean;
950
+ filtered: string[];
951
+ reason?: string;
952
+ };
953
+ /**
954
+ * Options for metadata validation
955
+ */
956
+ export interface ValidationOptions {
957
+ /**
958
+ * Tolerance for token count differences (default: 5%)
959
+ * Differences within this percentage are considered acceptable.
960
+ */
961
+ tokenTolerance?: number;
962
+ /**
963
+ * Allow hash mismatches without marking as invalid (default: false)
964
+ * When true, hash mismatches are only warnings.
965
+ */
966
+ allowHashMismatch?: boolean;
967
+ /**
968
+ * Custom tag validation function
969
+ * Called to filter/validate user-provided tags.
970
+ */
971
+ validateTags?: TagValidator;
972
+ /**
973
+ * Custom token counter function
974
+ * If provided, this is used instead of a built-in counter.
975
+ * Signature matches @character-foundry/tokenizers countCardTokens
976
+ */
977
+ countTokens?: (card: CCv3Data) => TokenCounts;
978
+ /**
979
+ * Custom content hash function
980
+ * If provided, this is used instead of the default SHA-256 hash.
981
+ */
982
+ computeHash?: (content: string) => Promise<string> | string;
983
+ }
984
+ /**
985
+ * Validate client-provided metadata against parsed card data
986
+ *
987
+ * This function ensures server authority over critical fields like
988
+ * token counts and content hashes while supporting optimistic UI.
989
+ *
990
+ * @param clientMetadata - Metadata provided by the client
991
+ * @param parseResult - Result from parseCard()
992
+ * @param options - Validation options
993
+ * @returns Validation result with authoritative values
994
+ *
995
+ * @example
996
+ * ```typescript
997
+ * import { parseCard, validateClientMetadata } from '@character-foundry/loader';
998
+ * import { countCardTokens } from '@character-foundry/tokenizers';
999
+ *
1000
+ * const parseResult = parseCard(buffer);
1001
+ * const result = await validateClientMetadata(clientMeta, parseResult, {
1002
+ * countTokens: (card) => countCardTokens(card),
1003
+ * tokenTolerance: 0.05, // 5% tolerance
1004
+ * });
1005
+ *
1006
+ * // Use authoritative values for storage
1007
+ * await db.insert({
1008
+ * ...clientMeta,
1009
+ * tokens: result.authoritative.tokens,
1010
+ * contentHash: result.authoritative.contentHash,
1011
+ * });
1012
+ * ```
1013
+ */
1014
+ export declare function validateClientMetadata(clientMetadata: ClientMetadata, parseResult: ParseResult, options?: ValidationOptions): Promise<ValidationResult>;
1015
+ /**
1016
+ * Compute content hash for a card (standalone utility)
1017
+ *
1018
+ * @param card - CCv3 card data
1019
+ * @returns SHA-256 hash of canonical content
1020
+ */
1021
+ export declare function computeContentHash(card: CCv3Data): Promise<string>;
1022
+ /**
1023
+ * Options for synchronous metadata validation
1024
+ */
1025
+ export interface SyncValidationOptions extends Omit<ValidationOptions, "computeHash"> {
1026
+ /**
1027
+ * Synchronous content hash function (required for sync version)
1028
+ */
1029
+ computeHash: (content: string) => string;
1030
+ }
1031
+ /**
1032
+ * Sync version of validateClientMetadata
1033
+ * Requires a synchronous hash function to be provided
1034
+ */
1035
+ export declare function validateClientMetadataSync(clientMetadata: ClientMetadata, parseResult: ParseResult, options: SyncValidationOptions): ValidationResult;
1036
+
1037
+ export {};