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
@@ -0,0 +1,41 @@
1
+ /**
2
+ * `cc seshtail` — Session Tail V2 governance overlay (in-memory, atop lib/session-tail.js).
3
+ */
4
+ import {
5
+ STAIL_SUB_MATURITY_V2, STAIL_EVENT_LIFECYCLE_V2,
6
+ setMaxActiveStailSubsPerOwnerV2, getMaxActiveStailSubsPerOwnerV2,
7
+ setMaxPendingStailEventsPerSubV2, getMaxPendingStailEventsPerSubV2,
8
+ setStailSubIdleMsV2, getStailSubIdleMsV2,
9
+ setStailEventStuckMsV2, getStailEventStuckMsV2,
10
+ registerStailSubV2, activateStailSubV2, pauseStailSubV2, closeStailSubV2, touchStailSubV2, getStailSubV2, listStailSubsV2,
11
+ createStailEventV2, tailingStailEventV2, completeStailEventV2, failStailEventV2, cancelStailEventV2, getStailEventV2, listStailEventsV2,
12
+ autoPauseIdleStailSubsV2, autoFailStuckStailEventsV2, getSessionTailGovStatsV2, _resetStateSessionTailV2,
13
+ } from "../lib/session-tail.js";
14
+
15
+ export function registerSeshtailCommand(program) {
16
+ const st = program.command("seshtail").description("Session Tail V2 governance");
17
+ st.command("enums-v2").action(() => console.log(JSON.stringify({ subMaturity: STAIL_SUB_MATURITY_V2, eventLifecycle: STAIL_EVENT_LIFECYCLE_V2 }, null, 2)));
18
+ st.command("config-v2").action(() => console.log(JSON.stringify({ maxActiveStailSubsPerOwner: getMaxActiveStailSubsPerOwnerV2(), maxPendingStailEventsPerSub: getMaxPendingStailEventsPerSubV2(), stailSubIdleMs: getStailSubIdleMsV2(), stailEventStuckMs: getStailEventStuckMsV2() }, null, 2)));
19
+ st.command("set-max-active-v2 <n>").action((n) => { setMaxActiveStailSubsPerOwnerV2(Number(n)); console.log("ok"); });
20
+ st.command("set-max-pending-v2 <n>").action((n) => { setMaxPendingStailEventsPerSubV2(Number(n)); console.log("ok"); });
21
+ st.command("set-idle-ms-v2 <n>").action((n) => { setStailSubIdleMsV2(Number(n)); console.log("ok"); });
22
+ st.command("set-stuck-ms-v2 <n>").action((n) => { setStailEventStuckMsV2(Number(n)); console.log("ok"); });
23
+ st.command("register-sub-v2 <id> <owner>").option("--sessionId <s>", "sessionId").action((id, owner, o) => console.log(JSON.stringify(registerStailSubV2({ id, owner, sessionId: o.sessionId }), null, 2)));
24
+ st.command("activate-sub-v2 <id>").action((id) => console.log(JSON.stringify(activateStailSubV2(id), null, 2)));
25
+ st.command("pause-sub-v2 <id>").action((id) => console.log(JSON.stringify(pauseStailSubV2(id), null, 2)));
26
+ st.command("close-sub-v2 <id>").action((id) => console.log(JSON.stringify(closeStailSubV2(id), null, 2)));
27
+ st.command("touch-sub-v2 <id>").action((id) => console.log(JSON.stringify(touchStailSubV2(id), null, 2)));
28
+ st.command("get-sub-v2 <id>").action((id) => console.log(JSON.stringify(getStailSubV2(id), null, 2)));
29
+ st.command("list-subs-v2").action(() => console.log(JSON.stringify(listStailSubsV2(), null, 2)));
30
+ st.command("create-event-v2 <id> <subId>").option("--cursor <c>", "cursor").action((id, subId, o) => console.log(JSON.stringify(createStailEventV2({ id, subId, cursor: o.cursor }), null, 2)));
31
+ st.command("tailing-event-v2 <id>").action((id) => console.log(JSON.stringify(tailingStailEventV2(id), null, 2)));
32
+ st.command("complete-event-v2 <id>").action((id) => console.log(JSON.stringify(completeStailEventV2(id), null, 2)));
33
+ st.command("fail-event-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(failStailEventV2(id, reason), null, 2)));
34
+ st.command("cancel-event-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(cancelStailEventV2(id, reason), null, 2)));
35
+ st.command("get-event-v2 <id>").action((id) => console.log(JSON.stringify(getStailEventV2(id), null, 2)));
36
+ st.command("list-events-v2").action(() => console.log(JSON.stringify(listStailEventsV2(), null, 2)));
37
+ st.command("auto-pause-idle-v2").action(() => console.log(JSON.stringify(autoPauseIdleStailSubsV2(), null, 2)));
38
+ st.command("auto-fail-stuck-v2").action(() => console.log(JSON.stringify(autoFailStuckStailEventsV2(), null, 2)));
39
+ st.command("gov-stats-v2").action(() => console.log(JSON.stringify(getSessionTailGovStatsV2(), null, 2)));
40
+ st.command("reset-state-v2").action(() => { _resetStateSessionTailV2(); console.log(JSON.stringify({ ok: true }, null, 2)); });
41
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * `cc seshu` — Session Usage V2 governance overlay (in-memory, atop lib/session-usage.js).
3
+ */
4
+ import {
5
+ SUSE_BUDGET_MATURITY_V2, SUSE_RECORD_LIFECYCLE_V2,
6
+ setMaxActiveSuseBudgetsPerOwnerV2, getMaxActiveSuseBudgetsPerOwnerV2,
7
+ setMaxPendingSuseRecordsPerBudgetV2, getMaxPendingSuseRecordsPerBudgetV2,
8
+ setSuseBudgetIdleMsV2, getSuseBudgetIdleMsV2,
9
+ setSuseRecordStuckMsV2, getSuseRecordStuckMsV2,
10
+ registerSuseBudgetV2, activateSuseBudgetV2, exhaustSuseBudgetV2, archiveSuseBudgetV2, touchSuseBudgetV2, getSuseBudgetV2, listSuseBudgetsV2,
11
+ createSuseRecordV2, recordingSuseRecordV2, recordSuseRecordV2, rejectSuseRecordV2, cancelSuseRecordV2, getSuseRecordV2, listSuseRecordsV2,
12
+ autoExhaustIdleSuseBudgetsV2, autoRejectStuckSuseRecordsV2, getSessionUsageGovStatsV2, _resetStateSessionUsageV2,
13
+ } from "../lib/session-usage.js";
14
+
15
+ export function registerSeshuCommand(program) {
16
+ const su = program.command("seshu").description("Session Usage V2 governance");
17
+ su.command("enums-v2").action(() => console.log(JSON.stringify({ budgetMaturity: SUSE_BUDGET_MATURITY_V2, recordLifecycle: SUSE_RECORD_LIFECYCLE_V2 }, null, 2)));
18
+ su.command("config-v2").action(() => console.log(JSON.stringify({ maxActiveSuseBudgetsPerOwner: getMaxActiveSuseBudgetsPerOwnerV2(), maxPendingSuseRecordsPerBudget: getMaxPendingSuseRecordsPerBudgetV2(), suseBudgetIdleMs: getSuseBudgetIdleMsV2(), suseRecordStuckMs: getSuseRecordStuckMsV2() }, null, 2)));
19
+ su.command("set-max-active-v2 <n>").action((n) => { setMaxActiveSuseBudgetsPerOwnerV2(Number(n)); console.log("ok"); });
20
+ su.command("set-max-pending-v2 <n>").action((n) => { setMaxPendingSuseRecordsPerBudgetV2(Number(n)); console.log("ok"); });
21
+ su.command("set-idle-ms-v2 <n>").action((n) => { setSuseBudgetIdleMsV2(Number(n)); console.log("ok"); });
22
+ su.command("set-stuck-ms-v2 <n>").action((n) => { setSuseRecordStuckMsV2(Number(n)); console.log("ok"); });
23
+ su.command("register-budget-v2 <id> <owner>").option("--limit <n>", "limit").action((id, owner, o) => console.log(JSON.stringify(registerSuseBudgetV2({ id, owner, limit: o.limit ? Number(o.limit) : undefined }), null, 2)));
24
+ su.command("activate-budget-v2 <id>").action((id) => console.log(JSON.stringify(activateSuseBudgetV2(id), null, 2)));
25
+ su.command("exhaust-budget-v2 <id>").action((id) => console.log(JSON.stringify(exhaustSuseBudgetV2(id), null, 2)));
26
+ su.command("archive-budget-v2 <id>").action((id) => console.log(JSON.stringify(archiveSuseBudgetV2(id), null, 2)));
27
+ su.command("touch-budget-v2 <id>").action((id) => console.log(JSON.stringify(touchSuseBudgetV2(id), null, 2)));
28
+ su.command("get-budget-v2 <id>").action((id) => console.log(JSON.stringify(getSuseBudgetV2(id), null, 2)));
29
+ su.command("list-budgets-v2").action(() => console.log(JSON.stringify(listSuseBudgetsV2(), null, 2)));
30
+ su.command("create-record-v2 <id> <budgetId>").option("--amount <n>", "amount").action((id, budgetId, o) => console.log(JSON.stringify(createSuseRecordV2({ id, budgetId, amount: o.amount ? Number(o.amount) : undefined }), null, 2)));
31
+ su.command("recording-record-v2 <id>").action((id) => console.log(JSON.stringify(recordingSuseRecordV2(id), null, 2)));
32
+ su.command("record-record-v2 <id>").action((id) => console.log(JSON.stringify(recordSuseRecordV2(id), null, 2)));
33
+ su.command("reject-record-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(rejectSuseRecordV2(id, reason), null, 2)));
34
+ su.command("cancel-record-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(cancelSuseRecordV2(id, reason), null, 2)));
35
+ su.command("get-record-v2 <id>").action((id) => console.log(JSON.stringify(getSuseRecordV2(id), null, 2)));
36
+ su.command("list-records-v2").action(() => console.log(JSON.stringify(listSuseRecordsV2(), null, 2)));
37
+ su.command("auto-exhaust-idle-v2").action(() => console.log(JSON.stringify(autoExhaustIdleSuseBudgetsV2(), null, 2)));
38
+ su.command("auto-reject-stuck-v2").action(() => console.log(JSON.stringify(autoRejectStuckSuseRecordsV2(), null, 2)));
39
+ su.command("gov-stats-v2").action(() => console.log(JSON.stringify(getSessionUsageGovStatsV2(), null, 2)));
40
+ su.command("reset-state-v2").action(() => { _resetStateSessionUsageV2(); console.log(JSON.stringify({ ok: true }, null, 2)); });
41
+ }
@@ -13,6 +13,35 @@ import {
13
13
  getSession,
14
14
  deleteSession,
15
15
  exportSessionMarkdown,
16
+ CONVERSATION_MATURITY_V2,
17
+ TURN_LIFECYCLE_V2,
18
+ getMaxActiveConvPerUserV2,
19
+ setMaxActiveConvPerUserV2,
20
+ getMaxPendingTurnsPerConvV2,
21
+ setMaxPendingTurnsPerConvV2,
22
+ getConvIdleMsV2,
23
+ setConvIdleMsV2,
24
+ getTurnStuckMsV2,
25
+ setTurnStuckMsV2,
26
+ getActiveConvCountV2,
27
+ getPendingTurnCountV2,
28
+ registerConversationV2,
29
+ getConversationV2,
30
+ listConversationsV2,
31
+ activateConversationV2,
32
+ pauseConversationV2,
33
+ archiveConversationV2,
34
+ touchConversationV2,
35
+ createTurnV2,
36
+ getTurnV2,
37
+ listTurnsV2,
38
+ streamTurnV2,
39
+ completeTurnV2,
40
+ failTurnV2,
41
+ cancelTurnV2,
42
+ autoArchiveIdleConversationsV2,
43
+ autoFailStuckTurnsV2,
44
+ getSessionManagerStatsV2,
16
45
  } from "../lib/session-manager.js";
17
46
  import {
18
47
  listJsonlSessions,
@@ -785,4 +814,233 @@ export function registerSessionCommand(program) {
785
814
  process.exit(1);
786
815
  }
787
816
  });
817
+
818
+ // ─────────────────────────────────────────────────────────────
819
+ // V2 Surface — conversation + turn lifecycle (in-memory, throwing API)
820
+ // ─────────────────────────────────────────────────────────────
821
+
822
+ session
823
+ .command("conversation-maturities-v2")
824
+ .description("List V2 conversation maturity states")
825
+ .option("--json", "Output as JSON")
826
+ .action((options) => {
827
+ const v = Object.values(CONVERSATION_MATURITY_V2);
828
+ if (options.json) console.log(JSON.stringify(v));
829
+ else logger.log(v.join(", "));
830
+ });
831
+
832
+ session
833
+ .command("turn-lifecycles-v2")
834
+ .description("List V2 turn lifecycle states")
835
+ .option("--json", "Output as JSON")
836
+ .action((options) => {
837
+ const v = Object.values(TURN_LIFECYCLE_V2);
838
+ if (options.json) console.log(JSON.stringify(v));
839
+ else logger.log(v.join(", "));
840
+ });
841
+
842
+ session
843
+ .command("stats-v2")
844
+ .description("Show V2 session stats")
845
+ .option("--json", "Output as JSON")
846
+ .action((options) => {
847
+ const stats = getSessionManagerStatsV2();
848
+ if (options.json) console.log(JSON.stringify(stats, null, 2));
849
+ else logger.log(JSON.stringify(stats, null, 2));
850
+ });
851
+
852
+ session
853
+ .command("get-max-active-conv-v2")
854
+ .description("Get max active conversations per user")
855
+ .action(() => logger.log(String(getMaxActiveConvPerUserV2())));
856
+ session
857
+ .command("set-max-active-conv-v2 <n>")
858
+ .description("Set max active conversations per user")
859
+ .action((n) => {
860
+ setMaxActiveConvPerUserV2(Number(n));
861
+ logger.log(String(getMaxActiveConvPerUserV2()));
862
+ });
863
+ session
864
+ .command("get-max-pending-turns-v2")
865
+ .description("Get max pending turns per conversation")
866
+ .action(() => logger.log(String(getMaxPendingTurnsPerConvV2())));
867
+ session
868
+ .command("set-max-pending-turns-v2 <n>")
869
+ .description("Set max pending turns per conversation")
870
+ .action((n) => {
871
+ setMaxPendingTurnsPerConvV2(Number(n));
872
+ logger.log(String(getMaxPendingTurnsPerConvV2()));
873
+ });
874
+ session
875
+ .command("get-conv-idle-ms-v2")
876
+ .description("Get conversation idle ms")
877
+ .action(() => logger.log(String(getConvIdleMsV2())));
878
+ session
879
+ .command("set-conv-idle-ms-v2 <ms>")
880
+ .description("Set conversation idle ms")
881
+ .action((ms) => {
882
+ setConvIdleMsV2(Number(ms));
883
+ logger.log(String(getConvIdleMsV2()));
884
+ });
885
+ session
886
+ .command("get-turn-stuck-ms-v2")
887
+ .description("Get turn stuck ms")
888
+ .action(() => logger.log(String(getTurnStuckMsV2())));
889
+ session
890
+ .command("set-turn-stuck-ms-v2 <ms>")
891
+ .description("Set turn stuck ms")
892
+ .action((ms) => {
893
+ setTurnStuckMsV2(Number(ms));
894
+ logger.log(String(getTurnStuckMsV2()));
895
+ });
896
+
897
+ session
898
+ .command("active-conv-count-v2 <userId>")
899
+ .description("Count active conversations for user")
900
+ .action((userId) => logger.log(String(getActiveConvCountV2(userId))));
901
+ session
902
+ .command("pending-turn-count-v2 <conversationId>")
903
+ .description("Count pending+streaming turns for conversation")
904
+ .action((conversationId) =>
905
+ logger.log(String(getPendingTurnCountV2(conversationId))),
906
+ );
907
+
908
+ session
909
+ .command("register-conversation-v2 <id>")
910
+ .description("Register V2 conversation (initial=draft)")
911
+ .requiredOption("-u, --user <userId>", "user id")
912
+ .requiredOption("-m, --model <model>", "model")
913
+ .option("--metadata <json>", "metadata JSON", "{}")
914
+ .action((id, opts) => {
915
+ const meta = JSON.parse(opts.metadata);
916
+ const c = registerConversationV2(id, {
917
+ userId: opts.user,
918
+ model: opts.model,
919
+ metadata: meta,
920
+ });
921
+ console.log(JSON.stringify(c, null, 2));
922
+ });
923
+
924
+ session
925
+ .command("get-conversation-v2 <id>")
926
+ .description("Get V2 conversation by id")
927
+ .action((id) => {
928
+ const c = getConversationV2(id);
929
+ if (!c) {
930
+ logger.error(`conversation ${id} not found`);
931
+ process.exit(1);
932
+ }
933
+ console.log(JSON.stringify(c, null, 2));
934
+ });
935
+
936
+ session
937
+ .command("list-conversations-v2")
938
+ .description("List V2 conversations")
939
+ .option("-u, --user <userId>", "filter by user")
940
+ .option("-s, --status <state>", "filter by status")
941
+ .action((opts) => {
942
+ const out = listConversationsV2({
943
+ userId: opts.user,
944
+ status: opts.status,
945
+ });
946
+ console.log(JSON.stringify(out, null, 2));
947
+ });
948
+
949
+ session
950
+ .command("activate-conversation-v2 <id>")
951
+ .description("Transition conversation → active")
952
+ .action((id) =>
953
+ console.log(JSON.stringify(activateConversationV2(id), null, 2)),
954
+ );
955
+ session
956
+ .command("pause-conversation-v2 <id>")
957
+ .description("Transition conversation → paused")
958
+ .action((id) =>
959
+ console.log(JSON.stringify(pauseConversationV2(id), null, 2)),
960
+ );
961
+ session
962
+ .command("archive-conversation-v2 <id>")
963
+ .description("Transition conversation → archived (terminal)")
964
+ .action((id) =>
965
+ console.log(JSON.stringify(archiveConversationV2(id), null, 2)),
966
+ );
967
+ session
968
+ .command("touch-conversation-v2 <id>")
969
+ .description("Update conversation lastSeenAt")
970
+ .action((id) =>
971
+ console.log(JSON.stringify(touchConversationV2(id), null, 2)),
972
+ );
973
+
974
+ session
975
+ .command("create-turn-v2 <id>")
976
+ .description("Create V2 turn (initial=pending)")
977
+ .requiredOption("-c, --conversation <id>", "conversation id")
978
+ .option("-r, --role <role>", "role (user/assistant)", "user")
979
+ .option("-m, --metadata <json>", "metadata JSON", "{}")
980
+ .action((id, opts) => {
981
+ const meta = JSON.parse(opts.metadata);
982
+ const t = createTurnV2(id, {
983
+ conversationId: opts.conversation,
984
+ role: opts.role,
985
+ metadata: meta,
986
+ });
987
+ console.log(JSON.stringify(t, null, 2));
988
+ });
989
+
990
+ session
991
+ .command("get-turn-v2 <id>")
992
+ .description("Get V2 turn by id")
993
+ .action((id) => {
994
+ const t = getTurnV2(id);
995
+ if (!t) {
996
+ logger.error(`turn ${id} not found`);
997
+ process.exit(1);
998
+ }
999
+ console.log(JSON.stringify(t, null, 2));
1000
+ });
1001
+
1002
+ session
1003
+ .command("list-turns-v2")
1004
+ .description("List V2 turns")
1005
+ .option("-c, --conversation <id>", "filter by conversation")
1006
+ .option("-s, --status <state>", "filter by status")
1007
+ .action((opts) => {
1008
+ const out = listTurnsV2({
1009
+ conversationId: opts.conversation,
1010
+ status: opts.status,
1011
+ });
1012
+ console.log(JSON.stringify(out, null, 2));
1013
+ });
1014
+
1015
+ session
1016
+ .command("stream-turn-v2 <id>")
1017
+ .description("Transition turn → streaming")
1018
+ .action((id) => console.log(JSON.stringify(streamTurnV2(id), null, 2)));
1019
+ session
1020
+ .command("complete-turn-v2 <id>")
1021
+ .description("Transition turn → completed (terminal)")
1022
+ .action((id) => console.log(JSON.stringify(completeTurnV2(id), null, 2)));
1023
+ session
1024
+ .command("fail-turn-v2 <id>")
1025
+ .description("Transition turn → failed (terminal)")
1026
+ .action((id) => console.log(JSON.stringify(failTurnV2(id), null, 2)));
1027
+ session
1028
+ .command("cancel-turn-v2 <id>")
1029
+ .description("Transition turn → cancelled (terminal)")
1030
+ .action((id) => console.log(JSON.stringify(cancelTurnV2(id), null, 2)));
1031
+
1032
+ session
1033
+ .command("auto-archive-idle-conv-v2")
1034
+ .description("Auto-archive idle conversations; output flipped")
1035
+ .action(() => {
1036
+ const flipped = autoArchiveIdleConversationsV2();
1037
+ console.log(JSON.stringify(flipped, null, 2));
1038
+ });
1039
+ session
1040
+ .command("auto-fail-stuck-turns-v2")
1041
+ .description("Auto-fail stuck streaming turns; output flipped")
1042
+ .action(() => {
1043
+ const flipped = autoFailStuckTurnsV2();
1044
+ console.log(JSON.stringify(flipped, null, 2));
1045
+ });
788
1046
  }
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Social Graph Analytics V2 governance commands — `cc sganal ...`
3
+ * 在内存中治理 SGAN profile (pending/active/stale/archived) + run 生命周期。
4
+ */
5
+ import {
6
+ SGAN_PROFILE_MATURITY_V2,
7
+ SGAN_RUN_LIFECYCLE_V2,
8
+ registerSganProfileV2,
9
+ activateSganProfileV2,
10
+ staleSganProfileV2,
11
+ archiveSganProfileV2,
12
+ touchSganProfileV2,
13
+ getSganProfileV2,
14
+ listSganProfilesV2,
15
+ createSganRunV2,
16
+ runningSganRunV2,
17
+ completeSganRunV2,
18
+ failSganRunV2,
19
+ cancelSganRunV2,
20
+ getSganRunV2,
21
+ listSganRunsV2,
22
+ setMaxActiveSganProfilesPerOwnerV2,
23
+ getMaxActiveSganProfilesPerOwnerV2,
24
+ setMaxPendingSganRunsPerProfileV2,
25
+ getMaxPendingSganRunsPerProfileV2,
26
+ setSganProfileIdleMsV2,
27
+ getSganProfileIdleMsV2,
28
+ setSganRunStuckMsV2,
29
+ getSganRunStuckMsV2,
30
+ autoStaleIdleSganProfilesV2,
31
+ autoFailStuckSganRunsV2,
32
+ getSocialGraphAnalyticsGovStatsV2,
33
+ } from "../lib/social-graph-analytics.js";
34
+
35
+ export function registerSganalCommand(program) {
36
+ const s = program
37
+ .command("sganal")
38
+ .description("Social Graph Analytics V2 governance (in-memory, CLI v0.143.0)");
39
+
40
+ s.command("enums-v2").action(() => console.log(JSON.stringify({ SGAN_PROFILE_MATURITY_V2, SGAN_RUN_LIFECYCLE_V2 }, null, 2)));
41
+ s.command("register-profile-v2")
42
+ .requiredOption("--id <id>")
43
+ .requiredOption("--owner <owner>")
44
+ .option("--algorithm <algorithm>", "graph algorithm", "centrality")
45
+ .action((o) => console.log(JSON.stringify(registerSganProfileV2(o), null, 2)));
46
+ s.command("activate-profile-v2 <id>").action((id) => console.log(JSON.stringify(activateSganProfileV2(id), null, 2)));
47
+ s.command("stale-profile-v2 <id>").action((id) => console.log(JSON.stringify(staleSganProfileV2(id), null, 2)));
48
+ s.command("archive-profile-v2 <id>").action((id) => console.log(JSON.stringify(archiveSganProfileV2(id), null, 2)));
49
+ s.command("touch-profile-v2 <id>").action((id) => console.log(JSON.stringify(touchSganProfileV2(id), null, 2)));
50
+ s.command("get-profile-v2 <id>").action((id) => console.log(JSON.stringify(getSganProfileV2(id), null, 2)));
51
+ s.command("list-profiles-v2").action(() => console.log(JSON.stringify(listSganProfilesV2(), null, 2)));
52
+
53
+ s.command("create-run-v2")
54
+ .requiredOption("--id <id>")
55
+ .requiredOption("--profile-id <profileId>")
56
+ .option("--snapshot-id <sid>", "graph snapshot id", "")
57
+ .action((o) => console.log(JSON.stringify(createSganRunV2({ id: o.id, profileId: o.profileId, snapshotId: o.snapshotId }), null, 2)));
58
+ s.command("running-run-v2 <id>").action((id) => console.log(JSON.stringify(runningSganRunV2(id), null, 2)));
59
+ s.command("complete-run-v2 <id>").action((id) => console.log(JSON.stringify(completeSganRunV2(id), null, 2)));
60
+ s.command("fail-run-v2 <id>").option("--reason <r>").action((id, o) => console.log(JSON.stringify(failSganRunV2(id, o.reason), null, 2)));
61
+ s.command("cancel-run-v2 <id>").option("--reason <r>").action((id, o) => console.log(JSON.stringify(cancelSganRunV2(id, o.reason), null, 2)));
62
+ s.command("get-run-v2 <id>").action((id) => console.log(JSON.stringify(getSganRunV2(id), null, 2)));
63
+ s.command("list-runs-v2").action(() => console.log(JSON.stringify(listSganRunsV2(), null, 2)));
64
+
65
+ s.command("config-v2").action(() => console.log(JSON.stringify({
66
+ maxActiveSganProfilesPerOwner: getMaxActiveSganProfilesPerOwnerV2(),
67
+ maxPendingSganRunsPerProfile: getMaxPendingSganRunsPerProfileV2(),
68
+ sganProfileIdleMs: getSganProfileIdleMsV2(),
69
+ sganRunStuckMs: getSganRunStuckMsV2(),
70
+ }, null, 2)));
71
+ s.command("set-max-active-profiles-v2 <n>").action((n) => { setMaxActiveSganProfilesPerOwnerV2(Number(n)); console.log(JSON.stringify({ maxActiveSganProfilesPerOwner: getMaxActiveSganProfilesPerOwnerV2() }, null, 2)); });
72
+ s.command("set-max-pending-runs-v2 <n>").action((n) => { setMaxPendingSganRunsPerProfileV2(Number(n)); console.log(JSON.stringify({ maxPendingSganRunsPerProfile: getMaxPendingSganRunsPerProfileV2() }, null, 2)); });
73
+ s.command("set-profile-idle-ms-v2 <ms>").action((ms) => { setSganProfileIdleMsV2(Number(ms)); console.log(JSON.stringify({ sganProfileIdleMs: getSganProfileIdleMsV2() }, null, 2)); });
74
+ s.command("set-run-stuck-ms-v2 <ms>").action((ms) => { setSganRunStuckMsV2(Number(ms)); console.log(JSON.stringify({ sganRunStuckMs: getSganRunStuckMsV2() }, null, 2)); });
75
+ s.command("auto-stale-idle-v2").action(() => console.log(JSON.stringify(autoStaleIdleSganProfilesV2(), null, 2)));
76
+ s.command("auto-fail-stuck-v2").action(() => console.log(JSON.stringify(autoFailStuckSganRunsV2(), null, 2)));
77
+ s.command("gov-stats-v2").action(() => console.log(JSON.stringify(getSocialGraphAnalyticsGovStatsV2(), null, 2)));
78
+ }
@@ -399,4 +399,44 @@ export function registerSiemCommand(program) {
399
399
  process.exit(1);
400
400
  }
401
401
  });
402
+
403
+ _registerSiemExporterV2Commands(siem);
404
+ }
405
+
406
+ function _registerSiemExporterV2Commands(parent) {
407
+ const L = async () => await import("../lib/siem-exporter.js");
408
+ parent.command("enums-v2").description("Show V2 enums (target maturity + export lifecycle)")
409
+ .action(async () => { const m = await L(); console.log(JSON.stringify({ targetMaturity: m.SIEM_TARGET_MATURITY_V2, exportLifecycle: m.SIEM_EXPORT_LIFECYCLE_V2 }, null, 2)); });
410
+ parent.command("config-v2").description("Show V2 config thresholds")
411
+ .action(async () => { const m = await L(); console.log(JSON.stringify({ maxActiveSiemTargetsPerOperator: m.getMaxActiveSiemTargetsPerOperatorV2(), maxPendingSiemExportsPerTarget: m.getMaxPendingSiemExportsPerTargetV2(), siemTargetIdleMs: m.getSiemTargetIdleMsV2(), siemExportStuckMs: m.getSiemExportStuckMsV2() }, null, 2)); });
412
+ parent.command("set-max-active-targets-v2 <n>").description("Set max active targets per operator")
413
+ .action(async (n) => { const m = await L(); m.setMaxActiveSiemTargetsPerOperatorV2(Number(n)); console.log("ok"); });
414
+ parent.command("set-max-pending-exports-v2 <n>").description("Set max pending exports per target")
415
+ .action(async (n) => { const m = await L(); m.setMaxPendingSiemExportsPerTargetV2(Number(n)); console.log("ok"); });
416
+ parent.command("set-target-idle-ms-v2 <n>").description("Set target idle threshold (ms)")
417
+ .action(async (n) => { const m = await L(); m.setSiemTargetIdleMsV2(Number(n)); console.log("ok"); });
418
+ parent.command("set-export-stuck-ms-v2 <n>").description("Set export stuck threshold (ms)")
419
+ .action(async (n) => { const m = await L(); m.setSiemExportStuckMsV2(Number(n)); console.log("ok"); });
420
+ parent.command("register-target-v2 <id> <operator>").description("Register V2 SIEM target")
421
+ .option("--kind <k>", "Target kind").action(async (id, operator, o) => { const m = await L(); console.log(JSON.stringify(m.registerSiemTargetV2({ id, operator, kind: o.kind }), null, 2)); });
422
+ parent.command("activate-target-v2 <id>").description("Activate target").action(async (id) => { const m = await L(); console.log(JSON.stringify(m.activateSiemTargetV2(id), null, 2)); });
423
+ parent.command("degrade-target-v2 <id>").description("Degrade target").action(async (id) => { const m = await L(); console.log(JSON.stringify(m.degradeSiemTargetV2(id), null, 2)); });
424
+ parent.command("retire-target-v2 <id>").description("Retire target (terminal)").action(async (id) => { const m = await L(); console.log(JSON.stringify(m.retireSiemTargetV2(id), null, 2)); });
425
+ parent.command("touch-target-v2 <id>").description("Touch target lastTouchedAt").action(async (id) => { const m = await L(); console.log(JSON.stringify(m.touchSiemTargetV2(id), null, 2)); });
426
+ parent.command("get-target-v2 <id>").description("Get V2 target").action(async (id) => { const m = await L(); console.log(JSON.stringify(m.getSiemTargetV2(id), null, 2)); });
427
+ parent.command("list-targets-v2").description("List V2 targets").action(async () => { const m = await L(); console.log(JSON.stringify(m.listSiemTargetsV2(), null, 2)); });
428
+ parent.command("create-export-v2 <id> <targetId>").description("Create V2 export (queued)")
429
+ .option("--format <f>", "Format", "json").action(async (id, targetId, o) => { const m = await L(); console.log(JSON.stringify(m.createSiemExportV2({ id, targetId, format: o.format }), null, 2)); });
430
+ parent.command("start-export-v2 <id>").description("Start export").action(async (id) => { const m = await L(); console.log(JSON.stringify(m.startSiemExportV2(id), null, 2)); });
431
+ parent.command("deliver-export-v2 <id>").description("Deliver export").action(async (id) => { const m = await L(); console.log(JSON.stringify(m.deliverSiemExportV2(id), null, 2)); });
432
+ parent.command("fail-export-v2 <id> [reason]").description("Fail export").action(async (id, reason) => { const m = await L(); console.log(JSON.stringify(m.failSiemExportV2(id, reason), null, 2)); });
433
+ parent.command("cancel-export-v2 <id> [reason]").description("Cancel export").action(async (id, reason) => { const m = await L(); console.log(JSON.stringify(m.cancelSiemExportV2(id, reason), null, 2)); });
434
+ parent.command("get-export-v2 <id>").description("Get V2 export").action(async (id) => { const m = await L(); console.log(JSON.stringify(m.getSiemExportV2(id), null, 2)); });
435
+ parent.command("list-exports-v2").description("List V2 exports").action(async () => { const m = await L(); console.log(JSON.stringify(m.listSiemExportsV2(), null, 2)); });
436
+ parent.command("auto-degrade-idle-v2").description("Auto-degrade idle targets")
437
+ .action(async () => { const m = await L(); console.log(JSON.stringify(m.autoDegradeIdleSiemTargetsV2(), null, 2)); });
438
+ parent.command("auto-fail-stuck-v2").description("Auto-fail stuck sending exports")
439
+ .action(async () => { const m = await L(); console.log(JSON.stringify(m.autoFailStuckSiemExportsV2(), null, 2)); });
440
+ parent.command("gov-stats-v2").description("V2 governance aggregate stats")
441
+ .action(async () => { const m = await L(); console.log(JSON.stringify(m.getSiemExporterGovStatsV2(), null, 2)); });
402
442
  }