odant-work 1.0.70 → 1.0.72

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.
@@ -1,7 +1,6 @@
1
1
  import staffProto from './tabs/staff.js';
2
2
  import messengersProto from './tabs/messengers.js';
3
3
  import databaseProto from './tabs/database.js';
4
- import searchProto from './tabs/search.js';
5
4
  import licenseProto from './tabs/license.js';
6
5
  import agentProto from './tabs/agent.js';
7
6
 
@@ -28,7 +27,6 @@ function regTab(tag, raw) {
28
27
  regTab('system-tab-staff', staffProto);
29
28
  regTab('system-tab-messengers', messengersProto);
30
29
  regTab('system-tab-database', databaseProto);
31
- regTab('system-tab-search', searchProto);
32
30
  regTab('system-tab-license', licenseProto);
33
31
  regTab('system-tab-agent', agentProto);
34
32
 
@@ -37,48 +35,59 @@ export default {
37
35
  template: /* html */`
38
36
  <style>
39
37
  :host {
40
- @apply --vertical;
38
+ @apply --horizontal;
41
39
  @apply --flex;
42
40
  overflow: hidden;
43
41
  background: var(--content-background);
44
42
  color: var(--content-color);
45
43
  }
46
- .sys-tabs {
47
- @apply --horizontal;
48
- align-items: center;
49
- gap: 6px;
50
- padding: 8px 14px;
51
- border-bottom: 1px solid var(--subtle-border, var(--border-color));
52
- background: var(--subtle-background);
53
- flex-wrap: wrap;
44
+ .sys-sidebar {
45
+ @apply --vertical;
46
+ width: 224px;
54
47
  flex-shrink: 0;
48
+ padding: 12px 10px;
49
+ gap: 4px;
50
+ border-right: 1px solid var(--subtle-border, var(--border-color));
51
+ background: var(--subtle-background, #f8fafc);
52
+ overflow-y: auto;
53
+ }
54
+ .sys-sep {
55
+ height: 1px;
56
+ margin: 6px 8px;
57
+ background: var(--subtle-border, var(--border-color));
58
+ opacity: 0.7;
55
59
  }
56
60
  .sys-tab {
57
61
  @apply --horizontal;
58
62
  align-items: center;
59
- gap: 6px;
60
- padding: 6px 12px;
63
+ gap: 9px;
64
+ width: 100%;
65
+ padding: 8px 12px;
61
66
  border-radius: 8px;
62
67
  border: 1px solid transparent;
63
68
  background: transparent;
64
69
  color: var(--content-color);
65
70
  font: inherit;
66
- font-size: 13px;
67
- font-weight: 600;
71
+ font-size: 13.5px;
72
+ font-weight: 500;
73
+ text-align: left;
68
74
  cursor: pointer;
69
75
  user-select: none;
76
+ transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
70
77
  }
71
78
  .sys-tab:hover {
72
- background: var(--accent-soft);
79
+ background: color-mix(in srgb, var(--accent-color, #2563eb) 6%, transparent);
73
80
  }
74
81
  .sys-tab.active {
75
- background: var(--content-background);
76
- color: var(--accent-color);
77
- border-color: var(--accent-color);
82
+ background: color-mix(in srgb, var(--accent-color, #2563eb) 10%, var(--content-background, #ffffff));
83
+ color: var(--accent-color, #2563eb);
84
+ border-color: color-mix(in srgb, var(--accent-color, #2563eb) 55%, transparent);
85
+ font-weight: 600;
78
86
  }
79
87
  .sys-body {
80
88
  @apply --vertical;
81
89
  @apply --flex;
90
+ min-width: 0;
82
91
  min-height: 0;
83
92
  overflow: hidden;
84
93
  }
@@ -103,14 +112,21 @@ export default {
103
112
  }
104
113
  </style>
105
114
 
106
- <div class="sys-tabs">
107
- <button type="button" class="sys-tab" ~for="availableTabs"
115
+ <nav class="sys-sidebar" aria-label="Разделы системы">
116
+ <button type="button" class="sys-tab" ~for="mainTabs"
108
117
  ~class="{ active: currentTabId === $for.item.id }"
109
118
  @tap="selectTab($for.item.id)">
110
119
  <oda-icon :icon="$for.item.icon" icon-size="16"></oda-icon>
111
120
  <span>{{$for.item.label}}</span>
112
121
  </button>
113
- </div>
122
+ <div class="sys-sep" ~if="mainTabs.length && infraTabs.length"></div>
123
+ <button type="button" class="sys-tab" ~for="infraTabs"
124
+ ~class="{ active: currentTabId === $for.item.id }"
125
+ @tap="selectTab($for.item.id)">
126
+ <oda-icon :icon="$for.item.icon" icon-size="16"></oda-icon>
127
+ <span>{{$for.item.label}}</span>
128
+ </button>
129
+ </nav>
114
130
 
115
131
  <div class="sys-body">
116
132
  <div ~if="currentTabId === 'requisites'" class="req-wrap">
@@ -130,14 +146,12 @@ export default {
130
146
  <item-tree ~if="currentTabId === 'files'" flex :$item="storageFolder" show-size hide-system items-selector="entries" hide-tops="1" hide-roots="1"></item-tree>
131
147
  <system-tab-messengers ~if="currentTabId === 'messengers'" flex :$item="$item"></system-tab-messengers>
132
148
  <system-tab-database ~if="currentTabId === 'database'" flex :$item="$item"></system-tab-database>
133
- <system-tab-search ~if="currentTabId === 'search'" flex :$item="$item" :initial-query="pendingQuery"></system-tab-search>
134
149
  <system-tab-license ~if="currentTabId === 'license'" flex :$item="$item"></system-tab-license>
135
150
  <system-tab-agent ~if="currentTabId === 'agent'" flex :$item="$item"></system-tab-agent>
136
151
  </div>
137
152
  `,
138
153
  activeTab: '',
139
154
  pendingPlace: '',
140
- pendingQuery: '',
141
155
  hasStaticFields: false,
142
156
  dataAccessNode: null,
143
157
  requisitesBody: null,
@@ -156,7 +170,7 @@ export default {
156
170
  get storageFolder() {
157
171
  return this.$item?.storage_folder;
158
172
  },
159
- get availableTabs() {
173
+ get mainTabs() {
160
174
  const t = this.$item?.type;
161
175
  const tabs = [];
162
176
  if (this.hasStaticFields)
@@ -165,17 +179,24 @@ export default {
165
179
  tabs.push({ id: 'profile', label: 'Профиль и токены', icon: 'icons:account-circle' });
166
180
  tabs.push({ id: 'staff', label: 'Пользователи', icon: 'icons:supervisor-account' });
167
181
  tabs.push({ id: 'files', label: 'Файлы', icon: 'fontawesome:r-folder-open' });
182
+ return tabs;
183
+ },
184
+ get infraTabs() {
185
+ const t = this.$item?.type;
186
+ const tabs = [];
168
187
  if (t !== '$user')
169
188
  tabs.push({ id: 'messengers', label: 'Мессенджеры', icon: 'communication:phonelink-ring' });
170
- if (t === '$server' || t === '$base' || t === '$project')
171
- tabs.push({ id: 'database', label: 'База данных', icon: 'carbon:data-base' });
172
- tabs.push({ id: 'search', label: 'Поиск', icon: 'icons:search' });
173
189
  if (t !== '$user')
174
190
  tabs.push({ id: 'agent', label: 'Агент и правила', icon: 'bootstrap:robot' });
191
+ if (t === '$server' || t === '$base' || t === '$project')
192
+ tabs.push({ id: 'database', label: 'База данных', icon: 'carbon:data-base' });
175
193
  if (t === '$server')
176
194
  tabs.push({ id: 'license', label: 'Лицензия', icon: 'carbon:certificate' });
177
195
  return tabs;
178
196
  },
197
+ get availableTabs() {
198
+ return [...this.mainTabs, ...this.infraTabs];
199
+ },
179
200
  get currentTabId() {
180
201
  const tabs = this.availableTabs;
181
202
  if (tabs.some(t => t.id === this.activeTab))
@@ -190,9 +211,11 @@ export default {
190
211
  async applyNav(nav = {}) {
191
212
  if (nav.place)
192
213
  this.pendingPlace = String(nav.place);
193
- if (nav.q)
194
- this.pendingQuery = String(nav.q);
195
214
  if (nav.tab) {
215
+ if (nav.tab === 'search' && this.$item && typeof window?.execute === 'function') {
216
+ window.execute(this.$item, { view: 'search', ...(nav.q ? { q: nav.q } : {}) });
217
+ return;
218
+ }
196
219
  const tabId = nav.tab === 'folder' ? 'files' : nav.tab === 'editor' ? 'requisites' : String(nav.tab);
197
220
  this.selectTab(tabId);
198
221
  }
@@ -74,6 +74,23 @@ export default {
74
74
  }
75
75
  </style>
76
76
 
77
+ <div class="card">
78
+ <div class="card-head">
79
+ <oda-icon icon="bootstrap:robot" icon-size="20"></oda-icon>
80
+ <span>Поведение цифрового двойника узла</span>
81
+ </div>
82
+ <div class="row" style="gap:16px;">
83
+ <label class="row" style="gap:6px;cursor:pointer;">
84
+ <input type="checkbox" :checked="proactivity.autoReply" @change="toggleProactivity('autoReply', $event.target.checked)">
85
+ <span>Отвечать на входящие обращения</span>
86
+ </label>
87
+ <label class="row" style="gap:6px;cursor:pointer;">
88
+ <input type="checkbox" :checked="proactivity.quietDigest" @change="toggleProactivity('quietDigest', $event.target.checked)">
89
+ <span>Тихая суточная сводка руководителю (только при наличии событий)</span>
90
+ </label>
91
+ </div>
92
+ </div>
93
+
77
94
  <div class="card">
78
95
  <div class="card-head">
79
96
  <oda-icon icon="bootstrap:robot" icon-size="20"></oda-icon>
@@ -167,6 +184,7 @@ export default {
167
184
  `,
168
185
  triggers: [],
169
186
  schedules: [],
187
+ proactivity: { autoReply: true, quietDigest: true },
170
188
  editing: false,
171
189
  editingIsNew: true,
172
190
  form: {},
@@ -185,6 +203,21 @@ export default {
185
203
  const res = await this.$item.fetch('agent_rules_list');
186
204
  this.triggers = Array.isArray(res?.triggers) ? res.triggers : [];
187
205
  this.schedules = Array.isArray(res?.schedules) ? res.schedules : [];
206
+ if (res?.proactivity)
207
+ this.proactivity = { ...this.proactivity, ...res.proactivity };
208
+ }
209
+ catch (e) {
210
+ this.error = String(e?.message || e);
211
+ }
212
+ },
213
+ async toggleProactivity(key, value) {
214
+ if (!this.$item?.fetch)
215
+ return;
216
+ this.error = '';
217
+ try {
218
+ const res = await this.$item.fetch('agent_proactivity_save', {}, JSON.stringify({ [key]: Boolean(value) }));
219
+ if (res?.proactivity)
220
+ this.proactivity = { ...this.proactivity, ...res.proactivity };
188
221
  }
189
222
  catch (e) {
190
223
  this.error = String(e?.message || e);
@@ -77,11 +77,11 @@ ODA({ is: 'work-voice-picker',
77
77
  </style>
78
78
  <div class="vertical" ~for="models">
79
79
  <div class="group-title" :title="$for.item.path">{{$for.item.label}}</div>
80
- <div class="v-row" ~for="$for.item.voices" ~for-item="v" :active="isSelected($for.item, v)" @tap="pick($for.item, v)">
81
- <oda-icon no-flex :icon="isSelected($for.item, v) ? 'carbon:checkmark' : 'carbon:dot-mark'" :icon-size="13" :style="isSelected($for.item, v) ? '' : 'opacity:0.25;'"></oda-icon>
82
- <span class="v-label">{{v.label}}</span>
83
- <button type="button" class="preview-btn" title="Прослушать этот голос" @tap.stop="preview($for.item, v)">
84
- <oda-icon :icon="previewKey === keyOf($for.item, v) ? 'spinners:3-dots-scale' : 'carbon:volume-up'" :icon-size="14"></oda-icon>
80
+ <div class="v-row" ~for="$for.item.voices" :active="isSelected($for.$for.item, $for.item)" @tap="pick($for.$for.item, $for.item)">
81
+ <oda-icon no-flex :icon="isSelected($for.$for.item, $for.item) ? 'carbon:checkmark' : 'carbon:dot-mark'" :icon-size="13" :style="isSelected($for.$for.item, $for.item) ? '' : 'opacity:0.25;'"></oda-icon>
82
+ <span class="v-label">{{$for.item.label}}</span>
83
+ <button type="button" class="preview-btn" title="Прослушать этот голос" @tap.stop="preview($for.$for.item, $for.item)">
84
+ <oda-icon :icon="previewKey === keyOf($for.$for.item, $for.item) ? 'spinners:3-dots-scale' : 'carbon:volume-up'" :icon-size="14"></oda-icon>
85
85
  </button>
86
86
  </div>
87
87
  </div>
@@ -133,6 +133,12 @@ ODA({is: 'chat-item',
133
133
  </div>
134
134
  <div class="preview" ~if="!compact && !expanded && !missingTargetPath && hasPreview && $file" ~is="previewTag" flex :$item="$file" :log="log" :log-content="logContent" style="user-select: text;" @expand-card.stop="expanded = true"></div>
135
135
  <div class="preview" ~if="!compact && !expanded && !missingTargetPath && !$file && !hasTargetFilePath && logContent" flex style="padding: 6px 12px; white-space: pre-wrap; user-select: text;">{{logContent}}</div>
136
+ <div class="approval-box" ~if="!compact && !expanded && log?.chatMessage?.kind === 'approval'" horizontal style="align-items: center; gap: 8px; padding: 4px 12px 8px;">
137
+ <span ~if="approvalStatus === 'approved'" style="font-size: 12px; font-weight: 700; color: #059669;">✓ Утверждено</span>
138
+ <span ~if="approvalStatus === 'rejected'" style="font-size: 12px; font-weight: 700; color: #dc2626;">✕ Отклонено</span>
139
+ <oda-button ~if="approvalStatus === 'pending'" icon="icons:check" info-invert label="Утвердить" @down.stop @tap.stop="_resolveChatApproval('approve')" style="border-radius: 6px; padding: 3px 10px; scale: 1;"></oda-button>
140
+ <oda-button ~if="approvalStatus === 'pending'" icon="icons:close" label="Отклонить" @down.stop @tap.stop="_resolveChatApproval('reject')" style="border-radius: 6px; padding: 3px 10px; scale: 1;"></oda-button>
141
+ </div>
136
142
  <div header ~if="!expanded && !missingTargetPath && includeFiles?.length" vertical style="padding: 8px; gap: 8px;">
137
143
  <chat-item ~for="includeFiles" visible history compact :$file="$for.item"></chat-item>
138
144
  </div>
@@ -225,14 +231,20 @@ ODA({is: 'chat-item',
225
231
  },
226
232
  },
227
233
  get isAgentSender() {
234
+ if (this.log?.sender === '$twin' || this.log?.chatMessage?.sender === '$twin')
235
+ return true;
228
236
  const act = String(this.log?.actor || '');
229
237
  if (act === 'AI' || act.startsWith('/MODELS/'))
230
238
  return true;
231
- if (Array.isArray(this.log?.receivers) && this.log.receivers.length === 1 && this.log.receivers[0] === this.log?.sender && !this.log?.path)
239
+ if (Array.isArray(this.log?.receivers) && this.log?.receivers.length === 1 && this.log.receivers[0] === this.log?.sender && !this.log?.path)
232
240
  return true;
233
241
  return false;
234
242
  },
235
243
  get agentSenderTitle() {
244
+ if (this.log?.sender === '$twin' || this.log?.chatMessage?.sender === '$twin') {
245
+ const nl = this.log?.chatMessage?.nodeLabel;
246
+ return nl ? `Цифровой двойник «${nl}»` : 'Цифровой двойник узла';
247
+ }
236
248
  const act = String(this.log?.actor || '');
237
249
  if (this.log?.actorLabel)
238
250
  return String(this.log.actorLabel);
@@ -240,6 +252,30 @@ ODA({is: 'chat-item',
240
252
  return 'ИИ-агент (' + act.split('/').pop() + ')';
241
253
  return 'ИИ-агент WORK';
242
254
  },
255
+ get approvalStatus() {
256
+ return this.log?.chatMessage?.meta?.status || 'pending';
257
+ },
258
+ async _resolveChatApproval(action) {
259
+ const cm = this.log?.chatMessage;
260
+ if (!cm?.id || !cm?.threadId)
261
+ return;
262
+ const owner = this._resolveFeedOwner();
263
+ if (!owner?.fetch)
264
+ return;
265
+ try {
266
+ const res = await owner.fetch('chat_action', { threadId: cm.threadId, messageId: cm.id, action });
267
+ if (res?.meta) {
268
+ this.log = {
269
+ ...this.log,
270
+ chatMessage: { ...cm, meta: res.meta },
271
+ };
272
+ this.render?.();
273
+ }
274
+ }
275
+ catch (err) {
276
+ console.warn('[chat-item] chat_action:', err);
277
+ }
278
+ },
243
279
  get isSender(){
244
280
  if (this.isAgentSender)
245
281
  return false;
@@ -593,6 +629,11 @@ ODA({is: 'chat-item',
593
629
  async _labelForLog(body) {
594
630
  if (!body)
595
631
  return '';
632
+ if (body.chatMessage) {
633
+ if (body.chatMessage.kind === 'approval')
634
+ return 'Запрос подтверждения';
635
+ return body.chatMessage.sender === '$twin' ? (body.chatMessage.nodeLabel ? `Двойник «${body.chatMessage.nodeLabel}»` : 'Цифровой двойник') : '';
636
+ }
596
637
  if (String(body.path || '').includes('/history/'))
597
638
  return CORE.historyEntryLabel(body.path);
598
639
  try {
@@ -665,6 +706,8 @@ ODA({is: 'chat-item',
665
706
  return this.loadPreview(taskFile).then(() => taskFile);
666
707
  }
667
708
  return Promise.resolve(this.itemBody).then(async body => {
709
+ if (body?.chatMessage)
710
+ return null;
668
711
  if (!body?.path || String(body.path).endsWith('.logs') || body?.ext === 'operation' || body?.ext === 'object') {
669
712
  if (body?.ext === 'operation' || body?.ext === 'object')
670
713
  this.hasPreview = true;
@@ -536,7 +536,7 @@ export default {
536
536
  return;
537
537
  const target = this.$item || globalThis.WORK;
538
538
  if (target && typeof window?.execute === 'function')
539
- window.execute(target, { view: 'system', tab: 'search', q });
539
+ window.execute(target, { view: 'search', q });
540
540
  },
541
541
  _onTreeScroll() {
542
542
  if (this._scrollRaf)
package/oda/oda.js CHANGED
@@ -184,10 +184,14 @@ Node:{
184
184
  Node.prototype.render = function (wake) {
185
185
  if (!this.__vnode__ || !this.isConnected)
186
186
  return;
187
- this.throttle('render', ()=>{
188
- const el = this.__vnode__.render(this) || this;
189
- if(!el[R].states.sleep || wake)
190
- if(el.nodeType === 1)
187
+ this.throttle('render', async ()=>{
188
+ let el = this.__vnode__.render(this) || this;
189
+ if (el?.then)
190
+ el = (await el) || this;
191
+ if (!el?.isConnected)
192
+ return;
193
+ if (!el?.[R]?.states?.sleep || wake)
194
+ if (el?.nodeType === 1)
191
195
  el.renderChildren(wake);
192
196
  })
193
197
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "odant-work",
3
- "version": "1.0.70",
3
+ "version": "1.0.72",
4
4
  "description": "ODANT-WORK — платформа цифровой организации (встроенная система учёта, документооборот, управление процессами и приватный мультимодальный ИИ)",
5
5
  "type": "module",
6
6
  "main": "sources/work.js",
package/sources/client.js CHANGED
@@ -480,6 +480,37 @@ WORK.login = async function(force = false){
480
480
  WORK.notifyAuth?.({ uid: '', reason: 'logout' });
481
481
  })();
482
482
  }
483
+ WORK.applyChatReadLocal = function ({ threadId = '', kind = '', nodePath = '', peerId = '' } = {}) {
484
+ const u = WORK.chatUnread;
485
+ if (!u)
486
+ return;
487
+ let delta = 0;
488
+ if (threadId && u.byThread?.[threadId]) {
489
+ delta = Number(u.byThread[threadId]) || 0;
490
+ delete u.byThread[threadId];
491
+ }
492
+ const normNode = nodePath ? String(nodePath).replace(/\/+$/, '') || '/' : '';
493
+ if ((kind === 'twin' || normNode) && normNode && u.byNode?.[normNode]) {
494
+ const prevNode = Number(u.byNode[normNode]) || 0;
495
+ const drop = delta > 0 ? Math.min(prevNode, delta) : prevNode;
496
+ if (!delta) delta = drop;
497
+ const nextNode = prevNode - drop;
498
+ if (nextNode > 0) u.byNode[normNode] = nextNode;
499
+ else delete u.byNode[normNode];
500
+ }
501
+ if ((kind === 'dm' || peerId) && peerId && u.byPeer?.[peerId]) {
502
+ const prevPeer = Number(u.byPeer[peerId]) || 0;
503
+ const drop = delta > 0 ? Math.min(prevPeer, delta) : prevPeer;
504
+ if (!delta) delta = drop;
505
+ const nextPeer = prevPeer - drop;
506
+ if (nextPeer > 0) u.byPeer[peerId] = nextPeer;
507
+ else delete u.byPeer[peerId];
508
+ }
509
+ if (delta > 0)
510
+ u.total = Math.max(0, (Number(u.total) || 0) - delta);
511
+ WORK.chatEvents ??= new EventTarget();
512
+ WORK.chatEvents.dispatchEvent(new CustomEvent('chat:read', { detail: { threadId, kind, nodePath: normNode, peerId } }));
513
+ };
483
514
  WORK.refreshChatUnread = async function () {
484
515
  if (!WORK.uid || typeof WORK.fetch !== 'function')
485
516
  return null;
@@ -638,14 +669,19 @@ class WebSocketEvents {
638
669
  WORK.chatUnread ??= { total: 0, byThread: {}, byNode: {}, byPeer: {} };
639
670
  if (data.threadId)
640
671
  WORK.chatUnread.byThread[data.threadId] = (WORK.chatUnread.byThread[data.threadId] || 0) + 1;
641
- if (data.kind === 'twin' && data.nodePath)
642
- WORK.chatUnread.byNode[data.nodePath] = (WORK.chatUnread.byNode[data.nodePath] || 0) + 1;
672
+ if (data.kind === 'twin' && data.nodePath) {
673
+ const np = String(data.nodePath).replace(/\/+$/, '') || '/';
674
+ WORK.chatUnread.byNode[np] = (WORK.chatUnread.byNode[np] || 0) + 1;
675
+ }
676
+ else if (data.kind === 'dm' && data.message?.sender) {
677
+ const peer = String(data.message.sender);
678
+ WORK.chatUnread.byPeer[peer] = (WORK.chatUnread.byPeer[peer] || 0) + 1;
679
+ }
643
680
  WORK.chatUnread.total = (WORK.chatUnread.total || 0) + 1;
644
681
  }
645
- else if (data.type === 'chat:read' && data.threadId && WORK.chatUnread?.byThread) {
646
- const prev = WORK.chatUnread.byThread[data.threadId] || 0;
647
- delete WORK.chatUnread.byThread[data.threadId];
648
- WORK.chatUnread.total = Math.max(0, (WORK.chatUnread.total || 0) - prev);
682
+ else if (data.type === 'chat:read' && data.threadId) {
683
+ WORK.applyChatReadLocal?.(data);
684
+ break;
649
685
  }
650
686
  WORK.chatEvents.dispatchEvent(new CustomEvent(data.type, { detail: data }));
651
687
  } break;
@@ -476,6 +476,7 @@ export async function createEnv({ place, contextPath, session, host, tz, locatio
476
476
  const TWIN_SERVICE_DENY = new Set([
477
477
  'create_class', 'update_class', 'move_class', 'delete_class',
478
478
  'assign', 'escalate', 'delete',
479
+ 'twin_rule_list', 'twin_rule_save', 'twin_schedule_save',
479
480
  'dev_write', 'dev_edit', 'dev_patch', 'dev_git', 'dev_shell',
480
481
  'shell', 'restart_server', 'os_write', 'os_rm',
481
482
  ]);
@@ -631,7 +632,7 @@ async function resolvePlace(lat, lon) {
631
632
  return place;
632
633
  }
633
634
 
634
- /** Блок «Контекст» — только то, что постоянно в задаче (место, пользователь, роли, местоположение); время — nowLine. */
635
+ /** Блок «Контекст» — только то, что постоянно в задаче (субъект, место, собеседник, роли, местоположение); время — nowLine. */
635
636
  async function placeBlock(place, session, location, contextPath) {
636
637
  const lines = ['# Контекст'];
637
638
  if (place) {
@@ -639,10 +640,28 @@ async function placeBlock(place, session, location, contextPath) {
639
640
  await place.init;
640
641
  }
641
642
  catch (e) { log.debug('place.init', e); /* без DATA */ }
642
- lines.push('- Место задачи (текущий класс): ' + place.path + (place.DATA?.label ? ' «' + place.DATA.label + '»' : '') + (place.type ? ' [' + place.type + ']' : ''));
643
+ const label = place.DATA?.label || place.label || place.id || place.path || 'WORK';
644
+ const cone = contextConeOf(contextPath || place.path);
645
+ const pt = place.type;
646
+ if (pt === '$structure') {
647
+ const orgName = cone?.[1] || '';
648
+ lines.push(`- Твоя идентичность (субъект): ты — цифровой двойник подразделения «${label}»${orgName ? ` (организация «${orgName}»)` : ''}, путь ${place.path}. Отвечай и действуй от первого лица этого подразделения.`);
649
+ }
650
+ else if (pt === '$base') {
651
+ lines.push(`- Твоя идентичность (субъект): ты — цифровой двойник организации «${label}» (${place.path}). Отвечай и действуй от первого лица этой организации.`);
652
+ }
653
+ else if (pt === '$project') {
654
+ lines.push(`- Твоя идентичность (субъект): ты — цифровой двойник проекта «${label}» (${place.path}). Отвечай и действуй от первого лица этого проекта.`);
655
+ }
656
+ else if (pt === '$server') {
657
+ lines.push(`- Твоя идентичность (субъект): ты — цифровой двойник системы WORK (корневой узел /). Отвечай и действуй от первого лица системы WORK.`);
658
+ }
659
+ else if (pt === '$user') {
660
+ lines.push(`- Твоя идентичность (субъект): ты — личный цифровой двойник пользователя «${label}» (${place.path}).`);
661
+ }
662
+ lines.push('- Место задачи (текущий узел/класс): ' + place.path + (place.DATA?.label ? ' «' + place.DATA.label + '»' : '') + (place.type ? ' [' + place.type + ']' : ''));
643
663
  if (contextPath && contextPath !== place.path)
644
664
  lines.push('- Открытая форма (контекст вопроса): ' + contextPath);
645
- const cone = contextConeOf(contextPath || place.path);
646
665
  if (cone) {
647
666
  const scopeDesc = cone.length > 2
648
667
  ? `подразделение «/${cone.join('/')}» организации «${cone[1]}»`
@@ -652,11 +671,11 @@ async function placeBlock(place, session, location, contextPath) {
652
671
  }
653
672
  const user = session?.$user;
654
673
  if (user && user !== globalThis.WORK) {
655
- lines.push('- Пользователь: ' + (user.DATA?.label || user.label || user.id) + ' (' + (user.path || '/USERS/' + user.id) + ')');
674
+ lines.push('- Собеседник (кто обратился): ' + (user.DATA?.label || user.label || user.id) + ' (' + (user.path || '/USERS/' + user.id) + ')');
656
675
  try {
657
676
  const roles = await place?.roles?.({ session });
658
677
  if (roles?.length)
659
- lines.push('- Роли пользователя здесь: ' + roles.join(', '));
678
+ lines.push('- Полномочия собеседника в этом узле: ' + roles.join(', '));
660
679
  }
661
680
  catch (e) { log.debug('place.roles', e); /* нет ролей */ }
662
681
  }