nexus-agents 2.156.0 → 2.157.1

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-IDOAR55M.js";
11
+ } from "./chunk-RHUKGSH7.js";
12
12
  import {
13
13
  BUILT_IN_EXPERTS
14
14
  } from "./chunk-ZM4O442V.js";
@@ -2000,4 +2000,4 @@ export {
2000
2000
  setupCommand,
2001
2001
  setupCommandAsync
2002
2002
  };
2003
- //# sourceMappingURL=chunk-ODE5GDJ7.js.map
2003
+ //# sourceMappingURL=chunk-ENPYELJM.js.map
@@ -354,9 +354,7 @@ var SIMULATED_VOTE_REASONING = {
354
354
  import { z } from "zod";
355
355
  var SyntheticVoteError = class extends Error {
356
356
  constructor(reason, rawOutput) {
357
- super(
358
- `Vote response parsing failed: ${reason}. To use synthetic fallback votes (NOT RECOMMENDED), set allowSyntheticVote: true`
359
- );
357
+ super(`Vote response parsing failed: ${reason}`);
360
358
  this.rawOutput = rawOutput;
361
359
  this.name = "SyntheticVoteError";
362
360
  }
@@ -608,26 +606,6 @@ function extractJsonFromResponse(text) {
608
606
  }
609
607
  return extractFirstJsonObject(text) ?? text.trim();
610
608
  }
611
- function createFallbackVote(output, _role, reason) {
612
- const lower = output.toLowerCase();
613
- let decision = "abstain";
614
- if (lower.includes("reject") || lower.includes("decline") || lower.includes("disagree")) {
615
- decision = "reject";
616
- } else if (lower.includes("approve") || lower.includes("accept") || lower.includes("agree")) {
617
- decision = "approve";
618
- }
619
- createLogger({ component: "voter-response" }).warn(
620
- "Creating synthetic vote (NOT parsed from LLM output)",
621
- { decision, reason }
622
- );
623
- return {
624
- decision,
625
- reasoning: `[SYNTHETIC: ${reason}] ${output.slice(0, 200)}`,
626
- confidence: 0.5,
627
- source: "fallback"
628
- // Mark as synthetic
629
- };
630
- }
631
609
  var REASONING_MAX_CHARS = 4e3;
632
610
  var CLAIM_MAX_CHARS = 2e3;
633
611
  var TRUNCATION_MARKER = " \u2026[truncated]";
@@ -663,8 +641,7 @@ function buildParsedVote(data) {
663
641
  source: "parsed"
664
642
  };
665
643
  }
666
- function parseVoteResponse(output, role, options) {
667
- const allowSyntheticVote = options?.allowSyntheticVote ?? false;
644
+ function parseVoteResponse(output, _role) {
668
645
  try {
669
646
  const jsonStr = extractJsonFromResponse(output);
670
647
  const parsed = JSON.parse(jsonStr);
@@ -673,19 +650,12 @@ function parseVoteResponse(output, role, options) {
673
650
  return buildParsedVote(validated.data);
674
651
  }
675
652
  const reason = `Validation failed: ${validated.error.issues.map((e) => e.message).join(", ")}`;
676
- if (!allowSyntheticVote) {
677
- throw new SyntheticVoteError(reason, output);
678
- }
679
- return createFallbackVote(output, role, reason);
653
+ throw new SyntheticVoteError(reason, output);
680
654
  } catch (error) {
681
655
  if (error instanceof SyntheticVoteError) {
682
656
  throw error;
683
657
  }
684
- const reason = getErrorMessage(error, "Unknown parse error");
685
- if (!allowSyntheticVote) {
686
- throw new SyntheticVoteError(reason, output);
687
- }
688
- return createFallbackVote(output, role, reason);
658
+ throw new SyntheticVoteError(getErrorMessage(error, "Unknown parse error"), output);
689
659
  }
690
660
  }
691
661
 
@@ -5174,11 +5144,29 @@ function emitVoteRejectedSignal(result, bus, logger10) {
5174
5144
 
5175
5145
  // src/mcp/tools/simulation-guard.ts
5176
5146
  var WARNED = /* @__PURE__ */ new Set();
5147
+ var ALLOW_SIMULATE_ENV = "NEXUS_ALLOW_SIMULATE";
5177
5148
  function isTestRunner() {
5178
5149
  return process.env.VITEST === "true" || process.env.NODE_ENV === "test";
5179
5150
  }
5180
- function warnIfSimulatedOutsideTests(toolName, logger10) {
5181
- if (isTestRunner()) return;
5151
+ function checkSimulationAllowed(toolName, logger10) {
5152
+ if (isTestRunner()) return { allowed: true, optedIn: false };
5153
+ if (process.env[ALLOW_SIMULATE_ENV] === "1") {
5154
+ warnOnce(toolName, logger10);
5155
+ return { allowed: true, optedIn: true };
5156
+ }
5157
+ return {
5158
+ allowed: false,
5159
+ reason: `[${toolName}] simulateVotes=true is rejected outside test runners: simulated votes are RANDOM and must not produce real decisions (#4170). Set ${ALLOW_SIMULATE_ENV}=1 to explicitly opt in (demos only).`
5160
+ };
5161
+ }
5162
+ function simulationDeniedResult(reason) {
5163
+ return toolStructuredError({
5164
+ errorCategory: "permission",
5165
+ message: reason,
5166
+ detail: { optIn: `${ALLOW_SIMULATE_ENV}=1` }
5167
+ });
5168
+ }
5169
+ function warnOnce(toolName, logger10) {
5182
5170
  if (WARNED.has(toolName)) return;
5183
5171
  WARNED.add(toolName);
5184
5172
  logger10.warn(
@@ -6089,7 +6077,6 @@ function recordVoteSideEffects(proposal, strategy, result, logger10, ratifies) {
6089
6077
  }
6090
6078
  async function handleConsensusVote(deps, args) {
6091
6079
  const logger10 = deps.logger ?? createLogger({ tool: "consensus_vote" });
6092
- if (args.simulateVotes) warnIfSimulatedOutsideTests("consensus_vote", logger10);
6093
6080
  try {
6094
6081
  const result = await executeVoting(args, logger10, {
6095
6082
  ...deps.gatewayAdapters !== void 0 && { gatewayAdapters: deps.gatewayAdapters }
@@ -6177,6 +6164,10 @@ function createConsensusVoteHandler(deps) {
6177
6164
  message: `Validation error: ${formatZodError(validationResult.error)}`
6178
6165
  });
6179
6166
  }
6167
+ if (validationResult.data.simulateVotes) {
6168
+ const simCheck = checkSimulationAllowed("consensus_vote", ctx.logger);
6169
+ if (!simCheck.allowed) return simulationDeniedResult(simCheck.reason);
6170
+ }
6180
6171
  const strategy = validationResult.data.strategy ?? "simple_majority";
6181
6172
  ctx.logger.debug("Starting consensus vote", {
6182
6173
  strategy,
@@ -6380,7 +6371,8 @@ export {
6380
6371
  ConsensusVoteInputSchema,
6381
6372
  mapOutcomeToDecision,
6382
6373
  recordDecisionCost,
6383
- warnIfSimulatedOutsideTests,
6374
+ checkSimulationAllowed,
6375
+ simulationDeniedResult,
6384
6376
  resetCorrelationTracker,
6385
6377
  createPolicyFailedResult,
6386
6378
  maybeEscalateContrarian,
@@ -6389,4 +6381,4 @@ export {
6389
6381
  CONSENSUS_VOTE_OUTPUT_SCHEMA,
6390
6382
  registerConsensusVoteTool
6391
6383
  };
6392
- //# sourceMappingURL=chunk-BEJWHTRX.js.map
6384
+ //# sourceMappingURL=chunk-JWCD3JCB.js.map