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
@@ -26,6 +26,44 @@ import {
26
26
  getRecommendationStats,
27
27
  getTopInterests,
28
28
  suggestTopics,
29
+ // V2 (Phase 48 V2)
30
+ PROFILE_MATURITY_V2,
31
+ FEED_LIFECYCLE_V2,
32
+ REC_DEFAULT_MAX_ACTIVE_PROFILES_PER_SEGMENT,
33
+ REC_DEFAULT_MAX_ACTIVE_FEEDS_PER_CURATOR,
34
+ REC_DEFAULT_PROFILE_IDLE_MS,
35
+ REC_DEFAULT_FEED_STALE_MS,
36
+ getDefaultMaxActiveProfilesPerSegmentV2,
37
+ getMaxActiveProfilesPerSegmentV2,
38
+ setMaxActiveProfilesPerSegmentV2,
39
+ getDefaultMaxActiveFeedsPerCuratorV2,
40
+ getMaxActiveFeedsPerCuratorV2,
41
+ setMaxActiveFeedsPerCuratorV2,
42
+ getDefaultProfileIdleMsV2,
43
+ getProfileIdleMsV2,
44
+ setProfileIdleMsV2,
45
+ getDefaultFeedStaleMsV2,
46
+ getFeedStaleMsV2,
47
+ setFeedStaleMsV2,
48
+ registerProfileV2,
49
+ getProfileV2,
50
+ setProfileMaturityV2,
51
+ activateProfile,
52
+ dormantProfile,
53
+ retireProfile,
54
+ touchProfileActivity,
55
+ registerFeedV2,
56
+ getFeedV2,
57
+ setFeedStatusV2,
58
+ activateFeed,
59
+ pauseFeed,
60
+ archiveFeed,
61
+ touchFeedPublish,
62
+ getActiveProfileCount,
63
+ getActiveFeedCount,
64
+ autoDormantIdleProfiles,
65
+ autoArchiveStaleFeeds,
66
+ getRecommendationStatsV2,
29
67
  } from "../lib/content-recommendation.js";
30
68
 
31
69
  function _dbFromCtx(cmd) {
@@ -332,5 +370,307 @@ export function registerRecommendCommand(program) {
332
370
  console.log(` ${s.action.padEnd(8)} ${s.topic} by ${s.amount}`);
333
371
  });
334
372
 
373
+ /* ── V2 (Phase 48 V2) ────────────────────────────── */
374
+
375
+ function _parseJsonFlag(value, label) {
376
+ if (value === undefined) return undefined;
377
+ try {
378
+ return JSON.parse(value);
379
+ } catch {
380
+ throw new Error(`Invalid JSON for ${label}`);
381
+ }
382
+ }
383
+
384
+ rec
385
+ .command("profile-maturities-v2")
386
+ .description("List V2 profile maturity states")
387
+ .option("--json", "JSON output")
388
+ .action((opts) => {
389
+ const out = Object.values(PROFILE_MATURITY_V2);
390
+ if (opts.json) return console.log(JSON.stringify(out, null, 2));
391
+ for (const s of out) console.log(` ${s}`);
392
+ });
393
+
394
+ rec
395
+ .command("feed-lifecycles-v2")
396
+ .description("List V2 feed lifecycle states")
397
+ .option("--json", "JSON output")
398
+ .action((opts) => {
399
+ const out = Object.values(FEED_LIFECYCLE_V2);
400
+ if (opts.json) return console.log(JSON.stringify(out, null, 2));
401
+ for (const s of out) console.log(` ${s}`);
402
+ });
403
+
404
+ rec
405
+ .command("default-max-active-profiles-per-segment")
406
+ .description("Show V2 default per-segment active-profile cap")
407
+ .action(() =>
408
+ console.log(String(getDefaultMaxActiveProfilesPerSegmentV2())),
409
+ );
410
+
411
+ rec
412
+ .command("max-active-profiles-per-segment")
413
+ .description("Show current V2 per-segment active-profile cap")
414
+ .action(() => console.log(String(getMaxActiveProfilesPerSegmentV2())));
415
+
416
+ rec
417
+ .command("set-max-active-profiles-per-segment <n>")
418
+ .description("Set V2 per-segment active-profile cap")
419
+ .action((n) =>
420
+ console.log(String(setMaxActiveProfilesPerSegmentV2(Number(n)))),
421
+ );
422
+
423
+ rec
424
+ .command("default-max-active-feeds-per-curator")
425
+ .description("Show V2 default per-curator active-feed cap")
426
+ .action(() => console.log(String(getDefaultMaxActiveFeedsPerCuratorV2())));
427
+
428
+ rec
429
+ .command("max-active-feeds-per-curator")
430
+ .description("Show current V2 per-curator active-feed cap")
431
+ .action(() => console.log(String(getMaxActiveFeedsPerCuratorV2())));
432
+
433
+ rec
434
+ .command("set-max-active-feeds-per-curator <n>")
435
+ .description("Set V2 per-curator active-feed cap")
436
+ .action((n) =>
437
+ console.log(String(setMaxActiveFeedsPerCuratorV2(Number(n)))),
438
+ );
439
+
440
+ rec
441
+ .command("default-profile-idle-ms")
442
+ .description("Show V2 default profile-idle window (ms)")
443
+ .action(() => console.log(String(getDefaultProfileIdleMsV2())));
444
+
445
+ rec
446
+ .command("profile-idle-ms")
447
+ .description("Show current V2 profile-idle window (ms)")
448
+ .action(() => console.log(String(getProfileIdleMsV2())));
449
+
450
+ rec
451
+ .command("set-profile-idle-ms <ms>")
452
+ .description("Set V2 profile-idle window (ms)")
453
+ .action((ms) => console.log(String(setProfileIdleMsV2(Number(ms)))));
454
+
455
+ rec
456
+ .command("default-feed-stale-ms")
457
+ .description("Show V2 default feed-stale window (ms)")
458
+ .action(() => console.log(String(getDefaultFeedStaleMsV2())));
459
+
460
+ rec
461
+ .command("feed-stale-ms")
462
+ .description("Show current V2 feed-stale window (ms)")
463
+ .action(() => console.log(String(getFeedStaleMsV2())));
464
+
465
+ rec
466
+ .command("set-feed-stale-ms <ms>")
467
+ .description("Set V2 feed-stale window (ms)")
468
+ .action((ms) => console.log(String(setFeedStaleMsV2(Number(ms)))));
469
+
470
+ rec
471
+ .command("active-profile-count")
472
+ .description("Count active V2 profiles (optionally scoped by segment)")
473
+ .option("-s, --segment <segment>", "Scope by segment")
474
+ .action((opts) => console.log(String(getActiveProfileCount(opts.segment))));
475
+
476
+ rec
477
+ .command("active-feed-count")
478
+ .description("Count active V2 feeds (optionally scoped by curator)")
479
+ .option("-c, --curator <curator>", "Scope by curator")
480
+ .action((opts) => console.log(String(getActiveFeedCount(opts.curator))));
481
+
482
+ rec
483
+ .command("register-profile-v2 <profile-id>")
484
+ .description("Register a V2 profile")
485
+ .requiredOption("-s, --segment <segment>", "Segment bucket")
486
+ .option("-u, --user-id <user-id>", "User id")
487
+ .option("-i, --initial-status <status>", "Initial maturity status")
488
+ .option("-m, --metadata <json>", "Metadata JSON")
489
+ .action((profileId, opts) => {
490
+ const db = _dbFromCtx(rec);
491
+ const metadata = _parseJsonFlag(opts.metadata, "--metadata");
492
+ const out = registerProfileV2(db, {
493
+ profileId,
494
+ segment: opts.segment,
495
+ userId: opts.userId,
496
+ initialStatus: opts.initialStatus,
497
+ metadata,
498
+ });
499
+ console.log(JSON.stringify(out, null, 2));
500
+ });
501
+
502
+ rec
503
+ .command("profile-v2 <profile-id>")
504
+ .description("Show a V2 profile")
505
+ .action((profileId) => {
506
+ const out = getProfileV2(profileId);
507
+ console.log(out ? JSON.stringify(out, null, 2) : "null");
508
+ });
509
+
510
+ rec
511
+ .command("set-profile-maturity-v2 <profile-id> <status>")
512
+ .description("Set V2 profile maturity status")
513
+ .option("-r, --reason <reason>", "Reason")
514
+ .option("-m, --metadata <json>", "Metadata JSON (merged)")
515
+ .action((profileId, status, opts) => {
516
+ const db = _dbFromCtx(rec);
517
+ const metadata = _parseJsonFlag(opts.metadata, "--metadata");
518
+ const out = setProfileMaturityV2(db, profileId, status, {
519
+ reason: opts.reason,
520
+ metadata,
521
+ });
522
+ console.log(JSON.stringify(out, null, 2));
523
+ });
524
+
525
+ rec
526
+ .command("activate-profile <profile-id>")
527
+ .description("Activate a V2 profile")
528
+ .option("-r, --reason <reason>", "Reason")
529
+ .action((profileId, opts) => {
530
+ const db = _dbFromCtx(rec);
531
+ console.log(
532
+ JSON.stringify(activateProfile(db, profileId, opts.reason), null, 2),
533
+ );
534
+ });
535
+
536
+ rec
537
+ .command("dormant-profile <profile-id>")
538
+ .description("Mark a V2 profile dormant")
539
+ .option("-r, --reason <reason>", "Reason")
540
+ .action((profileId, opts) => {
541
+ const db = _dbFromCtx(rec);
542
+ console.log(
543
+ JSON.stringify(dormantProfile(db, profileId, opts.reason), null, 2),
544
+ );
545
+ });
546
+
547
+ rec
548
+ .command("retire-profile <profile-id>")
549
+ .description("Retire a V2 profile")
550
+ .option("-r, --reason <reason>", "Reason")
551
+ .action((profileId, opts) => {
552
+ const db = _dbFromCtx(rec);
553
+ console.log(
554
+ JSON.stringify(retireProfile(db, profileId, opts.reason), null, 2),
555
+ );
556
+ });
557
+
558
+ rec
559
+ .command("touch-profile-activity <profile-id>")
560
+ .description("Bump lastActivityAt on a V2 profile")
561
+ .action((profileId) => {
562
+ console.log(JSON.stringify(touchProfileActivity(profileId), null, 2));
563
+ });
564
+
565
+ rec
566
+ .command("register-feed-v2 <feed-id>")
567
+ .description("Register a V2 feed")
568
+ .requiredOption("-c, --curator-id <curator>", "Curator id")
569
+ .option("-t, --topics <csv>", "Comma-separated topics")
570
+ .option("-i, --initial-status <status>", "Initial lifecycle status")
571
+ .option("-m, --metadata <json>", "Metadata JSON")
572
+ .action((feedId, opts) => {
573
+ const db = _dbFromCtx(rec);
574
+ const metadata = _parseJsonFlag(opts.metadata, "--metadata");
575
+ const topics = opts.topics
576
+ ? opts.topics
577
+ .split(",")
578
+ .map((s) => s.trim())
579
+ .filter(Boolean)
580
+ : [];
581
+ const out = registerFeedV2(db, {
582
+ feedId,
583
+ curatorId: opts.curatorId,
584
+ topics,
585
+ initialStatus: opts.initialStatus,
586
+ metadata,
587
+ });
588
+ console.log(JSON.stringify(out, null, 2));
589
+ });
590
+
591
+ rec
592
+ .command("feed-v2 <feed-id>")
593
+ .description("Show a V2 feed")
594
+ .action((feedId) => {
595
+ const out = getFeedV2(feedId);
596
+ console.log(out ? JSON.stringify(out, null, 2) : "null");
597
+ });
598
+
599
+ rec
600
+ .command("set-feed-status-v2 <feed-id> <status>")
601
+ .description("Set V2 feed lifecycle status")
602
+ .option("-r, --reason <reason>", "Reason")
603
+ .option("-m, --metadata <json>", "Metadata JSON (merged)")
604
+ .action((feedId, status, opts) => {
605
+ const db = _dbFromCtx(rec);
606
+ const metadata = _parseJsonFlag(opts.metadata, "--metadata");
607
+ const out = setFeedStatusV2(db, feedId, status, {
608
+ reason: opts.reason,
609
+ metadata,
610
+ });
611
+ console.log(JSON.stringify(out, null, 2));
612
+ });
613
+
614
+ rec
615
+ .command("activate-feed <feed-id>")
616
+ .description("Activate a V2 feed")
617
+ .option("-r, --reason <reason>", "Reason")
618
+ .action((feedId, opts) => {
619
+ const db = _dbFromCtx(rec);
620
+ console.log(
621
+ JSON.stringify(activateFeed(db, feedId, opts.reason), null, 2),
622
+ );
623
+ });
624
+
625
+ rec
626
+ .command("pause-feed <feed-id>")
627
+ .description("Pause a V2 feed")
628
+ .option("-r, --reason <reason>", "Reason")
629
+ .action((feedId, opts) => {
630
+ const db = _dbFromCtx(rec);
631
+ console.log(JSON.stringify(pauseFeed(db, feedId, opts.reason), null, 2));
632
+ });
633
+
634
+ rec
635
+ .command("archive-feed <feed-id>")
636
+ .description("Archive a V2 feed")
637
+ .option("-r, --reason <reason>", "Reason")
638
+ .action((feedId, opts) => {
639
+ const db = _dbFromCtx(rec);
640
+ console.log(
641
+ JSON.stringify(archiveFeed(db, feedId, opts.reason), null, 2),
642
+ );
643
+ });
644
+
645
+ rec
646
+ .command("touch-feed-publish <feed-id>")
647
+ .description("Bump lastPublishAt on a V2 feed")
648
+ .action((feedId) => {
649
+ console.log(JSON.stringify(touchFeedPublish(feedId), null, 2));
650
+ });
651
+
652
+ rec
653
+ .command("auto-dormant-idle-profiles")
654
+ .description("Auto-flip idle ACTIVE V2 profiles to DORMANT")
655
+ .action(() => {
656
+ const db = _dbFromCtx(rec);
657
+ console.log(JSON.stringify(autoDormantIdleProfiles(db), null, 2));
658
+ });
659
+
660
+ rec
661
+ .command("auto-archive-stale-feeds")
662
+ .description("Auto-flip stale ACTIVE/PAUSED V2 feeds to ARCHIVED")
663
+ .action(() => {
664
+ const db = _dbFromCtx(rec);
665
+ console.log(JSON.stringify(autoArchiveStaleFeeds(db), null, 2));
666
+ });
667
+
668
+ rec
669
+ .command("stats-v2")
670
+ .description("V2 recommendation stats (counts by state + config)")
671
+ .action(() => {
672
+ console.log(JSON.stringify(getRecommendationStatsV2(), null, 2));
673
+ });
674
+
335
675
  program.addCommand(rec);
336
676
  }
@@ -34,8 +34,51 @@ import {
34
34
  healthCheck,
35
35
  getMetrics,
36
36
  getRuntimeStats,
37
+ /* V2 (Phase 63) */
38
+ PLUGIN_MATURITY_V2,
39
+ RUNTIME_TASK_V2,
40
+ getDefaultMaxActivePluginsPerOwnerV2,
41
+ getMaxActivePluginsPerOwnerV2,
42
+ setMaxActivePluginsPerOwnerV2,
43
+ getDefaultMaxRunningTasksPerOwnerV2,
44
+ getMaxRunningTasksPerOwnerV2,
45
+ setMaxRunningTasksPerOwnerV2,
46
+ getDefaultPluginIdleMsV2,
47
+ getPluginIdleMsV2,
48
+ setPluginIdleMsV2,
49
+ getDefaultTaskStuckMsV2,
50
+ getTaskStuckMsV2,
51
+ setTaskStuckMsV2,
52
+ registerPluginV2,
53
+ getPluginV2,
54
+ setPluginMaturityV2,
55
+ activatePluginV2,
56
+ deprecatePluginV2,
57
+ retirePluginV2,
58
+ touchPluginInvocation,
59
+ enqueueRuntimeTaskV2,
60
+ getRuntimeTaskV2,
61
+ setRuntimeTaskStatusV2,
62
+ startRuntimeTask,
63
+ completeRuntimeTask,
64
+ failRuntimeTask,
65
+ cancelRuntimeTask,
66
+ getActivePluginCount,
67
+ getRunningTaskCount,
68
+ autoRetireIdlePlugins,
69
+ autoFailStuckRuntimeTasks,
70
+ getRuntimeStatsV2,
37
71
  } from "../lib/universal-runtime.js";
38
72
 
73
+ function _parseMetaV2(s) {
74
+ if (!s) return undefined;
75
+ try {
76
+ return JSON.parse(s);
77
+ } catch {
78
+ throw new Error(`--metadata must be valid JSON`);
79
+ }
80
+ }
81
+
39
82
  function _dbFromCtx(cmd) {
40
83
  const root = cmd?.parent?.parent ?? cmd?.parent;
41
84
  return root?._db;
@@ -496,5 +539,269 @@ export function registerRuntimeCommand(program) {
496
539
  console.log(`Uptime: ${s.metrics.uptimeMs}ms`);
497
540
  });
498
541
 
542
+ /* ═════════════════════════════════════════════════════ *
543
+ * Phase 63 V2 — Plugin Maturity + Runtime Task Lifecycle
544
+ * ═════════════════════════════════════════════════════ */
545
+
546
+ runtime
547
+ .command("plugin-maturities-v2")
548
+ .description("List Phase 63 V2 plugin maturity states")
549
+ .option("--json", "JSON output")
550
+ .action((opts) => {
551
+ const v = Object.values(PLUGIN_MATURITY_V2);
552
+ if (opts.json) return console.log(JSON.stringify(v, null, 2));
553
+ for (const s of v) console.log(s);
554
+ });
555
+
556
+ runtime
557
+ .command("runtime-task-lifecycles-v2")
558
+ .description("List Phase 63 V2 runtime-task lifecycle states")
559
+ .option("--json", "JSON output")
560
+ .action((opts) => {
561
+ const v = Object.values(RUNTIME_TASK_V2);
562
+ if (opts.json) return console.log(JSON.stringify(v, null, 2));
563
+ for (const s of v) console.log(s);
564
+ });
565
+
566
+ runtime
567
+ .command("default-max-active-plugins-per-owner")
568
+ .action(() => console.log(getDefaultMaxActivePluginsPerOwnerV2()));
569
+ runtime
570
+ .command("max-active-plugins-per-owner")
571
+ .action(() => console.log(getMaxActivePluginsPerOwnerV2()));
572
+ runtime
573
+ .command("set-max-active-plugins-per-owner <n>")
574
+ .action((n) => console.log(setMaxActivePluginsPerOwnerV2(n)));
575
+
576
+ runtime
577
+ .command("default-max-running-tasks-per-owner")
578
+ .action(() => console.log(getDefaultMaxRunningTasksPerOwnerV2()));
579
+ runtime
580
+ .command("max-running-tasks-per-owner")
581
+ .action(() => console.log(getMaxRunningTasksPerOwnerV2()));
582
+ runtime
583
+ .command("set-max-running-tasks-per-owner <n>")
584
+ .action((n) => console.log(setMaxRunningTasksPerOwnerV2(n)));
585
+
586
+ runtime
587
+ .command("default-plugin-idle-ms")
588
+ .action(() => console.log(getDefaultPluginIdleMsV2()));
589
+ runtime
590
+ .command("plugin-idle-ms")
591
+ .action(() => console.log(getPluginIdleMsV2()));
592
+ runtime
593
+ .command("set-plugin-idle-ms <ms>")
594
+ .action((ms) => console.log(setPluginIdleMsV2(ms)));
595
+
596
+ runtime
597
+ .command("default-task-stuck-ms")
598
+ .action(() => console.log(getDefaultTaskStuckMsV2()));
599
+ runtime
600
+ .command("task-stuck-ms")
601
+ .action(() => console.log(getTaskStuckMsV2()));
602
+ runtime
603
+ .command("set-task-stuck-ms <ms>")
604
+ .action((ms) => console.log(setTaskStuckMsV2(ms)));
605
+
606
+ runtime
607
+ .command("active-plugin-count")
608
+ .option("-o, --owner <id>")
609
+ .action((opts) => console.log(getActivePluginCount(opts.owner)));
610
+
611
+ runtime
612
+ .command("running-task-count")
613
+ .option("-o, --owner <id>")
614
+ .action((opts) => console.log(getRunningTaskCount(opts.owner)));
615
+
616
+ runtime
617
+ .command("register-plugin-v2 <plugin-id>")
618
+ .requiredOption("-o, --owner <id>")
619
+ .option("-n, --name <text>")
620
+ .option("-v, --version <text>")
621
+ .option("-i, --initial-status <status>")
622
+ .option("-m, --metadata <json>")
623
+ .option("--json")
624
+ .action((pluginId, opts) => {
625
+ const rec = registerPluginV2(_dbFromCtx(runtime), {
626
+ pluginId,
627
+ ownerId: opts.owner,
628
+ name: opts.name,
629
+ version: opts.version,
630
+ initialStatus: opts.initialStatus,
631
+ metadata: _parseMetaV2(opts.metadata),
632
+ });
633
+ if (opts.json) return console.log(JSON.stringify(rec, null, 2));
634
+ console.log(`Registered plugin ${pluginId} (${rec.status})`);
635
+ });
636
+
637
+ runtime
638
+ .command("plugin-v2 <plugin-id>")
639
+ .option("--json")
640
+ .action((id, opts) => {
641
+ const rec = getPluginV2(id);
642
+ if (!rec) {
643
+ console.error(`Unknown plugin: ${id}`);
644
+ process.exitCode = 1;
645
+ return;
646
+ }
647
+ if (opts.json) return console.log(JSON.stringify(rec, null, 2));
648
+ console.log(`${rec.pluginId} [${rec.status}] owner=${rec.ownerId}`);
649
+ });
650
+
651
+ runtime
652
+ .command("set-plugin-maturity-v2 <plugin-id> <status>")
653
+ .option("-r, --reason <text>")
654
+ .option("-m, --metadata <json>")
655
+ .action((id, status, opts) => {
656
+ const rec = setPluginMaturityV2(_dbFromCtx(runtime), id, status, {
657
+ reason: opts.reason,
658
+ metadata: _parseMetaV2(opts.metadata),
659
+ });
660
+ console.log(`${id} → ${rec.status}`);
661
+ });
662
+
663
+ runtime
664
+ .command("activate-plugin-v2 <plugin-id>")
665
+ .option("-r, --reason <text>")
666
+ .action((id, opts) => {
667
+ const rec = activatePluginV2(_dbFromCtx(runtime), id, opts.reason);
668
+ console.log(`${id} → ${rec.status}`);
669
+ });
670
+
671
+ runtime
672
+ .command("deprecate-plugin-v2 <plugin-id>")
673
+ .option("-r, --reason <text>")
674
+ .action((id, opts) => {
675
+ const rec = deprecatePluginV2(_dbFromCtx(runtime), id, opts.reason);
676
+ console.log(`${id} → ${rec.status}`);
677
+ });
678
+
679
+ runtime
680
+ .command("retire-plugin-v2 <plugin-id>")
681
+ .option("-r, --reason <text>")
682
+ .action((id, opts) => {
683
+ const rec = retirePluginV2(_dbFromCtx(runtime), id, opts.reason);
684
+ console.log(`${id} → ${rec.status}`);
685
+ });
686
+
687
+ runtime.command("touch-plugin-invocation <plugin-id>").action((id) => {
688
+ const r = touchPluginInvocation(id);
689
+ console.log(`${id} lastInvokedAt=${r.lastInvokedAt}`);
690
+ });
691
+
692
+ runtime
693
+ .command("enqueue-runtime-task-v2 <task-id>")
694
+ .requiredOption("-o, --owner <id>")
695
+ .requiredOption("-p, --plugin <id>")
696
+ .requiredOption("-k, --kind <name>")
697
+ .option("-m, --metadata <json>")
698
+ .option("--json")
699
+ .action((taskId, opts) => {
700
+ const rec = enqueueRuntimeTaskV2(_dbFromCtx(runtime), {
701
+ taskId,
702
+ ownerId: opts.owner,
703
+ pluginId: opts.plugin,
704
+ kind: opts.kind,
705
+ metadata: _parseMetaV2(opts.metadata),
706
+ });
707
+ if (opts.json) return console.log(JSON.stringify(rec, null, 2));
708
+ console.log(`Enqueued task ${taskId} (${rec.status})`);
709
+ });
710
+
711
+ runtime
712
+ .command("runtime-task-v2 <task-id>")
713
+ .option("--json")
714
+ .action((id, opts) => {
715
+ const rec = getRuntimeTaskV2(id);
716
+ if (!rec) {
717
+ console.error(`Unknown task: ${id}`);
718
+ process.exitCode = 1;
719
+ return;
720
+ }
721
+ if (opts.json) return console.log(JSON.stringify(rec, null, 2));
722
+ console.log(`${rec.taskId} [${rec.status}] owner=${rec.ownerId}`);
723
+ });
724
+
725
+ runtime
726
+ .command("set-runtime-task-status-v2 <task-id> <status>")
727
+ .option("-r, --reason <text>")
728
+ .option("-m, --metadata <json>")
729
+ .action((id, status, opts) => {
730
+ const rec = setRuntimeTaskStatusV2(_dbFromCtx(runtime), id, status, {
731
+ reason: opts.reason,
732
+ metadata: _parseMetaV2(opts.metadata),
733
+ });
734
+ console.log(`${id} → ${rec.status}`);
735
+ });
736
+
737
+ runtime
738
+ .command("start-runtime-task <task-id>")
739
+ .option("-r, --reason <text>")
740
+ .action((id, opts) => {
741
+ const rec = startRuntimeTask(_dbFromCtx(runtime), id, opts.reason);
742
+ console.log(`${id} → ${rec.status}`);
743
+ });
744
+
745
+ runtime
746
+ .command("complete-runtime-task <task-id>")
747
+ .option("-r, --reason <text>")
748
+ .action((id, opts) => {
749
+ const rec = completeRuntimeTask(_dbFromCtx(runtime), id, opts.reason);
750
+ console.log(`${id} → ${rec.status}`);
751
+ });
752
+
753
+ runtime
754
+ .command("fail-runtime-task <task-id>")
755
+ .option("-r, --reason <text>")
756
+ .action((id, opts) => {
757
+ const rec = failRuntimeTask(_dbFromCtx(runtime), id, opts.reason);
758
+ console.log(`${id} → ${rec.status}`);
759
+ });
760
+
761
+ runtime
762
+ .command("cancel-runtime-task <task-id>")
763
+ .option("-r, --reason <text>")
764
+ .action((id, opts) => {
765
+ const rec = cancelRuntimeTask(_dbFromCtx(runtime), id, opts.reason);
766
+ console.log(`${id} → ${rec.status}`);
767
+ });
768
+
769
+ runtime
770
+ .command("auto-retire-idle-plugins")
771
+ .option("--json")
772
+ .action((opts) => {
773
+ const r = autoRetireIdlePlugins(_dbFromCtx(runtime));
774
+ if (opts.json) return console.log(JSON.stringify(r, null, 2));
775
+ console.log(`Retired ${r.count} idle plugin(s)`);
776
+ });
777
+
778
+ runtime
779
+ .command("auto-fail-stuck-runtime-tasks")
780
+ .option("--json")
781
+ .action((opts) => {
782
+ const r = autoFailStuckRuntimeTasks(_dbFromCtx(runtime));
783
+ if (opts.json) return console.log(JSON.stringify(r, null, 2));
784
+ console.log(`Failed ${r.count} stuck task(s)`);
785
+ });
786
+
787
+ runtime
788
+ .command("stats-v2")
789
+ .description("Phase 63 V2 statistics")
790
+ .option("--json", "JSON output")
791
+ .action((opts) => {
792
+ const s = getRuntimeStatsV2();
793
+ if (opts.json) return console.log(JSON.stringify(s, null, 2));
794
+ console.log(
795
+ `Plugins(V2)=${s.totalPluginsV2} Tasks(V2)=${s.totalTasksV2} ` +
796
+ `caps: active-plugins/owner=${s.maxActivePluginsPerOwner} running-tasks/owner=${s.maxRunningTasksPerOwner}`,
797
+ );
798
+ console.log("plugins-by-status:");
799
+ for (const [k, v] of Object.entries(s.pluginsByStatus))
800
+ console.log(` ${k.padEnd(12)} ${v}`);
801
+ console.log("tasks-by-status:");
802
+ for (const [k, v] of Object.entries(s.tasksByStatus))
803
+ console.log(` ${k.padEnd(12)} ${v}`);
804
+ });
805
+
499
806
  program.addCommand(runtime);
500
807
  }