chainlesschain 0.66.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 (143) hide show
  1. package/bin/chainlesschain.js +0 -0
  2. package/package.json +1 -1
  3. package/src/commands/a2a.js +380 -0
  4. package/src/commands/agent-network.js +254 -1
  5. package/src/commands/audit.js +302 -0
  6. package/src/commands/automation.js +271 -1
  7. package/src/commands/bi.js +348 -0
  8. package/src/commands/codegen.js +224 -0
  9. package/src/commands/collab.js +341 -0
  10. package/src/commands/compliance.js +1035 -0
  11. package/src/commands/cowork.js +221 -0
  12. package/src/commands/crosschain.js +218 -0
  13. package/src/commands/dbevo.js +284 -0
  14. package/src/commands/dev.js +252 -0
  15. package/src/commands/did.js +358 -0
  16. package/src/commands/dlp.js +341 -0
  17. package/src/commands/encrypt.js +341 -0
  18. package/src/commands/evomap.js +394 -0
  19. package/src/commands/export.js +256 -1
  20. package/src/commands/federation.js +283 -0
  21. package/src/commands/fusion.js +258 -0
  22. package/src/commands/governance.js +325 -0
  23. package/src/commands/hardening.js +411 -0
  24. package/src/commands/hook.js +148 -0
  25. package/src/commands/import.js +252 -0
  26. package/src/commands/incentive.js +322 -0
  27. package/src/commands/inference.js +318 -0
  28. package/src/commands/infra.js +244 -0
  29. package/src/commands/instinct.js +260 -0
  30. package/src/commands/ipfs.js +318 -0
  31. package/src/commands/kg.js +387 -0
  32. package/src/commands/llm.js +263 -0
  33. package/src/commands/lowcode.js +356 -0
  34. package/src/commands/marketplace.js +256 -0
  35. package/src/commands/mcp.js +221 -0
  36. package/src/commands/memory.js +248 -0
  37. package/src/commands/multimodal.js +296 -0
  38. package/src/commands/nlprog.js +356 -0
  39. package/src/commands/note.js +244 -0
  40. package/src/commands/ops.js +354 -0
  41. package/src/commands/orchestrate.js +166 -0
  42. package/src/commands/org.js +277 -0
  43. package/src/commands/p2p.js +390 -0
  44. package/src/commands/perception.js +290 -0
  45. package/src/commands/permmem.js +251 -0
  46. package/src/commands/plugin-ecosystem.js +273 -0
  47. package/src/commands/pqc.js +393 -0
  48. package/src/commands/privacy.js +321 -0
  49. package/src/commands/quantization.js +351 -0
  50. package/src/commands/rcache.js +271 -0
  51. package/src/commands/recommend.js +340 -0
  52. package/src/commands/reputation.js +261 -0
  53. package/src/commands/runtime.js +307 -0
  54. package/src/commands/scim.js +262 -0
  55. package/src/commands/session.js +258 -0
  56. package/src/commands/siem.js +246 -0
  57. package/src/commands/skill.js +267 -1
  58. package/src/commands/sla.js +259 -0
  59. package/src/commands/social.js +256 -0
  60. package/src/commands/sso.js +186 -1
  61. package/src/commands/stress.js +230 -0
  62. package/src/commands/sync.js +256 -0
  63. package/src/commands/tech.js +338 -0
  64. package/src/commands/tenant.js +351 -0
  65. package/src/commands/terraform.js +245 -0
  66. package/src/commands/tokens.js +269 -0
  67. package/src/commands/trust.js +249 -0
  68. package/src/commands/wallet.js +277 -0
  69. package/src/commands/workflow.js +171 -0
  70. package/src/commands/zkp.js +335 -0
  71. package/src/index.js +4 -0
  72. package/src/lib/a2a-protocol.js +451 -0
  73. package/src/lib/agent-coordinator.js +325 -0
  74. package/src/lib/agent-network.js +387 -0
  75. package/src/lib/agent-router.js +395 -0
  76. package/src/lib/aiops.js +478 -0
  77. package/src/lib/app-builder.js +239 -0
  78. package/src/lib/audit-logger.js +379 -0
  79. package/src/lib/automation-engine.js +330 -0
  80. package/src/lib/autonomous-developer.js +350 -0
  81. package/src/lib/bi-engine.js +338 -0
  82. package/src/lib/code-agent.js +323 -0
  83. package/src/lib/collaboration-governance.js +364 -0
  84. package/src/lib/community-governance.js +436 -0
  85. package/src/lib/compliance-manager.js +434 -0
  86. package/src/lib/content-recommendation.js +469 -0
  87. package/src/lib/cross-chain.js +345 -0
  88. package/src/lib/crypto-manager.js +350 -0
  89. package/src/lib/dbevo.js +338 -0
  90. package/src/lib/decentral-infra.js +340 -0
  91. package/src/lib/did-manager.js +367 -0
  92. package/src/lib/dlp-engine.js +389 -0
  93. package/src/lib/evomap-federation.js +177 -0
  94. package/src/lib/evomap-governance.js +276 -0
  95. package/src/lib/federation-hardening.js +259 -0
  96. package/src/lib/hardening-manager.js +348 -0
  97. package/src/lib/hook-manager.js +380 -0
  98. package/src/lib/inference-network.js +330 -0
  99. package/src/lib/instinct-manager.js +332 -0
  100. package/src/lib/ipfs-storage.js +334 -0
  101. package/src/lib/knowledge-exporter.js +381 -0
  102. package/src/lib/knowledge-graph.js +432 -0
  103. package/src/lib/knowledge-importer.js +379 -0
  104. package/src/lib/llm-providers.js +391 -0
  105. package/src/lib/mcp-registry.js +333 -0
  106. package/src/lib/memory-manager.js +330 -0
  107. package/src/lib/multimodal.js +346 -0
  108. package/src/lib/nl-programming.js +343 -0
  109. package/src/lib/note-versioning.js +327 -0
  110. package/src/lib/org-manager.js +323 -0
  111. package/src/lib/p2p-manager.js +387 -0
  112. package/src/lib/perception.js +346 -0
  113. package/src/lib/perf-tuning.js +4 -1
  114. package/src/lib/permanent-memory.js +320 -0
  115. package/src/lib/plugin-ecosystem.js +377 -0
  116. package/src/lib/pqc-manager.js +368 -0
  117. package/src/lib/privacy-computing.js +427 -0
  118. package/src/lib/protocol-fusion.js +417 -0
  119. package/src/lib/quantization.js +325 -0
  120. package/src/lib/reputation-optimizer.js +299 -0
  121. package/src/lib/response-cache.js +327 -0
  122. package/src/lib/scim-manager.js +329 -0
  123. package/src/lib/session-manager.js +329 -0
  124. package/src/lib/siem-exporter.js +333 -0
  125. package/src/lib/skill-loader.js +377 -0
  126. package/src/lib/skill-marketplace.js +325 -0
  127. package/src/lib/sla-manager.js +275 -0
  128. package/src/lib/social-manager.js +326 -0
  129. package/src/lib/sso-manager.js +332 -0
  130. package/src/lib/stress-tester.js +330 -0
  131. package/src/lib/sync-manager.js +326 -0
  132. package/src/lib/tech-learning-engine.js +369 -0
  133. package/src/lib/tenant-saas.js +460 -0
  134. package/src/lib/terraform-manager.js +363 -0
  135. package/src/lib/threat-intel.js +335 -0
  136. package/src/lib/token-incentive.js +293 -0
  137. package/src/lib/token-tracker.js +329 -0
  138. package/src/lib/trust-security.js +390 -0
  139. package/src/lib/ueba.js +389 -0
  140. package/src/lib/universal-runtime.js +325 -0
  141. package/src/lib/wallet-manager.js +326 -0
  142. package/src/lib/workflow-engine.js +322 -0
  143. package/src/lib/zkp-engine.js +274 -0
@@ -17,6 +17,37 @@ import {
17
17
  TECH_TYPES,
18
18
  PRACTICE_LEVELS,
19
19
  ANTI_PATTERNS,
20
+ PROFILE_MATURITY_V2,
21
+ LEARNING_RUN_V2,
22
+ getMaxActiveProfilesPerOwnerV2,
23
+ setMaxActiveProfilesPerOwnerV2,
24
+ getMaxStudyingRunsPerLearnerV2,
25
+ setMaxStudyingRunsPerLearnerV2,
26
+ getProfileStaleMsV2,
27
+ setProfileStaleMsV2,
28
+ getRunStuckMsV2,
29
+ setRunStuckMsV2,
30
+ getActiveProfileCountV2,
31
+ getStudyingRunCountV2,
32
+ createProfileV2,
33
+ getProfileV2,
34
+ listProfilesV2,
35
+ setProfileMaturityV2,
36
+ activateProfileV2,
37
+ markProfileStaleV2,
38
+ archiveProfileV2,
39
+ touchProfileV2,
40
+ enqueueRunV2,
41
+ getRunV2,
42
+ listRunsV2,
43
+ setRunStatusV2,
44
+ startRunV2,
45
+ completeRunV2,
46
+ abandonRunV2,
47
+ failRunV2,
48
+ autoMarkStaleProfilesV2,
49
+ autoFailStuckRunsV2,
50
+ getTechLearningStatsV2,
20
51
  } from "../lib/tech-learning-engine.js";
21
52
 
22
53
  function _dbFromCtx(ctx) {
@@ -265,4 +296,311 @@ export function registerTechCommand(program) {
265
296
  process.exit(1);
266
297
  }
267
298
  });
299
+
300
+ /* ═══ V2 Surface ═══ */
301
+
302
+ function _parseMeta(s) {
303
+ if (!s) return undefined;
304
+ try {
305
+ return JSON.parse(s);
306
+ } catch {
307
+ throw new Error("--metadata must be valid JSON");
308
+ }
309
+ }
310
+
311
+ tech
312
+ .command("profile-maturities-v2")
313
+ .description("List profile maturity states (V2)")
314
+ .action(() => {
315
+ for (const v of Object.values(PROFILE_MATURITY_V2)) logger.log(` ${v}`);
316
+ });
317
+
318
+ tech
319
+ .command("learning-runs-v2")
320
+ .description("List learning run states (V2)")
321
+ .action(() => {
322
+ for (const v of Object.values(LEARNING_RUN_V2)) logger.log(` ${v}`);
323
+ });
324
+
325
+ tech
326
+ .command("stats-v2")
327
+ .description("Tech Learning V2 stats")
328
+ .action(() => {
329
+ console.log(JSON.stringify(getTechLearningStatsV2(), null, 2));
330
+ });
331
+
332
+ tech
333
+ .command("max-active-profiles-per-owner")
334
+ .description("Get/set max active profiles per owner (V2)")
335
+ .option("-s, --set <n>", "Set value", (v) => parseInt(v, 10))
336
+ .action((o) => {
337
+ if (typeof o.set === "number")
338
+ console.log(setMaxActiveProfilesPerOwnerV2(o.set));
339
+ else console.log(getMaxActiveProfilesPerOwnerV2());
340
+ });
341
+
342
+ tech
343
+ .command("max-studying-runs-per-learner")
344
+ .description("Get/set max studying runs per learner (V2)")
345
+ .option("-s, --set <n>", "Set value", (v) => parseInt(v, 10))
346
+ .action((o) => {
347
+ if (typeof o.set === "number")
348
+ console.log(setMaxStudyingRunsPerLearnerV2(o.set));
349
+ else console.log(getMaxStudyingRunsPerLearnerV2());
350
+ });
351
+
352
+ tech
353
+ .command("profile-stale-ms")
354
+ .description("Get/set profile stale threshold ms (V2)")
355
+ .option("-s, --set <n>", "Set value", (v) => parseInt(v, 10))
356
+ .action((o) => {
357
+ if (typeof o.set === "number") console.log(setProfileStaleMsV2(o.set));
358
+ else console.log(getProfileStaleMsV2());
359
+ });
360
+
361
+ tech
362
+ .command("run-stuck-ms")
363
+ .description("Get/set run stuck threshold ms (V2)")
364
+ .option("-s, --set <n>", "Set value", (v) => parseInt(v, 10))
365
+ .action((o) => {
366
+ if (typeof o.set === "number") console.log(setRunStuckMsV2(o.set));
367
+ else console.log(getRunStuckMsV2());
368
+ });
369
+
370
+ tech
371
+ .command("active-profile-count")
372
+ .description("Count active+stale profiles for owner (V2)")
373
+ .requiredOption("-o, --owner <owner>", "Owner")
374
+ .action((o) => {
375
+ console.log(getActiveProfileCountV2(o.owner));
376
+ });
377
+
378
+ tech
379
+ .command("studying-run-count")
380
+ .description("Count studying runs for learner (V2)")
381
+ .requiredOption("-l, --learner <learner>", "Learner")
382
+ .action((o) => {
383
+ console.log(getStudyingRunCountV2(o.learner));
384
+ });
385
+
386
+ tech
387
+ .command("create-profile-v2 <id>")
388
+ .description("Create a profile V2 (draft)")
389
+ .requiredOption("-o, --owner <owner>", "Owner")
390
+ .requiredOption("-s, --stack <stack>", "Stack name")
391
+ .option("-m, --metadata <json>", "JSON metadata")
392
+ .action((id, o) => {
393
+ console.log(
394
+ JSON.stringify(
395
+ createProfileV2({
396
+ id,
397
+ owner: o.owner,
398
+ stackName: o.stack,
399
+ metadata: _parseMeta(o.metadata),
400
+ }),
401
+ null,
402
+ 2,
403
+ ),
404
+ );
405
+ });
406
+
407
+ tech
408
+ .command("profile-v2 <id>")
409
+ .description("Show profile V2")
410
+ .action((id) => {
411
+ const p = getProfileV2(id);
412
+ if (!p) {
413
+ logger.error(`profile ${id} not found`);
414
+ process.exit(1);
415
+ }
416
+ console.log(JSON.stringify(p, null, 2));
417
+ });
418
+
419
+ tech
420
+ .command("list-profiles-v2")
421
+ .description("List profiles V2")
422
+ .option("-o, --owner <owner>", "Filter by owner")
423
+ .option("-s, --status <status>", "Filter by status")
424
+ .action((o) => {
425
+ console.log(
426
+ JSON.stringify(
427
+ listProfilesV2({ owner: o.owner, status: o.status }),
428
+ null,
429
+ 2,
430
+ ),
431
+ );
432
+ });
433
+
434
+ tech
435
+ .command("set-profile-maturity-v2 <id> <status>")
436
+ .description("Transition profile V2 to status")
437
+ .option("-r, --reason <reason>", "Reason")
438
+ .option("-m, --metadata <json>", "JSON metadata patch")
439
+ .action((id, status, o) => {
440
+ console.log(
441
+ JSON.stringify(
442
+ setProfileMaturityV2(id, status, {
443
+ reason: o.reason,
444
+ metadata: _parseMeta(o.metadata),
445
+ }),
446
+ null,
447
+ 2,
448
+ ),
449
+ );
450
+ });
451
+
452
+ tech
453
+ .command("activate-profile <id>")
454
+ .description("Transition profile → active (V2)")
455
+ .option("-r, --reason <reason>", "Reason")
456
+ .action((id, o) => {
457
+ console.log(
458
+ JSON.stringify(activateProfileV2(id, { reason: o.reason }), null, 2),
459
+ );
460
+ });
461
+
462
+ tech
463
+ .command("mark-profile-stale <id>")
464
+ .description("Transition profile → stale (V2)")
465
+ .option("-r, --reason <reason>", "Reason")
466
+ .action((id, o) => {
467
+ console.log(
468
+ JSON.stringify(markProfileStaleV2(id, { reason: o.reason }), null, 2),
469
+ );
470
+ });
471
+
472
+ tech
473
+ .command("archive-profile <id>")
474
+ .description("Transition profile → archived (V2)")
475
+ .option("-r, --reason <reason>", "Reason")
476
+ .action((id, o) => {
477
+ console.log(
478
+ JSON.stringify(archiveProfileV2(id, { reason: o.reason }), null, 2),
479
+ );
480
+ });
481
+
482
+ tech
483
+ .command("touch-profile <id>")
484
+ .description("Update lastTouchedAt (V2)")
485
+ .action((id) => {
486
+ console.log(JSON.stringify(touchProfileV2(id), null, 2));
487
+ });
488
+
489
+ tech
490
+ .command("enqueue-run-v2 <id>")
491
+ .description("Enqueue a learning run (V2)")
492
+ .requiredOption("-l, --learner <learner>", "Learner")
493
+ .requiredOption("-t, --topic <topic>", "Topic")
494
+ .option("-m, --metadata <json>", "JSON metadata")
495
+ .action((id, o) => {
496
+ console.log(
497
+ JSON.stringify(
498
+ enqueueRunV2({
499
+ id,
500
+ learner: o.learner,
501
+ topic: o.topic,
502
+ metadata: _parseMeta(o.metadata),
503
+ }),
504
+ null,
505
+ 2,
506
+ ),
507
+ );
508
+ });
509
+
510
+ tech
511
+ .command("run-v2 <id>")
512
+ .description("Show learning run V2")
513
+ .action((id) => {
514
+ const r = getRunV2(id);
515
+ if (!r) {
516
+ logger.error(`run ${id} not found`);
517
+ process.exit(1);
518
+ }
519
+ console.log(JSON.stringify(r, null, 2));
520
+ });
521
+
522
+ tech
523
+ .command("list-runs-v2")
524
+ .description("List learning runs V2")
525
+ .option("-l, --learner <learner>", "Filter by learner")
526
+ .option("-s, --status <status>", "Filter by status")
527
+ .action((o) => {
528
+ console.log(
529
+ JSON.stringify(
530
+ listRunsV2({ learner: o.learner, status: o.status }),
531
+ null,
532
+ 2,
533
+ ),
534
+ );
535
+ });
536
+
537
+ tech
538
+ .command("set-run-status-v2 <id> <status>")
539
+ .description("Transition run V2 to status")
540
+ .option("-r, --reason <reason>", "Reason")
541
+ .option("-m, --metadata <json>", "JSON metadata patch")
542
+ .action((id, status, o) => {
543
+ console.log(
544
+ JSON.stringify(
545
+ setRunStatusV2(id, status, {
546
+ reason: o.reason,
547
+ metadata: _parseMeta(o.metadata),
548
+ }),
549
+ null,
550
+ 2,
551
+ ),
552
+ );
553
+ });
554
+
555
+ tech
556
+ .command("start-run-v2 <id>")
557
+ .description("Transition run → studying (V2)")
558
+ .option("-r, --reason <reason>", "Reason")
559
+ .action((id, o) => {
560
+ console.log(
561
+ JSON.stringify(startRunV2(id, { reason: o.reason }), null, 2),
562
+ );
563
+ });
564
+
565
+ tech
566
+ .command("complete-run-v2 <id>")
567
+ .description("Transition run → completed (V2)")
568
+ .option("-r, --reason <reason>", "Reason")
569
+ .action((id, o) => {
570
+ console.log(
571
+ JSON.stringify(completeRunV2(id, { reason: o.reason }), null, 2),
572
+ );
573
+ });
574
+
575
+ tech
576
+ .command("fail-run-v2 <id>")
577
+ .description("Transition run → failed (V2)")
578
+ .option("-r, --reason <reason>", "Reason")
579
+ .action((id, o) => {
580
+ console.log(JSON.stringify(failRunV2(id, { reason: o.reason }), null, 2));
581
+ });
582
+
583
+ tech
584
+ .command("abandon-run-v2 <id>")
585
+ .description("Transition run → abandoned (V2)")
586
+ .option("-r, --reason <reason>", "Reason")
587
+ .action((id, o) => {
588
+ console.log(
589
+ JSON.stringify(abandonRunV2(id, { reason: o.reason }), null, 2),
590
+ );
591
+ });
592
+
593
+ tech
594
+ .command("auto-mark-stale-profiles")
595
+ .description("Bulk auto-flip active→stale past threshold (V2)")
596
+ .action(() => {
597
+ console.log(JSON.stringify(autoMarkStaleProfilesV2(), null, 2));
598
+ });
599
+
600
+ tech
601
+ .command("auto-fail-stuck-runs")
602
+ .description("Bulk auto-fail studying runs past threshold (V2)")
603
+ .action(() => {
604
+ console.log(JSON.stringify(autoFailStuckRunsV2(), null, 2));
605
+ });
268
606
  }
@@ -28,6 +28,40 @@ import {
28
28
  getSaasStats,
29
29
  exportTenant,
30
30
  importTenant,
31
+ TENANT_MATURITY_V2,
32
+ SUBSCRIPTION_LIFECYCLE_V2,
33
+ getDefaultMaxActiveTenantsPerPlanV2,
34
+ getMaxActiveTenantsPerPlanV2,
35
+ setMaxActiveTenantsPerPlanV2,
36
+ getDefaultMaxSubscriptionsPerTenantV2,
37
+ getMaxSubscriptionsPerTenantV2,
38
+ setMaxSubscriptionsPerTenantV2,
39
+ getDefaultTenantIdleMsV2,
40
+ getTenantIdleMsV2,
41
+ setTenantIdleMsV2,
42
+ getDefaultPastDueGraceMsV2,
43
+ getPastDueGraceMsV2,
44
+ setPastDueGraceMsV2,
45
+ registerTenantV2,
46
+ getTenantV2,
47
+ setTenantMaturityV2,
48
+ activateTenant,
49
+ suspendTenant,
50
+ archiveTenantV2,
51
+ cancelTenant,
52
+ touchTenantActivity,
53
+ registerSubscriptionV2,
54
+ getSubscriptionV2,
55
+ setSubscriptionStatusV2,
56
+ activateSubscription,
57
+ markSubscriptionPastDue,
58
+ cancelSubscriptionV2,
59
+ expireSubscription,
60
+ getActiveTenantCount,
61
+ getOpenSubscriptionCount,
62
+ autoArchiveIdleTenants,
63
+ autoExpirePastDueSubscriptions,
64
+ getSaasStatsV2,
31
65
  } from "../lib/tenant-saas.js";
32
66
 
33
67
  function _dbFromCtx(ctx) {
@@ -573,4 +607,321 @@ export function registerTenantCommand(program) {
573
607
  process.exit(1);
574
608
  }
575
609
  });
610
+
611
+ /* ── V2: Tenant Maturity + Subscription Lifecycle ─────────── */
612
+
613
+ tenant
614
+ .command("maturities-v2")
615
+ .description("List tenant V2 maturity states")
616
+ .option("--json", "JSON output")
617
+ .action((opts) => {
618
+ const s = Object.values(TENANT_MATURITY_V2);
619
+ if (opts.json) console.log(JSON.stringify(s));
620
+ else s.forEach((v) => console.log(v));
621
+ });
622
+
623
+ tenant
624
+ .command("subscription-lifecycles-v2")
625
+ .description("List subscription V2 lifecycle states")
626
+ .option("--json", "JSON output")
627
+ .action((opts) => {
628
+ const s = Object.values(SUBSCRIPTION_LIFECYCLE_V2);
629
+ if (opts.json) console.log(JSON.stringify(s));
630
+ else s.forEach((v) => console.log(v));
631
+ });
632
+
633
+ tenant
634
+ .command("default-max-active-tenants-per-plan")
635
+ .description("Show default max-active-tenants-per-plan")
636
+ .action(() => console.log(getDefaultMaxActiveTenantsPerPlanV2()));
637
+ tenant
638
+ .command("max-active-tenants-per-plan")
639
+ .description("Show current max-active-tenants-per-plan")
640
+ .action(() => console.log(getMaxActiveTenantsPerPlanV2()));
641
+ tenant
642
+ .command("set-max-active-tenants-per-plan <n>")
643
+ .description("Set max-active-tenants-per-plan")
644
+ .action((n) => {
645
+ setMaxActiveTenantsPerPlanV2(n);
646
+ console.log(getMaxActiveTenantsPerPlanV2());
647
+ });
648
+
649
+ tenant
650
+ .command("default-max-subscriptions-per-tenant")
651
+ .description("Show default max-subscriptions-per-tenant")
652
+ .action(() => console.log(getDefaultMaxSubscriptionsPerTenantV2()));
653
+ tenant
654
+ .command("max-subscriptions-per-tenant")
655
+ .description("Show current max-subscriptions-per-tenant")
656
+ .action(() => console.log(getMaxSubscriptionsPerTenantV2()));
657
+ tenant
658
+ .command("set-max-subscriptions-per-tenant <n>")
659
+ .description("Set max-subscriptions-per-tenant")
660
+ .action((n) => {
661
+ setMaxSubscriptionsPerTenantV2(n);
662
+ console.log(getMaxSubscriptionsPerTenantV2());
663
+ });
664
+
665
+ tenant
666
+ .command("default-tenant-idle-ms")
667
+ .description("Show default tenant-idle-ms")
668
+ .action(() => console.log(getDefaultTenantIdleMsV2()));
669
+ tenant
670
+ .command("tenant-idle-ms")
671
+ .description("Show current tenant-idle-ms")
672
+ .action(() => console.log(getTenantIdleMsV2()));
673
+ tenant
674
+ .command("set-tenant-idle-ms <ms>")
675
+ .description("Set tenant-idle-ms")
676
+ .action((ms) => {
677
+ setTenantIdleMsV2(ms);
678
+ console.log(getTenantIdleMsV2());
679
+ });
680
+
681
+ tenant
682
+ .command("default-past-due-grace-ms")
683
+ .description("Show default past-due-grace-ms")
684
+ .action(() => console.log(getDefaultPastDueGraceMsV2()));
685
+ tenant
686
+ .command("past-due-grace-ms")
687
+ .description("Show current past-due-grace-ms")
688
+ .action(() => console.log(getPastDueGraceMsV2()));
689
+ tenant
690
+ .command("set-past-due-grace-ms <ms>")
691
+ .description("Set past-due-grace-ms")
692
+ .action((ms) => {
693
+ setPastDueGraceMsV2(ms);
694
+ console.log(getPastDueGraceMsV2());
695
+ });
696
+
697
+ tenant
698
+ .command("active-tenant-count")
699
+ .description("Active tenant count (optionally scoped by plan)")
700
+ .option("-p, --plan <plan>", "Plan ID")
701
+ .action((opts) => console.log(getActiveTenantCount(opts.plan)));
702
+
703
+ tenant
704
+ .command("open-subscription-count")
705
+ .description("Open subscription count (optionally scoped by tenant)")
706
+ .option("-t, --tenant <id>", "Tenant ID")
707
+ .action((opts) => console.log(getOpenSubscriptionCount(opts.tenant)));
708
+
709
+ tenant
710
+ .command("register-v2 <tenant-id>")
711
+ .description("Register a V2 tenant")
712
+ .requiredOption("-p, --plan <plan>", "Plan")
713
+ .option("-o, --owner <id>", "Owner ID")
714
+ .option(
715
+ "-i, --initial-status <status>",
716
+ "Initial status (default provisioning)",
717
+ )
718
+ .option("-m, --metadata <json>", "Metadata JSON")
719
+ .action((tenantId, opts) => {
720
+ const config = { tenantId, plan: opts.plan };
721
+ if (opts.owner) config.ownerId = opts.owner;
722
+ if (opts.initialStatus) config.initialStatus = opts.initialStatus;
723
+ if (opts.metadata) config.metadata = JSON.parse(opts.metadata);
724
+ console.log(JSON.stringify(registerTenantV2(null, config), null, 2));
725
+ });
726
+
727
+ tenant
728
+ .command("tenant-v2 <tenant-id>")
729
+ .description("Get V2 tenant record")
730
+ .action((tenantId) => {
731
+ const rec = getTenantV2(tenantId);
732
+ console.log(rec ? JSON.stringify(rec, null, 2) : "null");
733
+ });
734
+
735
+ tenant
736
+ .command("set-maturity-v2 <tenant-id> <status>")
737
+ .description("Set tenant V2 maturity status")
738
+ .option("-r, --reason <reason>", "Reason")
739
+ .option("-m, --metadata <json>", "Metadata JSON patch")
740
+ .action((tenantId, status, opts) => {
741
+ const patch = {};
742
+ if (opts.reason !== undefined) patch.reason = opts.reason;
743
+ if (opts.metadata) patch.metadata = JSON.parse(opts.metadata);
744
+ console.log(
745
+ JSON.stringify(
746
+ setTenantMaturityV2(null, tenantId, status, patch),
747
+ null,
748
+ 2,
749
+ ),
750
+ );
751
+ });
752
+
753
+ tenant
754
+ .command("activate <tenant-id>")
755
+ .description("Transition tenant → active")
756
+ .option("-r, --reason <reason>", "Reason")
757
+ .action((tenantId, opts) =>
758
+ console.log(
759
+ JSON.stringify(activateTenant(null, tenantId, opts.reason), null, 2),
760
+ ),
761
+ );
762
+
763
+ tenant
764
+ .command("suspend <tenant-id>")
765
+ .description("Transition tenant → suspended")
766
+ .option("-r, --reason <reason>", "Reason")
767
+ .action((tenantId, opts) =>
768
+ console.log(
769
+ JSON.stringify(suspendTenant(null, tenantId, opts.reason), null, 2),
770
+ ),
771
+ );
772
+
773
+ tenant
774
+ .command("archive-v2 <tenant-id>")
775
+ .description("Transition tenant → archived")
776
+ .option("-r, --reason <reason>", "Reason")
777
+ .action((tenantId, opts) =>
778
+ console.log(
779
+ JSON.stringify(archiveTenantV2(null, tenantId, opts.reason), null, 2),
780
+ ),
781
+ );
782
+
783
+ tenant
784
+ .command("cancel-tenant <tenant-id>")
785
+ .description("Transition tenant → cancelled (terminal)")
786
+ .option("-r, --reason <reason>", "Reason")
787
+ .action((tenantId, opts) =>
788
+ console.log(
789
+ JSON.stringify(cancelTenant(null, tenantId, opts.reason), null, 2),
790
+ ),
791
+ );
792
+
793
+ tenant
794
+ .command("touch-activity <tenant-id>")
795
+ .description("Bump lastActivityAt for a tenant")
796
+ .action((tenantId) =>
797
+ console.log(JSON.stringify(touchTenantActivity(tenantId), null, 2)),
798
+ );
799
+
800
+ tenant
801
+ .command("subscription-register-v2 <subscription-id>")
802
+ .description("Register a V2 subscription")
803
+ .requiredOption("-t, --tenant <id>", "Tenant ID")
804
+ .requiredOption("-p, --plan <plan>", "Plan")
805
+ .option("-e, --expires-at <ms>", "Expires at (epoch ms)")
806
+ .option("-m, --metadata <json>", "Metadata JSON")
807
+ .action((subscriptionId, opts) => {
808
+ const config = {
809
+ subscriptionId,
810
+ tenantId: opts.tenant,
811
+ plan: opts.plan,
812
+ };
813
+ if (opts.expiresAt) config.expiresAt = Number(opts.expiresAt);
814
+ if (opts.metadata) config.metadata = JSON.parse(opts.metadata);
815
+ console.log(
816
+ JSON.stringify(registerSubscriptionV2(null, config), null, 2),
817
+ );
818
+ });
819
+
820
+ tenant
821
+ .command("subscription-v2 <subscription-id>")
822
+ .description("Get V2 subscription record")
823
+ .action((subscriptionId) => {
824
+ const rec = getSubscriptionV2(subscriptionId);
825
+ console.log(rec ? JSON.stringify(rec, null, 2) : "null");
826
+ });
827
+
828
+ tenant
829
+ .command("set-subscription-status-v2 <subscription-id> <status>")
830
+ .description("Set subscription V2 status")
831
+ .option("-r, --reason <reason>", "Reason")
832
+ .option("-m, --metadata <json>", "Metadata JSON patch")
833
+ .action((subscriptionId, status, opts) => {
834
+ const patch = {};
835
+ if (opts.reason !== undefined) patch.reason = opts.reason;
836
+ if (opts.metadata) patch.metadata = JSON.parse(opts.metadata);
837
+ console.log(
838
+ JSON.stringify(
839
+ setSubscriptionStatusV2(null, subscriptionId, status, patch),
840
+ null,
841
+ 2,
842
+ ),
843
+ );
844
+ });
845
+
846
+ tenant
847
+ .command("activate-subscription <subscription-id>")
848
+ .description("Transition subscription → active")
849
+ .option("-r, --reason <reason>", "Reason")
850
+ .action((subscriptionId, opts) =>
851
+ console.log(
852
+ JSON.stringify(
853
+ activateSubscription(null, subscriptionId, opts.reason),
854
+ null,
855
+ 2,
856
+ ),
857
+ ),
858
+ );
859
+
860
+ tenant
861
+ .command("mark-past-due <subscription-id>")
862
+ .description("Transition subscription → past_due")
863
+ .option("-r, --reason <reason>", "Reason")
864
+ .action((subscriptionId, opts) =>
865
+ console.log(
866
+ JSON.stringify(
867
+ markSubscriptionPastDue(null, subscriptionId, opts.reason),
868
+ null,
869
+ 2,
870
+ ),
871
+ ),
872
+ );
873
+
874
+ tenant
875
+ .command("cancel-subscription-v2 <subscription-id>")
876
+ .description("Transition subscription → cancelled (terminal)")
877
+ .option("-r, --reason <reason>", "Reason")
878
+ .action((subscriptionId, opts) =>
879
+ console.log(
880
+ JSON.stringify(
881
+ cancelSubscriptionV2(null, subscriptionId, opts.reason),
882
+ null,
883
+ 2,
884
+ ),
885
+ ),
886
+ );
887
+
888
+ tenant
889
+ .command("expire-subscription <subscription-id>")
890
+ .description("Transition subscription → expired (terminal)")
891
+ .option("-r, --reason <reason>", "Reason")
892
+ .action((subscriptionId, opts) =>
893
+ console.log(
894
+ JSON.stringify(
895
+ expireSubscription(null, subscriptionId, opts.reason),
896
+ null,
897
+ 2,
898
+ ),
899
+ ),
900
+ );
901
+
902
+ tenant
903
+ .command("auto-archive-idle-tenants")
904
+ .description("Bulk-flip idle tenants → archived")
905
+ .action(() => {
906
+ const flipped = autoArchiveIdleTenants(null);
907
+ console.log(JSON.stringify(flipped));
908
+ });
909
+
910
+ tenant
911
+ .command("auto-expire-past-due-subscriptions")
912
+ .description("Bulk-flip past-due subscriptions past grace → expired")
913
+ .action(() => {
914
+ const flipped = autoExpirePastDueSubscriptions(null);
915
+ console.log(JSON.stringify(flipped));
916
+ });
917
+
918
+ tenant
919
+ .command("stats-v2")
920
+ .description("Show V2 SaaS stats (all-enum-key)")
921
+ .option("--json", "JSON output")
922
+ .action((opts) => {
923
+ const s = getSaasStatsV2();
924
+ if (opts.json) console.log(JSON.stringify(s));
925
+ else console.log(JSON.stringify(s, null, 2));
926
+ });
576
927
  }