nexus-agents 2.117.2 → 2.118.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.
@@ -115,7 +115,7 @@ import {
115
115
  DEFAULT_TASK_TTL_MS,
116
116
  DEFAULT_TOOL_RATE_LIMITS,
117
117
  clampTaskTtl
118
- } from "./chunk-KQB4RDAC.js";
118
+ } from "./chunk-VPWMPJYW.js";
119
119
  import {
120
120
  resolveInsideRoot
121
121
  } from "./chunk-NUBSJGQZ.js";
@@ -40417,8 +40417,6 @@ var PIPELINE_STATE_KEYS = {
40417
40417
  QA_ITERATIONS: "qaIterations",
40418
40418
  SECURITY_PASSED: "securityPassed",
40419
40419
  FINDINGS: "findings",
40420
- SYNTHESIS: "synthesis",
40421
- DELIVERABLES: "deliverables",
40422
40420
  PARSED_SPEC: "parsedSpec",
40423
40421
  SCAFFOLD_OUTPUT: "scaffoldOutput",
40424
40422
  COMPLETED: "completed"
@@ -40467,8 +40465,6 @@ function registerStateFields(builder) {
40467
40465
  builder.addState(keys.QA_ITERATIONS, { defaultValue: 0, reducer: { type: "overwrite" } });
40468
40466
  builder.addState(keys.SECURITY_PASSED, { defaultValue: false, reducer: { type: "overwrite" } });
40469
40467
  builder.addState(keys.FINDINGS, { defaultValue: [], reducer: { type: "overwrite" } });
40470
- builder.addState(keys.SYNTHESIS, { defaultValue: null, reducer: { type: "overwrite" } });
40471
- builder.addState(keys.DELIVERABLES, { defaultValue: [], reducer: { type: "overwrite" } });
40472
40468
  builder.addState(keys.PARSED_SPEC, { defaultValue: null, reducer: { type: "overwrite" } });
40473
40469
  builder.addState(keys.SCAFFOLD_OUTPUT, { defaultValue: null, reducer: { type: "overwrite" } });
40474
40470
  builder.addState(keys.COMPLETED, { defaultValue: false, reducer: { type: "overwrite" } });
@@ -40600,12 +40596,6 @@ var DEV_PIPELINE_TEMPLATE = {
40600
40596
  stages: ["research", "plan", "vote", "decompose", "implement", "qa", "security"],
40601
40597
  dryRunStopAfter: "vote"
40602
40598
  };
40603
- var RESEARCH_PIPELINE_TEMPLATE = {
40604
- id: "research",
40605
- name: "Research Pipeline",
40606
- stages: ["decompose", "investigate", "synthesize", "vote", "scaffold"],
40607
- dryRunStopAfter: "vote"
40608
- };
40609
40599
  var AUDIT_PIPELINE_TEMPLATE = {
40610
40600
  id: "audit",
40611
40601
  name: "Security Audit Pipeline",
@@ -40635,7 +40625,12 @@ var GENERAL_PIPELINE_TEMPLATE = {
40635
40625
  };
40636
40626
  var PIPELINE_TEMPLATES = /* @__PURE__ */ new Map([
40637
40627
  ["dev", DEV_PIPELINE_TEMPLATE],
40638
- ["research", RESEARCH_PIPELINE_TEMPLATE],
40628
+ // The `research` template (decompose → investigate → synthesize → vote →
40629
+ // scaffold) was retired in #3488: `investigate`/`synthesize` had no stage
40630
+ // implementation and the order was incoherent, so it could never run.
40631
+ // Research-classified tasks fall back to `general`/`dev` (#3489), which
40632
+ // already cover research → plan → vote. The complete-but-unwired
40633
+ // `runResearchPipeline` subsystem (#1711) is a separate decision — see #3492.
40639
40634
  ["audit", AUDIT_PIPELINE_TEMPLATE],
40640
40635
  ["greenfield", GREENFIELD_PIPELINE_TEMPLATE],
40641
40636
  ["general", GENERAL_PIPELINE_TEMPLATE]
@@ -40885,8 +40880,10 @@ async function runAdaptiveOrchestrator(task, options) {
40885
40880
  const result = await runGraphPipeline(cleanTask, template, options.stages, options);
40886
40881
  return { ...result, selectionMethod, taskClassification: classification };
40887
40882
  }
40883
+ var RETIRED_TEMPLATE_ALIASES = { research: "general" };
40888
40884
  function resolveTemplate(templateId) {
40889
- const template = getTemplate(templateId);
40885
+ const resolvedId = RETIRED_TEMPLATE_ALIASES[templateId] ?? templateId;
40886
+ const template = getTemplate(resolvedId);
40890
40887
  if (template !== void 0) return template;
40891
40888
  logger35.warn("Unknown template, falling back to dev", { templateId });
40892
40889
  const fallback = PIPELINE_TEMPLATES.get("dev");
@@ -41682,6 +41679,22 @@ function createBudgetGuard(budget) {
41682
41679
  });
41683
41680
  return new BudgetGuard(breaker);
41684
41681
  }
41682
+ var DEFAULT_BUDGET_TOLERANCE = 1.5;
41683
+ var BUDGET_TOLERANCE_ENV = "NEXUS_BUDGET_TOLERANCE";
41684
+ function resolveBudgetTolerance() {
41685
+ const raw = process.env[BUDGET_TOLERANCE_ENV];
41686
+ if (raw === void 0 || raw.trim() === "") return DEFAULT_BUDGET_TOLERANCE;
41687
+ const parsed = Number(raw);
41688
+ if (!Number.isFinite(parsed) || parsed < 1) return DEFAULT_BUDGET_TOLERANCE;
41689
+ return parsed;
41690
+ }
41691
+ function estimateRelativeBudget(estimateTokens2, tolerance = DEFAULT_BUDGET_TOLERANCE) {
41692
+ if (estimateTokens2 === void 0 || !Number.isFinite(estimateTokens2) || estimateTokens2 <= 0) {
41693
+ return void 0;
41694
+ }
41695
+ if (!Number.isFinite(tolerance) || tolerance < 1) return void 0;
41696
+ return { maxTokens: Math.ceil(estimateTokens2 * tolerance) };
41697
+ }
41685
41698
 
41686
41699
  // src/pipeline/agent-executor.ts
41687
41700
  var logger40 = createLogger({ component: "agent-executor" });
@@ -41728,12 +41741,21 @@ function recordOutcome(args) {
41728
41741
  }
41729
41742
  async function runExpert(guard, expertType, prompt, executionId) {
41730
41743
  if (guard.isExhausted()) {
41744
+ emitPipelineStageEvent("dev-pipeline", "budget", "failed", {
41745
+ reason: "budget_exceeded",
41746
+ expertType,
41747
+ ...executionId !== void 0 ? { executionId } : {}
41748
+ });
41749
+ logger40.warn("Budget exhausted \u2014 expert call skipped (#3262/#3395)", {
41750
+ expertType,
41751
+ ...executionId !== void 0 ? { executionId } : {}
41752
+ });
41731
41753
  return {
41732
41754
  success: false,
41733
41755
  text: "",
41734
41756
  expertType,
41735
41757
  durationMs: 0,
41736
- error: "Budget exhausted \u2014 expert call skipped (#3395)"
41758
+ error: "Budget exhausted \u2014 expert call skipped (estimate-relative cap, #3262/#3395)"
41737
41759
  };
41738
41760
  }
41739
41761
  const result = await executeExpert(expertType, prompt);
@@ -44779,6 +44801,31 @@ ${task}`;
44779
44801
  throw err2;
44780
44802
  }
44781
44803
  }
44804
+ var OUTPUT_TOKEN_RATIO = 0.6;
44805
+ var DEFAULT_STAGE_COUNT = 6;
44806
+ function resolveRunBudget(task, templateId, logger56) {
44807
+ if (process.env["NEXUS_BUDGET_ENFORCE"] !== "1") return void 0;
44808
+ const effectiveId = templateId ?? classifyTask(task).pipelineType;
44809
+ const template = getTemplate(effectiveId) ?? getTemplate("general");
44810
+ const stageCount = template?.stages.length ?? DEFAULT_STAGE_COUNT;
44811
+ const perCall = Math.round(
44812
+ createSharedTaskAnalyzer().estimateTokens(task) * (1 + OUTPUT_TOKEN_RATIO)
44813
+ );
44814
+ const budget = estimateRelativeBudget(perCall * stageCount, resolveBudgetTolerance());
44815
+ if (budget === void 0) {
44816
+ logger56.warn("Budget enforcement on but no usable token estimate \u2014 running unguarded (#3262)", {
44817
+ perCall,
44818
+ stageCount
44819
+ });
44820
+ } else {
44821
+ logger56.info("Estimate-relative token budget enforced (#3262)", {
44822
+ template: effectiveId,
44823
+ stageCount,
44824
+ maxTokens: budget.maxTokens
44825
+ });
44826
+ }
44827
+ return budget;
44828
+ }
44782
44829
  function selectStageRegistry(template, task, agentStages) {
44783
44830
  const effectiveTemplate = template ?? classifyTask(task).pipelineType;
44784
44831
  if (effectiveTemplate === "greenfield") {
@@ -44807,7 +44854,8 @@ async function runPipelineHandler(args, logger56) {
44807
44854
  const agentStages = createAgentStages({
44808
44855
  simulateVotes: input.simulateVotes,
44809
44856
  votingStrategy: input.votingStrategy,
44810
- quickMode: input.quickMode
44857
+ quickMode: input.quickMode,
44858
+ budget: resolveRunBudget(task, input.template, logger56)
44811
44859
  });
44812
44860
  const stages = selectStageRegistry(input.template, task, agentStages);
44813
44861
  const result = await runAdaptiveOrchestrator(task, {
@@ -48900,7 +48948,6 @@ export {
48900
48948
  runGraphPipeline,
48901
48949
  extractStateValue,
48902
48950
  DEV_PIPELINE_TEMPLATE,
48903
- RESEARCH_PIPELINE_TEMPLATE,
48904
48951
  AUDIT_PIPELINE_TEMPLATE,
48905
48952
  GENERAL_PIPELINE_TEMPLATE,
48906
48953
  PIPELINE_TEMPLATES,
@@ -48963,4 +49010,4 @@ export {
48963
49010
  detectBackend,
48964
49011
  createTaskTracker
48965
49012
  };
48966
- //# sourceMappingURL=chunk-NHPCBKC2.js.map
49013
+ //# sourceMappingURL=chunk-N53G2GXS.js.map