@morphllm/morphsdk 0.2.114 → 0.2.116
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/{chunk-HI35Y6EZ.js → chunk-3JVHMOYJ.js} +18 -5
- package/dist/chunk-3JVHMOYJ.js.map +1 -0
- package/dist/{chunk-ALTKGCG5.js → chunk-5JARN2NG.js} +2 -2
- package/dist/{chunk-3U7AWFBN.js → chunk-62OVBE6G.js} +5 -5
- package/dist/{chunk-FL4ZBHK2.js → chunk-GENFEPHG.js} +2 -2
- package/dist/{chunk-23R562QJ.js → chunk-OVNPKTEG.js} +9 -4
- package/dist/chunk-OVNPKTEG.js.map +1 -0
- package/dist/{chunk-YY7NZLAI.js → chunk-RBOCP2MX.js} +42 -20
- package/dist/chunk-RBOCP2MX.js.map +1 -0
- package/dist/{client-Bm_umdno.d.ts → client-D7iO2TbA.d.ts} +7 -0
- package/dist/client.cjs +61 -23
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +6 -6
- package/dist/index.cjs +61 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/tools/warp_grep/agent/runner.cjs +41 -19
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +1 -1
- package/dist/tools/warp_grep/anthropic.cjs +39 -19
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.js +3 -3
- package/dist/tools/warp_grep/client.cjs +49 -21
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.d.ts +7 -1
- package/dist/tools/warp_grep/client.js +4 -2
- package/dist/tools/warp_grep/gemini.cjs +39 -19
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.js +2 -2
- package/dist/tools/warp_grep/index.cjs +47 -21
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.js +2 -2
- package/dist/tools/warp_grep/openai.cjs +39 -19
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.js +3 -3
- package/dist/tools/warp_grep/vercel.cjs +247 -21
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +7 -0
- package/dist/tools/warp_grep/vercel.js +3 -3
- package/package.json +6 -1
- package/dist/chunk-23R562QJ.js.map +0 -1
- package/dist/chunk-HI35Y6EZ.js.map +0 -1
- package/dist/chunk-YY7NZLAI.js.map +0 -1
- /package/dist/{chunk-ALTKGCG5.js.map → chunk-5JARN2NG.js.map} +0 -0
- /package/dist/{chunk-3U7AWFBN.js.map → chunk-62OVBE6G.js.map} +0 -0
- /package/dist/{chunk-FL4ZBHK2.js.map → chunk-GENFEPHG.js.map} +0 -0
|
@@ -1367,27 +1367,41 @@ async function callModel(messages, model, options = {}) {
|
|
|
1367
1367
|
maxRetries: options.retryConfig?.maxRetries,
|
|
1368
1368
|
timeout: timeoutMs
|
|
1369
1369
|
});
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
data
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1370
|
+
const MAX_EMPTY_RETRIES = 1;
|
|
1371
|
+
for (let attempt = 0; attempt <= MAX_EMPTY_RETRIES; attempt++) {
|
|
1372
|
+
let data;
|
|
1373
|
+
try {
|
|
1374
|
+
data = await client.chat.completions.create({
|
|
1375
|
+
model,
|
|
1376
|
+
temperature: 0,
|
|
1377
|
+
max_tokens: 1024,
|
|
1378
|
+
messages
|
|
1379
|
+
});
|
|
1380
|
+
} catch (error) {
|
|
1381
|
+
if (error instanceof import_openai.default.APIError && error.status === 404) {
|
|
1382
|
+
throw new Error(
|
|
1383
|
+
"The endpoint you are trying to call is likely deprecated. Please update with: npm cache clean --force && npx -y @morphllm/morphmcp@latest or visit: https://morphllm.com/mcp"
|
|
1384
|
+
);
|
|
1385
|
+
}
|
|
1386
|
+
throw error;
|
|
1387
|
+
}
|
|
1388
|
+
const choice = data?.choices?.[0];
|
|
1389
|
+
const content = choice?.message?.content;
|
|
1390
|
+
if (content && typeof content === "string") {
|
|
1391
|
+
return content;
|
|
1392
|
+
}
|
|
1393
|
+
if (attempt === MAX_EMPTY_RETRIES) {
|
|
1394
|
+
const finishReason = choice?.finish_reason ?? "unknown";
|
|
1395
|
+
const hasToolCalls = Array.isArray(choice?.message?.tool_calls) && choice.message.tool_calls.length > 0;
|
|
1396
|
+
const choicesLen = data?.choices?.length ?? 0;
|
|
1397
|
+
const contentType = content === null ? "null" : content === void 0 ? "undefined" : typeof content;
|
|
1380
1398
|
throw new Error(
|
|
1381
|
-
|
|
1399
|
+
`Invalid response from model: content=${contentType}, finish_reason=${finishReason}, has_tool_calls=${hasToolCalls}, choices_length=${choicesLen}`
|
|
1382
1400
|
);
|
|
1383
1401
|
}
|
|
1384
|
-
|
|
1385
|
-
}
|
|
1386
|
-
const content = data?.choices?.[0]?.message?.content;
|
|
1387
|
-
if (!content || typeof content !== "string") {
|
|
1388
|
-
throw new Error("Invalid response from model");
|
|
1402
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
1389
1403
|
}
|
|
1390
|
-
|
|
1404
|
+
throw new Error("Invalid response from model");
|
|
1391
1405
|
}
|
|
1392
1406
|
async function runWarpGrep(config) {
|
|
1393
1407
|
const totalStart = Date.now();
|
|
@@ -1416,17 +1430,21 @@ async function runWarpGrep(config) {
|
|
|
1416
1430
|
retryConfig: config.retryConfig,
|
|
1417
1431
|
timeout: timeoutMs
|
|
1418
1432
|
}).catch((e) => {
|
|
1419
|
-
|
|
1433
|
+
const errMsg = e instanceof Error ? e.message : String(e);
|
|
1434
|
+
console.error(`[warp_grep] Morph API call failed on turn ${turn}:`, errMsg);
|
|
1435
|
+
errors.push({ message: errMsg });
|
|
1420
1436
|
return "";
|
|
1421
1437
|
});
|
|
1422
1438
|
turnMetrics.morph_api_ms = Date.now() - modelCallStart;
|
|
1423
1439
|
if (!assistantContent) {
|
|
1440
|
+
console.error(`[warp_grep] Empty response from Morph API on turn ${turn}. Errors so far:`, errors);
|
|
1424
1441
|
timings.turns.push(turnMetrics);
|
|
1425
1442
|
break;
|
|
1426
1443
|
}
|
|
1427
1444
|
messages.push({ role: "assistant", content: assistantContent });
|
|
1428
1445
|
const toolCalls = parser.parse(assistantContent);
|
|
1429
1446
|
if (toolCalls.length === 0) {
|
|
1447
|
+
console.error(`[warp_grep] No tool calls parsed on turn ${turn}. Assistant content (first 500 chars):`, assistantContent.slice(0, 500));
|
|
1430
1448
|
errors.push({ message: "No tool calls produced by the model. Your MCP is likely out of date! Update it by running: rm -rf ~/.npm/_npx && npm cache clean --force && npx -y @morphllm/morphmcp@latest" });
|
|
1431
1449
|
terminationReason = "terminated";
|
|
1432
1450
|
timings.turns.push(turnMetrics);
|
|
@@ -1736,7 +1754,9 @@ async function executeToolCall(input, config) {
|
|
|
1736
1754
|
});
|
|
1737
1755
|
const finish = result.finish;
|
|
1738
1756
|
if (result.terminationReason !== "completed" || !finish?.metadata) {
|
|
1739
|
-
|
|
1757
|
+
const errorDetails = result.errors?.map((e) => e.message).join("; ") || "unknown reason";
|
|
1758
|
+
console.error(`[warp_grep] executeToolCall failed. Reason: ${result.terminationReason}. Errors: ${errorDetails}. Turns: ${result.timings?.turns?.length ?? 0}`);
|
|
1759
|
+
return { success: false, error: `Search did not complete: ${errorDetails}` };
|
|
1740
1760
|
}
|
|
1741
1761
|
const contexts = (finish.resolved ?? []).map((r) => ({
|
|
1742
1762
|
file: r.path,
|