@morphllm/morphsdk 0.2.115 → 0.2.117

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 (63) hide show
  1. package/dist/{chunk-SYZ75S3S.js → chunk-3JVHMOYJ.js} +2 -2
  2. package/dist/{chunk-SITZC3U6.js → chunk-5IVVJMMX.js} +2 -2
  3. package/dist/{chunk-CM75JPVD.js → chunk-5JARN2NG.js} +2 -2
  4. package/dist/{chunk-TZBDXZFC.js → chunk-C3LJORIT.js} +6 -6
  5. package/dist/{chunk-QOEZARHG.js → chunk-EAT5W3SH.js} +2 -2
  6. package/dist/{chunk-GQUNK324.js → chunk-GENFEPHG.js} +2 -2
  7. package/dist/{chunk-NTDAIKZI.js → chunk-OVNPKTEG.js} +2 -2
  8. package/dist/{chunk-25APYVON.js → chunk-PR44LEQQ.js} +2 -2
  9. package/dist/{chunk-RBTL6EJG.js → chunk-RBOCP2MX.js} +32 -18
  10. package/dist/chunk-RBOCP2MX.js.map +1 -0
  11. package/dist/{chunk-Q6Y4R236.js → chunk-YTYCHRQ2.js} +7 -9
  12. package/dist/{chunk-Q6Y4R236.js.map → chunk-YTYCHRQ2.js.map} +1 -1
  13. package/dist/{chunk-4IOC2D5Y.js → chunk-ZYPLV3HP.js} +2 -2
  14. package/dist/client.cjs +37 -25
  15. package/dist/client.cjs.map +1 -1
  16. package/dist/client.js +8 -8
  17. package/dist/index.cjs +37 -25
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.js +8 -8
  20. package/dist/tools/browser/anthropic.js +3 -3
  21. package/dist/tools/browser/core.cjs +6 -8
  22. package/dist/tools/browser/core.cjs.map +1 -1
  23. package/dist/tools/browser/core.js +2 -2
  24. package/dist/tools/browser/index.cjs +6 -8
  25. package/dist/tools/browser/index.cjs.map +1 -1
  26. package/dist/tools/browser/index.js +5 -5
  27. package/dist/tools/browser/live.cjs +6 -8
  28. package/dist/tools/browser/live.cjs.map +1 -1
  29. package/dist/tools/browser/live.js +1 -1
  30. package/dist/tools/browser/openai.js +3 -3
  31. package/dist/tools/browser/vercel.js +3 -3
  32. package/dist/tools/warp_grep/agent/runner.cjs +31 -17
  33. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
  34. package/dist/tools/warp_grep/agent/runner.js +1 -1
  35. package/dist/tools/warp_grep/anthropic.cjs +31 -17
  36. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  37. package/dist/tools/warp_grep/anthropic.js +3 -3
  38. package/dist/tools/warp_grep/client.cjs +31 -17
  39. package/dist/tools/warp_grep/client.cjs.map +1 -1
  40. package/dist/tools/warp_grep/client.js +2 -2
  41. package/dist/tools/warp_grep/gemini.cjs +31 -17
  42. package/dist/tools/warp_grep/gemini.cjs.map +1 -1
  43. package/dist/tools/warp_grep/gemini.js +2 -2
  44. package/dist/tools/warp_grep/index.cjs +31 -17
  45. package/dist/tools/warp_grep/index.cjs.map +1 -1
  46. package/dist/tools/warp_grep/index.js +2 -2
  47. package/dist/tools/warp_grep/openai.cjs +31 -17
  48. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  49. package/dist/tools/warp_grep/openai.js +3 -3
  50. package/dist/tools/warp_grep/vercel.cjs +31 -17
  51. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  52. package/dist/tools/warp_grep/vercel.js +3 -3
  53. package/package.json +1 -1
  54. package/dist/chunk-RBTL6EJG.js.map +0 -1
  55. /package/dist/{chunk-SYZ75S3S.js.map → chunk-3JVHMOYJ.js.map} +0 -0
  56. /package/dist/{chunk-SITZC3U6.js.map → chunk-5IVVJMMX.js.map} +0 -0
  57. /package/dist/{chunk-CM75JPVD.js.map → chunk-5JARN2NG.js.map} +0 -0
  58. /package/dist/{chunk-TZBDXZFC.js.map → chunk-C3LJORIT.js.map} +0 -0
  59. /package/dist/{chunk-QOEZARHG.js.map → chunk-EAT5W3SH.js.map} +0 -0
  60. /package/dist/{chunk-GQUNK324.js.map → chunk-GENFEPHG.js.map} +0 -0
  61. /package/dist/{chunk-NTDAIKZI.js.map → chunk-OVNPKTEG.js.map} +0 -0
  62. /package/dist/{chunk-25APYVON.js.map → chunk-PR44LEQQ.js.map} +0 -0
  63. /package/dist/{chunk-4IOC2D5Y.js.map → chunk-ZYPLV3HP.js.map} +0 -0
package/dist/client.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  MorphClient
3
- } from "./chunk-TZBDXZFC.js";
4
- import "./chunk-GQUNK324.js";
5
- import "./chunk-SYZ75S3S.js";
6
- import "./chunk-CM75JPVD.js";
3
+ } from "./chunk-C3LJORIT.js";
4
+ import "./chunk-GENFEPHG.js";
5
+ import "./chunk-3JVHMOYJ.js";
6
+ import "./chunk-5JARN2NG.js";
7
7
  import "./chunk-KW7OEGZK.js";
8
- import "./chunk-NTDAIKZI.js";
9
- import "./chunk-RBTL6EJG.js";
8
+ import "./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";
@@ -23,11 +23,11 @@ import "./chunk-Y5BB7JFH.js";
23
23
  import "./chunk-UNHHRMU7.js";
24
24
  import "./chunk-63WE2C5R.js";
25
25
  import "./chunk-M5DR2WOZ.js";
26
- import "./chunk-4IOC2D5Y.js";
26
+ import "./chunk-ZYPLV3HP.js";
27
27
  import "./chunk-SI2CKRKJ.js";
28
28
  import "./chunk-2AMEQAO2.js";
29
29
  import "./chunk-2VERUKO2.js";
30
- import "./chunk-Q6Y4R236.js";
30
+ import "./chunk-YTYCHRQ2.js";
31
31
  import "./chunk-FXBT4UDY.js";
32
32
  import "./chunk-GZMUGMOZ.js";
33
33
  import "./chunk-LE66XCOI.js";
package/dist/index.cjs CHANGED
@@ -1024,13 +1024,14 @@ function buildLiveUrl(debugUrl, options = {}) {
1024
1024
  }
1025
1025
  return url.toString();
1026
1026
  }
1027
+ function cdpToHttps(wsUrl) {
1028
+ return wsUrl.replace(/^wss:\/\//, "https://").replace(/^ws:\/\//, "http://");
1029
+ }
1027
1030
  function normalizeLiveUrl(debugUrl) {
1028
1031
  const trimmed = debugUrl.trim();
1029
- if (!trimmed) {
1030
- return trimmed;
1031
- }
1032
+ if (!trimmed) return trimmed;
1032
1033
  if (trimmed.startsWith("wss://") || trimmed.startsWith("ws://")) {
1033
- return `https://live.browser-use.com?wss=${encodeURIComponent(trimmed)}`;
1034
+ return `https://live.browser-use.com?wss=${encodeURIComponent(cdpToHttps(trimmed))}`;
1034
1035
  }
1035
1036
  let url;
1036
1037
  try {
@@ -1038,12 +1039,9 @@ function normalizeLiveUrl(debugUrl) {
1038
1039
  } catch {
1039
1040
  return trimmed;
1040
1041
  }
1041
- if (url.protocol === "wss:" || url.protocol === "ws:") {
1042
- return `https://live.browser-use.com?wss=${encodeURIComponent(trimmed)}`;
1043
- }
1044
1042
  const wssParam = url.searchParams.get("wss");
1045
1043
  if (wssParam && (wssParam.startsWith("wss://") || wssParam.startsWith("ws://"))) {
1046
- url.searchParams.set("wss", wssParam);
1044
+ url.searchParams.set("wss", cdpToHttps(wssParam));
1047
1045
  }
1048
1046
  return url.toString();
1049
1047
  }
@@ -3033,27 +3031,41 @@ async function callModel(messages, model, options = {}) {
3033
3031
  maxRetries: options.retryConfig?.maxRetries,
3034
3032
  timeout: timeoutMs
3035
3033
  });
3036
- let data;
3037
- try {
3038
- data = await client.chat.completions.create({
3039
- model,
3040
- temperature: 0,
3041
- max_tokens: 1024,
3042
- messages
3043
- });
3044
- } catch (error) {
3045
- if (error instanceof import_openai2.default.APIError && error.status === 404) {
3034
+ const MAX_EMPTY_RETRIES = 1;
3035
+ for (let attempt = 0; attempt <= MAX_EMPTY_RETRIES; attempt++) {
3036
+ let data;
3037
+ try {
3038
+ data = await client.chat.completions.create({
3039
+ model,
3040
+ temperature: 0,
3041
+ max_tokens: 1024,
3042
+ messages
3043
+ });
3044
+ } catch (error) {
3045
+ if (error instanceof import_openai2.default.APIError && error.status === 404) {
3046
+ throw new Error(
3047
+ "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"
3048
+ );
3049
+ }
3050
+ throw error;
3051
+ }
3052
+ const choice = data?.choices?.[0];
3053
+ const content = choice?.message?.content;
3054
+ if (content && typeof content === "string") {
3055
+ return content;
3056
+ }
3057
+ if (attempt === MAX_EMPTY_RETRIES) {
3058
+ const finishReason = choice?.finish_reason ?? "unknown";
3059
+ const hasToolCalls = Array.isArray(choice?.message?.tool_calls) && choice.message.tool_calls.length > 0;
3060
+ const choicesLen = data?.choices?.length ?? 0;
3061
+ const contentType = content === null ? "null" : content === void 0 ? "undefined" : typeof content;
3046
3062
  throw new Error(
3047
- "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"
3063
+ `Invalid response from model: content=${contentType}, finish_reason=${finishReason}, has_tool_calls=${hasToolCalls}, choices_length=${choicesLen}`
3048
3064
  );
3049
3065
  }
3050
- throw error;
3051
- }
3052
- const content = data?.choices?.[0]?.message?.content;
3053
- if (!content || typeof content !== "string") {
3054
- throw new Error("Invalid response from model");
3066
+ await new Promise((resolve2) => setTimeout(resolve2, 200));
3055
3067
  }
3056
- return content;
3068
+ throw new Error("Invalid response from model");
3057
3069
  }
3058
3070
  async function runWarpGrep(config) {
3059
3071
  const totalStart = Date.now();