@agentproto/collect 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/README.md +642 -2
- package/dist/chunk-FQLYZIVI.mjs +405 -0
- package/dist/chunk-FQLYZIVI.mjs.map +1 -0
- package/dist/chunk-SOLT3HJH.mjs +213 -0
- package/dist/chunk-SOLT3HJH.mjs.map +1 -0
- package/dist/chunk-SYTQ6RN6.mjs +98 -0
- package/dist/chunk-SYTQ6RN6.mjs.map +1 -0
- package/dist/connector-DUNy3vSU.d.ts +981 -0
- package/dist/connectors.d.ts +104 -0
- package/dist/connectors.mjs +1197 -0
- package/dist/connectors.mjs.map +1 -0
- package/dist/engine-BRXHKg5A.d.ts +384 -0
- package/dist/index.d.ts +134 -0
- package/dist/index.mjs +1494 -0
- package/dist/index.mjs.map +1 -0
- package/dist/node.d.ts +526 -0
- package/dist/node.mjs +2322 -0
- package/dist/node.mjs.map +1 -0
- package/package.json +71 -3
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { S as Subject, C as Connector, a as CollectTask } from './connector-DUNy3vSU.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
declare const WEB_CONNECTOR_ID = "web";
|
|
5
|
+
/** What a task carries about where the URL came from. */
|
|
6
|
+
interface WebTaskContext {
|
|
7
|
+
/** Sub-source label copied onto the item. */
|
|
8
|
+
sourceInstance?: string;
|
|
9
|
+
/** Subjects copied onto the item. */
|
|
10
|
+
subjects?: Subject[];
|
|
11
|
+
/** The query text or the link that led here. */
|
|
12
|
+
query?: string;
|
|
13
|
+
/** Id of the item that links to this page (kept as provenance only). */
|
|
14
|
+
from?: string;
|
|
15
|
+
/** Hosts, besides the page's own, a `rel=canonical` may point to. */
|
|
16
|
+
canonicalAliases?: string[];
|
|
17
|
+
/** Most bytes of HTML read from the page (default 5 MiB). */
|
|
18
|
+
maxInputBytes?: number;
|
|
19
|
+
/** Most characters of text kept (default 200 000). */
|
|
20
|
+
maxChars?: number;
|
|
21
|
+
}
|
|
22
|
+
/** A `web` task for a URL. Its id is the canonical URL, so the same page is queued once. */
|
|
23
|
+
declare function webTask(url: string, context?: WebTaskContext): CollectTask;
|
|
24
|
+
declare const WebExt: z.ZodObject<{
|
|
25
|
+
site: z.ZodString;
|
|
26
|
+
extractedAuthor: z.ZodOptional<z.ZodString>;
|
|
27
|
+
extraction: z.ZodEnum<{
|
|
28
|
+
blocked: "blocked";
|
|
29
|
+
empty: "empty";
|
|
30
|
+
ok: "ok";
|
|
31
|
+
not_html: "not_html";
|
|
32
|
+
}>;
|
|
33
|
+
paywalled: z.ZodOptional<z.ZodBoolean>;
|
|
34
|
+
note: z.ZodOptional<z.ZodString>;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
type WebExt = z.infer<typeof WebExt>;
|
|
37
|
+
declare const web: Connector;
|
|
38
|
+
|
|
39
|
+
type ExtractionStatus = "ok" | "empty" | "not_html" | "blocked";
|
|
40
|
+
/** Fewer words than this in the main text counts as an empty extraction. */
|
|
41
|
+
declare const MIN_WORDS = 15;
|
|
42
|
+
/** Default cap on the extracted text, in characters. */
|
|
43
|
+
declare const DEFAULT_MAX_CHARS = 200000;
|
|
44
|
+
/** Default cap on the HTML read, in bytes. */
|
|
45
|
+
declare const DEFAULT_MAX_INPUT_BYTES: number;
|
|
46
|
+
/** Default cap on the outbound links kept. */
|
|
47
|
+
declare const DEFAULT_MAX_LINKS = 1000;
|
|
48
|
+
/** Longest base URL or resolved link kept, in characters; a longer one is skipped. */
|
|
49
|
+
declare const MAX_URL_LENGTH = 2048;
|
|
50
|
+
/** Default cap on the total length of the retained link URLs. */
|
|
51
|
+
declare const DEFAULT_MAX_LINK_BYTES: number;
|
|
52
|
+
interface ArticleExtraction {
|
|
53
|
+
extraction: ExtractionStatus;
|
|
54
|
+
title?: string;
|
|
55
|
+
/** Main text, paragraphs separated by a blank line. */
|
|
56
|
+
text: string;
|
|
57
|
+
textTruncated: boolean;
|
|
58
|
+
wordCount: number;
|
|
59
|
+
author?: string;
|
|
60
|
+
authorUrl?: string;
|
|
61
|
+
/** Calendar day or full timestamp, ISO. A timestamp with no zone is read as UTC. */
|
|
62
|
+
publishedAt?: string;
|
|
63
|
+
language?: string;
|
|
64
|
+
canonicalUrl: string;
|
|
65
|
+
site: string;
|
|
66
|
+
/** Absolute, canonical, de-duplicated links of the main text. */
|
|
67
|
+
outboundLinks: string[];
|
|
68
|
+
hasMedia: boolean;
|
|
69
|
+
/** The page says its full text is behind a paywall. */
|
|
70
|
+
paywalled?: boolean;
|
|
71
|
+
/** The page is a verification or challenge page (the status is then `blocked`). */
|
|
72
|
+
challenge: boolean;
|
|
73
|
+
/** Why the result is cut or partial: `input_truncated`, `node_cap`, `too_complex`, `text_cap`, `link_cap`, `link_bytes_cap`, `base_ignored`, `url_too_long`. */
|
|
74
|
+
notes: string[];
|
|
75
|
+
}
|
|
76
|
+
interface ExtractOptions {
|
|
77
|
+
maxChars?: number;
|
|
78
|
+
maxNodes?: number;
|
|
79
|
+
maxLinks?: number;
|
|
80
|
+
/** Most characters of retained link URLs, all together (default 1 MiB). */
|
|
81
|
+
maxLinkBytes?: number;
|
|
82
|
+
/** Most tree operations the HTML parser may make before the page is given up as too tangled. */
|
|
83
|
+
maxParseOps?: number;
|
|
84
|
+
/** The caller already cut the input at its byte cap. */
|
|
85
|
+
inputTruncated?: boolean;
|
|
86
|
+
/** Hosts, besides the page's own, that a `rel=canonical` may point to. */
|
|
87
|
+
canonicalAliases?: readonly string[];
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* A calendar day or a full timestamp, or `undefined` when the value is not a
|
|
91
|
+
* real date. A timestamp with no zone is read as UTC, never in the host's
|
|
92
|
+
* local time; a text date (not ISO) is only read when it names its zone.
|
|
93
|
+
*/
|
|
94
|
+
declare function normalizeDate(value: string | undefined): string | undefined;
|
|
95
|
+
declare function authorSlug(name: string): string;
|
|
96
|
+
declare function extractArticle(html: string, pageUrl: string, options?: ExtractOptions): ArticleExtraction;
|
|
97
|
+
/** The charset a stored page is decoded with: BOM, then the response header, then a `<meta>` of the first bytes, then UTF-8. */
|
|
98
|
+
declare function charsetOf(bytes: Uint8Array, contentType?: string): string;
|
|
99
|
+
declare function decodeHtml(bytes: Uint8Array, contentType?: string): string;
|
|
100
|
+
|
|
101
|
+
/** Every connector this package ships, in registration order. */
|
|
102
|
+
declare const shippedConnectors: readonly Connector[];
|
|
103
|
+
|
|
104
|
+
export { type ArticleExtraction, DEFAULT_MAX_CHARS, DEFAULT_MAX_INPUT_BYTES, DEFAULT_MAX_LINKS, DEFAULT_MAX_LINK_BYTES, type ExtractOptions, type ExtractionStatus, MAX_URL_LENGTH, MIN_WORDS, WEB_CONNECTOR_ID, WebExt, type WebTaskContext, authorSlug, charsetOf, decodeHtml, extractArticle, normalizeDate, shippedConnectors, web, webTask };
|