@morphllm/morphsdk 0.2.82 → 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 (43) hide show
  1. package/dist/{chunk-EK5ZEOI3.js → chunk-HPR6BJA7.js} +5 -5
  2. package/dist/{chunk-FJKPMMNQ.js → chunk-HRK53IKL.js} +2 -2
  3. package/dist/{chunk-24EYSWME.js → chunk-LXG37353.js} +2 -2
  4. package/dist/{chunk-WIAYUEJK.js → chunk-QOYI77CN.js} +25 -5
  5. package/dist/chunk-QOYI77CN.js.map +1 -0
  6. package/dist/{chunk-ZLJAODDJ.js → chunk-RL4JBZ3T.js} +2 -2
  7. package/dist/{chunk-3ONNAQZU.js → chunk-S27A4NQM.js} +2 -2
  8. package/dist/client.cjs +24 -4
  9. package/dist/client.cjs.map +1 -1
  10. package/dist/client.js +6 -6
  11. package/dist/index.cjs +24 -4
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.js +6 -6
  14. package/dist/tools/warp_grep/agent/runner.cjs +24 -4
  15. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
  16. package/dist/tools/warp_grep/agent/runner.js +1 -1
  17. package/dist/tools/warp_grep/agent/types.cjs.map +1 -1
  18. package/dist/tools/warp_grep/agent/types.d.ts +14 -1
  19. package/dist/tools/warp_grep/anthropic.cjs +24 -4
  20. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  21. package/dist/tools/warp_grep/anthropic.js +3 -3
  22. package/dist/tools/warp_grep/client.cjs +24 -4
  23. package/dist/tools/warp_grep/client.cjs.map +1 -1
  24. package/dist/tools/warp_grep/client.js +2 -2
  25. package/dist/tools/warp_grep/gemini.cjs +24 -4
  26. package/dist/tools/warp_grep/gemini.cjs.map +1 -1
  27. package/dist/tools/warp_grep/gemini.js +2 -2
  28. package/dist/tools/warp_grep/index.cjs +24 -4
  29. package/dist/tools/warp_grep/index.cjs.map +1 -1
  30. package/dist/tools/warp_grep/index.js +2 -2
  31. package/dist/tools/warp_grep/openai.cjs +24 -4
  32. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  33. package/dist/tools/warp_grep/openai.js +3 -3
  34. package/dist/tools/warp_grep/vercel.cjs +24 -4
  35. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  36. package/dist/tools/warp_grep/vercel.js +3 -3
  37. package/package.json +1 -1
  38. package/dist/chunk-WIAYUEJK.js.map +0 -1
  39. /package/dist/{chunk-EK5ZEOI3.js.map → chunk-HPR6BJA7.js.map} +0 -0
  40. /package/dist/{chunk-FJKPMMNQ.js.map → chunk-HRK53IKL.js.map} +0 -0
  41. /package/dist/{chunk-24EYSWME.js.map → chunk-LXG37353.js.map} +0 -0
  42. /package/dist/{chunk-ZLJAODDJ.js.map → chunk-RL4JBZ3T.js.map} +0 -0
  43. /package/dist/{chunk-3ONNAQZU.js.map → chunk-S27A4NQM.js.map} +0 -0
package/dist/client.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  MorphClient
3
- } from "./chunk-EK5ZEOI3.js";
4
- import "./chunk-ZLJAODDJ.js";
5
- import "./chunk-24EYSWME.js";
6
- import "./chunk-3ONNAQZU.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-FJKPMMNQ.js";
9
- import "./chunk-WIAYUEJK.js";
8
+ import "./chunk-HRK53IKL.js";
9
+ import "./chunk-QOYI77CN.js";
10
10
  import "./chunk-PUGSTXLO.js";
11
11
  import "./chunk-P2O5JKE5.js";
12
12
  import "./chunk-APP75CBN.js";
package/dist/index.cjs CHANGED
@@ -1896,10 +1896,15 @@ async function callModel(messages, model, options = {}) {
1896
1896
  return content;
1897
1897
  }
1898
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 };
1899
1902
  const repoRoot = import_path3.default.resolve(config.repoRoot || process.cwd());
1900
1903
  const messages = [];
1901
1904
  messages.push({ role: "system", content: getSystemPrompt() });
1905
+ const initialStateStart = Date.now();
1902
1906
  const initialState = await buildInitialState(repoRoot, config.query, config.provider);
1907
+ timings.initial_state_ms = Date.now() - initialStateStart;
1903
1908
  messages.push({ role: "user", content: initialState });
1904
1909
  const maxTurns = AGENT_CONFIG.MAX_TURNS;
1905
1910
  const model = config.model || DEFAULT_MODEL;
@@ -1908,22 +1913,29 @@ async function runWarpGrep(config) {
1908
1913
  let finishMeta;
1909
1914
  let terminationReason = "terminated";
1910
1915
  for (let turn = 1; turn <= maxTurns; turn += 1) {
1916
+ const turnMetrics = { turn, morph_api_ms: 0, local_tools_ms: 0 };
1911
1917
  enforceContextLimit(messages);
1918
+ const modelCallStart = Date.now();
1912
1919
  const assistantContent = await callModel(messages, model, {
1913
1920
  morphApiKey: config.morphApiKey,
1914
1921
  morphApiUrl: config.morphApiUrl,
1915
1922
  retryConfig: config.retryConfig,
1916
- timeout: config.timeout
1923
+ timeout: timeoutMs
1917
1924
  }).catch((e) => {
1918
1925
  errors.push({ message: e instanceof Error ? e.message : String(e) });
1919
1926
  return "";
1920
1927
  });
1921
- if (!assistantContent) break;
1928
+ turnMetrics.morph_api_ms = Date.now() - modelCallStart;
1929
+ if (!assistantContent) {
1930
+ timings.turns.push(turnMetrics);
1931
+ break;
1932
+ }
1922
1933
  messages.push({ role: "assistant", content: assistantContent });
1923
1934
  const toolCalls = parser.parse(assistantContent);
1924
1935
  if (toolCalls.length === 0) {
1925
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" });
1926
1937
  terminationReason = "terminated";
1938
+ timings.turns.push(turnMetrics);
1927
1939
  break;
1928
1940
  }
1929
1941
  const finishCalls = toolCalls.filter((c) => c.name === "finish");
@@ -1964,7 +1976,9 @@ async function runWarpGrep(config) {
1964
1976
  )
1965
1977
  );
1966
1978
  }
1979
+ const toolExecStart = Date.now();
1967
1980
  const allResults = await Promise.all(allPromises);
1981
+ turnMetrics.local_tools_ms = Date.now() - toolExecStart;
1968
1982
  for (const result of allResults) {
1969
1983
  formatted.push(result);
1970
1984
  }
@@ -1973,6 +1987,7 @@ async function runWarpGrep(config) {
1973
1987
  const contextBudget = calculateContextBudget(messages);
1974
1988
  messages.push({ role: "user", content: formatted.join("\n") + turnMessage + "\n" + contextBudget });
1975
1989
  }
1990
+ timings.turns.push(turnMetrics);
1976
1991
  if (finishCalls.length) {
1977
1992
  const fc = finishCalls[0];
1978
1993
  const files = fc.arguments?.files ?? [];
@@ -1982,7 +1997,8 @@ async function runWarpGrep(config) {
1982
1997
  }
1983
1998
  }
1984
1999
  if (terminationReason !== "completed" || !finishMeta) {
1985
- return { terminationReason, messages, errors };
2000
+ timings.total_ms = Date.now() - totalStart;
2001
+ return { terminationReason, messages, errors, timings };
1986
2002
  }
1987
2003
  const parts = ["Relevant context found:"];
1988
2004
  for (const f of finishMeta.files) {
@@ -1990,6 +2006,7 @@ async function runWarpGrep(config) {
1990
2006
  parts.push(`- ${f.path}: ${ranges}`);
1991
2007
  }
1992
2008
  const payload = parts.join("\n");
2009
+ const finishResolutionStart = Date.now();
1993
2010
  const fileReadErrors = [];
1994
2011
  const resolved = await readFinishFiles(
1995
2012
  repoRoot,
@@ -2009,13 +2026,16 @@ async function runWarpGrep(config) {
2009
2026
  }
2010
2027
  }
2011
2028
  );
2029
+ timings.finish_resolution_ms = Date.now() - finishResolutionStart;
2012
2030
  if (fileReadErrors.length > 0) {
2013
2031
  errors.push(...fileReadErrors.map((e) => ({ message: `File read error: ${e.path} - ${e.error}` })));
2014
2032
  }
2033
+ timings.total_ms = Date.now() - totalStart;
2015
2034
  return {
2016
2035
  terminationReason: "completed",
2017
2036
  messages,
2018
- finish: { payload, metadata: finishMeta, resolved }
2037
+ finish: { payload, metadata: finishMeta, resolved },
2038
+ timings
2019
2039
  };
2020
2040
  }
2021
2041