@ai-ecoverse/slicc-kernel 1.159.6 → 1.160.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/README.md CHANGED
@@ -423,6 +423,7 @@ The module's default export (or its `main` export) is called with a context and
423
423
  - `sync.runScript(source, { filename })` (#1541, slicc-jsh#977) runs `source` as a classic script in the program's own global scope, synchronously, as Node's `vm.runInThisContext` does: `let`, `const` and `class` land in the global lexical scope, `var` (in strict code too) on the global object, and stack frames are named `filename` (default `[eval]`). On the Node entry it returns `{ value, completion: true }` with the completion value, and an error the script throws is thrown as it is. In a browser, where process workers are module workers with no synchronous classic-script path, it returns `undefined`, so a runtime feature-detects it with `ctx.sync.runScript('1') !== undefined`. A non-string `source` or `filename` is a `TypeError` everywhere. The script sees exactly the globals the program sees, `import()` inside it is refused, and a `var`, function or `let` declaration can't replace a global the program can't assign: a non-configurable one stays as it is, and the only configurable, non-assignable ones (`crypto`, `navigator`) are ones the program can already redefine with `Object.defineProperty`.
424
424
  - `sync.promiseState(promise)` (#1531, slicc-jsh#974) tells a native promise's state synchronously, as Node's `util.inspect` does: `{ state: 'pending' | 'fulfilled' | 'rejected', value }`. `value` is the very fulfillment value or rejection reason (`undefined` while pending), and probing doesn't handle a rejection. On the Node entry it reads the promise through an inspector session the process worker opens on first use, one per process and per thread; the probe runs no program code. Anything that isn't a native promise (a thenable, a proxy) is a `TypeError`. It answers `undefined` in a browser, where a worker has no inspector, on a Node built without one, once a program has changed `Object.prototype` or put a `toJSON` on a built-in prototype, and when the global object can't take a new property (`Object.preventExtensions(globalThis)`, or a frozen global).
425
425
  - **Kernel frames in a program's stacks** (#1583): on the Node entry, the process worker's bundle names itself `slicc-kernel:/node-process-worker.js` (a `sourceURL`), so the kernel's own frames in an error a program sees (its own errors, a failed `ctx` call, `runScript`) show that name and not the host directory the kernel is installed in. The same holds in `CallSite.toString()` and `getScriptNameOrSourceURL()`, which a program's own `Error.prepareStackTrace` gets; `getFileName()` still returns the bundle's file URL. Line and column numbers are unchanged, so they still point into `dist/node-process-worker.js`. Don't run an embedder with `--enable-source-maps` if program-visible paths matter: Node then maps the kernel's frames back to the absolute paths of its sources. In a browser the frames keep the bundle's URL, because Chrome ignores `sourceURL` in a module worker loaded by URL.
426
+ - `module` (#1598, slicc-jsh#566) is a frozen `{ path }` with the command module's own path in the kernel's file system (e.g. `/usr/lib/node_modules/jsh/dist/jsh.mjs`), so a program can read its package's other files through `ctx.fs` on first use. It's the path the kernel found the package under, with symlinks left as they are (a pnpm-style `node_modules/<name>` link stays in it), and reads the same files through `ctx.fs`. It's a kernel path, never a host one, and a thread gets the same. It's absent for the kernel's built-in programs (`sudo`, `crontab`) and for a program run from inline source with no file.
426
427
  - `memory()`, synchronous and without a kernel call, measures the calling isolate: each `thread` answers for its own (#1240, slicc-jsh#397). It returns a fresh plain object of numbers in bytes, each field only where it's measured: `heapUsed`, `heapTotal`, `heapLimit` (V8's heap size limit), `external`, `arrayBuffers` and `rss`. On the Node entry they come from V8's heap statistics and Node's memory usage, through functions the worker captured before its lockdown, so nothing reachable from the program leads back to `process` or `v8`. `rss` is the host process's resident set size, as a Node worker thread reports it in `process.memoryUsage().rss`: it isn't per process, but shared by every process and thread of the kernel, and by any other kernel in that host process (#1563, slicc-jsh#539). In a browser `memory()` answers `{}` for now, with no `rss`.
427
428
  - **`thread`, kernel threads of the same process** ([#1094](https://github.com/ai-ecoverse/slicc-kernel/issues/1094)), the base for Node's `worker_threads` (tinypool, piscina, vitest's and jest's thread pools, eslint's concurrency). `thread.spawn({ data, transfer })` resolves with `{ tid, port, exited, terminate() }`.
428
429
  - **What a thread is:** a new process worker in the **same process**. It has the same pid, descriptor table, cwd, umask, credentials and lockdown, and a sync lane of its own, so `sync` calls in one thread don't hold another.
@@ -8236,7 +8236,7 @@ function satisfies(version, range2) {
8236
8236
  }
8237
8237
 
8238
8238
  // src/version.ts
8239
- var KERNEL_VERSION = true ? "1.159.6" : "0.0.0-dev";
8239
+ var KERNEL_VERSION = true ? "1.160.0" : "0.0.0-dev";
8240
8240
  var OS_RELEASE = "6.0.0-slicc";
8241
8241
  function procVersion() {
8242
8242
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -7352,7 +7352,7 @@ var init_version = __esm({
7352
7352
  "src/version.ts"() {
7353
7353
  "use strict";
7354
7354
  init_captured_globals();
7355
- KERNEL_VERSION = true ? "1.159.6" : "0.0.0-dev";
7355
+ KERNEL_VERSION = true ? "1.160.0" : "0.0.0-dev";
7356
7356
  OS_RELEASE = "6.0.0-slicc";
7357
7357
  }
7358
7358
  });
@@ -16179,9 +16179,12 @@ function scriptRunner(run) {
16179
16179
  };
16180
16180
  }
16181
16181
  function hostExtras(o) {
16182
+ const path = o.modulePath;
16183
+ const module = path === void 0 ? {} : { module: capturedObject.freeze({ path }) };
16182
16184
  return {
16183
16185
  memory: () => measured(o.memory),
16184
- ...o.asyncContext ? { asyncContext: o.asyncContext() } : {}
16186
+ ...o.asyncContext ? { asyncContext: o.asyncContext() } : {},
16187
+ ...module
16185
16188
  };
16186
16189
  }
16187
16190
  function cleanOf(sab) {
@@ -16756,6 +16759,7 @@ async function runJs(init, port3, deps, thread) {
16756
16759
  memory: deps.memory,
16757
16760
  asyncContext: deps.asyncContext,
16758
16761
  runScript: deps.runScript,
16762
+ modulePath: modulePathOf(init.program),
16759
16763
  promiseState: deps.promiseState,
16760
16764
  ...thread?.owned ? { owned: thread.owned } : {},
16761
16765
  held: init.held,
@@ -16801,6 +16805,10 @@ async function runJs(init, port3, deps, thread) {
16801
16805
  if (exitedWith !== void 0) return exitedWith;
16802
16806
  return status2;
16803
16807
  }
16808
+ function modulePathOf(program) {
16809
+ if (program.glue !== "") return void 0;
16810
+ return program.path;
16811
+ }
16804
16812
  var NOT_RUNNABLE;
16805
16813
  var init_js_runtime = __esm({
16806
16814
  "src/process/js/js-runtime.ts"() {