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.
Files changed (78) hide show
  1. package/$server/$folder/$class/$structure/$department/ai/config.js +9 -0
  2. package/$server/$folder/$class/$structure/$department/ai/system.md +11 -0
  3. package/$server/$folder/$class/$structure/$department/class.js +9 -0
  4. package/$server/$folder/$class/$structure/$project/ai/config.js +9 -0
  5. package/$server/$folder/$class/$structure/$project/ai/system.md +12 -0
  6. package/$server/$folder/$class/$structure/$project/class.js +4 -1
  7. package/$server/$folder/$class/$structure/$project/handlers/pages/site/$handler/class.js +1 -1
  8. package/$server/$folder/$class/$structure/$server/ai/config.js +9 -0
  9. package/$server/$folder/$class/$structure/$server/ai/system.md +10 -0
  10. package/$server/$folder/$class/$structure/$server/class.js +2 -0
  11. package/$server/$folder/$class/$structure/$user/ai/config.js +9 -0
  12. package/$server/$folder/$class/$structure/$user/ai/system.md +8 -0
  13. package/$server/$folder/$class/$structure/$user/class.js +3 -0
  14. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/profile/$handler/class.js +5 -2
  15. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/staff/$handler/class.js +3 -0
  16. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/tokens/$handler/class.js +24 -0
  17. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/users/$handler/class.js +213 -0
  18. package/$server/$folder/$class/$structure/ai/system.md +1 -1
  19. package/$server/$folder/$class/$structure/class.js +4 -2
  20. package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +67 -20
  21. package/$server/$folder/$class/$structure/handlers/pages/form/system/agent/$handler/class.js +132 -3
  22. package/$server/$folder/$class/$structure/handlers/pages/form/system/staff/$handler/class.js +2 -2
  23. package/$server/$folder/$class/$structure/handlers/pages/site/$handler/class.js +2 -1
  24. package/$server/$folder/$class/ai/system.md +2 -2
  25. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/class.js +7 -0
  26. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/dock.js +22 -31
  27. package/$server/$folder/handlers/pages/form/$handler/class.js +47 -5
  28. package/$server/$folder/lib/chat-item/chat-item.js +14 -2
  29. package/$server/$folder/lib/consultant/consultant.js +1 -1
  30. package/$server/$folder/lib/explorer/explorer.js +38 -12
  31. package/$server/$folder/lib/icon/icon.js +1 -1
  32. package/$server/$folder/lib/node/node.js +3 -3
  33. package/$server/$folder/lib/site-loc/site-loc.js +8 -3
  34. package/$server/$folder/lib/tree/tree.js +8 -9
  35. package/AGENTS.md +3 -3
  36. package/MODULES/$domain/class.js +1 -0
  37. package/MODULES//320/234/320/276/320/264/320/265/320/273/320/270/Local/$provider/class.js +1 -0
  38. package/{$server/$folder/$class/$users → USERS/$user}/class.js +4 -1
  39. package/oda/oda.js +15 -1
  40. package/package.json +1 -1
  41. package/readme.md +1 -1
  42. package/scripts/import-bis.mjs +5 -5
  43. package/scripts/import-delovaya.mjs +5 -5
  44. package/sources/client/class.js +1 -1
  45. package/sources/client.js +84 -38
  46. package/sources/data/api.js +1 -1
  47. package/sources/data/classes.js +2 -1
  48. package/sources/data/schema.js +2 -0
  49. package/sources/host/auth-methods.js +15 -4
  50. package/sources/modules/agent/index.js +22 -6
  51. package/sources/modules/agent/node-rules.js +353 -9
  52. package/sources/modules/agent/scheduler.js +7 -0
  53. package/sources/modules/agent/scope.js +8 -6
  54. package/sources/modules/agent/tools/work/access.js +1 -1
  55. package/sources/modules/agent/tools/work/classes.js +1 -1
  56. package/sources/modules/agent/triggers.js +1 -1
  57. package/sources/modules/agent/twin-bus.js +2 -1
  58. package/sources/modules/notify/index.js +5 -2
  59. package/sources/modules/rag/extract.js +1 -1
  60. package/sources/modules/trainer/local-engine.js +3 -1
  61. package/sources/modules/user-profile/user-profile.js +120 -115
  62. package/sources/modules/user-profile/user-tokens.js +185 -0
  63. package/sources/server/access/gateway.js +4 -3
  64. package/sources/server/access/links.js +9 -6
  65. package/sources/server/chat-threads.js +1 -1
  66. package/sources/server/class/base-template.js +3 -2
  67. package/sources/server/class/distro.js +9 -5
  68. package/sources/server/class/feed.js +30 -0
  69. package/sources/server/class/scaffold.js +137 -0
  70. package/sources/server/class/search.js +2 -2
  71. package/sources/server/class/security.js +35 -11
  72. package/sources/server/class.js +5 -3
  73. package/sources/server/folder.js +17 -13
  74. package/sources/server/logs.js +14 -0
  75. package/sources/server/node.js +1 -1
  76. package/sources/server/user.js +3 -0
  77. package/sources/work.js +7 -0
  78. package/USERS/$users/class.js +0 -4
@@ -236,6 +236,48 @@ export default {
236
236
  </div>
237
237
  </div>
238
238
 
239
+ <!-- 1б. Автономный ночной аудит -->
240
+ <div class="card">
241
+ <div class="card-head">
242
+ <oda-icon icon="icons:verified-user" icon-size="20"></oda-icon>
243
+ <span>Автономный аудит во внерабочее время</span>
244
+ <div class="row" style="margin-left:auto;gap:10px;">
245
+ <label class="row" style="gap:5px;cursor:pointer;font-weight:400;font-size:12.5px;">
246
+ <input type="checkbox" :checked="auditEnabled" @change="saveAuditSettings({ enabled: $event.target.checked })">
247
+ <span>Включён</span>
248
+ </label>
249
+ <oda-button icon="icons:play-arrow" info-invert :disabled="auditRunning" @tap="runAuditNow()">
250
+ {{auditRunning ? 'Проверяю…' : 'Запустить аудит сейчас'}}
251
+ </oda-button>
252
+ </div>
253
+ </div>
254
+ <div class="row">
255
+ <div class="field-col" style="max-width:130px;">
256
+ <span class="field-label">Начало окна</span>
257
+ <input type="time" :value="auditWindowStart" @change="saveAuditSettings({ windowStart: $event.target.value })">
258
+ </div>
259
+ <div class="field-col" style="max-width:130px;">
260
+ <span class="field-label">Конец окна</span>
261
+ <input type="time" :value="auditWindowEnd" @change="saveAuditSettings({ windowEnd: $event.target.value })">
262
+ </div>
263
+ <div class="field-col" style="max-width:140px;">
264
+ <span class="field-label">Период (часов)</span>
265
+ <input type="number" min="1" max="168" :value="auditIntervalHours" @change="saveAuditSettings({ intervalHours: Number($event.target.value) || 24 })">
266
+ </div>
267
+ <div class="field-col">
268
+ <span class="field-label">Модель аудита</span>
269
+ <select :value="auditModel" @change="saveAuditSettings({ model: $event.target.value })">
270
+ <option value="">Основная модель узла</option>
271
+ <option ~for="availableModels" :value="$for.item.path">{{$for.item.label}}</option>
272
+ </select>
273
+ </div>
274
+ </div>
275
+ <div class="row" style="justify-content:space-between;" ~if="auditLastText || auditResultText">
276
+ <span class="muted">{{auditResultText || auditLastText}}</span>
277
+ <oda-button ~if="auditLastTask" icon="icons:open-in-new" @tap="openAuditTask()">Открыть задачу</oda-button>
278
+ </div>
279
+ </div>
280
+
239
281
  <!-- 2. Автоматические реакции на события -->
240
282
  <div class="card">
241
283
  <div class="card-head">
@@ -464,9 +506,36 @@ export default {
464
506
  },
465
507
  triggers: [],
466
508
  schedules: [],
509
+ availableModels: [],
510
+ auditRunning: false,
511
+ auditResultText: '',
467
512
  proactivity: {
468
513
  autoReply: true,
469
- quietDigest: true
514
+ quietDigest: true,
515
+ audit: {
516
+ enabled: true,
517
+ windowStart: '20:00',
518
+ windowEnd: '07:00',
519
+ intervalHours: 24,
520
+ model: '',
521
+ lastRun: 0,
522
+ lastStatus: '',
523
+ lastTask: '',
524
+ lastSummary: '',
525
+ }
526
+ },
527
+ get auditEnabled() { return this.proactivity?.audit?.enabled !== false; },
528
+ get auditWindowStart() { return this.proactivity?.audit?.windowStart || '20:00'; },
529
+ get auditWindowEnd() { return this.proactivity?.audit?.windowEnd || '07:00'; },
530
+ get auditIntervalHours() { return Number(this.proactivity?.audit?.intervalHours) || 24; },
531
+ get auditModel() { return this.proactivity?.audit?.model || ''; },
532
+ get auditLastTask() { return this.proactivity?.audit?.lastTask || ''; },
533
+ get auditLastText() {
534
+ const a = this.proactivity?.audit;
535
+ if (!a?.lastRun) return 'Проверок ещё не было (запустится в разрешённом ночном окне).';
536
+ const dt = new Date(a.lastRun).toLocaleString('ru-RU');
537
+ const st = a.lastStatus === 'ok' ? 'без замечаний' : a.lastStatus === 'findings' ? 'есть находки' : a.lastStatus === 'error' ? 'ошибка' : a.lastStatus;
538
+ return `Последний аудит: ${dt} (${st})${a.lastSummary ? ' — ' + a.lastSummary.slice(0, 140) : ''}`;
470
539
  },
471
540
  $form: null,
472
541
  allowSave: true,
@@ -552,9 +621,14 @@ export default {
552
621
  const [rulesRes, sysRes, clsRes, tasksRes] = await Promise.all([this.$item.fetch('agent_rules_list'), this.$item.fetch('agent_system_get').catch(() => null), this.$item.fetch('agent_available_classes').catch(() => null), this.$item.fetch('agent_tasks_list').catch(() => null)]);
553
622
  this.triggers = Array.isArray(rulesRes?.triggers) ? rulesRes.triggers : [];
554
623
  this.schedules = Array.isArray(rulesRes?.schedules) ? rulesRes.schedules : [];
624
+ this.availableModels = Array.isArray(rulesRes?.availableModels) ? rulesRes.availableModels : [];
555
625
  if (rulesRes?.proactivity) this.proactivity = {
556
626
  ...this.proactivity,
557
- ...rulesRes.proactivity
627
+ ...rulesRes.proactivity,
628
+ audit: {
629
+ ...(this.proactivity?.audit || {}),
630
+ ...(rulesRes.proactivity.audit || {})
631
+ }
558
632
  };
559
633
  if (sysRes) {
560
634
  this.systemText = String(sysRes.text || '');
@@ -589,12 +663,67 @@ export default {
589
663
  }));
590
664
  if (res?.proactivity) this.proactivity = {
591
665
  ...this.proactivity,
592
- ...res.proactivity
666
+ ...res.proactivity,
667
+ audit: {
668
+ ...(this.proactivity?.audit || {}),
669
+ ...(res.proactivity.audit || {})
670
+ }
593
671
  };
594
672
  } catch (e) {
595
673
  this.error = String(e?.message || e);
596
674
  }
597
675
  },
676
+ async saveAuditSettings(patch) {
677
+ if (!this.$item?.fetch) return;
678
+ this.error = '';
679
+ try {
680
+ const nextAudit = {
681
+ ...(this.proactivity?.audit || {}),
682
+ ...patch
683
+ };
684
+ const res = await this.$item.fetch('agent_proactivity_save', {}, JSON.stringify({
685
+ audit: nextAudit
686
+ }));
687
+ if (res?.proactivity) this.proactivity = {
688
+ ...this.proactivity,
689
+ ...res.proactivity,
690
+ audit: {
691
+ ...(this.proactivity?.audit || {}),
692
+ ...(res.proactivity.audit || {})
693
+ }
694
+ };
695
+ } catch (e) {
696
+ this.error = String(e?.message || e);
697
+ }
698
+ },
699
+ async runAuditNow() {
700
+ if (!this.$item?.fetch || this.auditRunning) return;
701
+ this.error = '';
702
+ this.auditRunning = true;
703
+ this.auditResultText = 'Выполняется аудит узла…';
704
+ try {
705
+ const res = await this.$item.fetch('agent_audit_run', {}, JSON.stringify({}));
706
+ if (res?.ok) {
707
+ this.auditResultText = res.quiet
708
+ ? 'Аудит завершён: проблем и новых предложений не выявлено.'
709
+ : 'Аудит завершён: найдены замечания/идеи (отправлены в чат BOSS).';
710
+ } else {
711
+ this.auditResultText = res?.error ? 'Ошибка аудита: ' + res.error : 'Аудит пропущен.';
712
+ }
713
+ await this.reload();
714
+ } catch (e) {
715
+ this.auditResultText = '';
716
+ this.error = String(e?.message || e);
717
+ } finally {
718
+ this.auditRunning = false;
719
+ }
720
+ },
721
+ async openAuditTask() {
722
+ const p = this.auditLastTask;
723
+ if (!p) return;
724
+ const item = await WORK.get_item(p).catch(() => null);
725
+ if (item && typeof window.top?.execute === 'function') window.top.execute(item);
726
+ },
598
727
  async saveSystemPrompt() {
599
728
  if (!this.$item?.fetch) return;
600
729
  this.error = '';
@@ -93,7 +93,7 @@ function isDroppedRemoteSubject(info) {
93
93
  function isDroppedStructure(info) {
94
94
  if (!info) return false;
95
95
  if (isDroppedRemoteSubject(info)) return false;
96
- if (['$structure', '$project', '$server'].includes(info.type)) return true;
96
+ if (info.DATA?.isStructure || ['$structure', '$project', '$server'].includes(info.type)) return true;
97
97
  return /^\/(?:ORGANIZATIONS|PROJECTS)\/[^/]+(?:\/[^/]+)*$/.test(info.path || '') && !String(info.path || '').includes('/MODULES/');
98
98
  }
99
99
  function isDroppedNetworkNode(info) {
@@ -487,7 +487,7 @@ if (typeof ODA === 'function' && !customElements.get('staff-member-menu')) {
487
487
  const idUpper = String(it.id).toUpperCase();
488
488
  const isDomainGroup = (t === '$domain' || t === '$folder') && ['USERS', 'ORGANIZATIONS', 'PROJECTS'].includes(idUpper);
489
489
  const isUser = t === '$user' || /\/USERS\/[^/]+$/i.test(p);
490
- const isUnit = ['$project', '$structure'].includes(t);
490
+ const isUnit = Boolean(it.DATA?.isProject || it.DATA?.isDepartment || ['$project', '$structure'].includes(t));
491
491
  if (!isDomainGroup && !isUser && !isUnit) continue;
492
492
  const lbl = it.DATA?.label || it.label || it.id;
493
493
  const icon = it.DATA?.icon || it.icon || (isUser ? 'icons:person' : isDomainGroup ? idUpper === 'USERS' ? 'social:people' : idUpper === 'PROJECTS' ? 'odant:project' : 'odant:base' : 'odant:structure');
@@ -148,6 +148,7 @@ export default {
148
148
  `,
149
149
  loaded: false,
150
150
  get kindLabel() {
151
+ if (this.$item?.DATA?.isDepartment) return 'Подразделение';
151
152
  return {
152
153
  '$project': 'Организация',
153
154
  '$structure': 'Подразделение',
@@ -166,7 +167,7 @@ export default {
166
167
  /** Дочерние узлы структуры (кроме кабинетов и данных). */
167
168
  get structureChildren() {
168
169
  if (!this.$item) return [];
169
- return Promise.resolve(this.$item.items).then(items => (items || []).filter(i => i instanceof CORE.$class && ['$structure', '$project'].includes(i.type))).catch(() => []);
170
+ return Promise.resolve(this.$item.items).then(items => (items || []).filter(i => i instanceof CORE.$class && (i.DATA?.isDepartment || i.DATA?.isProject || ['$structure', '$project'].includes(i.type)))).catch(() => []);
170
171
  },
171
172
  get units() {
172
173
  return this.structureChildren;
@@ -21,9 +21,9 @@
21
21
  2. **Установка.** Модуль ставится в структуру и работает для неё и всех структур ниже. Копия ниже продолжает копию выше и меняет только своё.
22
22
  3. **Владение.** Агент, роли, навыки и память есть только у структуры. Модуль поставляет классы данных, инструменты, подключения и модели. Класс данных хранит объекты в базе ближайшего проекта.
23
23
 
24
- - **Дерево и типы:** всё — папка или файл единого дерева; адрес узла — его путь. Папка с метапапкой `$тип` — класс: `class.js` (свойства), `readme.md` (контракт), `handlers/`. Ветки типов: `$structure` (кто действует: `$server`, `$project`, `$structure`, `$user`), `$module` (что установлено, в т. ч. `$mcp` и `$provider` с моделями `$ai`), `$data` (где хранятся объекты); `$class` абстрактен. `/X/~/…` отдаёт собранное по слоям: `/X/~/class.js`, `/X/~/readme.md`, `/X/~/handlers/…`.
24
+ - **Дерево и типы:** всё — папка или файл единого дерева; адрес узла — его путь. Папка с метапапкой `$тип` — класс: `class.js` (свойства), `readme.md` (контракт), `handlers/`. Ветки типов: `$structure` (абстрактный базовый тип; кто действует: `$server`, `$project`, `$department`, `$user`), `$module` (что установлено, в т. ч. `$mcp` и `$provider` с моделями `$ai`), `$data` (где хранятся объекты); `$class` абстрактен. `/X/~/…` отдаёт собранное по слоям: `/X/~/class.js`, `/X/~/readme.md`, `/X/~/handlers/…`.
25
25
  - **Ссылки:** только `ancestor` (узел продолжает другой) и `types` (примеси) в `class.js`; из пути ничего не вычисляется.
26
- - **Роли:** встроенная одна — `BOSS` (единственный владелец узла и поддерева на `$server`, `$project` и `$structure`, наследуется вниз). Остальные — записи `#security.ROLES` только подразделений `$structure` (`USERS`, права `LINKS`, маркер `external`), а не дочерние классы.
26
+ - **Роли:** встроенная одна — `BOSS` (единственный владелец узла и поддерева на `$server`, `$project` и `$department`, наследуется вниз). Остальные — записи `#security.ROLES` только подразделений `$department` (`USERS`, права `LINKS`, маркер `external`), а не дочерние классы.
27
27
  - **Учёт:** `$catalog` (листья хранят объекты, группы агрегируют), `$virtual` (`turnover`/`balance` + `OVERLAY`), `$struct` (`table: true` — таблица), `$operation` — двойная запись (Дебет + Кредит в `$account` + `logs`); проведённое исправляется только сторно; поля справочника-аналитики — субаналитики.
28
28
  - **Ядро и дерево:** ядро (`sources/`, `oda/`, `run.mjs`, `#system/`) меняется только по явной задаче доработки движка через `developer`-контур (тесты, отложенный перезапуск). Остальное — дерево, включая системный типизатор `/$server/$folder`; оно меняется штатно, без git. Правки типизатора и модулей уровня WORK — только извне проектов, с подтверждением, проверкой последствий и сбросом кэша.
29
29
  - **Арены инструментов:** дерево — WORK-инструментами (`ls/read/find/write/edit/delete`, `create_class/update_class/move_class/delete_class`), файлы ОС вне WORK — `os_*`; `shell` не служит обходом WORK-ограничений.
@@ -111,6 +111,8 @@ export default {
111
111
  },
112
112
  inForm: false,
113
113
  closable: false,
114
+ /** Узел, в метапапке которого лежит файл .task (точка работы задачи). */
115
+ ownerPoint: null,
114
116
  /** Внешний вид персонажа (ai/config.js dot); грузится один раз. */
115
117
  look: null,
116
118
  __microchatShell: true,
@@ -160,6 +162,11 @@ export default {
160
162
  };
161
163
  for (const [k, fn] of Object.entries(this._h)) n.listen(k, fn);
162
164
  this._reload();
165
+ this.ownerPoint = null;
166
+ Promise.resolve(n.$class).catch(() => null).then(async pt => {
167
+ if (!pt) pt = await Promise.resolve(n.$owner).catch(() => null);
168
+ if (this._bound === n && pt) this.ownerPoint = pt;
169
+ });
163
170
  n.fetch('dot_look').then(l => {
164
171
  if (this._bound === n && l) this.look = l;
165
172
  }).catch(() => {});
@@ -9,9 +9,7 @@
9
9
  */
10
10
  import { extOf, fileItemOf, fileUrl, copyText, findShell, fmtTime, linkifyWork, workHref, cleanWorkFilePath } from './util.js';
11
11
  import { fmtNum, fmtDate } from './docs.js';
12
- import '/$server/$folder/lib/dot/dot.js';
13
12
  import '/$server/$folder/lib/chat-item/chat-item.js';
14
- import { dotStateOfTask } from '/$server/$folder/lib/dot/dot-math.js';
15
13
 
16
14
  let snapshotName;
17
15
  try {
@@ -54,44 +52,41 @@ const STATUS = {
54
52
  };
55
53
 
56
54
  ODA({ is: 'microchat-header',
57
- imports: 'oda//button, oda//icon, ~/lib//prompt-bar',
55
+ imports: 'oda//button, oda//icon, ~/lib//prompt-bar, ~/lib//node-explorer',
58
56
  template: /*html*/`
59
57
  <style>
60
58
  :host { @apply --horizontal; align-items: center; gap: 8px; min-width: 0; box-sizing: border-box; }
61
- :host(:not([inline])) { padding: 6px 10px 6px 16px; border-bottom: 1px solid var(--subtle-border); min-height: 44px; }
62
- :host([inline]) { padding: 0 6px; max-width: 45vw; }
63
- :host([inline]) .title { font-weight: 500; font-size: small; opacity: .9; }
59
+ :host(:not([inline])) { padding: 4px 8px; min-height: 44px; @apply --accent-invert; box-shadow: 0 2px 6px var(--shadow-color); }
60
+ :host([inline]) { padding: 0 4px; }
61
+ :host(:not([inline])) .title { text-align: center; font-weight: 600; font-size: 14px; padding: 0 8px; }
64
62
  .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
65
- .chip { @apply --chip; }
66
- .chip[running] { background: var(--accent-soft); border-color: transparent; }
67
- .chip[waiting] { background: var(--warning-soft); border-color: transparent; }
68
- .chip[bad] { background: var(--error-soft); border-color: transparent; }
69
- :host([inline]) .chip { background: var(--content-background); color: var(--content-color); }
63
+ .owner-crumb { min-width: 0; max-width: 34vw; flex-shrink: 1; }
64
+ .chip { @apply --chip; background: var(--content-background); color: var(--content-color); }
65
+ .chip[running] { background: color-mix(in oklch, var(--accent-color) 18%, var(--content-background)); border-color: transparent; }
66
+ .chip[waiting] { background: var(--warning-soft, #fef3c7); color: var(--warning-color, #92400e); border-color: transparent; }
67
+ .chip[bad] { background: var(--error-soft, #fee2e2); color: var(--error-color, #991b1b); border-color: transparent; }
70
68
  .dialog-btn {
71
69
  width: 30px; height: 30px; border-radius: 50%; padding: 0; border: none;
72
70
  background: transparent; color: inherit; cursor: pointer;
73
- display: flex; align-items: center; justify-content: center; opacity: .8;
71
+ display: flex; align-items: center; justify-content: center; opacity: .85;
74
72
  }
75
- .dialog-btn:hover { background: var(--accent-soft); opacity: 1; }
73
+ .dialog-btn:hover, .dialog-btn[on] { background: rgba(255,255,255,.2); opacity: 1; }
76
74
  .dialog-btn:focus-visible { @apply --focus-ring; }
77
- .dialog-btn[on] { background: var(--accent-soft); color: var(--accent-color); opacity: 1; }
78
- :host([inline]) .dialog-btn:hover, :host([inline]) .dialog-btn[on] { background: rgba(255,255,255,.2); color: inherit; }
79
75
  .dialog-btn work-voice-bars { width: 18px; height: 18px; }
80
76
  .ring {
81
77
  position: relative; width: 30px; height: 30px; border: none; padding: 0; border-radius: 50%;
82
78
  background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; color: inherit;
83
79
  }
84
- .ring:hover, .ring[on] { background: var(--accent-soft); }
85
- :host([inline]) .ring:hover, :host([inline]) .ring[on] { background: rgba(255,255,255,.2); }
80
+ .ring:hover, .ring[on] { background: rgba(255,255,255,.2); }
86
81
  .ring svg { position: absolute; inset: 3px; transform: rotate(-90deg); }
87
82
  .ring span { font-size: 8px; font-weight: 700; }
88
83
  .dot { position: absolute; top: 2px; right: 2px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent-color); }
89
84
  oda-button { border-radius: var(--radius-s); padding: 2px; }
90
- oda-button[on] { background: var(--accent-soft); }
91
- :host([inline]) oda-button[on] { background: rgba(255,255,255,.2); }
85
+ oda-button[on] { background: rgba(255,255,255,.2); }
86
+ .close-btn { border-radius: 50% !important; flex-shrink: 0; }
92
87
  </style>
93
- <work-dot no-flex :size="inline ? 22 : 26" :state="dotState" :eyes="look.eyes || 'round'" :accessory="look.accessory || 'none'" :color="look.color || ''" :title="statusMeta.label"></work-dot>
94
- <span class="title" flex :title="title">{{title}}</span>
88
+ <item-node-explorer class="owner-crumb" no-flex ~if="!inline && ownerPoint" :$item="ownerPoint"></item-node-explorer>
89
+ <span class="title" ~if="!inline" flex :title="title">{{title}}</span>
95
90
  <span class="chip" no-flex :running="status === 'running'" :waiting="status === 'waiting'" :bad="status === 'error' || status === 'limit' || status === 'needs_review'">
96
91
  <oda-icon :icon="statusMeta.icon" :icon-size="12"></oda-icon>{{statusMeta.label}}
97
92
  </span>
@@ -101,19 +96,22 @@ ODA({ is: 'microchat-header',
101
96
  <oda-button no-flex ~if="canEnablePush" icon="carbon:notification" :icon-size="17" title="Включить уведомления задач" @tap="enablePush"></oda-button>
102
97
  <button class="ring" no-flex :on="dockOpen" :title="ringTitle" @tap="toggleDock">
103
98
  <svg viewBox="0 0 24 24" width="24" height="24">
104
- <circle cx="12" cy="12" r="10" fill="none" stroke="currentColor" stroke-opacity=".18" stroke-width="2.5"></circle>
105
- <circle cx="12" cy="12" r="10" fill="none" stroke="var(--accent-color)" stroke-width="2.5" stroke-linecap="round"
99
+ <circle cx="12" cy="12" r="10" fill="none" stroke="currentColor" stroke-opacity=".28" stroke-width="2.5"></circle>
100
+ <circle cx="12" cy="12" r="10" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"
106
101
  :stroke-dasharray="dash"></circle>
107
102
  </svg>
108
103
  <span>{{pct}}</span>
109
104
  <i class="dot" ~if="fresh"></i>
110
105
  </button>
111
- <oda-button no-flex ~if="closable" icon="carbon:close" :icon-size="18" title="Закрыть" @tap="close"></oda-button>
106
+ <oda-button class="close-btn" no-flex ~if="closable" error content-invert icon="icons:close" :icon-size="18" title="Закрыть" @tap="close"></oda-button>
112
107
  `,
113
108
  shell: null,
114
109
  inline: { $attr: true, $def: false },
110
+ get ownerPoint() { return this.shell?.ownerPoint || null; },
115
111
  attached() {
116
112
  this.shell ??= findShell(this);
113
+ if (!this.inline)
114
+ this.setAttribute('accent-invert', '');
117
115
  if (this.shell?.voiceOn && this.shell?._voice)
118
116
  this.bindVoice(this.shell._voice);
119
117
  },
@@ -147,13 +145,6 @@ ODA({ is: 'microchat-header',
147
145
  },
148
146
  get title() { return this.shell?.title || 'Задача'; },
149
147
  get status() { return this.shell?.status || 'idle'; },
150
- get look() { return this.shell?.look || {}; },
151
- /** Персонаж в шапке: статус задачи одним взглядом (работает, ждёт вас, ошибка). */
152
- get dotState() {
153
- if (this.shell?.voiceOn && this.shell?._voice?.state === 'speaking')
154
- return 'speaking';
155
- return dotStateOfTask(this.status);
156
- },
157
148
  get statusMeta() {
158
149
  if (this.status === 'idle' && this.shell?.data && !this.shell.items?.length)
159
150
  return { label: 'Новая', icon: 'carbon:add-alt' };
@@ -677,6 +677,16 @@ ODA({is: 'work-form',
677
677
  max-width: 100%;
678
678
  flex-shrink: 1;
679
679
  }
680
+ .task-form-title {
681
+ min-width: 0;
682
+ text-align: center;
683
+ font-weight: 600;
684
+ font-size: 14px;
685
+ overflow: hidden;
686
+ text-overflow: ellipsis;
687
+ white-space: nowrap;
688
+ padding: 0 8px;
689
+ }
680
690
  .mobile-back-spacer {
681
691
  width: 36px;
682
692
  flex-shrink: 0;
@@ -750,14 +760,15 @@ ODA({is: 'work-form',
750
760
  :style="'padding: 4px; gap: 8px; min-width: 0; align-items: ' + (ODA.states?.mobileMode ? 'flex-start' : 'center') + ';'">
751
761
  <div center flex horizontal class="form-header-inner" style="min-width: 0; flex-wrap: wrap; gap: 8px; margin: 4px; align-items: center;">
752
762
  <div ~if="ODA.states?.mobileMode && !isEmbeddedNoTree" class="mobile-back-spacer" style="width: 36px; flex-shrink: 0;"></div>
753
- <item-node-explorer no-flex :$item="rootItem"></item-node-explorer>
754
- <div flex></div>
763
+ <item-node-explorer no-flex :$item="isTaskForm ? taskHeaderPoint : rootItem"></item-node-explorer>
764
+ <div ~if="isTaskForm" class="task-form-title" flex :title="taskHeaderTitle">{{taskHeaderTitle}}</div>
765
+ <div ~if="!isTaskForm" flex></div>
755
766
  <oda-button ~if="showConsultantBtn" id="consultantBtn" shadow icon="bootstrap:robot" @tap="askConsultant" title="Спросить ИИ-консультанта по текущей форме" :icon-size info class="consultant-btn"
756
767
  :style="'border-radius: 50%; flex-shrink: 0; margin-right: ' + (ODA.states?.mobileMode ? '0px' : '4px') + ';'"></oda-button>
757
- <oda-button shadow icon="communication:call" @tap="call" title="Call..." :icon-size success class="call-btn"
768
+ <oda-button ~if="!isTaskForm" shadow icon="communication:call" @tap="call" title="Call..." :icon-size success class="call-btn"
758
769
  :style="'border-radius: 50%; flex-shrink: 0; margin-right: ' + (ODA.states?.mobileMode ? '0px' : '24px') + ';'"></oda-button>
759
770
  <slot name="top-panel"></slot>
760
- <div class="view-selector" no-flex horizontal
771
+ <div ~if="!isTaskForm || visibleFormViews.length > 1 || allowSave" class="view-selector" no-flex horizontal
761
772
  :style="'flex-wrap: wrap; max-width: 100%; min-width: 0; overflow: visible; justify-content: ' + (ODA.states?.mobileMode ? 'flex-start' : 'flex-end') + ';'">
762
773
  <div class="flow" no-flex horizontal style="flex-wrap: wrap; gap: 8px; border-radius: 4px; align-items: center; max-width: 100%; min-width: 0;">
763
774
 
@@ -1334,6 +1345,37 @@ ODA({is: 'work-form',
1334
1345
  * автоматически через Reactor, без ручных вызовов и render().
1335
1346
  */
1336
1347
  activeItem: null,
1348
+ _taskOwnerPoint: null,
1349
+ get isTaskForm() {
1350
+ const it = this.currentItem;
1351
+ if (!it)
1352
+ return false;
1353
+ const ext = String(it.ext || '').toLowerCase();
1354
+ if (ext === 'task')
1355
+ return true;
1356
+ return String(it.id || it.path || '').toLowerCase().endsWith('.task');
1357
+ },
1358
+ get taskHeaderPoint() {
1359
+ const cur = this.currentItem;
1360
+ if (this.view_control?.ownerPoint)
1361
+ return this.view_control.ownerPoint;
1362
+ if (this._taskOwnerPoint)
1363
+ return this._taskOwnerPoint;
1364
+ if (cur && !this._loadingTaskOwnerFor?.has?.(cur)) {
1365
+ this._loadingTaskOwnerFor ??= new WeakSet();
1366
+ this._loadingTaskOwnerFor.add(cur);
1367
+ Promise.resolve(cur.$class).catch(() => null).then(async pt => {
1368
+ if (!pt)
1369
+ pt = await Promise.resolve(cur.$owner).catch(() => null);
1370
+ if (this.currentItem === cur && pt)
1371
+ this._taskOwnerPoint = pt;
1372
+ });
1373
+ }
1374
+ return this.rootItem;
1375
+ },
1376
+ get taskHeaderTitle() {
1377
+ return this.view_control?.title || this.rootItemLabel || 'Задача';
1378
+ },
1337
1379
  get rootItem() {
1338
1380
  return this._rootItem || this.$item;
1339
1381
  },
@@ -1519,7 +1561,7 @@ ODA({is: 'work-form',
1519
1561
  return typeof location !== 'undefined' && new URLSearchParams(location.search).get('noTree') === '1';
1520
1562
  },
1521
1563
  get showConsultantBtn() {
1522
- if (!this.currentItem)
1564
+ if (!this.currentItem || this.isTaskForm)
1523
1565
  return false;
1524
1566
  const views = Array.isArray(this.formViews) ? this.formViews : [];
1525
1567
  return !views.some(v => v?.id === 'chat');
@@ -111,7 +111,7 @@ ODA({is: 'chat-item',
111
111
  align-self: center;
112
112
  }
113
113
  </style>
114
- <div vertical ~if="!compact && !hideAvatar && !expanded && !isTask" ~style="{padding: '0px 8px', order: (!isTask && !isSender) ? 2 : 0}">
114
+ <div vertical ~if="!compact && !hideAvatar && !expanded && !isTask && hasSenderAvatar" ~style="{padding: '0px 8px', order: (!isTask && !isSender) ? 2 : 0}">
115
115
  <div flex></div>
116
116
  <item-icon class="sender" icon-size="24" :$item="sender" :icon="isAgentSender ? 'bootstrap:robot' : ''" :title="isAgentSender ? agentSenderTitle : ''" :default="isAgentSender ? 'bootstrap:robot' : ''"></item-icon>
117
117
  </div>
@@ -233,6 +233,8 @@ ODA({is: 'chat-item',
233
233
  get isAgentSender() {
234
234
  if (this.log?.sender === '$twin' || this.log?.chatMessage?.sender === '$twin')
235
235
  return true;
236
+ if (this.log?.sender === 'WORK')
237
+ return true;
236
238
  const act = String(this.log?.actor || '');
237
239
  if (act === 'AI' || act.startsWith('/MODULES/Модели/'))
238
240
  return true;
@@ -245,6 +247,8 @@ ODA({is: 'chat-item',
245
247
  const nl = this.log?.chatMessage?.nodeLabel;
246
248
  return nl ? `Цифровой двойник «${nl}»` : 'Цифровой двойник узла';
247
249
  }
250
+ if (this.log?.sender === 'WORK')
251
+ return 'Система WORK';
248
252
  const act = String(this.log?.actor || '');
249
253
  if (this.log?.actorLabel)
250
254
  return String(this.log.actorLabel);
@@ -875,21 +879,29 @@ ODA({is: 'chat-item',
875
879
  this._revealIfReady();
876
880
  }
877
881
  },
882
+ _hasResolvedSender: false,
883
+ get hasSenderAvatar() {
884
+ return Boolean(this.isAgentSender || this._hasResolvedSender);
885
+ },
878
886
  get sender() {
879
887
  return Promise.resolve(this.itemBody).then(async body => {
880
888
  if (this.isAgentSender) {
889
+ this._hasResolvedSender = false;
881
890
  if (!this.senderIsReady)
882
891
  this._markSenderReady();
883
892
  return null;
884
893
  }
885
894
  if (!body?.sender) {
895
+ this._hasResolvedSender = false;
886
896
  if (!this.senderIsReady)
887
897
  this._markSenderReady();
888
898
  return null;
889
899
  }
890
900
  let users = await WORK.users;
901
+ const found = users.find(u => u.id === body.sender) || null;
902
+ this._hasResolvedSender = Boolean(found);
891
903
  this.senderId = body.sender;
892
- return users.find(u => u.id === body.sender) || null;
904
+ return found;
893
905
  })
894
906
  },
895
907
  get hideAvatar() {
@@ -672,7 +672,7 @@ ODA({
672
672
  prompt: `Покажи схему операции «${lbl}» (${ctx.path}), её проводки и последние зарегистрированные документы.`,
673
673
  };
674
674
  }
675
- if (t === '$structure' || t === '$project' || t === '$server') {
675
+ if ((ctx.DATA?.isStructure && !ctx.DATA?.isUser && t !== '$user') || t === '$structure' || t === '$project' || t === '$server') {
676
676
  return {
677
677
  icon: 'icons:supervisor-account',
678
678
  label: `Проверить роли BOSS, рабочие места и ленту «${lbl}»`,
@@ -107,6 +107,8 @@ export default {
107
107
  if (typeof window !== 'undefined' && window !== window.top)
108
108
  return [];
109
109
  const user = WORK.USER;
110
+ const userIcon = typeof user?.icon === 'string' && user.icon ? user.icon : (this._resolvedUserIcon || 'icons:account-circle');
111
+ const userColor = typeof user?.iconColor === 'string' && user.iconColor ? user.iconColor : 'transparent';
110
112
  const buttons = [];
111
113
  if (top.RTCCaller?.current_call) {
112
114
  buttons.push({
@@ -135,10 +137,19 @@ export default {
135
137
  }
136
138
  buttons.push({
137
139
  round: true,
138
- icon: user?.icon || 'icons:account-circle',
140
+ icon: userIcon,
139
141
  default: 'icons:account-circle',
140
- style: `color: white; fill: white; background:${user?.iconColor || 'transparent'}`,
141
- click: () => {
142
+ style: `color: white; fill: white; background:${userColor}`,
143
+ click: async () => {
144
+ if (WORK?.uid) {
145
+ const userNode = WORK.USER || await WORK.get_$user?.(WORK.uid).catch(() => null);
146
+ if (userNode) {
147
+ this._autoOpenedLogin = false;
148
+ this.visibleMode = 'main';
149
+ window.execute?.(userNode, { view: 'system/profile' });
150
+ return;
151
+ }
152
+ }
142
153
  this.showUser = true;
143
154
  },
144
155
  errorInvert: !WORK.uid,
@@ -156,19 +167,25 @@ export default {
156
167
  });
157
168
  return buttons;
158
169
  },
159
- /** Пересобрать кнопки (после входа/выхода и при старте/завершении звонка). */
170
+ _leftButtonsSig(list) {
171
+ return (list || []).map(b => `${b.icon || ''}|${b.title || ''}|${Boolean(b.rainbow)}|${Boolean(b.errorInvert)}|${b.style || ''}`).join(';;');
172
+ },
173
+ /** Пересобрать кнопки (только при реальном изменении состава/иконки, чтобы левая панель не мигала). */
160
174
  _refreshLeftButtons() {
161
- this.left_buttons = this._buildLeftButtons();
175
+ const next = this._buildLeftButtons();
176
+ const sig = this._leftButtonsSig(next);
177
+ if (sig !== this._lastLeftButtonsSig) {
178
+ this._lastLeftButtonsSig = sig;
179
+ this.left_buttons = next;
180
+ }
162
181
  const icon = WORK.USER?.icon;
163
- if (icon) {
182
+ if (icon && typeof icon.then === 'function') {
164
183
  Promise.resolve(icon).then(res => {
165
- if (!res)
184
+ const str = typeof res === 'string' && res ? res : '';
185
+ if (!str || str === this._resolvedUserIcon)
166
186
  return;
167
- const btn = this.left_buttons?.find?.(b => b.icon === 'icons:account-circle' || b.default === 'icons:account-circle');
168
- if (btn && btn.icon !== res) {
169
- btn.icon = res;
170
- this.left_buttons = [...this.left_buttons];
171
- }
187
+ this._resolvedUserIcon = str;
188
+ this._refreshLeftButtons();
172
189
  }).catch(() => { /* ignore */ });
173
190
  }
174
191
  return this.left_buttons;
@@ -717,6 +734,7 @@ export default {
717
734
  }
718
735
  }
719
736
  else {
737
+ this._autoOpenedLogin = true;
720
738
  this.showUser = true;
721
739
  }
722
740
  }
@@ -726,6 +744,7 @@ export default {
726
744
  this.async(async ()=>{
727
745
  await this._handleInviteQuery();
728
746
  if(!WORK.uid && !WORK.DEV_MODE){
747
+ this._autoOpenedLogin = true;
729
748
  this.visibleMode = 'user';
730
749
  if(this.left_drawer)
731
750
  this.left_drawer.closed = true;
@@ -762,7 +781,14 @@ export default {
762
781
  this._supportBadgeTimer = setInterval(() => this._refreshSupportBadge(), 60_000);
763
782
  }
764
783
  WORK.authEvents?.addEventListener('auth', () => {
784
+ this._resolvedUserIcon = '';
765
785
  this.user_icon = undefined;
786
+ if (WORK.uid && this._autoOpenedLogin && this.visibleMode === 'user') {
787
+ this._autoOpenedLogin = false;
788
+ this.visibleMode = 'main';
789
+ if (this.left_drawer)
790
+ this.left_drawer.closed = false;
791
+ }
766
792
  this._refreshLeftButtons();
767
793
  this._initTopLicenseBanner();
768
794
  this._refreshSupportBadge();
@@ -56,7 +56,7 @@ export default {
56
56
  if (!it || this.isUser || isLinkNode(it) || ('isPlace' in Object(it) && it.isPlace))
57
57
  return null;
58
58
  const t = it.type;
59
- if (t !== '$project' && t !== '$structure' && t !== '$server')
59
+ if ((!it.DATA?.isStructure || it.DATA?.isUser || t === '$user') && t !== '$project' && t !== '$structure' && t !== '$server')
60
60
  return null;
61
61
  it.__version;
62
62
  const bossIds = it.DATA?.roleIds?.BOSS;