@plurnk/plurnk-schemes-http 1.4.0 → 1.6.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/.env.defaults CHANGED
@@ -9,35 +9,15 @@
9
9
  # must not set them. Standalone (no daemon), the required numerics fail hard
10
10
  # when unset, naming the var.
11
11
  #
12
- # ── Required (render path) ───────────────────────────────────────────────────
13
- # Navigation/render timeout in ms (page.goto networkidle budget).
12
+ # ── Required (acquisition path) ─────────────────────────────────────────────
13
+ # HTTP request timeout in ms.
14
14
  PLURNK_SCHEMES_HTTP_FETCH_TIMEOUT=30000
15
- # Salvage threshold in body-text chars: a networkidle timeout whose DOM already
16
- # holds at least this much innerText is the chatty-page case (long-poll, ad
17
- # refresh) — the render is kept; below it the timeout propagates.
18
- PLURNK_SCHEMES_HTTP_SALVAGE_MIN_BODY_CHARS=200
19
- # Warm-chromium idle teardown in ms: the browser process closes after this long
20
- # with no render activity, and relaunches on the next render.
21
- PLURNK_SCHEMES_HTTP_IDLE_TIMEOUT=900000
22
15
 
23
16
  # ── Defaults (floor-set; override to change) ────────────────────────────────
24
- # Playwright BrowserType method. "launch" uses an operator-provisioned compatible
25
- # Chromium unless CHANNEL or EXECUTABLE_PATH selects another local browser. "connect"
26
- # uses a Playwright protocol endpoint; "connectOverCDP" attaches to a running
27
- # Chromium browser; "disabled" explicitly removes rendered HTML retrieval.
28
- PLURNK_SCHEMES_HTTP_PLAYWRIGHT_METHOD=launch
29
- # Browser launch/connection timeout in ms.
30
- PLURNK_SCHEMES_HTTP_PLAYWRIGHT_TIMEOUT=30000
31
- # Headless launch. Set 0 for a visible operator-managed browser session.
32
- PLURNK_SCHEMES_HTTP_PLAYWRIGHT_HEADLESS=1
33
- # Playwright's Chromium sandbox launch option. Playwright defaults this off;
34
- # set 1 only where the host/container supports Chromium user namespaces.
35
- PLURNK_SCHEMES_HTTP_PLAYWRIGHT_CHROMIUM_SANDBOX=0
36
- # Mobile device emulation on the render path (Pixel-5-class viewport + UA):
37
- # responsive sites serve a lighter, less-chrome layout — a better generation
38
- # hint. "0" renders desktop (escape hatch for sites that serve degraded or
39
- # blocked mobile content). Required read: unset crashes at render, naming the var.
40
- PLURNK_SCHEMES_HTTP_MOBILE=1
17
+ # Tavily Extract extraction depth ("basic" or "advanced").
18
+ PLURNK_SCHEMES_HTTP_TAVILY_DEPTH=basic
19
+ # Tavily Extract request timeout in ms.
20
+ PLURNK_SCHEMES_HTTP_TAVILY_TIMEOUT_MS=30000
41
21
  # Per-URL freshness TTL in ms: a re-read of a URL fetched within this window
42
22
  # serves the stored copy with ZERO round-trips (no conditional GET). This makes
43
23
  # a just-materialized web entry immediately readable like any other entry.
@@ -50,22 +30,12 @@ PLURNK_SCHEMES_HTTP_REDIRECTS=5
50
30
  # Maximum buffered characters in one incomplete SSE line/event. Exceeding this
51
31
  # bound terminates the remote stream instead of allowing unbounded memory growth.
52
32
  PLURNK_SCHEMES_HTTP_SSE_MAX_BUFFER_CHARS=1048576
53
- # Maximum characters retained from a caught fetch, render, or transport
33
+ # Maximum characters retained from a caught fetch, extract, or transport
54
34
  # diagnostic in a model-facing Problem detail. Complete errors remain in daemon
55
35
  # diagnostics.
56
36
  PLURNK_SCHEMES_HTTP_ERROR_DETAIL_LIMIT=512
57
37
 
58
38
  # ── Optional modes (absence IS the mode — never floor-set) ──────────────────
59
- # Required by connect/connectOverCDP: the Playwright or CDP endpoint.
60
- # PLURNK_SCHEMES_HTTP_PLAYWRIGHT_ENDPOINT=http://localhost:9222
61
- # Optional launch channel: chromium, chrome, chrome-beta, chrome-dev,
62
- # chrome-canary, msedge, msedge-beta, msedge-dev, or msedge-canary.
63
- # PLURNK_SCHEMES_HTTP_PLAYWRIGHT_CHANNEL=chrome
64
- # Optional exact browser executable for launch. Mutually exclusive with CHANNEL.
65
- # PLURNK_SCHEMES_HTTP_PLAYWRIGHT_EXECUTABLE_PATH=/usr/bin/chromium
66
- # Chromium JS heap cap in MB (--max-old-space-size). Unset → chromium default.
67
- # PLURNK_SCHEMES_HTTP_CHROMIUM_HEAP_MB=2048
68
-
69
- # Native Playwright browser-location controls remain authoritative. This example
70
- # is intentionally unset; the package never supplies its own path.
71
- # PLAYWRIGHT_BROWSERS_PATH=/var/cache/ms-playwright
39
+ # Optional Tavily API key for HTML-to-Markdown extraction. When omitted/unset,
40
+ # the installed HTML mimetype projection is used as the local floor.
41
+ # TAVILY_API_KEY=
package/README.md CHANGED
@@ -8,28 +8,28 @@ authored against the DB-free
8
8
 
9
9
  ## HTTP operations
10
10
 
11
- | Operation | Behavior |
12
- | --------------------------------- | ----------------------------------------------------------------------------------------- |
13
- | Unscoped `READ(http(s)://…)` | Fetch or reuse/revalidate a GET representation, then stream the selected response channel |
14
- | Scoped `READ(http(s)://…)<scope>` | Apply the standard entry READ to an already-materialized response without refetching |
15
- | `FIND(http(s)://…):matcher` | Materialize an exact URL when required, then use the universal entry query and matcher |
16
- | `SEND[200](http(s)://…):body:` | POST the body and stream the response |
17
- | `EDIT(http(s)://…):body:` | PUT a whole-resource replacement; line-scoped HTTP edits are invalid |
18
- | `KILL(http(s)://…)` | DELETE the remote resource and stream the response |
19
- | `SEND[499](http(s)://…)` | Cancel the routed in-flight subscription |
20
- | `SEND[410](http(s)://…)` | Delete the local stored response entry |
11
+ | Operation | Behavior |
12
+ | ---------------------------------------------- | ----------------------------------------------------------------------------------------- |
13
+ | `## READ0 (http(s)://…)` | Fetch or reuse/revalidate a GET representation, then stream the selected response channel |
14
+ | `## READ0 (http(s)://…) <scope>` | Apply the standard entry READ to an already-materialized response without refetching |
15
+ | `## FIND0 (http(s)://…)` with matcher body | Materialize an exact URL when required, then use the universal entry query and matcher |
16
+ | `## SEND0 [200] (http(s)://…)` with body | POST the body and stream the response |
17
+ | `## EDIT0 (http(s)://…)` with body | PUT a whole-resource replacement; line-scoped HTTP edits are invalid |
18
+ | `## KILL0 (http(s)://…)` | DELETE the remote resource and stream the response |
19
+ | `## SEND0 [499] (http(s)://…)` | Cancel the routed in-flight subscription |
20
+ | `## SEND0 [410] (http(s)://…)` | Delete the local stored response entry |
21
21
 
22
22
  A path-pattern FIND surveys already-materialized web entries; it does not crawl
23
- or discover the remote web. Exact FIND and matcher READ share the standard
24
- catalog, matcher evidence, weighting, pagination, and status contract.
23
+ or discover the remote web. Exact matcher FIND shares the standard flat
24
+ location, weighting, pagination, and status contract.
25
25
 
26
26
  ## HTTP channels
27
27
 
28
- | Channel | Content |
29
- | -------- | ----------------------------------------------------------------------- |
30
- | `body` | Text, derived Unicode, typed binary marker, SSE data, or readable HTML |
31
- | `header` | HTTP status line, headers, and package acquisition metadata |
32
- | `html` | Faithful HTML used to produce the readable body |
28
+ | Channel | Content |
29
+ | -------- | -------------------------------------------------------------------------- |
30
+ | `body` | Text, derived Unicode, typed binary marker, SSE data, or HTML-page Markdown |
31
+ | `header` | Origin, acquisition, materializer, projection, provider, and usage evidence |
32
+ | `html` | Original server-source HTML when the origin supplies it |
33
33
 
34
34
  A fragmentless operation publishes only `body`; auxiliary channels remain
35
35
  durable and can be addressed explicitly. Remote HTTP status is stored in
@@ -42,17 +42,25 @@ projection ceiling returns `413`.
42
42
 
43
43
  ## Design
44
44
 
45
- - WebFetcher checks automatic byte targets and redirects; direct HTTP,
46
- Playwright, and WebSocket use their ordinary configured transports.
47
- - Direct GET HTML is rendered through Playwright, projected into `body`, and
48
- retained faithfully in `html`.
45
+ - WebFetcher checks automatic byte targets and redirects; direct HTTP and
46
+ WebSocket retain their explicit-target authority.
47
+ - Generic GETs negotiate origin Markdown first. When the origin returns HTML,
48
+ configured Tavily produces `body`; otherwise the installed HTML reader is the
49
+ local route. Recoverable Tavily failures use that same reader as a `203`
50
+ recovery floor. Hard provider failures do not silently change producers.
51
+ - `body`, `header`, and `html` settle independently. The selected channel
52
+ determines operation success, so raw server source and evidence remain usable
53
+ when body production fails, and a provider body can survive origin transport
54
+ failure without fabricating HTML.
49
55
  - GET representations carry method, acquisition-time, and single-variant cache
50
- metadata; derived representations also carry projection identity. Explicit
51
- request metadata, `Vary`, `no-store`, expired origin freshness, or a reader
52
- change prevents unsafe reuse; the operator TTL remains an independent ceiling.
56
+ metadata; HTML adds materializer-route evidence, and local derivation adds
57
+ projection identity. Request metadata, `Vary`, `no-store`, expired freshness,
58
+ or a materializer/reader change prevents reuse; operator TTL is a separate
59
+ ceiling. Stale page composites are fully reacquired rather than restored by
60
+ an origin `304`.
53
61
  - HTTP(S) and WS(S) entry identity retains protocol, authority, path, ordered
54
62
  query, and explicit empty query; a fragment selects a channel.
55
- - Handler-owned browser and socket state follows the shared readiness, drain,
63
+ - Handler-owned socket state follows the shared readiness, drain,
56
64
  and aggregate-shutdown lifecycle.
57
65
  - All storage and streaming work uses `SchemeCtx` capabilities rather than a
58
66
  raw database handle.
@@ -70,19 +78,15 @@ npm i @plurnk/plurnk-schemes-http
70
78
  plurnk start
71
79
  ```
72
80
 
73
- The Playwright client is included. Provision a compatible local browser
74
- separately, select an external Playwright/CDP endpoint, or disable rendering.
75
81
  The shipped `.env.defaults` is the canonical operator configuration registry.
76
-
77
- For local `launch`:
78
-
79
- ```sh
80
- npx playwright install chromium
81
- ```
82
+ To enable Tavily Extract for generic public HTML materialization, set
83
+ `TAVILY_API_KEY` in `.env`. Depth and client timeout are controlled by
84
+ `PLURNK_SCHEMES_HTTP_TAVILY_DEPTH` and
85
+ `PLURNK_SCHEMES_HTTP_TAVILY_TIMEOUT_MS`. Without Tavily,
86
+ `@plurnk/plurnk-mimetypes-text-html` supplies the local body.
82
87
 
83
88
  ## Verify
84
89
 
85
90
  ```sh
86
91
  npm test
87
- npm run test:intg
88
92
  ```