nexus-agents 7.0.1 → 7.0.2

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.
@@ -0,0 +1,7 @@
1
+ // src/version.ts
2
+ var VERSION = true ? "7.0.2" : "dev";
3
+
4
+ export {
5
+ VERSION
6
+ };
7
+ //# sourceMappingURL=chunk-37JIYDVH.js.map
@@ -7,7 +7,7 @@ import {
7
7
  toolStructuredError,
8
8
  toolSuccessStructured,
9
9
  wrapToolWithTimeout
10
- } from "./chunk-PDMWQ2NK.js";
10
+ } from "./chunk-GAYSJGKD.js";
11
11
  import {
12
12
  JsonlStore,
13
13
  SECURITY_KEYWORDS,
@@ -2159,4 +2159,4 @@ export {
2159
2159
  runImprovementReview,
2160
2160
  registerImprovementReviewTool
2161
2161
  };
2162
- //# sourceMappingURL=chunk-6E2M3P5A.js.map
2162
+ //# sourceMappingURL=chunk-AGFXJUTS.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-MNG6VKJP.js";
3
+ } from "./chunk-37JIYDVH.js";
4
4
  import {
5
5
  emitClawGuardViolation
6
6
  } from "./chunk-6Q3KSZVI.js";
@@ -653,48 +653,50 @@ function measuredTrustTier(context) {
653
653
 
654
654
  // src/mcp/middleware/tool-input-sanitizer.ts
655
655
  var XML_INJECTION_PATTERN = /<\/?(system|human|assistant|instructions|user|prompt|context|tool_use|tool_result)\b[^>]*>/gi;
656
- var HIDDEN_INSTRUCTION_TRIGGER = /execute|delete|merge|apply/i;
657
- function hasHiddenInstruction(value) {
656
+ var INJECTION_DETECTORS = [
657
+ { name: "system_prompt_override", pattern: /ignore (?:all )?previous (?:instructions|rules)/i },
658
+ { name: "role_impersonation", pattern: /i(?:'m| am) the (?:repo |project )?(?:owner|admin)/i }
659
+ ];
660
+ function stripHtmlComments(value) {
658
661
  const OPEN = "<!--";
659
662
  const CLOSE = "-->";
663
+ let out = "";
660
664
  let from = 0;
665
+ let removed = 0;
661
666
  for (; ; ) {
662
667
  const open = value.indexOf(OPEN, from);
663
- if (open === -1) return false;
668
+ if (open === -1) break;
664
669
  const close = value.indexOf(CLOSE, open + OPEN.length);
665
- if (close === -1) return false;
666
- if (HIDDEN_INSTRUCTION_TRIGGER.test(value.slice(open + OPEN.length, close))) {
667
- return true;
668
- }
670
+ if (close === -1) break;
671
+ out += value.slice(from, open);
669
672
  from = close + CLOSE.length;
673
+ removed++;
670
674
  }
675
+ return { cleaned: removed === 0 ? value : out + value.slice(from), removed };
671
676
  }
672
- var INJECTION_DETECTORS = [
673
- { name: "system_prompt_override", pattern: /ignore (?:all )?previous (?:instructions|rules)/i },
674
- { name: "role_impersonation", pattern: /i(?:'m| am) the (?:repo |project )?(?:owner|admin)/i },
675
- // `hidden_instruction` is a scan, not a pattern — see hasHiddenInstruction.
676
- { name: "hidden_instruction", match: hasHiddenInstruction }
677
- ];
678
677
  function sanitizeString(value) {
679
678
  const MAX_PASSES = 5;
680
679
  let cleaned = value;
680
+ let commentsRemoved = 0;
681
681
  for (let pass = 0; pass < MAX_PASSES; pass++) {
682
682
  XML_INJECTION_PATTERN.lastIndex = 0;
683
- const next = cleaned.replace(XML_INJECTION_PATTERN, "");
684
- if (next === cleaned) break;
685
- cleaned = next;
683
+ const afterTags = cleaned.replace(XML_INJECTION_PATTERN, "");
684
+ const { cleaned: afterComments, removed } = stripHtmlComments(afterTags);
685
+ commentsRemoved += removed;
686
+ if (afterComments === cleaned) break;
687
+ cleaned = afterComments;
686
688
  }
687
- return { cleaned, modified: cleaned !== value };
689
+ return {
690
+ cleaned,
691
+ modified: cleaned !== value,
692
+ commentsRemoved
693
+ };
688
694
  }
689
695
  function detectPatterns(value) {
690
696
  const detected = [];
691
- for (const { name, pattern, match } of INJECTION_DETECTORS) {
692
- if (pattern !== void 0) {
693
- pattern.lastIndex = 0;
694
- if (pattern.test(value)) detected.push(name);
695
- } else if (match?.(value) === true) {
696
- detected.push(name);
697
- }
697
+ for (const { name, pattern } of INJECTION_DETECTORS) {
698
+ pattern.lastIndex = 0;
699
+ if (pattern.test(value)) detected.push(name);
698
700
  }
699
701
  return detected;
700
702
  }
@@ -704,8 +706,9 @@ function sanitizeValue(value, stats) {
704
706
  if (patterns.length > 0) {
705
707
  stats.patterns.push(...patterns);
706
708
  }
707
- const { cleaned, modified } = sanitizeString(value);
709
+ const { cleaned, modified, commentsRemoved } = sanitizeString(value);
708
710
  if (modified) stats.count++;
711
+ stats.commentsRemoved += commentsRemoved;
709
712
  return cleaned;
710
713
  }
711
714
  if (Array.isArray(value)) {
@@ -722,16 +725,23 @@ function sanitizeValue(value, stats) {
722
725
  }
723
726
  function sanitizeToolInput(args) {
724
727
  if (args === void 0 || args === null) {
725
- return { sanitized: args, wasModified: false, modifiedCount: 0, detectedPatterns: [] };
728
+ return {
729
+ sanitized: args,
730
+ wasModified: false,
731
+ modifiedCount: 0,
732
+ detectedPatterns: [],
733
+ commentsRemoved: 0
734
+ };
726
735
  }
727
- const stats = { count: 0, patterns: [] };
736
+ const stats = { count: 0, patterns: [], commentsRemoved: 0 };
728
737
  const sanitized = sanitizeValue(args, stats);
729
738
  const uniquePatterns = [...new Set(stats.patterns)];
730
739
  return {
731
740
  sanitized,
732
741
  wasModified: stats.count > 0,
733
742
  modifiedCount: stats.count,
734
- detectedPatterns: uniquePatterns
743
+ detectedPatterns: uniquePatterns,
744
+ commentsRemoved: stats.commentsRemoved
735
745
  };
736
746
  }
737
747
  function logSanitizationResult(result, logger, toolName) {
@@ -741,6 +751,12 @@ function logSanitizationResult(result, logger, toolName) {
741
751
  modifiedFields: result.modifiedCount
742
752
  });
743
753
  }
754
+ if (result.commentsRemoved > 0) {
755
+ logger.warn("Tool input sanitized \u2014 HTML comments removed", {
756
+ tool: toolName,
757
+ commentsRemoved: result.commentsRemoved
758
+ });
759
+ }
744
760
  if (result.detectedPatterns.length > 0) {
745
761
  logger.warn("Injection patterns detected in tool input", {
746
762
  tool: toolName,
@@ -2178,6 +2194,7 @@ export {
2178
2194
  logToolInvocationAudit,
2179
2195
  logPolicyAudit,
2180
2196
  logRateLimitAudit,
2197
+ sanitizeToolInput,
2181
2198
  defaultRetryable,
2182
2199
  coarsenFailureCategory,
2183
2200
  toolSuccess,
@@ -2214,4 +2231,4 @@ export {
2214
2231
  VOTING_THRESHOLDS,
2215
2232
  ConsensusMetricsSchema
2216
2233
  };
2217
- //# sourceMappingURL=chunk-PDMWQ2NK.js.map
2234
+ //# sourceMappingURL=chunk-GAYSJGKD.js.map