@character-foundry/character-foundry 0.4.3-dev.1766103111 → 0.4.3
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/dist/charx.cjs +52 -85
- package/dist/charx.cjs.map +1 -1
- package/dist/charx.d.cts +22 -22
- package/dist/charx.d.ts +22 -22
- package/dist/charx.js +52 -85
- package/dist/charx.js.map +1 -1
- package/dist/exporter.cjs +54 -104
- package/dist/exporter.cjs.map +1 -1
- package/dist/exporter.d.cts +19 -19
- package/dist/exporter.d.ts +19 -19
- package/dist/exporter.js +54 -104
- package/dist/exporter.js.map +1 -1
- package/dist/federation.cjs +36 -104
- package/dist/federation.cjs.map +1 -1
- package/dist/federation.d.cts +19 -54
- package/dist/federation.d.ts +19 -54
- package/dist/federation.js +36 -104
- package/dist/federation.js.map +1 -1
- package/dist/index.cjs +54 -104
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -29
- package/dist/index.d.ts +29 -29
- package/dist/index.js +54 -104
- package/dist/index.js.map +1 -1
- package/dist/loader.cjs +31 -171
- package/dist/loader.cjs.map +1 -1
- package/dist/loader.d.cts +23 -37
- package/dist/loader.d.ts +23 -37
- package/dist/loader.js +31 -171
- package/dist/loader.js.map +1 -1
- package/dist/lorebook.d.cts +23 -23
- package/dist/lorebook.d.ts +23 -23
- package/dist/normalizer.cjs +18 -72
- package/dist/normalizer.cjs.map +1 -1
- package/dist/normalizer.d.cts +37 -37
- package/dist/normalizer.d.ts +37 -37
- package/dist/normalizer.js +18 -72
- package/dist/normalizer.js.map +1 -1
- package/dist/png.cjs +18 -72
- package/dist/png.cjs.map +1 -1
- package/dist/png.d.cts +25 -25
- package/dist/png.d.ts +25 -25
- package/dist/png.js +18 -72
- package/dist/png.js.map +1 -1
- package/dist/schemas.cjs +23 -80
- package/dist/schemas.cjs.map +1 -1
- package/dist/schemas.d.cts +67 -85
- package/dist/schemas.d.ts +67 -85
- package/dist/schemas.js +23 -80
- package/dist/schemas.js.map +1 -1
- package/dist/voxta.cjs +20 -91
- package/dist/voxta.cjs.map +1 -1
- package/dist/voxta.d.cts +23 -23
- package/dist/voxta.d.ts +23 -23
- package/dist/voxta.js +20 -91
- package/dist/voxta.js.map +1 -1
- package/package.json +5 -5
package/dist/loader.d.cts
CHANGED
|
@@ -13,8 +13,8 @@ export type BinaryData = Uint8Array;
|
|
|
13
13
|
declare const CCv3CharacterBookSchema: z.ZodObject<{
|
|
14
14
|
name: z.ZodOptional<z.ZodString>;
|
|
15
15
|
description: z.ZodOptional<z.ZodString>;
|
|
16
|
-
scan_depth: z.
|
|
17
|
-
token_budget: z.
|
|
16
|
+
scan_depth: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
token_budget: z.ZodOptional<z.ZodNumber>;
|
|
18
18
|
recursive_scanning: z.ZodOptional<z.ZodBoolean>;
|
|
19
19
|
extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
20
20
|
entries: z.ZodArray<z.ZodObject<{
|
|
@@ -250,8 +250,8 @@ declare const CCv3CharacterBookSchema: z.ZodObject<{
|
|
|
250
250
|
}, z.ZodTypeAny, "passthrough">[];
|
|
251
251
|
name?: string | undefined;
|
|
252
252
|
description?: string | undefined;
|
|
253
|
-
scan_depth?:
|
|
254
|
-
token_budget?:
|
|
253
|
+
scan_depth?: number | undefined;
|
|
254
|
+
token_budget?: number | undefined;
|
|
255
255
|
recursive_scanning?: boolean | undefined;
|
|
256
256
|
extensions?: Record<string, unknown> | undefined;
|
|
257
257
|
}>;
|
|
@@ -276,8 +276,8 @@ declare const CCv3DataSchema: z.ZodObject<{
|
|
|
276
276
|
character_book: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
277
277
|
name: z.ZodOptional<z.ZodString>;
|
|
278
278
|
description: z.ZodOptional<z.ZodString>;
|
|
279
|
-
scan_depth: z.
|
|
280
|
-
token_budget: z.
|
|
279
|
+
scan_depth: z.ZodOptional<z.ZodNumber>;
|
|
280
|
+
token_budget: z.ZodOptional<z.ZodNumber>;
|
|
281
281
|
recursive_scanning: z.ZodOptional<z.ZodBoolean>;
|
|
282
282
|
extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
283
283
|
entries: z.ZodArray<z.ZodObject<{
|
|
@@ -513,14 +513,14 @@ declare const CCv3DataSchema: z.ZodObject<{
|
|
|
513
513
|
}, z.ZodTypeAny, "passthrough">[];
|
|
514
514
|
name?: string | undefined;
|
|
515
515
|
description?: string | undefined;
|
|
516
|
-
scan_depth?:
|
|
517
|
-
token_budget?:
|
|
516
|
+
scan_depth?: number | undefined;
|
|
517
|
+
token_budget?: number | undefined;
|
|
518
518
|
recursive_scanning?: boolean | undefined;
|
|
519
519
|
extensions?: Record<string, unknown> | undefined;
|
|
520
520
|
}>>>;
|
|
521
521
|
extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
522
522
|
assets: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
523
|
-
type: z.
|
|
523
|
+
type: z.ZodEnum<[
|
|
524
524
|
"icon",
|
|
525
525
|
"background",
|
|
526
526
|
"emotion",
|
|
@@ -529,7 +529,7 @@ declare const CCv3DataSchema: z.ZodObject<{
|
|
|
529
529
|
"video",
|
|
530
530
|
"custom",
|
|
531
531
|
"x-risu-asset"
|
|
532
|
-
]
|
|
532
|
+
]>;
|
|
533
533
|
uri: z.ZodString;
|
|
534
534
|
name: z.ZodString;
|
|
535
535
|
ext: z.ZodString;
|
|
@@ -540,15 +540,15 @@ declare const CCv3DataSchema: z.ZodObject<{
|
|
|
540
540
|
ext: string;
|
|
541
541
|
}, {
|
|
542
542
|
name: string;
|
|
543
|
+
type: "custom" | "icon" | "background" | "emotion" | "user_icon" | "sound" | "video" | "x-risu-asset";
|
|
543
544
|
uri: string;
|
|
544
545
|
ext: string;
|
|
545
|
-
type?: unknown;
|
|
546
546
|
}>, "many">>;
|
|
547
547
|
nickname: z.ZodOptional<z.ZodString>;
|
|
548
548
|
creator_notes_multilingual: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
549
549
|
source: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
550
|
-
creation_date: z.
|
|
551
|
-
modification_date: z.
|
|
550
|
+
creation_date: z.ZodOptional<z.ZodNumber>;
|
|
551
|
+
modification_date: z.ZodOptional<z.ZodNumber>;
|
|
552
552
|
}, "strip", z.ZodTypeAny, {
|
|
553
553
|
name: string;
|
|
554
554
|
description: string;
|
|
@@ -689,8 +689,8 @@ declare const CCv3DataSchema: z.ZodObject<{
|
|
|
689
689
|
}, z.ZodTypeAny, "passthrough">[];
|
|
690
690
|
name?: string | undefined;
|
|
691
691
|
description?: string | undefined;
|
|
692
|
-
scan_depth?:
|
|
693
|
-
token_budget?:
|
|
692
|
+
scan_depth?: number | undefined;
|
|
693
|
+
token_budget?: number | undefined;
|
|
694
694
|
recursive_scanning?: boolean | undefined;
|
|
695
695
|
extensions?: Record<string, unknown> | undefined;
|
|
696
696
|
} | null | undefined;
|
|
@@ -700,15 +700,15 @@ declare const CCv3DataSchema: z.ZodObject<{
|
|
|
700
700
|
group_only_greetings?: string[] | undefined;
|
|
701
701
|
assets?: {
|
|
702
702
|
name: string;
|
|
703
|
+
type: "custom" | "icon" | "background" | "emotion" | "user_icon" | "sound" | "video" | "x-risu-asset";
|
|
703
704
|
uri: string;
|
|
704
705
|
ext: string;
|
|
705
|
-
type?: unknown;
|
|
706
706
|
}[] | undefined;
|
|
707
707
|
nickname?: string | undefined;
|
|
708
708
|
creator_notes_multilingual?: Record<string, string> | undefined;
|
|
709
709
|
source?: string[] | undefined;
|
|
710
|
-
creation_date?:
|
|
711
|
-
modification_date?:
|
|
710
|
+
creation_date?: number | undefined;
|
|
711
|
+
modification_date?: number | undefined;
|
|
712
712
|
}>;
|
|
713
713
|
}, "strip", z.ZodTypeAny, {
|
|
714
714
|
data: {
|
|
@@ -855,8 +855,8 @@ declare const CCv3DataSchema: z.ZodObject<{
|
|
|
855
855
|
}, z.ZodTypeAny, "passthrough">[];
|
|
856
856
|
name?: string | undefined;
|
|
857
857
|
description?: string | undefined;
|
|
858
|
-
scan_depth?:
|
|
859
|
-
token_budget?:
|
|
858
|
+
scan_depth?: number | undefined;
|
|
859
|
+
token_budget?: number | undefined;
|
|
860
860
|
recursive_scanning?: boolean | undefined;
|
|
861
861
|
extensions?: Record<string, unknown> | undefined;
|
|
862
862
|
} | null | undefined;
|
|
@@ -866,15 +866,15 @@ declare const CCv3DataSchema: z.ZodObject<{
|
|
|
866
866
|
group_only_greetings?: string[] | undefined;
|
|
867
867
|
assets?: {
|
|
868
868
|
name: string;
|
|
869
|
+
type: "custom" | "icon" | "background" | "emotion" | "user_icon" | "sound" | "video" | "x-risu-asset";
|
|
869
870
|
uri: string;
|
|
870
871
|
ext: string;
|
|
871
|
-
type?: unknown;
|
|
872
872
|
}[] | undefined;
|
|
873
873
|
nickname?: string | undefined;
|
|
874
874
|
creator_notes_multilingual?: Record<string, string> | undefined;
|
|
875
875
|
source?: string[] | undefined;
|
|
876
|
-
creation_date?:
|
|
877
|
-
modification_date?:
|
|
876
|
+
creation_date?: number | undefined;
|
|
877
|
+
modification_date?: number | undefined;
|
|
878
878
|
};
|
|
879
879
|
spec: "chara_card_v3";
|
|
880
880
|
spec_version: "3.0";
|
|
@@ -1194,13 +1194,6 @@ export interface AuthoritativeMetadata {
|
|
|
1194
1194
|
tokens: TokenCounts;
|
|
1195
1195
|
/** Content hash computed server-side */
|
|
1196
1196
|
contentHash: string;
|
|
1197
|
-
/**
|
|
1198
|
-
* Content hash v2 computed server-side.
|
|
1199
|
-
*
|
|
1200
|
-
* @remarks
|
|
1201
|
-
* v1 is preserved for backwards compatibility. Prefer v2 for new storage/deduplication.
|
|
1202
|
-
*/
|
|
1203
|
-
contentHashV2?: string;
|
|
1204
1197
|
/** Whether the card has a lorebook */
|
|
1205
1198
|
hasLorebook: boolean;
|
|
1206
1199
|
/** Number of lorebook entries */
|
|
@@ -1300,13 +1293,6 @@ export declare function validateClientMetadata(clientMetadata: ClientMetadata, p
|
|
|
1300
1293
|
* @returns SHA-256 hash of canonical content
|
|
1301
1294
|
*/
|
|
1302
1295
|
export declare function computeContentHash(card: CCv3Data): Promise<string>;
|
|
1303
|
-
/**
|
|
1304
|
-
* Compute content hash v2 for a card (standalone utility)
|
|
1305
|
-
*
|
|
1306
|
-
* @param card - CCv3 card data
|
|
1307
|
-
* @returns SHA-256 hash of canonical content v2
|
|
1308
|
-
*/
|
|
1309
|
-
export declare function computeContentHashV2(card: CCv3Data): Promise<string>;
|
|
1310
1296
|
/**
|
|
1311
1297
|
* Options for synchronous metadata validation
|
|
1312
1298
|
*/
|
package/dist/loader.d.ts
CHANGED
|
@@ -13,8 +13,8 @@ export type BinaryData = Uint8Array;
|
|
|
13
13
|
declare const CCv3CharacterBookSchema: z.ZodObject<{
|
|
14
14
|
name: z.ZodOptional<z.ZodString>;
|
|
15
15
|
description: z.ZodOptional<z.ZodString>;
|
|
16
|
-
scan_depth: z.
|
|
17
|
-
token_budget: z.
|
|
16
|
+
scan_depth: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
token_budget: z.ZodOptional<z.ZodNumber>;
|
|
18
18
|
recursive_scanning: z.ZodOptional<z.ZodBoolean>;
|
|
19
19
|
extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
20
20
|
entries: z.ZodArray<z.ZodObject<{
|
|
@@ -250,8 +250,8 @@ declare const CCv3CharacterBookSchema: z.ZodObject<{
|
|
|
250
250
|
}, z.ZodTypeAny, "passthrough">[];
|
|
251
251
|
name?: string | undefined;
|
|
252
252
|
description?: string | undefined;
|
|
253
|
-
scan_depth?:
|
|
254
|
-
token_budget?:
|
|
253
|
+
scan_depth?: number | undefined;
|
|
254
|
+
token_budget?: number | undefined;
|
|
255
255
|
recursive_scanning?: boolean | undefined;
|
|
256
256
|
extensions?: Record<string, unknown> | undefined;
|
|
257
257
|
}>;
|
|
@@ -276,8 +276,8 @@ declare const CCv3DataSchema: z.ZodObject<{
|
|
|
276
276
|
character_book: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
277
277
|
name: z.ZodOptional<z.ZodString>;
|
|
278
278
|
description: z.ZodOptional<z.ZodString>;
|
|
279
|
-
scan_depth: z.
|
|
280
|
-
token_budget: z.
|
|
279
|
+
scan_depth: z.ZodOptional<z.ZodNumber>;
|
|
280
|
+
token_budget: z.ZodOptional<z.ZodNumber>;
|
|
281
281
|
recursive_scanning: z.ZodOptional<z.ZodBoolean>;
|
|
282
282
|
extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
283
283
|
entries: z.ZodArray<z.ZodObject<{
|
|
@@ -513,14 +513,14 @@ declare const CCv3DataSchema: z.ZodObject<{
|
|
|
513
513
|
}, z.ZodTypeAny, "passthrough">[];
|
|
514
514
|
name?: string | undefined;
|
|
515
515
|
description?: string | undefined;
|
|
516
|
-
scan_depth?:
|
|
517
|
-
token_budget?:
|
|
516
|
+
scan_depth?: number | undefined;
|
|
517
|
+
token_budget?: number | undefined;
|
|
518
518
|
recursive_scanning?: boolean | undefined;
|
|
519
519
|
extensions?: Record<string, unknown> | undefined;
|
|
520
520
|
}>>>;
|
|
521
521
|
extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
522
522
|
assets: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
523
|
-
type: z.
|
|
523
|
+
type: z.ZodEnum<[
|
|
524
524
|
"icon",
|
|
525
525
|
"background",
|
|
526
526
|
"emotion",
|
|
@@ -529,7 +529,7 @@ declare const CCv3DataSchema: z.ZodObject<{
|
|
|
529
529
|
"video",
|
|
530
530
|
"custom",
|
|
531
531
|
"x-risu-asset"
|
|
532
|
-
]
|
|
532
|
+
]>;
|
|
533
533
|
uri: z.ZodString;
|
|
534
534
|
name: z.ZodString;
|
|
535
535
|
ext: z.ZodString;
|
|
@@ -540,15 +540,15 @@ declare const CCv3DataSchema: z.ZodObject<{
|
|
|
540
540
|
ext: string;
|
|
541
541
|
}, {
|
|
542
542
|
name: string;
|
|
543
|
+
type: "custom" | "icon" | "background" | "emotion" | "user_icon" | "sound" | "video" | "x-risu-asset";
|
|
543
544
|
uri: string;
|
|
544
545
|
ext: string;
|
|
545
|
-
type?: unknown;
|
|
546
546
|
}>, "many">>;
|
|
547
547
|
nickname: z.ZodOptional<z.ZodString>;
|
|
548
548
|
creator_notes_multilingual: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
549
549
|
source: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
550
|
-
creation_date: z.
|
|
551
|
-
modification_date: z.
|
|
550
|
+
creation_date: z.ZodOptional<z.ZodNumber>;
|
|
551
|
+
modification_date: z.ZodOptional<z.ZodNumber>;
|
|
552
552
|
}, "strip", z.ZodTypeAny, {
|
|
553
553
|
name: string;
|
|
554
554
|
description: string;
|
|
@@ -689,8 +689,8 @@ declare const CCv3DataSchema: z.ZodObject<{
|
|
|
689
689
|
}, z.ZodTypeAny, "passthrough">[];
|
|
690
690
|
name?: string | undefined;
|
|
691
691
|
description?: string | undefined;
|
|
692
|
-
scan_depth?:
|
|
693
|
-
token_budget?:
|
|
692
|
+
scan_depth?: number | undefined;
|
|
693
|
+
token_budget?: number | undefined;
|
|
694
694
|
recursive_scanning?: boolean | undefined;
|
|
695
695
|
extensions?: Record<string, unknown> | undefined;
|
|
696
696
|
} | null | undefined;
|
|
@@ -700,15 +700,15 @@ declare const CCv3DataSchema: z.ZodObject<{
|
|
|
700
700
|
group_only_greetings?: string[] | undefined;
|
|
701
701
|
assets?: {
|
|
702
702
|
name: string;
|
|
703
|
+
type: "custom" | "icon" | "background" | "emotion" | "user_icon" | "sound" | "video" | "x-risu-asset";
|
|
703
704
|
uri: string;
|
|
704
705
|
ext: string;
|
|
705
|
-
type?: unknown;
|
|
706
706
|
}[] | undefined;
|
|
707
707
|
nickname?: string | undefined;
|
|
708
708
|
creator_notes_multilingual?: Record<string, string> | undefined;
|
|
709
709
|
source?: string[] | undefined;
|
|
710
|
-
creation_date?:
|
|
711
|
-
modification_date?:
|
|
710
|
+
creation_date?: number | undefined;
|
|
711
|
+
modification_date?: number | undefined;
|
|
712
712
|
}>;
|
|
713
713
|
}, "strip", z.ZodTypeAny, {
|
|
714
714
|
data: {
|
|
@@ -855,8 +855,8 @@ declare const CCv3DataSchema: z.ZodObject<{
|
|
|
855
855
|
}, z.ZodTypeAny, "passthrough">[];
|
|
856
856
|
name?: string | undefined;
|
|
857
857
|
description?: string | undefined;
|
|
858
|
-
scan_depth?:
|
|
859
|
-
token_budget?:
|
|
858
|
+
scan_depth?: number | undefined;
|
|
859
|
+
token_budget?: number | undefined;
|
|
860
860
|
recursive_scanning?: boolean | undefined;
|
|
861
861
|
extensions?: Record<string, unknown> | undefined;
|
|
862
862
|
} | null | undefined;
|
|
@@ -866,15 +866,15 @@ declare const CCv3DataSchema: z.ZodObject<{
|
|
|
866
866
|
group_only_greetings?: string[] | undefined;
|
|
867
867
|
assets?: {
|
|
868
868
|
name: string;
|
|
869
|
+
type: "custom" | "icon" | "background" | "emotion" | "user_icon" | "sound" | "video" | "x-risu-asset";
|
|
869
870
|
uri: string;
|
|
870
871
|
ext: string;
|
|
871
|
-
type?: unknown;
|
|
872
872
|
}[] | undefined;
|
|
873
873
|
nickname?: string | undefined;
|
|
874
874
|
creator_notes_multilingual?: Record<string, string> | undefined;
|
|
875
875
|
source?: string[] | undefined;
|
|
876
|
-
creation_date?:
|
|
877
|
-
modification_date?:
|
|
876
|
+
creation_date?: number | undefined;
|
|
877
|
+
modification_date?: number | undefined;
|
|
878
878
|
};
|
|
879
879
|
spec: "chara_card_v3";
|
|
880
880
|
spec_version: "3.0";
|
|
@@ -1194,13 +1194,6 @@ export interface AuthoritativeMetadata {
|
|
|
1194
1194
|
tokens: TokenCounts;
|
|
1195
1195
|
/** Content hash computed server-side */
|
|
1196
1196
|
contentHash: string;
|
|
1197
|
-
/**
|
|
1198
|
-
* Content hash v2 computed server-side.
|
|
1199
|
-
*
|
|
1200
|
-
* @remarks
|
|
1201
|
-
* v1 is preserved for backwards compatibility. Prefer v2 for new storage/deduplication.
|
|
1202
|
-
*/
|
|
1203
|
-
contentHashV2?: string;
|
|
1204
1197
|
/** Whether the card has a lorebook */
|
|
1205
1198
|
hasLorebook: boolean;
|
|
1206
1199
|
/** Number of lorebook entries */
|
|
@@ -1300,13 +1293,6 @@ export declare function validateClientMetadata(clientMetadata: ClientMetadata, p
|
|
|
1300
1293
|
* @returns SHA-256 hash of canonical content
|
|
1301
1294
|
*/
|
|
1302
1295
|
export declare function computeContentHash(card: CCv3Data): Promise<string>;
|
|
1303
|
-
/**
|
|
1304
|
-
* Compute content hash v2 for a card (standalone utility)
|
|
1305
|
-
*
|
|
1306
|
-
* @param card - CCv3 card data
|
|
1307
|
-
* @returns SHA-256 hash of canonical content v2
|
|
1308
|
-
*/
|
|
1309
|
-
export declare function computeContentHashV2(card: CCv3Data): Promise<string>;
|
|
1310
1296
|
/**
|
|
1311
1297
|
* Options for synchronous metadata validation
|
|
1312
1298
|
*/
|
package/dist/loader.js
CHANGED
|
@@ -413,58 +413,6 @@ import { z } from "zod";
|
|
|
413
413
|
import { z as z2 } from "zod";
|
|
414
414
|
import { z as z3 } from "zod";
|
|
415
415
|
import "zod";
|
|
416
|
-
function preprocessTimestamp(val) {
|
|
417
|
-
if (val === null || val === void 0) return void 0;
|
|
418
|
-
let num;
|
|
419
|
-
if (typeof val === "number") {
|
|
420
|
-
num = val;
|
|
421
|
-
} else if (typeof val === "string") {
|
|
422
|
-
const trimmed = val.trim();
|
|
423
|
-
if (!trimmed) return void 0;
|
|
424
|
-
const parsed = Number(trimmed);
|
|
425
|
-
if (!isNaN(parsed)) {
|
|
426
|
-
num = parsed;
|
|
427
|
-
} else {
|
|
428
|
-
const date = new Date(trimmed);
|
|
429
|
-
if (isNaN(date.getTime())) return void 0;
|
|
430
|
-
num = Math.floor(date.getTime() / 1e3);
|
|
431
|
-
}
|
|
432
|
-
} else {
|
|
433
|
-
return void 0;
|
|
434
|
-
}
|
|
435
|
-
if (num > 1e10) {
|
|
436
|
-
num = Math.floor(num / 1e3);
|
|
437
|
-
}
|
|
438
|
-
if (num < 0) return void 0;
|
|
439
|
-
return num;
|
|
440
|
-
}
|
|
441
|
-
function preprocessNumeric(val) {
|
|
442
|
-
if (val === null || val === void 0) return void 0;
|
|
443
|
-
if (typeof val === "number") {
|
|
444
|
-
return isNaN(val) ? void 0 : val;
|
|
445
|
-
}
|
|
446
|
-
if (typeof val === "string") {
|
|
447
|
-
const trimmed = val.trim();
|
|
448
|
-
if (!trimmed) return void 0;
|
|
449
|
-
const parsed = Number(trimmed);
|
|
450
|
-
return isNaN(parsed) ? void 0 : parsed;
|
|
451
|
-
}
|
|
452
|
-
return void 0;
|
|
453
|
-
}
|
|
454
|
-
var KNOWN_ASSET_TYPES = /* @__PURE__ */ new Set([
|
|
455
|
-
"icon",
|
|
456
|
-
"background",
|
|
457
|
-
"emotion",
|
|
458
|
-
"user_icon",
|
|
459
|
-
"sound",
|
|
460
|
-
"video",
|
|
461
|
-
"custom",
|
|
462
|
-
"x-risu-asset"
|
|
463
|
-
]);
|
|
464
|
-
function preprocessAssetType(val) {
|
|
465
|
-
if (typeof val !== "string") return "custom";
|
|
466
|
-
return KNOWN_ASSET_TYPES.has(val) ? val : "custom";
|
|
467
|
-
}
|
|
468
416
|
var ISO8601Schema = z.string().datetime();
|
|
469
417
|
var UUIDSchema = z.string().uuid();
|
|
470
418
|
var SpecSchema = z.enum(["v2", "v3"]);
|
|
@@ -487,19 +435,16 @@ var SourceFormatSchema = z.enum([
|
|
|
487
435
|
// VoxPkg format
|
|
488
436
|
]);
|
|
489
437
|
var OriginalShapeSchema = z.enum(["wrapped", "unwrapped", "legacy"]);
|
|
490
|
-
var AssetTypeSchema = z.
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
"x-risu-asset"
|
|
501
|
-
])
|
|
502
|
-
);
|
|
438
|
+
var AssetTypeSchema = z.enum([
|
|
439
|
+
"icon",
|
|
440
|
+
"background",
|
|
441
|
+
"emotion",
|
|
442
|
+
"user_icon",
|
|
443
|
+
"sound",
|
|
444
|
+
"video",
|
|
445
|
+
"custom",
|
|
446
|
+
"x-risu-asset"
|
|
447
|
+
]);
|
|
503
448
|
var AssetDescriptorSchema = z.object({
|
|
504
449
|
type: AssetTypeSchema,
|
|
505
450
|
uri: z.string(),
|
|
@@ -533,8 +478,8 @@ var CCv2LorebookEntrySchema = z2.object({
|
|
|
533
478
|
var CCv2CharacterBookSchema = z2.object({
|
|
534
479
|
name: z2.string().optional(),
|
|
535
480
|
description: z2.string().optional(),
|
|
536
|
-
scan_depth: z2.
|
|
537
|
-
token_budget: z2.
|
|
481
|
+
scan_depth: z2.number().int().nonnegative().optional(),
|
|
482
|
+
token_budget: z2.number().int().nonnegative().optional(),
|
|
538
483
|
recursive_scanning: z2.boolean().optional(),
|
|
539
484
|
extensions: z2.record(z2.unknown()).optional(),
|
|
540
485
|
entries: z2.array(CCv2LorebookEntrySchema)
|
|
@@ -608,8 +553,8 @@ var CCv3LorebookEntrySchema = z3.object({
|
|
|
608
553
|
var CCv3CharacterBookSchema = z3.object({
|
|
609
554
|
name: z3.string().optional(),
|
|
610
555
|
description: z3.string().optional(),
|
|
611
|
-
scan_depth: z3.
|
|
612
|
-
token_budget: z3.
|
|
556
|
+
scan_depth: z3.number().int().nonnegative().optional(),
|
|
557
|
+
token_budget: z3.number().int().nonnegative().optional(),
|
|
613
558
|
recursive_scanning: z3.boolean().optional(),
|
|
614
559
|
extensions: z3.record(z3.unknown()).optional(),
|
|
615
560
|
entries: z3.array(CCv3LorebookEntrySchema)
|
|
@@ -641,9 +586,10 @@ var CCv3DataInnerSchema = z3.object({
|
|
|
641
586
|
nickname: z3.string().optional(),
|
|
642
587
|
creator_notes_multilingual: z3.record(z3.string()).optional(),
|
|
643
588
|
source: z3.array(z3.string()).optional(),
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
modification_date: z3.
|
|
589
|
+
creation_date: z3.number().int().nonnegative().optional(),
|
|
590
|
+
// Unix timestamp in seconds
|
|
591
|
+
modification_date: z3.number().int().nonnegative().optional()
|
|
592
|
+
// Unix timestamp in seconds
|
|
647
593
|
});
|
|
648
594
|
var CCv3DataSchema = z3.object({
|
|
649
595
|
spec: z3.literal("chara_card_v3"),
|
|
@@ -8751,7 +8697,7 @@ function defaultTokenCounter(_card) {
|
|
|
8751
8697
|
total: 0
|
|
8752
8698
|
};
|
|
8753
8699
|
}
|
|
8754
|
-
function
|
|
8700
|
+
function getCanonicalContent(card) {
|
|
8755
8701
|
const normalized = {
|
|
8756
8702
|
name: card.data.name,
|
|
8757
8703
|
description: card.data.description || "",
|
|
@@ -8773,69 +8719,6 @@ function getCanonicalContentV1(card) {
|
|
|
8773
8719
|
};
|
|
8774
8720
|
return JSON.stringify(normalized, Object.keys(normalized).sort());
|
|
8775
8721
|
}
|
|
8776
|
-
function stableStringify(value) {
|
|
8777
|
-
if (value === null) return "null";
|
|
8778
|
-
switch (typeof value) {
|
|
8779
|
-
case "string":
|
|
8780
|
-
return JSON.stringify(value);
|
|
8781
|
-
case "number":
|
|
8782
|
-
return Number.isFinite(value) ? String(value) : "null";
|
|
8783
|
-
case "boolean":
|
|
8784
|
-
return value ? "true" : "false";
|
|
8785
|
-
case "bigint":
|
|
8786
|
-
return JSON.stringify(value.toString());
|
|
8787
|
-
case "undefined":
|
|
8788
|
-
case "function":
|
|
8789
|
-
case "symbol":
|
|
8790
|
-
return "null";
|
|
8791
|
-
case "object": {
|
|
8792
|
-
if (Array.isArray(value)) {
|
|
8793
|
-
const parts2 = value.map((item) => {
|
|
8794
|
-
if (item === void 0 || typeof item === "function" || typeof item === "symbol") {
|
|
8795
|
-
return "null";
|
|
8796
|
-
}
|
|
8797
|
-
return stableStringify(item);
|
|
8798
|
-
});
|
|
8799
|
-
return `[${parts2.join(",")}]`;
|
|
8800
|
-
}
|
|
8801
|
-
const obj = value;
|
|
8802
|
-
const keys = Object.keys(obj).sort();
|
|
8803
|
-
const parts = [];
|
|
8804
|
-
for (const key of keys) {
|
|
8805
|
-
const v = obj[key];
|
|
8806
|
-
if (v === void 0 || typeof v === "function" || typeof v === "symbol") {
|
|
8807
|
-
continue;
|
|
8808
|
-
}
|
|
8809
|
-
parts.push(`${JSON.stringify(key)}:${stableStringify(v)}`);
|
|
8810
|
-
}
|
|
8811
|
-
return `{${parts.join(",")}}`;
|
|
8812
|
-
}
|
|
8813
|
-
default:
|
|
8814
|
-
return "null";
|
|
8815
|
-
}
|
|
8816
|
-
}
|
|
8817
|
-
function getCanonicalContentV2(card) {
|
|
8818
|
-
const normalized = {
|
|
8819
|
-
name: card.data.name,
|
|
8820
|
-
description: card.data.description || "",
|
|
8821
|
-
personality: card.data.personality || "",
|
|
8822
|
-
scenario: card.data.scenario || "",
|
|
8823
|
-
first_mes: card.data.first_mes || "",
|
|
8824
|
-
mes_example: card.data.mes_example || "",
|
|
8825
|
-
system_prompt: card.data.system_prompt || "",
|
|
8826
|
-
post_history_instructions: card.data.post_history_instructions || "",
|
|
8827
|
-
alternate_greetings: card.data.alternate_greetings || [],
|
|
8828
|
-
character_book: card.data.character_book ? {
|
|
8829
|
-
entries: (card.data.character_book.entries || []).map((e) => ({
|
|
8830
|
-
keys: e.keys,
|
|
8831
|
-
content: e.content,
|
|
8832
|
-
enabled: e.enabled
|
|
8833
|
-
}))
|
|
8834
|
-
} : null,
|
|
8835
|
-
creator_notes: card.data.creator_notes || ""
|
|
8836
|
-
};
|
|
8837
|
-
return stableStringify(normalized);
|
|
8838
|
-
}
|
|
8839
8722
|
function isWithinTolerance(clientValue, computedValue, tolerance) {
|
|
8840
8723
|
if (clientValue === void 0) return false;
|
|
8841
8724
|
if (computedValue === 0) return clientValue === 0;
|
|
@@ -8856,18 +8739,15 @@ async function validateClientMetadata(clientMetadata, parseResult, options = {})
|
|
|
8856
8739
|
const warnings = [];
|
|
8857
8740
|
const errors = [];
|
|
8858
8741
|
const computedTokens = countTokens(card);
|
|
8859
|
-
const
|
|
8860
|
-
const
|
|
8861
|
-
const computedHashV1 = await computeHash(canonicalContentV1);
|
|
8862
|
-
const computedHashV2 = await computeHash(canonicalContentV2);
|
|
8742
|
+
const canonicalContent = getCanonicalContent(card);
|
|
8743
|
+
const computedHash = await computeHash(canonicalContent);
|
|
8863
8744
|
const entries = card.data.character_book?.entries || [];
|
|
8864
8745
|
const computedHasLorebook = entries.length > 0;
|
|
8865
8746
|
const computedLorebookCount = entries.length;
|
|
8866
8747
|
const authoritative = {
|
|
8867
8748
|
name: card.data.name,
|
|
8868
8749
|
tokens: computedTokens,
|
|
8869
|
-
contentHash:
|
|
8870
|
-
contentHashV2: computedHashV2,
|
|
8750
|
+
contentHash: computedHash,
|
|
8871
8751
|
hasLorebook: computedHasLorebook,
|
|
8872
8752
|
lorebookEntriesCount: computedLorebookCount
|
|
8873
8753
|
};
|
|
@@ -8879,27 +8759,21 @@ async function validateClientMetadata(clientMetadata, parseResult, options = {})
|
|
|
8879
8759
|
withinTolerance: false
|
|
8880
8760
|
});
|
|
8881
8761
|
}
|
|
8882
|
-
|
|
8883
|
-
const matchesV2 = clientMetadata.contentHash === computedHashV2;
|
|
8884
|
-
if (!matchesV1 && !matchesV2) {
|
|
8762
|
+
if (clientMetadata.contentHash !== computedHash) {
|
|
8885
8763
|
const disc = {
|
|
8886
8764
|
field: "contentHash",
|
|
8887
8765
|
clientValue: clientMetadata.contentHash,
|
|
8888
|
-
computedValue:
|
|
8766
|
+
computedValue: computedHash,
|
|
8889
8767
|
withinTolerance: false
|
|
8890
8768
|
};
|
|
8891
8769
|
discrepancies.push(disc);
|
|
8892
8770
|
if (allowHashMismatch) {
|
|
8893
8771
|
warnings.push(
|
|
8894
|
-
`Content hash mismatch: client=${clientMetadata.contentHash.substring(0, 8)}..., server
|
|
8772
|
+
`Content hash mismatch: client=${clientMetadata.contentHash.substring(0, 8)}..., server=${computedHash.substring(0, 8)}...`
|
|
8895
8773
|
);
|
|
8896
8774
|
} else {
|
|
8897
8775
|
errors.push("Content hash mismatch - possible tampering or encoding difference");
|
|
8898
8776
|
}
|
|
8899
|
-
} else if (matchesV1 && !matchesV2) {
|
|
8900
|
-
warnings.push(
|
|
8901
|
-
"Client contentHash matches legacy v1 canonicalization. Prefer authoritative.contentHashV2 for new storage."
|
|
8902
|
-
);
|
|
8903
8777
|
}
|
|
8904
8778
|
const tokenFields = [
|
|
8905
8779
|
"description",
|
|
@@ -8980,11 +8854,7 @@ async function validateClientMetadata(clientMetadata, parseResult, options = {})
|
|
|
8980
8854
|
};
|
|
8981
8855
|
}
|
|
8982
8856
|
async function computeContentHash(card) {
|
|
8983
|
-
const content =
|
|
8984
|
-
return sha256Hash(content);
|
|
8985
|
-
}
|
|
8986
|
-
async function computeContentHashV2(card) {
|
|
8987
|
-
const content = getCanonicalContentV2(card);
|
|
8857
|
+
const content = getCanonicalContent(card);
|
|
8988
8858
|
return sha256Hash(content);
|
|
8989
8859
|
}
|
|
8990
8860
|
function validateClientMetadataSync(clientMetadata, parseResult, options) {
|
|
@@ -9000,18 +8870,15 @@ function validateClientMetadataSync(clientMetadata, parseResult, options) {
|
|
|
9000
8870
|
const warnings = [];
|
|
9001
8871
|
const errors = [];
|
|
9002
8872
|
const computedTokens = countTokens(card);
|
|
9003
|
-
const
|
|
9004
|
-
const
|
|
9005
|
-
const computedHashV1 = computeHash(canonicalContentV1);
|
|
9006
|
-
const computedHashV2 = computeHash(canonicalContentV2);
|
|
8873
|
+
const canonicalContent = getCanonicalContent(card);
|
|
8874
|
+
const computedHash = computeHash(canonicalContent);
|
|
9007
8875
|
const entries = card.data.character_book?.entries || [];
|
|
9008
8876
|
const computedHasLorebook = entries.length > 0;
|
|
9009
8877
|
const computedLorebookCount = entries.length;
|
|
9010
8878
|
const authoritative = {
|
|
9011
8879
|
name: card.data.name,
|
|
9012
8880
|
tokens: computedTokens,
|
|
9013
|
-
contentHash:
|
|
9014
|
-
contentHashV2: computedHashV2,
|
|
8881
|
+
contentHash: computedHash,
|
|
9015
8882
|
hasLorebook: computedHasLorebook,
|
|
9016
8883
|
lorebookEntriesCount: computedLorebookCount
|
|
9017
8884
|
};
|
|
@@ -9023,13 +8890,11 @@ function validateClientMetadataSync(clientMetadata, parseResult, options) {
|
|
|
9023
8890
|
withinTolerance: false
|
|
9024
8891
|
});
|
|
9025
8892
|
}
|
|
9026
|
-
|
|
9027
|
-
const matchesV2 = clientMetadata.contentHash === computedHashV2;
|
|
9028
|
-
if (!matchesV1 && !matchesV2) {
|
|
8893
|
+
if (clientMetadata.contentHash !== computedHash) {
|
|
9029
8894
|
discrepancies.push({
|
|
9030
8895
|
field: "contentHash",
|
|
9031
8896
|
clientValue: clientMetadata.contentHash,
|
|
9032
|
-
computedValue:
|
|
8897
|
+
computedValue: computedHash,
|
|
9033
8898
|
withinTolerance: false
|
|
9034
8899
|
});
|
|
9035
8900
|
if (allowHashMismatch) {
|
|
@@ -9037,10 +8902,6 @@ function validateClientMetadataSync(clientMetadata, parseResult, options) {
|
|
|
9037
8902
|
} else {
|
|
9038
8903
|
errors.push("Content hash mismatch");
|
|
9039
8904
|
}
|
|
9040
|
-
} else if (matchesV1 && !matchesV2) {
|
|
9041
|
-
warnings.push(
|
|
9042
|
-
"Client contentHash matches legacy v1 canonicalization. Prefer authoritative.contentHashV2 for new storage."
|
|
9043
|
-
);
|
|
9044
8905
|
}
|
|
9045
8906
|
const tokenFields = [
|
|
9046
8907
|
"description",
|
|
@@ -9109,7 +8970,6 @@ function validateClientMetadataSync(clientMetadata, parseResult, options) {
|
|
|
9109
8970
|
}
|
|
9110
8971
|
export {
|
|
9111
8972
|
computeContentHash,
|
|
9112
|
-
computeContentHashV2,
|
|
9113
8973
|
detectFormat,
|
|
9114
8974
|
getContainerFormat,
|
|
9115
8975
|
mightBeCard,
|