@ai-ecoverse/slicc-kernel 1.111.0 → 1.113.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.
@@ -993,6 +993,8 @@ var S_ISGID2 = 1024;
993
993
  var READ_ATTEMPTS = 3;
994
994
  var MAX_LINKS2 = 40;
995
995
  var CHECK_MS = 1e3;
996
+ var ABSENT_MS = 2;
997
+ var ABSENT_NAMES = 4096;
996
998
  var FILE_HANDLES = 4096;
997
999
  var STALE = /* @__PURE__ */ new Set(["NotFoundError", "TypeMismatchError"]);
998
1000
  var EXECUTABLE = /\/node_modules\/(?:@[^/]+\/)?[^/]+\/bin\//;
@@ -1127,6 +1129,8 @@ var OpfsFs = class {
1127
1129
  meta;
1128
1130
  dirs = new PathMap();
1129
1131
  files = new PathMap();
1132
+ absent = new PathMap();
1133
+ changes = 0;
1130
1134
  snapshots = /* @__PURE__ */ new WeakMap();
1131
1135
  found = /* @__PURE__ */ new WeakMap();
1132
1136
  checked = /* @__PURE__ */ new WeakMap();
@@ -1365,8 +1369,14 @@ var OpfsFs = class {
1365
1369
  return true;
1366
1370
  }
1367
1371
  forget(path) {
1372
+ this.changes++;
1368
1373
  this.dirs.deleteTree(path);
1369
1374
  this.files.deleteTree(path);
1375
+ this.absent.deleteTree(path);
1376
+ }
1377
+ missed(path) {
1378
+ if (this.absent.size >= ABSENT_NAMES) this.absent.clear();
1379
+ this.absent.set(path, performance.now());
1370
1380
  }
1371
1381
  remember(path, handle, looked = false) {
1372
1382
  if (handle.kind !== "file") return handle;
@@ -1416,8 +1426,15 @@ var OpfsFs = class {
1416
1426
  this.snapshots.delete(cached);
1417
1427
  }
1418
1428
  }
1429
+ const kept = this.dirs.get(path);
1430
+ if (kept && await this.current(path, kept)) return kept;
1431
+ const gone = this.absent.get(path);
1432
+ if (gone !== void 0 && performance.now() - gone < ABSENT_MS) {
1433
+ throw translate({ name: "NotFoundError" }, path);
1434
+ }
1435
+ const seen = this.changes;
1419
1436
  const [dir, name2] = await this.parent(path);
1420
- const known = this.dirs.has(path);
1437
+ const known = kept !== void 0;
1421
1438
  return this.inDir(dir, async (parent) => {
1422
1439
  const [first, second] = known ? ["directory", "file"] : ["file", "directory"];
1423
1440
  try {
@@ -1427,7 +1444,9 @@ var OpfsFs = class {
1427
1444
  }
1428
1445
  return this.remember(path, await this.child(parent, name2, second), true);
1429
1446
  }).catch((err) => {
1430
- throw translate(err, path);
1447
+ const error = translate(err, path);
1448
+ if (error.code === "ENOENT" && seen === this.changes) this.missed(path);
1449
+ throw error;
1431
1450
  });
1432
1451
  }
1433
1452
  real(path) {
@@ -1554,7 +1573,9 @@ var OpfsFs = class {
1554
1573
  }
1555
1574
  flushing = {};
1556
1575
  touch(now, ...dirs) {
1576
+ this.changes++;
1557
1577
  for (const dir of dirs) {
1578
+ this.absent.deleteTree(dir);
1558
1579
  this.dirTimes.set(dir, now);
1559
1580
  this.dirDirty.add(dir);
1560
1581
  }
@@ -6192,7 +6213,7 @@ function satisfies(version, range2) {
6192
6213
  }
6193
6214
 
6194
6215
  // src/version.ts
6195
- var KERNEL_VERSION = true ? "1.111.0" : "0.0.0-dev";
6216
+ var KERNEL_VERSION = true ? "1.113.0" : "0.0.0-dev";
6196
6217
  var OS_RELEASE = "6.0.0-slicc";
6197
6218
  function procVersion() {
6198
6219
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -14706,6 +14727,7 @@ var Resolver = class {
14706
14727
  own;
14707
14728
  cache = /* @__PURE__ */ new Map();
14708
14729
  pending = /* @__PURE__ */ new Map();
14730
+ hosts;
14709
14731
  constructor(options) {
14710
14732
  this.uplink = options.uplink;
14711
14733
  this.routes = options.routes;
@@ -14713,6 +14735,14 @@ var Resolver = class {
14713
14735
  this.timeoutMs = options.timeoutMs ?? RESOLVE_TIMEOUT_MS;
14714
14736
  this.log = options.log ?? ((message3) => console.warn(message3));
14715
14737
  this.own = ownNames(options.hostname ?? DEFAULT_HOSTNAME);
14738
+ this.hosts = options.hosts;
14739
+ }
14740
+ async fromFile(key, family) {
14741
+ const listed = (await this.hosts?.().catch(() => void 0))?.get(key);
14742
+ if (!listed) return void 0;
14743
+ const v4 = listed.filter((a) => ipv4Bytes(a) !== void 0);
14744
+ const v6 = listed.filter((a) => ipv4Bytes(a) === void 0);
14745
+ return family === 4 ? v4 : family === 6 ? v6 : [...v4, ...v6];
14716
14746
  }
14717
14747
  async resolve(name2, family, blocking) {
14718
14748
  const key = name2.toLowerCase().replace(/\.$/, "");
@@ -14721,6 +14751,8 @@ var Resolver = class {
14721
14751
  const v4 = family !== 6 && local ? [local] : [];
14722
14752
  return family === 4 ? v4 : [...v4, key];
14723
14753
  }
14754
+ const listed = this.hosts ? await this.fromFile(key, family) : void 0;
14755
+ if (listed?.length) return listed;
14724
14756
  if (local) {
14725
14757
  const six = loopbackName(key, this.own) ? ["::1"] : [];
14726
14758
  return family === 6 ? six : family === 4 ? [local] : [local, ...six];
@@ -19122,6 +19154,43 @@ var JobTable = class {
19122
19154
  }
19123
19155
  };
19124
19156
 
19157
+ // src/kernel/net/hosts-file.ts
19158
+ var HOSTS_PATH = "/etc/hosts";
19159
+ function parseHosts(text) {
19160
+ const table = /* @__PURE__ */ new Map();
19161
+ for (const raw of text.split("\n")) {
19162
+ const [address, ...names] = raw.replace(/#.*/, "").trim().split(/\s+/);
19163
+ if (!address || names.length === 0) continue;
19164
+ if (ipv4Bytes(address) === void 0 && ipv6Groups(address) === void 0) continue;
19165
+ for (const name2 of names) {
19166
+ const key = name2.toLowerCase().replace(/\.$/, "");
19167
+ const known = table.get(key) ?? [];
19168
+ if (!known.includes(address)) known.push(address);
19169
+ table.set(key, known);
19170
+ }
19171
+ }
19172
+ return table;
19173
+ }
19174
+ function hostsReader(fs, path = HOSTS_PATH) {
19175
+ let stamp = "";
19176
+ let table;
19177
+ return async () => {
19178
+ const st = await fs.stat(path).catch(() => void 0);
19179
+ if (!st?.isFile) {
19180
+ stamp = "";
19181
+ table = void 0;
19182
+ return void 0;
19183
+ }
19184
+ const now = `${st.ino}:${st.size}:${st.mtime.getTime()}`;
19185
+ if (now === stamp && table) return table;
19186
+ const text = await fs.readFile(path).catch(() => void 0);
19187
+ if (text === void 0) return void 0;
19188
+ stamp = now;
19189
+ table = parseHosts(text);
19190
+ return table;
19191
+ };
19192
+ }
19193
+
19125
19194
  // src/kernel/net/redirect-hops.ts
19126
19195
  var HELD_MS = 3e4;
19127
19196
  var HELD_MAX = 64;
@@ -22494,7 +22563,12 @@ var Launcher = class {
22494
22563
  this.uplink = options.uplink;
22495
22564
  this.routes = new Routes(options.uplink?.traits.ipv6 === true);
22496
22565
  if (options.uplink?.routes) this.routes.set(options.uplink.routes);
22497
- this.resolver = new Resolver({ uplink: options.uplink, routes: this.routes, hostname });
22566
+ this.resolver = new Resolver({
22567
+ uplink: options.uplink,
22568
+ routes: this.routes,
22569
+ hostname,
22570
+ hosts: hostsReader(this.base)
22571
+ });
22498
22572
  if (options.uplink) this.net.useUplink({ uplink: options.uplink, routes: this.routes });
22499
22573
  enableNetwork(this.net, {
22500
22574
  transport: this.transport,