xiaozhi-client 1.9.4-beta.1 → 1.9.4-beta.11
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 +3 -0
- package/dist/backend/Logger.js.map +1 -0
- package/dist/backend/WebServer.js +93 -0
- package/dist/backend/WebServer.js.map +1 -0
- package/dist/backend/WebServerLauncher.js +11 -17
- package/dist/backend/WebServerLauncher.js.map +1 -1
- package/dist/backend/managers/MCPServiceManagerSingleton.js +27 -0
- package/dist/backend/managers/MCPServiceManagerSingleton.js.map +1 -0
- package/dist/backend/package.json +28 -52
- package/dist/backend/templates/json5/xiaozhi.config.json5 +14 -14
- package/dist/cli/index.js +29 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/config/index.js +2 -0
- package/dist/config/index.js.map +1 -0
- package/dist/frontend/assets/index-88NfCOo9.js.map +1 -1
- package/dist/shared-types/api-aP8BHcbg.d.ts +97 -0
- package/dist/shared-types/api.d.ts +202 -0
- package/dist/shared-types/api.js +50 -0
- package/dist/shared-types/api.js.map +1 -0
- package/dist/shared-types/app-oAmColIN.d.ts +91 -0
- package/dist/shared-types/chunk-BMOKIX3Q.js +51 -0
- package/dist/shared-types/chunk-BMOKIX3Q.js.map +1 -0
- package/dist/shared-types/config.d.ts +97 -0
- package/dist/shared-types/config.js +1 -0
- package/dist/shared-types/config.js.map +1 -0
- package/dist/shared-types/coze.d.ts +30 -0
- package/dist/shared-types/coze.js +1 -0
- package/dist/shared-types/coze.js.map +1 -0
- package/dist/shared-types/index.d.ts +186 -0
- package/dist/shared-types/index.js +4 -17
- package/dist/shared-types/index.js.map +1 -1
- package/dist/shared-types/mcp.d.ts +91 -0
- package/dist/shared-types/mcp.js +22 -0
- package/dist/shared-types/mcp.js.map +1 -0
- package/dist/shared-types/message-xoOM7ZuT.d.ts +154 -0
- package/dist/shared-types/timeout-CCp_IFHg.d.ts +39 -0
- package/dist/shared-types/toolApi-DYSy8ebd.d.ts +208 -0
- package/dist/shared-types/utils.d.ts +115 -0
- package/dist/shared-types/utils.js +15 -0
- package/dist/shared-types/utils.js.map +1 -0
- package/dist/shared-types/workflow-DDqq5Jgp.d.ts +83 -0
- package/package.json +28 -52
- package/templates/json5/xiaozhi.config.json5 +14 -14
- package/dist/backend/WebServerLauncher.d.ts +0 -1
- package/dist/backend/cli.d.ts +0 -1
- package/dist/backend/cli.js +0 -129
- package/dist/backend/cli.js.map +0 -1
- package/dist/cli.js +0 -2
- package/dist/docs/404/index.html +0 -19
- package/dist/docs/404.html +0 -19
- package/dist/docs/_next/static/JZ0ESgtaHnsqkxSabOqqU/_buildManifest.js +0 -1
- package/dist/docs/_next/static/JZ0ESgtaHnsqkxSabOqqU/_ssgManifest.js +0 -1
- package/dist/docs/_next/static/chunks/112-c9cbd8401d35f825.js +0 -4
- package/dist/docs/_next/static/chunks/2a9bc5d7-4c434acf20ba934a.js +0 -1
- package/dist/docs/_next/static/chunks/782-c26ca6c69e488d48.js +0 -1
- package/dist/docs/_next/static/chunks/799-fe0d35806fd12012.js +0 -1
- package/dist/docs/_next/static/chunks/9b1cb2c3-cc9ed703e6aef1a2.js +0 -1
- package/dist/docs/_next/static/chunks/app/[[...mdxPath]]/page-48f5c8f3210e0a8a.js +0 -1
- package/dist/docs/_next/static/chunks/app/_not-found/page-2e38866a1cbb77e4.js +0 -1
- package/dist/docs/_next/static/chunks/app/layout-e8f420537fd59e8d.js +0 -1
- package/dist/docs/_next/static/chunks/framework-b73126dabbf07067.js +0 -1
- package/dist/docs/_next/static/chunks/main-75dc65850b89d90d.js +0 -1
- package/dist/docs/_next/static/chunks/main-app-3303134270964ce6.js +0 -1
- package/dist/docs/_next/static/chunks/pages/_app-e698a68d07c8993d.js +0 -1
- package/dist/docs/_next/static/chunks/pages/_error-189a41ab5833da03.js +0 -1
- package/dist/docs/_next/static/chunks/polyfills-42372ed130431b0a.js +0 -1
- package/dist/docs/_next/static/chunks/webpack-10e2bf7d852ddb6e.js +0 -1
- package/dist/docs/_next/static/css/2d82b615fcca1590.css +0 -1
- package/dist/docs/_next/static/css/b03484a3c350cf6e.css +0 -1
- package/dist/docs/_next/static/css/b289318ef4b60b0a.css +0 -1
- package/dist/docs/_next/static/media/get-parameter.62eee93d.png +0 -0
- package/dist/docs/changelog/index.html +0 -585
- package/dist/docs/changelog/index.txt +0 -1079
- package/dist/docs/images/add-to-cherry-studio/step-1.png +0 -0
- package/dist/docs/images/add-to-cherry-studio/step-2.png +0 -0
- package/dist/docs/images/add-to-cherry-studio/step-3.png +0 -0
- package/dist/docs/images/add-to-cherry-studio/step-4.png +0 -0
- package/dist/docs/images/add-to-cherry-studio/step-5.png +0 -0
- package/dist/docs/images/add-to-cursor/step-1.png +0 -0
- package/dist/docs/images/add-to-cursor/step-2.png +0 -0
- package/dist/docs/images/add-to-cursor/step-3.png +0 -0
- package/dist/docs/images/coze-workflow/config-workflow-step-1.png +0 -0
- package/dist/docs/images/coze-workflow/config-workflow-step-2.png +0 -0
- package/dist/docs/images/coze-workflow/config-workflow-step-3.png +0 -0
- package/dist/docs/images/coze-workflow/get-parameter.png +0 -0
- package/dist/docs/images/integrate-to-cherry-studio.png +0 -0
- package/dist/docs/images/integrate-to-cursor.png +0 -0
- package/dist/docs/images/modelscope/step-1.png +0 -0
- package/dist/docs/images/modelscope/step-2.png +0 -0
- package/dist/docs/images/modelscope/step-3.png +0 -0
- package/dist/docs/images/modelscope/step-4.png +0 -0
- package/dist/docs/images/preview.png +0 -0
- package/dist/docs/images/use-multi-xiaozhi-mcp-endpoints/step-1.png +0 -0
- package/dist/docs/images/use-multi-xiaozhi-mcp-endpoints/step-2.png +0 -0
- package/dist/docs/images/use-multi-xiaozhi-mcp-endpoints/step-3.png +0 -0
- package/dist/docs/images/use-multi-xiaozhi-mcp-endpoints/step-4.png +0 -0
- package/dist/docs/images/use-multi-xiaozhi-mcp-endpoints/step-5.png +0 -0
- package/dist/docs/images/web-ui-preview.png +0 -0
- package/dist/docs/index.html +0 -22
- package/dist/docs/index.txt +0 -41
- package/dist/docs/quickstart/index.html +0 -64
- package/dist/docs/quickstart/index.txt +0 -185
- package/dist/docs/reference/command/index.html +0 -20
- package/dist/docs/reference/command/index.txt +0 -42
- package/dist/docs/usage/as-mcp/index.html +0 -36
- package/dist/docs/usage/as-mcp/index.txt +0 -101
- package/dist/docs/usage/coze-workflow/index.html +0 -35
- package/dist/docs/usage/coze-workflow/index.txt +0 -120
- package/dist/docs/usage/docker/index.html +0 -40
- package/dist/docs/usage/docker/index.txt +0 -154
- package/dist/docs/usage/modelscope/index.html +0 -32
- package/dist/docs/usage/modelscope/index.txt +0 -109
- package/dist/docs/usage/multi-endpoint/index.html +0 -32
- package/dist/docs/usage/multi-endpoint/index.txt +0 -118
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
export { a as CozeApiResponse, C as CozeWorkspace } from './api-aP8BHcbg.js';
|
|
2
|
+
import { C as CozeWorkflow } from './workflow-DDqq5Jgp.js';
|
|
3
|
+
export { a as CozeWorkflowCreator, c as CozeWorkflowsParams, W as WorkflowParameter, b as WorkflowParameterConfig } from './workflow-DDqq5Jgp.js';
|
|
4
|
+
export { a as EnhancedToolResultCache, E as ExtendedMCPToolsCache, c as MCPError, M as MCPMessage, b as MCPResponse, T as TaskStatus } from './message-xoOM7ZuT.js';
|
|
5
|
+
export { M as MCPToolData, T as ToolType } from './toolApi-DYSy8ebd.js';
|
|
6
|
+
import { M as MCPServerConfig } from './app-oAmColIN.js';
|
|
7
|
+
export { A as AppConfig, C as ConnectionConfig, L as LocalMCPServerConfig, b as MCPServerToolsConfig, a as MCPToolConfig, c as ModelScopeConfig, d as PlatformConfig, P as PlatformsConfig, S as SSEMCPServerConfig, e as StreamableHTTPMCPServerConfig, W as WebUIConfig } from './app-oAmColIN.js';
|
|
8
|
+
export { T as TimeoutError } from './timeout-CCp_IFHg.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 前端UI状态相关类型定义
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 扣子工作流列表响应
|
|
16
|
+
*/
|
|
17
|
+
interface CozeWorkflowsResult {
|
|
18
|
+
/** 工作流列表 */
|
|
19
|
+
items: CozeWorkflow[];
|
|
20
|
+
/** 是否有更多数据 */
|
|
21
|
+
hasMore: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 前端UI状态类型
|
|
25
|
+
*/
|
|
26
|
+
interface CozeUIState {
|
|
27
|
+
/** 当前选中的工作空间ID */
|
|
28
|
+
selectedWorkspaceId: string | null;
|
|
29
|
+
/** 工作空间列表加载状态 */
|
|
30
|
+
workspacesLoading: boolean;
|
|
31
|
+
/** 工作流列表加载状态 */
|
|
32
|
+
workflowsLoading: boolean;
|
|
33
|
+
/** 工作空间列表错误信息 */
|
|
34
|
+
workspacesError: string | null;
|
|
35
|
+
/** 工作流列表错误信息 */
|
|
36
|
+
workflowsError: string | null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 客户端状态
|
|
40
|
+
*/
|
|
41
|
+
interface ClientStatus {
|
|
42
|
+
status: "connected" | "disconnected";
|
|
43
|
+
mcpEndpoint: string;
|
|
44
|
+
activeMCPServers: string[];
|
|
45
|
+
lastHeartbeat?: number;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 前端API响应相关类型定义
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* MCP 服务添加请求接口(单服务格式)
|
|
54
|
+
*/
|
|
55
|
+
interface MCPServerAddRequest {
|
|
56
|
+
name: string;
|
|
57
|
+
config: MCPServerConfig;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* MCP 服务批量添加请求接口(mcpServers 格式)
|
|
61
|
+
*/
|
|
62
|
+
interface MCPServerBatchAddRequest {
|
|
63
|
+
mcpServers: Record<string, MCPServerConfig>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* MCP 服务添加操作结果
|
|
67
|
+
*/
|
|
68
|
+
interface MCPServerAddResult {
|
|
69
|
+
name: string;
|
|
70
|
+
success: boolean;
|
|
71
|
+
error?: string;
|
|
72
|
+
config?: MCPServerConfig;
|
|
73
|
+
tools?: string[];
|
|
74
|
+
status?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* MCP 服务批量添加响应
|
|
78
|
+
*/
|
|
79
|
+
interface MCPServerBatchAddResponse {
|
|
80
|
+
success: boolean;
|
|
81
|
+
message: string;
|
|
82
|
+
results: MCPServerAddResult[];
|
|
83
|
+
addedCount: number;
|
|
84
|
+
failedCount: number;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* MCP 服务状态接口
|
|
88
|
+
*/
|
|
89
|
+
interface MCPServerStatus {
|
|
90
|
+
name: string;
|
|
91
|
+
status: "connected" | "disconnected" | "connecting" | "error";
|
|
92
|
+
connected: boolean;
|
|
93
|
+
tools: string[];
|
|
94
|
+
lastUpdated?: string;
|
|
95
|
+
config: MCPServerConfig;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* MCP 服务列表响应接口
|
|
99
|
+
*/
|
|
100
|
+
interface MCPServerListResponse {
|
|
101
|
+
servers: MCPServerStatus[];
|
|
102
|
+
total: number;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* API 统一响应格式接口
|
|
106
|
+
*/
|
|
107
|
+
interface ApiSuccessResponse<T = any> {
|
|
108
|
+
success: boolean;
|
|
109
|
+
data?: T;
|
|
110
|
+
message?: string;
|
|
111
|
+
}
|
|
112
|
+
interface ApiErrorResponse {
|
|
113
|
+
error: {
|
|
114
|
+
code: string;
|
|
115
|
+
message: string;
|
|
116
|
+
details?: {
|
|
117
|
+
serverName?: string;
|
|
118
|
+
config?: any;
|
|
119
|
+
tools?: string[];
|
|
120
|
+
timestamp: string;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* API 错误码枚举
|
|
126
|
+
*/
|
|
127
|
+
declare enum MCPErrorCode {
|
|
128
|
+
SERVER_NOT_FOUND = "SERVER_NOT_FOUND",
|
|
129
|
+
SERVER_ALREADY_EXISTS = "SERVER_ALREADY_EXISTS",
|
|
130
|
+
INVALID_SERVICE_NAME = "INVALID_SERVICE_NAME",
|
|
131
|
+
INVALID_CONFIG = "INVALID_CONFIG",
|
|
132
|
+
CONFIG_UPDATE_FAILED = "CONFIG_UPDATE_FAILED",
|
|
133
|
+
CONNECTION_FAILED = "CONNECTION_FAILED",
|
|
134
|
+
ADD_FAILED = "ADD_FAILED",
|
|
135
|
+
REMOVE_FAILED = "REMOVE_FAILED",
|
|
136
|
+
INTERNAL_ERROR = "INTERNAL_ERROR",
|
|
137
|
+
VALIDATION_ERROR = "VALIDATION_ERROR"
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* 工具调用记录
|
|
141
|
+
*/
|
|
142
|
+
interface ToolCallRecord {
|
|
143
|
+
/** 工具名称 */
|
|
144
|
+
toolName: string;
|
|
145
|
+
/** 原始工具名称(如果有的话) */
|
|
146
|
+
originalToolName?: string;
|
|
147
|
+
/** 服务器名称 */
|
|
148
|
+
serverName?: string;
|
|
149
|
+
/** 调用参数 */
|
|
150
|
+
arguments?: any;
|
|
151
|
+
/** 调用结果 */
|
|
152
|
+
result?: any;
|
|
153
|
+
/** 是否成功 */
|
|
154
|
+
success: boolean;
|
|
155
|
+
/** 调用耗时(毫秒) */
|
|
156
|
+
duration?: number;
|
|
157
|
+
/** 错误信息 */
|
|
158
|
+
error?: string;
|
|
159
|
+
/** 时间戳 */
|
|
160
|
+
timestamp?: number;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* 工具调用日志响应
|
|
164
|
+
*/
|
|
165
|
+
interface ToolCallLogsResponse {
|
|
166
|
+
/** 日志记录列表 */
|
|
167
|
+
records: ToolCallRecord[];
|
|
168
|
+
/** 总数量 */
|
|
169
|
+
total: number;
|
|
170
|
+
/** 是否有更多数据 */
|
|
171
|
+
hasMore: boolean;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* API通用响应格式
|
|
175
|
+
*/
|
|
176
|
+
interface ApiResponse<T = any> {
|
|
177
|
+
success: boolean;
|
|
178
|
+
data?: T;
|
|
179
|
+
error?: {
|
|
180
|
+
code: string;
|
|
181
|
+
message: string;
|
|
182
|
+
details?: any;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export { type ApiErrorResponse, type ApiResponse, type ApiSuccessResponse, type ClientStatus, type CozeUIState, CozeWorkflow, type CozeWorkflowsResult, MCPErrorCode, type MCPServerAddRequest, type MCPServerAddResult, type MCPServerBatchAddRequest, type MCPServerBatchAddResponse, MCPServerConfig, type MCPServerListResponse, type MCPServerStatus, type ToolCallLogsResponse, type ToolCallRecord };
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TimeoutError
|
|
3
|
+
} from "./chunk-BMOKIX3Q.js";
|
|
4
|
+
|
|
1
5
|
// src/frontend/api.ts
|
|
2
6
|
var MCPErrorCode = /* @__PURE__ */ ((MCPErrorCode2) => {
|
|
3
7
|
MCPErrorCode2["SERVER_NOT_FOUND"] = "SERVER_NOT_FOUND";
|
|
@@ -12,23 +16,6 @@ var MCPErrorCode = /* @__PURE__ */ ((MCPErrorCode2) => {
|
|
|
12
16
|
MCPErrorCode2["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
13
17
|
return MCPErrorCode2;
|
|
14
18
|
})(MCPErrorCode || {});
|
|
15
|
-
|
|
16
|
-
// src/utils/timeout.ts
|
|
17
|
-
var TimeoutError = class _TimeoutError extends Error {
|
|
18
|
-
name = "TimeoutError";
|
|
19
|
-
constructor(message) {
|
|
20
|
-
super(message);
|
|
21
|
-
this.name = "TimeoutError";
|
|
22
|
-
Error.captureStackTrace(this, _TimeoutError);
|
|
23
|
-
}
|
|
24
|
-
toJSON() {
|
|
25
|
-
return {
|
|
26
|
-
name: this.name,
|
|
27
|
-
message: this.message,
|
|
28
|
-
stack: this.stack
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
19
|
export {
|
|
33
20
|
MCPErrorCode,
|
|
34
21
|
TimeoutError
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../packages/shared-types/src/frontend/api.ts"
|
|
1
|
+
{"version":3,"sources":["../../packages/shared-types/src/frontend/api.ts"],"sourcesContent":["/**\n * 前端API响应相关类型定义\n */\n\nimport type { MCPServerConfig } from \"../config\";\n\n/**\n * MCP 服务添加请求接口(单服务格式)\n */\nexport interface MCPServerAddRequest {\n name: string;\n config: MCPServerConfig;\n}\n\n/**\n * MCP 服务批量添加请求接口(mcpServers 格式)\n */\nexport interface MCPServerBatchAddRequest {\n mcpServers: Record<string, MCPServerConfig>;\n}\n\n/**\n * MCP 服务添加操作结果\n */\nexport interface MCPServerAddResult {\n name: string;\n success: boolean;\n error?: string;\n config?: MCPServerConfig;\n tools?: string[];\n status?: string;\n}\n\n/**\n * MCP 服务批量添加响应\n */\nexport interface MCPServerBatchAddResponse {\n success: boolean;\n message: string;\n results: MCPServerAddResult[];\n addedCount: number;\n failedCount: number;\n}\n\n/**\n * MCP 服务状态接口\n */\nexport interface MCPServerStatus {\n name: string;\n status: \"connected\" | \"disconnected\" | \"connecting\" | \"error\";\n connected: boolean;\n tools: string[];\n lastUpdated?: string;\n config: MCPServerConfig;\n}\n\n/**\n * MCP 服务列表响应接口\n */\nexport interface MCPServerListResponse {\n servers: MCPServerStatus[];\n total: number;\n}\n\n/**\n * API 统一响应格式接口\n */\nexport interface ApiSuccessResponse<T = any> {\n success: boolean;\n data?: T;\n message?: string;\n}\n\nexport interface ApiErrorResponse {\n error: {\n code: string;\n message: string;\n details?: {\n serverName?: string;\n config?: any;\n tools?: string[];\n timestamp: string;\n };\n };\n}\n\n/**\n * API 错误码枚举\n */\nexport enum MCPErrorCode {\n // 服务相关错误\n SERVER_NOT_FOUND = \"SERVER_NOT_FOUND\",\n SERVER_ALREADY_EXISTS = \"SERVER_ALREADY_EXISTS\",\n INVALID_SERVICE_NAME = \"INVALID_SERVICE_NAME\",\n\n // 配置相关错误\n INVALID_CONFIG = \"INVALID_CONFIG\",\n CONFIG_UPDATE_FAILED = \"CONFIG_UPDATE_FAILED\",\n\n // 连接相关错误\n CONNECTION_FAILED = \"CONNECTION_FAILED\",\n\n // 操作相关错误\n ADD_FAILED = \"ADD_FAILED\",\n REMOVE_FAILED = \"REMOVE_FAILED\",\n\n // 系统错误\n INTERNAL_ERROR = \"INTERNAL_ERROR\",\n VALIDATION_ERROR = \"VALIDATION_ERROR\",\n}\n\n/**\n * 工具调用记录\n */\nexport interface ToolCallRecord {\n /** 工具名称 */\n toolName: string;\n /** 原始工具名称(如果有的话) */\n originalToolName?: string;\n /** 服务器名称 */\n serverName?: string;\n /** 调用参数 */\n arguments?: any;\n /** 调用结果 */\n result?: any;\n /** 是否成功 */\n success: boolean;\n /** 调用耗时(毫秒) */\n duration?: number;\n /** 错误信息 */\n error?: string;\n /** 时间戳 */\n timestamp?: number;\n}\n\n/**\n * 工具调用日志响应\n */\nexport interface ToolCallLogsResponse {\n /** 日志记录列表 */\n records: ToolCallRecord[];\n /** 总数量 */\n total: number;\n /** 是否有更多数据 */\n hasMore: boolean;\n}\n\n/**\n * API通用响应格式\n */\nexport interface ApiResponse<T = any> {\n success: boolean;\n data?: T;\n error?: {\n code: string;\n message: string;\n details?: any;\n };\n}\n"],"mappings":";;;;;AAyFO,IAAK,eAAL,kBAAKA,kBAAL;AAEL,EAAAA,cAAA,sBAAmB;AACnB,EAAAA,cAAA,2BAAwB;AACxB,EAAAA,cAAA,0BAAuB;AAGvB,EAAAA,cAAA,oBAAiB;AACjB,EAAAA,cAAA,0BAAuB;AAGvB,EAAAA,cAAA,uBAAoB;AAGpB,EAAAA,cAAA,gBAAa;AACb,EAAAA,cAAA,mBAAgB;AAGhB,EAAAA,cAAA,oBAAiB;AACjB,EAAAA,cAAA,sBAAmB;AAnBT,SAAAA;AAAA,GAAA;","names":["MCPErrorCode"]}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { d as ToolCallResult, e as TransportConfig } from './message-xoOM7ZuT.js';
|
|
2
|
+
export { C as CacheConfig, h as CacheStateTransition, f as CacheStatistics, k as ConnectionState, a as EnhancedToolResultCache, E as ExtendedMCPToolsCache, c as MCPError, M as MCPMessage, b as MCPResponse, i as TaskInfo, T as TaskStatus, j as TimeoutConfig, g as ToolCallOptions } from './message-xoOM7ZuT.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* MCP 工具相关类型定义
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 工具调用结果联合类型
|
|
10
|
+
* 包含正常结果和超时响应
|
|
11
|
+
*/
|
|
12
|
+
type ToolCallResponse = ToolCallResult | TimeoutResponse;
|
|
13
|
+
/**
|
|
14
|
+
* 超时响应接口
|
|
15
|
+
*/
|
|
16
|
+
interface TimeoutResponse {
|
|
17
|
+
/** 是否为超时响应 */
|
|
18
|
+
isTimeout: true;
|
|
19
|
+
/** 超时时间(毫秒) */
|
|
20
|
+
timeoutMs: number;
|
|
21
|
+
/** 友好的超时消息 */
|
|
22
|
+
message: string;
|
|
23
|
+
/** 任务ID */
|
|
24
|
+
taskId?: string;
|
|
25
|
+
/** 是否在后台处理 */
|
|
26
|
+
backgroundProcessing: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* 验证是否为工具调用结果
|
|
30
|
+
*/
|
|
31
|
+
declare function isToolCallResult(response: any): response is ToolCallResult;
|
|
32
|
+
/**
|
|
33
|
+
* 验证是否为超时响应
|
|
34
|
+
*/
|
|
35
|
+
declare function isTimeoutResponse(response: any): response is TimeoutResponse;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* MCP 传输层类型定义
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 扩展的传输配置接口
|
|
43
|
+
* 支持不同传输协议的特定配置
|
|
44
|
+
*/
|
|
45
|
+
interface ExtendedTransportConfig extends TransportConfig {
|
|
46
|
+
/** 传输协议类型 */
|
|
47
|
+
protocol?: "stdio" | "http" | "websocket" | "sse";
|
|
48
|
+
/** WebSocket 特定配置 */
|
|
49
|
+
websocket?: {
|
|
50
|
+
url?: string;
|
|
51
|
+
path?: string;
|
|
52
|
+
port?: number;
|
|
53
|
+
};
|
|
54
|
+
/** HTTP 特定配置 */
|
|
55
|
+
http?: {
|
|
56
|
+
port?: number;
|
|
57
|
+
hostname?: string;
|
|
58
|
+
path?: string;
|
|
59
|
+
};
|
|
60
|
+
/** SSE 特定配置 */
|
|
61
|
+
sse?: {
|
|
62
|
+
path?: string;
|
|
63
|
+
port?: number;
|
|
64
|
+
};
|
|
65
|
+
/** Stdio 特定配置 */
|
|
66
|
+
stdio?: {
|
|
67
|
+
command?: string;
|
|
68
|
+
args?: string[];
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 连接统计信息
|
|
73
|
+
*/
|
|
74
|
+
interface ConnectionStats {
|
|
75
|
+
/** 连接ID */
|
|
76
|
+
connectionId: string;
|
|
77
|
+
/** 连接建立时间 */
|
|
78
|
+
connectedAt: string;
|
|
79
|
+
/** 最后活动时间 */
|
|
80
|
+
lastActivity: string;
|
|
81
|
+
/** 发送消息数 */
|
|
82
|
+
messagesSent: number;
|
|
83
|
+
/** 接收消息数 */
|
|
84
|
+
messagesReceived: number;
|
|
85
|
+
/** 错误次数 */
|
|
86
|
+
errorCount: number;
|
|
87
|
+
/** 平均响应时间(毫秒) */
|
|
88
|
+
averageResponseTime: number;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export { type ConnectionStats, type ExtendedTransportConfig, type TimeoutResponse, type ToolCallResponse, ToolCallResult, TransportConfig, isTimeoutResponse, isToolCallResult };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/mcp/message.ts
|
|
2
|
+
var ConnectionState = /* @__PURE__ */ ((ConnectionState2) => {
|
|
3
|
+
ConnectionState2["DISCONNECTED"] = "disconnected";
|
|
4
|
+
ConnectionState2["CONNECTING"] = "connecting";
|
|
5
|
+
ConnectionState2["CONNECTED"] = "connected";
|
|
6
|
+
ConnectionState2["ERROR"] = "error";
|
|
7
|
+
return ConnectionState2;
|
|
8
|
+
})(ConnectionState || {});
|
|
9
|
+
|
|
10
|
+
// src/mcp/tools.ts
|
|
11
|
+
function isToolCallResult(response) {
|
|
12
|
+
return response && Array.isArray(response.content) && response.content.length > 0 && response.content[0].type === "text" && typeof response.content[0].text === "string";
|
|
13
|
+
}
|
|
14
|
+
function isTimeoutResponse(response) {
|
|
15
|
+
return response && typeof response === "object" && response.isTimeout === true && typeof response.timeoutMs === "number" && typeof response.message === "string";
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
ConnectionState,
|
|
19
|
+
isTimeoutResponse,
|
|
20
|
+
isToolCallResult
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=mcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../packages/shared-types/src/mcp/message.ts","../../packages/shared-types/src/mcp/tools.ts"],"sourcesContent":["/**\n * MCP 消息协议相关类型定义\n */\n\n/**\n * MCP 消息接口\n */\nexport interface MCPMessage {\n jsonrpc: \"2.0\";\n method: string;\n params?: any;\n id?: string | number;\n}\n\n/**\n * MCP 响应接口\n */\nexport interface MCPResponse {\n jsonrpc: \"2.0\";\n result?: any;\n error?: MCPError;\n id: string | number | null;\n}\n\n/**\n * MCP 错误接口\n */\nexport interface MCPError {\n code: number;\n message: string;\n data?: any;\n}\n\n/**\n * 连接状态枚举\n */\nexport enum ConnectionState {\n DISCONNECTED = \"disconnected\",\n CONNECTING = \"connecting\",\n CONNECTED = \"connected\",\n ERROR = \"error\",\n}\n\n/**\n * 传输适配器配置接口\n */\nexport interface TransportConfig {\n name: string;\n timeout?: number;\n retryAttempts?: number;\n retryDelay?: number;\n}\n","/**\n * MCP 工具相关类型定义\n */\n\nimport type { ToolCallResult } from \"./cache\";\n\n/**\n * 工具调用结果联合类型\n * 包含正常结果和超时响应\n */\nexport type ToolCallResponse = ToolCallResult | TimeoutResponse;\n\n/**\n * 超时响应接口\n */\nexport interface TimeoutResponse {\n /** 是否为超时响应 */\n isTimeout: true;\n /** 超时时间(毫秒) */\n timeoutMs: number;\n /** 友好的超时消息 */\n message: string;\n /** 任务ID */\n taskId?: string;\n /** 是否在后台处理 */\n backgroundProcessing: boolean;\n}\n\n/**\n * 验证是否为工具调用结果\n */\nexport function isToolCallResult(response: any): response is ToolCallResult {\n return (\n response &&\n Array.isArray(response.content) &&\n response.content.length > 0 &&\n response.content[0].type === \"text\" &&\n typeof response.content[0].text === \"string\"\n );\n}\n\n/**\n * 验证是否为超时响应\n */\nexport function isTimeoutResponse(response: any): response is TimeoutResponse {\n return (\n response &&\n typeof response === \"object\" &&\n response.isTimeout === true &&\n typeof response.timeoutMs === \"number\" &&\n typeof response.message === \"string\"\n );\n}\n"],"mappings":";AAoCO,IAAK,kBAAL,kBAAKA,qBAAL;AACL,EAAAA,iBAAA,kBAAe;AACf,EAAAA,iBAAA,gBAAa;AACb,EAAAA,iBAAA,eAAY;AACZ,EAAAA,iBAAA,WAAQ;AAJE,SAAAA;AAAA,GAAA;;;ACLL,SAAS,iBAAiB,UAA2C;AAC1E,SACE,YACA,MAAM,QAAQ,SAAS,OAAO,KAC9B,SAAS,QAAQ,SAAS,KAC1B,SAAS,QAAQ,CAAC,EAAE,SAAS,UAC7B,OAAO,SAAS,QAAQ,CAAC,EAAE,SAAS;AAExC;AAKO,SAAS,kBAAkB,UAA4C;AAC5E,SACE,YACA,OAAO,aAAa,YACpB,SAAS,cAAc,QACvB,OAAO,SAAS,cAAc,YAC9B,OAAO,SAAS,YAAY;AAEhC;","names":["ConnectionState"]}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP 任务相关类型定义
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* 任务状态类型
|
|
6
|
+
*/
|
|
7
|
+
type TaskStatus = "pending" | "completed" | "failed" | "consumed" | "deleted";
|
|
8
|
+
/**
|
|
9
|
+
* 缓存状态转换接口
|
|
10
|
+
*/
|
|
11
|
+
interface CacheStateTransition {
|
|
12
|
+
from: TaskStatus;
|
|
13
|
+
to: TaskStatus;
|
|
14
|
+
reason: string;
|
|
15
|
+
timestamp: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 任务信息接口
|
|
19
|
+
*/
|
|
20
|
+
interface TaskInfo {
|
|
21
|
+
taskId: string;
|
|
22
|
+
toolName: string;
|
|
23
|
+
arguments: any;
|
|
24
|
+
status: TaskStatus;
|
|
25
|
+
startTime: string;
|
|
26
|
+
endTime?: string;
|
|
27
|
+
error?: string;
|
|
28
|
+
result?: any;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 超时配置选项
|
|
32
|
+
*/
|
|
33
|
+
interface TimeoutConfig {
|
|
34
|
+
timeout?: number;
|
|
35
|
+
enableFriendlyTimeout?: boolean;
|
|
36
|
+
backgroundProcessing?: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* MCP 缓存相关类型定义
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 工具调用结果接口(简化版)
|
|
45
|
+
*/
|
|
46
|
+
interface ToolCallResult {
|
|
47
|
+
content: Array<{
|
|
48
|
+
type: string;
|
|
49
|
+
text: string;
|
|
50
|
+
}>;
|
|
51
|
+
isError?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 扩展的 MCP 工具缓存接口
|
|
55
|
+
* 增加对 CustomMCP 执行结果的支持
|
|
56
|
+
*/
|
|
57
|
+
interface ExtendedMCPToolsCache {
|
|
58
|
+
customMCPResults?: Record<string, EnhancedToolResultCache>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 增强的工具执行结果缓存
|
|
62
|
+
* 用于存储 CustomMCP 工具的执行结果和状态
|
|
63
|
+
*/
|
|
64
|
+
interface EnhancedToolResultCache {
|
|
65
|
+
result: ToolCallResult;
|
|
66
|
+
timestamp: string;
|
|
67
|
+
ttl: number;
|
|
68
|
+
status: TaskStatus;
|
|
69
|
+
consumed: boolean;
|
|
70
|
+
taskId?: string;
|
|
71
|
+
retryCount: number;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* 缓存配置选项
|
|
75
|
+
*/
|
|
76
|
+
interface CacheConfig {
|
|
77
|
+
ttl?: number;
|
|
78
|
+
cleanupInterval?: number;
|
|
79
|
+
maxCacheSize?: number;
|
|
80
|
+
enableOneTimeCache?: boolean;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 缓存统计信息
|
|
84
|
+
*/
|
|
85
|
+
interface CacheStatistics {
|
|
86
|
+
totalEntries: number;
|
|
87
|
+
pendingTasks: number;
|
|
88
|
+
completedTasks: number;
|
|
89
|
+
failedTasks: number;
|
|
90
|
+
consumedEntries: number;
|
|
91
|
+
cacheHitRate: number;
|
|
92
|
+
lastCleanupTime: string;
|
|
93
|
+
memoryUsage: number;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 工具调用选项
|
|
97
|
+
*/
|
|
98
|
+
interface ToolCallOptions {
|
|
99
|
+
timeout?: number;
|
|
100
|
+
retries?: number;
|
|
101
|
+
retryDelay?: number;
|
|
102
|
+
enableCache?: boolean;
|
|
103
|
+
taskId?: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* MCP 消息协议相关类型定义
|
|
108
|
+
*/
|
|
109
|
+
/**
|
|
110
|
+
* MCP 消息接口
|
|
111
|
+
*/
|
|
112
|
+
interface MCPMessage {
|
|
113
|
+
jsonrpc: "2.0";
|
|
114
|
+
method: string;
|
|
115
|
+
params?: any;
|
|
116
|
+
id?: string | number;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* MCP 响应接口
|
|
120
|
+
*/
|
|
121
|
+
interface MCPResponse {
|
|
122
|
+
jsonrpc: "2.0";
|
|
123
|
+
result?: any;
|
|
124
|
+
error?: MCPError;
|
|
125
|
+
id: string | number | null;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* MCP 错误接口
|
|
129
|
+
*/
|
|
130
|
+
interface MCPError {
|
|
131
|
+
code: number;
|
|
132
|
+
message: string;
|
|
133
|
+
data?: any;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* 连接状态枚举
|
|
137
|
+
*/
|
|
138
|
+
declare enum ConnectionState {
|
|
139
|
+
DISCONNECTED = "disconnected",
|
|
140
|
+
CONNECTING = "connecting",
|
|
141
|
+
CONNECTED = "connected",
|
|
142
|
+
ERROR = "error"
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* 传输适配器配置接口
|
|
146
|
+
*/
|
|
147
|
+
interface TransportConfig {
|
|
148
|
+
name: string;
|
|
149
|
+
timeout?: number;
|
|
150
|
+
retryAttempts?: number;
|
|
151
|
+
retryDelay?: number;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export { type CacheConfig as C, type ExtendedMCPToolsCache as E, type MCPMessage as M, type TaskStatus as T, type EnhancedToolResultCache as a, type MCPResponse as b, type MCPError as c, type ToolCallResult as d, type TransportConfig as e, type CacheStatistics as f, type ToolCallOptions as g, type CacheStateTransition as h, type TaskInfo as i, type TimeoutConfig as j, ConnectionState as k };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 超时处理相关类型定义
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* 超时错误类型
|
|
6
|
+
*/
|
|
7
|
+
declare class TimeoutError extends Error {
|
|
8
|
+
readonly name: "TimeoutError";
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
toJSON(): {
|
|
11
|
+
name: "TimeoutError";
|
|
12
|
+
message: string;
|
|
13
|
+
stack: string | undefined;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 超时响应接口
|
|
18
|
+
*/
|
|
19
|
+
interface TimeoutResponse {
|
|
20
|
+
content: Array<{
|
|
21
|
+
type: "text";
|
|
22
|
+
text: string;
|
|
23
|
+
}>;
|
|
24
|
+
isError: boolean;
|
|
25
|
+
taskId: string;
|
|
26
|
+
status: "timeout";
|
|
27
|
+
message: string;
|
|
28
|
+
nextAction: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 验证是否为超时响应
|
|
32
|
+
*/
|
|
33
|
+
declare function isTimeoutResponse(response: any): response is TimeoutResponse;
|
|
34
|
+
/**
|
|
35
|
+
* 验证是否为超时错误
|
|
36
|
+
*/
|
|
37
|
+
declare function isTimeoutError(error: any): error is TimeoutError;
|
|
38
|
+
|
|
39
|
+
export { TimeoutError as T, type TimeoutResponse as a, isTimeoutError as b, isTimeoutResponse as i };
|