chainlesschain 0.81.0 → 0.143.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 (209) hide show
  1. package/bin/chainlesschain.js +0 -0
  2. package/package.json +1 -1
  3. package/src/commands/a2a.js +62 -0
  4. package/src/commands/activitypub.js +61 -0
  5. package/src/commands/agent-network.js +254 -1
  6. package/src/commands/agent.js +117 -0
  7. package/src/commands/audit.js +302 -0
  8. package/src/commands/automation.js +271 -1
  9. package/src/commands/bi.js +61 -0
  10. package/src/commands/bm25.js +78 -0
  11. package/src/commands/browse.js +64 -0
  12. package/src/commands/ccron.js +78 -0
  13. package/src/commands/codegen.js +224 -0
  14. package/src/commands/collab.js +341 -0
  15. package/src/commands/compliance.js +1075 -0
  16. package/src/commands/compt.js +78 -0
  17. package/src/commands/consol.js +231 -0
  18. package/src/commands/cowork.js +263 -0
  19. package/src/commands/crosschain.js +62 -0
  20. package/src/commands/dao.js +62 -0
  21. package/src/commands/dbevo.js +284 -0
  22. package/src/commands/dev.js +252 -0
  23. package/src/commands/did.js +358 -0
  24. package/src/commands/dlp.js +61 -0
  25. package/src/commands/economy.js +56 -0
  26. package/src/commands/encrypt.js +341 -0
  27. package/src/commands/evolution.js +56 -0
  28. package/src/commands/evomap.js +61 -0
  29. package/src/commands/export.js +256 -1
  30. package/src/commands/fflag.js +178 -0
  31. package/src/commands/fusion.js +258 -0
  32. package/src/commands/git.js +45 -0
  33. package/src/commands/governance.js +325 -0
  34. package/src/commands/hardening.js +411 -0
  35. package/src/commands/hmemory.js +56 -0
  36. package/src/commands/hook.js +148 -0
  37. package/src/commands/import.js +252 -0
  38. package/src/commands/incentive.js +322 -0
  39. package/src/commands/inference.js +42 -0
  40. package/src/commands/infra.js +244 -0
  41. package/src/commands/instinct.js +260 -0
  42. package/src/commands/ipfs.js +318 -0
  43. package/src/commands/itbudget.js +45 -0
  44. package/src/commands/kg.js +387 -0
  45. package/src/commands/llm.js +263 -0
  46. package/src/commands/lowcode.js +44 -0
  47. package/src/commands/matrix.js +62 -0
  48. package/src/commands/mcp.js +221 -0
  49. package/src/commands/mcpscaf.js +41 -0
  50. package/src/commands/meminj.js +41 -0
  51. package/src/commands/memory.js +248 -0
  52. package/src/commands/multimodal.js +296 -0
  53. package/src/commands/nlprog.js +356 -0
  54. package/src/commands/nostr.js +62 -0
  55. package/src/commands/note.js +244 -0
  56. package/src/commands/ops.js +354 -0
  57. package/src/commands/orchestrate.js +166 -0
  58. package/src/commands/orchgov.js +45 -0
  59. package/src/commands/org.js +277 -0
  60. package/src/commands/p2p.js +390 -0
  61. package/src/commands/pdfp.js +78 -0
  62. package/src/commands/perception.js +290 -0
  63. package/src/commands/perf.js +39 -0
  64. package/src/commands/perm.js +45 -0
  65. package/src/commands/permmem.js +251 -0
  66. package/src/commands/pipeline.js +57 -1
  67. package/src/commands/planmode.js +45 -0
  68. package/src/commands/plugin-ecosystem.js +273 -0
  69. package/src/commands/pqc.js +393 -0
  70. package/src/commands/promcomp.js +82 -0
  71. package/src/commands/quantization.js +351 -0
  72. package/src/commands/rcache.js +271 -0
  73. package/src/commands/recommend.js +382 -0
  74. package/src/commands/runtime.js +307 -0
  75. package/src/commands/scim.js +262 -0
  76. package/src/commands/seshhook.js +41 -0
  77. package/src/commands/seshsearch.js +41 -0
  78. package/src/commands/seshtail.js +41 -0
  79. package/src/commands/seshu.js +41 -0
  80. package/src/commands/session.js +258 -0
  81. package/src/commands/sganal.js +78 -0
  82. package/src/commands/siem.js +40 -0
  83. package/src/commands/skill.js +267 -1
  84. package/src/commands/slotfill.js +41 -0
  85. package/src/commands/social.js +290 -0
  86. package/src/commands/sso.js +186 -1
  87. package/src/commands/svccont.js +45 -0
  88. package/src/commands/sync.js +256 -0
  89. package/src/commands/tech.js +338 -0
  90. package/src/commands/tenant.js +351 -0
  91. package/src/commands/tms.js +45 -0
  92. package/src/commands/tokens.js +269 -0
  93. package/src/commands/topiccls.js +45 -0
  94. package/src/commands/trust.js +249 -0
  95. package/src/commands/uprof.js +45 -0
  96. package/src/commands/vcheck.js +78 -0
  97. package/src/commands/wallet.js +277 -0
  98. package/src/commands/webfetch.js +41 -0
  99. package/src/commands/workflow.js +171 -0
  100. package/src/commands/zkp.js +62 -0
  101. package/src/harness/prompt-compressor.js +331 -0
  102. package/src/index.js +65 -1
  103. package/src/lib/a2a-protocol.js +105 -0
  104. package/src/lib/activitypub-bridge.js +105 -0
  105. package/src/lib/agent-coordinator.js +325 -0
  106. package/src/lib/agent-economy.js +105 -0
  107. package/src/lib/agent-network.js +387 -0
  108. package/src/lib/agent-router.js +395 -0
  109. package/src/lib/aiops.js +478 -0
  110. package/src/lib/app-builder.js +105 -0
  111. package/src/lib/audit-logger.js +379 -0
  112. package/src/lib/automation-engine.js +330 -0
  113. package/src/lib/autonomous-agent.js +105 -0
  114. package/src/lib/autonomous-developer.js +350 -0
  115. package/src/lib/bi-engine.js +105 -0
  116. package/src/lib/bm25-search.js +81 -0
  117. package/src/lib/browser-automation.js +105 -0
  118. package/src/lib/code-agent.js +323 -0
  119. package/src/lib/collaboration-governance.js +364 -0
  120. package/src/lib/community-governance.js +436 -0
  121. package/src/lib/compliance-framework-reporter.js +105 -0
  122. package/src/lib/compliance-manager.js +434 -0
  123. package/src/lib/compression-telemetry.js +81 -0
  124. package/src/lib/content-recommendation.js +469 -0
  125. package/src/lib/content-recommender.js +105 -0
  126. package/src/lib/cowork-cron.js +81 -0
  127. package/src/lib/cowork-task-runner.js +105 -0
  128. package/src/lib/cross-chain.js +105 -0
  129. package/src/lib/crypto-manager.js +350 -0
  130. package/src/lib/dao-governance.js +105 -0
  131. package/src/lib/dbevo.js +338 -0
  132. package/src/lib/decentral-infra.js +340 -0
  133. package/src/lib/did-manager.js +367 -0
  134. package/src/lib/dlp-engine.js +105 -0
  135. package/src/lib/evolution-system.js +105 -0
  136. package/src/lib/evomap-manager.js +105 -0
  137. package/src/lib/execution-backend.js +105 -0
  138. package/src/lib/feature-flags.js +85 -0
  139. package/src/lib/git-integration.js +105 -0
  140. package/src/lib/hardening-manager.js +348 -0
  141. package/src/lib/hierarchical-memory.js +105 -0
  142. package/src/lib/hook-manager.js +380 -0
  143. package/src/lib/inference-network.js +105 -0
  144. package/src/lib/instinct-manager.js +332 -0
  145. package/src/lib/ipfs-storage.js +334 -0
  146. package/src/lib/iteration-budget.js +105 -0
  147. package/src/lib/knowledge-exporter.js +381 -0
  148. package/src/lib/knowledge-graph.js +432 -0
  149. package/src/lib/knowledge-importer.js +379 -0
  150. package/src/lib/llm-providers.js +391 -0
  151. package/src/lib/matrix-bridge.js +105 -0
  152. package/src/lib/mcp-registry.js +333 -0
  153. package/src/lib/mcp-scaffold.js +81 -0
  154. package/src/lib/memory-injection.js +81 -0
  155. package/src/lib/memory-manager.js +330 -0
  156. package/src/lib/multimodal.js +346 -0
  157. package/src/lib/nl-programming.js +343 -0
  158. package/src/lib/nostr-bridge.js +105 -0
  159. package/src/lib/note-versioning.js +327 -0
  160. package/src/lib/orchestrator.js +105 -0
  161. package/src/lib/org-manager.js +323 -0
  162. package/src/lib/p2p-manager.js +387 -0
  163. package/src/lib/pdf-parser.js +81 -0
  164. package/src/lib/perception.js +346 -0
  165. package/src/lib/perf-tuning.js +109 -1
  166. package/src/lib/permanent-memory.js +320 -0
  167. package/src/lib/permission-engine.js +81 -0
  168. package/src/lib/pipeline-orchestrator.js +105 -0
  169. package/src/lib/plan-mode.js +81 -0
  170. package/src/lib/plugin-ecosystem.js +377 -0
  171. package/src/lib/pqc-manager.js +368 -0
  172. package/src/lib/prompt-compressor.js +1 -10
  173. package/src/lib/protocol-fusion.js +417 -0
  174. package/src/lib/quantization.js +325 -0
  175. package/src/lib/response-cache.js +327 -0
  176. package/src/lib/scim-manager.js +329 -0
  177. package/src/lib/service-container.js +81 -0
  178. package/src/lib/session-consolidator.js +105 -0
  179. package/src/lib/session-hooks.js +81 -0
  180. package/src/lib/session-manager.js +329 -0
  181. package/src/lib/session-search.js +81 -0
  182. package/src/lib/session-tail.js +81 -0
  183. package/src/lib/session-usage.js +83 -0
  184. package/src/lib/siem-exporter.js +105 -0
  185. package/src/lib/skill-loader.js +377 -0
  186. package/src/lib/slot-filler.js +81 -0
  187. package/src/lib/social-graph-analytics.js +81 -0
  188. package/src/lib/social-graph.js +81 -0
  189. package/src/lib/social-manager.js +326 -0
  190. package/src/lib/sso-manager.js +332 -0
  191. package/src/lib/sub-agent-registry.js +110 -0
  192. package/src/lib/sync-manager.js +326 -0
  193. package/src/lib/task-model-selector.js +81 -0
  194. package/src/lib/tech-learning-engine.js +369 -0
  195. package/src/lib/tenant-saas.js +460 -0
  196. package/src/lib/threat-intel.js +335 -0
  197. package/src/lib/todo-manager.js +105 -0
  198. package/src/lib/token-incentive.js +293 -0
  199. package/src/lib/token-tracker.js +329 -0
  200. package/src/lib/topic-classifier.js +105 -0
  201. package/src/lib/trust-security.js +390 -0
  202. package/src/lib/ueba.js +389 -0
  203. package/src/lib/universal-runtime.js +325 -0
  204. package/src/lib/user-profile.js +81 -0
  205. package/src/lib/version-checker.js +81 -0
  206. package/src/lib/wallet-manager.js +326 -0
  207. package/src/lib/web-fetch.js +81 -0
  208. package/src/lib/workflow-engine.js +322 -0
  209. package/src/lib/zkp-engine.js +105 -0
@@ -17,6 +17,35 @@ import {
17
17
  listDailyNotes,
18
18
  getMemoryFile,
19
19
  updateMemoryFile,
20
+ ENTRY_MATURITY_V2,
21
+ CONSOLIDATION_LIFECYCLE_V2,
22
+ getMaxActiveEntriesPerCategoryV2,
23
+ setMaxActiveEntriesPerCategoryV2,
24
+ getMaxRunningJobsPerSourceV2,
25
+ setMaxRunningJobsPerSourceV2,
26
+ getEntryIdleMsV2,
27
+ setEntryIdleMsV2,
28
+ getJobStuckMsV2,
29
+ setJobStuckMsV2,
30
+ getActiveEntryCountV2,
31
+ getRunningJobCountV2,
32
+ registerEntryV2,
33
+ getEntryV2,
34
+ listEntriesV2,
35
+ activateEntryV2,
36
+ parkEntryV2,
37
+ archiveEntryV2,
38
+ touchEntryV2,
39
+ createConsolidationJobV2,
40
+ getConsolidationJobV2,
41
+ listConsolidationJobsV2,
42
+ startConsolidationJobV2,
43
+ succeedConsolidationJobV2,
44
+ failConsolidationJobV2,
45
+ cancelConsolidationJobV2,
46
+ autoParkIdleEntriesV2,
47
+ autoFailStuckJobsV2,
48
+ getMemoryManagerStatsV2,
20
49
  } from "../lib/memory-manager.js";
21
50
 
22
51
  export function registerMemoryCommand(program) {
@@ -454,4 +483,223 @@ export function registerMemoryCommand(program) {
454
483
  process.exit(1);
455
484
  }
456
485
  });
486
+
487
+ // ─── V2 governance surface ─────────────────────────────────
488
+
489
+ memory
490
+ .command("entry-maturities-v2")
491
+ .description("List V2 entry maturity states")
492
+ .action(() => {
493
+ console.log(JSON.stringify(Object.values(ENTRY_MATURITY_V2), null, 2));
494
+ });
495
+
496
+ memory
497
+ .command("consolidation-lifecycles-v2")
498
+ .description("List V2 consolidation job lifecycle states")
499
+ .action(() => {
500
+ console.log(
501
+ JSON.stringify(Object.values(CONSOLIDATION_LIFECYCLE_V2), null, 2),
502
+ );
503
+ });
504
+
505
+ memory
506
+ .command("stats-v2")
507
+ .description("Show V2 governance stats")
508
+ .action(() => {
509
+ console.log(JSON.stringify(getMemoryManagerStatsV2(), null, 2));
510
+ });
511
+
512
+ memory
513
+ .command("get-max-active-entries-v2")
514
+ .description("Get max active entries per category")
515
+ .action(() => console.log(getMaxActiveEntriesPerCategoryV2()));
516
+
517
+ memory
518
+ .command("set-max-active-entries-v2 <n>")
519
+ .description("Set max active entries per category")
520
+ .action((n) => {
521
+ setMaxActiveEntriesPerCategoryV2(Number(n));
522
+ console.log(getMaxActiveEntriesPerCategoryV2());
523
+ });
524
+
525
+ memory
526
+ .command("get-max-running-jobs-v2")
527
+ .description("Get max running jobs per source")
528
+ .action(() => console.log(getMaxRunningJobsPerSourceV2()));
529
+
530
+ memory
531
+ .command("set-max-running-jobs-v2 <n>")
532
+ .description("Set max running jobs per source")
533
+ .action((n) => {
534
+ setMaxRunningJobsPerSourceV2(Number(n));
535
+ console.log(getMaxRunningJobsPerSourceV2());
536
+ });
537
+
538
+ memory
539
+ .command("get-entry-idle-ms-v2")
540
+ .description("Get entry idle threshold (ms)")
541
+ .action(() => console.log(getEntryIdleMsV2()));
542
+
543
+ memory
544
+ .command("set-entry-idle-ms-v2 <n>")
545
+ .description("Set entry idle threshold (ms)")
546
+ .action((n) => {
547
+ setEntryIdleMsV2(Number(n));
548
+ console.log(getEntryIdleMsV2());
549
+ });
550
+
551
+ memory
552
+ .command("get-job-stuck-ms-v2")
553
+ .description("Get job stuck threshold (ms)")
554
+ .action(() => console.log(getJobStuckMsV2()));
555
+
556
+ memory
557
+ .command("set-job-stuck-ms-v2 <n>")
558
+ .description("Set job stuck threshold (ms)")
559
+ .action((n) => {
560
+ setJobStuckMsV2(Number(n));
561
+ console.log(getJobStuckMsV2());
562
+ });
563
+
564
+ memory
565
+ .command("active-entry-count-v2 <category>")
566
+ .description("Count active entries for a category")
567
+ .action((category) => console.log(getActiveEntryCountV2(category)));
568
+
569
+ memory
570
+ .command("running-job-count-v2 <source>")
571
+ .description("Count running jobs for a source")
572
+ .action((source) => console.log(getRunningJobCountV2(source)));
573
+
574
+ memory
575
+ .command("register-entry-v2 <id>")
576
+ .description("Register a V2 entry")
577
+ .requiredOption("-c, --category <category>", "Category")
578
+ .requiredOption("-s, --summary <summary>", "Summary")
579
+ .action((id, opts) => {
580
+ const e = registerEntryV2(id, {
581
+ category: opts.category,
582
+ summary: opts.summary,
583
+ });
584
+ console.log(JSON.stringify(e, null, 2));
585
+ });
586
+
587
+ memory
588
+ .command("get-entry-v2 <id>")
589
+ .description("Get a V2 entry")
590
+ .action((id) => {
591
+ const e = getEntryV2(id);
592
+ console.log(e ? JSON.stringify(e, null, 2) : "null");
593
+ });
594
+
595
+ memory
596
+ .command("list-entries-v2")
597
+ .description("List V2 entries")
598
+ .option("-c, --category <category>", "Filter by category")
599
+ .option("-s, --status <status>", "Filter by status")
600
+ .action((opts) => {
601
+ console.log(
602
+ JSON.stringify(
603
+ listEntriesV2({ category: opts.category, status: opts.status }),
604
+ null,
605
+ 2,
606
+ ),
607
+ );
608
+ });
609
+
610
+ memory
611
+ .command("activate-entry-v2 <id>")
612
+ .description("pending|parked → active")
613
+ .action((id) => console.log(JSON.stringify(activateEntryV2(id), null, 2)));
614
+
615
+ memory
616
+ .command("park-entry-v2 <id>")
617
+ .description("active → parked")
618
+ .action((id) => console.log(JSON.stringify(parkEntryV2(id), null, 2)));
619
+
620
+ memory
621
+ .command("archive-entry-v2 <id>")
622
+ .description("→ archived (terminal)")
623
+ .action((id) => console.log(JSON.stringify(archiveEntryV2(id), null, 2)));
624
+
625
+ memory
626
+ .command("touch-entry-v2 <id>")
627
+ .description("Update lastSeenAt")
628
+ .action((id) => console.log(JSON.stringify(touchEntryV2(id), null, 2)));
629
+
630
+ memory
631
+ .command("create-job-v2 <id>")
632
+ .description("Create a V2 consolidation job")
633
+ .requiredOption("-s, --source <source>", "Source")
634
+ .requiredOption("-c, --scope <scope>", "Scope")
635
+ .action((id, opts) => {
636
+ const j = createConsolidationJobV2(id, {
637
+ source: opts.source,
638
+ scope: opts.scope,
639
+ });
640
+ console.log(JSON.stringify(j, null, 2));
641
+ });
642
+
643
+ memory
644
+ .command("get-job-v2 <id>")
645
+ .description("Get a V2 consolidation job")
646
+ .action((id) => {
647
+ const j = getConsolidationJobV2(id);
648
+ console.log(j ? JSON.stringify(j, null, 2) : "null");
649
+ });
650
+
651
+ memory
652
+ .command("list-jobs-v2")
653
+ .description("List V2 consolidation jobs")
654
+ .option("-s, --source <source>", "Filter by source")
655
+ .option("--status <status>", "Filter by status")
656
+ .action((opts) => {
657
+ console.log(
658
+ JSON.stringify(
659
+ listConsolidationJobsV2({ source: opts.source, status: opts.status }),
660
+ null,
661
+ 2,
662
+ ),
663
+ );
664
+ });
665
+
666
+ memory
667
+ .command("start-job-v2 <id>")
668
+ .description("queued → running")
669
+ .action((id) =>
670
+ console.log(JSON.stringify(startConsolidationJobV2(id), null, 2)),
671
+ );
672
+
673
+ memory
674
+ .command("succeed-job-v2 <id>")
675
+ .description("running → succeeded (terminal)")
676
+ .action((id) =>
677
+ console.log(JSON.stringify(succeedConsolidationJobV2(id), null, 2)),
678
+ );
679
+
680
+ memory
681
+ .command("fail-job-v2 <id>")
682
+ .description("running → failed (terminal)")
683
+ .action((id) =>
684
+ console.log(JSON.stringify(failConsolidationJobV2(id), null, 2)),
685
+ );
686
+
687
+ memory
688
+ .command("cancel-job-v2 <id>")
689
+ .description("queued|running → cancelled (terminal)")
690
+ .action((id) =>
691
+ console.log(JSON.stringify(cancelConsolidationJobV2(id), null, 2)),
692
+ );
693
+
694
+ memory
695
+ .command("auto-park-idle-entries-v2")
696
+ .description("Flip idle active entries → parked")
697
+ .action(() =>
698
+ console.log(JSON.stringify(autoParkIdleEntriesV2(), null, 2)),
699
+ );
700
+
701
+ memory
702
+ .command("auto-fail-stuck-jobs-v2")
703
+ .description("Flip stuck running jobs → failed")
704
+ .action(() => console.log(JSON.stringify(autoFailStuckJobsV2(), null, 2)));
457
705
  }
@@ -35,6 +35,40 @@ import {
35
35
  getOutputFormats,
36
36
  listArtifacts,
37
37
  getMultimodalStats,
38
+ // V2 (Phase 27 V2)
39
+ SESSION_MATURITY_V2,
40
+ ARTIFACT_LIFECYCLE_V2,
41
+ getDefaultMaxActiveSessionsPerOwnerV2,
42
+ getMaxActiveSessionsPerOwnerV2,
43
+ setMaxActiveSessionsPerOwnerV2,
44
+ getDefaultMaxArtifactsPerSessionV2,
45
+ getMaxArtifactsPerSessionV2,
46
+ setMaxArtifactsPerSessionV2,
47
+ getDefaultSessionIdleMsV2,
48
+ getSessionIdleMsV2,
49
+ setSessionIdleMsV2,
50
+ getDefaultArtifactStaleMsV2,
51
+ getArtifactStaleMsV2,
52
+ setArtifactStaleMsV2,
53
+ registerSessionV2,
54
+ getSessionV2,
55
+ setSessionMaturityV2,
56
+ activateSession,
57
+ pauseSession,
58
+ completeSessionV2,
59
+ archiveSession,
60
+ touchSessionActivity,
61
+ registerArtifactV2,
62
+ getArtifactV2,
63
+ setArtifactStatusV2,
64
+ markArtifactReady,
65
+ purgeArtifact,
66
+ touchArtifactAccess,
67
+ getActiveSessionCount,
68
+ getArtifactCount,
69
+ autoArchiveIdleSessions,
70
+ autoPurgeStaleArtifacts,
71
+ getMultimodalStatsV2,
38
72
  } from "../lib/multimodal.js";
39
73
 
40
74
  function _dbFromCtx(cmd) {
@@ -400,5 +434,267 @@ export function registerMultimodalCommand(program) {
400
434
  console.log(` ${k}: ${v}`);
401
435
  });
402
436
 
437
+ /* ── V2 (Phase 27 V2) ────────────────────────────── */
438
+
439
+ function _parseJsonFlag(value, label) {
440
+ if (value === undefined) return undefined;
441
+ try {
442
+ return JSON.parse(value);
443
+ } catch {
444
+ throw new Error(`Invalid JSON for ${label}`);
445
+ }
446
+ }
447
+
448
+ mm.command("session-maturities-v2")
449
+ .option("--json", "JSON output")
450
+ .description("List V2 session maturity states")
451
+ .action((opts) => {
452
+ const out = Object.values(SESSION_MATURITY_V2);
453
+ if (opts.json) return console.log(JSON.stringify(out, null, 2));
454
+ for (const s of out) console.log(` ${s}`);
455
+ });
456
+
457
+ mm.command("artifact-lifecycles-v2")
458
+ .option("--json", "JSON output")
459
+ .description("List V2 artifact lifecycle states")
460
+ .action((opts) => {
461
+ const out = Object.values(ARTIFACT_LIFECYCLE_V2);
462
+ if (opts.json) return console.log(JSON.stringify(out, null, 2));
463
+ for (const s of out) console.log(` ${s}`);
464
+ });
465
+
466
+ mm.command("default-max-active-sessions-per-owner")
467
+ .description("Show V2 default per-owner active-session cap")
468
+ .action(() => console.log(String(getDefaultMaxActiveSessionsPerOwnerV2())));
469
+ mm.command("max-active-sessions-per-owner")
470
+ .description("Show current V2 per-owner active-session cap")
471
+ .action(() => console.log(String(getMaxActiveSessionsPerOwnerV2())));
472
+ mm.command("set-max-active-sessions-per-owner <n>")
473
+ .description("Set V2 per-owner active-session cap")
474
+ .action((n) =>
475
+ console.log(String(setMaxActiveSessionsPerOwnerV2(Number(n)))),
476
+ );
477
+
478
+ mm.command("default-max-artifacts-per-session")
479
+ .description("Show V2 default per-session artifact cap")
480
+ .action(() => console.log(String(getDefaultMaxArtifactsPerSessionV2())));
481
+ mm.command("max-artifacts-per-session")
482
+ .description("Show current V2 per-session artifact cap")
483
+ .action(() => console.log(String(getMaxArtifactsPerSessionV2())));
484
+ mm.command("set-max-artifacts-per-session <n>")
485
+ .description("Set V2 per-session artifact cap")
486
+ .action((n) => console.log(String(setMaxArtifactsPerSessionV2(Number(n)))));
487
+
488
+ mm.command("default-session-idle-ms")
489
+ .description("Show V2 default session-idle window (ms)")
490
+ .action(() => console.log(String(getDefaultSessionIdleMsV2())));
491
+ mm.command("session-idle-ms")
492
+ .description("Show current V2 session-idle window (ms)")
493
+ .action(() => console.log(String(getSessionIdleMsV2())));
494
+ mm.command("set-session-idle-ms <ms>")
495
+ .description("Set V2 session-idle window (ms)")
496
+ .action((ms) => console.log(String(setSessionIdleMsV2(Number(ms)))));
497
+
498
+ mm.command("default-artifact-stale-ms")
499
+ .description("Show V2 default artifact-stale window (ms)")
500
+ .action(() => console.log(String(getDefaultArtifactStaleMsV2())));
501
+ mm.command("artifact-stale-ms")
502
+ .description("Show current V2 artifact-stale window (ms)")
503
+ .action(() => console.log(String(getArtifactStaleMsV2())));
504
+ mm.command("set-artifact-stale-ms <ms>")
505
+ .description("Set V2 artifact-stale window (ms)")
506
+ .action((ms) => console.log(String(setArtifactStaleMsV2(Number(ms)))));
507
+
508
+ mm.command("active-session-count")
509
+ .description("Count active V2 sessions (optionally scoped by owner)")
510
+ .option("-o, --owner <owner>", "Scope by owner")
511
+ .action((opts) => console.log(String(getActiveSessionCount(opts.owner))));
512
+
513
+ mm.command("artifact-count")
514
+ .description("Count open V2 artifacts (optionally scoped by session)")
515
+ .option("-s, --session <session>", "Scope by session")
516
+ .action((opts) => console.log(String(getArtifactCount(opts.session))));
517
+
518
+ mm.command("register-session-v2 <session-id>")
519
+ .description("Register a V2 session")
520
+ .requiredOption("-o, --owner-id <owner>", "Owner id")
521
+ .option("-t, --title <title>", "Title")
522
+ .option("-i, --initial-status <status>", "Initial maturity status")
523
+ .option("-m, --metadata <json>", "Metadata JSON")
524
+ .action((sessionId, opts) => {
525
+ const db = _dbFromCtx(mm);
526
+ const metadata = _parseJsonFlag(opts.metadata, "--metadata");
527
+ console.log(
528
+ JSON.stringify(
529
+ registerSessionV2(db, {
530
+ sessionId,
531
+ ownerId: opts.ownerId,
532
+ title: opts.title,
533
+ initialStatus: opts.initialStatus,
534
+ metadata,
535
+ }),
536
+ null,
537
+ 2,
538
+ ),
539
+ );
540
+ });
541
+
542
+ mm.command("session-v2 <session-id>")
543
+ .description("Show a V2 session")
544
+ .action((sessionId) => {
545
+ const out = getSessionV2(sessionId);
546
+ console.log(out ? JSON.stringify(out, null, 2) : "null");
547
+ });
548
+
549
+ mm.command("set-session-maturity-v2 <session-id> <status>")
550
+ .description("Set V2 session maturity status")
551
+ .option("-r, --reason <reason>", "Reason")
552
+ .option("-m, --metadata <json>", "Metadata JSON (merged)")
553
+ .action((sessionId, status, opts) => {
554
+ const db = _dbFromCtx(mm);
555
+ const metadata = _parseJsonFlag(opts.metadata, "--metadata");
556
+ console.log(
557
+ JSON.stringify(
558
+ setSessionMaturityV2(db, sessionId, status, {
559
+ reason: opts.reason,
560
+ metadata,
561
+ }),
562
+ null,
563
+ 2,
564
+ ),
565
+ );
566
+ });
567
+
568
+ mm.command("activate-session <session-id>")
569
+ .option("-r, --reason <reason>")
570
+ .description("Activate a V2 session")
571
+ .action((id, opts) => {
572
+ const db = _dbFromCtx(mm);
573
+ console.log(
574
+ JSON.stringify(activateSession(db, id, opts.reason), null, 2),
575
+ );
576
+ });
577
+ mm.command("pause-session <session-id>")
578
+ .option("-r, --reason <reason>")
579
+ .description("Pause a V2 session")
580
+ .action((id, opts) => {
581
+ const db = _dbFromCtx(mm);
582
+ console.log(JSON.stringify(pauseSession(db, id, opts.reason), null, 2));
583
+ });
584
+ mm.command("complete-session-v2 <session-id>")
585
+ .option("-r, --reason <reason>")
586
+ .description("Complete a V2 session")
587
+ .action((id, opts) => {
588
+ const db = _dbFromCtx(mm);
589
+ console.log(
590
+ JSON.stringify(completeSessionV2(db, id, opts.reason), null, 2),
591
+ );
592
+ });
593
+ mm.command("archive-session <session-id>")
594
+ .option("-r, --reason <reason>")
595
+ .description("Archive a V2 session")
596
+ .action((id, opts) => {
597
+ const db = _dbFromCtx(mm);
598
+ console.log(JSON.stringify(archiveSession(db, id, opts.reason), null, 2));
599
+ });
600
+ mm.command("touch-session-activity <session-id>")
601
+ .description("Bump lastActivityAt on a V2 session")
602
+ .action((id) =>
603
+ console.log(JSON.stringify(touchSessionActivity(id), null, 2)),
604
+ );
605
+
606
+ mm.command("register-artifact-v2 <artifact-id>")
607
+ .description("Register a V2 artifact")
608
+ .requiredOption("-s, --session-id <session>", "Session id")
609
+ .requiredOption(
610
+ "-M, --modality <modality>",
611
+ "Modality (text/document/image/audio/screen)",
612
+ )
613
+ .option("-z, --size <bytes>", "Size in bytes", (v) => Number(v))
614
+ .option("-i, --initial-status <status>", "Initial lifecycle status")
615
+ .option("-m, --metadata <json>", "Metadata JSON")
616
+ .action((artifactId, opts) => {
617
+ const db = _dbFromCtx(mm);
618
+ const metadata = _parseJsonFlag(opts.metadata, "--metadata");
619
+ console.log(
620
+ JSON.stringify(
621
+ registerArtifactV2(db, {
622
+ artifactId,
623
+ sessionId: opts.sessionId,
624
+ modality: opts.modality,
625
+ size: opts.size,
626
+ initialStatus: opts.initialStatus,
627
+ metadata,
628
+ }),
629
+ null,
630
+ 2,
631
+ ),
632
+ );
633
+ });
634
+
635
+ mm.command("artifact-v2 <artifact-id>")
636
+ .description("Show a V2 artifact")
637
+ .action((id) => {
638
+ const out = getArtifactV2(id);
639
+ console.log(out ? JSON.stringify(out, null, 2) : "null");
640
+ });
641
+
642
+ mm.command("set-artifact-status-v2 <artifact-id> <status>")
643
+ .option("-r, --reason <reason>")
644
+ .option("-m, --metadata <json>")
645
+ .description("Set V2 artifact lifecycle status")
646
+ .action((id, status, opts) => {
647
+ const db = _dbFromCtx(mm);
648
+ const metadata = _parseJsonFlag(opts.metadata, "--metadata");
649
+ console.log(
650
+ JSON.stringify(
651
+ setArtifactStatusV2(db, id, status, {
652
+ reason: opts.reason,
653
+ metadata,
654
+ }),
655
+ null,
656
+ 2,
657
+ ),
658
+ );
659
+ });
660
+
661
+ mm.command("mark-artifact-ready <artifact-id>")
662
+ .option("-r, --reason <reason>")
663
+ .description("Mark V2 artifact ready")
664
+ .action((id, opts) => {
665
+ const db = _dbFromCtx(mm);
666
+ console.log(
667
+ JSON.stringify(markArtifactReady(db, id, opts.reason), null, 2),
668
+ );
669
+ });
670
+ mm.command("purge-artifact <artifact-id>")
671
+ .option("-r, --reason <reason>")
672
+ .description("Purge a V2 artifact")
673
+ .action((id, opts) => {
674
+ const db = _dbFromCtx(mm);
675
+ console.log(JSON.stringify(purgeArtifact(db, id, opts.reason), null, 2));
676
+ });
677
+ mm.command("touch-artifact-access <artifact-id>")
678
+ .description("Bump lastAccessAt on a V2 artifact")
679
+ .action((id) =>
680
+ console.log(JSON.stringify(touchArtifactAccess(id), null, 2)),
681
+ );
682
+
683
+ mm.command("auto-archive-idle-sessions")
684
+ .description("Auto-flip idle V2 sessions to ARCHIVED")
685
+ .action(() => {
686
+ const db = _dbFromCtx(mm);
687
+ console.log(JSON.stringify(autoArchiveIdleSessions(db), null, 2));
688
+ });
689
+ mm.command("auto-purge-stale-artifacts")
690
+ .description("Auto-flip stale READY V2 artifacts to PURGED")
691
+ .action(() => {
692
+ const db = _dbFromCtx(mm);
693
+ console.log(JSON.stringify(autoPurgeStaleArtifacts(db), null, 2));
694
+ });
695
+ mm.command("stats-v2")
696
+ .description("V2 multimodal stats (counts by state + config)")
697
+ .action(() => console.log(JSON.stringify(getMultimodalStatsV2(), null, 2)));
698
+
403
699
  program.addCommand(mm);
404
700
  }