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
@@ -9,6 +9,11 @@ import {
9
9
  TASK_STATUS,
10
10
  PRIVACY_MODE,
11
11
  DEFAULT_CONFIG,
12
+ NODE_STATUS_V2,
13
+ TASK_STATUS_V2,
14
+ PRIVACY_MODE_V2,
15
+ INFERENCE_DEFAULT_MAX_CONCURRENT_TASKS_PER_NODE,
16
+ INFERENCE_DEFAULT_HEARTBEAT_TIMEOUT_MS,
12
17
  ensureInferenceTables,
13
18
  registerNode,
14
19
  unregisterNode,
@@ -22,6 +27,20 @@ import {
22
27
  getTask,
23
28
  listTasks,
24
29
  getSchedulerStats,
30
+ setMaxConcurrentTasksPerNode,
31
+ getMaxConcurrentTasksPerNode,
32
+ setHeartbeatTimeoutMs,
33
+ getHeartbeatTimeoutMs,
34
+ getActiveTasksPerNode,
35
+ submitTaskV2,
36
+ dispatchTaskV2,
37
+ startTask,
38
+ completeTaskV2,
39
+ failTaskV2,
40
+ setTaskStatus,
41
+ autoMarkOfflineNodes,
42
+ findEligibleNodes,
43
+ getInferenceStatsV2,
25
44
  } from "../lib/inference-network.js";
26
45
 
27
46
  function _dbFromCtx(cmd) {
@@ -300,5 +319,304 @@ export function registerInferenceCommand(program) {
300
319
  if (t.avgDurationMs > 0) console.log(`Avg latency: ${t.avgDurationMs}ms`);
301
320
  });
302
321
 
322
+ /* ──────────────────────────────────────────────────
323
+ * V2 — Phase 67 surface
324
+ * ────────────────────────────────────────────────── */
325
+
326
+ inf
327
+ .command("node-statuses-v2")
328
+ .description("List V2 node statuses")
329
+ .option("--json", "JSON output")
330
+ .action((opts) => {
331
+ const v = Object.values(NODE_STATUS_V2);
332
+ if (opts.json) return console.log(JSON.stringify(v, null, 2));
333
+ for (const s of v) console.log(` ${s}`);
334
+ });
335
+
336
+ inf
337
+ .command("task-statuses-v2")
338
+ .description("List V2 task statuses")
339
+ .option("--json", "JSON output")
340
+ .action((opts) => {
341
+ const v = Object.values(TASK_STATUS_V2);
342
+ if (opts.json) return console.log(JSON.stringify(v, null, 2));
343
+ for (const s of v) console.log(` ${s}`);
344
+ });
345
+
346
+ inf
347
+ .command("privacy-modes-v2")
348
+ .description("List V2 privacy modes")
349
+ .option("--json", "JSON output")
350
+ .action((opts) => {
351
+ const v = Object.values(PRIVACY_MODE_V2);
352
+ if (opts.json) return console.log(JSON.stringify(v, null, 2));
353
+ for (const m of v) console.log(` ${m}`);
354
+ });
355
+
356
+ inf
357
+ .command("default-max-concurrent-tasks")
358
+ .description("Show default per-node concurrent task cap")
359
+ .option("--json", "JSON output")
360
+ .action((opts) => {
361
+ const v = INFERENCE_DEFAULT_MAX_CONCURRENT_TASKS_PER_NODE;
362
+ if (opts.json)
363
+ return console.log(JSON.stringify({ default: v }, null, 2));
364
+ console.log(v);
365
+ });
366
+
367
+ inf
368
+ .command("max-concurrent-tasks")
369
+ .description("Show current per-node concurrent task cap")
370
+ .option("--json", "JSON output")
371
+ .action((opts) => {
372
+ const v = getMaxConcurrentTasksPerNode();
373
+ if (opts.json) return console.log(JSON.stringify({ max: v }, null, 2));
374
+ console.log(v);
375
+ });
376
+
377
+ inf
378
+ .command("set-max-concurrent-tasks <n>")
379
+ .description("Set per-node concurrent task cap")
380
+ .option("--json", "JSON output")
381
+ .action((n, opts) => {
382
+ try {
383
+ setMaxConcurrentTasksPerNode(Number(n));
384
+ const v = getMaxConcurrentTasksPerNode();
385
+ if (opts.json) return console.log(JSON.stringify({ max: v }, null, 2));
386
+ console.log(`Max concurrent tasks per node: ${v}`);
387
+ } catch (e) {
388
+ if (opts.json)
389
+ return console.log(JSON.stringify({ error: e.message }, null, 2));
390
+ console.error(`Error: ${e.message}`);
391
+ process.exitCode = 1;
392
+ }
393
+ });
394
+
395
+ inf
396
+ .command("active-task-count <node-id>")
397
+ .description("Show current active tasks for a node")
398
+ .option("--json", "JSON output")
399
+ .action((nodeId, opts) => {
400
+ const v = getActiveTasksPerNode(nodeId);
401
+ if (opts.json)
402
+ return console.log(JSON.stringify({ nodeId, active: v }, null, 2));
403
+ console.log(v);
404
+ });
405
+
406
+ inf
407
+ .command("heartbeat-timeout")
408
+ .description("Show current heartbeat timeout (ms)")
409
+ .option("--json", "JSON output")
410
+ .action((opts) => {
411
+ const v = getHeartbeatTimeoutMs();
412
+ if (opts.json)
413
+ return console.log(JSON.stringify({ timeoutMs: v }, null, 2));
414
+ console.log(v);
415
+ });
416
+
417
+ inf
418
+ .command("set-heartbeat-timeout <ms>")
419
+ .description("Set heartbeat timeout (ms)")
420
+ .option("--json", "JSON output")
421
+ .action((ms, opts) => {
422
+ try {
423
+ setHeartbeatTimeoutMs(Number(ms));
424
+ const v = getHeartbeatTimeoutMs();
425
+ if (opts.json)
426
+ return console.log(JSON.stringify({ timeoutMs: v }, null, 2));
427
+ console.log(`Heartbeat timeout: ${v}ms`);
428
+ } catch (e) {
429
+ if (opts.json)
430
+ return console.log(JSON.stringify({ error: e.message }, null, 2));
431
+ console.error(`Error: ${e.message}`);
432
+ process.exitCode = 1;
433
+ }
434
+ });
435
+
436
+ inf
437
+ .command("submit-v2 <model>")
438
+ .description("Submit task (V2, creates queued no assignment)")
439
+ .option("-i, --input <text>", "Input data")
440
+ .option("-p, --priority <n>", "Priority (1-10)", parseInt)
441
+ .option("-m, --mode <mode>", "Privacy mode")
442
+ .option("--json", "JSON output")
443
+ .action((model, opts) => {
444
+ const db = _dbFromCtx(inf);
445
+ try {
446
+ const t = submitTaskV2(db, {
447
+ model,
448
+ input: opts.input,
449
+ privacyMode: opts.mode,
450
+ priority: opts.priority,
451
+ });
452
+ if (opts.json) return console.log(JSON.stringify(t, null, 2));
453
+ console.log(`Task submitted: ${t.id}`);
454
+ console.log(`Status: ${t.status}`);
455
+ } catch (e) {
456
+ if (opts.json)
457
+ return console.log(JSON.stringify({ error: e.message }, null, 2));
458
+ console.error(`Error: ${e.message}`);
459
+ process.exitCode = 1;
460
+ }
461
+ });
462
+
463
+ inf
464
+ .command("dispatch-v2 <task-id>")
465
+ .description("Dispatch queued task to online node")
466
+ .option("-n, --node <id>", "Specific node id (else least-loaded)")
467
+ .option("--json", "JSON output")
468
+ .action((taskId, opts) => {
469
+ const db = _dbFromCtx(inf);
470
+ try {
471
+ const t = dispatchTaskV2(db, taskId, { nodeId: opts.node });
472
+ if (opts.json) return console.log(JSON.stringify(t, null, 2));
473
+ console.log(`Dispatched ${t.id} → ${t.assigned_node}`);
474
+ } catch (e) {
475
+ if (opts.json)
476
+ return console.log(JSON.stringify({ error: e.message }, null, 2));
477
+ console.error(`Error: ${e.message}`);
478
+ process.exitCode = 1;
479
+ }
480
+ });
481
+
482
+ inf
483
+ .command("start-task <task-id>")
484
+ .description("Start dispatched task (dispatched → running)")
485
+ .option("--json", "JSON output")
486
+ .action((taskId, opts) => {
487
+ const db = _dbFromCtx(inf);
488
+ try {
489
+ const t = startTask(db, taskId);
490
+ if (opts.json) return console.log(JSON.stringify(t, null, 2));
491
+ console.log(`Task started at ${t.started_at}`);
492
+ } catch (e) {
493
+ if (opts.json)
494
+ return console.log(JSON.stringify({ error: e.message }, null, 2));
495
+ console.error(`Error: ${e.message}`);
496
+ process.exitCode = 1;
497
+ }
498
+ });
499
+
500
+ inf
501
+ .command("complete-v2 <task-id>")
502
+ .description("Complete running task (running → complete)")
503
+ .option("-o, --output <text>", "Task output")
504
+ .option("-d, --duration <ms>", "Duration in ms", parseInt)
505
+ .option("--json", "JSON output")
506
+ .action((taskId, opts) => {
507
+ const db = _dbFromCtx(inf);
508
+ try {
509
+ const t = completeTaskV2(db, taskId, {
510
+ output: opts.output,
511
+ durationMs: opts.duration,
512
+ });
513
+ if (opts.json) return console.log(JSON.stringify(t, null, 2));
514
+ console.log(`Completed ${t.id} (${t.duration_ms}ms)`);
515
+ } catch (e) {
516
+ if (opts.json)
517
+ return console.log(JSON.stringify({ error: e.message }, null, 2));
518
+ console.error(`Error: ${e.message}`);
519
+ process.exitCode = 1;
520
+ }
521
+ });
522
+
523
+ inf
524
+ .command("fail-v2 <task-id>")
525
+ .description("Fail task (any non-terminal → failed)")
526
+ .option("-e, --error <text>", "Error message")
527
+ .option("--json", "JSON output")
528
+ .action((taskId, opts) => {
529
+ const db = _dbFromCtx(inf);
530
+ try {
531
+ const t = failTaskV2(db, taskId, { error: opts.error });
532
+ if (opts.json) return console.log(JSON.stringify(t, null, 2));
533
+ console.log(`Failed ${t.id}: ${t.error_message || ""}`);
534
+ } catch (e) {
535
+ if (opts.json)
536
+ return console.log(JSON.stringify({ error: e.message }, null, 2));
537
+ console.error(`Error: ${e.message}`);
538
+ process.exitCode = 1;
539
+ }
540
+ });
541
+
542
+ inf
543
+ .command("set-task-status <task-id> <status>")
544
+ .description("Generic state-machine-guarded task status setter")
545
+ .option("-o, --output <text>", "Patch: output")
546
+ .option("-d, --duration <ms>", "Patch: durationMs", parseInt)
547
+ .option("-e, --error <text>", "Patch: errorMessage")
548
+ .option("--json", "JSON output")
549
+ .action((taskId, status, opts) => {
550
+ const db = _dbFromCtx(inf);
551
+ const patch = {};
552
+ if (opts.output !== undefined) patch.output = opts.output;
553
+ if (opts.duration !== undefined) patch.durationMs = opts.duration;
554
+ if (opts.error !== undefined) patch.errorMessage = opts.error;
555
+ try {
556
+ const t = setTaskStatus(db, taskId, status, patch);
557
+ if (opts.json) return console.log(JSON.stringify(t, null, 2));
558
+ console.log(`Task ${t.id} → ${t.status}`);
559
+ } catch (e) {
560
+ if (opts.json)
561
+ return console.log(JSON.stringify({ error: e.message }, null, 2));
562
+ console.error(`Error: ${e.message}`);
563
+ process.exitCode = 1;
564
+ }
565
+ });
566
+
567
+ inf
568
+ .command("auto-offline")
569
+ .description("Mark nodes with stale heartbeat as offline")
570
+ .option("--json", "JSON output")
571
+ .action((opts) => {
572
+ const db = _dbFromCtx(inf);
573
+ const offlined = autoMarkOfflineNodes(db);
574
+ if (opts.json) return console.log(JSON.stringify(offlined, null, 2));
575
+ if (offlined.length === 0) return console.log("No stale nodes.");
576
+ for (const n of offlined)
577
+ console.log(` ${n.node_id.padEnd(20)} → offline`);
578
+ });
579
+
580
+ inf
581
+ .command("eligible-nodes")
582
+ .description("List online, under-cap nodes matching capability")
583
+ .option("-c, --capability <cap>", "Required capability")
584
+ .option("-m, --mode <mode>", "Privacy mode (reserved)")
585
+ .option("--json", "JSON output")
586
+ .action((opts) => {
587
+ const nodes = findEligibleNodes({
588
+ capability: opts.capability,
589
+ privacyMode: opts.mode,
590
+ });
591
+ if (opts.json) return console.log(JSON.stringify(nodes, null, 2));
592
+ if (nodes.length === 0) return console.log("No eligible nodes.");
593
+ for (const n of nodes)
594
+ console.log(
595
+ ` ${n.node_id.padEnd(20)} load=${getActiveTasksPerNode(n.id)} ${n.id.slice(0, 8)}`,
596
+ );
597
+ });
598
+
599
+ inf
600
+ .command("stats-v2")
601
+ .description("V2 inference statistics (all-enum-key zero init)")
602
+ .option("--json", "JSON output")
603
+ .action((opts) => {
604
+ const s = getInferenceStatsV2();
605
+ if (opts.json) return console.log(JSON.stringify(s, null, 2));
606
+ console.log(`Nodes: ${s.totalNodes} Tasks: ${s.totalTasks}`);
607
+ console.log(`Max concurrent/node: ${s.maxConcurrentTasksPerNode}`);
608
+ console.log(`Heartbeat timeout: ${s.heartbeatTimeoutMs}ms`);
609
+ console.log(`Avg duration: ${s.avgDurationMs}ms`);
610
+ console.log("Nodes by status:");
611
+ for (const [k, v] of Object.entries(s.nodesByStatus))
612
+ console.log(` ${k.padEnd(12)} ${v}`);
613
+ console.log("Tasks by status:");
614
+ for (const [k, v] of Object.entries(s.tasksByStatus))
615
+ console.log(` ${k.padEnd(12)} ${v}`);
616
+ console.log("Tasks by privacy:");
617
+ for (const [k, v] of Object.entries(s.tasksByPrivacyMode))
618
+ console.log(` ${k.padEnd(12)} ${v}`);
619
+ });
620
+
303
621
  program.addCommand(inf);
304
622
  }
@@ -25,8 +25,53 @@ import {
25
25
  listRoutes,
26
26
  getConnectivityReport,
27
27
  getInfraStats,
28
+
29
+ // Phase 74-75 V2
30
+ PROVIDER_MATURITY_V2,
31
+ DEAL_LIFECYCLE_V2,
32
+ getDefaultMaxActiveProvidersPerOperatorV2,
33
+ getMaxActiveProvidersPerOperatorV2,
34
+ setMaxActiveProvidersPerOperatorV2,
35
+ getDefaultMaxActiveDealsPerProviderV2,
36
+ getMaxActiveDealsPerProviderV2,
37
+ setMaxActiveDealsPerProviderV2,
38
+ getDefaultProviderIdleMsV2,
39
+ getProviderIdleMsV2,
40
+ setProviderIdleMsV2,
41
+ getDefaultDealStuckMsV2,
42
+ getDealStuckMsV2,
43
+ setDealStuckMsV2,
44
+ registerProviderV2,
45
+ getProviderV2,
46
+ setProviderMaturityV2,
47
+ activateProvider,
48
+ degradeProvider,
49
+ offlineProvider,
50
+ retireProvider,
51
+ touchProviderHeartbeat,
52
+ enqueueDealV2,
53
+ getDealV2,
54
+ setDealStatusV2,
55
+ activateDeal,
56
+ completeDeal,
57
+ failDeal,
58
+ cancelDeal,
59
+ getActiveProviderCount,
60
+ getActiveDealCount,
61
+ autoOfflineStaleProviders,
62
+ autoFailStuckActiveDeals,
63
+ getDecentralInfraStatsV2,
28
64
  } from "../lib/decentral-infra.js";
29
65
 
66
+ function _parseMetaV2(raw) {
67
+ if (!raw) return undefined;
68
+ try {
69
+ return JSON.parse(raw);
70
+ } catch {
71
+ throw new Error("--metadata must be valid JSON");
72
+ }
73
+ }
74
+
30
75
  function _dbFromCtx(cmd) {
31
76
  const root = cmd?.parent?.parent ?? cmd?.parent;
32
77
  return root?._db;
@@ -357,5 +402,204 @@ export function registerInfraCommand(program) {
357
402
  );
358
403
  });
359
404
 
405
+ /* ═══════════════════════════════════════════════════ *
406
+ * Phase 74-75 V2
407
+ * ═══════════════════════════════════════════════════ */
408
+
409
+ inf
410
+ .command("provider-maturities-v2")
411
+ .description("List V2 provider maturity states")
412
+ .option("--json", "JSON")
413
+ .action((opts) => {
414
+ const xs = Object.values(PROVIDER_MATURITY_V2);
415
+ if (opts.json) return console.log(JSON.stringify(xs, null, 2));
416
+ for (const x of xs) console.log(` ${x}`);
417
+ });
418
+
419
+ inf
420
+ .command("deal-lifecycles-v2")
421
+ .description("List V2 deal lifecycle states")
422
+ .option("--json", "JSON")
423
+ .action((opts) => {
424
+ const xs = Object.values(DEAL_LIFECYCLE_V2);
425
+ if (opts.json) return console.log(JSON.stringify(xs, null, 2));
426
+ for (const x of xs) console.log(` ${x}`);
427
+ });
428
+
429
+ inf
430
+ .command("default-max-active-providers-per-operator")
431
+ .action(() => console.log(getDefaultMaxActiveProvidersPerOperatorV2()));
432
+ inf
433
+ .command("max-active-providers-per-operator")
434
+ .action(() => console.log(getMaxActiveProvidersPerOperatorV2()));
435
+ inf
436
+ .command("set-max-active-providers-per-operator <n>")
437
+ .action((n) => console.log(setMaxActiveProvidersPerOperatorV2(n)));
438
+
439
+ inf
440
+ .command("default-max-active-deals-per-provider")
441
+ .action(() => console.log(getDefaultMaxActiveDealsPerProviderV2()));
442
+ inf
443
+ .command("max-active-deals-per-provider")
444
+ .action(() => console.log(getMaxActiveDealsPerProviderV2()));
445
+ inf
446
+ .command("set-max-active-deals-per-provider <n>")
447
+ .action((n) => console.log(setMaxActiveDealsPerProviderV2(n)));
448
+
449
+ inf
450
+ .command("default-provider-idle-ms")
451
+ .action(() => console.log(getDefaultProviderIdleMsV2()));
452
+ inf
453
+ .command("provider-idle-ms")
454
+ .action(() => console.log(getProviderIdleMsV2()));
455
+ inf
456
+ .command("set-provider-idle-ms <ms>")
457
+ .action((ms) => console.log(setProviderIdleMsV2(ms)));
458
+
459
+ inf
460
+ .command("default-deal-stuck-ms")
461
+ .action(() => console.log(getDefaultDealStuckMsV2()));
462
+ inf.command("deal-stuck-ms").action(() => console.log(getDealStuckMsV2()));
463
+ inf
464
+ .command("set-deal-stuck-ms <ms>")
465
+ .action((ms) => console.log(setDealStuckMsV2(ms)));
466
+
467
+ inf
468
+ .command("active-provider-count")
469
+ .option("-o, --operator <id>")
470
+ .action((opts) => console.log(getActiveProviderCount(opts.operator)));
471
+ inf
472
+ .command("active-deal-count")
473
+ .option("-p, --provider <id>")
474
+ .action((opts) => console.log(getActiveDealCount(opts.provider)));
475
+
476
+ inf
477
+ .command("register-provider-v2 <provider-id>")
478
+ .requiredOption("-o, --operator <id>")
479
+ .requiredOption("-k, --kind <kind>")
480
+ .option("-i, --initial-status <s>")
481
+ .option("--metadata <json>")
482
+ .action((id, opts) => {
483
+ const r = registerProviderV2(null, {
484
+ providerId: id,
485
+ operatorId: opts.operator,
486
+ kind: opts.kind,
487
+ initialStatus: opts.initialStatus,
488
+ metadata: _parseMetaV2(opts.metadata),
489
+ });
490
+ console.log(JSON.stringify(r, null, 2));
491
+ });
492
+
493
+ inf.command("provider-v2 <provider-id>").action((id) => {
494
+ const r = getProviderV2(id);
495
+ if (!r) {
496
+ console.error(`Unknown provider: ${id}`);
497
+ process.exitCode = 1;
498
+ return;
499
+ }
500
+ console.log(JSON.stringify(r, null, 2));
501
+ });
502
+
503
+ inf
504
+ .command("set-provider-maturity-v2 <provider-id> <status>")
505
+ .option("-r, --reason <text>")
506
+ .option("--metadata <json>")
507
+ .action((id, status, opts) => {
508
+ const r = setProviderMaturityV2(null, id, status, {
509
+ reason: opts.reason,
510
+ metadata: _parseMetaV2(opts.metadata),
511
+ });
512
+ console.log(JSON.stringify(r, null, 2));
513
+ });
514
+
515
+ for (const [name, fn] of [
516
+ ["activate-provider", activateProvider],
517
+ ["degrade-provider", degradeProvider],
518
+ ["offline-provider", offlineProvider],
519
+ ["retire-provider", retireProvider],
520
+ ]) {
521
+ inf
522
+ .command(`${name} <provider-id>`)
523
+ .option("-r, --reason <text>")
524
+ .action((id, opts) => {
525
+ const r = fn(null, id, opts.reason);
526
+ console.log(JSON.stringify(r, null, 2));
527
+ });
528
+ }
529
+
530
+ inf
531
+ .command("touch-provider-heartbeat <provider-id>")
532
+ .action((id) =>
533
+ console.log(JSON.stringify(touchProviderHeartbeat(id), null, 2)),
534
+ );
535
+
536
+ inf
537
+ .command("enqueue-deal-v2 <deal-id>")
538
+ .requiredOption("-p, --provider <id>")
539
+ .requiredOption("-o, --owner <id>")
540
+ .option("--metadata <json>")
541
+ .action((id, opts) => {
542
+ const r = enqueueDealV2(null, {
543
+ dealId: id,
544
+ providerId: opts.provider,
545
+ ownerId: opts.owner,
546
+ metadata: _parseMetaV2(opts.metadata),
547
+ });
548
+ console.log(JSON.stringify(r, null, 2));
549
+ });
550
+
551
+ inf.command("deal-v2 <deal-id>").action((id) => {
552
+ const r = getDealV2(id);
553
+ if (!r) {
554
+ console.error(`Unknown deal: ${id}`);
555
+ process.exitCode = 1;
556
+ return;
557
+ }
558
+ console.log(JSON.stringify(r, null, 2));
559
+ });
560
+
561
+ inf
562
+ .command("set-deal-status-v2 <deal-id> <status>")
563
+ .option("-r, --reason <text>")
564
+ .option("--metadata <json>")
565
+ .action((id, status, opts) => {
566
+ const r = setDealStatusV2(null, id, status, {
567
+ reason: opts.reason,
568
+ metadata: _parseMetaV2(opts.metadata),
569
+ });
570
+ console.log(JSON.stringify(r, null, 2));
571
+ });
572
+
573
+ for (const [name, fn] of [
574
+ ["activate-deal", activateDeal],
575
+ ["complete-deal", completeDeal],
576
+ ["fail-deal", failDeal],
577
+ ["cancel-deal", cancelDeal],
578
+ ]) {
579
+ inf
580
+ .command(`${name} <deal-id>`)
581
+ .option("-r, --reason <text>")
582
+ .action((id, opts) => {
583
+ const r = fn(null, id, opts.reason);
584
+ console.log(JSON.stringify(r, null, 2));
585
+ });
586
+ }
587
+
588
+ inf
589
+ .command("auto-offline-stale-providers")
590
+ .action(() =>
591
+ console.log(JSON.stringify(autoOfflineStaleProviders(null), null, 2)),
592
+ );
593
+ inf
594
+ .command("auto-fail-stuck-active-deals")
595
+ .action(() =>
596
+ console.log(JSON.stringify(autoFailStuckActiveDeals(null), null, 2)),
597
+ );
598
+ inf
599
+ .command("stats-v2")
600
+ .action(() =>
601
+ console.log(JSON.stringify(getDecentralInfraStatsV2(), null, 2)),
602
+ );
603
+
360
604
  program.addCommand(inf);
361
605
  }