odant-work 1.0.100 → 1.0.102
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/$server/$folder/$class/$structure/$department/ai/config.js +9 -0
- package/$server/$folder/$class/$structure/$department/ai/system.md +11 -0
- package/$server/$folder/$class/$structure/$department/class.js +9 -0
- package/$server/$folder/$class/$structure/$project/ai/config.js +9 -0
- package/$server/$folder/$class/$structure/$project/ai/system.md +12 -0
- package/$server/$folder/$class/$structure/$project/class.js +4 -1
- package/$server/$folder/$class/$structure/$project/handlers/pages/site/$handler/class.js +1 -1
- package/$server/$folder/$class/$structure/$server/ai/config.js +9 -0
- package/$server/$folder/$class/$structure/$server/ai/system.md +10 -0
- package/$server/$folder/$class/$structure/$server/class.js +2 -0
- package/$server/$folder/$class/$structure/$user/ai/config.js +9 -0
- package/$server/$folder/$class/$structure/$user/ai/system.md +8 -0
- package/$server/$folder/$class/$structure/$user/class.js +3 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/profile/$handler/class.js +5 -2
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/staff/$handler/class.js +3 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/tokens/$handler/class.js +24 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/users/$handler/class.js +213 -0
- package/$server/$folder/$class/$structure/ai/system.md +1 -1
- package/$server/$folder/$class/$structure/class.js +4 -2
- package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +67 -20
- package/$server/$folder/$class/$structure/handlers/pages/form/system/agent/$handler/class.js +132 -3
- package/$server/$folder/$class/$structure/handlers/pages/form/system/staff/$handler/class.js +2 -2
- package/$server/$folder/$class/$structure/handlers/pages/site/$handler/class.js +2 -1
- package/$server/$folder/$class/ai/system.md +2 -2
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/class.js +7 -0
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/dock.js +22 -31
- package/$server/$folder/handlers/pages/form/$handler/class.js +47 -5
- package/$server/$folder/lib/chat-item/chat-item.js +14 -2
- package/$server/$folder/lib/consultant/consultant.js +1 -1
- package/$server/$folder/lib/explorer/explorer.js +38 -12
- package/$server/$folder/lib/icon/icon.js +1 -1
- package/$server/$folder/lib/node/node.js +3 -3
- package/$server/$folder/lib/site-loc/site-loc.js +8 -3
- package/$server/$folder/lib/tree/tree.js +8 -9
- package/AGENTS.md +3 -3
- package/MODULES/$domain/class.js +1 -0
- package/MODULES//320/234/320/276/320/264/320/265/320/273/320/270/Local/$provider/class.js +1 -0
- package/{$server/$folder/$class/$users → USERS/$user}/class.js +4 -1
- package/oda/oda.js +15 -1
- package/package.json +1 -1
- package/readme.md +1 -1
- package/scripts/import-bis.mjs +5 -5
- package/scripts/import-delovaya.mjs +5 -5
- package/sources/client/class.js +1 -1
- package/sources/client.js +84 -38
- package/sources/data/api.js +1 -1
- package/sources/data/classes.js +2 -1
- package/sources/data/schema.js +2 -0
- package/sources/host/auth-methods.js +15 -4
- package/sources/modules/agent/index.js +22 -6
- package/sources/modules/agent/node-rules.js +353 -9
- package/sources/modules/agent/scheduler.js +7 -0
- package/sources/modules/agent/scope.js +8 -6
- package/sources/modules/agent/tools/work/access.js +1 -1
- package/sources/modules/agent/tools/work/classes.js +1 -1
- package/sources/modules/agent/triggers.js +1 -1
- package/sources/modules/agent/twin-bus.js +2 -1
- package/sources/modules/notify/index.js +5 -2
- package/sources/modules/rag/extract.js +1 -1
- package/sources/modules/trainer/local-engine.js +3 -1
- package/sources/modules/user-profile/user-profile.js +120 -115
- package/sources/modules/user-profile/user-tokens.js +185 -0
- package/sources/server/access/gateway.js +4 -3
- package/sources/server/access/links.js +9 -6
- package/sources/server/chat-threads.js +1 -1
- package/sources/server/class/base-template.js +3 -2
- package/sources/server/class/distro.js +9 -5
- package/sources/server/class/feed.js +30 -0
- package/sources/server/class/scaffold.js +137 -0
- package/sources/server/class/search.js +2 -2
- package/sources/server/class/security.js +35 -11
- package/sources/server/class.js +5 -3
- package/sources/server/folder.js +17 -13
- package/sources/server/logs.js +14 -0
- package/sources/server/node.js +1 -1
- package/sources/server/user.js +3 -0
- package/sources/work.js +7 -0
- package/USERS/$users/class.js +0 -4
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* презентационные материалы и пользовательская документация (`docs`, `readme.md`, `whitepaper.*`);
|
|
8
8
|
* - Настроенные эталонные модули и коннекторы (`/MODULES/**`);
|
|
9
9
|
* - Чистые системные метапапки доменов (`/ORGANIZATIONS/$domain`, `/PROJECTS/$domain`,
|
|
10
|
-
* `/USERS/$
|
|
10
|
+
* `/USERS/$user`, `/NODES/$node` / `/NODES/$nodes`) БЕЗ пользователей, организаций и проектов;
|
|
11
11
|
* - Опционально: `node_modules` (для 100% офлайн-запуска без `npm install`);
|
|
12
12
|
* - Опционально: локальные модели ИИ и веса (`/MODELS/Local/*`, `/MODELS/Halogen/*` с `#weights` и `#adapters`);
|
|
13
13
|
* - Опционально: локальный Python-рантайм (`.venv`);
|
|
@@ -62,7 +62,6 @@ const CORE_DIRS = [
|
|
|
62
62
|
'rules',
|
|
63
63
|
'docs',
|
|
64
64
|
'PROJECTS/$domain',
|
|
65
|
-
'USERS/$users',
|
|
66
65
|
];
|
|
67
66
|
|
|
68
67
|
function normRel(p) {
|
|
@@ -288,9 +287,14 @@ export function collectDistroEntriesSync(rootDir = process.cwd(), opts = {}) {
|
|
|
288
287
|
for (const dir of CORE_DIRS) {
|
|
289
288
|
walkRelDir(dir);
|
|
290
289
|
}
|
|
291
|
-
for (const
|
|
292
|
-
|
|
293
|
-
|
|
290
|
+
for (const container of ['USERS', 'NODES']) {
|
|
291
|
+
const containerAbs = path.join(absRoot, container);
|
|
292
|
+
if (!fs.existsSync(containerAbs))
|
|
293
|
+
continue;
|
|
294
|
+
for (const e of fs.readdirSync(containerAbs, { withFileTypes: true })) {
|
|
295
|
+
if (e.isDirectory() && e.name.startsWith('$'))
|
|
296
|
+
walkRelDir(`${container}/${e.name}`);
|
|
297
|
+
}
|
|
294
298
|
}
|
|
295
299
|
|
|
296
300
|
// 4. Раздел /MODULES (все группы кроме Модели — целиком; в Модели пропускаем odant, а Local/Halogen — по выбору)
|
|
@@ -206,6 +206,36 @@ export const classFeedMethods = {
|
|
|
206
206
|
return listNodeRules(this, params);
|
|
207
207
|
},
|
|
208
208
|
|
|
209
|
+
/** Безопасный выбор модели по умолчанию для чата нового пользователя. */
|
|
210
|
+
async agent_default_model(params = {}) {
|
|
211
|
+
const { loadConfig } = await import('../../modules/agent/resources.js');
|
|
212
|
+
const { findFirstAvailableChatModel } = await import('../../modules/agent/index.js');
|
|
213
|
+
let place = this;
|
|
214
|
+
if (params.nodePath && globalThis.WORK) {
|
|
215
|
+
const target = await globalThis.WORK.get_item(String(params.nodePath)).catch(() => null);
|
|
216
|
+
const resolved = Array.isArray(target) ? target.at(-1) : target;
|
|
217
|
+
if (resolved)
|
|
218
|
+
place = resolved;
|
|
219
|
+
}
|
|
220
|
+
const cfg = await loadConfig(place).catch(() => ({}));
|
|
221
|
+
if (cfg?.model) {
|
|
222
|
+
const item = await globalThis.WORK?.get_item(cfg.model).catch(() => null);
|
|
223
|
+
if (item) {
|
|
224
|
+
await item.init?.catch?.(() => {});
|
|
225
|
+
if (item.DATA?.enabled !== false && (item.aiActive ?? item.DATA?.aiActive) !== false && typeof item.streamChat === 'function')
|
|
226
|
+
return cfg.model;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return (await findFirstAvailableChatModel()) || '';
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
/** Запустить автономный аудит узла прямо сейчас (только BOSS). */
|
|
233
|
+
async agent_audit_run(params = {}) {
|
|
234
|
+
await this.assertAccess(params, FS.$class.ACCESS_LEVEL.BOSS);
|
|
235
|
+
const { runNodeAutonomousAudit } = await import('../../modules/agent/node-rules.js');
|
|
236
|
+
return runNodeAutonomousAudit(this, { force: true, session: params.session });
|
|
237
|
+
},
|
|
238
|
+
|
|
209
239
|
/** Сохранить/удалить правило проактивности узла (только BOSS). */
|
|
210
240
|
async agent_rule_save(params = {}) {
|
|
211
241
|
const { saveNodeRule } = await import('../../modules/agent/node-rules.js');
|
|
@@ -110,6 +110,143 @@ export function readDeclaredChildTypesSync(branchDir) {
|
|
|
110
110
|
return out;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
function rootClassBranchSync(rootDir = process.cwd()) {
|
|
114
|
+
const base = String(rootDir || process.cwd());
|
|
115
|
+
try {
|
|
116
|
+
for (const ent of fs.readdirSync(base, { withFileTypes: true })) {
|
|
117
|
+
if (!(ent.isDirectory() || ent.isSymbolicLink()) || ent.name[0] !== '$' || ent.name === '$folder' || ent.name === '$file')
|
|
118
|
+
continue;
|
|
119
|
+
const candidate = path.join(base, ent.name, '$folder', '$class');
|
|
120
|
+
if (fs.existsSync(candidate))
|
|
121
|
+
return candidate;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
catch { /* ignore */ }
|
|
125
|
+
return '';
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Прочитать дочерние типы из ветки структуры в корневом типизаторе. */
|
|
129
|
+
export function structureSubtypesSync(rootDir = process.cwd()) {
|
|
130
|
+
const baseBranch = rootClassBranchSync(rootDir);
|
|
131
|
+
if (!baseBranch)
|
|
132
|
+
return [];
|
|
133
|
+
try {
|
|
134
|
+
for (const ent of fs.readdirSync(baseBranch, { withFileTypes: true })) {
|
|
135
|
+
if (!ent.isDirectory() || ent.name[0] !== '$' || ent.name === '$folder' || ent.name === '$file')
|
|
136
|
+
continue;
|
|
137
|
+
const subDir = path.join(baseBranch, ent.name);
|
|
138
|
+
const clsFile = path.join(subDir, 'class.js');
|
|
139
|
+
if (readOwnBoolSync(clsFile, 'isStructure') === true)
|
|
140
|
+
return readDeclaredChildTypesSync(subDir);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
catch { /* ignore */ }
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Имя метапапки подразделения (подтипа с `isDepartment: true` в ветке структур). */
|
|
148
|
+
export function departmentMetaNameSync(rootDir = process.cwd()) {
|
|
149
|
+
const baseBranch = rootClassBranchSync(rootDir);
|
|
150
|
+
if (!baseBranch)
|
|
151
|
+
return '';
|
|
152
|
+
try {
|
|
153
|
+
for (const ent of fs.readdirSync(baseBranch, { withFileTypes: true })) {
|
|
154
|
+
if (!ent.isDirectory() || ent.name[0] !== '$' || ent.name === '$folder' || ent.name === '$file')
|
|
155
|
+
continue;
|
|
156
|
+
const subDir = path.join(baseBranch, ent.name);
|
|
157
|
+
if (readOwnBoolSync(path.join(subDir, 'class.js'), 'isStructure') !== true)
|
|
158
|
+
continue;
|
|
159
|
+
for (const sub of fs.readdirSync(subDir, { withFileTypes: true })) {
|
|
160
|
+
if (!sub.isDirectory() || sub.name[0] !== '$')
|
|
161
|
+
continue;
|
|
162
|
+
if (readOwnBoolSync(path.join(subDir, sub.name, 'class.js'), 'isDepartment') === true)
|
|
163
|
+
return sub.name;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
catch { /* ignore */ }
|
|
168
|
+
return '';
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** Проверить булево свойство в class.js объявления типа внутри ветки `$folder/$class`. */
|
|
172
|
+
export function readTypePropSync(classBranchDir, type, key) {
|
|
173
|
+
const chain = findTypePathOnDisk(classBranchDir, type);
|
|
174
|
+
if (!chain || chain.length < 2)
|
|
175
|
+
return undefined;
|
|
176
|
+
return readOwnBoolSync(path.join(classBranchDir, ...chain.slice(1), 'class.js'), key);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Одноразовая миграция при старте: папки подразделений с прежней метапапкой
|
|
181
|
+
* базовой структуры переводим на выделенный суб-тип подразделений (`isDepartment: true`).
|
|
182
|
+
* Системный типизатор ($server/$folder/$class/...) и ветки $folder не затрагиваются.
|
|
183
|
+
*/
|
|
184
|
+
export function migrateDepartmentMetasSync(rootDir = process.cwd()) {
|
|
185
|
+
const deptMeta = departmentMetaNameSync(rootDir);
|
|
186
|
+
if (!deptMeta)
|
|
187
|
+
return [];
|
|
188
|
+
const baseBranch = rootClassBranchSync(rootDir);
|
|
189
|
+
if (!baseBranch)
|
|
190
|
+
return [];
|
|
191
|
+
let structMeta = '';
|
|
192
|
+
try {
|
|
193
|
+
for (const ent of fs.readdirSync(baseBranch, { withFileTypes: true })) {
|
|
194
|
+
if (ent.isDirectory() && ent.name[0] === '$' && readOwnBoolSync(path.join(baseBranch, ent.name, 'class.js'), 'isStructure') === true) {
|
|
195
|
+
structMeta = ent.name;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
catch { /* ignore */ }
|
|
201
|
+
if (!structMeta || structMeta === deptMeta)
|
|
202
|
+
return [];
|
|
203
|
+
const migrated = [];
|
|
204
|
+
const walkProject = (dir) => {
|
|
205
|
+
let entries;
|
|
206
|
+
try {
|
|
207
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
for (const ent of entries) {
|
|
213
|
+
if (!ent.isDirectory())
|
|
214
|
+
continue;
|
|
215
|
+
if (ent.name.startsWith('$') || ent.name.startsWith('.') || ent.name.startsWith('#') || ent.name === 'MODULES' || SCAFFOLD_SKIP.has(ent.name))
|
|
216
|
+
continue;
|
|
217
|
+
const childDir = path.join(dir, ent.name);
|
|
218
|
+
const oldMeta = path.join(childDir, structMeta);
|
|
219
|
+
const newMeta = path.join(childDir, deptMeta);
|
|
220
|
+
if (fs.existsSync(oldMeta) && !fs.existsSync(newMeta)) {
|
|
221
|
+
try {
|
|
222
|
+
fs.renameSync(oldMeta, newMeta);
|
|
223
|
+
migrated.push(childDir);
|
|
224
|
+
}
|
|
225
|
+
catch { /* ignore */ }
|
|
226
|
+
}
|
|
227
|
+
walkProject(childDir);
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
const rootAbs = String(rootDir || process.cwd());
|
|
231
|
+
try {
|
|
232
|
+
for (const top of fs.readdirSync(rootAbs, { withFileTypes: true })) {
|
|
233
|
+
if (!top.isDirectory() || top.name.startsWith('$') || top.name.startsWith('.'))
|
|
234
|
+
continue;
|
|
235
|
+
const containerDir = path.join(rootAbs, top.name);
|
|
236
|
+
const domainDirs = fs.readdirSync(containerDir, { withFileTypes: true }).filter(e => e.isDirectory() && e.name[0] === '$');
|
|
237
|
+
if (!domainDirs.some(d => readOwnBoolSync(path.join(containerDir, d.name, 'class.js'), 'archiveType') !== undefined || /\barchiveType\s*:/.test(fs.existsSync(path.join(containerDir, d.name, 'class.js')) ? fs.readFileSync(path.join(containerDir, d.name, 'class.js'), 'utf-8') : '')))
|
|
238
|
+
continue;
|
|
239
|
+
for (const proj of fs.readdirSync(containerDir, { withFileTypes: true })) {
|
|
240
|
+
if (!proj.isDirectory() || proj.name.startsWith('$') || proj.name.startsWith('.'))
|
|
241
|
+
continue;
|
|
242
|
+
walkProject(path.join(containerDir, proj.name));
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
catch { /* ignore */ }
|
|
247
|
+
return migrated;
|
|
248
|
+
}
|
|
249
|
+
|
|
113
250
|
/** Прочитать собственные объявления дочерних $-типов из `<dir>/<type>/$folder/$class`. */
|
|
114
251
|
export function readOwnChildTypesSync(realDir, type) {
|
|
115
252
|
if (!realDir || !type)
|
|
@@ -113,7 +113,7 @@ export const classSearchMethods = {
|
|
|
113
113
|
if ((clsItem.type === '$catalog' || clsItem.type === '$operation') && typeof clsItem.db_query === 'function') {
|
|
114
114
|
try {
|
|
115
115
|
const qParams = { ...params, search: rawQ, limit: 25 };
|
|
116
|
-
if (this.type === '$structure' && clsItem.type === '$operation')
|
|
116
|
+
if ((this.type === '$structure' || this.DATA?.isDepartment) && clsItem.type === '$operation')
|
|
117
117
|
qParams.unit = this.path;
|
|
118
118
|
const res = await clsItem.db_query(qParams);
|
|
119
119
|
for (const it of res?.items || []) {
|
|
@@ -172,7 +172,7 @@ export const classSearchMethods = {
|
|
|
172
172
|
await scanFolderFiles(cur.meta_folder, cur, 0);
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
if (cur.type === '$project' || cur.type === '$
|
|
175
|
+
if (cur.type === '$project' || cur.type === '$structure' || cur.DATA?.isStructure) {
|
|
176
176
|
const sec = cur.DATA?.['#security'];
|
|
177
177
|
if (sec) {
|
|
178
178
|
const { common, places } = WORKPLACES.normalizeSecurity(sec);
|
|
@@ -575,6 +575,17 @@ export const classSecurityMethods = {
|
|
|
575
575
|
}
|
|
576
576
|
if (this._isSystemItem(item))
|
|
577
577
|
return true;
|
|
578
|
+
if (this.areaOf(item).kind === POLICY.AREA.SECRET)
|
|
579
|
+
return false;
|
|
580
|
+
const isUserSession = Boolean(uid && params.session?.principal?.kind !== 'node');
|
|
581
|
+
if (isUserSession && (this.DATA?.allowAllUsers === true || item?.DATA?.allowAllUsers === true)) {
|
|
582
|
+
if (!(item instanceof FS.$class) || item === this || item.DATA?.allowAllUsers === true || !item.hasAssignments?.())
|
|
583
|
+
return true;
|
|
584
|
+
}
|
|
585
|
+
if (this.DATA?.container === true && !this.hasAssignments() && (item === this || !(item instanceof FS.$class))) {
|
|
586
|
+
if (isUserSession && await this._hasAccessibleChild(item, params))
|
|
587
|
+
return true;
|
|
588
|
+
}
|
|
578
589
|
const roles = await this.roles(params);
|
|
579
590
|
const isModNode = this.type === '$module'
|
|
580
591
|
|| item?.type === '$module'
|
|
@@ -728,7 +739,7 @@ export const classSecurityMethods = {
|
|
|
728
739
|
continue;
|
|
729
740
|
const sub = await Promise.resolve(node.items).catch(() => []) || [];
|
|
730
741
|
for (const s of sub) {
|
|
731
|
-
if (s
|
|
742
|
+
if (s && (s.type === '$structure' || s.DATA?.isDepartment) && s.id?.[0] !== '$')
|
|
732
743
|
stack.push({ node: s, depth: depth + 1 });
|
|
733
744
|
}
|
|
734
745
|
}
|
|
@@ -739,18 +750,36 @@ export const classSecurityMethods = {
|
|
|
739
750
|
return false;
|
|
740
751
|
},
|
|
741
752
|
|
|
753
|
+
async _hasAccessibleChild(node, params, depth = 0) {
|
|
754
|
+
if (!node || depth > 3)
|
|
755
|
+
return false;
|
|
756
|
+
const items = await Promise.resolve(node.items).catch(() => []);
|
|
757
|
+
for (const i of items || []) {
|
|
758
|
+
if (!i || i.isMetaFolder || i.id?.[0] === '$')
|
|
759
|
+
continue;
|
|
760
|
+
if (i instanceof FS.$class) {
|
|
761
|
+
if (await i.allowAccess(params))
|
|
762
|
+
return true;
|
|
763
|
+
}
|
|
764
|
+
else if (depth < 3 && await this._hasAccessibleChild(i, params, depth + 1)) {
|
|
765
|
+
return true;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
return false;
|
|
769
|
+
},
|
|
770
|
+
|
|
742
771
|
async allowAccess(params) {
|
|
743
772
|
const isSysSession = DEV_MODE || !params?.session || params.session.$user === globalThis.WORK;
|
|
744
|
-
|
|
745
|
-
|
|
773
|
+
await this.init;
|
|
774
|
+
// Раздел /USERS (usersContainer): виден внутренним сотрудникам и скрыт от внешних (external-only) и гостей
|
|
775
|
+
if (this.DATA?.usersContainer === true) {
|
|
746
776
|
if (isSysSession)
|
|
747
777
|
return true;
|
|
748
778
|
if (params?.session?.principal?.kind === 'node')
|
|
749
779
|
return false;
|
|
750
780
|
return this._hasInternalWorkRole(params);
|
|
751
781
|
}
|
|
752
|
-
// Домен-контейнер (например /PROJECTS): виден только BOSS или при наличии хотя бы одного доступного потомка
|
|
753
|
-
await this.init;
|
|
782
|
+
// Домен-контейнер (например /PROJECTS, /MODULES): виден только BOSS или при наличии хотя бы одного доступного потомка
|
|
754
783
|
if (this.DATA?.container === true && !this.hasAssignments()) {
|
|
755
784
|
if (isSysSession)
|
|
756
785
|
return true;
|
|
@@ -759,12 +788,7 @@ export const classSecurityMethods = {
|
|
|
759
788
|
const uid = this.constructor.resolveUid(params);
|
|
760
789
|
if (uid && (await this.allBosses).some(u => u?.id === uid))
|
|
761
790
|
return true;
|
|
762
|
-
|
|
763
|
-
for (const i of items) {
|
|
764
|
-
if (i instanceof FS.$class && await i.allowAccess(params))
|
|
765
|
-
return true;
|
|
766
|
-
}
|
|
767
|
-
return false;
|
|
791
|
+
return this._hasAccessibleChild(this, params);
|
|
768
792
|
}
|
|
769
793
|
let result = await this.canSee(this, params);
|
|
770
794
|
if (!result) {
|
package/sources/server/class.js
CHANGED
|
@@ -51,6 +51,7 @@ import {
|
|
|
51
51
|
ensureModelField,
|
|
52
52
|
parseCreateDevice,
|
|
53
53
|
findChildWithModel,
|
|
54
|
+
departmentMetaNameSync,
|
|
54
55
|
} from './class/scaffold.js';
|
|
55
56
|
import {
|
|
56
57
|
buildBasePassportClassJs,
|
|
@@ -166,7 +167,7 @@ export class $class extends $folder {
|
|
|
166
167
|
return 'odant:module';
|
|
167
168
|
if (this.type === '$domain' && this.id === 'MODULES')
|
|
168
169
|
return 'odant:folder';
|
|
169
|
-
if (this.type === '$structure')
|
|
170
|
+
if (this.type === '$structure' || this.DATA?.isDepartment)
|
|
170
171
|
return this.DATA?.icon || 'odant:structure';
|
|
171
172
|
return this.DATA?.icon;
|
|
172
173
|
},
|
|
@@ -445,7 +446,7 @@ export class $class extends $folder {
|
|
|
445
446
|
|
|
446
447
|
const self_to_save = this.constructor.getDifference(self_data, baseSelf);
|
|
447
448
|
|
|
448
|
-
const fileParams = Object.assign({}, params, { filename: 'class.js' });
|
|
449
|
+
const fileParams = Object.assign({ ignore_save_logs: true }, params, { filename: 'class.js' });
|
|
449
450
|
const toDataScript = data => 'export default ' + this.constructor.toScript(data);
|
|
450
451
|
|
|
451
452
|
const writes = [
|
|
@@ -816,7 +817,8 @@ export class $class extends $folder {
|
|
|
816
817
|
|
|
817
818
|
let post = p.post;
|
|
818
819
|
const explicitIcon = typeof p.icon === 'string' ? p.icon.trim() : '';
|
|
819
|
-
const
|
|
820
|
+
const deptType = departmentMetaNameSync(globalThis.WORK?.real_dir || process.cwd());
|
|
821
|
+
const defaultIcon = explicitIcon || ((type === '$structure' || (deptType && type === deptType)) ? inferStructureIcon(p.label, id) : '');
|
|
820
822
|
if (post == null) {
|
|
821
823
|
if (srcModClassFile && fs.existsSync(srcModClassFile)) {
|
|
822
824
|
const customLabel = (p.label && p.label !== id && p.label !== rawId) ? p.label : '';
|
package/sources/server/folder.js
CHANGED
|
@@ -12,6 +12,7 @@ import { DEV_MODE } from '../host/config.js';
|
|
|
12
12
|
import { assertNotMemory } from './memory-mark.js';
|
|
13
13
|
import { markClassesDirty, classObjectCount } from '../data/api.js';
|
|
14
14
|
import { isModuleType } from './class/module-status.js';
|
|
15
|
+
import { departmentMetaNameSync } from './class/scaffold.js';
|
|
15
16
|
|
|
16
17
|
function readOwnAncestorSync(metaRealDir) {
|
|
17
18
|
if (!metaRealDir)
|
|
@@ -1329,11 +1330,12 @@ export class $folder extends $item{
|
|
|
1329
1330
|
* Возвращает null, если ограничений по типам нет (кроме отсечения не-средовых узлов).
|
|
1330
1331
|
*/
|
|
1331
1332
|
_mainTreeAllowedTypes() {
|
|
1332
|
-
const ENV_TYPES = new Set(['$domain', '$structure', '$project', '$module', '$provider', '$mcp', '$users', '$user', '$node', '$ai']);
|
|
1333
1333
|
if (this.type === '$server')
|
|
1334
1334
|
return null;
|
|
1335
1335
|
if (Array.isArray(this.DATA?.mainTreeChildren))
|
|
1336
1336
|
return new Set(this.DATA.mainTreeChildren);
|
|
1337
|
+
if (typeof this.DATA?.mainTreeChildren === 'string')
|
|
1338
|
+
return new Set(this.DATA.mainTreeChildren.trim().split(/\s+/).filter(Boolean));
|
|
1337
1339
|
const p = String(this.path || '');
|
|
1338
1340
|
if ((this.type === '$domain' && (this.id === 'MODULES' || /\/MODULES$/.test(p)))
|
|
1339
1341
|
|| (this.type === '$folder' && /(?:^|\/)MODULES(?:\/|$)/.test(p)))
|
|
@@ -1341,16 +1343,14 @@ export class $folder extends $item{
|
|
|
1341
1343
|
if (this.type === '$folder')
|
|
1342
1344
|
return null;
|
|
1343
1345
|
if (this.parent?.type === '$server')
|
|
1344
|
-
return
|
|
1345
|
-
if (this.type === '$project' || this.type === '$structure')
|
|
1346
|
-
return new Set(['$structure', '$project']);
|
|
1346
|
+
return null;
|
|
1347
|
+
if (this.type === '$project' || this.type === '$structure' || this.DATA?.isDepartment)
|
|
1348
|
+
return new Set([this.type, '$structure', '$project', departmentMetaNameSync()].filter(Boolean));
|
|
1347
1349
|
if (this.type === '$module' || this.type === '$mcp' || this.type === '$user' || this.type === '$node' || this.type === '$ai')
|
|
1348
1350
|
return new Set();
|
|
1349
1351
|
if (this.type === '$provider')
|
|
1350
1352
|
return new Set(['$ai']);
|
|
1351
|
-
|
|
1352
|
-
return ENV_TYPES;
|
|
1353
|
-
return ENV_TYPES;
|
|
1353
|
+
return null;
|
|
1354
1354
|
}
|
|
1355
1355
|
|
|
1356
1356
|
_isMainTreeLeaf() {
|
|
@@ -1362,8 +1362,11 @@ export class $folder extends $item{
|
|
|
1362
1362
|
if (!Array.isArray(items) || !items.length)
|
|
1363
1363
|
return items || [];
|
|
1364
1364
|
const allowed = this._mainTreeAllowedTypes();
|
|
1365
|
-
if (!allowed)
|
|
1366
|
-
|
|
1365
|
+
if (!allowed) {
|
|
1366
|
+
if (!this.parent || this.type === '$folder')
|
|
1367
|
+
return items;
|
|
1368
|
+
return items.filter(it => it && it.id?.[0] !== '$' && !it.DATA?.objects);
|
|
1369
|
+
}
|
|
1367
1370
|
if (allowed.size === 0)
|
|
1368
1371
|
return [];
|
|
1369
1372
|
return items.filter(it => {
|
|
@@ -2443,10 +2446,11 @@ export class $folder extends $item{
|
|
|
2443
2446
|
|
|
2444
2447
|
sortItems(files, reverse = false, isType = this.isType) {
|
|
2445
2448
|
const rootOrder = { PROJECTS: 0, USERS: 1, NODES: 2, nodes: 2, MODULES: 3 };
|
|
2446
|
-
const typeGroup = (
|
|
2449
|
+
const typeGroup = (item) => {
|
|
2450
|
+
const t = item?.type;
|
|
2447
2451
|
if (t === '$catalog' || t === '$virtual' || t === '$struct' || t === '$operation' || t === '$register' || t === '$account')
|
|
2448
2452
|
return 0;
|
|
2449
|
-
if (t === '$structure' || t === '$project')
|
|
2453
|
+
if (t === '$structure' || t === '$project' || item?.DATA?.isDepartment)
|
|
2450
2454
|
return 1;
|
|
2451
2455
|
if (t === '$module' || t === '$provider' || t === '$mcp' || t === '$domain')
|
|
2452
2456
|
return 3;
|
|
@@ -2477,8 +2481,8 @@ export class $folder extends $item{
|
|
|
2477
2481
|
return ra - rb;
|
|
2478
2482
|
}
|
|
2479
2483
|
if (aCls && bCls && a.type !== b.type) {
|
|
2480
|
-
const ga = typeGroup(a
|
|
2481
|
-
const gb = typeGroup(b
|
|
2484
|
+
const ga = typeGroup(a);
|
|
2485
|
+
const gb = typeGroup(b);
|
|
2482
2486
|
if (ga !== gb)
|
|
2483
2487
|
return ga - gb;
|
|
2484
2488
|
}
|
package/sources/server/logs.js
CHANGED
|
@@ -125,7 +125,21 @@ export function logExt(row) {
|
|
|
125
125
|
return dot > 0 ? id.slice(dot + 1).toLowerCase() : '';
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
export function isSystemMetaLogRow(row) {
|
|
129
|
+
const p = String(row?.path || '').trim().replace(/\\/g, '/');
|
|
130
|
+
if (!p)
|
|
131
|
+
return false;
|
|
132
|
+
if (/(?:^|\/)class\.js$/i.test(p))
|
|
133
|
+
return true;
|
|
134
|
+
// Снимки метафайлов внутри $.../#... (кроме пользовательских документов и задач .task)
|
|
135
|
+
if (/\/#(?:secret|system)\//i.test(p) && !/\.task$/i.test(p))
|
|
136
|
+
return true;
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
|
|
128
140
|
export function matchesFilter(row, params) {
|
|
141
|
+
if (params.feedMode === 'dialog' && isSystemMetaLogRow(row))
|
|
142
|
+
return false;
|
|
129
143
|
if (!params.exts?.length)
|
|
130
144
|
return true;
|
|
131
145
|
return params.exts.includes(logExt(row));
|
package/sources/server/node.js
CHANGED
|
@@ -107,7 +107,7 @@ export class $node extends $class {
|
|
|
107
107
|
if (t === '$virtual') return 'virtual';
|
|
108
108
|
if (t === '$register') return 'sheet';
|
|
109
109
|
if (t === '$account') return 'postings';
|
|
110
|
-
if (t === '$project' || t === '$structure') return 'chat';
|
|
110
|
+
if (t === '$project' || t === '$structure' || this.DATA?.isDepartment) return 'chat';
|
|
111
111
|
if (t === '$file') return 'file';
|
|
112
112
|
}
|
|
113
113
|
return undefined;
|
package/sources/server/user.js
CHANGED
|
@@ -99,6 +99,9 @@ export class $user extends $class {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
async allowAccess(params) {
|
|
102
|
+
await this.init;
|
|
103
|
+
if (this.DATA?.usersContainer === true)
|
|
104
|
+
return super.allowAccess(params);
|
|
102
105
|
// WORK_DEV снимает все проверки видимости — и доступ к кабинету тоже (как canSee/canWrite)
|
|
103
106
|
if (DEV_MODE)
|
|
104
107
|
return true;
|
package/sources/work.js
CHANGED
|
@@ -13,6 +13,7 @@ import './server/server.js';
|
|
|
13
13
|
import { $server } from './server/server.js';
|
|
14
14
|
import { createRequestHandler, startServers } from './host/http-server.js';
|
|
15
15
|
import { attachWebSocket } from './host/websocket.js';
|
|
16
|
+
import { migrateDepartmentMetasSync } from './server/class/scaffold.js';
|
|
16
17
|
|
|
17
18
|
webPush.setVapidDetails(
|
|
18
19
|
'https://odant.org',
|
|
@@ -20,6 +21,12 @@ webPush.setVapidDetails(
|
|
|
20
21
|
vapidKeys.privateKey
|
|
21
22
|
);
|
|
22
23
|
|
|
24
|
+
if (process.env.WORK_MIGRATE_DEPT !== '0') {
|
|
25
|
+
const moved = migrateDepartmentMetasSync(process.cwd());
|
|
26
|
+
if (moved.length)
|
|
27
|
+
console.log('[WORK] мигрированы подразделения:', moved.length);
|
|
28
|
+
}
|
|
29
|
+
|
|
23
30
|
globalThis.WORK = new $server();
|
|
24
31
|
globalThis.ssid = $server.genGUID();
|
|
25
32
|
|
package/USERS/$users/class.js
DELETED