@plurnk/plurnk-schemes-http 1.3.11 → 1.4.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 +13 -11
- package/README.md +70 -23
- package/SPEC.md +461 -124
- package/dist/Browser.d.ts +2 -11
- package/dist/Browser.d.ts.map +1 -1
- package/dist/Browser.js +91 -69
- package/dist/Browser.js.map +1 -1
- package/dist/ContentType.d.ts +2 -0
- package/dist/ContentType.d.ts.map +1 -0
- package/dist/ContentType.js +15 -0
- package/dist/ContentType.js.map +1 -0
- package/dist/ErrorDetail.d.ts +6 -0
- package/dist/ErrorDetail.d.ts.map +1 -0
- package/dist/ErrorDetail.js +19 -0
- package/dist/ErrorDetail.js.map +1 -0
- package/dist/Guard.d.ts +1 -1
- package/dist/Guard.d.ts.map +1 -1
- package/dist/Guard.js +94 -53
- package/dist/Guard.js.map +1 -1
- package/dist/Http.d.ts.map +1 -1
- package/dist/Http.js +782 -273
- package/dist/Http.js.map +1 -1
- package/dist/WebFetcher.d.ts +38 -2
- package/dist/WebFetcher.d.ts.map +1 -1
- package/dist/WebFetcher.js +189 -48
- package/dist/WebFetcher.js.map +1 -1
- package/dist/Ws.d.ts +5 -1
- package/dist/Ws.d.ts.map +1 -1
- package/dist/Ws.js +431 -93
- package/dist/Ws.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -9
- package/dist/index.js.map +1 -1
- package/docs/http.md +95 -53
- package/docs/wss.md +39 -43
- package/package.json +14 -11
- package/scripts/install-browser.mjs +0 -19
package/.env.defaults
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# @plurnk/plurnk-schemes-http — .env.defaults (operator config + defaults floor).
|
|
2
2
|
#
|
|
3
3
|
# Every knob this package reads, family-namespaced PLURNK_SCHEMES_HTTP_*. This
|
|
4
|
-
# file
|
|
5
|
-
# member's .env.defaults into one operative floor at
|
|
6
|
-
# the operator's env
|
|
4
|
+
# file is the canonical value registry; {§http-config} owns policy. The daemon
|
|
5
|
+
# assembles every installed member's .env.defaults into one operative floor at
|
|
6
|
+
# boot, set-if-unset under the operator's env {§operator-config-env-defaults}.
|
|
7
7
|
# UNCOMMENTED keys are real defaults the floor sets. COMMENTED keys are modes
|
|
8
8
|
# whose ABSENCE is meaningful (unset = the documented behavior) — the floor
|
|
9
9
|
# must not set them. Standalone (no daemon), the required numerics fail hard
|
|
@@ -21,8 +21,8 @@ PLURNK_SCHEMES_HTTP_SALVAGE_MIN_BODY_CHARS=200
|
|
|
21
21
|
PLURNK_SCHEMES_HTTP_IDLE_TIMEOUT=900000
|
|
22
22
|
|
|
23
23
|
# ── Defaults (floor-set; override to change) ────────────────────────────────
|
|
24
|
-
# Playwright BrowserType method. "launch" uses
|
|
25
|
-
# unless CHANNEL or EXECUTABLE_PATH selects another local browser. "connect"
|
|
24
|
+
# Playwright BrowserType method. "launch" uses an operator-provisioned compatible
|
|
25
|
+
# Chromium unless CHANNEL or EXECUTABLE_PATH selects another local browser. "connect"
|
|
26
26
|
# uses a Playwright protocol endpoint; "connectOverCDP" attaches to a running
|
|
27
27
|
# Chromium browser; "disabled" explicitly removes rendered HTML retrieval.
|
|
28
28
|
PLURNK_SCHEMES_HTTP_PLAYWRIGHT_METHOD=launch
|
|
@@ -44,13 +44,16 @@ PLURNK_SCHEMES_HTTP_MOBILE=1
|
|
|
44
44
|
# 0 opts into revalidation on every read via ETag/304.
|
|
45
45
|
# Required read: unset crashes, naming the var.
|
|
46
46
|
PLURNK_SCHEMES_HTTP_TTL_MS=300000
|
|
47
|
-
# Max HTTP redirect hops
|
|
48
|
-
#
|
|
49
|
-
# none (strictest). Required read: unset crashes, naming the var.
|
|
47
|
+
# Max HTTP redirect hops automatic WebFetcher acquisition follows. Every hop is
|
|
48
|
+
# checked; 0 follows none. Required read: unset crashes, naming the var.
|
|
50
49
|
PLURNK_SCHEMES_HTTP_REDIRECTS=5
|
|
51
50
|
# Maximum buffered characters in one incomplete SSE line/event. Exceeding this
|
|
52
51
|
# bound terminates the remote stream instead of allowing unbounded memory growth.
|
|
53
52
|
PLURNK_SCHEMES_HTTP_SSE_MAX_BUFFER_CHARS=1048576
|
|
53
|
+
# Maximum characters retained from a caught fetch, render, or transport
|
|
54
|
+
# diagnostic in a model-facing Problem detail. Complete errors remain in daemon
|
|
55
|
+
# diagnostics.
|
|
56
|
+
PLURNK_SCHEMES_HTTP_ERROR_DETAIL_LIMIT=512
|
|
54
57
|
|
|
55
58
|
# ── Optional modes (absence IS the mode — never floor-set) ──────────────────
|
|
56
59
|
# Required by connect/connectOverCDP: the Playwright or CDP endpoint.
|
|
@@ -63,7 +66,6 @@ PLURNK_SCHEMES_HTTP_SSE_MAX_BUFFER_CHARS=1048576
|
|
|
63
66
|
# Chromium JS heap cap in MB (--max-old-space-size). Unset → chromium default.
|
|
64
67
|
# PLURNK_SCHEMES_HTTP_CHROMIUM_HEAP_MB=2048
|
|
65
68
|
|
|
66
|
-
# Native Playwright
|
|
67
|
-
#
|
|
69
|
+
# Native Playwright browser-location controls remain authoritative. This example
|
|
70
|
+
# is intentionally unset; the package never supplies its own path.
|
|
68
71
|
# PLAYWRIGHT_BROWSERS_PATH=/var/cache/ms-playwright
|
|
69
|
-
# PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
package/README.md
CHANGED
|
@@ -1,41 +1,88 @@
|
|
|
1
1
|
# plurnk-schemes-http
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
HTTP(S) request/response and WebSocket scheme handlers for the
|
|
4
|
+
[plurnk](https://github.com/plurnk/plurnk-service) agent runtime. The package is
|
|
5
|
+
authored against the DB-free
|
|
6
|
+
[`@plurnk/plurnk-schemes`](https://github.com/plurnk/plurnk-service/tree/main/plurnk-schemes)
|
|
7
|
+
`SchemeCtx` contract.
|
|
4
8
|
|
|
5
|
-
##
|
|
9
|
+
## HTTP operations
|
|
6
10
|
|
|
7
|
-
|
|
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 |
|
|
8
21
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
| `FIND(http(s)://host/path):matcher` | Materialize an exact URL when necessary, then query it through the standard entry FIND contract. Glob/regex scopes query already-materialized web entries. |
|
|
13
|
-
| `SEND[200](http(s)://…)` | Request with a body (POST); response streams back the same way. |
|
|
14
|
-
| `SEND[499](http(s)://…)` | Cancel an in-flight request (abort the fetch). |
|
|
15
|
-
| `SEND[410](http(s)://…)` | Delete the cached response entry. |
|
|
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.
|
|
16
25
|
|
|
17
|
-
|
|
26
|
+
## HTTP channels
|
|
18
27
|
|
|
19
|
-
|
|
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 |
|
|
20
33
|
|
|
21
|
-
|
|
22
|
-
|
|
34
|
+
A fragmentless operation publishes only `body`; auxiliary channels remain
|
|
35
|
+
durable and can be addressed explicitly. Remote HTTP status is stored in
|
|
36
|
+
`header`; the PLURNK operation result reports the streaming lifecycle.
|
|
37
|
+
Binary responses use an installed bounded readable projection when available;
|
|
38
|
+
only derived Unicode becomes durable. Otherwise direct operations preserve a
|
|
39
|
+
typed empty marker and return `415`, while exact query preparation prunes the
|
|
40
|
+
unreadable result from automatic search ingestion. Input above the common
|
|
41
|
+
projection ceiling returns `413`.
|
|
23
42
|
|
|
24
43
|
## Design
|
|
25
44
|
|
|
26
|
-
-
|
|
27
|
-
|
|
28
|
-
-
|
|
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`.
|
|
49
|
+
- 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.
|
|
53
|
+
- HTTP(S) and WS(S) entry identity retains protocol, authority, path, ordered
|
|
54
|
+
query, and explicit empty query; a fragment selects a channel.
|
|
55
|
+
- Handler-owned browser and socket state follows the shared readiness, drain,
|
|
56
|
+
and aggregate-shutdown lifecycle.
|
|
57
|
+
- All storage and streaming work uses `SchemeCtx` capabilities rather than a
|
|
58
|
+
raw database handle.
|
|
59
|
+
|
|
60
|
+
The same package registers `wss` (with `ws` routing to it) for
|
|
61
|
+
workspace-scoped full-duplex connections. See [`docs/wss.md`](docs/wss.md) for
|
|
62
|
+
its operation surface and current transport limits.
|
|
29
63
|
|
|
30
64
|
## Install
|
|
31
65
|
|
|
32
|
-
|
|
33
|
-
|
|
66
|
+
Requires Node.js 26 or newer.
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
npm i @plurnk/plurnk-schemes-http
|
|
70
|
+
plurnk start
|
|
34
71
|
```
|
|
35
72
|
|
|
36
|
-
|
|
37
|
-
|
|
73
|
+
The Playwright client is included. Provision a compatible local browser
|
|
74
|
+
separately, select an external Playwright/CDP endpoint, or disable rendering.
|
|
75
|
+
The shipped `.env.defaults` is the canonical operator configuration registry.
|
|
38
76
|
|
|
39
|
-
|
|
77
|
+
For local `launch`:
|
|
40
78
|
|
|
41
|
-
|
|
79
|
+
```sh
|
|
80
|
+
npx playwright install chromium
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Verify
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
npm test
|
|
87
|
+
npm run test:intg
|
|
88
|
+
```
|