@kenhkl/agent-gate 0.5.0 → 0.5.2

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 CHANGED
@@ -44,6 +44,25 @@ var init_cjs_shims = __esm({
44
44
  }
45
45
  });
46
46
 
47
+ // src/version.ts
48
+ var _version, version;
49
+ var init_version = __esm({
50
+ "src/version.ts"() {
51
+ "use strict";
52
+ init_cjs_shims();
53
+ _version = true ? "0.5.2" : (() => {
54
+ try {
55
+ const require2 = createRequire(importMetaUrl);
56
+ const pkg = require2("../package.json");
57
+ return pkg.version;
58
+ } catch {
59
+ return "unknown";
60
+ }
61
+ })();
62
+ version = _version;
63
+ }
64
+ });
65
+
47
66
  // src/shared/storage/json-storage.ts
48
67
  var json_storage_exports = {};
49
68
  __export(json_storage_exports, {
@@ -133,18 +152,18 @@ var init_json_storage = __esm({
133
152
  saveToolCalls(sessionId, records) {
134
153
  this.writeJsonFile((0, import_path.join)(this.toolCallsDir, `${sessionId}.json`), records);
135
154
  }
136
- getOrCreateAgent(agentType, hostname, version2 = "") {
155
+ getOrCreateAgent(agentType, hostname, version3 = "") {
137
156
  const agents = this.loadAgents();
138
157
  const id = `${agentType}:${hostname}`;
139
158
  const existing = agents.get(id);
140
159
  if (existing) {
141
160
  existing.last_seen_at = nowISO();
142
- if (version2) existing.agent_version = version2;
161
+ if (version3) existing.agent_version = version3;
143
162
  } else {
144
163
  agents.set(id, {
145
164
  id,
146
165
  agent_type: agentType,
147
- agent_version: version2,
166
+ agent_version: version3,
148
167
  hostname,
149
168
  registered_at: nowISO(),
150
169
  last_seen_at: nowISO()
@@ -367,11 +386,11 @@ CREATE INDEX IF NOT EXISTS idx_tool_calls_decision ON tool_calls(decision, calle
367
386
  return false;
368
387
  }
369
388
  }
370
- getOrCreateAgent(agentType, hostname, version2 = "") {
389
+ getOrCreateAgent(agentType, hostname, version3 = "") {
371
390
  const id = `${agentType}:${hostname}`;
372
391
  this.db.prepare(
373
392
  "INSERT OR IGNORE INTO agents (id, agent_type, agent_version, hostname) VALUES (?, ?, ?, ?)"
374
- ).run(id, agentType, version2, hostname);
393
+ ).run(id, agentType, version3, hostname);
375
394
  this.db.prepare("UPDATE agents SET last_seen_at = datetime('now') WHERE id = ?").run(id);
376
395
  return id;
377
396
  }
@@ -557,6 +576,7 @@ var init_db = __esm({
557
576
  var moss_client_exports = {};
558
577
  __export(moss_client_exports, {
559
578
  callAgentMoss: () => callAgentMoss,
579
+ fetchMossHealth: () => fetchMossHealth,
560
580
  setMossUrl: () => setMossUrl
561
581
  });
562
582
  function setMossUrl(url) {
@@ -580,6 +600,23 @@ async function callAgentMoss(request) {
580
600
  return failClosedResponse("AgentMoss service unavailable");
581
601
  }
582
602
  }
603
+ async function fetchMossHealth() {
604
+ try {
605
+ const resp = await fetch(`${mossUrl}/api/v1/health`, {
606
+ signal: AbortSignal.timeout(3e3)
607
+ });
608
+ if (!resp.ok) {
609
+ return { moss_version: "N/A", moss_status: "error" };
610
+ }
611
+ const data = await resp.json();
612
+ return {
613
+ moss_version: data.version || "unknown",
614
+ moss_status: data.status || "unknown"
615
+ };
616
+ } catch {
617
+ return { moss_version: "N/A", moss_status: "unreachable" };
618
+ }
619
+ }
583
620
  function failClosedResponse(reason) {
584
621
  return {
585
622
  decision: "Deny",
@@ -607,6 +644,7 @@ var init_models = __esm({
607
644
  "use strict";
608
645
  init_cjs_shims();
609
646
  import_zod = require("zod");
647
+ init_version();
610
648
  AgentGateInputSchema = import_zod.z.object({
611
649
  agent_type: import_zod.z.string().describe("Agent identifier, e.g. opendesk, claude-code"),
612
650
  agent_version: import_zod.z.string().default("0.1.0"),
@@ -652,7 +690,9 @@ var init_models = __esm({
652
690
  });
653
691
  HealthResponseSchema = import_zod.z.object({
654
692
  status: import_zod.z.string().default("healthy"),
655
- version: import_zod.z.string().default("0.2.2")
693
+ version: import_zod.z.string().default(version),
694
+ moss_version: import_zod.z.string().default("N/A"),
695
+ moss_status: import_zod.z.string().default("unknown")
656
696
  });
657
697
  }
658
698
  });
@@ -813,8 +853,8 @@ var init_cache = __esm({
813
853
  function store() {
814
854
  return createStorage();
815
855
  }
816
- function getOrCreateAgent(agentType, hostname, version2) {
817
- return store().getOrCreateAgent(agentType, hostname, version2);
856
+ function getOrCreateAgent(agentType, hostname, version3) {
857
+ return store().getOrCreateAgent(agentType, hostname, version3);
818
858
  }
819
859
  function getOrCreateSession(sessionId, agentId, cwd, prompt, osType) {
820
860
  store().getOrCreateSession(sessionId, agentId, cwd, prompt, osType);
@@ -844,7 +884,13 @@ var init_repository = __esm({
844
884
 
845
885
  // src/v1/routes.ts
846
886
  async function healthRoute(c) {
847
- return c.json(HealthResponseSchema.parse({}));
887
+ const mossHealth = await fetchMossHealth();
888
+ return c.json({
889
+ status: "healthy",
890
+ version,
891
+ moss_version: mossHealth.moss_version,
892
+ moss_status: mossHealth.moss_status
893
+ });
848
894
  }
849
895
  async function analyzeRoute(c) {
850
896
  const t0 = performance.now();
@@ -940,6 +986,7 @@ var init_routes = __esm({
940
986
  init_moss_client();
941
987
  init_cache();
942
988
  init_repository();
989
+ init_version();
943
990
  }
944
991
  });
945
992
 
@@ -6344,7 +6391,7 @@ var require_websocket_server = __commonJS({
6344
6391
  socket.on("error", socketOnError);
6345
6392
  const key = req.headers["sec-websocket-key"];
6346
6393
  const upgrade = req.headers.upgrade;
6347
- const version2 = +req.headers["sec-websocket-version"];
6394
+ const version3 = +req.headers["sec-websocket-version"];
6348
6395
  if (req.method !== "GET") {
6349
6396
  const message = "Invalid HTTP method";
6350
6397
  abortHandshakeOrEmitwsClientError(this, req, socket, 405, message);
@@ -6360,7 +6407,7 @@ var require_websocket_server = __commonJS({
6360
6407
  abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
6361
6408
  return;
6362
6409
  }
6363
- if (version2 !== 13 && version2 !== 8) {
6410
+ if (version3 !== 13 && version3 !== 8) {
6364
6411
  const message = "Missing or invalid Sec-WebSocket-Version header";
6365
6412
  abortHandshakeOrEmitwsClientError(this, req, socket, 400, message, {
6366
6413
  "Sec-WebSocket-Version": "13, 8"
@@ -6404,7 +6451,7 @@ var require_websocket_server = __commonJS({
6404
6451
  }
6405
6452
  if (this.options.verifyClient) {
6406
6453
  const info = {
6407
- origin: req.headers[`${version2 === 8 ? "sec-websocket-origin" : "origin"}`],
6454
+ origin: req.headers[`${version3 === 8 ? "sec-websocket-origin" : "origin"}`],
6408
6455
  secure: !!(req.socket.authorized || req.socket.encrypted),
6409
6456
  req
6410
6457
  };
@@ -19768,14 +19815,14 @@ var require_tls = __commonJS({
19768
19815
  c.version = c.session.version = session.version;
19769
19816
  c.session.sp = session.sp;
19770
19817
  } else {
19771
- var version2;
19818
+ var version3;
19772
19819
  for (var i = 1; i < tls.SupportedVersions.length; ++i) {
19773
- version2 = tls.SupportedVersions[i];
19774
- if (version2.minor <= msg.version.minor) {
19820
+ version3 = tls.SupportedVersions[i];
19821
+ if (version3.minor <= msg.version.minor) {
19775
19822
  break;
19776
19823
  }
19777
19824
  }
19778
- c.version = { major: version2.major, minor: version2.minor };
19825
+ c.version = { major: version3.major, minor: version3.minor };
19779
19826
  c.session.version = c.version;
19780
19827
  }
19781
19828
  if (session !== null) {
@@ -19946,8 +19993,8 @@ var require_tls = __commonJS({
19946
19993
  try {
19947
19994
  var sp = c.session.sp;
19948
19995
  sp.pre_master_secret = privateKey.decrypt(msg.enc_pre_master_secret);
19949
- var version2 = c.session.clientHelloVersion;
19950
- if (version2.major !== sp.pre_master_secret.charCodeAt(0) || version2.minor !== sp.pre_master_secret.charCodeAt(1)) {
19996
+ var version3 = c.session.clientHelloVersion;
19997
+ if (version3.major !== sp.pre_master_secret.charCodeAt(0) || version3.minor !== sp.pre_master_secret.charCodeAt(1)) {
19951
19998
  throw new Error("TLS version rollback attack detected.");
19952
19999
  }
19953
20000
  } catch (ex) {
@@ -24763,8 +24810,8 @@ var require_use_native = __commonJS({
24763
24810
  "use strict";
24764
24811
  init_cjs_shims();
24765
24812
  var fs2 = require("fs");
24766
- var version2 = process.env.__TESTING_MKDIRP_NODE_VERSION__ || process.version;
24767
- var versArr = version2.replace(/^v/, "").split(".");
24813
+ var version3 = process.env.__TESTING_MKDIRP_NODE_VERSION__ || process.version;
24814
+ var versArr = version3.replace(/^v/, "").split(".");
24768
24815
  var hasNative = +versArr[0] > 10 || +versArr[0] === 10 && +versArr[1] >= 12;
24769
24816
  var useNative = !hasNative ? () => false : (opts) => opts.mkdir === fs2.mkdir;
24770
24817
  var useNativeSync = !hasNative ? () => false : (opts) => opts.mkdirSync === fs2.mkdirSync;
@@ -25366,7 +25413,7 @@ function stringToBytes(str) {
25366
25413
  }
25367
25414
  return bytes;
25368
25415
  }
25369
- function v35(name, version2, hashfunc) {
25416
+ function v35(name, version3, hashfunc) {
25370
25417
  function generateUUID(value, namespace, buf, offset) {
25371
25418
  var _namespace;
25372
25419
  if (typeof value === "string") {
@@ -25382,7 +25429,7 @@ function v35(name, version2, hashfunc) {
25382
25429
  bytes.set(namespace);
25383
25430
  bytes.set(value, namespace.length);
25384
25431
  bytes = hashfunc(bytes);
25385
- bytes[6] = bytes[6] & 15 | version2;
25432
+ bytes[6] = bytes[6] & 15 | version3;
25386
25433
  bytes[8] = bytes[8] & 63 | 128;
25387
25434
  if (buf) {
25388
25435
  offset = offset || 0;
@@ -25531,19 +25578,19 @@ var init_nil = __esm({
25531
25578
  });
25532
25579
 
25533
25580
  // ../node_modules/uuid/dist/esm-node/version.js
25534
- function version(uuid) {
25581
+ function version2(uuid) {
25535
25582
  if (!validate_default(uuid)) {
25536
25583
  throw TypeError("Invalid UUID");
25537
25584
  }
25538
25585
  return parseInt(uuid.slice(14, 15), 16);
25539
25586
  }
25540
25587
  var version_default;
25541
- var init_version = __esm({
25588
+ var init_version2 = __esm({
25542
25589
  "../node_modules/uuid/dist/esm-node/version.js"() {
25543
25590
  "use strict";
25544
25591
  init_cjs_shims();
25545
25592
  init_validate();
25546
- version_default = version;
25593
+ version_default = version2;
25547
25594
  }
25548
25595
  });
25549
25596
 
@@ -25569,7 +25616,7 @@ var init_esm_node = __esm({
25569
25616
  init_v4();
25570
25617
  init_v5();
25571
25618
  init_nil();
25572
- init_version();
25619
+ init_version2();
25573
25620
  init_validate();
25574
25621
  init_stringify();
25575
25622
  init_parse();
@@ -29353,11 +29400,12 @@ var init_launcher = __esm({
29353
29400
  init_cjs_shims();
29354
29401
  var import_node_fs4 = require("fs");
29355
29402
  var import_yaml3 = require("yaml");
29403
+ init_version();
29356
29404
  async function main() {
29357
29405
  const args = process.argv.slice(2);
29358
29406
  const command = args[0];
29359
29407
  if (!command || command === "--help" || command === "-h") {
29360
- console.log(`AgentGate - AI Agent Data Collection & Security Analysis Gateway (TS v0.5.0)
29408
+ console.log(`AgentGate - AI Agent Data Collection & Security Analysis Gateway (TS v${version})
29361
29409
 
29362
29410
  Commands:
29363
29411
  start Start AgentGate with specified layers (unified)