@ai-ecoverse/slicc-kernel 1.180.0 → 1.182.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/dist/index.js CHANGED
@@ -1958,7 +1958,7 @@ var RemoteTransport = class {
1958
1958
  };
1959
1959
 
1960
1960
  // src/client/protocol.ts
1961
- var PROTOCOL = [1, 15];
1961
+ var PROTOCOL = [1, 17];
1962
1962
  function locksOf(scope = globalThis) {
1963
1963
  const locks = scope.navigator?.locks;
1964
1964
  return typeof locks?.request === "function" ? locks : void 0;
@@ -2264,6 +2264,19 @@ async function spawnOn(channel, argv, opts) {
2264
2264
  signal: async (name = "SIGTERM") => void await channel.call({ op: "kill", pid: -pgid, signal: name })
2265
2265
  };
2266
2266
  }
2267
+ async function sudoRunOn(channel, replay, { stdout, stderr, tag }) {
2268
+ await since(channel, 16, "sudoRun", async () => {
2269
+ });
2270
+ const started = Promise.withResolvers();
2271
+ let endedBy;
2272
+ const { done } = channel.request(
2273
+ { op: "sudo-run", replay, options: { stdout, stderr, tag } },
2274
+ { started: started.resolve, ended: (signal) => endedBy = signal }
2275
+ );
2276
+ done.catch(started.reject);
2277
+ const pid = await started.promise;
2278
+ return { pid, pgid: pid, ended: endedOf(done, () => endedBy) };
2279
+ }
2267
2280
  function endedOf(done, signal) {
2268
2281
  return quiet(
2269
2282
  done.then((status) => {
@@ -2465,6 +2478,7 @@ async function attachKernel(port, options = {}) {
2465
2478
  return () => channel.traitsListeners.delete(listener);
2466
2479
  },
2467
2480
  trace: (tag, onEvents, options2 = {}) => traceOn(channel, tag, onEvents, options2),
2481
+ sudoRun: (replay, options2 = {}) => sudoRunOn(channel, replay, options2),
2468
2482
  async close(o = {}) {
2469
2483
  if (channel.failure) return;
2470
2484
  await channel.call({ op: "detach", ...o.kill ? { kill: true } : {} }).catch(() => void 0);
@@ -2853,6 +2867,16 @@ function decodedRun(result) {
2853
2867
  stderr: decoder2.decode(result.stderr)
2854
2868
  };
2855
2869
  }
2870
+ async function sudoRunOn2(request, replay, { stdout, stderr, tag }) {
2871
+ const started = Promise.withResolvers();
2872
+ const { done } = request(
2873
+ { op: "sudo-run", replay, options: { stdout, stderr, tag } },
2874
+ { started: started.resolve }
2875
+ );
2876
+ done.catch(started.reject);
2877
+ const pid = await started.promise;
2878
+ return { pid, pgid: pid, ended: quiet(done.then(endedOf2)) };
2879
+ }
2856
2880
  function endedOf2(r) {
2857
2881
  if (typeof r === "number") return { status: r };
2858
2882
  const { status, signal } = r;
@@ -3018,6 +3042,7 @@ async function createKernel(options = {}) {
3018
3042
  return decodedRun(result);
3019
3043
  },
3020
3044
  openTerminal,
3045
+ sudoRun: (replay, sudoOptions = {}) => sudoRunOn2(request, replay, sudoOptions),
3021
3046
  connect: connector(call, bound),
3022
3047
  ...accounts(call, options.users === void 0 ? DEFAULT_USERS : options.users),
3023
3048
  setRoutes: async (routes) => void await call({ op: "routes", routes }),