odant-work 1.0.39 → 1.0.41

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 (27) hide show
  1. package/#system/package-manifest.json +29 -29
  2. package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/chat.js +212 -72
  3. package/$server/$folder/$file/$task/class.js +3 -0
  4. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/file.js +33 -1
  5. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/feed.js +65 -1
  6. package/$server/$folder/lib/consultant/consultant.js +9 -0
  7. package/MODELS/$ai/$folder/$class/$ai/handlers/pages/form/trainer/$handler/trainer.js +27 -7
  8. package/MODELS/$ai/$folder/$class/$provider/handlers/pages/form/trainer/$handler/trainer.js +2 -2
  9. package/package.json +1 -1
  10. package/sources/data/progress.md +11 -0
  11. package/sources/modules/agent/loop.js +39 -4
  12. package/sources/modules/agent/permissions.js +271 -111
  13. package/sources/modules/agent/session.js +89 -2
  14. package/sources/modules/agent/system.js +10 -3
  15. package/sources/modules/agent/tools/chrome.js +25 -4
  16. package/sources/modules/agent/tools/desktop.js +184 -170
  17. package/sources/modules/agent/tools/dev/checks.js +160 -160
  18. package/sources/modules/agent/tools/dev/git.js +276 -276
  19. package/sources/modules/agent/tools/net.js +45 -45
  20. package/sources/modules/agent/tools/os-proc.js +179 -169
  21. package/sources/modules/agent/tools/services.js +280 -275
  22. package/sources/modules/trainer/index.js +1 -0
  23. package/sources/modules/trainer/local-engine.js +321 -55
  24. package/sources/modules/trainer/worker/local_infer_worker.py +34 -12
  25. package/sources/reactor.js +8 -0
  26. package/sources/server/class/feed.js +21 -12
  27. package/sources/server/logs.js +50 -8
@@ -12,6 +12,7 @@ import path from 'node:path';
12
12
  import { $item } from '../core.js';
13
13
  import { FS } from './index.js';
14
14
  import * as REFS from './access/refs.js';
15
+ import { isOwnLogRow } from './access/policy.js';
15
16
  import { dataDb } from '../data/db.js';
16
17
 
17
18
  /** Сегодня по местному времени сервера (YYYY-MM-DD). */
@@ -170,16 +171,42 @@ function diskLogsDir(storage) {
170
171
  return fs.existsSync(d) ? d : '';
171
172
  }
172
173
 
173
- /** Даты, за которые есть логи (по убыванию); сегодня — всегда в списке. */
174
- export async function datesList(storage) {
175
- const dateSet = new Set([today()]);
174
+ function isVisibleChatRootRow(row, ownOnly = null) {
175
+ if (!row || row.time == null || row.mainContext)
176
+ return false;
177
+ if (ownOnly && !isOwnLogRow(row, ownOnly))
178
+ return false;
179
+ return true;
180
+ }
181
+
182
+ /**
183
+ * Даты, за которые есть логи (по убыванию).
184
+ * По умолчанию сегодня всегда в списке; при `nonEmpty: true` — только дни, где есть хотя бы одна видимая корневая запись (без `mainContext`).
185
+ */
186
+ export async function datesList(storage, { nonEmpty = false, ownOnly = null } = {}) {
187
+ const dateSet = new Set(nonEmpty ? [] : [today()]);
176
188
  try {
177
189
  const db = await dbForStorage(storage);
178
190
  const fp = feedPathOf(storage);
179
- const rows = db.prepare('SELECT DISTINCT day FROM logs WHERE feed_path = ?').all(fp);
180
- for (const r of rows) {
181
- if (r?.day && /^\d{4}-\d{2}-\d{2}$/.test(r.day))
182
- dateSet.add(r.day);
191
+ if (nonEmpty) {
192
+ const rows = db.prepare('SELECT day, body FROM logs WHERE feed_path = ?').all(fp);
193
+ for (const r of rows) {
194
+ if (!r?.day || !/^\d{4}-\d{2}-\d{2}$/.test(r.day) || dateSet.has(r.day))
195
+ continue;
196
+ try {
197
+ const row = typeof r.body === 'string' ? JSON.parse(r.body) : r.body;
198
+ if (isVisibleChatRootRow(row, ownOnly))
199
+ dateSet.add(r.day);
200
+ }
201
+ catch { /* skip broken json */ }
202
+ }
203
+ }
204
+ else {
205
+ const rows = db.prepare('SELECT DISTINCT day FROM logs WHERE feed_path = ?').all(fp);
206
+ for (const r of rows) {
207
+ if (r?.day && /^\d{4}-\d{2}-\d{2}$/.test(r.day))
208
+ dateSet.add(r.day);
209
+ }
183
210
  }
184
211
  }
185
212
  catch (e) {
@@ -189,8 +216,23 @@ export async function datesList(storage) {
189
216
  if (diskDir) {
190
217
  try {
191
218
  for (const entry of fs.readdirSync(diskDir, { withFileTypes: true })) {
192
- if (entry.isDirectory() && /^\d{4}-\d{2}-\d{2}$/.test(entry.name))
219
+ if (!entry.isDirectory() || !/^\d{4}-\d{2}-\d{2}$/.test(entry.name) || dateSet.has(entry.name))
220
+ continue;
221
+ if (!nonEmpty) {
193
222
  dateSet.add(entry.name);
223
+ continue;
224
+ }
225
+ const dayPath = path.join(diskDir, entry.name);
226
+ for (const fname of fs.readdirSync(dayPath).filter(n => n.endsWith('.logs'))) {
227
+ try {
228
+ const row = JSON.parse(fs.readFileSync(path.join(dayPath, fname), 'utf-8'));
229
+ if (isVisibleChatRootRow(row, ownOnly)) {
230
+ dateSet.add(entry.name);
231
+ break;
232
+ }
233
+ }
234
+ catch { /* skip */ }
235
+ }
194
236
  }
195
237
  }
196
238
  catch { /* ignore */ }