@hunt-labs/bytekit-mcp 0.2.7 → 0.3.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/CHANGELOG.md CHANGED
@@ -10,6 +10,43 @@ today, see [README.md](./README.md), which remains the authoritative usage guide
10
10
 
11
11
  ## [Unreleased]
12
12
 
13
+ ## [0.3.0] - 2026-08-20
14
+
15
+ ### Removed
16
+
17
+ - **BREAKING: the bundled docs no longer describe `cookies` or `headers` as capture request
18
+ fields** (#3242). Those fields were removed from `/v1/scrape`, `/v1/scrape/bulk`,
19
+ `/v1/screenshots`, `/v1/recordings` and `/v1/schema`; a request carrying either is rejected
20
+ with `400 validation_error`. Tools that composed request bodies from the bundle will no longer
21
+ see the fields offered.
22
+
23
+ ### Changed
24
+
25
+ - **`get_doc` now returns a bounded body, and says when it cut one** (#3233). A page above
26
+ 16,384 bytes comes back cut short, ending in a notice that names the limit, the page's full
27
+ size, and the docs URL that serves all of it — a caller can never mistake a partial page for a
28
+ complete one. Every page under the limit is returned byte for byte, in the same
29
+ `{ title, section, body }` envelope as before, so nothing else about the tool changes. The cap
30
+ is advertised in the tool's own description.
31
+ - **The bundled offline docs no longer ship an unbounded page** (#3233). The harvest step applies
32
+ the same 16,384-byte per-page bound. The generated `changelog` page was 46.5% of the whole
33
+ bundle on its own; it is still a bundled page, so `list_docs` lists it and `search_docs` ranks
34
+ it, but full-text search now reaches only the releases above the cut. The docs site keeps the
35
+ whole changelog.
36
+
37
+ ## [0.2.8] - 2026-08-19
38
+
39
+ ### Changed
40
+
41
+ - **The generated scrape contract's billing factor vocabulary gained `phase1_render`** (#3141).
42
+ `BillingFactorName` is a closed union copied verbatim into `src/scrape-contract.generated.ts`,
43
+ and screenshots and recordings bill on a basis the byte-scrape factors cannot name — Phase 1
44
+ proxy wire bytes times a 1.5 render-overhead multiplier. A capture's billing node carries that
45
+ one factor and none of the byte-scrape names; the two vocabularies never mix on a single node.
46
+ This release is a regeneration of the checked-in contract only, with no behavior change in the
47
+ server itself: the MCP tools do not call the capture endpoints whose responses now carry the
48
+ node.
49
+
13
50
  ## [0.2.7] - 2026-08-18
14
51
 
15
52
  ### Changed
@@ -0,0 +1,76 @@
1
+ /**
2
+ * The per-page byte bound on a bundled documentation body (issue #3233).
3
+ *
4
+ * WHY A BOUND EXISTS
5
+ * ------------------
6
+ * Every page in the bundle is a *retrieval unit*: `get_doc` returns one whole body into a
7
+ * caller's context, and the bundle itself ships inside the published `@hunt-labs/bytekit-mcp`
8
+ * tarball and the gateway Docker image. Both costs are per-entry, so both are bounded per-entry.
9
+ * At 96d5f3873 the generated `changelog` page was 135,687 bytes — 46.5% of the whole bundle and
10
+ * 14× the largest other page — and `get_doc("changelog")` handed all of it back uncapped.
11
+ *
12
+ * WHY 16 KiB, AND WHY PER-ENTRY
13
+ * -----------------------------
14
+ * Measured over the committed bundle at 96d5f3873 (103 entries): median body 744 bytes, p95
15
+ * 5,027, largest legitimate page 9,607 (`guides/monitors`), then a 14× jump straight to the
16
+ * changelog's 135,687. The threshold sits inside that gap:
17
+ *
18
+ * - 16,384 bytes is 1.7× the largest legitimate page, so every page written today passes with
19
+ * room to keep growing, and a page has to nearly double before it is flagged;
20
+ * - it is 8.3× below the changelog, so the entry this bound exists for is flagged decisively;
21
+ * - it is roughly 4k tokens — a page an agent can read inside a normal context budget, which
22
+ * is the property the ticket's Expected section asks for.
23
+ *
24
+ * The unit is PER-ENTRY, not whole-bundle, deliberately: a whole-bundle cap makes an innocent
25
+ * page start failing the moment unrelated pages are added, which punishes the wrong author and
26
+ * says nothing about whether any single retrieval is usable. A per-entry cap is a statement
27
+ * about the one thing a caller receives.
28
+ *
29
+ * WHERE IT IS APPLIED
30
+ * -------------------
31
+ * Twice, from this one definition:
32
+ * - `scripts/build-docs-bundle.ts`, at the harvest step, so the committed artifact never holds
33
+ * an oversized entry (that is the 46%-of-the-bundle half of the defect);
34
+ * - `src/tools/get-doc.ts`, at the read, so the tool's contract holds for whatever bundle is
35
+ * on disk rather than only for one this repo generated (that is the uncapped-read half).
36
+ * Applying it at the read is idempotent over an already-harvest-bounded body: the second call
37
+ * sees a body under the limit and returns it untouched.
38
+ *
39
+ * The cut is never silent — see {@link truncationNotice}.
40
+ */
41
+ export declare const MAX_DOC_BODY_BYTES: number;
42
+ /** Public docs origin, the same one `llms.txt` publishes page URLs under. */
43
+ export declare const DOCS_BASE_URL = "https://bytekit.com/docs";
44
+ /**
45
+ * The notice appended in place of the content that was cut.
46
+ *
47
+ * It carries four things a caller needs and cannot otherwise recover: that the body is
48
+ * incomplete, how large the page is in full, that the cut text is outside `search_docs` as well
49
+ * as outside this response, and where to read the whole of it. A truncation with no marker would
50
+ * reproduce this bug's own failure mode — an agent reasoning confidently over a partial page —
51
+ * in a new place.
52
+ *
53
+ * WHY THE SEARCH SENTENCE IS HERE (issue #3307)
54
+ * ---------------------------------------------
55
+ * `search_docs` matches over the same harvested bodies this bound cuts, so the bound narrowed
56
+ * SEARCH as well as retrieval — on the `changelog` page 88.3% of the text stopped being
57
+ * matchable at all. #3307 weighed restoring that coverage against stating plainly what is
58
+ * missing, and took the second: the bound is #3233's precedence rule and is not reopened here,
59
+ * and indexing more than `get_doc` will return would let a search hit land in bytes the reader
60
+ * is then refused. So the honest defect — a caller could not tell what they were NOT seeing —
61
+ * is answered where the caller is already looking, in the bytes they were handed.
62
+ *
63
+ * Its length depends only on `originalBytes` and `urlPath`, both known before the cut, so the
64
+ * budget left for content is computable in one pass.
65
+ */
66
+ export declare function truncationNotice(originalBytes: number, urlPath: string): string;
67
+ /**
68
+ * Bounds one documentation body at {@link MAX_DOC_BODY_BYTES}, announcing the cut in the bytes
69
+ * it returns. A body already under the limit is returned unchanged, byte for byte.
70
+ *
71
+ * `urlPath` is the bundle key (e.g. `guides/monitors`), used to point at the full page.
72
+ */
73
+ export declare function boundDocBody(body: string, urlPath: string): {
74
+ body: string;
75
+ truncated: boolean;
76
+ };
@@ -0,0 +1,102 @@
1
+ /**
2
+ * The per-page byte bound on a bundled documentation body (issue #3233).
3
+ *
4
+ * WHY A BOUND EXISTS
5
+ * ------------------
6
+ * Every page in the bundle is a *retrieval unit*: `get_doc` returns one whole body into a
7
+ * caller's context, and the bundle itself ships inside the published `@hunt-labs/bytekit-mcp`
8
+ * tarball and the gateway Docker image. Both costs are per-entry, so both are bounded per-entry.
9
+ * At 96d5f3873 the generated `changelog` page was 135,687 bytes — 46.5% of the whole bundle and
10
+ * 14× the largest other page — and `get_doc("changelog")` handed all of it back uncapped.
11
+ *
12
+ * WHY 16 KiB, AND WHY PER-ENTRY
13
+ * -----------------------------
14
+ * Measured over the committed bundle at 96d5f3873 (103 entries): median body 744 bytes, p95
15
+ * 5,027, largest legitimate page 9,607 (`guides/monitors`), then a 14× jump straight to the
16
+ * changelog's 135,687. The threshold sits inside that gap:
17
+ *
18
+ * - 16,384 bytes is 1.7× the largest legitimate page, so every page written today passes with
19
+ * room to keep growing, and a page has to nearly double before it is flagged;
20
+ * - it is 8.3× below the changelog, so the entry this bound exists for is flagged decisively;
21
+ * - it is roughly 4k tokens — a page an agent can read inside a normal context budget, which
22
+ * is the property the ticket's Expected section asks for.
23
+ *
24
+ * The unit is PER-ENTRY, not whole-bundle, deliberately: a whole-bundle cap makes an innocent
25
+ * page start failing the moment unrelated pages are added, which punishes the wrong author and
26
+ * says nothing about whether any single retrieval is usable. A per-entry cap is a statement
27
+ * about the one thing a caller receives.
28
+ *
29
+ * WHERE IT IS APPLIED
30
+ * -------------------
31
+ * Twice, from this one definition:
32
+ * - `scripts/build-docs-bundle.ts`, at the harvest step, so the committed artifact never holds
33
+ * an oversized entry (that is the 46%-of-the-bundle half of the defect);
34
+ * - `src/tools/get-doc.ts`, at the read, so the tool's contract holds for whatever bundle is
35
+ * on disk rather than only for one this repo generated (that is the uncapped-read half).
36
+ * Applying it at the read is idempotent over an already-harvest-bounded body: the second call
37
+ * sees a body under the limit and returns it untouched.
38
+ *
39
+ * The cut is never silent — see {@link truncationNotice}.
40
+ */
41
+ export const MAX_DOC_BODY_BYTES = 16 * 1024;
42
+ /** Public docs origin, the same one `llms.txt` publishes page URLs under. */
43
+ export const DOCS_BASE_URL = 'https://bytekit.com/docs';
44
+ /**
45
+ * The notice appended in place of the content that was cut.
46
+ *
47
+ * It carries four things a caller needs and cannot otherwise recover: that the body is
48
+ * incomplete, how large the page is in full, that the cut text is outside `search_docs` as well
49
+ * as outside this response, and where to read the whole of it. A truncation with no marker would
50
+ * reproduce this bug's own failure mode — an agent reasoning confidently over a partial page —
51
+ * in a new place.
52
+ *
53
+ * WHY THE SEARCH SENTENCE IS HERE (issue #3307)
54
+ * ---------------------------------------------
55
+ * `search_docs` matches over the same harvested bodies this bound cuts, so the bound narrowed
56
+ * SEARCH as well as retrieval — on the `changelog` page 88.3% of the text stopped being
57
+ * matchable at all. #3307 weighed restoring that coverage against stating plainly what is
58
+ * missing, and took the second: the bound is #3233's precedence rule and is not reopened here,
59
+ * and indexing more than `get_doc` will return would let a search hit land in bytes the reader
60
+ * is then refused. So the honest defect — a caller could not tell what they were NOT seeing —
61
+ * is answered where the caller is already looking, in the bytes they were handed.
62
+ *
63
+ * Its length depends only on `originalBytes` and `urlPath`, both known before the cut, so the
64
+ * budget left for content is computable in one pass.
65
+ */
66
+ export function truncationNotice(originalBytes, urlPath) {
67
+ return (`\n\n---\n[Truncated to the ${MAX_DOC_BODY_BYTES}-byte per-page limit — ` +
68
+ `this page is ${originalBytes} bytes in full. ` +
69
+ `The text cut here is not searchable either: search_docs matches only the part kept above. ` +
70
+ `Read all of it at ${DOCS_BASE_URL}/${urlPath}]`);
71
+ }
72
+ /**
73
+ * Slices `text` to at most `maxBytes` UTF-8 bytes, dropping any incomplete trailing multi-byte
74
+ * sequence so the result is always valid UTF-8.
75
+ *
76
+ * Deliberately local rather than lifted out of `src/lib/truncate.ts`: that module's slicer is
77
+ * private to a truncator with reserve-block and dangling-delimiter semantics that mean nothing
78
+ * for a docs page, and exporting it would widen this change into a module with invariants of its
79
+ * own. Six lines of duplication is the cheaper trade.
80
+ */
81
+ function sliceToBytes(text, maxBytes) {
82
+ if (maxBytes <= 0)
83
+ return '';
84
+ let out = Buffer.from(text, 'utf8').subarray(0, maxBytes).toString('utf8');
85
+ while (out.endsWith('�'))
86
+ out = out.slice(0, -1);
87
+ return out;
88
+ }
89
+ /**
90
+ * Bounds one documentation body at {@link MAX_DOC_BODY_BYTES}, announcing the cut in the bytes
91
+ * it returns. A body already under the limit is returned unchanged, byte for byte.
92
+ *
93
+ * `urlPath` is the bundle key (e.g. `guides/monitors`), used to point at the full page.
94
+ */
95
+ export function boundDocBody(body, urlPath) {
96
+ const originalBytes = Buffer.byteLength(body, 'utf8');
97
+ if (originalBytes <= MAX_DOC_BODY_BYTES)
98
+ return { body, truncated: false };
99
+ const notice = truncationNotice(originalBytes, urlPath);
100
+ const kept = sliceToBytes(body, MAX_DOC_BODY_BYTES - Buffer.byteLength(notice, 'utf8'));
101
+ return { body: kept + notice, truncated: true };
102
+ }
@@ -2,7 +2,7 @@
2
2
  "api": {
3
3
  "title": "API Reference",
4
4
  "section": "API Reference",
5
- "body": "# API Reference\n\nEvery ByteKit endpoint, request, and response.\n\nThe ByteKit REST API is organized by capability. Every endpoint shares one base\nURL and Bearer authentication — start with the [Quickstart](https://bytekit.com/docs/quickstart) and\n[Authentication](https://bytekit.com/docs/guides/authentication) guides.\n\n- [Scrape](https://bytekit.com/docs/api/scrape/createscrape) — Fetch any URL as raw HTML, clean markdown, or structured content.\n- [Screenshots](https://bytekit.com/docs/api/screenshots/createscreenshot) — Capture full-page or viewport PNG/JPEG.\n- [Bulk](https://bytekit.com/docs/api/bulk/createbulk) — Fan out many URLs in parallel with per-item webhooks.\n- [Monitors](https://bytekit.com/docs/api/monitors/createmonitor) — Watch a URL on a schedule and webhook on change.\n- [Sitemap](https://bytekit.com/docs/api/sitemap/createsitemap) — Discover URLs from a domain's sitemap or by crawling.\n- [Fetch](https://bytekit.com/docs/api/fetch/postfetch) — Low-latency raw HTTP fetch with optional conversion."
5
+ "body": "# API Reference\n\nEvery ByteKit endpoint, request, and response.\n\nThe ByteKit REST API is organized by capability. Every endpoint shares one base\nURL and Bearer authentication — start with the [Quickstart](https://bytekit.com/docs/quickstart) and\n[Authentication](https://bytekit.com/docs/guides/authentication) guides.\n\n- [Scrape](https://bytekit.com/docs/api/scrape/createscrape) — Fetch any URL as raw HTML, clean markdown, or structured content.\n- [Screenshots](https://bytekit.com/docs/api/screenshots/createscreenshot) — Capture full-page or viewport PNG/JPEG.\n- [Bulk](https://bytekit.com/docs/api/bulk/createbulk) — Fan out many URLs in parallel with per-item webhooks.\n- [Monitors](https://bytekit.com/docs/api/monitors/createmonitor) — Watch a URL on a schedule and webhook on change.\n- [Sitemap](https://bytekit.com/docs/api/sitemap/createsitemap) — Discover URLs from a domain's sitemap or by crawling.\n- [Fetch](https://bytekit.com/docs/api/fetch/postfetch) — Low-latency raw HTTP fetch with byte-for-byte upstream responses."
6
6
  },
7
7
  "api/account": {
8
8
  "title": "Account",
@@ -57,7 +57,7 @@
57
57
  "api/fetch-bulk/createfetchbulk": {
58
58
  "title": "Bulk fetch URLs",
59
59
  "section": "API Reference",
60
- "body": "# Bulk fetch URLs\n\nEnqueues multiple URLs for HTTP fetching. Results delivered via webhook.\nDoes not support options that require page rendering (cookies, wait_for_selector, etc.).\n\n**Limits:** request bodies are guarded in a two-tier shape. A streamed body\nwith no `Content-Length` header is capped at 2 MB before your API key\nis checked; a body that declares `Content-Length` is instead bounded\nthere by a 20 MB fail-safe (not the real limit — see below), since\nthat branch reads nothing until your key is verified. Once your key\nis verified, a second check re-gates the body against your account's\nown `max_bulk_size` (at this endpoint's per-item override budget),\nwhich reaches 16.8 MB for the largest documented account. A\nstandard-plan account's effective ceiling is 2 MB; either tier's\noverrun returns a `400` with error code `request_too_large`.\n"
60
+ "body": "# Bulk fetch URLs\n\nEnqueues multiple URLs for HTTP fetching. Results delivered via webhook.\nDoes not support options that require page rendering (wait_for_selector, etc.).\n\n**Limits:** request bodies are guarded in a two-tier shape. A streamed body\nwith no `Content-Length` header is capped at 2 MB before your API key\nis checked; a body that declares `Content-Length` is instead bounded\nthere by a 20 MB fail-safe (not the real limit — see below), since\nthat branch reads nothing until your key is verified. Once your key\nis verified, a second check re-gates the body against your account's\nown `max_bulk_size` (at this endpoint's per-item override budget),\nwhich reaches 16.8 MB for the largest documented account. A\nstandard-plan account's effective ceiling is 2 MB; either tier's\noverrun returns a `400` with error code `request_too_large`.\n"
61
61
  },
62
62
  "api/fetch-bulk/getfetchbulk": {
63
63
  "title": "Get fetch bulk job status",
@@ -67,7 +67,7 @@
67
67
  "api/fetch/getfetch": {
68
68
  "title": "Fetch a URL (GET)",
69
69
  "section": "API Reference",
70
- "body": "# Fetch a URL (GET)\n\nDirect HTTP fetch. The response body IS the content; metadata is returned in X-Fetch-* headers.\nOmit `format` for raw passthrough. Use `format=markdown` or `format=html` for conversion.\n"
70
+ "body": "# Fetch a URL (GET)\n\nDirect HTTP fetch. Successful responses return the upstream response bytes verbatim;\nmetadata is returned in X-Fetch-* headers. Non-2xx upstream responses use the\n`upstream_error` JSON envelope with the upstream HTTP status.\n"
71
71
  },
72
72
  "api/fetch/postfetch": {
73
73
  "title": "Fetch a URL (POST)",
@@ -137,7 +137,7 @@
137
137
  "api/schema/createschemaextraction": {
138
138
  "title": "Schema-driven structured extraction",
139
139
  "section": "API Reference",
140
- "body": "# Schema-driven structured extraction\n\nFetches `url` and extracts structured JSON conforming to the supplied\nJSON Schema (draft 2020-12) using an LLM. Fast-path only — slow-path\nrendering options (`wait_until=networkidle`, `cookies`, `delay_ms`,\ncustom `headers`, `wait_for_selector`) cause a `400 unsupported_url`.\n\nDual-axis billing: a fixed per-request credit charge **plus** the\nunderlying page's bandwidth, billed exactly like `/v1/scrape`. The\nbandwidth is still billed when the scrape succeeds but extraction later\nfails; both axes are refunded only when the scrape itself never runs.\n\nAvailability is gated by a server-side feature flag; when disabled the\nendpoint returns `404`.\n"
140
+ "body": "# Schema-driven structured extraction\n\nFetches `url` and extracts structured JSON conforming to the supplied\nJSON Schema (draft 2020-12) using an LLM. Fast-path only — slow-path\nrendering options (`wait_until=networkidle`, `delay_ms`,\n`wait_for_selector`) cause a `400 unsupported_url`.\n\nDual-axis billing: a fixed per-request credit charge **plus** the\nunderlying page's bandwidth, billed exactly like `/v1/scrape`. The\nbandwidth is still billed when the scrape succeeds but extraction later\nfails; both axes are refunded only when the scrape itself never runs.\n\nAvailability is gated by a server-side feature flag; when disabled the\nendpoint returns `404`.\n"
141
141
  },
142
142
  "api/scrape": {
143
143
  "title": "Scrape",
@@ -252,12 +252,12 @@
252
252
  "billing/bandwidth": {
253
253
  "title": "Bandwidth billing",
254
254
  "section": "General",
255
- "body": "# Bandwidth billing\n\nHow ByteKit measures billed bandwidth for capture and sitemap endpoints.\n\nByteKit bills most capture endpoints from bytes transferred over the upstream wire, not from the size of the final JSON, Markdown, image, or recording artifact. Sitemap jobs use the generated results artifact instead, as described below.\n\n## Upstream wire-byte endpoints\n\nFor scrape, fetch, crawl, and monitor requests, ByteKit applies one calculation and rounds once:\n\n```\nbilled bytes = round(upstream wire bytes × endpoint factor × cache factor × clean-Markdown factor)\n```\n\nThe endpoint factor depends on the work performed:\n\n| Endpoint | Factor |\n| --- | ---: |\n| Scrape | 1× |\n| Scrape with Markdown output | 1.5× |\n| Fetch | 1× |\n| Fetch with Markdown output | 1.5× |\n| Crawl | 1.5× |\n| Crawl links | 1× |\n| Monitor run | 1× |\n\nA cache hit contributes a **0.5×** factor. Successful clean-Markdown processing contributes a separate **3×** factor. These factors compose with the endpoint factor; they are not alternative rates.\n\n## Sitemap\n\nSitemap billing uses the byte length of the **gzip-compressed generated results CSV**. The worker builds the results CSV, compresses it, and uses that compressed length for the job's billed bytes and sitemap usage record.\n\nDiscovery fetch bytes are not accumulated into the sitemap charge. The charged byte count is the compressed results artifact, not the upstream bytes transferred while discovering URLs.\n\n## Other capture artifacts\n\nScreenshots and recordings use a separate capture basis: `phase1WireBytes × 1.5`, rounded to whole bytes. The 1.5× combines the upstream Phase 1 fetch with rendering overhead. If Phase 1 has no positive wire-byte measurement, that capture contributes zero billable bytes.\n\nYour current allowance, purchased bandwidth, rollover bandwidth, and remaining balance are shown under **Dashboard → Settings → Billing**."
255
+ "body": "# Bandwidth billing\n\nHow ByteKit measures billed bandwidth for capture and sitemap endpoints.\n\nByteKit bills most capture endpoints from bytes transferred over the upstream wire, not from the size of the final JSON, Markdown, image, or recording artifact. Sitemap jobs use the generated results artifact instead, as described below.\n\n## Upstream wire-byte endpoints\n\nFor scrape, fetch, crawl, and monitor requests, ByteKit applies one calculation and rounds once:\n\n```\nbilled bytes = round(upstream wire bytes × endpoint factor × cache factor × clean-Markdown factor)\n```\n\nThe endpoint factor depends on the work performed:\n\n| Endpoint | Factor |\n| --- | ---: |\n| Scrape | 1× |\n| Scrape with Markdown output | 1.5× |\n| Fetch | 1× |\n| Crawl | 1.5× |\n| Crawl links | 1× |\n| Monitor run | 1× |\n\nA cache hit contributes a **0.5×** factor. Successful clean-Markdown processing contributes a separate **3×** factor. These factors compose with the endpoint factor; they are not alternative rates.\n\n## Sitemap\n\nSitemap billing uses the byte length of the **gzip-compressed generated results CSV**. The worker builds the results CSV, compresses it, and uses that compressed length for the job's billed bytes and sitemap usage record.\n\nDiscovery fetch bytes are not accumulated into the sitemap charge. The charged byte count is the compressed results artifact, not the upstream bytes transferred while discovering URLs.\n\n## Other capture artifacts\n\nScreenshots and recordings use a separate capture basis: `phase1WireBytes × 1.5`, rounded to whole bytes. The 1.5× combines the upstream Phase 1 fetch with rendering overhead. If Phase 1 has no positive wire-byte measurement, that capture contributes zero billable bytes.\n\nYour current allowance, purchased bandwidth, rollover bandwidth, and remaining balance are shown under **Dashboard → Settings → Billing**."
256
256
  },
257
257
  "billing/credits": {
258
258
  "title": "Credit billing",
259
259
  "section": "General",
260
- "body": "# Credit billing\n\nHow search and schema extraction consume credits.\n\nCredits pay for operations with a per-request or per-upstream-page cost. They are tracked separately from bandwidth.\n\n## Search\n\nSearch costs one credit for every upstream results page requested:\n\n```\npages = min(ceil(limit / 10), 10)\ncredits = pages\n```\n\nFor example, a limit of 10 costs one credit, a limit of 11 costs two credits, and limits up to 100 are capped at ten upstream pages and ten credits. The charge follows the requested limit even if an upstream page returns fewer results.\n\n## Schema extraction\n\nSchema extraction is dual-axis billing. Each request has a fixed **10-credit** extraction charge and also consumes bandwidth for its source-page fetch. ByteKit pre-charges an estimated 100 KiB for that fetch, then reconciles the bandwidth charge to the actual upstream wire bytes.\n\nIf the request fails before the source page is fetched, ByteKit compensates the credit and bandwidth pre-charges. Failures after the fetch may retain the source-page bandwidth charge because that upstream work was completed.\n\nYour effective credit budget includes plan credits, purchased credits, and any live rollover credits."
260
+ "body": "# Credit billing\n\nHow search and schema extraction consume credits.\n\nCredits pay for operations with a per-request or per-upstream-page cost. They are tracked separately from bandwidth.\n\nOnly the two surfaces below are credit-billed. Scrape, fetch, screenshot, sitemap, and monitor-run requests are billed on bandwidth instead — see [Bandwidth billing](https://bytekit.com/docs/billing/bandwidth) for what those endpoints charge.\n\n## Search\n\nSearch costs one credit for every upstream results page requested:\n\n```\npages = min(ceil(limit / 10), 10)\ncredits = pages\n```\n\nFor example, a limit of 10 costs one credit, a limit of 11 costs two credits, and limits up to 100 are capped at ten upstream pages and ten credits. The charge follows the requested limit even if an upstream page returns fewer results.\n\n## Schema extraction\n\nSchema extraction is dual-axis billing. Each request has a fixed **10-credit** extraction charge and also consumes bandwidth for its source-page fetch. ByteKit pre-charges an estimated 100 KiB for that fetch, then reconciles the bandwidth charge to the actual upstream wire bytes.\n\nIf the request fails before the source page is fetched, ByteKit compensates the credit and bandwidth pre-charges. Failures after the fetch may retain the source-page bandwidth charge because that upstream work was completed.\n\nYour effective credit budget includes plan credits and purchased credits. Credits do not roll over — they reset every billing period."
261
261
  },
262
262
  "billing/spending": {
263
263
  "title": "Spending controls",
@@ -267,12 +267,12 @@
267
267
  "billing/top-ups": {
268
268
  "title": "Top-ups and rollover",
269
269
  "section": "General",
270
- "body": "# Top-ups and rollover\n\nHow purchased bandwidth and credits expire, carry across periods, and are consumed.\n\nTop-ups add bandwidth or credits without changing your plan's included allowance. The billing ledger records each purchase as its own lot and consumes eligible lots as billable work exceeds included and rollover allowances.\n\n## Expiration\n\nPurchased top-up lots expire **180 days after the payment provider object was created**. This expiry is fixed by the billing service; it is not configurable in the dashboard. Expired lots are removed from the active purchased balance and cannot fund new usage.\n\nThat source-backed rule supersedes older wording that described top-ups as never expiring or said their expiration could be configured.\n\n## Billing-period rollover\n\nMonthly plan allowances reset with the billing period. Purchased value is maintained in the billing ledger rather than being limited to the `account_usage_periods` row where the purchase first appeared; the current period's `topup_bytes` and `topup_credits` fields are projections of eligible, unexpired lot balances.\n\nCredit rollover is also live: credits present in the current period's `rollover_credits` field are included in the enforced credit budget together with included and purchased credits. Rollover is consumed before a top-up lot is charged. The presence of this budget field does not make top-up expiry configurable and does not extend a purchased lot beyond its 180-day expiry.\n\nYour current purchased and rollover balances appear under **Dashboard → Settings → Billing**."
270
+ "body": "# Top-ups and rollover\n\nHow purchased bandwidth and credits expire, carry across periods, and are consumed.\n\nTop-ups add bandwidth or credits without changing your plan's included allowance. The billing ledger records each purchase as its own lot and consumes eligible lots as billable work exceeds included and rollover allowances.\n\n## Expiration\n\nPurchased top-up lots expire **180 days after the payment provider object was created**. This expiry is fixed by the billing service; it is not configurable in the dashboard. Expired lots are removed from the active purchased balance and cannot fund new usage. If your subscription is cancelled or lapses, any purchased balance above the pay-as-you-go tier is held (not spent, not forfeited) until you resubscribe at the same tier or higher; the freeze does not pause or extend the 180-day expiry clock, so a held lot can still expire while frozen.\n\nThat source-backed rule supersedes older wording that described top-ups as never expiring or said their expiration could be configured.\n\n## Billing-period rollover\n\nUnused bandwidth from your monthly plan allowance rolls over to the next billing period, with no cap and no expiry. Purchased value is maintained separately in the billing ledger rather than being limited to the `account_usage_periods` row where the purchase first appeared; the current period's `topup_bytes` and `topup_credits` fields are projections of eligible, unexpired lot balances.\n\nCredits do not roll over — they reset every billing period. The `rollover_credits` field exists on the usage-period row and is read when computing the enforced credit budget, but it is never written non-zero today, so it has no effect in practice. This does not affect top-up expiry, which stays fixed at 180 days and is not configurable.\n\nYour current purchased and rollover balances appear under **Dashboard → Settings → Billing**."
271
271
  },
272
272
  "changelog": {
273
273
  "title": "Changelog",
274
274
  "section": "General",
275
- "body": "# Changelog\n\nRelease history for the ByteKit API and SDKs\n\n_No releases yet. Check back after the first version ships._"
275
+ "body": "# Changelog\n\nRelease history for the ByteKit SDKs, CLI, and MCP server\n\nEach section below is the `CHANGELOG.md` kept alongside that client’s source in the ByteKit\nrepository. Entries record what a release changed, including names and options it retired.\n\n## @hunt-labs/bytekit-sdk\n\nTypeScript SDK, published on npm.\n\n### [Unreleased]\n\n### [0.9.0] - 2026-08-20\n\n#### Removed\n\n- **BREAKING: the `cookies` and `headers` request-body fields are gone from every capture\n endpoint** (#3242) — `/v1/scrape`, `/v1/scrape/bulk`, `/v1/screenshots`, `/v1/recordings` and\n `/v1/schema`. A request that carries either field is rejected with `400 validation_error`; it\n is not ignored, and there is no deprecation window, feature flag, or compatibility header.\n `ScrapeOpts.cookies`, `ScrapeOpts.headers` and the exported `ScrapeCookie` type are removed\n from the SDK surface, so a call that still passes them no longer compiles.\n\n ```ts\n // before — compiled, and the values were forwarded to the target site\n await client.scrape.create({ url, cookies: [{ name: 'session', value: 'abc' }] });\n // after — does not compile; the same body over raw HTTP is a 400 validation_error\n await client.scrape.create({ url });\n ```\n\n ByteKit continues to manage its own cookie jar and request headers internally; what was removed\n is the caller's ability to inject or override them.\n\n#### Changed\n\n- **The generated types now declare the `503` response of `GET`/`POST /v1/fetch`** (#3372).\n `/v1/fetch` answers `503` on two conditions and both carry the ordinary `Error` envelope, so\n a typed consumer reading `operations['getFetch']['responses']` / `['postFetch']` can handle it\n instead of meeting an undeclared status at runtime. Read `error.code` to tell the two apart,\n because they disagree about `error.http_status`:\n - `upstream_error` — the target returned HTTP `502`, relayed at `503` because Cloudflare\n replaces a clean origin 502 with its own error page. `error.http_status` stays `502`, the\n **true upstream status**, and is the only surviving record of what the target answered.\n - `internal_error` (`Fetch service unavailable.`) — the fetch service was unreachable. There\n is no upstream, so `error.http_status` reports `503`, matching what was served.\n\n No runtime behaviour changes, and every other documented `/v1/fetch` status is unaffected.\n\n### [0.8.0] - 2026-08-19\n\n#### Removed\n\n- **BREAKING: `billing_multiplier` and `billed_bytes` are gone from the scrape success\n envelope** (#3143). Read `billing` instead — a `BillingNode` that names every factor\n applied to the charge, the multiplier they compose to, and the resulting billed bytes:\n\n ```ts\n // before\n const spend = res.billed_bytes; // flat, base-endpoint only\n // after\n const spend = res.billing?.billed_bytes;\n const why = res.billing?.factors; // [{ name: 'endpoint', value: 1.5, reason: 'scrape_md' }, …]\n ```\n\n This is a correction, not a rename: the two surfaces reported **different numbers for the\n same charge**. The flat pair carried the BASE-endpoint composition, so a markdown cache hit\n read `0.5` / `400` while the real charge — and the `X-Billing-Multiplier` header — was\n `0.75` / `600`; an html-only miss read the per-format credits estimate `1.5` / `150` against\n an endpoint factor of `1.0` / `100`. The flat pair also never carried the `clean_markdown`\n ×3 surcharge, so on a successful clean it under-reported the amount billed by two thirds.\n `billing.multiplier` composes every applied factor behind exactly one rounding, so it is the\n number that predicts your invoice.\n\n `billing` is optional and is **absent** on resources that completed before the billing node\n existed. A pre-node row omits the field rather than reporting a zero node, because a zero\n node would assert that a real past charge was zero. Test the node for presence\n (`res.billing !== undefined`, or equivalently a plain truthiness check — `billing` is an\n object or `undefined`, and an object is always truthy, so the two are the same test here).\n The hazard is a condition that reaches _into_ the node: `if (res.billing?.billed_bytes)`\n silently skips a genuine zero-byte charge, because `0` is falsy. Check that the node is\n present, then read `billed_bytes` from it.\n\n ```ts\n // wrong — a real 0-byte charge is falsy and disappears\n if (res.billing?.billed_bytes) record(res.billing.billed_bytes);\n // right — presence first, value second\n if (res.billing) record(res.billing.billed_bytes); // 0 is a charge, not an absence\n ```\n\n Two endpoints deliberately carry no node: `/v1/search` is billed per credit and reports\n `credits_used`, and a single `/v1/fetch` reports its charge through response headers only.\n The `/v1/logs` row field named `billing_multiplier` is a **different field** and is not the\n envelope field this release removed. It carries the BASE settled `credits_charged` factor,\n not the composed real-endpoint value the `X-Billing-Multiplier` header reports — a markdown\n cache hit reads `0.5` on the logs row and `0.75` on the header.\n\n#### Changed\n\n- Generated `ScrapeErrorEnvelope` types now describe terminal asynchronous `scrape.failed`\n webhook delivery (#1856). No runtime SDK behavior or API shape changed.\n\n#### Fixed\n\n- **`GET /v1/logs` entries now carry `billing_multiplier`, as a JSON number** (#3022). The\n gateway had been serializing that value under an undeclared key `credits`, and as the raw\n Postgres `NUMERIC(10,2)` string (`\"1.50\"`), while the OpenAPI spec — and therefore the\n generated types in `src/generated/api.d.ts` — declared `billing_multiplier?: number | null`.\n Anything typed against this package read `undefined` for the field.\n\n **Breaking at the wire level:** the undeclared `credits` key is gone from every `/v1/logs`\n entry. Code that reached past the generated types to read `credits` must read\n `billing_multiplier`. No SDK method exposes this endpoint, so the only change inside this\n package is the regenerated type description.\n\n- **`change_threshold` (on `monitors.create`/`monitors.list`/`monitors.get`/\n `monitors.update` responses) and `change_pct` (on `monitors.captures.list` entries)\n now serialize as JSON numbers, not strings** (#3021). Both are Postgres `NUMERIC(5,2)`\n columns; the gateway passed the raw driver string through unconverted (`\"5.00\"` /\n `\"7.25\"`) while the OpenAPI spec's _request_ schemas already declared `number` — only\n the _response_ schemas had been (incorrectly) edited to match the buggy string output.\n This release fixes the gateway serializer and corrects the two response schemas to\n `number` / `number | null`, so spec and runtime now agree.\n\n **Breaking at the wire level:** `client.monitors.create()`, `client.monitors.list()`,\n `client.monitors.get()`, and `client.monitors.update()` now return a JS number for\n `change_threshold` instead of a string (screenshot-type monitors only); the create\n response's `MonitorCreateResponse` and every other monitor route serialize through the\n same `MonitorResponse` schema, so all four are affected identically.\n `client.monitors.captures.list()` now returns a JS number for `change_pct` instead of a\n string. Code doing `parseFloat(monitor.change_threshold)` or template-literal\n interpolation keeps working; strict `typeof x === 'string'` checks or string methods\n (`.trim()`, `.padStart()`) will now throw. `change_pct` is `null` (not `0`) when there is\n no prior capture to diff against, unchanged from before. No SDK method-level shape\n changed otherwise — the only change inside this package is the regenerated type\n description.\n\n### [0.7.4] - 2026-08-19\n\n#### Changed\n\n- **`gen:version` no longer runs as part of `build`** (#3144). `scripts/gen-version.ts` writes\n `src/version.ts`, a _tracked_ source file, and it was chained into the `build` script. That made\n a build silently rewrite committed source whenever the file disagreed with the manifest: local\n runs went green on a tree CI could fail, the resulting ` M src/version.ts` was indistinguishable\n from routine build noise, and in CI the outcome depended on whether Turbo's build cache hit\n (restoring `dist/**` without re-running the generator) or missed. `build` now starts at\n `rm -rf dist ...`, so building this package touches nothing tracked. This changes `prepack` /\n `prepublishOnly` behavior too: both call `build`, so the publish path now reads the committed\n `src/version.ts` rather than regenerating it, and the committed value is what ships.\n- **New `gen:version-check` script**, `pnpm gen:version && git diff --exit-code src/version.ts`,\n mirroring the existing `gen:types-check` in the same manifest. It runs in `.woodpecker/ci.yaml`'s\n `types-drift` step, so a manifest bump without the matching `src/version.ts` regeneration now\n fails a named PR check instead of reaching `staging`. `src/__tests__/version-parity.test.ts`\n stays in place as the in-suite assertion; the gate is what makes its failure reachable before\n merge rather than after.\n\nNo runtime or type changes. `SDK_VERSION` and the `X-ByteKit-Client: sdk_ts/<version>` affix\nbehave exactly as before.\n\n### [0.7.3] - 2026-08-18\n\n#### Changed\n\n- **`XFetchContentLength`'s description no longer calls the header a wire-byte count** (#3133).\n `X-Fetch-Content-Length` is the byte length of the response body actually served: on a\n passthrough `/v1/fetch` (no `format`) that is the relayed upstream payload, so it does equal\n the upstream wire bytes — but with `format=html` or `format=markdown` the gateway overwrites\n it with the transformed document's length, which is typically far smaller than what is billed.\n The old description therefore read as a billing discrepancy on every transform request. Billing\n is unchanged and has always used the upstream compressed wire bytes reported by `X-Raw-Bytes` /\n `X-Billable-Bytes`. Generated-type comments only; no type or runtime behavior changes.\n\n### [0.7.2] - 2026-08-17\n\n#### Changed\n\n- **`ScrapeResponses.202`'s headers no longer advertise `X-Raw-Bytes`, `X-Billable-Bytes`, or\n `X-Billing-Multiplier`** (#3068). The gateway's async `/v1/scrape` path only ever emitted\n `X-Scrape-ID` and `X-Scrape-Status: queued` on a 202 — a queued scrape has no finalized byte\n charge yet — but `docs/api/openapi.yaml` documented the billing-transparency trio there too,\n so `src/generated/api.d.ts` typed three response headers the runtime never sends. This corrects\n the generated type to match the gateway's actual behavior; it does not change any runtime\n behavior. The synchronous `200` response, and `/v1/screenshots`' `202` (which does finalize a\n charge before responding), are unaffected.\n\n### [0.7.1] - 2026-08-11\n\n#### Changed\n\n- **Generated types follow the spec's corrected error and format vocabularies** (#2959). Two\n vocabulary corrections in `docs/api/openapi.yaml` flow through `src/generated/api.d.ts`:\n - `ScrapeErrorEnvelope.error.code` no longer lists `quota_exhausted`. The API has emitted\n `quota_exceeded` since #1539 and there is no throw site for `quota_exhausted` anywhere in\n the gateway, so this removes a code that has never been sent — not one that stops being\n sent. A consumer switching on it was matching a branch that could not be reached; the\n live code for an exceeded quota is `quota_exceeded`. `invalid_url`, which the API does\n emit, is unchanged and still listed.\n - `createBulk`'s `formats` now spells the raw-HTML value `raw_html`, matching `ScrapeRequest`\n and `createScrapeBulk`. `/v1/bulk` previously accepted only the internal `rawHtml`\n spelling and the spec documented that; it now accepts both, so the one endpoint that\n disagreed with the rest of the surface no longer does. `rawHtml` keeps working.\n\n#### Added\n\n- **`ByteKitError.headers` — the failing response's headers, so you can write your own backoff**\n (#2957). This SDK performs exactly one `fetch` per call and never retries, deliberately, so that\n retry policy stays the caller's. But the policy was unwritable: `ByteKitError` carried no\n headers and `requestWithResponse` returns headers only on 2xx — which a rate-limited request\n never reaches — so `Retry-After` and the `X-RateLimit-*` family were unreachable through the SDK\n at every entry point. `err.headers` closes that:\n\n ```ts\n if (err instanceof ByteKitError && err.status === 429) {\n const waitMs = Number(err.headers?.get('Retry-After') ?? 1) * 1000;\n }\n ```\n\n It is the runtime's own `Headers` object rather than a snapshot, so `get()` stays\n case-insensitive whatever casing the wire used. **Strictly additive**: it is optional and last\n on the constructor, follows the same `declare` discipline `details` uses, and an error\n constructed without one carries no `headers` key at all — `'headers' in err`, spreads and\n `JSON.stringify` are unchanged for every pre-existing construction, as are `status`, `code`,\n `message`, `details` and both 2xx return shapes. Only **response** headers are exposed;\n `Authorization` rides on the request and is never reachable through it.\n `ByteKitConnectionError` is unchanged — no response, no headers to carry.\n\n#### Fixed\n\n- **`screenshots.getWithResponse`'s docstring no longer promises headers that endpoint never\n emits** (#2957). The JSDoc — the one an IDE surfaces on hover, and the one the published SDK\n reference is generated from — claimed the documented `X-Screenshot-*` / `X-Raw-Bytes` /\n `X-Billable-Bytes` / `X-Billing-Multiplier` headers \"are on `headers`\". They are not:\n `GET /v1/screenshots/{id}` is declared with **no** `X-*` response headers, which is what\n `ByteKit.requestWithResponse`'s own doc comment and the README have said all along, and what a\n live GET confirms. Documentation only — no signature, return type or runtime behavior changed.\n `screenshots.createWithResponse` (`POST /v1/screenshots`) really does emit that family, and its\n docstring still says so.\n\n- **README documents the `signal`-vs-`timeoutMs` precedence and the `requestTimeoutMs` escape\n hatch** (#2957). Passing your own `AbortSignal` silently disables the constructor's `timeoutMs`\n — the signal becomes the request's only abort source, so a client built with `timeoutMs: 200`\n waits indefinitely if the signal never fires. That precedence was documented on\n `RequestOptions.signal` in the types, where only a reader already inspecting the option would\n meet it, and nowhere in the README. A new \"Timeouts and cancellation\" section states it with the\n full four-row precedence table and shows `requestTimeoutMs` composed alongside a caller signal\n (the request then aborts on whichever fires first). No behavior changed — the precedence is what\n it always was.\n\n- **`ScrapeWarning.code` now carries all 12 codes the server can emit** (#2948). The generated\n union in `src/generated/api.d.ts` listed 10. `low_quality_extraction` and\n `fragment_menu_stripped` — added to the server-side emitter union by #1701 — never reached\n `docs/api/openapi.yaml`, so every regeneration since faithfully reproduced the gap and the\n exported type was non-exhaustive: a `switch` over `warning.code` that TypeScript proved\n exhaustive would silently fall through on a warning the API really returns. Widening the spec\n and regenerating fixes the type; no runtime code changed. The other 10 codes are unaffected.\n\n- **Gateway wire-type correction: `billing_multiplier` is a JSON number on `scrape.get()` again**\n (#2954). `GET /v1/scrape/{id}` (and `GET /v1/scrape/bulk/{id}` items) were serializing\n `billing_multiplier` as a JSON string (e.g. `\"0.50\"`) instead of a number — the pg driver\n returns the underlying `NUMERIC(10,2)` column as a string, and the gateway's GET serializer\n passed it through unconverted, while `POST /v1/scrape`'s create-path value (computed in JS) was\n already correct. Fixed upstream in the gateway; this SDK required no code change, only removal\n of the `KNOWN DRIFT (#2426)` JSDoc on `ScrapeResource.get()` that documented the workaround —\n the static `number` type this\n\n---\n[Truncated to the 16384-byte per-page limit — this page is 141845 bytes in full. The text cut here is not searchable either: search_docs matches only the part kept above. Read all of it at https://bytekit.com/docs/changelog]"
276
276
  },
277
277
  "cli": {
278
278
  "title": "Install & Authenticate",
@@ -292,7 +292,7 @@
292
292
  "cli/fetch": {
293
293
  "title": "Fetch",
294
294
  "section": "CLI Reference",
295
- "body": "# Fetch\n\nFetch URL content operations\n\nFetch URL content operations\n\n### fetch › bulk\n\nBulk fetch operations\n\n| Option | Description |\n| --- | --- |\n| `-h, --help` | display help for command |\n\n#### fetch › bulk › create\n\nCreate a bulk fetch job\n\n| Option | Description |\n| --- | --- |\n| `--file <path>` | Path to a newline-delimited file. Each line is a plain URL, or a JSON object carrying \"url\" plus per-item config. A line whose only key is \"url\" behaves exactly as before (sent as a bare URL string); any line with additional keys switches the payload to the per-item shape. |\n| `--webhook-url <url>` | HTTPS webhook URL notified when the job completes |\n| `--webhook-secret <secret>` | HMAC secret used to sign the completion webhook (omitted → unsigned) |\n| `--defaults <json>` | Defaults applied to every entry, as a JSON object (omitted → none). Unknown keys are rejected by /v1/bulk (422) and ignored by scrape bulk / fetch bulk; fetch bulk additionally rejects browser-only keys (cookies, wait_until, wait_for_selector, delay_ms) with a 400. |\n| `--metadata <json>` | Arbitrary metadata echoed on the job envelope, as a JSON object, e.g. '\\{\"run\":\"7\"\\}' (omitted → none) |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit fetch bulk create --file <path> --webhook-url <url> --webhook-secret <secret> --defaults <json> --metadata <json>\n```\n\n#### fetch › bulk › get\n\nGet a bulk fetch job\n\n| Option | Description |\n| --- | --- |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit fetch bulk get <id>\n```\n\n### fetch › create\n\nFetch URL content (POST)\n\n| Option | Description |\n| --- | --- |\n| `--url <url>` | URL to fetch |\n| `--format <format>` | Response format (markdown or html) |\n| `--country <cc>` | Two-letter country code to route the request through (e.g. us, de) |\n| `--timeout-ms <n>` | Per-request timeout in milliseconds |\n| `--cache-ttl <ttl>` | Cache freshness: 0, Nh (hours), or Nd (days), e.g. 48h, 2d, 0 (omitted → server default) |\n| `--markdown-mode <mode>` | Markdown mode: article, raw, llm |\n| `--markdown-query <q>` | BM25 query string for relevance-ranked markdown filtering (omitted → disabled) |\n| `--markdown-links <mode>` | Link rendering: inline, references, none, text (omitted → server default) |\n| `--markdown-images <mode>` | Image retention: inline, references, none, text (omitted → server default) |\n| `--with-links-summary` | Append a Links footer to the markdown output (omitted → off) |\n| `--with-images-summary` | Append an Images footer to the markdown output (omitted → off) |\n| `--markdown-compact` | Collapse excessive whitespace in the markdown output (omitted → off) |\n| `--markdown-filter-images` | Filter low-signal images from the markdown output (omitted → off) |\n| `--markdown-include-media` | Return rich link/image objects and a tables array (omitted → off) |\n| `--markdown-include-warnings` | Include markdown-pipeline and tag-filter warnings (omitted → off) |\n| `--markdown-include-stats` | Include a top-level stats object (chars, tokens, blocks) (omitted → off) |\n| `--custom <json>` | User payload echoed on the envelope as a JSON object, e.g. '\\{\"job\":\"1\"\\}' (omitted → none) |\n| `-o, --output <file>` | Write the fetched body bytes to the given file path |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit fetch create --url <url> --format <format> --country <cc> --timeout-ms <n> --cache-ttl <ttl> --markdown-mode <mode> --markdown-query <q> --markdown-links <mode> --markdown-images <mode> --with-links-summary --with-images-summary --markdown-compact --markdown-filter-images --markdown-include-media --markdown-include-warnings --markdown-include-stats --custom <json>\n```\n\n### fetch › get\n\nFetch URL content (GET via query params)\n\n| Option | Description |\n| --- | --- |\n| `--url <url>` | URL to fetch |\n| `--format <format>` | Response format (markdown or html) |\n| `--country <cc>` | Two-letter country code to route the request through (e.g. us, de) |\n| `--timeout-ms <n>` | Per-request timeout in milliseconds |\n| `--cache-ttl <ttl>` | Cache freshness: 0, Nh (hours), or Nd (days), e.g. 48h, 2d, 0 (omitted → server default) |\n| `-o, --output <file>` | Write the fetched body bytes to the given file path |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit fetch get --url <url> --format <format> --country <cc> --timeout-ms <n> --cache-ttl <ttl>\n```"
295
+ "body": "# Fetch\n\nFetch URL content operations\n\nFetch URL content operations\n\n### fetch › bulk\n\nBulk fetch operations\n\n| Option | Description |\n| --- | --- |\n| `-h, --help` | display help for command |\n\n#### fetch › bulk › create\n\nCreate a bulk fetch job\n\n| Option | Description |\n| --- | --- |\n| `--file <path>` | Path to a newline-delimited file. Each line is a plain URL, or a JSON object carrying \"url\" plus per-item config. A line whose only key is \"url\" behaves exactly as before (sent as a bare URL string); any line with additional keys switches the payload to the per-item shape. |\n| `--webhook-url <url>` | HTTPS webhook URL notified when the job completes |\n| `--webhook-secret <secret>` | HMAC secret used to sign the completion webhook (omitted → unsigned) |\n| `--defaults <json>` | Defaults applied to every entry, as a JSON object (omitted → none). Unknown keys are rejected by /v1/bulk (422) and ignored by scrape bulk / fetch bulk; fetch bulk additionally rejects browser-only keys (cookies, wait_until, wait_for_selector, delay_ms) with a 400. |\n| `--metadata <json>` | Arbitrary metadata echoed on the job envelope, as a JSON object, e.g. '\\{\"run\":\"7\"\\}' (omitted → none) |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit fetch bulk create --file <path> --webhook-url <url> --webhook-secret <secret> --defaults <json> --metadata <json>\n```\n\n#### fetch › bulk › get\n\nGet a bulk fetch job\n\n| Option | Description |\n| --- | --- |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit fetch bulk get <id>\n```\n\n### fetch › create\n\nFetch URL content (POST)\n\n| Option | Description |\n| --- | --- |\n| `--url <url>` | URL to fetch |\n| `--country <cc>` | Two-letter country code to route the request through (e.g. us, de) |\n| `--timeout-ms <n>` | Per-request timeout in milliseconds |\n| `--cache-ttl <ttl>` | Cache freshness: 0, Nh (hours), or Nd (days), e.g. 48h, 2d, 0 (omitted → server default) |\n| `--custom <json>` | User payload echoed on the envelope as a JSON object, e.g. '\\{\"job\":\"1\"\\}' (omitted → none) |\n| `-o, --output <file>` | Write the fetched body bytes to the given file path |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit fetch create --url <url> --country <cc> --timeout-ms <n> --cache-ttl <ttl> --custom <json>\n```\n\n### fetch › get\n\nFetch URL content (GET via query params)\n\n| Option | Description |\n| --- | --- |\n| `--url <url>` | URL to fetch |\n| `--country <cc>` | Two-letter country code to route the request through (e.g. us, de) |\n| `--timeout-ms <n>` | Per-request timeout in milliseconds |\n| `--cache-ttl <ttl>` | Cache freshness: 0, Nh (hours), or Nd (days), e.g. 48h, 2d, 0 (omitted → server default) |\n| `-o, --output <file>` | Write the fetched body bytes to the given file path |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit fetch get --url <url> --country <cc> --timeout-ms <n> --cache-ttl <ttl>\n```"
296
296
  },
297
297
  "cli/monitors": {
298
298
  "title": "Monitors",
@@ -302,12 +302,12 @@
302
302
  "cli/scrape": {
303
303
  "title": "Scrape",
304
304
  "section": "CLI Reference",
305
- "body": "# Scrape\n\nScrape URL content\n\nScrape URL content\n\n### scrape › bulk\n\nBulk scrape operations\n\n| Option | Description |\n| --- | --- |\n| `-h, --help` | display help for command |\n\n#### scrape › bulk › create\n\nCreate a bulk scrape job\n\n| Option | Description |\n| --- | --- |\n| `--file <path>` | Path to a newline-delimited file. Each line is a plain URL, or a JSON object carrying \"url\" plus per-item config. A line whose only key is \"url\" behaves exactly as before (sent as a bare URL string); any line with additional keys switches the payload to the per-item shape. |\n| `--webhook-url <url>` | HTTPS webhook URL notified when the job completes |\n| `--webhook-secret <secret>` | HMAC secret used to sign the completion webhook (omitted → unsigned) |\n| `--defaults <json>` | Defaults applied to every entry, as a JSON object (omitted → none). Unknown keys are rejected by /v1/bulk (422) and ignored by scrape bulk / fetch bulk; fetch bulk additionally rejects browser-only keys (cookies, wait_until, wait_for_selector, delay_ms) with a 400. |\n| `--metadata <json>` | Arbitrary metadata echoed on the job envelope, as a JSON object, e.g. '\\{\"run\":\"7\"\\}' (omitted → none) |\n| `--custom <json>` | User payload echoed on every scrape entry, as a JSON object, e.g. '\\{\"job\":\"1\"\\}' (omitted → none; a per-entry value in --file wins) |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit scrape bulk create --file <path> --webhook-url <url> --webhook-secret <secret> --defaults <json> --metadata <json> --custom <json>\n```\n\n#### scrape › bulk › get\n\nGet a bulk scrape job\n\n| Option | Description |\n| --- | --- |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit scrape bulk get <id>\n```\n\n### scrape › create\n\nCreate a scrape job\n\n| Option | Description |\n| --- | --- |\n| `--url <url>` | URL to scrape |\n| `--format <format>` | Output format; repeat or comma-separate for multiple (e.g. --format raw_html --format markdown, or --format raw_html,markdown). Sent as the formats array; omitted → server default. |\n| `--country <cc>` | Two-letter country code to route the request through (e.g. us, de) |\n| `--timeout-ms <n>` | Per-request timeout in milliseconds |\n| `--markdown-mode <mode>` | Markdown extraction mode: article, raw, llm |\n| `--markdown-query <q>` | BM25 query string for relevance-ranked markdown filtering (omitted → disabled) |\n| `--cache-ttl <ttl>` | Cache freshness: 0, Nh (hours), or Nd (days), e.g. 48h, 2d, 0 (omitted → server default) |\n| `--cookies <json>` | Cookies as a JSON array, e.g. '[\\{\"name\":\"a\",\"value\":\"b\"\\}]' (omitted → none) |\n| `--headers <json>` | Extra request headers as a JSON object, e.g. '\\{\"X-A\":\"b\"\\}' (omitted → none) |\n| `--delay-ms <n>` | Post-load delay in milliseconds before capture |\n| `--events <csv>` | Webhook events (comma-separated): queued, completed, failed (omitted → server default) |\n| `--token-encoding <enc>` | Tokenizer for --token-budget: cl100k_base, o200k_base (omitted → server default) |\n| `--custom <json>` | User payload echoed on the envelope as a JSON object, e.g. '\\{\"job\":\"1\"\\}' (omitted → none) |\n| `--remove-base64-images` | Strip base64 data: images before conversion (server default) |\n| `--no-remove-base64-images` | Preserve base64 data: images in the pipeline output |\n| `--markdown-links <mode>` | Link rendering: inline, references, none, text |\n| `--markdown-images <mode>` | Image retention: inline, references, none, text |\n| `--with-links-summary` | Append a Links footer to the markdown output |\n| `--with-images-summary` | Append an Images footer to the markdown output |\n| `--markdown-compact` | Collapse excessive whitespace in the markdown output |\n| `--markdown-filter-images` | Filter low-signal images from the markdown output |\n| `--markdown-include-media` | Return rich link/image objects and a tables array |\n| `--markdown-include-warnings` | Include markdown-pipeline and tag-filter warnings |\n| `--markdown-include-stats` | Include a top-level stats object (chars, tokens, blocks) |\n| `--async` | Queue the scrape and return a job envelope immediately (no wait) |\n| `--webhook-url <url>` | HTTPS webhook URL notified when an async scrape completes |\n| `--token-budget <n>` | Maximum tokens of markdown to return |\n| `--clean-markdown` | Post-process markdown with the LLM cleaner (billed 3x) |\n| `--include-tags <csv>` | Comma-separated HTML tags to keep (e.g. article,main) |\n| `--exclude-tags <csv>` | Comma-separated HTML tags to drop (e.g. nav,footer) |\n| `--mobile` | Render with a mobile viewport/user-agent |\n| `--raw` | Print the requested format body raw, with no JSON wrapper |\n| `-o, --output <file>` | Write the output to the given file path (implies --raw unless --json is set) |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit scrape create --url <url> --format <format> --country <cc> --timeout-ms <n> --markdown-mode <mode> --markdown-query <q> --cache-ttl <ttl> --cookies <json> --headers <json> --delay-ms <n> --events <csv> --token-encoding <enc> --custom <json> --remove-base64-images --no-remove-base64-images --markdown-links <mode> --markdown-images <mode> --with-links-summary --with-images-summary --markdown-compact --markdown-filter-images --markdown-include-media --markdown-include-warnings --markdown-include-stats --async --webhook-url <url> --token-budget <n> --clean-markdown --include-tags <csv> --exclude-tags <csv> --mobile --raw\n```\n\n### scrape › get\n\nGet a scrape job by ID (use --raw/-o/--format to retrieve a completed body)\n\n| Option | Description |\n| --- | --- |\n| `--raw` | Print the requested format body raw, with no JSON wrapper |\n| `-o, --output <file>` | Write the output to the given file path (implies --raw unless --json is set) |\n| `--format <format>` | Which persisted format to emit — only takes effect with --raw/-o; ignored otherwise |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit scrape get <id> --raw --format <format>\n```"
305
+ "body": "# Scrape\n\nScrape URL content\n\nScrape URL content\n\n### scrape › bulk\n\nBulk scrape operations\n\n| Option | Description |\n| --- | --- |\n| `-h, --help` | display help for command |\n\n#### scrape › bulk › create\n\nCreate a bulk scrape job\n\n| Option | Description |\n| --- | --- |\n| `--file <path>` | Path to a newline-delimited file. Each line is a plain URL, or a JSON object carrying \"url\" plus per-item config. A line whose only key is \"url\" behaves exactly as before (sent as a bare URL string); any line with additional keys switches the payload to the per-item shape. |\n| `--webhook-url <url>` | HTTPS webhook URL notified when the job completes |\n| `--webhook-secret <secret>` | HMAC secret used to sign the completion webhook (omitted → unsigned) |\n| `--defaults <json>` | Defaults applied to every entry, as a JSON object (omitted → none). Unknown keys are rejected by /v1/bulk (422) and ignored by scrape bulk / fetch bulk; fetch bulk additionally rejects browser-only keys (wait_until, wait_for_selector, delay_ms) with a 400. `cookies` and `headers` are no longer accepted by any capture endpoint and 400 (#3242). |\n| `--metadata <json>` | Arbitrary metadata echoed on the job envelope, as a JSON object, e.g. '\\{\"run\":\"7\"\\}' (omitted → none) |\n| `--custom <json>` | User payload echoed on every scrape entry, as a JSON object, e.g. '\\{\"job\":\"1\"\\}' (omitted → none; a per-entry value in --file wins) |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit scrape bulk create --file <path> --webhook-url <url> --webhook-secret <secret> --defaults <json> --metadata <json> --custom <json>\n```\n\n#### scrape › bulk › get\n\nGet a bulk scrape job\n\n| Option | Description |\n| --- | --- |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit scrape bulk get <id>\n```\n\n### scrape › create\n\nCreate a scrape job\n\n| Option | Description |\n| --- | --- |\n| `--url <url>` | URL to scrape |\n| `--format <format>` | Output format; repeat or comma-separate for multiple (e.g. --format raw_html --format markdown, or --format raw_html,markdown). Sent as the formats array; omitted → server default. |\n| `--country <cc>` | Two-letter country code to route the request through (e.g. us, de) |\n| `--timeout-ms <n>` | Per-request timeout in milliseconds |\n| `--markdown-mode <mode>` | Markdown extraction mode: article, raw, llm |\n| `--markdown-query <q>` | BM25 query string for relevance-ranked markdown filtering (omitted → disabled) |\n| `--cache-ttl <ttl>` | Cache freshness: 0, Nh (hours), or Nd (days), e.g. 48h, 2d, 0 (omitted → server default) |\n| `--delay-ms <n>` | Post-load delay in milliseconds before capture |\n| `--events <csv>` | Webhook events (comma-separated): queued, completed, failed (omitted → server default) |\n| `--token-encoding <enc>` | Tokenizer for --token-budget: cl100k_base, o200k_base (omitted → server default) |\n| `--custom <json>` | User payload echoed on the envelope as a JSON object, e.g. '\\{\"job\":\"1\"\\}' (omitted → none) |\n| `--remove-base64-images` | Strip base64 data: images before conversion (server default) |\n| `--no-remove-base64-images` | Preserve base64 data: images in the pipeline output |\n| `--markdown-links <mode>` | Link rendering: inline, references, none, text |\n| `--markdown-images <mode>` | Image retention: inline, references, none, text |\n| `--with-links-summary` | Append a Links footer to the markdown output |\n| `--with-images-summary` | Append an Images footer to the markdown output |\n| `--markdown-compact` | Collapse excessive whitespace in the markdown output |\n| `--markdown-filter-images` | Filter low-signal images from the markdown output |\n| `--markdown-include-media` | Return rich link/image objects and a tables array |\n| `--markdown-include-warnings` | Include markdown-pipeline and tag-filter warnings |\n| `--markdown-include-stats` | Include a top-level stats object (chars, tokens, blocks) |\n| `--async` | Queue the scrape and return a job envelope immediately (no wait) |\n| `--webhook-url <url>` | HTTPS webhook URL notified when an async scrape completes |\n| `--token-budget <n>` | Maximum tokens of markdown to return |\n| `--clean-markdown` | Post-process markdown with the LLM cleaner (billed 3x) |\n| `--include-tags <csv>` | Comma-separated HTML tags to keep (e.g. article,main) |\n| `--exclude-tags <csv>` | Comma-separated HTML tags to drop (e.g. nav,footer) |\n| `--mobile` | Render with a mobile viewport/user-agent |\n| `--raw` | Print the requested format body raw, with no JSON wrapper |\n| `-o, --output <file>` | Write the output to the given file path (implies --raw unless --json is set) |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit scrape create --url <url> --format <format> --country <cc> --timeout-ms <n> --markdown-mode <mode> --markdown-query <q> --cache-ttl <ttl> --delay-ms <n> --events <csv> --token-encoding <enc> --custom <json> --remove-base64-images --no-remove-base64-images --markdown-links <mode> --markdown-images <mode> --with-links-summary --with-images-summary --markdown-compact --markdown-filter-images --markdown-include-media --markdown-include-warnings --markdown-include-stats --async --webhook-url <url> --token-budget <n> --clean-markdown --include-tags <csv> --exclude-tags <csv> --mobile --raw\n```\n\n### scrape › get\n\nGet a scrape job by ID (use --raw/-o/--format to retrieve a completed body)\n\n| Option | Description |\n| --- | --- |\n| `--raw` | Print the requested format body raw, with no JSON wrapper |\n| `-o, --output <file>` | Write the output to the given file path (implies --raw unless --json is set) |\n| `--format <format>` | Which persisted format to emit — only takes effect with --raw/-o; ignored otherwise |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit scrape get <id> --raw --format <format>\n```"
306
306
  },
307
307
  "cli/screenshots": {
308
308
  "title": "Screenshots",
309
309
  "section": "CLI Reference",
310
- "body": "# Screenshots\n\nScreenshot operations\n\nScreenshot operations\n\n### screenshots › create\n\nCapture a screenshot\n\n| Option | Description |\n| --- | --- |\n| `--url <url>` | URL to screenshot |\n| `--full-page` | Capture the full page (default: viewport only) |\n| `--device <device>` | Device profile: desktop, mobile |\n| `--viewport <WxH>` | Viewport size WIDTHxHEIGHT (e.g. 1280x720) |\n| `--format <format>` | Image format: jpeg, png |\n| `--quality <n>` | JPEG quality (1-100) |\n| `--wait-until <event>` | Wait condition: load, domcontentloaded, networkidle |\n| `--clip <x,y,w,h>` | Clip region X,Y,WIDTH,HEIGHT (e.g. 0,0,800,600) |\n| `--block-ads` | Block ads before capture (server default) |\n| `--no-block-ads` | Do not block ads |\n| `--block-cookie-banners` | Block cookie-consent banners before capture (server default) |\n| `--no-block-cookie-banners` | Do not block cookie-consent banners |\n| `--scroll` | Scroll the page before capture to trigger lazy content (server default) |\n| `--no-scroll` | Do not scroll the page before capture |\n| `--wait-for-selector <sel>` | Wait until this CSS selector is present before capture |\n| `--delay-ms <n>` | Post-load delay in milliseconds before capture |\n| `--dark-mode` | Emulate prefers-color-scheme: dark |\n| `--device-scale-factor <n>` | Device pixel ratio: 1, 2 |\n| `--include-html` | Include the rendered HTML alongside the screenshot |\n| `--country <cc>` | Two-letter country code to route the request through (e.g. us, de) |\n| `--language <lang>` | Accept-Language override (e.g. en-US) |\n| `--headers <json>` | Extra request headers as a JSON object, e.g. '\\{\"X-A\":\"b\"\\}' (omitted → none) |\n| `--cookies <json>` | Cookies as a JSON array of \\{name,value,domain\\}, e.g. '[\\{\"name\":\"a\",\"value\":\"b\",\"domain\":\"example.com\"\\}]' (omitted → none) |\n| `--metadata <json>` | Arbitrary metadata echoed on the screenshot envelope, as a JSON object, e.g. '\\{\"run\":\"7\"\\}' (omitted → none) |\n| `--async` | Queue the screenshot and return a job envelope immediately (no wait) |\n| `-o, --output <file>` | Download the captured image to this file path (use - for stdout). Not valid with --json. |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit screenshots create --url <url> --full-page --device <device> --viewport <WxH> --format <format> --quality <n> --wait-until <event> --clip <x,y,w,h> --block-ads --no-block-ads --block-cookie-banners --no-block-cookie-banners --scroll --no-scroll --wait-for-selector <sel> --delay-ms <n> --dark-mode --device-scale-factor <n> --include-html --country <cc> --language <lang> --headers <json> --cookies <json> --metadata <json> --async\n```\n\n### screenshots › get\n\nGet a screenshot by ID\n\n| Option | Description |\n| --- | --- |\n| `-o, --output <file>` | Download the captured image to this file path (use - for stdout). Not valid with --json. |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit screenshots get <id>\n```"
310
+ "body": "# Screenshots\n\nScreenshot operations\n\nScreenshot operations\n\n### screenshots › create\n\nCapture a screenshot\n\n| Option | Description |\n| --- | --- |\n| `--url <url>` | URL to screenshot |\n| `--full-page` | Capture the full page (default: viewport only) |\n| `--device <device>` | Device profile: desktop, mobile |\n| `--viewport <WxH>` | Viewport size WIDTHxHEIGHT (e.g. 1280x720) |\n| `--format <format>` | Image format: jpeg, png |\n| `--quality <n>` | JPEG quality (1-100) |\n| `--wait-until <event>` | Wait condition: load, domcontentloaded, networkidle |\n| `--clip <x,y,w,h>` | Clip region X,Y,WIDTH,HEIGHT (e.g. 0,0,800,600) |\n| `--block-ads` | Block ads before capture (server default) |\n| `--no-block-ads` | Do not block ads |\n| `--block-cookie-banners` | Block cookie-consent banners before capture (server default) |\n| `--no-block-cookie-banners` | Do not block cookie-consent banners |\n| `--scroll` | Scroll the page before capture to trigger lazy content (server default) |\n| `--no-scroll` | Do not scroll the page before capture |\n| `--wait-for-selector <sel>` | Wait until this CSS selector is present before capture |\n| `--delay-ms <n>` | Post-load delay in milliseconds before capture |\n| `--dark-mode` | Emulate prefers-color-scheme: dark |\n| `--device-scale-factor <n>` | Device pixel ratio: 1, 2 |\n| `--include-html` | Include the rendered HTML alongside the screenshot |\n| `--country <cc>` | Two-letter country code to route the request through (e.g. us, de) |\n| `--language <lang>` | Accept-Language override (e.g. en-US) |\n| `--metadata <json>` | Arbitrary metadata echoed on the screenshot envelope, as a JSON object, e.g. '\\{\"run\":\"7\"\\}' (omitted → none) |\n| `--async` | Queue the screenshot and return a job envelope immediately (no wait) |\n| `-o, --output <file>` | Download the captured image to this file path (use - for stdout). Not valid with --json. |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit screenshots create --url <url> --full-page --device <device> --viewport <WxH> --format <format> --quality <n> --wait-until <event> --clip <x,y,w,h> --block-ads --no-block-ads --block-cookie-banners --no-block-cookie-banners --scroll --no-scroll --wait-for-selector <sel> --delay-ms <n> --dark-mode --device-scale-factor <n> --include-html --country <cc> --language <lang> --metadata <json> --async\n```\n\n### screenshots › get\n\nGet a screenshot by ID\n\n| Option | Description |\n| --- | --- |\n| `-o, --output <file>` | Download the captured image to this file path (use - for stdout). Not valid with --json. |\n| `-h, --help` | display help for command |\n\n```bash\n$ bytekit screenshots get <id>\n```"
311
311
  },
312
312
  "cli/search": {
313
313
  "title": "Search",
@@ -352,7 +352,7 @@
352
352
  "guides/scraping": {
353
353
  "title": "Scraping",
354
354
  "section": "Guides",
355
- "body": "# Scraping\n\nScrape any URL as HTML, markdown, or structured content — formats, options, latency, and async polling.\n\n`POST /v1/scrape` fetches a URL and returns its content in the format you ask for. The same\nrequest shape works for every site; the options you pass determine the output and how long the\ncall takes.\n\n## Rendering & latency\n\nMost scrapes return in well under a second. Some options require ByteKit to fully render the page\nbefore it can return content, which takes longer — typically a few seconds. Pass these only when\nyou need them:\n\n| Option | When it adds latency |\n|--------|----------------------|\n| `cookies` | Non-empty array |\n| `headers` | Non-empty object |\n| `delay_ms` | Greater than `0` |\n| `async` | `true` (request is queued and processed off the fast path) |\n\nThe `country` option routes the request through a geo-located proxy. On its own it does not add\nrendering latency; it only does so when combined with one of the options above.\n\nLooking for `wait_for_selector` or `wait_until`? Those are not `ScrapeRequest` options — they\nbelong to the [Screenshot](https://bytekit.com/docs/api/screenshots/createscreenshot) endpoint. Sending them to\n`/v1/scrape` returns `422`.\n\n```bash\n# A simple, low-latency scrape\ncurl -X POST https://api.bytekit.com/v1/scrape \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://example.com\"}'\n```\n\n```bash\n# Slower: delay_ms forces a full render and waits before returning\ncurl -X POST https://api.bytekit.com/v1/scrape \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"url\": \"https://example.com\",\n \"delay_ms\": 2000\n }'\n```\n\n## Response fields\n\nThe default format is `raw_html` — pass `formats` to request others (`markdown`, `html`,\n`links`, `images`). The `formats` object in the response is keyed by the format you requested.\n\n| Field | Description |\n|-------|-------------|\n| `formats.raw_html` | Page content in the requested format (`raw_html` is the default when `formats` is omitted) |\n| `contentLength` | Compressed wire bytes — used for bandwidth billing |\n| `statusCode` | HTTP status code of the origin page |\n| `metadata.title` | Page `<title>` element |\n\nThe `X-Scrape-*` response headers describe how each request was handled (cache status, timing,\nand the final URL) — useful for debugging.\n\n## Async scrapes\n\nFor long-running pages, pass `\"async\": true` to get a `202 Accepted` response with a scrape\n`id` prefixed `sc_`. Poll the result with `GET /v1/scrape/{id}`.\n\n```bash\n# Start async scrape\ncurl -X POST https://api.bytekit.com/v1/scrape \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://example.com\", \"async\": true}'\n\n# Poll for result\ncurl https://api.bytekit.com/v1/scrape/sc_... \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\"\n```\n\n## Webhook event header\n\nEvery outbound webhook POST includes an `X-ByteKit-Event` header with the event type:\n\n| Event type | Trigger |\n|---|---|\n| `bulk.completed` | A bulk job finishes (all items processed) |\n| `scrape.completed` | An async scrape succeeds |\n| `scrape.failed` | An async scrape fails terminally |\n| `monitor.change_detected` | A monitor fires and detects a change (screenshot or content) |\n| `monitor.captured` | A monitor fires with no change detected (notify_on: every) |\n| `sitemap.completed` | A sitemap job finishes |\n| `sitemap.failed` | A sitemap job fails terminally |\n\nUse this header to dispatch events without inspecting the body shape:\n\n```python\nfrom flask import Flask, request\n\napp = Flask(__name__)\n\n@app.route(\"/webhooks/bytekit\", methods=[\"POST\"])\ndef handle():\n event = request.headers.get(\"X-ByteKit-Event\")\n if event == \"bulk.completed\":\n handle_bulk(request.json)\n elif event == \"scrape.completed\":\n handle_scrape(request.json)\n return \"\", 200\n```\n\n`X-ByteKit-Event` is a reserved header — you cannot supply it via `webhook_headers` in\nmonitor or bulk configuration. Attempts to do so will be rejected with a `422` at request\ntime.\n\n## Next steps\n\n- [Rate Limits](https://bytekit.com/docs/guides/rate-limits) — quota model and concurrency slots\n- [Errors](https://bytekit.com/docs/guides/errors) — how to interpret and retry error responses\n- [API Reference: Scrape](https://bytekit.com/docs/api/scrape/createscrape) — full request/response schema"
355
+ "body": "# Scraping\n\nScrape any URL as HTML, markdown, or structured content — formats, options, latency, and async polling.\n\n`POST /v1/scrape` fetches a URL and returns its content in the format you ask for. The same\nrequest shape works for every site; the options you pass determine the output and how long the\ncall takes.\n\n## Rendering & latency\n\nMost scrapes return in well under a second. Some options require ByteKit to fully render the page\nbefore it can return content, which takes longer — typically a few seconds. Pass these only when\nyou need them:\n\n| Option | When it adds latency |\n|--------|----------------------|\n| `delay_ms` | Greater than `0` |\n| `async` | `true` (request is queued and processed off the fast path) |\n\nThe `country` option routes the request through a geo-located proxy. On its own it does not add\nrendering latency; it only does so when combined with one of the options above.\n\nLooking for `wait_for_selector` or `wait_until`? Those are not `ScrapeRequest` options — they\nbelong to the [Screenshot](https://bytekit.com/docs/api/screenshots/createscreenshot) endpoint. Sending them to\n`/v1/scrape` returns `422`.\n\n`cookies` and `headers` are no longer request options on any capture endpoint. Sending either\nreturns `400 validation_error`.\n\n```bash\n# A simple, low-latency scrape\ncurl -X POST https://api.bytekit.com/v1/scrape \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://example.com\"}'\n```\n\n```bash\n# Slower: delay_ms forces a full render and waits before returning\ncurl -X POST https://api.bytekit.com/v1/scrape \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"url\": \"https://example.com\",\n \"delay_ms\": 2000\n }'\n```\n\n## Response fields\n\nThe default format is `raw_html` — pass `formats` to request others (`markdown`, `html`,\n`links`, `images`). The `formats` object in the response is keyed by the format you requested.\n\n| Field | Description |\n|-------|-------------|\n| `formats.raw_html` | Page content in the requested format (`raw_html` is the default when `formats` is omitted) |\n| `contentLength` | Compressed wire bytes — used for bandwidth billing |\n| `statusCode` | HTTP status code of the origin page |\n| `metadata.title` | Page `<title>` element |\n\nThe `X-Scrape-*` response headers describe how each request was handled (cache status, timing,\nand the final URL) — useful for debugging.\n\n## Async scrapes\n\nFor long-running pages, pass `\"async\": true` to get a `202 Accepted` response with a scrape\n`id` prefixed `sc_`. Poll the result with `GET /v1/scrape/{id}`.\n\n```bash\n# Start async scrape\ncurl -X POST https://api.bytekit.com/v1/scrape \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"url\": \"https://example.com\", \"async\": true}'\n\n# Poll for result\ncurl https://api.bytekit.com/v1/scrape/sc_... \\\n -H \"Authorization: Bearer sk_live_YOUR_KEY_HERE\"\n```\n\n## Webhook event header\n\nEvery outbound webhook POST includes an `X-ByteKit-Event` header with the event type:\n\n| Event type | Trigger |\n|---|---|\n| `bulk.completed` | A bulk job finishes (all items processed) |\n| `scrape.completed` | An async scrape succeeds |\n| `scrape.failed` | An async scrape fails terminally |\n| `monitor.change_detected` | A monitor fires and detects a change (screenshot or content) |\n| `monitor.captured` | A monitor fires with no change detected (notify_on: every) |\n| `sitemap.completed` | A sitemap job finishes |\n| `sitemap.failed` | A sitemap job fails terminally |\n\nUse this header to dispatch events without inspecting the body shape:\n\n```python\nfrom flask import Flask, request\n\napp = Flask(__name__)\n\n@app.route(\"/webhooks/bytekit\", methods=[\"POST\"])\ndef handle():\n event = request.headers.get(\"X-ByteKit-Event\")\n if event == \"bulk.completed\":\n handle_bulk(request.json)\n elif event == \"scrape.completed\":\n handle_scrape(request.json)\n return \"\", 200\n```\n\n`X-ByteKit-Event` is a reserved header — you cannot supply it via `webhook_headers` in\nmonitor or bulk configuration. Attempts to do so will be rejected with a `422` at request\ntime.\n\n## Next steps\n\n- [Rate Limits](https://bytekit.com/docs/guides/rate-limits) — quota model and concurrency slots\n- [Errors](https://bytekit.com/docs/guides/errors) — how to interpret and retry error responses\n- [API Reference: Scrape](https://bytekit.com/docs/api/scrape/createscrape) — full request/response schema"
356
356
  },
357
357
  "introduction": {
358
358
  "title": "Introduction",
@@ -402,12 +402,12 @@
402
402
  "sdk/python/fetch": {
403
403
  "title": "Fetch",
404
404
  "section": "SDK Reference",
405
- "body": "# Fetch\n\nFunctions for interacting with the `fetch` API resource. Each operation ships in four forms — `sync` / `sync_detailed` and their `async` counterparts.\n\n## Get Fetch\n\nFetch a URL (GET)\n\nDirect HTTP fetch. The response body IS the content; metadata is returned in X-Fetch-* headers.\nOmit `format` for raw passthrough. Use `format=markdown` or `format=html` for conversion.\n\n**Parameters**\n\n- `url_query (str)`\n- `format_ (Union[Unset, GetFetchFormat])`\n- `country (Union[Unset, str])`\n- `timeout_ms (Union[Unset, int])`\n- `cache_ttl (Union[GetFetchCacheTtlType1, Unset, str])`\n\n**Call styles**\n\n```python\nsync_detailed(client=client, url_query=url_query, format_=format_, country=country, timeout_ms=timeout_ms, cache_ttl=cache_ttl) -> Response[Union[Error, str]]\nsync(client=client, url_query=url_query, format_=format_, country=country, timeout_ms=timeout_ms, cache_ttl=cache_ttl) -> Optional[Union[Error, str]]\nawait asyncio_detailed(client=client, url_query=url_query, format_=format_, country=country, timeout_ms=timeout_ms, cache_ttl=cache_ttl) -> Response[Union[Error, str]]\nawait asyncio(client=client, url_query=url_query, format_=format_, country=country, timeout_ms=timeout_ms, cache_ttl=cache_ttl) -> Optional[Union[Error, str]]\n```\n\n## Post Fetch\n\nFetch a URL (POST)\n\nSame as GET /v1/fetch but with a JSON request body.\n\n**Limits:** request bodies are capped at 512 KB. An oversized body\nreturns a `400` with error code `request_too_large`.\n\n**Parameters**\n\n- `body (FetchRequest)`\n\n**Call styles**\n\n```python\nsync_detailed(client=client, body=body) -> Response[Union[Error, str]]\nsync(client=client, body=body) -> Optional[Union[Error, str]]\nawait asyncio_detailed(client=client, body=body) -> Response[Union[Error, str]]\nawait asyncio(client=client, body=body) -> Optional[Union[Error, str]]\n```"
405
+ "body": "# Fetch\n\nFunctions for interacting with the `fetch` API resource. Each operation ships in four forms — `sync` / `sync_detailed` and their `async` counterparts.\n\n## Get Fetch\n\nFetch a URL (GET)\n\nDirect HTTP fetch. Successful responses return the upstream response bytes verbatim;\nmetadata is returned in X-Fetch-* headers. Non-2xx upstream responses use the\n`upstream_error` JSON envelope with the upstream HTTP status.\n\n**Parameters**\n\n- `url_query (str)`\n- `country (Union[Unset, str])`\n- `timeout_ms (Union[Unset, int])`\n- `cache_ttl (Union[GetFetchCacheTtlType1, Unset, str])`\n\n**Call styles**\n\n```python\nsync_detailed(client=client, url_query=url_query, country=country, timeout_ms=timeout_ms, cache_ttl=cache_ttl) -> Response[Union[Error, str]]\nsync(client=client, url_query=url_query, country=country, timeout_ms=timeout_ms, cache_ttl=cache_ttl) -> Optional[Union[Error, str]]\nawait asyncio_detailed(client=client, url_query=url_query, country=country, timeout_ms=timeout_ms, cache_ttl=cache_ttl) -> Response[Union[Error, str]]\nawait asyncio(client=client, url_query=url_query, country=country, timeout_ms=timeout_ms, cache_ttl=cache_ttl) -> Optional[Union[Error, str]]\n```\n\n## Post Fetch\n\nFetch a URL (POST)\n\nSame as GET /v1/fetch but with a JSON request body.\n\n**Limits:** request bodies are capped at 512 KB. An oversized body\nreturns a `400` with error code `request_too_large`.\n\n**Parameters**\n\n- `body (FetchRequest)`\n\n**Call styles**\n\n```python\nsync_detailed(client=client, body=body) -> Response[Union[Error, str]]\nsync(client=client, body=body) -> Optional[Union[Error, str]]\nawait asyncio_detailed(client=client, body=body) -> Response[Union[Error, str]]\nawait asyncio(client=client, body=body) -> Optional[Union[Error, str]]\n```"
406
406
  },
407
407
  "sdk/python/fetch-bulk": {
408
408
  "title": "Fetch Bulk",
409
409
  "section": "SDK Reference",
410
- "body": "# Fetch Bulk\n\nFunctions for interacting with the `fetch_bulk` API resource. Each operation ships in four forms — `sync` / `sync_detailed` and their `async` counterparts.\n\n## Create Fetch Bulk\n\nBulk fetch URLs\n\nEnqueues multiple URLs for HTTP fetching. Results delivered via webhook.\nDoes not support options that require page rendering (cookies, wait_for_selector, etc.).\n\n**Limits:** request bodies are guarded in a two-tier shape. A streamed body\nwith no `Content-Length` header is capped at 2 MB before your API key\nis checked; a body that declares `Content-Length` is instead bounded\nthere by a 20 MB fail-safe (not the real limit — see below), since\nthat branch reads nothing until your key is verified. Once your key\nis verified, a second check re-gates the body against your account's\nown `max_bulk_size` (at this endpoint's per-item override budget),\nwhich reaches 16.8 MB for the largest documented account. A\nstandard-plan account's effective ceiling is 2 MB; either tier's\noverrun returns a `400` with error code `request_too_large`.\n\n**Parameters**\n\n- `body (CreateFetchBulkBody)`\n\n**Call styles**\n\n```python\nsync_detailed(client=client, body=body) -> Response[Union[CreateFetchBulkResponse202, Error]]\nsync(client=client, body=body) -> Optional[Union[CreateFetchBulkResponse202, Error]]\nawait asyncio_detailed(client=client, body=body) -> Response[Union[CreateFetchBulkResponse202, Error]]\nawait asyncio(client=client, body=body) -> Optional[Union[CreateFetchBulkResponse202, Error]]\n```\n\n## Get Fetch Bulk\n\nGet fetch bulk job status\n\nReturns the job envelope plus its per-URL items.\n\n**Downloading item content.** Each completed item's `content_url` is a\n**pre-signed** URL, minted fresh on every read of this endpoint and valid\nfor **600 seconds (10 minutes)** — the same signing lifetime as the\n`image_url` returned by `GET /v1/bulk/\\{id\\}/screenshots`. The underlying\nobjects are private, so an unsigned URL returns `401`: download the\ncontent inside that window, or re-poll this endpoint for a fresh\nsignature. Items that are not `completed`, and completed items with no\nstored object, carry `null` or the unsigned stored URL instead.\n\n**Parameters**\n\n- `id (str)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client) -> Response[Union[Error, GetFetchBulkResponse200]]\nsync(id=id, client=client) -> Optional[Union[Error, GetFetchBulkResponse200]]\nawait asyncio_detailed(id=id, client=client) -> Response[Union[Error, GetFetchBulkResponse200]]\nawait asyncio(id=id, client=client) -> Optional[Union[Error, GetFetchBulkResponse200]]\n```"
410
+ "body": "# Fetch Bulk\n\nFunctions for interacting with the `fetch_bulk` API resource. Each operation ships in four forms — `sync` / `sync_detailed` and their `async` counterparts.\n\n## Create Fetch Bulk\n\nBulk fetch URLs\n\nEnqueues multiple URLs for HTTP fetching. Results delivered via webhook.\nDoes not support options that require page rendering (wait_for_selector, etc.).\n\n**Limits:** request bodies are guarded in a two-tier shape. A streamed body\nwith no `Content-Length` header is capped at 2 MB before your API key\nis checked; a body that declares `Content-Length` is instead bounded\nthere by a 20 MB fail-safe (not the real limit — see below), since\nthat branch reads nothing until your key is verified. Once your key\nis verified, a second check re-gates the body against your account's\nown `max_bulk_size` (at this endpoint's per-item override budget),\nwhich reaches 16.8 MB for the largest documented account. A\nstandard-plan account's effective ceiling is 2 MB; either tier's\noverrun returns a `400` with error code `request_too_large`.\n\n**Parameters**\n\n- `body (CreateFetchBulkBody)`\n\n**Call styles**\n\n```python\nsync_detailed(client=client, body=body) -> Response[Union[CreateFetchBulkResponse202, Error]]\nsync(client=client, body=body) -> Optional[Union[CreateFetchBulkResponse202, Error]]\nawait asyncio_detailed(client=client, body=body) -> Response[Union[CreateFetchBulkResponse202, Error]]\nawait asyncio(client=client, body=body) -> Optional[Union[CreateFetchBulkResponse202, Error]]\n```\n\n## Get Fetch Bulk\n\nGet fetch bulk job status\n\nReturns the job envelope plus its per-URL items.\n\n**Downloading item content.** Each completed item's `content_url` is a\n**pre-signed** URL, minted fresh on every read of this endpoint and valid\nfor **600 seconds (10 minutes)** — the same signing lifetime as the\n`image_url` returned by `GET /v1/bulk/\\{id\\}/screenshots`. The underlying\nobjects are private, so an unsigned URL returns `401`: download the\ncontent inside that window, or re-poll this endpoint for a fresh\nsignature. Items that are not `completed`, and completed items with no\nstored object, carry `null` or the unsigned stored URL instead.\n\n**Parameters**\n\n- `id (str)`\n\n**Call styles**\n\n```python\nsync_detailed(id=id, client=client) -> Response[Union[Error, GetFetchBulkResponse200]]\nsync(id=id, client=client) -> Optional[Union[Error, GetFetchBulkResponse200]]\nawait asyncio_detailed(id=id, client=client) -> Response[Union[Error, GetFetchBulkResponse200]]\nawait asyncio(id=id, client=client) -> Optional[Union[Error, GetFetchBulkResponse200]]\n```"
411
411
  },
412
412
  "sdk/python/monitors": {
413
413
  "title": "Monitors",
@@ -462,12 +462,12 @@
462
462
  "sdk/typescript/client": {
463
463
  "title": "Client",
464
464
  "section": "SDK Reference",
465
- "body": "# Client\n\nThe ByteKit TypeScript SDK is a thin, type-safe wrapper over the REST API. Create a\n client with your API key, then call resource methods.\n\n```ts\nimport { ByteKit } from '@hunt-labs/bytekit-sdk';\n\nconst client = new ByteKit({\n apiKey: process.env.BYTEKIT_API_KEY!, // your sk_live_… key\n});\n```\n\n## Options (`ByteKitOptions`)\n\n- `apiKey` (required) — `string`\n- `baseUrl` — `string` Defaults to `https://api.bytekit.com`.\n- `timeoutMs` — `number` — Default CLIENT-SIDE request timeout in ms — the abort budget for the whole HTTP\nround-trip made by this SDK, covering time-to-headers **and** the response body\nread (so a large legitimate body counts against it too). `0` disables the SDK-side\ntimeout. Default 120000.\n\nNOT the same thing as `ScrapeOpts.timeout_ms`, which is the SERVER-side budget the\ngateway applies to the scrape itself. Override per call with\n`RequestOptions.requestTimeoutMs`.\n\n## Resources\n\nThe client exposes one property per resource:\n\n- [`client.scrape`](https://bytekit.com/docs/sdk/typescript/scrape) — Fetch a URL as raw HTML, clean markdown, or structured content.\n- [`client.screenshots`](https://bytekit.com/docs/sdk/typescript/screenshots) — Capture full-page or viewport screenshots.\n- [`client.bulk`](https://bytekit.com/docs/sdk/typescript/bulk) — Fan out many URLs in parallel with per-item webhooks.\n- [`client.fetch`](https://bytekit.com/docs/sdk/typescript/fetch) — Low-latency raw HTTP fetch with optional conversion.\n- [`client.monitors`](https://bytekit.com/docs/sdk/typescript/monitors) — Watch a URL on a schedule and webhook on change.\n- [`client.sitemap`](https://bytekit.com/docs/sdk/typescript/sitemap) — Discover URLs from a domain's sitemap or by crawling.\n- [`client.search`](https://bytekit.com/docs/sdk/typescript/search) — Run a web search and return ranked organic results.\n- [`client.account`](https://bytekit.com/docs/sdk/typescript/account) — Account info and API key management.\n- [`client.usage`](https://bytekit.com/docs/sdk/typescript/usage) — Billing-period and daily usage breakdowns.\n- [`client.webhooks`](https://bytekit.com/docs/sdk/typescript/webhooks) — List and retry webhook deliveries.\n\n## Errors\n\nAny non-2xx response throws a `ByteKitError` carrying the HTTP `status` and the API `code`.\n\n```ts\nimport { ByteKit, ByteKitError } from '@hunt-labs/bytekit-sdk';\n\ntry {\n await client.scrape.create({ url: 'https://example.com' });\n} catch (err) {\n if (err instanceof ByteKitError) {\n console.error(`${err.status} ${err.code}: ${err.message}`);\n }\n}\n```"
465
+ "body": "# Client\n\nThe ByteKit TypeScript SDK is a thin, type-safe wrapper over the REST API. Create a\n client with your API key, then call resource methods.\n\n```ts\nimport { ByteKit } from '@hunt-labs/bytekit-sdk';\n\nconst client = new ByteKit({\n apiKey: process.env.BYTEKIT_API_KEY!, // your sk_live_… key\n});\n```\n\n## Options (`ByteKitOptions`)\n\n- `apiKey` (required) — `string`\n- `baseUrl` — `string` Defaults to `https://api.bytekit.com`.\n- `timeoutMs` — `number` — Default CLIENT-SIDE request timeout in ms — the abort budget for the whole HTTP\nround-trip made by this SDK, covering time-to-headers **and** the response body\nread (so a large legitimate body counts against it too). `0` disables the SDK-side\ntimeout. Default 120000.\n\nNOT the same thing as `ScrapeOpts.timeout_ms`, which is the SERVER-side budget the\ngateway applies to the scrape itself. Override per call with\n`RequestOptions.requestTimeoutMs`.\n\n## Resources\n\nThe client exposes one property per resource:\n\n- [`client.scrape`](https://bytekit.com/docs/sdk/typescript/scrape) — Fetch a URL as raw HTML, clean markdown, or structured content.\n- [`client.screenshots`](https://bytekit.com/docs/sdk/typescript/screenshots) — Capture full-page or viewport screenshots.\n- [`client.bulk`](https://bytekit.com/docs/sdk/typescript/bulk) — Fan out many URLs in parallel with per-item webhooks.\n- [`client.fetch`](https://bytekit.com/docs/sdk/typescript/fetch) — Low-latency raw HTTP fetch with byte-for-byte upstream responses.\n- [`client.monitors`](https://bytekit.com/docs/sdk/typescript/monitors) — Watch a URL on a schedule and webhook on change.\n- [`client.sitemap`](https://bytekit.com/docs/sdk/typescript/sitemap) — Discover URLs from a domain's sitemap or by crawling.\n- [`client.search`](https://bytekit.com/docs/sdk/typescript/search) — Run a web search and return ranked organic results.\n- [`client.account`](https://bytekit.com/docs/sdk/typescript/account) — Account info and API key management.\n- [`client.usage`](https://bytekit.com/docs/sdk/typescript/usage) — Billing-period and daily usage breakdowns.\n- [`client.webhooks`](https://bytekit.com/docs/sdk/typescript/webhooks) — List and retry webhook deliveries.\n\n## Errors\n\nAny non-2xx response throws a `ByteKitError` carrying the HTTP `status` and the API `code`.\n\n```ts\nimport { ByteKit, ByteKitError } from '@hunt-labs/bytekit-sdk';\n\ntry {\n await client.scrape.create({ url: 'https://example.com' });\n} catch (err) {\n if (err instanceof ByteKitError) {\n console.error(`${err.status} ${err.code}: ${err.message}`);\n }\n}\n```"
466
466
  },
467
467
  "sdk/typescript/fetch": {
468
468
  "title": "Fetch",
469
469
  "section": "SDK Reference",
470
- "body": "# Fetch\n\nLow-latency raw HTTP fetch with optional conversion. Accessed via `client.fetch`.\n\n## create\n\n```ts\nclient.fetch.create(opts: FetchOpts, requestOptions?: RequestOptions): Promise<FetchResult>\n```\n\nPOST /v1/fetch — fetch URL content via POST body.\n\nResolves a `FetchResult` — the raw content body plus `X-Fetch-*` metadata.\nThe body is returned verbatim — a JSON-serving upstream comes back as the\nraw JSON string, not a parsed object.\n\n`requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an\noptional caller `signal`. It matters most here: the gateway's own ceiling for a\nfetch is 60 s, so without a per-call budget a slow upstream holds the caller for\nthe constructor default (2 minutes) rather than a duration the caller chose.\n\n## get\n\n```ts\nclient.fetch.get(opts: FetchGetOpts, requestOptions?: RequestOptions): Promise<FetchResult>\n```\n\nGET /v1/fetch — fetch URL content via query params.\n\nResolves a `FetchResult` — the raw content body plus `X-Fetch-*` metadata.\n\nAccepts only the five params the spec declares for this endpoint. `custom`\n(#2481) and the `markdown_*` / `with_*` tuning fields (#2539) are POST-body\noptions with no GET query param — they were silently dropped by this builder,\nso they are now compile errors instead. Use `create()` (POST) for those.\n\nThe query string is built by iterating `FETCH_GET_QUERY_KEYS`, the same list\n`FetchGetOpts` is derived from, so every accepted option is necessarily\nserialized.\n\n`requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an\noptional caller `signal`. As on `create`, the gateway's own ceiling for a fetch is\n60 s, so a per-call budget is what keeps a slow upstream from holding the caller\nfor the constructor default.\n\n## Options (`FetchOpts`)\n\n- `url` (required) — `string`\n- `format` — `'markdown' | 'html'` — Output format. `'markdown'` runs the HTML→markdown pipeline; `'html'` returns raw HTML. Narrowed to the spec union — off-spec values (e.g. `'pdf'`) are rejected at compile time.\n- `country` — `string`\n- `timeout_ms` — `number`\n- `markdown_mode` — `'article' | 'raw' | 'llm'` — Markdown processing mode. Only used when `format=markdown`. article/raw/llm.\n- `markdown_query` — `string` — BM25 query string for relevance-ranked filtering. Only used when `format=markdown`.\n- `markdown_links` — `'inline' | 'references' | 'none' | 'text'` — Link rendering style. Only used when `format=markdown`.\n- `markdown_images` — `'inline' | 'references' | 'none' | 'text'` — Image retention mode. Only used when `format=markdown`.\n- `with_links_summary` — `boolean` — Append a `Links:` footer to the markdown output. Only used when `format=markdown`.\n- `with_images_summary` — `boolean` — Append an `Images:` footer to the markdown output. Only used when `format=markdown`.\n- `markdown_compact` — `boolean` — Compact whitespace output. Only used when `format=markdown`.\n- `markdown_filter_images` — `boolean` — Filter low-signal images. Only used when `format=markdown`.\n- `markdown_include_media` — `boolean` — When true, `formats.links`/`formats.images` return rich objects and a top-level `tables` array is included. Only used when `format=markdown`.\n- `markdown_include_warnings` — `boolean` — When true, enables markdown-pipeline and tag-filter warnings for affected html/markdown requests.\n- `markdown_include_stats` — `boolean` — When true, includes a top-level `stats` object (chars, tokens, blocks). Only used when `format=markdown`.\n- `cache_ttl` — `string | 0` — How long a freshly fetched URL may be served from cache. Matches the\nOpenAPI `FetchRequest.cache_ttl` schema: a duration string (`\"48h\"`,\n`\"2d\"`, up to `168h` / `7d`) or the integer `0` to disable caching.\nDefaults to `\"48h\"` server-side when omitted.\n- `custom` — `Record<string, unknown>` — User-supplied JSON payload, base64-encoded into the `X-Fetch-Custom`\nresponse header so callers can correlate the response to caller-side\nstate. Capped at 4096 UTF-8 bytes after JSON serialization. Does NOT\naffect cache-key inputs."
470
+ "body": "# Fetch\n\nLow-latency raw HTTP fetch with byte-for-byte upstream responses. Accessed via `client.fetch`.\n\n## create\n\n```ts\nclient.fetch.create(opts: FetchOpts, requestOptions?: RequestOptions): Promise<FetchResult>\n```\n\nPOST /v1/fetch — fetch URL content via POST body.\n\nResolves a `FetchResult` — the raw content body plus `X-Fetch-*` metadata.\nThe body is returned verbatim — a JSON-serving upstream comes back as the\nraw JSON string, not a parsed object.\n\n`requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an\noptional caller `signal`. It matters most here: the gateway's own ceiling for a\nfetch is 60 s, so without a per-call budget a slow upstream holds the caller for\nthe constructor default (2 minutes) rather than a duration the caller chose.\n\n## get\n\n```ts\nclient.fetch.get(opts: FetchGetOpts, requestOptions?: RequestOptions): Promise<FetchResult>\n```\n\nGET /v1/fetch — fetch URL content via query params.\n\nResolves a `FetchResult` — the raw content body plus `X-Fetch-*` metadata.\n\nAccepts only the four params the spec declares for this endpoint. `custom`\nis a POST-body option with no GET query param; use `create()` for custom metadata.\n\nThe query string is built by iterating `FETCH_GET_QUERY_KEYS`, the same list\n`FetchGetOpts` is derived from, so every accepted option is necessarily\nserialized.\n\n`requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an\noptional caller `signal`. As on `create`, the gateway's own ceiling for a fetch is\n60 s, so a per-call budget is what keeps a slow upstream from holding the caller\nfor the constructor default.\n\n## Options (`FetchOpts`)\n\n- `url` (required) — `string`\n- `country` — `string`\n- `timeout_ms` — `number`\n- `cache_ttl` — `string | 0` — How long a freshly fetched URL may be served from cache. Matches the\nOpenAPI `FetchRequest.cache_ttl` schema: a duration string (`\"48h\"`,\n`\"2d\"`, up to `168h` / `7d`) or the integer `0` to disable caching.\nDefaults to `\"48h\"` server-side when omitted.\n- `custom` — `Record<string, unknown>` — User-supplied JSON payload, base64-encoded into the `X-Fetch-Custom`\nresponse header so callers can correlate the response to caller-side\nstate. Capped at 4096 UTF-8 bytes after JSON serialization. Does NOT\naffect cache-key inputs."
471
471
  },
472
472
  "sdk/typescript/fetch-bulk": {
473
473
  "title": "Fetch Bulk",
@@ -482,7 +482,7 @@
482
482
  "sdk/typescript/scrape": {
483
483
  "title": "Scrape",
484
484
  "section": "SDK Reference",
485
- "body": "# Scrape\n\nFetch a URL as raw HTML, clean markdown, or structured content. Accessed via `client.scrape`.\n\n## create\n\n```ts\nclient.scrape.create(opts: ScrapeOpts, requestOptions?: RequestOptions): Promise<ScrapeCreateResponse>\n```\n\nPOST /v1/scrape — create a scrape job.\n\nResolves to the 200 success envelope, or the 202 queued envelope when\n`async: true`. Narrow on `status` before reading the result.\n\n`requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an\noptional caller `signal`; both override the constructor's `timeoutMs` default. They\nare a different axis from `opts.timeout_ms`, which is the SERVER-side scrape budget.\n\n## get\n\n```ts\nclient.scrape.get(id: ScrapeId, requestOptions?: RequestOptions): Promise<ScrapeGetResponse>\n```\n\nGET /v1/scrape/\\{id\\} — poll a scrape by ID\n\n## Options (`ScrapeOpts`)\n\n- `url` (required) — `string`\n- `formats` — `Array<'raw_html' | 'html' | 'markdown' | 'links' | 'images'>`\n- `country` — `string`\n- `cookies` — `ScrapeCookie[]` — Cookies to set before loading the page. `name` and `value` are required (spec `Cookie` schema).\n- `headers` — `Record<string, string>`\n- `delay_ms` — `number`\n- `timeout_ms` — `number` — SERVER-side scrape budget in ms — how long the gateway may spend on the scrape itself. For the CLIENT-side abort budget (when this SDK gives up on the wire), see `RequestOptions.requestTimeoutMs`.\n- `async` — `boolean`\n- `webhook_url` — `string`\n- `events` — `Array<'queued' | 'completed' | 'failed'>`\n- `markdown_mode` — `MarkdownMode` — Markdown processing mode. article=article extraction (default), raw=minimal cleanup, llm=compact LLM-optimised output.\n- `markdown_query` — `string` — BM25 query string for relevance-ranked content filtering. Omit or leave empty to disable.\n- `markdown_links` — `MarkdownLinks` — Link rendering style in the markdown output.\n- `markdown_images` — `MarkdownImages` — Image retention mode in the markdown output. Distinct from `markdown_filter_images` (which drops low-signal images before conversion).\n- `with_links_summary` — `boolean` — When true, appends a `Links:` footer to the markdown output. Automatically enabled when `markdown_links` is `'references'`.\n- `with_images_summary` — `boolean` — When true, appends an `Images:` footer to the markdown output.\n- `markdown_compact` — `boolean` — Collapse excessive whitespace for a more compact output.\n- `markdown_filter_images` — `boolean` — Filter low-signal images from the markdown output.\n- `markdown_include_media` — `boolean` — When true, `formats.links` and `formats.images` return `ScrapeScoredLink[]` / `ScrapeScoredImage[]` (rich objects) instead of `string[]`, and a top-level `tables` array is included. Only effective when `markdown` is in `formats`.\n- `markdown_include_warnings` — `boolean` — When true, the response includes markdown-pipeline and tag-filter warnings. `artifact_unavailable` may appear independently when a requested persisted format cannot be rehydrated.\n- `markdown_include_stats` — `boolean` — When true, the response includes a top-level `stats` object with `ScrapeStats` (chars, tokens, blocks). Only effective when `markdown` is in `formats`.\n- `token_budget` — `number` — Maximum token count for the markdown output. Truncates at the last paragraph → sentence → token boundary under the limit. Absent → no truncation.\n- `token_encoding` — `TokenEncoding` — Tokenizer encoding hint for `token_budget`. `cl100k_base` (default) matches GPT-4/4o; `o200k_base` matches GPT-4o-mini / o-series.\n- `mobile` — `boolean` — When true, emulate a mobile device (mobile UA + viewport). Default false (desktop). Part of the cache key, so mobile and desktop responses cache independently.\n- `remove_base64_images` — `boolean` — When true (default), base64-encoded `data:` image sources are stripped before markdown conversion and from `html` output. Set false to preserve them. Does not affect `raw_html`.\n- `include_tags` — `string[]` — HTML element names (not CSS selectors) to keep. When non-empty, only content within these elements is included in `html`/`markdown` output. Applied before `exclude_tags`. Does not affect `raw_html`.\n- `exclude_tags` — `string[]` — HTML element names (not CSS selectors) to strip from `html`/`markdown` output. Applied after `include_tags`. Does not affect `raw_html`.\n- `clean_markdown` — `boolean` — When true and `markdown` is in `formats`, the converted markdown is sent to Groq for cleaning before return. Graceful degradation on any Groq failure. Billing: 3× credits and bytes applied only when cleaning succeeds.\n- `cache_ttl` — `string | 0` — How long a freshly fetched URL may be served from cache. `'0'`/`0` skips the\ncache read (the result is still written), `'Nh'`/`'Nd'` set a TTL (capped at\n168h / 7d). Default `'48h'`. Honoured on both the synchronous and asynchronous\npaths; the async success envelope reports the outcome via the `cache` field.\n- `custom` — `Record<string, unknown>` — User-supplied JSON payload, echoed back on the success envelope so callers\ncan correlate the response to caller-side state (job IDs, batch metadata).\nCapped at 4096 UTF-8 bytes after JSON serialization. Does NOT affect\ncache-key inputs — two requests differing only in `custom` share the same\ncache slot."
485
+ "body": "# Scrape\n\nFetch a URL as raw HTML, clean markdown, or structured content. Accessed via `client.scrape`.\n\n## create\n\n```ts\nclient.scrape.create(opts: ScrapeOpts, requestOptions?: RequestOptions): Promise<ScrapeCreateResponse>\n```\n\nPOST /v1/scrape — create a scrape job.\n\nResolves to the 200 success envelope, or the 202 queued envelope when\n`async: true`. Narrow on `status` before reading the result.\n\n`requestOptions` carries the CLIENT-side abort budget (`requestTimeoutMs`) and an\noptional caller `signal`; both override the constructor's `timeoutMs` default. They\nare a different axis from `opts.timeout_ms`, which is the SERVER-side scrape budget.\n\n## get\n\n```ts\nclient.scrape.get(id: ScrapeId, requestOptions?: RequestOptions): Promise<ScrapeGetResponse>\n```\n\nGET /v1/scrape/\\{id\\} — poll a scrape by ID\n\n## Options (`ScrapeOpts`)\n\n- `url` (required) — `string`\n- `formats` — `Array<'raw_html' | 'html' | 'markdown' | 'links' | 'images'>`\n- `country` — `string`\n- `delay_ms` — `number`\n- `timeout_ms` — `number` — SERVER-side scrape budget in ms — how long the gateway may spend on the scrape itself. For the CLIENT-side abort budget (when this SDK gives up on the wire), see `RequestOptions.requestTimeoutMs`.\n- `async` — `boolean`\n- `webhook_url` — `string`\n- `events` — `Array<'queued' | 'completed' | 'failed'>`\n- `markdown_mode` — `MarkdownMode` — Markdown processing mode. article=article extraction (default), raw=minimal cleanup, llm=compact LLM-optimised output.\n- `markdown_query` — `string` — BM25 query string for relevance-ranked content filtering. Omit or leave empty to disable.\n- `markdown_links` — `MarkdownLinks` — Link rendering style in the markdown output.\n- `markdown_images` — `MarkdownImages` — Image retention mode in the markdown output. Distinct from `markdown_filter_images` (which drops low-signal images before conversion).\n- `with_links_summary` — `boolean` — When true, appends a `Links:` footer to the markdown output. Automatically enabled when `markdown_links` is `'references'`.\n- `with_images_summary` — `boolean` — When true, appends an `Images:` footer to the markdown output.\n- `markdown_compact` — `boolean` — Collapse excessive whitespace for a more compact output.\n- `markdown_filter_images` — `boolean` — Filter low-signal images from the markdown output.\n- `markdown_include_media` — `boolean` — When true, `formats.links` and `formats.images` return `ScrapeScoredLink[]` / `ScrapeScoredImage[]` (rich objects) instead of `string[]`, and a top-level `tables` array is included. Only effective when `markdown` is in `formats`.\n- `markdown_include_warnings` — `boolean` — When true, the response includes markdown-pipeline and tag-filter warnings. `artifact_unavailable` may appear independently when a requested persisted format cannot be rehydrated.\n- `markdown_include_stats` — `boolean` — When true, the response includes a top-level `stats` object with `ScrapeStats` (chars, tokens, blocks). Only effective when `markdown` is in `formats`.\n- `token_budget` — `number` — Maximum token count for the markdown output. Truncates at the last paragraph → sentence → token boundary under the limit. Absent → no truncation.\n- `token_encoding` — `TokenEncoding` — Tokenizer encoding hint for `token_budget`. `cl100k_base` (default) matches GPT-4/4o; `o200k_base` matches GPT-4o-mini / o-series.\n- `mobile` — `boolean` — When true, emulate a mobile device (mobile UA + viewport). Default false (desktop). Part of the cache key, so mobile and desktop responses cache independently.\n- `remove_base64_images` — `boolean` — When true (default), base64-encoded `data:` image sources are stripped before markdown conversion and from `html` output. Set false to preserve them. Does not affect `raw_html`.\n- `include_tags` — `string[]` — HTML element names (not CSS selectors) to keep. When non-empty, only content within these elements is included in `html`/`markdown` output. Applied before `exclude_tags`. Does not affect `raw_html`.\n- `exclude_tags` — `string[]` — HTML element names (not CSS selectors) to strip from `html`/`markdown` output. Applied after `include_tags`. Does not affect `raw_html`.\n- `clean_markdown` — `boolean` — When true and `markdown` is in `formats`, the converted markdown is sent to Groq for cleaning before return. Graceful degradation on any Groq failure. Billing: 3× credits and bytes applied only when cleaning succeeds.\n- `cache_ttl` — `string | 0` — How long a freshly fetched URL may be served from cache. `'0'`/`0` skips the\ncache read (the result is still written), `'Nh'`/`'Nd'` set a TTL (capped at\n168h / 7d). Default `'48h'`. Honoured on both the synchronous and asynchronous\npaths; the async success envelope reports the outcome via the `cache` field.\n- `custom` — `Record<string, unknown>` — User-supplied JSON payload, echoed back on the success envelope so callers\ncan correlate the response to caller-side state (job IDs, batch metadata).\nCapped at 4096 UTF-8 bytes after JSON serialization. Does NOT affect\ncache-key inputs — two requests differing only in `custom` share the same\ncache slot."
486
486
  },
487
487
  "sdk/typescript/scrape-bulk": {
488
488
  "title": "Scrape Bulk",
@@ -117,35 +117,6 @@ export interface ScrapeSuccessEnvelope {
117
117
  total: number;
118
118
  truncated: boolean;
119
119
  };
120
- /**
121
- * Per-call billing multiplier for this scrape (1.0 base, +0.5/billable format).
122
- * Reports the BASE-endpoint composition: on a cache hit it is a flat 0.5 for
123
- * every requested format, because the per-endpoint factor is applied later, at
124
- * report time by GET /v1/usage/by-endpoint (issue #2313), not here. It equals
125
- * the X-Scrape-Credits-Charged header and the persisted credits_charged column
126
- * (both 0.5 on a cache hit), but it does NOT always equal the
127
- * X-Billing-Multiplier header, which composes the REAL endpoint: on a markdown
128
- * cache hit the header is 0.75 (scrape_md 1.5 x cacheHit 0.5) while this field
129
- * stays 0.5 (Exception D-scrape, issue #2315). Raw cache hits are 0.5 in both.
130
- * NOTE: pre-clean_markdown-multiplier; on clean_markdown:true the final billed
131
- * usage is 3x this. Omitted on paths with no billing value (issue #1899).
132
- * LEGACY (issue #3139): `billing` below is now the explanation of the charge —
133
- * it names every factor and composes to the X-Billing-Multiplier header. Read
134
- * that; this field is removed in the final slice of #3135.
135
- */
136
- billing_multiplier?: number;
137
- /**
138
- * Metered wire bytes for this call = round(content_length x billing_multiplier),
139
- * derived from the body multiplier above rather than from the header's. Same
140
- * value as the X-Billable-Bytes header wherever the two multipliers agree; on a
141
- * markdown cache hit the header carries round(content_length x 0.75) and this
142
- * field round(content_length x 0.5), per Exception D-scrape (issue #2315).
143
- * (pre-clean_markdown-multiplier, like the header). Omitted on paths with no
144
- * billing value (issue #1899).
145
- * LEGACY (issue #3139): read `billing.billed_bytes` below instead — it equals
146
- * the X-Billable-Bytes header on the same response.
147
- */
148
- billed_bytes?: number;
149
120
  /**
150
121
  * The named billing factor list (issue #3139) — the DEFINITION of what this
151
122
  * call is charged. `factors` lists every applying factor in composition order
@@ -198,10 +169,16 @@ export interface ScrapeQueuedEnvelope {
198
169
  export type ScrapeEnvelope = ScrapeSuccessEnvelope | ScrapeErrorEnvelope | ScrapeQueuedEnvelope;
199
170
  /**
200
171
  * The complete billing factor vocabulary — fixed and TOTAL, in the order the
201
- * factors compose. A charge is explained by these three names or it is not
202
- * explained at all.
172
+ * factors compose. A charge is explained by these names or it is not explained
173
+ * at all.
174
+ *
175
+ * The first three explain a BYTE-SCRAPE charge. `phase1_render` (issue #3141)
176
+ * explains a CAPTURE charge — screenshots and recordings bill on
177
+ * `phase1_wire_bytes × 1.5`, a basis the byte-scrape endpoint factor cannot
178
+ * name — and occupies the endpoint position in a capture node, which carries
179
+ * that factor and nothing else. The two vocabularies never mix on one node.
203
180
  */
204
- export type BillingFactorName = 'endpoint' | 'cache_hit' | 'clean_markdown';
181
+ export type BillingFactorName = 'endpoint' | 'cache_hit' | 'clean_markdown' | 'phase1_render';
205
182
  export interface BillingFactor {
206
183
  name: BillingFactorName;
207
184
  /** This factor's multiplicative contribution. */
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { loadBundle } from '../docs-bundle/load-bundle.js';
3
+ import { boundDocBody, MAX_DOC_BODY_BYTES } from '../docs-bundle/body-bound.js';
3
4
  /**
4
5
  * Validates that a path is safe to use as a bundle key lookup.
5
6
  *
@@ -20,7 +21,10 @@ function isValidPath(path) {
20
21
  return !segments.some((seg) => seg === '..' || seg === '.');
21
22
  }
22
23
  export function getDocTool(server) {
23
- server.tool('get_doc', 'Retrieve the full rendered markdown for a specific documentation page. Use list_docs or search_docs to discover valid paths first.', {
24
+ server.tool('get_doc', 'Retrieve the rendered markdown for a specific documentation page. Bodies are capped at ' +
25
+ `${MAX_DOC_BODY_BYTES} bytes; a page above the cap is returned cut short, with a closing ` +
26
+ 'notice naming its full size and the URL that serves all of it. Use list_docs or ' +
27
+ 'search_docs to discover valid paths first.', {
24
28
  path: z
25
29
  .string()
26
30
  .describe('Relative doc path (e.g. "guides/authentication", "api/scrape/createscrape")'),
@@ -50,11 +54,17 @@ export function getDocTool(server) {
50
54
  ],
51
55
  };
52
56
  }
57
+ // The bound is applied HERE, at the read, and not only at the harvest step that
58
+ // produced the bundle: `loadBundle` reads whatever docs-bundle.json is on disk, so
59
+ // the tool's own contract — never return a body no caller can use — has to hold for
60
+ // a bundle this repo did not generate. Over an already-bounded body the call is a
61
+ // no-op, which is what keeps every other entry byte-identical (issue #3233).
62
+ const { body } = boundDocBody(entry.body, params.path);
53
63
  return {
54
64
  content: [
55
65
  {
56
66
  type: 'text',
57
- text: JSON.stringify({ title: entry.title, section: entry.section, body: entry.body }, null, 2),
67
+ text: JSON.stringify({ title: entry.title, section: entry.section, body }, null, 2),
58
68
  },
59
69
  ],
60
70
  };
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { loadBundle } from '../docs-bundle/load-bundle.js';
3
+ import { MAX_DOC_BODY_BYTES, DOCS_BASE_URL } from '../docs-bundle/body-bound.js';
3
4
  const SNIPPET_RADIUS = 100; // chars on each side of the first match → ~200 total
4
5
  const MAX_RESULTS = 10;
5
6
  /**
@@ -64,8 +65,48 @@ function extractSnippet(text, tokens) {
64
65
  const snippet = text.slice(start, end).trim();
65
66
  return (start > 0 ? '…' : '') + snippet + (end < text.length ? '…' : '');
66
67
  }
68
+ /**
69
+ * The advertised description of `search_docs`.
70
+ *
71
+ * The closing disclosure is #3307's. `scoreEntry` runs over the bundle's harvested bodies, and
72
+ * those are bounded at {@link MAX_DOC_BODY_BYTES} — so search coverage is the bounded body, not
73
+ * the published page. On the `changelog` entry that is 16 KB of a ~140 KB page, and a query for a
74
+ * release below the cut returns nothing, with no way for the caller to tell an absent feature
75
+ * from an unindexed one. Saying so in the schema is the part of the fix an agent meets BEFORE it
76
+ * phrases a query; the per-page truncation notice (`body-bound.ts`) is the part it meets after.
77
+ *
78
+ * SAY WHICH TEXT IS MISSING, NOT JUST THAT SOME IS (#3307 review B1)
79
+ * ------------------------------------------------------------------
80
+ * The first wording called the missing part "every release older than the kept window". That was
81
+ * false, and false in the direction that does damage: the cut is POSITIONAL — the leading
82
+ * {@link MAX_DOC_BODY_BYTES} bytes in page order — and the changelog is ordered by distribution,
83
+ * not by date. The window ends inside the FIRST of its four `##` package sections, so the Python
84
+ * SDK, CLI and MCP-server histories are outside it entirely, newest releases included; the CLI's
85
+ * `0.9.0` and the MCP server's `0.3.0` share a release date with the TypeScript SDK release that
86
+ * IS inside the window. An agent told only older releases are missing, querying for the newest
87
+ * CLI release and getting nothing, concludes the feature does not exist — which is this ticket's
88
+ * own defect, recreated by the sentence meant to close it. A partial model is worse than none,
89
+ * because the agent acts on it.
90
+ *
91
+ * Both the limit and the docs origin are interpolated rather than restated, so this text cannot
92
+ * name a bound the harvest step does not apply or an origin the truncation notice does not use.
93
+ * The page URL is named outright, not merely pointed at: a search that returns zero results hands
94
+ * the agent no result to read, so routing it through `get_doc` first would cost a second call to
95
+ * learn where to go. The claim about which sections survive is re-derived from the committed
96
+ * bundle in `__tests__/search-coverage-disclosure.test.ts`, so prose and artifact are pinned to
97
+ * each other.
98
+ */
99
+ const SEARCH_DOCS_DESCRIPTION = 'Search the ByteKit documentation bundle. Returns up to 10 results with a snippet showing ' +
100
+ 'context around the first match. Case-insensitive token match over title and body. Body ' +
101
+ `matching covers only the bounded body get_doc returns — the leading ${MAX_DOC_BODY_BYTES} ` +
102
+ 'bytes of a page — so text cut from a longer page is not searchable here. The cut is ' +
103
+ 'positional, by page order, never by age. On the changelog page that window currently reaches ' +
104
+ 'only part of the first of its four package histories (@hunt-labs/bytekit-sdk), so the ' +
105
+ 'bytekit-sdk (Python), @hunt-labs/bytekit-cli and @hunt-labs/bytekit-mcp histories are not ' +
106
+ 'searchable here at all, their newest releases included; read the whole page at ' +
107
+ `${DOCS_BASE_URL}/changelog.`;
67
108
  export function searchDocsTool(server) {
68
- server.tool('search_docs', 'Search the ByteKit documentation bundle. Returns up to 10 results with a snippet showing context around the first match. Case-insensitive token match over title and body.', {
109
+ server.tool('search_docs', SEARCH_DOCS_DESCRIPTION, {
69
110
  query: z
70
111
  .string()
71
112
  .min(1, 'query must be non-empty')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hunt-labs/bytekit-mcp",
3
- "version": "0.2.7",
3
+ "version": "0.3.0",
4
4
  "description": "ByteKit MCP server — exposes ByteKit web-data tools (scrape, screenshot, search, docs) to AI agents over the Model Context Protocol, hosted or as a local stdio server.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -58,11 +58,12 @@
58
58
  "zod": "^3.23.6"
59
59
  },
60
60
  "scripts": {
61
- "prebuild": "pnpm check:scrape-contract && tsx scripts/build-docs-bundle.ts",
61
+ "prebuild": "pnpm check:scrape-contract",
62
62
  "build": "rm -rf dist tsconfig.tsbuildinfo && tsc && mkdir -p dist/docs-bundle && cp src/docs-bundle/docs-bundle.json dist/docs-bundle/docs-bundle.json",
63
63
  "typecheck": "pnpm check:scrape-contract && tsc --noEmit && tsc --noEmit -p tsconfig.scripts.json",
64
64
  "test": "pnpm check:scrape-contract && vitest run && pnpm test:package",
65
65
  "generate:scrape-contract": "tsx scripts/sync-scrape-contract.ts",
66
+ "generate:docs-bundle": "tsx scripts/build-docs-bundle.ts",
66
67
  "check:scrape-contract": "tsx scripts/sync-scrape-contract.ts --check",
67
68
  "test:package": "tsx scripts/test-package-boundary.ts"
68
69
  }