@productbrain/mcp 0.0.1-beta.9452 → 0.0.1-beta.9469

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.
@@ -43,7 +43,7 @@ import {
43
43
  trackQualityVerdict,
44
44
  trackSessionCaptureRate,
45
45
  trackZeroCaptureAuditFired
46
- } from "./chunk-Q77SFDBZ.js";
46
+ } from "./chunk-FVH3B7MF.js";
47
47
 
48
48
  // src/server.ts
49
49
  import { McpServer as McpServer2 } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -13544,4 +13544,4 @@ export {
13544
13544
  createProductBrainServer,
13545
13545
  initFeatureFlags
13546
13546
  };
13547
- //# sourceMappingURL=chunk-NCTCZQHK.js.map
13547
+ //# sourceMappingURL=chunk-BCQ7KBLE.js.map
@@ -1086,22 +1086,34 @@ function parseFallbackUrls(raw) {
1086
1086
  if (!raw) return [];
1087
1087
  return raw.split(",").map((u) => u.trim()).filter(Boolean);
1088
1088
  }
1089
- async function probeDeploymentCandidates(candidates, apiKey) {
1090
- for (const candidate of candidates) {
1089
+ async function checkKeyAgainstCandidates(candidates, apiKey, timeoutMs) {
1090
+ let rejections = 0;
1091
+ for (const url of candidates) {
1092
+ let data;
1091
1093
  try {
1092
- const probeRes = await fetch(`${candidate}/api/key-check`, {
1094
+ const res = await fetch(`${url}/api/key-check`, {
1093
1095
  method: "POST",
1094
1096
  headers: { "Authorization": `Bearer ${apiKey}`, "Content-Type": "application/json" },
1095
- signal: AbortSignal.timeout(3e3)
1097
+ signal: AbortSignal.timeout(timeoutMs)
1096
1098
  });
1097
- if (probeRes.ok) {
1098
- const data = await probeRes.json();
1099
- if (data.ok) return candidate;
1100
- }
1099
+ if (!res.ok) continue;
1100
+ data = await res.json();
1101
1101
  } catch {
1102
+ continue;
1103
+ }
1104
+ if (data?.ok === true) {
1105
+ return { verdict: "ok", url, deploymentUrl: data.deploymentUrl ?? url, workspaceName: data.workspaceName };
1102
1106
  }
1107
+ if (data?.ok === false && data.error === "rate_limited") {
1108
+ return { verdict: "rate_limited", url, deploymentUrl: url, retryAfterSeconds: data.retryAfterSeconds };
1109
+ }
1110
+ if (data?.ok === false && data.error === "invalid_key") rejections++;
1103
1111
  }
1104
- return null;
1112
+ return candidates.length > 0 && rejections === candidates.length ? { verdict: "rejected" } : { verdict: "unreachable" };
1113
+ }
1114
+ async function probeDeploymentCandidates(candidates, apiKey) {
1115
+ const result = await checkKeyAgainstCandidates(candidates, apiKey, 3e3);
1116
+ return result.verdict === "ok" || result.verdict === "rate_limited" ? result.url : null;
1105
1117
  }
1106
1118
 
1107
1119
  // src/client.ts
@@ -1651,6 +1663,8 @@ export {
1651
1663
  classifyError,
1652
1664
  retryIsFutile,
1653
1665
  warnOnProdFallthrough,
1666
+ parseFallbackUrls,
1667
+ checkKeyAgainstCandidates,
1654
1668
  getConversationId,
1655
1669
  runWithToolContext,
1656
1670
  DEFAULT_CLOUD_URL,
@@ -1681,4 +1695,4 @@ export {
1681
1695
  appUrl,
1682
1696
  apiKeysUrl
1683
1697
  };
1684
- //# sourceMappingURL=chunk-Q77SFDBZ.js.map
1698
+ //# sourceMappingURL=chunk-FVH3B7MF.js.map