nexus-agents 2.117.3 → 2.119.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.
@@ -8,7 +8,7 @@ import {
8
8
  checkSqlite,
9
9
  defaultConfig,
10
10
  initDataDirectories
11
- } from "./chunk-KU7GX43O.js";
11
+ } from "./chunk-WGVRUD3L.js";
12
12
  import {
13
13
  probeAllClis
14
14
  } from "./chunk-ONSYPTQV.js";
@@ -1987,4 +1987,4 @@ export {
1987
1987
  setupCommand,
1988
1988
  setupCommandAsync
1989
1989
  };
1990
- //# sourceMappingURL=chunk-KY6UJGXP.js.map
1990
+ //# sourceMappingURL=chunk-6M4BCY2N.js.map
@@ -115,7 +115,7 @@ import {
115
115
  DEFAULT_TASK_TTL_MS,
116
116
  DEFAULT_TOOL_RATE_LIMITS,
117
117
  clampTaskTtl
118
- } from "./chunk-KU7GX43O.js";
118
+ } from "./chunk-WGVRUD3L.js";
119
119
  import {
120
120
  resolveInsideRoot
121
121
  } from "./chunk-NUBSJGQZ.js";
@@ -34224,6 +34224,64 @@ function registerDelegateToModelTool(server, deps) {
34224
34224
  logger56.info("Registered delegate_to_model tool with secure handler and timeout protection");
34225
34225
  }
34226
34226
 
34227
+ // src/orchestration/graph/consensus-node.ts
34228
+ async function runConsensusGate(voter, input) {
34229
+ try {
34230
+ return await voter(input);
34231
+ } catch (error) {
34232
+ const message = error instanceof Error ? error.message : String(error);
34233
+ return {
34234
+ outcome: "rejected",
34235
+ feedback: `Consensus gate failed closed (voter error): ${message}`,
34236
+ detail: { error: message }
34237
+ };
34238
+ }
34239
+ }
34240
+ function createConsensusGateNode(options) {
34241
+ return async (state) => {
34242
+ let input;
34243
+ try {
34244
+ input = options.proposalFrom(state);
34245
+ } catch (error) {
34246
+ const message = error instanceof Error ? error.message : String(error);
34247
+ return {
34248
+ [options.verdictKey]: {
34249
+ outcome: "rejected",
34250
+ feedback: `Consensus gate failed closed (proposal extraction error): ${message}`,
34251
+ detail: { error: message }
34252
+ }
34253
+ };
34254
+ }
34255
+ const verdict = await runConsensusGate(options.voter, input);
34256
+ return { [options.verdictKey]: verdict };
34257
+ };
34258
+ }
34259
+ async function runGraphWithConsensus(options) {
34260
+ const proposalKey = options.proposalKey ?? "proposal";
34261
+ const verdictKey = options.verdictKey ?? "consensusVerdict";
34262
+ const gate = createConsensusGateNode({
34263
+ voter: options.voter,
34264
+ verdictKey,
34265
+ proposalFrom: (state) => {
34266
+ const raw2 = state[proposalKey];
34267
+ return { proposal: typeof raw2 === "string" ? raw2 : "" };
34268
+ }
34269
+ });
34270
+ const compiled = new GraphBuilder().addState(proposalKey, overwrite("")).addState(verdictKey, overwrite(null)).addNode("produce", options.produce).addNode("consensus", gate).addEdge(START, "produce").addEdge("produce", "consensus").addEdge("consensus", END).compile();
34271
+ if (!compiled.ok) {
34272
+ return err(
34273
+ new Error(
34274
+ `runGraphWithConsensus: graph compile failed: ${formatCompileError(compiled.error)}`
34275
+ )
34276
+ );
34277
+ }
34278
+ const execResult = await executeGraph(compiled.value, options.initialState ?? {});
34279
+ if (!execResult.ok) return err(execResult.error);
34280
+ const raw = execResult.value.finalState[verdictKey];
34281
+ const verdict = raw ?? void 0;
34282
+ return ok({ execution: execResult.value, verdict });
34283
+ }
34284
+
34227
34285
  // src/mcp/tools/run-graph-workflow-multicli-templates.ts
34228
34286
  var SECURITY_AUDIT_ASSIGNMENTS = [
34229
34287
  { node: "threat_model", preferredCli: "claude" },
@@ -41679,6 +41737,22 @@ function createBudgetGuard(budget) {
41679
41737
  });
41680
41738
  return new BudgetGuard(breaker);
41681
41739
  }
41740
+ var DEFAULT_BUDGET_TOLERANCE = 1.5;
41741
+ var BUDGET_TOLERANCE_ENV = "NEXUS_BUDGET_TOLERANCE";
41742
+ function resolveBudgetTolerance() {
41743
+ const raw = process.env[BUDGET_TOLERANCE_ENV];
41744
+ if (raw === void 0 || raw.trim() === "") return DEFAULT_BUDGET_TOLERANCE;
41745
+ const parsed = Number(raw);
41746
+ if (!Number.isFinite(parsed) || parsed < 1) return DEFAULT_BUDGET_TOLERANCE;
41747
+ return parsed;
41748
+ }
41749
+ function estimateRelativeBudget(estimateTokens2, tolerance = DEFAULT_BUDGET_TOLERANCE) {
41750
+ if (estimateTokens2 === void 0 || !Number.isFinite(estimateTokens2) || estimateTokens2 <= 0) {
41751
+ return void 0;
41752
+ }
41753
+ if (!Number.isFinite(tolerance) || tolerance < 1) return void 0;
41754
+ return { maxTokens: Math.ceil(estimateTokens2 * tolerance) };
41755
+ }
41682
41756
 
41683
41757
  // src/pipeline/agent-executor.ts
41684
41758
  var logger40 = createLogger({ component: "agent-executor" });
@@ -41725,12 +41799,21 @@ function recordOutcome(args) {
41725
41799
  }
41726
41800
  async function runExpert(guard, expertType, prompt, executionId) {
41727
41801
  if (guard.isExhausted()) {
41802
+ emitPipelineStageEvent("dev-pipeline", "budget", "failed", {
41803
+ reason: "budget_exceeded",
41804
+ expertType,
41805
+ ...executionId !== void 0 ? { executionId } : {}
41806
+ });
41807
+ logger40.warn("Budget exhausted \u2014 expert call skipped (#3262/#3395)", {
41808
+ expertType,
41809
+ ...executionId !== void 0 ? { executionId } : {}
41810
+ });
41728
41811
  return {
41729
41812
  success: false,
41730
41813
  text: "",
41731
41814
  expertType,
41732
41815
  durationMs: 0,
41733
- error: "Budget exhausted \u2014 expert call skipped (#3395)"
41816
+ error: "Budget exhausted \u2014 expert call skipped (estimate-relative cap, #3262/#3395)"
41734
41817
  };
41735
41818
  }
41736
41819
  const result = await executeExpert(expertType, prompt);
@@ -42934,6 +43017,14 @@ ${priorArt}` : research;
42934
43017
  };
42935
43018
  }
42936
43019
  function createVoteStageWrapper(stages) {
43020
+ const voter = async (input) => {
43021
+ const vote = await stages.vote(input.proposal, input.context ?? "");
43022
+ return {
43023
+ outcome: isApproved(vote) ? "approved" : "rejected",
43024
+ feedback: isApproved(vote) ? "" : getVoteFeedback(vote),
43025
+ detail: { vote }
43026
+ };
43027
+ };
42937
43028
  return {
42938
43029
  id: "vote",
42939
43030
  name: "Vote",
@@ -42941,19 +43032,14 @@ function createVoteStageWrapper(stages) {
42941
43032
  const start = getTimeProvider().now();
42942
43033
  const plan = typeof ctx.state[PIPELINE_STATE_KEYS.PLAN] === "string" ? ctx.state[PIPELINE_STATE_KEYS.PLAN] : "";
42943
43034
  const research = typeof ctx.state[PIPELINE_STATE_KEYS.RESEARCH] === "string" ? ctx.state[PIPELINE_STATE_KEYS.RESEARCH] : "";
42944
- try {
42945
- const vote = await stages.vote(plan, research);
42946
- const ms = getTimeProvider().now() - start;
42947
- const feedback = isApproved(vote) ? "" : getVoteFeedback(vote);
42948
- return {
42949
- stateKey: PIPELINE_STATE_KEYS.VOTE_RESULT,
42950
- value: { vote, feedback },
42951
- durationMs: ms,
42952
- success: isApproved(vote)
42953
- };
42954
- } catch (e) {
42955
- return failOutput(PIPELINE_STATE_KEYS.VOTE_RESULT, getErrorMessage(e), getTimeProvider().now() - start);
42956
- }
43035
+ const verdict = await runConsensusGate(voter, { proposal: plan, context: research });
43036
+ const vote = verdict.detail?.["vote"];
43037
+ return {
43038
+ stateKey: PIPELINE_STATE_KEYS.VOTE_RESULT,
43039
+ value: { vote, feedback: verdict.feedback },
43040
+ durationMs: getTimeProvider().now() - start,
43041
+ success: verdict.outcome === "approved"
43042
+ };
42957
43043
  }
42958
43044
  };
42959
43045
  }
@@ -44776,6 +44862,31 @@ ${task}`;
44776
44862
  throw err2;
44777
44863
  }
44778
44864
  }
44865
+ var OUTPUT_TOKEN_RATIO = 0.6;
44866
+ var DEFAULT_STAGE_COUNT = 6;
44867
+ function resolveRunBudget(task, templateId, logger56) {
44868
+ if (process.env["NEXUS_BUDGET_ENFORCE"] !== "1") return void 0;
44869
+ const effectiveId = templateId ?? classifyTask(task).pipelineType;
44870
+ const template = getTemplate(effectiveId) ?? getTemplate("general");
44871
+ const stageCount = template?.stages.length ?? DEFAULT_STAGE_COUNT;
44872
+ const perCall = Math.round(
44873
+ createSharedTaskAnalyzer().estimateTokens(task) * (1 + OUTPUT_TOKEN_RATIO)
44874
+ );
44875
+ const budget = estimateRelativeBudget(perCall * stageCount, resolveBudgetTolerance());
44876
+ if (budget === void 0) {
44877
+ logger56.warn("Budget enforcement on but no usable token estimate \u2014 running unguarded (#3262)", {
44878
+ perCall,
44879
+ stageCount
44880
+ });
44881
+ } else {
44882
+ logger56.info("Estimate-relative token budget enforced (#3262)", {
44883
+ template: effectiveId,
44884
+ stageCount,
44885
+ maxTokens: budget.maxTokens
44886
+ });
44887
+ }
44888
+ return budget;
44889
+ }
44779
44890
  function selectStageRegistry(template, task, agentStages) {
44780
44891
  const effectiveTemplate = template ?? classifyTask(task).pipelineType;
44781
44892
  if (effectiveTemplate === "greenfield") {
@@ -44804,7 +44915,8 @@ async function runPipelineHandler(args, logger56) {
44804
44915
  const agentStages = createAgentStages({
44805
44916
  simulateVotes: input.simulateVotes,
44806
44917
  votingStrategy: input.votingStrategy,
44807
- quickMode: input.quickMode
44918
+ quickMode: input.quickMode,
44919
+ budget: resolveRunBudget(task, input.template, logger56)
44808
44920
  });
44809
44921
  const stages = selectStageRegistry(input.template, task, agentStages);
44810
44922
  const result = await runAdaptiveOrchestrator(task, {
@@ -48806,6 +48918,9 @@ export {
48806
48918
  analyzeTask,
48807
48919
  selectModel,
48808
48920
  registerDelegateToModelTool,
48921
+ runConsensusGate,
48922
+ createConsensusGateNode,
48923
+ runGraphWithConsensus,
48809
48924
  getGraphWorkflowList,
48810
48925
  getGraphRegistry,
48811
48926
  ListExpertsInputSchema,
@@ -48959,4 +49074,4 @@ export {
48959
49074
  detectBackend,
48960
49075
  createTaskTracker
48961
49076
  };
48962
- //# sourceMappingURL=chunk-KZJHMSH6.js.map
49077
+ //# sourceMappingURL=chunk-I4BPTXSC.js.map