odant-work 1.0.99 → 1.0.101
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/#system/package-manifest.json +8 -8
- package/$server/$folder/$class/$structure/$user/class.js +1 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/profile/$handler/class.js +5 -2
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/staff/$handler/class.js +3 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/tokens/$handler/class.js +24 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/users/$handler/class.js +213 -0
- package/$server/$folder/lib/consultant/consultant.js +6 -1
- package/$server/$folder/lib/explorer/explorer.js +18 -1
- package/$server/$folder/lib/prompt-bar/prompt-bar.js +15 -1
- package/$server/$folder/lib/tree/tree.js +2 -3
- package/MODULES/$domain/class.js +1 -0
- package/MODULES//320/234/320/276/320/264/320/265/320/273/320/270/Local/$provider/class.js +1 -0
- package/{$server/$folder/$class/$users → USERS/$user}/class.js +4 -1
- package/oda/oda.js +15 -1
- package/package.json +1 -1
- package/readme.md +1 -1
- package/sources/client/handler.js +17 -5
- package/sources/client.js +68 -35
- package/sources/host/auth-methods.js +14 -3
- package/sources/modules/rag/extract.js +1 -1
- package/sources/modules/user-profile/user-profile.js +120 -115
- package/sources/modules/user-profile/user-tokens.js +185 -0
- package/sources/server/class/distro.js +9 -5
- package/sources/server/class/security.js +34 -10
- package/sources/server/folder.js +7 -7
- package/sources/server/user.js +3 -0
- package/USERS/$users/class.js +0 -4
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"packageName": "odant-work",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"createdAt":
|
|
5
|
-
"updatedAt":
|
|
3
|
+
"version": "1.0.100",
|
|
4
|
+
"createdAt": 1796221636211,
|
|
5
|
+
"updatedAt": 1796221636211,
|
|
6
6
|
"files": {
|
|
7
7
|
"run.mjs": "96274369c2ab29f293f787fbc1e371fc7e661f9577dccb2d1c245a866d193c77",
|
|
8
|
-
"package.json": "
|
|
9
|
-
"package-lock.json": "
|
|
8
|
+
"package.json": "bfe2cb05f9d5d62498b7bc1db83c5965cb63ee03322336c57b49d8e256cb9d5c",
|
|
9
|
+
"package-lock.json": "1dc6974607d303c3c790748e11a2c50dfca12e89f73a58d7e2217a1f1bbe39c7",
|
|
10
10
|
"sources/client/class.js": "ddd2862e2c78d337360a16a26f7af2ad28f603d58f480f39a0cc82192173050a",
|
|
11
11
|
"sources/client/field.js": "ffdd50fa8b6ec515cc42da5fca96658ff2b20e274601a1f926e0031372467a19",
|
|
12
12
|
"sources/client/file.js": "667101d75fa30840370d5be232e518aaac7c1fd52ca05a12da560eef6c0848b0",
|
|
13
13
|
"sources/client/folder.js": "7067540da0d766a09dd16fd1a39f20e41775f401cd4a6f10f5783bdf5ed9484d",
|
|
14
|
-
"sources/client/handler.js": "
|
|
14
|
+
"sources/client/handler.js": "21cd29a2212dcd5e8f3ae307d8ab43c38333482eab1710fc2383b103ba64b293",
|
|
15
15
|
"sources/client/index.js": "037ff635b149a617adf1219d34f0ba9dd936d5f60cea59e62d276a49468c3dc3",
|
|
16
16
|
"sources/client/readme.md": "a50aa4aa3a90606b2f446e2d29166aa26175ae87539901299e9347322ae4a2fe",
|
|
17
17
|
"sources/client/user.js": "bd5de82f24ae437291c22c06d21ea32847fdd5b6bc8e6be5efb37058680c9c9f",
|
|
@@ -796,7 +796,7 @@
|
|
|
796
796
|
"$server/$folder/lib/calendar-form/calendar-form.js": "dbfc0f7014659222ad3b3519d8e6c79bd5567102ab287096d59d015d66015148",
|
|
797
797
|
"$server/$folder/lib/chat-item/chat-item.js": "9ef0739195058295fdae64e3c1022bd5a5c43a9f048bff83f9ea5627b02cf6e0",
|
|
798
798
|
"$server/$folder/lib/class-picker/class-picker.js": "f7a4315793eb46ce76c76a28539a82a6894231d195d33fdeec5895eea2d5bebf",
|
|
799
|
-
"$server/$folder/lib/consultant/consultant.js": "
|
|
799
|
+
"$server/$folder/lib/consultant/consultant.js": "b612e59f0121164cea928c8ce1ba5a7a3537d53bbf8bbf37b2d120a2744c3df9",
|
|
800
800
|
"$server/$folder/lib/dialogs/confirm/confirm.js": "0664bcf90239951307b48698a8a1ff19e24a40d0998b969c593d44cd5bb639d2",
|
|
801
801
|
"$server/$folder/lib/dialogs/input/input.js": "02363770279ea07e249fb7d441518b45b5181aabb32306581b2adb384d8237f9",
|
|
802
802
|
"$server/$folder/lib/dialogs/popover/popover.js": "f845067f0db0f1851dcea596772aeb45d9916b37dd7de44a753033e5f14ede79",
|
|
@@ -826,7 +826,7 @@
|
|
|
826
826
|
"$server/$folder/lib/prompt-bar/beep-end.mp3": "617bd6134765d0ac9ef807bfba9096a812a7ca4c10ed270b1972586e7ff7be4d",
|
|
827
827
|
"$server/$folder/lib/prompt-bar/beep-start.mp3": "24004a82dd5274b852de766ef2b2ac035ca2d6b2aefc72086800968b4a98e77d",
|
|
828
828
|
"$server/$folder/lib/prompt-bar/progress.md": "c2ef67ebaae6f7211007a37563319856bf27c57b9ea68cabfb08f4bc0a53e6d2",
|
|
829
|
-
"$server/$folder/lib/prompt-bar/prompt-bar.js": "
|
|
829
|
+
"$server/$folder/lib/prompt-bar/prompt-bar.js": "eff81e408c65d314231ff6866a5daf6a142cb9e33b3f6ee2d77b38741d8fc246",
|
|
830
830
|
"$server/$folder/lib/prompt-bar/readme.md": "add5e4608da3a2efe446efec383a2ba5d017eb63635296976760c15dd6d43bec",
|
|
831
831
|
"$server/$folder/lib/readme.md": "d9927a3358092b1c0ed09eb349c81d0128aae04dddfbf1f093a21c0c4509ff68",
|
|
832
832
|
"$server/$folder/lib/role/role.js": "5d6edebf659fb163ce9a96a8ba5eeeb7465b74c1cd3f414e474fc9916edf4981",
|
package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/profile/$handler/class.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import '/sources/modules/user-profile/user-profile.js';
|
|
2
2
|
export default {
|
|
3
|
-
label: 'Профиль
|
|
3
|
+
label: 'Профиль',
|
|
4
4
|
icon: 'icons:account-circle',
|
|
5
5
|
order: 15,
|
|
6
|
+
allowUse($context) {
|
|
7
|
+
return !$context?.DATA?.usersContainer;
|
|
8
|
+
},
|
|
6
9
|
component: {
|
|
7
10
|
template: /* html */`
|
|
8
11
|
<style>
|
|
@@ -12,7 +15,7 @@ export default {
|
|
|
12
15
|
overflow: hidden;
|
|
13
16
|
}
|
|
14
17
|
</style>
|
|
15
|
-
<user-profile flex></user-profile>
|
|
18
|
+
<user-profile :$item flex></user-profile>
|
|
16
19
|
`
|
|
17
20
|
}
|
|
18
21
|
};
|
package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/tokens/$handler/class.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import '/sources/modules/user-profile/user-tokens.js';
|
|
2
|
+
export default {
|
|
3
|
+
label: 'Токены',
|
|
4
|
+
icon: 'communication:vpn-key',
|
|
5
|
+
order: 18,
|
|
6
|
+
allowUse($context, params) {
|
|
7
|
+
if (!$context?.id || $context?.DATA?.usersContainer)
|
|
8
|
+
return false;
|
|
9
|
+
const uid = $context?.constructor?.resolveUid?.(params) || params?.session?.uid || '';
|
|
10
|
+
return Boolean(uid && $context.id === uid);
|
|
11
|
+
},
|
|
12
|
+
component: {
|
|
13
|
+
template: /* html */`
|
|
14
|
+
<style>
|
|
15
|
+
:host {
|
|
16
|
+
@apply --vertical;
|
|
17
|
+
@apply --flex;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
}
|
|
20
|
+
</style>
|
|
21
|
+
<user-tokens :$item flex></user-tokens>
|
|
22
|
+
`
|
|
23
|
+
}
|
|
24
|
+
};
|
package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/users/$handler/class.js
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
label: 'Пользователи',
|
|
3
|
+
icon: 'social:people',
|
|
4
|
+
order: 15,
|
|
5
|
+
default: true,
|
|
6
|
+
allowUse($context) {
|
|
7
|
+
return Boolean($context?.DATA?.usersContainer);
|
|
8
|
+
},
|
|
9
|
+
component: {
|
|
10
|
+
imports: 'oda//icon, oda//button',
|
|
11
|
+
template: /* html */`
|
|
12
|
+
<style>
|
|
13
|
+
:host {
|
|
14
|
+
@apply --vertical;
|
|
15
|
+
@apply --flex;
|
|
16
|
+
overflow: auto;
|
|
17
|
+
padding: 16px;
|
|
18
|
+
gap: 12px;
|
|
19
|
+
box-sizing: border-box;
|
|
20
|
+
background: var(--content-background);
|
|
21
|
+
color: var(--content-color);
|
|
22
|
+
}
|
|
23
|
+
.header {
|
|
24
|
+
@apply --horizontal-center;
|
|
25
|
+
gap: 10px;
|
|
26
|
+
flex-wrap: wrap;
|
|
27
|
+
}
|
|
28
|
+
.search {
|
|
29
|
+
flex: 1 1 220px;
|
|
30
|
+
min-width: 180px;
|
|
31
|
+
padding: 7px 10px;
|
|
32
|
+
border-radius: 8px;
|
|
33
|
+
border: 1px solid var(--subtle-border, #cbd5e1);
|
|
34
|
+
background: var(--content-background);
|
|
35
|
+
color: var(--content-color);
|
|
36
|
+
font-size: 13.5px;
|
|
37
|
+
box-sizing: border-box;
|
|
38
|
+
}
|
|
39
|
+
.count {
|
|
40
|
+
font-size: 12.5px;
|
|
41
|
+
opacity: 0.72;
|
|
42
|
+
}
|
|
43
|
+
.list {
|
|
44
|
+
@apply --vertical;
|
|
45
|
+
gap: 8px;
|
|
46
|
+
}
|
|
47
|
+
.row {
|
|
48
|
+
@apply --horizontal-center;
|
|
49
|
+
gap: 10px;
|
|
50
|
+
padding: 8px 12px;
|
|
51
|
+
border-radius: 10px;
|
|
52
|
+
border: 1px solid var(--subtle-border, #e2e8f0);
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
transition: border-color .12s ease, background .12s ease;
|
|
55
|
+
}
|
|
56
|
+
.row:hover {
|
|
57
|
+
border-color: var(--accent-color, #4f46e5);
|
|
58
|
+
background: color-mix(in oklch, var(--accent-back, #4f46e5) 6%, transparent);
|
|
59
|
+
}
|
|
60
|
+
.row[disabled-user] {
|
|
61
|
+
opacity: 0.58;
|
|
62
|
+
}
|
|
63
|
+
.meta {
|
|
64
|
+
@apply --vertical;
|
|
65
|
+
flex: 1;
|
|
66
|
+
min-width: 0;
|
|
67
|
+
gap: 2px;
|
|
68
|
+
}
|
|
69
|
+
.title {
|
|
70
|
+
font-size: 14px;
|
|
71
|
+
font-weight: 600;
|
|
72
|
+
overflow: hidden;
|
|
73
|
+
text-overflow: ellipsis;
|
|
74
|
+
white-space: nowrap;
|
|
75
|
+
}
|
|
76
|
+
.sub {
|
|
77
|
+
font-size: 12px;
|
|
78
|
+
opacity: 0.72;
|
|
79
|
+
overflow: hidden;
|
|
80
|
+
text-overflow: ellipsis;
|
|
81
|
+
white-space: nowrap;
|
|
82
|
+
}
|
|
83
|
+
.badge {
|
|
84
|
+
font-size: 11.5px;
|
|
85
|
+
padding: 2px 8px;
|
|
86
|
+
border-radius: 999px;
|
|
87
|
+
border: 1px solid var(--subtle-border, #cbd5e1);
|
|
88
|
+
}
|
|
89
|
+
.badge.off {
|
|
90
|
+
color: var(--error-color, #dc2626);
|
|
91
|
+
border-color: color-mix(in srgb, var(--error-color, #dc2626) 45%, transparent);
|
|
92
|
+
}
|
|
93
|
+
.toggle-btn {
|
|
94
|
+
padding: 4px 10px;
|
|
95
|
+
border-radius: 6px;
|
|
96
|
+
border: 1px solid var(--subtle-border, #cbd5e1);
|
|
97
|
+
background: transparent;
|
|
98
|
+
color: inherit;
|
|
99
|
+
cursor: pointer;
|
|
100
|
+
font-size: 12px;
|
|
101
|
+
}
|
|
102
|
+
.toggle-btn:hover {
|
|
103
|
+
border-color: var(--accent-color, #4f46e5);
|
|
104
|
+
}
|
|
105
|
+
</style>
|
|
106
|
+
<div class="header">
|
|
107
|
+
<input class="search" placeholder="Поиск по имени, email или uid…" ::value="query">
|
|
108
|
+
<span class="count">Всего: {{filtered.length}}</span>
|
|
109
|
+
</div>
|
|
110
|
+
<div ~if="loading" class="count">Загрузка пользователей…</div>
|
|
111
|
+
<div ~if="!loading && !filtered.length" class="count">Пользователи не найдены</div>
|
|
112
|
+
<div ~if="!loading && filtered.length" class="list">
|
|
113
|
+
<div ~for="filtered" class="row" :disabled-user="!$for.item.enabled" @tap="openUser($for.item)">
|
|
114
|
+
<oda-icon round :icon="$for.item.icon || 'icons:account-circle'" :icon-color="$for.item.iconColor" icon-size="32"></oda-icon>
|
|
115
|
+
<div class="meta">
|
|
116
|
+
<span class="title">{{$for.item.label}}</span>
|
|
117
|
+
<span class="sub">{{$for.item.email ? ($for.item.email + ' · ') : ''}}{{$for.item.id}}</span>
|
|
118
|
+
</div>
|
|
119
|
+
<span ~if="!$for.item.enabled" class="badge off">Отключён</span>
|
|
120
|
+
<span ~if="$for.item.enabled" class="badge">Активен</span>
|
|
121
|
+
<button ~if="canToggle && $for.item.id !== selfUid" type="button" class="toggle-btn" @tap.stop="toggleEnabled($for.item)">
|
|
122
|
+
{{$for.item.enabled ? 'Отключить' : 'Включить'}}
|
|
123
|
+
</button>
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
`,
|
|
127
|
+
$item: {
|
|
128
|
+
$def: null,
|
|
129
|
+
set(n, o) {
|
|
130
|
+
if (o && this._onChanged)
|
|
131
|
+
o.unlisten?.('changed', this._onChanged);
|
|
132
|
+
if (n) {
|
|
133
|
+
this._onChanged ??= () => this.debounce?.('users-reload', () => this.reload(), 200) ?? this.reload();
|
|
134
|
+
n.listen?.('changed', this._onChanged);
|
|
135
|
+
this.reload();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
users: [],
|
|
140
|
+
loading: false,
|
|
141
|
+
canToggle: false,
|
|
142
|
+
query: '',
|
|
143
|
+
get selfUid() {
|
|
144
|
+
return WORK?.uid || '';
|
|
145
|
+
},
|
|
146
|
+
get filtered() {
|
|
147
|
+
const q = String(this.query || '').trim().toLowerCase();
|
|
148
|
+
if (!q)
|
|
149
|
+
return this.users || [];
|
|
150
|
+
return (this.users || []).filter(u =>
|
|
151
|
+
String(u.label || '').toLowerCase().includes(q)
|
|
152
|
+
|| String(u.email || '').toLowerCase().includes(q)
|
|
153
|
+
|| String(u.id || '').toLowerCase().includes(q)
|
|
154
|
+
);
|
|
155
|
+
},
|
|
156
|
+
async reload() {
|
|
157
|
+
if (!this.$item)
|
|
158
|
+
return;
|
|
159
|
+
this.loading = true;
|
|
160
|
+
try {
|
|
161
|
+
this.canToggle = Boolean(WORK?.DEV_MODE || await globalThis.WORK?.isBoss?.catch?.(() => false));
|
|
162
|
+
const raw = (await this.$item.items) || [];
|
|
163
|
+
const list = [];
|
|
164
|
+
for (const u of raw) {
|
|
165
|
+
if (!u || !u.id || u.id.startsWith('$'))
|
|
166
|
+
continue;
|
|
167
|
+
try { await u.init; } catch {}
|
|
168
|
+
const d = u.DATA || {};
|
|
169
|
+
list.push({
|
|
170
|
+
id: u.id,
|
|
171
|
+
label: u.label || d.label || d.email || u.id,
|
|
172
|
+
email: d.email || '',
|
|
173
|
+
icon: u.icon || d.icon || '',
|
|
174
|
+
iconColor: u.iconColor || '',
|
|
175
|
+
enabled: d.enabled !== false && d.blocked !== true,
|
|
176
|
+
item: u,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
list.sort((a, b) => String(a.label).localeCompare(String(b.label), 'ru'));
|
|
180
|
+
this.users = list;
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
this.users = [];
|
|
184
|
+
}
|
|
185
|
+
finally {
|
|
186
|
+
this.loading = false;
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
openUser(entry) {
|
|
190
|
+
if (!entry?.item)
|
|
191
|
+
return;
|
|
192
|
+
const exec = top?.execute || window.execute;
|
|
193
|
+
exec?.(entry.item, { view: 'system/profile' });
|
|
194
|
+
},
|
|
195
|
+
async toggleEnabled(entry) {
|
|
196
|
+
if (!entry?.item || !this.canToggle)
|
|
197
|
+
return;
|
|
198
|
+
const next = !entry.enabled;
|
|
199
|
+
try {
|
|
200
|
+
const res = await entry.item.fetch('set_enabled', { enabled: next });
|
|
201
|
+
entry.enabled = res?.enabled !== false;
|
|
202
|
+
this.users = [...this.users];
|
|
203
|
+
}
|
|
204
|
+
catch (e) {
|
|
205
|
+
console.warn('[users] set_enabled:', e?.message || e);
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
detached() {
|
|
209
|
+
if (this.$item && this._onChanged)
|
|
210
|
+
this.$item.unlisten?.('changed', this._onChanged);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
};
|
|
@@ -871,9 +871,14 @@ ODA({
|
|
|
871
871
|
async _hydrateModel() {
|
|
872
872
|
try {
|
|
873
873
|
const uid = globalThis.WORK?.uid || globalThis.WORK?.USER?.id || globalThis.WORK?.credentials?.uid || 'default';
|
|
874
|
-
const
|
|
874
|
+
const rawUserModel = localStorage.getItem(`work.user.ai:${uid}:model`)
|
|
875
875
|
|| localStorage.getItem('work.user.ai:default:model')
|
|
876
876
|
|| '';
|
|
877
|
+
const trimmed = rawUserModel.trim();
|
|
878
|
+
const modelsBase = ['MODULES', 'Модели'].join('/');
|
|
879
|
+
const userModel = /^\/?MODELS(?:\/|$)/i.test(trimmed)
|
|
880
|
+
? '/' + modelsBase + (trimmed.startsWith('/') ? trimmed : '/' + trimmed).slice('/MODELS'.length)
|
|
881
|
+
: rawUserModel;
|
|
877
882
|
if (userModel && !/(flux|sdxl|stable-?diffusion|z-image|embedding|bge-|rerank|whisper|\basr\b|\btts\b|\bstt\b|voice|kokoro|musicgen|wan2|ltx-video)/i.test(userModel)) {
|
|
878
883
|
this.model = userModel;
|
|
879
884
|
return;
|
|
@@ -138,7 +138,16 @@ export default {
|
|
|
138
138
|
icon: user?.icon || 'icons:account-circle',
|
|
139
139
|
default: 'icons:account-circle',
|
|
140
140
|
style: `color: white; fill: white; background:${user?.iconColor || 'transparent'}`,
|
|
141
|
-
click: () => {
|
|
141
|
+
click: async () => {
|
|
142
|
+
if (WORK?.uid) {
|
|
143
|
+
const userNode = WORK.USER || await WORK.get_$user?.(WORK.uid).catch(() => null);
|
|
144
|
+
if (userNode) {
|
|
145
|
+
this._autoOpenedLogin = false;
|
|
146
|
+
this.visibleMode = 'main';
|
|
147
|
+
window.execute?.(userNode, { view: 'system/profile' });
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
142
151
|
this.showUser = true;
|
|
143
152
|
},
|
|
144
153
|
errorInvert: !WORK.uid,
|
|
@@ -717,6 +726,7 @@ export default {
|
|
|
717
726
|
}
|
|
718
727
|
}
|
|
719
728
|
else {
|
|
729
|
+
this._autoOpenedLogin = true;
|
|
720
730
|
this.showUser = true;
|
|
721
731
|
}
|
|
722
732
|
}
|
|
@@ -726,6 +736,7 @@ export default {
|
|
|
726
736
|
this.async(async ()=>{
|
|
727
737
|
await this._handleInviteQuery();
|
|
728
738
|
if(!WORK.uid && !WORK.DEV_MODE){
|
|
739
|
+
this._autoOpenedLogin = true;
|
|
729
740
|
this.visibleMode = 'user';
|
|
730
741
|
if(this.left_drawer)
|
|
731
742
|
this.left_drawer.closed = true;
|
|
@@ -763,6 +774,12 @@ export default {
|
|
|
763
774
|
}
|
|
764
775
|
WORK.authEvents?.addEventListener('auth', () => {
|
|
765
776
|
this.user_icon = undefined;
|
|
777
|
+
if (WORK.uid && this._autoOpenedLogin && this.visibleMode === 'user') {
|
|
778
|
+
this._autoOpenedLogin = false;
|
|
779
|
+
this.visibleMode = 'main';
|
|
780
|
+
if (this.left_drawer)
|
|
781
|
+
this.left_drawer.closed = false;
|
|
782
|
+
}
|
|
766
783
|
this._refreshLeftButtons();
|
|
767
784
|
this._initTopLicenseBanner();
|
|
768
785
|
this._refreshSupportBadge();
|
|
@@ -43,13 +43,26 @@ function userAiStorageKey(suffix = 'model') {
|
|
|
43
43
|
return `work.user.ai:${uid}:${suffix}`;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
function normalizeModelPath(modelPath) {
|
|
47
|
+
const s = String(modelPath || '').trim().replace(/\\/g, '/');
|
|
48
|
+
if (!s)
|
|
49
|
+
return '';
|
|
50
|
+
if (/^\/?MODELS(?:\/|$)/i.test(s)) {
|
|
51
|
+
const clean = s.startsWith('/') ? s : '/' + s;
|
|
52
|
+
const modelsBase = ['MODULES', 'Модели'].join('/');
|
|
53
|
+
return '/' + modelsBase + clean.slice('/MODELS'.length);
|
|
54
|
+
}
|
|
55
|
+
return s;
|
|
56
|
+
}
|
|
57
|
+
|
|
46
58
|
export function getUserPreferredModel() {
|
|
47
59
|
if (typeof localStorage === 'undefined')
|
|
48
60
|
return '';
|
|
49
61
|
try {
|
|
50
|
-
const
|
|
62
|
+
const raw = localStorage.getItem(userAiStorageKey('model'))
|
|
51
63
|
|| localStorage.getItem('work.user.ai:default:model')
|
|
52
64
|
|| '';
|
|
65
|
+
const val = normalizeModelPath(raw);
|
|
53
66
|
if (val && /(flux|sdxl|stable-?diffusion|z-image|embedding|bge-|rerank|whisper|\basr\b|\btts\b|\bstt\b|voice|kokoro|musicgen|wan2|ltx-video)/i.test(val))
|
|
54
67
|
return '';
|
|
55
68
|
return val;
|
|
@@ -60,6 +73,7 @@ export function getUserPreferredModel() {
|
|
|
60
73
|
}
|
|
61
74
|
|
|
62
75
|
export function setUserPreferredModel(modelPath) {
|
|
76
|
+
modelPath = normalizeModelPath(modelPath);
|
|
63
77
|
if (!modelPath || typeof localStorage === 'undefined')
|
|
64
78
|
return;
|
|
65
79
|
if (/(flux|sdxl|stable-?diffusion|z-image|embedding|bge-|rerank|whisper|\basr\b|\btts\b|\bstt\b|voice|kokoro|musicgen|wan2|ltx-video)/i.test(modelPath))
|
|
@@ -6,7 +6,6 @@ function rawItem(it) {
|
|
|
6
6
|
return it?.[R]?.target || it;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
const MAIN_TREE_ENV_TYPES = new Set(['$domain', '$structure', '$project', '$module', '$provider', '$mcp', '$users', '$user', '$node', '$ai']);
|
|
10
9
|
const MAIN_TREE_LEAF_TYPES = new Set(['$module', '$mcp', '$user', '$ai']);
|
|
11
10
|
|
|
12
11
|
function isRootSectionNode(it) {
|
|
@@ -51,14 +50,14 @@ function filterMainTreeItems(items, parent) {
|
|
|
51
50
|
if (parent.type === '$folder')
|
|
52
51
|
return items;
|
|
53
52
|
if (isRootSectionNode(parent))
|
|
54
|
-
return items.filter(f => f &&
|
|
53
|
+
return items.filter(f => f && !f.DATA?.objects);
|
|
55
54
|
if (isMainTreeLeaf(parent))
|
|
56
55
|
return [];
|
|
57
56
|
if (parent.type === '$project' || parent.type === '$structure')
|
|
58
57
|
return items.filter(f => f && (f.type === '$structure' || f.type === '$project'));
|
|
59
58
|
if (parent.type === '$provider')
|
|
60
59
|
return items.filter(f => f?.type === '$ai');
|
|
61
|
-
return items.filter(f => f &&
|
|
60
|
+
return items.filter(f => f && !f.DATA?.objects);
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
/**
|
package/MODULES/$domain/class.js
CHANGED
package/oda/oda.js
CHANGED
|
@@ -356,13 +356,27 @@ localStorage: {
|
|
|
356
356
|
}
|
|
357
357
|
this.save();
|
|
358
358
|
}
|
|
359
|
-
save() {
|
|
359
|
+
save(sync = false) {
|
|
360
360
|
if (this._value === undefined)
|
|
361
361
|
return;
|
|
362
|
+
if (sync) {
|
|
363
|
+
this.flush();
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
362
366
|
this.debounce('saveToLocalStorage',()=>{
|
|
363
367
|
globalThis.localStorage.setItem(this.path, JSON.stringify(this.value));
|
|
364
368
|
})
|
|
365
369
|
}
|
|
370
|
+
flush() {
|
|
371
|
+
if (this._value === undefined)
|
|
372
|
+
return;
|
|
373
|
+
const dbKey = 'saveToLocalStorage.0';
|
|
374
|
+
if (this.__debounces__?.[dbKey]) {
|
|
375
|
+
clearTimeout(this.__debounces__[dbKey]);
|
|
376
|
+
delete this.__debounces__[dbKey];
|
|
377
|
+
}
|
|
378
|
+
globalThis.localStorage.setItem(this.path, JSON.stringify(this.value));
|
|
379
|
+
}
|
|
366
380
|
get version() {
|
|
367
381
|
return this.value.$$stamp;
|
|
368
382
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "odant-work",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.101",
|
|
4
4
|
"description": "ODANT-WORK — платформа цифровой организации (встроенная система учёта, документооборот, управление процессами и приватный мультимодальный ИИ)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "sources/work.js",
|
package/readme.md
CHANGED
|
@@ -114,7 +114,7 @@ WORK решает проблему управления организацион
|
|
|
114
114
|
| `/MODULES/` | Эталонные модули и внешние коннекторы (`Register`, `Geo`, `KLADR`, `Process`, `1C`, `Bitrix24`, `Telegram`, `DaData`, …) — предки для модулей организаций |
|
|
115
115
|
| `/MODELS/` | Встроенный источник ИИ: локальные (`Local`) и внешние провайдеры/модели (`$provider`, `$ai`), дообучение и профилировщик железа |
|
|
116
116
|
| `/NODES/` | Карта адресов внешних серверов WORK (федерация серверов) |
|
|
117
|
-
| `/USERS/` | Пользователи (класс `$
|
|
117
|
+
| `/USERS/` | Пользователи (класс `$user`, личные кабинеты `$user`) |
|
|
118
118
|
| `tests/`, `docs/` | Автотесты, контрольные задания (`tests/eval`) и проектная документация (`docs/architecture.md` — канон) |
|
|
119
119
|
|
|
120
120
|
## 5. В каком это состоянии
|
|
@@ -69,11 +69,23 @@ export class $handler extends $class{
|
|
|
69
69
|
const p = String(item?.path || '');
|
|
70
70
|
const s = String(item?.short || '');
|
|
71
71
|
const ctxShort = String(item?.$context?.short || '').replace(/\/+$/, '');
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
// Если short схлопнул ведущие $-слои в /~/handlers/... (например $user, $project, $mcp, $provider),
|
|
73
|
+
// восстанавливаем слой через контекст экземпляра или полный путь от /$server/$folder/... .
|
|
74
|
+
if (s.startsWith('/~/handlers/')) {
|
|
75
|
+
if (ctxShort && ctxShort !== '/')
|
|
76
|
+
return ctxShort + s;
|
|
77
|
+
if (p && !p.startsWith('/~/'))
|
|
78
|
+
return p;
|
|
79
|
+
return s;
|
|
80
|
+
}
|
|
81
|
+
// Для $file и обычных $folder (в т.ч. /$server/task/.../x.task/$folder/$file/$task/...)
|
|
82
|
+
// полный path содержит виртуальный сегмент /$folder/..., по которому get_item не проходит,
|
|
83
|
+
// а short (/~/task/.../~/handlers/... или /rules/admin.md/~/handlers/...) работает всегда.
|
|
84
|
+
if (s)
|
|
85
|
+
return s;
|
|
86
|
+
if (ctxShort && ctxShort !== '/' && p.startsWith('/~/handlers/'))
|
|
87
|
+
return ctxShort + p;
|
|
88
|
+
return p;
|
|
77
89
|
}
|
|
78
90
|
async import(path, is){
|
|
79
91
|
path = this._baseImportPath(this) + '/~/' + (path || 'class.js');
|