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
@@ -42,6 +42,33 @@ import {
42
42
  listIdentityMappings,
43
43
  checkIdentityConflict,
44
44
  getStats,
45
+ PROVIDER_MATURITY_V2 as PMV2,
46
+ LOGIN_LIFECYCLE_V2 as LLV2,
47
+ registerProviderV2,
48
+ activateProviderV2,
49
+ deprecateProviderV2,
50
+ retireProviderV2,
51
+ touchProviderV2,
52
+ getProviderV2,
53
+ listProvidersV2,
54
+ createLoginV2,
55
+ startLoginV2,
56
+ completeLoginV2,
57
+ failLoginV2,
58
+ cancelLoginV2,
59
+ getLoginV2,
60
+ listLoginsV2,
61
+ autoDeprecateIdleProvidersV2,
62
+ autoFailStuckLoginsV2,
63
+ getSsoManagerStatsV2,
64
+ setMaxActiveProvidersPerOwnerV2,
65
+ setMaxPendingLoginsPerProviderV2,
66
+ setProviderIdleMsV2,
67
+ setLoginStuckMsV2,
68
+ getMaxActiveProvidersPerOwnerV2,
69
+ getMaxPendingLoginsPerProviderV2,
70
+ getProviderIdleMsV2,
71
+ getLoginStuckMsV2,
45
72
  } from "../lib/sso-manager.js";
46
73
 
47
74
  function _dbFromCtx(cmd) {
@@ -76,7 +103,8 @@ export function registerSsoCommand(program) {
76
103
  .description(
77
104
  "SSO enterprise authentication — SAML / OAuth2 / OIDC (Phase 14)",
78
105
  )
79
- .hook("preAction", async (thisCommand) => {
106
+ .hook("preAction", async (thisCommand, actionCommand) => {
107
+ if (actionCommand && actionCommand.name().endsWith("-v2")) return;
80
108
  const db = await _prepare(thisCommand);
81
109
  thisCommand._db = db;
82
110
  });
@@ -795,4 +823,161 @@ export function registerSsoCommand(program) {
795
823
  await shutdown();
796
824
  }
797
825
  });
826
+
827
+ // ===== V2 Commands (cli 0.130.0) =====
828
+ const _v2json = (o) => console.log(JSON.stringify(o, null, 2));
829
+ sso
830
+ .command("provider-maturities-v2")
831
+ .description("List V2 provider maturity states")
832
+ .action(() => Object.values(PMV2).forEach((s) => console.log(s)));
833
+ sso
834
+ .command("login-lifecycles-v2")
835
+ .description("List V2 login lifecycle states")
836
+ .action(() => Object.values(LLV2).forEach((s) => console.log(s)));
837
+ sso
838
+ .command("stats-v2")
839
+ .description("V2 stats")
840
+ .action(() => _v2json(getSsoManagerStatsV2()));
841
+ sso
842
+ .command("config-v2")
843
+ .description("V2 config")
844
+ .action(() => {
845
+ console.log(
846
+ `maxActiveProvidersPerOwner: ${getMaxActiveProvidersPerOwnerV2()}`,
847
+ );
848
+ console.log(
849
+ `maxPendingLoginsPerProvider: ${getMaxPendingLoginsPerProviderV2()}`,
850
+ );
851
+ console.log(`providerIdleMs: ${getProviderIdleMsV2()}`);
852
+ console.log(`loginStuckMs: ${getLoginStuckMsV2()}`);
853
+ });
854
+ sso
855
+ .command("set-max-active-providers-v2 <n>")
856
+ .description("Set V2 active provider cap")
857
+ .action((n) => {
858
+ setMaxActiveProvidersPerOwnerV2(Number(n));
859
+ console.log("ok");
860
+ });
861
+ sso
862
+ .command("set-max-pending-logins-v2 <n>")
863
+ .description("Set V2 pending login cap")
864
+ .action((n) => {
865
+ setMaxPendingLoginsPerProviderV2(Number(n));
866
+ console.log("ok");
867
+ });
868
+ sso
869
+ .command("set-provider-idle-ms-v2 <n>")
870
+ .description("Set V2 provider idle ms")
871
+ .action((n) => {
872
+ setProviderIdleMsV2(Number(n));
873
+ console.log("ok");
874
+ });
875
+ sso
876
+ .command("set-login-stuck-ms-v2 <n>")
877
+ .description("Set V2 login stuck ms")
878
+ .action((n) => {
879
+ setLoginStuckMsV2(Number(n));
880
+ console.log("ok");
881
+ });
882
+ sso
883
+ .command("register-provider-v2 <id>")
884
+ .description("V2 register provider")
885
+ .requiredOption("-o, --owner <o>")
886
+ .requiredOption("-p, --protocol <p>")
887
+ .option("-d, --display-name <n>")
888
+ .action((id, opts) =>
889
+ _v2json(
890
+ registerProviderV2({
891
+ id,
892
+ owner: opts.owner,
893
+ protocol: opts.protocol,
894
+ displayName: opts.displayName,
895
+ }),
896
+ ),
897
+ );
898
+ sso
899
+ .command("activate-provider-v2 <id>")
900
+ .description("V2 activate provider")
901
+ .action((id) => _v2json(activateProviderV2(id)));
902
+ sso
903
+ .command("deprecate-provider-v2 <id>")
904
+ .description("V2 deprecate provider")
905
+ .action((id) => _v2json(deprecateProviderV2(id)));
906
+ sso
907
+ .command("retire-provider-v2 <id>")
908
+ .description("V2 retire provider")
909
+ .action((id) => _v2json(retireProviderV2(id)));
910
+ sso
911
+ .command("touch-provider-v2 <id>")
912
+ .description("V2 touch provider")
913
+ .action((id) => _v2json(touchProviderV2(id)));
914
+ sso
915
+ .command("get-provider-v2 <id>")
916
+ .description("V2 get provider")
917
+ .action((id) => _v2json(getProviderV2(id)));
918
+ sso
919
+ .command("list-providers-v2")
920
+ .description("V2 list providers")
921
+ .option("-o, --owner <o>")
922
+ .option("-s, --status <s>")
923
+ .option("-p, --protocol <p>")
924
+ .action((opts) => _v2json(listProvidersV2(opts)));
925
+ sso
926
+ .command("create-login-v2 <id>")
927
+ .description("V2 create login")
928
+ .requiredOption("-p, --provider-id <p>")
929
+ .option("-s, --subject <s>")
930
+ .action((id, opts) =>
931
+ _v2json(
932
+ createLoginV2({
933
+ id,
934
+ providerId: opts.providerId,
935
+ subject: opts.subject,
936
+ }),
937
+ ),
938
+ );
939
+ sso
940
+ .command("start-login-v2 <id>")
941
+ .description("V2 start login")
942
+ .action((id) => _v2json(startLoginV2(id)));
943
+ sso
944
+ .command("complete-login-v2 <id>")
945
+ .description("V2 complete login")
946
+ .action((id) => _v2json(completeLoginV2(id)));
947
+ sso
948
+ .command("fail-login-v2 <id>")
949
+ .description("V2 fail login")
950
+ .option("-e, --error <e>")
951
+ .action((id, opts) => _v2json(failLoginV2(id, opts.error)));
952
+ sso
953
+ .command("cancel-login-v2 <id>")
954
+ .description("V2 cancel login")
955
+ .action((id) => _v2json(cancelLoginV2(id)));
956
+ sso
957
+ .command("get-login-v2 <id>")
958
+ .description("V2 get login")
959
+ .action((id) => _v2json(getLoginV2(id)));
960
+ sso
961
+ .command("list-logins-v2")
962
+ .description("V2 list logins")
963
+ .option("-p, --provider-id <p>")
964
+ .option("-s, --status <s>")
965
+ .option("-S, --subject <s>")
966
+ .action((opts) =>
967
+ _v2json(
968
+ listLoginsV2({
969
+ providerId: opts.providerId,
970
+ status: opts.status,
971
+ subject: opts.subject,
972
+ }),
973
+ ),
974
+ );
975
+ sso
976
+ .command("auto-deprecate-idle-providers-v2")
977
+ .description("V2 auto-deprecate idle")
978
+ .action(() => _v2json(autoDeprecateIdleProvidersV2()));
979
+ sso
980
+ .command("auto-fail-stuck-logins-v2")
981
+ .description("V2 auto-fail stuck")
982
+ .action(() => _v2json(autoFailStuckLoginsV2()));
798
983
  }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * `cc svccont` — Service Container V2 governance overlay.
3
+ *
4
+ * In-memory governance for service containers + resolution lifecycle, layered
5
+ * atop `lib/service-container.js`. Independent of legacy DI/registry helpers.
6
+ */
7
+
8
+ import {
9
+ SVC_CONTAINER_MATURITY_V2, SVC_RESOLUTION_LIFECYCLE_V2,
10
+ setMaxActiveSvcContainersPerOwnerV2, getMaxActiveSvcContainersPerOwnerV2,
11
+ setMaxPendingSvcResolutionsPerContainerV2, getMaxPendingSvcResolutionsPerContainerV2,
12
+ setSvcContainerIdleMsV2, getSvcContainerIdleMsV2,
13
+ setSvcResolutionStuckMsV2, getSvcResolutionStuckMsV2,
14
+ registerSvcContainerV2, activateSvcContainerV2, degradeSvcContainerV2, decommissionSvcContainerV2, touchSvcContainerV2, getSvcContainerV2, listSvcContainersV2,
15
+ createSvcResolutionV2, resolvingSvcResolutionV2, resolveSvcResolutionV2, failSvcResolutionV2, cancelSvcResolutionV2, getSvcResolutionV2, listSvcResolutionsV2,
16
+ autoDegradeIdleSvcContainersV2, autoFailStuckSvcResolutionsV2, getServiceContainerGovStatsV2, _resetStateServiceContainerV2,
17
+ } from "../lib/service-container.js";
18
+
19
+ export function registerSvcContCommand(program) {
20
+ const sc = program.command("svccont").description("Service Container V2 governance");
21
+ sc.command("enums-v2").action(() => console.log(JSON.stringify({ containerMaturity: SVC_CONTAINER_MATURITY_V2, resolutionLifecycle: SVC_RESOLUTION_LIFECYCLE_V2 }, null, 2)));
22
+ sc.command("config-v2").action(() => console.log(JSON.stringify({ maxActiveSvcContainersPerOwner: getMaxActiveSvcContainersPerOwnerV2(), maxPendingSvcResolutionsPerContainer: getMaxPendingSvcResolutionsPerContainerV2(), svcContainerIdleMs: getSvcContainerIdleMsV2(), svcResolutionStuckMs: getSvcResolutionStuckMsV2() }, null, 2)));
23
+ sc.command("set-max-active-v2 <n>").action((n) => { setMaxActiveSvcContainersPerOwnerV2(Number(n)); console.log("ok"); });
24
+ sc.command("set-max-pending-v2 <n>").action((n) => { setMaxPendingSvcResolutionsPerContainerV2(Number(n)); console.log("ok"); });
25
+ sc.command("set-idle-ms-v2 <n>").action((n) => { setSvcContainerIdleMsV2(Number(n)); console.log("ok"); });
26
+ sc.command("set-stuck-ms-v2 <n>").action((n) => { setSvcResolutionStuckMsV2(Number(n)); console.log("ok"); });
27
+ sc.command("register-container-v2 <id> <owner>").option("--scope <s>", "scope").action((id, owner, o) => console.log(JSON.stringify(registerSvcContainerV2({ id, owner, scope: o.scope }), null, 2)));
28
+ sc.command("activate-container-v2 <id>").action((id) => console.log(JSON.stringify(activateSvcContainerV2(id), null, 2)));
29
+ sc.command("degrade-container-v2 <id>").action((id) => console.log(JSON.stringify(degradeSvcContainerV2(id), null, 2)));
30
+ sc.command("decommission-container-v2 <id>").action((id) => console.log(JSON.stringify(decommissionSvcContainerV2(id), null, 2)));
31
+ sc.command("touch-container-v2 <id>").action((id) => console.log(JSON.stringify(touchSvcContainerV2(id), null, 2)));
32
+ sc.command("get-container-v2 <id>").action((id) => console.log(JSON.stringify(getSvcContainerV2(id), null, 2)));
33
+ sc.command("list-containers-v2").action(() => console.log(JSON.stringify(listSvcContainersV2(), null, 2)));
34
+ sc.command("create-resolution-v2 <id> <containerId>").option("--token <t>", "token").action((id, containerId, o) => console.log(JSON.stringify(createSvcResolutionV2({ id, containerId, token: o.token }), null, 2)));
35
+ sc.command("resolving-resolution-v2 <id>").action((id) => console.log(JSON.stringify(resolvingSvcResolutionV2(id), null, 2)));
36
+ sc.command("resolve-resolution-v2 <id>").action((id) => console.log(JSON.stringify(resolveSvcResolutionV2(id), null, 2)));
37
+ sc.command("fail-resolution-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(failSvcResolutionV2(id, reason), null, 2)));
38
+ sc.command("cancel-resolution-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(cancelSvcResolutionV2(id, reason), null, 2)));
39
+ sc.command("get-resolution-v2 <id>").action((id) => console.log(JSON.stringify(getSvcResolutionV2(id), null, 2)));
40
+ sc.command("list-resolutions-v2").action(() => console.log(JSON.stringify(listSvcResolutionsV2(), null, 2)));
41
+ sc.command("auto-degrade-idle-v2").action(() => console.log(JSON.stringify(autoDegradeIdleSvcContainersV2(), null, 2)));
42
+ sc.command("auto-fail-stuck-v2").action(() => console.log(JSON.stringify(autoFailStuckSvcResolutionsV2(), null, 2)));
43
+ sc.command("gov-stats-v2").action(() => console.log(JSON.stringify(getServiceContainerGovStatsV2(), null, 2)));
44
+ sc.command("reset-state-v2").action(() => { _resetStateServiceContainerV2(); console.log(JSON.stringify({ ok: true }, null, 2)); });
45
+ }
@@ -16,6 +16,35 @@ import {
16
16
  clearSyncData,
17
17
  registerResource,
18
18
  getAllSyncStates,
19
+ RESOURCE_MATURITY_V2,
20
+ SYNC_RUN_V2,
21
+ getMaxActiveResourcesPerOwnerV2,
22
+ setMaxActiveResourcesPerOwnerV2,
23
+ getMaxRunningRunsPerResourceV2,
24
+ setMaxRunningRunsPerResourceV2,
25
+ getResourceIdleMsV2,
26
+ setResourceIdleMsV2,
27
+ getRunStuckMsV2,
28
+ setRunStuckMsV2,
29
+ getActiveResourceCountV2,
30
+ getRunningRunCountV2,
31
+ registerResourceV2,
32
+ getResourceV2,
33
+ listResourcesV2,
34
+ activateResourceV2,
35
+ pauseResourceV2,
36
+ archiveResourceV2,
37
+ touchResourceV2,
38
+ createSyncRunV2,
39
+ getSyncRunV2,
40
+ listSyncRunsV2,
41
+ startSyncRunV2,
42
+ succeedSyncRunV2,
43
+ failSyncRunV2,
44
+ cancelSyncRunV2,
45
+ autoArchiveIdleResourcesV2,
46
+ autoFailStuckSyncRunsV2,
47
+ getSyncManagerStatsV2,
19
48
  } from "../lib/sync-manager.js";
20
49
 
21
50
  export function registerSyncCommand(program) {
@@ -246,4 +275,231 @@ export function registerSyncCommand(program) {
246
275
  process.exit(1);
247
276
  }
248
277
  });
278
+
279
+ // ─────────────────────────────────────────────────────────────
280
+ // V2 Surface — resource + sync-run lifecycle (in-memory, throwing API)
281
+ // ─────────────────────────────────────────────────────────────
282
+
283
+ sync
284
+ .command("resource-maturities-v2")
285
+ .description("List V2 resource maturity states")
286
+ .option("--json", "Output as JSON")
287
+ .action((options) => {
288
+ const v = Object.values(RESOURCE_MATURITY_V2);
289
+ if (options.json) console.log(JSON.stringify(v));
290
+ else logger.log(v.join(", "));
291
+ });
292
+
293
+ sync
294
+ .command("run-lifecycles-v2")
295
+ .description("List V2 sync-run lifecycle states")
296
+ .option("--json", "Output as JSON")
297
+ .action((options) => {
298
+ const v = Object.values(SYNC_RUN_V2);
299
+ if (options.json) console.log(JSON.stringify(v));
300
+ else logger.log(v.join(", "));
301
+ });
302
+
303
+ sync
304
+ .command("stats-v2")
305
+ .description("Show V2 sync stats")
306
+ .option("--json", "Output as JSON")
307
+ .action((options) => {
308
+ const stats = getSyncManagerStatsV2();
309
+ if (options.json) console.log(JSON.stringify(stats, null, 2));
310
+ else logger.log(JSON.stringify(stats, null, 2));
311
+ });
312
+
313
+ sync
314
+ .command("get-max-active-resources-v2")
315
+ .description("Get max active resources per owner")
316
+ .action(() => logger.log(String(getMaxActiveResourcesPerOwnerV2())));
317
+ sync
318
+ .command("set-max-active-resources-v2 <n>")
319
+ .description("Set max active resources per owner")
320
+ .action((n) => {
321
+ setMaxActiveResourcesPerOwnerV2(Number(n));
322
+ logger.log(String(getMaxActiveResourcesPerOwnerV2()));
323
+ });
324
+ sync
325
+ .command("get-max-running-runs-v2")
326
+ .description("Get max running runs per resource")
327
+ .action(() => logger.log(String(getMaxRunningRunsPerResourceV2())));
328
+ sync
329
+ .command("set-max-running-runs-v2 <n>")
330
+ .description("Set max running runs per resource")
331
+ .action((n) => {
332
+ setMaxRunningRunsPerResourceV2(Number(n));
333
+ logger.log(String(getMaxRunningRunsPerResourceV2()));
334
+ });
335
+ sync
336
+ .command("get-resource-idle-ms-v2")
337
+ .description("Get resource idle ms")
338
+ .action(() => logger.log(String(getResourceIdleMsV2())));
339
+ sync
340
+ .command("set-resource-idle-ms-v2 <ms>")
341
+ .description("Set resource idle ms")
342
+ .action((ms) => {
343
+ setResourceIdleMsV2(Number(ms));
344
+ logger.log(String(getResourceIdleMsV2()));
345
+ });
346
+ sync
347
+ .command("get-run-stuck-ms-v2")
348
+ .description("Get run stuck ms")
349
+ .action(() => logger.log(String(getRunStuckMsV2())));
350
+ sync
351
+ .command("set-run-stuck-ms-v2 <ms>")
352
+ .description("Set run stuck ms")
353
+ .action((ms) => {
354
+ setRunStuckMsV2(Number(ms));
355
+ logger.log(String(getRunStuckMsV2()));
356
+ });
357
+
358
+ sync
359
+ .command("active-resource-count-v2 <owner>")
360
+ .description("Count active resources for owner")
361
+ .action((owner) => logger.log(String(getActiveResourceCountV2(owner))));
362
+ sync
363
+ .command("running-run-count-v2 <resourceId>")
364
+ .description("Count running runs for resource")
365
+ .action((resourceId) =>
366
+ logger.log(String(getRunningRunCountV2(resourceId))),
367
+ );
368
+
369
+ sync
370
+ .command("register-resource-v2 <id>")
371
+ .description("Register V2 resource (initial=pending)")
372
+ .requiredOption("-o, --owner <owner>", "owner")
373
+ .requiredOption("-k, --kind <kind>", "kind (file/note/...)")
374
+ .option("-m, --metadata <json>", "metadata JSON", "{}")
375
+ .action((id, opts) => {
376
+ const meta = JSON.parse(opts.metadata);
377
+ const r = registerResourceV2(id, {
378
+ owner: opts.owner,
379
+ kind: opts.kind,
380
+ metadata: meta,
381
+ });
382
+ console.log(JSON.stringify(r, null, 2));
383
+ });
384
+
385
+ sync
386
+ .command("get-resource-v2 <id>")
387
+ .description("Get V2 resource by id")
388
+ .action((id) => {
389
+ const r = getResourceV2(id);
390
+ if (!r) {
391
+ logger.error(`resource ${id} not found`);
392
+ process.exit(1);
393
+ }
394
+ console.log(JSON.stringify(r, null, 2));
395
+ });
396
+
397
+ sync
398
+ .command("list-resources-v2")
399
+ .description("List V2 resources")
400
+ .option("-o, --owner <owner>", "filter by owner")
401
+ .option("-k, --kind <kind>", "filter by kind")
402
+ .option("-s, --status <state>", "filter by status")
403
+ .action((opts) => {
404
+ const out = listResourcesV2({
405
+ owner: opts.owner,
406
+ kind: opts.kind,
407
+ status: opts.status,
408
+ });
409
+ console.log(JSON.stringify(out, null, 2));
410
+ });
411
+
412
+ sync
413
+ .command("activate-resource-v2 <id>")
414
+ .description("Transition resource → active")
415
+ .action((id) =>
416
+ console.log(JSON.stringify(activateResourceV2(id), null, 2)),
417
+ );
418
+ sync
419
+ .command("pause-resource-v2 <id>")
420
+ .description("Transition resource → paused")
421
+ .action((id) => console.log(JSON.stringify(pauseResourceV2(id), null, 2)));
422
+ sync
423
+ .command("archive-resource-v2 <id>")
424
+ .description("Transition resource → archived (terminal)")
425
+ .action((id) =>
426
+ console.log(JSON.stringify(archiveResourceV2(id), null, 2)),
427
+ );
428
+ sync
429
+ .command("touch-resource-v2 <id>")
430
+ .description("Update resource lastSeenAt")
431
+ .action((id) => console.log(JSON.stringify(touchResourceV2(id), null, 2)));
432
+
433
+ sync
434
+ .command("create-sync-run-v2 <id>")
435
+ .description("Create V2 sync run (initial=queued)")
436
+ .requiredOption("-r, --resource <id>", "resource id")
437
+ .option("-k, --kind <kind>", "run kind", "push")
438
+ .option("-m, --metadata <json>", "metadata JSON", "{}")
439
+ .action((id, opts) => {
440
+ const meta = JSON.parse(opts.metadata);
441
+ const j = createSyncRunV2(id, {
442
+ resourceId: opts.resource,
443
+ kind: opts.kind,
444
+ metadata: meta,
445
+ });
446
+ console.log(JSON.stringify(j, null, 2));
447
+ });
448
+
449
+ sync
450
+ .command("get-sync-run-v2 <id>")
451
+ .description("Get V2 sync run by id")
452
+ .action((id) => {
453
+ const j = getSyncRunV2(id);
454
+ if (!j) {
455
+ logger.error(`syncRun ${id} not found`);
456
+ process.exit(1);
457
+ }
458
+ console.log(JSON.stringify(j, null, 2));
459
+ });
460
+
461
+ sync
462
+ .command("list-sync-runs-v2")
463
+ .description("List V2 sync runs")
464
+ .option("-r, --resource <id>", "filter by resource")
465
+ .option("-s, --status <state>", "filter by status")
466
+ .action((opts) => {
467
+ const out = listSyncRunsV2({
468
+ resourceId: opts.resource,
469
+ status: opts.status,
470
+ });
471
+ console.log(JSON.stringify(out, null, 2));
472
+ });
473
+
474
+ sync
475
+ .command("start-sync-run-v2 <id>")
476
+ .description("Transition sync run → running")
477
+ .action((id) => console.log(JSON.stringify(startSyncRunV2(id), null, 2)));
478
+ sync
479
+ .command("succeed-sync-run-v2 <id>")
480
+ .description("Transition sync run → succeeded (terminal)")
481
+ .action((id) => console.log(JSON.stringify(succeedSyncRunV2(id), null, 2)));
482
+ sync
483
+ .command("fail-sync-run-v2 <id>")
484
+ .description("Transition sync run → failed (terminal)")
485
+ .action((id) => console.log(JSON.stringify(failSyncRunV2(id), null, 2)));
486
+ sync
487
+ .command("cancel-sync-run-v2 <id>")
488
+ .description("Transition sync run → cancelled (terminal)")
489
+ .action((id) => console.log(JSON.stringify(cancelSyncRunV2(id), null, 2)));
490
+
491
+ sync
492
+ .command("auto-archive-idle-v2")
493
+ .description("Auto-archive idle resources; output flipped")
494
+ .action(() => {
495
+ const flipped = autoArchiveIdleResourcesV2();
496
+ console.log(JSON.stringify(flipped, null, 2));
497
+ });
498
+ sync
499
+ .command("auto-fail-stuck-runs-v2")
500
+ .description("Auto-fail stuck running syncs; output flipped")
501
+ .action(() => {
502
+ const flipped = autoFailStuckSyncRunsV2();
503
+ console.log(JSON.stringify(flipped, null, 2));
504
+ });
249
505
  }