@kenhkl/agent-gate 0.5.0 → 0.5.1
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/cli.js +69 -27
- package/dist/cli.js.map +1 -1
- package/dist/dashboard.html +14 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -44,6 +44,19 @@ var init_cjs_shims = __esm({
|
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
+
// src/version.ts
|
|
48
|
+
var import_module, require2, pkg, version;
|
|
49
|
+
var init_version = __esm({
|
|
50
|
+
"src/version.ts"() {
|
|
51
|
+
"use strict";
|
|
52
|
+
init_cjs_shims();
|
|
53
|
+
import_module = require("module");
|
|
54
|
+
require2 = (0, import_module.createRequire)(importMetaUrl);
|
|
55
|
+
pkg = require2("../../package.json");
|
|
56
|
+
version = pkg.version;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
47
60
|
// src/shared/storage/json-storage.ts
|
|
48
61
|
var json_storage_exports = {};
|
|
49
62
|
__export(json_storage_exports, {
|
|
@@ -133,18 +146,18 @@ var init_json_storage = __esm({
|
|
|
133
146
|
saveToolCalls(sessionId, records) {
|
|
134
147
|
this.writeJsonFile((0, import_path.join)(this.toolCallsDir, `${sessionId}.json`), records);
|
|
135
148
|
}
|
|
136
|
-
getOrCreateAgent(agentType, hostname,
|
|
149
|
+
getOrCreateAgent(agentType, hostname, version3 = "") {
|
|
137
150
|
const agents = this.loadAgents();
|
|
138
151
|
const id = `${agentType}:${hostname}`;
|
|
139
152
|
const existing = agents.get(id);
|
|
140
153
|
if (existing) {
|
|
141
154
|
existing.last_seen_at = nowISO();
|
|
142
|
-
if (
|
|
155
|
+
if (version3) existing.agent_version = version3;
|
|
143
156
|
} else {
|
|
144
157
|
agents.set(id, {
|
|
145
158
|
id,
|
|
146
159
|
agent_type: agentType,
|
|
147
|
-
agent_version:
|
|
160
|
+
agent_version: version3,
|
|
148
161
|
hostname,
|
|
149
162
|
registered_at: nowISO(),
|
|
150
163
|
last_seen_at: nowISO()
|
|
@@ -367,11 +380,11 @@ CREATE INDEX IF NOT EXISTS idx_tool_calls_decision ON tool_calls(decision, calle
|
|
|
367
380
|
return false;
|
|
368
381
|
}
|
|
369
382
|
}
|
|
370
|
-
getOrCreateAgent(agentType, hostname,
|
|
383
|
+
getOrCreateAgent(agentType, hostname, version3 = "") {
|
|
371
384
|
const id = `${agentType}:${hostname}`;
|
|
372
385
|
this.db.prepare(
|
|
373
386
|
"INSERT OR IGNORE INTO agents (id, agent_type, agent_version, hostname) VALUES (?, ?, ?, ?)"
|
|
374
|
-
).run(id, agentType,
|
|
387
|
+
).run(id, agentType, version3, hostname);
|
|
375
388
|
this.db.prepare("UPDATE agents SET last_seen_at = datetime('now') WHERE id = ?").run(id);
|
|
376
389
|
return id;
|
|
377
390
|
}
|
|
@@ -557,6 +570,7 @@ var init_db = __esm({
|
|
|
557
570
|
var moss_client_exports = {};
|
|
558
571
|
__export(moss_client_exports, {
|
|
559
572
|
callAgentMoss: () => callAgentMoss,
|
|
573
|
+
fetchMossHealth: () => fetchMossHealth,
|
|
560
574
|
setMossUrl: () => setMossUrl
|
|
561
575
|
});
|
|
562
576
|
function setMossUrl(url) {
|
|
@@ -580,6 +594,23 @@ async function callAgentMoss(request) {
|
|
|
580
594
|
return failClosedResponse("AgentMoss service unavailable");
|
|
581
595
|
}
|
|
582
596
|
}
|
|
597
|
+
async function fetchMossHealth() {
|
|
598
|
+
try {
|
|
599
|
+
const resp = await fetch(`${mossUrl}/api/v1/health`, {
|
|
600
|
+
signal: AbortSignal.timeout(3e3)
|
|
601
|
+
});
|
|
602
|
+
if (!resp.ok) {
|
|
603
|
+
return { moss_version: "N/A", moss_status: "error" };
|
|
604
|
+
}
|
|
605
|
+
const data = await resp.json();
|
|
606
|
+
return {
|
|
607
|
+
moss_version: data.version || "unknown",
|
|
608
|
+
moss_status: data.status || "unknown"
|
|
609
|
+
};
|
|
610
|
+
} catch {
|
|
611
|
+
return { moss_version: "N/A", moss_status: "unreachable" };
|
|
612
|
+
}
|
|
613
|
+
}
|
|
583
614
|
function failClosedResponse(reason) {
|
|
584
615
|
return {
|
|
585
616
|
decision: "Deny",
|
|
@@ -607,6 +638,7 @@ var init_models = __esm({
|
|
|
607
638
|
"use strict";
|
|
608
639
|
init_cjs_shims();
|
|
609
640
|
import_zod = require("zod");
|
|
641
|
+
init_version();
|
|
610
642
|
AgentGateInputSchema = import_zod.z.object({
|
|
611
643
|
agent_type: import_zod.z.string().describe("Agent identifier, e.g. opendesk, claude-code"),
|
|
612
644
|
agent_version: import_zod.z.string().default("0.1.0"),
|
|
@@ -652,7 +684,9 @@ var init_models = __esm({
|
|
|
652
684
|
});
|
|
653
685
|
HealthResponseSchema = import_zod.z.object({
|
|
654
686
|
status: import_zod.z.string().default("healthy"),
|
|
655
|
-
version: import_zod.z.string().default(
|
|
687
|
+
version: import_zod.z.string().default(version),
|
|
688
|
+
moss_version: import_zod.z.string().default("N/A"),
|
|
689
|
+
moss_status: import_zod.z.string().default("unknown")
|
|
656
690
|
});
|
|
657
691
|
}
|
|
658
692
|
});
|
|
@@ -813,8 +847,8 @@ var init_cache = __esm({
|
|
|
813
847
|
function store() {
|
|
814
848
|
return createStorage();
|
|
815
849
|
}
|
|
816
|
-
function getOrCreateAgent(agentType, hostname,
|
|
817
|
-
return store().getOrCreateAgent(agentType, hostname,
|
|
850
|
+
function getOrCreateAgent(agentType, hostname, version3) {
|
|
851
|
+
return store().getOrCreateAgent(agentType, hostname, version3);
|
|
818
852
|
}
|
|
819
853
|
function getOrCreateSession(sessionId, agentId, cwd, prompt, osType) {
|
|
820
854
|
store().getOrCreateSession(sessionId, agentId, cwd, prompt, osType);
|
|
@@ -844,7 +878,13 @@ var init_repository = __esm({
|
|
|
844
878
|
|
|
845
879
|
// src/v1/routes.ts
|
|
846
880
|
async function healthRoute(c) {
|
|
847
|
-
|
|
881
|
+
const mossHealth = await fetchMossHealth();
|
|
882
|
+
return c.json({
|
|
883
|
+
status: "healthy",
|
|
884
|
+
version,
|
|
885
|
+
moss_version: mossHealth.moss_version,
|
|
886
|
+
moss_status: mossHealth.moss_status
|
|
887
|
+
});
|
|
848
888
|
}
|
|
849
889
|
async function analyzeRoute(c) {
|
|
850
890
|
const t0 = performance.now();
|
|
@@ -940,6 +980,7 @@ var init_routes = __esm({
|
|
|
940
980
|
init_moss_client();
|
|
941
981
|
init_cache();
|
|
942
982
|
init_repository();
|
|
983
|
+
init_version();
|
|
943
984
|
}
|
|
944
985
|
});
|
|
945
986
|
|
|
@@ -6344,7 +6385,7 @@ var require_websocket_server = __commonJS({
|
|
|
6344
6385
|
socket.on("error", socketOnError);
|
|
6345
6386
|
const key = req.headers["sec-websocket-key"];
|
|
6346
6387
|
const upgrade = req.headers.upgrade;
|
|
6347
|
-
const
|
|
6388
|
+
const version3 = +req.headers["sec-websocket-version"];
|
|
6348
6389
|
if (req.method !== "GET") {
|
|
6349
6390
|
const message = "Invalid HTTP method";
|
|
6350
6391
|
abortHandshakeOrEmitwsClientError(this, req, socket, 405, message);
|
|
@@ -6360,7 +6401,7 @@ var require_websocket_server = __commonJS({
|
|
|
6360
6401
|
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
6361
6402
|
return;
|
|
6362
6403
|
}
|
|
6363
|
-
if (
|
|
6404
|
+
if (version3 !== 13 && version3 !== 8) {
|
|
6364
6405
|
const message = "Missing or invalid Sec-WebSocket-Version header";
|
|
6365
6406
|
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message, {
|
|
6366
6407
|
"Sec-WebSocket-Version": "13, 8"
|
|
@@ -6404,7 +6445,7 @@ var require_websocket_server = __commonJS({
|
|
|
6404
6445
|
}
|
|
6405
6446
|
if (this.options.verifyClient) {
|
|
6406
6447
|
const info = {
|
|
6407
|
-
origin: req.headers[`${
|
|
6448
|
+
origin: req.headers[`${version3 === 8 ? "sec-websocket-origin" : "origin"}`],
|
|
6408
6449
|
secure: !!(req.socket.authorized || req.socket.encrypted),
|
|
6409
6450
|
req
|
|
6410
6451
|
};
|
|
@@ -19768,14 +19809,14 @@ var require_tls = __commonJS({
|
|
|
19768
19809
|
c.version = c.session.version = session.version;
|
|
19769
19810
|
c.session.sp = session.sp;
|
|
19770
19811
|
} else {
|
|
19771
|
-
var
|
|
19812
|
+
var version3;
|
|
19772
19813
|
for (var i = 1; i < tls.SupportedVersions.length; ++i) {
|
|
19773
|
-
|
|
19774
|
-
if (
|
|
19814
|
+
version3 = tls.SupportedVersions[i];
|
|
19815
|
+
if (version3.minor <= msg.version.minor) {
|
|
19775
19816
|
break;
|
|
19776
19817
|
}
|
|
19777
19818
|
}
|
|
19778
|
-
c.version = { major:
|
|
19819
|
+
c.version = { major: version3.major, minor: version3.minor };
|
|
19779
19820
|
c.session.version = c.version;
|
|
19780
19821
|
}
|
|
19781
19822
|
if (session !== null) {
|
|
@@ -19946,8 +19987,8 @@ var require_tls = __commonJS({
|
|
|
19946
19987
|
try {
|
|
19947
19988
|
var sp = c.session.sp;
|
|
19948
19989
|
sp.pre_master_secret = privateKey.decrypt(msg.enc_pre_master_secret);
|
|
19949
|
-
var
|
|
19950
|
-
if (
|
|
19990
|
+
var version3 = c.session.clientHelloVersion;
|
|
19991
|
+
if (version3.major !== sp.pre_master_secret.charCodeAt(0) || version3.minor !== sp.pre_master_secret.charCodeAt(1)) {
|
|
19951
19992
|
throw new Error("TLS version rollback attack detected.");
|
|
19952
19993
|
}
|
|
19953
19994
|
} catch (ex) {
|
|
@@ -24763,8 +24804,8 @@ var require_use_native = __commonJS({
|
|
|
24763
24804
|
"use strict";
|
|
24764
24805
|
init_cjs_shims();
|
|
24765
24806
|
var fs2 = require("fs");
|
|
24766
|
-
var
|
|
24767
|
-
var versArr =
|
|
24807
|
+
var version3 = process.env.__TESTING_MKDIRP_NODE_VERSION__ || process.version;
|
|
24808
|
+
var versArr = version3.replace(/^v/, "").split(".");
|
|
24768
24809
|
var hasNative = +versArr[0] > 10 || +versArr[0] === 10 && +versArr[1] >= 12;
|
|
24769
24810
|
var useNative = !hasNative ? () => false : (opts) => opts.mkdir === fs2.mkdir;
|
|
24770
24811
|
var useNativeSync = !hasNative ? () => false : (opts) => opts.mkdirSync === fs2.mkdirSync;
|
|
@@ -25366,7 +25407,7 @@ function stringToBytes(str) {
|
|
|
25366
25407
|
}
|
|
25367
25408
|
return bytes;
|
|
25368
25409
|
}
|
|
25369
|
-
function v35(name,
|
|
25410
|
+
function v35(name, version3, hashfunc) {
|
|
25370
25411
|
function generateUUID(value, namespace, buf, offset) {
|
|
25371
25412
|
var _namespace;
|
|
25372
25413
|
if (typeof value === "string") {
|
|
@@ -25382,7 +25423,7 @@ function v35(name, version2, hashfunc) {
|
|
|
25382
25423
|
bytes.set(namespace);
|
|
25383
25424
|
bytes.set(value, namespace.length);
|
|
25384
25425
|
bytes = hashfunc(bytes);
|
|
25385
|
-
bytes[6] = bytes[6] & 15 |
|
|
25426
|
+
bytes[6] = bytes[6] & 15 | version3;
|
|
25386
25427
|
bytes[8] = bytes[8] & 63 | 128;
|
|
25387
25428
|
if (buf) {
|
|
25388
25429
|
offset = offset || 0;
|
|
@@ -25531,19 +25572,19 @@ var init_nil = __esm({
|
|
|
25531
25572
|
});
|
|
25532
25573
|
|
|
25533
25574
|
// ../node_modules/uuid/dist/esm-node/version.js
|
|
25534
|
-
function
|
|
25575
|
+
function version2(uuid) {
|
|
25535
25576
|
if (!validate_default(uuid)) {
|
|
25536
25577
|
throw TypeError("Invalid UUID");
|
|
25537
25578
|
}
|
|
25538
25579
|
return parseInt(uuid.slice(14, 15), 16);
|
|
25539
25580
|
}
|
|
25540
25581
|
var version_default;
|
|
25541
|
-
var
|
|
25582
|
+
var init_version2 = __esm({
|
|
25542
25583
|
"../node_modules/uuid/dist/esm-node/version.js"() {
|
|
25543
25584
|
"use strict";
|
|
25544
25585
|
init_cjs_shims();
|
|
25545
25586
|
init_validate();
|
|
25546
|
-
version_default =
|
|
25587
|
+
version_default = version2;
|
|
25547
25588
|
}
|
|
25548
25589
|
});
|
|
25549
25590
|
|
|
@@ -25569,7 +25610,7 @@ var init_esm_node = __esm({
|
|
|
25569
25610
|
init_v4();
|
|
25570
25611
|
init_v5();
|
|
25571
25612
|
init_nil();
|
|
25572
|
-
|
|
25613
|
+
init_version2();
|
|
25573
25614
|
init_validate();
|
|
25574
25615
|
init_stringify();
|
|
25575
25616
|
init_parse();
|
|
@@ -29353,11 +29394,12 @@ var init_launcher = __esm({
|
|
|
29353
29394
|
init_cjs_shims();
|
|
29354
29395
|
var import_node_fs4 = require("fs");
|
|
29355
29396
|
var import_yaml3 = require("yaml");
|
|
29397
|
+
init_version();
|
|
29356
29398
|
async function main() {
|
|
29357
29399
|
const args = process.argv.slice(2);
|
|
29358
29400
|
const command = args[0];
|
|
29359
29401
|
if (!command || command === "--help" || command === "-h") {
|
|
29360
|
-
console.log(`AgentGate - AI Agent Data Collection & Security Analysis Gateway (TS
|
|
29402
|
+
console.log(`AgentGate - AI Agent Data Collection & Security Analysis Gateway (TS v${version})
|
|
29361
29403
|
|
|
29362
29404
|
Commands:
|
|
29363
29405
|
start Start AgentGate with specified layers (unified)
|