lingshu-skill 5.68.0 → 5.69.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 +22 -0
- package/README.md +1 -1
- package/SKILL-lite.md +1 -1
- package/SKILL-tiny.md +1 -1
- package/SKILL.md +1 -1
- package/assets/panel.html +11 -3
- package/cordis-plugin/lingshu-cron/plugin.js +32 -6
- package/cordis-plugin/lingshu-guard/plugin.js +34 -10
- package/cordis-plugin/lingshu-im/plugin.js +19 -2
- package/cordis-plugin/lingshu-startup/context-fold.js +5 -1
- package/cordis-plugin/lingshu-startup/plugin.js +9 -1
- package/index.js +26 -21
- package/manifest.json +27 -27
- package/package.json +1 -1
- package/scripts/astrbot_plugin_lingshu/CHECKSUMS.json +8 -8
- package/scripts/astrbot_plugin_lingshu/engine/CHANGELOG.md +22 -0
- package/scripts/astrbot_plugin_lingshu/engine/README.md +1 -1
- package/scripts/astrbot_plugin_lingshu/engine/SKILL-lite.md +1 -1
- package/scripts/astrbot_plugin_lingshu/engine/SKILL-tiny.md +1 -1
- package/scripts/astrbot_plugin_lingshu/engine/SKILL.md +1 -1
- package/scripts/astrbot_plugin_lingshu/engine/assets/panel.html +11 -3
- package/scripts/astrbot_plugin_lingshu/engine/scripts/panel_data.py +17 -3
- package/scripts/astrbot_plugin_lingshu/engine/scripts/panel_settings.py +24 -1
- package/scripts/panel_data.py +17 -3
- package/scripts/panel_settings.py +24 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## v5.69(2026-12-05)
|
|
4
|
+
|
|
5
|
+
### 🛡️ 150 项审计第十三批:Cordis IM 安全与面板设置组大收官
|
|
6
|
+
|
|
7
|
+
1. **LS-093(高·guard 注册失败拒绝态)**:`lingshu-guard` 注册全部失败时进入 deny-all——所有工具调用直接拒绝并给明确诊断,IM 鉴权绝不裸奔。
|
|
8
|
+
2. **LS-094(高·IM 授权跟随真实 HOME)**:`lingshu-im` 的 `memoryHome()` 与 Python 一致解析 `.home` 指针,旧默认目录的 consent.json 不再覆盖真实库授权。
|
|
9
|
+
3. **LS-095(高·群聊缺 chatId fail-closed)**:群聊消息无有效 chatId 时返回 null 拒绝召回/写回,绝不降级成私聊作用域。
|
|
10
|
+
4. **LS-099(高·SKILL.md 缺失仍挂 guard)**:`index.js` 技能文档注册失败不再阻断 guard 等安全组件挂载。
|
|
11
|
+
5. **LS-101(中·只读白名单移除 todo_write)**:`lingshu-guard` 的 `DEFAULT_READ_ONLY` 移除有写副作用的 `todo_write`。
|
|
12
|
+
6. **LS-102(中·cron 消息去重键)**:mid 规范统一为 `${role}:${mid}`,user/assistant 同数字 id 不再互相误判。
|
|
13
|
+
7. **LS-103(中·selfReviewDays 真正控制间隔)**:`dueByDays` 按真实日期差��算到期,配 3 天不再每天执行。
|
|
14
|
+
8. **LS-109(中·extract 只收集真实对话)**:工具/系统/插件注入消息不进对话缓冲,防自我吞噬。
|
|
15
|
+
9. **LS-111(中·cron 状态原子保存)**:`saveState` 不再先删旧状态,rename 失败时旧状态原样保留。
|
|
16
|
+
10. **LS-112(中·prior 排除插件注入)**:`lastUserText` 检查 source.name/kind,cron/IM 注入不触发无关 prior 检索。
|
|
17
|
+
11. **LS-113(中·token 标定 HOME 修复)**:`_calibPaths` 改用已有的 `memoryHome()`,修复 readBrainHome 未定义。
|
|
18
|
+
12. **LS-114(中·顶层 checkpoint 识别)**:`context-fold.js` 三个位置检查 compact-checkpoint 来源。
|
|
19
|
+
13. **LS-074(中·损坏 manifest 字段容错)**:`panel_data.py` 单条记录字段级容错,正常备份照常展示。
|
|
20
|
+
14. **LS-075/077(中·enum 设置与 NaN 拒绝)**:`panel_settings.py` 支持 enum 类型校验;float 拒绝 NaN/Infinity。
|
|
21
|
+
15. **LS-076/084(中·enum 渲染与体检契约)**:前端 enum 渲染为 select;dochealth 统一走 api() 并以 items 为准。
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
3
25
|
## v5.68(2026-12-04)
|
|
4
26
|
|
|
5
27
|
### 🔧 150 项审计第十二批:Cordis 插件多 Agent 隔离修复
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> 名字取自《黄帝内经》:**算力给思考,人格给灵魂,记忆给生命。**
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> 当��版本 **v5.69**(变更见 [CHANGELOG.md](CHANGELOG.md))
|
|
6
6
|
|
|
7
7
|
> 🔁 **双仓库镜像**:GitHub(主)与 Gitee(镜像)保持同步——[gitee.com/htmcwy_0/lingshu-skill](https://gitee.com/htmcwy_0/lingshu-skill)。灵枢的更新检查会探测两边最新提交,**谁更新就自动从谁拉取**;任一边不可达(Gitee 匿名风控 / GitHub 限额)时走另一边兜底。
|
|
8
8
|
|
package/SKILL-lite.md
CHANGED
package/SKILL-tiny.md
CHANGED
package/SKILL.md
CHANGED
package/assets/panel.html
CHANGED
|
@@ -4250,6 +4250,14 @@ function _settingRow(it){
|
|
|
4250
4250
|
const opts = (it.choices || []).map(c =>
|
|
4251
4251
|
`<option value="${esc(c)}"${String(it.value) === c ? " selected" : ""}>${esc(c)}</option>`).join("");
|
|
4252
4252
|
ctl = `<select id="${id}" data-key="${esc(it.key)}">${opts}</select>`;
|
|
4253
|
+
} else if (it.kind === "enum"){
|
|
4254
|
+
// LS-076(v5.69):enum 设置渲染为选项控件——支持 ["a","b"] 与 [{value,label}] 两种 options
|
|
4255
|
+
const opts = (it.options || []).map(o => {
|
|
4256
|
+
const v = (o && typeof o === "object") ? String(o.value ?? "") : String(o);
|
|
4257
|
+
const label = (o && typeof o === "object") ? String(o.label ?? o.value ?? "") : String(o);
|
|
4258
|
+
return `<option value="${esc(v)}"${String(it.value) === v ? " selected" : ""}>${esc(label)}</option>`;
|
|
4259
|
+
}).join("");
|
|
4260
|
+
ctl = `<select id="${id}" data-key="${esc(it.key)}">${opts}</select>`;
|
|
4253
4261
|
} else {
|
|
4254
4262
|
const step = it.step != null ? it.step : (it.kind === "float" ? 0.05 : 1);
|
|
4255
4263
|
const min = it.min != null ? ` min="${it.min}"` : "";
|
|
@@ -7872,9 +7880,9 @@ setTimeout(() => checkUpdate(true), 1200);
|
|
|
7872
7880
|
const el = body();
|
|
7873
7881
|
if (!el) return;
|
|
7874
7882
|
try {
|
|
7875
|
-
|
|
7876
|
-
const j = await
|
|
7877
|
-
const hist = Array.isArray(j) ? j : (j.history || j.rows || []);
|
|
7883
|
+
// LS-083/084(v5.69):统一 API helper 携带 token;items 字段前后端同一契约
|
|
7884
|
+
const j = await api("/api/doctor-history?limit=90");
|
|
7885
|
+
const hist = Array.isArray(j) ? j : (j.items || j.history || j.rows || []);
|
|
7878
7886
|
if (sum()) {
|
|
7879
7887
|
const st = (!Array.isArray(j) && j.stage) || null;
|
|
7880
7888
|
const g = st ? ` · 成长阶段:${esc(st.name || st.stage || "")}` : "";
|
|
@@ -235,12 +235,15 @@ function loadState(path) {
|
|
|
235
235
|
}
|
|
236
236
|
|
|
237
237
|
function saveState(path, state) {
|
|
238
|
+
// LS-111(v5.69):cron 状态真正原子保存——不得先删除旧状态!
|
|
239
|
+
// 旧实现在 rename 前先 rmSync(path):若 rename 失败或进程崩溃,
|
|
240
|
+
// 旧状态已被删除 → 下次启动 turns/days 全丢,daily/backup 全部重跑。
|
|
241
|
+
// 同目录 rename 本身就是原子的(Windows/POSIX 语义),无需先删旧文件。
|
|
238
242
|
try {
|
|
239
243
|
mkdirSync(dirname(path), { recursive: true })
|
|
240
244
|
const tmp = `${path}.${randomUUID()}.tmp`
|
|
241
245
|
writeFileSync(tmp, JSON.stringify(state, null, 2), 'utf8')
|
|
242
|
-
|
|
243
|
-
renameSync(tmp, path) // 原子替换(同目录 rename)
|
|
246
|
+
renameSync(tmp, path) // 同目录 rename 原子替换;失败时旧状态原样保留
|
|
244
247
|
} catch {}
|
|
245
248
|
}
|
|
246
249
|
|
|
@@ -262,7 +265,18 @@ function agentKey(agent) {
|
|
|
262
265
|
|
|
263
266
|
function dueByDays(task, state) {
|
|
264
267
|
const last = state?.days?.[task.id]
|
|
265
|
-
|
|
268
|
+
// LS-103(v5.69):让 `selfReviewDays` 真正控制间隔!
|
|
269
|
+
// 旧实现只比较"上次执行日 != 今天"——days:N 配 3 天时仍然每天执行。
|
|
270
|
+
// 现在按 task.days 计算真实到期时间:last 日期 + N 天后才算 due。
|
|
271
|
+
const n = Number(task.days) || 1
|
|
272
|
+
if (!last) return true
|
|
273
|
+
if (last === todayStr()) return false
|
|
274
|
+
// 解析本地日期(YYYY-MM-DD),加 N 天与今天比较
|
|
275
|
+
const parts = String(last).split('-').map(Number)
|
|
276
|
+
if (parts.length !== 3 || parts.some(Number.isNaN)) return true
|
|
277
|
+
const lastMs = new Date(parts[0], parts[1] - 1, parts[2]).getTime()
|
|
278
|
+
const due = lastMs + n * 86400 * 1000
|
|
279
|
+
return Date.now() >= due
|
|
266
280
|
}
|
|
267
281
|
|
|
268
282
|
// 按小时间隔判定(P11 #72)。备份原来用 days:1 —— 只在"当天第一次回合"跑一次,
|
|
@@ -957,7 +971,11 @@ const waterState = new Map() // agent -> { max } 水位守卫已提醒的最高
|
|
|
957
971
|
|
|
958
972
|
function _calibPaths() {
|
|
959
973
|
try {
|
|
960
|
-
|
|
974
|
+
// LS-113(v5.69):修复 token 标定的 HOME 获取函数!
|
|
975
|
+
// 旧代码调用了不存在的 readBrainHome() → ReferenceError → 样本永远写不进、
|
|
976
|
+
// 已有拟合也读不到。本文件已有的 memoryHome() 就是权威实现(BRAIN_MEMORY_HOME
|
|
977
|
+
// > .home 指针 > ~/.brain-memory),直接复用。
|
|
978
|
+
const home = memoryHome()
|
|
961
979
|
if (!home) return null
|
|
962
980
|
return { samples: join(home, 'token-calib.jsonl'), fit: join(home, 'token-calib.json') }
|
|
963
981
|
} catch { return null }
|
|
@@ -1262,10 +1280,18 @@ const waterState = new Map() // agent -> { max } 水位守卫已提醒的最高
|
|
|
1262
1280
|
let lastAsst = lastReply.get(agent) || ''
|
|
1263
1281
|
let batchIds = []
|
|
1264
1282
|
for (const m of msgs) {
|
|
1283
|
+
// LS-109(v5.69):extract 只收集允许的真实对话来源!
|
|
1284
|
+
// 工具输出、系统消息及灵枢各插件注入的内容不进对话缓冲——
|
|
1285
|
+
// 敏感工具输出和已有记忆块不能被再次摄入(自我吞噬)。
|
|
1286
|
+
if (m?.role !== 'user' && m?.role !== 'assistant') continue
|
|
1287
|
+
if (m?.source?.name && LINGSHU_SOURCES.has(m.source.name)) continue
|
|
1265
1288
|
const mid = m?.id
|
|
1266
1289
|
if (mid != null) {
|
|
1267
|
-
|
|
1268
|
-
|
|
1290
|
+
// LS-102(v5.69):修复消息 ID 去重键——统一用 `${role}:${mid}` 规范,
|
|
1291
|
+
// 同一数字 id 在 user/assistant 两个角色下不再互相误判为重复。
|
|
1292
|
+
const normMid = `${m.role}:${mid}`
|
|
1293
|
+
if (seenIds.has(normMid)) continue // 上一步已攒过这条,跳过(只加增量)
|
|
1294
|
+
batchIds.push(normMid)
|
|
1269
1295
|
}
|
|
1270
1296
|
for (const c of (Array.isArray(m?.content) ? m.content : [])) {
|
|
1271
1297
|
if (c?.type === 'text' && typeof c.text === 'string' && c.text.trim()) {
|
|
@@ -61,9 +61,10 @@ export const name = 'dsh-lingshu-guard'
|
|
|
61
61
|
const DEFAULT_READ_ONLY = [
|
|
62
62
|
'list_agents',
|
|
63
63
|
'skill',
|
|
64
|
-
'todo_write',
|
|
65
64
|
'ask_user_question',
|
|
66
65
|
]
|
|
66
|
+
// LS-101(v5.69):从只读白名单移除 `todo_write`——它有写副作用(修改用户的
|
|
67
|
+
// 任务列表),非 owner 不应通过 IM 操纵宿主的待办清单。
|
|
67
68
|
|
|
68
69
|
// guard 段默认值。shadow 默认 false:默认就拦(安全优先),不再"只记日志不拦"。
|
|
69
70
|
// 需要先观察误伤时显式设 shadow=true,启动会打 warn(观察模式,敏感命令不拦)。
|
|
@@ -452,13 +453,27 @@ export function apply(ctx, config) {
|
|
|
452
453
|
} catch { /* 坏载荷忽略 */ }
|
|
453
454
|
})
|
|
454
455
|
|
|
455
|
-
const check = (exec, agent) =>
|
|
456
|
+
const check = (exec, agent) => {
|
|
457
|
+
// LS-093(v5.69):注册失败的 agent 进入拒绝态——所有工具调用直接拒绝
|
|
458
|
+
if (isRegistrationFailed(agent)) {
|
|
459
|
+
return 'lingshu-guard: 守卫注册失败(deny-all 拒绝态),工具调用被拒绝。请检查宿主 dsh-tools 版本或重启会话。'
|
|
460
|
+
}
|
|
461
|
+
return checkTool(ctx, bindings, hostConfig, exec, agent, knownImSessions)
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// LS-093: 注册失败的 agent 集合——这些 agent 的工具调用一律拒绝
|
|
465
|
+
const guardRegistrationFailed = new Set()
|
|
466
|
+
|
|
467
|
+
function isRegistrationFailed(agent) {
|
|
468
|
+
return guardRegistrationFailed.has(agent?.id || agent?.name || 'default')
|
|
469
|
+
}
|
|
456
470
|
|
|
457
471
|
/**
|
|
458
472
|
* 给一个 agent 注册守卫。注册在 agent.ctx 上,作用域随 agent 销毁自动释放:
|
|
459
473
|
* 对话结束、会话删除、agent 重建都不会留下悬挂的守卫或重复注册。
|
|
460
474
|
*/
|
|
461
475
|
function registerFor(agent) {
|
|
476
|
+
let registered = false
|
|
462
477
|
try {
|
|
463
478
|
const agentCtx = agent?.ctx
|
|
464
479
|
if (!agentCtx || typeof agentCtx.on !== 'function') return
|
|
@@ -470,19 +485,28 @@ export function apply(ctx, config) {
|
|
|
470
485
|
try {
|
|
471
486
|
// 首选:单调执行守卫(dsh-tools 的正式 API)。
|
|
472
487
|
tools.guard((exec) => check(exec, agent))
|
|
473
|
-
|
|
488
|
+
registered = true
|
|
474
489
|
} catch (error) {
|
|
475
490
|
warn('lingshu-guard: tools.guard 注册失败,退回 tools/pre-execute', error)
|
|
476
491
|
}
|
|
477
492
|
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
493
|
+
if (!registered) {
|
|
494
|
+
// 旧宿主降级:pre-execute waterfall 里做同样的判定。
|
|
495
|
+
agentCtx.on('tools/pre-execute', async (exec, next) => {
|
|
496
|
+
const reason = check(exec, agent)
|
|
497
|
+
if (reason) return { kind: 'deny', reason }
|
|
498
|
+
return next()
|
|
499
|
+
})
|
|
500
|
+
registered = true
|
|
501
|
+
}
|
|
484
502
|
} catch (error) {
|
|
485
|
-
|
|
503
|
+
// LS-093(v5.69):注册失败进入拒绝态!
|
|
504
|
+
// 两种注册路径都失败 = 本 agent 的 IM 鉴权完全没生效,此时放行任何工具
|
|
505
|
+
// 等于裸奔。进入 deny-all:所有工具调用直接拒绝并给明确诊断。
|
|
506
|
+
guardRegistrationFailed.add(agent?.id || agent?.name || 'default')
|
|
507
|
+
warn('lingshu-guard: 守卫注册全部失败,本 agent 进入拒绝态(deny-all);'
|
|
508
|
+
+ '请检查宿主 dsh-tools 版本。诊断:'
|
|
509
|
+
+ (error?.message || String(error)).slice(0, 200), error)
|
|
486
510
|
}
|
|
487
511
|
}
|
|
488
512
|
|
|
@@ -252,7 +252,13 @@ function toIdentity(described) {
|
|
|
252
252
|
if (!sender) return null
|
|
253
253
|
const user = `${channel}:${enc(sender)}`
|
|
254
254
|
const chatType = String(described.chatType || '').trim()
|
|
255
|
+
// LS-095(v5.69):群聊缺少有效 chatId 时 fail-closed!
|
|
256
|
+
// 旧代码 group 为空串时照常处理——召回/写回会降级成私聊作用域,
|
|
257
|
+
// 群消息被错误地记到个人名下(隐私越界)。现在返回 null 让上层拒绝。
|
|
255
258
|
const group = chatType && chatType !== 'dm' ? String(described.chatId || '').trim() : ''
|
|
259
|
+
if (chatType && chatType !== 'dm' && !group) {
|
|
260
|
+
return null // 群聊无有效 chatId:禁止召回和写回,绝不降级成私聊作用域
|
|
261
|
+
}
|
|
256
262
|
return {
|
|
257
263
|
channel,
|
|
258
264
|
user,
|
|
@@ -362,8 +368,19 @@ export function apply(ctx, config) {
|
|
|
362
368
|
return found
|
|
363
369
|
}
|
|
364
370
|
|
|
365
|
-
/** 记忆目录:配置 > 宿主环境变量 > ~/.brain-memory(与 brain.py 默认一致)。
|
|
366
|
-
|
|
371
|
+
/** 记忆目录:配置 > 宿主环境变量 > .home 指针 > ~/.brain-memory(与 brain.py 默认一致)。
|
|
372
|
+
* LS-094(v5.69):授权读取跟随真实记忆 HOME——与 Python 一样解析 .home 指针文件,
|
|
373
|
+
* 旧默认目录的 consent.json 不再覆盖真实库的授权。 */
|
|
374
|
+
const memoryHome = () => {
|
|
375
|
+
if (cfg.memoryHome) return cfg.memoryHome
|
|
376
|
+
if (process.env.BRAIN_MEMORY_HOME) return process.env.BRAIN_MEMORY_HOME
|
|
377
|
+
const base = join(homedir(), '.brain-memory')
|
|
378
|
+
try {
|
|
379
|
+
const ptr = readFileSync(join(base, '.home'), 'utf8').trim()
|
|
380
|
+
if (ptr) return ptr
|
|
381
|
+
} catch { /* 没有指针文件就用默认���录 */ }
|
|
382
|
+
return base
|
|
383
|
+
}
|
|
367
384
|
|
|
368
385
|
/** 自动写回授权(consent.json 的 capture 字段),按文件 mtime 缓存:改完下一条即生效。 */
|
|
369
386
|
function captureAllowed(user) {
|
|
@@ -87,8 +87,12 @@ export function applyFolds(decision, maxChars = 1600) {
|
|
|
87
87
|
// 所以:只要本次请求里出现 hub 的 checkpoint,就让位给宿主(只记一次日志,不打扰)。
|
|
88
88
|
try {
|
|
89
89
|
const hasHostCheckpoint = msgs.some((m) => {
|
|
90
|
+
// LS-114(v5.69):识别顶层 checkpoint 来源!
|
|
91
|
+
// 旧代码只检查 m.data.source / m.data.message.source——宿主在某些路径下
|
|
92
|
+
// 把 source 挂在**消息顶层**(m.source),这类 checkpoint 会被漏检,
|
|
93
|
+
// 导致宿主已压缩我们又重复折叠。现在三个位置都查。
|
|
90
94
|
const d = m?.data
|
|
91
|
-
const src = d?.source ?? d?.message?.source
|
|
95
|
+
const src = d?.source ?? d?.message?.source ?? m?.source
|
|
92
96
|
return src && src.kind === 'compact-checkpoint'
|
|
93
97
|
})
|
|
94
98
|
if (hasHostCheckpoint) {
|
|
@@ -286,12 +286,20 @@ function runPrior(pythonExe, pythonCmdFallback, brainPy, taskText, budget, timeo
|
|
|
286
286
|
})
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
-
/** 从 pre-step 决策的 messages 里抽出最后一条用户文本(含多模态里的 text
|
|
289
|
+
/** 从 pre-step 决策的 messages 里抽出最后一条用户文本(含多模态里的 text 段)。
|
|
290
|
+
* LS-112(v5.69):排除插件注入的用户角色消息!
|
|
291
|
+
* cron / IM / startup 等灵枢插件注入的消息也带 role='user',但不代表用户真的
|
|
292
|
+
* 说了话——拿它们去查 prior 会触发无关检索。同时检查 source.name 与 source.kind。 */
|
|
290
293
|
export function lastUserText(messages) {
|
|
291
294
|
if (!Array.isArray(messages)) return ''
|
|
292
295
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
293
296
|
const m = messages[i]
|
|
294
297
|
if (!m || m.role !== 'user') continue
|
|
298
|
+
// 插件注入的 user 消息(source.name 或 source.kind 标明来源��跳过
|
|
299
|
+
const srcName = m?.source?.name || ''
|
|
300
|
+
const srcKind = m?.source?.kind || ''
|
|
301
|
+
if (srcName && srcName !== 'user') continue
|
|
302
|
+
if (srcKind && srcKind !== 'user') continue
|
|
295
303
|
const c = m.content
|
|
296
304
|
if (typeof c === 'string') return c.trim()
|
|
297
305
|
if (Array.isArray(c)) {
|
package/index.js
CHANGED
|
@@ -44,28 +44,33 @@ export const inject = ['skills']
|
|
|
44
44
|
export function apply(ctx, config) {
|
|
45
45
|
const content = loadSkillBody()
|
|
46
46
|
if (content === undefined) {
|
|
47
|
-
|
|
48
|
-
return
|
|
47
|
+
// LS-099(v5.69):SKILL.md 缺失时仍挂载安全 guard!
|
|
48
|
+
// 旧实现在技能文档注册失败时直接 return——guard 等安全组件也一起没挂,
|
|
49
|
+
// IM 鉴权完全失效(裸奔)。技能文档只是"使用说明",缺它不产生安全问题;
|
|
50
|
+
// 安全组件必须无条件挂载。
|
|
51
|
+
ctx.logger?.warn?.('lingshu-skill: SKILL.md not found next to index.js, bundled skill not registered'
|
|
52
|
+
+ '(安全组件仍会挂载——LS-099)')
|
|
53
|
+
} else {
|
|
54
|
+
ctx.skills.register({
|
|
55
|
+
name: 'lingshu',
|
|
56
|
+
description:
|
|
57
|
+
'Brain-inspired persistent memory, persona and growth system for AI coding agents. ' +
|
|
58
|
+
'Local-only, zero-dependency. Requires Python 3 on PATH (or configure the startup plugin).',
|
|
59
|
+
whenToUse:
|
|
60
|
+
'需要持久记忆、人格设定、成长记录或跨会话待办时使用;' +
|
|
61
|
+
'需 Python 3,缺 Python 时 startup 注入不可用但技能文档仍可读。',
|
|
62
|
+
content,
|
|
63
|
+
// DSH validateDefinition 要求 source/provider 必须是 string,缺失时
|
|
64
|
+
// `skill(name="lingshu")` 会抛 "source must be a string"(改进清单 #2)。
|
|
65
|
+
source: 'bundled:lingshu',
|
|
66
|
+
provider: 'lingshu-skill',
|
|
67
|
+
// v3.53:必须声明资源根目录。DSH 的 runtimeCandidate 只在技能带 path/resourceBase
|
|
68
|
+
// 时才把位置暴露给 list();此前没给,子插件(startup/cron)就查不到 brain.py,
|
|
69
|
+
// 注入与即记即存会**静默停摆**——2026-11-20 那次"记忆不录入了"就是这个。
|
|
70
|
+
resourceBase: { kind: 'directory', path: here },
|
|
71
|
+
invocation: { modelInvocable: true, userInvocable: true },
|
|
72
|
+
})
|
|
49
73
|
}
|
|
50
|
-
ctx.skills.register({
|
|
51
|
-
name: 'lingshu',
|
|
52
|
-
description:
|
|
53
|
-
'Brain-inspired persistent memory, persona and growth system for AI coding agents. ' +
|
|
54
|
-
'Local-only, zero-dependency. Requires Python 3 on PATH (or configure the startup plugin).',
|
|
55
|
-
whenToUse:
|
|
56
|
-
'需要持久记忆、人格设定、成长记录或跨会话待办时使用;' +
|
|
57
|
-
'需 Python 3,缺 Python 时 startup 注入不可用但技能文档仍可读。',
|
|
58
|
-
content,
|
|
59
|
-
// DSH validateDefinition 要求 source/provider 必须是 string,缺失时
|
|
60
|
-
// `skill(name="lingshu")` 会抛 "source must be a string"(改进清单 #2)。
|
|
61
|
-
source: 'bundled:lingshu',
|
|
62
|
-
provider: 'lingshu-skill',
|
|
63
|
-
// v3.53:必须声明资源根目录。DSH 的 runtimeCandidate 只在技能带 path/resourceBase
|
|
64
|
-
// 时才把位置暴露给 list();此前没给,子插件(startup/cron)就查不到 brain.py,
|
|
65
|
-
// 注入与即记即存会**静默停摆**——2026-11-20 那次"记忆不录入了"就是这个。
|
|
66
|
-
resourceBase: { kind: 'directory', path: here },
|
|
67
|
-
invocation: { modelInvocable: true, userInvocable: true },
|
|
68
|
-
})
|
|
69
74
|
|
|
70
75
|
// 挂载子插件:startup = 会话启动自动注入人格/记忆;cron = 做梦/清点/用量等例行维护。
|
|
71
76
|
// 各自 try/catch:一个挂载失败不能拖垮另一个和技能注册本身。
|
package/manifest.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "5.
|
|
2
|
+
"version": "5.69",
|
|
3
3
|
"files": {
|
|
4
4
|
"CHANGELOG.md": {
|
|
5
|
-
"sha256": "
|
|
6
|
-
"size":
|
|
5
|
+
"sha256": "b6262eb1435a7bac003cd0403e1e16baee293170585119ed5803124e2459a49b",
|
|
6
|
+
"size": 437749
|
|
7
7
|
},
|
|
8
8
|
"README.md": {
|
|
9
|
-
"sha256": "
|
|
10
|
-
"size":
|
|
9
|
+
"sha256": "5ab87b76dc757e6edd6ef1d760e9a979e55df48b2b8c2b76552747fabb7b1026",
|
|
10
|
+
"size": 114306
|
|
11
11
|
},
|
|
12
12
|
"SKILL-lite.md": {
|
|
13
|
-
"sha256": "
|
|
13
|
+
"sha256": "d2728fc7fd7f5f8e15e7d50302144aa07b95ebd5323eafcc42f6b4340daa4e96",
|
|
14
14
|
"size": 4440
|
|
15
15
|
},
|
|
16
16
|
"SKILL-tiny.md": {
|
|
17
|
-
"sha256": "
|
|
17
|
+
"sha256": "a3c73b3452e1f25c78fb71cad496f56b89559af5ac9ce036f88723b17c9ef69c",
|
|
18
18
|
"size": 1913
|
|
19
19
|
},
|
|
20
20
|
"SKILL.md": {
|
|
21
|
-
"sha256": "
|
|
21
|
+
"sha256": "4663a5d3bd3e369a8dee909b9303f2a9a853b9a2c7e8e0d2723d9a171ea93e4d",
|
|
22
22
|
"size": 25366
|
|
23
23
|
},
|
|
24
24
|
"assets/lingshu-icon-preview.png": {
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"size": 53924
|
|
35
35
|
},
|
|
36
36
|
"assets/panel.html": {
|
|
37
|
-
"sha256": "
|
|
38
|
-
"size":
|
|
37
|
+
"sha256": "7b8f3c1d595e14a06e266ea89c90620f3ce2223c2af2a089e407df734df28e17",
|
|
38
|
+
"size": 429122
|
|
39
39
|
},
|
|
40
40
|
"cordis-plugin/lingshu-cron/cordis.patch.yml": {
|
|
41
41
|
"sha256": "74fb1b914774754a985c15d01f60b64fa0c4dcbf24760de55b8bae76a015c2f7",
|
|
@@ -50,24 +50,24 @@
|
|
|
50
50
|
"size": 2205
|
|
51
51
|
},
|
|
52
52
|
"cordis-plugin/lingshu-cron/plugin.js": {
|
|
53
|
-
"sha256": "
|
|
54
|
-
"size":
|
|
53
|
+
"sha256": "b2bb77653562423dd01eeb872283eee1e0dcaf7a999c7be81b334189b9a0b2d8",
|
|
54
|
+
"size": 76447
|
|
55
55
|
},
|
|
56
56
|
"cordis-plugin/lingshu-guard/plugin.js": {
|
|
57
|
-
"sha256": "
|
|
58
|
-
"size":
|
|
57
|
+
"sha256": "c86066adb5726331099b7513ac7cc7eb078d271b0f71454b900b716303b0fd65",
|
|
58
|
+
"size": 23970
|
|
59
59
|
},
|
|
60
60
|
"cordis-plugin/lingshu-im/plugin.js": {
|
|
61
|
-
"sha256": "
|
|
62
|
-
"size":
|
|
61
|
+
"sha256": "6e36d0a1d0c0d961d581a24dfbfca89d1ae8cfe8a893fdcbbe97a33c1b231817",
|
|
62
|
+
"size": 27567
|
|
63
63
|
},
|
|
64
64
|
"cordis-plugin/lingshu-startup/README.md": {
|
|
65
65
|
"sha256": "e62016afb05dd910cd1b99fd547b1b5eead2afea43e0b90b96df2d2782c0b386",
|
|
66
66
|
"size": 8190
|
|
67
67
|
},
|
|
68
68
|
"cordis-plugin/lingshu-startup/context-fold.js": {
|
|
69
|
-
"sha256": "
|
|
70
|
-
"size":
|
|
69
|
+
"sha256": "16831c3340f2c17c3f6f31db5f1016ece20b2166442947dfeca0ed07429edea7",
|
|
70
|
+
"size": 6873
|
|
71
71
|
},
|
|
72
72
|
"cordis-plugin/lingshu-startup/context-pressure.js": {
|
|
73
73
|
"sha256": "32520abe482fc95a2d865e9cea5dfcd4d31bda24482986110f1005d49c10f5b6",
|
|
@@ -86,8 +86,8 @@
|
|
|
86
86
|
"size": 1391
|
|
87
87
|
},
|
|
88
88
|
"cordis-plugin/lingshu-startup/plugin.js": {
|
|
89
|
-
"sha256": "
|
|
90
|
-
"size":
|
|
89
|
+
"sha256": "9313a36b9ca91fb91c2cdefcd86646ae40ae689513125ffa7445bb382b948b5d",
|
|
90
|
+
"size": 28513
|
|
91
91
|
},
|
|
92
92
|
"cordis-plugin/lingshu-startup/resilience.js": {
|
|
93
93
|
"sha256": "05784a00d35b59c1f1b2945b4b04a632decec294cd0454dcc6991558b5179104",
|
|
@@ -134,11 +134,11 @@
|
|
|
134
134
|
"size": 8682
|
|
135
135
|
},
|
|
136
136
|
"index.js": {
|
|
137
|
-
"sha256": "
|
|
138
|
-
"size":
|
|
137
|
+
"sha256": "af3dcfd73a1e6d1de029a9b6abfae8df7e2c63ad7f08c05200f896ff7f797657",
|
|
138
|
+
"size": 6007
|
|
139
139
|
},
|
|
140
140
|
"package.json": {
|
|
141
|
-
"sha256": "
|
|
141
|
+
"sha256": "2e0bf71cfb949e9cc9a000f8950d9610489f255d2bdf31788f33fade558efdda",
|
|
142
142
|
"size": 1503
|
|
143
143
|
},
|
|
144
144
|
"scripts/anchor_retention.py": {
|
|
@@ -322,8 +322,8 @@
|
|
|
322
322
|
"size": 30102
|
|
323
323
|
},
|
|
324
324
|
"scripts/panel_data.py": {
|
|
325
|
-
"sha256": "
|
|
326
|
-
"size":
|
|
325
|
+
"sha256": "189eadcba9139fc934fc22fcd62911828b28fe3a4a189c8c0598043d227ea37b",
|
|
326
|
+
"size": 7864
|
|
327
327
|
},
|
|
328
328
|
"scripts/panel_icon.py": {
|
|
329
329
|
"sha256": "8b766740c547087c4d40ab7031a8b6845f3e0bdd3893079d2da22bb9c9694a9f",
|
|
@@ -338,8 +338,8 @@
|
|
|
338
338
|
"size": 160631
|
|
339
339
|
},
|
|
340
340
|
"scripts/panel_settings.py": {
|
|
341
|
-
"sha256": "
|
|
342
|
-
"size":
|
|
341
|
+
"sha256": "1d33fc5bf46ee64e3d1b052ecfa1b998a5da55a58e55807182a7214f8594b15b",
|
|
342
|
+
"size": 13611
|
|
343
343
|
},
|
|
344
344
|
"scripts/panel_shortcut.py": {
|
|
345
345
|
"sha256": "956374abe9d1e2b63618223e861f696070b6c0368a757f5a630f441c854ea1ea",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lingshu-skill",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.69.0",
|
|
4
4
|
"description": "Brain-inspired persistent memory, persona and growth system for AI coding agents. Local-only, zero-dependency Python. Requires Python 3.10+.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"PATCH_NOTES.md": "9296e524f743f358fd11115598398a754cfd69534526dde9c8ad85f14a418f89",
|
|
3
3
|
"README.md": "3d634d743b085eebd2cbb5dd3a00edfa728ed23947e20cc29e7c3b29087ec043",
|
|
4
|
-
"engine/CHANGELOG.md": "
|
|
5
|
-
"engine/README.md": "
|
|
6
|
-
"engine/SKILL-lite.md": "
|
|
7
|
-
"engine/SKILL-tiny.md": "
|
|
8
|
-
"engine/SKILL.md": "
|
|
9
|
-
"engine/assets/panel.html": "
|
|
4
|
+
"engine/CHANGELOG.md": "b6262eb1435a7bac003cd0403e1e16baee293170585119ed5803124e2459a49b",
|
|
5
|
+
"engine/README.md": "5ab87b76dc757e6edd6ef1d760e9a979e55df48b2b8c2b76552747fabb7b1026",
|
|
6
|
+
"engine/SKILL-lite.md": "4dcda5f429e4017a7beb0e95374e07b58e62825a7597d288ac71cbb9a0b269ef",
|
|
7
|
+
"engine/SKILL-tiny.md": "8c0304e4b6d4f55d81998a88f698eb4d51415853928cad5514404dbe3c016098",
|
|
8
|
+
"engine/SKILL.md": "4663a5d3bd3e369a8dee909b9303f2a9a853b9a2c7e8e0d2723d9a171ea93e4d",
|
|
9
|
+
"engine/assets/panel.html": "7b8f3c1d595e14a06e266ea89c90620f3ce2223c2af2a089e407df734df28e17",
|
|
10
10
|
"engine/docs/commands.md": "0ce8c88e5d2d04a8055b45c060ebd53b50c52b79b650312e2ee440845804ca4b",
|
|
11
11
|
"engine/docs/mechanics.md": "aa9683c827ed3419106e84d847ab16dc310c27fc62f588184192aaa1617523cc",
|
|
12
12
|
"engine/docs/models.md": "596bc1a3414f2de5569dcb41a0c494acae7daa534efd5a91dbcc3c4cb308d695",
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
"engine/scripts/occ.py": "4caac0d72ce071ea224ce2dc7d346effdbff8a516e3e7b54118a3be3ed274256",
|
|
53
53
|
"engine/scripts/panel_build.py": "5dfc687631c9818370d8392aca1443ce605f2e8994c2277019f0742e42008567",
|
|
54
54
|
"engine/scripts/panel_cloud.py": "a35155e968b90f5d51e86ffafb14c96a9e6cbb1f20152b9831cb95767d72ce09",
|
|
55
|
-
"engine/scripts/panel_data.py": "
|
|
55
|
+
"engine/scripts/panel_data.py": "189eadcba9139fc934fc22fcd62911828b28fe3a4a189c8c0598043d227ea37b",
|
|
56
56
|
"engine/scripts/panel_icon.py": "8b766740c547087c4d40ab7031a8b6845f3e0bdd3893079d2da22bb9c9694a9f",
|
|
57
57
|
"engine/scripts/panel_launcher.py": "c27c195acc126dace8b99f66906bbdb64ef4dcb4a66513907ebd4df159b97af1",
|
|
58
58
|
"engine/scripts/panel_server.py": "420292bf8f37a653f277b89f90f4f4744e9506c3062db2299a15aeca7040d3b1",
|
|
59
|
-
"engine/scripts/panel_settings.py": "
|
|
59
|
+
"engine/scripts/panel_settings.py": "1d33fc5bf46ee64e3d1b052ecfa1b998a5da55a58e55807182a7214f8594b15b",
|
|
60
60
|
"engine/scripts/panel_shortcut.py": "956374abe9d1e2b63618223e861f696070b6c0368a757f5a630f441c854ea1ea",
|
|
61
61
|
"engine/scripts/panel_splash.py": "36cd59e593ce52557a180a8767bfa9cd9c803f0cccaa141e7da8babd5a35e925",
|
|
62
62
|
"engine/scripts/panel_update.py": "b6256af938fec44e7e0c0073d7ed3f2b50487f6d52cea5772fe175d222b09f0d",
|
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## v5.69(2026-12-05)
|
|
4
|
+
|
|
5
|
+
### 🛡️ 150 项审计第十三批:Cordis IM 安全与面板设置组大收官
|
|
6
|
+
|
|
7
|
+
1. **LS-093(高·guard 注册失败拒绝态)**:`lingshu-guard` 注册全部失败时进入 deny-all——所有工具调用直接拒绝并给明确诊断,IM 鉴权绝不裸奔。
|
|
8
|
+
2. **LS-094(高·IM 授权跟随真实 HOME)**:`lingshu-im` 的 `memoryHome()` 与 Python 一致解析 `.home` 指针,旧默认目录的 consent.json 不再覆盖真实库授权。
|
|
9
|
+
3. **LS-095(高·群聊缺 chatId fail-closed)**:群聊消息无有效 chatId 时返回 null 拒绝召回/写回,绝不降级成私聊作用域。
|
|
10
|
+
4. **LS-099(高·SKILL.md 缺失仍挂 guard)**:`index.js` 技能文档注册失败不再阻断 guard 等安全组件挂载。
|
|
11
|
+
5. **LS-101(中·只读白名单移除 todo_write)**:`lingshu-guard` 的 `DEFAULT_READ_ONLY` 移除有写副作用的 `todo_write`。
|
|
12
|
+
6. **LS-102(中·cron 消息去重键)**:mid 规范统一为 `${role}:${mid}`,user/assistant 同数字 id 不再互相误判。
|
|
13
|
+
7. **LS-103(中·selfReviewDays 真正控制间隔)**:`dueByDays` 按真实日期差��算到期,配 3 天不再每天执行。
|
|
14
|
+
8. **LS-109(中·extract 只收集真实对话)**:工具/系统/插件注入消息不进对话缓冲,防自我吞噬。
|
|
15
|
+
9. **LS-111(中·cron 状态原子保存)**:`saveState` 不再先删旧状态,rename 失败时旧状态原样保留。
|
|
16
|
+
10. **LS-112(中·prior 排除插件注入)**:`lastUserText` 检查 source.name/kind,cron/IM 注入不触发无关 prior 检索。
|
|
17
|
+
11. **LS-113(中·token 标定 HOME 修复)**:`_calibPaths` 改用已有的 `memoryHome()`,修复 readBrainHome 未定义。
|
|
18
|
+
12. **LS-114(中·顶层 checkpoint 识别)**:`context-fold.js` 三个位置检查 compact-checkpoint 来源。
|
|
19
|
+
13. **LS-074(中·损坏 manifest 字段容错)**:`panel_data.py` 单条记录字段级容错,正常备份照常展示。
|
|
20
|
+
14. **LS-075/077(中·enum 设置与 NaN 拒绝)**:`panel_settings.py` 支持 enum 类型校验;float 拒绝 NaN/Infinity。
|
|
21
|
+
15. **LS-076/084(中·enum 渲染与体检契约)**:前端 enum 渲染为 select;dochealth 统一走 api() 并以 items 为准。
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
3
25
|
## v5.68(2026-12-04)
|
|
4
26
|
|
|
5
27
|
### 🔧 150 项审计第十二批:Cordis 插件多 Agent 隔离修复
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> 名字取自《黄帝内经》:**算力给思考,人格给灵魂,记忆给生命。**
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> 当��版本 **v5.69**(变更见 [CHANGELOG.md](CHANGELOG.md))
|
|
6
6
|
|
|
7
7
|
> 🔁 **双仓库镜像**:GitHub(主)与 Gitee(镜像)保持同步——[gitee.com/htmcwy_0/lingshu-skill](https://gitee.com/htmcwy_0/lingshu-skill)。灵枢的更新检查会探测两边最新提交,**谁更新就自动从谁拉取**;任一边不可达(Gitee 匿名风控 / GitHub 限额)时走另一边兜底。
|
|
8
8
|
|
|
@@ -4250,6 +4250,14 @@ function _settingRow(it){
|
|
|
4250
4250
|
const opts = (it.choices || []).map(c =>
|
|
4251
4251
|
`<option value="${esc(c)}"${String(it.value) === c ? " selected" : ""}>${esc(c)}</option>`).join("");
|
|
4252
4252
|
ctl = `<select id="${id}" data-key="${esc(it.key)}">${opts}</select>`;
|
|
4253
|
+
} else if (it.kind === "enum"){
|
|
4254
|
+
// LS-076(v5.69):enum 设置渲染为选项控件——支持 ["a","b"] 与 [{value,label}] 两种 options
|
|
4255
|
+
const opts = (it.options || []).map(o => {
|
|
4256
|
+
const v = (o && typeof o === "object") ? String(o.value ?? "") : String(o);
|
|
4257
|
+
const label = (o && typeof o === "object") ? String(o.label ?? o.value ?? "") : String(o);
|
|
4258
|
+
return `<option value="${esc(v)}"${String(it.value) === v ? " selected" : ""}>${esc(label)}</option>`;
|
|
4259
|
+
}).join("");
|
|
4260
|
+
ctl = `<select id="${id}" data-key="${esc(it.key)}">${opts}</select>`;
|
|
4253
4261
|
} else {
|
|
4254
4262
|
const step = it.step != null ? it.step : (it.kind === "float" ? 0.05 : 1);
|
|
4255
4263
|
const min = it.min != null ? ` min="${it.min}"` : "";
|
|
@@ -7872,9 +7880,9 @@ setTimeout(() => checkUpdate(true), 1200);
|
|
|
7872
7880
|
const el = body();
|
|
7873
7881
|
if (!el) return;
|
|
7874
7882
|
try {
|
|
7875
|
-
|
|
7876
|
-
const j = await
|
|
7877
|
-
const hist = Array.isArray(j) ? j : (j.history || j.rows || []);
|
|
7883
|
+
// LS-083/084(v5.69):统一 API helper 携带 token;items 字段前后端同一契约
|
|
7884
|
+
const j = await api("/api/doctor-history?limit=90");
|
|
7885
|
+
const hist = Array.isArray(j) ? j : (j.items || j.history || j.rows || []);
|
|
7878
7886
|
if (sum()) {
|
|
7879
7887
|
const st = (!Array.isArray(j) && j.stage) || null;
|
|
7880
7888
|
const g = st ? ` · 成长阶段:${esc(st.name || st.stage || "")}` : "";
|
|
@@ -98,10 +98,22 @@ def list_backups(limit: int = 30) -> dict:
|
|
|
98
98
|
except OSError:
|
|
99
99
|
continue
|
|
100
100
|
sha_file = p.with_name(p.name + ".sha256")
|
|
101
|
-
|
|
101
|
+
# LS-074(v5.69):隔离损坏备份 manifest 的字段错误!
|
|
102
|
+
# 单条记录的 manifest 读失败 / 字段类型错不再让它 abort 整个列表——
|
|
103
|
+
# 按字段级容错,正常备份照常展示。
|
|
104
|
+
man = None
|
|
105
|
+
man_err = ""
|
|
106
|
+
try:
|
|
107
|
+
man = _manifest_of(p)
|
|
108
|
+
except Exception as _me: # noqa: BLE001
|
|
109
|
+
man_err = str(_me)[:80]
|
|
102
110
|
records = None
|
|
103
|
-
if man:
|
|
104
|
-
|
|
111
|
+
if isinstance(man, dict):
|
|
112
|
+
try:
|
|
113
|
+
records = int(man.get("total_records") or 0)
|
|
114
|
+
except (TypeError, ValueError):
|
|
115
|
+
records = None
|
|
116
|
+
man_err = "total_records 字段类型异常"
|
|
105
117
|
if records is None:
|
|
106
118
|
records = _count_in_zip(p) # 老备份没清单:解包数一遍
|
|
107
119
|
age_h = max(0.0, (time.time() - st.st_mtime) / 3600.0)
|
|
@@ -120,6 +132,8 @@ def list_backups(limit: int = 30) -> dict:
|
|
|
120
132
|
"suspicious_why": ("包体过小" if bad_size
|
|
121
133
|
else (f"记录数 {records} < 阈值 {threshold}" if bad_records else "")),
|
|
122
134
|
"has_sha": sha_file.is_file(),
|
|
135
|
+
"manifest_ok": bool(isinstance(man, dict) and not man_err),
|
|
136
|
+
"manifest_error": man_err,
|
|
123
137
|
})
|
|
124
138
|
return {"dir": str(d), "dir_exists": d.is_dir(), "items": items,
|
|
125
139
|
"count": len(items), "current_records": cur,
|
|
@@ -167,7 +167,13 @@ def all_items() -> list[dict]:
|
|
|
167
167
|
|
|
168
168
|
|
|
169
169
|
def coerce(spec: dict, raw) -> Any:
|
|
170
|
-
"""按 schema 校验并转换一个值;不合法抛 ValueError(消息可直接给用户看)。
|
|
170
|
+
"""按 schema 校验并转换一个值;不合法抛 ValueError(消息可直接给用户看)。
|
|
171
|
+
|
|
172
|
+
LS-075(v5.69):实现 enum 设置的后端转换——kind=enum 按 options 校验并返回字符串。
|
|
173
|
+
LS-077(v5.69):拒绝 float 配置中的非有限数——NaN/Infinity 落盘后
|
|
174
|
+
标准 JSON 输出会变 `NaN` 字面量,前端 JSON.parse 直接失败("已写入但前端解析失败")。
|
|
175
|
+
"""
|
|
176
|
+
import math as _math
|
|
171
177
|
kind = spec["kind"]
|
|
172
178
|
if kind == "bool":
|
|
173
179
|
if isinstance(raw, bool):
|
|
@@ -178,11 +184,28 @@ def coerce(spec: dict, raw) -> Any:
|
|
|
178
184
|
if s in ("false", "0", "no", "off"):
|
|
179
185
|
return False
|
|
180
186
|
raise ValueError(f"{spec['label']} 是开关,只接受 true/false")
|
|
187
|
+
if kind == "enum":
|
|
188
|
+
# LS-075: enum 类型——按 options 白名单校验,返回字符串
|
|
189
|
+
opts = spec.get("options") or []
|
|
190
|
+
s = str(raw).strip()
|
|
191
|
+
# enum 的 options 可能是 ["a","b"] 或 [{"value":"a","label":"A"},...]
|
|
192
|
+
vals = []
|
|
193
|
+
for o in opts:
|
|
194
|
+
if isinstance(o, dict):
|
|
195
|
+
vals.append(str(o.get("value", "")))
|
|
196
|
+
else:
|
|
197
|
+
vals.append(str(o))
|
|
198
|
+
if s not in vals:
|
|
199
|
+
raise ValueError(f"{spec['label']} 只能是 {'/'.join(vals) if vals else '(无可选值)'}")
|
|
200
|
+
return s
|
|
181
201
|
if kind in ("int", "float"):
|
|
182
202
|
try:
|
|
183
203
|
num = float(raw)
|
|
184
204
|
except (TypeError, ValueError):
|
|
185
205
|
raise ValueError(f"{spec['label']} 需要是数字")
|
|
206
|
+
# LS-077: 拒绝非有限数
|
|
207
|
+
if not _math.isfinite(num):
|
|
208
|
+
raise ValueError(f"{spec['label']} 不能是 NaN 或 Infinity")
|
|
186
209
|
if kind == "int":
|
|
187
210
|
if num != int(num):
|
|
188
211
|
raise ValueError(f"{spec['label']} 需要是整数")
|
package/scripts/panel_data.py
CHANGED
|
@@ -98,10 +98,22 @@ def list_backups(limit: int = 30) -> dict:
|
|
|
98
98
|
except OSError:
|
|
99
99
|
continue
|
|
100
100
|
sha_file = p.with_name(p.name + ".sha256")
|
|
101
|
-
|
|
101
|
+
# LS-074(v5.69):隔离损坏备份 manifest 的字段错误!
|
|
102
|
+
# 单条记录的 manifest 读失败 / 字段类型错不再让它 abort 整个列表——
|
|
103
|
+
# 按字段级容错,正常备份照常展示。
|
|
104
|
+
man = None
|
|
105
|
+
man_err = ""
|
|
106
|
+
try:
|
|
107
|
+
man = _manifest_of(p)
|
|
108
|
+
except Exception as _me: # noqa: BLE001
|
|
109
|
+
man_err = str(_me)[:80]
|
|
102
110
|
records = None
|
|
103
|
-
if man:
|
|
104
|
-
|
|
111
|
+
if isinstance(man, dict):
|
|
112
|
+
try:
|
|
113
|
+
records = int(man.get("total_records") or 0)
|
|
114
|
+
except (TypeError, ValueError):
|
|
115
|
+
records = None
|
|
116
|
+
man_err = "total_records 字段类型异常"
|
|
105
117
|
if records is None:
|
|
106
118
|
records = _count_in_zip(p) # 老备份没清单:解包数一遍
|
|
107
119
|
age_h = max(0.0, (time.time() - st.st_mtime) / 3600.0)
|
|
@@ -120,6 +132,8 @@ def list_backups(limit: int = 30) -> dict:
|
|
|
120
132
|
"suspicious_why": ("包体过小" if bad_size
|
|
121
133
|
else (f"记录数 {records} < 阈值 {threshold}" if bad_records else "")),
|
|
122
134
|
"has_sha": sha_file.is_file(),
|
|
135
|
+
"manifest_ok": bool(isinstance(man, dict) and not man_err),
|
|
136
|
+
"manifest_error": man_err,
|
|
123
137
|
})
|
|
124
138
|
return {"dir": str(d), "dir_exists": d.is_dir(), "items": items,
|
|
125
139
|
"count": len(items), "current_records": cur,
|
|
@@ -167,7 +167,13 @@ def all_items() -> list[dict]:
|
|
|
167
167
|
|
|
168
168
|
|
|
169
169
|
def coerce(spec: dict, raw) -> Any:
|
|
170
|
-
"""按 schema 校验并转换一个值;不合法抛 ValueError(消息可直接给用户看)。
|
|
170
|
+
"""按 schema 校验并转换一个值;不合法抛 ValueError(消息可直接给用户看)。
|
|
171
|
+
|
|
172
|
+
LS-075(v5.69):实现 enum 设置的后端转换——kind=enum 按 options 校验并返回字符串。
|
|
173
|
+
LS-077(v5.69):拒绝 float 配置中的非有限数——NaN/Infinity 落盘后
|
|
174
|
+
标准 JSON 输出会变 `NaN` 字面量,前端 JSON.parse 直接失败("已写入但前端解析失败")。
|
|
175
|
+
"""
|
|
176
|
+
import math as _math
|
|
171
177
|
kind = spec["kind"]
|
|
172
178
|
if kind == "bool":
|
|
173
179
|
if isinstance(raw, bool):
|
|
@@ -178,11 +184,28 @@ def coerce(spec: dict, raw) -> Any:
|
|
|
178
184
|
if s in ("false", "0", "no", "off"):
|
|
179
185
|
return False
|
|
180
186
|
raise ValueError(f"{spec['label']} 是开关,只接受 true/false")
|
|
187
|
+
if kind == "enum":
|
|
188
|
+
# LS-075: enum 类型——按 options 白名单校验,返回字符串
|
|
189
|
+
opts = spec.get("options") or []
|
|
190
|
+
s = str(raw).strip()
|
|
191
|
+
# enum 的 options 可能是 ["a","b"] 或 [{"value":"a","label":"A"},...]
|
|
192
|
+
vals = []
|
|
193
|
+
for o in opts:
|
|
194
|
+
if isinstance(o, dict):
|
|
195
|
+
vals.append(str(o.get("value", "")))
|
|
196
|
+
else:
|
|
197
|
+
vals.append(str(o))
|
|
198
|
+
if s not in vals:
|
|
199
|
+
raise ValueError(f"{spec['label']} 只能是 {'/'.join(vals) if vals else '(无可选值)'}")
|
|
200
|
+
return s
|
|
181
201
|
if kind in ("int", "float"):
|
|
182
202
|
try:
|
|
183
203
|
num = float(raw)
|
|
184
204
|
except (TypeError, ValueError):
|
|
185
205
|
raise ValueError(f"{spec['label']} 需要是数字")
|
|
206
|
+
# LS-077: 拒绝非有限数
|
|
207
|
+
if not _math.isfinite(num):
|
|
208
|
+
raise ValueError(f"{spec['label']} 不能是 NaN 或 Infinity")
|
|
186
209
|
if kind == "int":
|
|
187
210
|
if num != int(num):
|
|
188
211
|
raise ValueError(f"{spec['label']} 需要是整数")
|