odant-work 1.0.66 → 1.0.67

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.
@@ -0,0 +1,289 @@
1
+ export default {
2
+ imports: 'oda//icon, oda//button',
3
+ template: /* html */`
4
+ <style>
5
+ :host {
6
+ @apply --vertical;
7
+ @apply --flex;
8
+ padding: 16px 20px;
9
+ gap: 16px;
10
+ overflow-y: auto;
11
+ background: var(--content-background);
12
+ color: var(--content-color);
13
+ font-size: 13px;
14
+ }
15
+ .card {
16
+ @apply --vertical;
17
+ gap: 10px;
18
+ padding: 14px 16px;
19
+ border: 1px solid var(--subtle-border, var(--border-color));
20
+ border-radius: 10px;
21
+ background: var(--subtle-background);
22
+ }
23
+ .card-head {
24
+ @apply --horizontal;
25
+ align-items: center;
26
+ gap: 8px;
27
+ font-weight: 700;
28
+ font-size: 14.5px;
29
+ }
30
+ .rule-item {
31
+ @apply --vertical;
32
+ gap: 6px;
33
+ padding: 10px 12px;
34
+ border-radius: 8px;
35
+ border: 1px solid var(--subtle-border, var(--border-color));
36
+ background: var(--content-background);
37
+ }
38
+ .row {
39
+ @apply --horizontal;
40
+ align-items: center;
41
+ gap: 8px;
42
+ flex-wrap: wrap;
43
+ }
44
+ input[type="text"], input[type="number"], select, textarea {
45
+ padding: 5px 8px;
46
+ border: 1px solid var(--control-border-color, var(--border-color));
47
+ border-radius: 6px;
48
+ font: inherit;
49
+ font-size: 12.5px;
50
+ background: var(--content-background);
51
+ color: var(--control-color, inherit);
52
+ }
53
+ textarea {
54
+ width: 100%;
55
+ min-height: 64px;
56
+ resize: vertical;
57
+ box-sizing: border-box;
58
+ }
59
+ .badge {
60
+ font-size: 11px;
61
+ padding: 2px 7px;
62
+ border-radius: 10px;
63
+ background: var(--accent-soft);
64
+ color: var(--accent-color);
65
+ font-weight: 600;
66
+ }
67
+ .badge.off {
68
+ background: rgba(148, 163, 184, 0.2);
69
+ color: var(--muted-color);
70
+ }
71
+ .muted {
72
+ color: var(--muted-color);
73
+ font-size: 12.5px;
74
+ }
75
+ </style>
76
+
77
+ <div class="card">
78
+ <div class="card-head">
79
+ <oda-icon icon="bootstrap:robot" icon-size="20"></oda-icon>
80
+ <span>Правила проактивности узла ({{triggers.length}})</span>
81
+ <div class="row" style="margin-left:auto;">
82
+ <oda-button icon="icons:add" @tap="openNewRule()">Новое правило</oda-button>
83
+ <oda-button icon="icons:refresh" @tap="reload()">Обновить</oda-button>
84
+ </div>
85
+ </div>
86
+
87
+ <div ~if="editing" class="rule-item" style="border-color:var(--accent-color);">
88
+ <div style="font-weight:700;">{{editingIsNew ? 'Новое правило проактивности' : 'Редактирование: ' + form.name}}</div>
89
+ <div class="row">
90
+ <input type="text" placeholder="Имя правила (латиница/цифры/_/-)" :disabled="!editingIsNew" ::value="form.name" style="width:200px;">
91
+ <select ::value="form.on">
92
+ <option value="db:register">Проведение документа (db:register)</option>
93
+ <option value="db:create">Создание объекта (db:create)</option>
94
+ <option value="db:update">Изменение объекта (db:update)</option>
95
+ <option value="chat:message">Сообщение в чате (chat:message)</option>
96
+ <option value="save">Сохранение файла (save)</option>
97
+ </select>
98
+ <input ~if="form.on !== 'save' && form.on !== 'chat:message'" type="text" placeholder="Путь класса (необязательно)" ::value="form.class" style="flex:1;min-width:200px;">
99
+ <input ~if="form.on === 'save'" type="text" placeholder="Расширения (eml, pdf)" ::value="form.ext" style="width:160px;">
100
+ </div>
101
+ <div class="row">
102
+ <input type="text" placeholder="Условие when (например: sum > 100000)" ::value="form.when" style="flex:1;min-width:220px;">
103
+ <input type="number" placeholder="Cooldown (сек)" ::value="form.cooldownSec" style="width:120px;" title="Пауза между срабатываниями на один объект (сек)">
104
+ <label class="row" style="gap:4px;cursor:pointer;">
105
+ <input type="checkbox" :checked="form.approval" @change="form.approval = $event.target.checked">
106
+ <span>Карточка подтверждения</span>
107
+ </label>
108
+ <label class="row" style="gap:4px;cursor:pointer;">
109
+ <input type="checkbox" :checked="form.enabled" @change="form.enabled = $event.target.checked">
110
+ <span>Включено</span>
111
+ </label>
112
+ </div>
113
+ <input type="text" placeholder="Быстрый шаблон ответа без LLM (необязательно, например: Проведена сумма {{sum}})" ::value="form.template">
114
+ <textarea placeholder="Инструкция для ИИ-агента (если не задан быстрый шаблон)..." ::value="form.body"></textarea>
115
+ <div class="row" style="justify-content:flex-end;">
116
+ <oda-button icon="icons:check" info-invert @tap="saveRule()">Сохранить</oda-button>
117
+ <oda-button icon="icons:close" @tap="editing = false">Отмена</oda-button>
118
+ </div>
119
+ </div>
120
+
121
+ <div ~if="!triggers.length" class="muted">Для этого узла ещё не заданы проактивные триггеры.</div>
122
+
123
+ <div class="rule-item" ~for="triggers">
124
+ <div class="row">
125
+ <b>{{$for.item.name}}</b>
126
+ <span class="badge">{{$for.item.on}}</span>
127
+ <span ~if="$for.item.approval" class="badge">подтверждение</span>
128
+ <span class="badge" ~class="{ off: !$for.item.enabled }">{{$for.item.enabled ? 'вкл' : 'выкл'}}</span>
129
+ <div class="row" style="margin-left:auto;">
130
+ <oda-button icon="editor:mode-edit" @tap="editRule($for.item)">Изменить</oda-button>
131
+ <oda-button ~if="$for.item.own" icon="icons:delete" @tap="deleteRule($for.item.name)"></oda-button>
132
+ </div>
133
+ </div>
134
+ <div ~if="$for.item.when" class="muted">Условие: <code>{{$for.item.when}}</code></div>
135
+ <div ~if="$for.item.template" class="muted">Шаблон: {{$for.item.template}}</div>
136
+ <div ~if="!$for.item.template && $for.item.body" class="muted">{{$for.item.body}}</div>
137
+ </div>
138
+ </div>
139
+
140
+ <div class="card">
141
+ <div class="card-head">
142
+ <oda-icon icon="icons:schedule" icon-size="20"></oda-icon>
143
+ <span>Расписания узла ({{schedules.length}})</span>
144
+ </div>
145
+ <div class="row">
146
+ <input type="text" placeholder="Название (например: Утренняя сводка)" ::value="schedLabel" style="width:220px;">
147
+ <input type="number" placeholder="Каждые (мин ≥ 15)" ::value="schedEvery" style="width:140px;">
148
+ <input type="text" placeholder="Задача для Агента..." ::value="schedPrompt" style="flex:1;min-width:220px;">
149
+ <oda-button icon="icons:add" @tap="addSchedule()">Добавить</oda-button>
150
+ </div>
151
+ <div ~if="!schedules.length" class="muted">Расписаний узла пока нет.</div>
152
+ <div class="rule-item" ~for="schedules">
153
+ <div class="row">
154
+ <b>{{$for.item.label}}</b>
155
+ <span class="badge">{{$for.item.when}}</span>
156
+ <span class="badge" ~class="{ off: !$for.item.enabled }">{{$for.item.enabled ? 'активно' : 'пауза'}}</span>
157
+ <div class="row" style="margin-left:auto;">
158
+ <oda-button @tap="toggleSched($for.item)">{{$for.item.enabled ? 'Пауза' : 'Включить'}}</oda-button>
159
+ <oda-button icon="icons:delete" @tap="deleteSched($for.item)"></oda-button>
160
+ </div>
161
+ </div>
162
+ <div class="muted">{{$for.item.prompt}}</div>
163
+ </div>
164
+ </div>
165
+
166
+ <div ~if="error" style="color:var(--error-color, #c00);">{{error}}</div>
167
+ `,
168
+ triggers: [],
169
+ schedules: [],
170
+ editing: false,
171
+ editingIsNew: true,
172
+ form: {},
173
+ schedLabel: '',
174
+ schedEvery: 60,
175
+ schedPrompt: '',
176
+ error: '',
177
+ async attached() {
178
+ await this.reload();
179
+ },
180
+ async reload() {
181
+ this.error = '';
182
+ if (!this.$item?.fetch)
183
+ return;
184
+ try {
185
+ const res = await this.$item.fetch('agent_rules_list');
186
+ this.triggers = Array.isArray(res?.triggers) ? res.triggers : [];
187
+ this.schedules = Array.isArray(res?.schedules) ? res.schedules : [];
188
+ }
189
+ catch (e) {
190
+ this.error = String(e?.message || e);
191
+ }
192
+ },
193
+ openNewRule() {
194
+ this.editingIsNew = true;
195
+ this.form = {
196
+ name: '',
197
+ on: 'db:register',
198
+ class: '',
199
+ ext: '',
200
+ when: '',
201
+ template: '',
202
+ body: '',
203
+ approval: false,
204
+ cooldownSec: 60,
205
+ maxPerHour: 20,
206
+ enabled: true,
207
+ };
208
+ this.editing = true;
209
+ },
210
+ editRule(r) {
211
+ this.editingIsNew = false;
212
+ this.form = {
213
+ name: r.name,
214
+ on: Array.isArray(r.on) ? r.on.join(', ') : (r.on || 'save'),
215
+ class: r.class || '',
216
+ ext: r.ext || '',
217
+ when: r.when || '',
218
+ template: r.template || '',
219
+ body: r.body || '',
220
+ approval: Boolean(r.approval),
221
+ cooldownSec: Number(r.cooldownSec) || 0,
222
+ maxPerHour: Number(r.maxPerHour) || 20,
223
+ enabled: r.enabled !== false,
224
+ as: r.as || '',
225
+ };
226
+ this.editing = true;
227
+ },
228
+ async saveRule() {
229
+ this.error = '';
230
+ try {
231
+ const payload = { ...this.form, as: this.form.as || WORK.uid };
232
+ await this.$item.fetch('agent_rule_save', {}, JSON.stringify(payload));
233
+ this.editing = false;
234
+ await this.reload();
235
+ }
236
+ catch (e) {
237
+ this.error = String(e?.message || e);
238
+ }
239
+ },
240
+ async deleteRule(name) {
241
+ this.error = '';
242
+ try {
243
+ await this.$item.fetch('agent_rule_save', {}, JSON.stringify({ name, delete: true }));
244
+ await this.reload();
245
+ }
246
+ catch (e) {
247
+ this.error = String(e?.message || e);
248
+ }
249
+ },
250
+ async addSchedule() {
251
+ this.error = '';
252
+ const prompt = String(this.schedPrompt || '').trim();
253
+ if (!prompt)
254
+ return;
255
+ try {
256
+ await this.$item.fetch('agent_schedule_save', {}, JSON.stringify({
257
+ label: this.schedLabel || prompt.slice(0, 50),
258
+ prompt,
259
+ rule: { every: Math.max(15, Number(this.schedEvery) || 60) },
260
+ }));
261
+ this.schedLabel = '';
262
+ this.schedPrompt = '';
263
+ await this.reload();
264
+ }
265
+ catch (e) {
266
+ this.error = String(e?.message || e);
267
+ }
268
+ },
269
+ async toggleSched(s) {
270
+ this.error = '';
271
+ try {
272
+ await this.$item.fetch('agent_schedule_save', {}, JSON.stringify({ id: s.id, toggle: true, enabled: !s.enabled }));
273
+ await this.reload();
274
+ }
275
+ catch (e) {
276
+ this.error = String(e?.message || e);
277
+ }
278
+ },
279
+ async deleteSched(s) {
280
+ this.error = '';
281
+ try {
282
+ await this.$item.fetch('agent_schedule_save', {}, JSON.stringify({ id: s.id, delete: true }));
283
+ await this.reload();
284
+ }
285
+ catch (e) {
286
+ this.error = String(e?.message || e);
287
+ }
288
+ },
289
+ };
@@ -184,6 +184,7 @@ ODA({is: 'work-form',
184
184
  <div :flex="ODA.states?.mobileMode"></div>
185
185
  <item-node-explorer no-flex :$item="rootItem"></item-node-explorer>
186
186
  <div flex></div>
187
+ <oda-button ~if="canOpenDataPage" shadow icon="carbon:data-base" @tap="openDataPage" title="Открыть проводник данных узла" label="Данные" :icon-size info-invert style="border-radius: 999px; padding: 0 10px; margin-right: 8px; flex-shrink: 0;"></oda-button>
187
188
  <oda-button id="consultantBtn" shadow icon="bootstrap:robot" @tap="askConsultant" title="Спросить ИИ-консультанта по текущей форме" :icon-size info-invert style="border-radius: 50%; margin-right: 8px; flex-shrink: 0;"></oda-button>
188
189
  <oda-button shadow icon="communication:call" @tap="call" title="Call..." :icon-size success style="border-radius: 50%;margin-right:32px;"></oda-button>
189
190
  <slot name="top-panel"></slot>
@@ -730,6 +731,10 @@ ODA({is: 'work-form',
730
731
  this._pendingInitialNav = nav;
731
732
  return;
732
733
  }
734
+ if (nav.noClassTree) {
735
+ this._noClassTreeFlag = true;
736
+ this._initClassTreeDrawer();
737
+ }
733
738
  if (nav.targetClassPath || nav.create || nav.copyFrom || (nav.id && this.hasClassTree)) {
734
739
  await this._handleNavigationTarget(nav, { isInitial: false });
735
740
  return;
@@ -820,7 +825,7 @@ ODA({is: 'work-form',
820
825
  return ownDefault;
821
826
  const isStruct = ['$server', '$base', '$project', '$structure', '$user'].includes($item?.type);
822
827
  const preferred = isStruct
823
- ? ['chat', 'data', 'calendar', 'email', 'system']
828
+ ? ['chat', 'calendar', 'email', 'system']
824
829
  : ['objects', 'virtual', 'sheet', 'turnovers', 'postings', 'map', 'bpmn'];
825
830
  for (const prefId of preferred) {
826
831
  const hit = (views || []).find(v => v.id === prefId);
@@ -870,9 +875,11 @@ ODA({is: 'work-form',
870
875
  this._initializingItem = false;
871
876
  }
872
877
  this._applyRoleColor(n, this._appliedRole);
873
- this._initClassTreeDrawer();
874
878
  const nav = this._takeNav(n.short || n.path) || this._pendingInitialNav;
875
879
  this._pendingInitialNav = null;
880
+ if (nav?.noClassTree || (typeof location !== 'undefined' && new URLSearchParams(location.search).get('noTree') === '1'))
881
+ this._noClassTreeFlag = true;
882
+ this._initClassTreeDrawer();
876
883
  if (nav) {
877
884
  if (nav.view === 'objects' && nav.id)
878
885
  nav.view = 'object';
@@ -899,7 +906,22 @@ ODA({is: 'work-form',
899
906
  _appliedRole: '',
900
907
  _syncingClassTreeFocus: false,
901
908
  view_control: null,
909
+ _noClassTreeFlag: false,
910
+ get canOpenDataPage() {
911
+ const t = this.currentItem?.type;
912
+ return t === '$base' || t === '$project' || t === '$structure';
913
+ },
914
+ openDataPage() {
915
+ const target = this.currentItem;
916
+ const execFn = (typeof window !== 'undefined' && (window.top?.execute || window.execute)) || null;
917
+ if (target && execFn)
918
+ execFn(target, { page: 'data' });
919
+ },
902
920
  get hasClassTree() {
921
+ if (this._noClassTreeFlag)
922
+ return false;
923
+ if (typeof location !== 'undefined' && new URLSearchParams(location.search).get('noTree') === '1')
924
+ return false;
903
925
  const root = this._rootItem || this.$item;
904
926
  if (!root)
905
927
  return false;
@@ -373,7 +373,7 @@ export default {
373
373
  }
374
374
  catch { /* ignore */ }
375
375
  },
376
- _upsertBookmarkForUrl(pageUrl, $item = null) {
376
+ _upsertBookmarkForUrl(pageUrl, $item = null, pagePrefix = '', pageIcon = '') {
377
377
  if (!pageUrl)
378
378
  return null;
379
379
  const short = $item?.short || $item?.path || this._extractShortFromUrl(pageUrl);
@@ -384,7 +384,8 @@ export default {
384
384
  if (!bm) {
385
385
  const lastSeg = String(short || '').split('/').filter(Boolean).pop() || '';
386
386
  const dated = CORE?.$file?.formatDatedFileLabel?.($item?.id || lastSeg, $item?.DATA?.label);
387
- const label = dated || $item?.DATA?.label || $item?.label || this._defaultLabelForShort(short);
387
+ const baseLabel = dated || $item?.DATA?.label || $item?.label || this._defaultLabelForShort(short);
388
+ const label = pagePrefix ? `${pagePrefix} · ${baseLabel}` : baseLabel;
388
389
  bm = {
389
390
  url: pageUrl,
390
391
  hash,
@@ -392,15 +393,17 @@ export default {
392
393
  stateKey: itemStateKey,
393
394
  label,
394
395
  title: `${label} (${short})`,
395
- icon: this._defaultIconForItem($item, short),
396
+ icon: pageIcon || this._defaultIconForItem($item, short),
396
397
  };
397
398
  list.push(bm);
398
399
  this.bookmarks = list;
399
- setTimeout(() => this._hydrateBookmarkMeta(bm, { cachedOnly: true }), 800);
400
+ if (!pagePrefix)
401
+ setTimeout(() => this._hydrateBookmarkMeta(bm, { cachedOnly: true }), 800);
400
402
  }
401
403
  else if ($item) {
402
- const label = $item?.DATA?.label || $item?.label || bm.label;
403
- const icon = this._defaultIconForItem($item, short);
404
+ const baseLabel = $item?.DATA?.label || $item?.label || bm.label;
405
+ const label = pagePrefix ? `${pagePrefix} · ${baseLabel}` : baseLabel;
406
+ const icon = pageIcon || this._defaultIconForItem($item, short);
404
407
  if (itemStateKey)
405
408
  bm.stateKey = itemStateKey;
406
409
  if (bm.label !== label || bm.icon !== icon) {
@@ -673,22 +676,30 @@ export default {
673
676
  window.execute = async ($item, nav) => {
674
677
  if (!$item)
675
678
  return;
679
+ let pageHandlerMeta = null;
676
680
  if ($item.type === '$handler') {
677
681
  const rawHPath = String($item.path || $item.short || '');
678
- const mForm = rawHPath.match(/^(.*?)\/(?:~|\$[^/]+(?:\/\$[^/]+)*)\/handlers\/pages\/form(?:\/([^/$]+))?/);
682
+ const mPage = rawHPath.match(/^(.*?)\/(?:~|\$[^/]+(?:\/\$[^/]+)*)\/handlers\/pages\/([^/$]+)(?:\/([^/$]+))?/);
679
683
  const rawSelf = $item[R]?.target || $item;
680
684
  const ctx = (Object.prototype.hasOwnProperty.call(rawSelf, '$context') || Object.prototype.hasOwnProperty.call($item, '$context'))
681
685
  ? await $item.$context
682
686
  : null;
683
687
  if (ctx && ctx.type !== '$handler') {
684
- const viewId = mForm?.[2] || ($item.id && $item.id !== 'form' ? $item.id : '');
688
+ const pageName = mPage?.[2] || 'form';
689
+ const viewId = pageName === 'form' ? (mPage?.[3] || ($item.id && $item.id !== 'form' ? $item.id : '')) : '';
690
+ pageHandlerMeta = pageName !== 'form'
691
+ ? { page: pageName, label: $item.DATA?.label || $item.label || pageName, icon: $item.DATA?.icon || $item.icon || '' }
692
+ : null;
685
693
  $item = ctx;
686
- if (viewId)
687
- nav = { ...(nav && typeof nav === 'object' ? nav : {}), view: viewId };
694
+ nav = {
695
+ ...(nav && typeof nav === 'object' ? nav : {}),
696
+ ...(pageName !== 'form' ? { page: pageName } : (viewId ? { view: viewId } : {})),
697
+ };
688
698
  }
689
699
  }
700
+ const pageName = ($item.type !== '$handler' && nav?.page) ? String(nav.page) : ($item.page || 'form');
690
701
  const short = $item?.short ?? $item?.path ?? '';
691
- const dataRoot = ($item?.type !== '$handler') ? this._resolveDataRootPath(short, $item) : '';
702
+ const dataRoot = ($item?.type !== '$handler' && pageName === 'form') ? this._resolveDataRootPath(short, $item) : '';
692
703
  const openShort = dataRoot || short;
693
704
  const navKey = openShort || '/';
694
705
  const effectiveNav = dataRoot
@@ -703,10 +714,13 @@ export default {
703
714
  }
704
715
  let hash = '#' + openShort;
705
716
  if ($item.type !== '$handler')
706
- hash += '/~/handlers/pages/' + ($item.page || 'form');
717
+ hash += '/~/handlers/pages/' + pageName;
707
718
  history.replaceState(null, '', window.location.pathname + hash);
708
- const fullUrl = encodeURI(window.location.origin + openShort + ($item.type !== '$handler' ? '/~/handlers/pages/' + ($item.page || 'form') : '') + '/index.html');
709
- const bm = this._upsertBookmarkForUrl(fullUrl, openShort === short ? $item : null);
719
+ const fullUrl = encodeURI(window.location.origin + openShort + ($item.type !== '$handler' ? '/~/handlers/pages/' + pageName : '') + '/index.html');
720
+ const pageLabelPrefix = pageName !== 'form'
721
+ ? (pageHandlerMeta?.label || ({ data: 'Данные', site: 'Сайт', storage: 'Хранилище', explorer: 'Проводник' }[pageName]) || pageName)
722
+ : '';
723
+ const bm = this._upsertBookmarkForUrl(fullUrl, openShort === short ? $item : null, pageLabelPrefix, pageHandlerMeta?.icon || (pageName === 'data' ? 'carbon:data-base' : ''));
710
724
  if (openShort !== short && bm) {
711
725
  const itemStateKey = ($item && ('_stateKey' in Object($item)) && $item._stateKey) ? String($item._stateKey) : '';
712
726
  if (itemStateKey && itemStateKey.includes('#place:') && itemStateKey.includes('->')) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "odant-work",
3
- "version": "1.0.66",
3
+ "version": "1.0.67",
4
4
  "description": "ODANT-WORK — платформа цифровой организации (встроенная система учёта, документооборот, управление процессами и приватный мультимодальный ИИ)",
5
5
  "type": "module",
6
6
  "main": "sources/work.js",
@@ -67,17 +67,36 @@ export class $handler extends $class{
67
67
  }
68
68
  async execute(...params) {
69
69
  const rawPath = String(this.path || this.short || '');
70
- const formViewMatch = rawPath.match(/\/handlers\/pages\/form(?:\/([^/$]+))?/);
71
- if (formViewMatch && window.execute) {
72
- const viewId = formViewMatch[1] || (this.id && this.id !== 'form' ? this.id : '');
70
+ const pageMatch = rawPath.match(/\/handlers\/pages\/([^/$]+)(?:\/([^/$]+))?/);
71
+ const execFn = (typeof window !== 'undefined' && (window.execute || window.top?.execute)) || null;
72
+ if (pageMatch && execFn) {
73
+ const pageName = pageMatch[1];
74
+ const subView = pageMatch[2] || '';
73
75
  const rawSelf = this[R]?.target || this;
74
76
  const hasOwnCtx = Object.prototype.hasOwnProperty.call(rawSelf, '$context') || Object.prototype.hasOwnProperty.call(this, '$context');
75
77
  const ctx = hasOwnCtx ? await this.$context : null;
78
+ const ev = params?.[0];
79
+ if (ev?.ctrlKey || ev?.shiftKey || ev?.metaKey) {
80
+ const targetShort = (ctx && ctx.type !== '$handler' ? ctx.short : this.short) || '';
81
+ const url = (ctx && ctx.type !== '$handler')
82
+ ? `${targetShort}/~/handlers/pages/${pageName}/`
83
+ : `${this.short}/`;
84
+ window.open(encodeURI(url), '_blank');
85
+ return;
86
+ }
87
+ let nav;
88
+ if (pageName === 'form') {
89
+ const viewId = subView || (this.id && this.id !== 'form' ? this.id : '');
90
+ nav = viewId ? { view: viewId } : undefined;
91
+ }
92
+ else {
93
+ nav = { page: pageName };
94
+ }
76
95
  if (ctx && ctx.type !== '$handler') {
77
- window.execute(ctx, viewId ? { view: viewId } : undefined);
96
+ execFn(ctx, nav);
78
97
  return;
79
98
  }
80
- window.execute(this, viewId ? { view: viewId } : undefined);
99
+ execFn(this, nav);
81
100
  return;
82
101
  }
83
102
 
@@ -87,8 +106,8 @@ export class $handler extends $class{
87
106
  return;
88
107
  }
89
108
 
90
- if (this.short.includes('form') && window.execute) {
91
- window.execute(this);
109
+ if (this.short.includes('form') && execFn) {
110
+ execFn(this);
92
111
  return;
93
112
  }
94
113
  window.open(this.short + '/');
@@ -467,6 +467,17 @@ async function logOperationFact(db, item, op, action, uid, p) {
467
467
  }
468
468
  }
469
469
 
470
+ let _triggersMod = null;
471
+ function emitDbTrigger(eventName, payload) {
472
+ globalThis.__workPendingTriggers = (globalThis.__workPendingTriggers || 0) + 1;
473
+ (_triggersMod ??= import('../modules/agent/triggers.js'))
474
+ .then(m => m.onDbEvent?.(eventName, payload))
475
+ .catch(() => {})
476
+ .finally(() => {
477
+ globalThis.__workPendingTriggers = Math.max(0, (globalThis.__workPendingTriggers || 1) - 1);
478
+ });
479
+ }
480
+
470
481
  /**
471
482
  * Схема для форм: у полей-ссылок (и в строках табличных частей, и в расширениях) к `target` (cid)
472
483
  * добавлен `targetPath` — форма и поле-ссылка открывают класс по пути дерева (`WORK.get_item`), а не по cid.
@@ -831,8 +842,10 @@ export const DATA_METHODS = Object.freeze({
831
842
  cid: cls.cid, body: bodyOf(p) ?? {}, time: p.time, unit: at.unit, place: at.place,
832
843
  ext_of: p.ext_of, valid_from: p.valid_from, basis_id: p.basis_id, basis_note: p.basis_note, author: uid,
833
844
  });
834
- if (obj)
845
+ if (obj) {
835
846
  await logOperationFact(db, item, obj, obj.status === 'registered' ? 'Проведено' : 'Создано', uid, p);
847
+ emitDbTrigger(obj.status === 'registered' ? 'db:register' : 'db:create', { basePath: resolveBasePath(item.path), cls, obj, params: p });
848
+ }
836
849
  return obj;
837
850
  }) },
838
851
 
@@ -849,10 +862,15 @@ export const DATA_METHODS = Object.freeze({
849
862
  db_versions: { level: 'read', fn: method('read', async ({ db, cls, p, vis }) => objectVersions(db, await visibleObject(db, cls, p.id, vis, p))) },
850
863
 
851
864
  /** Изменить объект: { id, post|body, replace?, time?, valid_from?, version? }. */
852
- db_update: { level: 'write', fn: method('write', ({ db, cls, p, uid, vis }) => updateObject(db, {
853
- id: ownObject(db, cls, p.id, vis), body: bodyOf(p), replace: flag(p.replace), time: p.time,
854
- valid_from: p.valid_from, version: p.version, author: uid,
855
- })) },
865
+ db_update: { level: 'write', fn: method('write', ({ db, cls, item, p, uid, vis }) => {
866
+ const obj = updateObject(db, {
867
+ id: ownObject(db, cls, p.id, vis), body: bodyOf(p), replace: flag(p.replace), time: p.time,
868
+ valid_from: p.valid_from, version: p.version, author: uid,
869
+ });
870
+ if (obj)
871
+ emitDbTrigger('db:update', { basePath: resolveBasePath(item.path), cls, obj, params: p });
872
+ return obj;
873
+ }) },
856
874
 
857
875
  /** Удалить объект (отметка): { id, version? }. */
858
876
  db_delete: { level: 'write', fn: method('write', ({ db, cls, p, uid, vis }) => deleteObject(db, { id: ownObject(db, cls, p.id, vis), version: p.version, author: uid })) },
@@ -886,6 +904,8 @@ export const DATA_METHODS = Object.freeze({
886
904
  db_register: { level: 'write', fn: method('write', async ({ db, cls, item, p, uid, vis }) => {
887
905
  const op = registerOperation(db, { id: ownObject(db, cls, p.id, vis), version: p.version, author: uid });
888
906
  await logOperationFact(db, item, op, 'Проведено', uid, p);
907
+ if (op)
908
+ emitDbTrigger('db:register', { basePath: resolveBasePath(item.path), cls, obj: op, params: p });
889
909
  return op;
890
910
  }) },
891
911
 
@@ -9,6 +9,7 @@
9
9
  import { log } from './log.js';
10
10
  import { runLoop, pickAllowedEffort } from './loop.js';
11
11
  import { workTools, accountingTools, classTools, contextConeOf } from './tools/work.js';
12
+ import { twinTools } from './twin-bus.js';
12
13
  import { webTools, serviceTools, mcpTools } from './tools/services.js';
13
14
  import { metaTools, listing, MAX_DEPTH } from './tools/meta.js';
14
15
  import { connectTools } from './tools/connect.js';
@@ -448,7 +449,7 @@ export async function createEnv({ place, contextPath, session, host, tz, locatio
448
449
  * restrict — ограничение call родителя, пережившее перезапуск (body.callRestrict дочерней задачи, R3/8.31).
449
450
  */
450
451
  async makeTools(def, depth = 0, parent = null, restrict = null) {
451
- let all = [...workTools, ...accountingTools, ...classTools, ...devSearchTools, ...devPatchTools, ...devGitTools, ...devCheckTools, ...devLspTools, ...branchTools, ...pluginTools, ...docTools, ...memoryTools, ...webTools, ...connectTools, ...browseTools, ...metaTools, ...scheduleTools, ...await env.extTools()];
452
+ let all = [...workTools, ...accountingTools, ...classTools, ...twinTools, ...devSearchTools, ...devPatchTools, ...devGitTools, ...devCheckTools, ...devLspTools, ...branchTools, ...pluginTools, ...docTools, ...memoryTools, ...webTools, ...connectTools, ...browseTools, ...metaTools, ...scheduleTools, ...await env.extTools()];
452
453
  // не-администратор этих инструментов даже не видит
453
454
  if (await system())
454
455
  all.push(...SYSTEM_TOOLS);
@@ -471,6 +472,15 @@ export async function createEnv({ place, contextPath, session, host, tz, locatio
471
472
  all = all.filter(t => !egressToolName(t.name));
472
473
  if (depth >= MAX_DEPTH)
473
474
  all = all.filter(t => t.name !== 'task');
475
+ if (session?.twinCall) {
476
+ const TWIN_SERVICE_DENY = new Set([
477
+ 'create_class', 'update_class', 'move_class', 'delete_class',
478
+ 'assign', 'escalate', 'delete',
479
+ 'dev_write', 'dev_edit', 'dev_patch', 'dev_git', 'dev_shell',
480
+ 'shell', 'restart_server', 'os_write', 'os_rm',
481
+ ]);
482
+ all = all.filter(t => !t.system && !TWIN_SERVICE_DENY.has(t.name));
483
+ }
474
484
  if (!def)
475
485
  return all;
476
486
  all = all.filter(t => !SUBAGENT_DENY.has(t.name));