dsh-folia 4.26.0-pre.2 → 4.26.0-pre.21
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/lib/asr/asr-local.js +166 -0
- package/lib/asr/asr-worker.cjs +169 -0
- package/lib/client.js +616 -757
- package/lib/index.js +5 -1
- package/lib/pet-chat-proactive.js +147 -74
- package/lib/routes/pet-chat.js +555 -74
- package/lib/routes/pets.js +30 -2
- package/lib/settings-schema.js +2161 -2168
- package/lib/tts/tts-worker.cjs +129 -0
- package/lib/voice/record.js +217 -0
- package/package.json +5 -1
package/lib/routes/pets.js
CHANGED
|
@@ -344,6 +344,8 @@ export function registerPetsRoutes(webServer, c) {
|
|
|
344
344
|
id: String((it && (it.slug || it.id)) || ''),
|
|
345
345
|
title: String((it && it.title) || ''),
|
|
346
346
|
bytes: Number(it && it.bytes) || null,
|
|
347
|
+
// 4.26:站点 DTO 现在给 sha256(门 1 起);有就传给下载队列按 sha 校验。
|
|
348
|
+
sha256: typeof (it && it.sha256) === 'string' ? it.sha256 : '',
|
|
347
349
|
url: abs,
|
|
348
350
|
cover: thumb && /\.(jpg|jpeg|png|webp|gif|avif)(\?|#|$)/i.test(thumb)
|
|
349
351
|
? (/^https?:/i.test(thumb) ? thumb : base + thumb) : null,
|
|
@@ -597,6 +599,32 @@ export function registerPetsRoutes(webServer, c) {
|
|
|
597
599
|
return;
|
|
598
600
|
}
|
|
599
601
|
|
|
602
|
+
/**
|
|
603
|
+
* **sha256 校验**(阶段 3):站点给了 sha 就必须对得上。
|
|
604
|
+
*
|
|
605
|
+
* 为什么要在校验失败时连目录一起删:安装是「先下载、再解压、后落盘」,
|
|
606
|
+
* 但只要上一次中途失败留下半个目录,`/pets/list` 就可能把它当成一只坏宠物。
|
|
607
|
+
* 这里统一 `cleanupPartial()`:删半成品目录 + 删缓存 zip,保证失败后磁盘干净。
|
|
608
|
+
*/
|
|
609
|
+
const cleanupPartial = () => {
|
|
610
|
+
try { rmSync(join(dataRoot(), id), { recursive: true, force: true }); } catch { /* ignore */ }
|
|
611
|
+
try { rmSync(zipDest, { force: true }); } catch { /* ignore */ }
|
|
612
|
+
};
|
|
613
|
+
if (item.sha256) {
|
|
614
|
+
const digest = createHash('sha256').update(buf).digest('hex');
|
|
615
|
+
if (digest !== item.sha256) {
|
|
616
|
+
cleanupPartial();
|
|
617
|
+
failInstall('sha-mismatch', 'expected=' + item.sha256.slice(0, 12) + ' actual=' + digest.slice(0, 12));
|
|
618
|
+
sendJson(res, 422, {
|
|
619
|
+
ok: false,
|
|
620
|
+
error: 'sha-mismatch',
|
|
621
|
+
expected: item.sha256,
|
|
622
|
+
actual: digest,
|
|
623
|
+
});
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
600
628
|
let entries;
|
|
601
629
|
try { entries = unzip(buf); } catch (e) {
|
|
602
630
|
failInstall('bad-zip', String((e && e.message) || e));
|
|
@@ -604,12 +632,12 @@ export function registerPetsRoutes(webServer, c) {
|
|
|
604
632
|
return;
|
|
605
633
|
}
|
|
606
634
|
const manifestRaw = entries.get('pet.json');
|
|
607
|
-
if (!manifestRaw) { failInstall('no-manifest'); sendJson(res, 422, { ok: false, error: 'no-manifest' }); return; }
|
|
635
|
+
if (!manifestRaw) { cleanupPartial(); failInstall('no-manifest'); sendJson(res, 422, { ok: false, error: 'no-manifest' }); return; }
|
|
608
636
|
let manifest;
|
|
609
637
|
try { manifest = JSON.parse(manifestRaw.toString('utf8')); } catch { failInstall('bad-manifest'); sendJson(res, 422, { ok: false, error: 'bad-manifest' }); return; }
|
|
610
638
|
const sheetName = basename((manifest.sprite2d && manifest.sprite2d.spritesheetPath) || 'spritesheet.webp');
|
|
611
639
|
const sheet = entries.get(sheetName);
|
|
612
|
-
if (!sheet) { failInstall('no-spritesheet', sheetName); sendJson(res, 422, { ok: false, error: 'no-spritesheet', detail: sheetName }); return; }
|
|
640
|
+
if (!sheet) { cleanupPartial(); failInstall('no-spritesheet', sheetName); sendJson(res, 422, { ok: false, error: 'no-spritesheet', detail: sheetName }); return; }
|
|
613
641
|
|
|
614
642
|
const dir = join(dataRoot(), id);
|
|
615
643
|
try {
|