@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.
package/dist/node.js CHANGED
@@ -2479,7 +2479,7 @@ var UserDb = class {
2479
2479
  };
2480
2480
 
2481
2481
  // src/client/protocol.ts
2482
- var PROTOCOL = [1, 9];
2482
+ var PROTOCOL = [1, 10];
2483
2483
  var FS_METHODS = [
2484
2484
  "readFile",
2485
2485
  "writeFile",
@@ -2729,6 +2729,10 @@ async function watchOp(l, req, watches, send, g) {
2729
2729
  watches.set(req.id, unwatch);
2730
2730
  return { result: req.id };
2731
2731
  }
2732
+ var TRAITS_WATCH = -1;
2733
+ function traitsWatch(launcher, transport, send) {
2734
+ return launcher.onTraits(() => send({ traits: transport.traits }));
2735
+ }
2732
2736
  function serveClient(port, host) {
2733
2737
  let state = "new";
2734
2738
  let self;
@@ -2780,6 +2784,7 @@ function serveClient(port, host) {
2780
2784
  ...host.lock ? { lock: host.lock } : {}
2781
2785
  }
2782
2786
  });
2787
+ watches.set(TRAITS_WATCH, traitsWatch(launcher, transport, send));
2783
2788
  }
2784
2789
  async function terminal(req, l) {
2785
2790
  const session = await l.openTerminal(req.argv, {
@@ -8565,6 +8570,7 @@ function pidStat(info, boot) {
8565
8570
  }
8566
8571
  var sigMask = (mask = 0) => (mask >>> 1).toString(16).padStart(16, "0");
8567
8572
  var STATES = { S: "S (sleeping)", T: "T (stopped)", Z: "Z (zombie)" };
8573
+ var tagLine = (tag) => `Tag: ${tag.replaceAll("\n", "\\n").replaceAll(" ", "\\t").replaceAll("\r", "\\r")}`;
8568
8574
  function pidStatus(info) {
8569
8575
  const state = STATES[info.state];
8570
8576
  const c = info.cred ?? ROOT;
@@ -8580,6 +8586,7 @@ function pidStatus(info) {
8580
8586
  "TracerPid: 0",
8581
8587
  `Uid: ${ids(c.ruid, c.euid, c.suid)}`,
8582
8588
  `Gid: ${ids(c.rgid, c.egid, c.sgid)}`,
8589
+ ...info.tag !== void 0 ? [tagLine(info.tag)] : [],
8583
8590
  "FDSize: 64",
8584
8591
  `VmSize: ${Math.ceil(info.memory / KIB)} kB`,
8585
8592
  `VmRSS: ${Math.ceil(info.memory / KIB)} kB`,
@@ -13838,7 +13845,9 @@ function replayingHops(inner, heldMs = HELD_MS) {
13838
13845
  return bodiless(hop);
13839
13846
  };
13840
13847
  return {
13841
- traits: { ...inner.traits, manualRedirects: true },
13848
+ get traits() {
13849
+ return { ...inner.traits, manualRedirects: true };
13850
+ },
13842
13851
  ...inner.websocket ? { websocket: inner.websocket.bind(inner) } : {},
13843
13852
  async fetch(request, owner = KERNEL) {
13844
13853
  const key = keyOf2(owner, request.method, request.url);
@@ -16380,6 +16389,7 @@ var Launcher = class {
16380
16389
  this.env = { ...networkEnv(hostname), SLICC_CDP_URL: this.cdp.url, ...options.env };
16381
16390
  this.ca = kernelCa(options.caStore ?? memoryCaStore());
16382
16391
  this.transport = replayingHops(options.transport ?? missingTransport());
16392
+ this.announcedTraits = JSON.stringify(this.transport.traits);
16383
16393
  this.uplink = options.uplink;
16384
16394
  this.routes = new Routes(options.uplink?.traits.ipv6 === true);
16385
16395
  if (options.uplink?.routes) this.routes.set(options.uplink.routes);
@@ -16451,6 +16461,19 @@ var Launcher = class {
16451
16461
  setRoutes(table) {
16452
16462
  this.routes.set(table);
16453
16463
  }
16464
+ traitsListeners = /* @__PURE__ */ new Set();
16465
+ announcedTraits = "";
16466
+ onTraits(listener) {
16467
+ this.traitsListeners.add(listener);
16468
+ return () => this.traitsListeners.delete(listener);
16469
+ }
16470
+ updateTransportTraits() {
16471
+ const now = JSON.stringify(this.transport.traits);
16472
+ if (now === this.announcedTraits) return false;
16473
+ this.announcedTraits = now;
16474
+ for (const listener of [...this.traitsListeners]) listener();
16475
+ return true;
16476
+ }
16454
16477
  commands(scope = "") {
16455
16478
  let found = this.catalogs.get(scope);
16456
16479
  if (!found) {
@@ -16974,6 +16997,7 @@ var Launcher = class {
16974
16997
  const cred = this.credOf(member.pid);
16975
16998
  if (!maySee(viewer, cred)) continue;
16976
16999
  const root = rootOf(member);
17000
+ const tag = this.tagOf(member.pid) ?? this.tagOf(root.pid);
16977
17001
  listed.push({
16978
17002
  pid: root.pid,
16979
17003
  tid: member.pid,
@@ -16988,7 +17012,8 @@ var Launcher = class {
16988
17012
  ...this.childrenOf(root.pid),
16989
17013
  umask: this.umaskOf(member.pid),
16990
17014
  cred,
16991
- ...this.signalMasksOf(member.pid)
17015
+ ...this.signalMasksOf(member.pid),
17016
+ ...tag !== void 0 && maySee(viewer, cred) ? { tag } : {}
16992
17017
  });
16993
17018
  }
16994
17019
  return listed;
@@ -17871,6 +17896,9 @@ function diagnosing(transport, check = diagnose) {
17871
17896
  if (!open) return transport;
17872
17897
  return {
17873
17898
  ...transport,
17899
+ get traits() {
17900
+ return transport.traits;
17901
+ },
17874
17902
  websocket: async (request) => {
17875
17903
  try {
17876
17904
  return await open(request);
@@ -18348,6 +18376,7 @@ var Channel = class {
18348
18376
  greeted = Promise.withResolvers();
18349
18377
  ended = Promise.withResolvers();
18350
18378
  remote;
18379
+ traitsListeners = /* @__PURE__ */ new Set();
18351
18380
  failure;
18352
18381
  pending = /* @__PURE__ */ new Map();
18353
18382
  watching = /* @__PURE__ */ new Map();
@@ -18395,6 +18424,11 @@ var Channel = class {
18395
18424
  return this.request(call).done;
18396
18425
  }
18397
18426
  receive(data) {
18427
+ if (data.traits && data.id === void 0) {
18428
+ if (this.remote) this.remote.traits = data.traits;
18429
+ for (const listener of [...this.traitsListeners]) listener(data.traits);
18430
+ return;
18431
+ }
18398
18432
  if (data.cdpOpen && data.port) {
18399
18433
  this.openCdp(data);
18400
18434
  return;
@@ -18675,6 +18709,10 @@ async function attachKernel(port, options = {}) {
18675
18709
  loopbackFetch: (input, options2) => loopbackFetch((o) => dialOn(channel, o), input, options2),
18676
18710
  fs: fsOn(channel),
18677
18711
  serveCdp: (hook, options2 = {}) => serveCdpOn(channel, hook, options2),
18712
+ onTraits(listener) {
18713
+ channel.traitsListeners.add(listener);
18714
+ return () => channel.traitsListeners.delete(listener);
18715
+ },
18678
18716
  async close(o = {}) {
18679
18717
  if (channel.failure) return;
18680
18718
  await channel.call({ op: "detach", ...o.kill ? { kill: true } : {} }).catch(() => void 0);
@@ -18860,6 +18898,7 @@ async function createNodeKernel(options = {}) {
18860
18898
  umount: (target) => guard2(async () => launcher.umount(target)),
18861
18899
  mounts: async () => launcher.mounts.list(),
18862
18900
  setRoutes: (routes) => guard2(async () => launcher.setRoutes(routes)),
18901
+ updateTransportTraits: () => guard2(async () => launcher.updateTransportTraits()),
18863
18902
  users: {
18864
18903
  mode: launcher.usersMode,
18865
18904
  add: (user) => guard2(() => launcher.users.add(user)),