kritya 0.8.41-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.
@@ -2,7 +2,7 @@ import fs from "node:fs";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
4
  import { createRequire } from "node:module";
5
- import { BUILTIN_PROVIDERS, CONFIG_DIR, CONFIG_FILE, legacyGlobalModel, loadConfig, privacyModeFor, resolveProvider, } from "../config/config.js";
5
+ import { BUILTIN_PROVIDERS, CONFIG_DIR, CONFIG_FILE, legacyGlobalModel, loadConfig, loadDotEnv, privacyModeFor, resolveProvider, } from "../config/config.js";
6
6
  import { DEFAULT_MODEL, contextWindowFor } from "../config/models.js";
7
7
  import { retentionDaysFor } from "../config/retention.js";
8
8
  import { assertJsonWithinLimits } from "../config/jsonSafety.js";
@@ -368,6 +368,13 @@ export async function runDoctorCli(argv, options = {}) {
368
368
  const offline = argv.includes("--offline");
369
369
  const dirArg = argv.find((a) => !a.startsWith("-"));
370
370
  const workspace = path.resolve(options.workspace ?? dirArg ?? ".");
371
+ // The user's own global .env is unconditionally trusted and is where the
372
+ // interactive and headless paths both pick up provider keys (see
373
+ // `runInteractive` in index.tsx and `runHeadless` in headless.ts). Without
374
+ // loading it here the provider check below sees only the ambient
375
+ // environment, so a key that lives solely in ~/.kritya/.env is reported as
376
+ // missing — a false "no API key" that also flips the exit code to 1.
377
+ loadDotEnv([path.join(CONFIG_DIR, ".env")]);
371
378
  const sections = await collectDiagnostics({ ...options, workspace, offline });
372
379
  const report = summarize(sections, workspace);
373
380
  if (json) {
@@ -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.41-beta",
3
+ "version": "0.8.43-beta",
4
4
  "description": "Kritya — Superintelligence at your command line",
5
5
  "type": "module",
6
6
  "publishConfig": {