agentflow-core 0.5.0 → 0.5.1

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.
@@ -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
- results.push({ filename: f, path: fp, mtime: stat.mtime.getTime(), ext: ".json" });
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
- results.push({ filename: f, path: fp, mtime: stat.mtime.getTime(), ext: ".jsonl" });
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 = f.ext === ".jsonl" ? processJsonlFile(f) : processJsonFile(f);
661
- for (const r of records) {
662
- allRecords.push(r);
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();
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
- results.push({ filename: f, path: fp, mtime: stat.mtime.getTime(), ext: ".json" });
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
- results.push({ filename: f, path: fp, mtime: stat.mtime.getTime(), ext: ".jsonl" });
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 = f.ext === ".jsonl" ? processJsonlFile(f) : processJsonFile(f);
696
- for (const r of records) {
697
- allRecords.push(r);
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();
package/dist/cli.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  startWatch,
7
7
  toAsciiTree,
8
8
  toTimeline
9
- } from "./chunk-T2BYYGA4.js";
9
+ } from "./chunk-LPTCBS77.js";
10
10
  import "./chunk-DY7YHFIB.js";
11
11
 
12
12
  // src/cli.ts
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
- results.push({ filename: f, path: fp, mtime: stat.mtime.getTime(), ext: ".json" });
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
- results.push({ filename: f, path: fp, mtime: stat.mtime.getTime(), ext: ".jsonl" });
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 = f.ext === ".jsonl" ? processJsonlFile(f) : processJsonFile(f);
1144
- for (const r of records) {
1145
- allRecords.push(r);
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();
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ import {
20
20
  stitchTrace,
21
21
  toAsciiTree,
22
22
  toTimeline
23
- } from "./chunk-T2BYYGA4.js";
23
+ } from "./chunk-LPTCBS77.js";
24
24
  import {
25
25
  graphToJson,
26
26
  loadGraph
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentflow-core",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Monitor any AI agent system. Auto-detects failures, sends alerts. Zero config, zero dependencies.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",