odant-work 1.0.19 → 1.0.21

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.
Files changed (32) hide show
  1. package/#system/package-manifest.json +35 -22
  2. package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/chat.js +21 -2
  3. package/$server/$folder/lib/chat-item/chat-item.js +17 -1
  4. package/$server/$folder/lib/local-models-transfer/local-models-transfer.js +972 -0
  5. package/MODELS/$ai/$folder/$class/$provider/handlers/pages/form/trainer/$handler/trainer.js +427 -106
  6. package/MODELS/Local/$provider/handlers/methods/transfer/$handler/class.js +41 -0
  7. package/package.json +1 -1
  8. package/rules/threats.md +117 -116
  9. package/sources/client.js +1 -0
  10. package/sources/data/progress.md +15 -0
  11. package/sources/host/auto-updater.js +30 -2
  12. package/sources/host/http-server.js +23 -0
  13. package/sources/host/websocket.js +127 -120
  14. package/sources/modules/agent/index.js +6 -1
  15. package/sources/modules/agent/readme.md +217 -216
  16. package/sources/modules/agent/tools/chrome.js +263 -0
  17. package/sources/modules/bridge/chrome.js +673 -0
  18. package/sources/modules/bridge/hub.js +395 -361
  19. package/sources/modules/chrome-extension/background.js +299 -0
  20. package/sources/modules/chrome-extension/manifest.json +25 -0
  21. package/sources/modules/chrome-extension/options.html +48 -0
  22. package/sources/modules/chrome-extension/options.js +104 -0
  23. package/sources/modules/chrome-extension/popup.html +25 -0
  24. package/sources/modules/chrome-extension/popup.js +32 -0
  25. package/sources/modules/trainer/halogen.js +16 -4
  26. package/sources/modules/trainer/huggingface.js +471 -95
  27. package/sources/modules/trainer/index.js +288 -1
  28. package/sources/modules/trainer/runner.js +54 -4
  29. package/sources/modules/trainer/tar-stream.js +458 -0
  30. package/sources/modules/trainer/transfer.js +1570 -0
  31. package/sources/modules/user-profile/user-profile.js +34 -10
  32. package/sources/modules/user-profile/user-token.js +168 -0
@@ -0,0 +1,299 @@
1
+ /**
2
+ * Service worker расширения WORK Chrome Bridge (MV3).
3
+ * Тонкий транспорт: принимает команды от сервера WORK по WebSocket `/~chrome`,
4
+ * создаёт/группирует только собственную вкладку агента («WORK») и транслирует
5
+ * разрешённые CDP-вызовы через `chrome.debugger`. Чужие вкладки не трогает никогда.
6
+ */
7
+
8
+ const ALLOWED_CDP_METHODS = new Set([
9
+ 'Accessibility.getFullAXTree',
10
+ 'DOM.scrollIntoViewIfNeeded',
11
+ 'DOM.getBoxModel',
12
+ 'DOM.focus',
13
+ 'Input.dispatchMouseEvent',
14
+ 'Input.insertText',
15
+ 'Input.dispatchKeyEvent',
16
+ 'Page.navigate',
17
+ 'Page.reload',
18
+ 'Page.getNavigationHistory',
19
+ 'Page.navigateToHistoryEntry',
20
+ 'Page.captureScreenshot',
21
+ 'Runtime.evaluate',
22
+ ]);
23
+
24
+ const ALLOWED_EVAL_EXPRS = new Set([
25
+ 'location.href',
26
+ 'document.title',
27
+ 'document.readyState',
28
+ ]);
29
+
30
+ let ws = null;
31
+ let agentTabId = null;
32
+ let attachedTabId = null;
33
+ let pingTimer = null;
34
+ let reconnectTimer = null;
35
+ let connecting = false;
36
+
37
+ function wsUrlFromServer(serverUrl) {
38
+ const u = new URL(String(serverUrl || '').trim());
39
+ if (u.protocol !== 'http:' && u.protocol !== 'https:')
40
+ throw new Error('Нужен адрес http:// или https://');
41
+ const proto = u.protocol === 'https:' ? 'wss:' : 'ws:';
42
+ const basePath = u.pathname.replace(/\/+$/, '');
43
+ return proto + '//' + u.host + basePath + '/~chrome';
44
+ }
45
+
46
+ async function setStatus(state, message, extra = {}) {
47
+ await chrome.storage.local.set({
48
+ lastStatus: {
49
+ state,
50
+ message: String(message || ''),
51
+ updatedAt: new Date().toISOString(),
52
+ ...extra,
53
+ },
54
+ });
55
+ }
56
+
57
+ function sendFrame(obj) {
58
+ if (ws && ws.readyState === WebSocket.OPEN) {
59
+ ws.send(JSON.stringify(obj));
60
+ return true;
61
+ }
62
+ return false;
63
+ }
64
+
65
+ async function restoreTabId() {
66
+ if (agentTabId != null)
67
+ return agentTabId;
68
+ try {
69
+ const stored = await chrome.storage.session.get('agentTabId');
70
+ if (typeof stored?.agentTabId === 'number')
71
+ agentTabId = stored.agentTabId;
72
+ }
73
+ catch { /* storage.session может быть недоступен */ }
74
+ return agentTabId;
75
+ }
76
+
77
+ async function saveTabId(tabId) {
78
+ agentTabId = tabId;
79
+ try {
80
+ if (tabId == null)
81
+ await chrome.storage.session.remove('agentTabId');
82
+ else
83
+ await chrome.storage.session.set({ agentTabId: tabId });
84
+ }
85
+ catch { /* не критично */ }
86
+ }
87
+
88
+ async function ensureAgentTab(initialUrl = 'about:blank') {
89
+ await restoreTabId();
90
+ if (agentTabId != null) {
91
+ try {
92
+ const tab = await chrome.tabs.get(agentTabId);
93
+ if (tab?.id) {
94
+ if (attachedTabId !== tab.id) {
95
+ await chrome.debugger.attach({ tabId: tab.id }, '1.3');
96
+ attachedTabId = tab.id;
97
+ }
98
+ return { tabId: tab.id };
99
+ }
100
+ }
101
+ catch {
102
+ await saveTabId(null);
103
+ attachedTabId = null;
104
+ }
105
+ }
106
+ const created = await chrome.tabs.create({ url: initialUrl, active: false });
107
+ if (!created?.id)
108
+ throw new Error('Не удалось создать вкладку агента');
109
+ await saveTabId(created.id);
110
+ try {
111
+ const groupId = await chrome.tabs.group({ tabIds: [created.id] });
112
+ if (chrome.tabGroups?.update)
113
+ await chrome.tabGroups.update(groupId, { title: 'WORK', color: 'blue' });
114
+ }
115
+ catch { /* группировка опциональна */ }
116
+ await chrome.debugger.attach({ tabId: created.id }, '1.3');
117
+ attachedTabId = created.id;
118
+ return { tabId: created.id };
119
+ }
120
+
121
+ async function runCdp(tabId, method, params) {
122
+ const m = String(method || '');
123
+ if (!ALLOWED_CDP_METHODS.has(m))
124
+ throw new Error('Запрещённый метод CDP: ' + m);
125
+ if (m === 'Runtime.evaluate' && !ALLOWED_EVAL_EXPRS.has(String(params?.expression || '')))
126
+ throw new Error('Произвольный Runtime.evaluate запрещён');
127
+ if (tabId !== agentTabId)
128
+ throw new Error('Доступ разрешён только к собственной вкладке агента');
129
+ if (attachedTabId !== tabId) {
130
+ await chrome.debugger.attach({ tabId }, '1.3');
131
+ attachedTabId = tabId;
132
+ }
133
+ return chrome.debugger.sendCommand({ tabId }, m, params || {});
134
+ }
135
+
136
+ async function handleRpc(msg) {
137
+ const id = msg.id;
138
+ try {
139
+ let result;
140
+ if (msg.op === 'ensure_tab')
141
+ result = await ensureAgentTab(msg.url || 'about:blank');
142
+ else if (msg.op === 'cdp')
143
+ result = await runCdp(msg.tabId, msg.method, msg.params);
144
+ else if (msg.op === 'close_tab') {
145
+ if (agentTabId != null) {
146
+ const tid = agentTabId;
147
+ await saveTabId(null);
148
+ attachedTabId = null;
149
+ try { await chrome.debugger.detach({ tabId: tid }); } catch {}
150
+ try { await chrome.tabs.remove(tid); } catch {}
151
+ }
152
+ result = { closed: true };
153
+ }
154
+ else
155
+ throw new Error('Неизвестная операция: ' + String(msg.op || ''));
156
+ sendFrame({ id, ok: true, result });
157
+ }
158
+ catch (e) {
159
+ sendFrame({ id, ok: false, error: String(e?.message || e) });
160
+ }
161
+ }
162
+
163
+ function stopTimers() {
164
+ if (pingTimer) {
165
+ clearInterval(pingTimer);
166
+ pingTimer = null;
167
+ }
168
+ if (reconnectTimer) {
169
+ clearTimeout(reconnectTimer);
170
+ reconnectTimer = null;
171
+ }
172
+ }
173
+
174
+ function scheduleReconnect(delayMs = 5000) {
175
+ if (reconnectTimer)
176
+ return;
177
+ reconnectTimer = setTimeout(() => {
178
+ reconnectTimer = null;
179
+ connect();
180
+ }, delayMs);
181
+ }
182
+
183
+ export async function connect(force = false) {
184
+ if (connecting)
185
+ return;
186
+ if (ws && ws.readyState === WebSocket.OPEN && !force)
187
+ return;
188
+ if (force && ws) {
189
+ try { ws.close(); } catch {}
190
+ ws = null;
191
+ }
192
+ const { serverUrl, token } = await chrome.storage.local.get(['serverUrl', 'token']);
193
+ if (!serverUrl || !token) {
194
+ await setStatus('unconfigured', 'Укажите адрес WORK и токен wmcp в настройках расширения.');
195
+ return;
196
+ }
197
+ let endpoint;
198
+ try {
199
+ endpoint = wsUrlFromServer(serverUrl);
200
+ }
201
+ catch (e) {
202
+ await setStatus('error', e.message);
203
+ return;
204
+ }
205
+ connecting = true;
206
+ await setStatus('connecting', 'Подключение к ' + serverUrl + '…');
207
+ try {
208
+ const socket = new WebSocket(endpoint);
209
+ ws = socket;
210
+ socket.addEventListener('open', () => {
211
+ connecting = false;
212
+ const manifest = chrome.runtime.getManifest();
213
+ socket.send(JSON.stringify({
214
+ type: 'auth',
215
+ token: String(token).trim(),
216
+ extensionVersion: manifest.version,
217
+ browserName: navigator.userAgent.includes('Edg/') ? 'Edge' : 'Chrome',
218
+ }));
219
+ stopTimers();
220
+ pingTimer = setInterval(() => {
221
+ sendFrame({ type: 'ping' });
222
+ }, 20_000);
223
+ });
224
+ socket.addEventListener('message', async ev => {
225
+ let msg;
226
+ try { msg = JSON.parse(String(ev.data || '')); } catch { return; }
227
+ if (msg.type === 'auth_ok') {
228
+ await setStatus('connected', 'Подключено к WORK (uid: ' + msg.uid + ')', { uid: msg.uid, readOnly: Boolean(msg.readOnly) });
229
+ return;
230
+ }
231
+ if (msg.type === 'pong')
232
+ return;
233
+ if (msg.id)
234
+ await handleRpc(msg);
235
+ });
236
+ socket.addEventListener('close', async ev => {
237
+ connecting = false;
238
+ stopTimers();
239
+ if (ws === socket)
240
+ ws = null;
241
+ const reason = ev.reason || ('код ' + ev.code);
242
+ await setStatus('disconnected', 'Отключено: ' + reason);
243
+ if (ev.code !== 4401 && ev.code !== 4403 && ev.code !== 4000)
244
+ scheduleReconnect(5000);
245
+ });
246
+ socket.addEventListener('error', async () => {
247
+ connecting = false;
248
+ await setStatus('error', 'Не удалось подключиться к ' + serverUrl);
249
+ });
250
+ }
251
+ catch (e) {
252
+ connecting = false;
253
+ await setStatus('error', String(e?.message || e));
254
+ scheduleReconnect(5000);
255
+ }
256
+ }
257
+
258
+ chrome.debugger.onDetach.addListener(async (source, reason) => {
259
+ if (source?.tabId != null && source.tabId === agentTabId) {
260
+ const tid = source.tabId;
261
+ await saveTabId(null);
262
+ attachedTabId = null;
263
+ sendFrame({ type: 'tab_detached', tabId: tid, reason });
264
+ }
265
+ });
266
+
267
+ chrome.tabs.onRemoved.addListener(async tabId => {
268
+ if (tabId === agentTabId) {
269
+ await saveTabId(null);
270
+ attachedTabId = null;
271
+ sendFrame({ type: 'tab_closed', tabId });
272
+ }
273
+ });
274
+
275
+ chrome.runtime.onMessage.addListener((msg, _sender, sendResponse) => {
276
+ if (msg?.type === 'reconnect') {
277
+ connect(true).then(() => sendResponse({ ok: true }));
278
+ return true;
279
+ }
280
+ if (msg?.type === 'disconnect') {
281
+ stopTimers();
282
+ if (ws) {
283
+ try { ws.close(1000, 'manual'); } catch {}
284
+ ws = null;
285
+ }
286
+ setStatus('disconnected', 'Отключено вручную').then(() => sendResponse({ ok: true }));
287
+ return true;
288
+ }
289
+ return false;
290
+ });
291
+
292
+ chrome.alarms.create('work-chrome-keepalive', { periodInMinutes: 0.5 });
293
+ chrome.alarms.onAlarm.addListener(alarm => {
294
+ if (alarm.name === 'work-chrome-keepalive')
295
+ connect(false);
296
+ });
297
+ chrome.runtime.onInstalled.addListener(() => connect(false));
298
+ chrome.runtime.onStartup.addListener(() => connect(false));
299
+ connect(false);
@@ -0,0 +1,25 @@
1
+ {
2
+ "manifest_version": 3,
3
+ "name": "WORK Chrome Bridge",
4
+ "version": "0.1.0",
5
+ "description": "Подключает ваш Chrome к агенту WORK через защищённый локальный канал с режимом «только просмотр» и подтверждением действий.",
6
+ "permissions": [
7
+ "debugger",
8
+ "tabs",
9
+ "tabGroups",
10
+ "storage",
11
+ "alarms"
12
+ ],
13
+ "background": {
14
+ "service_worker": "background.js",
15
+ "type": "module"
16
+ },
17
+ "options_ui": {
18
+ "page": "options.html",
19
+ "open_in_tab": true
20
+ },
21
+ "action": {
22
+ "default_popup": "popup.html",
23
+ "default_title": "WORK Chrome Bridge"
24
+ }
25
+ }
@@ -0,0 +1,48 @@
1
+ <!doctype html>
2
+ <html lang="ru">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>WORK Chrome Bridge — Настройки</title>
6
+ <style>
7
+ body { font-family: system-ui, -apple-system, sans-serif; max-width: 520px; margin: 32px auto; padding: 0 16px; color: #1f2937; }
8
+ h1 { font-size: 20px; margin-bottom: 8px; }
9
+ p.hint, .subhint { color: #4b5563; font-size: 13px; line-height: 1.45; }
10
+ .subhint { font-size: 12px; margin-top: 6px; }
11
+ label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
12
+ input { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; }
13
+ .row { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
14
+ button { padding: 8px 14px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; cursor: pointer; font-size: 13px; }
15
+ button.primary { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }
16
+ button:disabled { opacity: 0.5; cursor: not-allowed; }
17
+ .status { margin-top: 16px; padding: 10px 12px; border-radius: 6px; background: #f3f4f6; font-size: 13px; line-height: 1.4; }
18
+ .status.ok { background: #ecfdf5; color: #065f46; }
19
+ .status.err { background: #fef2f2; color: #991b1b; }
20
+ </style>
21
+ </head>
22
+ <body>
23
+ <h1>WORK Chrome Bridge</h1>
24
+ <p class="hint">
25
+ Подключает ваш Chrome к агенту WORK по локальному каналу.
26
+ При подключении всегда включается режим «только просмотр» (readOnly).
27
+ </p>
28
+
29
+ <label for="serverUrl">Адрес сервера WORK</label>
30
+ <input id="serverUrl" type="url" placeholder="http://localhost:8001">
31
+
32
+ <label for="token">Персональный токен (wmcp.… или готовая строка из профиля)</label>
33
+ <input id="token" type="password" placeholder="wmcp.UID.secret">
34
+ <div class="subhint">
35
+ Где взять: откройте WORK → ваш аватар внизу левой панели → <b>Подключения</b> → <b>Токен для подключения</b>
36
+ (это тот же персональный токен <code>wmcp.…</code>, что используется и для MCP).
37
+ </div>
38
+
39
+ <div class="row">
40
+ <button class="primary" id="saveBtn">Сохранить и подключить</button>
41
+ <button id="openWorkBtn">Открыть WORK</button>
42
+ <button id="clearBtn">Сбросить токен</button>
43
+ </div>
44
+
45
+ <div class="status" id="statusBox">Загрузка…</div>
46
+ <script src="options.js"></script>
47
+ </body>
48
+ </html>
@@ -0,0 +1,104 @@
1
+ const serverEl = document.getElementById('serverUrl');
2
+ const tokenEl = document.getElementById('token');
3
+ const statusEl = document.getElementById('statusBox');
4
+ const openWorkBtn = document.getElementById('openWorkBtn');
5
+
6
+ function validHttpUrl(raw) {
7
+ try {
8
+ const u = new URL(String(raw || '').trim());
9
+ return u.protocol === 'http:' || u.protocol === 'https:' ? u.origin + u.pathname.replace(/\/+$/, '') : '';
10
+ }
11
+ catch {
12
+ return '';
13
+ }
14
+ }
15
+
16
+ function updateOpenBtn() {
17
+ openWorkBtn.disabled = !validHttpUrl(serverEl.value);
18
+ }
19
+
20
+ /** Поддержка вставки готовой JSON-строки `{"server":...,"token":...}` из модалки профиля. */
21
+ function maybeParseBridgePayload(raw) {
22
+ const s = String(raw || '').trim();
23
+ if (!s.startsWith('{'))
24
+ return false;
25
+ try {
26
+ const obj = JSON.parse(s);
27
+ if (obj && typeof obj === 'object' && typeof obj.token === 'string') {
28
+ if (typeof obj.server === 'string' && validHttpUrl(obj.server))
29
+ serverEl.value = validHttpUrl(obj.server);
30
+ tokenEl.value = obj.token.trim();
31
+ updateOpenBtn();
32
+ return true;
33
+ }
34
+ }
35
+ catch { /* не JSON — оставляем как есть */ }
36
+ return false;
37
+ }
38
+
39
+ function renderStatus(st) {
40
+ if (!st) {
41
+ statusEl.className = 'status';
42
+ statusEl.textContent = 'Не настроено. Укажите адрес WORK и токен из профиля («Подключения» → «Токен для подключения»).';
43
+ return;
44
+ }
45
+ statusEl.className = 'status ' + (st.state === 'connected' ? 'ok' : (st.state === 'error' ? 'err' : ''));
46
+ let text = st.message || st.state;
47
+ if (/Invalid token|Auth required|4401/i.test(text))
48
+ text += ' — проверьте или перевыпустите токен в профиле WORK (аватар → «Подключения» → «Токен для подключения»).';
49
+ statusEl.textContent = text;
50
+ }
51
+
52
+ async function load() {
53
+ const data = await chrome.storage.local.get(['serverUrl', 'token', 'lastStatus']);
54
+ serverEl.value = data.serverUrl || 'http://localhost:8001';
55
+ tokenEl.value = data.token || '';
56
+ updateOpenBtn();
57
+ renderStatus(data.lastStatus);
58
+ }
59
+
60
+ serverEl.addEventListener('input', updateOpenBtn);
61
+
62
+ tokenEl.addEventListener('input', () => {
63
+ maybeParseBridgePayload(tokenEl.value);
64
+ });
65
+
66
+ openWorkBtn.addEventListener('click', () => {
67
+ const url = validHttpUrl(serverEl.value);
68
+ if (!url) {
69
+ renderStatus({ state: 'error', message: 'Укажите корректный адрес сервера WORK (http:// или https://).' });
70
+ return;
71
+ }
72
+ chrome.tabs.create({ url });
73
+ });
74
+
75
+ document.getElementById('saveBtn').addEventListener('click', async () => {
76
+ maybeParseBridgePayload(tokenEl.value);
77
+ const serverUrl = validHttpUrl(serverEl.value);
78
+ const token = tokenEl.value.trim();
79
+ if (!serverUrl || !token) {
80
+ renderStatus({
81
+ state: 'error',
82
+ message: 'Заполните адрес сервера WORK и токен (профиль WORK → «Подключения» → «Токен для подключения»).',
83
+ });
84
+ return;
85
+ }
86
+ serverEl.value = serverUrl;
87
+ await chrome.storage.local.set({ serverUrl, token });
88
+ await chrome.runtime.sendMessage({ type: 'reconnect' });
89
+ setTimeout(load, 500);
90
+ });
91
+
92
+ document.getElementById('clearBtn').addEventListener('click', async () => {
93
+ await chrome.storage.local.remove(['token']);
94
+ tokenEl.value = '';
95
+ await chrome.runtime.sendMessage({ type: 'disconnect' });
96
+ setTimeout(load, 200);
97
+ });
98
+
99
+ chrome.storage.onChanged.addListener(changes => {
100
+ if (changes.lastStatus)
101
+ renderStatus(changes.lastStatus.newValue);
102
+ });
103
+
104
+ load();
@@ -0,0 +1,25 @@
1
+ <!doctype html>
2
+ <html lang="ru">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>WORK Chrome Bridge</title>
6
+ <style>
7
+ body { font-family: system-ui, -apple-system, sans-serif; width: 280px; margin: 12px; color: #1f2937; font-size: 13px; }
8
+ .title { font-weight: 700; margin-bottom: 8px; }
9
+ .box { padding: 8px 10px; border-radius: 6px; background: #f3f4f6; margin-bottom: 10px; }
10
+ .box.ok { background: #ecfdf5; color: #065f46; }
11
+ .box.err { background: #fef2f2; color: #991b1b; }
12
+ .row { display: flex; gap: 6px; }
13
+ button { flex: 1; padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; cursor: pointer; font-size: 12px; }
14
+ </style>
15
+ </head>
16
+ <body>
17
+ <div class="title">WORK Chrome Bridge</div>
18
+ <div class="box" id="status">Загрузка…</div>
19
+ <div class="row">
20
+ <button id="reconnectBtn">Переподключить</button>
21
+ <button id="optionsBtn">Настройки</button>
22
+ </div>
23
+ <script src="popup.js"></script>
24
+ </body>
25
+ </html>
@@ -0,0 +1,32 @@
1
+ const statusEl = document.getElementById('status');
2
+
3
+ function render(st) {
4
+ if (!st) {
5
+ statusEl.className = 'box';
6
+ statusEl.textContent = 'Не настроено — откройте «Настройки».';
7
+ return;
8
+ }
9
+ statusEl.className = 'box ' + (st.state === 'connected' ? 'ok' : (st.state === 'error' ? 'err' : ''));
10
+ statusEl.textContent = st.message || st.state;
11
+ }
12
+
13
+ async function refresh() {
14
+ const { lastStatus } = await chrome.storage.local.get('lastStatus');
15
+ render(lastStatus);
16
+ }
17
+
18
+ document.getElementById('reconnectBtn').addEventListener('click', async () => {
19
+ await chrome.runtime.sendMessage({ type: 'reconnect' });
20
+ setTimeout(refresh, 400);
21
+ });
22
+
23
+ document.getElementById('optionsBtn').addEventListener('click', () => {
24
+ chrome.runtime.openOptionsPage();
25
+ });
26
+
27
+ chrome.storage.onChanged.addListener(changes => {
28
+ if (changes.lastStatus)
29
+ render(changes.lastStatus.newValue);
30
+ });
31
+
32
+ refresh();
@@ -1408,11 +1408,12 @@ export function inspectHalogenCatalogWithStatus(rootDir = process.cwd()) {
1408
1408
  d.status === 'downloading'
1409
1409
  && (d.repoId === spec.hfRepo || d.folderName === spec.nodeName || d.modelPath === spec.path)
1410
1410
  ) || null;
1411
+ const hasRealWeightFile = downloadedFiles.some(f => /\.(gguf|safetensors|hgn|hnpw|bin|onnx|pt|pth)$/i.test(f));
1411
1412
  return {
1412
1413
  ...spec,
1413
1414
  nodeConfigured,
1414
1415
  weightsDir: path.relative(rootDir, weightsDir).replace(/\\/g, '/'),
1415
- weightsDownloaded: downloadedFiles.length > 0,
1416
+ weightsDownloaded: !activeJob && hasRealWeightFile,
1416
1417
  downloadedFiles,
1417
1418
  activeDownload: activeJob,
1418
1419
  };
@@ -1422,7 +1423,7 @@ export function inspectHalogenCatalogWithStatus(rootDir = process.cwd()) {
1422
1423
  /**
1423
1424
  * Поставить в очередь скачивание всего пакета моделей Halo в `/MODELS/Local` (1 основная GPU-модель + 7 NPU-моделей)
1424
1425
  * или выбранного подмножества моделей с Hugging Face Hub прямо в `MODELS/Local/<nodeName>/#weights`,
1425
- * регистрируя узлы `$ai` в `/MODELS/Local/<nodeName>`.
1426
+ * регистрируя узлы `$ai` в `/MODELS/Local/<nodeName>` по мере завершения скачивания каждой модели.
1426
1427
  */
1427
1428
  export async function downloadHalogenBundle({
1428
1429
  rootDir = process.cwd(),
@@ -1451,7 +1452,6 @@ export async function downloadHalogenBundle({
1451
1452
  let alreadyActiveCount = 0;
1452
1453
 
1453
1454
  for (const spec of targets) {
1454
- await ensureHalogenModelNodes(rootDir, { models: [spec.nodeName], onlyWithWeights: false });
1455
1455
  const running = existingDownloads.find(d =>
1456
1456
  d.status === 'downloading'
1457
1457
  && (d.repoId === spec.hfRepo || d.folderName === spec.nodeName || d.modelPath === spec.path)
@@ -1465,9 +1465,21 @@ export async function downloadHalogenBundle({
1465
1465
  repoId: spec.hfRepo,
1466
1466
  providerFolder: 'Local',
1467
1467
  targetNodeName: spec.nodeName,
1468
+ nodeMeta: {
1469
+ label: spec.label || spec.nodeName,
1470
+ model: spec.model,
1471
+ protocol: 'halogen',
1472
+ icon: spec.icon || 'ai:qwen',
1473
+ modality: spec.modality,
1474
+ capabilities: spec.capabilities,
1475
+ efforts: spec.efforts,
1476
+ maxTokens: spec.maxTokens,
1477
+ maxOutput: spec.maxOutput,
1478
+ baseUrl: spec.baseUrl || HALOGEN_DEFAULT_BASE_URL,
1479
+ },
1468
1480
  rootDir,
1469
1481
  token,
1470
- registerInWork: false,
1482
+ registerInWork: true,
1471
1483
  waitForCompletion,
1472
1484
  fetchImpl,
1473
1485
  });