odant-work 1.0.19 → 1.0.20
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/#system/package-manifest.json +11 -11
- package/MODELS/$ai/$folder/$class/$provider/handlers/pages/form/trainer/$handler/trainer.js +49 -25
- package/package.json +1 -1
- package/sources/data/progress.md +4 -0
- package/sources/host/auto-updater.js +24 -0
- package/sources/modules/trainer/halogen.js +16 -4
- package/sources/modules/trainer/huggingface.js +63 -34
- package/sources/modules/trainer/runner.js +54 -4
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"packageName": "odant-work",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"createdAt":
|
|
5
|
-
"updatedAt":
|
|
3
|
+
"version": "1.0.20",
|
|
4
|
+
"createdAt": 1794575479714,
|
|
5
|
+
"updatedAt": 1794575479714,
|
|
6
6
|
"files": {
|
|
7
7
|
"run.mjs": "f8918c612e8641e9beee06221be6680aa6fd21f25468451f2ac857fd51772266",
|
|
8
|
-
"package.json": "
|
|
9
|
-
"package-lock.json": "
|
|
8
|
+
"package.json": "8d0e9410dd47fdbe38e381f115bdc32f307896bd1687c6791010c11c2923d136",
|
|
9
|
+
"package-lock.json": "83ecf187c651ef9b01a944f874938ad68c8b9676e0dcd67b7d3166590721823f",
|
|
10
10
|
"sources/client/class.js": "c3fb8f143fc83aaa2df1ddeddd412d2d4dfe88656578095babe2df34fb3b3922",
|
|
11
11
|
"sources/client/field.js": "ffdd50fa8b6ec515cc42da5fca96658ff2b20e274601a1f926e0031372467a19",
|
|
12
12
|
"sources/client/file.js": "667101d75fa30840370d5be232e518aaac7c1fd52ca05a12da560eef6c0848b0",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"sources/data/objects.js": "23f51d5b00cd766fe27879b874738bc9bd9056bd6e27285fb7a52926c0dbc6a8",
|
|
27
27
|
"sources/data/posting.js": "6595bb9ec632539ae7629504db327d25a491e61c1cdc598bb43d08ea0d45548d",
|
|
28
28
|
"sources/data/print.js": "704f0f2fc80c6466a4196e4650d763150cf9b592eab14ea67ece85d51100107c",
|
|
29
|
-
"sources/data/progress.md": "
|
|
29
|
+
"sources/data/progress.md": "97f27b7118693a96aa9f0bd3438c854e624d321b95928c438c6dadf26837d0d4",
|
|
30
30
|
"sources/data/readme.md": "593fa2ae07aa91bc26d7542275da6953a9cd419240a9a49e00cb62fb9d5d8e36",
|
|
31
31
|
"sources/data/reports.js": "0330f404860fe2589a7d46a2f0fe690ca23249bd841a062a26718742d4fd11d6",
|
|
32
32
|
"sources/data/schema.js": "2a598b33c9352e3b673639dda302caeb13620cf978960cbcaee906f7bb852d50",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"sources/data/time.js": "cb34c1137685e83265938bb007859dfc1fca3548588d1663ee01e1affc87a09a",
|
|
36
36
|
"sources/data/workspace.js": "afbc007c16a26e86de2753794e0e7387218e97aba378047a5f37ea7961e3e921",
|
|
37
37
|
"sources/host/auth-methods.js": "d4cc34ea5b56bb314ea903c065706135e12ff685f69e6234658588c92d2c6509",
|
|
38
|
-
"sources/host/auto-updater.js": "
|
|
38
|
+
"sources/host/auto-updater.js": "39649bf1fa9790698d80a0f2e5c6f89ea2a251af40fd095a0480a0f5f3a386ba",
|
|
39
39
|
"sources/host/babel-merge.js": "11d5b65cae03aeabd09f06f65bee78f6fd0131eab125cc87c0dcaaf2d10e08a5",
|
|
40
40
|
"sources/host/config.js": "f41058d2ef46afc0ac5e262a0f31064d3288ab3794c4d45c0761498e775f60ae",
|
|
41
41
|
"sources/host/email-utils.js": "618f474b92c85675aeeb7584c1ef7d73441b9efc1463b9b836e7facb86e5d558",
|
|
@@ -165,12 +165,12 @@
|
|
|
165
165
|
"sources/modules/sandbox/stream.js": "bfa74c918642e4fa5af170fdde52d825865f4fd09f771da5305898ac4738d4de",
|
|
166
166
|
"sources/modules/sandbox/vnc-proxy.js": "1c75c2b24d579f254de1c4727621fbbcc7e8a10360f638f4cf1c4bd91184d103",
|
|
167
167
|
"sources/modules/trainer/dataset.js": "ca91f11249ccf4fce9c15dc780711fa33059a3e1efbaf0ccdbbd59e529b0108e",
|
|
168
|
-
"sources/modules/trainer/halogen.js": "
|
|
169
|
-
"sources/modules/trainer/huggingface.js": "
|
|
168
|
+
"sources/modules/trainer/halogen.js": "b65f40c6e2262e2a77453edfe21f52318f8d8e92e473affb4180bcb1d755efe2",
|
|
169
|
+
"sources/modules/trainer/huggingface.js": "114df576ea8770af58f7737f7dd0b095a80d4438dc9b8accee1fdec5d36e7d61",
|
|
170
170
|
"sources/modules/trainer/index.js": "715ec739676d2e4cd8cec2768ede93e2546c502b8452f1314fe676592594431a",
|
|
171
171
|
"sources/modules/trainer/local-engine.js": "83cd121b208248606c8cbfdb7100c5ab1b2f06dc56b5266d2df8feda0237be4d",
|
|
172
172
|
"sources/modules/trainer/providers.js": "18e075140bb14a9dd2ef70412942a03558d415abab9387d1d42c39f8c422b073",
|
|
173
|
-
"sources/modules/trainer/runner.js": "
|
|
173
|
+
"sources/modules/trainer/runner.js": "347c413e96b5c4478693f35ce8a4261bcf52c207b0cda769eeb425e95ee53238",
|
|
174
174
|
"sources/modules/trainer/worker/local_infer_worker.py": "7b001d75c64ac3ae6de650f6d738f22bfc21b6bd0694b57248e5b40966deb443",
|
|
175
175
|
"sources/modules/trainer/worker/unsloth_train.py": "7774d94ffa6f60eed20c57a8dfdc12621d5d9f74d594c605dff32ff70e321e33",
|
|
176
176
|
"sources/modules/user-profile/user-profile.js": "47b71574ec51e6d40e218e996c8397b25f36418f21e69668c75f1df7d64eb914",
|
|
@@ -961,7 +961,7 @@
|
|
|
961
961
|
"MODELS/$ai/$folder/$class/$provider/handlers/pages/form/provider/$handler/class.js": "8d327820cefd696d351ac4fa7998994039e4d57ef7a9f8ae297209e4dd1b0a9e",
|
|
962
962
|
"MODELS/$ai/$folder/$class/$provider/handlers/pages/form/provider/$handler/provider.js": "b9ddf0040a9cd12e0dacd2dd3a61a1f0e62686cc664d02ef446326bc3991f4ce",
|
|
963
963
|
"MODELS/$ai/$folder/$class/$provider/handlers/pages/form/trainer/$handler/class.js": "06b279a1c053deb37dd7401c84df7f9370309b8dfbd35b368ab1bab4f635cb3f",
|
|
964
|
-
"MODELS/$ai/$folder/$class/$provider/handlers/pages/form/trainer/$handler/trainer.js": "
|
|
964
|
+
"MODELS/$ai/$folder/$class/$provider/handlers/pages/form/trainer/$handler/trainer.js": "566055422267755d68dd741712ea8fcfc032a0bffb5fe15ea03faf3389e52f19",
|
|
965
965
|
"MODELS/$ai/$folder/$class/$provider/readme.md": "d6ceef2010231ab121510c3d3f35630dd7009a069c7723f6673a0e264799b227",
|
|
966
966
|
"MODELS/$ai/class.js": "54e1bbbde88f8b1f272ff7f5cad87243407591748a44719b7ec90ae2b4962de7",
|
|
967
967
|
"MODELS/$ai/readme.md": "90d70305a2c85312282cf67cc468a0f0b417495cb3d5b3d2ca60c6f44b81cb77",
|
|
@@ -346,7 +346,10 @@ export default {
|
|
|
346
346
|
<div class="section-title">Идёт установка ({{activeDownloads.length}})</div>
|
|
347
347
|
<div class="model-row" ~for="activeDownloads">
|
|
348
348
|
<div class="model-main">
|
|
349
|
-
<div
|
|
349
|
+
<div>
|
|
350
|
+
<div class="model-name">{{$for.item.label || $for.item.folderName || $for.item.repoId}}</div>
|
|
351
|
+
<div class="model-desc">{{$for.item.repoId}} <span ~if="$for.item.currentFile">· {{$for.item.currentFile}}</span></div>
|
|
352
|
+
</div>
|
|
350
353
|
<div class="toolbar">
|
|
351
354
|
<span style="font-size:12px;font-weight:600;">{{$for.item.progress || 0}}% · {{$for.item.speedMBs || 0}} МБ/с</span>
|
|
352
355
|
<button type="button" class="btn danger" @tap="cancelDownload($for.item.id)">Отменить</button>
|
|
@@ -358,7 +361,7 @@ export default {
|
|
|
358
361
|
</div>
|
|
359
362
|
</div>
|
|
360
363
|
|
|
361
|
-
<!-- 3. Каталог моделей для установки в 1 клик -->
|
|
364
|
+
<!-- 3. Каталог моделей для установки в 1 клик (только ещё не установленные и не качающиеся прямо сейчас) -->
|
|
362
365
|
<div class="card">
|
|
363
366
|
<div class="section-title">Каталог моделей для установки</div>
|
|
364
367
|
|
|
@@ -394,13 +397,17 @@ export default {
|
|
|
394
397
|
• <b>Файл подкачки Windows 11:</b> рекомендуется фиксированный PageFile <b>128 ГБ</b> на NVMe SSD.
|
|
395
398
|
</div>
|
|
396
399
|
</div>
|
|
397
|
-
<button type="button" class="btn primary" @tap="downloadHalogenBundleAll()">
|
|
400
|
+
<button type="button" class="btn primary" ~if="availableHalogenCatalog.length" @tap="downloadHalogenBundleAll()">
|
|
398
401
|
Установить весь комплект Halo (GPU + NPU)
|
|
399
402
|
</button>
|
|
400
403
|
</div>
|
|
401
404
|
</div>
|
|
402
405
|
|
|
403
|
-
<div
|
|
406
|
+
<div ~if="!availableHalogenCatalog.length" style="opacity:0.75;padding:4px 0;">
|
|
407
|
+
Все модели комплекта Halo уже установлены или устанавливаются прямо сейчас (см. список выше).
|
|
408
|
+
</div>
|
|
409
|
+
|
|
410
|
+
<div class="model-row" ~for="availableHalogenCatalog">
|
|
404
411
|
<div class="model-main">
|
|
405
412
|
<div class="model-left">
|
|
406
413
|
<oda-icon :icon="$for.item.icon || 'ai:qwen'" icon-size="20"></oda-icon>
|
|
@@ -414,21 +421,20 @@ export default {
|
|
|
414
421
|
<span class="dot on"></span>
|
|
415
422
|
<span>{{$for.item.device}} · ~{{$for.item.ramGb}} ГБ</span>
|
|
416
423
|
</span>
|
|
417
|
-
<
|
|
418
|
-
<button type="button" class="btn primary" ~if="!$for.item.weightsDownloaded && !$for.item.activeDownload" @tap="downloadHalogenModel($for.item.nodeName)">
|
|
424
|
+
<button type="button" class="btn primary" @tap="downloadHalogenModel($for.item.nodeName)">
|
|
419
425
|
Установить
|
|
420
426
|
</button>
|
|
421
427
|
</div>
|
|
422
428
|
</div>
|
|
423
|
-
<div class="progress-track" ~if="$for.item.activeDownload">
|
|
424
|
-
<div class="progress-fill" ~style="{width: ($for.item.activeDownload.progress || 0) + '%'}"></div>
|
|
425
|
-
</div>
|
|
426
429
|
</div>
|
|
427
430
|
</div>
|
|
428
431
|
|
|
429
432
|
<!-- Обычный каталог моделей (Чат, Зрение, Речь, Картинки, Поиск) -->
|
|
430
433
|
<div ~if="hfModality !== 'halo'" class="vertical" style="gap:8px;">
|
|
431
|
-
<div
|
|
434
|
+
<div ~if="!availableHfModels.length" style="opacity:0.75;padding:4px 0;">
|
|
435
|
+
Все найденные модели этой категории уже установлены или устанавливаются выше.
|
|
436
|
+
</div>
|
|
437
|
+
<div class="model-row" ~for="availableHfModels">
|
|
432
438
|
<div class="model-main">
|
|
433
439
|
<div class="model-left">
|
|
434
440
|
<oda-icon :icon="$for.item.icon || 'ai:ollama'" icon-size="20"></oda-icon>
|
|
@@ -442,15 +448,11 @@ export default {
|
|
|
442
448
|
<span class="dot" ~class="$for.item.fit === 'too_large' ? 'off' : ($for.item.fit === 'optimal' ? 'on' : 'warn')"></span>
|
|
443
449
|
<span>~{{$for.item.ramRequiredGb || 4}} ГБ</span>
|
|
444
450
|
</span>
|
|
445
|
-
<
|
|
446
|
-
<button type="button" class="btn primary" ~if="!isRepoInstalled($for.item.id) && !getActiveDownload($for.item.id)" @tap="installModelOneClick($for.item.id)">
|
|
451
|
+
<button type="button" class="btn primary" @tap="installModelOneClick($for.item.id)">
|
|
447
452
|
Установить
|
|
448
453
|
</button>
|
|
449
454
|
</div>
|
|
450
455
|
</div>
|
|
451
|
-
<div class="progress-track" ~if="getActiveDownload($for.item.id)">
|
|
452
|
-
<div class="progress-fill" ~style="{width: (getActiveDownload($for.item.id)?.progress || 0) + '%'}"></div>
|
|
453
|
-
</div>
|
|
454
456
|
</div>
|
|
455
457
|
</div>
|
|
456
458
|
</div>
|
|
@@ -577,19 +579,41 @@ export default {
|
|
|
577
579
|
get activeDownloads() {
|
|
578
580
|
return (this.downloads || []).filter(d => d.status === 'downloading');
|
|
579
581
|
},
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|| String(m.model || '').toLowerCase() === String(repoId).toLowerCase()
|
|
582
|
+
get availableHalogenCatalog() {
|
|
583
|
+
return (this.halogenCatalog || []).filter(item =>
|
|
584
|
+
!item.weightsDownloaded
|
|
585
|
+
&& !item.activeDownload
|
|
586
|
+
&& !this.isRepoInstalled(item.hfRepo, item.nodeName)
|
|
587
|
+
&& !this.getActiveDownload(item.hfRepo, item.nodeName)
|
|
587
588
|
);
|
|
588
589
|
},
|
|
589
|
-
|
|
590
|
-
|
|
590
|
+
get availableHfModels() {
|
|
591
|
+
return (this.hfModels || []).filter(item =>
|
|
592
|
+
!this.isRepoInstalled(item.id)
|
|
593
|
+
&& !this.getActiveDownload(item.id)
|
|
594
|
+
);
|
|
595
|
+
},
|
|
596
|
+
isRepoInstalled(repoId, nodeName = '') {
|
|
597
|
+
if (!repoId && !nodeName)
|
|
598
|
+
return false;
|
|
599
|
+
const shortName = repoId ? String(repoId).split('/').pop().toLowerCase() : '';
|
|
600
|
+
const nodeLower = nodeName ? String(nodeName).toLowerCase() : '';
|
|
601
|
+
const repoLower = repoId ? String(repoId).toLowerCase() : '';
|
|
602
|
+
return (this.localModels || []).some(m => {
|
|
603
|
+
const mId = String(m.id || '').toLowerCase();
|
|
604
|
+
const mModel = String(m.model || '').toLowerCase();
|
|
605
|
+
return (shortName && mId === shortName)
|
|
606
|
+
|| (nodeLower && mId === nodeLower)
|
|
607
|
+
|| (repoLower && mModel === repoLower);
|
|
608
|
+
});
|
|
609
|
+
},
|
|
610
|
+
getActiveDownload(repoId, nodeName = '') {
|
|
611
|
+
if (!repoId && !nodeName)
|
|
591
612
|
return null;
|
|
592
|
-
return (this.downloads || []).find(d =>
|
|
613
|
+
return (this.downloads || []).find(d =>
|
|
614
|
+
d.status === 'downloading'
|
|
615
|
+
&& ((repoId && d.repoId === repoId) || (nodeName && d.folderName === nodeName))
|
|
616
|
+
) || null;
|
|
593
617
|
},
|
|
594
618
|
async attached() {
|
|
595
619
|
await this.reloadAll();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "odant-work",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.20",
|
|
4
4
|
"description": "ODANT-WORK — платформа цифровой организации (встроенная система учёта, документооборот, управление процессами и приватный мультимодальный ИИ)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "sources/work.js",
|
package/sources/data/progress.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# Прогресс: sources/data
|
|
2
2
|
|
|
3
3
|
## Последние изменения
|
|
4
|
+
- [23:15, 13.11] Устранение тройного дублирования карточек моделей при установке в `/MODELS/Local` и автоочистка устаревшей ветки `/MODELS/Halogen` (`MODELS/$ai/$folder/$class/$provider/handlers/pages/form/trainer/$handler/trainer.js`, `sources/modules/trainer/{huggingface,halogen,runner}.js`, `sources/host/auto-updater.js`, `tests/halogen-provider.test.js`, `odant-work@1.0.20`):
|
|
5
|
+
- **Скачивание в скрытую папку `#downloads` и регистрация `$ai` только по завершении:** теперь при установке модели файлы качаются во временную системную папку `/MODELS/Local/#downloads/<Имя>` и переносятся в `/MODELS/Local/<Имя>/#weights` вместе с созданием узла `$ai/class.js` только после 100% завершения загрузки весов (`.gguf/.safetensors/.hgn/.hnpw/.bin/.onnx`). Благодаря этому во время скачивания модели больше не появляются преждевременно ни в блоке «Установленные модели» (из-за раннего скачивания `config.json`), ни в левом дереве проводника.
|
|
6
|
+
- **Строго 1 карточка на каждую модель:** в интерфейсе `form/trainer` («Модели ИИ») модели из блоков «Установленные модели» и «Идёт установка» автоматически исключаются из нижнего блока «Каталог моделей для установки» (`availableHalogenCatalog` и `availableHfModels`), поэтому каждая модель отображается на экране ровно один раз (в каталоге → при скачивании в «Идёт установка» → после завершения в «Установленные модели»).
|
|
7
|
+
- **Автоочистка пустых дублей и `/MODELS/Halogen`:** при обновлении и при вызове `listLocalModelsAndAdapters` автоматически удаляются пустые/недокачанные папки моделей без бинарных файлов весов и мигрируется/удаляется устаревшая дублирующая папка `/MODELS/Halogen`.
|
|
4
8
|
- [22:55, 13.11] Защита базы данных лицензионного сервера `work.odant.org` от потери при перезапуске/обновлении через `npx` и автовосстановление данных из кэша `_npx` (`license-server/bin/server.mjs`, `license-server/src/{store,server,admin,index}.js`, `license-server/assets/admin.js`, `sources/host/auto-updater.js`, `tests/license-and-deploy.test.js`, `odant-work@1.0.19`, `work-license-server@1.0.22`):
|
|
5
9
|
- **Причина и устранение потери данных при `npx`:** в прежних версиях `defaultDataDir` вычислялся через `new URL('../data', import.meta.url)`, указывавший внутрь временного кэша `npx` (`~/.npm/_npx/<hash>/node_modules/work-license-server/data`). Теперь `resolvePersistentDataDir()` жёстко запрещает хранение базы внутри `_npx`/`node_modules` и сохраняет её в постоянной папке `<WORK>/data/store.json` + дублирует зеркало в профиле ОС (`~/.odant-work-license/data/store.json`).
|
|
6
10
|
- **Автоматическое восстановление и слияние (`mergeStoreStates`) при старте:** при запуске сервер автоматически сканирует все хэш-папки кэша `npx` (`~/.npm/_npx/*`, `/root/.npm/_npx/*`, `/home/*/.npm/_npx/*`, `%LOCALAPPDATA%/npm-cache/_npx/*`), находит прежние `store.json` и `authority-key.json` и без потерь объединяет всех пользователей, их реквизиты юрлиц, токены `owk1...`, серверы, лицензии, заказы, тикеты и резервы франшиз (отфильтровывая пустые дубли `Сервер WORK #1`, созданные при входе в пустую БД).
|
|
@@ -564,6 +564,30 @@ export function applyUpdateFromDirectory({
|
|
|
564
564
|
|
|
565
565
|
walkSource(absSource);
|
|
566
566
|
|
|
567
|
+
// Очистка устаревшей дублирующей ветки MODELS/Halogen (объединена с MODELS/Local) с сохранением скачанных весов
|
|
568
|
+
try {
|
|
569
|
+
const legacyHalogen = path.join(absRoot, 'MODELS', 'Halogen');
|
|
570
|
+
const localModelsDir = path.join(absRoot, 'MODELS', 'Local');
|
|
571
|
+
if (fs.existsSync(legacyHalogen) && !fs.existsSync(path.join(absSource, 'MODELS', 'Halogen'))) {
|
|
572
|
+
for (const entry of fs.readdirSync(legacyHalogen, { withFileTypes: true })) {
|
|
573
|
+
if (!entry.isDirectory() || entry.name.startsWith('$') || entry.name.startsWith('#'))
|
|
574
|
+
continue;
|
|
575
|
+
const oldWeights = path.join(legacyHalogen, entry.name, '#weights');
|
|
576
|
+
if (fs.existsSync(oldWeights)) {
|
|
577
|
+
const hasWeights = fs.readdirSync(oldWeights).some(
|
|
578
|
+
f => !f.endsWith('.part') && /\.(gguf|safetensors|hgn|hnpw|bin|onnx|pt|pth)$/i.test(f)
|
|
579
|
+
);
|
|
580
|
+
if (hasWeights && !fs.existsSync(path.join(localModelsDir, entry.name))) {
|
|
581
|
+
fs.mkdirSync(localModelsDir, { recursive: true });
|
|
582
|
+
fs.cpSync(path.join(legacyHalogen, entry.name), path.join(localModelsDir, entry.name), { recursive: true });
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
fs.rmSync(legacyHalogen, { recursive: true, force: true });
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
catch { /* ignore */ }
|
|
590
|
+
|
|
567
591
|
// Сохраняем обновлённый манифест поставки
|
|
568
592
|
const nextManifest = {
|
|
569
593
|
packageName: PACKAGE_NAME,
|
|
@@ -1408,11 +1408,12 @@ export function inspectHalogenCatalogWithStatus(rootDir = process.cwd()) {
|
|
|
1408
1408
|
d.status === 'downloading'
|
|
1409
1409
|
&& (d.repoId === spec.hfRepo || d.folderName === spec.nodeName || d.modelPath === spec.path)
|
|
1410
1410
|
) || null;
|
|
1411
|
+
const hasRealWeightFile = downloadedFiles.some(f => /\.(gguf|safetensors|hgn|hnpw|bin|onnx|pt|pth)$/i.test(f));
|
|
1411
1412
|
return {
|
|
1412
1413
|
...spec,
|
|
1413
1414
|
nodeConfigured,
|
|
1414
1415
|
weightsDir: path.relative(rootDir, weightsDir).replace(/\\/g, '/'),
|
|
1415
|
-
weightsDownloaded:
|
|
1416
|
+
weightsDownloaded: !activeJob && hasRealWeightFile,
|
|
1416
1417
|
downloadedFiles,
|
|
1417
1418
|
activeDownload: activeJob,
|
|
1418
1419
|
};
|
|
@@ -1422,7 +1423,7 @@ export function inspectHalogenCatalogWithStatus(rootDir = process.cwd()) {
|
|
|
1422
1423
|
/**
|
|
1423
1424
|
* Поставить в очередь скачивание всего пакета моделей Halo в `/MODELS/Local` (1 основная GPU-модель + 7 NPU-моделей)
|
|
1424
1425
|
* или выбранного подмножества моделей с Hugging Face Hub прямо в `MODELS/Local/<nodeName>/#weights`,
|
|
1425
|
-
* регистрируя узлы `$ai` в `/MODELS/Local/<nodeName
|
|
1426
|
+
* регистрируя узлы `$ai` в `/MODELS/Local/<nodeName>` по мере завершения скачивания каждой модели.
|
|
1426
1427
|
*/
|
|
1427
1428
|
export async function downloadHalogenBundle({
|
|
1428
1429
|
rootDir = process.cwd(),
|
|
@@ -1451,7 +1452,6 @@ export async function downloadHalogenBundle({
|
|
|
1451
1452
|
let alreadyActiveCount = 0;
|
|
1452
1453
|
|
|
1453
1454
|
for (const spec of targets) {
|
|
1454
|
-
await ensureHalogenModelNodes(rootDir, { models: [spec.nodeName], onlyWithWeights: false });
|
|
1455
1455
|
const running = existingDownloads.find(d =>
|
|
1456
1456
|
d.status === 'downloading'
|
|
1457
1457
|
&& (d.repoId === spec.hfRepo || d.folderName === spec.nodeName || d.modelPath === spec.path)
|
|
@@ -1465,9 +1465,21 @@ export async function downloadHalogenBundle({
|
|
|
1465
1465
|
repoId: spec.hfRepo,
|
|
1466
1466
|
providerFolder: 'Local',
|
|
1467
1467
|
targetNodeName: spec.nodeName,
|
|
1468
|
+
nodeMeta: {
|
|
1469
|
+
label: spec.label || spec.nodeName,
|
|
1470
|
+
model: spec.model,
|
|
1471
|
+
protocol: 'halogen',
|
|
1472
|
+
icon: spec.icon || 'ai:qwen',
|
|
1473
|
+
modality: spec.modality,
|
|
1474
|
+
capabilities: spec.capabilities,
|
|
1475
|
+
efforts: spec.efforts,
|
|
1476
|
+
maxTokens: spec.maxTokens,
|
|
1477
|
+
maxOutput: spec.maxOutput,
|
|
1478
|
+
baseUrl: spec.baseUrl || HALOGEN_DEFAULT_BASE_URL,
|
|
1479
|
+
},
|
|
1468
1480
|
rootDir,
|
|
1469
1481
|
token,
|
|
1470
|
-
registerInWork:
|
|
1482
|
+
registerInWork: true,
|
|
1471
1483
|
waitForCompletion,
|
|
1472
1484
|
fetchImpl,
|
|
1473
1485
|
});
|
|
@@ -1018,40 +1018,44 @@ export async function startHuggingFaceDownload({
|
|
|
1018
1018
|
rootDir = process.cwd(),
|
|
1019
1019
|
providerFolder = 'Local',
|
|
1020
1020
|
targetNodeName = '',
|
|
1021
|
+
nodeMeta = null,
|
|
1021
1022
|
registerInWork = true,
|
|
1022
1023
|
waitForCompletion = false,
|
|
1023
1024
|
fetchImpl = globalThis.fetch,
|
|
1024
1025
|
} = {}) {
|
|
1025
1026
|
const cleanId = validateRepoId(repoId);
|
|
1027
|
+
const safeProvider = String(providerFolder || 'Local').replace(/[<>:"/\\|?*]/g, '-');
|
|
1028
|
+
|
|
1029
|
+
// Если эта модель уже скачивается прямо сейчас — возвращаем активную задачу без дублирования
|
|
1030
|
+
for (const entry of _downloads.values()) {
|
|
1031
|
+
if (
|
|
1032
|
+
entry.job.status === 'downloading'
|
|
1033
|
+
&& entry.job.providerFolder === safeProvider
|
|
1034
|
+
&& (entry.job.repoId === cleanId || (targetNodeName && entry.job.folderName === targetNodeName))
|
|
1035
|
+
) {
|
|
1036
|
+
return { ...entry.job };
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1026
1040
|
const repoMeta = await inspectHuggingFaceRepo(cleanId, { revision, token, fetchImpl });
|
|
1027
1041
|
const selected = selectFilesToDownload(repoMeta, { files, quant });
|
|
1028
1042
|
if (!selected.length)
|
|
1029
1043
|
throw new Error(`В репозитории ${cleanId} не найдено подходящих файлов весов (.gguf / .safetensors)`);
|
|
1030
1044
|
|
|
1031
|
-
const safeProvider = String(providerFolder || 'Local').replace(/[<>:"/\\|?*]/g, '-');
|
|
1032
1045
|
const folderName = targetNodeName
|
|
1033
1046
|
? String(targetNodeName).replace(/[<>:"/\\|?*]/g, '-')
|
|
1034
1047
|
: safeModelFolderName(cleanId, quant && selected.some(f => f.kind === 'gguf') ? quant : '');
|
|
1035
1048
|
const modelDir = path.join(rootDir, 'MODELS', safeProvider, folderName);
|
|
1036
1049
|
const weightsDir = path.join(modelDir, '#weights');
|
|
1050
|
+
const stagingDir = path.join(rootDir, 'MODELS', safeProvider, '#downloads', folderName);
|
|
1037
1051
|
const primary = selected.find(f => f.name.endsWith('.gguf'))?.name
|
|
1038
1052
|
|| selected.find(f => f.name.endsWith('.safetensors') || f.name.endsWith('.hgn') || f.name.endsWith('.hnpw'))?.name
|
|
1039
1053
|
|| selected[0]?.name || '';
|
|
1040
1054
|
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
folderName,
|
|
1046
|
-
label: `${cleanId.split('/')[1] || cleanId}${quant && primary.endsWith('.gguf') ? ' (' + quant + ')' : ''}`,
|
|
1047
|
-
repoId: cleanId,
|
|
1048
|
-
modality: repoMeta.modality || 'llm',
|
|
1049
|
-
capabilities: repoMeta.capabilities || ['chat'],
|
|
1050
|
-
weightsDir,
|
|
1051
|
-
primaryFile: path.basename(primary),
|
|
1052
|
-
});
|
|
1053
|
-
}
|
|
1054
|
-
await fsp.mkdir(weightsDir, { recursive: true });
|
|
1055
|
+
const displayLabel = nodeMeta?.label
|
|
1056
|
+
|| `${cleanId.split('/')[1] || cleanId}${quant && primary.endsWith('.gguf') ? ' (' + quant + ')' : ''}`;
|
|
1057
|
+
|
|
1058
|
+
await fsp.mkdir(stagingDir, { recursive: true });
|
|
1055
1059
|
|
|
1056
1060
|
const jobId = 'hf_' + crypto.randomUUID().slice(0, 8);
|
|
1057
1061
|
const totalBytes = selected.reduce((acc, f) => acc + (Number(f.size) || 0), 0);
|
|
@@ -1060,8 +1064,9 @@ export async function startHuggingFaceDownload({
|
|
|
1060
1064
|
const job = {
|
|
1061
1065
|
id: jobId,
|
|
1062
1066
|
repoId: cleanId,
|
|
1063
|
-
|
|
1064
|
-
|
|
1067
|
+
label: displayLabel,
|
|
1068
|
+
modality: nodeMeta?.modality || repoMeta.modality || 'llm',
|
|
1069
|
+
capabilities: nodeMeta?.capabilities || repoMeta.capabilities || ['chat'],
|
|
1065
1070
|
revision: String(revision || 'main'),
|
|
1066
1071
|
providerFolder: safeProvider,
|
|
1067
1072
|
folderName,
|
|
@@ -1087,8 +1092,8 @@ export async function startHuggingFaceDownload({
|
|
|
1087
1092
|
if (controller.signal.aborted)
|
|
1088
1093
|
throw new Error('Загрузка отменена пользователем');
|
|
1089
1094
|
job.currentFile = fileEntry.name;
|
|
1090
|
-
const
|
|
1091
|
-
const partFile =
|
|
1095
|
+
const stagedFile = path.join(stagingDir, path.basename(fileEntry.name));
|
|
1096
|
+
const partFile = stagedFile + '.part';
|
|
1092
1097
|
|
|
1093
1098
|
let existingSize = 0;
|
|
1094
1099
|
try {
|
|
@@ -1144,10 +1149,25 @@ export async function startHuggingFaceDownload({
|
|
|
1144
1149
|
});
|
|
1145
1150
|
}
|
|
1146
1151
|
|
|
1147
|
-
await fsp.rename(partFile,
|
|
1152
|
+
await fsp.rename(partFile, stagedFile);
|
|
1148
1153
|
fileEntry.done = true;
|
|
1149
1154
|
}
|
|
1150
1155
|
|
|
1156
|
+
// Переносим готовые файлы из скрытой папки #downloads в целевую папку модели #weights
|
|
1157
|
+
await fsp.mkdir(weightsDir, { recursive: true });
|
|
1158
|
+
for (const fileEntry of job.files) {
|
|
1159
|
+
const stagedFile = path.join(stagingDir, path.basename(fileEntry.name));
|
|
1160
|
+
const destFile = path.join(weightsDir, path.basename(fileEntry.name));
|
|
1161
|
+
try {
|
|
1162
|
+
await fsp.rename(stagedFile, destFile);
|
|
1163
|
+
}
|
|
1164
|
+
catch {
|
|
1165
|
+
await fsp.copyFile(stagedFile, destFile);
|
|
1166
|
+
await fsp.unlink(stagedFile).catch(() => {});
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
await fsp.rm(stagingDir, { recursive: true, force: true }).catch(() => {});
|
|
1170
|
+
|
|
1151
1171
|
const manifestFile = path.join(weightsDir, 'hf-manifest.json');
|
|
1152
1172
|
await fsp.writeFile(manifestFile, JSON.stringify({
|
|
1153
1173
|
repoId: cleanId,
|
|
@@ -1158,6 +1178,27 @@ export async function startHuggingFaceDownload({
|
|
|
1158
1178
|
files: job.files,
|
|
1159
1179
|
}, null, 2), 'utf-8');
|
|
1160
1180
|
|
|
1181
|
+
// Регистрируем узел $ai/class.js только после полного завершения скачивания весов
|
|
1182
|
+
if (registerInWork && safeProvider === 'Local') {
|
|
1183
|
+
await registerLocalModelNode({
|
|
1184
|
+
rootDir,
|
|
1185
|
+
folderName,
|
|
1186
|
+
label: displayLabel,
|
|
1187
|
+
repoId: cleanId,
|
|
1188
|
+
model: nodeMeta?.model || '',
|
|
1189
|
+
protocol: nodeMeta?.protocol || '',
|
|
1190
|
+
icon: nodeMeta?.icon || '',
|
|
1191
|
+
modality: job.modality,
|
|
1192
|
+
capabilities: job.capabilities,
|
|
1193
|
+
efforts: nodeMeta?.efforts || null,
|
|
1194
|
+
maxTokens: nodeMeta?.maxTokens,
|
|
1195
|
+
maxOutput: nodeMeta?.maxOutput,
|
|
1196
|
+
baseUrl: nodeMeta?.baseUrl,
|
|
1197
|
+
weightsDir,
|
|
1198
|
+
primaryFile: path.basename(primary),
|
|
1199
|
+
});
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1161
1202
|
job.progress = 100;
|
|
1162
1203
|
job.status = 'completed';
|
|
1163
1204
|
job.finishedAt = Date.now();
|
|
@@ -1173,20 +1214,8 @@ export async function startHuggingFaceDownload({
|
|
|
1173
1214
|
job.status = controller.signal.aborted ? 'cancelled' : 'failed';
|
|
1174
1215
|
job.error = String(err?.message || err);
|
|
1175
1216
|
job.finishedAt = Date.now();
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
if (!hasWeights) {
|
|
1179
|
-
if (safeProvider === 'Local') {
|
|
1180
|
-
await fsp.rm(modelDir, { recursive: true, force: true }).catch(() => {});
|
|
1181
|
-
}
|
|
1182
|
-
else {
|
|
1183
|
-
await fsp.rm(weightsDir, { recursive: true, force: true }).catch(() => {});
|
|
1184
|
-
}
|
|
1185
|
-
try {
|
|
1186
|
-
const localNode = await globalThis.WORK?.get_item?.(`/MODELS/${safeProvider}`);
|
|
1187
|
-
localNode?.reset?.();
|
|
1188
|
-
}
|
|
1189
|
-
catch { /* ignore */ }
|
|
1217
|
+
if (controller.signal.aborted) {
|
|
1218
|
+
await fsp.rm(stagingDir, { recursive: true, force: true }).catch(() => {});
|
|
1190
1219
|
}
|
|
1191
1220
|
}
|
|
1192
1221
|
})();
|
|
@@ -7,7 +7,7 @@ import fsp from 'node:fs/promises';
|
|
|
7
7
|
import path from 'node:path';
|
|
8
8
|
import crypto from 'node:crypto';
|
|
9
9
|
import { spawn } from 'node:child_process';
|
|
10
|
-
import { registerLocalModelNode, estimateModelMemoryFromId } from './huggingface.js';
|
|
10
|
+
import { registerLocalModelNode, estimateModelMemoryFromId, listHuggingFaceDownloads } from './huggingface.js';
|
|
11
11
|
import { verifyCompletion } from './dataset.js';
|
|
12
12
|
|
|
13
13
|
const _jobs = new Map();
|
|
@@ -201,11 +201,39 @@ export async function detectHardware({ force = false } = {}) {
|
|
|
201
201
|
*/
|
|
202
202
|
export async function listLocalModelsAndAdapters(rootDir = process.cwd()) {
|
|
203
203
|
const localRoot = path.join(rootDir, 'MODELS', 'Local');
|
|
204
|
+
const legacyHalogenRoot = path.join(rootDir, 'MODELS', 'Halogen');
|
|
205
|
+
|
|
206
|
+
// Автоматическая миграция и очистка устаревшей дублирующей папки MODELS/Halogen
|
|
207
|
+
if (fs.existsSync(legacyHalogenRoot)) {
|
|
208
|
+
try {
|
|
209
|
+
const halEntries = await fsp.readdir(legacyHalogenRoot, { withFileTypes: true }).catch(() => []);
|
|
210
|
+
for (const he of halEntries) {
|
|
211
|
+
if (!he.isDirectory() || he.name.startsWith('$') || he.name.startsWith('#'))
|
|
212
|
+
continue;
|
|
213
|
+
const oldWeights = path.join(legacyHalogenRoot, he.name, '#weights');
|
|
214
|
+
if (fs.existsSync(oldWeights)) {
|
|
215
|
+
const wf = await fsp.readdir(oldWeights).catch(() => []);
|
|
216
|
+
const hasRealWeight = wf.some(f => !f.endsWith('.part') && /\.(gguf|safetensors|hgn|hnpw|bin|onnx|pt|pth)$/i.test(f));
|
|
217
|
+
if (hasRealWeight) {
|
|
218
|
+
const targetModelDir = path.join(localRoot, he.name);
|
|
219
|
+
if (!fs.existsSync(targetModelDir)) {
|
|
220
|
+
await fsp.mkdir(localRoot, { recursive: true });
|
|
221
|
+
await fsp.cp(path.join(legacyHalogenRoot, he.name), targetModelDir, { recursive: true });
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
await fsp.rm(legacyHalogenRoot, { recursive: true, force: true });
|
|
227
|
+
}
|
|
228
|
+
catch { /* ignore */ }
|
|
229
|
+
}
|
|
230
|
+
|
|
204
231
|
const models = [];
|
|
205
232
|
const adapters = [];
|
|
206
233
|
if (!fs.existsSync(localRoot))
|
|
207
234
|
return { models, adapters };
|
|
208
235
|
|
|
236
|
+
const activeDownloads = listHuggingFaceDownloads().filter(d => d.status === 'downloading');
|
|
209
237
|
const entries = await fsp.readdir(localRoot, { withFileTypes: true });
|
|
210
238
|
for (const e of entries) {
|
|
211
239
|
if (!e.isDirectory() || e.name.startsWith('$'))
|
|
@@ -227,13 +255,19 @@ export async function listLocalModelsAndAdapters(rootDir = process.cwd()) {
|
|
|
227
255
|
}
|
|
228
256
|
if (e.name.startsWith('#'))
|
|
229
257
|
continue;
|
|
258
|
+
|
|
259
|
+
const isDownloading = activeDownloads.some(
|
|
260
|
+
d => d.folderName === e.name || d.modelPath === `/MODELS/Local/${e.name}`
|
|
261
|
+
);
|
|
230
262
|
const aiClassFile = path.join(localRoot, e.name, '$ai', 'class.js');
|
|
231
263
|
const weightsDir = path.join(localRoot, e.name, '#weights');
|
|
232
264
|
let weightFiles = [];
|
|
265
|
+
let hasRealWeightBinary = false;
|
|
233
266
|
let sizeBytes = 0;
|
|
234
267
|
if (fs.existsSync(weightsDir)) {
|
|
235
268
|
const wf = await fsp.readdir(weightsDir).catch(() => []);
|
|
236
269
|
weightFiles = wf.filter(f => !f.endsWith('.part') && f !== 'hf-manifest.json');
|
|
270
|
+
hasRealWeightBinary = weightFiles.some(f => /\.(gguf|safetensors|hgn|hnpw|bin|onnx|pt|pth)$/i.test(f));
|
|
237
271
|
for (const f of weightFiles) {
|
|
238
272
|
try {
|
|
239
273
|
const st = await fsp.stat(path.join(weightsDir, f));
|
|
@@ -251,9 +285,25 @@ export async function listLocalModelsAndAdapters(rootDir = process.cwd()) {
|
|
|
251
285
|
}
|
|
252
286
|
catch { /* non-json class.js */ }
|
|
253
287
|
}
|
|
254
|
-
|
|
288
|
+
|
|
289
|
+
const isAdapterNode = Boolean(meta.adapterPath);
|
|
290
|
+
|
|
291
|
+
// Если папка модели была создана преждевременно прежней версией без скачанных весов и сейчас не качается — убираем пустой дубль
|
|
292
|
+
if (!isDownloading && !hasRealWeightBinary && !isAdapterNode) {
|
|
293
|
+
try {
|
|
294
|
+
await fsp.rm(path.join(localRoot, e.name), { recursive: true, force: true });
|
|
295
|
+
}
|
|
296
|
+
catch { /* ignore */ }
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Пока модель ещё скачивается, она отображается только в блоке «Идёт установка», а не в «Установленных моделях»
|
|
301
|
+
if (isDownloading && !hasRealWeightBinary && !isAdapterNode) {
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (hasRealWeightBinary || isAdapterNode) {
|
|
255
306
|
const enabled = meta.enabled !== false;
|
|
256
|
-
const hasWeights = weightFiles.length > 0;
|
|
257
307
|
models.push({
|
|
258
308
|
id: e.name,
|
|
259
309
|
label: meta.label || e.name,
|
|
@@ -263,7 +313,7 @@ export async function listLocalModelsAndAdapters(rootDir = process.cwd()) {
|
|
|
263
313
|
capabilities: Array.isArray(meta.capabilities) ? meta.capabilities : ['chat', 'stream'],
|
|
264
314
|
maxTokens: meta.maxTokens || 16384,
|
|
265
315
|
enabled,
|
|
266
|
-
active: enabled &&
|
|
316
|
+
active: enabled && (hasRealWeightBinary || isAdapterNode),
|
|
267
317
|
path: `/MODELS/Local/${e.name}`,
|
|
268
318
|
hasClass: fs.existsSync(aiClassFile),
|
|
269
319
|
weightFiles,
|