@xisui-pa/chatserver 0.0.0-stage → 1.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 +21 -0
- package/README.md +558 -2
- package/THIRD_PARTY_NOTICES.txt +179 -0
- package/dist/index.js +12295 -0
- package/dist/index.js.map +1 -0
- package/dist/models/chatserver-models.js +2740 -0
- package/dist/models/chatserver-models.js.map +1 -0
- package/package.json +67 -4
- package/schemas/config.schema.json +355 -0
- package/schemas/models.schema.json +103 -0
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "ChatServer configuration",
|
|
4
|
+
"description": "config.json for the built-in chat pipelines. Custom registered adapters and tools require extending this schema.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"properties": {
|
|
8
|
+
"$schema": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "Location of this JSON schema for editor validation and completion."
|
|
11
|
+
},
|
|
12
|
+
"chats": {
|
|
13
|
+
"type": "array",
|
|
14
|
+
"description": "Chat pipelines served by this process. An empty array runs no adapters.",
|
|
15
|
+
"default": [],
|
|
16
|
+
"items": {
|
|
17
|
+
"$ref": "#/definitions/chat"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"definitions": {
|
|
22
|
+
"localToolName": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"enum": ["web_search", "read_url", "calculate", "current_time", "read_image"]
|
|
25
|
+
},
|
|
26
|
+
"apiToolType": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"pattern": "^\\S+$",
|
|
29
|
+
"not": { "enum": ["function", "custom"] }
|
|
30
|
+
},
|
|
31
|
+
"nonEmptyString": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"pattern": "\\S"
|
|
34
|
+
},
|
|
35
|
+
"modelReference": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"pattern": "^[^\\s/](?:[^/]*[^\\s/])?/\\S(?:[\\s\\S]*\\S)?$",
|
|
38
|
+
"description": "<provider>/<model id>, using the provider name and model ID from models.json. Model IDs may contain additional slashes.",
|
|
39
|
+
"examples": [
|
|
40
|
+
"my-provider/my-model-id"
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
"duration": {
|
|
44
|
+
"type": "integer",
|
|
45
|
+
"minimum": 1,
|
|
46
|
+
"maximum": 2147483647
|
|
47
|
+
},
|
|
48
|
+
"chat": {
|
|
49
|
+
"type": "object",
|
|
50
|
+
"additionalProperties": false,
|
|
51
|
+
"required": [
|
|
52
|
+
"messager"
|
|
53
|
+
],
|
|
54
|
+
"properties": {
|
|
55
|
+
"messager": {
|
|
56
|
+
"$ref": "#/definitions/messager"
|
|
57
|
+
},
|
|
58
|
+
"stt": {
|
|
59
|
+
"$ref": "#/definitions/stt"
|
|
60
|
+
},
|
|
61
|
+
"tts": {
|
|
62
|
+
"$ref": "#/definitions/tts"
|
|
63
|
+
},
|
|
64
|
+
"filters": {
|
|
65
|
+
"type": "array",
|
|
66
|
+
"description": "Filters evaluated in order. Omit or use [] to delegate to the reply model without running filters.",
|
|
67
|
+
"default": [],
|
|
68
|
+
"items": {
|
|
69
|
+
"$ref": "#/definitions/filter"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"tts": {
|
|
75
|
+
"type": "object",
|
|
76
|
+
"additionalProperties": false,
|
|
77
|
+
"required": ["type", "model"],
|
|
78
|
+
"description": "Optional voice replies through an OpenAI-compatible audio/speech endpoint returning PCM/float WAV audio. Omit to use text replies only.",
|
|
79
|
+
"properties": {
|
|
80
|
+
"type": { "const": "model" },
|
|
81
|
+
"model": { "$ref": "#/definitions/modelReference" },
|
|
82
|
+
"options": {
|
|
83
|
+
"type": "object",
|
|
84
|
+
"description": "Provider speech fields such as voice, speed, instructions, or language. ChatServer controls model, input, response_format=wav, and stream_format=audio.",
|
|
85
|
+
"propertyNames": { "not": { "enum": ["model", "input", "response_format", "stream_format"] } },
|
|
86
|
+
"examples": [{ "voice": "alloy", "speed": 1 }]
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"stt": {
|
|
91
|
+
"type": "object",
|
|
92
|
+
"additionalProperties": false,
|
|
93
|
+
"required": ["type", "model"],
|
|
94
|
+
"description": "Optional speech-to-text settings. Omit the entire object to ignore voice input.",
|
|
95
|
+
"properties": {
|
|
96
|
+
"type": { "const": "model" },
|
|
97
|
+
"model": {
|
|
98
|
+
"description": "Required <provider>/<model id> for audio/transcriptions. There is no fallback to messager.replier.",
|
|
99
|
+
"allOf": [{ "$ref": "#/definitions/modelReference" }]
|
|
100
|
+
},
|
|
101
|
+
"audioConversionCmd": {
|
|
102
|
+
"type": "string",
|
|
103
|
+
"pattern": "^(?=[\\s\\S]*\\{input\\})(?=[\\s\\S]*\\{output\\})[\\s\\S]+$",
|
|
104
|
+
"description": "Optional shell command converting {input} to {output} as WAV. Runs in an isolated temporary directory; converter must be installed on the ChatServer machine. Without it, original audio is uploaded.",
|
|
105
|
+
"examples": ["ffmpeg -nostdin -y -i {input} -ar 16000 -ac 1 -c:a pcm_s16le {output}"]
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"messager": {
|
|
110
|
+
"type": "object",
|
|
111
|
+
"additionalProperties": false,
|
|
112
|
+
"required": [
|
|
113
|
+
"name",
|
|
114
|
+
"replier"
|
|
115
|
+
],
|
|
116
|
+
"properties": {
|
|
117
|
+
"name": {
|
|
118
|
+
"const": "wechat",
|
|
119
|
+
"description": "Registered transport. WeChat is the built-in implementation."
|
|
120
|
+
},
|
|
121
|
+
"replier": {
|
|
122
|
+
"$ref": "#/definitions/modelReference"
|
|
123
|
+
},
|
|
124
|
+
"memoryTokenLimit": {
|
|
125
|
+
"type": "integer",
|
|
126
|
+
"minimum": 100,
|
|
127
|
+
"maximum": 16000,
|
|
128
|
+
"default": 1000,
|
|
129
|
+
"description": "Per-conversation token budget for this pipeline's memory notes and confirmed replies, including their compact JSON metadata. Oldest entries are removed first; three-day retention still applies."
|
|
130
|
+
},
|
|
131
|
+
"persona": {
|
|
132
|
+
"description": "Optional replier identity, tone, and style as a nonempty string with one or more sentences; newlines are preserved. Omit for the default helpful assistant. Applies only to the replier; output-format and reply-length requirements still apply.",
|
|
133
|
+
"allOf": [{ "$ref": "#/definitions/nonEmptyString" }],
|
|
134
|
+
"examples": ["You are a warm, lightly humorous friend. Give practical photography advice. Keep your tone relaxed."]
|
|
135
|
+
},
|
|
136
|
+
"mainAccount": {
|
|
137
|
+
"description": "Exact sender ID authorized to use /status in a direct chat; usually wxid_..., not a display name.",
|
|
138
|
+
"allOf": [
|
|
139
|
+
{
|
|
140
|
+
"$ref": "#/definitions/nonEmptyString"
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
},
|
|
144
|
+
"localTools": {
|
|
145
|
+
"type": "array",
|
|
146
|
+
"description": "Application-managed tools, selected by name strings or objects containing only type. Omit to enable all built-ins; [] disables local tools. read_image enables conversation image caching and lookup for replies and model filters. Duplicate types are deduplicated.",
|
|
147
|
+
"default": [
|
|
148
|
+
"web_search",
|
|
149
|
+
"read_url",
|
|
150
|
+
"calculate",
|
|
151
|
+
"current_time",
|
|
152
|
+
"read_image"
|
|
153
|
+
],
|
|
154
|
+
"items": {
|
|
155
|
+
"oneOf": [
|
|
156
|
+
{ "$ref": "#/definitions/localToolName" },
|
|
157
|
+
{
|
|
158
|
+
"type": "object",
|
|
159
|
+
"required": ["type"],
|
|
160
|
+
"properties": {
|
|
161
|
+
"type": { "$ref": "#/definitions/localToolName" }
|
|
162
|
+
},
|
|
163
|
+
"additionalProperties": false
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
"apiTools": {
|
|
169
|
+
"type": "array",
|
|
170
|
+
"description": "Provider-hosted Responses API tools as type strings or definition objects with provider-specific options. Strings expand to objects with type. Omitted or [] enables none. The selected provider/model must support them; client-executed tools are not supported here.",
|
|
171
|
+
"default": [],
|
|
172
|
+
"items": {
|
|
173
|
+
"oneOf": [
|
|
174
|
+
{ "$ref": "#/definitions/apiToolType" },
|
|
175
|
+
{
|
|
176
|
+
"type": "object",
|
|
177
|
+
"required": ["type"],
|
|
178
|
+
"properties": {
|
|
179
|
+
"type": { "$ref": "#/definitions/apiToolType" }
|
|
180
|
+
},
|
|
181
|
+
"additionalProperties": true
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
"imageGeneration": {
|
|
187
|
+
"type": "boolean",
|
|
188
|
+
"description": "Enable provider-hosted image generation. Omit to enable when apiTools includes image_generation. True adds the hosted tool if missing; false removes it. Requires support from the replier's provider/model."
|
|
189
|
+
},
|
|
190
|
+
"imageWidthLimit": {
|
|
191
|
+
"type": "integer",
|
|
192
|
+
"minimum": 1,
|
|
193
|
+
"maximum": 16384,
|
|
194
|
+
"default": 1024,
|
|
195
|
+
"description": "Maximum generated image width in pixels. Combined with imageHeightLimit as the requested hosted-tool size unless a smaller concrete size is set in apiTools. The provider must support the requested dimensions. PNG output is required."
|
|
196
|
+
},
|
|
197
|
+
"imageHeightLimit": {
|
|
198
|
+
"type": "integer",
|
|
199
|
+
"minimum": 1,
|
|
200
|
+
"maximum": 16384,
|
|
201
|
+
"default": 1024,
|
|
202
|
+
"description": "Maximum generated image height in pixels. Combined with imageWidthLimit as the requested hosted-tool size unless a smaller concrete size is set in apiTools. The provider must support the requested dimensions. PNG output is required."
|
|
203
|
+
},
|
|
204
|
+
"dailyImageGenLimit": {
|
|
205
|
+
"type": "integer",
|
|
206
|
+
"minimum": 0,
|
|
207
|
+
"maximum": 9007199254740991,
|
|
208
|
+
"default": 10,
|
|
209
|
+
"description": "Daily image generation allowance shared by this messager's conversations. Zero disables generation. Usage is kept only in memory and resets on server restart or at server-local midnight; ambiguous provider failures consume quota."
|
|
210
|
+
},
|
|
211
|
+
"options": {
|
|
212
|
+
"$ref": "#/definitions/wechatOptions"
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
"wechatOptions": {
|
|
217
|
+
"type": "object",
|
|
218
|
+
"additionalProperties": false,
|
|
219
|
+
"properties": {
|
|
220
|
+
"baseUrl": {
|
|
221
|
+
"type": "string",
|
|
222
|
+
"format": "uri",
|
|
223
|
+
"pattern": "^https?://[^/?#@\\s]+(?:/[^?#\\s]*)?$",
|
|
224
|
+
"description": "agent-wechat HTTP(S) server root, without credentials, query, or fragment.",
|
|
225
|
+
"default": "http://127.0.0.1:6174"
|
|
226
|
+
},
|
|
227
|
+
"tokenEnv": {
|
|
228
|
+
"description": "Environment variable containing the bearer token; takes precedence over tokenFile.",
|
|
229
|
+
"default": "AGENT_WECHAT_TOKEN",
|
|
230
|
+
"allOf": [
|
|
231
|
+
{
|
|
232
|
+
"$ref": "#/definitions/nonEmptyString"
|
|
233
|
+
}
|
|
234
|
+
]
|
|
235
|
+
},
|
|
236
|
+
"tokenFile": {
|
|
237
|
+
"description": "Fallback bearer-token file. Relative paths resolve against the config directory; expand ~ yourself.",
|
|
238
|
+
"allOf": [
|
|
239
|
+
{
|
|
240
|
+
"$ref": "#/definitions/nonEmptyString"
|
|
241
|
+
}
|
|
242
|
+
]
|
|
243
|
+
},
|
|
244
|
+
"chatIds": {
|
|
245
|
+
"type": "array",
|
|
246
|
+
"description": "Chat IDs to monitor. Omit to monitor all chats; mainAccount is always included when configured.",
|
|
247
|
+
"items": {
|
|
248
|
+
"$ref": "#/definitions/nonEmptyString"
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
"pollIntervalMs": {
|
|
252
|
+
"description": "Delay after a completed poll, in milliseconds. Failed polls use exponential backoff.",
|
|
253
|
+
"default": 30000,
|
|
254
|
+
"allOf": [
|
|
255
|
+
{
|
|
256
|
+
"$ref": "#/definitions/duration"
|
|
257
|
+
}
|
|
258
|
+
]
|
|
259
|
+
},
|
|
260
|
+
"timeoutMs": {
|
|
261
|
+
"description": "Timeout for each WeChat REST request in milliseconds; independent of model timeouts.",
|
|
262
|
+
"default": 30000,
|
|
263
|
+
"allOf": [
|
|
264
|
+
{
|
|
265
|
+
"$ref": "#/definitions/duration"
|
|
266
|
+
}
|
|
267
|
+
]
|
|
268
|
+
},
|
|
269
|
+
"bundleGapMs": {
|
|
270
|
+
"type": "integer",
|
|
271
|
+
"minimum": 0,
|
|
272
|
+
"maximum": 2147483647,
|
|
273
|
+
"description": "Maximum timestamp gap between adjacent messages from the same sender, in milliseconds. Zero disables bundling.",
|
|
274
|
+
"default": 10000
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
"filter": {
|
|
279
|
+
"oneOf": [
|
|
280
|
+
{
|
|
281
|
+
"enum": [
|
|
282
|
+
"ignore",
|
|
283
|
+
"ignore-sender"
|
|
284
|
+
],
|
|
285
|
+
"description": "Shorthand ignore filter using the default <messager>_ignore file."
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
"$ref": "#/definitions/ignoreFilter"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"$ref": "#/definitions/modelFilter"
|
|
292
|
+
}
|
|
293
|
+
]
|
|
294
|
+
},
|
|
295
|
+
"ignoreFilter": {
|
|
296
|
+
"type": "object",
|
|
297
|
+
"additionalProperties": false,
|
|
298
|
+
"required": [
|
|
299
|
+
"type"
|
|
300
|
+
],
|
|
301
|
+
"properties": {
|
|
302
|
+
"type": {
|
|
303
|
+
"enum": [
|
|
304
|
+
"ignore",
|
|
305
|
+
"ignore-sender"
|
|
306
|
+
]
|
|
307
|
+
},
|
|
308
|
+
"options": {
|
|
309
|
+
"type": "object",
|
|
310
|
+
"additionalProperties": false,
|
|
311
|
+
"properties": {
|
|
312
|
+
"file": {
|
|
313
|
+
"type": "string",
|
|
314
|
+
"description": "Ignore-list file; defaults to <messager>_ignore in the config directory. Relative paths resolve against that directory."
|
|
315
|
+
},
|
|
316
|
+
"senderIds": {
|
|
317
|
+
"type": "array",
|
|
318
|
+
"description": "Inline sender IDs combined with the file's IDs. Ignored messages are excluded before buffering and model processing.",
|
|
319
|
+
"items": {
|
|
320
|
+
"type": "string"
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
"modelFilter": {
|
|
328
|
+
"type": "object",
|
|
329
|
+
"additionalProperties": false,
|
|
330
|
+
"required": [
|
|
331
|
+
"type",
|
|
332
|
+
"model"
|
|
333
|
+
],
|
|
334
|
+
"properties": {
|
|
335
|
+
"type": {
|
|
336
|
+
"const": "model"
|
|
337
|
+
},
|
|
338
|
+
"model": {
|
|
339
|
+
"$ref": "#/definitions/modelReference"
|
|
340
|
+
},
|
|
341
|
+
"options": {
|
|
342
|
+
"type": "object",
|
|
343
|
+
"additionalProperties": false,
|
|
344
|
+
"properties": {
|
|
345
|
+
"instructions": {
|
|
346
|
+
"type": "string",
|
|
347
|
+
"description": "Decision criteria for the filter model. Thinking is disabled for filter calls.",
|
|
348
|
+
"default": "Allow messages that would benefit from an assistant response. Otherwise abstain."
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "ChatServer model providers",
|
|
4
|
+
"description": "Non-secret provider and model settings in models.json. API keys belong in the OS credential manager or an environment override.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": [
|
|
8
|
+
"providers"
|
|
9
|
+
],
|
|
10
|
+
"properties": {
|
|
11
|
+
"$schema": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"description": "Location of this JSON schema for editor validation and completion."
|
|
14
|
+
},
|
|
15
|
+
"version": {
|
|
16
|
+
"const": 1,
|
|
17
|
+
"description": "File format version. Defaults to 1 when omitted.",
|
|
18
|
+
"default": 1
|
|
19
|
+
},
|
|
20
|
+
"providers": {
|
|
21
|
+
"type": "array",
|
|
22
|
+
"description": "Provider names must be unique. The application checks name uniqueness and config.json model references at runtime.",
|
|
23
|
+
"items": {
|
|
24
|
+
"$ref": "#/definitions/provider"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"definitions": {
|
|
29
|
+
"nonEmptyString": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"pattern": "\\S"
|
|
32
|
+
},
|
|
33
|
+
"provider": {
|
|
34
|
+
"type": "object",
|
|
35
|
+
"additionalProperties": false,
|
|
36
|
+
"required": [
|
|
37
|
+
"provider",
|
|
38
|
+
"baseUrl",
|
|
39
|
+
"models"
|
|
40
|
+
],
|
|
41
|
+
"properties": {
|
|
42
|
+
"provider": {
|
|
43
|
+
"description": "Provider name, also used as its credential-manager account and the prefix of <provider>/<model id> references.",
|
|
44
|
+
"allOf": [
|
|
45
|
+
{
|
|
46
|
+
"$ref": "#/definitions/nonEmptyString"
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
"baseUrl": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"format": "uri",
|
|
53
|
+
"pattern": "^https?://",
|
|
54
|
+
"description": "Required API base URL: Responses-compatible for chat models, audio/transcriptions-compatible for STT models. Omit endpoint suffixes such as /responses. There is no default."
|
|
55
|
+
},
|
|
56
|
+
"timeoutMs": {
|
|
57
|
+
"type": "integer",
|
|
58
|
+
"minimum": 1,
|
|
59
|
+
"maximum": 2147483647,
|
|
60
|
+
"description": "Timeout in milliseconds for this provider's model requests. For repliers with tools, also caps the complete model/tool cycle.",
|
|
61
|
+
"default": 180000
|
|
62
|
+
},
|
|
63
|
+
"models": {
|
|
64
|
+
"type": "array",
|
|
65
|
+
"description": "Models offered by this provider. Model names must be unique within the provider.",
|
|
66
|
+
"items": {
|
|
67
|
+
"$ref": "#/definitions/model"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"model": {
|
|
73
|
+
"type": "object",
|
|
74
|
+
"additionalProperties": false,
|
|
75
|
+
"required": [
|
|
76
|
+
"id"
|
|
77
|
+
],
|
|
78
|
+
"properties": {
|
|
79
|
+
"id": {
|
|
80
|
+
"description": "Model ID sent to the API and used after the first slash in config.json model references.",
|
|
81
|
+
"allOf": [
|
|
82
|
+
{
|
|
83
|
+
"$ref": "#/definitions/nonEmptyString"
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
"supportsImageToolResults": {
|
|
88
|
+
"type": "boolean",
|
|
89
|
+
"default": false,
|
|
90
|
+
"description": "Whether this model endpoint accepts native image content arrays in function_call_output. When true and read_image is available, chat images are referenced by ID and retrieved through that tool instead of attached to the initial prompt. If lookup is unavailable, direct attachments are used."
|
|
91
|
+
},
|
|
92
|
+
"name": {
|
|
93
|
+
"description": "CLI display/lookup name. Defaults to id when omitted.",
|
|
94
|
+
"allOf": [
|
|
95
|
+
{
|
|
96
|
+
"$ref": "#/definitions/nonEmptyString"
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|