crosscheck-mcp 0.2.21 → 0.2.22

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.
@@ -413,7 +413,27 @@ var PROVIDER_CAPS = {
413
413
  // temperature, so the prefix is the fix.
414
414
  reasoning_prefixes: ["gpt-5", "gpt-6", "o1", "o3", "o4"]
415
415
  },
416
- xai: { family: "openai_chat", system_role: "inline", supports_temperature: true },
416
+ xai: {
417
+ family: "openai_chat",
418
+ system_role: "inline",
419
+ // Kept `true`, unlike other reasoning models: grok-4 accepts temperature
420
+ // (verified 200 at 0.4 and 1.0) and a panel wants the variance. Dropping
421
+ // it would buy nothing and cost diversity.
422
+ supports_temperature: true,
423
+ // grok-4 IS reasoning-class — it emitted 1,432 reasoning tokens against 64
424
+ // visible on one call. Saying so strips the "think step by step" preambles
425
+ // it does not need, and lifts it off the non-reasoning ceiling (1500) onto
426
+ // the reasoning-safe one (2048).
427
+ //
428
+ // NOT the reason grok answers short, which was the initial guess and was
429
+ // wrong: at caps of 1500, 2048 and 6144 it returned 445, 404 and 461
430
+ // visible tokens, finish_reason=stop every time. The cap was never
431
+ // binding; grok is simply terse. The ceiling change removes a latent
432
+ // constraint, it does not make grok say more.
433
+ reasoning_prefixes: ["grok-4"],
434
+ // Measured: xAI's cap bounds visible output only. See the field docs.
435
+ reasoning_shares_output_budget: false
436
+ },
417
437
  mistral: { family: "openai_chat", system_role: "inline", supports_temperature: true },
418
438
  groq: { family: "openai_chat", system_role: "inline", supports_temperature: true },
419
439
  deepseek: { family: "openai_chat", system_role: "inline", supports_temperature: true },
@@ -452,6 +472,10 @@ function supportsTemperature(provider, model) {
452
472
  if (caps.supports_temperature === "model") return !isReasoningModel(provider, model);
453
473
  return Boolean(caps.supports_temperature);
454
474
  }
475
+ function reasoningSharesOutputBudget(provider) {
476
+ const caps = PROVIDER_CAPS[provider.toLowerCase()];
477
+ return caps?.reasoning_shares_output_budget ?? true;
478
+ }
455
479
 
456
480
  // src/providers/types.ts
457
481
  var ProviderError = class extends Error {
@@ -693,6 +717,23 @@ async function acquireRateLimit(provider, deps) {
693
717
  var ANTHROPIC_API_URL = "https://api.anthropic.com/v1/messages";
694
718
  var ANTHROPIC_VERSION_HEADER = "2023-06-01";
695
719
  var ANTHROPIC_STRUCTURED_TOOL_NAME = "structured_output";
720
+ function applyPromptCaching(body, env = process.env) {
721
+ const flag = (env["CROSSCHECK_ANTHROPIC_PROMPT_CACHE"] ?? "").trim();
722
+ if (flag === "0" || flag.toLowerCase() === "false") return;
723
+ if (typeof body.system === "string" && body.system !== "") {
724
+ body.system = [{ type: "text", text: body.system, cache_control: { type: "ephemeral" } }];
725
+ }
726
+ if (body.messages.length >= 2) {
727
+ const idx = body.messages.length - 2;
728
+ const m = body.messages[idx];
729
+ if (typeof m.content === "string" && m.content !== "") {
730
+ body.messages[idx] = {
731
+ role: m.role,
732
+ content: [{ type: "text", text: m.content, cache_control: { type: "ephemeral" } }]
733
+ };
734
+ }
735
+ }
736
+ }
696
737
  function buildAnthropicRequest(opts) {
697
738
  let system;
698
739
  const convo = [];
@@ -717,6 +758,7 @@ function buildAnthropicRequest(opts) {
717
758
  if (system !== void 0) {
718
759
  body.system = system;
719
760
  }
761
+ applyPromptCaching(body);
720
762
  if (isReasoningModel("anthropic", opts.model)) {
721
763
  if (opts.model.toLowerCase().startsWith("claude-fable-5")) {
722
764
  body.thinking = { type: "adaptive" };
@@ -776,6 +818,7 @@ function parseAnthropicResponse(opts) {
776
818
  const prompt = Math.trunc(Number(u["input_tokens"] ?? 0)) || 0;
777
819
  const cached = Math.trunc(Number(u["cache_read_input_tokens"] ?? 0)) || 0;
778
820
  const completion = Math.trunc(Number(u["output_tokens"] ?? 0)) || 0;
821
+ const cacheWrite = Math.trunc(Number(u["cache_creation_input_tokens"] ?? 0)) || 0;
779
822
  const usage = {
780
823
  provider: "anthropic",
781
824
  model: opts.model,
@@ -783,7 +826,7 @@ function parseAnthropicResponse(opts) {
783
826
  // production helper folds them in so prompt_tokens is the FULL
784
827
  // input volume; calculateCost then bills the cached subset at the
785
828
  // cached rate (cached <= prompt_tokens, since prompt = input+cached).
786
- prompt_tokens: prompt + cached,
829
+ prompt_tokens: prompt + cached + cacheWrite,
787
830
  completion_tokens: completion,
788
831
  cached_tokens: cached,
789
832
  total_tokens: 0,
@@ -1133,16 +1176,21 @@ function parseOpenAICompatibleResponse(opts) {
1133
1176
  const u = r["usage"] ?? {};
1134
1177
  const details = u["prompt_tokens_details"] ?? {};
1135
1178
  const cached = Math.trunc(Number(details["cached_tokens"] ?? 0)) || 0;
1179
+ const promptTokens = Math.trunc(Number(u["prompt_tokens"] ?? 0)) || 0;
1180
+ const reportedCompletion = Math.trunc(Number(u["completion_tokens"] ?? 0)) || 0;
1181
+ const reportedTotal = Math.trunc(Number(u["total_tokens"] ?? 0)) || 0;
1182
+ const derivedCompletion = reportedTotal > promptTokens ? reportedTotal - promptTokens : reportedCompletion;
1183
+ const completionTokens = Math.max(reportedCompletion, derivedCompletion);
1136
1184
  const usage = {
1137
1185
  provider: opts.provider,
1138
1186
  model: opts.model,
1139
- prompt_tokens: Math.trunc(Number(u["prompt_tokens"] ?? 0)) || 0,
1140
- completion_tokens: Math.trunc(Number(u["completion_tokens"] ?? 0)) || 0,
1187
+ prompt_tokens: promptTokens,
1188
+ completion_tokens: completionTokens,
1141
1189
  cached_tokens: cached,
1142
1190
  // Use the response's reported total_tokens directly. Python's
1143
1191
  // `Usage.to_dict()` falls back to prompt+completion only when
1144
1192
  // total_tokens is 0/missing; mirror that.
1145
- total_tokens: Math.trunc(Number(u["total_tokens"] ?? 0)) || 0,
1193
+ total_tokens: reportedTotal,
1146
1194
  cost_usd: 0,
1147
1195
  estimated: Object.keys(u).length === 0,
1148
1196
  purpose: opts.purpose
@@ -1184,7 +1232,11 @@ async function sendOpenAICompatible(args) {
1184
1232
  body.reasoning_effort = effort;
1185
1233
  }
1186
1234
  }
1187
- if (isReasoningModel(args.provider, args.model) && typeof body.max_completion_tokens === "number") {
1235
+ if (isReasoningModel(args.provider, args.model) && // Only where the cap is a SHARED budget. On a provider that bounds visible
1236
+ // output only (xAI), headroom cannot protect the answer from being crowded
1237
+ // out — nothing is crowding it — so it would merely authorise a
1238
+ // 25,000-token reply and the bill that comes with it.
1239
+ reasoningSharesOutputBudget(args.provider) && typeof body.max_completion_tokens === "number") {
1188
1240
  const raw = Number(process.env["CROSSCHECK_OPENAI_REASONING_HEADROOM_TOKENS"]);
1189
1241
  const headroom = Number.isFinite(raw) && raw >= 0 ? Math.trunc(raw) : 25e3;
1190
1242
  body.max_completion_tokens += headroom;
@@ -1359,7 +1411,7 @@ import { z } from "zod";
1359
1411
 
1360
1412
  // src/server-meta.ts
1361
1413
  var SERVER_NAME = "crosscheck-agent";
1362
- var SERVER_VERSION = true ? "0.2.21" : "0.0.0-dev";
1414
+ var SERVER_VERSION = true ? "0.2.22" : "0.0.0-dev";
1363
1415
 
1364
1416
  // src/tools/audit.ts
1365
1417
  import { readdirSync, readFileSync as readFileSync3, statSync } from "fs";
@@ -11782,7 +11834,7 @@ var CHECK_INTERVAL_SECONDS = 3 * 24 * 60 * 60;
11782
11834
  var DEFAULT_PACKAGE = "crosscheck-cli";
11783
11835
  var FETCH_TIMEOUT_MS = 3e3;
11784
11836
  function engineVersion() {
11785
- return true ? "0.2.21" : "0.0.0-dev";
11837
+ return true ? "0.2.22" : "0.0.0-dev";
11786
11838
  }
11787
11839
  function defaultUpdateCachePath() {
11788
11840
  const base = process.env["CROSSCHECK_DATA_DIR"] || path9.join(os.homedir() || os.tmpdir(), ".crosscheck");