@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.
@@ -1741,7 +1741,7 @@ function portCdpHook(ask, gone) {
1741
1741
  }
1742
1742
 
1743
1743
  // src/client/protocol.ts
1744
- var PROTOCOL = [1, 9];
1744
+ var PROTOCOL = [1, 10];
1745
1745
  var FS_METHODS = [
1746
1746
  "readFile",
1747
1747
  "writeFile",
@@ -2150,6 +2150,7 @@ function id(value) {
2150
2150
  return value;
2151
2151
  }
2152
2152
  function changeCred(cur, change) {
2153
+ if (typeof change !== "object" || change === null) throw fsError("EINVAL", "not a change");
2153
2154
  const privileged = cur.euid === 0;
2154
2155
  const next2 = copyCred(cur);
2155
2156
  for (const keys of [UIDS, GIDS]) {
@@ -4093,6 +4094,10 @@ async function watchOp(l, req, watches, send, g) {
4093
4094
  watches.set(req.id, unwatch);
4094
4095
  return { result: req.id };
4095
4096
  }
4097
+ var TRAITS_WATCH = -1;
4098
+ function traitsWatch(launcher, transport, send) {
4099
+ return launcher.onTraits(() => send({ traits: transport.traits }));
4100
+ }
4096
4101
  function serveClient(port, host) {
4097
4102
  let state = "new";
4098
4103
  let self;
@@ -4144,6 +4149,7 @@ function serveClient(port, host) {
4144
4149
  ...host.lock ? { lock: host.lock } : {}
4145
4150
  }
4146
4151
  });
4152
+ watches.set(TRAITS_WATCH, traitsWatch(launcher, transport, send));
4147
4153
  }
4148
4154
  async function terminal(req, l) {
4149
4155
  const session = await l.openTerminal(req.argv, {
@@ -14101,7 +14107,9 @@ function replayingHops(inner, heldMs = HELD_MS) {
14101
14107
  return bodiless(hop);
14102
14108
  };
14103
14109
  return {
14104
- traits: { ...inner.traits, manualRedirects: true },
14110
+ get traits() {
14111
+ return { ...inner.traits, manualRedirects: true };
14112
+ },
14105
14113
  ...inner.websocket ? { websocket: inner.websocket.bind(inner) } : {},
14106
14114
  async fetch(request2, owner = KERNEL) {
14107
14115
  const key = keyOf2(owner, request2.method, request2.url);
@@ -16540,6 +16548,7 @@ var Launcher = class {
16540
16548
  this.env = { ...networkEnv(hostname), SLICC_CDP_URL: this.cdp.url, ...options.env };
16541
16549
  this.ca = kernelCa(options.caStore ?? memoryCaStore());
16542
16550
  this.transport = replayingHops(options.transport ?? missingTransport());
16551
+ this.announcedTraits = JSON.stringify(this.transport.traits);
16543
16552
  this.uplink = options.uplink;
16544
16553
  this.routes = new Routes(options.uplink?.traits.ipv6 === true);
16545
16554
  if (options.uplink?.routes) this.routes.set(options.uplink.routes);
@@ -16611,6 +16620,19 @@ var Launcher = class {
16611
16620
  setRoutes(table) {
16612
16621
  this.routes.set(table);
16613
16622
  }
16623
+ traitsListeners = /* @__PURE__ */ new Set();
16624
+ announcedTraits = "";
16625
+ onTraits(listener) {
16626
+ this.traitsListeners.add(listener);
16627
+ return () => this.traitsListeners.delete(listener);
16628
+ }
16629
+ updateTransportTraits() {
16630
+ const now = JSON.stringify(this.transport.traits);
16631
+ if (now === this.announcedTraits) return false;
16632
+ this.announcedTraits = now;
16633
+ for (const listener of [...this.traitsListeners]) listener();
16634
+ return true;
16635
+ }
16614
16636
  commands(scope = "") {
16615
16637
  let found = this.catalogs.get(scope);
16616
16638
  if (!found) {
@@ -17812,6 +17834,14 @@ function sealedAsker(port) {
17812
17834
  }
17813
17835
 
17814
17836
  // src/serve.ts
17837
+ function networkOp(l, req, remote) {
17838
+ if (req.op === "routes") {
17839
+ l.setRoutes(req.routes);
17840
+ return true;
17841
+ }
17842
+ if (remote && req.traits) remote.traits = req.traits;
17843
+ return l.updateTransportTraits();
17844
+ }
17815
17845
  async function inOpfs(deps, root) {
17816
17846
  if (deps.syncAccess !== true) return false;
17817
17847
  const opfs = await deps.storage().catch(() => void 0);
@@ -18081,9 +18111,8 @@ function serveKernel(port, deps) {
18081
18111
  if (req.op === "open-terminal") return terminal(req);
18082
18112
  if (req.op === "connect") return connect(req.user, req.tag);
18083
18113
  if (isUsersRequest(req)) return usersOp(await ready2(), req);
18084
- if (req.op === "routes") {
18085
- (await ready2()).setRoutes(req.routes);
18086
- return true;
18114
+ if (req.op === "routes" || req.op === "transport-traits") {
18115
+ return networkOp(await ready2(), req, remote);
18087
18116
  }
18088
18117
  if (req.op === "dial") return dial(await ready2(), req);
18089
18118
  if (req.op === "mount" || req.op === "umount" || req.op === "mounts" || req.op === "insert")