odant-work 1.0.28 → 1.0.30
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 +43 -37
- package/$server/$folder/$class/ai/agents/builder.md +34 -24
- package/$server/$folder/$class/ai/agents/org-architect.md +40 -0
- package/$server/$folder/$class/ai/agents/readme.md +3 -1
- package/$server/$folder/$class/ai/agents/schema-validator.md +35 -0
- package/$server/$folder/$class/ai/skills/accounting-design.md +21 -0
- package/$server/$folder/$class/ai/skills/data-modeling.md +25 -0
- package/$server/$folder/$class/ai/skills/readme.md +3 -0
- package/$server/$folder/$class/ai/skills/schema-migration.md +23 -0
- package/$server/$folder/$class/handlers/pages/form/objects/$handler/objects.js +2 -0
- 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/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/util.js +4 -0
- package/$server/$folder/lib/consultant/consultant.js +1 -1
- package/$server/$folder/lib/tree/tree.js +2 -1
- package/MODELS/$ai/$folder/$class/$ai/class.js +17 -3
- package/MODELS/$ai/$folder/$class/$ai/handlers/pages/form/trainer/$handler/trainer.js +103 -6
- package/MODELS/$ai/$folder/$class/$provider/handlers/pages/form/trainer/$handler/trainer.js +37 -14
- package/oda/components/layouts/editor-form/editor-form.js +16 -3
- package/package.json +1 -1
- package/sources/data/progress.md +21 -0
- package/sources/data/schema.js +66 -2
- package/sources/host/auto-updater.js +1 -1
- package/sources/modules/agent/index.js +5 -4
- package/sources/modules/agent/tools/docs.js +1 -1
- package/sources/modules/agent/tools/meta.js +5 -1
- package/sources/modules/agent/tools/work/classes.js +1081 -0
- package/sources/modules/agent/tools/work/fs.js +1 -1
- package/sources/modules/agent/tools/work.js +1 -0
- package/sources/modules/trainer/halogen.js +350 -32
- package/sources/modules/trainer/huggingface.js +80 -6
- package/sources/modules/trainer/index.js +139 -3
- package/sources/modules/trainer/local-engine.js +26 -29
- package/sources/modules/trainer/paths.js +119 -0
- package/sources/modules/trainer/providers.js +51 -36
- package/sources/modules/trainer/runner.js +72 -31
- package/sources/server/class/security.js +10 -3
- package/sources/server/class.js +6 -0
|
@@ -180,7 +180,7 @@ export const write = {
|
|
|
180
180
|
await trackWrite(ctx, real, log, pre);
|
|
181
181
|
const req = absPath(args.path, ctx);
|
|
182
182
|
return (before == null ? 'создан ' : 'перезаписан ') + real + ' (' + String(args.content).length + ' символов)'
|
|
183
|
-
+ (real !== req ? '
|
|
183
|
+
+ (real !== req ? ' (помещён в папку задачи — в ссылках и дальнейших вызовах используй только этот путь)' : '');
|
|
184
184
|
},
|
|
185
185
|
};
|
|
186
186
|
|
|
@@ -14,6 +14,7 @@ import * as FEED_TOOLS from './work/feed.js';
|
|
|
14
14
|
// общие вызовы для остальных модулей (session.js, mcp/server.js, tools/sandbox.js, os-files.js, meta.js, docs.js)
|
|
15
15
|
export { forceTaskContext, TASK_WRITE_METHODS, absPath, contextConeOf, checkContextCone, assertContextCone, getItem, callAs, writeFile, writeBinary, resolvePeople, markUntrustedByPaths } from './work/common.js';
|
|
16
16
|
export { accountingTools } from './work/data.js';
|
|
17
|
+
export { classTools } from './work/classes.js';
|
|
17
18
|
|
|
18
19
|
export const workTools = [
|
|
19
20
|
FS_TOOLS.ls, FS_TOOLS.read, FS_TOOLS.find, DATA_TOOLS.search,
|
|
@@ -42,6 +42,8 @@ import {
|
|
|
42
42
|
modelWeightsDir,
|
|
43
43
|
modelClassFile,
|
|
44
44
|
migrateLocalModelsLayoutSync,
|
|
45
|
+
inspectWeightsDirectorySync,
|
|
46
|
+
getFreeDiskSpaceGb,
|
|
45
47
|
WEIGHT_FILE_EXT_RE,
|
|
46
48
|
} from './paths.js';
|
|
47
49
|
|
|
@@ -81,6 +83,8 @@ export const HALOGEN_MODELS_CATALOG = Object.freeze([
|
|
|
81
83
|
windowsBuboRepo: 'unsloth/Qwen3.8-Flash-Next-GGUF',
|
|
82
84
|
windowsBuboTwinRepo: 'HaloForgeLabs/bubo-qwen3.8-flash-next',
|
|
83
85
|
ggufFallbackRepo: 'unsloth/Qwen3.8-Flash-Next-GGUF',
|
|
86
|
+
platforms: ['linux', 'win32'],
|
|
87
|
+
windowsRamGb: 116.6,
|
|
84
88
|
device: 'iGPU (Radeon 8060S/8065S · gfx1151)',
|
|
85
89
|
modality: 'llm',
|
|
86
90
|
maxTokens: 262144,
|
|
@@ -91,6 +95,7 @@ export const HALOGEN_MODELS_CATALOG = Object.freeze([
|
|
|
91
95
|
efforts: ['off', 'low', 'medium', 'high'],
|
|
92
96
|
capabilities: ['chat', 'stream', 'tools', 'functions', 'vision', 'effort', 'thinking', 'fork'],
|
|
93
97
|
role: 'Основная агентская модель (`ai/config.js → model`): 180B MoE (Linux: Halogen 4.16 bpw / Windows: Halowin Bubo UD-Q4_K_XL + Dense Twin + MTP Draft Head, 57–94 tok/s decode, ~1415–1800 tok/s prefill)',
|
|
98
|
+
windowsRole: 'Основная агентская модель 180B MoE для Windows 11 Strix Halo через встроенный движок Halowin Bubo (UD-Q4_K_XL GGUF + MTP + Dense Twin + Vision, ~116.6 ГБ + ROCm 10.0)',
|
|
94
99
|
},
|
|
95
100
|
{
|
|
96
101
|
nodeName: 'Qwen3.5-2B-NPU',
|
|
@@ -100,6 +105,7 @@ export const HALOGEN_MODELS_CATALOG = Object.freeze([
|
|
|
100
105
|
baseUrl: 'http://127.0.0.1:8731/v1/chat/completions',
|
|
101
106
|
model: 'qwen3.5-2b',
|
|
102
107
|
hfRepo: 'peonist-ai/halogen-npu-qwen3.5-2b',
|
|
108
|
+
platforms: ['linux'],
|
|
103
109
|
device: 'NPU (Ryzen AI 55 TOPS)',
|
|
104
110
|
modality: 'llm',
|
|
105
111
|
maxTokens: 32768,
|
|
@@ -116,6 +122,7 @@ export const HALOGEN_MODELS_CATALOG = Object.freeze([
|
|
|
116
122
|
baseUrl: 'http://127.0.0.1:8731/v1/audio/transcriptions',
|
|
117
123
|
model: 'qwen3-asr-1.7b',
|
|
118
124
|
hfRepo: 'peonist-ai/halogen-npu-qwen3-asr-1.7b',
|
|
125
|
+
platforms: ['linux'],
|
|
119
126
|
gufoService: 'asr',
|
|
120
127
|
device: 'NPU (Ryzen AI 55 TOPS)',
|
|
121
128
|
modality: 'audio',
|
|
@@ -133,6 +140,7 @@ export const HALOGEN_MODELS_CATALOG = Object.freeze([
|
|
|
133
140
|
baseUrl: 'http://127.0.0.1:8731/v1/audio/speech',
|
|
134
141
|
model: 'qwen3-tts-1.7b-customvoice',
|
|
135
142
|
hfRepo: 'peonist-ai/halogen-npu-qwen3-tts-1.7b-customvoice',
|
|
143
|
+
platforms: ['linux'],
|
|
136
144
|
gufoService: 'tts',
|
|
137
145
|
device: 'NPU (Ryzen AI 55 TOPS)',
|
|
138
146
|
modality: 'audio',
|
|
@@ -150,6 +158,7 @@ export const HALOGEN_MODELS_CATALOG = Object.freeze([
|
|
|
150
158
|
baseUrl: 'http://127.0.0.1:8731/v1/images/generations',
|
|
151
159
|
model: 'flux2-klein-4b',
|
|
152
160
|
hfRepo: 'peonist-ai/halogen-npu-flux2-klein-4b',
|
|
161
|
+
platforms: ['linux'],
|
|
153
162
|
gufoService: 'image',
|
|
154
163
|
device: 'NPU (Ryzen AI 55 TOPS)',
|
|
155
164
|
modality: 'image',
|
|
@@ -167,6 +176,7 @@ export const HALOGEN_MODELS_CATALOG = Object.freeze([
|
|
|
167
176
|
baseUrl: 'http://127.0.0.1:8731/v1/embeddings',
|
|
168
177
|
model: 'qwen3-embedding-0.6b',
|
|
169
178
|
hfRepo: 'peonist-ai/halogen-npu-qwen3-embedding-0.6b',
|
|
179
|
+
platforms: ['linux'],
|
|
170
180
|
gufoService: 'embedding',
|
|
171
181
|
device: 'NPU (Ryzen AI 55 TOPS)',
|
|
172
182
|
modality: 'embed',
|
|
@@ -184,6 +194,7 @@ export const HALOGEN_MODELS_CATALOG = Object.freeze([
|
|
|
184
194
|
baseUrl: 'http://127.0.0.1:8731/v1/rerank',
|
|
185
195
|
model: 'qwen3-reranker-0.6b',
|
|
186
196
|
hfRepo: 'peonist-ai/halogen-npu-qwen3-reranker-0.6b',
|
|
197
|
+
platforms: ['linux'],
|
|
187
198
|
device: 'NPU (Ryzen AI 55 TOPS)',
|
|
188
199
|
modality: 'embed',
|
|
189
200
|
maxTokens: 8192,
|
|
@@ -200,6 +211,7 @@ export const HALOGEN_MODELS_CATALOG = Object.freeze([
|
|
|
200
211
|
baseUrl: 'http://127.0.0.1:8731/v1/systemone',
|
|
201
212
|
model: 'decider-0.8b',
|
|
202
213
|
hfRepo: 'peonist-ai/halogen-npu-decider-0.8b',
|
|
214
|
+
platforms: ['linux'],
|
|
203
215
|
gufoService: 'decision',
|
|
204
216
|
device: 'NPU (Ryzen AI 55 TOPS)',
|
|
205
217
|
modality: 'llm',
|
|
@@ -211,6 +223,25 @@ export const HALOGEN_MODELS_CATALOG = Object.freeze([
|
|
|
211
223
|
},
|
|
212
224
|
]);
|
|
213
225
|
|
|
226
|
+
/**
|
|
227
|
+
* Вернуть каталог моделей Halo, совместимый с указанной ОС (`win32` или `linux`).
|
|
228
|
+
* На Windows не возвращаем Linux-only модели `.hnpw`, а для `Qwen3.8-Flash-Next` указываем GGUF/Bubo-стек.
|
|
229
|
+
*/
|
|
230
|
+
export function getHalogenCatalogForPlatform(platform = os.platform()) {
|
|
231
|
+
const isWin = platform === 'win32';
|
|
232
|
+
return HALOGEN_MODELS_CATALOG
|
|
233
|
+
.filter(spec => !Array.isArray(spec.platforms) || spec.platforms.includes(platform))
|
|
234
|
+
.map(spec => isWin
|
|
235
|
+
? {
|
|
236
|
+
...spec,
|
|
237
|
+
hfRepo: spec.windowsBuboRepo || spec.hfRepo,
|
|
238
|
+
ramGb: spec.windowsRamGb || spec.ramGb,
|
|
239
|
+
role: spec.windowsRole || spec.role,
|
|
240
|
+
runtimeType: 'bubo',
|
|
241
|
+
}
|
|
242
|
+
: { ...spec, runtimeType: 'halogen-linux' });
|
|
243
|
+
}
|
|
244
|
+
|
|
214
245
|
/** Допустимые пресетные голоса `qwen3-tts-*-customvoice` в Halogen NPU. */
|
|
215
246
|
export const HALOGEN_TTS_VOICES = new Set([
|
|
216
247
|
'aiden', 'dylan', 'eric', 'ono_anna', 'ryan', 'serena', 'sohee', 'uncle_fu', 'vivian',
|
|
@@ -825,6 +856,45 @@ function findLocalGgufModel(rootDir = process.cwd()) {
|
|
|
825
856
|
return null;
|
|
826
857
|
}
|
|
827
858
|
|
|
859
|
+
/**
|
|
860
|
+
* Проверить системные требования Windows 11 перед загрузкой тяжёлого стека Halowin Bubo (диск, RAM+UMA, PageFile).
|
|
861
|
+
*/
|
|
862
|
+
export function checkWindowsHalogenPreflight({
|
|
863
|
+
rootDir = process.cwd(),
|
|
864
|
+
requiredDiskGb = 120,
|
|
865
|
+
minTotalMemoryGb = 96,
|
|
866
|
+
totalMemoryGb = null,
|
|
867
|
+
} = {}) {
|
|
868
|
+
const winEnv = inspectWindowsHalogenEnvironment({ rootDir });
|
|
869
|
+
const freeDiskGb = getFreeDiskSpaceGb(rootDir);
|
|
870
|
+
const warnings = [];
|
|
871
|
+
const errors = [];
|
|
872
|
+
|
|
873
|
+
if (freeDiskGb !== null && requiredDiskGb > 0 && freeDiskGb < requiredDiskGb) {
|
|
874
|
+
errors.push(`Недостаточно свободного места на диске: доступно ${freeDiskGb} ГБ, требуется не менее ${requiredDiskGb} ГБ.`);
|
|
875
|
+
}
|
|
876
|
+
if (totalMemoryGb !== null && minTotalMemoryGb > 0 && totalMemoryGb < minTotalMemoryGb) {
|
|
877
|
+
errors.push(`Недостаточно общей памяти (RAM + UMA): обнаружено ${totalMemoryGb} ГБ, для 180B модели требуется не менее ${minTotalMemoryGb} ГБ (рекомендуется 128–192 ГБ). Используйте компактную модель (например, Qwen3-30B-A3B или Qwen3-14B).`);
|
|
878
|
+
}
|
|
879
|
+
if (winEnv.pageFileOk === false) {
|
|
880
|
+
warnings.push(`Файл подкачки pagefile.sys равен ${winEnv.pageFileGb} ГБ; для стабильной работы 180B модели на Windows рекомендуется фиксированный PageFile 128 ГБ (131072 МБ).`);
|
|
881
|
+
}
|
|
882
|
+
if (!winEnv.vcRedistInstalled) {
|
|
883
|
+
warnings.push('Не обнаружена библиотека Microsoft VC++ 2015–2022 Redistributable (vcruntime140.dll) — её нужно установить для запуска bubo.exe.');
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
return {
|
|
887
|
+
ok: errors.length === 0,
|
|
888
|
+
freeDiskGb,
|
|
889
|
+
requiredDiskGb,
|
|
890
|
+
totalMemoryGb,
|
|
891
|
+
minTotalMemoryGb,
|
|
892
|
+
errors,
|
|
893
|
+
warnings,
|
|
894
|
+
windowsEnv: winEnv,
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
|
|
828
898
|
/**
|
|
829
899
|
* Скачать и подготовить нативный Windows-движок `Halowin Bubo` (`bubo-v0.1.2-windows-x64-gfx1151.zip`),
|
|
830
900
|
* официальный рантайм AMD ROCm 10.0.0 (`gfx1151`) и пакет весов `Qwen3.8-Flash-Next` (`UD-Q4_K_XL` + `Dense Twin` + `MTP`).
|
|
@@ -862,23 +932,41 @@ export async function prepareWindowsBuboRuntime({
|
|
|
862
932
|
if (_windowsPrepareState.logs.length > 80)
|
|
863
933
|
_windowsPrepareState.logs.shift();
|
|
864
934
|
_windowsPrepareState.message = clean;
|
|
935
|
+
const pctMatch = clean.match(/\b(\d{1,3})%/);
|
|
936
|
+
if (pctMatch && (step === 'model' || step === 'all')) {
|
|
937
|
+
const pct = Math.min(99, Math.max(0, Number(pctMatch[1])));
|
|
938
|
+
if (pct > _windowsPrepareState.progress)
|
|
939
|
+
_windowsPrepareState.progress = pct;
|
|
940
|
+
}
|
|
865
941
|
_windowsPrepareState.updatedAt = Date.now();
|
|
866
942
|
};
|
|
867
943
|
|
|
868
944
|
try {
|
|
945
|
+
if ((step === 'model' || step === 'all') && spawnImpl === spawn) {
|
|
946
|
+
const freeGb = getFreeDiskSpaceGb(rootDir);
|
|
947
|
+
if (freeGb !== null && freeGb < 118) {
|
|
948
|
+
throw new Error(`Недостаточно свободного места на диске для установки Qwen3.8-Flash-Next (Bubo GGUF): свободно ${freeGb} ГБ, требуется ~120 ГБ.`);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
const netCfg = loadTrainerNetworkSettings(rootDir);
|
|
953
|
+
const childEnv = {
|
|
954
|
+
...process.env,
|
|
955
|
+
...(netCfg.proxyUrl ? { HTTPS_PROXY: netCfg.proxyUrl, HTTP_PROXY: netCfg.proxyUrl } : {}),
|
|
956
|
+
};
|
|
957
|
+
|
|
869
958
|
let envInfo = inspectWindowsHalogenEnvironment({ rootDir });
|
|
870
959
|
|
|
871
960
|
// Шаг 1: Если `bubo.exe` ещё не установлен, скачиваем официальный релиз `bubo-v0.1.2-windows-x64-gfx1151.zip`
|
|
872
961
|
if (!envInfo.buboInstalled || step === 'download-bubo') {
|
|
873
962
|
const zipPath = path.join(runtimeRoot, BUBO_WINDOWS_RELEASE.zipFileName);
|
|
874
|
-
const netCfg = loadTrainerNetworkSettings(rootDir);
|
|
875
963
|
const effProxy = fetchImpl === globalThis.fetch ? netCfg.proxyUrl : '';
|
|
876
964
|
const netFetch = createNetworkFetch({ proxyUrl: effProxy, fetchImpl });
|
|
877
965
|
|
|
878
966
|
appendLog(`Скачивание ${BUBO_WINDOWS_RELEASE.zipFileName} (${(BUBO_WINDOWS_RELEASE.sizeBytes / (1024 * 1024)).toFixed(1)} МБ, ${netCfg.threads} потоков)…`);
|
|
879
|
-
_windowsPrepareState.progress =
|
|
967
|
+
_windowsPrepareState.progress = 10;
|
|
880
968
|
|
|
881
|
-
|
|
969
|
+
await downloadFileMultipart({
|
|
882
970
|
url: BUBO_WINDOWS_RELEASE.downloadUrl,
|
|
883
971
|
stagedFile: zipPath,
|
|
884
972
|
expectedSize: BUBO_WINDOWS_RELEASE.sizeBytes,
|
|
@@ -887,7 +975,7 @@ export async function prepareWindowsBuboRuntime({
|
|
|
887
975
|
onProgress: ({ downloadedBytes, totalBytes }) => {
|
|
888
976
|
const denom = totalBytes || BUBO_WINDOWS_RELEASE.sizeBytes;
|
|
889
977
|
if (denom > 0)
|
|
890
|
-
_windowsPrepareState.progress = Math.min(
|
|
978
|
+
_windowsPrepareState.progress = Math.min(25, 10 + Math.round((downloadedBytes / denom) * 15));
|
|
891
979
|
},
|
|
892
980
|
});
|
|
893
981
|
|
|
@@ -909,7 +997,7 @@ export async function prepareWindowsBuboRuntime({
|
|
|
909
997
|
|
|
910
998
|
await fsp.mkdir(buboDir, { recursive: true });
|
|
911
999
|
appendLog('Распаковка архива Halowin Bubo…');
|
|
912
|
-
_windowsPrepareState.progress =
|
|
1000
|
+
_windowsPrepareState.progress = 28;
|
|
913
1001
|
|
|
914
1002
|
let isPkZip = false;
|
|
915
1003
|
try {
|
|
@@ -940,7 +1028,7 @@ export async function prepareWindowsBuboRuntime({
|
|
|
940
1028
|
// Шаг 2: Установка официальных библиотек AMD ROCm 10.0.0 (`gfx1151`) через `bubo.exe prepare runtime --yes`
|
|
941
1029
|
if ((step === 'runtime' || step === 'all') && fs.existsSync(buboExe)) {
|
|
942
1030
|
appendLog('Загрузка официальных пакетов AMD ROCm 10.0.0 для gfx1151 (bubo prepare runtime --yes)…');
|
|
943
|
-
_windowsPrepareState.progress =
|
|
1031
|
+
_windowsPrepareState.progress = Math.max(_windowsPrepareState.progress, 35);
|
|
944
1032
|
await new Promise((resolve, reject) => {
|
|
945
1033
|
const proc = spawnImpl(buboExe, [
|
|
946
1034
|
'prepare', 'runtime',
|
|
@@ -948,6 +1036,7 @@ export async function prepareWindowsBuboRuntime({
|
|
|
948
1036
|
'--yes',
|
|
949
1037
|
], {
|
|
950
1038
|
cwd: path.dirname(buboExe),
|
|
1039
|
+
env: childEnv,
|
|
951
1040
|
windowsHide: true,
|
|
952
1041
|
});
|
|
953
1042
|
proc.stdout?.on('data', d => appendLog(d));
|
|
@@ -959,8 +1048,8 @@ export async function prepareWindowsBuboRuntime({
|
|
|
959
1048
|
|
|
960
1049
|
// Шаг 3: Подготовка 8 файлов модели Qwen3.8-Flash-Next (UD-Q4_K_XL + MTP + Dense Twin + Draft Head + Vision)
|
|
961
1050
|
if ((step === 'model' || step === 'all') && fs.existsSync(buboExe)) {
|
|
962
|
-
appendLog(`Подготовка модели Qwen3.8-Flash-Next (${modelSet}) через bubo prepare model…`);
|
|
963
|
-
_windowsPrepareState.progress =
|
|
1051
|
+
appendLog(`Подготовка модели Qwen3.8-Flash-Next (${modelSet}, ~116.6 ГБ) через bubo prepare model…`);
|
|
1052
|
+
_windowsPrepareState.progress = Math.max(_windowsPrepareState.progress, 45);
|
|
964
1053
|
const args = [
|
|
965
1054
|
'prepare', 'model',
|
|
966
1055
|
...(modelSet === 'original' ? ['--model-set', 'original'] : []),
|
|
@@ -970,6 +1059,7 @@ export async function prepareWindowsBuboRuntime({
|
|
|
970
1059
|
await new Promise((resolve, reject) => {
|
|
971
1060
|
const proc = spawnImpl(buboExe, args, {
|
|
972
1061
|
cwd: path.dirname(buboExe),
|
|
1062
|
+
env: childEnv,
|
|
973
1063
|
windowsHide: true,
|
|
974
1064
|
});
|
|
975
1065
|
proc.stdout?.on('data', d => appendLog(d));
|
|
@@ -977,6 +1067,36 @@ export async function prepareWindowsBuboRuntime({
|
|
|
977
1067
|
proc.on('error', reject);
|
|
978
1068
|
proc.on('close', code => code === 0 ? resolve() : reject(new Error(`bubo prepare model завершился с кодом ${code}`)));
|
|
979
1069
|
});
|
|
1070
|
+
|
|
1071
|
+
const afterEnv = inspectWindowsHalogenEnvironment({ rootDir });
|
|
1072
|
+
const flashSpec = HALOGEN_MODELS_CATALOG.find(m => m.nodeName === 'Qwen3.8-Flash-Next');
|
|
1073
|
+
if (flashSpec) {
|
|
1074
|
+
const wDir = afterEnv.buboManifestPath
|
|
1075
|
+
? path.dirname(afterEnv.buboManifestPath)
|
|
1076
|
+
: modelWeightsDir(rootDir, flashSpec.nodeName, 'Local');
|
|
1077
|
+
await registerLocalModelNode({
|
|
1078
|
+
rootDir,
|
|
1079
|
+
folderName: flashSpec.nodeName,
|
|
1080
|
+
label: flashSpec.label,
|
|
1081
|
+
repoId: flashSpec.windowsBuboRepo || 'unsloth/Qwen3.8-Flash-Next-GGUF',
|
|
1082
|
+
model: flashSpec.model,
|
|
1083
|
+
protocol: 'halogen',
|
|
1084
|
+
icon: flashSpec.icon || 'ai:qwen',
|
|
1085
|
+
modality: flashSpec.modality,
|
|
1086
|
+
capabilities: flashSpec.capabilities,
|
|
1087
|
+
efforts: flashSpec.efforts,
|
|
1088
|
+
maxTokens: flashSpec.maxTokens,
|
|
1089
|
+
maxOutput: flashSpec.maxOutput,
|
|
1090
|
+
baseUrl: flashSpec.baseUrl || HALOGEN_DEFAULT_BASE_URL,
|
|
1091
|
+
weightsDir: wDir,
|
|
1092
|
+
primaryFile: 'bubo-package.json',
|
|
1093
|
+
});
|
|
1094
|
+
try {
|
|
1095
|
+
const localNode = await globalThis.WORK?.get_item?.('/MODELS/Local');
|
|
1096
|
+
localNode?.reset?.();
|
|
1097
|
+
}
|
|
1098
|
+
catch { /* ignore */ }
|
|
1099
|
+
}
|
|
980
1100
|
}
|
|
981
1101
|
|
|
982
1102
|
_windowsPrepareState.status = 'completed';
|
|
@@ -1189,6 +1309,8 @@ export async function startHalogenBackend({
|
|
|
1189
1309
|
};
|
|
1190
1310
|
}
|
|
1191
1311
|
|
|
1312
|
+
let _backendStartPromise = null;
|
|
1313
|
+
|
|
1192
1314
|
export function stopHalogenBackend() {
|
|
1193
1315
|
if (_managedProc && !_managedProc.killed) {
|
|
1194
1316
|
try { _managedProc.kill(); } catch { /* ignore */ }
|
|
@@ -1198,6 +1320,118 @@ export function stopHalogenBackend() {
|
|
|
1198
1320
|
return { stopped: true };
|
|
1199
1321
|
}
|
|
1200
1322
|
|
|
1323
|
+
/**
|
|
1324
|
+
* Проверить готовность локального движка на порту `:8731` и при необходимости автоматически запустить его
|
|
1325
|
+
* внутри ядра WORK (Windows: `bubo.exe` / `gufo.exe` / `llama-server`).
|
|
1326
|
+
*/
|
|
1327
|
+
export async function ensureHalogenBackendRunning({
|
|
1328
|
+
rootDir = process.cwd(),
|
|
1329
|
+
baseUrl = HALOGEN_DEFAULT_BASE_URL,
|
|
1330
|
+
ai = null,
|
|
1331
|
+
waitTimeoutMs = 20000,
|
|
1332
|
+
platform = os.platform(),
|
|
1333
|
+
spawnImpl = spawn,
|
|
1334
|
+
} = {}) {
|
|
1335
|
+
let port = HALOGEN_DEFAULT_PORT;
|
|
1336
|
+
try {
|
|
1337
|
+
const u = new URL(baseUrl || HALOGEN_DEFAULT_BASE_URL);
|
|
1338
|
+
if (u.port)
|
|
1339
|
+
port = Number(u.port) || HALOGEN_DEFAULT_PORT;
|
|
1340
|
+
}
|
|
1341
|
+
catch { /* default */ }
|
|
1342
|
+
|
|
1343
|
+
const probe1 = await probeHalogenServer(baseUrl, { rootDir });
|
|
1344
|
+
if (probe1.online) {
|
|
1345
|
+
return {
|
|
1346
|
+
ready: true,
|
|
1347
|
+
alreadyRunning: true,
|
|
1348
|
+
mode: probe1.mode,
|
|
1349
|
+
origin: probe1.origin,
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
// Проверка на несовместимые Linux-веса (.hgn / .hnpw) на Windows
|
|
1354
|
+
const modelFolderName = String(ai?.id || ai?.path || '').split('/').filter(Boolean).pop() || '';
|
|
1355
|
+
const candidateWeightsDir = ai?.weightsDir
|
|
1356
|
+
? path.resolve(rootDir, ai.weightsDir)
|
|
1357
|
+
: (modelFolderName ? modelWeightsDir(rootDir, modelFolderName, 'Local') : '');
|
|
1358
|
+
const wInsp = candidateWeightsDir ? inspectWeightsDirectorySync(candidateWeightsDir, platform) : null;
|
|
1359
|
+
const winEnv = inspectWindowsHalogenEnvironment({ rootDir });
|
|
1360
|
+
|
|
1361
|
+
if (platform === 'win32' && wInsp?.incompatibleOnPlatform && !winEnv.buboModelPrepared) {
|
|
1362
|
+
return {
|
|
1363
|
+
ready: false,
|
|
1364
|
+
code: 'INCOMPATIBLE_FORMAT',
|
|
1365
|
+
reason: wInsp.incompatibleReason,
|
|
1366
|
+
weightsDir: candidateWeightsDir,
|
|
1367
|
+
};
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
if (_backendStartPromise)
|
|
1371
|
+
return _backendStartPromise;
|
|
1372
|
+
|
|
1373
|
+
_backendStartPromise = (async () => {
|
|
1374
|
+
try {
|
|
1375
|
+
const explicitGguf = (wInsp?.hasGguf && candidateWeightsDir)
|
|
1376
|
+
? path.join(candidateWeightsDir, wInsp.files.filter(f => f.toLowerCase().endsWith('.gguf') && !/mtp|mmproj/i.test(f)).sort()[0] || '')
|
|
1377
|
+
: '';
|
|
1378
|
+
|
|
1379
|
+
const startRes = await startHalogenBackend({
|
|
1380
|
+
rootDir,
|
|
1381
|
+
port,
|
|
1382
|
+
modelPath: explicitGguf && fs.existsSync(explicitGguf) ? explicitGguf : '',
|
|
1383
|
+
spawnImpl,
|
|
1384
|
+
});
|
|
1385
|
+
|
|
1386
|
+
if (startRes.mode === 'work-embedded-fallback') {
|
|
1387
|
+
const code = platform === 'win32'
|
|
1388
|
+
? (winEnv.buboInstalled ? 'MODEL_MISSING' : 'RUNTIME_MISSING')
|
|
1389
|
+
: 'SERVER_OFFLINE';
|
|
1390
|
+
return {
|
|
1391
|
+
ready: false,
|
|
1392
|
+
code,
|
|
1393
|
+
reason: startRes.note,
|
|
1394
|
+
windowsEnv: winEnv,
|
|
1395
|
+
};
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
const deadline = Date.now() + Math.max(2000, Number(waitTimeoutMs) || 20000);
|
|
1399
|
+
while (Date.now() < deadline) {
|
|
1400
|
+
if (!_managedProc && startRes.started && !startRes.alreadyRunning) {
|
|
1401
|
+
return {
|
|
1402
|
+
ready: false,
|
|
1403
|
+
code: 'PROCESS_EXITED',
|
|
1404
|
+
reason: 'Встроенный движок ИИ завершился сразу после запуска (проверьте наличие VC++ Redistributable, драйвера AMD и PageFile 128 ГБ).',
|
|
1405
|
+
windowsEnv: winEnv,
|
|
1406
|
+
};
|
|
1407
|
+
}
|
|
1408
|
+
const probe2 = await probeHalogenServer(baseUrl, { rootDir });
|
|
1409
|
+
if (probe2.online) {
|
|
1410
|
+
return {
|
|
1411
|
+
ready: true,
|
|
1412
|
+
alreadyRunning: false,
|
|
1413
|
+
mode: probe2.mode,
|
|
1414
|
+
origin: probe2.origin,
|
|
1415
|
+
};
|
|
1416
|
+
}
|
|
1417
|
+
await new Promise(r => setTimeout(r, 500));
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
return {
|
|
1421
|
+
ready: false,
|
|
1422
|
+
code: 'START_TIMEOUT',
|
|
1423
|
+
reason: `Встроенный движок (${startRes.runtime || startRes.mode}) запущен, но ещё загружает веса модели в память. Повторите запрос через 15–30 секунд.`,
|
|
1424
|
+
windowsEnv: winEnv,
|
|
1425
|
+
};
|
|
1426
|
+
}
|
|
1427
|
+
finally {
|
|
1428
|
+
_backendStartPromise = null;
|
|
1429
|
+
}
|
|
1430
|
+
})();
|
|
1431
|
+
|
|
1432
|
+
return _backendStartPromise;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1201
1435
|
/**
|
|
1202
1436
|
* Сгенерировать валидный WAV-буфер (24 кГц, 16 бит, моно) для автономного фоллбэка TTS,
|
|
1203
1437
|
* когда внешний сервер `:8731` (`halogen-flash-server` на Linux или `gufo serve tts` на Windows) не запущен.
|
|
@@ -1420,56 +1654,77 @@ export async function ensureHalogenModelNodes(rootDir = process.cwd(), { models
|
|
|
1420
1654
|
}
|
|
1421
1655
|
|
|
1422
1656
|
/**
|
|
1423
|
-
* Проверить наличие скачанных весов и узлов `$ai` для каждой модели
|
|
1657
|
+
* Проверить наличие скачанных весов и узлов `$ai` для каждой модели Halo, совместимой с текущей ОС.
|
|
1424
1658
|
*/
|
|
1425
|
-
export function inspectHalogenCatalogWithStatus(rootDir = process.cwd()) {
|
|
1659
|
+
export function inspectHalogenCatalogWithStatus(rootDir = process.cwd(), { platform = os.platform() } = {}) {
|
|
1426
1660
|
migrateLocalModelsLayoutSync(rootDir);
|
|
1427
1661
|
const activeDownloads = listHuggingFaceDownloads(rootDir);
|
|
1428
|
-
|
|
1662
|
+
const winEnv = platform === 'win32' ? inspectWindowsHalogenEnvironment({ rootDir }) : null;
|
|
1663
|
+
const catalog = getHalogenCatalogForPlatform(platform);
|
|
1664
|
+
|
|
1665
|
+
return catalog.map(spec => {
|
|
1429
1666
|
const localWeightsDir = modelWeightsDir(rootDir, spec.nodeName, 'Local');
|
|
1430
1667
|
const legacyLocalDir = path.join(rootDir, 'MODELS', 'Local', spec.nodeName, '#weights');
|
|
1431
1668
|
const legacyHalogenDir = path.join(rootDir, 'MODELS', 'Halogen', spec.nodeName, '#weights');
|
|
1432
1669
|
const weightsDir = fs.existsSync(localWeightsDir) ? localWeightsDir
|
|
1433
1670
|
: (fs.existsSync(legacyLocalDir) ? legacyLocalDir
|
|
1434
1671
|
: (fs.existsSync(legacyHalogenDir) ? legacyHalogenDir : localWeightsDir));
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
downloadedFiles = rawEntries
|
|
1442
|
-
.filter(f => !f.endsWith('.part') && f !== 'hf-manifest.json' && f !== 'download-state.json' && !f.endsWith('.tmp'));
|
|
1443
|
-
}
|
|
1444
|
-
catch { /* ignore */ }
|
|
1445
|
-
}
|
|
1672
|
+
|
|
1673
|
+
const wInsp = inspectWeightsDirectorySync(weightsDir, platform);
|
|
1674
|
+
const hasBuboReady = platform === 'win32'
|
|
1675
|
+
&& spec.nodeName === 'Qwen3.8-Flash-Next'
|
|
1676
|
+
&& Boolean(winEnv?.buboModelPrepared && winEnv?.buboManifestPath);
|
|
1677
|
+
|
|
1446
1678
|
const nodeConfigured = fs.existsSync(modelClassFile(rootDir, spec.nodeName, 'Local'));
|
|
1447
|
-
|
|
1679
|
+
let activeJob = activeDownloads.find(d =>
|
|
1448
1680
|
(d.status === 'downloading' || d.status === 'paused' || d.status === 'failed')
|
|
1449
1681
|
&& (d.repoId === spec.hfRepo || d.folderName === spec.nodeName || d.modelPath === spec.path)
|
|
1450
1682
|
) || null;
|
|
1451
|
-
|
|
1683
|
+
|
|
1684
|
+
if (!activeJob && platform === 'win32' && spec.nodeName === 'Qwen3.8-Flash-Next' && _windowsPrepareState.status === 'running') {
|
|
1685
|
+
activeJob = {
|
|
1686
|
+
id: 'bubo_prepare',
|
|
1687
|
+
repoId: spec.windowsBuboRepo || spec.hfRepo,
|
|
1688
|
+
folderName: spec.nodeName,
|
|
1689
|
+
label: spec.label,
|
|
1690
|
+
status: 'downloading',
|
|
1691
|
+
progress: _windowsPrepareState.progress || 5,
|
|
1692
|
+
downloadedBytes: 0,
|
|
1693
|
+
totalBytes: 0,
|
|
1694
|
+
currentFile: _windowsPrepareState.message || 'Подготовка Halowin Bubo…',
|
|
1695
|
+
sourceLabel: 'Halowin Bubo (ROCm 10.0)',
|
|
1696
|
+
speedMBs: 0,
|
|
1697
|
+
avgSpeedMBs: 0,
|
|
1698
|
+
};
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
const weightsDownloaded = hasBuboReady || (!activeJob && !wInsp.pendingDownload && wInsp.hasReadyWeights && !wInsp.incompatibleOnPlatform);
|
|
1702
|
+
|
|
1452
1703
|
return {
|
|
1453
1704
|
...spec,
|
|
1454
1705
|
nodeConfigured,
|
|
1455
|
-
weightsDir: path.relative(rootDir, weightsDir).replace(/\\/g, '/'),
|
|
1456
|
-
weightsDownloaded
|
|
1457
|
-
|
|
1706
|
+
weightsDir: path.relative(rootDir, hasBuboReady ? path.dirname(winEnv.buboManifestPath) : weightsDir).replace(/\\/g, '/'),
|
|
1707
|
+
weightsDownloaded,
|
|
1708
|
+
incompatibleOnPlatform: !hasBuboReady && wInsp.incompatibleOnPlatform,
|
|
1709
|
+
incompatibleReason: !hasBuboReady ? wInsp.incompatibleReason : '',
|
|
1710
|
+
downloadedFiles: wInsp.files,
|
|
1458
1711
|
activeDownload: activeJob,
|
|
1459
1712
|
};
|
|
1460
1713
|
});
|
|
1461
1714
|
}
|
|
1462
1715
|
|
|
1463
1716
|
/**
|
|
1464
|
-
* Поставить в очередь скачивание
|
|
1465
|
-
*
|
|
1466
|
-
*
|
|
1717
|
+
* Поставить в очередь скачивание совместимого с текущей ОС стека моделей Halo в `/MODELS/Local`:
|
|
1718
|
+
* - На Windows 11: проверяет диск/память и запускает нативную установку `Halowin Bubo` (ROCm 10.0.0 gfx1151 + GGUF 116.6 ГБ).
|
|
1719
|
+
* - На Linux: скачивает актуальные файлы `.hgn` + `.hnpw` для `halogen-flash-server`.
|
|
1467
1720
|
*/
|
|
1468
1721
|
export async function downloadHalogenBundle({
|
|
1469
1722
|
rootDir = process.cwd(),
|
|
1470
1723
|
models = null,
|
|
1471
1724
|
token = '',
|
|
1472
1725
|
waitForCompletion = false,
|
|
1726
|
+
platform = os.platform(),
|
|
1727
|
+
totalMemoryGb = null,
|
|
1473
1728
|
fetchImpl = globalThis.fetch,
|
|
1474
1729
|
} = {}) {
|
|
1475
1730
|
let filterList = null;
|
|
@@ -1480,11 +1735,73 @@ export async function downloadHalogenBundle({
|
|
|
1480
1735
|
filterList = new Set(models.split(',').map(m => m.trim()).filter(Boolean));
|
|
1481
1736
|
}
|
|
1482
1737
|
|
|
1738
|
+
const platformCatalog = getHalogenCatalogForPlatform(platform);
|
|
1483
1739
|
const targets = filterList
|
|
1484
|
-
?
|
|
1740
|
+
? platformCatalog.filter(m =>
|
|
1485
1741
|
filterList.has(m.nodeName) || filterList.has(m.model) || filterList.has(m.hfRepo) || filterList.has(m.path)
|
|
1486
1742
|
)
|
|
1487
|
-
: [...
|
|
1743
|
+
: [...platformCatalog];
|
|
1744
|
+
|
|
1745
|
+
if (platform === 'win32') {
|
|
1746
|
+
if (!targets.length) {
|
|
1747
|
+
throw new Error('Выбранная модель предназначена только для Linux (формат .hnpw/.hgn) и не поддерживается на Windows. Используйте совместимые Windows-модели из каталога.');
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
const preflight = checkWindowsHalogenPreflight({
|
|
1751
|
+
rootDir,
|
|
1752
|
+
requiredDiskGb: 120,
|
|
1753
|
+
minTotalMemoryGb: 96,
|
|
1754
|
+
totalMemoryGb,
|
|
1755
|
+
});
|
|
1756
|
+
if (!preflight.ok) {
|
|
1757
|
+
throw new Error(preflight.errors.join(' '));
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
if (_windowsPrepareState.status === 'running') {
|
|
1761
|
+
return {
|
|
1762
|
+
totalModels: targets.length,
|
|
1763
|
+
startedCount: 0,
|
|
1764
|
+
alreadyActiveCount: 1,
|
|
1765
|
+
mode: 'bubo-windows',
|
|
1766
|
+
preflight,
|
|
1767
|
+
jobs: [{
|
|
1768
|
+
id: 'bubo_prepare',
|
|
1769
|
+
folderName: 'Qwen3.8-Flash-Next',
|
|
1770
|
+
status: 'downloading',
|
|
1771
|
+
progress: _windowsPrepareState.progress,
|
|
1772
|
+
}],
|
|
1773
|
+
};
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
const runPrep = prepareWindowsBuboRuntime({
|
|
1777
|
+
rootDir,
|
|
1778
|
+
step: 'all',
|
|
1779
|
+
modelSet: 'original',
|
|
1780
|
+
fetchImpl,
|
|
1781
|
+
});
|
|
1782
|
+
if (waitForCompletion) {
|
|
1783
|
+
const res = await runPrep;
|
|
1784
|
+
if (!res.ok)
|
|
1785
|
+
throw new Error(res.error || 'Не удалось подготовить Halowin Bubo');
|
|
1786
|
+
}
|
|
1787
|
+
else {
|
|
1788
|
+
runPrep.catch(() => {});
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
return {
|
|
1792
|
+
totalModels: targets.length,
|
|
1793
|
+
startedCount: 1,
|
|
1794
|
+
alreadyActiveCount: 0,
|
|
1795
|
+
mode: 'bubo-windows',
|
|
1796
|
+
preflight,
|
|
1797
|
+
jobs: [{
|
|
1798
|
+
id: 'bubo_prepare',
|
|
1799
|
+
folderName: 'Qwen3.8-Flash-Next',
|
|
1800
|
+
status: _windowsPrepareState.status === 'completed' ? 'completed' : 'downloading',
|
|
1801
|
+
progress: _windowsPrepareState.progress,
|
|
1802
|
+
}],
|
|
1803
|
+
};
|
|
1804
|
+
}
|
|
1488
1805
|
|
|
1489
1806
|
const existingDownloads = listHuggingFaceDownloads(rootDir);
|
|
1490
1807
|
const jobs = [];
|
|
@@ -1505,6 +1822,7 @@ export async function downloadHalogenBundle({
|
|
|
1505
1822
|
repoId: spec.hfRepo,
|
|
1506
1823
|
providerFolder: 'Local',
|
|
1507
1824
|
targetNodeName: spec.nodeName,
|
|
1825
|
+
platform,
|
|
1508
1826
|
nodeMeta: {
|
|
1509
1827
|
label: spec.label || spec.nodeName,
|
|
1510
1828
|
model: spec.model,
|