odant-work 1.0.27 → 1.0.29
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 +18 -17
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/file.js +60 -74
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/readme.md +3 -3
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/dock.js +65 -82
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/docs.js +0 -20
- package/package.json +1 -1
- package/sources/data/progress.md +9 -0
- package/sources/host/process-guard.js +116 -0
- package/sources/modules/agent/index.js +1 -1
- package/sources/modules/agent/tools/docs.js +1 -1
- package/sources/modules/agent/tools/meta.js +5 -1
- package/sources/modules/agent/tools/work/fs.js +1 -1
- package/sources/modules/trainer/downloader.js +104 -25
- package/sources/modules/trainer/huggingface.js +66 -3
- package/sources/modules/trainer/index.js +2 -0
- package/sources/work.js +16 -0
|
@@ -336,6 +336,43 @@ export function saveTrainerNetworkSettings(patch = {}, rootDir = process.cwd())
|
|
|
336
336
|
|
|
337
337
|
// ── Прокси-транспорт (HTTP CONNECT + SOCKS5/SOCKS5h без внешних пакетов) ────
|
|
338
338
|
|
|
339
|
+
const NOOP = () => {};
|
|
340
|
+
const _guardedBodies = new WeakSet();
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Повесить страхующий обработчик `'error'` на поток тела ответа (`Readable` или
|
|
344
|
+
* web `ReadableStream`), чтобы фоновый обрыв соединения (например `UND_ERR_RES_CONTENT_LENGTH_MISMATCH`)
|
|
345
|
+
* никогда не превращался в неперехваченный `uncaughtException` EventEmitter'а.
|
|
346
|
+
*/
|
|
347
|
+
export function guardBody(body) {
|
|
348
|
+
if (!body || typeof body !== 'object')
|
|
349
|
+
return body;
|
|
350
|
+
if (_guardedBodies.has(body))
|
|
351
|
+
return body;
|
|
352
|
+
_guardedBodies.add(body);
|
|
353
|
+
try { body.on?.('error', NOOP); } catch { /* ignore */ }
|
|
354
|
+
try { body.addEventListener?.('error', NOOP); } catch { /* ignore */ }
|
|
355
|
+
return body;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Безопасно закрыть и отменить неиспользованное/прерванное тело ответа,
|
|
360
|
+
* гарантированно подавляя асинхронные отказы `cancel()`/`return()` на уже упавшем потоке.
|
|
361
|
+
*/
|
|
362
|
+
export async function discardBody(res) {
|
|
363
|
+
const body = res?.body ?? res;
|
|
364
|
+
if (!body || typeof body !== 'object')
|
|
365
|
+
return;
|
|
366
|
+
guardBody(body);
|
|
367
|
+
try {
|
|
368
|
+
const p = body.cancel?.();
|
|
369
|
+
if (p && typeof p.then === 'function')
|
|
370
|
+
await p.catch(NOOP);
|
|
371
|
+
}
|
|
372
|
+
catch { /* ignore */ }
|
|
373
|
+
try { body.destroy?.(); } catch { /* ignore */ }
|
|
374
|
+
}
|
|
375
|
+
|
|
339
376
|
function makeAbortError(msg = 'Запрос отменён') {
|
|
340
377
|
const err = new Error(msg);
|
|
341
378
|
err.name = 'AbortError';
|
|
@@ -390,15 +427,17 @@ async function fetchWithIdleTimeout(netFetch, url, options = {}, idleTimeoutMs =
|
|
|
390
427
|
* Чтение тела ответа с таймаутом простоя: если очередной чанк не пришёл за
|
|
391
428
|
* `idleTimeoutMs`, чтение прерывается ошибкой `makeStallError`.
|
|
392
429
|
*/
|
|
393
|
-
function makeIdleChunkReader(body, idleTimeoutMs = DEFAULT_IDLE_TIMEOUT_MS) {
|
|
430
|
+
export function makeIdleChunkReader(body, idleTimeoutMs = DEFAULT_IDLE_TIMEOUT_MS) {
|
|
431
|
+
guardBody(body);
|
|
394
432
|
const iterator = body[Symbol.asyncIterator]();
|
|
433
|
+
let closed = false;
|
|
395
434
|
const next = async () => {
|
|
396
435
|
let timer = null;
|
|
397
436
|
const timeoutPromise = new Promise((_, reject) => {
|
|
398
437
|
timer = setTimeout(() => reject(makeStallError(idleTimeoutMs)), idleTimeoutMs);
|
|
399
438
|
});
|
|
400
439
|
const chunkPromise = iterator.next();
|
|
401
|
-
chunkPromise.catch(
|
|
440
|
+
chunkPromise.catch(NOOP);
|
|
402
441
|
try {
|
|
403
442
|
return await Promise.race([chunkPromise, timeoutPromise]);
|
|
404
443
|
}
|
|
@@ -408,8 +447,25 @@ function makeIdleChunkReader(body, idleTimeoutMs = DEFAULT_IDLE_TIMEOUT_MS) {
|
|
|
408
447
|
}
|
|
409
448
|
};
|
|
410
449
|
const close = () => {
|
|
411
|
-
|
|
412
|
-
|
|
450
|
+
if (closed)
|
|
451
|
+
return;
|
|
452
|
+
closed = true;
|
|
453
|
+
// На уже упавшем потоке iterator.return() и body.cancel() возвращают отклонённый
|
|
454
|
+
// промис (например TypeError: terminated) — обязаны гасить их через .catch(),
|
|
455
|
+
// иначе Node завершает процесс по unhandledRejection.
|
|
456
|
+
try {
|
|
457
|
+
const ret = iterator.return?.();
|
|
458
|
+
if (ret && typeof ret.then === 'function')
|
|
459
|
+
ret.catch(NOOP);
|
|
460
|
+
}
|
|
461
|
+
catch { /* ignore */ }
|
|
462
|
+
try {
|
|
463
|
+
const can = body.cancel?.();
|
|
464
|
+
if (can && typeof can.then === 'function')
|
|
465
|
+
can.catch(NOOP);
|
|
466
|
+
}
|
|
467
|
+
catch { /* ignore */ }
|
|
468
|
+
try { body.destroy?.(); } catch { /* ignore */ }
|
|
413
469
|
};
|
|
414
470
|
return { next, close };
|
|
415
471
|
}
|
|
@@ -833,6 +889,7 @@ function wrapNodeResponse(res, url, signal) {
|
|
|
833
889
|
signal.addEventListener('abort', cancelBody, { once: true });
|
|
834
890
|
res.body = res;
|
|
835
891
|
res.cancel = cancelBody;
|
|
892
|
+
guardBody(res);
|
|
836
893
|
|
|
837
894
|
const readAll = async () => {
|
|
838
895
|
const chunks = [];
|
|
@@ -884,6 +941,8 @@ export function createNetworkFetch({
|
|
|
884
941
|
? await singleProxiedRequest(currentUrl, { ...options, method, headers: currentHeaders, signal }, proxyParsed)
|
|
885
942
|
: await fetchImpl(currentUrl, { ...options, method, headers: currentHeaders, redirect: 'manual' });
|
|
886
943
|
|
|
944
|
+
guardBody(res?.body);
|
|
945
|
+
|
|
887
946
|
if (![301, 302, 303, 307, 308].includes(res?.status))
|
|
888
947
|
return res;
|
|
889
948
|
|
|
@@ -892,8 +951,7 @@ export function createNetworkFetch({
|
|
|
892
951
|
return res;
|
|
893
952
|
|
|
894
953
|
// Закрываем тело редирект-ответа, чтобы не текли сокеты
|
|
895
|
-
|
|
896
|
-
try { res.body?.destroy?.(); } catch { /* ignore */ }
|
|
954
|
+
await discardBody(res);
|
|
897
955
|
|
|
898
956
|
const prevOrigin = new URL(currentUrl).origin;
|
|
899
957
|
const nextUrl = new URL(loc, currentUrl).toString();
|
|
@@ -1132,8 +1190,10 @@ export async function downloadFileMultipart({
|
|
|
1132
1190
|
try {
|
|
1133
1191
|
const reqHeaders = { ...headers, Range: `bytes=${probeRange.start}-${probeRange.end - 1}` };
|
|
1134
1192
|
probeRes = await netFetch(url, { headers: reqHeaders, signal });
|
|
1193
|
+
guardBody(probeRes?.body);
|
|
1135
1194
|
|
|
1136
1195
|
if (probeRes.status === 416) {
|
|
1196
|
+
await discardBody(probeRes);
|
|
1137
1197
|
if (totalSize > 0 && sumRangesBytes(completed) >= totalSize) {
|
|
1138
1198
|
await fsp.rename(partFile, stagedFile);
|
|
1139
1199
|
return { size: totalSize, ranges: [[0, totalSize]], rangeSupported: true, multipart: true };
|
|
@@ -1148,6 +1208,7 @@ export async function downloadFileMultipart({
|
|
|
1148
1208
|
throw e416;
|
|
1149
1209
|
}
|
|
1150
1210
|
if (!probeRes.ok && probeRes.status !== 206) {
|
|
1211
|
+
await discardBody(probeRes);
|
|
1151
1212
|
const errHttp = new Error(`Ошибка загрузки ${path.basename(stagedFile)}: HTTP ${probeRes.status}`);
|
|
1152
1213
|
errHttp.httpStatus = probeRes.status;
|
|
1153
1214
|
throw errHttp;
|
|
@@ -1193,8 +1254,7 @@ export async function downloadFileMultipart({
|
|
|
1193
1254
|
totalSize = cr.total;
|
|
1194
1255
|
if (!totalSize) {
|
|
1195
1256
|
// Неизвестный totalSize с 206 — безопасно докачать в 1 поток
|
|
1196
|
-
|
|
1197
|
-
try { probeRes.body?.destroy?.(); } catch { /* ignore */ }
|
|
1257
|
+
await discardBody(probeRes);
|
|
1198
1258
|
return downloadSingleStream({
|
|
1199
1259
|
url,
|
|
1200
1260
|
stagedFile,
|
|
@@ -1285,9 +1345,8 @@ export async function downloadFileMultipart({
|
|
|
1285
1345
|
break;
|
|
1286
1346
|
}
|
|
1287
1347
|
}
|
|
1288
|
-
|
|
1348
|
+
finally {
|
|
1289
1349
|
reader.close();
|
|
1290
|
-
throw err;
|
|
1291
1350
|
}
|
|
1292
1351
|
}
|
|
1293
1352
|
activeCursors.delete(workerId);
|
|
@@ -1303,10 +1362,20 @@ export async function downloadFileMultipart({
|
|
|
1303
1362
|
let pendingRes = initialRes;
|
|
1304
1363
|
|
|
1305
1364
|
while (cur < end) {
|
|
1306
|
-
if (signal?.aborted)
|
|
1365
|
+
if (signal?.aborted) {
|
|
1366
|
+
if (pendingRes) {
|
|
1367
|
+
await discardBody(pendingRes);
|
|
1368
|
+
pendingRes = null;
|
|
1369
|
+
}
|
|
1307
1370
|
throw makeAbortError('Загрузка приостановлена пользователем');
|
|
1308
|
-
|
|
1371
|
+
}
|
|
1372
|
+
if (firstFatalErr) {
|
|
1373
|
+
if (pendingRes) {
|
|
1374
|
+
await discardBody(pendingRes);
|
|
1375
|
+
pendingRes = null;
|
|
1376
|
+
}
|
|
1309
1377
|
return;
|
|
1378
|
+
}
|
|
1310
1379
|
|
|
1311
1380
|
try {
|
|
1312
1381
|
const res = pendingRes || await netFetch(url, {
|
|
@@ -1314,22 +1383,21 @@ export async function downloadFileMultipart({
|
|
|
1314
1383
|
signal,
|
|
1315
1384
|
});
|
|
1316
1385
|
pendingRes = null;
|
|
1386
|
+
guardBody(res?.body);
|
|
1317
1387
|
|
|
1318
1388
|
if (res.status === 429) {
|
|
1319
1389
|
const err429 = new Error(`Слишком много запросов (HTTP 429), уменьшаем потоки`);
|
|
1320
1390
|
err429.httpStatus = 429;
|
|
1321
1391
|
err429.retryable = true;
|
|
1322
1392
|
concurrencyLimit = Math.max(1, Math.floor(concurrencyLimit / 2));
|
|
1323
|
-
|
|
1324
|
-
try { res.body?.destroy?.(); } catch { /* ignore */ }
|
|
1393
|
+
await discardBody(res);
|
|
1325
1394
|
throw err429;
|
|
1326
1395
|
}
|
|
1327
1396
|
|
|
1328
1397
|
if (res.status !== 206 && res.status !== 200) {
|
|
1329
1398
|
const errHttp = new Error(`Ошибка сегмента ${path.basename(stagedFile)}: HTTP ${res.status}`);
|
|
1330
1399
|
errHttp.httpStatus = res.status;
|
|
1331
|
-
|
|
1332
|
-
try { res.body?.destroy?.(); } catch { /* ignore */ }
|
|
1400
|
+
await discardBody(res);
|
|
1333
1401
|
throw errHttp;
|
|
1334
1402
|
}
|
|
1335
1403
|
|
|
@@ -1448,7 +1516,9 @@ async function downloadSingleStream({
|
|
|
1448
1516
|
reqHeaders.Range = `bytes=${curSize}-`;
|
|
1449
1517
|
|
|
1450
1518
|
const res = await netFetch(url, { headers: reqHeaders, signal });
|
|
1519
|
+
guardBody(res?.body);
|
|
1451
1520
|
if (res.status === 416) {
|
|
1521
|
+
await discardBody(res);
|
|
1452
1522
|
if (curSize > 0 && (!totalSize || curSize >= totalSize)) {
|
|
1453
1523
|
await fsp.rename(partFile, stagedFile);
|
|
1454
1524
|
const sz = totalSize || curSize;
|
|
@@ -1463,6 +1533,7 @@ async function downloadSingleStream({
|
|
|
1463
1533
|
throw e416;
|
|
1464
1534
|
}
|
|
1465
1535
|
if (!res.ok && res.status !== 206) {
|
|
1536
|
+
await discardBody(res);
|
|
1466
1537
|
const errHttp = new Error(`Ошибка загрузки ${path.basename(stagedFile)}: HTTP ${res.status}`);
|
|
1467
1538
|
errHttp.httpStatus = res.status;
|
|
1468
1539
|
throw errHttp;
|
|
@@ -1563,9 +1634,8 @@ async function consumeSingleResponseToFile({
|
|
|
1563
1634
|
emit(buf.length);
|
|
1564
1635
|
}
|
|
1565
1636
|
}
|
|
1566
|
-
|
|
1637
|
+
finally {
|
|
1567
1638
|
reader.close();
|
|
1568
|
-
throw readErr;
|
|
1569
1639
|
}
|
|
1570
1640
|
await new Promise((resolve, reject) => {
|
|
1571
1641
|
out.end();
|
|
@@ -1670,6 +1740,9 @@ export async function probeTrainerNetwork({
|
|
|
1670
1740
|
discoveredRepo = probeRepoId;
|
|
1671
1741
|
}
|
|
1672
1742
|
}
|
|
1743
|
+
else {
|
|
1744
|
+
await discardBody(apiRes);
|
|
1745
|
+
}
|
|
1673
1746
|
}
|
|
1674
1747
|
catch { /* для кастомного зеркала без /api/models попробуем прямую пробу файла */ }
|
|
1675
1748
|
|
|
@@ -1684,6 +1757,7 @@ export async function probeTrainerNetwork({
|
|
|
1684
1757
|
const tDl0 = Date.now();
|
|
1685
1758
|
const res = await netFetch(fileUrl, { headers: dlHeaders, signal: controller.signal });
|
|
1686
1759
|
if (!res.ok && res.status !== 206) {
|
|
1760
|
+
await discardBody(res);
|
|
1687
1761
|
throw new Error(`Источник вернул HTTP ${res.status}${apiStatus ? ` (API: ${apiStatus})` : ''}`);
|
|
1688
1762
|
}
|
|
1689
1763
|
|
|
@@ -1691,15 +1765,20 @@ export async function probeTrainerNetwork({
|
|
|
1691
1765
|
let bytes = 0;
|
|
1692
1766
|
const limitBytes = Math.max(65536, Number(probeBytes) || 2 * 1024 * 1024);
|
|
1693
1767
|
if (res.body) {
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1768
|
+
guardBody(res.body);
|
|
1769
|
+
try {
|
|
1770
|
+
for await (const raw of res.body) {
|
|
1771
|
+
const buf = Buffer.isBuffer(raw) ? raw : Buffer.from(raw);
|
|
1772
|
+
bytes += buf.length;
|
|
1773
|
+
if (bytes >= limitBytes) {
|
|
1774
|
+
await discardBody(res);
|
|
1775
|
+
break;
|
|
1776
|
+
}
|
|
1701
1777
|
}
|
|
1702
1778
|
}
|
|
1779
|
+
finally {
|
|
1780
|
+
await discardBody(res);
|
|
1781
|
+
}
|
|
1703
1782
|
}
|
|
1704
1783
|
else if (typeof res.arrayBuffer === 'function') {
|
|
1705
1784
|
bytes = (await res.arrayBuffer()).byteLength;
|
|
@@ -1051,11 +1051,18 @@ function isRetryableDownloadError(err) {
|
|
|
1051
1051
|
return true;
|
|
1052
1052
|
if (err.httpStatus && err.httpStatus >= 400 && err.httpStatus < 500)
|
|
1053
1053
|
return false;
|
|
1054
|
-
const msg =
|
|
1054
|
+
const msg = [
|
|
1055
|
+
err?.message,
|
|
1056
|
+
err?.code,
|
|
1057
|
+
err?.name,
|
|
1058
|
+
err?.cause?.message,
|
|
1059
|
+
err?.cause?.code,
|
|
1060
|
+
err?.cause?.name,
|
|
1061
|
+
].filter(Boolean).join(' ') || String(err);
|
|
1055
1062
|
if (/Unexpected URL|Некорректн|отменена/i.test(msg))
|
|
1056
1063
|
return false;
|
|
1057
1064
|
return err.retryable === true
|
|
1058
|
-
|| /ECONNRESET|ETIMEDOUT|EPIPE|EAI_AGAIN|ENOTFOUND|network|fetch failed|terminated|aborted|socket|premature/i.test(msg);
|
|
1065
|
+
|| /ECONNRESET|ETIMEDOUT|EPIPE|EAI_AGAIN|ENOTFOUND|UND_ERR_|ERR_HTTP2_|ResponseContentLengthMismatch|content[- ]length|length does not match|network|fetch failed|terminated|aborted|socket|premature/i.test(msg);
|
|
1059
1066
|
}
|
|
1060
1067
|
|
|
1061
1068
|
async function writeDownloadStateSafe(stagingDir, job, extra = {}) {
|
|
@@ -1787,9 +1794,13 @@ export async function resumeHuggingFaceDownload({
|
|
|
1787
1794
|
if (!resolvedRepo)
|
|
1788
1795
|
throw new Error(`Не удалось определить репозиторий Hugging Face для докачки «${cleanFolder || key}»`);
|
|
1789
1796
|
|
|
1797
|
+
const stateFileNames = Array.isArray(state.files) && state.files.length
|
|
1798
|
+
? state.files.map(f => f?.name).filter(Boolean)
|
|
1799
|
+
: null;
|
|
1800
|
+
|
|
1790
1801
|
return startHuggingFaceDownload({
|
|
1791
1802
|
repoId: resolvedRepo,
|
|
1792
|
-
files: files ?? entry?.files ?? null,
|
|
1803
|
+
files: files ?? entry?.files ?? stateFileNames ?? null,
|
|
1793
1804
|
quant: quant || entry?.quant || 'Q8_0',
|
|
1794
1805
|
revision: entry?.job?.revision || state.revision || 'main',
|
|
1795
1806
|
token,
|
|
@@ -1838,6 +1849,58 @@ export async function restartActiveHuggingFaceDownloads({ rootDir = '' } = {}) {
|
|
|
1838
1849
|
return restarted;
|
|
1839
1850
|
}
|
|
1840
1851
|
|
|
1852
|
+
/**
|
|
1853
|
+
* На старте сервера автоматически подхватить загрузки, которые находились в статусе
|
|
1854
|
+
* `downloading` на момент аварийного завершения предыдущего процесса.
|
|
1855
|
+
* Паузы, поставленные пользователем (`paused`), не трогает.
|
|
1856
|
+
*/
|
|
1857
|
+
export async function resumeInterruptedDownloads({
|
|
1858
|
+
rootDir = process.cwd(),
|
|
1859
|
+
fetchImpl = globalThis.fetch,
|
|
1860
|
+
} = {}) {
|
|
1861
|
+
migrateLocalModelsLayoutSync(rootDir);
|
|
1862
|
+
const localRoot = localRootDir(rootDir);
|
|
1863
|
+
if (!fs.existsSync(localRoot))
|
|
1864
|
+
return [];
|
|
1865
|
+
|
|
1866
|
+
const resumed = [];
|
|
1867
|
+
let entries = [];
|
|
1868
|
+
try {
|
|
1869
|
+
entries = fs.readdirSync(localRoot, { withFileTypes: true });
|
|
1870
|
+
}
|
|
1871
|
+
catch {
|
|
1872
|
+
return [];
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
for (const e of entries) {
|
|
1876
|
+
if (!e.isDirectory() || e.name.startsWith('$') || e.name.startsWith('#') || e.name === 'models')
|
|
1877
|
+
continue;
|
|
1878
|
+
const weightsDir = getModelWeightsDir(rootDir, e.name, 'Local');
|
|
1879
|
+
const stateFile = path.join(weightsDir, DOWNLOAD_STATE_FILE);
|
|
1880
|
+
if (!fs.existsSync(stateFile))
|
|
1881
|
+
continue;
|
|
1882
|
+
let state = null;
|
|
1883
|
+
try {
|
|
1884
|
+
state = JSON.parse(fs.readFileSync(stateFile, 'utf-8'));
|
|
1885
|
+
}
|
|
1886
|
+
catch { continue; }
|
|
1887
|
+
if (state?.status !== 'downloading' || !state?.repoId)
|
|
1888
|
+
continue;
|
|
1889
|
+
try {
|
|
1890
|
+
const job = await resumeHuggingFaceDownload({
|
|
1891
|
+
folderName: e.name,
|
|
1892
|
+
rootDir,
|
|
1893
|
+
fetchImpl,
|
|
1894
|
+
});
|
|
1895
|
+
resumed.push(job);
|
|
1896
|
+
}
|
|
1897
|
+
catch (err) {
|
|
1898
|
+
console.warn(`[trainer] не удалось авто-возобновить загрузку «${e.name}»:`, err?.message || err);
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
return resumed;
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1841
1904
|
export function cancelHuggingFaceDownload(jobId, { keepFiles = false } = {}) {
|
|
1842
1905
|
const entry = _downloads.get(String(jobId || ''));
|
|
1843
1906
|
if (!entry)
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
discardHuggingFaceDownload,
|
|
19
19
|
resumeHuggingFaceDownload,
|
|
20
20
|
restartActiveHuggingFaceDownloads,
|
|
21
|
+
resumeInterruptedDownloads,
|
|
21
22
|
cancelHuggingFaceDownload,
|
|
22
23
|
registerLocalModelNode,
|
|
23
24
|
} from './huggingface.js';
|
|
@@ -184,6 +185,7 @@ export {
|
|
|
184
185
|
discardHuggingFaceDownload,
|
|
185
186
|
resumeHuggingFaceDownload,
|
|
186
187
|
restartActiveHuggingFaceDownloads,
|
|
188
|
+
resumeInterruptedDownloads,
|
|
187
189
|
cancelHuggingFaceDownload,
|
|
188
190
|
registerLocalModelNode,
|
|
189
191
|
buildWorkDataset,
|
package/sources/work.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { installProcessGuards } from './host/process-guard.js';
|
|
2
|
+
if (!process.env.WORK_TEST)
|
|
3
|
+
installProcessGuards();
|
|
4
|
+
|
|
1
5
|
import './reactor.js';
|
|
2
6
|
globalThis.ODA ??= function (prototype) {};
|
|
3
7
|
import webPush from 'web-push';
|
|
@@ -31,6 +35,18 @@ if (process.env.WORK_RECOVER !== '0') {
|
|
|
31
35
|
recoverTasks().catch(e => console.warn('[agent recovery]', e.message));
|
|
32
36
|
}
|
|
33
37
|
|
|
38
|
+
// Загрузки моделей ИИ, оборванные внезапным падением/рестартом (status === 'downloading'), продолжаем с того же байта;
|
|
39
|
+
// паузы, поставленные пользователем, не трогаем. WORK_RESUME_DOWNLOADS=0 — отключить.
|
|
40
|
+
if (process.env.WORK_RESUME_DOWNLOADS !== '0' && !process.env.WORK_TEST) {
|
|
41
|
+
import('./modules/trainer/huggingface.js')
|
|
42
|
+
.then(m => m.resumeInterruptedDownloads())
|
|
43
|
+
.then(list => {
|
|
44
|
+
if (Array.isArray(list) && list.length)
|
|
45
|
+
console.log('[trainer] авто-возобновлены прерванные загрузки:', list.map(j => j.folderName).join(', '));
|
|
46
|
+
})
|
|
47
|
+
.catch(e => console.warn('[trainer resume]', e?.message || e));
|
|
48
|
+
}
|
|
49
|
+
|
|
34
50
|
// прогрев дерева классов в фоне: первый вход не платит холодную сборку; WORK_PREWARM=0 — выключить
|
|
35
51
|
if (process.env.WORK_PREWARM !== '0') {
|
|
36
52
|
import('./host/prewarm.js')
|