@kenhkl/agent-moss 0.12.3 → 0.12.5
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 +12 -5
- package/dist/cli.js.map +1 -1
- package/dist/engine/coordinator.d.ts +3 -3
- package/dist/engine/coordinator.js +10 -4
- package/dist/engine/coordinator.js.map +1 -1
- package/dist/rules/l1_rules.json +6 -0
- package/dist/server.js +12 -5
- package/dist/server.js.map +1 -1
- package/dist/static/index.html +39 -3
- package/package.json +1 -1
package/dist/rules/l1_rules.json
CHANGED
|
@@ -323,6 +323,12 @@
|
|
|
323
323
|
"risk_level": "medium",
|
|
324
324
|
"risk_type": "data_exfiltration",
|
|
325
325
|
"reason": "导出敏感凭证"
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
"pattern": "(?:\\$\\(|`)\\s*(?:\\S+=\\S*\\s+)*(?:touch|rm|mkdir|mv|cp|dd|tee|truncate|chmod|chown|mkfifo|mknod|ln|shred|mkfs|nc|ncat|socat|bash|sh|zsh|dash|python|python3|perl|ruby|node|php|eval|exec|base64|sudo|su)\\b",
|
|
329
|
+
"risk_level": "critical",
|
|
330
|
+
"risk_type": "script_execution",
|
|
331
|
+
"reason": "检测到命令替换隐藏执行($(...)/反引号载荷含写/执行命令),可能产生文件系统副作用"
|
|
326
332
|
}
|
|
327
333
|
],
|
|
328
334
|
"injection_detection": [
|
package/dist/server.js
CHANGED
|
@@ -2783,6 +2783,7 @@ var init_heuristic = __esm({
|
|
|
2783
2783
|
var token_stats_exports = {};
|
|
2784
2784
|
__export(token_stats_exports, {
|
|
2785
2785
|
getRecentRecords: () => getRecentRecords,
|
|
2786
|
+
getRecentRecordsCount: () => getRecentRecordsCount,
|
|
2786
2787
|
getTokenStats: () => getTokenStats,
|
|
2787
2788
|
getTokenTrend: () => getTokenTrend,
|
|
2788
2789
|
recordTokenUsage: () => recordTokenUsage,
|
|
@@ -2903,9 +2904,14 @@ function getTokenStats(days = 0, startDate, endDate) {
|
|
|
2903
2904
|
by_date: a.byDate
|
|
2904
2905
|
};
|
|
2905
2906
|
}
|
|
2906
|
-
function getRecentRecords(limit = 20) {
|
|
2907
|
+
function getRecentRecords(limit = 20, offset = 0) {
|
|
2907
2908
|
const records = loadAllRecords(getStatsPath());
|
|
2908
|
-
|
|
2909
|
+
const start = Math.max(0, records.length - offset - limit);
|
|
2910
|
+
const end = records.length - offset;
|
|
2911
|
+
return records.slice(start, end);
|
|
2912
|
+
}
|
|
2913
|
+
function getRecentRecordsCount() {
|
|
2914
|
+
return loadAllRecords(getStatsPath()).length;
|
|
2909
2915
|
}
|
|
2910
2916
|
function getTokenTrend(days = 0, startDate, endDate) {
|
|
2911
2917
|
const records = filterByDate(loadAllRecords(getStatsPath()), days, startDate, endDate);
|
|
@@ -4661,10 +4667,10 @@ function formatPromptHistory(promptHistory, maxTextChars = 500) {
|
|
|
4661
4667
|
const lines = [];
|
|
4662
4668
|
for (let i = 0; i < promptHistory.length; i++) {
|
|
4663
4669
|
const turn = promptHistory[i];
|
|
4664
|
-
const text = (turn?.text || "").trim();
|
|
4670
|
+
const text = (typeof turn === "string" ? turn : turn?.text || "").trim();
|
|
4665
4671
|
if (!text) continue;
|
|
4666
4672
|
let line = ` \u7B2C${i + 1}\u8F6E\u7528\u6237\u610F\u56FE: ${text.slice(0, maxTextChars)}`;
|
|
4667
|
-
const actions = turn?.actions;
|
|
4673
|
+
const actions = typeof turn === "string" ? void 0 : turn?.actions;
|
|
4668
4674
|
if (actions && actions.length > 0) {
|
|
4669
4675
|
const types = actions.map((a) => a?.actionType).filter((t) => typeof t === "string" && t.length > 0);
|
|
4670
4676
|
if (types.length > 0) {
|
|
@@ -5468,7 +5474,8 @@ function createConsoleRouter() {
|
|
|
5468
5474
|
});
|
|
5469
5475
|
console2.get("/api/token-stats/recent", (c) => {
|
|
5470
5476
|
const limit = parseInt(c.req.query("limit") || "20", 10);
|
|
5471
|
-
|
|
5477
|
+
const offset = parseInt(c.req.query("offset") || "0", 10);
|
|
5478
|
+
return c.json({ records: getRecentRecords(limit, offset), total: getRecentRecordsCount() });
|
|
5472
5479
|
});
|
|
5473
5480
|
console2.get("/api/token-stats/trend", (c) => {
|
|
5474
5481
|
const days = parseInt(c.req.query("days") || "7", 10);
|