nexus-agents 6.3.17 → 7.0.1
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/{child-mcp-config-IPWKOUSE.js → child-mcp-config-ORXLS5HP.js} +2 -2
- package/dist/{chunk-XOCNOKIV.js → chunk-33FI7W3G.js} +2 -2
- package/dist/{chunk-QUMUVNL6.js → chunk-3CGUPSBW.js} +2 -2
- package/dist/{chunk-V2OHGKB5.js → chunk-6E2M3P5A.js} +3 -3
- package/dist/{chunk-PCZJMNPT.js → chunk-6GYTTWNM.js} +2 -2
- package/dist/{chunk-DR7DYEFQ.js → chunk-6Q3KSZVI.js} +2 -2
- package/dist/{chunk-DXIZQRP5.js → chunk-7U7HAYPB.js} +4 -4
- package/dist/{chunk-KYCJ47JZ.js → chunk-BTWKDT4F.js} +8 -8
- package/dist/{chunk-KXQNETUB.js → chunk-D6TL5GZV.js} +13 -4
- package/dist/chunk-D6TL5GZV.js.map +1 -0
- package/dist/{chunk-LT2LUIQK.js → chunk-HA2MM4C2.js} +71 -37
- package/dist/{chunk-LT2LUIQK.js.map → chunk-HA2MM4C2.js.map} +1 -1
- package/dist/{chunk-MB2YIETU.js → chunk-IWTK6FDT.js} +2 -2
- package/dist/{chunk-5EEEPQZY.js → chunk-JJT7NVNY.js} +3 -3
- package/dist/{chunk-6ZYJ46HN.js → chunk-JNZ3D5B5.js} +2 -2
- package/dist/{chunk-VNULIWRK.js → chunk-K2AWJGQO.js} +2 -2
- package/dist/{chunk-ET67NYCJ.js → chunk-KJWD2V4K.js} +7 -7
- package/dist/{chunk-UAKFLKW3.js → chunk-LVYRGNOC.js} +2 -2
- package/dist/chunk-MNG6VKJP.js +7 -0
- package/dist/{chunk-KASDQSEA.js.map → chunk-MNG6VKJP.js.map} +1 -1
- package/dist/{chunk-N34KB6DR.js → chunk-PDMWQ2NK.js} +141 -62
- package/dist/chunk-PDMWQ2NK.js.map +1 -0
- package/dist/{chunk-T47DKINM.js → chunk-Q6IODDEA.js} +6 -6
- package/dist/{chunk-RSSLLOU6.js → chunk-QAHGHWC7.js} +5 -5
- package/dist/{chunk-JC4WREXA.js → chunk-RBF64DXJ.js} +2 -2
- package/dist/{chunk-NVFYMGCC.js → chunk-RLBJTZHA.js} +2 -2
- package/dist/{chunk-HGL7B6WB.js → chunk-S2Z7CME3.js} +2 -2
- package/dist/{chunk-IRHLTW3P.js → chunk-SS5FADQN.js} +23 -9
- package/dist/chunk-SS5FADQN.js.map +1 -0
- package/dist/{chunk-OI6XXZOE.js → chunk-UJPVBDYG.js} +7 -7
- package/dist/{chunk-LUPEM2NF.js → chunk-UVO673OY.js} +3 -3
- package/dist/{chunk-CF5CXFYJ.js → chunk-VVXHIUFQ.js} +5 -5
- package/dist/{chunk-L3ZVRVHA.js → chunk-VYAXMVI5.js} +2 -2
- package/dist/{chunk-ZICPESTJ.js → chunk-XREG2HTQ.js} +4 -4
- package/dist/{chunk-SZZRE2VU.js → chunk-XZEYSIGG.js} +2 -2
- package/dist/{chunk-OP6PH7GC.js → chunk-Y5GYBP52.js} +2 -2
- package/dist/{chunk-UOHOHH72.js → chunk-Y742U2YM.js} +18 -7
- package/dist/{chunk-UOHOHH72.js.map → chunk-Y742U2YM.js.map} +1 -1
- package/dist/{chunk-KLQ352NK.js → chunk-ZD4VEHEG.js} +2 -2
- package/dist/{chunk-XOLGF5MK.js → chunk-ZGEDIKAM.js} +2 -2
- package/dist/{cli-circuit-breaker-TEW4RTM2.js → cli-circuit-breaker-5FYJDS5O.js} +3 -3
- package/dist/cli.js +41 -41
- package/dist/{composite-router-GEQSU4S3.js → composite-router-GE24MYPP.js} +2 -2
- package/dist/{consensus-vote-OHOQXNTT.js → consensus-vote-355WNDBN.js} +17 -17
- package/dist/{context-retriever-ECGC4EFR.js → context-retriever-3OO6N4V6.js} +8 -8
- package/dist/{doctor-deep-6WLU2HV7.js → doctor-deep-6WHVRRVQ.js} +3 -3
- package/dist/{doctor-live-OLSOA44K.js → doctor-live-J7JIZH3T.js} +9 -9
- package/dist/{expert-bridge-DWBQLHPG.js → expert-bridge-PWRVRFDG.js} +4 -4
- package/dist/{factory-Q7D2MNS2.js → factory-3BZDQQYM.js} +9 -9
- package/dist/{factory-OTIHI4GK.js → factory-UFKRSADE.js} +5 -5
- package/dist/{improvement-review-F2POEVI4.js → improvement-review-PO4LS6GO.js} +6 -6
- package/dist/index.d.ts +101 -14
- package/dist/index.js +31 -31
- package/dist/{init-opencode-MCS4F4MP.js → init-opencode-GDPE4U65.js} +6 -6
- package/dist/issue-triage-2LNYGQRJ.js +17 -0
- package/dist/{pr-reviewer-helpers-7OKVLICU.js → pr-reviewer-helpers-KBOP72XG.js} +4 -4
- package/dist/{registry-command-WRWJWKJV.js → registry-command-ZK4NQ2MX.js} +2 -2
- package/dist/{repo-security-plan-TW3D5JPQ.js → repo-security-plan-SZU4O2TN.js} +3 -3
- package/dist/{research-helpers-synthesize-3YBPFYMX.js → research-helpers-synthesize-QY3DDHTD.js} +4 -4
- package/dist/{routing-memory-5CLHRWID.js → routing-memory-2SMMUPTB.js} +2 -2
- package/dist/{session-memory-M2LUBDCR.js → session-memory-YQQVPLKM.js} +3 -3
- package/dist/{setup-config-OMH2SQLH.js → setup-config-LMZE4IRV.js} +3 -3
- package/dist/{setup-custom-api-WHU4TJKG.js → setup-custom-api-ZSBUIJID.js} +4 -4
- package/dist/setup-data-dir-O2EABCPO.js +29 -0
- package/dist/{tool-memory-K3LY6VBF.js → tool-memory-GUPG2M25.js} +5 -5
- package/dist/{unified-registry-DC7GEQKG.js → unified-registry-RPT4O3XB.js} +10 -10
- package/dist/{weather-report-XMWNDDHY.js → weather-report-6AVPMHHM.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-IRHLTW3P.js.map +0 -1
- package/dist/chunk-KASDQSEA.js +0 -7
- package/dist/chunk-KXQNETUB.js.map +0 -1
- package/dist/chunk-N34KB6DR.js.map +0 -1
- package/dist/issue-triage-A7JXRGSV.js +0 -17
- package/dist/setup-data-dir-BQVEUXP5.js +0 -29
- /package/dist/{child-mcp-config-IPWKOUSE.js.map → child-mcp-config-ORXLS5HP.js.map} +0 -0
- /package/dist/{chunk-XOCNOKIV.js.map → chunk-33FI7W3G.js.map} +0 -0
- /package/dist/{chunk-QUMUVNL6.js.map → chunk-3CGUPSBW.js.map} +0 -0
- /package/dist/{chunk-V2OHGKB5.js.map → chunk-6E2M3P5A.js.map} +0 -0
- /package/dist/{chunk-PCZJMNPT.js.map → chunk-6GYTTWNM.js.map} +0 -0
- /package/dist/{chunk-DR7DYEFQ.js.map → chunk-6Q3KSZVI.js.map} +0 -0
- /package/dist/{chunk-DXIZQRP5.js.map → chunk-7U7HAYPB.js.map} +0 -0
- /package/dist/{chunk-KYCJ47JZ.js.map → chunk-BTWKDT4F.js.map} +0 -0
- /package/dist/{chunk-MB2YIETU.js.map → chunk-IWTK6FDT.js.map} +0 -0
- /package/dist/{chunk-5EEEPQZY.js.map → chunk-JJT7NVNY.js.map} +0 -0
- /package/dist/{chunk-6ZYJ46HN.js.map → chunk-JNZ3D5B5.js.map} +0 -0
- /package/dist/{chunk-VNULIWRK.js.map → chunk-K2AWJGQO.js.map} +0 -0
- /package/dist/{chunk-ET67NYCJ.js.map → chunk-KJWD2V4K.js.map} +0 -0
- /package/dist/{chunk-UAKFLKW3.js.map → chunk-LVYRGNOC.js.map} +0 -0
- /package/dist/{chunk-T47DKINM.js.map → chunk-Q6IODDEA.js.map} +0 -0
- /package/dist/{chunk-RSSLLOU6.js.map → chunk-QAHGHWC7.js.map} +0 -0
- /package/dist/{chunk-JC4WREXA.js.map → chunk-RBF64DXJ.js.map} +0 -0
- /package/dist/{chunk-NVFYMGCC.js.map → chunk-RLBJTZHA.js.map} +0 -0
- /package/dist/{chunk-HGL7B6WB.js.map → chunk-S2Z7CME3.js.map} +0 -0
- /package/dist/{chunk-OI6XXZOE.js.map → chunk-UJPVBDYG.js.map} +0 -0
- /package/dist/{chunk-LUPEM2NF.js.map → chunk-UVO673OY.js.map} +0 -0
- /package/dist/{chunk-CF5CXFYJ.js.map → chunk-VVXHIUFQ.js.map} +0 -0
- /package/dist/{chunk-L3ZVRVHA.js.map → chunk-VYAXMVI5.js.map} +0 -0
- /package/dist/{chunk-ZICPESTJ.js.map → chunk-XREG2HTQ.js.map} +0 -0
- /package/dist/{chunk-SZZRE2VU.js.map → chunk-XZEYSIGG.js.map} +0 -0
- /package/dist/{chunk-OP6PH7GC.js.map → chunk-Y5GYBP52.js.map} +0 -0
- /package/dist/{chunk-KLQ352NK.js.map → chunk-ZD4VEHEG.js.map} +0 -0
- /package/dist/{chunk-XOLGF5MK.js.map → chunk-ZGEDIKAM.js.map} +0 -0
- /package/dist/{cli-circuit-breaker-TEW4RTM2.js.map → cli-circuit-breaker-5FYJDS5O.js.map} +0 -0
- /package/dist/{composite-router-GEQSU4S3.js.map → composite-router-GE24MYPP.js.map} +0 -0
- /package/dist/{consensus-vote-OHOQXNTT.js.map → consensus-vote-355WNDBN.js.map} +0 -0
- /package/dist/{context-retriever-ECGC4EFR.js.map → context-retriever-3OO6N4V6.js.map} +0 -0
- /package/dist/{doctor-deep-6WLU2HV7.js.map → doctor-deep-6WHVRRVQ.js.map} +0 -0
- /package/dist/{doctor-live-OLSOA44K.js.map → doctor-live-J7JIZH3T.js.map} +0 -0
- /package/dist/{expert-bridge-DWBQLHPG.js.map → expert-bridge-PWRVRFDG.js.map} +0 -0
- /package/dist/{factory-OTIHI4GK.js.map → factory-3BZDQQYM.js.map} +0 -0
- /package/dist/{factory-Q7D2MNS2.js.map → factory-UFKRSADE.js.map} +0 -0
- /package/dist/{improvement-review-F2POEVI4.js.map → improvement-review-PO4LS6GO.js.map} +0 -0
- /package/dist/{init-opencode-MCS4F4MP.js.map → init-opencode-GDPE4U65.js.map} +0 -0
- /package/dist/{issue-triage-A7JXRGSV.js.map → issue-triage-2LNYGQRJ.js.map} +0 -0
- /package/dist/{pr-reviewer-helpers-7OKVLICU.js.map → pr-reviewer-helpers-KBOP72XG.js.map} +0 -0
- /package/dist/{registry-command-WRWJWKJV.js.map → registry-command-ZK4NQ2MX.js.map} +0 -0
- /package/dist/{repo-security-plan-TW3D5JPQ.js.map → repo-security-plan-SZU4O2TN.js.map} +0 -0
- /package/dist/{research-helpers-synthesize-3YBPFYMX.js.map → research-helpers-synthesize-QY3DDHTD.js.map} +0 -0
- /package/dist/{routing-memory-5CLHRWID.js.map → routing-memory-2SMMUPTB.js.map} +0 -0
- /package/dist/{session-memory-M2LUBDCR.js.map → session-memory-YQQVPLKM.js.map} +0 -0
- /package/dist/{setup-config-OMH2SQLH.js.map → setup-config-LMZE4IRV.js.map} +0 -0
- /package/dist/{setup-custom-api-WHU4TJKG.js.map → setup-custom-api-ZSBUIJID.js.map} +0 -0
- /package/dist/{setup-data-dir-BQVEUXP5.js.map → setup-data-dir-O2EABCPO.js.map} +0 -0
- /package/dist/{tool-memory-K3LY6VBF.js.map → tool-memory-GUPG2M25.js.map} +0 -0
- /package/dist/{unified-registry-DC7GEQKG.js.map → unified-registry-RPT4O3XB.js.map} +0 -0
- /package/dist/{weather-report-XMWNDDHY.js.map → weather-report-6AVPMHHM.js.map} +0 -0
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
err,
|
|
5
5
|
getErrorMessage,
|
|
6
6
|
ok
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-Y742U2YM.js";
|
|
8
8
|
|
|
9
9
|
// src/scm/types.ts
|
|
10
10
|
var ScmError = class extends Error {
|
|
@@ -263,4 +263,4 @@ export {
|
|
|
263
263
|
ScmError,
|
|
264
264
|
GitHubProvider
|
|
265
265
|
};
|
|
266
|
-
//# sourceMappingURL=chunk-
|
|
266
|
+
//# sourceMappingURL=chunk-IWTK6FDT.js.map
|
|
@@ -12,11 +12,11 @@ import {
|
|
|
12
12
|
gateWithReputation,
|
|
13
13
|
resolveReputationGatingMode,
|
|
14
14
|
sanitizeInput
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-RLBJTZHA.js";
|
|
16
16
|
import {
|
|
17
17
|
createLogger,
|
|
18
18
|
getTimeProvider
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-Y742U2YM.js";
|
|
20
20
|
|
|
21
21
|
// src/dogfooding/pr-reviewer-helpers.ts
|
|
22
22
|
import { randomUUID } from "crypto";
|
|
@@ -303,4 +303,4 @@ export {
|
|
|
303
303
|
createFailedReview,
|
|
304
304
|
reviewPostingBlock
|
|
305
305
|
};
|
|
306
|
-
//# sourceMappingURL=chunk-
|
|
306
|
+
//# sourceMappingURL=chunk-JJT7NVNY.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
getErrorMessage,
|
|
5
5
|
getTimeProvider,
|
|
6
6
|
ok
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-Y742U2YM.js";
|
|
8
8
|
|
|
9
9
|
// src/context/session-memory.ts
|
|
10
10
|
import * as fs from "fs";
|
|
@@ -366,4 +366,4 @@ export {
|
|
|
366
366
|
SessionMemory,
|
|
367
367
|
createSessionMemory
|
|
368
368
|
};
|
|
369
|
-
//# sourceMappingURL=chunk-
|
|
369
|
+
//# sourceMappingURL=chunk-JNZ3D5B5.js.map
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
getErrorMessage,
|
|
6
6
|
ok,
|
|
7
7
|
parseBoolEnv
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-Y742U2YM.js";
|
|
9
9
|
|
|
10
10
|
// src/cli/research-helpers-io.ts
|
|
11
11
|
import * as fs2 from "fs/promises";
|
|
@@ -156,4 +156,4 @@ export {
|
|
|
156
156
|
loadPapersRegistry,
|
|
157
157
|
savePapersRegistry
|
|
158
158
|
};
|
|
159
|
-
//# sourceMappingURL=chunk-
|
|
159
|
+
//# sourceMappingURL=chunk-K2AWJGQO.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveCliSlot
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6GYTTWNM.js";
|
|
4
4
|
import {
|
|
5
5
|
createLogger,
|
|
6
6
|
getTimeProvider,
|
|
7
7
|
isRateLimitText
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-Y742U2YM.js";
|
|
9
9
|
|
|
10
10
|
// src/pipeline/expert-bridge.ts
|
|
11
11
|
function resolveCliFromModelString(model) {
|
|
@@ -21,7 +21,7 @@ async function getMcpConfigPath() {
|
|
|
21
21
|
if (cachedMcpConfigPath !== null) return cachedMcpConfigPath;
|
|
22
22
|
mcpConfigInitPromise ??= (async () => {
|
|
23
23
|
try {
|
|
24
|
-
const { generateMcpConfig } = await import("./child-mcp-config-
|
|
24
|
+
const { generateMcpConfig } = await import("./child-mcp-config-ORXLS5HP.js");
|
|
25
25
|
const config = await generateMcpConfig();
|
|
26
26
|
cachedMcpConfigPath = config.configPath;
|
|
27
27
|
cachedMcpConfigCleanup = config.cleanup;
|
|
@@ -93,8 +93,8 @@ var routerInitPromise = null;
|
|
|
93
93
|
async function getRouter() {
|
|
94
94
|
if (cachedRouter !== null) return cachedRouter;
|
|
95
95
|
routerInitPromise ??= (async () => {
|
|
96
|
-
const { createAllAdapters } = await import("./factory-
|
|
97
|
-
const { createCompositeRouter } = await import("./composite-router-
|
|
96
|
+
const { createAllAdapters } = await import("./factory-3BZDQQYM.js");
|
|
97
|
+
const { createCompositeRouter } = await import("./composite-router-GE24MYPP.js");
|
|
98
98
|
const adapters = createAllAdapters();
|
|
99
99
|
if (adapters.size === 0) {
|
|
100
100
|
routerInitPromise = null;
|
|
@@ -102,7 +102,7 @@ async function getRouter() {
|
|
|
102
102
|
}
|
|
103
103
|
cachedRouter = adaptCompositeRouter(createCompositeRouter(adapters));
|
|
104
104
|
try {
|
|
105
|
-
const { createCliCircuitBreakerIntegration } = await import("./cli-circuit-breaker-
|
|
105
|
+
const { createCliCircuitBreakerIntegration } = await import("./cli-circuit-breaker-5FYJDS5O.js");
|
|
106
106
|
cachedCircuitBreaker = createCliCircuitBreakerIntegration([...adapters.values()]);
|
|
107
107
|
} catch (error) {
|
|
108
108
|
const msg = error instanceof Error ? error.message : String(error);
|
|
@@ -213,4 +213,4 @@ export {
|
|
|
213
213
|
tokenSplitFromUsage,
|
|
214
214
|
executeExpert
|
|
215
215
|
};
|
|
216
|
-
//# sourceMappingURL=chunk-
|
|
216
|
+
//# sourceMappingURL=chunk-KJWD2V4K.js.map
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
lookupInTreeCapability,
|
|
14
14
|
ok,
|
|
15
15
|
resolveRetryAfterMs
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-Y742U2YM.js";
|
|
17
17
|
|
|
18
18
|
// src/config/model-parameter-support.ts
|
|
19
19
|
function parseClaudeMajorMinor(bareId) {
|
|
@@ -834,4 +834,4 @@ export {
|
|
|
834
834
|
DEFAULT_COLLECT_STREAM_MAX_CHUNKS,
|
|
835
835
|
collectStream
|
|
836
836
|
};
|
|
837
|
-
//# sourceMappingURL=chunk-
|
|
837
|
+
//# sourceMappingURL=chunk-LVYRGNOC.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/version.ts"],"sourcesContent":["/**\n * nexus-agents - Version constant\n *\n * Injected at build time via tsup define from package.json.\n * Do NOT edit this value manually — it is replaced during build.\n */\n\ndeclare const __NEXUS_VERSION__: string;\n\nexport const VERSION: string = typeof __NEXUS_VERSION__ !== 'undefined' ? __NEXUS_VERSION__ : 'dev';\n"],"mappings":";AASO,IAAM,UAAkB,OAA2C,
|
|
1
|
+
{"version":3,"sources":["../src/version.ts"],"sourcesContent":["/**\n * nexus-agents - Version constant\n *\n * Injected at build time via tsup define from package.json.\n * Do NOT edit this value manually — it is replaced during build.\n */\n\ndeclare const __NEXUS_VERSION__: string;\n\nexport const VERSION: string = typeof __NEXUS_VERSION__ !== 'undefined' ? __NEXUS_VERSION__ : 'dev';\n"],"mappings":";AASO,IAAM,UAAkB,OAA2C,UAAoB;","names":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
VERSION
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MNG6VKJP.js";
|
|
4
4
|
import {
|
|
5
5
|
emitClawGuardViolation
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6Q3KSZVI.js";
|
|
7
7
|
import {
|
|
8
8
|
CACHE_TIMEOUTS,
|
|
9
9
|
MCP_TIMEOUTS,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
getTimeProvider,
|
|
20
20
|
ok,
|
|
21
21
|
resolveToolClassGuardMs
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-Y742U2YM.js";
|
|
23
23
|
import {
|
|
24
24
|
getNexusDataDir
|
|
25
25
|
} from "./chunk-OGHEKPLD.js";
|
|
@@ -338,7 +338,11 @@ var PolicyFirewall = class {
|
|
|
338
338
|
return {
|
|
339
339
|
allowed: true,
|
|
340
340
|
reason: `[WARN MODE] Would be denied: ${decision.reason}`,
|
|
341
|
-
ruleName: rule.name
|
|
341
|
+
ruleName: rule.name,
|
|
342
|
+
// The evaluator is the only place that KNOWS this was a denial the mode
|
|
343
|
+
// overrode; saying so explicitly is what lets the audit path record it
|
|
344
|
+
// without inferring the fact from other fields (#4991).
|
|
345
|
+
overriddenByWarnMode: true
|
|
342
346
|
};
|
|
343
347
|
}
|
|
344
348
|
return denialDecision;
|
|
@@ -765,6 +769,79 @@ function stagePolicyFirewallForRollout(firewall, logger) {
|
|
|
765
769
|
return firewall;
|
|
766
770
|
}
|
|
767
771
|
|
|
772
|
+
// src/mcp/middleware/would-deny-sampler.ts
|
|
773
|
+
var MAX_TRACKED_PAIRS = 500;
|
|
774
|
+
var IDLE_RESET_MS = 10 * 60 * 1e3;
|
|
775
|
+
var occurrences = /* @__PURE__ */ new Map();
|
|
776
|
+
function pairKey(toolName, ruleName) {
|
|
777
|
+
return `${toolName}::${ruleName ?? "(unnamed rule)"}`;
|
|
778
|
+
}
|
|
779
|
+
function isPowerOfTwo(n) {
|
|
780
|
+
return n > 0 && (n & n - 1) === 0;
|
|
781
|
+
}
|
|
782
|
+
function sampleWouldDeny(toolName, ruleName) {
|
|
783
|
+
if (occurrences.size >= MAX_TRACKED_PAIRS) occurrences.clear();
|
|
784
|
+
const now = getTimeProvider().now();
|
|
785
|
+
const key = pairKey(toolName, ruleName);
|
|
786
|
+
const prior = occurrences.get(key);
|
|
787
|
+
const stale = prior !== void 0 && now - prior.lastSeenMs > IDLE_RESET_MS;
|
|
788
|
+
const occurrence = prior === void 0 || stale ? 1 : prior.count + 1;
|
|
789
|
+
occurrences.set(key, { count: occurrence, lastSeenMs: now });
|
|
790
|
+
return { emit: isPowerOfTwo(occurrence), occurrence };
|
|
791
|
+
}
|
|
792
|
+
function describeOccurrence(occurrence) {
|
|
793
|
+
if (occurrence <= 1) return "";
|
|
794
|
+
return ` (occurrence ${String(occurrence)}; intermediate occurrences of this rule were sampled out)`;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
// src/mcp/middleware/policy-audit-emit.ts
|
|
798
|
+
function recordPolicyVerdict(config, requestContext, verdict, ruleName) {
|
|
799
|
+
const auditLogger = config.auditLogger;
|
|
800
|
+
if (!auditLogger) return;
|
|
801
|
+
if (verdict !== "would_deny") {
|
|
802
|
+
emitPolicyAudit({
|
|
803
|
+
auditLogger,
|
|
804
|
+
toolName: config.toolName,
|
|
805
|
+
ctx: requestContext,
|
|
806
|
+
decision: verdict,
|
|
807
|
+
reason: "policy denied"
|
|
808
|
+
});
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
811
|
+
const sample = sampleWouldDeny(config.toolName, ruleName);
|
|
812
|
+
if (!sample.emit) return;
|
|
813
|
+
emitPolicyAudit({
|
|
814
|
+
auditLogger,
|
|
815
|
+
toolName: config.toolName,
|
|
816
|
+
ctx: requestContext,
|
|
817
|
+
decision: verdict,
|
|
818
|
+
reason: `policy would have denied (warn mode)${describeOccurrence(sample.occurrence)}`,
|
|
819
|
+
occurrence: sample.occurrence
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
function emitPolicyAudit({
|
|
823
|
+
auditLogger,
|
|
824
|
+
toolName,
|
|
825
|
+
ctx,
|
|
826
|
+
decision,
|
|
827
|
+
reason,
|
|
828
|
+
occurrence
|
|
829
|
+
}) {
|
|
830
|
+
const actor = actorFromContext(ctx);
|
|
831
|
+
auditLogger.logPolicyDecision({
|
|
832
|
+
policyName: "default",
|
|
833
|
+
decision,
|
|
834
|
+
reason,
|
|
835
|
+
toolName,
|
|
836
|
+
actor,
|
|
837
|
+
requestId: ctx.requestId,
|
|
838
|
+
// Typed and queryable, not only prose in `reason` (#5228 review): a
|
|
839
|
+
// consumer counting records must be able to see that 14 records stand for
|
|
840
|
+
// 10,000 occurrences without parsing a sentence.
|
|
841
|
+
...occurrence === void 0 ? {} : { occurrence }
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
|
|
768
845
|
// src/mcp/middleware/secure-handler.ts
|
|
769
846
|
function rateLimitError(nextTokenMs) {
|
|
770
847
|
return toolStructuredError({
|
|
@@ -845,15 +922,26 @@ function checkPolicy(opts) {
|
|
|
845
922
|
reason: decision.reason,
|
|
846
923
|
ruleName: decision.ruleName
|
|
847
924
|
});
|
|
848
|
-
return
|
|
925
|
+
return {
|
|
926
|
+
result: policyDeniedError(decision.reason, opts.requestId),
|
|
927
|
+
verdict: "deny",
|
|
928
|
+
ruleName: decision.ruleName
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
if (decision.overriddenByWarnMode === true) {
|
|
932
|
+
opts.logger.debug("Policy would have denied (warn mode)", {
|
|
933
|
+
reason: decision.reason,
|
|
934
|
+
ruleName: decision.ruleName
|
|
935
|
+
});
|
|
936
|
+
return { result: null, verdict: "would_deny", ruleName: decision.ruleName };
|
|
849
937
|
}
|
|
850
938
|
opts.logger.debug("Policy check passed", { reason: decision.reason });
|
|
851
|
-
return null;
|
|
939
|
+
return { result: null, verdict: null };
|
|
852
940
|
}
|
|
853
941
|
function runPolicyCheck(config, sanitizedArgs, mode, logger, requestContext) {
|
|
854
942
|
const firewall = config.policyFirewall ?? getGlobalPolicyFirewall();
|
|
855
|
-
if (!firewall) return null;
|
|
856
|
-
const
|
|
943
|
+
if (!firewall) return { error: null, nearMiss: false };
|
|
944
|
+
const { result, verdict, ruleName } = checkPolicy({
|
|
857
945
|
firewall,
|
|
858
946
|
toolName: config.toolName,
|
|
859
947
|
args: sanitizedArgs,
|
|
@@ -862,10 +950,10 @@ function runPolicyCheck(config, sanitizedArgs, mode, logger, requestContext) {
|
|
|
862
950
|
logger,
|
|
863
951
|
requestId: requestContext.requestId
|
|
864
952
|
});
|
|
865
|
-
if (
|
|
866
|
-
|
|
953
|
+
if (verdict !== null && config.auditLogger) {
|
|
954
|
+
recordPolicyVerdict(config, requestContext, verdict, ruleName);
|
|
867
955
|
}
|
|
868
|
-
return
|
|
956
|
+
return { error: result, nearMiss: verdict === "would_deny" };
|
|
869
957
|
}
|
|
870
958
|
async function executeHandler(handler, args, ctx, logger, logLifecycle) {
|
|
871
959
|
const startTime = getTimeProvider().now();
|
|
@@ -879,36 +967,25 @@ async function executeHandler(handler, args, ctx, logger, logLifecycle) {
|
|
|
879
967
|
}
|
|
880
968
|
return result;
|
|
881
969
|
}
|
|
882
|
-
function emitToolAudit(
|
|
970
|
+
function emitToolAudit({
|
|
971
|
+
auditLogger,
|
|
972
|
+
toolName,
|
|
973
|
+
ctx,
|
|
974
|
+
outcome,
|
|
975
|
+
durationMs,
|
|
976
|
+
nearMiss
|
|
977
|
+
}) {
|
|
883
978
|
const actor = actorFromContext(ctx);
|
|
884
|
-
const outcome = resultToOutcome(result.isError, false);
|
|
885
979
|
auditLogger.logToolInvocation({
|
|
886
980
|
toolName,
|
|
887
981
|
outcome,
|
|
888
982
|
actor,
|
|
889
983
|
requestId: ctx.requestId,
|
|
890
|
-
durationMs
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
auditLogger.logToolInvocation({
|
|
896
|
-
toolName,
|
|
897
|
-
outcome: "error",
|
|
898
|
-
actor,
|
|
899
|
-
requestId: ctx.requestId,
|
|
900
|
-
durationMs
|
|
901
|
-
});
|
|
902
|
-
}
|
|
903
|
-
function emitPolicyAudit(auditLogger, toolName, ctx, reason) {
|
|
904
|
-
const actor = actorFromContext(ctx);
|
|
905
|
-
auditLogger.logPolicyDecision({
|
|
906
|
-
policyName: "default",
|
|
907
|
-
decision: "deny",
|
|
908
|
-
reason,
|
|
909
|
-
toolName,
|
|
910
|
-
actor,
|
|
911
|
-
requestId: ctx.requestId
|
|
984
|
+
durationMs,
|
|
985
|
+
// The fact the sampler must never suppress: this call EXECUTED and a rule
|
|
986
|
+
// would have denied it. The policy record carries the detail and may be
|
|
987
|
+
// sampled; this says the action itself was not clean, on every occurrence.
|
|
988
|
+
...nearMiss ? { policyDecision: "would_deny" } : {}
|
|
912
989
|
});
|
|
913
990
|
}
|
|
914
991
|
function emitRateLimitAudit(auditLogger, toolName, ctx) {
|
|
@@ -937,23 +1014,23 @@ function checkSecurityTier(config, sanitizeResult, logger) {
|
|
|
937
1014
|
}
|
|
938
1015
|
function runPreChecks(config, args, mode, requestContext, logger) {
|
|
939
1016
|
const sizeResult = checkInputSize(args, logger, requestContext.requestId);
|
|
940
|
-
if (sizeResult) return { error: sizeResult, sanitizedArgs: args };
|
|
1017
|
+
if (sizeResult) return { error: sizeResult, sanitizedArgs: args, nearMiss: false };
|
|
941
1018
|
const sanitizeResult = sanitizeToolInput(args);
|
|
942
1019
|
logSanitizationResult(sanitizeResult, logger, config.toolName);
|
|
943
1020
|
const sanitizedArgs = sanitizeResult.wasModified ? sanitizeResult.sanitized : args;
|
|
944
1021
|
const tierError = checkSecurityTier(config, sanitizeResult, logger);
|
|
945
|
-
if (tierError !== null) return { error: tierError, sanitizedArgs };
|
|
1022
|
+
if (tierError !== null) return { error: tierError, sanitizedArgs, nearMiss: false };
|
|
946
1023
|
if (config.rateLimiter) {
|
|
947
1024
|
const rlResult = checkRateLimit(config.rateLimiter, logger);
|
|
948
1025
|
if (rlResult) {
|
|
949
1026
|
if (config.auditLogger)
|
|
950
1027
|
emitRateLimitAudit(config.auditLogger, config.toolName, requestContext);
|
|
951
|
-
return { error: rlResult, sanitizedArgs };
|
|
1028
|
+
return { error: rlResult, sanitizedArgs, nearMiss: false };
|
|
952
1029
|
}
|
|
953
1030
|
}
|
|
954
|
-
const
|
|
955
|
-
if (
|
|
956
|
-
return { error: null, sanitizedArgs };
|
|
1031
|
+
const policy = runPolicyCheck(config, sanitizedArgs, mode, logger, requestContext);
|
|
1032
|
+
if (policy.error) return { error: policy.error, sanitizedArgs, nearMiss: policy.nearMiss };
|
|
1033
|
+
return { error: null, sanitizedArgs, nearMiss: policy.nearMiss };
|
|
957
1034
|
}
|
|
958
1035
|
function createSecureHandler(handler, config) {
|
|
959
1036
|
const logger = config.logger ?? createLogger({ tool: config.toolName });
|
|
@@ -970,17 +1047,16 @@ function createSecureHandler(handler, config) {
|
|
|
970
1047
|
if (inherited === void 0) {
|
|
971
1048
|
requestLogger.info("Tool invocation started");
|
|
972
1049
|
}
|
|
973
|
-
const {
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
requestLogger
|
|
979
|
-
);
|
|
1050
|
+
const {
|
|
1051
|
+
error: preCheckError,
|
|
1052
|
+
sanitizedArgs,
|
|
1053
|
+
nearMiss
|
|
1054
|
+
} = runPreChecks(config, args, mode, requestContext, requestLogger);
|
|
980
1055
|
if (preCheckError) return preCheckError;
|
|
981
1056
|
return executeAndAudit(handler, sanitizedArgs, config, {
|
|
982
1057
|
requestContext,
|
|
983
1058
|
requestLogger,
|
|
1059
|
+
nearMiss,
|
|
984
1060
|
logLifecycle: inherited === void 0
|
|
985
1061
|
});
|
|
986
1062
|
};
|
|
@@ -998,25 +1074,28 @@ async function executeAndAudit(handler, sanitizedArgs, config, invocation) {
|
|
|
998
1074
|
);
|
|
999
1075
|
sanitizeToolResult(result, requestLogger);
|
|
1000
1076
|
if (config.auditLogger) {
|
|
1001
|
-
emitToolAudit(
|
|
1002
|
-
config.auditLogger,
|
|
1003
|
-
config.toolName,
|
|
1004
|
-
requestContext,
|
|
1005
|
-
result,
|
|
1006
|
-
getTimeProvider().now() - execStartTime
|
|
1007
|
-
|
|
1077
|
+
emitToolAudit({
|
|
1078
|
+
auditLogger: config.auditLogger,
|
|
1079
|
+
toolName: config.toolName,
|
|
1080
|
+
ctx: requestContext,
|
|
1081
|
+
outcome: resultToOutcome(result.isError, false),
|
|
1082
|
+
durationMs: getTimeProvider().now() - execStartTime,
|
|
1083
|
+
nearMiss: invocation.nearMiss
|
|
1084
|
+
});
|
|
1008
1085
|
}
|
|
1009
1086
|
return result;
|
|
1010
1087
|
} catch (error) {
|
|
1011
1088
|
const rawMessage = error instanceof Error ? error.message : "Unknown error";
|
|
1012
1089
|
requestLogger.error("Tool execution failed", error instanceof Error ? error : void 0);
|
|
1013
1090
|
if (config.auditLogger) {
|
|
1014
|
-
|
|
1015
|
-
config.auditLogger,
|
|
1016
|
-
config.toolName,
|
|
1017
|
-
requestContext,
|
|
1018
|
-
|
|
1019
|
-
|
|
1091
|
+
emitToolAudit({
|
|
1092
|
+
auditLogger: config.auditLogger,
|
|
1093
|
+
toolName: config.toolName,
|
|
1094
|
+
ctx: requestContext,
|
|
1095
|
+
outcome: "error",
|
|
1096
|
+
durationMs: getTimeProvider().now() - execStartTime,
|
|
1097
|
+
nearMiss: invocation.nearMiss
|
|
1098
|
+
});
|
|
1020
1099
|
}
|
|
1021
1100
|
const sanitized = sanitizeOutput(rawMessage, requestLogger);
|
|
1022
1101
|
return internalError(sanitized, requestContext.requestId);
|
|
@@ -2135,4 +2214,4 @@ export {
|
|
|
2135
2214
|
VOTING_THRESHOLDS,
|
|
2136
2215
|
ConsensusMetricsSchema
|
|
2137
2216
|
};
|
|
2138
|
-
//# sourceMappingURL=chunk-
|
|
2217
|
+
//# sourceMappingURL=chunk-PDMWQ2NK.js.map
|