odant-work 1.0.29 → 1.0.31

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.
Files changed (33) hide show
  1. package/#system/package-manifest.json +36 -30
  2. package/$server/$folder/$class/ai/agents/builder.md +34 -24
  3. package/$server/$folder/$class/ai/agents/org-architect.md +40 -0
  4. package/$server/$folder/$class/ai/agents/readme.md +3 -1
  5. package/$server/$folder/$class/ai/agents/schema-validator.md +35 -0
  6. package/$server/$folder/$class/ai/skills/accounting-design.md +21 -0
  7. package/$server/$folder/$class/ai/skills/data-modeling.md +25 -0
  8. package/$server/$folder/$class/ai/skills/readme.md +3 -0
  9. package/$server/$folder/$class/ai/skills/schema-migration.md +23 -0
  10. package/$server/$folder/$class/handlers/pages/form/objects/$handler/objects.js +2 -0
  11. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/util.js +4 -0
  12. package/$server/$folder/lib/consultant/consultant.js +1 -1
  13. package/$server/$folder/lib/tree/tree.js +2 -1
  14. package/MODELS/$ai/$folder/$class/$ai/class.js +17 -3
  15. package/MODELS/$ai/$folder/$class/$ai/handlers/pages/form/trainer/$handler/trainer.js +103 -6
  16. package/MODELS/$ai/$folder/$class/$provider/handlers/pages/form/trainer/$handler/trainer.js +41 -16
  17. package/oda/components/layouts/editor-form/editor-form.js +16 -3
  18. package/package.json +1 -1
  19. package/sources/data/progress.md +20 -0
  20. package/sources/data/schema.js +66 -2
  21. package/sources/host/auto-updater.js +1 -1
  22. package/sources/modules/agent/index.js +4 -3
  23. package/sources/modules/agent/tools/work/classes.js +1081 -0
  24. package/sources/modules/agent/tools/work.js +1 -0
  25. package/sources/modules/trainer/halogen.js +532 -32
  26. package/sources/modules/trainer/huggingface.js +86 -6
  27. package/sources/modules/trainer/index.js +141 -3
  28. package/sources/modules/trainer/local-engine.js +26 -29
  29. package/sources/modules/trainer/paths.js +119 -0
  30. package/sources/modules/trainer/providers.js +60 -36
  31. package/sources/modules/trainer/runner.js +142 -31
  32. package/sources/server/class/security.js +10 -3
  33. package/sources/server/class.js +6 -0
@@ -8,7 +8,9 @@
8
8
  * и быстрое добавление моделей в 1 клик.
9
9
  */
10
10
  import fs from 'node:fs';
11
+ import os from 'node:os';
11
12
  import path from 'node:path';
13
+ import { inspectWeightsDirectorySync } from './paths.js';
12
14
 
13
15
  export const AI_PROVIDER_PRESETS = Object.freeze([
14
16
  {
@@ -778,32 +780,29 @@ export function scaffoldProviderOnDiskSync({
778
780
  };
779
781
  }
780
782
 
781
- function hasWeightFilesInDirSync(dir) {
782
- if (!dir || !fs.existsSync(dir))
783
- return false;
784
- try {
785
- const entries = fs.readdirSync(dir);
786
- if (entries.includes('download-state.json')) {
787
- try {
788
- const st = JSON.parse(fs.readFileSync(path.join(dir, 'download-state.json'), 'utf-8'));
789
- if (st?.status !== 'completed')
790
- return false;
791
- }
792
- catch {
793
- return false;
794
- }
783
+ function hasCompatibleWeightFilesInDirSync(dir, platform = os.platform()) {
784
+ const info = inspectWeightsDirectorySync(dir, platform);
785
+ return Boolean(info.hasReadyWeights && !info.incompatibleOnPlatform);
786
+ }
787
+
788
+ function inspectDirCandidatesSync(dirs = [], platform = os.platform()) {
789
+ let incompatibleFound = null;
790
+ for (const dir of dirs) {
791
+ if (!dir)
792
+ continue;
793
+ const info = inspectWeightsDirectorySync(dir, platform);
794
+ if (info.hasReadyWeights && !info.incompatibleOnPlatform) {
795
+ return { ready: true, incompatible: false, info };
796
+ }
797
+ if (info.incompatibleOnPlatform && !incompatibleFound) {
798
+ incompatibleFound = info;
795
799
  }
796
- return entries.some(f =>
797
- !f.endsWith('.part')
798
- && !f.endsWith('.tmp')
799
- && f !== 'hf-manifest.json'
800
- && f !== 'download-state.json'
801
- && /\.(safetensors|gguf|bin|onnx|pt|pth|hgn|hnpw|json)$/i.test(f)
802
- );
803
- }
804
- catch {
805
- return false;
806
800
  }
801
+ return {
802
+ ready: false,
803
+ incompatible: Boolean(incompatibleFound),
804
+ info: incompatibleFound,
805
+ };
807
806
  }
808
807
 
809
808
  function readSecretJsonSync(rootDir, relFolder, filename) {
@@ -865,6 +864,11 @@ export function evaluateAiNodeActivitySync(item, rootDir = process.cwd()) {
865
864
 
866
865
  // 1. Локальный провайдер /MODELS/Local и его модели
867
866
  if (providerId === 'Local' || data.protocol === 'local' || data.protocol === 'halogen') {
867
+ const platform = os.platform();
868
+ const buboManifest1 = path.join(rootDir, 'MODELS', 'Local', 'models', 'qwen38-flash-next-base-ud-q4-k-xl-v1', 'bubo-package.json');
869
+ const buboManifest2 = path.join(rootDir, 'MODELS', 'Local', 'models', 'huihui-qwen38-flash-next-ud-q4-k-xl-v1', 'bubo-package.json');
870
+ const hasBuboGlobal = fs.existsSync(buboManifest1) || fs.existsSync(buboManifest2);
871
+
868
872
  if (type === '$provider') {
869
873
  const localDir = path.join(rootDir, 'MODELS', 'Local');
870
874
  let installedCount = 0;
@@ -874,9 +878,9 @@ export function evaluateAiNodeActivitySync(item, rootDir = process.cwd()) {
874
878
  if (!entry.isDirectory() || entry.name.startsWith('$') || entry.name.startsWith('#') || entry.name === 'models')
875
879
  continue;
876
880
  if (
877
- hasWeightFilesInDirSync(path.join(localDir, entry.name, '$ai', '#weights'))
878
- || hasWeightFilesInDirSync(path.join(localDir, entry.name, '#weights'))
879
- || hasWeightFilesInDirSync(path.join(localDir, entry.name, '#adapters'))
881
+ hasCompatibleWeightFilesInDirSync(path.join(localDir, entry.name, '$ai', '#weights'), platform)
882
+ || hasCompatibleWeightFilesInDirSync(path.join(localDir, entry.name, '#weights'), platform)
883
+ || hasCompatibleWeightFilesInDirSync(path.join(localDir, entry.name, '#adapters'), platform)
880
884
  ) {
881
885
  installedCount++;
882
886
  }
@@ -884,11 +888,10 @@ export function evaluateAiNodeActivitySync(item, rootDir = process.cwd()) {
884
888
  }
885
889
  }
886
890
  catch { /* ignore */ }
887
- const buboManifest1 = path.join(rootDir, 'MODELS', 'Local', 'models', 'qwen38-flash-next-base-ud-q4-k-xl-v1', 'bubo-package.json');
888
- if (installedCount > 0 || fs.existsSync(buboManifest1)) {
891
+ if (installedCount > 0 || hasBuboGlobal) {
889
892
  return { active: true, reason: `Активен (моделей: ${installedCount || 1})`, configuredKey: true };
890
893
  }
891
- return { active: false, reason: 'Нет скачанных локальных моделей (откройте для установки)', configuredKey: false };
894
+ return { active: false, reason: 'Нет совместимых скачанных локальных моделей (откройте для установки)', configuredKey: false };
892
895
  }
893
896
 
894
897
  // Дочерняя модель в /MODELS/Local/<Model>
@@ -896,14 +899,35 @@ export function evaluateAiNodeActivitySync(item, rootDir = process.cwd()) {
896
899
  const canonicalWeightsRel = path.join('MODELS', 'Local', modelName, '$ai', '#weights');
897
900
  const legacyWeightsRel = path.join('MODELS', 'Local', modelName, '#weights');
898
901
  const adapterRel = data.adapterPath || path.join('MODELS', 'Local', '$provider', '#adapters', modelName);
899
- const hasWeights = hasWeightFilesInDirSync(path.resolve(rootDir, data.weightsDir || canonicalWeightsRel))
900
- || hasWeightFilesInDirSync(path.resolve(rootDir, canonicalWeightsRel))
901
- || hasWeightFilesInDirSync(path.resolve(rootDir, legacyWeightsRel))
902
- || hasWeightFilesInDirSync(path.resolve(rootDir, adapterRel))
903
- || fs.existsSync(path.join(rootDir, 'MODELS', 'Local', 'models', 'qwen38-flash-next-base-ud-q4-k-xl-v1', 'bubo-package.json'));
904
- if (hasWeights) {
902
+ const isFlashNext = modelName === 'Qwen3.8-Flash-Next';
903
+
904
+ const check = inspectDirCandidatesSync([
905
+ data.weightsDir ? path.resolve(rootDir, data.weightsDir) : '',
906
+ path.resolve(rootDir, canonicalWeightsRel),
907
+ path.resolve(rootDir, legacyWeightsRel),
908
+ path.resolve(rootDir, adapterRel),
909
+ ], platform);
910
+
911
+ const isHalogenLinuxRepo = /^peonist-ai\/halogen-/i.test(String(data.hfRepo || ''));
912
+ if (platform === 'win32' && isHalogenLinuxRepo && !(isFlashNext && hasBuboGlobal) && !check.info?.hasGguf && !check.info?.hasBuboManifest) {
913
+ return {
914
+ active: false,
915
+ reason: check.info?.incompatibleReason || 'Веса формата Linux (.hgn/.hnpw) несовместимы с Windows',
916
+ incompatibleOnPlatform: true,
917
+ configuredKey: false,
918
+ };
919
+ }
920
+ if (check.ready || (isFlashNext && hasBuboGlobal)) {
905
921
  return { active: true, reason: 'Активна (веса модели на диске)', configuredKey: true };
906
922
  }
923
+ if (check.incompatible) {
924
+ return {
925
+ active: false,
926
+ reason: check.info?.incompatibleReason || 'Веса формата Linux (.hgn/.hnpw) несовместимы с Windows',
927
+ incompatibleOnPlatform: true,
928
+ configuredKey: false,
929
+ };
930
+ }
907
931
  return { active: false, reason: 'Веса модели не скачаны в $ai/#weights', configuredKey: false };
908
932
  }
909
933
 
@@ -16,6 +16,8 @@ import {
16
16
  modelWeightsDir,
17
17
  modelClassFile,
18
18
  migrateLocalModelsLayoutSync,
19
+ inspectWeightsDirectorySync,
20
+ getFreeDiskSpaceGb,
19
21
  WEIGHT_FILE_EXT_RE,
20
22
  } from './paths.js';
21
23
 
@@ -101,19 +103,95 @@ export function computeAdaptiveDefaults(usableMemoryGb) {
101
103
  };
102
104
  }
103
105
 
106
+ function parseRegMemoryBytes(regType, rawValue) {
107
+ const val = String(rawValue || '').trim();
108
+ if (!val)
109
+ return 0;
110
+ try {
111
+ if (/REG_QWORD|REG_DWORD/i.test(regType)) {
112
+ return Number(BigInt(val));
113
+ }
114
+ if (/REG_BINARY/i.test(regType)) {
115
+ const hex = val.replace(/[^0-9a-f]/gi, '');
116
+ if (hex.length >= 16) {
117
+ const buf = Buffer.from(hex.slice(0, 16), 'hex');
118
+ return Number(buf.readBigUInt64LE(0));
119
+ }
120
+ if (hex.length >= 8) {
121
+ const buf = Buffer.from(hex.slice(0, 8), 'hex');
122
+ return buf.readUInt32LE(0);
123
+ }
124
+ }
125
+ }
126
+ catch { /* ignore */ }
127
+ return 0;
128
+ }
129
+
130
+ function parseWindowsVideoRegistry(output) {
131
+ const byKey = new Map();
132
+ let cur = null;
133
+ for (const rawLine of String(output || '').split(/\r?\n/)) {
134
+ const line = rawLine.trim();
135
+ if (!line)
136
+ continue;
137
+ if (/^HKEY_/i.test(line)) {
138
+ const key = line.toLowerCase();
139
+ cur = byKey.get(key) || { name: '', qwBytes: 0, dwBytes: 0 };
140
+ byKey.set(key, cur);
141
+ continue;
142
+ }
143
+ if (!cur)
144
+ continue;
145
+ const mDesc = line.match(/^DriverDesc\s+REG_SZ\s+(.+)$/i);
146
+ if (mDesc) {
147
+ cur.name = mDesc[1].trim();
148
+ continue;
149
+ }
150
+ const mQw = line.match(/^HardwareInformation\.qwMemorySize\s+(REG_\w+)\s+(.+)$/i);
151
+ if (mQw) {
152
+ cur.qwBytes = parseRegMemoryBytes(mQw[1], mQw[2]);
153
+ continue;
154
+ }
155
+ const mDw = line.match(/^HardwareInformation\.MemorySize\s+(REG_\w+)\s+(.+)$/i);
156
+ if (mDw) {
157
+ cur.dwBytes = parseRegMemoryBytes(mDw[1], mDw[2]);
158
+ }
159
+ }
160
+
161
+ let bestName = '';
162
+ let maxBytes = 0;
163
+ for (const a of byKey.values()) {
164
+ if (/Basic Display|Virtual|Indirect/i.test(a.name))
165
+ continue;
166
+ const bytes = a.qwBytes || a.dwBytes || 0;
167
+ if (bytes > maxBytes) {
168
+ maxBytes = bytes;
169
+ bestName = a.name || bestName;
170
+ }
171
+ else if (!bestName && a.name) {
172
+ bestName = a.name;
173
+ }
174
+ }
175
+ return {
176
+ gpuName: bestName,
177
+ vramGb: maxBytes > 0 ? +(maxBytes / (1024 ** 3)).toFixed(1) : 0,
178
+ };
179
+ }
180
+
104
181
  /**
105
182
  * Определить реальный аппаратный профиль текущей машины (CPU, RAM, GPU/VRAM/UMA, Python + Unsloth, llama-server)
106
183
  * и адаптировать все бюджеты памяти и рекомендации под фактическое железо.
107
184
  */
108
185
  export async function detectHardware({ force = false } = {}) {
109
- const totalRamGb = +(os.totalmem() / (1024 ** 3)).toFixed(1);
186
+ const osTotalRamGb = +(os.totalmem() / (1024 ** 3)).toFixed(1);
110
187
  const freeRamGb = +(os.freemem() / (1024 ** 3)).toFixed(1);
188
+ const freeDiskGb = getFreeDiskSpaceGb(process.cwd());
111
189
 
112
190
  if (_hwCache && !force) {
113
191
  return {
114
192
  ..._hwCache,
115
- totalRamGb,
116
193
  freeRamGb,
194
+ freeDiskGb,
117
195
  };
118
196
  }
119
197
 
@@ -123,18 +201,35 @@ export async function detectHardware({ force = false } = {}) {
123
201
  const platform = os.platform();
124
202
  const arch = os.arch();
125
203
 
126
- // Параллельно опрашиваем видеокарту (NVIDIA / AMD ROCm) и окружение Python / llama-server
127
- const [nvidiaProbe, rocmProbe, pyProbe, llamaProbe] = await Promise.all([
204
+ const winVideoRegKey = 'HKLM\\SYSTEM\\CurrentControlSet\\Control\\Class\\{4d36e968-e325-11ce-bfc1-08002be10318}';
205
+
206
+ // Параллельно опрашиваем видеокарту (NVIDIA / AMD ROCm / нативный reg query на Windows за ~50 мс) и Python / llama-server
207
+ const [nvidiaProbe, rocmProbe, winRegDesc, winRegMem, pyProbe, llamaProbe] = await Promise.all([
128
208
  probeCommand('nvidia-smi', ['--query-gpu=name,memory.total', '--format=csv,noheader,nounits']),
129
209
  probeCommand('rocm-smi', ['--showproductname', '--showmeminfo', 'vram', '--json']),
210
+ platform === 'win32'
211
+ ? probeCommand('reg', ['query', winVideoRegKey, '/s', '/v', 'DriverDesc'], 2500)
212
+ : Promise.resolve({ ok: false, output: '' }),
213
+ platform === 'win32'
214
+ ? probeCommand('reg', ['query', winVideoRegKey, '/s', '/v', 'HardwareInformation.*MemorySize'], 2500)
215
+ : Promise.resolve({ ok: false, output: '' }),
130
216
  probeCommand('python', ['-c', 'import json, torch; import unsloth; print(json.dumps({"torch": torch.__version__, "cuda": torch.cuda.is_available(), "hip": getattr(torch.version, "hip", None)}))']),
131
217
  probeCommand('llama-server', ['--version']),
132
218
  ]);
133
219
 
134
220
  let gpuName = '';
135
221
  let vramGb = 0;
222
+ const physicalRamGb = osTotalRamGb;
136
223
  let memoryType = 'System RAM / UMA';
137
224
 
225
+ if (winRegDesc.ok || winRegMem.ok) {
226
+ const parsed = parseWindowsVideoRegistry(`${winRegDesc.output || ''}\n${winRegMem.output || ''}`);
227
+ if (parsed.gpuName)
228
+ gpuName = parsed.gpuName;
229
+ if (parsed.vramGb > 0)
230
+ vramGb = parsed.vramGb;
231
+ }
232
+
138
233
  if (nvidiaProbe.ok && nvidiaProbe.output) {
139
234
  const firstLine = nvidiaProbe.output.split(/\r?\n/)[0] || '';
140
235
  const parts = firstLine.split(',').map(s => s.trim());
@@ -161,16 +256,29 @@ export async function detectHardware({ force = false } = {}) {
161
256
  catch { /* ignore */ }
162
257
  }
163
258
 
164
- const isUnifiedApu = /Ryzen AI|Strix|Radeon|Apple M/i.test(cpuModel) || (!vramGb && /AMD|Apple/i.test(cpuModel));
259
+ const isUnifiedApu = /Ryzen AI|Strix|Radeon|Apple M/i.test(cpuModel)
260
+ || /Radeon\(TM\) 80[56]0S|Radeon 80[56]0S/i.test(gpuName)
261
+ || (!vramGb && /AMD|Apple/i.test(cpuModel));
165
262
  if (!gpuName) {
166
263
  gpuName = isUnifiedApu ? `${cpuModel} (Unified iGPU/UMA)` : 'CPU / Интегрированная память';
167
264
  }
265
+ else if (isUnifiedApu && vramGb > 0) {
266
+ memoryType = `Unified Memory / UMA (${vramGb} ГБ iGPU + ${osTotalRamGb} ГБ ОС)`;
267
+ }
268
+
269
+ // На системах с единой памятью (Strix Halo UMA / Apple Silicon) физическая RAM (например 192 ГБ)
270
+ // делится в BIOS между ОС (напр. 64 ГБ) и UMA GPU (напр. 128 ГБ). Учитываем полный физический пул!
271
+ const totalRamGb = isUnifiedApu
272
+ ? Math.max(osTotalRamGb, physicalRamGb, vramGb > 8 && osTotalRamGb + vramGb <= 256 ? +(osTotalRamGb + vramGb).toFixed(1) : osTotalRamGb)
273
+ : Math.max(osTotalRamGb, physicalRamGb);
168
274
 
169
275
  // Доступный бюджет памяти:
170
- // - если есть дискретная GPU с большой VRAM и не APU — можем использовать VRAM (или гибридно до 75% системной ОЗУ для GGUF);
171
- // - на системах с единой памятью (UMA) или CPU под модели безопасно выделяется ~78% от общего объёма ОЗУ.
276
+ // - если есть дискретная GPU с большой VRAM и не APU — можем использовать VRAM (или гибридно до 78% системной ОЗУ);
277
+ // - на системах с единой памятью (UMA) под модели безопасно выделяется ~78% от полного физического объёма ОЗУ (или весь UMA пул).
172
278
  const ramBudgetGb = +(totalRamGb * 0.78).toFixed(1);
173
- const usableMemoryGb = vramGb > ramBudgetGb ? vramGb : ramBudgetGb;
279
+ const usableMemoryGb = isUnifiedApu
280
+ ? Math.max(ramBudgetGb, +(vramGb * 0.92).toFixed(1))
281
+ : (vramGb > ramBudgetGb ? vramGb : ramBudgetGb);
174
282
 
175
283
  let unslothInstalled = false;
176
284
  let torchInfo = null;
@@ -190,7 +298,10 @@ export async function detectHardware({ force = false } = {}) {
190
298
  platform,
191
299
  arch,
192
300
  totalRamGb,
301
+ osTotalRamGb,
302
+ physicalRamGb,
193
303
  freeRamGb,
304
+ freeDiskGb,
194
305
  gpuName,
195
306
  vramGb,
196
307
  memoryType,
@@ -264,8 +375,9 @@ export async function listLocalModelsAndAdapters(rootDir = process.cwd()) {
264
375
  return { models, adapters };
265
376
 
266
377
  const entries = await fsp.readdir(localRoot, { withFileTypes: true });
378
+ const platform = os.platform();
267
379
  for (const e of entries) {
268
- if (!e.isDirectory() || e.name.startsWith('$') || e.name.startsWith('#'))
380
+ if (!e.isDirectory() || e.name.startsWith('$') || e.name.startsWith('#') || e.name === 'models')
269
381
  continue;
270
382
 
271
383
  const isDownloading = activeDownloads.some(
@@ -273,26 +385,12 @@ export async function listLocalModelsAndAdapters(rootDir = process.cwd()) {
273
385
  );
274
386
  const aiClassFile = modelClassFile(rootDir, e.name, 'Local');
275
387
  const weightsDir = modelWeightsDir(rootDir, e.name, 'Local');
276
- let weightFiles = [];
277
- let hasRealWeightBinary = false;
278
- let hasPendingDownload = false;
388
+ const wInsp = inspectWeightsDirectorySync(weightsDir, platform);
389
+ const weightFiles = wInsp.files || [];
390
+ const hasRealWeightBinary = wInsp.hasReadyWeights;
391
+ const hasPendingDownload = wInsp.pendingDownload;
279
392
  let sizeBytes = 0;
280
- if (fs.existsSync(weightsDir)) {
281
- const wf = await fsp.readdir(weightsDir).catch(() => []);
282
- const hasParts = wf.some(f => f.endsWith('.part'));
283
- let pendingState = false;
284
- if (wf.includes('download-state.json')) {
285
- try {
286
- const st = JSON.parse(await fsp.readFile(path.join(weightsDir, 'download-state.json'), 'utf-8'));
287
- pendingState = st?.status !== 'completed';
288
- }
289
- catch {
290
- pendingState = true;
291
- }
292
- }
293
- hasPendingDownload = hasParts || pendingState;
294
- weightFiles = wf.filter(f => !f.endsWith('.part') && f !== 'hf-manifest.json' && f !== 'download-state.json' && !f.endsWith('.tmp'));
295
- hasRealWeightBinary = weightFiles.some(f => WEIGHT_FILE_EXT_RE.test(f));
393
+ if (wInsp.exists) {
296
394
  for (const f of weightFiles) {
297
395
  try {
298
396
  const st = await fsp.stat(path.join(weightsDir, f));
@@ -312,9 +410,13 @@ export async function listLocalModelsAndAdapters(rootDir = process.cwd()) {
312
410
  }
313
411
 
314
412
  const isAdapterNode = Boolean(meta.adapterPath);
413
+ const hasBuboExternal = e.name === 'Qwen3.8-Flash-Next' && (
414
+ fs.existsSync(path.join(localRoot, 'models', 'qwen38-flash-next-base-ud-q4-k-xl-v1', 'bubo-package.json'))
415
+ || fs.existsSync(path.join(localRoot, 'models', 'huihui-qwen38-flash-next-ud-q4-k-xl-v1', 'bubo-package.json'))
416
+ );
315
417
 
316
418
  // Если папка модели пустая (ни готовых весов, ни незавершённой загрузки, ни адаптера) — убираем мусор
317
- if (!isDownloading && !hasPendingDownload && !hasRealWeightBinary && !isAdapterNode) {
419
+ if (!isDownloading && !hasPendingDownload && !hasRealWeightBinary && !isAdapterNode && !hasBuboExternal) {
318
420
  try {
319
421
  await fsp.rm(path.join(localRoot, e.name), { recursive: true, force: true });
320
422
  }
@@ -327,18 +429,25 @@ export async function listLocalModelsAndAdapters(rootDir = process.cwd()) {
327
429
  continue;
328
430
  }
329
431
 
330
- if (hasRealWeightBinary || isAdapterNode) {
432
+ if (hasRealWeightBinary || isAdapterNode || hasBuboExternal) {
331
433
  const enabled = meta.enabled !== false;
434
+ const isHalogenLinuxRepo = platform === 'win32' && /^peonist-ai\/halogen-/i.test(String(meta.hfRepo || ''));
435
+ const incompatible = !hasBuboExternal && (wInsp.incompatibleOnPlatform || (isHalogenLinuxRepo && !wInsp.hasGguf && !wInsp.hasBuboManifest));
436
+ const incompatibleReason = wInsp.incompatibleReason || (incompatible ? 'Веса формата Linux (.hgn/.hnpw) несовместимы с Windows. Удалите их и установите Windows-версию.' : '');
332
437
  models.push({
333
438
  id: e.name,
334
439
  label: meta.label || e.name,
335
440
  icon: meta.icon || 'ai:ollama',
336
441
  modality: meta.modality || 'llm',
337
442
  model: meta.model || meta.hfRepo || e.name,
443
+ protocol: meta.protocol || 'local',
338
444
  capabilities: Array.isArray(meta.capabilities) ? meta.capabilities : ['chat', 'stream'],
339
445
  maxTokens: meta.maxTokens || 16384,
340
446
  enabled,
341
- active: enabled && (hasRealWeightBinary || isAdapterNode),
447
+ active: enabled && (hasRealWeightBinary || isAdapterNode || hasBuboExternal) && !incompatible,
448
+ incompatibleOnPlatform: incompatible,
449
+ incompatibleReason: incompatible ? incompatibleReason : '',
450
+ weightFormat: hasBuboExternal ? 'bubo' : wInsp.weightFormat,
342
451
  path: `/MODELS/Local/${e.name}`,
343
452
  hasClass: fs.existsSync(aiClassFile),
344
453
  weightFiles,
@@ -623,3 +732,5 @@ export async function publishTrainedAdapter(jobId, {
623
732
  job.publishedPath = res.modelPath;
624
733
  return res;
625
734
  }
735
+
736
+ export { parseWindowsVideoRegistry };
@@ -565,7 +565,10 @@ export const classSecurityMethods = {
565
565
  || POLICY.isAgentControlPath(target, this.path);
566
566
  if (this.id === uid && params.session?.principal?.kind !== 'node' && !protectedTarget)
567
567
  return true;
568
- if (globalThis.WORK && await this._isWorkBoss(params))
568
+ // Руководитель корня WORK проходит и по системным путям ($server, sources, oda),
569
+ // но только когда он действует от своего имени: принудительный role=USER проверяем ниже.
570
+ if ((!params.role || params.role === this.constructor.ROLES.BOSS)
571
+ && globalThis.WORK && await this._isWorkBoss(params))
569
572
  return true;
570
573
  if (this._isSystemItem(item))
571
574
  return false;
@@ -643,10 +646,14 @@ export const classSecurityMethods = {
643
646
  return result;
644
647
  },
645
648
 
646
- /** Проверка BOSS на корневом WORK. */
649
+ /**
650
+ * Проверка BOSS на корневом WORK (в том числе на самом корне: это $server,
651
+ * который тоже наследует $structure). Рекурсии нет — roles() читает #security
652
+ * напрямую и не вызывает canWrite/assertAccess/_isWorkBoss.
653
+ */
647
654
  async _isWorkBoss(params = {}) {
648
655
  if (!globalThis.WORK) return false;
649
- return globalThis.WORK !== this && await globalThis.WORK.roles?.(params).then(r => r.includes(this.constructor.ROLES.BOSS));
656
+ return globalThis.WORK.roles?.(params).then(r => r.includes(this.constructor.ROLES.BOSS));
650
657
  },
651
658
 
652
659
  /** @deprecated алиас _isWorkBoss */
@@ -22,6 +22,7 @@ import { DATA_METHODS, classHasObjects, classObjectCount, markClassesDirty } fro
22
22
  import {
23
23
  TRAINER_METHODS,
24
24
  localStreamChat,
25
+ ensureHalogenBackendRunning,
25
26
  halogenFallback,
26
27
  evaluateAiNodeActivitySync,
27
28
  scaffoldProviderOnDiskSync,
@@ -862,6 +863,11 @@ Object.defineProperty($class.prototype, 'localStreamChat', {
862
863
  writable: true,
863
864
  configurable: true,
864
865
  });
866
+ Object.defineProperty($class.prototype, 'ensureHalogenBackendRunning', {
867
+ value: ensureHalogenBackendRunning,
868
+ writable: true,
869
+ configurable: true,
870
+ });
865
871
  Object.defineProperty($class.prototype, 'halogenFallback', {
866
872
  value: halogenFallback,
867
873
  writable: true,