@blockrun/mcp 0.23.0 → 0.23.2
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/dist/index.js +31 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -100,9 +100,10 @@ function getOrCreateWalletKey() {
|
|
|
100
100
|
const info = ensureEvmWallet();
|
|
101
101
|
return info.privateKey;
|
|
102
102
|
}
|
|
103
|
-
function buildSolanaClient() {
|
|
103
|
+
function buildSolanaClient(timeout) {
|
|
104
104
|
const privateKey = process.env.SOLANA_WALLET_KEY || loadSolanaWallet() || void 0;
|
|
105
|
-
|
|
105
|
+
const opts = { ...privateKey ? { privateKey } : {}, ...timeout ? { timeout } : {} };
|
|
106
|
+
return new SolanaLLMClient(Object.keys(opts).length ? opts : void 0);
|
|
106
107
|
}
|
|
107
108
|
function getClient() {
|
|
108
109
|
if (getChain() === "solana") {
|
|
@@ -117,6 +118,13 @@ function getClient() {
|
|
|
117
118
|
}
|
|
118
119
|
return _evmClient;
|
|
119
120
|
}
|
|
121
|
+
function buildClientWithTimeout(timeoutMs) {
|
|
122
|
+
if (getChain() === "solana") {
|
|
123
|
+
return buildSolanaClient(timeoutMs);
|
|
124
|
+
}
|
|
125
|
+
const privateKey = getOrCreateWalletKey();
|
|
126
|
+
return new LLMClient({ privateKey, timeout: timeoutMs });
|
|
127
|
+
}
|
|
120
128
|
function getAnthropicClient() {
|
|
121
129
|
if (!_anthropicClient) {
|
|
122
130
|
const privateKey = getOrCreateWalletKey();
|
|
@@ -415,17 +423,23 @@ ${parts.join("\n")}`;
|
|
|
415
423
|
}
|
|
416
424
|
return base;
|
|
417
425
|
}
|
|
418
|
-
function formatError(message) {
|
|
426
|
+
function formatError(message, opts) {
|
|
419
427
|
const msgLower = message.toLowerCase();
|
|
420
428
|
const hasStatus = (code) => new RegExp(`(^|[^0-9.])${code}([^0-9]|$)`).test(msgLower);
|
|
421
429
|
const isPaymentError = hasStatus("402") || msgLower.includes("balance") || msgLower.includes("insufficient") || msgLower.includes("payment") && !hasStatus("500");
|
|
430
|
+
const isModelUnavailable = msgLower.includes("not active for requested provider") || msgLower.includes("not found or not active");
|
|
422
431
|
const isServerError = hasStatus("500") || msgLower.includes("api error after payment");
|
|
432
|
+
const altHint = opts?.altModels ? ` (e.g. ${opts.altModels})` : "";
|
|
423
433
|
let errorText = `Error: ${message}`;
|
|
424
|
-
if (
|
|
434
|
+
if (isModelUnavailable) {
|
|
435
|
+
errorText += `
|
|
436
|
+
|
|
437
|
+
This model is temporarily unavailable upstream` + (opts?.altModels ? `. Try a different model${altHint} \u2014 it should work right away.` : `. Try a different model, or retry shortly.`);
|
|
438
|
+
} else if (isServerError) {
|
|
425
439
|
errorText += `
|
|
426
440
|
|
|
427
441
|
This is a temporary API issue. The API may be experiencing problems.
|
|
428
|
-
Try again in a few minutes
|
|
442
|
+
Try again in a few minutes` + (opts?.altModels ? `, or use a different model${altHint}.` : `.`);
|
|
429
443
|
} else if (isPaymentError) {
|
|
430
444
|
const chain = getChain();
|
|
431
445
|
const network = chain === "solana" ? "Solana" : "Base";
|
|
@@ -1387,7 +1401,7 @@ Error: ${errMsg}` }],
|
|
|
1387
1401
|
};
|
|
1388
1402
|
}
|
|
1389
1403
|
return {
|
|
1390
|
-
content: [{ type: "text", text: formatError(`Image generation failed: ${errMsg}
|
|
1404
|
+
content: [{ type: "text", text: formatError(`Image generation failed: ${errMsg}`, { altModels: "google/nano-banana, zai/cogview-4" }) }],
|
|
1391
1405
|
isError: true
|
|
1392
1406
|
};
|
|
1393
1407
|
}
|
|
@@ -2054,7 +2068,7 @@ Error: ${errMsg}` }],
|
|
|
2054
2068
|
};
|
|
2055
2069
|
}
|
|
2056
2070
|
return {
|
|
2057
|
-
content: [{ type: "text", text: formatError(`Video generation failed: ${errMsg}
|
|
2071
|
+
content: [{ type: "text", text: formatError(`Video generation failed: ${errMsg}`, { altModels: "bytedance/seedance-2.0, azure/sora-2" }) }],
|
|
2058
2072
|
isError: true
|
|
2059
2073
|
};
|
|
2060
2074
|
}
|
|
@@ -2857,6 +2871,15 @@ import { z as z14 } from "zod";
|
|
|
2857
2871
|
function estimateModalCost(path5) {
|
|
2858
2872
|
return path5.includes("sandbox/create") ? 0.01 : 1e-3;
|
|
2859
2873
|
}
|
|
2874
|
+
var MODAL_DEFAULT_TIMEOUT_S = 300;
|
|
2875
|
+
var MODAL_MAX_TIMEOUT_S = 1800;
|
|
2876
|
+
var MODAL_SLACK_MS = 15e3;
|
|
2877
|
+
function modalTimeoutMs(body) {
|
|
2878
|
+
const raw = body && typeof body === "object" ? body.timeout : void 0;
|
|
2879
|
+
const requested = typeof raw === "number" && raw > 0 ? raw : MODAL_DEFAULT_TIMEOUT_S;
|
|
2880
|
+
const clamped = Math.min(Math.max(requested, MODAL_DEFAULT_TIMEOUT_S), MODAL_MAX_TIMEOUT_S);
|
|
2881
|
+
return clamped * 1e3 + MODAL_SLACK_MS;
|
|
2882
|
+
}
|
|
2860
2883
|
function registerModalTool(server, budget) {
|
|
2861
2884
|
server.registerTool(
|
|
2862
2885
|
"blockrun_modal",
|
|
@@ -2890,7 +2913,7 @@ Full action shapes + GPU type details in the \`modal\` skill.`,
|
|
|
2890
2913
|
isError: true
|
|
2891
2914
|
};
|
|
2892
2915
|
}
|
|
2893
|
-
const client =
|
|
2916
|
+
const client = buildClientWithTimeout(modalTimeoutMs(body));
|
|
2894
2917
|
const endpoint = `/v1/modal/${cleanPath}`;
|
|
2895
2918
|
const result = await client.requestWithPaymentRaw(endpoint, body ?? {});
|
|
2896
2919
|
recordSpending(budget, estimatedCost, agent_id);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blockrun/mcp",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.2",
|
|
4
4
|
"mcpName": "io.github.BlockRunAI/blockrun-mcp",
|
|
5
5
|
"description": "BlockRun MCP Server - Give your AI agent web search, deep research, prediction markets, crypto data, X/Twitter intelligence. Paid via x402 micropayments.",
|
|
6
6
|
"type": "module",
|