log-llm-config-staging 1.3.71 → 1.3.72

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.
Files changed (2) hide show
  1. package/dist/tofu.js +24 -13
  2. package/package.json +1 -1
package/dist/tofu.js CHANGED
@@ -2,37 +2,48 @@
2
2
  * Tofu shim — centralises all imports from optimus-tofu-staging.
3
3
  *
4
4
  * Reads ~/opt-ai-sec/management/optimus_dev.env at startup:
5
- * - environment=development loads local dist (file-relative path)
6
- * - anything else loads the published npm package
5
+ * - No file / unreadable staging (ignores OPTIMUS_ENVIRONMENT).
6
+ * - File present environment= line in file, then OPTIMUS_ENVIRONMENT, then staging.
7
+ * - environment=development + local dist present → loads sibling optimus-tofu dist
8
+ * - staging / production / npx installs → published optimus-tofu-staging npm package
7
9
  *
8
10
  * All other source files import from this module, never directly from
9
11
  * "optimus-tofu-staging", so the conditional lives in exactly one place.
10
12
  */
11
- import { readFileSync } from "fs";
13
+ import { existsSync, readFileSync } from "fs";
12
14
  import { homedir } from "os";
13
15
  import path from "path";
14
16
  import { fileURLToPath } from "url";
17
+ function managementEnvPath() {
18
+ const home = homedir();
19
+ if (!home)
20
+ return null;
21
+ return path.join(home, "opt-ai-sec", "management", "optimus_dev.env");
22
+ }
15
23
  function readEnvironment() {
16
- const fromEnv = process.env.OPTIMUS_ENVIRONMENT?.trim().toLowerCase();
17
- if (fromEnv)
18
- return fromEnv;
24
+ const envPath = managementEnvPath();
25
+ if (!envPath) {
26
+ return "staging";
27
+ }
19
28
  try {
20
- const content = readFileSync(path.join(homedir(), "opt-ai-sec", "management", "optimus_dev.env"), "utf8");
29
+ const content = readFileSync(envPath, "utf8");
21
30
  const match = content.match(/^(?:environment|ENVIRONMENT|OPTIMUS_ENVIRONMENT)\s*=\s*(.+)/m);
22
31
  if (match)
23
32
  return match[1].trim().toLowerCase();
24
33
  }
25
34
  catch {
26
- // file missing or unreadable default to production
35
+ // No management file: this staging package defaults to staging (promotion rewrites to production).
36
+ return "staging";
27
37
  }
28
- return "production";
38
+ const fromEnv = process.env.OPTIMUS_ENVIRONMENT?.trim().toLowerCase();
39
+ if (fromEnv)
40
+ return fromEnv;
41
+ return "staging";
29
42
  }
30
43
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
31
- const isDevelopment = readEnvironment() === "development";
32
- // In development: resolve local optimus-tofu dist relative to this file.
33
- // dist/tofu.js → ../.. → npx_packages/staging/ → optimus-tofu/dist/index.js
34
44
  const localTofuPath = path.join(__dirname, "../../optimus-tofu/dist/index.js");
35
- const tofu = (isDevelopment
45
+ const useLocalTofu = readEnvironment() === "development" && existsSync(localTofuPath);
46
+ const tofu = (useLocalTofu
36
47
  ? await import(localTofuPath)
37
48
  : await import("optimus-tofu-staging"));
38
49
  export const { loadEndpointBase, buildStartupEndpointUrl, createSignature, persistAuthKey, readStoredAuthKey, ensureAuthentication, getEndpointSource, canonicalizePayload, getAuthKeyPath, } = tofu;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "log-llm-config-staging",
3
- "version": "1.3.71",
3
+ "version": "1.3.72",
4
4
  "description": "CLI helpers for logging hardware UUIDs and posting startup payloads to Optimus Security.",
5
5
  "type": "module",
6
6
  "bin": {