@ai-ecoverse/slicc-jsh 0.1.0-8 → 0.2.1
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/NOTICE +25 -0
- package/README.md +38 -5
- package/dist/host/jsh.mjs +10 -0
- package/dist/host/main.mjs +893 -0
- package/dist/jsh.mjs +11541 -1934
- package/dist/meta-main.json +1 -1
- package/dist/node.mjs +11556 -1973
- package/package.json +27 -10
package/NOTICE
CHANGED
|
@@ -33,6 +33,31 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
33
33
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
34
34
|
SOFTWARE.
|
|
35
35
|
|
|
36
|
+
--------------------------------------------------------------------------------
|
|
37
|
+
This product bundles acorn (from npm). License text follows:
|
|
38
|
+
|
|
39
|
+
MIT License
|
|
40
|
+
|
|
41
|
+
Copyright (C) 2012-2022 by various contributors (see AUTHORS)
|
|
42
|
+
|
|
43
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
44
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
45
|
+
in the Software without restriction, including without limitation the rights
|
|
46
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
47
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
48
|
+
furnished to do so, subject to the following conditions:
|
|
49
|
+
|
|
50
|
+
The above copyright notice and this permission notice shall be included in
|
|
51
|
+
all copies or substantial portions of the Software.
|
|
52
|
+
|
|
53
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
54
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
55
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
56
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
57
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
58
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
59
|
+
THE SOFTWARE.
|
|
60
|
+
|
|
36
61
|
--------------------------------------------------------------------------------
|
|
37
62
|
This product bundles event-target-shim (from npm). License text follows:
|
|
38
63
|
|
package/README.md
CHANGED
|
@@ -2,13 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
A Node.js-compatible runtime for [slicc-kernel](https://github.com/ai-ecoverse/slicc-kernel): the `node` and `jsh` commands, built on the kernel's `abi: "js"` programs.
|
|
4
4
|
|
|
5
|
-
Design and milestones: [slicc-kernel#68](https://github.com/ai-ecoverse/slicc-kernel/issues/68).
|
|
5
|
+
Design and milestones: [slicc-kernel#68](https://github.com/ai-ecoverse/slicc-kernel/issues/68). Running `jsh` outside SLICC (host Node, CDP): [docs/design/run-outside-slicc.md](docs/design/run-outside-slicc.md) (#20).
|
|
6
6
|
|
|
7
7
|
## Status
|
|
8
8
|
|
|
9
|
-
**
|
|
9
|
+
**0.2.0** — ships M2 net/http/https, M3 ESM, and host `jsh` (#22). Requires `slicc-kernel` ≥ 1.53.2 (Buffer `allocUnsafe` leak fix; 1.53.3 is the certified kernel). Published to npm `latest`.
|
|
10
10
|
|
|
11
|
-
**
|
|
11
|
+
**M1 shipped (0.1.0-8)** — Node-entry lockdown ([slicc-kernel#297](https://github.com/ai-ecoverse/slicc-kernel/issues/297)): CJS wrapper is Node's 5-arg form; `process` / `Buffer` / timers are real globals; vendor stream/string_decoder share jsh's Buffer class; StringDecoder accepts TypedArrays; timer stacks keep script URLs. Certified on hb2.
|
|
12
|
+
|
|
13
|
+
**M2 shipped:** `globalThis.fetch` / `WebSocket` from kernel ≥ 1.53.0 `OPEN_SLOTS` (`ctx.fetch` / `ctx.websocket`). `net` / `http` on `ctx.net` (loopback TCP); `https.createServer` waits on TLS, `https.request`/`get` use `ctx.fetch` with `redirect: 'manual'` (Node entry) and fall back to `'follow'` on browser transports that reject manual redirects (`ENOTSUP`). jsh `Buffer.allocUnsafe` / `allocUnsafeSlow` zero-fill and `poolSize` is `0`.
|
|
14
|
+
|
|
15
|
+
**WebSocket / nodeTransport gap:** when `ctx.websocket` rejects, jsh maps that to an `error` Event (no `close`; `readyState` stays `CONNECTING`), matching Node 22 undici. On today's kernels the Node-entry `nodeTransport` / `fetchTransport` path often never rejects a failed connect (the transport ignores the socket `error` event before `open`), so a refused `ws://` can hang with no events until [slicc-kernel#366](https://github.com/ai-ecoverse/slicc-kernel/issues/366) lands. Do not probe with `ctx.net.connect` before open: that dials the **kernel** loopback, while `nodeTransport` WebSockets reach the **host**'s `127.0.0.1`.
|
|
16
|
+
|
|
17
|
+
**M3 shipped:** ESM — `.mjs` / `"type":"module"`, static `import`/`export`, dynamic `import()`, `import.meta.url` / `import.meta.resolve`, and CJS↔ESM interop (`import` of CJS, `require` of ESM, `package.json` `"exports"` `import`/`require` conditions). The transform uses **acorn** (bundled) so multi-line imports/exports, strings/comments, and `$` identifiers parse correctly; imports are hoisted and export getters are registered before evaluation for cycles. Node-style detect-module for `-e` / ambiguous `.js` (dynamic `import()` alone stays CJS).
|
|
18
|
+
|
|
19
|
+
**Host jsh (#22):** package `bin` is `dist/host/jsh.mjs` — run `.jsh` on host Node 22+ with the same body scope and `sliccy:` modules as in the kernel.
|
|
20
|
+
|
|
21
|
+
**HTTP/HTTPS limits (M2):** request and response bodies are buffered whole until `end()` when no `Content-Length` is set (then sent with a computed length); with `Content-Length`, body bytes stream as written. No chunked transfer encoding / SSE yet — multi-write responses still flush as one payload. Bodies over 64 MiB are rejected (`413` on the server, `ERR_OUT_OF_RANGE` on the client). `http.Agent` follows Node's `_http_agent.js` request path (`addRequest` → `createSocket` → `createConnection`) so **agent-base** / http(s)-proxy-agent subclasses work; `getName`, `destroy`, `keepSocketAlive`, `reuseSocket`, `removeSocket`, and `sockets` / `freeSockets` / `requests` are present. Keep-alive pooling is not implemented (`keepAlive` is accepted, `req.reusedSocket` is always `false`). `https.request` options `cert` / `key` / `pfx` / `ca` throw `ERR_NOT_SUPPORTED` (no client certs / custom CA on `ctx.fetch`). `rejectUnauthorized: false` is accepted but ignored — TLS verification stays stricter than Node with that flag. Responses with no `Content-Length` and no chunked encoding wait for the peer's FIN (`socket.end` half-closes via `writer.close()` only). On the **browser** entry, `https.get` tries `redirect: 'manual'` and falls back to `'follow'` when the transport rejects it with `ENOTSUP` — so plain requests work, but a redirect may be followed instead of surfaced (`statusCode` / `Location`). The Node entry's `nodeTransport` supports manual redirects. Embedders with `traits.redirectHops` (kernel #315) can surface redirects in the browser.
|
|
22
|
+
|
|
23
|
+
**npm ecosystem gaps:** packages that import `node:tty` (e.g. chalk's Node build) or need `crypto` (e.g. nanoid's main entry) fail with `ERR_NOT_SUPPORTED` until those modules ship. Prefer the browser/`default` export condition, or a fixture that pins it, when dogfooding. The `tls` module itself is unsupported (`ERR_NOT_SUPPORTED`) — so **http-proxy-agent** / **https-proxy-agent** (which import `tls` for CONNECT tunnels) cannot run yet even though `http.Agent` subclasses via agent-base work for plain `http`.
|
|
24
|
+
|
|
25
|
+
**Still later:** `child_process` / `crypto` / `zlib` / `readline` / `tty` / `tls` / `worker_threads` / TLS `https.createServer` throw `ERR_NOT_SUPPORTED` until their milestone.
|
|
12
26
|
|
|
13
27
|
JS program entries are **esbuild-bundled** to single files (`dist/node.mjs`, `dist/jsh.mjs`) because the kernel loads `abi: "js"` modules via `data:` URLs (relative imports do not resolve).
|
|
14
28
|
|
|
@@ -19,6 +33,18 @@ JS program entries are **esbuild-bundled** to single files (`dist/node.mjs`, `di
|
|
|
19
33
|
| `node` | `dist/node.mjs` | Node 22.x-compatible entry |
|
|
20
34
|
| `jsh` | `dist/jsh.mjs` | `.jsh` scripts; binfmt maps `.jsh` → `jsh` |
|
|
21
35
|
|
|
36
|
+
## `jsh` outside SLICC
|
|
37
|
+
|
|
38
|
+
The package's `bin` is the host `jsh` (`dist/host/jsh.mjs`), which runs `.jsh` scripts on the host's own Node 22+. Inside slicc-kernel (a global `pnpm add -g` puts this `bin` on `PATH` ahead of the kernel's `jsh`), it hands off to the kernel jsh instead:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm i -g @ai-ecoverse/slicc-jsh
|
|
42
|
+
jsh script.jsh args… # or ./script.jsh with #!/usr/bin/env jsh
|
|
43
|
+
npx @ai-ecoverse/slicc-jsh script.jsh
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
A `.jsh` file is the body of an async function with `process`, `console`, `require`, `module`, `exports`, `fetch`, `__dirname` and `__filename` in scope, the same in the kernel and on the host. `require('fs')` is Node's `fs`. Built-in `sliccy:` modules are `cli`, `color`, `exec`, `fmt`, `http`, `pool`, `skill` and `time`. Any other `sliccy:<name>` resolves to an `@ai-ecoverse/sliccy-<name>` or `sliccy-<name>` package; `sliccy:browser` over CDP comes from slicc-cdp ([slicc-cdp#40](https://github.com/ai-ecoverse/slicc-cdp/issues/40)). The parity tables are in the [design note](docs/design/run-outside-slicc.md#parity-tables).
|
|
47
|
+
|
|
22
48
|
## Develop
|
|
23
49
|
|
|
24
50
|
```bash
|
|
@@ -26,6 +52,7 @@ npm ci
|
|
|
26
52
|
npm run build
|
|
27
53
|
npm run lint
|
|
28
54
|
npm run test:golden # host Node 22 baselines (npx node@22)
|
|
55
|
+
npm run test:jsh # .jsh parity: host jsh baseline vs kernel jsh
|
|
29
56
|
npm run test:integration # slicc-kernel Node entry, memory root
|
|
30
57
|
```
|
|
31
58
|
|
|
@@ -33,8 +60,14 @@ Golden fixtures live under `test/golden/fixtures/` and are **not** published (`f
|
|
|
33
60
|
|
|
34
61
|
```bash
|
|
35
62
|
npm run golden:record
|
|
63
|
+
npm run jsh:record # .jsh cases under test/jsh/fixtures/, recorded with the host jsh
|
|
36
64
|
```
|
|
37
65
|
|
|
38
|
-
##
|
|
66
|
+
## Release
|
|
67
|
+
|
|
68
|
+
Releases are cut by [semantic-release](https://semantic-release.gitbook.io/) on every push to `main` (`.github/workflows/release.yml`, the shared `node-release.yml` from slicc-shared-web), as in the sibling repos. It runs `npm run lint` and `npm test` (golden, `.jsh` parity, kernel integration), then derives the version from the commits since the last `v*` tag:
|
|
69
|
+
- a `feat:` commit gives a minor release (0.x stays 0.x until a breaking change);
|
|
70
|
+
- a `fix:` or `perf:` commit gives a patch release;
|
|
71
|
+
- other types (`chore:`, `docs:`, `ci:`, `test:`, `merge:`, …) release nothing.
|
|
39
72
|
|
|
40
|
-
|
|
73
|
+
It publishes to npm `latest` with trusted publishing (OIDC) and provenance, and creates a GitHub release. `version` in `package.json` stays `0.0.0`; semantic-release sets the real one when it publishes. npm has to trust `release.yml` for this package once: `npm run trust` (fledgling) sets that up, and `npm run trust:dry` shows what it would do.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The package's `bin` (dist/host/jsh.mjs). No static imports: inside
|
|
3
|
+
// slicc-kernel this file can end up running under jsh's own `node` runtime
|
|
4
|
+
// (a global pnpm/npm install puts this bin on PATH ahead of the kernel's
|
|
5
|
+
// `jsh` command), where the host CLI's Node builtins are not available. That
|
|
6
|
+
// runtime advertises the kernel jsh under this symbol (src/jsh/kernel.mjs);
|
|
7
|
+
// nothing else sets it, so a real host always gets the host CLI.
|
|
8
|
+
const kernel = globalThis[Symbol.for('slicc-jsh.kernel')];
|
|
9
|
+
if (kernel) await kernel.runJsh(process.argv.slice(2));
|
|
10
|
+
else await import('./main.mjs');
|