nexus-agents 2.150.2 → 2.150.4

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-BNQZKW3S.js";
11
+ } from "./chunk-UIUTDHRX.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-2ZUXJTIA.js.map
2003
+ //# sourceMappingURL=chunk-4ELTYI33.js.map
@@ -550,16 +550,63 @@ Respond with a JSON object containing:
550
550
 
551
551
  ${VOTE_PROMPT_EXAMPLES}`;
552
552
  }
553
+ function stepInString(state, ch) {
554
+ if (ch === "\\") state.escaped = true;
555
+ else if (ch === '"') state.inString = false;
556
+ }
557
+ function stepStructural(state, ch) {
558
+ if (ch === '"') state.inString = true;
559
+ else if (ch === "{") state.closers.push("}");
560
+ else if (ch === "[") state.closers.push("]");
561
+ else if (ch === "}" || ch === "]") {
562
+ if (state.closers.pop() === void 0) return "unbalanced";
563
+ if (state.closers.length === 0) return "complete";
564
+ }
565
+ return "continue";
566
+ }
567
+ function stepJsonScan(state, ch) {
568
+ if (state.escaped) {
569
+ state.escaped = false;
570
+ return "continue";
571
+ }
572
+ if (state.inString) {
573
+ stepInString(state, ch);
574
+ return "continue";
575
+ }
576
+ return stepStructural(state, ch);
577
+ }
578
+ function repairTruncatedObject(fragment, state) {
579
+ let repaired = state.inString ? `${fragment}"` : fragment;
580
+ for (let i = state.closers.length - 1; i >= 0; i--) {
581
+ const closer = state.closers[i];
582
+ if (closer !== void 0) repaired += closer;
583
+ }
584
+ return repaired;
585
+ }
586
+ function extractFirstJsonObject(text) {
587
+ const start = text.indexOf("{");
588
+ if (start === -1) return void 0;
589
+ const state = { closers: [], inString: false, escaped: false };
590
+ for (let i = start; i < text.length; i++) {
591
+ const result = stepJsonScan(state, text[i]);
592
+ if (result === "complete") return text.slice(start, i + 1);
593
+ if (result === "unbalanced") return void 0;
594
+ }
595
+ return state.closers.length > 0 ? repairTruncatedObject(text.slice(start), state) : void 0;
596
+ }
553
597
  function extractJsonFromResponse(text) {
554
- const codeBlockMatch = /```(?:json)?\s*([\s\S]*?)```/i.exec(text);
555
- if (codeBlockMatch?.[1] !== void 0) {
556
- return codeBlockMatch[1].trim();
598
+ const jsonFence = /```json\s*([\s\S]*?)```/i.exec(text);
599
+ if (jsonFence?.[1] !== void 0) {
600
+ return extractFirstJsonObject(jsonFence[1]) ?? jsonFence[1].trim();
557
601
  }
558
- const jsonMatch = /\{[\s\S]*\}/i.exec(text);
559
- if (jsonMatch?.[0] !== void 0) {
560
- return jsonMatch[0];
602
+ for (const match of text.matchAll(/```[a-zA-Z0-9]*\s*([\s\S]*?)```/g)) {
603
+ const inner = match[1];
604
+ if (inner?.trimStart().startsWith("{") === true) {
605
+ const obj = extractFirstJsonObject(inner);
606
+ if (obj !== void 0) return obj;
607
+ }
561
608
  }
562
- return text.trim();
609
+ return extractFirstJsonObject(text) ?? text.trim();
563
610
  }
564
611
  function createFallbackVote(output, _role, reason) {
565
612
  const lower = output.toLowerCase();
@@ -581,6 +628,30 @@ function createFallbackVote(output, _role, reason) {
581
628
  // Mark as synthetic
582
629
  };
583
630
  }
631
+ var REASONING_MAX_CHARS = 4e3;
632
+ var CLAIM_MAX_CHARS = 2e3;
633
+ var TRUNCATION_MARKER = " \u2026[truncated]";
634
+ function clampWithMarker(s, max) {
635
+ if (s.length <= max) return s;
636
+ return s.slice(0, Math.max(0, max - TRUNCATION_MARKER.length)) + TRUNCATION_MARKER;
637
+ }
638
+ function clampOversizeVoteStrings(parsed) {
639
+ if (typeof parsed !== "object" || parsed === null) return parsed;
640
+ const obj = { ...parsed };
641
+ if (typeof obj["reasoning"] === "string") {
642
+ obj["reasoning"] = clampWithMarker(obj["reasoning"], REASONING_MAX_CHARS);
643
+ }
644
+ if (Array.isArray(obj["findings"])) {
645
+ obj["findings"] = obj["findings"].map((finding) => {
646
+ if (typeof finding === "object" && finding !== null && typeof finding["claim"] === "string") {
647
+ const f = finding;
648
+ return { ...f, claim: clampWithMarker(f["claim"], CLAIM_MAX_CHARS) };
649
+ }
650
+ return finding;
651
+ });
652
+ }
653
+ return obj;
654
+ }
584
655
  function buildParsedVote(data) {
585
656
  return {
586
657
  decision: data.decision,
@@ -597,7 +668,7 @@ function parseVoteResponse(output, role, options) {
597
668
  try {
598
669
  const jsonStr = extractJsonFromResponse(output);
599
670
  const parsed = JSON.parse(jsonStr);
600
- const validated = VoteResponseSchema.safeParse(parsed);
671
+ const validated = VoteResponseSchema.safeParse(clampOversizeVoteStrings(parsed));
601
672
  if (validated.success) {
602
673
  return buildParsedVote(validated.data);
603
674
  }
@@ -721,8 +792,12 @@ function buildVoteRequest(role, proposal, timeoutMs, withResponseFormat) {
721
792
  { role: "system", content: VOTER_SYSTEM_PROMPTS[role] },
722
793
  { role: "user", content: buildVotePrompt(proposal) }
723
794
  ],
724
- // 2000 (#2245): JSON envelope + reasoning + YAML findings exceed the old 500.
725
- maxTokens: 2e3,
795
+ // 4000 (#4131): headroom so a findings-bearing verdict (JSON envelope +
796
+ // reasoning + structured findings) isn't cut mid-JSON by the token cap and
797
+ // silently dropped. Was 2000 (#2245, up from 500); large contrarian findings
798
+ // still overflowed it. Non-findings votes stop at natural completion, so the
799
+ // higher cap adds no cost for them.
800
+ maxTokens: 4e3,
726
801
  temperature: 0.3,
727
802
  // Low temperature for consistent evaluations
728
803
  // Thread the vote budget so the CLI timeout doesn't fire first (#3304); pass
@@ -6217,4 +6292,4 @@ export {
6217
6292
  CONSENSUS_VOTE_OUTPUT_SCHEMA,
6218
6293
  registerConsensusVoteTool
6219
6294
  };
6220
- //# sourceMappingURL=chunk-SF3AM3SY.js.map
6295
+ //# sourceMappingURL=chunk-CB234Y3O.js.map