@kenhkl/agent-gate 0.5.5 → 0.5.7
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 +14 -6
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/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.5.
|
|
53
|
+
_version = true ? "0.5.7" : (() => {
|
|
54
54
|
try {
|
|
55
55
|
const require2 = createRequire(importMetaUrl);
|
|
56
56
|
const pkg = require2("../package.json");
|
|
@@ -640,7 +640,9 @@ async function callAgentMoss(request) {
|
|
|
640
640
|
method: "POST",
|
|
641
641
|
headers: { "Content-Type": "application/json" },
|
|
642
642
|
body: JSON.stringify(request),
|
|
643
|
-
|
|
643
|
+
// 100s:覆盖 AgentMoss 总超时(90s)+ 余量,避免 AgentMoss 还在分析时
|
|
644
|
+
// 被 AgentGate 抢断后 fail-closed 误杀。AgentGate 这层不重试(AgentMoss 内部已重试)。
|
|
645
|
+
timeout: 1e5
|
|
644
646
|
});
|
|
645
647
|
if (!resp.ok) {
|
|
646
648
|
console.error(`[AgentGate] AgentMoss HTTP ${resp.status}: ${resp.statusText}`);
|
|
@@ -648,8 +650,14 @@ async function callAgentMoss(request) {
|
|
|
648
650
|
}
|
|
649
651
|
return await resp.json();
|
|
650
652
|
} catch (err) {
|
|
651
|
-
|
|
652
|
-
|
|
653
|
+
const errType = err?.type || "";
|
|
654
|
+
const errMsg = String(err?.message || err);
|
|
655
|
+
if (errType === "request-timeout" || errMsg.includes("timeout")) {
|
|
656
|
+
console.error(`[AgentGate] AgentMoss analysis timeout: ${errMsg}`);
|
|
657
|
+
return failClosedResponse("AgentMoss analysis timeout", "analysis_timeout");
|
|
658
|
+
}
|
|
659
|
+
console.error(`[AgentGate] AgentMoss unreachable: ${errMsg}`);
|
|
660
|
+
return failClosedResponse("AgentMoss service unavailable", "service_unavailable");
|
|
653
661
|
}
|
|
654
662
|
}
|
|
655
663
|
async function fetchMossHealth() {
|
|
@@ -669,12 +677,12 @@ async function fetchMossHealth() {
|
|
|
669
677
|
return { moss_version: "N/A", moss_status: "unreachable" };
|
|
670
678
|
}
|
|
671
679
|
}
|
|
672
|
-
function failClosedResponse(reason) {
|
|
680
|
+
function failClosedResponse(reason, riskType = "service_unavailable") {
|
|
673
681
|
return {
|
|
674
682
|
decision: "Deny",
|
|
675
683
|
reason,
|
|
676
684
|
risk_level: "high",
|
|
677
|
-
risk_type:
|
|
685
|
+
risk_type: riskType,
|
|
678
686
|
violated_layers: [],
|
|
679
687
|
confidence: 100
|
|
680
688
|
};
|