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