odant-work 1.0.93 → 1.0.95
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 +618 -649
- package/$server/$folder/$class/$ai/class.js +1 -0
- package/$server/$folder/$class/$ai/handlers/pages/form/system/ai/$handler/class.js +4 -1
- package/$server/$folder/$class/$data/$catalog/$virtual/class.js +1 -0
- package/$server/$folder/$class/$data/$catalog/class.js +1 -0
- package/$server/$folder/$class/$data/$operation/class.js +1 -0
- package/$server/$folder/$class/$data/$register/$account/class.js +1 -0
- package/$server/$folder/$class/$data/$register/class.js +1 -0
- package/$server/$folder/$class/$data/$struct/class.js +1 -0
- package/$server/$folder/$class/$domain/class.js +1 -0
- package/$server/$folder/$class/$module/$mcp/class.js +1 -0
- package/$server/$folder/$class/$module/$provider/class.js +1 -0
- package/$server/$folder/$class/$module/$provider/handlers/pages/form/system/ai/$handler/class.js +38 -6
- package/$server/$folder/$class/$module/class.js +1 -0
- package/$server/$folder/$class/$structure/$project/class.js +1 -0
- package/$server/$folder/$class/$structure/$server/class.js +1 -0
- package/$server/$folder/$class/$structure/$user/class.js +2 -0
- package/$server/$folder/$class/$structure/class.js +1 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/chat-task.js +20 -6
- package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +23 -17
- package/$server/$folder/$class/$structure/handlers/pages/form/system/agent/$handler/class.js +35 -3
- package/$server/$folder/$class/$structure/handlers/pages/form/system/messengers/$handler/class.js +38 -3
- package/$server/$folder/$class/$users/class.js +1 -0
- package/$server/$folder/$class/handlers/pages/form/system/requisites/$handler/class.js +95 -24
- package/$server/$folder/$class/handlers/pages/storage/$handler/class.js +22 -4
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/class.js +4 -3
- package/$server/$folder/handlers/pages/form/$handler/class.js +167 -13
- package/$server/$folder/lib/explorer/explorer.js +2 -1
- package/$server/$folder/lib/icon/icon.js +2 -2
- package/$server/$folder/lib/node/node.js +3 -11
- package/$server/$folder/lib/prompt-bar/prompt-bar.js +4 -2
- package/$server/$folder/lib/tree/tree.js +12 -1
- package/MODULES//320/224/320/260/320/275/320/275/321/213/320/265/Geo/$module/class.js +1 -0
- package/MODULES//320/234/320/276/320/264/320/265/320/273/320/270/Local/$provider/handlers/pages/form/system/engine/$handler/class.js +445 -0
- package/MODULES//320/243/321/207/321/221/321/202 /320/270 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/321/213/Register/$module/class.js" +1 -0
- package/package.json +1 -1
- package/run.mjs +11 -0
- package/scripts/agent-eval.mjs +1 -1
- package/scripts/migrate-tree.mjs +9 -438
- package/sources/client/class.js +1 -1
- package/sources/host/auth-methods.js +16 -2
- package/sources/host/auto-updater.js +34 -24
- package/sources/host/tree-migration.js +580 -0
- package/sources/host/tree-migration.json +85 -0
- package/sources/modules/agent/index.js +23 -10
- package/sources/modules/agent/session.js +22 -2
- package/sources/modules/agent/tools/meta.js +1 -1
- package/sources/modules/agent/voice.js +6 -2
- package/sources/modules/license/index.js +53 -0
- package/sources/modules/trainer/dataset.js +6 -4
- package/sources/modules/trainer/halogen.js +9 -9
- package/sources/modules/trainer/huggingface.js +1 -1
- package/sources/modules/trainer/index.js +25 -5
- package/sources/modules/trainer/local-engine.js +17 -11
- package/sources/modules/trainer/runner.js +32 -9
- package/sources/server/class/distro.js +1 -1
- package/sources/server/class.js +8 -0
- package/sources/server/folder.js +9 -2
- package/$server/$folder/$class/$data/$catalog/$folder/$class/$data/$catalog/$virtual/class.js +0 -4
- package/$server/$folder/$class/$data/$catalog/$folder/$class/$data/$catalog/class.js +0 -4
- package/$server/$folder/$class/$data/$catalog/$virtual/$folder/$class/$data/$catalog/$virtual/class.js +0 -4
- package/$server/$folder/$class/$data/$operation/$folder/$class/$data/$operation/class.js +0 -4
- package/$server/$folder/$class/$data/$register/$account/$folder/$class/$data/$register/$account/class.js +0 -4
- package/$server/$folder/$class/$data/$register/$folder/$class/$data/$register/$account/class.js +0 -4
- package/$server/$folder/$class/$data/$register/$folder/$class/$data/$register/class.js +0 -4
- package/$server/$folder/$class/$data/$struct/$folder/$class/$data/$struct/class.js +0 -4
- package/$server/$folder/$class/$domain/$folder/$class/$domain/class.js +0 -4
- package/$server/$folder/$class/$module/$folder/$class/$data/$catalog/class.js +0 -4
- package/$server/$folder/$class/$module/$folder/$class/$data/$operation/class.js +0 -4
- package/$server/$folder/$class/$module/$folder/$class/$data/$register/class.js +0 -4
- package/$server/$folder/$class/$module/$folder/$class/$data/$struct/class.js +0 -4
- package/$server/$folder/$class/$module/$folder/$class/$domain/class.js +0 -4
- package/$server/$folder/$class/$module/$folder/$class/$module/class.js +0 -4
- package/$server/$folder/$class/$structure/$folder/$class/$structure/class.js +0 -4
- package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$catalog/class.js +0 -4
- package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$operation/class.js +0 -4
- package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$register/class.js +0 -4
- package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$struct/class.js +0 -4
- package/$server/$folder/$class/$structure/$project/$folder/$class/$domain/class.js +0 -4
- package/$server/$folder/$class/$structure/$project/$folder/$class/$structure/$project/class.js +0 -4
- package/$server/$folder/$class/$structure/$project/$folder/$class/$structure/class.js +0 -4
- package/$server/$folder/$class/$structure/$server/$folder/$class/$domain/class.js +0 -4
- package/$server/$folder/$class/$users/$folder/$class/$structure/$user/class.js +0 -4
package/scripts/migrate-tree.mjs
CHANGED
|
@@ -1,448 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* - ORGANIZATIONS/ + $organization → PROJECTS/ + $project
|
|
4
|
-
* - MODELS/ → MODULES/Модели/ ($provider — подтип $module, $ai внутри $provider/$folder/$class/$ai)
|
|
5
|
-
* - /MODULES → 7 обычных папок-групп на русском (Модели, Поиск, Данные, Коннекторы, Маркетплейсы, Учёт и процессы, MCP)
|
|
6
|
-
* - MCP-модули (с полем `mcp:`) → метапапка $mcp (подтип $module)
|
|
7
|
-
* - Переписывание путей в *.js, *.json, *.md и SQLite-базах work.db
|
|
8
|
-
*
|
|
9
|
-
* Запуск:
|
|
2
|
+
* CLI-обёртка для ручного запуска миграции дерева WORK под архитектуру v1.0.93+:
|
|
10
3
|
* node scripts/migrate-tree.mjs [--dry-run] [--root <dir>]
|
|
11
4
|
*/
|
|
12
|
-
import fs from 'node:fs';
|
|
13
5
|
import path from 'node:path';
|
|
14
6
|
import { fileURLToPath } from 'node:url';
|
|
15
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
MODULE_GROUP_MAP,
|
|
9
|
+
STANDARD_GROUPS,
|
|
10
|
+
rewriteWorkPaths,
|
|
11
|
+
migrateSqliteDb,
|
|
12
|
+
migrateTreeSync as migrateTree,
|
|
13
|
+
} from '../sources/host/tree-migration.js';
|
|
16
14
|
|
|
17
|
-
export
|
|
18
|
-
// Поиск
|
|
19
|
-
DuckDuckGo: 'Поиск',
|
|
20
|
-
SearXNG: 'Поиск',
|
|
21
|
-
Yandex: 'Поиск',
|
|
22
|
-
// Данные
|
|
23
|
-
CBR: 'Данные',
|
|
24
|
-
DaData: 'Данные',
|
|
25
|
-
Geo: 'Данные',
|
|
26
|
-
KLADR: 'Данные',
|
|
27
|
-
RuCalendar: 'Данные',
|
|
28
|
-
Weather: 'Данные',
|
|
29
|
-
// Коннекторы
|
|
30
|
-
'1C': 'Коннекторы',
|
|
31
|
-
'2GIS': 'Коннекторы',
|
|
32
|
-
Bitrix24: 'Коннекторы',
|
|
33
|
-
Telegram: 'Коннекторы',
|
|
34
|
-
YandexDisk: 'Коннекторы',
|
|
35
|
-
// Маркетплейсы (раньше лежали в MODULES/Marketplaces/*)
|
|
36
|
-
Ozon: 'Маркетплейсы',
|
|
37
|
-
Wildberries: 'Маркетплейсы',
|
|
38
|
-
YandexMarket: 'Маркетплейсы',
|
|
39
|
-
// Учёт и процессы
|
|
40
|
-
Register: 'Учёт и процессы',
|
|
41
|
-
Process: 'Учёт и процессы',
|
|
42
|
-
});
|
|
15
|
+
export { MODULE_GROUP_MAP, STANDARD_GROUPS, rewriteWorkPaths, migrateSqliteDb, migrateTree };
|
|
43
16
|
|
|
44
|
-
export const STANDARD_GROUPS = Object.freeze([
|
|
45
|
-
'Модели',
|
|
46
|
-
'Поиск',
|
|
47
|
-
'Данные',
|
|
48
|
-
'Коннекторы',
|
|
49
|
-
'Маркетплейсы',
|
|
50
|
-
'Учёт и процессы',
|
|
51
|
-
'MCP',
|
|
52
|
-
]);
|
|
53
|
-
|
|
54
|
-
const SKIP_DIRS = new Set(['node_modules', '.git', '.svn', '#weights', '#runtime', '#datasets', '.RAG', 'logs', 'history']);
|
|
55
|
-
|
|
56
|
-
/** Переписать старые WORK-пути внутри текста. */
|
|
57
|
-
export function rewriteWorkPaths(text) {
|
|
58
|
-
if (typeof text !== 'string' || !text)
|
|
59
|
-
return text;
|
|
60
|
-
let out = text;
|
|
61
|
-
|
|
62
|
-
// 1. /ORGANIZATIONS → /PROJECTS и $organization → $project
|
|
63
|
-
out = out.replace(/\/ORGANIZATIONS(?=\/|$|['"`\s),;\]}])/g, '/PROJECTS');
|
|
64
|
-
out = out.replace(/(?<![A-Za-z0-9_])\$organization(?![A-Za-z0-9_])/g, '$project');
|
|
65
|
-
|
|
66
|
-
// 2. /MODELS → /MODULES/Модели
|
|
67
|
-
out = out.replace(/\/MODELS(?=\/|$|['"`\s),;\]}])/g, '/MODULES/Модели');
|
|
68
|
-
|
|
69
|
-
// 3. /MODULES/Marketplaces/<id> → /MODULES/Маркетплейсы/<id>
|
|
70
|
-
out = out.replace(/\/MODULES\/Marketplaces(?=\/|$|['"`\s),;\]}])/g, '/MODULES/Маркетплейсы');
|
|
71
|
-
|
|
72
|
-
// 4. Плоские /MODULES/<modId> → /MODULES/<группа>/<modId> (и внутри PROJECTS/<p>/MODULES/<modId>)
|
|
73
|
-
for (const [modId, group] of Object.entries(MODULE_GROUP_MAP)) {
|
|
74
|
-
const esc = modId.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
75
|
-
const re = new RegExp(`(\\/MODULES\\/)${esc}(?=\\/|$|['"\`\\s),;\\]}])`, 'g');
|
|
76
|
-
out = out.replace(re, `$1${group}/${modId}`);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return out;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function moveDirSafe(src, dst, dryRun) {
|
|
83
|
-
if (!fs.existsSync(src))
|
|
84
|
-
return false;
|
|
85
|
-
if (src === dst)
|
|
86
|
-
return false;
|
|
87
|
-
if (dryRun) {
|
|
88
|
-
console.log('[dry-run] mv', src, '->', dst);
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
fs.mkdirSync(path.dirname(dst), { recursive: true });
|
|
92
|
-
if (fs.existsSync(dst)) {
|
|
93
|
-
// Сливаем содержимое рекурсивно, не затирая существующие файлы в dst без нужды
|
|
94
|
-
for (const e of fs.readdirSync(src, { withFileTypes: true })) {
|
|
95
|
-
const s = path.join(src, e.name);
|
|
96
|
-
const d = path.join(dst, e.name);
|
|
97
|
-
if (e.isDirectory())
|
|
98
|
-
moveDirSafe(s, d, dryRun);
|
|
99
|
-
else if (!fs.existsSync(d))
|
|
100
|
-
fs.renameSync(s, d);
|
|
101
|
-
}
|
|
102
|
-
fs.rmSync(src, { recursive: true, force: true });
|
|
103
|
-
return true;
|
|
104
|
-
}
|
|
105
|
-
try {
|
|
106
|
-
fs.renameSync(src, dst);
|
|
107
|
-
}
|
|
108
|
-
catch {
|
|
109
|
-
fs.cpSync(src, dst, { recursive: true });
|
|
110
|
-
fs.rmSync(src, { recursive: true, force: true });
|
|
111
|
-
}
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function rewriteTextFilesInDir(dir, dryRun) {
|
|
116
|
-
if (!fs.existsSync(dir))
|
|
117
|
-
return 0;
|
|
118
|
-
let changed = 0;
|
|
119
|
-
const walk = (cur) => {
|
|
120
|
-
for (const e of fs.readdirSync(cur, { withFileTypes: true })) {
|
|
121
|
-
if (SKIP_DIRS.has(e.name))
|
|
122
|
-
continue;
|
|
123
|
-
const full = path.join(cur, e.name);
|
|
124
|
-
if (e.isDirectory()) {
|
|
125
|
-
walk(full);
|
|
126
|
-
}
|
|
127
|
-
else if (/\.(js|mjs|json|md)$/.test(e.name)) {
|
|
128
|
-
const stat = fs.statSync(full);
|
|
129
|
-
if (stat.size > 2 * 1024 * 1024)
|
|
130
|
-
continue;
|
|
131
|
-
const orig = fs.readFileSync(full, 'utf8');
|
|
132
|
-
const next = rewriteWorkPaths(orig);
|
|
133
|
-
if (next !== orig) {
|
|
134
|
-
changed++;
|
|
135
|
-
if (!dryRun)
|
|
136
|
-
fs.writeFileSync(full, next, 'utf8');
|
|
137
|
-
else
|
|
138
|
-
console.log('[dry-run] rewrite', full);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
walk(dir);
|
|
144
|
-
return changed;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export function migrateSqliteDb(dbPath, dryRun = false) {
|
|
148
|
-
if (!fs.existsSync(dbPath))
|
|
149
|
-
return 0;
|
|
150
|
-
if (dryRun) {
|
|
151
|
-
console.log('[dry-run] sqlite:', dbPath);
|
|
152
|
-
return 1;
|
|
153
|
-
}
|
|
154
|
-
const db = new DatabaseSync(dbPath);
|
|
155
|
-
let updatedRows = 0;
|
|
156
|
-
try {
|
|
157
|
-
db.exec('PRAGMA foreign_keys = OFF;');
|
|
158
|
-
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table'").all()
|
|
159
|
-
.map(r => r.name)
|
|
160
|
-
.filter(n => !n.startsWith('sqlite_') && !n.startsWith('objects_fts'));
|
|
161
|
-
db.exec('BEGIN TRANSACTION;');
|
|
162
|
-
for (const tbl of tables) {
|
|
163
|
-
const cols = db.prepare(`PRAGMA table_info("${tbl}")`).all();
|
|
164
|
-
const textCols = cols.filter(c => /TEXT|CHAR|CLOB/i.test(String(c.type || ''))).map(c => c.name);
|
|
165
|
-
if (!textCols.length)
|
|
166
|
-
continue;
|
|
167
|
-
const pkCols = cols.filter(c => c.pk > 0).sort((a, b) => a.pk - b.pk).map(c => c.name);
|
|
168
|
-
const usePk = pkCols.length > 0;
|
|
169
|
-
const selectCols = usePk
|
|
170
|
-
? [...new Set([...pkCols, ...textCols])]
|
|
171
|
-
: ['rowid', ...textCols];
|
|
172
|
-
const rows = db.prepare(`SELECT ${selectCols.map(c => c === 'rowid' ? 'rowid' : `"${c}"`).join(', ')} FROM "${tbl}"`).all();
|
|
173
|
-
for (const row of rows) {
|
|
174
|
-
const sets = [];
|
|
175
|
-
const vals = [];
|
|
176
|
-
for (const col of textCols) {
|
|
177
|
-
const v = row[col];
|
|
178
|
-
if (typeof v !== 'string' || !v)
|
|
179
|
-
continue;
|
|
180
|
-
const next = rewriteWorkPaths(v);
|
|
181
|
-
if (next !== v) {
|
|
182
|
-
sets.push(`"${col}" = ?`);
|
|
183
|
-
vals.push(next);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
if (sets.length) {
|
|
187
|
-
try {
|
|
188
|
-
if (usePk) {
|
|
189
|
-
const where = pkCols.map(c => `"${c}" = ?`).join(' AND ');
|
|
190
|
-
for (const c of pkCols) vals.push(row[c]);
|
|
191
|
-
db.prepare(`UPDATE "${tbl}" SET ${sets.join(', ')} WHERE ${where}`).run(...vals);
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
vals.push(row.rowid);
|
|
195
|
-
db.prepare(`UPDATE "${tbl}" SET ${sets.join(', ')} WHERE rowid = ?`).run(...vals);
|
|
196
|
-
}
|
|
197
|
-
updatedRows++;
|
|
198
|
-
}
|
|
199
|
-
catch (e) {
|
|
200
|
-
if (/UNIQUE/i.test(String(e?.message || ''))) {
|
|
201
|
-
// Строка с мигрированным ключом уже существует — удаляем дубликат со старым путём
|
|
202
|
-
if (usePk) {
|
|
203
|
-
const where = pkCols.map(c => `"${c}" = ?`).join(' AND ');
|
|
204
|
-
db.prepare(`DELETE FROM "${tbl}" WHERE ${where}`).run(...pkCols.map(c => row[c]));
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
db.prepare(`DELETE FROM "${tbl}" WHERE rowid = ?`).run(row.rowid);
|
|
208
|
-
}
|
|
209
|
-
updatedRows++;
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
throw e;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
db.exec('COMMIT;');
|
|
219
|
-
db.exec('PRAGMA foreign_keys = ON;');
|
|
220
|
-
}
|
|
221
|
-
catch (e) {
|
|
222
|
-
try { db.exec('ROLLBACK;'); } catch { /* ignore */ }
|
|
223
|
-
throw e;
|
|
224
|
-
}
|
|
225
|
-
finally {
|
|
226
|
-
db.close();
|
|
227
|
-
}
|
|
228
|
-
return updatedRows;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
function isMcpModuleDir(modDir) {
|
|
232
|
-
const clsFile = path.join(modDir, '$module', 'class.js');
|
|
233
|
-
if (!fs.existsSync(clsFile))
|
|
234
|
-
return false;
|
|
235
|
-
const text = fs.readFileSync(clsFile, 'utf8');
|
|
236
|
-
return /\bmcp\s*:/.test(text);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
export function migrateTree(rootDir = process.cwd(), { dryRun = false } = {}) {
|
|
240
|
-
const absRoot = path.resolve(rootDir);
|
|
241
|
-
const report = {
|
|
242
|
-
movedOrgs: [],
|
|
243
|
-
movedModules: [],
|
|
244
|
-
movedModels: [],
|
|
245
|
-
convertedMcp: [],
|
|
246
|
-
rewrittenFiles: 0,
|
|
247
|
-
updatedDbRows: 0,
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
// 1. Типы: site из $organization → $project (если ещё не перенесён) и удаление $organization
|
|
251
|
-
const orgTypeDir = path.join(absRoot, '$server', '$folder', '$class', '$structure', '$organization');
|
|
252
|
-
const projTypeDir = path.join(absRoot, '$server', '$folder', '$class', '$structure', '$project');
|
|
253
|
-
const orgSite = path.join(orgTypeDir, 'handlers', 'pages', 'site', '$handler', 'class.js');
|
|
254
|
-
const projSite = path.join(projTypeDir, 'handlers', 'pages', 'site', '$handler', 'class.js');
|
|
255
|
-
if (fs.existsSync(orgSite) && !fs.existsSync(projSite)) {
|
|
256
|
-
if (!dryRun) {
|
|
257
|
-
fs.mkdirSync(path.dirname(projSite), { recursive: true });
|
|
258
|
-
let code = fs.readFileSync(orgSite, 'utf8');
|
|
259
|
-
code = code
|
|
260
|
-
.replace(/\$organization/g, '$project')
|
|
261
|
-
.replace(/'организация'/g, "'проект'");
|
|
262
|
-
fs.writeFileSync(projSite, code, 'utf8');
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
console.log('[dry-run] copy site handler to $project');
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
if (fs.existsSync(orgTypeDir)) {
|
|
269
|
-
if (!dryRun)
|
|
270
|
-
fs.rmSync(orgTypeDir, { recursive: true, force: true });
|
|
271
|
-
else
|
|
272
|
-
console.log('[dry-run] rm', orgTypeDir);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// 2. Типы: MODELS/$ai/$folder/$class/$provider и $ai → $server/$folder/$class/$module/$provider
|
|
276
|
-
const modelsDir = path.join(absRoot, 'MODELS');
|
|
277
|
-
const modTypeDir = path.join(absRoot, '$server', '$folder', '$class', '$module');
|
|
278
|
-
const providerTypeDst = path.join(modTypeDir, '$provider');
|
|
279
|
-
const aiTypeDst = path.join(providerTypeDst, '$folder', '$class', '$ai');
|
|
280
|
-
|
|
281
|
-
const oldProviderType = path.join(modelsDir, '$ai', '$folder', '$class', '$provider');
|
|
282
|
-
const oldAiType = path.join(modelsDir, '$ai', '$folder', '$class', '$ai');
|
|
283
|
-
if (fs.existsSync(oldProviderType))
|
|
284
|
-
moveDirSafe(oldProviderType, providerTypeDst, dryRun);
|
|
285
|
-
if (fs.existsSync(oldAiType))
|
|
286
|
-
moveDirSafe(oldAiType, aiTypeDst, dryRun);
|
|
287
|
-
|
|
288
|
-
// 3. Создаём 7 стандартных обычных папок-групп в /MODULES
|
|
289
|
-
const modulesDir = path.join(absRoot, 'MODULES');
|
|
290
|
-
if (fs.existsSync(modulesDir)) {
|
|
291
|
-
for (const g of STANDARD_GROUPS) {
|
|
292
|
-
const gDir = path.join(modulesDir, g);
|
|
293
|
-
if (!fs.existsSync(gDir) && !dryRun)
|
|
294
|
-
fs.mkdirSync(gDir, { recursive: true });
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// 3a. Marketplaces/* → Маркетплейсы/* (убираем $domain)
|
|
298
|
-
const oldMpDir = path.join(modulesDir, 'Marketplaces');
|
|
299
|
-
if (fs.existsSync(oldMpDir)) {
|
|
300
|
-
for (const e of fs.readdirSync(oldMpDir, { withFileTypes: true })) {
|
|
301
|
-
if (!e.isDirectory() || e.name.startsWith('$'))
|
|
302
|
-
continue;
|
|
303
|
-
const src = path.join(oldMpDir, e.name);
|
|
304
|
-
const dst = path.join(modulesDir, 'Маркетплейсы', e.name);
|
|
305
|
-
if (moveDirSafe(src, dst, dryRun))
|
|
306
|
-
report.movedModules.push(`Marketplaces/${e.name} -> Маркетплейсы/${e.name}`);
|
|
307
|
-
}
|
|
308
|
-
if (!dryRun)
|
|
309
|
-
fs.rmSync(oldMpDir, { recursive: true, force: true });
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// 3b. Раскладываем остальные корневые модули в /MODULES по группам
|
|
313
|
-
for (const e of fs.readdirSync(modulesDir, { withFileTypes: true })) {
|
|
314
|
-
if (!e.isDirectory() || e.name.startsWith('$') || e.name.startsWith('#'))
|
|
315
|
-
continue;
|
|
316
|
-
if (STANDARD_GROUPS.includes(e.name))
|
|
317
|
-
continue;
|
|
318
|
-
const src = path.join(modulesDir, e.name);
|
|
319
|
-
let group = MODULE_GROUP_MAP[e.name];
|
|
320
|
-
if (!group) {
|
|
321
|
-
if (e.name.startsWith('plugin-') || isMcpModuleDir(src))
|
|
322
|
-
group = 'MCP';
|
|
323
|
-
else
|
|
324
|
-
continue;
|
|
325
|
-
}
|
|
326
|
-
const dst = path.join(modulesDir, group, e.name);
|
|
327
|
-
if (moveDirSafe(src, dst, dryRun))
|
|
328
|
-
report.movedModules.push(`${e.name} -> ${group}/${e.name}`);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// 3c. Переносим провайдеров из MODELS/* в MODULES/Модели/*
|
|
332
|
-
if (fs.existsSync(modelsDir)) {
|
|
333
|
-
for (const e of fs.readdirSync(modelsDir, { withFileTypes: true })) {
|
|
334
|
-
if (!e.isDirectory() || e.name.startsWith('$') || e.name.startsWith('#'))
|
|
335
|
-
continue;
|
|
336
|
-
const src = path.join(modelsDir, e.name);
|
|
337
|
-
const dst = path.join(modulesDir, 'Модели', e.name);
|
|
338
|
-
if (moveDirSafe(src, dst, dryRun))
|
|
339
|
-
report.movedModels.push(`MODELS/${e.name} -> MODULES/Модели/${e.name}`);
|
|
340
|
-
}
|
|
341
|
-
if (!dryRun)
|
|
342
|
-
fs.rmSync(modelsDir, { recursive: true, force: true });
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// 3d. Переводим MCP-модули ($module с полем `mcp:`) на подтип $mcp
|
|
346
|
-
for (const g of STANDARD_GROUPS) {
|
|
347
|
-
const gDir = path.join(modulesDir, g);
|
|
348
|
-
if (!fs.existsSync(gDir))
|
|
349
|
-
continue;
|
|
350
|
-
for (const e of fs.readdirSync(gDir, { withFileTypes: true })) {
|
|
351
|
-
if (!e.isDirectory() || e.name.startsWith('$'))
|
|
352
|
-
continue;
|
|
353
|
-
const modDir = path.join(gDir, e.name);
|
|
354
|
-
if (isMcpModuleDir(modDir)) {
|
|
355
|
-
const srcMeta = path.join(modDir, '$module');
|
|
356
|
-
const dstMeta = path.join(modDir, '$mcp');
|
|
357
|
-
if (moveDirSafe(srcMeta, dstMeta, dryRun))
|
|
358
|
-
report.convertedMcp.push(`${g}/${e.name}`);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
// 4. Переносим ORGANIZATIONS/* → PROJECTS/* и меняем $organization → $project
|
|
365
|
-
const orgsDir = path.join(absRoot, 'ORGANIZATIONS');
|
|
366
|
-
const projsDir = path.join(absRoot, 'PROJECTS');
|
|
367
|
-
if (fs.existsSync(orgsDir)) {
|
|
368
|
-
if (!dryRun)
|
|
369
|
-
fs.mkdirSync(projsDir, { recursive: true });
|
|
370
|
-
for (const e of fs.readdirSync(orgsDir, { withFileTypes: true })) {
|
|
371
|
-
if (!e.isDirectory() || e.name.startsWith('$') || e.name.startsWith('#'))
|
|
372
|
-
continue;
|
|
373
|
-
const src = path.join(orgsDir, e.name);
|
|
374
|
-
const dst = path.join(projsDir, e.name);
|
|
375
|
-
if (moveDirSafe(src, dst, dryRun)) {
|
|
376
|
-
report.movedOrgs.push(e.name);
|
|
377
|
-
const oldMeta = path.join(dst, '$organization');
|
|
378
|
-
const newMeta = path.join(dst, '$project');
|
|
379
|
-
if (fs.existsSync(oldMeta))
|
|
380
|
-
moveDirSafe(oldMeta, newMeta, dryRun);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
if (!dryRun)
|
|
384
|
-
fs.rmSync(orgsDir, { recursive: true, force: true });
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
// 5. Внутри каждого проекта в PROJECTS/*/MODULES раскладываем плоские модули по группам
|
|
388
|
-
if (fs.existsSync(projsDir)) {
|
|
389
|
-
for (const proj of fs.readdirSync(projsDir, { withFileTypes: true })) {
|
|
390
|
-
if (!proj.isDirectory() || proj.name.startsWith('$') || proj.name.startsWith('#'))
|
|
391
|
-
continue;
|
|
392
|
-
const pDir = path.join(projsDir, proj.name);
|
|
393
|
-
// Если вдруг осталась метапапка $organization
|
|
394
|
-
const oldMeta = path.join(pDir, '$organization');
|
|
395
|
-
const newMeta = path.join(pDir, '$project');
|
|
396
|
-
if (fs.existsSync(oldMeta))
|
|
397
|
-
moveDirSafe(oldMeta, newMeta, dryRun);
|
|
398
|
-
|
|
399
|
-
const pMods = path.join(pDir, 'MODULES');
|
|
400
|
-
if (fs.existsSync(pMods)) {
|
|
401
|
-
for (const me of fs.readdirSync(pMods, { withFileTypes: true })) {
|
|
402
|
-
if (!me.isDirectory() || me.name.startsWith('$') || me.name.startsWith('#'))
|
|
403
|
-
continue;
|
|
404
|
-
if (STANDARD_GROUPS.includes(me.name))
|
|
405
|
-
continue;
|
|
406
|
-
const group = MODULE_GROUP_MAP[me.name];
|
|
407
|
-
if (group) {
|
|
408
|
-
const src = path.join(pMods, me.name);
|
|
409
|
-
const dst = path.join(pMods, group, me.name);
|
|
410
|
-
moveDirSafe(src, dst, dryRun);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
// Мигрируем SQLite БД проекта
|
|
416
|
-
const dbPath = path.join(pDir, '$project', '#system', 'work.db');
|
|
417
|
-
report.updatedDbRows += migrateSqliteDb(dbPath, dryRun);
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
// 6. Переписываем старые пути в файлах внутри MODULES/, PROJECTS/, $server/$folder/$class/$module/$provider, #system/settings.json
|
|
422
|
-
report.rewrittenFiles += rewriteTextFilesInDir(modulesDir, dryRun);
|
|
423
|
-
report.rewrittenFiles += rewriteTextFilesInDir(projsDir, dryRun);
|
|
424
|
-
report.rewrittenFiles += rewriteTextFilesInDir(providerTypeDst, dryRun);
|
|
425
|
-
|
|
426
|
-
const sysSettings = path.join(absRoot, '#system', 'settings.json');
|
|
427
|
-
if (fs.existsSync(sysSettings)) {
|
|
428
|
-
const orig = fs.readFileSync(sysSettings, 'utf8');
|
|
429
|
-
const next = rewriteWorkPaths(orig);
|
|
430
|
-
if (next !== orig) {
|
|
431
|
-
report.rewrittenFiles++;
|
|
432
|
-
if (!dryRun)
|
|
433
|
-
fs.writeFileSync(sysSettings, next, 'utf8');
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
// Системная БД ./.data/work.db (если есть)
|
|
438
|
-
const rootDb = path.join(absRoot, '.data', 'work.db');
|
|
439
|
-
if (fs.existsSync(rootDb))
|
|
440
|
-
report.updatedDbRows += migrateSqliteDb(rootDb, dryRun);
|
|
441
|
-
|
|
442
|
-
return report;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
// CLI запуск
|
|
446
17
|
const isMain = process.argv[1] && path.resolve(process.argv[1]) === path.resolve(fileURLToPath(import.meta.url));
|
|
447
18
|
if (isMain) {
|
|
448
19
|
const args = process.argv.slice(2);
|
package/sources/client/class.js
CHANGED
|
@@ -12,7 +12,7 @@ export class $class extends $folder{
|
|
|
12
12
|
icon:{
|
|
13
13
|
get(){
|
|
14
14
|
if (this.type === '$module')
|
|
15
|
-
return 'odant:module';
|
|
15
|
+
return this.DATA?.icon || 'odant:module';
|
|
16
16
|
if (this.type === '$domain' && this.id === 'MODULES')
|
|
17
17
|
return 'odant:folder';
|
|
18
18
|
if (this.type === '$structure')
|
|
@@ -6,7 +6,7 @@ import * as CORE from '../server/index.js';
|
|
|
6
6
|
import { $server } from '../server/server.js';
|
|
7
7
|
import { audit } from '../server/access/audit.js';
|
|
8
8
|
import { inspectInvite, consumeInvite } from '../server/access/invites.js';
|
|
9
|
-
import { assertWorkplaceAvailableForLogin } from '../modules/license/index.js';
|
|
9
|
+
import { assertWorkplaceAvailableForLogin, sendLoginCodeViaLicenseHub } from '../modules/license/index.js';
|
|
10
10
|
|
|
11
11
|
const REGISTER_CODE_TTL_MS = 10 * 60 * 1000;
|
|
12
12
|
const REGISTER_MAX_ATTEMPTS = 5;
|
|
@@ -114,7 +114,21 @@ export const authMethods = {
|
|
|
114
114
|
if (DEV_MODE) {
|
|
115
115
|
return "На Вашу почту отправлено письмо с одноразовым кодом, введите его для продолжения регистрации.";
|
|
116
116
|
}
|
|
117
|
-
|
|
117
|
+
// Подключённый (лицензированный) клиент без собственного SMTP отправляет код через сервер поддержки
|
|
118
|
+
let relayError = '';
|
|
119
|
+
try {
|
|
120
|
+
const relayed = await sendLoginCodeViaLicenseHub({ email, code });
|
|
121
|
+
if (relayed?.ok)
|
|
122
|
+
return "На Вашу почту отправлено письмо с одноразовым кодом, введите его для продолжения регистрации.";
|
|
123
|
+
}
|
|
124
|
+
catch (relayErr) {
|
|
125
|
+
relayError = relayErr?.message || String(relayErr);
|
|
126
|
+
console.warn('[auth] Код входа не отправлен через сервер поддержки:', relayError);
|
|
127
|
+
}
|
|
128
|
+
throw new Error(
|
|
129
|
+
'Почтовый сервер не настроен. Администратор (BOSS) может настроить почтовый ящик в корне WORK → представление «Почта» (⚙️ Почтовые ящики) или в файле #system/mail.json'
|
|
130
|
+
+ (relayError ? `, либо подключить лицензию к серверу поддержки (${relayError})` : '')
|
|
131
|
+
);
|
|
118
132
|
}
|
|
119
133
|
const fromUser = activeMailer.fromUser || activeMailer.transport?.options?.auth?.user || 'noreply@localhost';
|
|
120
134
|
const mailOptions = {
|
|
@@ -18,6 +18,7 @@ import path from 'node:path';
|
|
|
18
18
|
import crypto from 'node:crypto';
|
|
19
19
|
import zlib from 'node:zlib';
|
|
20
20
|
import { spawn } from 'node:child_process';
|
|
21
|
+
import { needsTreeMigration, migrateTreeSync, rewriteWorkPaths } from './tree-migration.js';
|
|
21
22
|
|
|
22
23
|
export const PACKAGE_NAME = 'odant-work';
|
|
23
24
|
export const DEFAULT_NPM_REGISTRY = process.env.WORK_NPM_REGISTRY || 'https://registry.npmjs.org';
|
|
@@ -162,6 +163,19 @@ const TRACKED_ROOTS = [
|
|
|
162
163
|
'PROJECTS/$domain',
|
|
163
164
|
];
|
|
164
165
|
|
|
166
|
+
export function isExcludedFromPackageManifest(relPath) {
|
|
167
|
+
const segs = normalizeRelPath(relPath).split('/').filter(Boolean);
|
|
168
|
+
if (!segs.length)
|
|
169
|
+
return true;
|
|
170
|
+
if (segs[0] === 'MODULES' && segs[1] === 'Модели') {
|
|
171
|
+
if (segs[2] === 'odant' || segs[2] === 'Halogen')
|
|
172
|
+
return true;
|
|
173
|
+
if (segs[2] === 'Local' && segs[3] && !segs[3].startsWith('$'))
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
|
|
165
179
|
/**
|
|
166
180
|
* Собрать карту { [relPath]: sha256 } всех отслеживаемых файлов поставки в директории.
|
|
167
181
|
*/
|
|
@@ -181,6 +195,7 @@ export function scanTrackedFiles(rootDir = '.') {
|
|
|
181
195
|
|| rel.startsWith('.git/')
|
|
182
196
|
|| rel.startsWith('.svn/')
|
|
183
197
|
|| rel.includes('/.venv/')
|
|
198
|
+
|| isExcludedFromPackageManifest(rel)
|
|
184
199
|
|| isProtectedUserPath(rel)
|
|
185
200
|
) {
|
|
186
201
|
return;
|
|
@@ -550,6 +565,25 @@ export function applyUpdateFromDirectory({
|
|
|
550
565
|
dependenciesChanged: false,
|
|
551
566
|
};
|
|
552
567
|
|
|
568
|
+
// Если пакет использует новую групповую раскладку (MODULES/Модели), сначала безопасно
|
|
569
|
+
// мигрируем старое дерево на диске и ключи oldManifest.files, чтобы пользовательские
|
|
570
|
+
// изменения в старых путях сохранились и корректно сверились с эталоном.
|
|
571
|
+
try {
|
|
572
|
+
const sourceHasGroupedLayout = fs.existsSync(path.join(absSource, 'MODULES', 'Модели'));
|
|
573
|
+
if (sourceHasGroupedLayout && needsTreeMigration(absRoot)) {
|
|
574
|
+
report.treeMigration = migrateTreeSync(absRoot);
|
|
575
|
+
if (oldManifest?.files && typeof oldManifest.files === 'object') {
|
|
576
|
+
const remapped = {};
|
|
577
|
+
for (const [k, v] of Object.entries(oldManifest.files)) {
|
|
578
|
+
const nextKey = normalizeRelPath(rewriteWorkPaths('/' + normalizeRelPath(k)));
|
|
579
|
+
remapped[nextKey] = v;
|
|
580
|
+
}
|
|
581
|
+
oldManifest.files = remapped;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
catch { /* ignore */ }
|
|
586
|
+
|
|
553
587
|
const newManifestFiles = {};
|
|
554
588
|
const seenInSource = new Set();
|
|
555
589
|
const seenInSourceLower = new Set();
|
|
@@ -739,30 +773,6 @@ export function applyUpdateFromDirectory({
|
|
|
739
773
|
catch { /* ignore */ }
|
|
740
774
|
}
|
|
741
775
|
|
|
742
|
-
// Очистка устаревшей дублирующей ветки MODELS/Halogen (объединена с MODELS/Local) с сохранением скачанных весов
|
|
743
|
-
try {
|
|
744
|
-
const legacyHalogen = path.join(absRoot, 'Halogen');
|
|
745
|
-
const localModelsDir = path.join(absRoot, 'Local');
|
|
746
|
-
if (fs.existsSync(legacyHalogen) && !fs.existsSync(path.join(absSource, 'Halogen'))) {
|
|
747
|
-
for (const entry of fs.readdirSync(legacyHalogen, { withFileTypes: true })) {
|
|
748
|
-
if (!entry.isDirectory() || entry.name.startsWith('$') || entry.name.startsWith('#'))
|
|
749
|
-
continue;
|
|
750
|
-
const oldWeights = path.join(legacyHalogen, entry.name, '#weights');
|
|
751
|
-
if (fs.existsSync(oldWeights)) {
|
|
752
|
-
const hasWeights = fs.readdirSync(oldWeights).some(
|
|
753
|
-
f => !f.endsWith('.part') && /\.(gguf|safetensors|hgn|hnpw|bin|onnx|pt|pth)$/i.test(f)
|
|
754
|
-
);
|
|
755
|
-
if (hasWeights && !fs.existsSync(path.join(localModelsDir, entry.name))) {
|
|
756
|
-
fs.mkdirSync(localModelsDir, { recursive: true });
|
|
757
|
-
fs.cpSync(path.join(legacyHalogen, entry.name), path.join(localModelsDir, entry.name), { recursive: true });
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
fs.rmSync(legacyHalogen, { recursive: true, force: true });
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
catch { /* ignore */ }
|
|
765
|
-
|
|
766
776
|
// Сохраняем обновлённый манифест поставки
|
|
767
777
|
const nextManifest = {
|
|
768
778
|
packageName: PACKAGE_NAME,
|