@character-foundry/character-foundry 0.4.2 → 0.4.3-dev.1766019473

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 (57) hide show
  1. package/dist/charx.cjs +15 -36
  2. package/dist/charx.cjs.map +1 -1
  3. package/dist/charx.d.cts +18 -9
  4. package/dist/charx.d.ts +18 -9
  5. package/dist/charx.js +15 -36
  6. package/dist/charx.js.map +1 -1
  7. package/dist/exporter.cjs +34 -38
  8. package/dist/exporter.cjs.map +1 -1
  9. package/dist/exporter.d.cts +18 -9
  10. package/dist/exporter.d.ts +18 -9
  11. package/dist/exporter.js +34 -38
  12. package/dist/exporter.js.map +1 -1
  13. package/dist/federation.cjs +104 -36
  14. package/dist/federation.cjs.map +1 -1
  15. package/dist/federation.d.cts +53 -9
  16. package/dist/federation.d.ts +53 -9
  17. package/dist/federation.js +104 -36
  18. package/dist/federation.js.map +1 -1
  19. package/dist/index.cjs +34 -38
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +42 -21
  22. package/dist/index.d.ts +42 -21
  23. package/dist/index.js +34 -38
  24. package/dist/index.js.map +1 -1
  25. package/dist/loader.cjs +101 -15
  26. package/dist/loader.cjs.map +1 -1
  27. package/dist/loader.d.cts +42 -14
  28. package/dist/loader.d.ts +42 -14
  29. package/dist/loader.js +101 -15
  30. package/dist/loader.js.map +1 -1
  31. package/dist/lorebook.d.cts +34 -17
  32. package/dist/lorebook.d.ts +34 -17
  33. package/dist/normalizer.cjs +2 -2
  34. package/dist/normalizer.cjs.map +1 -1
  35. package/dist/normalizer.d.cts +60 -30
  36. package/dist/normalizer.d.ts +60 -30
  37. package/dist/normalizer.js +2 -2
  38. package/dist/normalizer.js.map +1 -1
  39. package/dist/png.cjs +2 -2
  40. package/dist/png.cjs.map +1 -1
  41. package/dist/png.d.cts +32 -16
  42. package/dist/png.d.ts +32 -16
  43. package/dist/png.js +2 -2
  44. package/dist/png.js.map +1 -1
  45. package/dist/schemas.cjs +7 -7
  46. package/dist/schemas.cjs.map +1 -1
  47. package/dist/schemas.d.cts +96 -48
  48. package/dist/schemas.d.ts +96 -48
  49. package/dist/schemas.js +7 -7
  50. package/dist/schemas.js.map +1 -1
  51. package/dist/voxta.cjs +21 -4
  52. package/dist/voxta.cjs.map +1 -1
  53. package/dist/voxta.d.cts +28 -14
  54. package/dist/voxta.d.ts +28 -14
  55. package/dist/voxta.js +21 -4
  56. package/dist/voxta.js.map +1 -1
  57. package/package.json +6 -6
package/dist/charx.cjs CHANGED
@@ -500,7 +500,7 @@ var CCv2LorebookEntrySchema = import_zod2.z.object({
500
500
  selective: import_zod2.z.boolean().nullable().optional(),
501
501
  secondary_keys: import_zod2.z.array(import_zod2.z.string()).nullable().optional(),
502
502
  constant: import_zod2.z.boolean().nullable().optional(),
503
- position: import_zod2.z.union([import_zod2.z.enum(["before_char", "after_char"]), import_zod2.z.number().int(), import_zod2.z.literal("")]).nullable().optional()
503
+ position: import_zod2.z.union([import_zod2.z.enum(["before_char", "after_char", "in_chat"]), import_zod2.z.number().int(), import_zod2.z.literal("")]).nullable().optional()
504
504
  }).passthrough();
505
505
  var CCv2CharacterBookSchema = import_zod2.z.object({
506
506
  name: import_zod2.z.string().optional(),
@@ -553,7 +553,7 @@ var CCv3LorebookEntrySchema = import_zod3.z.object({
553
553
  selective: import_zod3.z.boolean().nullable().optional(),
554
554
  secondary_keys: import_zod3.z.array(import_zod3.z.string()).nullable().optional(),
555
555
  constant: import_zod3.z.boolean().nullable().optional(),
556
- position: import_zod3.z.union([import_zod3.z.enum(["before_char", "after_char"]), import_zod3.z.number().int(), import_zod3.z.literal("")]).nullable().optional(),
556
+ position: import_zod3.z.union([import_zod3.z.enum(["before_char", "after_char", "in_chat"]), import_zod3.z.number().int(), import_zod3.z.literal("")]).nullable().optional(),
557
557
  extensions: import_zod3.z.record(import_zod3.z.unknown()).optional(),
558
558
  // v3 specific - also lenient with types since SillyTavern uses numbers for enums
559
559
  automation_id: import_zod3.z.string().optional(),
@@ -868,36 +868,6 @@ var SAFE_ASSET_TYPES = /* @__PURE__ */ new Set([
868
868
  "data",
869
869
  "unknown"
870
870
  ]);
871
- var SAFE_EXTENSIONS = /* @__PURE__ */ new Set([
872
- // Images
873
- "png",
874
- "jpg",
875
- "jpeg",
876
- "webp",
877
- "gif",
878
- "avif",
879
- "svg",
880
- "bmp",
881
- "ico",
882
- // Audio
883
- "mp3",
884
- "wav",
885
- "ogg",
886
- "flac",
887
- "m4a",
888
- "aac",
889
- "opus",
890
- // Video
891
- "mp4",
892
- "webm",
893
- "avi",
894
- "mov",
895
- "mkv",
896
- // Data
897
- "json",
898
- "txt",
899
- "bin"
900
- ]);
901
871
  function getCharxCategory(mimetype) {
902
872
  if (mimetype.startsWith("image/")) return "images";
903
873
  if (mimetype.startsWith("audio/")) return "audio";
@@ -913,11 +883,20 @@ function sanitizeAssetType(type) {
913
883
  return sanitized || "custom";
914
884
  }
915
885
  function sanitizeExtension(ext) {
916
- const normalized = ext.replace(/^\./, "").toLowerCase().replace(/[^a-z0-9]/g, "");
917
- if (SAFE_EXTENSIONS.has(normalized)) {
918
- return normalized;
886
+ const normalized = ext.trim().replace(/^\./, "").toLowerCase();
887
+ if (!normalized) {
888
+ throw new Error("Invalid asset extension: empty extension");
889
+ }
890
+ if (normalized.length > 64) {
891
+ throw new Error(`Invalid asset extension: too long (${normalized.length} chars)`);
892
+ }
893
+ if (normalized.includes("/") || normalized.includes("\\") || normalized.includes("\0")) {
894
+ throw new Error("Invalid asset extension: path separators are not allowed");
895
+ }
896
+ if (!/^[a-z0-9][a-z0-9._-]*$/.test(normalized)) {
897
+ throw new Error(`Invalid asset extension: "${ext}"`);
919
898
  }
920
- return "bin";
899
+ return normalized;
921
900
  }
922
901
  function sanitizeName(name, ext) {
923
902
  let safeName = name;