@memberjunction/ai-agents 6.3.0-edge.0 → 6.3.0-edge.1

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 (211) hide show
  1. package/README.md +8 -5
  2. package/dist/AgentDataPreloader.d.ts +9 -2
  3. package/dist/AgentDataPreloader.d.ts.map +1 -1
  4. package/dist/AgentDataPreloader.js +134 -15
  5. package/dist/AgentDataPreloader.js.map +1 -1
  6. package/dist/AgentDecisionService.d.ts +10 -1
  7. package/dist/AgentDecisionService.d.ts.map +1 -1
  8. package/dist/AgentDecisionService.js +28 -13
  9. package/dist/AgentDecisionService.js.map +1 -1
  10. package/dist/AgentRunner.d.ts +57 -15
  11. package/dist/AgentRunner.d.ts.map +1 -1
  12. package/dist/AgentRunner.js +692 -101
  13. package/dist/AgentRunner.js.map +1 -1
  14. package/dist/ArtifactToolManager.d.ts +134 -39
  15. package/dist/ArtifactToolManager.d.ts.map +1 -1
  16. package/dist/ArtifactToolManager.js +2761 -321
  17. package/dist/ArtifactToolManager.js.map +1 -1
  18. package/dist/GovernedArtifactService.d.ts +367 -0
  19. package/dist/GovernedArtifactService.d.ts.map +1 -0
  20. package/dist/GovernedArtifactService.js +2569 -0
  21. package/dist/GovernedArtifactService.js.map +1 -0
  22. package/dist/PayloadManager.d.ts +46 -0
  23. package/dist/PayloadManager.d.ts.map +1 -1
  24. package/dist/PayloadManager.js +284 -66
  25. package/dist/PayloadManager.js.map +1 -1
  26. package/dist/SkillMarkdownConverter.d.ts.map +1 -1
  27. package/dist/SkillMarkdownConverter.js +4 -2
  28. package/dist/SkillMarkdownConverter.js.map +1 -1
  29. package/dist/agent-context-injector.d.ts +2 -25
  30. package/dist/agent-context-injector.d.ts.map +1 -1
  31. package/dist/agent-context-injector.js +38 -153
  32. package/dist/agent-context-injector.js.map +1 -1
  33. package/dist/agent-instance.d.ts +28 -0
  34. package/dist/agent-instance.d.ts.map +1 -0
  35. package/dist/agent-instance.js +39 -0
  36. package/dist/agent-instance.js.map +1 -0
  37. package/dist/agent-memory-context-builder.d.ts.map +1 -1
  38. package/dist/agent-memory-context-builder.js +46 -42
  39. package/dist/agent-memory-context-builder.js.map +1 -1
  40. package/dist/agent-pre-execution-rag.d.ts.map +1 -1
  41. package/dist/agent-pre-execution-rag.js +5 -0
  42. package/dist/agent-pre-execution-rag.js.map +1 -1
  43. package/dist/agent-run-watchdog.d.ts +38 -6
  44. package/dist/agent-run-watchdog.d.ts.map +1 -1
  45. package/dist/agent-run-watchdog.js +75 -13
  46. package/dist/agent-run-watchdog.js.map +1 -1
  47. package/dist/agent-types/flow-agent-type.d.ts +6 -1
  48. package/dist/agent-types/flow-agent-type.d.ts.map +1 -1
  49. package/dist/agent-types/flow-agent-type.js +30 -7
  50. package/dist/agent-types/flow-agent-type.js.map +1 -1
  51. package/dist/agent-types/loop-agent-type.d.ts +4 -0
  52. package/dist/agent-types/loop-agent-type.d.ts.map +1 -1
  53. package/dist/agent-types/loop-agent-type.js +29 -0
  54. package/dist/agent-types/loop-agent-type.js.map +1 -1
  55. package/dist/artifact-presence-locator.d.ts +132 -0
  56. package/dist/artifact-presence-locator.d.ts.map +1 -0
  57. package/dist/artifact-presence-locator.js +472 -0
  58. package/dist/artifact-presence-locator.js.map +1 -0
  59. package/dist/artifact-tools/CSVToolLibrary.d.ts +2 -2
  60. package/dist/artifact-tools/CSVToolLibrary.d.ts.map +1 -1
  61. package/dist/artifact-tools/CSVToolLibrary.js +41 -14
  62. package/dist/artifact-tools/CSVToolLibrary.js.map +1 -1
  63. package/dist/artifact-tools/DataSnapshotToolLibrary.d.ts +2 -2
  64. package/dist/artifact-tools/DataSnapshotToolLibrary.d.ts.map +1 -1
  65. package/dist/artifact-tools/DataSnapshotToolLibrary.js +53 -21
  66. package/dist/artifact-tools/DataSnapshotToolLibrary.js.map +1 -1
  67. package/dist/artifact-tools/DocumentToolLibrary.d.ts +101 -0
  68. package/dist/artifact-tools/DocumentToolLibrary.d.ts.map +1 -0
  69. package/dist/artifact-tools/DocumentToolLibrary.js +1846 -0
  70. package/dist/artifact-tools/DocumentToolLibrary.js.map +1 -0
  71. package/dist/artifact-tools/DocxToolLibrary.d.ts +2 -4
  72. package/dist/artifact-tools/DocxToolLibrary.d.ts.map +1 -1
  73. package/dist/artifact-tools/DocxToolLibrary.js +42 -30
  74. package/dist/artifact-tools/DocxToolLibrary.js.map +1 -1
  75. package/dist/artifact-tools/ExcelToolLibrary.d.ts +2 -3
  76. package/dist/artifact-tools/ExcelToolLibrary.d.ts.map +1 -1
  77. package/dist/artifact-tools/ExcelToolLibrary.js +105 -49
  78. package/dist/artifact-tools/ExcelToolLibrary.js.map +1 -1
  79. package/dist/artifact-tools/GenericBinaryToolLibrary.d.ts +2 -2
  80. package/dist/artifact-tools/GenericBinaryToolLibrary.d.ts.map +1 -1
  81. package/dist/artifact-tools/GenericBinaryToolLibrary.js +3 -2
  82. package/dist/artifact-tools/GenericBinaryToolLibrary.js.map +1 -1
  83. package/dist/artifact-tools/JSONToolLibrary.d.ts +4 -4
  84. package/dist/artifact-tools/JSONToolLibrary.d.ts.map +1 -1
  85. package/dist/artifact-tools/JSONToolLibrary.js +32 -11
  86. package/dist/artifact-tools/JSONToolLibrary.js.map +1 -1
  87. package/dist/artifact-tools/PDFToolLibrary.d.ts +27 -3
  88. package/dist/artifact-tools/PDFToolLibrary.d.ts.map +1 -1
  89. package/dist/artifact-tools/PDFToolLibrary.js +36 -21
  90. package/dist/artifact-tools/PDFToolLibrary.js.map +1 -1
  91. package/dist/artifact-tools/SearchResultSetToolLibrary.d.ts +2 -2
  92. package/dist/artifact-tools/SearchResultSetToolLibrary.d.ts.map +1 -1
  93. package/dist/artifact-tools/SearchResultSetToolLibrary.js +83 -24
  94. package/dist/artifact-tools/SearchResultSetToolLibrary.js.map +1 -1
  95. package/dist/artifact-tools/SlideDeckToolLibrary.d.ts +50 -0
  96. package/dist/artifact-tools/SlideDeckToolLibrary.d.ts.map +1 -0
  97. package/dist/artifact-tools/SlideDeckToolLibrary.js +1617 -0
  98. package/dist/artifact-tools/SlideDeckToolLibrary.js.map +1 -0
  99. package/dist/artifact-tools/SpreadsheetToolLibrary.d.ts +87 -0
  100. package/dist/artifact-tools/SpreadsheetToolLibrary.d.ts.map +1 -0
  101. package/dist/artifact-tools/SpreadsheetToolLibrary.js +3351 -0
  102. package/dist/artifact-tools/SpreadsheetToolLibrary.js.map +1 -0
  103. package/dist/artifact-tools/TextToolLibrary.d.ts +3 -3
  104. package/dist/artifact-tools/TextToolLibrary.d.ts.map +1 -1
  105. package/dist/artifact-tools/TextToolLibrary.js +34 -24
  106. package/dist/artifact-tools/TextToolLibrary.js.map +1 -1
  107. package/dist/artifact-tools/WhiteboardToolLibrary.d.ts +69 -0
  108. package/dist/artifact-tools/WhiteboardToolLibrary.d.ts.map +1 -0
  109. package/dist/artifact-tools/WhiteboardToolLibrary.js +555 -0
  110. package/dist/artifact-tools/WhiteboardToolLibrary.js.map +1 -0
  111. package/dist/artifact-tools/artifact-comment-suggestion-helper.d.ts +98 -0
  112. package/dist/artifact-tools/artifact-comment-suggestion-helper.d.ts.map +1 -0
  113. package/dist/artifact-tools/artifact-comment-suggestion-helper.js +851 -0
  114. package/dist/artifact-tools/artifact-comment-suggestion-helper.js.map +1 -0
  115. package/dist/artifact-tools/artifact-tool-helpers.d.ts +21 -0
  116. package/dist/artifact-tools/artifact-tool-helpers.d.ts.map +1 -0
  117. package/dist/artifact-tools/artifact-tool-helpers.js +74 -0
  118. package/dist/artifact-tools/artifact-tool-helpers.js.map +1 -0
  119. package/dist/artifact-tools/grepHelper.d.ts +27 -0
  120. package/dist/artifact-tools/grepHelper.d.ts.map +1 -0
  121. package/dist/artifact-tools/grepHelper.js +229 -0
  122. package/dist/artifact-tools/grepHelper.js.map +1 -0
  123. package/dist/artifact-tools/node-vm-safe-regex.d.ts +10 -0
  124. package/dist/artifact-tools/node-vm-safe-regex.d.ts.map +1 -0
  125. package/dist/artifact-tools/node-vm-safe-regex.js +148 -0
  126. package/dist/artifact-tools/node-vm-safe-regex.js.map +1 -0
  127. package/dist/base-agent.d.ts +119 -14
  128. package/dist/base-agent.d.ts.map +1 -1
  129. package/dist/base-agent.js +529 -112
  130. package/dist/base-agent.js.map +1 -1
  131. package/dist/decision-discovery.d.ts +42 -15
  132. package/dist/decision-discovery.d.ts.map +1 -1
  133. package/dist/decision-discovery.js +90 -20
  134. package/dist/decision-discovery.js.map +1 -1
  135. package/dist/index.d.ts +12 -1
  136. package/dist/index.d.ts.map +1 -1
  137. package/dist/index.js +12 -2
  138. package/dist/index.js.map +1 -1
  139. package/dist/memory-decision-uses.d.ts +206 -0
  140. package/dist/memory-decision-uses.d.ts.map +1 -0
  141. package/dist/memory-decision-uses.js +259 -0
  142. package/dist/memory-decision-uses.js.map +1 -0
  143. package/dist/memory-manager-agent.d.ts +66 -6
  144. package/dist/memory-manager-agent.d.ts.map +1 -1
  145. package/dist/memory-manager-agent.js +184 -31
  146. package/dist/memory-manager-agent.js.map +1 -1
  147. package/dist/memory-note-gate.d.ts +12 -9
  148. package/dist/memory-note-gate.d.ts.map +1 -1
  149. package/dist/memory-note-gate.js +16 -11
  150. package/dist/memory-note-gate.js.map +1 -1
  151. package/dist/native-tools/agent-tool-circuit-breaker.d.ts +44 -0
  152. package/dist/native-tools/agent-tool-circuit-breaker.d.ts.map +1 -0
  153. package/dist/native-tools/agent-tool-circuit-breaker.js +71 -0
  154. package/dist/native-tools/agent-tool-circuit-breaker.js.map +1 -0
  155. package/dist/native-tools/agent-tools.d.ts +7 -0
  156. package/dist/native-tools/agent-tools.d.ts.map +1 -1
  157. package/dist/native-tools/agent-tools.js.map +1 -1
  158. package/dist/native-tools/control-tools.d.ts +8 -1
  159. package/dist/native-tools/control-tools.d.ts.map +1 -1
  160. package/dist/native-tools/control-tools.js +38 -5
  161. package/dist/native-tools/control-tools.js.map +1 -1
  162. package/dist/native-tools/framework-tools.d.ts +3 -3
  163. package/dist/native-tools/framework-tools.d.ts.map +1 -1
  164. package/dist/native-tools/framework-tools.js +20 -8
  165. package/dist/native-tools/framework-tools.js.map +1 -1
  166. package/dist/payload-path-keys.d.ts +54 -0
  167. package/dist/payload-path-keys.d.ts.map +1 -0
  168. package/dist/payload-path-keys.js +126 -0
  169. package/dist/payload-path-keys.js.map +1 -0
  170. package/dist/pipeline/template.d.ts +9 -4
  171. package/dist/pipeline/template.d.ts.map +1 -1
  172. package/dist/pipeline/template.js +29 -30
  173. package/dist/pipeline/template.js.map +1 -1
  174. package/dist/realtime/artifact-workspace-channel-server.d.ts +27 -0
  175. package/dist/realtime/artifact-workspace-channel-server.d.ts.map +1 -0
  176. package/dist/realtime/artifact-workspace-channel-server.js +43 -0
  177. package/dist/realtime/artifact-workspace-channel-server.js.map +1 -0
  178. package/dist/realtime/bridge-realtime-session-factory.d.ts +2 -2
  179. package/dist/realtime/bridge-realtime-session-factory.d.ts.map +1 -1
  180. package/dist/realtime/bridge-realtime-session-factory.js +7 -56
  181. package/dist/realtime/bridge-realtime-session-factory.js.map +1 -1
  182. package/dist/realtime/realtime-artifact-helpers.d.ts +37 -0
  183. package/dist/realtime/realtime-artifact-helpers.d.ts.map +1 -0
  184. package/dist/realtime/realtime-artifact-helpers.js +150 -0
  185. package/dist/realtime/realtime-artifact-helpers.js.map +1 -0
  186. package/dist/realtime/realtime-client-session-service.d.ts +87 -17
  187. package/dist/realtime/realtime-client-session-service.d.ts.map +1 -1
  188. package/dist/realtime/realtime-client-session-service.js +259 -39
  189. package/dist/realtime/realtime-client-session-service.js.map +1 -1
  190. package/dist/realtime/realtime-coagent-config.d.ts +22 -7
  191. package/dist/realtime/realtime-coagent-config.d.ts.map +1 -1
  192. package/dist/realtime/realtime-coagent-config.js +20 -22
  193. package/dist/realtime/realtime-coagent-config.js.map +1 -1
  194. package/dist/realtime/realtime-moderator-decision.d.ts +86 -0
  195. package/dist/realtime/realtime-moderator-decision.d.ts.map +1 -0
  196. package/dist/realtime/realtime-moderator-decision.js +131 -0
  197. package/dist/realtime/realtime-moderator-decision.js.map +1 -0
  198. package/dist/realtime/realtime-tool-broker.d.ts +6 -0
  199. package/dist/realtime/realtime-tool-broker.d.ts.map +1 -1
  200. package/dist/realtime/realtime-tool-broker.js +4 -2
  201. package/dist/realtime/realtime-tool-broker.js.map +1 -1
  202. package/dist/realtime/realtime-turn-moderator.d.ts +20 -0
  203. package/dist/realtime/realtime-turn-moderator.d.ts.map +1 -1
  204. package/dist/realtime/realtime-turn-moderator.js +63 -8
  205. package/dist/realtime/realtime-turn-moderator.js.map +1 -1
  206. package/dist/repeated-failing-step.d.ts +50 -0
  207. package/dist/repeated-failing-step.d.ts.map +1 -0
  208. package/dist/repeated-failing-step.js +130 -0
  209. package/dist/repeated-failing-step.js.map +1 -0
  210. package/dist/tsconfig.tsbuildinfo +1 -0
  211. package/package.json +20 -20
@@ -0,0 +1,206 @@
1
+ /**
2
+ * @fileoverview The Memory Manager's closed-set LLM calls, asked as typed decisions: whether a
3
+ * candidate note or example duplicates what is already stored, and whether two stored notes
4
+ * contradict each other.
5
+ *
6
+ * Each use runs through `RunDecisionUse` (`@memberjunction/ai-prompts`) in the mode the run names in
7
+ * `data.memoryDecisionMode` (`Prompt`, `Shadow` or `Decision`), defaulting to
8
+ * {@link MEMORY_DECISION_DEFAULT_MODE}. None of the three has a fitted calibration yet, so the
9
+ * default is `Shadow`: the LLM prompt still decides, and every shadow run records the decision's raw
10
+ * answer next to the prompt's verdict as labelled data for the `fit-decision-calibration` rig. Once a
11
+ * fit ships on the answering model's `ModelConfiguration.Decision.Calibrations` under these use and
12
+ * question keys, `Decision` mode acts on it. Until then, `Decision` mode finds no calibration, treats
13
+ * every answer as unsure and falls back to the prompt, so switching the mode early changes nothing.
14
+ *
15
+ * What stays in code: everything that is not a closed-set judgment. The contradiction prompt also
16
+ * extracted entity triples (only ever counted) and picked which note wins; the winner follows the
17
+ * prompt's own stated rule (recency beyond seven days, then importance, then access count, a tie
18
+ * keeping both), so the decision path applies that rule deterministically
19
+ * ({@link PickContradictionAuthority}) and asks the model only whether the notes conflict.
20
+ *
21
+ * No I/O: calibrations come from the loaded `AIEngine`, so each rule is unit-tested on its own.
22
+ *
23
+ * @module @memberjunction/ai-agents
24
+ */
25
+ import type { DecisionAnswer, LikelihoodQuestion } from '@memberjunction/ai';
26
+ import { type DecisionAnsweringModel, type DecisionCalibrationKey } from '@memberjunction/ai-core-plus';
27
+ import type { DecisionUseMode, ShadowDecisionComparison } from '@memberjunction/ai-prompts';
28
+ /** The mode a Memory Manager run uses for these calls when `data.memoryDecisionMode` names none. */
29
+ export declare const MEMORY_DECISION_DEFAULT_MODE: DecisionUseMode;
30
+ /** The decision use for "does this candidate note duplicate a stored note?". */
31
+ export declare const MEMORY_NOTE_DEDUPE_USE = "memory-note-dedupe";
32
+ /** The decision use for "does this candidate example duplicate a stored example?". */
33
+ export declare const MEMORY_EXAMPLE_DEDUPE_USE = "memory-example-dedupe";
34
+ /** The decision use for "do these two stored notes contradict each other?". */
35
+ export declare const MEMORY_CONTRADICTION_USE = "memory-contradiction";
36
+ /** The question key of both dedupe uses: the candidate adds nothing the stored items do not. */
37
+ export declare const MEMORY_DUPLICATE_QUESTION = "duplicate";
38
+ /** The question key of the contradiction use: the two notes cannot both be true now. */
39
+ export declare const MEMORY_CONTRADICTS_QUESTION = "contradicts";
40
+ /** The calibration keys, one per use. */
41
+ export declare const MEMORY_NOTE_DEDUPE_CALIBRATION_KEY: DecisionCalibrationKey;
42
+ export declare const MEMORY_EXAMPLE_DEDUPE_CALIBRATION_KEY: DecisionCalibrationKey;
43
+ export declare const MEMORY_CONTRADICTION_CALIBRATION_KEY: DecisionCalibrationKey;
44
+ /**
45
+ * The bands a **calibrated** probability is read in, for each yes/no these uses ask. At or above
46
+ * `Yes` the answer is yes; at or below `No` it is no; between them it is unsure and the LLM prompt
47
+ * answers. The gap is deliberate: no use has been measured yet, and an unsure band that sends the
48
+ * middle back to the prompt costs a call where a single threshold would cost a wrong write. Narrow
49
+ * it when a fit and its measurement ship.
50
+ */
51
+ export interface MemoryDecisionBands {
52
+ readonly Yes: number;
53
+ readonly No: number;
54
+ }
55
+ /** The provisional bands for every Memory Manager decision use. */
56
+ export declare const MEMORY_DECISION_BANDS: MemoryDecisionBands;
57
+ /** Characters of a note, an example input or an example output quoted in a decision's state. */
58
+ export declare const MEMORY_DECISION_MAX_TEXT_CHARS = 1500;
59
+ /** Days by which the newer note must postdate the older for recency alone to decide a contradiction. */
60
+ export declare const CONTRADICTION_RECENCY_DAYS = 7;
61
+ /** The dedupe prompt's verdict, the shape both dedupe calls return. */
62
+ export interface MemoryDedupeVerdict {
63
+ shouldAdd: boolean;
64
+ reason: string;
65
+ }
66
+ /** The contradiction verdict the Memory Manager acts on. */
67
+ export interface MemoryContradictionVerdict {
68
+ isContradiction: boolean;
69
+ keepNoteId?: string;
70
+ revokeNoteId?: string;
71
+ reason: string;
72
+ /** Entity triples the LLM prompt extracted; always 0 for a decision's verdict, which extracts none. */
73
+ triplesExtracted: number;
74
+ }
75
+ /** A stored note as the dedupe decision quotes it. */
76
+ export interface MemoryDedupeNote {
77
+ readonly type: string;
78
+ readonly content: string;
79
+ readonly similarity: number;
80
+ }
81
+ /** A stored example as the dedupe decision quotes it. */
82
+ export interface MemoryDedupeExample {
83
+ readonly input: string;
84
+ readonly output: string;
85
+ readonly successScore?: number | null;
86
+ readonly similarity: number;
87
+ }
88
+ /** A note in a contradiction pair: the fields the decision quotes and the authority rule reads. */
89
+ export interface MemoryContradictionNote {
90
+ readonly ID: string;
91
+ readonly Type: string;
92
+ readonly Note: string | null;
93
+ readonly CreatedAt: Date | string | null;
94
+ readonly ImportanceScore: number | null;
95
+ readonly AccessCount: number | null;
96
+ }
97
+ /** A decision's state and its one question. */
98
+ export interface MemoryDecisionRequest {
99
+ readonly State: Record<string, unknown>;
100
+ readonly Questions: Record<string, LikelihoodQuestion>;
101
+ }
102
+ /** How a calibrated yes/no read: its band, and the probabilities behind it. */
103
+ export interface MemoryDecisionReading {
104
+ readonly Band: 'Yes' | 'No' | 'Unsure';
105
+ readonly RawProbability?: number;
106
+ readonly CalibratedProbability?: number;
107
+ readonly Reason: string;
108
+ }
109
+ /**
110
+ * The note dedupe decision: the candidate and its similar stored notes as state, one Likelihood that
111
+ * the candidate is redundant.
112
+ *
113
+ * @param candidate The candidate note.
114
+ * @param similar The stored notes the semantic search found near it.
115
+ */
116
+ export declare function BuildNoteDedupeDecision(candidate: {
117
+ type: string;
118
+ content: string;
119
+ }, similar: ReadonlyArray<MemoryDedupeNote>): MemoryDecisionRequest;
120
+ /**
121
+ * The example dedupe decision: the candidate and its similar stored examples as state, one Likelihood
122
+ * that the candidate is redundant.
123
+ *
124
+ * @param candidate The candidate example.
125
+ * @param similar The stored examples the semantic search found near it.
126
+ */
127
+ export declare function BuildExampleDedupeDecision(candidate: {
128
+ exampleInput: string;
129
+ exampleOutput: string;
130
+ successScore?: number | null;
131
+ }, similar: ReadonlyArray<MemoryDedupeExample>): MemoryDecisionRequest;
132
+ /**
133
+ * The contradiction decision: the two notes as state, one Likelihood that they conflict. Which note
134
+ * wins is not asked: {@link PickContradictionAuthority} applies the rule the prompt states.
135
+ *
136
+ * @param noteA The first note.
137
+ * @param noteB The second note.
138
+ */
139
+ export declare function BuildContradictionDecision(noteA: MemoryContradictionNote, noteB: MemoryContradictionNote): MemoryDecisionRequest;
140
+ /**
141
+ * Reads one Likelihood answer against its calibration and the bands. Unsure when the answer is
142
+ * missing or not a Likelihood, when the answering model has no calibration for this use and question,
143
+ * or when the calibrated probability falls between the bands.
144
+ *
145
+ * @param answer The answer to the use's question.
146
+ * @param key The use and question, for the calibration lookup.
147
+ * @param answeredBy The model that answered.
148
+ * @param bands The yes and no bands (default: {@link MEMORY_DECISION_BANDS}).
149
+ */
150
+ export declare function ReadMemoryDecision(answer: DecisionAnswer | undefined, key: DecisionCalibrationKey, answeredBy: DecisionAnsweringModel, bands?: MemoryDecisionBands): MemoryDecisionReading;
151
+ /**
152
+ * The dedupe verdict from a decision, or null when it is unsure. A redundant candidate is not added.
153
+ *
154
+ * @param answers The decision's answers.
155
+ * @param key The dedupe use's calibration key.
156
+ * @param answeredBy The model that answered.
157
+ */
158
+ export declare function DedupeVerdictFromDecision(answers: Record<string, DecisionAnswer>, key: DecisionCalibrationKey, answeredBy: DecisionAnsweringModel): MemoryDedupeVerdict | null;
159
+ /**
160
+ * The contradiction verdict from a decision, or null when it is unsure. A contradiction names its
161
+ * winner by {@link PickContradictionAuthority}; when that rule ties, the prompt keeps both, so the
162
+ * verdict is no contradiction.
163
+ *
164
+ * @param answers The decision's answers.
165
+ * @param noteA The first note.
166
+ * @param noteB The second note.
167
+ * @param answeredBy The model that answered.
168
+ */
169
+ export declare function ContradictionVerdictFromDecision(answers: Record<string, DecisionAnswer>, noteA: MemoryContradictionNote, noteB: MemoryContradictionNote, answeredBy: DecisionAnsweringModel): MemoryContradictionVerdict | null;
170
+ /** Which note of a contradicting pair is authoritative, and why. */
171
+ export interface ContradictionAuthority {
172
+ readonly Keep: MemoryContradictionNote;
173
+ readonly Revoke: MemoryContradictionNote;
174
+ readonly Reason: string;
175
+ }
176
+ /**
177
+ * The authoritative note of a contradicting pair, by the rule the contradiction prompt states: the
178
+ * newer note when it is more than {@link CONTRADICTION_RECENCY_DAYS} days newer; otherwise the higher
179
+ * importance score; otherwise the higher access count. Null on a tie, which keeps both.
180
+ *
181
+ * @param noteA The first note.
182
+ * @param noteB The second note.
183
+ */
184
+ export declare function PickContradictionAuthority(noteA: MemoryContradictionNote, noteB: MemoryContradictionNote): ContradictionAuthority | null;
185
+ /**
186
+ * How a dedupe decision compares with the prompt's verdict, for a shadow run. The prompt's verdict
187
+ * is the label for a later fit: the question asks "redundant?", so its truth is `!shouldAdd`. Without
188
+ * a calibration the raw probability is compared at 0.5, which is only the agreement figure; the fit
189
+ * reads the raw answer from the run's `Result`.
190
+ *
191
+ * @param answers The decision's answers.
192
+ * @param existing The prompt's verdict.
193
+ * @param key The dedupe use's calibration key.
194
+ * @param answeredBy The model that answered.
195
+ */
196
+ export declare function CompareDedupeDecision(answers: Record<string, DecisionAnswer>, existing: MemoryDedupeVerdict, key: DecisionCalibrationKey, answeredBy: DecisionAnsweringModel): ShadowDecisionComparison;
197
+ /**
198
+ * How a contradiction decision compares with the prompt's verdict, for a shadow run; the label is the
199
+ * prompt's `isContradiction`.
200
+ *
201
+ * @param answers The decision's answers.
202
+ * @param existing The prompt's verdict, or null when the prompt failed (then nothing is compared).
203
+ * @param answeredBy The model that answered.
204
+ */
205
+ export declare function CompareContradictionDecision(answers: Record<string, DecisionAnswer>, existing: MemoryContradictionVerdict | null, answeredBy: DecisionAnsweringModel): ShadowDecisionComparison;
206
+ //# sourceMappingURL=memory-decision-uses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-decision-uses.d.ts","sourceRoot":"","sources":["../src/memory-decision-uses.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAEH,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC9B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAE5F,oGAAoG;AACpG,eAAO,MAAM,4BAA4B,EAAE,eAA0B,CAAC;AAEtE,gFAAgF;AAChF,eAAO,MAAM,sBAAsB,uBAAuB,CAAC;AAE3D,sFAAsF;AACtF,eAAO,MAAM,yBAAyB,0BAA0B,CAAC;AAEjE,+EAA+E;AAC/E,eAAO,MAAM,wBAAwB,yBAAyB,CAAC;AAE/D,gGAAgG;AAChG,eAAO,MAAM,yBAAyB,cAAc,CAAC;AAErD,wFAAwF;AACxF,eAAO,MAAM,2BAA2B,gBAAgB,CAAC;AAEzD,yCAAyC;AACzC,eAAO,MAAM,kCAAkC,EAAE,sBAA4G,CAAC;AAC9J,eAAO,MA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,EAAE,0BAA0B,GAAG,IAAI,EAC3C,UAAU,EAAE,sBAAsB,GACnC,wBAAwB,CAM1B"}
@@ -0,0 +1,259 @@
1
+ /**
2
+ * @fileoverview The Memory Manager's closed-set LLM calls, asked as typed decisions: whether a
3
+ * candidate note or example duplicates what is already stored, and whether two stored notes
4
+ * contradict each other.
5
+ *
6
+ * Each use runs through `RunDecisionUse` (`@memberjunction/ai-prompts`) in the mode the run names in
7
+ * `data.memoryDecisionMode` (`Prompt`, `Shadow` or `Decision`), defaulting to
8
+ * {@link MEMORY_DECISION_DEFAULT_MODE}. None of the three has a fitted calibration yet, so the
9
+ * default is `Shadow`: the LLM prompt still decides, and every shadow run records the decision's raw
10
+ * answer next to the prompt's verdict as labelled data for the `fit-decision-calibration` rig. Once a
11
+ * fit ships on the answering model's `ModelConfiguration.Decision.Calibrations` under these use and
12
+ * question keys, `Decision` mode acts on it. Until then, `Decision` mode finds no calibration, treats
13
+ * every answer as unsure and falls back to the prompt, so switching the mode early changes nothing.
14
+ *
15
+ * What stays in code: everything that is not a closed-set judgment. The contradiction prompt also
16
+ * extracted entity triples (only ever counted) and picked which note wins; the winner follows the
17
+ * prompt's own stated rule (recency beyond seven days, then importance, then access count, a tie
18
+ * keeping both), so the decision path applies that rule deterministically
19
+ * ({@link PickContradictionAuthority}) and asks the model only whether the notes conflict.
20
+ *
21
+ * No I/O: calibrations come from the loaded `AIEngine`, so each rule is unit-tested on its own.
22
+ *
23
+ * @module @memberjunction/ai-agents
24
+ */
25
+ import { DescribeAnsweringModel } from '@memberjunction/ai-core-plus';
26
+ import { AIEngine } from '@memberjunction/aiengine';
27
+ /** The mode a Memory Manager run uses for these calls when `data.memoryDecisionMode` names none. */
28
+ export const MEMORY_DECISION_DEFAULT_MODE = 'Shadow';
29
+ /** The decision use for "does this candidate note duplicate a stored note?". */
30
+ export const MEMORY_NOTE_DEDUPE_USE = 'memory-note-dedupe';
31
+ /** The decision use for "does this candidate example duplicate a stored example?". */
32
+ export const MEMORY_EXAMPLE_DEDUPE_USE = 'memory-example-dedupe';
33
+ /** The decision use for "do these two stored notes contradict each other?". */
34
+ export const MEMORY_CONTRADICTION_USE = 'memory-contradiction';
35
+ /** The question key of both dedupe uses: the candidate adds nothing the stored items do not. */
36
+ export const MEMORY_DUPLICATE_QUESTION = 'duplicate';
37
+ /** The question key of the contradiction use: the two notes cannot both be true now. */
38
+ export const MEMORY_CONTRADICTS_QUESTION = 'contradicts';
39
+ /** The calibration keys, one per use. */
40
+ export const MEMORY_NOTE_DEDUPE_CALIBRATION_KEY = Object.freeze({ Use: MEMORY_NOTE_DEDUPE_USE, Question: MEMORY_DUPLICATE_QUESTION });
41
+ export const MEMORY_EXAMPLE_DEDUPE_CALIBRATION_KEY = Object.freeze({ Use: MEMORY_EXAMPLE_DEDUPE_USE, Question: MEMORY_DUPLICATE_QUESTION });
42
+ export const MEMORY_CONTRADICTION_CALIBRATION_KEY = Object.freeze({ Use: MEMORY_CONTRADICTION_USE, Question: MEMORY_CONTRADICTS_QUESTION });
43
+ /** The provisional bands for every Memory Manager decision use. */
44
+ export const MEMORY_DECISION_BANDS = Object.freeze({ Yes: 0.7, No: 0.3 });
45
+ /** Characters of a note, an example input or an example output quoted in a decision's state. */
46
+ export const MEMORY_DECISION_MAX_TEXT_CHARS = 1500;
47
+ /** Days by which the newer note must postdate the older for recency alone to decide a contradiction. */
48
+ export const CONTRADICTION_RECENCY_DAYS = 7;
49
+ const NOTE_DUPLICATE_INSTRUCTIONS = 'The candidate note is redundant: an agent holding only the existing notes would act exactly as it would with the candidate added (the same advice, tools, constraints and assumptions about the user). Rewording, reframing, added justification or backstory do not make it different; a genuinely broader or narrower scope, a different tool, domain, constraint or fact does.';
50
+ const EXAMPLE_DUPLICATE_INSTRUCTIONS = 'The candidate example adds nothing the existing examples do not already show: it repeats a pattern they cover, as a minor variation or at lower quality. It is not redundant when it shows a different aspect, edge case or approach, or a clearly better response.';
51
+ const CONTRADICTS_INSTRUCTIONS = 'Note A and note B cannot both be true now: they assert different values for the same attribute of the same subject, or one states a changed policy or practice that the other contradicts. Complementary facts, different attributes, similar wording about different things, and a one-off exception to a stated policy are not contradictions.';
52
+ /** Text capped for a decision's state. */
53
+ function cap(text) {
54
+ return (text ?? '').slice(0, MEMORY_DECISION_MAX_TEXT_CHARS);
55
+ }
56
+ /**
57
+ * The note dedupe decision: the candidate and its similar stored notes as state, one Likelihood that
58
+ * the candidate is redundant.
59
+ *
60
+ * @param candidate The candidate note.
61
+ * @param similar The stored notes the semantic search found near it.
62
+ */
63
+ export function BuildNoteDedupeDecision(candidate, similar) {
64
+ return {
65
+ State: {
66
+ candidateNote: { type: candidate.type, content: cap(candidate.content) },
67
+ existingNotes: similar.map(n => ({ type: n.type, content: cap(n.content), similarity: roundSimilarity(n.similarity) }))
68
+ },
69
+ Questions: { [MEMORY_DUPLICATE_QUESTION]: { Kind: 'Likelihood', Instructions: NOTE_DUPLICATE_INSTRUCTIONS } }
70
+ };
71
+ }
72
+ /**
73
+ * The example dedupe decision: the candidate and its similar stored examples as state, one Likelihood
74
+ * that the candidate is redundant.
75
+ *
76
+ * @param candidate The candidate example.
77
+ * @param similar The stored examples the semantic search found near it.
78
+ */
79
+ export function BuildExampleDedupeDecision(candidate, similar) {
80
+ return {
81
+ State: {
82
+ candidateExample: { input: cap(candidate.exampleInput), output: cap(candidate.exampleOutput), successScore: candidate.successScore ?? null },
83
+ existingExamples: similar.map(e => ({ input: cap(e.input), output: cap(e.output), successScore: e.successScore ?? null, similarity: roundSimilarity(e.similarity) }))
84
+ },
85
+ Questions: { [MEMORY_DUPLICATE_QUESTION]: { Kind: 'Likelihood', Instructions: EXAMPLE_DUPLICATE_INSTRUCTIONS } }
86
+ };
87
+ }
88
+ /**
89
+ * The contradiction decision: the two notes as state, one Likelihood that they conflict. Which note
90
+ * wins is not asked: {@link PickContradictionAuthority} applies the rule the prompt states.
91
+ *
92
+ * @param noteA The first note.
93
+ * @param noteB The second note.
94
+ */
95
+ export function BuildContradictionDecision(noteA, noteB) {
96
+ return {
97
+ State: { noteA: contradictionNoteState(noteA), noteB: contradictionNoteState(noteB) },
98
+ Questions: { [MEMORY_CONTRADICTS_QUESTION]: { Kind: 'Likelihood', Instructions: CONTRADICTS_INSTRUCTIONS } }
99
+ };
100
+ }
101
+ function contradictionNoteState(note) {
102
+ return { type: note.Type, content: cap(note.Note), importanceScore: note.ImportanceScore ?? null, accessCount: note.AccessCount ?? 0 };
103
+ }
104
+ function roundSimilarity(similarity) {
105
+ return Math.round(similarity * 100) / 100;
106
+ }
107
+ /**
108
+ * Reads one Likelihood answer against its calibration and the bands. Unsure when the answer is
109
+ * missing or not a Likelihood, when the answering model has no calibration for this use and question,
110
+ * or when the calibrated probability falls between the bands.
111
+ *
112
+ * @param answer The answer to the use's question.
113
+ * @param key The use and question, for the calibration lookup.
114
+ * @param answeredBy The model that answered.
115
+ * @param bands The yes and no bands (default: {@link MEMORY_DECISION_BANDS}).
116
+ */
117
+ export function ReadMemoryDecision(answer, key, answeredBy, bands = MEMORY_DECISION_BANDS) {
118
+ const raw = answer?.Kind === 'Likelihood' && typeof answer.Probability === 'number' && Number.isFinite(answer.Probability)
119
+ ? answer.Probability
120
+ : undefined;
121
+ if (raw === undefined) {
122
+ return { Band: 'Unsure', Reason: `No Likelihood answer to '${key.Question}'` };
123
+ }
124
+ const calibrated = AIEngine.Instance.CalibrateDecisionProbability(key, raw, answeredBy);
125
+ if (calibrated === null) {
126
+ return { Band: 'Unsure', RawProbability: raw, Reason: `${DescribeAnsweringModel(answeredBy)} has no '${key.Use}' calibration` };
127
+ }
128
+ const band = calibrated >= bands.Yes ? 'Yes' : calibrated <= bands.No ? 'No' : 'Unsure';
129
+ return { Band: band, RawProbability: raw, CalibratedProbability: calibrated, Reason: `calibrated '${key.Question}' ${calibrated.toFixed(4)} (${band})` };
130
+ }
131
+ /**
132
+ * The dedupe verdict from a decision, or null when it is unsure. A redundant candidate is not added.
133
+ *
134
+ * @param answers The decision's answers.
135
+ * @param key The dedupe use's calibration key.
136
+ * @param answeredBy The model that answered.
137
+ */
138
+ export function DedupeVerdictFromDecision(answers, key, answeredBy) {
139
+ const reading = ReadMemoryDecision(answers[key.Question], key, answeredBy);
140
+ if (reading.Band === 'Unsure') {
141
+ return null;
142
+ }
143
+ return { shouldAdd: reading.Band === 'No', reason: `decision: ${reading.Reason}` };
144
+ }
145
+ /**
146
+ * The contradiction verdict from a decision, or null when it is unsure. A contradiction names its
147
+ * winner by {@link PickContradictionAuthority}; when that rule ties, the prompt keeps both, so the
148
+ * verdict is no contradiction.
149
+ *
150
+ * @param answers The decision's answers.
151
+ * @param noteA The first note.
152
+ * @param noteB The second note.
153
+ * @param answeredBy The model that answered.
154
+ */
155
+ export function ContradictionVerdictFromDecision(answers, noteA, noteB, answeredBy) {
156
+ const reading = ReadMemoryDecision(answers[MEMORY_CONTRADICTS_QUESTION], MEMORY_CONTRADICTION_CALIBRATION_KEY, answeredBy);
157
+ if (reading.Band === 'Unsure') {
158
+ return null;
159
+ }
160
+ if (reading.Band === 'No') {
161
+ return { isContradiction: false, reason: `decision: ${reading.Reason}`, triplesExtracted: 0 };
162
+ }
163
+ const authority = PickContradictionAuthority(noteA, noteB);
164
+ if (!authority) {
165
+ return { isContradiction: false, reason: `decision: ${reading.Reason}; recency, importance and access count tie, so both are kept`, triplesExtracted: 0 };
166
+ }
167
+ return {
168
+ isContradiction: true,
169
+ keepNoteId: authority.Keep.ID,
170
+ revokeNoteId: authority.Revoke.ID,
171
+ reason: `decision: ${reading.Reason}; ${authority.Reason}`,
172
+ triplesExtracted: 0
173
+ };
174
+ }
175
+ /**
176
+ * The authoritative note of a contradicting pair, by the rule the contradiction prompt states: the
177
+ * newer note when it is more than {@link CONTRADICTION_RECENCY_DAYS} days newer; otherwise the higher
178
+ * importance score; otherwise the higher access count. Null on a tie, which keeps both.
179
+ *
180
+ * @param noteA The first note.
181
+ * @param noteB The second note.
182
+ */
183
+ export function PickContradictionAuthority(noteA, noteB) {
184
+ const ageGapDays = (timeOf(noteB) - timeOf(noteA)) / 86_400_000;
185
+ if (Number.isFinite(ageGapDays) && Math.abs(ageGapDays) > CONTRADICTION_RECENCY_DAYS) {
186
+ return ageGapDays > 0
187
+ ? { Keep: noteB, Revoke: noteA, Reason: 'note B is more than 7 days newer' }
188
+ : { Keep: noteA, Revoke: noteB, Reason: 'note A is more than 7 days newer' };
189
+ }
190
+ const byImportance = compareSignal(noteA.ImportanceScore, noteB.ImportanceScore, 'importance score');
191
+ if (byImportance) {
192
+ return byImportance(noteA, noteB);
193
+ }
194
+ const byAccess = compareSignal(noteA.AccessCount, noteB.AccessCount, 'access count');
195
+ return byAccess ? byAccess(noteA, noteB) : null;
196
+ }
197
+ function timeOf(note) {
198
+ if (!note.CreatedAt) {
199
+ return Number.NaN;
200
+ }
201
+ return note.CreatedAt instanceof Date ? note.CreatedAt.getTime() : Date.parse(note.CreatedAt);
202
+ }
203
+ /** A picker for the higher of two signals, or null when they are equal or either is missing. */
204
+ function compareSignal(a, b, label) {
205
+ if (typeof a !== 'number' || typeof b !== 'number' || !Number.isFinite(a) || !Number.isFinite(b) || a === b) {
206
+ return null;
207
+ }
208
+ return a > b
209
+ ? (noteA, noteB) => ({ Keep: noteA, Revoke: noteB, Reason: `note A has the higher ${label}` })
210
+ : (noteA, noteB) => ({ Keep: noteB, Revoke: noteA, Reason: `note B has the higher ${label}` });
211
+ }
212
+ /**
213
+ * How a dedupe decision compares with the prompt's verdict, for a shadow run. The prompt's verdict
214
+ * is the label for a later fit: the question asks "redundant?", so its truth is `!shouldAdd`. Without
215
+ * a calibration the raw probability is compared at 0.5, which is only the agreement figure; the fit
216
+ * reads the raw answer from the run's `Result`.
217
+ *
218
+ * @param answers The decision's answers.
219
+ * @param existing The prompt's verdict.
220
+ * @param key The dedupe use's calibration key.
221
+ * @param answeredBy The model that answered.
222
+ */
223
+ export function CompareDedupeDecision(answers, existing, key, answeredBy) {
224
+ return compareYesNo(answers, !existing.shouldAdd, key, answeredBy, existing.shouldAdd ? 'LLM added it' : 'LLM rejected it as a duplicate');
225
+ }
226
+ /**
227
+ * How a contradiction decision compares with the prompt's verdict, for a shadow run; the label is the
228
+ * prompt's `isContradiction`.
229
+ *
230
+ * @param answers The decision's answers.
231
+ * @param existing The prompt's verdict, or null when the prompt failed (then nothing is compared).
232
+ * @param answeredBy The model that answered.
233
+ */
234
+ export function CompareContradictionDecision(answers, existing, answeredBy) {
235
+ if (!existing) {
236
+ return { Agreed: false, Summary: 'the LLM prompt gave no verdict to compare with', Details: { Question: MEMORY_CONTRADICTS_QUESTION } };
237
+ }
238
+ return compareYesNo(answers, existing.isContradiction, MEMORY_CONTRADICTION_CALIBRATION_KEY, answeredBy, existing.isContradiction ? 'LLM found a contradiction' : 'LLM found none');
239
+ }
240
+ /** Compares one yes/no answer with the prompt's yes/no. */
241
+ function compareYesNo(answers, existingYes, key, answeredBy, existingSummary) {
242
+ const reading = ReadMemoryDecision(answers[key.Question], key, answeredBy);
243
+ const decisionYes = reading.CalibratedProbability !== undefined
244
+ ? reading.Band === 'Yes' ? true : reading.Band === 'No' ? false : null
245
+ : reading.RawProbability !== undefined ? reading.RawProbability >= 0.5 : null;
246
+ const decisionSummary = decisionYes === null ? `decision unsure (${reading.Reason})` : `decision said ${decisionYes ? 'yes' : 'no'} to '${key.Question}'`;
247
+ return {
248
+ Agreed: decisionYes === existingYes,
249
+ Summary: `${decisionSummary}, ${existingSummary}`,
250
+ Details: {
251
+ Question: key.Question,
252
+ Label: existingYes,
253
+ RawProbability: reading.RawProbability ?? null,
254
+ CalibratedProbability: reading.CalibratedProbability ?? null,
255
+ Band: reading.Band
256
+ }
257
+ };
258
+ }
259
+ //# sourceMappingURL=memory-decision-uses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-decision-uses.js","sourceRoot":"","sources":["../src/memory-decision-uses.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EACH,sBAAsB,EAGzB,MAAM,8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B;KACJ,CAAC;AACN,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { BaseAgent } from './base-agent.js';
2
2
  import { UserInfo } from '@memberjunction/core';
3
3
  import { MJAIAgentNoteEntity } from '@memberjunction/core-entities';
4
- import { AIPromptRunner } from '@memberjunction/ai-prompts';
4
+ import { AIPromptRunner, type ShadowDecisionRunner } from '@memberjunction/ai-prompts';
5
5
  import { ExecuteAgentParams, AgentConfiguration, BaseAgentNextStep, MJAIPromptEntityExtended, MJAIAgentRunStepEntityExtended } from '@memberjunction/ai-core-plus';
6
6
  /** Per-cluster verification result, aggregated into a phase-level observability step. */
7
7
  interface ConsolidationVerificationResult {
@@ -66,8 +66,19 @@ export declare class MemoryManagerAgent extends BaseAgent {
66
66
  private _stepCounter;
67
67
  /** Context user for step operations */
68
68
  private _contextUser;
69
- /** Flag to enable typed decision gate instead of self-confidence threshold */
69
+ /**
70
+ * Whether the typed decision gate may replace the self-confidence threshold. On by default; it
71
+ * still needs the master switch ({@link DecisionsEnabled}), and a run turns it off with
72
+ * `data.enableDecisionGate: false`.
73
+ */
70
74
  private _enableDecisionGate;
75
+ /**
76
+ * How the run answers its dedupe and contradiction calls (`data.memoryDecisionMode`), see
77
+ * {@link MEMORY_DECISION_DEFAULT_MODE}.
78
+ */
79
+ private _memoryDecisionMode;
80
+ /** The run's execution scope (keys, configuration, credential scope), passed to every decision call */
81
+ private _memoryDecisionScope;
71
82
  /**
72
83
  * The run's merged agent-type prompt params, read when the run starts. They carry the master
73
84
  * switch for decision-model use ({@link DecisionsEnabled}), which the note gate needs.
@@ -76,10 +87,10 @@ export declare class MemoryManagerAgent extends BaseAgent {
76
87
  /** The run's cancellation signal, passed to the decision gate's calls */
77
88
  private _cancellationToken;
78
89
  /**
79
- * Whether the typed decision gate is enabled for filtering extracted memory notes.
80
- * When false (default), uses the self-reported confidence filter (confidence >= 80).
81
- * The gate also needs the master switch: the run's agent-type prompt params must set
82
- * `decisionsEnabled: true` ({@link DecisionsEnabled}), or the confidence filter is used.
90
+ * Whether the typed decision gate is enabled for filtering extracted memory notes. True by
91
+ * default. When false, or when the master switch is off (the run's agent-type prompt params must
92
+ * set `decisionsEnabled: true`, {@link DecisionsEnabled}), the self-reported confidence filter
93
+ * (confidence >= 80) is used.
83
94
  */
84
95
  get EnableDecisionGate(): boolean;
85
96
  set EnableDecisionGate(value: boolean);
@@ -278,6 +289,49 @@ export declare class MemoryManagerAgent extends BaseAgent {
278
289
  * neighbors. Returns the decision plus reason string — callers handle logging.
279
290
  */
280
291
  private runDedupePromptForCandidate;
292
+ /**
293
+ * Whether a candidate note adds to its similar stored notes, answered in the run's memory decision
294
+ * mode: by the dedupe prompt, by the prompt with a decision recorded beside it (`Shadow`), or by a
295
+ * calibrated decision that falls back to the prompt when unsure (`Decision`). Fails closed as the
296
+ * prompt does: no path adds a note on a failure.
297
+ */
298
+ private decideNoteDedupe;
299
+ /**
300
+ * Whether a candidate example adds to its similar stored examples, answered in the run's memory
301
+ * decision mode, as {@link decideNoteDedupe} answers it for notes.
302
+ */
303
+ private decideExampleDedupe;
304
+ /**
305
+ * Invoke the example dedupe LLM prompt for one candidate against its similar stored examples. A
306
+ * failed or unreadable call skips the example.
307
+ */
308
+ private runExampleDedupePrompt;
309
+ /**
310
+ * Answers one Memory Manager closed-set call through `RunDecisionUse`, in the run's mode. The
311
+ * decision is built from the run's decision prompt and execution scope, and asked only in `Shadow`
312
+ * and `Decision` modes.
313
+ */
314
+ private runMemoryDecisionUse;
315
+ /**
316
+ * The mode the run's dedupe and contradiction calls use: the configured `data.memoryDecisionMode`,
317
+ * or `Prompt` when the master switch for decision-model use is off ({@link DecisionsEnabled}),
318
+ * since a shadow decision is a decision call too.
319
+ */
320
+ private effectiveMemoryDecisionMode;
321
+ /** A Memory Manager decision as the runner takes it, or null when the decision prompt is missing. */
322
+ private buildMemoryDecision;
323
+ /**
324
+ * The runner `RunDecisionUse` asks the Memory Manager's decisions with, or undefined for a new
325
+ * `AIDecisionRunner`. An override point for tests and for hosts that route decisions elsewhere.
326
+ */
327
+ protected CreateMemoryDecisionRunner(): ShadowDecisionRunner | undefined;
328
+ /** The run's decision prompt: its agent-type prompt params' `decisionPromptName`, else `Default Decision`. */
329
+ private decisionPromptName;
330
+ /**
331
+ * The run's execution scope for its decision calls: the scope `BaseAgent` recorded for the run,
332
+ * or, when this run did not start through `Execute`, the same scope built from its params.
333
+ */
334
+ private memoryDecisionScope;
281
335
  /**
282
336
  * Populate userId and sourceAgentRunId on approved notes from the source
283
337
  * conversation's context. Only fills fields the LLM didn't already set.
@@ -451,6 +505,12 @@ export declare class MemoryManagerAgent extends BaseAgent {
451
505
  private detectAndResolveContradictions;
452
506
  /** Build unique candidate pairs of semantically similar notes for contradiction analysis. */
453
507
  private buildContradictionCandidatePairs;
508
+ /**
509
+ * Whether two stored notes contradict each other, answered in the run's memory decision mode. The
510
+ * decision answers only whether they conflict; the winner follows the prompt's own stated rule
511
+ * (`PickContradictionAuthority`). A failed prompt still skips the pair.
512
+ */
513
+ private decideContradiction;
454
514
  /** Evaluate a single note pair for contradiction using the LLM prompt. */
455
515
  private evaluateContradictionPair;
456
516
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"memory-manager-agent.d.ts","sourceRoot":"","sources":["../src/memory-manager-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAA0E,MAAM,sBAAsB,CAAC;AACxH,OAAO,EAEH,mBAAmB,EAKtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,cAAc,EAAuB,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAGH,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EAEjB,wBAAwB,EACxB,8BAA8B,EAGjC,MAAM,8BAA8B,CAAC;AA8KtC,yFAAyF;AACzF,UAAU,+BAA+B;IACrC,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B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