@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
@@ -109,6 +109,12 @@ declare function executeWarpGrep(input: WarpGrepInput & {
109
109
  declare function executeToolCall(input: {
110
110
  query: string;
111
111
  } | string, config: WarpGrepToolConfig): Promise<WarpGrepResult>;
112
+ /**
113
+ * Streaming version of executeToolCall that yields WarpGrepStep for each turn.
114
+ */
115
+ declare function executeToolCallStreaming(input: {
116
+ query: string;
117
+ } | string, config: WarpGrepToolConfig): AsyncGenerator<WarpGrepStep, WarpGrepResult, undefined>;
112
118
  /**
113
119
  * Format warp grep results for display or tool responses
114
120
  *
@@ -117,4 +123,4 @@ declare function executeToolCall(input: {
117
123
  */
118
124
  declare function formatResult(result: WarpGrepResult): string;
119
125
 
120
- export { WarpGrepClient, executeToolCall, executeWarpGrep, formatResult };
126
+ export { WarpGrepClient, executeToolCall, executeToolCallStreaming, executeWarpGrep, formatResult };
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  WarpGrepClient,
3
3
  executeToolCall,
4
+ executeToolCallStreaming,
4
5
  executeWarpGrep,
5
6
  formatResult
6
- } from "../../chunk-23R562QJ.js";
7
- import "../../chunk-YY7NZLAI.js";
7
+ } from "../../chunk-OVNPKTEG.js";
8
+ import "../../chunk-RBOCP2MX.js";
8
9
  import "../../chunk-PUGSTXLO.js";
9
10
  import "../../chunk-3MLWXJTJ.js";
10
11
  import "../../chunk-SNGGSPYJ.js";
@@ -15,6 +16,7 @@ import "../../chunk-PZ5AY32C.js";
15
16
  export {
16
17
  WarpGrepClient,
17
18
  executeToolCall,
19
+ executeToolCallStreaming,
18
20
  executeWarpGrep,
19
21
  formatResult
20
22
  };
@@ -1369,27 +1369,41 @@ async function callModel(messages, model, options = {}) {
1369
1369
  maxRetries: options.retryConfig?.maxRetries,
1370
1370
  timeout: timeoutMs
1371
1371
  });
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) {
1372
+ const MAX_EMPTY_RETRIES = 1;
1373
+ for (let attempt = 0; attempt <= MAX_EMPTY_RETRIES; attempt++) {
1374
+ let data;
1375
+ try {
1376
+ data = await client.chat.completions.create({
1377
+ model,
1378
+ temperature: 0,
1379
+ max_tokens: 1024,
1380
+ messages
1381
+ });
1382
+ } catch (error) {
1383
+ if (error instanceof import_openai.default.APIError && error.status === 404) {
1384
+ throw new Error(
1385
+ "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"
1386
+ );
1387
+ }
1388
+ throw error;
1389
+ }
1390
+ const choice = data?.choices?.[0];
1391
+ const content = choice?.message?.content;
1392
+ if (content && typeof content === "string") {
1393
+ return content;
1394
+ }
1395
+ if (attempt === MAX_EMPTY_RETRIES) {
1396
+ const finishReason = choice?.finish_reason ?? "unknown";
1397
+ const hasToolCalls = Array.isArray(choice?.message?.tool_calls) && choice.message.tool_calls.length > 0;
1398
+ const choicesLen = data?.choices?.length ?? 0;
1399
+ const contentType = content === null ? "null" : content === void 0 ? "undefined" : typeof content;
1382
1400
  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"
1401
+ `Invalid response from model: content=${contentType}, finish_reason=${finishReason}, has_tool_calls=${hasToolCalls}, choices_length=${choicesLen}`
1384
1402
  );
1385
1403
  }
1386
- throw error;
1387
- }
1388
- const content = data?.choices?.[0]?.message?.content;
1389
- if (!content || typeof content !== "string") {
1390
- throw new Error("Invalid response from model");
1404
+ await new Promise((resolve) => setTimeout(resolve, 200));
1391
1405
  }
1392
- return content;
1406
+ throw new Error("Invalid response from model");
1393
1407
  }
1394
1408
  async function runWarpGrep(config) {
1395
1409
  const totalStart = Date.now();
@@ -1418,17 +1432,21 @@ async function runWarpGrep(config) {
1418
1432
  retryConfig: config.retryConfig,
1419
1433
  timeout: timeoutMs
1420
1434
  }).catch((e) => {
1421
- errors.push({ message: e instanceof Error ? e.message : String(e) });
1435
+ const errMsg = e instanceof Error ? e.message : String(e);
1436
+ console.error(`[warp_grep] Morph API call failed on turn ${turn}:`, errMsg);
1437
+ errors.push({ message: errMsg });
1422
1438
  return "";
1423
1439
  });
1424
1440
  turnMetrics.morph_api_ms = Date.now() - modelCallStart;
1425
1441
  if (!assistantContent) {
1442
+ console.error(`[warp_grep] Empty response from Morph API on turn ${turn}. Errors so far:`, errors);
1426
1443
  timings.turns.push(turnMetrics);
1427
1444
  break;
1428
1445
  }
1429
1446
  messages.push({ role: "assistant", content: assistantContent });
1430
1447
  const toolCalls = parser.parse(assistantContent);
1431
1448
  if (toolCalls.length === 0) {
1449
+ console.error(`[warp_grep] No tool calls parsed on turn ${turn}. Assistant content (first 500 chars):`, assistantContent.slice(0, 500));
1432
1450
  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" });
1433
1451
  terminationReason = "terminated";
1434
1452
  timings.turns.push(turnMetrics);
@@ -1738,7 +1756,9 @@ async function executeToolCall(input, config) {
1738
1756
  });
1739
1757
  const finish = result.finish;
1740
1758
  if (result.terminationReason !== "completed" || !finish?.metadata) {
1741
- return { success: false, error: "Search did not complete" };
1759
+ const errorDetails = result.errors?.map((e) => e.message).join("; ") || "unknown reason";
1760
+ console.error(`[warp_grep] executeToolCall failed. Reason: ${result.terminationReason}. Errors: ${errorDetails}. Turns: ${result.timings?.turns?.length ?? 0}`);
1761
+ return { success: false, error: `Search did not complete: ${errorDetails}` };
1742
1762
  }
1743
1763
  const contexts = (finish.resolved ?? []).map((r) => ({
1744
1764
  file: r.path,