nexus-agents 2.169.0 → 2.171.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.
Files changed (129) hide show
  1. package/dist/{child-mcp-config-FJRGAMUU.js → child-mcp-config-NW4JZFWC.js} +2 -2
  2. package/dist/{chunk-CHF63T3L.js → chunk-25CWEJ2M.js} +4 -4
  3. package/dist/{chunk-MCT7JJF6.js → chunk-4KVAHGMB.js} +2 -2
  4. package/dist/{chunk-NT3KCLT6.js → chunk-5UDKUPZB.js} +7 -7
  5. package/dist/{chunk-DSMSYENI.js → chunk-76Q63KJM.js} +2 -2
  6. package/dist/{chunk-TB26XNJH.js → chunk-7AJWIOMT.js} +2 -2
  7. package/dist/{chunk-ZXFIBDT3.js → chunk-AJIDYCQG.js} +3 -3
  8. package/dist/{chunk-HNNSCTOI.js → chunk-B4XT3B2E.js} +2 -2
  9. package/dist/{chunk-BWG54OJS.js → chunk-BTH745HU.js} +2 -2
  10. package/dist/{chunk-SX4E2W3Z.js → chunk-CEDSYAAI.js} +2 -2
  11. package/dist/{chunk-3ON2P4WL.js → chunk-DLVDFJXU.js} +4 -4
  12. package/dist/{chunk-7S43YASS.js → chunk-DYFF72HX.js} +3 -3
  13. package/dist/{chunk-ROCNXZBC.js → chunk-E53VLN73.js} +8 -8
  14. package/dist/{chunk-5O4JRXNQ.js → chunk-FU2FRL46.js} +2 -2
  15. package/dist/{chunk-4G5W5EPU.js → chunk-GJRLIANS.js} +7 -7
  16. package/dist/{chunk-OOFPDA3B.js → chunk-IC3NZHPT.js} +2 -2
  17. package/dist/{chunk-PZF67XDY.js → chunk-IK7POCXO.js} +3 -3
  18. package/dist/{chunk-IQC2K3KY.js → chunk-KP4ZXW3B.js} +3 -3
  19. package/dist/{chunk-Q3UMNYV2.js → chunk-LFKCJQ7G.js} +4 -4
  20. package/dist/{chunk-W76DOL27.js → chunk-O4J34GZT.js} +2 -2
  21. package/dist/{chunk-WB33EPTV.js → chunk-PP5QL4EJ.js} +5 -5
  22. package/dist/{chunk-QXSR5KPG.js → chunk-QBCWORAK.js} +3 -3
  23. package/dist/{chunk-XGNB7LQB.js → chunk-QBOTSJ7S.js} +235 -20
  24. package/dist/chunk-QBOTSJ7S.js.map +1 -0
  25. package/dist/{chunk-JCJHQSAY.js → chunk-QFS5VOB6.js} +2 -2
  26. package/dist/{chunk-RO23OT47.js → chunk-RAK6PTNM.js} +2 -2
  27. package/dist/{chunk-R46SBPLH.js → chunk-RQGORCFM.js} +5 -5
  28. package/dist/{chunk-CD2NZFAI.js → chunk-S66XOAMZ.js} +2 -2
  29. package/dist/{chunk-EQRN5FRZ.js → chunk-SCHMBRK4.js} +3 -3
  30. package/dist/{chunk-T3VD32JY.js → chunk-SUWN54CK.js} +2 -2
  31. package/dist/{chunk-F6HJJG3E.js → chunk-SZ3CRNPI.js} +8 -8
  32. package/dist/{chunk-3JH3FMEJ.js → chunk-Y7JDXVJA.js} +2 -2
  33. package/dist/{chunk-N7FIUFQL.js → chunk-YIQ5Z7LV.js} +44 -118
  34. package/dist/chunk-YIQ5Z7LV.js.map +1 -0
  35. package/dist/{chunk-P7MYTCE6.js → chunk-Z5GJ4FXW.js} +4 -4
  36. package/dist/{chunk-HAVBBSYN.js → chunk-ZSWXEDI6.js} +2 -2
  37. package/dist/{cli-circuit-breaker-FJQXDC5M.js → cli-circuit-breaker-UWJNXHLC.js} +4 -4
  38. package/dist/cli.js +40 -40
  39. package/dist/{composite-router-UQTCPADM.js → composite-router-ULDZRQGO.js} +2 -2
  40. package/dist/{consensus-vote-FEDF24T5.js → consensus-vote-KF6M7NZJ.js} +15 -15
  41. package/dist/{context-retriever-TIJGFLGO.js → context-retriever-73PNAWES.js} +8 -8
  42. package/dist/{doctor-deep-EULAHWTK.js → doctor-deep-LURSTTF7.js} +3 -3
  43. package/dist/{expert-bridge-7HQ54XYU.js → expert-bridge-VWS3NBL3.js} +4 -4
  44. package/dist/{factory-RW2ROEDS.js → factory-KPJ2EG63.js} +5 -5
  45. package/dist/{factory-QZZQVDGQ.js → factory-MYJYONBQ.js} +8 -8
  46. package/dist/{improvement-review-DGQPADKS.js → improvement-review-APOK4U3Z.js} +5 -5
  47. package/dist/index.d.ts +151 -1
  48. package/dist/index.js +389 -155
  49. package/dist/index.js.map +1 -1
  50. package/dist/{init-opencode-MK2NUEWH.js → init-opencode-Y7WPFCY7.js} +5 -5
  51. package/dist/{issue-triage-RVDZEM53.js → issue-triage-4P3TDIJQ.js} +6 -6
  52. package/dist/{pr-reviewer-helpers-TKXJBDT6.js → pr-reviewer-helpers-4JX2LEVZ.js} +4 -4
  53. package/dist/{registry-command-VXXKVZ3H.js → registry-command-CTYTYRXF.js} +2 -2
  54. package/dist/{repo-security-plan-YCTKRAGA.js → repo-security-plan-4CXBXLAY.js} +3 -3
  55. package/dist/{research-helpers-synthesize-4L6SXYQU.js → research-helpers-synthesize-23OXMV47.js} +4 -4
  56. package/dist/{routing-memory-INY5DC2P.js → routing-memory-AWCOIW27.js} +2 -2
  57. package/dist/security/ast-rules/command-exec-go.yml +15 -0
  58. package/dist/security/ast-rules/dangerous-eval-python.yml +8 -0
  59. package/dist/security/ast-rules/shell-injection-python.yml +13 -0
  60. package/dist/{session-memory-TQMLN67N.js → session-memory-P53QXKGV.js} +3 -3
  61. package/dist/{setup-command-FT5LBTSR.js → setup-command-IRW76CNQ.js} +13 -13
  62. package/dist/{setup-config-U3WLC5OO.js → setup-config-B7WLUMUU.js} +3 -3
  63. package/dist/{setup-custom-api-2E4MZ5MF.js → setup-custom-api-B6QGKSEY.js} +3 -3
  64. package/dist/{tool-memory-IV5BVIV4.js → tool-memory-QUFVINHN.js} +5 -5
  65. package/dist/{unified-registry-6LFTI4MG.js → unified-registry-4NOWT2MU.js} +9 -9
  66. package/dist/{weather-report-7NZ6D4C7.js → weather-report-MCLS5MFZ.js} +2 -2
  67. package/package.json +4 -1
  68. package/src/security/ast-rules/command-exec-go.yml +15 -0
  69. package/src/security/ast-rules/dangerous-eval-python.yml +8 -0
  70. package/src/security/ast-rules/fixtures/sample.go +33 -0
  71. package/src/security/ast-rules/fixtures/sample.py +41 -0
  72. package/src/security/ast-rules/shell-injection-python.yml +13 -0
  73. package/dist/chunk-N7FIUFQL.js.map +0 -1
  74. package/dist/chunk-XGNB7LQB.js.map +0 -1
  75. /package/dist/{child-mcp-config-FJRGAMUU.js.map → child-mcp-config-NW4JZFWC.js.map} +0 -0
  76. /package/dist/{chunk-CHF63T3L.js.map → chunk-25CWEJ2M.js.map} +0 -0
  77. /package/dist/{chunk-MCT7JJF6.js.map → chunk-4KVAHGMB.js.map} +0 -0
  78. /package/dist/{chunk-NT3KCLT6.js.map → chunk-5UDKUPZB.js.map} +0 -0
  79. /package/dist/{chunk-DSMSYENI.js.map → chunk-76Q63KJM.js.map} +0 -0
  80. /package/dist/{chunk-TB26XNJH.js.map → chunk-7AJWIOMT.js.map} +0 -0
  81. /package/dist/{chunk-ZXFIBDT3.js.map → chunk-AJIDYCQG.js.map} +0 -0
  82. /package/dist/{chunk-HNNSCTOI.js.map → chunk-B4XT3B2E.js.map} +0 -0
  83. /package/dist/{chunk-BWG54OJS.js.map → chunk-BTH745HU.js.map} +0 -0
  84. /package/dist/{chunk-SX4E2W3Z.js.map → chunk-CEDSYAAI.js.map} +0 -0
  85. /package/dist/{chunk-3ON2P4WL.js.map → chunk-DLVDFJXU.js.map} +0 -0
  86. /package/dist/{chunk-7S43YASS.js.map → chunk-DYFF72HX.js.map} +0 -0
  87. /package/dist/{chunk-ROCNXZBC.js.map → chunk-E53VLN73.js.map} +0 -0
  88. /package/dist/{chunk-5O4JRXNQ.js.map → chunk-FU2FRL46.js.map} +0 -0
  89. /package/dist/{chunk-4G5W5EPU.js.map → chunk-GJRLIANS.js.map} +0 -0
  90. /package/dist/{chunk-OOFPDA3B.js.map → chunk-IC3NZHPT.js.map} +0 -0
  91. /package/dist/{chunk-PZF67XDY.js.map → chunk-IK7POCXO.js.map} +0 -0
  92. /package/dist/{chunk-IQC2K3KY.js.map → chunk-KP4ZXW3B.js.map} +0 -0
  93. /package/dist/{chunk-Q3UMNYV2.js.map → chunk-LFKCJQ7G.js.map} +0 -0
  94. /package/dist/{chunk-W76DOL27.js.map → chunk-O4J34GZT.js.map} +0 -0
  95. /package/dist/{chunk-WB33EPTV.js.map → chunk-PP5QL4EJ.js.map} +0 -0
  96. /package/dist/{chunk-QXSR5KPG.js.map → chunk-QBCWORAK.js.map} +0 -0
  97. /package/dist/{chunk-JCJHQSAY.js.map → chunk-QFS5VOB6.js.map} +0 -0
  98. /package/dist/{chunk-RO23OT47.js.map → chunk-RAK6PTNM.js.map} +0 -0
  99. /package/dist/{chunk-R46SBPLH.js.map → chunk-RQGORCFM.js.map} +0 -0
  100. /package/dist/{chunk-CD2NZFAI.js.map → chunk-S66XOAMZ.js.map} +0 -0
  101. /package/dist/{chunk-EQRN5FRZ.js.map → chunk-SCHMBRK4.js.map} +0 -0
  102. /package/dist/{chunk-T3VD32JY.js.map → chunk-SUWN54CK.js.map} +0 -0
  103. /package/dist/{chunk-F6HJJG3E.js.map → chunk-SZ3CRNPI.js.map} +0 -0
  104. /package/dist/{chunk-3JH3FMEJ.js.map → chunk-Y7JDXVJA.js.map} +0 -0
  105. /package/dist/{chunk-P7MYTCE6.js.map → chunk-Z5GJ4FXW.js.map} +0 -0
  106. /package/dist/{chunk-HAVBBSYN.js.map → chunk-ZSWXEDI6.js.map} +0 -0
  107. /package/dist/{cli-circuit-breaker-FJQXDC5M.js.map → cli-circuit-breaker-UWJNXHLC.js.map} +0 -0
  108. /package/dist/{composite-router-UQTCPADM.js.map → composite-router-ULDZRQGO.js.map} +0 -0
  109. /package/dist/{consensus-vote-FEDF24T5.js.map → consensus-vote-KF6M7NZJ.js.map} +0 -0
  110. /package/dist/{context-retriever-TIJGFLGO.js.map → context-retriever-73PNAWES.js.map} +0 -0
  111. /package/dist/{doctor-deep-EULAHWTK.js.map → doctor-deep-LURSTTF7.js.map} +0 -0
  112. /package/dist/{expert-bridge-7HQ54XYU.js.map → expert-bridge-VWS3NBL3.js.map} +0 -0
  113. /package/dist/{factory-QZZQVDGQ.js.map → factory-KPJ2EG63.js.map} +0 -0
  114. /package/dist/{factory-RW2ROEDS.js.map → factory-MYJYONBQ.js.map} +0 -0
  115. /package/dist/{improvement-review-DGQPADKS.js.map → improvement-review-APOK4U3Z.js.map} +0 -0
  116. /package/dist/{init-opencode-MK2NUEWH.js.map → init-opencode-Y7WPFCY7.js.map} +0 -0
  117. /package/dist/{issue-triage-RVDZEM53.js.map → issue-triage-4P3TDIJQ.js.map} +0 -0
  118. /package/dist/{pr-reviewer-helpers-TKXJBDT6.js.map → pr-reviewer-helpers-4JX2LEVZ.js.map} +0 -0
  119. /package/dist/{registry-command-VXXKVZ3H.js.map → registry-command-CTYTYRXF.js.map} +0 -0
  120. /package/dist/{repo-security-plan-YCTKRAGA.js.map → repo-security-plan-4CXBXLAY.js.map} +0 -0
  121. /package/dist/{research-helpers-synthesize-4L6SXYQU.js.map → research-helpers-synthesize-23OXMV47.js.map} +0 -0
  122. /package/dist/{routing-memory-INY5DC2P.js.map → routing-memory-AWCOIW27.js.map} +0 -0
  123. /package/dist/{session-memory-TQMLN67N.js.map → session-memory-P53QXKGV.js.map} +0 -0
  124. /package/dist/{setup-command-FT5LBTSR.js.map → setup-command-IRW76CNQ.js.map} +0 -0
  125. /package/dist/{setup-config-U3WLC5OO.js.map → setup-config-B7WLUMUU.js.map} +0 -0
  126. /package/dist/{setup-custom-api-2E4MZ5MF.js.map → setup-custom-api-B6QGKSEY.js.map} +0 -0
  127. /package/dist/{tool-memory-IV5BVIV4.js.map → tool-memory-QUFVINHN.js.map} +0 -0
  128. /package/dist/{unified-registry-6LFTI4MG.js.map → unified-registry-4NOWT2MU.js.map} +0 -0
  129. /package/dist/{weather-report-7NZ6D4C7.js.map → weather-report-MCLS5MFZ.js.map} +0 -0
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createGitHubProvider,
3
3
  createScmProvider
4
- } from "./chunk-CHF63T3L.js";
4
+ } from "./chunk-25CWEJ2M.js";
5
5
  import {
6
6
  ALLOWED_COMMANDS,
7
7
  ARTIFACT_TYPES,
@@ -522,7 +522,7 @@ import {
522
522
  validateWorkflow,
523
523
  validateWorkflowDependencies,
524
524
  withLogging
525
- } from "./chunk-N7FIUFQL.js";
525
+ } from "./chunk-YIQ5Z7LV.js";
526
526
  import {
527
527
  FALLBACK_SCANNER_DATA,
528
528
  buildPlanFromAnalysis,
@@ -530,7 +530,7 @@ import {
530
530
  generateSecurityPlan,
531
531
  getRegistryManifest,
532
532
  resolveScannerData
533
- } from "./chunk-HNNSCTOI.js";
533
+ } from "./chunk-B4XT3B2E.js";
534
534
  import {
535
535
  analyzeGitHubRepo,
536
536
  analyzeRepo,
@@ -556,20 +556,20 @@ import {
556
556
  getKnownNexusVarNames,
557
557
  startStdioServer,
558
558
  validateNexusEnv
559
- } from "./chunk-ROCNXZBC.js";
559
+ } from "./chunk-E53VLN73.js";
560
560
  import {
561
561
  OPENAI_MODELS,
562
562
  OPENAI_MODEL_ALIASES,
563
563
  OpenAIAdapter,
564
564
  createOpenAIAdapter
565
- } from "./chunk-3ON2P4WL.js";
565
+ } from "./chunk-DLVDFJXU.js";
566
566
  import {
567
567
  CliCircuitBreakerIntegration,
568
568
  createCliCircuitBreakerIntegration
569
- } from "./chunk-PZF67XDY.js";
569
+ } from "./chunk-IK7POCXO.js";
570
570
  import {
571
571
  executeExpert
572
- } from "./chunk-4G5W5EPU.js";
572
+ } from "./chunk-GJRLIANS.js";
573
573
  import {
574
574
  AgentFindingSchema,
575
575
  ConsensusEngine,
@@ -618,9 +618,9 @@ import {
618
618
  generateProposalId,
619
619
  parseAgentPairKey,
620
620
  registerConsensusVoteTool
621
- } from "./chunk-F6HJJG3E.js";
622
- import "./chunk-TB26XNJH.js";
623
- import "./chunk-7S43YASS.js";
621
+ } from "./chunk-SZ3CRNPI.js";
622
+ import "./chunk-7AJWIOMT.js";
623
+ import "./chunk-DYFF72HX.js";
624
624
  import {
625
625
  AgentActionSchema,
626
626
  GitHubReviewer,
@@ -642,11 +642,11 @@ import {
642
642
  requiresCorroboration,
643
643
  validateAgentAction,
644
644
  validateCorroboration
645
- } from "./chunk-R46SBPLH.js";
645
+ } from "./chunk-RQGORCFM.js";
646
646
  import {
647
647
  GitHubProvider,
648
648
  ScmError
649
- } from "./chunk-RO23OT47.js";
649
+ } from "./chunk-RAK6PTNM.js";
650
650
  import {
651
651
  GitHubUserRoleSchema,
652
652
  InjectionFlagSchema,
@@ -661,11 +661,11 @@ import {
661
661
  assessReputation,
662
662
  reconcileTrustTier,
663
663
  sanitizeInput
664
- } from "./chunk-SX4E2W3Z.js";
664
+ } from "./chunk-CEDSYAAI.js";
665
665
  import {
666
666
  ImprovementReviewInputSchema,
667
667
  registerImprovementReviewTool
668
- } from "./chunk-EQRN5FRZ.js";
668
+ } from "./chunk-SCHMBRK4.js";
669
669
  import {
670
670
  AgentPerformanceSchema,
671
671
  ConsensusAlgorithmSchema,
@@ -701,7 +701,7 @@ import {
701
701
  toolSuccess,
702
702
  toolSuccessStructured,
703
703
  validateToolInput
704
- } from "./chunk-IQC2K3KY.js";
704
+ } from "./chunk-KP4ZXW3B.js";
705
705
  import {
706
706
  AuditTrail,
707
707
  MAX_STRIPPED_ELEMENTS_PER_EVENT,
@@ -713,7 +713,7 @@ import {
713
713
  emitReputationEvent,
714
714
  emitSanitizationEvent,
715
715
  emitTrustEvent
716
- } from "./chunk-BWG54OJS.js";
716
+ } from "./chunk-BTH745HU.js";
717
717
  import {
718
718
  PersistentStrategyDistiller,
719
719
  RulesSnapshotSchema,
@@ -721,19 +721,19 @@ import {
721
721
  TokenCounter,
722
722
  TokenCounterProvider,
723
723
  createTokenCounter
724
- } from "./chunk-XGNB7LQB.js";
724
+ } from "./chunk-QBOTSJ7S.js";
725
725
  import {
726
726
  getTokenEnvVars,
727
727
  hasToken,
728
728
  resolveToken
729
- } from "./chunk-3JH3FMEJ.js";
730
- import "./chunk-HAVBBSYN.js";
729
+ } from "./chunk-Y7JDXVJA.js";
730
+ import "./chunk-ZSWXEDI6.js";
731
731
  import "./chunk-NUBSJGQZ.js";
732
732
  import {
733
733
  MemoryError
734
- } from "./chunk-Q3UMNYV2.js";
734
+ } from "./chunk-LFKCJQ7G.js";
735
735
  import "./chunk-6T3EPABN.js";
736
- import "./chunk-W76DOL27.js";
736
+ import "./chunk-O4J34GZT.js";
737
737
  import {
738
738
  BUILT_IN_EXPERTS,
739
739
  BuiltInExpertTypeSchema,
@@ -752,7 +752,7 @@ import {
752
752
  resetGlobalRegistry,
753
753
  withModelNotFoundFallback,
754
754
  wrapResilientWithFallback
755
- } from "./chunk-P7MYTCE6.js";
755
+ } from "./chunk-Z5GJ4FXW.js";
756
756
  import {
757
757
  BaseCliAdapter,
758
758
  CLAUDE_MODELS,
@@ -787,7 +787,7 @@ import {
787
787
  isCliAvailable,
788
788
  isRetryableError,
789
789
  sleep
790
- } from "./chunk-NT3KCLT6.js";
790
+ } from "./chunk-5UDKUPZB.js";
791
791
  import {
792
792
  AdapterModelError,
793
793
  BaseAdapter,
@@ -811,12 +811,12 @@ import {
811
811
  transformStream,
812
812
  validateApiKeyPresence,
813
813
  withTimeout
814
- } from "./chunk-MCT7JJF6.js";
814
+ } from "./chunk-4KVAHGMB.js";
815
815
  import {
816
816
  DEFAULTS,
817
817
  PROVIDER_ENV_KEYS
818
- } from "./chunk-JCJHQSAY.js";
819
- import "./chunk-DSMSYENI.js";
818
+ } from "./chunk-QFS5VOB6.js";
819
+ import "./chunk-76Q63KJM.js";
820
820
  import {
821
821
  AvailabilityCache,
822
822
  filterAvailableModels,
@@ -825,9 +825,9 @@ import {
825
825
  getFallbackChain,
826
826
  resetAvailabilityCache,
827
827
  resolveFallback
828
- } from "./chunk-T3VD32JY.js";
828
+ } from "./chunk-SUWN54CK.js";
829
829
  import "./chunk-QZUG667L.js";
830
- import "./chunk-OOFPDA3B.js";
830
+ import "./chunk-IC3NZHPT.js";
831
831
  import {
832
832
  AgentCapability,
833
833
  AgentError,
@@ -905,7 +905,7 @@ import {
905
905
  toError,
906
906
  unwrap,
907
907
  unwrapOr
908
- } from "./chunk-QXSR5KPG.js";
908
+ } from "./chunk-QBCWORAK.js";
909
909
  import "./chunk-AXTD4TFK.js";
910
910
  import "./chunk-DHVMSIT5.js";
911
911
  import "./chunk-ZPWHCABL.js";
@@ -1272,7 +1272,7 @@ var RateLimiter2 = class {
1272
1272
  * Sleeps for the specified duration.
1273
1273
  */
1274
1274
  sleep(ms) {
1275
- return new Promise((resolve2) => setTimeout(resolve2, ms));
1275
+ return new Promise((resolve3) => setTimeout(resolve3, ms));
1276
1276
  }
1277
1277
  /**
1278
1278
  * Returns the current number of available tokens.
@@ -1532,7 +1532,7 @@ var AbortError = class extends Error {
1532
1532
  function raceAbort(promise, signal) {
1533
1533
  if (signal === void 0) return promise;
1534
1534
  if (signal.aborted) return Promise.reject(new AbortError());
1535
- return new Promise((resolve2, reject) => {
1535
+ return new Promise((resolve3, reject) => {
1536
1536
  const onAbort = () => {
1537
1537
  reject(new AbortError());
1538
1538
  };
@@ -1540,7 +1540,7 @@ function raceAbort(promise, signal) {
1540
1540
  promise.then(
1541
1541
  (value) => {
1542
1542
  signal.removeEventListener("abort", onAbort);
1543
- resolve2(value);
1543
+ resolve3(value);
1544
1544
  },
1545
1545
  (error) => {
1546
1546
  signal.removeEventListener("abort", onAbort);
@@ -4154,47 +4154,271 @@ function createGitHubAdapter() {
4154
4154
  };
4155
4155
  }
4156
4156
 
4157
- // src/orchestration/spec-parser-types.ts
4157
+ // src/security/ast-rule-runner.ts
4158
+ import { existsSync as existsSync2 } from "fs";
4159
+ import { readdir, readFile, stat } from "fs/promises";
4160
+ import { dirname, extname, join as join2, relative, resolve as resolve2, sep } from "path";
4161
+ import { fileURLToPath } from "url";
4162
+ import { parse, registerDynamicLanguage } from "@ast-grep/napi";
4163
+ import goLangRegistration from "@ast-grep/lang-go";
4164
+ import pythonLangRegistration from "@ast-grep/lang-python";
4165
+ import { parse as parseYaml } from "yaml";
4158
4166
  import { z as z8 } from "zod";
4159
- var IssueReferenceSchema = z8.object({
4167
+ var polyglotLangsRegistered = false;
4168
+ function ensurePolyglotLangs() {
4169
+ if (polyglotLangsRegistered) return;
4170
+ registerDynamicLanguage({ python: pythonLangRegistration, go: goLangRegistration });
4171
+ polyglotLangsRegistered = true;
4172
+ }
4173
+ var AST_RULE_LANGUAGES = ["python", "go"];
4174
+ var AST_RULE_SEVERITIES = ["error", "warning", "info"];
4175
+ var RuleFileSchema = z8.object({
4176
+ id: z8.string().min(1),
4177
+ language: z8.enum(AST_RULE_LANGUAGES),
4178
+ severity: z8.enum(AST_RULE_SEVERITIES),
4179
+ message: z8.string().min(1),
4180
+ rule: z8.record(z8.string(), z8.unknown())
4181
+ });
4182
+ var MAX_SNIPPET_CHARS = 200;
4183
+ var DEFAULT_AST_QA_LIMIT = 200;
4184
+ var MAX_AST_QA_LIMIT = 2e3;
4185
+ var AST_QA_MAX_DEPTH = 24;
4186
+ var MAX_FILES_SCANNED = 5e3;
4187
+ var logger5 = createLogger({ component: "ast-rule-runner" });
4188
+ async function loadRules(dir) {
4189
+ let entries;
4190
+ try {
4191
+ entries = (await readdir(dir)).filter((f) => f.endsWith(".yml") || f.endsWith(".yaml")).sort();
4192
+ } catch (caught) {
4193
+ const e = caught instanceof Error ? caught : new Error(String(caught));
4194
+ throw new ValidationError(`ast-rule-runner: cannot read rules dir ${dir}: ${e.message}`, {
4195
+ cause: e
4196
+ });
4197
+ }
4198
+ const rules = [];
4199
+ for (const file of entries) {
4200
+ const path2 = join2(dir, file);
4201
+ const raw = await readFile(path2, "utf8");
4202
+ let parsed;
4203
+ try {
4204
+ parsed = parseYaml(raw);
4205
+ } catch (caught) {
4206
+ const e = caught instanceof Error ? caught : new Error(String(caught));
4207
+ throw new ValidationError(`ast-rule-runner: malformed YAML in ${path2}: ${e.message}`, {
4208
+ cause: e
4209
+ });
4210
+ }
4211
+ const result = RuleFileSchema.safeParse(parsed);
4212
+ if (!result.success) {
4213
+ throw new ValidationError(
4214
+ `ast-rule-runner: invalid rule file ${path2}: ${formatZodError(result.error)}`
4215
+ );
4216
+ }
4217
+ rules.push(result.data);
4218
+ }
4219
+ return rules;
4220
+ }
4221
+ function getBuiltInAstRulesPath() {
4222
+ const currentFile = fileURLToPath(import.meta.url);
4223
+ const currentDir = dirname(currentFile);
4224
+ if (currentFile.includes(`${sep}dist${sep}`) || currentFile.endsWith(`${sep}dist`)) {
4225
+ const distIndex = currentFile.lastIndexOf(`${sep}dist${sep}`);
4226
+ if (distIndex !== -1) {
4227
+ const distDir = currentFile.substring(0, distIndex + 5);
4228
+ const bundledPath = join2(distDir, "security", "ast-rules");
4229
+ if (existsSync2(bundledPath)) return bundledPath;
4230
+ }
4231
+ }
4232
+ const possiblePaths = [
4233
+ join2(currentDir, "ast-rules"),
4234
+ // Unbundled: sibling of this file in src/security/
4235
+ join2(currentDir, "security", "ast-rules"),
4236
+ // Bundled chunk: dist/security sibling
4237
+ join2(dirname(currentDir), "security", "ast-rules")
4238
+ ];
4239
+ for (const path2 of possiblePaths) {
4240
+ if (existsSync2(path2)) return path2;
4241
+ }
4242
+ return join2(currentDir, "ast-rules");
4243
+ }
4244
+ function resolveWithinCwd(target) {
4245
+ const resolved = resolve2(target);
4246
+ const cwdRoot = resolve2(".");
4247
+ if (resolved !== cwdRoot && !resolved.startsWith(cwdRoot + sep)) {
4248
+ return { error: `Path traversal denied: scope must be within ${cwdRoot}` };
4249
+ }
4250
+ return { resolved };
4251
+ }
4252
+ var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", "dist", ".git"]);
4253
+ var POLYGLOT_EXT_TO_LANG = {
4254
+ ".py": "python",
4255
+ ".go": "go"
4256
+ };
4257
+ function inferRuleLang(file) {
4258
+ return POLYGLOT_EXT_TO_LANG[extname(file).toLowerCase()] ?? null;
4259
+ }
4260
+ async function findPolyglotFiles(dir, maxDepth) {
4261
+ if (maxDepth <= 0) return [];
4262
+ const out = [];
4263
+ let entries;
4264
+ try {
4265
+ entries = await readdir(dir, { withFileTypes: true });
4266
+ } catch (caught) {
4267
+ const e = caught instanceof Error ? caught : new Error(String(caught));
4268
+ logger5.warn(`ast-rule-runner: skipped unreadable directory ${dir}: ${e.message}`);
4269
+ return out;
4270
+ }
4271
+ for (const entry of entries) {
4272
+ const fullPath = join2(dir, entry.name);
4273
+ if (entry.isDirectory() && !SKIP_DIRS.has(entry.name)) {
4274
+ out.push(...await findPolyglotFiles(fullPath, maxDepth - 1));
4275
+ } else if (entry.isFile() && inferRuleLang(entry.name) !== null) {
4276
+ out.push(fullPath);
4277
+ }
4278
+ }
4279
+ return out;
4280
+ }
4281
+ function langToParseArg(lang) {
4282
+ ensurePolyglotLangs();
4283
+ return lang;
4284
+ }
4285
+ function scanFile(src, lang, applicable, budget) {
4286
+ const { rel, limit, alreadyFound } = budget;
4287
+ const root = parse(langToParseArg(lang), src).root();
4288
+ const lines = src.split("\n");
4289
+ const findings = [];
4290
+ let total = 0;
4291
+ for (const rule of applicable) {
4292
+ const config = { rule: rule.rule };
4293
+ for (const node of root.findAll(config)) {
4294
+ total += 1;
4295
+ if (alreadyFound + findings.length < limit) {
4296
+ const { start } = node.range();
4297
+ const rawLine = lines[start.line] ?? node.text();
4298
+ findings.push({
4299
+ ruleId: rule.id,
4300
+ severity: rule.severity,
4301
+ message: rule.message,
4302
+ file: rel,
4303
+ line: start.line + 1,
4304
+ column: start.column + 1,
4305
+ snippet: rawLine.trim().slice(0, MAX_SNIPPET_CHARS)
4306
+ });
4307
+ }
4308
+ }
4309
+ }
4310
+ return { findings, total };
4311
+ }
4312
+ async function assertScanRootIsDirectory(resolved) {
4313
+ let rootStat;
4314
+ try {
4315
+ rootStat = await stat(resolved);
4316
+ } catch (caught) {
4317
+ const e = caught instanceof Error ? caught : new Error(String(caught));
4318
+ throw new ValidationError(`ast-rule-runner: cannot read targetDir ${resolved}: ${e.message}`, {
4319
+ cause: e
4320
+ });
4321
+ }
4322
+ if (!rootStat.isDirectory()) {
4323
+ throw new ValidationError(
4324
+ `ast-rule-runner: targetDir must be a directory, got a non-directory path: ${resolved}`
4325
+ );
4326
+ }
4327
+ }
4328
+ async function resolveScanFiles(root) {
4329
+ const discovered = await findPolyglotFiles(root, AST_QA_MAX_DEPTH);
4330
+ const files = discovered.slice(0, MAX_FILES_SCANNED);
4331
+ const filesSkipped = discovered.length - files.length;
4332
+ const filesTruncated = filesSkipped > 0;
4333
+ if (filesTruncated) {
4334
+ logger5.warn(
4335
+ `ast-rule-runner: ${String(filesSkipped)} file(s) NOT scanned \u2014 file cap ${String(MAX_FILES_SCANNED)} exceeded (discovered=${String(discovered.length)}). Scan is PARTIAL; do not treat findings as exhaustive.`
4336
+ );
4337
+ }
4338
+ return { files, filesSkipped, filesTruncated };
4339
+ }
4340
+ async function collectAstQaFindings(opts) {
4341
+ const guard = resolveWithinCwd(opts.targetDir);
4342
+ if ("error" in guard) {
4343
+ throw new SecurityError(guard.error);
4344
+ }
4345
+ await assertScanRootIsDirectory(guard.resolved);
4346
+ const rulesDir = opts.rulesDir ?? getBuiltInAstRulesPath();
4347
+ const rules = await loadRules(rulesDir);
4348
+ const limit = Math.min(Math.max(opts.limit ?? DEFAULT_AST_QA_LIMIT, 1), MAX_AST_QA_LIMIT);
4349
+ const { files, filesSkipped, filesTruncated } = await resolveScanFiles(guard.resolved);
4350
+ const findings = [];
4351
+ let total = 0;
4352
+ for (const file of files) {
4353
+ const lang = inferRuleLang(file);
4354
+ if (lang === null) continue;
4355
+ const applicable = rules.filter((r) => r.language === lang);
4356
+ if (applicable.length === 0) continue;
4357
+ let src;
4358
+ try {
4359
+ src = await readFile(file, "utf8");
4360
+ } catch {
4361
+ logger5.warn(`ast-rule-runner: skipped unreadable file ${file}`);
4362
+ continue;
4363
+ }
4364
+ const rel = relative(guard.resolved, file) || file;
4365
+ const scanned = scanFile(src, lang, applicable, { rel, limit, alreadyFound: findings.length });
4366
+ findings.push(...scanned.findings);
4367
+ total += scanned.total;
4368
+ }
4369
+ if (total > findings.length) {
4370
+ logger5.warn(
4371
+ `ast-rule-runner: ${String(total - findings.length)} finding(s) omitted beyond limit=${String(limit)} (total=${String(total)})`
4372
+ );
4373
+ }
4374
+ return { findings, total, limit, filesScanned: files.length, filesSkipped, filesTruncated };
4375
+ }
4376
+ async function runAstQaRules(opts) {
4377
+ const { findings } = await collectAstQaFindings(opts);
4378
+ return findings;
4379
+ }
4380
+
4381
+ // src/orchestration/spec-parser-types.ts
4382
+ import { z as z9 } from "zod";
4383
+ var IssueReferenceSchema = z9.object({
4160
4384
  /** Issue/PR number */
4161
- number: z8.number().int().positive(),
4385
+ number: z9.number().int().positive(),
4162
4386
  /** Raw text (e.g., "#123") */
4163
- raw: z8.string()
4387
+ raw: z9.string()
4164
4388
  });
4165
- var FileReferenceSchema = z8.object({
4389
+ var FileReferenceSchema = z9.object({
4166
4390
  /** File path (e.g., "src/foo.ts") */
4167
- path: z8.string(),
4391
+ path: z9.string(),
4168
4392
  /** Optional line number */
4169
- line: z8.number().int().positive().optional()
4393
+ line: z9.number().int().positive().optional()
4170
4394
  });
4171
- var TechStackSchema = z8.object({
4395
+ var TechStackSchema = z9.object({
4172
4396
  /** Programming language */
4173
- language: z8.string().optional(),
4397
+ language: z9.string().optional(),
4174
4398
  /** Framework or library */
4175
- framework: z8.string().optional(),
4399
+ framework: z9.string().optional(),
4176
4400
  /** Package manager */
4177
- packageManager: z8.string().optional()
4401
+ packageManager: z9.string().optional()
4178
4402
  });
4179
- var ParsedSpecSchema = z8.object({
4403
+ var ParsedSpecSchema = z9.object({
4180
4404
  /** Spec title (from first H1 or H2 heading) */
4181
- title: z8.string().min(1),
4405
+ title: z9.string().min(1),
4182
4406
  /** Overview/description text */
4183
- overview: z8.string(),
4407
+ overview: z9.string(),
4184
4408
  /** List of requirements */
4185
- requirements: z8.array(z8.string()),
4409
+ requirements: z9.array(z9.string()),
4186
4410
  /** Acceptance criteria (checklist items) */
4187
- acceptanceCriteria: z8.array(z8.string()),
4411
+ acceptanceCriteria: z9.array(z9.string()),
4188
4412
  /** Constraints or limitations */
4189
- constraints: z8.array(z8.string()),
4413
+ constraints: z9.array(z9.string()),
4190
4414
  /** Issue/PR references found in the spec */
4191
- issueReferences: z8.array(IssueReferenceSchema),
4415
+ issueReferences: z9.array(IssueReferenceSchema),
4192
4416
  /** File path references found in the spec */
4193
- fileReferences: z8.array(FileReferenceSchema),
4417
+ fileReferences: z9.array(FileReferenceSchema),
4194
4418
  /** Sections that were missing from the spec */
4195
- missingSections: z8.array(z8.string()),
4419
+ missingSections: z9.array(z9.string()),
4196
4420
  /** Raw markdown source */
4197
- rawMarkdown: z8.string(),
4421
+ rawMarkdown: z9.string(),
4198
4422
  /** Inferred technology stack */
4199
4423
  techStack: TechStackSchema.optional()
4200
4424
  });
@@ -4210,138 +4434,138 @@ var KNOWN_SECTIONS = [
4210
4434
  ];
4211
4435
 
4212
4436
  // src/orchestration/spec-decomposer-types.ts
4213
- import { z as z9 } from "zod";
4214
- var SubtaskTypeSchema = z9.enum(["code", "test", "docs", "config", "refactor"]);
4215
- var ComplexityLevelSchema = z9.enum(["simple", "moderate", "complex", "expert"]);
4216
- var SubtaskNodeSchema = z9.object({
4437
+ import { z as z10 } from "zod";
4438
+ var SubtaskTypeSchema = z10.enum(["code", "test", "docs", "config", "refactor"]);
4439
+ var ComplexityLevelSchema = z10.enum(["simple", "moderate", "complex", "expert"]);
4440
+ var SubtaskNodeSchema = z10.object({
4217
4441
  /** Unique identifier for this subtask */
4218
- id: z9.string().min(1),
4442
+ id: z10.string().min(1),
4219
4443
  /** Human-readable description of what this subtask does */
4220
- description: z9.string().min(1),
4444
+ description: z10.string().min(1),
4221
4445
  /** The type of work */
4222
4446
  type: SubtaskTypeSchema,
4223
4447
  /** Estimated complexity */
4224
4448
  complexity: ComplexityLevelSchema,
4225
4449
  /** Required capabilities for the executing agent */
4226
- capabilities: z9.array(z9.string()),
4450
+ capabilities: z10.array(z10.string()),
4227
4451
  /** IDs of subtasks this depends on */
4228
- dependsOn: z9.array(z9.string()),
4452
+ dependsOn: z10.array(z10.string()),
4229
4453
  /** Source requirement text that generated this subtask */
4230
- sourceRequirement: z9.string().optional()
4454
+ sourceRequirement: z10.string().optional()
4231
4455
  });
4232
- var DagEdgeSchema = z9.object({
4456
+ var DagEdgeSchema = z10.object({
4233
4457
  /** Source subtask ID */
4234
- from: z9.string().min(1),
4458
+ from: z10.string().min(1),
4235
4459
  /** Target subtask ID */
4236
- to: z9.string().min(1)
4460
+ to: z10.string().min(1)
4237
4461
  });
4238
- var TaskDagSchema = z9.object({
4462
+ var TaskDagSchema = z10.object({
4239
4463
  /** All subtask nodes */
4240
- nodes: z9.array(SubtaskNodeSchema),
4464
+ nodes: z10.array(SubtaskNodeSchema),
4241
4465
  /** Dependency edges (from must complete before to) */
4242
- edges: z9.array(DagEdgeSchema),
4466
+ edges: z10.array(DagEdgeSchema),
4243
4467
  /** Subtask IDs that can execute in parallel (no dependencies) */
4244
- roots: z9.array(z9.string()),
4468
+ roots: z10.array(z10.string()),
4245
4469
  /** Total estimated complexity across all subtasks */
4246
4470
  totalComplexity: ComplexityLevelSchema,
4247
4471
  /** Source spec title for traceability */
4248
- specTitle: z9.string()
4472
+ specTitle: z10.string()
4249
4473
  });
4250
4474
 
4251
4475
  // src/orchestration/scenario-validator-types.ts
4252
- import { z as z10 } from "zod";
4253
- var CriterionResultSchema = z10.object({
4476
+ import { z as z11 } from "zod";
4477
+ var CriterionResultSchema = z11.object({
4254
4478
  /** The original acceptance criterion text */
4255
- criterion: z10.string(),
4479
+ criterion: z11.string(),
4256
4480
  /** Whether this criterion was satisfied */
4257
- met: z10.boolean(),
4481
+ met: z11.boolean(),
4258
4482
  /** Which result(s) matched this criterion */
4259
- matchedResults: z10.array(z10.string())
4483
+ matchedResults: z11.array(z11.string())
4260
4484
  });
4261
- var ScenarioResultSchema = z10.object({
4485
+ var ScenarioResultSchema = z11.object({
4262
4486
  /** Satisfaction score from 0 (none met) to 1 (all met) */
4263
- satisfaction: z10.number().min(0).max(1),
4487
+ satisfaction: z11.number().min(0).max(1),
4264
4488
  /** Total acceptance criteria count */
4265
- totalCriteria: z10.number().int().nonnegative(),
4489
+ totalCriteria: z11.number().int().nonnegative(),
4266
4490
  /** Number of criteria met */
4267
- metCount: z10.number().int().nonnegative(),
4491
+ metCount: z11.number().int().nonnegative(),
4268
4492
  /** Per-criterion results */
4269
- criteria: z10.array(CriterionResultSchema),
4493
+ criteria: z11.array(CriterionResultSchema),
4270
4494
  /** Whether all criteria are met */
4271
- allMet: z10.boolean()
4495
+ allMet: z11.boolean()
4272
4496
  });
4273
4497
 
4274
4498
  // src/orchestration/parallel-exploration-types.ts
4275
- import { z as z11 } from "zod";
4276
- var ParallelExplorationConfigSchema = z11.object({
4499
+ import { z as z12 } from "zod";
4500
+ var ParallelExplorationConfigSchema = z12.object({
4277
4501
  /** Max CLIs to dispatch to in parallel (default: 3) */
4278
- maxParallelClis: z11.number().int().min(1).max(4).default(3),
4502
+ maxParallelClis: z12.number().int().min(1).max(4).default(3),
4279
4503
  /** Timeout per CLI invocation in ms (default: explorationMs from centralized timeouts). */
4280
- perCliTimeoutMs: z11.number().int().min(1e3).max(3e5).default(PER_CLI_TASK_TIMEOUTS.explorationMs),
4504
+ perCliTimeoutMs: z12.number().int().min(1e3).max(3e5).default(PER_CLI_TASK_TIMEOUTS.explorationMs),
4281
4505
  /** Maximum output chars per CLI response (default: 8000, raised from 4k for exploration depth). */
4282
- maxOutputCharsPerCli: z11.number().int().min(100).max(2e4).default(8e3)
4506
+ maxOutputCharsPerCli: z12.number().int().min(100).max(2e4).default(8e3)
4283
4507
  });
4284
4508
 
4285
4509
  // src/orchestration/triangulated-review-types.ts
4286
- import { z as z12 } from "zod";
4287
- var TriangulatedReviewConfigSchema = z12.object({
4510
+ import { z as z13 } from "zod";
4511
+ var TriangulatedReviewConfigSchema = z13.object({
4288
4512
  /** Max CLIs to dispatch to (default: 3). */
4289
- maxClis: z12.number().int().min(1).max(4).default(3),
4513
+ maxClis: z13.number().int().min(1).max(4).default(3),
4290
4514
  /** Per-CLI timeout in ms (default from config/timeouts.ts, Issue #984). */
4291
- perCliTimeoutMs: z12.number().int().min(PER_CLI_TASK_TIMEOUTS.minMs).max(PER_CLI_TASK_TIMEOUTS.maxMs).default(PER_CLI_TASK_TIMEOUTS.defaultMs),
4515
+ perCliTimeoutMs: z13.number().int().min(PER_CLI_TASK_TIMEOUTS.minMs).max(PER_CLI_TASK_TIMEOUTS.maxMs).default(PER_CLI_TASK_TIMEOUTS.defaultMs),
4292
4516
  /** Max chars per CLI response (default: 8000). */
4293
- maxOutputCharsPerCli: z12.number().int().min(100).max(3e4).default(8e3),
4517
+ maxOutputCharsPerCli: z13.number().int().min(100).max(3e4).default(8e3),
4294
4518
  /** Line proximity for dedup: findings within N lines are considered same (default: 5). */
4295
- lineProximity: z12.number().int().min(0).max(50).default(5)
4519
+ lineProximity: z13.number().int().min(0).max(50).default(5)
4296
4520
  });
4297
4521
 
4298
4522
  // src/orchestration/triangulated-review.ts
4299
4523
  var moduleLogger = createLogger({ component: "triangulated-review" });
4300
4524
 
4301
4525
  // src/orchestration/consensus-plan-types.ts
4302
- import { z as z13 } from "zod";
4303
- var PlanStepSchema = z13.object({
4526
+ import { z as z14 } from "zod";
4527
+ var PlanStepSchema = z14.object({
4304
4528
  /** Step description. */
4305
- description: z13.string(),
4529
+ description: z14.string(),
4306
4530
  /** Estimated complexity: low, medium, high. */
4307
- complexity: z13.enum(["low", "medium", "high"]).default("medium"),
4531
+ complexity: z14.enum(["low", "medium", "high"]).default("medium"),
4308
4532
  /** Dependencies on other step indices. */
4309
- dependencies: z13.array(z13.number().int().min(0)).default([])
4533
+ dependencies: z14.array(z14.number().int().min(0)).default([])
4310
4534
  });
4311
- var PlanRiskSchema = z13.object({
4535
+ var PlanRiskSchema = z14.object({
4312
4536
  /** Risk description. */
4313
- description: z13.string(),
4537
+ description: z14.string(),
4314
4538
  /** Impact level. */
4315
- impact: z13.enum(["low", "medium", "high"]).default("medium"),
4539
+ impact: z14.enum(["low", "medium", "high"]).default("medium"),
4316
4540
  /** Mitigation strategy. */
4317
- mitigation: z13.string().default("")
4541
+ mitigation: z14.string().default("")
4318
4542
  });
4319
- var ConsensusPlanConfigSchema = z13.object({
4543
+ var ConsensusPlanConfigSchema = z14.object({
4320
4544
  /** Max CLIs to dispatch to (default: 3). */
4321
- maxClis: z13.number().int().min(1).max(4).default(3),
4545
+ maxClis: z14.number().int().min(1).max(4).default(3),
4322
4546
  /** Per-CLI timeout in ms (default from config/timeouts.ts, Issue #984). */
4323
- perCliTimeoutMs: z13.number().int().min(PER_CLI_TASK_TIMEOUTS.minMs).max(PER_CLI_TASK_TIMEOUTS.maxMs).default(PER_CLI_TASK_TIMEOUTS.defaultMs),
4547
+ perCliTimeoutMs: z14.number().int().min(PER_CLI_TASK_TIMEOUTS.minMs).max(PER_CLI_TASK_TIMEOUTS.maxMs).default(PER_CLI_TASK_TIMEOUTS.defaultMs),
4324
4548
  /** Max chars per CLI response (default: 8000). */
4325
- maxOutputCharsPerCli: z13.number().int().min(100).max(3e4).default(8e3)
4549
+ maxOutputCharsPerCli: z14.number().int().min(100).max(3e4).default(8e3)
4326
4550
  });
4327
4551
 
4328
4552
  // src/orchestration/consensus-plan.ts
4329
4553
  var moduleLogger2 = createLogger({ component: "consensus-plan" });
4330
4554
 
4331
4555
  // src/agents/observability/orchestration-observer-types.ts
4332
- import { z as z14 } from "zod";
4333
- var AgentStateSchema = z14.enum(["idle", "thinking", "executing", "waiting", "error"]);
4334
- var OrchestrationObserverConfigSchema = z14.object({
4556
+ import { z as z15 } from "zod";
4557
+ var AgentStateSchema = z15.enum(["idle", "thinking", "executing", "waiting", "error"]);
4558
+ var OrchestrationObserverConfigSchema = z15.object({
4335
4559
  /** Maximum routing decisions to retain in history */
4336
- maxRoutingHistory: z14.number().positive().optional().default(100),
4560
+ maxRoutingHistory: z15.number().positive().optional().default(100),
4337
4561
  /** Maximum session metrics to retain */
4338
- maxSessionHistory: z14.number().positive().optional().default(50),
4562
+ maxSessionHistory: z15.number().positive().optional().default(50),
4339
4563
  /** Metrics update interval in ms */
4340
- metricsUpdateIntervalMs: z14.number().positive().optional().default(5e3),
4564
+ metricsUpdateIntervalMs: z15.number().positive().optional().default(5e3),
4341
4565
  /** Enable detailed event logging */
4342
- verboseLogging: z14.boolean().optional().default(false),
4566
+ verboseLogging: z15.boolean().optional().default(false),
4343
4567
  /** Token cost rates per model (USD per 1K tokens) */
4344
- tokenCostRates: z14.record(z14.string(), z14.number().nonnegative()).optional().default({
4568
+ tokenCostRates: z15.record(z15.string(), z15.number().nonnegative()).optional().default({
4345
4569
  claude: 0.015,
4346
4570
  gemini: 1e-3,
4347
4571
  codex: 0.01
@@ -4568,7 +4792,7 @@ var DEFAULT_BENCHMARK_CONFIG = {
4568
4792
 
4569
4793
  // src/benchmarks/benchmark-runner.ts
4570
4794
  import { cpus, totalmem, platform, arch } from "os";
4571
- var logger5 = createLogger({ component: "benchmark-runner" });
4795
+ var logger6 = createLogger({ component: "benchmark-runner" });
4572
4796
  var LatencySampler = class {
4573
4797
  samples = [];
4574
4798
  startTimes = /* @__PURE__ */ new Map();
@@ -4664,11 +4888,11 @@ async function runOperationBenchmark(operation, datasetSize, fn, config = {}) {
4664
4888
  const startTime = getTimeProvider().now();
4665
4889
  const startMemory = process.memoryUsage().heapUsed;
4666
4890
  let peakMemory = startMemory;
4667
- logger5.debug("Running warmup", { operation, iterations: cfg.warmupIterations });
4891
+ logger6.debug("Running warmup", { operation, iterations: cfg.warmupIterations });
4668
4892
  for (let i = 0; i < cfg.warmupIterations; i++) {
4669
4893
  await fn();
4670
4894
  }
4671
- logger5.debug("Running measurements", { operation, iterations: cfg.measurementIterations });
4895
+ logger6.debug("Running measurements", { operation, iterations: cfg.measurementIterations });
4672
4896
  for (let i = 0; i < cfg.measurementIterations; i++) {
4673
4897
  const id = `op-${String(i)}`;
4674
4898
  sampler.start(id);
@@ -4793,7 +5017,7 @@ ${"=".repeat(60)}`);
4793
5017
  }
4794
5018
 
4795
5019
  // src/benchmarks/memory-benchmarks.ts
4796
- var logger6 = createLogger({ component: "memory-benchmarks" });
5020
+ var logger7 = createLogger({ component: "memory-benchmarks" });
4797
5021
  var DEFAULT_MEMORY_BENCHMARK_CONFIG = {
4798
5022
  ...DEFAULT_BENCHMARK_CONFIG,
4799
5023
  contentSizeBytes: 1024,
@@ -4901,9 +5125,9 @@ async function benchmarkPrune(backend, data, config) {
4901
5125
  async function runMemoryBenchmarks(backend, name, config = {}) {
4902
5126
  const cfg = { ...DEFAULT_MEMORY_BENCHMARK_CONFIG, ...config };
4903
5127
  const operations = [];
4904
- logger6.info("Starting memory benchmarks", { name, sizes: cfg.datasetSizes });
5128
+ logger7.info("Starting memory benchmarks", { name, sizes: cfg.datasetSizes });
4905
5129
  for (const size of cfg.datasetSizes) {
4906
- logger6.info("Running benchmarks for dataset size", { size });
5130
+ logger7.info("Running benchmarks for dataset size", { size });
4907
5131
  const data = generateTestData(size, cfg);
4908
5132
  try {
4909
5133
  const futureDate = new Date(getTimeProvider().now() + 365 * 24 * 60 * 60 * 1e3);
@@ -4917,7 +5141,7 @@ async function runMemoryBenchmarks(backend, name, config = {}) {
4917
5141
  }
4918
5142
  const environment = getBenchmarkEnvironment();
4919
5143
  const summary = createBenchmarkSummary(operations, cfg);
4920
- logger6.info("Benchmarks complete", {
5144
+ logger7.info("Benchmarks complete", {
4921
5145
  name,
4922
5146
  passed: summary.passed,
4923
5147
  avgP95: summary.avgP95Latency,
@@ -4963,7 +5187,7 @@ function compareBenchmarks(baseline, current) {
4963
5187
  }
4964
5188
 
4965
5189
  // src/benchmarks/token-benchmark.ts
4966
- var logger7 = createLogger({ component: "token-benchmark" });
5190
+ var logger8 = createLogger({ component: "token-benchmark" });
4967
5191
  var CHARS_PER_TOKEN = 4;
4968
5192
  function estimateTokens2(text) {
4969
5193
  return Math.ceil(text.length / CHARS_PER_TOKEN);
@@ -4981,7 +5205,7 @@ async function runTokenBenchmark(backend, config = {}) {
4981
5205
  const cfg = { ...DEFAULT_MEMORY_BENCHMARK_CONFIG, ...config };
4982
5206
  const results = [];
4983
5207
  for (const size of cfg.datasetSizes) {
4984
- logger7.info("Running token benchmark", { size });
5208
+ logger8.info("Running token benchmark", { size });
4985
5209
  const data = generateTestData(size, cfg);
4986
5210
  for (const entry of data.entries) {
4987
5211
  await backend.store(entry.key, entry.content, {
@@ -5014,15 +5238,15 @@ async function runTokenBenchmark(backend, config = {}) {
5014
5238
  }
5015
5239
 
5016
5240
  // src/benchmarks/consolidation-benchmark.ts
5017
- var logger8 = createLogger({ component: "consolidation-benchmark" });
5241
+ var logger9 = createLogger({ component: "consolidation-benchmark" });
5018
5242
  async function runConsolidationBenchmark(operations, config = {}) {
5019
5243
  const cfg = { ...DEFAULT_MEMORY_BENCHMARK_CONFIG, ...config };
5020
5244
  const benchmarks = [];
5021
- logger8.info("Starting consolidation benchmarks", {
5245
+ logger9.info("Starting consolidation benchmarks", {
5022
5246
  operationCount: operations.length
5023
5247
  });
5024
5248
  for (const op of operations) {
5025
- logger8.info("Benchmarking consolidation operation", { name: op.name });
5249
+ logger9.info("Benchmarking consolidation operation", { name: op.name });
5026
5250
  const benchmark = await runOperationBenchmark(
5027
5251
  op.name,
5028
5252
  0,
@@ -5137,7 +5361,7 @@ function formatBenchmarkReport(report) {
5137
5361
  }
5138
5362
 
5139
5363
  // src/benchmarks/adapter-latency-benchmark.ts
5140
- var logger9 = createLogger({ component: "adapter-latency-benchmark" });
5364
+ var logger10 = createLogger({ component: "adapter-latency-benchmark" });
5141
5365
  var DEFAULT_ADAPTER_LATENCY_CONFIG = {
5142
5366
  warmupIterations: 3,
5143
5367
  measurementIterations: 10,
@@ -5187,7 +5411,7 @@ async function benchmarkScenario(adapter, scenario, config) {
5187
5411
  const errors = [];
5188
5412
  let successCount = 0;
5189
5413
  let failureCount = 0;
5190
- logger9.info("Benchmarking scenario", {
5414
+ logger10.info("Benchmarking scenario", {
5191
5415
  adapter: adapter.name,
5192
5416
  scenario: scenario.name,
5193
5417
  warmup: config.warmupIterations,
@@ -5554,45 +5778,45 @@ function matchesArtifactFilter(artifact, filter) {
5554
5778
  }
5555
5779
 
5556
5780
  // src/pipeline/trace-schema.ts
5557
- import { z as z15 } from "zod";
5558
- var ExecutionTraceEntrySchema = z15.object({
5781
+ import { z as z16 } from "zod";
5782
+ var ExecutionTraceEntrySchema = z16.object({
5559
5783
  /** Unix timestamp (ms). */
5560
- timestamp: z15.number(),
5784
+ timestamp: z16.number(),
5561
5785
  /** Run identifier (typically TaskContract.id). */
5562
- runId: z15.string().min(1),
5786
+ runId: z16.string().min(1),
5563
5787
  /** Pipeline event type that produced this trace entry. */
5564
- eventType: z15.string().min(1),
5788
+ eventType: z16.string().min(1),
5565
5789
  /** Execution ID for pipeline correlation. */
5566
- executionId: z15.string().optional(),
5790
+ executionId: z16.string().optional(),
5567
5791
  /** Graph node or stage that produced this event. */
5568
- nodeId: z15.string().optional(),
5792
+ nodeId: z16.string().optional(),
5569
5793
  /** Agent that executed this step. */
5570
- agentId: z15.string().optional(),
5794
+ agentId: z16.string().optional(),
5571
5795
  /** Model used for this step. */
5572
- modelId: z15.string().optional(),
5796
+ modelId: z16.string().optional(),
5573
5797
  /** Agent role (e.g., code_expert, security_expert). */
5574
- role: z15.string().optional(),
5798
+ role: z16.string().optional(),
5575
5799
  /** Duration in milliseconds. */
5576
- durationMs: z15.number().optional(),
5800
+ durationMs: z16.number().optional(),
5577
5801
  /** Human-readable model selection reasoning. */
5578
- reasoning: z15.string().optional(),
5802
+ reasoning: z16.string().optional(),
5579
5803
  /** Routing decision path (stage:result pairs). */
5580
- decisionPath: z15.array(z15.string()).optional(),
5804
+ decisionPath: z16.array(z16.string()).optional(),
5581
5805
  /** Error classification. */
5582
- errorTaxonomy: z15.enum(["retriable", "fatal"]).optional(),
5806
+ errorTaxonomy: z16.enum(["retriable", "fatal"]).optional(),
5583
5807
  /** Error message if this is a failure event. */
5584
- error: z15.string().optional(),
5808
+ error: z16.string().optional(),
5585
5809
  /** Wave number (1-based) for wave dispatch events. */
5586
- waveNumber: z15.number().optional(),
5810
+ waveNumber: z16.number().optional(),
5587
5811
  /** Total waves in the dispatch plan. */
5588
- totalWaves: z15.number().optional(),
5812
+ totalWaves: z16.number().optional(),
5589
5813
  /** Number of workers in this wave. */
5590
- workerCount: z15.number().optional()
5814
+ workerCount: z16.number().optional()
5591
5815
  });
5592
5816
 
5593
5817
  // src/security/quality-gate-types.ts
5594
- import { z as z16 } from "zod";
5595
- var PipelineStageSchema = z16.enum([
5818
+ import { z as z17 } from "zod";
5819
+ var PipelineStageSchema = z17.enum([
5596
5820
  "research",
5597
5821
  "plan",
5598
5822
  "vote",
@@ -5601,20 +5825,20 @@ var PipelineStageSchema = z16.enum([
5601
5825
  "qa",
5602
5826
  "ship"
5603
5827
  ]);
5604
- var GateVerdictSchema = z16.enum(["pass", "fail", "skip"]);
5605
- var GateCheckResultSchema = z16.object({
5828
+ var GateVerdictSchema = z17.enum(["pass", "fail", "skip"]);
5829
+ var GateCheckResultSchema = z17.object({
5606
5830
  /** Name of the check (e.g., 'tests_pass', 'lint_clean'). */
5607
- name: z16.string().min(1),
5831
+ name: z17.string().min(1),
5608
5832
  /** Pass/fail/skip verdict. */
5609
5833
  verdict: GateVerdictSchema,
5610
5834
  /** Human-readable details. */
5611
- details: z16.string().max(500),
5835
+ details: z17.string().max(500),
5612
5836
  /** Duration of the check in ms. */
5613
- durationMs: z16.number().nonnegative().optional()
5837
+ durationMs: z17.number().nonnegative().optional()
5614
5838
  });
5615
5839
 
5616
5840
  // src/pipeline/quality-pipeline.ts
5617
- var logger10 = createLogger({ component: "quality-pipeline" });
5841
+ var logger11 = createLogger({ component: "quality-pipeline" });
5618
5842
 
5619
5843
  // src/pipeline/iterative-consensus.ts
5620
5844
  var defaultLogger = createLogger({ component: "iterative-consensus" });
@@ -5715,7 +5939,7 @@ function buildVotingInput(plan, config) {
5715
5939
  }
5716
5940
  async function executeSingleVote(plan, config, log) {
5717
5941
  try {
5718
- const { executeVoting } = await import("./consensus-vote-FEDF24T5.js");
5942
+ const { executeVoting } = await import("./consensus-vote-KF6M7NZJ.js");
5719
5943
  const input = buildVotingInput(plan, config);
5720
5944
  const result = await executeVoting(input, log);
5721
5945
  return parseVotingResult(result);
@@ -5748,10 +5972,12 @@ function parseVotingResult(result) {
5748
5972
  }
5749
5973
 
5750
5974
  // src/replay/replay-executor.ts
5751
- var logger11 = createLogger({ component: "ReplayExecutor" });
5975
+ var logger12 = createLogger({ component: "ReplayExecutor" });
5752
5976
  export {
5753
5977
  ALLOWED_COMMANDS,
5754
5978
  ARTIFACT_TYPES,
5979
+ AST_RULE_LANGUAGES,
5980
+ AST_RULE_SEVERITIES,
5755
5981
  AUDIT_PIPELINE_TEMPLATE,
5756
5982
  AbTestTracker,
5757
5983
  ActivationStrategySchema,
@@ -5862,6 +6088,7 @@ export {
5862
6088
  DECEPTION_CATEGORY,
5863
6089
  DEFAULT_ACTIVATION_OPTIONS,
5864
6090
  DEFAULT_ADAPTER_LATENCY_CONFIG,
6091
+ DEFAULT_AST_QA_LIMIT,
5865
6092
  DEFAULT_BENCHMARK_CONFIG,
5866
6093
  DEFAULT_BUDGET,
5867
6094
  DEFAULT_COLLECT_STREAM_MAX_CHUNKS,
@@ -5994,8 +6221,10 @@ export {
5994
6221
  LoadedSkillSetSchema,
5995
6222
  LoggingConfigSchema,
5996
6223
  MANIPULATION_CATEGORY,
6224
+ MAX_AST_QA_LIMIT,
5997
6225
  MAX_DIFF_LENGTH,
5998
6226
  MAX_EXECUTION_TIME_MS,
6227
+ MAX_FILES_SCANNED,
5999
6228
  MEM0_TARGETS,
6000
6229
  MIN_EXPERTS_FOR_PATTERN,
6001
6230
  MODEL_CAPABILITIES,
@@ -6284,6 +6513,7 @@ export {
6284
6513
  calculateBackoffDelay as cliCalculateBackoffDelay,
6285
6514
  categorizeError as cliCategorizeError,
6286
6515
  closeServer,
6516
+ collectAstQaFindings,
6287
6517
  collectRealVotes,
6288
6518
  collectStream,
6289
6519
  compareBenchmarks,
@@ -6433,6 +6663,7 @@ export {
6433
6663
  emitStateUpdated,
6434
6664
  emitStepCompleted,
6435
6665
  emitTrustEvent,
6666
+ ensurePolyglotLangs,
6436
6667
  err,
6437
6668
  estimateTokens2 as estimateBenchmarkTokens,
6438
6669
  estimateTaskComplexity,
@@ -6476,6 +6707,7 @@ export {
6476
6707
  getAvailableClis,
6477
6708
  getAvailableRoles,
6478
6709
  getBenchmarkEnvironment,
6710
+ getBuiltInAstRulesPath,
6479
6711
  getBuiltInTemplates,
6480
6712
  getBuiltInTemplatesPath,
6481
6713
  getBuiltInTemplatesWithMetadata,
@@ -6536,6 +6768,7 @@ export {
6536
6768
  isZodError,
6537
6769
  listTemplateIds,
6538
6770
  loadCheckpointState,
6771
+ loadRules,
6539
6772
  loadTemplateFile,
6540
6773
  loadTemplatesFromDirectory,
6541
6774
  loadWorkflowFile,
@@ -6626,6 +6859,7 @@ export {
6626
6859
  resultToOutcome,
6627
6860
  runAdapterLatencyBenchmark,
6628
6861
  runAdaptiveOrchestrator,
6862
+ runAstQaRules,
6629
6863
  runBenchmark,
6630
6864
  runConsensusGate,
6631
6865
  runConsolidationBenchmark,