chainlesschain 0.81.0 → 0.132.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.
Files changed (110) hide show
  1. package/bin/chainlesschain.js +0 -0
  2. package/package.json +1 -1
  3. package/src/commands/agent-network.js +254 -1
  4. package/src/commands/audit.js +302 -0
  5. package/src/commands/automation.js +271 -1
  6. package/src/commands/codegen.js +224 -0
  7. package/src/commands/collab.js +341 -0
  8. package/src/commands/compliance.js +1035 -0
  9. package/src/commands/cowork.js +221 -0
  10. package/src/commands/dbevo.js +284 -0
  11. package/src/commands/dev.js +252 -0
  12. package/src/commands/did.js +358 -0
  13. package/src/commands/encrypt.js +341 -0
  14. package/src/commands/export.js +256 -1
  15. package/src/commands/fusion.js +258 -0
  16. package/src/commands/governance.js +325 -0
  17. package/src/commands/hardening.js +411 -0
  18. package/src/commands/hook.js +148 -0
  19. package/src/commands/import.js +252 -0
  20. package/src/commands/incentive.js +322 -0
  21. package/src/commands/infra.js +244 -0
  22. package/src/commands/instinct.js +260 -0
  23. package/src/commands/ipfs.js +318 -0
  24. package/src/commands/kg.js +387 -0
  25. package/src/commands/llm.js +263 -0
  26. package/src/commands/mcp.js +221 -0
  27. package/src/commands/memory.js +248 -0
  28. package/src/commands/multimodal.js +296 -0
  29. package/src/commands/nlprog.js +356 -0
  30. package/src/commands/note.js +244 -0
  31. package/src/commands/ops.js +354 -0
  32. package/src/commands/orchestrate.js +166 -0
  33. package/src/commands/org.js +277 -0
  34. package/src/commands/p2p.js +390 -0
  35. package/src/commands/perception.js +290 -0
  36. package/src/commands/permmem.js +251 -0
  37. package/src/commands/plugin-ecosystem.js +273 -0
  38. package/src/commands/pqc.js +393 -0
  39. package/src/commands/quantization.js +351 -0
  40. package/src/commands/rcache.js +271 -0
  41. package/src/commands/recommend.js +340 -0
  42. package/src/commands/runtime.js +307 -0
  43. package/src/commands/scim.js +262 -0
  44. package/src/commands/session.js +258 -0
  45. package/src/commands/skill.js +267 -1
  46. package/src/commands/social.js +256 -0
  47. package/src/commands/sso.js +186 -1
  48. package/src/commands/sync.js +256 -0
  49. package/src/commands/tech.js +338 -0
  50. package/src/commands/tenant.js +351 -0
  51. package/src/commands/tokens.js +269 -0
  52. package/src/commands/trust.js +249 -0
  53. package/src/commands/wallet.js +277 -0
  54. package/src/commands/workflow.js +171 -0
  55. package/src/index.js +4 -0
  56. package/src/lib/agent-coordinator.js +325 -0
  57. package/src/lib/agent-network.js +387 -0
  58. package/src/lib/agent-router.js +395 -0
  59. package/src/lib/aiops.js +478 -0
  60. package/src/lib/audit-logger.js +379 -0
  61. package/src/lib/automation-engine.js +330 -0
  62. package/src/lib/autonomous-developer.js +350 -0
  63. package/src/lib/code-agent.js +323 -0
  64. package/src/lib/collaboration-governance.js +364 -0
  65. package/src/lib/community-governance.js +436 -0
  66. package/src/lib/compliance-manager.js +434 -0
  67. package/src/lib/content-recommendation.js +469 -0
  68. package/src/lib/crypto-manager.js +350 -0
  69. package/src/lib/dbevo.js +338 -0
  70. package/src/lib/decentral-infra.js +340 -0
  71. package/src/lib/did-manager.js +367 -0
  72. package/src/lib/hardening-manager.js +348 -0
  73. package/src/lib/hook-manager.js +380 -0
  74. package/src/lib/instinct-manager.js +332 -0
  75. package/src/lib/ipfs-storage.js +334 -0
  76. package/src/lib/knowledge-exporter.js +381 -0
  77. package/src/lib/knowledge-graph.js +432 -0
  78. package/src/lib/knowledge-importer.js +379 -0
  79. package/src/lib/llm-providers.js +391 -0
  80. package/src/lib/mcp-registry.js +333 -0
  81. package/src/lib/memory-manager.js +330 -0
  82. package/src/lib/multimodal.js +346 -0
  83. package/src/lib/nl-programming.js +343 -0
  84. package/src/lib/note-versioning.js +327 -0
  85. package/src/lib/org-manager.js +323 -0
  86. package/src/lib/p2p-manager.js +387 -0
  87. package/src/lib/perception.js +346 -0
  88. package/src/lib/perf-tuning.js +4 -1
  89. package/src/lib/permanent-memory.js +320 -0
  90. package/src/lib/plugin-ecosystem.js +377 -0
  91. package/src/lib/pqc-manager.js +368 -0
  92. package/src/lib/protocol-fusion.js +417 -0
  93. package/src/lib/quantization.js +325 -0
  94. package/src/lib/response-cache.js +327 -0
  95. package/src/lib/scim-manager.js +329 -0
  96. package/src/lib/session-manager.js +329 -0
  97. package/src/lib/skill-loader.js +377 -0
  98. package/src/lib/social-manager.js +326 -0
  99. package/src/lib/sso-manager.js +332 -0
  100. package/src/lib/sync-manager.js +326 -0
  101. package/src/lib/tech-learning-engine.js +369 -0
  102. package/src/lib/tenant-saas.js +460 -0
  103. package/src/lib/threat-intel.js +335 -0
  104. package/src/lib/token-incentive.js +293 -0
  105. package/src/lib/token-tracker.js +329 -0
  106. package/src/lib/trust-security.js +390 -0
  107. package/src/lib/ueba.js +389 -0
  108. package/src/lib/universal-runtime.js +325 -0
  109. package/src/lib/wallet-manager.js +326 -0
  110. package/src/lib/workflow-engine.js +322 -0
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chainlesschain",
3
- "version": "0.81.0",
3
+ "version": "0.132.0",
4
4
  "description": "CLI for ChainlessChain - install, configure, and manage your personal AI management system",
5
5
  "type": "module",
6
6
  "bin": {
@@ -50,6 +50,37 @@ import {
50
50
  getTopAgents,
51
51
  getNetworkStats,
52
52
  getNetworkConfig,
53
+ AGENT_MATURITY_V2,
54
+ TASK_LIFECYCLE_V2,
55
+ getMaxActiveAgentsPerNetworkV2,
56
+ setMaxActiveAgentsPerNetworkV2,
57
+ getMaxPendingTasksPerAgentV2,
58
+ setMaxPendingTasksPerAgentV2,
59
+ getAgentIdleMsV2,
60
+ setAgentIdleMsV2,
61
+ getTaskStuckMsV2,
62
+ setTaskStuckMsV2,
63
+ registerAgentV2,
64
+ getAgentV2,
65
+ listAgentsV2,
66
+ setAgentStatusV2,
67
+ activateAgentV2,
68
+ suspendAgentV2,
69
+ revokeAgentV2,
70
+ touchAgentV2,
71
+ createTaskV2,
72
+ getTaskV2,
73
+ listTasksV2,
74
+ setTaskStatusV2,
75
+ startTaskV2,
76
+ completeTaskV2,
77
+ failTaskV2,
78
+ cancelTaskV2,
79
+ getActiveAgentCountV2,
80
+ getPendingTaskCountV2,
81
+ autoSuspendIdleAgentsV2,
82
+ autoFailStuckTasksV2,
83
+ getAgentNetworkStatsV2,
53
84
  } from "../lib/agent-network.js";
54
85
 
55
86
  function _dbFromCtx(cmd) {
@@ -81,7 +112,8 @@ export function registerAgentNetworkCommand(program) {
81
112
  .description(
82
113
  "Decentralized Agent Network (Phase 24) — DID / registry / credentials / task routing",
83
114
  )
84
- .hook("preAction", (thisCmd) => {
115
+ .hook("preAction", (thisCmd, actionCommand) => {
116
+ if (actionCommand && actionCommand.name().endsWith("-v2")) return;
85
117
  const db = _dbFromCtx(thisCmd);
86
118
  if (db) ensureAgentNetworkTables(db);
87
119
  });
@@ -780,6 +812,227 @@ export function registerAgentNetworkCommand(program) {
780
812
  console.log(`Peers: ${s.peers}`);
781
813
  });
782
814
 
815
+ // ─── V2 Governance Layer ──────────────────────────────────────────
816
+ const out = (obj) => console.log(JSON.stringify(obj, null, 2));
817
+ const tryRun = (fn) => {
818
+ try {
819
+ fn();
820
+ } catch (err) {
821
+ console.error(err.message);
822
+ process.exit(1);
823
+ }
824
+ };
825
+
826
+ anet
827
+ .command("agent-maturities-v2")
828
+ .description("List V2 agent maturity states")
829
+ .action(() => out(Object.values(AGENT_MATURITY_V2)));
830
+
831
+ anet
832
+ .command("task-lifecycles-v2")
833
+ .description("List V2 task lifecycle states")
834
+ .action(() => out(Object.values(TASK_LIFECYCLE_V2)));
835
+
836
+ anet
837
+ .command("stats-v2")
838
+ .description("V2 agent-network stats")
839
+ .action(() => out(getAgentNetworkStatsV2()));
840
+
841
+ anet
842
+ .command("get-max-active-agents-v2")
843
+ .description("Get max active agents per network (V2)")
844
+ .action(() =>
845
+ out({ maxActiveAgentsPerNetwork: getMaxActiveAgentsPerNetworkV2() }),
846
+ );
847
+
848
+ anet
849
+ .command("set-max-active-agents-v2 <n>")
850
+ .description("Set max active agents per network (V2)")
851
+ .action((n) =>
852
+ tryRun(() => {
853
+ setMaxActiveAgentsPerNetworkV2(Number(n));
854
+ out({ maxActiveAgentsPerNetwork: getMaxActiveAgentsPerNetworkV2() });
855
+ }),
856
+ );
857
+
858
+ anet
859
+ .command("get-max-pending-tasks-v2")
860
+ .description("Get max pending tasks per agent (V2)")
861
+ .action(() =>
862
+ out({ maxPendingTasksPerAgent: getMaxPendingTasksPerAgentV2() }),
863
+ );
864
+
865
+ anet
866
+ .command("set-max-pending-tasks-v2 <n>")
867
+ .description("Set max pending tasks per agent (V2)")
868
+ .action((n) =>
869
+ tryRun(() => {
870
+ setMaxPendingTasksPerAgentV2(Number(n));
871
+ out({ maxPendingTasksPerAgent: getMaxPendingTasksPerAgentV2() });
872
+ }),
873
+ );
874
+
875
+ anet
876
+ .command("get-agent-idle-ms-v2")
877
+ .description("Get agent idle threshold (V2)")
878
+ .action(() => out({ agentIdleMs: getAgentIdleMsV2() }));
879
+
880
+ anet
881
+ .command("set-agent-idle-ms-v2 <ms>")
882
+ .description("Set agent idle threshold (V2)")
883
+ .action((ms) =>
884
+ tryRun(() => {
885
+ setAgentIdleMsV2(Number(ms));
886
+ out({ agentIdleMs: getAgentIdleMsV2() });
887
+ }),
888
+ );
889
+
890
+ anet
891
+ .command("get-task-stuck-ms-v2")
892
+ .description("Get task stuck threshold (V2)")
893
+ .action(() => out({ taskStuckMs: getTaskStuckMsV2() }));
894
+
895
+ anet
896
+ .command("set-task-stuck-ms-v2 <ms>")
897
+ .description("Set task stuck threshold (V2)")
898
+ .action((ms) =>
899
+ tryRun(() => {
900
+ setTaskStuckMsV2(Number(ms));
901
+ out({ taskStuckMs: getTaskStuckMsV2() });
902
+ }),
903
+ );
904
+
905
+ anet
906
+ .command("active-agent-count-v2 <networkId>")
907
+ .description("Active agent count for network (V2)")
908
+ .action((networkId) =>
909
+ out({ networkId, count: getActiveAgentCountV2(networkId) }),
910
+ );
911
+
912
+ anet
913
+ .command("pending-task-count-v2 <agentId>")
914
+ .description("Pending task count for agent (V2)")
915
+ .action((agentId) =>
916
+ out({ agentId, count: getPendingTaskCountV2(agentId) }),
917
+ );
918
+
919
+ anet
920
+ .command("register-agent-v2 <id>")
921
+ .description("Register a V2 agent")
922
+ .requiredOption("-n, --network <id>", "network id")
923
+ .requiredOption("-d, --did <did>", "agent DID")
924
+ .option("--display <name>", "display name")
925
+ .action((id, opts) =>
926
+ tryRun(() =>
927
+ out(
928
+ registerAgentV2(id, {
929
+ networkId: opts.network,
930
+ did: opts.did,
931
+ displayName: opts.display,
932
+ }),
933
+ ),
934
+ ),
935
+ );
936
+
937
+ anet
938
+ .command("get-agent-v2 <id>")
939
+ .description("Get a V2 agent")
940
+ .action((id) => out(getAgentV2(id)));
941
+
942
+ anet
943
+ .command("list-agents-v2")
944
+ .description("List V2 agents")
945
+ .option("-n, --network <id>", "filter by network")
946
+ .option("-s, --status <status>", "filter by status")
947
+ .action((opts) =>
948
+ out(listAgentsV2({ networkId: opts.network, status: opts.status })),
949
+ );
950
+
951
+ anet
952
+ .command("set-agent-status-v2 <id> <next>")
953
+ .description("Set V2 agent status")
954
+ .action((id, next) => tryRun(() => out(setAgentStatusV2(id, next))));
955
+
956
+ anet
957
+ .command("activate-agent-v2 <id>")
958
+ .description("Activate a V2 agent")
959
+ .action((id) => tryRun(() => out(activateAgentV2(id))));
960
+
961
+ anet
962
+ .command("suspend-agent-v2 <id>")
963
+ .description("Suspend a V2 agent")
964
+ .action((id) => tryRun(() => out(suspendAgentV2(id))));
965
+
966
+ anet
967
+ .command("revoke-agent-v2 <id>")
968
+ .description("Revoke a V2 agent")
969
+ .action((id) => tryRun(() => out(revokeAgentV2(id))));
970
+
971
+ anet
972
+ .command("touch-agent-v2 <id>")
973
+ .description("Touch a V2 agent")
974
+ .action((id) => tryRun(() => out(touchAgentV2(id))));
975
+
976
+ anet
977
+ .command("create-task-v2 <id>")
978
+ .description("Create a V2 task")
979
+ .requiredOption("-a, --agent <id>", "agent id")
980
+ .option("-k, --kind <kind>", "task kind", "invoke")
981
+ .action((id, opts) =>
982
+ tryRun(() =>
983
+ out(createTaskV2(id, { agentId: opts.agent, kind: opts.kind })),
984
+ ),
985
+ );
986
+
987
+ anet
988
+ .command("get-task-v2 <id>")
989
+ .description("Get a V2 task")
990
+ .action((id) => out(getTaskV2(id)));
991
+
992
+ anet
993
+ .command("list-tasks-v2")
994
+ .description("List V2 tasks")
995
+ .option("-a, --agent <id>", "filter by agent")
996
+ .option("-s, --status <status>", "filter by status")
997
+ .action((opts) =>
998
+ out(listTasksV2({ agentId: opts.agent, status: opts.status })),
999
+ );
1000
+
1001
+ anet
1002
+ .command("set-task-status-v2 <id> <next>")
1003
+ .description("Set V2 task status")
1004
+ .action((id, next) => tryRun(() => out(setTaskStatusV2(id, next))));
1005
+
1006
+ anet
1007
+ .command("start-task-v2 <id>")
1008
+ .description("Start a V2 task")
1009
+ .action((id) => tryRun(() => out(startTaskV2(id))));
1010
+
1011
+ anet
1012
+ .command("complete-task-v2 <id>")
1013
+ .description("Complete a V2 task")
1014
+ .action((id) => tryRun(() => out(completeTaskV2(id))));
1015
+
1016
+ anet
1017
+ .command("fail-task-v2 <id>")
1018
+ .description("Fail a V2 task")
1019
+ .action((id) => tryRun(() => out(failTaskV2(id))));
1020
+
1021
+ anet
1022
+ .command("cancel-task-v2 <id>")
1023
+ .description("Cancel a V2 task")
1024
+ .action((id) => tryRun(() => out(cancelTaskV2(id))));
1025
+
1026
+ anet
1027
+ .command("auto-suspend-idle-agents-v2")
1028
+ .description("Auto-suspend idle V2 agents")
1029
+ .action(() => out(autoSuspendIdleAgentsV2()));
1030
+
1031
+ anet
1032
+ .command("auto-fail-stuck-tasks-v2")
1033
+ .description("Auto-fail stuck V2 tasks")
1034
+ .action(() => out(autoFailStuckTasksV2()));
1035
+
783
1036
  program.addCommand(anet);
784
1037
  return anet;
785
1038
  }
@@ -15,6 +15,34 @@ import {
15
15
  purgeLogs,
16
16
  EVENT_TYPES,
17
17
  RISK_LEVELS,
18
+ // V2
19
+ LOG_STATUS_V2,
20
+ INTEGRITY_STATUS_V2,
21
+ ALERT_STATUS_V2,
22
+ EVENT_TYPES_V2,
23
+ RISK_LEVELS_V2,
24
+ AUDIT_DEFAULT_MAX_ALERTS_PER_ACTOR,
25
+ AUDIT_DEFAULT_ARCHIVE_RETENTION_MS,
26
+ AUDIT_DEFAULT_PURGE_RETENTION_MS,
27
+ setMaxAlertsPerActor,
28
+ setArchiveRetentionMs,
29
+ setPurgeRetentionMs,
30
+ getMaxAlertsPerActor,
31
+ getArchiveRetentionMs,
32
+ getPurgeRetentionMs,
33
+ getOpenAlertCount,
34
+ logEventV2,
35
+ getLogStatusV2,
36
+ setLogStatusV2,
37
+ verifyChainV2,
38
+ autoArchiveLogs,
39
+ autoPurgeLogs,
40
+ getAlertStatusV2,
41
+ setAlertStatusV2,
42
+ acknowledgeAlert,
43
+ resolveAlert,
44
+ dismissAlert,
45
+ getAuditStatsV2,
18
46
  } from "../lib/audit-logger.js";
19
47
 
20
48
  const RISK_COLORS = {
@@ -283,4 +311,278 @@ export function registerAuditCommand(program) {
283
311
  logger.log(` ${color(value.padEnd(15))} ${chalk.gray(key)}`);
284
312
  }
285
313
  });
314
+
315
+ // ─────────────────────────────────────────────────────────────
316
+ // Phase 11 V2 — hash-chained integrity + log/alert lifecycle
317
+ // ─────────────────────────────────────────────────────────────
318
+
319
+ audit
320
+ .command("log-statuses-v2")
321
+ .description("List V2 log lifecycle states")
322
+ .action(() => {
323
+ for (const v of Object.values(LOG_STATUS_V2)) logger.log(v);
324
+ });
325
+
326
+ audit
327
+ .command("integrity-statuses-v2")
328
+ .description("List V2 integrity states")
329
+ .action(() => {
330
+ for (const v of Object.values(INTEGRITY_STATUS_V2)) logger.log(v);
331
+ });
332
+
333
+ audit
334
+ .command("alert-statuses-v2")
335
+ .description("List V2 alert lifecycle states")
336
+ .action(() => {
337
+ for (const v of Object.values(ALERT_STATUS_V2)) logger.log(v);
338
+ });
339
+
340
+ audit
341
+ .command("event-types-v2")
342
+ .description("List V2 event types")
343
+ .action(() => {
344
+ for (const v of EVENT_TYPES_V2) logger.log(v);
345
+ });
346
+
347
+ audit
348
+ .command("risk-levels-v2")
349
+ .description("List V2 risk levels")
350
+ .action(() => {
351
+ for (const v of RISK_LEVELS_V2) logger.log(v);
352
+ });
353
+
354
+ audit
355
+ .command("default-max-alerts-per-actor")
356
+ .description("Show default max alerts per actor")
357
+ .action(() => logger.log(String(AUDIT_DEFAULT_MAX_ALERTS_PER_ACTOR)));
358
+
359
+ audit
360
+ .command("max-alerts-per-actor")
361
+ .description("Show current max alerts per actor")
362
+ .action(() => logger.log(String(getMaxAlertsPerActor())));
363
+
364
+ audit
365
+ .command("set-max-alerts-per-actor <n>")
366
+ .description("Update max alerts per actor")
367
+ .action((n) => {
368
+ logger.log(String(setMaxAlertsPerActor(n)));
369
+ });
370
+
371
+ audit
372
+ .command("default-archive-retention-ms")
373
+ .description("Show default archive retention")
374
+ .action(() => logger.log(String(AUDIT_DEFAULT_ARCHIVE_RETENTION_MS)));
375
+
376
+ audit
377
+ .command("archive-retention-ms")
378
+ .description("Show current archive retention")
379
+ .action(() => logger.log(String(getArchiveRetentionMs())));
380
+
381
+ audit
382
+ .command("set-archive-retention-ms <ms>")
383
+ .description("Update archive retention (ms)")
384
+ .action((ms) => {
385
+ logger.log(String(setArchiveRetentionMs(ms)));
386
+ });
387
+
388
+ audit
389
+ .command("default-purge-retention-ms")
390
+ .description("Show default purge retention")
391
+ .action(() => logger.log(String(AUDIT_DEFAULT_PURGE_RETENTION_MS)));
392
+
393
+ audit
394
+ .command("purge-retention-ms")
395
+ .description("Show current purge retention")
396
+ .action(() => logger.log(String(getPurgeRetentionMs())));
397
+
398
+ audit
399
+ .command("set-purge-retention-ms <ms>")
400
+ .description("Update purge retention (ms)")
401
+ .action((ms) => {
402
+ logger.log(String(setPurgeRetentionMs(ms)));
403
+ });
404
+
405
+ audit
406
+ .command("open-alert-count")
407
+ .description("Count OPEN alerts (optionally scoped to actor)")
408
+ .option("-a, --actor <actor>", "Scope to actor")
409
+ .action((opts) => {
410
+ logger.log(String(getOpenAlertCount(opts.actor)));
411
+ });
412
+
413
+ audit
414
+ .command("log-event-v2 <log-id>")
415
+ .description("V2: register a hash-chained log entry")
416
+ .option("-t, --event-type <t>", "Event type (required)")
417
+ .option("-o, --operation <op>", "Operation (required)")
418
+ .option("-a, --actor <actor>", "Actor")
419
+ .option("-x, --target <target>", "Target")
420
+ .option("-d, --details <d>", "Details (JSON)")
421
+ .option("-r, --risk-level <rl>", "Risk level")
422
+ .option("-i, --ip-address <ip>", "IP address")
423
+ .option("-u, --user-agent <ua>", "User agent")
424
+ .action((logId, opts) => {
425
+ const db = bootstrap();
426
+ try {
427
+ const details = opts.details ? JSON.parse(opts.details) : undefined;
428
+ const entry = logEventV2(db, {
429
+ logId,
430
+ eventType: opts.eventType,
431
+ operation: opts.operation,
432
+ actor: opts.actor,
433
+ target: opts.target,
434
+ details,
435
+ riskLevel: opts.riskLevel,
436
+ ipAddress: opts.ipAddress,
437
+ userAgent: opts.userAgent,
438
+ });
439
+ logger.log(JSON.stringify(entry, null, 2));
440
+ } finally {
441
+ shutdown();
442
+ }
443
+ });
444
+
445
+ audit
446
+ .command("log-status-v2 <log-id>")
447
+ .description("V2: show log status + integrity")
448
+ .action((logId) => {
449
+ const entry = getLogStatusV2(logId);
450
+ if (!entry) {
451
+ logger.log(chalk.yellow("(not found)"));
452
+ return;
453
+ }
454
+ logger.log(JSON.stringify(entry, null, 2));
455
+ });
456
+
457
+ audit
458
+ .command("set-log-status-v2 <log-id> <status>")
459
+ .description("V2: transition log status (active|archived|purged)")
460
+ .option("-r, --reason <reason>", "Reason")
461
+ .action((logId, status, opts) => {
462
+ const db = bootstrap();
463
+ try {
464
+ const entry = setLogStatusV2(db, logId, status, {
465
+ reason: opts.reason,
466
+ });
467
+ logger.log(JSON.stringify(entry, null, 2));
468
+ } finally {
469
+ shutdown();
470
+ }
471
+ });
472
+
473
+ audit
474
+ .command("verify-chain-v2")
475
+ .description("V2: re-hash the chain and mark each entry verified/corrupted")
476
+ .action(() => {
477
+ const results = verifyChainV2();
478
+ logger.log(JSON.stringify(results, null, 2));
479
+ });
480
+
481
+ audit
482
+ .command("auto-archive-logs")
483
+ .description("V2: bulk-flip stale ACTIVE logs → ARCHIVED")
484
+ .action(() => {
485
+ const db = bootstrap();
486
+ try {
487
+ const archived = autoArchiveLogs(db);
488
+ logger.log(`Archived ${archived.length} log(s)`);
489
+ } finally {
490
+ shutdown();
491
+ }
492
+ });
493
+
494
+ audit
495
+ .command("auto-purge-logs")
496
+ .description("V2: bulk-flip stale ARCHIVED logs → PURGED")
497
+ .action(() => {
498
+ const db = bootstrap();
499
+ try {
500
+ const purged = autoPurgeLogs(db);
501
+ logger.log(`Purged ${purged.length} log(s)`);
502
+ } finally {
503
+ shutdown();
504
+ }
505
+ });
506
+
507
+ audit
508
+ .command("alert-status-v2 <alert-id>")
509
+ .description("V2: show alert status")
510
+ .action((alertId) => {
511
+ const entry = getAlertStatusV2(alertId);
512
+ if (!entry) {
513
+ logger.log(chalk.yellow("(not found)"));
514
+ return;
515
+ }
516
+ logger.log(JSON.stringify(entry, null, 2));
517
+ });
518
+
519
+ audit
520
+ .command("set-alert-status-v2 <alert-id> <status>")
521
+ .description(
522
+ "V2: transition alert status (open|acknowledged|resolved|dismissed)",
523
+ )
524
+ .option("-r, --reason <reason>", "Reason")
525
+ .option("-m, --metadata <meta>", "Metadata (JSON)")
526
+ .action((alertId, status, opts) => {
527
+ const db = bootstrap();
528
+ try {
529
+ const metadata = opts.metadata ? JSON.parse(opts.metadata) : undefined;
530
+ const entry = setAlertStatusV2(db, alertId, status, {
531
+ reason: opts.reason,
532
+ metadata,
533
+ });
534
+ logger.log(JSON.stringify(entry, null, 2));
535
+ } finally {
536
+ shutdown();
537
+ }
538
+ });
539
+
540
+ audit
541
+ .command("acknowledge-alert <alert-id>")
542
+ .description("V2: shortcut → acknowledged")
543
+ .option("-r, --reason <reason>", "Reason")
544
+ .action((alertId, opts) => {
545
+ const db = bootstrap();
546
+ try {
547
+ const entry = acknowledgeAlert(db, alertId, opts.reason);
548
+ logger.log(JSON.stringify(entry, null, 2));
549
+ } finally {
550
+ shutdown();
551
+ }
552
+ });
553
+
554
+ audit
555
+ .command("resolve-alert <alert-id>")
556
+ .description("V2: shortcut → resolved")
557
+ .option("-r, --reason <reason>", "Reason")
558
+ .action((alertId, opts) => {
559
+ const db = bootstrap();
560
+ try {
561
+ const entry = resolveAlert(db, alertId, opts.reason);
562
+ logger.log(JSON.stringify(entry, null, 2));
563
+ } finally {
564
+ shutdown();
565
+ }
566
+ });
567
+
568
+ audit
569
+ .command("dismiss-alert <alert-id>")
570
+ .description("V2: shortcut → dismissed")
571
+ .option("-r, --reason <reason>", "Reason")
572
+ .action((alertId, opts) => {
573
+ const db = bootstrap();
574
+ try {
575
+ const entry = dismissAlert(db, alertId, opts.reason);
576
+ logger.log(JSON.stringify(entry, null, 2));
577
+ } finally {
578
+ shutdown();
579
+ }
580
+ });
581
+
582
+ audit
583
+ .command("stats-v2")
584
+ .description("V2: all-enum-key stats snapshot")
585
+ .action(() => {
586
+ logger.log(JSON.stringify(getAuditStatsV2(), null, 2));
587
+ });
286
588
  }