odant-work 1.0.33 → 1.0.35

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.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "packageName": "odant-work",
3
- "version": "1.0.33",
3
+ "version": "1.0.35",
4
4
  "createdAt": 1794658837090,
5
- "updatedAt": 1794899882362,
5
+ "updatedAt": 1794907579300,
6
6
  "files": {
7
7
  "run.mjs": "f8918c612e8641e9beee06221be6680aa6fd21f25468451f2ac857fd51772266",
8
- "package.json": "66825cd9230bfe15f6c063e76d52cefe3419c97d78d7a832892656bab4752a62",
9
- "package-lock.json": "7b20f4d32c36a3d87e0aa0449c40af406a6e213891f46eeb70f9f6f64966f479",
8
+ "package.json": "dac8b4b481c29599650e69de519bec3847970df19a6f85195808c6529cad74ca",
9
+ "package-lock.json": "5cd95b2c680d0fa888fe74d58707ec41edb1ecaad0ad2a1d9fbefd3aa776404a",
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": "85aa3d098a9e957e77c1ac9db0aafecb0d9b3deeb969997df333796d54302f39",
29
+ "sources/data/progress.md": "1c976cec3c1ebf924bed4c5eccb32e39c54366c74637c8a9e4614320fb55ce89",
30
30
  "sources/data/readme.md": "593fa2ae07aa91bc26d7542275da6953a9cd419240a9a49e00cb62fb9d5d8e36",
31
31
  "sources/data/reports.js": "0330f404860fe2589a7d46a2f0fe690ca23249bd841a062a26718742d4fd11d6",
32
32
  "sources/data/schema.js": "1c994f9adb76c156dc86601dd6b1046376b66549b041e1a58aa1727b5476bdbe",
@@ -176,7 +176,7 @@
176
176
  "sources/modules/sandbox/vnc-proxy.js": "1c75c2b24d579f254de1c4727621fbbcc7e8a10360f638f4cf1c4bd91184d103",
177
177
  "sources/modules/trainer/dataset.js": "e631e1feda2958cf93436cb48a331958d7b029aa52bd42247865e87504b642f7",
178
178
  "sources/modules/trainer/downloader.js": "d9e96cb07e7bf64386558be8c2265c482af35a513f42954250add6d5fc87bdc4",
179
- "sources/modules/trainer/halogen.js": "d4e71304669ef55e02549bbd75c50eee5b9accdd53bd3f8431cfa377f7572d8f",
179
+ "sources/modules/trainer/halogen.js": "eddc61b4acf5494703d599e4dc5811ce27aa34d60abe24fddadc1755d460c9fe",
180
180
  "sources/modules/trainer/huggingface.js": "91878bb2975981e02dd21d2a587d7c345ef65cd2d7032c5769a63c9dba21f982",
181
181
  "sources/modules/trainer/index.js": "dd3c6336eb08410084d0826bf68afae55ab8ab39b2353c0a928ece75f28d4dea",
182
182
  "sources/modules/trainer/local-engine.js": "0aa161d9800be79534e8fcb8271c418a5e342d29244c95cd448e7df6d6b15458",
@@ -974,7 +974,7 @@
974
974
  "MODULES/Register/STRUCTS/Банковский счёт/$struct/class.js": "166ffafd1c7d1609b174ae7766e77842e6294c6902baabe787225a2eeb026cce",
975
975
  "MODULES/Register/STRUCTS/Единица измерения/$struct/class.js": "dd0982281ed782d23afd80d5985b79aa65c6acbe58dc080f943840ea798000b0",
976
976
  "MODULES/Register/STRUCTS/Паспорт/$struct/class.js": "4a50808e4db7741b0384a775177545d71686a680ccda7ef0ec68bf81f9c988b5",
977
- "MODELS/$ai/$folder/$class/$ai/class.js": "71067aebec993973ded4b445b6f18ddcb7adbdc1c91f355012effc48a0cf9b51",
977
+ "MODELS/$ai/$folder/$class/$ai/class.js": "d7622d2d138593a4f8a730f46158364eca73dc0c5f3adf6abd475d41e3556e6d",
978
978
  "MODELS/$ai/$folder/$class/$ai/handlers/pages/form/trainer/$handler/class.js": "fe5ba834156495c28a34acd4b70a6b6b3bdfccb67ec7bf99e92a292afbb66d19",
979
979
  "MODELS/$ai/$folder/$class/$ai/handlers/pages/form/trainer/$handler/trainer.js": "a7ad0ff60cb097fba075176dd89ab16992c469999818875ec1c5f79d0edb690a",
980
980
  "MODELS/$ai/$folder/$class/$ai/methods/chat/$method/class.js": "a5859e701c8ea25c627247e6e6ae5d32115ba2f027a5fedea62ed1c7df0110ac",
package/.secretsignore CHANGED
@@ -31,3 +31,4 @@ license-server/src/server.js
31
31
 
32
32
  # Экспортированный дамп сессии OpenCode для переноса между рабочими станциями
33
33
  current_session.json
34
+ opencode_session.json
@@ -225,6 +225,9 @@ export default {
225
225
  headers['X-Halogen-Guard'] = typeof options.halogenGuard === 'string' ? options.halogenGuard : 'watch';
226
226
  const url = new URL(isAnthropic ? anthropicUrl(ai.baseUrl) : ai.baseUrl);
227
227
  const transport = transportFor(url);
228
+ // Явный Content-Length (без Transfer-Encoding: chunked) — нативные локальные серверы вроде bubo.exe отклоняют chunked POST с 400 malformed request
229
+ const payload = JSON.stringify(body);
230
+ const reqHeaders = { ...headers, 'Content-Length': Buffer.byteLength(payload) };
228
231
 
229
232
  const doRequest = () => new Promise((resolve, reject) => {
230
233
  const req = transport.request({
@@ -233,7 +236,7 @@ export default {
233
236
  path: url.pathname + url.search,
234
237
  method: 'POST',
235
238
  agent: WORK.tls_agent?.(ai),
236
- headers,
239
+ headers: reqHeaders,
237
240
  }, (res) => {
238
241
  if (res.statusCode < 200 || res.statusCode >= 300) {
239
242
  // F28: тело ошибки — с потолком (чужой сервер не решает, сколько мы держим в памяти)
@@ -288,7 +291,7 @@ export default {
288
291
  else
289
292
  signal.addEventListener?.('abort', () => req.destroy(new Error('aborted')), { once: true });
290
293
  }
291
- req.write(JSON.stringify(body));
294
+ req.write(payload);
292
295
  req.end();
293
296
  });
294
297
 
@@ -298,10 +301,7 @@ export default {
298
301
  if (backend?.ready) {
299
302
  res = await doRequest();
300
303
  }
301
- else if (backend?.code === 'INCOMPATIBLE_FORMAT') {
302
- throw new Error(backend.reason);
303
- }
304
- else if (typeof WORK?.localStreamChat !== 'function') {
304
+ else if (isHalogenNode || backend?.code === 'INCOMPATIBLE_FORMAT' || typeof WORK?.localStreamChat !== 'function') {
305
305
  throw new Error(backend?.reason || 'Встроенный локальный движок ИИ не запущен.');
306
306
  }
307
307
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "odant-work",
3
- "version": "1.0.33",
3
+ "version": "1.0.35",
4
4
  "description": "ODANT-WORK — платформа цифровой организации (встроенная система учёта, документооборот, управление процессами и приватный мультимодальный ИИ)",
5
5
  "type": "module",
6
6
  "main": "sources/work.js",
@@ -1,6 +1,12 @@
1
1
  # Прогресс: sources/data
2
2
 
3
3
  ## Последние изменения
4
+ - [12:25, 17.11] Передача явного `Content-Length` в `streamChat` для совместимости с `bubo.exe` / Halogen (`MODELS/$ai/$folder/$class/$ai/class.js`, `tests/ai-stream.test.js`, `odant-work@1.0.35`):
5
+ - **Устранена ошибка `400 malformed request` при обращении к локальному серверу `:8731`:** в `streamChat` (`doRequest`) тело POST-запроса отправлялось через `req.write(...)` без заголовка `Content-Length`, из-за чего Node.js использовал `Transfer-Encoding: chunked`, который `bubo.exe` (`gufo 0.26.0`) отвергал с `400 invalid_request_error / malformed request`. Теперь `Content-Length` вычисляется явно через `Buffer.byteLength(payload)`.
6
+ - [11:15, 17.11] Исправление запуска нативного движка `bubo.exe` без `bubo-package.json`, перехват `stderr` и таймаут холодного старта (`sources/modules/trainer/halogen.js`, `MODELS/$ai/$folder/$class/$ai/class.js`, `tests/halogen-provider.test.js`, `odant-work@1.0.34`):
7
+ - **Убран лишний флаг `--cache-disk` при прямом запуске GGUF (`startHalogenBackend`, `computeHalogenMemoryPlan`):** в `bubo 0.1.2` опция `--cache-disk` без `--manifest bubo-package.json` завершает процесс с ошибкой (`Error: --cache-disk requires a prepared model package`). Теперь `--manifest` и `--cache-disk` передаются только при наличии `bubo-package.json` рядом с весами модели.
8
+ - **Перехват `stdout`/`stderr` и честная диагностика (`attachManagedBackendProcess`, `formatBackendExitReason`):** дочерние процессы (`bubo.exe`, `gufo.exe`, `llama-server`) запускаются с `stdio: ['ignore', 'pipe', 'pipe']` и кольцевым буфером на 8 КБ; при досрочном выходе (`PROCESS_EXITED`) в UI выводится реальный код выхода и текст ошибки из `stderr` (подсказка про VC++ / AMD / PageFile показывается только при пустом `stderr` или выявленной проблеме окружения).
9
+ - **Таймаут загрузки 108 ГБ весов и защита от дублей (`ensureHalogenBackendRunning`, `$ai/class.js`):** дефолтный `waitTimeoutMs` увеличен с 20 с до 120 с, повторный вызов `startHalogenBackend` при живом запускающемся процессе не спавнит дубликат `bubo.exe`, а `streamChat` для `protocol === 'halogen'` при ошибке старта сразу отдаёт `backend.reason` без повторного круга в `localStreamChat`.
4
10
  - [09:40, 17.11] Разделение движка `bubo` (`$provider/#runtime/bubo/`) и весов нейросети `Qwen3.8-Flash-Next` (`$ai/#weights/`) по архитектуре WORK (`sources/modules/trainer/{halogen,paths,runner,providers,huggingface,index}.js`, `tests/halogen-provider.test.js`, `odant-work@1.0.33`):
5
11
  - **Убрана ошибочная папка `MODELS/Local/models/` и зависимость от `bubo prepare model` / `bubo-package.json`:** `bubo.exe` (+ `ROCm 10.0.0`) используется строго как общий движок инференса в `MODELS/Local/$provider/#runtime/bubo/`, а все 8 GGUF-файлов `Qwen3.8-Flash-Next` (`QWEN_FLASH_NEXT_GGUF_FILES`) теперь качаются штатным загрузчиком WORK прямо в метапапку модели `MODELS/Local/Qwen3.8-Flash-Next/$ai/#weights/`.
6
12
  - **Прямой запуск `bubo.exe serve llm` (`resolveBuboModelFiles`):** движок запускается напрямую с флагами `--model`, `--mtp-model`, `--mmproj`, `--twin-model`, `--draft-head-model`; при этом инспектор и резолвер весов (`paths.js`, `halogen.js`) поддерживают как плоскую раскладку в `#weights/`, так и подпапки `mtp/`, `mmproj/`, `twin/`, `draft_head/` после ручного переноса файлов.
@@ -476,8 +476,96 @@ const _sessionHandles = new Map();
476
476
  const SESSION_HANDLE_TTL_MS = 10 * 60 * 1000;
477
477
  const SESSION_HANDLE_MAX = 16;
478
478
 
479
+ const BACKEND_LOG_TAIL_CHARS = 8192;
479
480
  let _managedProc = null;
480
481
  let _managedInfo = null;
482
+ let _lastManagedExit = null;
483
+
484
+ function appendLogTail(prev, chunk) {
485
+ const text = prev + (Buffer.isBuffer(chunk) ? chunk.toString('utf-8') : String(chunk || ''));
486
+ return text.length > BACKEND_LOG_TAIL_CHARS ? text.slice(-BACKEND_LOG_TAIL_CHARS) : text;
487
+ }
488
+
489
+ function attachManagedBackendProcess(proc, meta = {}) {
490
+ _managedProc = proc;
491
+ _lastManagedExit = null;
492
+ const state = {
493
+ ...meta,
494
+ pid: proc?.pid,
495
+ startedAt: Date.now(),
496
+ stdout: '',
497
+ stderr: '',
498
+ errorMessage: '',
499
+ };
500
+ _managedInfo = state;
501
+
502
+ proc?.stdout?.on?.('data', chunk => {
503
+ state.stdout = appendLogTail(state.stdout, chunk);
504
+ });
505
+ proc?.stderr?.on?.('data', chunk => {
506
+ state.stderr = appendLogTail(state.stderr, chunk);
507
+ });
508
+ proc?.on?.('error', err => {
509
+ state.errorMessage = String(err?.message || err || '');
510
+ });
511
+ proc?.on?.('exit', (code, signal) => {
512
+ _lastManagedExit = {
513
+ pid: proc?.pid,
514
+ runtime: state.runtime,
515
+ code,
516
+ signal,
517
+ stderr: state.stderr,
518
+ stdout: state.stdout,
519
+ errorMessage: state.errorMessage,
520
+ exitedAt: Date.now(),
521
+ };
522
+ if (_managedProc === proc) {
523
+ _managedProc = null;
524
+ _managedInfo = null;
525
+ }
526
+ });
527
+ return state;
528
+ }
529
+
530
+ function extractProcessErrorDetail(exitInfo) {
531
+ if (!exitInfo)
532
+ return '';
533
+ const combined = [exitInfo.stderr, exitInfo.stdout, exitInfo.errorMessage]
534
+ .filter(Boolean)
535
+ .join('\n')
536
+ .replace(/\u001b\[[0-9;]*m/g, '');
537
+ const lines = combined
538
+ .split(/\r?\n/)
539
+ .map(line => line.trim())
540
+ .filter(Boolean);
541
+ if (!lines.length)
542
+ return '';
543
+ const errorLines = lines.filter(line => /^(error|fatal|exception|panic)\b/i.test(line) || /\b(error|failed|fatal)\s*:/i.test(line));
544
+ const picked = (errorLines.length ? errorLines : lines).slice(-3).join(' | ');
545
+ return picked.length > 450 ? `${picked.slice(0, 447)}...` : picked;
546
+ }
547
+
548
+ function formatBackendExitReason({ runtimeLabel, exitInfo, winEnv }) {
549
+ const label = runtimeLabel || exitInfo?.runtime || 'встроенный движок';
550
+ const detail = extractProcessErrorDetail(exitInfo);
551
+ const codePart = exitInfo?.code !== undefined && exitInfo?.code !== null
552
+ ? `код ${exitInfo.code}`
553
+ : (exitInfo?.signal ? `сигнал ${exitInfo.signal}` : 'без кода');
554
+
555
+ if (detail) {
556
+ const envNotes = [];
557
+ if (winEnv?.isWindows) {
558
+ if (winEnv.vcRedistInstalled === false)
559
+ envNotes.push('не найден VC++ Redistributable (vcruntime140.dll)');
560
+ if (winEnv.pageFileOk === false)
561
+ envNotes.push(`PageFile ${winEnv.pageFileGb} ГБ вместо рекомендуемых 128 ГБ`);
562
+ }
563
+ const suffix = envNotes.length ? ` (${envNotes.join('; ')})` : '';
564
+ return `Встроенный движок ИИ (${label}) завершился (${codePart}): ${detail}${suffix}`;
565
+ }
566
+
567
+ return `Встроенный движок ИИ (${label}) завершился сразу после запуска (${codePart}; проверьте наличие VC++ Redistributable, драйвера AMD и PageFile 128 ГБ).`;
568
+ }
481
569
  let _windowsPrepareState = {
482
570
  status: 'idle',
483
571
  step: '',
@@ -698,8 +786,7 @@ export function computeHalogenMemoryPlan({
698
786
  ` --model "MODELS\\Local\\Qwen3.8-Flash-Next\\$ai\\#weights\\Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf" ^`,
699
787
  ` --served-model-name halogen-qwen3.8-flash-next ^`,
700
788
  ` --profile ${kvSlots > 1 ? 'subagents' : 'default'} --context ${contextTokens} ^`,
701
- ` --npu-prefill on ^`,
702
- ` --cache-disk "MODELS\\Local\\$provider\\#cache\\disk"`,
789
+ ` --npu-prefill on`,
703
790
  ].join('\n');
704
791
 
705
792
  const windowsGufoServicesCommand = [
@@ -1340,12 +1427,28 @@ export async function startHalogenBackend({
1340
1427
  }
1341
1428
 
1342
1429
  const winEnv = inspectWindowsHalogenEnvironment({ rootDir });
1430
+
1431
+ if (_managedProc && !_managedProc.killed && _managedInfo?.port === port) {
1432
+ return {
1433
+ started: true,
1434
+ alreadyStarting: true,
1435
+ mode: _managedInfo.runtime === 'llama-server' ? 'llama-server-windows' : 'bubo-windows',
1436
+ runtime: _managedInfo.runtimeLabel || _managedInfo.runtime,
1437
+ pid: _managedProc.pid,
1438
+ port,
1439
+ modelPath: _managedInfo.modelPath,
1440
+ windowsEnv: winEnv,
1441
+ };
1442
+ }
1443
+
1343
1444
  const cacheDir = localCacheDir(rootDir);
1344
1445
  fs.mkdirSync(path.join(cacheDir, 'disk'), { recursive: true });
1345
1446
  fs.mkdirSync(path.join(cacheDir, 'slots'), { recursive: true });
1346
1447
 
1347
1448
  const ggufPath = modelPath || findLocalGgufModel(rootDir);
1348
1449
  const resolvedSidecars = ggufPath ? resolveBuboModelFiles(path.dirname(ggufPath)) : null;
1450
+ const manifestCandidate = ggufPath ? path.join(path.dirname(ggufPath), 'bubo-package.json') : '';
1451
+ const hasBuboManifest = Boolean(manifestCandidate && fs.existsSync(manifestCandidate));
1349
1452
 
1350
1453
  // 1. Приоритет №1 на Windows: нативный движок Halowin Bubo (`bubo.exe serve llm` на ROCm 10.0.0 gfx1151 + Ryzen AI NPU)
1351
1454
  if (winEnv.buboInstalled && ggufPath && fs.existsSync(ggufPath)) {
@@ -1355,13 +1458,13 @@ export async function startHalogenBackend({
1355
1458
  '--host', '127.0.0.1',
1356
1459
  '--port', String(port),
1357
1460
  '--model', ggufPath,
1461
+ ...(hasBuboManifest ? ['--manifest', manifestCandidate, '--cache-disk', path.join(cacheDir, 'disk')] : []),
1358
1462
  ...(resolvedSidecars?.mtpModel ? ['--mtp-model', resolvedSidecars.mtpModel] : []),
1359
1463
  ...(resolvedSidecars?.mmprojModel ? ['--mmproj', resolvedSidecars.mmprojModel] : []),
1360
1464
  ...(resolvedSidecars?.twinModel ? ['--twin-model', resolvedSidecars.twinModel] : []),
1361
1465
  ...(resolvedSidecars?.draftHeadModel ? ['--draft-head-model', resolvedSidecars.draftHeadModel] : []),
1362
1466
  '--served-model-name', 'halogen-qwen3.8-flash-next',
1363
1467
  '--profile', profile || 'subagents',
1364
- '--cache-disk', path.join(cacheDir, 'disk'),
1365
1468
  ];
1366
1469
  if (npuPrefill && winEnv.npuDriverInstalled && winEnv.npuKernelsPresent && profile !== 'exact' && profile !== 'stock') {
1367
1470
  args.push('--npu-prefill', 'on');
@@ -1374,22 +1477,15 @@ export async function startHalogenBackend({
1374
1477
  cwd: path.dirname(winEnv.buboExePath),
1375
1478
  env,
1376
1479
  windowsHide: true,
1377
- stdio: 'ignore',
1480
+ stdio: ['ignore', 'pipe', 'pipe'],
1378
1481
  detached: false,
1379
1482
  });
1380
1483
  proc.unref?.();
1381
- _managedProc = proc;
1382
- _managedInfo = {
1383
- pid: proc.pid,
1484
+ attachManagedBackendProcess(proc, {
1384
1485
  port,
1385
1486
  modelPath: ggufPath,
1386
- startedAt: Date.now(),
1387
1487
  runtime: 'bubo',
1388
1488
  npuPrefill: Boolean(npuPrefill && winEnv.npuDriverInstalled && winEnv.npuKernelsPresent),
1389
- };
1390
- proc.on('exit', () => {
1391
- _managedProc = null;
1392
- _managedInfo = null;
1393
1489
  });
1394
1490
  return {
1395
1491
  started: true,
@@ -1419,21 +1515,14 @@ export async function startHalogenBackend({
1419
1515
  const proc = spawnImpl(winEnv.gufoExePath, args, {
1420
1516
  cwd: path.dirname(winEnv.gufoExePath),
1421
1517
  windowsHide: true,
1422
- stdio: 'ignore',
1518
+ stdio: ['ignore', 'pipe', 'pipe'],
1423
1519
  detached: false,
1424
1520
  });
1425
1521
  proc.unref?.();
1426
- _managedProc = proc;
1427
- _managedInfo = {
1428
- pid: proc.pid,
1522
+ attachManagedBackendProcess(proc, {
1429
1523
  port,
1430
1524
  modelPath: ggufPath,
1431
- startedAt: Date.now(),
1432
1525
  runtime: 'gufo',
1433
- };
1434
- proc.on('exit', () => {
1435
- _managedProc = null;
1436
- _managedInfo = null;
1437
1526
  });
1438
1527
  return {
1439
1528
  started: true,
@@ -1465,21 +1554,14 @@ export async function startHalogenBackend({
1465
1554
  ];
1466
1555
  const proc = spawnImpl('llama-server', args, {
1467
1556
  windowsHide: true,
1468
- stdio: 'ignore',
1557
+ stdio: ['ignore', 'pipe', 'pipe'],
1469
1558
  detached: false,
1470
1559
  });
1471
1560
  proc.unref?.();
1472
- _managedProc = proc;
1473
- _managedInfo = {
1474
- pid: proc.pid,
1561
+ attachManagedBackendProcess(proc, {
1475
1562
  port,
1476
1563
  modelPath: ggufPath,
1477
- startedAt: Date.now(),
1478
1564
  runtime: 'llama-server',
1479
- };
1480
- proc.on('exit', () => {
1481
- _managedProc = null;
1482
- _managedInfo = null;
1483
1565
  });
1484
1566
  return {
1485
1567
  started: true,
@@ -1512,6 +1594,7 @@ export function stopHalogenBackend() {
1512
1594
  }
1513
1595
  _managedProc = null;
1514
1596
  _managedInfo = null;
1597
+ _lastManagedExit = null;
1515
1598
  return { stopped: true };
1516
1599
  }
1517
1600
 
@@ -1523,7 +1606,7 @@ export async function ensureHalogenBackendRunning({
1523
1606
  rootDir = process.cwd(),
1524
1607
  baseUrl = HALOGEN_DEFAULT_BASE_URL,
1525
1608
  ai = null,
1526
- waitTimeoutMs = 20000,
1609
+ waitTimeoutMs = 120000,
1527
1610
  platform = os.platform(),
1528
1611
  spawnImpl = spawn,
1529
1612
  } = {}) {
@@ -1590,13 +1673,21 @@ export async function ensureHalogenBackendRunning({
1590
1673
  };
1591
1674
  }
1592
1675
 
1593
- const deadline = Date.now() + Math.max(2000, Number(waitTimeoutMs) || 20000);
1676
+ const timeoutMs = Math.max(2000, Number(waitTimeoutMs) || 120000);
1677
+ const deadline = Date.now() + timeoutMs;
1594
1678
  while (Date.now() < deadline) {
1595
1679
  if (!_managedProc && startRes.started && !startRes.alreadyRunning) {
1680
+ const exitInfo = _lastManagedExit;
1596
1681
  return {
1597
1682
  ready: false,
1598
1683
  code: 'PROCESS_EXITED',
1599
- reason: 'Встроенный движок ИИ завершился сразу после запуска (проверьте наличие VC++ Redistributable, драйвера AMD и PageFile 128 ГБ).',
1684
+ reason: formatBackendExitReason({
1685
+ runtimeLabel: startRes.runtime || startRes.mode,
1686
+ exitInfo,
1687
+ winEnv,
1688
+ }),
1689
+ exitCode: exitInfo?.code ?? null,
1690
+ stderr: exitInfo?.stderr || '',
1600
1691
  windowsEnv: winEnv,
1601
1692
  };
1602
1693
  }
@@ -1615,7 +1706,7 @@ export async function ensureHalogenBackendRunning({
1615
1706
  return {
1616
1707
  ready: false,
1617
1708
  code: 'START_TIMEOUT',
1618
- reason: `Встроенный движок (${startRes.runtime || startRes.mode}) запущен, но ещё загружает веса модели в память. Повторите запрос через 15–30 секунд.`,
1709
+ reason: `Встроенный движок (${startRes.runtime || startRes.mode}) запущен, но ещё загружает веса модели в память (ожидание ${Math.round(timeoutMs / 1000)} с истекло). Повторите запрос через 15–30 секунд.`,
1619
1710
  windowsEnv: winEnv,
1620
1711
  };
1621
1712
  }