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,78 @@
1
+ /**
2
+ * PDF Parser V2 governance commands — `cc pdfp ...`
3
+ * 在内存中治理 PDFP profile (pending/active/stale/archived) + parse 生命周期。
4
+ */
5
+ import {
6
+ PDFP_PROFILE_MATURITY_V2,
7
+ PDFP_PARSE_LIFECYCLE_V2,
8
+ registerPdfpProfileV2,
9
+ activatePdfpProfileV2,
10
+ stalePdfpProfileV2,
11
+ archivePdfpProfileV2,
12
+ touchPdfpProfileV2,
13
+ getPdfpProfileV2,
14
+ listPdfpProfilesV2,
15
+ createPdfpParseV2,
16
+ parsingPdfpParseV2,
17
+ parsePdfpParseV2,
18
+ failPdfpParseV2,
19
+ cancelPdfpParseV2,
20
+ getPdfpParseV2,
21
+ listPdfpParsesV2,
22
+ setMaxActivePdfpProfilesPerOwnerV2,
23
+ getMaxActivePdfpProfilesPerOwnerV2,
24
+ setMaxPendingPdfpParsesPerProfileV2,
25
+ getMaxPendingPdfpParsesPerProfileV2,
26
+ setPdfpProfileIdleMsV2,
27
+ getPdfpProfileIdleMsV2,
28
+ setPdfpParseStuckMsV2,
29
+ getPdfpParseStuckMsV2,
30
+ autoStaleIdlePdfpProfilesV2,
31
+ autoFailStuckPdfpParsesV2,
32
+ getPdfParserGovStatsV2,
33
+ } from "../lib/pdf-parser.js";
34
+
35
+ export function registerPdfpCommand(program) {
36
+ const p = program
37
+ .command("pdfp")
38
+ .description("PDF Parser V2 governance (in-memory, CLI v0.143.0)");
39
+
40
+ p.command("enums-v2").action(() => console.log(JSON.stringify({ PDFP_PROFILE_MATURITY_V2, PDFP_PARSE_LIFECYCLE_V2 }, null, 2)));
41
+ p.command("register-profile-v2")
42
+ .requiredOption("--id <id>")
43
+ .requiredOption("--owner <owner>")
44
+ .option("--encoding <encoding>", "encoding", "utf-8")
45
+ .action((o) => console.log(JSON.stringify(registerPdfpProfileV2(o), null, 2)));
46
+ p.command("activate-profile-v2 <id>").action((id) => console.log(JSON.stringify(activatePdfpProfileV2(id), null, 2)));
47
+ p.command("stale-profile-v2 <id>").action((id) => console.log(JSON.stringify(stalePdfpProfileV2(id), null, 2)));
48
+ p.command("archive-profile-v2 <id>").action((id) => console.log(JSON.stringify(archivePdfpProfileV2(id), null, 2)));
49
+ p.command("touch-profile-v2 <id>").action((id) => console.log(JSON.stringify(touchPdfpProfileV2(id), null, 2)));
50
+ p.command("get-profile-v2 <id>").action((id) => console.log(JSON.stringify(getPdfpProfileV2(id), null, 2)));
51
+ p.command("list-profiles-v2").action(() => console.log(JSON.stringify(listPdfpProfilesV2(), null, 2)));
52
+
53
+ p.command("create-parse-v2")
54
+ .requiredOption("--id <id>")
55
+ .requiredOption("--profile-id <profileId>")
56
+ .option("--path <path>", "pdf path", "")
57
+ .action((o) => console.log(JSON.stringify(createPdfpParseV2(o), null, 2)));
58
+ p.command("parsing-parse-v2 <id>").action((id) => console.log(JSON.stringify(parsingPdfpParseV2(id), null, 2)));
59
+ p.command("parse-parse-v2 <id>").action((id) => console.log(JSON.stringify(parsePdfpParseV2(id), null, 2)));
60
+ p.command("fail-parse-v2 <id>").option("--reason <r>").action((id, o) => console.log(JSON.stringify(failPdfpParseV2(id, o.reason), null, 2)));
61
+ p.command("cancel-parse-v2 <id>").option("--reason <r>").action((id, o) => console.log(JSON.stringify(cancelPdfpParseV2(id, o.reason), null, 2)));
62
+ p.command("get-parse-v2 <id>").action((id) => console.log(JSON.stringify(getPdfpParseV2(id), null, 2)));
63
+ p.command("list-parses-v2").action(() => console.log(JSON.stringify(listPdfpParsesV2(), null, 2)));
64
+
65
+ p.command("config-v2").action(() => console.log(JSON.stringify({
66
+ maxActivePdfpProfilesPerOwner: getMaxActivePdfpProfilesPerOwnerV2(),
67
+ maxPendingPdfpParsesPerProfile: getMaxPendingPdfpParsesPerProfileV2(),
68
+ pdfpProfileIdleMs: getPdfpProfileIdleMsV2(),
69
+ pdfpParseStuckMs: getPdfpParseStuckMsV2(),
70
+ }, null, 2)));
71
+ p.command("set-max-active-profiles-v2 <n>").action((n) => { setMaxActivePdfpProfilesPerOwnerV2(Number(n)); console.log(JSON.stringify({ maxActivePdfpProfilesPerOwner: getMaxActivePdfpProfilesPerOwnerV2() }, null, 2)); });
72
+ p.command("set-max-pending-parses-v2 <n>").action((n) => { setMaxPendingPdfpParsesPerProfileV2(Number(n)); console.log(JSON.stringify({ maxPendingPdfpParsesPerProfile: getMaxPendingPdfpParsesPerProfileV2() }, null, 2)); });
73
+ p.command("set-profile-idle-ms-v2 <ms>").action((ms) => { setPdfpProfileIdleMsV2(Number(ms)); console.log(JSON.stringify({ pdfpProfileIdleMs: getPdfpProfileIdleMsV2() }, null, 2)); });
74
+ p.command("set-parse-stuck-ms-v2 <ms>").action((ms) => { setPdfpParseStuckMsV2(Number(ms)); console.log(JSON.stringify({ pdfpParseStuckMs: getPdfpParseStuckMsV2() }, null, 2)); });
75
+ p.command("auto-stale-idle-v2").action(() => console.log(JSON.stringify(autoStaleIdlePdfpProfilesV2(), null, 2)));
76
+ p.command("auto-fail-stuck-v2").action(() => console.log(JSON.stringify(autoFailStuckPdfpParsesV2(), null, 2)));
77
+ p.command("gov-stats-v2").action(() => console.log(JSON.stringify(getPdfParserGovStatsV2(), null, 2)));
78
+ }
@@ -24,8 +24,53 @@ import {
24
24
  crossModalQuery,
25
25
  getPerceptionContext,
26
26
  getPerceptionStats,
27
+
28
+ // Phase 84 V2
29
+ SENSOR_MATURITY_V2,
30
+ CAPTURE_LIFECYCLE_V2,
31
+ getDefaultMaxActiveSensorsPerOperatorV2,
32
+ getMaxActiveSensorsPerOperatorV2,
33
+ setMaxActiveSensorsPerOperatorV2,
34
+ getDefaultMaxPendingCapturesPerSensorV2,
35
+ getMaxPendingCapturesPerSensorV2,
36
+ setMaxPendingCapturesPerSensorV2,
37
+ getDefaultSensorIdleMsV2,
38
+ getSensorIdleMsV2,
39
+ setSensorIdleMsV2,
40
+ getDefaultCaptureStuckMsV2,
41
+ getCaptureStuckMsV2,
42
+ setCaptureStuckMsV2,
43
+ registerSensorV2,
44
+ getSensorV2,
45
+ setSensorMaturityV2,
46
+ activateSensor,
47
+ degradeSensor,
48
+ offlineSensor,
49
+ retireSensor,
50
+ touchSensorHeartbeat,
51
+ registerCaptureV2,
52
+ getCaptureV2,
53
+ setCaptureStatusV2,
54
+ startProcessingCapture,
55
+ markCaptureReady,
56
+ failCapture,
57
+ discardCapture,
58
+ getActiveSensorCount,
59
+ getPendingCaptureCount,
60
+ autoOfflineStaleSensors,
61
+ autoFailStuckProcessingCaptures,
62
+ getPerceptionStatsV2,
27
63
  } from "../lib/perception.js";
28
64
 
65
+ function _parseMetaV2(raw) {
66
+ if (!raw) return undefined;
67
+ try {
68
+ return JSON.parse(raw);
69
+ } catch {
70
+ throw new Error("--metadata must be valid JSON");
71
+ }
72
+ }
73
+
29
74
  function _dbFromCtx(cmd) {
30
75
  const root = cmd?.parent?.parent ?? cmd?.parent;
31
76
  return root?._db;
@@ -381,5 +426,250 @@ export function registerPerceptionCommand(program) {
381
426
  console.log(`Index: ${s.index.total} entries`);
382
427
  });
383
428
 
429
+ /* ═══════════════════════════════════════════════════ *
430
+ * Phase 84 V2 — Sensor Maturity + Capture Lifecycle
431
+ * ═══════════════════════════════════════════════════ */
432
+
433
+ perc
434
+ .command("sensor-maturities-v2")
435
+ .description("List V2 sensor maturity states")
436
+ .option("--json", "JSON output")
437
+ .action((opts) => {
438
+ const xs = Object.values(SENSOR_MATURITY_V2);
439
+ if (opts.json) return console.log(JSON.stringify(xs, null, 2));
440
+ for (const x of xs) console.log(` ${x}`);
441
+ });
442
+
443
+ perc
444
+ .command("capture-lifecycles-v2")
445
+ .description("List V2 capture lifecycle states")
446
+ .option("--json", "JSON output")
447
+ .action((opts) => {
448
+ const xs = Object.values(CAPTURE_LIFECYCLE_V2);
449
+ if (opts.json) return console.log(JSON.stringify(xs, null, 2));
450
+ for (const x of xs) console.log(` ${x}`);
451
+ });
452
+
453
+ // ── Config defaults/getters/setters ────────────────
454
+
455
+ perc
456
+ .command("default-max-active-sensors-per-operator")
457
+ .description("Default cap")
458
+ .action(() => console.log(getDefaultMaxActiveSensorsPerOperatorV2()));
459
+ perc
460
+ .command("max-active-sensors-per-operator")
461
+ .description("Current cap")
462
+ .action(() => console.log(getMaxActiveSensorsPerOperatorV2()));
463
+ perc
464
+ .command("set-max-active-sensors-per-operator <n>")
465
+ .description("Set cap")
466
+ .action((n) => console.log(setMaxActiveSensorsPerOperatorV2(n)));
467
+
468
+ perc
469
+ .command("default-max-pending-captures-per-sensor")
470
+ .description("Default cap")
471
+ .action(() => console.log(getDefaultMaxPendingCapturesPerSensorV2()));
472
+ perc
473
+ .command("max-pending-captures-per-sensor")
474
+ .description("Current cap")
475
+ .action(() => console.log(getMaxPendingCapturesPerSensorV2()));
476
+ perc
477
+ .command("set-max-pending-captures-per-sensor <n>")
478
+ .description("Set cap")
479
+ .action((n) => console.log(setMaxPendingCapturesPerSensorV2(n)));
480
+
481
+ perc
482
+ .command("default-sensor-idle-ms")
483
+ .description("Default idle ms")
484
+ .action(() => console.log(getDefaultSensorIdleMsV2()));
485
+ perc
486
+ .command("sensor-idle-ms")
487
+ .description("Current idle ms")
488
+ .action(() => console.log(getSensorIdleMsV2()));
489
+ perc
490
+ .command("set-sensor-idle-ms <ms>")
491
+ .description("Set idle ms")
492
+ .action((ms) => console.log(setSensorIdleMsV2(ms)));
493
+
494
+ perc
495
+ .command("default-capture-stuck-ms")
496
+ .description("Default stuck ms")
497
+ .action(() => console.log(getDefaultCaptureStuckMsV2()));
498
+ perc
499
+ .command("capture-stuck-ms")
500
+ .description("Current stuck ms")
501
+ .action(() => console.log(getCaptureStuckMsV2()));
502
+ perc
503
+ .command("set-capture-stuck-ms <ms>")
504
+ .description("Set stuck ms")
505
+ .action((ms) => console.log(setCaptureStuckMsV2(ms)));
506
+
507
+ // ── Counts ─────────────────────────────────────────
508
+
509
+ perc
510
+ .command("active-sensor-count")
511
+ .description("Count of ACTIVE sensors")
512
+ .option("-o, --operator <id>", "filter by operator")
513
+ .action((opts) => console.log(getActiveSensorCount(opts.operator)));
514
+
515
+ perc
516
+ .command("pending-capture-count")
517
+ .description("Count of PENDING captures")
518
+ .option("-s, --sensor <id>", "filter by sensor")
519
+ .action((opts) => console.log(getPendingCaptureCount(opts.sensor)));
520
+
521
+ // ── Sensor lifecycle ───────────────────────────────
522
+
523
+ perc
524
+ .command("register-sensor-v2 <sensor-id>")
525
+ .description("Register a V2 sensor")
526
+ .requiredOption("-o, --operator <id>", "operator id")
527
+ .requiredOption("-m, --modality <mod>", "modality")
528
+ .option("-i, --initial-status <status>", "initial status")
529
+ .option("--metadata <json>", "metadata JSON")
530
+ .action((id, opts) => {
531
+ const r = registerSensorV2(null, {
532
+ sensorId: id,
533
+ operatorId: opts.operator,
534
+ modality: opts.modality,
535
+ initialStatus: opts.initialStatus,
536
+ metadata: _parseMetaV2(opts.metadata),
537
+ });
538
+ console.log(JSON.stringify(r, null, 2));
539
+ });
540
+
541
+ perc
542
+ .command("sensor-v2 <sensor-id>")
543
+ .description("Get a V2 sensor")
544
+ .action((id) => {
545
+ const r = getSensorV2(id);
546
+ if (!r) {
547
+ console.error(`Unknown sensor: ${id}`);
548
+ process.exitCode = 1;
549
+ return;
550
+ }
551
+ console.log(JSON.stringify(r, null, 2));
552
+ });
553
+
554
+ perc
555
+ .command("set-sensor-maturity-v2 <sensor-id> <status>")
556
+ .description("Transition sensor maturity")
557
+ .option("-r, --reason <text>", "reason")
558
+ .option("--metadata <json>", "metadata JSON")
559
+ .action((id, status, opts) => {
560
+ const r = setSensorMaturityV2(null, id, status, {
561
+ reason: opts.reason,
562
+ metadata: _parseMetaV2(opts.metadata),
563
+ });
564
+ console.log(JSON.stringify(r, null, 2));
565
+ });
566
+
567
+ for (const [name, fn] of [
568
+ ["activate-sensor", activateSensor],
569
+ ["degrade-sensor", degradeSensor],
570
+ ["offline-sensor", offlineSensor],
571
+ ["retire-sensor", retireSensor],
572
+ ]) {
573
+ perc
574
+ .command(`${name} <sensor-id>`)
575
+ .description(`Transition to ${name.split("-")[0]}`)
576
+ .option("-r, --reason <text>", "reason")
577
+ .action((id, opts) => {
578
+ const r = fn(null, id, opts.reason);
579
+ console.log(JSON.stringify(r, null, 2));
580
+ });
581
+ }
582
+
583
+ perc
584
+ .command("touch-sensor-heartbeat <sensor-id>")
585
+ .description("Bump lastHeartbeatAt")
586
+ .action((id) => {
587
+ const r = touchSensorHeartbeat(id);
588
+ console.log(JSON.stringify(r, null, 2));
589
+ });
590
+
591
+ // ── Capture lifecycle ──────────────────────────────
592
+
593
+ perc
594
+ .command("register-capture-v2 <capture-id>")
595
+ .description("Register a V2 capture")
596
+ .requiredOption("-s, --sensor <id>", "sensor id")
597
+ .option("-i, --initial-status <status>", "initial status")
598
+ .option("--metadata <json>", "metadata JSON")
599
+ .action((id, opts) => {
600
+ const r = registerCaptureV2(null, {
601
+ captureId: id,
602
+ sensorId: opts.sensor,
603
+ initialStatus: opts.initialStatus,
604
+ metadata: _parseMetaV2(opts.metadata),
605
+ });
606
+ console.log(JSON.stringify(r, null, 2));
607
+ });
608
+
609
+ perc
610
+ .command("capture-v2 <capture-id>")
611
+ .description("Get a V2 capture")
612
+ .action((id) => {
613
+ const r = getCaptureV2(id);
614
+ if (!r) {
615
+ console.error(`Unknown capture: ${id}`);
616
+ process.exitCode = 1;
617
+ return;
618
+ }
619
+ console.log(JSON.stringify(r, null, 2));
620
+ });
621
+
622
+ perc
623
+ .command("set-capture-status-v2 <capture-id> <status>")
624
+ .description("Transition capture lifecycle")
625
+ .option("-r, --reason <text>", "reason")
626
+ .option("--metadata <json>", "metadata JSON")
627
+ .action((id, status, opts) => {
628
+ const r = setCaptureStatusV2(null, id, status, {
629
+ reason: opts.reason,
630
+ metadata: _parseMetaV2(opts.metadata),
631
+ });
632
+ console.log(JSON.stringify(r, null, 2));
633
+ });
634
+
635
+ for (const [name, fn] of [
636
+ ["start-processing-capture", startProcessingCapture],
637
+ ["mark-capture-ready", markCaptureReady],
638
+ ["fail-capture", failCapture],
639
+ ["discard-capture", discardCapture],
640
+ ]) {
641
+ perc
642
+ .command(`${name} <capture-id>`)
643
+ .description(`Transition capture (${name})`)
644
+ .option("-r, --reason <text>", "reason")
645
+ .action((id, opts) => {
646
+ const r = fn(null, id, opts.reason);
647
+ console.log(JSON.stringify(r, null, 2));
648
+ });
649
+ }
650
+
651
+ // ── Auto-flips + stats ─────────────────────────────
652
+
653
+ perc
654
+ .command("auto-offline-stale-sensors")
655
+ .description("Flip stale ACTIVE/DEGRADED sensors → OFFLINE")
656
+ .action(() =>
657
+ console.log(JSON.stringify(autoOfflineStaleSensors(null), null, 2)),
658
+ );
659
+
660
+ perc
661
+ .command("auto-fail-stuck-processing-captures")
662
+ .description("Flip stuck PROCESSING captures → FAILED")
663
+ .action(() =>
664
+ console.log(
665
+ JSON.stringify(autoFailStuckProcessingCaptures(null), null, 2),
666
+ ),
667
+ );
668
+
669
+ perc
670
+ .command("stats-v2")
671
+ .description("V2 stats snapshot")
672
+ .action(() => console.log(JSON.stringify(getPerceptionStatsV2(), null, 2)));
673
+
384
674
  program.addCommand(perc);
385
675
  }
@@ -429,5 +429,44 @@ export function registerPerfCommand(program) {
429
429
  console.log(`Recent history: ${r.recentHistory.length}`);
430
430
  });
431
431
 
432
+ _registerPerfV2(perf);
432
433
  program.addCommand(perf);
433
434
  }
435
+
436
+ import {
437
+ PERF_TUNING_PROFILE_MATURITY_V2, PERF_BENCH_LIFECYCLE_V2,
438
+ setMaxActivePerfTuningProfilesPerOwnerV2, getMaxActivePerfTuningProfilesPerOwnerV2,
439
+ setMaxPendingPerfBenchesPerProfileV2, getMaxPendingPerfBenchesPerProfileV2,
440
+ setPerfTuningProfileIdleMsV2, getPerfTuningProfileIdleMsV2,
441
+ setPerfBenchStuckMsV2, getPerfBenchStuckMsV2,
442
+ registerPerfTuningProfileV2, activatePerfTuningProfileV2, stalePerfTuningProfileV2, decommissionPerfTuningProfileV2, touchPerfTuningProfileV2, getPerfTuningProfileV2, listPerfTuningProfilesV2,
443
+ createPerfBenchV2, startPerfBenchV2, completePerfBenchV2, failPerfBenchV2, cancelPerfBenchV2, getPerfBenchV2, listPerfBenchesV2,
444
+ autoStaleIdlePerfTuningProfilesV2, autoFailStuckPerfBenchesV2, getPerfTuningGovStatsV2, _resetStatePerfTuningV2,
445
+ } from "../lib/perf-tuning.js";
446
+
447
+ function _registerPerfV2(parent) {
448
+ parent.command("enums-v2").action(() => console.log(JSON.stringify({ profileMaturity: PERF_TUNING_PROFILE_MATURITY_V2, benchLifecycle: PERF_BENCH_LIFECYCLE_V2 }, null, 2)));
449
+ parent.command("config-v2").action(() => console.log(JSON.stringify({ maxActivePerfTuningProfilesPerOwner: getMaxActivePerfTuningProfilesPerOwnerV2(), maxPendingPerfBenchesPerProfile: getMaxPendingPerfBenchesPerProfileV2(), perfTuningProfileIdleMs: getPerfTuningProfileIdleMsV2(), perfBenchStuckMs: getPerfBenchStuckMsV2() }, null, 2)));
450
+ parent.command("set-max-active-v2 <n>").action((n) => { setMaxActivePerfTuningProfilesPerOwnerV2(Number(n)); console.log("ok"); });
451
+ parent.command("set-max-pending-v2 <n>").action((n) => { setMaxPendingPerfBenchesPerProfileV2(Number(n)); console.log("ok"); });
452
+ parent.command("set-idle-ms-v2 <n>").action((n) => { setPerfTuningProfileIdleMsV2(Number(n)); console.log("ok"); });
453
+ parent.command("set-stuck-ms-v2 <n>").action((n) => { setPerfBenchStuckMsV2(Number(n)); console.log("ok"); });
454
+ parent.command("register-profile-v2 <id> <owner>").option("--target <t>", "target").action((id, owner, o) => console.log(JSON.stringify(registerPerfTuningProfileV2({ id, owner, target: o.target }), null, 2)));
455
+ parent.command("activate-profile-v2 <id>").action((id) => console.log(JSON.stringify(activatePerfTuningProfileV2(id), null, 2)));
456
+ parent.command("stale-profile-v2 <id>").action((id) => console.log(JSON.stringify(stalePerfTuningProfileV2(id), null, 2)));
457
+ parent.command("decommission-profile-v2 <id>").action((id) => console.log(JSON.stringify(decommissionPerfTuningProfileV2(id), null, 2)));
458
+ parent.command("touch-profile-v2 <id>").action((id) => console.log(JSON.stringify(touchPerfTuningProfileV2(id), null, 2)));
459
+ parent.command("get-profile-v2 <id>").action((id) => console.log(JSON.stringify(getPerfTuningProfileV2(id), null, 2)));
460
+ parent.command("list-profiles-v2").action(() => console.log(JSON.stringify(listPerfTuningProfilesV2(), null, 2)));
461
+ parent.command("create-bench-v2 <id> <profileId>").option("--scenario <s>", "scenario").action((id, profileId, o) => console.log(JSON.stringify(createPerfBenchV2({ id, profileId, scenario: o.scenario }), null, 2)));
462
+ parent.command("start-bench-v2 <id>").action((id) => console.log(JSON.stringify(startPerfBenchV2(id), null, 2)));
463
+ parent.command("complete-bench-v2 <id>").action((id) => console.log(JSON.stringify(completePerfBenchV2(id), null, 2)));
464
+ parent.command("fail-bench-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(failPerfBenchV2(id, reason), null, 2)));
465
+ parent.command("cancel-bench-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(cancelPerfBenchV2(id, reason), null, 2)));
466
+ parent.command("get-bench-v2 <id>").action((id) => console.log(JSON.stringify(getPerfBenchV2(id), null, 2)));
467
+ parent.command("list-benches-v2").action(() => console.log(JSON.stringify(listPerfBenchesV2(), null, 2)));
468
+ parent.command("auto-stale-idle-v2").action(() => console.log(JSON.stringify(autoStaleIdlePerfTuningProfilesV2(), null, 2)));
469
+ parent.command("auto-fail-stuck-v2").action(() => console.log(JSON.stringify(autoFailStuckPerfBenchesV2(), null, 2)));
470
+ parent.command("gov-stats-v2").action(() => console.log(JSON.stringify(getPerfTuningGovStatsV2(), null, 2)));
471
+ parent.command("reset-state-v2").action(() => { _resetStatePerfTuningV2(); console.log(JSON.stringify({ ok: true }, null, 2)); });
472
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * `cc perm` — Permission Engine V2 governance overlay.
3
+ *
4
+ * In-memory governance for permission rules + check lifecycle, layered atop
5
+ * `lib/permission-engine.js`. Independent of legacy permission helpers.
6
+ */
7
+
8
+ import {
9
+ PERM_RULE_MATURITY_V2, PERM_CHECK_LIFECYCLE_V2,
10
+ setMaxActivePermRulesPerOwnerV2, getMaxActivePermRulesPerOwnerV2,
11
+ setMaxPendingPermChecksPerRuleV2, getMaxPendingPermChecksPerRuleV2,
12
+ setPermRuleIdleMsV2, getPermRuleIdleMsV2,
13
+ setPermCheckStuckMsV2, getPermCheckStuckMsV2,
14
+ registerPermRuleV2, activatePermRuleV2, disablePermRuleV2, retirePermRuleV2, touchPermRuleV2, getPermRuleV2, listPermRulesV2,
15
+ createPermCheckV2, evaluatePermCheckV2, allowPermCheckV2, denyPermCheckV2, cancelPermCheckV2, getPermCheckV2, listPermChecksV2,
16
+ autoDisableIdlePermRulesV2, autoDenyStuckPermChecksV2, getPermissionEngineGovStatsV2, _resetStatePermissionEngineV2,
17
+ } from "../lib/permission-engine.js";
18
+
19
+ export function registerPermCommand(program) {
20
+ const pe = program.command("perm").description("Permission Engine V2 governance");
21
+ pe.command("enums-v2").action(() => console.log(JSON.stringify({ ruleMaturity: PERM_RULE_MATURITY_V2, checkLifecycle: PERM_CHECK_LIFECYCLE_V2 }, null, 2)));
22
+ pe.command("config-v2").action(() => console.log(JSON.stringify({ maxActivePermRulesPerOwner: getMaxActivePermRulesPerOwnerV2(), maxPendingPermChecksPerRule: getMaxPendingPermChecksPerRuleV2(), permRuleIdleMs: getPermRuleIdleMsV2(), permCheckStuckMs: getPermCheckStuckMsV2() }, null, 2)));
23
+ pe.command("set-max-active-v2 <n>").action((n) => { setMaxActivePermRulesPerOwnerV2(Number(n)); console.log("ok"); });
24
+ pe.command("set-max-pending-v2 <n>").action((n) => { setMaxPendingPermChecksPerRuleV2(Number(n)); console.log("ok"); });
25
+ pe.command("set-idle-ms-v2 <n>").action((n) => { setPermRuleIdleMsV2(Number(n)); console.log("ok"); });
26
+ pe.command("set-stuck-ms-v2 <n>").action((n) => { setPermCheckStuckMsV2(Number(n)); console.log("ok"); });
27
+ pe.command("register-rule-v2 <id> <owner>").option("--scope <s>", "scope").action((id, owner, o) => console.log(JSON.stringify(registerPermRuleV2({ id, owner, scope: o.scope }), null, 2)));
28
+ pe.command("activate-rule-v2 <id>").action((id) => console.log(JSON.stringify(activatePermRuleV2(id), null, 2)));
29
+ pe.command("disable-rule-v2 <id>").action((id) => console.log(JSON.stringify(disablePermRuleV2(id), null, 2)));
30
+ pe.command("retire-rule-v2 <id>").action((id) => console.log(JSON.stringify(retirePermRuleV2(id), null, 2)));
31
+ pe.command("touch-rule-v2 <id>").action((id) => console.log(JSON.stringify(touchPermRuleV2(id), null, 2)));
32
+ pe.command("get-rule-v2 <id>").action((id) => console.log(JSON.stringify(getPermRuleV2(id), null, 2)));
33
+ pe.command("list-rules-v2").action(() => console.log(JSON.stringify(listPermRulesV2(), null, 2)));
34
+ pe.command("create-check-v2 <id> <ruleId>").option("--subject <s>", "subject").action((id, ruleId, o) => console.log(JSON.stringify(createPermCheckV2({ id, ruleId, subject: o.subject }), null, 2)));
35
+ pe.command("evaluate-check-v2 <id>").action((id) => console.log(JSON.stringify(evaluatePermCheckV2(id), null, 2)));
36
+ pe.command("allow-check-v2 <id>").action((id) => console.log(JSON.stringify(allowPermCheckV2(id), null, 2)));
37
+ pe.command("deny-check-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(denyPermCheckV2(id, reason), null, 2)));
38
+ pe.command("cancel-check-v2 <id> [reason]").action((id, reason) => console.log(JSON.stringify(cancelPermCheckV2(id, reason), null, 2)));
39
+ pe.command("get-check-v2 <id>").action((id) => console.log(JSON.stringify(getPermCheckV2(id), null, 2)));
40
+ pe.command("list-checks-v2").action(() => console.log(JSON.stringify(listPermChecksV2(), null, 2)));
41
+ pe.command("auto-disable-idle-v2").action(() => console.log(JSON.stringify(autoDisableIdlePermRulesV2(), null, 2)));
42
+ pe.command("auto-deny-stuck-v2").action(() => console.log(JSON.stringify(autoDenyStuckPermChecksV2(), null, 2)));
43
+ pe.command("gov-stats-v2").action(() => console.log(JSON.stringify(getPermissionEngineGovStatsV2(), null, 2)));
44
+ pe.command("reset-state-v2").action(() => { _resetStatePermissionEngineV2(); console.log(JSON.stringify({ ok: true }, null, 2)); });
45
+ }