jules-orchestrator-kit 0.22.2 ā 0.22.3
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/bin/agentctl.mjs +2 -2
- package/package.json +1 -1
- package/src/engine.mjs +13 -2
- package/src/git.mjs +1 -0
- package/src/preload-net-guard.mjs +132 -0
package/bin/agentctl.mjs
CHANGED
|
@@ -13,7 +13,7 @@ const command = args[0];
|
|
|
13
13
|
|
|
14
14
|
function printHelp() {
|
|
15
15
|
console.log(`
|
|
16
|
-
š agentctl v0.22.
|
|
16
|
+
š agentctl v0.22.3 ā Universal Agent Orchestrator & Safety Gatekeeper
|
|
17
17
|
|
|
18
18
|
Usage: agentctl <command> [options]
|
|
19
19
|
|
|
@@ -223,7 +223,7 @@ async function main() {
|
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
case "doctor": {
|
|
226
|
-
console.log(`\nš agentctl System Diagnostics (v0.22.
|
|
226
|
+
console.log(`\nš agentctl System Diagnostics (v0.22.3)`);
|
|
227
227
|
console.log(`--------------------------------------------------`);
|
|
228
228
|
console.log(` Project Root : ${root}`);
|
|
229
229
|
console.log(` Config File : ${config._file || "None (Using defaults)"}`);
|
package/package.json
CHANGED
package/src/engine.mjs
CHANGED
|
@@ -113,13 +113,24 @@ export async function gate(opts = {}) {
|
|
|
113
113
|
let testResult = { ok: true, status: 0 };
|
|
114
114
|
let buildResult = { ok: true, status: 0 };
|
|
115
115
|
|
|
116
|
+
const existingNodeOptions = process.env.NODE_OPTIONS || "";
|
|
117
|
+
const netGuardFlag = "--import ./src/preload-net-guard.mjs";
|
|
118
|
+
const guardNodeOptions = existingNodeOptions && !existingNodeOptions.includes(netGuardFlag)
|
|
119
|
+
? `${existingNodeOptions} ${netGuardFlag}`
|
|
120
|
+
: existingNodeOptions ? existingNodeOptions : netGuardFlag;
|
|
121
|
+
|
|
122
|
+
const testEnv = {
|
|
123
|
+
...process.env,
|
|
124
|
+
NODE_OPTIONS: guardNodeOptions,
|
|
125
|
+
};
|
|
126
|
+
|
|
116
127
|
if (testCmd) {
|
|
117
|
-
const res = runCmd(testCmd, { cwd: root, ignoreError: true });
|
|
128
|
+
const res = runCmd(testCmd, { cwd: root, ignoreError: true, env: testEnv });
|
|
118
129
|
testResult = { ok: res.status === 0, status: res.status, stdout: res.stdout, stderr: res.stderr, command: testCmd };
|
|
119
130
|
}
|
|
120
131
|
|
|
121
132
|
if (testResult.ok && buildCmd) {
|
|
122
|
-
const res = runCmd(buildCmd, { cwd: root, ignoreError: true });
|
|
133
|
+
const res = runCmd(buildCmd, { cwd: root, ignoreError: true, env: testEnv });
|
|
123
134
|
buildResult = { ok: res.status === 0, status: res.status, stdout: res.stdout, stderr: res.stderr, command: buildCmd };
|
|
124
135
|
}
|
|
125
136
|
|
package/src/git.mjs
CHANGED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import http from "node:http";
|
|
2
|
+
import https from "node:https";
|
|
3
|
+
|
|
4
|
+
const ALLOWLIST = new Set(["localhost", "127.0.0.1", "::1"]);
|
|
5
|
+
|
|
6
|
+
function normalizeHost(host) {
|
|
7
|
+
if (!host) return "localhost";
|
|
8
|
+
let h = String(host).trim().toLowerCase();
|
|
9
|
+
if (h.startsWith("[")) {
|
|
10
|
+
const closing = h.indexOf("]");
|
|
11
|
+
if (closing !== -1) {
|
|
12
|
+
h = h.substring(1, closing);
|
|
13
|
+
}
|
|
14
|
+
} else {
|
|
15
|
+
h = h.split(":")[0];
|
|
16
|
+
}
|
|
17
|
+
return h;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function checkHost(rawHost) {
|
|
21
|
+
const norm = normalizeHost(rawHost);
|
|
22
|
+
if (!ALLOWLIST.has(norm)) {
|
|
23
|
+
process.stderr.write(`[FATAL] ERR_UNMOCKED_NET: ${norm}\n`);
|
|
24
|
+
process.exit(188);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function extractHostFromFetch(input) {
|
|
29
|
+
let urlStr = "";
|
|
30
|
+
if (typeof input === "string") {
|
|
31
|
+
urlStr = input;
|
|
32
|
+
} else if (input && typeof input === "object") {
|
|
33
|
+
if (input instanceof URL) {
|
|
34
|
+
return input.hostname;
|
|
35
|
+
}
|
|
36
|
+
if (input.url) {
|
|
37
|
+
urlStr = String(input.url);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (urlStr) {
|
|
42
|
+
try {
|
|
43
|
+
const parsed = new URL(urlStr, "http://localhost");
|
|
44
|
+
return parsed.hostname;
|
|
45
|
+
} catch (_) {
|
|
46
|
+
return urlStr;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return "localhost";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function extractHostFromHttpArgs(args) {
|
|
53
|
+
if (!args || args.length === 0) return "localhost";
|
|
54
|
+
|
|
55
|
+
let urlArg = null;
|
|
56
|
+
let optionsArg = null;
|
|
57
|
+
|
|
58
|
+
if (typeof args[0] === "string" || args[0] instanceof URL) {
|
|
59
|
+
urlArg = args[0];
|
|
60
|
+
if (args[1] && typeof args[1] === "object" && !Array.isArray(args[1])) {
|
|
61
|
+
optionsArg = args[1];
|
|
62
|
+
}
|
|
63
|
+
} else if (args[0] && typeof args[0] === "object" && !Array.isArray(args[0])) {
|
|
64
|
+
optionsArg = args[0];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let rawHost = "";
|
|
68
|
+
if (optionsArg) {
|
|
69
|
+
rawHost = optionsArg.hostname || optionsArg.host;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!rawHost && urlArg) {
|
|
73
|
+
if (urlArg instanceof URL) {
|
|
74
|
+
rawHost = urlArg.hostname;
|
|
75
|
+
} else if (typeof urlArg === "string") {
|
|
76
|
+
try {
|
|
77
|
+
const u = new URL(urlArg, "http://localhost");
|
|
78
|
+
rawHost = u.hostname;
|
|
79
|
+
} catch (_) {
|
|
80
|
+
rawHost = urlArg;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (!rawHost) {
|
|
86
|
+
rawHost = "localhost";
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return rawHost;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Patch globalThis.fetch
|
|
93
|
+
if (typeof globalThis.fetch === "function") {
|
|
94
|
+
const origFetch = globalThis.fetch;
|
|
95
|
+
globalThis.fetch = function (input, init) {
|
|
96
|
+
const rawHost = extractHostFromFetch(input);
|
|
97
|
+
checkHost(rawHost);
|
|
98
|
+
return origFetch.call(this, input, init);
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Patch node:http.request
|
|
103
|
+
const origHttpRequest = http.request;
|
|
104
|
+
http.request = function (...args) {
|
|
105
|
+
const rawHost = extractHostFromHttpArgs(args);
|
|
106
|
+
checkHost(rawHost);
|
|
107
|
+
return origHttpRequest.apply(this, args);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// Patch node:http.get
|
|
111
|
+
const origHttpGet = http.get;
|
|
112
|
+
http.get = function (...args) {
|
|
113
|
+
const rawHost = extractHostFromHttpArgs(args);
|
|
114
|
+
checkHost(rawHost);
|
|
115
|
+
return origHttpGet.apply(this, args);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// Patch node:https.request
|
|
119
|
+
const origHttpsRequest = https.request;
|
|
120
|
+
https.request = function (...args) {
|
|
121
|
+
const rawHost = extractHostFromHttpArgs(args);
|
|
122
|
+
checkHost(rawHost);
|
|
123
|
+
return origHttpsRequest.apply(this, args);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// Patch node:https.get
|
|
127
|
+
const origHttpsGet = https.get;
|
|
128
|
+
https.get = function (...args) {
|
|
129
|
+
const rawHost = extractHostFromHttpArgs(args);
|
|
130
|
+
checkHost(rawHost);
|
|
131
|
+
return origHttpsGet.apply(this, args);
|
|
132
|
+
};
|