odant-work 1.0.105 → 1.0.107

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/$server/$folder/$class/$structure/$user/handlers/pages/form/calendar/$handler/class.js +12 -0
  2. package/$server/$folder/$class/$structure/$user/handlers/pages/form/email/$handler/class.js +12 -0
  3. package/$server/$folder/$class/$structure/$user/handlers/pages/form/folder/$handler/class.js +12 -0
  4. package/$server/$folder/$class/$structure/$user/handlers/pages/form/search/$handler/class.js +12 -0
  5. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/$handler/class.js +14 -0
  6. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/agent/$handler/class.js +5 -4
  7. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/skills/$handler/class.js +5 -4
  8. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/tokens/$handler/class.js +8 -2
  9. package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +73 -22
  10. package/$server/$folder/handlers/pages/form/$handler/class.js +255 -100
  11. package/$server/$folder/lib/consultant/consultant.js +123 -66
  12. package/$server/$folder/lib/explorer/explorer.js +19 -22
  13. package/$server/$folder/lib/icon/icon.js +4 -1
  14. package/$server/$folder/lib/prompt-bar/prompt-bar.js +24 -1
  15. package/$server/$folder/lib/tree/tree.js +5 -5
  16. package/MODULES/$domain/class.js +1 -0
  17. package/package.json +1 -1
  18. package/sources/client.js +30 -2
  19. package/sources/host/auth-methods.js +25 -14
  20. package/sources/host/http-server.js +1 -0
  21. package/sources/host/websocket.js +11 -8
  22. package/sources/modules/call/call.js +5 -1
  23. package/sources/modules/user-profile/user-profile.js +9 -1
  24. package/sources/server/access/gateway.js +3 -7
  25. package/sources/server/chat-threads.js +32 -3
  26. package/sources/server/class/feed.js +25 -13
  27. package/sources/server/class/security.js +97 -31
  28. package/sources/server/logs.js +17 -10
  29. package/sources/server/server.js +17 -6
  30. package/sources/server/user.js +20 -5
@@ -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), их подразделений ($structure) и подключённых модулей (/MODULES) в системе.',
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
- return CONSULTANT_PROMPT_CATEGORIES;
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 CONSULTANT_PROMPTS;
648
- return CONSULTANT_PROMPTS.filter(p => p.category === cat);
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 aiRoot = await WORK.get_item('/MODULES/Модели', 'info', { deep: 2 });
896
- if (!aiRoot)
897
- return;
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
- try {
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
- if (sig !== this._lastLeftButtonsSig) {
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
- if (isAdm) {
305
- this._treeScopeUser = null;
306
- this.hideRoots = 2;
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
  }
@@ -842,16 +829,26 @@ export default {
842
829
  WORK.authEvents?.addEventListener('auth', () => {
843
830
  this._resolvedUserIcon = '';
844
831
  this.user_icon = undefined;
845
- if (WORK.uid && this._autoOpenedLogin && this.visibleMode === 'user') {
832
+ if (!WORK.uid && !WORK.DEV_MODE) {
833
+ this.focusedPage = '';
834
+ this.pages = [];
835
+ this.bookmarks = [];
836
+ this._autoOpenedLogin = true;
837
+ this.visibleMode = 'user';
838
+ if (this.left_drawer)
839
+ this.left_drawer.closed = true;
840
+ }
841
+ else if (WORK.uid && this._autoOpenedLogin && this.visibleMode === 'user') {
846
842
  this._autoOpenedLogin = false;
847
843
  this.visibleMode = 'main';
848
844
  if (this.left_drawer)
849
845
  this.left_drawer.closed = false;
850
846
  }
851
- this._refreshLeftButtons();
847
+ this._refreshLeftButtons(true);
852
848
  this._initTopLicenseBanner();
853
849
  this._refreshSupportBadge();
854
850
  this._syncExplorerTreeScope();
851
+ this.$('#consultant')?._refreshUserScope?.();
855
852
  this.render?.();
856
853
  });
857
854
  if (!this._onNodeDeleted && WORK.chatEvents) {
@@ -46,8 +46,11 @@ export default {
46
46
  $def: false,
47
47
  $attr: true,
48
48
  get() {
49
- if (this.isUser)
49
+ if (this.isUser) {
50
+ if (this.$item?.DATA?.enabled === false || this.$item?.DATA?.blocked === true)
51
+ return false;
50
52
  return this.$item?.online;
53
+ }
51
54
  return false;
52
55
  }
53
56
  },
@@ -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)
@@ -697,7 +697,6 @@ ODA({is: 'oda-tree-node',
697
697
  :host {
698
698
  @apply --vertical;
699
699
  overflow: visible;
700
- padding: 4px;
701
700
  min-width: 0;
702
701
  }
703
702
  .node {
@@ -713,12 +712,12 @@ ODA({is: 'oda-tree-node',
713
712
  color: var(--content-color);
714
713
  }
715
714
  .node.large-icon-node {
716
- height: 52px;
717
- min-height: 52px;
715
+ height: 64px;
716
+ min-height: 64px;
718
717
  }
719
718
  .node.medium-icon-node {
720
- height: 38px;
721
- min-height: 38px;
719
+ height: 42px;
720
+ min-height: 42px;
722
721
  }
723
722
  .node.structure-only-node {
724
723
  height: 36px;
@@ -742,6 +741,7 @@ ODA({is: 'oda-tree-node',
742
741
  }
743
742
  .node.module-blocked item-node {
744
743
  opacity: .5;
744
+ filter: grayscale(1);
745
745
  }
746
746
  .sub-nodes {
747
747
  @apply --vertical;
@@ -3,6 +3,7 @@ export default {
3
3
  icon: 'odant:folder',
4
4
  form: 'system',
5
5
  container: true,
6
+ rootBossOnly: true,
6
7
  mainTreeChildren: ['$folder', '$module', '$provider', '$mcp'],
7
8
  ACCESS: {
8
9
  mcp_catalog: 'read',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "odant-work",
3
- "version": "1.0.105",
3
+ "version": "1.0.107",
4
4
  "description": "ODANT-WORK — платформа цифровой организации (встроенная система учёта, документооборот, управление процессами и приватный мультимодальный ИИ)",
5
5
  "type": "module",
6
6
  "main": "sources/work.js",
package/sources/client.js CHANGED
@@ -342,7 +342,7 @@ WORK.syncAuthUI = async function () {
342
342
  const explorer = window.explorer;
343
343
  if (!explorer)
344
344
  return;
345
- explorer.left_buttons = undefined;
345
+ explorer._refreshLeftButtons?.();
346
346
  explorer.render?.();
347
347
  };
348
348
 
@@ -403,6 +403,20 @@ WORK.onAuthChanged = function (payload = {}) {
403
403
  } catch {}
404
404
  return;
405
405
  }
406
+ if (payload.reason === 'disabled') {
407
+ WORK.clearSessionCache?.();
408
+ WORK.uid = '';
409
+ WORK.USER = undefined;
410
+ WORK._accountDisabled = true;
411
+ WORK._loginError = new Error('Учётная запись отключена администратором');
412
+ WORK._loginPromise = null;
413
+ WORK.syncAuthUI();
414
+ try {
415
+ WORK.authEvents?.dispatchEvent(new CustomEvent('auth', { detail: { uid: '', reason: 'disabled' } }));
416
+ WORK.authEvents?.dispatchEvent(new CustomEvent('login-state', { detail: { pending: false, error: WORK._loginError, uid: '' } }));
417
+ } catch {}
418
+ return;
419
+ }
406
420
  if (payload.reason === 'logout' && !newUid && !credUid) {
407
421
  WORK.uid = '';
408
422
  WORK.USER = undefined;
@@ -483,6 +497,7 @@ WORK.login = async function(force = false){
483
497
  const prevUid = WORK.uid || '';
484
498
  const authChanged = !WORK._authNotifiedOnce || prevUid !== uid;
485
499
  WORK.uid = uid;
500
+ WORK._accountDisabled = false;
486
501
  WORK._loginError = null;
487
502
  WORK._anonExitSynced = false;
488
503
  if (authChanged || !WORK.USER)
@@ -517,7 +532,20 @@ WORK.login = async function(force = false){
517
532
  }
518
533
  }
519
534
  catch (err) {
520
- WORK._loginError = err;
535
+ const errText = String(err?.message || err || '');
536
+ if (/отключена администратором|account_disabled/i.test(errText)) {
537
+ WORK._accountDisabled = true;
538
+ WORK.uid = '';
539
+ WORK.USER = undefined;
540
+ WORK._loginError = new Error('Учётная запись отключена администратором');
541
+ WORK.syncAuthUI();
542
+ try {
543
+ WORK.authEvents?.dispatchEvent(new CustomEvent('auth', { detail: { uid: '', reason: 'disabled' } }));
544
+ } catch {}
545
+ }
546
+ else {
547
+ WORK._loginError = err;
548
+ }
521
549
  if (WORK._loginPromise === run)
522
550
  WORK._loginPromise = null;
523
551
  throw err;