@ai-ecoverse/slicc-kernel 1.78.1 → 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, {
@@ -10147,6 +10152,7 @@ function pidStat(info, boot) {
10147
10152
  }
10148
10153
  var sigMask = (mask = 0) => (mask >>> 1).toString(16).padStart(16, "0");
10149
10154
  var STATES = { S: "S (sleeping)", T: "T (stopped)", Z: "Z (zombie)" };
10155
+ var tagLine = (tag) => `Tag: ${tag.replaceAll("\n", "\\n").replaceAll(" ", "\\t").replaceAll("\r", "\\r")}`;
10150
10156
  function pidStatus(info) {
10151
10157
  const state = STATES[info.state];
10152
10158
  const c = info.cred ?? ROOT;
@@ -10162,6 +10168,7 @@ function pidStatus(info) {
10162
10168
  "TracerPid: 0",
10163
10169
  `Uid: ${ids(c.ruid, c.euid, c.suid)}`,
10164
10170
  `Gid: ${ids(c.rgid, c.egid, c.sgid)}`,
10171
+ ...info.tag !== void 0 ? [tagLine(info.tag)] : [],
10165
10172
  "FDSize: 64",
10166
10173
  `VmSize: ${Math.ceil(info.memory / KIB)} kB`,
10167
10174
  `VmRSS: ${Math.ceil(info.memory / KIB)} kB`,
@@ -14099,7 +14106,9 @@ function replayingHops(inner, heldMs = HELD_MS) {
14099
14106
  return bodiless(hop);
14100
14107
  };
14101
14108
  return {
14102
- traits: { ...inner.traits, manualRedirects: true },
14109
+ get traits() {
14110
+ return { ...inner.traits, manualRedirects: true };
14111
+ },
14103
14112
  ...inner.websocket ? { websocket: inner.websocket.bind(inner) } : {},
14104
14113
  async fetch(request2, owner = KERNEL) {
14105
14114
  const key = keyOf2(owner, request2.method, request2.url);
@@ -16538,6 +16547,7 @@ var Launcher = class {
16538
16547
  this.env = { ...networkEnv(hostname), SLICC_CDP_URL: this.cdp.url, ...options.env };
16539
16548
  this.ca = kernelCa(options.caStore ?? memoryCaStore());
16540
16549
  this.transport = replayingHops(options.transport ?? missingTransport());
16550
+ this.announcedTraits = JSON.stringify(this.transport.traits);
16541
16551
  this.uplink = options.uplink;
16542
16552
  this.routes = new Routes(options.uplink?.traits.ipv6 === true);
16543
16553
  if (options.uplink?.routes) this.routes.set(options.uplink.routes);
@@ -16609,6 +16619,19 @@ var Launcher = class {
16609
16619
  setRoutes(table) {
16610
16620
  this.routes.set(table);
16611
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
+ }
16612
16635
  commands(scope = "") {
16613
16636
  let found = this.catalogs.get(scope);
16614
16637
  if (!found) {
@@ -17132,6 +17155,7 @@ var Launcher = class {
17132
17155
  const cred = this.credOf(member.pid);
17133
17156
  if (!maySee(viewer, cred)) continue;
17134
17157
  const root = rootOf(member);
17158
+ const tag = this.tagOf(member.pid) ?? this.tagOf(root.pid);
17135
17159
  listed.push({
17136
17160
  pid: root.pid,
17137
17161
  tid: member.pid,
@@ -17146,7 +17170,8 @@ var Launcher = class {
17146
17170
  ...this.childrenOf(root.pid),
17147
17171
  umask: this.umaskOf(member.pid),
17148
17172
  cred,
17149
- ...this.signalMasksOf(member.pid)
17173
+ ...this.signalMasksOf(member.pid),
17174
+ ...tag !== void 0 && maySee(viewer, cred) ? { tag } : {}
17150
17175
  });
17151
17176
  }
17152
17177
  return listed;
@@ -17808,6 +17833,14 @@ function sealedAsker(port) {
17808
17833
  }
17809
17834
 
17810
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
+ }
17811
17844
  async function inOpfs(deps, root) {
17812
17845
  if (deps.syncAccess !== true) return false;
17813
17846
  const opfs = await deps.storage().catch(() => void 0);
@@ -18077,9 +18110,8 @@ function serveKernel(port, deps) {
18077
18110
  if (req.op === "open-terminal") return terminal(req);
18078
18111
  if (req.op === "connect") return connect(req.user, req.tag);
18079
18112
  if (isUsersRequest(req)) return usersOp(await ready2(), req);
18080
- if (req.op === "routes") {
18081
- (await ready2()).setRoutes(req.routes);
18082
- return true;
18113
+ if (req.op === "routes" || req.op === "transport-traits") {
18114
+ return networkOp(await ready2(), req, remote);
18083
18115
  }
18084
18116
  if (req.op === "dial") return dial(await ready2(), req);
18085
18117
  if (req.op === "mount" || req.op === "umount" || req.op === "mounts" || req.op === "insert")