xiaozhi-client 2.3.1-beta.2 → 2.3.1-beta.4
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/README.md +6 -3
- package/dist/backend/WebServer.js +5 -5
- package/dist/backend/WebServerLauncher.js +1 -1
- package/dist/backend/{config-CQI3gsre.js → config-CtLjYTic.js} +10 -102
- package/dist/backend/config-CtLjYTic.js.map +1 -0
- package/dist/backend/{internal-mcp-manager-CE7FUsCF.js → internal-mcp-manager-B_XaJQHT.js} +2 -2
- package/dist/backend/{internal-mcp-manager-CE7FUsCF.js.map → internal-mcp-manager-B_XaJQHT.js.map} +1 -1
- package/dist/cli/index.js +25 -136
- package/dist/cli/index.js.map +1 -1
- package/package.json +1 -2
- package/dist/backend/config-CQI3gsre.js.map +0 -1
- package/dist/cli/templates/json5/package.json +0 -9
- package/dist/cli/templates/json5/prompts/default.md +0 -3
- package/dist/cli/templates/json5/xiaozhi.config.json5 +0 -59
- package/dist/cli/templates/jsonc/package.json +0 -9
- package/dist/cli/templates/jsonc/prompts/default.md +0 -3
- package/dist/cli/templates/jsonc/xiaozhi.config.jsonc +0 -59
- package/templates/json5/package.json +0 -9
- package/templates/json5/prompts/default.md +0 -3
- package/templates/json5/xiaozhi.config.json5 +0 -59
- package/templates/jsonc/package.json +0 -9
- package/templates/jsonc/prompts/default.md +0 -3
- package/templates/jsonc/xiaozhi.config.jsonc +0 -59
package/README.md
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
<br />
|
|
2
1
|
<div align="center">
|
|
3
|
-
<
|
|
2
|
+
<br />
|
|
3
|
+
<br />
|
|
4
|
+
<img src="logo.svg" alt="Xiaozhi Client" width="400" height="100" />
|
|
5
|
+
<br />
|
|
6
|
+
<br />
|
|
7
|
+
<br />
|
|
4
8
|
</div>
|
|
5
|
-
<br />
|
|
6
9
|
|
|
7
10
|
<div align="center">
|
|
8
11
|
<a href="https://www.npmjs.com/package/xiaozhi-client" target="_blank"><img src="https://img.shields.io/npm/v/xiaozhi-client" alt="npm version" /></a>
|
|
@@ -2,7 +2,7 @@ import { createRequire } from 'node:module';
|
|
|
2
2
|
globalThis.require = createRequire(import.meta.url);
|
|
3
3
|
|
|
4
4
|
import { a as __toESM, i as __reExport, n as __exportAll, r as __name, t as __commonJSMin } from "./chunk-Dn3sj6vE.js";
|
|
5
|
-
import { a as MCPConnection, c as configManager, n as isModelScopeURL, o as TypeFieldNormalizer, r as normalizeServiceConfig, s as ensureToolJSONSchema$1 } from "./config-
|
|
5
|
+
import { a as MCPConnection, c as configManager, n as isModelScopeURL, o as TypeFieldNormalizer, r as normalizeServiceConfig, s as ensureToolJSONSchema$1 } from "./config-CtLjYTic.js";
|
|
6
6
|
import { logger } from "./Logger.js";
|
|
7
7
|
import { createServer } from "node:http";
|
|
8
8
|
import { serve } from "@hono/node-server";
|
|
@@ -166,7 +166,7 @@ var Endpoint = class Endpoint {
|
|
|
166
166
|
* ```
|
|
167
167
|
*/
|
|
168
168
|
static async create(config) {
|
|
169
|
-
const { InternalMCPManagerAdapter } = await import("./internal-mcp-manager-
|
|
169
|
+
const { InternalMCPManagerAdapter } = await import("./internal-mcp-manager-B_XaJQHT.js");
|
|
170
170
|
const internalMCPManager = new InternalMCPManagerAdapter({
|
|
171
171
|
mcpServers: config.mcpServers,
|
|
172
172
|
reconnectDelay: config.reconnectDelay
|
|
@@ -11652,7 +11652,7 @@ var UpdateApiHandler = class extends BaseHandler {
|
|
|
11652
11652
|
* 如果构建时能读取到 package.json,则为真实版本号
|
|
11653
11653
|
* 否则为占位符,运行时从 package.json 读取
|
|
11654
11654
|
*/
|
|
11655
|
-
const VERSION = "2.3.1-beta.
|
|
11655
|
+
const VERSION = "2.3.1-beta.4";
|
|
11656
11656
|
const APP_NAME = "xiaozhi-client";
|
|
11657
11657
|
/**
|
|
11658
11658
|
* 版本工具类
|
|
@@ -11667,7 +11667,7 @@ var VersionUtils = class VersionUtils {
|
|
|
11667
11667
|
* 如果是占位符,则运行时从 package.json 读取
|
|
11668
11668
|
*/
|
|
11669
11669
|
static getVersion() {
|
|
11670
|
-
if ("2.3.1-beta.
|
|
11670
|
+
if ("2.3.1-beta.4" === "__VERSION__") return VersionUtils.getRuntimeVersion();
|
|
11671
11671
|
return VERSION;
|
|
11672
11672
|
}
|
|
11673
11673
|
/**
|
|
@@ -11675,7 +11675,7 @@ var VersionUtils = class VersionUtils {
|
|
|
11675
11675
|
*/
|
|
11676
11676
|
static getVersionInfo() {
|
|
11677
11677
|
if (VersionUtils.cachedVersionInfo) return VersionUtils.cachedVersionInfo;
|
|
11678
|
-
if ("2.3.1-beta.
|
|
11678
|
+
if ("2.3.1-beta.4" === "__VERSION__") {
|
|
11679
11679
|
VersionUtils.cachedVersionInfo = VersionUtils.getRuntimeVersionInfo();
|
|
11680
11680
|
return VersionUtils.cachedVersionInfo;
|
|
11681
11681
|
}
|
|
@@ -11,7 +11,7 @@ import { r as __name } from "./chunk-Dn3sj6vE.js";
|
|
|
11
11
|
*/
|
|
12
12
|
async function importModules() {
|
|
13
13
|
const webServerModule = await import("./WebServer.js");
|
|
14
|
-
const configModule = await import("./config-
|
|
14
|
+
const configModule = await import("./config-CtLjYTic.js").then((n) => n.t);
|
|
15
15
|
const loggerModule = await import("./Logger.js");
|
|
16
16
|
return {
|
|
17
17
|
WebServer: webServerModule.WebServer,
|
|
@@ -5,7 +5,6 @@ import { n as __exportAll, r as __name } from "./chunk-Dn3sj6vE.js";
|
|
|
5
5
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
6
6
|
import path, { dirname, isAbsolute, resolve } from "node:path";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
|
-
import * as commentJson from "comment-json";
|
|
9
8
|
import dayjs from "dayjs";
|
|
10
9
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
11
10
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
@@ -14,40 +13,6 @@ import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/
|
|
|
14
13
|
import { EventSource } from "eventsource";
|
|
15
14
|
import { EventEmitter } from "node:events";
|
|
16
15
|
|
|
17
|
-
//#region ../config/json5-adapter.ts
|
|
18
|
-
/**
|
|
19
|
-
* JSON5 注释保留适配器
|
|
20
|
-
* 使用 comment-json 实现 JSON5/JSONC 注释保留功能
|
|
21
|
-
*
|
|
22
|
-
* 注意:为了使用 comment-json 保留注释,JSON5 配置文件的键需要带引号。
|
|
23
|
-
* 这与 JSON5 标准语法允许不带引号的键略有不同,但能实现注释保留功能。
|
|
24
|
-
*/
|
|
25
|
-
/**
|
|
26
|
-
* 创建 JSON5 写入器适配器
|
|
27
|
-
* @param content 原始 JSON5 内容字符串
|
|
28
|
-
* @returns Json5WriterAdapter 实例
|
|
29
|
-
*/
|
|
30
|
-
function createJson5Writer(content) {
|
|
31
|
-
const parsedData = commentJson.parse(content);
|
|
32
|
-
return {
|
|
33
|
-
write(data) {
|
|
34
|
-
if (parsedData && typeof parsedData === "object" && data) Object.assign(parsedData, data);
|
|
35
|
-
},
|
|
36
|
-
toSource() {
|
|
37
|
-
return commentJson.stringify(parsedData, null, 2);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* 解析 JSON5 内容(带注释保留)
|
|
43
|
-
* @param content JSON5 内容字符串
|
|
44
|
-
* @returns 解析后的对象
|
|
45
|
-
*/
|
|
46
|
-
function parseJson5(content) {
|
|
47
|
-
return commentJson.parse(content);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
//#endregion
|
|
51
16
|
//#region ../config/resolver.ts
|
|
52
17
|
/**
|
|
53
18
|
* 配置解析器
|
|
@@ -86,17 +51,13 @@ var ConfigResolver = class ConfigResolver {
|
|
|
86
51
|
/**
|
|
87
52
|
* 在指定目录中查找配置文件
|
|
88
53
|
*
|
|
89
|
-
*
|
|
54
|
+
* 查找配置文件:xiaozhi.config.json
|
|
90
55
|
*
|
|
91
56
|
* @param dir - 要搜索的目录
|
|
92
57
|
* @returns 找到的配置文件路径,如果不存在则返回 null
|
|
93
58
|
*/
|
|
94
59
|
static findConfigInDir(dir) {
|
|
95
|
-
for (const fileName of [
|
|
96
|
-
"xiaozhi.config.json5",
|
|
97
|
-
"xiaozhi.config.jsonc",
|
|
98
|
-
"xiaozhi.config.json"
|
|
99
|
-
]) {
|
|
60
|
+
for (const fileName of ["xiaozhi.config.json"]) {
|
|
100
61
|
const filePath = path.join(dir, fileName);
|
|
101
62
|
if (existsSync(filePath)) return filePath;
|
|
102
63
|
}
|
|
@@ -120,7 +81,7 @@ var ConfigResolver = class ConfigResolver {
|
|
|
120
81
|
* 配置管理器
|
|
121
82
|
*
|
|
122
83
|
* 核心配置管理模块,负责:
|
|
123
|
-
* - 配置文件的读取和解析(支持 JSON
|
|
84
|
+
* - 配置文件的读取和解析(支持 JSON 格式)
|
|
124
85
|
* - 配置验证和类型检查
|
|
125
86
|
* - 配置更新和持久化
|
|
126
87
|
* - 配置变更事件通知
|
|
@@ -168,7 +129,6 @@ var ConfigManager = class ConfigManager {
|
|
|
168
129
|
defaultConfigPath;
|
|
169
130
|
config = null;
|
|
170
131
|
currentConfigPath = null;
|
|
171
|
-
json5Writer = null;
|
|
172
132
|
statsUpdateLocks = /* @__PURE__ */ new Map();
|
|
173
133
|
statsUpdateLockTimeouts = /* @__PURE__ */ new Map();
|
|
174
134
|
STATS_UPDATE_TIMEOUT = 5e3;
|
|
@@ -197,7 +157,7 @@ var ConfigManager = class ConfigManager {
|
|
|
197
157
|
}
|
|
198
158
|
/**
|
|
199
159
|
* 获取配置文件路径(动态计算)
|
|
200
|
-
*
|
|
160
|
+
* 支持配置文件格式:json
|
|
201
161
|
*
|
|
202
162
|
* 查找优先级:
|
|
203
163
|
* 1. 环境变量 XIAOZHI_CONFIG_DIR 指定的目录
|
|
@@ -212,14 +172,6 @@ var ConfigManager = class ConfigManager {
|
|
|
212
172
|
return resolve(process.env.XIAOZHI_CONFIG_DIR || process.cwd(), "xiaozhi.config.json");
|
|
213
173
|
}
|
|
214
174
|
/**
|
|
215
|
-
* 获取配置文件格式
|
|
216
|
-
*/
|
|
217
|
-
getConfigFileFormat(filePath) {
|
|
218
|
-
if (filePath.endsWith(".json5")) return "json5";
|
|
219
|
-
if (filePath.endsWith(".jsonc")) return "jsonc";
|
|
220
|
-
return "json";
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
175
|
* 获取配置管理器单例实例
|
|
224
176
|
*/
|
|
225
177
|
static getInstance() {
|
|
@@ -239,16 +191,14 @@ var ConfigManager = class ConfigManager {
|
|
|
239
191
|
}
|
|
240
192
|
/**
|
|
241
193
|
* 初始化配置文件
|
|
242
|
-
*
|
|
243
|
-
* @param format 配置文件格式,默认为 json
|
|
194
|
+
* 将默认模板配置复制到 xiaozhi.config.json
|
|
244
195
|
*/
|
|
245
|
-
initConfig(
|
|
196
|
+
initConfig() {
|
|
246
197
|
if (!existsSync(this.defaultConfigPath)) throw new Error(`默认配置模板文件不存在: ${this.defaultConfigPath}`);
|
|
247
198
|
if (this.configExists()) throw new Error("配置文件已存在,无需重复初始化");
|
|
248
|
-
const configPath = resolve(process.env.XIAOZHI_CONFIG_DIR || process.cwd(),
|
|
199
|
+
const configPath = resolve(process.env.XIAOZHI_CONFIG_DIR || process.cwd(), "xiaozhi.config.json");
|
|
249
200
|
copyFileSync(this.defaultConfigPath, configPath);
|
|
250
201
|
this.config = null;
|
|
251
|
-
this.json5Writer = null;
|
|
252
202
|
}
|
|
253
203
|
/**
|
|
254
204
|
* 加载配置文件
|
|
@@ -265,21 +215,8 @@ var ConfigManager = class ConfigManager {
|
|
|
265
215
|
try {
|
|
266
216
|
const configPath = this.getConfigFilePath();
|
|
267
217
|
this.currentConfigPath = configPath;
|
|
268
|
-
const configFileFormat = this.getConfigFileFormat(configPath);
|
|
269
218
|
const configData = readFileSync(configPath, "utf8").replace(/^\uFEFF/, "");
|
|
270
|
-
|
|
271
|
-
switch (configFileFormat) {
|
|
272
|
-
case "json5":
|
|
273
|
-
config = parseJson5(configData);
|
|
274
|
-
this.json5Writer = createJson5Writer(configData);
|
|
275
|
-
break;
|
|
276
|
-
case "jsonc":
|
|
277
|
-
config = commentJson.parse(configData);
|
|
278
|
-
break;
|
|
279
|
-
default:
|
|
280
|
-
config = JSON.parse(configData);
|
|
281
|
-
break;
|
|
282
|
-
}
|
|
219
|
+
const config = JSON.parse(configData);
|
|
283
220
|
this.validateConfig(config);
|
|
284
221
|
return config;
|
|
285
222
|
} catch (error) {
|
|
@@ -542,35 +479,7 @@ var ConfigManager = class ConfigManager {
|
|
|
542
479
|
configPath = this.getConfigFilePath();
|
|
543
480
|
this.currentConfigPath = configPath;
|
|
544
481
|
}
|
|
545
|
-
const
|
|
546
|
-
let configContent;
|
|
547
|
-
switch (configFileFormat) {
|
|
548
|
-
case "json5":
|
|
549
|
-
try {
|
|
550
|
-
if (this.json5Writer) {
|
|
551
|
-
this.json5Writer.write(config);
|
|
552
|
-
configContent = this.json5Writer.toSource();
|
|
553
|
-
} else {
|
|
554
|
-
console.warn("没有 JSON5 适配器实例,使用 comment-json 序列化");
|
|
555
|
-
configContent = commentJson.stringify(config, null, 2);
|
|
556
|
-
}
|
|
557
|
-
} catch (json5Error) {
|
|
558
|
-
console.warn("使用 JSON5 适配器保存失败,回退到 comment-json 序列化:", json5Error);
|
|
559
|
-
configContent = commentJson.stringify(config, null, 2);
|
|
560
|
-
}
|
|
561
|
-
break;
|
|
562
|
-
case "jsonc":
|
|
563
|
-
try {
|
|
564
|
-
configContent = commentJson.stringify(config, null, 2);
|
|
565
|
-
} catch (commentJsonError) {
|
|
566
|
-
console.warn("使用 comment-json 保存失败,回退到标准 JSON 格式:", commentJsonError);
|
|
567
|
-
configContent = JSON.stringify(config, null, 2);
|
|
568
|
-
}
|
|
569
|
-
break;
|
|
570
|
-
default:
|
|
571
|
-
configContent = JSON.stringify(config, null, 2);
|
|
572
|
-
break;
|
|
573
|
-
}
|
|
482
|
+
const configContent = `${JSON.stringify(config, null, 2)}\n`;
|
|
574
483
|
writeFileSync(configPath, configContent, "utf8");
|
|
575
484
|
this.config = config;
|
|
576
485
|
console.log("配置保存成功");
|
|
@@ -589,7 +498,6 @@ var ConfigManager = class ConfigManager {
|
|
|
589
498
|
reloadConfig() {
|
|
590
499
|
this.config = null;
|
|
591
500
|
this.currentConfigPath = null;
|
|
592
|
-
this.json5Writer = null;
|
|
593
501
|
}
|
|
594
502
|
/**
|
|
595
503
|
* 获取配置文件路径
|
|
@@ -2348,4 +2256,4 @@ var config_exports = /* @__PURE__ */ __exportAll({
|
|
|
2348
2256
|
|
|
2349
2257
|
//#endregion
|
|
2350
2258
|
export { MCPConnection as a, configManager as c, MCPManager as i, isModelScopeURL as n, TypeFieldNormalizer as o, normalizeServiceConfig as r, ensureToolJSONSchema as s, config_exports as t };
|
|
2351
|
-
//# sourceMappingURL=config-
|
|
2259
|
+
//# sourceMappingURL=config-CtLjYTic.js.map
|