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
|
@@ -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
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
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
|
-
|
|
878
|
-
||
|
|
879
|
-
||
|
|
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
|
-
|
|
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,26 @@ 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
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
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
|
+
if (check.ready || (isFlashNext && hasBuboGlobal)) {
|
|
905
912
|
return { active: true, reason: 'Активна (веса модели на диске)', configuredKey: true };
|
|
906
913
|
}
|
|
914
|
+
if (check.incompatible) {
|
|
915
|
+
return {
|
|
916
|
+
active: false,
|
|
917
|
+
reason: check.info?.incompatibleReason || 'Веса формата Linux (.hgn/.hnpw) несовместимы с Windows',
|
|
918
|
+
incompatibleOnPlatform: true,
|
|
919
|
+
configuredKey: false,
|
|
920
|
+
};
|
|
921
|
+
}
|
|
907
922
|
return { active: false, reason: 'Веса модели не скачаны в $ai/#weights', configuredKey: false };
|
|
908
923
|
}
|
|
909
924
|
|
|
@@ -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
|
|
|
@@ -106,14 +108,15 @@ export function computeAdaptiveDefaults(usableMemoryGb) {
|
|
|
106
108
|
* и адаптировать все бюджеты памяти и рекомендации под фактическое железо.
|
|
107
109
|
*/
|
|
108
110
|
export async function detectHardware({ force = false } = {}) {
|
|
109
|
-
const
|
|
111
|
+
const osTotalRamGb = +(os.totalmem() / (1024 ** 3)).toFixed(1);
|
|
110
112
|
const freeRamGb = +(os.freemem() / (1024 ** 3)).toFixed(1);
|
|
113
|
+
const freeDiskGb = getFreeDiskSpaceGb(process.cwd());
|
|
111
114
|
|
|
112
115
|
if (_hwCache && !force) {
|
|
113
116
|
return {
|
|
114
117
|
..._hwCache,
|
|
115
|
-
totalRamGb,
|
|
116
118
|
freeRamGb,
|
|
119
|
+
freeDiskGb,
|
|
117
120
|
};
|
|
118
121
|
}
|
|
119
122
|
|
|
@@ -123,18 +126,44 @@ export async function detectHardware({ force = false } = {}) {
|
|
|
123
126
|
const platform = os.platform();
|
|
124
127
|
const arch = os.arch();
|
|
125
128
|
|
|
126
|
-
|
|
127
|
-
|
|
129
|
+
const winPsScript = [
|
|
130
|
+
'$pm = (Get-CimInstance Win32_PhysicalMemory -ErrorAction SilentlyContinue | Measure-Object Capacity -Sum).Sum',
|
|
131
|
+
'$gpu = Get-CimInstance Win32_VideoController -ErrorAction SilentlyContinue | Where-Object { $_.Name -notmatch "Basic Display|Virtual" } | Select-Object -First 1 Name',
|
|
132
|
+
'$qw = (Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\\SYSTEM\\ControlSet001\\Control\\Class\\{4d36e968-e325-11ce-bfc1-08002be10318}\\0*" -Name "HardwareInformation.qwMemorySize" -ErrorAction SilentlyContinue | Measure-Object "HardwareInformation.qwMemorySize" -Maximum).Maximum',
|
|
133
|
+
'[PSCustomObject]@{phys=$pm;gpu=$gpu.Name;vram=$qw} | ConvertTo-Json -Compress',
|
|
134
|
+
].join('\n');
|
|
135
|
+
|
|
136
|
+
// Параллельно опрашиваем видеокарту (NVIDIA / AMD ROCm / Windows WMI+DXGI) и окружение Python / llama-server
|
|
137
|
+
const [nvidiaProbe, rocmProbe, winProbe, pyProbe, llamaProbe] = await Promise.all([
|
|
128
138
|
probeCommand('nvidia-smi', ['--query-gpu=name,memory.total', '--format=csv,noheader,nounits']),
|
|
129
139
|
probeCommand('rocm-smi', ['--showproductname', '--showmeminfo', 'vram', '--json']),
|
|
140
|
+
platform === 'win32'
|
|
141
|
+
? probeCommand('powershell', ['-NoProfile', '-EncodedCommand', Buffer.from(winPsScript, 'utf16le').toString('base64')], 4500)
|
|
142
|
+
: Promise.resolve({ ok: false, output: '' }),
|
|
130
143
|
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
144
|
probeCommand('llama-server', ['--version']),
|
|
132
145
|
]);
|
|
133
146
|
|
|
134
147
|
let gpuName = '';
|
|
135
148
|
let vramGb = 0;
|
|
149
|
+
let physicalRamGb = osTotalRamGb;
|
|
136
150
|
let memoryType = 'System RAM / UMA';
|
|
137
151
|
|
|
152
|
+
if (winProbe.ok && winProbe.output) {
|
|
153
|
+
try {
|
|
154
|
+
const w = JSON.parse(winProbe.output.split(/\r?\n/).pop() || '{}');
|
|
155
|
+
const physB = Number(w.phys) || 0;
|
|
156
|
+
if (physB > 0)
|
|
157
|
+
physicalRamGb = Math.max(osTotalRamGb, +(physB / (1024 ** 3)).toFixed(1));
|
|
158
|
+
const vramB = Number(w.vram) || 0;
|
|
159
|
+
if (vramB > 0)
|
|
160
|
+
vramGb = +(vramB / (1024 ** 3)).toFixed(1);
|
|
161
|
+
if (w.gpu && typeof w.gpu === 'string')
|
|
162
|
+
gpuName = w.gpu.trim();
|
|
163
|
+
}
|
|
164
|
+
catch { /* ignore */ }
|
|
165
|
+
}
|
|
166
|
+
|
|
138
167
|
if (nvidiaProbe.ok && nvidiaProbe.output) {
|
|
139
168
|
const firstLine = nvidiaProbe.output.split(/\r?\n/)[0] || '';
|
|
140
169
|
const parts = firstLine.split(',').map(s => s.trim());
|
|
@@ -161,16 +190,29 @@ export async function detectHardware({ force = false } = {}) {
|
|
|
161
190
|
catch { /* ignore */ }
|
|
162
191
|
}
|
|
163
192
|
|
|
164
|
-
const isUnifiedApu = /Ryzen AI|Strix|Radeon|Apple M/i.test(cpuModel)
|
|
193
|
+
const isUnifiedApu = /Ryzen AI|Strix|Radeon|Apple M/i.test(cpuModel)
|
|
194
|
+
|| /Radeon\(TM\) 80[56]0S|Radeon 80[56]0S/i.test(gpuName)
|
|
195
|
+
|| (!vramGb && /AMD|Apple/i.test(cpuModel));
|
|
165
196
|
if (!gpuName) {
|
|
166
197
|
gpuName = isUnifiedApu ? `${cpuModel} (Unified iGPU/UMA)` : 'CPU / Интегрированная память';
|
|
167
198
|
}
|
|
199
|
+
else if (isUnifiedApu && vramGb > 0) {
|
|
200
|
+
memoryType = `Unified Memory / UMA (${vramGb} ГБ iGPU + ${osTotalRamGb} ГБ ОС)`;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// На системах с единой памятью (Strix Halo UMA / Apple Silicon) физическая RAM (например 192 ГБ)
|
|
204
|
+
// делится в BIOS между ОС (напр. 64 ГБ) и UMA GPU (напр. 128 ГБ). Учитываем полный физический пул!
|
|
205
|
+
const totalRamGb = isUnifiedApu
|
|
206
|
+
? Math.max(osTotalRamGb, physicalRamGb, vramGb > 8 && osTotalRamGb + vramGb <= 256 ? +(osTotalRamGb + vramGb).toFixed(1) : osTotalRamGb)
|
|
207
|
+
: Math.max(osTotalRamGb, physicalRamGb);
|
|
168
208
|
|
|
169
209
|
// Доступный бюджет памяти:
|
|
170
|
-
// - если есть дискретная GPU с большой VRAM и не APU — можем использовать VRAM (или гибридно до
|
|
171
|
-
// - на системах с единой памятью (UMA)
|
|
210
|
+
// - если есть дискретная GPU с большой VRAM и не APU — можем использовать VRAM (или гибридно до 78% системной ОЗУ);
|
|
211
|
+
// - на системах с единой памятью (UMA) под модели безопасно выделяется ~78% от полного физического объёма ОЗУ (или весь UMA пул).
|
|
172
212
|
const ramBudgetGb = +(totalRamGb * 0.78).toFixed(1);
|
|
173
|
-
const usableMemoryGb =
|
|
213
|
+
const usableMemoryGb = isUnifiedApu
|
|
214
|
+
? Math.max(ramBudgetGb, +(vramGb * 0.92).toFixed(1))
|
|
215
|
+
: (vramGb > ramBudgetGb ? vramGb : ramBudgetGb);
|
|
174
216
|
|
|
175
217
|
let unslothInstalled = false;
|
|
176
218
|
let torchInfo = null;
|
|
@@ -190,7 +232,10 @@ export async function detectHardware({ force = false } = {}) {
|
|
|
190
232
|
platform,
|
|
191
233
|
arch,
|
|
192
234
|
totalRamGb,
|
|
235
|
+
osTotalRamGb,
|
|
236
|
+
physicalRamGb,
|
|
193
237
|
freeRamGb,
|
|
238
|
+
freeDiskGb,
|
|
194
239
|
gpuName,
|
|
195
240
|
vramGb,
|
|
196
241
|
memoryType,
|
|
@@ -264,8 +309,9 @@ export async function listLocalModelsAndAdapters(rootDir = process.cwd()) {
|
|
|
264
309
|
return { models, adapters };
|
|
265
310
|
|
|
266
311
|
const entries = await fsp.readdir(localRoot, { withFileTypes: true });
|
|
312
|
+
const platform = os.platform();
|
|
267
313
|
for (const e of entries) {
|
|
268
|
-
if (!e.isDirectory() || e.name.startsWith('$') || e.name.startsWith('#'))
|
|
314
|
+
if (!e.isDirectory() || e.name.startsWith('$') || e.name.startsWith('#') || e.name === 'models')
|
|
269
315
|
continue;
|
|
270
316
|
|
|
271
317
|
const isDownloading = activeDownloads.some(
|
|
@@ -273,26 +319,12 @@ export async function listLocalModelsAndAdapters(rootDir = process.cwd()) {
|
|
|
273
319
|
);
|
|
274
320
|
const aiClassFile = modelClassFile(rootDir, e.name, 'Local');
|
|
275
321
|
const weightsDir = modelWeightsDir(rootDir, e.name, 'Local');
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
322
|
+
const wInsp = inspectWeightsDirectorySync(weightsDir, platform);
|
|
323
|
+
const weightFiles = wInsp.files || [];
|
|
324
|
+
const hasRealWeightBinary = wInsp.hasReadyWeights;
|
|
325
|
+
const hasPendingDownload = wInsp.pendingDownload;
|
|
279
326
|
let sizeBytes = 0;
|
|
280
|
-
if (
|
|
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));
|
|
327
|
+
if (wInsp.exists) {
|
|
296
328
|
for (const f of weightFiles) {
|
|
297
329
|
try {
|
|
298
330
|
const st = await fsp.stat(path.join(weightsDir, f));
|
|
@@ -312,9 +344,13 @@ export async function listLocalModelsAndAdapters(rootDir = process.cwd()) {
|
|
|
312
344
|
}
|
|
313
345
|
|
|
314
346
|
const isAdapterNode = Boolean(meta.adapterPath);
|
|
347
|
+
const hasBuboExternal = e.name === 'Qwen3.8-Flash-Next' && (
|
|
348
|
+
fs.existsSync(path.join(localRoot, 'models', 'qwen38-flash-next-base-ud-q4-k-xl-v1', 'bubo-package.json'))
|
|
349
|
+
|| fs.existsSync(path.join(localRoot, 'models', 'huihui-qwen38-flash-next-ud-q4-k-xl-v1', 'bubo-package.json'))
|
|
350
|
+
);
|
|
315
351
|
|
|
316
352
|
// Если папка модели пустая (ни готовых весов, ни незавершённой загрузки, ни адаптера) — убираем мусор
|
|
317
|
-
if (!isDownloading && !hasPendingDownload && !hasRealWeightBinary && !isAdapterNode) {
|
|
353
|
+
if (!isDownloading && !hasPendingDownload && !hasRealWeightBinary && !isAdapterNode && !hasBuboExternal) {
|
|
318
354
|
try {
|
|
319
355
|
await fsp.rm(path.join(localRoot, e.name), { recursive: true, force: true });
|
|
320
356
|
}
|
|
@@ -327,18 +363,23 @@ export async function listLocalModelsAndAdapters(rootDir = process.cwd()) {
|
|
|
327
363
|
continue;
|
|
328
364
|
}
|
|
329
365
|
|
|
330
|
-
if (hasRealWeightBinary || isAdapterNode) {
|
|
366
|
+
if (hasRealWeightBinary || isAdapterNode || hasBuboExternal) {
|
|
331
367
|
const enabled = meta.enabled !== false;
|
|
368
|
+
const incompatible = !hasBuboExternal && wInsp.incompatibleOnPlatform;
|
|
332
369
|
models.push({
|
|
333
370
|
id: e.name,
|
|
334
371
|
label: meta.label || e.name,
|
|
335
372
|
icon: meta.icon || 'ai:ollama',
|
|
336
373
|
modality: meta.modality || 'llm',
|
|
337
374
|
model: meta.model || meta.hfRepo || e.name,
|
|
375
|
+
protocol: meta.protocol || 'local',
|
|
338
376
|
capabilities: Array.isArray(meta.capabilities) ? meta.capabilities : ['chat', 'stream'],
|
|
339
377
|
maxTokens: meta.maxTokens || 16384,
|
|
340
378
|
enabled,
|
|
341
|
-
active: enabled && (hasRealWeightBinary || isAdapterNode),
|
|
379
|
+
active: enabled && (hasRealWeightBinary || isAdapterNode || hasBuboExternal) && !incompatible,
|
|
380
|
+
incompatibleOnPlatform: incompatible,
|
|
381
|
+
incompatibleReason: incompatible ? wInsp.incompatibleReason : '',
|
|
382
|
+
weightFormat: hasBuboExternal ? 'bubo' : wInsp.weightFormat,
|
|
342
383
|
path: `/MODELS/Local/${e.name}`,
|
|
343
384
|
hasClass: fs.existsSync(aiClassFile),
|
|
344
385
|
weightFiles,
|
|
@@ -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
|
-
|
|
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
|
-
/**
|
|
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
|
|
656
|
+
return globalThis.WORK.roles?.(params).then(r => r.includes(this.constructor.ROLES.BOSS));
|
|
650
657
|
},
|
|
651
658
|
|
|
652
659
|
/** @deprecated алиас _isWorkBoss */
|
package/sources/server/class.js
CHANGED
|
@@ -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,
|