crosscheck-mcp 0.2.22 → 0.2.24

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.
@@ -1306,7 +1306,7 @@ init_cjs_shims();
1306
1306
  var CREDIT_RE = /insufficient|no\s+credit|credits?|billing|quota|payment\s*required|exceeded your current quota|not\s+enough|fund|no active subscription|spend limit/i;
1307
1307
  function isCreditsFailure(status, bodyText) {
1308
1308
  if (status === 402) return true;
1309
- if (status === 401 || status === 403 || status === 429 || status === 400) {
1309
+ if (status === 401 || status === 403 || status === 400) {
1310
1310
  return CREDIT_RE.test(bodyText);
1311
1311
  }
1312
1312
  return false;
@@ -1343,7 +1343,7 @@ function httpFailureToProviderError(provider, status, bodyText, retryAfterS, mod
1343
1343
  if (status === 429) {
1344
1344
  return new ProviderError(
1345
1345
  "rate_limit",
1346
- `${provider}: rate limited (HTTP 429). Detail: ${detail}`,
1346
+ `${provider}: rate limited (HTTP 429) \u2014 retrying with backoff. Note that some providers word a rate limit as a balance problem; check your balance before topping up. Detail: ${detail}`,
1347
1347
  { status, ...retryAfterS !== void 0 ? { retryAfterS } : {} }
1348
1348
  );
1349
1349
  }
@@ -2133,10 +2133,20 @@ function fallbackModelsFor(env, provider) {
2133
2133
  if (pinned && pinned !== DEFAULT_MODELS[provider]) return [];
2134
2134
  return DEFAULT_FALLBACKS[provider] ?? [];
2135
2135
  }
2136
+ var DEFAULT_EXCLUDED_PROVIDERS = ["mistral", "groq"];
2137
+ function excludedProviders(env) {
2138
+ const parse = (v) => (v ?? "").split(",").map((x) => x.trim().toLowerCase()).filter((x) => x !== "");
2139
+ const excluded = new Set(
2140
+ parse(env["CROSSCHECK_EXCLUDE_PROVIDERS"]).length > 0 ? parse(env["CROSSCHECK_EXCLUDE_PROVIDERS"]) : DEFAULT_EXCLUDED_PROVIDERS
2141
+ );
2142
+ for (const name of parse(env["CROSSCHECK_ENABLE_PROVIDERS"])) excluded.delete(name);
2143
+ return excluded;
2144
+ }
2136
2145
  function buildProviders(opts) {
2137
2146
  const out = {};
2147
+ const excluded = excludedProviders(opts.env);
2138
2148
  const anthropicKey = opts.env["ANTHROPIC_API_KEY"];
2139
- if (anthropicKey) {
2149
+ if (anthropicKey && !excluded.has("anthropic")) {
2140
2150
  const model = opts.env["ANTHROPIC_MODEL"] ?? DEFAULT_MODELS.anthropic;
2141
2151
  out["anthropic"] = makeAnthropicProvider(model, anthropicKey, opts, fallbackModelsFor(opts.env, "anthropic"));
2142
2152
  }
@@ -2152,11 +2162,12 @@ function buildProviders(opts) {
2152
2162
  for (const s of openAiCompatSpec) {
2153
2163
  const apiKey = opts.env[s.keyEnv];
2154
2164
  if (!apiKey) continue;
2165
+ if (excluded.has(s.name)) continue;
2155
2166
  const model = opts.env[s.modelEnv] ?? s.defaultModel;
2156
2167
  out[s.name] = makeOpenAICompatibleProvider(s.name, model, apiKey, opts, fallbackModelsFor(opts.env, s.name));
2157
2168
  }
2158
2169
  const geminiKey = opts.env["GEMINI_API_KEY"];
2159
- if (geminiKey) {
2170
+ if (geminiKey && !excluded.has("gemini")) {
2160
2171
  const model = opts.env["GEMINI_MODEL"] ?? DEFAULT_MODELS.gemini;
2161
2172
  out["gemini"] = makeGeminiProvider(model, geminiKey, opts, fallbackModelsFor(opts.env, "gemini"));
2162
2173
  }
@@ -2352,7 +2363,7 @@ var import_zod = require("zod");
2352
2363
  // src/server-meta.ts
2353
2364
  init_cjs_shims();
2354
2365
  var SERVER_NAME = "crosscheck-agent";
2355
- var SERVER_VERSION = true ? "0.2.22" : "0.0.0-dev";
2366
+ var SERVER_VERSION = true ? "0.2.24" : "0.0.0-dev";
2356
2367
 
2357
2368
  // src/tools/audit.ts
2358
2369
  init_cjs_shims();
@@ -10202,6 +10213,66 @@ function isObj6(v) {
10202
10213
 
10203
10214
  // src/tools/debate.ts
10204
10215
  init_cjs_shims();
10216
+
10217
+ // src/core/debate-compaction.ts
10218
+ init_cjs_shims();
10219
+ var DEFAULT_PRIOR_BUDGET_CHARS = 12e3;
10220
+ function renderTurn(e) {
10221
+ return `[${e.provider} \u2014 round ${e.round}]
10222
+ ${e.response ?? "(error)"}`;
10223
+ }
10224
+ function buildPriorTurns(transcript, opts = {}) {
10225
+ if (transcript.length === 0) {
10226
+ return { body: "", includedTurns: 0, omittedTurns: 0, chars: 0 };
10227
+ }
10228
+ const rendered = transcript.map(renderTurn);
10229
+ const full = rendered.join("\n\n");
10230
+ if (!opts.compress) {
10231
+ return { body: full, includedTurns: transcript.length, omittedTurns: 0, chars: full.length };
10232
+ }
10233
+ const budget = Math.max(0, opts.budgetChars ?? DEFAULT_PRIOR_BUDGET_CHARS);
10234
+ if (full.length <= budget) {
10235
+ return { body: full, includedTurns: transcript.length, omittedTurns: 0, chars: full.length };
10236
+ }
10237
+ const latestRound = Math.max(...transcript.map((e) => e.round));
10238
+ const keep = /* @__PURE__ */ new Set();
10239
+ let spent = 0;
10240
+ for (let i = transcript.length - 1; i >= 0; i -= 1) {
10241
+ const isLatest = transcript[i].round === latestRound;
10242
+ const cost = rendered[i].length + 2;
10243
+ if (isLatest) {
10244
+ keep.add(i);
10245
+ spent += cost;
10246
+ continue;
10247
+ }
10248
+ if (spent + cost > budget) continue;
10249
+ keep.add(i);
10250
+ spent += cost;
10251
+ }
10252
+ const parts = [];
10253
+ let omitted = 0;
10254
+ let pendingGap = 0;
10255
+ for (let i = 0; i < transcript.length; i += 1) {
10256
+ if (keep.has(i)) {
10257
+ if (pendingGap > 0) {
10258
+ parts.push(`[${pendingGap} earlier turn(s) omitted for length]`);
10259
+ pendingGap = 0;
10260
+ }
10261
+ parts.push(rendered[i]);
10262
+ } else {
10263
+ omitted += 1;
10264
+ pendingGap += 1;
10265
+ }
10266
+ }
10267
+ if (pendingGap > 0) parts.push(`[${pendingGap} earlier turn(s) omitted for length]`);
10268
+ const body = parts.join("\n\n");
10269
+ return { body, includedTurns: keep.size, omittedTurns: omitted, chars: body.length };
10270
+ }
10271
+ function buildModeratorTranscript(transcript) {
10272
+ return transcript.map(renderTurn).join("\n\n");
10273
+ }
10274
+
10275
+ // src/tools/debate.ts
10205
10276
  var import_node_perf_hooks9 = require("perf_hooks");
10206
10277
  var DEFERRED_OPTS4 = [
10207
10278
  // empty — every debate opt runs natively when its deps
@@ -10249,6 +10320,9 @@ async function runDebate(args, opts) {
10249
10320
  1,
10250
10321
  Math.trunc(Number(args["max_rounds"] ?? 3)) || 3
10251
10322
  );
10323
+ const compressRounds = args["compress_rounds"] === true;
10324
+ const priorBudgetChars = Math.trunc(Number(args["prior_budget_chars"] ?? DEFAULT_PRIOR_BUDGET_CHARS)) || DEFAULT_PRIOR_BUDGET_CHARS;
10325
+ let compactionMeta = null;
10252
10326
  const sessionId = typeof args["session_id"] === "string" ? args["session_id"] : null;
10253
10327
  const breakerEnv = await maybeBreakerEnvelope(
10254
10328
  opts.storage,
@@ -10359,7 +10433,7 @@ async function runDebate(args, opts) {
10359
10433
  const roundMessages = [
10360
10434
  {
10361
10435
  role: "system",
10362
- content: `You are debating peers from other model families. Round ${rnd}/${maxRounds}. Disagree where warranted, concede where right, and keep replies short and specific.`
10436
+ content: "You are debating peers from other model families. Disagree where warranted, concede where right, and keep replies short and specific."
10363
10437
  }
10364
10438
  ];
10365
10439
  if (context) {
@@ -10371,13 +10445,22 @@ ${context}` });
10371
10445
  TOPIC: ${topic}` : `TOPIC: ${topic}`;
10372
10446
  roundMessages.push({ role: "user", content: topicLine });
10373
10447
  if (transcript.length > 0) {
10374
- const prior = transcript.map(
10375
- (e) => `[${e.provider} \u2014 round ${e.round}]
10376
- ${e.response ?? "(error)"}`
10377
- ).join("\n\n");
10448
+ const prior = buildPriorTurns(transcript, {
10449
+ compress: compressRounds,
10450
+ budgetChars: priorBudgetChars
10451
+ });
10452
+ if (prior.omittedTurns > 0) compactionMeta = {
10453
+ omitted_turns: prior.omittedTurns,
10454
+ included_turns: prior.includedTurns,
10455
+ budget_chars: priorBudgetChars
10456
+ };
10378
10457
  roundMessages.push({ role: "user", content: `PRIOR TURNS:
10379
- ${prior}` });
10458
+ ${prior.body}` });
10380
10459
  }
10460
+ roundMessages.push({
10461
+ role: "user",
10462
+ content: `This is round ${rnd} of ${maxRounds}. Reply for this round.`
10463
+ });
10381
10464
  for (const p of selected) {
10382
10465
  const entry = await callPanelist(p, roundMessages);
10383
10466
  const withRound = { ...entry, round: rnd };
@@ -10425,10 +10508,7 @@ ${prior}` });
10425
10508
  let coReasoned = false;
10426
10509
  if (moderator) {
10427
10510
  const synthProvider = superRequested && opts.providers["anthropic"] ? retargetForSuper(opts.providers["anthropic"]) : upgraded ? retargetProvider(opts.providers["anthropic"], UPGRADE_MODEL) : moderator;
10428
- const condensed = transcript.map(
10429
- (e) => `[${e.provider} \u2014 round ${e.round}]
10430
- ${e.response ?? "(error)"}`
10431
- ).join("\n\n");
10511
+ const condensed = buildModeratorTranscript(transcript);
10432
10512
  const persona = buildPersonaInjection({
10433
10513
  toolName: "debate",
10434
10514
  prompt: topic,
@@ -10511,6 +10591,7 @@ ${condensed}`
10511
10591
  synthesis
10512
10592
  };
10513
10593
  if (personaMeta && personaMeta.used !== null) result["persona"] = personaMeta;
10594
+ if (compactionMeta) result["round_compaction"] = compactionMeta;
10514
10595
  if (upgraded) {
10515
10596
  result["reasoning_upgrade"] = {
10516
10597
  applied: true,
@@ -12844,7 +12925,7 @@ var CHECK_INTERVAL_SECONDS = 3 * 24 * 60 * 60;
12844
12925
  var DEFAULT_PACKAGE = "crosscheck-cli";
12845
12926
  var FETCH_TIMEOUT_MS = 3e3;
12846
12927
  function engineVersion() {
12847
- return true ? "0.2.22" : "0.0.0-dev";
12928
+ return true ? "0.2.24" : "0.0.0-dev";
12848
12929
  }
12849
12930
  function defaultUpdateCachePath() {
12850
12931
  const base = process.env["CROSSCHECK_DATA_DIR"] || import_node_path13.default.join(import_node_os2.default.homedir() || import_node_os2.default.tmpdir(), ".crosscheck");