crosscheck-mcp 0.1.4 → 0.1.6

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.
@@ -1318,6 +1318,53 @@ function defaultTransient(kind) {
1318
1318
  return kind === "rate_limit" || kind === "server" || kind === "timeout" || kind === "network";
1319
1319
  }
1320
1320
 
1321
+ // src/providers/http-errors.ts
1322
+ init_cjs_shims();
1323
+ 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;
1324
+ function isCreditsFailure(status, bodyText) {
1325
+ if (status === 402) return true;
1326
+ if (status === 401 || status === 403 || status === 429 || status === 400) {
1327
+ return CREDIT_RE.test(bodyText);
1328
+ }
1329
+ return false;
1330
+ }
1331
+ function httpFailureToProviderError(provider, status, bodyText) {
1332
+ const detail = bodyText.slice(0, 512);
1333
+ if (isCreditsFailure(status, bodyText)) {
1334
+ return new ProviderError(
1335
+ "auth",
1336
+ `${provider}: out of credits or billing isn't set up (HTTP ${status}). Your API key is reaching ${provider}, but the account has no usable balance \u2014 add credits / enable billing in your ${provider} console, then retry. Detail: ${detail}`,
1337
+ { status }
1338
+ );
1339
+ }
1340
+ if (status === 401 || status === 403) {
1341
+ return new ProviderError(
1342
+ "auth",
1343
+ `${provider}: API key rejected (HTTP ${status}). Check that the key is correct, active, and from the right ${provider} account. Detail: ${detail}`,
1344
+ { status }
1345
+ );
1346
+ }
1347
+ if (status === 429) {
1348
+ return new ProviderError(
1349
+ "rate_limit",
1350
+ `${provider}: rate limited (HTTP 429). Detail: ${detail}`,
1351
+ { status }
1352
+ );
1353
+ }
1354
+ if (status >= 500 && status <= 599) {
1355
+ return new ProviderError(
1356
+ "server",
1357
+ `${provider}: upstream server error (HTTP ${status}). Detail: ${detail}`,
1358
+ { status }
1359
+ );
1360
+ }
1361
+ return new ProviderError(
1362
+ "client",
1363
+ `${provider}: request failed (HTTP ${status}). Detail: ${detail}`,
1364
+ { status }
1365
+ );
1366
+ }
1367
+
1321
1368
  // src/providers/anthropic.ts
1322
1369
  var ANTHROPIC_API_URL = "https://api.anthropic.com/v1/messages";
1323
1370
  var ANTHROPIC_VERSION_HEADER = "2023-06-01";
@@ -1466,16 +1513,7 @@ async function sendAnthropic(args) {
1466
1513
  return { text, attempts: 1, usage: applyPricing(usage, args.pricing) };
1467
1514
  }
1468
1515
  const bodyText = await respLike.text().catch(() => "");
1469
- if (status === 401 || status === 403) {
1470
- throw new ProviderError("auth", `HTTP ${status}: ${bodyText.slice(0, 512)}`, { status });
1471
- }
1472
- if (status === 429) {
1473
- throw new ProviderError("rate_limit", `HTTP ${status}: ${bodyText.slice(0, 512)}`, { status });
1474
- }
1475
- if (status >= 500 && status <= 599) {
1476
- throw new ProviderError("server", `HTTP ${status}: ${bodyText.slice(0, 512)}`, { status });
1477
- }
1478
- throw new ProviderError("client", `HTTP ${status}: ${bodyText.slice(0, 512)}`, { status });
1516
+ throw httpFailureToProviderError("anthropic", status, bodyText);
1479
1517
  }
1480
1518
 
1481
1519
  // src/providers/gemini.ts
@@ -1649,16 +1687,7 @@ async function sendGemini(args) {
1649
1687
  return { text, attempts: 1, usage: applyPricing2(usage, args.pricing) };
1650
1688
  }
1651
1689
  const bodyText = await respLike.text().catch(() => "");
1652
- if (status === 401 || status === 403) {
1653
- throw new ProviderError("auth", `HTTP ${status}: ${bodyText.slice(0, 512)}`, { status });
1654
- }
1655
- if (status === 429) {
1656
- throw new ProviderError("rate_limit", `HTTP ${status}: ${bodyText.slice(0, 512)}`, { status });
1657
- }
1658
- if (status >= 500 && status <= 599) {
1659
- throw new ProviderError("server", `HTTP ${status}: ${bodyText.slice(0, 512)}`, { status });
1660
- }
1661
- throw new ProviderError("client", `HTTP ${status}: ${bodyText.slice(0, 512)}`, { status });
1690
+ throw httpFailureToProviderError("gemini", status, bodyText);
1662
1691
  }
1663
1692
 
1664
1693
  // src/providers/openai-compatible.ts
@@ -1810,16 +1839,7 @@ async function sendOpenAICompatible(args) {
1810
1839
  return { text, attempts: 1, usage: applyPricing3(usage, args.pricing) };
1811
1840
  }
1812
1841
  const bodyText = await respLike.text().catch(() => "");
1813
- if (status === 401 || status === 403) {
1814
- throw new ProviderError("auth", `HTTP ${status}: ${bodyText.slice(0, 512)}`, { status });
1815
- }
1816
- if (status === 429) {
1817
- throw new ProviderError("rate_limit", `HTTP ${status}: ${bodyText.slice(0, 512)}`, { status });
1818
- }
1819
- if (status >= 500 && status <= 599) {
1820
- throw new ProviderError("server", `HTTP ${status}: ${bodyText.slice(0, 512)}`, { status });
1821
- }
1822
- throw new ProviderError("client", `HTTP ${status}: ${bodyText.slice(0, 512)}`, { status });
1842
+ throw httpFailureToProviderError(args.provider, status, bodyText);
1823
1843
  }
1824
1844
 
1825
1845
  // src/providers/registry.ts
@@ -1914,7 +1934,7 @@ function makeGeminiProvider(model, apiKey, opts) {
1914
1934
  // src/server.ts
1915
1935
  init_cjs_shims();
1916
1936
  var import_server2 = require("@modelcontextprotocol/sdk/server/index.js");
1917
- var import_types5 = require("@modelcontextprotocol/sdk/types.js");
1937
+ var import_types6 = require("@modelcontextprotocol/sdk/types.js");
1918
1938
 
1919
1939
  // src/instructions.ts
1920
1940
  init_cjs_shims();
@@ -10708,7 +10728,7 @@ function pingTool() {
10708
10728
 
10709
10729
  // src/server.ts
10710
10730
  var SERVER_NAME = "crosscheck-agent";
10711
- var SERVER_VERSION = true ? "0.1.4" : "0.0.0-dev";
10731
+ var SERVER_VERSION = true ? "0.1.6" : "0.0.0-dev";
10712
10732
  function createServer(opts = {}) {
10713
10733
  const server = new import_server2.Server(
10714
10734
  { name: SERVER_NAME, version: SERVER_VERSION },
@@ -10721,14 +10741,14 @@ function createServer(opts = {}) {
10721
10741
  }
10722
10742
  );
10723
10743
  const tools = buildToolRegistry(opts);
10724
- server.setRequestHandler(import_types5.ListToolsRequestSchema, async () => ({
10744
+ server.setRequestHandler(import_types6.ListToolsRequestSchema, async () => ({
10725
10745
  tools: Array.from(tools.values()).map((t) => ({
10726
10746
  name: t.name,
10727
10747
  description: t.description,
10728
10748
  inputSchema: t.inputSchema
10729
10749
  }))
10730
10750
  }));
10731
- server.setRequestHandler(import_types5.CallToolRequestSchema, async (req) => {
10751
+ server.setRequestHandler(import_types6.CallToolRequestSchema, async (req) => {
10732
10752
  const name = req.params.name;
10733
10753
  const tool = tools.get(name);
10734
10754
  if (!tool) {