@plurnk/plurnk-schemes-http 1.3.12 → 1.5.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.
Files changed (47) hide show
  1. package/.env.defaults +18 -46
  2. package/README.md +74 -23
  3. package/SPEC.md +487 -124
  4. package/dist/Config.d.ts +3 -0
  5. package/dist/Config.d.ts.map +1 -0
  6. package/dist/Config.js +18 -0
  7. package/dist/Config.js.map +1 -0
  8. package/dist/ContentType.d.ts +2 -0
  9. package/dist/ContentType.d.ts.map +1 -0
  10. package/dist/ContentType.js +15 -0
  11. package/dist/ContentType.js.map +1 -0
  12. package/dist/ErrorDetail.d.ts +6 -0
  13. package/dist/ErrorDetail.d.ts.map +1 -0
  14. package/dist/ErrorDetail.js +19 -0
  15. package/dist/ErrorDetail.js.map +1 -0
  16. package/dist/Guard.d.ts +1 -1
  17. package/dist/Guard.d.ts.map +1 -1
  18. package/dist/Guard.js +95 -55
  19. package/dist/Guard.js.map +1 -1
  20. package/dist/Http.d.ts +3 -16
  21. package/dist/Http.d.ts.map +1 -1
  22. package/dist/Http.js +817 -331
  23. package/dist/Http.js.map +1 -1
  24. package/dist/TavilyExtract.d.ts +35 -0
  25. package/dist/TavilyExtract.d.ts.map +1 -0
  26. package/dist/TavilyExtract.js +204 -0
  27. package/dist/TavilyExtract.js.map +1 -0
  28. package/dist/WebFetcher.d.ts +88 -18
  29. package/dist/WebFetcher.d.ts.map +1 -1
  30. package/dist/WebFetcher.js +588 -70
  31. package/dist/WebFetcher.js.map +1 -1
  32. package/dist/Ws.d.ts +7 -3
  33. package/dist/Ws.d.ts.map +1 -1
  34. package/dist/Ws.js +432 -96
  35. package/dist/Ws.js.map +1 -1
  36. package/dist/index.d.ts +2 -3
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +4 -10
  39. package/dist/index.js.map +1 -1
  40. package/docs/http.md +108 -53
  41. package/docs/wss.md +39 -43
  42. package/package.json +14 -13
  43. package/dist/Browser.d.ts +0 -84
  44. package/dist/Browser.d.ts.map +0 -1
  45. package/dist/Browser.js +0 -273
  46. package/dist/Browser.js.map +0 -1
  47. package/scripts/install-browser.mjs +0 -19
package/dist/index.d.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  export { default } from "./Http.ts";
2
2
  export { default as Http } from "./Http.ts";
3
3
  export { default as Ws } from "./Ws.ts";
4
- export { default as Browser } from "./Browser.ts";
5
- export type { ChromiumEngine, ChromiumFactory, RenderResult } from "./Browser.ts";
6
4
  export { default as WebFetcher } from "./WebFetcher.ts";
7
- export type { WebFetchResult } from "./WebFetcher.ts";
5
+ export { PROJECTION_ID_HEADER, WebMaterializationError } from "./WebFetcher.ts";
6
+ export type { WebFetchResult, WebMaterializedResult } from "./WebFetcher.ts";
8
7
  export { default as Guard, GuardBlockedError } from "./Guard.ts";
9
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC;AAK5C,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AAIxC,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC;AAClD,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGlF,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC;AAG5C,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AAGxC,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAChF,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,16 +1,10 @@
1
- // Public API barrel for @plurnk/plurnk-schemes-http.
2
- // The default export is the scheme class plurnk-service registers at boot
3
- // (plugin discovery scans node_modules/@plurnk/* for `plurnk.kind === "scheme"`).
1
+ // Public package surface. package.json owns plugin registration {§http-manifest}.
4
2
  export { default } from "./Http.js";
5
3
  export { default as Http } from "./Http.js";
6
- // The WebSocket scheme (#468/#473) — this package's second first-class scheme,
7
- // registered `wss` via package.json plurnk.schemes ({ export: "Ws" }); the `ws`
8
- // prefix rides it (core's schemeNameOf, mirroring https → http).
4
+ // The registered WebSocket handler {§ws}.
9
5
  export { default as Ws } from "./Ws.js";
10
- // Standalone render foundation — exported so a future plurnk browser-
11
- // troubleshooting MCP package can sit on the same warm-Chromium pool.
12
- export { default as Browser } from "./Browser.js";
13
- // The guarded prefetch acquisition seam core's entrySink calls (#454).
6
+ // Automatic entry-acquisition primitive {§prefetch} and its URL check.
14
7
  export { default as WebFetcher } from "./WebFetcher.js";
8
+ export { PROJECTION_ID_HEADER, WebMaterializationError } from "./WebFetcher.js";
15
9
  export { default as Guard, GuardBlockedError } from "./Guard.js";
16
10
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,0EAA0E;AAC1E,kFAAkF;AAClF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC;AAE5C,+EAA+E;AAC/E,gFAAgF;AAChF,iEAAiE;AACjE,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AAExC,sEAAsE;AACtE,sEAAsE;AACtE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC;AAGlD,uEAAuE;AACvE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC;AAE5C,0CAA0C;AAC1C,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AAExC,uEAAuE;AACvE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAEhF,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
package/docs/http.md CHANGED
@@ -1,60 +1,115 @@
1
1
  # http(s)://
2
2
 
3
- Fetch a URL. HTML is rendered (headless browser, post-JS) and returned as
4
- **markdown by default** (main content; nav/ads/chrome stripped). Non-HTML
5
- returns its readable content under the response `Content-Type`. Every request
6
- streams its response: status `102` now, then an ordinary fragmentless READ
7
- returns the sanitized body. Auxiliary transport/archive channels are never
8
- presented by default.
9
-
10
- Re-reading a URL without `<scope>` **revalidates** it: the prior fetch's validators (`ETag`/
11
- `Last-Modified`) go out on the next READ, and if the page is unchanged the
12
- stored copy is served without re-rendering — always fresh, but cheap when
13
- nothing changed. Within the operator's freshness window a re-read serves the
14
- stored copy directly, skipping even that check. You just READ again; there's
15
- no cache flag to manage.
16
-
17
- A scoped READ (`READ(url)<start,end>`) observes the already-materialized
18
- readable response without refetching it. If the URL has not been materialized,
19
- READ it once without a scope first.
20
-
21
- The HTTP method is the **op**:
22
-
23
- - `READ(http(s)://…)` — GET.
24
- - `SEND[200](http(s)://…):body:` — POST the body.
25
- - `EDIT(http(s)://…):body:` — PUT the body (replaces the whole resource; no `<L>`).
26
- - `KILL(http(s)://…)` — DELETE the resource.
27
-
28
- The ordinary URL is the model-facing markdown for HTML, or readable response
29
- content for other textual types. Diagnostic channels require explicit access:
30
-
31
- - `#html` — faithful rendered DOM for HTML (`text/html`)
32
- - `#header` — response status line + headers (`text/plain`)
33
-
34
- Request headers ride **inside the target** as trailing `{Key: value}` blocks —
35
- one header per block, so a value may contain commas/colons:
36
-
37
- ```
38
- READ(https://api.example.com/v1/me{Authorization: Bearer TOKEN}{Accept: application/json})
39
- EDIT(https://api.example.com/v1/thing/42{Authorization: Bearer TOKEN}{Content-Type: application/json}):{"done":true}:
3
+ Use a web URL as an addressable entry. Every exact READ acquires or refreshes a
4
+ complete representation when needed, then core selects the channel and applies
5
+ the requested text scope. HTML becomes a readable model-facing body (normally
6
+ Markdown); original server source is retained separately. Auxiliary channels
7
+ are never presented by default.
8
+
9
+ | Operation | Remote action | Effect |
10
+ | --------------------------------- | ------------- | -------------------------------------------------------------------------- |
11
+ | `READ(http(s)://…)<scope?>` | GET if needed | Acquire/reuse the complete response, then return the selected scoped text |
12
+ | `FIND(http(s)://…):matcher` | GET if needed | Prepare an exact URL, then return flat match locations |
13
+ | `SEND[200](http(s)://…):body:` | POST | Submit the body and stream the response |
14
+ | `EDIT(http(s)://…):body:` | PUT | Replace the whole remote resource; do not use a line scope |
15
+ | `KILL(http(s)://…)` | DELETE | Delete the remote resource and stream the response |
16
+
17
+ A path-pattern FIND searches only web entries already materialized in the
18
+ workspace; a pattern cannot discover the remote web. FIND returns navigation
19
+ metadata, not the selected page body. Use READ for content.
20
+
21
+ Caller cancellation of an exact acquisition returns `499 cancelled`.
22
+
23
+ | Response | `body` | Other channel |
24
+ | ------------------------------------ | --------------------------------------------------- | ---------------------------------------------- |
25
+ | Negotiated origin Markdown | Exact origin Markdown | Independently requested server HTML in `#html` |
26
+ | GET HTML | Tavily Markdown or local HTML-reader projection | Original server HTML in `#html` |
27
+ | GET `text/event-stream` | Event `data` chunks after READ `102` | Initial response in `#header` |
28
+ | Configured textual response | Complete Fetch-decoded text under its declared type | Status and headers in `#header` |
29
+ | Origin HTTP `4xx`/`5xx` | Preserve available origin or independently produced text | Exact status on each origin-backed channel |
30
+ | Binary with a readable projection | Derived Unicode under the projection output type | Origin type and projection ID in `#header` |
31
+ | Binary without a readable projection | No fabricated text representation | Exact `415` Problem |
32
+
33
+ Generic public HTML uses configured Tavily as its body producer. A recoverable
34
+ timeout, transport error, `429`, `5xx`, or per-URL extraction failure uses the
35
+ local HTML reader and records terminal body status `203`. Authentication,
36
+ provider rejection, and malformed provider responses are hard failures and do
37
+ not silently switch producers. Any authored target metadata makes HTML use the
38
+ local reader directly. Origin Markdown always wins without Tavily.
39
+
40
+ Projection presence is structural: a returned projection is accepted even
41
+ when its content is empty. `422 no-readable-projection` means the local route
42
+ produced no model-facing body. An internal projection exception returns
43
+ non-retryable `500 projection-failed`.
44
+
45
+ A binary response uses the installed mimetype reader when one supplies a
46
+ bounded Unicode projection; raw bytes never enter a durable channel. Without a
47
+ reader, finite GET preparation returns `415 binary-response-unsupported`
48
+ without fabricating an entry. Input above the configured byte ceiling returns
49
+ `413 projection-input-limit`. A streamed POST, PUT, or DELETE response already
50
+ owns lifecycle evidence in `#header`; do not retry a mutation solely to
51
+ retrieve its binary body.
52
+
53
+ `#header` contains origin and package acquisition evidence. A Tavily attempt
54
+ adds its route, status, timing, any reported request ID and credits, and bounded
55
+ failure evidence. `body`, `header`, and `html` carry independent durable
56
+ producer outcomes; the selected channel determines success. Thus `#html` or
57
+ `#header` can remain readable after a body failure, while a Tavily body can
58
+ succeed without fabricating unavailable server HTML. `SEND[code]` is never the
59
+ remote HTTP status. A direct non-success origin response is still materialized:
60
+ origin-backed channels carry its exact durable `http-response-status` Problem,
61
+ while independently produced Tavily content and acquisition headers retain
62
+ their own outcomes.
63
+
64
+ For SSE, the response and persisted `#header` establish acquisition. READ then
65
+ returns `102` while events continue. Origin close settles the subscription at
66
+ `200`; later cancellation or transfer failure settles it at `499` or `502`
67
+ without rewriting the initial READ.
68
+
69
+ Re-reading an exact URL can reuse only a complete GET acquired without
70
+ explicit request metadata whose response had no `Vary` field. Plurnk keeps one
71
+ representation per URL, so any target metadata or `Vary` response bypasses both
72
+ the freshness shortcut and old validators instead of creating a variant store.
73
+ Eligible content is served directly only while both the operator TTL and any
74
+ origin `max-age` or `Expires` lifetime remain live. `no-cache` requires origin
75
+ validation; `no-store` evidence remains in the log but supplies neither content
76
+ nor validators to a later request. Only singular, syntactically valid stored
77
+ validators are sent. A 304 restores a non-page representation only when its
78
+ ETag or Last-Modified value identifies the nominated representation; otherwise
79
+ acquisition fails without serving the stored body. Responses to POST, PUT, and
80
+ DELETE are not reused as later GET representations. A projected GET is reused
81
+ only while the installed reader has the same projection identity. Page bodies
82
+ likewise require the same origin-Markdown, local, Tavily depth/version, or
83
+ local-fallback route. Once stale, a page composite is fully reacquired without
84
+ old validators; an origin 304 cannot certify provider or auxiliary material.
85
+
86
+ Scope never suppresses acquisition or refresh. The HTTP producer cannot see the
87
+ fragment or text coordinates; after preparation, the fragment (or `body` by
88
+ default) selects a durable channel and core applies the range. Cold and warm
89
+ forms therefore have identical selection and scope semantics.
90
+
91
+ Request headers ride inside the target as ordered trailing `{Key: value}`
92
+ blocks, one header per block:
93
+
94
+ ```plurnk
95
+ <<READ(https://api.example.com/v1/me{Authorization: Bearer TOKEN}{Accept: application/json})::READ
96
+ <<EDIT(https://api.example.com/v1/thing/42{Authorization: Bearer TOKEN}{Content-Type: application/json}):{"done":true}:EDIT
40
97
  ```
41
98
 
42
- Percent-encode `)`, `<`, and `}` inside a header value (the path-encoding rule).
43
-
44
- Host handling: a GitHub `…/blob/…` URL is fetched as its `raw.githubusercontent.com`
45
- source (line-navigable, exact) rather than the JS code-viewer page — so
46
- `READ(https://github.com/owner/repo/blob/main/src/x.ts)` returns the file's source.
47
-
48
- Cancel / cache:
49
-
50
- - `SEND[499](http(s)://…)` — cancel an in-flight request (abort the fetch).
51
- - `SEND[410](http(s)://…)` — drop the locally cached copy, forcing the next READ
52
- to full-fetch instead of revalidate. A local cache drop, **not** an HTTP
53
- DELETE — use `KILL` to DELETE the remote resource.
99
+ Percent-encode `)`, `<`, and `}` inside a header value.
100
+ An exact FIND forwards these headers when it must acquire the URL, but the
101
+ result remains intentionally ineligible for later cache reuse. Target headers
102
+ are never forwarded to Tavily, so HTML requests carrying any explicit metadata
103
+ use the local HTML-reader projection. Executor-supplied HTML also stays local;
104
+ only generic web acquisition grants Tavily spending authority.
54
105
 
55
- The `SEND[code]` is loop disposition (`102`/`200`/…), never the HTTP status —
56
- the real `2xx`/`4xx` comes back in `#header`.
106
+ GET acquisition of a GitHub `…/blob/…` URL uses its
107
+ `raw.githubusercontent.com` source. The addressed GitHub URL remains entry
108
+ identity. POST, PUT, and DELETE never use that rewrite.
57
109
 
58
- Status: `102` streaming · `499` cancelled · `502` upstream/render failure.
110
+ | Control | Effect |
111
+ | ------------------------ | --------------------------------------------------------------------- |
112
+ | `SEND[499](http(s)://…)` | Cancel the routed in-flight acquisition |
113
+ | `SEND[410](http(s)://…)` | Delete the local stored response; the next READ must acquire it again |
59
114
 
60
- For a persistent, bidirectional connection, see the `wss://` scheme.
115
+ For a persistent bidirectional connection, use `wss://`.
package/docs/wss.md CHANGED
@@ -1,45 +1,41 @@
1
1
  # wss:// — WebSocket
2
2
 
3
- A full-duplex, persistent connection to a WebSocket origin. Unlike `http://`
4
- (request/response) or SSE (a one-way `http://` event stream), a WebSocket is
5
- **bidirectional and stateful**: you open it once, then send and receive on the
6
- same live connection until it closes.
7
-
8
- ## Ops
9
-
10
- | Op | Effect |
11
- | --- | --- |
12
- | `READ(wss://host/path)` | Open the socket. Inbound frames stream into the `messages` channel as they arrive; the READ holds until the socket closes. |
13
- | `SEND[200](wss://host/path):your message:` | Push a message onto the **already-open** socket. READ it first — a SEND with no open socket is a `409`. |
14
- | `SEND[499](wss://host/path)` | Cancel: closes the open socket. |
15
- | `KILL(wss://host/path)` | Close the open socket. |
16
-
17
- ```
18
- <<READ(wss://echo.websocket.events)::READ
19
- <<SEND[200](wss://echo.websocket.events):hello:SEND
20
- <<KILL(wss://echo.websocket.events)::KILL
21
- ```
22
-
23
- A READ returns `102 Processing` and the socket's inbound frames accumulate in the
24
- `messages` channel across turns — read them as they land, the way you read any
25
- streaming subscription. The connection stays open for concurrent `SEND`s until
26
- you `KILL` it or the origin closes.
27
-
28
- ## Model
29
-
30
- - **One socket per target, per workspace.** The connection a READ opens is keyed by
31
- its path; a later SEND/KILL to the same target acts on that connection.
32
- - **SSRF-guarded.** The target is resolved and checked before connecting — a
33
- `ws://`/`wss://` into loopback, link-local, or RFC-1918/CGNAT space is refused
34
- (`403`), the same guard the fetch path uses.
35
-
36
- ## Day-one limits
37
-
38
- - **Text frames only.** Binary frames stringify loosely; structured binary is a
39
- follow-up (#468).
40
- - **No reconnection.** A dropped socket closes the READ; re-READ to reopen.
41
- - **Default handshake identity.** Custom request headers on the WebSocket
42
- handshake aren't wired yet (the standard `WebSocket` constructor has no header
43
- slot); pending, tracked on #468.
44
-
45
- Runtime: Node ≥22 (global `WebSocket`).
3
+ Use WebSocket for a persistent, bidirectional connection. `wss` is a
4
+ stateful scheme, not an HTTP content type: READ claims a workspace address and
5
+ owns its socket until terminal settlement, while concurrent SEND and KILL
6
+ operations address that owner.
7
+
8
+ | Operation | Effect |
9
+ | ------------------------------------- | ------------------------------------------------------------------------------------------ |
10
+ | `READ(wss://host/path)` | Claim the address, connect, mark `messages` active on `open`, and stream inbound frames |
11
+ | A second `READ` of the same address | Return `409` until the existing owner's terminal cleanup releases the claim |
12
+ | `SEND[200](wss://host/path):message:` | Send only through an open socket; claimed, connecting, or settling owners return `409` |
13
+ | `SEND[499](wss://host/path)` | Cancel the owning READ through its routed subscription handle |
14
+ | `KILL(wss://host/path)` | Close or cancel the claimed owner; an address with no owner is `404` |
15
+
16
+ | Owner state | Meaning | `SEND[200]` |
17
+ | ------------ | ---------------------------------------------------- | ------------------------------------------------ |
18
+ | `claimed` | Address reserved while entry/subscription setup runs | `409`; no second ownership path is created |
19
+ | `connecting` | Native socket exists but has not emitted `open` | `409`; wait for the active stream event |
20
+ | `open` | `open` was observed and the native state is open | Sends the message |
21
+ | `settling` | A terminal transition owns cleanup | `409`; wait for cleanup before another READ |
22
+
23
+ The native `open` event plus durable `messages` activation is the acquisition
24
+ boundary. It emits the ordinary metadata-only stream event and returns the READ
25
+ at `102`; later operations from the same worker or client may then SEND or KILL
26
+ the live owner. A close before acquisition is a direct `502` connection
27
+ failure. After acquisition, close, cancellation, and failure settle the retained
28
+ subscription without rewriting the initial READ.
29
+
30
+ Connection identity includes the workspace, exact `ws`/`wss` protocol, host,
31
+ non-default port, path, and ordered query. A fragment does not change socket
32
+ identity; `messages` is the only current channel.
33
+
34
+ | Current transport boundary | Behavior |
35
+ | -------------------------- | ----------------------------------------------------------------------- |
36
+ | Inbound payload | String event data only; no coercion or binary projection |
37
+ | Inbound order | Native event order; one durable write completes before the next begins |
38
+ | Binary inbound payload | Keep the text prefix, prune the suffix, settle `415`, and close with private-use code `4003` |
39
+ | Persistence failure | Keep the successful prefix; prune queued and later frames; settle `500` |
40
+ | Reconnection | None; READ again after terminal cleanup |
41
+ | Handshake headers | Target header metadata is not applied |
package/package.json CHANGED
@@ -1,21 +1,25 @@
1
1
  {
2
2
  "name": "@plurnk/plurnk-schemes-http",
3
- "version": "1.3.12",
4
- "description": "http(s):// URI scheme handler for the plurnk agent runtime — fetch + streaming response body.",
3
+ "version": "1.5.0",
4
+ "description": "HTTP(S) request/response and WebSocket scheme handlers for the plurnk agent runtime.",
5
5
  "keywords": [
6
6
  "plurnk",
7
7
  "scheme",
8
8
  "uri",
9
9
  "http",
10
- "https"
10
+ "https",
11
+ "websocket",
12
+ "ws",
13
+ "wss"
11
14
  ],
12
- "homepage": "https://github.com/plurnk/plurnk-schemes-http#readme",
15
+ "homepage": "https://github.com/plurnk/plurnk-service/tree/main/plurnk-schemes-http#readme",
13
16
  "bugs": {
14
- "url": "https://github.com/plurnk/plurnk-schemes-http/issues"
17
+ "url": "https://repo.possumtech.com/plurnk/plurnk-service/issues"
15
18
  },
16
19
  "repository": {
17
20
  "type": "git",
18
- "url": "git+https://github.com/plurnk/plurnk-schemes-http.git"
21
+ "url": "git+https://github.com/plurnk/plurnk-service.git",
22
+ "directory": "plurnk-schemes-http"
19
23
  },
20
24
  "engines": {
21
25
  "node": ">=26"
@@ -49,7 +53,6 @@
49
53
  },
50
54
  "files": [
51
55
  "dist/**/*",
52
- "scripts/**/*",
53
56
  ".env.defaults",
54
57
  "docs/**/*",
55
58
  "README.md",
@@ -58,19 +61,17 @@
58
61
  "scripts": {
59
62
  "test:lint": "tsc --noEmit",
60
63
  "test:unit": "node --conditions=plurnk-dev --test --env-file=.env.defaults src/**/*.test.ts",
61
- "test:intg": "node --conditions=plurnk-dev --test --env-file=.env.defaults test/integration/**/*.test.ts",
62
64
  "test": "npm run test:lint && npm run test:unit",
65
+ "build:clean": "rm -rf dist",
63
66
  "build:dist": "tsc -p tsconfig.build.json",
64
- "build": "npm run build:dist",
65
- "postinstall": "node scripts/install-browser.mjs",
67
+ "build": "npm run build:clean && npm run build:dist",
66
68
  "prepublishOnly": "npm audit --audit-level=moderate && npm test",
67
69
  "prepack": "npm run build"
68
70
  },
69
71
  "peerDependencies": {
70
- "@plurnk/plurnk-schemes": "^1.3.12"
72
+ "@plurnk/plurnk-schemes": "^1.5.0"
71
73
  },
72
74
  "dependencies": {
73
- "eventsource-parser": "^3.1.0",
74
- "playwright": "1.62.0"
75
+ "eventsource-parser": "^4.0.0"
75
76
  }
76
77
  }
package/dist/Browser.d.ts DELETED
@@ -1,84 +0,0 @@
1
- interface PwResponse {
2
- status(): number;
3
- statusText(): string;
4
- headers(): Record<string, string>;
5
- }
6
- interface PwRoute {
7
- request(): {
8
- url(): string;
9
- };
10
- continue(): Promise<void>;
11
- abort(): Promise<void>;
12
- }
13
- interface PwPage {
14
- route(pattern: string, handler: (route: PwRoute) => Promise<void>): Promise<void>;
15
- goto(url: string, opts: {
16
- waitUntil: "networkidle";
17
- timeout: number;
18
- }): Promise<PwResponse | null>;
19
- setExtraHTTPHeaders(headers: Record<string, string>): Promise<void>;
20
- content(): Promise<string>;
21
- evaluate<T>(fn: () => T): Promise<T>;
22
- close(): Promise<void>;
23
- }
24
- interface PwContext {
25
- newPage(): Promise<PwPage>;
26
- close(): Promise<void>;
27
- }
28
- interface PwContextOptions {
29
- userAgent: string;
30
- viewport: {
31
- width: number;
32
- height: number;
33
- };
34
- deviceScaleFactor: number;
35
- isMobile: boolean;
36
- hasTouch: boolean;
37
- }
38
- interface PwBrowser {
39
- newContext(options?: PwContextOptions): Promise<PwContext>;
40
- on(event: "disconnected", cb: () => void): void;
41
- close(): Promise<void>;
42
- }
43
- interface PwLaunchOptions {
44
- headless: boolean;
45
- chromiumSandbox: boolean;
46
- timeout: number;
47
- args: ReadonlyArray<string>;
48
- channel?: string;
49
- executablePath?: string;
50
- }
51
- interface PwConnectOptions {
52
- timeout: number;
53
- }
54
- export interface ChromiumEngine {
55
- launch(opts: PwLaunchOptions): Promise<PwBrowser>;
56
- connect(endpoint: string, opts: PwConnectOptions): Promise<PwBrowser>;
57
- connectOverCDP(endpoint: string, opts: PwConnectOptions): Promise<PwBrowser>;
58
- }
59
- export type ChromiumFactory = () => Promise<ChromiumEngine>;
60
- export type PlaywrightMethod = "launch" | "connect" | "connectOverCDP" | "disabled";
61
- export interface RenderResult {
62
- readonly status: number;
63
- readonly statusText: string;
64
- readonly headers: ReadonlyArray<readonly [string, string]>;
65
- readonly html: string;
66
- }
67
- export declare const BROWSER_UA = "Mozilla/5.0 (Linux; Android 13; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36";
68
- export declare const requireNumEnv: (key: string) => number;
69
- export default class Browser {
70
- #private;
71
- constructor(factory?: ChromiumFactory);
72
- ready(): Promise<PlaywrightMethod>;
73
- render(url: string, { workerId, signal, headers, guard, timeout }: {
74
- workerId: number;
75
- signal?: AbortSignal;
76
- headers?: ReadonlyArray<readonly [string, string]>;
77
- guard?: (url: string) => Promise<boolean>;
78
- timeout?: number;
79
- }): Promise<RenderResult>;
80
- closeContext(workerId: number): void;
81
- close(): Promise<void>;
82
- }
83
- export {};
84
- //# sourceMappingURL=Browser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Browser.d.ts","sourceRoot":"","sources":["../src/Browser.ts"],"names":[],"mappings":"AAmBA,UAAU,UAAU;IAChB,MAAM,IAAI,MAAM,CAAC;IACjB,UAAU,IAAI,MAAM,CAAC;IACrB,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC;AACD,UAAU,OAAO;IACb,OAAO,IAAI;QAAE,GAAG,IAAI,MAAM,CAAA;KAAE,CAAC;IAC7B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AACD,UAAU,MAAM;IACZ,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClF,IAAI,CAAC,GAAG,EAA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