@arisutalk/character-spec 0.0.0 → 0.0.2

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 (46) hide show
  1. package/LICENSE +202 -202
  2. package/README.md +154 -64
  3. package/dist/index.d.ts +15 -166
  4. package/dist/index.js +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/v0/Character/Assets.d.ts +37 -0
  7. package/dist/v0/Character/Assets.js +21 -0
  8. package/dist/v0/Character/Assets.js.map +1 -0
  9. package/dist/v0/Character/Character.d.ts +263 -0
  10. package/dist/v0/Character/Character.js +46 -0
  11. package/dist/v0/Character/Character.js.map +1 -0
  12. package/dist/v0/Character/Chat.d.ts +73 -0
  13. package/dist/v0/Character/Chat.js +19 -0
  14. package/dist/v0/Character/Chat.js.map +1 -0
  15. package/dist/v0/Character/Lorebook.d.ts +98 -0
  16. package/dist/v0/Character/Lorebook.js +68 -0
  17. package/dist/v0/Character/Lorebook.js.map +1 -0
  18. package/dist/v0/Character/Message.d.ts +32 -0
  19. package/dist/v0/Character/Message.js +34 -0
  20. package/dist/v0/Character/Message.js.map +1 -0
  21. package/dist/v0/Character/Meta.js +22 -0
  22. package/dist/v0/Character/Meta.js.map +1 -0
  23. package/dist/v0/Character/index.d.ts +6 -0
  24. package/dist/v0/Character.d.ts +6 -0
  25. package/dist/v0/Character.js +19 -0
  26. package/dist/v0/Character.js.map +1 -0
  27. package/dist/v0/Executables/Executable.d.ts +120 -0
  28. package/dist/v0/Executables/Executable.js +21 -0
  29. package/dist/v0/Executables/Executable.js.map +1 -0
  30. package/dist/v0/Executables/ReplaceHook.d.ts +161 -0
  31. package/dist/v0/Executables/ReplaceHook.js +57 -0
  32. package/dist/v0/Executables/ReplaceHook.js.map +1 -0
  33. package/dist/v0/Executables/index.d.ts +3 -0
  34. package/dist/v0/Executables.d.ts +3 -0
  35. package/dist/v0/Executables.js +9 -0
  36. package/dist/v0/Executables.js.map +1 -0
  37. package/dist/v0/index.d.ts +2 -0
  38. package/dist/v0/utils.d.ts +11 -0
  39. package/dist/v0/utils.js +14 -0
  40. package/dist/v0/utils.js.map +1 -0
  41. package/dist/v0.d.ts +2 -507
  42. package/dist/v0.js +4 -96
  43. package/dist/v0.js.map +1 -1
  44. package/package.json +13 -11
  45. package/dist/Character-Didq99iq.js +0 -157
  46. package/dist/Character-Didq99iq.js.map +0 -1
@@ -1,157 +0,0 @@
1
- import * as t from "valibot";
2
- const i = t.object({
3
- /**
4
- * Internally generated ID.
5
- */
6
- id: t.optional(t.string()),
7
- /**
8
- * Human readable name for the lorebook.
9
- */
10
- name: t.string(),
11
- /**
12
- * The condition for the lorebook to be activated.
13
- * If empty, it will not be activated.
14
- * Duplicated condition is no effect.
15
- * Use 'always' to activate without any condition. {@link LorebookConditionTypeMap#always}
16
- */
17
- condition: t.optional(t.array(t.custom(() => !0))),
18
- /**
19
- * The strategy for resolving multiple conditions.
20
- * "all" means all conditions must be met.
21
- * "any" means at least one condition must be met.
22
- */
23
- multipleConditionResolveStrategy: t.optional(t.picklist(["all", "any"])),
24
- /**
25
- * The lorebook content to be added on AI prompt.
26
- * Not for human reading, and it's scriptable.
27
- */
28
- content: t.string(),
29
- /**
30
- * The priority of the lorebook.
31
- * Higher priority means it will be activated first, remains when token limit is exceeded.
32
- * May be negative. Base is 0. Allows demical.
33
- */
34
- priority: t.optional(t.number()),
35
- /**
36
- * Whether the lorebook is enabled.
37
- */
38
- enabled: t.optional(t.boolean())
39
- }), o = {
40
- regex: t.object({
41
- /**
42
- * The type of the condition.
43
- * This condition matches the regex pattern.
44
- */
45
- type: t.literal("regex_match"),
46
- /**
47
- * The regex pattern to match.
48
- * Note that this is scriptable.
49
- */
50
- regexPattern: t.string(),
51
- /**
52
- * The regex flags to use.
53
- * Note that this is not scriptable.
54
- */
55
- regexFlags: t.optional(t.string())
56
- }),
57
- plainText: t.object({
58
- /**
59
- * The type of the condition.
60
- * This condition simply matches the text.
61
- */
62
- type: t.literal("plain_text_match"),
63
- /**
64
- * The text to match.
65
- * Note that this is scriptable.
66
- * No case sensitive.
67
- */
68
- text: t.string()
69
- }),
70
- always: t.object({
71
- /**
72
- * The type of the condition.
73
- * This condition is always true.
74
- */
75
- type: t.literal("always")
76
- })
77
- }, l = t.variant("type", [
78
- o.regex,
79
- o.plainText,
80
- o.always
81
- ]), n = t.object({
82
- /**
83
- * The configuration for the lorebook.
84
- * It is not scriptable.
85
- */
86
- config: t.object({
87
- /**
88
- * The token limit for the lorebook.
89
- * When the token limit is exceeded, some low-priority lorebooks will be deactivated to keep the token usage within the limit.
90
- * Positive integer.
91
- */
92
- tokenLimit: t.pipe(t.number(), t.integer(), t.minValue(1))
93
- }),
94
- /**
95
- * Contains the actual lorebooks.
96
- * Duplicated id is not allowed.
97
- */
98
- data: t.optional(
99
- t.pipe(
100
- t.array(i),
101
- t.check(
102
- (a) => a.map((e) => e.id).length === new Set(a.map((e) => e.id)).size,
103
- "Duplicated id is not allowed."
104
- )
105
- ),
106
- []
107
- )
108
- }), r = t.object({
109
- /**
110
- * The character description.
111
- */
112
- description: t.string(),
113
- /**
114
- * The authors note. It's usually used to mock the user's message(differ by prompt).
115
- */
116
- authorsNote: t.string(),
117
- /**
118
- * Lorebook data.
119
- * @see {@link LorebookDataSchema}
120
- */
121
- lorebook: n
122
- }), s = t.object({
123
- /**
124
- * The version of the character spec.
125
- * This is used to determine which schema to use for parsing.
126
- * Also tries to migrate the character to the latest version.
127
- */
128
- specVersion: t.literal(0),
129
- /**
130
- * Unique identifier for the character.
131
- */
132
- id: t.string(),
133
- /**
134
- * The display name of the character.
135
- * Human readable, not scriptable.
136
- */
137
- name: t.string(),
138
- /**
139
- * A short description of the character.
140
- * Human readable, not scriptable.
141
- */
142
- description: t.string(),
143
- /**
144
- * Optional URL for the character's avatar image.
145
- */
146
- avatarUrl: t.optional(t.pipe(t.string(), t.url())),
147
- prompt: r
148
- });
149
- export {
150
- s as C,
151
- i as L,
152
- r as a,
153
- o as b,
154
- l as c,
155
- n as d
156
- };
157
- //# sourceMappingURL=Character-Didq99iq.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Character-Didq99iq.js","sources":["../src/types/v0/Lorebook.ts","../src/types/v0/Character.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * @see {@link LorebookEntry}\n */\nexport const LorebookEntrySchema = v.object({\n /**\n * Internally generated ID.\n */\n id: v.optional(v.string()),\n /**\n * Human readable name for the lorebook.\n */\n name: v.string(),\n /**\n * The condition for the lorebook to be activated.\n * If empty, it will not be activated.\n * Duplicated condition is no effect.\n * Use 'always' to activate without any condition. {@link LorebookConditionTypeMap#always}\n */\n condition: v.optional(v.array(v.custom<LorebookCondition>(() => true))),\n /**\n * The strategy for resolving multiple conditions.\n * \"all\" means all conditions must be met.\n * \"any\" means at least one condition must be met.\n */\n multipleConditionResolveStrategy: v.optional(v.picklist([\"all\", \"any\"])),\n /**\n * The lorebook content to be added on AI prompt.\n * Not for human reading, and it's scriptable.\n */\n content: v.string(),\n /**\n * The priority of the lorebook.\n * Higher priority means it will be activated first, remains when token limit is exceeded.\n * May be negative. Base is 0. Allows demical.\n */\n priority: v.optional(v.number()),\n /**\n * Whether the lorebook is enabled.\n */\n enabled: v.optional(v.boolean()),\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 = v.InferOutput<typeof LorebookEntrySchema>;\n\n/**\n * @see {@link LorebookConditionSchema}\n */\nexport const LorebookConditionDetailSchema = {\n regex: v.object({\n /**\n * The type of the condition.\n * This condition matches the regex pattern.\n */\n type: v.literal(\"regex_match\"),\n /**\n * The regex pattern to match.\n * Note that this is scriptable.\n */\n regexPattern: v.string(),\n /**\n * The regex flags to use.\n * Note that this is not scriptable.\n */\n regexFlags: v.optional(v.string()),\n }),\n plainText: v.object({\n /**\n * The type of the condition.\n * This condition simply matches the text.\n */\n type: v.literal(\"plain_text_match\"),\n /**\n * The text to match.\n * Note that this is scriptable.\n * No case sensitive.\n */\n text: v.string(),\n }),\n always: v.object({\n /**\n * The type of the condition.\n * This condition is always true.\n */\n type: v.literal(\"always\"),\n }),\n} as const;\n\n/**\n * The condition for the lorebook to be activated.\n */\nexport const LorebookConditionSchema = v.variant(\"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 = v.InferOutput<typeof LorebookConditionSchema>;\n\n/**\n * @see {@link LorebookData}\n */\nexport const LorebookDataSchema = v.object({\n /**\n * The configuration for the lorebook.\n * It is not scriptable.\n */\n config: v.object({\n /**\n * The token limit for the lorebook.\n * When the token limit is exceeded, some low-priority lorebooks will be deactivated to keep the token usage within the limit.\n * Positive integer.\n */\n tokenLimit: v.pipe(v.number(), v.integer(), v.minValue(1)),\n }),\n /**\n * Contains the actual lorebooks.\n * Duplicated id is not allowed.\n */\n data: v.optional(\n v.pipe(\n v.array(LorebookEntrySchema),\n v.check(\n (data) =>\n data.map((i) => i.id).length ===\n new Set(data.map((i) => i.id)).size,\n \"Duplicated id is not allowed.\",\n ),\n ),\n [],\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 = v.InferOutput<typeof LorebookDataSchema>;\n","import * as v from \"valibot\";\nimport { LorebookDataSchema } from \"@/types/v0/Lorebook\";\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 = v.InferOutput<\n typeof CharacterPromptDataSchema\n>;\n\n/**\n * @see {@link CharacterPromptData}\n */\nexport const CharacterPromptDataSchema = v.object({\n /**\n * The character description.\n */\n description: v.string(),\n /**\n * The authors note. It's usually used to mock the user's message(differ by prompt).\n */\n authorsNote: v.string(),\n /**\n * Lorebook data.\n * @see {@link LorebookDataSchema}\n */\n lorebook: LorebookDataSchema,\n});\n\n/**\n * @see {@link Character}\n */\nexport const CharacterSchema = v.object({\n /**\n * The version of the character spec.\n * This is used to determine which schema to use for parsing.\n * Also tries to migrate the character to the latest version.\n */\n specVersion: v.literal(0),\n /**\n * Unique identifier for the character.\n */\n id: v.string(),\n /**\n * The display name of the character.\n * Human readable, not scriptable.\n */\n name: v.string(),\n /**\n * A short description of the character.\n * Human readable, not scriptable.\n */\n description: v.string(),\n /**\n * Optional URL for the character's avatar image.\n */\n avatarUrl: v.optional(v.pipe(v.string(), v.url())),\n prompt: CharacterPromptDataSchema,\n});\n\n/**\n * Represents a specific AI character personality.\n */\nexport type Character = v.InferOutput<typeof CharacterSchema>;\n"],"names":["LorebookEntrySchema","v","LorebookConditionDetailSchema","LorebookConditionSchema","LorebookDataSchema","data","i","CharacterPromptDataSchema","CharacterSchema"],"mappings":";AAKO,MAAMA,IAAsBC,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA,EAIxC,IAAIA,EAAE,SAASA,EAAE,QAAQ;AAAA;AAAA;AAAA;AAAA,EAIzB,MAAMA,EAAE,OAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOR,WAAWA,EAAE,SAASA,EAAE,MAAMA,EAAE,OAA0B,MAAM,EAAI,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMtE,kCAAkCA,EAAE,SAASA,EAAE,SAAS,CAAC,OAAO,KAAK,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,EAKvE,SAASA,EAAE,OAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMX,UAAUA,EAAE,SAASA,EAAE,QAAQ;AAAA;AAAA;AAAA;AAAA,EAI/B,SAASA,EAAE,SAASA,EAAE,SAAS;AACnC,CAAC,GAUYC,IAAgC;AAAA,EACzC,OAAOD,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,IAKZ,MAAMA,EAAE,QAAQ,aAAa;AAAA;AAAA;AAAA;A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