hugging-bay-mcp 0.1.11 → 0.1.12

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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ Changes for `hugging-bay-mcp`.
4
+
5
+ ## 0.1.12 — source candidate
6
+
7
+ Not published.
8
+
9
+ - Timed-out tool failures report unavailable status.
10
+ - Degraded deployment plans and incomplete runnable results retain unavailable or pending status instead of appearing empty.
package/README.md CHANGED
@@ -3,9 +3,9 @@
3
3
  [![npm version](https://img.shields.io/npm/v/hugging-bay-mcp.svg)](https://www.npmjs.com/package/hugging-bay-mcp) [![MCP discovery tools](https://img.shields.io/badge/discovery%20tools-28-blue)](https://huggingbay.xyz/api/mcp)
4
4
 
5
5
  **Promise:** Find open model files with recorded SHA-256 and licence labels. Public reads need no account.<br>
6
- **Install:** `npx -y hugging-bay-mcp@0.1.10`<br>
6
+ **Install:** `npx -y hugging-bay-mcp@0.1.11`<br>
7
7
  **MCP config (remote):** `claude mcp add --transport http hugging-bay https://huggingbay.xyz/api/mcp`<br>
8
- **MCP config (stdio):** `{"mcpServers":{"hugging-bay":{"command":"npx","args":["-y","hugging-bay-mcp@0.1.10"],"env":{"HUGGING_BAY_API":"https://huggingbay.xyz"}}}}`<br>
8
+ **MCP config (stdio):** `{"mcpServers":{"hugging-bay":{"command":"npx","args":["-y","hugging-bay-mcp@0.1.11"],"env":{"HUGGING_BAY_API":"https://huggingbay.xyz"}}}}`<br>
9
9
  **First call:** `search_artifacts({ "q": "Qwen3 0.6B GGUF" })`<br>
10
10
  **Ask:** Missing a model, file, tool or feature? Ask with request_feature (hosted MCP) or POST https://huggingbay.xyz/api/v1/requests. No account. You get an id and can check its status. What shipped: https://huggingbay.xyz/changelog<br>
11
11
  [Changelog](https://huggingbay.xyz/changelog?ref=npm) · [MCP docs](https://huggingbay.xyz/agents?ref=npm)<br>
@@ -20,7 +20,7 @@ per server name. For Claude Code:
20
20
  claude mcp add --transport http hugging-bay https://huggingbay.xyz/api/mcp
21
21
  claude mcp list
22
22
  # Or use stdio under a separate name:
23
- claude mcp add hugging-bay-stdio -- npx -y hugging-bay-mcp@0.1.10
23
+ claude mcp add hugging-bay-stdio -- npx -y hugging-bay-mcp@0.1.11
24
24
  ```
25
25
 
26
26
  For Codex CLI:
@@ -38,7 +38,7 @@ url = "https://huggingbay.xyz/api/mcp"
38
38
  ```
39
39
 
40
40
  For stdio, replace `url` with `command = "npx"` and
41
- `args = ["-y", "hugging-bay-mcp@0.1.10"]`. Codex's MCP list reports configuration;
41
+ `args = ["-y", "hugging-bay-mcp@0.1.11"]`. Codex's MCP list reports configuration;
42
42
  it does not prove a tool call succeeded. `auth_status: "unsupported"` describes
43
43
  OAuth support, not a requirement to sign in for public reads.
44
44
 
@@ -55,7 +55,8 @@ or connection does not establish model availability, fit or a successful run.
55
55
 
56
56
  ## Profiles: stdio and hosted
57
57
 
58
- **Source candidate:** `0.1.11` adds typed MCP tool results, closed argument validation, and the shared 15-second wait budget across pacing and retries. It is not published; the install pins above stay on 0.1.10. Its default stdio discovery profile retains the 28-tool contract.
58
+ **Source candidate:** `0.1.12` reports timeouts and degraded deployment or runnable results as unavailable or pending instead of empty.<br>
59
+ **MCP 0.1.11:** typed MCP tool results, closed argument validation, and a shared 15-second wait budget across pacing and retries. The SHA-pinned npm archive was measured on 2026-10-24; its default stdio discovery profile retains the 28-tool contract.
59
60
 
60
61
  The stdio launcher and hosted endpoint share the discovery profile. The package keeps
61
62
  the broader catalog available, but a client must opt into it explicitly:
@@ -63,7 +64,7 @@ the broader catalog available, but a client must opt into it explicitly:
63
64
  | Transport/profile | `tools/list` | What it is |
64
65
  | --- | --- | --- |
65
66
  | stdio default (`node packages/mcp/index.mjs`) | **28 tools** | same discovery profile as hosted `/api/mcp`; `tools/list` is the authority |
66
- | stdio `--profile full` | **107 tools** in the 0.1.11 source candidate | the complete current stdio catalog; use `tools/list` as the authority rather than hard-coding the count |
67
+ | stdio `--profile full` | **107 tools** in 0.1.11 | the complete current stdio catalog; use `tools/list` as the authority rather than hard-coding the count |
67
68
  | stdio `--profile verify` | **28 tools**; **29** with the run-proof flag | discovery plus `get_accepted_run_proof` when `HUGGING_BAY_MCP_ENABLE_UNRELEASED_RUN_PROOF=1` |
68
69
  | hosted `https://huggingbay.xyz/api/mcp` | **28 tools** | the deployed discovery profile; other hosted profiles use `?profile=` (see `https://huggingbay.xyz/.well-known/mcp.json`) |
69
70
 
@@ -77,8 +78,7 @@ with JSON-RPC `-32602` (`Unknown tool`).
77
78
 
78
79
  ## Stdio arguments and protocol errors
79
80
 
80
- The published npm **0.1.10 archive predates these argument and CLI fixes**.
81
- The 0.1.11 source candidate includes the contract below.
81
+ The measured npm 0.1.11 archive includes the argument and CLI contract below.
82
82
 
83
83
  `hugging-bay-mcp --help` (or `-h`) prints usage and exits successfully;
84
84
  `--version` (or `-v`) prints the artifact version and exits successfully.
@@ -147,7 +147,19 @@ export function mcpAnswerText(payload) {
147
147
  return withMarker(kept);
148
148
  }
149
149
 
150
+ // A detail link must ask the same question as the bounded response. Do not
151
+ // carry arbitrary tool arguments (credentials, host settings) into public URLs.
152
+ export function findRunnableSourceUrl(args, base) {
153
+ const url = new URL('/api/agents/find-runnable', base);
154
+ for (const key of ['task', 'model', 'requestedModel', 'model_name', 'modelName', 'commercial', 'gpu', 'hardware', 'ramGb', 'ram', 'ctx', 'os', 'deviceFamily', 'customMemoryGb', 'provenOnly']) {
155
+ const value = args[key];
156
+ if (['string', 'number', 'boolean'].includes(typeof value) && String(value) !== '') url.searchParams.set(key, String(value));
157
+ }
158
+ return url.href;
159
+ }
160
+
150
161
  export function mcpAnswerSource(name, args, payload, base) {
162
+ if (name === 'find_runnable' && process.env.HUGGING_BAY_AGENT_FLOW_V2 === '1') return findRunnableSourceUrl(args, base);
151
163
  const id = args.id || args.artifact || payload?.artifactId || payload?.id;
152
164
  if (id && ['get_artifact', 'get_artifact_card', 'get_harness_card', 'list_files', 'deployment_plan'].includes(name)) {
153
165
  const suffix = name === 'list_files' ? '/files' : name === 'get_artifact_card' ? '/card' : name === 'get_harness_card' ? '/harness-card' : '';
@@ -496,13 +496,11 @@ export const HOSTED_DISCOVERY_EXTRA_TOOLS = [
496
496
  "enum": [
497
497
  "received",
498
498
  "planned",
499
- "in_progress",
500
- "shipped",
499
+ "built",
501
500
  "declined",
502
- "duplicate",
503
501
  "withdrawn"
504
502
  ],
505
- "description": "Filter by the request lifecycle status."
503
+ "description": "Filter by the public lifecycle status: received, planned, built, declined or withdrawn."
506
504
  },
507
505
  "kind": {
508
506
  "type": "string",
package/index.mjs CHANGED
@@ -22,7 +22,7 @@ import { createMcpStdioReader } from "./mcp-stdio-framing.mjs";
22
22
  import { mcpStdioLimitsFromEnv, mcpRequestDeadlineMs } from "./mcp-stdio-limits.mjs";
23
23
  import { mcpSanitizeClientErrorMessage, mcpSanitizeClientErrorData } from "./mcp-stdio-client-errors.mjs";
24
24
  import { withStdioToolMetadata } from "./tool-descriptions.mjs";
25
- import { REQUEST_MISSING_TOOL, validateRequestMissing, requestMissingTool } from "./request-missing.mjs";
25
+ import { REQUEST_MISSING_TOOL, validateRequestMissing, requestMissingTool, requestMissingValidationMessage } from "./request-missing.mjs";
26
26
  import { tagMcpDownloadUrls } from "./mcp-download-via.mjs";
27
27
  import { HOSTED_DISCOVERY_EXTRA_TOOLS } from "./hosted-discovery-contracts.mjs";
28
28
  import { RUN_LOCAL_TOOL, createLocalRunner } from "./run-local.mjs";
@@ -1889,7 +1889,7 @@ async function apiRequest(path, options = {}) {
1889
1889
  body = text;
1890
1890
  }
1891
1891
  if (!response.ok && !acceptedStatuses.has(response.status)) {
1892
- const message = typeof body === "object" && body?.error ? body.error : `${response.status} ${response.statusText}`;
1892
+ const message = typeof body === "object" && (body?.message || body?.error) ? body.message || body.error : `${response.status} ${response.statusText}`;
1893
1893
  const error = new Error(message);
1894
1894
  error.status = response.status;
1895
1895
  const delay = backoffDelayMs(response.headers, body);
@@ -1977,7 +1977,7 @@ async function callTool(name, input, signal) {
1977
1977
  // verify/discovery launcher can never invoke a tool outside its profile.
1978
1978
  if (isBoundedProfile && !listedToolNames.has(name)) throw runProofError("mcp_tool_not_in_profile");
1979
1979
  if (swarmHelpersEnabled && SWARM_TOOLS.some(tool => tool.name === name)) {
1980
- swarmClient ||= createSwarmClient({ baseUrl: apiBase, token });
1980
+ swarmClient ||= createSwarmClient({ baseUrl: apiBase, token, backoffV1: process.env.HUGGING_BAY_SWARM_BACKOFF_V1 === "1" });
1981
1981
  return callSwarmTool(swarmClient, name, input, signal ? { signal } : {});
1982
1982
  }
1983
1983
  if (name === "run_local") return localRunner.run(input, signal);
@@ -1986,7 +1986,8 @@ async function callTool(name, input, signal) {
1986
1986
  const checked = validateRequestMissing(input);
1987
1987
  if (!checked.ok) {
1988
1988
  const { ok, ...payload } = checked;
1989
- throw Object.assign(new Error(checked.error), { rpcCode: -32602, payload });
1989
+ const message = requestMissingValidationMessage(checked);
1990
+ throw Object.assign(new Error(message), { rpcCode: -32602, payload: { ...payload, message } });
1990
1991
  }
1991
1992
  return apiRequest("/api/v1/request-missing", { method: "POST", body: JSON.stringify(checked.value) });
1992
1993
  }
@@ -215,7 +215,8 @@ function errorState(structured, text) {
215
215
  if (kind === "not_found" || /not_found/.test(code) || status === 404) return "not_found";
216
216
  if (kind === "rate_limited" || status === 429 || /rate_limit/.test(code)) return "rate_limited";
217
217
  if (kind === "forbidden" || status === 401 || status === 403 || /forbidden|not_authorized|auth_required|refused/.test(code)) return "refused";
218
- if (kind === "upstream_unavailable" || status >= 500 || /timeout|unavailable/.test(code)) return "unavailable";
218
+ if (kind === "upstream_unavailable" || status >= 500 || /timeout|unavailable/.test(code)
219
+ || (code === "tool_failed" && /timeout|timed out/i.test(String(structured?.message || text)))) return "unavailable";
219
220
  if (/invalid|arguments/i.test(code) || /^(Invalid tool arguments|Check the tool arguments|Check the model id)/.test(text)) return "invalid_arguments";
220
221
  if (structured?.reason === "local-package-required") return "refused";
221
222
  return "error";
@@ -223,15 +224,21 @@ function errorState(structured, text) {
223
224
 
224
225
  function successState(name, structured) {
225
226
  if (structured?.confirm_token || structured?.needsConfirmation === true || structured?.status === "needs_confirmation") return "needs_confirmation";
227
+ if (name === "deployment_plan" && structured?.available === false
228
+ && (structured?.degraded === true || structured?.artifact?.readiness === "unknown" || structured?.artifact?.degraded === true)) return "unavailable";
226
229
  const list = firstList(structured);
227
230
  if (Array.isArray(list) && list.length) {
228
231
  const pending = list.filter((row) => row?.state === "pending").length;
229
232
  if (pending === list.length) return "pending";
230
233
  if (pending > 0) return "partial";
231
234
  }
232
- if (structured?.state === "pending") return "pending";
235
+ if (structured?.state === "pending" || (name === "find_runnable"
236
+ && (structured?.pending === true || structured?.status === "pending"))) return "pending";
233
237
  if (name === "find_runnable") {
234
- if (!structured?.recommendation && !(structured?.alternatives?.length)) return "empty";
238
+ if (!structured?.recommendation && !(structured?.alternatives?.length)) {
239
+ return structured?.degraded === true || structured?.finderDegraded === true || structured?.stale === true
240
+ ? "unavailable" : "empty";
241
+ }
235
242
  } else if (Array.isArray(list) && list.length === 0) return "empty";
236
243
  if (structured?.degraded === true || structured?.stale === true || structured?.partial === true || structured?.finderDegraded === true) return "partial";
237
244
  return "ok";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hugging-bay-mcp",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "Open model files with recorded SHA-256 and licence labels. Ask for what's missing.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -74,6 +74,7 @@
74
74
  "hosted-discovery-contracts.mjs",
75
75
  "server.json",
76
76
  "README.md",
77
+ "CHANGELOG.md",
77
78
  "LICENSE",
78
79
  "starter-tasks.mjs"
79
80
  ]
@@ -75,22 +75,19 @@ export function createPublicReadFetch(options = {}) {
75
75
  const read = ["GET", "HEAD"].includes(method) || (method === "POST" && readOnlyPost);
76
76
  const signal = init?.signal ?? input?.signal;
77
77
  const origin = new URL(input?.url ?? String(input), "http://relative.invalid").origin;
78
- let remaining = Math.max(0, Math.min(Number(options.maxWaitMs ?? 15_000) || 0, 60_000));
79
- const deadline = now() + remaining;
78
+ let remaining = options.maxWaitMs ?? 15_000;
80
79
  while (read && (nextByOrigin.get(origin) || 0) > now()) {
81
80
  const at = nextByOrigin.get(origin);
82
81
  const delay = at - now();
83
82
  // A concurrent success may extend the same origin's cooldown.
84
- if (delay > Math.min(remaining, deadline - now())) {
83
+ if (delay > remaining) {
85
84
  throw Object.assign(new Error("public_read_backoff_pending"), { retryAfterSeconds: delay / 1000 });
86
85
  }
87
86
  await sleep(delay, signal);
88
87
  remaining -= delay;
89
88
  if (nextByOrigin.get(origin) === at) nextByOrigin.delete(origin);
90
89
  }
91
- const response = await fetchPublicReadWithRetry(input, init, {
92
- ...options, readOnlyPost, maxWaitMs: Math.max(0, Math.min(remaining, deadline - now())),
93
- });
90
+ const response = await fetchPublicReadWithRetry(input, init, { ...options, readOnlyPost });
94
91
  if (read && response.ok && response.headers.get("X-HB-Backoff") === "v1") {
95
92
  const hint = retryAfterMs(response.headers.get("Retry-After"), now());
96
93
  if (hint !== null && hint > 0) {
@@ -8,17 +8,17 @@ export const HOSTED_MCP_MANIFEST_METADATA_KEY = "xyz.huggingbay/hosted-mcp-manif
8
8
  export const HOSTED_DISCOVERY_TOOL_NAMES = MCP_PROFILE_MANIFEST.profiles.discovery.toolNames;
9
9
  export const HOSTED_DISCOVERY_TOOL_COUNT = HOSTED_DISCOVERY_TOOL_NAMES.length;
10
10
 
11
- // Immutable npm 0.1.10 measurements. Update only after a founder re-measures a new publish.
11
+ // SHA-pinned npm 0.1.11 measurements, observed 2026-10-24.
12
12
  export const REGISTRY_PUBLISHED_OBSERVATION = Object.freeze({
13
13
  "packageName": "hugging-bay-mcp",
14
- "packageVersion": "0.1.10",
15
- "date": "2026-10-20",
16
- "registryUrl": "https://registry.npmjs.org/hugging-bay-mcp/0.1.10",
17
- "tarballUrl": "https://registry.npmjs.org/hugging-bay-mcp/-/hugging-bay-mcp-0.1.10.tgz",
18
- "integrity": "sha512-UymF/k5cw8st2gJKmUUyj0JiFE0HFMsfyWy5uyhmBYqLEsA/TaeLK7nu27QigQ8U/yzTRpTrZ4tHQhjH6gMmyQ==",
19
- "sha256": "2b3e6f835fcdcf47e9986703111112567cc5a54128f8a95cd9b410dc7a77f53b",
20
- "shasum": "d7913214bece7f87990697668d972f35166e4411",
21
- "sizeBytes": 165440,
14
+ "packageVersion": "0.1.11",
15
+ "date": "2026-10-24",
16
+ "registryUrl": "https://registry.npmjs.org/hugging-bay-mcp/0.1.11",
17
+ "tarballUrl": "https://registry.npmjs.org/hugging-bay-mcp/-/hugging-bay-mcp-0.1.11.tgz",
18
+ "integrity": "sha512-QACxDfOV4tvNKUPnjvq1yX20LY8nJIe8NrQbkXHCXXe3WJJU67uAFRpOetVDeyKVqIkCJGE3oJ580WhAoPOA0g==",
19
+ "sha256": "1f6b5ea1f8ab56613737b4a271006afd63a5dac86363cc3f576e957e9375ac14",
20
+ "shasum": "3420a3d373f3826873a299bc2be854636f0b5ea7",
21
+ "sizeBytes": 194770,
22
22
  "defaultToolCount": 28,
23
23
  "hostedDiscoveryToolCount": 28,
24
24
  "status": "Observed published on npm; official MCP Registry is a separately dated channel.",
@@ -83,7 +83,7 @@ export function registryNpmEnvironmentVariables({ packageVersion = MCP_RELEASE_V
83
83
  {
84
84
  name: "HUGGING_BAY_MCP_PROFILE",
85
85
  description:
86
- "npm 0.1.10 defaults to 28 discovery tools. Full and verify are opt-in profiles; inspect tools/list for their schemas and counts. Accepted-run-proof access requires verify and HUGGING_BAY_MCP_ENABLE_UNRELEASED_RUN_PROOF=1. Hosted discovery exposes the same default tool names.",
86
+ `npm ${packageVersion} defaults to 28 discovery tools. Full and verify are opt-in profiles; inspect tools/list for their schemas and counts. Accepted-run-proof access requires verify and HUGGING_BAY_MCP_ENABLE_UNRELEASED_RUN_PROOF=1. Hosted discovery exposes the same default tool names.`,
87
87
  isRequired: false,
88
88
  default: MCP_PROFILE_MANIFEST.defaultProfile,
89
89
  choices: Object.keys(MCP_PROFILE_MANIFEST.profiles),
@@ -32,6 +32,22 @@ export function requestMissingTool(env = process.env) {
32
32
  return env?.HUGGING_BAY_MODEL_REQUESTS_V2 === "1" ? REQUEST_MISSING_V2_TOOL : REQUEST_MISSING_TOOL;
33
33
  }
34
34
 
35
+ export function requestMissingValidationMessage(result) {
36
+ if (result?.error === "request_missing_too_long") {
37
+ const field = result.details?.field === "task" ? "task" : "wanted";
38
+ const maxLength = field === "task" ? 1000 : 500;
39
+ return `Shorten ${field} to ${maxLength} characters or fewer.`;
40
+ }
41
+ if (result?.error === "request_missing_arguments_invalid") {
42
+ if (result.details?.field === "wanted") return "Fill in wanted with the missing model or item.";
43
+ if (result.details?.field === "task") return "Fill in task with what you needed the item for.";
44
+ if (result.details?.field === "confirm_token") return "Use the confirmation token returned by the preview.";
45
+ if (result.details?.unexpected) return "Remove fields that this request tool does not accept.";
46
+ return "Provide wanted and task as non-empty text fields.";
47
+ }
48
+ return "Check wanted, task, and the confirmation token, then try again.";
49
+ }
50
+
35
51
  /** Strict validation: bounded wanted/task and an optional confirmation token. */
36
52
  export function validateRequestMissing(input) {
37
53
  if (!input || typeof input !== "object" || Array.isArray(input)) return { ok: false, error: "request_missing_arguments_invalid" };
package/serve-verdict.mjs CHANGED
@@ -38,7 +38,11 @@ export function fileSignatureState(file = {}, { now = Date.now(), verified = fal
38
38
  export function computeServeVerdict(row = {}, { now = Date.now(), signature = fileSignatureState(row, { now }), artifactId } = {}) {
39
39
  const evidence = row.serveExplanation || {};
40
40
  const previous = row.serve_verdict;
41
- const checked_at = stamp(row.readinessCheckedAt || evidence.readinessCheckedAt || row.serveEvaluatedAt || evidence.serveEvaluatedAt || previous?.checked_at);
41
+ // Wire projection strips readinessCheckedAt. A later cache/wire pass must
42
+ // retain the stamp already computed from that observation, rather than fall
43
+ // back to an older correlation record in serveExplanation. Fresh producers
44
+ // supply readinessCheckedAt explicitly and therefore still take precedence.
45
+ const checked_at = stamp(row.readinessCheckedAt || evidence.readinessCheckedAt || previous?.checked_at || row.serveEvaluatedAt || evidence.serveEvaluatedAt);
42
46
  const age = checked_at ? now - Date.parse(checked_at) : Infinity;
43
47
  const retainedStale = previous?.freshness === 'stale' && row.readiness == null && checked_at === previous.checked_at;
44
48
  const current = checked_at !== null && age >= 0 && age < SERVE_VERDICT_MAX_AGE_MS
package/server.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "id": "1284199117",
10
10
  "subfolder": "packages/mcp"
11
11
  },
12
- "version": "0.1.11",
12
+ "version": "0.1.12",
13
13
  "websiteUrl": "https://huggingbay.xyz",
14
14
  "remotes": [
15
15
  {
@@ -22,7 +22,7 @@
22
22
  "registryType": "npm",
23
23
  "registryBaseUrl": "https://registry.npmjs.org",
24
24
  "identifier": "hugging-bay-mcp",
25
- "version": "0.1.11",
25
+ "version": "0.1.12",
26
26
  "transport": {
27
27
  "type": "stdio"
28
28
  },
@@ -41,7 +41,7 @@
41
41
  },
42
42
  {
43
43
  "name": "HUGGING_BAY_MCP_PROFILE",
44
- "description": "npm 0.1.10 defaults to 28 discovery tools. Full and verify are opt-in profiles; inspect tools/list for their schemas and counts. Accepted-run-proof access requires verify and HUGGING_BAY_MCP_ENABLE_UNRELEASED_RUN_PROOF=1. Hosted discovery exposes the same default tool names.",
44
+ "description": "npm 0.1.12 defaults to 28 discovery tools. Full and verify are opt-in profiles; inspect tools/list for their schemas and counts. Accepted-run-proof access requires verify and HUGGING_BAY_MCP_ENABLE_UNRELEASED_RUN_PROOF=1. Hosted discovery exposes the same default tool names.",
45
45
  "isRequired": false,
46
46
  "default": "discovery",
47
47
  "choices": [
@@ -77,14 +77,14 @@
77
77
  },
78
78
  "publishedObservation": {
79
79
  "packageName": "hugging-bay-mcp",
80
- "packageVersion": "0.1.10",
81
- "date": "2026-10-20",
82
- "registryUrl": "https://registry.npmjs.org/hugging-bay-mcp/0.1.10",
83
- "tarballUrl": "https://registry.npmjs.org/hugging-bay-mcp/-/hugging-bay-mcp-0.1.10.tgz",
84
- "integrity": "sha512-UymF/k5cw8st2gJKmUUyj0JiFE0HFMsfyWy5uyhmBYqLEsA/TaeLK7nu27QigQ8U/yzTRpTrZ4tHQhjH6gMmyQ==",
85
- "sha256": "2b3e6f835fcdcf47e9986703111112567cc5a54128f8a95cd9b410dc7a77f53b",
86
- "shasum": "d7913214bece7f87990697668d972f35166e4411",
87
- "sizeBytes": 165440,
80
+ "packageVersion": "0.1.11",
81
+ "date": "2026-10-24",
82
+ "registryUrl": "https://registry.npmjs.org/hugging-bay-mcp/0.1.11",
83
+ "tarballUrl": "https://registry.npmjs.org/hugging-bay-mcp/-/hugging-bay-mcp-0.1.11.tgz",
84
+ "integrity": "sha512-QACxDfOV4tvNKUPnjvq1yX20LY8nJIe8NrQbkXHCXXe3WJJU67uAFRpOetVDeyKVqIkCJGE3oJ580WhAoPOA0g==",
85
+ "sha256": "1f6b5ea1f8ab56613737b4a271006afd63a5dac86363cc3f576e957e9375ac14",
86
+ "shasum": "3420a3d373f3826873a299bc2be854636f0b5ea7",
87
+ "sizeBytes": 194770,
88
88
  "defaultToolCount": 28,
89
89
  "hostedDiscoveryToolCount": 28,
90
90
  "status": "Observed published on npm; official MCP Registry is a separately dated channel.",
@@ -150,7 +150,7 @@
150
150
  "sourceVersion": "0.1.11",
151
151
  "discoveryToolCount": 28,
152
152
  "discoveryToolNamesSha256": "63bd37153d6932885876c2b79e96a41a0803421a8f7e772a7d766eeea29de1d1",
153
- "generatedAt": "2026-10-24T15:11:53.923Z"
153
+ "generatedAt": "2026-10-25T20:22:37.625Z"
154
154
  }
155
155
  }
156
156
  }
package/swarm-client.mjs CHANGED
@@ -1,9 +1,13 @@
1
+ import { backoffDelayMs } from "./public-read-retry.mjs";
2
+
1
3
  // One instance per swarm/key. No token, request body or response is logged.
2
4
  export function createSwarmClient({ baseUrl, token = "", concurrency = 16, retries = 3,
5
+ backoffV1 = false, maxWaitMs = 15_000,
3
6
  maxEntries = 256, maxBytes = 16 * 1024 * 1024, fetchImpl = globalThis.fetch,
4
7
  sleep = ms => new Promise(resolve => setTimeout(resolve, ms)), random = Math.random } = {}) {
5
8
  if (!Number.isInteger(concurrency) || concurrency < 1 || concurrency > 64 || !Number.isInteger(retries) || retries < 0 || retries > 5) throw new Error("invalid_swarm_limits");
6
9
  if (!Number.isInteger(maxEntries) || maxEntries < 1 || maxEntries > 4096 || !Number.isFinite(maxBytes) || maxBytes < 1 || maxBytes > 64 * 1024 * 1024) throw new Error("invalid_swarm_cache_limits");
10
+ if (!Number.isFinite(maxWaitMs) || maxWaitMs < 0 || maxWaitMs > 60_000) throw new Error("invalid_swarm_wait_budget");
7
11
  const origin = new URL(baseUrl);
8
12
  if (!/^https?:$/.test(origin.protocol)) throw new Error("invalid_swarm_origin");
9
13
  const cache = new Map(), pending = new Map(), waiting = [];
@@ -24,7 +28,9 @@ export function createSwarmClient({ baseUrl, token = "", concurrency = 16, retri
24
28
  const request = async (path, { method = "GET", body, snapshot, signal } = {}) => {
25
29
  const url = new URL(path, origin);
26
30
  if (url.origin !== origin.origin) throw new Error("swarm_origin_mismatch");
27
- const read = method === "GET" || (method === "POST" && ["/api/v1/resolve/batch", "/api/v1/download-plans", "/api/agents/find-runnable/batch"].includes(url.pathname));
31
+ const safeGet = !backoffV1 || ["/api/v1/search", "/api/v1/resolve", "/api/agents/find-runnable", "/api/agents/find-model"].includes(url.pathname)
32
+ || /\/(?:files|download-plan)$/.test(url.pathname);
33
+ const read = (method === "GET" && safeGet) || (method === "POST" && ["/api/v1/resolve/batch", "/api/v1/download-plans", "/api/agents/find-runnable/batch"].includes(url.pathname));
28
34
  if (snapshot) {
29
35
  if (method === "GET") url.searchParams.set("snapshot", snapshot);
30
36
  else body = { ...body, snapshot };
@@ -39,14 +45,24 @@ export function createSwarmClient({ baseUrl, token = "", concurrency = 16, retri
39
45
  if (cacheable && pending.has(key)) return structuredClone(await waitFor(pending.get(key), signal));
40
46
  const networkSignal = cacheable ? AbortSignal.timeout(20_000) : signal;
41
47
  const send = async () => {
48
+ const deadline = Date.now() + maxWaitMs;
49
+ let waited = 0;
50
+ let lastError;
42
51
  for (let attempt = 0; ; attempt++) {
43
52
  networkSignal?.throwIfAborted();
44
- while (cooldown > Date.now()) {
45
- await sleep(Math.min(1000, Math.max(1, cooldown - Date.now())));
53
+ while ((read || !backoffV1) && cooldown > Date.now()) {
54
+ const remaining = cooldown - Date.now();
55
+ if (backoffV1 && read && remaining > Math.min(maxWaitMs - waited, deadline - Date.now())) {
56
+ throw lastError || Object.assign(new Error("public_read_backoff_pending"), { status: 429, retryAfterSeconds: remaining / 1000,
57
+ payload: { error: "public_read_backoff_pending", retry_after_s: remaining / 1000, retryAfterSeconds: remaining / 1000 } });
58
+ }
59
+ const pause = Math.min(1000, Math.max(1, remaining));
60
+ await sleep(pause);
61
+ waited += pause;
46
62
  networkSignal?.throwIfAborted();
47
63
  }
48
64
  await enter();
49
- if (cooldown > Date.now()) { leave(); attempt--; continue; }
65
+ if ((read || !backoffV1) && cooldown > Date.now()) { leave(); attempt--; continue; }
50
66
  let response, document;
51
67
  try {
52
68
  networkSignal?.throwIfAborted();
@@ -55,6 +71,21 @@ export function createSwarmClient({ baseUrl, token = "", concurrency = 16, retri
55
71
  ...(body ? { body: JSON.stringify(body) } : {}), signal: networkSignal || AbortSignal.timeout(20_000), redirect: "error" });
56
72
  try { document = await response.json(); } catch { document = null; }
57
73
  } finally { leave(); }
74
+ if (backoffV1 && read && [429, 503].includes(response.status)) {
75
+ const minimum = backoffDelayMs(response.headers, document);
76
+ const payload = document && typeof document === "object" && !Array.isArray(document) ? { ...document } : {};
77
+ if (minimum !== null) Object.assign(payload, { retry_after_s: minimum / 1000, retryAfterSeconds: minimum / 1000 });
78
+ const requestId = response.headers.get("X-Request-Id");
79
+ if (requestId && !payload.requestId) payload.requestId = requestId;
80
+ lastError = Object.assign(new Error(document?.error || "swarm_request_failed"), {
81
+ status: response.status, payload, retryAfterSeconds: minimum === null ? null : minimum / 1000,
82
+ });
83
+ if (minimum === null) throw lastError;
84
+ const delay = minimum + (minimum > 0 ? random() * 250 : 0);
85
+ cooldown = Math.max(cooldown, Date.now() + delay);
86
+ if (attempt >= Math.min(retries, 2) || delay > Math.min(maxWaitMs - waited, deadline - Date.now())) throw lastError;
87
+ continue;
88
+ }
58
89
  if (read && [429, 503].includes(response.status) && attempt < retries) {
59
90
  const header = response.headers.get("retry-after");
60
91
  const retry = header == null ? 0 : /^\d+(?:\.\d+)?$/.test(header) ? Number(header) * 1000 : Math.max(0, Date.parse(header) - Date.now());
@@ -62,6 +93,10 @@ export function createSwarmClient({ baseUrl, token = "", concurrency = 16, retri
62
93
  if (delay <= 120_000) { cooldown = Math.max(cooldown, Date.now() + delay); continue; }
63
94
  }
64
95
  if (!response.ok) throw Object.assign(new Error(document?.error || "swarm_request_failed"), { status: response.status, payload: document });
96
+ if (backoffV1 && read && response.headers.get("X-HB-Backoff") === "v1") {
97
+ const hint = backoffDelayMs(response.headers, null);
98
+ if (hint > 0) cooldown = Math.max(cooldown, Date.now() + hint);
99
+ }
65
100
  if (cacheable && document?.snapshotId !== (snapshot || body?.snapshot || url.searchParams.get("snapshot"))) {
66
101
  throw Object.assign(new Error("snapshot_mismatch"), { status: 409 });
67
102
  }
@@ -1829,7 +1829,7 @@ export const STDIO_TOOL_METADATA = {
1829
1829
  },
1830
1830
  "list_teach_bases": {
1831
1831
  "title": "List teach bases",
1832
- "description": "Teach is live: local fine-tuning on a user's past decisions (Mac app 0.1.4 or hbay-teach). Lists bases, memory and templates. Use when a user wants to fine-tune a model on their own examples (kept local). Judged on their own exam; may not help. Not for one-off or written rules. Example: {}. Apple silicon, macOS 14+; memory 0.5B 8 GB, 1.7B 16 GB, 4B 32 GB (last two estimated). No hosted training.",
1832
+ "description": "Teach is live: local fine-tuning on a user's past decisions (current Mac app or hbay-teach). Lists bases, memory and templates. Use when a user wants to fine-tune a model on their own examples (kept local). Judged on their own exam; may not help. Not for one-off or written rules. Example: {}. Apple silicon, macOS 14+; memory 0.5B 8 GB, 1.7B 16 GB, 4B 32 GB (last two estimated). No hosted training.",
1833
1833
  "annotations": {
1834
1834
  "title": "List teach bases",
1835
1835
  "readOnlyHint": true,
@@ -1841,7 +1841,7 @@ export const STDIO_TOOL_METADATA = {
1841
1841
  },
1842
1842
  "get_teach_template": {
1843
1843
  "title": "Get teach template",
1844
- "description": "Teach is live: starter template with synthetic data only. Training runs on the user's machine (Mac app 0.1.4 or hbay-teach). Valid ids are the id inputSchema enum. Use when a user wants synthetic starter examples for local fine-tuning but has no data yet: job type, learning target, sample size and local commands. Example: {\"id\":\"payment-risk\"}. Hosted tools do not train; examples stay local.",
1844
+ "description": "Teach is live: starter template with synthetic data only. Training runs on the user's machine (current Mac app or hbay-teach). Valid ids are the id inputSchema enum. Use when a user wants synthetic starter examples for local fine-tuning but has no data yet: job type, learning target, sample size and local commands. Example: {\"id\":\"payment-risk\"}. Hosted tools do not train; examples stay local.",
1845
1845
  "annotations": {
1846
1846
  "title": "Get teach template",
1847
1847
  "readOnlyHint": true,