xypriss 9.14.19 → 9.14.21

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/cjs/index.js CHANGED
@@ -4596,6 +4596,13 @@ class XessIpcClient {
4596
4596
  static probeSocketSync(socketPath) {
4597
4597
  if (!fs__namespace.existsSync(socketPath))
4598
4598
  return false;
4599
+ // Fast-path: When running under active libXESS supervisor, socket presence confirms shielding
4600
+ if (_isLibxessActive ||
4601
+ process.env?.LIBXESS_ACTIVE === "1" ||
4602
+ process.env?.XYPRISS_USER_TMP ||
4603
+ process.env?.XESS_TEMP_DIR) {
4604
+ return true;
4605
+ }
4599
4606
  const script = `
4600
4607
  const net = require("net");
4601
4608
  const sock = process.argv[1];
@@ -4604,21 +4611,16 @@ const client = net.createConnection(sock, () => {
4604
4611
  process.exit(0);
4605
4612
  });
4606
4613
  client.on("error", () => process.exit(1));
4607
- setTimeout(() => process.exit(1), 80);
4614
+ setTimeout(() => process.exit(1), 1000);
4608
4615
  `;
4609
4616
  try {
4610
4617
  node_child_process.execFileSync(process.execPath, ["-e", script, socketPath], {
4611
- timeout: 250,
4618
+ timeout: 1500,
4612
4619
  stdio: "ignore",
4613
4620
  });
4614
4621
  return true;
4615
4622
  }
4616
4623
  catch {
4617
- // Fichier socket abandonné sur disque sans superviseur actif : purge atomique
4618
- try {
4619
- fs__namespace.unlinkSync(socketPath);
4620
- }
4621
- catch { }
4622
4624
  return false;
4623
4625
  }
4624
4626
  }
@@ -4781,14 +4783,21 @@ setTimeout(() => process.exit(1), 80);
4781
4783
  const credential = sessionKey || authToken;
4782
4784
  const script = `
4783
4785
  const net = require("net");
4786
+ const fs = require("fs");
4784
4787
  const sock = process.argv[1];
4785
- const targetDir = process.argv[2] || "";
4786
- const action = process.argv[3];
4787
- const credential = process.argv[4] || "";
4788
+ let rawInput = "";
4789
+ try {
4790
+ rawInput = fs.readFileSync(0, "utf-8");
4791
+ } catch (e) {
4792
+ process.exit(1);
4793
+ }
4794
+ let payload;
4795
+ try {
4796
+ payload = JSON.parse(rawInput);
4797
+ } catch (e) {
4798
+ process.exit(1);
4799
+ }
4788
4800
  const client = net.createConnection(sock, () => {
4789
- const payload = action === "HANDSHAKE"
4790
- ? { action: "HANDSHAKE", projectDir: targetDir, token: credential }
4791
- : { action: action, projectDir: targetDir, sessionKey: credential };
4792
4801
  client.write(JSON.stringify(payload) + "\\n");
4793
4802
  });
4794
4803
  let data = "";
@@ -4806,13 +4815,18 @@ client.on("error", (err) => {
4806
4815
  });
4807
4816
  setTimeout(() => { process.exit(1); }, 3000);
4808
4817
  `;
4818
+ const inputPayload = JSON.stringify(action === "HANDSHAKE"
4819
+ ? { action: "HANDSHAKE", projectDir: targetDir, token: credential }
4820
+ : { action: action, projectDir: targetDir, sessionKey: credential });
4809
4821
  let lastErr;
4810
4822
  for (const sock of candidates) {
4811
4823
  try {
4812
- const output = node_child_process.execFileSync(process.execPath, ["-e", script, sock, targetDir, action, credential], {
4824
+ // Pass sensitive credentials exclusively via private stdin pipe, NEVER in process.argv
4825
+ const output = node_child_process.execFileSync(process.execPath, ["-e", script, sock], {
4826
+ input: inputPayload,
4813
4827
  encoding: "utf8",
4814
4828
  timeout: 3000,
4815
- stdio: ["ignore", "pipe", "pipe"],
4829
+ stdio: ["pipe", "pipe", "pipe"],
4816
4830
  });
4817
4831
  const parsed = JSON.parse(output.trim());
4818
4832
  if (parsed.action === "UNAUTHORIZED" || parsed.error) {
@@ -5158,7 +5172,7 @@ class SynapxClient {
5158
5172
  try {
5159
5173
  const child = node_child_process.spawn(binPath, ["daemon", process.cwd()], {
5160
5174
  detached: true,
5161
- stdio: "ignore",
5175
+ stdio: "inherit",
5162
5176
  env: {
5163
5177
  ...process.env,
5164
5178
  ...(sessionKey ? { XYPRISS_XESS_SESSION_KEY: sessionKey } : {}),
@@ -8840,46 +8854,64 @@ class XessShieldRequiredError extends Error {
8840
8854
  }
8841
8855
  }
8842
8856
 
8857
+ let cachedManifest = null;
8858
+ /**
8859
+ * Loads the authoritative plugins manifest provided by xfpm.
8860
+ */
8861
+ function getPluginsManifest() {
8862
+ if (cachedManifest)
8863
+ return cachedManifest;
8864
+ const manifestPath = process.env.XYPRISS_PLUGINS_MANIFEST ||
8865
+ (process.env.XYPRISS_PROJECT_ROOT
8866
+ ? path$1.join(process.env.XYPRISS_PROJECT_ROOT, "node_modules", ".xfpm", "plugins_manifest.json")
8867
+ : null);
8868
+ if (manifestPath && fs$1.existsSync(manifestPath)) {
8869
+ try {
8870
+ const raw = fs$1.readFileSync(manifestPath, "utf-8");
8871
+ cachedManifest = JSON.parse(raw);
8872
+ return cachedManifest;
8873
+ }
8874
+ catch {
8875
+ // ignore
8876
+ }
8877
+ }
8878
+ return null;
8879
+ }
8843
8880
  /**
8844
- * Checks if a directory is a "Real Project" root based on hierarchical criteria.
8845
- * Criteria:
8846
- * 1. (package.json + node_modules) -> Strong baseline
8847
- * 2. (package.json + src + tsconfig.json) -> High priority
8881
+ * Returns the primary project root determined by xfpm CLI.
8882
+ */
8883
+ function getPrimaryProjectRoot() {
8884
+ return process.env.XYPRISS_PROJECT_ROOT || process.cwd();
8885
+ }
8886
+ /**
8887
+ * Checks if a directory is a valid project root.
8848
8888
  */
8849
8889
  function isProjectRoot(dir) {
8850
- const pkgPath = path$1.join(dir, "package.json");
8851
- if (!fs$1.existsSync(pkgPath))
8890
+ if (!dir)
8852
8891
  return false;
8853
- // Strong Heuristics (Zero FS Read)
8854
- const hasNodeModules = fs$1.existsSync(path$1.join(dir, "node_modules"));
8855
- const hasTsConfig = fs$1.existsSync(path$1.join(dir, "tsconfig.json"));
8856
- const hasSrc = fs$1.existsSync(path$1.join(dir, "src"));
8857
- const hasXyConfig = fs$1.existsSync(path$1.join(dir, "xypriss.config.json")) ||
8858
- fs$1.existsSync(path$1.join(dir, "xypriss.config.jsonc"));
8859
- if (hasNodeModules || hasXyConfig || (hasSrc && hasTsConfig))
8860
- return true;
8861
- // Package Metadata Heuristic: A 'Real' package root is a unit that
8862
- // has an identity (name + version). This correctly identifies
8863
- // installed plugins even if they've been flattened or lack source configs.
8864
8892
  try {
8865
- const pkgStr = fs$1.readFileSync(pkgPath, "utf-8");
8866
- // Fast pre-check before parsing JSON
8867
- if (pkgStr.includes('"name"') && pkgStr.includes('"version"')) {
8868
- const pkg = JSON.parse(pkgStr);
8869
- if (pkg.name && pkg.version)
8870
- return true;
8893
+ const resolved = path$1.resolve(dir);
8894
+ const primaryRoot = process.env.XYPRISS_PROJECT_ROOT;
8895
+ if (primaryRoot && resolved === path$1.resolve(primaryRoot)) {
8896
+ return true;
8897
+ }
8898
+ const manifest = getPluginsManifest();
8899
+ if (manifest?.roots && manifest.roots[resolved]) {
8900
+ return true;
8871
8901
  }
8902
+ const pkgPath = path$1.join(resolved, "package.json");
8903
+ return fs$1.existsSync(pkgPath);
8872
8904
  }
8873
8905
  catch {
8874
- // Any error in reading/parsing means it's not a valid project root
8906
+ return false;
8875
8907
  }
8876
- return false;
8877
8908
  }
8878
8909
  /**
8879
- * Identifies the project root for a given caller path by traversing up the filesystem.
8910
+ * Identifies the project or plugin root for a given caller path using xfpm metadata.
8880
8911
  */
8881
8912
  function identifyProjectRoot(filePath) {
8882
- // Ensure the path is absolute and exists before traversing
8913
+ if (!filePath)
8914
+ return undefined;
8883
8915
  if (!path$1.isAbsolute(filePath)) {
8884
8916
  try {
8885
8917
  filePath = path$1.resolve(filePath);
@@ -8888,15 +8920,35 @@ function identifyProjectRoot(filePath) {
8888
8920
  return undefined;
8889
8921
  }
8890
8922
  }
8891
- if (!fs$1.existsSync(filePath))
8892
- return undefined;
8893
- let current = path$1.dirname(filePath);
8894
- const systemRootDir = path$1.parse(current).root;
8895
- while (current !== systemRootDir) {
8896
- if (isProjectRoot(current)) {
8897
- return current;
8923
+ const normalized = filePath.replace(/\\/g, "/");
8924
+ const primaryRoot = (process.env.XYPRISS_PROJECT_ROOT || process.cwd()).replace(/\\/g, "/");
8925
+ // 1. Direct O(1) match against verified plugins registered by xfpm
8926
+ const manifest = getPluginsManifest();
8927
+ if (manifest?.roots) {
8928
+ for (const [pluginRoot, _pluginName] of Object.entries(manifest.roots)) {
8929
+ const normPluginRoot = pluginRoot.replace(/\\/g, "/");
8930
+ if (normalized === normPluginRoot || normalized.startsWith(normPluginRoot + "/")) {
8931
+ return pluginRoot;
8932
+ }
8933
+ }
8934
+ }
8935
+ // 2. Direct match against primary project root
8936
+ if (normalized === primaryRoot || normalized.startsWith(primaryRoot + "/")) {
8937
+ // If inside node_modules, it is an undeclared/untrusted dependency, NOT the application root!
8938
+ if (normalized.includes("/node_modules/")) {
8939
+ return undefined;
8940
+ }
8941
+ return primaryRoot;
8942
+ }
8943
+ // 3. Monorepo development mods (/mods/<name>/) fallback
8944
+ const modsIdx = normalized.lastIndexOf("/mods/");
8945
+ if (modsIdx !== -1) {
8946
+ const afterMods = normalized.substring(modsIdx + 6);
8947
+ const nextSlash = afterMods.indexOf("/");
8948
+ const modName = nextSlash === -1 ? afterMods : afterMods.substring(0, nextSlash);
8949
+ if (modName) {
8950
+ return normalized.substring(0, modsIdx + 6 + modName.length);
8898
8951
  }
8899
- current = path$1.dirname(current);
8900
8952
  }
8901
8953
  return undefined;
8902
8954
  }
@@ -8906,30 +8958,25 @@ function identifyProjectRoot(filePath) {
8906
8958
  function getCallerProjectRoot() {
8907
8959
  const stack = new Error().stack;
8908
8960
  if (!stack)
8909
- return undefined;
8961
+ return getPrimaryProjectRoot();
8910
8962
  const lines = stack.split("\n");
8911
8963
  let callerFilePath = "";
8912
- // Line 0 is 'Error', Line 1 is the call to getCallerProjectRoot itself
8964
+ // Line 0 is 'Error', Line 1 is getCallerProjectRoot itself
8913
8965
  for (let i = 2; i < lines.length; i++) {
8914
8966
  const line = lines[i];
8915
- if (!line || line.includes(" (node:") || line.includes(" (native"))
8967
+ if (!line || line.includes(" (node:") || line.includes(" (bun:") || line.includes(" (native"))
8916
8968
  continue;
8917
- // Robust matching for file paths (handles both absolute and relative,
8918
- // but filters out non-file frames like '(native)' or 'replace (unknown)')
8919
8969
  const match = line.match(/\((.*\.([jt]s|[cm]js)):\d+:\d+\)$/) ||
8920
8970
  line.match(/at (.*\.([jt]s|[cm]js)):\d+:\d+$/);
8921
8971
  if (!match)
8922
8972
  continue;
8923
8973
  const filePath = match[1];
8924
- if (!filePath || filePath === "native" || filePath === "node:fs")
8974
+ if (!filePath || filePath === "native" || filePath === "node:fs" || filePath === "fs")
8925
8975
  continue;
8926
- // SKIP only purely internal engine files to find the real project caller.
8927
- // Even internal mods (/mods/) should be considered callers if they have their own root,
8928
- // so we don't skip them during stack analysis, but we still trust them for security.
8976
+ // Skip internal engine files to locate the user/plugin caller
8929
8977
  if (isEngineCorePath(filePath)) {
8930
8978
  continue;
8931
8979
  }
8932
- // Skip specifically the property getters if they appear differently
8933
8980
  if (line.includes("at get [") ||
8934
8981
  line.includes("at getStrict (") ||
8935
8982
  line.includes("PluginAPI.") ||
@@ -8939,7 +8986,7 @@ function getCallerProjectRoot() {
8939
8986
  break;
8940
8987
  }
8941
8988
  if (!callerFilePath)
8942
- return undefined;
8989
+ return getPrimaryProjectRoot();
8943
8990
  const root = identifyProjectRoot(callerFilePath);
8944
8991
  return root;
8945
8992
  }
@@ -9864,7 +9911,7 @@ class EnvApi {
9864
9911
  Object.defineProperty(process, "env", {
9865
9912
  value: envShield,
9866
9913
  writable: false,
9867
- configurable: true,
9914
+ configurable: false,
9868
9915
  enumerable: true,
9869
9916
  });
9870
9917
  }
@@ -18272,6 +18319,9 @@ class XyPrisRequestApp {
18272
18319
  if (prop in target || prop === "constructor") {
18273
18320
  return Reflect.get(target, prop, receiver);
18274
18321
  }
18322
+ if (prop === "xems") {
18323
+ return this.appInstance?.xems || this.appInstance?._xems;
18324
+ }
18275
18325
  // Otherwise, proxy to appInstance
18276
18326
  if (this.appInstance && prop in this.appInstance) {
18277
18327
  const value = this.appInstance[prop];
@@ -26865,8 +26915,9 @@ class XStatic {
26865
26915
  const cleanRelative = relativePath.startsWith("/")
26866
26916
  ? relativePath.substring(1)
26867
26917
  : relativePath;
26868
- const fileName = cleanRelative.split("/").pop() || "";
26869
26918
  // 2. Dotfile & Restricted File Protection (Global Policy)
26919
+ // Check every segment of cleanRelative to prevent /.git/config traversal
26920
+ const segments = cleanRelative.split("/").filter(Boolean);
26870
26921
  const dotfileConfig = this.globalConfig.dotfiles || "deny";
26871
26922
  const dotfileMode = typeof dotfileConfig === "object"
26872
26923
  ? dotfileConfig.mode
@@ -26875,12 +26926,10 @@ class XStatic {
26875
26926
  ? dotfileConfig.custom || []
26876
26927
  : [];
26877
26928
  if (dotfileMode === "deny") {
26878
- const isRestricted = fileName.startsWith(".") ||
26879
- customRestricted.includes(fileName);
26880
- if (isRestricted) {
26881
- this.qLog.warn(
26882
- // "security",
26883
- `Blocked attempt to access restricted file: ${fileName}`);
26929
+ const hasDotfileSegment = segments.some((s) => s.startsWith("."));
26930
+ const hasCustomRestricted = segments.some((s) => customRestricted.includes(s));
26931
+ if (hasDotfileSegment || hasCustomRestricted) {
26932
+ this.qLog.warn(`Blocked attempt to access restricted file or directory in path: ${cleanRelative}`);
26884
26933
  res.status(403).end("Forbidden: Access Denied");
26885
26934
  return next();
26886
26935
  }
@@ -26894,15 +26943,20 @@ class XStatic {
26894
26943
  if (!options.allowOutsideRoot &&
26895
26944
  !options.unsafe &&
26896
26945
  projectRoot) {
26897
- if (!rootDir.startsWith(projectRoot)) {
26946
+ const relProject = this.sys.path.relative(projectRoot, rootDir);
26947
+ const isInsideProject = !relProject.startsWith("..") && !this.sys.path.isAbsolute(relProject);
26948
+ if (!isInsideProject && rootDir !== projectRoot) {
26898
26949
  this.qLog.warn(`Blocked attempt to serve directory outside project root: ${rootDir}`);
26899
26950
  res.status(403).end("Forbidden: Project Root Violation");
26900
26951
  return next();
26901
26952
  }
26902
26953
  }
26903
26954
  // Check 2: Is the requested file inside the target directory? (Directory Jail Protection)
26955
+ // Strict separator check prevents sibling directory traversal (e.g. /public_backup matching /public)
26904
26956
  if (!options.allowOutsideDir && !options.unsafe) {
26905
- if (!resolvedPath.startsWith(rootDir)) {
26957
+ const relTarget = this.sys.path.relative(rootDir, resolvedPath);
26958
+ const isInsideTarget = !relTarget.startsWith("..") && !this.sys.path.isAbsolute(relTarget);
26959
+ if (!isInsideTarget && resolvedPath !== rootDir) {
26906
26960
  this.qLog.warn(`Blocked attempt to access file outside static target directory: ${resolvedPath}`);
26907
26961
  res.status(403).end("Forbidden: Sandbox Violation");
26908
26962
  return next();
@@ -29685,11 +29739,19 @@ class XyprissApp {
29685
29739
  const self = this;
29686
29740
  return new Proxy(this, {
29687
29741
  set(target, prop, value) {
29742
+ if (prop === "xems" || prop === "_xems") {
29743
+ target[prop] = value;
29744
+ return true;
29745
+ }
29688
29746
  const errorMsg = `[XyPriss Security] Mutation Attempt Detected: Application instance is immutable after creation. Property '${String(prop)}' cannot be changed.`;
29689
29747
  self.logger.error("security", errorMsg);
29690
29748
  throw new Error(errorMsg);
29691
29749
  },
29692
29750
  defineProperty(target, prop, descriptor) {
29751
+ if (prop === "xems" || prop === "_xems") {
29752
+ Object.defineProperty(target, prop, descriptor);
29753
+ return true;
29754
+ }
29693
29755
  const errorMsg = `[XyPriss Security] Mutation Attempt Detected: Cannot define new property '${String(prop)}' on locked app instance.`;
29694
29756
  self.logger.error("security", errorMsg);
29695
29757
  throw new Error(errorMsg);
@@ -34088,6 +34150,7 @@ class PluginSecurity {
34088
34150
  ...allowedMiddlewareMethods,
34089
34151
  "logger",
34090
34152
  "configs",
34153
+ "xems",
34091
34154
  ];
34092
34155
  // Facade for the app instance to avoid Proxy invariants on non-configurable properties
34093
34156
  const appFacade = {};
@@ -34106,6 +34169,9 @@ class PluginSecurity {
34106
34169
  return undefined;
34107
34170
  }
34108
34171
  }
34172
+ if (prop === "xems") {
34173
+ return target.xems || target._xems;
34174
+ }
34109
34175
  const originalMethod = target[prop];
34110
34176
  if (typeof originalMethod === "function") {
34111
34177
  if (allowedRoutingMethods.includes(prop) || allowedMiddlewareMethods.includes(prop)) {
@@ -34173,7 +34239,26 @@ class PluginSecurity {
34173
34239
  return originalMethod.bind(target);
34174
34240
  }
34175
34241
  return originalMethod;
34176
- }
34242
+ },
34243
+ set: (value) => {
34244
+ const target = server.app;
34245
+ if (prop === "xems" && OFFICIAL_PLUGINS.includes(pluginName)) {
34246
+ try {
34247
+ target.xems = value;
34248
+ }
34249
+ catch { }
34250
+ try {
34251
+ target._xems = value;
34252
+ }
34253
+ catch { }
34254
+ }
34255
+ else {
34256
+ try {
34257
+ target[prop] = value;
34258
+ }
34259
+ catch { }
34260
+ }
34261
+ },
34177
34262
  });
34178
34263
  }
34179
34264
  // Facade for the server instance
@@ -35402,7 +35487,13 @@ class XemsRunner {
35402
35487
  * otherwise returns this instance.
35403
35488
  */
35404
35489
  forApp(app) {
35405
- return app?.xems || this;
35490
+ if (!app)
35491
+ return this;
35492
+ const candidate = app.xems ||
35493
+ app._xems ||
35494
+ (app.appInstance && (app.appInstance.xems || app.appInstance._xems)) ||
35495
+ (app.server && (app.server.app?.xems || app.server.xems));
35496
+ return candidate || this;
35406
35497
  }
35407
35498
  /**
35408
35499
  * Forcefully stops the XEMS process and cleans up resources.
@@ -35518,12 +35609,15 @@ class XemsBuiltinPlugin {
35518
35609
  const app = server.app;
35519
35610
  const logger = app.logger;
35520
35611
  // 1. Configuration Extraction
35521
- // Cascade defaults from global configuration if child only specified partial options or none
35612
+ // Child server xems configuration takes absolute precedence over global defaults
35522
35613
  const globalXems = ConfigurationManager.get("server")?.xems;
35523
- const localXems = app.configs?.server?.xems;
35614
+ const localXems = app.configs?.server?.xems ||
35615
+ app.configs?.xems ||
35616
+ server?.app?.configs?.server?.xems ||
35617
+ server?.app?.configs?.xems;
35524
35618
  let xemsOptions;
35525
35619
  if (localXems && globalXems && typeof globalXems === "object") {
35526
- // Intelligent cascade merge: child inherits parent defaults but can override selectively
35620
+ // Intelligent cascade merge: child inherits parent defaults, but child options strictly override
35527
35621
  xemsOptions = mergeWithDefaults(globalXems, localXems);
35528
35622
  }
35529
35623
  else if (localXems) {
@@ -35589,8 +35683,35 @@ class XemsBuiltinPlugin {
35589
35683
  cacheSize: rawResources?.cacheSize,
35590
35684
  });
35591
35685
  this.logger.debug("xems", `XemsRunner instances count: ${XemsRunner.runnersByPath?.size ?? 0} for path: ${pathStr}`);
35592
- // Attach the shared runner to the app
35593
- app.xems = this.runner;
35686
+ // Attach the runner to the app and underlying server instances
35687
+ try {
35688
+ app.xems = this.runner;
35689
+ }
35690
+ catch { }
35691
+ try {
35692
+ app._xems = this.runner;
35693
+ }
35694
+ catch { }
35695
+ if (server && server.app) {
35696
+ try {
35697
+ server.app.xems = this.runner;
35698
+ }
35699
+ catch { }
35700
+ try {
35701
+ server.app._xems = this.runner;
35702
+ }
35703
+ catch { }
35704
+ }
35705
+ if (app.server && app.server.app) {
35706
+ try {
35707
+ app.server.app.xems = this.runner;
35708
+ }
35709
+ catch { }
35710
+ try {
35711
+ app.server.app._xems = this.runner;
35712
+ }
35713
+ catch { }
35714
+ }
35594
35715
  if (rawPath) {
35595
35716
  try {
35596
35717
  this.runner.enablePersistence(rawPath, secret, {
@@ -35604,7 +35725,24 @@ class XemsBuiltinPlugin {
35604
35725
  }
35605
35726
  else {
35606
35727
  // Expose fallback runner on app
35607
- app.xems = this.runner;
35728
+ try {
35729
+ app.xems = this.runner;
35730
+ }
35731
+ catch { }
35732
+ try {
35733
+ app._xems = this.runner;
35734
+ }
35735
+ catch { }
35736
+ if (server && server.app) {
35737
+ try {
35738
+ server.app.xems = this.runner;
35739
+ }
35740
+ catch { }
35741
+ try {
35742
+ server.app._xems = this.runner;
35743
+ }
35744
+ catch { }
35745
+ }
35608
35746
  if (!isAuxiliary && xemsOptions.enable !== false) {
35609
35747
  logger.warn("plugins", "XEMS requested but mandatory 'path' or 32-byte 'secret' is missing. Please provide both.");
35610
35748
  }
@@ -37338,8 +37476,15 @@ class MultiServerManager {
37338
37476
  }
37339
37477
  // Cascade server options (specifically server.xems, cookieOptions, secret, etc.)
37340
37478
  const baseServer = this.baseConfig?.server || {};
37341
- const childServer = config.server || {};
37479
+ const childServer = { ...(config.server || {}) };
37480
+ const childXems = childServer.xems || config.xems;
37481
+ if (childXems) {
37482
+ childServer.xems = childXems;
37483
+ }
37342
37484
  const mergedServer = mergeWithDefaults(baseServer, childServer);
37485
+ if (childXems) {
37486
+ mergedServer.xems = mergeWithDefaults(baseServer.xems || {}, childXems);
37487
+ }
37343
37488
  if (config.port)
37344
37489
  mergedServer.port = config.port;
37345
37490
  if (config.host)
@@ -38564,7 +38709,7 @@ class MultiServerApp {
38564
38709
  * ```
38565
38710
  *
38566
38711
  * @see {@link https://xypriss.nehonix.com/docs/getting-started} Getting Started Guide
38567
- * @see {@link https://xypriss.nehonix.com/docs/configuration} Configuration Reference
38712
+ * @see {@link https://xypriss.nehonix.com/docs/config/api} Configuration Reference
38568
38713
  */
38569
38714
  function createServer(options = {}) {
38570
38715
  // --- SECURITY: Internal Options Protection ---
@@ -38589,8 +38734,19 @@ function createServer(options = {}) {
38589
38734
  ConfigurationManager.update("multiServer", options.multiServer);
38590
38735
  }
38591
38736
  const servers = (xms || []).map((server) => {
38737
+ // Hoist top-level xems if child specified it directly on MultiServerConfig
38738
+ if (server.xems && !server.server?.xems) {
38739
+ server.server = server.server || {};
38740
+ server.server.xems = server.xems;
38741
+ }
38592
38742
  // Individual server options take precedence over global ones
38593
38743
  const merged = mergeWithDefaults(globalOptions, server);
38744
+ // Ensure child server xems explicitly overrides global server xems
38745
+ const explicitChildXems = server.server?.xems || server.xems;
38746
+ if (explicitChildXems) {
38747
+ merged.server = merged.server || {};
38748
+ merged.server.xems = mergeWithDefaults(globalOptions.server?.xems || {}, explicitChildXems);
38749
+ }
38594
38750
  // Ensure child server port & host override global server block
38595
38751
  if (server.port) {
38596
38752
  merged.server = merged.server || {};
@@ -38672,15 +38828,15 @@ class PluginAPI {
38672
38828
  if (!sys || !sys.__root__) {
38673
38829
  throw new Error("XyPriss Security Error: The provided system core instance is invalid or lacks an authorized project root association.");
38674
38830
  }
38675
- const manifestPath = sys.fs.join(sys.__root__, "package.json");
38676
- if (!sys.path.exists(manifestPath)) {
38831
+ const manifestPath = path.join(sys.__root__, "package.json");
38832
+ if (!fs.existsSync(manifestPath)) {
38677
38833
  throw new Error(`XyPriss I/O Error: Unable to access project manifest at "${manifestPath}". Verify that the file exists and is readable.`);
38678
38834
  }
38679
38835
  try {
38680
- return sys.fs.readJsonSync(manifestPath);
38836
+ return JSON.parse(fs.readFileSync(manifestPath, "utf-8"));
38681
38837
  }
38682
38838
  catch (err) {
38683
- throw new Error(`XyPriss I/O Error: Unable to access project manifest at "${manifestPath}". Verify that the file exists and is readable.`);
38839
+ throw new Error(`XyPriss JSON Error: Failed to parse project manifest at "${manifestPath}": ${err.message}`);
38684
38840
  }
38685
38841
  }
38686
38842
  /**