odant-work 1.0.66 → 1.0.68

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
+ };
@@ -1,21 +1,21 @@
1
- export default {
2
- icon: 'bootstrap:database-fill-gear',
3
- imports: '~/lib//explorer.js',
4
- extends: 'item-explorer',
5
- hideTops: 0,
6
- hideRoots: 1,
7
- showSize: true,
8
- itemsSelector: 'entries',
9
- async ready() {
10
- if (this.$item) {
11
- this.$context = this.$item;
12
- this.$item = undefined;
13
- this.$item = await this.$context.storage_folder;
14
- }
15
- },
16
- $public: {
17
- get allowUse() {
18
- return this.$item?.connstructor?.name !== '$file'
19
- }
20
- }
21
- }
1
+ export default {
2
+ icon: 'bootstrap:database-fill-gear',
3
+ imports: '~/lib//explorer.js',
4
+ extends: 'item-explorer',
5
+ hideTops: 0,
6
+ hideRoots: 1,
7
+ showSize: true,
8
+ itemsSelector: 'entries',
9
+ async ready() {
10
+ if (this.$item) {
11
+ this.$context = this.$item;
12
+ this.$item = undefined;
13
+ this.$item = await this.$context.storage_folder;
14
+ }
15
+ },
16
+ $public: {
17
+ get allowUse() {
18
+ return this.$item?.constructor?.name !== '$file';
19
+ }
20
+ }
21
+ }
@@ -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,23 @@ 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
+ if (!target)
917
+ return;
918
+ const short = target.short || target.path || '';
919
+ window.open(encodeURI(`${short}/~/handlers/pages/data/index.html`), '_blank');
920
+ },
902
921
  get hasClassTree() {
922
+ if (this._noClassTreeFlag)
923
+ return false;
924
+ if (typeof location !== 'undefined' && new URLSearchParams(location.search).get('noTree') === '1')
925
+ return false;
903
926
  const root = this._rootItem || this.$item;
904
927
  if (!root)
905
928
  return false;
@@ -31,6 +31,8 @@ export default {
31
31
  bookmarks: [],
32
32
  focusedPage: '',
33
33
  get hasBookmarks() {
34
+ if (typeof window !== 'undefined' && window !== window.top)
35
+ return false;
34
36
  return !this.mobile && Array.isArray(this.bookmarks) && this.bookmarks.length > 0 && this.visibleMode === 'main';
35
37
  },
36
38
  get bookmarkTabItems() {
@@ -101,6 +103,8 @@ export default {
101
103
  * через ~props логический `hidden` не применяет, поэтому кнопка висела всегда.
102
104
  */
103
105
  _buildLeftButtons() {
106
+ if (typeof window !== 'undefined' && window !== window.top)
107
+ return [];
104
108
  const user = WORK.USER;
105
109
  const buttons = [];
106
110
  if (top.RTCCaller?.current_call) {
@@ -197,7 +201,7 @@ export default {
197
201
  get icon() {
198
202
  return this.$handler?.icon;
199
203
  },
200
- hideRoots: 1,
204
+ hideRoots: 2,
201
205
  hideTops: 0,
202
206
  itemsSelector: 'items',
203
207
 
@@ -704,9 +708,11 @@ export default {
704
708
  let hash = '#' + openShort;
705
709
  if ($item.type !== '$handler')
706
710
  hash += '/~/handlers/pages/' + ($item.page || 'form');
707
- history.replaceState(null, '', window.location.pathname + hash);
711
+ const isTop = typeof window === 'undefined' || window === window.top;
712
+ if (isTop)
713
+ history.replaceState(null, '', window.location.pathname + hash);
708
714
  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);
715
+ const bm = isTop ? this._upsertBookmarkForUrl(fullUrl, openShort === short ? $item : null) : null;
710
716
  if (openShort !== short && bm) {
711
717
  const itemStateKey = ($item && ('_stateKey' in Object($item)) && $item._stateKey) ? String($item._stateKey) : '';
712
718
  if (itemStateKey && itemStateKey.includes('#place:') && itemStateKey.includes('->')) {
@@ -772,6 +778,11 @@ export default {
772
778
  }
773
779
  }
774
780
  }
781
+ const isTop = typeof window === 'undefined' || window === window.top;
782
+ if (!isTop) {
783
+ this.load_page();
784
+ return;
785
+ }
775
786
  const restored = this._restoreBookmarksState();
776
787
  const hasInitialHash = Boolean(window.location.hash && window.location.hash !== '#');
777
788
  if (!hasInitialHash && restored?.activeUrl) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "odant-work",
3
- "version": "1.0.66",
3
+ "version": "1.0.68",
4
4
  "description": "ODANT-WORK — платформа цифровой организации (встроенная система учёта, документооборот, управление процессами и приватный мультимодальный ИИ)",
5
5
  "type": "module",
6
6
  "main": "sources/work.js",
@@ -91,7 +91,14 @@ export class $handler extends $class{
91
91
  window.execute(this);
92
92
  return;
93
93
  }
94
- window.open(this.short + '/');
94
+ const pageMatch = rawPath.match(/\/handlers\/pages\/([^/$]+)/);
95
+ const rawSelf = this[R]?.target || this;
96
+ const hasOwnCtx = Object.prototype.hasOwnProperty.call(rawSelf, '$context') || Object.prototype.hasOwnProperty.call(this, '$context');
97
+ const ctx = hasOwnCtx ? await this.$context : null;
98
+ const url = (pageMatch && ctx && ctx.type !== '$handler')
99
+ ? `${ctx.short || ctx.path || ''}/~/handlers/pages/${pageMatch[1]}/`
100
+ : `${this.short}/`;
101
+ window.open(encodeURI(url), '_blank');
95
102
  }
96
103
  async showSettings(...params) {
97
104
  const module = await this.getModule();
@@ -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));