@forkpoint/agent-lighthouse-core 3.0.0 → 4.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 CHANGED
@@ -1,12 +1,14 @@
1
+ import { Dispatcher } from 'undici';
1
2
  import { CheerioAPI } from 'cheerio';
2
3
  import { z } from 'zod';
3
4
 
5
+ declare function isSafeUrl(url: string): Promise<boolean>;
4
6
  interface FetchOptions {
5
7
  url: string;
6
8
  timeout?: number;
7
9
  followRedirects?: boolean;
8
10
  acceptHeader?: string;
9
- method?: 'GET' | 'POST' | 'OPTIONS' | 'HEAD' | 'DELETE';
11
+ method?: "GET" | "POST" | "OPTIONS" | "HEAD" | "DELETE";
10
12
  body?: string;
11
13
  contentType?: string;
12
14
  /** Override the User-Agent header (e.g. to probe a site as a specific AI bot). */
@@ -56,18 +58,54 @@ interface FetchResult {
56
58
  }>;
57
59
  error?: string;
58
60
  }
61
+ interface FetcherOptions {
62
+ /**
63
+ * undici dispatcher for every request this fetcher makes.
64
+ *
65
+ * Omitted, requests go through a shared `new Agent()` whose per-origin
66
+ * connection count is unlimited — right for a site owner scanning their own
67
+ * site, who wants the scan over quickly. A caller scanning origins that did
68
+ * not invite it passes a bounded agent (`new Agent({ connections: 2 })`) so
69
+ * one scan cannot open 28 sockets at once against a stranger's WAF.
70
+ */
71
+ dispatcher?: Dispatcher;
72
+ /**
73
+ * How many requests this fetcher may have in flight at once.
74
+ *
75
+ * Omitted, there is no ceiling and every request is issued as it arrives.
76
+ *
77
+ * A bounded dispatcher alone is not enough for a caller that wants one, and
78
+ * the difference is what the clocks measure. `Agent({ connections: 2 })`
79
+ * accepts all 26 root-file requests the scan fires in one `Promise.all` and
80
+ * queues 24 of them inside undici — but the per-request deadline and the
81
+ * `ttfbMs` clock both start when `fetch()` is called, so an origin averaging
82
+ * 800 ms per file would have its tail requests time out on the scanner's own
83
+ * queue and be reported as unreachable. Waiting here instead holds a request
84
+ * outside both clocks until it can actually be issued, so what they measure
85
+ * is the origin.
86
+ */
87
+ maxConcurrent?: number;
88
+ /**
89
+ * Extra HTTP headers sent with every request from this fetcher.
90
+ */
91
+ headers?: Record<string, string>;
92
+ }
59
93
  /**
60
- * Validates that a URL is safe to fetch (http/https scheme, non-private IP).
61
- * Use before fetching any URL extracted from scanned site content.
94
+ * A dispatcher that opens at most `connections` sockets per origin.
95
+ *
96
+ * The scanner's own default has no such ceiling, and for a site owner scanning
97
+ * their own site that is the right trade. A caller scanning origins that did
98
+ * not invite it wants the ceiling, and this saves it from taking a direct
99
+ * dependency on undici to express one line of politeness.
62
100
  */
63
- declare function isSafeUrl(url: string): Promise<boolean>;
64
- declare function createFetcher(): {
101
+ declare function boundedDispatcher(connections: number): Dispatcher;
102
+ declare function createFetcher(fetcherOptions?: FetcherOptions): {
65
103
  fetch: (options: FetchOptions) => Promise<FetchResult>;
66
104
  };
67
105
 
68
106
  interface WafProtection {
69
107
  isBlocked: boolean;
70
- provider?: 'akamai' | 'cloudflare' | 'datadome' | 'perimeterx' | 'imperva' | 'kasada' | 'aws-waf' | 'generic-waf' | 'connection-drop' | 'rate-limited';
108
+ provider?: "akamai" | "cloudflare" | "datadome" | "perimeterx" | "imperva" | "kasada" | "aws-waf" | "generic-waf" | "connection-drop" | "rate-limited";
71
109
  name: string;
72
110
  reason: string;
73
111
  statusCode?: number;
@@ -89,7 +127,7 @@ interface WafProtection {
89
127
  */
90
128
  declare function detectWafProtection(targetUrl: string, homepageResult: FetchResult | null, rootFiles: Record<string, FetchResult>, scannedPagesCount: number): WafProtection | null;
91
129
 
92
- type PageType = 'homepage' | 'category' | 'product' | 'content';
130
+ type PageType = "homepage" | "category" | "product" | "content";
93
131
  declare const PAGE_TYPE_LABELS: Record<PageType, string>;
94
132
  /**
95
133
  * A user-supplied page to scan with an explicit type.
@@ -99,7 +137,7 @@ interface PageOverride {
99
137
  pageType: PageType;
100
138
  }
101
139
  /** Per-field presence in a product page's structured data. */
102
- type FieldStatus = 'found' | 'partial' | 'missing';
140
+ type FieldStatus = "found" | "partial" | "missing";
103
141
  /**
104
142
  * Field-level verification of a product page, read directly from its structured
105
143
  * data (JSON-LD + Microdata + RDFa).
@@ -115,7 +153,7 @@ interface ProductFieldVerification {
115
153
  reviewCount: FieldStatus;
116
154
  sourceUrl?: string;
117
155
  }
118
- type FixEffort = 'trivial' | 'easy' | 'moderate' | 'complex';
156
+ type FixEffort = "trivial" | "easy" | "moderate" | "complex";
119
157
  interface AuditGuidance {
120
158
  /** Customer-facing explanation of business impact when this audit fails */
121
159
  impact: string;
@@ -130,7 +168,7 @@ interface AuditGuidance {
130
168
  /** Tags for filtering/grouping in the report UI */
131
169
  tags?: string[];
132
170
  }
133
- type ScoreDisplayMode = 'binary' | 'ternary' | 'informative';
171
+ type ScoreDisplayMode = "binary" | "ternary" | "informative";
134
172
  /** Public sunset notice for a deprecated audit (see docs/evidence/sunset/not-a-factor.md). */
135
173
  interface DeprecationNotice {
136
174
  /** One sentence: why this signal is not a factor. */
@@ -142,12 +180,12 @@ interface DeprecationNotice {
142
180
  * Strength of the published evidence backing an audit, assigned in the audit's
143
181
  * dossier per docs/evidence/policy.md. Only A and B carry scoring weight.
144
182
  */
145
- type EvidenceGrade = 'A' | 'B' | 'C' | 'D';
183
+ type EvidenceGrade = "A" | "B" | "C" | "D";
146
184
  /**
147
185
  * How an audit participates in scoring. Derived from its evidence grade
148
186
  * (spec §4): only `scored` audits move a category score.
149
187
  */
150
- type AuditTier = 'scored' | 'informative' | 'experimental';
188
+ type AuditTier = "scored" | "informative" | "experimental";
151
189
  interface AuditMeta {
152
190
  id: string;
153
191
  category: string;
@@ -156,6 +194,7 @@ interface AuditMeta {
156
194
  description: string;
157
195
  scoreDisplayMode: ScoreDisplayMode;
158
196
  weight: number;
197
+ pageTypes?: PageType[];
159
198
  applicablePageTypes?: PageType[];
160
199
  defaultPriority: CheckPriority;
161
200
  guidance?: AuditGuidance;
@@ -185,7 +224,7 @@ interface AuditMeta {
185
224
  * Declared here rather than in `scan-evidence.ts` so `AuditMeta` can name it
186
225
  * without the audit layer importing the scan layer.
187
226
  */
188
- type EvidenceKey = 'origin-reachable' | 'unblocked-fetches' | 'rendered-body' | 'sample-adequate';
227
+ type EvidenceKey = "origin-reachable" | "unblocked-fetches" | "rendered-body" | "sample-adequate";
189
228
  interface AuditResult {
190
229
  status: CheckStatus;
191
230
  score: number;
@@ -210,8 +249,8 @@ interface AuditResult {
210
249
  */
211
250
  remediation?: string;
212
251
  }
213
- type CheckStatus = 'pass' | 'warn' | 'fail' | 'na';
214
- type CheckPriority = 'critical' | 'high' | 'medium' | 'low';
252
+ type CheckStatus = "pass" | "warn" | "fail" | "na";
253
+ type CheckPriority = "critical" | "high" | "medium" | "low";
215
254
  interface CheckRecommendation {
216
255
  priority: CheckPriority;
217
256
  description: string;
@@ -260,8 +299,10 @@ interface CategoryResult {
260
299
  passCount: number;
261
300
  warnCount: number;
262
301
  failCount: number;
302
+ registryMass?: number;
303
+ assessedMass?: number;
263
304
  }
264
- type ScoreTier = 'agent-ready' | 'partially-ready' | 'needs-work' | 'not-ready';
305
+ type ScoreTier = "agent-ready" | "partially-ready" | "needs-work" | "not-ready";
265
306
  /**
266
307
  * Whether a verdict about this site can mean anything, and what is missing.
267
308
  *
@@ -311,6 +352,39 @@ interface ScanReport {
311
352
  readinessVitals?: ReadinessVitals;
312
353
  productFields?: ProductFieldVerification;
313
354
  wafProtection?: WafProtection;
355
+ originEvidence?: {
356
+ origin: string;
357
+ version: string;
358
+ readAt: string;
359
+ cached: boolean;
360
+ };
361
+ conditions?: ScanConditions;
362
+ }
363
+ interface ScanConditions {
364
+ url: string;
365
+ pageType: {
366
+ type: PageType;
367
+ source: "declared" | "detected";
368
+ };
369
+ origin: {
370
+ origin: string;
371
+ version: string;
372
+ readAt: string;
373
+ cached: boolean;
374
+ };
375
+ coverage: {
376
+ registryMass: number;
377
+ assessedMass: number;
378
+ pageMass: number;
379
+ originMass: number;
380
+ gatedMass: number;
381
+ };
382
+ unscored: {
383
+ totalCount: number;
384
+ informativeCount: number;
385
+ gatedCount: number;
386
+ reasons: Record<string, number>;
387
+ };
314
388
  }
315
389
  interface ReadinessVitals {
316
390
  commerce: number;
@@ -319,6 +393,54 @@ interface ReadinessVitals {
319
393
  technical: number;
320
394
  }
321
395
 
396
+ interface OriginCacheOptions {
397
+ bypassOriginCache?: boolean;
398
+ headers?: Record<string, string>;
399
+ }
400
+ interface OriginEvidence {
401
+ origin: string;
402
+ version: string;
403
+ readAt: string;
404
+ rootFiles: Record<string, FetchResult>;
405
+ originHomepage?: FetchResult;
406
+ }
407
+ /**
408
+ * Derives a canonical anonymous origin cache key.
409
+ *
410
+ * Strips any userinfo/credentials from the URL so credentials never leak into
411
+ * cache keys. Request headers other than credentials are folded in as a
412
+ * fingerprint: a scan that sets a bot user agent must not share a slot with
413
+ * a default scan, since the origin may answer the two differently.
414
+ */
415
+ declare function computeOriginCacheKey(url: string, version?: string, headers?: Record<string, string>): string;
416
+ /**
417
+ * Determines whether the scan must bypass the shared origin cache.
418
+ * Authenticated scans (URL credentials, Authorization header, cookies) or explicit bypass flags bypass the shared cache.
419
+ */
420
+ declare function shouldBypassOriginCache(url: string, options?: OriginCacheOptions): boolean;
421
+ /**
422
+ * A bounded, TTL-evicting store of origin evidence.
423
+ *
424
+ * Expired entries are swept on every write, and the oldest entry is dropped
425
+ * when the store is full, so a process that scans many origins once each
426
+ * cannot grow without limit. A read of an expired key evicts it as well.
427
+ */
428
+ declare class OriginCache {
429
+ private cache;
430
+ private ttlMs;
431
+ private maxEntries;
432
+ constructor(ttlMs?: number, maxEntries?: number);
433
+ /** Drop every entry whose TTL has passed. */
434
+ sweep(now?: number): void;
435
+ get(key: string): OriginEvidence | undefined;
436
+ has(key: string): boolean;
437
+ set(key: string, evidence: OriginEvidence, ttlMs?: number): void;
438
+ delete(key: string): boolean;
439
+ clear(): void;
440
+ get size(): number;
441
+ }
442
+ declare const defaultOriginCache: OriginCache;
443
+
322
444
  /**
323
445
  * What a scan actually obtained, decided once, before any audit runs.
324
446
  *
@@ -356,7 +478,7 @@ interface A11yNodeFinding {
356
478
  target: string;
357
479
  summary: string;
358
480
  }
359
- type A11yStatus = 'pass' | 'fail' | 'incomplete' | 'inapplicable';
481
+ type A11yStatus = "pass" | "fail" | "incomplete" | "inapplicable";
360
482
  interface A11yRuleResult {
361
483
  status: A11yStatus;
362
484
  nodes: A11yNodeFinding[];
@@ -367,6 +489,7 @@ type A11yPageResult = Record<string, A11yRuleResult>;
367
489
  interface PageContext {
368
490
  url: string;
369
491
  pageType: PageType;
492
+ pageTypeSource?: "declared" | "detected";
370
493
  fetchResult: FetchResult;
371
494
  $: CheerioAPI;
372
495
  /** Parsed JSON-LD blocks only (used by JSON-LD-specific audits). */
@@ -399,6 +522,15 @@ interface CheckContext {
399
522
  baseUrl: string;
400
523
  fetch: (options: FetchOptions) => Promise<FetchResult>;
401
524
  wafProtection?: WafProtection;
525
+ /**
526
+ * The object per-scan gatherer caches key on.
527
+ *
528
+ * The runner hands each audit a scoped copy of this context, and a copy has
529
+ * a new identity. Without this stamp every gatherer `WeakMap` would miss
530
+ * once per audit and repeat its fetch. The runner sets it on each copy;
531
+ * an unstamped context is its own owner. See `gatherers/cache-owner.ts`.
532
+ */
533
+ cacheOwner?: object;
402
534
  /**
403
535
  * What the scan actually obtained, decided once before any audit ran.
404
536
  *
@@ -407,6 +539,16 @@ interface CheckContext {
407
539
  * harnesses that do not exercise the gate pass `allEvidenceMet()`.
408
540
  */
409
541
  evidence: ScanEvidence;
542
+ /**
543
+ * Origin evidence metadata and cached homepage response.
544
+ */
545
+ originEvidence?: {
546
+ origin: string;
547
+ version: string;
548
+ readAt: string;
549
+ cached: boolean;
550
+ originHomepage?: FetchResult;
551
+ };
410
552
  }
411
553
  type CheckFn = (ctx: CheckContext) => CheckResult | Promise<CheckResult>;
412
554
 
@@ -460,7 +602,7 @@ declare abstract class Audit {
460
602
  [key: string]: unknown;
461
603
  } | string, pageUrl?: string): AuditResult;
462
604
  /** Merge static meta with the runtime result to produce a CheckResult. */
463
- toCheckResult(rawResult: AuditResult): CheckResult;
605
+ toCheckResult(rawResult: AuditResult, overrideDisplayMode?: ScoreDisplayMode): CheckResult;
464
606
  }
465
607
 
466
608
  interface CategoryConfig {
@@ -535,7 +677,7 @@ interface AuditTrace {
535
677
  * `gated` — the scan never obtained evidence the audit needs.
536
678
  * `error` — it threw, or its result was rejected by the schema.
537
679
  */
538
- outcome: 'ran' | 'skipped' | 'gated' | 'error';
680
+ outcome: "ran" | "skipped" | "gated" | "error";
539
681
  status: CheckStatus;
540
682
  score: number;
541
683
  weight: number;
@@ -547,10 +689,10 @@ interface AuditTrace {
547
689
  explanation?: string;
548
690
  pageUrl?: string;
549
691
  /** The structured evidence behind the verdict, as the report carries it. */
550
- details?: CheckResult['details'];
692
+ details?: CheckResult["details"];
551
693
  }
552
694
  /** Which outcome a finished check represents. */
553
- declare function outcomeOf(check: CheckResult): AuditTrace['outcome'];
695
+ declare function outcomeOf(check: CheckResult): AuditTrace["outcome"];
554
696
  /** Build a trace record from a finished check. */
555
697
  declare function traceFromCheck(check: CheckResult, durationMs: number): AuditTrace;
556
698
  /** One trace as a log line: the shape a human scans, not the full record. */
@@ -566,10 +708,10 @@ interface AuditRunResult {
566
708
  * ProgressTracker, which owns counting and fraction/elapsed stamping.
567
709
  */
568
710
  type AuditProgressEvent = {
569
- type: 'unit:done';
711
+ type: "unit:done";
570
712
  label: string;
571
713
  } | {
572
- type: 'unit:fail';
714
+ type: "unit:fail";
573
715
  label: string;
574
716
  error: string;
575
717
  };
@@ -582,29 +724,37 @@ type AuditProgressEvent = {
582
724
  */
583
725
  type AuditTraceHandler = (trace: AuditTrace) => void;
584
726
  interface AuditPlan {
585
- runnable: Array<{
586
- reg: AuditRegistration;
587
- categoryId: string;
588
- }>;
727
+ runnable: RunnableAudit[];
589
728
  skipped: CheckResult[];
590
729
  }
591
730
  /** How `planAudits` should treat audits the scan cannot feed. */
592
731
  interface PlanOptions {
593
732
  /**
594
- * Skip audits whose `requires` the scan did not obtain.
733
+ * Skip audits whose `requires` the scan did not obtain. **Defaults to true.**
595
734
  *
596
- * Off by default while the gate is calibrated: turning it on changes what
597
- * every blocked or client-rendered scan reports, and that lands as one
598
- * deliberate change rather than as a side effect of this one.
735
+ * An audit's `requires` decides what a blocked or client-rendered scan
736
+ * reports, so a caller that omits this option gets the gated set — the same
737
+ * set a scan gets. A production diagnostic may pass `false` to bypass only
738
+ * these per-audit `requires` checks. It is never the default, and it never
739
+ * bypasses the unconditional unread-scan guard.
599
740
  */
600
741
  enforceEvidence?: boolean;
601
742
  }
743
+ interface RunnableAudit {
744
+ reg: AuditRegistration;
745
+ categoryId: string;
746
+ scopedPages?: PageContext[];
747
+ scoreDisplayMode?: ScoreDisplayMode;
748
+ }
602
749
  /**
603
750
  * Split a scan config into the audits that will actually execute and the
604
751
  * `na` stubs for those it will not. Exported so the orchestrator can size the
605
752
  * audits progress phase before running it.
606
753
  */
607
- declare function planAudits(ctx: CheckContext, config: ScanConfig, options?: PlanOptions): AuditPlan;
754
+ declare function planAudits(ctx: CheckContext, config: ScanConfig, options?: PlanOptions): {
755
+ runnable: RunnableAudit[];
756
+ skipped: CheckResult[];
757
+ };
608
758
  /**
609
759
  * Execute all audits registered in the config against the scan context.
610
760
  * Returns check results grouped into categories with weighted scores.
@@ -612,20 +762,20 @@ declare function planAudits(ctx: CheckContext, config: ScanConfig, options?: Pla
612
762
  */
613
763
  declare function runAudits(ctx: CheckContext, config: ScanConfig, onEvent?: (event: AuditProgressEvent) => void, plan?: AuditPlan, onTrace?: AuditTraceHandler): Promise<AuditRunResult>;
614
764
 
615
- type PhaseId = 'fetch-root' | 'fetch-pages' | 'analyze' | 'audits' | 'report';
765
+ type PhaseId = "fetch-root" | "fetch-pages" | "analyze" | "audits" | "report";
616
766
  type ScanEvent = {
617
- type: 'scan:start';
767
+ type: "scan:start";
618
768
  url: string;
619
769
  fraction: number;
620
770
  elapsedMs: number;
621
771
  } | {
622
- type: 'phase:start';
772
+ type: "phase:start";
623
773
  phase: PhaseId;
624
774
  totalUnits: number;
625
775
  fraction: number;
626
776
  elapsedMs: number;
627
777
  } | {
628
- type: 'unit:done';
778
+ type: "unit:done";
629
779
  phase: PhaseId;
630
780
  completed: number;
631
781
  total: number;
@@ -633,20 +783,20 @@ type ScanEvent = {
633
783
  fraction: number;
634
784
  elapsedMs: number;
635
785
  } | {
636
- type: 'unit:fail';
786
+ type: "unit:fail";
637
787
  phase: PhaseId;
638
788
  label: string;
639
789
  error: string;
640
790
  fraction: number;
641
791
  elapsedMs: number;
642
792
  } | {
643
- type: 'phase:done';
793
+ type: "phase:done";
644
794
  phase: PhaseId;
645
795
  durationMs: number;
646
796
  fraction: number;
647
797
  elapsedMs: number;
648
798
  } | {
649
- type: 'scan:done';
799
+ type: "scan:done";
650
800
  durationMs: number;
651
801
  /** Null when the scan obtained too little evidence to judge the site. */
652
802
  score: number | null;
@@ -693,6 +843,8 @@ declare class ProgressTracker {
693
843
  interface ScanOptions {
694
844
  onEvent?: (event: ScanEvent) => void;
695
845
  pages?: PageOverride[] | null;
846
+ /** Explicitly declared page type for the target URL. */
847
+ pageType?: PageType;
696
848
  signal?: AbortSignal;
697
849
  /**
698
850
  * Restrict the scan to these category ids. Unknown ids simply match nothing —
@@ -716,15 +868,41 @@ interface ScanOptions {
716
868
  *
717
869
  * On by default. An audit whose required evidence the scan never obtained
718
870
  * reports `na` tagged `skipped:no-evidence`, with the reason attached, and
719
- * is never constructed. Set it to `false` to run every audit regardless —
720
- * useful when measuring what the gate removes.
871
+ * is never constructed. Set it to `false` to bypass only the per-audit
872
+ * `requires` checks. The unread-scan guard remains unconditional, so a scan
873
+ * that read no attributable site response still runs no audit.
721
874
  */
722
875
  enforceEvidenceGate?: boolean;
876
+ /**
877
+ * undici dispatcher for every request this scan makes.
878
+ */
879
+ dispatcher?: Dispatcher;
880
+ /**
881
+ * How many requests this scan may have in flight at once.
882
+ */
883
+ maxConcurrent?: number;
884
+ /**
885
+ * Extra HTTP request headers to pass on all fetches.
886
+ */
887
+ headers?: Record<string, string>;
888
+ /**
889
+ * Explicitly bypass the shared origin evidence cache for this scan.
890
+ */
891
+ bypassOriginCache?: boolean;
892
+ /**
893
+ * Optional custom OriginCache instance (defaults to defaultOriginCache).
894
+ */
895
+ originCache?: OriginCache;
896
+ /**
897
+ * A `robots.txt` response the caller already has, used instead of fetching
898
+ * it again.
899
+ */
900
+ robotsTxt?: FetchResult;
723
901
  }
724
902
  declare function runScan(url: string, options?: ScanOptions): Promise<ScanReport>;
725
903
 
726
- type FetchClass = 'ok' | 'soft-404' | 'blocked' | 'missing' | 'error';
727
- type ExpectedKind = 'text' | 'json' | 'xml' | 'html';
904
+ type FetchClass = "ok" | "soft-404" | "blocked" | "missing" | "error";
905
+ type ExpectedKind = "text" | "json" | "xml" | "html";
728
906
  declare function stripBom(text: string): string;
729
907
  declare function normalizeNewlines(text: string): string;
730
908
  /**
@@ -740,7 +918,7 @@ declare function classifyFetch(result: FetchResult | undefined, expected: Expect
740
918
  declare function isRealFile(result: FetchResult | undefined, expected: ExpectedKind): boolean;
741
919
 
742
920
  interface RobotsRule {
743
- type: 'allow' | 'disallow';
921
+ type: "allow" | "disallow";
744
922
  path: string;
745
923
  }
746
924
  interface RobotsGroup {
@@ -814,7 +992,7 @@ declare const BASELINE_UA = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) App
814
992
  * rate limit each need a different remedy from the operator, and an opaque 403
815
993
  * may even be correct impersonation defence.
816
994
  */
817
- type BlockClass = 'ok' | 'cf-challenge' | 'pay-per-crawl' | 'anubis-pow' | 'rate-limited' | 'opaque-403' | 'soft-block' | 'transport-error';
995
+ type BlockClass = "ok" | "cf-challenge" | "pay-per-crawl" | "anubis-pow" | "rate-limited" | "opaque-403" | "soft-block" | "transport-error";
818
996
  interface UaProbe {
819
997
  url: string;
820
998
  token: string;
@@ -881,6 +1059,10 @@ interface SitemapTree {
881
1059
  malformedLastmod: number;
882
1060
  /** True when a cap stopped the walk, so `entries` is not the whole tree. */
883
1061
  truncated: boolean;
1062
+ /** Sitemap files that answered 200 and parsed as a urlset or sitemapindex. */
1063
+ readableFiles: string[];
1064
+ /** Sitemap files that answered 200 but were neither. A soft-404 lands here. */
1065
+ malformedFiles: string[];
884
1066
  }
885
1067
  /**
886
1068
  * Does this value parse as a W3C Datetime, the format the sitemap protocol
@@ -895,6 +1077,11 @@ declare function isW3CDateTime(value: string): boolean;
895
1077
  /**
896
1078
  * Walk a site's sitemap roots and collect their `<url>` rows.
897
1079
  *
1080
+ * Every root in `roots` is read: a robots.txt that declares three sitemaps
1081
+ * has three, and stopping at the first would judge a third of the site as
1082
+ * the whole. `fallbackRoots` are the conventional paths, probed in order only
1083
+ * when no declared root parsed, and the first one that does ends the probe.
1084
+ *
898
1085
  * Recursion stops after one level of `<sitemapindex>`: the depth of a nested
899
1086
  * index is chosen by the site being scanned, so following it arbitrarily is an
900
1087
  * unbounded walk driven by untrusted input. Every child URL is `isSafeUrl`- and
@@ -904,6 +1091,7 @@ declare function collectSitemapEntries(fetch: (options: FetchOptions) => Promise
904
1091
  maxChildren?: number;
905
1092
  maxEntries?: number;
906
1093
  signal?: AbortSignal;
1094
+ fallbackRoots?: string[];
907
1095
  }): Promise<SitemapTree>;
908
1096
  /**
909
1097
  * Take an even-strided sample of `n` entries.
@@ -923,7 +1111,7 @@ interface CssRule {
923
1111
  /** The enclosing at-rule prelude (`media print`, `supports (...)`), if any. */
924
1112
  atRule?: string;
925
1113
  /** Where the rule came from, for evidence. */
926
- origin: 'inline' | string;
1114
+ origin: "inline" | string;
927
1115
  }
928
1116
  /**
929
1117
  * Scan a stylesheet into flat selector/declaration pairs.
@@ -1088,11 +1276,20 @@ declare function extractStylesheetUrls($: CheerioAPI): string[];
1088
1276
  */
1089
1277
  declare function detectPageType(url: string, $: CheerioAPI, jsonLd: object[], meta: Record<string, string>, isFirstPage: boolean): PageType;
1090
1278
 
1091
- declare const DEFAULT_SCAN_LIMIT = 5;
1092
- declare const MAX_PAGES_PER_SCAN = 6;
1279
+ declare const DEFAULT_SCAN_LIMIT = 1;
1280
+ declare const MAX_PAGES_PER_SCAN = 1;
1281
+ declare const ORIGIN_EVIDENCE_VERSION = "v1";
1282
+ declare const DEFAULT_ORIGIN_CACHE_TTL_MS: number;
1283
+ /**
1284
+ * How many origins the shared cache holds at once. Each entry carries every
1285
+ * root file of one origin, so a long-lived process (the MCP server, a looped
1286
+ * live run) needs a ceiling, not only a TTL.
1287
+ */
1288
+ declare const DEFAULT_ORIGIN_CACHE_MAX_ENTRIES = 256;
1093
1289
  declare const REQUEST_TIMEOUT_MS = 10000;
1094
1290
  declare const SCAN_TIMEOUT_MS = 60000;
1095
1291
  declare const MAX_RESPONSE_BODY_BYTES: number;
1292
+ /** @deprecated Unused internally; retained for published API stability. Scheduled for removal in v4. */
1096
1293
  declare const MAX_CONCURRENT_REQUESTS = 10;
1097
1294
  declare const SCANNER_USER_AGENT = "AgentLighthouse/1.0 (+https://github.com/ForkPoint/agent-lighthouse)";
1098
1295
  declare const TAG_SKIPPED_PAGE_TYPE = "skipped:page-type";
@@ -1126,7 +1323,7 @@ declare function weightForGrade(grade: EvidenceGrade, tier: AuditTier): number;
1126
1323
  * fails/passes or readiness vitals. Every surface that ranks or scores checks
1127
1324
  * filters through this predicate so the rule cannot drift per package.
1128
1325
  */
1129
- declare function isInformative(check: Pick<CheckResult, 'scoreDisplayMode'>): boolean;
1326
+ declare function isInformative(check: Pick<CheckResult, "scoreDisplayMode">): boolean;
1130
1327
  declare function calculateCategoryScore(checks: CheckResult[]): number;
1131
1328
  /**
1132
1329
  * Assemble a category result.
@@ -1258,6 +1455,7 @@ declare const AuditMetaSchema: z.ZodObject<{
1258
1455
  description: z.ZodString;
1259
1456
  scoreDisplayMode: z.ZodEnum<["binary", "ternary", "informative"]>;
1260
1457
  weight: z.ZodNumber;
1458
+ pageTypes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1261
1459
  applicablePageTypes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1262
1460
  defaultPriority: z.ZodEnum<["critical", "high", "medium", "low"]>;
1263
1461
  guidance: z.ZodOptional<z.ZodObject<{
@@ -1308,6 +1506,7 @@ declare const AuditMetaSchema: z.ZodObject<{
1308
1506
  evidenceGrade: "A" | "B" | "C" | "D";
1309
1507
  tier: "informative" | "scored" | "experimental";
1310
1508
  dossier: string;
1509
+ pageTypes?: string[] | undefined;
1311
1510
  applicablePageTypes?: string[] | undefined;
1312
1511
  guidance?: {
1313
1512
  impact: string;
@@ -1334,6 +1533,7 @@ declare const AuditMetaSchema: z.ZodObject<{
1334
1533
  evidenceGrade: "A" | "B" | "C" | "D";
1335
1534
  tier: "informative" | "scored" | "experimental";
1336
1535
  dossier: string;
1536
+ pageTypes?: string[] | undefined;
1337
1537
  applicablePageTypes?: string[] | undefined;
1338
1538
  guidance?: {
1339
1539
  impact: string;
@@ -1452,13 +1652,128 @@ declare const CheckResultSchema: z.ZodObject<{
1452
1652
  evidenceGrade?: "A" | "B" | "C" | "D" | undefined;
1453
1653
  tier?: "informative" | "scored" | "experimental" | undefined;
1454
1654
  }>;
1655
+ declare const PageTypeSchema: z.ZodEnum<["homepage", "category", "product", "content"]>;
1656
+ declare const ScanConditionsSchema: z.ZodObject<{
1657
+ url: z.ZodString;
1658
+ pageType: z.ZodObject<{
1659
+ type: z.ZodEnum<["homepage", "category", "product", "content"]>;
1660
+ source: z.ZodEnum<["declared", "detected"]>;
1661
+ }, "strip", z.ZodTypeAny, {
1662
+ type: "homepage" | "category" | "product" | "content";
1663
+ source: "declared" | "detected";
1664
+ }, {
1665
+ type: "homepage" | "category" | "product" | "content";
1666
+ source: "declared" | "detected";
1667
+ }>;
1668
+ origin: z.ZodObject<{
1669
+ origin: z.ZodString;
1670
+ version: z.ZodString;
1671
+ readAt: z.ZodString;
1672
+ cached: z.ZodBoolean;
1673
+ }, "strip", z.ZodTypeAny, {
1674
+ origin: string;
1675
+ version: string;
1676
+ readAt: string;
1677
+ cached: boolean;
1678
+ }, {
1679
+ origin: string;
1680
+ version: string;
1681
+ readAt: string;
1682
+ cached: boolean;
1683
+ }>;
1684
+ coverage: z.ZodObject<{
1685
+ registryMass: z.ZodNumber;
1686
+ assessedMass: z.ZodNumber;
1687
+ pageMass: z.ZodNumber;
1688
+ originMass: z.ZodNumber;
1689
+ gatedMass: z.ZodNumber;
1690
+ }, "strip", z.ZodTypeAny, {
1691
+ registryMass: number;
1692
+ assessedMass: number;
1693
+ pageMass: number;
1694
+ originMass: number;
1695
+ gatedMass: number;
1696
+ }, {
1697
+ registryMass: number;
1698
+ assessedMass: number;
1699
+ pageMass: number;
1700
+ originMass: number;
1701
+ gatedMass: number;
1702
+ }>;
1703
+ unscored: z.ZodObject<{
1704
+ totalCount: z.ZodNumber;
1705
+ informativeCount: z.ZodNumber;
1706
+ gatedCount: z.ZodNumber;
1707
+ reasons: z.ZodRecord<z.ZodString, z.ZodNumber>;
1708
+ }, "strip", z.ZodTypeAny, {
1709
+ reasons: Record<string, number>;
1710
+ totalCount: number;
1711
+ informativeCount: number;
1712
+ gatedCount: number;
1713
+ }, {
1714
+ reasons: Record<string, number>;
1715
+ totalCount: number;
1716
+ informativeCount: number;
1717
+ gatedCount: number;
1718
+ }>;
1719
+ }, "strip", z.ZodTypeAny, {
1720
+ url: string;
1721
+ origin: {
1722
+ origin: string;
1723
+ version: string;
1724
+ readAt: string;
1725
+ cached: boolean;
1726
+ };
1727
+ pageType: {
1728
+ type: "homepage" | "category" | "product" | "content";
1729
+ source: "declared" | "detected";
1730
+ };
1731
+ coverage: {
1732
+ registryMass: number;
1733
+ assessedMass: number;
1734
+ pageMass: number;
1735
+ originMass: number;
1736
+ gatedMass: number;
1737
+ };
1738
+ unscored: {
1739
+ reasons: Record<string, number>;
1740
+ totalCount: number;
1741
+ informativeCount: number;
1742
+ gatedCount: number;
1743
+ };
1744
+ }, {
1745
+ url: string;
1746
+ origin: {
1747
+ origin: string;
1748
+ version: string;
1749
+ readAt: string;
1750
+ cached: boolean;
1751
+ };
1752
+ pageType: {
1753
+ type: "homepage" | "category" | "product" | "content";
1754
+ source: "declared" | "detected";
1755
+ };
1756
+ coverage: {
1757
+ registryMass: number;
1758
+ assessedMass: number;
1759
+ pageMass: number;
1760
+ originMass: number;
1761
+ gatedMass: number;
1762
+ };
1763
+ unscored: {
1764
+ reasons: Record<string, number>;
1765
+ totalCount: number;
1766
+ informativeCount: number;
1767
+ gatedCount: number;
1768
+ };
1769
+ }>;
1455
1770
 
1456
1771
  declare function normalizeUrl(input: string): string;
1457
1772
  declare function joinUrl(base: string, path: string): string;
1458
1773
  declare function extractDomain(url: string): string;
1459
1774
  declare function isPrivateIp(ip: string): boolean;
1460
1775
 
1461
- type PresetName = 'ecommerce' | 'saas' | 'content' | 'quick' | 'full';
1776
+ type PresetName = "ecommerce" | "saas" | "content" | "quick" | "full";
1462
1777
  interface PresetOptions {
1463
1778
  name: PresetName;
1464
1779
  description: string;
@@ -1481,7 +1796,7 @@ interface AgentLighthouseConfig {
1481
1796
  /** Per-category minimum score assertions */
1482
1797
  assertCategories?: Record<string, number>;
1483
1798
  /** Output report formats (terminal, html, json, md) */
1484
- output?: Array<'terminal' | 'html' | 'json' | 'md'>;
1799
+ output?: Array<"terminal" | "html" | "json" | "md">;
1485
1800
  /** Output directory for reports */
1486
1801
  outputDir?: string;
1487
1802
  /** Maximum number of pages to discover & scan */
@@ -1494,7 +1809,7 @@ declare function defineConfig(config: AgentLighthouseConfig): AgentLighthouseCon
1494
1809
  */
1495
1810
  declare function loadConfigFile(customPath?: string): AgentLighthouseConfig;
1496
1811
 
1497
- type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'debug';
1812
+ type LogLevel = "silent" | "error" | "warn" | "info" | "debug";
1498
1813
  declare class Logger {
1499
1814
  level: LogLevel;
1500
1815
  private shouldLog;
@@ -1516,4 +1831,4 @@ type AcpLinkType = (typeof ACP_LINK_TYPES)[number];
1516
1831
  */
1517
1832
  declare function resolvePolicyLinks(ctx: CheckContext): Map<AcpLinkType, string>;
1518
1833
 
1519
- export { ACP_LINK_TYPES, AI_CRAWLER_UAS, AUDIT_ID_PATTERN, type AcpLinkType, type AgentLighthouseConfig, Audit, type AuditGuidance, AuditGuidanceSchema, type AuditMeta, AuditMetaSchema, type AuditPlan, type AuditProgressEvent, type AuditRegistration, type AuditResult, AuditResultSchema, type AuditRunResult, type AuditTier, AuditTierSchema, type AuditTrace, type AuditTraceHandler, BASELINE_UA, type BlockClass, CATEGORY_IDS, CATEGORY_MASS, CATEGORY_NAMES, type CategoryConfig, type CategoryResult, type CheckContext, type CheckFn, type CheckPriority, CheckPrioritySchema, type CheckRecommendation, type CheckResult, CheckResultSchema, type CheckStatus, CheckStatusSchema, type CssRule, DEFAULT_SCAN_LIMIT, type DeprecationNotice, DeprecationNoticeSchema, type EvidenceGrade, EvidenceGradeSchema, type EvidenceKey, EvidenceKeySchema, type ExpectedKind, type FetchClass, 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 PageCss, type PageJudgement, type PageOverride, type PageType, type PhaseId, type PresetName, type PresetOptions, type ProductFieldVerification, ProgressTracker, READINESS_WEIGHTS, REQUEST_TIMEOUT_MS, type ReadinessVitals, type RobotsFile, type RobotsGroup, type RobotsRule, SCANNER_USER_AGENT, SCAN_TIMEOUT_MS, SCORE_TIER_LABELS, type ScanConfig, type ScanEvent, type ScanEvidence, type ScanOptions, type ScanReport, type ScanValidity, type ScoreDisplayMode, ScoreDisplayModeSchema, type ScoreTier, type SitemapEntry, type SitemapTree, TAG_SCAN_ERROR, TAG_SKIPPED_NO_EVIDENCE, TAG_SKIPPED_PAGE_TYPE, type UaProbe, type WafProtection, allEvidenceMet, allJsonLdNodes, buildCategoryResult, buildScanEvidence, calculateCategoryScore, calculateOverallScore, classifyFetch, classifyResponse, collectPageCss, collectSitemapEntries, createFetcher, defaultConfig, defineConfig, detectPageType, detectWafProtection, evidenceUrl, extractDomain, extractForms, extractHeadLinks, extractHeadings, extractImages, extractInternalLinks, extractJsonLd, extractMarkdownLinks, extractMetaTags, extractNavLinks, extractProductFieldVerification, extractScripts, extractStylesheetUrls, filterConfig, flattenJsonLd, formatTrace, getMainContentText, getPreset, getRenderedText, getScoreTier, getTierColor, getTierLabel, getWordCount, groupsForBot, hasNamedGroup, isBlanketBlocked, isInformative, isPathAllowed, isPrivateIp, isRealFile, isSafeUrl, isW3CDateTime, joinUrl, judgePages, loadConfigFile, logger, matchesUserAgent, normalizeNewlines, normalizeUrl, outcomeOf, pagesOfType, parseCssRules, parseHtml, parseRobots, parseRobotsFile, planAudits, probeUaParity, resolvePolicyLinks, runAudits, runScan, sampleEntries, stripBom, topLevelJsonLd, traceFromCheck, weightForGrade };
1834
+ export { ACP_LINK_TYPES, AI_CRAWLER_UAS, AUDIT_ID_PATTERN, type AcpLinkType, type AgentLighthouseConfig, Audit, type AuditGuidance, AuditGuidanceSchema, type AuditMeta, AuditMetaSchema, type AuditPlan, type AuditProgressEvent, type AuditRegistration, type AuditResult, AuditResultSchema, type AuditRunResult, type AuditTier, AuditTierSchema, type AuditTrace, type AuditTraceHandler, BASELINE_UA, type BlockClass, CATEGORY_IDS, CATEGORY_MASS, CATEGORY_NAMES, type CategoryConfig, type CategoryResult, type CheckContext, type CheckFn, type CheckPriority, CheckPrioritySchema, type CheckRecommendation, type CheckResult, CheckResultSchema, type CheckStatus, CheckStatusSchema, type CssRule, DEFAULT_ORIGIN_CACHE_MAX_ENTRIES, DEFAULT_ORIGIN_CACHE_TTL_MS, DEFAULT_SCAN_LIMIT, type DeprecationNotice, DeprecationNoticeSchema, type EvidenceGrade, EvidenceGradeSchema, type EvidenceKey, EvidenceKeySchema, type ExpectedKind, type FetchClass, type FetchOptions, type FetchResult, type FetcherOptions, type FieldStatus, type FixEffort, FixEffortSchema, MAX_CONCURRENT_REQUESTS, MAX_PAGES_PER_SCAN, MAX_RESPONSE_BODY_BYTES, ORIGIN_EVIDENCE_VERSION, OriginCache, type OriginCacheOptions, type OriginEvidence, PAGE_TYPE_LABELS, PHASE_WEIGHTS, PRESETS, type PageContext, type PageCss, type PageJudgement, type PageOverride, type PageType, PageTypeSchema, type PhaseId, type PresetName, type PresetOptions, type ProductFieldVerification, ProgressTracker, READINESS_WEIGHTS, REQUEST_TIMEOUT_MS, type ReadinessVitals, type RobotsFile, type RobotsGroup, type RobotsRule, SCANNER_USER_AGENT, SCAN_TIMEOUT_MS, SCORE_TIER_LABELS, type ScanConditions, ScanConditionsSchema, type ScanConfig, type ScanEvent, type ScanEvidence, type ScanOptions, type ScanReport, type ScanValidity, type ScoreDisplayMode, ScoreDisplayModeSchema, type ScoreTier, type SitemapEntry, type SitemapTree, TAG_SCAN_ERROR, TAG_SKIPPED_NO_EVIDENCE, TAG_SKIPPED_PAGE_TYPE, type UaProbe, type WafProtection, allEvidenceMet, allJsonLdNodes, boundedDispatcher, buildCategoryResult, buildScanEvidence, calculateCategoryScore, calculateOverallScore, classifyFetch, classifyResponse, collectPageCss, collectSitemapEntries, computeOriginCacheKey, createFetcher, defaultConfig, defaultOriginCache, defineConfig, detectPageType, detectWafProtection, evidenceUrl, extractDomain, extractForms, extractHeadLinks, extractHeadings, extractImages, extractInternalLinks, extractJsonLd, extractMarkdownLinks, extractMetaTags, extractNavLinks, extractProductFieldVerification, extractScripts, extractStylesheetUrls, filterConfig, flattenJsonLd, formatTrace, getMainContentText, getPreset, getRenderedText, getScoreTier, getTierColor, getTierLabel, getWordCount, groupsForBot, hasNamedGroup, isBlanketBlocked, isInformative, isPathAllowed, isPrivateIp, isRealFile, isSafeUrl, isW3CDateTime, joinUrl, judgePages, loadConfigFile, logger, matchesUserAgent, normalizeNewlines, normalizeUrl, outcomeOf, pagesOfType, parseCssRules, parseHtml, parseRobots, parseRobotsFile, planAudits, probeUaParity, resolvePolicyLinks, runAudits, runScan, sampleEntries, shouldBypassOriginCache, stripBom, topLevelJsonLd, traceFromCheck, weightForGrade };