@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.
Files changed (48) hide show
  1. package/dist/{chunk-HI35Y6EZ.js → chunk-3JVHMOYJ.js} +18 -5
  2. package/dist/chunk-3JVHMOYJ.js.map +1 -0
  3. package/dist/{chunk-ALTKGCG5.js → chunk-5JARN2NG.js} +2 -2
  4. package/dist/{chunk-3U7AWFBN.js → chunk-62OVBE6G.js} +5 -5
  5. package/dist/{chunk-FL4ZBHK2.js → chunk-GENFEPHG.js} +2 -2
  6. package/dist/{chunk-23R562QJ.js → chunk-OVNPKTEG.js} +9 -4
  7. package/dist/chunk-OVNPKTEG.js.map +1 -0
  8. package/dist/{chunk-YY7NZLAI.js → chunk-RBOCP2MX.js} +42 -20
  9. package/dist/chunk-RBOCP2MX.js.map +1 -0
  10. package/dist/{client-Bm_umdno.d.ts → client-D7iO2TbA.d.ts} +7 -0
  11. package/dist/client.cjs +61 -23
  12. package/dist/client.cjs.map +1 -1
  13. package/dist/client.d.ts +1 -1
  14. package/dist/client.js +6 -6
  15. package/dist/index.cjs +61 -23
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +6 -6
  19. package/dist/tools/warp_grep/agent/runner.cjs +41 -19
  20. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
  21. package/dist/tools/warp_grep/agent/runner.js +1 -1
  22. package/dist/tools/warp_grep/anthropic.cjs +39 -19
  23. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  24. package/dist/tools/warp_grep/anthropic.js +3 -3
  25. package/dist/tools/warp_grep/client.cjs +49 -21
  26. package/dist/tools/warp_grep/client.cjs.map +1 -1
  27. package/dist/tools/warp_grep/client.d.ts +7 -1
  28. package/dist/tools/warp_grep/client.js +4 -2
  29. package/dist/tools/warp_grep/gemini.cjs +39 -19
  30. package/dist/tools/warp_grep/gemini.cjs.map +1 -1
  31. package/dist/tools/warp_grep/gemini.js +2 -2
  32. package/dist/tools/warp_grep/index.cjs +47 -21
  33. package/dist/tools/warp_grep/index.cjs.map +1 -1
  34. package/dist/tools/warp_grep/index.js +2 -2
  35. package/dist/tools/warp_grep/openai.cjs +39 -19
  36. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  37. package/dist/tools/warp_grep/openai.js +3 -3
  38. package/dist/tools/warp_grep/vercel.cjs +247 -21
  39. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  40. package/dist/tools/warp_grep/vercel.d.ts +7 -0
  41. package/dist/tools/warp_grep/vercel.js +3 -3
  42. package/package.json +6 -1
  43. package/dist/chunk-23R562QJ.js.map +0 -1
  44. package/dist/chunk-HI35Y6EZ.js.map +0 -1
  45. package/dist/chunk-YY7NZLAI.js.map +0 -1
  46. /package/dist/{chunk-ALTKGCG5.js.map → chunk-5JARN2NG.js.map} +0 -0
  47. /package/dist/{chunk-3U7AWFBN.js.map → chunk-62OVBE6G.js.map} +0 -0
  48. /package/dist/{chunk-FL4ZBHK2.js.map → chunk-GENFEPHG.js.map} +0 -0
@@ -2,12 +2,12 @@ import {
2
2
  createWarpGrepTool,
3
3
  execute,
4
4
  warpGrepTool
5
- } from "../../chunk-ALTKGCG5.js";
5
+ } from "../../chunk-5JARN2NG.js";
6
6
  import "../../chunk-KW7OEGZK.js";
7
7
  import {
8
8
  formatResult
9
- } from "../../chunk-23R562QJ.js";
10
- import "../../chunk-YY7NZLAI.js";
9
+ } from "../../chunk-OVNPKTEG.js";
10
+ import "../../chunk-RBOCP2MX.js";
11
11
  import "../../chunk-PUGSTXLO.js";
12
12
  import "../../chunk-3MLWXJTJ.js";
13
13
  import "../../chunk-SNGGSPYJ.js";
@@ -569,6 +569,7 @@ var client_exports = {};
569
569
  __export(client_exports, {
570
570
  WarpGrepClient: () => WarpGrepClient,
571
571
  executeToolCall: () => executeToolCall,
572
+ executeToolCallStreaming: () => executeToolCallStreaming,
572
573
  executeWarpGrep: () => executeWarpGrep,
573
574
  formatResult: () => formatResult
574
575
  });
@@ -1366,27 +1367,41 @@ async function callModel(messages, model, options = {}) {
1366
1367
  maxRetries: options.retryConfig?.maxRetries,
1367
1368
  timeout: timeoutMs
1368
1369
  });
1369
- let data;
1370
- try {
1371
- data = await client.chat.completions.create({
1372
- model,
1373
- temperature: 0,
1374
- max_tokens: 1024,
1375
- messages
1376
- });
1377
- } catch (error) {
1378
- if (error instanceof import_openai.default.APIError && error.status === 404) {
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;
1379
1398
  throw new Error(
1380
- "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"
1399
+ `Invalid response from model: content=${contentType}, finish_reason=${finishReason}, has_tool_calls=${hasToolCalls}, choices_length=${choicesLen}`
1381
1400
  );
1382
1401
  }
1383
- throw error;
1384
- }
1385
- const content = data?.choices?.[0]?.message?.content;
1386
- if (!content || typeof content !== "string") {
1387
- throw new Error("Invalid response from model");
1402
+ await new Promise((resolve) => setTimeout(resolve, 200));
1388
1403
  }
1389
- return content;
1404
+ throw new Error("Invalid response from model");
1390
1405
  }
1391
1406
  async function runWarpGrep(config) {
1392
1407
  const totalStart = Date.now();
@@ -1415,17 +1430,21 @@ async function runWarpGrep(config) {
1415
1430
  retryConfig: config.retryConfig,
1416
1431
  timeout: timeoutMs
1417
1432
  }).catch((e) => {
1418
- errors.push({ message: e instanceof Error ? e.message : String(e) });
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 });
1419
1436
  return "";
1420
1437
  });
1421
1438
  turnMetrics.morph_api_ms = Date.now() - modelCallStart;
1422
1439
  if (!assistantContent) {
1440
+ console.error(`[warp_grep] Empty response from Morph API on turn ${turn}. Errors so far:`, errors);
1423
1441
  timings.turns.push(turnMetrics);
1424
1442
  break;
1425
1443
  }
1426
1444
  messages.push({ role: "assistant", content: assistantContent });
1427
1445
  const toolCalls = parser.parse(assistantContent);
1428
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));
1429
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" });
1430
1449
  terminationReason = "terminated";
1431
1450
  timings.turns.push(turnMetrics);
@@ -1558,17 +1577,21 @@ async function* runWarpGrepStreaming(config) {
1558
1577
  retryConfig: config.retryConfig,
1559
1578
  timeout: timeoutMs
1560
1579
  }).catch((e) => {
1561
- errors.push({ message: e instanceof Error ? e.message : String(e) });
1580
+ const errMsg = e instanceof Error ? e.message : String(e);
1581
+ console.error(`[warp_grep:stream] Morph API call failed on turn ${turn}:`, errMsg);
1582
+ errors.push({ message: errMsg });
1562
1583
  return "";
1563
1584
  });
1564
1585
  turnMetrics.morph_api_ms = Date.now() - modelCallStart;
1565
1586
  if (!assistantContent) {
1587
+ console.error(`[warp_grep:stream] Empty response from Morph API on turn ${turn}. Errors so far:`, errors);
1566
1588
  timings.turns.push(turnMetrics);
1567
1589
  break;
1568
1590
  }
1569
1591
  messages.push({ role: "assistant", content: assistantContent });
1570
1592
  const toolCalls = parser.parse(assistantContent);
1571
1593
  if (toolCalls.length === 0) {
1594
+ console.error(`[warp_grep:stream] No tool calls parsed on turn ${turn}. Assistant content (first 500 chars):`, assistantContent.slice(0, 500));
1572
1595
  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" });
1573
1596
  terminationReason = "terminated";
1574
1597
  timings.turns.push(turnMetrics);
@@ -1922,7 +1945,9 @@ async function executeToolCall(input, config) {
1922
1945
  });
1923
1946
  const finish = result.finish;
1924
1947
  if (result.terminationReason !== "completed" || !finish?.metadata) {
1925
- return { success: false, error: "Search did not complete" };
1948
+ const errorDetails = result.errors?.map((e) => e.message).join("; ") || "unknown reason";
1949
+ console.error(`[warp_grep] executeToolCall failed. Reason: ${result.terminationReason}. Errors: ${errorDetails}. Turns: ${result.timings?.turns?.length ?? 0}`);
1950
+ return { success: false, error: `Search did not complete: ${errorDetails}` };
1926
1951
  }
1927
1952
  const contexts = (finish.resolved ?? []).map((r) => ({
1928
1953
  file: r.path,
@@ -1934,7 +1959,9 @@ async function executeToolCall(input, config) {
1934
1959
  function processAgentResult(result) {
1935
1960
  const finish = result.finish;
1936
1961
  if (result.terminationReason !== "completed" || !finish?.metadata) {
1937
- return { success: false, error: "Search did not complete" };
1962
+ const errorDetails = result.errors?.map((e) => e.message).join("; ") || "unknown reason";
1963
+ console.error(`[warp_grep] processAgentResult failed. Reason: ${result.terminationReason}. Errors: ${errorDetails}. Turns: ${result.timings?.turns?.length ?? 0}`);
1964
+ return { success: false, error: `Search did not complete: ${errorDetails}` };
1938
1965
  }
1939
1966
  const contexts = (finish.resolved ?? []).map((r) => ({
1940
1967
  file: r.path,
@@ -1997,6 +2024,7 @@ function formatResult(result) {
1997
2024
  0 && (module.exports = {
1998
2025
  WarpGrepClient,
1999
2026
  executeToolCall,
2027
+ executeToolCallStreaming,
2000
2028
  executeWarpGrep,
2001
2029
  formatResult
2002
2030
  });