@arclabs561/ai-visual-test 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.secretsignore.example +20 -0
- package/CHANGELOG.md +360 -0
- package/CONTRIBUTING.md +63 -0
- package/DEPLOYMENT.md +80 -0
- package/LICENSE +22 -0
- package/README.md +142 -0
- package/SECURITY.md +108 -0
- package/api/health.js +34 -0
- package/api/validate.js +252 -0
- package/index.d.ts +1221 -0
- package/package.json +112 -0
- package/public/index.html +149 -0
- package/src/batch-optimizer.mjs +451 -0
- package/src/bias-detector.mjs +370 -0
- package/src/bias-mitigation.mjs +233 -0
- package/src/cache.mjs +433 -0
- package/src/config.mjs +268 -0
- package/src/constants.mjs +80 -0
- package/src/context-compressor.mjs +350 -0
- package/src/convenience.mjs +617 -0
- package/src/cost-tracker.mjs +257 -0
- package/src/cross-modal-consistency.mjs +170 -0
- package/src/data-extractor.mjs +232 -0
- package/src/dynamic-few-shot.mjs +140 -0
- package/src/dynamic-prompts.mjs +361 -0
- package/src/ensemble/index.mjs +53 -0
- package/src/ensemble-judge.mjs +366 -0
- package/src/error-handler.mjs +67 -0
- package/src/errors.mjs +167 -0
- package/src/experience-propagation.mjs +128 -0
- package/src/experience-tracer.mjs +487 -0
- package/src/explanation-manager.mjs +299 -0
- package/src/feedback-aggregator.mjs +248 -0
- package/src/game-goal-prompts.mjs +478 -0
- package/src/game-player.mjs +548 -0
- package/src/hallucination-detector.mjs +155 -0
- package/src/helpers/playwright.mjs +80 -0
- package/src/human-validation-manager.mjs +516 -0
- package/src/index.mjs +364 -0
- package/src/judge.mjs +929 -0
- package/src/latency-aware-batch-optimizer.mjs +192 -0
- package/src/load-env.mjs +159 -0
- package/src/logger.mjs +55 -0
- package/src/metrics.mjs +187 -0
- package/src/model-tier-selector.mjs +221 -0
- package/src/multi-modal/index.mjs +36 -0
- package/src/multi-modal-fusion.mjs +190 -0
- package/src/multi-modal.mjs +524 -0
- package/src/natural-language-specs.mjs +1071 -0
- package/src/pair-comparison.mjs +277 -0
- package/src/persona/index.mjs +42 -0
- package/src/persona-enhanced.mjs +200 -0
- package/src/persona-experience.mjs +572 -0
- package/src/position-counterbalance.mjs +140 -0
- package/src/prompt-composer.mjs +375 -0
- package/src/render-change-detector.mjs +583 -0
- package/src/research-enhanced-validation.mjs +436 -0
- package/src/retry.mjs +152 -0
- package/src/rubrics.mjs +231 -0
- package/src/score-tracker.mjs +277 -0
- package/src/smart-validator.mjs +447 -0
- package/src/spec-config.mjs +106 -0
- package/src/spec-templates.mjs +347 -0
- package/src/specs/index.mjs +38 -0
- package/src/temporal/index.mjs +102 -0
- package/src/temporal-adaptive.mjs +163 -0
- package/src/temporal-batch-optimizer.mjs +222 -0
- package/src/temporal-constants.mjs +69 -0
- package/src/temporal-context.mjs +49 -0
- package/src/temporal-decision-manager.mjs +271 -0
- package/src/temporal-decision.mjs +669 -0
- package/src/temporal-errors.mjs +58 -0
- package/src/temporal-note-pruner.mjs +173 -0
- package/src/temporal-preprocessor.mjs +543 -0
- package/src/temporal-prompt-formatter.mjs +219 -0
- package/src/temporal-validation.mjs +159 -0
- package/src/temporal.mjs +415 -0
- package/src/type-guards.mjs +311 -0
- package/src/uncertainty-reducer.mjs +470 -0
- package/src/utils/index.mjs +175 -0
- package/src/validation-framework.mjs +321 -0
- package/src/validation-result-normalizer.mjs +64 -0
- package/src/validation.mjs +243 -0
- package/src/validators/accessibility-programmatic.mjs +345 -0
- package/src/validators/accessibility-validator.mjs +223 -0
- package/src/validators/batch-validator.mjs +143 -0
- package/src/validators/hybrid-validator.mjs +268 -0
- package/src/validators/index.mjs +34 -0
- package/src/validators/prompt-builder.mjs +218 -0
- package/src/validators/rubric.mjs +85 -0
- package/src/validators/state-programmatic.mjs +260 -0
- package/src/validators/state-validator.mjs +291 -0
- package/vercel.json +27 -0
package/src/index.mjs
ADDED
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ai-visual-test
|
|
3
|
+
*
|
|
4
|
+
* Visual testing utilities using Vision Language Models (VLLM) for multi-modal validation.
|
|
5
|
+
*
|
|
6
|
+
* Supports:
|
|
7
|
+
* - Browser/Playwright integration
|
|
8
|
+
* - Multi-modal validation (screenshot + HTML + CSS + rendered code)
|
|
9
|
+
* - Persona-based experience testing with human-interpreted time scales
|
|
10
|
+
* - Built-in prompt templates (pluggable)
|
|
11
|
+
* - Context/hooks/encoding (compression, state history, temporal aggregation)
|
|
12
|
+
*
|
|
13
|
+
* Main entry point - exports all public APIs.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
// Auto-load .env file on module initialization
|
|
17
|
+
import { loadEnv } from './load-env.mjs';
|
|
18
|
+
loadEnv();
|
|
19
|
+
|
|
20
|
+
import { VLLMJudge, validateScreenshot as _validateScreenshot } from './judge.mjs';
|
|
21
|
+
|
|
22
|
+
export { VLLMJudge, _validateScreenshot as validateScreenshot };
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Extract semantic information from VLLM judgment text
|
|
26
|
+
*
|
|
27
|
+
* Utility function to parse VLLM responses into structured data.
|
|
28
|
+
* Useful for custom implementations that need to parse judgment text.
|
|
29
|
+
*
|
|
30
|
+
* @param {string | object} judgment - Judgment text or object from VLLM
|
|
31
|
+
* @returns {import('./index.mjs').SemanticInfo} Structured semantic information with score, issues, assessment, reasoning
|
|
32
|
+
*/
|
|
33
|
+
export function extractSemanticInfo(judgment) {
|
|
34
|
+
// Create a temporary judge instance to access the method
|
|
35
|
+
// This avoids needing to instantiate VLLMJudge with config
|
|
36
|
+
const judge = new VLLMJudge({ enabled: false });
|
|
37
|
+
return judge.extractSemanticInfo(judgment);
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
multiModalValidation,
|
|
41
|
+
captureTemporalScreenshots,
|
|
42
|
+
extractRenderedCode,
|
|
43
|
+
multiPerspectiveEvaluation
|
|
44
|
+
} from './multi-modal.mjs';
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
estimateUncertainty,
|
|
48
|
+
selfConsistencyCheck,
|
|
49
|
+
combineUncertaintySources,
|
|
50
|
+
enhanceWithUncertainty,
|
|
51
|
+
shouldUseSelfConsistency
|
|
52
|
+
} from './uncertainty-reducer.mjs';
|
|
53
|
+
export {
|
|
54
|
+
buildStructuredFusionPrompt,
|
|
55
|
+
calculateModalityWeights,
|
|
56
|
+
compareFusionStrategies
|
|
57
|
+
} from './multi-modal-fusion.mjs';
|
|
58
|
+
export {
|
|
59
|
+
aggregateTemporalNotes,
|
|
60
|
+
formatNotesForPrompt,
|
|
61
|
+
calculateCoherenceExported as calculateCoherence
|
|
62
|
+
} from './temporal.mjs';
|
|
63
|
+
export {
|
|
64
|
+
formatTemporalContext,
|
|
65
|
+
formatTemporalForPrompt,
|
|
66
|
+
formatSingleScaleForPrompt,
|
|
67
|
+
formatMultiScaleForPrompt
|
|
68
|
+
} from './temporal-prompt-formatter.mjs';
|
|
69
|
+
export {
|
|
70
|
+
TemporalDecisionManager,
|
|
71
|
+
createTemporalDecisionManager
|
|
72
|
+
} from './temporal-decision-manager.mjs';
|
|
73
|
+
|
|
74
|
+
export {
|
|
75
|
+
TemporalPreprocessingManager,
|
|
76
|
+
AdaptiveTemporalProcessor,
|
|
77
|
+
createTemporalPreprocessingManager,
|
|
78
|
+
createAdaptiveTemporalProcessor
|
|
79
|
+
} from './temporal-preprocessor.mjs';
|
|
80
|
+
export {
|
|
81
|
+
pruneTemporalNotes,
|
|
82
|
+
propagateNotes,
|
|
83
|
+
selectTopWeightedNotes
|
|
84
|
+
} from './temporal-note-pruner.mjs';
|
|
85
|
+
export {
|
|
86
|
+
calculateAttentionWeight
|
|
87
|
+
} from './temporal-decision.mjs';
|
|
88
|
+
export {
|
|
89
|
+
detectRenderChanges,
|
|
90
|
+
calculateOptimalFPS,
|
|
91
|
+
detectVisualChanges,
|
|
92
|
+
captureOnRenderChanges,
|
|
93
|
+
captureAdaptiveTemporalScreenshots
|
|
94
|
+
} from './render-change-detector.mjs';
|
|
95
|
+
export {
|
|
96
|
+
aggregateTemporalNotesAdaptive,
|
|
97
|
+
calculateOptimalWindowSize,
|
|
98
|
+
detectActivityPattern
|
|
99
|
+
} from './temporal-adaptive.mjs';
|
|
100
|
+
export {
|
|
101
|
+
getCached,
|
|
102
|
+
setCached,
|
|
103
|
+
clearCache,
|
|
104
|
+
getCacheStats,
|
|
105
|
+
initCache,
|
|
106
|
+
generateCacheKey
|
|
107
|
+
} from './cache.mjs';
|
|
108
|
+
export {
|
|
109
|
+
createConfig,
|
|
110
|
+
getProvider,
|
|
111
|
+
getConfig,
|
|
112
|
+
setConfig
|
|
113
|
+
} from './config.mjs';
|
|
114
|
+
export { loadEnv } from './load-env.mjs';
|
|
115
|
+
export { enableDebug, disableDebug, isDebugEnabled, warn, log, error } from './logger.mjs';
|
|
116
|
+
export { ScoreTracker } from './score-tracker.mjs';
|
|
117
|
+
export { BatchOptimizer } from './batch-optimizer.mjs';
|
|
118
|
+
export { TemporalBatchOptimizer } from './temporal-batch-optimizer.mjs';
|
|
119
|
+
export { LatencyAwareBatchOptimizer } from './latency-aware-batch-optimizer.mjs';
|
|
120
|
+
export { extractStructuredData } from './data-extractor.mjs';
|
|
121
|
+
export { aggregateFeedback, generateRecommendations } from './feedback-aggregator.mjs';
|
|
122
|
+
export { compressContext, compressStateHistory } from './context-compressor.mjs';
|
|
123
|
+
export { experiencePageAsPersona, experiencePageWithPersonas } from './persona-experience.mjs';
|
|
124
|
+
export { ExplanationManager, getExplanationManager } from './explanation-manager.mjs';
|
|
125
|
+
export {
|
|
126
|
+
createEnhancedPersona,
|
|
127
|
+
experiencePageWithEnhancedPersona,
|
|
128
|
+
calculatePersonaConsistency,
|
|
129
|
+
calculatePersonaDiversity
|
|
130
|
+
} from './persona-enhanced.mjs';
|
|
131
|
+
export {
|
|
132
|
+
ExperienceTrace,
|
|
133
|
+
ExperienceTracerManager,
|
|
134
|
+
getTracerManager
|
|
135
|
+
} from './experience-tracer.mjs';
|
|
136
|
+
export {
|
|
137
|
+
ExperiencePropagationTracker,
|
|
138
|
+
getPropagationTracker,
|
|
139
|
+
trackPropagation
|
|
140
|
+
} from './experience-propagation.mjs';
|
|
141
|
+
export {
|
|
142
|
+
checkCrossModalConsistency,
|
|
143
|
+
validateExperienceConsistency
|
|
144
|
+
} from './cross-modal-consistency.mjs';
|
|
145
|
+
export {
|
|
146
|
+
generateDynamicPrompt,
|
|
147
|
+
generatePromptVariations,
|
|
148
|
+
generateInteractionPrompt,
|
|
149
|
+
generateGameplayPrompt
|
|
150
|
+
} from './dynamic-prompts.mjs';
|
|
151
|
+
export {
|
|
152
|
+
generateGamePrompt,
|
|
153
|
+
createGameGoal,
|
|
154
|
+
createGameGoals
|
|
155
|
+
} from './game-goal-prompts.mjs';
|
|
156
|
+
export {
|
|
157
|
+
AIBrowserTestError,
|
|
158
|
+
ValidationError,
|
|
159
|
+
CacheError,
|
|
160
|
+
ConfigError,
|
|
161
|
+
ProviderError,
|
|
162
|
+
TimeoutError,
|
|
163
|
+
FileError,
|
|
164
|
+
isAIBrowserTestError,
|
|
165
|
+
isErrorType
|
|
166
|
+
} from './errors.mjs';
|
|
167
|
+
export {
|
|
168
|
+
retryWithBackoff,
|
|
169
|
+
isRetryableError,
|
|
170
|
+
calculateBackoff,
|
|
171
|
+
enhanceErrorMessage
|
|
172
|
+
} from './retry.mjs';
|
|
173
|
+
export {
|
|
174
|
+
CostTracker,
|
|
175
|
+
getCostTracker,
|
|
176
|
+
recordCost,
|
|
177
|
+
getCostStats
|
|
178
|
+
} from './cost-tracker.mjs';
|
|
179
|
+
export {
|
|
180
|
+
DEFAULT_RUBRIC,
|
|
181
|
+
buildRubricPrompt,
|
|
182
|
+
getRubricForTestType
|
|
183
|
+
} from './rubrics.mjs';
|
|
184
|
+
export {
|
|
185
|
+
detectBias,
|
|
186
|
+
detectPositionBias
|
|
187
|
+
} from './bias-detector.mjs';
|
|
188
|
+
export {
|
|
189
|
+
comparePair,
|
|
190
|
+
rankBatch
|
|
191
|
+
} from './pair-comparison.mjs';
|
|
192
|
+
export {
|
|
193
|
+
detectHallucination
|
|
194
|
+
} from './hallucination-detector.mjs';
|
|
195
|
+
export {
|
|
196
|
+
applyBiasMitigation,
|
|
197
|
+
mitigateBias,
|
|
198
|
+
mitigatePositionBias
|
|
199
|
+
} from './bias-mitigation.mjs';
|
|
200
|
+
export {
|
|
201
|
+
validateWithResearchEnhancements,
|
|
202
|
+
validateMultipleWithPositionAnalysis,
|
|
203
|
+
validateWithLengthAlignment,
|
|
204
|
+
validateWithExplicitRubric,
|
|
205
|
+
validateWithAllResearchEnhancements
|
|
206
|
+
} from './research-enhanced-validation.mjs';
|
|
207
|
+
export {
|
|
208
|
+
aggregateMultiScale,
|
|
209
|
+
SequentialDecisionContext,
|
|
210
|
+
humanPerceptionTime
|
|
211
|
+
} from './temporal-decision.mjs';
|
|
212
|
+
export {
|
|
213
|
+
TIME_SCALES,
|
|
214
|
+
MULTI_SCALE_WINDOWS,
|
|
215
|
+
READING_SPEEDS,
|
|
216
|
+
ATTENTION_MULTIPLIERS,
|
|
217
|
+
COMPLEXITY_MULTIPLIERS,
|
|
218
|
+
CONFIDENCE_THRESHOLDS,
|
|
219
|
+
TIME_BOUNDS,
|
|
220
|
+
CONTENT_THRESHOLDS
|
|
221
|
+
} from './temporal-constants.mjs';
|
|
222
|
+
export {
|
|
223
|
+
TemporalError,
|
|
224
|
+
PerceptionTimeError,
|
|
225
|
+
SequentialContextError,
|
|
226
|
+
MultiScaleError,
|
|
227
|
+
TemporalBatchError
|
|
228
|
+
} from './temporal-errors.mjs';
|
|
229
|
+
export {
|
|
230
|
+
createTemporalContext,
|
|
231
|
+
mergeTemporalContext,
|
|
232
|
+
extractTemporalContext
|
|
233
|
+
} from './temporal-context.mjs';
|
|
234
|
+
export {
|
|
235
|
+
EnsembleJudge,
|
|
236
|
+
createEnsembleJudge
|
|
237
|
+
} from './ensemble-judge.mjs';
|
|
238
|
+
export {
|
|
239
|
+
HumanValidationManager,
|
|
240
|
+
getHumanValidationManager,
|
|
241
|
+
initHumanValidation
|
|
242
|
+
} from './human-validation-manager.mjs';
|
|
243
|
+
export {
|
|
244
|
+
isObject,
|
|
245
|
+
isString,
|
|
246
|
+
isNumber,
|
|
247
|
+
isArray,
|
|
248
|
+
isFunction,
|
|
249
|
+
isPromise,
|
|
250
|
+
isValidationResult,
|
|
251
|
+
isValidationContext,
|
|
252
|
+
isPersona,
|
|
253
|
+
isTemporalNote,
|
|
254
|
+
assertObject,
|
|
255
|
+
assertString,
|
|
256
|
+
assertNonEmptyString,
|
|
257
|
+
assertNumber,
|
|
258
|
+
assertArray,
|
|
259
|
+
assertFunction,
|
|
260
|
+
pick,
|
|
261
|
+
getProperty
|
|
262
|
+
} from './type-guards.mjs';
|
|
263
|
+
export {
|
|
264
|
+
evaluateWithCounterBalance,
|
|
265
|
+
shouldUseCounterBalance
|
|
266
|
+
} from './position-counterbalance.mjs';
|
|
267
|
+
export {
|
|
268
|
+
selectFewShotExamples,
|
|
269
|
+
formatFewShotExamples
|
|
270
|
+
} from './dynamic-few-shot.mjs';
|
|
271
|
+
export {
|
|
272
|
+
spearmanCorrelation,
|
|
273
|
+
pearsonCorrelation,
|
|
274
|
+
calculateRankAgreement
|
|
275
|
+
} from './metrics.mjs';
|
|
276
|
+
export {
|
|
277
|
+
composeSingleImagePrompt,
|
|
278
|
+
composeComparisonPrompt,
|
|
279
|
+
composeMultiModalPrompt
|
|
280
|
+
} from './prompt-composer.mjs';
|
|
281
|
+
export {
|
|
282
|
+
testGameplay,
|
|
283
|
+
testBrowserExperience,
|
|
284
|
+
validateWithGoals
|
|
285
|
+
} from './convenience.mjs';
|
|
286
|
+
|
|
287
|
+
// Game playing (optional - requires Playwright)
|
|
288
|
+
// Originally motivated by interactive web applications
|
|
289
|
+
export {
|
|
290
|
+
playGame,
|
|
291
|
+
GameGym,
|
|
292
|
+
decideGameAction,
|
|
293
|
+
executeGameAction
|
|
294
|
+
} from './game-player.mjs';
|
|
295
|
+
|
|
296
|
+
// Natural language specifications (LLM-parseable, not formal specs)
|
|
297
|
+
export {
|
|
298
|
+
parseSpec,
|
|
299
|
+
mapToInterfaces,
|
|
300
|
+
executeSpec,
|
|
301
|
+
generatePropertyTests,
|
|
302
|
+
testBehavior,
|
|
303
|
+
validateSpec
|
|
304
|
+
} from './natural-language-specs.mjs';
|
|
305
|
+
export {
|
|
306
|
+
TEMPLATES,
|
|
307
|
+
createSpecFromTemplate,
|
|
308
|
+
composeTemplates,
|
|
309
|
+
inheritTemplate,
|
|
310
|
+
registerTemplate,
|
|
311
|
+
listTemplates,
|
|
312
|
+
getTemplate,
|
|
313
|
+
validateTemplate
|
|
314
|
+
} from './spec-templates.mjs';
|
|
315
|
+
export {
|
|
316
|
+
createSpecConfig,
|
|
317
|
+
getSpecConfig,
|
|
318
|
+
setSpecConfig,
|
|
319
|
+
resetSpecConfig
|
|
320
|
+
} from './spec-config.mjs';
|
|
321
|
+
// Error analysis utilities (evaluation tools, not core API)
|
|
322
|
+
// Import from evaluation/utils/spec-error-analysis.mjs if needed
|
|
323
|
+
export {
|
|
324
|
+
validateSmart,
|
|
325
|
+
validateAccessibilitySmart,
|
|
326
|
+
validateStateSmart,
|
|
327
|
+
validateElementSmart,
|
|
328
|
+
detectValidationMethod
|
|
329
|
+
} from './smart-validator.mjs';
|
|
330
|
+
export {
|
|
331
|
+
selectModelTier,
|
|
332
|
+
selectProvider,
|
|
333
|
+
selectModelTierAndProvider
|
|
334
|
+
} from './model-tier-selector.mjs';
|
|
335
|
+
export { normalizeValidationResult } from './validation-result-normalizer.mjs';
|
|
336
|
+
export { CACHE_CONSTANTS, TEMPORAL_CONSTANTS, API_CONSTANTS, UNCERTAINTY_CONSTANTS, BATCH_OPTIMIZER_CONSTANTS } from './constants.mjs';
|
|
337
|
+
export {
|
|
338
|
+
StateValidator,
|
|
339
|
+
AccessibilityValidator,
|
|
340
|
+
PromptBuilder,
|
|
341
|
+
validateWithRubric,
|
|
342
|
+
BatchValidator
|
|
343
|
+
} from './validators/index.mjs';
|
|
344
|
+
|
|
345
|
+
// Programmatic validators (fast, deterministic)
|
|
346
|
+
export {
|
|
347
|
+
getContrastRatio,
|
|
348
|
+
checkElementContrast,
|
|
349
|
+
checkAllTextContrast,
|
|
350
|
+
checkKeyboardNavigation,
|
|
351
|
+
validateStateProgrammatic,
|
|
352
|
+
validateElementPosition
|
|
353
|
+
} from './validators/index.mjs';
|
|
354
|
+
|
|
355
|
+
// Hybrid validators (programmatic + VLLM)
|
|
356
|
+
export {
|
|
357
|
+
validateAccessibilityHybrid,
|
|
358
|
+
validateStateHybrid,
|
|
359
|
+
validateWithProgrammaticContext
|
|
360
|
+
} from './validators/index.mjs';
|
|
361
|
+
|
|
362
|
+
export { StateMismatchError } from './errors.mjs';
|
|
363
|
+
export { initErrorHandlers } from './error-handler.mjs';
|
|
364
|
+
|