@optimuslabs/runtime-staging 0.3.3 → 0.3.5
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/index.js +1 -44
- package/dist/index.js.map +1 -1
- package/dist/lib/login.d.ts +15 -0
- package/dist/lib/login.d.ts.map +1 -0
- package/dist/lib/login.js +109 -0
- package/dist/lib/login.js.map +1 -0
- package/dist/lib/pending-events.d.ts +9 -4
- package/dist/lib/pending-events.d.ts.map +1 -1
- package/dist/lib/pending-events.js +75 -8
- package/dist/lib/pending-events.js.map +1 -1
- package/dist/lib/prompt-collection-policy.d.ts +5 -0
- package/dist/lib/prompt-collection-policy.d.ts.map +1 -0
- package/dist/lib/prompt-collection-policy.js +58 -0
- package/dist/lib/prompt-collection-policy.js.map +1 -0
- package/dist/lib/startup-sync.d.ts.map +1 -1
- package/dist/lib/startup-sync.js +2 -0
- package/dist/lib/startup-sync.js.map +1 -1
- package/dist/lib/telemetry/build-event.d.ts.map +1 -1
- package/dist/lib/telemetry/build-event.js +18 -6
- package/dist/lib/telemetry/build-event.js.map +1 -1
- package/dist/lib/telemetry/canonical.d.ts +1 -1
- package/dist/lib/telemetry/canonical.d.ts.map +1 -1
- package/dist/lib/telemetry/canonical.js +27 -15
- package/dist/lib/telemetry/canonical.js.map +1 -1
- package/dist/lib/telemetry/prompt-privacy.d.ts +5 -0
- package/dist/lib/telemetry/prompt-privacy.d.ts.map +1 -0
- package/dist/lib/telemetry/prompt-privacy.js +37 -0
- package/dist/lib/telemetry/prompt-privacy.js.map +1 -0
- package/dist/lib/telemetry/types.d.ts +1 -0
- package/dist/lib/telemetry/types.d.ts.map +1 -1
- package/dist/lib/tofu.js +3 -3
- package/dist/lib/tofu.js.map +1 -1
- package/dist/lib/transcript.d.ts +2 -0
- package/dist/lib/transcript.d.ts.map +1 -0
- package/dist/lib/transcript.js +70 -0
- package/dist/lib/transcript.js.map +1 -0
- package/dist/test/canonical.test.js +23 -0
- package/dist/test/canonical.test.js.map +1 -1
- package/dist/test/endpoint-config.test.js +1 -1
- package/dist/test/endpoint-config.test.js.map +1 -1
- package/dist/test/login.test.d.ts +2 -0
- package/dist/test/login.test.d.ts.map +1 -0
- package/dist/test/login.test.js +60 -0
- package/dist/test/login.test.js.map +1 -0
- package/dist/test/pending-events.test.js +34 -1
- package/dist/test/pending-events.test.js.map +1 -1
- package/dist/test/prompt-privacy.test.d.ts +2 -0
- package/dist/test/prompt-privacy.test.d.ts.map +1 -0
- package/dist/test/prompt-privacy.test.js +33 -0
- package/dist/test/prompt-privacy.test.js.map +1 -0
- package/dist/test/transcript.test.d.ts +2 -0
- package/dist/test/transcript.test.d.ts.map +1 -0
- package/dist/test/transcript.test.js +38 -0
- package/dist/test/transcript.test.js.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import { applyPromptCollectionToMetadata, stripRawEventPromptFields } from "../lib/telemetry/prompt-privacy.js";
|
|
5
|
+
test("stripRawEventPromptFields removes top-level prompt keys only", () => {
|
|
6
|
+
const stripped = stripRawEventPromptFields({
|
|
7
|
+
user_prompt: "secret",
|
|
8
|
+
prompt: "secret2",
|
|
9
|
+
tool_input: { prompt: "keep" },
|
|
10
|
+
});
|
|
11
|
+
assert(stripped);
|
|
12
|
+
assert.strictEqual(stripped.user_prompt, undefined);
|
|
13
|
+
assert.strictEqual(stripped.prompt, undefined);
|
|
14
|
+
assert.deepStrictEqual(stripped.tool_input, { prompt: "keep" });
|
|
15
|
+
});
|
|
16
|
+
test("applyPromptCollectionToMetadata hashes and drops plaintext when enabled", () => {
|
|
17
|
+
const digest = createHash("sha256").update("do a thing", "utf8").digest("hex");
|
|
18
|
+
const out = applyPromptCollectionToMetadata({
|
|
19
|
+
user_prompt: "do a thing",
|
|
20
|
+
raw_event: { user_prompt: "do a thing", command: "ls" },
|
|
21
|
+
}, true);
|
|
22
|
+
assert.strictEqual(out.user_prompt, undefined);
|
|
23
|
+
assert.strictEqual(out.user_prompt_hash, digest);
|
|
24
|
+
assert.strictEqual(out.raw_event.user_prompt, undefined);
|
|
25
|
+
assert.strictEqual(out.raw_event.command, "ls");
|
|
26
|
+
});
|
|
27
|
+
test("applyPromptCollectionToMetadata keeps plaintext when hashing is off", () => {
|
|
28
|
+
const out = applyPromptCollectionToMetadata({ user_prompt: "hello", raw_event: { user_prompt: "hello" } }, false);
|
|
29
|
+
assert.strictEqual(out.user_prompt, "hello");
|
|
30
|
+
assert.strictEqual(out.user_prompt_hash, undefined);
|
|
31
|
+
assert.strictEqual(out.raw_event.user_prompt, undefined);
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=prompt-privacy.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-privacy.test.js","sourceRoot":"","sources":["../../src/test/prompt-privacy.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,+BAA+B,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAEhH,IAAI,CAAC,8DAA8D,EAAE,GAAG,EAAE;IACxE,MAAM,QAAQ,GAAG,yBAAyB,CAAC;QACzC,WAAW,EAAE,QAAQ;QACrB,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;KAC/B,CAAC,CAAC;IACH,MAAM,CAAC,QAAQ,CAAC,CAAC;IACjB,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACpD,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC/C,MAAM,CAAC,eAAe,CAAC,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@@
|
|
|
1
|
+
{"version":3,"file":"transcript.test.d.ts","sourceRoot":"","sources":["../../src/test/transcript.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import os from "os";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import { readLastUserPrompt } from "../lib/transcript.js";
|
|
7
|
+
function transcript(lines) {
|
|
8
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "transcript-"));
|
|
9
|
+
const file = path.join(dir, "t.jsonl");
|
|
10
|
+
fs.writeFileSync(file, lines.map((l) => JSON.stringify(l)).join("\n") + "\n");
|
|
11
|
+
return file;
|
|
12
|
+
}
|
|
13
|
+
const codexUser = (text) => ({
|
|
14
|
+
type: "response_item",
|
|
15
|
+
payload: { type: "message", role: "user", content: [{ type: "input_text", text }] },
|
|
16
|
+
});
|
|
17
|
+
test("readLastUserPrompt - Codex: the last prompt the person typed", () => {
|
|
18
|
+
const file = transcript([
|
|
19
|
+
codexUser("# AGENTS.md instructions for /repo"),
|
|
20
|
+
codexUser("<environment_context>\n <cwd>/repo</cwd>"),
|
|
21
|
+
codexUser("first question"),
|
|
22
|
+
{ type: "response_item", payload: { type: "function_call", name: "shell" } },
|
|
23
|
+
codexUser("Run ls -la /tmp"),
|
|
24
|
+
]);
|
|
25
|
+
assert.strictEqual(readLastUserPrompt(file), "Run ls -la /tmp");
|
|
26
|
+
});
|
|
27
|
+
test("readLastUserPrompt - Codex: injected context is never taken for the prompt", () => {
|
|
28
|
+
const file = transcript([codexUser("real prompt"), codexUser("<environment_context>x")]);
|
|
29
|
+
assert.strictEqual(readLastUserPrompt(file), "real prompt");
|
|
30
|
+
});
|
|
31
|
+
test("readLastUserPrompt - Claude transcripts still read as before", () => {
|
|
32
|
+
const file = transcript([{ type: "user", message: { role: "user", content: "claude prompt" } }]);
|
|
33
|
+
assert.strictEqual(readLastUserPrompt(file), "claude prompt");
|
|
34
|
+
});
|
|
35
|
+
test("readLastUserPrompt - missing file is null", () => {
|
|
36
|
+
assert.strictEqual(readLastUserPrompt("/nonexistent/t.jsonl"), null);
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=transcript.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript.test.js","sourceRoot":"","sources":["../../src/test/transcript.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,SAAS,UAAU,CAAC,KAAgB;IAClC,MAAM,GAAG,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC;IAClE,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IACvC,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IAC9E,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,SAAS,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC;IACnC,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,EAAE;CACp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
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optimuslabs/runtime-staging",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
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,7 +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 ../
|
|
14
|
+
"pretest": "npm run build --prefix ../tofu && npm run build",
|
|
15
15
|
"test": "node --test dist/test/*.test.js",
|
|
16
16
|
"prepare": "npm run build"
|
|
17
17
|
},
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
"repository": {
|
|
28
28
|
"type": "git",
|
|
29
29
|
"url": "git+https://github.com/optimuslabs-io/optimus-secure-fdn.git",
|
|
30
|
-
"directory": "npx_packages/staging/optimuslabs/
|
|
30
|
+
"directory": "npx_packages/staging/optimuslabs/runtime"
|
|
31
31
|
},
|
|
32
32
|
"bugs": {
|
|
33
33
|
"url": "https://github.com/optimuslabs-io/optimus-secure-fdn/issues"
|
|
34
34
|
},
|
|
35
|
-
"homepage": "https://github.com/optimuslabs-io/optimus-secure-fdn/tree/main/npx_packages/staging/optimuslabs/
|
|
35
|
+
"homepage": "https://github.com/optimuslabs-io/optimus-secure-fdn/tree/main/npx_packages/staging/optimuslabs/runtime#readme",
|
|
36
36
|
"files": [
|
|
37
37
|
"dist/**/*",
|
|
38
38
|
"README.md"
|