kritya 0.8.42-beta → 0.8.43-beta

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.
@@ -3,9 +3,29 @@ import fs from "node:fs";
3
3
  import { createRequire } from "node:module";
4
4
  import os from "node:os";
5
5
  import path from "node:path";
6
+ import { CONFIG_DIR, loadDotEnv } from "../config/config.js";
6
7
  import { classifyDanger } from "../permissions/danger.js";
7
8
  let cachedTool;
8
9
  let cachedMxcExec;
10
+ let dotEnvLoaded = false;
11
+ /**
12
+ * Load `~/.kritya/.env` before the backend is resolved, once per process.
13
+ *
14
+ * `locateMxcExecutable` reads `KRITYA_MXC_EXEC` and `MXC_BIN_DIR` from the
15
+ * environment, but the sandbox module is callable from frontends that never
16
+ * load the global `.env` themselves (the tool executor reaches
17
+ * `sandboxAvailable()` directly). Without this, a user who configured the MXC
18
+ * path in `.env` would have it honoured only when some *other* entry point
19
+ * happened to load the file first — and because `sandboxTool()` memoizes its
20
+ * answer, a miss could not self-correct later in the session. Loading here
21
+ * makes discovery independent of who calls it first.
22
+ */
23
+ function loadSandboxEnv() {
24
+ if (dotEnvLoaded)
25
+ return;
26
+ dotEnvLoaded = true;
27
+ loadDotEnv([path.join(CONFIG_DIR, ".env")]);
28
+ }
9
29
  function commandExists(bin) {
10
30
  const finder = os.platform() === "win32" ? "where" : "which";
11
31
  try {
@@ -73,11 +93,13 @@ function mxcExecutable() {
73
93
  export function resetSandboxToolCache() {
74
94
  cachedTool = undefined;
75
95
  cachedMxcExec = undefined;
96
+ dotEnvLoaded = false;
76
97
  }
77
98
  /** Which sandbox backend (if any) is usable on this platform, cached after the first check. */
78
99
  function sandboxTool() {
79
100
  if (cachedTool !== undefined)
80
101
  return cachedTool;
102
+ loadSandboxEnv();
81
103
  const platform = os.platform();
82
104
  if (platform === "linux") {
83
105
  cachedTool = commandExists("bwrap") ? "bwrap" : null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kritya",
3
- "version": "0.8.42-beta",
3
+ "version": "0.8.43-beta",
4
4
  "description": "Kritya — Superintelligence at your command line",
5
5
  "type": "module",
6
6
  "publishConfig": {