nexus-agents 4.26.6 → 4.26.8
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/{chunk-XCJW3MZC.js → chunk-5ZLAA73M.js} +2 -2
- package/dist/{chunk-O3DWYQ4Y.js → chunk-AU6QDTRD.js} +63 -17
- package/dist/chunk-AU6QDTRD.js.map +1 -0
- package/dist/{chunk-FOEWSYSN.js → chunk-D472Q66M.js} +2 -2
- package/dist/chunk-EXS7P2VP.js +7 -0
- package/dist/{chunk-3HVT3RY4.js → chunk-OXD4H42X.js} +6 -6
- package/dist/{chunk-3HVT3RY4.js.map → chunk-OXD4H42X.js.map} +1 -1
- package/dist/{chunk-GVD6K5FS.js → chunk-WFWB3MVD.js} +3 -3
- package/dist/cli.js +7 -7
- package/dist/{consensus-vote-BHNHDNGM.js → consensus-vote-ZDQFTMDT.js} +4 -4
- package/dist/{improvement-review-XUNTLWEJ.js → improvement-review-HXZA4BQY.js} +4 -4
- package/dist/index.d.ts +7 -2
- package/dist/index.js +7 -7
- package/dist/{setup-data-dir-OSD2RLLS.js → setup-data-dir-AUUPYRZO.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-64OC7AXT.js +0 -7
- package/dist/chunk-O3DWYQ4Y.js.map +0 -1
- /package/dist/{chunk-XCJW3MZC.js.map → chunk-5ZLAA73M.js.map} +0 -0
- /package/dist/{chunk-FOEWSYSN.js.map → chunk-D472Q66M.js.map} +0 -0
- /package/dist/{chunk-64OC7AXT.js.map → chunk-EXS7P2VP.js.map} +0 -0
- /package/dist/{chunk-GVD6K5FS.js.map → chunk-WFWB3MVD.js.map} +0 -0
- /package/dist/{consensus-vote-BHNHDNGM.js.map → consensus-vote-ZDQFTMDT.js.map} +0 -0
- /package/dist/{improvement-review-XUNTLWEJ.js.map → improvement-review-HXZA4BQY.js.map} +0 -0
- /package/dist/{setup-data-dir-OSD2RLLS.js.map → setup-data-dir-AUUPYRZO.js.map} +0 -0
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
toolSuccessStructured,
|
|
24
24
|
withProgressHeartbeat,
|
|
25
25
|
wrapToolWithTimeout
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-AU6QDTRD.js";
|
|
27
27
|
import {
|
|
28
28
|
assessPanelIndependence,
|
|
29
29
|
countDistinctModels,
|
|
@@ -6779,4 +6779,4 @@ export {
|
|
|
6779
6779
|
CONSENSUS_VOTE_TOOL_SCHEMA,
|
|
6780
6780
|
registerConsensusVoteTool
|
|
6781
6781
|
};
|
|
6782
|
-
//# sourceMappingURL=chunk-
|
|
6782
|
+
//# sourceMappingURL=chunk-5ZLAA73M.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
VERSION
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EXS7P2VP.js";
|
|
4
4
|
import {
|
|
5
5
|
emitClawGuardViolation
|
|
6
6
|
} from "./chunk-MJQVSJZB.js";
|
|
@@ -571,6 +571,7 @@ function toolError(message) {
|
|
|
571
571
|
}
|
|
572
572
|
|
|
573
573
|
// src/mcp/middleware/request-context.ts
|
|
574
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
574
575
|
import { randomBytes } from "crypto";
|
|
575
576
|
function generateRequestId() {
|
|
576
577
|
const bytes = randomBytes(8);
|
|
@@ -604,7 +605,7 @@ function deriveTrustTier(caller) {
|
|
|
604
605
|
function createRequestContext(options) {
|
|
605
606
|
const caller = options.caller ?? {};
|
|
606
607
|
const context = {
|
|
607
|
-
requestId: generateRequestId(),
|
|
608
|
+
requestId: options.inheritRequestId ?? generateRequestId(),
|
|
608
609
|
timestamp: formatTimestamp(),
|
|
609
610
|
toolName: options.toolName,
|
|
610
611
|
caller,
|
|
@@ -614,6 +615,21 @@ function createRequestContext(options) {
|
|
|
614
615
|
};
|
|
615
616
|
return Object.freeze(context);
|
|
616
617
|
}
|
|
618
|
+
var requestContextStorage = new AsyncLocalStorage();
|
|
619
|
+
function runWithRequestContext(context, fn) {
|
|
620
|
+
const holder = { context, settled: false };
|
|
621
|
+
return requestContextStorage.run(
|
|
622
|
+
holder,
|
|
623
|
+
() => fn().finally(() => {
|
|
624
|
+
holder.settled = true;
|
|
625
|
+
})
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
function getCurrentRequestContext() {
|
|
629
|
+
const holder = requestContextStorage.getStore();
|
|
630
|
+
if (holder === void 0 || holder.settled) return void 0;
|
|
631
|
+
return holder.context;
|
|
632
|
+
}
|
|
617
633
|
function contextForLogging(ctx) {
|
|
618
634
|
return {
|
|
619
635
|
requestId: ctx.requestId,
|
|
@@ -832,9 +848,10 @@ function runPolicyCheck(config, sanitizedArgs, mode, logger, requestContext) {
|
|
|
832
848
|
}
|
|
833
849
|
return pResult;
|
|
834
850
|
}
|
|
835
|
-
async function executeHandler(handler, args, ctx, logger) {
|
|
851
|
+
async function executeHandler(handler, args, ctx, logger, logLifecycle) {
|
|
836
852
|
const startTime = getTimeProvider().now();
|
|
837
853
|
const result = handler.length >= 2 ? await handler(args, ctx) : await handler(args);
|
|
854
|
+
if (!logLifecycle) return result;
|
|
838
855
|
const durationMs = getTimeProvider().now() - startTime;
|
|
839
856
|
if (result.isError === true) {
|
|
840
857
|
logger.warn("Tool execution completed with error", { durationMs });
|
|
@@ -927,9 +944,13 @@ function createSecureHandler(handler, config) {
|
|
|
927
944
|
toolName: config.toolName,
|
|
928
945
|
...config.callerInfo && { caller: config.callerInfo }
|
|
929
946
|
};
|
|
930
|
-
const
|
|
947
|
+
const ambient = getCurrentRequestContext();
|
|
948
|
+
const inherited = ambient?.toolName === config.toolName ? ambient : void 0;
|
|
949
|
+
const requestContext = inherited === void 0 ? createRequestContext(ctxOpts) : createRequestContext({ ...ctxOpts, inheritRequestId: inherited.requestId });
|
|
931
950
|
const requestLogger = logger.child(contextForLogging(requestContext));
|
|
932
|
-
|
|
951
|
+
if (inherited === void 0) {
|
|
952
|
+
requestLogger.info("Tool invocation started");
|
|
953
|
+
}
|
|
933
954
|
const { error: preCheckError, sanitizedArgs } = runPreChecks(
|
|
934
955
|
config,
|
|
935
956
|
args,
|
|
@@ -938,17 +959,23 @@ function createSecureHandler(handler, config) {
|
|
|
938
959
|
requestLogger
|
|
939
960
|
);
|
|
940
961
|
if (preCheckError) return preCheckError;
|
|
941
|
-
return executeAndAudit(handler, sanitizedArgs,
|
|
962
|
+
return executeAndAudit(handler, sanitizedArgs, config, {
|
|
963
|
+
requestContext,
|
|
964
|
+
requestLogger,
|
|
965
|
+
logLifecycle: inherited === void 0
|
|
966
|
+
});
|
|
942
967
|
};
|
|
943
968
|
}
|
|
944
|
-
async function executeAndAudit(handler, sanitizedArgs,
|
|
969
|
+
async function executeAndAudit(handler, sanitizedArgs, config, invocation) {
|
|
970
|
+
const { requestContext, requestLogger } = invocation;
|
|
945
971
|
const execStartTime = getTimeProvider().now();
|
|
946
972
|
try {
|
|
947
973
|
const result = await executeHandler(
|
|
948
974
|
handler,
|
|
949
975
|
sanitizedArgs,
|
|
950
976
|
{ requestContext, logger: requestLogger },
|
|
951
|
-
requestLogger
|
|
977
|
+
requestLogger,
|
|
978
|
+
invocation.logLifecycle
|
|
952
979
|
);
|
|
953
980
|
sanitizeToolResult(result, requestLogger);
|
|
954
981
|
if (config.auditLogger) {
|
|
@@ -978,7 +1005,7 @@ async function executeAndAudit(handler, sanitizedArgs, requestContext, requestLo
|
|
|
978
1005
|
}
|
|
979
1006
|
|
|
980
1007
|
// src/mcp/mcp-notifier.ts
|
|
981
|
-
import { AsyncLocalStorage } from "async_hooks";
|
|
1008
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
982
1009
|
var internalLogger = createLogger({ component: "mcp-notifier" });
|
|
983
1010
|
function createMcpNotifier(server) {
|
|
984
1011
|
function send(level, logger, data) {
|
|
@@ -1015,8 +1042,8 @@ var NOOP_NOTIFIER = {
|
|
|
1015
1042
|
debug: () => void 0,
|
|
1016
1043
|
warn: () => void 0
|
|
1017
1044
|
};
|
|
1018
|
-
var progressContextStorage = new
|
|
1019
|
-
var abortSignalStorage = new
|
|
1045
|
+
var progressContextStorage = new AsyncLocalStorage2();
|
|
1046
|
+
var abortSignalStorage = new AsyncLocalStorage2();
|
|
1020
1047
|
async function withProgressHeartbeat(toolName, notifier, operation, intervalMs = 15e3) {
|
|
1021
1048
|
const startTime = Date.now();
|
|
1022
1049
|
let beatCount = 0;
|
|
@@ -1328,6 +1355,12 @@ function checkAccess(toolName, policy, args) {
|
|
|
1328
1355
|
};
|
|
1329
1356
|
}
|
|
1330
1357
|
if (policy.allowedTools === "*") return { decision: "allow" };
|
|
1358
|
+
if (policy.allowedTools.length === 0) {
|
|
1359
|
+
return {
|
|
1360
|
+
decision: "unmeasured",
|
|
1361
|
+
reason: `allowlist arm did not run for tool "${toolName}": the derived policy (source "${policy.source}", mode "${policy.mode}") carries an empty allowedTools, and no producer emits tool names (#5022)`
|
|
1362
|
+
};
|
|
1363
|
+
}
|
|
1331
1364
|
if (policy.allowedTools.includes(toolName)) return { decision: "allow" };
|
|
1332
1365
|
return decideOnViolation(toolName, policy.mode);
|
|
1333
1366
|
}
|
|
@@ -1359,9 +1392,9 @@ function decideOnViolation(toolName, mode) {
|
|
|
1359
1392
|
}
|
|
1360
1393
|
|
|
1361
1394
|
// src/security/access-constraint-deriver/mcp-guard.ts
|
|
1362
|
-
import { AsyncLocalStorage as
|
|
1363
|
-
var accessPolicyStorage = new
|
|
1364
|
-
var auditTrailStorage = new
|
|
1395
|
+
import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
1396
|
+
var accessPolicyStorage = new AsyncLocalStorage3();
|
|
1397
|
+
var auditTrailStorage = new AsyncLocalStorage3();
|
|
1365
1398
|
var MAX_WARNING_LEN = 500;
|
|
1366
1399
|
function withAuditTrail(trail, fn) {
|
|
1367
1400
|
return auditTrailStorage.run(trail, fn);
|
|
@@ -1417,6 +1450,16 @@ function createAccessPolicyChainMiddleware(toolName) {
|
|
|
1417
1450
|
if (decision.decision === "allow") {
|
|
1418
1451
|
return next(args, ctx);
|
|
1419
1452
|
}
|
|
1453
|
+
if (decision.decision === "unmeasured") {
|
|
1454
|
+
ctx.logger.info("access-policy: allowlist unmeasured", {
|
|
1455
|
+
tool: toolName,
|
|
1456
|
+
reason: decision.reason,
|
|
1457
|
+
policySource: policy.source,
|
|
1458
|
+
mode: policy.mode,
|
|
1459
|
+
requestId: ctx.requestContext.requestId
|
|
1460
|
+
});
|
|
1461
|
+
return next(args, ctx);
|
|
1462
|
+
}
|
|
1420
1463
|
if (decision.decision === "log-and-allow") {
|
|
1421
1464
|
ctx.logger.warn("access-policy: audit violation", {
|
|
1422
1465
|
tool: toolName,
|
|
@@ -1433,7 +1476,7 @@ function createAccessPolicyChainMiddleware(toolName) {
|
|
|
1433
1476
|
});
|
|
1434
1477
|
return next(args, ctx);
|
|
1435
1478
|
}
|
|
1436
|
-
ctx.logger.
|
|
1479
|
+
ctx.logger.warn("access-policy: tool call denied", {
|
|
1437
1480
|
tool: toolName,
|
|
1438
1481
|
reason: decision.reason,
|
|
1439
1482
|
matchedRule: decision.matchedRule,
|
|
@@ -1626,7 +1669,10 @@ function createMiddlewareChain(config) {
|
|
|
1626
1669
|
const requestContext = createRequestContext({ toolName: config.toolName });
|
|
1627
1670
|
const requestLogger = logger.child(contextForLogging(requestContext));
|
|
1628
1671
|
const ctx = { requestContext, logger: requestLogger };
|
|
1629
|
-
return
|
|
1672
|
+
return runWithRequestContext(
|
|
1673
|
+
requestContext,
|
|
1674
|
+
() => composed(args, ctx, (finalArgs, finalCtx) => handler(finalArgs, finalCtx))
|
|
1675
|
+
);
|
|
1630
1676
|
};
|
|
1631
1677
|
};
|
|
1632
1678
|
}
|
|
@@ -2068,4 +2114,4 @@ export {
|
|
|
2068
2114
|
VOTING_THRESHOLDS,
|
|
2069
2115
|
ConsensusMetricsSchema
|
|
2070
2116
|
};
|
|
2071
|
-
//# sourceMappingURL=chunk-
|
|
2117
|
+
//# sourceMappingURL=chunk-AU6QDTRD.js.map
|