@datasynx/agentic-ai-cartography 2.6.0 → 2.7.0

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/cli.js CHANGED
@@ -11,12 +11,12 @@ import {
11
11
  runDrift,
12
12
  runLocalDiscovery,
13
13
  startMcp
14
- } from "./chunk-X3UWUX3G.js";
14
+ } from "./chunk-HLWNO3RF.js";
15
15
  import {
16
16
  entitiesToYaml,
17
17
  startApi,
18
18
  toBackstageEntities
19
- } from "./chunk-PQ7Q6MI5.js";
19
+ } from "./chunk-TBPGFEMQ.js";
20
20
  import {
21
21
  CartographyDB,
22
22
  buildCartographyToolHandlers,
@@ -28,7 +28,7 @@ import {
28
28
  redactValue,
29
29
  stableStringify,
30
30
  stripSensitive
31
- } from "./chunk-GA4427LB.js";
31
+ } from "./chunk-YVV6NIT2.js";
32
32
  import {
33
33
  ConfigFileSchema,
34
34
  CostEntrySchema,
@@ -4685,7 +4685,7 @@ ${infraSummary.substring(0, 12e3)}`;
4685
4685
  process.exitCode = 1;
4686
4686
  }
4687
4687
  });
4688
- program.command("prune").description("Delete old sessions and their data").option("--older-than <days>", "Delete sessions older than N days", "30").option("--db <path>", "DB path").option("--dry-run", "Show what would be deleted without actually deleting", false).action((opts) => {
4688
+ program.command("prune").description("Delete old sessions and their data").option("--older-than <days>", "Delete sessions older than N days", "30").option("--events-older-than <days>", "Compact the audit trail: delete activity events older than N days (4.7 retention)").option("--db <path>", "DB path").option("--dry-run", "Show what would be deleted without actually deleting", false).action((opts) => {
4689
4689
  const days = parseInt(opts.olderThan, 10);
4690
4690
  if (Number.isNaN(days) || days < 1) {
4691
4691
  process.stderr.write(`Invalid --older-than: "${opts.olderThan}" (must be >= 1)
@@ -4696,6 +4696,26 @@ ${infraSummary.substring(0, 12e3)}`;
4696
4696
  const config = defaultConfig({ ...opts.db ? { dbPath: opts.db } : {} });
4697
4697
  const db = new CartographyDB(config.dbPath);
4698
4698
  const cutoff = new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString();
4699
+ if (opts.eventsOlderThan !== void 0) {
4700
+ const eventDays = parseInt(opts.eventsOlderThan, 10);
4701
+ if (Number.isNaN(eventDays) || eventDays < 1) {
4702
+ process.stderr.write(`Invalid --events-older-than: "${opts.eventsOlderThan}" (must be >= 1)
4703
+ `);
4704
+ process.exitCode = 2;
4705
+ db.close();
4706
+ return;
4707
+ }
4708
+ const eventCutoff = new Date(Date.now() - eventDays * 24 * 60 * 60 * 1e3).toISOString();
4709
+ if (opts.dryRun) {
4710
+ process.stderr.write(`Would compact the audit trail (delete events older than ${eventDays} days).
4711
+ `);
4712
+ } else {
4713
+ const removed = db.pruneEventsOlderThan(eventCutoff);
4714
+ logInfo("Audit events pruned", { removed, olderThanDays: eventDays });
4715
+ process.stderr.write(`Deleted ${removed} audit event(s) older than ${eventDays} days.
4716
+ `);
4717
+ }
4718
+ }
4699
4719
  const sessions = db.getSessions().filter((s) => s.startedAt < cutoff);
4700
4720
  if (sessions.length === 0) {
4701
4721
  process.stderr.write(`No sessions older than ${days} days.