@forkpoint/agent-lighthouse-core 0.3.0 → 1.0.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/index.d.mts +177 -5
- package/dist/index.d.ts +177 -5
- package/dist/index.js +401 -1618
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +396 -1618
- package/dist/index.mjs.map +1 -1
- package/migration-map.json +110 -0
- package/package.json +5 -3
package/dist/index.d.mts
CHANGED
|
@@ -89,6 +89,13 @@ interface AuditGuidance {
|
|
|
89
89
|
tags?: string[];
|
|
90
90
|
}
|
|
91
91
|
type ScoreDisplayMode = 'binary' | 'ternary' | 'informative';
|
|
92
|
+
/** Public sunset notice for a deprecated audit (see docs/evidence/sunset/NOT-A-FACTOR.md). */
|
|
93
|
+
interface DeprecationNotice {
|
|
94
|
+
/** One sentence: why this signal is not a factor. */
|
|
95
|
+
notice: string;
|
|
96
|
+
/** Public rationale URL (NOT-A-FACTOR.md anchor). */
|
|
97
|
+
link: string;
|
|
98
|
+
}
|
|
92
99
|
interface AuditMeta {
|
|
93
100
|
id: string;
|
|
94
101
|
category: string;
|
|
@@ -100,6 +107,8 @@ interface AuditMeta {
|
|
|
100
107
|
applicablePageTypes?: PageType[];
|
|
101
108
|
defaultPriority: CheckPriority;
|
|
102
109
|
guidance?: AuditGuidance;
|
|
110
|
+
/** Present when the audit is sunset: shown as a notice, excluded from scores. */
|
|
111
|
+
deprecated?: DeprecationNotice;
|
|
103
112
|
}
|
|
104
113
|
interface AuditResult {
|
|
105
114
|
status: CheckStatus;
|
|
@@ -148,6 +157,8 @@ interface CheckResult {
|
|
|
148
157
|
[key: string]: unknown;
|
|
149
158
|
};
|
|
150
159
|
tags?: string[];
|
|
160
|
+
/** Present when the audit is sunset: shown as a notice, excluded from scores. */
|
|
161
|
+
deprecated?: DeprecationNotice;
|
|
151
162
|
}
|
|
152
163
|
interface CategoryResult {
|
|
153
164
|
id: string;
|
|
@@ -198,8 +209,89 @@ interface ReadinessVitals {
|
|
|
198
209
|
technical: number;
|
|
199
210
|
}
|
|
200
211
|
|
|
201
|
-
type
|
|
202
|
-
|
|
212
|
+
type PhaseId = 'fetch-root' | 'fetch-pages' | 'analyze' | 'audits' | 'report';
|
|
213
|
+
type ScanEvent = {
|
|
214
|
+
type: 'scan:start';
|
|
215
|
+
url: string;
|
|
216
|
+
fraction: number;
|
|
217
|
+
elapsedMs: number;
|
|
218
|
+
} | {
|
|
219
|
+
type: 'phase:start';
|
|
220
|
+
phase: PhaseId;
|
|
221
|
+
totalUnits: number;
|
|
222
|
+
fraction: number;
|
|
223
|
+
elapsedMs: number;
|
|
224
|
+
} | {
|
|
225
|
+
type: 'unit:done';
|
|
226
|
+
phase: PhaseId;
|
|
227
|
+
completed: number;
|
|
228
|
+
total: number;
|
|
229
|
+
label?: string;
|
|
230
|
+
fraction: number;
|
|
231
|
+
elapsedMs: number;
|
|
232
|
+
} | {
|
|
233
|
+
type: 'unit:fail';
|
|
234
|
+
phase: PhaseId;
|
|
235
|
+
label: string;
|
|
236
|
+
error: string;
|
|
237
|
+
fraction: number;
|
|
238
|
+
elapsedMs: number;
|
|
239
|
+
} | {
|
|
240
|
+
type: 'phase:done';
|
|
241
|
+
phase: PhaseId;
|
|
242
|
+
durationMs: number;
|
|
243
|
+
fraction: number;
|
|
244
|
+
elapsedMs: number;
|
|
245
|
+
} | {
|
|
246
|
+
type: 'scan:done';
|
|
247
|
+
durationMs: number;
|
|
248
|
+
score: number;
|
|
249
|
+
fraction: number;
|
|
250
|
+
elapsedMs: number;
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* How much of the overall scan fraction each phase owns. Sums to 1 so the
|
|
254
|
+
* fraction of a finished scan is exactly 1.
|
|
255
|
+
*/
|
|
256
|
+
declare const PHASE_WEIGHTS: Record<PhaseId, number>;
|
|
257
|
+
/**
|
|
258
|
+
* Turns scan milestones into {@link ScanEvent}s. Owns the fraction math
|
|
259
|
+
* (`Σ weights of done phases + current phase weight × completed/total`),
|
|
260
|
+
* clamps it to be monotonic non-decreasing, and stamps `fraction`/`elapsedMs`
|
|
261
|
+
* onto every event. Emission is synchronous — throttling is a consumer concern.
|
|
262
|
+
*/
|
|
263
|
+
declare class ProgressTracker {
|
|
264
|
+
private readonly onEvent;
|
|
265
|
+
private readonly startMs;
|
|
266
|
+
private doneWeight;
|
|
267
|
+
private phase;
|
|
268
|
+
private phaseStartMs;
|
|
269
|
+
private totalUnits;
|
|
270
|
+
private completedUnits;
|
|
271
|
+
private lastFraction;
|
|
272
|
+
constructor(onEvent: (event: ScanEvent) => void);
|
|
273
|
+
/** Fraction of the whole scan that is complete, in [0, 1]. Never decreases. */
|
|
274
|
+
get fraction(): number;
|
|
275
|
+
/** Stamp an event with the current fraction/elapsed and advance the floor. */
|
|
276
|
+
private stamp;
|
|
277
|
+
private elapsedMs;
|
|
278
|
+
scanStart(url: string): void;
|
|
279
|
+
phaseStart(phase: PhaseId, totalUnits: number): void;
|
|
280
|
+
/** Correct the current phase's unit total (e.g. discovery finds pages mid-phase). */
|
|
281
|
+
setPhaseTotal(totalUnits: number): void;
|
|
282
|
+
unitDone(label?: string): void;
|
|
283
|
+
/** A failed unit still counts as settled work so the phase can complete. */
|
|
284
|
+
unitFail(label: string, error: string): void;
|
|
285
|
+
phaseDone(): void;
|
|
286
|
+
scanDone(score: number): void;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
interface ScanOptions {
|
|
290
|
+
onEvent?: (event: ScanEvent) => void;
|
|
291
|
+
pages?: PageOverride[] | null;
|
|
292
|
+
signal?: AbortSignal;
|
|
293
|
+
}
|
|
294
|
+
declare function runScan(url: string, options?: ScanOptions): Promise<ScanReport>;
|
|
203
295
|
|
|
204
296
|
interface A11yNodeFinding {
|
|
205
297
|
target: string;
|
|
@@ -310,12 +402,37 @@ interface AuditRunResult {
|
|
|
310
402
|
categories: CategoryResult[];
|
|
311
403
|
overallScore: number;
|
|
312
404
|
}
|
|
313
|
-
|
|
405
|
+
/**
|
|
406
|
+
* Progress emitted per settled audit. The orchestrator forwards these into the
|
|
407
|
+
* ProgressTracker, which owns counting and fraction/elapsed stamping.
|
|
408
|
+
*/
|
|
409
|
+
type AuditProgressEvent = {
|
|
410
|
+
type: 'unit:done';
|
|
411
|
+
label: string;
|
|
412
|
+
} | {
|
|
413
|
+
type: 'unit:fail';
|
|
414
|
+
label: string;
|
|
415
|
+
error: string;
|
|
416
|
+
};
|
|
417
|
+
interface AuditPlan {
|
|
418
|
+
runnable: Array<{
|
|
419
|
+
reg: AuditRegistration;
|
|
420
|
+
categoryId: string;
|
|
421
|
+
}>;
|
|
422
|
+
skipped: CheckResult[];
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Split a scan config into the audits that will actually execute and the
|
|
426
|
+
* page-type-skipped `na` stubs. Exported so the orchestrator can size the
|
|
427
|
+
* audits progress phase before running it.
|
|
428
|
+
*/
|
|
429
|
+
declare function planAudits(ctx: CheckContext, config: ScanConfig): AuditPlan;
|
|
314
430
|
/**
|
|
315
431
|
* Execute all audits registered in the config against the scan context.
|
|
316
432
|
* Returns check results grouped into categories with weighted scores.
|
|
433
|
+
* Pass a precomputed `plan` (from {@link planAudits}) to avoid recomputing it.
|
|
317
434
|
*/
|
|
318
|
-
declare function runAudits(ctx: CheckContext, config: ScanConfig,
|
|
435
|
+
declare function runAudits(ctx: CheckContext, config: ScanConfig, onEvent?: (event: AuditProgressEvent) => void, plan?: AuditPlan): Promise<AuditRunResult>;
|
|
319
436
|
|
|
320
437
|
declare function parseHtml(html: string): CheerioAPI;
|
|
321
438
|
declare function extractJsonLd($: CheerioAPI): object[];
|
|
@@ -421,6 +538,15 @@ declare const SCORE_TIER_LABELS: Record<ScoreTier, string>;
|
|
|
421
538
|
declare function getTierLabel(tier: string | null): string;
|
|
422
539
|
declare function getTierColor(tier: string | null): string;
|
|
423
540
|
|
|
541
|
+
/**
|
|
542
|
+
* Single source of truth for "this check is advisory only".
|
|
543
|
+
*
|
|
544
|
+
* Informative checks (deprecated audits / no proven consumer) are still shown
|
|
545
|
+
* to the user, but they must never influence scores, recommendations, top
|
|
546
|
+
* fails/passes or readiness vitals. Every surface that ranks or scores checks
|
|
547
|
+
* filters through this predicate so the rule cannot drift per package.
|
|
548
|
+
*/
|
|
549
|
+
declare function isInformative(check: Pick<CheckResult, 'scoreDisplayMode'>): boolean;
|
|
424
550
|
declare function calculateCategoryScore(checks: CheckResult[]): number;
|
|
425
551
|
declare function buildCategoryResult(id: string, checks: CheckResult[]): CategoryResult;
|
|
426
552
|
declare function calculateOverallScore(categories: CategoryResult[]): number;
|
|
@@ -515,6 +641,16 @@ declare const AuditGuidanceSchema: z.ZodObject<{
|
|
|
515
641
|
tags?: string[] | undefined;
|
|
516
642
|
}>;
|
|
517
643
|
declare const ScoreDisplayModeSchema: z.ZodEnum<["binary", "ternary", "informative"]>;
|
|
644
|
+
declare const DeprecationNoticeSchema: z.ZodObject<{
|
|
645
|
+
notice: z.ZodString;
|
|
646
|
+
link: z.ZodString;
|
|
647
|
+
}, "strip", z.ZodTypeAny, {
|
|
648
|
+
link: string;
|
|
649
|
+
notice: string;
|
|
650
|
+
}, {
|
|
651
|
+
link: string;
|
|
652
|
+
notice: string;
|
|
653
|
+
}>;
|
|
518
654
|
declare const AuditMetaSchema: z.ZodObject<{
|
|
519
655
|
id: z.ZodString;
|
|
520
656
|
category: z.ZodString;
|
|
@@ -547,6 +683,16 @@ declare const AuditMetaSchema: z.ZodObject<{
|
|
|
547
683
|
docsUrl?: string | undefined;
|
|
548
684
|
tags?: string[] | undefined;
|
|
549
685
|
}>>;
|
|
686
|
+
deprecated: z.ZodOptional<z.ZodObject<{
|
|
687
|
+
notice: z.ZodString;
|
|
688
|
+
link: z.ZodString;
|
|
689
|
+
}, "strip", z.ZodTypeAny, {
|
|
690
|
+
link: string;
|
|
691
|
+
notice: string;
|
|
692
|
+
}, {
|
|
693
|
+
link: string;
|
|
694
|
+
notice: string;
|
|
695
|
+
}>>;
|
|
550
696
|
}, "strip", z.ZodTypeAny, {
|
|
551
697
|
category: string;
|
|
552
698
|
title: string;
|
|
@@ -565,6 +711,10 @@ declare const AuditMetaSchema: z.ZodObject<{
|
|
|
565
711
|
docsUrl?: string | undefined;
|
|
566
712
|
tags?: string[] | undefined;
|
|
567
713
|
} | undefined;
|
|
714
|
+
deprecated?: {
|
|
715
|
+
link: string;
|
|
716
|
+
notice: string;
|
|
717
|
+
} | undefined;
|
|
568
718
|
}, {
|
|
569
719
|
category: string;
|
|
570
720
|
title: string;
|
|
@@ -583,6 +733,10 @@ declare const AuditMetaSchema: z.ZodObject<{
|
|
|
583
733
|
docsUrl?: string | undefined;
|
|
584
734
|
tags?: string[] | undefined;
|
|
585
735
|
} | undefined;
|
|
736
|
+
deprecated?: {
|
|
737
|
+
link: string;
|
|
738
|
+
notice: string;
|
|
739
|
+
} | undefined;
|
|
586
740
|
}>;
|
|
587
741
|
declare const CheckResultSchema: z.ZodObject<{
|
|
588
742
|
id: z.ZodString;
|
|
@@ -615,6 +769,16 @@ declare const CheckResultSchema: z.ZodObject<{
|
|
|
615
769
|
docsUrl?: string | undefined;
|
|
616
770
|
}>>;
|
|
617
771
|
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
772
|
+
deprecated: z.ZodOptional<z.ZodObject<{
|
|
773
|
+
notice: z.ZodString;
|
|
774
|
+
link: z.ZodString;
|
|
775
|
+
}, "strip", z.ZodTypeAny, {
|
|
776
|
+
link: string;
|
|
777
|
+
notice: string;
|
|
778
|
+
}, {
|
|
779
|
+
link: string;
|
|
780
|
+
notice: string;
|
|
781
|
+
}>>;
|
|
618
782
|
}, "strip", z.ZodTypeAny, {
|
|
619
783
|
status: "warn" | "pass" | "fail" | "na";
|
|
620
784
|
category: string;
|
|
@@ -636,6 +800,10 @@ declare const CheckResultSchema: z.ZodObject<{
|
|
|
636
800
|
explanation?: string | undefined;
|
|
637
801
|
pageUrl?: string | undefined;
|
|
638
802
|
tags?: string[] | undefined;
|
|
803
|
+
deprecated?: {
|
|
804
|
+
link: string;
|
|
805
|
+
notice: string;
|
|
806
|
+
} | undefined;
|
|
639
807
|
}, {
|
|
640
808
|
status: "warn" | "pass" | "fail" | "na";
|
|
641
809
|
category: string;
|
|
@@ -657,6 +825,10 @@ declare const CheckResultSchema: z.ZodObject<{
|
|
|
657
825
|
explanation?: string | undefined;
|
|
658
826
|
pageUrl?: string | undefined;
|
|
659
827
|
tags?: string[] | undefined;
|
|
828
|
+
deprecated?: {
|
|
829
|
+
link: string;
|
|
830
|
+
notice: string;
|
|
831
|
+
} | undefined;
|
|
660
832
|
}>;
|
|
661
833
|
|
|
662
834
|
declare function normalizeUrl(input: string): string;
|
|
@@ -711,4 +883,4 @@ declare class Logger {
|
|
|
711
883
|
}
|
|
712
884
|
declare const logger: Logger;
|
|
713
885
|
|
|
714
|
-
export { type AgentLighthouseConfig, Audit, type AuditGuidance, AuditGuidanceSchema, type AuditMeta, AuditMetaSchema, type AuditRegistration, type AuditResult, AuditResultSchema, type AuditRunResult, CATEGORY_NAMES, CATEGORY_WEIGHTS, type CategoryConfig, type CategoryResult, type CheckContext, type CheckFn, type CheckPriority, CheckPrioritySchema, type CheckRecommendation, type CheckResult, CheckResultSchema, type CheckStatus, CheckStatusSchema, DEFAULT_SCAN_LIMIT, type FetchOptions, type FetchResult, type FieldStatus, type FixEffort, FixEffortSchema, MAX_CONCURRENT_REQUESTS, MAX_PAGES_PER_SCAN, MAX_RESPONSE_BODY_BYTES, PAGE_TYPE_LABELS, PRESETS, type PageContext, type PageOverride, type PageType, type PresetName, type PresetOptions, type ProductFieldVerification, READINESS_WEIGHTS, REQUEST_TIMEOUT_MS, type ReadinessVitals, SCANNER_USER_AGENT, SCAN_TIMEOUT_MS, SCORE_TIER_LABELS, type ScanConfig, type ScanReport, type ScoreDisplayMode, ScoreDisplayModeSchema, type ScoreTier, TAG_SCAN_ERROR, TAG_SKIPPED_PAGE_TYPE, type WafProtection, buildCategoryResult, calculateCategoryScore, calculateOverallScore, createFetcher, defaultConfig, defineConfig, detectPageType, detectWafProtection, extractDomain, extractForms, extractHeadLinks, extractHeadings, extractImages, extractInternalLinks, extractJsonLd, extractMarkdownLinks, extractMetaTags, extractNavLinks, extractProductFieldVerification, extractScripts, extractStylesheetUrls, flattenJsonLd, getMainContentText, getPreset, getScoreTier, getTierColor, getTierLabel, getWordCount, isPrivateIp, isSafeUrl, joinUrl, loadConfigFile, logger, normalizeUrl, parseHtml, runAudits, runScan };
|
|
886
|
+
export { type AgentLighthouseConfig, Audit, type AuditGuidance, AuditGuidanceSchema, type AuditMeta, AuditMetaSchema, type AuditPlan, type AuditProgressEvent, type AuditRegistration, type AuditResult, AuditResultSchema, type AuditRunResult, CATEGORY_NAMES, CATEGORY_WEIGHTS, type CategoryConfig, type CategoryResult, type CheckContext, type CheckFn, type CheckPriority, CheckPrioritySchema, type CheckRecommendation, type CheckResult, CheckResultSchema, type CheckStatus, CheckStatusSchema, DEFAULT_SCAN_LIMIT, type DeprecationNotice, DeprecationNoticeSchema, type FetchOptions, type FetchResult, type FieldStatus, type FixEffort, FixEffortSchema, MAX_CONCURRENT_REQUESTS, MAX_PAGES_PER_SCAN, MAX_RESPONSE_BODY_BYTES, PAGE_TYPE_LABELS, PHASE_WEIGHTS, PRESETS, type PageContext, type PageOverride, type PageType, type PhaseId, type PresetName, type PresetOptions, type ProductFieldVerification, ProgressTracker, READINESS_WEIGHTS, REQUEST_TIMEOUT_MS, type ReadinessVitals, SCANNER_USER_AGENT, SCAN_TIMEOUT_MS, SCORE_TIER_LABELS, type ScanConfig, type ScanEvent, type ScanOptions, type ScanReport, type ScoreDisplayMode, ScoreDisplayModeSchema, type ScoreTier, TAG_SCAN_ERROR, TAG_SKIPPED_PAGE_TYPE, type WafProtection, buildCategoryResult, calculateCategoryScore, calculateOverallScore, createFetcher, defaultConfig, defineConfig, detectPageType, detectWafProtection, extractDomain, extractForms, extractHeadLinks, extractHeadings, extractImages, extractInternalLinks, extractJsonLd, extractMarkdownLinks, extractMetaTags, extractNavLinks, extractProductFieldVerification, extractScripts, extractStylesheetUrls, flattenJsonLd, getMainContentText, getPreset, getScoreTier, getTierColor, getTierLabel, getWordCount, isInformative, isPrivateIp, isSafeUrl, joinUrl, loadConfigFile, logger, normalizeUrl, parseHtml, planAudits, runAudits, runScan };
|
package/dist/index.d.ts
CHANGED
|
@@ -89,6 +89,13 @@ interface AuditGuidance {
|
|
|
89
89
|
tags?: string[];
|
|
90
90
|
}
|
|
91
91
|
type ScoreDisplayMode = 'binary' | 'ternary' | 'informative';
|
|
92
|
+
/** Public sunset notice for a deprecated audit (see docs/evidence/sunset/NOT-A-FACTOR.md). */
|
|
93
|
+
interface DeprecationNotice {
|
|
94
|
+
/** One sentence: why this signal is not a factor. */
|
|
95
|
+
notice: string;
|
|
96
|
+
/** Public rationale URL (NOT-A-FACTOR.md anchor). */
|
|
97
|
+
link: string;
|
|
98
|
+
}
|
|
92
99
|
interface AuditMeta {
|
|
93
100
|
id: string;
|
|
94
101
|
category: string;
|
|
@@ -100,6 +107,8 @@ interface AuditMeta {
|
|
|
100
107
|
applicablePageTypes?: PageType[];
|
|
101
108
|
defaultPriority: CheckPriority;
|
|
102
109
|
guidance?: AuditGuidance;
|
|
110
|
+
/** Present when the audit is sunset: shown as a notice, excluded from scores. */
|
|
111
|
+
deprecated?: DeprecationNotice;
|
|
103
112
|
}
|
|
104
113
|
interface AuditResult {
|
|
105
114
|
status: CheckStatus;
|
|
@@ -148,6 +157,8 @@ interface CheckResult {
|
|
|
148
157
|
[key: string]: unknown;
|
|
149
158
|
};
|
|
150
159
|
tags?: string[];
|
|
160
|
+
/** Present when the audit is sunset: shown as a notice, excluded from scores. */
|
|
161
|
+
deprecated?: DeprecationNotice;
|
|
151
162
|
}
|
|
152
163
|
interface CategoryResult {
|
|
153
164
|
id: string;
|
|
@@ -198,8 +209,89 @@ interface ReadinessVitals {
|
|
|
198
209
|
technical: number;
|
|
199
210
|
}
|
|
200
211
|
|
|
201
|
-
type
|
|
202
|
-
|
|
212
|
+
type PhaseId = 'fetch-root' | 'fetch-pages' | 'analyze' | 'audits' | 'report';
|
|
213
|
+
type ScanEvent = {
|
|
214
|
+
type: 'scan:start';
|
|
215
|
+
url: string;
|
|
216
|
+
fraction: number;
|
|
217
|
+
elapsedMs: number;
|
|
218
|
+
} | {
|
|
219
|
+
type: 'phase:start';
|
|
220
|
+
phase: PhaseId;
|
|
221
|
+
totalUnits: number;
|
|
222
|
+
fraction: number;
|
|
223
|
+
elapsedMs: number;
|
|
224
|
+
} | {
|
|
225
|
+
type: 'unit:done';
|
|
226
|
+
phase: PhaseId;
|
|
227
|
+
completed: number;
|
|
228
|
+
total: number;
|
|
229
|
+
label?: string;
|
|
230
|
+
fraction: number;
|
|
231
|
+
elapsedMs: number;
|
|
232
|
+
} | {
|
|
233
|
+
type: 'unit:fail';
|
|
234
|
+
phase: PhaseId;
|
|
235
|
+
label: string;
|
|
236
|
+
error: string;
|
|
237
|
+
fraction: number;
|
|
238
|
+
elapsedMs: number;
|
|
239
|
+
} | {
|
|
240
|
+
type: 'phase:done';
|
|
241
|
+
phase: PhaseId;
|
|
242
|
+
durationMs: number;
|
|
243
|
+
fraction: number;
|
|
244
|
+
elapsedMs: number;
|
|
245
|
+
} | {
|
|
246
|
+
type: 'scan:done';
|
|
247
|
+
durationMs: number;
|
|
248
|
+
score: number;
|
|
249
|
+
fraction: number;
|
|
250
|
+
elapsedMs: number;
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* How much of the overall scan fraction each phase owns. Sums to 1 so the
|
|
254
|
+
* fraction of a finished scan is exactly 1.
|
|
255
|
+
*/
|
|
256
|
+
declare const PHASE_WEIGHTS: Record<PhaseId, number>;
|
|
257
|
+
/**
|
|
258
|
+
* Turns scan milestones into {@link ScanEvent}s. Owns the fraction math
|
|
259
|
+
* (`Σ weights of done phases + current phase weight × completed/total`),
|
|
260
|
+
* clamps it to be monotonic non-decreasing, and stamps `fraction`/`elapsedMs`
|
|
261
|
+
* onto every event. Emission is synchronous — throttling is a consumer concern.
|
|
262
|
+
*/
|
|
263
|
+
declare class ProgressTracker {
|
|
264
|
+
private readonly onEvent;
|
|
265
|
+
private readonly startMs;
|
|
266
|
+
private doneWeight;
|
|
267
|
+
private phase;
|
|
268
|
+
private phaseStartMs;
|
|
269
|
+
private totalUnits;
|
|
270
|
+
private completedUnits;
|
|
271
|
+
private lastFraction;
|
|
272
|
+
constructor(onEvent: (event: ScanEvent) => void);
|
|
273
|
+
/** Fraction of the whole scan that is complete, in [0, 1]. Never decreases. */
|
|
274
|
+
get fraction(): number;
|
|
275
|
+
/** Stamp an event with the current fraction/elapsed and advance the floor. */
|
|
276
|
+
private stamp;
|
|
277
|
+
private elapsedMs;
|
|
278
|
+
scanStart(url: string): void;
|
|
279
|
+
phaseStart(phase: PhaseId, totalUnits: number): void;
|
|
280
|
+
/** Correct the current phase's unit total (e.g. discovery finds pages mid-phase). */
|
|
281
|
+
setPhaseTotal(totalUnits: number): void;
|
|
282
|
+
unitDone(label?: string): void;
|
|
283
|
+
/** A failed unit still counts as settled work so the phase can complete. */
|
|
284
|
+
unitFail(label: string, error: string): void;
|
|
285
|
+
phaseDone(): void;
|
|
286
|
+
scanDone(score: number): void;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
interface ScanOptions {
|
|
290
|
+
onEvent?: (event: ScanEvent) => void;
|
|
291
|
+
pages?: PageOverride[] | null;
|
|
292
|
+
signal?: AbortSignal;
|
|
293
|
+
}
|
|
294
|
+
declare function runScan(url: string, options?: ScanOptions): Promise<ScanReport>;
|
|
203
295
|
|
|
204
296
|
interface A11yNodeFinding {
|
|
205
297
|
target: string;
|
|
@@ -310,12 +402,37 @@ interface AuditRunResult {
|
|
|
310
402
|
categories: CategoryResult[];
|
|
311
403
|
overallScore: number;
|
|
312
404
|
}
|
|
313
|
-
|
|
405
|
+
/**
|
|
406
|
+
* Progress emitted per settled audit. The orchestrator forwards these into the
|
|
407
|
+
* ProgressTracker, which owns counting and fraction/elapsed stamping.
|
|
408
|
+
*/
|
|
409
|
+
type AuditProgressEvent = {
|
|
410
|
+
type: 'unit:done';
|
|
411
|
+
label: string;
|
|
412
|
+
} | {
|
|
413
|
+
type: 'unit:fail';
|
|
414
|
+
label: string;
|
|
415
|
+
error: string;
|
|
416
|
+
};
|
|
417
|
+
interface AuditPlan {
|
|
418
|
+
runnable: Array<{
|
|
419
|
+
reg: AuditRegistration;
|
|
420
|
+
categoryId: string;
|
|
421
|
+
}>;
|
|
422
|
+
skipped: CheckResult[];
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Split a scan config into the audits that will actually execute and the
|
|
426
|
+
* page-type-skipped `na` stubs. Exported so the orchestrator can size the
|
|
427
|
+
* audits progress phase before running it.
|
|
428
|
+
*/
|
|
429
|
+
declare function planAudits(ctx: CheckContext, config: ScanConfig): AuditPlan;
|
|
314
430
|
/**
|
|
315
431
|
* Execute all audits registered in the config against the scan context.
|
|
316
432
|
* Returns check results grouped into categories with weighted scores.
|
|
433
|
+
* Pass a precomputed `plan` (from {@link planAudits}) to avoid recomputing it.
|
|
317
434
|
*/
|
|
318
|
-
declare function runAudits(ctx: CheckContext, config: ScanConfig,
|
|
435
|
+
declare function runAudits(ctx: CheckContext, config: ScanConfig, onEvent?: (event: AuditProgressEvent) => void, plan?: AuditPlan): Promise<AuditRunResult>;
|
|
319
436
|
|
|
320
437
|
declare function parseHtml(html: string): CheerioAPI;
|
|
321
438
|
declare function extractJsonLd($: CheerioAPI): object[];
|
|
@@ -421,6 +538,15 @@ declare const SCORE_TIER_LABELS: Record<ScoreTier, string>;
|
|
|
421
538
|
declare function getTierLabel(tier: string | null): string;
|
|
422
539
|
declare function getTierColor(tier: string | null): string;
|
|
423
540
|
|
|
541
|
+
/**
|
|
542
|
+
* Single source of truth for "this check is advisory only".
|
|
543
|
+
*
|
|
544
|
+
* Informative checks (deprecated audits / no proven consumer) are still shown
|
|
545
|
+
* to the user, but they must never influence scores, recommendations, top
|
|
546
|
+
* fails/passes or readiness vitals. Every surface that ranks or scores checks
|
|
547
|
+
* filters through this predicate so the rule cannot drift per package.
|
|
548
|
+
*/
|
|
549
|
+
declare function isInformative(check: Pick<CheckResult, 'scoreDisplayMode'>): boolean;
|
|
424
550
|
declare function calculateCategoryScore(checks: CheckResult[]): number;
|
|
425
551
|
declare function buildCategoryResult(id: string, checks: CheckResult[]): CategoryResult;
|
|
426
552
|
declare function calculateOverallScore(categories: CategoryResult[]): number;
|
|
@@ -515,6 +641,16 @@ declare const AuditGuidanceSchema: z.ZodObject<{
|
|
|
515
641
|
tags?: string[] | undefined;
|
|
516
642
|
}>;
|
|
517
643
|
declare const ScoreDisplayModeSchema: z.ZodEnum<["binary", "ternary", "informative"]>;
|
|
644
|
+
declare const DeprecationNoticeSchema: z.ZodObject<{
|
|
645
|
+
notice: z.ZodString;
|
|
646
|
+
link: z.ZodString;
|
|
647
|
+
}, "strip", z.ZodTypeAny, {
|
|
648
|
+
link: string;
|
|
649
|
+
notice: string;
|
|
650
|
+
}, {
|
|
651
|
+
link: string;
|
|
652
|
+
notice: string;
|
|
653
|
+
}>;
|
|
518
654
|
declare const AuditMetaSchema: z.ZodObject<{
|
|
519
655
|
id: z.ZodString;
|
|
520
656
|
category: z.ZodString;
|
|
@@ -547,6 +683,16 @@ declare const AuditMetaSchema: z.ZodObject<{
|
|
|
547
683
|
docsUrl?: string | undefined;
|
|
548
684
|
tags?: string[] | undefined;
|
|
549
685
|
}>>;
|
|
686
|
+
deprecated: z.ZodOptional<z.ZodObject<{
|
|
687
|
+
notice: z.ZodString;
|
|
688
|
+
link: z.ZodString;
|
|
689
|
+
}, "strip", z.ZodTypeAny, {
|
|
690
|
+
link: string;
|
|
691
|
+
notice: string;
|
|
692
|
+
}, {
|
|
693
|
+
link: string;
|
|
694
|
+
notice: string;
|
|
695
|
+
}>>;
|
|
550
696
|
}, "strip", z.ZodTypeAny, {
|
|
551
697
|
category: string;
|
|
552
698
|
title: string;
|
|
@@ -565,6 +711,10 @@ declare const AuditMetaSchema: z.ZodObject<{
|
|
|
565
711
|
docsUrl?: string | undefined;
|
|
566
712
|
tags?: string[] | undefined;
|
|
567
713
|
} | undefined;
|
|
714
|
+
deprecated?: {
|
|
715
|
+
link: string;
|
|
716
|
+
notice: string;
|
|
717
|
+
} | undefined;
|
|
568
718
|
}, {
|
|
569
719
|
category: string;
|
|
570
720
|
title: string;
|
|
@@ -583,6 +733,10 @@ declare const AuditMetaSchema: z.ZodObject<{
|
|
|
583
733
|
docsUrl?: string | undefined;
|
|
584
734
|
tags?: string[] | undefined;
|
|
585
735
|
} | undefined;
|
|
736
|
+
deprecated?: {
|
|
737
|
+
link: string;
|
|
738
|
+
notice: string;
|
|
739
|
+
} | undefined;
|
|
586
740
|
}>;
|
|
587
741
|
declare const CheckResultSchema: z.ZodObject<{
|
|
588
742
|
id: z.ZodString;
|
|
@@ -615,6 +769,16 @@ declare const CheckResultSchema: z.ZodObject<{
|
|
|
615
769
|
docsUrl?: string | undefined;
|
|
616
770
|
}>>;
|
|
617
771
|
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
772
|
+
deprecated: z.ZodOptional<z.ZodObject<{
|
|
773
|
+
notice: z.ZodString;
|
|
774
|
+
link: z.ZodString;
|
|
775
|
+
}, "strip", z.ZodTypeAny, {
|
|
776
|
+
link: string;
|
|
777
|
+
notice: string;
|
|
778
|
+
}, {
|
|
779
|
+
link: string;
|
|
780
|
+
notice: string;
|
|
781
|
+
}>>;
|
|
618
782
|
}, "strip", z.ZodTypeAny, {
|
|
619
783
|
status: "warn" | "pass" | "fail" | "na";
|
|
620
784
|
category: string;
|
|
@@ -636,6 +800,10 @@ declare const CheckResultSchema: z.ZodObject<{
|
|
|
636
800
|
explanation?: string | undefined;
|
|
637
801
|
pageUrl?: string | undefined;
|
|
638
802
|
tags?: string[] | undefined;
|
|
803
|
+
deprecated?: {
|
|
804
|
+
link: string;
|
|
805
|
+
notice: string;
|
|
806
|
+
} | undefined;
|
|
639
807
|
}, {
|
|
640
808
|
status: "warn" | "pass" | "fail" | "na";
|
|
641
809
|
category: string;
|
|
@@ -657,6 +825,10 @@ declare const CheckResultSchema: z.ZodObject<{
|
|
|
657
825
|
explanation?: string | undefined;
|
|
658
826
|
pageUrl?: string | undefined;
|
|
659
827
|
tags?: string[] | undefined;
|
|
828
|
+
deprecated?: {
|
|
829
|
+
link: string;
|
|
830
|
+
notice: string;
|
|
831
|
+
} | undefined;
|
|
660
832
|
}>;
|
|
661
833
|
|
|
662
834
|
declare function normalizeUrl(input: string): string;
|
|
@@ -711,4 +883,4 @@ declare class Logger {
|
|
|
711
883
|
}
|
|
712
884
|
declare const logger: Logger;
|
|
713
885
|
|
|
714
|
-
export { type AgentLighthouseConfig, Audit, type AuditGuidance, AuditGuidanceSchema, type AuditMeta, AuditMetaSchema, type AuditRegistration, type AuditResult, AuditResultSchema, type AuditRunResult, CATEGORY_NAMES, CATEGORY_WEIGHTS, type CategoryConfig, type CategoryResult, type CheckContext, type CheckFn, type CheckPriority, CheckPrioritySchema, type CheckRecommendation, type CheckResult, CheckResultSchema, type CheckStatus, CheckStatusSchema, DEFAULT_SCAN_LIMIT, type FetchOptions, type FetchResult, type FieldStatus, type FixEffort, FixEffortSchema, MAX_CONCURRENT_REQUESTS, MAX_PAGES_PER_SCAN, MAX_RESPONSE_BODY_BYTES, PAGE_TYPE_LABELS, PRESETS, type PageContext, type PageOverride, type PageType, type PresetName, type PresetOptions, type ProductFieldVerification, READINESS_WEIGHTS, REQUEST_TIMEOUT_MS, type ReadinessVitals, SCANNER_USER_AGENT, SCAN_TIMEOUT_MS, SCORE_TIER_LABELS, type ScanConfig, type ScanReport, type ScoreDisplayMode, ScoreDisplayModeSchema, type ScoreTier, TAG_SCAN_ERROR, TAG_SKIPPED_PAGE_TYPE, type WafProtection, buildCategoryResult, calculateCategoryScore, calculateOverallScore, createFetcher, defaultConfig, defineConfig, detectPageType, detectWafProtection, extractDomain, extractForms, extractHeadLinks, extractHeadings, extractImages, extractInternalLinks, extractJsonLd, extractMarkdownLinks, extractMetaTags, extractNavLinks, extractProductFieldVerification, extractScripts, extractStylesheetUrls, flattenJsonLd, getMainContentText, getPreset, getScoreTier, getTierColor, getTierLabel, getWordCount, isPrivateIp, isSafeUrl, joinUrl, loadConfigFile, logger, normalizeUrl, parseHtml, runAudits, runScan };
|
|
886
|
+
export { type AgentLighthouseConfig, Audit, type AuditGuidance, AuditGuidanceSchema, type AuditMeta, AuditMetaSchema, type AuditPlan, type AuditProgressEvent, type AuditRegistration, type AuditResult, AuditResultSchema, type AuditRunResult, CATEGORY_NAMES, CATEGORY_WEIGHTS, type CategoryConfig, type CategoryResult, type CheckContext, type CheckFn, type CheckPriority, CheckPrioritySchema, type CheckRecommendation, type CheckResult, CheckResultSchema, type CheckStatus, CheckStatusSchema, DEFAULT_SCAN_LIMIT, type DeprecationNotice, DeprecationNoticeSchema, type FetchOptions, type FetchResult, type FieldStatus, type FixEffort, FixEffortSchema, MAX_CONCURRENT_REQUESTS, MAX_PAGES_PER_SCAN, MAX_RESPONSE_BODY_BYTES, PAGE_TYPE_LABELS, PHASE_WEIGHTS, PRESETS, type PageContext, type PageOverride, type PageType, type PhaseId, type PresetName, type PresetOptions, type ProductFieldVerification, ProgressTracker, READINESS_WEIGHTS, REQUEST_TIMEOUT_MS, type ReadinessVitals, SCANNER_USER_AGENT, SCAN_TIMEOUT_MS, SCORE_TIER_LABELS, type ScanConfig, type ScanEvent, type ScanOptions, type ScanReport, type ScoreDisplayMode, ScoreDisplayModeSchema, type ScoreTier, TAG_SCAN_ERROR, TAG_SKIPPED_PAGE_TYPE, type WafProtection, buildCategoryResult, calculateCategoryScore, calculateOverallScore, createFetcher, defaultConfig, defineConfig, detectPageType, detectWafProtection, extractDomain, extractForms, extractHeadLinks, extractHeadings, extractImages, extractInternalLinks, extractJsonLd, extractMarkdownLinks, extractMetaTags, extractNavLinks, extractProductFieldVerification, extractScripts, extractStylesheetUrls, flattenJsonLd, getMainContentText, getPreset, getScoreTier, getTierColor, getTierLabel, getWordCount, isInformative, isPrivateIp, isSafeUrl, joinUrl, loadConfigFile, logger, normalizeUrl, parseHtml, planAudits, runAudits, runScan };
|