@arisutalk/character-spec 0.0.4 → 0.0.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 (36) hide show
  1. package/dist/index.d.ts +4 -4
  2. package/dist/v0/Character/Assets.d.ts +30 -17
  3. package/dist/v0/Character/Assets.js +8 -4
  4. package/dist/v0/Character/Assets.js.map +1 -1
  5. package/dist/v0/Character/Character.d.ts +74 -63
  6. package/dist/v0/Character/Character.js +11 -10
  7. package/dist/v0/Character/Character.js.map +1 -1
  8. package/dist/v0/Character/Chat.d.ts +11 -4
  9. package/dist/v0/Character/Chat.js +1 -1
  10. package/dist/v0/Character/Chat.js.map +1 -1
  11. package/dist/v0/Character/Lorebook.d.ts +32 -25
  12. package/dist/v0/Character/Lorebook.js +14 -14
  13. package/dist/v0/Character/Lorebook.js.map +1 -1
  14. package/dist/v0/Character/Message.d.ts +23 -11
  15. package/dist/v0/Character/Message.js +8 -8
  16. package/dist/v0/Character/Message.js.map +1 -1
  17. package/dist/v0/Character/Meta.d.ts +19 -0
  18. package/dist/v0/Character/index.d.ts +2 -1
  19. package/dist/v0/Character.d.ts +2 -6
  20. package/dist/v0/Character.js +5 -3
  21. package/dist/v0/Character.js.map +1 -1
  22. package/dist/v0/Executables/Executable.d.ts +13 -8
  23. package/dist/v0/Executables/Executable.js +11 -8
  24. package/dist/v0/Executables/Executable.js.map +1 -1
  25. package/dist/v0/Executables/ReplaceHook.d.ts +66 -57
  26. package/dist/v0/Executables/ReplaceHook.js +10 -10
  27. package/dist/v0/Executables/ReplaceHook.js.map +1 -1
  28. package/dist/v0/Executables/index.d.ts +1 -1
  29. package/dist/v0/Executables.d.ts +2 -3
  30. package/dist/v0/index.d.ts +3 -1
  31. package/dist/v0/utils.d.ts +31 -6
  32. package/dist/v0/utils.js +21 -8
  33. package/dist/v0/utils.js.map +1 -1
  34. package/dist/v0.d.ts +1 -1
  35. package/dist/v0.js +5 -3
  36. package/package.json +7 -3
package/dist/index.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- // Auto-generated TypeScript types from Zod schemas
2
- import type { z } from "zod";
1
+ // Auto-generated entry declarations. DO NOT EDIT.
2
+ import type { ZodType } from "zod";
3
3
  import type { Character as CharacterV0 } from "./v0/Character/Character";
4
4
  export { CharacterV0 };
5
5
  export { CharacterSchema as CharacterV0Schema } from "./v0/Character/Character";
6
6
 
7
7
  export declare const characterMap: {
8
- readonly 0: z.ZodType<CharacterV0>;
8
+ readonly 0: ZodType<CharacterV0>;
9
9
  };
10
10
 
11
11
  export type CharacterMap = {
12
- "0": CharacterV0;
12
+ readonly "0": CharacterV0;
13
13
  };
14
14
 
15
15
  export default characterMap;
@@ -1,28 +1,41 @@
1
- // Auto-generated TypeScript types from Zod schemas
2
- // JSDoc comments are extracted from schema .meta({ description }) values
3
- import type { z } from "zod";
1
+ // Auto-generated TypeScript declarations from Zod schemas. DO NOT EDIT.
2
+ // Regenerate with: pnpm generate-types
4
3
 
4
+ import type { ZodType } from "zod";
5
+
6
+ /**
7
+ * An asset entity. Represents single asset, via either URL or binary data.
8
+ */
9
+ export type AssetEntity = {
10
+ /** MIME type of the asset. Usually `image/*` or `video/*`. */
11
+ mimeType: string;
12
+ /** The name of the asset. Used as the file name. Should be unique. */
13
+ name: string;
14
+ /** The data of the asset. */
15
+ data: string | Uint8Array;
16
+ };
17
+
18
+ /**
19
+ * An asset entity. Represents single asset, via either URL or binary data.
20
+ */
21
+ export declare const AssetEntitySchema: ZodType<AssetEntity>;
22
+
23
+ /**
24
+ * Settings for character assets.
25
+ */
5
26
  export type AssetsSetting = {
6
27
  /** The assets of the character. */
7
28
  assets: {
8
- /** The URL of the asset. */
9
- url: string;
10
29
  /** MIME type of the asset. Usually `image/*` or `video/*`. */
11
30
  mimeType: string;
12
31
  /** The name of the asset. Used as the file name. Should be unique. */
13
32
  name: string;
33
+ /** The data of the asset. */
34
+ data: string | Uint8Array;
14
35
  }[];
15
36
  };
16
37
 
17
- export declare const AssetsSettingSchema: z.ZodType<AssetsSetting>;
18
-
19
- export type AssetEntity = {
20
- /** The URL of the asset. */
21
- url: string;
22
- /** MIME type of the asset. Usually `image/*` or `video/*`. */
23
- mimeType: string;
24
- /** The name of the asset. Used as the file name. Should be unique. */
25
- name: string;
26
- };
27
-
28
- export declare const AssetEntitySchema: z.ZodType<AssetEntity>;
38
+ /**
39
+ * Settings for character assets.
40
+ */
41
+ export declare const AssetsSettingSchema: ZodType<AssetsSetting>;
@@ -1,18 +1,22 @@
1
1
  import { z as e } from "zod";
2
- import { ImageURLSchema as t, unique as s } from "../utils.js";
2
+ import { FileSchema as t, unique as s } from "../utils.js";
3
3
  const a = e.object({
4
- url: t.meta({ description: "The URL of the asset." }),
5
4
  mimeType: e.string().meta({
6
5
  description: "MIME type of the asset. Usually `image/*` or `video/*`."
7
6
  }),
8
7
  name: e.string().meta({
9
8
  description: "The name of the asset. Used as the file name. Should be unique."
9
+ }),
10
+ data: t.meta({
11
+ description: "The data of the asset."
10
12
  })
11
- }), m = e.object({
13
+ }).meta({
14
+ description: "An asset entity. Represents single asset, via either URL or binary data."
15
+ }), r = e.object({
12
16
  assets: e.array(a).refine(s("name"), { message: "Not unique key: name" }).meta({ description: "The assets of the character." })
13
17
  }).meta({ description: "Settings for character assets." });
14
18
  export {
15
19
  a as AssetEntitySchema,
16
- m as AssetsSettingSchema
20
+ r as AssetsSettingSchema
17
21
  };
18
22
  //# sourceMappingURL=Assets.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Assets.js","sources":["../../../src/types/v0/Character/Assets.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { ImageURLSchema, unique } from \"@/types/v0/utils\";\n\nexport const AssetEntitySchema = z.object({\n url: ImageURLSchema.meta({ description: \"The URL of the asset.\" }),\n mimeType: z.string().meta({\n description: \"MIME type of the asset. Usually `image/*` or `video/*`.\",\n }),\n name: z.string().meta({\n description:\n \"The name of the asset. Used as the file name. Should be unique.\",\n }),\n});\n\n/**\n * @see {@link AssetsSetting}\n */\nexport const AssetsSettingSchema = z\n .object({\n assets: z\n .array(AssetEntitySchema)\n .refine(unique(\"name\"), { message: \"Not unique key: name\" })\n .meta({ description: \"The assets of the character.\" }),\n })\n .meta({ description: \"Settings for character assets.\" });\n\n/**\n * This is the settings for character assets.\n */\nexport type AssetsSetting = z.infer<typeof AssetsSettingSchema>;\n"],"names":["AssetEntitySchema","z","ImageURLSchema","AssetsSettingSchema","unique"],"mappings":";;AAGO,MAAMA,IAAoBC,EAAE,OAAO;AAAA,EACtC,KAAKC,EAAe,KAAK,EAAE,aAAa,yBAAyB;AAAA,EACjE,UAAUD,EAAE,OAAA,EAAS,KAAK;AAAA,IACtB,aAAa;AAAA,EAAA,CAChB;AAAA,EACD,MAAMA,EAAE,OAAA,EAAS,KAAK;AAAA,IAClB,aACI;AAAA,EAAA,CACP;AACL,CAAC,GAKYE,IAAsBF,EAC9B,OAAO;AAAA,EACJ,QAAQA,EACH,MAAMD,CAAiB,EACvB,OAAOI,EAAO,MAAM,GAAG,EAAE,SAAS,wBAAwB,EAC1D,KAAK,EAAE,aAAa,gCAAgC;AAC7D,CAAC,EACA,KAAK,EAAE,aAAa,kCAAkC;"}
1
+ {"version":3,"file":"Assets.js","sources":["../../../src/types/v0/Character/Assets.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { FileSchema, unique } from \"@/types/v0/utils\";\n\nexport const AssetEntitySchema = z\n .object({\n mimeType: z.string().meta({\n description:\n \"MIME type of the asset. Usually `image/*` or `video/*`.\",\n }),\n name: z.string().meta({\n description:\n \"The name of the asset. Used as the file name. Should be unique.\",\n }),\n data: FileSchema.meta({\n description: \"The data of the asset.\",\n }),\n })\n .meta({\n description:\n \"An asset entity. Represents single asset, via either URL or binary data.\",\n });\n\n/**\n * @see {@link AssetsSetting}\n */\nexport const AssetsSettingSchema = z\n .object({\n assets: z\n .array(AssetEntitySchema)\n .refine(unique(\"name\"), { message: \"Not unique key: name\" })\n .meta({ description: \"The assets of the character.\" }),\n })\n .meta({ description: \"Settings for character assets.\" });\n\n/**\n * This is the settings for character assets.\n */\nexport type AssetsSetting = z.infer<typeof AssetsSettingSchema>;\n"],"names":["AssetEntitySchema","z","FileSchema","AssetsSettingSchema","unique"],"mappings":";;AAGO,MAAMA,IAAoBC,EAC5B,OAAO;AAAA,EACJ,UAAUA,EAAE,OAAA,EAAS,KAAK;AAAA,IACtB,aACI;AAAA,EAAA,CACP;AAAA,EACD,MAAMA,EAAE,OAAA,EAAS,KAAK;AAAA,IAClB,aACI;AAAA,EAAA,CACP;AAAA,EACD,MAAMC,EAAW,KAAK;AAAA,IAClB,aAAa;AAAA,EAAA,CAChB;AACL,CAAC,EACA,KAAK;AAAA,EACF,aACI;AACR,CAAC,GAKQC,IAAsBF,EAC9B,OAAO;AAAA,EACJ,QAAQA,EACH,MAAMD,CAAiB,EACvB,OAAOI,EAAO,MAAM,GAAG,EAAE,SAAS,wBAAwB,EAC1D,KAAK,EAAE,aAAa,gCAAgC;AAC7D,CAAC,EACA,KAAK,EAAE,aAAa,kCAAkC;"}
@@ -1,7 +1,66 @@
1
- // Auto-generated TypeScript types from Zod schemas
2
- // JSDoc comments are extracted from schema .meta({ description }) values
3
- import type { z } from "zod";
1
+ // Auto-generated TypeScript declarations from Zod schemas. DO NOT EDIT.
2
+ // Regenerate with: pnpm generate-types
4
3
 
4
+ import type { ZodType } from "zod";
5
+
6
+ /**
7
+ * The prompt data for a character. Used to generate the character's persona. All parameters are for AI prompt and scriptable.
8
+ */
9
+ export type CharacterPromptData = {
10
+ /** The character description. */
11
+ description: string;
12
+ /** The authors note. It's usually used to mock the user's message (differ by prompt). */
13
+ authorsNote?: string | undefined;
14
+ /** Global lorebook data */
15
+ lorebook: {
16
+ /** The configuration for the lorebook. Not scriptable. */
17
+ config: {
18
+ /** The token limit for the lorebook. When exceeded, low-priority lorebooks will be deactivated. Positive integer. */
19
+ tokenLimit?: number | undefined;
20
+ };
21
+ /** Contains the actual lorebooks. Duplicated id is not allowed. */
22
+ data: {
23
+ /** Internally generated ID. */
24
+ id: string;
25
+ /** Human readable name for the lorebook. */
26
+ name: string;
27
+ /** The condition for the lorebook to be activated. If empty, it will not be activated. Use 'always' to activate without any condition. */
28
+ condition: ({
29
+ /** This condition matches the regex pattern. */
30
+ type: "regex_match";
31
+ /** The regex pattern to match. Scriptable. */
32
+ regexPattern: string;
33
+ /** The regex flags to use. Not scriptable. */
34
+ regexFlags?: string | undefined;
35
+ } | {
36
+ /** This condition simply matches the text. */
37
+ type: "plain_text_match";
38
+ /** The text to match. Scriptable. Case insensitive. */
39
+ text: string;
40
+ } | {
41
+ /** This condition is always true. */
42
+ type: "always";
43
+ })[];
44
+ /** The strategy for resolving multiple conditions. 'all' means all must be met, 'any' means at least one. */
45
+ multipleConditionResolveStrategy?: ("all" | "any") | undefined;
46
+ /** The lorebook content to be added on AI prompt. Not for human reading. Scriptable. */
47
+ content: string;
48
+ /** The priority of the lorebook. Higher priority means it will be activated first. May be negative or decimal. Base is 0. */
49
+ priority?: number | undefined;
50
+ /** Whether the lorebook is enabled. */
51
+ enabled?: boolean | undefined;
52
+ }[];
53
+ };
54
+ };
55
+
56
+ /**
57
+ * The prompt data for a character. Used to generate the character's persona. All parameters are for AI prompt and scriptable.
58
+ */
59
+ export declare const CharacterPromptDataSchema: ZodType<CharacterPromptData>;
60
+
61
+ /**
62
+ * Represents a specific AI character personality.
63
+ */
5
64
  export type Character = {
6
65
  /** The version of the character spec. Used to determine which schema to use for parsing and migration. */
7
66
  specVersion: 0;
@@ -11,20 +70,20 @@ export type Character = {
11
70
  name: string;
12
71
  /** A short description of the character. Human readable, not scriptable. */
13
72
  description: string;
14
- /** Optional URL for the character's avatar image. */
73
+ /** Optional name of asset for the character's avatar image. */
15
74
  avatarUrl?: string | undefined;
16
75
  /** The prompt data for the character. */
17
76
  prompt: {
18
77
  /** The character description. */
19
78
  description: string;
20
79
  /** The authors note. It's usually used to mock the user's message (differ by prompt). */
21
- authorsNote: string;
22
- /** Lorebook data. */
80
+ authorsNote?: string | undefined;
81
+ /** Global lorebook data */
23
82
  lorebook: {
24
83
  /** The configuration for the lorebook. Not scriptable. */
25
84
  config: {
26
85
  /** The token limit for the lorebook. When exceeded, low-priority lorebooks will be deactivated. Positive integer. */
27
- tokenLimit: number;
86
+ tokenLimit?: number | undefined;
28
87
  };
29
88
  /** Contains the actual lorebooks. Duplicated id is not allowed. */
30
89
  data: {
@@ -66,10 +125,11 @@ export type Character = {
66
125
  runtimeSetting: {
67
126
  /** The maximum memory usage of the script, in MB. Not an exact limit. May be exceeded or ignored. */
68
127
  mem?: number | undefined;
128
+ /** The maximum execution time of the script, in seconds. Not an exact limit. May be exceeded or ignored. It is used per call, not a total limit. Default is 3 seconds. */
129
+ timeout: number;
69
130
  };
70
131
  /** Replace hooks for the script. */
71
132
  replaceHooks: {
72
- /** Replace hooks for display. Doesn't edit the data, only changes the display. */
73
133
  display: {
74
134
  /** The input pattern. May contain additional javascript expression if `isInputPatternScripted` is true. */
75
135
  input: string;
@@ -95,7 +155,6 @@ export type Character = {
95
155
  /** The output. May contain additional javascript expression if `isOutputScripted` is true. */
96
156
  output: string;
97
157
  }[];
98
- /** Replace hooks for input. User chat input will be edited by this. */
99
158
  input: {
100
159
  /** The input pattern. May contain additional javascript expression if `isInputPatternScripted` is true. */
101
160
  input: string;
@@ -121,7 +180,6 @@ export type Character = {
121
180
  /** The output. May contain additional javascript expression if `isOutputScripted` is true. */
122
181
  output: string;
123
182
  }[];
124
- /** Replace hooks for output. Character response will be edited by this. */
125
183
  output: {
126
184
  /** The input pattern. May contain additional javascript expression if `isInputPatternScripted` is true. */
127
185
  input: string;
@@ -147,7 +205,6 @@ export type Character = {
147
205
  /** The output. May contain additional javascript expression if `isOutputScripted` is true. */
148
206
  output: string;
149
207
  }[];
150
- /** Replace hooks for request. AI request will be edited by this. Differs from `input` in that it's for AI request. Does not edit the data, only changes the fetching request. */
151
208
  request: {
152
209
  /** The input pattern. May contain additional javascript expression if `isInputPatternScripted` is true. */
153
210
  input: string;
@@ -192,63 +249,17 @@ export type Character = {
192
249
  assets: {
193
250
  /** The assets of the character. */
194
251
  assets: {
195
- /** The URL of the asset. */
196
- url: string;
197
252
  /** MIME type of the asset. Usually `image/*` or `video/*`. */
198
253
  mimeType: string;
199
254
  /** The name of the asset. Used as the file name. Should be unique. */
200
255
  name: string;
256
+ /** The data of the asset. */
257
+ data: string | Uint8Array;
201
258
  }[];
202
259
  };
203
260
  };
204
261
 
205
- export declare const CharacterSchema: z.ZodType<Character>;
206
-
207
- export type CharacterPromptData = {
208
- /** The character description. */
209
- description: string;
210
- /** The authors note. It's usually used to mock the user's message (differ by prompt). */
211
- authorsNote: string;
212
- /** Lorebook data. */
213
- lorebook: {
214
- /** The configuration for the lorebook. Not scriptable. */
215
- config: {
216
- /** The token limit for the lorebook. When exceeded, low-priority lorebooks will be deactivated. Positive integer. */
217
- tokenLimit: number;
218
- };
219
- /** Contains the actual lorebooks. Duplicated id is not allowed. */
220
- data: {
221
- /** Internally generated ID. */
222
- id: string;
223
- /** Human readable name for the lorebook. */
224
- name: string;
225
- /** The condition for the lorebook to be activated. If empty, it will not be activated. Use 'always' to activate without any condition. */
226
- condition: ({
227
- /** This condition matches the regex pattern. */
228
- type: "regex_match";
229
- /** The regex pattern to match. Scriptable. */
230
- regexPattern: string;
231
- /** The regex flags to use. Not scriptable. */
232
- regexFlags?: string | undefined;
233
- } | {
234
- /** This condition simply matches the text. */
235
- type: "plain_text_match";
236
- /** The text to match. Scriptable. Case insensitive. */
237
- text: string;
238
- } | {
239
- /** This condition is always true. */
240
- type: "always";
241
- })[];
242
- /** The strategy for resolving multiple conditions. 'all' means all must be met, 'any' means at least one. */
243
- multipleConditionResolveStrategy?: ("all" | "any") | undefined;
244
- /** The lorebook content to be added on AI prompt. Not for human reading. Scriptable. */
245
- content: string;
246
- /** The priority of the lorebook. Higher priority means it will be activated first. May be negative or decimal. Base is 0. */
247
- priority?: number | undefined;
248
- /** Whether the lorebook is enabled. */
249
- enabled?: boolean | undefined;
250
- }[];
251
- };
252
- };
253
-
254
- export declare const CharacterPromptDataSchema: z.ZodType<CharacterPromptData>;
262
+ /**
263
+ * Represents a specific AI character personality.
264
+ */
265
+ export declare const CharacterSchema: ZodType<Character>;
@@ -3,16 +3,17 @@ import { AssetsSettingSchema as t } from "./Assets.js";
3
3
  import { LorebookDataSchema as a } from "./Lorebook.js";
4
4
  import { MetaSchema as r } from "./Meta.js";
5
5
  import { ScriptSettingSchema as o } from "../Executables/Executable.js";
6
- import { ImageURLSchema as i } from "../utils.js";
7
- const c = e.object({
6
+ const i = e.object({
8
7
  description: e.string().meta({ description: "The character description." }),
9
- authorsNote: e.string().meta({
8
+ authorsNote: e.string().optional().meta({
10
9
  description: "The authors note. It's usually used to mock the user's message (differ by prompt)."
11
10
  }),
12
- lorebook: a.meta({ description: "Lorebook data." })
11
+ lorebook: a.meta({
12
+ description: "Global lorebook data"
13
+ })
13
14
  }).meta({
14
15
  description: "The prompt data for a character. Used to generate the character's persona. All parameters are for AI prompt and scriptable."
15
- }), f = e.object({
16
+ }), h = e.object({
16
17
  specVersion: e.literal(0).meta({
17
18
  description: "The version of the character spec. Used to determine which schema to use for parsing and migration."
18
19
  }),
@@ -23,10 +24,10 @@ const c = e.object({
23
24
  description: e.string().meta({
24
25
  description: "A short description of the character. Human readable, not scriptable."
25
26
  }),
26
- avatarUrl: i.optional().meta({
27
- description: "Optional URL for the character's avatar image."
27
+ avatarUrl: e.string().optional().meta({
28
+ description: "Optional name of asset for the character's avatar image."
28
29
  }),
29
- prompt: c.meta({
30
+ prompt: i.meta({
30
31
  description: "The prompt data for the character."
31
32
  }),
32
33
  executables: o.meta({
@@ -40,7 +41,7 @@ const c = e.object({
40
41
  })
41
42
  }).meta({ description: "Represents a specific AI character personality." });
42
43
  export {
43
- c as CharacterPromptDataSchema,
44
- f as CharacterSchema
44
+ i as CharacterPromptDataSchema,
45
+ h as CharacterSchema
45
46
  };
46
47
  //# sourceMappingURL=Character.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Character.js","sources":["../../../src/types/v0/Character/Character.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AssetsSettingSchema } from \"@/types/v0/Character/Assets\";\nimport { LorebookDataSchema } from \"@/types/v0/Character/Lorebook\";\nimport { MetaSchema } from \"@/types/v0/Character/Meta\";\nimport { ScriptSettingSchema as ExecutableSettingSchema } from \"@/types/v0/Executables/Executable\";\nimport { ImageURLSchema } from \"@/types/v0/utils\";\n\n/**\n * The prompt data for a character.\n * It is used to generate the character's persona.\n * All of parameters are for AI prompt, and scriptable.\n */\nexport type CharacterPromptData = z.infer<typeof CharacterPromptDataSchema>;\n\nexport const CharacterPromptDataSchema = z\n .object({\n description: z\n .string()\n .meta({ description: \"The character description.\" }),\n authorsNote: z.string().meta({\n description:\n \"The authors note. It's usually used to mock the user's message (differ by prompt).\",\n }),\n lorebook: LorebookDataSchema.meta({ description: \"Lorebook data.\" }),\n })\n .meta({\n description:\n \"The prompt data for a character. Used to generate the character's persona. All parameters are for AI prompt and scriptable.\",\n });\n\nexport const CharacterSchema = z\n .object({\n specVersion: z.literal(0).meta({\n description:\n \"The version of the character spec. Used to determine which schema to use for parsing and migration.\",\n }),\n id: z\n .string()\n .meta({ description: \"Unique identifier for the character.\" }),\n name: z.string().meta({\n description:\n \"The display name of the character. Human readable, not scriptable.\",\n }),\n description: z.string().meta({\n description:\n \"A short description of the character. Human readable, not scriptable.\",\n }),\n avatarUrl: ImageURLSchema.optional().meta({\n description: \"Optional URL for the character's avatar image.\",\n }),\n prompt: CharacterPromptDataSchema.meta({\n description: \"The prompt data for the character.\",\n }),\n executables: ExecutableSettingSchema.meta({\n description:\n \"Script and hooks which can be used to control the character's behavior.\",\n }),\n metadata: MetaSchema.meta({\n description:\n \"Additional metadata about the character. Not used by the system, but can be used by the user.\",\n }),\n assets: AssetsSettingSchema.meta({\n description: \"Assets for the character.\",\n }),\n })\n .meta({ description: \"Represents a specific AI character personality.\" });\n\n/**\n * Represents a specific AI character personality.\n */\nexport type Character = z.infer<typeof CharacterSchema>;\n"],"names":["CharacterPromptDataSchema","z","LorebookDataSchema","CharacterSchema","ImageURLSchema","ExecutableSettingSchema","MetaSchema","AssetsSettingSchema"],"mappings":";;;;;;AAcO,MAAMA,IAA4BC,EACpC,OAAO;AAAA,EACJ,aAAaA,EACR,OAAA,EACA,KAAK,EAAE,aAAa,8BAA8B;AAAA,EACvD,aAAaA,EAAE,OAAA,EAAS,KAAK;AAAA,IACzB,aACI;AAAA,EAAA,CACP;AAAA,EACD,UAAUC,EAAmB,KAAK,EAAE,aAAa,kBAAkB;AACvE,CAAC,EACA,KAAK;AAAA,EACF,aACI;AACR,CAAC,GAEQC,IAAkBF,EAC1B,OAAO;AAAA,EACJ,aAAaA,EAAE,QAAQ,CAAC,EAAE,KAAK;AAAA,IAC3B,aACI;AAAA,EAAA,CACP;AAAA,EACD,IAAIA,EACC,OAAA,EACA,KAAK,EAAE,aAAa,wCAAwC;AAAA,EACjE,MAAMA,EAAE,OAAA,EAAS,KAAK;AAAA,IAClB,aACI;AAAA,EAAA,CACP;AAAA,EACD,aAAaA,EAAE,OAAA,EAAS,KAAK;AAAA,IACzB,aACI;AAAA,EAAA,CACP;AAAA,EACD,WAAWG,EAAe,SAAA,EAAW,KAAK;AAAA,IACtC,aAAa;AAAA,EAAA,CAChB;AAAA,EACD,QAAQJ,EAA0B,KAAK;AAAA,IACnC,aAAa;AAAA,EAAA,CAChB;AAAA,EACD,aAAaK,EAAwB,KAAK;AAAA,IACtC,aACI;AAAA,EAAA,CACP;AAAA,EACD,UAAUC,EAAW,KAAK;AAAA,IACtB,aACI;AAAA,EAAA,CACP;AAAA,EACD,QAAQC,EAAoB,KAAK;AAAA,IAC7B,aAAa;AAAA,EAAA,CAChB;AACL,CAAC,EACA,KAAK,EAAE,aAAa,mDAAmD;"}
1
+ {"version":3,"file":"Character.js","sources":["../../../src/types/v0/Character/Character.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AssetsSettingSchema } from \"@/types/v0/Character/Assets\";\nimport { LorebookDataSchema } from \"@/types/v0/Character/Lorebook\";\nimport { MetaSchema } from \"@/types/v0/Character/Meta\";\nimport { ScriptSettingSchema as ExecutableSettingSchema } from \"@/types/v0/Executables/Executable\";\n\n/**\n * The prompt data for a character.\n * It is used to generate the character's persona.\n * All of parameters are for AI prompt, and scriptable.\n */\nexport type CharacterPromptData = z.infer<typeof CharacterPromptDataSchema>;\n\nexport const CharacterPromptDataSchema = z\n .object({\n description: z\n .string()\n .meta({ description: \"The character description.\" }),\n authorsNote: z.string().optional().meta({\n description:\n \"The authors note. It's usually used to mock the user's message (differ by prompt).\",\n }),\n lorebook: LorebookDataSchema.meta({\n description: \"Global lorebook data\",\n }),\n })\n .meta({\n description:\n \"The prompt data for a character. Used to generate the character's persona. All parameters are for AI prompt and scriptable.\",\n });\n\nexport const CharacterSchema = z\n .object({\n specVersion: z.literal(0).meta({\n description:\n \"The version of the character spec. Used to determine which schema to use for parsing and migration.\",\n }),\n id: z\n .string()\n .meta({ description: \"Unique identifier for the character.\" }),\n name: z.string().meta({\n description:\n \"The display name of the character. Human readable, not scriptable.\",\n }),\n description: z.string().meta({\n description:\n \"A short description of the character. Human readable, not scriptable.\",\n }),\n avatarUrl: z.string().optional().meta({\n description:\n \"Optional name of asset for the character's avatar image.\",\n }),\n prompt: CharacterPromptDataSchema.meta({\n description: \"The prompt data for the character.\",\n }),\n executables: ExecutableSettingSchema.meta({\n description:\n \"Script and hooks which can be used to control the character's behavior.\",\n }),\n metadata: MetaSchema.meta({\n description:\n \"Additional metadata about the character. Not used by the system, but can be used by the user.\",\n }),\n assets: AssetsSettingSchema.meta({\n description: \"Assets for the character.\",\n }),\n })\n .meta({ description: \"Represents a specific AI character personality.\" });\n\n/**\n * Represents a specific AI character personality.\n */\nexport type Character = z.infer<typeof CharacterSchema>;\n"],"names":["CharacterPromptDataSchema","z","LorebookDataSchema","CharacterSchema","ExecutableSettingSchema","MetaSchema","AssetsSettingSchema"],"mappings":";;;;;AAaO,MAAMA,IAA4BC,EACpC,OAAO;AAAA,EACJ,aAAaA,EACR,OAAA,EACA,KAAK,EAAE,aAAa,8BAA8B;AAAA,EACvD,aAAaA,EAAE,OAAA,EAAS,SAAA,EAAW,KAAK;AAAA,IACpC,aACI;AAAA,EAAA,CACP;AAAA,EACD,UAAUC,EAAmB,KAAK;AAAA,IAC9B,aAAa;AAAA,EAAA,CAChB;AACL,CAAC,EACA,KAAK;AAAA,EACF,aACI;AACR,CAAC,GAEQC,IAAkBF,EAC1B,OAAO;AAAA,EACJ,aAAaA,EAAE,QAAQ,CAAC,EAAE,KAAK;AAAA,IAC3B,aACI;AAAA,EAAA,CACP;AAAA,EACD,IAAIA,EACC,OAAA,EACA,KAAK,EAAE,aAAa,wCAAwC;AAAA,EACjE,MAAMA,EAAE,OAAA,EAAS,KAAK;AAAA,IAClB,aACI;AAAA,EAAA,CACP;AAAA,EACD,aAAaA,EAAE,OAAA,EAAS,KAAK;AAAA,IACzB,aACI;AAAA,EAAA,CACP;AAAA,EACD,WAAWA,EAAE,OAAA,EAAS,SAAA,EAAW,KAAK;AAAA,IAClC,aACI;AAAA,EAAA,CACP;AAAA,EACD,QAAQD,EAA0B,KAAK;AAAA,IACnC,aAAa;AAAA,EAAA,CAChB;AAAA,EACD,aAAaI,EAAwB,KAAK;AAAA,IACtC,aACI;AAAA,EAAA,CACP;AAAA,EACD,UAAUC,EAAW,KAAK;AAAA,IACtB,aACI;AAAA,EAAA,CACP;AAAA,EACD,QAAQC,EAAoB,KAAK;AAAA,IAC7B,aAAa;AAAA,EAAA,CAChB;AACL,CAAC,EACA,KAAK,EAAE,aAAa,mDAAmD;"}
@@ -1,7 +1,11 @@
1
- // Auto-generated TypeScript types from Zod schemas
2
- // JSDoc comments are extracted from schema .meta({ description }) values
3
- import type { z } from "zod";
1
+ // Auto-generated TypeScript declarations from Zod schemas. DO NOT EDIT.
2
+ // Regenerate with: pnpm generate-types
4
3
 
4
+ import type { ZodType } from "zod";
5
+
6
+ /**
7
+ * Represents a chat session with a character.
8
+ */
5
9
  export type Chat = {
6
10
  /** Unique identifier for the chat session. */
7
11
  id: string;
@@ -47,4 +51,7 @@ export type Chat = {
47
51
  }[] | undefined;
48
52
  };
49
53
 
50
- export declare const ChatSchema: z.ZodType<Chat>;
54
+ /**
55
+ * Represents a chat session with a character.
56
+ */
57
+ export declare const ChatSchema: ZodType<Chat>;
@@ -8,7 +8,7 @@ const o = t.object({
8
8
  title: t.string().default("Chat").meta({ description: "Optional title for the chat." }),
9
9
  createdAt: t.number().default(Date.now).meta({ description: "creation timestamp (unix epoch)" }),
10
10
  updatedAt: t.number().default(Date.now).meta({ description: "Last updated timestamp (unix epoch)" }),
11
- lorebook: e.shape.data.optional().meta({ description: "Chat specific lorebook data." })
11
+ lorebook: e.unwrap().shape.data.optional().meta({ description: "Chat specific lorebook data." })
12
12
  }).meta({ description: "Represents a chat session with a character." });
13
13
  export {
14
14
  o as ChatSchema
@@ -1 +1 @@
1
- {"version":3,"file":"Chat.js","sources":["../../../src/types/v0/Character/Chat.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { LorebookDataSchema } from \"@/types/v0/Character/Lorebook\";\n\n/**\n * @see {@link Chat}\n */\nexport const ChatSchema = z\n .object({\n id: z\n .string()\n .meta({ description: \"Unique identifier for the chat session.\" }),\n characterId: z.string().meta({\n description: \"The ID of the character associated with this chat.\",\n }),\n title: z\n .string()\n .default(\"Chat\")\n .meta({ description: \"Optional title for the chat.\" }),\n createdAt: z\n .number()\n .default(Date.now)\n .meta({ description: \"creation timestamp (unix epoch)\" }),\n updatedAt: z\n .number()\n .default(Date.now)\n .meta({ description: \"Last updated timestamp (unix epoch)\" }),\n lorebook: LorebookDataSchema.shape.data\n .optional()\n .meta({ description: \"Chat specific lorebook data.\" }),\n })\n .meta({ description: \"Represents a chat session with a character.\" });\n\n/**\n * Represents a chat session with a character.\n */\nexport type Chat = z.infer<typeof ChatSchema>;\n"],"names":["ChatSchema","z","LorebookDataSchema"],"mappings":";;AAMO,MAAMA,IAAaC,EACrB,OAAO;AAAA,EACJ,IAAIA,EACC,OAAA,EACA,KAAK,EAAE,aAAa,2CAA2C;AAAA,EACpE,aAAaA,EAAE,OAAA,EAAS,KAAK;AAAA,IACzB,aAAa;AAAA,EAAA,CAChB;AAAA,EACD,OAAOA,EACF,OAAA,EACA,QAAQ,MAAM,EACd,KAAK,EAAE,aAAa,gCAAgC;AAAA,EACzD,WAAWA,EACN,OAAA,EACA,QAAQ,KAAK,GAAG,EAChB,KAAK,EAAE,aAAa,kCAAA,CAAmC;AAAA,EAC5D,WAAWA,EACN,OAAA,EACA,QAAQ,KAAK,GAAG,EAChB,KAAK,EAAE,aAAa,sCAAA,CAAuC;AAAA,EAChE,UAAUC,EAAmB,MAAM,KAC9B,SAAA,EACA,KAAK,EAAE,aAAa,+BAAA,CAAgC;AAC7D,CAAC,EACA,KAAK,EAAE,aAAa,+CAA+C;"}
1
+ {"version":3,"file":"Chat.js","sources":["../../../src/types/v0/Character/Chat.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { LorebookDataSchema } from \"@/types/v0/Character/Lorebook\";\n\n/**\n * @see {@link Chat}\n */\nexport const ChatSchema = z\n .object({\n id: z\n .string()\n .meta({ description: \"Unique identifier for the chat session.\" }),\n characterId: z.string().meta({\n description: \"The ID of the character associated with this chat.\",\n }),\n title: z\n .string()\n .default(\"Chat\")\n .meta({ description: \"Optional title for the chat.\" }),\n createdAt: z\n .number()\n .default(Date.now)\n .meta({ description: \"creation timestamp (unix epoch)\" }),\n updatedAt: z\n .number()\n .default(Date.now)\n .meta({ description: \"Last updated timestamp (unix epoch)\" }),\n lorebook: LorebookDataSchema.unwrap()\n .shape.data.optional()\n .meta({ description: \"Chat specific lorebook data.\" }),\n })\n .meta({ description: \"Represents a chat session with a character.\" });\n\n/**\n * Represents a chat session with a character.\n */\nexport type Chat = z.infer<typeof ChatSchema>;\n"],"names":["ChatSchema","z","LorebookDataSchema"],"mappings":";;AAMO,MAAMA,IAAaC,EACrB,OAAO;AAAA,EACJ,IAAIA,EACC,OAAA,EACA,KAAK,EAAE,aAAa,2CAA2C;AAAA,EACpE,aAAaA,EAAE,OAAA,EAAS,KAAK;AAAA,IACzB,aAAa;AAAA,EAAA,CAChB;AAAA,EACD,OAAOA,EACF,OAAA,EACA,QAAQ,MAAM,EACd,KAAK,EAAE,aAAa,gCAAgC;AAAA,EACzD,WAAWA,EACN,OAAA,EACA,QAAQ,KAAK,GAAG,EAChB,KAAK,EAAE,aAAa,kCAAA,CAAmC;AAAA,EAC5D,WAAWA,EACN,OAAA,EACA,QAAQ,KAAK,GAAG,EAChB,KAAK,EAAE,aAAa,sCAAA,CAAuC;AAAA,EAChE,UAAUC,EAAmB,OAAA,EACxB,MAAM,KAAK,SAAA,EACX,KAAK,EAAE,aAAa,+BAAA,CAAgC;AAC7D,CAAC,EACA,KAAK,EAAE,aAAa,+CAA+C;"}
@@ -1,12 +1,32 @@
1
- // Auto-generated TypeScript types from Zod schemas
2
- // JSDoc comments are extracted from schema .meta({ description }) values
3
- import type { z } from "zod";
1
+ // Auto-generated TypeScript declarations from Zod schemas. DO NOT EDIT.
2
+ // Regenerate with: pnpm generate-types
3
+
4
+ import type { ZodType } from "zod";
5
+
6
+ export type LorebookCondition = {
7
+ /** This condition matches the regex pattern. */
8
+ type: "regex_match";
9
+ /** The regex pattern to match. Scriptable. */
10
+ regexPattern: string;
11
+ /** The regex flags to use. Not scriptable. */
12
+ regexFlags?: string | undefined;
13
+ } | {
14
+ /** This condition simply matches the text. */
15
+ type: "plain_text_match";
16
+ /** The text to match. Scriptable. Case insensitive. */
17
+ text: string;
18
+ } | {
19
+ /** This condition is always true. */
20
+ type: "always";
21
+ };
22
+
23
+ export declare const LorebookConditionSchema: ZodType<LorebookCondition>;
4
24
 
5
25
  export type LorebookData = {
6
26
  /** The configuration for the lorebook. Not scriptable. */
7
27
  config: {
8
28
  /** The token limit for the lorebook. When exceeded, low-priority lorebooks will be deactivated. Positive integer. */
9
- tokenLimit: number;
29
+ tokenLimit?: number | undefined;
10
30
  };
11
31
  /** Contains the actual lorebooks. Duplicated id is not allowed. */
12
32
  data: {
@@ -42,8 +62,11 @@ export type LorebookData = {
42
62
  }[];
43
63
  };
44
64
 
45
- export declare const LorebookDataSchema: z.ZodType<LorebookData>;
65
+ export declare const LorebookDataSchema: ZodType<LorebookData>;
46
66
 
67
+ /**
68
+ * A lorebook entry. Small part of prompts activated by session's text matching.
69
+ */
47
70
  export type LorebookEntry = {
48
71
  /** Internally generated ID. */
49
72
  id: string;
@@ -76,23 +99,7 @@ export type LorebookEntry = {
76
99
  enabled?: boolean | undefined;
77
100
  };
78
101
 
79
- export declare const LorebookEntrySchema: z.ZodType<LorebookEntry>;
80
-
81
- export type LorebookCondition = {
82
- /** This condition matches the regex pattern. */
83
- type: "regex_match";
84
- /** The regex pattern to match. Scriptable. */
85
- regexPattern: string;
86
- /** The regex flags to use. Not scriptable. */
87
- regexFlags?: string | undefined;
88
- } | {
89
- /** This condition simply matches the text. */
90
- type: "plain_text_match";
91
- /** The text to match. Scriptable. Case insensitive. */
92
- text: string;
93
- } | {
94
- /** This condition is always true. */
95
- type: "always";
96
- };
97
-
98
- export declare const LorebookConditionSchema: z.ZodType<LorebookCondition>;
102
+ /**
103
+ * A lorebook entry. Small part of prompts activated by session's text matching.
104
+ */
105
+ export declare const LorebookEntrySchema: ZodType<LorebookEntry>;
@@ -1,5 +1,5 @@
1
1
  import { z as e } from "zod";
2
- import { unique as o } from "../utils.js";
2
+ import { unique as o, positiveInteger as i } from "../utils.js";
3
3
  const t = {
4
4
  regex: e.object({
5
5
  type: e.literal("regex_match").meta({
@@ -23,14 +23,14 @@ const t = {
23
23
  always: e.object({
24
24
  type: e.literal("always").meta({ description: "This condition is always true." })
25
25
  }).meta({ description: "Always active condition." })
26
- }, i = e.discriminatedUnion("type", [
26
+ }, a = e.discriminatedUnion("type", [
27
27
  t.regex,
28
28
  t.plainText,
29
29
  t.always
30
- ]), a = e.object({
30
+ ]), n = e.object({
31
31
  id: e.string().meta({ description: "Internally generated ID." }),
32
32
  name: e.string().meta({ description: "Human readable name for the lorebook." }),
33
- condition: e.array(i).default([]).meta({
33
+ condition: e.array(a).default([]).meta({
34
34
  description: "The condition for the lorebook to be activated. If empty, it will not be activated. Use 'always' to activate without any condition."
35
35
  }),
36
36
  multipleConditionResolveStrategy: e.enum(["all", "any"]).optional().meta({
@@ -45,24 +45,24 @@ const t = {
45
45
  enabled: e.boolean().optional().meta({ description: "Whether the lorebook is enabled." })
46
46
  }).meta({
47
47
  description: "A lorebook entry. Small part of prompts activated by session's text matching."
48
- }), s = e.object({
48
+ }), l = e.object({
49
49
  config: e.object({
50
- tokenLimit: e.number().int().min(1).meta({
50
+ tokenLimit: i.optional().meta({
51
51
  description: "The token limit for the lorebook. When exceeded, low-priority lorebooks will be deactivated. Positive integer."
52
52
  })
53
- }).meta({
53
+ }).prefault({}).meta({
54
54
  description: "The configuration for the lorebook. Not scriptable."
55
55
  }),
56
- data: e.array(a).refine(o("id"), { message: "Not unique key: id" }).default([]).meta({
56
+ data: e.array(n).refine(o("id"), { message: "Not unique key: id" }).default([]).meta({
57
57
  description: "Contains the actual lorebooks. Duplicated id is not allowed."
58
58
  })
59
59
  }).meta({
60
- description: "Object containing all data for the lorebook. Meant to be stored in the database."
61
- });
60
+ description: "Object containing data for the lorebook. Meant to be stored in the database."
61
+ }).prefault({});
62
62
  export {
63
- t as LorebookConditionDetailSchema,
64
- i as LorebookConditionSchema,
65
- s as LorebookDataSchema,
66
- a as LorebookEntrySchema
63
+ t as LorebookConditionDetails,
64
+ a as LorebookConditionSchema,
65
+ l as LorebookDataSchema,
66
+ n as LorebookEntrySchema
67
67
  };
68
68
  //# sourceMappingURL=Lorebook.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Lorebook.js","sources":["../../../src/types/v0/Character/Lorebook.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { unique } from \"@/types/v0/utils\";\n\n/**\n * @see {@link LorebookConditionSchema}\n */\nexport const LorebookConditionDetailSchema = {\n regex: z\n .object({\n type: z.literal(\"regex_match\").meta({\n description: \"This condition matches the regex pattern.\",\n }),\n regexPattern: z.string().meta({\n description: \"The regex pattern to match. Scriptable.\",\n }),\n regexFlags: z.string().optional().meta({\n description: \"The regex flags to use. Not scriptable.\",\n }),\n })\n .meta({ description: \"Regex match condition.\" }),\n plainText: z\n .object({\n type: z.literal(\"plain_text_match\").meta({\n description: \"This condition simply matches the text.\",\n }),\n text: z.string().meta({\n description: \"The text to match. Scriptable. Case insensitive.\",\n }),\n })\n .meta({ description: \"Plain text match condition.\" }),\n always: z\n .object({\n type: z\n .literal(\"always\")\n .meta({ description: \"This condition is always true.\" }),\n })\n .meta({ description: \"Always active condition.\" }),\n} as const;\n\n/**\n * The condition for the lorebook to be activated.\n */\nexport const LorebookConditionSchema = z.discriminatedUnion(\"type\", [\n LorebookConditionDetailSchema.regex,\n LorebookConditionDetailSchema.plainText,\n LorebookConditionDetailSchema.always,\n]);\n\n/**\n * The condition for the lorebook to be activated.\n * @see {@link LorebookConditionSchema}\n */\nexport type LorebookCondition = z.infer<typeof LorebookConditionSchema>;\n\n/**\n * @see {@link LorebookEntry}\n */\nexport const LorebookEntrySchema = z\n .object({\n id: z.string().meta({ description: \"Internally generated ID.\" }),\n name: z\n .string()\n .meta({ description: \"Human readable name for the lorebook.\" }),\n condition: z.array(LorebookConditionSchema).default([]).meta({\n description:\n \"The condition for the lorebook to be activated. If empty, it will not be activated. Use 'always' to activate without any condition.\",\n }),\n multipleConditionResolveStrategy: z\n .enum([\"all\", \"any\"])\n .optional()\n .meta({\n description:\n \"The strategy for resolving multiple conditions. 'all' means all must be met, 'any' means at least one.\",\n }),\n content: z.string().meta({\n description:\n \"The lorebook content to be added on AI prompt. Not for human reading. Scriptable.\",\n }),\n priority: z.number().optional().meta({\n description:\n \"The priority of the lorebook. Higher priority means it will be activated first. May be negative or decimal. Base is 0.\",\n }),\n enabled: z\n .boolean()\n .optional()\n .meta({ description: \"Whether the lorebook is enabled.\" }),\n })\n .meta({\n description:\n \"A lorebook entry. Small part of prompts activated by session's text matching.\",\n });\n\n/**\n * A lorebook is a collection of lorebooks.\n * Lorebook is a small part of prompts which is activated by session's text matching.\n */\nexport type LorebookEntry = z.infer<typeof LorebookEntrySchema>;\n\n/**\n * @see {@link LorebookData}\n */\nexport const LorebookDataSchema = z\n .object({\n config: z\n .object({\n tokenLimit: z.number().int().min(1).meta({\n description:\n \"The token limit for the lorebook. When exceeded, low-priority lorebooks will be deactivated. Positive integer.\",\n }),\n })\n .meta({\n description:\n \"The configuration for the lorebook. Not scriptable.\",\n }),\n data: z\n .array(LorebookEntrySchema)\n .refine(unique(\"id\"), { message: \"Not unique key: id\" })\n .default([])\n .meta({\n description:\n \"Contains the actual lorebooks. Duplicated id is not allowed.\",\n }),\n })\n .meta({\n description:\n \"Object containing all data for the lorebook. Meant to be stored in the database.\",\n });\n\n/**\n * Object containing all data for the lorebook.\n * It's meant to be stored in the database and many other places.\n */\nexport type LorebookData = z.infer<typeof LorebookDataSchema>;\n"],"names":["LorebookConditionDetailSchema","z","LorebookConditionSchema","LorebookEntrySchema","LorebookDataSchema","unique"],"mappings":";;AAMO,MAAMA,IAAgC;AAAA,EACzC,OAAOC,EACF,OAAO;AAAA,IACJ,MAAMA,EAAE,QAAQ,aAAa,EAAE,KAAK;AAAA,MAChC,aAAa;AAAA,IAAA,CAChB;AAAA,IACD,cAAcA,EAAE,OAAA,EAAS,KAAK;AAAA,MAC1B,aAAa;AAAA,IAAA,CAChB;AAAA,IACD,YAAYA,EAAE,OAAA,EAAS,SAAA,EAAW,KAAK;AAAA,MACnC,aAAa;AAAA,IAAA,CAChB;AAAA,EAAA,CACJ,EACA,KAAK,EAAE,aAAa,0BAA0B;AAAA,EACnD,WAAWA,EACN,OAAO;AAAA,IACJ,MAAMA,EAAE,QAAQ,kBAAkB,EAAE,KAAK;AAAA,MACrC,aAAa;AAAA,IAAA,C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AA,CACJ,EACA,KAAK;AAAA,IACF,aACI;AAAA,EAAA,CACP;AAAA,EACL,MAAMA,EACD,MAAME,CAAmB,EACzB,OAAOE,EAAO,IAAI,GAAG,EAAE,SAAS,sBAAsB,EACtD,QAAQ,CAAA,CAAE,EACV,KAAK;AAAA,IACF,aACI;AAAA,EAAA,CACP;AACT,CAAC,EACA,KAAK;AAAA,EACF,aACI;AACR,CAAC;"}
1
+ {"version":3,"file":"Lorebook.js","sources":["../../../src/types/v0/Character/Lorebook.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { positiveInteger, unique } from \"@/types/v0/utils\";\n\n/**\n * Lorebook condition detail schemas organized by type.\n * @see {@link LorebookConditionSchema}\n */\nexport const LorebookConditionDetails = {\n regex: z\n .object({\n type: z.literal(\"regex_match\").meta({\n description: \"This condition matches the regex pattern.\",\n }),\n regexPattern: z.string().meta({\n description: \"The regex pattern to match. Scriptable.\",\n }),\n regexFlags: z.string().optional().meta({\n description: \"The regex flags to use. Not scriptable.\",\n }),\n })\n .meta({ description: \"Regex match condition.\" }),\n plainText: z\n .object({\n type: z.literal(\"plain_text_match\").meta({\n description: \"This condition simply matches the text.\",\n }),\n text: z.string().meta({\n description: \"The text to match. Scriptable. Case insensitive.\",\n }),\n })\n .meta({ description: \"Plain text match condition.\" }),\n always: z\n .object({\n type: z\n .literal(\"always\")\n .meta({ description: \"This condition is always true.\" }),\n })\n .meta({ description: \"Always active condition.\" }),\n} as const;\n\n/**\n * The condition for the lorebook to be activated.\n */\nexport const LorebookConditionSchema = z.discriminatedUnion(\"type\", [\n LorebookConditionDetails.regex,\n LorebookConditionDetails.plainText,\n LorebookConditionDetails.always,\n]);\n\n/**\n * The condition for the lorebook to be activated.\n * @see {@link LorebookConditionSchema}\n */\nexport type LorebookCondition = z.infer<typeof LorebookConditionSchema>;\n\n/**\n * @see {@link LorebookEntry}\n */\nexport const LorebookEntrySchema = z\n .object({\n id: z.string().meta({ description: \"Internally generated ID.\" }),\n name: z\n .string()\n .meta({ description: \"Human readable name for the lorebook.\" }),\n condition: z\n .array(LorebookConditionSchema)\n .default([])\n .meta({\n description:\n \"The condition for the lorebook to be activated. \" +\n \"If empty, it will not be activated. \" +\n \"Use 'always' to activate without any condition.\",\n }),\n multipleConditionResolveStrategy: z\n .enum([\"all\", \"any\"])\n .optional()\n .meta({\n description:\n \"The strategy for resolving multiple conditions. 'all' means all must be met, 'any' means at least one.\",\n }),\n content: z.string().meta({\n description:\n \"The lorebook content to be added on AI prompt. Not for human reading. Scriptable.\",\n }),\n priority: z.number().optional().meta({\n description:\n \"The priority of the lorebook. Higher priority means it will be activated first. May be negative or decimal. Base is 0.\",\n }),\n enabled: z\n .boolean()\n .optional()\n .meta({ description: \"Whether the lorebook is enabled.\" }),\n })\n .meta({\n description:\n \"A lorebook entry. Small part of prompts activated by session's text matching.\",\n });\n\n/**\n * A lorebook is a collection of lorebooks.\n * Lorebook is a small part of prompts which is activated by session's text matching.\n */\nexport type LorebookEntry = z.infer<typeof LorebookEntrySchema>;\n\n/**\n * @see {@link LorebookData}\n */\nexport const LorebookDataSchema = z\n .object({\n config: z\n .object({\n tokenLimit: positiveInteger.optional().meta({\n description:\n \"The token limit for the lorebook. When exceeded, low-priority lorebooks will be deactivated. Positive integer.\",\n }),\n })\n .prefault({})\n .meta({\n description:\n \"The configuration for the lorebook. Not scriptable.\",\n }),\n data: z\n .array(LorebookEntrySchema)\n .refine(unique(\"id\"), { message: \"Not unique key: id\" })\n .default([])\n .meta({\n description:\n \"Contains the actual lorebooks. Duplicated id is not allowed.\",\n }),\n })\n .meta({\n description:\n \"Object containing data for the lorebook. Meant to be stored in the database.\",\n })\n .prefault({});\n\n/**\n * Object containing all data for the lorebook.\n * It's meant to be stored in the database and many other places.\n */\nexport type LorebookData = z.infer<typeof LorebookDataSchema>;\n"],"names":["LorebookConditionDetails","z","LorebookConditionSchema","LorebookEntrySchema","LorebookDataSchema","positiveInteger","unique"],"mappings":";;AAOO,MAAMA,IAA2B;AAAA,EAC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