webforai 3.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -5
- package/dist/bin.js +1277 -479
- package/dist/cjs/detect-client-shell.js +78 -0
- package/dist/cjs/extract-meta-refresh.js +71 -0
- package/dist/cjs/extractors/lib/sanitize.js +4 -0
- package/dist/cjs/html-to-mdast.js +2 -1
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/link-replacer.js +19 -13
- package/dist/cjs/loaders/cf-puppeteer.js +14 -7
- package/dist/cjs/loaders/fetch.js +14 -2
- package/dist/cjs/loaders/playwright.js +32 -30
- package/dist/cjs/loaders/puppeteer.js +14 -7
- package/dist/cjs/md-splitter.js +24 -11
- package/dist/cjs/mdast-handlers/custom-code-handler.js +18 -7
- package/dist/cjs/mdast-handlers/custom-div-handler.js +12 -33
- package/dist/cjs/mdast-handlers/definition-list-handler.js +17 -6
- package/dist/cjs/mdast-to-markdown.js +2 -5
- package/dist/cjs/normalize/index.js +11 -2
- package/dist/cjs/platform/client.js +73 -16
- package/dist/cjs/platform/index.js +4 -0
- package/dist/cjs/platform/types.js +7 -1
- package/dist/detect-client-shell.js +53 -0
- package/dist/extract-meta-refresh.js +47 -0
- package/dist/extractors/lib/sanitize.js +4 -0
- package/dist/html-to-mdast.js +2 -1
- package/dist/index.js +14 -0
- package/dist/link-replacer.js +19 -13
- package/dist/loaders/cf-puppeteer.js +15 -8
- package/dist/loaders/fetch.js +14 -2
- package/dist/loaders/playwright.js +32 -30
- package/dist/loaders/puppeteer.js +15 -8
- package/dist/md-splitter.js +24 -11
- package/dist/mdast-handlers/custom-code-handler.js +17 -7
- package/dist/mdast-handlers/custom-div-handler.js +12 -33
- package/dist/mdast-handlers/definition-list-handler.js +17 -6
- package/dist/mdast-to-markdown.js +2 -5
- package/dist/normalize/index.js +12 -2
- package/dist/platform/client.js +73 -16
- package/dist/platform/index.js +4 -0
- package/dist/platform/types.js +5 -1
- package/dist/types/cli/bin.js.map +1 -1
- package/dist/types/cli/commands/jobs/files.d.ts +28 -0
- package/dist/types/cli/commands/jobs/files.js.map +1 -0
- package/dist/types/cli/commands/jobs/llms-txt.d.ts +33 -0
- package/dist/types/cli/commands/jobs/llms-txt.js.map +1 -0
- package/dist/types/cli/commands/jobs/options.d.ts +58 -0
- package/dist/types/cli/commands/jobs/options.js.map +1 -0
- package/dist/types/cli/commands/jobs/run.d.ts +44 -0
- package/dist/types/cli/commands/jobs/run.js.map +1 -0
- package/dist/types/cli/commands/skill/content.js.map +1 -1
- package/dist/types/cli/commands/webforai/interactive.d.ts +1 -1
- package/dist/types/cli/commands/webforai/interactive.js.map +1 -1
- package/dist/types/cli/commands/webforai/options.d.ts +9 -2
- package/dist/types/cli/commands/webforai/options.js.map +1 -1
- package/dist/types/cli/commands/webforai/run.js.map +1 -1
- package/dist/types/cli/utils.d.ts +8 -1
- package/dist/types/cli/utils.js.map +1 -1
- package/dist/types/detect-client-shell.d.ts +24 -0
- package/dist/types/detect-client-shell.js.map +1 -0
- package/dist/types/extract-meta-refresh.d.ts +29 -0
- package/dist/types/extract-meta-refresh.js.map +1 -0
- package/dist/types/extractors/lib/sanitize.js.map +1 -1
- package/dist/types/html-to-mdast.js.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/link-replacer.d.ts +3 -1
- package/dist/types/link-replacer.js.map +1 -1
- package/dist/types/loaders/cf-puppeteer.js.map +1 -1
- package/dist/types/loaders/fetch.d.ts +4 -0
- package/dist/types/loaders/fetch.js.map +1 -1
- package/dist/types/loaders/playwright.js.map +1 -1
- package/dist/types/loaders/puppeteer.js.map +1 -1
- package/dist/types/md-splitter.d.ts +1 -1
- package/dist/types/md-splitter.js.map +1 -1
- package/dist/types/mdast-handlers/custom-code-handler.d.ts +2 -0
- package/dist/types/mdast-handlers/custom-code-handler.js.map +1 -1
- package/dist/types/mdast-handlers/custom-div-handler.js.map +1 -1
- package/dist/types/mdast-handlers/definition-list-handler.d.ts +0 -11
- package/dist/types/mdast-handlers/definition-list-handler.js.map +1 -1
- package/dist/types/mdast-to-markdown.js.map +1 -1
- package/dist/types/normalize/index.js.map +1 -1
- package/dist/types/platform/client.d.ts +2 -1
- package/dist/types/platform/client.js.map +1 -1
- package/dist/types/platform/error.d.ts +5 -3
- package/dist/types/platform/error.js.map +1 -1
- package/dist/types/platform/fetch.d.ts +2 -0
- package/dist/types/platform/fetch.js.map +1 -1
- package/dist/types/platform/index.d.ts +1 -1
- package/dist/types/platform/index.js.map +1 -1
- package/dist/types/platform/types.d.ts +35 -6
- package/dist/types/platform/types.js.map +1 -1
- package/package.json +16 -5
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
* `{ error: { code, message } }` envelope.
|
|
4
4
|
*
|
|
5
5
|
* `code` values worth branching on: `invalid_request` (400), `invalid_api_key` (401),
|
|
6
|
-
* `payment_required`
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* `payment_required` / `spend_cap_reached` (402), `robots_disallowed` (403), `job_not_found`
|
|
7
|
+
* (404), `rate_limited` / `too_many_jobs` (429, `retryAfter` set when the server sends it),
|
|
8
|
+
* `engine_unavailable` / `result_unavailable` / `scheduling_unknown` (503). 401 and 402
|
|
9
|
+
* messages end with a hint naming the deployment's dashboard. The client never retries on its
|
|
10
|
+
* own; a caller that wants backoff should honour `retryAfter` when present.
|
|
9
11
|
*
|
|
10
12
|
* Network-level failures (DNS, refused connections) are NOT wrapped — they propagate as the
|
|
11
13
|
* runtime's own `fetch` errors. `code` is `invalid_response` when the server answered with
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/platform/error.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/platform/error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAM1C,YAAY,IAAY,EAAE,OAAe,EAAE,MAAc,EAAE,UAAmB;QAC7E,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,CAAC;CACD"}
|
|
@@ -14,6 +14,8 @@ export interface FetchRequestInit {
|
|
|
14
14
|
method: string;
|
|
15
15
|
headers?: Record<string, string>;
|
|
16
16
|
body?: string;
|
|
17
|
+
/** Cancels an in-flight status request when polling stops or times out. */
|
|
18
|
+
signal?: AbortSignal;
|
|
17
19
|
}
|
|
18
20
|
/** The subset of a Response the client reads. */
|
|
19
21
|
export interface FetchResponseLike {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/platform/fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/platform/fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAqBH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAkB,EAAa,EAAE;IAC7D,IAAI,MAAM,EAAE,CAAC;QACZ,OAAO,MAAM,CAAC;IACf,CAAC;IACD,MAAM,WAAW,GAAI,UAAoC,CAAC,KAAK,CAAC;IAChE,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,kGAAkG,CAAC,CAAC;IACrH,CAAC;IACD,OAAO,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACrC,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { DEFAULT_BASE_URL, createPlatformClient, type PlatformClient, type PlatformClientOptions, type WaitForJobOptions, } from "./client";
|
|
2
2
|
export { PlatformApiError } from "./error";
|
|
3
3
|
export type { FetchLike, FetchRequestInit, FetchResponseLike } from "./fetch";
|
|
4
|
-
export { ENGINES, REGIONS, isStoredPageStub, type BatchOptions, type ConvertOptions, type CrawlOptions, type DemoResult, type DemoScrapeOptions, type Engine, type ExtractorPreset, type JobRef, type JobResultItem, type JobResultsPage, type JobState, type JobStatus, type JobType, type PageError, type PageFailure, type PageResult, type PageSuccess, type Region, type ScrapeOptions, type ScrapeResult, type StoredPageStub, } from "./types";
|
|
4
|
+
export { CRAWL_SITEMAP_MODES, ENGINES, REGIONS, REQUESTED_ENGINES, isStoredPageStub, type BatchOptions, type ConvertOptions, type CrawlOptions, type CrawlSitemapMode, type DemoResult, type DemoScrapeOptions, type Engine, type ExtractorPreset, type JobRef, type JobResultItem, type JobResultsPage, type JobState, type JobStatus, type JobType, type PageError, type PageFailure, type PageResult, type PageSuccess, type Region, type RequestedEngine, type ScrapeOptions, type ScrapeResult, type StoredPageStub, } from "./types";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/platform/index.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,OAAO,EACN,gBAAgB,EAChB,oBAAoB,GAIpB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EACN,OAAO,EACP,OAAO,EACP,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/platform/index.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,OAAO,EACN,gBAAgB,EAChB,oBAAoB,GAIpB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EACN,mBAAmB,EACnB,OAAO,EACP,OAAO,EACP,iBAAiB,EACjB,gBAAgB,GAwBhB,MAAM,SAAS,CAAC"}
|
|
@@ -8,8 +8,16 @@
|
|
|
8
8
|
/** How the platform acquires the page's HTML. */
|
|
9
9
|
export declare const ENGINES: readonly ["fetch", "browser", "proxy-fetch", "proxy-browser"];
|
|
10
10
|
export type Engine = (typeof ENGINES)[number];
|
|
11
|
+
/**
|
|
12
|
+
* What a request may ask for: a concrete engine, or `auto` (the server default) — the
|
|
13
|
+
* cheapest engine for the request, escalated to browser rendering when the fetched HTML is
|
|
14
|
+
* a client-rendered shell. Responses report the concrete engine that ran.
|
|
15
|
+
*/
|
|
16
|
+
export declare const REQUESTED_ENGINES: readonly ["fetch", "browser", "proxy-fetch", "proxy-browser", "auto"];
|
|
17
|
+
export type RequestedEngine = (typeof REQUESTED_ENGINES)[number];
|
|
11
18
|
/** Coarse egress location, honoured by the proxy engines only. */
|
|
12
|
-
|
|
19
|
+
/** Egress regions the hosted platform can honour (Japan, or no geo-targeting). */
|
|
20
|
+
export declare const REGIONS: readonly ["auto", "jp"];
|
|
13
21
|
export type Region = (typeof REGIONS)[number];
|
|
14
22
|
/** Extraction presets understood by the platform (passed through to the webforai library). */
|
|
15
23
|
export type ExtractorPreset = "auto" | "takumi" | "minimal" | "none";
|
|
@@ -21,13 +29,19 @@ export interface ConvertOptions {
|
|
|
21
29
|
baseUrl?: string;
|
|
22
30
|
}
|
|
23
31
|
interface CommonRequestOptions {
|
|
24
|
-
/** Defaults to `
|
|
25
|
-
engine?:
|
|
32
|
+
/** Defaults to `auto` server-side. */
|
|
33
|
+
engine?: RequestedEngine;
|
|
26
34
|
/** Browser engines only (`browser`, `proxy-browser`); +1 credit. */
|
|
27
35
|
screenshot?: boolean;
|
|
28
36
|
/** Re-upload the page's images behind expiring URLs; +1 credit per started 5 images. */
|
|
29
37
|
rehostImages?: boolean;
|
|
30
38
|
region?: Region;
|
|
39
|
+
/**
|
|
40
|
+
* Honor the target site's robots.txt rules: each URL is checked before it is fetched, and a
|
|
41
|
+
* disallowed URL fails with `robots_disallowed` (never billed). Defaults to `false` for
|
|
42
|
+
* scrape and batch and to `true` for crawl (pass `false` to turn it off).
|
|
43
|
+
*/
|
|
44
|
+
respectRobotsTxt?: boolean;
|
|
31
45
|
convert?: ConvertOptions;
|
|
32
46
|
}
|
|
33
47
|
export interface ScrapeOptions extends CommonRequestOptions {
|
|
@@ -37,6 +51,13 @@ export interface BatchOptions extends CommonRequestOptions {
|
|
|
37
51
|
/** 1–100 URLs. */
|
|
38
52
|
urls: string[];
|
|
39
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* How a crawl uses the site's sitemaps (robots.txt `Sitemap:` lines, else `/sitemap.xml`):
|
|
56
|
+
* `skip` (default) ignores them; `include` adds their same-origin URLs at depth 1 next to the
|
|
57
|
+
* links found on pages; `only` crawls the seed plus sitemap URLs and follows no page links.
|
|
58
|
+
*/
|
|
59
|
+
export declare const CRAWL_SITEMAP_MODES: readonly ["skip", "include", "only"];
|
|
60
|
+
export type CrawlSitemapMode = (typeof CRAWL_SITEMAP_MODES)[number];
|
|
40
61
|
export interface CrawlOptions extends CommonRequestOptions {
|
|
41
62
|
url: string;
|
|
42
63
|
/** 0–5, default 2. */
|
|
@@ -48,10 +69,13 @@ export interface CrawlOptions extends CommonRequestOptions {
|
|
|
48
69
|
excludePaths?: string[];
|
|
49
70
|
/** The platform currently only supports same-origin crawls; sending `false` is a 400. */
|
|
50
71
|
sameOrigin?: true;
|
|
72
|
+
/** Seed the crawl from the site's sitemaps; default `skip`. See {@link CRAWL_SITEMAP_MODES}. */
|
|
73
|
+
sitemap?: CrawlSitemapMode;
|
|
51
74
|
}
|
|
52
75
|
export interface ScrapeResult {
|
|
53
76
|
/** Final URL after redirects. */
|
|
54
77
|
url: string;
|
|
78
|
+
/** The engine that produced the result — `auto` requests resolve to a concrete one. */
|
|
55
79
|
engine: Engine;
|
|
56
80
|
markdown: string;
|
|
57
81
|
metadata: Record<string, unknown>;
|
|
@@ -63,6 +87,8 @@ export interface ScrapeResult {
|
|
|
63
87
|
original: string;
|
|
64
88
|
rehosted: string;
|
|
65
89
|
}[];
|
|
90
|
+
/** Present when the result is probably degraded (e.g. an unrendered client-side shell). */
|
|
91
|
+
warning?: string;
|
|
66
92
|
}
|
|
67
93
|
export interface JobRef {
|
|
68
94
|
jobId: string;
|
|
@@ -92,7 +118,8 @@ export type PageSuccess = ScrapeResult & {
|
|
|
92
118
|
export interface PageFailure {
|
|
93
119
|
status: "error";
|
|
94
120
|
url: string;
|
|
95
|
-
engine
|
|
121
|
+
/** As requested — a failed `auto` page never resolved to a concrete engine. */
|
|
122
|
+
engine: RequestedEngine;
|
|
96
123
|
error: PageError;
|
|
97
124
|
}
|
|
98
125
|
/** One page of an async job, after the client resolves any spilled results. */
|
|
@@ -105,7 +132,7 @@ export type PageResult = PageSuccess | PageFailure;
|
|
|
105
132
|
export interface StoredPageStub {
|
|
106
133
|
status: "ok";
|
|
107
134
|
url: string;
|
|
108
|
-
engine:
|
|
135
|
+
engine: RequestedEngine;
|
|
109
136
|
credits: number;
|
|
110
137
|
resultUrl: string;
|
|
111
138
|
}
|
|
@@ -124,7 +151,9 @@ export interface DemoScrapeOptions {
|
|
|
124
151
|
export interface DemoResult {
|
|
125
152
|
url: string;
|
|
126
153
|
region: Region;
|
|
127
|
-
/**
|
|
154
|
+
/** The engine `auto` resolved to. Absent from deployments older than 2026-09-24. */
|
|
155
|
+
engine?: Engine;
|
|
156
|
+
/** Truncated to ~40,000 characters by the demo endpoint (~8000 before 2026-09-24). */
|
|
128
157
|
markdown: string;
|
|
129
158
|
truncated: boolean;
|
|
130
159
|
title?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/platform/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,iDAAiD;AACjD,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,CAAU,CAAC;AAGrF,kEAAkE;AAClE,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/platform/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,iDAAiD;AACjD,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,CAAU,CAAC;AAGrF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAG,OAAO,EAAE,MAAM,CAAU,CAAC;AAG/D,kEAAkE;AAClE,kFAAkF;AAClF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,IAAI,CAAU,CAAC;AAwC/C;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAU,CAAC;AAiHxE,+DAA+D;AAC/D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAmB,EAA0B,EAAE,CAC/E,IAAI,CAAC,MAAM,KAAK,IAAI,IAAI,WAAW,IAAI,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,23 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webforai",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"description": "Convert web pages and local HTML to clean, LLM-ready Markdown: library, CLI (npx webforai) and hosted-API client.",
|
|
5
5
|
"author": "inaridiy",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"keywords": [
|
|
8
|
-
"
|
|
8
|
+
"html-to-markdown",
|
|
9
|
+
"markdown",
|
|
10
|
+
"llm",
|
|
9
11
|
"ai",
|
|
12
|
+
"scraper",
|
|
13
|
+
"crawler",
|
|
14
|
+
"readability",
|
|
15
|
+
"web-scraping",
|
|
16
|
+
"cli",
|
|
17
|
+
"rag",
|
|
10
18
|
"html",
|
|
11
19
|
"html2md",
|
|
12
|
-
"markdown",
|
|
13
20
|
"mdast",
|
|
14
21
|
"hast"
|
|
15
22
|
],
|
|
16
23
|
"repository": {
|
|
17
24
|
"type": "git",
|
|
18
|
-
"url": "https://github.com/inaridiy/webforai.git"
|
|
25
|
+
"url": "https://github.com/inaridiy/webforai.git",
|
|
26
|
+
"directory": "packages/webforai"
|
|
19
27
|
},
|
|
20
28
|
"homepage": "https://webforai.dev/",
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/inaridiy/webforai/issues"
|
|
31
|
+
},
|
|
21
32
|
"files": [
|
|
22
33
|
"dist",
|
|
23
34
|
"!dist/types/**/*.js"
|