odant-work 1.0.105 → 1.0.106
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/$user/handlers/pages/form/calendar/$handler/class.js +12 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/email/$handler/class.js +12 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/folder/$handler/class.js +12 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/profile/$handler/class.js +30 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/search/$handler/class.js +12 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/$handler/class.js +14 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/agent/$handler/class.js +5 -4
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/skills/$handler/class.js +5 -4
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/tokens/$handler/class.js +8 -2
- package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +65 -19
- package/$server/$folder/handlers/pages/form/$handler/class.js +17 -1
- package/$server/$folder/lib/consultant/consultant.js +123 -66
- package/$server/$folder/lib/explorer/explorer.js +9 -21
- package/$server/$folder/lib/prompt-bar/prompt-bar.js +24 -1
- package/MODULES/$domain/class.js +1 -0
- package/package.json +1 -1
- package/sources/client.js +1 -1
- package/sources/server/access/gateway.js +1 -1
- package/sources/server/chat-threads.js +32 -3
- package/sources/server/class/feed.js +24 -12
- package/sources/server/class/security.js +97 -31
- package/sources/server/user.js +12 -4
package/$server/$folder/$class/$structure/$user/handlers/pages/form/calendar/$handler/class.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
async allowUse($context, params) {
|
|
3
|
+
if (!$context?.id || $context?.DATA?.usersContainer)
|
|
4
|
+
return false;
|
|
5
|
+
const uid = $context?.constructor?.resolveUid?.(params) || params?.session?.uid || '';
|
|
6
|
+
if (uid && $context.id === uid)
|
|
7
|
+
return true;
|
|
8
|
+
if (globalThis.WORK?.DEV_MODE)
|
|
9
|
+
return true;
|
|
10
|
+
return Boolean(await globalThis.WORK?._isWorkBoss?.(params).catch(() => false));
|
|
11
|
+
},
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
async allowUse($context, params) {
|
|
3
|
+
if (!$context?.id || $context?.DATA?.usersContainer)
|
|
4
|
+
return false;
|
|
5
|
+
const uid = $context?.constructor?.resolveUid?.(params) || params?.session?.uid || '';
|
|
6
|
+
if (uid && $context.id === uid)
|
|
7
|
+
return true;
|
|
8
|
+
if (globalThis.WORK?.DEV_MODE)
|
|
9
|
+
return true;
|
|
10
|
+
return Boolean(await globalThis.WORK?._isWorkBoss?.(params).catch(() => false));
|
|
11
|
+
},
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
async allowUse($context, params) {
|
|
3
|
+
if (!$context?.id || $context?.DATA?.usersContainer)
|
|
4
|
+
return false;
|
|
5
|
+
const uid = $context?.constructor?.resolveUid?.(params) || params?.session?.uid || '';
|
|
6
|
+
if (uid && $context.id === uid)
|
|
7
|
+
return true;
|
|
8
|
+
if (globalThis.WORK?.DEV_MODE)
|
|
9
|
+
return true;
|
|
10
|
+
return Boolean(await globalThis.WORK?._isWorkBoss?.(params).catch(() => false));
|
|
11
|
+
},
|
|
12
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import '/sources/modules/user-profile/user-profile.js';
|
|
2
|
+
export default {
|
|
3
|
+
label: 'Профиль',
|
|
4
|
+
description: 'Личные данные и контактная информация пользователя',
|
|
5
|
+
icon: 'icons:account-circle',
|
|
6
|
+
order: 15,
|
|
7
|
+
async allowUse($context, params) {
|
|
8
|
+
if (!$context?.id || $context?.DATA?.usersContainer)
|
|
9
|
+
return false;
|
|
10
|
+
const uid = $context?.constructor?.resolveUid?.(params) || params?.session?.uid || '';
|
|
11
|
+
if (!uid || $context.id === uid)
|
|
12
|
+
return false;
|
|
13
|
+
if (globalThis.WORK?.DEV_MODE)
|
|
14
|
+
return false;
|
|
15
|
+
const isBoss = await globalThis.WORK?._isWorkBoss?.(params).catch(() => false);
|
|
16
|
+
return !isBoss;
|
|
17
|
+
},
|
|
18
|
+
component: {
|
|
19
|
+
template: /* html */`
|
|
20
|
+
<style>
|
|
21
|
+
:host {
|
|
22
|
+
@apply --vertical;
|
|
23
|
+
@apply --flex;
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
}
|
|
26
|
+
</style>
|
|
27
|
+
<user-profile :$item flex></user-profile>
|
|
28
|
+
`
|
|
29
|
+
}
|
|
30
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
async allowUse($context, params) {
|
|
3
|
+
if (!$context?.id || $context?.DATA?.usersContainer)
|
|
4
|
+
return false;
|
|
5
|
+
const uid = $context?.constructor?.resolveUid?.(params) || params?.session?.uid || '';
|
|
6
|
+
if (uid && $context.id === uid)
|
|
7
|
+
return true;
|
|
8
|
+
if (globalThis.WORK?.DEV_MODE)
|
|
9
|
+
return true;
|
|
10
|
+
return Boolean(await globalThis.WORK?._isWorkBoss?.(params).catch(() => false));
|
|
11
|
+
},
|
|
12
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
async allowUse($context, params) {
|
|
3
|
+
if (!$context?.id)
|
|
4
|
+
return false;
|
|
5
|
+
if ($context?.DATA?.usersContainer)
|
|
6
|
+
return true;
|
|
7
|
+
const uid = $context?.constructor?.resolveUid?.(params) || params?.session?.uid || '';
|
|
8
|
+
if (uid && $context.id === uid)
|
|
9
|
+
return true;
|
|
10
|
+
if (globalThis.WORK?.DEV_MODE)
|
|
11
|
+
return true;
|
|
12
|
+
return Boolean(await globalThis.WORK?._isWorkBoss?.(params).catch(() => false));
|
|
13
|
+
},
|
|
14
|
+
};
|
package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/agent/$handler/class.js
CHANGED
|
@@ -3,11 +3,12 @@ export default {
|
|
|
3
3
|
if (!$context?.id || $context?.DATA?.usersContainer)
|
|
4
4
|
return false;
|
|
5
5
|
const uid = $context?.constructor?.resolveUid?.(params) || params?.session?.uid || '';
|
|
6
|
-
if (uid && $context.id === uid)
|
|
7
|
-
return true;
|
|
8
6
|
if (globalThis.WORK?.DEV_MODE)
|
|
9
7
|
return true;
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
if (uid && $context.id === uid) {
|
|
9
|
+
const scope = await globalThis.WORK?.my_scope?.(params).catch(() => null);
|
|
10
|
+
return Boolean(scope?.hasAnyRole || scope?.isWorkBoss);
|
|
11
|
+
}
|
|
12
|
+
return Boolean(await globalThis.WORK?._isWorkBoss?.(params).catch(() => false));
|
|
12
13
|
},
|
|
13
14
|
};
|
package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/skills/$handler/class.js
CHANGED
|
@@ -3,11 +3,12 @@ export default {
|
|
|
3
3
|
if (!$context?.id || $context?.DATA?.usersContainer)
|
|
4
4
|
return false;
|
|
5
5
|
const uid = $context?.constructor?.resolveUid?.(params) || params?.session?.uid || '';
|
|
6
|
-
if (uid && $context.id === uid)
|
|
7
|
-
return true;
|
|
8
6
|
if (globalThis.WORK?.DEV_MODE)
|
|
9
7
|
return true;
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
if (uid && $context.id === uid) {
|
|
9
|
+
const scope = await globalThis.WORK?.my_scope?.(params).catch(() => null);
|
|
10
|
+
return Boolean(scope?.hasAnyRole || scope?.isWorkBoss);
|
|
11
|
+
}
|
|
12
|
+
return Boolean(await globalThis.WORK?._isWorkBoss?.(params).catch(() => false));
|
|
12
13
|
},
|
|
13
14
|
};
|
package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/tokens/$handler/class.js
CHANGED
|
@@ -5,11 +5,17 @@ export default {
|
|
|
5
5
|
description: 'Персональные токены для расширения WORK Chrome Bridge и внешних ИИ-клиентов (MCP: OpenCode, Claude Code, Cursor).',
|
|
6
6
|
icon: 'communication:vpn-key',
|
|
7
7
|
order: 18,
|
|
8
|
-
allowUse($context, params) {
|
|
8
|
+
async allowUse($context, params) {
|
|
9
9
|
if (!$context?.id || $context?.DATA?.usersContainer)
|
|
10
10
|
return false;
|
|
11
11
|
const uid = $context?.constructor?.resolveUid?.(params) || params?.session?.uid || '';
|
|
12
|
-
|
|
12
|
+
if (globalThis.WORK?.DEV_MODE)
|
|
13
|
+
return true;
|
|
14
|
+
if (uid && $context.id === uid) {
|
|
15
|
+
const scope = await globalThis.WORK?.my_scope?.(params).catch(() => null);
|
|
16
|
+
return Boolean(scope?.hasAnyRole || scope?.isWorkBoss);
|
|
17
|
+
}
|
|
18
|
+
return Boolean(await globalThis.WORK?._isWorkBoss?.(params).catch(() => false));
|
|
13
19
|
},
|
|
14
20
|
component: {
|
|
15
21
|
template: /* html */`
|
|
@@ -515,7 +515,7 @@ ODA({
|
|
|
515
515
|
<microchat-voice ~if="voiceOn"></microchat-voice>
|
|
516
516
|
<work-prompt-bar style="margin: 8px;" @tap="focusedItem = null"
|
|
517
517
|
::value ::files :ai="isAIMode" :placeholder :pending="awaitTask"
|
|
518
|
-
::model ::tts-mode ::receivers :dept-users="deptUsers" :operation-classes="operationClasses" :show-tts="
|
|
518
|
+
::model ::tts-mode ::receivers :dept-users="isForeignPrivate ? [] : deptUsers" :operation-classes="isForeignPrivate ? [] : operationClasses" :show-tts="!isForeignPrivate"
|
|
519
519
|
@receivers-changed="onReceiversChanged($event)" @create-operation="onCreateOperation($event)"
|
|
520
520
|
@send="onBarSend" @stop="onBarStop" @clear="clear" @prompt-key="_onPromptKey"></work-prompt-bar>
|
|
521
521
|
</div>
|
|
@@ -541,12 +541,19 @@ ODA({
|
|
|
541
541
|
this.hasExpandedCard = Boolean(detail.expanded);
|
|
542
542
|
}
|
|
543
543
|
},
|
|
544
|
+
get isForeignPrivate() {
|
|
545
|
+
return Boolean(this.$pdp?.isPrivate && this.$pdp?.$item?.id && WORK?.uid && this.$pdp.$item.id !== WORK.uid);
|
|
546
|
+
},
|
|
544
547
|
get placeholder() {
|
|
548
|
+
if (this.isForeignPrivate) {
|
|
549
|
+
const lbl = this.$pdp.$item?.DATA?.label || this.$pdp.$item?.label || 'пользователя';
|
|
550
|
+
return 'Сообщение для ' + lbl + ' ...';
|
|
551
|
+
}
|
|
545
552
|
if (this.$pdp.receivers.length) return 'Сообщение для ' + this.$pdp.receivers.map(user => user.label).join(', ') + ' ...';
|
|
546
553
|
return 'Новая задача для ИИ ...';
|
|
547
554
|
},
|
|
548
555
|
get isAIMode() {
|
|
549
|
-
const isForeign = this
|
|
556
|
+
const isForeign = this.isForeignPrivate;
|
|
550
557
|
const hasReceivers = !!this.$pdp?.receivers?.length;
|
|
551
558
|
return !isForeign && !hasReceivers;
|
|
552
559
|
},
|
|
@@ -1061,6 +1068,39 @@ ODA({
|
|
|
1061
1068
|
files: list,
|
|
1062
1069
|
draft
|
|
1063
1070
|
});
|
|
1071
|
+
} else if (this.isForeignPrivate) {
|
|
1072
|
+
const uploadedPaths = [];
|
|
1073
|
+
if (list.length) {
|
|
1074
|
+
const uploadTarget = (await this._ownCabinet()) || this.$pdp.$item;
|
|
1075
|
+
const formData = new FormData();
|
|
1076
|
+
for (const file of list) formData.append('file', file, file.name);
|
|
1077
|
+
const fileParams = {
|
|
1078
|
+
encoding: 'utf-8',
|
|
1079
|
+
...(WORK.uid ? { sender: WORK.uid } : {}),
|
|
1080
|
+
ignore_save_logs: true
|
|
1081
|
+
};
|
|
1082
|
+
const savedLogs = await uploadTarget.save_files(formData, fileParams);
|
|
1083
|
+
const arr = Array.isArray(savedLogs) ? savedLogs : savedLogs ? [savedLogs] : [];
|
|
1084
|
+
for (const l of arr) {
|
|
1085
|
+
const p = await pathOfLog(l);
|
|
1086
|
+
if (p) uploadedPaths.push(p.startsWith('/') ? p : '/' + p);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
const chatTarget = this.$pdp.$item;
|
|
1090
|
+
if (chatTarget?.fetch && (text || uploadedPaths.length)) {
|
|
1091
|
+
const chatPayload = {
|
|
1092
|
+
kind: 'dm',
|
|
1093
|
+
peerId: chatTarget.id,
|
|
1094
|
+
message: text,
|
|
1095
|
+
attachments: uploadedPaths.map(p => ({
|
|
1096
|
+
path: p,
|
|
1097
|
+
name: p.split('/').pop() || 'file'
|
|
1098
|
+
}))
|
|
1099
|
+
};
|
|
1100
|
+
await chatTarget.fetch('chat_send', {}, JSON.stringify(chatPayload));
|
|
1101
|
+
}
|
|
1102
|
+
this.clear();
|
|
1103
|
+
this.$('#ribbon')?.refreshFeed?.();
|
|
1064
1104
|
} else {
|
|
1065
1105
|
const params = {
|
|
1066
1106
|
encoding: 'utf-8'
|
|
@@ -1536,6 +1576,7 @@ ODA({
|
|
|
1536
1576
|
return history[idx];
|
|
1537
1577
|
},
|
|
1538
1578
|
get history() {
|
|
1579
|
+
if (this.isForeignUser) return Promise.resolve([]);
|
|
1539
1580
|
return Promise.resolve(this.lastDay?.logs).then(async items => {
|
|
1540
1581
|
if (!Array.isArray(items)) return [];
|
|
1541
1582
|
const result = [];
|
|
@@ -1612,6 +1653,9 @@ ODA({
|
|
|
1612
1653
|
get isLocalFeed() {
|
|
1613
1654
|
return this.$pdp?.feedMode === 'local';
|
|
1614
1655
|
},
|
|
1656
|
+
get isForeignUser() {
|
|
1657
|
+
return Boolean(this.$pdp?.isPrivate && this.$item?.id && WORK?.uid && this.$item.id !== WORK.uid);
|
|
1658
|
+
},
|
|
1615
1659
|
get isDialogFeed() {
|
|
1616
1660
|
return !this.isLocalFeed && this.$pdp?.feedMode !== 'audit';
|
|
1617
1661
|
},
|
|
@@ -1657,7 +1701,7 @@ ODA({
|
|
|
1657
1701
|
const source = (await this._resolveLogsSource()) || this.$item;
|
|
1658
1702
|
this._syncSourceListeners(source);
|
|
1659
1703
|
source.invalidate?.('logs_dates');
|
|
1660
|
-
const logsPromise = source.fetch('logs', {
|
|
1704
|
+
const logsPromise = this.isForeignUser ? Promise.resolve([]) : source.fetch('logs', {
|
|
1661
1705
|
mode: 'dates',
|
|
1662
1706
|
nonEmpty: 1,
|
|
1663
1707
|
...(this.isLocalFeed ? {
|
|
@@ -2016,22 +2060,24 @@ ODA({
|
|
|
2016
2060
|
feedMode: 'dialog'
|
|
2017
2061
|
};
|
|
2018
2062
|
let rows = [];
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2063
|
+
if (!this.$pdp?.isForeignUser) {
|
|
2064
|
+
try {
|
|
2065
|
+
if (typeof source.fetch === 'function') rows = await source.fetch('logs', {
|
|
2066
|
+
mode: 'bodies',
|
|
2067
|
+
day: this.day,
|
|
2068
|
+
role,
|
|
2069
|
+
uid,
|
|
2070
|
+
...local
|
|
2071
|
+
});else if (typeof source.logs === 'function') rows = await source.logs({
|
|
2072
|
+
mode: 'bodies',
|
|
2073
|
+
day: this.day,
|
|
2074
|
+
role,
|
|
2075
|
+
uid,
|
|
2076
|
+
...local
|
|
2077
|
+
});
|
|
2078
|
+
} catch {
|
|
2079
|
+
rows = [];
|
|
2080
|
+
}
|
|
2035
2081
|
}
|
|
2036
2082
|
if (!Array.isArray(rows)) rows = [];
|
|
2037
2083
|
const isDialogMetaRow = r => {
|
|
@@ -1571,11 +1571,21 @@ ODA({is: 'work-form',
|
|
|
1571
1571
|
return [];
|
|
1572
1572
|
return this.loadFormViews($item, role);
|
|
1573
1573
|
},
|
|
1574
|
+
_myScope: null,
|
|
1574
1575
|
get visibleFormViews() {
|
|
1575
1576
|
const views = this.formViews;
|
|
1576
1577
|
if (!Array.isArray(views))
|
|
1577
1578
|
return [];
|
|
1578
|
-
|
|
1579
|
+
const hideSystemForUnassigned = Boolean(
|
|
1580
|
+
this._myScope?.isUnassigned
|
|
1581
|
+
&& this.currentItem?.DATA?.isUser
|
|
1582
|
+
&& !this.currentItem?.DATA?.usersContainer
|
|
1583
|
+
);
|
|
1584
|
+
return views.filter(v => {
|
|
1585
|
+
if (hideSystemForUnassigned && v?.id === 'system')
|
|
1586
|
+
return false;
|
|
1587
|
+
return !(v?.DATA?.hidden || v?.hidden) || v?.id === this.view?.id;
|
|
1588
|
+
});
|
|
1579
1589
|
},
|
|
1580
1590
|
async loadFormViews($item, role) {
|
|
1581
1591
|
try {
|
|
@@ -1694,6 +1704,12 @@ ODA({is: 'work-form',
|
|
|
1694
1704
|
this._appliedRoleItem = n;
|
|
1695
1705
|
this._appliedRole = n.role || '';
|
|
1696
1706
|
this._rootHasChildClasses = await this._detectHasChildClasses(n);
|
|
1707
|
+
if (globalThis.WORK?.uid && !globalThis.WORK?.DEV_MODE && n?.DATA?.isUser && !n?.DATA?.usersContainer) {
|
|
1708
|
+
this._myScope = await globalThis.WORK.fetch('/', 'my_scope').catch(() => null);
|
|
1709
|
+
}
|
|
1710
|
+
else {
|
|
1711
|
+
this._myScope = null;
|
|
1712
|
+
}
|
|
1697
1713
|
}
|
|
1698
1714
|
finally {
|
|
1699
1715
|
this._initializingItem = false;
|
|
@@ -38,34 +38,6 @@ function ensureConsultantUI() {
|
|
|
38
38
|
]).catch(e => console.warn('[consultant] load UI:', e));
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
/** Первый лист $ai с поддержкой chat (приоритет провайдеру odant). */
|
|
42
|
-
function firstChatLeaf(node) {
|
|
43
|
-
if (!node)
|
|
44
|
-
return null;
|
|
45
|
-
if (!node.items?.length) {
|
|
46
|
-
if (node.type && node.type !== '$ai')
|
|
47
|
-
return null;
|
|
48
|
-
const mod = String(node.modality || node.DATA?.modality || '').toLowerCase();
|
|
49
|
-
if (['image', 'audio', 'embedding', 'video', 'voice', 'asr', 'tts', 'stt'].includes(mod))
|
|
50
|
-
return null;
|
|
51
|
-
const name = String(node.id || node.label || node.DATA?.label || node.path || '').toLowerCase();
|
|
52
|
-
if (/(flux|sdxl|stable-?diffusion|z-image|embedding|bge-|rerank|whisper|\basr\b|\btts\b|\bstt\b|voice|kokoro|musicgen|wan2|ltx-video)/i.test(name))
|
|
53
|
-
return null;
|
|
54
|
-
const c = node.capabilities || node.DATA?.capabilities;
|
|
55
|
-
const list = Array.isArray(c) ? c.map(String) : String(c || '').split(/[\s,]+/).filter(Boolean);
|
|
56
|
-
if (list.length && !list.includes('chat'))
|
|
57
|
-
return null;
|
|
58
|
-
return node;
|
|
59
|
-
}
|
|
60
|
-
const sorted = [...node.items].sort((a, b) => (a.id === 'odant' ? -1 : b.id === 'odant' ? 1 : 0));
|
|
61
|
-
for (const child of sorted) {
|
|
62
|
-
const found = firstChatLeaf(child);
|
|
63
|
-
if (found)
|
|
64
|
-
return found;
|
|
65
|
-
}
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
41
|
const STATUS_LABELS = {
|
|
70
42
|
idle: { label: 'Готов', icon: 'carbon:checkmark' },
|
|
71
43
|
running: { label: 'Думает…', icon: 'spinners:3-dots-scale' },
|
|
@@ -76,35 +48,76 @@ const STATUS_LABELS = {
|
|
|
76
48
|
limit: { label: 'Лимит шагов', icon: 'carbon:warning' },
|
|
77
49
|
};
|
|
78
50
|
|
|
51
|
+
const TIER_RANK = Object.freeze({
|
|
52
|
+
onboarding: 0,
|
|
53
|
+
member: 1,
|
|
54
|
+
unitBoss: 2,
|
|
55
|
+
workBoss: 3,
|
|
56
|
+
});
|
|
57
|
+
|
|
79
58
|
export const CONSULTANT_PROMPT_CATEGORIES = Object.freeze([
|
|
80
|
-
{ id: 'all', label: 'Все', icon: 'carbon:apps' },
|
|
81
|
-
{ id: 'accounting', label: 'Учёт и отчёты', icon: 'carbon:data-table' },
|
|
82
|
-
{ id: 'org', label: 'Оргструктура и права', icon: 'odant:structure' },
|
|
83
|
-
{ id: 'docs', label: 'Документы и задачи', icon: 'enterprise:calendar' },
|
|
84
|
-
{ id: 'system', label: 'Конструктор и ИИ', icon: 'carbon:tools' },
|
|
59
|
+
{ id: 'all', label: 'Все', icon: 'carbon:apps', minTier: 'member' },
|
|
60
|
+
{ id: 'accounting', label: 'Учёт и отчёты', icon: 'carbon:data-table', minTier: 'member' },
|
|
61
|
+
{ id: 'org', label: 'Оргструктура и права', icon: 'odant:structure', minTier: 'unitBoss' },
|
|
62
|
+
{ id: 'docs', label: 'Документы и задачи', icon: 'enterprise:calendar', minTier: 'member' },
|
|
63
|
+
{ id: 'system', label: 'Конструктор и ИИ', icon: 'carbon:tools', minTier: 'unitBoss' },
|
|
85
64
|
]);
|
|
86
65
|
|
|
87
66
|
export const CONSULTANT_PROMPTS = Object.freeze([
|
|
67
|
+
// Стартовый онбординг для нового неназначенного пользователя
|
|
68
|
+
{
|
|
69
|
+
id: 'onb-what-is-work',
|
|
70
|
+
category: 'docs',
|
|
71
|
+
minTier: 'onboarding',
|
|
72
|
+
maxTier: 'onboarding',
|
|
73
|
+
scenario: 0,
|
|
74
|
+
icon: 'icons:help-outline',
|
|
75
|
+
label: 'Как устроена система WORK и с чего начать?',
|
|
76
|
+
prompt: 'Объясни простыми словами, как устроена система WORK (проекты, подразделения, роли и личный кабинет) и с чего начать новому пользователю.',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: 'onb-my-access',
|
|
80
|
+
category: 'docs',
|
|
81
|
+
minTier: 'onboarding',
|
|
82
|
+
maxTier: 'onboarding',
|
|
83
|
+
scenario: 0,
|
|
84
|
+
icon: 'icons:supervisor-account',
|
|
85
|
+
label: 'Какие у меня сейчас права и почему нет проектов?',
|
|
86
|
+
prompt: 'Объясни, почему у меня пока не видны проекты и отделы, и как руководитель назначает сотрудника в подразделение.',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: 'onb-profile',
|
|
90
|
+
category: 'docs',
|
|
91
|
+
minTier: 'onboarding',
|
|
92
|
+
maxTier: 'onboarding',
|
|
93
|
+
scenario: 0,
|
|
94
|
+
icon: 'icons:account-circle',
|
|
95
|
+
label: 'Как заполнить профиль и настроить уведомления?',
|
|
96
|
+
prompt: 'Подскажи, как заполнить личный профиль, аватар, часовой пояс и настроить уведомления в моей учётной записи.',
|
|
97
|
+
},
|
|
88
98
|
// Сценарий 1: Оргструктура и рабочие места (BOSS, ROLES, USERS, GUESTS)
|
|
89
99
|
{
|
|
90
100
|
id: 'org-overview',
|
|
91
101
|
category: 'org',
|
|
102
|
+
minTier: 'unitBoss',
|
|
92
103
|
scenario: 1,
|
|
93
104
|
icon: 'odant:structure',
|
|
94
105
|
label: 'Какие организации, подразделения и модули доступны в системе?',
|
|
95
|
-
prompt: 'Покажи структуру организаций (/PROJECTS)
|
|
106
|
+
prompt: 'Покажи доступную структуру организаций (/PROJECTS) и их подразделений в системе.',
|
|
96
107
|
},
|
|
97
108
|
{
|
|
98
109
|
id: 'org-audit-access',
|
|
99
110
|
category: 'org',
|
|
111
|
+
minTier: 'unitBoss',
|
|
100
112
|
scenario: 1,
|
|
101
113
|
icon: 'icons:supervisor-account',
|
|
102
114
|
label: 'Аудит ролей BOSS и рабочих мест (ROLES / USERS / GUESTS)',
|
|
103
|
-
prompt: 'Проведи аудит настроек безопасности по организациям и подразделениям: кто назначен руководителем (BOSS), какие рабочие места (ROLES) созданы, где назначены групповые субъекты USERS и GUESTS и какие ссылки LINKS им выданы.',
|
|
115
|
+
prompt: 'Проведи аудит настроек безопасности по доступным организациям и подразделениям: кто назначен руководителем (BOSS), какие рабочие места (ROLES) созданы, где назначены групповые субъекты USERS и GUESTS и какие ссылки LINKS им выданы.',
|
|
104
116
|
},
|
|
105
117
|
{
|
|
106
118
|
id: 'org-setup-unit',
|
|
107
119
|
category: 'org',
|
|
120
|
+
minTier: 'unitBoss',
|
|
108
121
|
scenario: 1,
|
|
109
122
|
icon: 'icons:add',
|
|
110
123
|
label: 'Развернуть подразделение и настроить рабочие места',
|
|
@@ -114,6 +127,7 @@ export const CONSULTANT_PROMPTS = Object.freeze([
|
|
|
114
127
|
{
|
|
115
128
|
id: 'cat-summary',
|
|
116
129
|
category: 'accounting',
|
|
130
|
+
minTier: 'member',
|
|
117
131
|
scenario: 2,
|
|
118
132
|
icon: 'carbon:data-table',
|
|
119
133
|
label: 'Сводка по справочникам и операциям учёта',
|
|
@@ -122,6 +136,7 @@ export const CONSULTANT_PROMPTS = Object.freeze([
|
|
|
122
136
|
{
|
|
123
137
|
id: 'cat-quality',
|
|
124
138
|
category: 'accounting',
|
|
139
|
+
minTier: 'member',
|
|
125
140
|
scenario: 2,
|
|
126
141
|
icon: 'carbon:checkmark-outline',
|
|
127
142
|
label: 'Проверить справочники на дубликаты и пустые реквизиты',
|
|
@@ -131,6 +146,7 @@ export const CONSULTANT_PROMPTS = Object.freeze([
|
|
|
131
146
|
{
|
|
132
147
|
id: 'op-register',
|
|
133
148
|
category: 'accounting',
|
|
149
|
+
minTier: 'member',
|
|
134
150
|
scenario: 3,
|
|
135
151
|
icon: 'carbon:task-complete',
|
|
136
152
|
label: 'Зарегистрировать и провести хозяйственную операцию',
|
|
@@ -140,6 +156,7 @@ export const CONSULTANT_PROMPTS = Object.freeze([
|
|
|
140
156
|
{
|
|
141
157
|
id: 'acc-sheet-balance',
|
|
142
158
|
category: 'accounting',
|
|
159
|
+
minTier: 'member',
|
|
143
160
|
scenario: 4,
|
|
144
161
|
icon: 'carbon:report',
|
|
145
162
|
label: 'Оборотно-сальдовая ведомость и проверка баланса',
|
|
@@ -148,6 +165,7 @@ export const CONSULTANT_PROMPTS = Object.freeze([
|
|
|
148
165
|
{
|
|
149
166
|
id: 'acc-turnovers',
|
|
150
167
|
category: 'accounting',
|
|
168
|
+
minTier: 'member',
|
|
151
169
|
scenario: 4,
|
|
152
170
|
icon: 'carbon:analytics',
|
|
153
171
|
label: 'Анализ оборотов и задолженности по субконто (60, 62, 51, 41)',
|
|
@@ -157,6 +175,7 @@ export const CONSULTANT_PROMPTS = Object.freeze([
|
|
|
157
175
|
{
|
|
158
176
|
id: 'docs-feed-summary',
|
|
159
177
|
category: 'docs',
|
|
178
|
+
minTier: 'member',
|
|
160
179
|
scenario: 5,
|
|
161
180
|
icon: 'icons:question-answer',
|
|
162
181
|
label: 'Сводка событий, сообщений и задач в ленте',
|
|
@@ -165,6 +184,7 @@ export const CONSULTANT_PROMPTS = Object.freeze([
|
|
|
165
184
|
{
|
|
166
185
|
id: 'docs-office-export',
|
|
167
186
|
category: 'docs',
|
|
187
|
+
minTier: 'member',
|
|
168
188
|
scenario: 5,
|
|
169
189
|
icon: 'files-color:s-xlsx',
|
|
170
190
|
label: 'Сформировать отчёт в Excel (.xlsx) или Word (.docx)',
|
|
@@ -173,6 +193,7 @@ export const CONSULTANT_PROMPTS = Object.freeze([
|
|
|
173
193
|
{
|
|
174
194
|
id: 'docs-delegate-task',
|
|
175
195
|
category: 'docs',
|
|
196
|
+
minTier: 'member',
|
|
176
197
|
scenario: 5,
|
|
177
198
|
icon: 'carbon:send-alt',
|
|
178
199
|
label: 'Поставить поручение сотруднику со сроком исполнения',
|
|
@@ -182,6 +203,7 @@ export const CONSULTANT_PROMPTS = Object.freeze([
|
|
|
182
203
|
{
|
|
183
204
|
id: 'sys-builder-guide',
|
|
184
205
|
category: 'system',
|
|
206
|
+
minTier: 'unitBoss',
|
|
185
207
|
scenario: 6,
|
|
186
208
|
icon: 'carbon:tools',
|
|
187
209
|
label: 'Как добавить поле/аналитику в класс и настроить форму объекта?',
|
|
@@ -190,6 +212,7 @@ export const CONSULTANT_PROMPTS = Object.freeze([
|
|
|
190
212
|
{
|
|
191
213
|
id: 'sys-local-ai',
|
|
192
214
|
category: 'system',
|
|
215
|
+
minTier: 'workBoss',
|
|
193
216
|
scenario: 7,
|
|
194
217
|
icon: 'carbon:machine-learning-model',
|
|
195
218
|
label: 'Модели ИИ и дообучение на данных организации (/MODULES/Модели)',
|
|
@@ -198,6 +221,7 @@ export const CONSULTANT_PROMPTS = Object.freeze([
|
|
|
198
221
|
{
|
|
199
222
|
id: 'sys-mcp-skills',
|
|
200
223
|
category: 'system',
|
|
224
|
+
minTier: 'workBoss',
|
|
201
225
|
scenario: 7,
|
|
202
226
|
icon: 'carbon:plug',
|
|
203
227
|
label: 'Прожарка архитектуры (@grill-me), внешние навыки и MCP (/MODULES)',
|
|
@@ -513,7 +537,7 @@ ODA({
|
|
|
513
537
|
<button class="dialog-btn" no-flex ~if="uiReady && canVoice" :on="voiceOn" :title="voiceOn ? 'Выключить живой голосовой диалог' : 'Живой голосовой диалог (с взаимным перебиванием)'" :aria-pressed="voiceOn ? 'true' : 'false'" @tap="toggleVoice()">
|
|
514
538
|
<work-voice-bars :on="voiceOn"></work-voice-bars>
|
|
515
539
|
</button>
|
|
516
|
-
<oda-button no-flex icon="carbon:plug" :icon-size="16" title="Центр расширений ИИ: MCP-серверы (/MODULES) и Навыки (Skills)" @tap="openMcpAndSkills"></oda-button>
|
|
540
|
+
<oda-button no-flex ~if="isWorkBoss" icon="carbon:plug" :icon-size="16" title="Центр расширений ИИ: MCP-серверы (/MODULES) и Навыки (Skills)" @tap="openMcpAndSkills"></oda-button>
|
|
517
541
|
<oda-button no-flex icon="carbon:idea" :icon-size="16" title="Типовые сценарии и промпты" @tap="togglePrompts"></oda-button>
|
|
518
542
|
<oda-button no-flex icon="carbon:recently-viewed" :icon-size="16" title="Мои консультации (из личных логов)" @tap="toggleHistory"></oda-button>
|
|
519
543
|
<oda-button no-flex icon="carbon:chat" :icon-size="16" title="Открыть ленту пользователя" @tap="openUserFeed"></oda-button>
|
|
@@ -526,7 +550,7 @@ ODA({
|
|
|
526
550
|
<span>Типовые сценарии и промпты</span>
|
|
527
551
|
<oda-button icon="carbon:close" :icon-size="14" @tap="showPrompts = false"></oda-button>
|
|
528
552
|
</div>
|
|
529
|
-
<div class="prompt-cats">
|
|
553
|
+
<div class="prompt-cats" ~if="showCategoryPills">
|
|
530
554
|
<button class="prompt-cat-pill" ~for="promptCategories" :active="promptCategory === $for.item.id" @tap="promptCategory = $for.item.id">
|
|
531
555
|
<oda-icon no-flex :icon="$for.item.icon" :icon-size="12"></oda-icon>
|
|
532
556
|
<span>{{$for.item.label}}</span>
|
|
@@ -563,7 +587,7 @@ ODA({
|
|
|
563
587
|
<div class="welcome-text">
|
|
564
588
|
Задайте вопрос по работе в системе, структуре данных или учёту, выберите один из типовых сценариев ниже либо нажмите кнопку <b>«?»</b> в шапке открытой формы. Все диалоги сохраняются как задачи в ваших личных логах.
|
|
565
589
|
</div>
|
|
566
|
-
<div class="quick-chips" ~if="activeFormSummary">
|
|
590
|
+
<div class="quick-chips" ~if="activeFormSummary && !isUnassignedUser">
|
|
567
591
|
<button class="quick-chip" @tap="askCurrentForm">
|
|
568
592
|
<oda-icon no-flex icon="icons:dashboard" :icon-size="15"></oda-icon>
|
|
569
593
|
<span>Что сейчас открыто в форме «{{activeFormSummary.label}}»?</span>
|
|
@@ -573,7 +597,7 @@ ODA({
|
|
|
573
597
|
<span>{{contextSecondaryPrompt.label}}</span>
|
|
574
598
|
</button>
|
|
575
599
|
</div>
|
|
576
|
-
<div class="prompt-cats">
|
|
600
|
+
<div class="prompt-cats" ~if="showCategoryPills">
|
|
577
601
|
<button class="prompt-cat-pill" ~for="promptCategories" :active="promptCategory === $for.item.id" @tap="promptCategory = $for.item.id">
|
|
578
602
|
<oda-icon no-flex :icon="$for.item.icon" :icon-size="12"></oda-icon>
|
|
579
603
|
<span>{{$for.item.label}}</span>
|
|
@@ -600,7 +624,7 @@ ODA({
|
|
|
600
624
|
<oda-button class="down" ~if="hasMessages && !pinned && !needsHuman" icon="carbon:arrow-down" :icon-size="18" title="К последнему" @tap="toBottom"></oda-button>
|
|
601
625
|
<oda-button class="down attn" ~if="hasMessages && !pinned && needsHuman" accent-invert icon="carbon:arrow-down" :icon-size="16" label="Агент ждёт вас" title="Перейти к вопросу или разрешению" @tap="toBottom"></oda-button>
|
|
602
626
|
<microchat-voice ~if="voiceOn"></microchat-voice>
|
|
603
|
-
<work-prompt-bar ai ::value ::files :pending="busy" :placeholder="placeholderText"
|
|
627
|
+
<work-prompt-bar ai :hide-model-picker="isUnassignedUser" ::value ::files :pending="busy" :placeholder="placeholderText"
|
|
604
628
|
::model
|
|
605
629
|
@model-changed.stop="onModelChanged"
|
|
606
630
|
@send="send" @stop="stop"></work-prompt-bar>
|
|
@@ -630,6 +654,7 @@ ODA({
|
|
|
630
654
|
recentTasks: [],
|
|
631
655
|
activeFormContext: null,
|
|
632
656
|
activeFormSummary: null,
|
|
657
|
+
userScope: null,
|
|
633
658
|
_sending: false,
|
|
634
659
|
voiceOn: {
|
|
635
660
|
$def: false,
|
|
@@ -638,16 +663,46 @@ ODA({
|
|
|
638
663
|
},
|
|
639
664
|
},
|
|
640
665
|
|
|
666
|
+
get accessTier() {
|
|
667
|
+
const s = this.userScope;
|
|
668
|
+
if (!s)
|
|
669
|
+
return globalThis.WORK?.DEV_MODE ? 'workBoss' : 'onboarding';
|
|
670
|
+
if (s.isWorkBoss)
|
|
671
|
+
return 'workBoss';
|
|
672
|
+
if (s.isUnitBoss)
|
|
673
|
+
return 'unitBoss';
|
|
674
|
+
if (s.hasAnyRole)
|
|
675
|
+
return 'member';
|
|
676
|
+
return 'onboarding';
|
|
677
|
+
},
|
|
678
|
+
get isUnassignedUser() {
|
|
679
|
+
return this.accessTier === 'onboarding';
|
|
680
|
+
},
|
|
681
|
+
get isWorkBoss() {
|
|
682
|
+
return this.accessTier === 'workBoss';
|
|
683
|
+
},
|
|
684
|
+
get showCategoryPills() {
|
|
685
|
+
return this.promptCategories.length > 1;
|
|
686
|
+
},
|
|
641
687
|
get promptCategories() {
|
|
642
|
-
|
|
688
|
+
const rank = TIER_RANK[this.accessTier] ?? 0;
|
|
689
|
+
return CONSULTANT_PROMPT_CATEGORIES.filter(c => rank >= (TIER_RANK[c.minTier] ?? 0));
|
|
643
690
|
},
|
|
644
691
|
get filteredPrompts() {
|
|
692
|
+
const rank = TIER_RANK[this.accessTier] ?? 0;
|
|
693
|
+
const allowed = CONSULTANT_PROMPTS.filter(p => {
|
|
694
|
+
const minR = TIER_RANK[p.minTier] ?? 0;
|
|
695
|
+
const maxR = p.maxTier != null ? (TIER_RANK[p.maxTier] ?? 99) : 99;
|
|
696
|
+
return rank >= minR && rank <= maxR;
|
|
697
|
+
});
|
|
645
698
|
const cat = this.promptCategory || 'all';
|
|
646
|
-
if (cat === 'all')
|
|
647
|
-
return
|
|
648
|
-
return
|
|
699
|
+
if (cat === 'all' || this.isUnassignedUser)
|
|
700
|
+
return allowed;
|
|
701
|
+
return allowed.filter(p => p.category === cat);
|
|
649
702
|
},
|
|
650
703
|
get contextSecondaryPrompt() {
|
|
704
|
+
if (this.isUnassignedUser)
|
|
705
|
+
return null;
|
|
651
706
|
const ctx = this.activeFormSummary;
|
|
652
707
|
if (!ctx?.path)
|
|
653
708
|
return null;
|
|
@@ -753,6 +808,7 @@ ODA({
|
|
|
753
808
|
attached() {
|
|
754
809
|
ensureConsultantUI().then(() => {
|
|
755
810
|
this.uiReady = true;
|
|
811
|
+
this._refreshUserScope();
|
|
756
812
|
this._hydrateModel();
|
|
757
813
|
this.refreshFormContext();
|
|
758
814
|
});
|
|
@@ -829,9 +885,28 @@ ODA({
|
|
|
829
885
|
v.addEventListener(k, fn);
|
|
830
886
|
},
|
|
831
887
|
|
|
888
|
+
async _refreshUserScope() {
|
|
889
|
+
if (!globalThis.WORK?.uid) {
|
|
890
|
+
this.userScope = { isUnassigned: true, hasAnyRole: false, isUnitBoss: false, isWorkBoss: false };
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
893
|
+
if (globalThis.WORK?.DEV_MODE) {
|
|
894
|
+
this.userScope = { isUnassigned: false, hasAnyRole: true, isUnitBoss: true, isWorkBoss: true };
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
897
|
+
const res = await globalThis.WORK.fetch('/', 'my_scope').catch(() => null);
|
|
898
|
+
if (res) {
|
|
899
|
+
this.userScope = res;
|
|
900
|
+
const cats = this.promptCategories;
|
|
901
|
+
if (this.promptCategory !== 'all' && !cats.some(c => c.id === this.promptCategory))
|
|
902
|
+
this.promptCategory = 'all';
|
|
903
|
+
}
|
|
904
|
+
},
|
|
905
|
+
|
|
832
906
|
async onShow() {
|
|
833
907
|
await ensureConsultantUI();
|
|
834
908
|
this.uiReady = true;
|
|
909
|
+
this._refreshUserScope();
|
|
835
910
|
this._hydrateModel();
|
|
836
911
|
this.refreshFormContext();
|
|
837
912
|
this.async(() => {
|
|
@@ -892,12 +967,9 @@ ODA({
|
|
|
892
967
|
if (this.model && !/(flux|sdxl|stable-?diffusion|z-image|embedding|bge-|rerank|whisper|\basr\b|\btts\b|\bstt\b|voice|kokoro|musicgen|wan2|ltx-video)/i.test(this.model))
|
|
893
968
|
return;
|
|
894
969
|
try {
|
|
895
|
-
const
|
|
896
|
-
if (
|
|
897
|
-
|
|
898
|
-
const leaf = firstChatLeaf(aiRoot);
|
|
899
|
-
if (leaf?.path)
|
|
900
|
-
this.model = leaf.path;
|
|
970
|
+
const defModel = await WORK.fetch('/', 'agent_default_model', { nodePath: '/' }).catch(() => '');
|
|
971
|
+
if (typeof defModel === 'string' && defModel.trim())
|
|
972
|
+
this.model = defModel.trim();
|
|
901
973
|
}
|
|
902
974
|
catch { /* ignore */ }
|
|
903
975
|
},
|
|
@@ -922,22 +994,7 @@ ODA({
|
|
|
922
994
|
}
|
|
923
995
|
}
|
|
924
996
|
catch { /* ignore */ }
|
|
925
|
-
|
|
926
|
-
const usersRoot = await WORK.get_item('/USERS');
|
|
927
|
-
const items = await usersRoot?.items;
|
|
928
|
-
if (Array.isArray(items) && items.length) {
|
|
929
|
-
const found = items.find(u => u.id === 'CA4E097FF6C1D387') || items[0];
|
|
930
|
-
if (found?.save_file)
|
|
931
|
-
return found;
|
|
932
|
-
if (found?.id) {
|
|
933
|
-
const u = await WORK.get_$user(found.id);
|
|
934
|
-
if (u)
|
|
935
|
-
return u;
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
catch { /* ignore */ }
|
|
940
|
-
return this.$item || await WORK.get_item('/');
|
|
997
|
+
return null;
|
|
941
998
|
},
|
|
942
999
|
|
|
943
1000
|
onModelChanged(e) {
|
|
@@ -183,11 +183,12 @@ export default {
|
|
|
183
183
|
_leftButtonsSig(list) {
|
|
184
184
|
return (list || []).map(b => `${b.icon || ''}|${b.title || ''}|${Boolean(b.rainbow)}|${Boolean(b.errorInvert)}|${b.style || ''}`).join(';;');
|
|
185
185
|
},
|
|
186
|
-
/** Пересобрать кнопки (только при реальном изменении
|
|
187
|
-
_refreshLeftButtons() {
|
|
186
|
+
/** Пересобрать кнопки (только при реальном изменении состава/иконки или пустом списке, чтобы левая панель не мигала и не пропадала). */
|
|
187
|
+
_refreshLeftButtons(force = false) {
|
|
188
188
|
const next = this._buildLeftButtons();
|
|
189
189
|
const sig = this._leftButtonsSig(next);
|
|
190
|
-
|
|
190
|
+
const emptyNow = !Array.isArray(this.left_buttons) || this.left_buttons.length === 0;
|
|
191
|
+
if (force || emptyNow || sig !== this._lastLeftButtonsSig) {
|
|
191
192
|
this._lastLeftButtonsSig = sig;
|
|
192
193
|
this.left_buttons = next;
|
|
193
194
|
}
|
|
@@ -301,23 +302,9 @@ export default {
|
|
|
301
302
|
if (this.$item.type === '$server') {
|
|
302
303
|
try {
|
|
303
304
|
const isAdm = await this.$item.isBoss;
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
this.hideTops = 0;
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
const info = await WORK.fetch(location.origin + '/', 'info', { deep: 1, tree: 'main' }).catch(() => null);
|
|
311
|
-
if (Array.isArray(info?.items) && info.items.length === 0 && WORK.USER) {
|
|
312
|
-
this._treeScopeUser = WORK.USER;
|
|
313
|
-
this.hideRoots = 0;
|
|
314
|
-
this.hideTops = 0;
|
|
315
|
-
}
|
|
316
|
-
else {
|
|
317
|
-
this._treeScopeUser = null;
|
|
318
|
-
this.hideRoots = 2;
|
|
319
|
-
this.hideTops = 1;
|
|
320
|
-
}
|
|
305
|
+
this._treeScopeUser = null;
|
|
306
|
+
this.hideRoots = 2;
|
|
307
|
+
this.hideTops = isAdm ? 0 : 1;
|
|
321
308
|
}
|
|
322
309
|
catch { /* ignore */ }
|
|
323
310
|
}
|
|
@@ -848,10 +835,11 @@ export default {
|
|
|
848
835
|
if (this.left_drawer)
|
|
849
836
|
this.left_drawer.closed = false;
|
|
850
837
|
}
|
|
851
|
-
this._refreshLeftButtons();
|
|
838
|
+
this._refreshLeftButtons(true);
|
|
852
839
|
this._initTopLicenseBanner();
|
|
853
840
|
this._refreshSupportBadge();
|
|
854
841
|
this._syncExplorerTreeScope();
|
|
842
|
+
this.$('#consultant')?._refreshUserScope?.();
|
|
855
843
|
this.render?.();
|
|
856
844
|
});
|
|
857
845
|
if (!this._onNodeDeleted && WORK.chatEvents) {
|
|
@@ -282,6 +282,9 @@ async function fetchServerMentionsCatalog() {
|
|
|
282
282
|
if (_cachedServerMentions && Date.now() - _cachedServerMentionsAt < 60_000)
|
|
283
283
|
return _cachedServerMentions;
|
|
284
284
|
try {
|
|
285
|
+
const isBoss = Boolean(globalThis.WORK?.DEV_MODE || await globalThis.WORK?.isBoss?.catch?.(() => false));
|
|
286
|
+
if (!isBoss)
|
|
287
|
+
return null;
|
|
285
288
|
const srv = await globalThis.WORK?.get_item?.('/MODULES');
|
|
286
289
|
if (!srv || typeof srv.fetch !== 'function')
|
|
287
290
|
return null;
|
|
@@ -436,7 +439,7 @@ ODA({ is: 'work-prompt-bar',
|
|
|
436
439
|
</button>
|
|
437
440
|
<item-user ~for="receivers" border no-flex :$item="$for.item" :icon-size="22" title="Снять получателя" @tap.stop="toggleReceiver($for.item)"></item-user>
|
|
438
441
|
<div flex></div>
|
|
439
|
-
<button class="pill" id="model-pill" ~if="ai" :title="modelTitle" @tap.stop="selectModel($event)">
|
|
442
|
+
<button class="pill" id="model-pill" ~if="ai && !hideModelPicker" :title="modelTitle" @tap.stop="selectModel($event)">
|
|
440
443
|
<oda-icon :icon="modelIcon" :icon-size="16"></oda-icon><span>{{modelName}}</span><oda-icon icon="carbon:chevron-down" :icon-size="12"></oda-icon>
|
|
441
444
|
</button>
|
|
442
445
|
<span class="timer" ~if="recording">⏺ {{timer}}</span>
|
|
@@ -519,6 +522,7 @@ ODA({ is: 'work-prompt-bar',
|
|
|
519
522
|
return [...starts, ...contains].slice(0, 25);
|
|
520
523
|
},
|
|
521
524
|
ai: false,
|
|
525
|
+
hideModelPicker: false,
|
|
522
526
|
/** Вместо микрофона-диктовки — кнопка голосового диалога со спектром (форма задачи); событие dialog с новым состоянием. */
|
|
523
527
|
dialog: { $attr: true, $def: false },
|
|
524
528
|
dialogOn: false,
|
|
@@ -944,6 +948,25 @@ ODA({ is: 'work-prompt-bar',
|
|
|
944
948
|
},
|
|
945
949
|
async selectModel(e) {
|
|
946
950
|
const anchor = e?.currentTarget || (e?.nodeType === 1 ? e : null) || e?.target?.closest?.('button.pill') || this.$('#model-pill') || this;
|
|
951
|
+
const isWorkBoss = Boolean(WORK?.DEV_MODE || await WORK?.isBoss?.catch?.(() => false));
|
|
952
|
+
if (!isWorkBoss) {
|
|
953
|
+
const models = await WORK.fetch('/', 'agent_chat_models').catch(() => []);
|
|
954
|
+
const options = (Array.isArray(models) ? models : []).map(m => ({
|
|
955
|
+
id: m.path,
|
|
956
|
+
label: m.label || String(m.path || '').split('/').pop() || m.path,
|
|
957
|
+
icon: 'carbon:machine-learning-model',
|
|
958
|
+
hint: m.active ? '' : 'неактивна',
|
|
959
|
+
}));
|
|
960
|
+
if (!options.length)
|
|
961
|
+
return;
|
|
962
|
+
const picked = await this._menu({ currentTarget: anchor }, options, this.model);
|
|
963
|
+
if (picked) {
|
|
964
|
+
setUserPreferredModel(picked);
|
|
965
|
+
this.model = picked;
|
|
966
|
+
this.focusInput();
|
|
967
|
+
}
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
947
970
|
const modelsRoot = await WORK.get_item('/MODULES/Модели');
|
|
948
971
|
try {
|
|
949
972
|
if (modelsRoot?.[R]?.cache)
|
package/MODULES/$domain/class.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "odant-work",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.106",
|
|
4
4
|
"description": "ODANT-WORK — платформа цифровой организации (встроенная система учёта, документооборот, управление процессами и приватный мультимодальный ИИ)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "sources/work.js",
|
package/sources/client.js
CHANGED
|
@@ -42,7 +42,7 @@ export const MEMBERS = Object.freeze({
|
|
|
42
42
|
logs: L.READ, logs_dates: L.READ, log_files: L.READ, read_log_bodies: L.READ,
|
|
43
43
|
read_log_entry: L.READ, log_index: L.READ, chatSource: L.READ,
|
|
44
44
|
chat_thread_open: L.CALL, chat_threads_list: L.READ, chat_messages_list: L.READ,
|
|
45
|
-
chat_send: L.
|
|
45
|
+
chat_send: L.CALL, chat_mark_read: L.CALL, chat_action: L.WRITE, chat_unread_summary: L.AUTH, visible_contacts: L.AUTH, my_scope: L.AUTH,
|
|
46
46
|
mail_accounts: L.READ, mail_list: L.READ, mail_read: L.READ,
|
|
47
47
|
mail_draft_save: L.WRITE, mail_send: L.WRITE, mail_state: L.WRITE, mail_refresh: L.WRITE,
|
|
48
48
|
calendar_list: L.READ, calendar_save: L.WRITE,
|
|
@@ -44,6 +44,10 @@ export async function dbForThreadStorage(storage, kind = '') {
|
|
|
44
44
|
return LOGS.dbForStorage(storage);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
function isSysSession(params = {}) {
|
|
48
|
+
return DEV_MODE || !params?.session || params.session.$user === globalThis.WORK;
|
|
49
|
+
}
|
|
50
|
+
|
|
47
51
|
function resolveActorUid(storage, params = {}) {
|
|
48
52
|
const uid = storage?.constructor?.resolveUid?.(params);
|
|
49
53
|
if (uid)
|
|
@@ -127,6 +131,12 @@ export async function openThread(storage, params = {}) {
|
|
|
127
131
|
if (!peerId)
|
|
128
132
|
throw new Error('Не указан собеседник (peerId)');
|
|
129
133
|
const threadId = dmThreadId(uid, peerId);
|
|
134
|
+
const existing = getThreadWithMeta(db, threadId, uid);
|
|
135
|
+
if (!existing && peerId !== uid && !isSysSession(params)) {
|
|
136
|
+
const contacts = await visibleContacts(storage, params).catch(() => []);
|
|
137
|
+
if (!contacts.some(c => c.id === peerId))
|
|
138
|
+
throw new Error(ACCESS_DENIED);
|
|
139
|
+
}
|
|
130
140
|
const title = String(params.title || '').trim();
|
|
131
141
|
tx(db, () => {
|
|
132
142
|
db.prepare(`
|
|
@@ -354,6 +364,12 @@ export async function sendMessage(storage, params = {}) {
|
|
|
354
364
|
const isParticipant = thread.participants.some(p => p.uid === uid);
|
|
355
365
|
if (!isParticipant && !isTwinBot)
|
|
356
366
|
throw new Error(ACCESS_DENIED);
|
|
367
|
+
if (thread.kind !== 'dm' && !isTwinBot && !isSysSession(params)) {
|
|
368
|
+
const canSee = await storage.canSee?.(storage, params).catch(() => false);
|
|
369
|
+
const roles = await storage.roles?.(params).catch(() => []) || [];
|
|
370
|
+
if (!canSee && !roles.length)
|
|
371
|
+
throw new Error(ACCESS_DENIED);
|
|
372
|
+
}
|
|
357
373
|
|
|
358
374
|
const content = String(params.message ?? params.content ?? '');
|
|
359
375
|
const msgKind = String(params.kind || 'text').trim() || 'text';
|
|
@@ -561,14 +577,26 @@ export async function visibleContacts(storage, params = {}) {
|
|
|
561
577
|
});
|
|
562
578
|
}
|
|
563
579
|
|
|
580
|
+
await Promise.resolve(globalThis.WORK?.init).catch(() => {});
|
|
581
|
+
const rootBossIds = new Set(
|
|
582
|
+
(Array.isArray(globalThis.WORK?.DATA?.['#security']?.BOSS) ? globalThis.WORK.DATA['#security'].BOSS : [])
|
|
583
|
+
.filter(id => id && !WORKPLACES.isPseudoUser(id))
|
|
584
|
+
);
|
|
585
|
+
|
|
564
586
|
const isWorkBoss = uid && globalThis.WORK
|
|
565
|
-
? (
|
|
587
|
+
? (isSysSession(params) || await globalThis.WORK._isWorkBoss?.(params).catch(() => false))
|
|
566
588
|
: Boolean(DEV_MODE);
|
|
567
589
|
|
|
568
590
|
const visibleIds = new Set();
|
|
569
591
|
const externalOnlyIds = new Set();
|
|
570
592
|
if (uid && userMap.has(uid))
|
|
571
593
|
visibleIds.add(uid);
|
|
594
|
+
if (uid) {
|
|
595
|
+
for (const bossId of rootBossIds) {
|
|
596
|
+
if (userMap.has(bossId))
|
|
597
|
+
visibleIds.add(bossId);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
572
600
|
|
|
573
601
|
if (isWorkBoss) {
|
|
574
602
|
for (const id of userMap.keys())
|
|
@@ -581,7 +609,7 @@ export async function visibleContacts(storage, params = {}) {
|
|
|
581
609
|
const containers = dom ? ((await dom.items) || []).filter(c => c && c.id && c.id[0] !== '$') : [];
|
|
582
610
|
for (const base of containers) {
|
|
583
611
|
const units = [base];
|
|
584
|
-
const sub = await base.items
|
|
612
|
+
const sub = await Promise.resolve(base.items).catch(() => []) || [];
|
|
585
613
|
for (const s of sub) {
|
|
586
614
|
if (s?.type === '$structure' || s?.DATA?.isDepartment)
|
|
587
615
|
units.push(s);
|
|
@@ -590,7 +618,7 @@ export async function visibleContacts(storage, params = {}) {
|
|
|
590
618
|
const internalSet = new Set();
|
|
591
619
|
const externalSet = new Set();
|
|
592
620
|
for (const u of units) {
|
|
593
|
-
await u.init
|
|
621
|
+
await Promise.resolve(u.init).catch(() => {});
|
|
594
622
|
const sec = u.DATA?.['#security'] || {};
|
|
595
623
|
const roles = await u.roles?.(params).catch(() => []) || [];
|
|
596
624
|
if (roles.length)
|
|
@@ -650,6 +678,7 @@ export async function visibleContacts(storage, params = {}) {
|
|
|
650
678
|
out.push({
|
|
651
679
|
...entry,
|
|
652
680
|
external: externalOnlyIds.has(id),
|
|
681
|
+
superBoss: rootBossIds.has(id),
|
|
653
682
|
});
|
|
654
683
|
}
|
|
655
684
|
return out;
|
|
@@ -11,6 +11,18 @@ import { DEV_MODE } from '../../host/config.js';
|
|
|
11
11
|
|
|
12
12
|
const ACCESS_DENIED = 'Доступ запрещён';
|
|
13
13
|
|
|
14
|
+
function mergeChatPost(params = {}, post) {
|
|
15
|
+
let body = post ?? params?.post ?? params?.body ?? params?.data;
|
|
16
|
+
if (typeof body === 'string' && body.trim()) {
|
|
17
|
+
try { body = JSON.parse(body); } catch { /* ignore */ }
|
|
18
|
+
}
|
|
19
|
+
if (body && typeof body === 'object' && !Array.isArray(body)) {
|
|
20
|
+
const { session: _drop, ...safeBody } = body;
|
|
21
|
+
return { ...safeBody, ...params, session: params?.session };
|
|
22
|
+
}
|
|
23
|
+
return params;
|
|
24
|
+
}
|
|
25
|
+
|
|
14
26
|
export const classFeedMethods = {
|
|
15
27
|
/** Может ли вызывающий принудительно открыть местный лог точки (роль BOSS здесь или выше по дереву). */
|
|
16
28
|
async _canViewLocalFeed(params = {}) {
|
|
@@ -161,28 +173,28 @@ export const classFeedMethods = {
|
|
|
161
173
|
},
|
|
162
174
|
|
|
163
175
|
/** Открыть/создать беседу мессенджера (twin на $structure, dm на $user, group). */
|
|
164
|
-
async chat_thread_open(params = {}) {
|
|
165
|
-
return CHAT.openThread(this, params);
|
|
176
|
+
async chat_thread_open(params = {}, post) {
|
|
177
|
+
return CHAT.openThread(this, mergeChatPost(params, post));
|
|
166
178
|
},
|
|
167
179
|
|
|
168
180
|
/** Список бесед (mine — свои, audit — взаимодействия пользователей с Агентом для BOSS). */
|
|
169
|
-
async chat_threads_list(params = {}) {
|
|
170
|
-
return CHAT.listThreads(this, params);
|
|
181
|
+
async chat_threads_list(params = {}, post) {
|
|
182
|
+
return CHAT.listThreads(this, mergeChatPost(params, post));
|
|
171
183
|
},
|
|
172
184
|
|
|
173
185
|
/** Сообщения беседы с проверкой прав (участник или BOSS для twin-аудита). */
|
|
174
|
-
async chat_messages_list(params = {}) {
|
|
175
|
-
return CHAT.listMessages(this, params);
|
|
186
|
+
async chat_messages_list(params = {}, post) {
|
|
187
|
+
return CHAT.listMessages(this, mergeChatPost(params, post));
|
|
176
188
|
},
|
|
177
189
|
|
|
178
190
|
/** Отправить сообщение в беседу + рассылка по WebSocket. */
|
|
179
|
-
async chat_send(params = {}) {
|
|
180
|
-
return CHAT.sendMessage(this, params);
|
|
191
|
+
async chat_send(params = {}, post) {
|
|
192
|
+
return CHAT.sendMessage(this, mergeChatPost(params, post));
|
|
181
193
|
},
|
|
182
194
|
|
|
183
195
|
/** Отметить беседу прочитанной. */
|
|
184
|
-
async chat_mark_read(params = {}) {
|
|
185
|
-
return CHAT.markRead(this, params);
|
|
196
|
+
async chat_mark_read(params = {}, post) {
|
|
197
|
+
return CHAT.markRead(this, mergeChatPost(params, post));
|
|
186
198
|
},
|
|
187
199
|
|
|
188
200
|
/** Сводка непрочитанного. */
|
|
@@ -191,8 +203,8 @@ export const classFeedMethods = {
|
|
|
191
203
|
},
|
|
192
204
|
|
|
193
205
|
/** Подтвердить/отклонить карточку действия (kind = 'approval') в беседе. */
|
|
194
|
-
async chat_action(params = {}) {
|
|
195
|
-
return CHAT.resolveApproval(this, params);
|
|
206
|
+
async chat_action(params = {}, post) {
|
|
207
|
+
return CHAT.resolveApproval(this, mergeChatPost(params, post));
|
|
196
208
|
},
|
|
197
209
|
|
|
198
210
|
/** Вычисляемый список видимых контактов («Люди»). */
|
|
@@ -575,6 +575,8 @@ export const classSecurityMethods = {
|
|
|
575
575
|
}
|
|
576
576
|
if (this._isSystemItem(item))
|
|
577
577
|
return true;
|
|
578
|
+
if (this._hasRootBossOnlyAncestor(item) || this._hasRootBossOnlyAncestor(this))
|
|
579
|
+
return false;
|
|
578
580
|
if (this.areaOf(item).kind === POLICY.AREA.SECRET)
|
|
579
581
|
return false;
|
|
580
582
|
const isUserSession = Boolean(uid && params.session?.principal?.kind !== 'node');
|
|
@@ -712,41 +714,101 @@ export const classSecurityMethods = {
|
|
|
712
714
|
},
|
|
713
715
|
|
|
714
716
|
/** Есть ли у субъекта хотя бы одна внутренняя роль сотрудника (BOSS или не-external должность), а не только внешняя. */
|
|
715
|
-
async
|
|
716
|
-
if (
|
|
717
|
-
return true;
|
|
717
|
+
async _roleSummary(params = {}) {
|
|
718
|
+
if (this._isSysSession(params)) {
|
|
719
|
+
return { hasInternal: true, hasExternal: false, isWorkBoss: true, isUnitBoss: true, hasAnyRole: true };
|
|
720
|
+
}
|
|
718
721
|
const uid = this.constructor.resolveUid(params);
|
|
719
|
-
if (!uid)
|
|
720
|
-
return false;
|
|
721
|
-
|
|
722
|
-
|
|
722
|
+
if (!uid) {
|
|
723
|
+
return { hasInternal: false, hasExternal: false, isWorkBoss: false, isUnitBoss: false, hasAnyRole: false };
|
|
724
|
+
}
|
|
725
|
+
let hasInternal = false;
|
|
726
|
+
let hasExternal = false;
|
|
727
|
+
let isWorkBoss = false;
|
|
728
|
+
let isUnitBoss = false;
|
|
729
|
+
let hasAnyRole = false;
|
|
730
|
+
|
|
731
|
+
const inspectNode = async (node, isRoot = false) => {
|
|
732
|
+
const r = await Promise.resolve(node?.roles?.(params)).catch(() => []) || [];
|
|
723
733
|
if (!r.length)
|
|
724
|
-
return
|
|
734
|
+
return;
|
|
735
|
+
hasAnyRole = true;
|
|
725
736
|
const decl = node._declaredRolesSync?.() || {};
|
|
726
|
-
|
|
737
|
+
if (r.includes(this.constructor.ROLES.BOSS)) {
|
|
738
|
+
hasInternal = true;
|
|
739
|
+
if (isRoot)
|
|
740
|
+
isWorkBoss = true;
|
|
741
|
+
else
|
|
742
|
+
isUnitBoss = true;
|
|
743
|
+
}
|
|
744
|
+
for (const id of r) {
|
|
745
|
+
if (id === this.constructor.ROLES.BOSS || !decl[id]?.external)
|
|
746
|
+
hasInternal = true;
|
|
747
|
+
else
|
|
748
|
+
hasExternal = true;
|
|
749
|
+
}
|
|
727
750
|
};
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
751
|
+
|
|
752
|
+
if (globalThis.WORK)
|
|
753
|
+
await inspectNode(globalThis.WORK, true);
|
|
754
|
+
|
|
755
|
+
const dom = await globalThis.WORK?.get_item?.('/PROJECTS').catch(() => null);
|
|
756
|
+
const roots = dom ? ((await Promise.resolve(dom.items).catch(() => [])) || []).filter(b => b && b.id?.[0] !== '$') : [];
|
|
757
|
+
const stack = roots.map(node => ({ node, depth: 0 }));
|
|
758
|
+
while (stack.length) {
|
|
759
|
+
const { node, depth } = stack.pop();
|
|
760
|
+
await inspectNode(node, false);
|
|
761
|
+
if (isUnitBoss && hasInternal && hasExternal)
|
|
762
|
+
break;
|
|
763
|
+
if (depth >= 5)
|
|
764
|
+
continue;
|
|
765
|
+
const sub = await Promise.resolve(node.items).catch(() => []) || [];
|
|
766
|
+
for (const s of sub) {
|
|
767
|
+
if (s && (s.type === '$structure' || s.DATA?.isDepartment) && s.id?.[0] !== '$')
|
|
768
|
+
stack.push({ node: s, depth: depth + 1 });
|
|
745
769
|
}
|
|
770
|
+
}
|
|
771
|
+
return { hasInternal, hasExternal, isWorkBoss, isUnitBoss, hasAnyRole };
|
|
772
|
+
},
|
|
773
|
+
|
|
774
|
+
async _hasInternalWorkRole(params = {}) {
|
|
775
|
+
const sum = await this._roleSummary(params);
|
|
776
|
+
return sum.hasInternal;
|
|
777
|
+
},
|
|
778
|
+
|
|
779
|
+
_isSysSession(params) {
|
|
780
|
+
return DEV_MODE || !params?.session || params.session.$user === globalThis.WORK;
|
|
781
|
+
},
|
|
782
|
+
|
|
783
|
+
async _canAccessUsersContainer(params = {}) {
|
|
784
|
+
if (this._isSysSession(params))
|
|
785
|
+
return true;
|
|
786
|
+
if (params?.session?.principal?.kind === 'node')
|
|
787
|
+
return false;
|
|
788
|
+
const uid = this.constructor.resolveUid(params);
|
|
789
|
+
if (!uid)
|
|
746
790
|
return false;
|
|
791
|
+
const sum = await this._roleSummary(params);
|
|
792
|
+
// Внутренние сотрудники и неназначенные пользователи видят /USERS; внешние (external-only) — нет
|
|
793
|
+
return sum.hasInternal || !sum.hasExternal;
|
|
794
|
+
},
|
|
795
|
+
|
|
796
|
+
/** Сводка ролевого контекста текущего пользователя (для UI профиля и Консультанта). */
|
|
797
|
+
async my_scope(params = {}) {
|
|
798
|
+
const uid = this.constructor.resolveUid(params);
|
|
799
|
+
const sum = await this._roleSummary(params);
|
|
800
|
+
return {
|
|
801
|
+
uid: uid || '',
|
|
802
|
+
...sum,
|
|
803
|
+
isUnassigned: Boolean(uid && !sum.hasAnyRole && !sum.isWorkBoss),
|
|
747
804
|
};
|
|
748
|
-
|
|
749
|
-
|
|
805
|
+
},
|
|
806
|
+
|
|
807
|
+
_hasRootBossOnlyAncestor(node) {
|
|
808
|
+
for (let cur = node; cur && cur instanceof FS.$folder; cur = cur.$parent) {
|
|
809
|
+
if (cur.DATA?.rootBossOnly === true && (!cur.$parent || !cur.$parent.$parent))
|
|
810
|
+
return true;
|
|
811
|
+
}
|
|
750
812
|
return false;
|
|
751
813
|
},
|
|
752
814
|
|
|
@@ -769,15 +831,19 @@ export const classSecurityMethods = {
|
|
|
769
831
|
},
|
|
770
832
|
|
|
771
833
|
async allowAccess(params) {
|
|
772
|
-
const isSysSession =
|
|
834
|
+
const isSysSession = this._isSysSession(params);
|
|
773
835
|
await this.init;
|
|
774
|
-
// Раздел /USERS (usersContainer): виден внутренним
|
|
836
|
+
// Раздел /USERS (usersContainer): виден внутренним и неназначенным пользователям; скрыт от external-only и гостей
|
|
775
837
|
if (this.DATA?.usersContainer === true) {
|
|
838
|
+
return this._canAccessUsersContainer(params);
|
|
839
|
+
}
|
|
840
|
+
// Корневой контейнер с rootBossOnly (например /MODULES): виден в дереве и API только BOSS корня WORK
|
|
841
|
+
if (this._hasRootBossOnlyAncestor(this)) {
|
|
776
842
|
if (isSysSession)
|
|
777
843
|
return true;
|
|
778
844
|
if (params?.session?.principal?.kind === 'node')
|
|
779
845
|
return false;
|
|
780
|
-
return this.
|
|
846
|
+
return Boolean(await this._isWorkBoss(params));
|
|
781
847
|
}
|
|
782
848
|
// Домен-контейнер (например /PROJECTS, /MODULES): виден только BOSS или при наличии хотя бы одного доступного потомка
|
|
783
849
|
if (this.DATA?.container === true && !this.hasAssignments()) {
|
package/sources/server/user.js
CHANGED
|
@@ -150,13 +150,21 @@ export class $user extends $class {
|
|
|
150
150
|
await this.init;
|
|
151
151
|
if (this.DATA?.usersContainer === true)
|
|
152
152
|
return super.allowAccess(params);
|
|
153
|
-
|
|
154
|
-
if (DEV_MODE)
|
|
153
|
+
if (DEV_MODE || !params?.session || params.session.$user === globalThis.WORK)
|
|
155
154
|
return true;
|
|
156
|
-
// профили пользователей
|
|
155
|
+
// профили пользователей закрыты для узлов сети и анонимных запросов
|
|
157
156
|
if (params?.session?.principal?.kind === 'node')
|
|
158
157
|
return false;
|
|
159
|
-
|
|
158
|
+
const uid = this.constructor.resolveUid(params);
|
|
159
|
+
if (!uid)
|
|
160
|
+
return false;
|
|
161
|
+
if (this.id === uid)
|
|
162
|
+
return true;
|
|
163
|
+
if (globalThis.WORK && await this._isWorkBoss(params))
|
|
164
|
+
return true;
|
|
165
|
+
const { visibleContacts } = await import('./chat-threads.js');
|
|
166
|
+
const contacts = await visibleContacts(this, params);
|
|
167
|
+
return contacts.some(c => c.id === this.id);
|
|
160
168
|
}
|
|
161
169
|
}
|
|
162
170
|
$user.type_chain = Object.create(null);
|