@ai-ecoverse/slicc-jsh 0.2.1 → 0.3.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/dist/node.mjs CHANGED
@@ -1585,7 +1585,7 @@ function assignProcessExitCode(value) {
1585
1585
  // package.json
1586
1586
  var package_default = {
1587
1587
  name: "@ai-ecoverse/slicc-jsh",
1588
- version: "0.2.1",
1588
+ version: "0.3.1",
1589
1589
  description: "Node.js-compatible runtime for slicc-kernel: the node and jsh commands (abi: js)",
1590
1590
  type: "module",
1591
1591
  license: "Apache-2.0",
@@ -1639,7 +1639,7 @@ var package_default = {
1639
1639
  },
1640
1640
  scripts: {
1641
1641
  build: "node scripts/build.mjs && node scripts/build-host.mjs",
1642
- prepack: "npm run build",
1642
+ prepack: "npm run build && node scripts/strip-own-scripts.mjs",
1643
1643
  prepare: "npm run build",
1644
1644
  lint: "node scripts/lint.mjs",
1645
1645
  test: "npm run test:golden && npm run test:jsh && npm run test:integration",
@@ -1655,7 +1655,7 @@ var package_default = {
1655
1655
  "trust:dry": "npx fledgling sync --dry-run -y --skip-publish"
1656
1656
  },
1657
1657
  devDependencies: {
1658
- "@ai-ecoverse/slicc-kernel": "1.59.0",
1658
+ "@ai-ecoverse/slicc-kernel": "1.59.1",
1659
1659
  "@ai-ecoverse/wasi-pnpm": "12.9.1-8",
1660
1660
  "abort-controller": "3.0.0",
1661
1661
  acorn: "8.19.0",
@@ -10793,6 +10793,415 @@ function createEvents() {
10793
10793
  });
10794
10794
  }
10795
10795
 
10796
+ // src/runtime/builtins/child-process.mjs
10797
+ var SIGNAL_NAMES = {
10798
+ 1: "SIGHUP",
10799
+ 2: "SIGINT",
10800
+ 3: "SIGQUIT",
10801
+ 6: "SIGABRT",
10802
+ 9: "SIGKILL",
10803
+ 10: "SIGUSR1",
10804
+ 12: "SIGUSR2",
10805
+ 13: "SIGPIPE",
10806
+ 14: "SIGALRM",
10807
+ 15: "SIGTERM",
10808
+ 17: "SIGCHLD",
10809
+ 18: "SIGCONT",
10810
+ 19: "SIGSTOP",
10811
+ 20: "SIGTSTP"
10812
+ };
10813
+ var SIGNAL_NUMBERS = Object.fromEntries(
10814
+ Object.entries(SIGNAL_NAMES).map(([n, name]) => [name, Number(n)])
10815
+ );
10816
+ function notSupported(name) {
10817
+ const err = new Error(`slicc-jsh: child_process.${name} is not supported yet`);
10818
+ err.code = "ERR_NOT_SUPPORTED";
10819
+ throw err;
10820
+ }
10821
+ function normalizeArgs(file, args, options, callback) {
10822
+ if (typeof args === "function") {
10823
+ return { args: [], options: {}, callback: args };
10824
+ }
10825
+ if (typeof options === "function") {
10826
+ return { args: Array.isArray(args) ? args : [], options: {}, callback: options };
10827
+ }
10828
+ if (args != null && !Array.isArray(args) && typeof args === "object") {
10829
+ return { args: [], options: args, callback: typeof options === "function" ? options : callback };
10830
+ }
10831
+ return {
10832
+ args: Array.isArray(args) ? args.map(String) : [],
10833
+ options: options && typeof options === "object" ? options : {},
10834
+ callback: typeof callback === "function" ? callback : void 0
10835
+ };
10836
+ }
10837
+ function normalizeStdio(stdio) {
10838
+ if (stdio === void 0) return ["pipe", "pipe", "pipe"];
10839
+ if (typeof stdio === "string") return [stdio, stdio, stdio];
10840
+ if (Array.isArray(stdio)) {
10841
+ return [stdio[0] ?? "pipe", stdio[1] ?? "pipe", stdio[2] ?? "pipe"];
10842
+ }
10843
+ return ["pipe", "pipe", "pipe"];
10844
+ }
10845
+ function toKernelStdio(mode) {
10846
+ if (mode === "pipe" || mode === "overlapped") return "pipe";
10847
+ if (mode === "ignore" || mode === null || mode === void 0 || mode === "null") return "null";
10848
+ if (mode === "inherit") return "inherit";
10849
+ if (typeof mode === "number") return mode;
10850
+ const err = new Error(`The argument 'stdio' is invalid. Received ${String(mode)}`);
10851
+ err.code = "ERR_INVALID_ARG_VALUE";
10852
+ throw err;
10853
+ }
10854
+ function signalName(sig) {
10855
+ if (sig == null) return null;
10856
+ if (typeof sig === "string") return sig.startsWith("SIG") ? sig : `SIG${sig}`;
10857
+ if (typeof sig === "number") return SIGNAL_NAMES[sig] ?? String(sig);
10858
+ return null;
10859
+ }
10860
+ function spawnError(command, args, code, message) {
10861
+ const err = new Error(message ?? `spawn ${command} ${code}`);
10862
+ err.code = code;
10863
+ err.errno = code === "ENOENT" ? -2 : void 0;
10864
+ err.syscall = "spawn";
10865
+ err.path = command;
10866
+ err.spawnargs = args;
10867
+ return err;
10868
+ }
10869
+ function createChildProcess({ ctx, process: process2, Buffer: Buffer2, handles, getStream }) {
10870
+ class ChildProcess extends EventEmitter {
10871
+ constructor() {
10872
+ super();
10873
+ this.stdin = null;
10874
+ this.stdout = null;
10875
+ this.stderr = null;
10876
+ this.pid = void 0;
10877
+ this.exitCode = null;
10878
+ this.signalCode = null;
10879
+ this.killed = false;
10880
+ this.connected = false;
10881
+ this.spawnfile = "";
10882
+ this.spawnargs = [];
10883
+ this.#kernel = null;
10884
+ this.#handle = null;
10885
+ this.#closing = false;
10886
+ }
10887
+ #kernel;
10888
+ #handle;
10889
+ #closing;
10890
+ kill(signal = "SIGTERM") {
10891
+ const name = signalName(signal) ?? "SIGTERM";
10892
+ this.killed = true;
10893
+ if (!this.#kernel) return false;
10894
+ try {
10895
+ const ret = this.#kernel.kill(name);
10896
+ return ret !== false;
10897
+ } catch {
10898
+ return false;
10899
+ }
10900
+ }
10901
+ ref() {
10902
+ if (this.#handle) handles.add(this.#handle);
10903
+ return this;
10904
+ }
10905
+ unref() {
10906
+ if (this.#handle) handles.delete(this.#handle);
10907
+ return this;
10908
+ }
10909
+ /** @internal */
10910
+ _bindKernel(child) {
10911
+ this.#kernel = child;
10912
+ this.pid = child.pid;
10913
+ this.#handle = { kind: "child", pid: child.pid };
10914
+ handles.add(this.#handle);
10915
+ }
10916
+ /** @internal */
10917
+ _release() {
10918
+ if (this.#handle) {
10919
+ handles.delete(this.#handle);
10920
+ this.#handle = null;
10921
+ }
10922
+ }
10923
+ /** @internal */
10924
+ _markClosing() {
10925
+ this.#closing = true;
10926
+ }
10927
+ get _closing() {
10928
+ return this.#closing;
10929
+ }
10930
+ }
10931
+ function createPipeReadable() {
10932
+ const { Readable } = getStream();
10933
+ const r = new Readable({ read() {
10934
+ } });
10935
+ r._sliccPump = async (webStream) => {
10936
+ if (!webStream) {
10937
+ r.push(null);
10938
+ return;
10939
+ }
10940
+ try {
10941
+ const reader = webStream.getReader();
10942
+ for (; ; ) {
10943
+ const { done, value } = await reader.read();
10944
+ if (done) break;
10945
+ const chunk = value instanceof Uint8Array ? Buffer2.from(value) : Buffer2.from(String(value));
10946
+ r.push(chunk);
10947
+ }
10948
+ r.push(null);
10949
+ } catch (err) {
10950
+ r.destroy(err);
10951
+ }
10952
+ };
10953
+ return r;
10954
+ }
10955
+ function createPipeWritable() {
10956
+ const { Writable } = getStream();
10957
+ let writer = null;
10958
+ const pending = [];
10959
+ let ended = false;
10960
+ const w = new Writable({
10961
+ write(chunk, _enc, cb) {
10962
+ const bytes = typeof chunk === "string" ? Buffer2.from(chunk) : chunk;
10963
+ if (!writer) {
10964
+ pending.push({ bytes, cb });
10965
+ return;
10966
+ }
10967
+ writer.write(bytes).then(() => cb(), cb);
10968
+ },
10969
+ final(cb) {
10970
+ ended = true;
10971
+ if (!writer) {
10972
+ pending.push({ end: true, cb });
10973
+ return;
10974
+ }
10975
+ writer.close().then(() => cb(), cb);
10976
+ },
10977
+ destroy(err, cb) {
10978
+ if (writer) writer.abort(err).then(() => cb(err), () => cb(err));
10979
+ else cb(err);
10980
+ }
10981
+ });
10982
+ w._sliccAttach = (webStream) => {
10983
+ if (!webStream) {
10984
+ for (const p of pending) p.cb?.(new Error("stdin not available"));
10985
+ pending.length = 0;
10986
+ return;
10987
+ }
10988
+ writer = webStream.getWriter();
10989
+ for (const p of pending) {
10990
+ if (p.end) writer.close().then(() => p.cb(), p.cb);
10991
+ else writer.write(p.bytes).then(() => p.cb(), p.cb);
10992
+ }
10993
+ pending.length = 0;
10994
+ if (ended && pending.length === 0) {
10995
+ }
10996
+ };
10997
+ return w;
10998
+ }
10999
+ function prepareStdio(child, stdio) {
11000
+ const [inMode, outMode, errMode] = stdio;
11001
+ if (toKernelStdio(inMode) === "pipe") child.stdin = createPipeWritable();
11002
+ if (toKernelStdio(outMode) === "pipe") child.stdout = createPipeReadable();
11003
+ if (toKernelStdio(errMode) === "pipe") child.stderr = createPipeReadable();
11004
+ }
11005
+ function connectStdio(child, kernelChild) {
11006
+ child.stdin?._sliccAttach?.(kernelChild.stdin);
11007
+ const pumps = [];
11008
+ if (child.stdout?._sliccPump) pumps.push(child.stdout._sliccPump(kernelChild.stdout));
11009
+ if (child.stderr?._sliccPump) pumps.push(child.stderr._sliccPump(kernelChild.stderr));
11010
+ child._stdioPumps = Promise.all(pumps);
11011
+ }
11012
+ function finish(child, code, signal) {
11013
+ if (child._closing) return;
11014
+ child._markClosing();
11015
+ child.exitCode = code;
11016
+ child.signalCode = signal;
11017
+ child.emit("exit", code, signal);
11018
+ const after = child._stdioPumps ?? Promise.resolve();
11019
+ trackPromise(handles, after);
11020
+ after.finally(() => {
11021
+ child.emit("close", code, signal);
11022
+ child._release();
11023
+ handles.notify?.();
11024
+ });
11025
+ }
11026
+ function startSpawn(child, file, args, options, stdio) {
11027
+ const cwd = options.cwd != null ? String(options.cwd) : process2.cwd();
11028
+ const env = options.env ? { ...options.env } : { ...process2.env };
11029
+ const argv = [file, ...args];
11030
+ child.spawnfile = file;
11031
+ child.spawnargs = argv;
11032
+ const spawnPromise = ctx.spawn({
11033
+ argv,
11034
+ cwd,
11035
+ env,
11036
+ stdin: toKernelStdio(stdio[0]),
11037
+ stdout: toKernelStdio(stdio[1]),
11038
+ stderr: toKernelStdio(stdio[2])
11039
+ });
11040
+ trackPromise(handles, spawnPromise);
11041
+ spawnPromise.then(
11042
+ (kernelChild) => {
11043
+ child._bindKernel(kernelChild);
11044
+ connectStdio(child, kernelChild);
11045
+ child.emit("spawn");
11046
+ const waitP = kernelChild.wait();
11047
+ trackPromise(handles, waitP);
11048
+ waitP.then(
11049
+ (status) => {
11050
+ const sigNum = status?.signal;
11051
+ if (sigNum != null && sigNum !== 0) {
11052
+ const name = SIGNAL_NAMES[sigNum] ?? String(sigNum);
11053
+ finish(child, null, name);
11054
+ } else {
11055
+ const code = typeof status?.status === "number" ? status.status : 0;
11056
+ finish(child, code, null);
11057
+ }
11058
+ },
11059
+ (err) => {
11060
+ child.emit("error", err);
11061
+ finish(child, 1, null);
11062
+ }
11063
+ );
11064
+ },
11065
+ (err) => {
11066
+ const code = err?.code === "ENOENT" ? "ENOENT" : err?.code ?? "ERR_SPAWN_FAILED";
11067
+ const error = code === "ENOENT" ? spawnError(file, args, "ENOENT", `spawn ${file} ENOENT`) : spawnError(file, args, code, err?.message ?? String(err));
11068
+ try {
11069
+ child.stdout?.push?.(null);
11070
+ } catch {
11071
+ }
11072
+ try {
11073
+ child.stderr?.push?.(null);
11074
+ } catch {
11075
+ }
11076
+ process2.nextTick(() => {
11077
+ child.emit("error", error);
11078
+ if (code === "ENOENT") {
11079
+ child.exitCode = -2;
11080
+ child.emit("close", -2, null);
11081
+ } else {
11082
+ finish(child, 1, null);
11083
+ }
11084
+ child._release();
11085
+ handles.notify?.();
11086
+ });
11087
+ }
11088
+ );
11089
+ }
11090
+ function spawn(command, args, options) {
11091
+ let file = command;
11092
+ let argv = args;
11093
+ let opts = options;
11094
+ if (argv != null && !Array.isArray(argv) && typeof argv === "object") {
11095
+ opts = argv;
11096
+ argv = [];
11097
+ }
11098
+ argv = Array.isArray(argv) ? argv.map(String) : [];
11099
+ opts = opts && typeof opts === "object" ? opts : {};
11100
+ file = String(file);
11101
+ if (opts.shell) {
11102
+ const shell = typeof opts.shell === "string" ? opts.shell : "sh";
11103
+ const line = argv.length ? [file, ...argv].join(" ") : file;
11104
+ file = shell;
11105
+ argv = ["-c", line];
11106
+ }
11107
+ const stdio = normalizeStdio(opts.stdio);
11108
+ const child = new ChildProcess();
11109
+ prepareStdio(child, stdio);
11110
+ process2.nextTick(() => startSpawn(child, file, argv, opts, stdio));
11111
+ return child;
11112
+ }
11113
+ function execFile(file, args, options, callback) {
11114
+ const norm = normalizeArgs(file, args, options, callback);
11115
+ const opts = { ...norm.options };
11116
+ if (opts.stdio === void 0) opts.stdio = ["pipe", "pipe", "pipe"];
11117
+ const child = spawn(String(file), norm.args, opts);
11118
+ if (!norm.callback) return child;
11119
+ const maxBuffer = opts.maxBuffer ?? 1024 * 1024;
11120
+ let stdout = Buffer2.alloc(0);
11121
+ let stderr = Buffer2.alloc(0);
11122
+ let exited = false;
11123
+ const done = (err) => {
11124
+ if (exited) return;
11125
+ exited = true;
11126
+ const enc = opts.encoding;
11127
+ const out = enc ? stdout.toString(enc) : stdout;
11128
+ const errOut = enc ? stderr.toString(enc) : stderr;
11129
+ norm.callback(err, out, errOut);
11130
+ };
11131
+ if (child.stdout) {
11132
+ child.stdout.on("data", (chunk) => {
11133
+ stdout = Buffer2.concat([stdout, Buffer2.isBuffer(chunk) ? chunk : Buffer2.from(chunk)]);
11134
+ if (stdout.length > maxBuffer) {
11135
+ child.kill();
11136
+ const err = new Error("stdout maxBuffer exceeded");
11137
+ err.code = "ERR_CHILD_PROCESS_STDIO_MAXBUFFER";
11138
+ done(err);
11139
+ }
11140
+ });
11141
+ }
11142
+ if (child.stderr) {
11143
+ child.stderr.on("data", (chunk) => {
11144
+ stderr = Buffer2.concat([stderr, Buffer2.isBuffer(chunk) ? chunk : Buffer2.from(chunk)]);
11145
+ if (stderr.length > maxBuffer) {
11146
+ child.kill();
11147
+ const err = new Error("stderr maxBuffer exceeded");
11148
+ err.code = "ERR_CHILD_PROCESS_STDIO_MAXBUFFER";
11149
+ done(err);
11150
+ }
11151
+ });
11152
+ }
11153
+ child.on("error", (err) => done(err));
11154
+ child.on("close", (code, signal) => {
11155
+ if (exited) return;
11156
+ if (code === 0 && !signal) {
11157
+ done(null);
11158
+ return;
11159
+ }
11160
+ const err = new Error(`Command failed: ${file} ${norm.args.join(" ")}`);
11161
+ err.code = code;
11162
+ err.killed = child.killed;
11163
+ err.signal = signal;
11164
+ err.cmd = `${file} ${norm.args.join(" ")}`.trim();
11165
+ err.stdout = opts.encoding ? stdout.toString(opts.encoding) : stdout;
11166
+ err.stderr = opts.encoding ? stderr.toString(opts.encoding) : stderr;
11167
+ done(err);
11168
+ });
11169
+ return child;
11170
+ }
11171
+ function exec(command, options, callback) {
11172
+ let opts = options;
11173
+ let cb = callback;
11174
+ if (typeof options === "function") {
11175
+ cb = options;
11176
+ opts = {};
11177
+ }
11178
+ opts = opts && typeof opts === "object" ? opts : {};
11179
+ const shell = typeof opts.shell === "string" ? opts.shell : "sh";
11180
+ return execFile(shell, ["-c", String(command)], { ...opts, shell: false }, cb);
11181
+ }
11182
+ return {
11183
+ spawn,
11184
+ execFile,
11185
+ exec,
11186
+ spawnSync() {
11187
+ notSupported("spawnSync");
11188
+ },
11189
+ execSync() {
11190
+ notSupported("execSync");
11191
+ },
11192
+ execFileSync() {
11193
+ notSupported("execFileSync");
11194
+ },
11195
+ fork() {
11196
+ notSupported("fork");
11197
+ },
11198
+ ChildProcess,
11199
+ // Expose for tests / advanced callers
11200
+ _SIGNAL_NAMES: SIGNAL_NAMES,
11201
+ _SIGNAL_NUMBERS: SIGNAL_NUMBERS
11202
+ };
11203
+ }
11204
+
10796
11205
  // src/runtime/builtins/fs.mjs
10797
11206
  var encoder3 = new TextEncoder();
10798
11207
  var decoder3 = new TextDecoder();
@@ -11187,6 +11596,21 @@ function createFs({ ctx, path, process: process2, Buffer: Buffer2, handles, getS
11187
11596
  throw nodeFsError(err?.code || "ENOENT", "lstat", pathArg, err);
11188
11597
  }
11189
11598
  },
11599
+ /**
11600
+ * Resolve to a canonical absolute path. Symlink walk is not implemented;
11601
+ * when the path exists we return the normalized absolute form (enough for
11602
+ * pnpm's cmd shims, which only need dirname(realpathSync(argv[1]))).
11603
+ */
11604
+ realpathSync(p) {
11605
+ const pathArg = p;
11606
+ const target = abs(p);
11607
+ try {
11608
+ syncFs.stat(target);
11609
+ return target;
11610
+ } catch (err) {
11611
+ throw nodeFsError(err?.code || "ENOENT", "realpath", pathArg, err);
11612
+ }
11613
+ },
11190
11614
  readdirSync,
11191
11615
  mkdirSync,
11192
11616
  rmdirSync(p, options = {}) {
@@ -11825,6 +12249,7 @@ function createFs({ ctx, path, process: process2, Buffer: Buffer2, handles, getS
11825
12249
  access: callbackify(syncApi.accessSync),
11826
12250
  stat: callbackify(syncApi.statSync),
11827
12251
  lstat: callbackify(syncApi.lstatSync),
12252
+ realpath: callbackify(syncApi.realpathSync),
11828
12253
  readdir: callbackify(syncApi.readdirSync),
11829
12254
  mkdir: callbackify(syncApi.mkdirSync),
11830
12255
  rmdir: callbackify(syncApi.rmdirSync),
@@ -12685,7 +13110,7 @@ function createHttp2({ ctx, process: process2, Buffer: Buffer2, handles, getStre
12685
13110
 
12686
13111
  // src/runtime/builtins/https.mjs
12687
13112
  var TLS_CLIENT_OPTS = ["cert", "key", "pfx", "ca"];
12688
- function notSupported(what) {
13113
+ function notSupported2(what) {
12689
13114
  const err = new Error(`slicc-jsh: '${what}' is not supported yet (no TLS on ctx.net)`);
12690
13115
  err.code = "ERR_NOT_SUPPORTED";
12691
13116
  return err;
@@ -12699,7 +13124,7 @@ function isManualRedirectUnsupported(err) {
12699
13124
  function rejectTlsOptions(options) {
12700
13125
  for (const name of TLS_CLIENT_OPTS) {
12701
13126
  if (options?.[name] != null) {
12702
- throw notSupported(`https.request option '${name}'`);
13127
+ throw notSupported2(`https.request option '${name}'`);
12703
13128
  }
12704
13129
  }
12705
13130
  }
@@ -12733,7 +13158,7 @@ function createHttps({ ctx, Buffer: Buffer2, http, handles }) {
12733
13158
  }
12734
13159
  }
12735
13160
  function createServer() {
12736
- throw notSupported("https.createServer");
13161
+ throw notSupported2("https.createServer");
12737
13162
  }
12738
13163
  class ClientRequest extends EventEmitter {
12739
13164
  #ended = false;
@@ -12824,7 +13249,7 @@ function createHttps({ ctx, Buffer: Buffer2, http, handles }) {
12824
13249
  if (this.#sent || this.#destroyed) return;
12825
13250
  this.#sent = true;
12826
13251
  try {
12827
- if (typeof ctx.fetch !== "function") throw notSupported("https.request");
13252
+ if (typeof ctx.fetch !== "function") throw notSupported2("https.request");
12828
13253
  const opts = this.#opts;
12829
13254
  const method = (opts.method ?? "GET").toUpperCase();
12830
13255
  const host = opts.hostname ?? opts.host ?? "localhost";
@@ -13713,6 +14138,7 @@ var BUILTIN_LIST = [
13713
14138
  "assert",
13714
14139
  "assert/strict",
13715
14140
  "buffer",
14141
+ "child_process",
13716
14142
  "console",
13717
14143
  "events",
13718
14144
  "fs",
@@ -13736,7 +14162,6 @@ var BUILTIN_LIST = [
13736
14162
  "util/types"
13737
14163
  ];
13738
14164
  var NOT_YET = [
13739
- "child_process",
13740
14165
  "http2",
13741
14166
  "crypto",
13742
14167
  "zlib",
@@ -13755,7 +14180,7 @@ var NOT_YET = [
13755
14180
  "v8",
13756
14181
  "was"
13757
14182
  ];
13758
- function notSupported2(id) {
14183
+ function notSupported3(id) {
13759
14184
  const err = new Error(`slicc-jsh: '${id}' is not supported yet`);
13760
14185
  err.code = "ERR_NOT_SUPPORTED";
13761
14186
  throw err;
@@ -13801,6 +14226,13 @@ function createBuiltins({ ctx, process: process2, Buffer: Buffer2, console: cons
13801
14226
  if (!https) https = createHttps({ ctx, Buffer: Buffer2, http: getHttp(), handles });
13802
14227
  return https;
13803
14228
  };
14229
+ let childProcess;
14230
+ const getChildProcess = () => {
14231
+ if (!childProcess) {
14232
+ childProcess = createChildProcess({ ctx, process: process2, Buffer: Buffer2, handles, getStream });
14233
+ }
14234
+ return childProcess;
14235
+ };
13804
14236
  let ModuleExport = null;
13805
14237
  const implemented = {
13806
14238
  process: () => process2,
@@ -13826,7 +14258,8 @@ function createBuiltins({ ctx, process: process2, Buffer: Buffer2, console: cons
13826
14258
  "timers/promises": () => timersPromises,
13827
14259
  net: () => getNet(),
13828
14260
  http: () => getHttp(),
13829
- https: () => getHttps()
14261
+ https: () => getHttps(),
14262
+ child_process: () => getChildProcess()
13830
14263
  };
13831
14264
  return {
13832
14265
  installModule(Module) {
@@ -13840,7 +14273,7 @@ function createBuiltins({ ctx, process: process2, Buffer: Buffer2, console: cons
13840
14273
  },
13841
14274
  load(id) {
13842
14275
  const bare = id.startsWith("node:") ? id.slice(5) : id;
13843
- if (NOT_YET.includes(bare)) notSupported2(bare);
14276
+ if (NOT_YET.includes(bare)) notSupported3(bare);
13844
14277
  const factory = implemented[bare];
13845
14278
  if (!factory) {
13846
14279
  const err = new Error(`No such built-in module: ${id}`);
@@ -15892,6 +16325,42 @@ var Process = class extends EventEmitter {
15892
16325
  cwd() {
15893
16326
  return this._cwd;
15894
16327
  }
16328
+ /** Root (0) until credential plumbing is exposed on process. */
16329
+ getuid() {
16330
+ return 0;
16331
+ }
16332
+ geteuid() {
16333
+ return 0;
16334
+ }
16335
+ getgid() {
16336
+ return 0;
16337
+ }
16338
+ getegid() {
16339
+ return 0;
16340
+ }
16341
+ getgroups() {
16342
+ return [0];
16343
+ }
16344
+ /**
16345
+ * Minimal process.kill: only this process (pid === this.pid). Used by pnpm
16346
+ * cmd shims to re-raise a child's terminating signal. Unknown pids → ESRCH.
16347
+ */
16348
+ kill(pid, signal = "SIGTERM") {
16349
+ const target = Number(pid);
16350
+ if (target !== this.pid) {
16351
+ const err = new Error(`kill ESRCH`);
16352
+ err.code = "ESRCH";
16353
+ err.errno = -3;
16354
+ err.syscall = "kill";
16355
+ throw err;
16356
+ }
16357
+ const name = typeof signal === "string" ? signal.startsWith("SIG") ? signal : `SIG${signal}` : "SIGTERM";
16358
+ if (name === "SIGTERM" || name === "SIGINT" || name === "SIGHUP" || name === "SIGKILL") {
16359
+ const codes = { SIGTERM: 143, SIGINT: 130, SIGHUP: 129, SIGKILL: 137 };
16360
+ this.exit(codes[name] ?? 1);
16361
+ }
16362
+ return true;
16363
+ }
15895
16364
  chdir(path) {
15896
16365
  if (typeof path !== "string") {
15897
16366
  const err = new TypeError(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-jsh",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
4
4
  "description": "Node.js-compatible runtime for slicc-kernel: the node and jsh commands (abi: js)",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -54,8 +54,6 @@
54
54
  },
55
55
  "scripts": {
56
56
  "build": "node scripts/build.mjs && node scripts/build-host.mjs",
57
- "prepack": "npm run build",
58
- "prepare": "npm run build",
59
57
  "lint": "node scripts/lint.mjs",
60
58
  "test": "npm run test:golden && npm run test:jsh && npm run test:integration",
61
59
  "test:golden": "node --max-old-space-size=512 scripts/golden.mjs check",
@@ -70,7 +68,7 @@
70
68
  "trust:dry": "npx fledgling sync --dry-run -y --skip-publish"
71
69
  },
72
70
  "devDependencies": {
73
- "@ai-ecoverse/slicc-kernel": "1.59.0",
71
+ "@ai-ecoverse/slicc-kernel": "1.59.1",
74
72
  "@ai-ecoverse/wasi-pnpm": "12.9.1-8",
75
73
  "abort-controller": "3.0.0",
76
74
  "acorn": "8.19.0",