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
@@ -13,6 +13,37 @@ import {
13
13
  importMarkdownDir,
14
14
  importEnexFile,
15
15
  importNotionDir,
16
+ SOURCE_MATURITY_V2,
17
+ IMPORT_JOB_LIFECYCLE_V2,
18
+ getMaxActiveSourcesPerOwnerV2,
19
+ setMaxActiveSourcesPerOwnerV2,
20
+ getMaxPendingJobsPerSourceV2,
21
+ setMaxPendingJobsPerSourceV2,
22
+ getSourceIdleMsV2,
23
+ setSourceIdleMsV2,
24
+ getJobStuckMsV2,
25
+ setJobStuckMsV2,
26
+ registerSourceV2,
27
+ getSourceV2,
28
+ listSourcesV2,
29
+ setSourceStatusV2,
30
+ activateSourceV2,
31
+ pauseSourceV2,
32
+ archiveSourceV2,
33
+ touchSourceV2,
34
+ getActiveSourceCountV2,
35
+ createImportJobV2,
36
+ getImportJobV2,
37
+ listImportJobsV2,
38
+ setImportJobStatusV2,
39
+ startImportJobV2,
40
+ completeImportJobV2,
41
+ failImportJobV2,
42
+ cancelImportJobV2,
43
+ getPendingJobCountV2,
44
+ autoPauseIdleSourcesV2,
45
+ autoFailStuckImportJobsV2,
46
+ getKnowledgeImporterStatsV2,
16
47
  } from "../lib/knowledge-importer.js";
17
48
 
18
49
  export function registerImportCommand(program) {
@@ -256,4 +287,225 @@ export function registerImportCommand(program) {
256
287
  process.exit(1);
257
288
  }
258
289
  });
290
+
291
+ // ─── V2 Governance Layer ──────────────────────────────────────────
292
+ const out = (obj) => console.log(JSON.stringify(obj, null, 2));
293
+ const tryRun = (fn) => {
294
+ try {
295
+ fn();
296
+ } catch (err) {
297
+ logger.error(err.message);
298
+ process.exit(1);
299
+ }
300
+ };
301
+
302
+ imp
303
+ .command("source-maturities-v2")
304
+ .description("List V2 source maturity states")
305
+ .action(() => out(Object.values(SOURCE_MATURITY_V2)));
306
+
307
+ imp
308
+ .command("import-job-lifecycles-v2")
309
+ .description("List V2 import-job lifecycle states")
310
+ .action(() => out(Object.values(IMPORT_JOB_LIFECYCLE_V2)));
311
+
312
+ imp
313
+ .command("stats-v2")
314
+ .description("V2 knowledge-importer stats")
315
+ .action(() => out(getKnowledgeImporterStatsV2()));
316
+
317
+ imp
318
+ .command("get-max-active-sources-v2")
319
+ .description("Get max active sources per owner (V2)")
320
+ .action(() =>
321
+ out({ maxActiveSourcesPerOwner: getMaxActiveSourcesPerOwnerV2() }),
322
+ );
323
+
324
+ imp
325
+ .command("set-max-active-sources-v2 <n>")
326
+ .description("Set max active sources per owner (V2)")
327
+ .action((n) =>
328
+ tryRun(() => {
329
+ setMaxActiveSourcesPerOwnerV2(Number(n));
330
+ out({ maxActiveSourcesPerOwner: getMaxActiveSourcesPerOwnerV2() });
331
+ }),
332
+ );
333
+
334
+ imp
335
+ .command("get-max-pending-jobs-v2")
336
+ .description("Get max pending jobs per source (V2)")
337
+ .action(() =>
338
+ out({ maxPendingJobsPerSource: getMaxPendingJobsPerSourceV2() }),
339
+ );
340
+
341
+ imp
342
+ .command("set-max-pending-jobs-v2 <n>")
343
+ .description("Set max pending jobs per source (V2)")
344
+ .action((n) =>
345
+ tryRun(() => {
346
+ setMaxPendingJobsPerSourceV2(Number(n));
347
+ out({ maxPendingJobsPerSource: getMaxPendingJobsPerSourceV2() });
348
+ }),
349
+ );
350
+
351
+ imp
352
+ .command("get-source-idle-ms-v2")
353
+ .description("Get source idle threshold (V2)")
354
+ .action(() => out({ sourceIdleMs: getSourceIdleMsV2() }));
355
+
356
+ imp
357
+ .command("set-source-idle-ms-v2 <ms>")
358
+ .description("Set source idle threshold (V2)")
359
+ .action((ms) =>
360
+ tryRun(() => {
361
+ setSourceIdleMsV2(Number(ms));
362
+ out({ sourceIdleMs: getSourceIdleMsV2() });
363
+ }),
364
+ );
365
+
366
+ imp
367
+ .command("get-job-stuck-ms-v2")
368
+ .description("Get import-job stuck threshold (V2)")
369
+ .action(() => out({ jobStuckMs: getJobStuckMsV2() }));
370
+
371
+ imp
372
+ .command("set-job-stuck-ms-v2 <ms>")
373
+ .description("Set import-job stuck threshold (V2)")
374
+ .action((ms) =>
375
+ tryRun(() => {
376
+ setJobStuckMsV2(Number(ms));
377
+ out({ jobStuckMs: getJobStuckMsV2() });
378
+ }),
379
+ );
380
+
381
+ imp
382
+ .command("active-source-count-v2 <ownerId>")
383
+ .description("Active source count for owner (V2)")
384
+ .action((ownerId) =>
385
+ out({ ownerId, count: getActiveSourceCountV2(ownerId) }),
386
+ );
387
+
388
+ imp
389
+ .command("pending-job-count-v2 <sourceId>")
390
+ .description("Pending import-job count for source (V2)")
391
+ .action((sourceId) =>
392
+ out({ sourceId, count: getPendingJobCountV2(sourceId) }),
393
+ );
394
+
395
+ imp
396
+ .command("register-source-v2 <id>")
397
+ .description("Register a V2 source manifest")
398
+ .requiredOption("-o, --owner <id>", "owner id")
399
+ .requiredOption("-l, --label <label>", "source label")
400
+ .option("-k, --kind <kind>", "source kind", "markdown")
401
+ .action((id, opts) =>
402
+ tryRun(() =>
403
+ out(
404
+ registerSourceV2(id, {
405
+ ownerId: opts.owner,
406
+ label: opts.label,
407
+ kind: opts.kind,
408
+ }),
409
+ ),
410
+ ),
411
+ );
412
+
413
+ imp
414
+ .command("get-source-v2 <id>")
415
+ .description("Get a V2 source")
416
+ .action((id) => out(getSourceV2(id)));
417
+
418
+ imp
419
+ .command("list-sources-v2")
420
+ .description("List V2 sources")
421
+ .option("-o, --owner <id>", "filter by owner")
422
+ .option("-s, --status <status>", "filter by status")
423
+ .action((opts) =>
424
+ out(listSourcesV2({ ownerId: opts.owner, status: opts.status })),
425
+ );
426
+
427
+ imp
428
+ .command("set-source-status-v2 <id> <next>")
429
+ .description("Set V2 source status")
430
+ .action((id, next) => tryRun(() => out(setSourceStatusV2(id, next))));
431
+
432
+ imp
433
+ .command("activate-source-v2 <id>")
434
+ .description("Activate a V2 source")
435
+ .action((id) => tryRun(() => out(activateSourceV2(id))));
436
+
437
+ imp
438
+ .command("pause-source-v2 <id>")
439
+ .description("Pause a V2 source")
440
+ .action((id) => tryRun(() => out(pauseSourceV2(id))));
441
+
442
+ imp
443
+ .command("archive-source-v2 <id>")
444
+ .description("Archive a V2 source")
445
+ .action((id) => tryRun(() => out(archiveSourceV2(id))));
446
+
447
+ imp
448
+ .command("touch-source-v2 <id>")
449
+ .description("Touch a V2 source")
450
+ .action((id) => tryRun(() => out(touchSourceV2(id))));
451
+
452
+ imp
453
+ .command("create-import-job-v2 <id>")
454
+ .description("Create a V2 import job")
455
+ .requiredOption("-s, --source <id>", "source id")
456
+ .option("-k, --kind <kind>", "job kind", "scan")
457
+ .action((id, opts) =>
458
+ tryRun(() =>
459
+ out(createImportJobV2(id, { sourceId: opts.source, kind: opts.kind })),
460
+ ),
461
+ );
462
+
463
+ imp
464
+ .command("get-import-job-v2 <id>")
465
+ .description("Get a V2 import job")
466
+ .action((id) => out(getImportJobV2(id)));
467
+
468
+ imp
469
+ .command("list-import-jobs-v2")
470
+ .description("List V2 import jobs")
471
+ .option("-s, --source <id>", "filter by source")
472
+ .option("-t, --status <status>", "filter by status")
473
+ .action((opts) =>
474
+ out(listImportJobsV2({ sourceId: opts.source, status: opts.status })),
475
+ );
476
+
477
+ imp
478
+ .command("set-import-job-status-v2 <id> <next>")
479
+ .description("Set V2 import-job status")
480
+ .action((id, next) => tryRun(() => out(setImportJobStatusV2(id, next))));
481
+
482
+ imp
483
+ .command("start-import-job-v2 <id>")
484
+ .description("Start a V2 import job")
485
+ .action((id) => tryRun(() => out(startImportJobV2(id))));
486
+
487
+ imp
488
+ .command("complete-import-job-v2 <id>")
489
+ .description("Complete a V2 import job")
490
+ .action((id) => tryRun(() => out(completeImportJobV2(id))));
491
+
492
+ imp
493
+ .command("fail-import-job-v2 <id>")
494
+ .description("Fail a V2 import job")
495
+ .action((id) => tryRun(() => out(failImportJobV2(id))));
496
+
497
+ imp
498
+ .command("cancel-import-job-v2 <id>")
499
+ .description("Cancel a V2 import job")
500
+ .action((id) => tryRun(() => out(cancelImportJobV2(id))));
501
+
502
+ imp
503
+ .command("auto-pause-idle-sources-v2")
504
+ .description("Auto-pause idle V2 sources")
505
+ .action(() => out(autoPauseIdleSourcesV2()));
506
+
507
+ imp
508
+ .command("auto-fail-stuck-import-jobs-v2")
509
+ .description("Auto-fail stuck V2 import jobs")
510
+ .action(() => out(autoFailStuckImportJobsV2()));
259
511
  }
@@ -20,6 +20,33 @@ import {
20
20
  rewardContribution,
21
21
  getContributions,
22
22
  getLeaderboard,
23
+ // V2
24
+ ACCOUNT_STATUS_V2,
25
+ CLAIM_STATUS_V2,
26
+ TOKEN_DEFAULT_MAX_PENDING_CLAIMS_PER_USER,
27
+ TOKEN_DEFAULT_CLAIM_EXPIRY_MS,
28
+ TOKEN_DEFAULT_MAX_CLAIM_AMOUNT,
29
+ setMaxPendingClaimsPerUser,
30
+ setClaimExpiryMs,
31
+ setMaxClaimAmount,
32
+ getMaxPendingClaimsPerUser,
33
+ getClaimExpiryMs,
34
+ getMaxClaimAmount,
35
+ getPendingClaimCount,
36
+ registerAccountV2,
37
+ getAccountStatusV2,
38
+ setAccountStatusV2,
39
+ freezeAccount,
40
+ unfreezeAccount,
41
+ closeAccount,
42
+ submitClaimV2,
43
+ getClaimStatusV2,
44
+ setClaimStatusV2,
45
+ approveClaim,
46
+ rejectClaim,
47
+ payClaim,
48
+ autoExpireUnclaimedClaims,
49
+ getTokenStatsV2,
23
50
  } from "../lib/token-incentive.js";
24
51
 
25
52
  function _dbFromCtx(ctx) {
@@ -370,4 +397,299 @@ export function registerIncentiveCommand(program) {
370
397
  process.exit(1);
371
398
  }
372
399
  });
400
+
401
+ // ─────────────────────────────────────────────────────────────
402
+ // Phase 66 V2 — Account + Claim lifecycle
403
+ // ─────────────────────────────────────────────────────────────
404
+
405
+ inc
406
+ .command("account-statuses-v2")
407
+ .description("List V2 account states")
408
+ .action(() => {
409
+ for (const v of Object.values(ACCOUNT_STATUS_V2)) logger.log(v);
410
+ });
411
+
412
+ inc
413
+ .command("claim-statuses-v2")
414
+ .description("List V2 claim states")
415
+ .action(() => {
416
+ for (const v of Object.values(CLAIM_STATUS_V2)) logger.log(v);
417
+ });
418
+
419
+ inc
420
+ .command("default-max-pending-claims-per-user")
421
+ .description("Show default per-user pending claim cap")
422
+ .action(() =>
423
+ logger.log(String(TOKEN_DEFAULT_MAX_PENDING_CLAIMS_PER_USER)),
424
+ );
425
+
426
+ inc
427
+ .command("max-pending-claims-per-user")
428
+ .description("Show current per-user pending claim cap")
429
+ .action(() => logger.log(String(getMaxPendingClaimsPerUser())));
430
+
431
+ inc
432
+ .command("set-max-pending-claims-per-user <n>")
433
+ .description("Update per-user pending claim cap")
434
+ .action((n) => {
435
+ logger.log(String(setMaxPendingClaimsPerUser(n)));
436
+ });
437
+
438
+ inc
439
+ .command("default-claim-expiry-ms")
440
+ .description("Show default claim expiry (ms)")
441
+ .action(() => logger.log(String(TOKEN_DEFAULT_CLAIM_EXPIRY_MS)));
442
+
443
+ inc
444
+ .command("claim-expiry-ms")
445
+ .description("Show current claim expiry (ms)")
446
+ .action(() => logger.log(String(getClaimExpiryMs())));
447
+
448
+ inc
449
+ .command("set-claim-expiry-ms <ms>")
450
+ .description("Update claim expiry (ms)")
451
+ .action((ms) => {
452
+ logger.log(String(setClaimExpiryMs(ms)));
453
+ });
454
+
455
+ inc
456
+ .command("default-max-claim-amount")
457
+ .description("Show default max claim amount")
458
+ .action(() => logger.log(String(TOKEN_DEFAULT_MAX_CLAIM_AMOUNT)));
459
+
460
+ inc
461
+ .command("max-claim-amount")
462
+ .description("Show current max claim amount")
463
+ .action(() => logger.log(String(getMaxClaimAmount())));
464
+
465
+ inc
466
+ .command("set-max-claim-amount <n>")
467
+ .description("Update max claim amount")
468
+ .action((n) => {
469
+ logger.log(String(setMaxClaimAmount(n)));
470
+ });
471
+
472
+ inc
473
+ .command("pending-claim-count")
474
+ .description("Count PENDING claims (optionally scoped to user)")
475
+ .option("-u, --user <user>", "Scope to user")
476
+ .action((opts) => {
477
+ logger.log(String(getPendingClaimCount(opts.user)));
478
+ });
479
+
480
+ inc
481
+ .command("register-account-v2 <account-id>")
482
+ .description("V2: register a tracked account (tags ACTIVE)")
483
+ .option("-m, --metadata <meta>", "Metadata (JSON)")
484
+ .action((accountId, opts) => {
485
+ const ctx = bootstrap();
486
+ try {
487
+ const db = _dbFromCtx(ctx);
488
+ const metadata = opts.metadata ? JSON.parse(opts.metadata) : undefined;
489
+ const entry = registerAccountV2(db, { accountId, metadata });
490
+ logger.log(JSON.stringify(entry, null, 2));
491
+ } finally {
492
+ shutdown();
493
+ }
494
+ });
495
+
496
+ inc
497
+ .command("account-status-v2 <account-id>")
498
+ .description("V2: show account status")
499
+ .action((accountId) => {
500
+ const entry = getAccountStatusV2(accountId);
501
+ if (!entry) {
502
+ logger.log(chalk.yellow("(not found)"));
503
+ return;
504
+ }
505
+ logger.log(JSON.stringify(entry, null, 2));
506
+ });
507
+
508
+ inc
509
+ .command("set-account-status-v2 <account-id> <status>")
510
+ .description("V2: transition account status (active|frozen|closed)")
511
+ .option("-r, --reason <reason>", "Reason")
512
+ .option("-m, --metadata <meta>", "Metadata (JSON)")
513
+ .action((accountId, status, opts) => {
514
+ const ctx = bootstrap();
515
+ try {
516
+ const db = _dbFromCtx(ctx);
517
+ const metadata = opts.metadata ? JSON.parse(opts.metadata) : undefined;
518
+ const entry = setAccountStatusV2(db, accountId, status, {
519
+ reason: opts.reason,
520
+ metadata,
521
+ });
522
+ logger.log(JSON.stringify(entry, null, 2));
523
+ } finally {
524
+ shutdown();
525
+ }
526
+ });
527
+
528
+ inc
529
+ .command("freeze-account <account-id>")
530
+ .description("V2: shortcut → frozen")
531
+ .option("-r, --reason <reason>", "Reason")
532
+ .action((accountId, opts) => {
533
+ const ctx = bootstrap();
534
+ try {
535
+ const db = _dbFromCtx(ctx);
536
+ const entry = freezeAccount(db, accountId, opts.reason);
537
+ logger.log(JSON.stringify(entry, null, 2));
538
+ } finally {
539
+ shutdown();
540
+ }
541
+ });
542
+
543
+ inc
544
+ .command("unfreeze-account <account-id>")
545
+ .description("V2: shortcut → active (from frozen)")
546
+ .option("-r, --reason <reason>", "Reason")
547
+ .action((accountId, opts) => {
548
+ const ctx = bootstrap();
549
+ try {
550
+ const db = _dbFromCtx(ctx);
551
+ const entry = unfreezeAccount(db, accountId, opts.reason);
552
+ logger.log(JSON.stringify(entry, null, 2));
553
+ } finally {
554
+ shutdown();
555
+ }
556
+ });
557
+
558
+ inc
559
+ .command("close-account <account-id>")
560
+ .description("V2: shortcut → closed")
561
+ .option("-r, --reason <reason>", "Reason")
562
+ .action((accountId, opts) => {
563
+ const ctx = bootstrap();
564
+ try {
565
+ const db = _dbFromCtx(ctx);
566
+ const entry = closeAccount(db, accountId, opts.reason);
567
+ logger.log(JSON.stringify(entry, null, 2));
568
+ } finally {
569
+ shutdown();
570
+ }
571
+ });
572
+
573
+ inc
574
+ .command("submit-claim-v2 <claim-id>")
575
+ .description("V2: submit a claim (tags PENDING)")
576
+ .requiredOption("-u, --user <user>", "User ID")
577
+ .requiredOption("-a, --amount <amount>", "Amount")
578
+ .option("-c, --contribution <id>", "Contribution ID")
579
+ .option("-m, --metadata <meta>", "Metadata (JSON)")
580
+ .action((claimId, opts) => {
581
+ const ctx = bootstrap();
582
+ try {
583
+ const db = _dbFromCtx(ctx);
584
+ const metadata = opts.metadata ? JSON.parse(opts.metadata) : undefined;
585
+ const entry = submitClaimV2(db, {
586
+ claimId,
587
+ userId: opts.user,
588
+ amount: Number(opts.amount),
589
+ contributionId: opts.contribution,
590
+ metadata,
591
+ });
592
+ logger.log(JSON.stringify(entry, null, 2));
593
+ } finally {
594
+ shutdown();
595
+ }
596
+ });
597
+
598
+ inc
599
+ .command("claim-status-v2 <claim-id>")
600
+ .description("V2: show claim status")
601
+ .action((claimId) => {
602
+ const entry = getClaimStatusV2(claimId);
603
+ if (!entry) {
604
+ logger.log(chalk.yellow("(not found)"));
605
+ return;
606
+ }
607
+ logger.log(JSON.stringify(entry, null, 2));
608
+ });
609
+
610
+ inc
611
+ .command("set-claim-status-v2 <claim-id> <status>")
612
+ .description("V2: transition claim (pending|approved|paid|rejected)")
613
+ .option("-r, --reason <reason>", "Reason")
614
+ .option("-m, --metadata <meta>", "Metadata (JSON)")
615
+ .action((claimId, status, opts) => {
616
+ const ctx = bootstrap();
617
+ try {
618
+ const db = _dbFromCtx(ctx);
619
+ const metadata = opts.metadata ? JSON.parse(opts.metadata) : undefined;
620
+ const entry = setClaimStatusV2(db, claimId, status, {
621
+ reason: opts.reason,
622
+ metadata,
623
+ });
624
+ logger.log(JSON.stringify(entry, null, 2));
625
+ } finally {
626
+ shutdown();
627
+ }
628
+ });
629
+
630
+ inc
631
+ .command("approve-claim <claim-id>")
632
+ .description("V2: shortcut → approved")
633
+ .option("-r, --reason <reason>", "Reason")
634
+ .action((claimId, opts) => {
635
+ const ctx = bootstrap();
636
+ try {
637
+ const db = _dbFromCtx(ctx);
638
+ const entry = approveClaim(db, claimId, opts.reason);
639
+ logger.log(JSON.stringify(entry, null, 2));
640
+ } finally {
641
+ shutdown();
642
+ }
643
+ });
644
+
645
+ inc
646
+ .command("reject-claim <claim-id>")
647
+ .description("V2: shortcut → rejected")
648
+ .option("-r, --reason <reason>", "Reason")
649
+ .action((claimId, opts) => {
650
+ const ctx = bootstrap();
651
+ try {
652
+ const db = _dbFromCtx(ctx);
653
+ const entry = rejectClaim(db, claimId, opts.reason);
654
+ logger.log(JSON.stringify(entry, null, 2));
655
+ } finally {
656
+ shutdown();
657
+ }
658
+ });
659
+
660
+ inc
661
+ .command("pay-claim <claim-id>")
662
+ .description("V2: shortcut → paid (stamps paidAt)")
663
+ .option("-r, --reason <reason>", "Reason")
664
+ .action((claimId, opts) => {
665
+ const ctx = bootstrap();
666
+ try {
667
+ const db = _dbFromCtx(ctx);
668
+ const entry = payClaim(db, claimId, opts.reason);
669
+ logger.log(JSON.stringify(entry, null, 2));
670
+ } finally {
671
+ shutdown();
672
+ }
673
+ });
674
+
675
+ inc
676
+ .command("auto-expire-unclaimed-claims")
677
+ .description("V2: bulk-reject stale PENDING claims")
678
+ .action(() => {
679
+ const ctx = bootstrap();
680
+ try {
681
+ const db = _dbFromCtx(ctx);
682
+ const expired = autoExpireUnclaimedClaims(db);
683
+ logger.log(`Expired ${expired.length} claim(s)`);
684
+ } finally {
685
+ shutdown();
686
+ }
687
+ });
688
+
689
+ inc
690
+ .command("stats-v2")
691
+ .description("V2: all-enum-key stats snapshot")
692
+ .action(() => {
693
+ logger.log(JSON.stringify(getTokenStatsV2(), null, 2));
694
+ });
373
695
  }