@ai-ecoverse/slicc-kernel 1.79.0 → 1.81.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.
@@ -2768,7 +2768,7 @@ function importKey(namespace, name2, glue) {
2768
2768
  const literal = LITERALS[name2];
2769
2769
  return typeof namespace[literal] === "function" ? literal : void 0;
2770
2770
  }
2771
- function wrapImport(imports, name2, glue, wrap2) {
2771
+ function wrapImport(imports, name2, glue, wrap2, optional = false) {
2772
2772
  let wrapped = false;
2773
2773
  for (const ns of namespaces(imports)) {
2774
2774
  const key = importKey(ns, name2, glue);
@@ -2776,7 +2776,7 @@ function wrapImport(imports, name2, glue, wrap2) {
2776
2776
  ns[key] = wrap2(ns[key]);
2777
2777
  wrapped = true;
2778
2778
  }
2779
- if (!wrapped && typeof glue?.[name2] === "function") {
2779
+ if (!wrapped && !optional && typeof glue?.[name2] === "function") {
2780
2780
  throw new Error(`slicc-kernel cannot find the glue's ${LITERALS[name2]} among its imports`);
2781
2781
  }
2782
2782
  }
@@ -4719,12 +4719,18 @@ function holdWhileStopped(imports, header, glue) {
4719
4719
  while (Atomics.load(header, SAB_I_STOP) === 1) Atomics.wait(header, SAB_I_STOP, 1);
4720
4720
  };
4721
4721
  for (const name2 of ["fdWrite", "fdRead", "sleepMs"]) {
4722
- wrapImport(imports, name2, glue, (original) => (...args) => {
4723
- hold();
4724
- const done = original(...args);
4725
- hold();
4726
- return done;
4727
- });
4722
+ wrapImport(
4723
+ imports,
4724
+ name2,
4725
+ glue,
4726
+ (original) => (...args) => {
4727
+ hold();
4728
+ const done = original(...args);
4729
+ hold();
4730
+ return done;
4731
+ },
4732
+ true
4733
+ );
4728
4734
  }
4729
4735
  }
4730
4736
  function callerOwner(Fs, init) {
@@ -13171,7 +13177,12 @@ function createContext(o) {
13171
13177
  exiting ??= status2 & 255;
13172
13178
  return exitAtOnce(lane, [...writes], terminal.modes(), exiting);
13173
13179
  },
13174
- kill: killer({ self: o.pid, kernel, syncKernel, lane, writes, modes: terminal.modes })
13180
+ kill: killer({ self: o.pid, kernel, syncKernel, lane, writes, modes: terminal.modes }),
13181
+ cred: () => syncKernel.json({ op: "proc-cred" }),
13182
+ setcred(change) {
13183
+ if (typeof change !== "object" || change === null) throw new JsCallError("EINVAL", "setcred");
13184
+ return syncKernel.json({ op: "proc-setcred", change: { ...change } });
13185
+ }
13175
13186
  };
13176
13187
  const io = { read: read2, send: writeAll, close: (fd) => ctx.close(fd) };
13177
13188
  const children = childOps(kernel, io, { env: o.env, cwd: o.cwd, signal: signalNumber });