agentflow-core 0.5.0 → 0.5.2
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/dist/{chunk-T2BYYGA4.js → chunk-YTMQBL3T.js} +54 -10
- package/dist/cli.cjs +54 -10
- package/dist/cli.js +1 -1
- package/dist/index.cjs +54 -10
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -277,11 +277,29 @@ Examples:
|
|
|
277
277
|
`.trim()
|
|
278
278
|
);
|
|
279
279
|
}
|
|
280
|
+
var dirMtimeCache = /* @__PURE__ */ new Map();
|
|
281
|
+
var dirFileCache = /* @__PURE__ */ new Map();
|
|
280
282
|
function scanFiles(dirs, recursive) {
|
|
281
283
|
const results = [];
|
|
282
284
|
const seen = /* @__PURE__ */ new Set();
|
|
283
285
|
function scanDir(d, topLevel) {
|
|
284
286
|
try {
|
|
287
|
+
const dirStat = statSync(d);
|
|
288
|
+
const dirMtime = dirStat.mtime.getTime();
|
|
289
|
+
const cachedMtime = dirMtimeCache.get(d);
|
|
290
|
+
if (cachedMtime === dirMtime) {
|
|
291
|
+
const cached = dirFileCache.get(d);
|
|
292
|
+
if (cached) {
|
|
293
|
+
for (const f of cached) {
|
|
294
|
+
if (!seen.has(f.path)) {
|
|
295
|
+
seen.add(f.path);
|
|
296
|
+
results.push(f);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
const dirResults = [];
|
|
285
303
|
for (const f of readdirSync(d)) {
|
|
286
304
|
if (f.startsWith(".")) continue;
|
|
287
305
|
const fp = join(d, f);
|
|
@@ -299,12 +317,18 @@ function scanFiles(dirs, recursive) {
|
|
|
299
317
|
if (!stat.isFile()) continue;
|
|
300
318
|
if (f.endsWith(".json")) {
|
|
301
319
|
seen.add(fp);
|
|
302
|
-
|
|
320
|
+
const entry = { filename: f, path: fp, mtime: stat.mtime.getTime(), ext: ".json" };
|
|
321
|
+
results.push(entry);
|
|
322
|
+
dirResults.push(entry);
|
|
303
323
|
} else if (f.endsWith(".jsonl")) {
|
|
304
324
|
seen.add(fp);
|
|
305
|
-
|
|
325
|
+
const entry = { filename: f, path: fp, mtime: stat.mtime.getTime(), ext: ".jsonl" };
|
|
326
|
+
results.push(entry);
|
|
327
|
+
dirResults.push(entry);
|
|
306
328
|
}
|
|
307
329
|
}
|
|
330
|
+
dirMtimeCache.set(d, dirMtime);
|
|
331
|
+
dirFileCache.set(d, dirResults);
|
|
308
332
|
} catch {
|
|
309
333
|
}
|
|
310
334
|
}
|
|
@@ -648,20 +672,32 @@ var prevFileCount = 0;
|
|
|
648
672
|
var newExecCount = 0;
|
|
649
673
|
var sessionStart = Date.now();
|
|
650
674
|
var firstRender = true;
|
|
675
|
+
var fileCache = /* @__PURE__ */ new Map();
|
|
676
|
+
function getRecordsCached(f) {
|
|
677
|
+
const cached = fileCache.get(f.path);
|
|
678
|
+
if (cached && cached.mtime === f.mtime) return cached;
|
|
679
|
+
const records = f.ext === ".jsonl" ? processJsonlFile(f) : processJsonFile(f);
|
|
680
|
+
const traces = records.filter((r) => r.traceData).map((r) => r.traceData);
|
|
681
|
+
const entry = { mtime: f.mtime, records, traces };
|
|
682
|
+
fileCache.set(f.path, entry);
|
|
683
|
+
return entry;
|
|
684
|
+
}
|
|
651
685
|
function render(config) {
|
|
652
686
|
const files = scanFiles(config.dirs, config.recursive);
|
|
653
687
|
if (files.length > prevFileCount && prevFileCount > 0) {
|
|
654
688
|
newExecCount += files.length - prevFileCount;
|
|
655
689
|
}
|
|
656
690
|
prevFileCount = files.length;
|
|
691
|
+
const currentPaths = new Set(files.map((f) => f.path));
|
|
692
|
+
for (const key of fileCache.keys()) {
|
|
693
|
+
if (!currentPaths.has(key)) fileCache.delete(key);
|
|
694
|
+
}
|
|
657
695
|
const allRecords = [];
|
|
658
696
|
const allTraces = [];
|
|
659
697
|
for (const f of files.slice(0, 300)) {
|
|
660
|
-
const records
|
|
661
|
-
for (const r of records)
|
|
662
|
-
|
|
663
|
-
if (r.traceData) allTraces.push(r.traceData);
|
|
664
|
-
}
|
|
698
|
+
const { records, traces } = getRecordsCached(f);
|
|
699
|
+
for (const r of records) allRecords.push(r);
|
|
700
|
+
for (const t of traces) allTraces.push(t);
|
|
665
701
|
}
|
|
666
702
|
const deduped = [];
|
|
667
703
|
const seenAgents = /* @__PURE__ */ new Map();
|
|
@@ -2099,9 +2135,17 @@ agentflow watch started`);
|
|
|
2099
2135
|
records.push(...recs);
|
|
2100
2136
|
}
|
|
2101
2137
|
const alerts = detectTransitions(state, records, config, now);
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2138
|
+
const isBootstrap = pollCount === 1 && Object.keys(state.agents).length === 0;
|
|
2139
|
+
if (isBootstrap) {
|
|
2140
|
+
const suppressed = alerts.length;
|
|
2141
|
+
if (suppressed > 0) {
|
|
2142
|
+
console.log(`[bootstrap] Suppressed ${suppressed} initial alerts (baseline scan)`);
|
|
2143
|
+
}
|
|
2144
|
+
} else {
|
|
2145
|
+
for (const alert of alerts) {
|
|
2146
|
+
for (const channel of config.notifyChannels) {
|
|
2147
|
+
await sendAlert(alert, channel);
|
|
2148
|
+
}
|
|
2105
2149
|
}
|
|
2106
2150
|
}
|
|
2107
2151
|
state = updateWatchState(state, records, alerts, now);
|
package/dist/cli.cjs
CHANGED
|
@@ -312,11 +312,29 @@ Examples:
|
|
|
312
312
|
`.trim()
|
|
313
313
|
);
|
|
314
314
|
}
|
|
315
|
+
var dirMtimeCache = /* @__PURE__ */ new Map();
|
|
316
|
+
var dirFileCache = /* @__PURE__ */ new Map();
|
|
315
317
|
function scanFiles(dirs, recursive) {
|
|
316
318
|
const results = [];
|
|
317
319
|
const seen = /* @__PURE__ */ new Set();
|
|
318
320
|
function scanDir(d, topLevel) {
|
|
319
321
|
try {
|
|
322
|
+
const dirStat = (0, import_node_fs.statSync)(d);
|
|
323
|
+
const dirMtime = dirStat.mtime.getTime();
|
|
324
|
+
const cachedMtime = dirMtimeCache.get(d);
|
|
325
|
+
if (cachedMtime === dirMtime) {
|
|
326
|
+
const cached = dirFileCache.get(d);
|
|
327
|
+
if (cached) {
|
|
328
|
+
for (const f of cached) {
|
|
329
|
+
if (!seen.has(f.path)) {
|
|
330
|
+
seen.add(f.path);
|
|
331
|
+
results.push(f);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
const dirResults = [];
|
|
320
338
|
for (const f of (0, import_node_fs.readdirSync)(d)) {
|
|
321
339
|
if (f.startsWith(".")) continue;
|
|
322
340
|
const fp = (0, import_node_path.join)(d, f);
|
|
@@ -334,12 +352,18 @@ function scanFiles(dirs, recursive) {
|
|
|
334
352
|
if (!stat.isFile()) continue;
|
|
335
353
|
if (f.endsWith(".json")) {
|
|
336
354
|
seen.add(fp);
|
|
337
|
-
|
|
355
|
+
const entry = { filename: f, path: fp, mtime: stat.mtime.getTime(), ext: ".json" };
|
|
356
|
+
results.push(entry);
|
|
357
|
+
dirResults.push(entry);
|
|
338
358
|
} else if (f.endsWith(".jsonl")) {
|
|
339
359
|
seen.add(fp);
|
|
340
|
-
|
|
360
|
+
const entry = { filename: f, path: fp, mtime: stat.mtime.getTime(), ext: ".jsonl" };
|
|
361
|
+
results.push(entry);
|
|
362
|
+
dirResults.push(entry);
|
|
341
363
|
}
|
|
342
364
|
}
|
|
365
|
+
dirMtimeCache.set(d, dirMtime);
|
|
366
|
+
dirFileCache.set(d, dirResults);
|
|
343
367
|
} catch {
|
|
344
368
|
}
|
|
345
369
|
}
|
|
@@ -683,20 +707,32 @@ var prevFileCount = 0;
|
|
|
683
707
|
var newExecCount = 0;
|
|
684
708
|
var sessionStart = Date.now();
|
|
685
709
|
var firstRender = true;
|
|
710
|
+
var fileCache = /* @__PURE__ */ new Map();
|
|
711
|
+
function getRecordsCached(f) {
|
|
712
|
+
const cached = fileCache.get(f.path);
|
|
713
|
+
if (cached && cached.mtime === f.mtime) return cached;
|
|
714
|
+
const records = f.ext === ".jsonl" ? processJsonlFile(f) : processJsonFile(f);
|
|
715
|
+
const traces = records.filter((r) => r.traceData).map((r) => r.traceData);
|
|
716
|
+
const entry = { mtime: f.mtime, records, traces };
|
|
717
|
+
fileCache.set(f.path, entry);
|
|
718
|
+
return entry;
|
|
719
|
+
}
|
|
686
720
|
function render(config) {
|
|
687
721
|
const files = scanFiles(config.dirs, config.recursive);
|
|
688
722
|
if (files.length > prevFileCount && prevFileCount > 0) {
|
|
689
723
|
newExecCount += files.length - prevFileCount;
|
|
690
724
|
}
|
|
691
725
|
prevFileCount = files.length;
|
|
726
|
+
const currentPaths = new Set(files.map((f) => f.path));
|
|
727
|
+
for (const key of fileCache.keys()) {
|
|
728
|
+
if (!currentPaths.has(key)) fileCache.delete(key);
|
|
729
|
+
}
|
|
692
730
|
const allRecords = [];
|
|
693
731
|
const allTraces = [];
|
|
694
732
|
for (const f of files.slice(0, 300)) {
|
|
695
|
-
const records
|
|
696
|
-
for (const r of records)
|
|
697
|
-
|
|
698
|
-
if (r.traceData) allTraces.push(r.traceData);
|
|
699
|
-
}
|
|
733
|
+
const { records, traces } = getRecordsCached(f);
|
|
734
|
+
for (const r of records) allRecords.push(r);
|
|
735
|
+
for (const t of traces) allTraces.push(t);
|
|
700
736
|
}
|
|
701
737
|
const deduped = [];
|
|
702
738
|
const seenAgents = /* @__PURE__ */ new Map();
|
|
@@ -2330,9 +2366,17 @@ agentflow watch started`);
|
|
|
2330
2366
|
records.push(...recs);
|
|
2331
2367
|
}
|
|
2332
2368
|
const alerts = detectTransitions(state, records, config, now);
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2369
|
+
const isBootstrap = pollCount === 1 && Object.keys(state.agents).length === 0;
|
|
2370
|
+
if (isBootstrap) {
|
|
2371
|
+
const suppressed = alerts.length;
|
|
2372
|
+
if (suppressed > 0) {
|
|
2373
|
+
console.log(`[bootstrap] Suppressed ${suppressed} initial alerts (baseline scan)`);
|
|
2374
|
+
}
|
|
2375
|
+
} else {
|
|
2376
|
+
for (const alert of alerts) {
|
|
2377
|
+
for (const channel of config.notifyChannels) {
|
|
2378
|
+
await sendAlert(alert, channel);
|
|
2379
|
+
}
|
|
2336
2380
|
}
|
|
2337
2381
|
}
|
|
2338
2382
|
state = updateWatchState(state, records, alerts, now);
|
package/dist/cli.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -760,11 +760,29 @@ Examples:
|
|
|
760
760
|
`.trim()
|
|
761
761
|
);
|
|
762
762
|
}
|
|
763
|
+
var dirMtimeCache = /* @__PURE__ */ new Map();
|
|
764
|
+
var dirFileCache = /* @__PURE__ */ new Map();
|
|
763
765
|
function scanFiles(dirs, recursive) {
|
|
764
766
|
const results = [];
|
|
765
767
|
const seen = /* @__PURE__ */ new Set();
|
|
766
768
|
function scanDir(d, topLevel) {
|
|
767
769
|
try {
|
|
770
|
+
const dirStat = (0, import_node_fs.statSync)(d);
|
|
771
|
+
const dirMtime = dirStat.mtime.getTime();
|
|
772
|
+
const cachedMtime = dirMtimeCache.get(d);
|
|
773
|
+
if (cachedMtime === dirMtime) {
|
|
774
|
+
const cached = dirFileCache.get(d);
|
|
775
|
+
if (cached) {
|
|
776
|
+
for (const f of cached) {
|
|
777
|
+
if (!seen.has(f.path)) {
|
|
778
|
+
seen.add(f.path);
|
|
779
|
+
results.push(f);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
const dirResults = [];
|
|
768
786
|
for (const f of (0, import_node_fs.readdirSync)(d)) {
|
|
769
787
|
if (f.startsWith(".")) continue;
|
|
770
788
|
const fp = (0, import_node_path.join)(d, f);
|
|
@@ -782,12 +800,18 @@ function scanFiles(dirs, recursive) {
|
|
|
782
800
|
if (!stat.isFile()) continue;
|
|
783
801
|
if (f.endsWith(".json")) {
|
|
784
802
|
seen.add(fp);
|
|
785
|
-
|
|
803
|
+
const entry = { filename: f, path: fp, mtime: stat.mtime.getTime(), ext: ".json" };
|
|
804
|
+
results.push(entry);
|
|
805
|
+
dirResults.push(entry);
|
|
786
806
|
} else if (f.endsWith(".jsonl")) {
|
|
787
807
|
seen.add(fp);
|
|
788
|
-
|
|
808
|
+
const entry = { filename: f, path: fp, mtime: stat.mtime.getTime(), ext: ".jsonl" };
|
|
809
|
+
results.push(entry);
|
|
810
|
+
dirResults.push(entry);
|
|
789
811
|
}
|
|
790
812
|
}
|
|
813
|
+
dirMtimeCache.set(d, dirMtime);
|
|
814
|
+
dirFileCache.set(d, dirResults);
|
|
791
815
|
} catch {
|
|
792
816
|
}
|
|
793
817
|
}
|
|
@@ -1131,20 +1155,32 @@ var prevFileCount = 0;
|
|
|
1131
1155
|
var newExecCount = 0;
|
|
1132
1156
|
var sessionStart = Date.now();
|
|
1133
1157
|
var firstRender = true;
|
|
1158
|
+
var fileCache = /* @__PURE__ */ new Map();
|
|
1159
|
+
function getRecordsCached(f) {
|
|
1160
|
+
const cached = fileCache.get(f.path);
|
|
1161
|
+
if (cached && cached.mtime === f.mtime) return cached;
|
|
1162
|
+
const records = f.ext === ".jsonl" ? processJsonlFile(f) : processJsonFile(f);
|
|
1163
|
+
const traces = records.filter((r) => r.traceData).map((r) => r.traceData);
|
|
1164
|
+
const entry = { mtime: f.mtime, records, traces };
|
|
1165
|
+
fileCache.set(f.path, entry);
|
|
1166
|
+
return entry;
|
|
1167
|
+
}
|
|
1134
1168
|
function render(config) {
|
|
1135
1169
|
const files = scanFiles(config.dirs, config.recursive);
|
|
1136
1170
|
if (files.length > prevFileCount && prevFileCount > 0) {
|
|
1137
1171
|
newExecCount += files.length - prevFileCount;
|
|
1138
1172
|
}
|
|
1139
1173
|
prevFileCount = files.length;
|
|
1174
|
+
const currentPaths = new Set(files.map((f) => f.path));
|
|
1175
|
+
for (const key of fileCache.keys()) {
|
|
1176
|
+
if (!currentPaths.has(key)) fileCache.delete(key);
|
|
1177
|
+
}
|
|
1140
1178
|
const allRecords = [];
|
|
1141
1179
|
const allTraces = [];
|
|
1142
1180
|
for (const f of files.slice(0, 300)) {
|
|
1143
|
-
const records
|
|
1144
|
-
for (const r of records)
|
|
1145
|
-
|
|
1146
|
-
if (r.traceData) allTraces.push(r.traceData);
|
|
1147
|
-
}
|
|
1181
|
+
const { records, traces } = getRecordsCached(f);
|
|
1182
|
+
for (const r of records) allRecords.push(r);
|
|
1183
|
+
for (const t of traces) allTraces.push(t);
|
|
1148
1184
|
}
|
|
1149
1185
|
const deduped = [];
|
|
1150
1186
|
const seenAgents = /* @__PURE__ */ new Map();
|
|
@@ -2356,9 +2392,17 @@ agentflow watch started`);
|
|
|
2356
2392
|
records.push(...recs);
|
|
2357
2393
|
}
|
|
2358
2394
|
const alerts = detectTransitions(state, records, config, now);
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2395
|
+
const isBootstrap = pollCount === 1 && Object.keys(state.agents).length === 0;
|
|
2396
|
+
if (isBootstrap) {
|
|
2397
|
+
const suppressed = alerts.length;
|
|
2398
|
+
if (suppressed > 0) {
|
|
2399
|
+
console.log(`[bootstrap] Suppressed ${suppressed} initial alerts (baseline scan)`);
|
|
2400
|
+
}
|
|
2401
|
+
} else {
|
|
2402
|
+
for (const alert of alerts) {
|
|
2403
|
+
for (const channel of config.notifyChannels) {
|
|
2404
|
+
await sendAlert(alert, channel);
|
|
2405
|
+
}
|
|
2362
2406
|
}
|
|
2363
2407
|
}
|
|
2364
2408
|
state = updateWatchState(state, records, alerts, now);
|
package/dist/index.js
CHANGED
package/package.json
CHANGED