optimus-tool-call-staging 0.2.10 → 0.2.12
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/lib/tofu.d.ts
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
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
|
-
* -
|
|
6
|
-
* -
|
|
5
|
+
* - No file / unreadable → staging (ignores OPTIMUS_ENVIRONMENT).
|
|
6
|
+
* - File present → environment= line in file, then OPTIMUS_ENVIRONMENT, then staging.
|
|
7
|
+
* - environment=development → loads local dist (file-relative path)
|
|
8
|
+
* - anything else → loads the published 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.
|
package/dist/lib/tofu.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tofu.d.ts","sourceRoot":"","sources":["../../src/lib/tofu.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tofu.d.ts","sourceRoot":"","sources":["../../src/lib/tofu.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,KAAK,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAiCvD,eAAO,MACL,gBAAgB,qCAChB,uBAAuB,4CACvB,eAAe,oCACf,cAAc,mCACd,iBAAiB,sCACjB,oBAAoB,yCACpB,iBAAiB,sCACjB,mBAAmB,wCACnB,cAAc,iCACR,CAAC;AAET,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/lib/tofu.js
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
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
|
-
* -
|
|
6
|
-
* -
|
|
5
|
+
* - No file / unreadable → staging (ignores OPTIMUS_ENVIRONMENT).
|
|
6
|
+
* - File present → environment= line in file, then OPTIMUS_ENVIRONMENT, then staging.
|
|
7
|
+
* - environment=development → loads local dist (file-relative path)
|
|
8
|
+
* - anything else → loads the published 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.
|
|
@@ -13,19 +15,22 @@ import { homedir } from "os";
|
|
|
13
15
|
import path from "path";
|
|
14
16
|
import { fileURLToPath } from "url";
|
|
15
17
|
function readEnvironment() {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
return fromEnv;
|
|
18
|
+
const envPath = path.join(homedir(), "opt-ai-sec", "management", "optimus_dev.env");
|
|
19
|
+
let content;
|
|
19
20
|
try {
|
|
20
|
-
|
|
21
|
-
const match = content.match(/^(?:environment|ENVIRONMENT|OPTIMUS_ENVIRONMENT)\s*=\s*(.+)/m);
|
|
22
|
-
if (match)
|
|
23
|
-
return match[1].trim().toLowerCase();
|
|
21
|
+
content = readFileSync(envPath, "utf8");
|
|
24
22
|
}
|
|
25
23
|
catch {
|
|
26
|
-
// file
|
|
24
|
+
// No management file: this staging package defaults to staging (promotion rewrites to production).
|
|
25
|
+
return "staging";
|
|
27
26
|
}
|
|
28
|
-
|
|
27
|
+
const match = content.match(/^(?:environment|ENVIRONMENT|OPTIMUS_ENVIRONMENT)\s*=\s*(.+)/m);
|
|
28
|
+
if (match)
|
|
29
|
+
return match[1].trim().toLowerCase();
|
|
30
|
+
const fromEnv = process.env.OPTIMUS_ENVIRONMENT?.trim().toLowerCase();
|
|
31
|
+
if (fromEnv)
|
|
32
|
+
return fromEnv;
|
|
33
|
+
return "staging";
|
|
29
34
|
}
|
|
30
35
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
31
36
|
const isDevelopment = readEnvironment() === "development";
|
package/dist/lib/tofu.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tofu.js","sourceRoot":"","sources":["../../src/lib/tofu.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tofu.js","sourceRoot":"","sources":["../../src/lib/tofu.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAGpC,SAAS,eAAe;IACtB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,CAAC,CAAC;IACpF,IAAI,OAAe,CAAC;IACpB,IAAI,CAAC;QACH,OAAO,GAAG,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,mGAAmG;QACnG,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CACzB,8DAA8D,CAC/D,CAAC;IACF,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAChD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACtE,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IAC5B,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/D,MAAM,aAAa,GAAG,eAAe,EAAE,KAAK,aAAa,CAAC;AAE1D,yEAAyE;AACzE,mFAAmF;AACnF,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,qCAAqC,CAAC,CAAC;AAElF,MAAM,IAAI,GAAG,CACX,aAAa;IACX,CAAC,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC;IAC7B,CAAC,CAAC,MAAM,MAAM,CAAC,sBAAsB,CAAC,CACrB,CAAC;AAEtB,MAAM,CAAC,MAAM,EACX,gBAAgB,EAChB,uBAAuB,EACvB,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,GACf,GAAG,IAAI,CAAC"}
|
|
@@ -3,12 +3,18 @@ import assert from "node:assert";
|
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
// Resolve workspace optimus-tofu — lib re-export may load npm when management env ≠ development.
|
|
7
|
+
import { loadEndpointBase } from "../../../optimus-tofu/dist/endpoint-config.js";
|
|
8
|
+
test("loadEndpointBase - uses default when no env and no management file", () => {
|
|
8
9
|
const root = fs.mkdtempSync(path.join(os.tmpdir(), "optimus-tool-call-default-"));
|
|
9
|
-
const
|
|
10
|
+
const fakeHome = fs.mkdtempSync(path.join(os.tmpdir(), "optimus-tool-call-home-empty-"));
|
|
11
|
+
const base = loadEndpointBase({
|
|
12
|
+
cwd: root,
|
|
13
|
+
env: { HOME: fakeHome },
|
|
14
|
+
});
|
|
10
15
|
assert.strictEqual(base, "https://demo.optimuslabs.io/");
|
|
11
16
|
fs.rmSync(root, { recursive: true, force: true });
|
|
17
|
+
fs.rmSync(fakeHome, { recursive: true, force: true });
|
|
12
18
|
});
|
|
13
19
|
test("loadEndpointBase - OPTIMUS_ENDPOINT env overrides file/default", () => {
|
|
14
20
|
const root = fs.mkdtempSync(path.join(os.tmpdir(), "optimus-tool-call-endpoint-env-"));
|
|
@@ -31,13 +37,21 @@ test("loadEndpointBase - OPTIMUS_API_URL env takes precedence", () => {
|
|
|
31
37
|
assert.strictEqual(base, "http://localhost:8080/");
|
|
32
38
|
fs.rmSync(root, { recursive: true, force: true });
|
|
33
39
|
});
|
|
34
|
-
test("loadEndpointBase - reads OPTIMUS_ENDPOINT from optimus_dev.env
|
|
40
|
+
test("loadEndpointBase - reads OPTIMUS_ENDPOINT from management optimus_dev.env (not cwd)", () => {
|
|
35
41
|
const root = fs.mkdtempSync(path.join(os.tmpdir(), "optimus-tool-call-env-file-"));
|
|
42
|
+
const fakeHome = fs.mkdtempSync(path.join(os.tmpdir(), "optimus-tool-call-home-"));
|
|
43
|
+
const mgmt = path.join(fakeHome, "opt-ai-sec", "management");
|
|
44
|
+
fs.mkdirSync(mgmt, { recursive: true });
|
|
45
|
+
fs.writeFileSync(path.join(mgmt, "optimus_dev.env"), "OPTIMUS_ENDPOINT=https://demo.optimuslabs.io\n");
|
|
36
46
|
const nested = path.join(root, "a", "b", "c");
|
|
37
47
|
fs.mkdirSync(nested, { recursive: true });
|
|
38
|
-
fs.writeFileSync(path.join(root, "optimus_dev.env"), "OPTIMUS_ENDPOINT=https://
|
|
39
|
-
const base = loadEndpointBase({
|
|
48
|
+
fs.writeFileSync(path.join(root, "optimus_dev.env"), "OPTIMUS_ENDPOINT=https://wrong-from-cwd.example/\n");
|
|
49
|
+
const base = loadEndpointBase({
|
|
50
|
+
cwd: nested,
|
|
51
|
+
env: { HOME: fakeHome },
|
|
52
|
+
});
|
|
40
53
|
assert.strictEqual(base, "https://demo.optimuslabs.io/");
|
|
41
54
|
fs.rmSync(root, { recursive: true, force: true });
|
|
55
|
+
fs.rmSync(fakeHome, { recursive: true, force: true });
|
|
42
56
|
});
|
|
43
57
|
//# sourceMappingURL=endpoint-config.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-config.test.js","sourceRoot":"","sources":["../../src/test/endpoint-config.test.ts"],"names":[],"mappings":"AAA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@@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "optimus-tool-call-staging",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"description": "Agentic audit sensor — streams raw tool call metadata; the Optimus backend classifies on ingest",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "rm -rf dist && tsc && node ../../scripts/ensure-bin-executable.mjs",
|
|
13
13
|
"dev": "tsx src/index.ts",
|
|
14
|
+
"pretest": "npm run build --prefix ../optimus-tofu && npm run build",
|
|
14
15
|
"test": "node --test dist/test/*.test.js",
|
|
15
16
|
"prepare": "npm run build"
|
|
16
17
|
},
|
|
@@ -45,6 +46,6 @@
|
|
|
45
46
|
"typescript": "^5.0.0"
|
|
46
47
|
},
|
|
47
48
|
"dependencies": {
|
|
48
|
-
"optimus-tofu-staging": "
|
|
49
|
+
"optimus-tofu-staging": "^0.1.14"
|
|
49
50
|
}
|
|
50
51
|
}
|