@ai-ecoverse/slicc-kernel 1.43.1 → 1.44.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
@@ -1071,7 +1071,7 @@ var RemoteTransport = class {
1071
1071
  };
1072
1072
 
1073
1073
  // src/client/protocol.ts
1074
- var PROTOCOL = [1, 7];
1074
+ var PROTOCOL = [1, 8];
1075
1075
  function locksOf(scope = globalThis) {
1076
1076
  const locks = scope.navigator?.locks;
1077
1077
  return typeof locks?.request === "function" ? locks : void 0;
@@ -1256,6 +1256,8 @@ async function spawnOn(channel, argv, opts) {
1256
1256
  if (opts.pgid !== void 0)
1257
1257
  await since(channel, 3, "spawn into a process group", async () => {
1258
1258
  });
1259
+ if (opts.user !== void 0) await since(channel, 8, "spawn as a user", async () => {
1260
+ });
1259
1261
  const started = Promise.withResolvers();
1260
1262
  const options = { ...rest, ...stdin !== void 0 ? { stdin: bytesOf(stdin) } : {} };
1261
1263
  const { done } = channel.request(
@@ -1294,6 +1296,8 @@ async function runOn(channel, argv, opts) {
1294
1296
  }
1295
1297
  async function terminalOn(channel, argv, opts) {
1296
1298
  const { onData, ...options } = opts;
1299
+ if (opts.user !== void 0) await since(channel, 8, "a terminal as a user", async () => {
1300
+ });
1297
1301
  let listener = onData ?? null;
1298
1302
  const backlog = [];
1299
1303
  const started = Promise.withResolvers();
@@ -1688,6 +1692,16 @@ function cdpBridge(hook) {
1688
1692
  }
1689
1693
  };
1690
1694
  }
1695
+ function failed(message, code) {
1696
+ return Object.assign(new Error(message), code === void 0 ? {} : { code });
1697
+ }
1698
+ function kernelUsers(call) {
1699
+ return {
1700
+ add: async (user) => await call({ op: "users-add", user }),
1701
+ remove: async (name, options) => await call({ op: "users-remove", name, ...options ? { options } : {} }),
1702
+ list: async () => await call({ op: "users-list" })
1703
+ };
1704
+ }
1691
1705
  async function createKernel(options = {}) {
1692
1706
  if (!globalThis.crossOriginIsolated) throw new Error(ISOLATION);
1693
1707
  if (options.hostname !== void 0 && !isHostname(options.hostname)) {
@@ -1761,7 +1775,7 @@ async function createKernel(options = {}) {
1761
1775
  if (data.fd !== void 0) return call2.output?.(data.fd, data.bytes);
1762
1776
  if (data.started !== void 0) return call2.started?.(data.started);
1763
1777
  pending.delete(data.id);
1764
- if (data.error !== void 0) call2.reject(new Error(data.error));
1778
+ if (data.error !== void 0) call2.reject(failed(data.error, data.code));
1765
1779
  else call2.resolve(data.result);
1766
1780
  }
1767
1781
  );
@@ -1832,7 +1846,8 @@ async function createKernel(options = {}) {
1832
1846
  };
1833
1847
  },
1834
1848
  openTerminal,
1835
- connect: async () => await call({ op: "connect" }),
1849
+ connect: async (connectOptions = {}) => await call({ op: "connect", ...connectOptions }),
1850
+ users: kernelUsers(call),
1836
1851
  setRoutes: async (routes) => void await call({ op: "routes", routes }),
1837
1852
  dial,
1838
1853
  loopbackFetch: (input, fetchOptions) => loopbackFetch(dial, input, fetchOptions),