cbrowser 18.40.0 → 18.42.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/mcp-tools/base/persona-comparison-tools.d.ts +1 -1
- package/dist/mcp-tools/base/persona-comparison-tools.d.ts.map +1 -1
- package/dist/mcp-tools/base/persona-comparison-tools.js +166 -1
- package/dist/mcp-tools/base/persona-comparison-tools.js.map +1 -1
- package/dist/visual/cognitive-models.d.ts +265 -0
- package/dist/visual/cognitive-models.d.ts.map +1 -0
- package/dist/visual/cognitive-models.js +447 -0
- package/dist/visual/cognitive-models.js.map +1 -0
- package/dist/visual/cognitive-transport-chain.d.ts +143 -0
- package/dist/visual/cognitive-transport-chain.d.ts.map +1 -0
- package/dist/visual/cognitive-transport-chain.js +440 -0
- package/dist/visual/cognitive-transport-chain.js.map +1 -0
- package/dist/visual/index.d.ts +2 -0
- package/dist/visual/index.d.ts.map +1 -1
- package/dist/visual/index.js +2 -0
- package/dist/visual/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cognitive Models — Formal implementations from cognitive science
|
|
3
|
+
*
|
|
4
|
+
* Layer 4: Grossman & Balakrishnan (2005) probabilistic pointing model
|
|
5
|
+
* Layer 6: Perry, Zorzi & Ziegler (2019) multi-deficit reading model
|
|
6
|
+
*
|
|
7
|
+
* These replace the heuristic multipliers in cognitive-transport.ts
|
|
8
|
+
* with empirically grounded computational models.
|
|
9
|
+
*
|
|
10
|
+
* @see Grossman & Balakrishnan (2005) ACM TOCHI — probabilistic 2D pointing
|
|
11
|
+
* @see Perry, Zorzi & Ziegler (2019) Psychological Science — personalized dyslexia models
|
|
12
|
+
* @since v18.39.0
|
|
13
|
+
*/
|
|
14
|
+
// ── Mathematical Primitives ──
|
|
15
|
+
/**
|
|
16
|
+
* Standard normal CDF (cumulative distribution function).
|
|
17
|
+
* Abramowitz and Stegun approximation (7.1.26), error < 7.5e-8.
|
|
18
|
+
*/
|
|
19
|
+
function normalCDF(x) {
|
|
20
|
+
const a1 = 0.254829592;
|
|
21
|
+
const a2 = -0.284496736;
|
|
22
|
+
const a3 = 1.421413741;
|
|
23
|
+
const a4 = -1.453152027;
|
|
24
|
+
const a5 = 1.061405429;
|
|
25
|
+
const p = 0.3275911;
|
|
26
|
+
const sign = x < 0 ? -1 : 1;
|
|
27
|
+
const absX = Math.abs(x) / Math.SQRT2;
|
|
28
|
+
const t = 1 / (1 + p * absX);
|
|
29
|
+
const y = 1 - (((((a5 * t + a4) * t) + a3) * t + a2) * t + a1) * t * Math.exp(-absX * absX);
|
|
30
|
+
return 0.5 * (1 + sign * y);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Standard normal PDF (probability density function).
|
|
34
|
+
*/
|
|
35
|
+
function normalPDF(x) {
|
|
36
|
+
return Math.exp(-0.5 * x * x) / Math.sqrt(2 * Math.PI);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Known pointing profiles from the empirical literature.
|
|
40
|
+
*
|
|
41
|
+
* - Neurotypical baseline: MacKenzie (1992), Soukoreff & MacKenzie (2004)
|
|
42
|
+
* - Motor tremor: Hwang et al. (2004) ACM ASSETS
|
|
43
|
+
* - Elderly 65+: Chaparro et al. (1999), Ketcham et al. (2002)
|
|
44
|
+
* - ADHD: Flapper et al. (2006) — impulsive timing, near-normal precision
|
|
45
|
+
*/
|
|
46
|
+
const KNOWN_POINTING_PROFILES = {
|
|
47
|
+
neurotypical: { sigmaX: 4, sigmaY: 4, rho: 0.0, throughput: 4.9 },
|
|
48
|
+
tremor: { sigmaX: 12, sigmaY: 12, rho: 0.3, throughput: 2.1 },
|
|
49
|
+
elderly: { sigmaX: 7.2, sigmaY: 7.2, rho: 0.1, throughput: 3.2 },
|
|
50
|
+
adhd: { sigmaX: 5.5, sigmaY: 5.5, rho: 0.0, throughput: 4.2 },
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Derive a pointing profile from persona traits.
|
|
54
|
+
*
|
|
55
|
+
* Maps cognitive trait values to motor parameters by interpolating
|
|
56
|
+
* between known empirical profiles. Uses `motorPrecision` (derived from
|
|
57
|
+
* proceduralFluency and patience) as the primary interpolation axis.
|
|
58
|
+
*
|
|
59
|
+
* @param persona - Persona traits object with cognitive dimensions
|
|
60
|
+
* @returns Empirically calibrated pointing profile
|
|
61
|
+
*/
|
|
62
|
+
export function getPointingProfile(persona) {
|
|
63
|
+
const traits = persona.traits ?? {};
|
|
64
|
+
const a11y = persona.accessibilityTraits ?? {};
|
|
65
|
+
// Check for explicit tremor trait
|
|
66
|
+
if (a11y.tremor) {
|
|
67
|
+
return { ...KNOWN_POINTING_PROFILES.tremor };
|
|
68
|
+
}
|
|
69
|
+
// Check for persona name hints
|
|
70
|
+
const name = (persona.name ?? '').toLowerCase();
|
|
71
|
+
if (name.includes('tremor') || name.includes('parkinson')) {
|
|
72
|
+
return { ...KNOWN_POINTING_PROFILES.tremor };
|
|
73
|
+
}
|
|
74
|
+
if (name.includes('elderly') || name.includes('senior') || name.includes('aging')) {
|
|
75
|
+
return { ...KNOWN_POINTING_PROFILES.elderly };
|
|
76
|
+
}
|
|
77
|
+
if (name.includes('adhd')) {
|
|
78
|
+
return { ...KNOWN_POINTING_PROFILES.adhd };
|
|
79
|
+
}
|
|
80
|
+
// Derive motorPrecision from available traits
|
|
81
|
+
// motorPrecision is a composite of fine motor control indicators
|
|
82
|
+
const motorPrecision = traits.motorPrecision
|
|
83
|
+
?? (traits.proceduralFluency !== undefined && traits.patience !== undefined
|
|
84
|
+
? (traits.proceduralFluency * 0.6 + traits.patience * 0.4)
|
|
85
|
+
: undefined);
|
|
86
|
+
if (motorPrecision === undefined) {
|
|
87
|
+
return { ...KNOWN_POINTING_PROFILES.neurotypical };
|
|
88
|
+
}
|
|
89
|
+
// Interpolate between profiles based on motorPrecision (0-1)
|
|
90
|
+
// 1.0 = neurotypical, 0.0 = severe impairment (tremor)
|
|
91
|
+
const clamped = Math.max(0, Math.min(1, motorPrecision));
|
|
92
|
+
const neuro = KNOWN_POINTING_PROFILES.neurotypical;
|
|
93
|
+
const impaired = KNOWN_POINTING_PROFILES.tremor;
|
|
94
|
+
return {
|
|
95
|
+
sigmaX: neuro.sigmaX + (impaired.sigmaX - neuro.sigmaX) * (1 - clamped),
|
|
96
|
+
sigmaY: neuro.sigmaY + (impaired.sigmaY - neuro.sigmaY) * (1 - clamped),
|
|
97
|
+
rho: neuro.rho + (impaired.rho - neuro.rho) * (1 - clamped),
|
|
98
|
+
throughput: neuro.throughput + (impaired.throughput - neuro.throughput) * (1 - clamped),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Compute the probability that a user hits a rectangular target.
|
|
103
|
+
*
|
|
104
|
+
* Grossman & Balakrishnan (2005) bivariate normal integral over target rectangle.
|
|
105
|
+
* For independent axes (rho=0): P(hit) = Phi(W/(2*sigmaX)) * Phi(H/(2*sigmaY))
|
|
106
|
+
* For correlated axes (rho!=0): applies the Plackett (1954) correction term.
|
|
107
|
+
*
|
|
108
|
+
* Assumes the user aims at the target center (optimal aiming point).
|
|
109
|
+
*
|
|
110
|
+
* @param target - Target element dimensions
|
|
111
|
+
* @param profile - User's pointing profile
|
|
112
|
+
* @returns Hit probability in [0, 1]
|
|
113
|
+
*/
|
|
114
|
+
export function computeHitProbability(target, profile) {
|
|
115
|
+
const { width, height } = target;
|
|
116
|
+
const { sigmaX, sigmaY, rho } = profile;
|
|
117
|
+
// Guard: degenerate targets
|
|
118
|
+
if (width <= 0 || height <= 0)
|
|
119
|
+
return 0;
|
|
120
|
+
if (sigmaX <= 0 || sigmaY <= 0)
|
|
121
|
+
return 1;
|
|
122
|
+
// Standardized half-widths
|
|
123
|
+
const zx = width / (2 * sigmaX);
|
|
124
|
+
const zy = height / (2 * sigmaY);
|
|
125
|
+
// CDF of standard normal at the standardized edges
|
|
126
|
+
// P(|X| < W/2) = 2*Phi(W/(2*sigma)) - 1
|
|
127
|
+
const pX = 2 * normalCDF(zx) - 1;
|
|
128
|
+
const pY = 2 * normalCDF(zy) - 1;
|
|
129
|
+
// Independent-axis approximation (exact for rho=0)
|
|
130
|
+
const pIndependent = pX * pY;
|
|
131
|
+
if (Math.abs(rho) < 1e-6) {
|
|
132
|
+
return pIndependent;
|
|
133
|
+
}
|
|
134
|
+
// Correlated correction (Grossman & Balakrishnan's approximation)
|
|
135
|
+
// P(hit) ~= Phi_x * Phi_y * (1 + rho * phi(zx) * phi(zy) / (Phi_x * Phi_y))
|
|
136
|
+
// where phi is PDF and Phi is the one-sided CDF P(|X| < ...)
|
|
137
|
+
const phiX = normalPDF(zx);
|
|
138
|
+
const phiY = normalPDF(zy);
|
|
139
|
+
if (pX < 1e-10 || pY < 1e-10) {
|
|
140
|
+
return pIndependent;
|
|
141
|
+
}
|
|
142
|
+
const correction = 1 + rho * phiX * phiY / (pX * pY);
|
|
143
|
+
// Clamp to valid probability range
|
|
144
|
+
return Math.max(0, Math.min(1, pIndependent * correction));
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Compute Fitts' Law movement time for reaching a target.
|
|
148
|
+
*
|
|
149
|
+
* Uses the Shannon formulation (MacKenzie 1992, ISO 9241-9):
|
|
150
|
+
* MT = (1/throughput) * log2(D/W + 1)
|
|
151
|
+
*
|
|
152
|
+
* @param distance - Distance to target center in pixels
|
|
153
|
+
* @param width - Effective target width in the movement direction (pixels)
|
|
154
|
+
* @param throughput - User's Fitts' throughput in bits/s
|
|
155
|
+
* @returns Movement time in milliseconds
|
|
156
|
+
*/
|
|
157
|
+
export function computeFittsTime(distance, width, throughput) {
|
|
158
|
+
if (distance <= 0 || width <= 0 || throughput <= 0)
|
|
159
|
+
return 0;
|
|
160
|
+
const indexOfDifficulty = Math.log2(distance / width + 1);
|
|
161
|
+
return (1 / throughput) * indexOfDifficulty * 1000;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Compute motor accessibility for a set of target elements.
|
|
165
|
+
*
|
|
166
|
+
* For each element, computes hit probability and movement time using the
|
|
167
|
+
* Grossman & Balakrishnan pointing model and Fitts' Law. Identifies
|
|
168
|
+
* motor barriers: elements where P(hit) falls below a persona-adjusted threshold.
|
|
169
|
+
*
|
|
170
|
+
* Barrier thresholds (from WCAG 2.5 / AAA guidance):
|
|
171
|
+
* - Neurotypical (throughput >= 4.0): P(hit) < 0.85 is a barrier
|
|
172
|
+
* - Impaired (throughput < 4.0): P(hit) < 0.70 is a barrier (relaxed standard)
|
|
173
|
+
*
|
|
174
|
+
* @param targets - Interactive elements on the page
|
|
175
|
+
* @param persona - Persona to evaluate for
|
|
176
|
+
* @returns Motor accessibility result with per-element breakdown
|
|
177
|
+
*/
|
|
178
|
+
export function motorAccessibility(targets, persona) {
|
|
179
|
+
if (targets.length === 0) {
|
|
180
|
+
return { elements: [], score: 1, barrierCount: 0, transportCost: 0 };
|
|
181
|
+
}
|
|
182
|
+
const profile = getPointingProfile(persona);
|
|
183
|
+
const barrierThreshold = profile.throughput >= 4.0 ? 0.85 : 0.70;
|
|
184
|
+
const elements = targets.map(target => {
|
|
185
|
+
const hitProbability = computeHitProbability(target, profile);
|
|
186
|
+
// Use geometric mean of width and height as effective width for Fitts
|
|
187
|
+
const effectiveWidth = Math.sqrt(target.width * target.height);
|
|
188
|
+
const movementTime = computeFittsTime(target.distance, effectiveWidth, profile.throughput);
|
|
189
|
+
return {
|
|
190
|
+
selector: target.selector,
|
|
191
|
+
hitProbability: Math.round(hitProbability * 10000) / 10000,
|
|
192
|
+
movementTime: Math.round(movementTime),
|
|
193
|
+
isBarrier: hitProbability < barrierThreshold,
|
|
194
|
+
};
|
|
195
|
+
});
|
|
196
|
+
const barrierCount = elements.filter(e => e.isBarrier).length;
|
|
197
|
+
const meanHitProbability = elements.reduce((sum, e) => sum + e.hitProbability, 0) / elements.length;
|
|
198
|
+
const score = Math.round(meanHitProbability * 10000) / 10000;
|
|
199
|
+
const transportCost = Math.round((1 - score) * 10000) / 10000;
|
|
200
|
+
return { elements, score, barrierCount, transportCost };
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Known reading profiles from the empirical literature.
|
|
204
|
+
*
|
|
205
|
+
* - Neurotypical: Rayner (2009) — typical college reader
|
|
206
|
+
* - Dyslexic: Perry, Zorzi & Ziegler (2019) Psychological Science
|
|
207
|
+
* - Low vision: Legge et al. (2007) — central scotoma and crowding
|
|
208
|
+
* - ADHD: Dhar et al. (2010) — intact decoding, reduced sustained attention
|
|
209
|
+
* - Elderly: Rayner et al. (2006) — aging effects on eye movements
|
|
210
|
+
*/
|
|
211
|
+
const KNOWN_READING_PROFILES = {
|
|
212
|
+
neurotypical: { orthographic: 0.85, phonological: 0.80, visualSpan: 7, vocabulary: 0.75, crowding: 0.15 },
|
|
213
|
+
dyslexic: { orthographic: 0.40, phonological: 0.35, visualSpan: 4, vocabulary: 0.65, crowding: 0.55 },
|
|
214
|
+
lowVision: { orthographic: 0.60, phonological: 0.75, visualSpan: 3, vocabulary: 0.75, crowding: 0.70 },
|
|
215
|
+
adhd: { orthographic: 0.80, phonological: 0.75, visualSpan: 6, vocabulary: 0.70, crowding: 0.20 },
|
|
216
|
+
elderly: { orthographic: 0.70, phonological: 0.65, visualSpan: 5, vocabulary: 0.85, crowding: 0.30 },
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* Derive a reading profile from persona traits.
|
|
220
|
+
*
|
|
221
|
+
* Maps cognitive trait values to reading parameters by selecting the
|
|
222
|
+
* closest known profile and interpolating with the neurotypical baseline.
|
|
223
|
+
*
|
|
224
|
+
* @param persona - Persona traits object
|
|
225
|
+
* @returns Empirically calibrated reading profile
|
|
226
|
+
*/
|
|
227
|
+
export function getReadingProfile(persona) {
|
|
228
|
+
const traits = persona.traits ?? {};
|
|
229
|
+
const name = (persona.name ?? '').toLowerCase();
|
|
230
|
+
// Direct name matching for known profiles
|
|
231
|
+
if (name.includes('dyslexic') || name.includes('dyslexia')) {
|
|
232
|
+
return { ...KNOWN_READING_PROFILES.dyslexic };
|
|
233
|
+
}
|
|
234
|
+
if (name.includes('low-vision') || name.includes('low vision') || name.includes('magnified')) {
|
|
235
|
+
return { ...KNOWN_READING_PROFILES.lowVision };
|
|
236
|
+
}
|
|
237
|
+
if (name.includes('adhd') || name.includes('attention deficit')) {
|
|
238
|
+
return { ...KNOWN_READING_PROFILES.adhd };
|
|
239
|
+
}
|
|
240
|
+
if (name.includes('elderly') || name.includes('senior') || name.includes('aging')) {
|
|
241
|
+
return { ...KNOWN_READING_PROFILES.elderly };
|
|
242
|
+
}
|
|
243
|
+
// Trait-based interpolation
|
|
244
|
+
const textProcessing = traits.textProcessing;
|
|
245
|
+
const comprehension = traits.comprehension;
|
|
246
|
+
if (textProcessing === undefined && comprehension === undefined) {
|
|
247
|
+
return { ...KNOWN_READING_PROFILES.neurotypical };
|
|
248
|
+
}
|
|
249
|
+
// Use textProcessing as primary axis, comprehension as secondary
|
|
250
|
+
const readingAbility = textProcessing !== undefined && comprehension !== undefined
|
|
251
|
+
? textProcessing * 0.6 + comprehension * 0.4
|
|
252
|
+
: (textProcessing ?? comprehension ?? 0.75);
|
|
253
|
+
const clamped = Math.max(0, Math.min(1, readingAbility));
|
|
254
|
+
const neuro = KNOWN_READING_PROFILES.neurotypical;
|
|
255
|
+
const impaired = KNOWN_READING_PROFILES.dyslexic;
|
|
256
|
+
return {
|
|
257
|
+
orthographic: impaired.orthographic + (neuro.orthographic - impaired.orthographic) * clamped,
|
|
258
|
+
phonological: impaired.phonological + (neuro.phonological - impaired.phonological) * clamped,
|
|
259
|
+
visualSpan: Math.round(impaired.visualSpan + (neuro.visualSpan - impaired.visualSpan) * clamped),
|
|
260
|
+
vocabulary: impaired.vocabulary + (neuro.vocabulary - impaired.vocabulary) * clamped,
|
|
261
|
+
crowding: neuro.crowding + (impaired.crowding - neuro.crowding) * (1 - clamped),
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Irregular word patterns in English.
|
|
266
|
+
*
|
|
267
|
+
* These are grapheme-phoneme correspondence violations — words containing
|
|
268
|
+
* these patterns violate standard decoding rules and require whole-word
|
|
269
|
+
* (orthographic) recognition. Dyslexic readers with impaired orthographic
|
|
270
|
+
* processing are disproportionately slowed by these.
|
|
271
|
+
*
|
|
272
|
+
* Source: Plaut et al. (1996), Coltheart et al. (2001) DRC model.
|
|
273
|
+
*/
|
|
274
|
+
const IRREGULAR_PATTERN = /\b\w*(ough|tion|sion|ight|ould|alk|omb|wr|kn|gn|pn|ps|mn)\w*\b/gi;
|
|
275
|
+
/**
|
|
276
|
+
* Estimate the proportion of irregular words in a text passage.
|
|
277
|
+
*
|
|
278
|
+
* Returns the fraction of words that contain irregular grapheme-phoneme
|
|
279
|
+
* correspondences. This determines the orthographic processing demand:
|
|
280
|
+
* higher irregularity = more reliance on whole-word recognition.
|
|
281
|
+
*
|
|
282
|
+
* @param text - Text passage to analyze
|
|
283
|
+
* @returns Proportion of irregular words (0-1)
|
|
284
|
+
*/
|
|
285
|
+
export function estimateIrregularity(text) {
|
|
286
|
+
const words = text.trim().split(/\s+/);
|
|
287
|
+
if (words.length === 0)
|
|
288
|
+
return 0;
|
|
289
|
+
// Reset regex state (global flag)
|
|
290
|
+
IRREGULAR_PATTERN.lastIndex = 0;
|
|
291
|
+
const matches = text.match(IRREGULAR_PATTERN);
|
|
292
|
+
const irregularCount = matches ? matches.length : 0;
|
|
293
|
+
return Math.min(1, irregularCount / words.length);
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Compute reading difficulty for a text block using the multi-deficit model.
|
|
297
|
+
*
|
|
298
|
+
* The Perry, Zorzi & Ziegler (2019) framework models dyslexia as the
|
|
299
|
+
* intersection of multiple independent deficits. Each deficit independently
|
|
300
|
+
* increases fixation duration. The total penalty is additive (not multiplicative)
|
|
301
|
+
* because deficits affect different processing stages in the reading pipeline:
|
|
302
|
+
*
|
|
303
|
+
* Visual input -> Visual span (crowding) -> Orthographic processing ->
|
|
304
|
+
* Phonological decoding -> Lexical access (vocabulary) -> Comprehension
|
|
305
|
+
*
|
|
306
|
+
* Additional penalties from Rello & Baeza-Yates (2016) for font effects
|
|
307
|
+
* and WCAG 2.1 contrast requirements.
|
|
308
|
+
*
|
|
309
|
+
* @param text - Text content to analyze
|
|
310
|
+
* @param profile - Reader's deficit profile
|
|
311
|
+
* @param textBlock - Typographic properties of the text
|
|
312
|
+
* @returns Reading difficulty (0-1) and fixation duration
|
|
313
|
+
*/
|
|
314
|
+
export function computeReadingDifficulty(text, profile, textBlock) {
|
|
315
|
+
const words = text.trim().split(/\s+/);
|
|
316
|
+
const wordCount = Math.max(1, words.length);
|
|
317
|
+
const penalties = [];
|
|
318
|
+
// Base fixation duration: fluent adult reader (Rayner 2009)
|
|
319
|
+
const baseFixation = 250; // ms per word
|
|
320
|
+
// 1. Orthographic deficit: irregular words take longer to process
|
|
321
|
+
// When orthographic route is impaired, the reader must fall back to
|
|
322
|
+
// phonological decoding for irregular words, which is slower.
|
|
323
|
+
const irregularWordRatio = estimateIrregularity(text);
|
|
324
|
+
const orthoPenalty = (1 - profile.orthographic) * irregularWordRatio * 150;
|
|
325
|
+
if (orthoPenalty > 10) {
|
|
326
|
+
penalties.push(`orthographic: +${Math.round(orthoPenalty)}ms (${Math.round(irregularWordRatio * 100)}% irregular words)`);
|
|
327
|
+
}
|
|
328
|
+
// 2. Phonological deficit: all words require phonological activation
|
|
329
|
+
// Even for skilled readers, phonological codes are activated automatically.
|
|
330
|
+
// Impaired phonological processing slows all word recognition.
|
|
331
|
+
const phonoPenalty = (1 - profile.phonological) * 100;
|
|
332
|
+
if (phonoPenalty > 10) {
|
|
333
|
+
penalties.push(`phonological: +${Math.round(phonoPenalty)}ms`);
|
|
334
|
+
}
|
|
335
|
+
// 3. Visual span: fewer characters per fixation = more fixations per word
|
|
336
|
+
// Normal visual span ~7 characters (Legge et al. 2007).
|
|
337
|
+
// Reduced span means more saccades to read the same word.
|
|
338
|
+
const spanRatio = 7 / profile.visualSpan;
|
|
339
|
+
const spanPenalty = (spanRatio - 1) * 80;
|
|
340
|
+
if (spanPenalty > 5) {
|
|
341
|
+
penalties.push(`visual span: +${Math.round(spanPenalty)}ms (${profile.visualSpan} chars/fixation)`);
|
|
342
|
+
}
|
|
343
|
+
// 4. Vocabulary: unknown/rare words require additional processing
|
|
344
|
+
// Long words are more likely to be uncommon (Zipf's law correlation).
|
|
345
|
+
// Vocabulary deficit amplifies this effect.
|
|
346
|
+
const avgWordLength = words.reduce((sum, w) => sum + w.length, 0) / wordCount;
|
|
347
|
+
const vocabPenalty = (1 - profile.vocabulary) * Math.max(0, avgWordLength - 5) * 30;
|
|
348
|
+
if (vocabPenalty > 5) {
|
|
349
|
+
penalties.push(`vocabulary: +${Math.round(vocabPenalty)}ms (avg word length ${avgWordLength.toFixed(1)})`);
|
|
350
|
+
}
|
|
351
|
+
// 5. Crowding: small or dense text increases lateral masking
|
|
352
|
+
// Below 16px, crowding effects increase substantially.
|
|
353
|
+
// Pelli et al. (2004, 2007) established the critical spacing formula.
|
|
354
|
+
const crowdingPenalty = profile.crowding * Math.max(0, 16 - textBlock.fontSize) * 10;
|
|
355
|
+
if (crowdingPenalty > 5) {
|
|
356
|
+
penalties.push(`crowding: +${Math.round(crowdingPenalty)}ms (${textBlock.fontSize}px font)`);
|
|
357
|
+
}
|
|
358
|
+
// 6. Font penalty: serif fonts penalize dyslexic readers
|
|
359
|
+
// Rello & Baeza-Yates (2016): sans-serif fonts reduce fixation time
|
|
360
|
+
// for readers with orthographic processing below 0.6.
|
|
361
|
+
const fontPenalty = textBlock.isSerif && profile.orthographic < 0.6 ? 50 : 0;
|
|
362
|
+
if (fontPenalty > 0) {
|
|
363
|
+
penalties.push(`serif font: +${fontPenalty}ms (orthographic deficit)`);
|
|
364
|
+
}
|
|
365
|
+
// 7. Contrast penalty: low contrast increases fixation duration
|
|
366
|
+
// WCAG 2.1 SC 1.4.3 minimum is 4.5:1 for normal text.
|
|
367
|
+
// Below this threshold, all readers are affected, but impaired readers more so.
|
|
368
|
+
const contrastPenalty = textBlock.contrastRatio < 4.5
|
|
369
|
+
? (4.5 - textBlock.contrastRatio) * 40
|
|
370
|
+
: 0;
|
|
371
|
+
if (contrastPenalty > 0) {
|
|
372
|
+
penalties.push(`low contrast: +${Math.round(contrastPenalty)}ms (${textBlock.contrastRatio.toFixed(1)}:1 ratio)`);
|
|
373
|
+
}
|
|
374
|
+
// Total fixation duration per word
|
|
375
|
+
const totalFixation = baseFixation + orthoPenalty + phonoPenalty + spanPenalty + vocabPenalty + crowdingPenalty + fontPenalty + contrastPenalty;
|
|
376
|
+
// Words per minute
|
|
377
|
+
const wpm = Math.round(60000 / totalFixation);
|
|
378
|
+
// Normalize difficulty: 250ms = 0.0 (fluent), 750ms+ = 1.0 (severe)
|
|
379
|
+
const difficulty = Math.max(0, Math.min(1, (totalFixation - 250) / 500));
|
|
380
|
+
return {
|
|
381
|
+
difficulty: Math.round(difficulty * 10000) / 10000,
|
|
382
|
+
fixationDuration: Math.round(totalFixation),
|
|
383
|
+
wordsPerMinute: wpm,
|
|
384
|
+
penalties,
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Compute readability for multiple text blocks using the multi-deficit model.
|
|
389
|
+
*
|
|
390
|
+
* Evaluates each text block independently, then computes an aggregate
|
|
391
|
+
* readability score weighted by text length (longer blocks matter more).
|
|
392
|
+
*
|
|
393
|
+
* @param blocks - Array of text blocks with typographic properties
|
|
394
|
+
* @param persona - Persona to evaluate for
|
|
395
|
+
* @returns Readability result with per-block breakdown and aggregate score
|
|
396
|
+
*/
|
|
397
|
+
export function readability(blocks, persona) {
|
|
398
|
+
if (blocks.length === 0) {
|
|
399
|
+
return { blocks: [], score: 1, transportCost: 0 };
|
|
400
|
+
}
|
|
401
|
+
const profile = getReadingProfile(persona);
|
|
402
|
+
const results = blocks.map(block => {
|
|
403
|
+
const { difficulty, fixationDuration, wordsPerMinute, penalties } = computeReadingDifficulty(block.text, profile, block);
|
|
404
|
+
return {
|
|
405
|
+
text: block.text.length > 100 ? block.text.slice(0, 100) + '...' : block.text,
|
|
406
|
+
difficulty,
|
|
407
|
+
fixationDuration,
|
|
408
|
+
wordsPerMinute,
|
|
409
|
+
penalties,
|
|
410
|
+
};
|
|
411
|
+
});
|
|
412
|
+
// Weighted average by text length (longer blocks count more)
|
|
413
|
+
const totalChars = blocks.reduce((sum, b) => sum + b.text.length, 0) || 1;
|
|
414
|
+
const weightedDifficulty = results.reduce((sum, r, i) => {
|
|
415
|
+
const weight = blocks[i].text.length / totalChars;
|
|
416
|
+
return sum + r.difficulty * weight;
|
|
417
|
+
}, 0);
|
|
418
|
+
const score = Math.round((1 - weightedDifficulty) * 10000) / 10000;
|
|
419
|
+
const transportCost = Math.round(weightedDifficulty * 10000) / 10000;
|
|
420
|
+
return { blocks: results, score, transportCost };
|
|
421
|
+
}
|
|
422
|
+
// ── Unified Access ──
|
|
423
|
+
/**
|
|
424
|
+
* Compute both motor and reading accessibility for a persona.
|
|
425
|
+
*
|
|
426
|
+
* Combines Layer 4 (pointing model) and Layer 6 (reading model) into
|
|
427
|
+
* a single assessment. Each layer contributes independently to the
|
|
428
|
+
* total transport cost.
|
|
429
|
+
*
|
|
430
|
+
* @param targets - Interactive elements for motor assessment
|
|
431
|
+
* @param textBlocks - Text blocks for reading assessment
|
|
432
|
+
* @param persona - Persona to evaluate
|
|
433
|
+
* @returns Combined accessibility result
|
|
434
|
+
*/
|
|
435
|
+
export function cognitiveAccessibility(targets, textBlocks, persona) {
|
|
436
|
+
const motor = motorAccessibility(targets, persona);
|
|
437
|
+
const reading = readability(textBlocks, persona);
|
|
438
|
+
// Combined score: geometric mean (penalizes severe deficits in either domain)
|
|
439
|
+
const combinedScore = Math.round(Math.sqrt(motor.score * reading.score) * 10000) / 10000;
|
|
440
|
+
// Combined transport cost: sum of independent layer costs (clamped to [0,1])
|
|
441
|
+
const combinedTransportCost = Math.round(Math.min(1, motor.transportCost + reading.transportCost) * 10000) / 10000;
|
|
442
|
+
return { motor, reading, combinedScore, combinedTransportCost };
|
|
443
|
+
}
|
|
444
|
+
// ── Exports for testing ──
|
|
445
|
+
export { normalCDF as _normalCDF, normalPDF as _normalPDF };
|
|
446
|
+
export { KNOWN_POINTING_PROFILES, KNOWN_READING_PROFILES };
|
|
447
|
+
//# sourceMappingURL=cognitive-models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cognitive-models.js","sourceRoot":"","sources":["../../src/visual/cognitive-models.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,gCAAgC;AAEhC;;;GAGG;AACH,SAAS,SAAS,CAAC,CAAS;IAC1B,MAAM,EAAE,GAAG,WAAW,CAAC;IACvB,MAAM,EAAE,GAAG,CAAC,WAAW,CAAC;IACxB,MAAM,EAAE,GAAG,WAAW,CAAC;IACvB,MAAM,EAAE,GAAG,CAAC,WAAW,CAAC;IACxB,MAAM,EAAE,GAAG,WAAW,CAAC;IACvB,MAAM,CAAC,GAAG,SAAS,CAAC;IAEpB,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;IACtC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7B,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,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AO,EAAE,SAAS,IAAI,UAAU,EAAE,SAAS,IAAI,UAAU,EAAE,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cognitive Optimal Transport — Sequential Transport Chain
|
|
3
|
+
*
|
|
4
|
+
* Implements the CHI 2027 paper's core contribution:
|
|
5
|
+
* - 26-dimensional demand distribution computed from page features
|
|
6
|
+
* - Sequential transport chain where each layer depletes capacity
|
|
7
|
+
* - Asymmetric deficit-surplus cost
|
|
8
|
+
* - Layer interaction terms
|
|
9
|
+
*
|
|
10
|
+
* Mathematical foundation: The total Cognitive Transport Cost is NOT
|
|
11
|
+
* the sum of independent layers. Each layer receives the user's RESIDUAL
|
|
12
|
+
* capacity after prior layers have consumed resources.
|
|
13
|
+
*
|
|
14
|
+
* @see Section 3.4 of "Cognitive Optimal Transport: A Unified Framework"
|
|
15
|
+
* @since v18.39.0
|
|
16
|
+
*/
|
|
17
|
+
import { type OTCognitiveProfile } from './cognitive-transport.js';
|
|
18
|
+
/** Page metrics extracted from a live page (matches extractPageMetrics return) */
|
|
19
|
+
export interface PageMetrics {
|
|
20
|
+
informationDensity: number;
|
|
21
|
+
visualComplexity: number;
|
|
22
|
+
interactiveElementCount: number;
|
|
23
|
+
textDensity: number;
|
|
24
|
+
animationLevel: number;
|
|
25
|
+
choiceCount: number;
|
|
26
|
+
navigationDepth: number;
|
|
27
|
+
}
|
|
28
|
+
export interface DemandDistribution {
|
|
29
|
+
/** 26-dimensional demand vector (0-1 per trait) */
|
|
30
|
+
demands: Record<string, number>;
|
|
31
|
+
/** Per-dimension demand variance (from spatial variability across page) */
|
|
32
|
+
variance: Record<string, number>;
|
|
33
|
+
}
|
|
34
|
+
export interface LayerResult {
|
|
35
|
+
name: string;
|
|
36
|
+
transportCost: number;
|
|
37
|
+
capacityConsumed: number;
|
|
38
|
+
residualCapacity: Record<string, number>;
|
|
39
|
+
}
|
|
40
|
+
export interface SequentialTransportResult {
|
|
41
|
+
/** Total Cognitive Transport Cost */
|
|
42
|
+
totalCTC: number;
|
|
43
|
+
/** Per-layer results in sequential order */
|
|
44
|
+
layers: LayerResult[];
|
|
45
|
+
/** Pairwise interaction terms */
|
|
46
|
+
interactions: Record<string, number>;
|
|
47
|
+
/** Additive-only CTC for comparison */
|
|
48
|
+
additiveCTC: number;
|
|
49
|
+
/** Asymmetric deficit-surplus breakdown */
|
|
50
|
+
deficitCost: number;
|
|
51
|
+
surplusCost: number;
|
|
52
|
+
/** Per-trait transport cost */
|
|
53
|
+
traitCosts: Record<string, number>;
|
|
54
|
+
/** Bottleneck layer (highest cost) */
|
|
55
|
+
bottleneckLayer: string;
|
|
56
|
+
/** Predicted abandonment probability (0-1) */
|
|
57
|
+
abandonmentRisk: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The 26 demand dimensions used by the sequential transport chain.
|
|
61
|
+
* Superset of the base 25 OT cognitive traits — includes extended traits
|
|
62
|
+
* from CognitiveTraits that capture decision biases, learning transfer,
|
|
63
|
+
* and emotional regulation.
|
|
64
|
+
*/
|
|
65
|
+
export declare const DEMAND_DIMENSIONS: readonly ["patience", "riskTolerance", "comprehension", "persistence", "workingMemory", "readingTendency", "resilience", "selfEfficacy", "emotionalContagion", "satisficing", "anchoringBias", "fearOfMissingOut", "socialProofSensitivity", "changeBlindness", "attentionPattern", "motorPrecision", "proceduralFluency", "informationForaging", "metacognitivePlanning", "transferLearning", "interruptRecovery", "trustCalibration", "mentalModelRigidity", "curiosity", "processingSpeed", "textProcessing"];
|
|
66
|
+
/**
|
|
67
|
+
* Compute the 26-dimensional demand distribution from page metrics.
|
|
68
|
+
*
|
|
69
|
+
* Each page feature maps to specific trait dimensions via calibrated
|
|
70
|
+
* sigmoid functions. The mapping encodes HOW each page characteristic
|
|
71
|
+
* creates cognitive demand on specific user capacities.
|
|
72
|
+
*
|
|
73
|
+
* Traits not affected by any page feature receive demand = 0.0 (no demand).
|
|
74
|
+
*
|
|
75
|
+
* @param pageMetrics - Extracted page analysis metrics
|
|
76
|
+
* @returns DemandDistribution with per-trait demand and variance
|
|
77
|
+
*/
|
|
78
|
+
export declare function computeDemandDistribution(pageMetrics: PageMetrics): DemandDistribution;
|
|
79
|
+
/**
|
|
80
|
+
* Compute the Sequential Cognitive Transport Cost (CTC).
|
|
81
|
+
*
|
|
82
|
+
* Unlike additive cognitive load models, the sequential chain depletes
|
|
83
|
+
* capacity at each processing layer. A user who spends cognitive resources
|
|
84
|
+
* on saliency detection has LESS available for subsequent decision-making.
|
|
85
|
+
*
|
|
86
|
+
* The algorithm processes layers in temporal order:
|
|
87
|
+
* Saliency -> Cognitive Load -> Decision -> Motor -> Frustration -> Readability
|
|
88
|
+
*
|
|
89
|
+
* Each layer:
|
|
90
|
+
* 1. Computes asymmetric transport cost (deficit is expensive, surplus is cheap)
|
|
91
|
+
* 2. Depletes residual capacity proportional to cost incurred
|
|
92
|
+
* 3. Records the remaining capacity for downstream layers
|
|
93
|
+
*
|
|
94
|
+
* @param persona - OTCognitiveProfile with trait values
|
|
95
|
+
* @param demand - 26D demand distribution from page analysis
|
|
96
|
+
* @param options - Enable/disable asymmetric costs and interaction terms
|
|
97
|
+
* @returns Complete sequential transport result with per-layer breakdown
|
|
98
|
+
*/
|
|
99
|
+
export declare function computeSequentialCTC(persona: OTCognitiveProfile, demand: DemandDistribution, options?: {
|
|
100
|
+
asymmetric?: boolean;
|
|
101
|
+
interactions?: boolean;
|
|
102
|
+
}): SequentialTransportResult;
|
|
103
|
+
/**
|
|
104
|
+
* End-to-end Cognitive Optimal Transport computation.
|
|
105
|
+
*
|
|
106
|
+
* Extracts page metrics from a live Playwright page, computes the
|
|
107
|
+
* 26D demand distribution, and runs the full sequential transport chain.
|
|
108
|
+
*
|
|
109
|
+
* This is the primary entry point for MCP tools that need a single
|
|
110
|
+
* CTC score with full breakdown.
|
|
111
|
+
*
|
|
112
|
+
* @param persona - OTCognitiveProfile with trait values
|
|
113
|
+
* @param page - Playwright Page object (or any object with evaluate())
|
|
114
|
+
* @returns Complete sequential transport result
|
|
115
|
+
*/
|
|
116
|
+
export declare function computeFullCOT(persona: OTCognitiveProfile, page: any): Promise<SequentialTransportResult>;
|
|
117
|
+
/**
|
|
118
|
+
* Compute demand distribution from raw metric values (no page required).
|
|
119
|
+
* Useful for testing, simulation, and sensitivity analysis.
|
|
120
|
+
*/
|
|
121
|
+
export declare function computeDemandFromRawMetrics(informationDensity: number, visualComplexity: number, interactiveElementCount: number, textDensity: number, animationLevel: number, choiceCount: number, navigationDepth: number): DemandDistribution;
|
|
122
|
+
/**
|
|
123
|
+
* Compare sequential vs. additive CTC to quantify the sequential effect.
|
|
124
|
+
*
|
|
125
|
+
* Returns the ratio (sequential / additive). Values > 1.0 indicate that
|
|
126
|
+
* capacity depletion and interactions amplify the total cost beyond what
|
|
127
|
+
* independent layers would predict.
|
|
128
|
+
*/
|
|
129
|
+
export declare function sequentialAmplification(result: SequentialTransportResult): number;
|
|
130
|
+
/**
|
|
131
|
+
* Identify the top N most costly traits across all layers.
|
|
132
|
+
* Useful for targeted remediation — fix the traits that hurt most.
|
|
133
|
+
*/
|
|
134
|
+
export declare function topCostlyTraits(result: SequentialTransportResult, n?: number): Array<{
|
|
135
|
+
trait: string;
|
|
136
|
+
cost: number;
|
|
137
|
+
}>;
|
|
138
|
+
/**
|
|
139
|
+
* Compute CTC for a minimal/empty page (baseline).
|
|
140
|
+
* Useful for normalizing CTC scores against the best-case scenario.
|
|
141
|
+
*/
|
|
142
|
+
export declare function baselineCTC(persona: OTCognitiveProfile): SequentialTransportResult;
|
|
143
|
+
//# sourceMappingURL=cognitive-transport-chain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cognitive-transport-chain.d.ts","sourceRoot":"","sources":["../../src/visual/cognitive-transport-chain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,E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