dsh-config-manager 0.8.0 → 0.8.1
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/lib/adapters/mcp.d.ts +6 -1
- package/lib/adapters/mcp.js +22 -4
- package/lib/client.js +560 -560
- package/lib/core/messages.d.ts +2 -0
- package/lib/core/messages.js +4 -0
- package/lib/core/patch-document.d.ts +65 -0
- package/lib/core/patch-document.js +161 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.js +35 -53
- package/package.json +1 -1
- package/src/adapters/mcp.test.ts +23 -3
- package/src/adapters/mcp.ts +24 -4
- package/src/core/messages.ts +4 -0
- package/src/core/patch-document.test.ts +107 -0
- package/src/core/patch-document.ts +194 -0
- package/src/index.facade.test.ts +83 -1
- package/src/index.ts +37 -47
- package/src/utils/patch-yaml.test.ts +1 -1
package/lib/adapters/mcp.d.ts
CHANGED
|
@@ -41,7 +41,12 @@ export declare function extractMcpServers(lines: {
|
|
|
41
41
|
* 为非空字符串),否则两边会漂。返回 undefined = 该行只剩 MCP 条目,整行丢弃。
|
|
42
42
|
*/
|
|
43
43
|
export declare function stripMcpEntries(raw: unknown): unknown | undefined;
|
|
44
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* 由导出条目构造写回 patch 行 raw(单行形态,与 dsh-mcp-client 组合 config 语义一致)。
|
|
46
|
+
*
|
|
47
|
+
* `config.transport` 必须显式写:读侧靠它判定 server 类型,只在「没有 transport 的旧行」
|
|
48
|
+
* 上才回落 url 猜测(issue #133:此前写回丢了这个字段,stdio/http 只能靠 url 有没有值猜)。
|
|
49
|
+
*/
|
|
45
50
|
export declare function buildMcpPatchLine(lineId: string, server: McpServerEntry): Record<string, unknown>;
|
|
46
51
|
/**
|
|
47
52
|
* 单元 id:两条数据源各自独立前缀。
|
package/lib/adapters/mcp.js
CHANGED
|
@@ -33,7 +33,8 @@ export function extractMcpServers(lines) {
|
|
|
33
33
|
const serverName = c['serverName'];
|
|
34
34
|
if (typeof serverName !== 'string' || serverName === '')
|
|
35
35
|
continue;
|
|
36
|
-
|
|
36
|
+
// transport 优先(写回时一定有);老行没有该字段才回落「有 url = 远程」的猜测
|
|
37
|
+
const type = mcpTransportOf(c) ?? (typeof c['url'] === 'string' && c['url'] !== '' ? 'streamable-http' : 'stdio');
|
|
37
38
|
servers.push({
|
|
38
39
|
serverName,
|
|
39
40
|
type,
|
|
@@ -77,6 +78,11 @@ export function stripMcpEntries(raw) {
|
|
|
77
78
|
return raw;
|
|
78
79
|
return isMcpEntry(single[0]) ? undefined : raw;
|
|
79
80
|
}
|
|
81
|
+
/** `config.transport` 的合法取值;读不出来(缺字段/写错)返回 undefined,由调用方回落 url 判定。 */
|
|
82
|
+
function mcpTransportOf(c) {
|
|
83
|
+
const transport = c['transport'];
|
|
84
|
+
return transport === 'stdio' || transport === 'streamable-http' ? transport : undefined;
|
|
85
|
+
}
|
|
80
86
|
/** 单个 patch entry 是否是 MCP 服务器行(与 extractMcpServers 的判定同口径) */
|
|
81
87
|
function isMcpEntry(entry) {
|
|
82
88
|
if (entry === null || typeof entry !== 'object')
|
|
@@ -102,9 +108,21 @@ function entriesOf(raw) {
|
|
|
102
108
|
}
|
|
103
109
|
return [];
|
|
104
110
|
}
|
|
105
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* MCP server 行的包名(bundle id,**必须带 scope**)。
|
|
113
|
+
*
|
|
114
|
+
* 宿主按 bundle id 解析 patch 行的 `name`;裸名 `dsh-mcp-client` 是否被归一化未经验证,
|
|
115
|
+
* 而用户机上的真实行都是 `@deepseek-ai/dsh-mcp-client`(issue #133 报告的原始行)。
|
|
116
|
+
*/
|
|
117
|
+
const MCP_BUNDLE_NAME = '@deepseek-ai/dsh-mcp-client';
|
|
118
|
+
/**
|
|
119
|
+
* 由导出条目构造写回 patch 行 raw(单行形态,与 dsh-mcp-client 组合 config 语义一致)。
|
|
120
|
+
*
|
|
121
|
+
* `config.transport` 必须显式写:读侧靠它判定 server 类型,只在「没有 transport 的旧行」
|
|
122
|
+
* 上才回落 url 猜测(issue #133:此前写回丢了这个字段,stdio/http 只能靠 url 有没有值猜)。
|
|
123
|
+
*/
|
|
106
124
|
export function buildMcpPatchLine(lineId, server) {
|
|
107
|
-
const config = { serverName: server.serverName };
|
|
125
|
+
const config = { serverName: server.serverName, transport: server.type };
|
|
108
126
|
if (server.type === 'streamable-http') {
|
|
109
127
|
config['url'] = server.url;
|
|
110
128
|
if (server.headers !== undefined)
|
|
@@ -119,7 +137,7 @@ export function buildMcpPatchLine(lineId, server) {
|
|
|
119
137
|
if (server.cwd !== undefined)
|
|
120
138
|
config['cwd'] = server.cwd;
|
|
121
139
|
}
|
|
122
|
-
return { id: lineId, name:
|
|
140
|
+
return { id: lineId, name: MCP_BUNDLE_NAME, config };
|
|
123
141
|
}
|
|
124
142
|
/** 连接器计划项的 id 前缀(导入时按前缀分派到 applyConnectorItem) */
|
|
125
143
|
const MCP_CONNECTOR_ITEM_PREFIX = 'mcp-connector:';
|