@node9/proxy 1.45.0 → 1.46.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.
package/dist/index.js CHANGED
@@ -2264,6 +2264,19 @@ function evaluateSmartConditions(args, rule) {
2264
2264
  });
2265
2265
  return mode === "any" ? results.some((r) => r) : results.every((r) => r);
2266
2266
  }
2267
+ var VERDICT_RANK = {
2268
+ allow: 0,
2269
+ review: 1,
2270
+ block: 2
2271
+ };
2272
+ function resolvePinned(matches) {
2273
+ if (matches.length === 0) return void 0;
2274
+ const pinned = matches.filter((r) => r.pinned);
2275
+ if (pinned.length === 0) return matches[0];
2276
+ return pinned.reduce(
2277
+ (best, r) => VERDICT_RANK[r.verdict] > VERDICT_RANK[best.verdict] ? r : best
2278
+ );
2279
+ }
2267
2280
  function tokenize2(toolName) {
2268
2281
  return toolName.toLowerCase().split(/[_.\-\s]+/).filter(Boolean);
2269
2282
  }
@@ -2376,9 +2389,10 @@ async function evaluatePolicy(config, toolName, args, context = {}, hooks = {})
2376
2389
  }
2377
2390
  }
2378
2391
  if (config.policy.smartRules.length > 0) {
2379
- const matchedRule = config.policy.smartRules.find(
2392
+ const matches = config.policy.smartRules.filter(
2380
2393
  (rule) => matchesPattern(toolName, rule.tool) && !(bashCommand !== null && rule.name && AST_FS_REGEX_RULES.has(rule.name)) && evaluateSmartConditions(args, rule)
2381
2394
  );
2395
+ const matchedRule = resolvePinned(matches);
2382
2396
  if (matchedRule) {
2383
2397
  if (matchedRule.verdict === "allow")
2384
2398
  return { decision: "allow", ruleName: matchedRule.name ?? matchedRule.tool };
package/dist/index.mjs CHANGED
@@ -2234,6 +2234,19 @@ function evaluateSmartConditions(args, rule) {
2234
2234
  });
2235
2235
  return mode === "any" ? results.some((r) => r) : results.every((r) => r);
2236
2236
  }
2237
+ var VERDICT_RANK = {
2238
+ allow: 0,
2239
+ review: 1,
2240
+ block: 2
2241
+ };
2242
+ function resolvePinned(matches) {
2243
+ if (matches.length === 0) return void 0;
2244
+ const pinned = matches.filter((r) => r.pinned);
2245
+ if (pinned.length === 0) return matches[0];
2246
+ return pinned.reduce(
2247
+ (best, r) => VERDICT_RANK[r.verdict] > VERDICT_RANK[best.verdict] ? r : best
2248
+ );
2249
+ }
2237
2250
  function tokenize2(toolName) {
2238
2251
  return toolName.toLowerCase().split(/[_.\-\s]+/).filter(Boolean);
2239
2252
  }
@@ -2346,9 +2359,10 @@ async function evaluatePolicy(config, toolName, args, context = {}, hooks = {})
2346
2359
  }
2347
2360
  }
2348
2361
  if (config.policy.smartRules.length > 0) {
2349
- const matchedRule = config.policy.smartRules.find(
2362
+ const matches = config.policy.smartRules.filter(
2350
2363
  (rule) => matchesPattern(toolName, rule.tool) && !(bashCommand !== null && rule.name && AST_FS_REGEX_RULES.has(rule.name)) && evaluateSmartConditions(args, rule)
2351
2364
  );
2365
+ const matchedRule = resolvePinned(matches);
2352
2366
  if (matchedRule) {
2353
2367
  if (matchedRule.verdict === "allow")
2354
2368
  return { decision: "allow", ruleName: matchedRule.name ?? matchedRule.tool };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node9/proxy",
3
- "version": "1.45.0",
3
+ "version": "1.46.0",
4
4
  "description": "The Sudo Command for AI Agents. Execution Security for Claude Code, Codex, Gemini, Cursor, Opencode, Pi, and any MCP server.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",