nexus-agents 8.60.0 → 8.60.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.
Files changed (33) hide show
  1. package/dist/{chunk-GYOPH7LC.js → chunk-3UAEJN4N.js} +34 -299
  2. package/dist/chunk-3UAEJN4N.js.map +1 -0
  3. package/dist/{chunk-EVEYEV3W.js → chunk-426AIY5F.js} +2 -2
  4. package/dist/{chunk-TH7NLNPU.js → chunk-5ZVGPKNO.js} +202 -9
  5. package/dist/chunk-5ZVGPKNO.js.map +1 -0
  6. package/dist/{chunk-UEUHEBNI.js → chunk-7JA62DNM.js} +2 -2
  7. package/dist/{chunk-BQRZFAJU.js → chunk-Q3LSWYM5.js} +113 -31
  8. package/dist/chunk-Q3LSWYM5.js.map +1 -0
  9. package/dist/{chunk-CMIKHBQS.js → chunk-RTEZ6OJY.js} +3 -3
  10. package/dist/{chunk-LAEKMOIF.js → chunk-TCEMOFIM.js} +3 -3
  11. package/dist/cli.js +8 -9
  12. package/dist/cli.js.map +1 -1
  13. package/dist/{consensus-vote-C2HYWT3Y.js → consensus-vote-QMDRIAM7.js} +4 -5
  14. package/dist/{improvement-review-VUJBBHIG.js → improvement-review-GFC6TLLK.js} +4 -5
  15. package/dist/index.d.ts +5 -5
  16. package/dist/index.js +16 -18
  17. package/dist/index.js.map +1 -1
  18. package/dist/{issue-triage-XUUOXCXQ.js → issue-triage-CGMODLMK.js} +2 -3
  19. package/dist/{setup-data-dir-J7N2LE4T.js → setup-data-dir-CVZAQ4R6.js} +3 -3
  20. package/package.json +1 -1
  21. package/dist/chunk-BQRZFAJU.js.map +0 -1
  22. package/dist/chunk-GYOPH7LC.js.map +0 -1
  23. package/dist/chunk-JZ7MTCXL.js +0 -217
  24. package/dist/chunk-JZ7MTCXL.js.map +0 -1
  25. package/dist/chunk-TH7NLNPU.js.map +0 -1
  26. /package/dist/{chunk-EVEYEV3W.js.map → chunk-426AIY5F.js.map} +0 -0
  27. /package/dist/{chunk-UEUHEBNI.js.map → chunk-7JA62DNM.js.map} +0 -0
  28. /package/dist/{chunk-CMIKHBQS.js.map → chunk-RTEZ6OJY.js.map} +0 -0
  29. /package/dist/{chunk-LAEKMOIF.js.map → chunk-TCEMOFIM.js.map} +0 -0
  30. /package/dist/{consensus-vote-C2HYWT3Y.js.map → consensus-vote-QMDRIAM7.js.map} +0 -0
  31. /package/dist/{improvement-review-VUJBBHIG.js.map → improvement-review-GFC6TLLK.js.map} +0 -0
  32. /package/dist/{issue-triage-XUUOXCXQ.js.map → issue-triage-CGMODLMK.js.map} +0 -0
  33. /package/dist/{setup-data-dir-J7N2LE4T.js.map → setup-data-dir-CVZAQ4R6.js.map} +0 -0
@@ -1,9 +1,6 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-UEUHEBNI.js";
4
- import {
5
- emitClawGuardViolation
6
- } from "./chunk-JZ7MTCXL.js";
3
+ } from "./chunk-7JA62DNM.js";
7
4
  import {
8
5
  CACHE_TIMEOUTS,
9
6
  MCP_TIMEOUTS,
@@ -1474,270 +1471,6 @@ var TimeoutGuard = class {
1474
1471
  }
1475
1472
  };
1476
1473
 
1477
- // src/security/access-constraint-deriver/denylist.ts
1478
- var UNBYPASSABLE_PATH_PATTERNS = [
1479
- // Environment files
1480
- ".env",
1481
- ".env.*",
1482
- "**/.env",
1483
- "**/.env.*",
1484
- // SSH credentials
1485
- "~/.ssh/**",
1486
- "**/ssh/id_*",
1487
- "**/*_rsa",
1488
- "**/*_ed25519",
1489
- "**/*.pem",
1490
- // Cloud credentials
1491
- "~/.aws/**",
1492
- "~/.azure/**",
1493
- "~/.gcp/**",
1494
- "~/.config/gcloud/**",
1495
- "~/.kube/config",
1496
- // Unix secret files
1497
- "/etc/shadow",
1498
- "/etc/sudoers",
1499
- "/etc/sudoers.d/**",
1500
- // Common secret file patterns
1501
- "**/secrets.*",
1502
- "**/credentials.*",
1503
- "**/private_key.*",
1504
- "**/id_rsa*"
1505
- ];
1506
- var UNBYPASSABLE_TOOL_NAMES = [
1507
- // Destructive git operations
1508
- "git_push_force",
1509
- "git_reset_hard",
1510
- "git_branch_delete_force",
1511
- "git_clean_force",
1512
- // Destructive filesystem
1513
- "rm_recursive_force",
1514
- "chmod_recursive",
1515
- // Identity / auth mutations
1516
- "ssh_add_key",
1517
- "gpg_add_key",
1518
- "npm_publish_force",
1519
- // Remote destruction
1520
- "github_repo_delete",
1521
- "github_org_transfer",
1522
- "aws_account_close"
1523
- ];
1524
- function compileGlobToRegex(pattern) {
1525
- const pat = pattern.toLowerCase();
1526
- const escaped = pat.replace(/[\\.+^$()|[\]{}]/g, "\\$&").replace(/\*\*/g, "__DOUBLESTAR__").replace(/\*/g, "[^/]*").replace(/__DOUBLESTAR__/g, ".*");
1527
- const anchored = escaped.startsWith("~/") ? `(^|/)${escaped.slice(2)}$` : escaped.startsWith("/") ? `^${escaped}$` : `(^|/)${escaped}$`;
1528
- return new RegExp(anchored);
1529
- }
1530
- var COMPILED_PATH_PATTERNS = UNBYPASSABLE_PATH_PATTERNS.map((pattern) => ({
1531
- pattern,
1532
- regex: compileGlobToRegex(pattern)
1533
- }));
1534
- function isPathDenied(path) {
1535
- const normalized = path.toLowerCase();
1536
- return COMPILED_PATH_PATTERNS.some((c) => c.regex.test(normalized));
1537
- }
1538
- function isToolDenied(toolName) {
1539
- return UNBYPASSABLE_TOOL_NAMES.includes(toolName);
1540
- }
1541
-
1542
- // src/security/access-constraint-deriver/tool-risk.ts
1543
- var READ_ONLY_TOOLS2 = /* @__PURE__ */ new Set([
1544
- // Discovery / listing
1545
- "list_experts",
1546
- "list_workflows",
1547
- // Research reads
1548
- "research_query",
1549
- "research_analyze",
1550
- "research_catalog_review",
1551
- "research_synthesize",
1552
- // Memory reads
1553
- "memory_query",
1554
- "memory_stats",
1555
- // Observability
1556
- "weather_report",
1557
- "query_trace",
1558
- "query_task_state",
1559
- // Async-mode result polling (#3042 / epic #2631)
1560
- "get_job_result",
1561
- // Async-mode job discovery (#3046 / epic #2631 Stage 5)
1562
- "list_jobs",
1563
- // Codebase intelligence (read-only over local files)
1564
- "search_codebase",
1565
- "extract_symbols",
1566
- // Repo analysis (read-only)
1567
- "repo_analyze",
1568
- "repo_security_plan",
1569
- // Routing recommendation (no side effects — returns recommendation)
1570
- "delegate_to_model",
1571
- // Registry import (returns a draft template — does not write)
1572
- "registry_import"
1573
- ]);
1574
- function isRiskyTool(toolName) {
1575
- return !READ_ONLY_TOOLS2.has(toolName);
1576
- }
1577
-
1578
- // src/security/access-constraint-deriver/enforcer.ts
1579
- function checkAccess(toolName, policy, args) {
1580
- if (isToolDenied(toolName)) {
1581
- return {
1582
- decision: "deny",
1583
- reason: `tool "${toolName}" is on the unbypassable deny-tool list`,
1584
- matchedRule: "unbypassable:tool"
1585
- };
1586
- }
1587
- if (typeof args?.path === "string" && args.path.length > 0 && isPathDenied(args.path)) {
1588
- return {
1589
- decision: "deny",
1590
- reason: `path "${args.path}" is on the unbypassable deny-path list`,
1591
- matchedRule: "unbypassable:path"
1592
- };
1593
- }
1594
- if (policy.allowedTools === "*") return { decision: "allow" };
1595
- if (policy.allowedTools.length === 0) {
1596
- const refuseVerb = policy.refuseVerbMatched;
1597
- return {
1598
- decision: "unmeasured",
1599
- 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)${refuseVerbNote(refuseVerb)}`,
1600
- ...refuseVerb !== void 0 && { refuseVerbMatched: refuseVerb }
1601
- };
1602
- }
1603
- if (policy.allowedTools.includes(toolName)) return { decision: "allow" };
1604
- return decideOnViolation(toolName, policy.mode);
1605
- }
1606
- function refuseVerbNote(refuseVerb) {
1607
- if (refuseVerb === void 0) return "";
1608
- return `; the objective matched the destructive verb "${refuseVerb}", which this verdict does NOT deny (#5895)`;
1609
- }
1610
- function decideOnViolation(toolName, mode) {
1611
- if (mode === "audit") {
1612
- return {
1613
- decision: "log-and-allow",
1614
- warning: `tool "${toolName}" not in derived policy (audit mode)`
1615
- };
1616
- }
1617
- if (mode === "confirm_risky") {
1618
- if (!isRiskyTool(toolName)) {
1619
- return {
1620
- decision: "log-and-allow",
1621
- warning: `tool "${toolName}" not in derived policy (confirm_risky mode, read-only \u2014 would have required human approval, allowed because read-only)`
1622
- };
1623
- }
1624
- return {
1625
- decision: "deny",
1626
- reason: `tool "${toolName}" not in derived policy (confirm_risky mode, risky \u2014 would have required human approval; denied for now, add to allowedTools or run in audit mode to allow)`,
1627
- matchedRule: "allowedTools:confirm_risky"
1628
- };
1629
- }
1630
- return {
1631
- decision: "deny",
1632
- reason: `tool "${toolName}" not in derived policy`,
1633
- matchedRule: "allowedTools"
1634
- };
1635
- }
1636
-
1637
- // src/security/access-constraint-deriver/mcp-guard.ts
1638
- import { AsyncLocalStorage as AsyncLocalStorage3 } from "node:async_hooks";
1639
- var accessPolicyStorage = new AsyncLocalStorage3();
1640
- var auditTrailStorage = new AsyncLocalStorage3();
1641
- var MAX_WARNING_LEN = 500;
1642
- function withAuditTrail(trail, fn) {
1643
- return auditTrailStorage.run(trail, fn);
1644
- }
1645
- function getActiveAuditTrail() {
1646
- return auditTrailStorage.getStore();
1647
- }
1648
- function recordAuditModeViolation(input) {
1649
- const trail = getActiveAuditTrail();
1650
- if (trail === void 0) return;
1651
- try {
1652
- emitClawGuardViolation(trail, {
1653
- toolName: input.toolName,
1654
- warning: input.warning.slice(0, MAX_WARNING_LEN),
1655
- policySource: input.policySource,
1656
- mode: input.mode,
1657
- requestId: input.requestId,
1658
- // Outside `warning`, so the 500-char cap above cannot eat it.
1659
- ...input.matchedRule !== void 0 && { matchedRule: input.matchedRule }
1660
- });
1661
- } catch {
1662
- }
1663
- }
1664
- function withAccessPolicy(policy, fn) {
1665
- return accessPolicyStorage.run(policy, fn);
1666
- }
1667
- function getActivePolicy() {
1668
- return accessPolicyStorage.getStore();
1669
- }
1670
-
1671
- // src/security/access-constraint-deriver/chain-adapter.ts
1672
- function toGuardArgs(args) {
1673
- if (typeof args !== "object" || args === null) return void 0;
1674
- const path = args["path"];
1675
- return typeof path === "string" && path.length > 0 ? { path } : void 0;
1676
- }
1677
- function createAccessPolicyChainMiddleware(toolName) {
1678
- return async (args, ctx, next) => {
1679
- const policy = getActivePolicy();
1680
- if (policy === void 0 || policy.mode === "off") {
1681
- return next(args, ctx);
1682
- }
1683
- const decision = checkAccess(toolName, policy, toGuardArgs(args));
1684
- if (decision.decision === "allow") {
1685
- return next(args, ctx);
1686
- }
1687
- if (decision.decision === "unmeasured") {
1688
- ctx.logger.info("access-policy: allowlist unmeasured", {
1689
- tool: toolName,
1690
- reason: decision.reason,
1691
- policySource: policy.source,
1692
- mode: policy.mode,
1693
- requestId: ctx.requestContext.requestId,
1694
- // #5895: a stable field, so a future counter keys on this rather than
1695
- // parsing `reason`. Absent unless the objective matched a refuse verb.
1696
- ...decision.refuseVerbMatched !== void 0 && {
1697
- refuseVerbMatched: decision.refuseVerbMatched
1698
- }
1699
- });
1700
- return next(args, ctx);
1701
- }
1702
- if (decision.decision === "log-and-allow") {
1703
- ctx.logger.warn("access-policy: audit violation", {
1704
- tool: toolName,
1705
- warning: decision.warning,
1706
- policySource: policy.source,
1707
- requestId: ctx.requestContext.requestId
1708
- });
1709
- recordAuditModeViolation({
1710
- toolName,
1711
- warning: decision.warning,
1712
- policySource: policy.source,
1713
- mode: policy.mode,
1714
- requestId: ctx.requestContext.requestId
1715
- });
1716
- return next(args, ctx);
1717
- }
1718
- reportAdvisoryViolation(toolName, decision, policy, ctx);
1719
- return next(args, ctx);
1720
- };
1721
- }
1722
- function reportAdvisoryViolation(toolName, decision, policy, ctx) {
1723
- ctx.logger.warn("access-policy: advisory violation", {
1724
- tool: toolName,
1725
- reason: decision.reason,
1726
- matchedRule: decision.matchedRule,
1727
- policySource: policy.source,
1728
- mode: policy.mode,
1729
- requestId: ctx.requestContext.requestId
1730
- });
1731
- recordAuditModeViolation({
1732
- toolName,
1733
- warning: `[advisory: would have denied] ${decision.reason}`,
1734
- policySource: policy.source,
1735
- mode: policy.mode,
1736
- requestId: ctx.requestContext.requestId,
1737
- matchedRule: decision.matchedRule
1738
- });
1739
- }
1740
-
1741
1474
  // src/mcp/middleware/middleware-chain.ts
1742
1475
  function errorResult(category, message, requestId) {
1743
1476
  return toolStructuredError({
@@ -1863,57 +1596,61 @@ function composeMiddleware(middlewares) {
1863
1596
  return dispatch(0, args);
1864
1597
  };
1865
1598
  }
1866
- function addAuditMiddleware(middlewares, skip) {
1599
+ function addAuditMiddleware(stages, skip) {
1867
1600
  if (skip.audit !== true) {
1868
- middlewares.push(createAuditMiddleware());
1601
+ stages.push({ name: "audit", middleware: createAuditMiddleware() });
1869
1602
  }
1870
1603
  }
1871
- function addRateLimitMiddleware(middlewares, config, skip) {
1604
+ function addRateLimitMiddleware(stages, config, skip) {
1872
1605
  if (skip.rateLimit !== true && config.rateLimiter !== void 0) {
1873
1606
  const limiter = config.rateLimiter instanceof RateLimiter ? config.rateLimiter : new RateLimiter(config.rateLimiter);
1874
- middlewares.push(createRateLimitMiddleware(limiter));
1607
+ stages.push({ name: "rateLimit", middleware: createRateLimitMiddleware(limiter) });
1875
1608
  }
1876
1609
  }
1877
- function addValidationMiddleware(middlewares, config, skip) {
1610
+ function addValidationMiddleware(stages, config, skip) {
1878
1611
  if (skip.validation !== true && config.schema !== void 0) {
1879
- middlewares.push(createValidationMiddleware(config.schema));
1612
+ stages.push({ name: "validation", middleware: createValidationMiddleware(config.schema) });
1880
1613
  }
1881
1614
  }
1882
- function addPolicyMiddleware(middlewares, config, skip) {
1615
+ function addPolicyMiddleware(stages, config, skip) {
1883
1616
  if (skip.policy !== true && config.policyFirewall !== void 0) {
1884
1617
  const mode = config.executionMode ?? "read-only";
1885
- middlewares.push(
1886
- createPolicyMiddleware(config.policyFirewall, config.toolName, mode, config.allowedPaths)
1887
- );
1618
+ stages.push({
1619
+ name: "policy",
1620
+ middleware: createPolicyMiddleware(
1621
+ config.policyFirewall,
1622
+ config.toolName,
1623
+ mode,
1624
+ config.allowedPaths
1625
+ )
1626
+ });
1888
1627
  }
1889
1628
  }
1890
- function addTimeoutMiddleware(middlewares, config, skip) {
1629
+ function addTimeoutMiddleware(stages, config, skip) {
1891
1630
  if (skip.timeout !== true && config.timeout !== void 0) {
1892
1631
  const guard = new TimeoutGuard(config.timeout);
1893
- middlewares.push(createTimeoutMiddleware(guard, config.toolName));
1894
- }
1895
- }
1896
- function addAccessPolicyMiddleware(middlewares, config, skip) {
1897
- if (skip.accessPolicy !== true) {
1898
- middlewares.push(createAccessPolicyChainMiddleware(config.toolName));
1632
+ stages.push({ name: "timeout", middleware: createTimeoutMiddleware(guard, config.toolName) });
1899
1633
  }
1900
1634
  }
1901
1635
  function buildMiddlewareStack(config) {
1902
1636
  const skip = config.skip ?? {};
1903
- const middlewares = [];
1904
- middlewares.push(createMetricsMiddleware());
1905
- addAuditMiddleware(middlewares, skip);
1906
- addRateLimitMiddleware(middlewares, config, skip);
1907
- addValidationMiddleware(middlewares, config, skip);
1908
- addPolicyMiddleware(middlewares, config, skip);
1909
- addAccessPolicyMiddleware(middlewares, config, skip);
1910
- addTimeoutMiddleware(middlewares, config, skip);
1911
- return middlewares;
1637
+ const stages = [];
1638
+ stages.push({ name: "metrics", middleware: createMetricsMiddleware() });
1639
+ addAuditMiddleware(stages, skip);
1640
+ addRateLimitMiddleware(stages, config, skip);
1641
+ addValidationMiddleware(stages, config, skip);
1642
+ addPolicyMiddleware(stages, config, skip);
1643
+ addTimeoutMiddleware(stages, config, skip);
1644
+ return stages;
1912
1645
  }
1913
1646
  function createMiddlewareChain(config) {
1914
1647
  const logger = config.logger ?? createLogger({ tool: config.toolName });
1915
- const middlewares = buildMiddlewareStack(config);
1916
- const composed = composeMiddleware(middlewares);
1648
+ const stages = buildMiddlewareStack(config);
1649
+ logger.debug("Middleware chain built", {
1650
+ toolName: config.toolName,
1651
+ stages: stages.map((stage) => stage.name)
1652
+ });
1653
+ const composed = composeMiddleware(stages.map((stage) => stage.middleware));
1917
1654
  return (handler) => {
1918
1655
  return async (args) => {
1919
1656
  const requestContext = createRequestContext({ toolName: config.toolName });
@@ -2355,8 +2092,6 @@ export {
2355
2092
  NOOP_NOTIFIER,
2356
2093
  abortSignalStorage,
2357
2094
  withProgressHeartbeat,
2358
- withAuditTrail,
2359
- withAccessPolicy,
2360
2095
  getToolTimeout,
2361
2096
  wrapToolWithTimeout,
2362
2097
  toSdkCallback,
@@ -2380,4 +2115,4 @@ export {
2380
2115
  DEFAULT_CONSENSUS_CONFIG,
2381
2116
  ConsensusMetricsSchema
2382
2117
  };
2383
- //# sourceMappingURL=chunk-GYOPH7LC.js.map
2118
+ //# sourceMappingURL=chunk-3UAEJN4N.js.map