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
@@ -25,8 +25,47 @@ import {
25
25
  listADRs,
26
26
  renderADR,
27
27
  AUTONOMY_LEVELS,
28
+ ADR_MATURITY_V2,
29
+ DEV_SESSION_V2,
30
+ getMaxActiveAdrsPerAuthor,
31
+ setMaxActiveAdrsPerAuthor,
32
+ getMaxRunningSessionsPerDeveloper,
33
+ setMaxRunningSessionsPerDeveloper,
34
+ getAdrStaleMs,
35
+ setAdrStaleMs,
36
+ getSessionStuckMs,
37
+ setSessionStuckMs,
38
+ getActiveAdrCount,
39
+ getRunningSessionCount,
40
+ createAdrV2,
41
+ getAdrV2,
42
+ listAdrsV2,
43
+ setAdrMaturityV2,
44
+ acceptAdr,
45
+ deprecateAdr,
46
+ supersedeAdr,
47
+ enqueueSessionV2,
48
+ getSessionV2,
49
+ listSessionsV2,
50
+ setSessionStatusV2,
51
+ startSessionV2,
52
+ completeSessionV2,
53
+ failSessionV2,
54
+ cancelSessionV2,
55
+ autoSupersedeStaleDrafts,
56
+ autoFailStuckSessions,
57
+ getAutonomousDeveloperStatsV2,
28
58
  } from "../lib/autonomous-developer.js";
29
59
 
60
+ function _parseJsonV2(s) {
61
+ if (!s) return undefined;
62
+ try {
63
+ return JSON.parse(s);
64
+ } catch {
65
+ throw new Error(`invalid JSON: ${s}`);
66
+ }
67
+ }
68
+
30
69
  function _dbFromCtx(ctx) {
31
70
  if (!ctx.db) {
32
71
  logger.error("Database not available");
@@ -408,4 +447,217 @@ export function registerDevCommand(program) {
408
447
 
409
448
  // silence unused import lints (AUTONOMY_LEVELS re-exported for consumers)
410
449
  void AUTONOMY_LEVELS;
450
+
451
+ /* ── V2 Surface (Autonomous Developer) ─────────────────── */
452
+
453
+ dev
454
+ .command("adr-maturities-v2")
455
+ .description("List ADR_MATURITY_V2 enum")
456
+ .action(() => {
457
+ for (const v of Object.values(ADR_MATURITY_V2)) console.log(` ${v}`);
458
+ });
459
+
460
+ dev
461
+ .command("dev-sessions-v2")
462
+ .description("List DEV_SESSION_V2 enum")
463
+ .action(() => {
464
+ for (const v of Object.values(DEV_SESSION_V2)) console.log(` ${v}`);
465
+ });
466
+
467
+ dev
468
+ .command("max-active-adrs-per-author")
469
+ .description("Get max-active-adrs-per-author cap")
470
+ .action(() => console.log(getMaxActiveAdrsPerAuthor()));
471
+ dev
472
+ .command("set-max-active-adrs-per-author <n>")
473
+ .action((n) => console.log(setMaxActiveAdrsPerAuthor(Number(n))));
474
+
475
+ dev
476
+ .command("max-running-sessions-per-developer")
477
+ .description("Get max-running-sessions-per-developer cap")
478
+ .action(() => console.log(getMaxRunningSessionsPerDeveloper()));
479
+ dev
480
+ .command("set-max-running-sessions-per-developer <n>")
481
+ .action((n) => console.log(setMaxRunningSessionsPerDeveloper(Number(n))));
482
+
483
+ dev
484
+ .command("adr-stale-ms")
485
+ .description("Get adr-stale-ms threshold")
486
+ .action(() => console.log(getAdrStaleMs()));
487
+ dev
488
+ .command("set-adr-stale-ms <n>")
489
+ .action((n) => console.log(setAdrStaleMs(Number(n))));
490
+
491
+ dev
492
+ .command("session-stuck-ms")
493
+ .description("Get session-stuck-ms threshold")
494
+ .action(() => console.log(getSessionStuckMs()));
495
+ dev
496
+ .command("set-session-stuck-ms <n>")
497
+ .action((n) => console.log(setSessionStuckMs(Number(n))));
498
+
499
+ dev
500
+ .command("active-adr-count")
501
+ .description("Count non-superseded ADRs (optionally by author)")
502
+ .option("-a, --author <author>")
503
+ .action((opts) => console.log(getActiveAdrCount(opts.author)));
504
+
505
+ dev
506
+ .command("running-session-count")
507
+ .description("Count RUNNING sessions (optionally by developer)")
508
+ .option("-d, --developer <developer>")
509
+ .action((opts) => console.log(getRunningSessionCount(opts.developer)));
510
+
511
+ dev
512
+ .command("create-adr-v2 <adr-id>")
513
+ .description("Create V2 ADR")
514
+ .requiredOption("-a, --author <author>", "author")
515
+ .requiredOption("-t, --title <title>", "title")
516
+ .option("-i, --initial <status>", "initial status", ADR_MATURITY_V2.DRAFT)
517
+ .option("--metadata <json>", "metadata JSON")
518
+ .action((id, opts) => {
519
+ const a = createAdrV2({
520
+ id,
521
+ author: opts.author,
522
+ title: opts.title,
523
+ initialStatus: opts.initial,
524
+ metadata: _parseJsonV2(opts.metadata),
525
+ });
526
+ console.log(JSON.stringify(a, null, 2));
527
+ });
528
+
529
+ dev
530
+ .command("adr-v2 <adr-id>")
531
+ .description("Show V2 ADR")
532
+ .action((id) => {
533
+ const a = getAdrV2(id);
534
+ if (!a) return console.error(`ADR ${id} not found`);
535
+ console.log(JSON.stringify(a, null, 2));
536
+ });
537
+
538
+ dev
539
+ .command("list-adrs-v2")
540
+ .description("List V2 ADRs")
541
+ .option("-a, --author <author>")
542
+ .option("-s, --status <status>")
543
+ .action((opts) => console.log(JSON.stringify(listAdrsV2(opts), null, 2)));
544
+
545
+ dev
546
+ .command("set-adr-maturity-v2 <adr-id> <status>")
547
+ .description("Transition V2 ADR maturity")
548
+ .option("-r, --reason <reason>")
549
+ .option("--metadata <json>")
550
+ .action((id, status, opts) => {
551
+ const a = setAdrMaturityV2(id, status, {
552
+ reason: opts.reason,
553
+ metadata: _parseJsonV2(opts.metadata),
554
+ });
555
+ console.log(JSON.stringify(a, null, 2));
556
+ });
557
+
558
+ for (const [name, fn] of [
559
+ ["accept-adr", acceptAdr],
560
+ ["deprecate-adr", deprecateAdr],
561
+ ["supersede-adr", supersedeAdr],
562
+ ]) {
563
+ dev
564
+ .command(`${name} <adr-id>`)
565
+ .description(`Shortcut for ${name.replace("-adr", "")} transition`)
566
+ .option("-r, --reason <reason>")
567
+ .action((id, opts) => {
568
+ const a = fn(id, { reason: opts.reason });
569
+ console.log(JSON.stringify(a, null, 2));
570
+ });
571
+ }
572
+
573
+ dev
574
+ .command("enqueue-session-v2 <session-id>")
575
+ .description("Enqueue V2 dev session")
576
+ .requiredOption("-d, --developer <developer>")
577
+ .requiredOption("-g, --goal <goal>")
578
+ .option("--metadata <json>")
579
+ .action((id, opts) => {
580
+ const s = enqueueSessionV2({
581
+ id,
582
+ developer: opts.developer,
583
+ goal: opts.goal,
584
+ metadata: _parseJsonV2(opts.metadata),
585
+ });
586
+ console.log(JSON.stringify(s, null, 2));
587
+ });
588
+
589
+ dev
590
+ .command("session-v2 <session-id>")
591
+ .description("Show V2 session")
592
+ .action((id) => {
593
+ const s = getSessionV2(id);
594
+ if (!s) return console.error(`session ${id} not found`);
595
+ console.log(JSON.stringify(s, null, 2));
596
+ });
597
+
598
+ dev
599
+ .command("list-sessions-v2")
600
+ .description("List V2 sessions")
601
+ .option("-d, --developer <developer>")
602
+ .option("-s, --status <status>")
603
+ .action((opts) =>
604
+ console.log(JSON.stringify(listSessionsV2(opts), null, 2)),
605
+ );
606
+
607
+ dev
608
+ .command("set-session-status-v2 <session-id> <status>")
609
+ .option("-r, --reason <reason>")
610
+ .option("--metadata <json>")
611
+ .action((id, status, opts) => {
612
+ const s = setSessionStatusV2(id, status, {
613
+ reason: opts.reason,
614
+ metadata: _parseJsonV2(opts.metadata),
615
+ });
616
+ console.log(JSON.stringify(s, null, 2));
617
+ });
618
+
619
+ for (const [name, fn] of [
620
+ ["start-session-v2", startSessionV2],
621
+ ["complete-session-v2", completeSessionV2],
622
+ ["fail-session-v2", failSessionV2],
623
+ ["cancel-session-v2", cancelSessionV2],
624
+ ]) {
625
+ dev
626
+ .command(`${name} <session-id>`)
627
+ .description(`Shortcut for ${name.replace("-session-v2", "")} transition`)
628
+ .option("-r, --reason <reason>")
629
+ .action((id, opts) => {
630
+ const s = fn(id, { reason: opts.reason });
631
+ console.log(JSON.stringify(s, null, 2));
632
+ });
633
+ }
634
+
635
+ dev
636
+ .command("auto-supersede-stale-drafts")
637
+ .description(
638
+ "Bulk-supersede DRAFT ADRs whose updatedAt is older than adrStaleMs",
639
+ )
640
+ .action(() =>
641
+ console.log(
642
+ JSON.stringify({ flipped: autoSupersedeStaleDrafts() }, null, 2),
643
+ ),
644
+ );
645
+
646
+ dev
647
+ .command("auto-fail-stuck-sessions")
648
+ .description(
649
+ "Bulk-fail RUNNING sessions whose startedAt is older than sessionStuckMs",
650
+ )
651
+ .action(() =>
652
+ console.log(
653
+ JSON.stringify({ flipped: autoFailStuckSessions() }, null, 2),
654
+ ),
655
+ );
656
+
657
+ dev
658
+ .command("stats-v2")
659
+ .description("Show V2 autonomous-developer stats")
660
+ .action(() =>
661
+ console.log(JSON.stringify(getAutonomousDeveloperStatsV2(), null, 2)),
662
+ );
411
663
  }
@@ -16,6 +16,35 @@ import {
16
16
  verifyWithDID,
17
17
  exportIdentity,
18
18
  resolveDID,
19
+ IDENTITY_MATURITY_V2,
20
+ ISSUANCE_LIFECYCLE_V2,
21
+ getMaxActiveIdentitiesPerOwnerV2,
22
+ setMaxActiveIdentitiesPerOwnerV2,
23
+ getMaxPendingIssuancesPerIdentityV2,
24
+ setMaxPendingIssuancesPerIdentityV2,
25
+ getIdentityIdleMsV2,
26
+ setIdentityIdleMsV2,
27
+ getIssuanceStuckMsV2,
28
+ setIssuanceStuckMsV2,
29
+ registerIdentityV2,
30
+ getIdentityV2,
31
+ listIdentitiesV2,
32
+ activateIdentityV2,
33
+ suspendIdentityV2,
34
+ revokeIdentityV2,
35
+ touchIdentityV2,
36
+ createIssuanceV2,
37
+ getIssuanceV2,
38
+ listIssuancesV2,
39
+ startIssuanceV2,
40
+ completeIssuanceV2,
41
+ failIssuanceV2,
42
+ cancelIssuanceV2,
43
+ getActiveIdentityCountV2,
44
+ getPendingIssuanceCountV2,
45
+ autoSuspendIdleIdentitiesV2,
46
+ autoFailStuckIssuancesV2,
47
+ getDidManagerStatsV2,
19
48
  } from "../lib/did-manager.js";
20
49
 
21
50
  export function registerDidCommand(program) {
@@ -373,4 +402,333 @@ export function registerDidCommand(program) {
373
402
  process.exit(1);
374
403
  }
375
404
  });
405
+
406
+ // ===== V2 in-memory governance surface (no DB, no bootstrap) =====
407
+
408
+ did
409
+ .command("identity-maturities-v2")
410
+ .description("[V2] List identity maturity states")
411
+ .option("--json")
412
+ .action((o) => {
413
+ const s = Object.values(IDENTITY_MATURITY_V2);
414
+ if (o.json) console.log(JSON.stringify(s, null, 2));
415
+ else for (const v of s) logger.log(v);
416
+ });
417
+ did
418
+ .command("issuance-lifecycles-v2")
419
+ .description("[V2] List issuance lifecycle states")
420
+ .option("--json")
421
+ .action((o) => {
422
+ const s = Object.values(ISSUANCE_LIFECYCLE_V2);
423
+ if (o.json) console.log(JSON.stringify(s, null, 2));
424
+ else for (const v of s) logger.log(v);
425
+ });
426
+ did
427
+ .command("config-v2")
428
+ .description("[V2] Show governance config")
429
+ .option("--json")
430
+ .action((o) => {
431
+ const cfg = {
432
+ maxActiveIdentitiesPerOwner: getMaxActiveIdentitiesPerOwnerV2(),
433
+ maxPendingIssuancesPerIdentity: getMaxPendingIssuancesPerIdentityV2(),
434
+ identityIdleMs: getIdentityIdleMsV2(),
435
+ issuanceStuckMs: getIssuanceStuckMsV2(),
436
+ };
437
+ if (o.json) console.log(JSON.stringify(cfg, null, 2));
438
+ else for (const [k, v] of Object.entries(cfg)) logger.log(`${k}: ${v}`);
439
+ });
440
+ did
441
+ .command("set-max-active-identities-per-owner-v2 <n>")
442
+ .description("[V2] Set per-owner active identity cap")
443
+ .action((n) => {
444
+ try {
445
+ setMaxActiveIdentitiesPerOwnerV2(Number(n));
446
+ logger.success(`= ${getMaxActiveIdentitiesPerOwnerV2()}`);
447
+ } catch (e) {
448
+ logger.error(e.message);
449
+ process.exit(1);
450
+ }
451
+ });
452
+ did
453
+ .command("set-max-pending-issuances-per-identity-v2 <n>")
454
+ .description("[V2] Set per-identity pending issuance cap")
455
+ .action((n) => {
456
+ try {
457
+ setMaxPendingIssuancesPerIdentityV2(Number(n));
458
+ logger.success(`= ${getMaxPendingIssuancesPerIdentityV2()}`);
459
+ } catch (e) {
460
+ logger.error(e.message);
461
+ process.exit(1);
462
+ }
463
+ });
464
+ did
465
+ .command("set-identity-idle-ms-v2 <ms>")
466
+ .description("[V2] Set identity idle threshold (ms)")
467
+ .action((m) => {
468
+ try {
469
+ setIdentityIdleMsV2(Number(m));
470
+ logger.success(`= ${getIdentityIdleMsV2()}`);
471
+ } catch (e) {
472
+ logger.error(e.message);
473
+ process.exit(1);
474
+ }
475
+ });
476
+ did
477
+ .command("set-issuance-stuck-ms-v2 <ms>")
478
+ .description("[V2] Set issuance stuck threshold (ms)")
479
+ .action((m) => {
480
+ try {
481
+ setIssuanceStuckMsV2(Number(m));
482
+ logger.success(`= ${getIssuanceStuckMsV2()}`);
483
+ } catch (e) {
484
+ logger.error(e.message);
485
+ process.exit(1);
486
+ }
487
+ });
488
+
489
+ did
490
+ .command("register-identity-v2 <id>")
491
+ .description("[V2] Register a DID identity profile (PENDING)")
492
+ .requiredOption("-o, --owner <id>")
493
+ .requiredOption("-m, --method <method>")
494
+ .option("-d, --display-name <name>")
495
+ .action((id, o) => {
496
+ try {
497
+ const i = registerIdentityV2(id, {
498
+ ownerId: o.owner,
499
+ didMethod: o.method,
500
+ displayName: o.displayName,
501
+ });
502
+ logger.success(`identity ${i.id} registered (status=${i.status})`);
503
+ } catch (e) {
504
+ logger.error(e.message);
505
+ process.exit(1);
506
+ }
507
+ });
508
+ did
509
+ .command("activate-identity-v2 <id>")
510
+ .description("[V2] Activate identity (pending|suspended -> active)")
511
+ .action((id) => {
512
+ try {
513
+ activateIdentityV2(id);
514
+ logger.success(`identity ${id} active`);
515
+ } catch (e) {
516
+ logger.error(e.message);
517
+ process.exit(1);
518
+ }
519
+ });
520
+ did
521
+ .command("suspend-identity-v2 <id>")
522
+ .description("[V2] Suspend identity (active -> suspended)")
523
+ .action((id) => {
524
+ try {
525
+ suspendIdentityV2(id);
526
+ logger.success(`identity ${id} suspended`);
527
+ } catch (e) {
528
+ logger.error(e.message);
529
+ process.exit(1);
530
+ }
531
+ });
532
+ did
533
+ .command("revoke-identity-v2 <id>")
534
+ .description("[V2] Revoke identity (terminal)")
535
+ .action((id) => {
536
+ try {
537
+ revokeIdentityV2(id);
538
+ logger.success(`identity ${id} revoked`);
539
+ } catch (e) {
540
+ logger.error(e.message);
541
+ process.exit(1);
542
+ }
543
+ });
544
+ did
545
+ .command("touch-identity-v2 <id>")
546
+ .description("[V2] Bump identity lastSeenAt")
547
+ .action((id) => {
548
+ try {
549
+ touchIdentityV2(id);
550
+ logger.success(`identity ${id} touched`);
551
+ } catch (e) {
552
+ logger.error(e.message);
553
+ process.exit(1);
554
+ }
555
+ });
556
+ did
557
+ .command("get-identity-v2 <id>")
558
+ .description("[V2] Show identity profile")
559
+ .option("--json")
560
+ .action((id, o) => {
561
+ try {
562
+ const i = getIdentityV2(id);
563
+ if (!i) {
564
+ logger.info("identity not found");
565
+ return;
566
+ }
567
+ console.log(JSON.stringify(i, null, 2));
568
+ } catch (e) {
569
+ logger.error(e.message);
570
+ process.exit(1);
571
+ }
572
+ });
573
+ did
574
+ .command("list-identities-v2")
575
+ .description("[V2] List identity profiles")
576
+ .option("-o, --owner <id>")
577
+ .option("-s, --status <s>")
578
+ .option("-m, --method <method>")
579
+ .option("--json")
580
+ .action((o) => {
581
+ const list = listIdentitiesV2({
582
+ ownerId: o.owner,
583
+ status: o.status,
584
+ didMethod: o.method,
585
+ });
586
+ if (o.json) console.log(JSON.stringify(list, null, 2));
587
+ else
588
+ for (const i of list)
589
+ logger.log(`${i.id}\t${i.ownerId}\t${i.status}\t${i.didMethod}`);
590
+ });
591
+
592
+ did
593
+ .command("create-issuance-v2 <id>")
594
+ .description("[V2] Create a queued V2 issuance")
595
+ .requiredOption("-i, --identity <id>")
596
+ .requiredOption("-t, --type <ctype>")
597
+ .action((id, o) => {
598
+ try {
599
+ const j = createIssuanceV2(id, {
600
+ identityId: o.identity,
601
+ credentialType: o.type,
602
+ });
603
+ logger.success(
604
+ `issuance ${j.id} queued (identity=${j.identityId} type=${j.credentialType})`,
605
+ );
606
+ } catch (e) {
607
+ logger.error(e.message);
608
+ process.exit(1);
609
+ }
610
+ });
611
+ did
612
+ .command("start-issuance-v2 <id>")
613
+ .description("[V2] Start issuance (queued -> issuing)")
614
+ .action((id) => {
615
+ try {
616
+ startIssuanceV2(id);
617
+ logger.success(`issuance ${id} issuing`);
618
+ } catch (e) {
619
+ logger.error(e.message);
620
+ process.exit(1);
621
+ }
622
+ });
623
+ did
624
+ .command("complete-issuance-v2 <id>")
625
+ .description("[V2] Complete issuance (issuing -> issued)")
626
+ .action((id) => {
627
+ try {
628
+ completeIssuanceV2(id);
629
+ logger.success(`issuance ${id} issued`);
630
+ } catch (e) {
631
+ logger.error(e.message);
632
+ process.exit(1);
633
+ }
634
+ });
635
+ did
636
+ .command("fail-issuance-v2 <id>")
637
+ .description("[V2] Fail issuance (issuing -> failed)")
638
+ .action((id) => {
639
+ try {
640
+ failIssuanceV2(id);
641
+ logger.success(`issuance ${id} failed`);
642
+ } catch (e) {
643
+ logger.error(e.message);
644
+ process.exit(1);
645
+ }
646
+ });
647
+ did
648
+ .command("cancel-issuance-v2 <id>")
649
+ .description("[V2] Cancel issuance (queued|issuing -> cancelled)")
650
+ .action((id) => {
651
+ try {
652
+ cancelIssuanceV2(id);
653
+ logger.success(`issuance ${id} cancelled`);
654
+ } catch (e) {
655
+ logger.error(e.message);
656
+ process.exit(1);
657
+ }
658
+ });
659
+ did
660
+ .command("get-issuance-v2 <id>")
661
+ .description("[V2] Show issuance")
662
+ .option("--json")
663
+ .action((id, o) => {
664
+ try {
665
+ const j = getIssuanceV2(id);
666
+ if (!j) {
667
+ logger.info("issuance not found");
668
+ return;
669
+ }
670
+ console.log(JSON.stringify(j, null, 2));
671
+ } catch (e) {
672
+ logger.error(e.message);
673
+ process.exit(1);
674
+ }
675
+ });
676
+ did
677
+ .command("list-issuances-v2")
678
+ .description("[V2] List V2 issuances")
679
+ .option("-i, --identity <id>")
680
+ .option("-s, --status <s>")
681
+ .option("--json")
682
+ .action((o) => {
683
+ const list = listIssuancesV2({
684
+ identityId: o.identity,
685
+ status: o.status,
686
+ });
687
+ if (o.json) console.log(JSON.stringify(list, null, 2));
688
+ else
689
+ for (const j of list)
690
+ logger.log(
691
+ `${j.id}\t${j.identityId}\t${j.status}\t${j.credentialType}`,
692
+ );
693
+ });
694
+
695
+ did
696
+ .command("active-identity-count-v2")
697
+ .description("[V2] Count active identities (optional --owner)")
698
+ .option("-o, --owner <id>")
699
+ .action((o) => logger.log(String(getActiveIdentityCountV2(o.owner))));
700
+ did
701
+ .command("pending-issuance-count-v2")
702
+ .description("[V2] Count pending issuances (queued+issuing)")
703
+ .option("-i, --identity <id>")
704
+ .action((o) => logger.log(String(getPendingIssuanceCountV2(o.identity))));
705
+ did
706
+ .command("auto-suspend-idle-identities-v2")
707
+ .description("[V2] Suspend idle active identities")
708
+ .option("--now <ms>")
709
+ .option("--json")
710
+ .action((o) => {
711
+ const list = autoSuspendIdleIdentitiesV2(
712
+ o.now ? { now: Number(o.now) } : undefined,
713
+ );
714
+ if (o.json) console.log(JSON.stringify(list, null, 2));
715
+ else logger.success(`suspended ${list.length}`);
716
+ });
717
+ did
718
+ .command("auto-fail-stuck-issuances-v2")
719
+ .description("[V2] Fail stuck issuing")
720
+ .option("--now <ms>")
721
+ .option("--json")
722
+ .action((o) => {
723
+ const list = autoFailStuckIssuancesV2(
724
+ o.now ? { now: Number(o.now) } : undefined,
725
+ );
726
+ if (o.json) console.log(JSON.stringify(list, null, 2));
727
+ else logger.success(`failed ${list.length}`);
728
+ });
729
+ did
730
+ .command("stats-v2")
731
+ .description("[V2] Show governance stats")
732
+ .option("--json")
733
+ .action(() => console.log(JSON.stringify(getDidManagerStatsV2(), null, 2)));
376
734
  }