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
@@ -1181,4 +1181,225 @@ export function registerCoworkCommand(program) {
1181
1181
  );
1182
1182
  logger.log("");
1183
1183
  });
1184
+
1185
+ // ===== V2 governance subcommands (agent-coordinator V2) =====
1186
+ cowork
1187
+ .command("coord-agent-maturities-v2")
1188
+ .description("List coord agent maturity states (V2)")
1189
+ .action(async () => {
1190
+ const m = await import("../lib/agent-coordinator.js");
1191
+ console.log(JSON.stringify(m.COORD_AGENT_MATURITY_V2, null, 2));
1192
+ });
1193
+ cowork
1194
+ .command("coord-assignment-lifecycle-v2")
1195
+ .description("List coord assignment lifecycle states (V2)")
1196
+ .action(async () => {
1197
+ const m = await import("../lib/agent-coordinator.js");
1198
+ console.log(JSON.stringify(m.COORD_ASSIGNMENT_LIFECYCLE_V2, null, 2));
1199
+ });
1200
+ cowork
1201
+ .command("coord-stats-v2")
1202
+ .description("Show agent-coordinator V2 stats")
1203
+ .action(async () => {
1204
+ const m = await import("../lib/agent-coordinator.js");
1205
+ console.log(JSON.stringify(m.getAgentCoordinatorStatsV2(), null, 2));
1206
+ });
1207
+ cowork
1208
+ .command("coord-config-v2")
1209
+ .description("Show agent-coordinator V2 config")
1210
+ .action(async () => {
1211
+ const m = await import("../lib/agent-coordinator.js");
1212
+ console.log(
1213
+ JSON.stringify(
1214
+ {
1215
+ maxActiveAgentsPerOwner: m.getMaxActiveAgentsPerOwnerCoordV2(),
1216
+ maxPendingAssignmentsPerAgent:
1217
+ m.getMaxPendingAssignmentsPerAgentV2(),
1218
+ agentIdleMs: m.getAgentIdleMsCoordV2(),
1219
+ assignmentStuckMs: m.getAssignmentStuckMsV2(),
1220
+ },
1221
+ null,
1222
+ 2,
1223
+ ),
1224
+ );
1225
+ });
1226
+ cowork
1227
+ .command("coord-register-agent-v2 <id> <owner>")
1228
+ .description("Register a coord agent (V2)")
1229
+ .action(async (id, owner) => {
1230
+ const m = await import("../lib/agent-coordinator.js");
1231
+ console.log(
1232
+ JSON.stringify(m.registerCoordAgentV2({ id, owner }), null, 2),
1233
+ );
1234
+ });
1235
+ cowork
1236
+ .command("coord-activate-agent-v2 <id>")
1237
+ .description("Activate a coord agent (V2)")
1238
+ .action(async (id) => {
1239
+ const m = await import("../lib/agent-coordinator.js");
1240
+ console.log(JSON.stringify(m.activateCoordAgentV2(id), null, 2));
1241
+ });
1242
+ cowork
1243
+ .command("coord-idle-agent-v2 <id>")
1244
+ .description("Mark coord agent as idle (V2)")
1245
+ .action(async (id) => {
1246
+ const m = await import("../lib/agent-coordinator.js");
1247
+ console.log(JSON.stringify(m.idleCoordAgentV2(id), null, 2));
1248
+ });
1249
+ cowork
1250
+ .command("coord-retire-agent-v2 <id>")
1251
+ .description("Retire a coord agent (V2)")
1252
+ .action(async (id) => {
1253
+ const m = await import("../lib/agent-coordinator.js");
1254
+ console.log(JSON.stringify(m.retireCoordAgentV2(id), null, 2));
1255
+ });
1256
+ cowork
1257
+ .command("coord-touch-agent-v2 <id>")
1258
+ .description("Touch a coord agent (V2)")
1259
+ .action(async (id) => {
1260
+ const m = await import("../lib/agent-coordinator.js");
1261
+ console.log(JSON.stringify(m.touchCoordAgentV2(id), null, 2));
1262
+ });
1263
+ cowork
1264
+ .command("coord-get-agent-v2 <id>")
1265
+ .description("Get a coord agent (V2)")
1266
+ .action(async (id) => {
1267
+ const m = await import("../lib/agent-coordinator.js");
1268
+ console.log(JSON.stringify(m.getCoordAgentV2(id), null, 2));
1269
+ });
1270
+ cowork
1271
+ .command("coord-list-agents-v2")
1272
+ .description("List coord agents (V2)")
1273
+ .action(async () => {
1274
+ const m = await import("../lib/agent-coordinator.js");
1275
+ console.log(JSON.stringify(m.listCoordAgentsV2(), null, 2));
1276
+ });
1277
+ cowork
1278
+ .command("coord-create-assignment-v2 <id> <agentId>")
1279
+ .description("Create a coord assignment (V2)")
1280
+ .action(async (id, agentId) => {
1281
+ const m = await import("../lib/agent-coordinator.js");
1282
+ console.log(
1283
+ JSON.stringify(m.createAssignmentV2({ id, agentId }), null, 2),
1284
+ );
1285
+ });
1286
+ cowork
1287
+ .command("coord-dispatch-assignment-v2 <id>")
1288
+ .description("Dispatch a coord assignment (V2)")
1289
+ .action(async (id) => {
1290
+ const m = await import("../lib/agent-coordinator.js");
1291
+ console.log(JSON.stringify(m.dispatchAssignmentV2(id), null, 2));
1292
+ });
1293
+ cowork
1294
+ .command("coord-complete-assignment-v2 <id>")
1295
+ .description("Complete a coord assignment (V2)")
1296
+ .action(async (id) => {
1297
+ const m = await import("../lib/agent-coordinator.js");
1298
+ console.log(JSON.stringify(m.completeAssignmentV2(id), null, 2));
1299
+ });
1300
+ cowork
1301
+ .command("coord-fail-assignment-v2 <id> [reason]")
1302
+ .description("Fail a coord assignment (V2)")
1303
+ .action(async (id, reason) => {
1304
+ const m = await import("../lib/agent-coordinator.js");
1305
+ console.log(JSON.stringify(m.failAssignmentV2(id, reason), null, 2));
1306
+ });
1307
+ cowork
1308
+ .command("coord-cancel-assignment-v2 <id> [reason]")
1309
+ .description("Cancel a coord assignment (V2)")
1310
+ .action(async (id, reason) => {
1311
+ const m = await import("../lib/agent-coordinator.js");
1312
+ console.log(JSON.stringify(m.cancelAssignmentV2(id, reason), null, 2));
1313
+ });
1314
+ cowork
1315
+ .command("coord-get-assignment-v2 <id>")
1316
+ .description("Get a coord assignment (V2)")
1317
+ .action(async (id) => {
1318
+ const m = await import("../lib/agent-coordinator.js");
1319
+ console.log(JSON.stringify(m.getAssignmentV2(id), null, 2));
1320
+ });
1321
+ cowork
1322
+ .command("coord-list-assignments-v2")
1323
+ .description("List coord assignments (V2)")
1324
+ .action(async () => {
1325
+ const m = await import("../lib/agent-coordinator.js");
1326
+ console.log(JSON.stringify(m.listAssignmentsV2(), null, 2));
1327
+ });
1328
+ cowork
1329
+ .command("coord-auto-idle-agents-v2")
1330
+ .description("Auto-idle coord agents (V2)")
1331
+ .action(async () => {
1332
+ const m = await import("../lib/agent-coordinator.js");
1333
+ console.log(JSON.stringify(m.autoIdleCoordAgentsV2(), null, 2));
1334
+ });
1335
+ cowork
1336
+ .command("coord-auto-fail-stuck-assignments-v2")
1337
+ .description("Auto-fail stuck coord assignments (V2)")
1338
+ .action(async () => {
1339
+ const m = await import("../lib/agent-coordinator.js");
1340
+ console.log(JSON.stringify(m.autoFailStuckAssignmentsV2(), null, 2));
1341
+ });
1342
+ cowork
1343
+ .command("coord-set-max-active-agents-v2 <n>")
1344
+ .description("Set max active coord agents per owner (V2)")
1345
+ .action(async (n) => {
1346
+ const m = await import("../lib/agent-coordinator.js");
1347
+ m.setMaxActiveAgentsPerOwnerCoordV2(parseInt(n, 10));
1348
+ console.log(
1349
+ JSON.stringify(
1350
+ { maxActiveAgentsPerOwner: m.getMaxActiveAgentsPerOwnerCoordV2() },
1351
+ null,
1352
+ 2,
1353
+ ),
1354
+ );
1355
+ });
1356
+ cowork
1357
+ .command("coord-set-max-pending-assignments-v2 <n>")
1358
+ .description("Set max pending coord assignments per agent (V2)")
1359
+ .action(async (n) => {
1360
+ const m = await import("../lib/agent-coordinator.js");
1361
+ m.setMaxPendingAssignmentsPerAgentV2(parseInt(n, 10));
1362
+ console.log(
1363
+ JSON.stringify(
1364
+ {
1365
+ maxPendingAssignmentsPerAgent:
1366
+ m.getMaxPendingAssignmentsPerAgentV2(),
1367
+ },
1368
+ null,
1369
+ 2,
1370
+ ),
1371
+ );
1372
+ });
1373
+ cowork
1374
+ .command("coord-set-agent-idle-ms-v2 <n>")
1375
+ .description("Set coord agent idle timeout ms (V2)")
1376
+ .action(async (n) => {
1377
+ const m = await import("../lib/agent-coordinator.js");
1378
+ m.setAgentIdleMsCoordV2(parseInt(n, 10));
1379
+ console.log(
1380
+ JSON.stringify({ agentIdleMs: m.getAgentIdleMsCoordV2() }, null, 2),
1381
+ );
1382
+ });
1383
+ cowork
1384
+ .command("coord-set-assignment-stuck-ms-v2 <n>")
1385
+ .description("Set coord assignment stuck timeout ms (V2)")
1386
+ .action(async (n) => {
1387
+ const m = await import("../lib/agent-coordinator.js");
1388
+ m.setAssignmentStuckMsV2(parseInt(n, 10));
1389
+ console.log(
1390
+ JSON.stringify(
1391
+ { assignmentStuckMs: m.getAssignmentStuckMsV2() },
1392
+ null,
1393
+ 2,
1394
+ ),
1395
+ );
1396
+ });
1397
+ cowork
1398
+ .command("coord-reset-state-v2")
1399
+ .description("Reset agent-coordinator V2 in-memory state")
1400
+ .action(async () => {
1401
+ const m = await import("../lib/agent-coordinator.js");
1402
+ m._resetStateAgentCoordinatorV2();
1403
+ console.log(JSON.stringify({ ok: true }, null, 2));
1404
+ });
1184
1405
  }
@@ -27,6 +27,24 @@ import {
27
27
  listMessages,
28
28
  estimateFee,
29
29
  getCrossChainStats,
30
+ // V2
31
+ BRIDGE_STATUS_V2,
32
+ SWAP_STATUS_V2,
33
+ MESSAGE_STATUS_V2,
34
+ CHAIN_ID_V2,
35
+ CROSSCHAIN_DEFAULT_MAX_ACTIVE_BRIDGES_PER_ADDRESS,
36
+ setMaxActiveBridgesPerAddress,
37
+ getMaxActiveBridgesPerAddress,
38
+ getActiveBridgeCount,
39
+ configureChainV2,
40
+ getChainConfigV2,
41
+ listChainsV2,
42
+ bridgeAssetV2,
43
+ setBridgeStatusV2,
44
+ setSwapStatusV2,
45
+ setMessageStatusV2,
46
+ autoExpireSwapsV2,
47
+ getCrossChainStatsV2,
30
48
  } from "../lib/cross-chain.js";
31
49
 
32
50
  function _dbFromCtx(cmd) {
@@ -378,5 +396,205 @@ export function registerCrossChainCommand(program) {
378
396
  console.log(`Messages: ${stats.messages.total}`);
379
397
  });
380
398
 
399
+ /* ══════════════════════════════════════════════════
400
+ * Phase 89 — Cross-Chain V2 subcommands
401
+ * ══════════════════════════════════════════════════ */
402
+
403
+ cc.command("bridge-statuses-v2")
404
+ .description("List V2 bridge statuses")
405
+ .option("--json", "JSON output")
406
+ .action((opts) => {
407
+ const values = Object.values(BRIDGE_STATUS_V2);
408
+ if (opts.json) return console.log(JSON.stringify(values, null, 2));
409
+ for (const v of values) console.log(` ${v}`);
410
+ });
411
+
412
+ cc.command("swap-statuses-v2")
413
+ .description("List V2 swap statuses")
414
+ .option("--json", "JSON output")
415
+ .action((opts) => {
416
+ const values = Object.values(SWAP_STATUS_V2);
417
+ if (opts.json) return console.log(JSON.stringify(values, null, 2));
418
+ for (const v of values) console.log(` ${v}`);
419
+ });
420
+
421
+ cc.command("message-statuses-v2")
422
+ .description("List V2 message statuses")
423
+ .option("--json", "JSON output")
424
+ .action((opts) => {
425
+ const values = Object.values(MESSAGE_STATUS_V2);
426
+ if (opts.json) return console.log(JSON.stringify(values, null, 2));
427
+ for (const v of values) console.log(` ${v}`);
428
+ });
429
+
430
+ cc.command("chain-ids-v2")
431
+ .description("List V2 chain IDs")
432
+ .option("--json", "JSON output")
433
+ .action((opts) => {
434
+ const values = Object.values(CHAIN_ID_V2);
435
+ if (opts.json) return console.log(JSON.stringify(values, null, 2));
436
+ for (const v of values) console.log(` ${v}`);
437
+ });
438
+
439
+ cc.command("default-max-active-bridges")
440
+ .description("Show default max active bridges per address")
441
+ .action(() => {
442
+ console.log(` ${CROSSCHAIN_DEFAULT_MAX_ACTIVE_BRIDGES_PER_ADDRESS}`);
443
+ });
444
+
445
+ cc.command("max-active-bridges")
446
+ .description("Show current max active bridges per address")
447
+ .action(() => {
448
+ console.log(` ${getMaxActiveBridgesPerAddress()}`);
449
+ });
450
+
451
+ cc.command("active-bridge-count [address]")
452
+ .description("Active (non-terminal) bridge count, optionally by address")
453
+ .action((address) => {
454
+ console.log(` ${getActiveBridgeCount(address)}`);
455
+ });
456
+
457
+ cc.command("set-max-active-bridges <n>")
458
+ .description("Set max active bridges per address (positive integer)")
459
+ .action((n) => {
460
+ setMaxActiveBridgesPerAddress(parseFloat(n));
461
+ console.log(
462
+ ` Max active bridges per address = ${getMaxActiveBridgesPerAddress()}`,
463
+ );
464
+ });
465
+
466
+ cc.command("configure-chain <chain-id>")
467
+ .description("Configure a supported chain (rpcUrl, contract, enabled)")
468
+ .option("--rpc-url <url>", "RPC URL")
469
+ .option("--contract <addr>", "Contract address")
470
+ .option("--disabled", "Set enabled=false")
471
+ .option("--json", "JSON output")
472
+ .action((chainId, opts) => {
473
+ const cfg = configureChainV2({
474
+ chainId,
475
+ rpcUrl: opts.rpcUrl,
476
+ contractAddress: opts.contract,
477
+ enabled: !opts.disabled,
478
+ });
479
+ if (opts.json) return console.log(JSON.stringify(cfg, null, 2));
480
+ console.log(` Configured ${cfg.chainId} (enabled=${cfg.enabled})`);
481
+ });
482
+
483
+ cc.command("chain-config <chain-id>")
484
+ .description("Show chain config (or 'not configured')")
485
+ .option("--json", "JSON output")
486
+ .action((chainId, opts) => {
487
+ const cfg = getChainConfigV2(chainId);
488
+ if (opts.json) return console.log(JSON.stringify(cfg, null, 2));
489
+ if (!cfg) return console.log(" not configured");
490
+ console.log(
491
+ ` ${cfg.chainId} enabled=${cfg.enabled} rpc=${cfg.rpcUrl ?? "-"} contract=${cfg.contractAddress ?? "-"}`,
492
+ );
493
+ });
494
+
495
+ cc.command("list-chains-v2")
496
+ .description("List chains enriched with V2 config")
497
+ .option("--json", "JSON output")
498
+ .action((opts) => {
499
+ const chains = listChainsV2();
500
+ if (opts.json) return console.log(JSON.stringify(chains, null, 2));
501
+ for (const c of chains) {
502
+ console.log(
503
+ ` ${c.id.padEnd(12)} ${c.symbol.padEnd(6)} enabled=${c.enabled} rpc=${c.rpcUrl ?? "-"}`,
504
+ );
505
+ }
506
+ });
507
+
508
+ cc.command("bridge-v2 <from-chain> <to-chain> <amount>")
509
+ .description(
510
+ "Create a bridge (V2: throws on error, enforces per-address cap)",
511
+ )
512
+ .option("--asset <name>", "Asset symbol", "native")
513
+ .option("--sender <addr>", "Sender address")
514
+ .option("--recipient <addr>", "Recipient address")
515
+ .option("--json", "JSON output")
516
+ .action((fromChain, toChain, amount, opts) => {
517
+ const r = bridgeAssetV2(_dbFromCtx(cc), {
518
+ fromChain,
519
+ toChain,
520
+ asset: opts.asset,
521
+ amount: parseFloat(amount),
522
+ senderAddress: opts.sender,
523
+ recipientAddress: opts.recipient,
524
+ });
525
+ if (opts.json) return console.log(JSON.stringify(r, null, 2));
526
+ console.log(` Bridge created: ${r.bridgeId} fee=${r.fee}`);
527
+ });
528
+
529
+ cc.command("set-bridge-status <bridge-id> <status>")
530
+ .description("Set bridge status with state-machine guard")
531
+ .option("--lock-tx <hash>", "Lock tx hash")
532
+ .option("--mint-tx <hash>", "Mint tx hash")
533
+ .option("--message <msg>", "Error message")
534
+ .option("--json", "JSON output")
535
+ .action((bridgeId, status, opts) => {
536
+ const b = setBridgeStatusV2(_dbFromCtx(cc), bridgeId, status, {
537
+ lockTxHash: opts.lockTx,
538
+ mintTxHash: opts.mintTx,
539
+ errorMessage: opts.message,
540
+ });
541
+ if (opts.json) return console.log(JSON.stringify(b, null, 2));
542
+ console.log(` ${b.id} ${b.status}`);
543
+ });
544
+
545
+ cc.command("set-swap-status <swap-id> <status>")
546
+ .description("Set swap status with state-machine guard")
547
+ .option("--claim-tx <hash>", "Claim tx hash")
548
+ .option("--refund-tx <hash>", "Refund tx hash")
549
+ .option("--json", "JSON output")
550
+ .action((swapId, status, opts) => {
551
+ const s = setSwapStatusV2(_dbFromCtx(cc), swapId, status, {
552
+ claimTxHash: opts.claimTx,
553
+ refundTxHash: opts.refundTx,
554
+ });
555
+ if (opts.json) return console.log(JSON.stringify(s, null, 2));
556
+ console.log(` ${s.id} ${s.status}`);
557
+ });
558
+
559
+ cc.command("set-message-status <message-id> <status>")
560
+ .description("Set message status with state-machine guard")
561
+ .option("--source-tx <hash>", "Source tx hash")
562
+ .option("--dest-tx <hash>", "Destination tx hash")
563
+ .option("--json", "JSON output")
564
+ .action((messageId, status, opts) => {
565
+ const m = setMessageStatusV2(_dbFromCtx(cc), messageId, status, {
566
+ sourceTxHash: opts.sourceTx,
567
+ destinationTxHash: opts.destTx,
568
+ });
569
+ if (opts.json) return console.log(JSON.stringify(m, null, 2));
570
+ console.log(` ${m.id} ${m.status} retries=${m.retries}`);
571
+ });
572
+
573
+ cc.command("auto-expire-swaps")
574
+ .description("Bulk-flip past-deadline swaps to EXPIRED")
575
+ .option("--json", "JSON output")
576
+ .action((opts) => {
577
+ const expired = autoExpireSwapsV2(_dbFromCtx(cc));
578
+ if (opts.json) return console.log(JSON.stringify(expired, null, 2));
579
+ console.log(` Expired ${expired.length} swap(s)`);
580
+ });
581
+
582
+ cc.command("stats-v2")
583
+ .description("V2 cross-chain statistics (all-enum-key)")
584
+ .option("--json", "JSON output")
585
+ .action((opts) => {
586
+ const s = getCrossChainStatsV2();
587
+ if (opts.json) return console.log(JSON.stringify(s, null, 2));
588
+ console.log(
589
+ ` Bridges: ${s.totalBridges} (active ${s.activeBridges}, volume ${s.totalBridgeVolume}, fees ${s.totalFees})`,
590
+ );
591
+ console.log(` Swaps: ${s.totalSwaps}`);
592
+ console.log(` Messages: ${s.totalMessages}`);
593
+ console.log(` Configured chains: ${s.configuredChains}`);
594
+ console.log(
595
+ ` Max active bridges / addr: ${s.maxActiveBridgesPerAddress}`,
596
+ );
597
+ });
598
+
381
599
  program.addCommand(cc);
382
600
  }