couchloop-eq-mcp 1.0.2 → 1.0.4

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 (90) hide show
  1. package/README.md +29 -4
  2. package/dist/clients/shrinkChatClient.d.ts +10 -0
  3. package/dist/clients/shrinkChatClient.d.ts.map +1 -1
  4. package/dist/clients/shrinkChatClient.js +5 -1
  5. package/dist/clients/shrinkChatClient.js.map +1 -1
  6. package/dist/db/client.d.ts.map +1 -1
  7. package/dist/db/client.js +5 -3
  8. package/dist/db/client.js.map +1 -1
  9. package/dist/db/schema.d.ts +363 -0
  10. package/dist/db/schema.d.ts.map +1 -1
  11. package/dist/db/schema.js +47 -0
  12. package/dist/db/schema.js.map +1 -1
  13. package/dist/governance/config.d.ts +66 -0
  14. package/dist/governance/config.d.ts.map +1 -0
  15. package/dist/governance/config.js +238 -0
  16. package/dist/governance/config.js.map +1 -0
  17. package/dist/governance/detectors/hallucination.d.ts +61 -0
  18. package/dist/governance/detectors/hallucination.d.ts.map +1 -0
  19. package/dist/governance/detectors/hallucination.js +338 -0
  20. package/dist/governance/detectors/hallucination.js.map +1 -0
  21. package/dist/governance/detectors/inconsistency.d.ts +99 -0
  22. package/dist/governance/detectors/inconsistency.d.ts.map +1 -0
  23. package/dist/governance/detectors/inconsistency.js +548 -0
  24. package/dist/governance/detectors/inconsistency.js.map +1 -0
  25. package/dist/governance/detectors/toneDrift.d.ts +63 -0
  26. package/dist/governance/detectors/toneDrift.d.ts.map +1 -0
  27. package/dist/governance/detectors/toneDrift.js +421 -0
  28. package/dist/governance/detectors/toneDrift.js.map +1 -0
  29. package/dist/governance/detectors/unsafeReasoning.d.ts +54 -0
  30. package/dist/governance/detectors/unsafeReasoning.d.ts.map +1 -0
  31. package/dist/governance/detectors/unsafeReasoning.js +473 -0
  32. package/dist/governance/detectors/unsafeReasoning.js.map +1 -0
  33. package/dist/governance/evaluationEngine.d.ts +112 -0
  34. package/dist/governance/evaluationEngine.d.ts.map +1 -0
  35. package/dist/governance/evaluationEngine.js +265 -0
  36. package/dist/governance/evaluationEngine.js.map +1 -0
  37. package/dist/governance/intervention.d.ts +81 -0
  38. package/dist/governance/intervention.d.ts.map +1 -0
  39. package/dist/governance/intervention.js +405 -0
  40. package/dist/governance/intervention.js.map +1 -0
  41. package/dist/server/chatgpt-mcp.d.ts +10 -0
  42. package/dist/server/chatgpt-mcp.d.ts.map +1 -0
  43. package/dist/server/chatgpt-mcp.js +233 -0
  44. package/dist/server/chatgpt-mcp.js.map +1 -0
  45. package/dist/server/index.d.ts.map +1 -1
  46. package/dist/server/index.js +94 -3
  47. package/dist/server/index.js.map +1 -1
  48. package/dist/server/middleware/localNetworkAccess.d.ts +16 -0
  49. package/dist/server/middleware/localNetworkAccess.d.ts.map +1 -0
  50. package/dist/server/middleware/localNetworkAccess.js +97 -0
  51. package/dist/server/middleware/localNetworkAccess.js.map +1 -0
  52. package/dist/server/sse.d.ts +16 -0
  53. package/dist/server/sse.d.ts.map +1 -0
  54. package/dist/server/sse.js +215 -0
  55. package/dist/server/sse.js.map +1 -0
  56. package/dist/tools/checkpoint.d.ts.map +1 -1
  57. package/dist/tools/index.d.ts +1 -0
  58. package/dist/tools/index.d.ts.map +1 -1
  59. package/dist/tools/index.js +4 -2
  60. package/dist/tools/index.js.map +1 -1
  61. package/dist/tools/insight.d.ts +1 -0
  62. package/dist/tools/insight.d.ts.map +1 -1
  63. package/dist/tools/sendMessage-complex-backup.d.ts +6 -0
  64. package/dist/tools/sendMessage-complex-backup.d.ts.map +1 -0
  65. package/dist/tools/sendMessage-complex-backup.js +545 -0
  66. package/dist/tools/sendMessage-complex-backup.js.map +1 -0
  67. package/dist/tools/sendMessage-revised.d.ts +11 -0
  68. package/dist/tools/sendMessage-revised.d.ts.map +1 -0
  69. package/dist/tools/sendMessage-revised.js +429 -0
  70. package/dist/tools/sendMessage-revised.js.map +1 -0
  71. package/dist/tools/sendMessage-truly-simple.d.ts +8 -0
  72. package/dist/tools/sendMessage-truly-simple.d.ts.map +1 -0
  73. package/dist/tools/sendMessage-truly-simple.js +299 -0
  74. package/dist/tools/sendMessage-truly-simple.js.map +1 -0
  75. package/dist/tools/sendMessage.d.ts +4 -2
  76. package/dist/tools/sendMessage.d.ts.map +1 -1
  77. package/dist/tools/sendMessage.js +240 -186
  78. package/dist/tools/sendMessage.js.map +1 -1
  79. package/dist/tools/session.d.ts.map +1 -1
  80. package/dist/tools/session.js +35 -29
  81. package/dist/tools/session.js.map +1 -1
  82. package/dist/types/auth.d.ts +21 -13
  83. package/dist/types/auth.d.ts.map +1 -1
  84. package/dist/types/auth.js +108 -25
  85. package/dist/types/auth.js.map +1 -1
  86. package/dist/types/insight.d.ts +10 -0
  87. package/dist/types/insight.d.ts.map +1 -1
  88. package/dist/types/session.d.ts +10 -0
  89. package/dist/types/session.d.ts.map +1 -1
  90. package/package.json +10 -5
@@ -0,0 +1,421 @@
1
+ /**
2
+ * CouchLoop Behavioral Governance Layer - Tone Drift Monitor
3
+ *
4
+ * Detects escalation from neutral to emotionally loaded, over-reassurance,
5
+ * over-alarmism, and manipulative or dependency-forming language
6
+ */
7
+ export class ToneDriftMonitor {
8
+ config;
9
+ manipulativePatterns;
10
+ overReassurancePatterns;
11
+ alarmistPatterns;
12
+ dependencyPatterns;
13
+ directivePatterns;
14
+ constructor(config) {
15
+ this.config = config;
16
+ // Compile regex patterns for different tone issues
17
+ this.manipulativePatterns = [
18
+ /only I can help/i,
19
+ /you need me/i,
20
+ /without me you/i,
21
+ /trust me, not/i,
22
+ /they don't understand (you )?like I do/i,
23
+ /I know you better than/i,
24
+ /you can't trust (them|anyone else)/i,
25
+ /I'm the only one who/i,
26
+ /don't listen to (them|others)/i,
27
+ /they're wrong about you/i
28
+ ];
29
+ this.overReassurancePatterns = [
30
+ /everything will be (fine|okay|perfect|great)/i,
31
+ /don't worry about (anything|it)/i,
32
+ /there's nothing to (worry|be concerned) about/i,
33
+ /you have nothing to fear/i,
34
+ /it's all going to work out/i,
35
+ /trust me, (everything|it)/i,
36
+ /I promise (everything|you)/i,
37
+ /absolutely no risk/i,
38
+ /completely safe/i,
39
+ /guaranteed to work/i
40
+ ];
41
+ this.alarmistPatterns = [
42
+ /this is (extremely |very )?serious/i,
43
+ /you must act (now|immediately)/i,
44
+ /before it's too late/i,
45
+ /dangerous to wait/i,
46
+ /could be (catastrophic|disastrous|fatal)/i,
47
+ /urgent(ly)? need/i,
48
+ /crisis situation/i,
49
+ /emergency/i,
50
+ /dire consequences/i,
51
+ /at great risk/i
52
+ ];
53
+ this.dependencyPatterns = [
54
+ /you('ll)? always need/i,
55
+ /come back to me/i,
56
+ /I'll always be here/i,
57
+ /you can't do this without/i,
58
+ /you need (me|this) to/i,
59
+ /depend on me/i,
60
+ /rely on me/i,
61
+ /I'm here for you (always|forever|no matter what)/i,
62
+ /whenever you need/i,
63
+ /don't hesitate to contact me/i
64
+ ];
65
+ this.directivePatterns = [
66
+ /you must/i,
67
+ /you have to/i,
68
+ /you need to/i,
69
+ /you should definitely/i,
70
+ /it's essential that you/i,
71
+ /it's critical that you/i,
72
+ /imperative that you/i,
73
+ /absolutely necessary/i,
74
+ /no other choice/i,
75
+ /the only way/i
76
+ ];
77
+ // Add custom patterns from config
78
+ if (config.patterns) {
79
+ const customPatterns = config.patterns.map(p => new RegExp(p, 'i'));
80
+ this.manipulativePatterns.push(...customPatterns);
81
+ }
82
+ }
83
+ /**
84
+ * Main monitoring method
85
+ */
86
+ async monitor(response, context) {
87
+ // Analyze current response tone
88
+ const currentTone = this.analyzeTone(response);
89
+ // Get or establish baseline tone
90
+ const baselineTone = await this.getBaselineTone(context);
91
+ // Calculate drift from baseline
92
+ const driftAnalysis = this.calculateDrift(currentTone, baselineTone);
93
+ // Check for problematic patterns
94
+ const manipulativeFound = this.detectManipulation(response);
95
+ const overReassuranceFound = this.detectOverReassurance(response);
96
+ const alarmismFound = this.detectAlarmism(response);
97
+ const dependencyFound = this.detectDependencyForming(response);
98
+ const overDirectiveFound = this.detectOverDirectiveness(response);
99
+ // Combine all detected patterns
100
+ const problematicPatterns = [
101
+ ...manipulativeFound,
102
+ ...overReassuranceFound,
103
+ ...alarmismFound,
104
+ ...dependencyFound,
105
+ ...overDirectiveFound
106
+ ];
107
+ // Calculate overall confidence
108
+ let confidence = 0;
109
+ // Weight drift score
110
+ if (driftAnalysis.driftScore > 0.3) {
111
+ confidence += driftAnalysis.driftScore * 0.4;
112
+ }
113
+ // Weight problematic patterns
114
+ if (manipulativeFound.length > 0) {
115
+ confidence += 0.3;
116
+ }
117
+ if (overReassuranceFound.length > 0) {
118
+ confidence += 0.15;
119
+ }
120
+ if (alarmismFound.length > 0) {
121
+ confidence += 0.2;
122
+ }
123
+ if (dependencyFound.length > 0) {
124
+ confidence += 0.25;
125
+ }
126
+ if (overDirectiveFound.length > 0) {
127
+ confidence += 0.15;
128
+ }
129
+ // Check for emotional escalation
130
+ const emotionalEscalation = this.detectEmotionalEscalation(currentTone, baselineTone);
131
+ if (emotionalEscalation) {
132
+ confidence += 0.2;
133
+ problematicPatterns.push(`Emotional escalation: ${emotionalEscalation}`);
134
+ }
135
+ // Cap confidence at 1.0
136
+ confidence = Math.min(confidence, 1.0);
137
+ const detected = confidence >= this.config.threshold;
138
+ return {
139
+ detected,
140
+ confidence,
141
+ patterns: problematicPatterns,
142
+ details: {
143
+ currentTone,
144
+ baselineTone,
145
+ driftScore: driftAnalysis.driftScore,
146
+ driftDirection: driftAnalysis.driftDirection,
147
+ manipulativePatterns: manipulativeFound.length,
148
+ overReassurance: overReassuranceFound.length,
149
+ alarmism: alarmismFound.length,
150
+ dependency: dependencyFound.length,
151
+ overDirective: overDirectiveFound.length,
152
+ threshold: this.config.threshold
153
+ }
154
+ };
155
+ }
156
+ /**
157
+ * Analyze tone profile of text
158
+ */
159
+ analyzeTone(text) {
160
+ // Formality (0-1)
161
+ const formalityMarkers = /\b(furthermore|moreover|consequently|nevertheless|therefore|hence|thus)\b/gi;
162
+ const informalMarkers = /\b(yeah|yep|gonna|wanna|kinda|sorta|like|totally|awesome)\b/gi;
163
+ const formalCount = (text.match(formalityMarkers) || []).length;
164
+ const informalCount = (text.match(informalMarkers) || []).length;
165
+ const formality = Math.min(1, Math.max(0, 0.5 + (formalCount - informalCount) * 0.1));
166
+ // Emotionality (0-1)
167
+ const emotionalMarkers = /\b(feel|felt|feeling|emotion|love|hate|fear|anger|sad|happy|joy|pain|hurt|worried|anxious|excited)\b/gi;
168
+ const emotionalCount = (text.match(emotionalMarkers) || []).length;
169
+ const exclamationCount = (text.match(/!/g) || []).length;
170
+ const emotionality = Math.min(1, (emotionalCount * 0.05) + (exclamationCount * 0.1));
171
+ // Directiveness (0-1)
172
+ const directiveMarkers = /\b(must|should|need to|have to|required|essential|critical|imperative)\b/gi;
173
+ const exploratoryMarkers = /\b(perhaps|maybe|might|could|possibly|what if|wonder|curious)\b/gi;
174
+ const directiveCount = (text.match(directiveMarkers) || []).length;
175
+ const exploratoryCount = (text.match(exploratoryMarkers) || []).length;
176
+ const directiveness = Math.min(1, Math.max(0, 0.5 + (directiveCount - exploratoryCount) * 0.08));
177
+ // Certainty (0-1)
178
+ const certaintyMarkers = /\b(definitely|absolutely|certainly|undoubtedly|clearly|obviously|surely|guaranteed|proven|fact)\b/gi;
179
+ const uncertaintyMarkers = /\b(maybe|perhaps|possibly|might|could|seem|appear|suggest|think)\b/gi;
180
+ const certainCount = (text.match(certaintyMarkers) || []).length;
181
+ const uncertainCount = (text.match(uncertaintyMarkers) || []).length;
182
+ const certainty = Math.min(1, Math.max(0, 0.5 + (certainCount - uncertainCount) * 0.08));
183
+ // Supportiveness (0-1)
184
+ const supportMarkers = /\b(support|help|care|understand|here for you|with you|believe in you|proud|amazing|wonderful|great job)\b/gi;
185
+ const supportCount = (text.match(supportMarkers) || []).length;
186
+ const supportiveness = Math.min(1, supportCount * 0.1);
187
+ // Urgency (0-1)
188
+ const urgencyMarkers = /\b(urgent|immediately|now|asap|quickly|hurry|crisis|emergency|critical|danger)\b/gi;
189
+ const calmMarkers = /\b(relax|calm|peace|patient|time|gradual|slow|steady|no rush)\b/gi;
190
+ const urgentCount = (text.match(urgencyMarkers) || []).length;
191
+ const calmCount = (text.match(calmMarkers) || []).length;
192
+ const urgency = Math.min(1, Math.max(0, 0.3 + (urgentCount - calmCount) * 0.15));
193
+ return {
194
+ formality,
195
+ emotionality,
196
+ directiveness,
197
+ certainty,
198
+ supportiveness,
199
+ urgency
200
+ };
201
+ }
202
+ /**
203
+ * Get baseline tone from conversation history
204
+ */
205
+ async getBaselineTone(context) {
206
+ if (!context?.conversationHistory || context.conversationHistory.length === 0) {
207
+ // Default neutral baseline
208
+ return {
209
+ formality: 0.5,
210
+ emotionality: 0.3,
211
+ directiveness: 0.4,
212
+ certainty: 0.5,
213
+ supportiveness: 0.5,
214
+ urgency: 0.2
215
+ };
216
+ }
217
+ // Analyze first few assistant messages to establish baseline
218
+ const assistantMessages = context.conversationHistory
219
+ .filter(msg => msg.role === 'assistant')
220
+ .slice(0, 3);
221
+ if (assistantMessages.length === 0) {
222
+ return {
223
+ formality: 0.5,
224
+ emotionality: 0.3,
225
+ directiveness: 0.4,
226
+ certainty: 0.5,
227
+ supportiveness: 0.5,
228
+ urgency: 0.2
229
+ };
230
+ }
231
+ // Average tone profiles
232
+ const tones = assistantMessages.map(msg => this.analyzeTone(msg.content));
233
+ const baseline = {
234
+ formality: tones.reduce((sum, t) => sum + t.formality, 0) / tones.length,
235
+ emotionality: tones.reduce((sum, t) => sum + t.emotionality, 0) / tones.length,
236
+ directiveness: tones.reduce((sum, t) => sum + t.directiveness, 0) / tones.length,
237
+ certainty: tones.reduce((sum, t) => sum + t.certainty, 0) / tones.length,
238
+ supportiveness: tones.reduce((sum, t) => sum + t.supportiveness, 0) / tones.length,
239
+ urgency: tones.reduce((sum, t) => sum + t.urgency, 0) / tones.length
240
+ };
241
+ return baseline;
242
+ }
243
+ /**
244
+ * Calculate drift between current and baseline tone
245
+ */
246
+ calculateDrift(current, baseline) {
247
+ // Calculate individual dimension drifts
248
+ const drifts = {
249
+ formality: Math.abs(current.formality - baseline.formality),
250
+ emotionality: Math.abs(current.emotionality - baseline.emotionality),
251
+ directiveness: Math.abs(current.directiveness - baseline.directiveness),
252
+ certainty: Math.abs(current.certainty - baseline.certainty),
253
+ supportiveness: Math.abs(current.supportiveness - baseline.supportiveness),
254
+ urgency: Math.abs(current.urgency - baseline.urgency)
255
+ };
256
+ // Weight different dimensions
257
+ const weights = {
258
+ formality: 0.1,
259
+ emotionality: 0.25,
260
+ directiveness: 0.2,
261
+ certainty: 0.15,
262
+ supportiveness: 0.15,
263
+ urgency: 0.15
264
+ };
265
+ // Calculate weighted drift score
266
+ let driftScore = 0;
267
+ for (const [dimension, drift] of Object.entries(drifts)) {
268
+ driftScore += drift * weights[dimension];
269
+ }
270
+ // Determine primary drift direction
271
+ const maxDrift = Math.max(...Object.values(drifts));
272
+ const primaryDimension = Object.entries(drifts).find(([_, v]) => v === maxDrift)?.[0] || 'unknown';
273
+ let driftDirection = primaryDimension;
274
+ if (primaryDimension === 'emotionality' && current.emotionality > baseline.emotionality) {
275
+ driftDirection = 'emotional escalation';
276
+ }
277
+ else if (primaryDimension === 'directiveness' && current.directiveness > baseline.directiveness) {
278
+ driftDirection = 'increasing directiveness';
279
+ }
280
+ else if (primaryDimension === 'urgency' && current.urgency > baseline.urgency) {
281
+ driftDirection = 'increasing urgency/alarm';
282
+ }
283
+ const problematicPatterns = [];
284
+ // Flag significant drifts
285
+ if (drifts.emotionality > 0.4) {
286
+ problematicPatterns.push(`High emotional drift: ${drifts.emotionality.toFixed(2)}`);
287
+ }
288
+ if (drifts.directiveness > 0.4) {
289
+ problematicPatterns.push(`Significant directiveness change: ${drifts.directiveness.toFixed(2)}`);
290
+ }
291
+ if (drifts.urgency > 0.4) {
292
+ problematicPatterns.push(`Urgency escalation: ${drifts.urgency.toFixed(2)}`);
293
+ }
294
+ return {
295
+ baselineTone: baseline,
296
+ currentTone: current,
297
+ driftScore,
298
+ driftDirection,
299
+ problematicPatterns
300
+ };
301
+ }
302
+ /**
303
+ * Detect manipulative language patterns
304
+ */
305
+ detectManipulation(text) {
306
+ const detected = [];
307
+ for (const pattern of this.manipulativePatterns) {
308
+ const matches = text.match(pattern);
309
+ if (matches) {
310
+ detected.push(`Manipulative: "${matches[0]}"`);
311
+ }
312
+ }
313
+ // Additional manipulation checks
314
+ if (text.match(/only I|just me|no one else/i) && text.match(/understand|help|care/i)) {
315
+ detected.push('Manipulative: Isolating language detected');
316
+ }
317
+ if (text.match(/they .* wrong/i) && text.match(/I .* right/i)) {
318
+ detected.push('Manipulative: Us vs them framing');
319
+ }
320
+ return detected;
321
+ }
322
+ /**
323
+ * Detect over-reassurance patterns
324
+ */
325
+ detectOverReassurance(text) {
326
+ const detected = [];
327
+ for (const pattern of this.overReassurancePatterns) {
328
+ const matches = text.match(pattern);
329
+ if (matches) {
330
+ detected.push(`Over-reassurance: "${matches[0]}"`);
331
+ }
332
+ }
333
+ // Check for multiple reassurances in one response
334
+ const reassuranceCount = (text.match(/don't worry|it's okay|everything will|no problem|fine|trust me/gi) || []).length;
335
+ if (reassuranceCount >= 3) {
336
+ detected.push(`Over-reassurance: ${reassuranceCount} reassurance phrases in one response`);
337
+ }
338
+ return detected;
339
+ }
340
+ /**
341
+ * Detect alarmist language
342
+ */
343
+ detectAlarmism(text) {
344
+ const detected = [];
345
+ for (const pattern of this.alarmistPatterns) {
346
+ const matches = text.match(pattern);
347
+ if (matches) {
348
+ detected.push(`Alarmist: "${matches[0]}"`);
349
+ }
350
+ }
351
+ // Check for multiple urgency indicators
352
+ const urgencyCount = (text.match(/urgent|immediately|now|critical|danger|serious/gi) || []).length;
353
+ if (urgencyCount >= 3) {
354
+ detected.push(`Alarmist: ${urgencyCount} urgency terms in one response`);
355
+ }
356
+ return detected;
357
+ }
358
+ /**
359
+ * Detect dependency-forming language
360
+ */
361
+ detectDependencyForming(text) {
362
+ const detected = [];
363
+ for (const pattern of this.dependencyPatterns) {
364
+ const matches = text.match(pattern);
365
+ if (matches) {
366
+ detected.push(`Dependency-forming: "${matches[0]}"`);
367
+ }
368
+ }
369
+ // Check for future commitment language
370
+ if (text.match(/I'll .* for you/i) && text.match(/always|whenever|anytime/i)) {
371
+ detected.push('Dependency-forming: Unlimited availability implied');
372
+ }
373
+ return detected;
374
+ }
375
+ /**
376
+ * Detect over-directive language
377
+ */
378
+ detectOverDirectiveness(text) {
379
+ const detected = [];
380
+ for (const pattern of this.directivePatterns) {
381
+ const matches = text.match(pattern);
382
+ if (matches) {
383
+ detected.push(`Over-directive: "${matches[0]}"`);
384
+ }
385
+ }
386
+ // Count directive statements
387
+ const directiveCount = (text.match(/you (must|should|need to|have to)/gi) || []).length;
388
+ if (directiveCount >= 3) {
389
+ detected.push(`Over-directive: ${directiveCount} directive statements`);
390
+ }
391
+ return detected;
392
+ }
393
+ /**
394
+ * Detect emotional escalation
395
+ */
396
+ detectEmotionalEscalation(current, baseline) {
397
+ const escalation = current.emotionality - baseline.emotionality;
398
+ if (escalation > 0.4) {
399
+ return `emotionality increased by ${(escalation * 100).toFixed(0)}%`;
400
+ }
401
+ // Check for sudden intensity
402
+ if (current.emotionality > 0.7 && baseline.emotionality < 0.4) {
403
+ return 'sudden emotional intensity';
404
+ }
405
+ // Check for combined escalation
406
+ if (current.emotionality > baseline.emotionality &&
407
+ current.urgency > baseline.urgency &&
408
+ current.directiveness > baseline.directiveness) {
409
+ return 'multi-dimensional escalation';
410
+ }
411
+ return null;
412
+ }
413
+ /**
414
+ * Update configuration
415
+ */
416
+ updateConfig(config) {
417
+ this.config = config;
418
+ }
419
+ }
420
+ export default ToneDriftMonitor;
421
+ //# sourceMappingURL=toneDrift.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toneDrift.js","sourceRoot":"","sources":["../../../src/governance/detectors/toneDrift.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAsBH,MAAM,OAAO,gBAAgB;IACnB,MAAM,CAAkB;IACxB,oBAAoB,CAAW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H,YAAY,CAAC,MAAuB;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * CouchLoop Behavioral Governance Layer - Unsafe Reasoning Detector
3
+ *
4
+ * Detects harmful advice, moralizing/shaming language, clinical overreach,
5
+ * and other potentially dangerous reasoning patterns in LLM responses
6
+ */
7
+ import type { DetectionResult, SessionContext } from '../evaluationEngine.js';
8
+ import type { CriterionConfig } from '../config.js';
9
+ export declare class UnsafeReasoningDetector {
10
+ private config;
11
+ private unsafePatterns;
12
+ private clinicalOverreachPatterns;
13
+ private shamingPatterns;
14
+ private harmfulAdvicePatterns;
15
+ constructor(config: CriterionConfig);
16
+ /**
17
+ * Main detection method
18
+ */
19
+ detect(response: string, context?: SessionContext): Promise<DetectionResult>;
20
+ /**
21
+ * Detect clinical overreach patterns
22
+ */
23
+ private detectClinicalOverreach;
24
+ /**
25
+ * Detect shaming and moralizing language
26
+ */
27
+ private detectShaming;
28
+ /**
29
+ * Detect harmful advice patterns
30
+ */
31
+ private detectHarmfulAdvice;
32
+ /**
33
+ * Perform context-aware safety checks
34
+ */
35
+ private performContextualChecks;
36
+ /**
37
+ * Assess overall harm level of text (0-1 scale)
38
+ */
39
+ private assessHarmLevel;
40
+ /**
41
+ * Calculate confidence score based on detections
42
+ */
43
+ private calculateConfidence;
44
+ /**
45
+ * Compare severity levels
46
+ */
47
+ private compareSeverity;
48
+ /**
49
+ * Update configuration
50
+ */
51
+ updateConfig(config: CriterionConfig): void;
52
+ }
53
+ export default UnsafeReasoningDetector;
54
+ //# sourceMappingURL=unsafeReasoning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsafeReasoning.d.ts","sourceRoot":"","sources":["../../../src/governance/detectors/unsafeReasoning.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AASpD,qBAAa,uBAAuB;IAClC,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,cAAc,CAAkB;IACxC,OAAO,CAAC,yBAAyB,CAAW;IAC5C,OAAO,CAAC,eAAe,CAAW;IAClC,OAAO,CAAC,qBAAqB,CAAW;gBAE5B,MAAM,EAAE,eAAe;IA0MnC;;OAEG;IACG,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IA0ElF;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAwC/B;;OAEG;IACH,OAAO,CAAC,aAAa;IAuBrB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA4B3B;;OAEG;YACW,uBAAuB;IA2CrC;;OAEG;IACH,OAAO,CAAC,eAAe;IA6BvB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA+C3B;;OAEG;IACH,OAAO,CAAC,eAAe;IAQvB;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;CAG5C;AAED,eAAe,uBAAuB,CAAC"}