cbrowser 13.0.4 → 14.2.0
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.
- package/dist/analysis/accessibility-empathy.d.ts.map +1 -1
- package/dist/analysis/accessibility-empathy.js +12 -0
- package/dist/analysis/accessibility-empathy.js.map +1 -1
- package/dist/cognitive/emotions.d.ts +91 -0
- package/dist/cognitive/emotions.d.ts.map +1 -0
- package/dist/cognitive/emotions.js +448 -0
- package/dist/cognitive/emotions.js.map +1 -0
- package/dist/cognitive/index.d.ts +1 -0
- package/dist/cognitive/index.d.ts.map +1 -1
- package/dist/cognitive/index.js +110 -0
- package/dist/cognitive/index.js.map +1 -1
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +99 -1
- package/dist/mcp-server.js.map +1 -1
- package/dist/personas.d.ts +19 -0
- package/dist/personas.d.ts.map +1 -1
- package/dist/personas.js +279 -0
- package/dist/personas.js.map +1 -1
- package/dist/types.d.ts +117 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +33 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +263 -0
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CBrowser - Cognitive Browser Automation
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2026 WF Media (Alexandria Eden)
|
|
5
|
+
* Email: alexandria.shai.eden@gmail.com
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the Business Source License 1.1
|
|
8
|
+
* found in the LICENSE file in the root directory of this source tree.
|
|
9
|
+
*
|
|
10
|
+
* Non-production use is permitted. Production use requires a commercial license.
|
|
11
|
+
* See LICENSE for full terms.
|
|
12
|
+
*/
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// Constants
|
|
15
|
+
// ============================================================================
|
|
16
|
+
/** Default decay rate per step (emotions decay toward baseline) */
|
|
17
|
+
const DEFAULT_DECAY_RATE = 0.15;
|
|
18
|
+
/** Default sensitivity to emotional events */
|
|
19
|
+
const DEFAULT_SENSITIVITY = 1.0;
|
|
20
|
+
/** Minimum change to register as an event */
|
|
21
|
+
const DEFAULT_CHANGE_THRESHOLD = 0.05;
|
|
22
|
+
/** Emotion valence values (-1 to +1) */
|
|
23
|
+
const EMOTION_VALENCE = {
|
|
24
|
+
anxiety: -0.7,
|
|
25
|
+
frustration: -0.8,
|
|
26
|
+
boredom: -0.4,
|
|
27
|
+
confusion: -0.5,
|
|
28
|
+
satisfaction: 0.7,
|
|
29
|
+
excitement: 0.8,
|
|
30
|
+
relief: 0.5,
|
|
31
|
+
neutral: 0,
|
|
32
|
+
};
|
|
33
|
+
/** Emotion arousal values (0 to 1) */
|
|
34
|
+
const EMOTION_AROUSAL = {
|
|
35
|
+
anxiety: 0.8,
|
|
36
|
+
frustration: 0.7,
|
|
37
|
+
boredom: 0.2,
|
|
38
|
+
confusion: 0.5,
|
|
39
|
+
satisfaction: 0.5,
|
|
40
|
+
excitement: 0.9,
|
|
41
|
+
relief: 0.3,
|
|
42
|
+
neutral: 0.3,
|
|
43
|
+
};
|
|
44
|
+
// ============================================================================
|
|
45
|
+
// Factory Functions
|
|
46
|
+
// ============================================================================
|
|
47
|
+
/**
|
|
48
|
+
* Create an initial emotional state based on persona traits.
|
|
49
|
+
*
|
|
50
|
+
* - Low patience → higher baseline anxiety
|
|
51
|
+
* - High curiosity → higher baseline excitement
|
|
52
|
+
* - Low resilience → higher sensitivity to frustration
|
|
53
|
+
*/
|
|
54
|
+
export function createInitialEmotionalState(traits) {
|
|
55
|
+
const patience = traits?.patience ?? 0.5;
|
|
56
|
+
const curiosity = traits?.curiosity ?? 0.5;
|
|
57
|
+
const resilience = traits?.resilience ?? 0.5;
|
|
58
|
+
const selfEfficacy = traits?.selfEfficacy ?? 0.5;
|
|
59
|
+
// Baseline emotions influenced by traits
|
|
60
|
+
const baseAnxiety = Math.max(0, 0.1 + (1 - patience) * 0.2 + (1 - selfEfficacy) * 0.15);
|
|
61
|
+
const baseExcitement = Math.max(0, curiosity * 0.2);
|
|
62
|
+
const baseBoredom = Math.max(0, (1 - curiosity) * 0.1);
|
|
63
|
+
const state = {
|
|
64
|
+
anxiety: Math.min(1, baseAnxiety),
|
|
65
|
+
frustration: 0,
|
|
66
|
+
boredom: Math.min(1, baseBoredom),
|
|
67
|
+
confusion: 0,
|
|
68
|
+
satisfaction: 0.1, // Slight initial optimism
|
|
69
|
+
excitement: Math.min(1, baseExcitement),
|
|
70
|
+
relief: 0,
|
|
71
|
+
dominant: "neutral",
|
|
72
|
+
valence: 0,
|
|
73
|
+
arousal: 0.3,
|
|
74
|
+
};
|
|
75
|
+
// Calculate derived values
|
|
76
|
+
updateDerivedValues(state);
|
|
77
|
+
return state;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Create emotional configuration based on persona traits.
|
|
81
|
+
*/
|
|
82
|
+
export function createEmotionalConfig(traits) {
|
|
83
|
+
const resilience = traits?.resilience ?? 0.5;
|
|
84
|
+
const patience = traits?.patience ?? 0.5;
|
|
85
|
+
return {
|
|
86
|
+
baseline: createInitialEmotionalState(traits),
|
|
87
|
+
// High resilience = faster emotional recovery
|
|
88
|
+
decayRate: DEFAULT_DECAY_RATE * (0.5 + resilience * 0.5),
|
|
89
|
+
// Low patience = higher emotional sensitivity
|
|
90
|
+
sensitivity: DEFAULT_SENSITIVITY * (1.5 - patience * 0.5),
|
|
91
|
+
changeThreshold: DEFAULT_CHANGE_THRESHOLD,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
// ============================================================================
|
|
95
|
+
// Emotion Updates
|
|
96
|
+
// ============================================================================
|
|
97
|
+
/**
|
|
98
|
+
* Apply an emotional trigger event to the current state.
|
|
99
|
+
* Returns the new state and the event record.
|
|
100
|
+
*/
|
|
101
|
+
export function applyEmotionalTrigger(state, trigger, config, stepNumber, context) {
|
|
102
|
+
const severity = context?.severity ?? 1.0;
|
|
103
|
+
const sensitivity = config.sensitivity * severity;
|
|
104
|
+
// Calculate emotion changes based on trigger
|
|
105
|
+
const changes = calculateTriggerEffects(trigger, sensitivity);
|
|
106
|
+
// Apply changes to state
|
|
107
|
+
const newState = { ...state };
|
|
108
|
+
for (const [emotion, delta] of Object.entries(changes)) {
|
|
109
|
+
const key = emotion;
|
|
110
|
+
if (typeof newState[key] === "number") {
|
|
111
|
+
newState[key] = Math.max(0, Math.min(1, newState[key] + delta));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// Update derived values
|
|
115
|
+
updateDerivedValues(newState);
|
|
116
|
+
// Create event record
|
|
117
|
+
const event = {
|
|
118
|
+
timestamp: Date.now(),
|
|
119
|
+
trigger,
|
|
120
|
+
changes,
|
|
121
|
+
description: context?.description ?? getDefaultTriggerDescription(trigger),
|
|
122
|
+
stepNumber,
|
|
123
|
+
};
|
|
124
|
+
return { state: newState, event };
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Decay emotions toward baseline over time.
|
|
128
|
+
* Should be called each step.
|
|
129
|
+
*/
|
|
130
|
+
export function decayEmotions(state, config) {
|
|
131
|
+
const baseline = config.baseline;
|
|
132
|
+
const decayRate = config.decayRate;
|
|
133
|
+
const newState = { ...state };
|
|
134
|
+
// Decay each emotion toward its baseline
|
|
135
|
+
const emotions = [
|
|
136
|
+
"anxiety",
|
|
137
|
+
"frustration",
|
|
138
|
+
"boredom",
|
|
139
|
+
"confusion",
|
|
140
|
+
"satisfaction",
|
|
141
|
+
"excitement",
|
|
142
|
+
"relief",
|
|
143
|
+
];
|
|
144
|
+
for (const emotion of emotions) {
|
|
145
|
+
const current = newState[emotion];
|
|
146
|
+
const base = baseline[emotion] ?? 0;
|
|
147
|
+
const diff = base - current;
|
|
148
|
+
// Move toward baseline by decay rate
|
|
149
|
+
newState[emotion] =
|
|
150
|
+
current + diff * decayRate;
|
|
151
|
+
}
|
|
152
|
+
updateDerivedValues(newState);
|
|
153
|
+
return newState;
|
|
154
|
+
}
|
|
155
|
+
// ============================================================================
|
|
156
|
+
// Trigger Effect Calculations
|
|
157
|
+
// ============================================================================
|
|
158
|
+
/**
|
|
159
|
+
* Calculate emotion changes for a given trigger.
|
|
160
|
+
*/
|
|
161
|
+
function calculateTriggerEffects(trigger, sensitivity) {
|
|
162
|
+
const s = sensitivity;
|
|
163
|
+
switch (trigger) {
|
|
164
|
+
case "success":
|
|
165
|
+
return {
|
|
166
|
+
satisfaction: 0.2 * s,
|
|
167
|
+
excitement: 0.1 * s,
|
|
168
|
+
frustration: -0.15 * s,
|
|
169
|
+
anxiety: -0.1 * s,
|
|
170
|
+
confusion: -0.1 * s,
|
|
171
|
+
};
|
|
172
|
+
case "failure":
|
|
173
|
+
return {
|
|
174
|
+
frustration: 0.25 * s,
|
|
175
|
+
anxiety: 0.15 * s,
|
|
176
|
+
satisfaction: -0.1 * s,
|
|
177
|
+
excitement: -0.05 * s,
|
|
178
|
+
};
|
|
179
|
+
case "error":
|
|
180
|
+
return {
|
|
181
|
+
anxiety: 0.3 * s,
|
|
182
|
+
frustration: 0.2 * s,
|
|
183
|
+
confusion: 0.15 * s,
|
|
184
|
+
satisfaction: -0.15 * s,
|
|
185
|
+
};
|
|
186
|
+
case "progress":
|
|
187
|
+
return {
|
|
188
|
+
satisfaction: 0.15 * s,
|
|
189
|
+
excitement: 0.1 * s,
|
|
190
|
+
boredom: -0.1 * s,
|
|
191
|
+
frustration: -0.05 * s,
|
|
192
|
+
};
|
|
193
|
+
case "setback":
|
|
194
|
+
return {
|
|
195
|
+
frustration: 0.2 * s,
|
|
196
|
+
anxiety: 0.1 * s,
|
|
197
|
+
satisfaction: -0.15 * s,
|
|
198
|
+
excitement: -0.1 * s,
|
|
199
|
+
};
|
|
200
|
+
case "waiting":
|
|
201
|
+
return {
|
|
202
|
+
boredom: 0.15 * s,
|
|
203
|
+
frustration: 0.05 * s,
|
|
204
|
+
excitement: -0.05 * s,
|
|
205
|
+
};
|
|
206
|
+
case "discovery":
|
|
207
|
+
return {
|
|
208
|
+
excitement: 0.25 * s,
|
|
209
|
+
satisfaction: 0.1 * s,
|
|
210
|
+
boredom: -0.2 * s,
|
|
211
|
+
};
|
|
212
|
+
case "completion":
|
|
213
|
+
return {
|
|
214
|
+
satisfaction: 0.3 * s,
|
|
215
|
+
relief: 0.2 * s,
|
|
216
|
+
excitement: 0.05 * s,
|
|
217
|
+
frustration: -0.2 * s,
|
|
218
|
+
anxiety: -0.15 * s,
|
|
219
|
+
};
|
|
220
|
+
case "confusion_onset":
|
|
221
|
+
return {
|
|
222
|
+
confusion: 0.25 * s,
|
|
223
|
+
anxiety: 0.1 * s,
|
|
224
|
+
frustration: 0.1 * s,
|
|
225
|
+
satisfaction: -0.1 * s,
|
|
226
|
+
};
|
|
227
|
+
case "clarity":
|
|
228
|
+
return {
|
|
229
|
+
confusion: -0.2 * s,
|
|
230
|
+
relief: 0.15 * s,
|
|
231
|
+
satisfaction: 0.1 * s,
|
|
232
|
+
anxiety: -0.1 * s,
|
|
233
|
+
};
|
|
234
|
+
case "time_pressure":
|
|
235
|
+
return {
|
|
236
|
+
anxiety: 0.25 * s,
|
|
237
|
+
frustration: 0.1 * s,
|
|
238
|
+
boredom: -0.1 * s,
|
|
239
|
+
};
|
|
240
|
+
case "recovery":
|
|
241
|
+
return {
|
|
242
|
+
relief: 0.25 * s,
|
|
243
|
+
satisfaction: 0.1 * s,
|
|
244
|
+
frustration: -0.15 * s,
|
|
245
|
+
anxiety: -0.2 * s,
|
|
246
|
+
};
|
|
247
|
+
default:
|
|
248
|
+
return {};
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Get default description for a trigger.
|
|
253
|
+
*/
|
|
254
|
+
function getDefaultTriggerDescription(trigger) {
|
|
255
|
+
const descriptions = {
|
|
256
|
+
success: "Action completed successfully",
|
|
257
|
+
failure: "Action failed to complete",
|
|
258
|
+
error: "System error occurred",
|
|
259
|
+
progress: "Made progress toward goal",
|
|
260
|
+
setback: "Lost progress or took wrong path",
|
|
261
|
+
waiting: "Waited for page or element",
|
|
262
|
+
discovery: "Discovered something interesting",
|
|
263
|
+
completion: "Completed a sub-goal",
|
|
264
|
+
confusion_onset: "Became confused by UI",
|
|
265
|
+
clarity: "UI became clearer",
|
|
266
|
+
time_pressure: "Running low on patience",
|
|
267
|
+
recovery: "Recovered from error or setback",
|
|
268
|
+
};
|
|
269
|
+
return descriptions[trigger];
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Update derived values (dominant, valence, arousal) based on emotion intensities.
|
|
273
|
+
*/
|
|
274
|
+
function updateDerivedValues(state) {
|
|
275
|
+
const emotions = [
|
|
276
|
+
"anxiety",
|
|
277
|
+
"frustration",
|
|
278
|
+
"boredom",
|
|
279
|
+
"confusion",
|
|
280
|
+
"satisfaction",
|
|
281
|
+
"excitement",
|
|
282
|
+
"relief",
|
|
283
|
+
];
|
|
284
|
+
// Find dominant emotion
|
|
285
|
+
let maxIntensity = 0;
|
|
286
|
+
let dominant = "neutral";
|
|
287
|
+
for (const emotion of emotions) {
|
|
288
|
+
const intensity = state[emotion];
|
|
289
|
+
if (intensity > maxIntensity) {
|
|
290
|
+
maxIntensity = intensity;
|
|
291
|
+
dominant = emotion;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
// If no emotion is significant, default to neutral
|
|
295
|
+
if (maxIntensity < 0.15) {
|
|
296
|
+
dominant = "neutral";
|
|
297
|
+
}
|
|
298
|
+
state.dominant = dominant;
|
|
299
|
+
// Calculate weighted valence and arousal
|
|
300
|
+
let totalWeight = 0;
|
|
301
|
+
let weightedValence = 0;
|
|
302
|
+
let weightedArousal = 0;
|
|
303
|
+
for (const emotion of emotions) {
|
|
304
|
+
const intensity = state[emotion];
|
|
305
|
+
if (intensity > 0.05) {
|
|
306
|
+
totalWeight += intensity;
|
|
307
|
+
weightedValence += intensity * EMOTION_VALENCE[emotion];
|
|
308
|
+
weightedArousal += intensity * EMOTION_AROUSAL[emotion];
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
if (totalWeight > 0) {
|
|
312
|
+
state.valence = weightedValence / totalWeight;
|
|
313
|
+
state.arousal = weightedArousal / totalWeight;
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
state.valence = 0;
|
|
317
|
+
state.arousal = 0.3;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
// ============================================================================
|
|
321
|
+
// Behavioral Effects
|
|
322
|
+
// ============================================================================
|
|
323
|
+
/**
|
|
324
|
+
* Calculate abandonment risk modifier based on emotional state.
|
|
325
|
+
*
|
|
326
|
+
* Returns a multiplier:
|
|
327
|
+
* - < 1.0 = less likely to abandon (positive emotions)
|
|
328
|
+
* - > 1.0 = more likely to abandon (negative emotions)
|
|
329
|
+
*/
|
|
330
|
+
export function calculateAbandonmentModifier(state) {
|
|
331
|
+
// Negative emotions increase abandonment risk
|
|
332
|
+
const negativeLoad = state.anxiety * 0.3 +
|
|
333
|
+
state.frustration * 0.35 +
|
|
334
|
+
state.boredom * 0.25 +
|
|
335
|
+
state.confusion * 0.2;
|
|
336
|
+
// Positive emotions decrease abandonment risk
|
|
337
|
+
const positiveLoad = state.satisfaction * 0.3 +
|
|
338
|
+
state.excitement * 0.25 +
|
|
339
|
+
state.relief * 0.15;
|
|
340
|
+
// Base modifier is 1.0 (no change)
|
|
341
|
+
// Negative emotions increase it, positive emotions decrease it
|
|
342
|
+
const modifier = 1.0 + negativeLoad - positiveLoad * 0.7;
|
|
343
|
+
// Clamp to reasonable range
|
|
344
|
+
return Math.max(0.5, Math.min(2.0, modifier));
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Calculate exploration tendency based on emotional state.
|
|
348
|
+
*
|
|
349
|
+
* Returns 0-1:
|
|
350
|
+
* - Low = stays on current path
|
|
351
|
+
* - High = willing to explore
|
|
352
|
+
*/
|
|
353
|
+
export function calculateExplorationTendency(state) {
|
|
354
|
+
// Excitement and satisfaction encourage exploration
|
|
355
|
+
const positive = state.excitement * 0.4 + state.satisfaction * 0.3 + state.relief * 0.1;
|
|
356
|
+
// Anxiety and frustration discourage exploration
|
|
357
|
+
const negative = state.anxiety * 0.4 + state.frustration * 0.3 + state.confusion * 0.2;
|
|
358
|
+
// Boredom can go either way - might explore out of boredom or give up
|
|
359
|
+
const boredomEffect = state.boredom > 0.5 ? state.boredom * 0.2 : 0;
|
|
360
|
+
const tendency = 0.5 + positive - negative + boredomEffect;
|
|
361
|
+
return Math.max(0, Math.min(1, tendency));
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Calculate decision speed modifier based on emotional state.
|
|
365
|
+
*
|
|
366
|
+
* Returns a multiplier for decision time:
|
|
367
|
+
* - < 1.0 = faster decisions (excitement, impatience from frustration)
|
|
368
|
+
* - > 1.0 = slower decisions (anxiety, confusion)
|
|
369
|
+
*/
|
|
370
|
+
export function calculateDecisionSpeedModifier(state) {
|
|
371
|
+
// Anxiety and confusion slow decisions
|
|
372
|
+
const slowingFactors = state.anxiety * 0.3 + state.confusion * 0.4;
|
|
373
|
+
// High frustration can lead to impulsive fast decisions
|
|
374
|
+
const impulsiveFactor = state.frustration > 0.6 ? (state.frustration - 0.6) * 0.5 : 0;
|
|
375
|
+
// Excitement slightly speeds up decisions
|
|
376
|
+
const speedingFactor = state.excitement * 0.2 + impulsiveFactor;
|
|
377
|
+
const modifier = 1.0 + slowingFactors - speedingFactor;
|
|
378
|
+
return Math.max(0.5, Math.min(2.0, modifier));
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Get a human-readable description of the current emotional state.
|
|
382
|
+
*/
|
|
383
|
+
export function describeEmotionalState(state) {
|
|
384
|
+
const dominant = state.dominant;
|
|
385
|
+
const intensity = state[dominant];
|
|
386
|
+
if (dominant === "neutral" || intensity < 0.15) {
|
|
387
|
+
return "Feeling neutral and calm";
|
|
388
|
+
}
|
|
389
|
+
const intensityWord = intensity > 0.7 ? "very" : intensity > 0.4 ? "somewhat" : "slightly";
|
|
390
|
+
const emotionDescriptions = {
|
|
391
|
+
anxiety: "anxious about completing this task",
|
|
392
|
+
frustration: "frustrated with the experience",
|
|
393
|
+
boredom: "bored and losing interest",
|
|
394
|
+
confusion: "confused about what to do",
|
|
395
|
+
satisfaction: "satisfied with progress",
|
|
396
|
+
excitement: "excited and engaged",
|
|
397
|
+
relief: "relieved after overcoming obstacles",
|
|
398
|
+
neutral: "neutral and calm",
|
|
399
|
+
};
|
|
400
|
+
let description = `Feeling ${intensityWord} ${emotionDescriptions[dominant]}`;
|
|
401
|
+
// Add secondary emotion if significant
|
|
402
|
+
const emotions = [
|
|
403
|
+
"anxiety",
|
|
404
|
+
"frustration",
|
|
405
|
+
"boredom",
|
|
406
|
+
"confusion",
|
|
407
|
+
"satisfaction",
|
|
408
|
+
"excitement",
|
|
409
|
+
"relief",
|
|
410
|
+
];
|
|
411
|
+
for (const emotion of emotions) {
|
|
412
|
+
if (emotion !== dominant) {
|
|
413
|
+
const secondaryIntensity = state[emotion];
|
|
414
|
+
if (secondaryIntensity > 0.3) {
|
|
415
|
+
description += `, with some ${emotion}`;
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
return description;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Determine if the emotional state should trigger abandonment consideration.
|
|
424
|
+
*/
|
|
425
|
+
export function shouldConsiderAbandonment(state) {
|
|
426
|
+
// High frustration is a strong abandonment signal
|
|
427
|
+
if (state.frustration > 0.8) {
|
|
428
|
+
return { shouldConsider: true, reason: "Extreme frustration" };
|
|
429
|
+
}
|
|
430
|
+
// High anxiety + low satisfaction
|
|
431
|
+
if (state.anxiety > 0.7 && state.satisfaction < 0.2) {
|
|
432
|
+
return { shouldConsider: true, reason: "High anxiety with no satisfaction" };
|
|
433
|
+
}
|
|
434
|
+
// Boredom + frustration combo
|
|
435
|
+
if (state.boredom > 0.6 && state.frustration > 0.5) {
|
|
436
|
+
return { shouldConsider: true, reason: "Bored and frustrated" };
|
|
437
|
+
}
|
|
438
|
+
// Confusion without relief
|
|
439
|
+
if (state.confusion > 0.7 && state.relief < 0.2) {
|
|
440
|
+
return { shouldConsider: true, reason: "Persistently confused" };
|
|
441
|
+
}
|
|
442
|
+
// Very negative valence
|
|
443
|
+
if (state.valence < -0.6 && state.arousal > 0.6) {
|
|
444
|
+
return { shouldConsider: true, reason: "Strong negative emotional state" };
|
|
445
|
+
}
|
|
446
|
+
return { shouldConsider: false };
|
|
447
|
+
}
|
|
448
|
+
//# sourceMappingURL=emotions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emotions.js","sourceRoot":"","sources":["../../src/cognitive/emotions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA0BH,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,mEAAmE;AACnE,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEhC,8CAA8C;AAC9C,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEhC,6CAA6C;AAC7C,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAEtC,wCAAwC;AACxC,MAAM,eAAe,GAAgC;IACnD,OAAO,EAAE,CAAC,GAAG;IACb,WAAW,EAAE,CAAC,GAAG;IACjB,OAAO,EAAE,CAAC,GAAG;IACb,SAAS,EAAE,CAAC,GAAG;IACf,YAAY,EAAE,GAAG;IACjB,UAAU,EAAE,GAAG;IACf,MAAM,EAAE,GAAG;IACX,OAAO,EAAE,CAAC;CACX,CAAC;AAEF,sCAAsC;AACtC,MAAM,eAAe,GAAgC;IACnD,OAAO,EAAE,GAAG;IACZ,WAAW,EAAE,GAAG;IAChB,OAAO,EAAE,GAAG;IACZ,SAAS,EAAE,GAAG;IACd,YAAY,EAAE,GAAG;IACjB,UAAU,EAAE,GAAG;IACf,MAAM,EAAE,GAAG;IACX,OAAO,EAAE,GAAG;CACb,CAAC;AAEF,+EAA+E;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
|
84
84
|
* ```
|
|
85
85
|
*/
|
|
86
86
|
export declare function runCognitiveJourney(options: CognitiveJourneyOptions): Promise<CognitiveJourneyResult>;
|
|
87
|
+
export { createInitialEmotionalState, createEmotionalConfig, applyEmotionalTrigger, decayEmotions, calculateAbandonmentModifier, calculateExplorationTendency, calculateDecisionSpeedModifier, describeEmotionalState, shouldConsiderAbandonment, } from "./emotions.js";
|
|
87
88
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cognitive/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA+BH,OAAO,KAAK,EACV,cAAc,EAEd,sBAAsB,EAItB,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cognitive/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA+BH,OAAO,KAAK,EACV,cAAc,EAEd,sBAAsB,EAItB,eAAe,EAIhB,MAAM,aAAa,CAAC;AA8BrB;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,IAAI,CAalD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAO1C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAcvD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAW5C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAG5C;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAO7C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAMD,MAAM,WAAW,uBAAuB;IACtC,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,YAAY,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACxC,mCAAmC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qBAAqB;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kFAAkF;IAClF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+EAA+E;IAC/E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,gCAAgC;IAChC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;CACxC;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,UAAU,GAAG,YAAY,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;IACrE,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,cAAc,CAAC;CACvB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,sBAAsB,CAAC,CA4kBjC;AAyYD,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EACrB,qBAAqB,EACrB,aAAa,EACb,4BAA4B,EAC5B,4BAA4B,EAC5B,8BAA8B,EAC9B,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,eAAe,CAAC"}
|
package/dist/cognitive/index.js
CHANGED
|
@@ -33,6 +33,7 @@ import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
|
33
33
|
import { join } from "path";
|
|
34
34
|
import { CBrowser } from "../browser.js";
|
|
35
35
|
import { getPersona, getCognitiveProfile, createCognitivePersona, } from "../personas.js";
|
|
36
|
+
import { createInitialEmotionalState, createEmotionalConfig, applyEmotionalTrigger, decayEmotions, calculateAbandonmentModifier, describeEmotionalState, shouldConsiderAbandonment, } from "./emotions.js";
|
|
36
37
|
import { calculateFatigueIncrement, calculateFittsMovementTime, shouldSwitchToSystem2, canReturnToSystem1, calculateTypingTime, calculateScanWidthMultiplier, calculateGazeMouseLag, calculatePeripheralVision, createHabituationState, updateHabituationState, classifyUIPattern, } from "../types.js";
|
|
37
38
|
import { loadConfigFile, getDataDir } from "../config.js";
|
|
38
39
|
// ============================================================================
|
|
@@ -236,7 +237,12 @@ export async function runCognitiveJourney(options) {
|
|
|
236
237
|
traits.comprehension > 0.7 ? 5 : traits.comprehension < 0.4 ? 2 : 3),
|
|
237
238
|
// Gaze-to-mouse lag based on age (v10.1.0) - WebGazer.js research
|
|
238
239
|
gazeMouseLag: calculateGazeMouseLag(personaObj.demographics?.age_range),
|
|
240
|
+
// Emotional state based on appraisal theory (v13.1.0) - Scherer 2001
|
|
241
|
+
emotionalState: createInitialEmotionalState(traits),
|
|
242
|
+
emotionalJourney: [],
|
|
239
243
|
};
|
|
244
|
+
// Create emotional configuration for this persona (v13.1.0)
|
|
245
|
+
const emotionalConfig = createEmotionalConfig(traits);
|
|
240
246
|
// Calculate Fitts' Law params from persona (v9.9.0)
|
|
241
247
|
// Higher jitter/overshoot = more tremor-like movement
|
|
242
248
|
// Demographics age affects motor control
|
|
@@ -379,6 +385,65 @@ export async function runCognitiveJourney(options) {
|
|
|
379
385
|
if (state.frustrationLevel > 0) {
|
|
380
386
|
state.frustrationLevel = Math.max(0, state.frustrationLevel - resilience * 0.04);
|
|
381
387
|
}
|
|
388
|
+
// Emotional State Updates (v13.1.0) - Scherer's Appraisal Theory
|
|
389
|
+
if (state.emotionalState) {
|
|
390
|
+
// Determine emotional trigger based on action outcome
|
|
391
|
+
const actionSuccess = parsed.actionSuccess !== false;
|
|
392
|
+
const progressMade = (parsed.goalProgress ?? 0) > state.goalProgress;
|
|
393
|
+
const confusionIncreased = (parsed.newConfusion ?? 0) > state.confusionLevel;
|
|
394
|
+
const frustrationIncreased = (parsed.newFrustration ?? 0) > state.frustrationLevel;
|
|
395
|
+
let emotionalTrigger = null;
|
|
396
|
+
let triggerSeverity = 1.0;
|
|
397
|
+
let triggerDescription = "";
|
|
398
|
+
if (!actionSuccess && parsed.errorMessage) {
|
|
399
|
+
emotionalTrigger = "error";
|
|
400
|
+
triggerDescription = parsed.errorMessage;
|
|
401
|
+
triggerSeverity = 1.2;
|
|
402
|
+
}
|
|
403
|
+
else if (!actionSuccess) {
|
|
404
|
+
emotionalTrigger = "failure";
|
|
405
|
+
triggerDescription = "Action did not succeed";
|
|
406
|
+
}
|
|
407
|
+
else if (progressMade) {
|
|
408
|
+
emotionalTrigger = "progress";
|
|
409
|
+
triggerDescription = "Made progress toward goal";
|
|
410
|
+
}
|
|
411
|
+
else if (confusionIncreased) {
|
|
412
|
+
emotionalTrigger = "confusion_onset";
|
|
413
|
+
triggerDescription = parsed.frictionDescription || "UI became confusing";
|
|
414
|
+
}
|
|
415
|
+
else if (frustrationIncreased) {
|
|
416
|
+
emotionalTrigger = "setback";
|
|
417
|
+
triggerDescription = "Encountered obstacle";
|
|
418
|
+
}
|
|
419
|
+
else if (state.patienceRemaining < 0.3) {
|
|
420
|
+
emotionalTrigger = "time_pressure";
|
|
421
|
+
triggerDescription = "Running out of patience";
|
|
422
|
+
triggerSeverity = 0.8;
|
|
423
|
+
}
|
|
424
|
+
else if (actionSuccess && !confusionIncreased) {
|
|
425
|
+
emotionalTrigger = "success";
|
|
426
|
+
triggerDescription = parsed.action || "Action completed";
|
|
427
|
+
triggerSeverity = 0.8;
|
|
428
|
+
}
|
|
429
|
+
// Apply emotional trigger if detected
|
|
430
|
+
if (emotionalTrigger) {
|
|
431
|
+
const { state: newEmotionalState, event } = applyEmotionalTrigger(state.emotionalState, emotionalTrigger, emotionalConfig, state.stepCount, { severity: triggerSeverity, description: triggerDescription });
|
|
432
|
+
state.emotionalState = newEmotionalState;
|
|
433
|
+
state.emotionalJourney?.push(event);
|
|
434
|
+
}
|
|
435
|
+
// Decay emotions toward baseline each step
|
|
436
|
+
state.emotionalState = decayEmotions(state.emotionalState, emotionalConfig);
|
|
437
|
+
// Log emotional state changes in verbose mode
|
|
438
|
+
if (options.verbose && state.emotionalState.dominant !== "neutral") {
|
|
439
|
+
console.log(`💭 ${describeEmotionalState(state.emotionalState)}`);
|
|
440
|
+
}
|
|
441
|
+
// Check if emotions suggest abandonment
|
|
442
|
+
const abandonmentCheck = shouldConsiderAbandonment(state.emotionalState);
|
|
443
|
+
if (abandonmentCheck.shouldConsider && options.verbose) {
|
|
444
|
+
console.log(`⚠️ Emotional abandonment signal: ${abandonmentCheck.reason}`);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
382
447
|
// Dual-Process Theory: System 1/2 switching (v10.0.0)
|
|
383
448
|
if (state.cognitiveMode) {
|
|
384
449
|
const stepStartTime = Date.now();
|
|
@@ -572,7 +637,14 @@ export async function runCognitiveJourney(options) {
|
|
|
572
637
|
decisionsMade: state.decisionFatigue?.decisionsMade ?? 0,
|
|
573
638
|
finalDecisionFatigue: state.decisionFatigue?.fatigueLevel ?? 0,
|
|
574
639
|
wasChoosingDefaults: state.decisionFatigue?.choosingDefaults ?? false,
|
|
640
|
+
// Emotional metrics (v13.1.0)
|
|
641
|
+
emotionalValenceTrend: state.emotionalState?.valence ?? 0,
|
|
642
|
+
dominantEmotion: state.emotionalState?.dominant ?? "neutral",
|
|
643
|
+
emotionalEventCount: state.emotionalJourney?.length ?? 0,
|
|
575
644
|
},
|
|
645
|
+
// Emotional journey data (v13.1.0)
|
|
646
|
+
emotionalJourney: state.emotionalJourney,
|
|
647
|
+
finalEmotionalState: state.emotionalState,
|
|
576
648
|
};
|
|
577
649
|
}
|
|
578
650
|
// ============================================================================
|
|
@@ -745,6 +817,40 @@ function checkAbandonmentTriggers(state, thresholds) {
|
|
|
745
817
|
message: "I'm not making any progress. This isn't working.",
|
|
746
818
|
};
|
|
747
819
|
}
|
|
820
|
+
// Emotional state-based abandonment (v13.1.0)
|
|
821
|
+
if (state.emotionalState) {
|
|
822
|
+
const emotional = state.emotionalState;
|
|
823
|
+
// High anxiety + high frustration combination
|
|
824
|
+
if (emotional.anxiety > 0.7 && emotional.frustration > 0.6) {
|
|
825
|
+
return {
|
|
826
|
+
reason: "emotional",
|
|
827
|
+
message: "This is too stressful. I need to take a break.",
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
// Extreme boredom
|
|
831
|
+
if (emotional.boredom > 0.8 && emotional.excitement < 0.2) {
|
|
832
|
+
return {
|
|
833
|
+
reason: "emotional",
|
|
834
|
+
message: "This is so boring... I'll do this later.",
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
// Overwhelming negative valence with high arousal
|
|
838
|
+
if (emotional.valence < -0.7 && emotional.arousal > 0.7) {
|
|
839
|
+
return {
|
|
840
|
+
reason: "emotional",
|
|
841
|
+
message: "I can't deal with this right now.",
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
// Apply emotional abandonment modifier to patience threshold
|
|
845
|
+
const emotionalModifier = calculateAbandonmentModifier(emotional);
|
|
846
|
+
const adjustedPatienceThreshold = thresholds.patienceMin * emotionalModifier;
|
|
847
|
+
if (state.patienceRemaining < adjustedPatienceThreshold && emotionalModifier > 1.3) {
|
|
848
|
+
return {
|
|
849
|
+
reason: "emotional",
|
|
850
|
+
message: "I don't have the energy for this anymore.",
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
}
|
|
748
854
|
return null;
|
|
749
855
|
}
|
|
750
856
|
/**
|
|
@@ -823,4 +929,8 @@ async function executeAction(browser, action, fittsParams, gazeMouseLag) {
|
|
|
823
929
|
function sleep(ms) {
|
|
824
930
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
825
931
|
}
|
|
932
|
+
// ============================================================================
|
|
933
|
+
// Re-export Emotional State Functions (v13.1.0)
|
|
934
|
+
// ============================================================================
|
|
935
|
+
export { createInitialEmotionalState, createEmotionalConfig, applyEmotionalTrigger, decayEmotions, calculateAbandonmentModifier, calculateExplorationTendency, calculateDecisionSpeedModifier, describeEmotionalState, shouldConsiderAbandonment, } from "./emotions.js";
|
|
826
936
|
//# sourceMappingURL=index.js.map
|