odant-work 1.0.101 → 1.0.103
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.
- package/$server/$folder/$class/$structure/$department/ai/config.js +9 -0
- package/$server/$folder/$class/$structure/$department/ai/system.md +11 -0
- package/$server/$folder/$class/$structure/$department/class.js +9 -0
- package/$server/$folder/$class/$structure/$project/ai/config.js +9 -0
- package/$server/$folder/$class/$structure/$project/ai/system.md +12 -0
- package/$server/$folder/$class/$structure/$project/class.js +4 -1
- package/$server/$folder/$class/$structure/$project/handlers/pages/site/$handler/class.js +1 -1
- package/$server/$folder/$class/$structure/$server/ai/config.js +9 -0
- package/$server/$folder/$class/$structure/$server/ai/system.md +10 -0
- package/$server/$folder/$class/$structure/$server/class.js +2 -0
- package/$server/$folder/$class/$structure/$user/ai/config.js +9 -0
- package/$server/$folder/$class/$structure/$user/ai/system.md +8 -0
- package/$server/$folder/$class/$structure/$user/class.js +2 -0
- package/$server/$folder/$class/$structure/ai/system.md +1 -1
- package/$server/$folder/$class/$structure/class.js +4 -2
- package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/chat-task.js +17 -6
- package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +91 -22
- package/$server/$folder/$class/$structure/handlers/pages/form/system/agent/$handler/class.js +132 -3
- package/$server/$folder/$class/$structure/handlers/pages/form/system/staff/$handler/class.js +2 -2
- package/$server/$folder/$class/$structure/handlers/pages/site/$handler/class.js +2 -1
- package/$server/$folder/$class/ai/system.md +2 -2
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/class.js +38 -8
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/dock.js +22 -31
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/util.js +32 -0
- package/$server/$folder/handlers/pages/form/$handler/class.js +47 -5
- package/$server/$folder/lib/chat-item/chat-item.js +14 -2
- package/$server/$folder/lib/consultant/consultant.js +81 -4
- package/$server/$folder/lib/explorer/explorer.js +20 -11
- package/$server/$folder/lib/icon/icon.js +1 -1
- package/$server/$folder/lib/node/node.js +3 -3
- package/$server/$folder/lib/site-loc/site-loc.js +8 -3
- package/$server/$folder/lib/tree/tree.js +8 -8
- package/AGENTS.md +3 -3
- package/autostart.bat +28 -0
- package/autostart.sh +17 -0
- package/package.json +1 -1
- package/run.mjs +19 -0
- package/scripts/autostart.mjs +281 -0
- package/scripts/import-bis.mjs +5 -5
- package/scripts/import-delovaya.mjs +5 -5
- package/scripts/watchdog.mjs +496 -0
- package/sources/client/class.js +1 -1
- package/sources/client.js +141 -8
- package/sources/data/api.js +1 -1
- package/sources/data/classes.js +2 -1
- package/sources/data/schema.js +2 -0
- package/sources/host/auth-methods.js +3 -1
- package/sources/host/auto-updater.js +23 -1
- package/sources/host/http-server.js +5 -3
- package/sources/host/push.js +43 -14
- package/sources/host/websocket.js +52 -3
- package/sources/modules/agent/index.js +38 -10
- package/sources/modules/agent/node-rules.js +353 -9
- package/sources/modules/agent/scheduler.js +7 -0
- package/sources/modules/agent/scope.js +8 -6
- package/sources/modules/agent/session.js +38 -8
- package/sources/modules/agent/tools/work/access.js +1 -1
- package/sources/modules/agent/tools/work/classes.js +1 -1
- package/sources/modules/agent/triggers.js +1 -1
- package/sources/modules/agent/twin-bus.js +2 -1
- package/sources/modules/notify/index.js +5 -2
- package/sources/modules/trainer/local-engine.js +3 -1
- package/sources/modules/user-profile/user-profile.js +129 -0
- package/sources/server/access/gateway.js +5 -3
- package/sources/server/access/links.js +9 -6
- package/sources/server/chat-threads.js +1 -1
- package/sources/server/class/base-template.js +3 -2
- package/sources/server/class/feed.js +36 -0
- package/sources/server/class/scaffold.js +137 -0
- package/sources/server/class/search.js +2 -2
- package/sources/server/class/security.js +1 -1
- package/sources/server/class.js +5 -3
- package/sources/server/folder.js +10 -6
- package/sources/server/logs.js +14 -0
- package/sources/server/node.js +1 -1
- package/sources/server/server.js +50 -1
- package/sources/server/user.js +45 -0
- package/sources/work.js +7 -0
- package/start.bat +25 -0
- package/start.sh +27 -0
- package/stop.bat +25 -0
- package/stop.sh +16 -0
- package/sw.js +3 -11
|
@@ -12,7 +12,7 @@ import './ui/dock.js';
|
|
|
12
12
|
import './ui/voice-ui.js';
|
|
13
13
|
import { VoiceController } from './ui/voice.js';
|
|
14
14
|
import { collectDocs, computeStats, stableDocs, activityOf, taskFiles, computerUse, realPathOfSnapshot } from './ui/docs.js';
|
|
15
|
-
import { pathOfWorkHref, workHref } from './ui/util.js';
|
|
15
|
+
import { pathOfWorkHref, workHref, playTaskCompletionClick } from './ui/util.js';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Клик по WORK-ссылке в markdown (событие md-link от oda-markdown-viewer):
|
|
@@ -111,6 +111,8 @@ export default {
|
|
|
111
111
|
},
|
|
112
112
|
inForm: false,
|
|
113
113
|
closable: false,
|
|
114
|
+
/** Узел, в метапапке которого лежит файл .task (точка работы задачи). */
|
|
115
|
+
ownerPoint: null,
|
|
114
116
|
/** Внешний вид персонажа (ai/config.js dot); грузится один раз. */
|
|
115
117
|
look: null,
|
|
116
118
|
__microchatShell: true,
|
|
@@ -144,22 +146,41 @@ export default {
|
|
|
144
146
|
this.computerChecked = false;
|
|
145
147
|
}
|
|
146
148
|
this._bound = n || null;
|
|
149
|
+
this._hasActiveRun = false;
|
|
147
150
|
if (!n) return;
|
|
148
151
|
this._h = {
|
|
149
152
|
'changed': () => this._reload(),
|
|
150
153
|
'task.delta': e => this._onDelta(e.detail?.value),
|
|
154
|
+
'chat.start': () => {
|
|
155
|
+
this._hasActiveRun = true;
|
|
156
|
+
},
|
|
151
157
|
'task.state': e => {
|
|
152
158
|
const s = e.detail?.value?.status;
|
|
153
159
|
if (s) {
|
|
160
|
+
const prevStatus = this.status;
|
|
154
161
|
this.status = s;
|
|
155
162
|
this._lastDelta = Date.now();
|
|
163
|
+
if (s === 'running') this._hasActiveRun = true;
|
|
164
|
+
else if (s === 'waiting' && (this._hasActiveRun || prevStatus === 'running') && this._isOnScreen()) {
|
|
165
|
+
this._hasActiveRun = false;
|
|
166
|
+
playTaskCompletionClick();
|
|
167
|
+
}
|
|
156
168
|
}
|
|
157
169
|
},
|
|
158
170
|
'task.moved': e => this._handleTaskMoved(e.detail?.value || e.detail),
|
|
159
|
-
'chat.done': () =>
|
|
171
|
+
'chat.done': () => {
|
|
172
|
+
if (this._hasActiveRun && this._isOnScreen()) playTaskCompletionClick();
|
|
173
|
+
this._hasActiveRun = false;
|
|
174
|
+
this._reload();
|
|
175
|
+
}
|
|
160
176
|
};
|
|
161
177
|
for (const [k, fn] of Object.entries(this._h)) n.listen(k, fn);
|
|
162
178
|
this._reload();
|
|
179
|
+
this.ownerPoint = null;
|
|
180
|
+
Promise.resolve(n.$class).catch(() => null).then(async pt => {
|
|
181
|
+
if (!pt) pt = await Promise.resolve(n.$owner).catch(() => null);
|
|
182
|
+
if (this._bound === n && pt) this.ownerPoint = pt;
|
|
183
|
+
});
|
|
163
184
|
n.fetch('dot_look').then(l => {
|
|
164
185
|
if (this._bound === n && l) this.look = l;
|
|
165
186
|
}).catch(() => {});
|
|
@@ -176,7 +197,7 @@ export default {
|
|
|
176
197
|
*/
|
|
177
198
|
_watchPresence() {
|
|
178
199
|
this._presenceIO ??= new IntersectionObserver(entries => {
|
|
179
|
-
|
|
200
|
+
this._notifyPresence(entries.some(e => e.isIntersecting));
|
|
180
201
|
});
|
|
181
202
|
this._presenceIO.observe(this);
|
|
182
203
|
this._presenceOnVis = () => this._notifyPresence();
|
|
@@ -185,10 +206,11 @@ export default {
|
|
|
185
206
|
// (в чате адрес не содержит путь задачи — сравнивать URL недостаточно)
|
|
186
207
|
this._presenceOnSw = e => {
|
|
187
208
|
const msg = e?.data;
|
|
209
|
+
const port = e?.ports?.[0] || msg?.port;
|
|
188
210
|
const mine = this._bound?.path || this.$item?.path;
|
|
189
|
-
if (msg?.type !== 'work:is-task-visible' || !
|
|
211
|
+
if (msg?.type !== 'work:is-task-visible' || !port || !mine || msg.path !== mine) return;
|
|
190
212
|
if (this._isOnScreen()) try {
|
|
191
|
-
|
|
213
|
+
port.postMessage({
|
|
192
214
|
visible: true
|
|
193
215
|
});
|
|
194
216
|
} catch {/* порт закрыт */}
|
|
@@ -197,6 +219,8 @@ export default {
|
|
|
197
219
|
this.async(() => this._notifyPresence(), 150);
|
|
198
220
|
},
|
|
199
221
|
_unwatchPresence() {
|
|
222
|
+
const p = this._bound?.path || this.$item?.path;
|
|
223
|
+
if (p) globalThis.WORK?.setTaskPresence?.(p, false);
|
|
200
224
|
this._presenceIO?.disconnect();
|
|
201
225
|
this._presenceIO = null;
|
|
202
226
|
if (this._presenceOnVis) document.removeEventListener('visibilitychange', this._presenceOnVis);
|
|
@@ -213,9 +237,12 @@ export default {
|
|
|
213
237
|
h = window.innerHeight || 0;
|
|
214
238
|
return r.bottom > 0 && r.right > 0 && r.top < h && r.left < w;
|
|
215
239
|
},
|
|
216
|
-
_notifyPresence() {
|
|
240
|
+
_notifyPresence(intersecting) {
|
|
217
241
|
const path = this._bound?.path || this.$item?.path;
|
|
218
|
-
if (!path
|
|
242
|
+
if (!path) return;
|
|
243
|
+
const visible = intersecting === false ? false : this._isOnScreen();
|
|
244
|
+
globalThis.WORK?.setTaskPresence?.(path, visible);
|
|
245
|
+
if (!visible) return;
|
|
219
246
|
try {
|
|
220
247
|
navigator.serviceWorker?.ready?.then(reg => reg.active?.postMessage({
|
|
221
248
|
type: 'work:task-visible',
|
|
@@ -489,6 +516,7 @@ export default {
|
|
|
489
516
|
}
|
|
490
517
|
};
|
|
491
518
|
this._lastDelta = Date.now();
|
|
519
|
+
this._hasActiveRun = true;
|
|
492
520
|
if (this.status !== 'running') this.status = 'running';
|
|
493
521
|
if (/^(?:computer_|sandbox_)/.test(String(d.name || '')) && d.name !== 'computer_destroy') this._openMonitorOnce();
|
|
494
522
|
this._stick();
|
|
@@ -537,6 +565,7 @@ export default {
|
|
|
537
565
|
const prevComputerUsed = Boolean(this._cu?.used);
|
|
538
566
|
this.data = data;
|
|
539
567
|
this.status = data.status || 'idle';
|
|
568
|
+
if (this.status === 'running') this._hasActiveRun = true;
|
|
540
569
|
this._lastDelta = Date.now();
|
|
541
570
|
this._noticeDocs(before);
|
|
542
571
|
if (this.computer.used) {
|
|
@@ -665,6 +694,7 @@ export default {
|
|
|
665
694
|
};
|
|
666
695
|
this.pinned = true;
|
|
667
696
|
this.status = 'running';
|
|
697
|
+
this._hasActiveRun = true;
|
|
668
698
|
this._stick();
|
|
669
699
|
},
|
|
670
700
|
toast(text) {
|
|
@@ -682,7 +712,7 @@ export default {
|
|
|
682
712
|
try {
|
|
683
713
|
navigator.serviceWorker.controller.postMessage({
|
|
684
714
|
type: 'work:task-visible',
|
|
685
|
-
|
|
715
|
+
path: this.$item.path
|
|
686
716
|
});
|
|
687
717
|
} catch {/* ignore */}
|
|
688
718
|
}
|
|
@@ -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:
|
|
62
|
-
:host([inline]) { padding: 0
|
|
63
|
-
:host([inline]) .title { font-weight:
|
|
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
|
-
.
|
|
66
|
-
.chip
|
|
67
|
-
.chip[
|
|
68
|
-
.chip[
|
|
69
|
-
|
|
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: .
|
|
71
|
+
display: flex; align-items: center; justify-content: center; opacity: .85;
|
|
74
72
|
}
|
|
75
|
-
.dialog-btn:hover { background:
|
|
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:
|
|
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:
|
|
91
|
-
|
|
85
|
+
oda-button[on] { background: rgba(255,255,255,.2); }
|
|
86
|
+
.close-btn { border-radius: 50% !important; flex-shrink: 0; }
|
|
92
87
|
</style>
|
|
93
|
-
<
|
|
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=".
|
|
105
|
-
<circle cx="12" cy="12" r="10" fill="none" stroke="
|
|
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="
|
|
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' };
|
|
@@ -546,3 +546,35 @@ export function resultMarkdown(t) {
|
|
|
546
546
|
return r;
|
|
547
547
|
return '```\n' + r.replace(/```/g, '``\u200b`') + '\n```';
|
|
548
548
|
}
|
|
549
|
+
|
|
550
|
+
let _clickAudioCtx = null;
|
|
551
|
+
/** Тихий короткий звуковой щелчок по завершении ответа или переходе в ожидание при открытом чате. */
|
|
552
|
+
export function playTaskCompletionClick() {
|
|
553
|
+
try {
|
|
554
|
+
if (globalThis.WORK?.userSettings?.chatSound === false)
|
|
555
|
+
return false;
|
|
556
|
+
const AC = globalThis.AudioContext || globalThis.webkitAudioContext;
|
|
557
|
+
if (!AC)
|
|
558
|
+
return false;
|
|
559
|
+
const ctx = _clickAudioCtx ??= new AC();
|
|
560
|
+
if (ctx.state === 'suspended')
|
|
561
|
+
ctx.resume?.().catch(() => {});
|
|
562
|
+
const now = ctx.currentTime;
|
|
563
|
+
const osc = ctx.createOscillator();
|
|
564
|
+
const gain = ctx.createGain();
|
|
565
|
+
osc.type = 'triangle';
|
|
566
|
+
osc.frequency.setValueAtTime(920, now);
|
|
567
|
+
osc.frequency.exponentialRampToValueAtTime(420, now + 0.032);
|
|
568
|
+
gain.gain.setValueAtTime(0.001, now);
|
|
569
|
+
gain.gain.linearRampToValueAtTime(0.055, now + 0.004);
|
|
570
|
+
gain.gain.exponentialRampToValueAtTime(0.0001, now + 0.038);
|
|
571
|
+
osc.connect(gain);
|
|
572
|
+
gain.connect(ctx.destination);
|
|
573
|
+
osc.start(now);
|
|
574
|
+
osc.stop(now + 0.042);
|
|
575
|
+
return true;
|
|
576
|
+
}
|
|
577
|
+
catch {
|
|
578
|
+
return false;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
@@ -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
|
|
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
|
|
904
|
+
return found;
|
|
893
905
|
})
|
|
894
906
|
},
|
|
895
907
|
get hideAvatar() {
|
|
@@ -18,6 +18,7 @@ let _pathOfWorkHref = null;
|
|
|
18
18
|
let _resolveClientLocation = null;
|
|
19
19
|
let _dotStateOfTask = null;
|
|
20
20
|
let _VoiceController = null;
|
|
21
|
+
let _playTaskCompletionClick = null;
|
|
21
22
|
|
|
22
23
|
function ensureConsultantUI() {
|
|
23
24
|
return _uiLoaded ??= Promise.all([
|
|
@@ -28,6 +29,7 @@ function ensureConsultantUI() {
|
|
|
28
29
|
import('/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/util.js').then(m => {
|
|
29
30
|
_pathOfWorkHref = m.pathOfWorkHref;
|
|
30
31
|
_resolveClientLocation = m.resolveClientLocation;
|
|
32
|
+
_playTaskCompletionClick = m.playTaskCompletionClick;
|
|
31
33
|
_resolveClientLocation?.(0)?.catch?.(() => {});
|
|
32
34
|
}),
|
|
33
35
|
import('/$server/$folder/lib/dot/dot.js'),
|
|
@@ -672,7 +674,7 @@ ODA({
|
|
|
672
674
|
prompt: `Покажи схему операции «${lbl}» (${ctx.path}), её проводки и последние зарегистрированные документы.`,
|
|
673
675
|
};
|
|
674
676
|
}
|
|
675
|
-
if (t === '$structure' || t === '$project' || t === '$server') {
|
|
677
|
+
if ((ctx.DATA?.isStructure && !ctx.DATA?.isUser && t !== '$user') || t === '$structure' || t === '$project' || t === '$server') {
|
|
676
678
|
return {
|
|
677
679
|
icon: 'icons:supervisor-account',
|
|
678
680
|
label: `Проверить роли BOSS, рабочие места и ленту «${lbl}»`,
|
|
@@ -773,8 +775,10 @@ ODA({
|
|
|
773
775
|
if (col)
|
|
774
776
|
this._ro.observe(col);
|
|
775
777
|
}, 50);
|
|
778
|
+
this._watchPresence();
|
|
776
779
|
},
|
|
777
780
|
detached() {
|
|
781
|
+
this._unwatchPresence();
|
|
778
782
|
this._unbindTask();
|
|
779
783
|
this._voice?.disable();
|
|
780
784
|
this.voiceOn = false;
|
|
@@ -1152,26 +1156,99 @@ ODA({
|
|
|
1152
1156
|
}
|
|
1153
1157
|
},
|
|
1154
1158
|
|
|
1159
|
+
_watchPresence() {
|
|
1160
|
+
this._presenceIO ??= new IntersectionObserver(entries => {
|
|
1161
|
+
this._notifyPresence(entries.some(e => e.isIntersecting));
|
|
1162
|
+
});
|
|
1163
|
+
this._presenceIO.observe(this);
|
|
1164
|
+
this._presenceOnVis = () => this._notifyPresence();
|
|
1165
|
+
document.addEventListener('visibilitychange', this._presenceOnVis);
|
|
1166
|
+
this._presenceOnSw = e => {
|
|
1167
|
+
const msg = e?.data;
|
|
1168
|
+
const port = e?.ports?.[0] || msg?.port;
|
|
1169
|
+
const mine = this.taskItem?.path;
|
|
1170
|
+
if (msg?.type !== 'work:is-task-visible' || !port || !mine || msg.path !== mine)
|
|
1171
|
+
return;
|
|
1172
|
+
if (this._isOnScreen()) {
|
|
1173
|
+
try { port.postMessage({ visible: true }); } catch { /* ignore */ }
|
|
1174
|
+
}
|
|
1175
|
+
};
|
|
1176
|
+
navigator.serviceWorker?.addEventListener?.('message', this._presenceOnSw);
|
|
1177
|
+
this.async(() => this._notifyPresence(), 150);
|
|
1178
|
+
},
|
|
1179
|
+
_unwatchPresence() {
|
|
1180
|
+
const p = this.taskItem?.path;
|
|
1181
|
+
if (p) globalThis.WORK?.setTaskPresence?.(p, false);
|
|
1182
|
+
this._presenceIO?.disconnect();
|
|
1183
|
+
this._presenceIO = null;
|
|
1184
|
+
if (this._presenceOnVis) document.removeEventListener('visibilitychange', this._presenceOnVis);
|
|
1185
|
+
this._presenceOnVis = null;
|
|
1186
|
+
if (this._presenceOnSw) navigator.serviceWorker?.removeEventListener?.('message', this._presenceOnSw);
|
|
1187
|
+
this._presenceOnSw = null;
|
|
1188
|
+
},
|
|
1189
|
+
_isOnScreen() {
|
|
1190
|
+
if (document.visibilityState !== 'visible' || !this.isConnected)
|
|
1191
|
+
return false;
|
|
1192
|
+
const r = this.getBoundingClientRect?.();
|
|
1193
|
+
if (!r || r.width < 2 || r.height < 2)
|
|
1194
|
+
return false;
|
|
1195
|
+
const w = window.innerWidth || 0;
|
|
1196
|
+
const h = window.innerHeight || 0;
|
|
1197
|
+
return r.bottom > 0 && r.right > 0 && r.top < h && r.left < w;
|
|
1198
|
+
},
|
|
1199
|
+
_notifyPresence(intersecting) {
|
|
1200
|
+
const path = this.taskItem?.path;
|
|
1201
|
+
if (!path) return;
|
|
1202
|
+
const visible = intersecting === false ? false : this._isOnScreen();
|
|
1203
|
+
globalThis.WORK?.setTaskPresence?.(path, visible);
|
|
1204
|
+
if (!visible) return;
|
|
1205
|
+
try {
|
|
1206
|
+
navigator.serviceWorker?.ready?.then(reg => reg.active?.postMessage({ type: 'work:task-visible', path })).catch(() => {});
|
|
1207
|
+
} catch { /* ignore */ }
|
|
1208
|
+
},
|
|
1155
1209
|
_bindTask(task) {
|
|
1210
|
+
const prevPath = this.taskItem?.path;
|
|
1211
|
+
if (prevPath && prevPath !== task?.path)
|
|
1212
|
+
globalThis.WORK?.setTaskPresence?.(prevPath, false);
|
|
1156
1213
|
this._unbindTask();
|
|
1157
1214
|
this.taskItem = task || null;
|
|
1215
|
+
this._hasActiveRun = false;
|
|
1158
1216
|
if (!task)
|
|
1159
1217
|
return;
|
|
1160
1218
|
this._taskHandlers = {
|
|
1161
1219
|
'changed': () => this._reloadTask(),
|
|
1162
|
-
'task.delta': e =>
|
|
1220
|
+
'task.delta': e => {
|
|
1221
|
+
this._hasActiveRun = true;
|
|
1222
|
+
this._onDelta(e.detail?.value);
|
|
1223
|
+
},
|
|
1224
|
+
'chat.start': () => {
|
|
1225
|
+
this._hasActiveRun = true;
|
|
1226
|
+
},
|
|
1163
1227
|
'task.state': e => {
|
|
1164
1228
|
const s = e.detail?.value?.status;
|
|
1165
1229
|
if (s) {
|
|
1230
|
+
const prev = this.status;
|
|
1166
1231
|
this.status = s;
|
|
1167
1232
|
this._lastDelta = Date.now();
|
|
1233
|
+
if (s === 'running')
|
|
1234
|
+
this._hasActiveRun = true;
|
|
1235
|
+
else if (s === 'waiting' && (this._hasActiveRun || prev === 'running') && this._isOnScreen()) {
|
|
1236
|
+
this._hasActiveRun = false;
|
|
1237
|
+
_playTaskCompletionClick?.();
|
|
1238
|
+
}
|
|
1168
1239
|
}
|
|
1169
1240
|
},
|
|
1170
|
-
'chat.done': () =>
|
|
1241
|
+
'chat.done': () => {
|
|
1242
|
+
if (this._hasActiveRun && this._isOnScreen())
|
|
1243
|
+
_playTaskCompletionClick?.();
|
|
1244
|
+
this._hasActiveRun = false;
|
|
1245
|
+
this._reloadTask();
|
|
1246
|
+
},
|
|
1171
1247
|
};
|
|
1172
1248
|
for (const [k, fn] of Object.entries(this._taskHandlers))
|
|
1173
1249
|
task.listen?.(k, fn);
|
|
1174
1250
|
this._reloadTask();
|
|
1251
|
+
this._notifyPresence();
|
|
1175
1252
|
},
|
|
1176
1253
|
|
|
1177
1254
|
_unbindTask() {
|
|
@@ -1286,7 +1363,7 @@ ODA({
|
|
|
1286
1363
|
this.toast(res.error || 'Не удалось отправить ответ');
|
|
1287
1364
|
else if (this.taskItem?.path && navigator.serviceWorker?.controller) {
|
|
1288
1365
|
try {
|
|
1289
|
-
navigator.serviceWorker.controller.postMessage({ type: 'work:task-visible',
|
|
1366
|
+
navigator.serviceWorker.controller.postMessage({ type: 'work:task-visible', path: this.taskItem.path });
|
|
1290
1367
|
}
|
|
1291
1368
|
catch { /* ignore */ }
|
|
1292
1369
|
}
|
|
@@ -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:
|
|
140
|
+
icon: userIcon,
|
|
139
141
|
default: 'icons:account-circle',
|
|
140
|
-
style: `color: white; fill: white; background:${
|
|
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
|
-
|
|
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
|
-
|
|
184
|
+
const str = typeof res === 'string' && res ? res : '';
|
|
185
|
+
if (!str || str === this._resolvedUserIcon)
|
|
175
186
|
return;
|
|
176
|
-
|
|
177
|
-
|
|
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;
|