dsh-mcp-connector 0.2.83 → 0.2.84

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,23 @@
2
2
 
3
3
  本项目遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/);首个公开版本从 `0.1.0` 开始。
4
4
 
5
+ ## [0.2.84] - 2026-10-29
6
+
7
+ ### Added
8
+
9
+ - PR #195:已安装页增加本机连接统计,以当前 profile 成功连接过的目录卡片为单位,明确区分历史基线与近 30 天首次连接的新卡片。
10
+ - 统计不包含社区总量、独立用户数或业务调用成功数,不上传数据。
11
+
12
+ ### Fixed
13
+
14
+ - 统计写入改为后台串行队列,增加超时、队列上限和释放保护;存储异常不阻塞连接返回或启动基线初始化。
15
+ - 撤回社区上报、汇总、参与开关与热门排序实验;本版本不部署统计后端。
16
+
17
+ ### Verification
18
+
19
+ - 自动化覆盖去重、持久化恢复、基线、统计失败/挂起/晚到、队列上限、API 范围与 UI 文案。
20
+ - 发行素材使用无凭据 Mock 重新采集;CI、Mock 与 macOS 测试不代替 Windows Desktop 实机验收。
21
+
5
22
  ## [0.2.83] - 2026-10-26
6
23
 
7
24
  ### Fixed
package/README.en.md CHANGED
@@ -106,7 +106,7 @@ As of 2026-10-24, the public Registry publishes 112 connector descriptors. After
106
106
  | Connection diagnostics and last-success cache | |
107
107
  | ![Connection diagnostics](https://raw.githubusercontent.com/duhu2000/dsh-mcp-connector/main/docs/screenshots/07-connection-diagnostics.png) | |
108
108
 
109
- <!-- generated:media -->Screenshots and GIF were captured from v0.2.83 (2026-10-26), using the credential-free Mock harness. They demonstrate UI, not real business acceptance; counts are fixtures. See [asset provenance](docs/screenshots/README.md).<!-- /generated:media -->
109
+ <!-- generated:media -->Screenshots and GIF were captured from v0.2.84 (2026-10-29), using the credential-free Mock harness. They demonstrate UI, not real business acceptance; counts are fixtures. See [asset provenance](docs/screenshots/README.md).<!-- /generated:media -->
110
110
 
111
111
  ## Installation
112
112
 
@@ -231,7 +231,7 @@ npm run dev:ui
231
231
 
232
232
  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.
233
233
 
234
- <!-- generated:version -->The current public version is [`dsh-mcp-connector@0.2.83`](https://www.npmjs.com/package/dsh-mcp-connector), with [GitHub Release v0.2.83](https://github.com/duhu2000/dsh-mcp-connector/releases/tag/v0.2.83).<!-- /generated:version -->
234
+ <!-- generated:version -->The current public version is [`dsh-mcp-connector@0.2.84`](https://www.npmjs.com/package/dsh-mcp-connector), with [GitHub Release v0.2.84](https://github.com/duhu2000/dsh-mcp-connector/releases/tag/v0.2.84).<!-- /generated:version -->
235
235
 
236
236
  See [CHANGELOG.md](CHANGELOG.md) for version history and [docs/DESKTOP-E2E.md](docs/DESKTOP-E2E.md) for the Desktop release checklist.
237
237
 
package/README.md CHANGED
@@ -108,7 +108,7 @@ Desktop 需要完全退出并重新启动应用;Web 需要停止原 `dsh web`
108
108
  | 连接诊断与最后成功缓存 | |
109
109
  | ![连接诊断](https://raw.githubusercontent.com/duhu2000/dsh-mcp-connector/main/docs/screenshots/07-connection-diagnostics.png) | |
110
110
 
111
- <!-- generated:media -->截图与 GIF 采集自 v0.2.83(2026-10-26)无凭据 Mock 页面,展示界面而非真实业务验收;市场数量是测试夹具。来源与更新方法见 [素材说明](docs/screenshots/README.md)。<!-- /generated:media -->
111
+ <!-- generated:media -->截图与 GIF 采集自 v0.2.84(2026-10-29)无凭据 Mock 页面,展示界面而非真实业务验收;市场数量是测试夹具。来源与更新方法见 [素材说明](docs/screenshots/README.md)。<!-- /generated:media -->
112
112
 
113
113
  ## 安装
114
114
 
@@ -226,7 +226,7 @@ npm run dev:ui
226
226
 
227
227
  公共 Registry 每次合并后会生成 `catalog-stats.json`;本仓库的定时工作流每小时同步中英文介绍和统计快照。npm 页面中的静态正文随版本发布更新,上方动态统计徽标则直接读取 Registry,可在不发布新 npm 版本时保持实时数量一致。
228
228
 
229
- <!-- generated:version -->当前公开版本为 [`dsh-mcp-connector@0.2.83`](https://www.npmjs.com/package/dsh-mcp-connector),对应 [GitHub Release v0.2.83](https://github.com/duhu2000/dsh-mcp-connector/releases/tag/v0.2.83)。<!-- /generated:version -->
229
+ <!-- generated:version -->当前公开版本为 [`dsh-mcp-connector@0.2.84`](https://www.npmjs.com/package/dsh-mcp-connector),对应 [GitHub Release v0.2.84](https://github.com/duhu2000/dsh-mcp-connector/releases/tag/v0.2.84)。<!-- /generated:version -->
230
230
 
231
231
  版本能力与变更记录见 [CHANGELOG.md](CHANGELOG.md)。
232
232
  Desktop 发版回归见 [docs/DESKTOP-E2E.md](docs/DESKTOP-E2E.md)。
Binary file
@@ -1,6 +1,6 @@
1
1
  # 产品截图与演示的来源及更新
2
2
 
3
- <!-- generated:media -->本组 7 张截图和 GIF 均从 v0.2.83 于 2026-10-26 重新采集,未修改截图中的版本文字。<!-- /generated:media -->
3
+ <!-- generated:media -->本组 7 张截图和 GIF 均从 v0.2.84 于 2026-10-29 重新采集,未修改截图中的版本文字。<!-- /generated:media -->
4
4
 
5
5
  全部素材由真实产品 UI 的无凭据 Mock harness 渲染:1280×720 浏览器视口、800px 产品面板、桌面两列卡片。顶部保留“无凭据 Mock”标识;目录数、连接数与工具数是演示夹具,不代表生产统计或真实授权、业务验收。不会读取用户 profile、调用服务商或上传业务数据。
6
6
 
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "capture": {
4
- "capturedOn": "2026-10-26",
5
- "sourceVersion": "0.2.83",
6
- "sourceFingerprint": "4a677c677d57b6389199d2bf6dfd5b376182444dd1105ba7afd34c335eb3b29e",
4
+ "capturedOn": "2026-10-29",
5
+ "sourceVersion": "0.2.84",
6
+ "sourceFingerprint": "4182e235bc910727b4741fdbf148e8052f6a2c8344353cb021c68877208a7403",
7
7
  "browserViewport": {
8
8
  "width": 1280,
9
9
  "height": 720
@@ -16,68 +16,68 @@
16
16
  "screenshots": [
17
17
  {
18
18
  "path": "docs/screenshots/01-market-overview.jpg",
19
- "sha256": "97265e2142b290c8ffdf75a402e65da6c1c34939adaba28ea4175d834a4252fa",
19
+ "sha256": "8a5f91ca890db8d1687579e3740fa2e9097f50ae75a6804661da10c8e2cc1d2b",
20
20
  "width": 1280,
21
21
  "height": 720,
22
- "capturedOn": "2026-10-26",
23
- "sourceVersion": "0.2.83"
22
+ "capturedOn": "2026-10-29",
23
+ "sourceVersion": "0.2.84"
24
24
  },
25
25
  {
26
26
  "path": "docs/screenshots/02-connector-detail.jpg",
27
- "sha256": "5c4433afc32d5ff629f3ce13c546ac8ed0ee7a09cfa321dadb691aae980192db",
27
+ "sha256": "1df1ca2e1e38234257ee9d76253b3229e7892fcfe1349baa8785266a46eb111d",
28
28
  "width": 1280,
29
29
  "height": 720,
30
- "capturedOn": "2026-10-26",
31
- "sourceVersion": "0.2.83"
30
+ "capturedOn": "2026-10-29",
31
+ "sourceVersion": "0.2.84"
32
32
  },
33
33
  {
34
34
  "path": "docs/screenshots/03-tool-discovery.jpg",
35
- "sha256": "058f5aea7d11845677fb77937af82b4ad2957db363fde412e45aa9e579d7b586",
35
+ "sha256": "20c6feb645fb81cbf78329ef82fa3c4a48dbeb664c80aa41fe5b1a9dbe2d6ea6",
36
36
  "width": 1280,
37
37
  "height": 720,
38
- "capturedOn": "2026-10-26",
39
- "sourceVersion": "0.2.83"
38
+ "capturedOn": "2026-10-29",
39
+ "sourceVersion": "0.2.84"
40
40
  },
41
41
  {
42
42
  "path": "docs/screenshots/04-json-import.jpg",
43
- "sha256": "1d40f4d02b0338c192419f7f71dbf420faa8c92d4d0a5fd9f7676b7822bfcdb8",
43
+ "sha256": "6f29ec8029c57e5475798dd07d69cdc13820ae92a019bc16bfa67ca207f68e18",
44
44
  "width": 1280,
45
45
  "height": 720,
46
- "capturedOn": "2026-10-26",
47
- "sourceVersion": "0.2.83"
46
+ "capturedOn": "2026-10-29",
47
+ "sourceVersion": "0.2.84"
48
48
  },
49
49
  {
50
50
  "path": "docs/screenshots/05-unified-tool-search.png",
51
- "sha256": "e172da60d9abcf77639287180a4fd6b4b5dca1a95ba0f3967d7d36488fdae795",
51
+ "sha256": "c2d5b02508dc9b3eae15b77ba76fbb2b45cacf3e244c78b0430b0020109cf3ce",
52
52
  "width": 1280,
53
53
  "height": 720,
54
- "capturedOn": "2026-10-26",
55
- "sourceVersion": "0.2.83"
54
+ "capturedOn": "2026-10-29",
55
+ "sourceVersion": "0.2.84"
56
56
  },
57
57
  {
58
58
  "path": "docs/screenshots/06-tool-parameters.png",
59
- "sha256": "f09f04513af0f3ee40c455df5c537b1635ae42e83073c455bfd25db0e35625b7",
59
+ "sha256": "ecf4780ecb0f2da908419e4137e3945f159ff4b1adad8e55ee587048aef5c1a7",
60
60
  "width": 1280,
61
61
  "height": 720,
62
- "capturedOn": "2026-10-26",
63
- "sourceVersion": "0.2.83"
62
+ "capturedOn": "2026-10-29",
63
+ "sourceVersion": "0.2.84"
64
64
  },
65
65
  {
66
66
  "path": "docs/screenshots/07-connection-diagnostics.png",
67
- "sha256": "457898c3a256c06f613cc602dcd69193f54fcc59b5ca278228e66fc31a7e32cc",
67
+ "sha256": "f69df9eba4d3dc9b7f5100dc5479ec9c1fbf30ddf469a2e0e7942cde23132361",
68
68
  "width": 1280,
69
69
  "height": 720,
70
- "capturedOn": "2026-10-26",
71
- "sourceVersion": "0.2.83"
70
+ "capturedOn": "2026-10-29",
71
+ "sourceVersion": "0.2.84"
72
72
  }
73
73
  ],
74
74
  "demo": {
75
75
  "path": "docs/demo.gif",
76
- "sha256": "7501018e2e32d565a309473c666f1cf02601746ce78e04d2452a4368f851c1f1",
76
+ "sha256": "5f92ba8ea94ae1c42999c198cfdb8f9737ff6845b936a78804385d05fc88d223",
77
77
  "width": 960,
78
78
  "height": 540,
79
- "capturedOn": "2026-10-26",
80
- "sourceVersion": "0.2.83",
79
+ "capturedOn": "2026-10-29",
80
+ "sourceVersion": "0.2.84",
81
81
  "durationSeconds": 36
82
82
  }
83
83
  }
@@ -8,7 +8,7 @@
8
8
 
9
9
  | 项目 | 验收要求 |
10
10
  |---|---|
11
- | 前提 | <!-- generated:version -->正式 `dsh-mcp-connector@0.2.83`<!-- /generated:version -->;当前 Workspace;企查查 OAuth 可用;测试账号具有目标企业数据权限 |
11
+ | 前提 | <!-- generated:version -->正式 `dsh-mcp-connector@0.2.84`<!-- /generated:version -->;当前 Workspace;企查查 OAuth 可用;测试账号具有目标企业数据权限 |
12
12
  | 权限/管理员 | 账号权限、组织授权和可见字段由服务商控制;企业组织可能需要管理员开通,当前文档不能替代审批 |
13
13
  | 费用 | 可能受套餐、次数或字段权限影响;MCP连接器无法确认本次费用,调用前在服务商侧核对 |
14
14
  | 运行/数据去向 | 远程 MCP Server;企业名称、查询参数和调用结果经 DSH Host 发送到/返回自 `agent.qcc.com` |
@@ -0,0 +1,111 @@
1
+ /** Local, profile-scoped facts. No network, account IDs, credentials or business data. */
2
+ import { z } from 'zod';
3
+ export const connectionStatisticSchema = z.object({
4
+ connectorId: z.string().min(1).max(256),
5
+ firstObservedAt: z.number().int().nonnegative(),
6
+ baseline: z.boolean(),
7
+ firstSuccessAt: z.number().int().nonnegative().nullable(),
8
+ });
9
+ export class ConnectionStatistics {
10
+ constructor(table, { now = Date.now, timeoutMs = 1000, maxPending = 128 } = {}) {
11
+ this.table = table;
12
+ this.now = now;
13
+ this.records = new Map();
14
+ this.queue = Promise.resolve();
15
+ this.available = true;
16
+ this.timeoutMs = timeoutMs;
17
+ this.maxPending = maxPending;
18
+ this.pending = 0;
19
+ }
20
+ async load() {
21
+ for (const [key, raw] of this.table.entries()) {
22
+ const result = connectionStatisticSchema.safeParse(raw);
23
+ if (!result.success || key !== result.data.connectorId) throw Error('Invalid connection statistics');
24
+ this.records.set(key, result.data);
25
+ }
26
+ }
27
+ write(action) {
28
+ if (!this.available) return Promise.resolve();
29
+ if (this.pending >= this.maxPending) {
30
+ this.available = false;
31
+ return Promise.reject(Error('Statistics queue full'));
32
+ }
33
+ this.pending++;
34
+ const pending = this.queue.catch(() => {}).then(async () => {
35
+ if (!this.available) return;
36
+ let timer;
37
+ try {
38
+ await Promise.race([
39
+ Promise.resolve().then(action),
40
+ new Promise((_, reject) => {
41
+ timer = setTimeout(() => reject(Error('Statistics timeout')), this.timeoutMs);
42
+ }),
43
+ ]);
44
+ } catch (error) {
45
+ this.available = false;
46
+ throw error;
47
+ } finally {
48
+ clearTimeout(timer);
49
+ }
50
+ }).finally(() => { this.pending--; });
51
+ this.queue = pending;
52
+ return pending;
53
+ }
54
+ dispose() { this.available = false; }
55
+ async put(record) {
56
+ // Publish memory only after durable storage succeeds.
57
+ const safe = connectionStatisticSchema.parse(record);
58
+ await this.table.put(safe.connectorId, safe);
59
+ if (this.available) this.records.set(safe.connectorId, safe);
60
+ }
61
+ baseline(ids) {
62
+ return this.write(async () => {
63
+ for (const id of new Set(ids)) {
64
+ if (!this.available) return;
65
+ if (!this.records.has(id)) await this.put({ connectorId: id, firstObservedAt: this.now(), baseline: true, firstSuccessAt: null });
66
+ }
67
+ });
68
+ }
69
+ success(id) {
70
+ return this.write(async () => {
71
+ const existing = this.records.get(id);
72
+ if (existing?.firstSuccessAt != null) return;
73
+ await this.put({ connectorId: id, firstObservedAt: existing?.firstObservedAt ?? this.now(), baseline: existing?.baseline ?? false, firstSuccessAt: this.now() });
74
+ });
75
+ }
76
+ snapshot() {
77
+ const cutoff = this.now() - 30 * 86400000;
78
+ const items = [...this.records.values()].map(r => ({
79
+ connectorId: r.connectorId,
80
+ cumulativeSuccessfulConnections: r.firstSuccessAt == null ? 0 : 1,
81
+ newSuccessfulConnections30d: !r.baseline && r.firstSuccessAt != null && r.firstSuccessAt >= cutoff ? 1 : 0,
82
+ historicalBaseline: r.baseline,
83
+ }));
84
+ return { scope: 'local-profile', reportingEnabled: false, available: this.available,
85
+ cumulativeSuccessfulConnections: items.reduce((n, r) => n + r.cumulativeSuccessfulConnections, 0),
86
+ newSuccessfulConnections30d: items.reduce((n, r) => n + r.newSuccessfulConnections30d, 0),
87
+ historicalBaseline: items.filter(r => r.historicalBaseline).length, items };
88
+ }
89
+ }
90
+
91
+ /** Wrap final outcomes, not saves: rollback, cancelled OAuth and validation errors never count. */
92
+ export function observeConnectionSuccess(api, statistics, { known, onError = () => {} }) {
93
+ let warned = false;
94
+ const report = () => {
95
+ if (warned) return;
96
+ warned = true;
97
+ try { onError(); } catch { /* Diagnostics must never break connections. */ }
98
+ };
99
+ for (const method of ['connect', 'configure']) {
100
+ const action = api[method];
101
+ api[method] = async function (...args) {
102
+ const id = method === 'connect' ? args[0] : args[0]?.connectorId;
103
+ const result = await action.apply(this, args);
104
+ if (statistics.available && result?.ok === true && typeof id === 'string' && known(id)) {
105
+ // Optional bookkeeping must not delay the successful connection response.
106
+ void statistics.success(id).catch(report);
107
+ }
108
+ return result;
109
+ };
110
+ }
111
+ }
package/lib/index.js CHANGED
@@ -11,6 +11,7 @@
11
11
  * export_config / snapshots / install_from_url / status / rename / set_enabled /
12
12
  * disconnect / refresh_catalog / publish / tools_list / tool_search / tool_detail
13
13
  */
14
+ import { ConnectionStatistics, observeConnectionSuccess } from './connection-statistics.js';
14
15
  import { randomUUID } from 'node:crypto';
15
16
  import z from '@deepseek-ai/schemastery';
16
17
  import {
@@ -155,6 +156,13 @@ export async function apply(ctx, config) {
155
156
  });
156
157
 
157
158
  const connectionStore = new ConnectionStore(domain);
159
+ const statisticTable = config.persistSecrets ? domain.tables.get('connection_statistics') : new Map();
160
+ const connectionStatistics = new ConnectionStatistics(config.persistSecrets ? statisticTable : {
161
+ entries: () => statisticTable.entries(), put: async (key, value) => statisticTable.set(key, value),
162
+ });
163
+ const statisticsError = () => logger.warn('Local connection statistics unavailable; connection behavior is unchanged');
164
+ try { await connectionStatistics.load(); }
165
+ catch { connectionStatistics.available = false; statisticsError(); }
158
166
  const grantStore = new GrantStore(domain, {
159
167
  // 只有真实持久化模式才启用跨进程 Grant journal。测试可通过内部字段
160
168
  // 传入临时目录,不让 fake storage 触碰用户真实 $DSH_HOME。
@@ -1689,6 +1697,9 @@ export async function apply(ctx, config) {
1689
1697
  /* ───────────────────────── api 门面 ───────────────────────── */
1690
1698
 
1691
1699
  const api = {
1700
+ async connectionStatistics() {
1701
+ return { ok: true, detail: { ...connectionStatistics.snapshot(), persistent: config.persistSecrets === true }, message: '本 profile 成功连接过的卡片数;不是连接次数或社区总量,不上传数据' };
1702
+ },
1692
1703
  async versionStatus(force = false) {
1693
1704
  const detail = versionStatusService.status({ force });
1694
1705
  let message = `当前版本 v${detail.installedVersion}`;
@@ -3375,6 +3386,9 @@ export async function apply(ctx, config) {
3375
3386
  logger.warn(`skip invalid stored connection "${key}": ${error.message}`);
3376
3387
  }
3377
3388
  }
3389
+ if (connectionStatistics.available) void connectionStatistics.baseline([...state.connections.values()]
3390
+ .map(record => record.connectorId).filter(id => state.merged.some(d => d.id === id)))
3391
+ .catch(() => { statisticsError(); });
3378
3392
  if (config.persistSecrets) {
3379
3393
  for (const [key, cached] of await toolCatalogStore.entries().catch(() => [])) {
3380
3394
  const record = state.connections.get(key);
@@ -3528,6 +3542,10 @@ export async function apply(ctx, config) {
3528
3542
  return result;
3529
3543
  };
3530
3544
  } });
3545
+ observeConnectionSuccess(api, connectionStatistics, {
3546
+ known: id => state.merged.some(d => d.id === id) && !state.dynamic.has(id),
3547
+ onError: statisticsError,
3548
+ });
3531
3549
  const observableApi = observeStatusEvents(discoveryApi, statusEvents);
3532
3550
  scheduleDiscovery();
3533
3551
  const discoveryInterval = setInterval(() => {
@@ -3551,6 +3569,7 @@ export async function apply(ctx, config) {
3551
3569
  }
3552
3570
 
3553
3571
  ctx.effect(() => () => {
3572
+ connectionStatistics.dispose();
3554
3573
  discoveryDisposed = true;
3555
3574
  clearTimeout(discoveryTimer);
3556
3575
  clearInterval(discoveryInterval);
package/lib/stores.js CHANGED
@@ -4,6 +4,7 @@
4
4
  * OAuth grant 同步写入本机受限权限 journal,防止多 Host 的整文件
5
5
  * last-write-wins 覆盖新轮换 Token;凭证不进入 loader 配置树或日志。
6
6
  */
7
+ import { connectionStatisticSchema } from './connection-statistics.js';
7
8
  import { defineDomain, domainTable } from '@deepseek-ai/dsh-storage-domain';
8
9
  import { connectionRecordSchema, connectionScopeDocumentSchema, connectionSnapshotSchema, governancePolicySchema, grantRecordSchema, catalogRecordSchema, toolCatalogRecordSchema } from './schema.js';
9
10
  import { DEFAULT_ACCOUNT } from './constants.js';
@@ -23,6 +24,7 @@ export function defineConnectorDomain() {
23
24
  governance: domainTable(governancePolicySchema),
24
25
  connection_scopes: domainTable(connectionScopeDocumentSchema),
25
26
  tool_catalog: domainTable(toolCatalogRecordSchema),
27
+ connection_statistics: domainTable(connectionStatisticSchema),
26
28
  },
27
29
  });
28
30
  }
package/lib/web.js CHANGED
@@ -35,6 +35,7 @@ const API_WHITELIST = new Map([
35
35
  ['applyConnectionScope', (api, p) => api.applyConnectionScope(p ?? {})],
36
36
  ['previewConnectionScopeRollback', (api, p) => api.previewConnectionScopeRollback(p?.rollbackRevision)],
37
37
  ['rollbackConnectionScope', (api, p) => api.rollbackConnectionScope(p?.rollbackRevision, p?.expectedRevision)],
38
+ ['connectionStatistics', (api) => api.connectionStatistics()],
38
39
  ['catalog', (api, p) => api.catalog(p ?? {})],
39
40
  ['templateCatalogReferences', (api) => api.templateCatalogReferences()],
40
41
  ['status', (api, p) => api.status(p ?? {})],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mcp-connector",
3
- "version": "0.2.83",
3
+ "version": "0.2.84",
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",
package/ui/index.html CHANGED
@@ -1720,14 +1720,14 @@
1720
1720
  const pendingMigration = migration.ok ? migration.detail?.pendingCount || 0 : 0;
1721
1721
  const migrationHtml = pendingMigration > 0 ? `<div class="migration-banner"><div class="copy"><strong>发现旧企查查 MCP 授权</strong>可安全复制 ${pendingMigration} 组授权到 MCP连接器;不会删除旧插件或原凭据。</div><button class="btn" type="button" onclick="window.__mcp.migrateLegacy()">迁移</button></div>` : '';
1722
1722
  if (!items.length) {
1723
- main.innerHTML = `${migrationHtml}<div class="stats"><span class="count">可从旧企查查 OAuth 插件复制已有授权</span><button class="btn ghost" id="config-backup" type="button" onclick="window.__mcp.openConfigBackup()">配置备份</button><button class="btn ghost" type="button" title="扫描企查查旧 OAuth 插件;不会删除旧插件或原凭据" onclick="window.__mcp.scanLegacy()">检测企查查旧授权</button></div><div class="empty">还没有连接任何 MCP · 到「市场」里连接一个吧</div>`;
1723
+ main.innerHTML = `${migrationHtml}<div class="stats"><span class="count">可从旧企查查 OAuth 插件复制已有授权</span><button class="btn ghost" type="button" onclick="window.__mcp.openConnectionStatistics()">本机连接统计</button><button class="btn ghost" id="config-backup" type="button" onclick="window.__mcp.openConfigBackup()">配置备份</button><button class="btn ghost" type="button" title="扫描企查查旧 OAuth 插件;不会删除旧插件或原凭据" onclick="window.__mcp.scanLegacy()">检测企查查旧授权</button></div><div class="empty">还没有连接任何 MCP · 到「市场」里连接一个吧</div>`;
1724
1724
  if (preserveScroll) main.scrollTop = previousScrollTop;
1725
1725
  return;
1726
1726
  }
1727
1727
  markCommunityCtaEligible();
1728
1728
  const filtered = items.filter(matchesSearch);
1729
1729
  const rollbackDisabled = scopeRollbackRevision === null ? 'disabled' : '';
1730
- main.innerHTML = `${migrationHtml}<div class="stats"><span class="count">共 <strong>${filtered.length}</strong> 条连接${searchQuery ? ` · 搜索「${esc(searchQuery)}」` : ''} · 作用域 revision=${scopeRevision}</span><button class="btn ghost" id="scope-rollback" type="button" ${rollbackDisabled} onclick="window.__mcp.rollbackScope()">回滚上次范围变更</button><button class="btn ghost" id="config-backup" type="button" onclick="window.__mcp.openConfigBackup()">配置备份</button><button class="btn ghost" type="button" title="扫描企查查旧 OAuth 插件;不会删除旧插件或原凭据" onclick="window.__mcp.scanLegacy()">检测企查查旧授权</button></div><div class="rows">${filtered.map(rowHtml).join('')}</div>${communityCtaHtml()}`;
1730
+ main.innerHTML = `${migrationHtml}<div class="stats"><span class="count">共 <strong>${filtered.length}</strong> 条连接${searchQuery ? ` · 搜索「${esc(searchQuery)}」` : ''} · 作用域 revision=${scopeRevision}</span><button class="btn ghost" id="scope-rollback" type="button" ${rollbackDisabled} onclick="window.__mcp.rollbackScope()">回滚上次范围变更</button><button class="btn ghost" type="button" onclick="window.__mcp.openConnectionStatistics()">本机连接统计</button><button class="btn ghost" id="config-backup" type="button" onclick="window.__mcp.openConfigBackup()">配置备份</button><button class="btn ghost" type="button" title="扫描企查查旧 OAuth 插件;不会删除旧插件或原凭据" onclick="window.__mcp.scanLegacy()">检测企查查旧授权</button></div><div class="rows">${filtered.map(rowHtml).join('')}</div>${communityCtaHtml()}`;
1731
1731
  if (preserveScroll) main.scrollTop = previousScrollTop;
1732
1732
  } finally { finishViewRender(render); }
1733
1733
  }
@@ -2206,6 +2206,20 @@
2206
2206
  },
2207
2207
  openAdd(mode) { openAddConnection(mode); },
2208
2208
  openConfig(connectorId) { openAddConnection('manual', marketItems[connectorId] || {}); },
2209
+ async openConnectionStatistics() {
2210
+ openModal('本机连接统计', '<p>正在读取本机记录…</p>');
2211
+ const r = await call('connectionStatistics', {});
2212
+ const d = r.detail;
2213
+ if (!r.ok || !d?.available) {
2214
+ openModal('本机连接统计', '<p>统计暂不可用,不影响连接。请检查 Host 日志。</p>');
2215
+ return;
2216
+ }
2217
+ openModal('本机连接统计', `<div class="form-note">仅统计当前 profile,不是社区总量或独立用户数。数据保存在本机,不向外上传。${d.persistent ? '' : '当前未启用持久化,重启后计数清空。'}</div>
2218
+ <p>成功连接过的卡片数 <strong>${esc(d.cumulativeSuccessfulConnections)}</strong> · 近 30 天首次连接的新卡片 <strong>${esc(d.newSuccessfulConnections30d)}</strong></p>
2219
+ <p>历史已有连接基线:${esc(d.historicalBaseline)} 张卡片,未验证前不计成功,验证后也不计新增。</p>
2220
+ <p>同一卡片只计一次;重启、升级、重新授权和重连不重复增加,断开不扣减。此处成功指连接流程完成,不代表业务调用成功。</p>
2221
+ <div>${(d.items || []).map(x => `<p><strong>${esc(x.connectorId)}</strong>:${x.cumulativeSuccessfulConnections ? '已记录成功' : '历史配置,待验证'}${x.historicalBaseline ? ' · 历史基线' : ''}</p>`).join('') || '尚无统计记录。'}</div>`);
2222
+ },
2209
2223
  async openConfigBackup() { await openConfigBackup(); },
2210
2224
  async copyBackup() {
2211
2225
  const text = $('#backup-json')?.value || '';