nexus-agents 2.26.1 → 2.28.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 (49) hide show
  1. package/README.md +7 -7
  2. package/dist/{chunk-X33QNBGA.js → chunk-E7EX2KQJ.js} +3 -5
  3. package/dist/{chunk-X33QNBGA.js.map → chunk-E7EX2KQJ.js.map} +1 -1
  4. package/dist/{chunk-BOWNZMPH.js → chunk-L2SHSW4T.js} +3017 -1300
  5. package/dist/chunk-L2SHSW4T.js.map +1 -0
  6. package/dist/{chunk-ARNVVQ5W.js → chunk-LKSTILEE.js} +1213 -117
  7. package/dist/chunk-LKSTILEE.js.map +1 -0
  8. package/dist/{chunk-L3LQ3RP5.js → chunk-QZEAD6AG.js} +10339 -6289
  9. package/dist/chunk-QZEAD6AG.js.map +1 -0
  10. package/dist/{chunk-LCHCASB7.js → chunk-UGNLR4NZ.js} +2 -2
  11. package/dist/{chunk-UVQ7R4C4.js → chunk-YSDUVCCZ.js} +137 -717
  12. package/dist/chunk-YSDUVCCZ.js.map +1 -0
  13. package/dist/cli.d.ts +8 -1
  14. package/dist/cli.js +644 -216
  15. package/dist/cli.js.map +1 -1
  16. package/dist/{dist-Y5F6UM2N.js → dist-H5XNXVAV.js} +1384 -1295
  17. package/dist/dist-H5XNXVAV.js.map +1 -0
  18. package/dist/doctor-deep-BDE2PHVX.js +11 -0
  19. package/dist/index.d.ts +4299 -7411
  20. package/dist/index.js +588 -132
  21. package/dist/index.js.map +1 -1
  22. package/dist/{setup-command-VNF3KTCJ.js → setup-command-SS7LMN7Y.js} +5 -6
  23. package/dist/setup-config-DSMOOLVW.js +9 -0
  24. package/dist/workflows/templates/code-review.yaml +1 -1
  25. package/dist/workflows/templates/refactoring.yaml +1 -1
  26. package/dist/workflows/templates/research-review.yaml +19 -4
  27. package/dist/workflows/templates/security-audit.yaml +1 -1
  28. package/dist/workflows/templates/standards-review.yaml +1 -1
  29. package/package.json +12 -12
  30. package/src/workflows/templates/code-review.yaml +1 -1
  31. package/src/workflows/templates/refactoring.yaml +1 -1
  32. package/src/workflows/templates/research-review.yaml +19 -4
  33. package/src/workflows/templates/security-audit.yaml +1 -1
  34. package/src/workflows/templates/standards-review.yaml +1 -1
  35. package/dist/chunk-ARNVVQ5W.js.map +0 -1
  36. package/dist/chunk-BOWNZMPH.js.map +0 -1
  37. package/dist/chunk-L3LQ3RP5.js.map +0 -1
  38. package/dist/chunk-LCDOP543.js +0 -365
  39. package/dist/chunk-LCDOP543.js.map +0 -1
  40. package/dist/chunk-PGNRXCYY.js +0 -776
  41. package/dist/chunk-PGNRXCYY.js.map +0 -1
  42. package/dist/chunk-UVQ7R4C4.js.map +0 -1
  43. package/dist/dist-Y5F6UM2N.js.map +0 -1
  44. package/dist/doctor-deep-I2J5CRFG.js +0 -13
  45. package/dist/setup-config-VQSWWJ5O.js +0 -9
  46. /package/dist/{chunk-LCHCASB7.js.map → chunk-UGNLR4NZ.js.map} +0 -0
  47. /package/dist/{doctor-deep-I2J5CRFG.js.map → doctor-deep-BDE2PHVX.js.map} +0 -0
  48. /package/dist/{setup-command-VNF3KTCJ.js.map → setup-command-SS7LMN7Y.js.map} +0 -0
  49. /package/dist/{setup-config-VQSWWJ5O.js.map → setup-config-DSMOOLVW.js.map} +0 -0
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ import {
3
3
  ARTIFACT_TYPES,
4
4
  ActivationStrategySchema,
5
5
  AdapterModelError,
6
+ AgentActionSchema,
6
7
  AgentEventSchema,
7
8
  AgentFindingSchema,
8
9
  AgentMessageSchema,
@@ -28,6 +29,7 @@ import {
28
29
  AuditQueryCriteriaSchema,
29
30
  AuditResourceSchema,
30
31
  AuditSeveritySchema,
32
+ AuditTrail,
31
33
  AuthorizationMethodSchema,
32
34
  AvailabilityCache,
33
35
  BUILT_IN_EXPERTS,
@@ -166,6 +168,7 @@ import {
166
168
  GitHubProvider,
167
169
  GitHubReviewer,
168
170
  GitHubUserInfo,
171
+ GitHubUserRoleSchema,
169
172
  GraphBuilder,
170
173
  HarnessExecutor,
171
174
  HarnessExecutorError,
@@ -177,6 +180,7 @@ import {
177
180
  InMemoryAuditStorage,
178
181
  InMemoryCheckpointStore,
179
182
  IndependentSubsetSchema,
183
+ InjectionFlagSchema,
180
184
  InputDefinitionSchema,
181
185
  InputDefinitionSchema2,
182
186
  InputTypeSchema,
@@ -185,6 +189,7 @@ import {
185
189
  ListExpertsInputSchema,
186
190
  ListWorkflowsInputSchema,
187
191
  LoadedSkillSetSchema,
192
+ LockedWriter,
188
193
  LoggingConfigSchema,
189
194
  MAX_EXECUTION_TIME_MS,
190
195
  MIN_EXPERTS_FOR_PATTERN,
@@ -219,6 +224,7 @@ import {
219
224
  PatchApplicatorError,
220
225
  PathScoreBreakdownSchema,
221
226
  PathScoreSchema,
227
+ PersistentOutcomeStore,
222
228
  PipelineRunner,
223
229
  PlanContractSchema,
224
230
  PluginManifestSchema,
@@ -238,6 +244,8 @@ import {
238
244
  PruningStrategy,
239
245
  QualitySignalsSchema,
240
246
  REJECTION_CATEGORIES,
247
+ REPO_COMPLEXITY,
248
+ ROLE_DEFAULT_TRUST,
241
249
  RateLimiter,
242
250
  ReasoningDepthSchema,
243
251
  ReasoningNodeMetadataSchema,
@@ -250,6 +258,7 @@ import {
250
258
  RepoSecurityPlanInputSchema,
251
259
  ReportGenerationError,
252
260
  ReportGenerator,
261
+ ReputationCache,
253
262
  RestApiConfigSchema,
254
263
  RestApiServer,
255
264
  ResultAggregator,
@@ -266,6 +275,8 @@ import {
266
275
  SWEBenchRunnerError,
267
276
  SWE_BENCH_DATASETS,
268
277
  SWE_BENCH_SYSTEM_PROMPT,
278
+ SanitizedInputSchema,
279
+ SanitizerConfigSchema,
269
280
  ScmError,
270
281
  ScoreBreakdownSchema,
271
282
  SdkAdapter,
@@ -295,16 +306,19 @@ import {
295
306
  SkillProvenanceSchema,
296
307
  SkillRBACSchema,
297
308
  SkillSecurityErrorSchema,
309
+ SourceCitationSchema,
298
310
  StageResultSchema,
299
311
  StageSpecSchema,
300
312
  StepExecutor,
301
313
  StreamCancelledError,
302
314
  StreamController,
303
315
  StreamError,
316
+ StrippedElementSchema,
304
317
  SubTaskSchema,
305
318
  SubtaskPrioritySchema,
306
319
  SubtaskStatusSchema,
307
320
  SupermajorityStrategy,
321
+ SuspiciousSignalSchema,
308
322
  SwarmObserver,
309
323
  SwarmObserver2,
310
324
  SwarmObserverConfigSchema,
@@ -317,6 +331,7 @@ import {
317
331
  TRINITY_ROLE_MAX_TOKENS,
318
332
  TRINITY_ROLE_PROMPTS,
319
333
  TRINITY_ROLE_TEMPERATURES,
334
+ TRUST_TIER_NUMERIC,
320
335
  TaskAnalysisResultSchema,
321
336
  TaskAnalysisSchema,
322
337
  TaskComplexity,
@@ -334,6 +349,7 @@ import {
334
349
  TestingExpert,
335
350
  TextDashboardRenderer,
336
351
  ToolSetSchema,
352
+ TraceLogger,
337
353
  TreeStateSchema,
338
354
  TreeStatisticsSchema,
339
355
  TrinityConfigSchema,
@@ -341,10 +357,12 @@ import {
341
357
  TrinityPhaseSchema,
342
358
  TrinityRoleSchema,
343
359
  TrinityStopReasonSchema,
360
+ TrustTierSchema,
344
361
  UnanimousStrategy,
345
362
  VOTING_THRESHOLDS,
346
363
  ValidationDashboard,
347
364
  VerifierVerdictSchema,
365
+ ViolationSchema,
348
366
  VoteDecisionSchema,
349
367
  VoteMessageSchema,
350
368
  VoteSchema,
@@ -376,10 +394,12 @@ import {
376
394
  append,
377
395
  applyPatch,
378
396
  areStepsCompleted,
397
+ assessReputation,
379
398
  bufferStream,
380
399
  buildDependencyGraph,
381
400
  buildDependencyGraph2,
382
401
  buildDockerArgs,
402
+ buildEnrichedPrompt,
383
403
  buildFinalResult,
384
404
  buildHarnessArgs,
385
405
  buildHarnessCommand,
@@ -399,10 +419,13 @@ import {
399
419
  calculateWinLoss,
400
420
  canApplyPatch,
401
421
  canExecuteSkill,
422
+ canInfluenceDecisions,
423
+ canProceed,
402
424
  cancelExecution,
403
425
  checkPermissionBoundary,
404
426
  checkPipelinePolicy,
405
427
  chunkByDirectory,
428
+ classifyTrust,
406
429
  clearRegistryCache,
407
430
  clearTemplateCache,
408
431
  collectRealVotes,
@@ -418,6 +441,8 @@ import {
418
441
  createArchitectureExpert,
419
442
  createAttestation,
420
443
  createAuditLogger,
444
+ createAuditTrail,
445
+ createBenchmarkMemory,
421
446
  createCheckpoint,
422
447
  createCheckpointStore,
423
448
  createClaudeAdapter,
@@ -440,6 +465,7 @@ import {
440
465
  createDependencyError,
441
466
  createDocumentationExpert,
442
467
  createDryRunHandler,
468
+ createEmptyContext,
443
469
  createEvaluationHarness,
444
470
  createEventBusBridge,
445
471
  createExecutionContext,
@@ -448,6 +474,7 @@ import {
448
474
  createExplorationPrompt,
449
475
  createFeedbackIntegration,
450
476
  createFullGitHubProvider,
477
+ createGraphAuditBridge,
451
478
  createHarnessExecutor,
452
479
  createHigherOrderVotingStrategy,
453
480
  createInitialCostMetrics,
@@ -525,14 +552,24 @@ import {
525
552
  denyMutationsWithoutModeRule,
526
553
  detectTestFramework,
527
554
  determineFinalStatus,
555
+ emitCorroborationEvent,
528
556
  emitExecutionComplete,
557
+ emitGraphExecutionEvent,
529
558
  emitNodeResults,
530
559
  emitNodeStarted,
560
+ emitPolicyEvent,
561
+ emitReputationEvent,
562
+ emitSanitizationEvent,
531
563
  emitStateUpdated,
532
564
  emitStepCompleted,
565
+ emitThresholdUpdate,
566
+ emitTrendDetected,
567
+ emitTrustEvent,
568
+ estimateDifficulty,
533
569
  estimateTokens,
534
570
  evaluatePolicy,
535
571
  evaluatePolicy2,
572
+ evaluatePolicy3,
536
573
  evaluatePredictions,
537
574
  executeDelegatePipeline,
538
575
  executeGraph,
@@ -542,12 +579,17 @@ import {
542
579
  executeParallel,
543
580
  executeSpec,
544
581
  exportReport,
582
+ extractApproach,
545
583
  extractBooleanField,
546
584
  extractExpressions,
585
+ extractFilesFromResponse,
586
+ extractHypothesis,
547
587
  extractModelName,
548
588
  extractNumberField,
589
+ extractPastSuccessRates,
549
590
  extractPatch,
550
591
  extractRepoFromInstanceId,
592
+ extractRepoName,
551
593
  extractSessionId,
552
594
  extractStringArrayField,
553
595
  extractStringField,
@@ -558,8 +600,10 @@ import {
558
600
  findActiveSession,
559
601
  findMissingDependencies,
560
602
  formatCompileError,
603
+ formatContextForPrompt,
561
604
  formatValidationResult,
562
605
  fromArray,
606
+ generateMcpConfig,
563
607
  generateProposalId,
564
608
  generateReport,
565
609
  generateSecurityPlan,
@@ -572,8 +616,10 @@ import {
572
616
  getCliForModelId,
573
617
  getCompletedInstanceIds,
574
618
  getCompletedSteps,
619
+ getCorroborationRules,
575
620
  getCpuCores,
576
621
  getDatasetInfo,
622
+ getDefaultAllowedTools,
577
623
  getDockerVersion,
578
624
  getEventBusStats,
579
625
  getExecutionDuration,
@@ -592,6 +638,7 @@ import {
592
638
  getRecommendedRole,
593
639
  getReferencedSteps,
594
640
  getRegistryManifest,
641
+ getRequiredTrustTier,
595
642
  getResultsFilePath,
596
643
  getSkillSetForTask,
597
644
  getSkillsForTask,
@@ -610,6 +657,8 @@ import {
610
657
  initializeEventBusBridge,
611
658
  isCancelled,
612
659
  isCliAvailable as isCliAvailable2,
660
+ isMutatingAction,
661
+ isReadOnlyAction,
613
662
  isStepCompleted,
614
663
  listInstances,
615
664
  loadDataset,
@@ -622,6 +671,7 @@ import {
622
671
  logToolInvocationAudit,
623
672
  logToolStart,
624
673
  logToolSuccess,
674
+ mapAuthorAssociation,
625
675
  mapResolutionStatus,
626
676
  mapStateToPhase,
627
677
  mapTestStatus,
@@ -645,6 +695,7 @@ import {
645
695
  quickSelect,
646
696
  readJsonResults,
647
697
  readPredictions,
698
+ recordOutcome,
648
699
  reduceStream,
649
700
  registerConsensusVoteTool,
650
701
  registerCorePlugins,
@@ -666,6 +717,9 @@ import {
666
717
  registerRunGraphWorkflowTool,
667
718
  registerRunWorkflowTool,
668
719
  registerTools,
720
+ requireApiKey,
721
+ requiresCitation,
722
+ requiresCorroboration,
669
723
  resetAvailabilityCache,
670
724
  resetPipelinePluginRegistry,
671
725
  resetRegistry,
@@ -680,11 +734,14 @@ import {
680
734
  resultToOutcome,
681
735
  runAgentOnInstance,
682
736
  runBenchmarkInstances,
737
+ runBenchmarkParallel,
683
738
  runPreconditions,
739
+ runSingleInstance,
684
740
  runTests,
685
741
  runVerification,
686
742
  safePathsRule,
687
743
  safeValidateExpertConfig,
744
+ sanitizeInput,
688
745
  scoreByHybrid,
689
746
  scoreByImportance,
690
747
  scoreByRecency,
@@ -694,6 +751,7 @@ import {
694
751
  setVariable,
695
752
  skip,
696
753
  snapshotContext,
754
+ sortByPriority,
697
755
  storeStepResult,
698
756
  take,
699
757
  takeUntil,
@@ -706,8 +764,12 @@ import {
706
764
  transformInstanceResult,
707
765
  transformStream,
708
766
  transformTestResult,
767
+ updateContext,
768
+ validateAgentAction,
769
+ validateApiKeyPresence,
709
770
  validateCapabilities,
710
771
  validateCommand,
772
+ validateCorroboration,
711
773
  validateDependencyGraph,
712
774
  validateDiskSpace,
713
775
  validateDocker,
@@ -733,7 +795,7 @@ import {
733
795
  withLogging,
734
796
  withTimeout,
735
797
  writePredictions
736
- } from "./chunk-L3LQ3RP5.js";
798
+ } from "./chunk-QZEAD6AG.js";
737
799
  import {
738
800
  BaseCliAdapter,
739
801
  CLI_TIMEOUT_PROFILES,
@@ -763,14 +825,8 @@ import {
763
825
  isCliAvailable,
764
826
  sleep,
765
827
  startStdioServer
766
- } from "./chunk-ARNVVQ5W.js";
828
+ } from "./chunk-LKSTILEE.js";
767
829
  import "./chunk-X2M7OF27.js";
768
- import {
769
- generateWeatherReport
770
- } from "./chunk-PGNRXCYY.js";
771
- import {
772
- PER_CLI_TASK_TIMEOUTS
773
- } from "./chunk-LCDOP543.js";
774
830
  import {
775
831
  AgentCapability,
776
832
  AgentError,
@@ -793,8 +849,8 @@ import {
793
849
  OrchestratorError,
794
850
  OutcomeFailureCategorySchema,
795
851
  OutcomeStore,
852
+ PER_CLI_TASK_TIMEOUTS,
796
853
  ParseError,
797
- PersistentOutcomeStore,
798
854
  PreferenceRouter,
799
855
  PreferenceRouterConfigSchema,
800
856
  QueryFeatureExtractor,
@@ -818,11 +874,11 @@ import {
818
874
  detectLatencyPatterns,
819
875
  detectSuccessPatterns,
820
876
  detectTrend,
821
- emitThresholdUpdate,
822
- emitTrendDetected,
823
877
  ensureLearningDir,
824
878
  err,
879
+ extractNonErrorMessage,
825
880
  formatZodError,
881
+ generateWeatherReport,
826
882
  getErrorMessage,
827
883
  getOutcomeStore,
828
884
  getRandomProvider,
@@ -841,7 +897,7 @@ import {
841
897
  toError,
842
898
  unwrap,
843
899
  unwrapOr
844
- } from "./chunk-BOWNZMPH.js";
900
+ } from "./chunk-L2SHSW4T.js";
845
901
  import "./chunk-UP2VWCW5.js";
846
902
 
847
903
  // src/adapters/factory.ts
@@ -854,7 +910,7 @@ var AdapterConfigSchema = z.object({
854
910
  /** API key for authentication (optional, may come from environment) */
855
911
  apiKey: z.string().optional(),
856
912
  /** Base URL for the API (optional, uses provider default) */
857
- baseUrl: z.string().url("Base URL must be a valid URL").optional(),
913
+ baseUrl: z.url("Base URL must be a valid URL").optional(),
858
914
  /** Request timeout in milliseconds */
859
915
  timeout: z.number().positive("Timeout must be positive").optional(),
860
916
  /** Maximum number of retries for failed requests */
@@ -1739,11 +1795,7 @@ var OpenAIAdapter = class extends BaseAdapter {
1739
1795
  }
1740
1796
  super(baseConfig);
1741
1797
  this.resolvedModelId = resolvedModelId;
1742
- if (!config.apiKey || config.apiKey.trim() === "") {
1743
- throw new ConfigError("OpenAI API key is required", {
1744
- context: { providerId: "openai", modelId: config.modelId }
1745
- });
1746
- }
1798
+ requireApiKey(config.apiKey, "OpenAI", config.modelId);
1747
1799
  this.client = this.createClient(config);
1748
1800
  }
1749
1801
  /**
@@ -1774,14 +1826,8 @@ var OpenAIAdapter = class extends BaseAdapter {
1774
1826
  if (!baseResult.ok) {
1775
1827
  return baseResult;
1776
1828
  }
1777
- const apiKey = this.config.apiKey;
1778
- if (apiKey === void 0 || apiKey === "" || apiKey.trim() === "") {
1779
- return err(
1780
- new ConfigError("OpenAI API key is required", {
1781
- context: { providerId: this.providerId, modelId: this.modelId }
1782
- })
1783
- );
1784
- }
1829
+ const keyResult = validateApiKeyPresence(this.config.apiKey, this.providerId, this.modelId);
1830
+ if (!keyResult.ok) return keyResult;
1785
1831
  return ok(void 0);
1786
1832
  }
1787
1833
  /**
@@ -2324,11 +2370,7 @@ var GeminiAdapter = class extends BaseAdapter {
2324
2370
  }
2325
2371
  super(baseConfig);
2326
2372
  this.resolvedModelId = resolvedModelId;
2327
- if (!config.apiKey || config.apiKey.trim() === "") {
2328
- throw new ConfigError("Google API key is required", {
2329
- context: { providerId: "google", modelId: config.modelId }
2330
- });
2331
- }
2373
+ requireApiKey(config.apiKey, "Google", config.modelId);
2332
2374
  this.client = new GoogleGenAI({ apiKey: config.apiKey });
2333
2375
  }
2334
2376
  /**
@@ -2340,14 +2382,8 @@ var GeminiAdapter = class extends BaseAdapter {
2340
2382
  if (!baseResult.ok) {
2341
2383
  return baseResult;
2342
2384
  }
2343
- const apiKey = this.config.apiKey;
2344
- if (apiKey === void 0 || apiKey === "" || apiKey.trim() === "") {
2345
- return err(
2346
- new ConfigError("Google API key is required", {
2347
- context: { providerId: this.providerId, modelId: this.modelId }
2348
- })
2349
- );
2350
- }
2385
+ const keyResult = validateApiKeyPresence(this.config.apiKey, this.providerId, this.modelId);
2386
+ if (!keyResult.ok) return keyResult;
2351
2387
  return ok(void 0);
2352
2388
  }
2353
2389
  /**
@@ -2899,13 +2935,13 @@ var JournalEventTypeSchema = z2.enum([
2899
2935
  "session_end"
2900
2936
  ]);
2901
2937
  var JournalEntrySchema = z2.object({
2902
- timestamp: z2.string().datetime(),
2938
+ timestamp: z2.iso.datetime(),
2903
2939
  event: JournalEventTypeSchema,
2904
2940
  sessionId: z2.string().min(1),
2905
2941
  taskId: z2.string().optional(),
2906
2942
  summary: z2.string(),
2907
2943
  tokensUsed: z2.number().int().nonnegative().optional(),
2908
- metadata: z2.record(z2.unknown()).optional()
2944
+ metadata: z2.record(z2.string(), z2.unknown()).optional()
2909
2945
  });
2910
2946
 
2911
2947
  // src/context/session-journal.ts
@@ -2985,16 +3021,26 @@ function createIndexes(db) {
2985
3021
  db.exec(`CREATE INDEX IF NOT EXISTS idx_outcomes_timestamp ON task_outcomes(timestamp)`);
2986
3022
  }
2987
3023
  function rowToDecision(row) {
3024
+ let alternativeModels = [];
3025
+ let taskProfile = {};
3026
+ try {
3027
+ alternativeModels = JSON.parse(row.alternative_models);
3028
+ } catch {
3029
+ }
3030
+ try {
3031
+ taskProfile = JSON.parse(row.task_profile);
3032
+ } catch {
3033
+ }
2988
3034
  return {
2989
3035
  id: row.id,
2990
3036
  traceId: row.trace_id,
2991
3037
  timestamp: new Date(row.timestamp).toISOString(),
2992
3038
  routerType: row.router_type,
2993
3039
  selectedModel: row.selected_model,
2994
- alternativeModels: JSON.parse(row.alternative_models),
3040
+ alternativeModels,
2995
3041
  confidence: row.confidence,
2996
3042
  reason: row.reason,
2997
- taskProfile: JSON.parse(row.task_profile),
3043
+ taskProfile,
2998
3044
  requestId: row.request_id ?? void 0
2999
3045
  };
3000
3046
  }
@@ -3073,6 +3119,7 @@ var SQLiteOutcomeStorage = class {
3073
3119
  logger;
3074
3120
  db = null;
3075
3121
  initialized = false;
3122
+ initPromise;
3076
3123
  constructor(config) {
3077
3124
  const validation = OutcomeStorageConfigSchema.safeParse(config);
3078
3125
  if (!validation.success) {
@@ -3096,6 +3143,12 @@ var SQLiteOutcomeStorage = class {
3096
3143
  /** Initialize the storage backend. */
3097
3144
  async initialize() {
3098
3145
  if (this.initialized) return ok(void 0);
3146
+ this.initPromise ??= this.doInitialize().finally(() => {
3147
+ this.initPromise = void 0;
3148
+ });
3149
+ return this.initPromise;
3150
+ }
3151
+ async doInitialize() {
3099
3152
  try {
3100
3153
  const betterSqlite3Module = await import("better-sqlite3").catch((error) => {
3101
3154
  this.logger.debug("Failed to import better-sqlite3", { error: String(error) });
@@ -3653,7 +3706,7 @@ var AbTestTracker = class {
3653
3706
  );
3654
3707
  const relativeImprovement = control.successRate > 0 ? (treatment.successRate - control.successRate) / control.successRate : 0;
3655
3708
  const recommendedSampleSize = calculateMinSampleSize(
3656
- control.successRate || 0.5,
3709
+ control.successRate,
3657
3710
  experiment.minimumDetectableEffect
3658
3711
  );
3659
3712
  const hasMinimumSampleSize = control.n >= experiment.minSampleSize && treatment.n >= experiment.minSampleSize;
@@ -4632,39 +4685,370 @@ function getSafetyTaxonomySummary() {
4632
4685
  };
4633
4686
  }
4634
4687
 
4635
- // src/orchestration/spec-parser-types.ts
4688
+ // src/security/firewall/firewall-types.ts
4636
4689
  import { z as z7 } from "zod";
4637
- var IssueReferenceSchema = z7.object({
4690
+ var FirewallStagesSchema = z7.object({
4691
+ sanitization: z7.boolean().default(true),
4692
+ trustClassification: z7.boolean().default(true),
4693
+ reputationAssessment: z7.boolean().default(false),
4694
+ policyEnforcement: z7.boolean().default(true),
4695
+ corroboration: z7.boolean().default(false),
4696
+ audit: z7.boolean().default(true)
4697
+ });
4698
+ var FirewallConfigSchema = z7.object({
4699
+ stages: FirewallStagesSchema.default(() => ({
4700
+ sanitization: true,
4701
+ trustClassification: true,
4702
+ reputationAssessment: false,
4703
+ policyEnforcement: true,
4704
+ corroboration: false,
4705
+ audit: true
4706
+ })),
4707
+ allowlistedMaintainers: z7.array(z7.string().min(1)).default([]),
4708
+ maxInputLength: z7.number().int().positive().default(5e4),
4709
+ context: z7.object({
4710
+ hasWriteAccess: z7.boolean().default(false),
4711
+ hasSecretAccess: z7.boolean().default(false)
4712
+ }).default(() => ({
4713
+ hasWriteAccess: false,
4714
+ hasSecretAccess: false
4715
+ }))
4716
+ });
4717
+ var ATLDataSchema = z7.object({
4718
+ tier: z7.enum(["1", "2", "3", "4"]),
4719
+ source: z7.string().min(1),
4720
+ user: z7.string().min(1),
4721
+ sanitized: z7.boolean(),
4722
+ rep: z7.number().min(0).max(1).optional()
4723
+ });
4724
+
4725
+ // src/security/firewall/agent-trust-labels.ts
4726
+ var ATL_PREFIX = "[ATL:";
4727
+ var ATL_SUFFIX = "]";
4728
+ var ATL_PATTERN = /^\[ATL:(.+)\]$/;
4729
+ function generateATL(data) {
4730
+ const validated = ATLDataSchema.parse(data);
4731
+ const parts = [
4732
+ `tier=${validated.tier}`,
4733
+ `source=${encodeATLValue(validated.source)}`,
4734
+ `user=${encodeATLValue(validated.user)}`,
4735
+ `sanitized=${String(validated.sanitized)}`
4736
+ ];
4737
+ if (validated.rep !== void 0) {
4738
+ parts.push(`rep=${validated.rep.toFixed(2)}`);
4739
+ }
4740
+ return `${ATL_PREFIX}${parts.join(",")}${ATL_SUFFIX}`;
4741
+ }
4742
+ function parseATL(atl) {
4743
+ const match = ATL_PATTERN.exec(atl.trim());
4744
+ if (match === null) return void 0;
4745
+ const body = match[1];
4746
+ if (body === void 0) return void 0;
4747
+ const raw = parseKeyValuePairs(body);
4748
+ if (raw === void 0) return void 0;
4749
+ return validateParsedATL(raw);
4750
+ }
4751
+ function parseKeyValuePairs(body) {
4752
+ const pairs = body.split(",");
4753
+ const raw = {};
4754
+ for (const pair of pairs) {
4755
+ const eqIndex = pair.indexOf("=");
4756
+ if (eqIndex < 1) return void 0;
4757
+ raw[pair.slice(0, eqIndex)] = pair.slice(eqIndex + 1);
4758
+ }
4759
+ return raw;
4760
+ }
4761
+ function validateParsedATL(raw) {
4762
+ const tier = raw["tier"];
4763
+ const source = raw["source"];
4764
+ const user = raw["user"];
4765
+ const sanitized = raw["sanitized"];
4766
+ if (tier === void 0 || source === void 0 || user === void 0 || sanitized === void 0) {
4767
+ return void 0;
4768
+ }
4769
+ const parsed = {
4770
+ tier,
4771
+ source: decodeATLValue(source),
4772
+ user: decodeATLValue(user),
4773
+ sanitized: sanitized === "true",
4774
+ ...raw["rep"] !== void 0 ? { rep: parseFloat(raw["rep"]) } : {}
4775
+ };
4776
+ const result = ATLDataSchema.safeParse(parsed);
4777
+ return result.success ? result.data : void 0;
4778
+ }
4779
+ function encodeATLValue(value) {
4780
+ return value.replace(/,/g, "%2C").replace(/=/g, "%3D").replace(/\]/g, "%5D");
4781
+ }
4782
+ function decodeATLValue(value) {
4783
+ return value.replace(/%2C/g, ",").replace(/%3D/g, "=").replace(/%5D/g, "]");
4784
+ }
4785
+
4786
+ // src/security/firewall/firewall-pipeline.ts
4787
+ var HostileInputFirewall = class {
4788
+ stages;
4789
+ allowlisted;
4790
+ maxInputLength;
4791
+ adapter;
4792
+ reputationCache;
4793
+ auditTrail;
4794
+ constructor(config) {
4795
+ const validated = FirewallConfigSchema.parse({
4796
+ stages: config.stages,
4797
+ allowlistedMaintainers: config.allowlistedMaintainers,
4798
+ maxInputLength: config.maxInputLength,
4799
+ context: config.context
4800
+ });
4801
+ this.stages = validated.stages;
4802
+ this.allowlisted = validated.allowlistedMaintainers;
4803
+ this.maxInputLength = validated.maxInputLength;
4804
+ this.adapter = config.adapter;
4805
+ this.reputationCache = new ReputationCache();
4806
+ this.auditTrail = createAuditTrail();
4807
+ }
4808
+ /**
4809
+ * Processes untrusted input through the firewall pipeline.
4810
+ * Returns a structured FirewallResult or a typed FirewallError.
4811
+ */
4812
+ process(input) {
4813
+ const start = Date.now();
4814
+ this.auditTrail.clear();
4815
+ const metaResult = this.runExtraction(input);
4816
+ if (!metaResult.ok) return metaResult;
4817
+ const meta = metaResult.value;
4818
+ const sanitized = this.runSanitization(meta);
4819
+ const trust = this.runClassification(meta, sanitized);
4820
+ const reputation = this.runReputation(meta, sanitized);
4821
+ const atl = this.buildATL(meta, trust, sanitized, reputation);
4822
+ const auditEvents = this.auditTrail.query().map((e) => ({ id: e.id, type: e.type }));
4823
+ return ok({
4824
+ sanitized,
4825
+ trust,
4826
+ ...reputation !== void 0 ? { reputation } : {},
4827
+ atl,
4828
+ auditEvents,
4829
+ durationMs: Date.now() - start
4830
+ });
4831
+ }
4832
+ /** Returns the internal audit trail for inspection. */
4833
+ getAuditTrail() {
4834
+ return this.auditTrail;
4835
+ }
4836
+ // ==========================================================================
4837
+ // Pipeline Stages (private)
4838
+ // ==========================================================================
4839
+ runExtraction(input) {
4840
+ try {
4841
+ const meta = this.adapter.extractMetadata(input);
4842
+ return ok(meta);
4843
+ } catch (cause) {
4844
+ const message = cause instanceof Error ? cause.message : String(cause);
4845
+ return err({
4846
+ code: "EXTRACTION_FAILED",
4847
+ message: `Adapter extraction failed: ${message}`,
4848
+ stage: "extraction"
4849
+ });
4850
+ }
4851
+ }
4852
+ runSanitization(meta) {
4853
+ if (!this.stages.sanitization) {
4854
+ return createPassthroughSanitized(meta);
4855
+ }
4856
+ const result = sanitizeInput(
4857
+ meta.content,
4858
+ meta.authorAssociation,
4859
+ meta.username,
4860
+ {
4861
+ allowlistedMaintainers: [...this.allowlisted],
4862
+ maxInputLength: this.maxInputLength
4863
+ }
4864
+ );
4865
+ if (this.stages.audit) {
4866
+ emitSanitizationEvent(this.auditTrail, {
4867
+ source: meta.sourceType,
4868
+ wasModified: result.wasModified,
4869
+ strippedCount: result.strippedElements.length,
4870
+ injectionFlagCount: result.injectionFlags.length
4871
+ });
4872
+ }
4873
+ return result;
4874
+ }
4875
+ runClassification(meta, sanitized) {
4876
+ if (!this.stages.trustClassification) {
4877
+ return createPassthroughClassification(meta);
4878
+ }
4879
+ const result = classifyTrust({
4880
+ username: meta.username,
4881
+ authorAssociation: meta.authorAssociation,
4882
+ sanitizedInput: sanitized,
4883
+ config: {
4884
+ allowlistedMaintainers: [...this.allowlisted]
4885
+ }
4886
+ });
4887
+ if (this.stages.audit) {
4888
+ emitTrustEvent(this.auditTrail, {
4889
+ username: meta.username,
4890
+ assignedTier: result.trustTier,
4891
+ userRole: result.userRole,
4892
+ isAllowlisted: result.isAllowlisted,
4893
+ wasDowngraded: result.wasDowngraded,
4894
+ reason: result.reason
4895
+ });
4896
+ }
4897
+ return result;
4898
+ }
4899
+ runReputation(meta, sanitized) {
4900
+ if (!this.stages.reputationAssessment) return void 0;
4901
+ const metadata = {
4902
+ username: meta.username,
4903
+ accountAgeDays: 365,
4904
+ priorContributions: 0,
4905
+ recentCommentCount: 0,
4906
+ recentCommentWindowMinutes: 60,
4907
+ authorAssociation: meta.authorAssociation.toUpperCase(),
4908
+ injectionFlags: sanitized.injectionFlags
4909
+ };
4910
+ const result = assessReputation(metadata, this.reputationCache);
4911
+ if (this.stages.audit) {
4912
+ emitReputationEvent(this.auditTrail, {
4913
+ username: meta.username,
4914
+ reputationScore: result.reputationScore,
4915
+ isSuspicious: result.isSuspicious,
4916
+ effectiveTier: result.effectiveTrustTier,
4917
+ signalCount: result.suspiciousSignals.length
4918
+ });
4919
+ }
4920
+ return result;
4921
+ }
4922
+ buildATL(meta, trust, sanitized, reputation) {
4923
+ const data = {
4924
+ tier: trust.trustTier,
4925
+ source: meta.sourceType,
4926
+ user: meta.username,
4927
+ sanitized: sanitized.wasModified,
4928
+ ...reputation !== void 0 ? { rep: reputation.reputationScore / 100 } : {}
4929
+ };
4930
+ return generateATL(data);
4931
+ }
4932
+ };
4933
+ function createPassthroughSanitized(meta) {
4934
+ return {
4935
+ content: meta.content,
4936
+ originalLength: meta.content.length,
4937
+ trustTier: "3",
4938
+ userRole: meta.authorAssociation,
4939
+ injectionFlags: [],
4940
+ strippedElements: [],
4941
+ wasModified: false,
4942
+ sanitizedAt: (/* @__PURE__ */ new Date()).toISOString()
4943
+ };
4944
+ }
4945
+ function createPassthroughClassification(meta) {
4946
+ return {
4947
+ trustTier: "3",
4948
+ userRole: meta.authorAssociation,
4949
+ isAllowlisted: false,
4950
+ wasDowngraded: false,
4951
+ reason: "Trust classification disabled \u2014 default Tier 3"
4952
+ };
4953
+ }
4954
+
4955
+ // src/security/firewall/github-adapter.ts
4956
+ import { z as z8 } from "zod";
4957
+ var GitHubIssueSchema = z8.object({
4958
+ type: z8.literal("issue"),
4959
+ username: z8.string().min(1),
4960
+ authorAssociation: z8.string().min(1),
4961
+ title: z8.string().default(""),
4962
+ body: z8.string().default("")
4963
+ });
4964
+ var GitHubCommentSchema = z8.object({
4965
+ type: z8.literal("comment"),
4966
+ username: z8.string().min(1),
4967
+ authorAssociation: z8.string().min(1),
4968
+ body: z8.string().default("")
4969
+ });
4970
+ var GitHubPRSchema = z8.object({
4971
+ type: z8.literal("pull_request"),
4972
+ username: z8.string().min(1),
4973
+ authorAssociation: z8.string().min(1),
4974
+ title: z8.string().default(""),
4975
+ body: z8.string().default("")
4976
+ });
4977
+ var GitHubInputSchema = z8.discriminatedUnion("type", [
4978
+ GitHubIssueSchema,
4979
+ GitHubCommentSchema,
4980
+ GitHubPRSchema
4981
+ ]);
4982
+ function toSourceType(type) {
4983
+ const mapping = {
4984
+ issue: "github-issue",
4985
+ comment: "github-comment",
4986
+ pull_request: "github-pr"
4987
+ };
4988
+ return mapping[type];
4989
+ }
4990
+ function extractContent(input) {
4991
+ if (input.type === "comment") return input.body;
4992
+ const title = input.title;
4993
+ const body = input.body;
4994
+ return title && body ? `${title}
4995
+
4996
+ ${body}` : title || body;
4997
+ }
4998
+ function createGitHubAdapter() {
4999
+ return {
5000
+ platform: "github",
5001
+ extractMetadata(input) {
5002
+ const result = GitHubInputSchema.safeParse(input);
5003
+ if (!result.success) {
5004
+ const issues = result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ");
5005
+ throw new Error(`GitHub input validation failed: ${issues}`);
5006
+ }
5007
+ const parsed = result.data;
5008
+ const role = mapAuthorAssociation(parsed.authorAssociation);
5009
+ return {
5010
+ username: parsed.username,
5011
+ authorAssociation: role,
5012
+ content: extractContent(parsed),
5013
+ sourceType: toSourceType(parsed.type)
5014
+ };
5015
+ }
5016
+ };
5017
+ }
5018
+
5019
+ // src/orchestration/spec-parser-types.ts
5020
+ import { z as z9 } from "zod";
5021
+ var IssueReferenceSchema = z9.object({
4638
5022
  /** Issue/PR number */
4639
- number: z7.number().int().positive(),
5023
+ number: z9.number().int().positive(),
4640
5024
  /** Raw text (e.g., "#123") */
4641
- raw: z7.string()
5025
+ raw: z9.string()
4642
5026
  });
4643
- var FileReferenceSchema = z7.object({
5027
+ var FileReferenceSchema = z9.object({
4644
5028
  /** File path (e.g., "src/foo.ts") */
4645
- path: z7.string(),
5029
+ path: z9.string(),
4646
5030
  /** Optional line number */
4647
- line: z7.number().int().positive().optional()
5031
+ line: z9.number().int().positive().optional()
4648
5032
  });
4649
- var ParsedSpecSchema = z7.object({
5033
+ var ParsedSpecSchema = z9.object({
4650
5034
  /** Spec title (from first H1 or H2 heading) */
4651
- title: z7.string().min(1),
5035
+ title: z9.string().min(1),
4652
5036
  /** Overview/description text */
4653
- overview: z7.string(),
5037
+ overview: z9.string(),
4654
5038
  /** List of requirements */
4655
- requirements: z7.array(z7.string()),
5039
+ requirements: z9.array(z9.string()),
4656
5040
  /** Acceptance criteria (checklist items) */
4657
- acceptanceCriteria: z7.array(z7.string()),
5041
+ acceptanceCriteria: z9.array(z9.string()),
4658
5042
  /** Constraints or limitations */
4659
- constraints: z7.array(z7.string()),
5043
+ constraints: z9.array(z9.string()),
4660
5044
  /** Issue/PR references found in the spec */
4661
- issueReferences: z7.array(IssueReferenceSchema),
5045
+ issueReferences: z9.array(IssueReferenceSchema),
4662
5046
  /** File path references found in the spec */
4663
- fileReferences: z7.array(FileReferenceSchema),
5047
+ fileReferences: z9.array(FileReferenceSchema),
4664
5048
  /** Sections that were missing from the spec */
4665
- missingSections: z7.array(z7.string()),
5049
+ missingSections: z9.array(z9.string()),
4666
5050
  /** Raw markdown source */
4667
- rawMarkdown: z7.string()
5051
+ rawMarkdown: z9.string()
4668
5052
  });
4669
5053
  var KNOWN_SECTIONS = [
4670
5054
  "overview",
@@ -4678,119 +5062,119 @@ var KNOWN_SECTIONS = [
4678
5062
  ];
4679
5063
 
4680
5064
  // src/orchestration/spec-decomposer-types.ts
4681
- import { z as z8 } from "zod";
4682
- var SubtaskTypeSchema = z8.enum(["code", "test", "docs", "config", "refactor"]);
4683
- var ComplexityLevelSchema = z8.enum(["simple", "moderate", "complex", "expert"]);
4684
- var SubtaskNodeSchema = z8.object({
5065
+ import { z as z10 } from "zod";
5066
+ var SubtaskTypeSchema = z10.enum(["code", "test", "docs", "config", "refactor"]);
5067
+ var ComplexityLevelSchema = z10.enum(["simple", "moderate", "complex", "expert"]);
5068
+ var SubtaskNodeSchema = z10.object({
4685
5069
  /** Unique identifier for this subtask */
4686
- id: z8.string().min(1),
5070
+ id: z10.string().min(1),
4687
5071
  /** Human-readable description of what this subtask does */
4688
- description: z8.string().min(1),
5072
+ description: z10.string().min(1),
4689
5073
  /** The type of work */
4690
5074
  type: SubtaskTypeSchema,
4691
5075
  /** Estimated complexity */
4692
5076
  complexity: ComplexityLevelSchema,
4693
5077
  /** Required capabilities for the executing agent */
4694
- capabilities: z8.array(z8.string()),
5078
+ capabilities: z10.array(z10.string()),
4695
5079
  /** IDs of subtasks this depends on */
4696
- dependsOn: z8.array(z8.string()),
5080
+ dependsOn: z10.array(z10.string()),
4697
5081
  /** Source requirement text that generated this subtask */
4698
- sourceRequirement: z8.string().optional()
5082
+ sourceRequirement: z10.string().optional()
4699
5083
  });
4700
- var DagEdgeSchema = z8.object({
5084
+ var DagEdgeSchema = z10.object({
4701
5085
  /** Source subtask ID */
4702
- from: z8.string().min(1),
5086
+ from: z10.string().min(1),
4703
5087
  /** Target subtask ID */
4704
- to: z8.string().min(1)
5088
+ to: z10.string().min(1)
4705
5089
  });
4706
- var TaskDagSchema = z8.object({
5090
+ var TaskDagSchema = z10.object({
4707
5091
  /** All subtask nodes */
4708
- nodes: z8.array(SubtaskNodeSchema),
5092
+ nodes: z10.array(SubtaskNodeSchema),
4709
5093
  /** Dependency edges (from must complete before to) */
4710
- edges: z8.array(DagEdgeSchema),
5094
+ edges: z10.array(DagEdgeSchema),
4711
5095
  /** Subtask IDs that can execute in parallel (no dependencies) */
4712
- roots: z8.array(z8.string()),
5096
+ roots: z10.array(z10.string()),
4713
5097
  /** Total estimated complexity across all subtasks */
4714
5098
  totalComplexity: ComplexityLevelSchema,
4715
5099
  /** Source spec title for traceability */
4716
- specTitle: z8.string()
5100
+ specTitle: z10.string()
4717
5101
  });
4718
5102
 
4719
5103
  // src/orchestration/scenario-validator-types.ts
4720
- import { z as z9 } from "zod";
4721
- var CriterionResultSchema = z9.object({
5104
+ import { z as z11 } from "zod";
5105
+ var CriterionResultSchema = z11.object({
4722
5106
  /** The original acceptance criterion text */
4723
- criterion: z9.string(),
5107
+ criterion: z11.string(),
4724
5108
  /** Whether this criterion was satisfied */
4725
- met: z9.boolean(),
5109
+ met: z11.boolean(),
4726
5110
  /** Which result(s) matched this criterion */
4727
- matchedResults: z9.array(z9.string())
5111
+ matchedResults: z11.array(z11.string())
4728
5112
  });
4729
- var ScenarioResultSchema = z9.object({
5113
+ var ScenarioResultSchema = z11.object({
4730
5114
  /** Satisfaction score from 0 (none met) to 1 (all met) */
4731
- satisfaction: z9.number().min(0).max(1),
5115
+ satisfaction: z11.number().min(0).max(1),
4732
5116
  /** Total acceptance criteria count */
4733
- totalCriteria: z9.number().int().nonnegative(),
5117
+ totalCriteria: z11.number().int().nonnegative(),
4734
5118
  /** Number of criteria met */
4735
- metCount: z9.number().int().nonnegative(),
5119
+ metCount: z11.number().int().nonnegative(),
4736
5120
  /** Per-criterion results */
4737
- criteria: z9.array(CriterionResultSchema),
5121
+ criteria: z11.array(CriterionResultSchema),
4738
5122
  /** Whether all criteria are met */
4739
- allMet: z9.boolean()
5123
+ allMet: z11.boolean()
4740
5124
  });
4741
5125
 
4742
5126
  // src/orchestration/parallel-exploration-types.ts
4743
- import { z as z10 } from "zod";
4744
- var ParallelExplorationConfigSchema = z10.object({
5127
+ import { z as z12 } from "zod";
5128
+ var ParallelExplorationConfigSchema = z12.object({
4745
5129
  /** Max CLIs to dispatch to in parallel (default: 3) */
4746
- maxParallelClis: z10.number().int().min(1).max(4).default(3),
4747
- /** Timeout per CLI invocation in ms (default: 60_000) */
4748
- perCliTimeoutMs: z10.number().int().min(1e3).max(3e5).default(6e4),
4749
- /** Maximum output chars per CLI response (default: 4000) */
4750
- maxOutputCharsPerCli: z10.number().int().min(100).max(2e4).default(4e3)
5130
+ maxParallelClis: z12.number().int().min(1).max(4).default(3),
5131
+ /** Timeout per CLI invocation in ms (default: explorationMs from centralized timeouts). */
5132
+ perCliTimeoutMs: z12.number().int().min(1e3).max(3e5).default(PER_CLI_TASK_TIMEOUTS.explorationMs),
5133
+ /** Maximum output chars per CLI response (default: 8000, raised from 4k for exploration depth). */
5134
+ maxOutputCharsPerCli: z12.number().int().min(100).max(2e4).default(8e3)
4751
5135
  });
4752
5136
 
4753
5137
  // src/orchestration/triangulated-review-types.ts
4754
- import { z as z11 } from "zod";
4755
- var TriangulatedReviewConfigSchema = z11.object({
5138
+ import { z as z13 } from "zod";
5139
+ var TriangulatedReviewConfigSchema = z13.object({
4756
5140
  /** Max CLIs to dispatch to (default: 3). */
4757
- maxClis: z11.number().int().min(1).max(4).default(3),
5141
+ maxClis: z13.number().int().min(1).max(4).default(3),
4758
5142
  /** Per-CLI timeout in ms (default from config/timeouts.ts, Issue #984). */
4759
- perCliTimeoutMs: z11.number().int().min(PER_CLI_TASK_TIMEOUTS.minMs).max(PER_CLI_TASK_TIMEOUTS.maxMs).default(PER_CLI_TASK_TIMEOUTS.defaultMs),
5143
+ perCliTimeoutMs: z13.number().int().min(PER_CLI_TASK_TIMEOUTS.minMs).max(PER_CLI_TASK_TIMEOUTS.maxMs).default(PER_CLI_TASK_TIMEOUTS.defaultMs),
4760
5144
  /** Max chars per CLI response (default: 8000). */
4761
- maxOutputCharsPerCli: z11.number().int().min(100).max(3e4).default(8e3),
5145
+ maxOutputCharsPerCli: z13.number().int().min(100).max(3e4).default(8e3),
4762
5146
  /** Line proximity for dedup: findings within N lines are considered same (default: 5). */
4763
- lineProximity: z11.number().int().min(0).max(50).default(5)
5147
+ lineProximity: z13.number().int().min(0).max(50).default(5)
4764
5148
  });
4765
5149
 
4766
5150
  // src/orchestration/triangulated-review.ts
4767
5151
  var moduleLogger = createLogger({ component: "triangulated-review" });
4768
5152
 
4769
5153
  // src/orchestration/consensus-plan-types.ts
4770
- import { z as z12 } from "zod";
4771
- var PlanStepSchema = z12.object({
5154
+ import { z as z14 } from "zod";
5155
+ var PlanStepSchema = z14.object({
4772
5156
  /** Step description. */
4773
- description: z12.string(),
5157
+ description: z14.string(),
4774
5158
  /** Estimated complexity: low, medium, high. */
4775
- complexity: z12.enum(["low", "medium", "high"]).default("medium"),
5159
+ complexity: z14.enum(["low", "medium", "high"]).default("medium"),
4776
5160
  /** Dependencies on other step indices. */
4777
- dependencies: z12.array(z12.number().int().min(0)).default([])
5161
+ dependencies: z14.array(z14.number().int().min(0)).default([])
4778
5162
  });
4779
- var PlanRiskSchema = z12.object({
5163
+ var PlanRiskSchema = z14.object({
4780
5164
  /** Risk description. */
4781
- description: z12.string(),
5165
+ description: z14.string(),
4782
5166
  /** Impact level. */
4783
- impact: z12.enum(["low", "medium", "high"]).default("medium"),
5167
+ impact: z14.enum(["low", "medium", "high"]).default("medium"),
4784
5168
  /** Mitigation strategy. */
4785
- mitigation: z12.string().default("")
5169
+ mitigation: z14.string().default("")
4786
5170
  });
4787
- var ConsensusPlanConfigSchema = z12.object({
5171
+ var ConsensusPlanConfigSchema = z14.object({
4788
5172
  /** Max CLIs to dispatch to (default: 3). */
4789
- maxClis: z12.number().int().min(1).max(4).default(3),
5173
+ maxClis: z14.number().int().min(1).max(4).default(3),
4790
5174
  /** Per-CLI timeout in ms (default from config/timeouts.ts, Issue #984). */
4791
- perCliTimeoutMs: z12.number().int().min(PER_CLI_TASK_TIMEOUTS.minMs).max(PER_CLI_TASK_TIMEOUTS.maxMs).default(PER_CLI_TASK_TIMEOUTS.defaultMs),
5175
+ perCliTimeoutMs: z14.number().int().min(PER_CLI_TASK_TIMEOUTS.minMs).max(PER_CLI_TASK_TIMEOUTS.maxMs).default(PER_CLI_TASK_TIMEOUTS.defaultMs),
4792
5176
  /** Max chars per CLI response (default: 8000). */
4793
- maxOutputCharsPerCli: z12.number().int().min(100).max(3e4).default(8e3)
5177
+ maxOutputCharsPerCli: z14.number().int().min(100).max(3e4).default(8e3)
4794
5178
  });
4795
5179
 
4796
5180
  // src/orchestration/consensus-plan.ts
@@ -4864,7 +5248,9 @@ var PIPELINE_EVENT_TYPES = [
4864
5248
  "learning.threshold_updated",
4865
5249
  "learning.trend_detected",
4866
5250
  "tool.invoked",
4867
- "tool.completed"
5251
+ "tool.completed",
5252
+ "wave.started",
5253
+ "wave.completed"
4868
5254
  ];
4869
5255
 
4870
5256
  // src/pipeline/artifact-store.ts
@@ -4992,7 +5378,9 @@ function recordStageFailed(event, store) {
4992
5378
  success: false,
4993
5379
  durationMs: 0,
4994
5380
  timestamp: new Date(event.timestamp).toISOString(),
4995
- source: "delegate"
5381
+ source: "delegate",
5382
+ failureCategory: categorizeOutcomeErrorMessage(event.error),
5383
+ errorMessage: event.error.slice(0, 500)
4996
5384
  };
4997
5385
  store.append(outcome);
4998
5386
  }
@@ -5005,34 +5393,40 @@ function normalizeCli(cli) {
5005
5393
  }
5006
5394
 
5007
5395
  // src/pipeline/trace-schema.ts
5008
- import { z as z13 } from "zod";
5009
- var ExecutionTraceEntrySchema = z13.object({
5396
+ import { z as z15 } from "zod";
5397
+ var ExecutionTraceEntrySchema = z15.object({
5010
5398
  /** Unix timestamp (ms). */
5011
- timestamp: z13.number(),
5399
+ timestamp: z15.number(),
5012
5400
  /** Run identifier (typically TaskContract.id). */
5013
- runId: z13.string().min(1),
5401
+ runId: z15.string().min(1),
5014
5402
  /** Pipeline event type that produced this trace entry. */
5015
- eventType: z13.string().min(1),
5403
+ eventType: z15.string().min(1),
5016
5404
  /** Execution ID for pipeline correlation. */
5017
- executionId: z13.string().optional(),
5405
+ executionId: z15.string().optional(),
5018
5406
  /** Graph node or stage that produced this event. */
5019
- nodeId: z13.string().optional(),
5407
+ nodeId: z15.string().optional(),
5020
5408
  /** Agent that executed this step. */
5021
- agentId: z13.string().optional(),
5409
+ agentId: z15.string().optional(),
5022
5410
  /** Model used for this step. */
5023
- modelId: z13.string().optional(),
5411
+ modelId: z15.string().optional(),
5024
5412
  /** Agent role (e.g., code_expert, security_expert). */
5025
- role: z13.string().optional(),
5413
+ role: z15.string().optional(),
5026
5414
  /** Duration in milliseconds. */
5027
- durationMs: z13.number().optional(),
5415
+ durationMs: z15.number().optional(),
5028
5416
  /** Human-readable model selection reasoning. */
5029
- reasoning: z13.string().optional(),
5417
+ reasoning: z15.string().optional(),
5030
5418
  /** Routing decision path (stage:result pairs). */
5031
- decisionPath: z13.array(z13.string()).optional(),
5419
+ decisionPath: z15.array(z15.string()).optional(),
5032
5420
  /** Error classification. */
5033
- errorTaxonomy: z13.enum(["retriable", "fatal"]).optional(),
5421
+ errorTaxonomy: z15.enum(["retriable", "fatal"]).optional(),
5034
5422
  /** Error message if this is a failure event. */
5035
- error: z13.string().optional()
5423
+ error: z15.string().optional(),
5424
+ /** Wave number (1-based) for wave dispatch events. */
5425
+ waveNumber: z15.number().optional(),
5426
+ /** Total waves in the dispatch plan. */
5427
+ totalWaves: z15.number().optional(),
5428
+ /** Number of workers in this wave. */
5429
+ workerCount: z15.number().optional()
5036
5430
  });
5037
5431
 
5038
5432
  // src/scm/factory.ts
@@ -5070,6 +5464,7 @@ export {
5070
5464
  AdapterFactory,
5071
5465
  AdapterModelError,
5072
5466
  RateLimiter2 as AdapterRateLimiter,
5467
+ AgentActionSchema,
5073
5468
  AgentCapability,
5074
5469
  AgentError,
5075
5470
  AgentEventSchema,
@@ -5097,6 +5492,7 @@ export {
5097
5492
  AuditQueryCriteriaSchema,
5098
5493
  AuditResourceSchema,
5099
5494
  AuditSeveritySchema,
5495
+ AuditTrail,
5100
5496
  AuthorizationMethodSchema,
5101
5497
  AvailabilityCache,
5102
5498
  BIAS_CATEGORY,
@@ -5270,6 +5666,7 @@ export {
5270
5666
  GitHubProvider,
5271
5667
  GitHubReviewer,
5272
5668
  GitHubUserInfo,
5669
+ GitHubUserRoleSchema,
5273
5670
  GraphBuilder,
5274
5671
  HARM_EMOTIONAL_CATEGORY,
5275
5672
  HARM_FINANCIAL_CATEGORY,
@@ -5279,6 +5676,7 @@ export {
5279
5676
  HigherOrderVotingConfigSchema,
5280
5677
  HigherOrderVotingResultSchema,
5281
5678
  HigherOrderVotingStrategy,
5679
+ HostileInputFirewall,
5282
5680
  ICTMConfigSchema,
5283
5681
  ICTMInferenceResultSchema,
5284
5682
  INSTRUCTION_SAFETY_CATEGORY,
@@ -5286,6 +5684,7 @@ export {
5286
5684
  InMemoryCheckpointStore,
5287
5685
  InMemoryPreferenceStore,
5288
5686
  IndependentSubsetSchema,
5687
+ InjectionFlagSchema,
5289
5688
  InputDefinitionSchema2 as InputDefinitionSchema,
5290
5689
  InputTypeSchema,
5291
5690
  SwarmObserverConfigSchema2 as InteractionObserverConfigSchema,
@@ -5297,6 +5696,7 @@ export {
5297
5696
  ListExpertsInputSchema,
5298
5697
  ListWorkflowsInputSchema,
5299
5698
  LoadedSkillSetSchema,
5699
+ LockedWriter,
5300
5700
  LoggingConfigSchema,
5301
5701
  MANIPULATION_CATEGORY,
5302
5702
  MAX_EXECUTION_TIME_MS,
@@ -5374,8 +5774,10 @@ export {
5374
5774
  QualitySignalsSchema,
5375
5775
  QueryFeatureExtractor,
5376
5776
  REJECTION_CATEGORIES,
5777
+ REPO_COMPLEXITY,
5377
5778
  RISK_AWARENESS_CATEGORY,
5378
5779
  ROBUSTNESS_CATEGORY,
5780
+ ROLE_DEFAULT_TRUST,
5379
5781
  RateLimitError,
5380
5782
  ReasoningDepthSchema,
5381
5783
  ReasoningNodeMetadataSchema,
@@ -5388,6 +5790,7 @@ export {
5388
5790
  RepoSecurityPlanInputSchema,
5389
5791
  ReportGenerationError,
5390
5792
  ReportGenerator,
5793
+ ReputationCache,
5391
5794
  RestApiConfigSchema,
5392
5795
  RestApiServer,
5393
5796
  DelegateRequestSchema as RestDelegateRequestSchema,
@@ -5421,6 +5824,8 @@ export {
5421
5824
  SafetyCategoryIdSchema,
5422
5825
  SafetyCategorySchema,
5423
5826
  SafetyTestCaseSchema,
5827
+ SanitizedInputSchema,
5828
+ SanitizerConfigSchema,
5424
5829
  ScenarioResultSchema,
5425
5830
  ScmError,
5426
5831
  ScoreBreakdownSchema,
@@ -5453,6 +5858,7 @@ export {
5453
5858
  SkillProvenanceSchema,
5454
5859
  SkillRBACSchema,
5455
5860
  SkillSecurityErrorSchema,
5861
+ SourceCitationSchema,
5456
5862
  StageResultSchema,
5457
5863
  StageSpecSchema,
5458
5864
  StrategyDistiller,
@@ -5463,6 +5869,7 @@ export {
5463
5869
  InputDefinitionSchema as StrictInputDefinitionSchema,
5464
5870
  WorkflowDefinitionSchema as StrictWorkflowDefinitionSchema,
5465
5871
  WorkflowStepSchema as StrictWorkflowStepSchema,
5872
+ StrippedElementSchema,
5466
5873
  SubTaskSchema,
5467
5874
  SubprocessCliAdapter,
5468
5875
  SubtaskNodeSchema,
@@ -5470,6 +5877,7 @@ export {
5470
5877
  SubtaskStatusSchema,
5471
5878
  SubtaskTypeSchema,
5472
5879
  SupermajorityStrategy,
5880
+ SuspiciousSignalSchema,
5473
5881
  SwarmObserver,
5474
5882
  SwarmObserverConfigSchema,
5475
5883
  SynthesizedResultSchema,
@@ -5480,6 +5888,7 @@ export {
5480
5888
  TRINITY_ROLE_MAX_TOKENS,
5481
5889
  TRINITY_ROLE_PROMPTS,
5482
5890
  TRINITY_ROLE_TEMPERATURES,
5891
+ TRUST_TIER_NUMERIC,
5483
5892
  TaskAnalysisResultSchema,
5484
5893
  TaskAnalysisSchema,
5485
5894
  TaskComplexity,
@@ -5502,6 +5911,7 @@ export {
5502
5911
  TokenCounter,
5503
5912
  TokenCounterProvider,
5504
5913
  ToolSetSchema,
5914
+ TraceLogger,
5505
5915
  TreeStateSchema,
5506
5916
  TreeStatisticsSchema,
5507
5917
  TrinityConfigSchema,
@@ -5509,12 +5919,14 @@ export {
5509
5919
  TrinityPhaseSchema,
5510
5920
  TrinityRoleSchema,
5511
5921
  TrinityStopReasonSchema,
5922
+ TrustTierSchema,
5512
5923
  UnanimousStrategy,
5513
5924
  VERSION,
5514
5925
  VOTING_THRESHOLDS,
5515
5926
  ValidationDashboard,
5516
5927
  ValidationError,
5517
5928
  VerifierVerdictSchema,
5929
+ ViolationSchema,
5518
5930
  VoteDecisionSchema,
5519
5931
  VoteMessageSchema,
5520
5932
  VoteSchema,
@@ -5545,9 +5957,11 @@ export {
5545
5957
  append,
5546
5958
  applyPatch,
5547
5959
  areStepsCompleted,
5960
+ assessReputation,
5548
5961
  bufferStream,
5549
5962
  buildDependencyGraph2 as buildDependencyGraph,
5550
5963
  buildDockerArgs,
5964
+ buildEnrichedPrompt,
5551
5965
  buildFinalResult,
5552
5966
  buildHarnessArgs,
5553
5967
  buildHarnessCommand,
@@ -5569,12 +5983,15 @@ export {
5569
5983
  calculateWinLoss,
5570
5984
  canApplyPatch,
5571
5985
  canExecuteSkill,
5986
+ canInfluenceDecisions,
5987
+ canProceed,
5572
5988
  cancelExecution,
5573
5989
  categorizeOutcomeError,
5574
5990
  categorizeOutcomeErrorMessage,
5575
5991
  checkPermissionBoundary,
5576
5992
  checkPipelinePolicy,
5577
5993
  chunkByDirectory,
5994
+ classifyTrust,
5578
5995
  clearRegistryCache,
5579
5996
  clearTemplateCache,
5580
5997
  closeServer,
@@ -5596,6 +6013,8 @@ export {
5596
6013
  createArchitectureExpert,
5597
6014
  createAttestation,
5598
6015
  createAuditLogger,
6016
+ createAuditTrail,
6017
+ createBenchmarkMemory,
5599
6018
  createCheckpoint,
5600
6019
  createCheckpointStore,
5601
6020
  createClaudeAdapter,
@@ -5621,6 +6040,7 @@ export {
5621
6040
  createDependencyError,
5622
6041
  createDocumentationExpert,
5623
6042
  createDryRunHandler,
6043
+ createEmptyContext,
5624
6044
  createEvaluationHarness,
5625
6045
  createEventBusBridge,
5626
6046
  createExecutionContext,
@@ -5631,7 +6051,9 @@ export {
5631
6051
  createFeedbackSubscriber,
5632
6052
  createFullGitHubProvider,
5633
6053
  createGeminiAdapter,
6054
+ createGitHubAdapter,
5634
6055
  createGitHubProvider,
6056
+ createGraphAuditBridge,
5635
6057
  createHarnessExecutor,
5636
6058
  createHigherOrderVotingStrategy,
5637
6059
  createInitialCostMetrics,
@@ -5722,19 +6144,27 @@ export {
5722
6144
  detectTestFramework,
5723
6145
  detectTrend,
5724
6146
  determineFinalStatus,
6147
+ emitCorroborationEvent,
5725
6148
  emitExecutionComplete,
6149
+ emitGraphExecutionEvent,
5726
6150
  emitNodeResults,
5727
6151
  emitNodeStarted,
6152
+ emitPolicyEvent,
6153
+ emitReputationEvent,
6154
+ emitSanitizationEvent,
5728
6155
  emitStateUpdated,
5729
6156
  emitStepCompleted,
5730
6157
  emitThresholdUpdate,
5731
6158
  emitTrendDetected,
6159
+ emitTrustEvent,
5732
6160
  err,
6161
+ estimateDifficulty,
5733
6162
  estimateTaskComplexity,
5734
6163
  estimateTokens,
5735
6164
  evaluatePolicy2 as evaluatePipelinePolicy,
5736
6165
  evaluatePolicy,
5737
6166
  evaluatePredictions,
6167
+ evaluatePolicy3 as evaluateSecurityPolicy,
5738
6168
  executeDelegatePipeline,
5739
6169
  executeGraph,
5740
6170
  executeHarness,
@@ -5743,12 +6173,18 @@ export {
5743
6173
  executeParallel,
5744
6174
  executeSpec,
5745
6175
  exportReport,
6176
+ extractApproach,
5746
6177
  extractBooleanField,
5747
6178
  extractExpressions,
6179
+ extractFilesFromResponse,
6180
+ extractHypothesis,
5748
6181
  extractModelName,
6182
+ extractNonErrorMessage,
5749
6183
  extractNumberField,
6184
+ extractPastSuccessRates,
5750
6185
  extractPatch,
5751
6186
  extractRepoFromInstanceId,
6187
+ extractRepoName,
5752
6188
  extractSessionId,
5753
6189
  extractStringArrayField,
5754
6190
  extractStringField,
@@ -5759,8 +6195,11 @@ export {
5759
6195
  findActiveSession,
5760
6196
  findMissingDependencies,
5761
6197
  formatCompileError,
6198
+ formatContextForPrompt,
5762
6199
  formatValidationResult,
5763
6200
  fromArray,
6201
+ generateATL,
6202
+ generateMcpConfig,
5764
6203
  generateProposalId,
5765
6204
  generateReport,
5766
6205
  generateSecurityPlan,
@@ -5777,8 +6216,10 @@ export {
5777
6216
  getCliForModelId,
5778
6217
  getCompletedInstanceIds,
5779
6218
  getCompletedSteps,
6219
+ getCorroborationRules,
5780
6220
  getCpuCores,
5781
6221
  getDatasetInfo,
6222
+ getDefaultAllowedTools,
5782
6223
  getDockerVersion,
5783
6224
  getEventBusStats,
5784
6225
  getExecutionDuration,
@@ -5799,6 +6240,7 @@ export {
5799
6240
  getRecommendedRole,
5800
6241
  getReferencedSteps,
5801
6242
  getRegistryManifest,
6243
+ getRequiredTrustTier,
5802
6244
  getResultsFilePath,
5803
6245
  getSafetyCategory,
5804
6246
  getSafetyTaxonomySummary,
@@ -5823,7 +6265,9 @@ export {
5823
6265
  isCancelled,
5824
6266
  isCliAvailable,
5825
6267
  isErr,
6268
+ isMutatingAction,
5826
6269
  isOk,
6270
+ isReadOnlyAction,
5827
6271
  isRetryableError,
5828
6272
  isCliAvailable2 as isSWEBenchCliAvailable,
5829
6273
  isStepCompleted,
@@ -5841,6 +6285,7 @@ export {
5841
6285
  logToolSuccess,
5842
6286
  logger,
5843
6287
  map,
6288
+ mapAuthorAssociation,
5844
6289
  mapErr,
5845
6290
  mapResolutionStatus,
5846
6291
  mapStateToPhase,
@@ -5851,6 +6296,7 @@ export {
5851
6296
  ok,
5852
6297
  orchestrateInputToTaskContract,
5853
6298
  overwrite,
6299
+ parseATL,
5854
6300
  parseAgentPairKey,
5855
6301
  parseExpression,
5856
6302
  parseJsonResults,
@@ -5866,6 +6312,7 @@ export {
5866
6312
  quickSelect,
5867
6313
  readJsonResults,
5868
6314
  readPredictions,
6315
+ recordOutcome,
5869
6316
  reduceStream,
5870
6317
  registerConsensusVoteTool,
5871
6318
  registerCorePlugins,
@@ -5887,6 +6334,8 @@ export {
5887
6334
  registerRunGraphWorkflowTool,
5888
6335
  registerRunWorkflowTool,
5889
6336
  registerTools,
6337
+ requiresCitation,
6338
+ requiresCorroboration,
5890
6339
  resetAvailabilityCache,
5891
6340
  resetPipelineArtifactStore,
5892
6341
  resetPipelinePluginRegistry,
@@ -5902,12 +6351,15 @@ export {
5902
6351
  resultToOutcome,
5903
6352
  runAgentOnInstance,
5904
6353
  runBenchmarkInstances,
6354
+ runBenchmarkParallel,
5905
6355
  runPreconditions,
6356
+ runSingleInstance,
5906
6357
  runTests,
5907
6358
  runVerification,
5908
6359
  safePathsRule,
5909
6360
  safeValidateExpertConfig,
5910
6361
  sanitize,
6362
+ sanitizeInput,
5911
6363
  scoreByHybrid,
5912
6364
  scoreByImportance,
5913
6365
  scoreByRecency,
@@ -5919,6 +6371,7 @@ export {
5919
6371
  skip,
5920
6372
  sleep,
5921
6373
  snapshotContext,
6374
+ sortByPriority,
5922
6375
  startStdioServer,
5923
6376
  storeStepResult,
5924
6377
  take,
@@ -5935,7 +6388,10 @@ export {
5935
6388
  transformTestResult,
5936
6389
  unwrap,
5937
6390
  unwrapOr,
6391
+ updateContext,
6392
+ validateAgentAction,
5938
6393
  validateCommand,
6394
+ validateCorroboration,
5939
6395
  validateDependencyGraph,
5940
6396
  validateDiskSpace,
5941
6397
  validateDocker,