polite-crawler 0.1.2 → 0.1.4
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 +555 -8
- package/build/cli-daemon-ZYRdy6EW.mjs +38 -0
- package/build/cli-daemon-ZYRdy6EW.mjs.map +1 -0
- package/build/cli-recipes-Bci6HREA.mjs +59 -0
- package/build/cli-recipes-Bci6HREA.mjs.map +1 -0
- package/build/cli.mjs +673 -26
- package/build/cli.mjs.map +1 -1
- package/build/daemon-DK6U51_v.mjs +515 -0
- package/build/daemon-DK6U51_v.mjs.map +1 -0
- package/build/{open-Ca1lcWR3.d.mts → daemon-wwIWsUmU.d.mts} +919 -17
- package/build/{diff-Dk2eSvi-.mjs → diff-BUM91Rev.mjs} +2 -2
- package/build/{diff-Dk2eSvi-.mjs.map → diff-BUM91Rev.mjs.map} +1 -1
- package/build/{extract-DcwNrTK7.mjs → extract-CefB5Vfn.mjs} +2 -2
- package/build/{extract-DcwNrTK7.mjs.map → extract-CefB5Vfn.mjs.map} +1 -1
- package/build/hours.d.mts +26 -0
- package/build/hours.mjs +48 -1
- package/build/hours.mjs.map +1 -1
- package/build/index.d.mts +491 -11
- package/build/index.mjs +14 -9
- package/build/loopback-C_QYowSf.mjs +22 -0
- package/build/loopback-C_QYowSf.mjs.map +1 -0
- package/build/mcp.d.mts +158 -2
- package/build/mcp.mjs +567 -18
- package/build/mcp.mjs.map +1 -1
- package/build/ollama-BJxkjny4.mjs +160 -0
- package/build/ollama-BJxkjny4.mjs.map +1 -0
- package/build/{open-DnrWgkC0.mjs → open-CbpSCEZc.mjs} +1127 -16
- package/build/open-CbpSCEZc.mjs.map +1 -0
- package/build/recipe-GiFQojmo.mjs +279 -0
- package/build/recipe-GiFQojmo.mjs.map +1 -0
- package/build/recipe-product-Dellqudu.mjs +892 -0
- package/build/recipe-product-Dellqudu.mjs.map +1 -0
- package/build/{runtime-k8mo1_7U.mjs → runtime-D_r2SYge.mjs} +3 -3
- package/build/{runtime-k8mo1_7U.mjs.map → runtime-D_r2SYge.mjs.map} +1 -1
- package/build/transformers-BQMlaGj4.mjs +133 -0
- package/build/transformers-BQMlaGj4.mjs.map +1 -0
- package/build/{duration-iIuMMofi.mjs → version-BPem-XZd.mjs} +10 -10
- package/build/version-BPem-XZd.mjs.map +1 -0
- package/build/{wacz-sfOLT8e9.mjs → wacz-QyzLp4mC.mjs} +3 -3
- package/build/{wacz-sfOLT8e9.mjs.map → wacz-QyzLp4mC.mjs.map} +1 -1
- package/build/{warc-VIPscWxY.mjs → warc-BHcaRKHw.mjs} +2 -2
- package/build/{warc-VIPscWxY.mjs.map → warc-BHcaRKHw.mjs.map} +1 -1
- package/build/webbotauth-CjJdTAfE.mjs.map +1 -1
- package/package.json +10 -2
- package/build/duration-iIuMMofi.mjs.map +0 -1
- package/build/open-DnrWgkC0.mjs.map +0 -1
package/build/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DAYS, Day, Hours, Interval, Week, describeWeek, disagreements, fromCompact, fromSchemaOrg, fromText, toHoursWeek } from "./hours.mjs";
|
|
1
|
+
import { DAYS, Day, Hours, HoursComparison, Interval, Week, compareHours, describeWeek, disagreements, fromCompact, fromSchemaOrg, fromText, toHoursWeek } from "./hours.mjs";
|
|
2
2
|
import { t as ScopeOptions } from "./urls-BTDSgDLC.mjs";
|
|
3
3
|
import { a as typesOf, c as decodeBody, n as PageLink, r as extractPage, s as bodyEncoding, t as PageExtract } from "./html-BACljlkf.mjs";
|
|
4
|
-
import { $ as
|
|
4
|
+
import { $ as RECIPE_LIMITS, $n as FetchOutcome, $r as ReadOptions, $t as checkFields, A as RuntimeOptions, Ai as PlaywrightRenderer, An as DiffHunk, Ar as Found, At as VectorWrite, B as WatchEvent, Bn as VersionChoice, Br as Archived, Bt as ExtractOptions, C as FetchOptions, Ci as ScanOptions, Cn as SitemapEntry, Cr as DocDigest, Ct as createHybridSearch, D as OpenedCrawler, Di as Duration, Dn as feedDate, Dr as ExtractedDoc, Dt as VectorHit, E as OpenOptions, Ei as makeRecord, En as SitemapRead, Er as DocVersion, Et as VectorCounts, F as isMailbox, Fi as Renderer, Fn as DiffResult, Fr as ReadingIndex, Ft as CrawlRunOptions, G as WatchRun, Gn as CacheEntry, Gr as CatchUpResult, Gt as FieldCandidate, H as WatchList, Hn as diffDocument, Hr as archiveExtractor, Ht as ExtractSource, I as openCrawler, Ii as playwrightRenderer, In as DiffSide, Ir as SearchRank, It as CrawlStop, J as WatchStop, Jn as CrawlEvent, Jr as Extractors, Jt as FieldKind, K as WatchRunOptions, Kn as CacheIndex, Kr as CrawlRuntime, Kt as FieldCheck, L as WATCH_LIMITS, Li as BlobStore, Ln as DiffSummary, Lr as Variant, Lt as CrawlSummary, M as StoreRuntime, Mi as RenderOptions, Mn as DiffLimits, Mr as NO_EMBEDDER, Mt as CrawlOptions, N as createRuntime, Ni as RenderRefused, Nn as DiffLine, Nr as Passage, Nt as CrawlPage, O as PoliteCrawler, Oi as durationMs, On as readSitemap, Or as FAST_RANK_SHARE, Ot as VectorStore, P as defaultUserAgent, Pi as Rendered, Pn as DiffOptions, Pr as RankMode, Pt as CrawlRun, Q as runWatch, Qn as DEFAULT_SECRET_PARAMS, Qr as PageResult, Qt as FieldsChecked, R as WATCH_SCHEMA, Ri as FileBlobStore, Rn as MetaChange, Rr as VersionAt, Rt as UrlPattern, S as startDaemon, Si as DamagedLine, Sn as SITEMAP_LIMITS, Sr as Doc, St as Ranked, T as HybridCrawler, Ti as RecordInput, Tn as SitemapLimits, Tr as DocInput, Tt as VECTORS_SCHEMA, U as WatchOptions, Un as diffTexts, Ur as archivedDocId, Ut as ExtractSummary, V as WatchKind, Vn as WordPart, Vr as WebArchive, Vt as ExtractResult, W as WatchPending, Wn as CAPTURE_SCHEMA, Wr as CapturePayload, Wt as FIELD_KINDS, X as WatchStoreOptions, Xn as CrawlerOptions, Xr as Indexed, Xt as FieldSpan, Y as WatchStore, Yn as Crawler, Yr as HELD_BACK, Yt as FieldResult, Z as WatchSummary, Zn as DEADLINE_NOTE, Zr as PageOptions, Zt as FieldStatus, _ as WatchSchedule, _i as verifyQuote, _n as DiscoverSource, _r as verifySignature, _t as EmbedStop, a as DaemonDue, ai as fetchAndIndex, an as FusedRank, ar as KEY_DIRECTORY_PATH, at as RecipeExtract, b as readDaemonState, bi as CaptureLog, bn as discoverSite, br as egressLookup, bt as HybridSearch, c as DaemonMcpOptions, ci as heldBackMeta, cn as chunkText, cr as KeyInput, ct as RecipeResult, d as DaemonState, di as pageDocId, dn as fuseRanks, dr as SignatureCheck, dt as defineRecipe, ei as ReadResult, en as extractDocument, er as FetchRequest, et as RESERVED_RECIPES, f as DaemonStatus, fi as pageExtractor, fn as unitVector, fr as SignedRequest, ft as readJson, g as ScheduleResult, gi as renderAndIndex, gn as DiscoverRunOptions, gr as keyDirectory, gt as EmbedResult, h as ScheduleOptions, hi as reindex, hn as DiscoverResult, hr as createWebBotAuthSigner, ht as EmbedOptions, i as Daemon, ii as catchUpIndex, in as Embedder, ir as DirectoryKey, it as RecipeDoc, j as SearchOptions, ji as RefusedReason, jn as DiffInput, jr as Latest, jt as CRAWL_LIMITS, k as RankOptions, ki as NO_PLAYWRIGHT, kn as DIFF_LIMITS, kr as FindIndexOptions, kt as VectorStoreOptions, l as DaemonMcpService, li as isHeldBack, ln as chunkTokensOf, lr as RequestSigner, lt as RecipeRunOptions, m as DaemonTick, mi as recordOverride, mn as DiscoverOptions, mr as WebBotAuthSigner, mt as runRecipe, n as DAEMON_DEFAULTS, ni as VerifyOptions, nn as ChunkOptions, nr as RenderRequest, nt as RecipeCapture, o as DaemonMcpHooks, oi as fetchPage, on as HYBRID_DEFAULTS, or as KEY_DIRECTORY_TYPE, ot as RecipeRequest, p as DaemonTask, pi as readDocument, pn as DISCOVER_LIMITS, pr as WebBotAuthOptions, pt as registerRecipe, q as WatchRunnerOptions, qn as CaptureWriter, qr as Extractor, qt as FieldClaim, r as DAEMON_STATE_SCHEMA, ri as VerifyResult, rn as EmbedCallOptions, rr as renderedKey, rt as RecipeDefinition, s as DaemonMcpHost, si as findDocuments, sn as TextChunk, sr as KeyDirectory, st as RecipeRequestOptions, t as ChangeCommandOptions, ti as ReindexResult, tn as CHUNK_LIMITS, tr as Fetched, tt as Recipe, u as DaemonOptions, ui as isoTime, un as estimateTokens, ur as SignatureAgentType, ut as RecipeTarget, v as changeCommand, vi as versionAtTime, vn as DiscoverStop, vr as EgressOptions, vt as HybridFindOptions, w as FindOptions, wi as CaptureRecord, wn as SitemapKind, wr as DocIndex, wt as StoredChunk, x as scheduleWatches, xi as CaptureReader, xn as Changefreq, xr as DigestOptions, xt as HybridSearchOptions, y as daemonStateFile, yi as CaptureFilter, yn as DiscoveredUrl, yr as EgressRefused, yt as HybridOptions, z as WatchEntry, zn as TextDiff, zr as VersionText, zt as crawlSite } from "./daemon-wwIWsUmU.mjs";
|
|
5
5
|
import { r as Signals, t as AiInput } from "./signals-BHpy2xb2.mjs";
|
|
6
6
|
import { E as nextValidatorMemo, O as realClock, S as ValidatorVerdict, _ as VALIDATOR_MEMO, b as ValidatorMemo, f as PolicyOptions, i as HostResult, n as DEFAULT_POLICY, o as HostStateStore, p as PolitenessPolicy, r as HostCounts, s as HostStop, t as Clock, u as MemoryHostStateStore, v as ValidatorAnswer, x as ValidatorReport, y as ValidatorLimits } from "./politeness-yI3xBEx9.mjs";
|
|
7
7
|
import { a as Robots, c as RobotsRule, h as parseRobots, l as RobotsSignal, o as RobotsDecision, s as RobotsGroup, t as ALLOW_ALL, u as decide } from "./robots-R-qaEBOb.mjs";
|
|
@@ -32,6 +32,139 @@ interface Verified {
|
|
|
32
32
|
*/
|
|
33
33
|
export declare const locate: (text: string, quote: string) => Verified;
|
|
34
34
|
//#endregion
|
|
35
|
+
//#region src/version.d.ts
|
|
36
|
+
/** This is the version of the package. A test makes sure that it agrees with `package.json`. */
|
|
37
|
+
export declare const VERSION = "0.1.4";
|
|
38
|
+
/** This is the product token that robots.txt rules match when an application gives no token. */
|
|
39
|
+
export declare const DEFAULT_TOKEN = "PoliteCrawler";
|
|
40
|
+
/** This page tells a site owner what the crawler is and how to control it. */
|
|
41
|
+
export declare const BOT_PAGE = "https://mark1russell7.github.io/crawler/bot/";
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/ollama.d.ts
|
|
44
|
+
/**
|
|
45
|
+
* The Ollama embedder sends texts to the local HTTP API of Ollama (`POST /api/embed`). The package
|
|
46
|
+
* has no dependency for it: you install Ollama, start it (`ollama serve`) and pull a model
|
|
47
|
+
* (`ollama pull nomic-embed-text`).
|
|
48
|
+
*
|
|
49
|
+
* The page text goes to the Ollama server. Thus the embedder accepts only a server on this
|
|
50
|
+
* computer (a loopback address), unless `allowRemote` is true.
|
|
51
|
+
*/
|
|
52
|
+
/** These are the facts of the embedding models that the Ollama library has. */
|
|
53
|
+
interface EmbeddingModel {
|
|
54
|
+
readonly dimensions: number;
|
|
55
|
+
readonly maxInputTokens: number;
|
|
56
|
+
/** This prefix goes before the text of a question. */
|
|
57
|
+
readonly queryPrefix?: string | undefined;
|
|
58
|
+
/** This prefix goes before each chunk of a stored text. */
|
|
59
|
+
readonly documentPrefix?: string | undefined;
|
|
60
|
+
}
|
|
61
|
+
/** These are the facts of three embedding models of Ollama. The name has no tag (`nomic-embed-text`, not `nomic-embed-text:latest`). */
|
|
62
|
+
export declare const OLLAMA_MODELS: Readonly<Record<string, EmbeddingModel>>;
|
|
63
|
+
/** These options make an Ollama embedder. */
|
|
64
|
+
interface OllamaEmbedderOptions {
|
|
65
|
+
/** This value is the model of Ollama, with a tag when you want one. The default is `nomic-embed-text`. */
|
|
66
|
+
readonly model?: string | undefined;
|
|
67
|
+
/** This URL is the Ollama server. The default is `http://127.0.0.1:11434`. */
|
|
68
|
+
readonly baseUrl?: string | undefined;
|
|
69
|
+
/** This value is the number of texts in one request. The default is 32. */
|
|
70
|
+
readonly batch?: number | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* The value true lets `baseUrl` be a server on a different computer. The default is false,
|
|
73
|
+
* because the embedder sends the text of the stored pages to the server.
|
|
74
|
+
*/
|
|
75
|
+
readonly allowRemote?: boolean | undefined;
|
|
76
|
+
/** This value is the length of each vector. The default comes from `OLLAMA_MODELS`, or from the first answer. */
|
|
77
|
+
readonly dimensions?: number | undefined;
|
|
78
|
+
/** This value is the input limit of the model in tokens. The default comes from `OLLAMA_MODELS`, or it is 256. */
|
|
79
|
+
readonly maxInputTokens?: number | undefined;
|
|
80
|
+
/** This prefix goes before the text of a question. The default comes from `OLLAMA_MODELS`. */
|
|
81
|
+
readonly queryPrefix?: string | undefined;
|
|
82
|
+
/** This prefix goes before each chunk of a stored text. The default comes from `OLLAMA_MODELS`. */
|
|
83
|
+
readonly documentPrefix?: string | undefined;
|
|
84
|
+
/** This value is the longest time of one request in milliseconds. The default is 2 minutes, because the first request loads the model. */
|
|
85
|
+
readonly timeoutMs?: number | undefined;
|
|
86
|
+
}
|
|
87
|
+
/** The text of the error when no Ollama server answers. */
|
|
88
|
+
export declare const NO_OLLAMA = "Ollama does not answer: install it from https://ollama.com, then start it with ollama serve";
|
|
89
|
+
/** This function tells if a host name is a loopback address: `localhost`, `127.0.0.0/8` or `::1`. */
|
|
90
|
+
export declare const isLoopback: (host: string) => boolean;
|
|
91
|
+
/**
|
|
92
|
+
* This function makes an embedder that sends texts to Ollama (`POST {baseUrl}/api/embed`). It
|
|
93
|
+
* sends `batch` texts in each request, and it stops when the signal aborts. The errors tell what
|
|
94
|
+
* to do: `ollama serve` when no server answers, and `ollama pull <model>` when the model is not
|
|
95
|
+
* there. A `baseUrl` on a different computer throws a `RangeError`, unless `allowRemote` is true.
|
|
96
|
+
*/
|
|
97
|
+
export declare const ollamaEmbedder: (options?: OllamaEmbedderOptions) => Embedder;
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/transformers.d.ts
|
|
100
|
+
/**
|
|
101
|
+
* The transformers embedder uses an embedding model in this process, with transformers.js
|
|
102
|
+
* (`@huggingface/transformers`). The package is an optional peer: the embedder loads it at its
|
|
103
|
+
* first text, as the renderer loads `playwright-core` at its first page.
|
|
104
|
+
*
|
|
105
|
+
* The first use of a model downloads its files from the Hugging Face Hub (huggingface.co). That
|
|
106
|
+
* download does not go through the polite crawler. transformers.js keeps the files in `cacheDir`
|
|
107
|
+
* (its default is `node_modules/@huggingface/transformers/.cache/`), so the next use reads the disk.
|
|
108
|
+
*/
|
|
109
|
+
/** The text of the error when the optional package `@huggingface/transformers` is not installed. */
|
|
110
|
+
export declare const NO_TRANSFORMERS = "the transformers embedder needs the package @huggingface/transformers: npm install @huggingface/transformers. For the MCP server with npx, start it with npx -y -p polite-crawler -p @huggingface/transformers polite-crawler mcp --embedder transformers";
|
|
111
|
+
/** The pooling of the vectors of the tokens: their mean, or the vector of the first token (`cls`). */
|
|
112
|
+
type Pooling = "mean" | "cls";
|
|
113
|
+
/** These are the facts of the models that the embedder knows. Each one is on the Hugging Face Hub with ONNX files. */
|
|
114
|
+
export declare const TRANSFORMERS_MODELS: Readonly<Record<string, EmbeddingModel & {
|
|
115
|
+
readonly pooling: Pooling;
|
|
116
|
+
}>>;
|
|
117
|
+
/** These options make a transformers embedder. */
|
|
118
|
+
interface TransformersEmbedderOptions {
|
|
119
|
+
/** This value is the model on the Hugging Face Hub. The default is `Xenova/bge-small-en-v1.5` (384 dimensions, approximately 34 MB quantized). */
|
|
120
|
+
readonly model?: string | undefined;
|
|
121
|
+
/** The value true (the default) loads the 8-bit model (`dtype: "q8"`). The value false loads the 32-bit model, which is larger. */
|
|
122
|
+
readonly quantized?: boolean | undefined;
|
|
123
|
+
/** This folder keeps the files of the model. The default is the cache of transformers.js. */
|
|
124
|
+
readonly cacheDir?: string | undefined;
|
|
125
|
+
/** The value true uses only the files in the cache, with no download. The default is false. */
|
|
126
|
+
readonly localOnly?: boolean | undefined;
|
|
127
|
+
/** This value is the pooling of the model. The default comes from `TRANSFORMERS_MODELS`, or it is `mean`. */
|
|
128
|
+
readonly pooling?: Pooling | undefined;
|
|
129
|
+
/** This value is the length of each vector. The default comes from `TRANSFORMERS_MODELS`, or from the first answer. */
|
|
130
|
+
readonly dimensions?: number | undefined;
|
|
131
|
+
/** This value is the input limit of the model in tokens. The default comes from `TRANSFORMERS_MODELS`, or it is 256. */
|
|
132
|
+
readonly maxInputTokens?: number | undefined;
|
|
133
|
+
/** This prefix goes before the text of a question. The default comes from `TRANSFORMERS_MODELS`. */
|
|
134
|
+
readonly queryPrefix?: string | undefined;
|
|
135
|
+
/** This prefix goes before each chunk of a stored text. The default comes from `TRANSFORMERS_MODELS`. */
|
|
136
|
+
readonly documentPrefix?: string | undefined;
|
|
137
|
+
/** This value is the number of texts that the model reads at one time. The default is 8. */
|
|
138
|
+
readonly batch?: number | undefined;
|
|
139
|
+
}
|
|
140
|
+
/** This is the part of a feature-extraction pipeline of transformers.js that the embedder uses. */
|
|
141
|
+
interface FeatureExtractor {
|
|
142
|
+
(texts: string[], options: {
|
|
143
|
+
readonly pooling: Pooling;
|
|
144
|
+
readonly normalize: boolean;
|
|
145
|
+
}): Promise<{
|
|
146
|
+
readonly data: ArrayLike<number>;
|
|
147
|
+
readonly dims: readonly number[];
|
|
148
|
+
}>;
|
|
149
|
+
dispose?(): Promise<unknown>;
|
|
150
|
+
}
|
|
151
|
+
/** This is the part of the module `@huggingface/transformers` that the embedder uses. */
|
|
152
|
+
interface TransformersModule {
|
|
153
|
+
pipeline(task: "feature-extraction", model: string, options: {
|
|
154
|
+
readonly dtype: "q8" | "fp32";
|
|
155
|
+
readonly cache_dir?: string | undefined;
|
|
156
|
+
readonly local_files_only?: boolean | undefined;
|
|
157
|
+
}): Promise<FeatureExtractor>;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* This function makes an embedder that uses a model in this process with transformers.js. It loads
|
|
161
|
+
* the package and the model at its first text, one time. It pools the vectors of the tokens as the
|
|
162
|
+
* model expects (`cls` for BGE, `mean` for the others) and gives vectors with a length of 1. When
|
|
163
|
+
* the package is not installed, `embed` rejects with `NO_TRANSFORMERS`. The signal stops the work
|
|
164
|
+
* between two batches.
|
|
165
|
+
*/
|
|
166
|
+
export declare const transformersEmbedder: (options?: TransformersEmbedderOptions, load?: () => Promise<TransformersModule>) => Embedder;
|
|
167
|
+
//#endregion
|
|
35
168
|
//#region src/hoststate.d.ts
|
|
36
169
|
/** These options change a SQLite host state store. */
|
|
37
170
|
interface SqliteHostStateOptions {
|
|
@@ -92,14 +225,6 @@ export declare class SqliteHostStateStore implements HostStateStore {
|
|
|
92
225
|
close(): void;
|
|
93
226
|
}
|
|
94
227
|
//#endregion
|
|
95
|
-
//#region src/version.d.ts
|
|
96
|
-
/** This is the version of the package. A test makes sure that it agrees with `package.json`. */
|
|
97
|
-
export declare const VERSION = "0.1.2";
|
|
98
|
-
/** This is the product token that robots.txt rules match when an application gives no token. */
|
|
99
|
-
export declare const DEFAULT_TOKEN = "PoliteCrawler";
|
|
100
|
-
/** This page tells a site owner what the crawler is and how to control it. */
|
|
101
|
-
export declare const BOT_PAGE = "https://mark1russell7.github.io/crawler/bot/";
|
|
102
|
-
//#endregion
|
|
103
228
|
//#region src/pdf.d.ts
|
|
104
229
|
/**
|
|
105
230
|
* The crawler reads the text of a PDF. Restaurant menus are often PDFs: 29 of 231 surveyed
|
|
@@ -138,6 +263,361 @@ interface PdfOptions {
|
|
|
138
263
|
export declare const isPdf: (body: Uint8Array, contentType: string | null) => boolean;
|
|
139
264
|
export declare const readPdf: (bytes: Uint8Array, options?: PdfOptions) => Promise<PdfText>;
|
|
140
265
|
//#endregion
|
|
266
|
+
//#region src/recipe-venue.d.ts
|
|
267
|
+
/** These are the limits of the venue recipe. */
|
|
268
|
+
export declare const VENUE_LIMITS: {
|
|
269
|
+
/** The pages of the site that a read fetches after the home page, by default. */
|
|
270
|
+
readonly pages: number;
|
|
271
|
+
/** The most pages after the home page. */
|
|
272
|
+
readonly maxPages: number;
|
|
273
|
+
/** The most menu links of a result. */
|
|
274
|
+
readonly menus: number;
|
|
275
|
+
/** The most readings of one page. A page with more is a list of something else. */
|
|
276
|
+
readonly readingsPerPage: number;
|
|
277
|
+
/** The most links of one page that the recipe ranks. */
|
|
278
|
+
readonly links: number;
|
|
279
|
+
/** The distance in metres within which a JSON-LD location is the venue. */
|
|
280
|
+
readonly nearMetres: number;
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* This function tells if a page names a venue: the page has the first word of the name and 60
|
|
284
|
+
* percent of its words. A domain that a venue let go can show a different business. It gives
|
|
285
|
+
* undefined for a name with no word.
|
|
286
|
+
*/
|
|
287
|
+
export declare const namesVenue: (name: string, page: {
|
|
288
|
+
readonly title: string;
|
|
289
|
+
readonly text: string;
|
|
290
|
+
}) => boolean | undefined;
|
|
291
|
+
/**
|
|
292
|
+
* This function ranks the links of a page by the words of their text and path. The links to
|
|
293
|
+
* the hours or a menu come first. It keeps only the links on the site of `home`,
|
|
294
|
+
* and it leaves out the files (a PDF, an image) and the home page itself.
|
|
295
|
+
*/
|
|
296
|
+
export declare const rankHoursLinks: (links: readonly PageLink[], home: string) => PageLink[];
|
|
297
|
+
/** A link to a menu. */
|
|
298
|
+
interface VenueLink {
|
|
299
|
+
readonly url: string;
|
|
300
|
+
readonly text: string;
|
|
301
|
+
}
|
|
302
|
+
/** The place of a venue, to choose its hours on a page that lists more than one location. */
|
|
303
|
+
interface VenueLocation {
|
|
304
|
+
/** This text is the street address, for example `12 Via Esempio`. The number and the street count. */
|
|
305
|
+
readonly address?: string | undefined;
|
|
306
|
+
readonly lat?: number | undefined;
|
|
307
|
+
readonly lon?: number | undefined;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* This function tells if a JSON-LD location record is the venue. The record must have the same
|
|
311
|
+
* number on a street that shares a word, or a position near the venue (`VENUE_LIMITS.nearMetres`).
|
|
312
|
+
*/
|
|
313
|
+
export declare const locationMatches: (record: Readonly<Record<string, unknown>>, location: VenueLocation) => boolean;
|
|
314
|
+
/** One reading of the hours, with the source that it came from. */
|
|
315
|
+
interface VenueReading {
|
|
316
|
+
/** The value `jsonld` is the structured data of a page, `text` the text of a page, and `osm` the value of the caller. */
|
|
317
|
+
readonly from: "jsonld" | "osm" | "text";
|
|
318
|
+
/**
|
|
319
|
+
* This value orders the readings, 0 first. JSON-LD is 0, a text under an hours heading is 1 and
|
|
320
|
+
* OpenStreetMap is 2. A text with no label of a different schedule is 3. A different schedule is
|
|
321
|
+
* 4, for example a brunch, a kitchen, a happy hour or an office.
|
|
322
|
+
*/
|
|
323
|
+
readonly rank: number;
|
|
324
|
+
/** The value `opening` is the opening hours of the venue (a rank of 3 or less). Else it is `other`. */
|
|
325
|
+
readonly schedule: "opening" | "other";
|
|
326
|
+
/** This text is the line above a reading of the text, for example `Hours` or `Happy hour`. */
|
|
327
|
+
readonly label: string | null;
|
|
328
|
+
/** This text is the week as words, from `describeWeek`. */
|
|
329
|
+
readonly hours: string;
|
|
330
|
+
readonly week: Week;
|
|
331
|
+
/** This value is true when the reader guessed an am or a pm. */
|
|
332
|
+
readonly inferred: boolean;
|
|
333
|
+
/** This value is true when the reader left out a rule or a line (a holiday, a date). */
|
|
334
|
+
readonly partial: boolean;
|
|
335
|
+
/** This text names the season or the dates of the hours. */
|
|
336
|
+
readonly season: string | null;
|
|
337
|
+
/** This text is the words that the hours came from. A reading of the text can be a quote for `verify`. */
|
|
338
|
+
readonly raw: string;
|
|
339
|
+
/** This path names the JSON-LD record of the reading in the metadata of the document, for example `jsonld[2]`. */
|
|
340
|
+
readonly path: string | null;
|
|
341
|
+
/** This URL is the page of the reading. */
|
|
342
|
+
readonly url: string | null;
|
|
343
|
+
readonly doc: string | null;
|
|
344
|
+
/** This id is the capture of the text that the reading came from. A citation names it. */
|
|
345
|
+
readonly capture: string | null;
|
|
346
|
+
readonly fetched_at: string | null;
|
|
347
|
+
/** This value tells that the page is an archived copy, with the archive and the date of the copy. */
|
|
348
|
+
readonly archived?: Archived | undefined;
|
|
349
|
+
}
|
|
350
|
+
/** A stored document, or a version of one: what `venueReadingsOf` reads. */
|
|
351
|
+
interface VenueSource {
|
|
352
|
+
readonly doc?: string | null | undefined;
|
|
353
|
+
readonly url: string | null;
|
|
354
|
+
readonly text: string;
|
|
355
|
+
readonly meta: Readonly<Record<string, unknown>>;
|
|
356
|
+
readonly capture?: string | null | undefined;
|
|
357
|
+
readonly fetched_at?: string | null | undefined;
|
|
358
|
+
}
|
|
359
|
+
/** The result of `venueReadingsOf`: what one document says. */
|
|
360
|
+
interface VenueRead {
|
|
361
|
+
readonly readings: readonly VenueReading[];
|
|
362
|
+
/** This value is the first `telephone` of the JSON-LD records of the venue. */
|
|
363
|
+
readonly phone: string | null;
|
|
364
|
+
readonly menus: readonly VenueLink[];
|
|
365
|
+
readonly notes: readonly string[];
|
|
366
|
+
/** This value counts the work of the reader. The tests use it, because it does not change with the computer. */
|
|
367
|
+
readonly steps: number;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* This function reads the hours of one stored document, or of one version of it. It is pure, and
|
|
371
|
+
* it sends no request. Thus it also reads a version at a time (`versionAtTime`) or an archived copy.
|
|
372
|
+
*
|
|
373
|
+
* - It reads each JSON-LD record of a venue type with `fromSchemaOrg`, and the text with `fromText`.
|
|
374
|
+
* - On a page that lists more than one location, it reads only the location that matches
|
|
375
|
+
* `location`. With no `location`, it reads none of them, and a note says so.
|
|
376
|
+
* - It gives the first `telephone` and the menu links that are not on a review or social site.
|
|
377
|
+
*/
|
|
378
|
+
export declare const venueReadingsOf: (source: VenueSource, options?: {
|
|
379
|
+
readonly location?: VenueLocation | undefined;
|
|
380
|
+
}) => VenueRead;
|
|
381
|
+
/** An OpenStreetMap `opening_hours` value, with where the caller got it. */
|
|
382
|
+
interface VenueOsm {
|
|
383
|
+
/** This text is the value of the tag, for example `Mo-Fr 08:00-18:00; Sa 09:00-13:00`. */
|
|
384
|
+
readonly value: string;
|
|
385
|
+
readonly url?: string | null | undefined;
|
|
386
|
+
readonly doc?: string | null | undefined;
|
|
387
|
+
readonly capture?: string | null | undefined;
|
|
388
|
+
readonly fetched_at?: string | null | undefined;
|
|
389
|
+
}
|
|
390
|
+
/** These options control `readVenue`. */
|
|
391
|
+
interface VenueOptions {
|
|
392
|
+
/** This value is the number of pages after the home page, from 0 to `VENUE_LIMITS.maxPages`. The default is 3. */
|
|
393
|
+
readonly pages?: number | undefined;
|
|
394
|
+
/** This text is the name of the venue. The result tells if the home page names it (`names_venue`). */
|
|
395
|
+
readonly name?: string | undefined;
|
|
396
|
+
/** With true, a home page that does not name the venue gives no reading, and the recipe fetches no more pages. */
|
|
397
|
+
readonly requireName?: boolean | undefined;
|
|
398
|
+
/** This value is the place of the venue, for a page that lists more than one location. */
|
|
399
|
+
readonly location?: VenueLocation | undefined;
|
|
400
|
+
/** This value is an OpenStreetMap `opening_hours` value. The recipe reads it, and sends no request for it. */
|
|
401
|
+
readonly osm?: string | VenueOsm | undefined;
|
|
402
|
+
/** The value `auto` renders a page only when it shows almost nothing without JavaScript. */
|
|
403
|
+
readonly render?: "auto" | "never" | "always" | undefined;
|
|
404
|
+
/** A stored copy younger than this age answers with no request. The default is `24h`. */
|
|
405
|
+
readonly maxAge?: Duration | undefined;
|
|
406
|
+
/** These agents get their robots.txt rules applied too, for example `Claude-User`. */
|
|
407
|
+
readonly onBehalfOf?: readonly string[] | undefined;
|
|
408
|
+
readonly signal?: AbortSignal | undefined;
|
|
409
|
+
/** No request starts after this time from the start of the read, for example `"2m"`. */
|
|
410
|
+
readonly budget?: Duration | undefined;
|
|
411
|
+
readonly scope?: string | undefined;
|
|
412
|
+
readonly labels?: Readonly<Record<string, string>> | undefined;
|
|
413
|
+
/** This name connects the captures to the job that asked for them. The default is `venue`. */
|
|
414
|
+
readonly job?: string | undefined;
|
|
415
|
+
/** This value is true when a person gave this URL directly. It is the only way to read a held-back page. The crawler logs it. */
|
|
416
|
+
readonly userProvided?: boolean | undefined;
|
|
417
|
+
/** The value `archive` reads an archived copy of a page that the site refuses, or when the site is down. */
|
|
418
|
+
readonly fallback?: "archive" | "none" | undefined;
|
|
419
|
+
readonly archiveDespiteRobots?: boolean | undefined;
|
|
420
|
+
}
|
|
421
|
+
/** One page that the venue recipe fetched. */
|
|
422
|
+
interface VenuePage {
|
|
423
|
+
readonly url: string;
|
|
424
|
+
readonly doc: string | null;
|
|
425
|
+
readonly outcome: string;
|
|
426
|
+
readonly status: number;
|
|
427
|
+
readonly rendered: boolean;
|
|
428
|
+
readonly capture: string | null;
|
|
429
|
+
readonly fetched_at: string | null;
|
|
430
|
+
readonly from_cache: boolean;
|
|
431
|
+
readonly held_back: boolean;
|
|
432
|
+
readonly archived?: Archived | undefined;
|
|
433
|
+
readonly note: string | null;
|
|
434
|
+
}
|
|
435
|
+
/** The result of `readVenue`. */
|
|
436
|
+
interface VenueResult {
|
|
437
|
+
/** This URL is the site that the caller gave. */
|
|
438
|
+
readonly url: string;
|
|
439
|
+
/** This URL is where the home page landed, after the redirects. */
|
|
440
|
+
readonly home: string | null;
|
|
441
|
+
/** This URL is the new site, when the home page landed on a different host. */
|
|
442
|
+
readonly moved: string | null;
|
|
443
|
+
/** This value tells if the home page names the venue. It is null with no `name`. */
|
|
444
|
+
readonly names_venue: boolean | null;
|
|
445
|
+
readonly pages: readonly VenuePage[];
|
|
446
|
+
/** These are the readings, one for each source, label and week: the best first. */
|
|
447
|
+
readonly readings: readonly VenueReading[];
|
|
448
|
+
/** This reading is the best reading of the opening hours, from any source. */
|
|
449
|
+
readonly best: VenueReading | null;
|
|
450
|
+
/** This reading is the best reading of the site itself (not OpenStreetMap) with no guess. A check for a change compares it. */
|
|
451
|
+
readonly from_site: VenueReading | null;
|
|
452
|
+
/** These days are the days where two readings of the whole schedule (a rank of 2 or less) disagree. */
|
|
453
|
+
readonly disagree: readonly Day[];
|
|
454
|
+
readonly menus: readonly VenueLink[];
|
|
455
|
+
readonly phone: string | null;
|
|
456
|
+
/** These ids are the captures of the pages that the recipe read. */
|
|
457
|
+
readonly captures: readonly string[];
|
|
458
|
+
/** This value is true when a page asked not to be AI input, so the recipe read nothing from it. */
|
|
459
|
+
readonly held_back: boolean;
|
|
460
|
+
readonly note: string | null;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* This function reads the hours of a venue from its site. It fetches the home page and the pages
|
|
464
|
+
* that most likely hold hours or a menu. Each one is a fetch of the crawler. Thus robots.txt, the
|
|
465
|
+
* pace, the stops, the capture log and the rule for a held-back page apply. It renders a page only
|
|
466
|
+
* when the page needs JavaScript, as `fetch` does.
|
|
467
|
+
*
|
|
468
|
+
* It gives each reading with its source, the best reading, and the days where the readings
|
|
469
|
+
* disagree. It writes nothing but the capture log. To choose the true hours is the decision of
|
|
470
|
+
* the application.
|
|
471
|
+
*/
|
|
472
|
+
export declare const readVenue: (target: RecipeTarget, url: string, options?: VenueOptions) => Promise<VenueResult>;
|
|
473
|
+
//#endregion
|
|
474
|
+
//#region src/recipe-product.d.ts
|
|
475
|
+
type Json = Readonly<Record<string, unknown>>;
|
|
476
|
+
/** These are the limits of the product reader. A page with more is hostile or broken, and the reader stops there. */
|
|
477
|
+
export declare const PRODUCT_LIMITS: {
|
|
478
|
+
/** The most JSON-LD records that the reader examines. */
|
|
479
|
+
readonly records: number;
|
|
480
|
+
/** The most offers of one product or variant. */
|
|
481
|
+
readonly offers: number;
|
|
482
|
+
/** The most variants of one product. */
|
|
483
|
+
readonly variants: number;
|
|
484
|
+
/** The levels of `hasVariant` and of nested offers that the reader follows. */
|
|
485
|
+
readonly depth: number;
|
|
486
|
+
/** The longest text of a price. */
|
|
487
|
+
readonly priceChars: number;
|
|
488
|
+
};
|
|
489
|
+
/** An amount of money, as schema.org Product data gives it. */
|
|
490
|
+
interface Money {
|
|
491
|
+
/** This value is the amount in the unit of the currency, for example 12.5. */
|
|
492
|
+
readonly amount: number;
|
|
493
|
+
/** This value is the ISO 4217 code of the currency, for example `EUR`. */
|
|
494
|
+
readonly currency: string;
|
|
495
|
+
/** This text is the price as the page wrote it, for a check with `extract`. */
|
|
496
|
+
readonly raw: string;
|
|
497
|
+
}
|
|
498
|
+
/** The variant of a product that the URL names. */
|
|
499
|
+
interface ProductVariant {
|
|
500
|
+
readonly name: string | null;
|
|
501
|
+
readonly sku: string | null;
|
|
502
|
+
readonly price: Money | null;
|
|
503
|
+
readonly availability: string | null;
|
|
504
|
+
}
|
|
505
|
+
/** The result of `productOf`: what the Product data of a page says. */
|
|
506
|
+
interface ProductRead {
|
|
507
|
+
/** This value is true when the page has a Product record. */
|
|
508
|
+
readonly found: boolean;
|
|
509
|
+
readonly name: string | null;
|
|
510
|
+
readonly brand: string | null;
|
|
511
|
+
readonly sku: string | null;
|
|
512
|
+
readonly gtin: string | null;
|
|
513
|
+
/** This value is the lowest price of the offers, in the first currency of the page. */
|
|
514
|
+
readonly price: Money | null;
|
|
515
|
+
/** This value is the highest price, when the offers give a range (sizes, colors, variants). */
|
|
516
|
+
readonly price_to: Money | null;
|
|
517
|
+
/**
|
|
518
|
+
* This value is the schema.org name of the availability, for example `InStock`. When the offers
|
|
519
|
+
* do not agree, it is `InStock` if one offer is in stock, and `availabilities` gives each value.
|
|
520
|
+
*/
|
|
521
|
+
readonly availability: string | null;
|
|
522
|
+
readonly availabilities: readonly string[];
|
|
523
|
+
/** This value is the variant that the URL names (`?variant=`, `sku` or `gtin`), read alone. */
|
|
524
|
+
readonly variant: ProductVariant | null;
|
|
525
|
+
readonly seller: string | null;
|
|
526
|
+
readonly image: string | null;
|
|
527
|
+
readonly notes: readonly string[];
|
|
528
|
+
/** This value counts the work of the reader. The tests use it, because it does not change with the computer. */
|
|
529
|
+
readonly steps: number;
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* This function reads an amount as a shop writes it: `19.99`, `1,299.00`, `1.299,00`, `$19.99` or
|
|
533
|
+
* the number 19.99. The last separator is the decimal point, with one exception. One kind of
|
|
534
|
+
* separator, each followed by three digits, separates thousands: `1.299` is 1299. For a
|
|
535
|
+
* currency with three decimal digits, one point with three digits is the decimal point. A text
|
|
536
|
+
* with two numbers (a range), a negative amount or zero gives undefined.
|
|
537
|
+
*/
|
|
538
|
+
export declare const readAmount: (value: unknown, currency?: string) => number | undefined;
|
|
539
|
+
/**
|
|
540
|
+
* This function picks the product of a page from its JSON-LD records. A page often has more
|
|
541
|
+
* records of products: the related products, the products that others bought. It picks:
|
|
542
|
+
*
|
|
543
|
+
* 1. The product whose `url` or `@id` is the page (the path, with no query).
|
|
544
|
+
* 2. Else the largest product with offers or variants.
|
|
545
|
+
* 3. Else the largest product.
|
|
546
|
+
*
|
|
547
|
+
* It also reads the `mainEntity` of a record (a `WebPage` or an `ItemPage` that names its product).
|
|
548
|
+
*/
|
|
549
|
+
export declare const pickProduct: (records: readonly Json[], page: string) => {
|
|
550
|
+
readonly product: Json | undefined;
|
|
551
|
+
readonly steps: number;
|
|
552
|
+
};
|
|
553
|
+
/** This function gives the variant that a URL names: the `variant` parameter of Shopify, or a `sku` or `gtin` parameter. */
|
|
554
|
+
export declare const pickVariant: (product: Json, page: string) => Json | undefined;
|
|
555
|
+
/**
|
|
556
|
+
* This function reads the Product data of a page from its JSON-LD records. It is pure, and it sends
|
|
557
|
+
* no request. Thus it also reads a version at a time, or the stored JSON-LD of a document.
|
|
558
|
+
*
|
|
559
|
+
* - The prices are in the first currency of the offers. A price with no currency is not a price.
|
|
560
|
+
* - A list price or a struck-through price is not the price.
|
|
561
|
+
* - A currency must be an ISO 4217 code (`€` and `£` count too). The notes name each other one.
|
|
562
|
+
*/
|
|
563
|
+
export declare const productOf: (records: readonly Json[], page: string) => ProductRead;
|
|
564
|
+
/** These options control `readProduct`. */
|
|
565
|
+
interface ProductOptions {
|
|
566
|
+
/** The value `auto` (the default) renders once more when the plain page has no Product data. `never` does not render. */
|
|
567
|
+
readonly render?: "auto" | "never" | "always" | undefined;
|
|
568
|
+
/** A stored copy younger than this age answers with no request. The default is `24h`. */
|
|
569
|
+
readonly maxAge?: Duration | undefined;
|
|
570
|
+
/** These agents get their robots.txt rules applied too, for example `Claude-User`. */
|
|
571
|
+
readonly onBehalfOf?: readonly string[] | undefined;
|
|
572
|
+
readonly signal?: AbortSignal | undefined;
|
|
573
|
+
/** No request starts after this time from the start of the read, for example `"1m"`. */
|
|
574
|
+
readonly budget?: Duration | undefined;
|
|
575
|
+
readonly scope?: string | undefined;
|
|
576
|
+
readonly labels?: Readonly<Record<string, string>> | undefined;
|
|
577
|
+
/** This name connects the captures to the job that asked for them. The default is `product`. */
|
|
578
|
+
readonly job?: string | undefined;
|
|
579
|
+
/** This value is true when a person gave this URL directly. It is the only way to read a held-back page. The crawler logs it. */
|
|
580
|
+
readonly userProvided?: boolean | undefined;
|
|
581
|
+
/** The value `archive` reads an archived copy of a page that the shop refuses. Its prices are of the date of the copy. */
|
|
582
|
+
readonly fallback?: "archive" | "none" | undefined;
|
|
583
|
+
readonly archiveDespiteRobots?: boolean | undefined;
|
|
584
|
+
}
|
|
585
|
+
/** The result of `readProduct`. */
|
|
586
|
+
interface ProductResult extends Omit<ProductRead, "steps" | "notes"> {
|
|
587
|
+
readonly url: string;
|
|
588
|
+
/** This value is true when the page says what it sells, in structured data: the Product has a name. */
|
|
589
|
+
readonly verified: boolean;
|
|
590
|
+
/**
|
|
591
|
+
* This value is true when the site refused the crawler. The causes are a 401, a 402 or a 403, a
|
|
592
|
+
* challenge, a bot check, a stop of the host or robots.txt. The recipe stops there, and the note
|
|
593
|
+
* says why. With `fallback: "archive"`, it stays true when an archived copy answers.
|
|
594
|
+
*/
|
|
595
|
+
readonly wall: boolean;
|
|
596
|
+
readonly outcome: string;
|
|
597
|
+
readonly status: number;
|
|
598
|
+
readonly rendered: boolean;
|
|
599
|
+
readonly doc: string | null;
|
|
600
|
+
/** This id is the capture of the text that the recipe read. A citation names it. */
|
|
601
|
+
readonly capture: string | null;
|
|
602
|
+
readonly fetched_at: string | null;
|
|
603
|
+
readonly captures: readonly string[];
|
|
604
|
+
readonly from_cache: boolean;
|
|
605
|
+
/** This value is true when the page asked not to be AI input, so the recipe read nothing from it. */
|
|
606
|
+
readonly held_back: boolean;
|
|
607
|
+
/** This value tells that the page is an archived copy, with the archive and the date of the copy. */
|
|
608
|
+
readonly archived?: Archived | undefined;
|
|
609
|
+
readonly note: string | null;
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* This function reads a product page. It fetches the page through the crawler: robots.txt, the
|
|
613
|
+
* pace, the stops, the capture log and the rule for a held-back page apply. When the plain page has
|
|
614
|
+
* no Product data, it renders the page once, because some shops write that data with JavaScript.
|
|
615
|
+
*
|
|
616
|
+
* A shop that refuses the crawler gives `wall: true` and a note. The recipe writes nothing but the
|
|
617
|
+
* capture log. `extract` can check each value against the stored page.
|
|
618
|
+
*/
|
|
619
|
+
export declare const readProduct: (target: RecipeTarget, url: string, options?: ProductOptions) => Promise<ProductResult>;
|
|
620
|
+
//#endregion
|
|
141
621
|
//#region src/warc.d.ts
|
|
142
622
|
/** The source of an export: the folder of a store, or the capture log and the blob store of a runtime. */
|
|
143
623
|
type ArchiveSource = string | {
|
|
@@ -227,5 +707,5 @@ interface WaczResult extends ArchiveCounts {
|
|
|
227
707
|
*/
|
|
228
708
|
export declare const exportWacz: (source: ArchiveSource, options: ArchiveOptions) => Promise<WaczResult>;
|
|
229
709
|
//#endregion
|
|
230
|
-
export { ALLOW_ALL, type AiInput, type ArchiveCounts, type ArchiveFilter, type ArchiveOptions, type ArchiveSource, type Archived, type BlobStore, CAPTURE_SCHEMA, CRAWL_LIMITS, type CacheEntry, type CacheIndex, type CaptureFilter, CaptureLog, type CapturePayload, type CaptureReader, type CaptureRecord, type CaptureWriter, type CatchUpResult, type Changefreq, type Clock, type CrawlEvent, type CrawlOptions, type CrawlPage, type CrawlRun, type CrawlRunOptions, type CrawlRuntime, type CrawlStop, type CrawlSummary, Crawler, type CrawlerOptions, DAYS, DEADLINE_NOTE, DEFAULT_POLICY, DEFAULT_SECRET_PARAMS, DIFF_LIMITS, DISCOVER_LIMITS, type DamagedLine, type Day, type DiffHunk, type DiffInput, type DiffLimits, type DiffLine, type DiffOptions, type DiffResult, type DiffSide, type DiffSummary, type DirectoryKey, type DiscoverOptions, type DiscoverResult, type DiscoverRunOptions, type DiscoverSource, type DiscoverStop, type DiscoveredUrl, type Doc, DocIndex, type DocInput, type DocVersion, type Duration, type EgressOptions, EgressRefused, type ExtractOptions, type ExtractResult, type ExtractSource, type ExtractSummary, type ExtractedDoc, type Extractor, Extractors, FAST_RANK_SHARE, FIELD_KINDS, type FetchOptions, type FetchOutcome, type FetchRequest, type Fetched, type FieldCandidate, type FieldCheck, type FieldClaim, type FieldKind, type FieldResult, type FieldSpan, type FieldStatus, type FieldsChecked, FileBlobStore, type FindIndexOptions, type FindOptions, type Found, HELD_BACK, type HostCounts, type HostResult, type HostStateStore, type HostStop, type Hours, type Indexed, type Interval, KEY_DIRECTORY_PATH, KEY_DIRECTORY_TYPE, type KeyDirectory, type KeyInput, type Latest, MemoryHostStateStore, type MetaChange, NO_PLAYWRIGHT, type OpenOptions, type OpenedCrawler, type PageExtract, type PageLink, type PageOptions, type PageResult, type PdfOptions, type PdfText, type PlaywrightRenderer, type PolicyOptions, type PoliteCrawler, type PolitenessPolicy, type RankMode, type ReadOptions, type ReadResult, type ReadingIndex, type RecordInput, type RefusedReason, type ReindexResult, type RenderOptions, RenderRefused, type RenderRequest, type Rendered, type Renderer, type RequestSigner, type Robots, type RobotsDecision, type RobotsGroup, type RobotsRule, type RobotsSignal, type RuntimeOptions, SITEMAP_LIMITS, type ScanOptions, type ScopeOptions, type Signals, type SignatureAgentType, type SignatureCheck, type SignedRequest, type SitemapEntry, type SitemapKind, type SitemapLimits, type SitemapRead, type StoreRuntime, type TextDiff, type UrlPattern, VALIDATOR_MEMO, type ValidatorAnswer, type ValidatorLimits, type ValidatorMemo, type ValidatorReport, type ValidatorVerdict, type Variant, type Verified, type VerifyOptions, type VerifyResult, type VersionAt, type VersionChoice, type VersionText, WATCH_LIMITS, WATCH_SCHEMA, type WaczResult, type WarcResult, type WatchEntry, type WatchEvent, type WatchKind, type WatchList, type WatchOptions, type WatchPending, type WatchRun, type WatchRunOptions, type WatchRunnerOptions, type WatchStop, WatchStore, type WatchStoreOptions, type WatchSummary, type WebArchive, type WebBotAuthOptions, type WebBotAuthSigner, type Week, type WordPart, archiveExtractor, archivedDocId, bodyEncoding, catchUpIndex, checkFields, crawlSite, createRuntime, createWebBotAuthSigner, decide, decodeBody, defaultUserAgent, describeWeek, diffDocument, diffTexts, disagreements, discoverSite, durationMs, egressLookup, extractDocument, extractPage, feedDate, fetchAndIndex, fetchPage, findDocuments, fromCompact, fromSchemaOrg, fromText, heldBackMeta, isHeldBack, isMailbox, isoTime, keyDirectory, makeRecord, nextValidatorMemo, openCrawler, pageDocId, pageExtractor, parseRobots, playwrightRenderer, readDocument, readSitemap, realClock, recordOverride, reindex, renderAndIndex, renderedKey, runWatch, toHoursWeek, typesOf, verifyQuote, verifySignature, versionAtTime };
|
|
710
|
+
export { ALLOW_ALL, type AiInput, type ArchiveCounts, type ArchiveFilter, type ArchiveOptions, type ArchiveSource, type Archived, type BlobStore, CAPTURE_SCHEMA, CHUNK_LIMITS, CRAWL_LIMITS, type CacheEntry, type CacheIndex, type CaptureFilter, CaptureLog, type CapturePayload, type CaptureReader, type CaptureRecord, type CaptureWriter, type CatchUpResult, type ChangeCommandOptions, type Changefreq, type ChunkOptions, type Clock, type CrawlEvent, type CrawlOptions, type CrawlPage, type CrawlRun, type CrawlRunOptions, type CrawlRuntime, type CrawlStop, type CrawlSummary, Crawler, type CrawlerOptions, DAEMON_DEFAULTS, DAEMON_STATE_SCHEMA, DAYS, DEADLINE_NOTE, DEFAULT_POLICY, DEFAULT_SECRET_PARAMS, DIFF_LIMITS, DISCOVER_LIMITS, type Daemon, type DaemonDue, type DaemonMcpHooks, type DaemonMcpHost, type DaemonMcpOptions, type DaemonMcpService, type DaemonOptions, type DaemonState, type DaemonStatus, type DaemonTask, type DaemonTick, type DamagedLine, type Day, type DiffHunk, type DiffInput, type DiffLimits, type DiffLine, type DiffOptions, type DiffResult, type DiffSide, type DiffSummary, type DigestOptions, type DirectoryKey, type DiscoverOptions, type DiscoverResult, type DiscoverRunOptions, type DiscoverSource, type DiscoverStop, type DiscoveredUrl, type Doc, type DocDigest, DocIndex, type DocInput, type DocVersion, type Duration, type EgressOptions, EgressRefused, type EmbedCallOptions, type EmbedOptions, type EmbedResult, type EmbedStop, type Embedder, type EmbeddingModel, type ExtractOptions, type ExtractResult, type ExtractSource, type ExtractSummary, type ExtractedDoc, type Extractor, Extractors, FAST_RANK_SHARE, FIELD_KINDS, type FeatureExtractor, type FetchOptions, type FetchOutcome, type FetchRequest, type Fetched, type FieldCandidate, type FieldCheck, type FieldClaim, type FieldKind, type FieldResult, type FieldSpan, type FieldStatus, type FieldsChecked, FileBlobStore, type FindIndexOptions, type FindOptions, type Found, type FusedRank, HELD_BACK, HYBRID_DEFAULTS, type HostCounts, type HostResult, type HostStateStore, type HostStop, type Hours, type HoursComparison, type HybridCrawler, type HybridFindOptions, type HybridOptions, type HybridSearch, type HybridSearchOptions, type Indexed, type Interval, KEY_DIRECTORY_PATH, KEY_DIRECTORY_TYPE, type KeyDirectory, type KeyInput, type Latest, MemoryHostStateStore, type MetaChange, type Money, NO_EMBEDDER, NO_PLAYWRIGHT, type OllamaEmbedderOptions, type OpenOptions, type OpenedCrawler, type PageExtract, type PageLink, type PageOptions, type PageResult, type Passage, type PdfOptions, type PdfText, type PlaywrightRenderer, type PolicyOptions, type PoliteCrawler, type PolitenessPolicy, type Pooling, type ProductOptions, type ProductRead, type ProductResult, type ProductVariant, RECIPE_LIMITS, RESERVED_RECIPES, type RankMode, type RankOptions, type Ranked, type ReadOptions, type ReadResult, type ReadingIndex, type Recipe, type RecipeCapture, type RecipeDefinition, type RecipeDoc, type RecipeExtract, type RecipeRequest, type RecipeRequestOptions, type RecipeResult, type RecipeRunOptions, type RecipeTarget, type RecordInput, type RefusedReason, type ReindexResult, type RenderOptions, RenderRefused, type RenderRequest, type Rendered, type Renderer, type RequestSigner, type Robots, type RobotsDecision, type RobotsGroup, type RobotsRule, type RobotsSignal, type RuntimeOptions, SITEMAP_LIMITS, type ScanOptions, type ScheduleOptions, type ScheduleResult, type ScopeOptions, type SearchOptions, type SearchRank, type Signals, type SignatureAgentType, type SignatureCheck, type SignedRequest, type SitemapEntry, type SitemapKind, type SitemapLimits, type SitemapRead, type StoreRuntime, type StoredChunk, type TextChunk, type TextDiff, type TransformersEmbedderOptions, type TransformersModule, type UrlPattern, VALIDATOR_MEMO, VECTORS_SCHEMA, type ValidatorAnswer, type ValidatorLimits, type ValidatorMemo, type ValidatorReport, type ValidatorVerdict, type Variant, type VectorCounts, type VectorHit, VectorStore, type VectorStoreOptions, type VectorWrite, type VenueLink, type VenueLocation, type VenueOptions, type VenueOsm, type VenuePage, type VenueRead, type VenueReading, type VenueResult, type VenueSource, type Verified, type VerifyOptions, type VerifyResult, type VersionAt, type VersionChoice, type VersionText, WATCH_LIMITS, WATCH_SCHEMA, type WaczResult, type WarcResult, type WatchEntry, type WatchEvent, type WatchKind, type WatchList, type WatchOptions, type WatchPending, type WatchRun, type WatchRunOptions, type WatchRunnerOptions, type WatchSchedule, type WatchStop, WatchStore, type WatchStoreOptions, type WatchSummary, type WebArchive, type WebBotAuthOptions, type WebBotAuthSigner, type Week, type WordPart, archiveExtractor, archivedDocId, bodyEncoding, catchUpIndex, changeCommand, checkFields, chunkText, chunkTokensOf, compareHours, crawlSite, createHybridSearch, createRuntime, createWebBotAuthSigner, daemonStateFile, decide, decodeBody, defaultUserAgent, defineRecipe, describeWeek, diffDocument, diffTexts, disagreements, discoverSite, durationMs, egressLookup, estimateTokens, extractDocument, extractPage, feedDate, fetchAndIndex, fetchPage, findDocuments, fromCompact, fromSchemaOrg, fromText, fuseRanks, heldBackMeta, isHeldBack, isMailbox, isoTime, keyDirectory, makeRecord, nextValidatorMemo, openCrawler, pageDocId, pageExtractor, parseRobots, playwrightRenderer, readDaemonState, readDocument, readJson, readSitemap, realClock, recordOverride, registerRecipe, reindex, renderAndIndex, renderedKey, runRecipe, runWatch, scheduleWatches, startDaemon, toHoursWeek, typesOf, unitVector, verifyQuote, verifySignature, versionAtTime };
|
|
231
711
|
//# sourceMappingURL=index.d.mts.map
|
package/build/index.mjs
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { n as FileBlobStore, t as CaptureLog } from "./log-Dx-wXjJl.mjs";
|
|
2
2
|
import { n as RenderRefused, r as playwrightRenderer, t as NO_PLAYWRIGHT } from "./render-C1CUraWF.mjs";
|
|
3
3
|
import { r as checkedRenderer } from "./browser-CKRNbIDT.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { i as durationMs, n as DEFAULT_TOKEN, r as VERSION, t as BOT_PAGE } from "./version-BPem-XZd.mjs";
|
|
5
|
+
import { B as egressLookup, F as renderedKey, I as makeRecord, M as Crawler, N as DEADLINE_NOTE, O as locate, P as DEFAULT_SECRET_PARAMS, T as readPdf, _ as versionAtTime, a as fetchPage, b as archivedDocId, c as isHeldBack, d as pageExtractor, f as readDocument, g as verifyQuote, h as renderAndIndex, i as fetchAndIndex, j as CAPTURE_SCHEMA, l as isoTime, m as reindex, n as HELD_BACK, o as findDocuments, p as recordOverride, r as catchUpIndex, s as heldBackMeta, t as Extractors, u as pageDocId, v as archiveExtractor, w as isPdf, z as EgressRefused } from "./runtime-D_r2SYge.mjs";
|
|
5
6
|
import { DEFAULT_POLICY, MemoryHostStateStore, VALIDATOR_MEMO, nextValidatorMemo, realClock } from "./politeness.mjs";
|
|
6
7
|
import { ALLOW_ALL, decide, parseRobots } from "./robots.mjs";
|
|
7
|
-
import { i as VERSION, n as BOT_PAGE, r as DEFAULT_TOKEN, t as durationMs } from "./duration-iIuMMofi.mjs";
|
|
8
8
|
import { i as keyDirectory, n as KEY_DIRECTORY_TYPE, o as verifySignature, r as createWebBotAuthSigner, t as KEY_DIRECTORY_PATH } from "./webbotauth-CjJdTAfE.mjs";
|
|
9
|
-
import {
|
|
9
|
+
import { A as NO_EMBEDDER, C as DISCOVER_LIMITS, D as readSitemap, E as feedDate, O as DocIndex, S as crawlSite, T as SITEMAP_LIMITS, _ as estimateTokens, b as SqliteHostStateStore, c as WatchStore, d as VectorStore, f as createHybridSearch, g as chunkTokensOf, h as chunkText, i as openCrawler, k as FAST_RANK_SHARE, l as runWatch, m as HYBRID_DEFAULTS, n as defaultUserAgent, o as WATCH_LIMITS, p as CHUNK_LIMITS, r as isMailbox, s as WATCH_SCHEMA, t as createRuntime, u as VECTORS_SCHEMA, v as fuseRanks, w as discoverSite, x as CRAWL_LIMITS, y as unitVector } from "./open-CbpSCEZc.mjs";
|
|
10
10
|
import { a as bodyEncoding, o as decodeBody, r as typesOf, t as extractPage } from "./html-DkQUAE_d.mjs";
|
|
11
|
-
import { n as diffDocument, r as diffTexts, t as DIFF_LIMITS } from "./diff-
|
|
12
|
-
import { n as checkFields, r as extractDocument, t as FIELD_KINDS } from "./extract-
|
|
13
|
-
import {
|
|
14
|
-
import { t as
|
|
15
|
-
import { n as
|
|
16
|
-
|
|
11
|
+
import { n as diffDocument, r as diffTexts, t as DIFF_LIMITS } from "./diff-BUM91Rev.mjs";
|
|
12
|
+
import { n as checkFields, r as extractDocument, t as FIELD_KINDS } from "./extract-CefB5Vfn.mjs";
|
|
13
|
+
import { a as readJson, i as defineRecipe, n as RESERVED_RECIPES, o as registerRecipe, s as runRecipe, t as RECIPE_LIMITS } from "./recipe-GiFQojmo.mjs";
|
|
14
|
+
import { c as startDaemon, i as daemonStateFile, n as DAEMON_STATE_SCHEMA, o as readDaemonState, r as changeCommand, s as scheduleWatches, t as DAEMON_DEFAULTS } from "./daemon-DK6U51_v.mjs";
|
|
15
|
+
import { i as ollamaEmbedder, n as OLLAMA_MODELS, r as isLoopback, t as NO_OLLAMA } from "./ollama-BJxkjny4.mjs";
|
|
16
|
+
import { n as TRANSFORMERS_MODELS, r as transformersEmbedder, t as NO_TRANSFORMERS } from "./transformers-BQMlaGj4.mjs";
|
|
17
|
+
import { DAYS, compareHours, describeWeek, disagreements, fromCompact, fromSchemaOrg, fromText, toHoursWeek } from "./hours.mjs";
|
|
18
|
+
import { a as readAmount, c as locationMatches, d as readVenue, f as venueReadingsOf, i as productOf, l as namesVenue, n as pickProduct, o as readProduct, r as pickVariant, s as VENUE_LIMITS, t as PRODUCT_LIMITS, u as rankHoursLinks } from "./recipe-product-Dellqudu.mjs";
|
|
19
|
+
import { t as exportWacz } from "./wacz-QyzLp4mC.mjs";
|
|
20
|
+
import { n as exportWarc } from "./warc-BHcaRKHw.mjs";
|
|
21
|
+
export { ALLOW_ALL, BOT_PAGE, CAPTURE_SCHEMA, CHUNK_LIMITS, CRAWL_LIMITS, CaptureLog, Crawler, DAEMON_DEFAULTS, DAEMON_STATE_SCHEMA, DAYS, DEADLINE_NOTE, DEFAULT_POLICY, DEFAULT_SECRET_PARAMS, DEFAULT_TOKEN, DIFF_LIMITS, DISCOVER_LIMITS, DocIndex, EgressRefused, Extractors, FAST_RANK_SHARE, FIELD_KINDS, FileBlobStore, HELD_BACK, HYBRID_DEFAULTS, KEY_DIRECTORY_PATH, KEY_DIRECTORY_TYPE, MemoryHostStateStore, NO_EMBEDDER, NO_OLLAMA, NO_PLAYWRIGHT, NO_TRANSFORMERS, OLLAMA_MODELS, PRODUCT_LIMITS, RECIPE_LIMITS, RESERVED_RECIPES, RenderRefused, SITEMAP_LIMITS, SqliteHostStateStore, TRANSFORMERS_MODELS, VALIDATOR_MEMO, VECTORS_SCHEMA, VENUE_LIMITS, VERSION, VectorStore, WATCH_LIMITS, WATCH_SCHEMA, WatchStore, archiveExtractor, archivedDocId, bodyEncoding, catchUpIndex, changeCommand, checkFields, checkedRenderer, chunkText, chunkTokensOf, compareHours, crawlSite, createHybridSearch, createRuntime, createWebBotAuthSigner, daemonStateFile, decide, decodeBody, defaultUserAgent, defineRecipe, describeWeek, diffDocument, diffTexts, disagreements, discoverSite, durationMs, egressLookup, estimateTokens, exportWacz, exportWarc, extractDocument, extractPage, feedDate, fetchAndIndex, fetchPage, findDocuments, fromCompact, fromSchemaOrg, fromText, fuseRanks, heldBackMeta, isHeldBack, isLoopback, isMailbox, isPdf, isoTime, keyDirectory, locate, locationMatches, makeRecord, namesVenue, nextValidatorMemo, ollamaEmbedder, openCrawler, pageDocId, pageExtractor, parseRobots, pickProduct, pickVariant, playwrightRenderer, productOf, rankHoursLinks, readAmount, readDaemonState, readDocument, readJson, readPdf, readProduct, readSitemap, readVenue, realClock, recordOverride, registerRecipe, reindex, renderAndIndex, renderedKey, runRecipe, runWatch, scheduleWatches, startDaemon, toHoursWeek, transformersEmbedder, typesOf, unitVector, venueReadingsOf, verifyQuote, verifySignature, versionAtTime };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isIP } from "node:net";
|
|
2
|
+
//#region src/loopback.ts
|
|
3
|
+
/**
|
|
4
|
+
* This function tells if a host name or an address is a loopback host: `localhost`, an address in
|
|
5
|
+
* `127.0.0.0/8`, or `::1`. The MCP server over HTTP binds to a loopback host unless the operator
|
|
6
|
+
* permits a different host. The function imports only Node.js, so the command line uses it before
|
|
7
|
+
* the store opens.
|
|
8
|
+
*/
|
|
9
|
+
const isLoopbackHost = (host) => {
|
|
10
|
+
const name = host.trim().toLowerCase().replace(/^\[(.*)\]$/, "$1");
|
|
11
|
+
if (name === "localhost" || name.endsWith(".localhost")) return true;
|
|
12
|
+
const mapped = name.startsWith("::ffff:") ? name.slice(7) : name;
|
|
13
|
+
if (isIP(mapped) === 4) return mapped.startsWith("127.");
|
|
14
|
+
if (isIP(name) === 6) return /^(?:0{0,4}:){7}0{0,3}1$|^::1$/.test(name);
|
|
15
|
+
return false;
|
|
16
|
+
};
|
|
17
|
+
/** This function gives a host for a URL: an IPv6 address goes in brackets. */
|
|
18
|
+
const urlHost = (host) => isIP(host) === 6 ? `[${host}]` : host;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { urlHost as n, isLoopbackHost as t };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=loopback-C_QYowSf.mjs.map
|