@morphllm/morphsdk 0.2.81 → 0.2.83

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 (77) hide show
  1. package/dist/{chunk-4NI25AKV.js → chunk-4KMBU6T3.js} +2 -2
  2. package/dist/{chunk-XT5ZO6ES.js → chunk-5PNMAWLC.js} +8 -2
  3. package/dist/chunk-5PNMAWLC.js.map +1 -0
  4. package/dist/{chunk-X6A64F2F.js → chunk-HPR6BJA7.js} +5 -5
  5. package/dist/{chunk-4VMIPD4G.js → chunk-HRK53IKL.js} +8 -6
  6. package/dist/chunk-HRK53IKL.js.map +1 -0
  7. package/dist/{chunk-NTTQJM6O.js → chunk-LXG37353.js} +2 -2
  8. package/dist/{chunk-467MCW5R.js → chunk-P2O5JKE5.js} +2 -2
  9. package/dist/{chunk-PHJQ4N3T.js → chunk-PUGSTXLO.js} +2 -2
  10. package/dist/{chunk-B3UC7UVA.js → chunk-QOYI77CN.js} +30 -8
  11. package/dist/chunk-QOYI77CN.js.map +1 -0
  12. package/dist/{chunk-Z2HDXUH7.js → chunk-RL4JBZ3T.js} +2 -2
  13. package/dist/{chunk-OFMDENAQ.js → chunk-S27A4NQM.js} +2 -2
  14. package/dist/{client-CSINf0lQ.d.ts → client-CsO9LifG.d.ts} +1 -1
  15. package/dist/client.cjs +38 -8
  16. package/dist/client.cjs.map +1 -1
  17. package/dist/client.d.ts +2 -2
  18. package/dist/client.js +10 -10
  19. package/dist/index.cjs +38 -8
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.js +10 -10
  23. package/dist/tools/warp_grep/agent/config.cjs +7 -1
  24. package/dist/tools/warp_grep/agent/config.cjs.map +1 -1
  25. package/dist/tools/warp_grep/agent/config.d.ts +1 -0
  26. package/dist/tools/warp_grep/agent/config.js +1 -1
  27. package/dist/tools/warp_grep/agent/runner.cjs +34 -6
  28. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
  29. package/dist/tools/warp_grep/agent/runner.js +3 -3
  30. package/dist/tools/warp_grep/agent/types.cjs.map +1 -1
  31. package/dist/tools/warp_grep/agent/types.d.ts +16 -1
  32. package/dist/tools/warp_grep/anthropic.cjs +36 -7
  33. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  34. package/dist/tools/warp_grep/anthropic.d.ts +1 -1
  35. package/dist/tools/warp_grep/anthropic.js +7 -7
  36. package/dist/tools/warp_grep/client.cjs +38 -8
  37. package/dist/tools/warp_grep/client.cjs.map +1 -1
  38. package/dist/tools/warp_grep/client.d.ts +1 -1
  39. package/dist/tools/warp_grep/client.js +6 -6
  40. package/dist/tools/warp_grep/gemini.cjs +36 -7
  41. package/dist/tools/warp_grep/gemini.cjs.map +1 -1
  42. package/dist/tools/warp_grep/gemini.d.ts +1 -1
  43. package/dist/tools/warp_grep/gemini.js +6 -6
  44. package/dist/tools/warp_grep/harness.cjs +7 -1
  45. package/dist/tools/warp_grep/harness.cjs.map +1 -1
  46. package/dist/tools/warp_grep/harness.js +3 -3
  47. package/dist/tools/warp_grep/index.cjs +38 -8
  48. package/dist/tools/warp_grep/index.cjs.map +1 -1
  49. package/dist/tools/warp_grep/index.d.ts +1 -1
  50. package/dist/tools/warp_grep/index.js +6 -6
  51. package/dist/tools/warp_grep/openai.cjs +36 -7
  52. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  53. package/dist/tools/warp_grep/openai.d.ts +1 -1
  54. package/dist/tools/warp_grep/openai.js +7 -7
  55. package/dist/tools/warp_grep/providers/local.cjs +7 -1
  56. package/dist/tools/warp_grep/providers/local.cjs.map +1 -1
  57. package/dist/tools/warp_grep/providers/local.js +2 -2
  58. package/dist/tools/warp_grep/providers/remote.cjs +7 -1
  59. package/dist/tools/warp_grep/providers/remote.cjs.map +1 -1
  60. package/dist/tools/warp_grep/providers/remote.d.ts +1 -1
  61. package/dist/tools/warp_grep/providers/remote.js +2 -2
  62. package/dist/tools/warp_grep/vercel.cjs +36 -7
  63. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  64. package/dist/tools/warp_grep/vercel.d.ts +1 -1
  65. package/dist/tools/warp_grep/vercel.js +7 -7
  66. package/dist/{types-CnvVDM63.d.ts → types-Cv4LpqVl.d.ts} +2 -0
  67. package/package.json +1 -1
  68. package/dist/chunk-4VMIPD4G.js.map +0 -1
  69. package/dist/chunk-B3UC7UVA.js.map +0 -1
  70. package/dist/chunk-XT5ZO6ES.js.map +0 -1
  71. /package/dist/{chunk-4NI25AKV.js.map → chunk-4KMBU6T3.js.map} +0 -0
  72. /package/dist/{chunk-X6A64F2F.js.map → chunk-HPR6BJA7.js.map} +0 -0
  73. /package/dist/{chunk-NTTQJM6O.js.map → chunk-LXG37353.js.map} +0 -0
  74. /package/dist/{chunk-467MCW5R.js.map → chunk-P2O5JKE5.js.map} +0 -0
  75. /package/dist/{chunk-PHJQ4N3T.js.map → chunk-PUGSTXLO.js.map} +0 -0
  76. /package/dist/{chunk-Z2HDXUH7.js.map → chunk-RL4JBZ3T.js.map} +0 -0
  77. /package/dist/{chunk-OFMDENAQ.js.map → chunk-S27A4NQM.js.map} +0 -0
package/dist/client.d.ts CHANGED
@@ -5,11 +5,11 @@ import './tools/browser/core.js';
5
5
  import './tools/warp_grep/client.js';
6
6
  import './git/client.js';
7
7
  import './modelrouter/core.js';
8
- export { M as MorphClient, a as MorphClientConfig } from './client-CSINf0lQ.js';
8
+ export { M as MorphClient, a as MorphClientConfig } from './client-CsO9LifG.js';
9
9
  import './tools/fastapply/types.js';
10
10
  import './tools/codebase_search/types.js';
11
11
  import './tools/browser/types.js';
12
- import './types-CnvVDM63.js';
12
+ import './types-Cv4LpqVl.js';
13
13
  import './tools/warp_grep/providers/types.js';
14
14
  import './git/types.js';
15
15
  import 'isomorphic-git';
package/dist/client.js CHANGED
@@ -1,22 +1,22 @@
1
1
  import {
2
2
  MorphClient
3
- } from "./chunk-X6A64F2F.js";
4
- import "./chunk-Z2HDXUH7.js";
5
- import "./chunk-NTTQJM6O.js";
6
- import "./chunk-OFMDENAQ.js";
3
+ } from "./chunk-HPR6BJA7.js";
4
+ import "./chunk-RL4JBZ3T.js";
5
+ import "./chunk-LXG37353.js";
6
+ import "./chunk-S27A4NQM.js";
7
7
  import "./chunk-KW7OEGZK.js";
8
- import "./chunk-4VMIPD4G.js";
9
- import "./chunk-B3UC7UVA.js";
10
- import "./chunk-PHJQ4N3T.js";
11
- import "./chunk-467MCW5R.js";
8
+ import "./chunk-HRK53IKL.js";
9
+ import "./chunk-QOYI77CN.js";
10
+ import "./chunk-PUGSTXLO.js";
11
+ import "./chunk-P2O5JKE5.js";
12
12
  import "./chunk-APP75CBN.js";
13
13
  import "./chunk-5QRN3JNB.js";
14
14
  import "./chunk-FMLHRJDF.js";
15
- import "./chunk-4NI25AKV.js";
15
+ import "./chunk-4KMBU6T3.js";
16
16
  import "./chunk-G2RSY56Q.js";
17
17
  import "./chunk-YPKNMYD4.js";
18
18
  import "./chunk-TPP2UGQP.js";
19
- import "./chunk-XT5ZO6ES.js";
19
+ import "./chunk-5PNMAWLC.js";
20
20
  import "./chunk-UBX7QYBD.js";
21
21
  import "./chunk-GJU7UOFL.js";
22
22
  import "./chunk-76DJEQEP.js";
package/dist/index.cjs CHANGED
@@ -1001,9 +1001,15 @@ async function checkHealth(config = {}) {
1001
1001
  }
1002
1002
 
1003
1003
  // tools/warp_grep/agent/config.ts
1004
+ var parseEnvTimeout = (envValue, defaultMs) => {
1005
+ if (!envValue) return defaultMs;
1006
+ const parsed = parseInt(envValue, 10);
1007
+ return isNaN(parsed) || parsed <= 0 ? defaultMs : parsed;
1008
+ };
1004
1009
  var AGENT_CONFIG = {
1005
1010
  MAX_TURNS: 4,
1006
- TIMEOUT_MS: 3e4,
1011
+ /** Default timeout for model calls. Can be overridden via MORPH_WARP_GREP_TIMEOUT env var (in ms) */
1012
+ TIMEOUT_MS: parseEnvTimeout(process.env.MORPH_WARP_GREP_TIMEOUT, 3e4),
1007
1013
  MAX_CONTEXT_CHARS: 54e4,
1008
1014
  MAX_OUTPUT_LINES: 200,
1009
1015
  MAX_READ_LINES: 800,
@@ -1871,7 +1877,8 @@ async function callModel(messages, model, options = {}) {
1871
1877
  },
1872
1878
  options.retryConfig
1873
1879
  );
1874
- const resp = await withTimeout(fetchPromise, AGENT_CONFIG.TIMEOUT_MS, "morph-warp-grep request timed out");
1880
+ const timeoutMs = options.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
1881
+ const resp = await withTimeout(fetchPromise, timeoutMs, "morph-warp-grep request timed out");
1875
1882
  if (!resp.ok) {
1876
1883
  if (resp.status === 404) {
1877
1884
  throw new Error(
@@ -1889,10 +1896,15 @@ async function callModel(messages, model, options = {}) {
1889
1896
  return content;
1890
1897
  }
1891
1898
  async function runWarpGrep(config) {
1899
+ const totalStart = Date.now();
1900
+ const timeoutMs = config.timeout ?? AGENT_CONFIG.TIMEOUT_MS;
1901
+ const timings = { turns: [], timeout_ms: timeoutMs };
1892
1902
  const repoRoot = import_path3.default.resolve(config.repoRoot || process.cwd());
1893
1903
  const messages = [];
1894
1904
  messages.push({ role: "system", content: getSystemPrompt() });
1905
+ const initialStateStart = Date.now();
1895
1906
  const initialState = await buildInitialState(repoRoot, config.query, config.provider);
1907
+ timings.initial_state_ms = Date.now() - initialStateStart;
1896
1908
  messages.push({ role: "user", content: initialState });
1897
1909
  const maxTurns = AGENT_CONFIG.MAX_TURNS;
1898
1910
  const model = config.model || DEFAULT_MODEL;
@@ -1901,21 +1913,29 @@ async function runWarpGrep(config) {
1901
1913
  let finishMeta;
1902
1914
  let terminationReason = "terminated";
1903
1915
  for (let turn = 1; turn <= maxTurns; turn += 1) {
1916
+ const turnMetrics = { turn, morph_api_ms: 0, local_tools_ms: 0 };
1904
1917
  enforceContextLimit(messages);
1918
+ const modelCallStart = Date.now();
1905
1919
  const assistantContent = await callModel(messages, model, {
1906
1920
  morphApiKey: config.morphApiKey,
1907
1921
  morphApiUrl: config.morphApiUrl,
1908
- retryConfig: config.retryConfig
1922
+ retryConfig: config.retryConfig,
1923
+ timeout: timeoutMs
1909
1924
  }).catch((e) => {
1910
1925
  errors.push({ message: e instanceof Error ? e.message : String(e) });
1911
1926
  return "";
1912
1927
  });
1913
- if (!assistantContent) break;
1928
+ turnMetrics.morph_api_ms = Date.now() - modelCallStart;
1929
+ if (!assistantContent) {
1930
+ timings.turns.push(turnMetrics);
1931
+ break;
1932
+ }
1914
1933
  messages.push({ role: "assistant", content: assistantContent });
1915
1934
  const toolCalls = parser.parse(assistantContent);
1916
1935
  if (toolCalls.length === 0) {
1917
1936
  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" });
1918
1937
  terminationReason = "terminated";
1938
+ timings.turns.push(turnMetrics);
1919
1939
  break;
1920
1940
  }
1921
1941
  const finishCalls = toolCalls.filter((c) => c.name === "finish");
@@ -1956,7 +1976,9 @@ async function runWarpGrep(config) {
1956
1976
  )
1957
1977
  );
1958
1978
  }
1979
+ const toolExecStart = Date.now();
1959
1980
  const allResults = await Promise.all(allPromises);
1981
+ turnMetrics.local_tools_ms = Date.now() - toolExecStart;
1960
1982
  for (const result of allResults) {
1961
1983
  formatted.push(result);
1962
1984
  }
@@ -1965,6 +1987,7 @@ async function runWarpGrep(config) {
1965
1987
  const contextBudget = calculateContextBudget(messages);
1966
1988
  messages.push({ role: "user", content: formatted.join("\n") + turnMessage + "\n" + contextBudget });
1967
1989
  }
1990
+ timings.turns.push(turnMetrics);
1968
1991
  if (finishCalls.length) {
1969
1992
  const fc = finishCalls[0];
1970
1993
  const files = fc.arguments?.files ?? [];
@@ -1974,7 +1997,8 @@ async function runWarpGrep(config) {
1974
1997
  }
1975
1998
  }
1976
1999
  if (terminationReason !== "completed" || !finishMeta) {
1977
- return { terminationReason, messages, errors };
2000
+ timings.total_ms = Date.now() - totalStart;
2001
+ return { terminationReason, messages, errors, timings };
1978
2002
  }
1979
2003
  const parts = ["Relevant context found:"];
1980
2004
  for (const f of finishMeta.files) {
@@ -1982,6 +2006,7 @@ async function runWarpGrep(config) {
1982
2006
  parts.push(`- ${f.path}: ${ranges}`);
1983
2007
  }
1984
2008
  const payload = parts.join("\n");
2009
+ const finishResolutionStart = Date.now();
1985
2010
  const fileReadErrors = [];
1986
2011
  const resolved = await readFinishFiles(
1987
2012
  repoRoot,
@@ -2001,13 +2026,16 @@ async function runWarpGrep(config) {
2001
2026
  }
2002
2027
  }
2003
2028
  );
2029
+ timings.finish_resolution_ms = Date.now() - finishResolutionStart;
2004
2030
  if (fileReadErrors.length > 0) {
2005
2031
  errors.push(...fileReadErrors.map((e) => ({ message: `File read error: ${e.path} - ${e.error}` })));
2006
2032
  }
2033
+ timings.total_ms = Date.now() - totalStart;
2007
2034
  return {
2008
2035
  terminationReason: "completed",
2009
2036
  messages,
2010
- finish: { payload, metadata: finishMeta, resolved }
2037
+ finish: { payload, metadata: finishMeta, resolved },
2038
+ timings
2011
2039
  };
2012
2040
  }
2013
2041
 
@@ -2636,7 +2664,8 @@ var WarpGrepClient = class {
2636
2664
  debug: input.debug ?? this.config.debug,
2637
2665
  morphApiKey: this.config.morphApiKey,
2638
2666
  morphApiUrl: this.config.morphApiUrl,
2639
- retryConfig: this.config.retryConfig
2667
+ retryConfig: this.config.retryConfig,
2668
+ timeout: this.config.timeout
2640
2669
  }
2641
2670
  );
2642
2671
  }
@@ -2653,7 +2682,8 @@ async function executeToolCall(input, config) {
2653
2682
  debug: config.debug ?? false,
2654
2683
  morphApiKey: config.morphApiKey,
2655
2684
  morphApiUrl: config.morphApiUrl,
2656
- retryConfig: config.retryConfig
2685
+ retryConfig: config.retryConfig,
2686
+ timeout: config.timeout
2657
2687
  });
2658
2688
  const finish = result.finish;
2659
2689
  if (result.terminationReason !== "completed" || !finish?.metadata) {