@kenhkl/agent-gate 0.9.2 → 0.9.4

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/v3/cli.js CHANGED
@@ -50,7 +50,7 @@ var init_version = __esm({
50
50
  "src/version.ts"() {
51
51
  "use strict";
52
52
  init_cjs_shims();
53
- _version = true ? "0.9.2" : (() => {
53
+ _version = true ? "0.9.4" : (() => {
54
54
  try {
55
55
  const require2 = createRequire(importMetaUrl);
56
56
  const pkg = require2("../package.json");
@@ -199,8 +199,8 @@ function readFdToken() {
199
199
  if (!raw) return "";
200
200
  const fd = parseInt(raw, 10);
201
201
  if (!Number.isFinite(fd)) return "";
202
- const cached = fdTokenCache.get(fd);
203
- if (cached !== void 0) return cached;
202
+ const cached2 = fdTokenCache.get(fd);
203
+ if (cached2 !== void 0) return cached2;
204
204
  try {
205
205
  const buf = Buffer.alloc(8192);
206
206
  const n = (0, import_node_fs.readSync)(fd, buf, 0, buf.length, null);
@@ -442,7 +442,7 @@ function agentInflight() {
442
442
  return envInt("AGENT_GATE_MAX_AGENT_INFLIGHT", 8);
443
443
  }
444
444
  function bump(kind, key, windowSec, extra) {
445
- const now = Date.now() / 1e3;
445
+ const now = performance.now() / 1e3;
446
446
  const k = `${kind}|${key}`;
447
447
  let b = counters.get(k);
448
448
  if (!b || now - b.start >= windowSec) {
@@ -509,7 +509,7 @@ function mossTokenPath() {
509
509
  return (0, import_node_path.join)(home, ".config", "agentmoss", "auth_token");
510
510
  }
511
511
  function resolveMossToken(force = false) {
512
- const now = Date.now() / 1e3;
512
+ const now = performance.now() / 1e3;
513
513
  if (!force && mossTokenCache.expires > now) return mossTokenCache.value;
514
514
  let tok = env("AGENT_GATE_MOSS_TOKEN");
515
515
  if (!tok) tok = env("AGENT_MOSS_AUTH_TOKEN");
@@ -594,7 +594,7 @@ var init_security = __esm({
594
594
  return this.qps > 0;
595
595
  }
596
596
  allow(key) {
597
- const now = Date.now() / 1e3;
597
+ const now = performance.now() / 1e3;
598
598
  const cur = this.buckets.get(key) ?? { tokens: this.burst, last: now };
599
599
  const tokens = Math.min(this.burst, cur.tokens + (now - cur.last) * this.qps);
600
600
  if (tokens < 1) {
@@ -1028,15 +1028,15 @@ var init_json_storage = __esm({
1028
1028
  const archiveCount = total - keep;
1029
1029
  const toArchive = flat.slice(0, archiveCount);
1030
1030
  const archiveIds = new Set(toArchive.map((x) => String(x.rec.id)));
1031
- const { mkdirSync: mkdirSync5, writeFileSync: writeFileSync4 } = require("fs");
1032
- const { join: join12 } = require("path");
1031
+ const { mkdirSync: mkdirSync6, writeFileSync: writeFileSync5 } = require("fs");
1032
+ const { join: join13 } = require("path");
1033
1033
  const { gzipSync } = require("zlib");
1034
- const archiveDir = join12(this.dataDir, "archive");
1035
- if (!(0, import_fs2.existsSync)(archiveDir)) mkdirSync5(archiveDir, { recursive: true, mode: 448 });
1034
+ const archiveDir = join13(this.dataDir, "archive");
1035
+ if (!(0, import_fs2.existsSync)(archiveDir)) mkdirSync6(archiveDir, { recursive: true, mode: 448 });
1036
1036
  const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
1037
- const file = join12(archiveDir, `tool_calls-${stamp}.jsonl.gz`);
1037
+ const file = join13(archiveDir, `tool_calls-${stamp}.jsonl.gz`);
1038
1038
  const payload = toArchive.map((x) => JSON.stringify(x.rec)).join("\n") + "\n";
1039
- writeFileSync4(file, gzipSync(Buffer.from(payload, "utf-8")), { mode: 384 });
1039
+ writeFileSync5(file, gzipSync(Buffer.from(payload, "utf-8")), { mode: 384 });
1040
1040
  for (const [sid, recs] of bySession) {
1041
1041
  const remain = recs.filter((r) => !archiveIds.has(String(r.id)));
1042
1042
  if (remain.length !== recs.length) this.saveToolCalls(sid, remain);
@@ -1357,11 +1357,11 @@ CREATE INDEX IF NOT EXISTS idx_tool_calls_decision ON tool_calls(decision, calle
1357
1357
  const row = this.db.prepare("SELECT COUNT(*) as total FROM tool_calls").get();
1358
1358
  let dbBytes = 0;
1359
1359
  try {
1360
- const { statSync: statSync10, existsSync: existsSync12 } = require("fs");
1360
+ const { statSync: statSync10, existsSync: existsSync13 } = require("fs");
1361
1361
  dbBytes = statSync10(this.dbPath).size;
1362
1362
  for (const suffix of ["-wal", "-shm"]) {
1363
1363
  const p = this.dbPath + suffix;
1364
- if (existsSync12(p)) dbBytes += statSync10(p).size;
1364
+ if (existsSync13(p)) dbBytes += statSync10(p).size;
1365
1365
  }
1366
1366
  } catch {
1367
1367
  }
@@ -1394,15 +1394,15 @@ CREATE INDEX IF NOT EXISTS idx_tool_calls_decision ON tool_calls(decision, calle
1394
1394
  "SELECT * FROM tool_calls WHERE id <= ? ORDER BY id"
1395
1395
  ).all(cutoff.id);
1396
1396
  if (rows.length === 0) return { archived: 0, file: "" };
1397
- const { writeFileSync: writeFileSync4, mkdirSync: mkdirSync5, existsSync: existsSync12 } = require("fs");
1398
- const { dirname: dirname6, join: join12 } = require("path");
1397
+ const { writeFileSync: writeFileSync5, mkdirSync: mkdirSync6, existsSync: existsSync13 } = require("fs");
1398
+ const { dirname: dirname7, join: join13 } = require("path");
1399
1399
  const { gzipSync } = require("zlib");
1400
- const archiveDir = join12(dirname6(this.dbPath), "archive");
1401
- if (!existsSync12(archiveDir)) mkdirSync5(archiveDir, { recursive: true, mode: 448 });
1400
+ const archiveDir = join13(dirname7(this.dbPath), "archive");
1401
+ if (!existsSync13(archiveDir)) mkdirSync6(archiveDir, { recursive: true, mode: 448 });
1402
1402
  const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
1403
- const file = join12(archiveDir, `tool_calls-${stamp}.jsonl.gz`);
1403
+ const file = join13(archiveDir, `tool_calls-${stamp}.jsonl.gz`);
1404
1404
  const payload = rows.map((r) => JSON.stringify(r)).join("\n") + "\n";
1405
- writeFileSync4(file, gzipSync(Buffer.from(payload, "utf-8")), { mode: 384 });
1405
+ writeFileSync5(file, gzipSync(Buffer.from(payload, "utf-8")), { mode: 384 });
1406
1406
  const deleted = this.db.transaction(() => {
1407
1407
  const res = this.db.prepare("DELETE FROM tool_calls WHERE id <= ?").run(cutoff.id);
1408
1408
  this.db.prepare(`
@@ -1508,14 +1508,14 @@ function getDb(dbPath) {
1508
1508
  if (rawDb) return rawDb;
1509
1509
  try {
1510
1510
  const Database = require("better-sqlite3");
1511
- const { existsSync: existsSync12, mkdirSync: mkdirSync5 } = require("fs");
1512
- const { join: join12, dirname: dirname6 } = require("path");
1511
+ const { existsSync: existsSync13, mkdirSync: mkdirSync6 } = require("fs");
1512
+ const { join: join13, dirname: dirname7 } = require("path");
1513
1513
  const home = process.env.HOME || process.env.USERPROFILE || "/tmp";
1514
- const xdgData = process.env.XDG_DATA_HOME || join12(home, ".local", "share");
1515
- const defaultPath = join12(xdgData, "agent_gate", "agent_gate_ts.db");
1514
+ const xdgData = process.env.XDG_DATA_HOME || join13(home, ".local", "share");
1515
+ const defaultPath = join13(xdgData, "agent_gate", "agent_gate_ts.db");
1516
1516
  const path11 = dbPath || defaultPath;
1517
- const dir2 = dirname6(path11);
1518
- if (!existsSync12(dir2)) mkdirSync5(dir2, { recursive: true });
1517
+ const dir2 = dirname7(path11);
1518
+ if (!existsSync13(dir2)) mkdirSync6(dir2, { recursive: true });
1519
1519
  rawDb = new Database(path11);
1520
1520
  rawDb.pragma("journal_mode = WAL");
1521
1521
  return rawDb;
@@ -1558,6 +1558,46 @@ var init_db = __esm({
1558
1558
  }
1559
1559
  });
1560
1560
 
1561
+ // src/shared/instance-id.ts
1562
+ function getInstanceId() {
1563
+ if (cached) return cached;
1564
+ const env2 = (process.env.AGENT_GATE_INSTANCE_ID || "").trim();
1565
+ if (env2) {
1566
+ cached = env2;
1567
+ return cached;
1568
+ }
1569
+ const filePath = process.env.AGENT_GATE_INSTANCE_ID_PATH || (0, import_path4.join)((0, import_os.homedir)(), ".config", "agentgate", "instance_id");
1570
+ try {
1571
+ if ((0, import_fs4.existsSync)(filePath)) {
1572
+ const v2 = (0, import_fs4.readFileSync)(filePath, "utf-8").trim();
1573
+ if (v2) {
1574
+ cached = v2;
1575
+ return cached;
1576
+ }
1577
+ }
1578
+ const v = (0, import_crypto2.randomUUID)();
1579
+ (0, import_fs4.mkdirSync)((0, import_path4.dirname)(filePath), { recursive: true });
1580
+ (0, import_fs4.writeFileSync)(filePath, v + "\n", { mode: 384 });
1581
+ cached = v;
1582
+ return cached;
1583
+ } catch {
1584
+ cached = `ephemeral-${(0, import_crypto2.randomUUID)()}`;
1585
+ return cached;
1586
+ }
1587
+ }
1588
+ var import_fs4, import_os, import_path4, import_crypto2, cached;
1589
+ var init_instance_id = __esm({
1590
+ "src/shared/instance-id.ts"() {
1591
+ "use strict";
1592
+ init_cjs_shims();
1593
+ import_fs4 = require("fs");
1594
+ import_os = require("os");
1595
+ import_path4 = require("path");
1596
+ import_crypto2 = require("crypto");
1597
+ cached = "";
1598
+ }
1599
+ });
1600
+
1561
1601
  // src/shared/multi-session.ts
1562
1602
  function isMultiSessionEnabled() {
1563
1603
  const raw = (process.env.AGENT_GATE_MULTI_SESSION ?? "").trim().toLowerCase();
@@ -1604,6 +1644,9 @@ function buildSessionHistory(queryToolCalls2, sessionId, listAgentTypes) {
1604
1644
  return [...bySession.entries()].slice(0, maxSessions).map(([sid, actions]) => ({
1605
1645
  session_id: sid,
1606
1646
  ...sessionAgent.get(sid) ? { agent_id: sessionAgent.get(sid) } : {},
1647
+ // AgentGate 自己的存储属于本安装实例;带上实例 ID 让 AgentMoss 在
1648
+ // 展示层按「同实例不隐藏」处理(否则用户自己的历史会话也会被脱敏)。
1649
+ instance_id: getInstanceId(),
1607
1650
  action_history: actions.slice(0, DEFAULT_ACTIONS_PER_SESSION)
1608
1651
  }));
1609
1652
  } catch {
@@ -1618,6 +1661,7 @@ var init_multi_session = __esm({
1618
1661
  "src/shared/multi-session.ts"() {
1619
1662
  "use strict";
1620
1663
  init_cjs_shims();
1664
+ init_instance_id();
1621
1665
  DEFAULT_HISTORY_LIMIT = 500;
1622
1666
  DEFAULT_MAX_SESSIONS = 5;
1623
1667
  DEFAULT_ACTIONS_PER_SESSION = 100;
@@ -1751,6 +1795,8 @@ var init_models = __esm({
1751
1795
  agent_type: import_zod.z.string().describe("Agent identifier, e.g. opendesk, claude-code"),
1752
1796
  agent_version: import_zod.z.string().default("0.1.0"),
1753
1797
  session_id: import_zod.z.string().describe("Session unique identifier"),
1798
+ /** 安装级实例 ID(仅展示层脱敏用;缺省由 AgentGate 自动生成)。 */
1799
+ instance_id: import_zod.z.string().optional(),
1754
1800
  tool_name: import_zod.z.string().optional().describe("Tool name, e.g. bash, file_write"),
1755
1801
  command: import_zod.z.string().optional().describe("Tool command or description"),
1756
1802
  a_next: import_zod.z.object({
@@ -1867,6 +1913,8 @@ function normalize(input, systemContext) {
1867
1913
  // 历史上只在 metadata.agent_type 里带,AgentMoss 读顶层 req.agent_id → 空 →
1868
1914
  // 定制规则从未生效(OpenDesk memory-* 操作走 L3 耗时 1~137s)。
1869
1915
  agent_id: input.agent_type || "",
1916
+ // 实例 ID:仅用于 AgentMoss 展示层脱敏(同实例不隐藏),不参与判定。
1917
+ instance_id: input.instance_id || getInstanceId(),
1870
1918
  metadata: {
1871
1919
  ...input.metadata,
1872
1920
  agent_type: input.agent_type,
@@ -1885,6 +1933,7 @@ var init_normalizer = __esm({
1885
1933
  "use strict";
1886
1934
  init_cjs_shims();
1887
1935
  init_multi_session();
1936
+ init_instance_id();
1888
1937
  }
1889
1938
  });
1890
1939
 
@@ -1893,22 +1942,22 @@ async function collectSystemInfo() {
1893
1942
  try {
1894
1943
  return {
1895
1944
  system: process.platform,
1896
- distribution: `${import_os.default.type()} ${import_os.default.release()}`,
1897
- hostname: import_os.default.hostname(),
1898
- arch: import_os.default.arch(),
1899
- cpu_count: import_os.default.cpus().length,
1900
- memory_total_mb: Math.round(import_os.default.totalmem() / (1024 * 1024))
1945
+ distribution: `${import_os2.default.type()} ${import_os2.default.release()}`,
1946
+ hostname: import_os2.default.hostname(),
1947
+ arch: import_os2.default.arch(),
1948
+ cpu_count: import_os2.default.cpus().length,
1949
+ memory_total_mb: Math.round(import_os2.default.totalmem() / (1024 * 1024))
1901
1950
  };
1902
1951
  } catch {
1903
1952
  return { system: "unknown" };
1904
1953
  }
1905
1954
  }
1906
- var import_os;
1955
+ var import_os2;
1907
1956
  var init_system_info = __esm({
1908
1957
  "src/shared/collector/system-info.ts"() {
1909
1958
  "use strict";
1910
1959
  init_cjs_shims();
1911
- import_os = __toESM(require("os"));
1960
+ import_os2 = __toESM(require("os"));
1912
1961
  }
1913
1962
  });
1914
1963
 
@@ -1935,7 +1984,7 @@ var init_process_info = __esm({
1935
1984
  // src/shared/collector/user-info.ts
1936
1985
  async function collectUserInfo() {
1937
1986
  try {
1938
- const userInfo = import_os2.default.userInfo();
1987
+ const userInfo = import_os3.default.userInfo();
1939
1988
  return {
1940
1989
  uid: userInfo.uid,
1941
1990
  gid: userInfo.gid,
@@ -1946,12 +1995,12 @@ async function collectUserInfo() {
1946
1995
  return { uid: -1 };
1947
1996
  }
1948
1997
  }
1949
- var import_os2;
1998
+ var import_os3;
1950
1999
  var init_user_info = __esm({
1951
2000
  "src/shared/collector/user-info.ts"() {
1952
2001
  "use strict";
1953
2002
  init_cjs_shims();
1954
- import_os2 = __toESM(require("os"));
2003
+ import_os3 = __toESM(require("os"));
1955
2004
  }
1956
2005
  });
1957
2006
 
@@ -2098,10 +2147,10 @@ async function analyzeRoute(c) {
2098
2147
  const toolName = input.tool_name || input.a_next?.action_type || "unknown";
2099
2148
  const command = input.command || input.a_next?.action_detail || "";
2100
2149
  const key = cacheKey(input.session_id, input.cwd, command);
2101
- const cached = getCached(key);
2102
- if (cached) {
2150
+ const cached2 = getCached(key);
2151
+ if (cached2) {
2103
2152
  return c.json({
2104
- ...cached,
2153
+ ...cached2,
2105
2154
  analysis_duration_ms: 0,
2106
2155
  collected_context: {},
2107
2156
  ...storageOversizeInfo()
@@ -2403,17 +2452,17 @@ async function dashboardRoute(c) {
2403
2452
  return c.html(UNAUTHORIZED_HTML, 401, DASHBOARD_SECURITY_HEADERS);
2404
2453
  }
2405
2454
  }
2406
- const { readFileSync: readFileSync14, existsSync: existsSync12 } = await import("fs");
2407
- const { resolve: resolve4, dirname: dirname6 } = await import("path");
2455
+ const { readFileSync: readFileSync15, existsSync: existsSync13 } = await import("fs");
2456
+ const { resolve: resolve4, dirname: dirname7 } = await import("path");
2408
2457
  const { fileURLToPath } = await import("url");
2409
- const __dirname2 = dirname6(fileURLToPath(importMetaUrl));
2458
+ const __dirname2 = dirname7(fileURLToPath(importMetaUrl));
2410
2459
  const paths = [
2411
2460
  resolve4(__dirname2, "dashboard.html"),
2412
2461
  resolve4(__dirname2, "../dashboard.html"),
2413
2462
  resolve4(__dirname2, "../src/v1/dashboard.html")
2414
2463
  ];
2415
- const htmlPath = paths.find((p) => existsSync12(p)) || paths[0];
2416
- const html = readFileSync14(htmlPath, "utf-8");
2464
+ const htmlPath = paths.find((p) => existsSync13(p)) || paths[0];
2465
+ const html = readFileSync15(htmlPath, "utf-8");
2417
2466
  return c.html(html, 200, DASHBOARD_SECURITY_HEADERS);
2418
2467
  }
2419
2468
  var import_hono, import_cors, import_logger, import_cookie, PUBLIC_PAGE_PATHS, UNAUTHORIZED_HTML, AGENT_FORBIDDEN_HTML;
@@ -26105,14 +26154,14 @@ var require_find_made = __commonJS({
26105
26154
  "../node_modules/mkdirp/lib/find-made.js"(exports2, module2) {
26106
26155
  "use strict";
26107
26156
  init_cjs_shims();
26108
- var { dirname: dirname6 } = require("path");
26157
+ var { dirname: dirname7 } = require("path");
26109
26158
  var findMade = (opts, parent2, path11 = void 0) => {
26110
26159
  if (path11 === parent2)
26111
26160
  return Promise.resolve();
26112
26161
  return opts.statAsync(parent2).then(
26113
26162
  (st) => st.isDirectory() ? path11 : void 0,
26114
26163
  // will fail later
26115
- (er) => er.code === "ENOENT" ? findMade(opts, dirname6(parent2), parent2) : void 0
26164
+ (er) => er.code === "ENOENT" ? findMade(opts, dirname7(parent2), parent2) : void 0
26116
26165
  );
26117
26166
  };
26118
26167
  var findMadeSync = (opts, parent2, path11 = void 0) => {
@@ -26121,7 +26170,7 @@ var require_find_made = __commonJS({
26121
26170
  try {
26122
26171
  return opts.statSync(parent2).isDirectory() ? path11 : void 0;
26123
26172
  } catch (er) {
26124
- return er.code === "ENOENT" ? findMadeSync(opts, dirname6(parent2), parent2) : void 0;
26173
+ return er.code === "ENOENT" ? findMadeSync(opts, dirname7(parent2), parent2) : void 0;
26125
26174
  }
26126
26175
  };
26127
26176
  module2.exports = { findMade, findMadeSync };
@@ -26133,10 +26182,10 @@ var require_mkdirp_manual = __commonJS({
26133
26182
  "../node_modules/mkdirp/lib/mkdirp-manual.js"(exports2, module2) {
26134
26183
  "use strict";
26135
26184
  init_cjs_shims();
26136
- var { dirname: dirname6 } = require("path");
26185
+ var { dirname: dirname7 } = require("path");
26137
26186
  var mkdirpManual = (path11, opts, made) => {
26138
26187
  opts.recursive = false;
26139
- const parent2 = dirname6(path11);
26188
+ const parent2 = dirname7(path11);
26140
26189
  if (parent2 === path11) {
26141
26190
  return opts.mkdirAsync(path11, opts).catch((er) => {
26142
26191
  if (er.code !== "EISDIR")
@@ -26159,7 +26208,7 @@ var require_mkdirp_manual = __commonJS({
26159
26208
  });
26160
26209
  };
26161
26210
  var mkdirpManualSync = (path11, opts, made) => {
26162
- const parent2 = dirname6(path11);
26211
+ const parent2 = dirname7(path11);
26163
26212
  opts.recursive = false;
26164
26213
  if (parent2 === path11) {
26165
26214
  try {
@@ -26196,12 +26245,12 @@ var require_mkdirp_native = __commonJS({
26196
26245
  "../node_modules/mkdirp/lib/mkdirp-native.js"(exports2, module2) {
26197
26246
  "use strict";
26198
26247
  init_cjs_shims();
26199
- var { dirname: dirname6 } = require("path");
26248
+ var { dirname: dirname7 } = require("path");
26200
26249
  var { findMade, findMadeSync } = require_find_made();
26201
26250
  var { mkdirpManual, mkdirpManualSync } = require_mkdirp_manual();
26202
26251
  var mkdirpNative = (path11, opts) => {
26203
26252
  opts.recursive = true;
26204
- const parent2 = dirname6(path11);
26253
+ const parent2 = dirname7(path11);
26205
26254
  if (parent2 === path11)
26206
26255
  return opts.mkdirAsync(path11, opts);
26207
26256
  return findMade(opts, path11).then((made) => opts.mkdirAsync(path11, opts).then(() => made).catch((er) => {
@@ -26213,7 +26262,7 @@ var require_mkdirp_native = __commonJS({
26213
26262
  };
26214
26263
  var mkdirpNativeSync = (path11, opts) => {
26215
26264
  opts.recursive = true;
26216
- const parent2 = dirname6(path11);
26265
+ const parent2 = dirname7(path11);
26217
26266
  if (parent2 === path11)
26218
26267
  return opts.mkdirSync(path11, opts);
26219
26268
  const made = findMadeSync(opts, path11);
@@ -26669,17 +26718,17 @@ var require_ProxyFinalRequestFilter = __commonJS({
26669
26718
  // ../node_modules/uuid/dist/esm-node/rng.js
26670
26719
  function rng() {
26671
26720
  if (poolPtr > rnds8Pool.length - 16) {
26672
- import_crypto2.default.randomFillSync(rnds8Pool);
26721
+ import_crypto3.default.randomFillSync(rnds8Pool);
26673
26722
  poolPtr = 0;
26674
26723
  }
26675
26724
  return rnds8Pool.slice(poolPtr, poolPtr += 16);
26676
26725
  }
26677
- var import_crypto2, rnds8Pool, poolPtr;
26726
+ var import_crypto3, rnds8Pool, poolPtr;
26678
26727
  var init_rng = __esm({
26679
26728
  "../node_modules/uuid/dist/esm-node/rng.js"() {
26680
26729
  "use strict";
26681
26730
  init_cjs_shims();
26682
- import_crypto2 = __toESM(require("crypto"));
26731
+ import_crypto3 = __toESM(require("crypto"));
26683
26732
  rnds8Pool = new Uint8Array(256);
26684
26733
  poolPtr = rnds8Pool.length;
26685
26734
  }
@@ -26894,14 +26943,14 @@ function md5(bytes) {
26894
26943
  } else if (typeof bytes === "string") {
26895
26944
  bytes = Buffer.from(bytes, "utf8");
26896
26945
  }
26897
- return import_crypto3.default.createHash("md5").update(bytes).digest();
26946
+ return import_crypto4.default.createHash("md5").update(bytes).digest();
26898
26947
  }
26899
- var import_crypto3, md5_default;
26948
+ var import_crypto4, md5_default;
26900
26949
  var init_md5 = __esm({
26901
26950
  "../node_modules/uuid/dist/esm-node/md5.js"() {
26902
26951
  "use strict";
26903
26952
  init_cjs_shims();
26904
- import_crypto3 = __toESM(require("crypto"));
26953
+ import_crypto4 = __toESM(require("crypto"));
26905
26954
  md5_default = md5;
26906
26955
  }
26907
26956
  });
@@ -26920,14 +26969,14 @@ var init_v3 = __esm({
26920
26969
  });
26921
26970
 
26922
26971
  // ../node_modules/uuid/dist/esm-node/native.js
26923
- var import_crypto4, native_default;
26972
+ var import_crypto5, native_default;
26924
26973
  var init_native = __esm({
26925
26974
  "../node_modules/uuid/dist/esm-node/native.js"() {
26926
26975
  "use strict";
26927
26976
  init_cjs_shims();
26928
- import_crypto4 = __toESM(require("crypto"));
26977
+ import_crypto5 = __toESM(require("crypto"));
26929
26978
  native_default = {
26930
- randomUUID: import_crypto4.default.randomUUID
26979
+ randomUUID: import_crypto5.default.randomUUID
26931
26980
  };
26932
26981
  }
26933
26982
  });
@@ -26969,14 +27018,14 @@ function sha1(bytes) {
26969
27018
  } else if (typeof bytes === "string") {
26970
27019
  bytes = Buffer.from(bytes, "utf8");
26971
27020
  }
26972
- return import_crypto5.default.createHash("sha1").update(bytes).digest();
27021
+ return import_crypto6.default.createHash("sha1").update(bytes).digest();
26973
27022
  }
26974
- var import_crypto5, sha1_default;
27023
+ var import_crypto6, sha1_default;
26975
27024
  var init_sha1 = __esm({
26976
27025
  "../node_modules/uuid/dist/esm-node/sha1.js"() {
26977
27026
  "use strict";
26978
27027
  init_cjs_shims();
26979
- import_crypto5 = __toESM(require("crypto"));
27028
+ import_crypto6 = __toESM(require("crypto"));
26980
27029
  sha1_default = sha1;
26981
27030
  }
26982
27031
  });
@@ -28640,10 +28689,10 @@ var init_interceptor = __esm({
28640
28689
  * @param awaitDecision when true, await AgentMoss instead of fire-and-forget.
28641
28690
  */
28642
28691
  async _processResponse(flowId, respHeaders, respBody, awaitDecision) {
28643
- const cached = this._requestCache.get(flowId);
28644
- if (!cached) return { events: [], deny: { deny: false } };
28692
+ const cached2 = this._requestCache.get(flowId);
28693
+ if (!cached2) return { events: [], deny: { deny: false } };
28645
28694
  this._requestCache.delete(flowId);
28646
- const { parser, meta, headers, url } = cached;
28695
+ const { parser, meta, headers, url } = cached2;
28647
28696
  const toolCalls = parser.parseResponse(url, respHeaders, respBody, meta);
28648
28697
  if (toolCalls.length === 0) return { events: [], deny: { deny: false } };
28649
28698
  const agentType = parser.detectAgentType(headers, meta);
@@ -29650,12 +29699,12 @@ var init_coordinator = __esm({
29650
29699
  `[PhaseCoordinator][L1]: tool=${toolName} id=${toolCallId} session=${sessionId.slice(0, 8)} level=${this.level}`
29651
29700
  );
29652
29701
  if (this.decisionCache) {
29653
- const cached = this.decisionCache.get(sessionId, "", this._eventCommand(event));
29654
- if (cached) {
29702
+ const cached2 = this.decisionCache.get(sessionId, "", this._eventCommand(event));
29703
+ if (cached2) {
29655
29704
  console.log(
29656
- `[PhaseCoordinator]: decision cache HIT (tool=${toolName}) \u2192 ${String(cached.decision ?? "Allow")}`
29705
+ `[PhaseCoordinator]: decision cache HIT (tool=${toolName}) \u2192 ${String(cached2.decision ?? "Allow")}`
29657
29706
  );
29658
- return String(cached.decision ?? "Allow");
29707
+ return String(cached2.decision ?? "Allow");
29659
29708
  }
29660
29709
  }
29661
29710
  if (this.whitelistEngine?.isWhitelisted(event)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kenhkl/agent-gate",
3
- "version": "0.9.2",
3
+ "version": "0.9.4",
4
4
  "description": "AI Agent data collection & security analysis gateway (TypeScript)",
5
5
  "main": "dist/v1/server.js",
6
6
  "bin": {