@arisutalk/character-spec 0.0.0

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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2025 concertypin
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # @arisutalk/character-spec ✨
2
+
3
+ Hi there! Welcome to the **character-spec** library for ArisuTalk! 🌸
4
+ This package defines the official character specification, schemas, and providing migration tools strictly typed with [Valibot](https://valibot.dev/).
5
+
6
+ It's super important to keep our waifus... I mean, characters, well-defined! (◕‿◕✿)
7
+ v0 is still in development, it's not even finished!
8
+
9
+ ## 📦 Installation
10
+
11
+ Grab it with your favorite package manager!
12
+
13
+ ```bash
14
+ pnpm add @arisutalk/character-spec valibot
15
+ ```
16
+ *Note: `valibot` is a peer dependency! Don't forget it!* 😉
17
+
18
+ ## 🚀 Usage
19
+
20
+ Here is how you can use the schemas to validate your character data. It's safe and sound! 🛡️
21
+
22
+ ```typescript
23
+ import { CharacterSchema, type Character } from "@arisutalk/character-spec/v0";
24
+ import * as v from "valibot";
25
+
26
+ // Let's say you have some raw data...
27
+ const rawData: Character = {
28
+ specVersion: 0,
29
+ id: "uuid-1234",
30
+ name: "Aris",
31
+ description: "Light Attribute AoE Dealer from Blue Archive.",
32
+ prompt: {} as any // Just for example, you should fill it with valid data!
33
+ };
34
+
35
+ // Validate it against v0 Schema!
36
+ const AL_1S = v.parse(CharacterSchema, rawData);
37
+
38
+ console.log(`Hello, ${AL_1S.name}!`); // Typescript knows 'name' exists! ✨
39
+ ```
40
+
41
+ ## 📂 Structure
42
+
43
+ Everything is versioned so we don't break things!
44
+ - `src/types/v0/`: Contains the initial Version 0 specs.
45
+ - `Character.ts`: The main character object.
46
+ - `Lorebook.ts`: World info and lore.
47
+ - `Chat.ts` & `Message.ts`: Chat history structures.
48
+
49
+ ## 🛠️ Development
50
+
51
+ Want to contribute? Yay! Make sure to keep things clean. 🧹
52
+
53
+ ```bash
54
+ # Build the library
55
+ pnpm build
56
+
57
+ # Lint the code (Biome is fast! ⚡)
58
+ pnpm lint
59
+
60
+ # Format the code
61
+ pnpm format
62
+ ```
63
+
64
+ Made with ❤️ for ArisuTalk.
@@ -0,0 +1,157 @@
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
@@ -0,0 +1 @@
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;AAAA;AAAA,IAK7B,cAAcA,EAAE,OAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKhB,YAAYA,EAAE,SAASA,EAAE,QAAQ;AAAA,EAAA,CACpC;AAAA,EACD,WAAWA,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,IAKhB,MAAMA,EAAE,QAAQ,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMlC,MAAMA,EAAE,OAAA;AAAA,EAAO,CAClB;AAAA,EACD,QAAQA,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,IAKb,MAAMA,EAAE,QAAQ,QAAQ;AAAA,EAAA,CAC3B;AACL,GAKaE,IAA0BF,EAAE,QAAQ,QAAQ;AAAA,EACrDC,EAA8B;AAAA,EAC9BA,EAA8B;AAAA,EAC9BA,EAA8B;AAClC,CAAC,GAWYE,IAAqBH,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKvC,QAAQA,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMb,YAAYA,EAAE,KAAKA,EAAE,OAAA,GAAUA,EAAE,QAAA,GAAWA,EAAE,SAAS,CAAC,CAAC;AAAA,EAAA,CAC5D;AAAA;AAAA;AAAA;AAAA;AAAA,EAKD,MAAMA,EAAE;AAAA,IACJA,EAAE;AAAA,MACEA,EAAE,MAAMD,CAAmB;AAAA,MAC3BC,EAAE;AAAA,QACE,CAACI,MACGA,EAAK,IAAI,CAACC,MAAMA,EAAE,EAAE,EAAE,WACtB,IAAI,IAAID,EAAK,IAAI,CAACC,MAAMA,EAAE,EAAE,CAAC,EAAE;AAAA,QACnC;AAAA,MAAA;AAAA,IACJ;AAAA,IAEJ,CAAA;AAAA,EAAC;AAET,CAAC,GC5HYC,IAA4BN,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA,EAI9C,aAAaA,EAAE,OAAA;AAAA;AAAA;AAAA;AAAA,EAIf,aAAaA,EAAE,OAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKf,UAAUG;AACd,CAAC,GAKYI,IAAkBP,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMpC,aAAaA,EAAE,QAAQ,CAAC;AAAA;AAAA;AAAA;AAAA,EAIxB,IAAIA,EAAE,OAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKN,MAAMA,EAAE,OAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKR,aAAaA,EAAE,OAAA;AAAA;AAAA;AAAA;AAAA,EAIf,WAAWA,EAAE,SAASA,EAAE,KAAKA,EAAE,UAAUA,EAAE,IAAA,CAAK,CAAC;AAAA,EACjD,QAAQM;AACZ,CAAC;"}
@@ -0,0 +1,166 @@
1
+ import { ArraySchema } from 'valibot';
2
+ import { BooleanSchema } from 'valibot';
3
+ import { CheckAction } from 'valibot';
4
+ import { CustomSchema } from 'valibot';
5
+ import { IntegerAction } from 'valibot';
6
+ import { LiteralSchema } from 'valibot';
7
+ import { MinValueAction } from 'valibot';
8
+ import { NumberSchema } from 'valibot';
9
+ import { ObjectSchema } from 'valibot';
10
+ import { OptionalSchema } from 'valibot';
11
+ import { PicklistSchema } from 'valibot';
12
+ import { SchemaWithPipe } from 'valibot';
13
+ import { StringSchema } from 'valibot';
14
+ import { UrlAction } from 'valibot';
15
+ import * as v from 'valibot';
16
+
17
+ /**
18
+ * Represents a specific AI character personality.
19
+ */
20
+ declare type Character = v.InferOutput<typeof CharacterSchema>;
21
+
22
+ export declare type CharacterMap = {
23
+ "0": Character;
24
+ };
25
+
26
+ declare const characterMap: {
27
+ readonly 0: ObjectSchema< {
28
+ readonly specVersion: LiteralSchema<0, undefined>;
29
+ readonly id: StringSchema<undefined>;
30
+ readonly name: StringSchema<undefined>;
31
+ readonly description: StringSchema<undefined>;
32
+ readonly avatarUrl: OptionalSchema<SchemaWithPipe<readonly [StringSchema<undefined>, UrlAction<string, undefined>]>, undefined>;
33
+ readonly prompt: ObjectSchema< {
34
+ readonly description: StringSchema<undefined>;
35
+ readonly authorsNote: StringSchema<undefined>;
36
+ readonly lorebook: ObjectSchema< {
37
+ readonly config: ObjectSchema< {
38
+ readonly tokenLimit: SchemaWithPipe<readonly [NumberSchema<undefined>, IntegerAction<number, undefined>, MinValueAction<number, 1, undefined>]>;
39
+ }, undefined>;
40
+ readonly data: OptionalSchema<SchemaWithPipe<readonly [ArraySchema<ObjectSchema< {
41
+ readonly id: OptionalSchema<StringSchema<undefined>, undefined>;
42
+ readonly name: StringSchema<undefined>;
43
+ readonly condition: OptionalSchema<ArraySchema<CustomSchema< {
44
+ type: "regex_match";
45
+ regexPattern: string;
46
+ regexFlags?: string | undefined;
47
+ } | {
48
+ type: "plain_text_match";
49
+ text: string;
50
+ } | {
51
+ type: "always";
52
+ }, undefined>, undefined>, undefined>;
53
+ readonly multipleConditionResolveStrategy: OptionalSchema<PicklistSchema<["all", "any"], undefined>, undefined>;
54
+ readonly content: StringSchema<undefined>;
55
+ readonly priority: OptionalSchema<NumberSchema<undefined>, undefined>;
56
+ readonly enabled: OptionalSchema<BooleanSchema<undefined>, undefined>;
57
+ }, undefined>, undefined>, CheckAction< {
58
+ id?: string | undefined;
59
+ name: string;
60
+ condition?: ({
61
+ type: "regex_match";
62
+ regexPattern: string;
63
+ regexFlags?: string | undefined;
64
+ } | {
65
+ type: "plain_text_match";
66
+ text: string;
67
+ } | {
68
+ type: "always";
69
+ })[] | undefined;
70
+ multipleConditionResolveStrategy?: "all" | "any" | undefined;
71
+ content: string;
72
+ priority?: number | undefined;
73
+ enabled?: boolean | undefined;
74
+ }[], "Duplicated id is not allowed.">]>, readonly []>;
75
+ }, undefined>;
76
+ }, undefined>;
77
+ }, undefined>;
78
+ };
79
+ export { characterMap }
80
+ export default characterMap;
81
+
82
+ /**
83
+ * @see {@link Character}
84
+ */
85
+ declare const CharacterSchema: v.ObjectSchema<{
86
+ /**
87
+ * The version of the character spec.
88
+ * This is used to determine which schema to use for parsing.
89
+ * Also tries to migrate the character to the latest version.
90
+ */
91
+ readonly specVersion: v.LiteralSchema<0, undefined>;
92
+ /**
93
+ * Unique identifier for the character.
94
+ */
95
+ readonly id: v.StringSchema<undefined>;
96
+ /**
97
+ * The display name of the character.
98
+ * Human readable, not scriptable.
99
+ */
100
+ readonly name: v.StringSchema<undefined>;
101
+ /**
102
+ * A short description of the character.
103
+ * Human readable, not scriptable.
104
+ */
105
+ readonly description: v.StringSchema<undefined>;
106
+ /**
107
+ * Optional URL for the character's avatar image.
108
+ */
109
+ readonly avatarUrl: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.UrlAction<string, undefined>]>, undefined>;
110
+ readonly prompt: v.ObjectSchema<{
111
+ /**
112
+ * The character description.
113
+ */
114
+ readonly description: v.StringSchema<undefined>;
115
+ /**
116
+ * The authors note. It's usually used to mock the user's message(differ by prompt).
117
+ */
118
+ readonly authorsNote: v.StringSchema<undefined>;
119
+ /**
120
+ * Lorebook data.
121
+ * @see {@link LorebookDataSchema}
122
+ */
123
+ readonly lorebook: v.ObjectSchema<{
124
+ readonly config: v.ObjectSchema<{
125
+ readonly tokenLimit: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
126
+ }, undefined>;
127
+ readonly data: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
128
+ readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
129
+ readonly name: v.StringSchema<undefined>;
130
+ readonly condition: v.OptionalSchema<v.ArraySchema<v.CustomSchema<{
131
+ type: "regex_match";
132
+ regexPattern: string;
133
+ regexFlags?: string | undefined;
134
+ } | {
135
+ type: "plain_text_match";
136
+ text: string;
137
+ } | {
138
+ type: "always";
139
+ }, undefined>, undefined>, undefined>;
140
+ readonly multipleConditionResolveStrategy: v.OptionalSchema<v.PicklistSchema<["all", "any"], undefined>, undefined>;
141
+ readonly content: v.StringSchema<undefined>;
142
+ readonly priority: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
143
+ readonly enabled: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
144
+ }, undefined>, undefined>, v.CheckAction<{
145
+ id?: string | undefined;
146
+ name: string;
147
+ condition?: ({
148
+ type: "regex_match";
149
+ regexPattern: string;
150
+ regexFlags?: string | undefined;
151
+ } | {
152
+ type: "plain_text_match";
153
+ text: string;
154
+ } | {
155
+ type: "always";
156
+ })[] | undefined;
157
+ multipleConditionResolveStrategy?: "all" | "any" | undefined;
158
+ content: string;
159
+ priority?: number | undefined;
160
+ enabled?: boolean | undefined;
161
+ }[], "Duplicated id is not allowed.">]>, readonly []>;
162
+ }, undefined>;
163
+ }, undefined>;
164
+ }, undefined>;
165
+
166
+ export { }
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ import { C as a } from "./Character-Didq99iq.js";
2
+ const t = {
3
+ 0: a
4
+ };
5
+ export {
6
+ t as characterMap,
7
+ t as default
8
+ };
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import {\n type Character as CharacterV0,\n CharacterSchema as CharacterV0Schema,\n} from \"@/types/v0/Character\";\n\nexport const characterMap = {\n 0: CharacterV0Schema,\n} as const;\nexport type CharacterMap = {\n \"0\": CharacterV0;\n};\n\nexport default characterMap;\n"],"names":["characterMap","CharacterV0Schema"],"mappings":";AAKO,MAAMA,IAAe;AAAA,EACxB,GAAGC;AACP;"}
package/dist/v0.d.ts ADDED
@@ -0,0 +1,507 @@
1
+ import * as v from 'valibot';
2
+
3
+ /**
4
+ * Represents a specific AI character personality.
5
+ */
6
+ export declare type Character = v.InferOutput<typeof CharacterSchema>;
7
+
8
+ /**
9
+ * The prompt data for a character.
10
+ * It is used to generate the character's persona.
11
+ * All of parameters are for AI prompt, and scriptable.
12
+ */
13
+ export declare type CharacterPromptData = v.InferOutput<typeof CharacterPromptDataSchema>;
14
+
15
+ /**
16
+ * @see {@link CharacterPromptData}
17
+ */
18
+ export declare const CharacterPromptDataSchema: v.ObjectSchema<{
19
+ /**
20
+ * The character description.
21
+ */
22
+ readonly description: v.StringSchema<undefined>;
23
+ /**
24
+ * The authors note. It's usually used to mock the user's message(differ by prompt).
25
+ */
26
+ readonly authorsNote: v.StringSchema<undefined>;
27
+ /**
28
+ * Lorebook data.
29
+ * @see {@link LorebookDataSchema}
30
+ */
31
+ readonly lorebook: v.ObjectSchema<{
32
+ readonly config: v.ObjectSchema<{
33
+ readonly tokenLimit: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
34
+ }, undefined>;
35
+ readonly data: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
36
+ readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
37
+ readonly name: v.StringSchema<undefined>;
38
+ readonly condition: v.OptionalSchema<v.ArraySchema<v.CustomSchema<{
39
+ type: "regex_match";
40
+ regexPattern: string;
41
+ regexFlags?: string | undefined;
42
+ } | {
43
+ type: "plain_text_match";
44
+ text: string;
45
+ } | {
46
+ type: "always";
47
+ }, undefined>, undefined>, undefined>;
48
+ readonly multipleConditionResolveStrategy: v.OptionalSchema<v.PicklistSchema<["all", "any"], undefined>, undefined>;
49
+ readonly content: v.StringSchema<undefined>;
50
+ readonly priority: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
51
+ readonly enabled: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
52
+ }, undefined>, undefined>, v.CheckAction<{
53
+ id?: string | undefined;
54
+ name: string;
55
+ condition?: ({
56
+ type: "regex_match";
57
+ regexPattern: string;
58
+ regexFlags?: string | undefined;
59
+ } | {
60
+ type: "plain_text_match";
61
+ text: string;
62
+ } | {
63
+ type: "always";
64
+ })[] | undefined;
65
+ multipleConditionResolveStrategy?: "all" | "any" | undefined;
66
+ content: string;
67
+ priority?: number | undefined;
68
+ enabled?: boolean | undefined;
69
+ }[], "Duplicated id is not allowed.">]>, readonly []>;
70
+ }, undefined>;
71
+ }, undefined>;
72
+
73
+ /**
74
+ * @see {@link Character}
75
+ */
76
+ export declare const CharacterSchema: v.ObjectSchema<{
77
+ /**
78
+ * The version of the character spec.
79
+ * This is used to determine which schema to use for parsing.
80
+ * Also tries to migrate the character to the latest version.
81
+ */
82
+ readonly specVersion: v.LiteralSchema<0, undefined>;
83
+ /**
84
+ * Unique identifier for the character.
85
+ */
86
+ readonly id: v.StringSchema<undefined>;
87
+ /**
88
+ * The display name of the character.
89
+ * Human readable, not scriptable.
90
+ */
91
+ readonly name: v.StringSchema<undefined>;
92
+ /**
93
+ * A short description of the character.
94
+ * Human readable, not scriptable.
95
+ */
96
+ readonly description: v.StringSchema<undefined>;
97
+ /**
98
+ * Optional URL for the character's avatar image.
99
+ */
100
+ readonly avatarUrl: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.UrlAction<string, undefined>]>, undefined>;
101
+ readonly prompt: v.ObjectSchema<{
102
+ /**
103
+ * The character description.
104
+ */
105
+ readonly description: v.StringSchema<undefined>;
106
+ /**
107
+ * The authors note. It's usually used to mock the user's message(differ by prompt).
108
+ */
109
+ readonly authorsNote: v.StringSchema<undefined>;
110
+ /**
111
+ * Lorebook data.
112
+ * @see {@link LorebookDataSchema}
113
+ */
114
+ readonly lorebook: v.ObjectSchema<{
115
+ readonly config: v.ObjectSchema<{
116
+ readonly tokenLimit: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
117
+ }, undefined>;
118
+ readonly data: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
119
+ readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
120
+ readonly name: v.StringSchema<undefined>;
121
+ readonly condition: v.OptionalSchema<v.ArraySchema<v.CustomSchema<{
122
+ type: "regex_match";
123
+ regexPattern: string;
124
+ regexFlags?: string | undefined;
125
+ } | {
126
+ type: "plain_text_match";
127
+ text: string;
128
+ } | {
129
+ type: "always";
130
+ }, undefined>, undefined>, undefined>;
131
+ readonly multipleConditionResolveStrategy: v.OptionalSchema<v.PicklistSchema<["all", "any"], undefined>, undefined>;
132
+ readonly content: v.StringSchema<undefined>;
133
+ readonly priority: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
134
+ readonly enabled: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
135
+ }, undefined>, undefined>, v.CheckAction<{
136
+ id?: string | undefined;
137
+ name: string;
138
+ condition?: ({
139
+ type: "regex_match";
140
+ regexPattern: string;
141
+ regexFlags?: string | undefined;
142
+ } | {
143
+ type: "plain_text_match";
144
+ text: string;
145
+ } | {
146
+ type: "always";
147
+ })[] | undefined;
148
+ multipleConditionResolveStrategy?: "all" | "any" | undefined;
149
+ content: string;
150
+ priority?: number | undefined;
151
+ enabled?: boolean | undefined;
152
+ }[], "Duplicated id is not allowed.">]>, readonly []>;
153
+ }, undefined>;
154
+ }, undefined>;
155
+ }, undefined>;
156
+
157
+ /**
158
+ * Represents a chat session with a character.
159
+ */
160
+ export declare type Chat = v.InferOutput<typeof ChatSchema>;
161
+
162
+ /**
163
+ * @see {@link Chat}
164
+ */
165
+ export declare const ChatSchema: v.ObjectSchema<{
166
+ /**
167
+ * Unique identifier for the chat session.
168
+ */
169
+ readonly id: v.StringSchema<undefined>;
170
+ /**
171
+ * The ID of the character associated with this chat.
172
+ */
173
+ readonly characterId: v.StringSchema<undefined>;
174
+ /**
175
+ * The list of messages in this chat.
176
+ */
177
+ readonly messages: v.ArraySchema<v.ObjectSchema<{
178
+ readonly id: v.StringSchema<undefined>;
179
+ readonly role: v.UnionSchema<[v.LiteralSchema<"user", undefined>, v.LiteralSchema<"assistant", undefined>, v.LiteralSchema<"system", undefined>], undefined>;
180
+ readonly content: v.VariantSchema<"type", [v.ObjectSchema<{
181
+ readonly type: v.LiteralSchema<"string", undefined>;
182
+ readonly data: v.StringSchema<undefined>;
183
+ }, undefined>, v.ObjectSchema<{
184
+ readonly type: v.LiteralSchema<"file", undefined>;
185
+ readonly data: v.StringSchema<undefined>;
186
+ readonly mimeType: v.StringSchema<undefined>;
187
+ }, undefined>, v.ObjectSchema<{
188
+ readonly type: v.LiteralSchema<"inline_file", undefined>;
189
+ readonly data: v.UnionSchema<[v.FileSchema<undefined>, v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.Base64Action<string, undefined>]>, v.BlobSchema<undefined>], undefined>;
190
+ readonly mimeType: v.StringSchema<undefined>;
191
+ }, undefined>], undefined>;
192
+ readonly timestamp: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
193
+ }, undefined>, undefined>;
194
+ /**
195
+ * Optional title for the chat.
196
+ */
197
+ readonly title: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
198
+ /**
199
+ * creation timestamp(unix epoch)
200
+ */
201
+ readonly createdAt: v.OptionalSchema<v.NumberSchema<undefined>, () => number>;
202
+ /**
203
+ * Last updated timestamp(unix epoch)
204
+ */
205
+ readonly updatedAt: v.OptionalSchema<v.NumberSchema<undefined>, () => number>;
206
+ }, undefined>;
207
+
208
+ /**
209
+ * The condition for the lorebook to be activated.
210
+ * @see {@link LorebookConditionSchema}
211
+ */
212
+ export declare type LorebookCondition = v.InferOutput<typeof LorebookConditionSchema>;
213
+
214
+ /**
215
+ * @see {@link LorebookConditionSchema}
216
+ */
217
+ export declare const LorebookConditionDetailSchema: {
218
+ readonly regex: v.ObjectSchema<{
219
+ /**
220
+ * The type of the condition.
221
+ * This condition matches the regex pattern.
222
+ */
223
+ readonly type: v.LiteralSchema<"regex_match", undefined>;
224
+ /**
225
+ * The regex pattern to match.
226
+ * Note that this is scriptable.
227
+ */
228
+ readonly regexPattern: v.StringSchema<undefined>;
229
+ /**
230
+ * The regex flags to use.
231
+ * Note that this is not scriptable.
232
+ */
233
+ readonly regexFlags: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
234
+ }, undefined>;
235
+ readonly plainText: v.ObjectSchema<{
236
+ /**
237
+ * The type of the condition.
238
+ * This condition simply matches the text.
239
+ */
240
+ readonly type: v.LiteralSchema<"plain_text_match", undefined>;
241
+ /**
242
+ * The text to match.
243
+ * Note that this is scriptable.
244
+ * No case sensitive.
245
+ */
246
+ readonly text: v.StringSchema<undefined>;
247
+ }, undefined>;
248
+ readonly always: v.ObjectSchema<{
249
+ /**
250
+ * The type of the condition.
251
+ * This condition is always true.
252
+ */
253
+ readonly type: v.LiteralSchema<"always", undefined>;
254
+ }, undefined>;
255
+ };
256
+
257
+ /**
258
+ * The condition for the lorebook to be activated.
259
+ */
260
+ export declare const LorebookConditionSchema: v.VariantSchema<"type", [v.ObjectSchema<{
261
+ /**
262
+ * The type of the condition.
263
+ * This condition matches the regex pattern.
264
+ */
265
+ readonly type: v.LiteralSchema<"regex_match", undefined>;
266
+ /**
267
+ * The regex pattern to match.
268
+ * Note that this is scriptable.
269
+ */
270
+ readonly regexPattern: v.StringSchema<undefined>;
271
+ /**
272
+ * The regex flags to use.
273
+ * Note that this is not scriptable.
274
+ */
275
+ readonly regexFlags: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
276
+ }, undefined>, v.ObjectSchema<{
277
+ /**
278
+ * The type of the condition.
279
+ * This condition simply matches the text.
280
+ */
281
+ readonly type: v.LiteralSchema<"plain_text_match", undefined>;
282
+ /**
283
+ * The text to match.
284
+ * Note that this is scriptable.
285
+ * No case sensitive.
286
+ */
287
+ readonly text: v.StringSchema<undefined>;
288
+ }, undefined>, v.ObjectSchema<{
289
+ /**
290
+ * The type of the condition.
291
+ * This condition is always true.
292
+ */
293
+ readonly type: v.LiteralSchema<"always", undefined>;
294
+ }, undefined>], undefined>;
295
+
296
+ /**
297
+ * Object containing all data for the lorebook.
298
+ * It's meant to be stored in the database and many other places.
299
+ */
300
+ export declare type LorebookData = v.InferOutput<typeof LorebookDataSchema>;
301
+
302
+ /**
303
+ * @see {@link LorebookData}
304
+ */
305
+ export declare const LorebookDataSchema: v.ObjectSchema<{
306
+ /**
307
+ * The configuration for the lorebook.
308
+ * It is not scriptable.
309
+ */
310
+ readonly config: v.ObjectSchema<{
311
+ /**
312
+ * The token limit for the lorebook.
313
+ * When the token limit is exceeded, some low-priority lorebooks will be deactivated to keep the token usage within the limit.
314
+ * Positive integer.
315
+ */
316
+ readonly tokenLimit: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
317
+ }, undefined>;
318
+ /**
319
+ * Contains the actual lorebooks.
320
+ * Duplicated id is not allowed.
321
+ */
322
+ readonly data: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
323
+ /**
324
+ * Internally generated ID.
325
+ */
326
+ readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
327
+ /**
328
+ * Human readable name for the lorebook.
329
+ */
330
+ readonly name: v.StringSchema<undefined>;
331
+ /**
332
+ * The condition for the lorebook to be activated.
333
+ * If empty, it will not be activated.
334
+ * Duplicated condition is no effect.
335
+ * Use 'always' to activate without any condition. {@link LorebookConditionTypeMap#always}
336
+ */
337
+ readonly condition: v.OptionalSchema<v.ArraySchema<v.CustomSchema<{
338
+ type: "regex_match";
339
+ regexPattern: string;
340
+ regexFlags?: string | undefined;
341
+ } | {
342
+ type: "plain_text_match";
343
+ text: string;
344
+ } | {
345
+ type: "always";
346
+ }, undefined>, undefined>, undefined>;
347
+ /**
348
+ * The strategy for resolving multiple conditions.
349
+ * "all" means all conditions must be met.
350
+ * "any" means at least one condition must be met.
351
+ */
352
+ readonly multipleConditionResolveStrategy: v.OptionalSchema<v.PicklistSchema<["all", "any"], undefined>, undefined>;
353
+ /**
354
+ * The lorebook content to be added on AI prompt.
355
+ * Not for human reading, and it's scriptable.
356
+ */
357
+ readonly content: v.StringSchema<undefined>;
358
+ /**
359
+ * The priority of the lorebook.
360
+ * Higher priority means it will be activated first, remains when token limit is exceeded.
361
+ * May be negative. Base is 0. Allows demical.
362
+ */
363
+ readonly priority: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
364
+ /**
365
+ * Whether the lorebook is enabled.
366
+ */
367
+ readonly enabled: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
368
+ }, undefined>, undefined>, v.CheckAction<{
369
+ id?: string | undefined;
370
+ name: string;
371
+ condition?: ({
372
+ type: "regex_match";
373
+ regexPattern: string;
374
+ regexFlags?: string | undefined;
375
+ } | {
376
+ type: "plain_text_match";
377
+ text: string;
378
+ } | {
379
+ type: "always";
380
+ })[] | undefined;
381
+ multipleConditionResolveStrategy?: "all" | "any" | undefined;
382
+ content: string;
383
+ priority?: number | undefined;
384
+ enabled?: boolean | undefined;
385
+ }[], "Duplicated id is not allowed.">]>, readonly []>;
386
+ }, undefined>;
387
+
388
+ /**
389
+ * A lorebook is a collection of lorebooks.
390
+ * Lorebook is a small part of prompts which is activated by session's text matching.
391
+ */
392
+ export declare type LorebookEntry = v.InferOutput<typeof LorebookEntrySchema>;
393
+
394
+ /**
395
+ * @see {@link LorebookEntry}
396
+ */
397
+ export declare const LorebookEntrySchema: v.ObjectSchema<{
398
+ /**
399
+ * Internally generated ID.
400
+ */
401
+ readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
402
+ /**
403
+ * Human readable name for the lorebook.
404
+ */
405
+ readonly name: v.StringSchema<undefined>;
406
+ /**
407
+ * The condition for the lorebook to be activated.
408
+ * If empty, it will not be activated.
409
+ * Duplicated condition is no effect.
410
+ * Use 'always' to activate without any condition. {@link LorebookConditionTypeMap#always}
411
+ */
412
+ readonly condition: v.OptionalSchema<v.ArraySchema<v.CustomSchema<{
413
+ type: "regex_match";
414
+ regexPattern: string;
415
+ regexFlags?: string | undefined;
416
+ } | {
417
+ type: "plain_text_match";
418
+ text: string;
419
+ } | {
420
+ type: "always";
421
+ }, undefined>, undefined>, undefined>;
422
+ /**
423
+ * The strategy for resolving multiple conditions.
424
+ * "all" means all conditions must be met.
425
+ * "any" means at least one condition must be met.
426
+ */
427
+ readonly multipleConditionResolveStrategy: v.OptionalSchema<v.PicklistSchema<["all", "any"], undefined>, undefined>;
428
+ /**
429
+ * The lorebook content to be added on AI prompt.
430
+ * Not for human reading, and it's scriptable.
431
+ */
432
+ readonly content: v.StringSchema<undefined>;
433
+ /**
434
+ * The priority of the lorebook.
435
+ * Higher priority means it will be activated first, remains when token limit is exceeded.
436
+ * May be negative. Base is 0. Allows demical.
437
+ */
438
+ readonly priority: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
439
+ /**
440
+ * Whether the lorebook is enabled.
441
+ */
442
+ readonly enabled: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
443
+ }, undefined>;
444
+
445
+ /**
446
+ * Represents a single message in a chat history.
447
+ */
448
+ export declare type Message = v.InferOutput<typeof MessageSchema>;
449
+
450
+ /**
451
+ * @see {@link Message}
452
+ */
453
+ export declare const MessageSchema: v.ObjectSchema<{
454
+ /** Unique identifier for the message. */
455
+ readonly id: v.StringSchema<undefined>;
456
+ /** The role of the message sender. */
457
+ readonly role: v.UnionSchema<[v.LiteralSchema<"user", undefined>, v.LiteralSchema<"assistant", undefined>, v.LiteralSchema<"system", undefined>], undefined>;
458
+ /** The content of the message. */
459
+ readonly content: v.VariantSchema<"type", [v.ObjectSchema<{
460
+ /**
461
+ * string: The message content is a simple string.
462
+ */
463
+ readonly type: v.LiteralSchema<"string", undefined>;
464
+ /**
465
+ * The message content.
466
+ */
467
+ readonly data: v.StringSchema<undefined>;
468
+ }, undefined>, v.ObjectSchema<{
469
+ /**
470
+ * file: The file content is stored in the separated storage.
471
+ */
472
+ readonly type: v.LiteralSchema<"file", undefined>;
473
+ /**
474
+ * URL of the file. May be absolute or relative, or even uuid.
475
+ * Client should handle the actual file loading.
476
+ * Don't use base64 encoded file. Instead, use with type:"inline_file".
477
+ */
478
+ readonly data: v.StringSchema<undefined>;
479
+ /**
480
+ * MIME type of the file.
481
+ */
482
+ readonly mimeType: v.StringSchema<undefined>;
483
+ }, undefined>, v.ObjectSchema<{
484
+ /**
485
+ * inline_file: The file content is embedded in the message.
486
+ */
487
+ readonly type: v.LiteralSchema<"inline_file", undefined>;
488
+ /**
489
+ * File content. May be base64 encoded or file, or blob.
490
+ * It's good to use url with type:"file" instead, to avoid getting too large message.
491
+ */
492
+ readonly data: v.UnionSchema<[v.FileSchema<undefined>, v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.Base64Action<string, undefined>]>, v.BlobSchema<undefined>], undefined>;
493
+ /**
494
+ * MIME type of the file.
495
+ */
496
+ readonly mimeType: v.StringSchema<undefined>;
497
+ }, undefined>], undefined>;
498
+ /** The timestamp when the message was created. */
499
+ readonly timestamp: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
500
+ }, undefined>;
501
+
502
+ /**
503
+ * Represents the role of the message sender.
504
+ */
505
+ export declare const RoleSchema: v.UnionSchema<[v.LiteralSchema<"user", undefined>, v.LiteralSchema<"assistant", undefined>, v.LiteralSchema<"system", undefined>], undefined>;
506
+
507
+ export { }
package/dist/v0.js ADDED
@@ -0,0 +1,99 @@
1
+ import { a as s, C as l, b as c, c as m, d as p, L as b } from "./Character-Didq99iq.js";
2
+ import * as e from "valibot";
3
+ const a = e.union([
4
+ e.literal("user"),
5
+ e.literal("assistant"),
6
+ e.literal("system")
7
+ ]), t = {
8
+ text: e.object({
9
+ /**
10
+ * string: The message content is a simple string.
11
+ */
12
+ type: e.literal("string"),
13
+ /**
14
+ * The message content.
15
+ */
16
+ data: e.string()
17
+ }),
18
+ file: e.object({
19
+ /**
20
+ * file: The file content is stored in the separated storage.
21
+ */
22
+ type: e.literal("file"),
23
+ /**
24
+ * URL of the file. May be absolute or relative, or even uuid.
25
+ * Client should handle the actual file loading.
26
+ * Don't use base64 encoded file. Instead, use with type:"inline_file".
27
+ */
28
+ data: e.string(),
29
+ /**
30
+ * MIME type of the file.
31
+ */
32
+ mimeType: e.string()
33
+ }),
34
+ inline_file: e.object({
35
+ /**
36
+ * inline_file: The file content is embedded in the message.
37
+ */
38
+ type: e.literal("inline_file"),
39
+ /**
40
+ * File content. May be base64 encoded or file, or blob.
41
+ * It's good to use url with type:"file" instead, to avoid getting too large message.
42
+ */
43
+ data: e.union([e.file(), e.pipe(e.string(), e.base64()), e.blob()]),
44
+ /**
45
+ * MIME type of the file.
46
+ */
47
+ mimeType: e.string()
48
+ })
49
+ }, i = e.object({
50
+ /** Unique identifier for the message. */
51
+ id: e.string(),
52
+ /** The role of the message sender. */
53
+ role: a,
54
+ /** The content of the message. */
55
+ content: e.variant("type", [
56
+ t.text,
57
+ t.file,
58
+ t.inline_file
59
+ ]),
60
+ /** The timestamp when the message was created. */
61
+ timestamp: e.optional(e.number())
62
+ }), o = e.object({
63
+ /**
64
+ * Unique identifier for the chat session.
65
+ */
66
+ id: e.string(),
67
+ /**
68
+ * The ID of the character associated with this chat.
69
+ */
70
+ characterId: e.string(),
71
+ /**
72
+ * The list of messages in this chat.
73
+ */
74
+ messages: e.array(i),
75
+ /**
76
+ * Optional title for the chat.
77
+ */
78
+ title: e.optional(e.string()),
79
+ /**
80
+ * creation timestamp(unix epoch)
81
+ */
82
+ createdAt: e.optional(e.number(), Date.now),
83
+ /**
84
+ * Last updated timestamp(unix epoch)
85
+ */
86
+ updatedAt: e.optional(e.number(), Date.now)
87
+ });
88
+ export {
89
+ s as CharacterPromptDataSchema,
90
+ l as CharacterSchema,
91
+ o as ChatSchema,
92
+ c as LorebookConditionDetailSchema,
93
+ m as LorebookConditionSchema,
94
+ p as LorebookDataSchema,
95
+ b as LorebookEntrySchema,
96
+ i as MessageSchema,
97
+ a as RoleSchema
98
+ };
99
+ //# sourceMappingURL=v0.js.map
package/dist/v0.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v0.js","sources":["../src/types/v0/Message.ts","../src/types/v0/Chat.ts"],"sourcesContent":["import * as v from \"valibot\";\n\n/**\n * Represents the role of the message sender.\n */\nexport const RoleSchema = v.union([\n v.literal(\"user\"),\n v.literal(\"assistant\"),\n v.literal(\"system\"),\n]);\n\nconst MessageContentSchema = {\n text: v.object({\n /**\n * string: The message content is a simple string.\n */\n type: v.literal(\"string\"),\n /**\n * The message content.\n */\n data: v.string(),\n }),\n file: v.object({\n /**\n * file: The file content is stored in the separated storage.\n */\n type: v.literal(\"file\"),\n /**\n * URL of the file. May be absolute or relative, or even uuid.\n * Client should handle the actual file loading.\n * Don't use base64 encoded file. Instead, use with type:\"inline_file\".\n */\n data: v.string(),\n /**\n * MIME type of the file.\n */\n mimeType: v.string(),\n }),\n inline_file: v.object({\n /**\n * inline_file: The file content is embedded in the message.\n */\n type: v.literal(\"inline_file\"),\n /**\n * File content. May be base64 encoded or file, or blob.\n * It's good to use url with type:\"file\" instead, to avoid getting too large message.\n */\n data: v.union([v.file(), v.pipe(v.string(), v.base64()), v.blob()]),\n /**\n * MIME type of the file.\n */\n mimeType: v.string(),\n }),\n};\n\n/**\n * @see {@link Message}\n */\nexport const MessageSchema = v.object({\n /** Unique identifier for the message. */\n id: v.string(),\n /** The role of the message sender. */\n role: RoleSchema,\n /** The content of the message. */\n content: v.variant(\"type\", [\n MessageContentSchema.text,\n MessageContentSchema.file,\n MessageContentSchema.inline_file,\n ]),\n /** The timestamp when the message was created. */\n timestamp: v.optional(v.number()),\n});\n\n/**\n * Represents a single message in a chat history.\n */\nexport type Message = v.InferOutput<typeof MessageSchema>;\n","import * as v from \"valibot\";\nimport { MessageSchema } from \"@/types/v0/Message\";\n\n/**\n * @see {@link Chat}\n */\nexport const ChatSchema = v.object({\n /**\n * Unique identifier for the chat session.\n */\n id: v.string(),\n /**\n * The ID of the character associated with this chat.\n */\n characterId: v.string(),\n /**\n * The list of messages in this chat.\n */\n messages: v.array(MessageSchema),\n /**\n * Optional title for the chat.\n */\n title: v.optional(v.string()),\n /**\n * creation timestamp(unix epoch)\n */\n createdAt: v.optional(v.number(), Date.now),\n /**\n * Last updated timestamp(unix epoch)\n */\n updatedAt: v.optional(v.number(), Date.now),\n});\n\n/**\n * Represents a chat session with a character.\n */\nexport type Chat = v.InferOutput<typeof ChatSchema>;\n"],"names":["RoleSchema","v","MessageContentSchema","MessageSchema","ChatSchema"],"mappings":";;AAKO,MAAMA,IAAaC,EAAE,MAAM;AAAA,EAC9BA,EAAE,QAAQ,MAAM;AAAA,EAChBA,EAAE,QAAQ,WAAW;AAAA,EACrBA,EAAE,QAAQ,QAAQ;AACtB,CAAC,GAEKC,IAAuB;AAAA,EACzB,MAAMD,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA,IAIX,MAAMA,EAAE,QAAQ,QAAQ;AAAA;AAAA;AAAA;AAAA,IAIxB,MAAMA,EAAE,OAAA;AAAA,EAAO,CAClB;AAAA,EACD,MAAMA,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA,IAIX,MAAMA,EAAE,QAAQ,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMtB,MAAMA,EAAE,OAAA;AAAA;AAAA;AAAA;AAAA,IAIR,UAAUA,EAAE,OAAA;AAAA,EAAO,CACtB;AAAA,EACD,aAAaA,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA,IAIlB,MAAMA,EAAE,QAAQ,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA,IAK7B,MAAMA,EAAE,MAAM,CAACA,EAAE,KAAA,GAAQA,EAAE,KAAKA,EAAE,OAAA,GAAUA,EAAE,OAAA,CAAQ,GAAGA,EAAE,KAAA,CAAM,CAAC;AAAA;AAAA;AAAA;AAAA,IAIlE,UAAUA,EAAE,OAAA;AAAA,EAAO,CACtB;AACL,GAKaE,IAAgBF,EAAE,OAAO;AAAA;AAAA,EAElC,IAAIA,EAAE,OAAA;AAAA;AAAA,EAEN,MAAMD;AAAA;AAAA,EAEN,SAASC,EAAE,QAAQ,QAAQ;AAAA,IACvBC,EAAqB;AAAA,IACrBA,EAAqB;AAAA,IACrBA,EAAqB;AAAA,EAAA,CACxB;AAAA;AAAA,EAED,WAAWD,EAAE,SAASA,EAAE,QAAQ;AACpC,CAAC,GCjEYG,IAAaH,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA,EAI/B,IAAIA,EAAE,OAAA;AAAA;AAAA;AAAA;AAAA,EAIN,aAAaA,EAAE,OAAA;AAAA;AAAA;AAAA;AAAA,EAIf,UAAUA,EAAE,MAAME,CAAa;AAAA;AAAA;AAAA;AAAA,EAI/B,OAAOF,EAAE,SAASA,EAAE,QAAQ;AAAA;AAAA;AAAA;AAAA,EAI5B,WAAWA,EAAE,SAASA,EAAE,OAAA,GAAU,KAAK,GAAG;AAAA;AAAA;AAAA;AAAA,EAI1C,WAAWA,EAAE,SAASA,EAAE,OAAA,GAAU,KAAK,GAAG;AAC9C,CAAC;"}
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@arisutalk/character-spec",
3
+ "description": "Character specification, schema & migration for ArisuTalk",
4
+ "version": "0.0.0",
5
+ "contributors": [
6
+ {
7
+ "name": "concertypin",
8
+ "url": "https://github.com/concertypin"
9
+ }
10
+ ],
11
+ "repository": "github:arisutalk/character-spec",
12
+ "license": "Apache-2.0",
13
+ "engines": {
14
+ "node": ">=22"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "main": "dist/index.js",
20
+ "types": "dist/index.d.ts",
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "type": "module",
25
+ "scripts": {
26
+ "build": "vite build",
27
+ "prepare": "pnpm exec simple-git-hooks",
28
+ "format": "biome format --write .",
29
+ "lint": "biome check ."
30
+ },
31
+ "peerDependencies": {
32
+ "valibot": "^1.2.0"
33
+ },
34
+ "devDependencies": {
35
+ "@biomejs/biome": "^2.3.5",
36
+ "lint-staged": "^16.2.6",
37
+ "simple-git-hooks": "^2.13.1",
38
+ "typescript": "^5.9.3",
39
+ "valibot": "^1.2.0",
40
+ "vite": "^6.4.1",
41
+ "vite-plugin-dts": "^4.5.4",
42
+ "vite-tsconfig-paths": "^5.1.4"
43
+ },
44
+ "exports": {
45
+ ".": {
46
+ "import": "./dist/index.js",
47
+ "types": "./dist/index.d.ts"
48
+ },
49
+ "./v0": {
50
+ "import": "./dist/v0.js",
51
+ "types": "./dist/v0.d.ts"
52
+ }
53
+ },
54
+ "packageManager": "pnpm@10.16.1+sha512.0e155aa2629db8672b49e8475da6226aa4bdea85fdcdfdc15350874946d4f3c91faaf64cbdc4a5d1ab8002f473d5c3fcedcd197989cf0390f9badd3c04678706"
55
+ }