@kenhkl/agent-gate 0.5.1 → 0.5.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/cli.js +46 -7
- package/dist/cli.js.map +1 -1
- package/dist/dashboard.html +36 -16
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -45,15 +45,21 @@ var init_cjs_shims = __esm({
|
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
// src/version.ts
|
|
48
|
-
var
|
|
48
|
+
var _version, version;
|
|
49
49
|
var init_version = __esm({
|
|
50
50
|
"src/version.ts"() {
|
|
51
51
|
"use strict";
|
|
52
52
|
init_cjs_shims();
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
_version = true ? "0.5.3" : (() => {
|
|
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;
|
|
57
63
|
}
|
|
58
64
|
});
|
|
59
65
|
|
|
@@ -226,6 +232,22 @@ var init_json_storage = __esm({
|
|
|
226
232
|
const limit = params.limit || 50;
|
|
227
233
|
return allRecords.slice(offset, offset + limit);
|
|
228
234
|
}
|
|
235
|
+
countToolCalls(params) {
|
|
236
|
+
const sessions = this.loadSessions();
|
|
237
|
+
let allRecords = [];
|
|
238
|
+
try {
|
|
239
|
+
const files = (0, import_fs.readdirSync)(this.toolCallsDir).filter((f) => f.endsWith(".json"));
|
|
240
|
+
for (const file of files) {
|
|
241
|
+
const records = this.readJsonFile((0, import_path.join)(this.toolCallsDir, file), []);
|
|
242
|
+
allRecords.push(...records);
|
|
243
|
+
}
|
|
244
|
+
} catch {
|
|
245
|
+
}
|
|
246
|
+
if (params.decision) {
|
|
247
|
+
allRecords = allRecords.filter((r) => r.decision === params.decision);
|
|
248
|
+
}
|
|
249
|
+
return allRecords.length;
|
|
250
|
+
}
|
|
229
251
|
enrichRecord(record, sessions, agents) {
|
|
230
252
|
const session = sessions.get(record.session_id);
|
|
231
253
|
const agentId = session?.agent_id;
|
|
@@ -452,6 +474,19 @@ CREATE INDEX IF NOT EXISTS idx_tool_calls_decision ON tool_calls(decision, calle
|
|
|
452
474
|
${where} ORDER BY tc.called_at DESC LIMIT ? OFFSET ?`
|
|
453
475
|
).all(...values, limit, offset);
|
|
454
476
|
}
|
|
477
|
+
countToolCalls(params) {
|
|
478
|
+
const conditions = [];
|
|
479
|
+
const values = [];
|
|
480
|
+
if (params.decision) {
|
|
481
|
+
conditions.push("tc.decision = ?");
|
|
482
|
+
values.push(params.decision);
|
|
483
|
+
}
|
|
484
|
+
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
485
|
+
const row = this.db.prepare(
|
|
486
|
+
`SELECT COUNT(*) as total FROM tool_calls tc ${where}`
|
|
487
|
+
).get(...values);
|
|
488
|
+
return row?.total ?? 0;
|
|
489
|
+
}
|
|
455
490
|
getAgentsList() {
|
|
456
491
|
return this.db.prepare(`
|
|
457
492
|
SELECT a.agent_type, a.hostname, a.agent_version as version,
|
|
@@ -862,6 +897,9 @@ function insertToolCall(record) {
|
|
|
862
897
|
function queryToolCalls(params) {
|
|
863
898
|
return store().queryToolCalls(params);
|
|
864
899
|
}
|
|
900
|
+
function countToolCalls(params) {
|
|
901
|
+
return store().countToolCalls(params);
|
|
902
|
+
}
|
|
865
903
|
function getAgentsList() {
|
|
866
904
|
return store().getAgentsList();
|
|
867
905
|
}
|
|
@@ -958,8 +996,9 @@ async function toolCallsRoute(c) {
|
|
|
958
996
|
const decision = c.req.query("decision");
|
|
959
997
|
const limit = parseInt(c.req.query("limit") || "50", 10);
|
|
960
998
|
const offset = parseInt(c.req.query("offset") || "0", 10);
|
|
961
|
-
const
|
|
962
|
-
|
|
999
|
+
const total = countToolCalls({ decision });
|
|
1000
|
+
const data = queryToolCalls({ decision, limit, offset });
|
|
1001
|
+
return c.json({ total, data });
|
|
963
1002
|
}
|
|
964
1003
|
async function agentsRoute(c) {
|
|
965
1004
|
const agents = getAgentsList();
|