@memberjunction/core-entities-server 6.3.0-edge.0 → 6.3.0-edge.2

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 (200) hide show
  1. package/dist/custom/AgentChannelConversationDriver.server.d.ts +87 -0
  2. package/dist/custom/AgentChannelConversationDriver.server.d.ts.map +1 -0
  3. package/dist/custom/AgentChannelConversationDriver.server.js +216 -0
  4. package/dist/custom/AgentChannelConversationDriver.server.js.map +1 -0
  5. package/dist/custom/AnchoredConversationReadSecurityHook.d.ts +1 -0
  6. package/dist/custom/AnchoredConversationReadSecurityHook.d.ts.map +1 -1
  7. package/dist/custom/AnchoredConversationReadSecurityHook.js +23 -10
  8. package/dist/custom/AnchoredConversationReadSecurityHook.js.map +1 -1
  9. package/dist/custom/ArtifactSecurityHookHelpers.d.ts +223 -0
  10. package/dist/custom/ArtifactSecurityHookHelpers.d.ts.map +1 -0
  11. package/dist/custom/ArtifactSecurityHookHelpers.js +1402 -0
  12. package/dist/custom/ArtifactSecurityHookHelpers.js.map +1 -0
  13. package/dist/custom/AudienceNamedPersonAgentRequestService.d.ts +25 -0
  14. package/dist/custom/AudienceNamedPersonAgentRequestService.d.ts.map +1 -0
  15. package/dist/custom/AudienceNamedPersonAgentRequestService.js +304 -0
  16. package/dist/custom/AudienceNamedPersonAgentRequestService.js.map +1 -0
  17. package/dist/custom/ConversationDetailWritePermissionProvider.d.ts +113 -0
  18. package/dist/custom/ConversationDetailWritePermissionProvider.d.ts.map +1 -0
  19. package/dist/custom/ConversationDetailWritePermissionProvider.js +200 -0
  20. package/dist/custom/ConversationDetailWritePermissionProvider.js.map +1 -0
  21. package/dist/custom/ConversationReadSecurityHook.d.ts +61 -0
  22. package/dist/custom/ConversationReadSecurityHook.d.ts.map +1 -0
  23. package/dist/custom/ConversationReadSecurityHook.js +587 -0
  24. package/dist/custom/ConversationReadSecurityHook.js.map +1 -0
  25. package/dist/custom/MJAIAgentEntityServer.server.d.ts +80 -34
  26. package/dist/custom/MJAIAgentEntityServer.server.d.ts.map +1 -1
  27. package/dist/custom/MJAIAgentEntityServer.server.js +383 -43
  28. package/dist/custom/MJAIAgentEntityServer.server.js.map +1 -1
  29. package/dist/custom/MJAIAgentPersonaEntityServer.server.d.ts +23 -0
  30. package/dist/custom/MJAIAgentPersonaEntityServer.server.d.ts.map +1 -0
  31. package/dist/custom/MJAIAgentPersonaEntityServer.server.js +93 -0
  32. package/dist/custom/MJAIAgentPersonaEntityServer.server.js.map +1 -0
  33. package/dist/custom/MJAIAgentUserPolicyEntityServer.server.d.ts +24 -13
  34. package/dist/custom/MJAIAgentUserPolicyEntityServer.server.d.ts.map +1 -1
  35. package/dist/custom/MJAIAgentUserPolicyEntityServer.server.js +167 -24
  36. package/dist/custom/MJAIAgentUserPolicyEntityServer.server.js.map +1 -1
  37. package/dist/custom/MJAIBridgeAgentIdentityEntityServer.server.js +2 -2
  38. package/dist/custom/MJAIBridgeAgentIdentityEntityServer.server.js.map +1 -1
  39. package/dist/custom/MJArtifactEntityServer.server.d.ts +38 -0
  40. package/dist/custom/MJArtifactEntityServer.server.d.ts.map +1 -0
  41. package/dist/custom/MJArtifactEntityServer.server.js +436 -0
  42. package/dist/custom/MJArtifactEntityServer.server.js.map +1 -0
  43. package/dist/custom/MJArtifactGuestShareLinkEntityServer.server.d.ts +32 -0
  44. package/dist/custom/MJArtifactGuestShareLinkEntityServer.server.d.ts.map +1 -0
  45. package/dist/custom/MJArtifactGuestShareLinkEntityServer.server.js +434 -0
  46. package/dist/custom/MJArtifactGuestShareLinkEntityServer.server.js.map +1 -0
  47. package/dist/custom/MJArtifactPermissionEntityServer.server.d.ts +18 -0
  48. package/dist/custom/MJArtifactPermissionEntityServer.server.d.ts.map +1 -0
  49. package/dist/custom/MJArtifactPermissionEntityServer.server.js +194 -0
  50. package/dist/custom/MJArtifactPermissionEntityServer.server.js.map +1 -0
  51. package/dist/custom/MJArtifactVersionAttributeEntityServer.server.d.ts +22 -0
  52. package/dist/custom/MJArtifactVersionAttributeEntityServer.server.d.ts.map +1 -0
  53. package/dist/custom/MJArtifactVersionAttributeEntityServer.server.js +312 -0
  54. package/dist/custom/MJArtifactVersionAttributeEntityServer.server.js.map +1 -0
  55. package/dist/custom/MJArtifactVersionEntityServer.server.d.ts +76 -12
  56. package/dist/custom/MJArtifactVersionEntityServer.server.d.ts.map +1 -1
  57. package/dist/custom/MJArtifactVersionEntityServer.server.js +934 -55
  58. package/dist/custom/MJArtifactVersionEntityServer.server.js.map +1 -1
  59. package/dist/custom/MJArtifactWorkingStateEntityServer.server.d.ts +42 -0
  60. package/dist/custom/MJArtifactWorkingStateEntityServer.server.d.ts.map +1 -0
  61. package/dist/custom/MJArtifactWorkingStateEntityServer.server.js +547 -0
  62. package/dist/custom/MJArtifactWorkingStateEntityServer.server.js.map +1 -0
  63. package/dist/custom/MJCollectionArtifactEntityServer.server.d.ts +36 -0
  64. package/dist/custom/MJCollectionArtifactEntityServer.server.d.ts.map +1 -0
  65. package/dist/custom/MJCollectionArtifactEntityServer.server.js +533 -0
  66. package/dist/custom/MJCollectionArtifactEntityServer.server.js.map +1 -0
  67. package/dist/custom/MJCollectionEntityServer.server.d.ts +23 -0
  68. package/dist/custom/MJCollectionEntityServer.server.d.ts.map +1 -0
  69. package/dist/custom/MJCollectionEntityServer.server.js +555 -0
  70. package/dist/custom/MJCollectionEntityServer.server.js.map +1 -0
  71. package/dist/custom/MJCollectionPermissionEntityServer.server.d.ts +18 -0
  72. package/dist/custom/MJCollectionPermissionEntityServer.server.d.ts.map +1 -0
  73. package/dist/custom/MJCollectionPermissionEntityServer.server.js +196 -0
  74. package/dist/custom/MJCollectionPermissionEntityServer.server.js.map +1 -0
  75. package/dist/custom/MJConversationDetailEntityServer.server.d.ts +27 -2
  76. package/dist/custom/MJConversationDetailEntityServer.server.d.ts.map +1 -1
  77. package/dist/custom/MJConversationDetailEntityServer.server.js +300 -4
  78. package/dist/custom/MJConversationDetailEntityServer.server.js.map +1 -1
  79. package/dist/custom/MJConversationEntityServer.server.d.ts +6 -20
  80. package/dist/custom/MJConversationEntityServer.server.d.ts.map +1 -1
  81. package/dist/custom/MJConversationEntityServer.server.js +293 -16
  82. package/dist/custom/MJConversationEntityServer.server.js.map +1 -1
  83. package/dist/custom/MJEntityEntityServer.server.d.ts +9 -0
  84. package/dist/custom/MJEntityEntityServer.server.d.ts.map +1 -1
  85. package/dist/custom/MJEntityEntityServer.server.js +31 -2
  86. package/dist/custom/MJEntityEntityServer.server.js.map +1 -1
  87. package/dist/custom/MJGraphConceptEntityServer.server.d.ts +92 -0
  88. package/dist/custom/MJGraphConceptEntityServer.server.d.ts.map +1 -0
  89. package/dist/custom/MJGraphConceptEntityServer.server.js +203 -0
  90. package/dist/custom/MJGraphConceptEntityServer.server.js.map +1 -0
  91. package/dist/custom/MJGraphEdgeEntityServer.server.d.ts +16 -2
  92. package/dist/custom/MJGraphEdgeEntityServer.server.d.ts.map +1 -1
  93. package/dist/custom/MJGraphEdgeEntityServer.server.js +26 -4
  94. package/dist/custom/MJGraphEdgeEntityServer.server.js.map +1 -1
  95. package/dist/custom/MJListEntityServer.server.d.ts +26 -10
  96. package/dist/custom/MJListEntityServer.server.d.ts.map +1 -1
  97. package/dist/custom/MJListEntityServer.server.js +118 -20
  98. package/dist/custom/MJListEntityServer.server.js.map +1 -1
  99. package/dist/custom/MJMLModelPublishRecordEntityServer.server.d.ts +31 -0
  100. package/dist/custom/MJMLModelPublishRecordEntityServer.server.d.ts.map +1 -0
  101. package/dist/custom/MJMLModelPublishRecordEntityServer.server.js +68 -0
  102. package/dist/custom/MJMLModelPublishRecordEntityServer.server.js.map +1 -0
  103. package/dist/custom/MJMLModelScoringBindingEntityServer.server.d.ts +78 -0
  104. package/dist/custom/MJMLModelScoringBindingEntityServer.server.d.ts.map +1 -0
  105. package/dist/custom/MJMLModelScoringBindingEntityServer.server.js +273 -0
  106. package/dist/custom/MJMLModelScoringBindingEntityServer.server.js.map +1 -0
  107. package/dist/custom/MJMLOutputBindingEntityServer.server.d.ts +18 -0
  108. package/dist/custom/MJMLOutputBindingEntityServer.server.d.ts.map +1 -0
  109. package/dist/custom/MJMLOutputBindingEntityServer.server.js +61 -0
  110. package/dist/custom/MJMLOutputBindingEntityServer.server.js.map +1 -0
  111. package/dist/custom/MJMLPredictionUnitEntityServer.server.d.ts +3 -3
  112. package/dist/custom/MJMLPredictionUnitEntityServer.server.d.ts.map +1 -1
  113. package/dist/custom/MJMLPredictionUnitEntityServer.server.js +4 -4
  114. package/dist/custom/MJMLPredictionUnitEntityServer.server.js.map +1 -1
  115. package/dist/custom/MJProjectEntityServer.server.d.ts +28 -2
  116. package/dist/custom/MJProjectEntityServer.server.d.ts.map +1 -1
  117. package/dist/custom/MJProjectEntityServer.server.js +115 -2
  118. package/dist/custom/MJProjectEntityServer.server.js.map +1 -1
  119. package/dist/custom/MJQueryEntityServer.server.d.ts +41 -4
  120. package/dist/custom/MJQueryEntityServer.server.d.ts.map +1 -1
  121. package/dist/custom/MJQueryEntityServer.server.js +99 -14
  122. package/dist/custom/MJQueryEntityServer.server.js.map +1 -1
  123. package/dist/custom/MJQuerySQLEntityServer.server.d.ts +13 -1
  124. package/dist/custom/MJQuerySQLEntityServer.server.d.ts.map +1 -1
  125. package/dist/custom/MJQuerySQLEntityServer.server.js +37 -3
  126. package/dist/custom/MJQuerySQLEntityServer.server.js.map +1 -1
  127. package/dist/custom/MJResourcePermissionEntityServer.server.d.ts +28 -0
  128. package/dist/custom/MJResourcePermissionEntityServer.server.d.ts.map +1 -0
  129. package/dist/custom/MJResourcePermissionEntityServer.server.js +206 -0
  130. package/dist/custom/MJResourcePermissionEntityServer.server.js.map +1 -0
  131. package/dist/custom/MJScheduledJobEntityServer.server.d.ts +27 -0
  132. package/dist/custom/MJScheduledJobEntityServer.server.d.ts.map +1 -0
  133. package/dist/custom/MJScheduledJobEntityServer.server.js +56 -0
  134. package/dist/custom/MJScheduledJobEntityServer.server.js.map +1 -0
  135. package/dist/custom/MJScopedNotificationConfigEntityServer.server.d.ts +15 -0
  136. package/dist/custom/MJScopedNotificationConfigEntityServer.server.d.ts.map +1 -0
  137. package/dist/custom/MJScopedNotificationConfigEntityServer.server.js +48 -0
  138. package/dist/custom/MJScopedNotificationConfigEntityServer.server.js.map +1 -0
  139. package/dist/custom/MJTagEntityServer.server.d.ts +11 -1
  140. package/dist/custom/MJTagEntityServer.server.d.ts.map +1 -1
  141. package/dist/custom/MJTagEntityServer.server.js +28 -3
  142. package/dist/custom/MJTagEntityServer.server.js.map +1 -1
  143. package/dist/custom/MJUserEntityServer.server.d.ts +2 -1
  144. package/dist/custom/MJUserEntityServer.server.d.ts.map +1 -1
  145. package/dist/custom/MJUserEntityServer.server.js +2 -1
  146. package/dist/custom/MJUserEntityServer.server.js.map +1 -1
  147. package/dist/custom/MJUserRoutineEntityServer.server.d.ts +23 -0
  148. package/dist/custom/MJUserRoutineEntityServer.server.d.ts.map +1 -1
  149. package/dist/custom/MJUserRoutineEntityServer.server.js +320 -3
  150. package/dist/custom/MJUserRoutineEntityServer.server.js.map +1 -1
  151. package/dist/custom/MJUserViewEntityServer.server.d.ts +8 -2
  152. package/dist/custom/MJUserViewEntityServer.server.d.ts.map +1 -1
  153. package/dist/custom/MJUserViewEntityServer.server.js +25 -12
  154. package/dist/custom/MJUserViewEntityServer.server.js.map +1 -1
  155. package/dist/custom/RestrictedFieldCommentClassifier.d.ts +9 -3
  156. package/dist/custom/RestrictedFieldCommentClassifier.d.ts.map +1 -1
  157. package/dist/custom/RestrictedFieldCommentClassifier.js +91 -15
  158. package/dist/custom/RestrictedFieldCommentClassifier.js.map +1 -1
  159. package/dist/custom/RestrictedFieldDecision.d.ts +121 -0
  160. package/dist/custom/RestrictedFieldDecision.d.ts.map +1 -0
  161. package/dist/custom/RestrictedFieldDecision.js +168 -0
  162. package/dist/custom/RestrictedFieldDecision.js.map +1 -0
  163. package/dist/custom/SpreadsheetWorkerEntry.d.ts +25 -0
  164. package/dist/custom/SpreadsheetWorkerEntry.d.ts.map +1 -0
  165. package/dist/custom/SpreadsheetWorkerEntry.js +37 -0
  166. package/dist/custom/SpreadsheetWorkerEntry.js.map +1 -0
  167. package/dist/custom/SpreadsheetWorkerRunner.d.ts +45 -0
  168. package/dist/custom/SpreadsheetWorkerRunner.d.ts.map +1 -0
  169. package/dist/custom/SpreadsheetWorkerRunner.js +243 -0
  170. package/dist/custom/SpreadsheetWorkerRunner.js.map +1 -0
  171. package/dist/custom/approvalStamp.d.ts +19 -3
  172. package/dist/custom/approvalStamp.d.ts.map +1 -1
  173. package/dist/custom/approvalStamp.js +13 -3
  174. package/dist/custom/approvalStamp.js.map +1 -1
  175. package/dist/custom/fieldPermissionDelta.d.ts +15 -1
  176. package/dist/custom/fieldPermissionDelta.d.ts.map +1 -1
  177. package/dist/custom/fieldPermissionDelta.js +28 -7
  178. package/dist/custom/fieldPermissionDelta.js.map +1 -1
  179. package/dist/custom/fieldPermissionReconciler.d.ts +4 -1
  180. package/dist/custom/fieldPermissionReconciler.d.ts.map +1 -1
  181. package/dist/custom/fieldPermissionReconciler.js +4 -2
  182. package/dist/custom/fieldPermissionReconciler.js.map +1 -1
  183. package/dist/custom/graph/GraphFindPathServerOperation.d.ts +24 -0
  184. package/dist/custom/graph/GraphFindPathServerOperation.d.ts.map +1 -0
  185. package/dist/custom/graph/GraphFindPathServerOperation.js +88 -0
  186. package/dist/custom/graph/GraphFindPathServerOperation.js.map +1 -0
  187. package/dist/custom/graph/index.d.ts +2 -0
  188. package/dist/custom/graph/index.d.ts.map +1 -0
  189. package/dist/custom/graph/index.js +2 -0
  190. package/dist/custom/graph/index.js.map +1 -0
  191. package/dist/custom/list-refresh/ListRefreshRoutine.d.ts +40 -0
  192. package/dist/custom/list-refresh/ListRefreshRoutine.d.ts.map +1 -0
  193. package/dist/custom/list-refresh/ListRefreshRoutine.js +114 -0
  194. package/dist/custom/list-refresh/ListRefreshRoutine.js.map +1 -0
  195. package/dist/index.d.ts +24 -0
  196. package/dist/index.d.ts.map +1 -1
  197. package/dist/index.js +33 -0
  198. package/dist/index.js.map +1 -1
  199. package/dist/tsconfig.tsbuildinfo +1 -0
  200. package/package.json +31 -30
@@ -1,22 +1,37 @@
1
1
  import { LogError, LogStatus, RunView, WellKnownUserSource } from '@memberjunction/core';
2
2
  import { AIPromptParams } from '@memberjunction/ai-core-plus';
3
- import { AIPromptRunner } from '@memberjunction/ai-prompts';
4
- import { AIEngine } from '@memberjunction/aiengine';
3
+ import { AIEngineBase } from '@memberjunction/ai-engine-base';
4
+ import { AIDecisionParams, AIPromptRunner, RunDecisionUse } from '@memberjunction/ai-prompts';
5
+ import { GetGlobalObjectStore } from '@memberjunction/global';
5
6
  import { BuildLinkedRecordPrimaryKeyFilter, DetectReferencedRestrictedFieldsDeterministic, MergeRestrictedFieldsIntoAnchorMetadata, ParseConversationAnchorMetadata } from '@memberjunction/core-entities';
6
- let customRestrictedFieldClassifier = null;
7
+ import { AnsweredByOf, BuildRestrictedFieldQuestions, BuildRestrictedFieldState, CompareRestrictedFieldDecision, FlaggedFieldsFromVerdicts, GetRestrictedFieldClassifierDecisionMode, ReadRestrictedFieldVerdicts, RESTRICTED_FIELD_CLASSIFIER_USE } from './RestrictedFieldDecision.js';
8
+ const GLOBAL_KEY_RESTRICTED_FIELD_CLASSIFIER = '___MJ_RESTRICTED_FIELD_LLM_CLASSIFIER_STATE__';
9
+ function getRestrictedFieldClassifierState() {
10
+ const store = GetGlobalObjectStore();
11
+ if (store) {
12
+ const existing = store[GLOBAL_KEY_RESTRICTED_FIELD_CLASSIFIER];
13
+ if (existing && typeof existing === 'object' && 'Callback' in existing) {
14
+ return existing;
15
+ }
16
+ const created = { Callback: null };
17
+ store[GLOBAL_KEY_RESTRICTED_FIELD_CLASSIFIER] = created;
18
+ return created;
19
+ }
20
+ return { Callback: null };
21
+ }
7
22
  /**
8
23
  * Registers (or clears with `null`) a custom semantic classifier callback for detecting
9
24
  * references to FLS-restricted fields in record comments. Used by tests and custom
10
- * enterprise classification policies; when `null`, the default `AIEngine` classifier runs.
25
+ * enterprise classification policies; when `null`, the default `AIEngineBase` classifier runs.
11
26
  */
12
27
  export function RegisterRestrictedFieldLLMClassifier(callback) {
13
- customRestrictedFieldClassifier = callback;
28
+ getRestrictedFieldClassifierState().Callback = callback;
14
29
  }
15
30
  /**
16
31
  * Returns the currently registered custom classifier callback, if any.
17
32
  */
18
33
  export function GetRegisteredRestrictedFieldLLMClassifier() {
19
- return customRestrictedFieldClassifier;
34
+ return getRestrictedFieldClassifierState().Callback;
20
35
  }
21
36
  /**
22
37
  * Inspects a comment (`messageText`) posted on an anchored conversation to detect whether it
@@ -81,7 +96,7 @@ export async function InspectAndStampRestrictedFieldsForComment(params) {
81
96
  const text = (MessageText ?? '').trim();
82
97
  const unmatchedFields = restrictedFields.filter((f) => !detectedSet.has(f.Name));
83
98
  if (!params.SkipLLMStage && text.length > 0 && unmatchedFields.length > 0) {
84
- const llmMatches = await runSemanticRestrictedFieldClassifier(entityInfo, unmatchedFields, text, Conversation.AnchorType, Conversation.AnchorKey, ContextUser);
99
+ const llmMatches = await runSemanticRestrictedFieldClassifier(Provider, entityInfo, unmatchedFields, text, Conversation.AnchorType, Conversation.AnchorKey, ContextUser);
85
100
  for (const fieldName of llmMatches) {
86
101
  detectedSet.add(fieldName);
87
102
  }
@@ -159,7 +174,7 @@ async function loadLinkedRecordRestrictedFieldValues(provider, contextUser, enti
159
174
  }
160
175
  return null;
161
176
  }
162
- async function runSemanticRestrictedFieldClassifier(entityInfo, candidateFields, messageText, anchorType, anchorKey, contextUser) {
177
+ async function runSemanticRestrictedFieldClassifier(provider, entityInfo, candidateFields, messageText, anchorType, anchorKey, contextUser) {
163
178
  const prompt = {
164
179
  EntityName: entityInfo.Name,
165
180
  EntityDisplayName: entityInfo.DisplayNameOrName,
@@ -176,9 +191,10 @@ async function runSemanticRestrictedFieldClassifier(entityInfo, candidateFields,
176
191
  for (const f of candidateFields) {
177
192
  validByLower.set(f.Name.toLowerCase(), f.Name);
178
193
  }
179
- if (customRestrictedFieldClassifier) {
194
+ const customClassifier = GetRegisteredRestrictedFieldLLMClassifier();
195
+ if (customClassifier) {
180
196
  try {
181
- const rawMatches = await customRestrictedFieldClassifier(prompt, contextUser);
197
+ const rawMatches = await customClassifier(prompt, contextUser);
182
198
  return normalizeMatchedFieldNames(rawMatches, validByLower);
183
199
  }
184
200
  catch (error) {
@@ -186,7 +202,7 @@ async function runSemanticRestrictedFieldClassifier(entityInfo, candidateFields,
186
202
  return [];
187
203
  }
188
204
  }
189
- return runDefaultAIEngineRestrictedFieldClassifier(prompt, contextUser, validByLower);
205
+ return runDefaultAIEngineRestrictedFieldClassifier(provider, prompt, contextUser, validByLower);
190
206
  }
191
207
  function normalizeMatchedFieldNames(rawNames, validByLower) {
192
208
  if (!Array.isArray(rawNames)) {
@@ -204,15 +220,64 @@ function normalizeMatchedFieldNames(rawNames, validByLower) {
204
220
  return [...canonical];
205
221
  }
206
222
  const RESTRICTED_FIELD_CLASSIFIER_PROMPT_NAME = 'Anchored Comment Restricted Field Classifier';
207
- async function runDefaultAIEngineRestrictedFieldClassifier(prompt, contextUser, validByLower) {
223
+ /** The decision prompt the semantic stage asks when its mode is `Shadow` or `Decision`. */
224
+ const RESTRICTED_FIELD_DECISION_PROMPT_NAME = 'Default Decision';
225
+ let restrictedFieldDecisionRunner = null;
226
+ /**
227
+ * Sets (or clears with `null`) the decision runner the semantic stage uses. For tests; the default is
228
+ * a new `AIDecisionRunner` per call.
229
+ */
230
+ export function SetRestrictedFieldDecisionRunner(runner) {
231
+ restrictedFieldDecisionRunner = runner;
232
+ }
233
+ /**
234
+ * The default semantic stage: the governed prompt, the decision, or both, as
235
+ * `GetRestrictedFieldClassifierDecisionMode()` says (see `RestrictedFieldDecision.ts`). Every failure
236
+ * of the prompt reads as "nothing flagged", as it always has; a failed or unsure decision falls back
237
+ * to the prompt.
238
+ */
239
+ async function runDefaultAIEngineRestrictedFieldClassifier(provider, prompt, contextUser, validByLower) {
240
+ const aiEngine = AIEngineBase.GetProviderInstance(provider, AIEngineBase);
208
241
  try {
209
- await AIEngine.Instance.Config(false, contextUser);
242
+ await aiEngine.Config(false, contextUser);
210
243
  }
211
244
  catch (error) {
212
245
  LogStatus(`[RestrictedFieldCommentClassifier] AIEngine.Config unavailable; skipping Stage 2 semantic classification: ${error instanceof Error ? error.message : String(error)}`);
213
246
  return [];
214
247
  }
215
- const aiPrompt = AIEngine.Instance.Prompts?.find((p) => p.Name === RESTRICTED_FIELD_CLASSIFIER_PROMPT_NAME && p.Status === 'Active');
248
+ const outcome = await RunDecisionUse({
249
+ Use: RESTRICTED_FIELD_CLASSIFIER_USE,
250
+ Mode: GetRestrictedFieldClassifierDecisionMode(),
251
+ BuildDecision: () => buildRestrictedFieldDecision(aiEngine, prompt, contextUser),
252
+ FromDecision: (run) => {
253
+ const flagged = FlaggedFieldsFromVerdicts(ReadRestrictedFieldVerdicts(prompt, run.Answers, AnsweredByOf(run)));
254
+ return flagged === null ? null : normalizeMatchedFieldNames(flagged, validByLower);
255
+ },
256
+ RunExisting: () => runRestrictedFieldPrompt(aiEngine, prompt, contextUser, validByLower),
257
+ Compare: (answers, existing, run) => CompareRestrictedFieldDecision(ReadRestrictedFieldVerdicts(prompt, answers, AnsweredByOf(run)), existing),
258
+ Runner: restrictedFieldDecisionRunner ?? undefined
259
+ });
260
+ return outcome.Value;
261
+ }
262
+ /**
263
+ * The decision for the semantic stage, asked as the commenting user, or null when there is no
264
+ * active decision prompt or nothing to ask about.
265
+ */
266
+ function buildRestrictedFieldDecision(aiEngine, prompt, contextUser) {
267
+ const decisionPrompt = aiEngine.Prompts?.find((p) => p.Name === RESTRICTED_FIELD_DECISION_PROMPT_NAME && p.Status === 'Active');
268
+ if (!decisionPrompt || prompt.CandidateFields.length === 0) {
269
+ return null;
270
+ }
271
+ const params = new AIDecisionParams();
272
+ params.prompt = decisionPrompt;
273
+ params.contextUser = contextUser;
274
+ params.State = BuildRestrictedFieldState(prompt);
275
+ params.Questions = BuildRestrictedFieldQuestions(prompt);
276
+ return params;
277
+ }
278
+ /** The governed prompt: the semantic stage as it ran before decisions. Any failure flags nothing. */
279
+ async function runRestrictedFieldPrompt(aiEngine, prompt, contextUser, validByLower) {
280
+ const aiPrompt = aiEngine.Prompts?.find((p) => p.Name === RESTRICTED_FIELD_CLASSIFIER_PROMPT_NAME && p.Status === 'Active');
216
281
  if (!aiPrompt) {
217
282
  return [];
218
283
  }
@@ -220,7 +285,18 @@ async function runDefaultAIEngineRestrictedFieldClassifier(prompt, contextUser,
220
285
  const runner = new AIPromptRunner();
221
286
  const params = new AIPromptParams();
222
287
  params.prompt = aiPrompt;
223
- params.data = prompt;
288
+ params.data = {
289
+ EntityName: prompt.EntityName,
290
+ EntityDisplayName: prompt.EntityDisplayName,
291
+ MessageText: prompt.MessageText,
292
+ AnchorType: prompt.AnchorType,
293
+ AnchorKey: prompt.AnchorKey,
294
+ CandidateFields: prompt.CandidateFields.map((f) => ({
295
+ Name: f.Name,
296
+ DisplayName: f.DisplayName,
297
+ Description: f.Description
298
+ }))
299
+ };
224
300
  params.contextUser = contextUser;
225
301
  const execution = await runner.ExecutePrompt(params);
226
302
  if (!execution.success || !execution.result) {
@@ -1 +1 @@
1
- {"version":3,"file":"RestrictedFieldCommentClassifier.js","sourceRoot":"","sources":["../../src/custom/RestrictedFieldCommentClassifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,QAAQ,EACR,SAAS,EACT,OAAO,EAEP,mBAAmB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EACH,iCAAiC,EACjC,6CAA6C,EAC7C,uCAAuC,EACvC,+BAA+B,EAElC,MAAM,+BAA+B,CAAC;AA4BvC,IAAI,+BAA+B,GA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AAG,MAAM,MAAM,CAAC,aAAa,CAAiC,MAAM,CAAC,CAAC;QACrF,IAAI,CAAC,SAAS,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;YAC1C,SAAS,CACL,uDAAuD,uCAAuC,mCAC1F,SAAS,CAAC,YAAY,IAAI,SAC9B,EAAE,CACL,CAAC;YACF,OAAO,EAAE,CAAC;QACd,CAAC;QAED,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,gBAAgB,CAAC;QAC/C,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACtB,OAAO,0BAA0B,CAC7B,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,EAC/D,YAAY,CACf,CAAC;QACN,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,SAAS,CACL,uDAAuD,uCAAuC,YAC1F,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACzD,EAAE,CACL,CAAC;IACN,CAAC;IAED,OAAO,EAAE,CAAC;AACd,CAAC"}
1
+ {"version":3,"file":"RestrictedFieldCommentClassifier.js","sourceRoot":"","sources":["../../src/custom/RestrictedFieldCommentClassifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,QAAQ,EACR,SAAS,EACT,OAAO,EAEP,mBAAmB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,cAAc,EAA6B,MAAM,4BAA4B,CAAC;AACzH,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EACH,iCAAiC,EACjC,6CAA6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AC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,SAAS,CACL,uDAAuD,uCAAuC,YAC1F,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACzD,EAAE,CACL,CAAC;IACN,CAAC;IAED,OAAO,EAAE,CAAC;AACd,CAAC"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * @fileoverview The restricted-field classifier asked as a decision: one Likelihood per candidate
3
+ * field, "does this comment discuss or reveal it?", answered in a single call.
4
+ *
5
+ * This is Stage 2 of {@link InspectAndStampRestrictedFieldsForComment}, the semantic check that runs
6
+ * after the deterministic name match. The existing path is the `Anchored Comment Restricted Field
7
+ * Classifier` prompt; this module is the decision that can replace it, through `RunDecisionUse`:
8
+ * - `Prompt`: only the prompt answers.
9
+ * - `Shadow` (the default): the prompt answers; the decision runs beside it and its run records
10
+ * whether the two flagged the same fields (`RunName = 'Shadow: restricted-field-classifier'`).
11
+ * - `Decision`: a field is flagged when its **calibrated** probability is at or above
12
+ * {@link RESTRICTED_FIELD_DECISION_MIN_PROBABILITY}. An answer from a model with no calibration for
13
+ * this use falls back to the prompt, as a failed decision does.
14
+ *
15
+ * The default stays `Shadow` because no calibration has been fitted for this use yet: the shadow runs
16
+ * are the labelled data for the fit (the `fit-decision-calibration` rig). Switch a deployment to
17
+ * `Decision` only once a fit is in the answering model's `ModelConfiguration.Decision.Calibrations`.
18
+ *
19
+ * Kept apart from the classifier so the question, state and reading rules are unit-tested on their own.
20
+ *
21
+ * @module @memberjunction/core-entities-server
22
+ */
23
+ import type { DecisionAnswer, LikelihoodQuestion } from '@memberjunction/ai';
24
+ import type { DecisionAnsweringModel, DecisionCalibrationKey } from '@memberjunction/ai-core-plus';
25
+ import { type AIDecisionRunResult, type DecisionUseMode, type ShadowDecisionComparison } from '@memberjunction/ai-prompts';
26
+ /** The decision use: names shadow runs and selects the calibration. */
27
+ export declare const RESTRICTED_FIELD_CLASSIFIER_USE = "restricted-field-classifier";
28
+ /** The question every field's Likelihood shares for calibration, whatever its key (`f1`, `f2`, …). */
29
+ export declare const RESTRICTED_FIELD_DECISION_QUESTION = "discusses";
30
+ /** Which calibration the per-field Likelihoods read. */
31
+ export declare const RESTRICTED_FIELD_CALIBRATION_KEY: DecisionCalibrationKey;
32
+ /**
33
+ * The least calibrated probability at which a field is flagged in `Decision` mode.
34
+ *
35
+ * Deliberately low. The cost of the two errors is not symmetric: a missed field leaves a comment
36
+ * about a restricted value readable by people the field rule hides it from, while a false flag only
37
+ * hides one comment from them. So the threshold trades precision for recall. Revisit it with the
38
+ * calibration fit, against the shadow runs' labelled outcomes.
39
+ */
40
+ export declare const RESTRICTED_FIELD_DECISION_MIN_PROBABILITY = 0.2;
41
+ /** The mode used when nothing is configured: `Shadow`, until a calibration is fitted. */
42
+ export declare const RESTRICTED_FIELD_DEFAULT_DECISION_MODE: DecisionUseMode;
43
+ /** The raw probability a shadow comparison reads as "the decision flagged it", since it has no calibration yet. */
44
+ export declare const RESTRICTED_FIELD_SHADOW_RAW_THRESHOLD = 0.5;
45
+ /**
46
+ * Sets how the restricted-field classifier's semantic stage is answered. MJServer calls it at startup
47
+ * from `decisions.restrictedFieldClassifier` in its config. A value that is not a mode (case-insensitive)
48
+ * restores the default, `Shadow`.
49
+ *
50
+ * @param mode `Prompt`, `Shadow` or `Decision`.
51
+ */
52
+ export declare function SetRestrictedFieldClassifierDecisionMode(mode: unknown): void;
53
+ /** How the restricted-field classifier's semantic stage is answered now. */
54
+ export declare function GetRestrictedFieldClassifierDecisionMode(): DecisionUseMode;
55
+ /** A candidate restricted field, as the decision asks about it. */
56
+ export interface RestrictedFieldDecisionCandidate {
57
+ Name: string;
58
+ DisplayName: string;
59
+ Description: string | null;
60
+ }
61
+ /** What the decision is asked about: the comment, and the record type it is on. */
62
+ export interface RestrictedFieldDecisionInput {
63
+ EntityDisplayName: string;
64
+ MessageText: string;
65
+ AnchorType: string | null;
66
+ AnchorKey: string | null;
67
+ CandidateFields: ReadonlyArray<RestrictedFieldDecisionCandidate>;
68
+ }
69
+ /** The question key of the candidate at this index: `f1`, `f2`, … */
70
+ export declare function RestrictedFieldQuestionKey(index: number): string;
71
+ /**
72
+ * One Likelihood per candidate field, keyed `f1`, `f2`, … in the candidates' order. Each question
73
+ * names its field and quotes its description: a native decision driver may answer each question on
74
+ * its own against the state, so a question that named only its key would ask the same thing about
75
+ * every field.
76
+ *
77
+ * @param input The comment and its candidate fields.
78
+ */
79
+ export declare function BuildRestrictedFieldQuestions(input: RestrictedFieldDecisionInput): Record<string, LikelihoodQuestion>;
80
+ /**
81
+ * The state the questions are asked about: the comment, the record type, and where on the record
82
+ * it is anchored. Nothing from the record itself: the record's values never go to the model.
83
+ *
84
+ * @param input The comment and its candidate fields.
85
+ */
86
+ export declare function BuildRestrictedFieldState(input: RestrictedFieldDecisionInput): Record<string, unknown>;
87
+ /** One field's answer, raw and calibrated. */
88
+ export interface RestrictedFieldDecisionVerdict {
89
+ Name: string;
90
+ RawProbability: number | null;
91
+ CalibratedProbability: number | null;
92
+ }
93
+ /**
94
+ * Each candidate's answer, raw and calibrated for the model that answered. A missing or non-Likelihood
95
+ * answer reads as null.
96
+ *
97
+ * @param input The comment and its candidate fields, in the order the questions were built.
98
+ * @param answers The decision's answers.
99
+ * @param answeredBy The model that answered.
100
+ */
101
+ export declare function ReadRestrictedFieldVerdicts(input: RestrictedFieldDecisionInput, answers: Record<string, DecisionAnswer>, answeredBy: DecisionAnsweringModel): RestrictedFieldDecisionVerdict[];
102
+ /** The model that answered a decision run, for calibration. */
103
+ export declare function AnsweredByOf(run: AIDecisionRunResult): DecisionAnsweringModel;
104
+ /**
105
+ * The fields the decision flags, or null when it is not good enough to act on: a field went
106
+ * unanswered, or the model that answered has no calibration for this use. Null falls back to the
107
+ * prompt in `Decision` mode.
108
+ *
109
+ * @param verdicts Each candidate's answer, from {@link ReadRestrictedFieldVerdicts}.
110
+ */
111
+ export declare function FlaggedFieldsFromVerdicts(verdicts: ReadonlyArray<RestrictedFieldDecisionVerdict>): string[] | null;
112
+ /**
113
+ * How the decision compares with the prompt's flagged fields, for a shadow run. The decision has no
114
+ * calibration yet, so it counts as flagging a field at a raw {@link RESTRICTED_FIELD_SHADOW_RAW_THRESHOLD};
115
+ * the raw and calibrated probabilities are kept in `Details` for the fit.
116
+ *
117
+ * @param verdicts Each candidate's answer.
118
+ * @param promptFields The fields the prompt flagged.
119
+ */
120
+ export declare function CompareRestrictedFieldDecision(verdicts: ReadonlyArray<RestrictedFieldDecisionVerdict>, promptFields: readonly string[]): ShadowDecisionComparison;
121
+ //# sourceMappingURL=RestrictedFieldDecision.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RestrictedFieldDecision.d.ts","sourceRoot":"","sources":["../../src/custom/RestrictedFieldDecision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEnG,OAAO,EAEH,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAChC,MAAM,4BAA4B,CAAC;AAEpC,uEAAuE;AACvE,eAAO,MAAM,+BAA+B,gCAAgC,CAAC;AAE7E,sGAAsG;AACtG,eAAO,MAAM,kCAAkC,cAAc,CAAC;AAE9D,wDAAwD;AACxD,eAAO,MAAM,gCAAgC,EAAE,sBAG7C,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,yCAAyC,MAAM,CAAC;AAE7D,yFAAyF;AACzF,eAAO,MAAM,sCAAsC,EAAE,eAA0B,CAAC;AAEhF,mHAAmH;AACnH,eAAO,MAAM,qCAAqC,MAAM,CAAC;AAIzD;;;;;;GAMG;AACH,wBAAgB,wCAAwC,CAAC,IAAI,EAAE,OAA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gB,yBAAyB,CAAC,QAAQ,EAAE,aAAa,CAAC,8BAA8B,CAAC,GAAG,MAAM,EAAE,GAAG,IAAI,CAOlH;AAED;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAC1C,QAAQ,EAAE,aAAa,CAAC,8BAA8B,CAAC,EACvD,YAAY,EAAE,SAAS,MAAM,EAAE,GAChC,wBAAwB,CAoB1B"}
@@ -0,0 +1,168 @@
1
+ /**
2
+ * @fileoverview The restricted-field classifier asked as a decision: one Likelihood per candidate
3
+ * field, "does this comment discuss or reveal it?", answered in a single call.
4
+ *
5
+ * This is Stage 2 of {@link InspectAndStampRestrictedFieldsForComment}, the semantic check that runs
6
+ * after the deterministic name match. The existing path is the `Anchored Comment Restricted Field
7
+ * Classifier` prompt; this module is the decision that can replace it, through `RunDecisionUse`:
8
+ * - `Prompt`: only the prompt answers.
9
+ * - `Shadow` (the default): the prompt answers; the decision runs beside it and its run records
10
+ * whether the two flagged the same fields (`RunName = 'Shadow: restricted-field-classifier'`).
11
+ * - `Decision`: a field is flagged when its **calibrated** probability is at or above
12
+ * {@link RESTRICTED_FIELD_DECISION_MIN_PROBABILITY}. An answer from a model with no calibration for
13
+ * this use falls back to the prompt, as a failed decision does.
14
+ *
15
+ * The default stays `Shadow` because no calibration has been fitted for this use yet: the shadow runs
16
+ * are the labelled data for the fit (the `fit-decision-calibration` rig). Switch a deployment to
17
+ * `Decision` only once a fit is in the answering model's `ModelConfiguration.Decision.Calibrations`.
18
+ *
19
+ * Kept apart from the classifier so the question, state and reading rules are unit-tested on their own.
20
+ *
21
+ * @module @memberjunction/core-entities-server
22
+ */
23
+ import { AIEngine } from '@memberjunction/aiengine';
24
+ import { ResolveDecisionUseMode } from '@memberjunction/ai-prompts';
25
+ /** The decision use: names shadow runs and selects the calibration. */
26
+ export const RESTRICTED_FIELD_CLASSIFIER_USE = 'restricted-field-classifier';
27
+ /** The question every field's Likelihood shares for calibration, whatever its key (`f1`, `f2`, …). */
28
+ export const RESTRICTED_FIELD_DECISION_QUESTION = 'discusses';
29
+ /** Which calibration the per-field Likelihoods read. */
30
+ export const RESTRICTED_FIELD_CALIBRATION_KEY = Object.freeze({
31
+ Use: RESTRICTED_FIELD_CLASSIFIER_USE,
32
+ Question: RESTRICTED_FIELD_DECISION_QUESTION
33
+ });
34
+ /**
35
+ * The least calibrated probability at which a field is flagged in `Decision` mode.
36
+ *
37
+ * Deliberately low. The cost of the two errors is not symmetric: a missed field leaves a comment
38
+ * about a restricted value readable by people the field rule hides it from, while a false flag only
39
+ * hides one comment from them. So the threshold trades precision for recall. Revisit it with the
40
+ * calibration fit, against the shadow runs' labelled outcomes.
41
+ */
42
+ export const RESTRICTED_FIELD_DECISION_MIN_PROBABILITY = 0.2;
43
+ /** The mode used when nothing is configured: `Shadow`, until a calibration is fitted. */
44
+ export const RESTRICTED_FIELD_DEFAULT_DECISION_MODE = 'Shadow';
45
+ /** The raw probability a shadow comparison reads as "the decision flagged it", since it has no calibration yet. */
46
+ export const RESTRICTED_FIELD_SHADOW_RAW_THRESHOLD = 0.5;
47
+ let restrictedFieldDecisionMode = RESTRICTED_FIELD_DEFAULT_DECISION_MODE;
48
+ /**
49
+ * Sets how the restricted-field classifier's semantic stage is answered. MJServer calls it at startup
50
+ * from `decisions.restrictedFieldClassifier` in its config. A value that is not a mode (case-insensitive)
51
+ * restores the default, `Shadow`.
52
+ *
53
+ * @param mode `Prompt`, `Shadow` or `Decision`.
54
+ */
55
+ export function SetRestrictedFieldClassifierDecisionMode(mode) {
56
+ restrictedFieldDecisionMode = ResolveDecisionUseMode(mode, RESTRICTED_FIELD_DEFAULT_DECISION_MODE);
57
+ }
58
+ /** How the restricted-field classifier's semantic stage is answered now. */
59
+ export function GetRestrictedFieldClassifierDecisionMode() {
60
+ return restrictedFieldDecisionMode;
61
+ }
62
+ /** The question key of the candidate at this index: `f1`, `f2`, … */
63
+ export function RestrictedFieldQuestionKey(index) {
64
+ return `f${index + 1}`;
65
+ }
66
+ /**
67
+ * One Likelihood per candidate field, keyed `f1`, `f2`, … in the candidates' order. Each question
68
+ * names its field and quotes its description: a native decision driver may answer each question on
69
+ * its own against the state, so a question that named only its key would ask the same thing about
70
+ * every field.
71
+ *
72
+ * @param input The comment and its candidate fields.
73
+ */
74
+ export function BuildRestrictedFieldQuestions(input) {
75
+ const questions = {};
76
+ input.CandidateFields.forEach((field, i) => {
77
+ questions[RestrictedFieldQuestionKey(i)] = {
78
+ Kind: 'Likelihood',
79
+ Instructions: describeFieldQuestion(input.EntityDisplayName, field)
80
+ };
81
+ });
82
+ return questions;
83
+ }
84
+ /** The statement one field's Likelihood asks about. */
85
+ function describeFieldQuestion(entityDisplayName, field) {
86
+ const description = field.Description?.trim();
87
+ const what = description ? `the "${field.DisplayName}" field (${description})` : `the "${field.DisplayName}" field`;
88
+ return `This comment on a ${entityDisplayName} record discusses, asks about, or reveals the value of ${what}, ` +
89
+ `whether it names the field or only refers to its content.`;
90
+ }
91
+ /**
92
+ * The state the questions are asked about: the comment, the record type, and where on the record
93
+ * it is anchored. Nothing from the record itself: the record's values never go to the model.
94
+ *
95
+ * @param input The comment and its candidate fields.
96
+ */
97
+ export function BuildRestrictedFieldState(input) {
98
+ return {
99
+ recordType: input.EntityDisplayName,
100
+ anchor: input.AnchorKey ? `${input.AnchorType ?? 'Section'}: ${input.AnchorKey}` : (input.AnchorType ?? 'Record'),
101
+ comment: input.MessageText
102
+ };
103
+ }
104
+ /**
105
+ * Each candidate's answer, raw and calibrated for the model that answered. A missing or non-Likelihood
106
+ * answer reads as null.
107
+ *
108
+ * @param input The comment and its candidate fields, in the order the questions were built.
109
+ * @param answers The decision's answers.
110
+ * @param answeredBy The model that answered.
111
+ */
112
+ export function ReadRestrictedFieldVerdicts(input, answers, answeredBy) {
113
+ return input.CandidateFields.map((field, i) => {
114
+ const answer = answers[RestrictedFieldQuestionKey(i)];
115
+ const raw = answer?.Kind === 'Likelihood' && Number.isFinite(answer.Probability) ? answer.Probability : null;
116
+ const calibrated = raw === null ? null : AIEngine.Instance.CalibrateDecisionProbability(RESTRICTED_FIELD_CALIBRATION_KEY, raw, answeredBy);
117
+ return { Name: field.Name, RawProbability: raw, CalibratedProbability: calibrated };
118
+ });
119
+ }
120
+ /** The model that answered a decision run, for calibration. */
121
+ export function AnsweredByOf(run) {
122
+ return { ModelName: run.modelInfo?.modelName, ResolvedModel: run.DecisionResult?.ResolvedModel };
123
+ }
124
+ /**
125
+ * The fields the decision flags, or null when it is not good enough to act on: a field went
126
+ * unanswered, or the model that answered has no calibration for this use. Null falls back to the
127
+ * prompt in `Decision` mode.
128
+ *
129
+ * @param verdicts Each candidate's answer, from {@link ReadRestrictedFieldVerdicts}.
130
+ */
131
+ export function FlaggedFieldsFromVerdicts(verdicts) {
132
+ if (verdicts.some(v => v.CalibratedProbability === null)) {
133
+ return null;
134
+ }
135
+ return verdicts
136
+ .filter(v => (v.CalibratedProbability ?? 0) >= RESTRICTED_FIELD_DECISION_MIN_PROBABILITY)
137
+ .map(v => v.Name);
138
+ }
139
+ /**
140
+ * How the decision compares with the prompt's flagged fields, for a shadow run. The decision has no
141
+ * calibration yet, so it counts as flagging a field at a raw {@link RESTRICTED_FIELD_SHADOW_RAW_THRESHOLD};
142
+ * the raw and calibrated probabilities are kept in `Details` for the fit.
143
+ *
144
+ * @param verdicts Each candidate's answer.
145
+ * @param promptFields The fields the prompt flagged.
146
+ */
147
+ export function CompareRestrictedFieldDecision(verdicts, promptFields) {
148
+ const promptSet = new Set(promptFields.map(f => f.toLowerCase()));
149
+ const decisionFields = verdicts
150
+ .filter(v => (v.RawProbability ?? 0) >= RESTRICTED_FIELD_SHADOW_RAW_THRESHOLD)
151
+ .map(v => v.Name);
152
+ const decisionSet = new Set(decisionFields.map(f => f.toLowerCase()));
153
+ const agreed = decisionSet.size === promptSet.size && [...decisionSet].every(f => promptSet.has(f));
154
+ return {
155
+ Agreed: agreed,
156
+ Summary: `decision flagged [${decisionFields.join(', ')}], prompt flagged [${promptFields.join(', ')}]`,
157
+ Details: {
158
+ PromptFields: [...promptFields],
159
+ Fields: verdicts.map(v => ({
160
+ Name: v.Name,
161
+ RawProbability: v.RawProbability,
162
+ CalibratedProbability: v.CalibratedProbability,
163
+ PromptFlagged: promptSet.has(v.Name.toLowerCase())
164
+ }))
165
+ }
166
+ };
167
+ }
168
+ //# sourceMappingURL=RestrictedFieldDecision.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RestrictedFieldDecision.js","sourceRoot":"","sources":["../../src/custom/RestrictedFieldDecision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EACH,sBAAsB,EAIzB,MAAM,4BAA4B,CAAC;AAEpC,uEAAuE;AACvE,MAAM,CAAC,MAAM,+BAA+B,GAAG,6BAA6B,CAAC;AAE7E,sGAAsG;AACtG,MAAM,CAAC,MAAM,kCAAkC,GAAG,WAAW,CAAC;AAE9D,wDAAwD;AACxD,MAAM,CAAC,MAAM,gCAAgC,GAA2B,MAAM,CAAC,MAAM,CAAC;IAClF,GAAG,EAAE,+BAA+B;IACpC,QAAQ,EAAE,kCAAkC;CAC/C,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,yCAAyC,GAAG,GAAG,CAAC;AAE7D,yFAAyF;AACzF,MAAM,CAAC,MAAM,sCAAsC,GAAoB,QAAQ,CAAC;AAEhF,mHAAmH;AACnH,MAAM,CAAC,MAAM,qCAAqC,GAAG,GAAG,CAAC;AAEzD,IAAI,2BAA2B,GAAoB,sCAAsC,CAAC;AAE1F;;;;;;GAMG;AACH,MAAM,UAAU,wCAAwC,CAAC,IAAa;IAClE,2BAA2B,GAAG,sBAAsB,CAAC,IAAI,EAAE,sCAAsC,CAAC,CAAC;AACvG,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,wCAAwC;IACpD,OAAO,2BAA2B,CAAC;AACvC,CAAC;AAkBD,q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S,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;aACrD,CAAC,CAAC;SACN;KACJ,CAAC;AACN,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { type SpreadsheetCellEditContext, type WorkbookSpec } from '@memberjunction/core-entities';
2
+ export type SpreadsheetWorkerRequest = {
3
+ Op: 'import';
4
+ Bytes: Uint8Array;
5
+ ConfigurationJson?: string | null;
6
+ SkipEvaluate?: boolean;
7
+ } | {
8
+ Op: 'patch';
9
+ OriginalBytes: Uint8Array;
10
+ Workbook: WorkbookSpec;
11
+ } | {
12
+ Op: 'evaluate';
13
+ Workbook: WorkbookSpec;
14
+ EditContext?: SpreadsheetCellEditContext;
15
+ };
16
+ export type SpreadsheetWorkerReply = {
17
+ Ok: true;
18
+ Workbook?: WorkbookSpec;
19
+ Bytes?: Uint8Array;
20
+ EvaluatedFormulaCount?: number;
21
+ } | {
22
+ Ok: false;
23
+ Error: string;
24
+ };
25
+ //# sourceMappingURL=SpreadsheetWorkerEntry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SpreadsheetWorkerEntry.d.ts","sourceRoot":"","sources":["../../src/custom/SpreadsheetWorkerEntry.ts"],"names":[],"mappings":"AACA,OAAO,EAGH,KAAK,0BAA0B,EAC/B,KAAK,YAAY,EACpB,MAAM,+BAA+B,CAAC;AAEvC,MAAM,MAAM,wBAAwB,GAC9B;IACI,EAAE,EAAE,QAAQ,CAAC;IACb,KAAK,EAAE,UAAU,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B,GACD;IACI,EAAE,EAAE,OAAO,CAAC;IACZ,aAAa,EAAE,UAAU,CAAC;IAC1B,QAAQ,EAAE,YAAY,CAAC;CAC1B,GACD;IACI,EAAE,EAAE,UAAU,CAAC;IACf,QAAQ,EAAE,YAAY,CAAC;IACvB,WAAW,CAAC,EAAE,0BAA0B,CAAC;CAC5C,CAAC;AAER,MAAM,MAAM,sBAAsB,GAC5B;IACI,EAAE,EAAE,IAAI,CAAC;IACT,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAClC,GACD;IACI,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACjB,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { parentPort, workerData } from 'node:worker_threads';
2
+ import { SetSpreadsheetWorkerIsolationRequired, SpreadsheetEngine } from '@memberjunction/core-entities';
3
+ function runWorkerRequest(req) {
4
+ try {
5
+ SetSpreadsheetWorkerIsolationRequired(false);
6
+ const engine = SpreadsheetEngine.Instance;
7
+ switch (req.Op) {
8
+ case 'import': {
9
+ const workbook = engine.ImportFromXlsxBytes(req.Bytes, req.ConfigurationJson, req.SkipEvaluate !== undefined ? { SkipEvaluate: req.SkipEvaluate } : undefined);
10
+ return { Ok: true, Workbook: workbook };
11
+ }
12
+ case 'patch': {
13
+ const bytes = engine.PatchXlsxBytes(req.OriginalBytes, req.Workbook);
14
+ return { Ok: true, Bytes: bytes };
15
+ }
16
+ case 'evaluate': {
17
+ engine.EvaluateWorkbook(req.Workbook, req.EditContext);
18
+ return {
19
+ Ok: true,
20
+ Workbook: req.Workbook,
21
+ EvaluatedFormulaCount: engine.LastEvaluatedFormulaCount
22
+ };
23
+ }
24
+ }
25
+ }
26
+ catch (err) {
27
+ return {
28
+ Ok: false,
29
+ Error: err instanceof Error ? err.message : String(err)
30
+ };
31
+ }
32
+ }
33
+ if (parentPort && workerData) {
34
+ const reply = runWorkerRequest(workerData);
35
+ parentPort.postMessage(reply);
36
+ }
37
+ //# sourceMappingURL=SpreadsheetWorkerEntry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SpreadsheetWorkerEntry.js","sourceRoot":"","sources":["../../src/custom/SpreadsheetWorkerEntry.ts"],"names":[],"m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H,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;SAC1D,CAAC;IACN,CAAC;AACL,CAAC;AAED,IAAI,UAAU,IAAI,UAAU,EAAE,CAAC;IAC3B,MAAM,KAAK,GAAG,gBAAgB,CAAC,UAAsC,CAAC,CAAC;IACvE,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { type ResourceLimits } from 'node:worker_threads';
2
+ import { type SpreadsheetCellEditContext, type WorkbookSpec } from '@memberjunction/core-entities';
3
+ /** Default wall-clock timeout for server-side isolated spreadsheet worker execution (`R6-1`). */
4
+ export declare const DEFAULT_SPREADSHEET_WORKER_TIMEOUT_MS = 10000;
5
+ /** Default maximum concurrent spreadsheet workers per server process (`R7-3`). */
6
+ export declare const DEFAULT_MAX_CONCURRENT_SPREADSHEET_WORKERS = 4;
7
+ /** Default maximum queued spreadsheet worker requests before backpressure rejection (`R7-3`). */
8
+ export declare const DEFAULT_MAX_QUEUED_SPREADSHEET_WORKERS = 32;
9
+ /** Default maximum time a queued worker request will wait for a pool slot before rejecting (`R8`). */
10
+ export declare const DEFAULT_SPREADSHEET_WORKER_QUEUE_WAIT_TIMEOUT_MS = 10000;
11
+ /** Default V8 heap limits applied to each isolated spreadsheet worker (`R6-1`). */
12
+ export declare const DEFAULT_SPREADSHEET_WORKER_RESOURCE_LIMITS: Readonly<ResourceLimits>;
13
+ export interface SpreadsheetWorkerExecutionOptions {
14
+ TimeoutMs?: number;
15
+ QueueWaitTimeoutMs?: number;
16
+ ResourceLimits?: ResourceLimits;
17
+ WorkerEntryPath?: string;
18
+ MaxConcurrentWorkers?: number;
19
+ MaxQueuedWorkers?: number;
20
+ }
21
+ /**
22
+ * Runs {@link SpreadsheetEngine.ImportFromXlsxBytes} inside a heap-bounded, wall-clock-timed
23
+ * `node:worker_threads` worker (`R6-1`).
24
+ */
25
+ export declare function RunSpreadsheetImportInWorker(bytes: Uint8Array, configurationJson?: string | null, options?: SpreadsheetWorkerExecutionOptions & {
26
+ SkipEvaluate?: boolean;
27
+ }): Promise<WorkbookSpec>;
28
+ /**
29
+ * Runs {@link SpreadsheetEngine.PatchXlsxBytes} inside a heap-bounded, wall-clock-timed
30
+ * `node:worker_threads` worker (`R6-1`).
31
+ */
32
+ export declare function RunSpreadsheetPatchInWorker(originalBytes: Uint8Array, workbook: WorkbookSpec, options?: SpreadsheetWorkerExecutionOptions): Promise<Uint8Array>;
33
+ /**
34
+ * Runs {@link SpreadsheetEngine.EvaluateWorkbook} inside a heap-bounded, wall-clock-timed
35
+ * `node:worker_threads` worker (`R6-1`).
36
+ */
37
+ export declare function RunSpreadsheetEvaluateInWorker(workbook: WorkbookSpec, editContext?: SpreadsheetCellEditContext, options?: SpreadsheetWorkerExecutionOptions): Promise<{
38
+ Workbook: WorkbookSpec;
39
+ EvaluatedFormulaCount: number;
40
+ }>;
41
+ /**
42
+ * Registers the server-side `node:worker_threads` runner with {@link SpreadsheetEngine} (`R6-1`, `R8-3`).
43
+ */
44
+ export declare function RegisterSpreadsheetServerWorkerRunner(options?: SpreadsheetWorkerExecutionOptions): void;
45
+ //# sourceMappingURL=SpreadsheetWorkerRunner.d.ts.map