@unson/brainbase-mcp 0.47.5 → 0.47.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.
@@ -193,6 +193,13 @@ async function requestEmbeddings(config, texts, deadline) {
193
193
  throw new EmbeddingProviderError('embedding_request_failed', 'embedding service request failed');
194
194
  }
195
195
  if (!Number.isInteger(response.status) || response.status < 200 || response.status >= 300) {
196
+ // Surface an exhausted embedding balance distinctly so Graph search can tell
197
+ // the owner that semantic retrieval is temporarily down for a billing reason,
198
+ // not a malformed request. The quota signal is either HTTP 402 or an explicit
199
+ // `embedding_provider_quota_exhausted` body code. Never echo the body itself.
200
+ if (response.status === 402 || await errorBodyCode(response, deadline) === 'embedding_provider_quota_exhausted') {
201
+ throw new EmbeddingProviderError('embedding_provider_quota_exhausted', 'the embedding provider prepaid balance is exhausted; semantic Graph search will work again once the balance is restored. Use resolve_entity or get_entity for known identifiers meanwhile');
202
+ }
196
203
  throw new EmbeddingProviderError('embedding_request_failed', `embedding service returned HTTP ${Number.isInteger(response.status) ? response.status : 'an invalid status'}`);
197
204
  }
198
205
  let raw;
@@ -213,6 +220,27 @@ async function requestEmbeddings(config, texts, deadline) {
213
220
  }
214
221
  return validateEmbeddingResponse(parsed, texts.length);
215
222
  }
223
+ /**
224
+ * Best-effort read of a failed response's `code` field. The error body may be
225
+ * absent, oversized, or non-JSON; any failure is swallowed because the HTTP
226
+ * status is still actionable on its own. The body text is never surfaced.
227
+ */
228
+ async function errorBodyCode(response, deadline) {
229
+ let raw;
230
+ try {
231
+ raw = await withDeadline(readResponseText(response), deadline);
232
+ }
233
+ catch {
234
+ return undefined;
235
+ }
236
+ try {
237
+ const parsed = JSON.parse(raw);
238
+ return isRecord(parsed) && typeof parsed.code === 'string' ? parsed.code : undefined;
239
+ }
240
+ catch {
241
+ return undefined;
242
+ }
243
+ }
216
244
  function createDeadline(timeoutMs) {
217
245
  return { controller: new AbortController(), expiresAt: Date.now() + timeoutMs, timeoutMs };
218
246
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unson/brainbase-mcp",
3
- "version": "0.47.5",
3
+ "version": "0.47.6",
4
4
  "description": "Local-first Brainbase judgment OS that lets supported AI agents reuse a user's approved goals, priorities, decisions, and judgment criteria.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -624,5 +624,5 @@
624
624
  "url": "https://github.com/Unson-LLC/brainbase/issues"
625
625
  },
626
626
  "homepage": "https://github.com/Unson-LLC/brainbase#readme",
627
- "gitHead": "58653c598fd801e609c9e9627fbfaf8715081ad5"
627
+ "gitHead": "d3b1b39f16c8626514c07bac12f23ff4d1b814fb"
628
628
  }