@xberg-io/crawlberg 1.10.2 → 1.11.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.
Files changed (4) hide show
  1. package/README.md +5 -5
  2. package/index.d.ts +513 -508
  3. package/index.js +160 -82
  4. package/package.json +23 -14
package/index.d.ts CHANGED
@@ -1,132 +1,110 @@
1
- /* auto-generated by NAPI-RS */
1
+ // This file is auto-generated by alef — DO NOT EDIT.
2
+ // alef:hash:760ec0215fe97398ca13eabd5625cdc092e885d8a65d635b7fb1d3a6044f1005
3
+ // To regenerate: alef generate
4
+ // To verify freshness: alef verify
2
5
  /* eslint-disable */
3
- /**
4
- * This type implements JavaScript's async iterable protocol.
5
- * It can be used with `for await...of` loops.
6
- *
7
- * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols
8
- */
9
- export declare class BatchCrawlStreamIterator {
10
6
 
11
- }
7
+ export type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };
8
+
9
+ /** Crawl multiple seed URLs concurrently, each following links to configured depth. */
10
+ export declare function batchCrawl(engine: CrawlEngineHandle, urls: Array<string>): Promise<BatchCrawlResults>;
11
+
12
+ /** Scrape multiple URLs concurrently. */
13
+ export declare function batchScrape(engine: CrawlEngineHandle, urls: Array<string>): Promise<BatchScrapeResults>;
14
+
15
+ /** Crawl a website starting from `url`, following links up to the configured depth. */
16
+ export declare function crawl(engine: CrawlEngineHandle, url: string): Promise<CrawlResult>;
12
17
 
13
18
  /**
14
- * Opaque handle to a configured crawl engine.
19
+ * Create a new crawl engine with the given configuration.
15
20
  *
16
- * Constructed via `create_engine` with an optional `CrawlConfig`.
17
- * Default implementations for all pluggable components are used internally.
21
+ * If `config` is `None`, uses `CrawlConfig.default()`.
22
+ * Returns an error if the configuration is invalid.
18
23
  */
19
- export declare class CrawlEngineHandle {
20
- /**
21
- * Stream a single-URL crawl, yielding `CrawlEvent`s as pages are processed.
22
- *
23
- * Returns an async stream that emits one event per crawled page, plus a
24
- * terminal `Complete` event. On per-URL failure during the crawl, emits an
25
- * `Error` event followed by `Complete`. The stream item type is wrapped in
26
- * a `Result` to surface transport-level errors; today every emit is `Ok`.
27
- *
28
- * Language bindings expose this as the native streaming shape for each
29
- * target. WASM does not expose native streaming wrappers.
30
- */
31
- crawlStream(req: JsCrawlStreamRequest): Promise<CrawlStreamIterator>
32
- /**
33
- * Stream a multi-URL crawl, yielding `CrawlEvent`s across all seeds.
34
- *
35
- * Returns an async stream that emits one event per crawled page across all
36
- * seeds, plus terminal `Complete` and `Error` events as appropriate. The
37
- * stream item type is wrapped in a `Result` to surface transport-level
38
- * errors; today every emit is `Ok`.
39
- *
40
- * Language bindings expose this as the native streaming shape for each
41
- * target. WASM does not expose native streaming wrappers.
42
- */
43
- batchCrawlStream(req: BatchCrawlStreamRequest): Promise<BatchCrawlStreamIterator>
44
- }
45
- export type JsCrawlEngineHandle = CrawlEngineHandle
24
+ export declare function createEngine(config?: CrawlConfig | undefined | null): CrawlEngineHandle;
46
25
 
47
26
  /**
48
- * This type implements JavaScript's async iterable protocol.
49
- * It can be used with `for await...of` loops.
27
+ * Convert markdown links to numbered citations.
50
28
  *
51
- * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols
29
+ * `[Example](https://example.com)` becomes `Example[1]`
30
+ * with `[1]: https://example.com` in the reference list.
31
+ * Images `![alt](url)` are preserved unchanged.
52
32
  */
53
- export declare class CrawlStreamIterator {
33
+ export declare function generateCitations(markdown: string): CitationResult;
54
34
 
55
- }
35
+ /** Execute browser actions on a single page. */
36
+ export declare function interact(
37
+ engine: CrawlEngineHandle,
38
+ url: string,
39
+ actions: Array<PageAction>,
40
+ ): Promise<InteractionResult>;
56
41
 
57
42
  /** Result from a single page action execution. */
58
43
  export interface ActionResult {
59
44
  /** Zero-based index of the action in the sequence. */
60
- actionIndex?: number
45
+ readonly actionIndex?: number;
61
46
  /** The type of action that was executed. */
62
- actionType?: string
47
+ readonly actionType?: string;
63
48
  /** Whether the action completed successfully. */
64
- success?: boolean
49
+ readonly success?: boolean;
65
50
  /** Action-specific return data (screenshot bytes, JS return value, scraped HTML). */
66
- data?: any
51
+ readonly data?: JsonValue;
67
52
  /** Error message if the action failed. */
68
- error?: string
53
+ readonly error?: string;
69
54
  }
70
55
 
71
56
  /** Article metadata extracted from `article:*` Open Graph tags. */
72
57
  export interface ArticleMetadata {
73
58
  /** The article publication time. */
74
- publishedTime?: string
59
+ readonly publishedTime?: string;
75
60
  /** The article modification time. */
76
- modifiedTime?: string
61
+ readonly modifiedTime?: string;
77
62
  /** The article author. */
78
- author?: string
63
+ readonly author?: string;
79
64
  /** The article section. */
80
- section?: string
65
+ readonly section?: string;
81
66
  /** The article tags. */
82
- tags?: Array<string>
67
+ readonly tags?: Array<string>;
83
68
  }
84
69
 
85
70
  /** The category of a downloaded asset. */
86
- export declare const enum AssetCategory {
71
+ export declare enum AssetCategory {
87
72
  /** A document file (PDF, DOC, etc.). */
88
- Document = 'document',
73
+ Document = "document",
89
74
  /** An image file. */
90
- Image = 'image',
75
+ Image = "image",
91
76
  /** An audio file. */
92
- Audio = 'audio',
77
+ Audio = "audio",
93
78
  /** A video file. */
94
- Video = 'video',
79
+ Video = "video",
95
80
  /** A font file. */
96
- Font = 'font',
81
+ Font = "font",
97
82
  /** A CSS stylesheet. */
98
- Stylesheet = 'stylesheet',
83
+ Stylesheet = "stylesheet",
99
84
  /** A JavaScript file. */
100
- Script = 'script',
85
+ Script = "script",
101
86
  /** An archive file (ZIP, TAR, etc.). */
102
- Archive = 'archive',
87
+ Archive = "archive",
103
88
  /** A data file (JSON, XML, CSV, etc.). */
104
- Data = 'data',
89
+ Data = "data",
105
90
  /** An unrecognized asset type. */
106
- Other = 'other'
91
+ Other = "other",
107
92
  }
108
93
 
109
94
  /** Authentication configuration. */
110
- export interface AuthConfig {
111
- type: string
112
- username?: string
113
- password?: string
114
- token?: string
115
- name?: string
116
- value?: string
117
- }
118
-
119
- /** Crawl multiple seed URLs concurrently, each following links to configured depth. */
120
- export declare function batchCrawl(engine: CrawlEngineHandle, urls: Array<string>): Promise<BatchCrawlResults>
95
+ export type AuthConfig =
96
+ | { type: "basic"; username: string; password: string }
97
+ | { type: "bearer"; token: string }
98
+ | { type: "header"; name: string; value: string };
121
99
 
122
100
  /** Result from a single URL in a batch crawl operation. */
123
101
  export interface BatchCrawlResult {
124
102
  /** The seed URL that was crawled. */
125
- url?: string
103
+ readonly url?: string;
126
104
  /** The crawl result, if successful. */
127
- result?: JsCrawlResult
105
+ readonly result?: CrawlResult;
128
106
  /** The error message, if the crawl failed. */
129
- error?: string
107
+ readonly error?: string;
130
108
  }
131
109
 
132
110
  /**
@@ -137,17 +115,15 @@ export interface BatchCrawlResult {
137
115
  */
138
116
  export interface BatchCrawlResults {
139
117
  /** Per-URL crawl results, in the order seed URLs were submitted. */
140
- results?: Array<BatchCrawlResult>
118
+ readonly results?: Array<BatchCrawlResult>;
141
119
  /** Total number of seed URLs in the batch (equal to `results.len()`). */
142
- totalCount?: number
120
+ readonly totalCount?: number;
143
121
  /** Number of seed URLs whose crawl succeeded (`error` is `None`). */
144
- completedCount?: number
122
+ readonly completedCount?: number;
145
123
  /** Number of seed URLs whose crawl failed (`error` is `Some`). */
146
- failedCount?: number
124
+ readonly failedCount?: number;
147
125
  }
148
126
 
149
- export declare function batchCrawlStream(engine: CrawlEngineHandle, urls: Array<string>): Promise<BatchCrawlStreamIterator>
150
-
151
127
  /**
152
128
  * Request to begin a multi-URL streaming crawl.
153
129
  *
@@ -160,20 +136,17 @@ export interface BatchCrawlStreamRequest {
160
136
  * The seed URLs to crawl. Each URL is followed independently up to the
161
137
  * engine's configured depth.
162
138
  */
163
- urls?: Array<string>
139
+ readonly urls?: Array<string>;
164
140
  }
165
141
 
166
- /** Scrape multiple URLs concurrently. */
167
- export declare function batchScrape(engine: CrawlEngineHandle, urls: Array<string>): Promise<BatchScrapeResults>
168
-
169
142
  /** Result from a single URL in a batch scrape operation. */
170
143
  export interface BatchScrapeResult {
171
144
  /** The URL that was scraped. */
172
- url?: string
145
+ readonly url?: string;
173
146
  /** The scrape result, if successful. */
174
- result?: JsScrapeResult
147
+ readonly result?: ScrapeResult;
175
148
  /** The error message, if the scrape failed. */
176
- error?: string
149
+ readonly error?: string;
177
150
  }
178
151
 
179
152
  /**
@@ -184,72 +157,76 @@ export interface BatchScrapeResult {
184
157
  */
185
158
  export interface BatchScrapeResults {
186
159
  /** Per-URL scrape results, in the order URLs were submitted. */
187
- results?: Array<BatchScrapeResult>
160
+ readonly results?: Array<BatchScrapeResult>;
188
161
  /** Total number of URLs in the batch (equal to `results.len()`). */
189
- totalCount?: number
162
+ readonly totalCount?: number;
190
163
  /** Number of URLs whose scrape succeeded (`error` is `None`). */
191
- completedCount?: number
164
+ readonly completedCount?: number;
192
165
  /** Number of URLs whose scrape failed (`error` is `Some`). */
193
- failedCount?: number
166
+ readonly failedCount?: number;
194
167
  }
195
168
 
196
169
  /** Browser backend used for JavaScript rendering. */
197
- export declare const enum BrowserBackend {
170
+ export declare enum BrowserBackend {
198
171
  /** Existing Chromium/CDP backend powered by chromiumoxide. */
199
- Chromiumoxide = 'chromiumoxide',
172
+ Chromiumoxide = "chromiumoxide",
200
173
  /** Crawlberg-owned native browser backend derived from Obscura. */
201
- Native = 'native'
174
+ Native = "native",
202
175
  }
203
176
 
204
177
  /** Browser fallback configuration. */
205
178
  export interface BrowserConfig {
206
179
  /** When to use the headless browser fallback. */
207
- mode?: BrowserMode | 'auto' | 'always' | 'never' | 'stealth'
180
+ readonly mode?: BrowserMode;
208
181
  /** Browser backend used to render JavaScript-heavy pages. */
209
- backend?: BrowserBackend | 'chromiumoxide' | 'native'
182
+ readonly backend?: BrowserBackend;
210
183
  /**
211
184
  * CDP WebSocket endpoint for connecting to an external browser instance.
212
185
  * Crawlberg disconnects during teardown but never closes the external browser process. <!-- -->
213
186
  */
214
- endpoint?: string
187
+ readonly endpoint?: string;
215
188
  /** Timeout for browser page load and rendering (in milliseconds when serialized). */
216
- timeout?: number
189
+ readonly timeout?: number;
217
190
  /**
218
191
  * Overall deadline for a single browser fetch, covering browser launch (or
219
192
  * page acquisition from a shared pool), page setup, navigation, rendering,
220
- * and screenshot capture. Must exceed `timeout` to leave room for launch
221
- * and setup overhead; a fetch that has not returned within this deadline
222
- * fails with a timeout error (in milliseconds when serialized).
193
+ * screenshot capture, and every retry of the fetch. Must exceed `timeout`
194
+ * to leave room for launch and setup overhead; a fetch that has not
195
+ * returned within this deadline fails with a timeout error (in
196
+ * milliseconds when serialized). The wait for the delay of the domain
197
+ * (`rate_limit_ms`) is not counted, so a delay longer than this deadline
198
+ * does not fail the page. A scrape with the native backend is not bounded
199
+ * by this deadline.
223
200
  *
224
201
  * Shutdown/teardown is governed separately by `shutdown_timeout` and is
225
202
  * not counted against this deadline: an already-computed result is
226
203
  * delivered to the caller without waiting for the browser process to
227
204
  * exit.
228
205
  */
229
- overallTimeout?: number
206
+ readonly overallTimeout?: number;
230
207
  /**
231
208
  * How long to wait for the browser process to close and exit cleanly
232
209
  * during teardown before the process is forcibly killed (in milliseconds
233
210
  * when serialized).
234
211
  */
235
- shutdownTimeout?: number
212
+ readonly shutdownTimeout?: number;
236
213
  /** Wait strategy after browser navigation. */
237
- wait?: BrowserWait | 'network_idle' | 'selector' | 'fixed'
214
+ readonly wait?: BrowserWait;
238
215
  /** CSS selector to wait for when `wait` is `Selector`. */
239
- waitSelector?: string
216
+ readonly waitSelector?: string;
240
217
  /** Extra time to wait after the wait condition is met. */
241
- extraWait?: number
218
+ readonly extraWait?: number;
242
219
  /**
243
220
  * Proxy for browser fetches. Overrides `CrawlConfig.proxy` when set.
244
221
  * Native backend supports http/https only (no SOCKS5).
245
222
  */
246
- proxy?: JsProxyConfig
223
+ readonly proxy?: ProxyConfig;
247
224
  /**
248
225
  * URL patterns to block before the network request fires. Supports `*`
249
226
  * wildcards. Useful for skipping ads/analytics/large images. Honored by
250
- * `BrowserBackend.Native`; chromiumoxide ignores this field today.
227
+ * both browser backends.
251
228
  */
252
- blockUrlPatterns?: Array<string>
229
+ readonly blockUrlPatterns?: Array<string>;
253
230
  /**
254
231
  * JavaScript snippet evaluated after navigation completes.
255
232
  *
@@ -257,23 +234,24 @@ export interface BrowserConfig {
257
234
  * Interactions run this script before page actions on both browser backends but do
258
235
  * not include the script result in `InteractionResult`.
259
236
  */
260
- evalScript?: string
237
+ readonly evalScript?: string;
261
238
  /**
262
239
  * User-agent used when fetching robots.txt. Defaults to `BrowserConfig.user_agent`
263
240
  * (or crawlberg's default) if unset. Native only.
264
241
  */
265
- robotsUserAgent?: string
242
+ readonly robotsUserAgent?: string;
266
243
  /**
267
244
  * Capture the full network event stream into the result. Default false
268
245
  * (only the document event is captured). Native only.
269
246
  */
270
- captureNetworkEvents?: boolean
247
+ readonly captureNetworkEvents?: boolean;
271
248
  /**
272
249
  * Enable session affinity: reuse chromiumoxide Pages for same-domain
273
250
  * requests so cookies + fingerprint + solved challenges persist.
274
- * Default: true. When false, each request gets a fresh Page.
251
+ * Default: true. Session reuse requires `CrawlConfig.browser_session_pool` alongside a browser pool.
252
+ * Without a session pool, or when false, each request gets a fresh Page.
275
253
  */
276
- sessionAffinity?: boolean
254
+ readonly sessionAffinity?: boolean;
277
255
  /**
278
256
  * Chrome or Chromium executable to launch. When set, crawlberg launches only this
279
257
  * binary, and a path that is missing or not executable is an error that names the
@@ -282,7 +260,7 @@ export interface BrowserConfig {
282
260
  * Chromium or Edge. Chromiumoxide backend only: ignored, with a warning, when `endpoint`
283
261
  * is set, with the native backend, and by scrapes and crawls that use a shared browser pool.
284
262
  */
285
- chromePath?: string
263
+ readonly chromePath?: string;
286
264
  /**
287
265
  * Extra Chrome command-line flags, each written as `--flag` or `--flag=value`, for example
288
266
  * `--user-agent=...`. A flag here replaces a crawlberg default flag of the same name
@@ -295,11 +273,9 @@ export interface BrowserConfig {
295
273
  * when `endpoint` is set, with the native backend, and by scrapes and crawls that use a
296
274
  * shared browser pool.
297
275
  */
298
- chromeArgs?: Array<string>
276
+ readonly chromeArgs?: Array<string>;
299
277
  }
300
278
 
301
- export declare function browserConfigDefault(): BrowserConfig
302
-
303
279
  /**
304
280
  * Browser-specific extras populated when the native browser backend was used.
305
281
  *
@@ -307,27 +283,27 @@ export declare function browserConfigDefault(): BrowserConfig
307
283
  */
308
284
  export interface BrowserExtras {
309
285
  /** Return value of `BrowserConfig.eval_script`, if provided. */
310
- evalResult?: any
286
+ readonly evalResult?: JsonValue;
311
287
  /**
312
288
  * Network events captured during page navigation (only populated when
313
289
  * `BrowserConfig.capture_network_events` is true).
314
290
  */
315
- networkEvents?: Array<JsResponseMeta>
291
+ readonly networkEvents?: Array<ResponseMeta>;
316
292
  /**
317
293
  * All non-expired cookies present in the browser's cookie jar after
318
294
  * navigation completes (includes both prior cookies and server Set-Cookie).
319
295
  */
320
- cookies?: Array<JsCookieInfo>
296
+ readonly cookies?: Array<CookieInfo>;
321
297
  }
322
298
 
323
299
  /** When to use the headless browser fallback. */
324
- export declare const enum BrowserMode {
300
+ export declare enum BrowserMode {
325
301
  /** Automatically detect when JS rendering is needed and fall back to browser. */
326
- Auto = 'auto',
302
+ Auto = "auto",
327
303
  /** Always use the browser for every request. */
328
- Always = 'always',
304
+ Always = "always",
329
305
  /** Never use the browser fallback. */
330
- Never = 'never',
306
+ Never = "never",
331
307
  /**
332
308
  * Always use the browser with all stealth surfaces enabled.
333
309
  *
@@ -343,17 +319,17 @@ export declare const enum BrowserMode {
343
319
  * Use this instead of setting the now-removed `BrowserConfig.stealth`
344
320
  * boolean field.
345
321
  */
346
- Stealth = 'stealth'
322
+ Stealth = "stealth",
347
323
  }
348
324
 
349
325
  /** Wait strategy for browser page rendering. */
350
- export declare const enum BrowserWait {
326
+ export declare enum BrowserWait {
351
327
  /** Wait until network activity is idle. */
352
- NetworkIdle = 'network_idle',
328
+ NetworkIdle = "network_idle",
353
329
  /** Wait for a specific CSS selector to appear in the DOM. */
354
- Selector = 'selector',
330
+ Selector = "selector",
355
331
  /** Wait for a fixed duration after navigation. */
356
- Fixed = 'fixed'
332
+ Fixed = "fixed",
357
333
  }
358
334
 
359
335
  /**
@@ -362,19 +338,19 @@ export declare const enum BrowserWait {
362
338
  */
363
339
  export interface CitationReference {
364
340
  /** 1-based reference number as it appears in the source text. */
365
- index?: number
341
+ readonly index?: number;
366
342
  /** Resolved absolute URL for this reference. */
367
- url?: string
343
+ readonly url?: string;
368
344
  /** Human-readable anchor text or title for the reference. */
369
- text?: string
345
+ readonly text?: string;
370
346
  }
371
347
 
372
348
  /** Result of citation conversion. */
373
349
  export interface CitationResult {
374
350
  /** Markdown with links replaced by numbered citations. */
375
- content?: string
351
+ readonly content?: string;
376
352
  /** Numbered reference list: (index, url, text). */
377
- references?: Array<CitationReference>
353
+ readonly references?: Array<CitationReference>;
378
354
  }
379
355
 
380
356
  /**
@@ -386,7 +362,7 @@ export interface CitationResult {
386
362
  */
387
363
  export interface ContentConfig {
388
364
  /** Output format: `"markdown"` (default), `"plain"`, `"djot"`. */
389
- outputFormat?: string
365
+ readonly outputFormat?: string;
390
366
  /**
391
367
  * Preprocessing aggressiveness: `"minimal"`, `"standard"` (default), `"aggressive"`.
392
368
  *
@@ -394,18 +370,18 @@ export interface ContentConfig {
394
370
  * - Standard: also removes nav, nav-hinted headers/footers/asides, forms.
395
371
  * - Aggressive: removes all footers/asides unconditionally.
396
372
  */
397
- preprocessingPreset?: string
373
+ readonly preprocessingPreset?: string;
398
374
  /** Remove navigation elements (nav, breadcrumbs, menus). Default: `true`. */
399
- removeNavigation?: boolean
375
+ readonly removeNavigation?: boolean;
400
376
  /** Remove form elements. Default: `true`. */
401
- removeForms?: boolean
377
+ readonly removeForms?: boolean;
402
378
  /**
403
379
  * HTML tag names to strip (render children only, remove the tag wrapper).
404
380
  * Default: `[]`.
405
381
  */
406
- stripTags?: Array<string>
382
+ readonly stripTags?: Array<string>;
407
383
  /** HTML tag names to preserve as raw HTML in output. */
408
- preserveTags?: Array<string>
384
+ readonly preserveTags?: Array<string>;
409
385
  /**
410
386
  * CSS selectors for elements to exclude entirely (element + all content).
411
387
  *
@@ -421,17 +397,17 @@ export interface ContentConfig {
421
397
  *
422
398
  * Example: `[".cookie-banner", "#ad-container", "[role='complementary']"]`
423
399
  */
424
- excludeSelectors?: Array<string>
400
+ readonly excludeSelectors?: Array<string>;
425
401
  /** Skip image elements in output. Default: `false`. */
426
- skipImages?: boolean
402
+ readonly skipImages?: boolean;
427
403
  /** Max DOM traversal depth. Prevents stack overflow on deeply nested HTML. */
428
- maxDepth?: number
404
+ readonly maxDepth?: number;
429
405
  /** Enable line wrapping. Default: `false`. */
430
- wrap?: boolean
406
+ readonly wrap?: boolean;
431
407
  /** Wrap width when `wrap` is enabled. Default: `80`. */
432
- wrapWidth?: number
408
+ readonly wrapWidth?: number;
433
409
  /** Include document structure tree in output. Default: `true`. */
434
- includeDocumentStructure?: boolean
410
+ readonly includeDocumentStructure?: boolean;
435
411
  /**
436
412
  * Prepend a YAML frontmatter block (`title`, `description`, etc., extracted from
437
413
  * `<head>`) to the markdown output. Default: `true`.
@@ -441,64 +417,89 @@ export interface ContentConfig {
441
417
  * is populated independently by `crate.html.metadata.extract_metadata` from the
442
418
  * parsed DOM, so turning this off does not lose any metadata field.
443
419
  */
444
- extractMetadata?: boolean
420
+ readonly extractMetadata?: boolean;
421
+ /** Replace paragraph source line breaks with spaces. Default: `false`. */
422
+ readonly stripNewlines?: boolean;
423
+ /** Markdown unordered-list markers, cycled by nesting level. Default: `"-*+"`. */
424
+ readonly bullets?: string;
425
+ /** Spaces per nested list level. Default: `2`. */
426
+ readonly listIndentWidth?: number;
427
+ /** Markdown emphasis marker: `"*"` (default) or `"_"`. */
428
+ readonly strongEmSymbol?: string;
429
+ /** Render tables without column-width padding. Default: `false`. */
430
+ readonly compactTables?: boolean;
431
+ /** HTML elements whose inline images stay images instead of alt text. Default: `[]`. */
432
+ readonly keepInlineImagesIn?: Array<string>;
433
+ /**
434
+ * Keep hidden elements, including body templates, in converted output. Default: `false`.
435
+ * Scripts and styles remain excluded; explicit exclusions and image settings still apply.
436
+ */
437
+ readonly keepHidden?: boolean;
445
438
  }
446
439
 
447
- export declare function contentConfigDefault(): ContentConfig
448
-
449
440
  /** Content filter applied to each crawled page before it reaches the result. */
450
- export declare const enum ContentFilterKind {
441
+ export declare enum ContentFilterKind {
451
442
  /** Keep only pages scoring at or above `bm25_threshold` for `bm25_query`. */
452
- Bm25 = 'bm_25'
443
+ Bm25 = "bm_25",
453
444
  }
454
445
 
455
- /** Information about an HTTP cookie received from a response. */
446
+ /**
447
+ * Information about a cookie that a crawled page set.
448
+ *
449
+ * A crawl result gives `domain` and `path` as the browser stores the cookie, so a cookie has
450
+ * the same fields whether an HTTP fetch or the browser received it.
451
+ */
456
452
  export interface CookieInfo {
457
453
  /** The cookie name. */
458
- name?: string
454
+ readonly name?: string;
459
455
  /** The cookie value. */
460
- value?: string
461
- /** The cookie domain, if specified. */
462
- domain?: string
463
- /** The cookie path, if specified. */
464
- path?: string
456
+ readonly value?: string;
457
+ /**
458
+ * The hosts that get the cookie back. A host-only cookie (no `Domain` attribute) has the
459
+ * host that set it, such as `example.com`. A domain cookie has its domain with a leading
460
+ * dot, such as `.example.com`. A `Domain` equal to an IP address or a one-label host gives
461
+ * a host-only cookie.
462
+ */
463
+ readonly domain?: string;
464
+ /**
465
+ * The path that gets the cookie back: the `Path` attribute when it starts with `/`,
466
+ * otherwise the directory of the page that set the cookie (RFC 6265 default path).
467
+ */
468
+ readonly path?: string;
465
469
  }
466
470
 
467
- /** Crawl a website starting from `url`, following links up to the configured depth. */
468
- export declare function crawl(engine: CrawlEngineHandle, url: string): Promise<CrawlResult>
469
-
470
471
  /** Configuration for crawl, scrape, and map operations. */
471
472
  export interface CrawlConfig {
472
473
  /** Maximum crawl depth (number of link hops from the start URL). */
473
- maxDepth?: number
474
+ readonly maxDepth?: number;
474
475
  /** Maximum number of pages to crawl. */
475
- maxPages?: number
476
+ readonly maxPages?: number;
476
477
  /**
477
478
  * Maximum links enqueued from a single page. Defaults to 10000.
478
479
  *
479
480
  * Bounds the work one hostile or pathological page can create; links past the
480
481
  * cap are dropped and a warning is logged.
481
482
  */
482
- maxLinksPerPage?: number
483
+ readonly maxLinksPerPage?: number;
483
484
  /** Maximum number of concurrent requests. */
484
- maxConcurrent?: number
485
+ readonly maxConcurrent?: number;
485
486
  /**
486
487
  * Traversal order. Defaults to breadth-first.
487
488
  *
488
489
  * A frontier or strategy set explicitly on `CrawlEngineBuilder` takes precedence over
489
490
  * this field.
490
491
  */
491
- crawlStrategy?: CrawlStrategyKind | 'bfs' | 'dfs' | 'best_first' | 'adaptive'
492
+ readonly crawlStrategy?: CrawlStrategyKind;
492
493
  /**
493
494
  * Content filter applied to each page. `None` keeps every page.
494
495
  *
495
496
  * A content filter set explicitly on `CrawlEngineBuilder` takes precedence.
496
497
  */
497
- contentFilter?: ContentFilterKind | 'bm_25'
498
+ readonly contentFilter?: ContentFilterKind;
498
499
  /** Query the BM25 content filter scores pages against. Required by `ContentFilterKind.Bm25`. */
499
- bm25Query?: string
500
+ readonly bm25Query?: string;
500
501
  /** Minimum BM25 score a page must reach to be kept. Defaults to `0.0`. */
501
- bm25Threshold?: number
502
+ readonly bm25Threshold?: number;
502
503
  /**
503
504
  * Whether to respect robots.txt directives. A crawl that respects them also honours
504
505
  * the page's own robots instructions: it does not follow the links of a page marked
@@ -507,7 +508,7 @@ export interface CrawlConfig {
507
508
  * page is still crawled and its links followed; the page result marks it with
508
509
  * `noindex_detected`.
509
510
  */
510
- respectRobotsTxt?: boolean
511
+ readonly respectRobotsTxt?: boolean;
511
512
  /**
512
513
  * When true, HTTP-level error responses (404 NotFound, 403 Forbidden, WAF blocks)
513
514
  * are surfaced as `ScrapeResult` records with the matching `status_code` rather
@@ -519,9 +520,9 @@ export interface CrawlConfig {
519
520
  * the user opted into redirect-following, so receiving a 404 there is part of
520
521
  * the normal flow rather than an unexpected error.
521
522
  */
522
- softHttpErrors?: boolean
523
+ readonly softHttpErrors?: boolean;
523
524
  /** Custom user-agent string. */
524
- userAgent?: string
525
+ readonly userAgent?: string;
525
526
  /**
526
527
  * Whether to confine *document* links (`.pdf`, `.docx`, `.zip`, ...) to the seed domain.
527
528
  *
@@ -531,18 +532,18 @@ export interface CrawlConfig {
531
532
  * are followed cross-host by default -- the usual case being documents served from a CDN
532
533
  * or object store. Set this to `true` to require documents to live on the seed domain too.
533
534
  */
534
- stayOnDomain?: boolean
535
+ readonly stayOnDomain?: boolean;
535
536
  /**
536
537
  * Whether subdomains of the seed host are in scope.
537
538
  *
538
539
  * Applies to page links unconditionally, and to document links when
539
540
  * `Self.stay_on_domain` is set.
540
541
  */
541
- allowSubdomains?: boolean
542
+ readonly allowSubdomains?: boolean;
542
543
  /** Regex patterns for paths to include during crawling. */
543
- includePaths?: Array<string>
544
+ readonly includePaths?: Array<string>;
544
545
  /** Regex patterns for paths to exclude during crawling. */
545
- excludePaths?: Array<string>
546
+ readonly excludePaths?: Array<string>;
546
547
  /**
547
548
  * Whether `include_paths`/`exclude_paths` match against `path?query` instead of just
548
549
  * `path`. Defaults to `false`, matching path only: a pattern anchored with `$` (e.g.
@@ -550,7 +551,7 @@ export interface CrawlConfig {
550
551
  * opt-in rather than silently changing what an existing config matches. Has no effect
551
552
  * when `Self.path_patterns_match_url` is `true`.
552
553
  */
553
- pathPatternsMatchQuery?: boolean
554
+ readonly pathPatternsMatchQuery?: boolean;
554
555
  /**
555
556
  * Whether `include_paths`/`exclude_paths` match against the full URL,
556
557
  * `scheme://host[:port]/path?query`, so a pattern can scope by host. Defaults to `false`.
@@ -559,20 +560,20 @@ export interface CrawlConfig {
559
560
  * `user:password@`, a fragment or a default port, and the host is in punycode
560
561
  * (`bücher.de` is matched as `xn--bcher-kva.de`).
561
562
  */
562
- pathPatternsMatchUrl?: boolean
563
+ readonly pathPatternsMatchUrl?: boolean;
563
564
  /**
564
- * Whether the crawl-dedup key includes the (sorted) query string. Defaults to `false`,
565
- * matching historical behavior: `/item?id=1` and `/item?id=2` are treated as one page and
566
- * only the first is fetched. `true` keeps the query, sorted, in the key, so each distinct
567
- * query is fetched once.
565
+ * Whether the crawl-dedup key includes the query string, sorted by parameter name.
566
+ * Defaults to `true`: `/item?id=1` and `/item?id=2` are distinct pages, each fetched once.
567
+ * Set to `false` to merge query variants and fetch only the first. Session parameters
568
+ * produce a page for each distinct value unless removed with `strip_tracking_params`.
568
569
  */
569
- dedupIncludeQuery?: boolean
570
+ readonly dedupIncludeQuery?: boolean;
570
571
  /**
571
572
  * Whether to strip `tracking_params` from a discovered URL before it is deduplicated,
572
573
  * fetched, and reported. Defaults to `false`, so no tracking parameters are stripped
573
574
  * unless explicitly enabled.
574
575
  */
575
- stripTrackingParams?: boolean
576
+ readonly stripTrackingParams?: boolean;
576
577
  /**
577
578
  * Query parameter name patterns to strip when `strip_tracking_params` is `true`. A
578
579
  * pattern ending in `*` matches by prefix (`utm_*` matches `utm_source`, `utm_campaign`,
@@ -580,46 +581,47 @@ export interface CrawlConfig {
580
581
  * `["utm_*", "fbclid", "gclid", "ref"]`, applied only once `strip_tracking_params` is
581
582
  * enabled.
582
583
  */
583
- trackingParams?: Array<string>
584
+ readonly trackingParams?: Array<string>;
584
585
  /**
585
586
  * Custom HTTP headers to send with each request to the seed URL's host. A request to another host
586
587
  * does not carry them.
587
588
  */
588
- customHeaders?: Record<string, string>
589
+ readonly customHeaders?: Record<string, string>;
589
590
  /** Timeout for individual HTTP requests (in milliseconds when serialized). */
590
- requestTimeout?: number
591
+ readonly requestTimeout?: number;
591
592
  /**
592
593
  * Per-domain rate limit in milliseconds. When set, enforces a minimum delay
593
- * between requests to the same domain. Defaults to 200ms when `None`.
594
+ * between requests to the same domain, in HTTP mode and before each page load in
595
+ * browser mode. When `None`, HTTP mode uses 200ms and browser mode applies no delay.
594
596
  */
595
- rateLimitMs?: number
597
+ readonly rateLimitMs?: number;
596
598
  /** Maximum number of redirects to follow. */
597
- maxRedirects?: number
599
+ readonly maxRedirects?: number;
598
600
  /** Number of retry attempts for failed requests. Bounded by `MAX_RETRY_COUNT`. */
599
- retryCount?: number
601
+ readonly retryCount?: number;
600
602
  /**
601
603
  * HTTP status codes that should trigger a retry. When empty, every rate limit, server
602
604
  * error, bad gateway and timeout is retried. When set, only a failure whose status is
603
605
  * listed is retried, so a timeout without a response is not.
604
606
  */
605
- retryCodes?: Array<number>
607
+ readonly retryCodes?: Array<number>;
606
608
  /**
607
609
  * Initial delay, in milliseconds, before the first retry. Doubled on each
608
610
  * subsequent attempt (capped at `retry_max_delay_ms`). Defaults to 100ms.
609
611
  */
610
- retryInitialDelayMs?: number
612
+ readonly retryInitialDelayMs?: number;
611
613
  /** Upper bound, in milliseconds, on the exponential retry backoff. Defaults to 60s. */
612
- retryMaxDelayMs?: number
614
+ readonly retryMaxDelayMs?: number;
613
615
  /**
614
616
  * Fraction of the per-domain rate-limit delay to randomly jitter by, in `[0.0, 1.0]`.
615
617
  * `0.0` (the default) applies no jitter and preserves the previous fixed-interval
616
618
  * behaviour; `0.1` jitters the delay by up to ±10%.
617
619
  */
618
- rateLimitJitterRatio?: number
620
+ readonly rateLimitJitterRatio?: number;
619
621
  /** Whether to enable cookie handling. */
620
- cookiesEnabled?: boolean
622
+ readonly cookiesEnabled?: boolean;
621
623
  /** Authentication configuration. */
622
- auth?: JsAuthConfig
624
+ readonly auth?: AuthConfig;
623
625
  /**
624
626
  * Maximum response body size in bytes.
625
627
  *
@@ -628,27 +630,27 @@ export interface CrawlConfig {
628
630
  * hundred compressed bytes can otherwise expand to gigabytes in memory. To read
629
631
  * bodies larger than that, set this explicitly.
630
632
  */
631
- maxBodySize?: number
633
+ readonly maxBodySize?: number;
632
634
  /** CSS selectors for tags to remove from HTML before processing. */
633
- removeTags?: Array<string>
635
+ readonly removeTags?: Array<string>;
634
636
  /** Content extraction and conversion configuration. */
635
- content?: ContentConfig
637
+ readonly content?: ContentConfig;
636
638
  /** Maximum number of URLs to return from a map operation. */
637
- mapLimit?: number
639
+ readonly mapLimit?: number;
638
640
  /** Search filter for map results (case-insensitive substring match on URLs). */
639
- mapSearch?: string
641
+ readonly mapSearch?: string;
640
642
  /** Whether to download assets (CSS, JS, images, etc.) from the page. */
641
- downloadAssets?: boolean
643
+ readonly downloadAssets?: boolean;
642
644
  /** Filter for asset categories to download. */
643
- assetTypes?: Array<AssetCategory | 'document' | 'image' | 'audio' | 'video' | 'font' | 'stylesheet' | 'script' | 'archive' | 'data' | 'other'>
645
+ readonly assetTypes?: Array<AssetCategory>;
644
646
  /** Maximum size in bytes for individual asset downloads. */
645
- maxAssetSize?: number
647
+ readonly maxAssetSize?: number;
646
648
  /** Browser configuration. */
647
- browser?: BrowserConfig
649
+ readonly browser?: BrowserConfig;
648
650
  /** Proxy configuration for HTTP requests. */
649
- proxy?: JsProxyConfig
651
+ readonly proxy?: ProxyConfig;
650
652
  /** List of user-agent strings for rotation. If non-empty, overrides `user_agent`. */
651
- userAgents?: Array<string>
653
+ readonly userAgents?: Array<string>;
652
654
  /**
653
655
  * Whether to capture a screenshot when using the browser.
654
656
  *
@@ -660,29 +662,29 @@ export interface CrawlConfig {
660
662
  * `BrowserMode.Auto`/`Never`, or during `crawl()`) has no effect and logs a
661
663
  * warning rather than silently doing nothing.
662
664
  */
663
- captureScreenshot?: boolean
665
+ readonly captureScreenshot?: boolean;
664
666
  /**
665
667
  * Re-enqueue discovered `LinkType.Document` URLs into the crawl frontier so
666
668
  * the crawl follows links *from* document pages (PDFs, etc.) as it would
667
669
  * from HTML pages. Default: `false` (documents terminate at materialisation).
668
670
  */
669
- followDocumentUrls?: boolean
671
+ readonly followDocumentUrls?: boolean;
670
672
  /**
671
673
  * Maximum document-depth (from the seed URL through document links only)
672
674
  * when `follow_document_urls` is true. `None` means inherit `max_depth`.
673
675
  * Independent of `max_depth`: a document URL is enqueued only if BOTH the
674
676
  * outer `max_depth` and (if set) `document_url_depth` permit it.
675
677
  */
676
- documentUrlDepth?: number
678
+ readonly documentUrlDepth?: number;
677
679
  /**
678
680
  * Whether to download non-HTML documents (PDF, DOCX, images, code, etc.) instead of skipping them.
679
681
  * Defaults to `true` — unlike `download_assets` and `capture_screenshot`, which default to `false`.
680
682
  */
681
- downloadDocuments?: boolean
683
+ readonly downloadDocuments?: boolean;
682
684
  /** Maximum size in bytes for document downloads. Defaults to 50 MB. */
683
- documentMaxSize?: number
685
+ readonly documentMaxSize?: number;
684
686
  /** Allowlist of MIME types to download. If empty, uses built-in defaults. */
685
- documentMimeTypes?: Array<string>
687
+ readonly documentMimeTypes?: Array<string>;
686
688
  /**
687
689
  * Directory to stream downloaded document bytes into instead of holding them in
688
690
  * memory on `DownloadedDocument.content`. When set, `content` is left empty and
@@ -690,16 +692,16 @@ export interface CrawlConfig {
690
692
  * `None` (default) preserves today's in-memory-only behavior. Has no effect on
691
693
  * wasm32, which has no filesystem — use `document_content_encoding` there instead.
692
694
  */
693
- documentOutputDir?: string
695
+ readonly documentOutputDir?: string;
694
696
  /**
695
697
  * Opt-in encoding that duplicates `DownloadedDocument.content` into a serializable
696
698
  * field for language bindings that need the bytes in-memory (`content` itself is
697
699
  * `alef(skip)`ed). `None` (default) means no encoding is produced. Independent of
698
700
  * `document_output_dir` — set both to get a file on disk and an in-memory copy.
699
701
  */
700
- documentContentEncoding?: DocumentContentEncoding | 'base_64'
702
+ readonly documentContentEncoding?: DocumentContentEncoding;
701
703
  /** Path to write WARC output. If `None`, WARC output is disabled. */
702
- warcOutput?: string
704
+ readonly warcOutput?: string;
703
705
  /**
704
706
  * Named browser profile for persistent sessions (cookies, localStorage).
705
707
  *
@@ -710,9 +712,9 @@ export interface CrawlConfig {
710
712
  * exists) or when connecting to an external CDP endpoint whose process crawlberg
711
713
  * does not own.
712
714
  */
713
- browserProfile?: string
715
+ readonly browserProfile?: string;
714
716
  /** Whether to save changes back to the browser profile on exit. */
715
- saveBrowserProfile?: boolean
717
+ readonly saveBrowserProfile?: boolean;
716
718
  /**
717
719
  * SSRF policy for outbound network requests. Default: deny private networks,
718
720
  * allow http/https only, max 5 redirects.
@@ -727,7 +729,7 @@ export interface CrawlConfig {
727
729
  * `deny_private = true`. Enforce egress restrictions at the network layer for that
728
730
  * deployment target; do not rely on this field. See `crawlberg.net.validate_url`.
729
731
  */
730
- ssrf?: JsSsrfPolicy
732
+ readonly ssrf?: SsrfPolicy;
731
733
  /**
732
734
  * Pins `SsrfPolicy.deny_private` to a caller-chosen value, bypassing the
733
735
  * `CRAWLBERG_ALLOW_PRIVATE_NETWORK` operator override entirely for this config.
@@ -747,10 +749,43 @@ export interface CrawlConfig {
747
749
  * `ssrf.deny_private` to `false`. `Some(value)` pins `ssrf.deny_private` to `value`
748
750
  * and the environment variable is not consulted for this config.
749
751
  */
750
- ssrfDenyPrivateExplicit?: boolean
752
+ readonly ssrfDenyPrivateExplicit?: boolean;
751
753
  }
752
754
 
753
- export declare function crawlConfigDefault(): CrawlConfig
755
+ /**
756
+ * Opaque handle to a configured crawl engine.
757
+ *
758
+ * Constructed via `create_engine` with an optional `CrawlConfig`.
759
+ * Default implementations for all pluggable components are used internally.
760
+ */
761
+ export declare class CrawlEngineHandle {
762
+ /**
763
+ * Stream a single-URL crawl, yielding `CrawlEvent`s as pages are processed.
764
+ *
765
+ * Returns an async stream that emits one event per crawled page, plus a
766
+ * terminal `Complete` event. On per-URL failure during the crawl, emits an
767
+ * `Error` event followed by `Complete`. The stream item type is wrapped in
768
+ * a `Result` to surface transport-level errors; today every emit is `Ok`.
769
+ *
770
+ * Language bindings expose this as the native streaming shape for each
771
+ * target. WASM does not expose native streaming wrappers.
772
+ */
773
+ crawlStream(req?: CrawlStreamRequest | undefined | null): Promise<AsyncGenerator<CrawlEvent, void, undefined>>;
774
+ /**
775
+ * Stream a multi-URL crawl, yielding `CrawlEvent`s across all seeds.
776
+ *
777
+ * Returns an async stream that emits one event per crawled page across all
778
+ * seeds, plus terminal `Complete` and `Error` events as appropriate. The
779
+ * stream item type is wrapped in a `Result` to surface transport-level
780
+ * errors; today every emit is `Ok`.
781
+ *
782
+ * Language bindings expose this as the native streaming shape for each
783
+ * target. WASM does not expose native streaming wrappers.
784
+ */
785
+ batchCrawlStream(
786
+ req?: BatchCrawlStreamRequest | undefined | null,
787
+ ): Promise<AsyncGenerator<CrawlEvent, void, undefined>>;
788
+ }
754
789
 
755
790
  /**
756
791
  * An event emitted during a streaming crawl operation.
@@ -760,101 +795,103 @@ export declare function crawlConfigDefault(): CrawlConfig
760
795
  *
761
796
  * Delivered to bindings through each target's native streaming idiom.
762
797
  */
763
- export interface CrawlEvent {
764
- type: string
765
- result?: CrawlPageResult
766
- url?: string
767
- error?: string
768
- pagesCrawled?: number
769
- }
798
+ export type CrawlEvent =
799
+ | { type: "page"; result: CrawlPageResult }
800
+ | { type: "error"; url: string; error: string }
801
+ | { type: "complete"; pagesCrawled: number };
770
802
 
771
803
  /** The result of crawling a single page during a crawl operation. */
772
804
  export interface CrawlPageResult {
773
805
  /** The original URL of the page. */
774
- url?: string
806
+ readonly url?: string;
775
807
  /** The normalized URL of the page. */
776
- normalizedUrl?: string
808
+ readonly normalizedUrl?: string;
777
809
  /** The HTTP status code of the response. */
778
- statusCode?: number
810
+ readonly statusCode?: number;
779
811
  /** The Content-Type header value. */
780
- contentType?: string
812
+ readonly contentType?: string;
781
813
  /** The HTML body of the response. */
782
- html?: string
814
+ readonly html?: string;
783
815
  /** The size of the response body in bytes. */
784
- bodySize?: number
816
+ readonly bodySize?: number;
785
817
  /** Extracted metadata from the page. */
786
- metadata?: JsPageMetadata
818
+ readonly metadata?: PageMetadata;
787
819
  /** Links found on the page. */
788
- links?: Array<JsLinkInfo>
820
+ readonly links?: Array<LinkInfo>;
789
821
  /** Images found on the page. */
790
- images?: Array<JsImageInfo>
822
+ readonly images?: Array<ImageInfo>;
791
823
  /** Feed links found on the page. */
792
- feeds?: Array<JsFeedInfo>
824
+ readonly feeds?: Array<FeedInfo>;
793
825
  /** JSON-LD entries found on the page. */
794
- jsonLd?: Array<JsJsonLdEntry>
826
+ readonly jsonLd?: Array<JsonLdEntry>;
795
827
  /** The depth of this page from the start URL. */
796
- depth?: number
828
+ readonly depth?: number;
797
829
  /** Whether this page is on the same domain as the start URL. */
798
- stayedOnDomain?: boolean
830
+ readonly stayedOnDomain?: boolean;
799
831
  /** Whether this page was skipped (binary or PDF content). */
800
- wasSkipped?: boolean
832
+ readonly wasSkipped?: boolean;
801
833
  /** Whether the content is a PDF. */
802
- isPdf?: boolean
834
+ readonly isPdf?: boolean;
803
835
  /** The detected character set encoding. */
804
- detectedCharset?: string
836
+ readonly detectedCharset?: string;
805
837
  /** Markdown conversion of the page content. */
806
- markdown?: JsMarkdownResult
838
+ readonly markdown?: MarkdownResult;
807
839
  /** Structured data extracted by LLM. Populated when extraction is configured. */
808
- extractedData?: any
840
+ readonly extractedData?: JsonValue;
809
841
  /** Metadata about the LLM extraction pass (cost, tokens, model). */
810
- extractionMeta?: JsExtractionMeta
842
+ readonly extractionMeta?: ExtractionMeta;
811
843
  /** Downloaded non-HTML document (PDF, DOCX, image, code, etc.). */
812
- downloadedDocument?: JsDownloadedDocument
844
+ readonly downloadedDocument?: DownloadedDocument;
813
845
  /** Whether the browser fallback was used to fetch this page. */
814
- browserUsed?: boolean
846
+ readonly browserUsed?: boolean;
815
847
  /**
816
848
  * The URL this page's content was actually fetched from, after following any HTTP,
817
849
  * `Refresh` header, or `<meta http-equiv="refresh">` redirect `url` pointed at.
818
850
  * Equal to `url` when the fetch did not redirect.
819
851
  */
820
- finalUrl?: string
852
+ readonly finalUrl?: string;
821
853
  /** Redirect hops taken to reach `final_url` from `url`. */
822
- redirectCount?: number
854
+ readonly redirectCount?: number;
823
855
  /**
824
856
  * Whether the page asked not to be indexed, by its robots meta tag or `X-Robots-Tag`
825
857
  * header. The page is still crawled and its links still followed.
826
858
  */
827
- noindexDetected?: boolean
859
+ readonly noindexDetected?: boolean;
828
860
  /**
829
861
  * Whether the page asked that its links not be followed, by its robots meta tag or
830
862
  * `X-Robots-Tag` header. When the crawl respects robots, its links are not followed.
831
863
  */
832
- nofollowDetected?: boolean
864
+ readonly nofollowDetected?: boolean;
833
865
  /**
834
866
  * URLs of the requests the page sent in browser mode that the SSRF policy refused, without
835
867
  * their credentials, each listed once. The page is kept; only the refused requests failed.
836
868
  */
837
- ssrfRefusedUrls?: Array<string>
869
+ readonly ssrfRefusedUrls?: Array<string>;
870
+ /**
871
+ * Seed address as supplied, or the discovered link address resolved against its base.
872
+ * Preserves source spelling through redirects; URL credentials are removed. <!-- -->
873
+ */
874
+ readonly originalUrl?: string;
838
875
  }
839
876
 
840
877
  /** The result of a multi-page crawl operation. */
841
878
  export interface CrawlResult {
842
879
  /** The list of crawled pages. */
843
- pages?: Array<CrawlPageResult>
880
+ readonly pages?: Array<CrawlPageResult>;
844
881
  /** The final URL after following redirects. */
845
- finalUrl?: string
882
+ readonly finalUrl?: string;
846
883
  /** The number of redirects followed. */
847
- redirectCount?: number
884
+ readonly redirectCount?: number;
848
885
  /** Whether any page was skipped during crawling. */
849
- wasSkipped?: boolean
886
+ readonly wasSkipped?: boolean;
850
887
  /** An error message, if the crawl encountered an issue. */
851
- error?: string
888
+ readonly error?: string;
852
889
  /** Cookies collected during the crawl. */
853
- cookies?: Array<CookieInfo>
890
+ readonly cookies?: Array<CookieInfo>;
854
891
  /** Whether all crawled pages stayed on the same domain as the start URL. */
855
- stayedOnDomain?: boolean
892
+ readonly stayedOnDomain?: boolean;
856
893
  /** Whether the browser fallback was used for any page in this crawl. */
857
- browserUsed?: boolean
894
+ readonly browserUsed?: boolean;
858
895
  }
859
896
 
860
897
  /**
@@ -864,19 +901,17 @@ export interface CrawlResult {
864
901
  * property of the frontier: the engine hands its bounded selection window to the strategy, so
865
902
  * a strategy alone can only reorder URLs that have already been dequeued.
866
903
  */
867
- export declare const enum CrawlStrategyKind {
904
+ export declare enum CrawlStrategyKind {
868
905
  /** Breadth-first: a FIFO frontier visits every URL at one depth before the next. */
869
- Bfs = 'bfs',
906
+ Bfs = "bfs",
870
907
  /** Depth-first: a LIFO frontier descends into a page's children before its siblings. */
871
- Dfs = 'dfs',
908
+ Dfs = "dfs",
872
909
  /** Highest-priority-first within the selection window, scored by `CrawlStrategy.score_url`. */
873
- BestFirst = 'best_first',
910
+ BestFirst = "best_first",
874
911
  /** Like `BestFirst`, but stops once newly crawled pages stop contributing new terms. */
875
- Adaptive = 'adaptive'
912
+ Adaptive = "adaptive",
876
913
  }
877
914
 
878
- export declare function crawlStream(engine: CrawlEngineHandle, url: string): Promise<CrawlStreamIterator>
879
-
880
915
  /**
881
916
  * Request to begin a single-URL streaming crawl.
882
917
  *
@@ -886,17 +921,9 @@ export declare function crawlStream(engine: CrawlEngineHandle, url: string): Pro
886
921
  */
887
922
  export interface CrawlStreamRequest {
888
923
  /** The seed URL to crawl. */
889
- url?: string
924
+ readonly url?: string;
890
925
  }
891
926
 
892
- /**
893
- * Create a new crawl engine with the given configuration.
894
- *
895
- * If `config` is `None`, uses `CrawlConfig.default()`.
896
- * Returns an error if the configuration is invalid.
897
- */
898
- export declare function createEngine(config?: CrawlConfig | undefined | null): CrawlEngineHandle
899
-
900
927
  /**
901
928
  * Opt-in encoding applied to a downloaded document's bytes for callers who need the
902
929
  * content available in a serializable field rather than reading it from disk.
@@ -905,25 +932,25 @@ export declare function createEngine(config?: CrawlConfig | undefined | null): C
905
932
  * screenshots, base64-encoding a document by default would duplicate an already
906
933
  * up-to-`document_max_size` buffer (50 MB default) in memory per document.
907
934
  */
908
- export declare const enum DocumentContentEncoding {
935
+ export declare enum DocumentContentEncoding {
909
936
  /** Populate `DownloadedDocument.content_base64` with a base64-encoded copy. */
910
- Base64 = 'base_64'
937
+ Base64 = "base_64",
911
938
  }
912
939
 
913
940
  /** A downloaded asset from a page. */
914
941
  export interface DownloadedAsset {
915
942
  /** The original URL of the asset. */
916
- url?: string
943
+ readonly url?: string;
917
944
  /** The SHA-256 content hash of the asset. */
918
- contentHash?: string
945
+ readonly contentHash?: string;
919
946
  /** The MIME type from the Content-Type header. */
920
- mimeType?: string
947
+ readonly mimeType?: string;
921
948
  /** The size of the asset in bytes. */
922
- size?: number
949
+ readonly size?: number;
923
950
  /** The category of the asset. */
924
- assetCategory?: AssetCategory | 'document' | 'image' | 'audio' | 'video' | 'font' | 'stylesheet' | 'script' | 'archive' | 'data' | 'other'
951
+ readonly assetCategory?: AssetCategory;
925
952
  /** The HTML tag that referenced this asset (e.g., "link", "script", "img"). */
926
- htmlTag?: string
953
+ readonly htmlTag?: string;
927
954
  }
928
955
 
929
956
  /**
@@ -935,95 +962,86 @@ export interface DownloadedAsset {
935
962
  */
936
963
  export interface DownloadedDocument {
937
964
  /** The URL the document was fetched from. */
938
- url?: string
965
+ readonly url?: string;
939
966
  /** The MIME type from the Content-Type header. */
940
- mimeType?: string
967
+ readonly mimeType?: string;
941
968
  /** Size of the document in bytes. */
942
- size?: number
969
+ readonly size?: number;
943
970
  /** Filename extracted from Content-Disposition or URL path. */
944
- filename?: string
971
+ readonly filename?: string;
945
972
  /** SHA-256 hex digest of the content. */
946
- contentHash?: string
973
+ readonly contentHash?: string;
947
974
  /** Selected response headers. */
948
- headers?: Record<string, string>
975
+ readonly headers?: Record<string, string>;
949
976
  /**
950
977
  * True when `content` (or the file at `content_path`) was truncated to
951
978
  * `document_max_size`; `size` still reports the original, untruncated length.
952
979
  */
953
- truncated?: boolean
980
+ readonly truncated?: boolean;
954
981
  /**
955
982
  * Filesystem path the document was streamed to when `document_output_dir` was
956
983
  * set. `content` is empty in memory when this is populated.
957
984
  */
958
- contentPath?: string
985
+ readonly contentPath?: string;
959
986
  /**
960
987
  * Base64-encoded copy of `content`, populated only when
961
988
  * `document_content_encoding` was set to `Base64`.
962
989
  */
963
- contentBase64?: string
990
+ readonly contentBase64?: string;
964
991
  }
965
992
 
966
993
  /** Metadata about an LLM extraction pass. */
967
994
  export interface ExtractionMeta {
968
995
  /** Estimated cost of the LLM call in USD. */
969
- cost?: number
996
+ readonly cost?: number;
970
997
  /** Number of prompt (input) tokens consumed. */
971
- promptTokens?: number
998
+ readonly promptTokens?: number;
972
999
  /** Number of completion (output) tokens generated. */
973
- completionTokens?: number
1000
+ readonly completionTokens?: number;
974
1001
  /** The model identifier used for extraction. */
975
- model?: string
1002
+ readonly model?: string;
976
1003
  /** Number of content chunks sent to the LLM. */
977
- chunksProcessed?: number
1004
+ readonly chunksProcessed?: number;
978
1005
  }
979
1006
 
980
1007
  /** Information about a favicon or icon link. */
981
1008
  export interface FaviconInfo {
982
1009
  /** The icon URL. */
983
- url?: string
1010
+ readonly url?: string;
984
1011
  /** The `rel` attribute (e.g., "icon", "apple-touch-icon"). */
985
- rel?: string
1012
+ readonly rel?: string;
986
1013
  /** The `sizes` attribute, if present. */
987
- sizes?: string
1014
+ readonly sizes?: string;
988
1015
  /** The MIME type, if present. */
989
- mimeType?: string
1016
+ readonly mimeType?: string;
990
1017
  }
991
1018
 
992
1019
  /** Information about a feed link found on a page. */
993
1020
  export interface FeedInfo {
994
1021
  /** The feed URL. */
995
- url?: string
1022
+ readonly url?: string;
996
1023
  /** The feed title, if present. */
997
- title?: string
1024
+ readonly title?: string;
998
1025
  /** The type of feed. */
999
- feedType?: FeedType | 'rss' | 'atom' | 'json_feed'
1026
+ readonly feedType?: FeedType;
1000
1027
  }
1001
1028
 
1002
1029
  /** The type of a feed (RSS, Atom, or JSON Feed). */
1003
- export declare const enum FeedType {
1030
+ export declare enum FeedType {
1004
1031
  /** RSS feed. */
1005
- Rss = 'rss',
1032
+ Rss = "rss",
1006
1033
  /** Atom feed. */
1007
- Atom = 'atom',
1034
+ Atom = "atom",
1008
1035
  /** JSON Feed. */
1009
- JsonFeed = 'json_feed'
1036
+ JsonFeed = "json_feed",
1010
1037
  }
1011
1038
 
1012
- /**
1013
- * Convert markdown links to numbered citations.
1014
- *
1015
- * `[Example](https://example.com)` becomes `Example[1]`
1016
- * with `[1]: https://example.com` in the reference list.
1017
- * Images `![alt](url)` are preserved unchanged.
1018
- */
1019
- export declare function generateCitations(markdown: string): CitationResult
1020
-
1021
1039
  /** A heading element extracted from the page. */
1022
1040
  export interface HeadingInfo {
1023
1041
  /** The heading level (1-6). */
1024
- level?: number
1042
+ readonly level?: number;
1025
1043
  /** The heading text content. */
1026
- text?: string
1044
+ readonly text?: string;
1027
1045
  }
1028
1046
 
1029
1047
  /**
@@ -1043,125 +1061,125 @@ export interface HeadingInfo {
1043
1061
  *
1044
1062
  * `Exact`: HostMatcher.Exact
1045
1063
  */
1046
- export interface HostMatcher {
1047
- type: string
1048
- value?: string
1049
- }
1064
+ export type HostMatcher =
1065
+ | { type: "exact"; value: string }
1066
+ | { type: "suffix"; value: string }
1067
+ | { type: "cidr"; value: string };
1050
1068
 
1051
1069
  /** An hreflang alternate link entry. */
1052
1070
  export interface HreflangEntry {
1053
1071
  /** The language code (e.g., "en", "fr", "x-default"). */
1054
- lang?: string
1072
+ readonly lang?: string;
1055
1073
  /** The URL for this language variant. */
1056
- url?: string
1074
+ readonly url?: string;
1057
1075
  }
1058
1076
 
1059
1077
  /** Information about an image found on a page. */
1060
1078
  export interface ImageInfo {
1061
1079
  /** The image URL. */
1062
- url?: string
1080
+ readonly url?: string;
1063
1081
  /** The alt text, if present. */
1064
- alt?: string
1082
+ readonly alt?: string;
1065
1083
  /** The width attribute, if present and parseable. */
1066
- width?: number
1084
+ readonly width?: number;
1067
1085
  /** The height attribute, if present and parseable. */
1068
- height?: number
1086
+ readonly height?: number;
1069
1087
  /** The source of the image reference. */
1070
- source?: ImageSource | 'img' | 'picture_source' | 'og:image' | 'twitter:image'
1088
+ readonly source?: ImageSource;
1071
1089
  }
1072
1090
 
1073
1091
  /** The source of an image reference. */
1074
- export declare const enum ImageSource {
1092
+ export declare enum ImageSource {
1075
1093
  /** An `<img>` tag. */
1076
- Img = 'img',
1094
+ Img = "img",
1077
1095
  /** A `<source>` tag inside `<picture>`. */
1078
- PictureSource = 'picture_source',
1096
+ PictureSource = "picture_source",
1079
1097
  /** An `og:image` meta tag. */
1080
- OgImage = 'og:image',
1098
+ OgImage = "og:image",
1081
1099
  /** A `twitter:image` meta tag. */
1082
- TwitterImage = 'twitter:image'
1100
+ TwitterImage = "twitter:image",
1083
1101
  }
1084
1102
 
1085
- /** Execute browser actions on a single page. */
1086
- export declare function interact(engine: CrawlEngineHandle, url: string, actions: Array<PageAction>): Promise<InteractionResult>
1087
-
1088
1103
  /** Result of executing a sequence of page interaction actions. */
1089
1104
  export interface InteractionResult {
1090
1105
  /** Results from each executed action. */
1091
- actionResults?: Array<ActionResult>
1106
+ readonly actionResults?: Array<ActionResult>;
1092
1107
  /** Final page HTML after all actions completed. */
1093
- finalHtml?: string
1108
+ readonly finalHtml?: string;
1094
1109
  /** Final page URL (may have changed due to navigation). */
1095
- finalUrl?: string
1110
+ readonly finalUrl?: string;
1096
1111
  /**
1097
1112
  * Base64-encoded PNG screenshot taken after all actions.
1098
1113
  *
1099
1114
  * Populated only when a `PageAction.Screenshot` action actually ran, so
1100
1115
  * callers that never request a screenshot do not pay the encoding cost.
1101
1116
  */
1102
- screenshotBase64?: string
1117
+ readonly screenshotBase64?: string;
1103
1118
  /**
1104
1119
  * URLs of the requests the page sent during the session that the SSRF policy refused,
1105
1120
  * including during the extra wait, without their credentials, each listed once.
1106
1121
  */
1107
- ssrfRefusedUrls?: Array<string>
1122
+ readonly ssrfRefusedUrls?: Array<string>;
1108
1123
  }
1109
1124
 
1110
1125
  /** A JSON-LD structured data entry found on a page. */
1111
1126
  export interface JsonLdEntry {
1112
1127
  /** The `@type` value from the JSON-LD object. */
1113
- schemaType?: string
1128
+ readonly schemaType?: string;
1114
1129
  /** The `name` value, if present. */
1115
- name?: string
1130
+ readonly name?: string;
1116
1131
  /** The raw JSON-LD string. */
1117
- raw?: string
1132
+ readonly raw?: string;
1118
1133
  }
1119
1134
 
1120
1135
  /** Information about a link found on a page. */
1121
1136
  export interface LinkInfo {
1122
1137
  /** The resolved URL of the link. */
1123
- url?: string
1138
+ readonly url?: string;
1124
1139
  /** The visible text of the link. */
1125
- text?: string
1140
+ readonly text?: string;
1126
1141
  /** The classification of the link. */
1127
- linkType?: LinkType | 'internal' | 'external' | 'anchor' | 'document'
1142
+ readonly linkType?: LinkType;
1128
1143
  /** The `rel` attribute value, if present. */
1129
- rel?: string
1144
+ readonly rel?: string;
1130
1145
  /** Whether the link has `rel="nofollow"`. */
1131
- nofollow?: boolean
1146
+ readonly nofollow?: boolean;
1147
+ /**
1148
+ * Link address resolved against the page's base without changing path spelling.
1149
+ * Percent escapes, Unicode, spaces, backslashes and dot segments are preserved.
1150
+ * URL credentials are removed. <!-- -->
1151
+ */
1152
+ readonly originalUrl?: string;
1132
1153
  }
1133
1154
 
1134
1155
  /** The classification of a link. */
1135
- export declare const enum LinkType {
1156
+ export declare enum LinkType {
1136
1157
  /** A link to the same domain. */
1137
- Internal = 'internal',
1158
+ Internal = "internal",
1138
1159
  /** A link to a different domain. */
1139
- External = 'external',
1140
- /** A fragment-only link (e.g., `#section`). */
1141
- Anchor = 'anchor',
1160
+ External = "external",
1161
+ /** A link into the page it is on: its address without the fragment is the page address (e.g., `#section`). */
1162
+ Anchor = "anchor",
1142
1163
  /** A link to a downloadable document (PDF, DOC, etc.). */
1143
- Document = 'document'
1164
+ Document = "document",
1144
1165
  }
1145
1166
 
1146
1167
  /** The result of a map operation, containing discovered URLs. */
1147
1168
  export interface MapResult {
1148
1169
  /** The list of discovered URLs. */
1149
- urls?: Array<JsSitemapUrl>
1170
+ readonly urls?: Array<SitemapUrl>;
1150
1171
  }
1151
1172
 
1152
- /** Discover all pages on a website by following links and sitemaps. */
1153
- export declare function mapUrls(engine: CrawlEngineHandle, url: string): Promise<MapResult>
1154
-
1155
1173
  /** Rich markdown conversion result from HTML processing. */
1156
1174
  export interface MarkdownResult {
1157
1175
  /** Converted markdown text. */
1158
- content?: string
1176
+ readonly content?: string;
1159
1177
  /** Structured document tree with semantic nodes. */
1160
- documentStructure?: any
1178
+ readonly documentStructure?: JsonValue;
1161
1179
  /** Extracted tables with structured cell data. */
1162
- tables?: Array<any>
1180
+ readonly tables?: Array<JsonValue>;
1163
1181
  /** Non-fatal processing warnings. */
1164
- warnings?: Array<string>
1182
+ readonly warnings?: Array<string>;
1165
1183
  /**
1166
1184
  * Whether citation conversion was applied and produced at least one reference.
1167
1185
  *
@@ -1170,9 +1188,9 @@ export interface MarkdownResult {
1170
1188
  * is available in `content`; the full reference list is accessible via
1171
1189
  * `generate_citations` if needed separately.
1172
1190
  */
1173
- citations?: boolean
1191
+ readonly citations?: boolean;
1174
1192
  /** Content-filtered markdown optimized for LLM consumption. */
1175
- fitContent?: string
1193
+ readonly fitContent?: string;
1176
1194
  }
1177
1195
 
1178
1196
  /**
@@ -1181,193 +1199,188 @@ export interface MarkdownResult {
1181
1199
  * Actions are serialized with a `type` tag using camelCase naming,
1182
1200
  * except `ExecuteJs` which is explicitly renamed to `"executeJs"`.
1183
1201
  */
1184
- export interface PageAction {
1185
- type: string
1186
- selector?: string
1187
- text?: string
1188
- key?: string
1189
- direction?: JsScrollDirection
1190
- amount?: number
1191
- milliseconds?: number
1192
- fullPage?: boolean
1193
- script?: string
1194
- }
1202
+ export type PageAction =
1203
+ | { type: "click"; selector: string }
1204
+ | { type: "type"; selector: string; text: string }
1205
+ | { type: "press"; key: string }
1206
+ | { type: "scroll"; direction: ScrollDirection; selector: string; amount: number }
1207
+ | { type: "wait"; milliseconds: number; selector: string }
1208
+ | { type: "screenshot"; fullPage: boolean }
1209
+ | { type: "executeJs"; script: string }
1210
+ | { type: "scrape" };
1195
1211
 
1196
1212
  /** Metadata extracted from an HTML page's `<meta>` tags and `<title>` element. */
1197
1213
  export interface PageMetadata {
1198
1214
  /** The page title from the `<title>` element. */
1199
- title?: string
1215
+ readonly title?: string;
1200
1216
  /** The meta description. */
1201
- description?: string
1217
+ readonly description?: string;
1202
1218
  /** The canonical URL from `<link rel="canonical">`. */
1203
- canonicalUrl?: string
1219
+ readonly canonicalUrl?: string;
1204
1220
  /** Keywords from `<meta name="keywords">`. */
1205
- keywords?: string
1221
+ readonly keywords?: string;
1206
1222
  /** Author from `<meta name="author">`. */
1207
- author?: string
1223
+ readonly author?: string;
1208
1224
  /** Viewport content from `<meta name="viewport">`. */
1209
- viewport?: string
1225
+ readonly viewport?: string;
1210
1226
  /** Theme color from `<meta name="theme-color">`. */
1211
- themeColor?: string
1227
+ readonly themeColor?: string;
1212
1228
  /** Generator from `<meta name="generator">`. */
1213
- generator?: string
1229
+ readonly generator?: string;
1214
1230
  /** Robots content from `<meta name="robots">`. */
1215
- robots?: string
1231
+ readonly robots?: string;
1216
1232
  /** The `lang` attribute from the `<html>` element. */
1217
- htmlLang?: string
1233
+ readonly htmlLang?: string;
1218
1234
  /** The `dir` attribute from the `<html>` element. */
1219
- htmlDir?: string
1235
+ readonly htmlDir?: string;
1220
1236
  /** Open Graph title. */
1221
- ogTitle?: string
1237
+ readonly ogTitle?: string;
1222
1238
  /** Open Graph type. */
1223
- ogType?: string
1239
+ readonly ogType?: string;
1224
1240
  /** Open Graph image URL. */
1225
- ogImage?: string
1241
+ readonly ogImage?: string;
1226
1242
  /** Open Graph description. */
1227
- ogDescription?: string
1243
+ readonly ogDescription?: string;
1228
1244
  /** Open Graph URL. */
1229
- ogUrl?: string
1245
+ readonly ogUrl?: string;
1230
1246
  /** Open Graph site name. */
1231
- ogSiteName?: string
1247
+ readonly ogSiteName?: string;
1232
1248
  /** Open Graph locale. */
1233
- ogLocale?: string
1249
+ readonly ogLocale?: string;
1234
1250
  /** Open Graph video URL. */
1235
- ogVideo?: string
1251
+ readonly ogVideo?: string;
1236
1252
  /** Open Graph audio URL. */
1237
- ogAudio?: string
1253
+ readonly ogAudio?: string;
1238
1254
  /** Open Graph locale alternates. */
1239
- ogLocaleAlternates?: Array<string>
1255
+ readonly ogLocaleAlternates?: Array<string>;
1240
1256
  /** Twitter card type. */
1241
- twitterCard?: string
1257
+ readonly twitterCard?: string;
1242
1258
  /** Twitter title. */
1243
- twitterTitle?: string
1259
+ readonly twitterTitle?: string;
1244
1260
  /** Twitter description. */
1245
- twitterDescription?: string
1261
+ readonly twitterDescription?: string;
1246
1262
  /** Twitter image URL. */
1247
- twitterImage?: string
1263
+ readonly twitterImage?: string;
1248
1264
  /** Twitter site handle. */
1249
- twitterSite?: string
1265
+ readonly twitterSite?: string;
1250
1266
  /** Twitter creator handle. */
1251
- twitterCreator?: string
1267
+ readonly twitterCreator?: string;
1252
1268
  /** Dublin Core title. */
1253
- dcTitle?: string
1269
+ readonly dcTitle?: string;
1254
1270
  /** Dublin Core creator. */
1255
- dcCreator?: string
1271
+ readonly dcCreator?: string;
1256
1272
  /** Dublin Core subject. */
1257
- dcSubject?: string
1273
+ readonly dcSubject?: string;
1258
1274
  /** Dublin Core description. */
1259
- dcDescription?: string
1275
+ readonly dcDescription?: string;
1260
1276
  /** Dublin Core publisher. */
1261
- dcPublisher?: string
1277
+ readonly dcPublisher?: string;
1262
1278
  /** Dublin Core date. */
1263
- dcDate?: string
1279
+ readonly dcDate?: string;
1264
1280
  /** Dublin Core type. */
1265
- dcType?: string
1281
+ readonly dcType?: string;
1266
1282
  /** Dublin Core format. */
1267
- dcFormat?: string
1283
+ readonly dcFormat?: string;
1268
1284
  /** Dublin Core identifier. */
1269
- dcIdentifier?: string
1285
+ readonly dcIdentifier?: string;
1270
1286
  /** Dublin Core language. */
1271
- dcLanguage?: string
1287
+ readonly dcLanguage?: string;
1272
1288
  /** Dublin Core rights. */
1273
- dcRights?: string
1289
+ readonly dcRights?: string;
1274
1290
  /** Article metadata from `article:*` Open Graph tags. */
1275
- article?: ArticleMetadata
1291
+ readonly article?: ArticleMetadata;
1276
1292
  /** Hreflang alternate links. */
1277
- hreflangs?: Array<HreflangEntry>
1293
+ readonly hreflangs?: Array<HreflangEntry>;
1278
1294
  /** Favicon and icon links. */
1279
- favicons?: Array<FaviconInfo>
1295
+ readonly favicons?: Array<FaviconInfo>;
1280
1296
  /** Heading elements (h1-h6). */
1281
- headings?: Array<HeadingInfo>
1297
+ readonly headings?: Array<HeadingInfo>;
1282
1298
  /** Computed word count of the page body text. */
1283
- wordCount?: number
1299
+ readonly wordCount?: number;
1284
1300
  }
1285
1301
 
1286
1302
  /** Proxy configuration for HTTP requests. */
1287
1303
  export interface ProxyConfig {
1288
1304
  /** Proxy URL (e.g. "http://proxy:8080"). <!-- --> */
1289
- url?: string
1305
+ readonly url?: string;
1290
1306
  /** Optional username for proxy authentication. */
1291
- username?: string
1307
+ readonly username?: string;
1292
1308
  /** Optional password for proxy authentication. */
1293
- password?: string
1309
+ readonly password?: string;
1294
1310
  }
1295
1311
 
1296
1312
  /** Response metadata extracted from HTTP headers. */
1297
1313
  export interface ResponseMeta {
1298
1314
  /** The ETag header value. */
1299
- etag?: string
1315
+ readonly etag?: string;
1300
1316
  /** The Last-Modified header value. */
1301
- lastModified?: string
1317
+ readonly lastModified?: string;
1302
1318
  /** The Cache-Control header value. */
1303
- cacheControl?: string
1319
+ readonly cacheControl?: string;
1304
1320
  /** The Server header value. */
1305
- server?: string
1321
+ readonly server?: string;
1306
1322
  /** The X-Powered-By header value. */
1307
- xPoweredBy?: string
1323
+ readonly xPoweredBy?: string;
1308
1324
  /** The Content-Language header value. */
1309
- contentLanguage?: string
1325
+ readonly contentLanguage?: string;
1310
1326
  /** The Content-Encoding header value. */
1311
- contentEncoding?: string
1327
+ readonly contentEncoding?: string;
1312
1328
  }
1313
1329
 
1314
- /** Scrape a single URL, returning extracted page data. */
1315
- export declare function scrape(engine: CrawlEngineHandle, url: string): Promise<ScrapeResult>
1316
-
1317
1330
  /** The result of a single-page scrape operation. */
1318
1331
  export interface ScrapeResult {
1319
1332
  /** The HTTP status code of the response. */
1320
- statusCode?: number
1333
+ readonly statusCode?: number;
1321
1334
  /** The final URL after following all redirects. */
1322
- finalUrl?: string
1335
+ readonly finalUrl?: string;
1323
1336
  /** The Content-Type header value. */
1324
- contentType?: string
1337
+ readonly contentType?: string;
1325
1338
  /** The HTML body of the response. */
1326
- html?: string
1339
+ readonly html?: string;
1327
1340
  /** The size of the response body in bytes. */
1328
- bodySize?: number
1341
+ readonly bodySize?: number;
1329
1342
  /** Extracted metadata from the page. */
1330
- metadata?: PageMetadata
1343
+ readonly metadata?: PageMetadata;
1331
1344
  /** Links found on the page. */
1332
- links?: Array<LinkInfo>
1345
+ readonly links?: Array<LinkInfo>;
1333
1346
  /** Images found on the page. */
1334
- images?: Array<ImageInfo>
1347
+ readonly images?: Array<ImageInfo>;
1335
1348
  /** Feed links found on the page. */
1336
- feeds?: Array<FeedInfo>
1349
+ readonly feeds?: Array<FeedInfo>;
1337
1350
  /** JSON-LD entries found on the page. */
1338
- jsonLd?: Array<JsonLdEntry>
1351
+ readonly jsonLd?: Array<JsonLdEntry>;
1339
1352
  /** Whether the URL is allowed by robots.txt. */
1340
- isAllowed?: boolean
1353
+ readonly isAllowed?: boolean;
1341
1354
  /** The crawl delay from robots.txt, in seconds. */
1342
- crawlDelay?: number
1355
+ readonly crawlDelay?: number;
1343
1356
  /** Whether a noindex directive was detected. */
1344
- noindexDetected?: boolean
1357
+ readonly noindexDetected?: boolean;
1345
1358
  /** Whether a nofollow directive was detected. */
1346
- nofollowDetected?: boolean
1359
+ readonly nofollowDetected?: boolean;
1347
1360
  /** The X-Robots-Tag header values, joined with `, ` when the response sent more than one. */
1348
- xRobotsTag?: string
1361
+ readonly xRobotsTag?: string;
1349
1362
  /** Whether the content is a PDF. */
1350
- isPdf?: boolean
1363
+ readonly isPdf?: boolean;
1351
1364
  /** Whether the page was skipped (binary or PDF content). */
1352
- wasSkipped?: boolean
1365
+ readonly wasSkipped?: boolean;
1353
1366
  /** The detected character set encoding. */
1354
- detectedCharset?: string
1367
+ readonly detectedCharset?: string;
1355
1368
  /** Whether an authentication header was sent with the request. */
1356
- authHeaderSent?: boolean
1369
+ readonly authHeaderSent?: boolean;
1357
1370
  /** Response metadata extracted from HTTP headers. */
1358
- responseMeta?: ResponseMeta
1371
+ readonly responseMeta?: ResponseMeta;
1359
1372
  /** Downloaded assets from the page. */
1360
- assets?: Array<DownloadedAsset>
1373
+ readonly assets?: Array<DownloadedAsset>;
1361
1374
  /** Whether the page content suggests JavaScript rendering is needed. */
1362
- jsRenderHint?: boolean
1375
+ readonly jsRenderHint?: boolean;
1363
1376
  /** Whether the browser fallback was used to fetch this page. */
1364
- browserUsed?: boolean
1377
+ readonly browserUsed?: boolean;
1365
1378
  /** Markdown conversion of the page content. */
1366
- markdown?: MarkdownResult
1379
+ readonly markdown?: MarkdownResult;
1367
1380
  /** Structured data extracted by LLM. Populated when extraction is configured. */
1368
- extractedData?: any
1381
+ readonly extractedData?: JsonValue;
1369
1382
  /** Metadata about the LLM extraction pass (cost, tokens, model). */
1370
- extractionMeta?: ExtractionMeta
1383
+ readonly extractionMeta?: ExtractionMeta;
1371
1384
  /**
1372
1385
  * Base64-encoded PNG screenshot of the page.
1373
1386
  *
@@ -1375,45 +1388,45 @@ export interface ScrapeResult {
1375
1388
  * request, so callers that never requested a screenshot do not pay the
1376
1389
  * encoding cost.
1377
1390
  */
1378
- screenshotBase64?: string
1391
+ readonly screenshotBase64?: string;
1379
1392
  /** Downloaded non-HTML document (PDF, DOCX, image, code, etc.). */
1380
- downloadedDocument?: DownloadedDocument
1393
+ readonly downloadedDocument?: DownloadedDocument;
1381
1394
  /**
1382
1395
  * Browser-specific extras (eval result, network events, cookies). Only
1383
1396
  * populated when `BrowserBackend.Native` was used for this request.
1384
1397
  */
1385
- browser?: BrowserExtras
1398
+ readonly browser?: BrowserExtras;
1386
1399
  /**
1387
1400
  * URLs of the requests the page sent in browser mode that the SSRF policy refused, without
1388
1401
  * their credentials, each listed once. The page is kept; only the refused requests failed.
1389
1402
  */
1390
- ssrfRefusedUrls?: Array<string>
1403
+ readonly ssrfRefusedUrls?: Array<string>;
1391
1404
  }
1392
1405
 
1393
1406
  /** Direction for a scroll action. */
1394
- export declare const enum ScrollDirection {
1407
+ export declare enum ScrollDirection {
1395
1408
  /** Scroll upward. */
1396
- Up = 'up',
1409
+ Up = "up",
1397
1410
  /** Scroll downward. */
1398
- Down = 'down'
1411
+ Down = "down",
1399
1412
  }
1400
1413
 
1401
1414
  /** A URL entry from a sitemap. */
1402
1415
  export interface SitemapUrl {
1403
1416
  /** The URL. */
1404
- url?: string
1417
+ readonly url?: string;
1405
1418
  /** The last modification date, if present. */
1406
- lastmod?: string
1419
+ readonly lastmod?: string;
1407
1420
  /** The change frequency, if present. */
1408
- changefreq?: string
1421
+ readonly changefreq?: string;
1409
1422
  /** The priority, if present. */
1410
- priority?: string
1423
+ readonly priority?: string;
1411
1424
  }
1412
1425
 
1413
1426
  /** SSRF policy configuration. */
1414
1427
  export interface SsrfPolicy {
1415
1428
  /** If true, reject URLs that resolve to private/metadata IP ranges. */
1416
- denyPrivate?: boolean
1429
+ readonly denyPrivate?: boolean;
1417
1430
  /**
1418
1431
  * Hostnames and IP ranges permitted regardless of `deny_private`, unless a matching
1419
1432
  * address is in `denylist`.
@@ -1433,7 +1446,7 @@ export interface SsrfPolicy {
1433
1446
  * An empty allowlist therefore denies nothing by itself — it simply leaves
1434
1447
  * `deny_private` and the deny-list in sole control.
1435
1448
  */
1436
- allowlist?: Array<JsHostMatcher>
1449
+ readonly allowlist?: Array<HostMatcher>;
1437
1450
  /**
1438
1451
  * IP ranges refused regardless of `deny_private` and `allowlist`.
1439
1452
  *
@@ -1443,37 +1456,29 @@ export interface SsrfPolicy {
1443
1456
  * and cannot weaken it. A hostname is refused when an upstream proxy or remote browser
1444
1457
  * performs the connection lookup, because that lookup cannot be bound to these checks.
1445
1458
  */
1446
- denylist?: Array<JsHostMatcher>
1459
+ readonly denylist?: Array<HostMatcher>;
1447
1460
  /** Maximum number of HTTP redirects to follow during validation. */
1448
- maxRedirects?: number
1461
+ readonly maxRedirects?: number;
1449
1462
  /**
1450
1463
  * Allowed URI schemes. Default: `["http", "https"]`.
1451
1464
  *
1452
1465
  * Only `http` and `https` are supported. An empty list denies every URL.
1453
1466
  */
1454
- schemeAllowlist?: Array<string>
1467
+ readonly schemeAllowlist?: Array<string>;
1455
1468
  }
1456
1469
 
1457
- export declare function ssrfPolicyDefault(): SsrfPolicy
1470
+ /** Discover all pages on a website by following links and sitemaps. */
1471
+ export declare function mapUrls(engine: CrawlEngineHandle, url: string): Promise<MapResult>;
1458
1472
 
1459
- /**
1460
- * Create a policy from environment variables.
1461
- *
1462
- * On native platforms, reads `CRAWLBERG_ALLOW_PRIVATE_NETWORK` — if set to "1" or "true"
1463
- * (case-insensitive), sets `deny_private = false`. Otherwise, defaults to `deny_private = true`.
1464
- *
1465
- * On wasm32 targets (browser/Node.js), environment variables are not accessible to the
1466
- * compiled module. Defaults to `deny_private = false` because:
1467
- * - Outbound requests in a browser go through the fetch API, which enforces its own network policies.
1468
- * - Rust-side SSRF checking is unenforceable and redundant in a wasm32 context.
1469
- * - For testing and localhost access, the host's network sandbox is the enforcing boundary.
1470
- *
1471
- * **Node.js caveat:** `deny_private` and `denylist` have no effect on hostname-based requests
1472
- * under `wasm32`. There is no DNS resolution on this target, so `validate_url` only ever
1473
- * checks a literal IP host; a domain name falls straight through to `Ok(())`. In a browser
1474
- * this is covered by same-origin/CORS. Node's `fetch` enforces no CORS, so a Node service
1475
- * embedding this wasm module can be driven to internal hosts by domain name despite the
1476
- * policy. Enforce egress restrictions (network policy, firewall, proxy allowlist) outside
1477
- * the process.
1478
- */
1479
- export declare function ssrfPolicyFromEnv(): SsrfPolicy
1473
+ /** Scrape a single URL, returning extracted page data. */
1474
+ export declare function scrape(engine: CrawlEngineHandle, url: string): Promise<ScrapeResult>;
1475
+
1476
+ export declare class BatchCrawlStreamIterator {
1477
+ next(value?: undefined): Promise<IteratorResult<CrawlEvent, void>>;
1478
+ [Symbol.asyncIterator](): AsyncGenerator<CrawlEvent, void, undefined>;
1479
+ }
1480
+
1481
+ export declare class CrawlStreamIterator {
1482
+ next(value?: undefined): Promise<IteratorResult<CrawlEvent, void>>;
1483
+ [Symbol.asyncIterator](): AsyncGenerator<CrawlEvent, void, undefined>;
1484
+ }