odant-work 1.0.101 → 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 (63) 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 +2 -0
  14. package/$server/$folder/$class/$structure/ai/system.md +1 -1
  15. package/$server/$folder/$class/$structure/class.js +4 -2
  16. package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +67 -20
  17. package/$server/$folder/$class/$structure/handlers/pages/form/system/agent/$handler/class.js +132 -3
  18. package/$server/$folder/$class/$structure/handlers/pages/form/system/staff/$handler/class.js +2 -2
  19. package/$server/$folder/$class/$structure/handlers/pages/site/$handler/class.js +2 -1
  20. package/$server/$folder/$class/ai/system.md +2 -2
  21. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/class.js +7 -0
  22. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/dock.js +22 -31
  23. package/$server/$folder/handlers/pages/form/$handler/class.js +47 -5
  24. package/$server/$folder/lib/chat-item/chat-item.js +14 -2
  25. package/$server/$folder/lib/consultant/consultant.js +1 -1
  26. package/$server/$folder/lib/explorer/explorer.js +20 -11
  27. package/$server/$folder/lib/icon/icon.js +1 -1
  28. package/$server/$folder/lib/node/node.js +3 -3
  29. package/$server/$folder/lib/site-loc/site-loc.js +8 -3
  30. package/$server/$folder/lib/tree/tree.js +6 -6
  31. package/AGENTS.md +3 -3
  32. package/package.json +1 -1
  33. package/scripts/import-bis.mjs +5 -5
  34. package/scripts/import-delovaya.mjs +5 -5
  35. package/sources/client/class.js +1 -1
  36. package/sources/client.js +19 -6
  37. package/sources/data/api.js +1 -1
  38. package/sources/data/classes.js +2 -1
  39. package/sources/data/schema.js +2 -0
  40. package/sources/host/auth-methods.js +1 -1
  41. package/sources/modules/agent/index.js +22 -6
  42. package/sources/modules/agent/node-rules.js +353 -9
  43. package/sources/modules/agent/scheduler.js +7 -0
  44. package/sources/modules/agent/scope.js +8 -6
  45. package/sources/modules/agent/tools/work/access.js +1 -1
  46. package/sources/modules/agent/tools/work/classes.js +1 -1
  47. package/sources/modules/agent/triggers.js +1 -1
  48. package/sources/modules/agent/twin-bus.js +2 -1
  49. package/sources/modules/notify/index.js +5 -2
  50. package/sources/modules/trainer/local-engine.js +3 -1
  51. package/sources/server/access/gateway.js +4 -3
  52. package/sources/server/access/links.js +9 -6
  53. package/sources/server/chat-threads.js +1 -1
  54. package/sources/server/class/base-template.js +3 -2
  55. package/sources/server/class/feed.js +30 -0
  56. package/sources/server/class/scaffold.js +137 -0
  57. package/sources/server/class/search.js +2 -2
  58. package/sources/server/class/security.js +1 -1
  59. package/sources/server/class.js +5 -3
  60. package/sources/server/folder.js +10 -6
  61. package/sources/server/logs.js +14 -0
  62. package/sources/server/node.js +1 -1
  63. package/sources/work.js +7 -0
@@ -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,9 +137,9 @@ 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'}`,
142
+ style: `color: white; fill: white; background:${userColor}`,
141
143
  click: async () => {
142
144
  if (WORK?.uid) {
143
145
  const userNode = WORK.USER || await WORK.get_$user?.(WORK.uid).catch(() => null);
@@ -165,19 +167,25 @@ export default {
165
167
  });
166
168
  return buttons;
167
169
  },
168
- /** Пересобрать кнопки (после входа/выхода и при старте/завершении звонка). */
170
+ _leftButtonsSig(list) {
171
+ return (list || []).map(b => `${b.icon || ''}|${b.title || ''}|${Boolean(b.rainbow)}|${Boolean(b.errorInvert)}|${b.style || ''}`).join(';;');
172
+ },
173
+ /** Пересобрать кнопки (только при реальном изменении состава/иконки, чтобы левая панель не мигала). */
169
174
  _refreshLeftButtons() {
170
- 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
+ }
171
181
  const icon = WORK.USER?.icon;
172
- if (icon) {
182
+ if (icon && typeof icon.then === 'function') {
173
183
  Promise.resolve(icon).then(res => {
174
- if (!res)
184
+ const str = typeof res === 'string' && res ? res : '';
185
+ if (!str || str === this._resolvedUserIcon)
175
186
  return;
176
- const btn = this.left_buttons?.find?.(b => b.icon === 'icons:account-circle' || b.default === 'icons:account-circle');
177
- if (btn && btn.icon !== res) {
178
- btn.icon = res;
179
- this.left_buttons = [...this.left_buttons];
180
- }
187
+ this._resolvedUserIcon = str;
188
+ this._refreshLeftButtons();
181
189
  }).catch(() => { /* ignore */ });
182
190
  }
183
191
  return this.left_buttons;
@@ -773,6 +781,7 @@ export default {
773
781
  this._supportBadgeTimer = setInterval(() => this._refreshSupportBadge(), 60_000);
774
782
  }
775
783
  WORK.authEvents?.addEventListener('auth', () => {
784
+ this._resolvedUserIcon = '';
776
785
  this.user_icon = undefined;
777
786
  if (WORK.uid && this._autoOpenedLogin && this.visibleMode === 'user') {
778
787
  this._autoOpenedLogin = false;
@@ -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;
@@ -284,7 +284,7 @@ export default {
284
284
  if (!it || ('isPlace' in Object(it) && it.isPlace))
285
285
  return '';
286
286
  const t = it.type;
287
- if (t === '$project' || t === '$structure' || t === '$server' || t === '$domain')
287
+ if ((it.DATA?.isStructure && !it.DATA?.isUser && t !== '$user') || t === '$project' || t === '$structure' || t === '$server' || t === '$domain')
288
288
  return '';
289
289
  const c = isLinkNode(it) ? it.objectCount : it.DATA?.objectCount;
290
290
  return (typeof c === 'number' && c > 0) ? c.toLocaleString('ru-RU') : '';
@@ -357,7 +357,7 @@ export default {
357
357
  return false;
358
358
  const t = it.type;
359
359
  const isNetServer = t === '$node' && it.id !== 'NODES';
360
- return t === '$project' || t === '$structure' || t === '$server' || isNetServer || it.id === 'PROJECTS';
360
+ return (it.DATA?.isStructure && !it.DATA?.isUser && t !== '$user') || t === '$project' || t === '$structure' || t === '$server' || isNetServer || it.id === 'PROJECTS';
361
361
  },
362
362
  // пользователи в строке дерева не показываются (шум и запросы на каждую строку); свойство оставлено для совместимости биндов
363
363
  showUsers: false,
@@ -431,7 +431,7 @@ export default {
431
431
  return 24;
432
432
  const t = this.$item?.type;
433
433
  const isNetServer = t === '$node' && this.$item?.id !== 'NODES';
434
- if(this.isUser || t === '$user' || t === '$project' || t === '$structure' || t === '$server' || isNetServer)
434
+ if(this.isUser || this.$item?.DATA?.isStructure || t === '$user' || t === '$project' || t === '$structure' || t === '$server' || isNetServer)
435
435
  return 48;
436
436
  if(t === '$module' || t === '$provider' || t === '$mcp')
437
437
  return 32;
@@ -10,8 +10,13 @@ export const STRUCTURE_TYPES = Object.freeze(['$structure', '$project']);
10
10
  * @param {string} type Тип элемента ($project, $structure, …)
11
11
  * @returns {string}
12
12
  */
13
- export function structureKind(type) {
14
- switch (type) {
13
+ export function structureKind(typeOrItem) {
14
+ if (typeOrItem && typeof typeOrItem === 'object') {
15
+ if (typeOrItem.DATA?.isProject) return 'org';
16
+ if (typeOrItem.DATA?.isDepartment) return 'unit';
17
+ typeOrItem = typeOrItem.type;
18
+ }
19
+ switch (typeOrItem) {
15
20
  case '$project': return 'org';
16
21
  case '$structure': return 'unit';
17
22
  default: return '';
@@ -20,7 +25,7 @@ export function structureKind(type) {
20
25
 
21
26
  /** Узел оргструктуры (есть сайт, участвует в навигации). */
22
27
  export function isStructureNode(item) {
23
- return !!item && STRUCTURE_TYPES.includes(item.type);
28
+ return !!item && (STRUCTURE_TYPES.includes(item.type) || item.DATA?.isProject === true || item.DATA?.isDepartment === true);
24
29
  }
25
30
 
26
31
  function _encodeVal(v) {
@@ -53,8 +53,8 @@ function filterMainTreeItems(items, parent) {
53
53
  return items.filter(f => f && !f.DATA?.objects);
54
54
  if (isMainTreeLeaf(parent))
55
55
  return [];
56
- if (parent.type === '$project' || parent.type === '$structure')
57
- return items.filter(f => f && (f.type === '$structure' || f.type === '$project'));
56
+ if (parent.type === '$project' || parent.type === '$structure' || parent.DATA?.isProject || parent.DATA?.isDepartment)
57
+ return items.filter(f => f && (f.type === '$structure' || f.type === '$project' || f.DATA?.isDepartment || f.DATA?.isProject));
58
58
  if (parent.type === '$provider')
59
59
  return items.filter(f => f?.type === '$ai');
60
60
  return items.filter(f => f && !f.DATA?.objects);
@@ -76,7 +76,7 @@ export function knownHasItems(it, pdp = {}) {
76
76
  return false;
77
77
  if (it.DATA?.mainTree === true && typeof it.DATA?.hasItems === 'boolean')
78
78
  return it.DATA.hasItems;
79
- if (it.type === '$project' || it.type === '$structure')
79
+ if (it.type === '$project' || it.type === '$structure' || it.DATA?.isProject || it.DATA?.isDepartment)
80
80
  return undefined;
81
81
  }
82
82
  // __version — реактивная зависимость: после события changed флаг удаляется и пересчитывается по items
@@ -861,7 +861,7 @@ ODA({is: 'oda-tree-node',
861
861
  return false;
862
862
  const t = it.type;
863
863
  const isNetServer = t === '$node' && it.id !== 'NODES';
864
- return it instanceof CORE.$user || t === '$user' || t === '$project' || t === '$structure' || t === '$server' || isNetServer;
864
+ return it instanceof CORE.$user || it.DATA?.isStructure === true || t === '$user' || t === '$project' || t === '$structure' || t === '$server' || isNetServer;
865
865
  },
866
866
  get isMediumIconNode() {
867
867
  return this.isModule;
@@ -884,7 +884,7 @@ ODA({is: 'oda-tree-node',
884
884
  return false;
885
885
  const t = it.type;
886
886
  // $server (корень WORK) и $project — тоже наследники $structure: на них показываем BOSS.
887
- return t === '$project' || t === '$structure' || t === '$server';
887
+ return (it.DATA?.isStructure === true && !it.DATA?.isUser && t !== '$user') || t === '$project' || t === '$structure' || t === '$server';
888
888
  },
889
889
  get isModule() {
890
890
  const it = this.$item;
@@ -930,7 +930,7 @@ ODA({is: 'oda-tree-node',
930
930
  return false;
931
931
  this.$item.__version;
932
932
  const t = this.$item?.type;
933
- if (t !== '$structure' && t !== '$project' && t !== '$server')
933
+ if ((!this.$item?.DATA?.isStructure && t !== '$structure' && t !== '$project' && t !== '$server') || this.$item?.DATA?.isUser || t === '$user')
934
934
  return false;
935
935
  return !!this.$item?.DATA?.hasSecurity;
936
936
  },
package/AGENTS.md CHANGED
@@ -30,9 +30,9 @@
30
30
  2. **Установка.** Модуль ставится в структуру и работает для неё и всех структур ниже. Копия ниже продолжает копию выше и меняет только своё.
31
31
  3. **Владение.** Агент, роли, навыки и память есть только у структуры. Модуль поставляет классы данных, инструменты, подключения и модели. Класс данных хранит объекты в базе ближайшего проекта.
32
32
 
33
- - **Дерево и типы:** всё — папка или файл единого дерева; адрес узла — его путь. Папка с метапапкой `$тип` — класс: `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/…`.
33
+ - **Дерево и типы:** всё — папка или файл единого дерева; адрес узла — его путь. Папка с метапапкой `$тип` — класс: `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/…`.
34
34
  - **Ссылки:** только `ancestor` (узел продолжает другой) и `types` (примеси) в `class.js`; из пути ничего не вычисляется.
35
- - **Роли:** встроенная одна — `BOSS` (единственный владелец узла и поддерева на `$server`, `$project` и `$structure`, наследуется вниз). Остальные — записи `#security.ROLES` только подразделений `$structure` (`USERS`, права `LINKS`, маркер `external`), а не дочерние классы.
35
+ - **Роли:** встроенная одна — `BOSS` (единственный владелец узла и поддерева на `$server`, `$project` и `$department`, наследуется вниз). Остальные — записи `#security.ROLES` только подразделений `$department` (`USERS`, права `LINKS`, маркер `external`), а не дочерние классы.
36
36
  - **Учёт:** `$catalog` (листья хранят объекты, группы агрегируют), `$virtual` (`turnover`/`balance` + `OVERLAY`), `$struct` (`table: true` — таблица), `$operation` — двойная запись (Дебет + Кредит в `$account` + `logs`); проведённое исправляется только сторно; поля справочника-аналитики — субаналитики.
37
37
  - **Ядро и дерево:** ядро (`sources/`, `oda/`, `run.mjs`, `#system/`) меняется только по явной задаче доработки движка через `developer`-контур (тесты, отложенный перезапуск). Остальное — дерево, включая системный типизатор `/$server/$folder`; оно меняется штатно, без git. Правки типизатора и модулей уровня WORK — только извне проектов, с подтверждением, проверкой последствий и сбросом кэша.
38
38
  - **Арены инструментов:** дерево — WORK-инструментами (`ls/read/find/write/edit/delete`, `create_class/update_class/move_class/delete_class`), файлы ОС вне WORK — `os_*`; `shell` не служит обходом WORK-ограничений.
@@ -48,7 +48,7 @@
48
48
  ## Дополнительно для сессий разработки (OpenCode / репозиторий)
49
49
 
50
50
  1. Актуальность рабочей копии: ветка **`main`** (`git pull origin main`; при использовании SVN — `svn update`).
51
- 2. Демо-база организации (`PROJECTS/Маслоторг/$project/#system/work.db`): `node scripts/demo-seed.mjs`.
51
+ 2. Демо-база организации (`<Проект>/$project/#system/work.db`): `node scripts/demo-seed.mjs`.
52
52
  3. Документация: канон — **`docs/architecture.md`** (при расхождении он главнее кода и остальных документов; меняет его только владелец проекта). Справочно: **`docs/use-cases.md`**, **`docs/work-mcp.md`**, **`docs/autonomous-install-and-licensing.md`**, **`docs/halogen-provider.md`**, **`docs/chrome-extension.md`**, **`sources/data/progress.md`** (исторические спецификации — в `docs/archive/`).
53
53
  4. Протокол экономии токенов/кэша: основная модель **`Gemini 4 Argon`** (`opencode/gemini-4-argon`), не менять модель внутри длинной сессии, разведку делегировать субагенту `explore`, сжимать (`/compact`) на границах этапов. В начале сессии выдать короткий блок **«Рекомендация на шаг»**.
54
54
  5. Принцип единого UI: единая форма объектов — `form/objects` (и карточка `form/object` с `designMode`), выборщик класса — `item-class-picker`; `form/builder` удалён (модель данных меняется через ИИ-инструменты `create_class`/`update_class` и вкладку «Система → Реквизиты»).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "odant-work",
3
- "version": "1.0.101",
3
+ "version": "1.0.102",
4
4
  "description": "ODANT-WORK — платформа цифровой организации (встроенная система учёта, документооборот, управление процессами и приватный мультимодальный ИИ)",
5
5
  "type": "module",
6
6
  "main": "sources/work.js",
@@ -124,8 +124,8 @@ export function scaffoldBisClasses() {
124
124
  }
125
125
  }`);
126
126
 
127
- // 1.2. Подразделения ($structure) и рабочие места (ROLES + LINKS)
128
- writeClassJs('accounting', '$structure', `{
127
+ // 1.2. Подразделения ($department) и рабочие места (ROLES + LINKS)
128
+ writeClassJs('accounting', '$department', `{
129
129
  icon: "icons:account-balance",
130
130
  label: "Бухгалтерия",
131
131
  "#security": {
@@ -229,7 +229,7 @@ export function scaffoldBisClasses() {
229
229
  }
230
230
  }`);
231
231
 
232
- writeClassJs('orders', '$structure', `{
232
+ writeClassJs('orders', '$department', `{
233
233
  icon: "icons:shopping-cart",
234
234
  label: "Заказы и договоры",
235
235
  "#security": {
@@ -254,7 +254,7 @@ export function scaffoldBisClasses() {
254
254
  }
255
255
  }`);
256
256
 
257
- writeClassJs('hr', '$structure', `{
257
+ writeClassJs('hr', '$department', `{
258
258
  icon: "icons:supervisor-account",
259
259
  label: "Кадры и делопроизводство",
260
260
  "#security": {
@@ -277,7 +277,7 @@ export function scaffoldBisClasses() {
277
277
  }
278
278
  }`);
279
279
 
280
- writeClassJs('development', '$structure', `{
280
+ writeClassJs('development', '$department', `{
281
281
  icon: "carbon:code",
282
282
  label: "Разработка и выставки",
283
283
  "#security": {
@@ -240,8 +240,8 @@ export function scaffoldDelovayaClasses() {
240
240
  }
241
241
  }`);
242
242
 
243
- // 2.2. Подразделения ($structure) и рабочие места (ROLES + LINKS)
244
- writeClassJs('accounting', '$structure', `{
243
+ // 2.2. Подразделения ($department) и рабочие места (ROLES + LINKS)
244
+ writeClassJs('accounting', '$department', `{
245
245
  icon: "icons:account-balance",
246
246
  label: "Бухгалтерия",
247
247
  "#security": {
@@ -322,7 +322,7 @@ export function scaffoldDelovayaClasses() {
322
322
  }
323
323
  }`);
324
324
 
325
- writeClassJs('orders', '$structure', `{
325
+ writeClassJs('orders', '$department', `{
326
326
  icon: "icons:shopping-cart",
327
327
  label: "Отдел заказов",
328
328
  "#security": {
@@ -344,7 +344,7 @@ export function scaffoldDelovayaClasses() {
344
344
  }
345
345
  }`);
346
346
 
347
- writeClassJs('hr', '$structure', `{
347
+ writeClassJs('hr', '$department', `{
348
348
  icon: "icons:supervisor-account",
349
349
  label: "Отдел кадров",
350
350
  "#security": {
@@ -363,7 +363,7 @@ export function scaffoldDelovayaClasses() {
363
363
  }
364
364
  }`);
365
365
 
366
- writeClassJs('research', '$structure', `{
366
+ writeClassJs('research', '$department', `{
367
367
  icon: "carbon:analytics",
368
368
  label: "Маркетинговые исследования",
369
369
  "#security": {
@@ -15,7 +15,7 @@ export class $class extends $folder{
15
15
  return this.DATA?.icon || 'odant:module';
16
16
  if (this.type === '$domain' && this.id === 'MODULES')
17
17
  return 'odant:folder';
18
- if (this.type === '$structure')
18
+ if (this.type === '$structure' || this.DATA?.isDepartment)
19
19
  return this.DATA?.icon || 'odant:structure';
20
20
  return this.DATA?.icon || 'bootstrap:database';
21
21
  },
package/sources/client.js CHANGED
@@ -478,18 +478,26 @@ WORK.login = async function(force = false){
478
478
  if (pendingInviteToken) {
479
479
  try { sessionStorage.removeItem('work.pendingInviteToken'); } catch { /* ignore */ }
480
480
  }
481
+ const prevUid = WORK.uid || '';
482
+ const authChanged = !WORK._authNotifiedOnce || prevUid !== uid;
481
483
  WORK.uid = uid;
482
484
  WORK._loginError = null;
483
485
  WORK._anonExitSynced = false;
484
- await WORK.syncAuthUI();
486
+ if (authChanged || !WORK.USER)
487
+ await WORK.syncAuthUI();
485
488
  WORK.refreshChatUnread?.();
486
- WORK.notifyAuth?.({ uid, reason: 'login' });
489
+ if (authChanged) {
490
+ WORK._authNotifiedOnce = true;
491
+ WORK.notifyAuth?.({ uid, reason: 'login' });
492
+ }
487
493
  return res;
488
494
  }
489
495
  const hadAuth = Boolean(WORK.uid);
496
+ const authChanged = !WORK._authNotifiedOnce || hadAuth;
490
497
  if (WORK.uid)
491
498
  await WORK.removeCurrentPushSubscription?.();
492
499
  WORK.uid = '';
500
+ WORK._pushSyncedUid = '';
493
501
  WORK._loginError = null;
494
502
  WORK.USER = undefined;
495
503
  WORK.chatUnread = { total: 0, byThread: {}, byNode: {}, byPeer: {} };
@@ -497,8 +505,11 @@ WORK.login = async function(force = false){
497
505
  WORK._anonExitSynced = true;
498
506
  await WORK.fetch("/", 'user_exit', {}, {}).catch(() => {});
499
507
  }
500
- await WORK.syncAuthUI();
501
- WORK.notifyAuth?.({ uid: '', reason: 'logout' });
508
+ if (authChanged) {
509
+ await WORK.syncAuthUI();
510
+ WORK._authNotifiedOnce = true;
511
+ WORK.notifyAuth?.({ uid: '', reason: 'logout' });
512
+ }
502
513
  }
503
514
  catch (err) {
504
515
  WORK._loginError = err;
@@ -824,16 +835,18 @@ if (WORK.top === window) {
824
835
  }
825
836
  // Даже действующую подписку привязываем к текущему uid после входа/рестарта.
826
837
  await WORK.storePushSubscription(subscription);
838
+ WORK._pushSyncedUid = WORK.uid;
827
839
  return true;
828
840
  }
829
841
  catch (err) { console.warn('[push] subscription', err); return false; }
830
842
  };
831
843
  setTimeout(() => {
832
- WORK.enableTaskNotifications(false);
844
+ if (WORK.uid && WORK._pushSyncedUid !== WORK.uid)
845
+ WORK.enableTaskNotifications(false);
833
846
  RTCCaller.init();
834
847
  }, 3000);
835
848
  WORK.authEvents?.addEventListener('auth', e => {
836
- if (e.detail?.uid)
849
+ if (e.detail?.uid && WORK._pushSyncedUid !== e.detail.uid)
837
850
  WORK.enableTaskNotifications(false);
838
851
  });
839
852
  }