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
@@ -18,6 +18,22 @@ import {
18
18
  listOptimizationRuns,
19
19
  applyOptimizedParams,
20
20
  OPTIMIZATION_OBJECTIVES,
21
+ // V2 (Phase 60)
22
+ RUN_STATUS_V2,
23
+ OBJECTIVE_V2,
24
+ DECAY_MODEL_V2,
25
+ ANOMALY_METHOD_V2,
26
+ REPUTATION_DEFAULT_MAX_CONCURRENT,
27
+ setMaxConcurrentOptimizations,
28
+ getMaxConcurrentOptimizations,
29
+ getActiveOptimizationCount,
30
+ startOptimizationV2,
31
+ completeOptimization,
32
+ cancelOptimization,
33
+ failOptimization,
34
+ applyOptimization,
35
+ setRunStatus,
36
+ getReputationStatsV2,
21
37
  } from "../lib/reputation-optimizer.js";
22
38
 
23
39
  function _dbFromCtx(ctx) {
@@ -346,4 +362,249 @@ export function registerReputationCommand(program) {
346
362
  for (const v of values) logger.log(` ${chalk.cyan(v)}`);
347
363
  }
348
364
  });
365
+
366
+ /* ── V2 (Phase 60) ───────────────────────────────────────── */
367
+
368
+ rep
369
+ .command("run-statuses")
370
+ .description(
371
+ "List V2 run statuses (running/complete/applied/failed/cancelled)",
372
+ )
373
+ .option("--json", "Output as JSON")
374
+ .action((options) => {
375
+ const values = Object.values(RUN_STATUS_V2);
376
+ if (options.json) console.log(JSON.stringify(values, null, 2));
377
+ else for (const v of values) logger.log(` ${chalk.cyan(v)}`);
378
+ });
379
+
380
+ rep
381
+ .command("v2-objectives")
382
+ .description("List V2 objectives (frozen enum)")
383
+ .option("--json", "Output as JSON")
384
+ .action((options) => {
385
+ const values = Object.values(OBJECTIVE_V2);
386
+ if (options.json) console.log(JSON.stringify(values, null, 2));
387
+ else for (const v of values) logger.log(` ${chalk.cyan(v)}`);
388
+ });
389
+
390
+ rep
391
+ .command("decay-models")
392
+ .description("List V2 decay models (frozen enum)")
393
+ .option("--json", "Output as JSON")
394
+ .action((options) => {
395
+ const values = Object.values(DECAY_MODEL_V2);
396
+ if (options.json) console.log(JSON.stringify(values, null, 2));
397
+ else for (const v of values) logger.log(` ${chalk.cyan(v)}`);
398
+ });
399
+
400
+ rep
401
+ .command("anomaly-methods")
402
+ .description("List V2 anomaly methods (frozen enum)")
403
+ .option("--json", "Output as JSON")
404
+ .action((options) => {
405
+ const values = Object.values(ANOMALY_METHOD_V2);
406
+ if (options.json) console.log(JSON.stringify(values, null, 2));
407
+ else for (const v of values) logger.log(` ${chalk.cyan(v)}`);
408
+ });
409
+
410
+ rep
411
+ .command("default-max-concurrent")
412
+ .description("Show default max concurrent optimizations")
413
+ .action(() => {
414
+ logger.log(` ${REPUTATION_DEFAULT_MAX_CONCURRENT}`);
415
+ });
416
+
417
+ rep
418
+ .command("max-concurrent")
419
+ .description("Show current max concurrent optimizations")
420
+ .action(() => {
421
+ logger.log(` ${getMaxConcurrentOptimizations()}`);
422
+ });
423
+
424
+ rep
425
+ .command("active-optimization-count")
426
+ .description("Show count of currently-RUNNING optimizations")
427
+ .action(() => {
428
+ logger.log(` ${getActiveOptimizationCount()}`);
429
+ });
430
+
431
+ rep
432
+ .command("set-max-concurrent <n>")
433
+ .description("Set the concurrency cap for RUNNING optimizations")
434
+ .action((n) => {
435
+ try {
436
+ const v = setMaxConcurrentOptimizations(Number(n));
437
+ logger.success(`Max concurrent = ${v}`);
438
+ } catch (err) {
439
+ logger.error(`Failed: ${err.message}`);
440
+ process.exit(1);
441
+ }
442
+ });
443
+
444
+ rep
445
+ .command("start-v2")
446
+ .description(
447
+ "Start a V2 optimization (RUNNING only, driven by complete/cancel/fail)",
448
+ )
449
+ .option(
450
+ "-o, --objective <name>",
451
+ "Objective (accuracy|fairness|resilience|convergence_speed)",
452
+ "accuracy",
453
+ )
454
+ .option("-i, --iterations <n>", "Iteration count", parseInt, 50)
455
+ .option("--json", "Output as JSON")
456
+ .action(async (options) => {
457
+ try {
458
+ const ctx = await bootstrap({ verbose: program.opts().verbose });
459
+ const db = _dbFromCtx(ctx);
460
+ const run = startOptimizationV2(db, {
461
+ objective: options.objective,
462
+ iterations: options.iterations,
463
+ });
464
+ if (options.json) console.log(JSON.stringify(run, null, 2));
465
+ else {
466
+ logger.success(`Optimization started [${run.status}]`);
467
+ logger.log(` ${chalk.bold("Run ID:")} ${chalk.cyan(run.runId)}`);
468
+ logger.log(` ${chalk.bold("Objective:")} ${run.objective}`);
469
+ logger.log(` ${chalk.bold("Iterations:")} ${run.iterations}`);
470
+ }
471
+ await shutdown();
472
+ } catch (err) {
473
+ logger.error(`Failed: ${err.message}`);
474
+ process.exit(1);
475
+ }
476
+ });
477
+
478
+ rep
479
+ .command("complete <run-id>")
480
+ .description(
481
+ "Complete a V2 optimization (RUNNING → COMPLETE, runs iterations)",
482
+ )
483
+ .option("--json", "Output as JSON")
484
+ .action(async (runId, options) => {
485
+ try {
486
+ const ctx = await bootstrap({ verbose: program.opts().verbose });
487
+ const db = _dbFromCtx(ctx);
488
+ const result = completeOptimization(db, runId);
489
+ if (options.json) console.log(JSON.stringify(result, null, 2));
490
+ else {
491
+ logger.success(`Completed [${result.status}]`);
492
+ logger.log(` ${chalk.bold("Best score:")} ${result.bestScore}`);
493
+ logger.log(
494
+ ` ${chalk.bold("Best params:")} ${JSON.stringify(result.bestParams)}`,
495
+ );
496
+ }
497
+ await shutdown();
498
+ } catch (err) {
499
+ logger.error(`Failed: ${err.message}`);
500
+ process.exit(1);
501
+ }
502
+ });
503
+
504
+ rep
505
+ .command("cancel <run-id>")
506
+ .description("Cancel a V2 RUNNING optimization")
507
+ .action(async (runId) => {
508
+ try {
509
+ const ctx = await bootstrap({ verbose: program.opts().verbose });
510
+ const db = _dbFromCtx(ctx);
511
+ const result = cancelOptimization(db, runId);
512
+ logger.success(`Cancelled [${result.status}]`);
513
+ await shutdown();
514
+ } catch (err) {
515
+ logger.error(`Failed: ${err.message}`);
516
+ process.exit(1);
517
+ }
518
+ });
519
+
520
+ rep
521
+ .command("fail <run-id>")
522
+ .description("Fail a V2 RUNNING optimization")
523
+ .option("--message <msg>", "Error message")
524
+ .action(async (runId, options) => {
525
+ try {
526
+ const ctx = await bootstrap({ verbose: program.opts().verbose });
527
+ const db = _dbFromCtx(ctx);
528
+ const result = failOptimization(db, runId, options.message);
529
+ logger.success(`Failed [${result.status}]`);
530
+ if (result.errorMessage)
531
+ logger.log(` ${chalk.bold("Error:")} ${result.errorMessage}`);
532
+ await shutdown();
533
+ } catch (err) {
534
+ logger.error(`Failed: ${err.message}`);
535
+ process.exit(1);
536
+ }
537
+ });
538
+
539
+ rep
540
+ .command("apply-v2 <run-id>")
541
+ .description("Apply a V2 COMPLETE optimization (COMPLETE → APPLIED)")
542
+ .action(async (runId) => {
543
+ try {
544
+ const ctx = await bootstrap({ verbose: program.opts().verbose });
545
+ const db = _dbFromCtx(ctx);
546
+ const result = applyOptimization(db, runId);
547
+ logger.success(`Applied [${result.status}]`);
548
+ await shutdown();
549
+ } catch (err) {
550
+ logger.error(`Failed: ${err.message}`);
551
+ process.exit(1);
552
+ }
553
+ });
554
+
555
+ rep
556
+ .command("set-status <run-id> <status>")
557
+ .description("Set V2 run status via the state machine")
558
+ .option("--message <msg>", "Error message (FAILED only)")
559
+ .option("--json", "Output as JSON")
560
+ .action(async (runId, status, options) => {
561
+ try {
562
+ const ctx = await bootstrap({ verbose: program.opts().verbose });
563
+ const db = _dbFromCtx(ctx);
564
+ const patch = options.message ? { errorMessage: options.message } : {};
565
+ const result = setRunStatus(db, runId, status, patch);
566
+ if (options.json) console.log(JSON.stringify(result, null, 2));
567
+ else logger.success(`Status = ${result.status}`);
568
+ await shutdown();
569
+ } catch (err) {
570
+ logger.error(`Failed: ${err.message}`);
571
+ process.exit(1);
572
+ }
573
+ });
574
+
575
+ rep
576
+ .command("stats-v2")
577
+ .description("V2 aggregated stats")
578
+ .option("--json", "Output as JSON")
579
+ .action(async (options) => {
580
+ try {
581
+ const ctx = await bootstrap({ verbose: program.opts().verbose });
582
+ _dbFromCtx(ctx);
583
+ const stats = getReputationStatsV2();
584
+ if (options.json) console.log(JSON.stringify(stats, null, 2));
585
+ else {
586
+ logger.log(` ${chalk.bold("Total runs:")} ${stats.totalRuns}`);
587
+ logger.log(` ${chalk.bold("Active:")} ${stats.activeRuns}`);
588
+ logger.log(
589
+ ` ${chalk.bold("Max concurrent:")} ${stats.maxConcurrentOptimizations}`,
590
+ );
591
+ logger.log(` ${chalk.bold("By status:")}`);
592
+ for (const [k, v] of Object.entries(stats.byStatus))
593
+ logger.log(` ${k.padEnd(12)} ${v}`);
594
+ logger.log(` ${chalk.bold("By objective:")}`);
595
+ for (const [k, v] of Object.entries(stats.byObjective))
596
+ logger.log(` ${k.padEnd(20)} ${v}`);
597
+ logger.log(
598
+ ` ${chalk.bold("Observations:")} ${stats.observations.totalObservations} (${stats.observations.totalDids} DIDs)`,
599
+ );
600
+ logger.log(
601
+ ` ${chalk.bold("Best score ever:")} ${stats.bestScoreEver}`,
602
+ );
603
+ }
604
+ await shutdown();
605
+ } catch (err) {
606
+ logger.error(`Failed: ${err.message}`);
607
+ process.exit(1);
608
+ }
609
+ });
349
610
  }
@@ -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
  }