@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
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
executeToolCall,
|
|
7
7
|
formatResult
|
|
8
|
-
} from "../../chunk-
|
|
9
|
-
import "../../chunk-
|
|
8
|
+
} from "../../chunk-OVNPKTEG.js";
|
|
9
|
+
import "../../chunk-RBOCP2MX.js";
|
|
10
10
|
import "../../chunk-PUGSTXLO.js";
|
|
11
11
|
import "../../chunk-3MLWXJTJ.js";
|
|
12
12
|
import "../../chunk-SNGGSPYJ.js";
|
|
@@ -1390,27 +1390,41 @@ async function callModel(messages, model, options = {}) {
|
|
|
1390
1390
|
maxRetries: options.retryConfig?.maxRetries,
|
|
1391
1391
|
timeout: timeoutMs
|
|
1392
1392
|
});
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
data
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1393
|
+
const MAX_EMPTY_RETRIES = 1;
|
|
1394
|
+
for (let attempt = 0; attempt <= MAX_EMPTY_RETRIES; attempt++) {
|
|
1395
|
+
let data;
|
|
1396
|
+
try {
|
|
1397
|
+
data = await client.chat.completions.create({
|
|
1398
|
+
model,
|
|
1399
|
+
temperature: 0,
|
|
1400
|
+
max_tokens: 1024,
|
|
1401
|
+
messages
|
|
1402
|
+
});
|
|
1403
|
+
} catch (error) {
|
|
1404
|
+
if (error instanceof import_openai.default.APIError && error.status === 404) {
|
|
1405
|
+
throw new Error(
|
|
1406
|
+
"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"
|
|
1407
|
+
);
|
|
1408
|
+
}
|
|
1409
|
+
throw error;
|
|
1410
|
+
}
|
|
1411
|
+
const choice = data?.choices?.[0];
|
|
1412
|
+
const content = choice?.message?.content;
|
|
1413
|
+
if (content && typeof content === "string") {
|
|
1414
|
+
return content;
|
|
1415
|
+
}
|
|
1416
|
+
if (attempt === MAX_EMPTY_RETRIES) {
|
|
1417
|
+
const finishReason = choice?.finish_reason ?? "unknown";
|
|
1418
|
+
const hasToolCalls = Array.isArray(choice?.message?.tool_calls) && choice.message.tool_calls.length > 0;
|
|
1419
|
+
const choicesLen = data?.choices?.length ?? 0;
|
|
1420
|
+
const contentType = content === null ? "null" : content === void 0 ? "undefined" : typeof content;
|
|
1403
1421
|
throw new Error(
|
|
1404
|
-
|
|
1422
|
+
`Invalid response from model: content=${contentType}, finish_reason=${finishReason}, has_tool_calls=${hasToolCalls}, choices_length=${choicesLen}`
|
|
1405
1423
|
);
|
|
1406
1424
|
}
|
|
1407
|
-
|
|
1408
|
-
}
|
|
1409
|
-
const content = data?.choices?.[0]?.message?.content;
|
|
1410
|
-
if (!content || typeof content !== "string") {
|
|
1411
|
-
throw new Error("Invalid response from model");
|
|
1425
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
1412
1426
|
}
|
|
1413
|
-
|
|
1427
|
+
throw new Error("Invalid response from model");
|
|
1414
1428
|
}
|
|
1415
1429
|
async function runWarpGrep(config) {
|
|
1416
1430
|
const totalStart = Date.now();
|
|
@@ -1439,17 +1453,21 @@ async function runWarpGrep(config) {
|
|
|
1439
1453
|
retryConfig: config.retryConfig,
|
|
1440
1454
|
timeout: timeoutMs
|
|
1441
1455
|
}).catch((e) => {
|
|
1442
|
-
|
|
1456
|
+
const errMsg = e instanceof Error ? e.message : String(e);
|
|
1457
|
+
console.error(`[warp_grep] Morph API call failed on turn ${turn}:`, errMsg);
|
|
1458
|
+
errors.push({ message: errMsg });
|
|
1443
1459
|
return "";
|
|
1444
1460
|
});
|
|
1445
1461
|
turnMetrics.morph_api_ms = Date.now() - modelCallStart;
|
|
1446
1462
|
if (!assistantContent) {
|
|
1463
|
+
console.error(`[warp_grep] Empty response from Morph API on turn ${turn}. Errors so far:`, errors);
|
|
1447
1464
|
timings.turns.push(turnMetrics);
|
|
1448
1465
|
break;
|
|
1449
1466
|
}
|
|
1450
1467
|
messages.push({ role: "assistant", content: assistantContent });
|
|
1451
1468
|
const toolCalls = parser.parse(assistantContent);
|
|
1452
1469
|
if (toolCalls.length === 0) {
|
|
1470
|
+
console.error(`[warp_grep] No tool calls parsed on turn ${turn}. Assistant content (first 500 chars):`, assistantContent.slice(0, 500));
|
|
1453
1471
|
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" });
|
|
1454
1472
|
terminationReason = "terminated";
|
|
1455
1473
|
timings.turns.push(turnMetrics);
|
|
@@ -1582,17 +1600,21 @@ async function* runWarpGrepStreaming(config) {
|
|
|
1582
1600
|
retryConfig: config.retryConfig,
|
|
1583
1601
|
timeout: timeoutMs
|
|
1584
1602
|
}).catch((e) => {
|
|
1585
|
-
|
|
1603
|
+
const errMsg = e instanceof Error ? e.message : String(e);
|
|
1604
|
+
console.error(`[warp_grep:stream] Morph API call failed on turn ${turn}:`, errMsg);
|
|
1605
|
+
errors.push({ message: errMsg });
|
|
1586
1606
|
return "";
|
|
1587
1607
|
});
|
|
1588
1608
|
turnMetrics.morph_api_ms = Date.now() - modelCallStart;
|
|
1589
1609
|
if (!assistantContent) {
|
|
1610
|
+
console.error(`[warp_grep:stream] Empty response from Morph API on turn ${turn}. Errors so far:`, errors);
|
|
1590
1611
|
timings.turns.push(turnMetrics);
|
|
1591
1612
|
break;
|
|
1592
1613
|
}
|
|
1593
1614
|
messages.push({ role: "assistant", content: assistantContent });
|
|
1594
1615
|
const toolCalls = parser.parse(assistantContent);
|
|
1595
1616
|
if (toolCalls.length === 0) {
|
|
1617
|
+
console.error(`[warp_grep:stream] No tool calls parsed on turn ${turn}. Assistant content (first 500 chars):`, assistantContent.slice(0, 500));
|
|
1596
1618
|
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" });
|
|
1597
1619
|
terminationReason = "terminated";
|
|
1598
1620
|
timings.turns.push(turnMetrics);
|
|
@@ -1946,7 +1968,9 @@ async function executeToolCall(input, config) {
|
|
|
1946
1968
|
});
|
|
1947
1969
|
const finish = result.finish;
|
|
1948
1970
|
if (result.terminationReason !== "completed" || !finish?.metadata) {
|
|
1949
|
-
|
|
1971
|
+
const errorDetails = result.errors?.map((e) => e.message).join("; ") || "unknown reason";
|
|
1972
|
+
console.error(`[warp_grep] executeToolCall failed. Reason: ${result.terminationReason}. Errors: ${errorDetails}. Turns: ${result.timings?.turns?.length ?? 0}`);
|
|
1973
|
+
return { success: false, error: `Search did not complete: ${errorDetails}` };
|
|
1950
1974
|
}
|
|
1951
1975
|
const contexts = (finish.resolved ?? []).map((r) => ({
|
|
1952
1976
|
file: r.path,
|
|
@@ -1958,7 +1982,9 @@ async function executeToolCall(input, config) {
|
|
|
1958
1982
|
function processAgentResult(result) {
|
|
1959
1983
|
const finish = result.finish;
|
|
1960
1984
|
if (result.terminationReason !== "completed" || !finish?.metadata) {
|
|
1961
|
-
|
|
1985
|
+
const errorDetails = result.errors?.map((e) => e.message).join("; ") || "unknown reason";
|
|
1986
|
+
console.error(`[warp_grep] processAgentResult failed. Reason: ${result.terminationReason}. Errors: ${errorDetails}. Turns: ${result.timings?.turns?.length ?? 0}`);
|
|
1987
|
+
return { success: false, error: `Search did not complete: ${errorDetails}` };
|
|
1962
1988
|
}
|
|
1963
1989
|
const contexts = (finish.resolved ?? []).map((r) => ({
|
|
1964
1990
|
file: r.path,
|