@kenhkl/agent-moss 0.16.9 → 0.16.13
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/README.md +3 -0
- package/dist/cli.d.ts +19 -1
- package/dist/cli.js +2605 -478
- package/dist/data/agent_moss.service +4 -0
- package/dist/data/rules_template/README.md +133 -0
- package/dist/data/rules_template/extra.json +14 -0
- package/dist/data/rules_template/override.json +15 -0
- package/dist/engine/coordinator.js +917 -208
- package/dist/server.d.ts +18 -1
- package/dist/server.js +1809 -312
- package/dist/static/index.html +26 -1
- package/package.json +2 -1
package/dist/static/index.html
CHANGED
|
@@ -201,7 +201,10 @@ body {
|
|
|
201
201
|
.ag-link:hover { text-decoration: underline; }
|
|
202
202
|
|
|
203
203
|
/* Toast */
|
|
204
|
-
.ag-toast { position: fixed; top: 20px; right: 20px; padding: 12px 20px; border-radius: 8px; font-size: 13px; z-index:
|
|
204
|
+
.ag-toast { position: fixed; top: 20px; right: 20px; padding: 12px 20px; border-radius: 8px; font-size: 13px; z-index: 10000; box-shadow: 0 4px 12px rgba(0,0,0,.15); animation: ag-slide-in .3s ease; }
|
|
205
|
+
/* 仅内置规则模式的顶部横幅是 sticky + z-index 9999;toast 必须在其之上,
|
|
206
|
+
并下移一个横幅高度,否则错误提示会被横幅挡住。 */
|
|
207
|
+
body.builtin-only-mode .ag-toast { top: calc(20px + var(--am-builtin-banner-height, 48px)); }
|
|
205
208
|
.ag-toast-success { background: var(--ag-green); color: #fff; }
|
|
206
209
|
.ag-toast-error { background: var(--ag-red); color: #fff; }
|
|
207
210
|
.ag-toast-warning { background: var(--ag-orange); color: #fff; }
|
|
@@ -246,6 +249,10 @@ body {
|
|
|
246
249
|
</style>
|
|
247
250
|
</head>
|
|
248
251
|
<body>
|
|
252
|
+
<div id="builtin-only-banner" style="display:none;background:#b45309;color:#fff;padding:6px 14px;font-size:12px;line-height:1.5;text-align:center;position:sticky;top:0;z-index:9999">
|
|
253
|
+
仅内置规则模式:已忽略 runtime 配置与 Console 自定义,修改规则不会生效。需重启服务并移除 <code>AGENT_MOSS_RULES_BUILTIN_ONLY</code> 后再改规则。<br>
|
|
254
|
+
Built-in rules only: runtime config and Console changes are ignored. Restart without <code>AGENT_MOSS_RULES_BUILTIN_ONLY</code> to edit rules.
|
|
255
|
+
</div>
|
|
249
256
|
<div class="ag-wrap">
|
|
250
257
|
<div class="ag-tabs" id="tabs">
|
|
251
258
|
<div class="ag-tab active" data-page="overview">概览</div>
|
|
@@ -553,6 +560,24 @@ function agPrompt(title, opts = {}) {
|
|
|
553
560
|
// ===== Pages =====
|
|
554
561
|
async function refreshConfig() {
|
|
555
562
|
state.config = await api('config');
|
|
563
|
+
// cold / builtin 模式:顶部显示只读横幅(写接口由后端统一 403)
|
|
564
|
+
const rulesMode = state.config.rules_mode || (state.config.builtin_only ? 'builtin' : 'hot');
|
|
565
|
+
if (rulesMode === 'cold' || rulesMode === 'builtin') {
|
|
566
|
+
const banner = el('builtin-only-banner');
|
|
567
|
+
if (banner) {
|
|
568
|
+
banner.innerHTML = rulesMode === 'cold'
|
|
569
|
+
? '冷启动规则模式:runtime 配置与 Console 自定义已忽略;规则目录仅在启动时读取一次,修改规则目录需重启服务。<br>'
|
|
570
|
+
+ 'Cold-start rules mode: runtime config and Console changes are ignored. Rule directories are loaded once at startup; restart to apply changes.'
|
|
571
|
+
: '仅内置规则模式:已忽略 runtime 配置与 Console 自定义,修改规则不会生效。需重启服务并移除 <code>AGENT_MOSS_RULES_BUILTIN_ONLY</code> 后再改规则。<br>'
|
|
572
|
+
+ 'Built-in rules only: runtime config and Console changes are ignored. Restart without <code>AGENT_MOSS_RULES_BUILTIN_ONLY</code> to edit rules.';
|
|
573
|
+
banner.style.display = 'block';
|
|
574
|
+
// 记录横幅实际高度(窄屏会换行),让 toast 显示在横幅下方而不是被挡住
|
|
575
|
+
document.documentElement.style.setProperty(
|
|
576
|
+
'--am-builtin-banner-height', banner.offsetHeight + 'px'
|
|
577
|
+
);
|
|
578
|
+
document.body.classList.add('builtin-only-mode');
|
|
579
|
+
}
|
|
580
|
+
}
|
|
556
581
|
state.envOverrides = await loadEnvOverrides();
|
|
557
582
|
state.agentRules = await api('agents');
|
|
558
583
|
// 场景定制规则:后端按 AGENT_MOSS_SCENARIO env 过滤(无 env 返回空 → 场景页显示"未启用"提示)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kenhkl/agent-moss",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.13",
|
|
4
4
|
"description": "Multi-layer security analysis engine for AI agents (TypeScript)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/server.js",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"openai": "^4.104.0",
|
|
37
37
|
"pino": "^9.5.0",
|
|
38
38
|
"pino-pretty": "^11.3.0",
|
|
39
|
+
"smol-toml": "^1.9.1",
|
|
39
40
|
"yaml": "^2.6.0",
|
|
40
41
|
"zod": "^3.23.0"
|
|
41
42
|
},
|