dsh-mcp-connector 0.2.78 → 0.2.79

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/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  本项目遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/);首个公开版本从 `0.1.0` 开始。
4
4
 
5
+ ## [0.2.79] - 2026-10-24
6
+
7
+ ### Fixed
8
+
9
+ - #178:治理、项目作用域和会话注入刷新改为轻量名称读取,不再调用 tools.schemas() 深克隆参数,切断 schema 读取副作用引起的延迟事件回路。
10
+ - 默认全局/always 且无 deny 或停用连接时跳过清单读取;项目隔离每轮只读取一次,不按 Agent 数重复。
11
+ - 保留执行 guard、工具增删感知和权限交集;名称读取失败时保留已有限制,不把错误当空清单,也不回退 schema 扫描。
12
+
13
+ ### Compatibility and verification
14
+
15
+ - 优先使用上游公开 definitions();已发布旧 Host 通过集中、只读、形状校验的内部 view() 兼容层读取名称。内部接口属于兼容风险,增加 Windows/Linux × Host 0.2.1-rc.2/rc.3 契约门禁;不修改宿主安装。
16
+ - 增加同步、微任务、下一轮事件交付及残余 schema 反馈回路回归。详见 docs/ACCEPTANCE-178-20261024.md。
17
+ - 本次是工具运行时机制修复;报告者 Windows Desktop UI 的原始卡顿与 1.29 亿次调用对照仍需复测,#178 保留跟踪。不包含延期的国际化或其他草案功能。
18
+
5
19
  ## [0.2.78] - 2026-10-22
6
20
 
7
21
  ### Fixed
package/README.en.md CHANGED
@@ -225,7 +225,7 @@ npm run dev:ui
225
225
 
226
226
  Every Registry merge regenerates `catalog-stats.json`; an hourly workflow in this repository synchronizes the Chinese and English product copy plus a local stats snapshot. The static npm README updates with package releases, while the live badges above read the Registry directly and therefore stay current without another npm release.
227
227
 
228
- The current public version is [`dsh-mcp-connector@0.2.78`](https://www.npmjs.com/package/dsh-mcp-connector), with [GitHub Release v0.2.78](https://github.com/duhu2000/dsh-mcp-connector/releases/tag/v0.2.78).
228
+ The current public version is [`dsh-mcp-connector@0.2.79`](https://www.npmjs.com/package/dsh-mcp-connector), with [GitHub Release v0.2.79](https://github.com/duhu2000/dsh-mcp-connector/releases/tag/v0.2.79).
229
229
 
230
230
  See [CHANGELOG.md](CHANGELOG.md) for version history and [docs/DESKTOP-E2E.md](docs/DESKTOP-E2E.md) for the Desktop release checklist.
231
231
 
package/README.md CHANGED
@@ -220,7 +220,7 @@ npm run dev:ui
220
220
 
221
221
  公共 Registry 每次合并后会生成 `catalog-stats.json`;本仓库的定时工作流每小时同步中英文介绍和统计快照。npm 页面中的静态正文随版本发布更新,上方动态统计徽标则直接读取 Registry,可在不发布新 npm 版本时保持实时数量一致。
222
222
 
223
- 当前公开版本为 [`dsh-mcp-connector@0.2.78`](https://www.npmjs.com/package/dsh-mcp-connector),对应 [GitHub Release v0.2.78](https://github.com/duhu2000/dsh-mcp-connector/releases/tag/v0.2.78)。
223
+ 当前公开版本为 [`dsh-mcp-connector@0.2.79`](https://www.npmjs.com/package/dsh-mcp-connector),对应 [GitHub Release v0.2.79](https://github.com/duhu2000/dsh-mcp-connector/releases/tag/v0.2.79)。
224
224
 
225
225
  版本能力与变更记录见 [CHANGELOG.md](CHANGELOG.md)。
226
226
  Desktop 发版回归见 [docs/DESKTOP-E2E.md](docs/DESKTOP-E2E.md)。
@@ -7,6 +7,8 @@
7
7
  * credential.
8
8
  */
9
9
 
10
+ import { readHostToolNames, supportsHostToolNames } from './host-tool-names.js';
11
+
10
12
  export const CONNECTION_SCOPE_HISTORY_LIMIT = 20;
11
13
  export const CONNECTION_SCOPE_TYPES = ['global', 'project'];
12
14
 
@@ -280,19 +282,18 @@ export function createHostScopeController(ctx, {
280
282
  : null;
281
283
 
282
284
  function observedPublicNames() {
283
- if (typeof ctx.tools?.schemas !== 'function') return [];
284
285
  try {
285
- return ctx.tools.schemas().map((schema) => schema?.name)
286
+ return readHostToolNames(ctx.tools)
286
287
  .filter((name) => typeof name === 'string' && recordForPublicName(name))
287
288
  .sort();
288
289
  } catch (error) {
289
290
  logger?.warn?.(`scope read Host tools failed: ${error.message}`);
290
- return [];
291
+ return null;
291
292
  }
292
293
  }
293
294
 
294
- function installRestriction(agent) {
295
- const denied = observedPublicNames().filter((name) => {
295
+ function installRestriction(agent, observed) {
296
+ const denied = observed.filter((name) => {
296
297
  const record = recordForPublicName(name);
297
298
  return record && !visible(record, agent);
298
299
  });
@@ -315,15 +316,21 @@ export function createHostScopeController(ctx, {
315
316
  let syncing = false;
316
317
  function refresh() {
317
318
  if (disposed || !agentsMounted) return;
318
- // Reading lazy Host schemas or replacing a restriction may synchronously
319
- // emit tools/change. Ignore that nested notification: replaying it scans
320
- // the same single-threaded state and can otherwise keep the event loop in
321
- // a permanent tools/change cycle with plugins that re-register tools.
319
+ // Ignore synchronous restriction notifications while reconciling. Name-only
320
+ // reads avoid schema side effects; delayed events still observe real changes.
322
321
  if (syncing) return;
323
322
  syncing = true;
324
323
  try {
325
324
  const live = new Set(mountedAgentCtx?.agents?.list?.() ?? []);
326
- for (const agent of live) installRestriction(agent);
325
+ // Global bindings cannot hide tools. When project isolation is needed,
326
+ // enumerate once per refresh, not once per live Agent.
327
+ const currentBindings = bindings();
328
+ const needsRestriction = records().some((record) => (
329
+ !bindingForConnection(currentBindings, record.key).global
330
+ ));
331
+ const observed = live.size && needsRestriction ? observedPublicNames() : [];
332
+ if (observed === null) return;
333
+ for (const agent of live) installRestriction(agent, observed);
327
334
  for (const agent of restrictions.keys()) if (!live.has(agent)) restrictions.delete(agent);
328
335
  } finally {
329
336
  syncing = false;
@@ -363,7 +370,7 @@ export function createHostScopeController(ctx, {
363
370
  capabilities() {
364
371
  return {
365
372
  executionGuard: Boolean(disposeGuard),
366
- visibilityRestriction: agentsMounted && typeof ctx.tools?.restrict === 'function',
373
+ visibilityRestriction: agentsMounted && typeof ctx.tools?.restrict === 'function' && supportsHostToolNames(ctx.tools),
367
374
  workspaceRegistry: typeof workspaceIdForAgent === 'function',
368
375
  restrictedAgents: restrictions.size,
369
376
  };
package/lib/governance.js CHANGED
@@ -5,6 +5,7 @@
5
5
  * 连接记录的 lifecycle disabled 是物理下线状态,任何 allow 规则都不能覆盖。
6
6
  */
7
7
  import { createHash } from 'node:crypto';
8
+ import { readHostToolNames, supportsHostToolNames } from './host-tool-names.js';
8
9
 
9
10
  export const GOVERNANCE_HISTORY_LIMIT = 20;
10
11
  export const GOVERNANCE_SCOPES = ['connection', 'server', 'tool'];
@@ -302,20 +303,23 @@ export function createHostGovernanceController(ctx, { getRules, getRecords, logg
302
303
  : null;
303
304
 
304
305
  function observedPublicNames() {
305
- if (typeof ctx.tools?.schemas !== 'function') return [];
306
306
  try {
307
- return ctx.tools.schemas()
308
- .map((schema) => schema?.name)
307
+ return readHostToolNames(ctx.tools)
309
308
  .filter((name) => typeof name === 'string' && targetForPublicName(name))
310
309
  .sort();
311
310
  } catch (error) {
312
311
  logger?.warn?.(`governance read Host tools failed: ${error.message}`);
313
- return [];
312
+ return null;
314
313
  }
315
314
  }
316
315
 
317
316
  function deniedObservedNames() {
318
- return observedPublicNames().filter((name) => inspect(name)?.policy.effect === 'deny');
317
+ // The default policy cannot deny anything. Avoid deep-cloning every Host
318
+ // schema just to prove that the resulting restriction would be empty.
319
+ // Disabled connections still require enforcement even without a deny rule.
320
+ if (!records().some((record) => record.enabled === false)
321
+ && !rules().some((rule) => rule.effect === 'deny')) return [];
322
+ return observedPublicNames()?.filter((name) => inspect(name)?.policy.effect === 'deny') ?? null;
319
323
  }
320
324
 
321
325
  function installRestriction(agent, denied) {
@@ -338,16 +342,15 @@ export function createHostGovernanceController(ctx, { getRules, getRecords, logg
338
342
  let syncing = false;
339
343
  function syncRestrictions() {
340
344
  if (disposed || !agentsMounted) return;
341
- // schemas()/restrict() may synchronously cause another tools/change while
342
- // Host plugins materialize lazy schemas or re-register equivalent tools.
343
- // JavaScript cannot interleave an unrelated external change in this stack,
344
- // so replaying that nested event only scans the same state again and can
345
- // form an endless tools/change -> schemas -> tools/change loop.
345
+ // Restriction installation may synchronously notify the same controller.
346
+ // Name-only reads below do not materialize schemas; delayed notifications
347
+ // are harmless rechecks and identical deny sets do not reinstall a mask.
346
348
  if (syncing) return;
347
349
  syncing = true;
348
350
  try {
349
- const denied = deniedObservedNames();
350
351
  const live = new Set(mountedAgentCtx?.agents?.list?.() ?? []);
352
+ const denied = live.size ? deniedObservedNames() : [];
353
+ if (denied === null) return;
351
354
  for (const agent of live) installRestriction(agent, denied);
352
355
  for (const agent of agentRestrictions.keys()) {
353
356
  if (!live.has(agent)) agentRestrictions.delete(agent);
@@ -385,7 +388,7 @@ export function createHostGovernanceController(ctx, { getRules, getRecords, logg
385
388
  capabilities() {
386
389
  return {
387
390
  executionGuard: Boolean(disposeGuard),
388
- visibilityRestriction: agentsMounted && typeof ctx.tools?.restrict === 'function',
391
+ visibilityRestriction: agentsMounted && typeof ctx.tools?.restrict === 'function' && supportsHostToolNames(ctx.tools),
389
392
  activeAgents: mountedAgentCtx?.agents?.list?.().length ?? 0,
390
393
  restrictedAgents: agentRestrictions.size,
391
394
  };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Name-only Host adapter. Never materialize schemas on the visibility event path.
3
+ *
4
+ * Upstream exposes definitions() on main. Published Host 0.1.2-rc.1 and
5
+ * 0.2.1-rc.2/rc.3 instead expose view() at runtime (private in their typings).
6
+ * Keep that legacy dependency here, read-only and shape-checked; never patch
7
+ * the Host or retain its definitions. Pinned real-Host tests cover the bridge.
8
+ */
9
+ export function supportsHostToolNames(tools) {
10
+ return typeof tools?.definitions === 'function' || typeof tools?.view === 'function';
11
+ }
12
+
13
+ export function readHostToolNames(tools) {
14
+ let names;
15
+ if (typeof tools?.definitions === 'function') {
16
+ const definitions = tools.definitions();
17
+ if (!Array.isArray(definitions)) throw new Error('Host tools.definitions() 返回格式不兼容');
18
+ names = definitions.map((definition) => definition?.name);
19
+ } else if (typeof tools?.view === 'function') {
20
+ const view = tools.view();
21
+ if (!(view?.visible instanceof Map)
22
+ || !(view.knownNames instanceof Set)
23
+ || !(view.restrictableNames instanceof Set)) {
24
+ throw new Error('Host tools.view() 返回格式不兼容');
25
+ }
26
+ names = [...view.visible.keys()];
27
+ } else {
28
+ // A schema fallback would reintroduce #178. Callers retain existing masks
29
+ // on error and their independent execution guards remain active.
30
+ throw new Error('当前 Host 不支持轻量工具名称读取,无法刷新工具可见性限制');
31
+ }
32
+ if (names.some((name) => typeof name !== 'string' || !name)) {
33
+ throw new Error('Host 工具名称格式不兼容');
34
+ }
35
+ return [...new Set(names)].sort();
36
+ }
@@ -7,6 +7,8 @@
7
7
  * another conversation or survive a DSH restart.
8
8
  */
9
9
 
10
+ import { readHostToolNames, supportsHostToolNames } from './host-tool-names.js';
11
+
10
12
  export const INJECTION_MODES = ['always', 'session'];
11
13
  export const DEFAULT_SESSION_TOOL_TTL_MINUTES = 30;
12
14
  export const MAX_SESSION_TOOL_TTL_MINUTES = 30;
@@ -68,14 +70,13 @@ export function createSessionToolInjectionController(ctx, {
68
70
  }
69
71
 
70
72
  function observedPublicNames() {
71
- if (typeof ctx.tools?.schemas !== 'function') return [];
72
73
  try {
73
- return ctx.tools.schemas().map((schema) => schema?.name)
74
+ return readHostToolNames(ctx.tools)
74
75
  .filter((name) => typeof name === 'string' && recordForPublicName(name))
75
76
  .sort();
76
77
  } catch (error) {
77
78
  logger?.warn?.(`session injection read Host tools failed: ${error.message}`);
78
- return [];
79
+ return null;
79
80
  }
80
81
  }
81
82
 
@@ -165,9 +166,15 @@ export function createSessionToolInjectionController(ctx, {
165
166
  if (disposed || !agentsMounted || syncing) return;
166
167
  syncing = true;
167
168
  try {
168
- const observed = observedPublicNames();
169
- const observedSet = new Set(observed);
170
169
  const live = new Set(mountedAgentCtx?.agents?.list?.() ?? []);
170
+ // Legacy/default always-on connections need no session visibility mask.
171
+ // Still reconcile empty masks and purge activations when the mode changes.
172
+ const needsRestriction = records().some((record) => (
173
+ record.enabled !== false && normalizeInjectionMode(record.injectionMode) === 'session'
174
+ ));
175
+ const observed = live.size && needsRestriction ? observedPublicNames() : [];
176
+ if (observed === null) return;
177
+ const observedSet = new Set(observed);
171
178
  for (const agent of live) {
172
179
  purgeState(agent, observedSet);
173
180
  installRestriction(agent, deniedNames(agent, observed));
@@ -223,7 +230,9 @@ export function createSessionToolInjectionController(ctx, {
223
230
  if (!isRecordVisible(record, agent)) throw new Error(`连接 "${record.name}" 不属于当前工作区`);
224
231
  const requested = uniqueNames(input.publicNames);
225
232
  if (requested.length === 0) throw new Error('必须指定至少一个精确 public tool name');
226
- const observed = new Set(observedPublicNames());
233
+ const names = observedPublicNames();
234
+ if (names === null) throw new Error('Host 工具名称读取失败,暂不能激活工具');
235
+ const observed = new Set(names);
227
236
  for (const publicName of requested) {
228
237
  if (!observed.has(publicName)) throw new Error(`Host 尚未观察到工具 "${publicName}"`);
229
238
  const owner = recordForPublicName(publicName);
@@ -249,7 +258,9 @@ export function createSessionToolInjectionController(ctx, {
249
258
 
250
259
  function status(agent) {
251
260
  assertAgent(agent);
252
- const observed = new Set(observedPublicNames());
261
+ const names = observedPublicNames();
262
+ if (names === null) throw new Error('Host 工具名称读取失败,暂不能读取会话工具状态');
263
+ const observed = new Set(names);
253
264
  purgeState(agent, observed);
254
265
  const state = stateFor(agent);
255
266
  const active = [...(state?.activations ?? new Map()).entries()].map(([publicName, activation]) => ({
@@ -375,7 +386,7 @@ export function createSessionToolInjectionController(ctx, {
375
386
  function capabilities() {
376
387
  return {
377
388
  executionGuard: Boolean(disposeGuard),
378
- visibilityRestriction: agentsMounted && typeof ctx.tools?.restrict === 'function',
389
+ visibilityRestriction: agentsMounted && typeof ctx.tools?.restrict === 'function' && supportsHostToolNames(ctx.tools),
379
390
  activeAgents: mountedAgentCtx?.agents?.list?.().length ?? 0,
380
391
  restrictedAgents: restrictions.size,
381
392
  maxTtlMinutes: MAX_SESSION_TOOL_TTL_MINUTES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mcp-connector",
3
- "version": "0.2.78",
3
+ "version": "0.2.79",
4
4
  "description": "DeepSeek Harness MCP Connector: connect servers, search tools across active connections, and troubleshoot discovery. Includes a continuously updated catalog; supports OAuth 2.0 PKCE, API keys, Streamable HTTP/stdio, and mcpServers JSON import.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",