@forkpoint/agent-lighthouse-core 0.2.4 → 0.4.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 +111 -5
- package/dist/index.d.ts +111 -5
- package/dist/index.js +1138 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1135 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -198,8 +198,89 @@ interface ReadinessVitals {
|
|
|
198
198
|
technical: number;
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
type
|
|
202
|
-
|
|
201
|
+
type PhaseId = 'fetch-root' | 'fetch-pages' | 'analyze' | 'audits' | 'report';
|
|
202
|
+
type ScanEvent = {
|
|
203
|
+
type: 'scan:start';
|
|
204
|
+
url: string;
|
|
205
|
+
fraction: number;
|
|
206
|
+
elapsedMs: number;
|
|
207
|
+
} | {
|
|
208
|
+
type: 'phase:start';
|
|
209
|
+
phase: PhaseId;
|
|
210
|
+
totalUnits: number;
|
|
211
|
+
fraction: number;
|
|
212
|
+
elapsedMs: number;
|
|
213
|
+
} | {
|
|
214
|
+
type: 'unit:done';
|
|
215
|
+
phase: PhaseId;
|
|
216
|
+
completed: number;
|
|
217
|
+
total: number;
|
|
218
|
+
label?: string;
|
|
219
|
+
fraction: number;
|
|
220
|
+
elapsedMs: number;
|
|
221
|
+
} | {
|
|
222
|
+
type: 'unit:fail';
|
|
223
|
+
phase: PhaseId;
|
|
224
|
+
label: string;
|
|
225
|
+
error: string;
|
|
226
|
+
fraction: number;
|
|
227
|
+
elapsedMs: number;
|
|
228
|
+
} | {
|
|
229
|
+
type: 'phase:done';
|
|
230
|
+
phase: PhaseId;
|
|
231
|
+
durationMs: number;
|
|
232
|
+
fraction: number;
|
|
233
|
+
elapsedMs: number;
|
|
234
|
+
} | {
|
|
235
|
+
type: 'scan:done';
|
|
236
|
+
durationMs: number;
|
|
237
|
+
score: number;
|
|
238
|
+
fraction: number;
|
|
239
|
+
elapsedMs: number;
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* How much of the overall scan fraction each phase owns. Sums to 1 so the
|
|
243
|
+
* fraction of a finished scan is exactly 1.
|
|
244
|
+
*/
|
|
245
|
+
declare const PHASE_WEIGHTS: Record<PhaseId, number>;
|
|
246
|
+
/**
|
|
247
|
+
* Turns scan milestones into {@link ScanEvent}s. Owns the fraction math
|
|
248
|
+
* (`Σ weights of done phases + current phase weight × completed/total`),
|
|
249
|
+
* clamps it to be monotonic non-decreasing, and stamps `fraction`/`elapsedMs`
|
|
250
|
+
* onto every event. Emission is synchronous — throttling is a consumer concern.
|
|
251
|
+
*/
|
|
252
|
+
declare class ProgressTracker {
|
|
253
|
+
private readonly onEvent;
|
|
254
|
+
private readonly startMs;
|
|
255
|
+
private doneWeight;
|
|
256
|
+
private phase;
|
|
257
|
+
private phaseStartMs;
|
|
258
|
+
private totalUnits;
|
|
259
|
+
private completedUnits;
|
|
260
|
+
private lastFraction;
|
|
261
|
+
constructor(onEvent: (event: ScanEvent) => void);
|
|
262
|
+
/** Fraction of the whole scan that is complete, in [0, 1]. Never decreases. */
|
|
263
|
+
get fraction(): number;
|
|
264
|
+
/** Stamp an event with the current fraction/elapsed and advance the floor. */
|
|
265
|
+
private stamp;
|
|
266
|
+
private elapsedMs;
|
|
267
|
+
scanStart(url: string): void;
|
|
268
|
+
phaseStart(phase: PhaseId, totalUnits: number): void;
|
|
269
|
+
/** Correct the current phase's unit total (e.g. discovery finds pages mid-phase). */
|
|
270
|
+
setPhaseTotal(totalUnits: number): void;
|
|
271
|
+
unitDone(label?: string): void;
|
|
272
|
+
/** A failed unit still counts as settled work so the phase can complete. */
|
|
273
|
+
unitFail(label: string, error: string): void;
|
|
274
|
+
phaseDone(): void;
|
|
275
|
+
scanDone(score: number): void;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
interface ScanOptions {
|
|
279
|
+
onEvent?: (event: ScanEvent) => void;
|
|
280
|
+
pages?: PageOverride[] | null;
|
|
281
|
+
signal?: AbortSignal;
|
|
282
|
+
}
|
|
283
|
+
declare function runScan(url: string, options?: ScanOptions): Promise<ScanReport>;
|
|
203
284
|
|
|
204
285
|
interface A11yNodeFinding {
|
|
205
286
|
target: string;
|
|
@@ -310,12 +391,37 @@ interface AuditRunResult {
|
|
|
310
391
|
categories: CategoryResult[];
|
|
311
392
|
overallScore: number;
|
|
312
393
|
}
|
|
313
|
-
|
|
394
|
+
/**
|
|
395
|
+
* Progress emitted per settled audit. The orchestrator forwards these into the
|
|
396
|
+
* ProgressTracker, which owns counting and fraction/elapsed stamping.
|
|
397
|
+
*/
|
|
398
|
+
type AuditProgressEvent = {
|
|
399
|
+
type: 'unit:done';
|
|
400
|
+
label: string;
|
|
401
|
+
} | {
|
|
402
|
+
type: 'unit:fail';
|
|
403
|
+
label: string;
|
|
404
|
+
error: string;
|
|
405
|
+
};
|
|
406
|
+
interface AuditPlan {
|
|
407
|
+
runnable: Array<{
|
|
408
|
+
reg: AuditRegistration;
|
|
409
|
+
categoryId: string;
|
|
410
|
+
}>;
|
|
411
|
+
skipped: CheckResult[];
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Split a scan config into the audits that will actually execute and the
|
|
415
|
+
* page-type-skipped `na` stubs. Exported so the orchestrator can size the
|
|
416
|
+
* audits progress phase before running it.
|
|
417
|
+
*/
|
|
418
|
+
declare function planAudits(ctx: CheckContext, config: ScanConfig): AuditPlan;
|
|
314
419
|
/**
|
|
315
420
|
* Execute all audits registered in the config against the scan context.
|
|
316
421
|
* Returns check results grouped into categories with weighted scores.
|
|
422
|
+
* Pass a precomputed `plan` (from {@link planAudits}) to avoid recomputing it.
|
|
317
423
|
*/
|
|
318
|
-
declare function runAudits(ctx: CheckContext, config: ScanConfig,
|
|
424
|
+
declare function runAudits(ctx: CheckContext, config: ScanConfig, onEvent?: (event: AuditProgressEvent) => void, plan?: AuditPlan): Promise<AuditRunResult>;
|
|
319
425
|
|
|
320
426
|
declare function parseHtml(html: string): CheerioAPI;
|
|
321
427
|
declare function extractJsonLd($: CheerioAPI): object[];
|
|
@@ -711,4 +817,4 @@ declare class Logger {
|
|
|
711
817
|
}
|
|
712
818
|
declare const logger: Logger;
|
|
713
819
|
|
|
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 };
|
|
820
|
+
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 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, isPrivateIp, isSafeUrl, joinUrl, loadConfigFile, logger, normalizeUrl, parseHtml, planAudits, runAudits, runScan };
|
package/dist/index.d.ts
CHANGED
|
@@ -198,8 +198,89 @@ interface ReadinessVitals {
|
|
|
198
198
|
technical: number;
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
type
|
|
202
|
-
|
|
201
|
+
type PhaseId = 'fetch-root' | 'fetch-pages' | 'analyze' | 'audits' | 'report';
|
|
202
|
+
type ScanEvent = {
|
|
203
|
+
type: 'scan:start';
|
|
204
|
+
url: string;
|
|
205
|
+
fraction: number;
|
|
206
|
+
elapsedMs: number;
|
|
207
|
+
} | {
|
|
208
|
+
type: 'phase:start';
|
|
209
|
+
phase: PhaseId;
|
|
210
|
+
totalUnits: number;
|
|
211
|
+
fraction: number;
|
|
212
|
+
elapsedMs: number;
|
|
213
|
+
} | {
|
|
214
|
+
type: 'unit:done';
|
|
215
|
+
phase: PhaseId;
|
|
216
|
+
completed: number;
|
|
217
|
+
total: number;
|
|
218
|
+
label?: string;
|
|
219
|
+
fraction: number;
|
|
220
|
+
elapsedMs: number;
|
|
221
|
+
} | {
|
|
222
|
+
type: 'unit:fail';
|
|
223
|
+
phase: PhaseId;
|
|
224
|
+
label: string;
|
|
225
|
+
error: string;
|
|
226
|
+
fraction: number;
|
|
227
|
+
elapsedMs: number;
|
|
228
|
+
} | {
|
|
229
|
+
type: 'phase:done';
|
|
230
|
+
phase: PhaseId;
|
|
231
|
+
durationMs: number;
|
|
232
|
+
fraction: number;
|
|
233
|
+
elapsedMs: number;
|
|
234
|
+
} | {
|
|
235
|
+
type: 'scan:done';
|
|
236
|
+
durationMs: number;
|
|
237
|
+
score: number;
|
|
238
|
+
fraction: number;
|
|
239
|
+
elapsedMs: number;
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* How much of the overall scan fraction each phase owns. Sums to 1 so the
|
|
243
|
+
* fraction of a finished scan is exactly 1.
|
|
244
|
+
*/
|
|
245
|
+
declare const PHASE_WEIGHTS: Record<PhaseId, number>;
|
|
246
|
+
/**
|
|
247
|
+
* Turns scan milestones into {@link ScanEvent}s. Owns the fraction math
|
|
248
|
+
* (`Σ weights of done phases + current phase weight × completed/total`),
|
|
249
|
+
* clamps it to be monotonic non-decreasing, and stamps `fraction`/`elapsedMs`
|
|
250
|
+
* onto every event. Emission is synchronous — throttling is a consumer concern.
|
|
251
|
+
*/
|
|
252
|
+
declare class ProgressTracker {
|
|
253
|
+
private readonly onEvent;
|
|
254
|
+
private readonly startMs;
|
|
255
|
+
private doneWeight;
|
|
256
|
+
private phase;
|
|
257
|
+
private phaseStartMs;
|
|
258
|
+
private totalUnits;
|
|
259
|
+
private completedUnits;
|
|
260
|
+
private lastFraction;
|
|
261
|
+
constructor(onEvent: (event: ScanEvent) => void);
|
|
262
|
+
/** Fraction of the whole scan that is complete, in [0, 1]. Never decreases. */
|
|
263
|
+
get fraction(): number;
|
|
264
|
+
/** Stamp an event with the current fraction/elapsed and advance the floor. */
|
|
265
|
+
private stamp;
|
|
266
|
+
private elapsedMs;
|
|
267
|
+
scanStart(url: string): void;
|
|
268
|
+
phaseStart(phase: PhaseId, totalUnits: number): void;
|
|
269
|
+
/** Correct the current phase's unit total (e.g. discovery finds pages mid-phase). */
|
|
270
|
+
setPhaseTotal(totalUnits: number): void;
|
|
271
|
+
unitDone(label?: string): void;
|
|
272
|
+
/** A failed unit still counts as settled work so the phase can complete. */
|
|
273
|
+
unitFail(label: string, error: string): void;
|
|
274
|
+
phaseDone(): void;
|
|
275
|
+
scanDone(score: number): void;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
interface ScanOptions {
|
|
279
|
+
onEvent?: (event: ScanEvent) => void;
|
|
280
|
+
pages?: PageOverride[] | null;
|
|
281
|
+
signal?: AbortSignal;
|
|
282
|
+
}
|
|
283
|
+
declare function runScan(url: string, options?: ScanOptions): Promise<ScanReport>;
|
|
203
284
|
|
|
204
285
|
interface A11yNodeFinding {
|
|
205
286
|
target: string;
|
|
@@ -310,12 +391,37 @@ interface AuditRunResult {
|
|
|
310
391
|
categories: CategoryResult[];
|
|
311
392
|
overallScore: number;
|
|
312
393
|
}
|
|
313
|
-
|
|
394
|
+
/**
|
|
395
|
+
* Progress emitted per settled audit. The orchestrator forwards these into the
|
|
396
|
+
* ProgressTracker, which owns counting and fraction/elapsed stamping.
|
|
397
|
+
*/
|
|
398
|
+
type AuditProgressEvent = {
|
|
399
|
+
type: 'unit:done';
|
|
400
|
+
label: string;
|
|
401
|
+
} | {
|
|
402
|
+
type: 'unit:fail';
|
|
403
|
+
label: string;
|
|
404
|
+
error: string;
|
|
405
|
+
};
|
|
406
|
+
interface AuditPlan {
|
|
407
|
+
runnable: Array<{
|
|
408
|
+
reg: AuditRegistration;
|
|
409
|
+
categoryId: string;
|
|
410
|
+
}>;
|
|
411
|
+
skipped: CheckResult[];
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Split a scan config into the audits that will actually execute and the
|
|
415
|
+
* page-type-skipped `na` stubs. Exported so the orchestrator can size the
|
|
416
|
+
* audits progress phase before running it.
|
|
417
|
+
*/
|
|
418
|
+
declare function planAudits(ctx: CheckContext, config: ScanConfig): AuditPlan;
|
|
314
419
|
/**
|
|
315
420
|
* Execute all audits registered in the config against the scan context.
|
|
316
421
|
* Returns check results grouped into categories with weighted scores.
|
|
422
|
+
* Pass a precomputed `plan` (from {@link planAudits}) to avoid recomputing it.
|
|
317
423
|
*/
|
|
318
|
-
declare function runAudits(ctx: CheckContext, config: ScanConfig,
|
|
424
|
+
declare function runAudits(ctx: CheckContext, config: ScanConfig, onEvent?: (event: AuditProgressEvent) => void, plan?: AuditPlan): Promise<AuditRunResult>;
|
|
319
425
|
|
|
320
426
|
declare function parseHtml(html: string): CheerioAPI;
|
|
321
427
|
declare function extractJsonLd($: CheerioAPI): object[];
|
|
@@ -711,4 +817,4 @@ declare class Logger {
|
|
|
711
817
|
}
|
|
712
818
|
declare const logger: Logger;
|
|
713
819
|
|
|
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 };
|
|
820
|
+
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 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, isPrivateIp, isSafeUrl, joinUrl, loadConfigFile, logger, normalizeUrl, parseHtml, planAudits, runAudits, runScan };
|