@remnic/core 9.3.702 → 9.3.704

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 (272) hide show
  1. package/dist/access-boundary.d.ts +7 -7
  2. package/dist/access-boundary.js +15 -15
  3. package/dist/access-cli.js +31 -31
  4. package/dist/access-http.d.ts +7 -7
  5. package/dist/access-http.js +19 -19
  6. package/dist/access-mcp.d.ts +7 -7
  7. package/dist/access-mcp.js +18 -18
  8. package/dist/access-operations.d.ts +7 -7
  9. package/dist/access-operations.js +17 -17
  10. package/dist/access-schema.js +3 -3
  11. package/dist/{access-service-COCzhgEL.d.ts → access-service-C8hc8N2i.d.ts} +4 -4
  12. package/dist/access-service.d.ts +7 -7
  13. package/dist/access-service.js +14 -14
  14. package/dist/access-surface-catalog.d.ts +7 -7
  15. package/dist/action-confidence.d.ts +3 -3
  16. package/dist/active-memory-bridge.d.ts +3 -3
  17. package/dist/active-recall.d.ts +3 -3
  18. package/dist/behavior-learner.d.ts +3 -3
  19. package/dist/behavior-signals.d.ts +3 -3
  20. package/dist/bootstrap.d.ts +6 -6
  21. package/dist/briefing.d.ts +3 -3
  22. package/dist/briefing.js +3 -3
  23. package/dist/buffer-surprise-report.d.ts +3 -3
  24. package/dist/buffer.d.ts +3 -3
  25. package/dist/bulk-import/index.d.ts +4 -4
  26. package/dist/calibration.d.ts +3 -3
  27. package/dist/capabilities.d.ts +3 -3
  28. package/dist/{capsule-crypto-YO5QJ6L3.js → capsule-crypto-GWVG7LGC.js} +2 -2
  29. package/dist/{catalog-DxCzhjE6.d.ts → catalog-CAeU0e1C.d.ts} +1 -1
  30. package/dist/causal-behavior.d.ts +3 -3
  31. package/dist/causal-consolidation.d.ts +3 -3
  32. package/dist/causal-consolidation.js +4 -4
  33. package/dist/{chunk-5VXVXJH6.js → chunk-25FHSOEB.js} +5 -5
  34. package/dist/{chunk-ZCEI242W.js → chunk-3EHCV6YV.js} +368 -358
  35. package/dist/chunk-3EHCV6YV.js.map +1 -0
  36. package/dist/{chunk-QQW2LIEA.js → chunk-53EEQYE5.js} +4 -4
  37. package/dist/{chunk-VDX2J7OX.js → chunk-5W7CTZ2E.js} +4 -4
  38. package/dist/{chunk-VPAFWWCL.js → chunk-6AFVIOVZ.js} +2 -2
  39. package/dist/{chunk-6TAETM63.js → chunk-6GHWF4QH.js} +2 -2
  40. package/dist/{chunk-EZR35XHX.js → chunk-6Q7JFY4P.js} +2 -2
  41. package/dist/{chunk-64XXOQRW.js → chunk-7G4KPGR3.js} +2 -2
  42. package/dist/{chunk-TGAHHCB6.js → chunk-AE3C4PY6.js} +2 -2
  43. package/dist/{chunk-CI7RKSRE.js → chunk-AQEJKOKI.js} +2 -1
  44. package/dist/{chunk-CZJ6QSKG.js → chunk-CTY6QSLZ.js} +4 -4
  45. package/dist/{chunk-FVI5B7DE.js → chunk-DE2OPIQD.js} +2 -2
  46. package/dist/{chunk-MDJURR27.js → chunk-HW5EF6LV.js} +2 -2
  47. package/dist/{chunk-BMFZLLNI.js → chunk-ICP53SKG.js} +2 -2
  48. package/dist/{chunk-MBUM2Y3L.js → chunk-K7QRDDSR.js} +2 -2
  49. package/dist/{chunk-GFIARMA7.js → chunk-NMW3T6T6.js} +5 -5
  50. package/dist/{chunk-6VVP6NK7.js → chunk-OCFNG4LB.js} +2 -2
  51. package/dist/{chunk-KC6TCAWV.js → chunk-OOEVMJK4.js} +5 -5
  52. package/dist/{chunk-MXEWQKM7.js → chunk-ORXVO6TH.js} +2 -2
  53. package/dist/{chunk-BXLOS5AJ.js → chunk-OWHERGF2.js} +2 -2
  54. package/dist/{chunk-EOOVJK2U.js → chunk-PJ5MDXOF.js} +3 -3
  55. package/dist/{chunk-X5J3JZR3.js → chunk-PKMQK2WY.js} +3 -3
  56. package/dist/{chunk-Q4O3ET6F.js → chunk-QDIVMS25.js} +2 -2
  57. package/dist/{chunk-EYJD6KIO.js → chunk-QHNJVWF6.js} +2 -2
  58. package/dist/{chunk-JMA4RYRN.js → chunk-QV5WFNZ2.js} +2 -2
  59. package/dist/{chunk-XGMCUY5P.js → chunk-R64MNFPV.js} +20 -20
  60. package/dist/{chunk-QGJAGC2J.js → chunk-RYDT7LAI.js} +2 -2
  61. package/dist/{chunk-JTKFZMZ7.js → chunk-S24J5LLQ.js} +3 -3
  62. package/dist/{chunk-AMNLZ6SF.js → chunk-TUPNAHHQ.js} +2 -2
  63. package/dist/{chunk-DL6H3D7S.js → chunk-UNNDFYUX.js} +5 -5
  64. package/dist/{chunk-QIMFOCSH.js → chunk-UOIRJ45Z.js} +2 -2
  65. package/dist/{chunk-DQEMWVMT.js → chunk-UVYI6VIX.js} +1 -1
  66. package/dist/{chunk-IX72AAMZ.js → chunk-WAHI7SPK.js} +2 -2
  67. package/dist/{chunk-7WWURLG6.js → chunk-XPOOY35N.js} +2 -2
  68. package/dist/{chunk-NUIJEGVD.js → chunk-XXDOJ5NL.js} +5 -5
  69. package/dist/{chunk-Z7XEIAV4.js → chunk-YLB7NMLD.js} +2 -2
  70. package/dist/{chunk-OXEAMU42.js → chunk-ZXFNSKPY.js} +8 -8
  71. package/dist/{cli-BM4xQPp4.d.ts → cli-ChE0XlJY.d.ts} +6 -6
  72. package/dist/cli.d.ts +9 -9
  73. package/dist/cli.js +31 -31
  74. package/dist/compounding/engine.d.ts +3 -3
  75. package/dist/compounding/engine.js +3 -3
  76. package/dist/compounding/preference-consolidator.d.ts +3 -3
  77. package/dist/compression-optimizer.d.ts +3 -3
  78. package/dist/config.d.ts +3 -3
  79. package/dist/connectors/codex-materialize-runner.d.ts +3 -3
  80. package/dist/connectors/codex-materialize-runner.js +3 -3
  81. package/dist/connectors/codex-materialize.d.ts +3 -3
  82. package/dist/connectors/index.d.ts +3 -3
  83. package/dist/connectors/index.js +3 -3
  84. package/dist/consolidation-provenance-check.d.ts +3 -3
  85. package/dist/consolidation-undo.d.ts +3 -3
  86. package/dist/contradiction/index.d.ts +3 -3
  87. package/dist/conversation-index/backend.d.ts +3 -3
  88. package/dist/conversation-index/chunker.d.ts +3 -3
  89. package/dist/conversation-index/faiss-adapter.d.ts +3 -3
  90. package/dist/conversation-index/indexer.d.ts +3 -3
  91. package/dist/conversation-index/search.d.ts +3 -3
  92. package/dist/day-summary.d.ts +3 -3
  93. package/dist/delinearize.d.ts +3 -3
  94. package/dist/direct-answer-wiring.d.ts +3 -3
  95. package/dist/direct-answer.d.ts +3 -3
  96. package/dist/embedding-fallback.d.ts +3 -3
  97. package/dist/enrichment/index.d.ts +3 -3
  98. package/dist/entity-retrieval.d.ts +3 -3
  99. package/dist/entity-retrieval.js +3 -3
  100. package/dist/entity-schema.d.ts +3 -3
  101. package/dist/explicit-capture.d.ts +6 -6
  102. package/dist/extraction-faithfulness.d.ts +3 -3
  103. package/dist/extraction-judge-telemetry.d.ts +3 -3
  104. package/dist/extraction-judge-training.d.ts +3 -3
  105. package/dist/extraction-judge.d.ts +3 -3
  106. package/dist/extraction.d.ts +3 -3
  107. package/dist/fallback-llm.d.ts +3 -3
  108. package/dist/identity-continuity.d.ts +3 -3
  109. package/dist/importance.d.ts +3 -3
  110. package/dist/importers/index.d.ts +2 -2
  111. package/dist/index.d.ts +14 -29
  112. package/dist/index.js +42 -42
  113. package/dist/intent.d.ts +3 -3
  114. package/dist/lcm/archive.d.ts +1 -1
  115. package/dist/lcm/archive.js +2 -2
  116. package/dist/lcm/engine.d.ts +3 -3
  117. package/dist/lcm/engine.js +4 -4
  118. package/dist/lcm/index.d.ts +3 -3
  119. package/dist/lcm/index.js +4 -4
  120. package/dist/lcm/queue.d.ts +1 -1
  121. package/dist/lcm/recall.d.ts +1 -1
  122. package/dist/lcm/summarizer.d.ts +1 -1
  123. package/dist/lcm/summarizer.js +3 -3
  124. package/dist/lcm/tools.d.ts +3 -3
  125. package/dist/lifecycle.d.ts +3 -3
  126. package/dist/live-connectors-runner.d.ts +3 -3
  127. package/dist/local-llm.d.ts +3 -3
  128. package/dist/maintenance/memory-governance.d.ts +3 -3
  129. package/dist/maintenance/memory-governance.js +3 -3
  130. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +3 -3
  131. package/dist/maintenance/rebuild-memory-projection.js +4 -4
  132. package/dist/mcp-memory-inspector-app.d.ts +7 -7
  133. package/dist/memory-action-policy.d.ts +3 -3
  134. package/dist/memory-cache.d.ts +3 -3
  135. package/dist/memory-lifecycle-ledger-utils.d.ts +3 -3
  136. package/dist/memory-projection-store.d.ts +3 -3
  137. package/dist/memory-provenance.d.ts +3 -3
  138. package/dist/memory-worth-outcomes.d.ts +3 -3
  139. package/dist/{index-DJ9QWMw-.d.ts → message-parts/index.d.ts} +2 -1
  140. package/dist/message-parts/index.js +24 -0
  141. package/dist/models-json.d.ts +3 -3
  142. package/dist/namespaces/migrate.d.ts +4 -4
  143. package/dist/namespaces/migrate.js +8 -8
  144. package/dist/namespaces/principal.d.ts +3 -3
  145. package/dist/namespaces/search.d.ts +3 -3
  146. package/dist/namespaces/search.js +4 -4
  147. package/dist/namespaces/storage.d.ts +4 -4
  148. package/dist/namespaces/storage.js +3 -3
  149. package/dist/native-knowledge.d.ts +3 -3
  150. package/dist/objective-state-writers.d.ts +1 -1
  151. package/dist/objective-state-writers.js +2 -2
  152. package/dist/operator-toolkit.d.ts +3 -3
  153. package/dist/operator-toolkit.js +12 -12
  154. package/dist/orchestration/maintenance.d.ts +4 -4
  155. package/dist/orchestration/maintenance.js +5 -5
  156. package/dist/{orchestrator-C9CDWAm6.d.ts → orchestrator-m_PnhyHj.d.ts} +4 -4
  157. package/dist/orchestrator.d.ts +6 -6
  158. package/dist/orchestrator.js +22 -22
  159. package/dist/patterns-cli.d.ts +3 -3
  160. package/dist/{pipeline-BSTuml0d.d.ts → pipeline-DmqtvION.d.ts} +1 -1
  161. package/dist/policy-runtime.d.ts +3 -3
  162. package/dist/provenance.d.ts +3 -3
  163. package/dist/qmd-recall-cache.d.ts +3 -3
  164. package/dist/qmd.d.ts +3 -3
  165. package/dist/recall-disclosure-escalation.d.ts +3 -3
  166. package/dist/recall-explain-renderer.d.ts +3 -3
  167. package/dist/recall-planner-llm.d.ts +3 -3
  168. package/dist/recall-state.d.ts +3 -3
  169. package/dist/recall-tag-filter.d.ts +3 -3
  170. package/dist/recall-xray-cli.d.ts +3 -3
  171. package/dist/recall-xray-renderer.d.ts +3 -3
  172. package/dist/recall-xray.d.ts +3 -3
  173. package/dist/replay/normalizers/chatgpt.d.ts +1 -1
  174. package/dist/replay/normalizers/claude.d.ts +1 -1
  175. package/dist/replay/normalizers/openclaw.d.ts +1 -1
  176. package/dist/replay/normalizers/shared.d.ts +1 -1
  177. package/dist/replay/runner.d.ts +1 -1
  178. package/dist/replay/types.d.ts +1 -1
  179. package/dist/resolve-auth-token.d.ts +3 -3
  180. package/dist/retrieval-agents.d.ts +3 -3
  181. package/dist/retrieval-tiers.d.ts +3 -3
  182. package/dist/routing/engine.d.ts +3 -3
  183. package/dist/routing/store.d.ts +3 -3
  184. package/dist/schemas.d.ts +22 -22
  185. package/dist/search/embed-helper.d.ts +3 -3
  186. package/dist/search/factory.d.ts +3 -3
  187. package/dist/search/factory.js +3 -3
  188. package/dist/search/index.d.ts +3 -3
  189. package/dist/search/index.js +7 -7
  190. package/dist/search/lancedb-backend.d.ts +3 -3
  191. package/dist/search/meilisearch-backend.d.ts +3 -3
  192. package/dist/search/noop-backend.d.ts +3 -3
  193. package/dist/search/orama-backend.d.ts +3 -3
  194. package/dist/search/port.d.ts +3 -3
  195. package/dist/search/remote-backend.d.ts +3 -3
  196. package/dist/{semantic-consolidation-DgFXyALl.d.ts → semantic-consolidation-DVBbq6Wr.d.ts} +1 -1
  197. package/dist/semantic-consolidation.d.ts +4 -4
  198. package/dist/semantic-consolidation.js +4 -4
  199. package/dist/semantic-rule-promotion.js +3 -3
  200. package/dist/semantic-rule-verifier.d.ts +3 -3
  201. package/dist/semantic-rule-verifier.js +3 -3
  202. package/dist/session-observer-bands.d.ts +3 -3
  203. package/dist/session-observer-state.d.ts +3 -3
  204. package/dist/shared-context/manager.d.ts +3 -3
  205. package/dist/signal.d.ts +3 -3
  206. package/dist/storage.d.ts +3 -3
  207. package/dist/storage.js +2 -2
  208. package/dist/summarizer.d.ts +3 -3
  209. package/dist/summary-snapshot.d.ts +3 -3
  210. package/dist/temporal-supersession.d.ts +3 -3
  211. package/dist/temporal-validity.d.ts +3 -3
  212. package/dist/threading.d.ts +3 -3
  213. package/dist/tier-migration.d.ts +3 -3
  214. package/dist/tier-routing.d.ts +3 -3
  215. package/dist/topics.d.ts +3 -3
  216. package/dist/transcript.d.ts +3 -3
  217. package/dist/transfer/backup.js +2 -2
  218. package/dist/transfer/capsule-export.js +2 -2
  219. package/dist/transfer/capsule-import.js +2 -2
  220. package/dist/transfer/types.d.ts +12 -12
  221. package/dist/{types-MWKPZnM0.d.ts → types-CJrvHJjx.d.ts} +2 -2
  222. package/dist/{types-ByK7T3L6.d.ts → types-gb_SNtjR.d.ts} +1 -1
  223. package/dist/types.d.ts +3 -3
  224. package/dist/utility-runtime.d.ts +3 -3
  225. package/dist/utils/path.d.ts +17 -0
  226. package/dist/utils/path.js +9 -0
  227. package/dist/utils/path.js.map +1 -0
  228. package/dist/verified-recall.js +3 -3
  229. package/package.json +27 -2
  230. package/src/cli/creation-ledger-commands.ts +346 -0
  231. package/src/cli/research-status-commands.ts +256 -0
  232. package/src/cli.ts +7 -516
  233. package/dist/chunk-ZCEI242W.js.map +0 -1
  234. package/dist/path-X2K5XCHL.js +0 -9
  235. /package/dist/{capsule-crypto-YO5QJ6L3.js.map → capsule-crypto-GWVG7LGC.js.map} +0 -0
  236. /package/dist/{chunk-5VXVXJH6.js.map → chunk-25FHSOEB.js.map} +0 -0
  237. /package/dist/{chunk-QQW2LIEA.js.map → chunk-53EEQYE5.js.map} +0 -0
  238. /package/dist/{chunk-VDX2J7OX.js.map → chunk-5W7CTZ2E.js.map} +0 -0
  239. /package/dist/{chunk-VPAFWWCL.js.map → chunk-6AFVIOVZ.js.map} +0 -0
  240. /package/dist/{chunk-6TAETM63.js.map → chunk-6GHWF4QH.js.map} +0 -0
  241. /package/dist/{chunk-EZR35XHX.js.map → chunk-6Q7JFY4P.js.map} +0 -0
  242. /package/dist/{chunk-64XXOQRW.js.map → chunk-7G4KPGR3.js.map} +0 -0
  243. /package/dist/{chunk-TGAHHCB6.js.map → chunk-AE3C4PY6.js.map} +0 -0
  244. /package/dist/{chunk-CI7RKSRE.js.map → chunk-AQEJKOKI.js.map} +0 -0
  245. /package/dist/{chunk-CZJ6QSKG.js.map → chunk-CTY6QSLZ.js.map} +0 -0
  246. /package/dist/{chunk-FVI5B7DE.js.map → chunk-DE2OPIQD.js.map} +0 -0
  247. /package/dist/{chunk-MDJURR27.js.map → chunk-HW5EF6LV.js.map} +0 -0
  248. /package/dist/{chunk-BMFZLLNI.js.map → chunk-ICP53SKG.js.map} +0 -0
  249. /package/dist/{chunk-MBUM2Y3L.js.map → chunk-K7QRDDSR.js.map} +0 -0
  250. /package/dist/{chunk-GFIARMA7.js.map → chunk-NMW3T6T6.js.map} +0 -0
  251. /package/dist/{chunk-6VVP6NK7.js.map → chunk-OCFNG4LB.js.map} +0 -0
  252. /package/dist/{chunk-KC6TCAWV.js.map → chunk-OOEVMJK4.js.map} +0 -0
  253. /package/dist/{chunk-MXEWQKM7.js.map → chunk-ORXVO6TH.js.map} +0 -0
  254. /package/dist/{chunk-BXLOS5AJ.js.map → chunk-OWHERGF2.js.map} +0 -0
  255. /package/dist/{chunk-EOOVJK2U.js.map → chunk-PJ5MDXOF.js.map} +0 -0
  256. /package/dist/{chunk-X5J3JZR3.js.map → chunk-PKMQK2WY.js.map} +0 -0
  257. /package/dist/{chunk-Q4O3ET6F.js.map → chunk-QDIVMS25.js.map} +0 -0
  258. /package/dist/{chunk-EYJD6KIO.js.map → chunk-QHNJVWF6.js.map} +0 -0
  259. /package/dist/{chunk-JMA4RYRN.js.map → chunk-QV5WFNZ2.js.map} +0 -0
  260. /package/dist/{chunk-XGMCUY5P.js.map → chunk-R64MNFPV.js.map} +0 -0
  261. /package/dist/{chunk-QGJAGC2J.js.map → chunk-RYDT7LAI.js.map} +0 -0
  262. /package/dist/{chunk-JTKFZMZ7.js.map → chunk-S24J5LLQ.js.map} +0 -0
  263. /package/dist/{chunk-AMNLZ6SF.js.map → chunk-TUPNAHHQ.js.map} +0 -0
  264. /package/dist/{chunk-DL6H3D7S.js.map → chunk-UNNDFYUX.js.map} +0 -0
  265. /package/dist/{chunk-QIMFOCSH.js.map → chunk-UOIRJ45Z.js.map} +0 -0
  266. /package/dist/{chunk-DQEMWVMT.js.map → chunk-UVYI6VIX.js.map} +0 -0
  267. /package/dist/{chunk-IX72AAMZ.js.map → chunk-WAHI7SPK.js.map} +0 -0
  268. /package/dist/{chunk-7WWURLG6.js.map → chunk-XPOOY35N.js.map} +0 -0
  269. /package/dist/{chunk-NUIJEGVD.js.map → chunk-XXDOJ5NL.js.map} +0 -0
  270. /package/dist/{chunk-Z7XEIAV4.js.map → chunk-YLB7NMLD.js.map} +0 -0
  271. /package/dist/{chunk-OXEAMU42.js.map → chunk-ZXFNSKPY.js.map} +0 -0
  272. /package/dist/{path-X2K5XCHL.js.map → message-parts/index.js.map} +0 -0
@@ -0,0 +1,346 @@
1
+ /**
2
+ * Creation-memory ledger command group — extracted from cli.ts (#1532 Phase B).
3
+ *
4
+ * Ten creation-memory ledger commands — thin wrappers over exported
5
+ * runXxxCliCommand helpers across three ledgers:
6
+ * - resume-bundle (status / record / build)
7
+ * - commitment (status / record / set-state / lifecycle)
8
+ * - work-product (status / record / recall-search)
9
+ *
10
+ * Behaviour is identical to the inline registration it replaces — the
11
+ * cli-command-surface contract tests guard against silent drift.
12
+ *
13
+ * Circular import note: same safe pattern as research-status-commands.ts —
14
+ * the runXxx helpers are referenced only inside action callbacks invoked at
15
+ * runtime, never at module-eval time.
16
+ */
17
+
18
+ import type { Orchestrator } from "../orchestrator.js";
19
+ import type { CliCommand } from "../cli.js";
20
+ import type { CommitmentLedgerEntry } from "../commitment-ledger.js";
21
+ import type { WorkProductLedgerEntry } from "../work-product-ledger.js";
22
+ import type { ResumeBundle } from "../resume-bundles.js";
23
+ import {
24
+ runResumeBundleStatusCliCommand,
25
+ runResumeBundleRecordCliCommand,
26
+ runResumeBundleBuildCliCommand,
27
+ runCommitmentStatusCliCommand,
28
+ runCommitmentRecordCliCommand,
29
+ runCommitmentSetStateCliCommand,
30
+ runCommitmentLifecycleCliCommand,
31
+ runWorkProductStatusCliCommand,
32
+ runWorkProductRecordCliCommand,
33
+ runWorkProductRecallSearchCliCommand,
34
+ } from "../cli.js";
35
+
36
+ /**
37
+ * Register the creation-memory ledger command group on the parent `engram`
38
+ * command. Extracted verbatim from registerCli; behaviour-preserving.
39
+ */
40
+ export function registerCreationLedgerCommands(
41
+ cmd: CliCommand,
42
+ orchestrator: Orchestrator,
43
+ ): void {
44
+ cmd
45
+ .command("resume-bundle-status")
46
+ .description("Show resume bundle status, bundle counts, and the latest recorded handoff bundle")
47
+ .action(async () => {
48
+ const status = await runResumeBundleStatusCliCommand({
49
+ memoryDir: orchestrator.config.memoryDir,
50
+ resumeBundleDir: orchestrator.config.resumeBundleDir,
51
+ creationMemoryEnabled: orchestrator.config.creationMemoryEnabled,
52
+ resumeBundlesEnabled: orchestrator.config.resumeBundlesEnabled,
53
+ });
54
+ console.log(JSON.stringify(status, null, 2));
55
+ console.log("OK");
56
+ });
57
+
58
+ cmd
59
+ .command("resume-bundle-record")
60
+ .description("Record an explicit resume bundle when creation-memory handoff bundles are enabled")
61
+ .requiredOption("--bundle-id <bundleId>", "Resume bundle id")
62
+ .requiredOption("--recorded-at <recordedAt>", "ISO timestamp for the bundle")
63
+ .requiredOption("--session-key <sessionKey>", "Session key that owns the bundle")
64
+ .requiredOption("--source <source>", "Bundle source (tool_result|cli|system|manual)")
65
+ .requiredOption("--scope <scope>", "Primary scope or recovery domain for the bundle")
66
+ .requiredOption("--summary <summary>", "Human-readable summary of what this bundle preserves")
67
+ .option("--key-fact <keyFact...>", "Short facts that a resumed agent should retain")
68
+ .option("--next-action <nextAction...>", "Explicit next actions for the resumed agent")
69
+ .option("--risk-flag <riskFlag...>", "Open risks or cautions attached to the bundle")
70
+ .option(
71
+ "--objective-state-snapshot-ref <objectiveStateSnapshotRef...>",
72
+ "Objective-state snapshot refs attached to the bundle",
73
+ )
74
+ .option(
75
+ "--work-product-entry-ref <workProductEntryRef...>",
76
+ "Work-product ledger refs attached to the bundle",
77
+ )
78
+ .option(
79
+ "--commitment-entry-ref <commitmentEntryRef...>",
80
+ "Commitment ledger refs attached to the bundle",
81
+ )
82
+ .action(async (...args: unknown[]) => {
83
+ const options = (args[0] ?? {}) as Record<string, unknown>;
84
+ const filePath = await runResumeBundleRecordCliCommand({
85
+ memoryDir: orchestrator.config.memoryDir,
86
+ resumeBundleDir: orchestrator.config.resumeBundleDir,
87
+ creationMemoryEnabled: orchestrator.config.creationMemoryEnabled,
88
+ resumeBundlesEnabled: orchestrator.config.resumeBundlesEnabled,
89
+ bundle: {
90
+ schemaVersion: 1,
91
+ bundleId: String(options.bundleId ?? ""),
92
+ recordedAt: String(options.recordedAt ?? ""),
93
+ sessionKey: String(options.sessionKey ?? ""),
94
+ source: String(options.source ?? "") as ResumeBundle["source"],
95
+ scope: String(options.scope ?? ""),
96
+ summary: String(options.summary ?? ""),
97
+ keyFacts: Array.isArray(options.keyFact) ? options.keyFact.map(String) : undefined,
98
+ nextActions: Array.isArray(options.nextAction) ? options.nextAction.map(String) : undefined,
99
+ riskFlags: Array.isArray(options.riskFlag) ? options.riskFlag.map(String) : undefined,
100
+ objectiveStateSnapshotRefs: Array.isArray(options.objectiveStateSnapshotRef)
101
+ ? options.objectiveStateSnapshotRef.map(String)
102
+ : undefined,
103
+ workProductEntryRefs: Array.isArray(options.workProductEntryRef)
104
+ ? options.workProductEntryRef.map(String)
105
+ : undefined,
106
+ commitmentEntryRefs: Array.isArray(options.commitmentEntryRef)
107
+ ? options.commitmentEntryRef.map(String)
108
+ : undefined,
109
+ },
110
+ });
111
+ console.log(JSON.stringify({ wrote: filePath !== null, filePath }, null, 2));
112
+ console.log("OK");
113
+ });
114
+
115
+ cmd
116
+ .command("resume-bundle-build")
117
+ .description("Build and persist a resume bundle from transcript recovery, objective state, work products, and open commitments")
118
+ .requiredOption("--bundle-id <bundleId>", "Resume bundle id")
119
+ .requiredOption("--recorded-at <recordedAt>", "ISO timestamp for the bundle")
120
+ .requiredOption("--session-key <sessionKey>", "Session key that owns the bundle")
121
+ .requiredOption("--scope <scope>", "Primary scope or recovery domain for the bundle")
122
+ .action(async (...args: unknown[]) => {
123
+ const options = (args[0] ?? {}) as Record<string, unknown>;
124
+ const built = await runResumeBundleBuildCliCommand({
125
+ memoryDir: orchestrator.config.memoryDir,
126
+ resumeBundleDir: orchestrator.config.resumeBundleDir,
127
+ objectiveStateStoreDir: orchestrator.config.objectiveStateStoreDir,
128
+ workProductLedgerDir: orchestrator.config.workProductLedgerDir,
129
+ commitmentLedgerDir: orchestrator.config.commitmentLedgerDir,
130
+ creationMemoryEnabled: orchestrator.config.creationMemoryEnabled,
131
+ resumeBundlesEnabled: orchestrator.config.resumeBundlesEnabled,
132
+ transcriptEnabled: orchestrator.config.transcriptEnabled,
133
+ objectiveStateMemoryEnabled: orchestrator.config.objectiveStateMemoryEnabled,
134
+ commitmentLedgerEnabled: orchestrator.config.commitmentLedgerEnabled,
135
+ bundleId: String(options.bundleId ?? ""),
136
+ recordedAt: String(options.recordedAt ?? ""),
137
+ sessionKey: String(options.sessionKey ?? ""),
138
+ scope: String(options.scope ?? ""),
139
+ });
140
+ console.log(JSON.stringify({
141
+ wrote: built !== null,
142
+ filePath: built?.filePath ?? null,
143
+ bundle: built?.bundle ?? null,
144
+ }, null, 2));
145
+ console.log("OK");
146
+ });
147
+
148
+ cmd
149
+ .command("commitment-status")
150
+ .description("Show commitment ledger status, entry counts, and the latest recorded commitment")
151
+ .action(async () => {
152
+ const status = await runCommitmentStatusCliCommand({
153
+ memoryDir: orchestrator.config.memoryDir,
154
+ commitmentLedgerDir: orchestrator.config.commitmentLedgerDir,
155
+ creationMemoryEnabled: orchestrator.config.creationMemoryEnabled,
156
+ commitmentLedgerEnabled: orchestrator.config.commitmentLedgerEnabled,
157
+ commitmentLifecycleEnabled: orchestrator.config.commitmentLifecycleEnabled,
158
+ commitmentStaleDays: orchestrator.config.commitmentStaleDays,
159
+ commitmentDecayDays: orchestrator.config.commitmentDecayDays,
160
+ });
161
+ console.log(JSON.stringify(status, null, 2));
162
+ console.log("OK");
163
+ });
164
+
165
+ cmd
166
+ .command("commitment-record")
167
+ .description("Record a commitment ledger entry when commitment memory is enabled")
168
+ .requiredOption("--entry-id <entryId>", "Commitment entry id")
169
+ .requiredOption("--recorded-at <recordedAt>", "ISO timestamp for the entry")
170
+ .requiredOption("--session-key <sessionKey>", "Session key that owns the commitment")
171
+ .requiredOption("--source <source>", "Entry source (tool_result|cli|system|manual)")
172
+ .requiredOption("--kind <kind>", "Entry kind (promise|follow_up|deadline|deliverable)")
173
+ .requiredOption("--state <state>", "Entry state (open|fulfilled|cancelled|expired)")
174
+ .requiredOption("--scope <scope>", "Primary scope or identifier for the commitment")
175
+ .requiredOption("--summary <summary>", "Human-readable summary of the commitment")
176
+ .option("--due-at <dueAt>", "Optional due timestamp for the commitment")
177
+ .option("--tag <tag...>", "Tags to attach to the commitment entry")
178
+ .option("--entity-ref <entityRef...>", "Entity refs to attach to the commitment entry")
179
+ .option(
180
+ "--work-product-entry-ref <workProductEntryRef...>",
181
+ "Work-product ledger refs that this commitment depends on",
182
+ )
183
+ .option(
184
+ "--objective-state-snapshot-ref <objectiveStateSnapshotRef...>",
185
+ "Objective-state snapshot refs to link to this commitment",
186
+ )
187
+ .action(async (...args: unknown[]) => {
188
+ const options = (args[0] ?? {}) as Record<string, unknown>;
189
+ const filePath = await runCommitmentRecordCliCommand({
190
+ memoryDir: orchestrator.config.memoryDir,
191
+ commitmentLedgerDir: orchestrator.config.commitmentLedgerDir,
192
+ creationMemoryEnabled: orchestrator.config.creationMemoryEnabled,
193
+ commitmentLedgerEnabled: orchestrator.config.commitmentLedgerEnabled,
194
+ entry: {
195
+ schemaVersion: 1,
196
+ entryId: String(options.entryId ?? ""),
197
+ recordedAt: String(options.recordedAt ?? ""),
198
+ sessionKey: String(options.sessionKey ?? ""),
199
+ source: String(options.source ?? "") as CommitmentLedgerEntry["source"],
200
+ kind: String(options.kind ?? "") as CommitmentLedgerEntry["kind"],
201
+ state: String(options.state ?? "") as CommitmentLedgerEntry["state"],
202
+ scope: String(options.scope ?? ""),
203
+ summary: String(options.summary ?? ""),
204
+ dueAt: typeof options.dueAt === "string" ? options.dueAt : undefined,
205
+ tags: Array.isArray(options.tag) ? options.tag.map(String) : undefined,
206
+ entityRefs: Array.isArray(options.entityRef) ? options.entityRef.map(String) : undefined,
207
+ workProductEntryRefs: Array.isArray(options.workProductEntryRef)
208
+ ? options.workProductEntryRef.map(String)
209
+ : undefined,
210
+ objectiveStateSnapshotRefs: Array.isArray(options.objectiveStateSnapshotRef)
211
+ ? options.objectiveStateSnapshotRef.map(String)
212
+ : undefined,
213
+ },
214
+ });
215
+ console.log(JSON.stringify({ wrote: filePath !== null, filePath }, null, 2));
216
+ console.log("OK");
217
+ });
218
+
219
+ cmd
220
+ .command("commitment-set-state")
221
+ .description("Transition an existing commitment ledger entry when commitment lifecycle is enabled")
222
+ .requiredOption("--entry-id <entryId>", "Commitment entry id")
223
+ .requiredOption("--state <state>", "Next state (open|fulfilled|cancelled|expired)")
224
+ .requiredOption("--changed-at <changedAt>", "ISO timestamp for the lifecycle transition")
225
+ .action(async (...args: unknown[]) => {
226
+ const options = (args[0] ?? {}) as Record<string, unknown>;
227
+ const entry = await runCommitmentSetStateCliCommand({
228
+ memoryDir: orchestrator.config.memoryDir,
229
+ commitmentLedgerDir: orchestrator.config.commitmentLedgerDir,
230
+ creationMemoryEnabled: orchestrator.config.creationMemoryEnabled,
231
+ commitmentLedgerEnabled: orchestrator.config.commitmentLedgerEnabled,
232
+ commitmentLifecycleEnabled: orchestrator.config.commitmentLifecycleEnabled,
233
+ entryId: String(options.entryId ?? ""),
234
+ nextState: String(options.state ?? "") as CommitmentLedgerEntry["state"],
235
+ changedAt: String(options.changedAt ?? ""),
236
+ });
237
+ console.log(JSON.stringify({ updated: entry !== null, entry }, null, 2));
238
+ console.log("OK");
239
+ });
240
+
241
+ cmd
242
+ .command("commitment-lifecycle-run")
243
+ .description("Apply overdue-expiry and resolved-entry cleanup to the commitment ledger")
244
+ .option("--now <now>", "Override the lifecycle timestamp for testing or backfills")
245
+ .action(async (...args: unknown[]) => {
246
+ const options = (args[0] ?? {}) as Record<string, unknown>;
247
+ const result = await runCommitmentLifecycleCliCommand({
248
+ memoryDir: orchestrator.config.memoryDir,
249
+ commitmentLedgerDir: orchestrator.config.commitmentLedgerDir,
250
+ creationMemoryEnabled: orchestrator.config.creationMemoryEnabled,
251
+ commitmentLedgerEnabled: orchestrator.config.commitmentLedgerEnabled,
252
+ commitmentLifecycleEnabled: orchestrator.config.commitmentLifecycleEnabled,
253
+ commitmentDecayDays: orchestrator.config.commitmentDecayDays,
254
+ now: typeof options.now === "string" ? options.now : undefined,
255
+ });
256
+ console.log(JSON.stringify({ applied: result !== null, result }, null, 2));
257
+ console.log("OK");
258
+ });
259
+
260
+ cmd
261
+ .command("work-product-status")
262
+ .description("Show work-product ledger status, entry counts, and the latest recorded work product")
263
+ .action(async () => {
264
+ const status = await runWorkProductStatusCliCommand({
265
+ memoryDir: orchestrator.config.memoryDir,
266
+ workProductLedgerDir: orchestrator.config.workProductLedgerDir,
267
+ creationMemoryEnabled: orchestrator.config.creationMemoryEnabled,
268
+ });
269
+ console.log(JSON.stringify(status, null, 2));
270
+ console.log("OK");
271
+ });
272
+
273
+ cmd
274
+ .command("work-product-record")
275
+ .description("Record a work-product ledger entry when creation-memory is enabled")
276
+ .requiredOption("--entry-id <entryId>", "Ledger entry id")
277
+ .requiredOption("--recorded-at <recordedAt>", "ISO timestamp for the entry")
278
+ .requiredOption("--session-key <sessionKey>", "Session key that created the work product")
279
+ .requiredOption("--source <source>", "Entry source (tool_result|cli|system|manual)")
280
+ .requiredOption("--kind <kind>", "Entry kind (artifact|file|record|report|workspace)")
281
+ .requiredOption(
282
+ "--entry-action <entryAction>",
283
+ "Entry action (created|updated|deleted|referenced|published)",
284
+ )
285
+ .requiredOption("--scope <scope>", "Primary scope or identifier for the created work product")
286
+ .requiredOption("--summary <summary>", "Human-readable summary of the work product")
287
+ .option("--artifact-path <artifactPath>", "Optional path to the created artifact")
288
+ .option("--tag <tag...>", "Tags to attach to the work-product entry")
289
+ .option("--entity-ref <entityRef...>", "Entity refs to attach to the work-product entry")
290
+ .option(
291
+ "--objective-state-snapshot-ref <objectiveStateSnapshotRef...>",
292
+ "Objective-state snapshot refs to link to this work product",
293
+ )
294
+ .action(async (...args: unknown[]) => {
295
+ const options = (args[0] ?? {}) as Record<string, unknown>;
296
+ const filePath = await runWorkProductRecordCliCommand({
297
+ memoryDir: orchestrator.config.memoryDir,
298
+ workProductLedgerDir: orchestrator.config.workProductLedgerDir,
299
+ creationMemoryEnabled: orchestrator.config.creationMemoryEnabled,
300
+ entry: {
301
+ schemaVersion: 1,
302
+ entryId: String(options.entryId ?? ""),
303
+ recordedAt: String(options.recordedAt ?? ""),
304
+ sessionKey: String(options.sessionKey ?? ""),
305
+ source: String(options.source ?? "") as WorkProductLedgerEntry["source"],
306
+ kind: String(options.kind ?? "") as WorkProductLedgerEntry["kind"],
307
+ action: String(options.entryAction ?? "") as WorkProductLedgerEntry["action"],
308
+ scope: String(options.scope ?? ""),
309
+ summary: String(options.summary ?? ""),
310
+ artifactPath: typeof options.artifactPath === "string" ? options.artifactPath : undefined,
311
+ tags: Array.isArray(options.tag) ? options.tag.map(String) : undefined,
312
+ entityRefs: Array.isArray(options.entityRef) ? options.entityRef.map(String) : undefined,
313
+ objectiveStateSnapshotRefs: Array.isArray(options.objectiveStateSnapshotRef)
314
+ ? options.objectiveStateSnapshotRef.map(String)
315
+ : undefined,
316
+ },
317
+ });
318
+ console.log(JSON.stringify({ wrote: filePath !== null, filePath }, null, 2));
319
+ console.log("OK");
320
+ });
321
+
322
+ cmd
323
+ .command("work-product-recall-search")
324
+ .description("Preview work-product recovery candidates when creation-memory recall is enabled")
325
+ .argument("<query>", "Prompt-like query to evaluate against the work-product ledger")
326
+ .option("--max-results <count>", "Maximum number of work-product results to return", "3")
327
+ .option("--session-key <sessionKey>", "Optional session key to boost same-session work products")
328
+ .action(async (...args: unknown[]) => {
329
+ const query = typeof args[0] === "string" ? args[0] : "";
330
+ const options = (args[1] ?? {}) as Record<string, unknown>;
331
+ const maxResults = typeof options.maxResults === "string"
332
+ ? Number.parseInt(options.maxResults, 10)
333
+ : 3;
334
+ const results = await runWorkProductRecallSearchCliCommand({
335
+ memoryDir: orchestrator.config.memoryDir,
336
+ workProductLedgerDir: orchestrator.config.workProductLedgerDir,
337
+ creationMemoryEnabled: orchestrator.config.creationMemoryEnabled,
338
+ workProductRecallEnabled: orchestrator.config.workProductRecallEnabled,
339
+ query,
340
+ maxResults: Number.isFinite(maxResults) ? maxResults : 3,
341
+ sessionKey: typeof options.sessionKey === "string" ? options.sessionKey : undefined,
342
+ });
343
+ console.log(JSON.stringify(results, null, 2));
344
+ console.log("OK");
345
+ });
346
+ }
@@ -0,0 +1,256 @@
1
+ /**
2
+ * Research-status command group — extracted from cli.ts (#1532 Phase B).
3
+ *
4
+ * Eleven read-only status / preview commands that are thin wrappers over
5
+ * exported runXxxCliCommand helpers: objective-state, causal-trajectory,
6
+ * trust-zone, abstraction-node, cue-anchor, harmonic-search, and the
7
+ * utility-telemetry / utility-learning family. Each handler reads a few
8
+ * orchestrator.config fields, calls the helper, and prints JSON + "OK".
9
+ *
10
+ * Behaviour is identical to the inline registration it replaces — the
11
+ * cli-command-surface contract tests guard against silent drift.
12
+ *
13
+ * Circular import note: this module imports the runXxx helpers from ../cli.js
14
+ * while ../cli.js imports this module's registrar. This is safe in ESM: the
15
+ * helpers are referenced only inside action callbacks (invoked at runtime,
16
+ * long after both modules have finished evaluating), never at module-eval
17
+ * time, so the live bindings are populated before any action runs.
18
+ */
19
+
20
+ import type { Orchestrator } from "../orchestrator.js";
21
+ import type { CliCommand } from "../cli.js";
22
+ import type { UtilityTelemetryEvent } from "../utility-telemetry.js";
23
+ import {
24
+ runObjectiveStateStatusCliCommand,
25
+ runCausalTrajectoryStatusCliCommand,
26
+ runTrustZoneStatusCliCommand,
27
+ runTrustZoneDemoSeedCliCommand,
28
+ runAbstractionNodeStatusCliCommand,
29
+ runCueAnchorStatusCliCommand,
30
+ runHarmonicSearchCliCommand,
31
+ runUtilityTelemetryStatusCliCommand,
32
+ runUtilityTelemetryRecordCliCommand,
33
+ runUtilityLearningStatusCliCommand,
34
+ runUtilityLearningCliCommand,
35
+ } from "../cli.js";
36
+
37
+ /**
38
+ * Register the research-status command group on the parent `engram` command.
39
+ * Extracted verbatim from registerCli; behaviour-preserving.
40
+ */
41
+ export function registerResearchStatusCommands(
42
+ cmd: CliCommand,
43
+ orchestrator: Orchestrator,
44
+ ): void {
45
+ cmd
46
+ .command("objective-state-status")
47
+ .description("Show objective-state store status, snapshot counts, and latest stored snapshot")
48
+ .action(async () => {
49
+ const status = await runObjectiveStateStatusCliCommand({
50
+ memoryDir: orchestrator.config.memoryDir,
51
+ objectiveStateStoreDir: orchestrator.config.objectiveStateStoreDir,
52
+ objectiveStateMemoryEnabled: orchestrator.config.objectiveStateMemoryEnabled,
53
+ objectiveStateSnapshotWritesEnabled: orchestrator.config.objectiveStateSnapshotWritesEnabled,
54
+ });
55
+ console.log(JSON.stringify(status, null, 2));
56
+ console.log("OK");
57
+ });
58
+
59
+ cmd
60
+ .command("causal-trajectory-status")
61
+ .description("Show causal-trajectory store status, record counts, and latest stored chain")
62
+ .action(async () => {
63
+ const status = await runCausalTrajectoryStatusCliCommand({
64
+ memoryDir: orchestrator.config.memoryDir,
65
+ causalTrajectoryStoreDir: orchestrator.config.causalTrajectoryStoreDir,
66
+ causalTrajectoryMemoryEnabled: orchestrator.config.causalTrajectoryMemoryEnabled,
67
+ });
68
+ console.log(JSON.stringify(status, null, 2));
69
+ console.log("OK");
70
+ });
71
+
72
+ cmd
73
+ .command("trust-zone-status")
74
+ .description("Show trust-zone store status, zoned record counts, and latest stored record")
75
+ .action(async () => {
76
+ const status = await runTrustZoneStatusCliCommand({
77
+ memoryDir: orchestrator.config.memoryDir,
78
+ trustZoneStoreDir: orchestrator.config.trustZoneStoreDir,
79
+ trustZonesEnabled: orchestrator.config.trustZonesEnabled,
80
+ quarantinePromotionEnabled: orchestrator.config.quarantinePromotionEnabled,
81
+ memoryPoisoningDefenseEnabled: orchestrator.config.memoryPoisoningDefenseEnabled,
82
+ });
83
+ console.log(JSON.stringify(status, null, 2));
84
+ console.log("OK");
85
+ });
86
+
87
+ cmd
88
+ .command("trust-zone-demo-seed")
89
+ .description("Explicitly seed an opt-in trust-zone demo dataset for buyer-facing walkthroughs")
90
+ .option("--scenario <scenario>", "Demo scenario id (default: enterprise-buyer-v1)")
91
+ .option("--recorded-at <isoTimestamp>", "Base ISO timestamp used to anchor demo records")
92
+ .option("--dry-run", "Preview the demo dataset without writing any trust-zone records")
93
+ .action(async (...args: unknown[]) => {
94
+ const options = (args[0] ?? {}) as Record<string, unknown>;
95
+ const result = await runTrustZoneDemoSeedCliCommand({
96
+ memoryDir: orchestrator.config.memoryDir,
97
+ trustZoneStoreDir: orchestrator.config.trustZoneStoreDir,
98
+ trustZonesEnabled: orchestrator.config.trustZonesEnabled,
99
+ scenario: typeof options.scenario === "string" ? options.scenario : undefined,
100
+ recordedAt: typeof options.recordedAt === "string" ? options.recordedAt : undefined,
101
+ dryRun: options.dryRun === true,
102
+ });
103
+ console.log(JSON.stringify(result, null, 2));
104
+ console.log("OK");
105
+ });
106
+
107
+ cmd
108
+ .command("abstraction-node-status")
109
+ .description("Show abstraction-node store status, abstraction counts, and latest stored node")
110
+ .action(async () => {
111
+ const status = await runAbstractionNodeStatusCliCommand({
112
+ memoryDir: orchestrator.config.memoryDir,
113
+ abstractionNodeStoreDir: orchestrator.config.abstractionNodeStoreDir,
114
+ harmonicRetrievalEnabled: orchestrator.config.harmonicRetrievalEnabled,
115
+ abstractionAnchorsEnabled: orchestrator.config.abstractionAnchorsEnabled,
116
+ });
117
+ console.log(JSON.stringify(status, null, 2));
118
+ console.log("OK");
119
+ });
120
+
121
+ cmd
122
+ .command("cue-anchor-status")
123
+ .description("Show cue-anchor index status, anchor counts, and the latest stored cue anchor")
124
+ .action(async () => {
125
+ const status = await runCueAnchorStatusCliCommand({
126
+ memoryDir: orchestrator.config.memoryDir,
127
+ abstractionNodeStoreDir: orchestrator.config.abstractionNodeStoreDir,
128
+ harmonicRetrievalEnabled: orchestrator.config.harmonicRetrievalEnabled,
129
+ abstractionAnchorsEnabled: orchestrator.config.abstractionAnchorsEnabled,
130
+ });
131
+ console.log(JSON.stringify(status, null, 2));
132
+ console.log("OK");
133
+ });
134
+
135
+ cmd
136
+ .command("harmonic-search")
137
+ .description("Preview harmonic retrieval blending over abstraction nodes and cue anchors")
138
+ .argument("<query>", "Prompt-like query to evaluate against harmonic retrieval storage")
139
+ .option("--max-results <count>", "Maximum number of blended results to return", "3")
140
+ .option("--session-key <sessionKey>", "Optional session key for same-session tie-breaking")
141
+ .action(async (...args: unknown[]) => {
142
+ const query = typeof args[0] === "string" ? args[0] : "";
143
+ const options = (args[1] ?? {}) as Record<string, unknown>;
144
+ const maxResults = typeof options.maxResults === "string"
145
+ ? Number.parseInt(options.maxResults, 10)
146
+ : 3;
147
+ const results = await runHarmonicSearchCliCommand({
148
+ memoryDir: orchestrator.config.memoryDir,
149
+ abstractionNodeStoreDir: orchestrator.config.abstractionNodeStoreDir,
150
+ harmonicRetrievalEnabled: orchestrator.config.harmonicRetrievalEnabled,
151
+ abstractionAnchorsEnabled: orchestrator.config.abstractionAnchorsEnabled,
152
+ query,
153
+ maxResults: Number.isFinite(maxResults) ? maxResults : 3,
154
+ sessionKey: typeof options.sessionKey === "string" ? options.sessionKey : undefined,
155
+ });
156
+ console.log(JSON.stringify(results, null, 2));
157
+ console.log("OK");
158
+ });
159
+
160
+ cmd
161
+ .command("utility-status")
162
+ .description("Show utility-learning telemetry status, event counts, and the latest utility event")
163
+ .action(async () => {
164
+ const status = await runUtilityTelemetryStatusCliCommand({
165
+ memoryDir: orchestrator.config.memoryDir,
166
+ memoryUtilityLearningEnabled: orchestrator.config.memoryUtilityLearningEnabled,
167
+ promotionByOutcomeEnabled: orchestrator.config.promotionByOutcomeEnabled,
168
+ });
169
+ console.log(JSON.stringify(status, null, 2));
170
+ console.log("OK");
171
+ });
172
+
173
+ cmd
174
+ .command("utility-record")
175
+ .description("Record a utility-learning telemetry event when utility learning is enabled")
176
+ .requiredOption("--event-id <eventId>", "Utility telemetry event id")
177
+ .requiredOption("--recorded-at <recordedAt>", "ISO timestamp for the event")
178
+ .requiredOption("--session-key <sessionKey>", "Session key associated with the event")
179
+ .requiredOption("--source <source>", "Event source (cli|system|benchmark|tool_result)")
180
+ .requiredOption("--target <target>", "Telemetry target (promotion|ranking)")
181
+ .requiredOption("--decision <decision>", "Decision taken (promote|demote|hold|boost|suppress)")
182
+ .requiredOption("--outcome <outcome>", "Observed outcome (helpful|neutral|harmful)")
183
+ .requiredOption("--utility-score <utilityScore>", "Bounded utility score between -1 and 1")
184
+ .requiredOption("--summary <summary>", "Human-readable summary of the measured utility event")
185
+ .option("--memory-id <memoryId...>", "Memory ids linked to the utility event")
186
+ .option("--entity-ref <entityRef...>", "Entity refs linked to the utility event")
187
+ .option("--tag <tag...>", "Tags to attach to the utility event")
188
+ .action(async (...args: unknown[]) => {
189
+ const options = (args[0] ?? {}) as Record<string, unknown>;
190
+ const utilityScore = typeof options.utilityScore === "string"
191
+ ? Number.parseFloat(options.utilityScore)
192
+ : Number.NaN;
193
+ const filePath = await runUtilityTelemetryRecordCliCommand({
194
+ memoryDir: orchestrator.config.memoryDir,
195
+ memoryUtilityLearningEnabled: orchestrator.config.memoryUtilityLearningEnabled,
196
+ event: {
197
+ schemaVersion: 1,
198
+ eventId: String(options.eventId ?? ""),
199
+ recordedAt: String(options.recordedAt ?? ""),
200
+ sessionKey: String(options.sessionKey ?? ""),
201
+ source: String(options.source ?? "") as UtilityTelemetryEvent["source"],
202
+ target: String(options.target ?? "") as UtilityTelemetryEvent["target"],
203
+ decision: String(options.decision ?? "") as UtilityTelemetryEvent["decision"],
204
+ outcome: String(options.outcome ?? "") as UtilityTelemetryEvent["outcome"],
205
+ utilityScore,
206
+ summary: String(options.summary ?? ""),
207
+ memoryIds: Array.isArray(options.memoryId) ? options.memoryId.map(String) : undefined,
208
+ entityRefs: Array.isArray(options.entityRef) ? options.entityRef.map(String) : undefined,
209
+ tags: Array.isArray(options.tag) ? options.tag.map(String) : undefined,
210
+ },
211
+ });
212
+ console.log(JSON.stringify({ wrote: filePath !== null, filePath }, null, 2));
213
+ console.log("OK");
214
+ });
215
+
216
+ cmd
217
+ .command("utility-learning-status")
218
+ .description("Show offline utility-learning snapshot status and learned weight counts")
219
+ .action(async () => {
220
+ const status = await runUtilityLearningStatusCliCommand({
221
+ memoryDir: orchestrator.config.memoryDir,
222
+ memoryUtilityLearningEnabled: orchestrator.config.memoryUtilityLearningEnabled,
223
+ promotionByOutcomeEnabled: orchestrator.config.promotionByOutcomeEnabled,
224
+ });
225
+ console.log(JSON.stringify(status, null, 2));
226
+ console.log("OK");
227
+ });
228
+
229
+ cmd
230
+ .command("utility-learn")
231
+ .description("Learn bounded offline promotion/ranking weights from recorded utility telemetry")
232
+ .option("--window-days <days>", "Telemetry lookback window in days", "14")
233
+ .option("--min-event-count <count>", "Minimum event count required per target/decision group", "3")
234
+ .option("--max-weight-magnitude <value>", "Maximum absolute learned weight magnitude", "0.35")
235
+ .action(async (...args: unknown[]) => {
236
+ const options = (args[0] ?? {}) as Record<string, unknown>;
237
+ const learningWindowDays = typeof options.windowDays === "string"
238
+ ? Number.parseInt(options.windowDays, 10)
239
+ : 14;
240
+ const minEventCount = typeof options.minEventCount === "string"
241
+ ? Number.parseInt(options.minEventCount, 10)
242
+ : 3;
243
+ const maxWeightMagnitude = typeof options.maxWeightMagnitude === "string"
244
+ ? Number.parseFloat(options.maxWeightMagnitude)
245
+ : 0.35;
246
+ const result = await runUtilityLearningCliCommand({
247
+ memoryDir: orchestrator.config.memoryDir,
248
+ memoryUtilityLearningEnabled: orchestrator.config.memoryUtilityLearningEnabled,
249
+ learningWindowDays,
250
+ minEventCount,
251
+ maxWeightMagnitude,
252
+ });
253
+ console.log(JSON.stringify(result, null, 2));
254
+ console.log("OK");
255
+ });
256
+ }