chainlesschain 0.81.0 → 0.143.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 (209) hide show
  1. package/bin/chainlesschain.js +0 -0
  2. package/package.json +1 -1
  3. package/src/commands/a2a.js +62 -0
  4. package/src/commands/activitypub.js +61 -0
  5. package/src/commands/agent-network.js +254 -1
  6. package/src/commands/agent.js +117 -0
  7. package/src/commands/audit.js +302 -0
  8. package/src/commands/automation.js +271 -1
  9. package/src/commands/bi.js +61 -0
  10. package/src/commands/bm25.js +78 -0
  11. package/src/commands/browse.js +64 -0
  12. package/src/commands/ccron.js +78 -0
  13. package/src/commands/codegen.js +224 -0
  14. package/src/commands/collab.js +341 -0
  15. package/src/commands/compliance.js +1075 -0
  16. package/src/commands/compt.js +78 -0
  17. package/src/commands/consol.js +231 -0
  18. package/src/commands/cowork.js +263 -0
  19. package/src/commands/crosschain.js +62 -0
  20. package/src/commands/dao.js +62 -0
  21. package/src/commands/dbevo.js +284 -0
  22. package/src/commands/dev.js +252 -0
  23. package/src/commands/did.js +358 -0
  24. package/src/commands/dlp.js +61 -0
  25. package/src/commands/economy.js +56 -0
  26. package/src/commands/encrypt.js +341 -0
  27. package/src/commands/evolution.js +56 -0
  28. package/src/commands/evomap.js +61 -0
  29. package/src/commands/export.js +256 -1
  30. package/src/commands/fflag.js +178 -0
  31. package/src/commands/fusion.js +258 -0
  32. package/src/commands/git.js +45 -0
  33. package/src/commands/governance.js +325 -0
  34. package/src/commands/hardening.js +411 -0
  35. package/src/commands/hmemory.js +56 -0
  36. package/src/commands/hook.js +148 -0
  37. package/src/commands/import.js +252 -0
  38. package/src/commands/incentive.js +322 -0
  39. package/src/commands/inference.js +42 -0
  40. package/src/commands/infra.js +244 -0
  41. package/src/commands/instinct.js +260 -0
  42. package/src/commands/ipfs.js +318 -0
  43. package/src/commands/itbudget.js +45 -0
  44. package/src/commands/kg.js +387 -0
  45. package/src/commands/llm.js +263 -0
  46. package/src/commands/lowcode.js +44 -0
  47. package/src/commands/matrix.js +62 -0
  48. package/src/commands/mcp.js +221 -0
  49. package/src/commands/mcpscaf.js +41 -0
  50. package/src/commands/meminj.js +41 -0
  51. package/src/commands/memory.js +248 -0
  52. package/src/commands/multimodal.js +296 -0
  53. package/src/commands/nlprog.js +356 -0
  54. package/src/commands/nostr.js +62 -0
  55. package/src/commands/note.js +244 -0
  56. package/src/commands/ops.js +354 -0
  57. package/src/commands/orchestrate.js +166 -0
  58. package/src/commands/orchgov.js +45 -0
  59. package/src/commands/org.js +277 -0
  60. package/src/commands/p2p.js +390 -0
  61. package/src/commands/pdfp.js +78 -0
  62. package/src/commands/perception.js +290 -0
  63. package/src/commands/perf.js +39 -0
  64. package/src/commands/perm.js +45 -0
  65. package/src/commands/permmem.js +251 -0
  66. package/src/commands/pipeline.js +57 -1
  67. package/src/commands/planmode.js +45 -0
  68. package/src/commands/plugin-ecosystem.js +273 -0
  69. package/src/commands/pqc.js +393 -0
  70. package/src/commands/promcomp.js +82 -0
  71. package/src/commands/quantization.js +351 -0
  72. package/src/commands/rcache.js +271 -0
  73. package/src/commands/recommend.js +382 -0
  74. package/src/commands/runtime.js +307 -0
  75. package/src/commands/scim.js +262 -0
  76. package/src/commands/seshhook.js +41 -0
  77. package/src/commands/seshsearch.js +41 -0
  78. package/src/commands/seshtail.js +41 -0
  79. package/src/commands/seshu.js +41 -0
  80. package/src/commands/session.js +258 -0
  81. package/src/commands/sganal.js +78 -0
  82. package/src/commands/siem.js +40 -0
  83. package/src/commands/skill.js +267 -1
  84. package/src/commands/slotfill.js +41 -0
  85. package/src/commands/social.js +290 -0
  86. package/src/commands/sso.js +186 -1
  87. package/src/commands/svccont.js +45 -0
  88. package/src/commands/sync.js +256 -0
  89. package/src/commands/tech.js +338 -0
  90. package/src/commands/tenant.js +351 -0
  91. package/src/commands/tms.js +45 -0
  92. package/src/commands/tokens.js +269 -0
  93. package/src/commands/topiccls.js +45 -0
  94. package/src/commands/trust.js +249 -0
  95. package/src/commands/uprof.js +45 -0
  96. package/src/commands/vcheck.js +78 -0
  97. package/src/commands/wallet.js +277 -0
  98. package/src/commands/webfetch.js +41 -0
  99. package/src/commands/workflow.js +171 -0
  100. package/src/commands/zkp.js +62 -0
  101. package/src/harness/prompt-compressor.js +331 -0
  102. package/src/index.js +65 -1
  103. package/src/lib/a2a-protocol.js +105 -0
  104. package/src/lib/activitypub-bridge.js +105 -0
  105. package/src/lib/agent-coordinator.js +325 -0
  106. package/src/lib/agent-economy.js +105 -0
  107. package/src/lib/agent-network.js +387 -0
  108. package/src/lib/agent-router.js +395 -0
  109. package/src/lib/aiops.js +478 -0
  110. package/src/lib/app-builder.js +105 -0
  111. package/src/lib/audit-logger.js +379 -0
  112. package/src/lib/automation-engine.js +330 -0
  113. package/src/lib/autonomous-agent.js +105 -0
  114. package/src/lib/autonomous-developer.js +350 -0
  115. package/src/lib/bi-engine.js +105 -0
  116. package/src/lib/bm25-search.js +81 -0
  117. package/src/lib/browser-automation.js +105 -0
  118. package/src/lib/code-agent.js +323 -0
  119. package/src/lib/collaboration-governance.js +364 -0
  120. package/src/lib/community-governance.js +436 -0
  121. package/src/lib/compliance-framework-reporter.js +105 -0
  122. package/src/lib/compliance-manager.js +434 -0
  123. package/src/lib/compression-telemetry.js +81 -0
  124. package/src/lib/content-recommendation.js +469 -0
  125. package/src/lib/content-recommender.js +105 -0
  126. package/src/lib/cowork-cron.js +81 -0
  127. package/src/lib/cowork-task-runner.js +105 -0
  128. package/src/lib/cross-chain.js +105 -0
  129. package/src/lib/crypto-manager.js +350 -0
  130. package/src/lib/dao-governance.js +105 -0
  131. package/src/lib/dbevo.js +338 -0
  132. package/src/lib/decentral-infra.js +340 -0
  133. package/src/lib/did-manager.js +367 -0
  134. package/src/lib/dlp-engine.js +105 -0
  135. package/src/lib/evolution-system.js +105 -0
  136. package/src/lib/evomap-manager.js +105 -0
  137. package/src/lib/execution-backend.js +105 -0
  138. package/src/lib/feature-flags.js +85 -0
  139. package/src/lib/git-integration.js +105 -0
  140. package/src/lib/hardening-manager.js +348 -0
  141. package/src/lib/hierarchical-memory.js +105 -0
  142. package/src/lib/hook-manager.js +380 -0
  143. package/src/lib/inference-network.js +105 -0
  144. package/src/lib/instinct-manager.js +332 -0
  145. package/src/lib/ipfs-storage.js +334 -0
  146. package/src/lib/iteration-budget.js +105 -0
  147. package/src/lib/knowledge-exporter.js +381 -0
  148. package/src/lib/knowledge-graph.js +432 -0
  149. package/src/lib/knowledge-importer.js +379 -0
  150. package/src/lib/llm-providers.js +391 -0
  151. package/src/lib/matrix-bridge.js +105 -0
  152. package/src/lib/mcp-registry.js +333 -0
  153. package/src/lib/mcp-scaffold.js +81 -0
  154. package/src/lib/memory-injection.js +81 -0
  155. package/src/lib/memory-manager.js +330 -0
  156. package/src/lib/multimodal.js +346 -0
  157. package/src/lib/nl-programming.js +343 -0
  158. package/src/lib/nostr-bridge.js +105 -0
  159. package/src/lib/note-versioning.js +327 -0
  160. package/src/lib/orchestrator.js +105 -0
  161. package/src/lib/org-manager.js +323 -0
  162. package/src/lib/p2p-manager.js +387 -0
  163. package/src/lib/pdf-parser.js +81 -0
  164. package/src/lib/perception.js +346 -0
  165. package/src/lib/perf-tuning.js +109 -1
  166. package/src/lib/permanent-memory.js +320 -0
  167. package/src/lib/permission-engine.js +81 -0
  168. package/src/lib/pipeline-orchestrator.js +105 -0
  169. package/src/lib/plan-mode.js +81 -0
  170. package/src/lib/plugin-ecosystem.js +377 -0
  171. package/src/lib/pqc-manager.js +368 -0
  172. package/src/lib/prompt-compressor.js +1 -10
  173. package/src/lib/protocol-fusion.js +417 -0
  174. package/src/lib/quantization.js +325 -0
  175. package/src/lib/response-cache.js +327 -0
  176. package/src/lib/scim-manager.js +329 -0
  177. package/src/lib/service-container.js +81 -0
  178. package/src/lib/session-consolidator.js +105 -0
  179. package/src/lib/session-hooks.js +81 -0
  180. package/src/lib/session-manager.js +329 -0
  181. package/src/lib/session-search.js +81 -0
  182. package/src/lib/session-tail.js +81 -0
  183. package/src/lib/session-usage.js +83 -0
  184. package/src/lib/siem-exporter.js +105 -0
  185. package/src/lib/skill-loader.js +377 -0
  186. package/src/lib/slot-filler.js +81 -0
  187. package/src/lib/social-graph-analytics.js +81 -0
  188. package/src/lib/social-graph.js +81 -0
  189. package/src/lib/social-manager.js +326 -0
  190. package/src/lib/sso-manager.js +332 -0
  191. package/src/lib/sub-agent-registry.js +110 -0
  192. package/src/lib/sync-manager.js +326 -0
  193. package/src/lib/task-model-selector.js +81 -0
  194. package/src/lib/tech-learning-engine.js +369 -0
  195. package/src/lib/tenant-saas.js +460 -0
  196. package/src/lib/threat-intel.js +335 -0
  197. package/src/lib/todo-manager.js +105 -0
  198. package/src/lib/token-incentive.js +293 -0
  199. package/src/lib/token-tracker.js +329 -0
  200. package/src/lib/topic-classifier.js +105 -0
  201. package/src/lib/trust-security.js +390 -0
  202. package/src/lib/ueba.js +389 -0
  203. package/src/lib/universal-runtime.js +325 -0
  204. package/src/lib/user-profile.js +81 -0
  205. package/src/lib/version-checker.js +81 -0
  206. package/src/lib/wallet-manager.js +326 -0
  207. package/src/lib/web-fetch.js +81 -0
  208. package/src/lib/workflow-engine.js +322 -0
  209. package/src/lib/zkp-engine.js +105 -0
@@ -11,7 +11,41 @@ import ora from "ora";
11
11
  import fs from "fs";
12
12
  import path from "path";
13
13
  import { logger } from "../lib/logger.js";
14
- import { CLISkillLoader, LAYER_NAMES } from "../lib/skill-loader.js";
14
+ import {
15
+ CLISkillLoader,
16
+ LAYER_NAMES,
17
+ SKILL_MATURITY_V2,
18
+ EXECUTION_LIFECYCLE_V2,
19
+ getMaxActiveSkillsPerOwnerV2,
20
+ setMaxActiveSkillsPerOwnerV2,
21
+ getMaxPendingExecutionsPerSkillV2,
22
+ setMaxPendingExecutionsPerSkillV2,
23
+ getSkillIdleMsV2,
24
+ setSkillIdleMsV2,
25
+ getExecStuckMsV2,
26
+ setExecStuckMsV2,
27
+ registerSkillV2,
28
+ getSkillV2,
29
+ listSkillsV2,
30
+ setSkillStatusV2,
31
+ activateSkillV2,
32
+ deprecateSkillV2,
33
+ archiveSkillV2,
34
+ touchSkillV2,
35
+ getActiveSkillCountV2,
36
+ createExecutionV2,
37
+ getExecutionV2,
38
+ listExecutionsV2,
39
+ setExecutionStatusV2,
40
+ startExecutionV2,
41
+ succeedExecutionV2,
42
+ failExecutionV2,
43
+ cancelExecutionV2,
44
+ getPendingExecutionCountV2,
45
+ autoDeprecateIdleSkillsV2,
46
+ autoFailStuckExecutionsV2,
47
+ getSkillLoaderStatsV2,
48
+ } from "../lib/skill-loader.js";
15
49
  import { getElectronUserDataDir } from "../lib/paths.js";
16
50
  import { findProjectRoot } from "../lib/project-detector.js";
17
51
  import {
@@ -695,4 +729,236 @@ export function registerSkillCommand(program) {
695
729
  ` ${chalk.bold("Total:")} ${allSkills.length} skills resolved\n`,
696
730
  );
697
731
  });
732
+
733
+ // ─── V2 Governance Layer ──────────────────────────────────────────
734
+ const out = (obj) => console.log(JSON.stringify(obj, null, 2));
735
+ const tryRun = (fn) => {
736
+ try {
737
+ fn();
738
+ } catch (err) {
739
+ logger.error(err.message);
740
+ process.exit(1);
741
+ }
742
+ };
743
+
744
+ skill
745
+ .command("skill-maturities-v2")
746
+ .description("List V2 skill maturity states")
747
+ .action(() => out(Object.values(SKILL_MATURITY_V2)));
748
+
749
+ skill
750
+ .command("execution-lifecycles-v2")
751
+ .description("List V2 execution lifecycle states")
752
+ .action(() => out(Object.values(EXECUTION_LIFECYCLE_V2)));
753
+
754
+ skill
755
+ .command("stats-v2")
756
+ .description("V2 skill-loader stats")
757
+ .action(() => out(getSkillLoaderStatsV2()));
758
+
759
+ skill
760
+ .command("get-max-active-skills-v2")
761
+ .description("Get max active skills per owner (V2)")
762
+ .action(() =>
763
+ out({ maxActiveSkillsPerOwner: getMaxActiveSkillsPerOwnerV2() }),
764
+ );
765
+
766
+ skill
767
+ .command("set-max-active-skills-v2 <n>")
768
+ .description("Set max active skills per owner (V2)")
769
+ .action((n) =>
770
+ tryRun(() => {
771
+ setMaxActiveSkillsPerOwnerV2(Number(n));
772
+ out({ maxActiveSkillsPerOwner: getMaxActiveSkillsPerOwnerV2() });
773
+ }),
774
+ );
775
+
776
+ skill
777
+ .command("get-max-pending-executions-v2")
778
+ .description("Get max pending executions per skill (V2)")
779
+ .action(() =>
780
+ out({
781
+ maxPendingExecutionsPerSkill: getMaxPendingExecutionsPerSkillV2(),
782
+ }),
783
+ );
784
+
785
+ skill
786
+ .command("set-max-pending-executions-v2 <n>")
787
+ .description("Set max pending executions per skill (V2)")
788
+ .action((n) =>
789
+ tryRun(() => {
790
+ setMaxPendingExecutionsPerSkillV2(Number(n));
791
+ out({
792
+ maxPendingExecutionsPerSkill: getMaxPendingExecutionsPerSkillV2(),
793
+ });
794
+ }),
795
+ );
796
+
797
+ skill
798
+ .command("get-skill-idle-ms-v2")
799
+ .description("Get skill idle threshold (V2)")
800
+ .action(() => out({ skillIdleMs: getSkillIdleMsV2() }));
801
+
802
+ skill
803
+ .command("set-skill-idle-ms-v2 <ms>")
804
+ .description("Set skill idle threshold (V2)")
805
+ .action((ms) =>
806
+ tryRun(() => {
807
+ setSkillIdleMsV2(Number(ms));
808
+ out({ skillIdleMs: getSkillIdleMsV2() });
809
+ }),
810
+ );
811
+
812
+ skill
813
+ .command("get-exec-stuck-ms-v2")
814
+ .description("Get execution stuck threshold (V2)")
815
+ .action(() => out({ execStuckMs: getExecStuckMsV2() }));
816
+
817
+ skill
818
+ .command("set-exec-stuck-ms-v2 <ms>")
819
+ .description("Set execution stuck threshold (V2)")
820
+ .action((ms) =>
821
+ tryRun(() => {
822
+ setExecStuckMsV2(Number(ms));
823
+ out({ execStuckMs: getExecStuckMsV2() });
824
+ }),
825
+ );
826
+
827
+ skill
828
+ .command("active-skill-count-v2 <ownerId>")
829
+ .description("Active skill count for owner (V2)")
830
+ .action((ownerId) =>
831
+ out({ ownerId, count: getActiveSkillCountV2(ownerId) }),
832
+ );
833
+
834
+ skill
835
+ .command("pending-execution-count-v2 <skillId>")
836
+ .description("Pending execution count for skill (V2)")
837
+ .action((skillId) =>
838
+ out({ skillId, count: getPendingExecutionCountV2(skillId) }),
839
+ );
840
+
841
+ skill
842
+ .command("register-skill-v2 <id>")
843
+ .description("Register a V2 skill")
844
+ .requiredOption("-o, --owner <id>", "owner id")
845
+ .requiredOption("-n, --name <name>", "skill name")
846
+ .option("-l, --layer <layer>", "skill layer", "workspace")
847
+ .action((id, opts) =>
848
+ tryRun(() =>
849
+ out(
850
+ registerSkillV2(id, {
851
+ ownerId: opts.owner,
852
+ name: opts.name,
853
+ layer: opts.layer,
854
+ }),
855
+ ),
856
+ ),
857
+ );
858
+
859
+ skill
860
+ .command("get-skill-v2 <id>")
861
+ .description("Get a V2 skill")
862
+ .action((id) => out(getSkillV2(id)));
863
+
864
+ skill
865
+ .command("list-skills-v2")
866
+ .description("List V2 skills")
867
+ .option("-o, --owner <id>", "filter by owner")
868
+ .option("-s, --status <status>", "filter by status")
869
+ .option("-l, --layer <layer>", "filter by layer")
870
+ .action((opts) =>
871
+ out(
872
+ listSkillsV2({
873
+ ownerId: opts.owner,
874
+ status: opts.status,
875
+ layer: opts.layer,
876
+ }),
877
+ ),
878
+ );
879
+
880
+ skill
881
+ .command("set-skill-status-v2 <id> <next>")
882
+ .description("Set V2 skill status")
883
+ .action((id, next) => tryRun(() => out(setSkillStatusV2(id, next))));
884
+
885
+ skill
886
+ .command("activate-skill-v2 <id>")
887
+ .description("Activate a V2 skill")
888
+ .action((id) => tryRun(() => out(activateSkillV2(id))));
889
+
890
+ skill
891
+ .command("deprecate-skill-v2 <id>")
892
+ .description("Deprecate a V2 skill")
893
+ .action((id) => tryRun(() => out(deprecateSkillV2(id))));
894
+
895
+ skill
896
+ .command("archive-skill-v2 <id>")
897
+ .description("Archive a V2 skill")
898
+ .action((id) => tryRun(() => out(archiveSkillV2(id))));
899
+
900
+ skill
901
+ .command("touch-skill-v2 <id>")
902
+ .description("Touch a V2 skill")
903
+ .action((id) => tryRun(() => out(touchSkillV2(id))));
904
+
905
+ skill
906
+ .command("create-execution-v2 <id>")
907
+ .description("Create a V2 execution")
908
+ .requiredOption("-s, --skill <id>", "skill id")
909
+ .option("-k, --kind <kind>", "execution kind", "invoke")
910
+ .action((id, opts) =>
911
+ tryRun(() =>
912
+ out(createExecutionV2(id, { skillId: opts.skill, kind: opts.kind })),
913
+ ),
914
+ );
915
+
916
+ skill
917
+ .command("get-execution-v2 <id>")
918
+ .description("Get a V2 execution")
919
+ .action((id) => out(getExecutionV2(id)));
920
+
921
+ skill
922
+ .command("list-executions-v2")
923
+ .description("List V2 executions")
924
+ .option("-s, --skill <id>", "filter by skill")
925
+ .option("-t, --status <status>", "filter by status")
926
+ .action((opts) =>
927
+ out(listExecutionsV2({ skillId: opts.skill, status: opts.status })),
928
+ );
929
+
930
+ skill
931
+ .command("set-execution-status-v2 <id> <next>")
932
+ .description("Set V2 execution status")
933
+ .action((id, next) => tryRun(() => out(setExecutionStatusV2(id, next))));
934
+
935
+ skill
936
+ .command("start-execution-v2 <id>")
937
+ .description("Start a V2 execution")
938
+ .action((id) => tryRun(() => out(startExecutionV2(id))));
939
+
940
+ skill
941
+ .command("succeed-execution-v2 <id>")
942
+ .description("Succeed a V2 execution")
943
+ .action((id) => tryRun(() => out(succeedExecutionV2(id))));
944
+
945
+ skill
946
+ .command("fail-execution-v2 <id>")
947
+ .description("Fail a V2 execution")
948
+ .action((id) => tryRun(() => out(failExecutionV2(id))));
949
+
950
+ skill
951
+ .command("cancel-execution-v2 <id>")
952
+ .description("Cancel a V2 execution")
953
+ .action((id) => tryRun(() => out(cancelExecutionV2(id))));
954
+
955
+ skill
956
+ .command("auto-deprecate-idle-skills-v2")
957
+ .description("Auto-deprecate idle V2 skills")
958
+ .action(() => out(autoDeprecateIdleSkillsV2()));
959
+
960
+ skill
961
+ .command("auto-fail-stuck-executions-v2")
962
+ .description("Auto-fail stuck V2 executions")
963
+ .action(() => out(autoFailStuckExecutionsV2()));
698
964
  }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * `cc slotfill` — Slot Filler V2 governance overlay (in-memory, atop lib/slot-filler.js).
3
+ */
4
+ import {
5
+ SLOTF_PROFILE_MATURITY_V2, SLOTF_FILL_LIFECYCLE_V2,
6
+ setMaxActiveSlotfTemplatesPerOwnerV2, getMaxActiveSlotfTemplatesPerOwnerV2,
7
+ setMaxPendingSlotfFillsPerTemplateV2, getMaxPendingSlotfFillsPerTemplateV2,
8
+ setSlotfTemplateIdleMsV2, getSlotfTemplateIdleMsV2,
9
+ setSlotfFillStuckMsV2, getSlotfFillStuckMsV2,
10
+ registerSlotfTemplateV2, activateSlotfTemplateV2, staleSlotfTemplateV2, archiveSlotfTemplateV2, touchSlotfTemplateV2, getSlotfTemplateV2, listSlotfTemplatesV2,
11
+ createSlotfFillV2, fillingSlotfFillV2, fillSlotfFillV2, failSlotfFillV2, cancelSlotfFillV2, getSlotfFillV2, listSlotfFillsV2,
12
+ autoStaleIdleSlotfTemplatesV2, autoFailStuckSlotfFillsV2, getSlotFillerGovStatsV2, _resetStateSlotFillerV2,
13
+ } from "../lib/slot-filler.js";
14
+
15
+ export function registerSlotfillCommand(program) {
16
+ const sf = program.command("slotfill").description("Slot Filler V2 governance");
17
+ sf.command("enums-v2").action(() => console.log(JSON.stringify({ profileMaturity: SLOTF_PROFILE_MATURITY_V2, fillLifecycle: SLOTF_FILL_LIFECYCLE_V2 }, null, 2)));
18
+ sf.command("config-v2").action(() => console.log(JSON.stringify({ maxActiveSlotfTemplatesPerOwner: getMaxActiveSlotfTemplatesPerOwnerV2(), maxPendingSlotfFillsPerTemplate: getMaxPendingSlotfFillsPerTemplateV2(), slotfTemplateIdleMs: getSlotfTemplateIdleMsV2(), slotfFillStuckMs: getSlotfFillStuckMsV2() }, null, 2)));
19
+ sf.command("set-max-active-v2 <n>").action((n) => { setMaxActiveSlotfTemplatesPerOwnerV2(Number(n)); console.log("ok"); });
20
+ sf.command("set-max-pending-v2 <n>").action((n) => { setMaxPendingSlotfFillsPerTemplateV2(Number(n)); console.log("ok"); });
21
+ sf.command("set-idle-ms-v2 <n>").action((n) => { setSlotfTemplateIdleMsV2(Number(n)); console.log("ok"); });
22
+ sf.command("set-stuck-ms-v2 <n>").action((n) => { setSlotfFillStuckMsV2(Number(n)); console.log("ok"); });
23
+ sf.command("register-template-v2 <id> <owner>").option("--schema <s>", "schema").action((id, owner, o) => console.log(JSON.stringify(registerSlotfTemplateV2({ id, owner, schema: o.schema }), null, 2)));
24
+ sf.command("activate-template-v2 <id>").action((id) => console.log(JSON.stringify(activateSlotfTemplateV2(id), null, 2)));
25
+ sf.command("stale-template-v2 <id>").action((id) => console.log(JSON.stringify(staleSlotfTemplateV2(id), null, 2)));
26
+ sf.command("archive-template-v2 <id>").action((id) => console.log(JSON.stringify(archiveSlotfTemplateV2(id), null, 2)));
27
+ sf.command("touch-template-v2 <id>").action((id) => console.log(JSON.stringify(touchSlotfTemplateV2(id), null, 2)));
28
+ sf.command("get-template-v2 <id>").action((id) => console.log(JSON.stringify(getSlotfTemplateV2(id), null, 2)));
29
+ sf.command("list-templates-v2").action(() => console.log(JSON.stringify(listSlotfTemplatesV2(), null, 2)));
30
+ sf.command("create-fill-v2 <id> <templateId>").option("--input <s>", "input").action((id, templateId, o) => console.log(JSON.stringify(createSlotfFillV2({ id, templateId, input: o.input }), null, 2)));
31
+ sf.command("filling-fill-v2 <id>").action((id) => console.log(JSON.stringify(fillingSlotfFillV2(id), null, 2)));
32
+ sf.command("fill-fill-v2 <id>").action((id) => console.log(JSON.stringify(fillSlotfFillV2(id), null, 2)));
33
+ sf.command("fail-fill-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(failSlotfFillV2(id, reason), null, 2)));
34
+ sf.command("cancel-fill-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(cancelSlotfFillV2(id, reason), null, 2)));
35
+ sf.command("get-fill-v2 <id>").action((id) => console.log(JSON.stringify(getSlotfFillV2(id), null, 2)));
36
+ sf.command("list-fills-v2").action(() => console.log(JSON.stringify(listSlotfFillsV2(), null, 2)));
37
+ sf.command("auto-stale-idle-v2").action(() => console.log(JSON.stringify(autoStaleIdleSlotfTemplatesV2(), null, 2)));
38
+ sf.command("auto-fail-stuck-v2").action(() => console.log(JSON.stringify(autoFailStuckSlotfFillsV2(), null, 2)));
39
+ sf.command("gov-stats-v2").action(() => console.log(JSON.stringify(getSlotFillerGovStatsV2(), null, 2)));
40
+ sf.command("reset-state-v2").action(() => { _resetStateSlotFillerV2(); console.log(JSON.stringify({ ok: true }, null, 2)); });
41
+ }
@@ -23,6 +23,35 @@ import {
23
23
  getChatMessages,
24
24
  getChatThreads,
25
25
  getSocialStats,
26
+ RELATIONSHIP_MATURITY_V2,
27
+ THREAD_LIFECYCLE_V2,
28
+ getMaxConnectedPerUserV2,
29
+ setMaxConnectedPerUserV2,
30
+ getMaxOpenThreadsPerUserV2,
31
+ setMaxOpenThreadsPerUserV2,
32
+ getRelationshipIdleMsV2,
33
+ setRelationshipIdleMsV2,
34
+ getThreadStuckMsV2,
35
+ setThreadStuckMsV2,
36
+ getConnectedCountV2,
37
+ getOpenThreadCountV2,
38
+ registerRelationshipV2,
39
+ getRelationshipV2,
40
+ listRelationshipsV2,
41
+ connectRelationshipV2,
42
+ muteRelationshipV2,
43
+ blockRelationshipV2,
44
+ touchRelationshipV2,
45
+ createThreadV2,
46
+ getThreadV2,
47
+ listThreadsV2,
48
+ engageThreadV2,
49
+ resolveThreadV2,
50
+ abandonThreadV2,
51
+ reportThreadV2,
52
+ autoMuteIdleRelationshipsV2,
53
+ autoAbandonStuckThreadsV2,
54
+ getSocialManagerStatsV2,
26
55
  } from "../lib/social-manager.js";
27
56
  import { classifyTopic, detectLanguage } from "../lib/topic-classifier.js";
28
57
  import {
@@ -34,6 +63,14 @@ import {
34
63
  loadFromDb as graphLoadFromDb,
35
64
  subscribe as graphSubscribe,
36
65
  EDGE_TYPES,
66
+ SG_NODE_MATURITY_V2, SG_EDGE_LIFECYCLE_V2,
67
+ setMaxActiveSgNodesPerOwnerV2, getMaxActiveSgNodesPerOwnerV2,
68
+ setMaxPendingSgEdgesPerNodeV2, getMaxPendingSgEdgesPerNodeV2,
69
+ setSgNodeIdleMsV2, getSgNodeIdleMsV2,
70
+ setSgEdgeStuckMsV2, getSgEdgeStuckMsV2,
71
+ registerSgNodeV2, activateSgNodeV2, deactivateSgNodeV2, removeSgNodeV2, touchSgNodeV2, getSgNodeV2, listSgNodesV2,
72
+ createSgEdgeV2, establishSgEdgeV2, severSgEdgeV2, expireSgEdgeV2, cancelSgEdgeV2, getSgEdgeV2, listSgEdgesV2,
73
+ autoDeactivateIdleSgNodesV2, autoExpireStaleSgEdgesV2, getSocialGraphGovStatsV2, _resetStateSocialGraphV2,
37
74
  } from "../lib/social-graph.js";
38
75
  import {
39
76
  METRICS as ANALYTICS_METRICS,
@@ -1053,4 +1090,257 @@ export function registerSocialCommand(program) {
1053
1090
  process.exit(1);
1054
1091
  }
1055
1092
  });
1093
+
1094
+ // ─────────────────────────────────────────────────────────────
1095
+ // V2 Surface — relationship + thread lifecycle (in-memory, throwing)
1096
+ // ─────────────────────────────────────────────────────────────
1097
+
1098
+ social
1099
+ .command("relationship-maturities-v2")
1100
+ .description("List V2 relationship maturity states")
1101
+ .option("--json", "Output as JSON")
1102
+ .action((options) => {
1103
+ const v = Object.values(RELATIONSHIP_MATURITY_V2);
1104
+ if (options.json) console.log(JSON.stringify(v));
1105
+ else logger.log(v.join(", "));
1106
+ });
1107
+
1108
+ social
1109
+ .command("thread-lifecycles-v2")
1110
+ .description("List V2 thread lifecycle states")
1111
+ .option("--json", "Output as JSON")
1112
+ .action((options) => {
1113
+ const v = Object.values(THREAD_LIFECYCLE_V2);
1114
+ if (options.json) console.log(JSON.stringify(v));
1115
+ else logger.log(v.join(", "));
1116
+ });
1117
+
1118
+ social
1119
+ .command("stats-v2")
1120
+ .description("Show V2 social stats")
1121
+ .option("--json", "Output as JSON")
1122
+ .action((options) => {
1123
+ const stats = getSocialManagerStatsV2();
1124
+ if (options.json) console.log(JSON.stringify(stats, null, 2));
1125
+ else logger.log(JSON.stringify(stats, null, 2));
1126
+ });
1127
+
1128
+ social
1129
+ .command("get-max-connected-v2")
1130
+ .description("Get max connected per user")
1131
+ .action(() => logger.log(String(getMaxConnectedPerUserV2())));
1132
+ social
1133
+ .command("set-max-connected-v2 <n>")
1134
+ .description("Set max connected per user")
1135
+ .action((n) => {
1136
+ setMaxConnectedPerUserV2(Number(n));
1137
+ logger.log(String(getMaxConnectedPerUserV2()));
1138
+ });
1139
+ social
1140
+ .command("get-max-open-threads-v2")
1141
+ .description("Get max open threads per user")
1142
+ .action(() => logger.log(String(getMaxOpenThreadsPerUserV2())));
1143
+ social
1144
+ .command("set-max-open-threads-v2 <n>")
1145
+ .description("Set max open threads per user")
1146
+ .action((n) => {
1147
+ setMaxOpenThreadsPerUserV2(Number(n));
1148
+ logger.log(String(getMaxOpenThreadsPerUserV2()));
1149
+ });
1150
+ social
1151
+ .command("get-relationship-idle-ms-v2")
1152
+ .description("Get relationship idle ms")
1153
+ .action(() => logger.log(String(getRelationshipIdleMsV2())));
1154
+ social
1155
+ .command("set-relationship-idle-ms-v2 <ms>")
1156
+ .description("Set relationship idle ms")
1157
+ .action((ms) => {
1158
+ setRelationshipIdleMsV2(Number(ms));
1159
+ logger.log(String(getRelationshipIdleMsV2()));
1160
+ });
1161
+ social
1162
+ .command("get-thread-stuck-ms-v2")
1163
+ .description("Get thread stuck ms")
1164
+ .action(() => logger.log(String(getThreadStuckMsV2())));
1165
+ social
1166
+ .command("set-thread-stuck-ms-v2 <ms>")
1167
+ .description("Set thread stuck ms")
1168
+ .action((ms) => {
1169
+ setThreadStuckMsV2(Number(ms));
1170
+ logger.log(String(getThreadStuckMsV2()));
1171
+ });
1172
+
1173
+ social
1174
+ .command("connected-count-v2 <userId>")
1175
+ .description("Count connected relationships for user")
1176
+ .action((userId) => logger.log(String(getConnectedCountV2(userId))));
1177
+ social
1178
+ .command("open-thread-count-v2 <userId>")
1179
+ .description("Count open+engaged threads for user")
1180
+ .action((userId) => logger.log(String(getOpenThreadCountV2(userId))));
1181
+
1182
+ social
1183
+ .command("register-relationship-v2 <id>")
1184
+ .description("Register V2 relationship (initial=pending)")
1185
+ .requiredOption("-u, --user <userId>", "user id")
1186
+ .requiredOption("-p, --peer <peerId>", "peer id")
1187
+ .option("-m, --metadata <json>", "metadata JSON", "{}")
1188
+ .action((id, opts) => {
1189
+ const meta = JSON.parse(opts.metadata);
1190
+ const r = registerRelationshipV2(id, {
1191
+ userId: opts.user,
1192
+ peerId: opts.peer,
1193
+ metadata: meta,
1194
+ });
1195
+ console.log(JSON.stringify(r, null, 2));
1196
+ });
1197
+
1198
+ social
1199
+ .command("get-relationship-v2 <id>")
1200
+ .description("Get V2 relationship by id")
1201
+ .action((id) => {
1202
+ const r = getRelationshipV2(id);
1203
+ if (!r) {
1204
+ logger.error(`relationship ${id} not found`);
1205
+ process.exit(1);
1206
+ }
1207
+ console.log(JSON.stringify(r, null, 2));
1208
+ });
1209
+
1210
+ social
1211
+ .command("list-relationships-v2")
1212
+ .description("List V2 relationships")
1213
+ .option("-u, --user <userId>", "filter by user")
1214
+ .option("-s, --status <state>", "filter by status")
1215
+ .action((opts) => {
1216
+ const out = listRelationshipsV2({
1217
+ userId: opts.user,
1218
+ status: opts.status,
1219
+ });
1220
+ console.log(JSON.stringify(out, null, 2));
1221
+ });
1222
+
1223
+ social
1224
+ .command("connect-relationship-v2 <id>")
1225
+ .description("Transition relationship → connected")
1226
+ .action((id) =>
1227
+ console.log(JSON.stringify(connectRelationshipV2(id), null, 2)),
1228
+ );
1229
+ social
1230
+ .command("mute-relationship-v2 <id>")
1231
+ .description("Transition relationship → muted")
1232
+ .action((id) =>
1233
+ console.log(JSON.stringify(muteRelationshipV2(id), null, 2)),
1234
+ );
1235
+ social
1236
+ .command("block-relationship-v2 <id>")
1237
+ .description("Transition relationship → blocked (terminal)")
1238
+ .action((id) =>
1239
+ console.log(JSON.stringify(blockRelationshipV2(id), null, 2)),
1240
+ );
1241
+ social
1242
+ .command("touch-relationship-v2 <id>")
1243
+ .description("Update relationship lastSeenAt")
1244
+ .action((id) =>
1245
+ console.log(JSON.stringify(touchRelationshipV2(id), null, 2)),
1246
+ );
1247
+
1248
+ social
1249
+ .command("create-thread-v2 <id>")
1250
+ .description("Create V2 thread (initial=open)")
1251
+ .requiredOption("-u, --user <userId>", "user id")
1252
+ .requiredOption("-t, --topic <topic>", "topic")
1253
+ .option("-m, --metadata <json>", "metadata JSON", "{}")
1254
+ .action((id, opts) => {
1255
+ const meta = JSON.parse(opts.metadata);
1256
+ const t = createThreadV2(id, {
1257
+ userId: opts.user,
1258
+ topic: opts.topic,
1259
+ metadata: meta,
1260
+ });
1261
+ console.log(JSON.stringify(t, null, 2));
1262
+ });
1263
+
1264
+ social
1265
+ .command("get-thread-v2 <id>")
1266
+ .description("Get V2 thread by id")
1267
+ .action((id) => {
1268
+ const t = getThreadV2(id);
1269
+ if (!t) {
1270
+ logger.error(`thread ${id} not found`);
1271
+ process.exit(1);
1272
+ }
1273
+ console.log(JSON.stringify(t, null, 2));
1274
+ });
1275
+
1276
+ social
1277
+ .command("list-threads-v2")
1278
+ .description("List V2 threads")
1279
+ .option("-u, --user <userId>", "filter by user")
1280
+ .option("-s, --status <state>", "filter by status")
1281
+ .action((opts) => {
1282
+ const out = listThreadsV2({
1283
+ userId: opts.user,
1284
+ status: opts.status,
1285
+ });
1286
+ console.log(JSON.stringify(out, null, 2));
1287
+ });
1288
+
1289
+ social
1290
+ .command("engage-thread-v2 <id>")
1291
+ .description("Transition thread → engaged")
1292
+ .action((id) => console.log(JSON.stringify(engageThreadV2(id), null, 2)));
1293
+ social
1294
+ .command("resolve-thread-v2 <id>")
1295
+ .description("Transition thread → resolved (terminal)")
1296
+ .action((id) => console.log(JSON.stringify(resolveThreadV2(id), null, 2)));
1297
+ social
1298
+ .command("abandon-thread-v2 <id>")
1299
+ .description("Transition thread → abandoned (terminal)")
1300
+ .action((id) => console.log(JSON.stringify(abandonThreadV2(id), null, 2)));
1301
+ social
1302
+ .command("report-thread-v2 <id>")
1303
+ .description("Transition thread → reported (terminal)")
1304
+ .action((id) => console.log(JSON.stringify(reportThreadV2(id), null, 2)));
1305
+
1306
+ social
1307
+ .command("auto-mute-idle-rel-v2")
1308
+ .description("Auto-mute idle connected relationships; output flipped")
1309
+ .action(() => {
1310
+ const flipped = autoMuteIdleRelationshipsV2();
1311
+ console.log(JSON.stringify(flipped, null, 2));
1312
+ });
1313
+ social
1314
+ .command("auto-abandon-stuck-threads-v2")
1315
+ .description("Auto-abandon stuck threads; output flipped")
1316
+ .action(() => {
1317
+ const flipped = autoAbandonStuckThreadsV2();
1318
+ console.log(JSON.stringify(flipped, null, 2));
1319
+ });
1320
+
1321
+ // ===== Social Graph V2 governance overlay (sg-*-v2 prefix) =====
1322
+ social.command("sg-enums-v2").action(() => console.log(JSON.stringify({ nodeMaturity: SG_NODE_MATURITY_V2, edgeLifecycle: SG_EDGE_LIFECYCLE_V2 }, null, 2)));
1323
+ social.command("sg-config-v2").action(() => console.log(JSON.stringify({ maxActiveSgNodesPerOwner: getMaxActiveSgNodesPerOwnerV2(), maxPendingSgEdgesPerNode: getMaxPendingSgEdgesPerNodeV2(), sgNodeIdleMs: getSgNodeIdleMsV2(), sgEdgeStuckMs: getSgEdgeStuckMsV2() }, null, 2)));
1324
+ social.command("sg-set-max-active-v2 <n>").action((n) => { setMaxActiveSgNodesPerOwnerV2(Number(n)); console.log("ok"); });
1325
+ social.command("sg-set-max-pending-v2 <n>").action((n) => { setMaxPendingSgEdgesPerNodeV2(Number(n)); console.log("ok"); });
1326
+ social.command("sg-set-idle-ms-v2 <n>").action((n) => { setSgNodeIdleMsV2(Number(n)); console.log("ok"); });
1327
+ social.command("sg-set-stuck-ms-v2 <n>").action((n) => { setSgEdgeStuckMsV2(Number(n)); console.log("ok"); });
1328
+ social.command("sg-register-node-v2 <id> <owner>").option("--handle <h>", "handle").action((id, owner, o) => console.log(JSON.stringify(registerSgNodeV2({ id, owner, handle: o.handle }), null, 2)));
1329
+ social.command("sg-activate-node-v2 <id>").action((id) => console.log(JSON.stringify(activateSgNodeV2(id), null, 2)));
1330
+ social.command("sg-deactivate-node-v2 <id>").action((id) => console.log(JSON.stringify(deactivateSgNodeV2(id), null, 2)));
1331
+ social.command("sg-remove-node-v2 <id>").action((id) => console.log(JSON.stringify(removeSgNodeV2(id), null, 2)));
1332
+ social.command("sg-touch-node-v2 <id>").action((id) => console.log(JSON.stringify(touchSgNodeV2(id), null, 2)));
1333
+ social.command("sg-get-node-v2 <id>").action((id) => console.log(JSON.stringify(getSgNodeV2(id), null, 2)));
1334
+ social.command("sg-list-nodes-v2").action(() => console.log(JSON.stringify(listSgNodesV2(), null, 2)));
1335
+ social.command("sg-create-edge-v2 <id> <nodeId>").option("--target <t>", "targetId").action((id, nodeId, o) => console.log(JSON.stringify(createSgEdgeV2({ id, nodeId, targetId: o.target }), null, 2)));
1336
+ social.command("sg-establish-edge-v2 <id>").action((id) => console.log(JSON.stringify(establishSgEdgeV2(id), null, 2)));
1337
+ social.command("sg-sever-edge-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(severSgEdgeV2(id, reason), null, 2)));
1338
+ social.command("sg-expire-edge-v2 <id>").action((id) => console.log(JSON.stringify(expireSgEdgeV2(id), null, 2)));
1339
+ social.command("sg-cancel-edge-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(cancelSgEdgeV2(id, reason), null, 2)));
1340
+ social.command("sg-get-edge-v2 <id>").action((id) => console.log(JSON.stringify(getSgEdgeV2(id), null, 2)));
1341
+ social.command("sg-list-edges-v2").action(() => console.log(JSON.stringify(listSgEdgesV2(), null, 2)));
1342
+ social.command("sg-auto-deactivate-idle-v2").action(() => console.log(JSON.stringify(autoDeactivateIdleSgNodesV2(), null, 2)));
1343
+ social.command("sg-auto-expire-stale-v2").action(() => console.log(JSON.stringify(autoExpireStaleSgEdgesV2(), null, 2)));
1344
+ social.command("sg-gov-stats-v2").action(() => console.log(JSON.stringify(getSocialGraphGovStatsV2(), null, 2)));
1345
+ social.command("sg-reset-state-v2").action(() => { _resetStateSocialGraphV2(); console.log(JSON.stringify({ ok: true }, null, 2)); });
1056
1346
  }