odant-work 1.0.31 → 1.0.33

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.
@@ -34,6 +34,7 @@ import http from 'node:http';
34
34
  import https from 'node:https';
35
35
  import crypto from 'node:crypto';
36
36
  import { spawn } from 'node:child_process';
37
+ import AdmZip from 'adm-zip';
37
38
  import { startHuggingFaceDownload, listHuggingFaceDownloads, registerLocalModelNode } from './huggingface.js';
38
39
  import { loadTrainerNetworkSettings, createNetworkFetch, downloadFileMultipart } from './downloader.js';
39
40
  import {
@@ -68,6 +69,62 @@ export const BUBO_WINDOWS_RELEASE = Object.freeze({
68
69
  vcRedistUrl: 'https://aka.ms/vs/17/release/vc_redist.x64.exe',
69
70
  });
70
71
 
72
+ /**
73
+ * Точные 8 GGUF-файлов сети `Qwen3.8-Flash-Next` (`UD-Q4_K_XL` + `MTP` + `Vision` + `Dense Twin` + `Draft Head`, 108.6 GiB)
74
+ * для скачивания штатным многопоточным загрузчиком WORK прямо в метапапку модели `MODELS/Local/Qwen3.8-Flash-Next/$ai/#weights/`.
75
+ */
76
+ export const QWEN_FLASH_NEXT_GGUF_FILES = Object.freeze([
77
+ {
78
+ name: 'UD-Q4_K_XL/Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf',
79
+ destRelPath: 'Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf',
80
+ url: 'https://huggingface.co/unsloth/Qwen3.8-Flash-Next-GGUF/resolve/766911a6b7369840a91dbcd95f9f997acaab6cd6/UD-Q4_K_XL/Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf',
81
+ size: 10946624,
82
+ },
83
+ {
84
+ name: 'UD-Q4_K_XL/Qwen3.8-Flash-Next-UD-Q4_K_XL-00002-of-00004.gguf',
85
+ destRelPath: 'Qwen3.8-Flash-Next-UD-Q4_K_XL-00002-of-00004.gguf',
86
+ url: 'https://huggingface.co/unsloth/Qwen3.8-Flash-Next-GGUF/resolve/766911a6b7369840a91dbcd95f9f997acaab6cd6/UD-Q4_K_XL/Qwen3.8-Flash-Next-UD-Q4_K_XL-00002-of-00004.gguf',
87
+ size: 49859583136,
88
+ },
89
+ {
90
+ name: 'UD-Q4_K_XL/Qwen3.8-Flash-Next-UD-Q4_K_XL-00003-of-00004.gguf',
91
+ destRelPath: 'Qwen3.8-Flash-Next-UD-Q4_K_XL-00003-of-00004.gguf',
92
+ url: 'https://huggingface.co/unsloth/Qwen3.8-Flash-Next-GGUF/resolve/766911a6b7369840a91dbcd95f9f997acaab6cd6/UD-Q4_K_XL/Qwen3.8-Flash-Next-UD-Q4_K_XL-00003-of-00004.gguf',
93
+ size: 49376141504,
94
+ },
95
+ {
96
+ name: 'UD-Q4_K_XL/Qwen3.8-Flash-Next-UD-Q4_K_XL-00004-of-00004.gguf',
97
+ destRelPath: 'Qwen3.8-Flash-Next-UD-Q4_K_XL-00004-of-00004.gguf',
98
+ url: 'https://huggingface.co/unsloth/Qwen3.8-Flash-Next-GGUF/resolve/766911a6b7369840a91dbcd95f9f997acaab6cd6/UD-Q4_K_XL/Qwen3.8-Flash-Next-UD-Q4_K_XL-00004-of-00004.gguf',
99
+ size: 12087983520,
100
+ },
101
+ {
102
+ name: 'mtp/mtp-Qwen3.8-Flash-Next-shared-Q8_0.gguf',
103
+ destRelPath: 'mtp-Qwen3.8-Flash-Next-shared-Q8_0.gguf',
104
+ url: 'https://huggingface.co/unsloth/Qwen3.8-Flash-Next-GGUF/resolve/766911a6b7369840a91dbcd95f9f997acaab6cd6/MTP/mtp-Qwen3.8-Flash-Next-shared-Q8_0.gguf',
105
+ size: 2786568256,
106
+ },
107
+ {
108
+ name: 'mmproj/mmproj-Qwen3.8-Flash-Next-BF16.gguf',
109
+ destRelPath: 'mmproj-Qwen3.8-Flash-Next-BF16.gguf',
110
+ url: 'https://huggingface.co/unsloth/Qwen3.8-Flash-Next-GGUF/resolve/766911a6b7369840a91dbcd95f9f997acaab6cd6/mmproj-BF16.gguf',
111
+ size: 907542944,
112
+ },
113
+ {
114
+ name: 'twin/iq4-nofullattn-nohc.gguf',
115
+ destRelPath: 'iq4-nofullattn-nohc.gguf',
116
+ url: 'https://huggingface.co/HaloForgeLabs/bubo-qwen3.8-flash-next/resolve/0a3c343bec2095f43f2906371c83e4faa8a47da1/twin-base/iq4-nofullattn-nohc.gguf',
117
+ size: 1230788768,
118
+ },
119
+ {
120
+ name: 'draft_head/draft-out-q4k.gguf',
121
+ destRelPath: 'draft-out-q4k.gguf',
122
+ url: 'https://huggingface.co/HaloForgeLabs/bubo-qwen3.8-flash-next/resolve/0a3c343bec2095f43f2906371c83e4faa8a47da1/draft_head/draft-out-q4k.gguf',
123
+ size: 357581248,
124
+ },
125
+ ]);
126
+ export const BUBO_ORIGINAL_MODEL_FILES = QWEN_FLASH_NEXT_GGUF_FILES;
127
+
71
128
  /**
72
129
  * Каталог штатных моделей для машинок Halo в `/MODELS/Local` (1 основная GPU-модель + 7 NPU-моделей на одном порту 8731).
73
130
  */
@@ -630,16 +687,15 @@ export function computeHalogenMemoryPlan({
630
687
  ` ${HALOGEN_IMAGE_TAG}`,
631
688
  ].join('\n');
632
689
 
633
- // Нативная подготовка и запуск Halowin Bubo (gufo v0.26.0 + AMD ROCm 10.0.0 gfx1151 + Ryzen AI XRT NPU) на Windows 11
690
+ // Нативная подготовка движка Halowin Bubo (AMD ROCm 10.0.0 gfx1151) и запуск нейросети из её метапапки `$ai/#weights`
634
691
  const windowsPrepareCommand = [
635
- `.\\bubo.exe prepare runtime --yes`,
636
- `.\\bubo.exe prepare model --model-set original --output "MODELS\\Local" --yes`,
692
+ `.\\bubo.exe prepare runtime --runtime-dir "MODELS\\Local\\$provider\\#runtime\\bubo\\runtime\\rocm-10.0.0-gfx1151" --yes`,
637
693
  ].join('\n');
638
694
 
639
695
  const windowsCommand = [
640
696
  `bubo.exe serve llm ^`,
641
697
  ` --host 127.0.0.1 --port ${HALOGEN_DEFAULT_PORT} ^`,
642
- ` --manifest "MODELS\\Local\\models\\qwen38-flash-next-base-ud-q4-k-xl-v1\\bubo-package.json" ^`,
698
+ ` --model "MODELS\\Local\\Qwen3.8-Flash-Next\\$ai\\#weights\\Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf" ^`,
643
699
  ` --served-model-name halogen-qwen3.8-flash-next ^`,
644
700
  ` --profile ${kvSlots > 1 ? 'subagents' : 'default'} --context ${contextTokens} ^`,
645
701
  ` --npu-prefill on ^`,
@@ -708,9 +764,25 @@ export function inspectWindowsHalogenEnvironment({ rootDir = process.cwd() } = {
708
764
  const systemRoot = process.env.SystemRoot || 'C:\\Windows';
709
765
  const rtBase = localRuntimeDir(rootDir);
710
766
 
767
+ const nestedBuboCandidates = [];
768
+ for (const parentDir of [path.join(rtBase, 'bubo'), path.join(rootDir, 'MODELS', 'Local', '#runtime', 'bubo')]) {
769
+ try {
770
+ if (fs.existsSync(parentDir)) {
771
+ for (const sub of fs.readdirSync(parentDir, { withFileTypes: true })) {
772
+ if (sub.isDirectory()) {
773
+ nestedBuboCandidates.push(path.join(parentDir, sub.name, 'bin', 'bubo.exe'));
774
+ nestedBuboCandidates.push(path.join(parentDir, sub.name, 'bubo.exe'));
775
+ }
776
+ }
777
+ }
778
+ }
779
+ catch { /* ignore */ }
780
+ }
781
+
711
782
  const buboCandidates = [
712
783
  path.join(rtBase, 'bubo', 'bin', 'bubo.exe'),
713
784
  path.join(rtBase, 'bubo', 'bubo.exe'),
785
+ ...nestedBuboCandidates,
714
786
  path.join(rootDir, 'MODELS', 'Local', '#runtime', 'bubo', 'bin', 'bubo.exe'),
715
787
  path.join(rootDir, 'MODELS', 'Local', '#runtime', 'bubo', 'bubo.exe'),
716
788
  path.join(rootDir, 'MODELS', 'Halogen', '#runtime', 'bubo', 'bin', 'bubo.exe'),
@@ -734,19 +806,9 @@ export function inspectWindowsHalogenEnvironment({ rootDir = process.cwd() } = {
734
806
  ].filter(Boolean);
735
807
  const rocmRuntimeDir = rocmCandidates.find(p => fs.existsSync(p)) || null;
736
808
 
737
- const manifestCandidates = [
738
- process.env.BUBO_MANIFEST || '',
739
- path.join(modelWeightsDir(rootDir, 'Qwen3.8-Flash-Next', 'Local'), 'bubo-package.json'),
740
- path.join(rootDir, 'MODELS', 'Local', 'models', 'qwen38-flash-next-base-ud-q4-k-xl-v1', 'bubo-package.json'),
741
- path.join(rootDir, 'MODELS', 'Local', 'models', 'huihui-qwen38-flash-next-ud-q4-k-xl-v1', 'bubo-package.json'),
742
- path.join(rootDir, 'MODELS', 'Local', 'Qwen3.8-Flash-Next', '#weights', 'bubo-package.json'),
743
- path.join(rootDir, 'MODELS', 'Halogen', 'models', 'qwen38-flash-next-base-ud-q4-k-xl-v1', 'bubo-package.json'),
744
- path.join(rootDir, 'MODELS', 'Halogen', 'models', 'huihui-qwen38-flash-next-ud-q4-k-xl-v1', 'bubo-package.json'),
745
- path.join(rootDir, 'MODELS', 'Halogen', 'Qwen3.8-Flash-Next', '#weights', 'bubo-package.json'),
746
- path.join(localAppData, 'Bubo', 'models', 'qwen38-flash-next-base-ud-q4-k-xl-v1', 'bubo-package.json'),
747
- path.join(localAppData, 'Bubo', 'models', 'huihui-qwen38-flash-next-ud-q4-k-xl-v1', 'bubo-package.json'),
748
- ].filter(Boolean);
749
- const buboManifestPath = manifestCandidates.find(p => fs.existsSync(p)) || null;
809
+ const flashWeightsDir = modelWeightsDir(rootDir, 'Qwen3.8-Flash-Next', 'Local');
810
+ const flashResolved = resolveBuboModelFiles(flashWeightsDir);
811
+ const anyLocalGguf = flashResolved.mainModel || findLocalGgufModel(rootDir);
750
812
 
751
813
  const gufoCandidates = [
752
814
  path.join(rtBase, 'gufo', 'gufo.exe'),
@@ -793,8 +855,8 @@ export function inspectWindowsHalogenEnvironment({ rootDir = process.cwd() } = {
793
855
  buboRootDir,
794
856
  rocmRuntimePrepared: Boolean(rocmRuntimeDir),
795
857
  rocmRuntimeDir,
796
- buboModelPrepared: Boolean(buboManifestPath),
797
- buboManifestPath,
858
+ buboModelPrepared: Boolean(anyLocalGguf),
859
+ buboManifestPath: null,
798
860
  gufoInstalled: Boolean(gufoExePath),
799
861
  gufoExePath,
800
862
  strataInstalled: Boolean(strataExePath),
@@ -956,40 +1018,78 @@ export async function probeHalogenServer(baseUrl = HALOGEN_DEFAULT_BASE_URL, { f
956
1018
  }
957
1019
 
958
1020
  /**
959
- * Найти локальный GGUF-файл модели (в `/MODELS/Halogen` или `/MODELS/Local`).
1021
+ * Найти основной шард GGUF и все вспомогательные файлы (MTP, Vision mmproj, Dense Twin, Draft Head)
1022
+ * внутри метапапки модели `$ai/#weights` — поддерживается как плоская раскладка, так и подпапки `mtp/`, `mmproj/`, `twin/`, `draft_head/`.
960
1023
  */
961
- function findLocalGgufModel(rootDir = process.cwd()) {
962
- const searchRoots = [
963
- path.join(rootDir, 'MODELS', 'Local', 'models'),
964
- path.join(rootDir, 'MODELS', 'Local'),
965
- path.join(rootDir, 'MODELS', 'Halogen', 'models'),
966
- path.join(rootDir, 'MODELS', 'Halogen'),
967
- ];
968
- for (const base of searchRoots) {
969
- if (!fs.existsSync(base))
970
- continue;
1024
+ export function resolveBuboModelFiles(weightsDir) {
1025
+ const empty = { mainModel: null, mtpModel: null, mmprojModel: null, twinModel: null, draftHeadModel: null };
1026
+ if (!weightsDir || !fs.existsSync(weightsDir))
1027
+ return empty;
1028
+ const candidates = [];
1029
+ const scanDir = (dir) => {
1030
+ if (!fs.existsSync(dir))
1031
+ return;
971
1032
  try {
972
- for (const entry of fs.readdirSync(base, { withFileTypes: true })) {
973
- if (!entry.isDirectory() || entry.name.startsWith('$') || entry.name.startsWith('#'))
974
- continue;
975
- const candidates = [
976
- path.join(base, entry.name, '$ai', '#weights'),
977
- path.join(base, entry.name, '#weights'),
978
- path.join(base, entry.name),
979
- ];
980
- for (const dir of candidates) {
981
- if (!fs.existsSync(dir))
982
- continue;
983
- const gguf = fs.readdirSync(dir)
984
- .filter(f => f.endsWith('.gguf') && !f.endsWith('.part') && !/mtp|mmproj/i.test(f))
985
- .sort()[0];
986
- if (gguf)
987
- return path.join(dir, gguf);
988
- }
1033
+ for (const ent of fs.readdirSync(dir, { withFileTypes: true })) {
1034
+ if (ent.isFile() && ent.name.toLowerCase().endsWith('.gguf') && !ent.name.endsWith('.part'))
1035
+ candidates.push(path.join(dir, ent.name));
989
1036
  }
990
1037
  }
991
1038
  catch { /* ignore */ }
1039
+ };
1040
+ scanDir(weightsDir);
1041
+ for (const sub of ['mtp', 'mmproj', 'twin', 'draft_head'])
1042
+ scanDir(path.join(weightsDir, sub));
1043
+
1044
+ const isSidecar = (p) => {
1045
+ const base = path.basename(p).toLowerCase();
1046
+ const dirName = path.basename(path.dirname(p)).toLowerCase();
1047
+ return ['mtp', 'mmproj', 'twin', 'draft_head'].includes(dirName)
1048
+ || /^(mtp[-_]|mmproj[-_]|iq4-nofullattn|twin[-_]|draft[-_]?out|draft[-_]?head)/.test(base);
1049
+ };
1050
+
1051
+ const mainModel = candidates
1052
+ .filter(p => !isSidecar(p))
1053
+ .sort((a, b) => (/-00001-of-/i.test(a) ? -1 : /-00001-of-/i.test(b) ? 1 : a.localeCompare(b)))[0] || null;
1054
+ const mtpModel = candidates.find(p =>
1055
+ path.basename(path.dirname(p)).toLowerCase() === 'mtp' || /^mtp[-_]/i.test(path.basename(p))
1056
+ ) || null;
1057
+ const mmprojModel = candidates.find(p =>
1058
+ path.basename(path.dirname(p)).toLowerCase() === 'mmproj' || /^mmproj[-_]/i.test(path.basename(p))
1059
+ ) || null;
1060
+ const twinModel = candidates.find(p =>
1061
+ path.basename(path.dirname(p)).toLowerCase() === 'twin' || /iq4-nofullattn|^twin[-_]/i.test(path.basename(p))
1062
+ ) || null;
1063
+ const draftHeadModel = candidates.find(p =>
1064
+ path.basename(path.dirname(p)).toLowerCase() === 'draft_head' || /draft[-_]?out|draft[-_]?head/i.test(path.basename(p))
1065
+ ) || null;
1066
+
1067
+ return { mainModel, mtpModel, mmprojModel, twinModel, draftHeadModel };
1068
+ }
1069
+
1070
+ /**
1071
+ * Найти локальный GGUF-файл модели в метапапках моделей `/MODELS/Local/<Модель>/$ai/#weights`.
1072
+ */
1073
+ function findLocalGgufModel(rootDir = process.cwd()) {
1074
+ const preferred = resolveBuboModelFiles(modelWeightsDir(rootDir, 'Qwen3.8-Flash-Next', 'Local'));
1075
+ if (preferred.mainModel)
1076
+ return preferred.mainModel;
1077
+
1078
+ const localRoot = path.join(rootDir, 'MODELS', 'Local');
1079
+ if (!fs.existsSync(localRoot))
1080
+ return null;
1081
+ try {
1082
+ for (const entry of fs.readdirSync(localRoot, { withFileTypes: true })) {
1083
+ if (!entry.isDirectory() || entry.name.startsWith('$') || entry.name.startsWith('#') || entry.name === 'models')
1084
+ continue;
1085
+ for (const dir of [modelWeightsDir(rootDir, entry.name, 'Local'), path.join(localRoot, entry.name, '#weights')]) {
1086
+ const resolved = resolveBuboModelFiles(dir);
1087
+ if (resolved.mainModel)
1088
+ return resolved.mainModel;
1089
+ }
1090
+ }
992
1091
  }
1092
+ catch { /* ignore */ }
993
1093
  return null;
994
1094
  }
995
1095
 
@@ -1035,13 +1135,12 @@ export function checkWindowsHalogenPreflight({
1035
1135
  }
1036
1136
 
1037
1137
  /**
1038
- * Скачать и подготовить нативный Windows-движок `Halowin Bubo` (`bubo-v0.1.2-windows-x64-gfx1151.zip`),
1039
- * официальный рантайм AMD ROCm 10.0.0 (`gfx1151`) и пакет весов `Qwen3.8-Flash-Next` (`UD-Q4_K_XL` + `Dense Twin` + `MTP`).
1138
+ * Скачать и подготовить общий нативный Windows-движок `Halowin Bubo` (`bubo-v0.1.2-windows-x64-gfx1151.zip`)
1139
+ * и официальный рантайм AMD ROCm 10.0.0 (`gfx1151`) в `MODELS/Local/$provider/#runtime/bubo/`.
1040
1140
  */
1041
1141
  export async function prepareWindowsBuboRuntime({
1042
1142
  rootDir = process.cwd(),
1043
1143
  step = 'runtime',
1044
- modelSet = 'original',
1045
1144
  fetchImpl = globalThis.fetch,
1046
1145
  spawnImpl = spawn,
1047
1146
  } = {}) {
@@ -1049,7 +1148,6 @@ export async function prepareWindowsBuboRuntime({
1049
1148
  const runtimeRoot = localRuntimeDir(rootDir);
1050
1149
  const buboDir = path.join(runtimeRoot, 'bubo');
1051
1150
  const rocmDir = path.join(buboDir, 'runtime', 'rocm-10.0.0-gfx1151');
1052
- const modelsOutDir = path.join(rootDir, 'MODELS', 'Local');
1053
1151
 
1054
1152
  await fsp.mkdir(runtimeRoot, { recursive: true });
1055
1153
 
@@ -1057,7 +1155,7 @@ export async function prepareWindowsBuboRuntime({
1057
1155
  status: 'running',
1058
1156
  step,
1059
1157
  progress: 5,
1060
- message: 'Проверка нативного пакета Halowin Bubo (gfx1151)…',
1158
+ message: 'Проверка нативного движка Halowin Bubo (gfx1151)…',
1061
1159
  logs: [],
1062
1160
  error: '',
1063
1161
  updatedAt: Date.now(),
@@ -1071,22 +1169,10 @@ export async function prepareWindowsBuboRuntime({
1071
1169
  if (_windowsPrepareState.logs.length > 80)
1072
1170
  _windowsPrepareState.logs.shift();
1073
1171
  _windowsPrepareState.message = clean;
1074
- const pctMatch = clean.match(/\b(\d{1,3})%/);
1075
- if (pctMatch && (step === 'model' || step === 'all')) {
1076
- const pct = Math.min(99, Math.max(0, Number(pctMatch[1])));
1077
- if (pct > _windowsPrepareState.progress)
1078
- _windowsPrepareState.progress = pct;
1079
- }
1080
1172
  _windowsPrepareState.updatedAt = Date.now();
1081
1173
  };
1082
1174
 
1083
1175
  try {
1084
- if (step === 'model' || step === 'all') {
1085
- const freeGb = getFreeDiskSpaceGb(rootDir);
1086
- if (freeGb !== null && freeGb < 118) {
1087
- appendLog(`Предупреждение: на диске свободно ${freeGb} ГБ (рекомендуется ~120 ГБ для модели).`);
1088
- }
1089
- }
1090
1176
 
1091
1177
  const netCfg = loadTrainerNetworkSettings(rootDir);
1092
1178
  const childEnv = {
@@ -1149,22 +1235,42 @@ export async function prepareWindowsBuboRuntime({
1149
1235
  catch { /* ignore */ }
1150
1236
 
1151
1237
  if (os.platform() === 'win32' && isPkZip) {
1152
- await new Promise((resolve, reject) => {
1153
- const ps = spawnImpl('powershell', [
1154
- '-NoProfile',
1155
- '-Command',
1156
- `Expand-Archive -Path "${zipPath}" -DestinationPath "${buboDir}" -Force`,
1157
- ], { windowsHide: true });
1158
- ps.on('error', reject);
1159
- ps.on('close', code => code === 0 ? resolve() : reject(new Error(`Expand-Archive завершился с кодом ${code}`)));
1160
- });
1238
+ const zip = new AdmZip(zipPath);
1239
+ const entries = zip.getEntries();
1240
+ // В релизе bubo все файлы лежат внутри одной корневой папки `bubo-v0.1.2-windows-x64-gfx1151/` —
1241
+ // снимаем этот общий префикс при распаковке, чтобы `bin/bubo.exe` оказался прямо в `#runtime/bubo/bin/bubo.exe`.
1242
+ const topDirs = new Set(entries.map(e => String(e.entryName || '').split('/')[0]).filter(Boolean));
1243
+ const stripPrefix = topDirs.size === 1 ? ([...topDirs][0] + '/') : '';
1244
+ for (const entry of entries) {
1245
+ let rel = String(entry.entryName || '').replace(/^\/+/, '');
1246
+ if (stripPrefix && rel.startsWith(stripPrefix))
1247
+ rel = rel.slice(stripPrefix.length);
1248
+ if (!rel || rel.includes('..'))
1249
+ continue;
1250
+ const dest = path.resolve(buboDir, rel);
1251
+ if (!dest.startsWith(path.resolve(buboDir)))
1252
+ continue;
1253
+ if (entry.isDirectory) {
1254
+ await fsp.mkdir(dest, { recursive: true });
1255
+ }
1256
+ else {
1257
+ await fsp.mkdir(path.dirname(dest), { recursive: true });
1258
+ await fsp.writeFile(dest, entry.getData());
1259
+ }
1260
+ }
1161
1261
  }
1162
1262
  envInfo = inspectWindowsHalogenEnvironment({ rootDir });
1263
+ if (os.platform() === 'win32' && !envInfo.buboExePath && spawnImpl === spawn) {
1264
+ throw new Error('После распаковки архива Halowin Bubo не найден файл bin/bubo.exe.');
1265
+ }
1163
1266
  }
1164
1267
 
1165
1268
  const buboExe = envInfo.buboExePath || path.join(buboDir, 'bin', 'bubo.exe');
1269
+ if ((step === 'runtime' || step === 'all') && !fs.existsSync(buboExe)) {
1270
+ throw new Error(`Исполняемый файл bubo.exe не найден по пути: ${buboExe}`);
1271
+ }
1166
1272
 
1167
- // Шаг 2: Установка официальных библиотек AMD ROCm 10.0.0 (`gfx1151`) через `bubo.exe prepare runtime --yes`
1273
+ // Шаг 2: Установка официальных библиотек AMD ROCm 10.0.0 (`gfx1151`) в общий #runtime/bubo/runtime/
1168
1274
  if ((step === 'runtime' || step === 'all') && fs.existsSync(buboExe)) {
1169
1275
  appendLog('Загрузка официальных пакетов AMD ROCm 10.0.0 для gfx1151 (bubo prepare runtime --yes)…');
1170
1276
  _windowsPrepareState.progress = Math.max(_windowsPrepareState.progress, 35);
@@ -1185,59 +1291,6 @@ export async function prepareWindowsBuboRuntime({
1185
1291
  });
1186
1292
  }
1187
1293
 
1188
- // Шаг 3: Подготовка 8 файлов модели Qwen3.8-Flash-Next (UD-Q4_K_XL + MTP + Dense Twin + Draft Head + Vision)
1189
- if ((step === 'model' || step === 'all') && fs.existsSync(buboExe)) {
1190
- appendLog(`Подготовка модели Qwen3.8-Flash-Next (${modelSet}, ~116.6 ГБ) через bubo prepare model…`);
1191
- _windowsPrepareState.progress = Math.max(_windowsPrepareState.progress, 45);
1192
- const args = [
1193
- 'prepare', 'model',
1194
- ...(modelSet === 'original' ? ['--model-set', 'original'] : []),
1195
- '--output', modelsOutDir,
1196
- '--yes',
1197
- ];
1198
- await new Promise((resolve, reject) => {
1199
- const proc = spawnImpl(buboExe, args, {
1200
- cwd: path.dirname(buboExe),
1201
- env: childEnv,
1202
- windowsHide: true,
1203
- });
1204
- proc.stdout?.on('data', d => appendLog(d));
1205
- proc.stderr?.on('data', d => appendLog(d));
1206
- proc.on('error', reject);
1207
- proc.on('close', code => code === 0 ? resolve() : reject(new Error(`bubo prepare model завершился с кодом ${code}`)));
1208
- });
1209
-
1210
- const afterEnv = inspectWindowsHalogenEnvironment({ rootDir });
1211
- const flashSpec = HALOGEN_MODELS_CATALOG.find(m => m.nodeName === 'Qwen3.8-Flash-Next');
1212
- if (flashSpec) {
1213
- const wDir = afterEnv.buboManifestPath
1214
- ? path.dirname(afterEnv.buboManifestPath)
1215
- : modelWeightsDir(rootDir, flashSpec.nodeName, 'Local');
1216
- await registerLocalModelNode({
1217
- rootDir,
1218
- folderName: flashSpec.nodeName,
1219
- label: flashSpec.label,
1220
- repoId: flashSpec.windowsBuboRepo || 'unsloth/Qwen3.8-Flash-Next-GGUF',
1221
- model: flashSpec.model,
1222
- protocol: 'halogen',
1223
- icon: flashSpec.icon || 'ai:qwen',
1224
- modality: flashSpec.modality,
1225
- capabilities: flashSpec.capabilities,
1226
- efforts: flashSpec.efforts,
1227
- maxTokens: flashSpec.maxTokens,
1228
- maxOutput: flashSpec.maxOutput,
1229
- baseUrl: flashSpec.baseUrl || HALOGEN_DEFAULT_BASE_URL,
1230
- weightsDir: wDir,
1231
- primaryFile: 'bubo-package.json',
1232
- });
1233
- try {
1234
- const localNode = await globalThis.WORK?.get_item?.('/MODELS/Local');
1235
- localNode?.reset?.();
1236
- }
1237
- catch { /* ignore */ }
1238
- }
1239
- }
1240
-
1241
1294
  _windowsPrepareState.status = 'completed';
1242
1295
  _windowsPrepareState.progress = 100;
1243
1296
  appendLog('Нативный стек Halowin Bubo (AMD ROCm 10.0.0 gfx1151) готов к работе.');
@@ -1292,17 +1345,20 @@ export async function startHalogenBackend({
1292
1345
  fs.mkdirSync(path.join(cacheDir, 'slots'), { recursive: true });
1293
1346
 
1294
1347
  const ggufPath = modelPath || findLocalGgufModel(rootDir);
1348
+ const resolvedSidecars = ggufPath ? resolveBuboModelFiles(path.dirname(ggufPath)) : null;
1295
1349
 
1296
- // 1. Приоритет №1 на Windows: нативный Halowin Bubo (`bubo.exe serve llm` на ROCm 10.0.0 gfx1151 + Ryzen AI NPU)
1297
- if (winEnv.buboInstalled && (winEnv.buboManifestPath || (ggufPath && fs.existsSync(ggufPath)))) {
1350
+ // 1. Приоритет №1 на Windows: нативный движок Halowin Bubo (`bubo.exe serve llm` на ROCm 10.0.0 gfx1151 + Ryzen AI NPU)
1351
+ if (winEnv.buboInstalled && ggufPath && fs.existsSync(ggufPath)) {
1298
1352
  try {
1299
1353
  const args = [
1300
1354
  'serve', 'llm',
1301
1355
  '--host', '127.0.0.1',
1302
1356
  '--port', String(port),
1303
- ...(winEnv.buboManifestPath
1304
- ? ['--manifest', winEnv.buboManifestPath]
1305
- : ['--model', ggufPath]),
1357
+ '--model', ggufPath,
1358
+ ...(resolvedSidecars?.mtpModel ? ['--mtp-model', resolvedSidecars.mtpModel] : []),
1359
+ ...(resolvedSidecars?.mmprojModel ? ['--mmproj', resolvedSidecars.mmprojModel] : []),
1360
+ ...(resolvedSidecars?.twinModel ? ['--twin-model', resolvedSidecars.twinModel] : []),
1361
+ ...(resolvedSidecars?.draftHeadModel ? ['--draft-head-model', resolvedSidecars.draftHeadModel] : []),
1306
1362
  '--served-model-name', 'halogen-qwen3.8-flash-next',
1307
1363
  '--profile', profile || 'subagents',
1308
1364
  '--cache-disk', path.join(cacheDir, 'disk'),
@@ -1326,7 +1382,7 @@ export async function startHalogenBackend({
1326
1382
  _managedInfo = {
1327
1383
  pid: proc.pid,
1328
1384
  port,
1329
- modelPath: winEnv.buboManifestPath || ggufPath,
1385
+ modelPath: ggufPath,
1330
1386
  startedAt: Date.now(),
1331
1387
  runtime: 'bubo',
1332
1388
  npuPrefill: Boolean(npuPrefill && winEnv.npuDriverInstalled && winEnv.npuKernelsPresent),
@@ -1341,7 +1397,7 @@ export async function startHalogenBackend({
1341
1397
  runtime: 'bubo.exe (AMD ROCm 10.0.0 gfx1151)',
1342
1398
  pid: proc.pid,
1343
1399
  port,
1344
- modelPath: winEnv.buboManifestPath || ggufPath,
1400
+ modelPath: ggufPath,
1345
1401
  windowsEnv: winEnv,
1346
1402
  };
1347
1403
  }
@@ -1497,7 +1553,7 @@ export async function ensureHalogenBackendRunning({
1497
1553
  const wInsp = candidateWeightsDir ? inspectWeightsDirectorySync(candidateWeightsDir, platform) : null;
1498
1554
  const winEnv = inspectWindowsHalogenEnvironment({ rootDir });
1499
1555
 
1500
- if (platform === 'win32' && wInsp?.incompatibleOnPlatform && !winEnv.buboModelPrepared) {
1556
+ if (platform === 'win32' && wInsp?.incompatibleOnPlatform) {
1501
1557
  return {
1502
1558
  ready: false,
1503
1559
  code: 'INCOMPATIBLE_FORMAT',
@@ -1512,7 +1568,7 @@ export async function ensureHalogenBackendRunning({
1512
1568
  _backendStartPromise = (async () => {
1513
1569
  try {
1514
1570
  const explicitGguf = (wInsp?.hasGguf && candidateWeightsDir)
1515
- ? path.join(candidateWeightsDir, wInsp.files.filter(f => f.toLowerCase().endsWith('.gguf') && !/mtp|mmproj/i.test(f)).sort()[0] || '')
1571
+ ? (resolveBuboModelFiles(candidateWeightsDir).mainModel || '')
1516
1572
  : '';
1517
1573
 
1518
1574
  const startRes = await startHalogenBackend({
@@ -1792,13 +1848,36 @@ export async function ensureHalogenModelNodes(rootDir = process.cwd(), { models
1792
1848
  return registered;
1793
1849
  }
1794
1850
 
1851
+ /**
1852
+ * Убедиться, что общий нативный Windows-движок `bubo.exe` + `ROCm 10.0.0 gfx1151`
1853
+ * установлен в `MODELS/Local/$provider/#runtime/bubo/` (без скачивания или копирования весов).
1854
+ */
1855
+ export async function ensureWindowsBuboEngineInstalled({
1856
+ rootDir = process.cwd(),
1857
+ fetchImpl = globalThis.fetch,
1858
+ spawnImpl = spawn,
1859
+ } = {}) {
1860
+ const envInfo = inspectWindowsHalogenEnvironment({ rootDir });
1861
+ if (!envInfo.buboInstalled || !envInfo.rocmRuntimePrepared) {
1862
+ const rtRes = await prepareWindowsBuboRuntime({
1863
+ rootDir,
1864
+ step: 'runtime',
1865
+ fetchImpl,
1866
+ spawnImpl,
1867
+ });
1868
+ if (!rtRes.ok)
1869
+ throw new Error(rtRes.error || 'Не удалось установить встроенный движок Halowin Bubo (ROCm 10.0 gfx1151)');
1870
+ }
1871
+ return { ok: true, windowsEnv: inspectWindowsHalogenEnvironment({ rootDir }) };
1872
+ }
1873
+ export const finalizeWindowsBuboModel = ensureWindowsBuboEngineInstalled;
1874
+
1795
1875
  /**
1796
1876
  * Проверить наличие скачанных весов и узлов `$ai` для каждой модели Halo, совместимой с текущей ОС.
1797
1877
  */
1798
1878
  export function inspectHalogenCatalogWithStatus(rootDir = process.cwd(), { platform = os.platform() } = {}) {
1799
1879
  migrateLocalModelsLayoutSync(rootDir);
1800
1880
  const activeDownloads = listHuggingFaceDownloads(rootDir);
1801
- const winEnv = platform === 'win32' ? inspectWindowsHalogenEnvironment({ rootDir }) : null;
1802
1881
  const catalog = getHalogenCatalogForPlatform(platform);
1803
1882
 
1804
1883
  return catalog.map(spec => {
@@ -1810,42 +1889,40 @@ export function inspectHalogenCatalogWithStatus(rootDir = process.cwd(), { platf
1810
1889
  : (fs.existsSync(legacyHalogenDir) ? legacyHalogenDir : localWeightsDir));
1811
1890
 
1812
1891
  const wInsp = inspectWeightsDirectorySync(weightsDir, platform);
1813
- const hasBuboReady = platform === 'win32'
1814
- && spec.nodeName === 'Qwen3.8-Flash-Next'
1815
- && Boolean(winEnv?.buboModelPrepared && winEnv?.buboManifestPath);
1816
1892
 
1817
1893
  const nodeConfigured = fs.existsSync(modelClassFile(rootDir, spec.nodeName, 'Local'));
1818
1894
  let activeJob = activeDownloads.find(d =>
1819
1895
  (d.status === 'downloading' || d.status === 'paused' || d.status === 'failed')
1820
- && (d.repoId === spec.hfRepo || d.folderName === spec.nodeName || d.modelPath === spec.path)
1896
+ && (d.repoId === spec.hfRepo || (spec.windowsBuboRepo && d.repoId === spec.windowsBuboRepo) || d.folderName === spec.nodeName || d.modelPath === spec.path)
1821
1897
  ) || null;
1822
1898
 
1823
- if (!activeJob && platform === 'win32' && spec.nodeName === 'Qwen3.8-Flash-Next' && _windowsPrepareState.status === 'running') {
1899
+ if (!activeJob && platform === 'win32' && spec.nodeName === 'Qwen3.8-Flash-Next' && (_windowsPrepareState.status === 'running' || _windowsPrepareState.status === 'error')) {
1824
1900
  activeJob = {
1825
1901
  id: 'bubo_prepare',
1826
1902
  repoId: spec.windowsBuboRepo || spec.hfRepo,
1827
1903
  folderName: spec.nodeName,
1828
1904
  label: spec.label,
1829
- status: 'downloading',
1905
+ status: _windowsPrepareState.status === 'error' ? 'failed' : 'downloading',
1906
+ error: _windowsPrepareState.error || '',
1830
1907
  progress: _windowsPrepareState.progress || 5,
1831
1908
  downloadedBytes: 0,
1832
1909
  totalBytes: 0,
1833
- currentFile: _windowsPrepareState.message || 'Подготовка Halowin Bubo…',
1910
+ currentFile: _windowsPrepareState.message || 'Установка движка Halowin Bubo…',
1834
1911
  sourceLabel: 'Halowin Bubo (ROCm 10.0)',
1835
1912
  speedMBs: 0,
1836
1913
  avgSpeedMBs: 0,
1837
1914
  };
1838
1915
  }
1839
1916
 
1840
- const weightsDownloaded = hasBuboReady || (!activeJob && !wInsp.pendingDownload && wInsp.hasReadyWeights && !wInsp.incompatibleOnPlatform);
1917
+ const weightsDownloaded = !activeJob && !wInsp.pendingDownload && wInsp.hasReadyWeights && !wInsp.incompatibleOnPlatform;
1841
1918
 
1842
1919
  return {
1843
1920
  ...spec,
1844
1921
  nodeConfigured,
1845
- weightsDir: path.relative(rootDir, hasBuboReady ? path.dirname(winEnv.buboManifestPath) : weightsDir).replace(/\\/g, '/'),
1922
+ weightsDir: path.relative(rootDir, weightsDir).replace(/\\/g, '/'),
1846
1923
  weightsDownloaded,
1847
- incompatibleOnPlatform: !hasBuboReady && wInsp.incompatibleOnPlatform,
1848
- incompatibleReason: !hasBuboReady ? wInsp.incompatibleReason : '',
1924
+ incompatibleOnPlatform: wInsp.incompatibleOnPlatform,
1925
+ incompatibleReason: wInsp.incompatibleReason || '',
1849
1926
  downloadedFiles: wInsp.files,
1850
1927
  activeDownload: activeJob,
1851
1928
  };
@@ -1902,51 +1979,48 @@ export async function downloadHalogenBundle({
1902
1979
  let alreadyActiveCount = 0;
1903
1980
 
1904
1981
  for (const spec of targets) {
1905
- if (spec.runtimeType === 'bubo') {
1906
- if (_windowsPrepareState.status === 'running') {
1907
- alreadyActiveCount++;
1908
- jobs.push({
1909
- id: 'bubo_prepare',
1910
- folderName: spec.nodeName,
1911
- status: 'downloading',
1912
- progress: _windowsPrepareState.progress,
1913
- });
1914
- }
1915
- else {
1916
- const runPrep = prepareWindowsBuboRuntime({
1917
- rootDir,
1918
- step: 'all',
1919
- modelSet: 'original',
1920
- fetchImpl,
1921
- });
1922
- if (waitForCompletion) {
1923
- const res = await runPrep;
1924
- if (!res.ok)
1925
- throw new Error(res.error || 'Не удалось подготовить Halowin Bubo');
1926
- }
1927
- else {
1928
- runPrep.catch(() => {});
1929
- }
1930
- startedCount++;
1931
- jobs.push({
1932
- id: 'bubo_prepare',
1933
- folderName: spec.nodeName,
1934
- status: _windowsPrepareState.status === 'completed' ? 'completed' : 'downloading',
1935
- progress: _windowsPrepareState.progress,
1936
- });
1937
- }
1938
- continue;
1939
- }
1940
-
1941
1982
  const running = existingDownloads.find(d =>
1942
1983
  d.status === 'downloading'
1943
- && (d.repoId === spec.hfRepo || d.folderName === spec.nodeName || d.modelPath === spec.path)
1984
+ && (d.repoId === spec.hfRepo || (spec.windowsBuboRepo && d.repoId === spec.windowsBuboRepo) || d.folderName === spec.nodeName || d.modelPath === spec.path)
1944
1985
  );
1945
1986
  if (running) {
1946
1987
  alreadyActiveCount++;
1947
1988
  jobs.push(running);
1948
1989
  continue;
1949
1990
  }
1991
+
1992
+ if (spec.runtimeType === 'bubo') {
1993
+ const job = await startHuggingFaceDownload({
1994
+ repoId: spec.windowsBuboRepo || 'unsloth/Qwen3.8-Flash-Next-GGUF',
1995
+ customFiles: QWEN_FLASH_NEXT_GGUF_FILES,
1996
+ onComplete: ({ rootDir: rd }) => ensureWindowsBuboEngineInstalled({ rootDir: rd, fetchImpl }),
1997
+ providerFolder: 'Local',
1998
+ targetNodeName: spec.nodeName,
1999
+ platform,
2000
+ nodeMeta: {
2001
+ label: spec.label || spec.nodeName,
2002
+ model: spec.model,
2003
+ protocol: 'halogen',
2004
+ icon: spec.icon || 'ai:qwen',
2005
+ modality: spec.modality,
2006
+ capabilities: spec.capabilities,
2007
+ efforts: spec.efforts,
2008
+ maxTokens: spec.maxTokens,
2009
+ maxOutput: spec.maxOutput,
2010
+ baseUrl: spec.baseUrl || HALOGEN_DEFAULT_BASE_URL,
2011
+ primaryFile: 'Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf',
2012
+ },
2013
+ rootDir,
2014
+ token,
2015
+ registerInWork: true,
2016
+ waitForCompletion,
2017
+ fetchImpl,
2018
+ });
2019
+ startedCount++;
2020
+ jobs.push(job);
2021
+ continue;
2022
+ }
2023
+
1950
2024
  const job = await startHuggingFaceDownload({
1951
2025
  repoId: spec.hfRepo,
1952
2026
  providerFolder: 'Local',