nexus-agents 2.34.0 → 2.41.0

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.
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  VERSION,
6
6
  initDataDirectories
7
- } from "./chunk-YW5QDPGU.js";
7
+ } from "./chunk-CNQ5WLHD.js";
8
8
  import {
9
9
  CLI_SUBPROCESS_TIMEOUTS,
10
10
  createLogger,
@@ -1580,4 +1580,4 @@ export {
1580
1580
  setupCommand,
1581
1581
  setupCommandAsync
1582
1582
  };
1583
- //# sourceMappingURL=chunk-QOULVKG6.js.map
1583
+ //# sourceMappingURL=chunk-7FZV43MB.js.map
@@ -24,7 +24,7 @@ import {
24
24
  } from "./chunk-CLYZ7FWP.js";
25
25
 
26
26
  // src/version.ts
27
- var VERSION = true ? "2.34.0" : "dev";
27
+ var VERSION = true ? "2.41.0" : "dev";
28
28
 
29
29
  // src/cli/setup-data-dir.ts
30
30
  import { mkdirSync, existsSync as existsSync2 } from "fs";
@@ -758,7 +758,7 @@ async function runDoctorFix(result) {
758
758
  writeLine2("\u2500".repeat(40));
759
759
  let fixCount = 0;
760
760
  if (!result.dataDirectory.rootExists || result.dataDirectory.subdirectories.some((d) => !d.exists || !d.writable)) {
761
- const { runSetup } = await import("./setup-command-N6MTXKV3.js");
761
+ const { runSetup } = await import("./setup-command-BJEGQZ33.js");
762
762
  const setupResult = runSetup({
763
763
  skipMcp: true,
764
764
  skipRules: true,
@@ -836,4 +836,4 @@ export {
836
836
  startStdioServer,
837
837
  closeServer
838
838
  };
839
- //# sourceMappingURL=chunk-YW5QDPGU.js.map
839
+ //# sourceMappingURL=chunk-CNQ5WLHD.js.map
@@ -795,6 +795,160 @@ function contextForLogging(ctx) {
795
795
  };
796
796
  }
797
797
 
798
+ // src/security/access-constraint-deriver/denylist.ts
799
+ var UNBYPASSABLE_PATH_PATTERNS = [
800
+ // Environment files
801
+ ".env",
802
+ ".env.*",
803
+ "**/.env",
804
+ "**/.env.*",
805
+ // SSH credentials
806
+ "~/.ssh/**",
807
+ "**/ssh/id_*",
808
+ "**/*_rsa",
809
+ "**/*_ed25519",
810
+ "**/*.pem",
811
+ // Cloud credentials
812
+ "~/.aws/**",
813
+ "~/.azure/**",
814
+ "~/.gcp/**",
815
+ "~/.config/gcloud/**",
816
+ "~/.kube/config",
817
+ // Unix secret files
818
+ "/etc/shadow",
819
+ "/etc/sudoers",
820
+ "/etc/sudoers.d/**",
821
+ // Common secret file patterns
822
+ "**/secrets.*",
823
+ "**/credentials.*",
824
+ "**/private_key.*",
825
+ "**/id_rsa*"
826
+ ];
827
+ var UNBYPASSABLE_TOOL_NAMES = [
828
+ // Destructive git operations
829
+ "git_push_force",
830
+ "git_reset_hard",
831
+ "git_branch_delete_force",
832
+ "git_clean_force",
833
+ // Destructive filesystem
834
+ "rm_recursive_force",
835
+ "chmod_recursive",
836
+ // Identity / auth mutations
837
+ "ssh_add_key",
838
+ "gpg_add_key",
839
+ "npm_publish_force",
840
+ // Remote destruction
841
+ "github_repo_delete",
842
+ "github_org_transfer",
843
+ "aws_account_close"
844
+ ];
845
+ function compileGlobToRegex(pattern) {
846
+ const pat = pattern.toLowerCase();
847
+ const escaped = pat.replace(/[\\.+^$()|[\]{}]/g, "\\$&").replace(/\*\*/g, "__DOUBLESTAR__").replace(/\*/g, "[^/]*").replace(/__DOUBLESTAR__/g, ".*");
848
+ const anchored = escaped.startsWith("~/") ? `(^|/)${escaped.slice(2)}$` : escaped.startsWith("/") ? `^${escaped}$` : `(^|/)${escaped}$`;
849
+ return new RegExp(anchored);
850
+ }
851
+ var COMPILED_PATH_PATTERNS = UNBYPASSABLE_PATH_PATTERNS.map((pattern) => ({
852
+ pattern,
853
+ regex: compileGlobToRegex(pattern)
854
+ }));
855
+ function isPathDenied(path4) {
856
+ const normalized = path4.toLowerCase();
857
+ return COMPILED_PATH_PATTERNS.some((c) => c.regex.test(normalized));
858
+ }
859
+ function isToolDenied(toolName) {
860
+ return UNBYPASSABLE_TOOL_NAMES.includes(toolName);
861
+ }
862
+
863
+ // src/security/access-constraint-deriver/enforcer.ts
864
+ function checkAccess(toolName, policy, args) {
865
+ if (isToolDenied(toolName)) {
866
+ return {
867
+ decision: "deny",
868
+ reason: `tool "${toolName}" is on the unbypassable deny-tool list`,
869
+ matchedRule: "unbypassable:tool"
870
+ };
871
+ }
872
+ if (typeof args?.path === "string" && args.path.length > 0 && isPathDenied(args.path)) {
873
+ return {
874
+ decision: "deny",
875
+ reason: `path "${args.path}" is on the unbypassable deny-path list`,
876
+ matchedRule: "unbypassable:path"
877
+ };
878
+ }
879
+ if (policy.allowedTools === "*") return { decision: "allow" };
880
+ if (policy.allowedTools.includes(toolName)) return { decision: "allow" };
881
+ if (policy.mode === "audit") {
882
+ return {
883
+ decision: "log-and-allow",
884
+ warning: `tool "${toolName}" not in derived policy (audit mode)`
885
+ };
886
+ }
887
+ return {
888
+ decision: "deny",
889
+ reason: `tool "${toolName}" not in derived policy`,
890
+ matchedRule: "allowedTools"
891
+ };
892
+ }
893
+
894
+ // src/security/access-constraint-deriver/mcp-guard.ts
895
+ import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
896
+ var accessPolicyStorage = new AsyncLocalStorage2();
897
+ function withAccessPolicy(policy, fn) {
898
+ return accessPolicyStorage.run(policy, fn);
899
+ }
900
+ function getActivePolicy() {
901
+ return accessPolicyStorage.getStore();
902
+ }
903
+ function denyToToolResult(decision, requestId) {
904
+ return {
905
+ isError: true,
906
+ content: [
907
+ {
908
+ type: "text",
909
+ text: `access denied: ${decision.reason} (rule: ${decision.matchedRule}, request: ${requestId})`
910
+ }
911
+ ]
912
+ };
913
+ }
914
+
915
+ // src/security/access-constraint-deriver/chain-adapter.ts
916
+ function toGuardArgs(args) {
917
+ if (typeof args !== "object" || args === null) return void 0;
918
+ const path4 = args["path"];
919
+ return typeof path4 === "string" && path4.length > 0 ? { path: path4 } : void 0;
920
+ }
921
+ function createAccessPolicyChainMiddleware(toolName) {
922
+ return async (args, ctx, next) => {
923
+ const policy = getActivePolicy();
924
+ if (policy === void 0 || policy.mode === "off") {
925
+ return next(args, ctx);
926
+ }
927
+ const decision = checkAccess(toolName, policy, toGuardArgs(args));
928
+ if (decision.decision === "allow") {
929
+ return next(args, ctx);
930
+ }
931
+ if (decision.decision === "log-and-allow") {
932
+ ctx.logger.warn("access-policy: audit violation", {
933
+ tool: toolName,
934
+ warning: decision.warning,
935
+ policySource: policy.source,
936
+ requestId: ctx.requestContext.requestId
937
+ });
938
+ return next(args, ctx);
939
+ }
940
+ ctx.logger.info("access-policy: tool call denied", {
941
+ tool: toolName,
942
+ reason: decision.reason,
943
+ matchedRule: decision.matchedRule,
944
+ policySource: policy.source,
945
+ mode: policy.mode,
946
+ requestId: ctx.requestContext.requestId
947
+ });
948
+ return denyToToolResult(decision, ctx.requestContext.requestId);
949
+ };
950
+ }
951
+
798
952
  // src/mcp/middleware/middleware-chain.ts
799
953
  function errorResult(message, requestId) {
800
954
  return {
@@ -939,6 +1093,11 @@ function addTimeoutMiddleware(middlewares, config, skip2) {
939
1093
  middlewares.push(createTimeoutMiddleware(guard, config.toolName));
940
1094
  }
941
1095
  }
1096
+ function addAccessPolicyMiddleware(middlewares, config, skip2) {
1097
+ if (skip2.accessPolicy !== true) {
1098
+ middlewares.push(createAccessPolicyChainMiddleware(config.toolName));
1099
+ }
1100
+ }
942
1101
  function buildMiddlewareStack(config) {
943
1102
  const skip2 = config.skip ?? {};
944
1103
  const middlewares = [];
@@ -947,6 +1106,7 @@ function buildMiddlewareStack(config) {
947
1106
  addRateLimitMiddleware(middlewares, config, skip2);
948
1107
  addValidationMiddleware(middlewares, config, skip2);
949
1108
  addPolicyMiddleware(middlewares, config, skip2);
1109
+ addAccessPolicyMiddleware(middlewares, config, skip2);
950
1110
  addTimeoutMiddleware(middlewares, config, skip2);
951
1111
  return middlewares;
952
1112
  }
@@ -12639,6 +12799,7 @@ export {
12639
12799
  createMcpNotifier,
12640
12800
  NOOP_NOTIFIER,
12641
12801
  withProgressHeartbeat,
12802
+ withAccessPolicy,
12642
12803
  getToolTimeout,
12643
12804
  wrapToolWithTimeout,
12644
12805
  toSdkCallback,
@@ -12718,4 +12879,4 @@ export {
12718
12879
  CONSENSUS_VOTE_OUTPUT_SCHEMA,
12719
12880
  registerConsensusVoteTool
12720
12881
  };
12721
- //# sourceMappingURL=chunk-A6Q2NRXT.js.map
12882
+ //# sourceMappingURL=chunk-SYS7LUWC.js.map