@remnic/core 1.1.3 → 1.1.5

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 (182) hide show
  1. package/dist/access-cli.js +19 -19
  2. package/dist/access-http.d.ts +7 -7
  3. package/dist/access-http.js +12 -11
  4. package/dist/access-mcp.d.ts +7 -7
  5. package/dist/access-mcp.js +11 -10
  6. package/dist/access-schema.d.ts +89 -4
  7. package/dist/access-schema.js +1 -1
  8. package/dist/{access-service-_AEUMVyX.d.ts → access-service-CWYIkMwY.d.ts} +74 -18
  9. package/dist/access-service.d.ts +7 -7
  10. package/dist/access-service.js +9 -8
  11. package/dist/active-memory-bridge.d.ts +1 -1
  12. package/dist/active-recall.d.ts +1 -1
  13. package/dist/behavior-learner.d.ts +1 -1
  14. package/dist/behavior-signals.d.ts +1 -1
  15. package/dist/bootstrap.d.ts +6 -6
  16. package/dist/briefing.d.ts +2 -2
  17. package/dist/briefing.js +4 -4
  18. package/dist/buffer-surprise-report.d.ts +1 -1
  19. package/dist/buffer.d.ts +2 -2
  20. package/dist/calibration.d.ts +1 -1
  21. package/dist/causal-behavior.d.ts +1 -1
  22. package/dist/causal-consolidation.d.ts +2 -2
  23. package/dist/causal-consolidation.js +4 -4
  24. package/dist/{chunk-LZRYQK6L.js → chunk-3YBRSJ52.js} +2 -2
  25. package/dist/{chunk-DCE6SQLA.js → chunk-46AIFPQM.js} +3 -3
  26. package/dist/{chunk-AKUCB2OG.js → chunk-4CVIF7UZ.js} +14 -7
  27. package/dist/chunk-4CVIF7UZ.js.map +1 -0
  28. package/dist/{chunk-34F3PLWZ.js → chunk-57SNKQNS.js} +2 -2
  29. package/dist/{chunk-DHRQHX36.js → chunk-5XVDDCMH.js} +2 -2
  30. package/dist/{chunk-BOUYNNYD.js → chunk-67YLUWLG.js} +32 -13
  31. package/dist/{chunk-BOUYNNYD.js.map → chunk-67YLUWLG.js.map} +1 -1
  32. package/dist/{chunk-IM3JSE73.js → chunk-7NFZWXAY.js} +722 -27
  33. package/dist/chunk-7NFZWXAY.js.map +1 -0
  34. package/dist/{chunk-4PLGJRBV.js → chunk-DKVEJTLC.js} +188 -18
  35. package/dist/chunk-DKVEJTLC.js.map +1 -0
  36. package/dist/{chunk-DR7MCMPS.js → chunk-DTDB6YS2.js} +219 -9
  37. package/dist/chunk-DTDB6YS2.js.map +1 -0
  38. package/dist/{chunk-55FXRRSJ.js → chunk-ERWKQVCX.js} +2 -2
  39. package/dist/{chunk-7GCMLT7J.js → chunk-FG5R5AQF.js} +5 -5
  40. package/dist/{chunk-Y3WQ4ZWK.js → chunk-FLHPNR5W.js} +2 -2
  41. package/dist/{chunk-JWSENLQI.js → chunk-H62HCANJ.js} +3 -1
  42. package/dist/{chunk-JWSENLQI.js.map → chunk-H62HCANJ.js.map} +1 -1
  43. package/dist/{chunk-L5IIGA5V.js → chunk-HPJPGIGN.js} +2 -2
  44. package/dist/{chunk-SS253RXF.js → chunk-KCZZLFW5.js} +2 -2
  45. package/dist/{chunk-47WOM4YW.js → chunk-MJPNOMY4.js} +2 -2
  46. package/dist/{chunk-ZGXSCMQN.js → chunk-OAIXBFAH.js} +18 -18
  47. package/dist/{chunk-ZGXSCMQN.js.map → chunk-OAIXBFAH.js.map} +1 -1
  48. package/dist/{chunk-RILIVK4O.js → chunk-RICG4UNC.js} +28 -2
  49. package/dist/chunk-RICG4UNC.js.map +1 -0
  50. package/dist/{chunk-SMA4IMHV.js → chunk-SGTA3HJC.js} +3 -3
  51. package/dist/{chunk-VTJVUHRK.js → chunk-SRBJUAMP.js} +1 -1
  52. package/dist/chunk-SRBJUAMP.js.map +1 -0
  53. package/dist/{chunk-R2L7SUX2.js → chunk-TMPLRVHD.js} +2 -2
  54. package/dist/{chunk-43EKP2UK.js → chunk-TOC3VOOF.js} +1 -1
  55. package/dist/{chunk-43EKP2UK.js.map → chunk-TOC3VOOF.js.map} +1 -1
  56. package/dist/{chunk-USFPPRAF.js → chunk-WMK6YP7C.js} +5 -3
  57. package/dist/chunk-WMK6YP7C.js.map +1 -0
  58. package/dist/{chunk-N7X62G74.js → chunk-X6VBWOVZ.js} +4 -4
  59. package/dist/{chunk-LW2NMHDW.js → chunk-Y6EPN6XF.js} +2 -2
  60. package/dist/{chunk-LVYGDT5V.js → chunk-Z665HFAD.js} +10 -12
  61. package/dist/chunk-Z665HFAD.js.map +1 -0
  62. package/dist/{cli-x2APT9a6.d.ts → cli-CWLyGroU.d.ts} +4 -4
  63. package/dist/cli.d.ts +8 -8
  64. package/dist/cli.js +22 -21
  65. package/dist/{codex-materialize-CQlLTzke.d.ts → codex-materialize-XRen3WAz.d.ts} +1 -1
  66. package/dist/compression-optimizer.d.ts +1 -1
  67. package/dist/config.d.ts +1 -1
  68. package/dist/config.js +1 -1
  69. package/dist/consolidation-provenance-check.d.ts +2 -2
  70. package/dist/consolidation-undo.d.ts +2 -2
  71. package/dist/day-summary.d.ts +1 -1
  72. package/dist/delinearize.d.ts +1 -1
  73. package/dist/direct-answer-wiring.d.ts +1 -1
  74. package/dist/direct-answer.d.ts +1 -1
  75. package/dist/embedding-fallback.d.ts +1 -1
  76. package/dist/{engine-ICC2DSQF.js → engine-WJ7K6AZ2.js} +7 -5
  77. package/dist/entity-retrieval.d.ts +2 -2
  78. package/dist/entity-retrieval.js +4 -4
  79. package/dist/entity-schema.d.ts +1 -1
  80. package/dist/explicit-capture.d.ts +6 -6
  81. package/dist/extraction-judge-telemetry.d.ts +1 -1
  82. package/dist/extraction-judge-training.d.ts +1 -1
  83. package/dist/extraction-judge.d.ts +1 -1
  84. package/dist/extraction.d.ts +1 -1
  85. package/dist/extraction.js +2 -2
  86. package/dist/fallback-llm.d.ts +1 -1
  87. package/dist/identity-continuity.d.ts +1 -1
  88. package/dist/importance.d.ts +1 -1
  89. package/dist/index.d.ts +26 -14
  90. package/dist/index.js +47 -27
  91. package/dist/index.js.map +1 -1
  92. package/dist/intent.d.ts +1 -1
  93. package/dist/lifecycle.d.ts +1 -1
  94. package/dist/live-connectors-runner.d.ts +1 -1
  95. package/dist/local-llm.d.ts +1 -1
  96. package/dist/memory-action-policy.d.ts +1 -1
  97. package/dist/memory-cache.d.ts +1 -1
  98. package/dist/{memory-governance-KG52RITE.js → memory-governance-KXMAURFF.js} +5 -5
  99. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  100. package/dist/{memory-projection-store-D3vBHS4J.d.ts → memory-projection-store-ConH7gNj.d.ts} +2 -2
  101. package/dist/memory-projection-store.d.ts +2 -2
  102. package/dist/memory-projection-store.js +1 -1
  103. package/dist/memory-worth-outcomes.d.ts +2 -2
  104. package/dist/models-json.d.ts +1 -1
  105. package/dist/native-knowledge.d.ts +1 -1
  106. package/dist/operator-toolkit.d.ts +2 -2
  107. package/dist/operator-toolkit.js +7 -7
  108. package/dist/{orchestrator-ChkesB8U.d.ts → orchestrator-BHkiEBbd.d.ts} +36 -11
  109. package/dist/orchestrator.d.ts +6 -6
  110. package/dist/orchestrator.js +14 -14
  111. package/dist/patterns-cli.d.ts +1 -1
  112. package/dist/policy-runtime.d.ts +1 -1
  113. package/dist/{port-hqGnoStS.d.ts → port-DZHdlUId.d.ts} +1 -1
  114. package/dist/qmd-recall-cache.d.ts +2 -2
  115. package/dist/qmd.d.ts +2 -2
  116. package/dist/recall-disclosure-escalation.d.ts +1 -1
  117. package/dist/recall-explain-renderer.d.ts +1 -1
  118. package/dist/recall-explain-renderer.js +3 -3
  119. package/dist/recall-state.d.ts +1 -1
  120. package/dist/recall-tag-filter.d.ts +1 -1
  121. package/dist/recall-xray-cli.d.ts +1 -1
  122. package/dist/recall-xray-cli.js +4 -4
  123. package/dist/recall-xray-renderer.d.ts +1 -1
  124. package/dist/recall-xray-renderer.js +3 -3
  125. package/dist/recall-xray.d.ts +2 -2
  126. package/dist/recall-xray.js +2 -2
  127. package/dist/resolve-auth-token.d.ts +1 -1
  128. package/dist/resume-bundles.js +2 -2
  129. package/dist/retrieval-agents.d.ts +2 -2
  130. package/dist/retrieval-tiers.d.ts +1 -1
  131. package/dist/schemas.d.ts +54 -54
  132. package/dist/{semantic-consolidation-ByBXb-sf.d.ts → semantic-consolidation-Cxj-inGC.d.ts} +2 -2
  133. package/dist/semantic-consolidation.d.ts +3 -3
  134. package/dist/semantic-consolidation.js +4 -4
  135. package/dist/semantic-rule-promotion.js +4 -4
  136. package/dist/semantic-rule-verifier.d.ts +1 -1
  137. package/dist/semantic-rule-verifier.js +4 -4
  138. package/dist/session-observer-bands.d.ts +1 -1
  139. package/dist/session-observer-state.d.ts +1 -1
  140. package/dist/signal.d.ts +1 -1
  141. package/dist/storage.d.ts +2 -2
  142. package/dist/storage.js +3 -3
  143. package/dist/summarizer.d.ts +1 -1
  144. package/dist/summary-snapshot.d.ts +1 -1
  145. package/dist/temporal-supersession.d.ts +2 -2
  146. package/dist/temporal-validity.d.ts +1 -1
  147. package/dist/threading.d.ts +1 -1
  148. package/dist/tier-migration.d.ts +3 -3
  149. package/dist/tier-routing.d.ts +1 -1
  150. package/dist/topics.d.ts +1 -1
  151. package/dist/transcript.d.ts +1 -1
  152. package/dist/types-B49NzJ5q.d.ts +2707 -0
  153. package/dist/types.d.ts +1 -2668
  154. package/dist/types.js +1 -1
  155. package/dist/utility-runtime.d.ts +1 -1
  156. package/dist/verified-recall.js +4 -4
  157. package/package.json +6 -3
  158. package/scripts/ensure-better-sqlite3.mjs +124 -0
  159. package/dist/chunk-4PLGJRBV.js.map +0 -1
  160. package/dist/chunk-AKUCB2OG.js.map +0 -1
  161. package/dist/chunk-DR7MCMPS.js.map +0 -1
  162. package/dist/chunk-IM3JSE73.js.map +0 -1
  163. package/dist/chunk-LVYGDT5V.js.map +0 -1
  164. package/dist/chunk-RILIVK4O.js.map +0 -1
  165. package/dist/chunk-USFPPRAF.js.map +0 -1
  166. package/dist/chunk-VTJVUHRK.js.map +0 -1
  167. /package/dist/{chunk-LZRYQK6L.js.map → chunk-3YBRSJ52.js.map} +0 -0
  168. /package/dist/{chunk-DCE6SQLA.js.map → chunk-46AIFPQM.js.map} +0 -0
  169. /package/dist/{chunk-34F3PLWZ.js.map → chunk-57SNKQNS.js.map} +0 -0
  170. /package/dist/{chunk-DHRQHX36.js.map → chunk-5XVDDCMH.js.map} +0 -0
  171. /package/dist/{chunk-55FXRRSJ.js.map → chunk-ERWKQVCX.js.map} +0 -0
  172. /package/dist/{chunk-7GCMLT7J.js.map → chunk-FG5R5AQF.js.map} +0 -0
  173. /package/dist/{chunk-Y3WQ4ZWK.js.map → chunk-FLHPNR5W.js.map} +0 -0
  174. /package/dist/{chunk-L5IIGA5V.js.map → chunk-HPJPGIGN.js.map} +0 -0
  175. /package/dist/{chunk-SS253RXF.js.map → chunk-KCZZLFW5.js.map} +0 -0
  176. /package/dist/{chunk-47WOM4YW.js.map → chunk-MJPNOMY4.js.map} +0 -0
  177. /package/dist/{chunk-SMA4IMHV.js.map → chunk-SGTA3HJC.js.map} +0 -0
  178. /package/dist/{chunk-R2L7SUX2.js.map → chunk-TMPLRVHD.js.map} +0 -0
  179. /package/dist/{chunk-N7X62G74.js.map → chunk-X6VBWOVZ.js.map} +0 -0
  180. /package/dist/{chunk-LW2NMHDW.js.map → chunk-Y6EPN6XF.js.map} +0 -0
  181. /package/dist/{engine-ICC2DSQF.js.map → engine-WJ7K6AZ2.js.map} +0 -0
  182. /package/dist/{memory-governance-KG52RITE.js.map → memory-governance-KXMAURFF.js.map} +0 -0
@@ -11,7 +11,7 @@ import {
11
11
  } from "./chunk-H7XKCNR6.js";
12
12
  import {
13
13
  toRecallExplainJson
14
- } from "./chunk-LW2NMHDW.js";
14
+ } from "./chunk-Y6EPN6XF.js";
15
15
  import {
16
16
  clusterByKey,
17
17
  resolveGitContext
@@ -27,7 +27,7 @@ import {
27
27
  } from "./chunk-EQINRHYR.js";
28
28
  import {
29
29
  estimateRecallTokens
30
- } from "./chunk-USFPPRAF.js";
30
+ } from "./chunk-WMK6YP7C.js";
31
31
  import {
32
32
  buildProposedActions,
33
33
  buildQualityScore,
@@ -35,7 +35,7 @@ import {
35
35
  listMemoryGovernanceRuns,
36
36
  readMemoryGovernanceRunArtifact,
37
37
  runMemoryGovernance
38
- } from "./chunk-LZRYQK6L.js";
38
+ } from "./chunk-3YBRSJ52.js";
39
39
  import {
40
40
  recordMemoryOutcome
41
41
  } from "./chunk-EIR5VLIH.js";
@@ -50,6 +50,9 @@ import {
50
50
  import {
51
51
  wrapWorkLayerContext
52
52
  } from "./chunk-EEQLFRUM.js";
53
+ import {
54
+ formatProfileTraceAscii
55
+ } from "./chunk-NBNN5GOB.js";
53
56
  import {
54
57
  buildProcedurePersistBody,
55
58
  normalizeProcedureSteps
@@ -76,14 +79,14 @@ import {
76
79
  buildBriefing,
77
80
  parseBriefingFocus,
78
81
  parseBriefingWindow
79
- } from "./chunk-SS253RXF.js";
82
+ } from "./chunk-KCZZLFW5.js";
80
83
  import {
81
84
  parseEntityFile
82
- } from "./chunk-DCE6SQLA.js";
85
+ } from "./chunk-46AIFPQM.js";
83
86
  import {
84
87
  DEFAULT_RECALL_DISCLOSURE,
85
88
  isRecallDisclosure
86
- } from "./chunk-43EKP2UK.js";
89
+ } from "./chunk-TOC3VOOF.js";
87
90
  import {
88
91
  inferMemoryStatus,
89
92
  toMemoryPathRel
@@ -94,7 +97,7 @@ import {
94
97
  } from "./chunk-SCU65EZI.js";
95
98
  import {
96
99
  getMemoryProjectionPath
97
- } from "./chunk-BOUYNNYD.js";
100
+ } from "./chunk-67YLUWLG.js";
98
101
  import {
99
102
  log
100
103
  } from "./chunk-2ODBA7MQ.js";
@@ -113,6 +116,7 @@ import {
113
116
  import { stat } from "fs/promises";
114
117
  import * as nodeFs from "fs/promises";
115
118
  import { constants as fsConstants } from "fs";
119
+ import { createHash } from "crypto";
116
120
  import { ZodError } from "zod";
117
121
 
118
122
  // src/work/storage.ts
@@ -2553,6 +2557,147 @@ var EngramAccessService = class {
2553
2557
  });
2554
2558
  return { namespace: resolvedNamespace, ...report };
2555
2559
  }
2560
+ async memorySummarizeHourly() {
2561
+ await this.orchestrator.summarizer.runHourly();
2562
+ return {
2563
+ ok: true,
2564
+ message: "Hourly summarization completed. Check the summaries directory for results."
2565
+ };
2566
+ }
2567
+ async conversationIndexUpdate(request = {}) {
2568
+ if (!this.orchestrator.config.conversationIndexEnabled) {
2569
+ return {
2570
+ enabled: false,
2571
+ sessions: 0,
2572
+ chunks: 0,
2573
+ skipped: 0,
2574
+ skippedSessionKeys: [],
2575
+ embeddedRuns: 0,
2576
+ reason: "disabled"
2577
+ };
2578
+ }
2579
+ const hours = typeof request.hours === "number" && Number.isFinite(request.hours) ? Math.max(1, Math.floor(request.hours)) : 24;
2580
+ let sessionKey;
2581
+ if (request.sessionKey !== void 0) {
2582
+ if (typeof request.sessionKey !== "string" || request.sessionKey.trim().length === 0) {
2583
+ throw new EngramAccessInputError("sessionKey must be a non-empty string when provided");
2584
+ }
2585
+ sessionKey = request.sessionKey.trim();
2586
+ }
2587
+ if (sessionKey) {
2588
+ const result = await this.orchestrator.updateConversationIndex(
2589
+ sessionKey,
2590
+ hours,
2591
+ { embed: request.embed }
2592
+ );
2593
+ return {
2594
+ enabled: true,
2595
+ sessionKey,
2596
+ sessions: 1,
2597
+ chunks: result.chunks,
2598
+ skipped: result.skipped ? 1 : 0,
2599
+ skippedSessionKeys: result.skipped ? [sessionKey] : [],
2600
+ embeddedRuns: result.embedded ? 1 : 0,
2601
+ reason: result.reason,
2602
+ retryAfterMs: result.retryAfterMs
2603
+ };
2604
+ }
2605
+ const sessionKeys = await this.orchestrator.transcript.listSessionKeys();
2606
+ let chunks = 0;
2607
+ let skipped = 0;
2608
+ const skippedSessionKeys = [];
2609
+ let embeddedRuns = 0;
2610
+ for (const sessionKey2 of sessionKeys) {
2611
+ const result = await this.orchestrator.updateConversationIndex(
2612
+ sessionKey2,
2613
+ hours,
2614
+ { embed: request.embed }
2615
+ );
2616
+ chunks += result.chunks;
2617
+ if (result.skipped) {
2618
+ skipped += 1;
2619
+ skippedSessionKeys.push(sessionKey2);
2620
+ }
2621
+ if (result.embedded) {
2622
+ embeddedRuns += 1;
2623
+ }
2624
+ }
2625
+ return {
2626
+ enabled: true,
2627
+ sessions: sessionKeys.length,
2628
+ chunks,
2629
+ skipped,
2630
+ skippedSessionKeys,
2631
+ embeddedRuns
2632
+ };
2633
+ }
2634
+ async profilingReport(request = {}) {
2635
+ const profiler = this.orchestrator.profiler;
2636
+ if (!profiler.isEnabled) {
2637
+ return {
2638
+ enabled: false,
2639
+ reason: "disabled",
2640
+ message: "Profiling is disabled. Set profilingEnabled: true in your plugin config to enable."
2641
+ };
2642
+ }
2643
+ const format = request.format ?? "ascii";
2644
+ if (format !== "ascii" && format !== "json") {
2645
+ throw new EngramAccessInputError("format must be one of: ascii, json");
2646
+ }
2647
+ const limit = request.limit ?? 5;
2648
+ if (!Number.isInteger(limit) || limit < 1 || limit > 20) {
2649
+ throw new EngramAccessInputError("limit must be an integer between 1 and 20");
2650
+ }
2651
+ const traces = profiler.getRecentTraces(limit);
2652
+ const stats = profiler.getStats();
2653
+ const bottleneck = profiler.identifyBottleneck();
2654
+ if (format === "json") {
2655
+ return {
2656
+ enabled: true,
2657
+ format,
2658
+ traces,
2659
+ stats,
2660
+ bottleneck
2661
+ };
2662
+ }
2663
+ const lines = [];
2664
+ lines.push("Engram Profiling Report");
2665
+ lines.push("=".repeat(60));
2666
+ lines.push("");
2667
+ const allBuckets = [
2668
+ ["byKind", stats.byKind],
2669
+ ["bySpan", stats.bySpan]
2670
+ ];
2671
+ const hasStats = allBuckets.some(([, entries]) => Object.keys(entries).length > 0);
2672
+ if (hasStats) {
2673
+ lines.push("Aggregate Stats (all retained traces):");
2674
+ for (const [bucket, entries] of allBuckets) {
2675
+ for (const [key, summary] of Object.entries(entries)) {
2676
+ lines.push(
2677
+ ` ${bucket}/${key}: avg=${summary.avgMs}ms p50=${summary.p50Ms}ms p95=${summary.p95Ms}ms max=${summary.maxMs}ms (n=${summary.count})`
2678
+ );
2679
+ }
2680
+ }
2681
+ lines.push("");
2682
+ }
2683
+ if (bottleneck) {
2684
+ lines.push(`Bottleneck: ${bottleneck}`);
2685
+ lines.push("");
2686
+ }
2687
+ if (traces.length === 0) {
2688
+ lines.push("No traces recorded yet. Trigger a recall or extraction to see timing data.");
2689
+ } else {
2690
+ for (const trace of traces) {
2691
+ lines.push(formatProfileTraceAscii(trace));
2692
+ lines.push("");
2693
+ }
2694
+ }
2695
+ return {
2696
+ enabled: true,
2697
+ format,
2698
+ report: lines.join("\n")
2699
+ };
2700
+ }
2556
2701
  async trustZoneStatus(namespace, principal) {
2557
2702
  const resolvedNamespace = this.resolveReadableNamespace(namespace, principal);
2558
2703
  const storage = await this.orchestrator.getStorage(resolvedNamespace);
@@ -2770,10 +2915,15 @@ var EngramAccessService = class {
2770
2915
  sessionKey: lcmSessionKey,
2771
2916
  role: m.role,
2772
2917
  content: m.content,
2918
+ parts: m.parts,
2919
+ rawContent: m.rawContent,
2920
+ sourceFormat: m.sourceFormat,
2773
2921
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
2774
2922
  }));
2775
2923
  try {
2776
- const extractionPromise = this.orchestrator.ingestReplayBatch(turns);
2924
+ const extractionPromise = this.orchestrator.ingestReplayBatch(turns, {
2925
+ archiveLcm: false
2926
+ });
2777
2927
  extractionPromise.catch((err) => {
2778
2928
  log.error(`access-observe background extraction failed: ${err}`);
2779
2929
  });
@@ -3472,6 +3622,66 @@ ${next}`);
3472
3622
  });
3473
3623
  return { promoted: true, memoryId: request.memoryId };
3474
3624
  }
3625
+ async memoryActionApply(request) {
3626
+ const actionTypes = /* @__PURE__ */ new Set([
3627
+ "store_episode",
3628
+ "store_note",
3629
+ "update_note",
3630
+ "create_artifact",
3631
+ "summarize_node",
3632
+ "discard",
3633
+ "link_graph"
3634
+ ]);
3635
+ if (!actionTypes.has(request.action)) {
3636
+ throw new EngramAccessInputError(
3637
+ `memory_action_apply: invalid action ${JSON.stringify(request.action)}`
3638
+ );
3639
+ }
3640
+ if (this.orchestrator.config.contextCompressionActionsEnabled !== true) {
3641
+ throw new EngramAccessInputError(
3642
+ "memory_action_apply is disabled; enable contextCompressionActionsEnabled to use this tool"
3643
+ );
3644
+ }
3645
+ const outcome = request.outcome ?? "skipped";
3646
+ if (outcome !== "applied" && outcome !== "skipped" && outcome !== "failed") {
3647
+ throw new EngramAccessInputError(
3648
+ `memory_action_apply: outcome must be "applied", "skipped", or "failed"; got ${JSON.stringify(outcome)}`
3649
+ );
3650
+ }
3651
+ const resolvedNs = this.resolveWritableNamespace(
3652
+ request.namespace,
3653
+ request.sessionKey,
3654
+ request.principal
3655
+ );
3656
+ const inputSummaryParts = [
3657
+ request.content,
3658
+ request.category ? `category=${request.category}` : void 0,
3659
+ request.linkTargetId ? `linkTargetId=${request.linkTargetId}` : void 0,
3660
+ request.linkType ? `linkType=${request.linkType}` : void 0,
3661
+ typeof request.linkStrength === "number" ? `linkStrength=${request.linkStrength}` : void 0,
3662
+ request.artifactType ? `artifactType=${request.artifactType}` : void 0,
3663
+ typeof request.execute === "boolean" ? `execute=${request.execute}` : void 0
3664
+ ].filter((part) => typeof part === "string" && part.length > 0);
3665
+ const event = {
3666
+ action: request.action,
3667
+ outcome,
3668
+ namespace: resolvedNs,
3669
+ actor: "access.memory_action_apply",
3670
+ subsystem: "access.memory_action_apply",
3671
+ reason: request.reason,
3672
+ memoryId: request.memoryId,
3673
+ sourceSessionKey: request.sessionKey,
3674
+ inputSummary: inputSummaryParts.length > 0 ? inputSummaryParts.join(" | ").slice(0, 500) : void 0,
3675
+ dryRun: request.dryRun === true,
3676
+ promptHash: typeof request.sourcePrompt === "string" && request.sourcePrompt.length > 0 ? createHash("sha256").update(request.sourcePrompt).digest("hex") : void 0
3677
+ };
3678
+ const preview = this.orchestrator.previewMemoryActionEvent(event);
3679
+ if (request.dryRun === true) {
3680
+ return { recorded: false, dryRun: true, event: preview };
3681
+ }
3682
+ const recorded = await this.orchestrator.appendMemoryActionEvent(event);
3683
+ return { recorded, event: preview };
3684
+ }
3475
3685
  async contextCheckpoint(request) {
3476
3686
  const resolvedNs = this.resolveWritableNamespace(request.namespace, request.sessionKey, request.principal);
3477
3687
  const storage = await this.orchestrator.getStorage(resolvedNs);
@@ -4017,4 +4227,4 @@ export {
4017
4227
  shapeMemorySummary,
4018
4228
  EngramAccessService
4019
4229
  };
4020
- //# sourceMappingURL=chunk-DR7MCMPS.js.map
4230
+ //# sourceMappingURL=chunk-DTDB6YS2.js.map