deepdebug-local-agent 1.3.0 → 1.5.0
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/.github/workflows/deploy-gcp.yml +58 -26
- package/CHANGELOG.md +6 -0
- package/docs/la-protocol-v2.md +102 -0
- package/package.json +2 -1
- package/scripts/sync-la-protocol-v2-contract.mjs +58 -0
- package/src/la-protocol-v2/chunks.js +45 -0
- package/src/la-protocol-v2/config.js +27 -0
- package/src/la-protocol-v2/content-handlers/audit.js +36 -0
- package/src/la-protocol-v2/content-handlers/config.js +48 -0
- package/src/la-protocol-v2/content-handlers/egress.js +65 -0
- package/src/la-protocol-v2/content-handlers/git-diff.js +92 -0
- package/src/la-protocol-v2/content-handlers/handler.js +170 -0
- package/src/la-protocol-v2/content-handlers/index.js +6 -0
- package/src/la-protocol-v2/content-handlers/install.js +50 -0
- package/src/la-protocol-v2/content-handlers/path-guard.js +142 -0
- package/src/la-protocol-v2/content-handlers/ref-registry.js +87 -0
- package/src/la-protocol-v2/content.js +63 -0
- package/src/la-protocol-v2/contract/CONTRACT_SOURCE.json +81 -0
- package/src/la-protocol-v2/contract/README.md +103 -0
- package/src/la-protocol-v2/contract/ack.schema.json +51 -0
- package/src/la-protocol-v2/contract/alert.schema.json +62 -0
- package/src/la-protocol-v2/contract/approval.decision.schema.json +57 -0
- package/src/la-protocol-v2/contract/audit.event.schema.json +86 -0
- package/src/la-protocol-v2/contract/config.update.schema.json +73 -0
- package/src/la-protocol-v2/contract/content.request.schema.json +110 -0
- package/src/la-protocol-v2/contract/content.response.schema.json +90 -0
- package/src/la-protocol-v2/contract/defs.schema.json +191 -0
- package/src/la-protocol-v2/contract/envelope.schema.json +89 -0
- package/src/la-protocol-v2/contract/error.schema.json +59 -0
- package/src/la-protocol-v2/contract/heartbeat.schema.json +100 -0
- package/src/la-protocol-v2/contract/hello.schema.json +111 -0
- package/src/la-protocol-v2/contract/incident.candidate.schema.json +102 -0
- package/src/la-protocol-v2/contract/index.json +166 -0
- package/src/la-protocol-v2/contract/job.assign.schema.json +212 -0
- package/src/la-protocol-v2/contract/job.cancel.schema.json +52 -0
- package/src/la-protocol-v2/contract/job.event.schema.json +115 -0
- package/src/la-protocol-v2/contract/job.result.schema.json +100 -0
- package/src/la-protocol-v2/contract/log.stats.schema.json +79 -0
- package/src/la-protocol-v2/contract/ready.schema.json +106 -0
- package/src/la-protocol-v2/contract/register.schema.json +92 -0
- package/src/la-protocol-v2/contract/scan.upload.schema.json +59 -0
- package/src/la-protocol-v2/contract/scan.uploaded.schema.json +51 -0
- package/src/la-protocol-v2/contract/webhook.forward.schema.json +69 -0
- package/src/la-protocol-v2/contract.js +90 -0
- package/src/la-protocol-v2/errors.js +34 -0
- package/src/la-protocol-v2/index.js +8 -0
- package/src/la-protocol-v2/link.js +93 -0
- package/src/la-protocol-v2/runtime.js +81 -0
- package/src/la-protocol-v2/session.js +650 -0
- package/src/la-protocol-v2/strict-json.js +47 -0
- package/src/server.js +25 -4
- package/test/contract/la-protocol-v2/vectors/ack.vectors.json +149 -0
- package/test/contract/la-protocol-v2/vectors/alert.vectors.json +101 -0
- package/test/contract/la-protocol-v2/vectors/approval.decision.vectors.json +165 -0
- package/test/contract/la-protocol-v2/vectors/audit.event.vectors.json +156 -0
- package/test/contract/la-protocol-v2/vectors/config.update.vectors.json +189 -0
- package/test/contract/la-protocol-v2/vectors/content.request.vectors.json +325 -0
- package/test/contract/la-protocol-v2/vectors/content.response.vectors.json +413 -0
- package/test/contract/la-protocol-v2/vectors/cross-type.vectors.json +260 -0
- package/test/contract/la-protocol-v2/vectors/error.vectors.json +179 -0
- package/test/contract/la-protocol-v2/vectors/heartbeat.vectors.json +109 -0
- package/test/contract/la-protocol-v2/vectors/hello.vectors.json +224 -0
- package/test/contract/la-protocol-v2/vectors/incident.candidate.vectors.json +186 -0
- package/test/contract/la-protocol-v2/vectors/job.assign.vectors.json +631 -0
- package/test/contract/la-protocol-v2/vectors/job.cancel.vectors.json +133 -0
- package/test/contract/la-protocol-v2/vectors/job.event.vectors.json +233 -0
- package/test/contract/la-protocol-v2/vectors/job.result.vectors.json +137 -0
- package/test/contract/la-protocol-v2/vectors/log.stats.vectors.json +137 -0
- package/test/contract/la-protocol-v2/vectors/ready.vectors.json +177 -0
- package/test/contract/la-protocol-v2/vectors/register.vectors.json +399 -0
- package/test/contract/la-protocol-v2/vectors/scan.upload.vectors.json +137 -0
- package/test/contract/la-protocol-v2/vectors/scan.uploaded.vectors.json +101 -0
- package/test/contract/la-protocol-v2/vectors/traces/invalid-agent-mismatch.json +140 -0
- package/test/contract/la-protocol-v2/vectors/traces/invalid-chunk-after-last.json +200 -0
- package/test/contract/la-protocol-v2/vectors/traces/invalid-chunk-byte-length-mismatch.json +174 -0
- package/test/contract/la-protocol-v2/vectors/traces/invalid-chunk-last-flag.json +200 -0
- package/test/contract/la-protocol-v2/vectors/traces/invalid-chunk-out-of-order.json +200 -0
- package/test/contract/la-protocol-v2/vectors/traces/invalid-chunk-total-changes.json +200 -0
- package/test/contract/la-protocol-v2/vectors/traces/invalid-clock-skew.json +46 -0
- package/test/contract/la-protocol-v2/vectors/traces/invalid-event-before-ready.json +72 -0
- package/test/contract/la-protocol-v2/vectors/traces/invalid-first-frame-not-register.json +48 -0
- package/test/contract/la-protocol-v2/vectors/traces/invalid-frame-over-48kib.json +141 -0
- package/test/contract/la-protocol-v2/vectors/traces/invalid-la-sends-job-assign.json +173 -0
- package/test/contract/la-protocol-v2/vectors/traces/invalid-params-raw-differs-from-payload.json +172 -0
- package/test/contract/la-protocol-v2/vectors/traces/invalid-payload-above-limit.json +174 -0
- package/test/contract/la-protocol-v2/vectors/traces/invalid-resume-restarts-seq.json +144 -0
- package/test/contract/la-protocol-v2/vectors/traces/invalid-seq-gap.json +166 -0
- package/test/contract/la-protocol-v2/vectors/traces/invalid-seq-repeated.json +166 -0
- package/test/contract/la-protocol-v2/vectors/traces/invalid-sig-tenant-mismatch.json +172 -0
- package/test/contract/la-protocol-v2/vectors/traces/invalid-signature-warn-with-enforce-required.json +77 -0
- package/test/contract/la-protocol-v2/vectors/traces/invalid-tenant-mismatch.json +140 -0
- package/test/contract/la-protocol-v2/vectors/traces/invalid-type-outside-allowlist.json +140 -0
- package/test/contract/la-protocol-v2/vectors/traces/valid-content-chunks-in-order.json +224 -0
- package/test/contract/la-protocol-v2/vectors/traces/valid-handshake-and-job.json +266 -0
- package/test/contract/la-protocol-v2/vectors/traces/valid-resume-continues-seq.json +168 -0
- package/test/contract/la-protocol-v2/vectors/traces/valid-retransmit-is-idempotent.json +193 -0
- package/test/contract/la-protocol-v2/vectors/webhook.forward.vectors.json +170 -0
- package/test/la-protocol-v2/content-handlers.test.js +633 -0
- package/test/la-protocol-v2/content-path-guard.test.js +214 -0
- package/test/la-protocol-v2/content-wiring.test.js +225 -0
- package/test/la-protocol-v2/contract.test.js +131 -0
- package/test/la-protocol-v2/helpers/content-rig.js +94 -0
- package/test/la-protocol-v2/helpers/la-rig.js +83 -0
- package/test/la-protocol-v2/helpers/reference-cp.js +349 -0
- package/test/la-protocol-v2/helpers/spawn-agent.js +36 -0
- package/test/la-protocol-v2/link.test.js +141 -0
- package/test/la-protocol-v2/session-inbound.test.js +279 -0
- package/test/la-protocol-v2/session-outbound.test.js +382 -0
- package/test/la-protocol-v2/traces.test.js +270 -0
- package/test/la-protocol-v2/tunnel-e2e.test.js +124 -0
- package/tools/graphify-validation/extras/README.md +19 -0
- package/tools/graphify-validation/extras/bymethod.py +35 -0
- package/tools/graphify-validation/extras/docker/Dockerfile +16 -0
- package/tools/graphify-validation/extras/docker/inner.sh +7 -0
- package/tools/graphify-validation/extras/g10.py +59 -0
- package/tools/graphify-validation/extras/g3aug.py +49 -0
- package/tools/graphify-validation/extras/hybrid.py +34 -0
- package/tools/graphify-validation/extras/truth2.py +44 -0
- package/tools/interop/LaV2NodeContentInteropTest.java +248 -0
- package/tools/interop/LaV2NodeInteropTest.java +266 -0
- package/tools/interop/README.md +38 -0
- package/tools/interop/la-interop-client.mjs +97 -0
- package/tools/interop/la-interop-content-client.mjs +91 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// F3-07 interoperability client: the REAL Local Agent content handlers (src/la-protocol-v2/content-handlers, DLP, path
|
|
3
|
+
// guard, opaque ids) around the real v2 link, against the real gateway LaV2Session (driven by LaV2NodeContentInteropTest).
|
|
4
|
+
// Nothing is faked on the agent side except the workspace manager (one temp workspace). It prepares files, mints the
|
|
5
|
+
// opaque ids the way a future inventory would (link.content.mintRef) and prints them, one JSON per line, for the test.
|
|
6
|
+
//
|
|
7
|
+
// env: GW_URL TOKEN TENANT AGENT KEY_ID PUBLIC_KEY MODE(enforce) LOCAL_AGENT_DLP_MODE ... (LOCAL_AGENT_CONTENT_HANDLERS is forced on)
|
|
8
|
+
// stdin: "quit"
|
|
9
|
+
import crypto from "node:crypto";
|
|
10
|
+
import fs from "node:fs";
|
|
11
|
+
import os from "node:os";
|
|
12
|
+
import path from "node:path";
|
|
13
|
+
import readline from "node:readline";
|
|
14
|
+
import { execFileSync } from "node:child_process";
|
|
15
|
+
import WebSocket from "ws";
|
|
16
|
+
import { buildV2Link } from "../../src/la-protocol-v2/runtime.js";
|
|
17
|
+
import { resolveSigningConfig } from "../../src/utils/request-signing.js";
|
|
18
|
+
|
|
19
|
+
const { GW_URL, TOKEN, TENANT, AGENT, KEY_ID, PUBLIC_KEY, MODE = "enforce" } = process.env;
|
|
20
|
+
const out = (o) => process.stdout.write(JSON.stringify(o) + "\n");
|
|
21
|
+
|
|
22
|
+
const base = fs.mkdtempSync(path.join(os.tmpdir(), "f307-interop-"));
|
|
23
|
+
const ROOT = path.join(base, "ws");
|
|
24
|
+
fs.mkdirSync(ROOT);
|
|
25
|
+
const put = (rel, data) => { const p = path.join(ROOT, rel); fs.mkdirSync(path.dirname(p), { recursive: true }); fs.writeFileSync(p, data); };
|
|
26
|
+
const git = (...a) => execFileSync("git", ["-c", "user.email=t@t", "-c", "user.name=t", "-c", "commit.gpgsign=false", ...a], { cwd: ROOT, stdio: "ignore" });
|
|
27
|
+
|
|
28
|
+
export const GH = "ghp_" + "A1b2C3d4E5f6G7h8I9j0K1l2M3n4O5p6Q7r8";
|
|
29
|
+
// letters only: the DLP phone rule masks long digit runs, which would make 1 MiB grow past the limit
|
|
30
|
+
const bigText = Buffer.from("alpha beta gamma delta epsilon zeta eta theta\n".repeat(30000)).subarray(0, 1024 * 1024);
|
|
31
|
+
const straddle = "a".repeat(32766 - 20 - 1) + "\n" + `k=${GH}\n` + "z\n".repeat(60000);
|
|
32
|
+
|
|
33
|
+
put("src/app.txt", `first line\ntoken = "${GH}"\nlast line\n`);
|
|
34
|
+
put("big.txt", bigText);
|
|
35
|
+
put("mid.txt", straddle);
|
|
36
|
+
put("swapped.txt", "innocent");
|
|
37
|
+
put("bin.png", Buffer.concat([Buffer.from([0x89, 0x50, 0x4e, 0x47, 0]), crypto.randomBytes(4000)]));
|
|
38
|
+
put(".env", "API=SECRET-ENV-VALUE-123456\n");
|
|
39
|
+
put("tracked.js", "const a = 1;\n");
|
|
40
|
+
fs.writeFileSync(path.join(base, "outside-secret.txt"), "OUTSIDE-SECRET-CONTENT");
|
|
41
|
+
git("init", "-q", "-b", "main"); git("add", "-f", "-A"); git("commit", "-q", "-m", "init");
|
|
42
|
+
put("tracked.js", `const a = 2;\nconst t = "${GH}";\n`);
|
|
43
|
+
|
|
44
|
+
const signing = resolveSigningConfig({
|
|
45
|
+
LOCAL_AGENT_SIGNATURE_MODE: MODE, LOCAL_AGENT_SIGNING_PUBLIC_KEYS: `${KEY_ID}=${PUBLIC_KEY}`, LOCAL_AGENT_TENANT_ID: TENANT,
|
|
46
|
+
}, { defaultFile: null, fileCfg: {} });
|
|
47
|
+
|
|
48
|
+
const env = { ...process.env, LOCAL_AGENT_CONTENT_HANDLERS: "true", LOCAL_AGENT_PROTOCOL_V2: "true" };
|
|
49
|
+
const link = await buildV2Link({
|
|
50
|
+
tenantId: TENANT, agentId: AGENT, signing, getWorkspaceRoot: () => ROOT, env,
|
|
51
|
+
wsManager: { list: () => [{ id: "ws-1", root: ROOT, tenantId: TENANT }] },
|
|
52
|
+
log: { info: () => {}, log: () => {}, warn: (m) => out({ evt: "warn", m }) },
|
|
53
|
+
});
|
|
54
|
+
const session = link.session;
|
|
55
|
+
session.on("ready", (i) => out({ evt: "ready", resumed: i.resumed, sessionId: i.sessionId }));
|
|
56
|
+
session.on("refused", (c) => out({ evt: "refused", code: c }));
|
|
57
|
+
session.on("peer-error", (c) => out({ evt: "peer-error", code: c }));
|
|
58
|
+
|
|
59
|
+
const mint = (kind, rel) => link.content.mintRef({ workspaceId: "ws-1", kind, rel })?.id ?? null;
|
|
60
|
+
const refs = {
|
|
61
|
+
app: mint("file", "src/app.txt"), big: mint("file", "big.txt"), mid: mint("file", "mid.txt"), swapped: mint("file", "swapped.txt"),
|
|
62
|
+
bin: mint("file", "bin.png"), envFile: mint("file", ".env"), diffFile: mint("diff", "tracked.js"),
|
|
63
|
+
};
|
|
64
|
+
// after the id was handed out the file becomes a link to a file OUTSIDE the workspace
|
|
65
|
+
fs.rmSync(path.join(ROOT, "swapped.txt"));
|
|
66
|
+
fs.symlinkSync(path.join(base, "outside-secret.txt"), path.join(ROOT, "swapped.txt"));
|
|
67
|
+
out({ evt: "refs", refs, bigSha256: crypto.createHash("sha256").update(bigText).digest("hex"), bigBytes: bigText.length, ghp: GH });
|
|
68
|
+
|
|
69
|
+
let ws;
|
|
70
|
+
let quitting = false;
|
|
71
|
+
function connect() {
|
|
72
|
+
ws = new WebSocket(GW_URL, { headers: { Authorization: `Bearer ${TOKEN}` } });
|
|
73
|
+
const mine = ws;
|
|
74
|
+
ws.on("open", () => {
|
|
75
|
+
const legacy = () => { out({ evt: "legacy-register" }); mine.send(JSON.stringify({ type: "register", tenantId: TENANT, port: 5055, workspacePath: null })); };
|
|
76
|
+
if (!link.begin(mine, legacy)) legacy();
|
|
77
|
+
const hb = setInterval(() => { if (mine.readyState === 1) mine.send("ping"); else clearInterval(hb); }, 5000);
|
|
78
|
+
});
|
|
79
|
+
ws.on("message", (data, isBinary) => {
|
|
80
|
+
const text = data.toString();
|
|
81
|
+
if (text === "pong") return;
|
|
82
|
+
if (link.handleMessage(mine, text, isBinary)) return;
|
|
83
|
+
out({ evt: "v1-message" });
|
|
84
|
+
});
|
|
85
|
+
ws.on("close", (code) => { out({ evt: "closed", code }); link.onClose(mine); if (!quitting) setTimeout(connect, 100); });
|
|
86
|
+
ws.on("error", () => {});
|
|
87
|
+
}
|
|
88
|
+
connect();
|
|
89
|
+
|
|
90
|
+
const done = () => { quitting = true; try { ws.terminate(); } catch { /* gone */ } link.close(); fs.rmSync(base, { recursive: true, force: true }); process.exit(0); };
|
|
91
|
+
readline.createInterface({ input: process.stdin }).on("line", (l) => { if (l.trim() === "quit") done(); }).on("close", done);
|