dsh-maoying 0.1.6 → 0.1.8
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/index.mjs +27 -0
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -818,11 +818,38 @@ export async function registerCreatorRoutes(ctx) {
|
|
|
818
818
|
const dbg = readHostVersionDebug(home)
|
|
819
819
|
let shape = null
|
|
820
820
|
try { shape = composeManagedRows(home, ctx.logger).shape } catch { /* 诊断信息尽力而为 */ }
|
|
821
|
+
// 预设注册表内窥:每张 preset 的激活诊断只有注册表自己知道,防御式
|
|
822
|
+
// 探测其服务面(方法名在宿主版本间可能变动,全部吞错尽力而为)。
|
|
823
|
+
const jsonSafe = (v, depth = 0) => {
|
|
824
|
+
if (depth > 4) return '…'
|
|
825
|
+
try {
|
|
826
|
+
if (v === null || v === undefined) return v
|
|
827
|
+
if (typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean') return v
|
|
828
|
+
if (typeof v === 'function') return `[fn ${v.name || 'anon'}]`
|
|
829
|
+
if (Array.isArray(v)) return v.slice(0, 50).map((x) => jsonSafe(x, depth + 1))
|
|
830
|
+
if (v instanceof Map) return { __map: [...v.keys()].slice(0, 50) }
|
|
831
|
+
if (v instanceof Set) return { __set: [...v].slice(0, 50).map((x) => jsonSafe(x, depth + 1)) }
|
|
832
|
+
const out = {}
|
|
833
|
+
for (const k of Object.keys(v).slice(0, 80)) out[k] = jsonSafe(v[k], depth + 1)
|
|
834
|
+
return out
|
|
835
|
+
} catch { return '[unserializable]' }
|
|
836
|
+
}
|
|
837
|
+
const registryDump = {}
|
|
838
|
+
try {
|
|
839
|
+
const svc = typeof ctx.get === 'function' ? ctx.get('agentPresets') : null
|
|
840
|
+
if (svc && typeof svc.list === 'function') {
|
|
841
|
+
// list() 返回每张 preset 的 {id,name,order,broken}——broken 即
|
|
842
|
+
// 面板上显示的逐行激活诊断(注册表自带审计,一行一条不可用原因)。
|
|
843
|
+
const rows = await svc.list()
|
|
844
|
+
registryDump.presets = jsonSafe(rows)
|
|
845
|
+
}
|
|
846
|
+
} catch (e) { registryDump.error = String(e?.message ?? e) }
|
|
821
847
|
json(res, 200, {
|
|
822
848
|
ok: true,
|
|
823
849
|
hostVersion: dbg.version,
|
|
824
850
|
trace: dbg.trace,
|
|
825
851
|
shape,
|
|
852
|
+
registry: registryDump,
|
|
826
853
|
runtime: {
|
|
827
854
|
argv: process.argv,
|
|
828
855
|
execPath: process.execPath,
|