chainlesschain 0.132.0 → 0.145.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 (135) hide show
  1. package/package.json +1 -1
  2. package/src/commands/a2a.js +230 -0
  3. package/src/commands/activitypub.js +191 -0
  4. package/src/commands/agent.js +601 -0
  5. package/src/commands/audit.js +206 -0
  6. package/src/commands/bi.js +186 -0
  7. package/src/commands/bm25.js +162 -0
  8. package/src/commands/browse.js +225 -0
  9. package/src/commands/ccron.js +178 -0
  10. package/src/commands/chat.js +207 -0
  11. package/src/commands/compliance.js +420 -0
  12. package/src/commands/compt.js +176 -0
  13. package/src/commands/consol.js +237 -0
  14. package/src/commands/cowork.js +588 -0
  15. package/src/commands/crosschain.js +216 -0
  16. package/src/commands/dao.js +216 -0
  17. package/src/commands/dlp.js +206 -0
  18. package/src/commands/economy.js +211 -0
  19. package/src/commands/evolution.js +209 -0
  20. package/src/commands/evomap.js +216 -0
  21. package/src/commands/fflag.js +230 -0
  22. package/src/commands/git.js +185 -0
  23. package/src/commands/hardening.js +209 -0
  24. package/src/commands/hmemory.js +210 -0
  25. package/src/commands/incentive.js +209 -0
  26. package/src/commands/inference.js +178 -0
  27. package/src/commands/itbudget.js +161 -0
  28. package/src/commands/kg.js +206 -0
  29. package/src/commands/lowcode.js +201 -0
  30. package/src/commands/marketplace.js +206 -0
  31. package/src/commands/matrix.js +214 -0
  32. package/src/commands/mcpscaf.js +153 -0
  33. package/src/commands/meminj.js +153 -0
  34. package/src/commands/nostr.js +213 -0
  35. package/src/commands/orchestrate.js +217 -0
  36. package/src/commands/orchgov.js +156 -0
  37. package/src/commands/pdfp.js +160 -0
  38. package/src/commands/perf.js +176 -0
  39. package/src/commands/perm.js +156 -0
  40. package/src/commands/pipeline.js +211 -0
  41. package/src/commands/planmode.js +154 -0
  42. package/src/commands/privacy.js +203 -0
  43. package/src/commands/promcomp.js +166 -0
  44. package/src/commands/recommend.js +185 -0
  45. package/src/commands/reputation.js +208 -0
  46. package/src/commands/sandbox.js +206 -0
  47. package/src/commands/seshhook.js +153 -0
  48. package/src/commands/seshsearch.js +149 -0
  49. package/src/commands/seshtail.js +152 -0
  50. package/src/commands/seshu.js +160 -0
  51. package/src/commands/sganal.js +172 -0
  52. package/src/commands/siem.js +207 -0
  53. package/src/commands/sla.js +212 -0
  54. package/src/commands/slotfill.js +154 -0
  55. package/src/commands/social.js +159 -0
  56. package/src/commands/stress.js +206 -0
  57. package/src/commands/svccont.js +157 -0
  58. package/src/commands/terraform.js +206 -0
  59. package/src/commands/tms.js +183 -0
  60. package/src/commands/topiccls.js +158 -0
  61. package/src/commands/uprof.js +154 -0
  62. package/src/commands/vcheck.js +172 -0
  63. package/src/commands/webfetch.js +150 -0
  64. package/src/commands/zkp.js +218 -0
  65. package/src/harness/prompt-compressor.js +331 -0
  66. package/src/index.js +101 -1
  67. package/src/lib/a2a-protocol.js +373 -0
  68. package/src/lib/activitypub-bridge.js +343 -0
  69. package/src/lib/agent-economy.js +358 -0
  70. package/src/lib/app-builder.js +338 -0
  71. package/src/lib/audit-logger.js +321 -0
  72. package/src/lib/autonomous-agent.js +341 -0
  73. package/src/lib/bi-engine.js +339 -0
  74. package/src/lib/bm25-search.js +333 -0
  75. package/src/lib/browser-automation.js +352 -0
  76. package/src/lib/chat-core.js +336 -0
  77. package/src/lib/claude-code-bridge.js +341 -0
  78. package/src/lib/compliance-framework-reporter.js +359 -0
  79. package/src/lib/compliance-manager.js +330 -0
  80. package/src/lib/compression-telemetry.js +333 -0
  81. package/src/lib/content-recommender.js +370 -0
  82. package/src/lib/cowork-cron.js +330 -0
  83. package/src/lib/cowork-learning.js +333 -0
  84. package/src/lib/cowork-task-runner.js +362 -0
  85. package/src/lib/cowork-workflow.js +327 -0
  86. package/src/lib/cross-chain.js +365 -0
  87. package/src/lib/dao-governance.js +339 -0
  88. package/src/lib/dlp-engine.js +343 -0
  89. package/src/lib/evolution-system.js +336 -0
  90. package/src/lib/evomap-manager.js +339 -0
  91. package/src/lib/execution-backend.js +351 -0
  92. package/src/lib/feature-flags.js +330 -0
  93. package/src/lib/git-integration.js +343 -0
  94. package/src/lib/hardening-manager.js +341 -0
  95. package/src/lib/hierarchical-memory.js +341 -0
  96. package/src/lib/inference-network.js +362 -0
  97. package/src/lib/iteration-budget.js +357 -0
  98. package/src/lib/knowledge-graph.js +333 -0
  99. package/src/lib/matrix-bridge.js +339 -0
  100. package/src/lib/mcp-scaffold.js +345 -0
  101. package/src/lib/memory-injection.js +320 -0
  102. package/src/lib/nostr-bridge.js +342 -0
  103. package/src/lib/orchestrator.js +350 -0
  104. package/src/lib/pdf-parser.js +330 -0
  105. package/src/lib/perf-tuning.js +364 -0
  106. package/src/lib/permission-engine.js +319 -0
  107. package/src/lib/pipeline-orchestrator.js +345 -0
  108. package/src/lib/plan-mode.js +328 -0
  109. package/src/lib/privacy-computing.js +335 -0
  110. package/src/lib/prompt-compressor.js +1 -10
  111. package/src/lib/reputation-optimizer.js +340 -0
  112. package/src/lib/sandbox-v2.js +327 -0
  113. package/src/lib/service-container.js +342 -0
  114. package/src/lib/session-consolidator.js +352 -0
  115. package/src/lib/session-hooks.js +340 -0
  116. package/src/lib/session-search.js +334 -0
  117. package/src/lib/session-tail.js +320 -0
  118. package/src/lib/session-usage.js +329 -0
  119. package/src/lib/siem-exporter.js +352 -0
  120. package/src/lib/skill-marketplace.js +345 -0
  121. package/src/lib/sla-manager.js +341 -0
  122. package/src/lib/slot-filler.js +333 -0
  123. package/src/lib/social-graph-analytics.js +327 -0
  124. package/src/lib/social-graph.js +304 -0
  125. package/src/lib/stress-tester.js +342 -0
  126. package/src/lib/sub-agent-registry.js +359 -0
  127. package/src/lib/task-model-selector.js +333 -0
  128. package/src/lib/terraform-manager.js +333 -0
  129. package/src/lib/todo-manager.js +339 -0
  130. package/src/lib/token-incentive.js +341 -0
  131. package/src/lib/topic-classifier.js +353 -0
  132. package/src/lib/user-profile.js +325 -0
  133. package/src/lib/version-checker.js +335 -0
  134. package/src/lib/web-fetch.js +322 -0
  135. package/src/lib/zkp-engine.js +342 -0
@@ -586,3 +586,209 @@ export function registerAuditCommand(program) {
586
586
  logger.log(JSON.stringify(getAuditStatsV2(), null, 2));
587
587
  });
588
588
  }
589
+
590
+ // === Iter16 V2 governance overlay ===
591
+ export function registerAuditGovV2Commands(program) {
592
+ const parent = program.commands.find((c) => c.name() === "audit");
593
+ if (!parent) return;
594
+ const L = async () => await import("../lib/audit-logger.js");
595
+ parent
596
+ .command("aud-gov-enums-v2")
597
+ .description("Show V2 enums (aud maturity + write lifecycle)")
598
+ .action(async () => {
599
+ const m = await L();
600
+ console.log(
601
+ JSON.stringify(
602
+ {
603
+ profileMaturity: m.AUD_PROFILE_MATURITY_V2,
604
+ writeLifecycle: m.AUD_WRITE_LIFECYCLE_V2,
605
+ },
606
+ null,
607
+ 2,
608
+ ),
609
+ );
610
+ });
611
+ parent
612
+ .command("aud-gov-config-v2")
613
+ .description("Show V2 config thresholds")
614
+ .action(async () => {
615
+ const m = await L();
616
+ console.log(
617
+ JSON.stringify(
618
+ {
619
+ maxActive: m.getMaxActiveAudProfilesPerOwnerV2(),
620
+ maxPending: m.getMaxPendingAudWritesPerProfileV2(),
621
+ idleMs: m.getAudProfileIdleMsV2(),
622
+ stuckMs: m.getAudWriteStuckMsV2(),
623
+ },
624
+ null,
625
+ 2,
626
+ ),
627
+ );
628
+ });
629
+ parent
630
+ .command("aud-gov-set-max-active-v2 <n>")
631
+ .description("Set max active profiles per owner")
632
+ .action(async (n) => {
633
+ const m = await L();
634
+ m.setMaxActiveAudProfilesPerOwnerV2(Number(n));
635
+ console.log("ok");
636
+ });
637
+ parent
638
+ .command("aud-gov-set-max-pending-v2 <n>")
639
+ .description("Set max pending writes per profile")
640
+ .action(async (n) => {
641
+ const m = await L();
642
+ m.setMaxPendingAudWritesPerProfileV2(Number(n));
643
+ console.log("ok");
644
+ });
645
+ parent
646
+ .command("aud-gov-set-idle-ms-v2 <n>")
647
+ .description("Set profile idle threshold (ms)")
648
+ .action(async (n) => {
649
+ const m = await L();
650
+ m.setAudProfileIdleMsV2(Number(n));
651
+ console.log("ok");
652
+ });
653
+ parent
654
+ .command("aud-gov-set-stuck-ms-v2 <n>")
655
+ .description("Set write stuck threshold (ms)")
656
+ .action(async (n) => {
657
+ const m = await L();
658
+ m.setAudWriteStuckMsV2(Number(n));
659
+ console.log("ok");
660
+ });
661
+ parent
662
+ .command("aud-gov-register-v2 <id> <owner>")
663
+ .description("Register V2 aud profile")
664
+ .option("--level <v>", "level")
665
+ .action(async (id, owner, o) => {
666
+ const m = await L();
667
+ console.log(
668
+ JSON.stringify(
669
+ m.registerAudProfileV2({ id, owner, level: o.level }),
670
+ null,
671
+ 2,
672
+ ),
673
+ );
674
+ });
675
+ parent
676
+ .command("aud-gov-activate-v2 <id>")
677
+ .description("Activate profile")
678
+ .action(async (id) => {
679
+ const m = await L();
680
+ console.log(JSON.stringify(m.activateAudProfileV2(id), null, 2));
681
+ });
682
+ parent
683
+ .command("aud-gov-suspend-v2 <id>")
684
+ .description("Suspend profile")
685
+ .action(async (id) => {
686
+ const m = await L();
687
+ console.log(JSON.stringify(m.suspendAudProfileV2(id), null, 2));
688
+ });
689
+ parent
690
+ .command("aud-gov-archive-v2 <id>")
691
+ .description("Archive profile (terminal)")
692
+ .action(async (id) => {
693
+ const m = await L();
694
+ console.log(JSON.stringify(m.archiveAudProfileV2(id), null, 2));
695
+ });
696
+ parent
697
+ .command("aud-gov-touch-v2 <id>")
698
+ .description("Touch profile")
699
+ .action(async (id) => {
700
+ const m = await L();
701
+ console.log(JSON.stringify(m.touchAudProfileV2(id), null, 2));
702
+ });
703
+ parent
704
+ .command("aud-gov-get-v2 <id>")
705
+ .description("Get profile")
706
+ .action(async (id) => {
707
+ const m = await L();
708
+ console.log(JSON.stringify(m.getAudProfileV2(id), null, 2));
709
+ });
710
+ parent
711
+ .command("aud-gov-list-v2")
712
+ .description("List profiles")
713
+ .action(async () => {
714
+ const m = await L();
715
+ console.log(JSON.stringify(m.listAudProfilesV2(), null, 2));
716
+ });
717
+ parent
718
+ .command("aud-gov-create-write-v2 <id> <profileId>")
719
+ .description("Create write (queued)")
720
+ .option("--key <v>", "key")
721
+ .action(async (id, profileId, o) => {
722
+ const m = await L();
723
+ console.log(
724
+ JSON.stringify(
725
+ m.createAudWriteV2({ id, profileId, key: o.key }),
726
+ null,
727
+ 2,
728
+ ),
729
+ );
730
+ });
731
+ parent
732
+ .command("aud-gov-writing-write-v2 <id>")
733
+ .description("Mark write as writing")
734
+ .action(async (id) => {
735
+ const m = await L();
736
+ console.log(JSON.stringify(m.writingAudWriteV2(id), null, 2));
737
+ });
738
+ parent
739
+ .command("aud-gov-complete-write-v2 <id>")
740
+ .description("Write OK")
741
+ .action(async (id) => {
742
+ const m = await L();
743
+ console.log(JSON.stringify(m.writeOkAudV2(id), null, 2));
744
+ });
745
+ parent
746
+ .command("aud-gov-fail-write-v2 <id> [reason]")
747
+ .description("Fail write")
748
+ .action(async (id, reason) => {
749
+ const m = await L();
750
+ console.log(JSON.stringify(m.failAudWriteV2(id, reason), null, 2));
751
+ });
752
+ parent
753
+ .command("aud-gov-cancel-write-v2 <id> [reason]")
754
+ .description("Cancel write")
755
+ .action(async (id, reason) => {
756
+ const m = await L();
757
+ console.log(JSON.stringify(m.cancelAudWriteV2(id, reason), null, 2));
758
+ });
759
+ parent
760
+ .command("aud-gov-get-write-v2 <id>")
761
+ .description("Get write")
762
+ .action(async (id) => {
763
+ const m = await L();
764
+ console.log(JSON.stringify(m.getAudWriteV2(id), null, 2));
765
+ });
766
+ parent
767
+ .command("aud-gov-list-writes-v2")
768
+ .description("List writes")
769
+ .action(async () => {
770
+ const m = await L();
771
+ console.log(JSON.stringify(m.listAudWritesV2(), null, 2));
772
+ });
773
+ parent
774
+ .command("aud-gov-auto-suspend-idle-v2")
775
+ .description("Auto-suspend idle profiles")
776
+ .action(async () => {
777
+ const m = await L();
778
+ console.log(JSON.stringify(m.autoSuspendIdleAudProfilesV2(), null, 2));
779
+ });
780
+ parent
781
+ .command("aud-gov-auto-fail-stuck-v2")
782
+ .description("Auto-fail stuck writes")
783
+ .action(async () => {
784
+ const m = await L();
785
+ console.log(JSON.stringify(m.autoFailStuckAudWritesV2(), null, 2));
786
+ });
787
+ parent
788
+ .command("aud-gov-gov-stats-v2")
789
+ .description("V2 gov aggregate stats")
790
+ .action(async () => {
791
+ const m = await L();
792
+ console.log(JSON.stringify(m.getAuditLoggerGovStatsV2(), null, 2));
793
+ });
794
+ }
@@ -585,4 +585,190 @@ export function registerBiCommand(program) {
585
585
  process.exit(1);
586
586
  }
587
587
  });
588
+ registerBiV2Command(bi);
589
+ }
590
+
591
+ import {
592
+ BI_DATASET_MATURITY_V2,
593
+ BI_QUERY_LIFECYCLE_V2,
594
+ registerBiDatasetV2,
595
+ activateBiDatasetV2,
596
+ staleBiDatasetV2,
597
+ archiveBiDatasetV2,
598
+ touchBiDatasetV2,
599
+ getBiDatasetV2,
600
+ listBiDatasetsV2,
601
+ createBiQueryV2,
602
+ startBiQueryV2,
603
+ completeBiQueryV2,
604
+ failBiQueryV2,
605
+ cancelBiQueryV2,
606
+ getBiQueryV2,
607
+ listBiQueriesV2,
608
+ setMaxActiveBiDatasetsPerOwnerV2,
609
+ getMaxActiveBiDatasetsPerOwnerV2,
610
+ setMaxPendingBiQueriesPerDatasetV2,
611
+ getMaxPendingBiQueriesPerDatasetV2,
612
+ setBiDatasetIdleMsV2,
613
+ getBiDatasetIdleMsV2,
614
+ setBiQueryStuckMsV2,
615
+ getBiQueryStuckMsV2,
616
+ autoStaleIdleBiDatasetsV2,
617
+ autoFailStuckBiQueriesV2,
618
+ getBiEngineStatsV2,
619
+ } from "../lib/bi-engine.js";
620
+
621
+ export function registerBiV2Command(bi) {
622
+ bi.command("enums-v2")
623
+ .description("Show V2 enums")
624
+ .action(() => {
625
+ console.log(
626
+ JSON.stringify(
627
+ { BI_DATASET_MATURITY_V2, BI_QUERY_LIFECYCLE_V2 },
628
+ null,
629
+ 2,
630
+ ),
631
+ );
632
+ });
633
+ bi.command("register-dataset-v2")
634
+ .description("Register a BI dataset profile (pending)")
635
+ .requiredOption("--id <id>")
636
+ .requiredOption("--owner <owner>")
637
+ .option("--source <source>")
638
+ .action((o) => {
639
+ console.log(JSON.stringify(registerBiDatasetV2(o), null, 2));
640
+ });
641
+ bi.command("activate-dataset-v2 <id>")
642
+ .description("Activate dataset")
643
+ .action((id) => {
644
+ console.log(JSON.stringify(activateBiDatasetV2(id), null, 2));
645
+ });
646
+ bi.command("stale-dataset-v2 <id>")
647
+ .description("Mark dataset stale")
648
+ .action((id) => {
649
+ console.log(JSON.stringify(staleBiDatasetV2(id), null, 2));
650
+ });
651
+ bi.command("archive-dataset-v2 <id>")
652
+ .description("Archive dataset (terminal)")
653
+ .action((id) => {
654
+ console.log(JSON.stringify(archiveBiDatasetV2(id), null, 2));
655
+ });
656
+ bi.command("touch-dataset-v2 <id>")
657
+ .description("Refresh lastTouchedAt")
658
+ .action((id) => {
659
+ console.log(JSON.stringify(touchBiDatasetV2(id), null, 2));
660
+ });
661
+ bi.command("get-dataset-v2 <id>")
662
+ .description("Get dataset")
663
+ .action((id) => {
664
+ console.log(JSON.stringify(getBiDatasetV2(id), null, 2));
665
+ });
666
+ bi.command("list-datasets-v2")
667
+ .description("List datasets")
668
+ .action(() => {
669
+ console.log(JSON.stringify(listBiDatasetsV2(), null, 2));
670
+ });
671
+ bi.command("create-query-v2")
672
+ .description("Create a BI query (queued)")
673
+ .requiredOption("--id <id>")
674
+ .requiredOption("--dataset-id <datasetId>")
675
+ .option("--sql <sql>")
676
+ .action((o) => {
677
+ console.log(
678
+ JSON.stringify(
679
+ createBiQueryV2({ id: o.id, datasetId: o.datasetId, sql: o.sql }),
680
+ null,
681
+ 2,
682
+ ),
683
+ );
684
+ });
685
+ bi.command("start-query-v2 <id>")
686
+ .description("Transition query to running")
687
+ .action((id) => {
688
+ console.log(JSON.stringify(startBiQueryV2(id), null, 2));
689
+ });
690
+ bi.command("complete-query-v2 <id>")
691
+ .description("Transition query to completed")
692
+ .action((id) => {
693
+ console.log(JSON.stringify(completeBiQueryV2(id), null, 2));
694
+ });
695
+ bi.command("fail-query-v2 <id>")
696
+ .description("Fail query")
697
+ .option("--reason <r>")
698
+ .action((id, o) => {
699
+ console.log(JSON.stringify(failBiQueryV2(id, o.reason), null, 2));
700
+ });
701
+ bi.command("cancel-query-v2 <id>")
702
+ .description("Cancel query")
703
+ .option("--reason <r>")
704
+ .action((id, o) => {
705
+ console.log(JSON.stringify(cancelBiQueryV2(id, o.reason), null, 2));
706
+ });
707
+ bi.command("get-query-v2 <id>")
708
+ .description("Get query")
709
+ .action((id) => {
710
+ console.log(JSON.stringify(getBiQueryV2(id), null, 2));
711
+ });
712
+ bi.command("list-queries-v2")
713
+ .description("List queries")
714
+ .action(() => {
715
+ console.log(JSON.stringify(listBiQueriesV2(), null, 2));
716
+ });
717
+ bi.command("set-max-active-datasets-v2 <n>")
718
+ .description("Set per-owner active cap")
719
+ .action((n) => {
720
+ setMaxActiveBiDatasetsPerOwnerV2(Number(n));
721
+ console.log(
722
+ JSON.stringify(
723
+ { maxActiveBiDatasetsPerOwner: getMaxActiveBiDatasetsPerOwnerV2() },
724
+ null,
725
+ 2,
726
+ ),
727
+ );
728
+ });
729
+ bi.command("set-max-pending-queries-v2 <n>")
730
+ .description("Set per-dataset pending cap")
731
+ .action((n) => {
732
+ setMaxPendingBiQueriesPerDatasetV2(Number(n));
733
+ console.log(
734
+ JSON.stringify(
735
+ {
736
+ maxPendingBiQueriesPerDataset: getMaxPendingBiQueriesPerDatasetV2(),
737
+ },
738
+ null,
739
+ 2,
740
+ ),
741
+ );
742
+ });
743
+ bi.command("set-dataset-idle-ms-v2 <n>")
744
+ .description("Set idle threshold")
745
+ .action((n) => {
746
+ setBiDatasetIdleMsV2(Number(n));
747
+ console.log(
748
+ JSON.stringify({ biDatasetIdleMs: getBiDatasetIdleMsV2() }, null, 2),
749
+ );
750
+ });
751
+ bi.command("set-query-stuck-ms-v2 <n>")
752
+ .description("Set stuck threshold")
753
+ .action((n) => {
754
+ setBiQueryStuckMsV2(Number(n));
755
+ console.log(
756
+ JSON.stringify({ biQueryStuckMs: getBiQueryStuckMsV2() }, null, 2),
757
+ );
758
+ });
759
+ bi.command("auto-stale-idle-datasets-v2")
760
+ .description("Auto-stale idle datasets")
761
+ .action(() => {
762
+ console.log(JSON.stringify(autoStaleIdleBiDatasetsV2(), null, 2));
763
+ });
764
+ bi.command("auto-fail-stuck-queries-v2")
765
+ .description("Auto-fail stuck running queries")
766
+ .action(() => {
767
+ console.log(JSON.stringify(autoFailStuckBiQueriesV2(), null, 2));
768
+ });
769
+ bi.command("gov-stats-v2")
770
+ .description("V2 governance aggregate stats")
771
+ .action(() => {
772
+ console.log(JSON.stringify(getBiEngineStatsV2(), null, 2));
773
+ });
588
774
  }
@@ -0,0 +1,162 @@
1
+ /**
2
+ * BM25 Search V2 governance commands — `cc bm25 ...`
3
+ * 在内存中治理 BM25 profile (pending/active/stale/archived) + query 生命周期。
4
+ */
5
+ import {
6
+ BM25_PROFILE_MATURITY_V2,
7
+ BM25_QUERY_LIFECYCLE_V2,
8
+ registerBm25ProfileV2,
9
+ activateBm25ProfileV2,
10
+ staleBm25ProfileV2,
11
+ archiveBm25ProfileV2,
12
+ touchBm25ProfileV2,
13
+ getBm25ProfileV2,
14
+ listBm25ProfilesV2,
15
+ createBm25QueryV2,
16
+ searchingBm25QueryV2,
17
+ completeBm25QueryV2,
18
+ failBm25QueryV2,
19
+ cancelBm25QueryV2,
20
+ getBm25QueryV2,
21
+ listBm25QueriesV2,
22
+ setMaxActiveBm25ProfilesPerOwnerV2,
23
+ getMaxActiveBm25ProfilesPerOwnerV2,
24
+ setMaxPendingBm25QueriesPerProfileV2,
25
+ getMaxPendingBm25QueriesPerProfileV2,
26
+ setBm25ProfileIdleMsV2,
27
+ getBm25ProfileIdleMsV2,
28
+ setBm25QueryStuckMsV2,
29
+ getBm25QueryStuckMsV2,
30
+ autoStaleIdleBm25ProfilesV2,
31
+ autoFailStuckBm25QueriesV2,
32
+ getBm25SearchGovStatsV2,
33
+ } from "../lib/bm25-search.js";
34
+
35
+ export function registerBm25Command(program) {
36
+ const b = program
37
+ .command("bm25")
38
+ .description("BM25 Search V2 governance (in-memory, CLI v0.143.0)");
39
+
40
+ b.command("enums-v2").action(() =>
41
+ console.log(
42
+ JSON.stringify(
43
+ { BM25_PROFILE_MATURITY_V2, BM25_QUERY_LIFECYCLE_V2 },
44
+ null,
45
+ 2,
46
+ ),
47
+ ),
48
+ );
49
+ b.command("register-profile-v2")
50
+ .requiredOption("--id <id>")
51
+ .requiredOption("--owner <owner>")
52
+ .option("--field <field>", "indexed field", "content")
53
+ .action((o) =>
54
+ console.log(JSON.stringify(registerBm25ProfileV2(o), null, 2)),
55
+ );
56
+ b.command("activate-profile-v2 <id>").action((id) =>
57
+ console.log(JSON.stringify(activateBm25ProfileV2(id), null, 2)),
58
+ );
59
+ b.command("stale-profile-v2 <id>").action((id) =>
60
+ console.log(JSON.stringify(staleBm25ProfileV2(id), null, 2)),
61
+ );
62
+ b.command("archive-profile-v2 <id>").action((id) =>
63
+ console.log(JSON.stringify(archiveBm25ProfileV2(id), null, 2)),
64
+ );
65
+ b.command("touch-profile-v2 <id>").action((id) =>
66
+ console.log(JSON.stringify(touchBm25ProfileV2(id), null, 2)),
67
+ );
68
+ b.command("get-profile-v2 <id>").action((id) =>
69
+ console.log(JSON.stringify(getBm25ProfileV2(id), null, 2)),
70
+ );
71
+ b.command("list-profiles-v2").action(() =>
72
+ console.log(JSON.stringify(listBm25ProfilesV2(), null, 2)),
73
+ );
74
+
75
+ b.command("create-query-v2")
76
+ .requiredOption("--id <id>")
77
+ .requiredOption("--profile-id <profileId>")
78
+ .option("--q <q>", "query text", "")
79
+ .action((o) => console.log(JSON.stringify(createBm25QueryV2(o), null, 2)));
80
+ b.command("searching-query-v2 <id>").action((id) =>
81
+ console.log(JSON.stringify(searchingBm25QueryV2(id), null, 2)),
82
+ );
83
+ b.command("complete-query-v2 <id>").action((id) =>
84
+ console.log(JSON.stringify(completeBm25QueryV2(id), null, 2)),
85
+ );
86
+ b.command("fail-query-v2 <id>")
87
+ .option("--reason <r>")
88
+ .action((id, o) =>
89
+ console.log(JSON.stringify(failBm25QueryV2(id, o.reason), null, 2)),
90
+ );
91
+ b.command("cancel-query-v2 <id>")
92
+ .option("--reason <r>")
93
+ .action((id, o) =>
94
+ console.log(JSON.stringify(cancelBm25QueryV2(id, o.reason), null, 2)),
95
+ );
96
+ b.command("get-query-v2 <id>").action((id) =>
97
+ console.log(JSON.stringify(getBm25QueryV2(id), null, 2)),
98
+ );
99
+ b.command("list-queries-v2").action(() =>
100
+ console.log(JSON.stringify(listBm25QueriesV2(), null, 2)),
101
+ );
102
+
103
+ b.command("config-v2").action(() =>
104
+ console.log(
105
+ JSON.stringify(
106
+ {
107
+ maxActiveBm25ProfilesPerOwner: getMaxActiveBm25ProfilesPerOwnerV2(),
108
+ maxPendingBm25QueriesPerProfile:
109
+ getMaxPendingBm25QueriesPerProfileV2(),
110
+ bm25ProfileIdleMs: getBm25ProfileIdleMsV2(),
111
+ bm25QueryStuckMs: getBm25QueryStuckMsV2(),
112
+ },
113
+ null,
114
+ 2,
115
+ ),
116
+ ),
117
+ );
118
+ b.command("set-max-active-profiles-v2 <n>").action((n) => {
119
+ setMaxActiveBm25ProfilesPerOwnerV2(Number(n));
120
+ console.log(
121
+ JSON.stringify(
122
+ { maxActiveBm25ProfilesPerOwner: getMaxActiveBm25ProfilesPerOwnerV2() },
123
+ null,
124
+ 2,
125
+ ),
126
+ );
127
+ });
128
+ b.command("set-max-pending-queries-v2 <n>").action((n) => {
129
+ setMaxPendingBm25QueriesPerProfileV2(Number(n));
130
+ console.log(
131
+ JSON.stringify(
132
+ {
133
+ maxPendingBm25QueriesPerProfile:
134
+ getMaxPendingBm25QueriesPerProfileV2(),
135
+ },
136
+ null,
137
+ 2,
138
+ ),
139
+ );
140
+ });
141
+ b.command("set-profile-idle-ms-v2 <ms>").action((ms) => {
142
+ setBm25ProfileIdleMsV2(Number(ms));
143
+ console.log(
144
+ JSON.stringify({ bm25ProfileIdleMs: getBm25ProfileIdleMsV2() }, null, 2),
145
+ );
146
+ });
147
+ b.command("set-query-stuck-ms-v2 <ms>").action((ms) => {
148
+ setBm25QueryStuckMsV2(Number(ms));
149
+ console.log(
150
+ JSON.stringify({ bm25QueryStuckMs: getBm25QueryStuckMsV2() }, null, 2),
151
+ );
152
+ });
153
+ b.command("auto-stale-idle-v2").action(() =>
154
+ console.log(JSON.stringify(autoStaleIdleBm25ProfilesV2(), null, 2)),
155
+ );
156
+ b.command("auto-fail-stuck-v2").action(() =>
157
+ console.log(JSON.stringify(autoFailStuckBm25QueriesV2(), null, 2)),
158
+ );
159
+ b.command("gov-stats-v2").action(() =>
160
+ console.log(JSON.stringify(getBm25SearchGovStatsV2(), null, 2)),
161
+ );
162
+ }