dsh-agent-control-center 0.4.0 → 0.5.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/CHANGELOG.md +84 -0
- package/README.md +4 -4
- package/README.zh.md +4 -4
- package/client.js +247 -18
- package/docs/01-CONTRACT.md +1 -1
- package/docs/05-ACCEPTANCE-EVIDENCE.md +72 -2
- package/docs/07-GUIDE.md +1 -1
- package/docs/08-COMPATIBILITY.md +23 -4
- package/docs/09-ARCHITECTURE.md +1 -1
- package/docs/12-PLUGIN-HEALTH.md +18 -1
- package/docs/13-PAGE-REGRESSION-0.4.0.md +47 -0
- package/index.js +1 -1
- package/lib/core/caps.js +28 -7
- package/lib/core/compat.js +16 -5
- package/lib/core/http.js +17 -1
- package/lib/core/tools-view.js +92 -0
- package/lib/modules/b-tools.js +62 -38
- package/lib/modules/e-meta.js +12 -10
- package/lib/modules/l-health.js +182 -1
- package/package.json +1 -1
- package/src/client/i18n/health.js +56 -0
- package/src/client/pages/health.js +147 -0
- package/src/client/pages/tools.js +42 -16
package/lib/modules/e-meta.js
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
*/
|
|
30
30
|
import path from 'node:path'
|
|
31
31
|
import { ensureDir, writeJsonAtomic } from '../core/atomic.js'
|
|
32
|
+
import { isExecutable, readDefinitions, toolsApiKind } from '../core/tools-view.js'
|
|
32
33
|
|
|
33
34
|
const EXPORT_SCHEMA_VERSION = 1
|
|
34
35
|
const EXPORT_KIND = 'dsh-agent-control-center/config-export'
|
|
@@ -280,15 +281,15 @@ export default function createModule(core) {
|
|
|
280
281
|
/** Visible tool count for one Agent (`tools.definitions(agent)`), never executes. */
|
|
281
282
|
function toolCountOf(agent) {
|
|
282
283
|
const tools = service('tools')
|
|
283
|
-
if (tools === undefined ||
|
|
284
|
+
if (tools === undefined || toolsApiKind(tools) === null) {
|
|
284
285
|
return unavailable('宿主未提供 tools 服务')
|
|
285
286
|
}
|
|
286
287
|
try {
|
|
287
|
-
const definitions = tools.definitions
|
|
288
|
+
const definitions = readDefinitions(tools, agent).definitions
|
|
288
289
|
return {
|
|
289
290
|
available: true,
|
|
290
291
|
value: Array.isArray(definitions) ? definitions.length : 0,
|
|
291
|
-
basis: '
|
|
292
|
+
basis: 'Agent 作用域可见数(readDefinitions(agent);0.2.3 起为 getAll(agent))(统计口径为可见工具,不是执行探活)',
|
|
292
293
|
}
|
|
293
294
|
} catch (error) {
|
|
294
295
|
return unavailable('读取 Agent 可见工具失败', redactText(error?.message ?? error, 160))
|
|
@@ -355,7 +356,7 @@ export default function createModule(core) {
|
|
|
355
356
|
async function toolsForPresets(presetIds) {
|
|
356
357
|
const tools = service('tools')
|
|
357
358
|
const presets = service('agentPresets')
|
|
358
|
-
if (tools === undefined ||
|
|
359
|
+
if (tools === undefined || toolsApiKind(tools) === null) {
|
|
359
360
|
return { available: false, reason: '宿主未提供 tools 服务', results: new Map() }
|
|
360
361
|
}
|
|
361
362
|
if (presets === undefined || typeof presets.acquireScope !== 'function') {
|
|
@@ -366,21 +367,22 @@ export default function createModule(core) {
|
|
|
366
367
|
let lease
|
|
367
368
|
try {
|
|
368
369
|
lease = await presets.acquireScope(presetId)
|
|
369
|
-
const definitions = tools
|
|
370
|
+
const definitions = readDefinitions(tools, lease.key).definitions
|
|
370
371
|
const names = Array.isArray(definitions) ? definitions.map((definition) => text(definition?.name)).filter((name) => name.length > 0) : []
|
|
371
372
|
let conditional = null
|
|
372
|
-
|
|
373
|
+
const capabilityKnown = typeof tools?.executable === 'function' || typeof tools?.get === 'function'
|
|
374
|
+
if (capabilityKnown) {
|
|
373
375
|
conditional = 0
|
|
374
376
|
for (const name of names) {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
} catch {
|
|
377
|
+
const executable = isExecutable(tools, name, lease.key)
|
|
378
|
+
if (executable === null) {
|
|
378
379
|
conditional = null
|
|
379
380
|
break
|
|
380
381
|
}
|
|
382
|
+
if (executable === false) conditional += 1
|
|
381
383
|
}
|
|
382
384
|
}
|
|
383
|
-
results.set(presetId, { available: true, visible: names.length, conditional, basis: '
|
|
385
|
+
results.set(presetId, { available: true, visible: names.length, conditional, basis: '作用域可见数(readDefinitions(lease.key);0.2.3 起为 getAll);acquireScope 租约已释放' })
|
|
384
386
|
} catch (error) {
|
|
385
387
|
results.set(presetId, unavailable('读取预设可见工具失败', redactText(error?.message ?? error, 160)))
|
|
386
388
|
} finally {
|
package/lib/modules/l-health.js
CHANGED
|
@@ -764,6 +764,14 @@ export default function createModule(core) {
|
|
|
764
764
|
return Array.isArray(value.conflicts) && value.conflicts.length > 0 ? 'warn' : 'ok'
|
|
765
765
|
}
|
|
766
766
|
|
|
767
|
+
/** @param {Record<string, any>} value @returns {'ok' | 'warn' | 'error'} */
|
|
768
|
+
function driftSeverity(value) {
|
|
769
|
+
if (value.available !== true) return 'warn'
|
|
770
|
+
const drifts = Array.isArray(value.drifts) ? value.drifts : []
|
|
771
|
+
if (drifts.some((drift) => drift.kind === 'startup-failed')) return 'error'
|
|
772
|
+
return drifts.length > 0 ? 'warn' : 'ok'
|
|
773
|
+
}
|
|
774
|
+
|
|
767
775
|
/** @param {Record<string, any>} value @returns {'ok' | 'warn' | 'error'} */
|
|
768
776
|
function compatSeverity(value) {
|
|
769
777
|
if (value.available !== true) return 'error'
|
|
@@ -791,13 +799,178 @@ export default function createModule(core) {
|
|
|
791
799
|
return worst
|
|
792
800
|
}
|
|
793
801
|
|
|
802
|
+
/**
|
|
803
|
+
* Compare what the profile declares with what the Loader is running. Two
|
|
804
|
+
* host services carry that evidence: `pluginManager` knows each row's
|
|
805
|
+
* effective enablement and fiber phase, `configEditor` knows which rows are
|
|
806
|
+
* addressable through the profile patch. Reading the patch file itself is
|
|
807
|
+
* refused by the path fence, so this answer never claims to have parsed it.
|
|
808
|
+
*
|
|
809
|
+
* @param {Record<string, unknown>} params
|
|
810
|
+
* @returns {Promise<Record<string, unknown>>}
|
|
811
|
+
*/
|
|
812
|
+
async function driftMethod(params) {
|
|
813
|
+
assertParams(params)
|
|
814
|
+
// `listBundles()` walks every install location and costs seconds on a large
|
|
815
|
+
// profile, so the bundle half is opt-in and the page asks for it on demand.
|
|
816
|
+
const includeBundles = util.boolParam(isPlainObject(params) ? params : {}, 'includeBundles', false)
|
|
817
|
+
const manager = service('pluginManager')
|
|
818
|
+
const editor = service('configEditor')
|
|
819
|
+
const notes = []
|
|
820
|
+
/** @type {Array<{ entryId: string, moduleName: string, enabled: boolean | null, fiberPhase: string | null, addressable: boolean, inProfile: boolean | null }>} */
|
|
821
|
+
/** @type {Map<string, string>} entryId → the id a profile patch would use */
|
|
822
|
+
const profileIdsOf = new Map()
|
|
823
|
+
const rows = []
|
|
824
|
+
/** @type {Array<{ kind: string, id: string, detail: string, suggestion: string }>} */
|
|
825
|
+
const drifts = []
|
|
826
|
+
|
|
827
|
+
if (manager === undefined || manager === null || typeof manager.listPlugins !== 'function') {
|
|
828
|
+
notes.push('宿主未提供 pluginManager.listPlugins:无法比较声明与运行时')
|
|
829
|
+
} else {
|
|
830
|
+
let listed
|
|
831
|
+
try {
|
|
832
|
+
listed = await manager.listPlugins()
|
|
833
|
+
} catch (error) {
|
|
834
|
+
notes.push(`pluginManager.listPlugins 失败:${util.redact(errorMessage(error), 120)}`)
|
|
835
|
+
listed = null
|
|
836
|
+
}
|
|
837
|
+
if (Array.isArray(listed)) {
|
|
838
|
+
for (const row of listed.slice(0, MAX_PLUGIN_ITEMS)) {
|
|
839
|
+
if (!isPlainObject(row)) continue
|
|
840
|
+
const entryId = util.redact(typeof row.entryId === 'string' ? row.entryId : '', 160)
|
|
841
|
+
const moduleName = util.redact(typeof row.moduleName === 'string' ? row.moduleName : '', 160)
|
|
842
|
+
const enabled = typeof row.enabled === 'boolean' ? row.enabled : null
|
|
843
|
+
const fiberPhase = typeof row.fiberPhase === 'string' ? row.fiberPhase : null
|
|
844
|
+
const addressable = typeof row.patchId === 'string' && row.patchId.length > 0
|
|
845
|
+
// Loader entry ids carry an `include:` prefix; profile patch ids do not.
|
|
846
|
+
const profileId = entryId.startsWith('include:') ? entryId.slice('include:'.length) : entryId
|
|
847
|
+
rows.push({ entryId, moduleName, enabled, fiberPhase, addressable, inProfile: null })
|
|
848
|
+
profileIdsOf.set(entryId, profileId)
|
|
849
|
+
const diagnostic = typeof row.diagnostic === 'string' && row.diagnostic.length > 0
|
|
850
|
+
? util.redact(row.diagnostic, 300)
|
|
851
|
+
: null
|
|
852
|
+
if (diagnostic !== null && drifts.length < MAX_ANOMALIES) {
|
|
853
|
+
drifts.push({
|
|
854
|
+
kind: 'startup-failed',
|
|
855
|
+
id: entryId || moduleName,
|
|
856
|
+
detail: `插件行 ${moduleName || entryId} 启动失败:${diagnostic}`,
|
|
857
|
+
suggestion: '修好该插件的配置或依赖后重载 profile;本页只读,不会替你重启或改写行',
|
|
858
|
+
})
|
|
859
|
+
}
|
|
860
|
+
if (enabled === true && fiberPhase !== null && fiberPhase !== 'active' && drifts.length < MAX_ANOMALIES) {
|
|
861
|
+
drifts.push({
|
|
862
|
+
kind: 'enabled-not-running',
|
|
863
|
+
id: entryId || moduleName,
|
|
864
|
+
detail: `插件行 ${moduleName || entryId} 声明为启用但运行时相位是 ${fiberPhase}`,
|
|
865
|
+
suggestion: '确认该模块是否加载失败(见 diagnostics 行),必要时在 DSH 原生插件页重载',
|
|
866
|
+
})
|
|
867
|
+
}
|
|
868
|
+
if (enabled === false && fiberPhase === 'active' && drifts.length < MAX_ANOMALIES) {
|
|
869
|
+
drifts.push({
|
|
870
|
+
kind: 'disabled-but-running',
|
|
871
|
+
id: entryId || moduleName,
|
|
872
|
+
detail: `插件行 ${moduleName || entryId} 声明为停用但运行时仍在 active`,
|
|
873
|
+
suggestion: '该行多半是在本次会话启动后才被停用;重载 profile 才会真正卸载',
|
|
874
|
+
})
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
} else if (listed !== null) {
|
|
878
|
+
notes.push('pluginManager.listPlugins 的返回值不是数组')
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
/** @type {Set<string>} */
|
|
883
|
+
const mountedIds = new Set()
|
|
884
|
+
if (editor === undefined || editor === null || typeof editor.entries !== 'function') {
|
|
885
|
+
notes.push('宿主未提供 configEditor.entries:无法确认哪些行能通过 profile patch 寻址')
|
|
886
|
+
} else {
|
|
887
|
+
try {
|
|
888
|
+
const entries = editor.entries()
|
|
889
|
+
for (const entry of (Array.isArray(entries) ? entries : []).slice(0, MAX_PLUGIN_ITEMS)) {
|
|
890
|
+
const id = isPlainObject(entry) && isPlainObject(entry.options) && typeof entry.options.id === 'string'
|
|
891
|
+
? entry.options.id
|
|
892
|
+
: null
|
|
893
|
+
if (id !== null) mountedIds.add(util.redact(id, 160))
|
|
894
|
+
}
|
|
895
|
+
} catch (error) {
|
|
896
|
+
notes.push(`configEditor.entries 失败:${util.redact(errorMessage(error), 120)}`)
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
/**
|
|
901
|
+
* Rows provided by a bundle or by the installation itself are addressable
|
|
902
|
+
* through the plugin manager but not owned by this profile's patch. That is
|
|
903
|
+
* normal, not drift: it is reported as a count so nobody reads the rows
|
|
904
|
+
* list as "profile rows".
|
|
905
|
+
*/
|
|
906
|
+
if (mountedIds.size > 0 && rows.length > 0) {
|
|
907
|
+
let inProfile = 0
|
|
908
|
+
for (const row of rows) {
|
|
909
|
+
const profileId = profileIdsOf.get(row.entryId) ?? row.entryId
|
|
910
|
+
const owned = mountedIds.has(profileId)
|
|
911
|
+
row.inProfile = owned
|
|
912
|
+
if (owned) inProfile += 1
|
|
913
|
+
}
|
|
914
|
+
const outside = rows.length - inProfile
|
|
915
|
+
if (outside > 0) {
|
|
916
|
+
notes.push(`${outside} 行由 bundle 或安装自带的 patch 提供,不受本 profile 的 patch 管辖;调整它们要用 DSH 原生插件页`)
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
// A bundle the profile asks for but the installation cannot provide.
|
|
921
|
+
if (includeBundles !== true) {
|
|
922
|
+
notes.push('未检查 bundle 安装状态:`includeBundles: true` 会读取每个安装位置,通常需要数秒')
|
|
923
|
+
} else if (manager !== undefined && manager !== null && typeof manager.listBundles === 'function') {
|
|
924
|
+
try {
|
|
925
|
+
const bundles = await manager.listBundles()
|
|
926
|
+
for (const bundle of (Array.isArray(bundles) ? bundles : []).slice(0, MAX_PLUGIN_ITEMS)) {
|
|
927
|
+
if (!isPlainObject(bundle) || bundle.availability !== 'missing') continue
|
|
928
|
+
if (drifts.length >= MAX_ANOMALIES) break
|
|
929
|
+
const name = util.redact(typeof bundle.name === 'string' ? bundle.name : '', 160)
|
|
930
|
+
drifts.push({
|
|
931
|
+
kind: 'declared-not-installed',
|
|
932
|
+
id: name,
|
|
933
|
+
detail: `profile 声明了 bundle ${name},但安装目录里找不到它(availability=missing)`,
|
|
934
|
+
suggestion: '重新安装该 bundle,或从 profile 里移除这一行',
|
|
935
|
+
})
|
|
936
|
+
}
|
|
937
|
+
} catch (error) {
|
|
938
|
+
notes.push(`pluginManager.listBundles 失败:${util.redact(errorMessage(error), 120)}`)
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
const self = rows.find((row) => row.moduleName === 'dsh-agent-control-center')
|
|
943
|
+
return {
|
|
944
|
+
available: rows.length > 0 || mountedIds.size > 0,
|
|
945
|
+
source: 'pluginManager.listPlugins + pluginManager.listBundles + configEditor.entries',
|
|
946
|
+
rows,
|
|
947
|
+
mountedRows: mountedIds.size,
|
|
948
|
+
inProfileRows: rows.filter((row) => row.inProfile === true).length,
|
|
949
|
+
bundlesChecked: includeBundles === true,
|
|
950
|
+
self: self === undefined
|
|
951
|
+
? null
|
|
952
|
+
: {
|
|
953
|
+
entryId: self.entryId,
|
|
954
|
+
profileId: profileIdsOf.get(self.entryId) ?? self.entryId,
|
|
955
|
+
enabled: self.enabled,
|
|
956
|
+
fiberPhase: self.fiberPhase,
|
|
957
|
+
addressable: self.addressable,
|
|
958
|
+
inProfile: self.inProfile,
|
|
959
|
+
},
|
|
960
|
+
drifts,
|
|
961
|
+
notes,
|
|
962
|
+
note: '只读比较:不解析 profile patch 文件(该文件可能含插件密钥,路径围栏按设计拒绝读取),因此「声明」一侧取自 pluginManager 的清单与寻址结果,本页不声称读到了 YAML 内容。',
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
|
|
794
966
|
/** @returns {Promise<Record<string, unknown>>} */
|
|
795
967
|
async function summaryMethod(params) {
|
|
796
968
|
assertParams(params)
|
|
797
|
-
const [plugins, settings, sections, compat] = await Promise.all([
|
|
969
|
+
const [plugins, settings, sections, drift, compat] = await Promise.all([
|
|
798
970
|
safeProbe(() => pluginsMethod()),
|
|
799
971
|
safeProbe(() => settingsMethod()),
|
|
800
972
|
safeProbe(() => sectionsMethod()),
|
|
973
|
+
safeProbe(() => driftMethod()),
|
|
801
974
|
safeProbe(() => compatMethod()),
|
|
802
975
|
])
|
|
803
976
|
const own = ownRow()
|
|
@@ -805,6 +978,7 @@ export default function createModule(core) {
|
|
|
805
978
|
{ id: 'plugins', severity: pluginsSeverity(plugins) },
|
|
806
979
|
{ id: 'settings', severity: settingsSeverity(settings) },
|
|
807
980
|
{ id: 'sections', severity: sectionsSeverity(sections) },
|
|
981
|
+
{ id: 'drift', severity: driftSeverity(drift) },
|
|
808
982
|
{ id: 'compat', severity: compatSeverity(compat) },
|
|
809
983
|
])
|
|
810
984
|
return {
|
|
@@ -822,6 +996,11 @@ export default function createModule(core) {
|
|
|
822
996
|
count: sections.available === true && Array.isArray(sections.sections) ? sections.sections.length : null,
|
|
823
997
|
conflicts: sections.available === true && Array.isArray(sections.conflicts) ? sections.conflicts.length : null,
|
|
824
998
|
},
|
|
999
|
+
drift: {
|
|
1000
|
+
rows: Array.isArray(drift.rows) ? drift.rows.length : null,
|
|
1001
|
+
mounted: typeof drift.mountedRows === 'number' ? drift.mountedRows : null,
|
|
1002
|
+
count: Array.isArray(drift.drifts) ? drift.drifts.length : null,
|
|
1003
|
+
},
|
|
825
1004
|
compat: {
|
|
826
1005
|
level: compat.available === true && typeof compat.level === 'string' ? compat.level : null,
|
|
827
1006
|
readOnly: compat.available === true ? compat.readOnly === true : null,
|
|
@@ -853,6 +1032,8 @@ export default function createModule(core) {
|
|
|
853
1032
|
'health.settings': (params) => settingsMethod(params),
|
|
854
1033
|
/** Static scan of client bundles for literal `settings.section` registrations. */
|
|
855
1034
|
'health.sections': (params) => sectionsMethod(params),
|
|
1035
|
+
/** Declared-vs-running comparison across pluginManager and configEditor. */
|
|
1036
|
+
'health.drift': (params) => driftMethod(params),
|
|
856
1037
|
/** Compatibility verdict, preferring `core.compatibility.current()`. */
|
|
857
1038
|
'health.compat': (params) => compatMethod(params),
|
|
858
1039
|
/** One concurrent aggregate over the four probes, plus the worst section. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-agent-control-center",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "DSH Agent Control Center: AGENTS.md editing with backups, tool inventory, sessions, real token usage, agent metadata, diagnostics and templates in one settings page.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -57,6 +57,34 @@ ACC.addI18n({
|
|
|
57
57
|
'health.refresh.plugins': '刷新插件清单',
|
|
58
58
|
'health.refresh.settings': '刷新设置命名空间',
|
|
59
59
|
'health.refresh.sections': '刷新分区扫描结果',
|
|
60
|
+
'health.driftTitle': '声明与运行时(漂移)',
|
|
61
|
+
'health.driftSubtitle': 'profile 声明的插件行与 Loader 实际运行状态;不解析 patch 文件本身',
|
|
62
|
+
'health.driftTileRows': '插件行',
|
|
63
|
+
'health.driftTileMounted': 'profile 可寻址',
|
|
64
|
+
'health.driftTileInProfile': 'profile 管辖',
|
|
65
|
+
'health.driftTileCount': '漂移项',
|
|
66
|
+
'health.driftClean': '无漂移',
|
|
67
|
+
'health.driftFound': '有漂移',
|
|
68
|
+
'health.driftSelf': '本插件行',
|
|
69
|
+
'health.driftSelfEnabled': '启用',
|
|
70
|
+
'health.driftYes': '是',
|
|
71
|
+
'health.driftEmpty': '声明的插件行都在运行状态,未发现漂移。',
|
|
72
|
+
'health.driftCheckBundles': '检查 bundle 安装状态',
|
|
73
|
+
'health.driftCheckBundlesHint': '会读取每个安装位置,通常需要数秒',
|
|
74
|
+
'health.driftNotes': '说明',
|
|
75
|
+
'health.driftKindLabel': '类型',
|
|
76
|
+
'health.driftKindUnknown': '未知漂移类型',
|
|
77
|
+
'health.driftKind.startup-failed': '启动失败',
|
|
78
|
+
'health.driftKind.enabled-not-running': '已启用但未运行',
|
|
79
|
+
'health.driftKind.disabled-but-running': '已停用但仍在运行',
|
|
80
|
+
'health.driftKind.addressable-not-in-profile': '可寻址但不在 profile',
|
|
81
|
+
'health.driftKind.declared-not-installed': '声明未安装',
|
|
82
|
+
'health.driftAction.startup-failed': '修好该插件的配置或依赖,然后在 DSH 原生插件页重载',
|
|
83
|
+
'health.driftAction.enabled-not-running': '确认该模块是否加载失败(看 Diagnostics),必要时重载 profile',
|
|
84
|
+
'health.driftAction.disabled-but-running': '重载 profile 才会真正卸载该行',
|
|
85
|
+
'health.driftAction.addressable-not-in-profile': '确认该行来自哪一层 patch(bundle/内置/include)',
|
|
86
|
+
'health.driftAction.declared-not-installed': '重新安装该 bundle,或从 profile 移除该行',
|
|
87
|
+
'health.refresh.drift': '刷新漂移对比',
|
|
60
88
|
'health.refresh.compat': '刷新兼容性结论',
|
|
61
89
|
'health.refresh.host': '刷新宿主通道',
|
|
62
90
|
|
|
@@ -183,6 +211,34 @@ ACC.addI18n({
|
|
|
183
211
|
'health.refresh.plugins': 'Refresh plugin inventory',
|
|
184
212
|
'health.refresh.settings': 'Refresh settings namespaces',
|
|
185
213
|
'health.refresh.sections': 'Refresh section scan',
|
|
214
|
+
'health.driftTitle': 'Declared vs running (drift)',
|
|
215
|
+
'health.driftSubtitle': 'Plugin rows the profile declares against what the Loader actually runs; the patch file itself is not parsed',
|
|
216
|
+
'health.driftTileRows': 'Plugin rows',
|
|
217
|
+
'health.driftTileMounted': 'Addressable',
|
|
218
|
+
'health.driftTileInProfile': 'Profile-owned',
|
|
219
|
+
'health.driftTileCount': 'Drift items',
|
|
220
|
+
'health.driftClean': 'No drift',
|
|
221
|
+
'health.driftFound': 'Drift found',
|
|
222
|
+
'health.driftSelf': 'This plugin row',
|
|
223
|
+
'health.driftSelfEnabled': 'Enabled',
|
|
224
|
+
'health.driftYes': 'yes',
|
|
225
|
+
'health.driftEmpty': 'Every declared plugin row matches its running state.',
|
|
226
|
+
'health.driftCheckBundles': 'Check bundle installation',
|
|
227
|
+
'health.driftCheckBundlesHint': 'Reads every install location; usually takes seconds',
|
|
228
|
+
'health.driftNotes': 'Notes',
|
|
229
|
+
'health.driftKindLabel': 'Kind',
|
|
230
|
+
'health.driftKindUnknown': 'Unknown drift kind',
|
|
231
|
+
'health.driftKind.startup-failed': 'Startup failed',
|
|
232
|
+
'health.driftKind.enabled-not-running': 'Enabled but not running',
|
|
233
|
+
'health.driftKind.disabled-but-running': 'Disabled but still running',
|
|
234
|
+
'health.driftKind.addressable-not-in-profile': 'Addressable outside the profile',
|
|
235
|
+
'health.driftKind.declared-not-installed': 'Declared but not installed',
|
|
236
|
+
'health.driftAction.startup-failed': 'Fix that plugin configuration or dependency, then reload it from the native plugin page',
|
|
237
|
+
'health.driftAction.enabled-not-running': 'Check whether the module failed to load (Diagnostics) and reload the profile',
|
|
238
|
+
'health.driftAction.disabled-but-running': 'Reloading the profile is what actually unloads this row',
|
|
239
|
+
'health.driftAction.addressable-not-in-profile': 'Check which patch layer provides this row (bundle, built-in, include)',
|
|
240
|
+
'health.driftAction.declared-not-installed': 'Reinstall that bundle or remove the row from the profile',
|
|
241
|
+
'health.refresh.drift': 'Refresh drift comparison',
|
|
186
242
|
'health.refresh.compat': 'Refresh compatibility verdict',
|
|
187
243
|
'health.refresh.host': 'Refresh host channel',
|
|
188
244
|
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
const STACK_STYLE = { display: 'flex', flexDirection: 'column', gap: '8px' }
|
|
23
23
|
const COLUMN_STYLE = { display: 'flex', flexDirection: 'column', gap: '2px' }
|
|
24
24
|
const SMALL_STYLE = { fontSize: '11px' }
|
|
25
|
+
const FLEX_WRAP_STYLE = { display: 'flex', flexWrap: 'wrap', gap: '8px' }
|
|
25
26
|
const BREAK_STYLE = { wordBreak: 'break-word' }
|
|
26
27
|
const EMPTY_VALUE = '—'
|
|
27
28
|
|
|
@@ -30,6 +31,9 @@
|
|
|
30
31
|
/** Anomaly kind → shared tone; `unaddressable` rows are usable, only uneditable. */
|
|
31
32
|
const ANOMALY_TONE = { 'duplicate-module': 'warn', unaddressable: 'warn' }
|
|
32
33
|
/** Summary section id → navigation copy. */
|
|
34
|
+
|
|
35
|
+
/** Drift kinds carry their own tone: a startup failure is red, the rest amber. */
|
|
36
|
+
const DRIFT_TONE = { 'startup-failed': 'danger', 'enabled-not-running': 'warn', 'disabled-but-running': 'warn', 'addressable-not-in-profile': 'warn', 'declared-not-installed': 'warn' }
|
|
33
37
|
const BLOCK_KEYS = {
|
|
34
38
|
plugins: 'health.block.plugins',
|
|
35
39
|
settings: 'health.block.settings',
|
|
@@ -95,6 +99,26 @@
|
|
|
95
99
|
return t('health.anomalyActionGeneric')
|
|
96
100
|
}
|
|
97
101
|
|
|
102
|
+
/** @param {string} kind @param {Function} t @returns {string} */
|
|
103
|
+
function driftKindLabel(kind, t) {
|
|
104
|
+
if (kind === 'startup-failed') return t('health.driftKind.startup-failed')
|
|
105
|
+
if (kind === 'enabled-not-running') return t('health.driftKind.enabled-not-running')
|
|
106
|
+
if (kind === 'disabled-but-running') return t('health.driftKind.disabled-but-running')
|
|
107
|
+
if (kind === 'addressable-not-in-profile') return t('health.driftKind.addressable-not-in-profile')
|
|
108
|
+
if (kind === 'declared-not-installed') return t('health.driftKind.declared-not-installed')
|
|
109
|
+
return t('health.driftKindUnknown')
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** @param {string} kind @param {Function} t @returns {string} */
|
|
113
|
+
function driftAction(kind, t) {
|
|
114
|
+
if (kind === 'startup-failed') return t('health.driftAction.startup-failed')
|
|
115
|
+
if (kind === 'enabled-not-running') return t('health.driftAction.enabled-not-running')
|
|
116
|
+
if (kind === 'disabled-but-running') return t('health.driftAction.disabled-but-running')
|
|
117
|
+
if (kind === 'addressable-not-in-profile') return t('health.driftAction.addressable-not-in-profile')
|
|
118
|
+
if (kind === 'declared-not-installed') return t('health.driftAction.declared-not-installed')
|
|
119
|
+
return t('health.anomalyActionGeneric')
|
|
120
|
+
}
|
|
121
|
+
|
|
98
122
|
/** @param {string} kind @param {Function} t @returns {string} */
|
|
99
123
|
function conflictKindLabel(kind, t) {
|
|
100
124
|
return kind === 'duplicate-id' ? t('health.conflictKind.duplicate-id') : t('health.conflictKindUnknown')
|
|
@@ -355,6 +379,128 @@
|
|
|
355
379
|
)
|
|
356
380
|
}
|
|
357
381
|
|
|
382
|
+
/** @param {{ t: Function, drift: any }} props */
|
|
383
|
+
function DriftNotice(props) {
|
|
384
|
+
const t = props.t
|
|
385
|
+
const drift = isRecord(props.drift) ? props.drift : {}
|
|
386
|
+
const kind = textOf(drift.kind)
|
|
387
|
+
return h(
|
|
388
|
+
C.Notice,
|
|
389
|
+
{ tone: DRIFT_TONE[kind] || 'warn' },
|
|
390
|
+
h(
|
|
391
|
+
'div',
|
|
392
|
+
{ style: { ...COLUMN_STYLE, gap: '3px' } },
|
|
393
|
+
h('span', null, h('strong', null, `${t('health.driftKindLabel')}: ${driftKindLabel(kind, t)}${kind.length > 0 ? ` · ${kind}` : ''}`)),
|
|
394
|
+
textOf(drift.detail).length > 0 ? h('div', { style: BREAK_STYLE }, textOf(drift.detail)) : null,
|
|
395
|
+
h('span', { className: 'acc-muted', style: SMALL_STYLE }, `${t('health.anomalySuggestion')}: ${driftAction(kind, t)}`),
|
|
396
|
+
),
|
|
397
|
+
)
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/** @param {{ t: Function, data: any, onDeep?: Function, loading?: boolean }} props */
|
|
401
|
+
function DriftBody(props) {
|
|
402
|
+
const t = props.t
|
|
403
|
+
const data = isRecord(props.data) ? props.data : {}
|
|
404
|
+
const drifts = Array.isArray(data.drifts) ? data.drifts : []
|
|
405
|
+
const notes = Array.isArray(data.notes) ? data.notes : []
|
|
406
|
+
const rows = typeof data.rows === 'number' ? data.rows : (Array.isArray(data.rows) ? data.rows.length : null)
|
|
407
|
+
const mounted = typeof data.mountedRows === 'number' ? data.mountedRows : null
|
|
408
|
+
const inProfile = typeof data.inProfileRows === 'number' ? data.inProfileRows : null
|
|
409
|
+
const self = isRecord(data.self) ? data.self : null
|
|
410
|
+
const source = textOf(data.source)
|
|
411
|
+
return h(
|
|
412
|
+
'div',
|
|
413
|
+
{ style: STACK_STYLE },
|
|
414
|
+
h(
|
|
415
|
+
'div',
|
|
416
|
+
{ className: 'acc-row', style: FLEX_WRAP_STYLE },
|
|
417
|
+
h(StatusTile, { label: t('health.driftTileRows'), value: countText(rows) }),
|
|
418
|
+
h(StatusTile, { label: t('health.driftTileMounted'), value: countText(mounted) }),
|
|
419
|
+
h(StatusTile, { label: t('health.driftTileInProfile'), value: countText(inProfile) }),
|
|
420
|
+
h(StatusTile, {
|
|
421
|
+
label: t('health.driftTileCount'),
|
|
422
|
+
value: countText(drifts.length),
|
|
423
|
+
hint: drifts.length === 0 ? h(C.Badge, { tone: 'success' }, t('health.driftClean')) : h(C.Badge, { tone: 'warn' }, t('health.driftFound')),
|
|
424
|
+
}),
|
|
425
|
+
),
|
|
426
|
+
self === null
|
|
427
|
+
? null
|
|
428
|
+
: h(
|
|
429
|
+
'div',
|
|
430
|
+
{ className: 'acc-muted', style: SMALL_STYLE },
|
|
431
|
+
`${t('health.driftSelf')}: ${textOf(self.entryId) || EMPTY_VALUE} · ${t('health.driftSelfEnabled')} ${self.enabled === true ? t('health.yes') : self.enabled === false ? t('health.no') : EMPTY_VALUE} · ${textOf(self.fiberPhase) || EMPTY_VALUE}`,
|
|
432
|
+
),
|
|
433
|
+
h(
|
|
434
|
+
'div',
|
|
435
|
+
{ className: 'acc-row' },
|
|
436
|
+
h('span', { className: 'acc-muted', style: SMALL_STYLE }, `${t('health.source')}:`),
|
|
437
|
+
h(C.Mono, { text: source.length > 0 ? source : EMPTY_VALUE }),
|
|
438
|
+
),
|
|
439
|
+
drifts.length === 0
|
|
440
|
+
? h(C.Notice, { tone: 'success' }, t('health.driftEmpty'))
|
|
441
|
+
: h(
|
|
442
|
+
'div',
|
|
443
|
+
{ style: STACK_STYLE },
|
|
444
|
+
drifts.map((drift, index) => h(DriftNotice, { key: `drift-${index}`, t, drift })),
|
|
445
|
+
),
|
|
446
|
+
props.onDeep === undefined || data.bundlesChecked === true
|
|
447
|
+
? null
|
|
448
|
+
: h(
|
|
449
|
+
'div',
|
|
450
|
+
{ className: 'acc-row', style: { justifyContent: 'flex-start' } },
|
|
451
|
+
h(
|
|
452
|
+
C.Btn,
|
|
453
|
+
{ tone: 'ghost', onClick: props.onDeep, disabled: props.loading === true, title: t('health.driftCheckBundlesHint') },
|
|
454
|
+
props.loading === true ? t('health.refreshing') : t('health.driftCheckBundles'),
|
|
455
|
+
),
|
|
456
|
+
h('span', { className: 'acc-muted', style: SMALL_STYLE }, t('health.driftCheckBundlesHint')),
|
|
457
|
+
),
|
|
458
|
+
notes.length === 0
|
|
459
|
+
? null
|
|
460
|
+
: h(
|
|
461
|
+
'div',
|
|
462
|
+
{ style: STACK_STYLE },
|
|
463
|
+
h('div', { className: 'acc-section-title' }, t('health.driftNotes')),
|
|
464
|
+
notes.map((note, index) =>
|
|
465
|
+
h('div', { key: `note-${index}`, className: 'acc-muted', style: { ...SMALL_STYLE, ...BREAK_STYLE } }, String(note)),
|
|
466
|
+
),
|
|
467
|
+
),
|
|
468
|
+
h(NoteLine, { t, text: data.note }),
|
|
469
|
+
)
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/** @param {{ t: Function, gate: any, onGateRefresh: Function }} props */
|
|
473
|
+
function DriftCard(props) {
|
|
474
|
+
const t = props.t
|
|
475
|
+
const gate = isRecord(props.gate) ? props.gate : {}
|
|
476
|
+
const blocked = gate.available === false
|
|
477
|
+
// Bundle inspection reads every install location and costs seconds, so it
|
|
478
|
+
// is a deliberate extra step, not part of the first read.
|
|
479
|
+
const [deep, setDeep] = ACC.useState(false)
|
|
480
|
+
const state = ACC.useAsync(
|
|
481
|
+
blocked
|
|
482
|
+
? gatedLoader(gate)
|
|
483
|
+
: (context) => ACC.api('health.drift', deep ? { includeBundles: true } : {}, context),
|
|
484
|
+
[deep],
|
|
485
|
+
)
|
|
486
|
+
return h(
|
|
487
|
+
BlockCard,
|
|
488
|
+
{
|
|
489
|
+
t,
|
|
490
|
+
title: t('health.driftTitle'),
|
|
491
|
+
subtitle: t('health.driftSubtitle'),
|
|
492
|
+
loading: state.status === 'loading',
|
|
493
|
+
onRefresh: blocked ? props.onGateRefresh : state.reload,
|
|
494
|
+
refreshLabel: t('health.refresh.drift'),
|
|
495
|
+
},
|
|
496
|
+
h(BlockContent, {
|
|
497
|
+
t,
|
|
498
|
+
state,
|
|
499
|
+
render: (data) => h(DriftBody, { t, data, onDeep: () => setDeep(true), loading: state.status === 'loading' }),
|
|
500
|
+
}),
|
|
501
|
+
)
|
|
502
|
+
}
|
|
503
|
+
|
|
358
504
|
/** @param {{ t: Function, anomaly: any }} props */
|
|
359
505
|
function AnomalyNotice(props) {
|
|
360
506
|
const t = props.t
|
|
@@ -816,6 +962,7 @@
|
|
|
816
962
|
h(PluginsCard, { t, gate: gateView, onGateRefresh: gate.reload }),
|
|
817
963
|
h(SettingsCard, { t, gate: gateView, onGateRefresh: gate.reload }),
|
|
818
964
|
h(SectionsCard, { t, gate: gateView, onGateRefresh: gate.reload }),
|
|
965
|
+
h(DriftCard, { t, gate: gateView, onGateRefresh: gate.reload }),
|
|
819
966
|
h(CompatCard, { t, gate: gateView, onGateRefresh: gate.reload }),
|
|
820
967
|
)
|
|
821
968
|
}
|
|
@@ -146,20 +146,6 @@
|
|
|
146
146
|
return h(C.Btn, { tone: 'ghost', onClick: copy, title: label, 'aria-live': 'polite' }, label)
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
/** Esc collapses the open detail panel while it is open. */
|
|
150
|
-
function useEscape(active, onEscape) {
|
|
151
|
-
ACC.useEffect(() => {
|
|
152
|
-
if (!active) return undefined
|
|
153
|
-
const handler = (event) => {
|
|
154
|
-
if (event.key !== 'Escape') return
|
|
155
|
-
event.stopPropagation()
|
|
156
|
-
onEscape()
|
|
157
|
-
}
|
|
158
|
-
document.addEventListener('keydown', handler)
|
|
159
|
-
return () => document.removeEventListener('keydown', handler)
|
|
160
|
-
}, [active, onEscape])
|
|
161
|
-
}
|
|
162
|
-
|
|
163
149
|
/** @param {{ value: unknown, onOpen: Function, t: Function }} props */
|
|
164
150
|
function SourceBadge(props) {
|
|
165
151
|
const source = props.value || {}
|
|
@@ -474,7 +460,42 @@
|
|
|
474
460
|
[selected, days, agentId],
|
|
475
461
|
)
|
|
476
462
|
|
|
477
|
-
|
|
463
|
+
// Escape closes the host Settings dialog. Local state (an open detail row or a
|
|
464
|
+
// non-empty search) must consume the key first: a capture-phase listener runs
|
|
465
|
+
// before the host's document-level handler, and stopPropagation keeps it from
|
|
466
|
+
// reaching the dialog.
|
|
467
|
+
ACC.useEffect(() => {
|
|
468
|
+
// The host may close the Settings dialog from any of the three key events
|
|
469
|
+
// at any level, so the whole Escape gesture is consumed here: keydown
|
|
470
|
+
// decides whether the page owns it, keypress/keyup follow for the same
|
|
471
|
+
// gesture so a later phase cannot reopen the dialog's close path.
|
|
472
|
+
let ownedByPage = false
|
|
473
|
+
const handler = (event) => {
|
|
474
|
+
if (event.key !== 'Escape') return
|
|
475
|
+
const input = searchRef.current
|
|
476
|
+
if (event.type === 'keydown') {
|
|
477
|
+
ownedByPage = selected !== '' || search !== '' || (input !== null && document.activeElement === input)
|
|
478
|
+
}
|
|
479
|
+
if (!ownedByPage) return
|
|
480
|
+
event.preventDefault()
|
|
481
|
+
event.stopPropagation()
|
|
482
|
+
if (event.type !== 'keydown') return
|
|
483
|
+
if (selected !== '') {
|
|
484
|
+
setSelected('')
|
|
485
|
+
return
|
|
486
|
+
}
|
|
487
|
+
if (search !== '') {
|
|
488
|
+
setSearch('')
|
|
489
|
+
return
|
|
490
|
+
}
|
|
491
|
+
if (input !== null) input.blur()
|
|
492
|
+
}
|
|
493
|
+
const types = ['keydown', 'keypress', 'keyup']
|
|
494
|
+
for (const type of types) window.addEventListener(type, handler, true)
|
|
495
|
+
return () => {
|
|
496
|
+
for (const type of types) window.removeEventListener(type, handler, true)
|
|
497
|
+
}
|
|
498
|
+
}, [selected, search])
|
|
478
499
|
ACC.useEffect(() => {
|
|
479
500
|
const onKey = (event) => {
|
|
480
501
|
if (event.key !== '/' || event.metaKey || event.ctrlKey || event.altKey) return
|
|
@@ -560,7 +581,12 @@
|
|
|
560
581
|
placeholder: t('tools.searchPlaceholder'),
|
|
561
582
|
value: search,
|
|
562
583
|
onChange: (event) => setSearch(event.target.value),
|
|
563
|
-
onKeyDown: (event) => {
|
|
584
|
+
onKeyDown: (event) => {
|
|
585
|
+
if (event.key !== 'Escape') return
|
|
586
|
+
// The page-level capture handler already clears the query; keep the
|
|
587
|
+
// dialog open if it ever arrives here first.
|
|
588
|
+
event.preventDefault()
|
|
589
|
+
},
|
|
564
590
|
'aria-label': t('tools.search'),
|
|
565
591
|
style: { minWidth: '180px' },
|
|
566
592
|
}),
|