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
@@ -25,8 +25,53 @@ import {
25
25
  listRoutes,
26
26
  getConnectivityReport,
27
27
  getInfraStats,
28
+
29
+ // Phase 74-75 V2
30
+ PROVIDER_MATURITY_V2,
31
+ DEAL_LIFECYCLE_V2,
32
+ getDefaultMaxActiveProvidersPerOperatorV2,
33
+ getMaxActiveProvidersPerOperatorV2,
34
+ setMaxActiveProvidersPerOperatorV2,
35
+ getDefaultMaxActiveDealsPerProviderV2,
36
+ getMaxActiveDealsPerProviderV2,
37
+ setMaxActiveDealsPerProviderV2,
38
+ getDefaultProviderIdleMsV2,
39
+ getProviderIdleMsV2,
40
+ setProviderIdleMsV2,
41
+ getDefaultDealStuckMsV2,
42
+ getDealStuckMsV2,
43
+ setDealStuckMsV2,
44
+ registerProviderV2,
45
+ getProviderV2,
46
+ setProviderMaturityV2,
47
+ activateProvider,
48
+ degradeProvider,
49
+ offlineProvider,
50
+ retireProvider,
51
+ touchProviderHeartbeat,
52
+ enqueueDealV2,
53
+ getDealV2,
54
+ setDealStatusV2,
55
+ activateDeal,
56
+ completeDeal,
57
+ failDeal,
58
+ cancelDeal,
59
+ getActiveProviderCount,
60
+ getActiveDealCount,
61
+ autoOfflineStaleProviders,
62
+ autoFailStuckActiveDeals,
63
+ getDecentralInfraStatsV2,
28
64
  } from "../lib/decentral-infra.js";
29
65
 
66
+ function _parseMetaV2(raw) {
67
+ if (!raw) return undefined;
68
+ try {
69
+ return JSON.parse(raw);
70
+ } catch {
71
+ throw new Error("--metadata must be valid JSON");
72
+ }
73
+ }
74
+
30
75
  function _dbFromCtx(cmd) {
31
76
  const root = cmd?.parent?.parent ?? cmd?.parent;
32
77
  return root?._db;
@@ -357,5 +402,204 @@ export function registerInfraCommand(program) {
357
402
  );
358
403
  });
359
404
 
405
+ /* ═══════════════════════════════════════════════════ *
406
+ * Phase 74-75 V2
407
+ * ═══════════════════════════════════════════════════ */
408
+
409
+ inf
410
+ .command("provider-maturities-v2")
411
+ .description("List V2 provider maturity states")
412
+ .option("--json", "JSON")
413
+ .action((opts) => {
414
+ const xs = Object.values(PROVIDER_MATURITY_V2);
415
+ if (opts.json) return console.log(JSON.stringify(xs, null, 2));
416
+ for (const x of xs) console.log(` ${x}`);
417
+ });
418
+
419
+ inf
420
+ .command("deal-lifecycles-v2")
421
+ .description("List V2 deal lifecycle states")
422
+ .option("--json", "JSON")
423
+ .action((opts) => {
424
+ const xs = Object.values(DEAL_LIFECYCLE_V2);
425
+ if (opts.json) return console.log(JSON.stringify(xs, null, 2));
426
+ for (const x of xs) console.log(` ${x}`);
427
+ });
428
+
429
+ inf
430
+ .command("default-max-active-providers-per-operator")
431
+ .action(() => console.log(getDefaultMaxActiveProvidersPerOperatorV2()));
432
+ inf
433
+ .command("max-active-providers-per-operator")
434
+ .action(() => console.log(getMaxActiveProvidersPerOperatorV2()));
435
+ inf
436
+ .command("set-max-active-providers-per-operator <n>")
437
+ .action((n) => console.log(setMaxActiveProvidersPerOperatorV2(n)));
438
+
439
+ inf
440
+ .command("default-max-active-deals-per-provider")
441
+ .action(() => console.log(getDefaultMaxActiveDealsPerProviderV2()));
442
+ inf
443
+ .command("max-active-deals-per-provider")
444
+ .action(() => console.log(getMaxActiveDealsPerProviderV2()));
445
+ inf
446
+ .command("set-max-active-deals-per-provider <n>")
447
+ .action((n) => console.log(setMaxActiveDealsPerProviderV2(n)));
448
+
449
+ inf
450
+ .command("default-provider-idle-ms")
451
+ .action(() => console.log(getDefaultProviderIdleMsV2()));
452
+ inf
453
+ .command("provider-idle-ms")
454
+ .action(() => console.log(getProviderIdleMsV2()));
455
+ inf
456
+ .command("set-provider-idle-ms <ms>")
457
+ .action((ms) => console.log(setProviderIdleMsV2(ms)));
458
+
459
+ inf
460
+ .command("default-deal-stuck-ms")
461
+ .action(() => console.log(getDefaultDealStuckMsV2()));
462
+ inf.command("deal-stuck-ms").action(() => console.log(getDealStuckMsV2()));
463
+ inf
464
+ .command("set-deal-stuck-ms <ms>")
465
+ .action((ms) => console.log(setDealStuckMsV2(ms)));
466
+
467
+ inf
468
+ .command("active-provider-count")
469
+ .option("-o, --operator <id>")
470
+ .action((opts) => console.log(getActiveProviderCount(opts.operator)));
471
+ inf
472
+ .command("active-deal-count")
473
+ .option("-p, --provider <id>")
474
+ .action((opts) => console.log(getActiveDealCount(opts.provider)));
475
+
476
+ inf
477
+ .command("register-provider-v2 <provider-id>")
478
+ .requiredOption("-o, --operator <id>")
479
+ .requiredOption("-k, --kind <kind>")
480
+ .option("-i, --initial-status <s>")
481
+ .option("--metadata <json>")
482
+ .action((id, opts) => {
483
+ const r = registerProviderV2(null, {
484
+ providerId: id,
485
+ operatorId: opts.operator,
486
+ kind: opts.kind,
487
+ initialStatus: opts.initialStatus,
488
+ metadata: _parseMetaV2(opts.metadata),
489
+ });
490
+ console.log(JSON.stringify(r, null, 2));
491
+ });
492
+
493
+ inf.command("provider-v2 <provider-id>").action((id) => {
494
+ const r = getProviderV2(id);
495
+ if (!r) {
496
+ console.error(`Unknown provider: ${id}`);
497
+ process.exitCode = 1;
498
+ return;
499
+ }
500
+ console.log(JSON.stringify(r, null, 2));
501
+ });
502
+
503
+ inf
504
+ .command("set-provider-maturity-v2 <provider-id> <status>")
505
+ .option("-r, --reason <text>")
506
+ .option("--metadata <json>")
507
+ .action((id, status, opts) => {
508
+ const r = setProviderMaturityV2(null, id, status, {
509
+ reason: opts.reason,
510
+ metadata: _parseMetaV2(opts.metadata),
511
+ });
512
+ console.log(JSON.stringify(r, null, 2));
513
+ });
514
+
515
+ for (const [name, fn] of [
516
+ ["activate-provider", activateProvider],
517
+ ["degrade-provider", degradeProvider],
518
+ ["offline-provider", offlineProvider],
519
+ ["retire-provider", retireProvider],
520
+ ]) {
521
+ inf
522
+ .command(`${name} <provider-id>`)
523
+ .option("-r, --reason <text>")
524
+ .action((id, opts) => {
525
+ const r = fn(null, id, opts.reason);
526
+ console.log(JSON.stringify(r, null, 2));
527
+ });
528
+ }
529
+
530
+ inf
531
+ .command("touch-provider-heartbeat <provider-id>")
532
+ .action((id) =>
533
+ console.log(JSON.stringify(touchProviderHeartbeat(id), null, 2)),
534
+ );
535
+
536
+ inf
537
+ .command("enqueue-deal-v2 <deal-id>")
538
+ .requiredOption("-p, --provider <id>")
539
+ .requiredOption("-o, --owner <id>")
540
+ .option("--metadata <json>")
541
+ .action((id, opts) => {
542
+ const r = enqueueDealV2(null, {
543
+ dealId: id,
544
+ providerId: opts.provider,
545
+ ownerId: opts.owner,
546
+ metadata: _parseMetaV2(opts.metadata),
547
+ });
548
+ console.log(JSON.stringify(r, null, 2));
549
+ });
550
+
551
+ inf.command("deal-v2 <deal-id>").action((id) => {
552
+ const r = getDealV2(id);
553
+ if (!r) {
554
+ console.error(`Unknown deal: ${id}`);
555
+ process.exitCode = 1;
556
+ return;
557
+ }
558
+ console.log(JSON.stringify(r, null, 2));
559
+ });
560
+
561
+ inf
562
+ .command("set-deal-status-v2 <deal-id> <status>")
563
+ .option("-r, --reason <text>")
564
+ .option("--metadata <json>")
565
+ .action((id, status, opts) => {
566
+ const r = setDealStatusV2(null, id, status, {
567
+ reason: opts.reason,
568
+ metadata: _parseMetaV2(opts.metadata),
569
+ });
570
+ console.log(JSON.stringify(r, null, 2));
571
+ });
572
+
573
+ for (const [name, fn] of [
574
+ ["activate-deal", activateDeal],
575
+ ["complete-deal", completeDeal],
576
+ ["fail-deal", failDeal],
577
+ ["cancel-deal", cancelDeal],
578
+ ]) {
579
+ inf
580
+ .command(`${name} <deal-id>`)
581
+ .option("-r, --reason <text>")
582
+ .action((id, opts) => {
583
+ const r = fn(null, id, opts.reason);
584
+ console.log(JSON.stringify(r, null, 2));
585
+ });
586
+ }
587
+
588
+ inf
589
+ .command("auto-offline-stale-providers")
590
+ .action(() =>
591
+ console.log(JSON.stringify(autoOfflineStaleProviders(null), null, 2)),
592
+ );
593
+ inf
594
+ .command("auto-fail-stuck-active-deals")
595
+ .action(() =>
596
+ console.log(JSON.stringify(autoFailStuckActiveDeals(null), null, 2)),
597
+ );
598
+ inf
599
+ .command("stats-v2")
600
+ .action(() =>
601
+ console.log(JSON.stringify(getDecentralInfraStatsV2(), null, 2)),
602
+ );
603
+
360
604
  program.addCommand(inf);
361
605
  }
@@ -14,6 +14,35 @@ import {
14
14
  decayInstincts,
15
15
  generateInstinctPrompt,
16
16
  INSTINCT_CATEGORIES,
17
+ PROFILE_MATURITY_V2,
18
+ OBSERVATION_LIFECYCLE_V2,
19
+ getMaxActiveProfilesPerUserV2,
20
+ setMaxActiveProfilesPerUserV2,
21
+ getMaxPendingObsPerProfileV2,
22
+ setMaxPendingObsPerProfileV2,
23
+ getProfileIdleMsV2,
24
+ setProfileIdleMsV2,
25
+ getObsStuckMsV2,
26
+ setObsStuckMsV2,
27
+ getActiveProfileCountV2,
28
+ getPendingObsCountV2,
29
+ registerProfileV2,
30
+ getProfileV2,
31
+ listProfilesV2,
32
+ activateProfileV2,
33
+ dormantProfileV2,
34
+ archiveProfileV2,
35
+ touchProfileV2,
36
+ createObservationV2,
37
+ getObservationV2,
38
+ listObservationsV2,
39
+ reviewObservationV2,
40
+ reinforceObservationV2,
41
+ promoteObservationV2,
42
+ discardObservationV2,
43
+ autoDormantIdleProfilesV2,
44
+ autoDiscardStaleObservationsV2,
45
+ getInstinctManagerStatsV2,
17
46
  } from "../lib/instinct-manager.js";
18
47
 
19
48
  export function registerInstinctCommand(program) {
@@ -199,4 +228,235 @@ export function registerInstinctCommand(program) {
199
228
  process.exit(1);
200
229
  }
201
230
  });
231
+
232
+ // ─── V2 governance surface ─────────────────────────────────
233
+
234
+ instinct
235
+ .command("profile-maturities-v2")
236
+ .description("List V2 profile maturity states")
237
+ .action(() => {
238
+ console.log(JSON.stringify(Object.values(PROFILE_MATURITY_V2), null, 2));
239
+ });
240
+
241
+ instinct
242
+ .command("observation-lifecycles-v2")
243
+ .description("List V2 observation lifecycle states")
244
+ .action(() => {
245
+ console.log(
246
+ JSON.stringify(Object.values(OBSERVATION_LIFECYCLE_V2), null, 2),
247
+ );
248
+ });
249
+
250
+ instinct
251
+ .command("stats-v2")
252
+ .description("Show V2 governance stats")
253
+ .action(() => {
254
+ console.log(JSON.stringify(getInstinctManagerStatsV2(), null, 2));
255
+ });
256
+
257
+ instinct
258
+ .command("get-max-active-profiles-v2")
259
+ .description("Get max active profiles per user")
260
+ .action(() => console.log(getMaxActiveProfilesPerUserV2()));
261
+
262
+ instinct
263
+ .command("set-max-active-profiles-v2 <n>")
264
+ .description("Set max active profiles per user")
265
+ .action((n) => {
266
+ setMaxActiveProfilesPerUserV2(Number(n));
267
+ console.log(getMaxActiveProfilesPerUserV2());
268
+ });
269
+
270
+ instinct
271
+ .command("get-max-pending-obs-v2")
272
+ .description("Get max pending observations per profile")
273
+ .action(() => console.log(getMaxPendingObsPerProfileV2()));
274
+
275
+ instinct
276
+ .command("set-max-pending-obs-v2 <n>")
277
+ .description("Set max pending observations per profile")
278
+ .action((n) => {
279
+ setMaxPendingObsPerProfileV2(Number(n));
280
+ console.log(getMaxPendingObsPerProfileV2());
281
+ });
282
+
283
+ instinct
284
+ .command("get-profile-idle-ms-v2")
285
+ .description("Get profile idle threshold (ms)")
286
+ .action(() => console.log(getProfileIdleMsV2()));
287
+
288
+ instinct
289
+ .command("set-profile-idle-ms-v2 <n>")
290
+ .description("Set profile idle threshold (ms)")
291
+ .action((n) => {
292
+ setProfileIdleMsV2(Number(n));
293
+ console.log(getProfileIdleMsV2());
294
+ });
295
+
296
+ instinct
297
+ .command("get-obs-stuck-ms-v2")
298
+ .description("Get observation stuck threshold (ms)")
299
+ .action(() => console.log(getObsStuckMsV2()));
300
+
301
+ instinct
302
+ .command("set-obs-stuck-ms-v2 <n>")
303
+ .description("Set observation stuck threshold (ms)")
304
+ .action((n) => {
305
+ setObsStuckMsV2(Number(n));
306
+ console.log(getObsStuckMsV2());
307
+ });
308
+
309
+ instinct
310
+ .command("active-profile-count-v2 <userId>")
311
+ .description("Count active profiles for a user")
312
+ .action((userId) => console.log(getActiveProfileCountV2(userId)));
313
+
314
+ instinct
315
+ .command("pending-obs-count-v2 <profileId>")
316
+ .description("Count pending observations for a profile")
317
+ .action((profileId) => console.log(getPendingObsCountV2(profileId)));
318
+
319
+ instinct
320
+ .command("register-profile-v2 <id>")
321
+ .description("Register a V2 profile")
322
+ .requiredOption("-u, --user <userId>", "User id")
323
+ .requiredOption("-c, --category <category>", "Category")
324
+ .action((id, opts) => {
325
+ const p = registerProfileV2(id, {
326
+ userId: opts.user,
327
+ category: opts.category,
328
+ });
329
+ console.log(JSON.stringify(p, null, 2));
330
+ });
331
+
332
+ instinct
333
+ .command("get-profile-v2 <id>")
334
+ .description("Get a V2 profile")
335
+ .action((id) => {
336
+ const p = getProfileV2(id);
337
+ console.log(p ? JSON.stringify(p, null, 2) : "null");
338
+ });
339
+
340
+ instinct
341
+ .command("list-profiles-v2")
342
+ .description("List V2 profiles")
343
+ .option("-u, --user <userId>", "Filter by user")
344
+ .option("-c, --category <category>", "Filter by category")
345
+ .option("-s, --status <status>", "Filter by status")
346
+ .action((opts) => {
347
+ console.log(
348
+ JSON.stringify(
349
+ listProfilesV2({
350
+ userId: opts.user,
351
+ category: opts.category,
352
+ status: opts.status,
353
+ }),
354
+ null,
355
+ 2,
356
+ ),
357
+ );
358
+ });
359
+
360
+ instinct
361
+ .command("activate-profile-v2 <id>")
362
+ .description("pending|dormant → active")
363
+ .action((id) =>
364
+ console.log(JSON.stringify(activateProfileV2(id), null, 2)),
365
+ );
366
+
367
+ instinct
368
+ .command("dormant-profile-v2 <id>")
369
+ .description("active → dormant")
370
+ .action((id) => console.log(JSON.stringify(dormantProfileV2(id), null, 2)));
371
+
372
+ instinct
373
+ .command("archive-profile-v2 <id>")
374
+ .description("→ archived (terminal)")
375
+ .action((id) => console.log(JSON.stringify(archiveProfileV2(id), null, 2)));
376
+
377
+ instinct
378
+ .command("touch-profile-v2 <id>")
379
+ .description("Update lastSeenAt")
380
+ .action((id) => console.log(JSON.stringify(touchProfileV2(id), null, 2)));
381
+
382
+ instinct
383
+ .command("create-observation-v2 <id>")
384
+ .description("Create a V2 observation")
385
+ .requiredOption("-p, --profile <profileId>", "Profile id")
386
+ .requiredOption("-s, --signal <signal>", "Signal text")
387
+ .action((id, opts) => {
388
+ const o = createObservationV2(id, {
389
+ profileId: opts.profile,
390
+ signal: opts.signal,
391
+ });
392
+ console.log(JSON.stringify(o, null, 2));
393
+ });
394
+
395
+ instinct
396
+ .command("get-observation-v2 <id>")
397
+ .description("Get a V2 observation")
398
+ .action((id) => {
399
+ const o = getObservationV2(id);
400
+ console.log(o ? JSON.stringify(o, null, 2) : "null");
401
+ });
402
+
403
+ instinct
404
+ .command("list-observations-v2")
405
+ .description("List V2 observations")
406
+ .option("-p, --profile <profileId>", "Filter by profile")
407
+ .option("-s, --status <status>", "Filter by status")
408
+ .action((opts) => {
409
+ console.log(
410
+ JSON.stringify(
411
+ listObservationsV2({
412
+ profileId: opts.profile,
413
+ status: opts.status,
414
+ }),
415
+ null,
416
+ 2,
417
+ ),
418
+ );
419
+ });
420
+
421
+ instinct
422
+ .command("review-observation-v2 <id>")
423
+ .description("captured → reviewed")
424
+ .action((id) =>
425
+ console.log(JSON.stringify(reviewObservationV2(id), null, 2)),
426
+ );
427
+
428
+ instinct
429
+ .command("reinforce-observation-v2 <id>")
430
+ .description("reviewed → reinforced")
431
+ .action((id) =>
432
+ console.log(JSON.stringify(reinforceObservationV2(id), null, 2)),
433
+ );
434
+
435
+ instinct
436
+ .command("promote-observation-v2 <id>")
437
+ .description("reviewed|reinforced → promoted (terminal)")
438
+ .action((id) =>
439
+ console.log(JSON.stringify(promoteObservationV2(id), null, 2)),
440
+ );
441
+
442
+ instinct
443
+ .command("discard-observation-v2 <id>")
444
+ .description("→ discarded (terminal)")
445
+ .action((id) =>
446
+ console.log(JSON.stringify(discardObservationV2(id), null, 2)),
447
+ );
448
+
449
+ instinct
450
+ .command("auto-dormant-idle-profiles-v2")
451
+ .description("Flip idle active profiles → dormant")
452
+ .action(() =>
453
+ console.log(JSON.stringify(autoDormantIdleProfilesV2(), null, 2)),
454
+ );
455
+
456
+ instinct
457
+ .command("auto-discard-stale-observations-v2")
458
+ .description("Flip stale captured/reviewed → discarded")
459
+ .action(() =>
460
+ console.log(JSON.stringify(autoDiscardStaleObservationsV2(), null, 2)),
461
+ );
202
462
  }