@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
|
@@ -18,11 +18,11 @@ import {
|
|
|
18
18
|
executeToolCall,
|
|
19
19
|
executeWarpGrep,
|
|
20
20
|
formatResult
|
|
21
|
-
} from "../../chunk-
|
|
21
|
+
} from "../../chunk-OVNPKTEG.js";
|
|
22
22
|
import {
|
|
23
23
|
runWarpGrep,
|
|
24
24
|
runWarpGrepStreaming
|
|
25
|
-
} from "../../chunk-
|
|
25
|
+
} from "../../chunk-RBOCP2MX.js";
|
|
26
26
|
import {
|
|
27
27
|
RemoteCommandsProvider
|
|
28
28
|
} from "../../chunk-PUGSTXLO.js";
|
|
@@ -1368,27 +1368,41 @@ async function callModel(messages, model, options = {}) {
|
|
|
1368
1368
|
maxRetries: options.retryConfig?.maxRetries,
|
|
1369
1369
|
timeout: timeoutMs
|
|
1370
1370
|
});
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
data
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1371
|
+
const MAX_EMPTY_RETRIES = 1;
|
|
1372
|
+
for (let attempt = 0; attempt <= MAX_EMPTY_RETRIES; attempt++) {
|
|
1373
|
+
let data;
|
|
1374
|
+
try {
|
|
1375
|
+
data = await client.chat.completions.create({
|
|
1376
|
+
model,
|
|
1377
|
+
temperature: 0,
|
|
1378
|
+
max_tokens: 1024,
|
|
1379
|
+
messages
|
|
1380
|
+
});
|
|
1381
|
+
} catch (error) {
|
|
1382
|
+
if (error instanceof import_openai.default.APIError && error.status === 404) {
|
|
1383
|
+
throw new Error(
|
|
1384
|
+
"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"
|
|
1385
|
+
);
|
|
1386
|
+
}
|
|
1387
|
+
throw error;
|
|
1388
|
+
}
|
|
1389
|
+
const choice = data?.choices?.[0];
|
|
1390
|
+
const content = choice?.message?.content;
|
|
1391
|
+
if (content && typeof content === "string") {
|
|
1392
|
+
return content;
|
|
1393
|
+
}
|
|
1394
|
+
if (attempt === MAX_EMPTY_RETRIES) {
|
|
1395
|
+
const finishReason = choice?.finish_reason ?? "unknown";
|
|
1396
|
+
const hasToolCalls = Array.isArray(choice?.message?.tool_calls) && choice.message.tool_calls.length > 0;
|
|
1397
|
+
const choicesLen = data?.choices?.length ?? 0;
|
|
1398
|
+
const contentType = content === null ? "null" : content === void 0 ? "undefined" : typeof content;
|
|
1381
1399
|
throw new Error(
|
|
1382
|
-
|
|
1400
|
+
`Invalid response from model: content=${contentType}, finish_reason=${finishReason}, has_tool_calls=${hasToolCalls}, choices_length=${choicesLen}`
|
|
1383
1401
|
);
|
|
1384
1402
|
}
|
|
1385
|
-
|
|
1386
|
-
}
|
|
1387
|
-
const content = data?.choices?.[0]?.message?.content;
|
|
1388
|
-
if (!content || typeof content !== "string") {
|
|
1389
|
-
throw new Error("Invalid response from model");
|
|
1403
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
1390
1404
|
}
|
|
1391
|
-
|
|
1405
|
+
throw new Error("Invalid response from model");
|
|
1392
1406
|
}
|
|
1393
1407
|
async function runWarpGrep(config) {
|
|
1394
1408
|
const totalStart = Date.now();
|
|
@@ -1417,17 +1431,21 @@ async function runWarpGrep(config) {
|
|
|
1417
1431
|
retryConfig: config.retryConfig,
|
|
1418
1432
|
timeout: timeoutMs
|
|
1419
1433
|
}).catch((e) => {
|
|
1420
|
-
|
|
1434
|
+
const errMsg = e instanceof Error ? e.message : String(e);
|
|
1435
|
+
console.error(`[warp_grep] Morph API call failed on turn ${turn}:`, errMsg);
|
|
1436
|
+
errors.push({ message: errMsg });
|
|
1421
1437
|
return "";
|
|
1422
1438
|
});
|
|
1423
1439
|
turnMetrics.morph_api_ms = Date.now() - modelCallStart;
|
|
1424
1440
|
if (!assistantContent) {
|
|
1441
|
+
console.error(`[warp_grep] Empty response from Morph API on turn ${turn}. Errors so far:`, errors);
|
|
1425
1442
|
timings.turns.push(turnMetrics);
|
|
1426
1443
|
break;
|
|
1427
1444
|
}
|
|
1428
1445
|
messages.push({ role: "assistant", content: assistantContent });
|
|
1429
1446
|
const toolCalls = parser.parse(assistantContent);
|
|
1430
1447
|
if (toolCalls.length === 0) {
|
|
1448
|
+
console.error(`[warp_grep] No tool calls parsed on turn ${turn}. Assistant content (first 500 chars):`, assistantContent.slice(0, 500));
|
|
1431
1449
|
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" });
|
|
1432
1450
|
terminationReason = "terminated";
|
|
1433
1451
|
timings.turns.push(turnMetrics);
|
|
@@ -1737,7 +1755,9 @@ async function executeToolCall(input, config) {
|
|
|
1737
1755
|
});
|
|
1738
1756
|
const finish = result.finish;
|
|
1739
1757
|
if (result.terminationReason !== "completed" || !finish?.metadata) {
|
|
1740
|
-
|
|
1758
|
+
const errorDetails = result.errors?.map((e) => e.message).join("; ") || "unknown reason";
|
|
1759
|
+
console.error(`[warp_grep] executeToolCall failed. Reason: ${result.terminationReason}. Errors: ${errorDetails}. Turns: ${result.timings?.turns?.length ?? 0}`);
|
|
1760
|
+
return { success: false, error: `Search did not complete: ${errorDetails}` };
|
|
1741
1761
|
}
|
|
1742
1762
|
const contexts = (finish.resolved ?? []).map((r) => ({
|
|
1743
1763
|
file: r.path,
|