@kenhkl/agent-gate 0.9.1 → 0.9.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/dist/dashboard.html +175 -3
- package/dist/shared/storage/db.d.ts +2 -0
- package/dist/shared/storage/db.js +16 -3
- package/dist/v1/cli.js +112 -45
- package/dist/v1/server.js +160 -93
- package/dist/v3/cli.js +140 -73
- package/package.json +1 -1
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.
|
|
53
|
+
_version = true ? "0.9.3" : (() => {
|
|
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
|
|
203
|
-
if (
|
|
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);
|
|
@@ -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:
|
|
1032
|
-
const { join:
|
|
1031
|
+
const { mkdirSync: mkdirSync6, writeFileSync: writeFileSync5 } = require("fs");
|
|
1032
|
+
const { join: join13 } = require("path");
|
|
1033
1033
|
const { gzipSync } = require("zlib");
|
|
1034
|
-
const archiveDir =
|
|
1035
|
-
if (!(0, import_fs2.existsSync)(archiveDir))
|
|
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 =
|
|
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
|
-
|
|
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);
|
|
@@ -1163,6 +1163,7 @@ CREATE TABLE IF NOT EXISTS tool_calls (
|
|
|
1163
1163
|
reason TEXT DEFAULT '',
|
|
1164
1164
|
confidence INTEGER DEFAULT 0,
|
|
1165
1165
|
analysis_duration_ms REAL DEFAULT 0,
|
|
1166
|
+
violation_graph TEXT DEFAULT '{}',
|
|
1166
1167
|
called_at TEXT DEFAULT (datetime('now')),
|
|
1167
1168
|
UNIQUE(session_id, seq)
|
|
1168
1169
|
);
|
|
@@ -1189,6 +1190,17 @@ CREATE INDEX IF NOT EXISTS idx_tool_calls_decision ON tool_calls(decision, calle
|
|
|
1189
1190
|
this.db = new Database(path11);
|
|
1190
1191
|
this.db.pragma("journal_mode = WAL");
|
|
1191
1192
|
this.db.exec(SCHEMA);
|
|
1193
|
+
this.ensureColumn("tool_calls", "violation_graph", "violation_graph TEXT DEFAULT '{}'");
|
|
1194
|
+
}
|
|
1195
|
+
/** 幂等补列(旧数据库平滑升级,失败不阻断启动)。 */
|
|
1196
|
+
ensureColumn(table, column, ddl) {
|
|
1197
|
+
try {
|
|
1198
|
+
const cols = this.db.prepare(`PRAGMA table_info(${table})`).all();
|
|
1199
|
+
if (!cols.some((c) => c.name === column)) {
|
|
1200
|
+
this.db.exec(`ALTER TABLE ${table} ADD COLUMN ${ddl}`);
|
|
1201
|
+
}
|
|
1202
|
+
} catch {
|
|
1203
|
+
}
|
|
1192
1204
|
}
|
|
1193
1205
|
static isAvailable() {
|
|
1194
1206
|
try {
|
|
@@ -1230,8 +1242,8 @@ CREATE INDEX IF NOT EXISTS idx_tool_calls_decision ON tool_calls(decision, calle
|
|
|
1230
1242
|
return this.db.prepare(`
|
|
1231
1243
|
INSERT INTO tool_calls (session_id, seq, tool_name, command, description, cwd,
|
|
1232
1244
|
action_type, action_detail, decision, risk_level, risk_type, violated_layers,
|
|
1233
|
-
reason, confidence, analysis_duration_ms)
|
|
1234
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
1245
|
+
reason, confidence, analysis_duration_ms, violation_graph)
|
|
1246
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
1235
1247
|
`).run(
|
|
1236
1248
|
rec.session_id,
|
|
1237
1249
|
seq2,
|
|
@@ -1247,7 +1259,8 @@ CREATE INDEX IF NOT EXISTS idx_tool_calls_decision ON tool_calls(decision, calle
|
|
|
1247
1259
|
rec.violated_layers,
|
|
1248
1260
|
rec.reason,
|
|
1249
1261
|
rec.confidence,
|
|
1250
|
-
rec.analysis_duration_ms
|
|
1262
|
+
rec.analysis_duration_ms,
|
|
1263
|
+
rec.violation_graph || "{}"
|
|
1251
1264
|
);
|
|
1252
1265
|
})(record);
|
|
1253
1266
|
return Number(result.lastInsertRowid);
|
|
@@ -1344,11 +1357,11 @@ CREATE INDEX IF NOT EXISTS idx_tool_calls_decision ON tool_calls(decision, calle
|
|
|
1344
1357
|
const row = this.db.prepare("SELECT COUNT(*) as total FROM tool_calls").get();
|
|
1345
1358
|
let dbBytes = 0;
|
|
1346
1359
|
try {
|
|
1347
|
-
const { statSync: statSync10, existsSync:
|
|
1360
|
+
const { statSync: statSync10, existsSync: existsSync13 } = require("fs");
|
|
1348
1361
|
dbBytes = statSync10(this.dbPath).size;
|
|
1349
1362
|
for (const suffix of ["-wal", "-shm"]) {
|
|
1350
1363
|
const p = this.dbPath + suffix;
|
|
1351
|
-
if (
|
|
1364
|
+
if (existsSync13(p)) dbBytes += statSync10(p).size;
|
|
1352
1365
|
}
|
|
1353
1366
|
} catch {
|
|
1354
1367
|
}
|
|
@@ -1381,15 +1394,15 @@ CREATE INDEX IF NOT EXISTS idx_tool_calls_decision ON tool_calls(decision, calle
|
|
|
1381
1394
|
"SELECT * FROM tool_calls WHERE id <= ? ORDER BY id"
|
|
1382
1395
|
).all(cutoff.id);
|
|
1383
1396
|
if (rows.length === 0) return { archived: 0, file: "" };
|
|
1384
|
-
const { writeFileSync:
|
|
1385
|
-
const { dirname:
|
|
1397
|
+
const { writeFileSync: writeFileSync5, mkdirSync: mkdirSync6, existsSync: existsSync13 } = require("fs");
|
|
1398
|
+
const { dirname: dirname7, join: join13 } = require("path");
|
|
1386
1399
|
const { gzipSync } = require("zlib");
|
|
1387
|
-
const archiveDir =
|
|
1388
|
-
if (!
|
|
1400
|
+
const archiveDir = join13(dirname7(this.dbPath), "archive");
|
|
1401
|
+
if (!existsSync13(archiveDir)) mkdirSync6(archiveDir, { recursive: true, mode: 448 });
|
|
1389
1402
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
1390
|
-
const file =
|
|
1403
|
+
const file = join13(archiveDir, `tool_calls-${stamp}.jsonl.gz`);
|
|
1391
1404
|
const payload = rows.map((r) => JSON.stringify(r)).join("\n") + "\n";
|
|
1392
|
-
|
|
1405
|
+
writeFileSync5(file, gzipSync(Buffer.from(payload, "utf-8")), { mode: 384 });
|
|
1393
1406
|
const deleted = this.db.transaction(() => {
|
|
1394
1407
|
const res = this.db.prepare("DELETE FROM tool_calls WHERE id <= ?").run(cutoff.id);
|
|
1395
1408
|
this.db.prepare(`
|
|
@@ -1495,14 +1508,14 @@ function getDb(dbPath) {
|
|
|
1495
1508
|
if (rawDb) return rawDb;
|
|
1496
1509
|
try {
|
|
1497
1510
|
const Database = require("better-sqlite3");
|
|
1498
|
-
const { existsSync:
|
|
1499
|
-
const { join:
|
|
1511
|
+
const { existsSync: existsSync13, mkdirSync: mkdirSync6 } = require("fs");
|
|
1512
|
+
const { join: join13, dirname: dirname7 } = require("path");
|
|
1500
1513
|
const home = process.env.HOME || process.env.USERPROFILE || "/tmp";
|
|
1501
|
-
const xdgData = process.env.XDG_DATA_HOME ||
|
|
1502
|
-
const defaultPath =
|
|
1514
|
+
const xdgData = process.env.XDG_DATA_HOME || join13(home, ".local", "share");
|
|
1515
|
+
const defaultPath = join13(xdgData, "agent_gate", "agent_gate_ts.db");
|
|
1503
1516
|
const path11 = dbPath || defaultPath;
|
|
1504
|
-
const dir2 =
|
|
1505
|
-
if (!
|
|
1517
|
+
const dir2 = dirname7(path11);
|
|
1518
|
+
if (!existsSync13(dir2)) mkdirSync6(dir2, { recursive: true });
|
|
1506
1519
|
rawDb = new Database(path11);
|
|
1507
1520
|
rawDb.pragma("journal_mode = WAL");
|
|
1508
1521
|
return rawDb;
|
|
@@ -1545,6 +1558,46 @@ var init_db = __esm({
|
|
|
1545
1558
|
}
|
|
1546
1559
|
});
|
|
1547
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
|
+
|
|
1548
1601
|
// src/shared/multi-session.ts
|
|
1549
1602
|
function isMultiSessionEnabled() {
|
|
1550
1603
|
const raw = (process.env.AGENT_GATE_MULTI_SESSION ?? "").trim().toLowerCase();
|
|
@@ -1591,6 +1644,9 @@ function buildSessionHistory(queryToolCalls2, sessionId, listAgentTypes) {
|
|
|
1591
1644
|
return [...bySession.entries()].slice(0, maxSessions).map(([sid, actions]) => ({
|
|
1592
1645
|
session_id: sid,
|
|
1593
1646
|
...sessionAgent.get(sid) ? { agent_id: sessionAgent.get(sid) } : {},
|
|
1647
|
+
// AgentGate 自己的存储属于本安装实例;带上实例 ID 让 AgentMoss 在
|
|
1648
|
+
// 展示层按「同实例不隐藏」处理(否则用户自己的历史会话也会被脱敏)。
|
|
1649
|
+
instance_id: getInstanceId(),
|
|
1594
1650
|
action_history: actions.slice(0, DEFAULT_ACTIONS_PER_SESSION)
|
|
1595
1651
|
}));
|
|
1596
1652
|
} catch {
|
|
@@ -1605,6 +1661,7 @@ var init_multi_session = __esm({
|
|
|
1605
1661
|
"src/shared/multi-session.ts"() {
|
|
1606
1662
|
"use strict";
|
|
1607
1663
|
init_cjs_shims();
|
|
1664
|
+
init_instance_id();
|
|
1608
1665
|
DEFAULT_HISTORY_LIMIT = 500;
|
|
1609
1666
|
DEFAULT_MAX_SESSIONS = 5;
|
|
1610
1667
|
DEFAULT_ACTIONS_PER_SESSION = 100;
|
|
@@ -1738,6 +1795,8 @@ var init_models = __esm({
|
|
|
1738
1795
|
agent_type: import_zod.z.string().describe("Agent identifier, e.g. opendesk, claude-code"),
|
|
1739
1796
|
agent_version: import_zod.z.string().default("0.1.0"),
|
|
1740
1797
|
session_id: import_zod.z.string().describe("Session unique identifier"),
|
|
1798
|
+
/** 安装级实例 ID(仅展示层脱敏用;缺省由 AgentGate 自动生成)。 */
|
|
1799
|
+
instance_id: import_zod.z.string().optional(),
|
|
1741
1800
|
tool_name: import_zod.z.string().optional().describe("Tool name, e.g. bash, file_write"),
|
|
1742
1801
|
command: import_zod.z.string().optional().describe("Tool command or description"),
|
|
1743
1802
|
a_next: import_zod.z.object({
|
|
@@ -1780,6 +1839,8 @@ var init_models = __esm({
|
|
|
1780
1839
|
violated_layers: import_zod.z.array(import_zod.z.string()).default([]),
|
|
1781
1840
|
confidence: import_zod.z.number().int().min(0).max(100).default(100),
|
|
1782
1841
|
analysis_duration_ms: import_zod.z.number().default(0),
|
|
1842
|
+
// 结构化攻击链图(组合式拦截时非空;前端弹窗画图用)
|
|
1843
|
+
violation_graph: import_zod.z.any().nullable().optional(),
|
|
1783
1844
|
oversize: import_zod.z.boolean().optional().describe("\u672C\u5730\u5B58\u50A8\u662F\u5426\u8D85\u8FC7\u6E05\u7406\u9608\u503C\uFF08agg \u7528\uFF09"),
|
|
1784
1845
|
thresholdMB: import_zod.z.number().optional().describe("\u5B58\u50A8\u6E05\u7406\u9608\u503C MB\uFF08agg \u7528\uFF09"),
|
|
1785
1846
|
collected_context: import_zod.z.object({
|
|
@@ -1852,6 +1913,8 @@ function normalize(input, systemContext) {
|
|
|
1852
1913
|
// 历史上只在 metadata.agent_type 里带,AgentMoss 读顶层 req.agent_id → 空 →
|
|
1853
1914
|
// 定制规则从未生效(OpenDesk memory-* 操作走 L3 耗时 1~137s)。
|
|
1854
1915
|
agent_id: input.agent_type || "",
|
|
1916
|
+
// 实例 ID:仅用于 AgentMoss 展示层脱敏(同实例不隐藏),不参与判定。
|
|
1917
|
+
instance_id: input.instance_id || getInstanceId(),
|
|
1855
1918
|
metadata: {
|
|
1856
1919
|
...input.metadata,
|
|
1857
1920
|
agent_type: input.agent_type,
|
|
@@ -1870,6 +1933,7 @@ var init_normalizer = __esm({
|
|
|
1870
1933
|
"use strict";
|
|
1871
1934
|
init_cjs_shims();
|
|
1872
1935
|
init_multi_session();
|
|
1936
|
+
init_instance_id();
|
|
1873
1937
|
}
|
|
1874
1938
|
});
|
|
1875
1939
|
|
|
@@ -1878,22 +1942,22 @@ async function collectSystemInfo() {
|
|
|
1878
1942
|
try {
|
|
1879
1943
|
return {
|
|
1880
1944
|
system: process.platform,
|
|
1881
|
-
distribution: `${
|
|
1882
|
-
hostname:
|
|
1883
|
-
arch:
|
|
1884
|
-
cpu_count:
|
|
1885
|
-
memory_total_mb: Math.round(
|
|
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))
|
|
1886
1950
|
};
|
|
1887
1951
|
} catch {
|
|
1888
1952
|
return { system: "unknown" };
|
|
1889
1953
|
}
|
|
1890
1954
|
}
|
|
1891
|
-
var
|
|
1955
|
+
var import_os2;
|
|
1892
1956
|
var init_system_info = __esm({
|
|
1893
1957
|
"src/shared/collector/system-info.ts"() {
|
|
1894
1958
|
"use strict";
|
|
1895
1959
|
init_cjs_shims();
|
|
1896
|
-
|
|
1960
|
+
import_os2 = __toESM(require("os"));
|
|
1897
1961
|
}
|
|
1898
1962
|
});
|
|
1899
1963
|
|
|
@@ -1920,7 +1984,7 @@ var init_process_info = __esm({
|
|
|
1920
1984
|
// src/shared/collector/user-info.ts
|
|
1921
1985
|
async function collectUserInfo() {
|
|
1922
1986
|
try {
|
|
1923
|
-
const userInfo =
|
|
1987
|
+
const userInfo = import_os3.default.userInfo();
|
|
1924
1988
|
return {
|
|
1925
1989
|
uid: userInfo.uid,
|
|
1926
1990
|
gid: userInfo.gid,
|
|
@@ -1931,12 +1995,12 @@ async function collectUserInfo() {
|
|
|
1931
1995
|
return { uid: -1 };
|
|
1932
1996
|
}
|
|
1933
1997
|
}
|
|
1934
|
-
var
|
|
1998
|
+
var import_os3;
|
|
1935
1999
|
var init_user_info = __esm({
|
|
1936
2000
|
"src/shared/collector/user-info.ts"() {
|
|
1937
2001
|
"use strict";
|
|
1938
2002
|
init_cjs_shims();
|
|
1939
|
-
|
|
2003
|
+
import_os3 = __toESM(require("os"));
|
|
1940
2004
|
}
|
|
1941
2005
|
});
|
|
1942
2006
|
|
|
@@ -2083,10 +2147,10 @@ async function analyzeRoute(c) {
|
|
|
2083
2147
|
const toolName = input.tool_name || input.a_next?.action_type || "unknown";
|
|
2084
2148
|
const command = input.command || input.a_next?.action_detail || "";
|
|
2085
2149
|
const key = cacheKey(input.session_id, input.cwd, command);
|
|
2086
|
-
const
|
|
2087
|
-
if (
|
|
2150
|
+
const cached2 = getCached(key);
|
|
2151
|
+
if (cached2) {
|
|
2088
2152
|
return c.json({
|
|
2089
|
-
...
|
|
2153
|
+
...cached2,
|
|
2090
2154
|
analysis_duration_ms: 0,
|
|
2091
2155
|
collected_context: {},
|
|
2092
2156
|
...storageOversizeInfo()
|
|
@@ -2124,7 +2188,9 @@ async function analyzeRoute(c) {
|
|
|
2124
2188
|
violated_layers: JSON.stringify(mossResult.violated_layers),
|
|
2125
2189
|
reason: mossResult.reason,
|
|
2126
2190
|
confidence: mossResult.confidence,
|
|
2127
|
-
analysis_duration_ms: performance.now() - t0
|
|
2191
|
+
analysis_duration_ms: performance.now() - t0,
|
|
2192
|
+
// 结构化攻击链图(组合式拦截才有;前端弹窗画图用)
|
|
2193
|
+
violation_graph: JSON.stringify(mossResult.violation_graph || null)
|
|
2128
2194
|
});
|
|
2129
2195
|
setCache(key, mossResult);
|
|
2130
2196
|
if (isMultiSessionEnabled()) {
|
|
@@ -2148,6 +2214,7 @@ async function analyzeRoute(c) {
|
|
|
2148
2214
|
violated_layers: mossResult.violated_layers,
|
|
2149
2215
|
confidence: mossResult.confidence,
|
|
2150
2216
|
analysis_duration_ms: Math.round(durationMs * 10) / 10,
|
|
2217
|
+
violation_graph: mossResult.violation_graph ?? null,
|
|
2151
2218
|
...storageOversizeInfo(),
|
|
2152
2219
|
collected_context: {
|
|
2153
2220
|
os: context.os,
|
|
@@ -2385,17 +2452,17 @@ async function dashboardRoute(c) {
|
|
|
2385
2452
|
return c.html(UNAUTHORIZED_HTML, 401, DASHBOARD_SECURITY_HEADERS);
|
|
2386
2453
|
}
|
|
2387
2454
|
}
|
|
2388
|
-
const { readFileSync:
|
|
2389
|
-
const { resolve: resolve4, dirname:
|
|
2455
|
+
const { readFileSync: readFileSync15, existsSync: existsSync13 } = await import("fs");
|
|
2456
|
+
const { resolve: resolve4, dirname: dirname7 } = await import("path");
|
|
2390
2457
|
const { fileURLToPath } = await import("url");
|
|
2391
|
-
const __dirname2 =
|
|
2458
|
+
const __dirname2 = dirname7(fileURLToPath(importMetaUrl));
|
|
2392
2459
|
const paths = [
|
|
2393
2460
|
resolve4(__dirname2, "dashboard.html"),
|
|
2394
2461
|
resolve4(__dirname2, "../dashboard.html"),
|
|
2395
2462
|
resolve4(__dirname2, "../src/v1/dashboard.html")
|
|
2396
2463
|
];
|
|
2397
|
-
const htmlPath = paths.find((p) =>
|
|
2398
|
-
const html =
|
|
2464
|
+
const htmlPath = paths.find((p) => existsSync13(p)) || paths[0];
|
|
2465
|
+
const html = readFileSync15(htmlPath, "utf-8");
|
|
2399
2466
|
return c.html(html, 200, DASHBOARD_SECURITY_HEADERS);
|
|
2400
2467
|
}
|
|
2401
2468
|
var import_hono, import_cors, import_logger, import_cookie, PUBLIC_PAGE_PATHS, UNAUTHORIZED_HTML, AGENT_FORBIDDEN_HTML;
|
|
@@ -26087,14 +26154,14 @@ var require_find_made = __commonJS({
|
|
|
26087
26154
|
"../node_modules/mkdirp/lib/find-made.js"(exports2, module2) {
|
|
26088
26155
|
"use strict";
|
|
26089
26156
|
init_cjs_shims();
|
|
26090
|
-
var { dirname:
|
|
26157
|
+
var { dirname: dirname7 } = require("path");
|
|
26091
26158
|
var findMade = (opts, parent2, path11 = void 0) => {
|
|
26092
26159
|
if (path11 === parent2)
|
|
26093
26160
|
return Promise.resolve();
|
|
26094
26161
|
return opts.statAsync(parent2).then(
|
|
26095
26162
|
(st) => st.isDirectory() ? path11 : void 0,
|
|
26096
26163
|
// will fail later
|
|
26097
|
-
(er) => er.code === "ENOENT" ? findMade(opts,
|
|
26164
|
+
(er) => er.code === "ENOENT" ? findMade(opts, dirname7(parent2), parent2) : void 0
|
|
26098
26165
|
);
|
|
26099
26166
|
};
|
|
26100
26167
|
var findMadeSync = (opts, parent2, path11 = void 0) => {
|
|
@@ -26103,7 +26170,7 @@ var require_find_made = __commonJS({
|
|
|
26103
26170
|
try {
|
|
26104
26171
|
return opts.statSync(parent2).isDirectory() ? path11 : void 0;
|
|
26105
26172
|
} catch (er) {
|
|
26106
|
-
return er.code === "ENOENT" ? findMadeSync(opts,
|
|
26173
|
+
return er.code === "ENOENT" ? findMadeSync(opts, dirname7(parent2), parent2) : void 0;
|
|
26107
26174
|
}
|
|
26108
26175
|
};
|
|
26109
26176
|
module2.exports = { findMade, findMadeSync };
|
|
@@ -26115,10 +26182,10 @@ var require_mkdirp_manual = __commonJS({
|
|
|
26115
26182
|
"../node_modules/mkdirp/lib/mkdirp-manual.js"(exports2, module2) {
|
|
26116
26183
|
"use strict";
|
|
26117
26184
|
init_cjs_shims();
|
|
26118
|
-
var { dirname:
|
|
26185
|
+
var { dirname: dirname7 } = require("path");
|
|
26119
26186
|
var mkdirpManual = (path11, opts, made) => {
|
|
26120
26187
|
opts.recursive = false;
|
|
26121
|
-
const parent2 =
|
|
26188
|
+
const parent2 = dirname7(path11);
|
|
26122
26189
|
if (parent2 === path11) {
|
|
26123
26190
|
return opts.mkdirAsync(path11, opts).catch((er) => {
|
|
26124
26191
|
if (er.code !== "EISDIR")
|
|
@@ -26141,7 +26208,7 @@ var require_mkdirp_manual = __commonJS({
|
|
|
26141
26208
|
});
|
|
26142
26209
|
};
|
|
26143
26210
|
var mkdirpManualSync = (path11, opts, made) => {
|
|
26144
|
-
const parent2 =
|
|
26211
|
+
const parent2 = dirname7(path11);
|
|
26145
26212
|
opts.recursive = false;
|
|
26146
26213
|
if (parent2 === path11) {
|
|
26147
26214
|
try {
|
|
@@ -26178,12 +26245,12 @@ var require_mkdirp_native = __commonJS({
|
|
|
26178
26245
|
"../node_modules/mkdirp/lib/mkdirp-native.js"(exports2, module2) {
|
|
26179
26246
|
"use strict";
|
|
26180
26247
|
init_cjs_shims();
|
|
26181
|
-
var { dirname:
|
|
26248
|
+
var { dirname: dirname7 } = require("path");
|
|
26182
26249
|
var { findMade, findMadeSync } = require_find_made();
|
|
26183
26250
|
var { mkdirpManual, mkdirpManualSync } = require_mkdirp_manual();
|
|
26184
26251
|
var mkdirpNative = (path11, opts) => {
|
|
26185
26252
|
opts.recursive = true;
|
|
26186
|
-
const parent2 =
|
|
26253
|
+
const parent2 = dirname7(path11);
|
|
26187
26254
|
if (parent2 === path11)
|
|
26188
26255
|
return opts.mkdirAsync(path11, opts);
|
|
26189
26256
|
return findMade(opts, path11).then((made) => opts.mkdirAsync(path11, opts).then(() => made).catch((er) => {
|
|
@@ -26195,7 +26262,7 @@ var require_mkdirp_native = __commonJS({
|
|
|
26195
26262
|
};
|
|
26196
26263
|
var mkdirpNativeSync = (path11, opts) => {
|
|
26197
26264
|
opts.recursive = true;
|
|
26198
|
-
const parent2 =
|
|
26265
|
+
const parent2 = dirname7(path11);
|
|
26199
26266
|
if (parent2 === path11)
|
|
26200
26267
|
return opts.mkdirSync(path11, opts);
|
|
26201
26268
|
const made = findMadeSync(opts, path11);
|
|
@@ -26651,17 +26718,17 @@ var require_ProxyFinalRequestFilter = __commonJS({
|
|
|
26651
26718
|
// ../node_modules/uuid/dist/esm-node/rng.js
|
|
26652
26719
|
function rng() {
|
|
26653
26720
|
if (poolPtr > rnds8Pool.length - 16) {
|
|
26654
|
-
|
|
26721
|
+
import_crypto3.default.randomFillSync(rnds8Pool);
|
|
26655
26722
|
poolPtr = 0;
|
|
26656
26723
|
}
|
|
26657
26724
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
26658
26725
|
}
|
|
26659
|
-
var
|
|
26726
|
+
var import_crypto3, rnds8Pool, poolPtr;
|
|
26660
26727
|
var init_rng = __esm({
|
|
26661
26728
|
"../node_modules/uuid/dist/esm-node/rng.js"() {
|
|
26662
26729
|
"use strict";
|
|
26663
26730
|
init_cjs_shims();
|
|
26664
|
-
|
|
26731
|
+
import_crypto3 = __toESM(require("crypto"));
|
|
26665
26732
|
rnds8Pool = new Uint8Array(256);
|
|
26666
26733
|
poolPtr = rnds8Pool.length;
|
|
26667
26734
|
}
|
|
@@ -26876,14 +26943,14 @@ function md5(bytes) {
|
|
|
26876
26943
|
} else if (typeof bytes === "string") {
|
|
26877
26944
|
bytes = Buffer.from(bytes, "utf8");
|
|
26878
26945
|
}
|
|
26879
|
-
return
|
|
26946
|
+
return import_crypto4.default.createHash("md5").update(bytes).digest();
|
|
26880
26947
|
}
|
|
26881
|
-
var
|
|
26948
|
+
var import_crypto4, md5_default;
|
|
26882
26949
|
var init_md5 = __esm({
|
|
26883
26950
|
"../node_modules/uuid/dist/esm-node/md5.js"() {
|
|
26884
26951
|
"use strict";
|
|
26885
26952
|
init_cjs_shims();
|
|
26886
|
-
|
|
26953
|
+
import_crypto4 = __toESM(require("crypto"));
|
|
26887
26954
|
md5_default = md5;
|
|
26888
26955
|
}
|
|
26889
26956
|
});
|
|
@@ -26902,14 +26969,14 @@ var init_v3 = __esm({
|
|
|
26902
26969
|
});
|
|
26903
26970
|
|
|
26904
26971
|
// ../node_modules/uuid/dist/esm-node/native.js
|
|
26905
|
-
var
|
|
26972
|
+
var import_crypto5, native_default;
|
|
26906
26973
|
var init_native = __esm({
|
|
26907
26974
|
"../node_modules/uuid/dist/esm-node/native.js"() {
|
|
26908
26975
|
"use strict";
|
|
26909
26976
|
init_cjs_shims();
|
|
26910
|
-
|
|
26977
|
+
import_crypto5 = __toESM(require("crypto"));
|
|
26911
26978
|
native_default = {
|
|
26912
|
-
randomUUID:
|
|
26979
|
+
randomUUID: import_crypto5.default.randomUUID
|
|
26913
26980
|
};
|
|
26914
26981
|
}
|
|
26915
26982
|
});
|
|
@@ -26951,14 +27018,14 @@ function sha1(bytes) {
|
|
|
26951
27018
|
} else if (typeof bytes === "string") {
|
|
26952
27019
|
bytes = Buffer.from(bytes, "utf8");
|
|
26953
27020
|
}
|
|
26954
|
-
return
|
|
27021
|
+
return import_crypto6.default.createHash("sha1").update(bytes).digest();
|
|
26955
27022
|
}
|
|
26956
|
-
var
|
|
27023
|
+
var import_crypto6, sha1_default;
|
|
26957
27024
|
var init_sha1 = __esm({
|
|
26958
27025
|
"../node_modules/uuid/dist/esm-node/sha1.js"() {
|
|
26959
27026
|
"use strict";
|
|
26960
27027
|
init_cjs_shims();
|
|
26961
|
-
|
|
27028
|
+
import_crypto6 = __toESM(require("crypto"));
|
|
26962
27029
|
sha1_default = sha1;
|
|
26963
27030
|
}
|
|
26964
27031
|
});
|
|
@@ -28622,10 +28689,10 @@ var init_interceptor = __esm({
|
|
|
28622
28689
|
* @param awaitDecision when true, await AgentMoss instead of fire-and-forget.
|
|
28623
28690
|
*/
|
|
28624
28691
|
async _processResponse(flowId, respHeaders, respBody, awaitDecision) {
|
|
28625
|
-
const
|
|
28626
|
-
if (!
|
|
28692
|
+
const cached2 = this._requestCache.get(flowId);
|
|
28693
|
+
if (!cached2) return { events: [], deny: { deny: false } };
|
|
28627
28694
|
this._requestCache.delete(flowId);
|
|
28628
|
-
const { parser, meta, headers, url } =
|
|
28695
|
+
const { parser, meta, headers, url } = cached2;
|
|
28629
28696
|
const toolCalls = parser.parseResponse(url, respHeaders, respBody, meta);
|
|
28630
28697
|
if (toolCalls.length === 0) return { events: [], deny: { deny: false } };
|
|
28631
28698
|
const agentType = parser.detectAgentType(headers, meta);
|
|
@@ -29632,12 +29699,12 @@ var init_coordinator = __esm({
|
|
|
29632
29699
|
`[PhaseCoordinator][L1]: tool=${toolName} id=${toolCallId} session=${sessionId.slice(0, 8)} level=${this.level}`
|
|
29633
29700
|
);
|
|
29634
29701
|
if (this.decisionCache) {
|
|
29635
|
-
const
|
|
29636
|
-
if (
|
|
29702
|
+
const cached2 = this.decisionCache.get(sessionId, "", this._eventCommand(event));
|
|
29703
|
+
if (cached2) {
|
|
29637
29704
|
console.log(
|
|
29638
|
-
`[PhaseCoordinator]: decision cache HIT (tool=${toolName}) \u2192 ${String(
|
|
29705
|
+
`[PhaseCoordinator]: decision cache HIT (tool=${toolName}) \u2192 ${String(cached2.decision ?? "Allow")}`
|
|
29639
29706
|
);
|
|
29640
|
-
return String(
|
|
29707
|
+
return String(cached2.decision ?? "Allow");
|
|
29641
29708
|
}
|
|
29642
29709
|
}
|
|
29643
29710
|
if (this.whitelistEngine?.isWhitelisted(event)) {
|