xiaozhi-client 2.0.0 → 2.1.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/dist/backend/Logger.js +2 -2
- package/dist/backend/Logger.js.map +1 -1
- package/dist/backend/WebServer.js +20 -20
- package/dist/backend/WebServer.js.map +1 -1
- package/dist/backend/WebServerLauncher.js +19 -19
- package/dist/backend/WebServerLauncher.js.map +1 -1
- package/dist/backend/package.json +12 -6
- package/dist/backend/templates/default/prompts/default.md +3 -0
- package/dist/backend/templates/default/xiaozhi.config.json +17 -6
- package/dist/backend/templates/hello-world/prompts/default.md +3 -0
- package/dist/backend/templates/hello-world/xiaozhi.config.json +17 -0
- package/dist/backend/templates/json5/prompts/default.md +3 -0
- package/dist/backend/templates/json5/xiaozhi.config.json5 +18 -0
- package/dist/backend/templates/jsonc/prompts/default.md +3 -0
- package/dist/backend/templates/jsonc/xiaozhi.config.jsonc +18 -0
- package/dist/backend/templates/modelscope/prompts/default.md +3 -0
- package/dist/backend/templates/modelscope/xiaozhi.config.json +17 -0
- package/dist/cli/index.js +18 -12
- package/dist/cli/index.js.map +1 -1
- package/dist/config/index.d.ts +5 -6
- package/dist/config/index.js +23 -32
- package/dist/config/index.js.map +1 -1
- package/dist/frontend/assets/index-BAV6nu4X.js +81 -0
- package/dist/frontend/assets/index-BAV6nu4X.js.map +1 -0
- package/dist/frontend/assets/index-HDlbxheg.css +1 -0
- package/dist/frontend/assets/{react-vendor-nhjYH1qO.js → react-vendor-BPQojLhf.js} +13 -13
- package/dist/frontend/assets/react-vendor-BPQojLhf.js.map +1 -0
- package/dist/frontend/assets/{utils-OFMjZRUK.js → utils-BWIWSmq9.js} +2 -2
- package/dist/frontend/assets/{utils-OFMjZRUK.js.map → utils-BWIWSmq9.js.map} +1 -1
- package/dist/frontend/index.html +4 -4
- package/package.json +11 -11
- package/templates/default/prompts/default.md +3 -0
- package/templates/default/xiaozhi.config.json +17 -6
- package/templates/hello-world/prompts/default.md +3 -0
- package/templates/hello-world/xiaozhi.config.json +17 -0
- package/templates/json5/prompts/default.md +3 -0
- package/templates/json5/xiaozhi.config.json5 +18 -0
- package/templates/jsonc/prompts/default.md +3 -0
- package/templates/jsonc/xiaozhi.config.jsonc +18 -0
- package/templates/modelscope/prompts/default.md +3 -0
- package/templates/modelscope/xiaozhi.config.json +17 -0
- package/dist/frontend/assets/index-DWj2UcGy.css +0 -1
- package/dist/frontend/assets/index-HnebiJM5.js +0 -81
- package/dist/frontend/assets/index-HnebiJM5.js.map +0 -1
- package/dist/frontend/assets/react-vendor-nhjYH1qO.js.map +0 -1
- package/dist/shared-types/api-B5HunvHc.d.ts +0 -97
- package/dist/shared-types/api.d.ts +0 -204
- package/dist/shared-types/api.js +0 -50
- package/dist/shared-types/api.js.map +0 -1
- package/dist/shared-types/app-Ceijcsur.d.ts +0 -95
- package/dist/shared-types/chunk-BMOKIX3Q.js +0 -51
- package/dist/shared-types/chunk-BMOKIX3Q.js.map +0 -1
- package/dist/shared-types/config.d.ts +0 -97
- package/dist/shared-types/config.js +0 -1
- package/dist/shared-types/config.js.map +0 -1
- package/dist/shared-types/coze.d.ts +0 -31
- package/dist/shared-types/coze.js +0 -1
- package/dist/shared-types/coze.js.map +0 -1
- package/dist/shared-types/index.d.ts +0 -188
- package/dist/shared-types/index.js +0 -23
- package/dist/shared-types/index.js.map +0 -1
- package/dist/shared-types/mcp.d.ts +0 -93
- package/dist/shared-types/mcp.js +0 -31
- package/dist/shared-types/mcp.js.map +0 -1
- package/dist/shared-types/message-BrlYWzXV.d.ts +0 -154
- package/dist/shared-types/schema-Bs4SCukS.d.ts +0 -25
- package/dist/shared-types/timeout-D1mc0P3r.d.ts +0 -39
- package/dist/shared-types/tool-definition-B6f-mWPy.d.ts +0 -93
- package/dist/shared-types/toolApi-D-G8Chst.d.ts +0 -200
- package/dist/shared-types/utils.d.ts +0 -115
- package/dist/shared-types/utils.js +0 -15
- package/dist/shared-types/utils.js.map +0 -1
- package/dist/shared-types/workflow-Dl-hsNZK.d.ts +0 -86
package/dist/config/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { MCPTransportType } from '@xiaozhi-client/mcp-core';
|
|
2
|
+
export { MCPTransportType } from '@xiaozhi-client/mcp-core';
|
|
3
|
+
|
|
1
4
|
interface LocalMCPServerConfig {
|
|
2
5
|
command: string;
|
|
3
6
|
args: string[];
|
|
@@ -236,6 +239,7 @@ declare class ConfigManager {
|
|
|
236
239
|
validateConfig(config: unknown): void;
|
|
237
240
|
/**
|
|
238
241
|
* 获取配置(只读)
|
|
242
|
+
* 使用缓存机制避免频繁的文件 I/O 操作
|
|
239
243
|
*/
|
|
240
244
|
getConfig(): Readonly<AppConfig>;
|
|
241
245
|
/**
|
|
@@ -597,11 +601,6 @@ declare const configManager: ConfigManager;
|
|
|
597
601
|
declare class ConfigValidationError extends Error {
|
|
598
602
|
constructor(message: string);
|
|
599
603
|
}
|
|
600
|
-
declare enum MCPTransportType {
|
|
601
|
-
STDIO = "stdio",
|
|
602
|
-
SSE = "sse",
|
|
603
|
-
HTTP = "http"
|
|
604
|
-
}
|
|
605
604
|
interface MCPServiceConfig {
|
|
606
605
|
type: MCPTransportType;
|
|
607
606
|
command?: string;
|
|
@@ -702,4 +701,4 @@ declare class ConfigInitializer {
|
|
|
702
701
|
private static getDefaultTemplateDir;
|
|
703
702
|
}
|
|
704
703
|
|
|
705
|
-
export { type ASRConfig, type AppConfig, type ChainHandlerConfig, ConfigInitializer, ConfigManager, ConfigResolver, ConfigValidationError, type ConnectionConfig, type CozePlatformConfig, type CustomMCPConfig, type CustomMCPTool, type FunctionHandlerConfig, type HTTPMCPServerConfig, type HandlerConfig, type HttpHandlerConfig, type LLMConfig, type LocalMCPServerConfig, type MCPHandlerConfig, type MCPServerConfig, type MCPServerToolsConfig, type MCPServiceConfig, type MCPToolConfig,
|
|
704
|
+
export { type ASRConfig, type AppConfig, type ChainHandlerConfig, ConfigInitializer, ConfigManager, ConfigResolver, ConfigValidationError, type ConnectionConfig, type CozePlatformConfig, type CustomMCPConfig, type CustomMCPTool, type FunctionHandlerConfig, type HTTPMCPServerConfig, type HandlerConfig, type HttpHandlerConfig, type LLMConfig, type LocalMCPServerConfig, type MCPHandlerConfig, type MCPServerConfig, type MCPServerToolsConfig, type MCPServiceConfig, type MCPToolConfig, type ModelScopeConfig, type PlatformConfig, type PlatformsConfig, type ProxyHandlerConfig, type SSEMCPServerConfig, type ScriptHandlerConfig, type StreamableHTTPMCPServerConfig, type TTSConfig, type ToolCallLogConfig, type WebServerInstance, type WebUIConfig, configManager, getConfigTypeDescription, isModelScopeURL, normalizeServiceConfig, normalizeServiceConfigBatch };
|
package/dist/config/index.js
CHANGED
|
@@ -320,10 +320,13 @@ var ConfigManager = class _ConfigManager {
|
|
|
320
320
|
}
|
|
321
321
|
/**
|
|
322
322
|
* 获取配置(只读)
|
|
323
|
+
* 使用缓存机制避免频繁的文件 I/O 操作
|
|
323
324
|
*/
|
|
324
325
|
getConfig() {
|
|
325
|
-
this.config
|
|
326
|
-
|
|
326
|
+
if (!this.config) {
|
|
327
|
+
this.config = this.loadConfig();
|
|
328
|
+
}
|
|
329
|
+
return structuredClone(this.config);
|
|
327
330
|
}
|
|
328
331
|
/**
|
|
329
332
|
* 获取可修改的配置对象(内部使用,保留注释信息)
|
|
@@ -544,6 +547,15 @@ var ConfigManager = class _ConfigManager {
|
|
|
544
547
|
config.platforms[platformName] = platformConfig;
|
|
545
548
|
}
|
|
546
549
|
}
|
|
550
|
+
if ("asr" in newConfig) {
|
|
551
|
+
config.asr = newConfig.asr;
|
|
552
|
+
}
|
|
553
|
+
if ("tts" in newConfig) {
|
|
554
|
+
config.tts = newConfig.tts;
|
|
555
|
+
}
|
|
556
|
+
if ("llm" in newConfig) {
|
|
557
|
+
config.llm = newConfig.llm;
|
|
558
|
+
}
|
|
547
559
|
this.saveConfig(config);
|
|
548
560
|
this.emitEvent("config:updated", {
|
|
549
561
|
type: "config",
|
|
@@ -1622,6 +1634,7 @@ var configManager = ConfigManager.getInstance();
|
|
|
1622
1634
|
|
|
1623
1635
|
// src/adapter.ts
|
|
1624
1636
|
import { dirname as dirname2, isAbsolute, resolve as resolve2 } from "path";
|
|
1637
|
+
import { MCPTransportType, inferTransportTypeFromUrl } from "@xiaozhi-client/mcp-core";
|
|
1625
1638
|
var ConfigValidationError = class extends Error {
|
|
1626
1639
|
static {
|
|
1627
1640
|
__name(this, "ConfigValidationError");
|
|
@@ -1631,28 +1644,6 @@ var ConfigValidationError = class extends Error {
|
|
|
1631
1644
|
this.name = "ConfigValidationError";
|
|
1632
1645
|
}
|
|
1633
1646
|
};
|
|
1634
|
-
var MCPTransportType = /* @__PURE__ */ ((MCPTransportType2) => {
|
|
1635
|
-
MCPTransportType2["STDIO"] = "stdio";
|
|
1636
|
-
MCPTransportType2["SSE"] = "sse";
|
|
1637
|
-
MCPTransportType2["HTTP"] = "http";
|
|
1638
|
-
return MCPTransportType2;
|
|
1639
|
-
})(MCPTransportType || {});
|
|
1640
|
-
function inferTransportTypeFromUrl(url) {
|
|
1641
|
-
try {
|
|
1642
|
-
const parsedUrl = new URL(url);
|
|
1643
|
-
const pathname = parsedUrl.pathname;
|
|
1644
|
-
if (pathname.endsWith("/sse")) {
|
|
1645
|
-
return "sse" /* SSE */;
|
|
1646
|
-
}
|
|
1647
|
-
if (pathname.endsWith("/mcp")) {
|
|
1648
|
-
return "http" /* HTTP */;
|
|
1649
|
-
}
|
|
1650
|
-
return "http" /* HTTP */;
|
|
1651
|
-
} catch (error) {
|
|
1652
|
-
return "http" /* HTTP */;
|
|
1653
|
-
}
|
|
1654
|
-
}
|
|
1655
|
-
__name(inferTransportTypeFromUrl, "inferTransportTypeFromUrl");
|
|
1656
1647
|
function normalizeServiceConfig(config) {
|
|
1657
1648
|
console.log("\u8F6C\u6362\u914D\u7F6E", { config });
|
|
1658
1649
|
try {
|
|
@@ -1691,7 +1682,7 @@ function convertByConfigType(config) {
|
|
|
1691
1682
|
throw new ConfigValidationError("\u7F51\u7EDC\u914D\u7F6E\u5FC5\u987B\u5305\u542B\u6709\u6548\u7684 url \u5B57\u6BB5");
|
|
1692
1683
|
}
|
|
1693
1684
|
const inferredType = inferTransportTypeFromUrl(config.url || "");
|
|
1694
|
-
if (inferredType ===
|
|
1685
|
+
if (inferredType === MCPTransportType.SSE) {
|
|
1695
1686
|
const sseConfig = { ...config, type: "sse" };
|
|
1696
1687
|
return convertSSEConfig(sseConfig);
|
|
1697
1688
|
}
|
|
@@ -1738,7 +1729,7 @@ function convertLocalConfig(config) {
|
|
|
1738
1729
|
return arg;
|
|
1739
1730
|
});
|
|
1740
1731
|
return {
|
|
1741
|
-
type:
|
|
1732
|
+
type: MCPTransportType.STDIO,
|
|
1742
1733
|
command: resolvedCommand,
|
|
1743
1734
|
args: resolvedArgs,
|
|
1744
1735
|
...env !== void 0 && { env }
|
|
@@ -1753,7 +1744,7 @@ function convertSSEConfig(config) {
|
|
|
1753
1744
|
const url = config.url;
|
|
1754
1745
|
const type = "type" in config ? config.type : void 0;
|
|
1755
1746
|
const headers = "headers" in config ? config.headers : void 0;
|
|
1756
|
-
const inferredType = type === "sse" ?
|
|
1747
|
+
const inferredType = type === "sse" ? MCPTransportType.SSE : inferTransportTypeFromUrl(url || "");
|
|
1757
1748
|
const isModelScope = url ? isModelScopeURL(url) : false;
|
|
1758
1749
|
console.log("SSE\u914D\u7F6E\u8F6C\u6362", {
|
|
1759
1750
|
url,
|
|
@@ -1774,7 +1765,7 @@ function convertHTTPConfig(config) {
|
|
|
1774
1765
|
const url = config.url;
|
|
1775
1766
|
const headers = "headers" in config ? config.headers : void 0;
|
|
1776
1767
|
return {
|
|
1777
|
-
type:
|
|
1768
|
+
type: MCPTransportType.HTTP,
|
|
1778
1769
|
url: url || "",
|
|
1779
1770
|
headers
|
|
1780
1771
|
};
|
|
@@ -1839,17 +1830,17 @@ function validateNewConfig(config) {
|
|
|
1839
1830
|
throw new ConfigValidationError("\u4F20\u8F93\u7C7B\u578B\u672A\u6307\u5B9A\uFF0C\u8BF7\u68C0\u67E5\u914D\u7F6E\u6216\u542F\u7528\u81EA\u52A8\u63A8\u65AD");
|
|
1840
1831
|
}
|
|
1841
1832
|
switch (config.type) {
|
|
1842
|
-
case
|
|
1833
|
+
case MCPTransportType.STDIO:
|
|
1843
1834
|
if (!config.command) {
|
|
1844
1835
|
throw new ConfigValidationError("STDIO \u914D\u7F6E\u5FC5\u987B\u5305\u542B command \u5B57\u6BB5");
|
|
1845
1836
|
}
|
|
1846
1837
|
break;
|
|
1847
|
-
case
|
|
1838
|
+
case MCPTransportType.SSE:
|
|
1848
1839
|
if (config.url === void 0 || config.url === null) {
|
|
1849
1840
|
throw new ConfigValidationError("SSE \u914D\u7F6E\u5FC5\u987B\u5305\u542B url \u5B57\u6BB5");
|
|
1850
1841
|
}
|
|
1851
1842
|
break;
|
|
1852
|
-
case
|
|
1843
|
+
case MCPTransportType.HTTP:
|
|
1853
1844
|
if (config.url === void 0 || config.url === null) {
|
|
1854
1845
|
throw new ConfigValidationError("HTTP \u914D\u7F6E\u5FC5\u987B\u5305\u542B url \u5B57\u6BB5");
|
|
1855
1846
|
}
|
|
@@ -1873,7 +1864,7 @@ function getConfigTypeDescription(config) {
|
|
|
1873
1864
|
}
|
|
1874
1865
|
const inferredType = inferTransportTypeFromUrl(config.url);
|
|
1875
1866
|
const isModelScope = isModelScopeURL(config.url);
|
|
1876
|
-
if (inferredType ===
|
|
1867
|
+
if (inferredType === MCPTransportType.SSE) {
|
|
1877
1868
|
return `SSE${isModelScope ? " (ModelScope)" : ""} (${config.url})`;
|
|
1878
1869
|
}
|
|
1879
1870
|
return `HTTP (${config.url})`;
|